Skip to content

refactor(api): collapse DataSchema builder/built distinction and remove DT.Meta#872

Merged
johngeorgewright merged 5 commits into
masterfrom
simplifying-data-meta
Apr 21, 2026
Merged

refactor(api): collapse DataSchema builder/built distinction and remove DT.Meta#872
johngeorgewright merged 5 commits into
masterfrom
simplifying-data-meta

Conversation

@johngeorgewright

Copy link
Copy Markdown
Collaborator

DataSchema now exposes its parser records as public readonly fields and is passed directly to Data.create() — the separate .build() step and the BuiltDataSchema interface are gone. The DT.Meta indirection is also removed: Data<$ extends DataSchema = DataSchema> indexes the schema directly using camelCase keys that mirror the runtime object ($['payloadParsers'], etc.), so there is one shape for both type-level and value-level access.

TargetingPredicates is decoupled from the old Meta shape, Data exposes a schema getter, and downstream packages (server, client, fs, explode, json-schema, date-range) are updated to the new generic.

BREAKING CHANGE: .build(), BuiltDataSchema, DT.Meta, and DT.EmptyMeta have been removed.

Migration:

  • Drop .build() calls; pass the DataSchema to Data.create() directly.
  • Replace $ extends DT.Meta with $ extends DataSchema.
  • Rename indexed access keys from PascalCase to camelCase: $['PayloadParsers']$['payloadParsers'] $['TargetingParsers']$['targetingParsers'] $['QueryParsers']$['queryParsers'] $['FallThroughTargetingParsers']$['fallThroughTargetingParsers']
  • Replace DT.Any with DataSchema in generic constraints where you previously used it as the "match any" bound.

…ve DT.Meta

DataSchema now exposes its parser records as public readonly fields and
is passed directly to `Data.create()` — the separate `.build()` step and
the `BuiltDataSchema` interface are gone. The DT.Meta indirection is
also removed: `Data<$ extends DataSchema = DataSchema>` indexes the
schema directly using camelCase keys that mirror the runtime object
(`$['payloadParsers']`, etc.), so there is one shape for both type-level
and value-level access.

TargetingPredicates is decoupled from the old Meta shape, `Data` exposes
a `schema` getter, and downstream packages (server, client, fs,
explode, json-schema, date-range) are updated to the new generic.

BREAKING CHANGE: `.build()`, `BuiltDataSchema`, `DT.Meta`, and
`DT.EmptyMeta` have been removed.

Migration:
- Drop `.build()` calls; pass the `DataSchema` to `Data.create()` directly.
- Replace `$ extends DT.Meta` with `$ extends DataSchema`.
- Rename indexed access keys from PascalCase to camelCase:
  `$['PayloadParsers']`              → `$['payloadParsers']`
  `$['TargetingParsers']`            → `$['targetingParsers']`
  `$['QueryParsers']`                → `$['queryParsers']`
  `$['FallThroughTargetingParsers']` → `$['fallThroughTargetingParsers']`
- Replace `DT.Any` with `DataSchema` in generic constraints where you
  previously used it as the "match any" bound.
Copilot AI review requested due to automatic review settings April 21, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors @targetd/api’s type model so DataSchema is passed directly to Data.create() (no .build() / BuiltDataSchema) and removes the DT.Meta indirection by indexing directly into the schema’s camelCase parser-record fields. Updates all downstream packages to the new generics and indexing keys.

Changes:

  • Remove the DataSchema “builder vs built” split; Data.create() now accepts DataSchema directly and Data exposes a schema getter.
  • Replace DT.Meta/PascalCase indexed-access types with DataSchema/camelCase keys across server/client/fs/explode/json-schema/date-range.
  • Update docs/tests/examples to drop .build() and align with the new schema-driven generics.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/server/test/index.test.ts Drops DT usage and .build() in server tests; updates helper typing.
