@party-stack/ontology 0.19.0 → 0.20.0
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/lib/OntologyPullConfig.d.ts +15 -13
- package/lib/OntologyPullConfig.d.ts.map +1 -1
- package/lib/OntologyPullConfig.js +0 -1
- package/lib/cli/format.d.ts +4 -0
- package/lib/cli/format.d.ts.map +1 -0
- package/lib/cli/format.js +19 -0
- package/lib/cli/format.js.map +1 -0
- package/lib/cli/generate.d.ts +6 -5
- package/lib/cli/generate.d.ts.map +1 -1
- package/lib/cli/generate.js +86 -110
- package/lib/cli/generate.js.map +1 -1
- package/lib/cli/index.d.ts +1 -3
- package/lib/cli/index.js +42 -59
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/pull.d.ts +3 -1
- package/lib/cli/pull.d.ts.map +1 -1
- package/lib/cli/pull.js +42 -60
- package/lib/cli/pull.js.map +1 -1
- package/lib/examples/blog.d.ts +347 -345
- package/lib/examples/blog.d.ts.map +1 -1
- package/lib/examples/blog.js +350 -337
- package/lib/examples/blog.js.map +1 -1
- package/lib/examples/blog.live-queries.d.ts +8 -3
- package/lib/examples/blog.live-queries.d.ts.map +1 -1
- package/lib/examples/blog.live-queries.js +28 -44
- package/lib/examples/blog.live-queries.js.map +1 -1
- package/lib/examples/generated/constants.d.ts +1 -2
- package/lib/examples/generated/constants.js +0 -2
- package/lib/examples/generated/live.d.ts +5 -3
- package/lib/examples/generated/live.d.ts.map +1 -1
- package/lib/examples/generated/live.js +12 -8
- package/lib/examples/generated/live.js.map +1 -1
- package/lib/examples/generated/types.d.ts +52 -50
- package/lib/examples/generated/types.d.ts.map +1 -1
- package/lib/examples/generated/types.js +0 -2
- package/lib/generate/builders.d.ts +8 -5
- package/lib/generate/builders.d.ts.map +1 -1
- package/lib/generate/builders.js +53 -55
- package/lib/generate/builders.js.map +1 -1
- package/lib/generate/constants.d.ts +3 -1
- package/lib/generate/constants.d.ts.map +1 -1
- package/lib/generate/constants.js +23 -26
- package/lib/generate/constants.js.map +1 -1
- package/lib/generate/index.d.ts +6 -6
- package/lib/generate/index.js +6 -6
- package/lib/generate/live.d.ts +8 -6
- package/lib/generate/live.d.ts.map +1 -1
- package/lib/generate/live.js +43 -42
- package/lib/generate/live.js.map +1 -1
- package/lib/generate/ontology.d.ts +4 -2
- package/lib/generate/ontology.d.ts.map +1 -1
- package/lib/generate/ontology.js +453 -354
- package/lib/generate/ontology.js.map +1 -1
- package/lib/generate/types.d.ts +7 -5
- package/lib/generate/types.d.ts.map +1 -1
- package/lib/generate/types.js +190 -262
- package/lib/generate/types.js.map +1 -1
- package/lib/generate/utils/buildJsDocs.d.ts +7 -4
- package/lib/generate/utils/buildJsDocs.d.ts.map +1 -1
- package/lib/generate/utils/buildJsDocs.js +14 -10
- package/lib/generate/utils/buildJsDocs.js.map +1 -1
- package/lib/index.d.ts +30 -13
- package/lib/index.js +18 -10
- package/lib/infer.d.ts +129 -151
- package/lib/infer.d.ts.map +1 -1
- package/lib/infer.js +10 -6
- package/lib/infer.js.map +1 -1
- package/lib/installation/createMetaOntologyConfiguration.d.ts +6 -3
- package/lib/installation/createMetaOntologyConfiguration.d.ts.map +1 -1
- package/lib/installation/createMetaOntologyConfiguration.js +13 -11
- package/lib/installation/createMetaOntologyConfiguration.js.map +1 -1
- package/lib/installation/createOntologyBackendInstallation.d.ts +3 -1
- package/lib/installation/createOntologyBackendInstallation.d.ts.map +1 -1
- package/lib/installation/createOntologyBackendInstallation.js +205 -268
- package/lib/installation/createOntologyBackendInstallation.js.map +1 -1
- package/lib/installation/index.d.ts +4 -4
- package/lib/installation/index.js +3 -3
- package/lib/installation/types.d.ts +83 -80
- package/lib/installation/types.d.ts.map +1 -1
- package/lib/installation/types.js +0 -1
- package/lib/ir/generated/builders.d.ts +294 -382
- package/lib/ir/generated/builders.d.ts.map +1 -1
- package/lib/ir/generated/builders.js +180 -119
- package/lib/ir/generated/builders.js.map +1 -1
- package/lib/ir/generated/constants.d.ts +137 -135
- package/lib/ir/generated/constants.d.ts.map +1 -1
- package/lib/ir/generated/constants.js +162 -129
- package/lib/ir/generated/constants.js.map +1 -1
- package/lib/ir/generated/types.d.ts +236 -234
- package/lib/ir/generated/types.d.ts.map +1 -1
- package/lib/ir/generated/types.js +0 -2
- package/lib/ir/index.d.ts +4 -4
- package/lib/ir/index.js +3 -4
- package/lib/ir/schema.d.ts +2174 -2172
- package/lib/ir/schema.d.ts.map +1 -1
- package/lib/ir/schema.js +1184 -1343
- package/lib/ir/schema.js.map +1 -1
- package/lib/ir/validate.d.ts +5 -3
- package/lib/ir/validate.d.ts.map +1 -1
- package/lib/ir/validate.js +589 -707
- package/lib/ir/validate.js.map +1 -1
- package/lib/json/index.d.ts +10 -8
- package/lib/json/index.d.ts.map +1 -1
- package/lib/json/index.js +101 -135
- package/lib/json/index.js.map +1 -1
- package/lib/lenses.d.ts +7 -4
- package/lib/lenses.d.ts.map +1 -1
- package/lib/lenses.js +96 -132
- package/lib/lenses.js.map +1 -1
- package/lib/live/LiveOntology.d.ts +55 -60
- package/lib/live/LiveOntology.d.ts.map +1 -1
- package/lib/live/LiveOntology.js +98 -124
- package/lib/live/LiveOntology.js.map +1 -1
- package/lib/live/OntologyBackendAdapter.d.ts +84 -77
- package/lib/live/OntologyBackendAdapter.d.ts.map +1 -1
- package/lib/live/OntologyBackendAdapter.js +0 -1
- package/lib/live/actions/createLiveOntologyAction.d.ts +27 -24
- package/lib/live/actions/createLiveOntologyAction.d.ts.map +1 -1
- package/lib/live/actions/createLiveOntologyAction.js +24 -21
- package/lib/live/actions/createLiveOntologyAction.js.map +1 -1
- package/lib/live/actions/createLiveOntologyActions.d.ts +23 -20
- package/lib/live/actions/createLiveOntologyActions.d.ts.map +1 -1
- package/lib/live/actions/createLiveOntologyActions.js +131 -161
- package/lib/live/actions/createLiveOntologyActions.js.map +1 -1
- package/lib/live/actions/prepareActionParameters.d.ts +14 -11
- package/lib/live/actions/prepareActionParameters.d.ts.map +1 -1
- package/lib/live/actions/prepareActionParameters.js +190 -228
- package/lib/live/actions/prepareActionParameters.js.map +1 -1
- package/lib/live/attachments/attachmentSources.d.ts +7 -4
- package/lib/live/attachments/attachmentSources.d.ts.map +1 -1
- package/lib/live/attachments/attachmentSources.js +55 -71
- package/lib/live/attachments/attachmentSources.js.map +1 -1
- package/lib/live/attachments/createLiveOntologyAttachments.d.ts +47 -44
- package/lib/live/attachments/createLiveOntologyAttachments.d.ts.map +1 -1
- package/lib/live/attachments/createLiveOntologyAttachments.js +65 -83
- package/lib/live/attachments/createLiveOntologyAttachments.js.map +1 -1
- package/lib/live/attachments/types.d.ts +10 -8
- package/lib/live/attachments/types.d.ts.map +1 -1
- package/lib/live/attachments/types.js +0 -1
- package/lib/live/attachments/unsupportedOntologyAttachmentsAdapter.d.ts +3 -1
- package/lib/live/attachments/unsupportedOntologyAttachmentsAdapter.d.ts.map +1 -1
- package/lib/live/attachments/unsupportedOntologyAttachmentsAdapter.js +5 -3
- package/lib/live/attachments/unsupportedOntologyAttachmentsAdapter.js.map +1 -1
- package/lib/live/expression.d.ts +16 -13
- package/lib/live/expression.d.ts.map +1 -1
- package/lib/live/expression.js +142 -223
- package/lib/live/expression.js.map +1 -1
- package/lib/live/index.d.ts +12 -9
- package/lib/live/index.js +6 -8
- package/lib/live/mutators/OntologyEdits.d.ts +12 -9
- package/lib/live/mutators/OntologyEdits.d.ts.map +1 -1
- package/lib/live/mutators/OntologyEdits.js +57 -74
- package/lib/live/mutators/OntologyEdits.js.map +1 -1
- package/lib/live/mutators/createMutatorTx.d.ts +7 -5
- package/lib/live/mutators/createMutatorTx.d.ts.map +1 -1
- package/lib/live/mutators/createMutatorTx.js +53 -69
- package/lib/live/mutators/createMutatorTx.js.map +1 -1
- package/lib/live/mutators/runOptimisticAction.d.ts +16 -13
- package/lib/live/mutators/runOptimisticAction.d.ts.map +1 -1
- package/lib/live/mutators/runOptimisticAction.js +26 -26
- package/lib/live/mutators/runOptimisticAction.js.map +1 -1
- package/lib/live/mutators/types.d.ts +18 -16
- package/lib/live/mutators/types.d.ts.map +1 -1
- package/lib/live/mutators/types.js +0 -1
- package/lib/live/objects/OntologyObject.d.ts +2 -0
- package/lib/live/objects/OntologyObject.d.ts.map +1 -1
- package/lib/live/objects/OntologyObject.js +0 -1
- package/lib/live/objects/createLiveOntologyObjectCollection.d.ts +14 -11
- package/lib/live/objects/createLiveOntologyObjectCollection.d.ts.map +1 -1
- package/lib/live/objects/createLiveOntologyObjectCollection.js +62 -49
- package/lib/live/objects/createLiveOntologyObjectCollection.js.map +1 -1
- package/lib/live/objects/ontologyObjectCollectionId.d.ts +2 -0
- package/lib/live/objects/ontologyObjectCollectionId.d.ts.map +1 -1
- package/lib/live/objects/ontologyObjectCollectionId.js +6 -2
- package/lib/live/objects/ontologyObjectCollectionId.js.map +1 -1
- package/lib/live/outbox/createOntologyOutbox.d.ts +16 -14
- package/lib/live/outbox/createOntologyOutbox.d.ts.map +1 -1
- package/lib/live/outbox/createOntologyOutbox.js +275 -326
- package/lib/live/outbox/createOntologyOutbox.js.map +1 -1
- package/lib/live/outbox/leaderExecutor.d.ts +15 -13
- package/lib/live/outbox/leaderExecutor.d.ts.map +1 -1
- package/lib/live/outbox/leaderExecutor.js +114 -153
- package/lib/live/outbox/leaderExecutor.js.map +1 -1
- package/lib/live/outbox/outboxService.d.ts +4 -2
- package/lib/live/outbox/outboxService.d.ts.map +1 -1
- package/lib/live/outbox/outboxService.js +66 -71
- package/lib/live/outbox/outboxService.js.map +1 -1
- package/lib/live/outbox/projectionManager.d.ts +26 -24
- package/lib/live/outbox/projectionManager.d.ts.map +1 -1
- package/lib/live/outbox/projectionManager.js +121 -147
- package/lib/live/outbox/projectionManager.js.map +1 -1
- package/lib/live/outbox/repository.d.ts +27 -25
- package/lib/live/outbox/repository.d.ts.map +1 -1
- package/lib/live/outbox/repository.js +192 -241
- package/lib/live/outbox/repository.js.map +1 -1
- package/lib/live/outbox/service.d.ts +52 -50
- package/lib/live/outbox/service.d.ts.map +1 -1
- package/lib/live/outbox/service.js +5 -1
- package/lib/live/outbox/service.js.map +1 -1
- package/lib/live/outbox/types.d.ts +35 -33
- package/lib/live/outbox/types.d.ts.map +1 -1
- package/lib/live/outbox/types.js +10 -6
- package/lib/live/outbox/types.js.map +1 -1
- package/lib/live/waitForCollectionReady.d.ts +3 -1
- package/lib/live/waitForCollectionReady.d.ts.map +1 -1
- package/lib/live/waitForCollectionReady.js +44 -65
- package/lib/live/waitForCollectionReady.js.map +1 -1
- package/lib/meta/createLocalMetaOntologyBackendAdapter.d.ts +5 -2
- package/lib/meta/createLocalMetaOntologyBackendAdapter.d.ts.map +1 -1
- package/lib/meta/createLocalMetaOntologyBackendAdapter.js +37 -39
- package/lib/meta/createLocalMetaOntologyBackendAdapter.js.map +1 -1
- package/lib/meta/generated/constants.d.ts +137 -135
- package/lib/meta/generated/constants.d.ts.map +1 -1
- package/lib/meta/generated/constants.js +162 -129
- package/lib/meta/generated/constants.js.map +1 -1
- package/lib/meta/generated/live.d.ts +5 -2
- package/lib/meta/generated/live.d.ts.map +1 -1
- package/lib/meta/generated/live.js +12 -8
- package/lib/meta/generated/live.js.map +1 -1
- package/lib/meta/generated/types.d.ts +233 -231
- package/lib/meta/generated/types.d.ts.map +1 -1
- package/lib/meta/generated/types.js +0 -2
- package/lib/meta/ontology.d.ts +23 -21
- package/lib/meta/ontology.d.ts.map +1 -1
- package/lib/meta/ontology.js +100 -104
- package/lib/meta/ontology.js.map +1 -1
- package/lib/meta/pull.d.ts +8 -6
- package/lib/meta/pull.d.ts.map +1 -1
- package/lib/meta/pull.js +39 -52
- package/lib/meta/pull.js.map +1 -1
- package/lib/utils/index.d.ts +8 -8
- package/lib/utils/index.js +5 -6
- package/lib/utils/links.d.ts +34 -31
- package/lib/utils/links.d.ts.map +1 -1
- package/lib/utils/links.js +10 -17
- package/lib/utils/links.js.map +1 -1
- package/lib/utils/paths.d.ts +2 -0
- package/lib/utils/paths.d.ts.map +1 -1
- package/lib/utils/paths.js +32 -44
- package/lib/utils/paths.js.map +1 -1
- package/lib/utils/provide.d.ts +2 -0
- package/lib/utils/provide.d.ts.map +1 -1
- package/lib/utils/provide.js +7 -9
- package/lib/utils/provide.js.map +1 -1
- package/lib/utils/targets.d.ts +20 -18
- package/lib/utils/targets.d.ts.map +1 -1
- package/lib/utils/targets.js +0 -1
- package/lib/utils/typeNames.d.ts +10 -8
- package/lib/utils/typeNames.d.ts.map +1 -1
- package/lib/utils/typeNames.js +0 -1
- package/lib/utils/types.d.ts +6 -4
- package/lib/utils/types.d.ts.map +1 -1
- package/lib/utils/types.js +38 -38
- package/lib/utils/types.js.map +1 -1
- package/lib/utils/uncertain.d.ts +5 -3
- package/lib/utils/uncertain.d.ts.map +1 -1
- package/lib/utils/uncertain.js +11 -9
- package/lib/utils/uncertain.js.map +1 -1
- package/lib/utils/validation.d.ts +4 -2
- package/lib/utils/validation.d.ts.map +1 -1
- package/lib/utils/validation.js +0 -1
- package/lib/utils/values.d.ts +18 -18
- package/lib/utils/values.d.ts.map +1 -1
- package/lib/utils/values.js +0 -1
- package/package.json +22 -26
- package/lib/OntologyPullConfig.js.map +0 -1
- package/lib/cli/index.d.ts.map +0 -1
- package/lib/cli/index.test.d.ts +0 -2
- package/lib/cli/index.test.d.ts.map +0 -1
- package/lib/cli/index.test.js +0 -34
- package/lib/cli/index.test.js.map +0 -1
- package/lib/cli/pull.test.d.ts +0 -2
- package/lib/cli/pull.test.d.ts.map +0 -1
- package/lib/cli/pull.test.js +0 -125
- package/lib/cli/pull.test.js.map +0 -1
- package/lib/examples/generated/constants.d.ts.map +0 -1
- package/lib/examples/generated/constants.js.map +0 -1
- package/lib/examples/generated/types.js.map +0 -1
- package/lib/generate/builders.test.d.ts +0 -2
- package/lib/generate/builders.test.d.ts.map +0 -1
- package/lib/generate/builders.test.js +0 -49
- package/lib/generate/builders.test.js.map +0 -1
- package/lib/generate/index.d.ts.map +0 -1
- package/lib/generate/index.js.map +0 -1
- package/lib/generate/live.test.d.ts +0 -2
- package/lib/generate/live.test.d.ts.map +0 -1
- package/lib/generate/live.test.js +0 -22
- package/lib/generate/live.test.js.map +0 -1
- package/lib/generate/ontology.test.d.ts +0 -2
- package/lib/generate/ontology.test.d.ts.map +0 -1
- package/lib/generate/ontology.test.js +0 -157
- package/lib/generate/ontology.test.js.map +0 -1
- package/lib/generate/types.test.d.ts +0 -2
- package/lib/generate/types.test.d.ts.map +0 -1
- package/lib/generate/types.test.js +0 -304
- package/lib/generate/types.test.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/infer.test.d.ts +0 -2
- package/lib/infer.test.d.ts.map +0 -1
- package/lib/infer.test.js +0 -125
- package/lib/infer.test.js.map +0 -1
- package/lib/installation/createMetaOntologyConfiguration.test.d.ts +0 -2
- package/lib/installation/createMetaOntologyConfiguration.test.d.ts.map +0 -1
- package/lib/installation/createMetaOntologyConfiguration.test.js +0 -20
- package/lib/installation/createMetaOntologyConfiguration.test.js.map +0 -1
- package/lib/installation/createOntologyBackendInstallation.test.d.ts +0 -2
- package/lib/installation/createOntologyBackendInstallation.test.d.ts.map +0 -1
- package/lib/installation/createOntologyBackendInstallation.test.js +0 -320
- package/lib/installation/createOntologyBackendInstallation.test.js.map +0 -1
- package/lib/installation/index.d.ts.map +0 -1
- package/lib/installation/index.js.map +0 -1
- package/lib/installation/types.js.map +0 -1
- package/lib/ir/generated/types.js.map +0 -1
- package/lib/ir/index.d.ts.map +0 -1
- package/lib/ir/index.js.map +0 -1
- package/lib/ir/validate.test.d.ts +0 -2
- package/lib/ir/validate.test.d.ts.map +0 -1
- package/lib/ir/validate.test.js +0 -1061
- package/lib/ir/validate.test.js.map +0 -1
- package/lib/json/index.test.d.ts +0 -2
- package/lib/json/index.test.d.ts.map +0 -1
- package/lib/json/index.test.js +0 -142
- package/lib/json/index.test.js.map +0 -1
- package/lib/lenses.test.d.ts +0 -2
- package/lib/lenses.test.d.ts.map +0 -1
- package/lib/lenses.test.js +0 -80
- package/lib/lenses.test.js.map +0 -1
- package/lib/live/LiveOntology.test.d.ts +0 -2
- package/lib/live/LiveOntology.test.d.ts.map +0 -1
- package/lib/live/LiveOntology.test.js +0 -507
- package/lib/live/LiveOntology.test.js.map +0 -1
- package/lib/live/OntologyBackendAdapter.js.map +0 -1
- package/lib/live/actions/createLiveOntologyAction.test.d.ts +0 -2
- package/lib/live/actions/createLiveOntologyAction.test.d.ts.map +0 -1
- package/lib/live/actions/createLiveOntologyAction.test.js +0 -232
- package/lib/live/actions/createLiveOntologyAction.test.js.map +0 -1
- package/lib/live/actions/prepareActionParameters.test.d.ts +0 -2
- package/lib/live/actions/prepareActionParameters.test.d.ts.map +0 -1
- package/lib/live/actions/prepareActionParameters.test.js +0 -165
- package/lib/live/actions/prepareActionParameters.test.js.map +0 -1
- package/lib/live/attachments/attachmentMetadata.test.d.ts +0 -2
- package/lib/live/attachments/attachmentMetadata.test.d.ts.map +0 -1
- package/lib/live/attachments/attachmentMetadata.test.js +0 -73
- package/lib/live/attachments/attachmentMetadata.test.js.map +0 -1
- package/lib/live/attachments/createLiveOntologyAttachments.test.d.ts +0 -2
- package/lib/live/attachments/createLiveOntologyAttachments.test.d.ts.map +0 -1
- package/lib/live/attachments/createLiveOntologyAttachments.test.js +0 -363
- package/lib/live/attachments/createLiveOntologyAttachments.test.js.map +0 -1
- package/lib/live/attachments/types.js.map +0 -1
- package/lib/live/expression.test.d.ts +0 -2
- package/lib/live/expression.test.d.ts.map +0 -1
- package/lib/live/expression.test.js +0 -311
- package/lib/live/expression.test.js.map +0 -1
- package/lib/live/index.d.ts.map +0 -1
- package/lib/live/index.js.map +0 -1
- package/lib/live/mutators/OntologyEdits.test.d.ts +0 -2
- package/lib/live/mutators/OntologyEdits.test.d.ts.map +0 -1
- package/lib/live/mutators/OntologyEdits.test.js +0 -85
- package/lib/live/mutators/OntologyEdits.test.js.map +0 -1
- package/lib/live/mutators/createMutatorTx.test.d.ts +0 -2
- package/lib/live/mutators/createMutatorTx.test.d.ts.map +0 -1
- package/lib/live/mutators/createMutatorTx.test.js +0 -180
- package/lib/live/mutators/createMutatorTx.test.js.map +0 -1
- package/lib/live/mutators/types.js.map +0 -1
- package/lib/live/objects/OntologyObject.js.map +0 -1
- package/lib/live/objects/createLiveOntologyObjectCollection.test.d.ts +0 -2
- package/lib/live/objects/createLiveOntologyObjectCollection.test.d.ts.map +0 -1
- package/lib/live/objects/createLiveOntologyObjectCollection.test.js +0 -310
- package/lib/live/objects/createLiveOntologyObjectCollection.test.js.map +0 -1
- package/lib/live/outbox/createOntologyOutbox.test.d.ts +0 -2
- package/lib/live/outbox/createOntologyOutbox.test.d.ts.map +0 -1
- package/lib/live/outbox/createOntologyOutbox.test.js +0 -1030
- package/lib/live/outbox/createOntologyOutbox.test.js.map +0 -1
- package/lib/meta/generated/types.js.map +0 -1
- package/lib/meta/ontology.test.d.ts +0 -2
- package/lib/meta/ontology.test.d.ts.map +0 -1
- package/lib/meta/ontology.test.js +0 -84
- package/lib/meta/ontology.test.js.map +0 -1
- package/lib/utils/index.d.ts.map +0 -1
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/links.test.d.ts +0 -2
- package/lib/utils/links.test.d.ts.map +0 -1
- package/lib/utils/links.test.js +0 -109
- package/lib/utils/links.test.js.map +0 -1
- package/lib/utils/paths.test.d.ts +0 -2
- package/lib/utils/paths.test.d.ts.map +0 -1
- package/lib/utils/paths.test.js +0 -33
- package/lib/utils/paths.test.js.map +0 -1
- package/lib/utils/targets.js.map +0 -1
- package/lib/utils/typeNames.js.map +0 -1
- package/lib/utils/types.test.d.ts +0 -2
- package/lib/utils/types.test.d.ts.map +0 -1
- package/lib/utils/types.test.js +0 -157
- package/lib/utils/types.test.js.map +0 -1
- package/lib/utils/uncertain.test.d.ts +0 -2
- package/lib/utils/uncertain.test.d.ts.map +0 -1
- package/lib/utils/uncertain.test.js +0 -14
- package/lib/utils/uncertain.test.js.map +0 -1
- package/lib/utils/validation.js.map +0 -1
- package/lib/utils/values.js.map +0 -1
package/lib/ir/validate.js
CHANGED
|
@@ -1,741 +1,623 @@
|
|
|
1
|
-
import { isLinkHopFromForeignKeySource, resolveLinkHop
|
|
1
|
+
import { isLinkHopFromForeignKeySource, resolveLinkHop } from "../utils/links.js";
|
|
2
2
|
import { unwrapType } from "../utils/types.js";
|
|
3
3
|
import { ImageMediaTypeOptions } from "./generated/constants.js";
|
|
4
|
-
|
|
4
|
+
//#region src/ir/validate.ts
|
|
5
5
|
function validateNonNegativeRange(range, path) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
message: "Range min must be less than or equal to max.",
|
|
21
|
-
path,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return errors;
|
|
6
|
+
if (!range) return [];
|
|
7
|
+
const errors = [];
|
|
8
|
+
for (const bound of ["min", "max"]) {
|
|
9
|
+
const value = range[bound];
|
|
10
|
+
if (value !== void 0 && (!Number.isFinite(value) || value < 0)) errors.push({
|
|
11
|
+
message: `Range ${bound} must be a finite, non-negative number.`,
|
|
12
|
+
path: [...path, bound]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (range.min !== void 0 && range.max !== void 0 && range.min > range.max) errors.push({
|
|
16
|
+
message: "Range min must be less than or equal to max.",
|
|
17
|
+
path
|
|
18
|
+
});
|
|
19
|
+
return errors;
|
|
25
20
|
}
|
|
26
21
|
function validateAttachmentConstraints(type) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
22
|
+
const constraint = type.value.constraint;
|
|
23
|
+
if (!constraint) return [];
|
|
24
|
+
const errors = validateNonNegativeRange(constraint.size, ["constraint", "size"]);
|
|
25
|
+
const content = constraint.content;
|
|
26
|
+
if (content?.kind !== "image") return errors;
|
|
27
|
+
for (const [index, mediaType] of (content.value.mediaTypes ?? []).entries()) if (!ImageMediaTypeOptions.some((option) => option.value === mediaType)) errors.push({
|
|
28
|
+
message: `Unsupported image media type: "${mediaType}".`,
|
|
29
|
+
path: [
|
|
30
|
+
"constraint",
|
|
31
|
+
"content",
|
|
32
|
+
"value",
|
|
33
|
+
"mediaTypes",
|
|
34
|
+
index
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
errors.push(...validateNonNegativeRange(content.value.dimensions?.width, [
|
|
38
|
+
"constraint",
|
|
39
|
+
"content",
|
|
40
|
+
"value",
|
|
41
|
+
"dimensions",
|
|
42
|
+
"width"
|
|
43
|
+
]), ...validateNonNegativeRange(content.value.dimensions?.height, [
|
|
44
|
+
"constraint",
|
|
45
|
+
"content",
|
|
46
|
+
"value",
|
|
47
|
+
"dimensions",
|
|
48
|
+
"height"
|
|
49
|
+
]));
|
|
50
|
+
return errors;
|
|
56
51
|
}
|
|
57
52
|
function validateTypeDef(type, path, valueTypeNames, objectTypeNames) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
case "struct":
|
|
100
|
-
return validateStructFields(type.value.fields, [...path, "fields"], valueTypeNames, objectTypeNames);
|
|
101
|
-
case "union":
|
|
102
|
-
return validateUnionVariants(type.value.variants, [...path, "variants"], valueTypeNames, objectTypeNames);
|
|
103
|
-
case "optional":
|
|
104
|
-
return validateTypeDef(type.value.type, [...path, "type"], valueTypeNames, objectTypeNames);
|
|
105
|
-
case "result":
|
|
106
|
-
return [
|
|
107
|
-
...validateTypeDef(type.value.okType, [...path, "okType"], valueTypeNames, objectTypeNames),
|
|
108
|
-
...validateTypeDef(type.value.errType, [...path, "errType"], valueTypeNames, objectTypeNames),
|
|
109
|
-
];
|
|
110
|
-
case "ref":
|
|
111
|
-
return valueTypeNames.has(type.value.name)
|
|
112
|
-
? []
|
|
113
|
-
: [
|
|
114
|
-
{
|
|
115
|
-
message: `Unknown value type reference: "${type.value.name}".`,
|
|
116
|
-
path: [...path, "name"],
|
|
117
|
-
},
|
|
118
|
-
];
|
|
119
|
-
}
|
|
53
|
+
switch (type.kind) {
|
|
54
|
+
case "string":
|
|
55
|
+
case "boolean":
|
|
56
|
+
case "integer":
|
|
57
|
+
case "float":
|
|
58
|
+
case "double":
|
|
59
|
+
case "date":
|
|
60
|
+
case "timestamp":
|
|
61
|
+
case "geopoint":
|
|
62
|
+
case "unknown": return [];
|
|
63
|
+
case "attachment": return validateAttachmentConstraints(type).map((error) => ({
|
|
64
|
+
...error,
|
|
65
|
+
path: [...path, ...error.path ?? []]
|
|
66
|
+
}));
|
|
67
|
+
case "objectReference": return objectTypeNames.has(type.value.objectType) ? [] : [{
|
|
68
|
+
message: `Unknown object type reference: "${type.value.objectType}".`,
|
|
69
|
+
path: [...path, "objectType"]
|
|
70
|
+
}];
|
|
71
|
+
case "list": return validateTypeDef(type.value.elementType, [...path, "elementType"], valueTypeNames, objectTypeNames);
|
|
72
|
+
case "map": {
|
|
73
|
+
const errors = [];
|
|
74
|
+
if (type.value.keyType.kind !== "string") errors.push({
|
|
75
|
+
message: "Map key types must be string.",
|
|
76
|
+
path: [...path, "keyType"]
|
|
77
|
+
});
|
|
78
|
+
return [
|
|
79
|
+
...errors,
|
|
80
|
+
...validateTypeDef(type.value.keyType, [...path, "keyType"], valueTypeNames, objectTypeNames),
|
|
81
|
+
...validateTypeDef(type.value.valueType, [...path, "valueType"], valueTypeNames, objectTypeNames)
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
case "struct": return validateStructFields(type.value.fields, [...path, "fields"], valueTypeNames, objectTypeNames);
|
|
85
|
+
case "union": return validateUnionVariants(type.value.variants, [...path, "variants"], valueTypeNames, objectTypeNames);
|
|
86
|
+
case "optional": return validateTypeDef(type.value.type, [...path, "type"], valueTypeNames, objectTypeNames);
|
|
87
|
+
case "result": return [...validateTypeDef(type.value.okType, [...path, "okType"], valueTypeNames, objectTypeNames), ...validateTypeDef(type.value.errType, [...path, "errType"], valueTypeNames, objectTypeNames)];
|
|
88
|
+
case "ref": return valueTypeNames.has(type.value.name) ? [] : [{
|
|
89
|
+
message: `Unknown value type reference: "${type.value.name}".`,
|
|
90
|
+
path: [...path, "name"]
|
|
91
|
+
}];
|
|
92
|
+
}
|
|
120
93
|
}
|
|
121
94
|
function validateStructFields(fields, path, valueTypeNames, objectTypeNames) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
95
|
+
const fieldNames = /* @__PURE__ */ new Set();
|
|
96
|
+
const errors = [];
|
|
97
|
+
for (let i = 0; i < fields.length; i++) {
|
|
98
|
+
const field = fields[i];
|
|
99
|
+
const fieldPath = [...path, i];
|
|
100
|
+
if (fieldNames.has(field.name)) errors.push({
|
|
101
|
+
message: `Duplicate field name: "${field.name}".`,
|
|
102
|
+
path: [...fieldPath, "name"]
|
|
103
|
+
});
|
|
104
|
+
fieldNames.add(field.name);
|
|
105
|
+
errors.push(...validateTypeDef(field.type, [...fieldPath, "type"], valueTypeNames, objectTypeNames));
|
|
106
|
+
}
|
|
107
|
+
return errors;
|
|
134
108
|
}
|
|
135
109
|
function validateUnionVariants(variants, path, valueTypeNames, objectTypeNames) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
return errors;
|
|
110
|
+
const seen = /* @__PURE__ */ new Set();
|
|
111
|
+
const errors = [];
|
|
112
|
+
for (let i = 0; i < variants.length; i++) {
|
|
113
|
+
const variant = variants[i];
|
|
114
|
+
const variantPath = [...path, i];
|
|
115
|
+
if (seen.has(variant.name)) errors.push({
|
|
116
|
+
message: `Duplicate variant name: "${variant.name}".`,
|
|
117
|
+
path: [...variantPath, "name"]
|
|
118
|
+
});
|
|
119
|
+
seen.add(variant.name);
|
|
120
|
+
errors.push(...validateTypeDef(variant.type, [...variantPath, "type"], valueTypeNames, objectTypeNames));
|
|
121
|
+
}
|
|
122
|
+
return errors;
|
|
151
123
|
}
|
|
152
124
|
function validateProperties(properties, path, valueTypeNames, objectTypeNames) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
return errors;
|
|
125
|
+
const names = /* @__PURE__ */ new Set();
|
|
126
|
+
const errors = [];
|
|
127
|
+
for (let i = 0; i < properties.length; i++) {
|
|
128
|
+
const prop = properties[i];
|
|
129
|
+
const propPath = [...path, i];
|
|
130
|
+
if (names.has(prop.name)) errors.push({
|
|
131
|
+
message: `Duplicate property name: "${prop.name}".`,
|
|
132
|
+
path: [...propPath, "name"]
|
|
133
|
+
});
|
|
134
|
+
names.add(prop.name);
|
|
135
|
+
errors.push(...validateTypeDef(prop.type, [...propPath, "type"], valueTypeNames, objectTypeNames));
|
|
136
|
+
}
|
|
137
|
+
return errors;
|
|
168
138
|
}
|
|
169
|
-
function resolveType(type, valueTypes, seen = new Set()) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
const resolved = valueTypes.get(name);
|
|
178
|
-
if (!resolved) {
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
|
-
return resolveType(resolved, valueTypes, new Set([...seen, name]));
|
|
139
|
+
function resolveType(type, valueTypes, seen = /* @__PURE__ */ new Set()) {
|
|
140
|
+
if (type.kind !== "ref") return type;
|
|
141
|
+
const name = type.value.name;
|
|
142
|
+
if (seen.has(name)) return;
|
|
143
|
+
const resolved = valueTypes.get(name);
|
|
144
|
+
if (!resolved) return;
|
|
145
|
+
return resolveType(resolved, valueTypes, /* @__PURE__ */ new Set([...seen, name]));
|
|
182
146
|
}
|
|
183
147
|
function resolveFieldType(type, path, valueTypes) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const field = resolvedType.value.fields.find((candidate) => candidate.name === segment);
|
|
197
|
-
return field ? resolveFieldType(field.type, rest, valueTypes) : undefined;
|
|
198
|
-
}
|
|
199
|
-
default:
|
|
200
|
-
return undefined;
|
|
201
|
-
}
|
|
148
|
+
const resolvedType = resolveType(type, valueTypes);
|
|
149
|
+
if (!resolvedType) return;
|
|
150
|
+
if (path.length === 0) return resolvedType;
|
|
151
|
+
const [segment, ...rest] = path;
|
|
152
|
+
switch (resolvedType.kind) {
|
|
153
|
+
case "optional": return resolveFieldType(resolvedType.value.type, path, valueTypes);
|
|
154
|
+
case "struct": {
|
|
155
|
+
const field = resolvedType.value.fields.find((candidate) => candidate.name === segment);
|
|
156
|
+
return field ? resolveFieldType(field.type, rest, valueTypes) : void 0;
|
|
157
|
+
}
|
|
158
|
+
default: return;
|
|
159
|
+
}
|
|
202
160
|
}
|
|
203
161
|
function resolveExpressionType(expression, parameters, valueTypes, objectTypes, linkTypes, contextType, locals) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
value: {},
|
|
281
|
-
};
|
|
282
|
-
})(),
|
|
283
|
-
})),
|
|
284
|
-
},
|
|
285
|
-
};
|
|
286
|
-
case "map": {
|
|
287
|
-
const sourceType = resolveExpressionType(expression.value.source, parameters, valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
288
|
-
const listType = sourceType &&
|
|
289
|
-
sourceType.kind !== "ontologyObject"
|
|
290
|
-
? unwrapOptionalType(sourceType, valueTypes)
|
|
291
|
-
: undefined;
|
|
292
|
-
if (listType?.kind !== "list") {
|
|
293
|
-
return undefined;
|
|
294
|
-
}
|
|
295
|
-
const bodyLocals = new Map(locals);
|
|
296
|
-
bodyLocals.set(expression.value.binding, listType.value.elementType);
|
|
297
|
-
const bodyType = resolveExpressionType(expression.value.body, parameters, valueTypes, objectTypes, linkTypes, contextType, bodyLocals);
|
|
298
|
-
return bodyType && bodyType.kind !== "ontologyObject"
|
|
299
|
-
? {
|
|
300
|
-
kind: "list",
|
|
301
|
-
value: { elementType: bodyType },
|
|
302
|
-
}
|
|
303
|
-
: undefined;
|
|
304
|
-
}
|
|
305
|
-
case "literal":
|
|
306
|
-
return { kind: "unknown", value: {} };
|
|
307
|
-
case "uuid":
|
|
308
|
-
return { kind: "string", value: {} };
|
|
309
|
-
case "now":
|
|
310
|
-
return { kind: "timestamp", value: {} };
|
|
311
|
-
}
|
|
162
|
+
switch (expression.kind) {
|
|
163
|
+
case "inputReference": return parameters.get(expression.value.name)?.type;
|
|
164
|
+
case "contextReference": return contextType ? resolveFieldType(contextType, [expression.value.name], valueTypes) : void 0;
|
|
165
|
+
case "localReference": return locals.get(expression.value.name);
|
|
166
|
+
case "getAt": {
|
|
167
|
+
const sourceType = resolveExpressionType(expression.value.source, parameters, valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
168
|
+
if (!sourceType || expression.value.path.length === 0) return;
|
|
169
|
+
if (sourceType.kind === "ontologyObject") {
|
|
170
|
+
const [propertyName, ...rest] = expression.value.path;
|
|
171
|
+
const property = objectTypes.get(sourceType.objectType)?.properties.find((candidate) => candidate.name === propertyName);
|
|
172
|
+
return property ? resolveFieldType(property.type, rest, valueTypes) : void 0;
|
|
173
|
+
}
|
|
174
|
+
return resolveFieldType(sourceType, expression.value.path, valueTypes);
|
|
175
|
+
}
|
|
176
|
+
case "objectLookup": {
|
|
177
|
+
const referenceType = resolveExpressionType(expression.value.reference, parameters, valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
178
|
+
const resolved = referenceType?.kind === "ontologyObject" ? void 0 : referenceType ? unwrapOptionalType(referenceType, valueTypes) : void 0;
|
|
179
|
+
return resolved?.kind === "objectReference" ? {
|
|
180
|
+
kind: "ontologyObject",
|
|
181
|
+
objectType: resolved.value.objectType
|
|
182
|
+
} : void 0;
|
|
183
|
+
}
|
|
184
|
+
case "linkHop": {
|
|
185
|
+
const sourceType = resolveExpressionType(expression.value.source, parameters, valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
186
|
+
if (sourceType?.kind !== "ontologyObject") return;
|
|
187
|
+
const link = resolveLinkHop({
|
|
188
|
+
objectTypes: [...objectTypes.values()],
|
|
189
|
+
linkTypes: [...linkTypes]
|
|
190
|
+
}, sourceType.objectType, expression.value.link);
|
|
191
|
+
if (!link) return void 0;
|
|
192
|
+
const foreignKeyOnSource = isLinkHopFromForeignKeySource(link, sourceType.objectType, expression.value.link);
|
|
193
|
+
if (!foreignKeyOnSource && link.cardinality === "many") return;
|
|
194
|
+
return {
|
|
195
|
+
kind: "ontologyObject",
|
|
196
|
+
objectType: foreignKeyOnSource ? link.target.objectType : link.source.objectType
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
case "struct": return {
|
|
200
|
+
kind: "struct",
|
|
201
|
+
value: { fields: expression.value.fields.map((field) => ({
|
|
202
|
+
name: field.name,
|
|
203
|
+
displayName: field.name,
|
|
204
|
+
type: (() => {
|
|
205
|
+
const resolved = resolveExpressionType(field.value, parameters, valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
206
|
+
return resolved && resolved.kind !== "ontologyObject" ? resolved : {
|
|
207
|
+
kind: "unknown",
|
|
208
|
+
value: {}
|
|
209
|
+
};
|
|
210
|
+
})()
|
|
211
|
+
})) }
|
|
212
|
+
};
|
|
213
|
+
case "map": {
|
|
214
|
+
const sourceType = resolveExpressionType(expression.value.source, parameters, valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
215
|
+
const listType = sourceType && sourceType.kind !== "ontologyObject" ? unwrapOptionalType(sourceType, valueTypes) : void 0;
|
|
216
|
+
if (listType?.kind !== "list") return;
|
|
217
|
+
const bodyLocals = new Map(locals);
|
|
218
|
+
bodyLocals.set(expression.value.binding, listType.value.elementType);
|
|
219
|
+
const bodyType = resolveExpressionType(expression.value.body, parameters, valueTypes, objectTypes, linkTypes, contextType, bodyLocals);
|
|
220
|
+
return bodyType && bodyType.kind !== "ontologyObject" ? {
|
|
221
|
+
kind: "list",
|
|
222
|
+
value: { elementType: bodyType }
|
|
223
|
+
} : void 0;
|
|
224
|
+
}
|
|
225
|
+
case "literal": return {
|
|
226
|
+
kind: "unknown",
|
|
227
|
+
value: {}
|
|
228
|
+
};
|
|
229
|
+
case "uuid": return {
|
|
230
|
+
kind: "string",
|
|
231
|
+
value: {}
|
|
232
|
+
};
|
|
233
|
+
case "now": return {
|
|
234
|
+
kind: "timestamp",
|
|
235
|
+
value: {}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
312
238
|
}
|
|
313
|
-
function validateExpression(expression, parameters, path, valueTypes, objectTypes, linkTypes, contextType, locals = new Map()) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const errors = validateExpression(expression.value.source, parameters, [...path, "source"], valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
397
|
-
const sourceType = resolveExpressionType(expression.value.source, parameters, valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
398
|
-
const listType = sourceType &&
|
|
399
|
-
sourceType.kind !== "ontologyObject"
|
|
400
|
-
? unwrapOptionalType(sourceType, valueTypes)
|
|
401
|
-
: undefined;
|
|
402
|
-
if (sourceType && listType?.kind !== "list") {
|
|
403
|
-
errors.push({
|
|
404
|
-
message: "Map expression source must resolve to a list.",
|
|
405
|
-
path: [...path, "source"],
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
if (!expression.value.binding) {
|
|
409
|
-
errors.push({
|
|
410
|
-
message: "Map expression binding must not be empty.",
|
|
411
|
-
path: [...path, "binding"],
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
const bodyLocals = new Map(locals);
|
|
415
|
-
bodyLocals.set(expression.value.binding, listType?.kind === "list" ? listType.value.elementType : { kind: "unknown", value: {} });
|
|
416
|
-
errors.push(...validateExpression(expression.value.body, parameters, [...path, "body"], valueTypes, objectTypes, linkTypes, contextType, bodyLocals));
|
|
417
|
-
return errors;
|
|
418
|
-
}
|
|
419
|
-
case "uuid":
|
|
420
|
-
case "now":
|
|
421
|
-
case "literal":
|
|
422
|
-
return [];
|
|
423
|
-
}
|
|
239
|
+
function validateExpression(expression, parameters, path, valueTypes, objectTypes, linkTypes, contextType, locals = /* @__PURE__ */ new Map()) {
|
|
240
|
+
switch (expression.kind) {
|
|
241
|
+
case "inputReference":
|
|
242
|
+
if (!parameters.get(expression.value.name)) return [{
|
|
243
|
+
message: `Unknown action parameter: "${expression.value.name}".`,
|
|
244
|
+
path: [...path, "name"]
|
|
245
|
+
}];
|
|
246
|
+
return [];
|
|
247
|
+
case "contextReference":
|
|
248
|
+
if (!contextType) return [];
|
|
249
|
+
return resolveFieldType(contextType, [expression.value.name], valueTypes) ? [] : [{
|
|
250
|
+
message: `Unknown context value: "${expression.value.name}".`,
|
|
251
|
+
path: [...path, "name"]
|
|
252
|
+
}];
|
|
253
|
+
case "localReference":
|
|
254
|
+
if (!locals.get(expression.value.name)) return [{
|
|
255
|
+
message: `Unknown expression binding: "${expression.value.name}".`,
|
|
256
|
+
path: [...path, "name"]
|
|
257
|
+
}];
|
|
258
|
+
return [];
|
|
259
|
+
case "getAt":
|
|
260
|
+
case "objectLookup":
|
|
261
|
+
case "linkHop": {
|
|
262
|
+
const childKey = expression.kind === "objectLookup" ? "reference" : "source";
|
|
263
|
+
const errors = validateExpression(expression.kind === "objectLookup" ? expression.value.reference : expression.value.source, parameters, [...path, childKey], valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
264
|
+
if (expression.kind === "getAt" && expression.value.path.length === 0) errors.push({
|
|
265
|
+
message: "Get-at expression paths must not be empty.",
|
|
266
|
+
path: [...path, "path"]
|
|
267
|
+
});
|
|
268
|
+
if (!resolveExpressionType(expression, parameters, valueTypes, objectTypes, linkTypes, contextType, locals)) errors.push({
|
|
269
|
+
message: expression.kind === "getAt" ? "Get-at expression source and path must resolve structurally." : expression.kind === "objectLookup" ? "Object lookup references must resolve to an object reference." : "Link hop must resolve to a named to-one link.",
|
|
270
|
+
path
|
|
271
|
+
});
|
|
272
|
+
return errors;
|
|
273
|
+
}
|
|
274
|
+
case "struct": {
|
|
275
|
+
const errors = [];
|
|
276
|
+
const names = /* @__PURE__ */ new Set();
|
|
277
|
+
for (let index = 0; index < expression.value.fields.length; index++) {
|
|
278
|
+
const field = expression.value.fields[index];
|
|
279
|
+
if (names.has(field.name)) errors.push({
|
|
280
|
+
message: `Duplicate struct expression field: "${field.name}".`,
|
|
281
|
+
path: [
|
|
282
|
+
...path,
|
|
283
|
+
"fields",
|
|
284
|
+
index,
|
|
285
|
+
"name"
|
|
286
|
+
]
|
|
287
|
+
});
|
|
288
|
+
names.add(field.name);
|
|
289
|
+
errors.push(...validateExpression(field.value, parameters, [
|
|
290
|
+
...path,
|
|
291
|
+
"fields",
|
|
292
|
+
index,
|
|
293
|
+
"value"
|
|
294
|
+
], valueTypes, objectTypes, linkTypes, contextType, locals));
|
|
295
|
+
}
|
|
296
|
+
return errors;
|
|
297
|
+
}
|
|
298
|
+
case "map": {
|
|
299
|
+
const errors = validateExpression(expression.value.source, parameters, [...path, "source"], valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
300
|
+
const sourceType = resolveExpressionType(expression.value.source, parameters, valueTypes, objectTypes, linkTypes, contextType, locals);
|
|
301
|
+
const listType = sourceType && sourceType.kind !== "ontologyObject" ? unwrapOptionalType(sourceType, valueTypes) : void 0;
|
|
302
|
+
if (sourceType && listType?.kind !== "list") errors.push({
|
|
303
|
+
message: "Map expression source must resolve to a list.",
|
|
304
|
+
path: [...path, "source"]
|
|
305
|
+
});
|
|
306
|
+
if (!expression.value.binding) errors.push({
|
|
307
|
+
message: "Map expression binding must not be empty.",
|
|
308
|
+
path: [...path, "binding"]
|
|
309
|
+
});
|
|
310
|
+
const bodyLocals = new Map(locals);
|
|
311
|
+
bodyLocals.set(expression.value.binding, listType?.kind === "list" ? listType.value.elementType : {
|
|
312
|
+
kind: "unknown",
|
|
313
|
+
value: {}
|
|
314
|
+
});
|
|
315
|
+
errors.push(...validateExpression(expression.value.body, parameters, [...path, "body"], valueTypes, objectTypes, linkTypes, contextType, bodyLocals));
|
|
316
|
+
return errors;
|
|
317
|
+
}
|
|
318
|
+
case "uuid":
|
|
319
|
+
case "now":
|
|
320
|
+
case "literal": return [];
|
|
321
|
+
}
|
|
424
322
|
}
|
|
425
323
|
function unwrapOptionalType(type, valueTypes) {
|
|
426
|
-
|
|
427
|
-
|
|
324
|
+
const resolved = resolveType(type, valueTypes);
|
|
325
|
+
return resolved?.kind === "optional" ? unwrapOptionalType(resolved.value.type, valueTypes) : resolved;
|
|
428
326
|
}
|
|
429
327
|
function areDefaultTypesCompatible(target, source, valueTypes) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
if (targetType.kind === "objectReference" && sourceType.kind === "objectReference") {
|
|
439
|
-
return targetType.value.objectType === sourceType.value.objectType;
|
|
440
|
-
}
|
|
441
|
-
if (targetType.kind === "list" && sourceType.kind === "list") {
|
|
442
|
-
return areDefaultTypesCompatible(targetType.value.elementType, sourceType.value.elementType, valueTypes);
|
|
443
|
-
}
|
|
444
|
-
return true;
|
|
328
|
+
const targetType = unwrapOptionalType(target, valueTypes);
|
|
329
|
+
const sourceType = unwrapOptionalType(source, valueTypes);
|
|
330
|
+
if (!targetType || !sourceType) return false;
|
|
331
|
+
if (targetType.kind === "unknown" || sourceType.kind === "unknown") return true;
|
|
332
|
+
if (targetType.kind !== sourceType.kind) return false;
|
|
333
|
+
if (targetType.kind === "objectReference" && sourceType.kind === "objectReference") return targetType.value.objectType === sourceType.value.objectType;
|
|
334
|
+
if (targetType.kind === "list" && sourceType.kind === "list") return areDefaultTypesCompatible(targetType.value.elementType, sourceType.value.elementType, valueTypes);
|
|
335
|
+
return true;
|
|
445
336
|
}
|
|
446
337
|
function validateActionObjectReference(reference, parameters, path, valueTypes, objectTypes) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
},
|
|
467
|
-
],
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
const targetObjectType = objectTypes.get(resolved.value.objectType);
|
|
471
|
-
return targetObjectType
|
|
472
|
-
? { errors: [], objectType: targetObjectType }
|
|
473
|
-
: {
|
|
474
|
-
errors: [
|
|
475
|
-
{
|
|
476
|
-
message: `Unknown object type reference: "${resolved.value.objectType}".`,
|
|
477
|
-
path: [...path, "name"],
|
|
478
|
-
},
|
|
479
|
-
],
|
|
480
|
-
};
|
|
338
|
+
const parameterName = reference.name;
|
|
339
|
+
const parameter = parameters.get(parameterName);
|
|
340
|
+
if (!parameter) return { errors: [{
|
|
341
|
+
message: `Unknown action parameter: "${parameterName}".`,
|
|
342
|
+
path: [...path, "name"]
|
|
343
|
+
}] };
|
|
344
|
+
const resolved = resolveType(parameter.type, valueTypes);
|
|
345
|
+
if (!resolved || resolved.kind !== "objectReference") return { errors: [{
|
|
346
|
+
message: `Action target parameter "${parameterName}" must be an object reference.`,
|
|
347
|
+
path: [...path, "name"]
|
|
348
|
+
}] };
|
|
349
|
+
const targetObjectType = objectTypes.get(resolved.value.objectType);
|
|
350
|
+
return targetObjectType ? {
|
|
351
|
+
errors: [],
|
|
352
|
+
objectType: targetObjectType
|
|
353
|
+
} : { errors: [{
|
|
354
|
+
message: `Unknown object type reference: "${resolved.value.objectType}".`,
|
|
355
|
+
path: [...path, "name"]
|
|
356
|
+
}] };
|
|
481
357
|
}
|
|
482
358
|
function validateActionPropertyAssignment(assignment, target, parameters, path, valueTypes, objectTypes, linkTypes, contextType) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const errors = validateExpression(assignment.value, parameters, [...path, "value"], valueTypes, objectTypes, linkTypes, contextType);
|
|
500
|
-
return resolved
|
|
501
|
-
? errors
|
|
502
|
-
: [
|
|
503
|
-
...errors,
|
|
504
|
-
{
|
|
505
|
-
message: `Invalid property "${assignment.property.join(".")}" on object type "${target.name}".`,
|
|
506
|
-
path: [...path, "property"],
|
|
507
|
-
},
|
|
508
|
-
];
|
|
359
|
+
if (assignment.property.length === 0) return [{
|
|
360
|
+
message: "Action property assignments must specify a property.",
|
|
361
|
+
path: [...path, "property"]
|
|
362
|
+
}];
|
|
363
|
+
const [propertyName, ...rest] = assignment.property;
|
|
364
|
+
const property = target.properties.find((candidate) => candidate.name === propertyName);
|
|
365
|
+
if (!property) return [{
|
|
366
|
+
message: `Unknown property "${propertyName}" on object type "${target.name}".`,
|
|
367
|
+
path: [...path, "property"]
|
|
368
|
+
}];
|
|
369
|
+
const resolved = resolveFieldType(property.type, rest, valueTypes);
|
|
370
|
+
const errors = validateExpression(assignment.value, parameters, [...path, "value"], valueTypes, objectTypes, linkTypes, contextType);
|
|
371
|
+
return resolved ? errors : [...errors, {
|
|
372
|
+
message: `Invalid property "${assignment.property.join(".")}" on object type "${target.name}".`,
|
|
373
|
+
path: [...path, "property"]
|
|
374
|
+
}];
|
|
509
375
|
}
|
|
510
376
|
function validateAction(action, path, valueTypes, objectTypes, linkTypes, contextType) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
377
|
+
const errors = [];
|
|
378
|
+
const parameters = new Map(action.parameters.map((parameter) => [parameter.name, parameter]));
|
|
379
|
+
const seenParameters = /* @__PURE__ */ new Set();
|
|
380
|
+
for (let index = 0; index < action.parameters.length; index++) {
|
|
381
|
+
const parameter = action.parameters[index];
|
|
382
|
+
const parameterPath = [
|
|
383
|
+
...path,
|
|
384
|
+
"parameters",
|
|
385
|
+
index
|
|
386
|
+
];
|
|
387
|
+
if (seenParameters.has(parameter.name)) errors.push({
|
|
388
|
+
message: `Duplicate action parameter name: "${parameter.name}".`,
|
|
389
|
+
path: [...parameterPath, "name"]
|
|
390
|
+
});
|
|
391
|
+
seenParameters.add(parameter.name);
|
|
392
|
+
errors.push(...validateTypeDef(parameter.type, [...parameterPath, "type"], new Set(valueTypes.keys()), new Set(objectTypes.keys())));
|
|
393
|
+
if (parameter.defaultValue) {
|
|
394
|
+
errors.push(...validateExpression(parameter.defaultValue, parameters, [...parameterPath, "defaultValue"], valueTypes, objectTypes, linkTypes, contextType));
|
|
395
|
+
const sourceType = resolveExpressionType(parameter.defaultValue, parameters, valueTypes, objectTypes, linkTypes, contextType, /* @__PURE__ */ new Map());
|
|
396
|
+
if (sourceType && sourceType.kind !== "ontologyObject" && !areDefaultTypesCompatible(parameter.type, sourceType, valueTypes)) errors.push({
|
|
397
|
+
message: `Default value for "${parameter.name}" has an incompatible type.`,
|
|
398
|
+
path: [...parameterPath, "defaultValue"]
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
for (let index = 0; index < action.logic.length; index++) {
|
|
403
|
+
const step = action.logic[index];
|
|
404
|
+
const stepPath = [
|
|
405
|
+
...path,
|
|
406
|
+
"logic",
|
|
407
|
+
index
|
|
408
|
+
];
|
|
409
|
+
switch (step.kind) {
|
|
410
|
+
case "createObject": {
|
|
411
|
+
const objectType = objectTypes.get(step.value.objectType);
|
|
412
|
+
if (!objectType) {
|
|
413
|
+
errors.push({
|
|
414
|
+
message: `Unknown object type "${step.value.objectType}" in action "${action.name}".`,
|
|
415
|
+
path: [
|
|
416
|
+
...stepPath,
|
|
417
|
+
"value",
|
|
418
|
+
"objectType"
|
|
419
|
+
]
|
|
420
|
+
});
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
for (let valueIndex = 0; valueIndex < step.value.values.length; valueIndex++) errors.push(...validateActionPropertyAssignment(step.value.values[valueIndex], objectType, parameters, [
|
|
424
|
+
...stepPath,
|
|
425
|
+
"value",
|
|
426
|
+
"values",
|
|
427
|
+
valueIndex
|
|
428
|
+
], valueTypes, objectTypes, linkTypes, contextType));
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
case "updateObject": {
|
|
432
|
+
const target = validateActionObjectReference(step.value.object, parameters, [
|
|
433
|
+
...stepPath,
|
|
434
|
+
"value",
|
|
435
|
+
"object"
|
|
436
|
+
], valueTypes, objectTypes);
|
|
437
|
+
errors.push(...target.errors);
|
|
438
|
+
if (!target.objectType) continue;
|
|
439
|
+
for (let valueIndex = 0; valueIndex < step.value.values.length; valueIndex++) errors.push(...validateActionPropertyAssignment(step.value.values[valueIndex], target.objectType, parameters, [
|
|
440
|
+
...stepPath,
|
|
441
|
+
"value",
|
|
442
|
+
"values",
|
|
443
|
+
valueIndex
|
|
444
|
+
], valueTypes, objectTypes, linkTypes, contextType));
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
case "deleteObject": errors.push(...validateActionObjectReference(step.value.object, parameters, [
|
|
448
|
+
...stepPath,
|
|
449
|
+
"value",
|
|
450
|
+
"object"
|
|
451
|
+
], valueTypes, objectTypes).errors);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return errors;
|
|
573
455
|
}
|
|
574
456
|
function validateQueryFunctionType(queryFunctionType, path, valueTypeNames, objectTypeNames) {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
457
|
+
const errors = [];
|
|
458
|
+
const seenParameters = /* @__PURE__ */ new Set();
|
|
459
|
+
for (let index = 0; index < queryFunctionType.parameters.length; index++) {
|
|
460
|
+
const parameter = queryFunctionType.parameters[index];
|
|
461
|
+
const parameterPath = [
|
|
462
|
+
...path,
|
|
463
|
+
"parameters",
|
|
464
|
+
index
|
|
465
|
+
];
|
|
466
|
+
if (seenParameters.has(parameter.name)) errors.push({
|
|
467
|
+
message: `Duplicate query function parameter name: "${parameter.name}".`,
|
|
468
|
+
path: [...parameterPath, "name"]
|
|
469
|
+
});
|
|
470
|
+
seenParameters.add(parameter.name);
|
|
471
|
+
errors.push(...validateTypeDef(parameter.type, [...parameterPath, "type"], valueTypeNames, objectTypeNames));
|
|
472
|
+
}
|
|
473
|
+
errors.push(...validateTypeDef(queryFunctionType.returnType, [...path, "returnType"], valueTypeNames, objectTypeNames));
|
|
474
|
+
return errors;
|
|
591
475
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
errors.push(...validateQueryFunctionType(queryFunctionType, queryFunctionTypePath, valueTypeNames, objectTypeNames));
|
|
736
|
-
}
|
|
737
|
-
return errors.length === 0
|
|
738
|
-
? { kind: "ok", value: undefined }
|
|
739
|
-
: { kind: "err", value: errors };
|
|
476
|
+
function validate(ontology) {
|
|
477
|
+
const errors = [];
|
|
478
|
+
const valueTypeNames = /* @__PURE__ */ new Set();
|
|
479
|
+
for (let i = 0; i < ontology.types.length; i++) {
|
|
480
|
+
const vt = ontology.types[i];
|
|
481
|
+
if (valueTypeNames.has(vt.name)) errors.push({
|
|
482
|
+
message: `Duplicate value type name: "${vt.name}".`,
|
|
483
|
+
path: [
|
|
484
|
+
"types",
|
|
485
|
+
i,
|
|
486
|
+
"name"
|
|
487
|
+
]
|
|
488
|
+
});
|
|
489
|
+
valueTypeNames.add(vt.name);
|
|
490
|
+
}
|
|
491
|
+
const objectTypeNames = /* @__PURE__ */ new Set();
|
|
492
|
+
for (let i = 0; i < ontology.objectTypes.length; i++) {
|
|
493
|
+
const ot = ontology.objectTypes[i];
|
|
494
|
+
if (objectTypeNames.has(ot.name)) errors.push({
|
|
495
|
+
message: `Duplicate object type name: "${ot.name}".`,
|
|
496
|
+
path: [
|
|
497
|
+
"objectTypes",
|
|
498
|
+
i,
|
|
499
|
+
"name"
|
|
500
|
+
]
|
|
501
|
+
});
|
|
502
|
+
objectTypeNames.add(ot.name);
|
|
503
|
+
}
|
|
504
|
+
const valueTypes = new Map(ontology.types.map((type) => [type.name, type.type]));
|
|
505
|
+
const objectTypes = new Map(ontology.objectTypes.map((objectType) => [objectType.name, objectType]));
|
|
506
|
+
if (ontology.contextType) {
|
|
507
|
+
errors.push(...validateTypeDef(ontology.contextType, ["contextType"], valueTypeNames, objectTypeNames));
|
|
508
|
+
const resolvedContextType = resolveType(ontology.contextType, valueTypes);
|
|
509
|
+
if (resolvedContextType?.kind === "struct") {
|
|
510
|
+
const userField = resolvedContextType.value.fields.find((field) => field.name === "user");
|
|
511
|
+
const unwrappedUserType = userField ? unwrapType(userField.type).type : void 0;
|
|
512
|
+
const resolvedUserType = unwrappedUserType ? resolveType(unwrappedUserType, valueTypes) : void 0;
|
|
513
|
+
if (userField && resolvedUserType?.kind !== "objectReference") errors.push({
|
|
514
|
+
message: "Reserved context field \"user\" must be an object reference.",
|
|
515
|
+
path: [
|
|
516
|
+
"contextType",
|
|
517
|
+
"fields",
|
|
518
|
+
resolvedContextType.value.fields.indexOf(userField),
|
|
519
|
+
"type"
|
|
520
|
+
]
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
for (let i = 0; i < ontology.types.length; i++) {
|
|
525
|
+
const vt = ontology.types[i];
|
|
526
|
+
errors.push(...validateTypeDef(vt.type, [
|
|
527
|
+
"types",
|
|
528
|
+
i,
|
|
529
|
+
"type"
|
|
530
|
+
], valueTypeNames, objectTypeNames));
|
|
531
|
+
}
|
|
532
|
+
for (let i = 0; i < ontology.objectTypes.length; i++) {
|
|
533
|
+
const ot = ontology.objectTypes[i];
|
|
534
|
+
const otPath = ["objectTypes", i];
|
|
535
|
+
errors.push(...validateProperties(ot.properties, [...otPath, "properties"], valueTypeNames, objectTypeNames));
|
|
536
|
+
const propertyNames = new Set(ot.properties.map((p) => p.name));
|
|
537
|
+
if (!propertyNames.has(ot.primaryKey)) errors.push({
|
|
538
|
+
message: `Primary key "${ot.primaryKey}" does not reference a valid property.`,
|
|
539
|
+
path: [...otPath, "primaryKey"]
|
|
540
|
+
});
|
|
541
|
+
if (ot.title && !propertyNames.has(ot.title)) errors.push({
|
|
542
|
+
message: `Title "${ot.title}" does not reference a valid property.`,
|
|
543
|
+
path: [...otPath, "title"]
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
const linkIds = /* @__PURE__ */ new Set();
|
|
547
|
+
const linkNames = /* @__PURE__ */ new Set();
|
|
548
|
+
for (let i = 0; i < ontology.linkTypes.length; i++) {
|
|
549
|
+
const lt = ontology.linkTypes[i];
|
|
550
|
+
const ltPath = ["linkTypes", i];
|
|
551
|
+
if (linkIds.has(lt.id)) errors.push({
|
|
552
|
+
message: `Duplicate link type id: "${lt.id}".`,
|
|
553
|
+
path: [...ltPath, "id"]
|
|
554
|
+
});
|
|
555
|
+
linkIds.add(lt.id);
|
|
556
|
+
const linkName = `${lt.source.objectType}:${lt.target.name}`;
|
|
557
|
+
if (linkNames.has(linkName)) errors.push({
|
|
558
|
+
message: `Duplicate link type target name: "${lt.target.name}" on "${lt.source.objectType}".`,
|
|
559
|
+
path: [
|
|
560
|
+
...ltPath,
|
|
561
|
+
"target",
|
|
562
|
+
"name"
|
|
563
|
+
]
|
|
564
|
+
});
|
|
565
|
+
linkNames.add(linkName);
|
|
566
|
+
if (!objectTypeNames.has(lt.source.objectType)) errors.push({
|
|
567
|
+
message: `Source object type "${lt.source.objectType}" does not exist.`,
|
|
568
|
+
path: [
|
|
569
|
+
...ltPath,
|
|
570
|
+
"source",
|
|
571
|
+
"objectType"
|
|
572
|
+
]
|
|
573
|
+
});
|
|
574
|
+
if (!objectTypeNames.has(lt.target.objectType)) errors.push({
|
|
575
|
+
message: `Target object type "${lt.target.objectType}" does not exist.`,
|
|
576
|
+
path: [
|
|
577
|
+
...ltPath,
|
|
578
|
+
"target",
|
|
579
|
+
"objectType"
|
|
580
|
+
]
|
|
581
|
+
});
|
|
582
|
+
const foreignKeyRoot = lt.foreignKey.split(".")[0];
|
|
583
|
+
const sourceType = ontology.objectTypes.find((candidate) => candidate.name === lt.source.objectType);
|
|
584
|
+
const sourceHasFk = sourceType?.properties.some((property) => property.name === foreignKeyRoot) ?? false;
|
|
585
|
+
if (sourceType && !sourceHasFk) errors.push({
|
|
586
|
+
message: `Foreign key "${lt.foreignKey}" does not exist on source object type "${lt.source.objectType}" for link "${lt.id}".`,
|
|
587
|
+
path: [...ltPath, "foreignKey"]
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
const actionNames = /* @__PURE__ */ new Set();
|
|
591
|
+
for (let i = 0; i < ontology.actionTypes.length; i++) {
|
|
592
|
+
const action = ontology.actionTypes[i];
|
|
593
|
+
const actionPath = ["actionTypes", i];
|
|
594
|
+
if (actionNames.has(action.name)) errors.push({
|
|
595
|
+
message: `Duplicate action type name: "${action.name}".`,
|
|
596
|
+
path: [...actionPath, "name"]
|
|
597
|
+
});
|
|
598
|
+
actionNames.add(action.name);
|
|
599
|
+
errors.push(...validateAction(action, actionPath, valueTypes, objectTypes, ontology.linkTypes, ontology.contextType));
|
|
600
|
+
}
|
|
601
|
+
const queryFunctionTypeNames = /* @__PURE__ */ new Set();
|
|
602
|
+
for (let i = 0; i < ontology.queryFunctionTypes.length; i++) {
|
|
603
|
+
const queryFunctionType = ontology.queryFunctionTypes[i];
|
|
604
|
+
const queryFunctionTypePath = ["queryFunctionTypes", i];
|
|
605
|
+
if (queryFunctionTypeNames.has(queryFunctionType.name)) errors.push({
|
|
606
|
+
message: `Duplicate query function type name: "${queryFunctionType.name}".`,
|
|
607
|
+
path: [...queryFunctionTypePath, "name"]
|
|
608
|
+
});
|
|
609
|
+
queryFunctionTypeNames.add(queryFunctionType.name);
|
|
610
|
+
errors.push(...validateQueryFunctionType(queryFunctionType, queryFunctionTypePath, valueTypeNames, objectTypeNames));
|
|
611
|
+
}
|
|
612
|
+
return errors.length === 0 ? {
|
|
613
|
+
kind: "ok",
|
|
614
|
+
value: void 0
|
|
615
|
+
} : {
|
|
616
|
+
kind: "err",
|
|
617
|
+
value: errors
|
|
618
|
+
};
|
|
740
619
|
}
|
|
620
|
+
//#endregion
|
|
621
|
+
export { validate };
|
|
622
|
+
|
|
741
623
|
//# sourceMappingURL=validate.js.map
|