@coasys/ad4m 0.13.0-test-3 → 0.13.0-test-5
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 +6717 -15519
- package/lib/index.js +4811 -13662
- package/lib/src/Ad4mClient.d.ts +7 -3
- package/lib/src/Ad4mClient.js +39 -13
- package/lib/src/agent/Agent.js +26 -272
- package/lib/src/agent/AgentClient.d.ts +10 -21
- package/lib/src/agent/AgentClient.js +75 -427
- 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 +52 -0
- package/lib/src/apiClient.js +231 -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 +3 -3
- package/lib/src/expression/ExpressionClient.js +13 -76
- package/lib/src/expression/ExpressionRef.js +2 -25
- 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 +6 -1
- package/lib/src/index.js +6 -1
- 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 +1 -1
- package/lib/src/language/Language.js +10 -76
- 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 +76 -44
- package/lib/src/model/Ad4mModel.js +635 -479
- package/lib/src/model/Ad4mModel.test.js +371 -815
- package/lib/src/model/ModelQueryBuilder.d.ts +15 -27
- package/lib/src/model/ModelQueryBuilder.js +163 -224
- package/lib/src/model/decorators.d.ts +22 -0
- package/lib/src/model/decorators.js +7 -0
- package/lib/src/model/hydration.d.ts +3 -93
- package/lib/src/model/hydration.js +3 -970
- package/lib/src/model/index.d.ts +0 -4
- package/lib/src/model/index.js +0 -4
- package/lib/src/model/model-manifest.d.ts +41 -0
- package/lib/src/model/model-manifest.js +11 -0
- package/lib/src/model/query-sparql.d.ts +4 -67
- package/lib/src/model/query-sparql.js +26 -322
- package/lib/src/model/query-sparql.test.js +35 -218
- package/lib/src/model/query-utils.d.ts +1 -0
- package/lib/src/model/query-utils.js +46 -1
- package/lib/src/model/shacl-gen.js +4 -0
- package/lib/src/model/types.d.ts +51 -43
- package/lib/src/model/types.js +4 -1
- 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 +13 -17
- package/lib/src/perspectives/PerspectiveClient.js +179 -429
- package/lib/src/perspectives/PerspectiveClient.test.js +55 -0
- package/lib/src/perspectives/PerspectiveDiff.js +4 -31
- package/lib/src/perspectives/PerspectiveHandle.js +3 -43
- package/lib/src/perspectives/PerspectiveProxy.d.ts +106 -71
- package/lib/src/perspectives/PerspectiveProxy.js +289 -310
- package/lib/src/runtime/RuntimeClient.d.ts +6 -6
- package/lib/src/runtime/RuntimeClient.js +93 -467
- package/lib/src/runtime/RuntimeTypes.d.ts +101 -0
- package/lib/src/runtime/RuntimeTypes.js +45 -0
- package/lib/src/shacl/SHACLShape.d.ts +7 -0
- package/lib/src/shacl/SHACLShape.js +19 -0
- package/lib/src/shacl/SHACLShape.test.js +82 -0
- package/lib/src/typeDefs.js +3 -628
- package/package.json +6 -18
- package/rollup.config.js +0 -7
- package/src/Ad4mClient.test.ts +1179 -1340
- package/src/Ad4mClient.ts +40 -15
- package/src/agent/Agent.ts +0 -99
- package/src/agent/AgentClient.ts +112 -526
- 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 +283 -0
- package/src/expression/Expression.ts +3 -43
- package/src/expression/ExpressionClient.ts +14 -77
- package/src/expression/ExpressionRef.ts +0 -6
- 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 +6 -1
- package/src/jestSetup.ts +1 -1
- package/src/language/Icon.ts +0 -4
- package/src/language/Language.ts +2 -23
- 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 +766 -1173
- package/src/model/Ad4mModel.ts +664 -529
- package/src/model/ModelQueryBuilder.ts +203 -251
- package/src/model/decorators.ts +29 -0
- package/src/model/hydration.ts +3 -1037
- package/src/model/index.ts +0 -4
- package/src/model/query-sparql.test.ts +34 -242
- package/src/model/query-sparql.ts +27 -337
- package/src/model/query-utils.ts +47 -2
- package/src/model/shacl-gen.ts +5 -0
- package/src/model/types.ts +55 -44
- 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 +206 -148
- package/src/perspectives/PerspectiveClient.ts +247 -442
- package/src/perspectives/PerspectiveDiff.ts +0 -8
- package/src/perspectives/PerspectiveHandle.ts +1 -12
- package/src/perspectives/PerspectiveProxy.test.ts +41 -0
- package/src/perspectives/PerspectiveProxy.ts +331 -348
- package/src/runtime/RuntimeClient.ts +112 -474
- package/src/runtime/RuntimeTypes.ts +144 -0
- package/src/shacl/SHACLShape.test.ts +94 -0
- package/src/shacl/SHACLShape.ts +27 -0
- package/src/typeDefs.ts +3 -5
- package/tsconfig.json +3 -7
- 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/LanguageResolver.ts +0 -98
- package/src/model/Subject.ts +0 -159
- package/src/model/hydration-batch.ts +0 -205
- package/src/model/hydration-batching.test.ts +0 -563
- package/src/model/prolog-facts.ts +0 -145
- package/src/model/query-prolog.ts +0 -148
- package/src/model/query-sparql-batch.ts +0 -301
- package/src/model/subscription-delta.test.ts +0 -207
- package/src/model/subscription-pool.ts +0 -211
- package/src/neighbourhood/NeighbourhoodResolver.ts +0 -100
- package/src/perspectives/PerspectiveResolver.ts +0 -364
- package/src/runtime/RuntimeResolver.ts +0 -749
- package/src/unwrapApolloResult.ts +0 -16
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
* Allows building queries with a chainable interface and either
|
|
5
5
|
* running them once or subscribing to real-time updates.
|
|
6
6
|
*/
|
|
7
|
-
import { groupSPARQLResults, hasJsOnlyWhereFilters, parseSparqlCount } from "./query-sparql";
|
|
8
|
-
import { getRelationsMetadata } from "./decorators";
|
|
9
|
-
import { pooledSubscribe } from "./subscription-pool";
|
|
10
7
|
/** Query builder for Ad4mModel queries.
|
|
11
8
|
* Allows building queries with a fluent interface and either running them once
|
|
12
9
|
* or subscribing to updates.
|
|
@@ -31,7 +28,6 @@ export class ModelQueryBuilder {
|
|
|
31
28
|
constructor(perspective, ctor, query) {
|
|
32
29
|
this.queryParams = {};
|
|
33
30
|
this.modelClassName = null;
|
|
34
|
-
this.engineFlag = 'sparql';
|
|
35
31
|
this.perspective = perspective;
|
|
36
32
|
this.ctor = ctor;
|
|
37
33
|
if (query)
|
|
@@ -42,7 +38,7 @@ export class ModelQueryBuilder {
|
|
|
42
38
|
*
|
|
43
39
|
* This method:
|
|
44
40
|
* 1. Stops the keepalive signals to the subscription
|
|
45
|
-
* 2. Unsubscribes from
|
|
41
|
+
* 2. Unsubscribes from subscription updates
|
|
46
42
|
* 3. Notifies the backend to clean up subscription resources
|
|
47
43
|
* 4. Clears the subscription reference
|
|
48
44
|
*
|
|
@@ -205,25 +201,25 @@ export class ModelQueryBuilder {
|
|
|
205
201
|
return this;
|
|
206
202
|
}
|
|
207
203
|
/**
|
|
208
|
-
*
|
|
204
|
+
* Controls whether SPARQL property getters are evaluated during hydration.
|
|
209
205
|
*
|
|
210
|
-
* By default, collection queries
|
|
211
|
-
* Call `.deepQuery()`
|
|
206
|
+
* By default, collection queries evaluate property getters (deepQuery=true).
|
|
207
|
+
* Call `.deepQuery(false)` to skip getter evaluation for performance.
|
|
212
208
|
*
|
|
209
|
+
* @param enabled - Whether to evaluate property getters (default: true)
|
|
213
210
|
* @returns The query builder for chaining
|
|
214
211
|
*
|
|
215
212
|
* @example
|
|
216
213
|
* ```typescript
|
|
217
214
|
* const messages = await Message.query(perspective)
|
|
218
215
|
* .parent(channel)
|
|
219
|
-
* .deepQuery()
|
|
216
|
+
* .deepQuery(false) // skip property getters for performance
|
|
220
217
|
* .limit(30)
|
|
221
218
|
* .get();
|
|
222
|
-
* // messages[i].replyingTo is populated
|
|
223
219
|
* ```
|
|
224
220
|
*/
|
|
225
|
-
deepQuery() {
|
|
226
|
-
this.queryParams.deepQuery =
|
|
221
|
+
deepQuery(enabled = true) {
|
|
222
|
+
this.queryParams.deepQuery = enabled;
|
|
227
223
|
return this;
|
|
228
224
|
}
|
|
229
225
|
/**
|
|
@@ -262,9 +258,9 @@ export class ModelQueryBuilder {
|
|
|
262
258
|
}
|
|
263
259
|
/**
|
|
264
260
|
* Sets the query engine to use.
|
|
261
|
+
* @deprecated Prolog engine has been removed. All queries use SPARQL/Rust.
|
|
265
262
|
*/
|
|
266
|
-
engine(
|
|
267
|
-
this.engineFlag = eng;
|
|
263
|
+
engine(_eng) {
|
|
268
264
|
return this;
|
|
269
265
|
}
|
|
270
266
|
/**
|
|
@@ -280,16 +276,7 @@ export class ModelQueryBuilder {
|
|
|
280
276
|
* ```
|
|
281
277
|
*/
|
|
282
278
|
async get() {
|
|
283
|
-
|
|
284
|
-
if (this.engineFlag === 'sparql') {
|
|
285
|
-
results = await this.executeSparqlQuery();
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
const query = await this.ctor.queryToProlog(this.perspective, this.queryParams, this.modelClassName);
|
|
289
|
-
const result = await this.perspective.infer(query);
|
|
290
|
-
({ results } = await this.ctor.instancesFromPrologResult(this.perspective, this.queryParams, result));
|
|
291
|
-
}
|
|
292
|
-
return results;
|
|
279
|
+
return await this.executeSparqlQuery();
|
|
293
280
|
}
|
|
294
281
|
/**
|
|
295
282
|
* Executes the query once using SPARQL and returns the results.
|
|
@@ -298,22 +285,12 @@ export class ModelQueryBuilder {
|
|
|
298
285
|
return this.executeSparqlQuery();
|
|
299
286
|
}
|
|
300
287
|
/**
|
|
301
|
-
* Shared
|
|
288
|
+
* Shared query execution logic — routes through the executor-side modelQuery endpoint.
|
|
302
289
|
*/
|
|
303
290
|
async executeSparqlQuery() {
|
|
304
|
-
const
|
|
305
|
-
const rawResult = await this.perspective.querySparql(sparqlQuery);
|
|
306
|
-
const { results } = await this.processSparqlResult(rawResult);
|
|
291
|
+
const { results } = await this.ctor.executeModelQuery(this.perspective, this.queryParams, this.modelClassName);
|
|
307
292
|
return results;
|
|
308
293
|
}
|
|
309
|
-
/**
|
|
310
|
-
* Groups raw SPARQL results and hydrates them into model instances.
|
|
311
|
-
* Centralises the repeated groupSPARQLResults → instancesFromQueryResult pipeline.
|
|
312
|
-
*/
|
|
313
|
-
async processSparqlResult(rawResult, queryOverride, computeTotalCount = false) {
|
|
314
|
-
const grouped = groupSPARQLResults(Array.isArray(rawResult) ? rawResult : []);
|
|
315
|
-
return await this.ctor.instancesFromQueryResult(this.perspective, queryOverride || this.queryParams, grouped, computeTotalCount);
|
|
316
|
-
}
|
|
317
294
|
/**
|
|
318
295
|
* Returns the first matching instance, or `null` if none match.
|
|
319
296
|
*
|
|
@@ -360,70 +337,80 @@ export class ModelQueryBuilder {
|
|
|
360
337
|
* builder.dispose();
|
|
361
338
|
* ```
|
|
362
339
|
*
|
|
363
|
-
* @remarks
|
|
364
|
-
* By default, this uses SPARQL live queries for real-time updates.
|
|
365
|
-
* Prolog subscriptions remain available via `.useSPARQL(false)`.
|
|
366
340
|
*/
|
|
367
341
|
async subscribe(callback) {
|
|
368
342
|
// Clean up any existing subscription
|
|
369
343
|
this.dispose();
|
|
370
344
|
const ctor = this.ctor;
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
345
|
+
// Build the model query params (className, queryJson, shapeJson)
|
|
346
|
+
const { className, queryJson, shapeJson } = ctor.prepareModelQueryParams(this.queryParams, this.modelClassName);
|
|
347
|
+
// Register model subscription via Rust — this builds trigger SPARQL internally,
|
|
348
|
+
// registers the subscription, and runs the initial query in one call.
|
|
349
|
+
const { subscriptionId, result: initialModelResult } = await this.perspective.modelSubscribe(className, queryJson, shapeJson);
|
|
350
|
+
// Convert JSON instances to model class instances
|
|
351
|
+
const parseResults = (raw) => {
|
|
352
|
+
return ctor.parseModelResult(this.perspective, raw, this.queryParams.include, this.queryParams.properties);
|
|
353
|
+
};
|
|
354
|
+
// Parse initial results
|
|
355
|
+
const initialResults = parseResults(initialModelResult);
|
|
356
|
+
// Track last emitted result fingerprint to suppress duplicate callbacks
|
|
357
|
+
let lastResultFingerprint = null;
|
|
358
|
+
const buildFingerprint = (results) => {
|
|
359
|
+
if (results.length === 0)
|
|
360
|
+
return '0:';
|
|
361
|
+
return JSON.stringify(results, (_, v) => typeof v === 'function' ? undefined : v);
|
|
362
|
+
};
|
|
363
|
+
lastResultFingerprint = buildFingerprint(initialResults);
|
|
364
|
+
// Listen for subscription updates via the same GraphQL subscription channel.
|
|
365
|
+
// When Rust re-runs the model query and finds changed results, it pushes them.
|
|
366
|
+
const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
|
|
367
|
+
// Skip delayed #init# messages — initial data was already returned
|
|
368
|
+
// synchronously from modelSubscribe(). Late init messages contain stale
|
|
369
|
+
// data that would overwrite real subscription updates.
|
|
370
|
+
if (rawResult && rawResult.isInit)
|
|
371
|
+
return;
|
|
372
|
+
try {
|
|
373
|
+
const results = parseResults(rawResult);
|
|
374
|
+
const fp = buildFingerprint(results);
|
|
388
375
|
if (fp === lastResultFingerprint)
|
|
389
376
|
return;
|
|
390
377
|
lastResultFingerprint = fp;
|
|
391
|
-
callback(hydratedResults);
|
|
392
|
-
});
|
|
393
|
-
// Store dispose function as subscription
|
|
394
|
-
this.currentSubscription = { dispose: pooled.dispose };
|
|
395
|
-
const initialResults = pooled.initialResult;
|
|
396
|
-
lastResultFingerprint = buildFingerprint(initialResults);
|
|
397
|
-
return initialResults;
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
const query = await ctor.queryToProlog(this.perspective, this.queryParams, this.modelClassName);
|
|
401
|
-
this.currentSubscription = await this.perspective.subscribeInfer(query);
|
|
402
|
-
const processResults = async (result) => {
|
|
403
|
-
const { results } = await ctor.instancesFromPrologResult(this.perspective, this.queryParams, result);
|
|
404
378
|
callback(results);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
379
|
+
}
|
|
380
|
+
catch (e) {
|
|
381
|
+
console.error('Model subscription update parse error:', e);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
// Set up keepalive with failure tracking
|
|
385
|
+
let keepaliveFailures = 0;
|
|
386
|
+
const keepaliveTimer = setInterval(() => {
|
|
387
|
+
this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
|
|
388
|
+
keepaliveFailures = 0;
|
|
389
|
+
}).catch((e) => {
|
|
390
|
+
keepaliveFailures++;
|
|
391
|
+
console.warn(`Model subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
|
|
392
|
+
});
|
|
393
|
+
}, 30000);
|
|
394
|
+
// Store dispose function
|
|
395
|
+
this.currentSubscription = {
|
|
396
|
+
dispose: () => {
|
|
397
|
+
clearInterval(keepaliveTimer);
|
|
398
|
+
unsubscribe();
|
|
399
|
+
this.perspective.client.disposeQuerySubscription(this.perspective.uuid, subscriptionId).catch(() => { });
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
// Take snapshots for dirty tracking
|
|
403
|
+
for (const inst of initialResults) {
|
|
404
|
+
inst.takeSnapshot?.(this.queryParams.include);
|
|
410
405
|
}
|
|
406
|
+
return initialResults;
|
|
411
407
|
}
|
|
412
408
|
/**
|
|
413
409
|
* Subscribes to the query and receives updates using SPARQL.
|
|
410
|
+
* @deprecated Use subscribe() instead — now routes through Rust model subscription.
|
|
414
411
|
*/
|
|
415
412
|
async subscribeSparql(callback) {
|
|
416
|
-
this.
|
|
417
|
-
const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, this.queryParams);
|
|
418
|
-
this.currentSubscription = await this.perspective.subscribeQuery(sparqlQuery);
|
|
419
|
-
const processResults = async (result) => {
|
|
420
|
-
const { results } = await this.processSparqlResult(result);
|
|
421
|
-
callback(results);
|
|
422
|
-
};
|
|
423
|
-
this.currentSubscription.onResult(processResults);
|
|
424
|
-
const { results } = await this.processSparqlResult(this.currentSubscription.result);
|
|
425
|
-
// Initial results returned via Promise only — callback is for subsequent updates
|
|
426
|
-
return results;
|
|
413
|
+
return this.subscribe(callback);
|
|
427
414
|
}
|
|
428
415
|
/**
|
|
429
416
|
* Gets the total count of matching entities.
|
|
@@ -438,40 +425,15 @@ export class ModelQueryBuilder {
|
|
|
438
425
|
* ```
|
|
439
426
|
*/
|
|
440
427
|
async count() {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
const metadata = this.ctor.getModelMetadata();
|
|
444
|
-
const allRelMeta = getRelationsMetadata(this.ctor);
|
|
445
|
-
if (hasJsOnlyWhereFilters(metadata, allRelMeta, this.queryParams.where)) {
|
|
446
|
-
const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, this.queryParams);
|
|
447
|
-
const rawResult = await this.perspective.querySparql(sparqlQuery);
|
|
448
|
-
const { totalCount } = await this.processSparqlResult(rawResult, undefined, true);
|
|
449
|
-
return totalCount;
|
|
450
|
-
}
|
|
451
|
-
// Use efficient COUNT query — no hydration
|
|
452
|
-
const countSparql = await this.ctor.countQueryToSPARQL(this.perspective, this.queryParams);
|
|
453
|
-
const countResult = await this.perspective.querySparql(countSparql);
|
|
454
|
-
return parseSparqlCount(countResult) ?? 0;
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
457
|
-
const query = await this.ctor.countQueryToProlog(this.perspective, this.queryParams, this.modelClassName);
|
|
458
|
-
const result = await this.perspective.infer(query);
|
|
459
|
-
return result?.[0]?.TotalCount || 0;
|
|
460
|
-
}
|
|
428
|
+
const { totalCount } = await this.ctor.executeModelQuery(this.perspective, { ...this.queryParams, limit: 0 }, this.modelClassName);
|
|
429
|
+
return totalCount;
|
|
461
430
|
}
|
|
462
431
|
/**
|
|
463
432
|
* Gets the total count of matching entities using SPARQL.
|
|
464
|
-
* Delegates to count()
|
|
433
|
+
* Delegates to count().
|
|
465
434
|
*/
|
|
466
435
|
async countSparql() {
|
|
467
|
-
|
|
468
|
-
this.engineFlag = 'sparql';
|
|
469
|
-
try {
|
|
470
|
-
return await this.count();
|
|
471
|
-
}
|
|
472
|
-
finally {
|
|
473
|
-
this.engineFlag = prev;
|
|
474
|
-
}
|
|
436
|
+
return await this.count();
|
|
475
437
|
}
|
|
476
438
|
/**
|
|
477
439
|
* Subscribes to count updates for matching entities.
|
|
@@ -500,53 +462,52 @@ export class ModelQueryBuilder {
|
|
|
500
462
|
* builder.dispose();
|
|
501
463
|
* ```
|
|
502
464
|
*
|
|
503
|
-
* @remarks
|
|
504
|
-
* By default, this uses SPARQL live queries for real-time updates.
|
|
505
|
-
* Prolog subscriptions remain available via `.useSPARQL(false)`.
|
|
506
465
|
*/
|
|
507
466
|
async countSubscribe(callback) {
|
|
508
467
|
// Clean up any existing subscription
|
|
509
468
|
this.dispose();
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
469
|
+
const countParams = { ...this.queryParams, limit: 0 };
|
|
470
|
+
const { className, queryJson, shapeJson } = this.ctor.prepareModelQueryParams(countParams, this.modelClassName);
|
|
471
|
+
const { subscriptionId, result: initialModelResult } = await this.perspective.modelSubscribe(className, queryJson, shapeJson);
|
|
472
|
+
const parseCount = (raw) => {
|
|
473
|
+
const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
474
|
+
return data.totalCount ?? 0;
|
|
475
|
+
};
|
|
476
|
+
const initialCount = parseCount(initialModelResult);
|
|
477
|
+
const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
|
|
478
|
+
if (rawResult && rawResult.isInit)
|
|
479
|
+
return;
|
|
480
|
+
try {
|
|
481
|
+
callback(parseCount(rawResult));
|
|
482
|
+
}
|
|
483
|
+
catch (e) {
|
|
484
|
+
console.error('Count subscription update parse error:', e);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
let keepaliveFailures = 0;
|
|
488
|
+
const keepaliveTimer = setInterval(() => {
|
|
489
|
+
this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
|
|
490
|
+
keepaliveFailures = 0;
|
|
491
|
+
}).catch((e) => {
|
|
492
|
+
keepaliveFailures++;
|
|
493
|
+
console.warn(`Count subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
|
|
494
|
+
});
|
|
495
|
+
}, 30000);
|
|
496
|
+
this.currentSubscription = {
|
|
497
|
+
dispose: () => {
|
|
498
|
+
clearInterval(keepaliveTimer);
|
|
499
|
+
unsubscribe();
|
|
500
|
+
this.perspective.client.disposeQuerySubscription(this.perspective.uuid, subscriptionId).catch(() => { });
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
return initialCount;
|
|
534
504
|
}
|
|
535
505
|
/**
|
|
536
506
|
* Subscribes to count updates using SPARQL.
|
|
507
|
+
* @deprecated Use countSubscribe() instead — now routes through Rust model subscription.
|
|
537
508
|
*/
|
|
538
509
|
async countSubscribeSparql(callback) {
|
|
539
|
-
this.
|
|
540
|
-
const sparqlQuery = await this.ctor.queryToSPARQL(this.perspective, this.queryParams);
|
|
541
|
-
this.currentSubscription = await this.perspective.subscribeQuery(sparqlQuery);
|
|
542
|
-
const processResults = async (result) => {
|
|
543
|
-
const { totalCount } = await this.processSparqlResult(result, undefined, true);
|
|
544
|
-
callback(totalCount);
|
|
545
|
-
};
|
|
546
|
-
this.currentSubscription.onResult(processResults);
|
|
547
|
-
const { totalCount } = await this.processSparqlResult(this.currentSubscription.result, undefined, true);
|
|
548
|
-
// Initial count returned via Promise — callback for updates only
|
|
549
|
-
return totalCount;
|
|
510
|
+
return this.countSubscribe(callback);
|
|
550
511
|
}
|
|
551
512
|
/**
|
|
552
513
|
* Gets a page of results with pagination metadata.
|
|
@@ -565,32 +526,15 @@ export class ModelQueryBuilder {
|
|
|
565
526
|
*/
|
|
566
527
|
async paginate(pageSize, pageNumber) {
|
|
567
528
|
const paginationQuery = { ...(this.queryParams || {}), limit: pageSize, offset: pageSize * (pageNumber - 1), count: true };
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const result = await this.perspective.querySparql(sparqlQuery);
|
|
571
|
-
const { results, totalCount } = await this.processSparqlResult(result, paginationQuery, true);
|
|
572
|
-
return { results, totalCount, pageSize, pageNumber };
|
|
573
|
-
}
|
|
574
|
-
else {
|
|
575
|
-
const prologQuery = await this.ctor.queryToProlog(this.perspective, paginationQuery, this.modelClassName);
|
|
576
|
-
const result = await this.perspective.infer(prologQuery);
|
|
577
|
-
const { results, totalCount } = (await this.ctor.instancesFromPrologResult(this.perspective, paginationQuery, result));
|
|
578
|
-
return { results, totalCount, pageSize, pageNumber };
|
|
579
|
-
}
|
|
529
|
+
const { results, totalCount } = await this.ctor.executeModelQuery(this.perspective, paginationQuery, this.modelClassName);
|
|
530
|
+
return { results, totalCount, pageSize, pageNumber };
|
|
580
531
|
}
|
|
581
532
|
/**
|
|
582
533
|
* Gets a page of results using SPARQL.
|
|
583
|
-
* Delegates to paginate()
|
|
534
|
+
* Delegates to paginate().
|
|
584
535
|
*/
|
|
585
536
|
async paginateSparql(pageSize, pageNumber) {
|
|
586
|
-
|
|
587
|
-
this.engineFlag = 'sparql';
|
|
588
|
-
try {
|
|
589
|
-
return await this.paginate(pageSize, pageNumber);
|
|
590
|
-
}
|
|
591
|
-
finally {
|
|
592
|
-
this.engineFlag = prev;
|
|
593
|
-
}
|
|
537
|
+
return await this.paginate(pageSize, pageNumber);
|
|
594
538
|
}
|
|
595
539
|
/**
|
|
596
540
|
* Subscribes to paginated results updates.
|
|
@@ -621,65 +565,60 @@ export class ModelQueryBuilder {
|
|
|
621
565
|
* builder.dispose();
|
|
622
566
|
* ```
|
|
623
567
|
*
|
|
624
|
-
* @remarks
|
|
625
|
-
* By default, this uses SPARQL live queries for real-time updates.
|
|
626
|
-
* Prolog subscriptions remain available via `.useSPARQL(false)`.
|
|
627
568
|
*/
|
|
628
569
|
async paginateSubscribe(pageSize, pageNumber, callback) {
|
|
629
570
|
// Clean up any existing subscription
|
|
630
571
|
this.dispose();
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
572
|
+
const ctor = this.ctor;
|
|
573
|
+
// Subscribe to the full result set (no limit/offset) so the subscription
|
|
574
|
+
// detects changes anywhere in the dataset. Rust builds trigger SPARQL
|
|
575
|
+
// from the shape predicates.
|
|
576
|
+
const subscriptionParams = { ...(this.queryParams || {}) };
|
|
577
|
+
delete subscriptionParams.limit;
|
|
578
|
+
delete subscriptionParams.offset;
|
|
579
|
+
const { className, queryJson, shapeJson } = ctor.prepareModelQueryParams(subscriptionParams, this.modelClassName);
|
|
580
|
+
const { subscriptionId } = await this.perspective.modelSubscribe(className, queryJson, shapeJson);
|
|
581
|
+
// Build the paginated query for Rust endpoint (count: true fetches both results and totalCount in one call)
|
|
582
|
+
const paginatedQuery = {
|
|
583
|
+
...(this.queryParams || {}),
|
|
584
|
+
limit: pageSize,
|
|
585
|
+
offset: pageSize * (pageNumber - 1),
|
|
586
|
+
count: true,
|
|
587
|
+
};
|
|
588
|
+
const processResults = async () => {
|
|
589
|
+
const { results, totalCount } = await ctor.executeModelQuery(this.perspective, paginatedQuery, this.modelClassName);
|
|
590
|
+
callback({ results, totalCount, pageSize, pageNumber });
|
|
591
|
+
};
|
|
592
|
+
const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
|
|
593
|
+
if (rawResult && rawResult.isInit)
|
|
594
|
+
return;
|
|
595
|
+
processResults().catch(e => console.error('Paginate subscription error:', e));
|
|
596
|
+
});
|
|
597
|
+
let keepaliveFailures = 0;
|
|
598
|
+
const keepaliveTimer = setInterval(() => {
|
|
599
|
+
this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
|
|
600
|
+
keepaliveFailures = 0;
|
|
601
|
+
}).catch((e) => {
|
|
602
|
+
keepaliveFailures++;
|
|
603
|
+
console.warn(`Paginate subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
|
|
604
|
+
});
|
|
605
|
+
}, 30000);
|
|
606
|
+
this.currentSubscription = {
|
|
607
|
+
dispose: () => {
|
|
608
|
+
clearInterval(keepaliveTimer);
|
|
609
|
+
unsubscribe();
|
|
610
|
+
this.perspective.client.disposeQuerySubscription(this.perspective.uuid, subscriptionId).catch(() => { });
|
|
611
|
+
},
|
|
612
|
+
};
|
|
613
|
+
// Initial fetch (single call with count: true)
|
|
614
|
+
const { results, totalCount } = await ctor.executeModelQuery(this.perspective, paginatedQuery, this.modelClassName);
|
|
615
|
+
return { results, totalCount, pageSize, pageNumber };
|
|
670
616
|
}
|
|
671
617
|
/**
|
|
672
618
|
* Subscribes to paginated results updates using SPARQL.
|
|
673
|
-
* Delegates to paginateSubscribe()
|
|
619
|
+
* Delegates to paginateSubscribe().
|
|
674
620
|
*/
|
|
675
621
|
async paginateSubscribeSparql(pageSize, pageNumber, callback) {
|
|
676
|
-
|
|
677
|
-
this.engineFlag = 'sparql';
|
|
678
|
-
try {
|
|
679
|
-
return await this.paginateSubscribe(pageSize, pageNumber, callback);
|
|
680
|
-
}
|
|
681
|
-
finally {
|
|
682
|
-
this.engineFlag = prev;
|
|
683
|
-
}
|
|
622
|
+
return await this.paginateSubscribe(pageSize, pageNumber, callback);
|
|
684
623
|
}
|
|
685
624
|
}
|
|
@@ -135,6 +135,28 @@ export interface PropertyOptions {
|
|
|
135
135
|
* The function takes the raw value as input and returns the transformed value.
|
|
136
136
|
*/
|
|
137
137
|
transform?: (value: any) => any;
|
|
138
|
+
/**
|
|
139
|
+
* Allowed values for this property (enum constraint).
|
|
140
|
+
* Maps to SHACL `sh:in`. Each entry has a `value` (the stored RDF term)
|
|
141
|
+
* and an optional `label` (human-readable display name).
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* @Property({
|
|
146
|
+
* through: "task://status",
|
|
147
|
+
* options: [
|
|
148
|
+
* { value: "task://todo", label: "To Do" },
|
|
149
|
+
* { value: "task://doing", label: "Doing" },
|
|
150
|
+
* { value: "task://done", label: "Done" },
|
|
151
|
+
* ]
|
|
152
|
+
* })
|
|
153
|
+
* status: string = "task://todo";
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
options?: Array<{
|
|
157
|
+
value: string;
|
|
158
|
+
label?: string;
|
|
159
|
+
}>;
|
|
138
160
|
}
|
|
139
161
|
/**
|
|
140
162
|
* Convenience decorator for defining optional (not required) properties.
|
|
@@ -521,8 +521,15 @@ function resolveRelationArgs(first, second) {
|
|
|
521
521
|
return opts;
|
|
522
522
|
}
|
|
523
523
|
export function HasMany(first, second) {
|
|
524
|
+
const explicitThrough = typeof first === 'function' ? second?.through : first.through;
|
|
524
525
|
const opts = resolveRelationArgs(first, second);
|
|
525
526
|
return function (target, key) {
|
|
527
|
+
if (!explicitThrough && !opts.getter) {
|
|
528
|
+
const className = (target.constructor?.name) ?? 'unknown';
|
|
529
|
+
console.warn(`@HasMany on ${className}.${String(key)} has no 'through' predicate — defaulting to 'ad4m://has_child'. ` +
|
|
530
|
+
`Add { through: 'ad4m://has_child' } to silence this warning, or use a semantic predicate ` +
|
|
531
|
+
`like { through: 'myns://has_${String(key)}' } for efficient targeted queries.`);
|
|
532
|
+
}
|
|
526
533
|
// --- relation registry ---
|
|
527
534
|
const ctor = target.constructor;
|
|
528
535
|
if (!relationRegistry.has(ctor))
|