Member Junction
    Preparing search index...

    Runtime extension of ComponentSpec that provides helper methods for permission checking, validation, and other runtime operations. This class is not included in AI prompts to keep token usage efficient.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    changeRequest?: ComponentChangeRequest

    Current change request being processed, if any. Populated by Impact Assessor at the start of a modification flow. Updated by each agent as it processes the request.

    This field is only present during active modification flows and for embedded components (never on registry components).

    code: string

    JavaScript code

    componentRole?: ComponentRole

    Declares the contract this component implements.

    Distinct from type (which is descriptive): componentRole is a commitment that the component's props, events, and methods conform to a role-specific contract, letting hosts mount it generically and letting authoring agents target a known shape.

    • form: implements FormHostProps + standard form events/methods (see @memberjunction/interactivecomponents/forms). Hosted by InteractiveFormComponent against a BaseEntity record.
    • dashboard | widget | report | detail-pane: reserved for future role contracts.

    Unset = a generic component, mounted directly. No behavior change for existing components.

    createNewVersion?: boolean

    When an architect decides to use an existing component as a base for a new version, they can set this flag to true. This indicates that the new version will be created based on the existing component based on the namespace/name/version specified above

    dataRequirements?: ComponentDataRequirements

    Describes the entities and queries a component requires to function.

    dependencies?: ComponentSpec[]

    Describes any other components this one depends on, if any

    description: string

    End-user friendly description of what the component does

    diagrams?: { content: string; description?: string; title: string }[]

    Optional array of diagrams that use Mermaid syntax to illustrate component design. When provided each entry in the array specifies a title, optional description and the mermaid content itself. Examples of diagrams include:

    • Flowcharts of the process the component implements
    • Entity-relationship diagrams of the data model the component uses
    • Sequence diagrams illustrating interactions between the components various parts
    events?: ComponentEvent[]

    Events that the component emits, if any

    exampleUsage: string

    Example of the component being used in JSX format. This is used to provide a clear example on the properties and event handling that the component supports.

    functionalRequirements: string

    A functional description of what the component should do in markdown.

    Describes:

    • Core functionality
    • Any business rules
    • Expected outcomes
    • UX considerations
    latestTestResult?: ComponentTestResult

    Result of the most recent test harness execution. Tells downstream agents whether the current code is working or broken.

    Only populated for embedded components after code generation completes. Registry components do not have test results as they are pre-tested.

    3rd party lib dependencies, if any

    location: "embedded" | "registry"

    Components can be embedded or registry. Registry means we don't have the code directly here nor do we generate the code, we simply use the component from its registry

    Metadata about methods the component supports, if any

    name: string
    namespace?: string

    Used when location === "registry", a hierarchical namespace such as "crm/analytics/accounts". The combination of the namespace and name are how a registry component is loaded. Registry components might have a root level segment that starts with @ such as "@memberjunction/examples/entities" or if the root segment doesn't have @ that means the component is local to that registry

    properties?: ComponentProperty[]

    Properties the component accepts, if any

    readinessLevel?: "incomplete" | "beta" | "production"

    Self-declared maturity level of the component. When a component is "in progress" and is not yet complete but is partially done, it can be marked as "incomplete". When it is functionally complete but not yet widely tested, it can be marked as "beta". When it is fully complete and tested, it can be marked as "production". This is intended to help architects and developers understand the readiness of a component for use in production systems.

    registry?: string

    Used when location === 'registry' - the unique name of a given registry without the @ sign for example MJ or Skip would be valid globally unique registry names (as registered with MemberJunction.org) You would not include @ here. Fully qualified component identifiers would be @Registry/Namespace/Name/Version but in the context of this field it is just the registry name.

    relevantExamples?: ComponentExample[]

    Relevant examples of components intended to inspire this component's creation

    selectionReasoning?: string

    Only used when location === 'registry', logic explaining why this component is being selected to serve a specific use case or requirement

    technicalDesign: string

    Technical explanation of the component in markdown.

    title: string

    User-friendly name

    type: string

    Self-declared type - some common options below, can be any string if the standard ones aren't sufficient

    typeDefinitions?: Record<string, ComponentTypeDefinition>

    Optional: Custom type definitions for complex prop types (e.g., ColumnDef, FieldDefinition). Similar to TypeScript interfaces, used for lint-time validation of object literals.

    version?: string

    Used when location === "registry", a semantic versioning string such as "1.0.0" "^1.0.0" "~1.0.0" Follows conventions documented here: https://semver.org/ and https://docs.npmjs.com/about-semantic-versioning

    workPlan?: string

    If a component isn't complete or encounters problems in testing, this field can be used to track a work plan for completing or fixing the component. Generally this work plan string will contain a markdown formatted list of tasks to be done with rich explanations to allow developers (human+AI) to collaborate on completing the component.

    Accessors

    Methods

    • Check if this component depends on a specific library. Can check by either library name or global variable.

      Parameters

      • libraryNameOrGlobal: string

        Library name or global variable to check

      Returns boolean

      true if the component depends on the specified library

    • Get all entity names that this component accesses. Useful for pre-loading permissions or understanding component data dependencies.

      Returns string[]

      Array of entity names accessed by the component

    • Get all component dependencies recursively. Traverses the entire dependency tree to return a flat list of all components this one depends on, directly or indirectly.

      Parameters

      • visitedNames: Set<string> = ...

        Set of already visited component names (for cycle detection)

      Returns ComponentSpec[]

      Array of all component dependencies

    • Get a summary of all data access patterns for this component. Useful for documentation and understanding component behavior.

      Returns {
          entities: { name: string; permissions: string[] }[];
          entityCount: number;
          mode: string;
          queries: { category: string; name: string }[];
          queryCount: number;
          requiresWrite: boolean;
      }

      Object describing all data access patterns

    • Check if the component has any write capabilities (create, update, or delete). This helps determine if the component can modify data or is purely read-only.

      Returns boolean

      true if the component requires any write permissions

    • Check if the component only requires read permissions across all entities. This is useful for determining if a component is effectively read-only from a permissions perspective.

      Returns boolean

      true if the component only requires 'read' permissions

    • Validate that a user has all required permissions to use this component. This method checks each entity's permission requirements against the user's actual permissions in MemberJunction using the Metadata system.

      Parameters

      • user: UserInfo

        The MemberJunction UserInfo object

      Returns Promise<
          {
              canRender: boolean;
              degradedPermissions: {
                  entity: string;
                  permission: ComponentEntitySimplePermission;
                  reason: string;
              }[];
              missingPermissions: {
                  entity: string;
                  permission: ComponentEntitySimplePermission;
              }[];
          },
      >

      Validation result with details about any missing permissions