@coasys/ad4m 0.13.0-test-2 → 0.13.0-test-4
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 +2805 -10556
- package/lib/index.js +2513 -10322
- package/lib/src/Ad4mClient.d.ts +7 -3
- package/lib/src/Ad4mClient.js +29 -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 -2
- package/lib/src/index.js +6 -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 -214
- 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 +81 -38
- package/lib/src/model/Ad4mModel.js +651 -408
- package/lib/src/model/Ad4mModel.test.js +488 -750
- package/lib/src/model/ModelQueryBuilder.d.ts +28 -21
- package/lib/src/model/ModelQueryBuilder.js +160 -195
- package/lib/src/model/decorators.d.ts +22 -0
- package/lib/src/model/decorators.js +7 -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 +8 -60
- package/lib/src/model/hydration.js +41 -541
- 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 +36 -22
- package/lib/src/model/query-sparql.js +188 -53
- 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/query-utils.js +4 -0
- package/lib/src/model/shacl-gen.js +4 -0
- 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.js +48 -2
- package/lib/src/model/types.d.ts +58 -1
- 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 +12 -15
- package/lib/src/perspectives/PerspectiveClient.js +168 -400
- 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 +95 -71
- package/lib/src/perspectives/PerspectiveProxy.js +288 -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 +9 -24
- package/rollup.config.js +0 -7
- package/src/Ad4mClient.test.ts +1182 -1288
- package/src/Ad4mClient.ts +30 -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 -2
- package/src/jestSetup.ts +1 -1
- package/src/language/Icon.ts +0 -4
- package/src/language/Language.ts +50 -292
- 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 +827 -808
- package/src/model/Ad4mModel.ts +676 -457
- package/src/model/ModelQueryBuilder.ts +199 -217
- package/src/model/decorators.ts +29 -0
- package/src/model/hydration.ts +17 -572
- package/src/model/index.ts +0 -4
- package/src/model/query-sparql.test.ts +360 -0
- package/src/model/query-sparql.ts +203 -56
- package/src/model/query-utils.ts +4 -0
- package/src/model/shacl-gen.ts +5 -0
- package/src/model/types.ts +62 -1
- 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 +227 -412
- 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 +325 -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/lib/src/model/query-surreal.d.ts +0 -44
- package/lib/src/model/query-surreal.js +0 -249
- package/lib/src/model/surreal-utils.d.ts +0 -42
- 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/hydration-batch.ts +0 -205
- 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-pool.ts +0 -163
- 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
- package/tsconfig-browser.json +0 -82
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { PerspectiveClient } from "./PerspectiveClient";
|
|
2
|
+
import { PerspectiveHandle, PerspectiveState } from "./PerspectiveHandle";
|
|
3
|
+
/**
|
|
4
|
+
* Focused unit tests for PerspectiveClient proxy cache behaviour.
|
|
5
|
+
* Uses a mock Apollo client to isolate cache logic from network.
|
|
6
|
+
*/
|
|
7
|
+
// Minimal mock Apollo client that returns controllable results
|
|
8
|
+
function createMockApolloClient(overrides = {}) {
|
|
9
|
+
return {
|
|
10
|
+
query: overrides.query || jest.fn().mockResolvedValue({ data: {} }),
|
|
11
|
+
mutate: overrides.mutate || jest.fn().mockResolvedValue({ data: {} }),
|
|
12
|
+
subscribe: overrides.subscribe || jest.fn().mockReturnValue({
|
|
13
|
+
subscribe: jest.fn()
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function makeHandle(uuid, name, state = PerspectiveState.Private) {
|
|
18
|
+
const h = new PerspectiveHandle(uuid, name, state);
|
|
19
|
+
return h;
|
|
20
|
+
}
|
|
21
|
+
describe('PerspectiveClient proxy cache', () => {
|
|
22
|
+
it('byUUID returns the same proxy reference on cache hit', async () => {
|
|
23
|
+
const handle = makeHandle('uuid-1', 'Test');
|
|
24
|
+
const mockClient = createMockApolloClient({
|
|
25
|
+
query: jest.fn().mockResolvedValue({
|
|
26
|
+
data: { perspective: handle }
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
30
|
+
const p1 = await client.byUUID('uuid-1');
|
|
31
|
+
const p2 = await client.byUUID('uuid-1');
|
|
32
|
+
expect(p1).toBe(p2);
|
|
33
|
+
// Only one query should have been made (second is cache hit)
|
|
34
|
+
expect(mockClient.query).toHaveBeenCalledTimes(1);
|
|
35
|
+
});
|
|
36
|
+
it('byUUID returns null for non-existent perspectives', async () => {
|
|
37
|
+
const mockClient = createMockApolloClient({
|
|
38
|
+
query: jest.fn().mockResolvedValue({
|
|
39
|
+
data: { perspective: null }
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
43
|
+
const p = await client.byUUID('non-existent');
|
|
44
|
+
expect(p).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
it('all() populates cache so subsequent byUUID is a hit', async () => {
|
|
47
|
+
const handles = [
|
|
48
|
+
makeHandle('uuid-a', 'A'),
|
|
49
|
+
makeHandle('uuid-b', 'B'),
|
|
50
|
+
];
|
|
51
|
+
const queryFn = jest.fn()
|
|
52
|
+
.mockResolvedValueOnce({ data: { perspectives: handles } });
|
|
53
|
+
const mockClient = createMockApolloClient({ query: queryFn });
|
|
54
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
55
|
+
const all = await client.all();
|
|
56
|
+
expect(all.length).toBe(2);
|
|
57
|
+
// byUUID should be a cache hit — no additional query
|
|
58
|
+
const pa = await client.byUUID('uuid-a');
|
|
59
|
+
expect(pa).toBe(all[0]);
|
|
60
|
+
expect(queryFn).toHaveBeenCalledTimes(1); // only the all() query
|
|
61
|
+
});
|
|
62
|
+
it('add() populates cache', async () => {
|
|
63
|
+
const handle = makeHandle('uuid-new', 'New');
|
|
64
|
+
const mockClient = createMockApolloClient({
|
|
65
|
+
mutate: jest.fn().mockResolvedValue({
|
|
66
|
+
data: { perspectiveAdd: handle }
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
70
|
+
const added = await client.add('New');
|
|
71
|
+
expect(added.uuid).toBe('uuid-new');
|
|
72
|
+
// byUUID should hit cache
|
|
73
|
+
const fetched = await client.byUUID('uuid-new');
|
|
74
|
+
expect(fetched).toBe(added);
|
|
75
|
+
});
|
|
76
|
+
it('update() evicts and recreates cached proxy', async () => {
|
|
77
|
+
const originalHandle = makeHandle('uuid-u', 'Original');
|
|
78
|
+
const updatedHandle = makeHandle('uuid-u', 'Updated');
|
|
79
|
+
const queryFn = jest.fn().mockResolvedValue({
|
|
80
|
+
data: { perspective: originalHandle }
|
|
81
|
+
});
|
|
82
|
+
const mutateFn = jest.fn().mockResolvedValue({
|
|
83
|
+
data: { perspectiveUpdate: updatedHandle }
|
|
84
|
+
});
|
|
85
|
+
const mockClient = createMockApolloClient({
|
|
86
|
+
query: queryFn,
|
|
87
|
+
mutate: mutateFn,
|
|
88
|
+
});
|
|
89
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
90
|
+
const original = await client.byUUID('uuid-u');
|
|
91
|
+
expect(original.name).toBe('Original');
|
|
92
|
+
const updated = await client.update('uuid-u', 'Updated');
|
|
93
|
+
expect(updated).not.toBe(original); // new reference after eviction
|
|
94
|
+
expect(updated.name).toBe('Updated');
|
|
95
|
+
expect(original.name).toBe('Original'); // old reference retains stale data
|
|
96
|
+
});
|
|
97
|
+
it('remove() evicts from cache', async () => {
|
|
98
|
+
const handle = makeHandle('uuid-r', 'ToRemove');
|
|
99
|
+
const queryFn = jest.fn().mockResolvedValue({
|
|
100
|
+
data: { perspective: handle }
|
|
101
|
+
});
|
|
102
|
+
const mutateFn = jest.fn().mockResolvedValue({
|
|
103
|
+
data: { perspectiveRemove: true }
|
|
104
|
+
});
|
|
105
|
+
const mockClient = createMockApolloClient({
|
|
106
|
+
query: queryFn,
|
|
107
|
+
mutate: mutateFn,
|
|
108
|
+
});
|
|
109
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
110
|
+
const p = await client.byUUID('uuid-r');
|
|
111
|
+
expect(p).toBeTruthy();
|
|
112
|
+
expect(queryFn).toHaveBeenCalledTimes(1);
|
|
113
|
+
await client.remove('uuid-r');
|
|
114
|
+
// byUUID should miss cache and query again
|
|
115
|
+
const handle2 = makeHandle('uuid-r', 'Recreated');
|
|
116
|
+
queryFn.mockResolvedValueOnce({ data: { perspective: handle2 } });
|
|
117
|
+
const p2 = await client.byUUID('uuid-r');
|
|
118
|
+
expect(p2).not.toBe(p);
|
|
119
|
+
expect(p2.name).toBe('Recreated');
|
|
120
|
+
expect(queryFn).toHaveBeenCalledTimes(2);
|
|
121
|
+
});
|
|
122
|
+
it('getOrCreateProxy does not re-register listeners on cache hit', async () => {
|
|
123
|
+
// Verify that getting the same proxy twice does not create duplicate subscriptions
|
|
124
|
+
const handle = makeHandle('uuid-dup', 'NoDuplicates');
|
|
125
|
+
const subscribeCalls = [];
|
|
126
|
+
const subscribeFn = jest.fn().mockImplementation((opts) => {
|
|
127
|
+
// Track subscription query names
|
|
128
|
+
const queryStr = opts.query?.loc?.source?.body || '';
|
|
129
|
+
subscribeCalls.push(queryStr);
|
|
130
|
+
return {
|
|
131
|
+
subscribe: jest.fn()
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
const queryFn = jest.fn()
|
|
135
|
+
.mockResolvedValueOnce({ data: { perspectives: [handle] } });
|
|
136
|
+
const mockClient = createMockApolloClient({
|
|
137
|
+
query: queryFn,
|
|
138
|
+
subscribe: subscribeFn,
|
|
139
|
+
});
|
|
140
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
141
|
+
const all = await client.all();
|
|
142
|
+
const firstProxy = all[0];
|
|
143
|
+
// Record how many subscribe calls happened from PerspectiveProxy constructor
|
|
144
|
+
const callsAfterFirst = subscribeFn.mock.calls.length;
|
|
145
|
+
// Get same proxy again via all() — should be cache hit, no new constructor call
|
|
146
|
+
queryFn.mockResolvedValueOnce({ data: { perspectives: [handle] } });
|
|
147
|
+
const all2 = await client.all();
|
|
148
|
+
const secondProxy = all2[0];
|
|
149
|
+
expect(secondProxy).toBe(firstProxy);
|
|
150
|
+
// No additional subscribe calls should have been made
|
|
151
|
+
expect(subscribeFn.mock.calls.length).toBe(callsAfterFirst);
|
|
152
|
+
});
|
|
153
|
+
it('all() updates existing cached proxies with fresh data', async () => {
|
|
154
|
+
const handle1 = makeHandle('uuid-f', 'OldName');
|
|
155
|
+
const handle2 = makeHandle('uuid-f', 'FreshName');
|
|
156
|
+
const queryFn = jest.fn()
|
|
157
|
+
.mockResolvedValueOnce({ data: { perspective: handle1 } })
|
|
158
|
+
.mockResolvedValueOnce({ data: { perspectives: [handle2] } });
|
|
159
|
+
const mockClient = createMockApolloClient({ query: queryFn });
|
|
160
|
+
const client = new PerspectiveClient(mockClient, false);
|
|
161
|
+
const original = await client.byUUID('uuid-f');
|
|
162
|
+
expect(original.name).toBe('OldName');
|
|
163
|
+
const all = await client.all();
|
|
164
|
+
const refreshed = all.find(p => p.uuid === 'uuid-f');
|
|
165
|
+
expect(refreshed).toBe(original); // same reference
|
|
166
|
+
expect(refreshed.name).toBe('FreshName'); // updated in-place
|
|
167
|
+
expect(original.name).toBe('FreshName'); // original ref also updated
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('PerspectiveProxy getClassShape sh:in URI-decoding', () => {
|
|
171
|
+
// This tests the sh:in parsing logic in getClassShape() which was fixed
|
|
172
|
+
// to URI-decode values from the Rust executor's SPARQL results
|
|
173
|
+
function parseShInValue(raw) {
|
|
174
|
+
// Reproduce the exact parsing logic from PerspectiveProxy.getClassShape()
|
|
175
|
+
try {
|
|
176
|
+
if (raw.startsWith('literal:string:')) {
|
|
177
|
+
raw = decodeURIComponent(raw.substring('literal:string:'.length));
|
|
178
|
+
}
|
|
179
|
+
return JSON.parse(raw);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
it('parses plain JSON sh:in values', () => {
|
|
186
|
+
const result = parseShInValue('[{"value":"a"},{"value":"b","label":"B"}]');
|
|
187
|
+
expect(result).toEqual([
|
|
188
|
+
{ value: 'a' },
|
|
189
|
+
{ value: 'b', label: 'B' },
|
|
190
|
+
]);
|
|
191
|
+
});
|
|
192
|
+
it('strips literal:string: prefix and parses', () => {
|
|
193
|
+
const result = parseShInValue('literal:string:[{"value":"x"},{"value":"y"}]');
|
|
194
|
+
expect(result).toEqual([
|
|
195
|
+
{ value: 'x' },
|
|
196
|
+
{ value: 'y' },
|
|
197
|
+
]);
|
|
198
|
+
});
|
|
199
|
+
it('URI-decodes encoded sh:in values from Rust executor', () => {
|
|
200
|
+
// Rust executor may URI-encode the JSON when returning SPARQL results
|
|
201
|
+
const encoded = 'literal:string:' + encodeURIComponent('[{"value":"hello world"},{"value":"a&b"}]');
|
|
202
|
+
const result = parseShInValue(encoded);
|
|
203
|
+
expect(result).toEqual([
|
|
204
|
+
{ value: 'hello world' },
|
|
205
|
+
{ value: 'a&b' },
|
|
206
|
+
]);
|
|
207
|
+
});
|
|
208
|
+
it('handles double-encoded brackets and quotes', () => {
|
|
209
|
+
const encoded = 'literal:string:%5B%7B%22value%22%3A%22active%22%7D%2C%7B%22value%22%3A%22inactive%22%7D%5D';
|
|
210
|
+
const result = parseShInValue(encoded);
|
|
211
|
+
expect(result).toEqual([
|
|
212
|
+
{ value: 'active' },
|
|
213
|
+
{ value: 'inactive' },
|
|
214
|
+
]);
|
|
215
|
+
});
|
|
216
|
+
it('returns undefined for malformed JSON', () => {
|
|
217
|
+
const result = parseShInValue('literal:string:not-json');
|
|
218
|
+
expect(result).toBeUndefined();
|
|
219
|
+
});
|
|
220
|
+
it('handles already-decoded values without prefix', () => {
|
|
221
|
+
const result = parseShInValue('[{"value":"test"}]');
|
|
222
|
+
expect(result).toEqual([{ value: 'test' }]);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
@@ -1,33 +1,6 @@
|
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Field(type => [LinkExpression]),
|
|
17
|
-
__metadata("design:type", Array)
|
|
18
|
-
], PerspectiveDiff.prototype, "additions", void 0);
|
|
19
|
-
__decorate([
|
|
20
|
-
Field(type => [LinkExpression]),
|
|
21
|
-
__metadata("design:type", Array)
|
|
22
|
-
], PerspectiveDiff.prototype, "removals", void 0);
|
|
23
|
-
PerspectiveDiff = __decorate([
|
|
24
|
-
ObjectType()
|
|
25
|
-
], PerspectiveDiff);
|
|
26
|
-
export { PerspectiveDiff };
|
|
27
|
-
let PerspectiveDiffExpression = class PerspectiveDiffExpression extends ExpressionGeneric(PerspectiveDiff) {
|
|
28
|
-
};
|
|
29
|
-
PerspectiveDiffExpression = __decorate([
|
|
30
|
-
ObjectType()
|
|
31
|
-
], PerspectiveDiffExpression);
|
|
32
|
-
export { PerspectiveDiffExpression };
|
|
2
|
+
export class PerspectiveDiff {
|
|
3
|
+
}
|
|
4
|
+
export class PerspectiveDiffExpression extends ExpressionGeneric(PerspectiveDiff) {
|
|
5
|
+
}
|
|
33
6
|
;
|
|
@@ -1,14 +1,3 @@
|
|
|
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
|
-
import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
|
|
12
1
|
export var PerspectiveState;
|
|
13
2
|
(function (PerspectiveState) {
|
|
14
3
|
PerspectiveState["Private"] = "PRIVATE";
|
|
@@ -18,10 +7,10 @@ export var PerspectiveState;
|
|
|
18
7
|
PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
|
|
19
8
|
PerspectiveState["Synced"] = "SYNCED";
|
|
20
9
|
})(PerspectiveState || (PerspectiveState = {}));
|
|
21
|
-
// This type is used in the
|
|
10
|
+
// This type is used in the REST interface to reference a mutable
|
|
22
11
|
// prespective that is implemented locally by the Ad4m runtime.
|
|
23
12
|
// The UUID is used in mutations to identify the perspective that gets mutated.
|
|
24
|
-
|
|
13
|
+
export class PerspectiveHandle {
|
|
25
14
|
constructor(uuid, name, state) {
|
|
26
15
|
this.uuid = uuid;
|
|
27
16
|
this.name = name;
|
|
@@ -32,33 +21,4 @@ let PerspectiveHandle = class PerspectiveHandle {
|
|
|
32
21
|
this.state = PerspectiveState.Private;
|
|
33
22
|
}
|
|
34
23
|
}
|
|
35
|
-
}
|
|
36
|
-
__decorate([
|
|
37
|
-
Field(),
|
|
38
|
-
__metadata("design:type", String)
|
|
39
|
-
], PerspectiveHandle.prototype, "uuid", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
Field(),
|
|
42
|
-
__metadata("design:type", String)
|
|
43
|
-
], PerspectiveHandle.prototype, "name", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
Field(),
|
|
46
|
-
__metadata("design:type", String)
|
|
47
|
-
], PerspectiveHandle.prototype, "state", void 0);
|
|
48
|
-
__decorate([
|
|
49
|
-
Field(type => String, { nullable: true }),
|
|
50
|
-
__metadata("design:type", String)
|
|
51
|
-
], PerspectiveHandle.prototype, "sharedUrl", void 0);
|
|
52
|
-
__decorate([
|
|
53
|
-
Field(type => NeighbourhoodExpression, { nullable: true }),
|
|
54
|
-
__metadata("design:type", NeighbourhoodExpression)
|
|
55
|
-
], PerspectiveHandle.prototype, "neighbourhood", void 0);
|
|
56
|
-
__decorate([
|
|
57
|
-
Field(type => [String], { nullable: true }),
|
|
58
|
-
__metadata("design:type", Array)
|
|
59
|
-
], PerspectiveHandle.prototype, "owners", void 0);
|
|
60
|
-
PerspectiveHandle = __decorate([
|
|
61
|
-
ObjectType(),
|
|
62
|
-
__metadata("design:paramtypes", [String, String, String])
|
|
63
|
-
], PerspectiveHandle);
|
|
64
|
-
export { PerspectiveHandle };
|
|
24
|
+
}
|
|
@@ -16,7 +16,7 @@ type QueryCallback = (result: AllInstancesResult) => void;
|
|
|
16
16
|
* This class handles:
|
|
17
17
|
* - Keeping the subscription alive by sending periodic keepalive signals
|
|
18
18
|
* - Managing callbacks for result updates
|
|
19
|
-
* - Subscribing to query updates via
|
|
19
|
+
* - Subscribing to query updates via WebSocket subscriptions
|
|
20
20
|
* - Maintaining the latest query result
|
|
21
21
|
* - Ensuring subscription is fully initialized before allowing access
|
|
22
22
|
* - Cleaning up resources when disposed
|
|
@@ -107,7 +107,7 @@ export declare class QuerySubscriptionProxy {
|
|
|
107
107
|
*
|
|
108
108
|
* This method:
|
|
109
109
|
* 1. Stops the keepalive timer
|
|
110
|
-
* 2. Unsubscribes from
|
|
110
|
+
* 2. Unsubscribes from subscription updates
|
|
111
111
|
* 3. Clears all registered callbacks
|
|
112
112
|
* 4. Cleans up any pending initialization timeout
|
|
113
113
|
*
|
|
@@ -175,11 +175,16 @@ export declare class PerspectiveProxy {
|
|
|
175
175
|
state: PerspectiveState | null;
|
|
176
176
|
/** List of owners of this perspective */
|
|
177
177
|
owners?: string[];
|
|
178
|
+
/** @internal Exposed for ModelQueryBuilder subscription management */
|
|
179
|
+
get client(): PerspectiveClient;
|
|
178
180
|
/**
|
|
179
181
|
* Creates a new PerspectiveProxy instance.
|
|
180
182
|
* Note: Don't create this directly, use ad4m.perspective.add() instead.
|
|
181
183
|
*/
|
|
182
184
|
constructor(handle: PerspectiveHandle, ad4m: PerspectiveClient);
|
|
185
|
+
/** Update the proxy's internal handle and public fields in-place.
|
|
186
|
+
* Keeps the same object reference so all holders see the update. */
|
|
187
|
+
updateHandle(handle: PerspectiveHandle): void;
|
|
183
188
|
/**
|
|
184
189
|
* Escapes special regex characters in a string to prevent ReDoS attacks
|
|
185
190
|
* and regex injection when building dynamic regular expressions.
|
|
@@ -314,6 +319,35 @@ export declare class PerspectiveProxy {
|
|
|
314
319
|
* @returns Query results as parsed JSON
|
|
315
320
|
*/
|
|
316
321
|
querySparql(query: string): Promise<any>;
|
|
322
|
+
/**
|
|
323
|
+
* Execute a model query — the executor-side replacement for SPARQL query building + JS hydration.
|
|
324
|
+
*
|
|
325
|
+
* @param className - The model class name (e.g. "Recipe")
|
|
326
|
+
* @param queryJson - Structured query as JSON string
|
|
327
|
+
* @param shapeJson - Optional shape metadata JSON from the model class
|
|
328
|
+
* @returns Object with `instances` array and `totalCount`
|
|
329
|
+
*/
|
|
330
|
+
modelQuery(className: string, queryJson: string, shapeJson?: string): Promise<{
|
|
331
|
+
instances: any[];
|
|
332
|
+
totalCount: number;
|
|
333
|
+
}>;
|
|
334
|
+
/**
|
|
335
|
+
* Subscribe to model query changes. Builds trigger SPARQL from the model shape
|
|
336
|
+
* internally in Rust, registers a subscription, runs the initial query, and
|
|
337
|
+
* pushes updated results when relevant links change.
|
|
338
|
+
*
|
|
339
|
+
* The subscription reuses the same GraphQL subscription channel as subscribeQuery().
|
|
340
|
+
* Use keepAliveQuery() / disposeQuerySubscription() with the returned subscriptionId.
|
|
341
|
+
*
|
|
342
|
+
* @param className - The model class name
|
|
343
|
+
* @param queryJson - JSON-serialized query parameters (same as modelQuery)
|
|
344
|
+
* @param shapeJson - Optional shape metadata JSON from the model class
|
|
345
|
+
* @returns Object with `subscriptionId` and initial `result`
|
|
346
|
+
*/
|
|
347
|
+
modelSubscribe(className: string, queryJson: string, shapeJson?: string): Promise<{
|
|
348
|
+
subscriptionId: string;
|
|
349
|
+
result: any;
|
|
350
|
+
}>;
|
|
317
351
|
/**
|
|
318
352
|
* Adds a new link to the perspective.
|
|
319
353
|
*
|
|
@@ -523,7 +557,7 @@ export declare class PerspectiveProxy {
|
|
|
523
557
|
* Adds Social DNA code to the perspective.
|
|
524
558
|
*
|
|
525
559
|
* **Recommended:** Use {@link addShacl} instead, which accepts the `SHACLShape` type directly.
|
|
526
|
-
* This method is primarily for the
|
|
560
|
+
* This method is primarily for the RPC API layer and legacy Prolog code.
|
|
527
561
|
*
|
|
528
562
|
* @param name - Unique name for this SDNA definition
|
|
529
563
|
* @param sdnaCode - Prolog SDNA code (legacy, can be empty string if shaclJson provided)
|
|
@@ -672,16 +706,6 @@ export declare class PerspectiveProxy {
|
|
|
672
706
|
* that matches the given properties will be used.
|
|
673
707
|
*/
|
|
674
708
|
isSubjectInstance<T>(expression: string, subjectClass: T): Promise<boolean>;
|
|
675
|
-
/** For an existing subject instance (existing in the perspective's links)
|
|
676
|
-
* this function returns a proxy object that can be used to access the subject's
|
|
677
|
-
* properties and methods.
|
|
678
|
-
*
|
|
679
|
-
* @param base URI of the subject's root expression
|
|
680
|
-
* @param subjectClass Either a string with the name of the subject class, or an object
|
|
681
|
-
* with the properties of the subject class. In the latter case, the first subject class
|
|
682
|
-
* that matches the given properties will be used.
|
|
683
|
-
*/
|
|
684
|
-
getSubjectProxy<T>(base: string, subjectClass: T): Promise<T>;
|
|
685
709
|
/**
|
|
686
710
|
* Gets subject class metadata from SHACL links using SHACLShape.fromLinks().
|
|
687
711
|
* Retrieves the SHACL shape and extracts metadata for instance queries.
|
|
@@ -702,23 +726,6 @@ export declare class PerspectiveProxy {
|
|
|
702
726
|
condition?: string;
|
|
703
727
|
}>;
|
|
704
728
|
} | null>;
|
|
705
|
-
/** @deprecated Use getSubjectClassMetadata() */
|
|
706
|
-
getSubjectClassMetadataFromSDNA(className: string): Promise<{
|
|
707
|
-
requiredPredicates: string[];
|
|
708
|
-
requiredTriples: Array<{
|
|
709
|
-
predicate: string;
|
|
710
|
-
target?: string;
|
|
711
|
-
}>;
|
|
712
|
-
properties: Map<string, {
|
|
713
|
-
predicate: string;
|
|
714
|
-
resolveLanguage?: string;
|
|
715
|
-
}>;
|
|
716
|
-
relations: Map<string, {
|
|
717
|
-
predicate: string;
|
|
718
|
-
instanceFilter?: string;
|
|
719
|
-
condition?: string;
|
|
720
|
-
}>;
|
|
721
|
-
} | null>;
|
|
722
729
|
/**
|
|
723
730
|
* Generates a SPARQL query to find instances based on class metadata.
|
|
724
731
|
*/
|
|
@@ -727,53 +734,12 @@ export declare class PerspectiveProxy {
|
|
|
727
734
|
* Returns base URIs of matching instances.
|
|
728
735
|
*/
|
|
729
736
|
private findInstancesByMetadata;
|
|
730
|
-
/**
|
|
731
|
-
* Gets a property value using SPARQL when Prolog fails.
|
|
732
|
-
* This is used as a fallback in SdnaOnly mode where link data isn't in Prolog.
|
|
733
|
-
*/
|
|
734
|
-
getPropertyValueViaSparql(baseExpression: string, className: string, propertyName: string): Promise<any>;
|
|
735
|
-
/**
|
|
736
|
-
* Gets relation values using SPARQL when Prolog fails.
|
|
737
|
-
* This is used as a fallback in SdnaOnly mode where link data isn't in Prolog.
|
|
738
|
-
* Note: This is used by Subject.ts (legacy pattern). Ad4mModel.ts uses getModelMetadata() instead.
|
|
739
|
-
*/
|
|
740
|
-
getRelationValuesViaSparql(baseExpression: string, className: string, relationName: string): Promise<any[]>;
|
|
741
|
-
/**
|
|
742
|
-
* Batch-checks multiple expressions against subject class metadata using a single or limited SPARQL queries.
|
|
743
|
-
* This avoids N+1 query problems by checking all values at once.
|
|
744
|
-
*/
|
|
745
|
-
batchCheckSubjectInstances(expressions: string[], metadata: {
|
|
746
|
-
requiredPredicates: string[];
|
|
747
|
-
requiredTriples: Array<{
|
|
748
|
-
predicate: string;
|
|
749
|
-
target?: string;
|
|
750
|
-
}>;
|
|
751
|
-
properties: Map<string, {
|
|
752
|
-
predicate: string;
|
|
753
|
-
resolveLanguage?: string;
|
|
754
|
-
}>;
|
|
755
|
-
relations: Map<string, {
|
|
756
|
-
predicate: string;
|
|
757
|
-
instanceFilter?: string;
|
|
758
|
-
condition?: string;
|
|
759
|
-
}>;
|
|
760
|
-
}): Promise<string[]>;
|
|
761
|
-
/**
|
|
762
|
-
* Fallback sequential instance checking when batch checking isn't available.
|
|
763
|
-
*/
|
|
764
|
-
private filterInstancesSequential;
|
|
765
737
|
/** Returns all subject instances of the given subject class as proxy objects.
|
|
766
738
|
* @param subjectClass Either a string with the name of the subject class, or an object
|
|
767
739
|
* with the properties of the subject class. In the latter case, all subject classes
|
|
768
740
|
* that match the given properties will be used.
|
|
769
741
|
*/
|
|
770
742
|
getAllSubjectInstances<T>(subjectClass: T): Promise<T[]>;
|
|
771
|
-
/** Returns all subject proxies of the given subject class as proxy objects.
|
|
772
|
-
* @param subjectClass Either a string with the name of the subject class, or an object
|
|
773
|
-
* with the properties of the subject class. In the latter case, all subject classes
|
|
774
|
-
* that match the given properties will be used.
|
|
775
|
-
*/
|
|
776
|
-
getAllSubjectProxies<T>(subjectClass: T): Promise<T[]>;
|
|
777
743
|
/**
|
|
778
744
|
* Find a subject class by matching an object's properties/relations against SHACL shapes.
|
|
779
745
|
* Queries SHACL links client-side to find a class whose properties contain all required ones.
|
|
@@ -805,6 +771,64 @@ export declare class PerspectiveProxy {
|
|
|
805
771
|
* Call this after wiping a perspective's links so that
|
|
806
772
|
* subsequent register() calls re-add SHACL definitions. */
|
|
807
773
|
clearEnsuredSubjectClasses(): void;
|
|
774
|
+
/**
|
|
775
|
+
* Returns a list of all class names that have been registered as SHACL
|
|
776
|
+
* subject classes in this perspective (via `ensureSDNASubjectClass` or `addSdna`).
|
|
777
|
+
*
|
|
778
|
+
* @returns Array of class name strings (e.g. `["Channel", "Message", "Task"]`)
|
|
779
|
+
*/
|
|
780
|
+
listRegisteredClasses(): Promise<string[]>;
|
|
781
|
+
/**
|
|
782
|
+
* Returns the SHACL shape metadata for a registered class, including
|
|
783
|
+
* property names, predicates, datatypes, and cardinality constraints.
|
|
784
|
+
*
|
|
785
|
+
* @param className - The name of the registered class
|
|
786
|
+
* @returns Shape metadata or `null` if the class is not registered
|
|
787
|
+
*/
|
|
788
|
+
getClassShape(className: string): Promise<{
|
|
789
|
+
className: string;
|
|
790
|
+
shapeUri: string;
|
|
791
|
+
properties: Array<{
|
|
792
|
+
name: string;
|
|
793
|
+
predicate: string;
|
|
794
|
+
datatype?: string;
|
|
795
|
+
required: boolean;
|
|
796
|
+
collection: boolean;
|
|
797
|
+
writable: boolean;
|
|
798
|
+
options?: Array<{
|
|
799
|
+
value: string;
|
|
800
|
+
label?: string;
|
|
801
|
+
}>;
|
|
802
|
+
}>;
|
|
803
|
+
} | null>;
|
|
804
|
+
/**
|
|
805
|
+
* Detects which registered subject classes a given instance conforms to,
|
|
806
|
+
* based on its stored triples matching the class shapes' required properties.
|
|
807
|
+
*
|
|
808
|
+
* @param baseExpression - The instance's base expression / subject URI
|
|
809
|
+
* @returns Array of class names the instance matches
|
|
810
|
+
*/
|
|
811
|
+
getInstanceClasses(baseExpression: string): Promise<string[]>;
|
|
812
|
+
/**
|
|
813
|
+
* Returns all named options (sh:in values) for a registered class, grouped by property.
|
|
814
|
+
*
|
|
815
|
+
* @param className - The name of the registered class
|
|
816
|
+
* @returns Record mapping property name → array of { value, label } options
|
|
817
|
+
*/
|
|
818
|
+
getNamedOptions(className: string): Promise<Record<string, Array<{
|
|
819
|
+
value: string;
|
|
820
|
+
label?: string;
|
|
821
|
+
}>>>;
|
|
822
|
+
/**
|
|
823
|
+
* Adds a named option (sh:in value) to a property of a registered class.
|
|
824
|
+
* This appends to the existing sh:in list stored on the property shape.
|
|
825
|
+
*
|
|
826
|
+
* @param className - The registered class name
|
|
827
|
+
* @param propertyName - The property to add the option to
|
|
828
|
+
* @param value - The RDF value for the option
|
|
829
|
+
* @param label - Optional human-readable label
|
|
830
|
+
*/
|
|
831
|
+
addNamedOption(className: string, propertyName: string, value: string, label?: string): Promise<void>;
|
|
808
832
|
getNeighbourhoodProxy(): NeighbourhoodProxy;
|
|
809
833
|
/**
|
|
810
834
|
* Returns a proxy object for working with AI capabilities.
|