On this page
A connector pulls one external source into one of the platform's data planes. There are five families, they dispatch four different ways, and the family decides the checklist.
When to use#
Use a connector to pull data on a schedule or on upload from a marketplace, ad or analytics platform, an ERP or HRM, or a market-data vendor. Do not use one to push data from your own application into MSO Cloud: that is Platform API and events. A one-off spreadsheet needs no code: the Google Sheets connector and the upload wizard turn a sheet into a declared dataset (Configured, not coded).
The family is the data plane, and the planes never mix:
| Family | Plane and contract | Dispatch |
|---|---|---|
marketplace |
1st-party commerce; ApiConnector or FileConnector; orders, creators, inventory, settlements |
Class registered in the worker's connector registry |
marketing |
1st-party marketing (ADR 0008); no interface, one driver function per vendor | MARKETING_ map in the marketing processor |
dataset |
1st-party grids for the org's own dataset (ADR 0049); Dataset |
DATASET_ map in the dataset processor, plus a binding adapter |
market_ |
3rd-party estimates, own market_ store, never in 1st-party KPIs |
A MarketDataParser entry (file) or a scheduled vendor pull |
content_ |
1st-party conversation corpora a client supplies (ADR 0022) | No connector manifest; corpus upload wizard |
The contract#
- Manifest as a plugin:
kind: 'connector',connectorFamily,transport(api,file,both),providerId,thirdPartyData,dependsOninpackages/plugin-host/src/registry.ts; schemapackages/plugin-host/src/manifest.ts; family enumpackages/plugin-host/src/connector-family.ts. - Connector metadata, a second and different "manifest":
ConnectorManifestSchemainpackages/connectors/core/src/manifest.ts(kindapi|file|dataset,produces,defaultSchedule). Itsidequalsconnector_credentials.connector_typeand the plugin'sproviderId. - Classes:
ApiConnector(api-connector.ts),FileConnector(file-connector.ts),DatasetConnector(dataset-connector.ts:authenticate,healthCheck,listSources,readSource), all inpackages/connectors/core/src. - Shared transport for API calls:
packages/connectors/core/src/http.ts(timeout, bounded retries,Retry-After, secret redaction).
How registration works#
- Marketplace:
registerConnectors()inapps/worker/src/connectors/index.tsregisters a class factory, never a shared instance, because anApiConnectorkeeps its authenticated client in instance state. The registry rejects a duplicate id.packages/actions/src/index.tskeeps a second list (ACTION_CONNECTOR_FACTORIES) of the three connectors that can execute write actions. - Marketing: the type string goes in
MARKETING_CONNECTOR_TYPES(packages/connectors/core/src/marketing-connectors.ts) and its driver inMARKETING_DRIVERS(apps/worker/src/processors/sync-marketing.ts); thesatisfies Record<...>makes a missing driver a compile error. An unlisted type throws the permanentCONNECTOR_NO_DRIVER. - Dataset:
DATASET_CONNECTOR_TYPESandDATASET_DRIVERS(apps/worker/src/processors/sync-dataset.ts), plus oneDatasetBindingAdapterper type inapps/web/src/server/routers/connectors-dataset-binding.tsfor the interactive picker. - Market intel: an entry in
PARSERSofpackages/connectors/core/src/market-data-registry.ts; every market-intel plugindependsOnthe Market Intelligence plugin.
Add one#
- Create
packages/connectors/<name>; model it on the nearest sibling (google-adsfor marketing,odoofor dataset,haravanfor marketplace). Validate every vendor response with a Zod schema and route HTTP throughcore/src/http.ts. - Add the plugin manifest in
packages/plugin-host/src/registry.tsin the table for your family; copy keysplugins.connector<Name>.nameand.descriptionintopackages/i18n/src/messages/{vi,en}.ts. - Do the family step: marketplace registers in
apps/worker/src/connectors/index.tsand adds the workspace dependency inapps/worker/package.json; marketing and dataset add the type and driver as above, then the dependency (marketing also adds the connector package toapps/web/package.json, because the web app uses its config parser and ping); market intel adds the parser. - Config keys that name an upstream account go in
CONNECTOR_SOURCE_KEY_FIELDS(packages/schema/src/tables/connectors.ts) with a migration; keys that only tune a sync go inOPERATIONAL_KEYSinscripts/audit/connector-source-key.py. One active credential per org, brand, type and source is a database constraint. - If the vendor pins an API version, add a row to
packages/connectors/upstream-api.json. - Add the picker card and copy where the sibling has them (
apps/web/src/app/(dashboard)/connectors/_components/connector-catalog.tsxandconnector-directory.tsbeside it), and replay tests built from recorded vendor responses. - Marketing only, in
apps/worker/src/processors/sync-marketing.ts: add the vendor'sisPermanent<Vendor>ErrortoclassifyPermanent, a list separate fromMARKETING_DRIVERS; without it a revoked token retries five times instead of dead-lettering once. - Marketing only, when the vendor is a new ad platform slug (needs
packages/schemaowner review): add it toAD_PLATFORMS(packages/schema/src/tables/marketing-spend.ts),AD_PLATFORM_SLUGS(apps/web/src/lib/ad-platforms.ts),PLATFORM_LABELS(packages/charts/src/formatters.ts),PLATFORM_ALIASES(packages/metrics/src/plan-binding-suggest.ts) anddimension-value-semantics.ts(packages/metrics/src). Add a connector shows each edit. - To make a stream re-pullable for history, follow the
connector-backfillskill (skills/connector-backfill/SKILL.md).
Guards#
pnpm tsx scripts/audit/plugin-manifest-validity.ts; in audit:all: connector-family-routing-closed.py (every connector plugin is routed once and has a driver, with a shrink-only baseline of deliberately unrouted ids), connector-source-key.py, connector-api-sunset.py. Tests: packages/connectors/core/src/{registry,marketing-connectors,dataset-connectors}.test.ts, packages/connectors/core/src/mapping/starter-templates.test.ts, and a driver.test.ts or connector.test.ts per package.
Operating it#
- Schedule: the
scheduledqueue sweeps connectors (orders:poll-incrementalevery 5 minutes,marketing:sync-cadence-sweep,dataset:sync-cadence-sweep,market-intel:sync-dailyinapps/worker/src/schedules.ts); each credential's own interval decides whether it is due. Queues: per-marketplacesync-tiktok-shop,sync-shopee,sync-lazada,sync-filefor the rest,sync-marketing, and thedatasetqueue. - Retries: five BullMQ attempts with 30 s exponential backoff on sync queues.
isPermanentSyncError(packages/connectors/core/src/errors.ts) marks auth failures, undecryptable credentials, bad mapping specs and foreign-key violations as permanent: they go to the dead-letter table once. A connector still waiting for its first authorization is skipped on a cron tick, not failed. - Marketing vendors restate closed days, so each driver re-pulls
lookbackDaysand upserts on natural keys. Marketplace sync reads a per-stream watermark (connector_watermarks) and writes raw rows, then promotes to silver. - Each marketing vendor package carries its own
isPermanent<Vendor>Error; new ones must treat an authentication failure as permanent. - Observe:
sync_jobs,sync_dead_letters,connector_credentials.health_message.
Where it stops#
- No marketing or dataset interface: drivers are free functions with a
DriverArgsobject, so only the compile-time map and the audit catch omissions. - Backfill streams are shaped for marketplace data; marketing relies on
lookbackDays, dataset has no backfill. - Manifests without a driver exist and are baselined in
connector-family-routing-closed.py:tiktok-affiliate,warehouse,bitrix24and three market-data sources that were retired from the picker (a social listening source, a social trend source and a public-data source). Their cards read as coming soon (Project status). content_intelhas the family enum member and a vertical, but no connector manifest.