Member Junction
    Preparing search index...

    Specialized client that is designed to be used exclusively on the server side by the System User using the MJ API KEY. This is designed to allow server side code such as within the context of an MJAPI server to talk to another MAJPI server but as the client.

    It is possible for a server to use the regular

    client to talk to another MJAPI server, but that would require the server to have a user account and the server would have to be able to log in as that user via a JWT token. This is not always possible or convenient in the flow.

    Also the standard client configuration process has a certain amount over overhead in always loading up certain metadata that is not necessary for many system user operations.

    Finaly, this client can be used in parallel with the regular client to allow a server to mix and match the two as needed.

    Index

    Constructors

    • Parameters

      • url: string

        MJAPI server URL

      • token: string

        Optional, JWT token that is used for a normal user authentication flow. This is required if mjAPIKey is not provided.

      • sessionId: string

        Optional, UUID that is used to track a session. This can be any string.

      • mjAPIKey: string

        Shared Secret key that is provided for system user authentication. This is required if token is not provided.

      Returns GraphQLSystemUserClient

    Accessors

    • get Client(): GraphQLClient

      Returns the underlying GraphQL client which is an instance of the GraphQLClient object from the graphql-request package. This is useful if you want to perform any operation that is not directly supported by this class via specialized methods.

      Returns GraphQLClient

    Methods

    • This method will return a list of all entities that are available on the remote server. This is a lightweight call that only returns the basic metadata for each entity and does not include all of the attributes at either the entity or the field level. This is useful for getting a list of entities that are available on the remote server and knowing their IDs and Entity Field IDs on the remote server. For core MemberJunction entities and entity fields, the ID values are globally unique and set by the MemberJunction distribution, however, for other entities that are generated on each target system they can vary so it is best to use lookups name or a combination of SchemaName and BaseTable to uniquely identify an entity.

      Returns Promise<SimpleRemoteEntityOutput>

    • Calls the GetData() query on the server to execute any number of provided SQL queries in parallel and returns the results. The queries MUST BE read only and not perform any DML operations. The remote server will execute the queries using a special lower-privilege user that is not allowed to perform any form of write operations.

      Parameters

      • queries: string[]

        an array of SQL queries to execute on the remote server

      • accessToken: string

        the short-lived access token that is required to perform this operation. This is different from the MJAPI key and is used for a second factor and is a short-lived token. You will receive this token when an MJAPI calls your server to request something along with the URL to call back.

      Returns Promise<GetDataOutput>

    • This method is used to invoke the data synchronization mutation on the remote server. This method is used to create, update, or delete records in the remote server. The method takes an array of ActionItemInput objects Each of the ActionItemInput objects represents a single action to take on a single entity. The action can be Create, Update, CreateOrUpdate, Delete, or DeleteWithFilter. The RecordJSON field is used for Create, CreateOrUpdate and Update whereas the DeleteFilter field is used for DeleteWithFilter. The PrimaryKey and AlternateKey fields are used to identify the record to be acted upon.

      Use of the AlternateKey is important for situations where you might have divergent primary keys across systems. For example for user entities that are individually generated on each system by CodeGen, the primary key will be different per system, so you would use the combination of the SchemaName and BaseTable to identify the entity and then use the AlternateKey to provide the combination of these fields to uniquely identify the record for updates.

      Parameters

      Returns Promise<SyncDataResult>