ObjectStackObjectStack

Datasource schema — Data Protocol reference

Datasource schemas of the ObjectStack Data Protocol: Datasource, DriverDefinition and 3 more — each property with its type, default and a TypeScript example.

Source: packages/spec/src/data/datasource.zod.ts

TypeScript Usage

import { DatasourceSchema, DriverDefinitionSchema, DriverType, ExternalDatasourceSettingsSchema, SchemaModeSchema } from '@objectstack/spec/data';
import type { Datasource, DriverDefinition, DriverType, ExternalDatasourceSettings, SchemaMode } from '@objectstack/spec/data';

// Validate data
const result = DatasourceSchema.parse(data);

Datasource

Properties

PropertyTypeRequiredDescription
namestring✅Unique datasource identifier (snake_case). Reserved: 'drivers', a path the datasource admin API serves itself, so a datasource of that name could never be read by name.
labelstringoptionalDisplay label
driverstring✅Underlying driver type
configRecord<string, any>✅Driver specific configuration
pool{ min?: number; max?: number; idleTimeoutMillis?: number; connectionTimeoutMillis?: number }optionalConnection pool settings
ssl{ enabled?: boolean; rejectUnauthorized?: boolean; ca?: string; cert?: string; … }optionalSSL/TLS configuration for secure database connections
descriptionstringoptionalInternal description
activebooleanoptional (default: true)Is datasource enabled
autoConnectbooleanoptional (default: false)Force a live driver connection at boot even when managed + unrouted (ADR-0062 D2).
schemaModeEnum<'managed' | 'external' | 'validate-only'>optional (default: "managed")Schema ownership mode
external{ allowedSchemas?: string[]; allowWrites?: boolean; validation?: object; credentialsRef?: string; … }optionalExternal datasource settings: federation policy (schemaMode != "managed") plus the secrets-store credentials reference (valid in every schemaMode) or the connector instance an API-backed datasource borrows its credential from
originEnum<'code' | 'runtime'>optional (default: "code")Datasource provenance (server-managed, read-only)
_lockEnum<'none' | 'no-overlay' | 'no-delete' | 'full'>optionalItem-level lock — controls overlay & delete (ADR-0010).
_lockReasonstringoptionalHuman-readable reason shown when a write is refused by _lock.
_lockSourceEnum<'artifact' | 'package' | 'env-forced'>optionalLayer that set _lock (artifact | package | env-forced).
_provenanceEnum<'package' | 'org' | 'env-forced' | 'platform'>optionalOrigin of the item (package | org | env-forced | platform).
_packageIdstringoptionalOwning package machine id.
_packageVersionstringoptionalOwning package version.
_lockDocsUrlstringoptionalOptional documentation link surfaced next to _lockReason.

Nested Shape: Datasource.pool

PropertyTypeRequiredDescription
minnumberoptional (default: 0)Minimum connections
maxnumberoptional (default: 10)Maximum connections
idleTimeoutMillisnumberoptional (default: 30000)Idle timeout
connectionTimeoutMillisnumberoptional (default: 3000)Connection establishment timeout

Nested Shape: Datasource.ssl

PropertyTypeRequiredDescription
enabledbooleanoptional (default: false)Enable SSL/TLS for database connection
rejectUnauthorizedbooleanoptional (default: true)Reject connections with invalid/self-signed certificates
castringoptionalCA certificate (PEM format or path to file)
certstringoptionalClient certificate (PEM format or path to file)
keystringoptionalClient private key (PEM format or path to file)

Nested Shape: Datasource.external

PropertyTypeRequiredDescription
allowedSchemasstring[]optionalWhitelist of remote schemas/databases that may be exposed.
allowWritesbooleanoptional (default: false)Global write gate. Individual objects must also opt in via object.external.writable.
validation{ onMismatch?: Enum<'fail' | 'warn' | 'ignore'>; checkOnBoot?: boolean; checkIntervalMs?: number }optional (default: {"onMismatch":"fail","checkOnBoot":true})Boot/drift validation policy
credentialsRefstringoptionalReference into the secrets store; never inline credentials. Valid in every schemaMode — the one external key a managed datasource may carry.
connectorstringoptionalName of a declared connector instance (a connectors entry with a provider) whose credential this API-backed datasource borrows — whichever kind the instance's auth declares (bearer, api-key or basic; ADR-0143 D2 adds the grant-bearing kinds), resolved the way the connector resolves it. One Connect serves both the connector's actions and this datasource's records. Exclusive with credentialsRef; refused on a built-in database driver and on a managed datasource.
queryTimeoutMsnumberoptional (default: 30000)Hard cap on per-query execution time.
rowCapintegeroptionalPlugin-driver datasources only (a non-managed datasource whose driver is not a built-in id): the most rows the engine reads from the driver for one request, and so the most rows one read may match before it is refused with EXTERNAL_ROW_CAP_EXCEEDED (422). Absent: 1000. At most 10000. Each list page reads every match up to this cap from the remote, twice (the rows and the total), so raise it only as far as the widest read needs.

DriverDefinition

Properties

PropertyTypeRequiredDescription
idstring✅Unique driver identifier (e.g. "postgres")
labelstring✅Display label (e.g. "PostgreSQL")
descriptionstringoptional
iconstringoptional
configSchemaRecord<string, any>✅JSON Schema for connection configuration

DriverType

Underlying driver identifier

Type: string


ExternalDatasourceSettings

External datasource settings: federation policy (schemaMode != "managed") plus the secrets-store credentials reference (valid in every schemaMode) or the connector instance an API-backed datasource borrows its credential from

Properties

PropertyTypeRequiredDescription
allowedSchemasstring[]optionalWhitelist of remote schemas/databases that may be exposed.
allowWritesbooleanoptional (default: false)Global write gate. Individual objects must also opt in via object.external.writable.
validation{ onMismatch?: Enum<'fail' | 'warn' | 'ignore'>; checkOnBoot?: boolean; checkIntervalMs?: number }optional (default: {"onMismatch":"fail","checkOnBoot":true})Boot/drift validation policy
credentialsRefstringoptionalReference into the secrets store; never inline credentials. Valid in every schemaMode — the one external key a managed datasource may carry.
connectorstringoptionalName of a declared connector instance (a connectors entry with a provider) whose credential this API-backed datasource borrows — whichever kind the instance's auth declares (bearer, api-key or basic; ADR-0143 D2 adds the grant-bearing kinds), resolved the way the connector resolves it. One Connect serves both the connector's actions and this datasource's records. Exclusive with credentialsRef; refused on a built-in database driver and on a managed datasource.
queryTimeoutMsnumberoptional (default: 30000)Hard cap on per-query execution time.
rowCapintegeroptionalPlugin-driver datasources only (a non-managed datasource whose driver is not a built-in id): the most rows the engine reads from the driver for one request, and so the most rows one read may match before it is refused with EXTERNAL_ROW_CAP_EXCEEDED (422). Absent: 1000. At most 10000. Each list page reads every match up to this cap from the remote, twice (the rows and the total), so raise it only as far as the widest read needs.

Nested Shape: ExternalDatasourceSettings.validation

PropertyTypeRequiredDescription
onMismatchEnum<'fail' | 'warn' | 'ignore'>optional (default: "fail")What to do when a federated object diverges from the remote table.
checkOnBootbooleanoptional (default: true)Validate federated objects against the remote schema at boot.
checkIntervalMsnumberoptionalOptional background drift-check interval in milliseconds.

SchemaMode

Schema ownership mode

Allowed Values

  • managed
  • external
  • validate-only

On this page