feat(standard-schema): standard_schema package (rename from schema_model) + utils + ack re-export#116
Open
leoafarias wants to merge 11 commits into
Open
feat(standard-schema): standard_schema package (rename from schema_model) + utils + ack re-export#116leoafarias wants to merge 11 commits into
leoafarias wants to merge 11 commits into
Conversation
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.
|
To view this pull requests documentation preview, visit the following URL: 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.
There was a problem hiding this comment.
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_schemapackage (contracts, JSON Schema converter API, utils, tests, publishing metadata). - Implement Standard Schema validation + JSON Schema conversion on
AckSchema.standard, including flattening ACK errors intoStandardIssuepaths. - Introduce typed path segments (
SchemaPathSegment) to preserve string-vs-index identity in issue paths; addAckSchemaModel.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 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 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 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. |
…ndard # Conflicts: # pubspec.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Standardizes the Standard Schema contracts as the
standard_schemapackage (renamed fromschema_model) and wires Ack to it.schema_model→standard_schemato 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.standard-schema/standard-schemaindex.ts(spec v1.1.0):StandardSchema,StandardJsonSchema, results/issues, validate options, JSON Schema converter + targets.package:standard_schema/utils.dart) porting@standard-schema/utils:getDotPath(issue)andStandardSchemaError.package:ack/ack.dart, so consumers don't need a separatestandard_schemadependency.Spec conformance (errors)
Failure output matches the spec's
FailureResult/Issue/PathSegment: a flatissuesarray, each{ message, path }, with object keys as strings and list indexes as ints (thePropertyKeyform). A parity test maps real nested failures throughgetDotPath→user.tags.1,user.age.Documented Dart deviations (all spec-permitted or generics-driven):
~standard→standardgetter, dropped phantomtypes/InferInput/InferOutput,intversion, bare-PropertyKeypaths,Targetas an extension type, and the Dart-onlyStandardSchemaWithJsonSchemaconvenience.Breaking change
SchemaContext.createChild(pathSegment:)now takes a typedSchemaPathSegment(.property/.index/.passThrough) instead of a raw string — affects custom schema authors / manual context construction. Migration snippet inack/CHANGELOG.md.Publishing
standard_schema 0.0.1-dev.0is 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 formatclean;dart pub publish --dry-runvalidates.