@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLocalCollection.js","names":[],"sources":["../../src/tanstack/createLocalCollection.ts"],"sourcesContent":["import { createEffectLocalCollection } from \"./localCollection.js\";\nimport type { RuntimeService } from \"@party-stack/runtime\";\nimport type { Collection } from \"@tanstack/db\";\nimport type { Scope } from \"effect\";\n\nexport function createLocalCollection<T extends object, TKey extends string | number>(options: {\n name: string;\n getKey: (value: T) => TKey;\n runtime: RuntimeService;\n schemaVersion?: number;\n /** Optional owner for the collection's Effect resources. */\n scope: Scope.Scope;\n}): Collection<T, TKey> {\n return createEffectLocalCollection(options);\n}\n"],"mappings":";;AAKA,SAAgB,sBAAsE,SAO9D;CACpB,OAAO,4BAA4B,OAAO;AAC9C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CollectionConfig, CollectionOptions, ContextFromSource, QueryBuilder, RefsForContext, Source } from "@tanstack/db";
|
|
2
|
+
import { OntologyDefinition, OntologyObject } from "@party-stack/ontology-spec";
|
|
3
|
+
//#region src/tanstack/descriptors.d.ts
|
|
4
|
+
export declare const ontologyCollectionDependency = "@party-stack/ontology/collectionOptions";
|
|
5
|
+
export type OntologyCollectionResolver = (id: string, objectType: string, localOnly: boolean) => CollectionConfig<OntologyObject, string | number>;
|
|
6
|
+
export type OntologyLinkDefinitions<Definition extends OntologyDefinition> = Partial<{ readonly [Name in keyof Definition["objectTypes"]]: Readonly<Record<string, {
|
|
7
|
+
readonly objectType: Extract<keyof Definition["objectTypes"], string>;
|
|
8
|
+
readonly source: readonly string[];
|
|
9
|
+
readonly target: readonly string[];
|
|
10
|
+
}>>; }>;
|
|
11
|
+
type Descriptor<Definition extends OntologyDefinition, Name extends keyof Definition["objectTypes"]> = CollectionOptions<Definition["objectTypes"][Name], string | number>;
|
|
12
|
+
type RowRef<S extends Source[string]> = RefsForContext<ContextFromSource<{
|
|
13
|
+
row: S;
|
|
14
|
+
}>>["row"];
|
|
15
|
+
type LinkQuery<Definition extends OntologyDefinition, Link> = Link extends {
|
|
16
|
+
objectType: infer Target extends keyof Definition["objectTypes"];
|
|
17
|
+
} ? QueryBuilder<ContextFromSource<{
|
|
18
|
+
row: Descriptor<Definition, Target>;
|
|
19
|
+
}>> : never;
|
|
20
|
+
export type OntologyCollectionDescriptors<Definition extends OntologyDefinition, Links extends OntologyLinkDefinitions<Definition> = Record<never, never>> = { readonly [Name in keyof Definition["objectTypes"]]: CollectionOptions<Definition["objectTypes"][Name], string | number> & {
|
|
21
|
+
readonly primaryKey: Extract<keyof Definition["objectTypes"][Name], string>;
|
|
22
|
+
readonly links: Name extends keyof Links ? { readonly [Link in keyof Links[Name]]: (row: RowRef<Descriptor<Definition, Name>>) => LinkQuery<Definition, Links[Name][Link]>; } : Record<never, never>;
|
|
23
|
+
}; };
|
|
24
|
+
/** Reusable module-level descriptors. Each ontology's DbClient supplies the replica
|
|
25
|
+
* and owns the collection instances; descriptors contain neither account data nor IO.
|
|
26
|
+
*/
|
|
27
|
+
export declare function ontologyCollections<Definition extends OntologyDefinition, const Links extends OntologyLinkDefinitions<Definition> = Record<never, never>>(primaryKeys: { readonly [Name in keyof Definition["objectTypes"]]: Extract<keyof Definition["objectTypes"][Name], string>; }, linkDefinitions?: Links): {
|
|
28
|
+
objects: OntologyCollectionDescriptors<Definition, Links>;
|
|
29
|
+
cachedObjects: OntologyCollectionDescriptors<Definition, Links>;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=descriptors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptors.d.ts","names":[],"sources":["../../src/tanstack/descriptors.ts"],"mappings":";;;qBAWa;YACD,8BACR,YACA,oBACA,uBACC,iBAAiB;YAEV,wBAAwB,mBAAmB,sBAAsB,oBAC/D,cAAc,4BAA4B,SAChD;WAGiB,YAAY,cAAc;WAC1B;WACA;;KAKpB,WACD,mBAAmB,oBACnB,mBAAmB,6BACnB,kBAAkB,0BAA0B;KAC3C,OAAO,UAAU,kBAAkB,eAAe;EAAoB,KAAK;;KAC3E,UAAU,mBAAmB,oBAAoB,QAAQ;EAC1D,kBAAkB,qBAAqB;IAErC,aAAa;EAAoB,KAAK,WAAW,YAAY;;YAGvD,8BACR,mBAAmB,oBACnB,cAAc,wBAAwB,cAAc,oCAE1C,cAAc,4BAA4B,kBAChD,0BAA0B;WAGjB,YAAY,cAAc,0BAA0B;WACpD,OAAO,mBAAmB,oBAEf,cAAc,MAAM,SAC1B,KAAK,OAAO,WAAW,YAAY,WAClC,UAAU,YAAY,MAAM,MAAM,YAE3C;;;;;wBAOE,oBACZ,mBAAmB,0BACb,cAAc,wBAAwB,cAAc,sBAE1D,yBACc,cAAc,4BAA4B,cAC1C,0BAA0B,mBAIxC,kBAAkB;EAuDT,SAAO,8BAAA,YAAA;EAAsB,eAAa,8BAAA,YAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Query, collectionOptions, eq } from "@tanstack/db";
|
|
2
|
+
//#region src/tanstack/descriptors.ts
|
|
3
|
+
const ontologyCollectionDependency = "@party-stack/ontology/collectionOptions";
|
|
4
|
+
/** Reusable module-level descriptors. Each ontology's DbClient supplies the replica
|
|
5
|
+
* and owns the collection instances; descriptors contain neither account data nor IO.
|
|
6
|
+
*/
|
|
7
|
+
function ontologyCollections(primaryKeys, linkDefinitions) {
|
|
8
|
+
const descriptors = (localOnly) => {
|
|
9
|
+
const entries = /* @__PURE__ */ new Map();
|
|
10
|
+
const result = new Proxy(Object.create(null), { get: (_target, name) => {
|
|
11
|
+
if (typeof name !== "string" || name === "then") return void 0;
|
|
12
|
+
let descriptor = entries.get(name);
|
|
13
|
+
if (!descriptor) {
|
|
14
|
+
const id = `party-stack:${localOnly ? "cached" : "objects"}:${name}`;
|
|
15
|
+
const primaryKey = primaryKeys[name];
|
|
16
|
+
if (!primaryKey) throw new Error(`Missing primary key for ontology collection: ${name}`);
|
|
17
|
+
const native = collectionOptions(id, (client) => client.requireDependency(ontologyCollectionDependency)(id, name, localOnly));
|
|
18
|
+
const links = Object.fromEntries(Object.entries(linkDefinitions?.[name] ?? {}).map(([name, link]) => [name, (parent) => new Query().from({ row: result[link.objectType] }).where(({ row }) => eq(link.target.reduce((value, key) => value[key], row), link.source.reduce((value, key) => value[key], parent)))]));
|
|
19
|
+
descriptor = Object.freeze(Object.defineProperties({
|
|
20
|
+
...native,
|
|
21
|
+
primaryKey,
|
|
22
|
+
links: Object.freeze(links)
|
|
23
|
+
}, Object.getOwnPropertyDescriptors(native)));
|
|
24
|
+
entries.set(name, descriptor);
|
|
25
|
+
}
|
|
26
|
+
return descriptor;
|
|
27
|
+
} });
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
objects: descriptors(false),
|
|
32
|
+
cachedObjects: descriptors(true)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ontologyCollectionDependency, ontologyCollections };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=descriptors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptors.js","names":[],"sources":["../../src/tanstack/descriptors.ts"],"sourcesContent":["import { collectionOptions, eq, Query } from \"@tanstack/db\";\nimport type { OntologyDefinition, OntologyObject } from \"@party-stack/ontology-spec\";\nimport type {\n CollectionConfig,\n CollectionOptions,\n ContextFromSource,\n QueryBuilder,\n RefsForContext,\n Source,\n} from \"@tanstack/db\";\n\nexport const ontologyCollectionDependency = \"@party-stack/ontology/collectionOptions\";\nexport type OntologyCollectionResolver = (\n id: string,\n objectType: string,\n localOnly: boolean\n) => CollectionConfig<OntologyObject, string | number>;\n\nexport type OntologyLinkDefinitions<Definition extends OntologyDefinition> = Partial<{\n readonly [Name in keyof Definition[\"objectTypes\"]]: Readonly<\n Record<\n string,\n {\n readonly objectType: Extract<keyof Definition[\"objectTypes\"], string>;\n readonly source: readonly string[];\n readonly target: readonly string[];\n }\n >\n >;\n}>;\ntype Descriptor<\n Definition extends OntologyDefinition,\n Name extends keyof Definition[\"objectTypes\"],\n> = CollectionOptions<Definition[\"objectTypes\"][Name], string | number>;\ntype RowRef<S extends Source[string]> = RefsForContext<ContextFromSource<{ row: S }>>[\"row\"];\ntype LinkQuery<Definition extends OntologyDefinition, Link> = Link extends {\n objectType: infer Target extends keyof Definition[\"objectTypes\"];\n}\n ? QueryBuilder<ContextFromSource<{ row: Descriptor<Definition, Target> }>>\n : never;\n\nexport type OntologyCollectionDescriptors<\n Definition extends OntologyDefinition,\n Links extends OntologyLinkDefinitions<Definition> = Record<never, never>,\n> = {\n readonly [Name in keyof Definition[\"objectTypes\"]]: CollectionOptions<\n Definition[\"objectTypes\"][Name],\n string | number\n > & {\n readonly primaryKey: Extract<keyof Definition[\"objectTypes\"][Name], string>;\n readonly links: Name extends keyof Links\n ? {\n readonly [Link in keyof Links[Name]]: (\n row: RowRef<Descriptor<Definition, Name>>\n ) => LinkQuery<Definition, Links[Name][Link]>;\n }\n : Record<never, never>;\n };\n};\n\n/** Reusable module-level descriptors. Each ontology's DbClient supplies the replica\n * and owns the collection instances; descriptors contain neither account data nor IO.\n */\nexport function ontologyCollections<\n Definition extends OntologyDefinition,\n const Links extends OntologyLinkDefinitions<Definition> = Record<never, never>,\n>(\n primaryKeys: {\n readonly [Name in keyof Definition[\"objectTypes\"]]: Extract<\n keyof Definition[\"objectTypes\"][Name],\n string\n >;\n },\n linkDefinitions?: Links\n) {\n const descriptors = (localOnly: boolean) => {\n const entries = new Map<\n string,\n CollectionOptions<OntologyObject, string | number> & { readonly primaryKey: string }\n >();\n const result: OntologyCollectionDescriptors<Definition, Links> = new Proxy(Object.create(null), {\n get: (_target, name) => {\n if (typeof name !== \"string\" || name === \"then\") return undefined;\n let descriptor = entries.get(name);\n if (!descriptor) {\n const id = `party-stack:${localOnly ? \"cached\" : \"objects\"}:${name}`;\n const primaryKey = primaryKeys[name];\n if (!primaryKey) throw new Error(`Missing primary key for ontology collection: ${name}`);\n const native = collectionOptions(id, (client) =>\n client.requireDependency<OntologyCollectionResolver>(ontologyCollectionDependency)(\n id,\n name,\n localOnly\n )\n );\n const links = Object.fromEntries(\n Object.entries(linkDefinitions?.[name] ?? {}).map(([name, link]) => [\n name,\n (parent: Record<string, unknown>) =>\n new Query().from({ row: result[link.objectType] }).where(({ row }) =>\n eq(\n link.target.reduce(\n (value, key) => (value as Record<string, unknown>)[key],\n row as unknown\n ),\n link.source.reduce(\n (value, key) => (value as Record<string, unknown>)[key],\n parent as unknown\n )\n )\n ),\n ])\n );\n // Native descriptors are frozen and carry non-enumerable branding\n // and factories. Preserve those descriptors on a fresh object.\n descriptor = Object.freeze(\n Object.defineProperties(\n { ...native, primaryKey, links: Object.freeze(links) },\n Object.getOwnPropertyDescriptors(native)\n )\n );\n entries.set(name, descriptor);\n }\n return descriptor;\n },\n });\n return result;\n };\n return { objects: descriptors(false), cachedObjects: descriptors(true) };\n}\n"],"mappings":";;AAWA,MAAa,+BAA+B;;;;AAoD5C,SAAgB,oBAIZ,aAMA,iBACF;CACE,MAAM,eAAe,cAAuB;EACxC,MAAM,0BAAU,IAAI,IAGlB;EACF,MAAM,SAA2D,IAAI,MAAM,OAAO,OAAO,IAAI,GAAG,EAC5F,MAAM,SAAS,SAAS;GACpB,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAO,KAAA;GACxD,IAAI,aAAa,QAAQ,IAAI,IAAI;GACjC,IAAI,CAAC,YAAY;IACb,MAAM,KAAK,eAAe,YAAY,WAAW,UAAU,GAAG;IAC9D,MAAM,aAAa,YAAY;IAC/B,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,gDAAgD,MAAM;IACvF,MAAM,SAAS,kBAAkB,KAAK,WAClC,OAAO,kBAA8C,4BAA4B,CAAC,CAC9E,IACA,MACA,SACJ,CACJ;IACA,MAAM,QAAQ,OAAO,YACjB,OAAO,QAAQ,kBAAkB,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAChE,OACC,WACG,IAAI,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,OAAO,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,EAAE,UACxD,GACI,KAAK,OAAO,QACP,OAAO,QAAS,MAAkC,MACnD,GACJ,GACA,KAAK,OAAO,QACP,OAAO,QAAS,MAAkC,MACnD,MACJ,CACJ,CACJ,CACR,CAAC,CACL;IAGA,aAAa,OAAO,OAChB,OAAO,iBACH;KAAE,GAAG;KAAQ;KAAY,OAAO,OAAO,OAAO,KAAK;IAAE,GACrD,OAAO,0BAA0B,MAAM,CAC3C,CACJ;IACA,QAAQ,IAAI,MAAM,UAAU;GAChC;GACA,OAAO;EACX,EACJ,CAAC;EACD,OAAO;CACX;CACA,OAAO;EAAE,SAAS,YAAY,KAAK;EAAG,eAAe,YAAY,IAAI;CAAE;AAC3E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LoadSubsetOptions } from "@tanstack/db";
|
|
2
|
+
import { Query as Query$1 } from "@party-stack/ontology-storage";
|
|
3
|
+
//#region src/tanstack/diagnostics.d.ts
|
|
4
|
+
export interface CollectionDemandDiagnostic {
|
|
5
|
+
readonly objectType: string;
|
|
6
|
+
readonly query?: Query$1;
|
|
7
|
+
/** Tab-local source demand before storage translation; never sent to the backend. */
|
|
8
|
+
readonly requested?: Pick<LoadSubsetOptions, "where" | "orderBy" | "limit" | "offset" | "cursor">;
|
|
9
|
+
readonly exact?: boolean;
|
|
10
|
+
readonly filterExact?: boolean;
|
|
11
|
+
readonly orderExact?: boolean;
|
|
12
|
+
/** Whether this acquisition has delivered its first local snapshot. */
|
|
13
|
+
readonly received?: boolean;
|
|
14
|
+
/** Whether local delivery and upstream readiness have both completed. */
|
|
15
|
+
readonly ready?: boolean;
|
|
16
|
+
/** In-process identity only; never serialized or sent to a replica owner. */
|
|
17
|
+
readonly subscription?: object;
|
|
18
|
+
}
|
|
19
|
+
/** Read existing acquisitions without starting sync, acquiring demand, or reading rows. */
|
|
20
|
+
export declare const getCollectionDemands: (collection: object) => readonly CollectionDemandDiagnostic[];
|
|
21
|
+
export declare function registerCollectionDemands(collection: object, read: () => readonly CollectionDemandDiagnostic[]): () => void;
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","names":["Query"],"sources":["../../src/tanstack/diagnostics.ts"],"mappings":";;;iBAGiB;WACJ;WACA,QAAQA;;WAER,YAAY,KAAK;WACjB;WACA;WACA;;WAEA;;WAEA;;WAEA;;;qBAIA,uBAAoB,gCAAkC;wBAGnD,0BACZ,oBACA,qBAAqB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/tanstack/diagnostics.ts
|
|
2
|
+
const readers = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
/** Read existing acquisitions without starting sync, acquiring demand, or reading rows. */
|
|
4
|
+
const getCollectionDemands = (collection) => readers.get(collection)?.() ?? [];
|
|
5
|
+
function registerCollectionDemands(collection, read) {
|
|
6
|
+
readers.set(collection, read);
|
|
7
|
+
return () => {
|
|
8
|
+
if (readers.get(collection) === read) readers.delete(collection);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getCollectionDemands, registerCollectionDemands };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","names":[],"sources":["../../src/tanstack/diagnostics.ts"],"sourcesContent":["import type { Query } from \"@party-stack/ontology-storage\";\nimport type { LoadSubsetOptions } from \"@tanstack/db\";\n\nexport interface CollectionDemandDiagnostic {\n readonly objectType: string;\n readonly query?: Query;\n /** Tab-local source demand before storage translation; never sent to the backend. */\n readonly requested?: Pick<LoadSubsetOptions, \"where\" | \"orderBy\" | \"limit\" | \"offset\" | \"cursor\">;\n readonly exact?: boolean;\n readonly filterExact?: boolean;\n readonly orderExact?: boolean;\n /** Whether this acquisition has delivered its first local snapshot. */\n readonly received?: boolean;\n /** Whether local delivery and upstream readiness have both completed. */\n readonly ready?: boolean;\n /** In-process identity only; never serialized or sent to a replica owner. */\n readonly subscription?: object;\n}\nconst readers = new WeakMap<object, () => readonly CollectionDemandDiagnostic[]>();\n/** Read existing acquisitions without starting sync, acquiring demand, or reading rows. */\nexport const getCollectionDemands = (collection: object): readonly CollectionDemandDiagnostic[] =>\n readers.get(collection)?.() ?? [];\n\nexport function registerCollectionDemands(\n collection: object,\n read: () => readonly CollectionDemandDiagnostic[]\n) {\n readers.set(collection, read);\n return () => {\n if (readers.get(collection) === read) readers.delete(collection);\n };\n}\n"],"mappings":";AAkBA,MAAM,0BAAU,IAAI,QAA6D;;AAEjF,MAAa,wBAAwB,eACjC,QAAQ,IAAI,UAAU,CAAC,GAAG,KAAK,CAAC;AAEpC,SAAgB,0BACZ,YACA,MACF;CACE,QAAQ,IAAI,YAAY,IAAI;CAC5B,aAAa;EACT,IAAI,QAAQ,IAAI,UAAU,MAAM,MAAM,QAAQ,OAAO,UAAU;CACnE;AACJ"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OntologyCollectionDescriptors, OntologyLinkDefinitions, ontologyCollections } from "./descriptors.js";
|
|
2
|
+
import { CollectionDemandDiagnostic, getCollectionDemands } from "./diagnostics.js";
|
|
3
|
+
import { localCollectionOptions, makeLocalCollection, makeReplicatedCollection, persistedCollectionOptions, replicatedCollectionOptions, scopedCollection } from "./collections.js";
|
|
4
|
+
import { createLocalCollection } from "./createLocalCollection.js";
|
|
5
|
+
import { storageSubset } from "./subset.js";
|
|
6
|
+
export { type CollectionDemandDiagnostic, type OntologyCollectionDescriptors, type OntologyLinkDefinitions, createLocalCollection, getCollectionDemands, localCollectionOptions, makeLocalCollection, makeReplicatedCollection, ontologyCollections, persistedCollectionOptions, replicatedCollectionOptions, scopedCollection, storageSubset };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ontologyCollections } from "./descriptors.js";
|
|
2
|
+
import { getCollectionDemands } from "./diagnostics.js";
|
|
3
|
+
import { storageSubset } from "./subset.js";
|
|
4
|
+
import { localCollectionOptions, makeLocalCollection, makeReplicatedCollection, persistedCollectionOptions, replicatedCollectionOptions, scopedCollection } from "./collections.js";
|
|
5
|
+
import { createLocalCollection } from "./createLocalCollection.js";
|
|
6
|
+
export { createLocalCollection, getCollectionDemands, localCollectionOptions, makeLocalCollection, makeReplicatedCollection, ontologyCollections, persistedCollectionOptions, replicatedCollectionOptions, scopedCollection, storageSubset };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RuntimeService } from "@party-stack/runtime";
|
|
2
|
+
import { Scope } from "effect";
|
|
3
|
+
import { Collection } from "@tanstack/db";
|
|
4
|
+
//#region src/tanstack/localCollection.d.ts
|
|
5
|
+
/** Synchronous application boundary; storage acquisition and all work stay in the runtime's scope. */
|
|
6
|
+
export declare function createEffectLocalCollection<A extends object, K extends string | number>(options: {
|
|
7
|
+
name: string;
|
|
8
|
+
getKey: (value: A) => K;
|
|
9
|
+
runtime: RuntimeService;
|
|
10
|
+
schemaVersion?: number;
|
|
11
|
+
scope: Scope.Scope;
|
|
12
|
+
}): Collection<A, K>;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=localCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localCollection.d.ts","names":[],"sources":["../../src/tanstack/localCollection.ts"],"mappings":";;;;;wBAQgB,4BAA4B,kBAAkB,2BAA2B;EACrF;EACA,SAAS,OAAO,MAAM;EACtB,SAAS;EACT;EACA,OAAO,MAAM;IACb,WAAW,GAAG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { localCollectionOptions } from "./collections.js";
|
|
2
|
+
import { Runtime } from "@party-stack/runtime";
|
|
3
|
+
import { Context, Effect, Exit, Scope } from "effect";
|
|
4
|
+
import { BasicIndex, createCollection } from "@tanstack/db";
|
|
5
|
+
//#region src/tanstack/localCollection.ts
|
|
6
|
+
/** Synchronous application boundary; storage acquisition and all work stay in the runtime's scope. */
|
|
7
|
+
function createEffectLocalCollection(options) {
|
|
8
|
+
const managed = { runPromise: Effect.runPromiseWith(Context.make(Runtime, options.runtime)) };
|
|
9
|
+
let closed = false;
|
|
10
|
+
let collection;
|
|
11
|
+
const initialized = managed.runPromise(Effect.gen(function* () {
|
|
12
|
+
const scope = yield* Scope.fork(options.scope);
|
|
13
|
+
yield* Scope.addFinalizer(scope, Effect.promise(async () => {
|
|
14
|
+
if (closed) return;
|
|
15
|
+
closed = true;
|
|
16
|
+
await collection.cleanup({ dependents: true });
|
|
17
|
+
}));
|
|
18
|
+
const config = yield* Scope.provide(localCollectionOptions(options), scope);
|
|
19
|
+
if (closed) yield* Scope.close(scope, Exit.void);
|
|
20
|
+
return {
|
|
21
|
+
scope,
|
|
22
|
+
config
|
|
23
|
+
};
|
|
24
|
+
}));
|
|
25
|
+
initialized.catch(() => void 0);
|
|
26
|
+
const config = {
|
|
27
|
+
id: `party-stack:${options.runtime.owner}:${options.runtime.namespace}:${options.name}`,
|
|
28
|
+
getKey: options.getKey,
|
|
29
|
+
defaultIndexType: BasicIndex,
|
|
30
|
+
autoIndex: "eager",
|
|
31
|
+
syncMode: "on-demand",
|
|
32
|
+
startSync: true,
|
|
33
|
+
onInsert: async (args) => (await initialized).config.onInsert(args),
|
|
34
|
+
onUpdate: async (args) => (await initialized).config.onUpdate(args),
|
|
35
|
+
onDelete: async (args) => (await initialized).config.onDelete(args),
|
|
36
|
+
sync: {
|
|
37
|
+
rowUpdateMode: "full",
|
|
38
|
+
sync: (args) => {
|
|
39
|
+
let alive = true;
|
|
40
|
+
const started = initialized.then(({ config }) => {
|
|
41
|
+
if (closed || !alive) return void 0;
|
|
42
|
+
return config.sync.sync(args);
|
|
43
|
+
});
|
|
44
|
+
started.catch((error) => {
|
|
45
|
+
if (alive && !closed) args.fail(error);
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
loadSubset: async (subset) => {
|
|
49
|
+
const sync = await started;
|
|
50
|
+
if (sync && typeof sync === "object") await sync.loadSubset?.(subset);
|
|
51
|
+
},
|
|
52
|
+
unloadSubset: (subset) => {
|
|
53
|
+
started.then((sync) => {
|
|
54
|
+
if (sync && typeof sync === "object") sync.unloadSubset?.(subset);
|
|
55
|
+
}).catch(() => void 0);
|
|
56
|
+
},
|
|
57
|
+
cleanup: async () => {
|
|
58
|
+
alive = false;
|
|
59
|
+
const sync = await started;
|
|
60
|
+
if (typeof sync === "function") await sync();
|
|
61
|
+
else await sync?.cleanup?.();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
collection = createCollection(config);
|
|
68
|
+
return collection;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { createEffectLocalCollection };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=localCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localCollection.js","names":[],"sources":["../../src/tanstack/localCollection.ts"],"sourcesContent":["import { Runtime } from \"@party-stack/runtime\";\nimport { BasicIndex, createCollection } from \"@tanstack/db\";\nimport { Context, Effect, Exit, Scope } from \"effect\";\nimport { localCollectionOptions } from \"./collections.js\";\nimport type { RuntimeService } from \"@party-stack/runtime\";\nimport type { Collection, CollectionConfig } from \"@tanstack/db\";\n\n/** Synchronous application boundary; storage acquisition and all work stay in the runtime's scope. */\nexport function createEffectLocalCollection<A extends object, K extends string | number>(options: {\n name: string;\n getKey: (value: A) => K;\n runtime: RuntimeService;\n schemaVersion?: number;\n scope: Scope.Scope;\n}): Collection<A, K> {\n const managed = { runPromise: Effect.runPromiseWith(Context.make(Runtime, options.runtime)) };\n let closed = false;\n let collection: Collection<A, K>;\n const initialized = managed.runPromise(\n Effect.gen(function* () {\n const scope = yield* Scope.fork(options.scope);\n yield* Scope.addFinalizer(\n scope,\n Effect.promise(async () => {\n if (closed) return;\n closed = true;\n await collection.cleanup({ dependents: true });\n })\n );\n const config = yield* Scope.provide(localCollectionOptions<A, K>(options), scope);\n if (closed) yield* Scope.close(scope, Exit.void);\n return { scope, config };\n })\n );\n // Consumers see initialization failures through query and mutation promises.\n void initialized.catch(() => undefined);\n const config: CollectionConfig<A, K> = {\n id: `party-stack:${options.runtime.owner}:${options.runtime.namespace}:${options.name}`,\n getKey: options.getKey,\n defaultIndexType: BasicIndex,\n autoIndex: \"eager\",\n syncMode: \"on-demand\",\n startSync: true,\n onInsert: async (args) => (await initialized).config.onInsert!(args),\n onUpdate: async (args) => (await initialized).config.onUpdate!(args),\n onDelete: async (args) => (await initialized).config.onDelete!(args),\n sync: {\n rowUpdateMode: \"full\",\n sync: (args) => {\n let alive = true;\n const started = initialized.then(({ config }) => {\n if (closed || !alive) return undefined;\n return config.sync.sync(args);\n });\n void started.catch((error) => {\n if (alive && !closed) args.fail(error);\n });\n return {\n loadSubset: async (subset) => {\n const sync = await started;\n if (sync && typeof sync === \"object\") await sync.loadSubset?.(subset);\n },\n unloadSubset: (subset) => {\n void started\n .then((sync) => {\n if (sync && typeof sync === \"object\") sync.unloadSubset?.(subset);\n })\n .catch(() => undefined);\n },\n cleanup: async () => {\n alive = false;\n const sync = await started;\n if (typeof sync === \"function\") await sync();\n else await sync?.cleanup?.();\n },\n };\n },\n },\n };\n collection = createCollection(config);\n return collection;\n}\n"],"mappings":";;;;;;AAQA,SAAgB,4BAAyE,SAMpE;CACjB,MAAM,UAAU,EAAE,YAAY,OAAO,eAAe,QAAQ,KAAK,SAAS,QAAQ,OAAO,CAAC,EAAE;CAC5F,IAAI,SAAS;CACb,IAAI;CACJ,MAAM,cAAc,QAAQ,WACxB,OAAO,IAAI,aAAa;EACpB,MAAM,QAAQ,OAAO,MAAM,KAAK,QAAQ,KAAK;EAC7C,OAAO,MAAM,aACT,OACA,OAAO,QAAQ,YAAY;GACvB,IAAI,QAAQ;GACZ,SAAS;GACT,MAAM,WAAW,QAAQ,EAAE,YAAY,KAAK,CAAC;EACjD,CAAC,CACL;EACA,MAAM,SAAS,OAAO,MAAM,QAAQ,uBAA6B,OAAO,GAAG,KAAK;EAChF,IAAI,QAAQ,OAAO,MAAM,MAAM,OAAO,KAAK,IAAI;EAC/C,OAAO;GAAE;GAAO;EAAO;CAC3B,CAAC,CACL;CAEA,YAAiB,YAAY,KAAA,CAAS;CACtC,MAAM,SAAiC;EACnC,IAAI,eAAe,QAAQ,QAAQ,MAAM,GAAG,QAAQ,QAAQ,UAAU,GAAG,QAAQ;EACjF,QAAQ,QAAQ;EAChB,kBAAkB;EAClB,WAAW;EACX,UAAU;EACV,WAAW;EACX,UAAU,OAAO,UAAU,MAAM,YAAA,CAAa,OAAO,SAAU,IAAI;EACnE,UAAU,OAAO,UAAU,MAAM,YAAA,CAAa,OAAO,SAAU,IAAI;EACnE,UAAU,OAAO,UAAU,MAAM,YAAA,CAAa,OAAO,SAAU,IAAI;EACnE,MAAM;GACF,eAAe;GACf,OAAO,SAAS;IACZ,IAAI,QAAQ;IACZ,MAAM,UAAU,YAAY,MAAM,EAAE,aAAa;KAC7C,IAAI,UAAU,CAAC,OAAO,OAAO,KAAA;KAC7B,OAAO,OAAO,KAAK,KAAK,IAAI;IAChC,CAAC;IACD,QAAa,OAAO,UAAU;KAC1B,IAAI,SAAS,CAAC,QAAQ,KAAK,KAAK,KAAK;IACzC,CAAC;IACD,OAAO;KACH,YAAY,OAAO,WAAW;MAC1B,MAAM,OAAO,MAAM;MACnB,IAAI,QAAQ,OAAO,SAAS,UAAU,MAAM,KAAK,aAAa,MAAM;KACxE;KACA,eAAe,WAAW;MACtB,QACK,MAAM,SAAS;OACZ,IAAI,QAAQ,OAAO,SAAS,UAAU,KAAK,eAAe,MAAM;MACpE,CAAC,CAAC,CACD,YAAY,KAAA,CAAS;KAC9B;KACA,SAAS,YAAY;MACjB,QAAQ;MACR,MAAM,OAAO,MAAM;MACnB,IAAI,OAAO,SAAS,YAAY,MAAM,KAAK;WACtC,MAAM,MAAM,UAAU;KAC/B;IACJ;GACJ;EACJ;CACJ;CACA,aAAa,iBAAiB,MAAM;CACpC,OAAO;AACX"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LoadSubsetOptions } from "@tanstack/db";
|
|
2
|
+
import { OntologyIR, Subset } from "@party-stack/ontology-spec";
|
|
3
|
+
import { ObjectSubset } from "@party-stack/ontology-spec/query";
|
|
4
|
+
import { Query as Query$1 } from "@party-stack/ontology-storage";
|
|
5
|
+
//#region src/tanstack/subset.d.ts
|
|
6
|
+
/** Translate TanStack semantics into the shared ontology expression IR. Unsupported expressions
|
|
7
|
+
* widen demand; TanStack still evaluates the original query on the returned rows.
|
|
8
|
+
* In particular, a residual filter or locale comparator must run before LIMIT.
|
|
9
|
+
*/
|
|
10
|
+
export declare function analyzeOntologySubset(subset: LoadSubsetOptions, ir?: OntologyIR, objectType?: string): {
|
|
11
|
+
subset: Subset;
|
|
12
|
+
exact: boolean;
|
|
13
|
+
filterExact: boolean;
|
|
14
|
+
orderExact: boolean;
|
|
15
|
+
orderedWindowExact: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function analyzeStorageSubset(subset: LoadSubsetOptions, ir?: OntologyIR, objectType?: string): {
|
|
18
|
+
subset: Subset;
|
|
19
|
+
exact: boolean;
|
|
20
|
+
filterExact: boolean;
|
|
21
|
+
orderExact: boolean;
|
|
22
|
+
orderedWindowExact: boolean;
|
|
23
|
+
query: Query$1;
|
|
24
|
+
};
|
|
25
|
+
export declare function storageSubset(subset: LoadSubsetOptions, ir?: OntologyIR, objectType?: string): Query$1;
|
|
26
|
+
export declare function ontologySubset(subset: LoadSubsetOptions, ir: OntologyIR, objectType: string): ObjectSubset;
|
|
27
|
+
//#endregion
|
|
28
|
+
//# sourceMappingURL=subset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subset.d.ts","names":["Query"],"sources":["../../src/tanstack/subset.ts"],"mappings":";;;;;;;;;wBAgDgB,sBAAsB,QAAQ,mBAAmB,KAAK,YAAY;;;;;;;wBAqSlE,qBAAqB,QAAQ,mBAAmB,KAAK,YAAY;;;;;;;;wBAIjE,cAAc,QAAQ,mBAAmB,KAAK,YAAY,sBAAsBA;wBAGhF,eAAe,QAAQ,mBAAmB,IAAI,YAAY,qBAAqB"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { IR } from "@tanstack/db";
|
|
2
|
+
import * as q from "@party-stack/ontology-spec/query";
|
|
3
|
+
//#region src/tanstack/subset.ts
|
|
4
|
+
const field = (...path) => q.field("row", ...path);
|
|
5
|
+
const isField = (value) => value.kind === "getAt";
|
|
6
|
+
const unknown = {
|
|
7
|
+
yes: true,
|
|
8
|
+
no: true,
|
|
9
|
+
exact: false
|
|
10
|
+
};
|
|
11
|
+
const combine = (op, values) => {
|
|
12
|
+
const terminal = op === "or";
|
|
13
|
+
if (values.includes(terminal)) return terminal;
|
|
14
|
+
const predicates = values.filter((value) => typeof value !== "boolean");
|
|
15
|
+
return predicates.length === 0 ? !terminal : predicates.length === 1 ? predicates[0] : q[op](...predicates);
|
|
16
|
+
};
|
|
17
|
+
const predicate = (value) => value === true ? void 0 : value === false ? q.or() : value;
|
|
18
|
+
const negate = (value) => typeof value === "boolean" ? !value : q.not(value);
|
|
19
|
+
/** Translate TanStack semantics into the shared ontology expression IR. Unsupported expressions
|
|
20
|
+
* widen demand; TanStack still evaluates the original query on the returned rows.
|
|
21
|
+
* In particular, a residual filter or locale comparator must run before LIMIT.
|
|
22
|
+
*/
|
|
23
|
+
function analyzeOntologySubset(subset, ir, objectType) {
|
|
24
|
+
const objects = new Map(ir?.objectTypes.map((type) => [type.name, type]));
|
|
25
|
+
const named = new Map(ir?.types.map((type) => [type.name, type.type]));
|
|
26
|
+
const resolve = (type, path, optional = false, seen = /* @__PURE__ */ new Set()) => {
|
|
27
|
+
if (!type || seen.has(type)) return void 0;
|
|
28
|
+
const next = /* @__PURE__ */ new Set([...seen, type]);
|
|
29
|
+
if (type.kind === "optional") return resolve(type.value.type, path, true, next);
|
|
30
|
+
if (type.kind === "ref") return resolve(named.get(type.value.name), path, optional, next);
|
|
31
|
+
if (type.kind === "objectReference") {
|
|
32
|
+
const object = objects.get(type.value.objectType);
|
|
33
|
+
return resolve(object?.properties.find((prop) => prop.name === object.primaryKey)?.type, path, optional, next);
|
|
34
|
+
}
|
|
35
|
+
if (path.length) return type.kind === "struct" ? resolve(type.value.fields.find((prop) => prop.name === path[0])?.type, path.slice(1), optional, next) : void 0;
|
|
36
|
+
if (type.kind === "list") return {
|
|
37
|
+
elementFamily: resolve(type.value.elementType, [], false, next)?.family,
|
|
38
|
+
optional
|
|
39
|
+
};
|
|
40
|
+
switch (type.kind) {
|
|
41
|
+
case "string":
|
|
42
|
+
case "boolean":
|
|
43
|
+
case "date":
|
|
44
|
+
case "timestamp": return {
|
|
45
|
+
family: type.kind,
|
|
46
|
+
optional
|
|
47
|
+
};
|
|
48
|
+
case "integer":
|
|
49
|
+
case "float":
|
|
50
|
+
case "double": return {
|
|
51
|
+
family: "number",
|
|
52
|
+
optional
|
|
53
|
+
};
|
|
54
|
+
default: return;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const value = (expression) => {
|
|
58
|
+
if (expression.type === "ref") {
|
|
59
|
+
const path = IR.getPropRefPropertyPath(expression);
|
|
60
|
+
if (!path.length) return void 0;
|
|
61
|
+
const type = objects.get(objectType ?? "")?.properties.find((prop) => prop.name === path[0])?.type;
|
|
62
|
+
const resolved = resolve(type, path.slice(1));
|
|
63
|
+
return resolved && {
|
|
64
|
+
operand: field(...path),
|
|
65
|
+
...resolved
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (expression.type !== "val") return void 0;
|
|
69
|
+
const literal = expression.value;
|
|
70
|
+
if (literal == null) return {
|
|
71
|
+
operand: q.literal(literal),
|
|
72
|
+
optional: true
|
|
73
|
+
};
|
|
74
|
+
if (typeof literal === "string" || typeof literal === "boolean") return {
|
|
75
|
+
operand: q.literal(literal),
|
|
76
|
+
family: typeof literal,
|
|
77
|
+
optional: false
|
|
78
|
+
};
|
|
79
|
+
if (typeof literal === "number" && Number.isFinite(literal)) return {
|
|
80
|
+
operand: q.literal(literal),
|
|
81
|
+
family: "number",
|
|
82
|
+
optional: false
|
|
83
|
+
};
|
|
84
|
+
if (typeof literal === "object") {
|
|
85
|
+
const tag = Reflect.get(literal, Symbol.toStringTag);
|
|
86
|
+
if (tag === "Temporal.Instant" || tag === "Temporal.PlainDate") return {
|
|
87
|
+
operand: q.literal(literal),
|
|
88
|
+
family: tag === "Temporal.Instant" ? "timestamp" : "date",
|
|
89
|
+
optional: false
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const present = (v) => !v.optional ? true : isField(v.operand) ? q.ne(v.operand, q.literal(void 0)) : false;
|
|
94
|
+
const truth = (expression) => {
|
|
95
|
+
if (expression.type === "val" && (typeof expression.value === "boolean" || expression.value == null)) return {
|
|
96
|
+
yes: expression.value === true,
|
|
97
|
+
no: expression.value === false,
|
|
98
|
+
exact: true
|
|
99
|
+
};
|
|
100
|
+
if (expression.type === "ref") {
|
|
101
|
+
const v = value(expression);
|
|
102
|
+
return v?.family === "boolean" ? {
|
|
103
|
+
yes: q.eq(v.operand, q.literal(true)),
|
|
104
|
+
no: q.eq(v.operand, q.literal(false)),
|
|
105
|
+
exact: true
|
|
106
|
+
} : unknown;
|
|
107
|
+
}
|
|
108
|
+
if (expression.type !== "func") return unknown;
|
|
109
|
+
const { name, args } = expression;
|
|
110
|
+
if (name === "and" || name === "or") {
|
|
111
|
+
const children = args.map(truth);
|
|
112
|
+
return {
|
|
113
|
+
yes: combine(name, children.map((c) => c.yes)),
|
|
114
|
+
no: combine(name === "and" ? "or" : "and", children.map((c) => c.no)),
|
|
115
|
+
exact: children.every((c) => c.exact)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (name === "not" && args.length === 1) {
|
|
119
|
+
const child = truth(args[0]);
|
|
120
|
+
return {
|
|
121
|
+
yes: child.no,
|
|
122
|
+
no: child.yes,
|
|
123
|
+
exact: child.exact
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const left = args[0] && value(args[0]);
|
|
127
|
+
if (!left) return unknown;
|
|
128
|
+
if ((name === "isNull" || name === "isUndefined") && args.length === 1) {
|
|
129
|
+
const yes = q.eq(left.operand, q.literal(name === "isNull" ? null : void 0));
|
|
130
|
+
return {
|
|
131
|
+
yes,
|
|
132
|
+
no: negate(yes),
|
|
133
|
+
exact: true
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (left.family === "date" && (name === "eq" || name === "in")) return unknown;
|
|
137
|
+
if (name === "in" && args[1]?.type === "ref") {
|
|
138
|
+
const array = value(args[1]);
|
|
139
|
+
if (!array?.elementFamily || !isField(array.operand)) return unknown;
|
|
140
|
+
if (!left.family) return {
|
|
141
|
+
yes: false,
|
|
142
|
+
no: false,
|
|
143
|
+
exact: true
|
|
144
|
+
};
|
|
145
|
+
if (left.family !== array.elementFamily) return unknown;
|
|
146
|
+
const yes = q.contains(array.operand, left.operand);
|
|
147
|
+
return {
|
|
148
|
+
yes: combine("and", [present(left), yes]),
|
|
149
|
+
no: combine("and", [present(left), negate(yes)]),
|
|
150
|
+
exact: true
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (name === "in" && args[1]?.type === "val" && Array.isArray(args[1].value)) {
|
|
154
|
+
const items = args[1].value.filter((item) => item != null).map((item) => value(new IR.Value(item)));
|
|
155
|
+
if (items.some((item) => !item || item.family !== left.family)) return unknown;
|
|
156
|
+
const yes = q.inArray(left.operand, q.literal(items.map((item) => item.operand.value.value)));
|
|
157
|
+
return {
|
|
158
|
+
yes: combine("and", [present(left), yes]),
|
|
159
|
+
no: combine("and", [present(left), negate(yes)]),
|
|
160
|
+
exact: true
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (![
|
|
164
|
+
"eq",
|
|
165
|
+
"gt",
|
|
166
|
+
"gte",
|
|
167
|
+
"lt",
|
|
168
|
+
"lte",
|
|
169
|
+
"like",
|
|
170
|
+
"ilike"
|
|
171
|
+
].includes(name)) return unknown;
|
|
172
|
+
const right = args[1] && value(args[1]);
|
|
173
|
+
if (!right || args.length !== 2) return unknown;
|
|
174
|
+
if (!left.family || !right.family) return {
|
|
175
|
+
yes: false,
|
|
176
|
+
no: false,
|
|
177
|
+
exact: true
|
|
178
|
+
};
|
|
179
|
+
if (left.family !== right.family) return unknown;
|
|
180
|
+
const guard = combine("and", [present(left), present(right)]);
|
|
181
|
+
let yes;
|
|
182
|
+
if (name === "eq" || name === "gt" || name === "gte" || name === "lt" || name === "lte") yes = q[name](left.operand, right.operand);
|
|
183
|
+
else if ((name === "like" || name === "ilike") && left.family === "string") yes = q[name](left.operand, right.operand);
|
|
184
|
+
else return unknown;
|
|
185
|
+
return {
|
|
186
|
+
yes: name === "eq" && (!left.optional || !right.optional) ? yes : combine("and", [guard, yes]),
|
|
187
|
+
no: combine("and", [guard, negate(yes)]),
|
|
188
|
+
exact: true
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const filter = subset.where ? truth(subset.where) : {
|
|
192
|
+
yes: true,
|
|
193
|
+
exact: true
|
|
194
|
+
};
|
|
195
|
+
const cursor = subset.cursor ? truth(new IR.Func("or", [subset.cursor.whereFrom, subset.cursor.whereCurrent])) : void 0;
|
|
196
|
+
const orderBy = [];
|
|
197
|
+
let ordered = true;
|
|
198
|
+
let homogeneousOrder = true;
|
|
199
|
+
for (const order of subset.orderBy ?? []) {
|
|
200
|
+
const v = value(order.expression);
|
|
201
|
+
const compare = order.compareOptions;
|
|
202
|
+
homogeneousOrder &&= !!v?.family && (compare.nulls === "first" || compare.nulls === "last");
|
|
203
|
+
if (order.expression.type !== "ref" || !v || compare.stringSort === "custom" || v.family === "string" && compare.stringSort !== "lexical") {
|
|
204
|
+
ordered = false;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
orderBy.push({
|
|
208
|
+
expression: v.operand,
|
|
209
|
+
direction: compare.direction,
|
|
210
|
+
nulls: compare.nulls
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
const bounded = filter.exact && ordered && !cursor;
|
|
214
|
+
const limit = bounded && subset.limit !== void 0 ? subset.limit + (subset.offset ?? 0) : void 0;
|
|
215
|
+
const finalOrder = subset.orderBy?.at(-1)?.expression;
|
|
216
|
+
const finalPath = finalOrder?.type === "ref" ? IR.getPropRefPropertyPath(finalOrder) : [];
|
|
217
|
+
const finalValue = finalOrder && value(finalOrder);
|
|
218
|
+
const orderedWindowExact = bounded && homogeneousOrder && subset.limit !== void 0 && Number.isSafeInteger(subset.limit) && subset.limit >= 0 && limit !== void 0 && Number.isSafeInteger(limit) && limit >= 0 && Number.isSafeInteger(subset.offset ?? 0) && (subset.offset ?? 0) >= 0 && finalPath.length === 1 && finalPath[0] === objects.get(objectType ?? "")?.primaryKey && !!finalValue && !finalValue.optional && (finalValue.family === "string" || finalValue.family === "number");
|
|
219
|
+
return {
|
|
220
|
+
subset: {
|
|
221
|
+
where: predicate(combine("and", [filter.yes, cursor?.yes ?? true])),
|
|
222
|
+
...ordered && orderBy.length ? { orderBy } : {},
|
|
223
|
+
...limit !== void 0 && Number.isSafeInteger(limit) ? { page: { limit } } : {}
|
|
224
|
+
},
|
|
225
|
+
exact: filter.exact && ordered && !cursor,
|
|
226
|
+
filterExact: filter.exact,
|
|
227
|
+
orderExact: ordered,
|
|
228
|
+
orderedWindowExact
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/** Raw Tables/transaction adapter. Only serializes nodes constructed by the analyzer above. */
|
|
232
|
+
function storageScan(subset) {
|
|
233
|
+
const operand = (e) => e.kind === "getAt" ? {
|
|
234
|
+
_tag: "Field",
|
|
235
|
+
path: e.value.path
|
|
236
|
+
} : e.value.value;
|
|
237
|
+
const predicate = (e) => {
|
|
238
|
+
if (e.kind === "and" || e.kind === "or") return {
|
|
239
|
+
op: e.kind,
|
|
240
|
+
predicates: e.value.expressions.map(predicate)
|
|
241
|
+
};
|
|
242
|
+
if (e.kind === "not") return {
|
|
243
|
+
op: "not",
|
|
244
|
+
predicate: predicate(e.value.expression)
|
|
245
|
+
};
|
|
246
|
+
if (e.kind === "in") return {
|
|
247
|
+
op: "in",
|
|
248
|
+
left: operand(e.value.left),
|
|
249
|
+
values: e.value.right.value.value
|
|
250
|
+
};
|
|
251
|
+
const binary = e;
|
|
252
|
+
return {
|
|
253
|
+
op: binary.kind,
|
|
254
|
+
left: operand(binary.value.left),
|
|
255
|
+
right: operand(binary.value.right)
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
return {
|
|
259
|
+
where: subset.where ? predicate(subset.where) : void 0,
|
|
260
|
+
...subset.orderBy ? { orderBy: subset.orderBy.map((o) => ({
|
|
261
|
+
field: operand(o.expression),
|
|
262
|
+
direction: o.direction,
|
|
263
|
+
nulls: o.nulls
|
|
264
|
+
})) } : {},
|
|
265
|
+
...subset.page?.limit !== void 0 ? { limit: subset.page.limit } : {}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function analyzeStorageSubset(subset, ir, objectType) {
|
|
269
|
+
const analysis = analyzeOntologySubset(subset, ir, objectType);
|
|
270
|
+
return {
|
|
271
|
+
...analysis,
|
|
272
|
+
query: storageScan(analysis.subset)
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function storageSubset(subset, ir, objectType) {
|
|
276
|
+
return analyzeStorageSubset(subset, ir, objectType).query;
|
|
277
|
+
}
|
|
278
|
+
function ontologySubset(subset, ir, objectType) {
|
|
279
|
+
return {
|
|
280
|
+
from: {
|
|
281
|
+
source: { objectType },
|
|
282
|
+
binding: "row"
|
|
283
|
+
},
|
|
284
|
+
...analyzeOntologySubset(subset, ir, objectType).subset
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
export { analyzeOntologySubset, analyzeStorageSubset, ontologySubset, storageSubset };
|
|
289
|
+
|
|
290
|
+
//# sourceMappingURL=subset.js.map
|