@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
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// FR-032 (ADR-0032) — canonical reference expansion.
|
|
2
|
+
//
|
|
3
|
+
// `expandRef(raw, packageContext)` is the SINGLE ref-expansion primitive. It
|
|
4
|
+
// lowers an authored metadata reference to its fully-qualified canonical form
|
|
5
|
+
// per ADR-0032 §2.1 — deterministically, with NO root fallback:
|
|
6
|
+
//
|
|
7
|
+
// bare `Name` (no `::`, no leading `.`) → `<P>::Name` (current package only;
|
|
8
|
+
// stays bare when P is empty/root).
|
|
9
|
+
// qualified `pkg::Name` (contains `::`, → unchanged (absolute from root).
|
|
10
|
+
// NOT leading `::`)
|
|
11
|
+
// `::Rest` (leading `::`) → strip the leading `::`; the
|
|
12
|
+
// remainder is absolute from root
|
|
13
|
+
// (so `::a::b::C` ≡ `a::b::C`,
|
|
14
|
+
// `::Apple` = root-level Apple).
|
|
15
|
+
// `..::Rest` (one or more leading `..::`) → drop one package segment from P
|
|
16
|
+
// per `..::`, then resolve Rest
|
|
17
|
+
// (itself bare/qualified) against the
|
|
18
|
+
// reduced package. Over-drop (more
|
|
19
|
+
// `..::` than P has segments) throws.
|
|
20
|
+
//
|
|
21
|
+
// The trailing FR-024 DOTTED CHILD suffix (`.child` / `.child.grandchild`) is
|
|
22
|
+
// PRESERVED verbatim: only the OWNER part (everything before the first `.` in
|
|
23
|
+
// the final `::`-segment) is expanded; the `.child...` tail is reattached.
|
|
24
|
+
//
|
|
25
|
+
// The desugar runs this on every ref-bearing attr so canonical JSON is FQN-only
|
|
26
|
+
// (ADR-0032 §2.2/§2.3); the resolution layer then does pure FQN matching. The
|
|
27
|
+
// `package` attribute is NEVER expanded — it is the node's identity.
|
|
28
|
+
|
|
29
|
+
import type { MetaData } from "./shared/meta-data.js";
|
|
30
|
+
import { PACKAGE_SEPARATOR, PACKAGE_PARENT, CHILD_REF_SEPARATOR } from "./shared/structural.js";
|
|
31
|
+
import { RELATIONSHIP_ATTR_OBJECT_REF } from "./core/relationship/relationship-constants.js";
|
|
32
|
+
import { FIELD_ATTR_OBJECT_REF } from "./core/field/field-constants.js";
|
|
33
|
+
import { IDENTITY_REFERENCE_ATTR_REFERENCES } from "./core/identity/identity-constants.js";
|
|
34
|
+
import {
|
|
35
|
+
ORIGIN_PASSTHROUGH_ATTR_FROM,
|
|
36
|
+
ORIGIN_PASSTHROUGH_ATTR_VIA,
|
|
37
|
+
ORIGIN_AGGREGATE_ATTR_OF,
|
|
38
|
+
ORIGIN_AGGREGATE_ATTR_VIA,
|
|
39
|
+
ORIGIN_COLLECTION_ATTR_VIA,
|
|
40
|
+
} from "./persistence/origin/origin-constants.js";
|
|
41
|
+
import { SOURCE_ATTR_PARAMETER_REF } from "./persistence/source/source-constants.js";
|
|
42
|
+
import { TEMPLATE_ATTR_PAYLOAD_REF, TEMPLATE_ATTR_RESPONSE_REF } from "./template/template-constants.js";
|
|
43
|
+
|
|
44
|
+
const PARENT_PREFIX = PACKAGE_PARENT + PACKAGE_SEPARATOR; // "..::"
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The inline (`@`-prefixed) attribute names whose VALUE is a metadata reference
|
|
48
|
+
* subject to FR-032 expansion/guarding (ADR-0032 §3). The structural `extends`
|
|
49
|
+
* key is handled separately (it is not `@`-prefixed). `@objectRef`/`@references`
|
|
50
|
+
* are pure object refs; `@from`/`@of`/`@via` carry an entity HEAD (possibly with
|
|
51
|
+
* a dotted relationship/field tail — expandRef preserves the tail);
|
|
52
|
+
* `@parameterRef`/`@payloadRef`/`@responseRef` reference value-objects. These are
|
|
53
|
+
* expanded by the YAML desugar and rejected (when still relative) by the
|
|
54
|
+
* canonical-JSON guard. `@sourceRefField` (a FK FIELD name, not an object ref)
|
|
55
|
+
* and `@through` are intentionally NOT in this set (out of scope for FR-032 T-slice).
|
|
56
|
+
*/
|
|
57
|
+
export const REF_BEARING_ATTR_NAMES: ReadonlySet<string> = new Set<string>([
|
|
58
|
+
RELATIONSHIP_ATTR_OBJECT_REF, // = FIELD_ATTR_OBJECT_REF (same spelling "objectRef")
|
|
59
|
+
FIELD_ATTR_OBJECT_REF,
|
|
60
|
+
IDENTITY_REFERENCE_ATTR_REFERENCES,
|
|
61
|
+
ORIGIN_PASSTHROUGH_ATTR_FROM,
|
|
62
|
+
ORIGIN_PASSTHROUGH_ATTR_VIA, // = ORIGIN_AGGREGATE_ATTR_VIA = ORIGIN_COLLECTION_ATTR_VIA ("via")
|
|
63
|
+
ORIGIN_AGGREGATE_ATTR_OF,
|
|
64
|
+
ORIGIN_AGGREGATE_ATTR_VIA,
|
|
65
|
+
ORIGIN_COLLECTION_ATTR_VIA,
|
|
66
|
+
SOURCE_ATTR_PARAMETER_REF,
|
|
67
|
+
TEMPLATE_ATTR_PAYLOAD_REF,
|
|
68
|
+
TEMPLATE_ATTR_RESPONSE_REF,
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* True when `raw` is a relative reference form (`::Rest` or `..::Rest`) that the
|
|
73
|
+
* YAML desugar must expand before canonical JSON. Canonical JSON must be FQN; a
|
|
74
|
+
* relative ref surviving into it is `ERR_RELATIVE_REF_IN_CANONICAL`.
|
|
75
|
+
*/
|
|
76
|
+
export function isRelativeRef(raw: string): boolean {
|
|
77
|
+
return raw.startsWith(PACKAGE_SEPARATOR) || raw.startsWith(PARENT_PREFIX);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Split a ref into its owner part (the object reference) and any FR-024 dotted
|
|
82
|
+
* child tail. The `.` that marks a child can only appear in the FINAL
|
|
83
|
+
* `::`-segment (package separators never follow a child dot), so the owner ends
|
|
84
|
+
* at the first `.` AFTER the last `::`. Returns `{ owner, tail }` where `tail`
|
|
85
|
+
* includes the leading `.` (or is "" when there is no child suffix).
|
|
86
|
+
*/
|
|
87
|
+
function splitChildTail(raw: string): { owner: string; tail: string } {
|
|
88
|
+
const lastSep = raw.lastIndexOf(PACKAGE_SEPARATOR);
|
|
89
|
+
const segStart = lastSep === -1 ? 0 : lastSep + PACKAGE_SEPARATOR.length;
|
|
90
|
+
const dotInSeg = raw.indexOf(CHILD_REF_SEPARATOR, segStart);
|
|
91
|
+
if (dotInSeg === -1) return { owner: raw, tail: "" };
|
|
92
|
+
return { owner: raw.slice(0, dotInSeg), tail: raw.slice(dotInSeg) };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Expand an authored reference's OWNER part (no child tail) to its FQN per
|
|
97
|
+
* ADR-0032 §2.1. Throws on parent-relative over-drop.
|
|
98
|
+
*/
|
|
99
|
+
function expandOwner(owner: string, packageContext: string): string {
|
|
100
|
+
// root-absolute: leading "::" → strip; the remainder is absolute from root.
|
|
101
|
+
if (owner.startsWith(PACKAGE_SEPARATOR)) {
|
|
102
|
+
return owner.slice(PACKAGE_SEPARATOR.length);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// parent-relative: one or more leading "..::".
|
|
106
|
+
if (owner.startsWith(PARENT_PREFIX)) {
|
|
107
|
+
let rest = owner;
|
|
108
|
+
let levels = 0;
|
|
109
|
+
while (rest.startsWith(PARENT_PREFIX)) {
|
|
110
|
+
levels++;
|
|
111
|
+
rest = rest.slice(PARENT_PREFIX.length);
|
|
112
|
+
}
|
|
113
|
+
const pkgParts = packageContext !== "" ? packageContext.split(PACKAGE_SEPARATOR) : [];
|
|
114
|
+
if (levels > pkgParts.length) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`Relative reference '${owner}' over-drops: ${levels} parent level(s) ` +
|
|
117
|
+
`but the package context '${packageContext}' has only ${pkgParts.length} segment(s)`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
const reducedPkg = pkgParts.slice(0, pkgParts.length - levels).join(PACKAGE_SEPARATOR);
|
|
121
|
+
// `rest` is itself bare/qualified — resolve it against the reduced package.
|
|
122
|
+
// (A qualified remainder still resolves bare-in-the-reduced-package per the
|
|
123
|
+
// §2.1 example `..::veg::Carrot` → `acme::veg::Carrot`.)
|
|
124
|
+
return reducedPkg !== "" ? `${reducedPkg}${PACKAGE_SEPARATOR}${rest}` : rest;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// qualified: contains "::" (not leading) → absolute, unchanged.
|
|
128
|
+
if (owner.includes(PACKAGE_SEPARATOR)) {
|
|
129
|
+
return owner;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// bare name → current package (only). Stays bare when context is empty/root.
|
|
133
|
+
return packageContext !== "" ? `${packageContext}${PACKAGE_SEPARATOR}${owner}` : owner;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Expand an authored reference to its fully-qualified canonical form per
|
|
138
|
+
* ADR-0032 §2.1, preserving any FR-024 dotted child suffix. The package context
|
|
139
|
+
* `P` is the declaring node's effective package (its own `package` or the
|
|
140
|
+
* file-default). Throws on parent-relative over-drop — the caller emits an error.
|
|
141
|
+
*/
|
|
142
|
+
export function expandRef(raw: string, packageContext: string): string {
|
|
143
|
+
const { owner, tail } = splitChildTail(raw);
|
|
144
|
+
return expandOwner(owner, packageContext) + tail;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* FR-032 — does a root-level object `node` satisfy an (already-expanded)
|
|
149
|
+
* object reference `ref`? After the YAML desugar + corpus sweep every ref is
|
|
150
|
+
* fully qualified, so resolution is a pure FQN match. Objects keep a BARE
|
|
151
|
+
* `fqn()` per the FR5d cross-port contract, so the canonical FQN accessor is
|
|
152
|
+
* `resolutionKey()` (`<package | fileDefaultPackage>::<name>`) — this mirrors
|
|
153
|
+
* `super-resolve`'s `findInTree`. The bare `name`/`fqn()` arms cover legacy
|
|
154
|
+
* same-tree refs and root-level (empty-package) objects.
|
|
155
|
+
*
|
|
156
|
+
* This is the single matcher the non-super resolvers (origin `@from`/`@of`/
|
|
157
|
+
* `@via` heads, template `@payloadRef`/`@responseRef`, source `@parameterRef`)
|
|
158
|
+
* share, so FQN matching behaves identically everywhere a ref resolves.
|
|
159
|
+
*/
|
|
160
|
+
export function refMatchesObject(node: MetaData, ref: string): boolean {
|
|
161
|
+
return node.resolutionKey() === ref || node.fqn() === ref || node.name === ref;
|
|
162
|
+
}
|
package/src/naming.ts
CHANGED
|
@@ -65,7 +65,13 @@ export function resolveTableName(entity: MetaData): string {
|
|
|
65
65
|
// so this helper now just delegates. Writability (table vs view/storedProc/
|
|
66
66
|
// tableFunction) only affects write-routing — for SELECT-side name resolution,
|
|
67
67
|
// a read-only primary source is the right answer.
|
|
68
|
-
|
|
68
|
+
//
|
|
69
|
+
// Effective children (own + inherited via the super chain) so a TPH SUBTYPE
|
|
70
|
+
// — which declares no source of its own and inherits the discriminator base's
|
|
71
|
+
// single table (FR-017) — resolves to that base table rather than the
|
|
72
|
+
// entity-name fallback. For an entity declaring its own source, own shadows
|
|
73
|
+
// inherited, so the result is unchanged.
|
|
74
|
+
const source = entity.children().find(
|
|
69
75
|
(c): c is MetaSource => c instanceof MetaSource && c.role === SOURCE_ROLE_PRIMARY,
|
|
70
76
|
);
|
|
71
77
|
if (source !== undefined) return source.physicalName;
|
|
@@ -111,7 +117,9 @@ export function buildNameMap(
|
|
|
111
117
|
): EntityNameMap {
|
|
112
118
|
const jsToDb = new Map<string, string>();
|
|
113
119
|
const dbToJs = new Map<string, string>();
|
|
114
|
-
|
|
120
|
+
// Effective children so a TPH subtype's name map covers inherited base
|
|
121
|
+
// fields + its own (FR-017); own shadows inherited on a name conflict.
|
|
122
|
+
for (const child of entity.children()) {
|
|
115
123
|
if (child.type !== TYPE_FIELD) continue;
|
|
116
124
|
const dbCol = resolveColumnName(child, strategy);
|
|
117
125
|
jsToDb.set(child.name, dbCol);
|
package/src/parser-core.ts
CHANGED
|
@@ -31,7 +31,7 @@ import { canonicalSerialize, inferAttrSubType } from "./serializer-json.js";
|
|
|
31
31
|
import { ParseError, type ErrorCode } from "./errors.js";
|
|
32
32
|
import { resolvedSource, type ErrorSource, type LoaderWarning, type Contributor } from "./source.js";
|
|
33
33
|
import { semanticDiff } from "./semantic-diff.js";
|
|
34
|
-
import { resolveSuperRef } from "./super-resolve.js";
|
|
34
|
+
import { resolveSuperRef, isChildTargetingRef } from "./super-resolve.js";
|
|
35
35
|
import { JsonPathBuilder } from "./json-path.js";
|
|
36
36
|
import { getYamlPosition, type YamlPosition } from "./core/yaml-positions.js";
|
|
37
37
|
import {
|
|
@@ -56,8 +56,10 @@ import {
|
|
|
56
56
|
TYPE_SUBTYPE_SEPARATOR,
|
|
57
57
|
PACKAGE_SEPARATOR,
|
|
58
58
|
} from "./shared/structural.js";
|
|
59
|
-
import { ATTR_SUBTYPE_PROPERTIES } from "./core/attr/attr-constants.js";
|
|
59
|
+
import { ATTR_SUBTYPE_PROPERTIES, ATTR_SUBTYPE_STRINGARRAY } from "./core/attr/attr-constants.js";
|
|
60
|
+
import { attrClassFor } from "./attr-class-map.js";
|
|
60
61
|
import type { AttrValue } from "./shared/meta-data.js";
|
|
62
|
+
import { isRelativeRef, REF_BEARING_ATTR_NAMES } from "./naming-refs.js";
|
|
61
63
|
|
|
62
64
|
// ---------------------------------------------------------------------------
|
|
63
65
|
// Public API
|
|
@@ -158,6 +160,44 @@ function reportProblem(
|
|
|
158
160
|
warnings.push(msg);
|
|
159
161
|
}
|
|
160
162
|
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// FR-032 (ADR-0032) — canonical-JSON ref guard.
|
|
165
|
+
//
|
|
166
|
+
// Canonical JSON is the self-contained interchange form: every ref-bearing attr
|
|
167
|
+
// MUST be fully-qualified. A relative authoring form (leading `::` or `..::`)
|
|
168
|
+
// surviving into canonical JSON is `ERR_RELATIVE_REF_IN_CANONICAL`. The guard
|
|
169
|
+
// fires ONLY for JSON-format input — YAML-format input has already been
|
|
170
|
+
// desugar-expanded via expandRef (so any `::`/`..::` there is correct authoring
|
|
171
|
+
// that was lowered to FQN before buildTree sees it). Like ERR_RESERVED_ATTR,
|
|
172
|
+
// this is a hard error routed through the loader's error sink even in lax mode.
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
function guardRelativeRefInCanonical(
|
|
176
|
+
refLabel: string,
|
|
177
|
+
rawValue: unknown,
|
|
178
|
+
strict: boolean,
|
|
179
|
+
warnings: string[],
|
|
180
|
+
path: string,
|
|
181
|
+
): void {
|
|
182
|
+
if (_currentFormat !== "json") return;
|
|
183
|
+
if (typeof rawValue !== "string") return;
|
|
184
|
+
if (!isRelativeRef(rawValue)) return;
|
|
185
|
+
const msg =
|
|
186
|
+
`Relative reference '${rawValue}' on ${refLabel} at ${path} is not allowed in ` +
|
|
187
|
+
`canonical JSON — canonical JSON must be fully-qualified. Relative forms ` +
|
|
188
|
+
`(leading '::' or '..::') are YAML-authoring sugar that the desugar expands.`;
|
|
189
|
+
if (strict) {
|
|
190
|
+
throw new ParseError(msg, { code: "ERR_RELATIVE_REF_IN_CANONICAL", source: errSource() });
|
|
191
|
+
}
|
|
192
|
+
if (_currentErrors !== undefined) {
|
|
193
|
+
_currentErrors.push(
|
|
194
|
+
new ParseError(msg, { code: "ERR_RELATIVE_REF_IN_CANONICAL", source: errSource() }),
|
|
195
|
+
);
|
|
196
|
+
} else {
|
|
197
|
+
warnings.push(msg);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
161
201
|
// ---------------------------------------------------------------------------
|
|
162
202
|
// Internal helper — split a fused wrapper key into (type, subType).
|
|
163
203
|
//
|
|
@@ -479,10 +519,19 @@ function parseNodeFresh(
|
|
|
479
519
|
|
|
480
520
|
// --- Determine name ---
|
|
481
521
|
const rawName = nodeData[RESERVED_KEY_NAME];
|
|
482
|
-
|
|
522
|
+
let name = typeof rawName === "string" ? rawName : "";
|
|
483
523
|
|
|
484
524
|
// --- Create the model ---
|
|
485
525
|
const def = registry.find(type, subType)!;
|
|
526
|
+
// Config-driven default name for a SINGLETON child type: when the node is
|
|
527
|
+
// declared with no name and its type definition is `maxOccurs: 1` with a
|
|
528
|
+
// `defaultName`, assign it (e.g. identity.primary → "primary"). Safe by
|
|
529
|
+
// construction — maxOccurs===1 guarantees no sibling can collide — and keeps
|
|
530
|
+
// the one-and-only node addressable. Multi-cardinality types carry no
|
|
531
|
+
// defaultName, so they still require an explicit name (FR-024).
|
|
532
|
+
if (name === "" && def.maxOccurs === 1 && def.defaultName !== undefined) {
|
|
533
|
+
name = def.defaultName;
|
|
534
|
+
}
|
|
486
535
|
const model = def.factory(def.typeId, name);
|
|
487
536
|
// FR5a — stamp the source provenance envelope using the parser's current
|
|
488
537
|
// JSONPath stack + source id. setSource happens BEFORE freeze (the parser
|
|
@@ -530,8 +579,25 @@ function parseNodeFresh(
|
|
|
530
579
|
// (Skipped when deferSuperResolution is true — the loader resolves after
|
|
531
580
|
// all input files have been parsed, so cross-file super refs work.)
|
|
532
581
|
if (model.superRef !== undefined && accumRoot !== undefined && !_deferSuperResolution) {
|
|
533
|
-
|
|
582
|
+
// FR-024: thread the referrer's type so dotted `Entity.child` refs resolve
|
|
583
|
+
// type-scoped — kept consistent with the deferred path (super-resolve.ts).
|
|
584
|
+
const superModel = resolveSuperRef(model.superRef, effectivePkg, accumRoot, { type: model.type });
|
|
534
585
|
if (superModel !== undefined) {
|
|
586
|
+
// FR-024 — a dotted child-targeting ref must resolve to a node of the
|
|
587
|
+
// SAME type and subtype as the extending node. Dotted-only check; the
|
|
588
|
+
// shipped top-level extends behavior is unchanged.
|
|
589
|
+
if (
|
|
590
|
+
isChildTargetingRef(model.superRef) &&
|
|
591
|
+
(superModel.type !== model.type || superModel.subType !== model.subType)
|
|
592
|
+
) {
|
|
593
|
+
throw new ParseError(
|
|
594
|
+
`the extends target '${model.superRef}' is ${superModel.type}.${superModel.subType} but the extending node '${model.fqn()}' is ${model.type}.${model.subType} — a dotted extends must target a node of the same type and subtype`,
|
|
595
|
+
{
|
|
596
|
+
code: "ERR_EXTENDS_TARGET_MISMATCH",
|
|
597
|
+
source: resolvedSource(errSource(), model.fqn(), model.superRef),
|
|
598
|
+
},
|
|
599
|
+
);
|
|
600
|
+
}
|
|
535
601
|
model.setSuperResolved(superModel);
|
|
536
602
|
} else {
|
|
537
603
|
// FR5d — emit format=resolved with referrer + target. referrer is the
|
|
@@ -887,6 +953,9 @@ function applyReservedKeys(
|
|
|
887
953
|
if (typeof rawExtends !== "string") {
|
|
888
954
|
reportProblem(`"${RESERVED_KEY_EXTENDS}" must be a string at ${path}`, strict, warnings, "ERR_UNRESOLVED_SUPER");
|
|
889
955
|
} else {
|
|
956
|
+
// FR-032: canonical JSON `extends` must be FQN; reject a surviving
|
|
957
|
+
// relative form (no-op for YAML-format input, which was desugar-expanded).
|
|
958
|
+
guardRelativeRefInCanonical(`"${RESERVED_KEY_EXTENDS}"`, rawExtends, strict, warnings, path);
|
|
890
959
|
model.setSuper(rawExtends);
|
|
891
960
|
}
|
|
892
961
|
}
|
|
@@ -974,6 +1043,13 @@ function applyInlineAttrsAndUnknownKeys(
|
|
|
974
1043
|
|
|
975
1044
|
const rawVal = nodeData[key];
|
|
976
1045
|
|
|
1046
|
+
// FR-032: a ref-bearing inline attr (@objectRef/@references/@from/@of/@via/
|
|
1047
|
+
// @parameterRef/@payloadRef/@responseRef) in canonical JSON must be FQN —
|
|
1048
|
+
// reject a surviving relative form. No-op for YAML-format input.
|
|
1049
|
+
if (REF_BEARING_ATTR_NAMES.has(attrName)) {
|
|
1050
|
+
guardRelativeRefInCanonical(`${ATTR_PREFIX}${attrName}`, rawVal, strict, warnings, path);
|
|
1051
|
+
}
|
|
1052
|
+
|
|
977
1053
|
try {
|
|
978
1054
|
const attr = materializeAttr(model, attrName, rawVal, registry);
|
|
979
1055
|
model.setMetaAttr(attr);
|
|
@@ -1004,16 +1080,27 @@ function materializeAttr(
|
|
|
1004
1080
|
const perTypeSpec = registry.attrsOf(owner.type, owner.subType).find((s) => s.name === attrName);
|
|
1005
1081
|
const attrSpec = perTypeSpec ?? registry.getCommonAttrs().find((s) => s.name === attrName);
|
|
1006
1082
|
let subType: string;
|
|
1007
|
-
if (attrSpec !== undefined && attrSpec.
|
|
1083
|
+
if (attrSpec !== undefined && attrSpec.isArray === true) {
|
|
1084
|
+
// An array-flagged attr (`string` + `isArray`): array-ness is the orthogonal
|
|
1085
|
+
// axis the `stringarray` subtype was retired in favor of. Coerce through the
|
|
1086
|
+
// array string-attr class (bare-string → one-element array) keyed off the
|
|
1087
|
+
// retired-as-a-subtype-but-kept-as-a-coercion `stringarray` class-map entry.
|
|
1088
|
+
subType = ATTR_SUBTYPE_STRINGARRAY;
|
|
1089
|
+
} else if (attrSpec !== undefined && attrSpec.valueType !== undefined) {
|
|
1008
1090
|
subType = attrSpec.valueType;
|
|
1009
1091
|
} else {
|
|
1010
1092
|
// Undeclared or declared-but-untyped (@default): preserve the author's shape.
|
|
1011
1093
|
subType = inferUndeclaredAttrSubType(rawVal);
|
|
1012
1094
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1095
|
+
// The array-coercion class is no longer a registered (attr, subType); resolve
|
|
1096
|
+
// it through the dependency-free attr-class-map (which still carries it).
|
|
1097
|
+
const def = subType === ATTR_SUBTYPE_STRINGARRAY ? undefined : registry.find(TYPE_ATTR, subType);
|
|
1098
|
+
const Ctor = subType === ATTR_SUBTYPE_STRINGARRAY ? attrClassFor(subType) : undefined;
|
|
1099
|
+
const node = (Ctor !== undefined
|
|
1100
|
+
? new Ctor(new TypeId(TYPE_ATTR, subType), attrName)
|
|
1101
|
+
: def !== undefined
|
|
1102
|
+
? def.factory(def.typeId, attrName)
|
|
1103
|
+
: new MetaAttr(new TypeId(TYPE_ATTR, subType), attrName)) as MetaAttr;
|
|
1017
1104
|
const coerced = node.coerce(rawVal);
|
|
1018
1105
|
const desugared = node.desugar(coerced);
|
|
1019
1106
|
node.setAttr(RESERVED_KEY_VALUE, desugared);
|
|
@@ -10,6 +10,22 @@ export const FIELD_ATTR_COLUMN = "column";
|
|
|
10
10
|
/** When true, suppress the @filterable-without-index Loader warning (Project D drift check). */
|
|
11
11
|
export const FIELD_ATTR_DB_INDEXED = "db.indexed";
|
|
12
12
|
|
|
13
|
+
// --- Physical RDB index/constraint attrs the db provider adds to identity.* ---
|
|
14
|
+
// These EXTEND core identity subtypes (via registry.extend) rather than living on
|
|
15
|
+
// core, because they are pure physical-storage concerns (index ordering, partial-
|
|
16
|
+
// index predicate, FK constraint naming) with no logical-model meaning.
|
|
17
|
+
|
|
18
|
+
/** identity.secondary: per-field index-key sort direction array ('asc' | 'desc'), positional to @fields. Drives DESC-ordered index keys. */
|
|
19
|
+
export const IDENTITY_ATTR_ORDERS = "orders";
|
|
20
|
+
/** identity.secondary: a partial-index predicate (raw SQL). When set, the index covers only matching rows. */
|
|
21
|
+
export const IDENTITY_ATTR_WHERE = "where";
|
|
22
|
+
/** identity.secondary: a raw key EXPRESSION for a functional/expression index (e.g. "lower(email)"); used instead of @fields. */
|
|
23
|
+
export const IDENTITY_ATTR_EXPR = "expr";
|
|
24
|
+
/** identity.secondary: index access method (e.g. "gin", "gist"); default "btree", which is not rendered. */
|
|
25
|
+
export const IDENTITY_ATTR_USING = "using";
|
|
26
|
+
/** identity.reference: physical FK constraint-name override. Absent → the auto-derived `<table>_<firstFkColumn>_fk`. */
|
|
27
|
+
export const IDENTITY_ATTR_CONSTRAINT_NAME = "constraintName";
|
|
28
|
+
|
|
13
29
|
/**
|
|
14
30
|
* R6 Plan 2b: `@dbColumnType` — physical DB column-type override on a field.
|
|
15
31
|
* Selects the DB column type WITHOUT changing the logical field type or its
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate-embedded-metamodel.ts — DO NOT EDIT.
|
|
2
|
+
// Canonical source: repo-root spec/metamodel/db.json
|
|
3
|
+
// Regenerate: bun run scripts/generate-embedded-metamodel.ts
|
|
4
|
+
//
|
|
5
|
+
// Embeds the canonical FR-033 ProviderDefinition so the provider can register
|
|
6
|
+
// itself wherever the on-disk spec/ tree is unavailable (bundled builds).
|
|
7
|
+
import type { ProviderDefinition } from "../../provider-data.js";
|
|
8
|
+
|
|
9
|
+
export const DB_DEFINITION: ProviderDefinition = {
|
|
10
|
+
"provider": "metaobjects-db",
|
|
11
|
+
"extends": [
|
|
12
|
+
{
|
|
13
|
+
"type": "field",
|
|
14
|
+
"subType": "*",
|
|
15
|
+
"children": [
|
|
16
|
+
{
|
|
17
|
+
"type": "attr",
|
|
18
|
+
"subType": "string",
|
|
19
|
+
"name": "column",
|
|
20
|
+
"min": 0,
|
|
21
|
+
"max": 1,
|
|
22
|
+
"description": "Physical column name for this field on an rdb source. Defaults to the field name via columnNamingStrategy."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "attr",
|
|
26
|
+
"subType": "boolean",
|
|
27
|
+
"name": "db.indexed",
|
|
28
|
+
"min": 0,
|
|
29
|
+
"max": 1,
|
|
30
|
+
"description": "When true, suppress the @filterable-without-index Loader warning (the field is indexed by other means)."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "attr",
|
|
34
|
+
"subType": "string",
|
|
35
|
+
"name": "dbColumnType",
|
|
36
|
+
"min": 0,
|
|
37
|
+
"max": 1,
|
|
38
|
+
"description": "Physical DB column-type override (ADR-0013 escape hatch). Legal values are uuid | jsonb | timestamp_with_tz, each legal only on a specific logical field subtype (uuid/jsonb on field.string, timestamp_with_tz on field.timestamp). The logical field type and its native binding are unchanged."
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "field",
|
|
44
|
+
"subType": "object",
|
|
45
|
+
"children": [
|
|
46
|
+
{
|
|
47
|
+
"type": "attr",
|
|
48
|
+
"subType": "string",
|
|
49
|
+
"name": "storage",
|
|
50
|
+
"min": 0,
|
|
51
|
+
"max": 1,
|
|
52
|
+
"allowedValues": [
|
|
53
|
+
"flattened",
|
|
54
|
+
"jsonb",
|
|
55
|
+
"subdocument"
|
|
56
|
+
],
|
|
57
|
+
"description": "Storage strategy for an object-typed field (set with @objectRef). \"flattened\" expands the nested value into prefixed columns on the parent table. \"jsonb\" stores the structured value in a single jsonb column (supports isArray=true for arrays of values). \"subdocument\" is a hint for document-store codegen targets and emits no Postgres column."
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"type": "field",
|
|
63
|
+
"subType": [
|
|
64
|
+
"date",
|
|
65
|
+
"time",
|
|
66
|
+
"timestamp"
|
|
67
|
+
],
|
|
68
|
+
"children": [
|
|
69
|
+
{
|
|
70
|
+
"type": "attr",
|
|
71
|
+
"subType": "string",
|
|
72
|
+
"name": "autoSet",
|
|
73
|
+
"min": 0,
|
|
74
|
+
"max": 1,
|
|
75
|
+
"allowedValues": [
|
|
76
|
+
"onCreate",
|
|
77
|
+
"onUpdate"
|
|
78
|
+
],
|
|
79
|
+
"description": "Auto-set semantics for timestamp-like fields: 'onCreate' stamps on insert, 'onUpdate' stamps on every write."
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"type": "source",
|
|
85
|
+
"subType": "rdb",
|
|
86
|
+
"children": [
|
|
87
|
+
{
|
|
88
|
+
"type": "attr",
|
|
89
|
+
"subType": "string",
|
|
90
|
+
"name": "table",
|
|
91
|
+
"min": 0,
|
|
92
|
+
"max": 1,
|
|
93
|
+
"description": "Physical SQL table name for source.rdb @kind: \"table\" (default). FR-016: Defaults from the source's bare structural `name` via the project's columnNamingStrategy when omitted, then from the owning entity's name. Pre-1.0 legacy spelling for view/materializedView/storedProc/tableFunction kinds during the transition; canonical-serializer rewrites to the kind-matching alias."
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"type": "attr",
|
|
97
|
+
"subType": "string",
|
|
98
|
+
"name": "view",
|
|
99
|
+
"min": 0,
|
|
100
|
+
"max": 1,
|
|
101
|
+
"description": "Physical SQL view name for source.rdb @kind: \"view\". Same internal slot as @table."
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "attr",
|
|
105
|
+
"subType": "string",
|
|
106
|
+
"name": "materializedView",
|
|
107
|
+
"min": 0,
|
|
108
|
+
"max": 1,
|
|
109
|
+
"description": "Physical SQL materialized-view name for source.rdb @kind: \"materializedView\". Same internal slot as @table."
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"type": "attr",
|
|
113
|
+
"subType": "string",
|
|
114
|
+
"name": "proc",
|
|
115
|
+
"min": 0,
|
|
116
|
+
"max": 1,
|
|
117
|
+
"description": "Physical SQL stored-procedure name for source.rdb @kind: \"storedProc\". Same internal slot as @table."
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"type": "attr",
|
|
121
|
+
"subType": "string",
|
|
122
|
+
"name": "function",
|
|
123
|
+
"min": 0,
|
|
124
|
+
"max": 1,
|
|
125
|
+
"description": "Physical SQL table-function name for source.rdb @kind: \"tableFunction\". Same internal slot as @table."
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"type": "attr",
|
|
129
|
+
"subType": "string",
|
|
130
|
+
"name": "kind",
|
|
131
|
+
"min": 0,
|
|
132
|
+
"max": 1,
|
|
133
|
+
"allowedValues": [
|
|
134
|
+
"table",
|
|
135
|
+
"view",
|
|
136
|
+
"materializedView",
|
|
137
|
+
"storedProc",
|
|
138
|
+
"tableFunction"
|
|
139
|
+
],
|
|
140
|
+
"description": "The kind of database object this source represents: table (default, writable), view, materializedView, storedProc, or tableFunction. Non-table kinds are read-only."
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"type": "attr",
|
|
144
|
+
"subType": "string",
|
|
145
|
+
"name": "role",
|
|
146
|
+
"min": 0,
|
|
147
|
+
"max": 1,
|
|
148
|
+
"allowedValues": [
|
|
149
|
+
"primary",
|
|
150
|
+
"replica",
|
|
151
|
+
"index",
|
|
152
|
+
"cache",
|
|
153
|
+
"publish",
|
|
154
|
+
"mirror"
|
|
155
|
+
],
|
|
156
|
+
"description": "Role this source plays when an object has multiple sources: primary (default, system of record), replica, index, cache, publish, or mirror."
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"type": "attr",
|
|
160
|
+
"subType": "string",
|
|
161
|
+
"name": "schema",
|
|
162
|
+
"min": 0,
|
|
163
|
+
"max": 1,
|
|
164
|
+
"description": "Optional database schema name (e.g. 'catalog', 'public'). Postgres defaults to 'public'; SQLite rejects any non-default value."
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"type": "attr",
|
|
168
|
+
"subType": "string",
|
|
169
|
+
"name": "parameterRef",
|
|
170
|
+
"min": 0,
|
|
171
|
+
"max": 1,
|
|
172
|
+
"description": "FR-015: name or FQN of an object.value describing the input shape of this source's callable interface. Permitted on @kind: \"storedProc\" / \"tableFunction\"; rejected on non-callable kinds (table / view / materializedView). Field children of the referenced object.value become the call-site parameter list in declaration order. Symmetric with template.@payloadRef in FR-004 — the typed-input pattern reuses object.value rather than minting a new parameter.* node type."
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"type": "identity",
|
|
178
|
+
"subType": "secondary",
|
|
179
|
+
"children": [
|
|
180
|
+
{
|
|
181
|
+
"type": "attr",
|
|
182
|
+
"subType": "string",
|
|
183
|
+
"name": "orders",
|
|
184
|
+
"isArray": true,
|
|
185
|
+
"min": 0,
|
|
186
|
+
"max": 1,
|
|
187
|
+
"allowedValues": [
|
|
188
|
+
"asc",
|
|
189
|
+
"desc"
|
|
190
|
+
],
|
|
191
|
+
"description": "Physical index-key sort direction, positional to @fields ('asc' | 'desc'). Omit for all-ascending (the default); a shorter array leaves trailing keys ascending. Drives DESC-ordered index keys (e.g. a recency index on a timestamp). RDB-physical — contributed by the db provider, not core identity."
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"type": "attr",
|
|
195
|
+
"subType": "string",
|
|
196
|
+
"name": "where",
|
|
197
|
+
"min": 0,
|
|
198
|
+
"max": 1,
|
|
199
|
+
"description": "Partial-index predicate (raw SQL, e.g. \"delivered_at IS NULL\"). When set, the index covers only rows matching the predicate — smaller and cheaper for queries that always filter on it. Absent = a full index over every row. RDB-physical — contributed by the db provider."
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"type": "attr",
|
|
203
|
+
"subType": "string",
|
|
204
|
+
"name": "expr",
|
|
205
|
+
"min": 0,
|
|
206
|
+
"max": 1,
|
|
207
|
+
"description": "Raw key EXPRESSION for a functional/expression index (e.g. \"lower(email)\"). Used INSTEAD of @fields — the index key is the expression rather than plain columns. RDB-physical — contributed by the db provider."
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"type": "attr",
|
|
211
|
+
"subType": "string",
|
|
212
|
+
"name": "using",
|
|
213
|
+
"min": 0,
|
|
214
|
+
"max": 1,
|
|
215
|
+
"description": "Index access method (e.g. \"gin\", \"gist\", \"hash\"); default \"btree\" (not rendered). Pair with @expr for e.g. a GIN index over an array/jsonb expression. RDB-physical — contributed by the db provider."
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"type": "identity",
|
|
221
|
+
"subType": "reference",
|
|
222
|
+
"children": [
|
|
223
|
+
{
|
|
224
|
+
"type": "attr",
|
|
225
|
+
"subType": "string",
|
|
226
|
+
"name": "constraintName",
|
|
227
|
+
"min": 0,
|
|
228
|
+
"max": 1,
|
|
229
|
+
"description": "Physical foreign-key constraint name override. Absent → the backend's auto-derived default (e.g. `<table>_<firstFkColumn>_fk`). Lets a model adopt an existing database whose FK constraints follow a different naming convention without a destructive rename. RDB-physical — contributed by the db provider."
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
};
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
// dbProvider — the DB-domain MetaDataTypeProvider. Registers the DB-domain
|
|
2
|
-
// attributes (@column / @db.indexed
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// attributes (@column / @db.indexed / @dbColumnType + @storage on field.object,
|
|
3
|
+
// @autoSet on temporal fields; @table/@kind/@role/@schema/... on source.rdb) by
|
|
4
|
+
// EXTENDING the core-registered types. Mirrors Java's CoreDBMetaDataProvider
|
|
5
|
+
// (com.metaobjects.database).
|
|
6
|
+
//
|
|
7
|
+
// FR-033 S1.5-A: the attrs + their descriptions are now DATA — read from
|
|
8
|
+
// spec/metamodel/db.json (embedded as DB_DEFINITION) via the unified
|
|
9
|
+
// applyProviderDefinition apply path's `extends` handling. The provider declares
|
|
10
|
+
// no new types, so the factory map is empty.
|
|
5
11
|
|
|
6
12
|
import type { MetaDataTypeProvider } from "../../provider.js";
|
|
7
13
|
import type { TypeRegistry } from "../../registry.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { SOURCE_SUBTYPE_RDB } from "../source/source-constants.js";
|
|
11
|
-
import { columnSchema, dbIndexedSchema, dbColumnTypeSchema } from "./db-schema.js";
|
|
12
|
-
import { sourceRdbAttrs } from "../source/source-schema.js";
|
|
14
|
+
import { applyProviderDefinition } from "../../provider-data.js";
|
|
15
|
+
import { DB_DEFINITION } from "./db-definition.embedded.js";
|
|
13
16
|
|
|
14
17
|
export const dbProvider: MetaDataTypeProvider = {
|
|
15
18
|
id: "metaobjects-db",
|
|
16
19
|
dependencies: ["metaobjects-core-types"],
|
|
17
20
|
description:
|
|
18
|
-
"DB-domain attributes — @column / @db.indexed / @dbColumnType on fields, @table/@kind/@role/@schema on source.rdb.",
|
|
21
|
+
"DB-domain attributes — @column / @db.indexed / @dbColumnType on every field, @storage on field.object, @autoSet on temporal fields, @table/@kind/@role/@schema on source.rdb.",
|
|
19
22
|
registerTypes(registry: TypeRegistry): void {
|
|
20
|
-
|
|
21
|
-
registry.extend(TYPE_FIELD, subType, {
|
|
22
|
-
attributes: [columnSchema, dbIndexedSchema, dbColumnTypeSchema],
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
// source.rdb — @table/@kind/@role/@schema attrs.
|
|
26
|
-
registry.extend(TYPE_SOURCE, SOURCE_SUBTYPE_RDB, {
|
|
27
|
-
attributes: [...sourceRdbAttrs],
|
|
28
|
-
});
|
|
23
|
+
applyProviderDefinition(registry, DB_DEFINITION, {});
|
|
29
24
|
},
|
|
30
25
|
};
|