@coasys/ad4m 0.13.1-staging.1 → 0.13.1-staging.2
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/lib/index.cjs +3789 -1192
- package/lib/index.js +3783 -1193
- package/lib/src/generated/api/AgentsByDidsRequest.d.ts +3 -0
- package/lib/src/generated/api/CallSessionInfo.d.ts +23 -0
- package/lib/src/generated/api/DiscardBatchRequest.d.ts +3 -0
- package/lib/src/generated/api/Events.d.ts +13 -3
- package/lib/src/generated/api/Events.js +1 -0
- package/lib/src/generated/api/FlowStateChangedEvent.d.ts +38 -0
- package/lib/src/generated/api/FlowStateEntry.d.ts +18 -0
- package/lib/src/generated/api/FlowStateEntry.js +2 -0
- package/lib/src/generated/api/IceServer.d.ts +18 -0
- package/lib/src/generated/api/IceServer.js +2 -0
- package/lib/src/generated/api/OnlineAgent.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveDiscardBatchParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveDiscardBatchParams.js +2 -0
- package/lib/src/generated/api/PerspectiveFlowFiredParams.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveFlowFiredParams.js +2 -0
- package/lib/src/generated/api/PerspectiveFlowStatesParams.d.ts +11 -0
- package/lib/src/generated/api/PerspectiveFlowStatesParams.js +2 -0
- package/lib/src/generated/api/PerspectiveGetAllShaclParams.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveGetAllShaclParams.js +2 -0
- package/lib/src/generated/api/PerspectiveModelQueryParams.d.ts +6 -1
- package/lib/src/generated/api/PerspectiveRemoveSubjectParams.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveRemoveSubjectParams.js +2 -0
- package/lib/src/generated/api/PerspectiveResynced.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveResynced.js +2 -0
- package/lib/src/generated/api/PerspectiveSubscribed.d.ts +10 -0
- package/lib/src/generated/api/PerspectiveSubscribed.js +2 -0
- package/lib/src/generated/api/PerspectiveUpdateSubjectParams.d.ts +10 -0
- package/lib/src/generated/api/PerspectiveUpdateSubjectParams.js +2 -0
- package/lib/src/generated/api/QuerySubscriptionUpdate.d.ts +19 -0
- package/lib/src/generated/api/QuerySubscriptionUpdate.js +2 -0
- package/lib/src/generated/api/QuerySubscriptionUpdateEvent.d.ts +7 -0
- package/lib/src/generated/api/QuerySubscriptionUpdateEvent.js +1 -0
- package/lib/src/generated/api/QueryUpdatesLagged.d.ts +7 -0
- package/lib/src/generated/api/QueryUpdatesLagged.js +2 -0
- package/lib/src/generated/api/RemoveSubjectRequest.d.ts +9 -0
- package/lib/src/generated/api/RemoveSubjectRequest.js +2 -0
- package/lib/src/generated/api/ResyncSubscriptionRequest.d.ts +3 -0
- package/lib/src/generated/api/ResyncSubscriptionRequest.js +2 -0
- package/lib/src/generated/api/RpcMethods.d.ts +134 -14
- package/lib/src/generated/api/RpcMethods.js +12 -0
- package/lib/src/generated/api/SfuAddIceCandidateParams.d.ts +8 -0
- package/lib/src/generated/api/SfuAddIceCandidateParams.js +2 -0
- package/lib/src/generated/api/SfuAnswerServerOfferParams.d.ts +8 -0
- package/lib/src/generated/api/SfuAnswerServerOfferParams.js +2 -0
- package/lib/src/generated/api/SfuCallJoinParams.d.ts +14 -0
- package/lib/src/generated/api/SfuCallJoinParams.js +2 -0
- package/lib/src/generated/api/SfuCallRenegotiationOffer.d.ts +30 -0
- package/lib/src/generated/api/SfuCallRenegotiationOffer.js +1 -0
- package/lib/src/generated/api/SfuCascadePipe.d.ts +4 -0
- package/lib/src/generated/api/SfuCascadePipe.js +2 -0
- package/lib/src/generated/api/SfuCascadeStatus.d.ts +8 -0
- package/lib/src/generated/api/SfuCascadeStatus.js +1 -0
- package/lib/src/generated/api/SfuConfig.d.ts +52 -0
- package/lib/src/generated/api/SfuConfig.js +1 -0
- package/lib/src/generated/api/SfuDataMessage.d.ts +24 -0
- package/lib/src/generated/api/SfuDataMessage.js +2 -0
- package/lib/src/generated/api/SfuEnsureMembershipParams.d.ts +4 -0
- package/lib/src/generated/api/SfuEnsureMembershipParams.js +2 -0
- package/lib/src/generated/api/SfuMigrateEvent.d.ts +21 -0
- package/lib/src/generated/api/SfuMigrateEvent.js +2 -0
- package/lib/src/generated/api/SfuNeighbourhoodParams.d.ts +3 -0
- package/lib/src/generated/api/SfuNeighbourhoodParams.js +2 -0
- package/lib/src/generated/api/SfuParticipantQualityPreference.d.ts +7 -0
- package/lib/src/generated/api/SfuParticipantQualityPreference.js +2 -0
- package/lib/src/generated/api/SfuPerspectiveParams.d.ts +6 -0
- package/lib/src/generated/api/SfuPerspectiveParams.js +2 -0
- package/lib/src/generated/api/SfuQualityPreferenceParams.d.ts +8 -0
- package/lib/src/generated/api/SfuQualityPreferenceParams.js +2 -0
- package/lib/src/generated/api/SfuRoomInfo.d.ts +11 -0
- package/lib/src/generated/api/SfuRoomInfo.js +1 -0
- package/lib/src/generated/api/SfuRoomParams.d.ts +4 -0
- package/lib/src/generated/api/SfuRoomParams.js +2 -0
- package/lib/src/generated/api/SfuRoomParticipantInfo.d.ts +11 -0
- package/lib/src/generated/api/SfuRoomParticipantInfo.js +2 -0
- package/lib/src/generated/api/SfuRoomRoster.d.ts +13 -0
- package/lib/src/generated/api/SfuRoomRoster.js +2 -0
- package/lib/src/generated/api/SfuSendDataParams.d.ts +10 -0
- package/lib/src/generated/api/SfuSendDataParams.js +2 -0
- package/lib/src/generated/api/SfuSetConfigParams.d.ts +5 -0
- package/lib/src/generated/api/SfuSetConfigParams.js +1 -0
- package/lib/src/generated/api/SfuStatus.d.ts +24 -0
- package/lib/src/generated/api/SfuStatus.js +2 -0
- package/lib/src/generated/api/TrackMapEntry.d.ts +17 -0
- package/lib/src/generated/api/TrackMapEntry.js +2 -0
- package/lib/src/generated/api/UpdateSubjectRequest.d.ts +12 -0
- package/lib/src/generated/api/UpdateSubjectRequest.js +2 -0
- package/lib/src/generated/api/index.d.ts +3 -0
- package/lib/src/index.d.ts +7 -0
- package/lib/src/index.js +4 -0
- package/lib/src/model/Ad4mModel.d.ts +84 -0
- package/lib/src/model/Ad4mModel.js +234 -4
- package/lib/src/model/ModelQueryBuilder.d.ts +16 -35
- package/lib/src/model/ModelQueryBuilder.js +88 -270
- package/lib/src/model/decorators.d.ts +32 -0
- package/lib/src/model/decorators.js +40 -1
- package/lib/src/model/shacl-gen.d.ts +3 -1
- package/lib/src/model/shacl-gen.js +13 -1
- package/lib/src/model/types.d.ts +7 -0
- package/lib/src/neighbourhood/MeshManager.d.ts +384 -0
- package/lib/src/neighbourhood/MeshManager.js +1144 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +91 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.js +196 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +55 -1
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +170 -3
- package/lib/src/neighbourhood/Session.d.ts +105 -0
- package/lib/src/neighbourhood/Session.js +412 -0
- package/lib/src/neighbourhood/SfuManager.d.ts +174 -0
- package/lib/src/neighbourhood/SfuManager.js +619 -0
- package/lib/src/neighbourhood/SfuTypes.d.ts +35 -0
- package/lib/src/neighbourhood/SfuTypes.js +8 -0
- package/lib/src/perspectives/FlowInstance.d.ts +63 -24
- package/lib/src/perspectives/FlowInstance.js +74 -31
- package/lib/src/perspectives/FlowModels.d.ts +0 -16
- package/lib/src/perspectives/FlowModels.js +8 -16
- package/lib/src/perspectives/LiveQuery.d.ts +49 -0
- package/lib/src/perspectives/LiveQuery.js +169 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +24 -15
- package/lib/src/perspectives/PerspectiveClient.js +33 -36
- package/lib/src/perspectives/PerspectiveProxy.d.ts +67 -167
- package/lib/src/perspectives/PerspectiveProxy.js +121 -475
- package/lib/src/perspectives/TextContent.d.ts +31 -0
- package/lib/src/perspectives/TextContent.js +52 -0
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +23 -0
- package/lib/src/perspectives/WakerSubscriptionManager.js +58 -17
- package/lib/src/shacl/SHACLFlow.d.ts +7 -4
- package/lib/src/shacl/SHACLFlow.js +7 -4
- package/lib/src/shacl/SHACLShape.d.ts +9 -0
- package/lib/src/shacl/SHACLShape.js +37 -0
- package/package.json +2 -2
- package/pnpm-workspace.yaml +4 -1
- package/src/Ad4mClient.test.ts +89 -17
- package/src/generated/api/AgentsByDidsRequest.ts +3 -0
- package/src/generated/api/CallSessionInfo.ts +20 -0
- package/src/generated/api/DiscardBatchRequest.ts +3 -0
- package/src/generated/api/Events.ts +14 -3
- package/src/generated/api/FlowStateChangedEvent.ts +36 -0
- package/src/generated/api/FlowStateEntry.ts +18 -0
- package/src/generated/api/IceServer.ts +19 -0
- package/src/generated/api/OnlineAgent.ts +6 -1
- package/src/generated/api/PerspectiveDiscardBatchParams.ts +3 -0
- package/src/generated/api/PerspectiveFlowFiredParams.ts +7 -0
- package/src/generated/api/PerspectiveFlowStatesParams.ts +11 -0
- package/src/generated/api/PerspectiveGetAllShaclParams.ts +6 -0
- package/src/generated/api/PerspectiveModelQueryParams.ts +5 -1
- package/src/generated/api/PerspectiveRemoveSubjectParams.ts +3 -0
- package/src/generated/api/PerspectiveResynced.ts +7 -0
- package/src/generated/api/PerspectiveSubscribed.ts +8 -0
- package/src/generated/api/PerspectiveUpdateSubjectParams.ts +7 -0
- package/src/generated/api/QuerySubscriptionUpdate.ts +10 -0
- package/src/generated/api/QuerySubscriptionUpdateEvent.ts +9 -0
- package/src/generated/api/QueryUpdatesLagged.ts +7 -0
- package/src/generated/api/RemoveSubjectRequest.ts +7 -0
- package/src/generated/api/ResyncSubscriptionRequest.ts +3 -0
- package/src/generated/api/RpcMethods.ts +68 -8
- package/src/generated/api/SfuAddIceCandidateParams.ts +7 -0
- package/src/generated/api/SfuAnswerServerOfferParams.ts +7 -0
- package/src/generated/api/SfuCallJoinParams.ts +13 -0
- package/src/generated/api/SfuCallRenegotiationOffer.ts +29 -0
- package/src/generated/api/SfuCascadePipe.ts +3 -0
- package/src/generated/api/SfuCascadeStatus.ts +7 -0
- package/src/generated/api/SfuConfig.ts +53 -0
- package/src/generated/api/SfuDataMessage.ts +23 -0
- package/src/generated/api/SfuEnsureMembershipParams.ts +3 -0
- package/src/generated/api/SfuMigrateEvent.ts +20 -0
- package/src/generated/api/{KeepAliveQueryRequest.ts → SfuNeighbourhoodParams.ts} +1 -1
- package/src/generated/api/SfuParticipantQualityPreference.ts +6 -0
- package/src/generated/api/{PerspectiveSubscribeQueryResult.ts → SfuPerspectiveParams.ts} +4 -1
- package/src/generated/api/SfuQualityPreferenceParams.ts +7 -0
- package/src/generated/api/SfuRoomInfo.ts +7 -0
- package/src/generated/api/SfuRoomParams.ts +3 -0
- package/src/generated/api/SfuRoomParticipantInfo.ts +8 -0
- package/src/generated/api/SfuRoomRoster.ts +12 -0
- package/src/generated/api/SfuSendDataParams.ts +7 -0
- package/src/generated/api/SfuSetConfigParams.ts +4 -0
- package/src/generated/api/SfuStatus.ts +24 -0
- package/src/generated/api/TrackMapEntry.ts +18 -0
- package/src/generated/api/UpdateSubjectRequest.ts +10 -0
- package/src/generated/api/index.ts +3 -0
- package/src/index.ts +7 -0
- package/src/model/Ad4mModel.test.ts +255 -231
- package/src/model/Ad4mModel.ts +271 -4
- package/src/model/ModelQueryBuilder.ts +103 -310
- package/src/model/abstract-classes.test.ts +225 -0
- package/src/model/decorators.ts +81 -0
- package/src/model/shacl-gen.ts +13 -0
- package/src/model/types.ts +7 -0
- package/src/neighbourhood/MeshManager.test.ts +2640 -0
- package/src/neighbourhood/MeshManager.ts +1350 -0
- package/src/neighbourhood/NeighbourhoodClient.ts +271 -0
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +23 -0
- package/src/neighbourhood/NeighbourhoodProxy.ts +247 -1
- package/src/neighbourhood/Session.test.ts +800 -0
- package/src/neighbourhood/Session.ts +525 -0
- package/src/neighbourhood/SfuManager.test.ts +677 -0
- package/src/neighbourhood/SfuManager.ts +803 -0
- package/src/neighbourhood/SfuTypes.ts +40 -0
- package/src/perspectives/FlowInstance.ts +108 -31
- package/src/perspectives/FlowModels.ts +8 -18
- package/src/perspectives/LiveQuery.test.ts +197 -0
- package/src/perspectives/LiveQuery.ts +189 -0
- package/src/perspectives/PerspectiveClient.ts +51 -51
- package/src/perspectives/PerspectiveProxy.test.ts +85 -401
- package/src/perspectives/PerspectiveProxy.ts +126 -536
- package/src/perspectives/TextContent.test.ts +123 -0
- package/src/perspectives/TextContent.ts +36 -0
- package/src/perspectives/WakerSubscriptionManager.test.ts +88 -6
- package/src/perspectives/WakerSubscriptionManager.ts +69 -18
- package/src/shacl/SHACLFlow.ts +7 -4
- package/src/shacl/SHACLShape.test.ts +2 -1
- package/src/shacl/SHACLShape.ts +49 -0
- package/lib/src/generated/api/KeepAliveQueryRequest.d.ts +0 -3
- package/lib/src/generated/api/PerspectiveModelSubscribeResult.d.ts +0 -7
- package/lib/src/generated/api/PerspectiveQuerySubscriptionFilter.d.ts +0 -6
- package/lib/src/generated/api/PerspectiveSubscribeQueryResult.d.ts +0 -4
- package/src/generated/api/PerspectiveModelSubscribeResult.ts +0 -6
- package/src/generated/api/PerspectiveQuerySubscriptionFilter.ts +0 -3
- /package/lib/src/generated/api/{KeepAliveQueryRequest.js → AgentsByDidsRequest.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveModelSubscribeResult.js → CallSessionInfo.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveQuerySubscriptionFilter.js → DiscardBatchRequest.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveSubscribeQueryResult.js → FlowStateChangedEvent.js} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK's TextContent mirrors the executor's built-in
|
|
3
|
+
* (`hardwired_sdna/text_content.json`), is read by its URI, and is never
|
|
4
|
+
* registered in a perspective (#1446).
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import { TextContent } from "./TextContent";
|
|
9
|
+
import { Ad4mModel } from "../model/Ad4mModel";
|
|
10
|
+
import { Model, Property } from "../model/decorators";
|
|
11
|
+
|
|
12
|
+
const SDNA = JSON.parse(
|
|
13
|
+
fs.readFileSync(
|
|
14
|
+
path.resolve(__dirname, "../../../rust-executor/src/perspectives/hardwired_sdna/text_content.json"),
|
|
15
|
+
"utf-8",
|
|
16
|
+
),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
describe("TextContent", () => {
|
|
20
|
+
it("matches the executor's built-in shape", () => {
|
|
21
|
+
const { shape } = (TextContent as any).generateSHACL();
|
|
22
|
+
expect(shape.targetClass).toBe(SDNA.target_class);
|
|
23
|
+
expect(shape.isAbstract).toBe(SDNA.abstract);
|
|
24
|
+
expect(shape.properties.map((p: any) => [p.path, p.name])).toEqual(
|
|
25
|
+
SDNA.properties.map((p: any) => [p.path, p.name]),
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("is queried by its URI; a class extending it is not", () => {
|
|
30
|
+
expect((TextContent as any).prepareModelQueryParams({}).className).toBe("ad4m://TextContent");
|
|
31
|
+
|
|
32
|
+
@Model({ name: "OwnText" })
|
|
33
|
+
class OwnText extends TextContent {
|
|
34
|
+
@Property({ through: "app://extra" })
|
|
35
|
+
extra: string = "";
|
|
36
|
+
}
|
|
37
|
+
expect((OwnText as any).prepareModelQueryParams({}).className).toBe("OwnText");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("is sent by its URI in a union too, so the executor refuses it as abstract", async () => {
|
|
41
|
+
@Model({ name: "UnionPeer" })
|
|
42
|
+
class UnionPeer extends Ad4mModel {
|
|
43
|
+
@Property({ through: "app://peer" })
|
|
44
|
+
peer: string = "";
|
|
45
|
+
}
|
|
46
|
+
expect(Ad4mModel.prepareUnionQueryParams([TextContent, UnionPeer] as any, {}).classNames).toEqual([
|
|
47
|
+
"ad4m://TextContent",
|
|
48
|
+
"UnionPeer",
|
|
49
|
+
]);
|
|
50
|
+
const sent: any[] = [];
|
|
51
|
+
const perspective: any = {
|
|
52
|
+
modelQuery: async (classNames: any) => {
|
|
53
|
+
sent.push(classNames);
|
|
54
|
+
throw new Error("classNames: 'ad4m://TextContent' is an abstract class.");
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
await expect(Ad4mModel.findAllOf(perspective, [TextContent, UnionPeer] as any)).rejects.toThrow("abstract class");
|
|
58
|
+
expect(sent).toEqual([["ad4m://TextContent", "UnionPeer"]]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("is implemented through an alias", () => {
|
|
62
|
+
expect(() => {
|
|
63
|
+
@Model({ name: "FluxishMessage", implements: [TextContent] })
|
|
64
|
+
class FluxishMessage extends Ad4mModel {
|
|
65
|
+
@Property({ through: "flux://body", alias: { TextContent: "text" } })
|
|
66
|
+
body: string = "";
|
|
67
|
+
}
|
|
68
|
+
}).not.toThrow();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("register() writes nothing", async () => {
|
|
72
|
+
const { PerspectiveProxy } = await import("./PerspectiveProxy");
|
|
73
|
+
const calls: string[] = [];
|
|
74
|
+
const proxy = Object.create(PerspectiveProxy.prototype);
|
|
75
|
+
// The skip comes before anything else: a write would be recorded, and
|
|
76
|
+
// reaching the private registration set throws on this bare object.
|
|
77
|
+
Object.defineProperty(proxy, "addSdna", { value: () => { calls.push("addSdna"); } });
|
|
78
|
+
Object.defineProperty(proxy, "addSdnaAll", { value: () => { calls.push("addSdnaAll"); } });
|
|
79
|
+
await expect(proxy.ensureSubjectClasses([TextContent])).resolves.toBeUndefined();
|
|
80
|
+
await expect(proxy.ensureSubjectClass(TextContent)).resolves.toBeUndefined();
|
|
81
|
+
expect(calls).toEqual([]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("save() and delete() of a row read through it go to the executor by its URI", async () => {
|
|
85
|
+
const calls: any[][] = [];
|
|
86
|
+
const client: any = new Proxy({}, {
|
|
87
|
+
get: (_t, key) => async (...args: any[]) => {
|
|
88
|
+
calls.push([key, ...args]);
|
|
89
|
+
if (key === "modelQuery") {
|
|
90
|
+
return { instances: [{ id: "ad4m://m/1", __subjectClass: "Message", text: "hi" }], totalCount: 1 };
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
const { PerspectiveProxy } = await import("./PerspectiveProxy");
|
|
96
|
+
const proxy = new PerspectiveProxy({ uuid: "p" } as any, client);
|
|
97
|
+
const [row] = await TextContent.findAll(proxy);
|
|
98
|
+
row.text = "edited";
|
|
99
|
+
calls.length = 0;
|
|
100
|
+
await row.save("batch");
|
|
101
|
+
expect(calls).toEqual([["updateSubject", "p", "ad4m://TextContent", "ad4m://m/1", JSON.stringify({ text: "edited" }), "batch"]]);
|
|
102
|
+
|
|
103
|
+
calls.length = 0;
|
|
104
|
+
await row.delete("batch");
|
|
105
|
+
expect(calls[0]).toEqual(["removeSubject", "p", "ad4m://TextContent", "ad4m://m/1", "batch"]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("delete() through it drops the perspective's cached query results, like an update", async () => {
|
|
109
|
+
const { setCachedResult, getCachedResult } = await import("../model/query-cache");
|
|
110
|
+
const client: any = new Proxy({}, { get: () => async () => true });
|
|
111
|
+
const { PerspectiveProxy } = await import("./PerspectiveProxy");
|
|
112
|
+
const proxy = new PerspectiveProxy({ uuid: "p-cache" } as any, client);
|
|
113
|
+
const row = new TextContent(proxy, "ad4m://m/1");
|
|
114
|
+
|
|
115
|
+
setCachedResult("p-cache", "SELECT ?v", [{ v: "old" }]);
|
|
116
|
+
await proxy.updateSubject("ad4m://TextContent", "ad4m://m/1", { text: "new" });
|
|
117
|
+
expect(getCachedResult("p-cache", "SELECT ?v")).toBeUndefined();
|
|
118
|
+
|
|
119
|
+
setCachedResult("p-cache", "SELECT ?v", [{ v: "old" }]);
|
|
120
|
+
await row.delete();
|
|
121
|
+
expect(getCachedResult("p-cache", "SELECT ?v")).toBeUndefined();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Ad4mModel } from "../model/Ad4mModel";
|
|
2
|
+
import { Model, Property } from "../model/decorators";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The built-in abstract class `TextContent { text }` (#1446): text a view or
|
|
6
|
+
* an LLM can read — a message, a note, a block of a document. `text` may
|
|
7
|
+
* contain HTML or Markdown.
|
|
8
|
+
*
|
|
9
|
+
* Querying it reads every class that has a `text` property, or a property
|
|
10
|
+
* aliased to `text`:
|
|
11
|
+
*
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Model({ name: "Message", implements: [TextContent] })
|
|
14
|
+
* class Message extends Ad4mModel {
|
|
15
|
+
* @Property({ through: "flux://body", alias: { TextContent: "text" } })
|
|
16
|
+
* body: string = "";
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* const everything = await TextContent.findAll(perspective, { parent: { id: channel } });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Built in: the executor declares it (mirrors
|
|
23
|
+
* `rust-executor/src/perspectives/hardwired_sdna/text_content.json`) and
|
|
24
|
+
* reads it by its URI, `ad4m://TextContent`, so a perspective never stores it
|
|
25
|
+
* and an app class named `TextContent` does not replace it. `register()` on
|
|
26
|
+
* it writes nothing.
|
|
27
|
+
*/
|
|
28
|
+
@Model({ name: "TextContent", abstract: true })
|
|
29
|
+
export class TextContent extends Ad4mModel {
|
|
30
|
+
/** The URI the executor reads it by. */
|
|
31
|
+
static readonly builtinUri = "ad4m://TextContent";
|
|
32
|
+
|
|
33
|
+
/** The text. May contain HTML or Markdown. */
|
|
34
|
+
@Property({ through: "ad4m://text" })
|
|
35
|
+
text: string = "";
|
|
36
|
+
}
|
|
@@ -185,7 +185,7 @@ describe('WakerSubscriptionManager', () => {
|
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
/** Delivers one new mention and returns the parents it woke with, the parent query and any warnings. */
|
|
188
|
-
async function wakeWithParentRows(rows: unknown) {
|
|
188
|
+
async function wakeWithParentRows(rows: unknown, ancestorDepth?: number, address = 'test://message') {
|
|
189
189
|
let deliver: ((result: any) => Promise<void>) | undefined;
|
|
190
190
|
const ProxyClass = function () {
|
|
191
191
|
return {
|
|
@@ -200,7 +200,7 @@ describe('WakerSubscriptionManager', () => {
|
|
|
200
200
|
const client = {
|
|
201
201
|
querySparql: (_uuid: string, query: string) => {
|
|
202
202
|
queries.push(query);
|
|
203
|
-
return Promise.resolve(rows);
|
|
203
|
+
return Promise.resolve(typeof rows === 'function' ? rows(query) : rows);
|
|
204
204
|
},
|
|
205
205
|
};
|
|
206
206
|
const wakes: any[] = [];
|
|
@@ -210,11 +210,12 @@ describe('WakerSubscriptionManager', () => {
|
|
|
210
210
|
QuerySubscriptionProxy: ProxyClass,
|
|
211
211
|
debounceMs: 10,
|
|
212
212
|
retryPendingMs: 60_000,
|
|
213
|
+
...(ancestorDepth !== undefined ? { ancestorDepth } : {}),
|
|
213
214
|
onWake: (_sub, _result, mentions) => { wakes.push(mentions); },
|
|
214
215
|
});
|
|
215
216
|
|
|
216
217
|
await manager.subscribe({ ...sub, id: 'mention-parents' });
|
|
217
|
-
await deliver!([{ source:
|
|
218
|
+
await deliver!([{ source: address }]);
|
|
218
219
|
await waitUntil(() => wakes.length > 0);
|
|
219
220
|
manager.disposeAll();
|
|
220
221
|
return { wakes, queries, warnings };
|
|
@@ -223,20 +224,101 @@ describe('WakerSubscriptionManager', () => {
|
|
|
223
224
|
it('resolves the parents of a new mention from the flat rows querySparql returns', async () => {
|
|
224
225
|
const { wakes, queries } = await wakeWithParentRows([{ source: 'test://parent' }]);
|
|
225
226
|
expect(queries[0]).toContain('<ad4m://has_child> <test://message>');
|
|
226
|
-
expect(wakes).toEqual([[{ address: 'test://message', parents: ['test://parent'] }]]);
|
|
227
|
+
expect(wakes).toEqual([[{ address: 'test://message', parents: ['test://parent'], ancestors: [] }]]);
|
|
227
228
|
});
|
|
228
229
|
|
|
229
230
|
it('keeps only string parents when a row leaves ?source unbound', async () => {
|
|
230
231
|
const { wakes } = await wakeWithParentRows([{ source: 'test://a' }, {}, { source: 'test://b' }]);
|
|
231
|
-
expect(wakes).toEqual([[{ address: 'test://message', parents: ['test://a', 'test://b'] }]]);
|
|
232
|
+
expect(wakes).toEqual([[{ address: 'test://message', parents: ['test://a', 'test://b'], ancestors: [] }]]);
|
|
232
233
|
});
|
|
233
234
|
|
|
234
235
|
it('reports no parents, without a warning, when querySparql returns a non-array', async () => {
|
|
235
236
|
const { wakes, warnings } = await wakeWithParentRows(true);
|
|
236
|
-
expect(wakes).toEqual([[{ address: 'test://message', parents: [] }]]);
|
|
237
|
+
expect(wakes).toEqual([[{ address: 'test://message', parents: [], ancestors: [] }]]);
|
|
237
238
|
expect(warnings).toEqual([]);
|
|
238
239
|
});
|
|
239
240
|
|
|
241
|
+
/** Containment as a map of child → parents, answered per query the way querySparql would. */
|
|
242
|
+
const tree = (parents: Record<string, string[]>) => (query: string) => {
|
|
243
|
+
const values = /VALUES \?child \{([^}]+)\}/.exec(query)?.[1];
|
|
244
|
+
const children = values
|
|
245
|
+
? Array.from(values.matchAll(/<([^>]+)>/g), (match) => match[1])
|
|
246
|
+
: [/<ad4m:\/\/has_child> <([^>]+)>/.exec(query)?.[1] ?? ''];
|
|
247
|
+
return children.flatMap((child) => (parents[child] ?? []).map((source) => ({ source })));
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
it('reports the chain above the parents, nearest first, each address once', async () => {
|
|
251
|
+
// A message in a thread in a call in a space — and the call is also in a second channel, so two
|
|
252
|
+
// paths reach the space.
|
|
253
|
+
const { wakes } = await wakeWithParentRows(
|
|
254
|
+
tree({
|
|
255
|
+
'test://message': ['test://thread'],
|
|
256
|
+
'test://thread': ['test://call'],
|
|
257
|
+
'test://call': ['test://space', 'test://channel'],
|
|
258
|
+
'test://channel': ['test://space'],
|
|
259
|
+
}),
|
|
260
|
+
);
|
|
261
|
+
expect(wakes).toEqual([
|
|
262
|
+
[
|
|
263
|
+
{
|
|
264
|
+
address: 'test://message',
|
|
265
|
+
parents: ['test://thread'],
|
|
266
|
+
ancestors: ['test://call', 'test://space', 'test://channel'],
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
]);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('stops at its depth, and at a cycle, rather than walking forever', async () => {
|
|
273
|
+
const { wakes } = await wakeWithParentRows(
|
|
274
|
+
tree({
|
|
275
|
+
'test://message': ['test://a'],
|
|
276
|
+
'test://a': ['test://b'],
|
|
277
|
+
'test://b': ['test://c'],
|
|
278
|
+
'test://c': ['test://message'],
|
|
279
|
+
}),
|
|
280
|
+
5,
|
|
281
|
+
);
|
|
282
|
+
// c leads back to the message: seen already, so the walk ends there rather than going round.
|
|
283
|
+
expect(wakes[0][0].ancestors).toEqual(['test://b', 'test://c']);
|
|
284
|
+
const shallow = await wakeWithParentRows(tree({ 'test://message': ['test://a'], 'test://a': ['test://b'], 'test://b': ['test://c'] }), 1);
|
|
285
|
+
expect(shallow.wakes[0][0].ancestors).toEqual(['test://b']);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('looks up a branching ancestor level in one query', async () => {
|
|
289
|
+
const { wakes, queries } = await wakeWithParentRows(tree({
|
|
290
|
+
'test://message': ['test://left', 'test://right'],
|
|
291
|
+
'test://left': ['test://root'],
|
|
292
|
+
'test://right': ['test://root'],
|
|
293
|
+
}));
|
|
294
|
+
expect(wakes[0][0].ancestors).toEqual(['test://root']);
|
|
295
|
+
expect(queries).toHaveLength(3);
|
|
296
|
+
expect(queries[1]).toContain('VALUES ?child { <test://left> <test://right> }');
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it.each(['<', '>', '"', '{', '}', '|', '^', '`', '\\', ' ', '\t', '\n', '\u0000'])(
|
|
300
|
+
'does not query an unsafe mention address containing %p', async (character) => {
|
|
301
|
+
const address = `test://unsafe${character}address`;
|
|
302
|
+
const { wakes, queries, warnings } = await wakeWithParentRows([], 3, address);
|
|
303
|
+
expect(queries).toEqual([]);
|
|
304
|
+
expect(wakes[0][0]).toEqual({ address, parents: [], ancestors: [] });
|
|
305
|
+
expect(warnings).toHaveLength(1);
|
|
306
|
+
expect(warnings[0]).toContain('unsafe address');
|
|
307
|
+
},
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
it('skips an unsafe ancestor lookup without dropping safe siblings', async () => {
|
|
311
|
+
const unsafe = 'test://bad> . ?s ?p ?o . #';
|
|
312
|
+
const { wakes, queries, warnings } = await wakeWithParentRows(tree({
|
|
313
|
+
'test://message': [unsafe, 'test://safe'],
|
|
314
|
+
'test://safe': ['test://root'],
|
|
315
|
+
}));
|
|
316
|
+
expect(wakes[0][0].ancestors).toEqual(['test://root']);
|
|
317
|
+
expect(queries).toHaveLength(3);
|
|
318
|
+
expect(queries.every((query) => !query.includes(unsafe))).toBe(true);
|
|
319
|
+
expect(warnings).toHaveLength(1);
|
|
320
|
+
});
|
|
321
|
+
|
|
240
322
|
it('names the operator as the fix for a locked executor, on both message shapes', () => {
|
|
241
323
|
// Current executor message (post-#973) and the older internal error must
|
|
242
324
|
// both map to the same hint, and the hint must point at the node operator —
|
|
@@ -22,6 +22,12 @@ export interface MentionMessage {
|
|
|
22
22
|
address: string;
|
|
23
23
|
/** All parent addresses this message belongs to (channels, conversations, etc.). */
|
|
24
24
|
parents: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Everything above the parents, nearest first: their parents, theirs, and so on up to the
|
|
27
|
+
* manager's `ancestorDepth`. Each address once, however many paths reach it. Empty when the
|
|
28
|
+
* parents have none, or the walk could not be made.
|
|
29
|
+
*/
|
|
30
|
+
ancestors: string[];
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
export interface WakerLogger {
|
|
@@ -38,6 +44,12 @@ export interface WakerSubscriptionManagerOptions {
|
|
|
38
44
|
logger: WakerLogger;
|
|
39
45
|
/** Debounce interval in ms before firing the wake callback (default 2000) */
|
|
40
46
|
debounceMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* How many levels above a mentioned item's parents to report as `ancestors` (default 3).
|
|
49
|
+
* Each level is one batched query, so the walk is bounded by this depth and by
|
|
50
|
+
* what the levels hold. 0 reports parents only.
|
|
51
|
+
*/
|
|
52
|
+
ancestorDepth?: number;
|
|
41
53
|
/** Called when a subscription fires (after debounce). Return value is ignored.
|
|
42
54
|
* For mention subs, `mentions` contains per-message parent info. */
|
|
43
55
|
onWake: (sub: WakerSubscription, result: any, mentions?: MentionMessage[]) => void;
|
|
@@ -108,6 +120,7 @@ export class WakerSubscriptionManager {
|
|
|
108
120
|
private perspectiveClient: any;
|
|
109
121
|
private logger: WakerLogger;
|
|
110
122
|
private debounceMs: number;
|
|
123
|
+
private ancestorDepth: number;
|
|
111
124
|
private onWake: (sub: WakerSubscription, result: any, mentions?: MentionMessage[]) => void;
|
|
112
125
|
private onPersist?: (subscriptions: WakerSubscription[], seenMessages: Record<string, string[]>) => void;
|
|
113
126
|
private QuerySubscriptionProxyCtor: any;
|
|
@@ -141,6 +154,7 @@ export class WakerSubscriptionManager {
|
|
|
141
154
|
this.perspectiveClient = options.perspectiveClient;
|
|
142
155
|
this.logger = options.logger;
|
|
143
156
|
this.debounceMs = options.debounceMs ?? 2000;
|
|
157
|
+
this.ancestorDepth = options.ancestorDepth ?? 3;
|
|
144
158
|
this.onWake = options.onWake;
|
|
145
159
|
this.onPersist = options.onPersist;
|
|
146
160
|
this.QuerySubscriptionProxyCtor = options.QuerySubscriptionProxy ?? null;
|
|
@@ -185,7 +199,6 @@ export class WakerSubscriptionManager {
|
|
|
185
199
|
sub.query,
|
|
186
200
|
this.perspectiveClient,
|
|
187
201
|
);
|
|
188
|
-
proxy.isSPARQL = true;
|
|
189
202
|
// Suppress unhandled rejection from proxy.initialized — QuerySubscriptionProxy
|
|
190
203
|
// rejects this promise internally when subscribe() fails, and if nobody catches
|
|
191
204
|
// it before the next microtask it crashes the process.
|
|
@@ -291,27 +304,17 @@ export class WakerSubscriptionManager {
|
|
|
291
304
|
`[waker] ${sub.id}: ${newMessages.length} new message(s) out of ${result.length} total`,
|
|
292
305
|
);
|
|
293
306
|
|
|
294
|
-
// Resolve parents per new message
|
|
307
|
+
// Resolve parents, and the chain above them, per new message
|
|
295
308
|
const mentions: MentionMessage[] = [];
|
|
296
309
|
for (const msgAddr of newMessages) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
this.logger.info(`[waker] ${sub.id}: resolving parents for ${msgAddr}`);
|
|
301
|
-
const rows: unknown = await this.perspectiveClient.querySparql(sub.perspective, parentQuery);
|
|
302
|
-
if (Array.isArray(rows)) {
|
|
303
|
-
// A row omits a variable left unbound in its solution.
|
|
304
|
-
parents.push(...rows.map((row) => row?.source).filter((source): source is string => typeof source === "string"));
|
|
305
|
-
}
|
|
306
|
-
} catch (err: any) {
|
|
307
|
-
this.logger.warn(
|
|
308
|
-
`[waker] ${sub.id}: parent resolution failed for ${msgAddr} — ${err?.message ?? err}`,
|
|
309
|
-
);
|
|
310
|
-
}
|
|
310
|
+
this.logger.info(`[waker] ${sub.id}: resolving parents for ${msgAddr}`);
|
|
311
|
+
const parents = await this.parentsOf(sub, [msgAddr]);
|
|
312
|
+
const ancestors = await this.ancestorsOf(sub, msgAddr, parents);
|
|
311
313
|
this.logger.info(
|
|
312
|
-
`[waker] ${sub.id}: message ${msgAddr} has ${parents.length} parent(s): ${parents.join(", ")}
|
|
314
|
+
`[waker] ${sub.id}: message ${msgAddr} has ${parents.length} parent(s): ${parents.join(", ")}` +
|
|
315
|
+
(ancestors.length ? `; ancestors: ${ancestors.join(", ")}` : ""),
|
|
313
316
|
);
|
|
314
|
-
mentions.push({ address: msgAddr, parents });
|
|
317
|
+
mentions.push({ address: msgAddr, parents, ancestors });
|
|
315
318
|
}
|
|
316
319
|
|
|
317
320
|
// Mark all new messages as seen
|
|
@@ -464,6 +467,54 @@ export class WakerSubscriptionManager {
|
|
|
464
467
|
return this.activeSubscriptions.has(id);
|
|
465
468
|
}
|
|
466
469
|
|
|
470
|
+
/** Resolve one containment level in one query; skip unsafe IRI tokens and treat failures as none. */
|
|
471
|
+
private async parentsOf(sub: WakerSubscription, addresses: string[]): Promise<string[]> {
|
|
472
|
+
const safe = [...new Set(addresses)].filter((address) => {
|
|
473
|
+
if (/[<>"{}|^`\\\s\x00-\x20]/.test(address)) {
|
|
474
|
+
this.logger.warn(`[waker] ${sub.id}: skipping parent lookup for unsafe address ${JSON.stringify(address)}`);
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
return true;
|
|
478
|
+
});
|
|
479
|
+
if (!safe.length) return [];
|
|
480
|
+
try {
|
|
481
|
+
const query = safe.length === 1
|
|
482
|
+
? `SELECT ?source WHERE { ?source <ad4m://has_child> <${safe[0]}> . }`
|
|
483
|
+
: `SELECT ?source WHERE { VALUES ?child { ${safe.map((address) => `<${address}>`).join(" ")} } ?source <ad4m://has_child> ?child . }`;
|
|
484
|
+
const rows: unknown = await this.perspectiveClient.querySparql(sub.perspective, query);
|
|
485
|
+
if (!Array.isArray(rows)) return [];
|
|
486
|
+
// A row omits a variable left unbound in its solution.
|
|
487
|
+
return rows.map((row) => row?.source).filter((source): source is string => typeof source === "string");
|
|
488
|
+
} catch (err: any) {
|
|
489
|
+
this.logger.warn(`[waker] ${sub.id}: parent resolution failed for ${JSON.stringify(safe)} — ${err?.message ?? err}`);
|
|
490
|
+
return [];
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* The chain above an item's parents, a level at a time, nearest first, up to `ancestorDepth`.
|
|
496
|
+
*
|
|
497
|
+
* Breadth-first with a visited set: containment is a graph, not a tree — an item can sit in two
|
|
498
|
+
* places, and nothing stops a cycle — so each address is reported once and the walk always ends.
|
|
499
|
+
* Each level uses one batched parent lookup, bounded by the depth.
|
|
500
|
+
*/
|
|
501
|
+
private async ancestorsOf(sub: WakerSubscription, address: string, parents: string[]): Promise<string[]> {
|
|
502
|
+
const seen = new Set<string>([address, ...parents]);
|
|
503
|
+
const ancestors: string[] = [];
|
|
504
|
+
let level = parents;
|
|
505
|
+
for (let depth = 0; depth < this.ancestorDepth && level.length; depth++) {
|
|
506
|
+
const next: string[] = [];
|
|
507
|
+
for (const parent of await this.parentsOf(sub, level)) {
|
|
508
|
+
if (seen.has(parent)) continue;
|
|
509
|
+
seen.add(parent);
|
|
510
|
+
next.push(parent);
|
|
511
|
+
}
|
|
512
|
+
ancestors.push(...next);
|
|
513
|
+
level = next;
|
|
514
|
+
}
|
|
515
|
+
return ancestors;
|
|
516
|
+
}
|
|
517
|
+
|
|
467
518
|
private persist(): void {
|
|
468
519
|
if (this.onPersist) {
|
|
469
520
|
const seen: Record<string, string[]> = {};
|
package/src/shacl/SHACLFlow.ts
CHANGED
|
@@ -317,10 +317,13 @@ export interface FlowTransition {
|
|
|
317
317
|
* - What states exist and their per-state guards (via `requires`)
|
|
318
318
|
* - How to transition between states (via transitions + consensus rules)
|
|
319
319
|
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
320
|
+
* A running instance's state is not stored on the graph: the executor
|
|
321
|
+
* derives it from the signed transition proposals and keeps what it derived
|
|
322
|
+
* per agent, outside the perspective (#1424). Read it through the
|
|
323
|
+
* `FlowInstance` wrapper ({@link FlowInstance.start} /
|
|
324
|
+
* {@link FlowInstance.findAll}, `currentStateName`) or
|
|
325
|
+
* `PerspectiveProxy.flowStates`, and follow it with
|
|
326
|
+
* `PerspectiveProxy.onFlowStateChanged` — see design doc §4.3/§5.
|
|
324
327
|
*
|
|
325
328
|
* @example
|
|
326
329
|
* ```typescript
|
|
@@ -5,7 +5,8 @@ import { join } from 'path';
|
|
|
5
5
|
import { Parser } from 'n3';
|
|
6
6
|
|
|
7
7
|
// Links the executor's parse_shacl_to_links writes for a shape that uses every
|
|
8
|
-
// field (golden[0])
|
|
8
|
+
// field (golden[0]), one with empty action lists (golden[1]) and an abstract
|
|
9
|
+
// class (golden[2], #1435); its test
|
|
9
10
|
// `parse_shacl_to_links_matches_the_golden_fixture` pins the same file.
|
|
10
11
|
const goldenCases = JSON.parse(readFileSync(
|
|
11
12
|
join(__dirname, '../../../rust-executor/src/perspectives/fixtures/shacl_writer_golden.json'), 'utf8'));
|
package/src/shacl/SHACLShape.ts
CHANGED
|
@@ -66,6 +66,19 @@ function parseTransform(json: string, propShapeId: string): NodeExpression {
|
|
|
66
66
|
return parsed;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/** The `ad4m://alias` payload: URL-encoded JSON `{ abstractClass: name }`.
|
|
70
|
+
* One that does not decode to a map of strings is dropped. */
|
|
71
|
+
function parseAlias(raw: string): Record<string, string> | undefined {
|
|
72
|
+
try {
|
|
73
|
+
const parsed = JSON.parse(decodeURIComponent(raw));
|
|
74
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
75
|
+
&& Object.values(parsed).every(v => typeof v === 'string')) {
|
|
76
|
+
return parsed;
|
|
77
|
+
}
|
|
78
|
+
} catch {}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
69
82
|
/** Whether the executor stores a property as a collection (`ad4m://CollectionShape`). */
|
|
70
83
|
function isCollection(p: SHACLPropertyShape): boolean {
|
|
71
84
|
return p.collection ?? (p.relationKind === 'hasMany' || p.relationKind === 'belongsToMany');
|
|
@@ -257,6 +270,12 @@ export interface SHACLPropertyShape {
|
|
|
257
270
|
* for the generic LLM interpreter. Emitted as an `ad4m://identity` link
|
|
258
271
|
* (`literal:string:true`) and read back on `ShapeProperty.identity`. */
|
|
259
272
|
identity?: boolean;
|
|
273
|
+
|
|
274
|
+
/** AD4M-specific: the name this property answers to when its class is read
|
|
275
|
+
* through an abstract class, keyed by the abstract class's name:
|
|
276
|
+
* `{ TextContent: "text" }`. Emitted as one `ad4m://alias` link
|
|
277
|
+
* (`literal:string:` + the URL-encoded JSON map). */
|
|
278
|
+
alias?: Record<string, string>;
|
|
260
279
|
}
|
|
261
280
|
|
|
262
281
|
/**
|
|
@@ -288,6 +307,11 @@ export class SHACLShape {
|
|
|
288
307
|
* on `ModelShape.interpretation_hint` by the Rust model query. */
|
|
289
308
|
interpretationHint?: string;
|
|
290
309
|
|
|
310
|
+
/** AD4M-specific: an abstract class. Querying it reads every concrete class
|
|
311
|
+
* that has its property names; it is never created. Emitted as one
|
|
312
|
+
* `ad4m://abstract` link on the shape node. */
|
|
313
|
+
isAbstract?: boolean;
|
|
314
|
+
|
|
291
315
|
/**
|
|
292
316
|
* Create a new SHACL Shape
|
|
293
317
|
* @param targetClassOrShapeUri - If one argument: the target class (shape URI auto-derived as {class}Shape)
|
|
@@ -445,6 +469,14 @@ export class SHACLShape {
|
|
|
445
469
|
});
|
|
446
470
|
}
|
|
447
471
|
|
|
472
|
+
if (this.isAbstract) {
|
|
473
|
+
links.push({
|
|
474
|
+
source: this.nodeShapeUri,
|
|
475
|
+
predicate: "ad4m://abstract",
|
|
476
|
+
target: "literal:true"
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
448
480
|
// Property shapes (each gets a named URI: {namespace}/{ClassName}.{propertyName})
|
|
449
481
|
for (let i = 0; i < this.properties.length; i++) {
|
|
450
482
|
const prop = this.properties[i];
|
|
@@ -701,6 +733,14 @@ export class SHACLShape {
|
|
|
701
733
|
target: `literal:string:true`
|
|
702
734
|
});
|
|
703
735
|
}
|
|
736
|
+
|
|
737
|
+
if (prop.alias && Object.keys(prop.alias).length > 0) {
|
|
738
|
+
links.push({
|
|
739
|
+
source: propShapeId,
|
|
740
|
+
predicate: "ad4m://alias",
|
|
741
|
+
target: `literal:string:${encodeURIComponent(JSON.stringify(prop.alias))}`
|
|
742
|
+
});
|
|
743
|
+
}
|
|
704
744
|
}
|
|
705
745
|
|
|
706
746
|
return links;
|
|
@@ -741,6 +781,7 @@ export class SHACLShape {
|
|
|
741
781
|
shape.constructor_actions = json(shapeUri, "ad4m://constructor");
|
|
742
782
|
shape.destructor_actions = json(shapeUri, "ad4m://destructor");
|
|
743
783
|
shape.interpretationHint = str(shapeUri, "ad4m://interpretation_hint");
|
|
784
|
+
if (bool(shapeUri, "ad4m://abstract")) shape.isAbstract = true;
|
|
744
785
|
|
|
745
786
|
for (const propLink of links.filter(l => l.source === shapeUri && l.predicate === "sh://property")) {
|
|
746
787
|
const id = propLink.target;
|
|
@@ -755,6 +796,7 @@ export class SHACLShape {
|
|
|
755
796
|
const hasValue = target(id, "sh://hasValue");
|
|
756
797
|
const identity = str(id, "ad4m://identity");
|
|
757
798
|
const transform = str(id, "ad4m://transform");
|
|
799
|
+
const alias = str(id, "ad4m://alias");
|
|
758
800
|
|
|
759
801
|
const prop: SHACLPropertyShape = {
|
|
760
802
|
name,
|
|
@@ -788,6 +830,7 @@ export class SHACLShape {
|
|
|
788
830
|
interpretationHint: str(id, "ad4m://interpretation_hint"),
|
|
789
831
|
identity: identity === undefined ? undefined : identity === 'true',
|
|
790
832
|
transform: transform === undefined ? undefined : parseTransform(transform, id),
|
|
833
|
+
alias: alias === undefined ? undefined : parseAlias(alias),
|
|
791
834
|
};
|
|
792
835
|
shape.addProperty(Object.fromEntries(Object.entries(prop).filter(([, v]) => v !== undefined)) as SHACLPropertyShape);
|
|
793
836
|
}
|
|
@@ -807,6 +850,7 @@ export class SHACLShape {
|
|
|
807
850
|
target_class: this.targetClass,
|
|
808
851
|
parent_shapes: this.parentShapes.length > 0 ? this.parentShapes : undefined,
|
|
809
852
|
interpretation_hint: this.interpretationHint,
|
|
853
|
+
abstract: this.isAbstract || undefined,
|
|
810
854
|
properties: this.properties.map(p => ({
|
|
811
855
|
path: p.path,
|
|
812
856
|
name: p.name,
|
|
@@ -837,6 +881,7 @@ export class SHACLShape {
|
|
|
837
881
|
transform: p.transform,
|
|
838
882
|
interpretation_hint: p.interpretationHint,
|
|
839
883
|
identity: p.identity,
|
|
884
|
+
alias: p.alias,
|
|
840
885
|
// The backend reads the ordering declaration back from the
|
|
841
886
|
// `ad4m://ordering` link that `parse_shacl_to_links` writes from this
|
|
842
887
|
// field. `ensureSubjectClass` ships `toJSON()`, so omitting it here
|
|
@@ -896,6 +941,7 @@ export class SHACLShape {
|
|
|
896
941
|
interpretationHint: p.interpretation_hint,
|
|
897
942
|
identity: p.identity,
|
|
898
943
|
ordering: p.ordering,
|
|
944
|
+
alias: p.alias,
|
|
899
945
|
});
|
|
900
946
|
}
|
|
901
947
|
|
|
@@ -913,6 +959,9 @@ export class SHACLShape {
|
|
|
913
959
|
if (json.interpretation_hint) {
|
|
914
960
|
shape.interpretationHint = json.interpretation_hint;
|
|
915
961
|
}
|
|
962
|
+
if (json.abstract) {
|
|
963
|
+
shape.isAbstract = true;
|
|
964
|
+
}
|
|
916
965
|
|
|
917
966
|
return shape;
|
|
918
967
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Wire names stay snake_case, as the SDK reads them.
|
|
5
|
-
*/
|
|
6
|
-
export type PerspectiveModelSubscribeResult = { subscription_id: string, result: string, };
|
|
File without changes
|
|
File without changes
|
/package/lib/src/generated/api/{PerspectiveQuerySubscriptionFilter.js → DiscardBatchRequest.js}
RENAMED
|
File without changes
|
/package/lib/src/generated/api/{PerspectiveSubscribeQueryResult.js → FlowStateChangedEvent.js}
RENAMED
|
File without changes
|