@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ontology.js","names":[],"sources":["../../src/generate/ontology.ts"],"sourcesContent":["import { Temporal } from \"temporal-polyfill\";\nimport { CodeBlockWriter, Project, type WriterFunction } from \"ts-morph\";\nimport type {\n ActionTypeDef,\n Deprecation,\n Expression,\n FieldDef,\n LinkTypeDef,\n LinkTypeSideDef,\n NamedTypeDef,\n ObjectTypeDef,\n PropertyAssignment,\n PropertyDef,\n QueryFunctionTypeDef,\n StringConstraint,\n TypeDef,\n VariantDef,\n OntologyIR,\n} from \"../ir/generated/types.js\";\n\nexport interface GenerateOntologyOpts {\n ontologyImportPath?: string;\n}\n\nfunction withWriter(fn: WriterFunction): string {\n const writer = new CodeBlockWriter();\n fn(writer);\n return writer.toString();\n}\n\nfunction isIdentifier(value: string): boolean {\n return /^[$A-Z_a-z][$\\w]*$/.test(value);\n}\n\nfunction writePropertyName(writer: CodeBlockWriter, name: string): void {\n writer.write(isIdentifier(name) ? name : JSON.stringify(name));\n}\n\nfunction writeArray(writer: CodeBlockWriter, values: string[]): void {\n if (values.length === 0) {\n writer.write(\"[]\");\n return;\n }\n\n writer.write(\"[\");\n writer.newLine();\n writer.indent(() => {\n for (const value of values) {\n writer.write(value);\n writer.write(\",\");\n writer.newLine();\n }\n });\n writer.write(\"]\");\n}\n\nfunction writeObject(\n writer: CodeBlockWriter,\n entries: Array<{ name: string; value: string | undefined }>\n): void {\n const definedEntries = entries.filter((entry) => entry.value !== undefined);\n if (definedEntries.length === 0) {\n writer.write(\"{}\");\n return;\n }\n\n writer.write(\"{\");\n writer.newLine();\n writer.indent(() => {\n for (const entry of definedEntries) {\n writePropertyName(writer, entry.name);\n writer.write(\": \");\n writer.write(entry.value!);\n writer.write(\",\");\n writer.newLine();\n }\n });\n writer.write(\"}\");\n}\n\nfunction renderObject(entries: Array<{ name: string; value: string | undefined }>): string {\n return withWriter((writer) => writeObject(writer, entries));\n}\n\ninterface RenderContext {\n markTemporalUsed(): void;\n}\n\nfunction renderPlainValue(value: unknown, ctx?: RenderContext): string {\n return withWriter((writer) => writePlainValue(writer, value, ctx));\n}\n\nfunction writePlainValue(writer: CodeBlockWriter, value: unknown, ctx?: RenderContext): void {\n if (value === null) {\n writer.write(\"null\");\n return;\n }\n\n if (value === undefined) {\n writer.write(\"undefined\");\n return;\n }\n\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n writer.write(JSON.stringify(value));\n return;\n }\n\n if (value instanceof Temporal.Instant) {\n ctx?.markTemporalUsed();\n writer.write(`Temporal.Instant.from(${JSON.stringify(value.toString())})`);\n return;\n }\n\n if (value instanceof Temporal.PlainDate) {\n ctx?.markTemporalUsed();\n writer.write(`Temporal.PlainDate.from(${JSON.stringify(value.toString())})`);\n return;\n }\n\n if (Array.isArray(value)) {\n writeArray(\n writer,\n value.map((entry) => renderPlainValue(entry, ctx))\n );\n return;\n }\n\n writeObject(\n writer,\n Object.entries(value).map(([name, entryValue]) => ({\n name,\n value: entryValue === undefined ? undefined : renderPlainValue(entryValue, ctx),\n }))\n );\n}\n\nfunction renderDeprecation(value: Deprecation | undefined): string | undefined {\n return value === undefined ? undefined : renderPlainValue(value);\n}\n\nfunction renderStringConstraint(constraint: StringConstraint): string {\n switch (constraint.kind) {\n case \"enum\":\n return `o.StringConstraint.enum(${renderPlainValue(constraint.value)})`;\n case \"regex\":\n return `o.StringConstraint.regex(${renderPlainValue(constraint.value)})`;\n }\n}\n\nfunction renderType(type: TypeDef): string {\n switch (type.kind) {\n case \"string\":\n return `o.string(${renderObject([\n {\n name: \"constraint\",\n value: type.value.constraint ? renderStringConstraint(type.value.constraint) : undefined,\n },\n {\n name: \"suggestions\",\n value: type.value.suggestions ? renderPlainValue(type.value.suggestions) : undefined,\n },\n ])})`;\n case \"boolean\":\n return `o.boolean(${renderPlainValue(type.value)})`;\n case \"integer\":\n return `o.integer(${renderPlainValue(type.value)})`;\n case \"float\":\n return `o.float(${renderPlainValue(type.value)})`;\n case \"double\":\n return `o.double(${renderPlainValue(type.value)})`;\n case \"date\":\n return `o.date(${renderPlainValue(type.value)})`;\n case \"timestamp\":\n return `o.timestamp(${renderPlainValue(type.value)})`;\n case \"geopoint\":\n return `o.geopoint(${renderPlainValue(type.value)})`;\n case \"attachment\":\n return `o.attachment(${renderPlainValue(type.value)})`;\n case \"objectReference\":\n return `o.objectReference(${renderPlainValue(type.value)})`;\n case \"unknown\":\n return `o.unknown(${renderPlainValue(type.value)})`;\n case \"list\":\n return `o.list(${renderObject([{ name: \"elementType\", value: renderType(type.value.elementType) }])})`;\n case \"map\":\n return `o.map(${renderObject([\n { name: \"keyType\", value: renderType(type.value.keyType) },\n { name: \"valueType\", value: renderType(type.value.valueType) },\n ])})`;\n case \"struct\":\n return `o.struct(${renderObject([\n {\n name: \"fields\",\n value: withWriter((writer) =>\n writeArray(\n writer,\n type.value.fields.map((field) => renderField(field))\n )\n ),\n },\n ])})`;\n case \"union\":\n return `o.union(${renderObject([\n {\n name: \"variants\",\n value: withWriter((writer) =>\n writeArray(\n writer,\n type.value.variants.map((variant) => renderVariant(variant))\n )\n ),\n },\n ])})`;\n case \"optional\":\n return `o.optional(${renderObject([{ name: \"type\", value: renderType(type.value.type) }])})`;\n case \"result\":\n return `o.result(${renderObject([\n { name: \"okType\", value: renderType(type.value.okType) },\n { name: \"errType\", value: renderType(type.value.errType) },\n ])})`;\n case \"ref\":\n return `o.ref(${renderPlainValue(type.value)})`;\n }\n}\n\nfunction renderField(field: FieldDef): string {\n return renderObject([\n { name: \"name\", value: renderPlainValue(field.name) },\n { name: \"displayName\", value: renderPlainValue(field.displayName) },\n { name: \"type\", value: renderType(field.type) },\n { name: \"description\", value: field.description ? renderPlainValue(field.description) : undefined },\n { name: \"deprecated\", value: renderDeprecation(field.deprecated) },\n ]);\n}\n\nfunction renderVariant(variant: VariantDef): string {\n return renderObject([\n { name: \"name\", value: renderPlainValue(variant.name) },\n { name: \"type\", value: renderType(variant.type) },\n ]);\n}\n\nfunction renderNamedType(type: NamedTypeDef): string {\n return renderObject([\n { name: \"name\", value: renderPlainValue(type.name) },\n { name: \"description\", value: type.description ? renderPlainValue(type.description) : undefined },\n { name: \"deprecated\", value: renderDeprecation(type.deprecated) },\n { name: \"type\", value: renderType(type.type) },\n ]);\n}\n\nfunction renderProperty(property: PropertyDef): string {\n return renderObject([\n { name: \"name\", value: renderPlainValue(property.name) },\n { name: \"displayName\", value: renderPlainValue(property.displayName) },\n { name: \"type\", value: renderType(property.type) },\n {\n name: \"description\",\n value: property.description ? renderPlainValue(property.description) : undefined,\n },\n { name: \"deprecated\", value: renderDeprecation(property.deprecated) },\n ]);\n}\n\nfunction renderObjectType(objectType: ObjectTypeDef): string {\n return renderObject([\n { name: \"name\", value: renderPlainValue(objectType.name) },\n { name: \"displayName\", value: renderPlainValue(objectType.displayName) },\n { name: \"pluralDisplayName\", value: renderPlainValue(objectType.pluralDisplayName) },\n { name: \"primaryKey\", value: renderPlainValue(objectType.primaryKey) },\n {\n name: \"title\",\n value: objectType.title ? renderPlainValue(objectType.title) : undefined,\n },\n {\n name: \"icon\",\n value: objectType.icon ? renderPlainValue(objectType.icon) : undefined,\n },\n {\n name: \"color\",\n value: objectType.color ? renderPlainValue(objectType.color) : undefined,\n },\n {\n name: \"properties\",\n value: withWriter((writer) =>\n writeArray(\n writer,\n objectType.properties.map((property) => renderProperty(property))\n )\n ),\n },\n {\n name: \"description\",\n value: objectType.description ? renderPlainValue(objectType.description) : undefined,\n },\n { name: \"deprecated\", value: renderDeprecation(objectType.deprecated) },\n ]);\n}\n\nfunction renderLinkTypeSide(side: LinkTypeSideDef): string {\n return renderObject([\n { name: \"objectType\", value: renderPlainValue(side.objectType) },\n { name: \"name\", value: renderPlainValue(side.name) },\n { name: \"displayName\", value: renderPlainValue(side.displayName) },\n ]);\n}\n\nfunction renderLinkType(linkType: LinkTypeDef): string {\n return renderObject([\n { name: \"id\", value: renderPlainValue(linkType.id) },\n { name: \"source\", value: renderLinkTypeSide(linkType.source) },\n { name: \"target\", value: renderLinkTypeSide(linkType.target) },\n { name: \"foreignKey\", value: renderPlainValue(linkType.foreignKey) },\n { name: \"cardinality\", value: renderPlainValue(linkType.cardinality) },\n ]);\n}\n\nfunction renderExpression(expression: Expression, ctx?: RenderContext): string {\n return `o.Expression.${expression.kind}(${renderPlainValue(expression.value, ctx)})`;\n}\n\nfunction renderActionPropertyAssignment(assignment: PropertyAssignment, ctx?: RenderContext): string {\n return renderObject([\n { name: \"property\", value: renderPlainValue(assignment.property) },\n { name: \"value\", value: renderExpression(assignment.value, ctx) },\n ]);\n}\n\nfunction renderActionType(actionType: ActionTypeDef, ctx?: RenderContext): string {\n return renderObject([\n { name: \"meta\", value: actionType.meta ? renderPlainValue(actionType.meta) : undefined },\n { name: \"name\", value: renderPlainValue(actionType.name) },\n { name: \"displayName\", value: renderPlainValue(actionType.displayName) },\n { name: \"icon\", value: actionType.icon ? renderPlainValue(actionType.icon) : undefined },\n {\n name: \"color\",\n value: actionType.color ? renderPlainValue(actionType.color) : undefined,\n },\n {\n name: \"parameters\",\n value: withWriter((writer) =>\n writeArray(\n writer,\n actionType.parameters.map((parameter) =>\n renderObject([\n { name: \"name\", value: renderPlainValue(parameter.name) },\n { name: \"displayName\", value: renderPlainValue(parameter.displayName) },\n { name: \"type\", value: renderType(parameter.type) },\n {\n name: \"description\",\n value: parameter.description\n ? renderPlainValue(parameter.description)\n : undefined,\n },\n { name: \"deprecated\", value: renderDeprecation(parameter.deprecated) },\n {\n name: \"defaultValue\",\n value: parameter.defaultValue\n ? renderExpression(parameter.defaultValue, ctx)\n : undefined,\n },\n ])\n )\n )\n ),\n },\n {\n name: \"logic\",\n value: withWriter((writer) =>\n writeArray(\n writer,\n actionType.logic.map(\n (step) =>\n `o.ActionLogicStep.${step.kind}(${renderObject([\n {\n name: \"objectType\",\n value:\n \"objectType\" in step.value\n ? renderPlainValue(step.value.objectType)\n : undefined,\n },\n {\n name: \"object\",\n value:\n \"object\" in step.value\n ? renderPlainValue(step.value.object)\n : undefined,\n },\n {\n name: \"values\",\n value:\n \"values\" in step.value\n ? withWriter((arrayWriter) =>\n writeArray(\n arrayWriter,\n (\"values\" in step.value ? step.value.values : []).map(\n (value) =>\n renderActionPropertyAssignment(value, ctx)\n )\n )\n )\n : undefined,\n },\n ])})`\n )\n )\n ),\n },\n {\n name: \"description\",\n value: actionType.description ? renderPlainValue(actionType.description) : undefined,\n },\n { name: \"deprecated\", value: renderDeprecation(actionType.deprecated) },\n ]);\n}\n\nfunction renderQueryFunctionType(queryFunctionType: QueryFunctionTypeDef): string {\n return renderObject([\n { name: \"name\", value: renderPlainValue(queryFunctionType.name) },\n { name: \"displayName\", value: renderPlainValue(queryFunctionType.displayName) },\n {\n name: \"parameters\",\n value: withWriter((writer) =>\n writeArray(\n writer,\n queryFunctionType.parameters.map((parameter) =>\n renderObject([\n { name: \"name\", value: renderPlainValue(parameter.name) },\n { name: \"displayName\", value: renderPlainValue(parameter.displayName) },\n { name: \"type\", value: renderType(parameter.type) },\n {\n name: \"description\",\n value: parameter.description\n ? renderPlainValue(parameter.description)\n : undefined,\n },\n { name: \"deprecated\", value: renderDeprecation(parameter.deprecated) },\n ])\n )\n )\n ),\n },\n { name: \"returnType\", value: renderType(queryFunctionType.returnType) },\n {\n name: \"description\",\n value: queryFunctionType.description\n ? renderPlainValue(queryFunctionType.description)\n : undefined,\n },\n { name: \"deprecated\", value: renderDeprecation(queryFunctionType.deprecated) },\n ]);\n}\n\nexport function generateOntology(ir: OntologyIR, opts: GenerateOntologyOpts = {}): string {\n const ontologyImportPath = opts.ontologyImportPath ?? \"@party-stack/ontology\";\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\"ontology.ts\", \"\");\n\n let usesTemporalTypes = false;\n const ctx: RenderContext = {\n markTemporalUsed() {\n usesTemporalTypes = true;\n },\n };\n\n const renderedActionTypes = ir.actionTypes.map((actionType) => renderActionType(actionType, ctx));\n\n sourceFile.addImportDeclaration({\n moduleSpecifier: ontologyImportPath,\n namedImports: [\"defineOntology\", \"o\"],\n });\n if (usesTemporalTypes) {\n sourceFile.addImportDeclaration({\n moduleSpecifier: \"temporal-polyfill\",\n namedImports: [\"Temporal\"],\n });\n }\n\n sourceFile.addStatements((writer) => {\n writer.write(\"export default defineOntology(\");\n writeObject(writer, [\n {\n name: \"types\",\n value: withWriter((arrayWriter) =>\n writeArray(\n arrayWriter,\n ir.types.map((type) => renderNamedType(type))\n )\n ),\n },\n {\n name: \"objectTypes\",\n value: withWriter((arrayWriter) =>\n writeArray(\n arrayWriter,\n ir.objectTypes.map((objectType) => renderObjectType(objectType))\n )\n ),\n },\n {\n name: \"linkTypes\",\n value: withWriter((arrayWriter) =>\n writeArray(\n arrayWriter,\n ir.linkTypes.map((linkType) => renderLinkType(linkType))\n )\n ),\n },\n {\n name: \"actionTypes\",\n value: withWriter((arrayWriter) => writeArray(arrayWriter, renderedActionTypes)),\n },\n {\n name: \"queryFunctionTypes\",\n value: withWriter((arrayWriter) =>\n writeArray(\n arrayWriter,\n ir.queryFunctionTypes.map((queryFunctionType) =>\n renderQueryFunctionType(queryFunctionType)\n )\n )\n ),\n },\n ...(ir.contextType\n ? [\n {\n name: \"contextType\",\n value: renderType(ir.contextType),\n },\n ]\n : []),\n ]);\n writer.write(\");\");\n writer.newLine();\n });\n\n return sourceFile.getFullText().trim();\n}\n"],"mappings":";;;AAwBA,SAAS,WAAW,IAA4B;CAC5C,MAAM,SAAS,IAAI,gBAAgB;CACnC,GAAG,MAAM;CACT,OAAO,OAAO,SAAS;AAC3B;AAEA,SAAS,aAAa,OAAwB;CAC1C,OAAO,qBAAqB,KAAK,KAAK;AAC1C;AAEA,SAAS,kBAAkB,QAAyB,MAAoB;CACpE,OAAO,MAAM,aAAa,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI,CAAC;AACjE;AAEA,SAAS,WAAW,QAAyB,QAAwB;CACjE,IAAI,OAAO,WAAW,GAAG;EACrB,OAAO,MAAM,IAAI;EACjB;CACJ;CAEA,OAAO,MAAM,GAAG;CAChB,OAAO,QAAQ;CACf,OAAO,aAAa;EAChB,KAAK,MAAM,SAAS,QAAQ;GACxB,OAAO,MAAM,KAAK;GAClB,OAAO,MAAM,GAAG;GAChB,OAAO,QAAQ;EACnB;CACJ,CAAC;CACD,OAAO,MAAM,GAAG;AACpB;AAEA,SAAS,YACL,QACA,SACI;CACJ,MAAM,iBAAiB,QAAQ,QAAQ,UAAU,MAAM,UAAU,KAAA,CAAS;CAC1E,IAAI,eAAe,WAAW,GAAG;EAC7B,OAAO,MAAM,IAAI;EACjB;CACJ;CAEA,OAAO,MAAM,GAAG;CAChB,OAAO,QAAQ;CACf,OAAO,aAAa;EAChB,KAAK,MAAM,SAAS,gBAAgB;GAChC,kBAAkB,QAAQ,MAAM,IAAI;GACpC,OAAO,MAAM,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from "../ir/generated/types.js";
|
|
2
|
-
//#region src/generate/types.d.ts
|
|
3
|
-
export interface GenerateTypeDefinitionsOpts {
|
|
4
|
-
valuesImportPath?: string;
|
|
5
|
-
objectTypes?: ReadonlyMap<string, ObjectTypeDef>;
|
|
6
|
-
}
|
|
7
|
-
interface GenerateTypeContext {
|
|
8
|
-
objectTypes?: ReadonlyMap<string, ObjectTypeDef>;
|
|
9
|
-
}
|
|
10
|
-
export declare function generateForTypeDef(type: TypeDef, ctx?: GenerateTypeContext): string;
|
|
11
|
-
export declare function generateTypeDefinitions(schema: Pick<OntologyIR, "types">, opts?: GenerateTypeDefinitionsOpts): string;
|
|
12
|
-
export interface GenerateTypesOpts {
|
|
13
|
-
outputTypeName?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function generateTypes(ir: OntologyIR, opts?: GenerateTypesOpts): string;
|
|
16
|
-
//#endregion
|
|
17
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/generate/types.ts"],"mappings":";;iBAiCiB;EACb;EACA,cAAc,oBAAoB;;UAG5B;EACN,cAAc,oBAAoB;;wBAGtB,mBAAmB,MAAM,SAAS,MAAK;wBAyIvC,wBACZ,QAAQ,KAAK,sBACb,OAAM;iBA2BO;EACb;;wBA0JY,cAAc,IAAI,YAAY,OAAM"}
|
package/lib/generate/types.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { unwrapType } from "../utils/types.js";
|
|
2
|
-
import { ImageMediaTypeOptions } from "../ir/generated/constants.js";
|
|
3
|
-
import { buildJsDocs } from "./utils/buildJsDocs.js";
|
|
4
|
-
import { pascalCase } from "change-case";
|
|
5
|
-
import { CodeBlockWriter, Project, Writers } from "ts-morph";
|
|
6
|
-
//#region src/generate/types.ts
|
|
7
|
-
function withWriter(fn) {
|
|
8
|
-
const writer = new CodeBlockWriter();
|
|
9
|
-
fn(writer);
|
|
10
|
-
return writer.toString();
|
|
11
|
-
}
|
|
12
|
-
function union(options) {
|
|
13
|
-
if (options.length === 0) return "never";
|
|
14
|
-
if (options.length === 1) return options[0];
|
|
15
|
-
return withWriter(Writers.unionType(options[0], options[1], ...options.slice(2)));
|
|
16
|
-
}
|
|
17
|
-
function renderPropertyName(name) {
|
|
18
|
-
return /^[$A-Z_][0-9A-Z_$]*$/i.test(name) ? name : JSON.stringify(name);
|
|
19
|
-
}
|
|
20
|
-
function generateForTypeDef(type, ctx = {}) {
|
|
21
|
-
switch (type.kind) {
|
|
22
|
-
case "string":
|
|
23
|
-
if (type.value.constraint?.kind === "enum") {
|
|
24
|
-
const options = type.value.constraint.value.options;
|
|
25
|
-
return union(options.map((option) => `"${option.value}"`));
|
|
26
|
-
}
|
|
27
|
-
return "string";
|
|
28
|
-
case "boolean": return "boolean";
|
|
29
|
-
case "integer": return "v.integer";
|
|
30
|
-
case "float": return "v.float";
|
|
31
|
-
case "double": return "v.double";
|
|
32
|
-
case "date": return "v.date";
|
|
33
|
-
case "timestamp": return "v.timestamp";
|
|
34
|
-
case "geopoint": return "v.geopoint";
|
|
35
|
-
case "attachment": {
|
|
36
|
-
const content = type.value.constraint?.content;
|
|
37
|
-
if (content?.kind !== "image") return "v.attachment";
|
|
38
|
-
const mediaTypes = content.value.mediaTypes;
|
|
39
|
-
return mediaTypes ? `v.attachment<${union(mediaTypes.map((mediaType) => JSON.stringify(mediaType)))}>` : `v.attachment<${union(ImageMediaTypeOptions.map((option) => JSON.stringify(option.value)))}>`;
|
|
40
|
-
}
|
|
41
|
-
case "objectReference": {
|
|
42
|
-
const objectType = ctx.objectTypes?.get(type.value.objectType);
|
|
43
|
-
if (!objectType) throw new Error(`Cannot generate object reference type for unknown object type "${type.value.objectType}".`);
|
|
44
|
-
const primaryKey = objectType?.properties.find((property) => property.name === objectType.primaryKey);
|
|
45
|
-
if (!primaryKey) throw new Error(`Cannot generate object reference type for "${type.value.objectType}" because primary key "${objectType.primaryKey}" is not a property.`);
|
|
46
|
-
return generateForTypeDef(primaryKey.type, ctx);
|
|
47
|
-
}
|
|
48
|
-
case "unknown": return "unknown";
|
|
49
|
-
case "list": return `Array<${generateForTypeDef(type.value.elementType, ctx)}>`;
|
|
50
|
-
case "map": return `Record<string, ${generateForTypeDef(type.value.valueType, ctx)}>`;
|
|
51
|
-
case "struct": return generateForStructTypeDef(type.value, ctx);
|
|
52
|
-
case "union": return generateForUnionTypeDef(type.value, ctx);
|
|
53
|
-
case "optional": return union([generateForTypeDef(type.value.type, ctx), "undefined"]);
|
|
54
|
-
case "result": return `v.Result<${generateForTypeDef(type.value.okType, ctx)}, ${generateForTypeDef(type.value.errType, ctx)}>`;
|
|
55
|
-
case "ref": return type.value.name;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function generateForStructTypeDef(type, ctx) {
|
|
59
|
-
if (type.fields.length === 0) return "Record<never, never>";
|
|
60
|
-
return withWriter(Writers.objectType({ properties: type.fields.map((field) => {
|
|
61
|
-
const { type: fieldType, isOptional } = unwrapType(field.type);
|
|
62
|
-
return {
|
|
63
|
-
name: renderPropertyName(field.name),
|
|
64
|
-
type: generateForTypeDef(fieldType, ctx),
|
|
65
|
-
hasQuestionToken: isOptional,
|
|
66
|
-
docs: buildJsDocs({
|
|
67
|
-
description: field.description,
|
|
68
|
-
deprecated: field.deprecated
|
|
69
|
-
})
|
|
70
|
-
};
|
|
71
|
-
}) }));
|
|
72
|
-
}
|
|
73
|
-
function generateForUnionTypeDef(type, ctx) {
|
|
74
|
-
return `v.Union<${withWriter(Writers.objectType({ properties: type.variants.map((variant) => ({
|
|
75
|
-
name: renderPropertyName(variant.name),
|
|
76
|
-
type: generateForTypeDef(variant.type, ctx)
|
|
77
|
-
})) }))}>`;
|
|
78
|
-
}
|
|
79
|
-
function collectTypeDefinitions(ir) {
|
|
80
|
-
return { types: [...ir.types, ...ir.objectTypes.map((objectType) => ({
|
|
81
|
-
name: objectType.name,
|
|
82
|
-
description: objectType.description,
|
|
83
|
-
deprecated: objectType.deprecated,
|
|
84
|
-
type: {
|
|
85
|
-
kind: "struct",
|
|
86
|
-
value: { fields: objectType.properties }
|
|
87
|
-
}
|
|
88
|
-
}))] };
|
|
89
|
-
}
|
|
90
|
-
function generateTypeDefinitions(schema, opts = {}) {
|
|
91
|
-
const sourceFile = new Project({ useInMemoryFileSystem: true }).createSourceFile("types.ts", "");
|
|
92
|
-
sourceFile.addImportDeclaration({
|
|
93
|
-
moduleSpecifier: opts.valuesImportPath ?? "@party-stack/ontology/values",
|
|
94
|
-
namespaceImport: "v"
|
|
95
|
-
});
|
|
96
|
-
for (const type of schema.types) sourceFile.addTypeAlias({
|
|
97
|
-
name: type.name,
|
|
98
|
-
isExported: true,
|
|
99
|
-
type: generateForTypeDef(type.type, { objectTypes: opts.objectTypes }),
|
|
100
|
-
docs: buildJsDocs({
|
|
101
|
-
description: type.description,
|
|
102
|
-
deprecated: type.deprecated
|
|
103
|
-
})
|
|
104
|
-
});
|
|
105
|
-
const typeAliases = sourceFile.getTypeAliases();
|
|
106
|
-
for (const alias of typeAliases.slice(0, -1)) alias.appendWhitespace("\n");
|
|
107
|
-
return sourceFile.getFullText().trim();
|
|
108
|
-
}
|
|
109
|
-
function addOntologyAggregateType(sourceFile, ir, outputTypeName) {
|
|
110
|
-
const properties = [{
|
|
111
|
-
name: "context",
|
|
112
|
-
type: `${outputTypeName}Context`
|
|
113
|
-
}, {
|
|
114
|
-
name: "objectTypes",
|
|
115
|
-
type: ir.objectTypes.length === 0 ? "Record<never, never>" : Writers.objectType({ properties: ir.objectTypes.map((objectType) => ({
|
|
116
|
-
name: renderPropertyName(objectType.name),
|
|
117
|
-
type: objectType.name
|
|
118
|
-
})) })
|
|
119
|
-
}];
|
|
120
|
-
properties.push({
|
|
121
|
-
name: "actionTypes",
|
|
122
|
-
type: ir.actionTypes.length === 0 ? "Record<never, never>" : Writers.objectType({ properties: ir.actionTypes.map((action) => ({
|
|
123
|
-
name: renderPropertyName(action.name),
|
|
124
|
-
type: Writers.objectType({ properties: [{
|
|
125
|
-
name: "parameters",
|
|
126
|
-
type: `${pascalCase(action.name)}Parameters`
|
|
127
|
-
}] })
|
|
128
|
-
})) })
|
|
129
|
-
});
|
|
130
|
-
properties.push({
|
|
131
|
-
name: "queryFunctionTypes",
|
|
132
|
-
type: ir.queryFunctionTypes.length === 0 ? "Record<never, never>" : Writers.objectType({ properties: ir.queryFunctionTypes.map((queryFunctionType) => ({
|
|
133
|
-
name: renderPropertyName(queryFunctionType.name),
|
|
134
|
-
type: Writers.objectType({ properties: [{
|
|
135
|
-
name: "parameters",
|
|
136
|
-
type: `${pascalCase(queryFunctionType.name)}Parameters`
|
|
137
|
-
}, {
|
|
138
|
-
name: "returnType",
|
|
139
|
-
type: `${pascalCase(queryFunctionType.name)}Return`
|
|
140
|
-
}] })
|
|
141
|
-
})) })
|
|
142
|
-
});
|
|
143
|
-
sourceFile.addTypeAlias({
|
|
144
|
-
name: outputTypeName,
|
|
145
|
-
isExported: true,
|
|
146
|
-
type: Writers.objectType({ properties })
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function addOntologyContextType(sourceFile, ir, outputTypeName) {
|
|
150
|
-
const objectTypes = new Map(ir.objectTypes.map((objectType) => [objectType.name, objectType]));
|
|
151
|
-
sourceFile.addTypeAlias({
|
|
152
|
-
name: `${outputTypeName}Context`,
|
|
153
|
-
isExported: true,
|
|
154
|
-
type: ir.contextType ? `${generateForTypeDef(ir.contextType, { objectTypes })} & Record<string, unknown>` : "Record<string, unknown>"
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
function addActionParameterTypes(sourceFile, ir) {
|
|
158
|
-
const objectTypes = new Map(ir.objectTypes.map((objectType) => [objectType.name, objectType]));
|
|
159
|
-
for (const actionType of ir.actionTypes) sourceFile.addTypeAlias({
|
|
160
|
-
name: `${pascalCase(actionType.name)}Parameters`,
|
|
161
|
-
isExported: true,
|
|
162
|
-
type: withWriter(Writers.objectType({ properties: actionType.parameters.map((parameter) => {
|
|
163
|
-
const parameterType = parameter.type;
|
|
164
|
-
const isOptional = parameterType.kind === "optional";
|
|
165
|
-
const renderedType = generateForTypeDef(isOptional ? parameterType.value.type : parameterType, { objectTypes });
|
|
166
|
-
return {
|
|
167
|
-
name: renderPropertyName(parameter.name),
|
|
168
|
-
type: isOptional ? union([renderedType, "null"]) : renderedType,
|
|
169
|
-
hasQuestionToken: isOptional || parameter.defaultValue !== void 0
|
|
170
|
-
};
|
|
171
|
-
}) }))
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
function addQueryParameterTypes(sourceFile, ir) {
|
|
175
|
-
const objectTypes = new Map(ir.objectTypes.map((objectType) => [objectType.name, objectType]));
|
|
176
|
-
for (const queryFunctionType of ir.queryFunctionTypes) {
|
|
177
|
-
sourceFile.addTypeAlias({
|
|
178
|
-
name: `${pascalCase(queryFunctionType.name)}Parameters`,
|
|
179
|
-
isExported: true,
|
|
180
|
-
type: withWriter(Writers.objectType({ properties: queryFunctionType.parameters.map((parameter) => {
|
|
181
|
-
const parameterType = parameter.type;
|
|
182
|
-
const isOptional = parameterType.kind === "optional";
|
|
183
|
-
const renderedType = generateForTypeDef(isOptional ? parameterType.value.type : parameterType, { objectTypes });
|
|
184
|
-
return {
|
|
185
|
-
name: renderPropertyName(parameter.name),
|
|
186
|
-
type: isOptional ? union([renderedType, "undefined"]) : renderedType,
|
|
187
|
-
hasQuestionToken: isOptional
|
|
188
|
-
};
|
|
189
|
-
}) }))
|
|
190
|
-
});
|
|
191
|
-
sourceFile.addTypeAlias({
|
|
192
|
-
name: `${pascalCase(queryFunctionType.name)}Return`,
|
|
193
|
-
isExported: true,
|
|
194
|
-
type: generateForTypeDef(queryFunctionType.returnType, { objectTypes }),
|
|
195
|
-
docs: buildJsDocs({
|
|
196
|
-
description: queryFunctionType.description,
|
|
197
|
-
deprecated: queryFunctionType.deprecated
|
|
198
|
-
})
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function generateTypes(ir, opts = {}) {
|
|
203
|
-
const outputTypeName = opts.outputTypeName ?? "GeneratedOntology";
|
|
204
|
-
const objectTypes = new Map(ir.objectTypes.map((objectType) => [objectType.name, objectType]));
|
|
205
|
-
const typeDefinitions = generateTypeDefinitions(collectTypeDefinitions(ir), { objectTypes });
|
|
206
|
-
const aggregateFile = new Project({ useInMemoryFileSystem: true }).createSourceFile("ontology-aggregate.ts", "");
|
|
207
|
-
addOntologyContextType(aggregateFile, ir, outputTypeName);
|
|
208
|
-
addActionParameterTypes(aggregateFile, ir);
|
|
209
|
-
addQueryParameterTypes(aggregateFile, ir);
|
|
210
|
-
addOntologyAggregateType(aggregateFile, ir, outputTypeName);
|
|
211
|
-
return `${typeDefinitions}\n\n${aggregateFile.getFullText().trim()}`.trim();
|
|
212
|
-
}
|
|
213
|
-
//#endregion
|
|
214
|
-
export { generateForTypeDef, generateTypeDefinitions, generateTypes };
|
|
215
|
-
|
|
216
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/generate/types.ts"],"sourcesContent":["import { pascalCase } from \"change-case\";\nimport { CodeBlockWriter, Project, Writers, type WriterFunction } from \"ts-morph\";\nimport { ImageMediaTypeOptions } from \"../ir/generated/constants.js\";\nimport { unwrapType } from \"../utils/types.js\";\nimport { buildJsDocs } from \"./utils/buildJsDocs.js\";\nimport type {\n OntologyIR,\n ObjectTypeDef,\n StructTypeDef,\n TypeDef,\n UnionTypeDef,\n} from \"../ir/generated/types.js\";\n\nfunction withWriter(fn: WriterFunction): string {\n const writer = new CodeBlockWriter();\n fn(writer);\n return writer.toString();\n}\n\nfunction union(options: string[]): string {\n if (options.length === 0) {\n return \"never\";\n }\n if (options.length === 1) {\n return options[0]!;\n }\n return withWriter(Writers.unionType(options[0]!, options[1]!, ...options.slice(2)));\n}\n\nfunction renderPropertyName(name: string): string {\n return /^[$A-Z_][0-9A-Z_$]*$/i.test(name) ? name : JSON.stringify(name);\n}\n\nexport interface GenerateTypeDefinitionsOpts {\n valuesImportPath?: string;\n objectTypes?: ReadonlyMap<string, ObjectTypeDef>;\n}\n\ninterface GenerateTypeContext {\n objectTypes?: ReadonlyMap<string, ObjectTypeDef>;\n}\n\nexport function generateForTypeDef(type: TypeDef, ctx: GenerateTypeContext = {}): string {\n switch (type.kind) {\n case \"string\": {\n if (type.value.constraint?.kind === \"enum\") {\n const options = type.value.constraint.value.options;\n return union(options.map((option) => `\"${option.value}\"`));\n }\n return \"string\";\n }\n\n case \"boolean\":\n return \"boolean\";\n\n case \"integer\":\n return \"v.integer\";\n\n case \"float\":\n return \"v.float\";\n\n case \"double\":\n return \"v.double\";\n\n case \"date\":\n return \"v.date\";\n\n case \"timestamp\":\n return \"v.timestamp\";\n\n case \"geopoint\":\n return \"v.geopoint\";\n\n case \"attachment\": {\n const content = type.value.constraint?.content;\n if (content?.kind !== \"image\") return \"v.attachment\";\n const mediaTypes = content.value.mediaTypes;\n return mediaTypes\n ? `v.attachment<${union(mediaTypes.map((mediaType) => JSON.stringify(mediaType)))}>`\n : `v.attachment<${union(\n ImageMediaTypeOptions.map((option) => JSON.stringify(option.value))\n )}>`;\n }\n\n case \"objectReference\": {\n const objectType = ctx.objectTypes?.get(type.value.objectType);\n if (!objectType) {\n throw new Error(\n `Cannot generate object reference type for unknown object type \"${type.value.objectType}\".`\n );\n }\n const primaryKey = objectType?.properties.find(\n (property) => property.name === objectType.primaryKey\n );\n if (!primaryKey) {\n throw new Error(\n `Cannot generate object reference type for \"${type.value.objectType}\" because primary key \"${objectType.primaryKey}\" is not a property.`\n );\n }\n return generateForTypeDef(primaryKey.type, ctx);\n }\n\n case \"unknown\":\n return \"unknown\";\n\n case \"list\":\n return `Array<${generateForTypeDef(type.value.elementType, ctx)}>`;\n\n case \"map\":\n return `Record<string, ${generateForTypeDef(type.value.valueType, ctx)}>`;\n\n case \"struct\":\n return generateForStructTypeDef(type.value, ctx);\n\n case \"union\":\n return generateForUnionTypeDef(type.value, ctx);\n\n case \"optional\":\n return union([generateForTypeDef(type.value.type, ctx), \"undefined\"]);\n\n case \"result\":\n return `v.Result<${generateForTypeDef(type.value.okType, ctx)}, ${generateForTypeDef(type.value.errType, ctx)}>`;\n\n case \"ref\":\n return type.value.name;\n }\n}\n\nfunction generateForStructTypeDef(type: StructTypeDef, ctx: GenerateTypeContext): string {\n if (type.fields.length === 0) {\n return \"Record<never, never>\";\n }\n\n return withWriter(\n Writers.objectType({\n properties: type.fields.map((field) => {\n const { type: fieldType, isOptional } = unwrapType(field.type);\n return {\n name: renderPropertyName(field.name),\n type: generateForTypeDef(fieldType, ctx),\n hasQuestionToken: isOptional,\n docs: buildJsDocs({ description: field.description, deprecated: field.deprecated }),\n };\n }),\n })\n );\n}\n\nfunction generateForUnionTypeDef(type: UnionTypeDef, ctx: GenerateTypeContext): string {\n const innerType = withWriter(\n Writers.objectType({\n properties: type.variants.map((variant) => ({\n name: renderPropertyName(variant.name),\n type: generateForTypeDef(variant.type, ctx),\n })),\n })\n );\n return `v.Union<${innerType}>`;\n}\n\nfunction collectTypeDefinitions(ir: OntologyIR): Pick<OntologyIR, \"types\"> {\n return {\n types: [\n ...ir.types,\n ...ir.objectTypes.map((objectType) => ({\n name: objectType.name,\n description: objectType.description,\n deprecated: objectType.deprecated,\n type: {\n kind: \"struct\" as const,\n value: {\n fields: objectType.properties,\n },\n },\n })),\n ],\n };\n}\n\nexport function generateTypeDefinitions(\n schema: Pick<OntologyIR, \"types\">,\n opts: GenerateTypeDefinitionsOpts = {}\n): string {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\"types.ts\", \"\");\n\n sourceFile.addImportDeclaration({\n moduleSpecifier: opts.valuesImportPath ?? \"@party-stack/ontology/values\",\n namespaceImport: \"v\",\n });\n\n for (const type of schema.types) {\n sourceFile.addTypeAlias({\n name: type.name,\n isExported: true,\n type: generateForTypeDef(type.type, { objectTypes: opts.objectTypes }),\n docs: buildJsDocs({ description: type.description, deprecated: type.deprecated }),\n });\n }\n\n const typeAliases = sourceFile.getTypeAliases();\n for (const alias of typeAliases.slice(0, -1)) {\n alias.appendWhitespace(\"\\n\");\n }\n\n return sourceFile.getFullText().trim();\n}\n\nexport interface GenerateTypesOpts {\n outputTypeName?: string;\n}\n\nfunction addOntologyAggregateType(\n sourceFile: import(\"ts-morph\").SourceFile,\n ir: OntologyIR,\n outputTypeName: string\n): void {\n const properties = [\n {\n name: \"context\",\n type: `${outputTypeName}Context`,\n },\n {\n name: \"objectTypes\",\n type:\n ir.objectTypes.length === 0\n ? \"Record<never, never>\"\n : Writers.objectType({\n properties: ir.objectTypes.map((objectType) => ({\n name: renderPropertyName(objectType.name),\n type: objectType.name,\n })),\n }),\n },\n ];\n\n properties.push({\n name: \"actionTypes\",\n type:\n ir.actionTypes.length === 0\n ? \"Record<never, never>\"\n : Writers.objectType({\n properties: ir.actionTypes.map((action) => ({\n name: renderPropertyName(action.name),\n type: Writers.objectType({\n properties: [\n {\n name: \"parameters\",\n type: `${pascalCase(action.name)}Parameters`,\n },\n ],\n }),\n })),\n }),\n });\n\n properties.push({\n name: \"queryFunctionTypes\",\n type:\n ir.queryFunctionTypes.length === 0\n ? \"Record<never, never>\"\n : Writers.objectType({\n properties: ir.queryFunctionTypes.map((queryFunctionType) => ({\n name: renderPropertyName(queryFunctionType.name),\n type: Writers.objectType({\n properties: [\n {\n name: \"parameters\",\n type: `${pascalCase(queryFunctionType.name)}Parameters`,\n },\n {\n name: \"returnType\",\n type: `${pascalCase(queryFunctionType.name)}Return`,\n },\n ],\n }),\n })),\n }),\n });\n\n sourceFile.addTypeAlias({\n name: outputTypeName,\n isExported: true,\n type: Writers.objectType({ properties }),\n });\n}\n\nfunction addOntologyContextType(\n sourceFile: import(\"ts-morph\").SourceFile,\n ir: OntologyIR,\n outputTypeName: string\n): void {\n const objectTypes = new Map(ir.objectTypes.map((objectType) => [objectType.name, objectType]));\n sourceFile.addTypeAlias({\n name: `${outputTypeName}Context`,\n isExported: true,\n type: ir.contextType\n ? `${generateForTypeDef(ir.contextType, {\n objectTypes,\n })} & Record<string, unknown>`\n : \"Record<string, unknown>\",\n });\n}\n\nfunction addActionParameterTypes(sourceFile: import(\"ts-morph\").SourceFile, ir: OntologyIR): void {\n const objectTypes = new Map(ir.objectTypes.map((objectType) => [objectType.name, objectType]));\n for (const actionType of ir.actionTypes) {\n sourceFile.addTypeAlias({\n name: `${pascalCase(actionType.name)}Parameters`,\n isExported: true,\n type: withWriter(\n Writers.objectType({\n properties: actionType.parameters.map((parameter) => {\n const parameterType = parameter.type;\n const isOptional = parameterType.kind === \"optional\";\n const type = isOptional ? parameterType.value.type : parameterType;\n const renderedType = generateForTypeDef(type, { objectTypes });\n return {\n name: renderPropertyName(parameter.name),\n type: isOptional ? union([renderedType, \"null\"]) : renderedType,\n hasQuestionToken: isOptional || parameter.defaultValue !== undefined,\n };\n }),\n })\n ),\n });\n }\n}\n\nfunction addQueryParameterTypes(sourceFile: import(\"ts-morph\").SourceFile, ir: OntologyIR): void {\n const objectTypes = new Map(ir.objectTypes.map((objectType) => [objectType.name, objectType]));\n for (const queryFunctionType of ir.queryFunctionTypes) {\n sourceFile.addTypeAlias({\n name: `${pascalCase(queryFunctionType.name)}Parameters`,\n isExported: true,\n type: withWriter(\n Writers.objectType({\n properties: queryFunctionType.parameters.map((parameter) => {\n const parameterType = parameter.type;\n const isOptional = parameterType.kind === \"optional\";\n const type = isOptional ? parameterType.value.type : parameterType;\n const renderedType = generateForTypeDef(type, { objectTypes });\n return {\n name: renderPropertyName(parameter.name),\n type: isOptional ? union([renderedType, \"undefined\"]) : renderedType,\n hasQuestionToken: isOptional,\n };\n }),\n })\n ),\n });\n sourceFile.addTypeAlias({\n name: `${pascalCase(queryFunctionType.name)}Return`,\n isExported: true,\n type: generateForTypeDef(queryFunctionType.returnType, { objectTypes }),\n docs: buildJsDocs({\n description: queryFunctionType.description,\n deprecated: queryFunctionType.deprecated,\n }),\n });\n }\n}\n\nexport function generateTypes(ir: OntologyIR, opts: GenerateTypesOpts = {}): string {\n const outputTypeName = opts.outputTypeName ?? \"GeneratedOntology\";\n const objectTypes = new Map(ir.objectTypes.map((objectType) => [objectType.name, objectType]));\n const typeDefinitions = generateTypeDefinitions(collectTypeDefinitions(ir), {\n objectTypes,\n });\n const project = new Project({ useInMemoryFileSystem: true });\n const aggregateFile = project.createSourceFile(\"ontology-aggregate.ts\", \"\");\n addOntologyContextType(aggregateFile, ir, outputTypeName);\n addActionParameterTypes(aggregateFile, ir);\n addQueryParameterTypes(aggregateFile, ir);\n addOntologyAggregateType(aggregateFile, ir, outputTypeName);\n return `${typeDefinitions}\\n\\n${aggregateFile.getFullText().trim()}`.trim();\n}\n"],"mappings":";;;;;;AAaA,SAAS,WAAW,IAA4B;CAC5C,MAAM,SAAS,IAAI,gBAAgB;CACnC,GAAG,MAAM;CACT,OAAO,OAAO,SAAS;AAC3B;AAEA,SAAS,MAAM,SAA2B;CACtC,IAAI,QAAQ,WAAW,GACnB,OAAO;CAEX,IAAI,QAAQ,WAAW,GACnB,OAAO,QAAQ;CAEnB,OAAO,WAAW,QAAQ,UAAU,QAAQ,IAAK,QAAQ,IAAK,GAAG,QAAQ,MAAM,CAAC,CAAC,CAAC;AACtF;AAEA,SAAS,mBAAmB,MAAsB;CAC9C,OAAO,wBAAwB,KAAK,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI;AAC1E;AAWA,SAAgB,mBAAmB,MAAe,MAA2B,CAAC,GAAW;CACrF,QAAQ,KAAK,MAAb;EACI,KAAK;GACD,IAAI,KAAK,MAAM,YAAY,SAAS,QAAQ;IACxC,MAAM,UAAU,KAAK,MAAM,WAAW,MAAM;IAC5C,OAAO,MAAM,QAAQ,KAAK,WAAW,IAAI,OAAO,MAAM,EAAE,CAAC;GAC7D;GACA,OAAO;EAGX,KAAK,WACD,OAAO;EAEX,KAAK,WACD,OAAO;EAEX,KAAK,SACD,OAAO;EAEX,KAAK,UACD,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AAY,kBAAkB,WAAW,KAAK,cAAc;IACxD,MAAM,gBAAgB,UAAU;IAChC,MAAM,aAAa,cAAc,SAAS;IAE1C,MAAM,eAAe,mBADR,aAAa,cAAc,MAAM,OAAO,eACP,EAAE,YAAY,CAAC;IAC7D,OAAO;KACH,MAAM,mBAAmB,UAAU,IAAI;KACvC,MAAM,aAAa,MAAM,CAAC,cAAc,WAAW,CAAC,IAAI;KACxD,kBAAkB;IACtB;GACJ,CAAC,EACL,CAAC,CACL;EACJ,CAAC;EACD,WAAW,aAAa;GACpB,MAAM,GAAG,WAAW,kBAAkB,IAAI,EAAE;GAC5C,YAAY;GACZ,MAAM,mBAAmB,kBAAkB,YAAY,EAAE,YAAY,CAAC;GACtE,MAAM,YAAY;IACd,aAAa,kBAAkB;IAC/B,YAAY,kBAAkB;GAClC,CAAC;EACL,CAAC;CACL;AACJ;AAEA,SAAgB,cAAc,IAAgB,OAA0B,CAAC,GAAW;CAChF,MAAM,iBAAiB,KAAK,kBAAkB;CAC9C,MAAM,cAAc,IAAI,IAAI,GAAG,YAAY,KAAK,eAAe,CAAC,WAAW,MAAM,UAAU,CAAC,CAAC;CAC7F,MAAM,kBAAkB,wBAAwB,uBAAuB,EAAE,GAAG,EACxE,YACJ,CAAC;CAED,MAAM,gBAAgB,IADF,QAAQ,EAAE,uBAAuB,KAAK,CAC9B,CAAC,CAAC,iBAAiB,yBAAyB,EAAE;CAC1E,uBAAuB,eAAe,IAAI,cAAc;CACxD,wBAAwB,eAAe,EAAE;CACzC,uBAAuB,eAAe,EAAE;CACxC,yBAAyB,eAAe,IAAI,cAAc;CAC1D,OAAO,GAAG,gBAAgB,MAAM,cAAc,YAAY,CAAC,CAAC,KAAK,IAAI,KAAK;AAC9E"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Deprecation } from "../../ir/generated/types.js";
|
|
2
|
-
import "../../ir/index.js";
|
|
3
|
-
import { JSDocStructure, OptionalKind } from "ts-morph";
|
|
4
|
-
//#region src/generate/utils/buildJsDocs.d.ts
|
|
5
|
-
export declare function buildJsDocs(opts: {
|
|
6
|
-
description?: string;
|
|
7
|
-
deprecated?: Deprecation;
|
|
8
|
-
}): OptionalKind<JSDocStructure>[] | undefined;
|
|
9
|
-
//#endregion
|
|
10
|
-
//# sourceMappingURL=buildJsDocs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildJsDocs.d.ts","names":[],"sources":["../../../src/generate/utils/buildJsDocs.ts"],"mappings":";;;;wBAGgB,YAAY;EACxB;EACA,aAAa;IACb,aAAa"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/generate/utils/buildJsDocs.ts
|
|
2
|
-
function buildJsDocs(opts) {
|
|
3
|
-
const { description, deprecated } = opts;
|
|
4
|
-
if (!description && !deprecated) return void 0;
|
|
5
|
-
return [{
|
|
6
|
-
description,
|
|
7
|
-
tags: deprecated ? [{
|
|
8
|
-
tagName: "deprecated",
|
|
9
|
-
text: deprecated.message
|
|
10
|
-
}] : void 0
|
|
11
|
-
}];
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { buildJsDocs };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=buildJsDocs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildJsDocs.js","names":[],"sources":["../../../src/generate/utils/buildJsDocs.ts"],"sourcesContent":["import type { Deprecation } from \"../../ir/index.js\";\nimport type { JSDocStructure, OptionalKind } from \"ts-morph\";\n\nexport function buildJsDocs(opts: {\n description?: string;\n deprecated?: Deprecation;\n}): OptionalKind<JSDocStructure>[] | undefined {\n const { description, deprecated } = opts;\n if (!description && !deprecated) return undefined;\n\n return [\n {\n description,\n tags: deprecated ? [{ tagName: \"deprecated\", text: deprecated.message }] : undefined,\n },\n ];\n}\n"],"mappings":";AAGA,SAAgB,YAAY,MAGmB;CAC3C,MAAM,EAAE,aAAa,eAAe;CACpC,IAAI,CAAC,eAAe,CAAC,YAAY,OAAO,KAAA;CAExC,OAAO,CACH;EACI;EACA,MAAM,aAAa,CAAC;GAAE,SAAS;GAAc,MAAM,WAAW;EAAQ,CAAC,IAAI,KAAA;CAC/E,CACJ;AACJ"}
|
package/lib/infer.d.ts
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { Result, attachment, date, double, float, geopoint, integer, timestamp } from "./utils/values.js";
|
|
2
|
-
import { ImageMediaType, NamedTypeDef, OntologyIR, TypeDef } from "./ir/generated/types.js";
|
|
3
|
-
import { ActionTypeName, ActionTypes, ArrayElement, NamedTypes, ObjectTypeName, ObjectTypes, QueryFunctionTypeName, QueryFunctionTypes } from "./utils/typeNames.js";
|
|
4
|
-
import { OntologyDefinition } from "./live/LiveOntology.js";
|
|
5
|
-
//#region src/infer.d.ts
|
|
6
|
-
export type ReadonlyDeep<T> = T extends ((...args: never[]) => unknown) ? T : T extends readonly (infer Element)[] ? readonly ReadonlyDeep<Element>[] : T extends object ? { readonly [K in keyof T]: ReadonlyDeep<T[K]>; } : T;
|
|
7
|
-
export type MutableDeep<T> = T extends ((...args: never[]) => unknown) ? T : T extends readonly (infer Element)[] ? Array<MutableDeep<Element>> : T extends object ? { -readonly [K in keyof T]: MutableDeep<T[K]>; } : T;
|
|
8
|
-
type FlattenObject<T> = { [K in keyof T]: T[K]; } & {};
|
|
9
|
-
type TypeKind<Type> = Type extends {
|
|
10
|
-
readonly kind: infer Kind extends string;
|
|
11
|
-
} ? Kind : never;
|
|
12
|
-
type TypeValue<Type> = Type extends {
|
|
13
|
-
readonly value: infer Value;
|
|
14
|
-
} ? Value : never;
|
|
15
|
-
type NamedTypeByName<Ontology, Name extends PropertyKey> = Extract<NamedTypes<Ontology>, {
|
|
16
|
-
readonly name: Name;
|
|
17
|
-
}>;
|
|
18
|
-
type ObjectTypeByName<Ontology, Name extends PropertyKey> = Extract<ObjectTypes<Ontology>, {
|
|
19
|
-
readonly name: Name;
|
|
20
|
-
}>;
|
|
21
|
-
type ActionTypeByName<Ontology, Name extends PropertyKey> = Extract<ActionTypes<Ontology>, {
|
|
22
|
-
readonly name: Name;
|
|
23
|
-
}>;
|
|
24
|
-
type QueryFunctionTypeByName<Ontology, Name extends PropertyKey> = Extract<QueryFunctionTypes<Ontology>, {
|
|
25
|
-
readonly name: Name;
|
|
26
|
-
}>;
|
|
27
|
-
type ObjectTypeProperties<ObjectType> = ObjectType extends {
|
|
28
|
-
readonly properties: infer Properties;
|
|
29
|
-
} ? Properties : never;
|
|
30
|
-
type InferString<Value> = Value extends {
|
|
31
|
-
readonly constraint?: infer Constraint;
|
|
32
|
-
} ? NonNullable<Constraint> extends {
|
|
33
|
-
readonly kind: "enum";
|
|
34
|
-
readonly value: {
|
|
35
|
-
readonly options: infer Options;
|
|
36
|
-
};
|
|
37
|
-
} ? ArrayElement<Options> extends {
|
|
38
|
-
readonly value: infer OptionValue extends string;
|
|
39
|
-
} ? OptionValue : never : string : string;
|
|
40
|
-
type StructField<Fields> = ArrayElement<Fields>;
|
|
41
|
-
type FieldName<Field> = Field extends {
|
|
42
|
-
readonly name: infer Name extends PropertyKey;
|
|
43
|
-
} ? Name : never;
|
|
44
|
-
type FieldByName<Fields, Name extends PropertyKey> = Extract<StructField<Fields>, {
|
|
45
|
-
readonly name: Name;
|
|
46
|
-
}>;
|
|
47
|
-
type FieldType<Fields, Name extends PropertyKey> = FieldByName<Fields, Name> extends {
|
|
48
|
-
readonly type: infer Type;
|
|
49
|
-
} ? Type : never;
|
|
50
|
-
type RequiredFieldNames<Fields> = StructField<Fields> extends (infer Field) ? Field extends {
|
|
51
|
-
readonly type: infer Type;
|
|
52
|
-
} ? Type extends {
|
|
53
|
-
readonly kind: "optional";
|
|
54
|
-
} ? never : FieldName<Field> : never : never;
|
|
55
|
-
type OptionalFieldNames<Fields> = StructField<Fields> extends (infer Field) ? Field extends {
|
|
56
|
-
readonly type: infer Type;
|
|
57
|
-
} ? Type extends {
|
|
58
|
-
readonly kind: "optional";
|
|
59
|
-
} ? FieldName<Field> : never : never : never;
|
|
60
|
-
type InferStructFields<Fields, Ontology> = StructField<Fields> extends never ? Record<never, never> : FlattenObject<{ [Name in RequiredFieldNames<Fields>]: InferType<FieldType<Fields, Name>, Ontology>; } & { [Name in OptionalFieldNames<Fields>]?: TypeValue<FieldType<Fields, Name>> extends {
|
|
61
|
-
readonly type: infer Inner;
|
|
62
|
-
} ? InferType<Inner, Ontology> : never; }>;
|
|
63
|
-
type InferUnionVariant<Variant, Ontology> = Variant extends {
|
|
64
|
-
readonly name: infer Name extends string;
|
|
65
|
-
readonly type: infer Type;
|
|
66
|
-
} ? {
|
|
67
|
-
kind: Name;
|
|
68
|
-
value: InferType<Type, Ontology>;
|
|
69
|
-
} : never;
|
|
70
|
-
type ObjectPrimaryKey<ObjectType> = ObjectType extends {
|
|
71
|
-
readonly primaryKey: infer PrimaryKey extends PropertyKey;
|
|
72
|
-
} ? PrimaryKey : never;
|
|
73
|
-
type InferObjectReference<Value, Ontology> = Value extends {
|
|
74
|
-
readonly objectType: infer Name extends PropertyKey;
|
|
75
|
-
} ? InferType<FieldType<ObjectTypeProperties<ObjectTypeByName<Ontology, Name>>, ObjectPrimaryKey<ObjectTypeByName<Ontology, Name>>>, Ontology> : never;
|
|
76
|
-
type InferImageAttachment<Value> = Value extends {
|
|
77
|
-
readonly mediaTypes: infer MediaTypes;
|
|
78
|
-
} ? attachment<Extract<ArrayElement<MediaTypes>, string>> : attachment<ImageMediaType>;
|
|
79
|
-
type InferAttachment<Value> = Value extends {
|
|
80
|
-
readonly constraint: {
|
|
81
|
-
readonly content: infer Content;
|
|
82
|
-
};
|
|
83
|
-
} ? Content extends {
|
|
84
|
-
readonly kind: "image";
|
|
85
|
-
readonly value: infer ImageConstraint;
|
|
86
|
-
} ? InferImageAttachment<ImageConstraint> : attachment : attachment;
|
|
87
|
-
type InferByKind<Type, Ontology> = {
|
|
88
|
-
string: InferString<TypeValue<Type>>;
|
|
89
|
-
boolean: boolean;
|
|
90
|
-
integer: integer;
|
|
91
|
-
float: float;
|
|
92
|
-
double: double;
|
|
93
|
-
date: date;
|
|
94
|
-
timestamp: timestamp;
|
|
95
|
-
geopoint: geopoint;
|
|
96
|
-
attachment: InferAttachment<TypeValue<Type>>;
|
|
97
|
-
objectReference: InferObjectReference<TypeValue<Type>, Ontology>;
|
|
98
|
-
unknown: unknown;
|
|
99
|
-
list: TypeValue<Type> extends {
|
|
100
|
-
readonly elementType: infer ElementType;
|
|
101
|
-
} ? Array<InferType<ElementType, Ontology>> : never;
|
|
102
|
-
map: TypeValue<Type> extends {
|
|
103
|
-
readonly valueType: infer ValueType;
|
|
104
|
-
} ? Record<string, InferType<ValueType, Ontology>> : never;
|
|
105
|
-
struct: TypeValue<Type> extends {
|
|
106
|
-
readonly fields: infer Fields;
|
|
107
|
-
} ? InferStructFields<Fields, Ontology> : never;
|
|
108
|
-
union: TypeValue<Type> extends {
|
|
109
|
-
readonly variants: infer Variants;
|
|
110
|
-
} ? InferUnionVariant<ArrayElement<Variants>, Ontology> : never;
|
|
111
|
-
optional: TypeValue<Type> extends {
|
|
112
|
-
readonly type: infer Inner;
|
|
113
|
-
} ? InferType<Inner, Ontology> | undefined : never;
|
|
114
|
-
result: TypeValue<Type> extends {
|
|
115
|
-
readonly okType: infer OkType;
|
|
116
|
-
readonly errType: infer ErrType;
|
|
117
|
-
} ? Result<InferType<OkType, Ontology>, InferType<ErrType, Ontology>> : never;
|
|
118
|
-
ref: TypeValue<Type> extends {
|
|
119
|
-
readonly name: infer Name extends PropertyKey;
|
|
120
|
-
} ? InferNamedTypeByName<Ontology, Name> : never;
|
|
121
|
-
};
|
|
122
|
-
export type InferType<Type, Ontology = never> = TypeKind<Type> extends keyof InferByKind<Type, Ontology> ? InferByKind<Type, Ontology>[TypeKind<Type>] : never;
|
|
123
|
-
type InferNamedTypeByName<Ontology, Name extends PropertyKey> = NamedTypeByName<Ontology, Name> extends {
|
|
124
|
-
readonly type: infer Type;
|
|
125
|
-
} ? InferType<Type, Ontology> : ObjectTypeByName<Ontology, Name> extends {
|
|
126
|
-
readonly properties: infer Properties;
|
|
127
|
-
} ? InferStructFields<Properties, Ontology> : never;
|
|
128
|
-
export type InferNamedType<Type, Ontology = never> = Type extends {
|
|
129
|
-
readonly type: infer TypeDef;
|
|
130
|
-
} ? InferType<TypeDef, Ontology> : never;
|
|
131
|
-
type InferObjectType<ObjectType, Ontology> = ObjectType extends {
|
|
132
|
-
readonly properties: infer Properties;
|
|
133
|
-
} ? InferStructFields<Properties, Ontology> : never;
|
|
134
|
-
type ActionParameters<ActionType> = ActionType extends {
|
|
135
|
-
readonly parameters: infer Parameters;
|
|
136
|
-
} ? Parameters : never;
|
|
137
|
-
type ActionParameter<Parameters> = ArrayElement<Parameters>;
|
|
138
|
-
type ActionParameterName<Parameter> = Parameter extends {
|
|
139
|
-
readonly name: infer Name extends PropertyKey;
|
|
140
|
-
} ? Name : never;
|
|
141
|
-
type ActionParameterByName<Parameters, Name extends PropertyKey> = Extract<ActionParameter<Parameters>, {
|
|
142
|
-
readonly name: Name;
|
|
143
|
-
}>;
|
|
144
|
-
type ActionParameterType<Parameters, Name extends PropertyKey> = ActionParameterByName<Parameters, Name> extends {
|
|
145
|
-
readonly type: infer Type;
|
|
146
|
-
} ? Type : never;
|
|
147
|
-
type RequiredActionParameterNames<Parameters> = ActionParameter<Parameters> extends (infer Parameter) ? Parameter extends {
|
|
148
|
-
readonly type: infer Type;
|
|
149
|
-
} ? Type extends {
|
|
150
|
-
readonly kind: "optional";
|
|
151
|
-
} ? never : Parameter extends {
|
|
152
|
-
readonly defaultValue: unknown;
|
|
153
|
-
} ? never : ActionParameterName<Parameter> : never : never;
|
|
154
|
-
type OptionalActionParameterNames<Parameters> = ActionParameter<Parameters> extends (infer Parameter) ? Parameter extends {
|
|
155
|
-
readonly type: infer Type;
|
|
156
|
-
} ? Type extends {
|
|
157
|
-
readonly kind: "optional";
|
|
158
|
-
} ? ActionParameterName<Parameter> : Parameter extends {
|
|
159
|
-
readonly defaultValue: unknown;
|
|
160
|
-
} ? ActionParameterName<Parameter> : never : never : never;
|
|
161
|
-
type InferActionParameter<Parameters, Name extends PropertyKey, Ontology> = ActionParameterType<Parameters, Name> extends (infer Type) ? Type extends {
|
|
162
|
-
readonly kind: "optional";
|
|
163
|
-
readonly value: {
|
|
164
|
-
readonly type: infer Inner;
|
|
165
|
-
};
|
|
166
|
-
} ? InferType<Inner, Ontology> | null : InferType<Type, Ontology> : never;
|
|
167
|
-
type InferActionParameters<Parameters, Ontology> = ActionParameter<Parameters> extends never ? Record<never, never> : FlattenObject<{ [Name in RequiredActionParameterNames<Parameters>]: InferActionParameter<Parameters, Name, Ontology>; } & { [Name in OptionalActionParameterNames<Parameters>]?: InferActionParameter<Parameters, Name, Ontology>; }>;
|
|
168
|
-
type QueryParameters<QueryFunctionType> = QueryFunctionType extends {
|
|
169
|
-
readonly parameters: infer Parameters;
|
|
170
|
-
} ? Parameters : never;
|
|
171
|
-
type QueryReturnType<QueryFunctionType> = QueryFunctionType extends {
|
|
172
|
-
readonly returnType: infer ReturnType;
|
|
173
|
-
} ? ReturnType : never;
|
|
174
|
-
type QueryParameter<Parameters> = ArrayElement<Parameters>;
|
|
175
|
-
type QueryParameterName<Parameter> = Parameter extends {
|
|
176
|
-
readonly name: infer Name extends PropertyKey;
|
|
177
|
-
} ? Name : never;
|
|
178
|
-
type QueryParameterByName<Parameters, Name extends PropertyKey> = Extract<QueryParameter<Parameters>, {
|
|
179
|
-
readonly name: Name;
|
|
180
|
-
}>;
|
|
181
|
-
type QueryParameterType<Parameters, Name extends PropertyKey> = QueryParameterByName<Parameters, Name> extends {
|
|
182
|
-
readonly type: infer Type;
|
|
183
|
-
} ? Type : never;
|
|
184
|
-
type RequiredQueryParameterNames<Parameters> = QueryParameter<Parameters> extends (infer Parameter) ? Parameter extends {
|
|
185
|
-
readonly type: infer Type;
|
|
186
|
-
} ? Type extends {
|
|
187
|
-
readonly kind: "optional";
|
|
188
|
-
} ? never : QueryParameterName<Parameter> : never : never;
|
|
189
|
-
type OptionalQueryParameterNames<Parameters> = QueryParameter<Parameters> extends (infer Parameter) ? Parameter extends {
|
|
190
|
-
readonly type: infer Type;
|
|
191
|
-
} ? Type extends {
|
|
192
|
-
readonly kind: "optional";
|
|
193
|
-
} ? QueryParameterName<Parameter> : never : never : never;
|
|
194
|
-
type InferQueryParameter<Parameters, Name extends PropertyKey, Ontology> = QueryParameterType<Parameters, Name> extends (infer Type) ? Type extends {
|
|
195
|
-
readonly kind: "optional";
|
|
196
|
-
readonly value: {
|
|
197
|
-
readonly type: infer Inner;
|
|
198
|
-
};
|
|
199
|
-
} ? InferType<Inner, Ontology> : InferType<Type, Ontology> : never;
|
|
200
|
-
type InferQueryParameters<Parameters, Ontology> = QueryParameter<Parameters> extends never ? Record<never, never> : FlattenObject<{ [Name in RequiredQueryParameterNames<Parameters>]: InferQueryParameter<Parameters, Name, Ontology>; } & { [Name in OptionalQueryParameterNames<Parameters>]?: InferQueryParameter<Parameters, Name, Ontology>; }>;
|
|
201
|
-
export type InferOntology<Ontology> = {
|
|
202
|
-
context: Ontology extends {
|
|
203
|
-
readonly contextType: infer ContextType;
|
|
204
|
-
} ? InferType<ContextType, Ontology> : Record<string, unknown>;
|
|
205
|
-
objectTypes: { [Name in ObjectTypeName<Ontology>]: InferObjectType<ObjectTypeByName<Ontology, Name>, Ontology>; };
|
|
206
|
-
actionTypes: { [Name in ActionTypeName<Ontology>]: {
|
|
207
|
-
parameters: InferActionParameters<ActionParameters<ActionTypeByName<Ontology, Name>>, Ontology>;
|
|
208
|
-
}; };
|
|
209
|
-
queryFunctionTypes: { [Name in QueryFunctionTypeName<Ontology>]: {
|
|
210
|
-
parameters: InferQueryParameters<QueryParameters<QueryFunctionTypeByName<Ontology, Name>>, Ontology>;
|
|
211
|
-
returnType: InferType<QueryReturnType<QueryFunctionTypeByName<Ontology, Name>>, Ontology>;
|
|
212
|
-
}; };
|
|
213
|
-
} & OntologyDefinition;
|
|
214
|
-
export type ConstOntologyIR = ReadonlyDeep<OntologyIR>;
|
|
215
|
-
export type ConstTypeDef = ReadonlyDeep<TypeDef>;
|
|
216
|
-
export type ConstNamedTypeDef = ReadonlyDeep<NamedTypeDef>;
|
|
217
|
-
export type Infer<Input extends ConstOntologyIR | ConstNamedTypeDef | ConstTypeDef, Ontology extends ConstOntologyIR = Extract<Input, ConstOntologyIR>> = Input extends ConstOntologyIR ? InferOntology<Input> : Input extends ConstNamedTypeDef ? InferNamedType<Input, Ontology> : Input extends ConstTypeDef ? InferType<Input, Ontology> : never;
|
|
218
|
-
export declare function defineOntology<const Ontology extends ConstOntologyIR>(ontology: Ontology): MutableDeep<Ontology>;
|
|
219
|
-
export declare function defineType<const Type extends ConstTypeDef>(type: Type): MutableDeep<Type>;
|
|
220
|
-
export declare function defineNamedType<const Type extends ConstNamedTypeDef>(type: Type): MutableDeep<Type>;
|
|
221
|
-
//#endregion
|
|
222
|
-
//# sourceMappingURL=infer.d.ts.map
|
package/lib/infer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"infer.d.ts","names":[],"sources":["../src/infer.ts"],"mappings":";;;;;YAuBY,aAAa,KAAK,eAAc,6BACtC,IACA,0BAA0B,sBACf,aAAa,aACtB,+BACc,WAAW,IAAI,aAAa,EAAE,SAC1C;YAEE,YAAY,KAAK,eAAc,6BACrC,IACA,0BAA0B,aACxB,MAAM,YAAY,YAClB,gCACe,WAAW,IAAI,YAAY,EAAE,SAC1C;KAEL,cAAc,QAAQ,WAAW,IAAI,EAAE;KAEvC,SAAS,QAAQ;WAAwB,YAAY;IAAwB;KAE7E,UAAU,QAAQ;WAAwB,aAAa;IAAU;KAEjE,gBAAgB,UAAU,aAAa,eAAe,QACvD,WAAW;WACA,MAAM;;KAGhB,iBAAiB,UAAU,aAAa,eAAe,QACxD,YAAY;WACD,MAAM;;KAGhB,iBAAiB,UAAU,aAAa,eAAe,QACxD,YAAY;WACD,MAAM;;KAGhB,wBA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gBAAgB,iBAAiB,UAAU,OAAO;EAE1F,gBACK,QAAQ,eAAe;IACpB,YAAY,sBAAsB,iBAAiB,iBAAiB,UAAU,QAAQ;;EAG9F,uBACK,QAAQ,sBAAsB;IAC3B,YAAY,qBACR,gBAAgB,wBAAwB,UAAU,QAClD;IAEJ,YAAY,UAAU,gBAAgB,wBAAwB,UAAU,QAAQ;;IAGxF;YAEQ,kBAAkB,aAAa;YAC/B,eAAe,aAAa;YAC5B,oBAAoB,aAAa;YAEjC,MACR,cAAc,kBAAkB,oBAAoB,cACpD,iBAAiB,kBAAkB,QAAQ,OAAO,oBAClD,cAAc,kBACZ,cAAc,SACd,cAAc,oBACZ,eAAe,OAAO,YACtB,cAAc,eACZ,UAAU,OAAO;wBAGX,qBAAqB,iBAAiB,iBAClD,UAAU,WACX,YAAY;wBAIC,iBAAiB,aAAa,cAAc,MAAM,OAAO,YAAY;wBAIrE,sBAAsB,aAAa,mBAAmB,MAAM,OAAO,YAAY"}
|
package/lib/infer.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/infer.ts
|
|
2
|
-
function defineOntology(ontology) {
|
|
3
|
-
return ontology;
|
|
4
|
-
}
|
|
5
|
-
function defineType(type) {
|
|
6
|
-
return type;
|
|
7
|
-
}
|
|
8
|
-
function defineNamedType(type) {
|
|
9
|
-
return type;
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { defineNamedType, defineOntology, defineType };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=infer.js.map
|