Skip to content
MSO CloudDocumentation

Add a data source (connector)

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_DRIVERS map in the marketing processor
dataset 1st-party grids for the org's own dataset (ADR 0049); DatasetConnector DATASET_DRIVERS map in the dataset processor, plus a binding adapter
market_intel 3rd-party estimates, own market_intel_* store, never in 1st-party KPIs A MarketDataParser entry (file) or a scheduled vendor pull
content_intel 1st-party conversation corpora a client supplies (ADR 0022) No connector manifest; corpus upload wizard

Sequence of one connector sync run from the cron sweep to the watermark

The contract#

  • Manifest as a plugin: kind: 'connector', connectorFamily, transport (api, file, both), providerId, thirdPartyData, dependsOn in packages/plugin-host/src/registry.ts; schema packages/plugin-host/src/manifest.ts; family enum packages/plugin-host/src/connector-family.ts.
  • Connector metadata, a second and different "manifest": ConnectorManifestSchema in packages/connectors/core/src/manifest.ts (kind api|file|dataset, produces, defaultSchedule). Its id equals connector_credentials.connector_type and the plugin's providerId.
  • Classes: ApiConnector (api-connector.ts), FileConnector (file-connector.ts), DatasetConnector (dataset-connector.ts: authenticate, healthCheck, listSources, readSource), all in packages/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() in apps/worker/src/connectors/index.ts registers a class factory, never a shared instance, because an ApiConnector keeps its authenticated client in instance state. The registry rejects a duplicate id. packages/actions/src/index.ts keeps 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 in MARKETING_DRIVERS (apps/worker/src/processors/sync-marketing.ts); the satisfies Record<...> makes a missing driver a compile error. An unlisted type throws the permanent CONNECTOR_NO_DRIVER.
  • Dataset: DATASET_CONNECTOR_TYPES and DATASET_DRIVERS (apps/worker/src/processors/sync-dataset.ts), plus one DatasetBindingAdapter per type in apps/web/src/server/routers/connectors-dataset-binding.ts for the interactive picker.
  • Market intel: an entry in PARSERS of packages/connectors/core/src/market-data-registry.ts; every market-intel plugin dependsOn the Market Intelligence plugin.

Add one#

  1. Create packages/connectors/<name>; model it on the nearest sibling (google-ads for marketing, odoo for dataset, haravan for marketplace). Validate every vendor response with a Zod schema and route HTTP through core/src/http.ts.
  2. Add the plugin manifest in packages/plugin-host/src/registry.ts in the table for your family; copy keys plugins.connector<Name>.name and .description into packages/i18n/src/messages/{vi,en}.ts.
  3. Do the family step: marketplace registers in apps/worker/src/connectors/index.ts and adds the workspace dependency in apps/worker/package.json; marketing and dataset add the type and driver as above, then the dependency (marketing also adds the connector package to apps/web/package.json, because the web app uses its config parser and ping); market intel adds the parser.
  4. 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 in OPERATIONAL_KEYS in scripts/audit/connector-source-key.py. One active credential per org, brand, type and source is a database constraint.
  5. If the vendor pins an API version, add a row to packages/connectors/upstream-api.json.
  6. Add the picker card and copy where the sibling has them (apps/web/src/app/(dashboard)/connectors/_components/connector-catalog.tsx and connector-directory.ts beside it), and replay tests built from recorded vendor responses.
  7. Marketing only, in apps/worker/src/processors/sync-marketing.ts: add the vendor's isPermanent<Vendor>Error to classifyPermanent, a list separate from MARKETING_DRIVERS; without it a revoked token retries five times instead of dead-lettering once.
  8. Marketing only, when the vendor is a new ad platform slug (needs packages/schema owner review): add it to AD_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) and dimension-value-semantics.ts (packages/metrics/src). Add a connector shows each edit.
  9. To make a stream re-pullable for history, follow the connector-backfill skill (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 scheduled queue sweeps connectors (orders:poll-incremental every 5 minutes, marketing:sync-cadence-sweep, dataset:sync-cadence-sweep, market-intel:sync-daily in apps/worker/src/schedules.ts); each credential's own interval decides whether it is due. Queues: per-marketplace sync-tiktok-shop, sync-shopee, sync-lazada, sync-file for the rest, sync-marketing, and the dataset queue.
  • 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 lookbackDays and 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 DriverArgs object, 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, bitrix24 and 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_intel has the family enum member and a vertical, but no connector manifest.