ObjectStackObjectStack

Query Adapter schema — API Protocol reference

Defines mapping rules between the internal unified query DSL (defined in data/query.zod.ts) and external API protocol formats: REST and OData.

API Query DSL Adapter Protocol

Defines mapping rules between the internal unified query DSL (defined in data/query.zod.ts) and external API protocol formats: REST and OData.

This enables ObjectStack to expose a single internal query representation while supporting multiple API standards for external consumers.

See also: data/query.zod.ts - Unified internal query DSL

See also: api/rest-server.zod.ts - REST API configuration

See also: api/odata.zod.ts - OData API configuration

Source: packages/spec/src/api/query-adapter.zod.ts

TypeScript Usage

import { ODataQueryAdapterSchema, OperatorMappingSchema, QueryAdapterConfigSchema, QueryAdapterTargetSchema, RestQueryAdapterSchema } from '@objectstack/spec/api';
import type { ODataQueryAdapter, OperatorMapping, QueryAdapterConfig, QueryAdapterTarget, RestQueryAdapter } from '@objectstack/spec/api';

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

ODataQueryAdapter

Properties

PropertyTypeRequiredDescription
versionEnum<'v2' | 'v4'>optional (default: "v4")OData version
usePrefixbooleanoptional (default: true)Use $ prefix for system query options ($filter vs filter)
stringFunctionsEnum<'contains' | 'startswith' | 'endswith' | 'tolower' | 'toupper' | 'trim' | 'concat' | 'substring' | 'length'>[]optionalSupported OData string functions
expand{ enabled?: boolean; maxDepth?: integer }optional$expand configuration

Nested Shape: ODataQueryAdapter.expand

PropertyTypeRequiredDescription
enabledbooleanoptional (default: true)Enable $expand support
maxDepthintegeroptional (default: 3)Maximum expand depth

OperatorMapping

Properties

PropertyTypeRequiredDescription
operatorstring✅Unified DSL operator
reststringoptionalREST query parameter template
odatastringoptionalOData $filter expression template

QueryAdapterConfig

Properties

PropertyTypeRequiredDescription
operatorMappings{ operator: string; rest?: string; odata?: string }[]optionalCustom operator mappings
rest{ filterStyle?: Enum<'bracket' | 'dot' | 'flat' | 'rsql'>; pagination?: object; sorting?: object; fieldsParam?: string }optionalREST query adapter configuration
odata{ version?: Enum<'v2' | 'v4'>; usePrefix?: boolean; stringFunctions?: Enum<'contains' | 'startswith' | 'endswith' | 'tolower' | 'toupper' | 'trim' | …>[]; expand?: object }optionalOData query adapter configuration

Nested Shape: QueryAdapterConfig.operatorMappings[number]

PropertyTypeRequiredDescription
operatorstring✅Unified DSL operator
reststringoptionalREST query parameter template
odatastringoptionalOData $filter expression template

Nested Shape: QueryAdapterConfig.rest

PropertyTypeRequiredDescription
filterStyleEnum<'bracket' | 'dot' | 'flat' | 'rsql'>optional (default: "bracket")REST filter parameter encoding style
pagination{ limitParam?: string; offsetParam?: string; cursorParam?: string; pageParam?: string }optionalPagination parameter name mappings
sorting{ param?: string; format?: Enum<'comma' | 'array' | 'pipe'> }optionalSort parameter mapping
fieldsParamstringoptional (default: "fields")Field selection parameter name

Nested Shape: QueryAdapterConfig.odata

PropertyTypeRequiredDescription
versionEnum<'v2' | 'v4'>optional (default: "v4")OData version
usePrefixbooleanoptional (default: true)Use $ prefix for system query options ($filter vs filter)
stringFunctionsEnum<'contains' | 'startswith' | 'endswith' | 'tolower' | 'toupper' | 'trim' | …>[]optionalSupported OData string functions
expand{ enabled?: boolean; maxDepth?: integer }optional$expand configuration

QueryAdapterTarget

Allowed Values

  • rest
  • odata

RestQueryAdapter

Properties

PropertyTypeRequiredDescription
filterStyleEnum<'bracket' | 'dot' | 'flat' | 'rsql'>optional (default: "bracket")REST filter parameter encoding style
pagination{ limitParam?: string; offsetParam?: string; cursorParam?: string; pageParam?: string }optionalPagination parameter name mappings
sorting{ param?: string; format?: Enum<'comma' | 'array' | 'pipe'> }optionalSort parameter mapping
fieldsParamstringoptional (default: "fields")Field selection parameter name

Nested Shape: RestQueryAdapter.pagination

PropertyTypeRequiredDescription
limitParamstringoptional (default: "limit")Page size parameter name
offsetParamstringoptional (default: "offset")Offset parameter name
cursorParamstringoptional (default: "cursor")Cursor parameter name
pageParamstringoptional (default: "page")Page number parameter name

Nested Shape: RestQueryAdapter.sorting

PropertyTypeRequiredDescription
paramstringoptional (default: "sort")Sort parameter name
formatEnum<'comma' | 'array' | 'pipe'>optional (default: "comma")Sort parameter encoding format

On this page