@party-stack/ontology 0.19.1 → 0.21.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/README.md +31 -0
- package/lib/OntologyPullConfig.d.ts +4 -17
- package/lib/OntologyPullConfig.d.ts.map +1 -1
- package/lib/authentication.d.ts +1068 -0
- package/lib/authentication.d.ts.map +1 -0
- package/lib/authentication.js +55 -0
- package/lib/authentication.js.map +1 -0
- package/lib/cli/index.js +19 -45
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/pull.d.ts.map +1 -1
- package/lib/cli/pull.js +16 -29
- package/lib/cli/pull.js.map +1 -1
- package/lib/client.d.ts +11 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +21 -0
- package/lib/client.js.map +1 -0
- package/lib/examples/blog.d.ts +2 -387
- package/lib/examples/blog.js +1 -353
- package/lib/examples/blog.live-queries.d.ts +1 -1
- package/lib/examples/blog.live-queries.d.ts.map +1 -1
- package/lib/examples/blog.live-queries.js +1 -1
- package/lib/examples/blog.live-queries.js.map +1 -1
- package/lib/examples/generated/collections.d.ts +7 -0
- package/lib/examples/generated/collections.d.ts.map +1 -0
- package/lib/examples/generated/collections.js +12 -0
- package/lib/examples/generated/collections.js.map +1 -0
- package/lib/examples/generated/live.d.ts +2 -2
- package/lib/examples/generated/live.d.ts.map +1 -1
- package/lib/examples/generated/live.js.map +1 -1
- package/lib/http.d.ts +13 -0
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +29 -0
- package/lib/http.js.map +1 -0
- package/lib/index.d.ts +19 -25
- package/lib/index.js +9 -15
- package/lib/json/index.d.ts +1 -16
- package/lib/json/index.js +2 -132
- package/lib/live/LiveOntology.d.ts +114 -50
- package/lib/live/LiveOntology.d.ts.map +1 -1
- package/lib/live/LiveOntology.js +23 -103
- package/lib/live/LiveOntology.js.map +1 -1
- package/lib/live/actions/createLiveOntologyAction.d.ts +15 -16
- package/lib/live/actions/createLiveOntologyAction.d.ts.map +1 -1
- package/lib/live/actions/createLiveOntologyAction.js +3 -11
- package/lib/live/actions/createLiveOntologyAction.js.map +1 -1
- package/lib/live/actions/types.d.ts +21 -0
- package/lib/live/actions/types.d.ts.map +1 -0
- package/lib/live/attachments/createLiveOntologyAttachments.d.ts +30 -19
- package/lib/live/attachments/createLiveOntologyAttachments.d.ts.map +1 -1
- package/lib/live/attachments/createLiveOntologyAttachments.js +43 -60
- package/lib/live/attachments/createLiveOntologyAttachments.js.map +1 -1
- package/lib/live/attachments/types.d.ts +4 -3
- package/lib/live/index.d.ts +10 -10
- package/lib/live/index.js +5 -6
- package/lib/live/mutators/createReadTx.d.ts +5 -0
- package/lib/live/mutators/createReadTx.d.ts.map +1 -0
- package/lib/live/mutators/createReadTx.js +19 -0
- package/lib/live/mutators/createReadTx.js.map +1 -0
- package/lib/live/mutators/types.d.ts +7 -2
- package/lib/live/mutators/types.d.ts.map +1 -1
- package/lib/live/objects/types.d.ts +6 -0
- package/lib/live/objects/types.d.ts.map +1 -0
- package/lib/live/outbox/types.d.ts +24 -15
- package/lib/live/outbox/types.d.ts.map +1 -1
- package/lib/live/outbox/types.js +1 -11
- package/lib/live/pins.d.ts +51 -0
- package/lib/live/pins.d.ts.map +1 -0
- package/lib/live/pins.js +113 -0
- package/lib/live/pins.js.map +1 -0
- package/lib/live/storageBackend.d.ts +50 -0
- package/lib/live/storageBackend.d.ts.map +1 -0
- package/lib/live/storageBackend.js +42 -0
- package/lib/live/storageBackend.js.map +1 -0
- package/lib/local.d.ts +15 -0
- package/lib/local.d.ts.map +1 -0
- package/lib/local.js +19 -0
- package/lib/local.js.map +1 -0
- package/lib/meta/generated/collections.d.ts +7 -0
- package/lib/meta/generated/collections.d.ts.map +1 -0
- package/lib/meta/generated/collections.js +15 -0
- package/lib/meta/generated/collections.js.map +1 -0
- package/lib/meta/generated/live.d.ts +3 -3
- package/lib/meta/generated/live.d.ts.map +1 -1
- package/lib/meta/generated/live.js +2 -2
- package/lib/meta/generated/live.js.map +1 -1
- package/lib/meta/pull.d.ts +5 -9
- package/lib/meta/pull.d.ts.map +1 -1
- package/lib/meta/pull.js +5 -43
- package/lib/meta/pull.js.map +1 -1
- package/lib/query.d.ts +1 -0
- package/lib/query.js +2 -0
- package/lib/runtime/host.d.ts +35 -0
- package/lib/runtime/host.d.ts.map +1 -0
- package/lib/runtime/host.js +39 -0
- package/lib/runtime/host.js.map +1 -0
- package/lib/runtime/index.d.ts +2 -0
- package/lib/runtime/index.js +1 -0
- package/lib/runtime/live.d.ts +25 -0
- package/lib/runtime/live.d.ts.map +1 -0
- package/lib/runtime/live.js +31 -0
- package/lib/runtime/live.js.map +1 -0
- package/lib/runtime/resource.d.ts +24 -0
- package/lib/runtime/resource.d.ts.map +1 -0
- package/lib/runtime/resource.js +127 -0
- package/lib/runtime/resource.js.map +1 -0
- package/lib/runtime/transactions.d.ts +27 -0
- package/lib/runtime/transactions.d.ts.map +1 -0
- package/lib/runtime/transactions.js +188 -0
- package/lib/runtime/transactions.js.map +1 -0
- package/lib/runtime/view.d.ts +25 -0
- package/lib/runtime/view.d.ts.map +1 -0
- package/lib/runtime/view.js +256 -0
- package/lib/runtime/view.js.map +1 -0
- package/lib/tanstack/collections.d.ts +73 -0
- package/lib/tanstack/collections.d.ts.map +1 -0
- package/lib/tanstack/collections.js +495 -0
- package/lib/tanstack/collections.js.map +1 -0
- package/lib/tanstack/createLocalCollection.d.ts +14 -0
- package/lib/tanstack/createLocalCollection.d.ts.map +1 -0
- package/lib/tanstack/createLocalCollection.js +9 -0
- package/lib/tanstack/createLocalCollection.js.map +1 -0
- package/lib/tanstack/descriptors.d.ts +33 -0
- package/lib/tanstack/descriptors.d.ts.map +1 -0
- package/lib/tanstack/descriptors.js +38 -0
- package/lib/tanstack/descriptors.js.map +1 -0
- package/lib/tanstack/diagnostics.d.ts +23 -0
- package/lib/tanstack/diagnostics.d.ts.map +1 -0
- package/lib/tanstack/diagnostics.js +14 -0
- package/lib/tanstack/diagnostics.js.map +1 -0
- package/lib/tanstack/index.d.ts +6 -0
- package/lib/tanstack/index.js +6 -0
- package/lib/tanstack/localCollection.d.ts +14 -0
- package/lib/tanstack/localCollection.d.ts.map +1 -0
- package/lib/tanstack/localCollection.js +73 -0
- package/lib/tanstack/localCollection.js.map +1 -0
- package/lib/tanstack/subset.d.ts +28 -0
- package/lib/tanstack/subset.d.ts.map +1 -0
- package/lib/tanstack/subset.js +290 -0
- package/lib/tanstack/subset.js.map +1 -0
- package/lib/testing/sqlite.d.ts +40 -0
- package/lib/testing/sqlite.d.ts.map +1 -0
- package/lib/testing/sqlite.js +409 -0
- package/lib/testing/sqlite.js.map +1 -0
- package/lib/testing/sqliteBackend.d.ts +68 -0
- package/lib/testing/sqliteBackend.d.ts.map +1 -0
- package/lib/testing/sqliteBackend.js +34 -0
- package/lib/testing/sqliteBackend.js.map +1 -0
- package/lib/utils/index.d.ts +1 -8
- package/lib/utils/index.js +2 -5
- package/lib/utils/values.d.ts +1 -33
- package/lib/worker.d.ts +19 -0
- package/lib/worker.d.ts.map +1 -0
- package/lib/worker.js +46 -0
- package/lib/worker.js.map +1 -0
- package/package.json +54 -19
- package/lib/_virtual/_rolldown/runtime.js +0 -13
- package/lib/cli/format.d.ts +0 -4
- package/lib/cli/format.d.ts.map +0 -1
- package/lib/cli/format.js +0 -19
- package/lib/cli/format.js.map +0 -1
- package/lib/cli/generate.d.ts +0 -10
- package/lib/cli/generate.d.ts.map +0 -1
- package/lib/cli/generate.js +0 -108
- package/lib/cli/generate.js.map +0 -1
- package/lib/examples/blog.d.ts.map +0 -1
- package/lib/examples/blog.js.map +0 -1
- package/lib/generate/builders.d.ts +0 -12
- package/lib/generate/builders.d.ts.map +0 -1
- package/lib/generate/builders.js +0 -58
- package/lib/generate/builders.js.map +0 -1
- package/lib/generate/constants.d.ts +0 -5
- package/lib/generate/constants.d.ts.map +0 -1
- package/lib/generate/constants.js +0 -28
- package/lib/generate/constants.js.map +0 -1
- package/lib/generate/index.d.ts +0 -6
- package/lib/generate/index.js +0 -6
- package/lib/generate/live.d.ts +0 -12
- package/lib/generate/live.d.ts.map +0 -1
- package/lib/generate/live.js +0 -48
- package/lib/generate/live.js.map +0 -1
- package/lib/generate/ontology.d.ts +0 -8
- package/lib/generate/ontology.d.ts.map +0 -1
- package/lib/generate/ontology.js +0 -501
- package/lib/generate/ontology.js.map +0 -1
- package/lib/generate/types.d.ts +0 -17
- package/lib/generate/types.d.ts.map +0 -1
- package/lib/generate/types.js +0 -216
- package/lib/generate/types.js.map +0 -1
- package/lib/generate/utils/buildJsDocs.d.ts +0 -10
- package/lib/generate/utils/buildJsDocs.d.ts.map +0 -1
- package/lib/generate/utils/buildJsDocs.js +0 -16
- package/lib/generate/utils/buildJsDocs.js.map +0 -1
- package/lib/infer.d.ts +0 -222
- package/lib/infer.d.ts.map +0 -1
- package/lib/infer.js +0 -14
- package/lib/infer.js.map +0 -1
- package/lib/installation/createMetaOntologyConfiguration.d.ts +0 -10
- package/lib/installation/createMetaOntologyConfiguration.d.ts.map +0 -1
- package/lib/installation/createMetaOntologyConfiguration.js +0 -16
- package/lib/installation/createMetaOntologyConfiguration.js.map +0 -1
- package/lib/installation/createOntologyBackendInstallation.d.ts +0 -5
- package/lib/installation/createOntologyBackendInstallation.d.ts.map +0 -1
- package/lib/installation/createOntologyBackendInstallation.js +0 -221
- package/lib/installation/createOntologyBackendInstallation.js.map +0 -1
- package/lib/installation/index.d.ts +0 -4
- package/lib/installation/index.js +0 -3
- package/lib/installation/types.d.ts +0 -94
- package/lib/installation/types.d.ts.map +0 -1
- package/lib/ir/generated/builders.d.ts +0 -380
- package/lib/ir/generated/builders.d.ts.map +0 -1
- package/lib/ir/generated/builders.js +0 -186
- package/lib/ir/generated/builders.js.map +0 -1
- package/lib/ir/generated/constants.d.ts +0 -265
- package/lib/ir/generated/constants.d.ts.map +0 -1
- package/lib/ir/generated/constants.js +0 -165
- package/lib/ir/generated/constants.js.map +0 -1
- package/lib/ir/generated/types.d.ts +0 -416
- package/lib/ir/generated/types.d.ts.map +0 -1
- package/lib/ir/index.d.ts +0 -4
- package/lib/ir/index.js +0 -3
- package/lib/ir/schema.d.ts +0 -2246
- package/lib/ir/schema.d.ts.map +0 -1
- package/lib/ir/schema.js +0 -1187
- package/lib/ir/schema.js.map +0 -1
- package/lib/ir/validate.d.ts +0 -8
- package/lib/ir/validate.d.ts.map +0 -1
- package/lib/ir/validate.js +0 -623
- package/lib/ir/validate.js.map +0 -1
- package/lib/json/index.d.ts.map +0 -1
- package/lib/json/index.js.map +0 -1
- package/lib/lenses.d.ts +0 -21
- package/lib/lenses.d.ts.map +0 -1
- package/lib/lenses.js +0 -110
- package/lib/lenses.js.map +0 -1
- package/lib/live/OntologyBackendAdapter.d.ts +0 -100
- package/lib/live/OntologyBackendAdapter.d.ts.map +0 -1
- package/lib/live/OntologyBackendAdapter.js +0 -1
- package/lib/live/actions/createLiveOntologyActions.d.ts +0 -28
- package/lib/live/actions/createLiveOntologyActions.d.ts.map +0 -1
- package/lib/live/actions/createLiveOntologyActions.js +0 -139
- package/lib/live/actions/createLiveOntologyActions.js.map +0 -1
- package/lib/live/actions/prepareActionParameters.d.ts +0 -19
- package/lib/live/actions/prepareActionParameters.d.ts.map +0 -1
- package/lib/live/actions/prepareActionParameters.js +0 -213
- package/lib/live/actions/prepareActionParameters.js.map +0 -1
- package/lib/live/attachments/attachmentSources.d.ts +0 -10
- package/lib/live/attachments/attachmentSources.d.ts.map +0 -1
- package/lib/live/attachments/attachmentSources.js +0 -64
- package/lib/live/attachments/attachmentSources.js.map +0 -1
- package/lib/live/attachments/unsupportedOntologyAttachmentsAdapter.d.ts +0 -5
- package/lib/live/attachments/unsupportedOntologyAttachmentsAdapter.d.ts.map +0 -1
- package/lib/live/attachments/unsupportedOntologyAttachmentsAdapter.js +0 -6
- package/lib/live/attachments/unsupportedOntologyAttachmentsAdapter.js.map +0 -1
- package/lib/live/expression.d.ts +0 -23
- package/lib/live/expression.d.ts.map +0 -1
- package/lib/live/expression.js +0 -160
- package/lib/live/expression.js.map +0 -1
- package/lib/live/mutators/OntologyEdits.d.ts +0 -15
- package/lib/live/mutators/OntologyEdits.d.ts.map +0 -1
- package/lib/live/mutators/OntologyEdits.js +0 -65
- package/lib/live/mutators/OntologyEdits.js.map +0 -1
- package/lib/live/mutators/createMutatorTx.d.ts +0 -11
- package/lib/live/mutators/createMutatorTx.d.ts.map +0 -1
- package/lib/live/mutators/createMutatorTx.js +0 -61
- package/lib/live/mutators/createMutatorTx.js.map +0 -1
- package/lib/live/mutators/runOptimisticAction.d.ts +0 -19
- package/lib/live/mutators/runOptimisticAction.d.ts.map +0 -1
- package/lib/live/mutators/runOptimisticAction.js +0 -30
- package/lib/live/mutators/runOptimisticAction.js.map +0 -1
- package/lib/live/objects/OntologyObject.d.ts +0 -4
- package/lib/live/objects/OntologyObject.d.ts.map +0 -1
- package/lib/live/objects/OntologyObject.js +0 -1
- package/lib/live/objects/createLiveOntologyObjectCollection.d.ts +0 -17
- package/lib/live/objects/createLiveOntologyObjectCollection.d.ts.map +0 -1
- package/lib/live/objects/createLiveOntologyObjectCollection.js +0 -55
- package/lib/live/objects/createLiveOntologyObjectCollection.js.map +0 -1
- package/lib/live/objects/ontologyObjectCollectionId.d.ts +0 -4
- package/lib/live/objects/ontologyObjectCollectionId.d.ts.map +0 -1
- package/lib/live/objects/ontologyObjectCollectionId.js +0 -8
- package/lib/live/objects/ontologyObjectCollectionId.js.map +0 -1
- package/lib/live/outbox/createOntologyOutbox.d.ts +0 -23
- package/lib/live/outbox/createOntologyOutbox.d.ts.map +0 -1
- package/lib/live/outbox/createOntologyOutbox.js +0 -292
- package/lib/live/outbox/createOntologyOutbox.js.map +0 -1
- package/lib/live/outbox/leaderExecutor.d.ts +0 -20
- package/lib/live/outbox/leaderExecutor.d.ts.map +0 -1
- package/lib/live/outbox/leaderExecutor.js +0 -130
- package/lib/live/outbox/leaderExecutor.js.map +0 -1
- package/lib/live/outbox/outboxService.d.ts +0 -7
- package/lib/live/outbox/outboxService.d.ts.map +0 -1
- package/lib/live/outbox/outboxService.js +0 -68
- package/lib/live/outbox/outboxService.js.map +0 -1
- package/lib/live/outbox/projectionManager.d.ts +0 -31
- package/lib/live/outbox/projectionManager.d.ts.map +0 -1
- package/lib/live/outbox/projectionManager.js +0 -127
- package/lib/live/outbox/projectionManager.js.map +0 -1
- package/lib/live/outbox/repository.d.ts +0 -31
- package/lib/live/outbox/repository.d.ts.map +0 -1
- package/lib/live/outbox/repository.js +0 -196
- package/lib/live/outbox/repository.js.map +0 -1
- package/lib/live/outbox/service.d.ts +0 -61
- package/lib/live/outbox/service.d.ts.map +0 -1
- package/lib/live/outbox/service.js +0 -6
- package/lib/live/outbox/service.js.map +0 -1
- package/lib/live/outbox/types.js.map +0 -1
- package/lib/live/waitForCollectionReady.d.ts +0 -5
- package/lib/live/waitForCollectionReady.d.ts.map +0 -1
- package/lib/live/waitForCollectionReady.js +0 -49
- package/lib/live/waitForCollectionReady.js.map +0 -1
- package/lib/meta/createLocalMetaOntologyBackendAdapter.d.ts +0 -7
- package/lib/meta/createLocalMetaOntologyBackendAdapter.d.ts.map +0 -1
- package/lib/meta/createLocalMetaOntologyBackendAdapter.js +0 -44
- package/lib/meta/createLocalMetaOntologyBackendAdapter.js.map +0 -1
- package/lib/meta/generated/constants.d.ts +0 -265
- package/lib/meta/generated/constants.d.ts.map +0 -1
- package/lib/meta/generated/constants.js +0 -165
- package/lib/meta/generated/constants.js.map +0 -1
- package/lib/meta/generated/types.d.ts +0 -417
- package/lib/meta/generated/types.d.ts.map +0 -1
- package/lib/meta/generated/types.js +0 -1
- package/lib/meta/ontology.d.ts +0 -26
- package/lib/meta/ontology.d.ts.map +0 -1
- package/lib/meta/ontology.js +0 -111
- package/lib/meta/ontology.js.map +0 -1
- package/lib/utils/links.d.ts +0 -49
- package/lib/utils/links.d.ts.map +0 -1
- package/lib/utils/links.js +0 -13
- package/lib/utils/links.js.map +0 -1
- package/lib/utils/paths.d.ts +0 -6
- package/lib/utils/paths.d.ts.map +0 -1
- package/lib/utils/paths.js +0 -42
- package/lib/utils/paths.js.map +0 -1
- package/lib/utils/provide.d.ts +0 -4
- package/lib/utils/provide.d.ts.map +0 -1
- package/lib/utils/provide.js +0 -9
- package/lib/utils/provide.js.map +0 -1
- package/lib/utils/targets.d.ts +0 -37
- package/lib/utils/targets.d.ts.map +0 -1
- package/lib/utils/targets.js +0 -1
- package/lib/utils/typeNames.d.ts +0 -28
- package/lib/utils/typeNames.d.ts.map +0 -1
- package/lib/utils/typeNames.js +0 -1
- package/lib/utils/types.d.ts +0 -12
- package/lib/utils/types.d.ts.map +0 -1
- package/lib/utils/types.js +0 -48
- package/lib/utils/types.js.map +0 -1
- package/lib/utils/uncertain.d.ts +0 -11
- package/lib/utils/uncertain.d.ts.map +0 -1
- package/lib/utils/uncertain.js +0 -14
- package/lib/utils/uncertain.js.map +0 -1
- package/lib/utils/validation.d.ts +0 -7
- package/lib/utils/validation.d.ts.map +0 -1
- package/lib/utils/validation.js +0 -1
- package/lib/utils/values.d.ts.map +0 -1
- /package/lib/{installation → live/actions}/types.js +0 -0
- /package/lib/{ir/generated → live/objects}/types.js +0 -0
package/lib/ir/validate.js
DELETED
|
@@ -1,623 +0,0 @@
|
|
|
1
|
-
import { isLinkHopFromForeignKeySource, resolveLinkHop } from "../utils/links.js";
|
|
2
|
-
import { unwrapType } from "../utils/types.js";
|
|
3
|
-
import { ImageMediaTypeOptions } from "./generated/constants.js";
|
|
4
|
-
//#region src/ir/validate.ts
|
|
5
|
-
function validateNonNegativeRange(range, path) {
|
|
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;
|
|
20
|
-
}
|
|
21
|
-
function validateAttachmentConstraints(type) {
|
|
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;
|
|
51
|
-
}
|
|
52
|
-
function validateTypeDef(type, path, valueTypeNames, objectTypeNames) {
|
|
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
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function validateStructFields(fields, path, valueTypeNames, objectTypeNames) {
|
|
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;
|
|
108
|
-
}
|
|
109
|
-
function validateUnionVariants(variants, path, valueTypeNames, objectTypeNames) {
|
|
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;
|
|
123
|
-
}
|
|
124
|
-
function validateProperties(properties, path, valueTypeNames, objectTypeNames) {
|
|
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;
|
|
138
|
-
}
|
|
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]));
|
|
146
|
-
}
|
|
147
|
-
function resolveFieldType(type, path, valueTypes) {
|
|
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
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function resolveExpressionType(expression, parameters, valueTypes, objectTypes, linkTypes, contextType, locals) {
|
|
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
|
-
}
|
|
238
|
-
}
|
|
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
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function unwrapOptionalType(type, valueTypes) {
|
|
324
|
-
const resolved = resolveType(type, valueTypes);
|
|
325
|
-
return resolved?.kind === "optional" ? unwrapOptionalType(resolved.value.type, valueTypes) : resolved;
|
|
326
|
-
}
|
|
327
|
-
function areDefaultTypesCompatible(target, source, valueTypes) {
|
|
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;
|
|
336
|
-
}
|
|
337
|
-
function validateActionObjectReference(reference, parameters, path, valueTypes, objectTypes) {
|
|
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
|
-
}] };
|
|
357
|
-
}
|
|
358
|
-
function validateActionPropertyAssignment(assignment, target, parameters, path, valueTypes, objectTypes, linkTypes, contextType) {
|
|
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
|
-
}];
|
|
375
|
-
}
|
|
376
|
-
function validateAction(action, path, valueTypes, objectTypes, linkTypes, contextType) {
|
|
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;
|
|
455
|
-
}
|
|
456
|
-
function validateQueryFunctionType(queryFunctionType, path, valueTypeNames, objectTypeNames) {
|
|
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;
|
|
475
|
-
}
|
|
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
|
-
};
|
|
619
|
-
}
|
|
620
|
-
//#endregion
|
|
621
|
-
export { validate };
|
|
622
|
-
|
|
623
|
-
//# sourceMappingURL=validate.js.map
|