Skip to content

feat(standard-schema): standard_schema package (rename from schema_model) + utils + ack re-export#116

Open
leoafarias wants to merge 11 commits into
mainfrom
feat/schema-model-standard
Open

feat(standard-schema): standard_schema package (rename from schema_model) + utils + ack re-export#116
leoafarias wants to merge 11 commits into
mainfrom
feat/schema-model-standard

Conversation

@leoafarias

Copy link
Copy Markdown
Collaborator

Summary

Standardizes the Standard Schema contracts as the standard_schema package (renamed from schema_model) and wires Ack to it.

  • Rename schema_modelstandard_schema to match upstream @standard-schema/spec. The package holds the Standard Schema contracts (not a schema model); Ack's internal JSON-Schema model (ack/lib/src/schema_model/AckSchemaModel) is unaffected.
  • Faithful port, verified field-by-field against the canonical standard-schema/standard-schema index.ts (spec v1.1.0): StandardSchema, StandardJsonSchema, results/issues, validate options, JSON Schema converter + targets.
  • Opt-in utils (package:standard_schema/utils.dart) porting @standard-schema/utils: getDotPath(issue) and StandardSchemaError.
  • Ack re-exports the contract types from package:ack/ack.dart, so consumers don't need a separate standard_schema dependency.

Spec conformance (errors)

Failure output matches the spec's FailureResult/Issue/PathSegment: a flat issues array, each { message, path }, with object keys as strings and list indexes as ints (the PropertyKey form). A parity test maps real nested failures through getDotPathuser.tags.1, user.age.

Documented Dart deviations (all spec-permitted or generics-driven): ~standardstandard getter, dropped phantom types/InferInput/InferOutput, int version, bare-PropertyKey paths, Target as an extension type, and the Dart-only StandardSchemaWithJsonSchema convenience.

Breaking change

SchemaContext.createChild(pathSegment:) now takes a typed SchemaPathSegment (.property / .index / .passThrough) instead of a raw string — affects custom schema authors / manual context construction. Migration snippet in ack/CHANGELOG.md.

Publishing

standard_schema 0.0.1-dev.0 is published to pub.dev (prerelease) to reserve the name; Ack depends on >=0.0.1-dev.0 <0.1.0.

Verification

  • standard_schema: analyze clean, 9/9 tests.
  • ack: analyze clean, 937/937 tests.
  • dart format clean; dart pub publish --dry-run validates.

Moves AckSchemaModel and related types into a new `schema_model` package, adds legacy aliases in `ack` for backwards compatibility, and introduces standard_schema/schema_model_parser alongside updated changelogs and CI config.
Relocate schema model types, parser, and warnings from the schema_model
package into ack under the AckSchemaModel naming. Remove legacy aliases
and compat tests. Narrow schema_model to the StandardSchema validation
contract and update dependent packages and tests accordingly.
Split the StandardSchema contract into StandardTyped, StandardSchema,
StandardJsonSchema, and StandardSchemaWithJsonSchema to match the official
Standard Schema family. AckSchema now implements the combined
StandardSchemaWithJsonSchema contract.

Introduce a typed SchemaPathSegment so standard issue paths distinguish
string object keys from integer list indexes, preserving numeric-looking
object keys as strings.
… ack

Rename schema_model -> standard_schema to match @standard-schema/spec; the internal ack AckSchemaModel (lib/src/schema_model/) is unaffected. Add the opt-in utils.dart library (getDotPath + StandardSchemaError) porting @standard-schema/utils. Re-export the standard_schema contract types from package:ack so consumers no longer need a separate dependency. Document spec deviations and the SchemaPathSegment migration. Publish prep: standard_schema 0.0.1-dev.0 with ack's dependency constraint updated to match.
@docs-page

docs-page Bot commented Jun 10, 2026

Copy link
Copy Markdown

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/ack~116

Documentation is deployed and generated using docs.page.

CI resolves firebase_ai ^3.12.1 to 3.12.2 (the lock is gitignored, so it floats); the native fixture manifest tests assert the recorded sourceVersion matches the resolved package version. Regenerated via tool/generate_firebase_ai_response_json_schema_fixtures.dart -- only sourceVersion changed (3.12.1 -> 3.12.2); schema output is byte-identical. Fixes the failing 'manifest tracks every case and feature' tests.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new standard_schema Dart package that defines Standard Schema contracts (+ opt-in utils), and wires package:ack to implement and re-export those contracts so consumers can use AckSchema.standard without adding an extra dependency.