packages/server/src/middleware/castQueryArrayProps.ts Rebinds middleware generics to DataSchema/Data<$> instead of DT.Any.
packages/server/src/index.ts Updates createServer generics and query typing to schema-indexed access.
packages/server/README.md Updates examples to remove .build() and use schema directly.
packages/json-schema/test/fixtures/data.ts Drops .build() from fixture schema creation.
packages/json-schema/src/index.ts Rebinds schema generation helpers to Data<$ extends DataSchema>.
packages/json-schema/src/cli.ts Updates CLI type-guard to use Data type.
packages/fs/test/fixtures/data.ts Drops .build() from fixture schema creation.
packages/fs/src/watch.ts Updates watcher generics from DT.Any to Data<$ extends DataSchema>.
packages/fs/src/load.ts Updates loader generics/signatures to Data<$ extends DataSchema>.
packages/fs/README.md Updates examples to remove .build() and use schema directly.
packages/explode/src/types.ts Switches explode typing to index into DataSchema parser records.
packages/explode/README.md Updates examples to remove .build().
packages/date-range/test/index.test.ts Drops .build() from date-range tests.
packages/date-range/src/index.ts Updates inline example to remove .build().
packages/date-range/README.md Updates examples to remove .build().
packages/client/test/index.test.ts Updates client tests to use data.schema typing pattern.
packages/client/src/index.ts Changes Client generic to DataSchema and camelCase indexed access; removes ClientWithData.
packages/client/README.md Updates examples to remove .build().
packages/api/test/type-stress.test.ts Updates stress test schema creation to remove .build().
packages/api/test/Data.test.ts Updates core API tests to remove .build() and match new schema API.
packages/api/src/types/Payload.ts Rebinds payload types to DataSchema and camelCase parser keys.
packages/api/src/types/FallThroughTargeting.ts Rebinds fallthrough types to DataSchema and camelCase parser keys.
packages/api/src/types/Data.ts Removes DT.Meta/DT.Any modeling; keeps insertable shape keyed off DataSchema.
packages/api/src/predicates/targetIncludes.ts Updates docs/examples to remove .build().
packages/api/src/predicates/equals.ts Updates docs/examples to remove .build().
packages/api/src/parsers/TargetingPredicates.ts Decouples predicates typing from DT.Meta to a minimal { targetingParsers, queryParsers } shape.
packages/api/src/parsers/DataItems.ts Rebinds parsers/types to DataSchema and camelCase keys.
packages/api/src/parsers/DataItemVariablesParser.ts Rebinds variable parser typing to DataSchema and camelCase keys.
packages/api/src/parsers/DataItemRules.ts Rebinds rules parser typing to DataSchema and camelCase keys.
packages/api/src/parsers/DataItemRule.ts Rebinds rule parser typing to DataSchema and camelCase keys.
packages/api/src/parsers/DataItem.ts Rebinds item parser typing to DataSchema and camelCase keys.
packages/api/src/index.ts Removes BuiltDataSchema export and keeps package surface aligned to new API.
packages/api/src/QueryableData.ts Updates query interface generics/indexing to DataSchema + camelCase keys.
packages/api/src/PromisedData.ts Updates promised wrapper generics/indexing to DataSchema + camelCase keys.
packages/api/src/InsertableData.ts Updates insert interface generic bound to DataSchema.
packages/api/src/DataSchema.ts Implements “schema is the record” approach (public frozen records; no .build()).
packages/api/src/Data.ts Makes Data generic over DataSchema, stores schema, and removes built-schema dependency.
packages/api/README.md Updates top-level API docs/examples to remove .build() and explain new split.
README.md Updates repo README examples to remove .build().
.github/copilot-instructions.md Updates internal dev guide references to new DataSchema/Data API shape.

Comment thread packages/api/src/DataSchema.ts
Comment thread packages/api/src/parsers/DataItems.ts Outdated
Comment thread packages/api/src/parsers/DataItem.ts
Comment thread packages/api/src/parsers/DataItemRule.ts
Comment thread packages/client/src/index.ts
Comment thread packages/fs/src/load.ts
Comment thread packages/json-schema/src/cli.ts Outdated
Comment thread packages/api/src/parsers/DataItemRules.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 15:16
@johngeorgewright johngeorgewright merged commit 55e3108 into master Apr 21, 2026
5 checks passed
@johngeorgewright johngeorgewright deleted the simplifying-data-meta branch April 21, 2026 15:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants