Member Junction
    Preparing search index...

    Read-only connector that pulls conversational data (Conversations, Conversation Details, optional AI Agent Runs/Steps, reference Users and Agents) from a remote, self-hosted MemberJunction GraphQL API into this MJ's native conversation entities.

    Destination mapping on this MJ:

    • Conversations -> MJ: Conversations
    • ConversationDetails -> MJ: Conversation Details
    • AIAgents / Users / AIAgentRuns / AIAgentRunSteps are reference-only by default and not auto-mapped to MJ entities.

    Design notes:

    • Extends BaseIntegrationConnector directly (not REST) because MJ uses GraphQL, not REST-over-HTTP-verbs.
    • No dependency on @memberjunction/graphql-data-provider — we POST plain GraphQL over fetch to keep the dependency surface minimal.
    • The GraphQL query is built from IntegrationObject metadata — the connector does NOT switch on entity names. DefaultQueryParams carries the graphql_fields selection, watermark_field, and mj_target_entity / mj_field_map hints.
    • MJ's GraphQL filter convention is ExtraFilter — a SQL-like WHERE clause. We build the filter string from the watermark, escaping the datetime literal, and send it as a GraphQL variable ($extraFilter: String) rather than interpolating into the query text. This avoids injection from the watermark value.
    • Pagination is offset/limit via MJ's skip / top args.
    • 200 OK with non-empty errors[] is treated as a transient failure and retried like a 5xx.

    Configuration shape:

    {
    "GraphQLEndpoint": "https://mj.customer.org/graphql",
    "ApiKey": "<read-only key>",
    "AuthHeader": "x-api-key: {key}",
    "RequestTimeoutMs": 30000,
    "MinRequestIntervalMs": 250
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get DiscoveryIsAuthoritative(): boolean

      §7 — does this connector's discovery (DiscoverObjects/DiscoverFields → IntrospectSchema) return the AUTHORITATIVE, COMPLETE gamut of objects/fields the credentials expose? Default false (safe): a connector must explicitly affirm this. Override to true ONLY when DiscoverObjects hits a real list/describe endpoint that returns EVERYTHING accessible — so an object/field absent from a refresh genuinely means the source dropped it (and may be deactivated). Leave false for stubbed discovery (returns nothing → static metadata is all we have), a cache-driven IntrospectSchema, or any partial/scoped enumeration — there, absence proves nothing and MUST NOT deactivate.

      Returns boolean

    • get IntegrationName(): string

      The canonical integration name (e.g., "HubSpot", "Rasa.io"). Used by GetActionGeneratorConfig() and IntegrationActionExecutor to match connectors to action Config.IntegrationName.

      Override in subclasses. Defaults to the class name.

      Returns string

    • get MaxConcurrencyHint(): number

      Highest SAFE per-layer concurrency the source tolerates (plan.md §7 peak parallelization) — the ceiling the engine's adaptive controller ramps toward. null → use configured syncConcurrency.

      Returns number

    • get MonotonicWatermark(): boolean

      Whether the watermark this connector returns (FetchBatchResult.NewWatermarkValue) is a RELIABLE, monotonically-increasing global maximum — i.e. the connector fetches in watermark order so the last batch's value IS the true high-water mark, and an updated record always re-surfaces at a NEW (higher) watermark. When true, the engine uses that watermark to NARROW the next incremental (instead of advancing a full sync to wall-clock "now", and instead of the keyset clear-and-re-scan), so incrementals fetch only what's new.

      Default false — the safe, backwards-compatible choice: a connector whose source returns records out of watermark order (e.g. HubSpot's creation-ordered list API, where the last batch can carry old modstamps) MUST stay false so the engine keeps advancing to "now" and never saves a stale watermark. Override to true ONLY when the source guarantees monotonic ordering.

      Returns boolean

    • get RateLimitPolicy(): RateLimitPolicy

      Token-bucket rate-limit policy for this connector's source API (plan.md §7 peak-aware rate limiting). null → the engine derives a conservative rate from Integration.BatchRequestWaitTime. Override to push to the source's real limits.

      Returns RateLimitPolicy

    • get SupportsBatchWrite(): boolean

      Whether this connector supports batched target writes (plan.md §7 aggressive batching).

      Returns boolean

    • get SupportsCreate(): boolean

      Whether this connector supports creating new records in the external system.

      Returns boolean

    • get SupportsDelete(): boolean

      Whether this connector supports deleting records from the external system.

      Returns boolean

    • get SupportsGet(): boolean

      Whether this connector supports reading/fetching records. Always true.

      Returns boolean

    • get SupportsListing(): boolean

      Whether this connector supports paginated listing of records.

      Returns boolean

    • get SupportsSearch(): boolean

      Whether this connector supports searching/querying records with filters.

      Returns boolean

    • get SupportsUpdate(): boolean

      Whether this connector supports updating existing records in the external system.

      Returns boolean

    • get SupportsUpsert(): boolean

      Whether this connector supports idempotent upserts (create-or-update keyed by a unique business property). Connectors override this AND Upsert to enable it.

      Returns boolean

    Methods

    • Builds a CRUDResult for a record CREATE, failing LOUDLY when the external system returned no usable record ID. A 2xx response with an empty/undefined ID means the create did not durably produce a record we can track — returning Success:true there silently loses the record and causes duplicate creates on the next sync (the HubSpot-association class of bug, fixed in next commit 9f718a7e). This makes that failure explicit at the connector boundary.

      Parameters

      • externalID: string
      • statusCode: number
      • objectName: string

      Returns CRUDResult

    • Discovery via the connector's READ PATH (FetchChanges), TIME-BOUNDED — the way to gather a statistically-significant sample when a single DiscoverFields sample is too small to PROVE a key. "Discovery is the sync read path with the save removed."

      Loops FetchChanges as a read-only FULL fetch (WatermarkValue=null, nothing persisted), threading pagination/keyset cursors across batches, and streams every record through the data-informed field + provable-PK inference. It stops at the discovery TIME BUDGET (default 5 min), or a record cap, or source exhaustion — whichever comes first — so the provable-PK decision is made on as much real data as the budget allows. It NEVER fabricates a key: if even this larger sample yields no provable single/composite PK, the field set comes back PK-less and the object is honestly not added.

      Falls back to the single-sample DiscoverFields if the read path can't run for this object (e.g. a connector whose FetchChanges needs an already-persisted IO row that doesn't exist yet).

      Parameters

      Returns Promise<ExternalFieldSchema[]>

    • Stage-2 field discovery for sources WITHOUT a describe/introspection endpoint (file feeds, undocumented JSON list endpoints): stream the source's actual records — READ-ONLY, no save, no ack — and derive the full field set + data-informed PK/uniqueness/nullability from the gathered statistics. The connector supplies whatever read-only fetch yields the records; this helper turns that stream into ExternalFieldSchema[].

      Why data-informed: streaming the real values lets pickPrimaryKeyFromStats pick the PK from evidence (uniqueness/non-null statistics) COMBINED with the naming convention, rather than a name guess alone. The PK is a SOFT key, so the pick is best-available, not strict-significance: a confident unique+non-null column wins outright; otherwise a near-unique / convention-named column is taken as a soft key (a PK-less object would stall CodeGen). The scan is time-bounded — it stops on exhaustion OR opts.Discovery.TimeBudgetMs; more rows simply mean stronger claims.

      Provable-only encoding into the standard flags:

      • IsPrimaryKey — set ONLY on the single statistics-first pick. Multiple equally-ranked unique columns leave PK unset here (ambiguous → the pipeline's SoftPKClassifier LLM tiebreaker decides, fed these same stats). Zero unique columns → no PK is fabricated.
      • IsUniqueKey — set when the column was all-distinct over the scan AND uniqueness was provable (the distinct-cap wasn't hit).
      • AllowsNull — asserted true ONLY when a null/absent value was actually observed; otherwise left undefined (permissive default). Never fabricates NOT NULL — critical under a time-capped partial scan where unseen rows could still be null.

      The PK emitted here is SOFT (it rides additionalSchemaInfo via the persist + DDL path; it is NEVER a hard DB key), so a wrong inference can never reject a valid row — the engine dedupes via the record-map. IsReadOnly defaults to true (stream discovery targets read feeds); a writable source overrides via opts.ReadOnly.

      Parameters

      • records:
            | AsyncIterable<Record<string, unknown>, any, any>
            | Iterable<Record<string, unknown>, any, any>

        A read-only sync/async iterable of source records (the caller's fetch yields them).

      • Optionalopts: { Discovery?: StreamDiscoveryOptions; Pk?: PkPickOptions; ReadOnly?: boolean }

      Returns Promise<ExternalFieldSchema[]>

    • The record source DiscoverFieldsViaFetch streams for field/PK inference. Default: loop FetchChanges (full fetch), yielding each record's fields until maxRecords. A protocol subclass (e.g. REST) overrides this to sample a template-var CHILD with the correct record-constrained, recursive stream. Yields plain field maps; the caller stops it at maxRecords.

      Parameters

      Returns AsyncGenerator<Record<string, unknown>>

    • Parse a Retry-After / rate-limit signal out of a failed response or thrown error into milliseconds so the engine can back off precisely. Return undefined when the error is not a throttle (or carries no hint).

      Parameters

      • _error: unknown

      Returns number

    • Returns the ActionGeneratorConfig for this connector, combining the integration name, category, icon, and objects into a ready-to-use configuration for ActionMetadataGenerator.Generate().

      Override in subclasses to customize the config (e.g., icon, category). Returns null by default if GetIntegrationObjects() returns empty.

      Returns ActionGeneratorConfig

    • Returns suggested default field mappings for an external object to MJ entity. Override in subclasses to provide intelligent defaults.

      Parameters

      • _objectName: string

        Name of the external object

      • _entityName: string

        Name of the target MJ entity

      Returns DefaultFieldMapping[]

      Array of default field mappings (empty by default)

    • Returns the integration objects and their fields that this connector supports, for use by the ActionMetadataGenerator. This is static metadata that does NOT require a live connection — it describes the connector's known object model.

      Override in subclasses to provide connector-specific objects/fields. Returns an empty array by default (no action generation available).

      Returns IntegrationObjectInfo[]

    • Type-driven post-processing hook (plan.md §10): a connector may normalize/enforce a record's values to the resolved column formats AFTER transform/normalize and BEFORE write. Default returns the record unchanged. (Named for this system — NOT MCP, not take.) The engine ALSO applies target-type constraint enforcement; this is the connector-side complement.

      Parameters

      Returns ExternalRecord

    • Name of a stable, monotonic ordering key (PK/identity) usable for KEYSET/seek resume on watermark-less objects (plan.md §7 — resume from last-seen key, robust to mid-stream insert/delete). null → keyset resume unavailable for this object.

      Parameters

      • _objectName: string

      Returns string

    • Upserts a record — a single idempotent create-or-update keyed by a unique business property (e.g. email), eliminating the search-then-create race window. Override in subclasses whose external system exposes a keyed upsert primitive. Check SupportsUpsert before calling.

      Parameters

      Returns Promise<CRUDResult>