ObjectStackObjectStack

Datasource

Datasource protocol schemas

Driver Identifier Can be a built-in driver or a plugin-contributed driver (e.g., "com.vendor.snowflake").

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
namestringUnique datasource identifier
labelstringoptionalDisplay label
driverstringUnderlying 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)
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'>optionalOrigin of the item (package | org | env-forced).
_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.
queryTimeoutMsnumberoptional (default: 30000)Hard cap on per-query execution time.

DriverDefinition

Properties

PropertyTypeRequiredDescription
idstringUnique driver identifier (e.g. "postgres")
labelstringDisplay 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)

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.
queryTimeoutMsnumberoptional (default: 30000)Hard cap on per-query execution time.

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