Changes:

  • Add the new packages/standard_schema package (contracts, JSON Schema converter API, utils, tests, publishing metadata).
  • Implement Standard Schema validation + JSON Schema conversion on AckSchema.standard, including flattening ACK errors into StandardIssue paths.
  • Introduce typed path segments (SchemaPathSegment) to preserve string-vs-index identity in issue paths; add AckSchemaModel.fromJsonSchema(...) JSON Schema import.

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/update_release_changelog.dart Include standard_schema changelog in release automation.
README.md Document the new standard_schema package in the monorepo overview.
pubspec.yaml Add standard_schema to the workspace and Melos package sets.
PUBLISHING.md Update release/publish instructions to include standard_schema (incl. first-publish notes).
packages/standard_schema/test/utils_test.dart Tests for getDotPath and StandardSchemaError.
packages/standard_schema/test/standard_schema_test.dart Conformance-style tests for the contract traits and JSON Schema converter API.
packages/standard_schema/README.md Package documentation and usage examples.
packages/standard_schema/pubspec.yaml New package metadata and SDK/dev dependency constraints.
packages/standard_schema/LICENSE License file for the new package.
packages/standard_schema/lib/utils.dart Opt-in utils barrel export.
packages/standard_schema/lib/standard_schema.dart Main barrel export for Standard Schema contracts.
packages/standard_schema/lib/src/utils.dart Implementation of getDotPath and StandardSchemaError.
packages/standard_schema/lib/src/standard_schema.dart Core Standard Schema contracts, results, and JSON Schema converter types.
packages/standard_schema/CHANGELOG.md Initial dev changelog entry.
packages/standard_schema/analysis_options.yaml Analyzer strictness for the new package.
packages/standard_schema/.pubignore Pub publishing ignore rules for the new package.
packages/ack/test/validation/standard_schema_export_test.dart Test that ack.dart re-exports Standard Schema contract types.
packages/ack/test/validation/standard_schema_dotpath_test.dart Parity test for dot-path rendering of ACK-produced issue paths.
packages/ack/test/validation/standard_schema_conformance_test.dart Conformance tests for AckSchema.standard, typed path segments, and JSON Schema target behavior.
packages/ack/test/schemas/core_schema_test.dart Minor whitespace/formatting cleanup.
packages/ack/test/schema_model/ack_schema_model_parser_test.dart Tests for the new AckSchemaModel.fromJsonSchema(...) importer.
packages/ack/pubspec.yaml Add dependency on standard_schema.
packages/ack/lib/src/validation/standard_issues.dart Convert SchemaError trees into flat StandardIssue lists.
packages/ack/lib/src/schemas/schema.dart Implement StandardSchemaWithJsonSchema via AckSchema.standard + Draft-7-only converter.
packages/ack/lib/src/schemas/object_schema.dart Update child context creation to use typed property path segments.
packages/ack/lib/src/schemas/list_schema.dart Update child context creation to use typed index path segments.
packages/ack/lib/src/schemas/discriminated_object_schema.dart Use pass-through path segments for discriminator branch routing.
packages/ack/lib/src/schemas/any_of_schema.dart Use pass-through path segments for composition branches.
packages/ack/lib/src/schema_model/ack_schema_model.dart Add AckSchemaModel.fromJsonSchema(...) and include parser part.
packages/ack/lib/src/schema_model/ack_schema_model_parser.dart New JSON Schema importer implementation.
packages/ack/lib/src/context.dart Add SchemaPathSegment and expose SchemaContext.pathSegments.
packages/ack/lib/ack.dart Re-export standard_schema contract types (and standard issue conversion).
packages/ack/CHANGELOG.md Document breaking change + new Standard Schema and JSON Schema import features.
packages/ack_firebase_ai/test/to_firebase_ai_native_schema_fixture_test.dart Relax fixture provenance assertion to avoid patch-bump noise.
packages/ack_firebase_ai/test/fixtures/firebase_ai_native_schema/manifest.json Update recorded firebase_ai source version.
packages/ack_firebase_ai/test/fixtures/firebase_ai_native_json_schema/manifest.json Update recorded firebase_ai source version.
.github/workflows/release.yml Add standard_schema to the release workflow package list.

Comment thread packages/ack/lib/src/context.dart Outdated
Comment on lines +18 to +21
const SchemaPathSegment.index(int index)
: assert(index >= 0, 'List path indexes must be non-negative.'),
_kind = _SchemaPathSegmentKind.listIndex,
_value = index;
Comment thread packages/ack/lib/src/context.dart Outdated
Comment on lines +96 to +104
List<Object> get pathSegments {
final parentSegments = parent?.pathSegments ?? const <Object>[];
if (parent == null) return parentSegments;

final segment = pathSegment ?? SchemaPathSegment.property(name);
final pathValue = segment._issueValue;
if (pathValue == null) return parentSegments;
return [...parentSegments, pathValue];
}
Comment thread packages/ack/CHANGELOG.md Outdated
Comment on lines +26 to +36
* `AckSchema.standard` implements the combined `StandardSchemaWithJsonSchema`
contract with flat `StandardIssue` failures and a Draft-7 JSON Schema
converter.
* `SchemaContext.pathSegments` exposes raw path segments with list indices as
integers while preserving numeric-looking object keys as strings, and
`SchemaError.toStandardIssues()` maps ACK errors to standard issues.
* `AckSchemaModel.fromJsonSchema(...)` imports supported Draft-7 JSON Schema
maps into ACK's existing schema model as a best-effort Ack feature.
* `package:ack/ack.dart` now re-exports the `standard_schema` contract types
(`StandardSchema`, `StandardResult`, `StandardIssue`, `JsonSchemaTarget`,
…) so they can be used without depending on `standard_schema` directly.
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