@coasys/ad4m 0.12.1-dev → 0.13.0-postmessage-ws-proxy.3
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 +2 -25
- package/jest-setup.ts +1 -1
- package/lib/index.cjs +8677 -15318
- package/lib/index.js +14507 -21223
- package/lib/src/Ad4mClient.d.ts +9 -3
- package/lib/src/Ad4mClient.js +40 -13
- package/lib/src/Literal.js +6 -5
- package/lib/src/agent/Agent.js +26 -272
- package/lib/src/agent/AgentClient.d.ts +33 -21
- package/lib/src/agent/AgentClient.js +180 -374
- package/lib/src/agent/AgentStatus.js +2 -37
- package/lib/src/ai/AIClient.d.ts +12 -4
- package/lib/src/ai/AIClient.js +81 -285
- package/lib/src/ai/AITypes.d.ts +55 -0
- package/lib/src/ai/AITypes.js +18 -0
- package/lib/src/ai/Tasks.js +10 -133
- package/lib/src/apiClient.d.ts +53 -0
- package/lib/src/apiClient.js +234 -0
- package/lib/src/cache/PersistentCache.d.ts +40 -0
- package/lib/src/cache/PersistentCache.js +139 -0
- package/lib/src/expression/Expression.d.ts +1 -1
- package/lib/src/expression/Expression.js +13 -122
- package/lib/src/expression/ExpressionClient.d.ts +11 -3
- package/lib/src/expression/ExpressionClient.js +120 -75
- package/lib/src/expression/ExpressionRef.js +4 -27
- package/lib/src/generated/api/AIModelLoadingStatus.d.ts +7 -0
- package/lib/src/generated/api/AIModelLoadingStatus.js +2 -0
- package/lib/src/generated/api/AddLinkExpressionRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinkExpressionRequest.js +1 -0
- package/lib/src/generated/api/AddLinkRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinkRequest.js +1 -0
- package/lib/src/generated/api/AddLinksBulkRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinksBulkRequest.js +1 -0
- package/lib/src/generated/api/AddSdnaRequest.d.ts +6 -0
- package/lib/src/generated/api/AddSdnaRequest.js +2 -0
- package/lib/src/generated/api/ApplyTemplateRequest.d.ts +4 -0
- package/lib/src/generated/api/ApplyTemplateRequest.js +2 -0
- package/lib/src/generated/api/AuthInfoInput.d.ts +10 -0
- package/lib/src/generated/api/AuthInfoInput.js +1 -0
- package/lib/src/generated/api/CapabilityInput.d.ts +5 -0
- package/lib/src/generated/api/CapabilityInput.js +1 -0
- package/lib/src/generated/api/CommitBatchRequest.d.ts +3 -0
- package/lib/src/generated/api/CommitBatchRequest.js +2 -0
- package/lib/src/generated/api/ComputeLogEntry.d.ts +9 -0
- package/lib/src/generated/api/ComputeLogEntry.js +2 -0
- package/lib/src/generated/api/CreateExpressionRequest.d.ts +4 -0
- package/lib/src/generated/api/CreateExpressionRequest.js +2 -0
- package/lib/src/generated/api/CreatePerspectiveRequest.d.ts +3 -0
- package/lib/src/generated/api/CreatePerspectiveRequest.js +2 -0
- package/lib/src/generated/api/CreateSubjectRequest.d.ts +6 -0
- package/lib/src/generated/api/CreateSubjectRequest.js +2 -0
- package/lib/src/generated/api/EmbedRequest.d.ts +4 -0
- package/lib/src/generated/api/EmbedRequest.js +2 -0
- package/lib/src/generated/api/EntanglementProofInput.d.ts +6 -0
- package/lib/src/generated/api/EntanglementProofInput.js +2 -0
- package/lib/src/generated/api/ExecuteCommandsRequest.d.ts +4 -0
- package/lib/src/generated/api/ExecuteCommandsRequest.js +2 -0
- package/lib/src/generated/api/ExportRequest.d.ts +5 -0
- package/lib/src/generated/api/ExportRequest.js +2 -0
- package/lib/src/generated/api/ExpressionManyRequest.d.ts +3 -0
- package/lib/src/generated/api/ExpressionManyRequest.js +2 -0
- package/lib/src/generated/api/ExpressionProof.d.ts +4 -0
- package/lib/src/generated/api/ExpressionProof.js +2 -0
- package/lib/src/generated/api/ExpressionProofInput.d.ts +6 -0
- package/lib/src/generated/api/ExpressionProofInput.js +2 -0
- package/lib/src/generated/api/FriendSendMessageRequest.d.ts +3 -0
- package/lib/src/generated/api/FriendSendMessageRequest.js +2 -0
- package/lib/src/generated/api/FriendsListRequest.d.ts +3 -0
- package/lib/src/generated/api/FriendsListRequest.js +2 -0
- package/lib/src/generated/api/GenerateAgentRequest.d.ts +3 -0
- package/lib/src/generated/api/GenerateAgentRequest.js +2 -0
- package/lib/src/generated/api/GenerateJwtRequest.d.ts +4 -0
- package/lib/src/generated/api/GenerateJwtRequest.js +2 -0
- package/lib/src/generated/api/GetSubjectDataRequest.d.ts +4 -0
- package/lib/src/generated/api/GetSubjectDataRequest.js +2 -0
- package/lib/src/generated/api/ImportAgentRequest.d.ts +6 -0
- package/lib/src/generated/api/ImportAgentRequest.js +2 -0
- package/lib/src/generated/api/ImportRequest.d.ts +4 -0
- package/lib/src/generated/api/ImportRequest.js +2 -0
- package/lib/src/generated/api/JoinNeighbourhoodRequest.d.ts +3 -0
- package/lib/src/generated/api/JoinNeighbourhoodRequest.js +2 -0
- package/lib/src/generated/api/LanguageMetaInput.d.ts +6 -0
- package/lib/src/generated/api/LanguageMetaInput.js +2 -0
- package/lib/src/generated/api/Link.d.ts +5 -0
- package/lib/src/generated/api/Link.js +2 -0
- package/lib/src/generated/api/LinkExpression.d.ts +10 -0
- package/lib/src/generated/api/LinkExpression.js +1 -0
- package/lib/src/generated/api/LinkExpressionInput.d.ts +10 -0
- package/lib/src/generated/api/LinkExpressionInput.js +1 -0
- package/lib/src/generated/api/LinkInput.d.ts +5 -0
- package/lib/src/generated/api/LinkInput.js +2 -0
- package/lib/src/generated/api/LinkLanguageTemplatesRequest.d.ts +3 -0
- package/lib/src/generated/api/LinkLanguageTemplatesRequest.js +2 -0
- package/lib/src/generated/api/LinkMutations.d.ts +6 -0
- package/lib/src/generated/api/LinkMutations.js +1 -0
- package/lib/src/generated/api/LinkStatus.d.ts +1 -0
- package/lib/src/generated/api/LinkStatus.js +2 -0
- package/lib/src/generated/api/LockAgentRequest.d.ts +3 -0
- package/lib/src/generated/api/LockAgentRequest.js +2 -0
- package/lib/src/generated/api/ModelType.d.ts +1 -0
- package/lib/src/generated/api/ModelType.js +2 -0
- package/lib/src/generated/api/NotificationInput.d.ts +10 -0
- package/lib/src/generated/api/NotificationInput.js +2 -0
- package/lib/src/generated/api/OpenLinkRequest.d.ts +3 -0
- package/lib/src/generated/api/OpenLinkRequest.js +2 -0
- package/lib/src/generated/api/PermitCapabilityRequest.d.ts +3 -0
- package/lib/src/generated/api/PermitCapabilityRequest.js +2 -0
- package/lib/src/generated/api/PerspectiveInput.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveInput.js +1 -0
- package/lib/src/generated/api/PromptRequest.d.ts +4 -0
- package/lib/src/generated/api/PromptRequest.js +2 -0
- package/lib/src/generated/api/PublishLanguageRequest.d.ts +5 -0
- package/lib/src/generated/api/PublishLanguageRequest.js +1 -0
- package/lib/src/generated/api/PublishNeighbourhoodRequest.d.ts +6 -0
- package/lib/src/generated/api/PublishNeighbourhoodRequest.js +1 -0
- package/lib/src/generated/api/QueryRequest.d.ts +7 -0
- package/lib/src/generated/api/QueryRequest.js +2 -0
- package/lib/src/generated/api/RemoveLinkRequest.d.ts +5 -0
- package/lib/src/generated/api/RemoveLinkRequest.js +1 -0
- package/lib/src/generated/api/RemoveLinksBulkRequest.d.ts +5 -0
- package/lib/src/generated/api/RemoveLinksBulkRequest.js +1 -0
- package/lib/src/generated/api/ResourceInput.d.ts +4 -0
- package/lib/src/generated/api/ResourceInput.js +2 -0
- package/lib/src/generated/api/SetDefaultModelRequest.d.ts +4 -0
- package/lib/src/generated/api/SetDefaultModelRequest.js +1 -0
- package/lib/src/generated/api/SetFreeHostingEnabledRequest.d.ts +3 -0
- package/lib/src/generated/api/SetFreeHostingEnabledRequest.js +2 -0
- package/lib/src/generated/api/SetMultiUserRequest.d.ts +3 -0
- package/lib/src/generated/api/SetMultiUserRequest.js +2 -0
- package/lib/src/generated/api/SetStatusRequest.d.ts +3 -0
- package/lib/src/generated/api/SetStatusRequest.js +2 -0
- package/lib/src/generated/api/SignMessageRequest.d.ts +3 -0
- package/lib/src/generated/api/SignMessageRequest.js +2 -0
- package/lib/src/generated/api/TrustedAgentsRequest.d.ts +3 -0
- package/lib/src/generated/api/TrustedAgentsRequest.js +2 -0
- package/lib/src/generated/api/UnlockAgentRequest.d.ts +4 -0
- package/lib/src/generated/api/UnlockAgentRequest.js +2 -0
- package/lib/src/generated/api/UpdateLinkRequest.d.ts +7 -0
- package/lib/src/generated/api/UpdateLinkRequest.js +1 -0
- package/lib/src/generated/api/UpdatePerspectiveRequest.d.ts +3 -0
- package/lib/src/generated/api/UpdatePerspectiveRequest.js +2 -0
- package/lib/src/generated/api/UserStatistics.d.ts +9 -0
- package/lib/src/generated/api/UserStatistics.js +2 -0
- package/lib/src/generated/api/VerificationRequestResult.d.ts +6 -0
- package/lib/src/generated/api/VerificationRequestResult.js +2 -0
- package/lib/src/generated/api/VerifySignatureRequest.d.ts +5 -0
- package/lib/src/generated/api/VerifySignatureRequest.js +2 -0
- package/lib/src/generated/api/WriteSettingsRequest.d.ts +3 -0
- package/lib/src/generated/api/WriteSettingsRequest.js +2 -0
- package/lib/src/generated/api/index.d.ts +42 -0
- package/lib/src/generated/api/index.js +7 -0
- package/lib/src/index.d.ts +8 -2
- package/lib/src/index.js +8 -2
- package/lib/src/jestSetup.d.ts +0 -1
- package/lib/src/jestSetup.js +1 -1
- package/lib/src/language/Icon.js +2 -21
- package/lib/src/language/Language.d.ts +26 -176
- package/lib/src/language/Language.js +32 -72
- package/lib/src/language/LanguageClient.d.ts +2 -2
- package/lib/src/language/LanguageClient.js +15 -105
- package/lib/src/language/LanguageHandle.js +2 -41
- package/lib/src/language/LanguageMeta.js +4 -75
- package/lib/src/language/LanguageRef.js +2 -25
- package/lib/src/links/Links.js +14 -111
- package/lib/src/model/Ad4mModel.d.ts +143 -63
- package/lib/src/model/Ad4mModel.js +583 -425
- package/lib/src/model/Ad4mModel.test.js +1434 -688
- package/lib/src/model/ModelQueryBuilder.d.ts +61 -45
- package/lib/src/model/ModelQueryBuilder.js +315 -157
- package/lib/src/model/Subject.js +6 -6
- package/lib/src/model/decorators.d.ts +36 -8
- package/lib/src/model/decorators.js +41 -14
- package/lib/src/model/hydration-batch.d.ts +34 -0
- package/lib/src/model/hydration-batch.js +147 -0
- package/lib/src/model/hydration-batching.test.d.ts +7 -0
- package/lib/src/model/hydration-batching.test.js +456 -0
- package/lib/src/model/hydration.d.ts +3 -92
- package/lib/src/model/hydration.js +3 -691
- package/lib/src/model/index.d.ts +3 -4
- package/lib/src/model/index.js +3 -4
- package/lib/src/model/json-schema.js +2 -2
- package/lib/src/model/model-manifest.d.ts +41 -0
- package/lib/src/model/model-manifest.js +11 -0
- package/lib/src/model/query-cache.d.ts +30 -0
- package/lib/src/model/query-cache.js +66 -0
- package/lib/src/model/query-cache.test.d.ts +1 -0
- package/lib/src/model/query-cache.test.js +43 -0
- package/lib/src/model/query-common.d.ts +1 -1
- package/lib/src/model/query-common.js +1 -1
- package/lib/src/model/query-sparql-batch.d.ts +17 -0
- package/lib/src/model/query-sparql-batch.js +260 -0
- package/lib/src/model/query-sparql.d.ts +51 -0
- package/lib/src/model/query-sparql.js +466 -0
- package/lib/src/model/query-sparql.test.d.ts +1 -0
- package/lib/src/model/query-sparql.test.js +312 -0
- package/lib/src/model/{surreal-utils.d.ts → query-utils.d.ts} +13 -9
- package/lib/src/model/query-utils.js +189 -0
- package/lib/src/model/relation-filtering.test.js +15 -15
- package/lib/src/model/sdna.js +1 -1
- package/lib/src/model/shacl-gen.js +154 -57
- package/lib/src/model/subscription-delta.test.d.ts +24 -0
- package/lib/src/model/subscription-delta.test.js +180 -0
- package/lib/src/model/subscription-pool.d.ts +39 -0
- package/lib/src/model/subscription-pool.js +165 -0
- package/lib/src/model/types.d.ts +195 -5
- package/lib/src/model/types.js +5 -2
- package/lib/src/neighbourhood/Neighbourhood.js +4 -32
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +3 -3
- package/lib/src/neighbourhood/NeighbourhoodClient.js +40 -203
- package/lib/src/perspectives/LinkQuery.js +2 -42
- package/lib/src/perspectives/Perspective.d.ts +1 -1
- package/lib/src/perspectives/Perspective.js +10 -52
- package/lib/src/perspectives/PerspectiveClient.d.ts +22 -32
- package/lib/src/perspectives/PerspectiveClient.js +188 -454
- package/lib/src/perspectives/PerspectiveClient.test.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveClient.test.js +224 -0
- package/lib/src/perspectives/PerspectiveDiff.js +4 -31
- package/lib/src/perspectives/PerspectiveHandle.js +3 -43
- package/lib/src/perspectives/PerspectiveProxy.d.ts +157 -78
- package/lib/src/perspectives/PerspectiveProxy.js +475 -389
- package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveResolver.js +0 -11
- package/lib/src/perspectives/SparqlBindings.d.ts +47 -0
- package/lib/src/perspectives/SparqlBindings.js +65 -0
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +3 -3
- package/lib/src/perspectives/WakerSubscriptionManager.js +12 -12
- package/lib/src/runtime/RuntimeClient.d.ts +8 -6
- package/lib/src/runtime/RuntimeClient.js +97 -454
- package/lib/src/runtime/RuntimeResolver.d.ts +14 -0
- package/lib/src/runtime/RuntimeResolver.js +84 -0
- package/lib/src/runtime/RuntimeTypes.d.ts +101 -0
- package/lib/src/runtime/RuntimeTypes.js +45 -0
- package/lib/src/schema.gql +14 -1
- package/lib/src/shacl/SHACLFlow.d.ts +1 -1
- package/lib/src/shacl/SHACLFlow.js +9 -9
- package/lib/src/shacl/SHACLShape.d.ts +26 -1
- package/lib/src/shacl/SHACLShape.js +140 -38
- package/lib/src/shacl/SHACLShape.test.js +82 -0
- package/lib/src/typeDefs.js +3 -615
- package/lib/src/utils.d.ts +6 -6
- package/lib/src/utils.js +6 -6
- package/package.json +9 -24
- package/rollup.config.js +0 -7
- package/src/Ad4mClient.test.ts +1192 -1288
- package/src/Ad4mClient.ts +46 -15
- package/src/Literal.test.ts +10 -5
- package/src/Literal.ts +6 -5
- package/src/agent/Agent.ts +0 -99
- package/src/agent/AgentClient.ts +238 -467
- package/src/agent/AgentStatus.ts +0 -12
- package/src/ai/AIClient.ts +96 -296
- package/src/ai/AITypes.ts +66 -0
- package/src/ai/Tasks.ts +0 -52
- package/src/apiClient.ts +287 -0
- package/src/cache/PersistentCache.ts +145 -0
- package/src/cache/cache.test.ts +713 -0
- package/src/expression/Expression.ts +3 -43
- package/src/expression/ExpressionClient.ts +148 -77
- package/src/expression/ExpressionRef.ts +2 -8
- package/src/generated/api/AIModelLoadingStatus.ts +3 -0
- package/src/generated/api/AddLinkExpressionRequest.ts +4 -0
- package/src/generated/api/AddLinkRequest.ts +4 -0
- package/src/generated/api/AddLinksBulkRequest.ts +4 -0
- package/src/generated/api/AddSdnaRequest.ts +3 -0
- package/src/generated/api/ApplyTemplateRequest.ts +3 -0
- package/src/generated/api/AuthInfoInput.ts +4 -0
- package/src/generated/api/CapabilityInput.ts +4 -0
- package/src/generated/api/CommitBatchRequest.ts +3 -0
- package/src/generated/api/ComputeLogEntry.ts +3 -0
- package/src/generated/api/CreateExpressionRequest.ts +3 -0
- package/src/generated/api/CreatePerspectiveRequest.ts +3 -0
- package/src/generated/api/CreateSubjectRequest.ts +3 -0
- package/src/generated/api/EmbedRequest.ts +3 -0
- package/src/generated/api/EntanglementProofInput.ts +3 -0
- package/src/generated/api/ExecuteCommandsRequest.ts +3 -0
- package/src/generated/api/ExportRequest.ts +3 -0
- package/src/generated/api/ExpressionManyRequest.ts +3 -0
- package/src/generated/api/ExpressionProof.ts +3 -0
- package/src/generated/api/ExpressionProofInput.ts +3 -0
- package/src/generated/api/FriendSendMessageRequest.ts +3 -0
- package/src/generated/api/FriendsListRequest.ts +3 -0
- package/src/generated/api/GenerateAgentRequest.ts +3 -0
- package/src/generated/api/GenerateJwtRequest.ts +3 -0
- package/src/generated/api/GetSubjectDataRequest.ts +3 -0
- package/src/generated/api/ImportAgentRequest.ts +3 -0
- package/src/generated/api/ImportRequest.ts +3 -0
- package/src/generated/api/JoinNeighbourhoodRequest.ts +3 -0
- package/src/generated/api/LanguageMetaInput.ts +3 -0
- package/src/generated/api/Link.ts +3 -0
- package/src/generated/api/LinkExpression.ts +6 -0
- package/src/generated/api/LinkExpressionInput.ts +6 -0
- package/src/generated/api/LinkInput.ts +3 -0
- package/src/generated/api/LinkLanguageTemplatesRequest.ts +3 -0
- package/src/generated/api/LinkMutations.ts +5 -0
- package/src/generated/api/LinkStatus.ts +3 -0
- package/src/generated/api/LockAgentRequest.ts +3 -0
- package/src/generated/api/ModelType.ts +3 -0
- package/src/generated/api/NotificationInput.ts +3 -0
- package/src/generated/api/OpenLinkRequest.ts +3 -0
- package/src/generated/api/PermitCapabilityRequest.ts +3 -0
- package/src/generated/api/PerspectiveInput.ts +4 -0
- package/src/generated/api/PromptRequest.ts +3 -0
- package/src/generated/api/PublishLanguageRequest.ts +4 -0
- package/src/generated/api/PublishNeighbourhoodRequest.ts +4 -0
- package/src/generated/api/QueryRequest.ts +6 -0
- package/src/generated/api/RemoveLinkRequest.ts +4 -0
- package/src/generated/api/RemoveLinksBulkRequest.ts +4 -0
- package/src/generated/api/ResourceInput.ts +3 -0
- package/src/generated/api/SetDefaultModelRequest.ts +4 -0
- package/src/generated/api/SetFreeHostingEnabledRequest.ts +3 -0
- package/src/generated/api/SetMultiUserRequest.ts +3 -0
- package/src/generated/api/SetStatusRequest.ts +3 -0
- package/src/generated/api/SignMessageRequest.ts +3 -0
- package/src/generated/api/TrustedAgentsRequest.ts +3 -0
- package/src/generated/api/UnlockAgentRequest.ts +3 -0
- package/src/generated/api/UpdateLinkRequest.ts +5 -0
- package/src/generated/api/UpdatePerspectiveRequest.ts +3 -0
- package/src/generated/api/UserStatistics.ts +3 -0
- package/src/generated/api/VerificationRequestResult.ts +3 -0
- package/src/generated/api/VerifySignatureRequest.ts +3 -0
- package/src/generated/api/WriteSettingsRequest.ts +3 -0
- package/src/generated/api/index.ts +49 -0
- package/src/index.ts +8 -2
- package/src/jestSetup.ts +1 -1
- package/src/language/Icon.ts +0 -4
- package/src/language/Language.ts +51 -248
- package/src/language/LanguageClient.ts +21 -132
- package/src/language/LanguageHandle.ts +0 -14
- package/src/language/LanguageMeta.ts +0 -29
- package/src/language/LanguageRef.ts +0 -7
- package/src/links/Links.ts +0 -37
- package/src/model/Ad4mModel.test.ts +1664 -792
- package/src/model/Ad4mModel.ts +664 -499
- package/src/model/ModelQueryBuilder.ts +362 -183
- package/src/model/decorators.ts +71 -22
- package/src/model/hydration.ts +3 -772
- package/src/model/index.ts +3 -4
- package/src/model/json-schema.ts +2 -2
- package/src/model/query-cache.test.ts +54 -0
- package/src/model/query-cache.ts +79 -0
- package/src/model/query-common.ts +1 -1
- package/src/model/query-sparql.test.ts +376 -0
- package/src/model/query-sparql.ts +504 -0
- package/src/model/query-utils.ts +209 -0
- package/src/model/relation-filtering.test.ts +60 -53
- package/src/model/sdna.ts +1 -1
- package/src/model/shacl-gen.ts +163 -64
- package/src/model/shacl-roundtrip.test.ts +197 -0
- package/src/model/types-typed-query.test.ts +360 -0
- package/src/model/types.ts +256 -5
- package/src/neighbourhood/Neighbourhood.ts +0 -9
- package/src/neighbourhood/NeighbourhoodClient.ts +42 -207
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +34 -36
- package/src/perspectives/LinkQuery.ts +0 -15
- package/src/perspectives/Perspective.ts +1 -12
- package/src/perspectives/PerspectiveClient.test.ts +262 -0
- package/src/perspectives/PerspectiveClient.ts +252 -468
- package/src/perspectives/PerspectiveDiff.ts +0 -8
- package/src/perspectives/PerspectiveHandle.ts +1 -12
- package/src/perspectives/PerspectiveProxy.test.ts +125 -0
- package/src/perspectives/PerspectiveProxy.ts +522 -434
- package/src/perspectives/SparqlBindings.ts +79 -0
- package/src/perspectives/WakerSubscriptionManager.ts +13 -13
- package/src/runtime/RuntimeClient.ts +118 -461
- package/src/runtime/RuntimeTypes.ts +144 -0
- package/src/shacl/SHACLFlow.ts +9 -9
- package/src/shacl/SHACLShape.test.ts +204 -0
- package/src/shacl/SHACLShape.ts +191 -39
- package/src/typeDefs.ts +3 -5
- package/src/utils.ts +6 -6
- package/tsconfig.json +3 -7
- package/lib/src/model/query-surreal.d.ts +0 -44
- package/lib/src/model/query-surreal.js +0 -249
- package/lib/src/model/surreal-utils.js +0 -128
- package/shims/reflect-metadata.ts +0 -0
- package/shims/type-graphql.ts +0 -75
- package/src/PubSub.ts +0 -17
- package/src/agent/AgentResolver.ts +0 -263
- package/src/ai/AIResolver.ts +0 -372
- package/src/buildSchema.ts +0 -43
- package/src/expression/ExpressionResolver.ts +0 -64
- package/src/language/LanguageContext.ts +0 -37
- package/src/language/LanguageResolver.ts +0 -98
- package/src/model/Subject.ts +0 -159
- package/src/model/prolog-facts.ts +0 -145
- package/src/model/query-prolog.ts +0 -148
- package/src/model/query-surreal.ts +0 -280
- package/src/model/surreal-utils.ts +0 -147
- package/src/neighbourhood/NeighbourhoodResolver.ts +0 -100
- package/src/perspectives/PerspectiveResolver.ts +0 -372
- package/src/runtime/RuntimeResolver.ts +0 -691
- package/src/unwrapApolloResult.ts +0 -16
- package/tsconfig-browser.json +0 -82
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscription Pool — deduplicates identical SPARQL subscriptions.
|
|
3
|
+
*
|
|
4
|
+
* When multiple UI components subscribe to the same SPARQL query on the same
|
|
5
|
+
* perspective, the pool shares a single `subscribeQuery()` call and distributes
|
|
6
|
+
* results to all registered callbacks. Hydration happens once per result set,
|
|
7
|
+
* then is shared across all subscribers.
|
|
8
|
+
*
|
|
9
|
+
* Key: `perspectiveUUID + sparqlQuery`
|
|
10
|
+
*/
|
|
11
|
+
import type { PerspectiveProxy } from "../perspectives/PerspectiveProxy";
|
|
12
|
+
type HydrateCallback = (rawResult: any) => Promise<any>;
|
|
13
|
+
type ResultCallback = (hydratedResult: any) => void;
|
|
14
|
+
export interface PooledSubscription {
|
|
15
|
+
/** The initial (hydrated) result */
|
|
16
|
+
initialResult: any;
|
|
17
|
+
/** Unsubscribe this particular callback from the pool */
|
|
18
|
+
dispose: () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Subscribe to a SPARQL query, sharing the underlying subscription
|
|
22
|
+
* with any other subscribers using the same perspective + query.
|
|
23
|
+
*
|
|
24
|
+
* @param perspective - The perspective proxy
|
|
25
|
+
* @param sparqlQuery - The SPARQL query text
|
|
26
|
+
* @param hydrate - Async function that takes raw SPARQL results and returns hydrated results
|
|
27
|
+
* @param onResult - Callback for subsequent result updates (hydrated)
|
|
28
|
+
* @returns PooledSubscription with initial result and dispose function
|
|
29
|
+
*/
|
|
30
|
+
export declare function pooledSubscribe(perspective: PerspectiveProxy, sparqlQuery: string, hydrate: HydrateCallback, onResult: ResultCallback): Promise<PooledSubscription>;
|
|
31
|
+
/**
|
|
32
|
+
* Clear the entire pool (for testing).
|
|
33
|
+
*/
|
|
34
|
+
export declare function clearSubscriptionPool(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get the current pool size (for testing).
|
|
37
|
+
*/
|
|
38
|
+
export declare function subscriptionPoolSize(): number;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscription Pool — deduplicates identical SPARQL subscriptions.
|
|
3
|
+
*
|
|
4
|
+
* When multiple UI components subscribe to the same SPARQL query on the same
|
|
5
|
+
* perspective, the pool shares a single `subscribeQuery()` call and distributes
|
|
6
|
+
* results to all registered callbacks. Hydration happens once per result set,
|
|
7
|
+
* then is shared across all subscribers.
|
|
8
|
+
*
|
|
9
|
+
* Key: `perspectiveUUID + sparqlQuery`
|
|
10
|
+
*/
|
|
11
|
+
const pool = new Map();
|
|
12
|
+
function makeKey(perspectiveUUID, sparqlQuery) {
|
|
13
|
+
return `${perspectiveUUID}::${sparqlQuery}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Subscribe to a SPARQL query, sharing the underlying subscription
|
|
17
|
+
* with any other subscribers using the same perspective + query.
|
|
18
|
+
*
|
|
19
|
+
* @param perspective - The perspective proxy
|
|
20
|
+
* @param sparqlQuery - The SPARQL query text
|
|
21
|
+
* @param hydrate - Async function that takes raw SPARQL results and returns hydrated results
|
|
22
|
+
* @param onResult - Callback for subsequent result updates (hydrated)
|
|
23
|
+
* @returns PooledSubscription with initial result and dispose function
|
|
24
|
+
*/
|
|
25
|
+
export async function pooledSubscribe(perspective, sparqlQuery, hydrate, onResult) {
|
|
26
|
+
const uuid = perspective.uuid || perspective.handle?.uuid || '';
|
|
27
|
+
const key = makeKey(uuid, sparqlQuery);
|
|
28
|
+
const entry = pool.get(key);
|
|
29
|
+
const subscriber = { onResult, hydrate };
|
|
30
|
+
if (entry) {
|
|
31
|
+
// Join existing subscription
|
|
32
|
+
entry.callbacks.add(subscriber);
|
|
33
|
+
entry.refCount++;
|
|
34
|
+
// Hydrate latest result for this new subscriber
|
|
35
|
+
let initialResult;
|
|
36
|
+
if (entry.latestHydrated !== undefined) {
|
|
37
|
+
initialResult = entry.latestHydrated;
|
|
38
|
+
}
|
|
39
|
+
else if (entry.latestRaw !== undefined) {
|
|
40
|
+
initialResult = await hydrate(entry.latestRaw);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
initialResult,
|
|
44
|
+
dispose: () => disposeSubscriber(key, subscriber),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Create new subscription
|
|
48
|
+
const subscription = await perspective.subscribeQuery(sparqlQuery);
|
|
49
|
+
const newEntry = {
|
|
50
|
+
subscription,
|
|
51
|
+
callbacks: new Set([subscriber]),
|
|
52
|
+
latestRaw: subscription.result,
|
|
53
|
+
latestHydrated: undefined,
|
|
54
|
+
hydrating: false,
|
|
55
|
+
refCount: 1,
|
|
56
|
+
};
|
|
57
|
+
pool.set(key, newEntry);
|
|
58
|
+
// Set up shared result handler with delta optimization
|
|
59
|
+
subscription.onResult(async (rawResult) => {
|
|
60
|
+
const prevRaw = newEntry.latestRaw;
|
|
61
|
+
newEntry.latestRaw = rawResult;
|
|
62
|
+
newEntry.hydrating = true;
|
|
63
|
+
try {
|
|
64
|
+
const firstSub = newEntry.callbacks.values().next().value;
|
|
65
|
+
if (firstSub) {
|
|
66
|
+
// Delta optimization: if the new result is strictly an addition
|
|
67
|
+
// (all previous rows still present + new rows), only hydrate the
|
|
68
|
+
// new rows and append them to the cached hydrated result.
|
|
69
|
+
const prevArr = Array.isArray(prevRaw) ? prevRaw : [];
|
|
70
|
+
const newArr = Array.isArray(rawResult) ? rawResult : [];
|
|
71
|
+
const prevHydrated = newEntry.latestHydrated;
|
|
72
|
+
if (prevHydrated &&
|
|
73
|
+
Array.isArray(prevHydrated) &&
|
|
74
|
+
newArr.length > prevArr.length &&
|
|
75
|
+
newArr.length - prevArr.length <= 5 // small delta — worth optimizing
|
|
76
|
+
) {
|
|
77
|
+
// Build a set of source URIs from previous results for quick lookup
|
|
78
|
+
const prevSources = new Set(prevArr.map((r) => `${r.source}|${r.predicate}|${r.target}`));
|
|
79
|
+
const addedRows = newArr.filter((r) => !prevSources.has(`${r.source}|${r.predicate}|${r.target}`));
|
|
80
|
+
// Check that no rows were removed (pure addition)
|
|
81
|
+
const newSources = new Set(newArr.map((r) => `${r.source}|${r.predicate}|${r.target}`));
|
|
82
|
+
const removedRows = prevArr.filter((r) => !newSources.has(`${r.source}|${r.predicate}|${r.target}`));
|
|
83
|
+
if (removedRows.length === 0 && addedRows.length > 0) {
|
|
84
|
+
// Verify ALL added rows have sources not in previous results.
|
|
85
|
+
// If any added row's source matches an existing source, it means
|
|
86
|
+
// an existing instance got new links — we need full rehydration.
|
|
87
|
+
const prevSourceIds = new Set(prevArr.map((r) => r.source));
|
|
88
|
+
const allNewSources = addedRows.every((r) => !prevSourceIds.has(r.source));
|
|
89
|
+
if (allNewSources) {
|
|
90
|
+
// Pure addition of new instances — hydrate only the new rows
|
|
91
|
+
try {
|
|
92
|
+
const deltaHydrated = await firstSub.hydrate(addedRows);
|
|
93
|
+
if (Array.isArray(deltaHydrated)) {
|
|
94
|
+
const merged = [...prevHydrated, ...deltaHydrated];
|
|
95
|
+
newEntry.latestHydrated = merged;
|
|
96
|
+
for (const cb of newEntry.callbacks) {
|
|
97
|
+
try {
|
|
98
|
+
cb.onResult(merged);
|
|
99
|
+
}
|
|
100
|
+
catch (e) { /* subscriber error */ }
|
|
101
|
+
}
|
|
102
|
+
return; // Delta path succeeded
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// Delta hydration failed — fall through to full hydration
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Full hydration fallback
|
|
112
|
+
const hydrated = await firstSub.hydrate(rawResult);
|
|
113
|
+
newEntry.latestHydrated = hydrated;
|
|
114
|
+
// Distribute to all callbacks
|
|
115
|
+
for (const cb of newEntry.callbacks) {
|
|
116
|
+
try {
|
|
117
|
+
cb.onResult(hydrated);
|
|
118
|
+
}
|
|
119
|
+
catch (e) { /* subscriber error */ }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
newEntry.hydrating = false;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// Hydrate initial result
|
|
128
|
+
const initialResult = await hydrate(subscription.result);
|
|
129
|
+
newEntry.latestHydrated = initialResult;
|
|
130
|
+
return {
|
|
131
|
+
initialResult,
|
|
132
|
+
dispose: () => disposeSubscriber(key, subscriber),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function disposeSubscriber(key, subscriber) {
|
|
136
|
+
const entry = pool.get(key);
|
|
137
|
+
if (!entry)
|
|
138
|
+
return;
|
|
139
|
+
entry.callbacks.delete(subscriber);
|
|
140
|
+
entry.refCount--;
|
|
141
|
+
if (entry.refCount <= 0) {
|
|
142
|
+
// Last subscriber — tear down the underlying subscription
|
|
143
|
+
if (entry.subscription?.dispose) {
|
|
144
|
+
entry.subscription.dispose();
|
|
145
|
+
}
|
|
146
|
+
pool.delete(key);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Clear the entire pool (for testing).
|
|
151
|
+
*/
|
|
152
|
+
export function clearSubscriptionPool() {
|
|
153
|
+
for (const entry of pool.values()) {
|
|
154
|
+
if (entry.subscription?.dispose) {
|
|
155
|
+
entry.subscription.dispose();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
pool.clear();
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the current pool size (for testing).
|
|
162
|
+
*/
|
|
163
|
+
export function subscriptionPoolSize() {
|
|
164
|
+
return pool.size;
|
|
165
|
+
}
|
package/lib/src/model/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Shared type definitions for the Ad4mModel system.
|
|
3
3
|
*
|
|
4
4
|
* Extracted into a standalone module so that utility files
|
|
5
|
-
* (`
|
|
5
|
+
* (`query-utils.ts`, `decorators.ts`, etc.) can import types without
|
|
6
6
|
* creating circular runtime dependencies on `Ad4mModel.ts`.
|
|
7
7
|
*/
|
|
8
8
|
import type { Ad4mModel } from "./Ad4mModel";
|
|
@@ -61,18 +61,75 @@ export type ParentScope = {
|
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
63
|
export interface IncludeMap {
|
|
64
|
-
[relation: string]: boolean | RelationSubQuery;
|
|
64
|
+
[relation: string]: boolean | RelationSubQuery | IncludeProjection;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* A lightweight projection that computes a scalar or list value from a relation
|
|
68
|
+
* without fully hydrating the linked instances.
|
|
69
|
+
*
|
|
70
|
+
* Keys in `IncludeMap` that begin with `$` are treated as projections.
|
|
71
|
+
* Results are attached directly to each queried instance under the same key.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* // Attach a like-count to each post
|
|
76
|
+
* const posts = await Post.findAll(perspective, {
|
|
77
|
+
* include: {
|
|
78
|
+
* $likeCount: { from: 'likes', count: true },
|
|
79
|
+
* $myLike: { from: 'likes', limit: 1 },
|
|
80
|
+
* }
|
|
81
|
+
* });
|
|
82
|
+
* posts[0].$likeCount // number
|
|
83
|
+
* posts[0].$myLike // string ID or null
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export interface IncludeProjection {
|
|
87
|
+
/** The relation name on the parent model to project over. */
|
|
88
|
+
from: string;
|
|
89
|
+
/** When true, attaches an integer count instead of a list. */
|
|
90
|
+
count?: true;
|
|
91
|
+
/**
|
|
92
|
+
* Bare class name of the projection target. Set automatically by
|
|
93
|
+
* `prepareModelQueryParams`; the executor resolves the target's shape
|
|
94
|
+
* through its in-memory cache when applying projection where filters.
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
targetClassName?: string;
|
|
98
|
+
/** Post-hydration where clause applied to the target instances. */
|
|
99
|
+
where?: Where;
|
|
100
|
+
/** Limit results (when 1, the attached value is unwrapped to a scalar). */
|
|
101
|
+
limit?: number;
|
|
102
|
+
/** Order results before applying limit. */
|
|
103
|
+
order?: Order;
|
|
104
|
+
}
|
|
105
|
+
/** Type guard for IncludeProjection objects. */
|
|
106
|
+
export declare function isIncludeProjection(val: unknown): val is IncludeProjection;
|
|
66
107
|
export type Query = {
|
|
67
108
|
/** Filter to instances that are the target of a link from a given parent. */
|
|
68
109
|
parent?: ParentScope;
|
|
69
110
|
properties?: string[];
|
|
70
111
|
include?: IncludeMap;
|
|
112
|
+
/**
|
|
113
|
+
* When true, eager-loads every declared forward relation on the model.
|
|
114
|
+
* Equivalent to listing all relation field names in `include: {}` explicitly.
|
|
115
|
+
* Useful for tree-walking and manifest-style inspections.
|
|
116
|
+
* Individual relations can still be overridden via `include` (explicit entries take precedence).
|
|
117
|
+
*/
|
|
118
|
+
includeAll?: boolean;
|
|
71
119
|
where?: Where;
|
|
72
120
|
order?: Order;
|
|
73
121
|
offset?: number;
|
|
74
122
|
limit?: number;
|
|
75
123
|
count?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* When true, SPARQL property getters (@Property with `getter`) ARE evaluated
|
|
126
|
+
* during collection hydration. Defaults to true — getters run post-pagination
|
|
127
|
+
* via batched VALUES queries so the cost is O(getters), not O(instances × getters).
|
|
128
|
+
*
|
|
129
|
+
* Set to false to explicitly skip getter evaluation for performance-sensitive
|
|
130
|
+
* queries where getter-backed properties are not needed.
|
|
131
|
+
*/
|
|
132
|
+
deepQuery?: boolean;
|
|
76
133
|
};
|
|
77
134
|
/**
|
|
78
135
|
* Sub-query options for a specific relation inside an `IncludeMap`.
|
|
@@ -86,6 +143,139 @@ export type Query = {
|
|
|
86
143
|
* ```
|
|
87
144
|
*/
|
|
88
145
|
export type RelationSubQuery = Omit<Query, 'parent' | 'count'>;
|
|
146
|
+
/** Keys of T that are user-declared (not methods, not inherited from Ad4mModel). */
|
|
147
|
+
export type ModelDataKeys<T extends Ad4mModel> = {
|
|
148
|
+
[K in keyof T]: K extends keyof Ad4mModel ? never : T[K] extends (...args: any[]) => any ? never : K;
|
|
149
|
+
}[keyof T];
|
|
150
|
+
/** Keys of T that can appear in a `where` clause — scalars and scalar arrays.
|
|
151
|
+
* Excludes typed Ad4mModel references (single or array); `string[]`/`number[]`
|
|
152
|
+
* remain included because they're often filterable even when also used as
|
|
153
|
+
* link targets.
|
|
154
|
+
*
|
|
155
|
+
* Iterates over `keyof T` directly (not `ModelDataKeys<T>`) to preserve the
|
|
156
|
+
* key constraint — mapped types over computed type aliases sometimes widen
|
|
157
|
+
* to `string | undefined` in the key position, which then breaks indexing. */
|
|
158
|
+
export type PropertyKeysOf<T extends Ad4mModel> = {
|
|
159
|
+
[K in keyof T]: K extends ModelDataKeys<T> ? NonNullable<T[K]> extends Ad4mModel ? never : NonNullable<T[K]> extends Ad4mModel[] ? never : K : never;
|
|
160
|
+
}[keyof T];
|
|
161
|
+
/** Keys of T that can appear in `include` — typed Ad4mModel references AND
|
|
162
|
+
* `string[]` link-target arrays (the `@HasMany` + `string[]` pattern that
|
|
163
|
+
* AD4M uses for relations without a target class thunk). Handles both
|
|
164
|
+
* `?: Foo` (optional → `Foo | undefined`) and `Foo | null` field shapes, and
|
|
165
|
+
* optional/nullable array variants (`?: Foo[]`, `Foo[] | null`). */
|
|
166
|
+
export type RelationKeysOf<T extends Ad4mModel> = {
|
|
167
|
+
[K in keyof T]: K extends ModelDataKeys<T> ? NonNullable<T[K]> extends Ad4mModel ? K : NonNullable<T[K]> extends Ad4mModel[] ? K : NonNullable<T[K]> extends string[] ? K : never : never;
|
|
168
|
+
}[keyof T];
|
|
169
|
+
/** The model type referenced by a relation field K on T.
|
|
170
|
+
* Falls back to `Ad4mModel` (loose) for the `string[]` relation pattern,
|
|
171
|
+
* since no target class is available at the type level. */
|
|
172
|
+
export type RelatedModel<T extends Ad4mModel, K extends RelationKeysOf<T>> = NonNullable<T[K]> extends (infer U)[] ? (U extends Ad4mModel ? U : Ad4mModel) : NonNullable<T[K]> extends Ad4mModel ? NonNullable<T[K]> : Ad4mModel;
|
|
173
|
+
/** True when T has no statically-declared data fields (e.g. fromSHACL classes). */
|
|
174
|
+
type HasNoTypedFields<T extends Ad4mModel> = [
|
|
175
|
+
PropertyKeysOf<T> | RelationKeysOf<T>
|
|
176
|
+
] extends [never] ? true : false;
|
|
177
|
+
export type StringWhereOps = {
|
|
178
|
+
not?: string | string[];
|
|
179
|
+
contains?: string;
|
|
180
|
+
};
|
|
181
|
+
export type NumericWhereOps = {
|
|
182
|
+
not?: number | number[];
|
|
183
|
+
lt?: number;
|
|
184
|
+
lte?: number;
|
|
185
|
+
gt?: number;
|
|
186
|
+
gte?: number;
|
|
187
|
+
between?: [number, number];
|
|
188
|
+
};
|
|
189
|
+
export type TypedWhereCondition<V> = V extends string ? string | string[] | StringWhereOps : V extends number ? number | number[] | NumericWhereOps : V extends boolean ? boolean : V extends Array<infer U> ? U extends string ? string | string[] | StringWhereOps : U extends number ? number | number[] | NumericWhereOps : WhereCondition : WhereCondition;
|
|
190
|
+
/** Strict Where: keys constrained to T's properties, plus the well-known
|
|
191
|
+
* link-metadata fields (`id`/`author`/`timestamp`). */
|
|
192
|
+
type StrictTypedWhere<T extends Ad4mModel> = {
|
|
193
|
+
[K in PropertyKeysOf<T>]?: TypedWhereCondition<T[K]>;
|
|
194
|
+
} & {
|
|
195
|
+
base?: string | string[];
|
|
196
|
+
id?: string | string[];
|
|
197
|
+
author?: WhereCondition;
|
|
198
|
+
timestamp?: WhereCondition;
|
|
199
|
+
};
|
|
200
|
+
/** Public typed `where` for a model class. Falls back to the loose `Where`
|
|
201
|
+
* shape when T has no declared fields (e.g. fromSHACL-derived classes). */
|
|
202
|
+
export type TypedWhere<T extends Ad4mModel> = HasNoTypedFields<T> extends true ? Where : StrictTypedWhere<T>;
|
|
203
|
+
type StrictTypedOrder<T extends Ad4mModel> = {
|
|
204
|
+
[K in PropertyKeysOf<T> | 'timestamp' | 'author' | 'createdAt' | 'updatedAt']?: 'ASC' | 'DESC';
|
|
205
|
+
};
|
|
206
|
+
export type TypedOrder<T extends Ad4mModel> = HasNoTypedFields<T> extends true ? Order : StrictTypedOrder<T>;
|
|
207
|
+
/** Sub-query for an eager-loaded relation — inherits the target model's constraints. */
|
|
208
|
+
export type TypedRelationSubQuery<U extends Ad4mModel> = {
|
|
209
|
+
where?: TypedWhere<U>;
|
|
210
|
+
order?: TypedOrder<U>;
|
|
211
|
+
include?: TypedIncludeMap<U>;
|
|
212
|
+
limit?: number;
|
|
213
|
+
offset?: number;
|
|
214
|
+
};
|
|
215
|
+
/** Projection — `from` must be a real relation on T; `where`/`order` constrained to that target.
|
|
216
|
+
* Modelled as a discriminated union so the literal `count: true` and `limit: 1`
|
|
217
|
+
* variants narrow inference into `IncludeExtras` (count → number, limit-1 → scalar). */
|
|
218
|
+
export type TypedIncludeProjection<T extends Ad4mModel> = {
|
|
219
|
+
[K in RelationKeysOf<T>]: {
|
|
220
|
+
from: K;
|
|
221
|
+
count: true;
|
|
222
|
+
} | {
|
|
223
|
+
from: K;
|
|
224
|
+
limit: 1;
|
|
225
|
+
where?: TypedWhere<RelatedModel<T, K>>;
|
|
226
|
+
order?: TypedOrder<RelatedModel<T, K>>;
|
|
227
|
+
} | {
|
|
228
|
+
from: K;
|
|
229
|
+
limit?: number;
|
|
230
|
+
where?: TypedWhere<RelatedModel<T, K>>;
|
|
231
|
+
order?: TypedOrder<RelatedModel<T, K>>;
|
|
232
|
+
};
|
|
233
|
+
}[RelationKeysOf<T>];
|
|
234
|
+
type StrictTypedIncludeMap<T extends Ad4mModel> = {
|
|
235
|
+
[K in RelationKeysOf<T>]?: boolean | TypedRelationSubQuery<RelatedModel<T, K>>;
|
|
236
|
+
} & {
|
|
237
|
+
[K in `$${string}`]?: TypedIncludeProjection<T>;
|
|
238
|
+
};
|
|
239
|
+
export type TypedIncludeMap<T extends Ad4mModel> = HasNoTypedFields<T> extends true ? IncludeMap : StrictTypedIncludeMap<T>;
|
|
240
|
+
/**
|
|
241
|
+
* Given a model T and an `include` literal I, compute the extra fields
|
|
242
|
+
* contributed by `$`-prefixed projection keys.
|
|
243
|
+
*
|
|
244
|
+
* - `{ count: true }` → `number`
|
|
245
|
+
* - `{ from: R, limit: 1 }` → `RelatedModel<T,R> | null`
|
|
246
|
+
* - `{ from: R }` (no limit/1) → `RelatedModel<T,R>[]`
|
|
247
|
+
*
|
|
248
|
+
* Returns `unknown` (intersection-neutral) when `I` has no `$`-keys, so that
|
|
249
|
+
* `T & IncludeExtras<T, I>` collapses back to `T` and downstream type
|
|
250
|
+
* predicates (`(x): x is T => ...`) keep working unchanged.
|
|
251
|
+
*/
|
|
252
|
+
export type IncludeExtras<T extends Ad4mModel, I> = I extends Record<string, any> ? Extract<keyof I, `$${string}`> extends never ? unknown : {
|
|
253
|
+
[K in Extract<keyof I, `$${string}`>]: I[K] extends {
|
|
254
|
+
count: true;
|
|
255
|
+
} ? number : I[K] extends {
|
|
256
|
+
from: infer R;
|
|
257
|
+
limit: 1;
|
|
258
|
+
} ? (R extends RelationKeysOf<T> ? RelatedModel<T, R> | null : never) : I[K] extends {
|
|
259
|
+
from: infer R;
|
|
260
|
+
} ? (R extends RelationKeysOf<T> ? RelatedModel<T, R>[] : never) : unknown;
|
|
261
|
+
} : unknown;
|
|
262
|
+
type StrictTypedQuery<T extends Ad4mModel> = {
|
|
263
|
+
parent?: ParentScope;
|
|
264
|
+
properties?: PropertyKeysOf<T>[];
|
|
265
|
+
include?: TypedIncludeMap<T>;
|
|
266
|
+
includeAll?: boolean;
|
|
267
|
+
where?: TypedWhere<T>;
|
|
268
|
+
order?: TypedOrder<T>;
|
|
269
|
+
offset?: number;
|
|
270
|
+
limit?: number;
|
|
271
|
+
count?: boolean;
|
|
272
|
+
deepQuery?: boolean;
|
|
273
|
+
};
|
|
274
|
+
export type TypedQuery<T extends Ad4mModel> = HasNoTypedFields<T> extends true ? Query : StrictTypedQuery<T>;
|
|
275
|
+
/** Helper that extracts the `include` literal from a TypedQuery for use with IncludeExtras. */
|
|
276
|
+
export type IncludeOf<Q> = Q extends {
|
|
277
|
+
include?: infer I;
|
|
278
|
+
} ? I : undefined;
|
|
89
279
|
/**
|
|
90
280
|
* Options accepted by the instance `get()` method.
|
|
91
281
|
*
|
|
@@ -95,7 +285,6 @@ export type GetOptions = Pick<Query, 'include' | 'properties'>;
|
|
|
95
285
|
export type AllInstancesResult = {
|
|
96
286
|
AllInstances: Ad4mModel[];
|
|
97
287
|
TotalCount?: number;
|
|
98
|
-
isInit?: boolean;
|
|
99
288
|
};
|
|
100
289
|
export type ResultsWithTotalCount<T> = {
|
|
101
290
|
results: T[];
|
|
@@ -128,7 +317,7 @@ export interface PropertyMetadata {
|
|
|
128
317
|
prologGetter?: string;
|
|
129
318
|
/** Custom Prolog setter code */
|
|
130
319
|
prologSetter?: string;
|
|
131
|
-
/** Custom
|
|
320
|
+
/** Custom getter code */
|
|
132
321
|
getter?: string;
|
|
133
322
|
/** Whether stored locally only */
|
|
134
323
|
local?: boolean;
|
|
@@ -145,7 +334,7 @@ export interface RelationMetadata {
|
|
|
145
334
|
name: string;
|
|
146
335
|
/** The predicate URI (through value) */
|
|
147
336
|
predicate: string;
|
|
148
|
-
/** Custom
|
|
337
|
+
/** Custom getter code */
|
|
149
338
|
getter?: string;
|
|
150
339
|
/** Whether stored locally only */
|
|
151
340
|
local?: boolean;
|
|
@@ -172,3 +361,4 @@ export interface ModelMetadata {
|
|
|
172
361
|
/** Map of relation name to metadata */
|
|
173
362
|
relations: Record<string, RelationMetadata>;
|
|
174
363
|
}
|
|
364
|
+
export {};
|
package/lib/src/model/types.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* Shared type definitions for the Ad4mModel system.
|
|
3
3
|
*
|
|
4
4
|
* Extracted into a standalone module so that utility files
|
|
5
|
-
* (`
|
|
5
|
+
* (`query-utils.ts`, `decorators.ts`, etc.) can import types without
|
|
6
6
|
* creating circular runtime dependencies on `Ad4mModel.ts`.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
/** Type guard for IncludeProjection objects. */
|
|
9
|
+
export function isIncludeProjection(val) {
|
|
10
|
+
return typeof val === 'object' && val !== null && 'from' in val;
|
|
11
|
+
}
|
|
@@ -1,38 +1,10 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { Field, ObjectType } from "type-graphql";
|
|
11
1
|
import { ExpressionGeneric } from "../expression/Expression";
|
|
12
|
-
|
|
13
|
-
let Neighbourhood = class Neighbourhood {
|
|
2
|
+
export class Neighbourhood {
|
|
14
3
|
constructor(linkLanguage, meta) {
|
|
15
4
|
this.linkLanguage = linkLanguage;
|
|
16
5
|
this.meta = meta;
|
|
17
6
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__metadata("design:type", String)
|
|
22
|
-
], Neighbourhood.prototype, "linkLanguage", void 0);
|
|
23
|
-
__decorate([
|
|
24
|
-
Field(),
|
|
25
|
-
__metadata("design:type", Perspective)
|
|
26
|
-
], Neighbourhood.prototype, "meta", void 0);
|
|
27
|
-
Neighbourhood = __decorate([
|
|
28
|
-
ObjectType(),
|
|
29
|
-
__metadata("design:paramtypes", [String, Perspective])
|
|
30
|
-
], Neighbourhood);
|
|
31
|
-
export { Neighbourhood };
|
|
32
|
-
let NeighbourhoodExpression = class NeighbourhoodExpression extends ExpressionGeneric(Neighbourhood) {
|
|
33
|
-
};
|
|
34
|
-
NeighbourhoodExpression = __decorate([
|
|
35
|
-
ObjectType()
|
|
36
|
-
], NeighbourhoodExpression);
|
|
37
|
-
export { NeighbourhoodExpression };
|
|
7
|
+
}
|
|
8
|
+
export class NeighbourhoodExpression extends ExpressionGeneric(Neighbourhood) {
|
|
9
|
+
}
|
|
38
10
|
;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiClient } from "../apiClient";
|
|
2
2
|
import { Address } from "../Address";
|
|
3
3
|
import { DID } from "../DID";
|
|
4
4
|
import { OnlineAgent, TelepresenceSignalCallback } from "../language/Language";
|
|
@@ -6,7 +6,7 @@ import { Perspective, PerspectiveUnsignedInput } from "../perspectives/Perspecti
|
|
|
6
6
|
import { PerspectiveHandle } from "../perspectives/PerspectiveHandle";
|
|
7
7
|
export declare class NeighbourhoodClient {
|
|
8
8
|
#private;
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(baseUrl: string, token?: string, sharedApiClient?: ApiClient);
|
|
10
10
|
publishFromPerspective(perspectiveUUID: string, linkLanguage: Address, meta: Perspective): Promise<string>;
|
|
11
11
|
joinFromUrl(url: string): Promise<PerspectiveHandle>;
|
|
12
12
|
otherAgents(perspectiveUUID: string): Promise<DID[]>;
|
|
@@ -18,7 +18,7 @@ export declare class NeighbourhoodClient {
|
|
|
18
18
|
sendSignalU(perspectiveUUID: string, remoteAgentDid: string, payload: PerspectiveUnsignedInput): Promise<boolean>;
|
|
19
19
|
sendBroadcast(perspectiveUUID: string, payload: Perspective, loopback?: boolean): Promise<boolean>;
|
|
20
20
|
sendBroadcastU(perspectiveUUID: string, payload: PerspectiveUnsignedInput, loopback?: boolean): Promise<boolean>;
|
|
21
|
-
dispatchSignal(perspectiveUUID: string, signal:
|
|
21
|
+
dispatchSignal(perspectiveUUID: string, signal: unknown): void;
|
|
22
22
|
subscribeToSignals(perspectiveUUID: string): Promise<void>;
|
|
23
23
|
addSignalHandler(perspectiveUUID: string, handler: TelepresenceSignalCallback): Promise<void>;
|
|
24
24
|
removeSignalHandler(perspectiveUUID: string, handler: TelepresenceSignalCallback): void;
|