@metaobjectsdev/metadata 0.9.0 → 0.11.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attr-schema-validate.d.ts +1 -1
- package/dist/attr-schema-validate.d.ts.map +1 -1
- package/dist/attr-schema-validate.js +96 -11
- package/dist/attr-schema-validate.js.map +1 -1
- package/dist/constraint-merge.d.ts +18 -0
- package/dist/constraint-merge.d.ts.map +1 -0
- package/dist/constraint-merge.js +0 -0
- package/dist/constraint-merge.js.map +1 -0
- package/dist/constraint-validate.d.ts +6 -0
- package/dist/constraint-validate.d.ts.map +1 -0
- package/dist/constraint-validate.js +274 -0
- package/dist/constraint-validate.js.map +1 -0
- package/dist/core/attr/attr-constants.d.ts +13 -3
- package/dist/core/attr/attr-constants.d.ts.map +1 -1
- package/dist/core/attr/attr-constants.js +11 -2
- package/dist/core/attr/attr-constants.js.map +1 -1
- package/dist/core/attr/attr-definition.embedded.d.ts +3 -0
- package/dist/core/attr/attr-definition.embedded.d.ts.map +1 -0
- package/dist/core/attr/attr-definition.embedded.js +60 -0
- package/dist/core/attr/attr-definition.embedded.js.map +1 -0
- package/dist/core/documentation/doc-constants.d.ts +3 -2
- package/dist/core/documentation/doc-constants.d.ts.map +1 -1
- package/dist/core/documentation/doc-constants.js +3 -1
- package/dist/core/documentation/doc-constants.js.map +1 -1
- package/dist/core/documentation/doc-provider.d.ts.map +1 -1
- package/dist/core/documentation/doc-provider.js +6 -2
- package/dist/core/documentation/doc-provider.js.map +1 -1
- package/dist/core/documentation/documentation-definition.embedded.d.ts +3 -0
- package/dist/core/documentation/documentation-definition.embedded.d.ts.map +1 -0
- package/dist/core/documentation/documentation-definition.embedded.js +79 -0
- package/dist/core/documentation/documentation-definition.embedded.js.map +1 -0
- package/dist/core/field/field-constants.d.ts +7 -4
- package/dist/core/field/field-constants.d.ts.map +1 -1
- package/dist/core/field/field-constants.js +7 -7
- package/dist/core/field/field-constants.js.map +1 -1
- package/dist/core/field/field-definition.embedded.d.ts +3 -0
- package/dist/core/field/field-definition.embedded.d.ts.map +1 -0
- package/dist/core/field/field-definition.embedded.js +236 -0
- package/dist/core/field/field-definition.embedded.js.map +1 -0
- package/dist/core/field/meta-field.d.ts.map +1 -1
- package/dist/core/field/meta-field.js +7 -5
- package/dist/core/field/meta-field.js.map +1 -1
- package/dist/core/identity/identity-constants.d.ts.map +1 -1
- package/dist/core/identity/identity-constants.js +3 -0
- package/dist/core/identity/identity-constants.js.map +1 -1
- package/dist/core/identity/identity-definition.embedded.d.ts +3 -0
- package/dist/core/identity/identity-definition.embedded.d.ts.map +1 -0
- package/dist/core/identity/identity-definition.embedded.js +93 -0
- package/dist/core/identity/identity-definition.embedded.js.map +1 -0
- package/dist/core/identity/meta-identity.d.ts.map +1 -1
- package/dist/core/identity/meta-identity.js +8 -1
- package/dist/core/identity/meta-identity.js.map +1 -1
- package/dist/core/identity/validate-identity-passthrough.d.ts +42 -0
- package/dist/core/identity/validate-identity-passthrough.d.ts.map +1 -0
- package/dist/core/identity/validate-identity-passthrough.js +158 -0
- package/dist/core/identity/validate-identity-passthrough.js.map +1 -0
- package/dist/core/object/object-constants.d.ts +2 -1
- package/dist/core/object/object-constants.d.ts.map +1 -1
- package/dist/core/object/object-constants.js +3 -0
- package/dist/core/object/object-constants.js.map +1 -1
- package/dist/core/object/object-definition.embedded.d.ts +3 -0
- package/dist/core/object/object-definition.embedded.d.ts.map +1 -0
- package/dist/core/object/object-definition.embedded.js +110 -0
- package/dist/core/object/object-definition.embedded.js.map +1 -0
- package/dist/core/object/validate-discriminator.d.ts.map +1 -1
- package/dist/core/object/validate-discriminator.js +1 -3
- package/dist/core/object/validate-discriminator.js.map +1 -1
- package/dist/core/query/query-constants.d.ts.map +1 -1
- package/dist/core/query/query-constants.js +5 -3
- package/dist/core/query/query-constants.js.map +1 -1
- package/dist/core/relationship/derive-m2m-fields.d.ts +26 -0
- package/dist/core/relationship/derive-m2m-fields.d.ts.map +1 -0
- package/dist/core/relationship/derive-m2m-fields.js +102 -0
- package/dist/core/relationship/derive-m2m-fields.js.map +1 -0
- package/dist/core/relationship/meta-relationship.d.ts +6 -4
- package/dist/core/relationship/meta-relationship.d.ts.map +1 -1
- package/dist/core/relationship/meta-relationship.js +12 -8
- package/dist/core/relationship/meta-relationship.js.map +1 -1
- package/dist/core/relationship/relationship-constants.d.ts +6 -2
- package/dist/core/relationship/relationship-constants.d.ts.map +1 -1
- package/dist/core/relationship/relationship-constants.js +6 -2
- package/dist/core/relationship/relationship-constants.js.map +1 -1
- package/dist/core/relationship/relationship-definition.embedded.d.ts +3 -0
- package/dist/core/relationship/relationship-definition.embedded.d.ts.map +1 -0
- package/dist/core/relationship/relationship-definition.embedded.js +310 -0
- package/dist/core/relationship/relationship-definition.embedded.js.map +1 -0
- package/dist/core/validator/validator-constants.d.ts +14 -1
- package/dist/core/validator/validator-constants.d.ts.map +1 -1
- package/dist/core/validator/validator-constants.js +20 -1
- package/dist/core/validator/validator-constants.js.map +1 -1
- package/dist/core/validator/validator-definition.embedded.d.ts +3 -0
- package/dist/core/validator/validator-definition.embedded.d.ts.map +1 -0
- package/dist/core/validator/validator-definition.embedded.js +255 -0
- package/dist/core/validator/validator-definition.embedded.js.map +1 -0
- package/dist/core/yaml-desugar.d.ts.map +1 -1
- package/dist/core/yaml-desugar.js +88 -10
- package/dist/core/yaml-desugar.js.map +1 -1
- package/dist/core-types.d.ts +5 -2
- package/dist/core-types.d.ts.map +1 -1
- package/dist/core-types.js +285 -116
- package/dist/core-types.js.map +1 -1
- package/dist/errors.d.ts +3 -3
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +87 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/library/embedded-library.generated.d.ts +2 -0
- package/dist/library/embedded-library.generated.d.ts.map +1 -0
- package/dist/library/embedded-library.generated.js +11 -0
- package/dist/library/embedded-library.generated.js.map +1 -0
- package/dist/library/library-sources.d.ts +12 -0
- package/dist/library/library-sources.d.ts.map +1 -0
- package/dist/library/library-sources.js +88 -0
- package/dist/library/library-sources.js.map +1 -0
- package/dist/loader/meta-data-loader.d.ts +10 -2
- package/dist/loader/meta-data-loader.d.ts.map +1 -1
- package/dist/loader/meta-data-loader.js +57 -6
- package/dist/loader/meta-data-loader.js.map +1 -1
- package/dist/loader/shortcuts.d.ts +2 -5
- package/dist/loader/shortcuts.d.ts.map +1 -1
- package/dist/loader/shortcuts.js.map +1 -1
- package/dist/loader/validation-passes.d.ts +3 -0
- package/dist/loader/validation-passes.d.ts.map +1 -1
- package/dist/loader/validation-passes.js +519 -34
- package/dist/loader/validation-passes.js.map +1 -1
- package/dist/loader/validation-registry.d.ts +10 -0
- package/dist/loader/validation-registry.d.ts.map +1 -0
- package/dist/loader/validation-registry.js +84 -0
- package/dist/loader/validation-registry.js.map +1 -0
- package/dist/metamodel-docs/index.d.ts +19 -0
- package/dist/metamodel-docs/index.d.ts.map +1 -0
- package/dist/metamodel-docs/index.js +37 -0
- package/dist/metamodel-docs/index.js.map +1 -0
- package/dist/metamodel-docs/provenance.d.ts +42 -0
- package/dist/metamodel-docs/provenance.d.ts.map +1 -0
- package/dist/metamodel-docs/provenance.js +148 -0
- package/dist/metamodel-docs/provenance.js.map +1 -0
- package/dist/metamodel-docs/provider-definitions.d.ts +8 -0
- package/dist/metamodel-docs/provider-definitions.d.ts.map +1 -0
- package/dist/metamodel-docs/provider-definitions.js +48 -0
- package/dist/metamodel-docs/provider-definitions.js.map +1 -0
- package/dist/metamodel-docs/render.d.ts +12 -0
- package/dist/metamodel-docs/render.d.ts.map +1 -0
- package/dist/metamodel-docs/render.js +252 -0
- package/dist/metamodel-docs/render.js.map +1 -0
- package/dist/naming-refs.d.ts +41 -0
- package/dist/naming-refs.d.ts.map +1 -0
- package/dist/naming-refs.js +144 -0
- package/dist/naming-refs.js.map +1 -0
- package/dist/naming.d.ts.map +1 -1
- package/dist/naming.js +10 -2
- package/dist/naming.js.map +1 -1
- package/dist/parser-core.d.ts.map +1 -1
- package/dist/parser-core.js +84 -9
- package/dist/parser-core.js.map +1 -1
- package/dist/persistence/db/db-constants.d.ts +10 -0
- package/dist/persistence/db/db-constants.d.ts.map +1 -1
- package/dist/persistence/db/db-constants.js +14 -0
- package/dist/persistence/db/db-constants.js.map +1 -1
- package/dist/persistence/db/db-definition.embedded.d.ts +3 -0
- package/dist/persistence/db/db-definition.embedded.d.ts.map +1 -0
- package/dist/persistence/db/db-definition.embedded.js +227 -0
- package/dist/persistence/db/db-definition.embedded.js.map +1 -0
- package/dist/persistence/db/db-provider.d.ts.map +1 -1
- package/dist/persistence/db/db-provider.js +13 -18
- package/dist/persistence/db/db-provider.js.map +1 -1
- package/dist/persistence/origin/origin-definition.embedded.d.ts +3 -0
- package/dist/persistence/origin/origin-definition.embedded.d.ts.map +1 -0
- package/dist/persistence/origin/origin-definition.embedded.js +88 -0
- package/dist/persistence/origin/origin-definition.embedded.js.map +1 -0
- package/dist/persistence/source/source-definition.embedded.d.ts +3 -0
- package/dist/persistence/source/source-definition.embedded.d.ts.map +1 -0
- package/dist/persistence/source/source-definition.embedded.js +17 -0
- package/dist/persistence/source/source-definition.embedded.js.map +1 -0
- package/dist/persistence/source/validate-source-parameter-ref.d.ts.map +1 -1
- package/dist/persistence/source/validate-source-parameter-ref.js +7 -1
- package/dist/persistence/source/validate-source-parameter-ref.js.map +1 -1
- package/dist/persistence/source/validate-source-roles.d.ts.map +1 -1
- package/dist/persistence/source/validate-source-roles.js +16 -1
- package/dist/persistence/source/validate-source-roles.js.map +1 -1
- package/dist/presentation/layout/layout-definition.embedded.d.ts +3 -0
- package/dist/presentation/layout/layout-definition.embedded.d.ts.map +1 -0
- package/dist/presentation/layout/layout-definition.embedded.js +16 -0
- package/dist/presentation/layout/layout-definition.embedded.js.map +1 -0
- package/dist/presentation/ui/ui-definition.embedded.d.ts +3 -0
- package/dist/presentation/ui/ui-definition.embedded.d.ts.map +1 -0
- package/dist/presentation/ui/ui-definition.embedded.js +114 -0
- package/dist/presentation/ui/ui-definition.embedded.js.map +1 -0
- package/dist/presentation/ui/ui-provider.d.ts +3 -0
- package/dist/presentation/ui/ui-provider.d.ts.map +1 -0
- package/dist/presentation/ui/ui-provider.js +21 -0
- package/dist/presentation/ui/ui-provider.js.map +1 -0
- package/dist/presentation/view/view-definition.embedded.d.ts +3 -0
- package/dist/presentation/view/view-definition.embedded.d.ts.map +1 -0
- package/dist/presentation/view/view-definition.embedded.js +76 -0
- package/dist/presentation/view/view-definition.embedded.js.map +1 -0
- package/dist/provider-data.d.ts +184 -0
- package/dist/provider-data.d.ts.map +1 -0
- package/dist/provider-data.js +271 -0
- package/dist/provider-data.js.map +1 -0
- package/dist/provider.d.ts +3 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +15 -1
- package/dist/provider.js.map +1 -1
- package/dist/registry-coverage.d.ts +99 -0
- package/dist/registry-coverage.d.ts.map +1 -0
- package/dist/registry-coverage.js +294 -0
- package/dist/registry-coverage.js.map +1 -0
- package/dist/registry-manifest-exclusions.d.ts +62 -0
- package/dist/registry-manifest-exclusions.d.ts.map +1 -0
- package/dist/registry-manifest-exclusions.js +163 -0
- package/dist/registry-manifest-exclusions.js.map +1 -0
- package/dist/registry-manifest.d.ts +117 -0
- package/dist/registry-manifest.d.ts.map +1 -0
- package/dist/registry-manifest.js +242 -0
- package/dist/registry-manifest.js.map +1 -0
- package/dist/registry.d.ts +76 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +37 -1
- package/dist/registry.js.map +1 -1
- package/dist/shared/structural.d.ts +7 -0
- package/dist/shared/structural.d.ts.map +1 -1
- package/dist/shared/structural.js +7 -0
- package/dist/shared/structural.js.map +1 -1
- package/dist/subtype-rules.d.ts.map +1 -1
- package/dist/subtype-rules.js +97 -13
- package/dist/subtype-rules.js.map +1 -1
- package/dist/super-resolve.d.ts +49 -2
- package/dist/super-resolve.d.ts.map +1 -1
- package/dist/super-resolve.js +128 -43
- package/dist/super-resolve.js.map +1 -1
- package/dist/template/meta-template.d.ts +3 -2
- package/dist/template/meta-template.d.ts.map +1 -1
- package/dist/template/meta-template.js +3 -2
- package/dist/template/meta-template.js.map +1 -1
- package/dist/template/prompt-definition.embedded.d.ts +3 -0
- package/dist/template/prompt-definition.embedded.d.ts.map +1 -0
- package/dist/template/prompt-definition.embedded.js +368 -0
- package/dist/template/prompt-definition.embedded.js.map +1 -0
- package/dist/template/prompt-provider.d.ts +3 -0
- package/dist/template/prompt-provider.d.ts.map +1 -0
- package/dist/template/prompt-provider.js +25 -0
- package/dist/template/prompt-provider.js.map +1 -0
- package/dist/template/template-constants.d.ts +2 -0
- package/dist/template/template-constants.d.ts.map +1 -1
- package/dist/template/template-constants.js +7 -0
- package/dist/template/template-constants.js.map +1 -1
- package/dist/template/template-definition.embedded.d.ts +3 -0
- package/dist/template/template-definition.embedded.d.ts.map +1 -0
- package/dist/template/template-definition.embedded.js +30 -0
- package/dist/template/template-definition.embedded.js.map +1 -0
- package/dist/validate-max-occurs.d.ts +5 -0
- package/dist/validate-max-occurs.d.ts.map +1 -0
- package/dist/validate-max-occurs.js +28 -0
- package/dist/validate-max-occurs.js.map +1 -0
- package/dist/validation-types.d.ts +36 -0
- package/dist/validation-types.d.ts.map +1 -0
- package/dist/validation-types.js +7 -0
- package/dist/validation-types.js.map +1 -0
- package/package.json +33 -22
- package/src/attr-schema-validate.ts +108 -8
- package/src/constraint-merge.ts +0 -0
- package/src/constraint-validate.ts +363 -0
- package/src/core/attr/attr-constants.ts +15 -3
- package/src/core/attr/attr-definition.embedded.ts +67 -0
- package/src/core/documentation/doc-constants.ts +3 -1
- package/src/core/documentation/doc-provider.ts +6 -2
- package/src/core/documentation/documentation-definition.embedded.ts +86 -0
- package/src/core/field/field-constants.ts +8 -7
- package/src/core/field/field-definition.embedded.ts +243 -0
- package/src/core/field/meta-field.ts +6 -7
- package/src/core/identity/identity-constants.ts +4 -0
- package/src/core/identity/identity-definition.embedded.ts +100 -0
- package/src/core/identity/meta-identity.ts +8 -1
- package/src/core/identity/validate-identity-passthrough.ts +194 -0
- package/src/core/object/object-constants.ts +3 -0
- package/src/core/object/object-definition.embedded.ts +117 -0
- package/src/core/object/validate-discriminator.ts +0 -4
- package/src/core/query/query-constants.ts +5 -3
- package/src/core/relationship/derive-m2m-fields.ts +145 -0
- package/src/core/relationship/meta-relationship.ts +15 -9
- package/src/core/relationship/relationship-constants.ts +6 -2
- package/src/core/relationship/relationship-definition.embedded.ts +317 -0
- package/src/core/validator/validator-constants.ts +22 -1
- package/src/core/validator/validator-definition.embedded.ts +262 -0
- package/src/core/yaml-desugar.ts +96 -7
- package/src/core-types.ts +314 -150
- package/src/errors.ts +89 -2
- package/src/index.ts +47 -2
- package/src/library/embedded-library.generated.ts +10 -0
- package/src/library/library-sources.ts +97 -0
- package/src/loader/meta-data-loader.ts +78 -7
- package/src/loader/shortcuts.ts +2 -2
- package/src/loader/validation-passes.ts +690 -34
- package/src/loader/validation-registry.ts +93 -0
- package/src/metamodel-docs/index.ts +41 -0
- package/src/metamodel-docs/provenance.ts +187 -0
- package/src/metamodel-docs/provider-definitions.ts +50 -0
- package/src/metamodel-docs/render.ts +309 -0
- package/src/naming-refs.ts +162 -0
- package/src/naming.ts +10 -2
- package/src/parser-core.ts +96 -9
- package/src/persistence/db/db-constants.ts +16 -0
- package/src/persistence/db/db-definition.embedded.ts +234 -0
- package/src/persistence/db/db-provider.ts +13 -18
- package/src/persistence/origin/origin-definition.embedded.ts +95 -0
- package/src/persistence/source/source-definition.embedded.ts +24 -0
- package/src/persistence/source/validate-source-parameter-ref.ts +7 -1
- package/src/persistence/source/validate-source-roles.ts +22 -1
- package/src/presentation/layout/layout-definition.embedded.ts +23 -0
- package/src/presentation/ui/ui-definition.embedded.ts +121 -0
- package/src/presentation/ui/ui-provider.ts +25 -0
- package/src/presentation/view/view-definition.embedded.ts +83 -0
- package/src/provider-data.ts +463 -0
- package/src/provider.ts +18 -0
- package/src/registry-coverage.ts +430 -0
- package/src/registry-manifest-exclusions.ts +176 -0
- package/src/registry-manifest.ts +334 -0
- package/src/registry.ts +106 -3
- package/src/shared/structural.ts +8 -0
- package/src/subtype-rules.ts +135 -18
- package/src/super-resolve.ts +153 -43
- package/src/template/meta-template.ts +3 -2
- package/src/template/prompt-definition.embedded.ts +375 -0
- package/src/template/prompt-provider.ts +29 -0
- package/src/template/template-constants.ts +8 -0
- package/src/template/template-definition.embedded.ts +37 -0
- package/src/validate-max-occurs.ts +39 -0
- package/src/validation-types.ts +57 -0
- package/dist/core/documentation/doc-schema.d.ts +0 -8
- package/dist/core/documentation/doc-schema.d.ts.map +0 -1
- package/dist/core/documentation/doc-schema.js +0 -53
- package/dist/core/documentation/doc-schema.js.map +0 -1
- package/dist/core/field/field-schema.d.ts +0 -22
- package/dist/core/field/field-schema.d.ts.map +0 -1
- package/dist/core/field/field-schema.js +0 -171
- package/dist/core/field/field-schema.js.map +0 -1
- package/dist/core/identity/identity-schema.d.ts +0 -6
- package/dist/core/identity/identity-schema.d.ts.map +0 -1
- package/dist/core/identity/identity-schema.js +0 -55
- package/dist/core/identity/identity-schema.js.map +0 -1
- package/dist/core/object/object-schema.d.ts +0 -4
- package/dist/core/object/object-schema.d.ts.map +0 -1
- package/dist/core/object/object-schema.js +0 -28
- package/dist/core/object/object-schema.js.map +0 -1
- package/dist/core/relationship/relationship-schema.d.ts +0 -4
- package/dist/core/relationship/relationship-schema.d.ts.map +0 -1
- package/dist/core/relationship/relationship-schema.js +0 -51
- package/dist/core/relationship/relationship-schema.js.map +0 -1
- package/dist/core/validator/validator-schema.d.ts +0 -4
- package/dist/core/validator/validator-schema.d.ts.map +0 -1
- package/dist/core/validator/validator-schema.js +0 -38
- package/dist/core/validator/validator-schema.js.map +0 -1
- package/dist/persistence/db/db-schema.d.ts +0 -14
- package/dist/persistence/db/db-schema.d.ts.map +0 -1
- package/dist/persistence/db/db-schema.js +0 -35
- package/dist/persistence/db/db-schema.js.map +0 -1
- package/dist/persistence/origin/origin-schema.d.ts +0 -4
- package/dist/persistence/origin/origin-schema.d.ts.map +0 -1
- package/dist/persistence/origin/origin-schema.js +0 -59
- package/dist/persistence/origin/origin-schema.js.map +0 -1
- package/dist/persistence/source/source-schema.d.ts +0 -4
- package/dist/persistence/source/source-schema.d.ts.map +0 -1
- package/dist/persistence/source/source-schema.js +0 -98
- package/dist/persistence/source/source-schema.js.map +0 -1
- package/dist/presentation/layout/layout-schema.d.ts +0 -4
- package/dist/presentation/layout/layout-schema.d.ts.map +0 -1
- package/dist/presentation/layout/layout-schema.js +0 -46
- package/dist/presentation/layout/layout-schema.js.map +0 -1
- package/dist/presentation/view/view-schema.d.ts +0 -4
- package/dist/presentation/view/view-schema.d.ts.map +0 -1
- package/dist/presentation/view/view-schema.js +0 -15
- package/dist/presentation/view/view-schema.js.map +0 -1
- package/dist/template/template-schema.d.ts +0 -3
- package/dist/template/template-schema.d.ts.map +0 -1
- package/dist/template/template-schema.js +0 -173
- package/dist/template/template-schema.js.map +0 -1
- package/src/core/documentation/doc-schema.ts +0 -64
- package/src/core/field/field-schema.ts +0 -228
- package/src/core/identity/identity-schema.ts +0 -80
- package/src/core/object/object-schema.ts +0 -35
- package/src/core/relationship/relationship-schema.ts +0 -67
- package/src/core/validator/validator-schema.ts +0 -50
- package/src/persistence/db/db-schema.ts +0 -50
- package/src/persistence/origin/origin-schema.ts +0 -80
- package/src/persistence/source/source-schema.ts +0 -129
- package/src/presentation/layout/layout-schema.ts +0 -62
- package/src/presentation/view/view-schema.ts +0 -21
- package/src/template/template-schema.ts +0 -211
package/src/errors.ts
CHANGED
|
@@ -23,7 +23,35 @@ export const ERROR_CODES = [
|
|
|
23
23
|
"ERR_MISSING_SUBTYPE",
|
|
24
24
|
"ERR_DUPLICATE_NAME",
|
|
25
25
|
"ERR_UNRESOLVED_SUPER",
|
|
26
|
+
// FR-024 (ADR-0029) — a dotted `Entity.child` extends ref resolved to a node
|
|
27
|
+
// whose type or subtype does not match the extending node's. Dotted-only.
|
|
28
|
+
"ERR_EXTENDS_TARGET_MISMATCH",
|
|
29
|
+
// FR-024 — an identity.* node has no name. Identities are named,
|
|
30
|
+
// author-chosen (e.g. "id"), so the dotted by-name extends form can
|
|
31
|
+
// address them.
|
|
32
|
+
"ERR_IDENTITY_NAME_REQUIRED",
|
|
33
|
+
// A `type.subType` declared with `maxOccurs` (e.g. identity.primary,
|
|
34
|
+
// maxOccurs:1) appears more times than allowed under one parent.
|
|
35
|
+
"ERR_TOO_MANY_OCCURRENCES",
|
|
36
|
+
// FR-024 — an identity.* on an object.projection lacks `extends`; a
|
|
37
|
+
// projection identity is a pass-through of an entity identity.
|
|
38
|
+
"ERR_PROJECTION_IDENTITY_NOT_EXTENDED",
|
|
39
|
+
// FR-024 — identity key correspondence broken: an extended-identity field
|
|
40
|
+
// has no local pass-through field extending it, or an explicit @fields
|
|
41
|
+
// disagrees with the computed pass-through key.
|
|
42
|
+
"ERR_IDENTITY_KEY_MISMATCH",
|
|
43
|
+
// FR-024 (ADR-0028) — a source.* on an object.projection has a writable
|
|
44
|
+
// @kind (table, or @kind omitted which defaults to table). Projections are
|
|
45
|
+
// derived read-only representations; their sources must be read-only kinds.
|
|
46
|
+
"ERR_PROJECTION_SOURCE_WRITABLE",
|
|
26
47
|
"ERR_INVALID_SUBTYPE_CHILD",
|
|
48
|
+
// FR-033 — a STRUCTURAL child (field/identity/source/validator/… — not an
|
|
49
|
+
// attr) is placed under a parent whose registered childRules do not admit it
|
|
50
|
+
// (the structural analogue of ERR_UNKNOWN_ATTR). Enforced in validate()
|
|
51
|
+
// against the merged wildcard-match semantics; a NO-OP under today's wildcard
|
|
52
|
+
// childRules (the rail strict per-subtype rules will use in S1). Strict-load
|
|
53
|
+
// only. Detail names the parent, the child, and which placement was rejected.
|
|
54
|
+
"ERR_CHILD_NOT_ALLOWED",
|
|
27
55
|
"ERR_UNKNOWN_ATTR",
|
|
28
56
|
"ERR_BAD_ATTR_VALUE",
|
|
29
57
|
"ERR_BAD_DEFAULT_SORT_FIELD",
|
|
@@ -37,7 +65,42 @@ export const ERROR_CODES = [
|
|
|
37
65
|
"ERR_OVERLAY_NO_TARGET",
|
|
38
66
|
"ERR_MALFORMED_YAML",
|
|
39
67
|
"ERR_INVALID_ORIGIN",
|
|
68
|
+
// FR-024 (ADR-0029 decision 5) — an implicit (omitted-@via) origin path is
|
|
69
|
+
// ambiguous: more than one single-hop relationship leads from the base
|
|
70
|
+
// entity to the @from/@of entity (the error names the candidates), or a
|
|
71
|
+
// projection's base entity cannot be derived because its fields extend
|
|
72
|
+
// multiple entities and no extended identity anchors the base.
|
|
73
|
+
"ERR_AMBIGUOUS_PATH",
|
|
74
|
+
// FR-024 (ADR-0029 decision 6) — origin cardinality contract broken: a
|
|
75
|
+
// passthrough @via path crosses a to-many hop (row-multiplying — you meant
|
|
76
|
+
// aggregate), or an aggregate @via path is to-one at every hop (you meant
|
|
77
|
+
// passthrough). Checked on explicit AND inferred paths.
|
|
78
|
+
"ERR_ORIGIN_CARDINALITY",
|
|
79
|
+
// FR-024 (ADR-0029 decision 7) — a field declares BOTH an entity-nested
|
|
80
|
+
// `extends` (shape lineage) and an `origin.passthrough` @from (data lineage)
|
|
81
|
+
// and they disagree: the resolved @from target is not the field's resolved
|
|
82
|
+
// extends target (nor anywhere on its extends chain). Host-agnostic
|
|
83
|
+
// (projections, entities, values). Aggregates are never judged (they
|
|
84
|
+
// compute something new); a top-level abstract extends target is never
|
|
85
|
+
// judged (shape-only reuse makes no lineage claim).
|
|
86
|
+
"ERR_EXTENDS_ORIGIN_MISMATCH",
|
|
87
|
+
// FR-024 (spec §7) — an object.entity field carrying an origin.* child is
|
|
88
|
+
// derived (read-only), so the entity must declare at least one source with
|
|
89
|
+
// a read-only @kind (view/materializedView/storedProc/tableFunction) to
|
|
90
|
+
// provide it. Table-only (or source-less) entities with derived fields
|
|
91
|
+
// error. Projections and object.value hosts are exempt. Until the Phase-E
|
|
92
|
+
// B4b cutover removes view-PRIMARY entities, a read-only-kind PRIMARY
|
|
93
|
+
// source also counts as providable (legacy spelling).
|
|
94
|
+
"ERR_DERIVED_FIELD_NO_READ_SOURCE",
|
|
95
|
+
"ERR_ENTITY_PRIMARY_SOURCE_READONLY",
|
|
40
96
|
"ERR_INVALID_TEMPLATE",
|
|
97
|
+
// FR-017 — M:N relationship validation (slim vocabulary): @through must name a
|
|
98
|
+
// junction declaring two identity.reference children; @sourceRefField must match
|
|
99
|
+
// one of them; M:N attrs are invalid on a 1:N (@cardinality:one / no @through).
|
|
100
|
+
"ERR_INVALID_RELATIONSHIP",
|
|
101
|
+
// identity.reference @references names an FK target that does not resolve to any
|
|
102
|
+
// object in the loaded tree (a dangling cross-reference between metadata).
|
|
103
|
+
"ERR_INVALID_REFERENCE",
|
|
41
104
|
"ERR_VAR_NOT_ON_PAYLOAD",
|
|
42
105
|
"ERR_PARTIAL_UNRESOLVED",
|
|
43
106
|
"ERR_REQUIRED_SLOT_UNUSED",
|
|
@@ -45,6 +108,9 @@ export const ERROR_CODES = [
|
|
|
45
108
|
"ERR_BAD_ATTR_FILTER",
|
|
46
109
|
"ERR_STORAGE_FLATTENED_ARRAY",
|
|
47
110
|
"ERR_STORAGE_WITHOUT_OBJECT_REF",
|
|
111
|
+
// ADR-0013 — a field.object REQUIRES @objectRef (open/untyped JSON uses
|
|
112
|
+
// the physical @dbColumnType: jsonb escape hatch on field.string instead).
|
|
113
|
+
"ERR_OBJECT_FIELD_WITHOUT_OBJECT_REF",
|
|
48
114
|
// Source v2 (ADR-0007) error codes — enforcement added during the source-v2 rollout.
|
|
49
115
|
"ERR_RESERVED_ATTR",
|
|
50
116
|
"ERR_SOURCE_NO_PRIMARY",
|
|
@@ -71,6 +137,24 @@ export const ERROR_CODES = [
|
|
|
71
137
|
// FR5c — multi-file overlay merge produced a conflicting attribute value:
|
|
72
138
|
// two contributors set the same @attr to different non-empty values.
|
|
73
139
|
"ERR_MERGE_CONFLICT",
|
|
140
|
+
// SP-H Unit9 — @filterable: true on a field subtype with no filter-operator
|
|
141
|
+
// band (e.g. field.object). Would silently generate an empty-ops filter.
|
|
142
|
+
"ERR_FILTERABLE_UNSUPPORTED_SUBTYPE",
|
|
143
|
+
// ADR-0023 — a registration was attempted against a registry sealed after its
|
|
144
|
+
// agreed metamodel-provider bootstrap. Codegen cannot invent metamodel attrs.
|
|
145
|
+
"ERR_REGISTRY_SEALED",
|
|
146
|
+
// FR-032 (ADR-0032) — a ref-bearing attr (extends/@objectRef/@references/
|
|
147
|
+
// origin @from/@of/@via/@parameterRef/@payloadRef/@responseRef) in CANONICAL
|
|
148
|
+
// JSON used a relative authoring form (leading `::` or `..::`). Canonical JSON
|
|
149
|
+
// is the self-contained interchange form: every ref MUST be fully-qualified.
|
|
150
|
+
// Relative navigation is YAML-only (the desugar expands it via expandRef).
|
|
151
|
+
"ERR_RELATIVE_REF_IN_CANONICAL",
|
|
152
|
+
// FR-033 — a provider set's merged metamodel constraint graph is contradictory.
|
|
153
|
+
// Surfaced by validateConstraints (constraint-validate.ts) at registry compose:
|
|
154
|
+
// dangling ref / unsatisfiable required child / bad cardinality / closed-set
|
|
155
|
+
// clash / required-child cycle / conflicting attr redefinition. The detail names
|
|
156
|
+
// which of the six checks fired and the offending type(s).
|
|
157
|
+
"ERR_INVALID_METAMODEL_CONSTRAINT",
|
|
74
158
|
"ERR_UNKNOWN",
|
|
75
159
|
] as const;
|
|
76
160
|
|
|
@@ -111,7 +195,10 @@ export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
|
111
195
|
* envelope's `jsonPath` and `files` and have been dropped — see CHANGELOG.
|
|
112
196
|
*/
|
|
113
197
|
export class ParseError extends Error implements LoaderError {
|
|
114
|
-
|
|
198
|
+
// Widened from the core ErrorCode union so a DOWNSTREAM provider's validator can emit its
|
|
199
|
+
// own codes (LoaderError.code is `string`; the envelope compares codes as strings). Known
|
|
200
|
+
// core codes still surface in editor suggestions via the `string & {}` idiom.
|
|
201
|
+
readonly code: ErrorCode | (string & {});
|
|
115
202
|
readonly source: ErrorSource;
|
|
116
203
|
readonly suggestions?: string[];
|
|
117
204
|
readonly fixture?: string;
|
|
@@ -120,7 +207,7 @@ export class ParseError extends Error implements LoaderError {
|
|
|
120
207
|
constructor(
|
|
121
208
|
message: string,
|
|
122
209
|
opts: {
|
|
123
|
-
code: ErrorCode;
|
|
210
|
+
code: ErrorCode | (string & {});
|
|
124
211
|
source: ErrorSource;
|
|
125
212
|
suggestions?: string[];
|
|
126
213
|
fixture?: string;
|
package/src/index.ts
CHANGED
|
@@ -68,11 +68,23 @@ export {
|
|
|
68
68
|
MetaReferenceIdentity,
|
|
69
69
|
} from "./core/identity/meta-identity.js";
|
|
70
70
|
export type { IdentityGeneration } from "./core/identity/meta-identity.js";
|
|
71
|
+
// FR-024 — projection identity pass-through derivation (computed local key;
|
|
72
|
+
// pure tree read, codegen-facing).
|
|
73
|
+
export {
|
|
74
|
+
computedIdentityFields,
|
|
75
|
+
identityOwnFields,
|
|
76
|
+
identityEffectiveFields,
|
|
77
|
+
resolveIdentityPassthrough,
|
|
78
|
+
} from "./core/identity/validate-identity-passthrough.js";
|
|
79
|
+
export type { IdentityPassthroughResolution } from "./core/identity/validate-identity-passthrough.js";
|
|
71
80
|
// Relationship
|
|
72
81
|
export { MetaRelationship } from "./core/relationship/meta-relationship.js";
|
|
73
82
|
// Cross-entity reference lookup
|
|
74
83
|
export { findReferenceBetween } from "./core/relationship/find-reference.js";
|
|
75
84
|
export type { ReferenceLookup } from "./core/relationship/find-reference.js";
|
|
85
|
+
// FR-017 — M:N junction FK derivation (hetero / directed-self-join / symmetric)
|
|
86
|
+
export { deriveM2MFields, M2MDerivationError } from "./core/relationship/derive-m2m-fields.js";
|
|
87
|
+
export type { M2MFields } from "./core/relationship/derive-m2m-fields.js";
|
|
76
88
|
// Validator: base + subtype-specific
|
|
77
89
|
export {
|
|
78
90
|
MetaValidator,
|
|
@@ -122,9 +134,39 @@ export type AnyMeta =
|
|
|
122
134
|
export { TypeId, TypeRegistry, childRuleMatches } from "./registry.js";
|
|
123
135
|
export type { AttrSchema, ChildRule, TypeDefinition } from "./registry.js";
|
|
124
136
|
export { registerCoreTypes, coreTypesProvider, coreProviders } from "./core-types.js";
|
|
137
|
+
|
|
138
|
+
// FR-033 — the constraint engine: additive merge + the contradiction validator.
|
|
139
|
+
export { mergeConstraints } from "./constraint-merge.js";
|
|
140
|
+
export type { EffectiveConstraints } from "./constraint-merge.js";
|
|
141
|
+
export { validateConstraints } from "./constraint-validate.js";
|
|
142
|
+
|
|
143
|
+
// Registry conformance manifest (SP-G) — the canonical logical-vocabulary serializer.
|
|
144
|
+
export { buildRegistryManifest, emitRegistryManifest, classifyPerTypeAttr } from "./registry-manifest.js";
|
|
145
|
+
export type { AttrClassification } from "./registry-manifest.js";
|
|
146
|
+
export { ExclusionReason } from "./registry-manifest-exclusions.js";
|
|
147
|
+
|
|
148
|
+
// FR-033 S3 — metamodel doc-gen: tiered, LLM-readable docs FOR THE METAMODEL
|
|
149
|
+
// (the type/subtype/attr vocabulary), generated from the strict registry.
|
|
150
|
+
// Distinct from `meta docs --model` (which documents a user's entities).
|
|
151
|
+
export {
|
|
152
|
+
renderMetamodelDocs,
|
|
153
|
+
buildMetamodelProvenance,
|
|
154
|
+
coreProviderDescriptions,
|
|
155
|
+
renderCoreMetamodelDocs,
|
|
156
|
+
} from "./metamodel-docs/index.js";
|
|
157
|
+
export type { MetamodelProvenance } from "./metamodel-docs/index.js";
|
|
158
|
+
|
|
159
|
+
// Registry coverage (SP-G Unit 5) — untested-vocabulary report (manifest vs
|
|
160
|
+
// fixture corpora). NODE-ONLY: registry-coverage.ts statically imports node:fs
|
|
161
|
+
// to scan the fixture corpora, so it must NOT be re-exported from this
|
|
162
|
+
// browser-facing barrel (it would drag node:fs into the root entry, breaking
|
|
163
|
+
// browser-safety.test.ts). It is a build-time tooling module — consumers (and
|
|
164
|
+
// its test) import it directly by path: `@metaobjectsdev/metadata/src/registry-coverage`.
|
|
125
165
|
export { dbProvider } from "./persistence/db/db-provider.js";
|
|
126
|
-
export { commonDocAttrs } from "./core/documentation/doc-schema.js";
|
|
127
166
|
export { docProvider } from "./core/documentation/doc-provider.js";
|
|
167
|
+
export { promptProvider } from "./template/prompt-provider.js";
|
|
168
|
+
export { uiProvider } from "./presentation/ui/ui-provider.js";
|
|
169
|
+
export { FIELD_ATTR_XML_TEXT } from "./template/template-constants.js";
|
|
128
170
|
|
|
129
171
|
// Type provider model
|
|
130
172
|
export { composeRegistry } from "./provider.js";
|
|
@@ -157,9 +199,12 @@ export type { SerializeOptions } from "./serializer-json.js";
|
|
|
157
199
|
// Super resolution helper (most resolution moved into parser; this is the lookup utility)
|
|
158
200
|
export { resolveSuperRef } from "./super-resolve.js";
|
|
159
201
|
|
|
202
|
+
// FR-032 (ADR-0032) — canonical reference expansion + FQN object matching.
|
|
203
|
+
export { expandRef, isRelativeRef, refMatchesObject, REF_BEARING_ATTR_NAMES } from "./naming-refs.js";
|
|
204
|
+
|
|
160
205
|
// Loader hierarchy
|
|
161
206
|
export { MetaDataLoader } from "./loader/meta-data-loader.js";
|
|
162
|
-
export type { LoadOptions, LoadResult, LoadingState } from "./loader/meta-data-loader.js";
|
|
207
|
+
export type { LoadOptions, LoadResult, LoadingState, DirectoryFactoryOptions } from "./loader/meta-data-loader.js";
|
|
163
208
|
export { InMemoryStringSource } from "./loader/meta-data-source.js";
|
|
164
209
|
export type { MetaDataSource, MetaDataFormat } from "./loader/meta-data-source.js";
|
|
165
210
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate-embedded-library.ts — DO NOT EDIT.
|
|
2
|
+
// Canonical source: repo-root library/**/*.yaml
|
|
3
|
+
// Regenerate: bun run scripts/generate-embedded-library.ts
|
|
4
|
+
//
|
|
5
|
+
// Embeds the canonical library files as string literals so they resolve
|
|
6
|
+
// wherever the on-disk library/ directory is unavailable.
|
|
7
|
+
// Keys are refs: path under library/ minus the .yaml extension.
|
|
8
|
+
export const EMBEDDED_LIBRARY: Record<string, string> = {
|
|
9
|
+
"ai/llm-call": "# library/ai/llm-call.yaml\n# MetaObjects-shipped standard metadata. Adopters opt in via the loader's\n# `libraries: [\"ai\"]` option, then `extends: \"metaobjects::ai::LlmCallBase\"`.\nmetadata:\n package: metaobjects::ai\n children:\n - object.entity:\n name: LlmCallBase\n abstract: true\n children:\n - field.uuid: { name: traceId }\n - field.uuid: { name: spanId }\n - field.uuid: { name: parentSpanId }\n - field.string: { name: sessionId }\n - field.string: { name: callType }\n - field.string: { name: system }\n - field.string: { name: requestModel }\n - field.string: { name: responseModel }\n - field.int: { name: inputTokens }\n - field.int: { name: outputTokens }\n - field.currency: { name: costMinor, currency: USD }\n - field.int: { name: latencyMs }\n - field.string: { name: finishReason }\n - field.string: { name: status }\n - field.string: { name: errorDetail }\n - field.timestamp: { name: startedAt }\n - field.string: { name: llmRequest, dbColumnType: jsonb } # generic jsonb (no objectRef)\n - field.string: { name: llmResponse, dbColumnType: jsonb }\n - object.entity:\n name: LlmCall\n extends: metaobjects::ai::LlmCallBase\n children:\n - source.rdb: { table: llm_call, role: primary }\n - identity.primary: { name: id, fields: [\"spanId\"] }\n",
|
|
10
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// library-sources.ts — resolves MetaDataSource instances for shipped library packages.
|
|
2
|
+
//
|
|
3
|
+
// On-disk-first: if the repo-root library/ tree is reachable (dev / installed-from-source
|
|
4
|
+
// layout), a FileSource is returned so edits to the on-disk YAML are picked up immediately.
|
|
5
|
+
// Embedded fallback: when the binary is compiled (bun --compile) or the library/ directory
|
|
6
|
+
// is absent, the content embedded in embedded-library.generated.ts is used.
|
|
7
|
+
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { join, dirname } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { FileSource } from "../loader/sources/file-source.js";
|
|
12
|
+
import { InMemoryStringSource } from "../loader/meta-data-source.js";
|
|
13
|
+
import type { MetaDataSource } from "../loader/meta-data-source.js";
|
|
14
|
+
import { EMBEDDED_LIBRARY } from "./embedded-library.generated.js";
|
|
15
|
+
|
|
16
|
+
// Package → ordered refs, derived from the generated embedded module so adding a
|
|
17
|
+
// library file (which regenerates EMBEDDED_LIBRARY) needs no edit here.
|
|
18
|
+
const REFS_BY_PACKAGE: Readonly<Record<string, readonly string[]>> = (() => {
|
|
19
|
+
const map: Record<string, string[]> = {};
|
|
20
|
+
for (const ref of Object.keys(EMBEDDED_LIBRARY).sort()) {
|
|
21
|
+
const pkg = ref.split("/")[0];
|
|
22
|
+
if (pkg === undefined || pkg === "") continue;
|
|
23
|
+
(map[pkg] ??= []).push(ref);
|
|
24
|
+
}
|
|
25
|
+
return map;
|
|
26
|
+
})();
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Locate the repo-root `library/` directory by walking up from this module's
|
|
30
|
+
* location until a directory contains BOTH `library/` and `server/` (the two
|
|
31
|
+
* structural anchors that identify the repo root). Returns the path to the
|
|
32
|
+
* `library/` subdirectory if found, or `undefined` when absent (compiled binary).
|
|
33
|
+
*/
|
|
34
|
+
function libraryDirOnDisk(): string | undefined {
|
|
35
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
36
|
+
for (let i = 0; i < 12; i++) {
|
|
37
|
+
if (existsSync(join(dir, "library")) && existsSync(join(dir, "server"))) {
|
|
38
|
+
return join(dir, "library");
|
|
39
|
+
}
|
|
40
|
+
const parent = dirname(dir);
|
|
41
|
+
if (parent === dir) break; // reached filesystem root
|
|
42
|
+
dir = parent;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Cache the on-disk location: resolved once per process.
|
|
48
|
+
let _cache: { dir: string | undefined } | undefined;
|
|
49
|
+
|
|
50
|
+
function getLibraryDir(): string | undefined {
|
|
51
|
+
return (_cache ??= { dir: libraryDirOnDisk() }).dir;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns a list of `MetaDataSource` instances for the requested library packages.
|
|
56
|
+
*
|
|
57
|
+
* - Recognized packages: `"ai"` (others contribute no sources).
|
|
58
|
+
* - Per ref: if the on-disk `library/<ref>.yaml` exists, returns a `FileSource`;
|
|
59
|
+
* otherwise falls back to an `InMemoryStringSource` built from the embedded content.
|
|
60
|
+
*
|
|
61
|
+
* @param packages - Package names to include (e.g. `["ai"]`).
|
|
62
|
+
*/
|
|
63
|
+
export function librarySources(packages: string[]): MetaDataSource[] {
|
|
64
|
+
const dir = getLibraryDir();
|
|
65
|
+
const out: MetaDataSource[] = [];
|
|
66
|
+
|
|
67
|
+
for (const pkg of packages) {
|
|
68
|
+
const refs = REFS_BY_PACKAGE[pkg];
|
|
69
|
+
if (refs === undefined) continue; // unknown package — no sources
|
|
70
|
+
|
|
71
|
+
for (const ref of refs) {
|
|
72
|
+
if (dir !== undefined) {
|
|
73
|
+
const path = join(dir, `${ref}.yaml`);
|
|
74
|
+
if (existsSync(path)) {
|
|
75
|
+
out.push(new FileSource(path));
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const embedded = EMBEDDED_LIBRARY[ref];
|
|
80
|
+
if (embedded !== undefined) {
|
|
81
|
+
out.push(
|
|
82
|
+
new InMemoryStringSource(embedded, {
|
|
83
|
+
id: `library:${ref}.yaml`,
|
|
84
|
+
format: "yaml",
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
87
|
+
} else {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`library ref "${ref}" (package "${pkg}") has no on-disk file and no embedded entry — ` +
|
|
90
|
+
`the embedded library module is stale; run scripts/generate-embedded-library.ts`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
@@ -17,7 +17,8 @@ import { ParseError } from "../errors.js";
|
|
|
17
17
|
import type { LoaderWarning } from "../source.js";
|
|
18
18
|
import { codeSource, resolvedSource } from "../source.js";
|
|
19
19
|
import { parseJson } from "../parser-json.js";
|
|
20
|
-
import { validateDataGridSortFields, validateFilterableHasIndex, validateOriginPaths, validateDataGridFilterValues, validateFieldObjectStorage, validateTemplatePayloadRefs, validateFieldDefaults } from "./validation-passes.js";
|
|
20
|
+
import { validateDataGridSortFields, validateFilterableHasIndex, validateFilterableHasSupportedOps, validateOriginPaths, validateDerivedFieldProvidability, validateDataGridFilterValues, validateFieldObjectStorage, validateTemplatePayloadRefs, validateFieldDefaults, validateRelationships } from "./validation-passes.js";
|
|
21
|
+
import { runRegisteredValidation } from "./validation-registry.js";
|
|
21
22
|
import { validateSourceRoles } from "../persistence/source/validate-source-roles.js";
|
|
22
23
|
import { validateSourcePhysicalNames } from "../persistence/source/validate-source-physical-names.js";
|
|
23
24
|
import { validateSourceParameterRef } from "../persistence/source/validate-source-parameter-ref.js";
|
|
@@ -25,6 +26,8 @@ import { validateFieldReadOnly } from "../core/field/validate-field-readonly.js"
|
|
|
25
26
|
import { validateDiscriminator } from "../core/object/validate-discriminator.js";
|
|
26
27
|
import { resolveDeferredSupers } from "../super-resolve.js";
|
|
27
28
|
import { validateSubtypeRules } from "../subtype-rules.js";
|
|
29
|
+
import { validateMaxOccurs } from "../validate-max-occurs.js";
|
|
30
|
+
import { validateIdentityPassthrough } from "../core/identity/validate-identity-passthrough.js";
|
|
28
31
|
import { validateAttrSchema } from "../attr-schema-validate.js";
|
|
29
32
|
import type { MetaDataFormat, MetaDataSource } from "./meta-data-source.js";
|
|
30
33
|
import { InMemoryStringSource } from "./meta-data-source.js";
|
|
@@ -35,9 +38,18 @@ import type { ParseOptions, ParseResult } from "../parser-core.js";
|
|
|
35
38
|
// browser-safety crawler — which walks every `import|export from` it sees,
|
|
36
39
|
// type-only or not — never follows a path into a node:fs-using file.
|
|
37
40
|
// Keep field-for-field in sync with `DirectoryOptions` in `./sources/directory-source.ts`.
|
|
38
|
-
type DirectoryFactoryOptions = {
|
|
41
|
+
export type DirectoryFactoryOptions = {
|
|
39
42
|
exclude?: string[];
|
|
40
43
|
recurse?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Opt-in library packages to prepend before the directory's own sources.
|
|
46
|
+
* Library sources are prepended so `extends` references to library-shipped
|
|
47
|
+
* abstract bases are resolvable from app metadata files.
|
|
48
|
+
*
|
|
49
|
+
* Example: `{ libraries: ["ai"] }` prepends the `metaobjects::ai` library
|
|
50
|
+
* (LlmCallBase etc.) so app entities may use `extends: "metaobjects::ai::LlmCallBase"`.
|
|
51
|
+
*/
|
|
52
|
+
libraries?: string[];
|
|
41
53
|
};
|
|
42
54
|
|
|
43
55
|
// YAML parser and node:fs-backed Source impls are loaded lazily (dynamic
|
|
@@ -101,7 +113,9 @@ export class MetaDataLoader {
|
|
|
101
113
|
}
|
|
102
114
|
|
|
103
115
|
private static _defaultRegistry(): TypeRegistry {
|
|
104
|
-
|
|
116
|
+
// FR-033 — validate the library's own metamodel at bootstrap: a contradictory
|
|
117
|
+
// core provider set fails fast here (the real metamodel must be contradiction-free).
|
|
118
|
+
return composeRegistry(coreProviders, { validate: true });
|
|
105
119
|
}
|
|
106
120
|
|
|
107
121
|
// ---------------------------------------------------------------------------
|
|
@@ -124,7 +138,7 @@ export class MetaDataLoader {
|
|
|
124
138
|
dir: string,
|
|
125
139
|
opts?: DirectoryFactoryOptions & LoadOptions,
|
|
126
140
|
): Promise<LoadResult> {
|
|
127
|
-
const { exclude, recurse, ...loaderOpts } = opts ?? {};
|
|
141
|
+
const { exclude, recurse, libraries, ...loaderOpts } = opts ?? {};
|
|
128
142
|
// Conditional spreads honor exactOptionalPropertyTypes — only forward keys
|
|
129
143
|
// when the caller supplied a value, so DirectorySource's own defaults apply.
|
|
130
144
|
const dirOpts: DirectoryFactoryOptions = {
|
|
@@ -134,8 +148,19 @@ export class MetaDataLoader {
|
|
|
134
148
|
const { DirectorySource } = await import("./sources/directory-source.js");
|
|
135
149
|
const loader = new MetaDataLoader(loaderOpts);
|
|
136
150
|
try {
|
|
137
|
-
const
|
|
138
|
-
|
|
151
|
+
const dirSources = await new DirectorySource(dir, dirOpts).expand();
|
|
152
|
+
// Library sources are loaded lazily and conditionally to keep the import
|
|
153
|
+
// path away from the browser-safe entry (library-sources.ts uses node:fs)
|
|
154
|
+
// and to avoid the import cost when no libraries are requested.
|
|
155
|
+
let libSources: MetaDataSource[] = [];
|
|
156
|
+
if (libraries?.length) {
|
|
157
|
+
const { librarySources } = await import("../library/library-sources.js");
|
|
158
|
+
libSources = librarySources(libraries);
|
|
159
|
+
}
|
|
160
|
+
// Prepend library sources so `extends` refs to library-shipped abstract
|
|
161
|
+
// bases are resolvable when the merged root is built. Super resolution is
|
|
162
|
+
// deferred (order-independent), but prepending is the deterministic choice.
|
|
163
|
+
return loader.load([...libSources, ...dirSources]);
|
|
139
164
|
} catch (err) {
|
|
140
165
|
// Match the pre-unification contract: a missing/unreadable directory is
|
|
141
166
|
// surfaced as a collected error on the LoadResult, not a throw. The
|
|
@@ -396,6 +421,22 @@ export class MetaDataLoader {
|
|
|
396
421
|
// parse-time source supplies files + jsonPath (the location of the
|
|
397
422
|
// broken `extends:` on disk); referrer = the declaring node's FQN;
|
|
398
423
|
// target = the unresolved supertype ref.
|
|
424
|
+
if (failure.kind === "target-mismatch") {
|
|
425
|
+
// FR-024 — a dotted child-targeting ref resolved, but the target's
|
|
426
|
+
// type/subtype differs from the extending node's. Dotted-only check.
|
|
427
|
+
const r = failure.referrer;
|
|
428
|
+
const t = failure.target;
|
|
429
|
+
errors.push(
|
|
430
|
+
new ParseError(
|
|
431
|
+
`the extends target '${failure.ref}' is ${t?.type}.${t?.subType} but the extending node '${failure.nodeFqn}' is ${r?.type}.${r?.subType} — a dotted extends must target a node of the same type and subtype`,
|
|
432
|
+
{
|
|
433
|
+
code: "ERR_EXTENDS_TARGET_MISMATCH",
|
|
434
|
+
source: resolvedSource(failure.source, failure.nodeFqn, failure.ref),
|
|
435
|
+
},
|
|
436
|
+
),
|
|
437
|
+
);
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
399
440
|
errors.push(
|
|
400
441
|
new ParseError(
|
|
401
442
|
`the SuperClass '${failure.ref}' does not exist (referenced by ${failure.nodeFqn})`,
|
|
@@ -413,19 +454,49 @@ export class MetaDataLoader {
|
|
|
413
454
|
errors.push(...ruleResult.errors);
|
|
414
455
|
warnings.push(...ruleResult.warnings);
|
|
415
456
|
|
|
457
|
+
// maxOccurs enforcement (config-driven singleton constraint, e.g. one
|
|
458
|
+
// identity.primary per entity) — the safety complement to defaultName.
|
|
459
|
+
errors.push(...validateMaxOccurs(root, this._registry));
|
|
460
|
+
|
|
461
|
+
// FR-024 B3 — projection identity pass-through + key correspondence
|
|
462
|
+
// (ERR_PROJECTION_IDENTITY_NOT_EXTENDED / ERR_IDENTITY_KEY_MISMATCH).
|
|
463
|
+
errors.push(...validateIdentityPassthrough(root));
|
|
464
|
+
|
|
416
465
|
// Fourth pass: data-grid @defaultSortField cross-reference validation.
|
|
417
466
|
errors.push(...validateDataGridSortFields(root));
|
|
418
467
|
|
|
419
468
|
// Fifth pass: @filterable without index drift warning.
|
|
420
469
|
warnings.push(...validateFilterableHasIndex(root));
|
|
421
470
|
|
|
471
|
+
// SP-H Unit9 — @filterable on a subtype with no operator band → error
|
|
472
|
+
// (would silently generate a filter that rejects every request).
|
|
473
|
+
errors.push(...validateFilterableHasSupportedOps(root));
|
|
474
|
+
|
|
422
475
|
// Sixth pass: origin path validation — validates passthrough.@from,
|
|
423
476
|
// aggregate.@of, and .@via relationship chains.
|
|
424
477
|
errors.push(...validateOriginPaths(root));
|
|
425
478
|
|
|
479
|
+
// FR-024 B6 — derived-field providability: an entity field carrying an
|
|
480
|
+
// origin.* is derived (read-only) and must be providable by at least one
|
|
481
|
+
// read-only-kind source on the entity (spec §7 multi-source pattern);
|
|
482
|
+
// projections and object.value hosts are exempt.
|
|
483
|
+
errors.push(...validateDerivedFieldProvidability(root));
|
|
484
|
+
|
|
426
485
|
// Seventh pass: @filter value validation — fields filterable + ops allowed per subtype.
|
|
427
486
|
errors.push(...validateDataGridFilterValues(root));
|
|
428
487
|
|
|
488
|
+
// FR-017 — M:N relationship validation (deferred-resolution): @through names a
|
|
489
|
+
// junction declaring two identity.reference children; @sourceRefField matches one;
|
|
490
|
+
// @symmetric is self-join-only + mutually exclusive with @sourceRefField; M:N attrs
|
|
491
|
+
// are invalid on a 1:N relationship.
|
|
492
|
+
errors.push(...validateRelationships(root));
|
|
493
|
+
|
|
494
|
+
// Phase 2 — validation DERIVED FROM THE TYPE REGISTRY: each node's TypeDefinition
|
|
495
|
+
// carries its reference descriptors + imperative validator, run as one recursive walk
|
|
496
|
+
// over a built-once symbol table. A downstream provider's custom type validates itself
|
|
497
|
+
// simply by being in this registry — no separate wiring.
|
|
498
|
+
errors.push(...runRegisteredValidation(root, this._registry));
|
|
499
|
+
|
|
429
500
|
// template.* validation — @payloadRef resolves to a known object;
|
|
430
501
|
// @requiredSlots are real fields on it (FR-004 Plan #3, T2).
|
|
431
502
|
errors.push(...validateTemplatePayloadRefs(root));
|
|
@@ -433,7 +504,7 @@ export class MetaDataLoader {
|
|
|
433
504
|
// Eighth pass: attribute-schema validation (Phase A3) — checks each
|
|
434
505
|
// node's @-attributes against its (type, subType) AttrSchema: required
|
|
435
506
|
// attrs present, declared attrs well-typed, allowedValues honored.
|
|
436
|
-
const attrSchemaResult = validateAttrSchema(root, this._registry);
|
|
507
|
+
const attrSchemaResult = validateAttrSchema(root, this._registry, this._strict);
|
|
437
508
|
errors.push(...attrSchemaResult.errors);
|
|
438
509
|
warnings.push(...attrSchemaResult.warnings);
|
|
439
510
|
|
package/src/loader/shortcuts.ts
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
// preserving the package root's browser-safety contract.
|
|
9
9
|
|
|
10
10
|
import { MetaDataLoader } from "./meta-data-loader.js";
|
|
11
|
-
import type { LoadOptions, LoadResult } from "./meta-data-loader.js";
|
|
11
|
+
import type { LoadOptions, LoadResult, DirectoryFactoryOptions } from "./meta-data-loader.js";
|
|
12
12
|
import type { MetaDataFormat } from "./meta-data-source.js";
|
|
13
13
|
|
|
14
14
|
export function loadDirectory(
|
|
15
15
|
dir: string,
|
|
16
|
-
opts?:
|
|
16
|
+
opts?: DirectoryFactoryOptions & LoadOptions,
|
|
17
17
|
): Promise<LoadResult> {
|
|
18
18
|
return MetaDataLoader.fromDirectory(dir, opts);
|
|
19
19
|
}
|