@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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sfu.status`: whether this executor can relay media to remote
|
|
3
|
+
* participants.
|
|
4
|
+
*/
|
|
5
|
+
export type SfuStatus = {
|
|
6
|
+
reachability: "public" | "nat" | "unknown";
|
|
7
|
+
/**
|
|
8
|
+
* True when the SFU accepts inbound connections from the internet.
|
|
9
|
+
*/
|
|
10
|
+
isPublic: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The SFU server's bound UDP address (`ip:port`).
|
|
13
|
+
*/
|
|
14
|
+
bindAddress: string;
|
|
15
|
+
/**
|
|
16
|
+
* The public address (`ip:port`) offered next to the bind address
|
|
17
|
+
* behind NAT, when there is one.
|
|
18
|
+
*/
|
|
19
|
+
advertisedAddress?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Human-readable reachability detail.
|
|
22
|
+
*/
|
|
23
|
+
detail: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps one outbound SDP m-line to the originating participant's DID.
|
|
3
|
+
*/
|
|
4
|
+
export type TrackMapEntry = {
|
|
5
|
+
/**
|
|
6
|
+
* The SDP mid (media-line identifier) in the offer.
|
|
7
|
+
*/
|
|
8
|
+
mid: string;
|
|
9
|
+
/**
|
|
10
|
+
* DID of the participant whose media this m-line carries.
|
|
11
|
+
*/
|
|
12
|
+
agentDid: string;
|
|
13
|
+
/**
|
|
14
|
+
* `"audio"` or `"video"`.
|
|
15
|
+
*/
|
|
16
|
+
mediaKind: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Through an abstract class (#1435), dispatched to the record's own classes.
|
|
3
|
+
*/
|
|
4
|
+
export type UpdateSubjectRequest = {
|
|
5
|
+
subjectClass: string;
|
|
6
|
+
expressionAddress: string;
|
|
7
|
+
/**
|
|
8
|
+
* A JSON object: property name → value.
|
|
9
|
+
*/
|
|
10
|
+
values: string;
|
|
11
|
+
batchId?: string;
|
|
12
|
+
};
|
|
@@ -2,11 +2,13 @@ export type { AddLinkExpressionRequest } from "./AddLinkExpressionRequest";
|
|
|
2
2
|
export type { AddLinkRequest } from "./AddLinkRequest";
|
|
3
3
|
export type { AddLinksBulkRequest } from "./AddLinksBulkRequest";
|
|
4
4
|
export type { AddSdnaRequest } from "./AddSdnaRequest";
|
|
5
|
+
export type { AgentsByDidsRequest } from "./AgentsByDidsRequest";
|
|
5
6
|
export type { ApplyTemplateRequest } from "./ApplyTemplateRequest";
|
|
6
7
|
export type { CommitBatchRequest } from "./CommitBatchRequest";
|
|
7
8
|
export type { CreateExpressionRequest } from "./CreateExpressionRequest";
|
|
8
9
|
export type { CreatePerspectiveRequest } from "./CreatePerspectiveRequest";
|
|
9
10
|
export type { CreateSubjectRequest } from "./CreateSubjectRequest";
|
|
11
|
+
export type { DiscardBatchRequest } from "./DiscardBatchRequest";
|
|
10
12
|
export type { EmbedRequest } from "./EmbedRequest";
|
|
11
13
|
export type { ExecuteCommandsRequest } from "./ExecuteCommandsRequest";
|
|
12
14
|
export type { ExportRequest } from "./ExportRequest";
|
|
@@ -30,6 +32,7 @@ export type { PublishNeighbourhoodRequest } from "./PublishNeighbourhoodRequest"
|
|
|
30
32
|
export type { QueryRequest } from "./QueryRequest";
|
|
31
33
|
export type { RemoveLinkRequest } from "./RemoveLinkRequest";
|
|
32
34
|
export type { RemoveLinksBulkRequest } from "./RemoveLinksBulkRequest";
|
|
35
|
+
export type { ResyncSubscriptionRequest } from "./ResyncSubscriptionRequest";
|
|
33
36
|
export type { RunInterpretationRequest } from "./RunInterpretationRequest";
|
|
34
37
|
export type { SetDefaultModelRequest } from "./SetDefaultModelRequest";
|
|
35
38
|
export type { SetFreeHostingEnabledRequest } from "./SetFreeHostingEnabledRequest";
|
package/lib/src/index.d.ts
CHANGED
|
@@ -16,9 +16,11 @@ export * from "./Literal";
|
|
|
16
16
|
export * from "./perspectives/Perspective";
|
|
17
17
|
export * from "./perspectives/PerspectiveHandle";
|
|
18
18
|
export * from "./perspectives/PerspectiveProxy";
|
|
19
|
+
export * from "./perspectives/LiveQuery";
|
|
19
20
|
export * from "./perspectives/AutoProcessor";
|
|
20
21
|
export * from "./perspectives/InterpretationModels";
|
|
21
22
|
export * from "./perspectives/FlowModels";
|
|
23
|
+
export * from "./perspectives/TextContent";
|
|
22
24
|
export * from "./perspectives/FlowInstance";
|
|
23
25
|
export * from "./perspectives/SparqlBindings";
|
|
24
26
|
export * from "./perspectives/WakerSubscriptionManager";
|
|
@@ -28,6 +30,11 @@ export * from "./SmartLiteral";
|
|
|
28
30
|
export * from "./model";
|
|
29
31
|
export * from "./neighbourhood/Neighbourhood";
|
|
30
32
|
export * from "./neighbourhood/NeighbourhoodProxy";
|
|
33
|
+
export * from "./neighbourhood/SfuTypes";
|
|
34
|
+
export type { SfuNeighbourhoodApi } from "./neighbourhood/SfuManager";
|
|
35
|
+
export type { Session, SessionTopology, SessionState, SessionEvent, SessionEventCallback, SessionCreateOptions } from "./neighbourhood/Session";
|
|
36
|
+
export { MeshManager, createTelepresenceChannel, parseCallMessage, CALL_PROTOCOL_VERSION, DEFAULT_ICE_SERVERS } from "./neighbourhood/MeshManager";
|
|
37
|
+
export type { SignallingChannel, TelepresenceProxy, MeshManagerOptions, MeshEvent, MeshEventCallback, MeshParticipant, RecoveryRung, CallBody, CallMessage, CallEnvelope, CallGenerations } from "./neighbourhood/MeshManager";
|
|
31
38
|
export * from "./typeDefs";
|
|
32
39
|
export * from "./DID";
|
|
33
40
|
export * from "./utils";
|
package/lib/src/index.js
CHANGED
|
@@ -16,9 +16,11 @@ export * from "./Literal";
|
|
|
16
16
|
export * from "./perspectives/Perspective";
|
|
17
17
|
export * from "./perspectives/PerspectiveHandle";
|
|
18
18
|
export * from "./perspectives/PerspectiveProxy";
|
|
19
|
+
export * from "./perspectives/LiveQuery";
|
|
19
20
|
export * from "./perspectives/AutoProcessor";
|
|
20
21
|
export * from "./perspectives/InterpretationModels";
|
|
21
22
|
export * from "./perspectives/FlowModels";
|
|
23
|
+
export * from "./perspectives/TextContent";
|
|
22
24
|
// Also exports FlowFireOutcome / FlowProposeResult, the result shapes of the
|
|
23
25
|
// flow write API — they live beside the `proposeTransition()` surface.
|
|
24
26
|
export * from "./perspectives/FlowInstance";
|
|
@@ -30,6 +32,8 @@ export * from "./SmartLiteral";
|
|
|
30
32
|
export * from "./model";
|
|
31
33
|
export * from "./neighbourhood/Neighbourhood";
|
|
32
34
|
export * from "./neighbourhood/NeighbourhoodProxy";
|
|
35
|
+
export * from "./neighbourhood/SfuTypes";
|
|
36
|
+
export { MeshManager, createTelepresenceChannel, parseCallMessage, CALL_PROTOCOL_VERSION, DEFAULT_ICE_SERVERS } from "./neighbourhood/MeshManager";
|
|
33
37
|
export * from "./typeDefs";
|
|
34
38
|
export * from "./DID";
|
|
35
39
|
export * from "./utils";
|
|
@@ -328,6 +328,13 @@ export declare class Ad4mModel {
|
|
|
328
328
|
* Shape resolution happens server-side from the perspective's SHACL triples.
|
|
329
329
|
* @internal
|
|
330
330
|
*/
|
|
331
|
+
/**
|
|
332
|
+
* The name the executor knows this class by: its class name, or a
|
|
333
|
+
* built-in abstract class's URI (`ad4m://TextContent`, #1446). The URI is
|
|
334
|
+
* the class's own static only: a subclass is a class of its own.
|
|
335
|
+
* @internal
|
|
336
|
+
*/
|
|
337
|
+
static queriedAs(): string;
|
|
331
338
|
static prepareModelQueryParams(query?: Query, classNameOverride?: string | null): {
|
|
332
339
|
className: string;
|
|
333
340
|
queryJson: string;
|
|
@@ -339,6 +346,68 @@ export declare class Ad4mModel {
|
|
|
339
346
|
* @internal
|
|
340
347
|
*/
|
|
341
348
|
static parseModelResult<T extends Ad4mModel>(this: typeof Ad4mModel & (new (...args: any[]) => T), perspective: PerspectiveProxy, raw: any, include?: IncludeMap, properties?: string[]): T[];
|
|
349
|
+
/**
|
|
350
|
+
* Build the wire parameters for one query over several classes.
|
|
351
|
+
*
|
|
352
|
+
* Each class normalises the query as it would for itself — its polymorphic
|
|
353
|
+
* include defaults, its `$` projections, its parent predicate — and the
|
|
354
|
+
* results are merged: includes and projections by key (the first class that
|
|
355
|
+
* declares a key decides its form; a projection two classes tag with
|
|
356
|
+
* different target classes is refused), the parent scope only when every
|
|
357
|
+
* class that can resolve it resolves it to the same predicate.
|
|
358
|
+
* @internal
|
|
359
|
+
*/
|
|
360
|
+
static prepareUnionQueryParams(classes: (typeof Ad4mModel)[], query?: Query): {
|
|
361
|
+
classNames: string[];
|
|
362
|
+
queryJson: string;
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Build each row of a union result as the class the executor hydrated it as
|
|
366
|
+
* (`__subjectClass`). A row of a class not in `classes` stays plain JSON.
|
|
367
|
+
* @internal
|
|
368
|
+
*/
|
|
369
|
+
static parseUnionResult(classes: (typeof Ad4mModel)[], perspective: PerspectiveProxy, raw: any, include?: IncludeMap, properties?: string[]): Ad4mModel[];
|
|
370
|
+
/** @internal */
|
|
371
|
+
static executeUnionQuery(perspective: PerspectiveProxy, classes: (typeof Ad4mModel)[], query?: Query, options?: CallOptions): Promise<ResultsWithTotalCount<Ad4mModel>>;
|
|
372
|
+
/**
|
|
373
|
+
* One query over several model classes (#1238).
|
|
374
|
+
*
|
|
375
|
+
* `where`, `order`, `limit` and `offset` apply once, over the union. Each
|
|
376
|
+
* result is an instance of the class the executor hydrated it as: the first
|
|
377
|
+
* `preferClasses` entry it conforms to, otherwise the most specific of
|
|
378
|
+
* `classes` it conforms to. A record that is several of them is returned
|
|
379
|
+
* once; `__subjectClasses` on it names every class it conforms to.
|
|
380
|
+
*
|
|
381
|
+
* - `where` on a property a class does not declare excludes that class's rows.
|
|
382
|
+
* - `order` on such a property sorts those rows last, in both directions,
|
|
383
|
+
* then by id.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* const items = await Ad4mModel.findAllOf(perspective, [Placement, EdgeRoute], {
|
|
388
|
+
* parent: { id: canvas.id, predicate: "canvas://item" },
|
|
389
|
+
* order: { zIndex: "ASC" },
|
|
390
|
+
* limit: 50,
|
|
391
|
+
* });
|
|
392
|
+
* for (const item of items) {
|
|
393
|
+
* if (item instanceof Placement) { ... }
|
|
394
|
+
* }
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
static findAllOf<C extends (typeof Ad4mModel)[]>(perspective: PerspectiveProxy, classes: [...C], query?: Query, options?: CallOptions): Promise<InstanceType<C[number]>[]>;
|
|
398
|
+
/**
|
|
399
|
+
* A {@link ModelQueryBuilder} over several model classes: the builder form of
|
|
400
|
+
* {@link findAllOf}. `subscribe()` registers one subscription, which re-runs
|
|
401
|
+
* when any of the classes changes.
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```typescript
|
|
405
|
+
* const builder = Ad4mModel.queryOf(perspective, [Placement, EdgeRoute])
|
|
406
|
+
* .parent(canvas.id, "canvas://item");
|
|
407
|
+
* await builder.subscribe((items) => render(items));
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
static queryOf<C extends (typeof Ad4mModel)[]>(perspective: PerspectiveProxy, classes: [...C], query?: Query): ModelQueryBuilder<InstanceType<C[number]>>;
|
|
342
411
|
/**
|
|
343
412
|
* Execute a model query via the executor-side endpoint.
|
|
344
413
|
*
|
|
@@ -458,6 +527,11 @@ export declare class Ad4mModel {
|
|
|
458
527
|
/** Resolve a relation argument to a plain string ID. Accepts either a raw
|
|
459
528
|
* string ID or an Ad4mModel instance (in which case `.id` is used). */
|
|
460
529
|
private resolveRelationId;
|
|
530
|
+
/** A relation write on a row read through an abstract class (#1435). The
|
|
531
|
+
* relation's predicate is the abstract class's, which no record's class
|
|
532
|
+
* reads: the executor runs the adder, remover or setter of each of the
|
|
533
|
+
* record's classes for the relation answering to `key`. */
|
|
534
|
+
private relationThroughAbstract;
|
|
461
535
|
private setRelationValues;
|
|
462
536
|
private addRelationValue;
|
|
463
537
|
private removeRelationValue;
|
|
@@ -488,6 +562,16 @@ export declare class Ad4mModel {
|
|
|
488
562
|
* ```
|
|
489
563
|
*/
|
|
490
564
|
save(batchId?: string): Promise<void>;
|
|
565
|
+
/** The name the executor knows the class by when it is abstract (#1435):
|
|
566
|
+
* a built-in's URI (#1446). Through an abstract class, the executor
|
|
567
|
+
* writes to the record's own classes. */
|
|
568
|
+
private abstractName;
|
|
569
|
+
private changedValues;
|
|
570
|
+
/** `changedValues()` with each relation's members as IDs, as the relation
|
|
571
|
+
* helpers send them: a member may be a model instance. An action envelope
|
|
572
|
+
* (`{ action: "adder", value }`) keeps its action, as `innerUpdate()` runs
|
|
573
|
+
* it; an action it does not know is a setter there, so it is one here. */
|
|
574
|
+
private changedValuesForDispatch;
|
|
491
575
|
private cleanCopy;
|
|
492
576
|
private innerUpdate;
|
|
493
577
|
/**
|
|
@@ -980,9 +980,19 @@ export class Ad4mModel {
|
|
|
980
980
|
* Shape resolution happens server-side from the perspective's SHACL triples.
|
|
981
981
|
* @internal
|
|
982
982
|
*/
|
|
983
|
+
/**
|
|
984
|
+
* The name the executor knows this class by: its class name, or a
|
|
985
|
+
* built-in abstract class's URI (`ad4m://TextContent`, #1446). The URI is
|
|
986
|
+
* the class's own static only: a subclass is a class of its own.
|
|
987
|
+
* @internal
|
|
988
|
+
*/
|
|
989
|
+
static queriedAs() {
|
|
990
|
+
const builtinUri = Object.prototype.hasOwnProperty.call(this, 'builtinUri') ? this.builtinUri : undefined;
|
|
991
|
+
return builtinUri || this.getModelMetadata().className;
|
|
992
|
+
}
|
|
983
993
|
static prepareModelQueryParams(query = {}, classNameOverride) {
|
|
984
994
|
const metadata = this.getModelMetadata();
|
|
985
|
-
const className = classNameOverride ||
|
|
995
|
+
const className = classNameOverride || this.queriedAs();
|
|
986
996
|
// Expand includeAll: true to a full IncludeMap covering every forward relation.
|
|
987
997
|
if (query.includeAll) {
|
|
988
998
|
const allRelMeta = getRelationsMetadata(this);
|
|
@@ -1086,6 +1096,159 @@ export class Ad4mModel {
|
|
|
1086
1096
|
return [];
|
|
1087
1097
|
return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
|
|
1088
1098
|
}
|
|
1099
|
+
// ── One query over several classes (#1238) ────────────────────────────────
|
|
1100
|
+
/**
|
|
1101
|
+
* Build the wire parameters for one query over several classes.
|
|
1102
|
+
*
|
|
1103
|
+
* Each class normalises the query as it would for itself — its polymorphic
|
|
1104
|
+
* include defaults, its `$` projections, its parent predicate — and the
|
|
1105
|
+
* results are merged: includes and projections by key (the first class that
|
|
1106
|
+
* declares a key decides its form; a projection two classes tag with
|
|
1107
|
+
* different target classes is refused), the parent scope only when every
|
|
1108
|
+
* class that can resolve it resolves it to the same predicate.
|
|
1109
|
+
* @internal
|
|
1110
|
+
*/
|
|
1111
|
+
static prepareUnionQueryParams(classes, query = {}) {
|
|
1112
|
+
if (!classes.length)
|
|
1113
|
+
throw new Error('A query over several classes needs at least one class');
|
|
1114
|
+
const { parent, preferClasses, ...rest } = query;
|
|
1115
|
+
const inputs = classes.map((c) => JSON.parse(c.prepareModelQueryParams(rest).queryJson));
|
|
1116
|
+
// A projection is tagged with its relation's target class, at every depth,
|
|
1117
|
+
// and the executor hydrates a list projection (and resolves its `where`)
|
|
1118
|
+
// as that class. Two classes that tag the same key differently cannot share
|
|
1119
|
+
// one form of it, so the key is refused rather than read as the first's.
|
|
1120
|
+
const tags = new Map();
|
|
1121
|
+
const collectTags = (node, path) => {
|
|
1122
|
+
if (!node || typeof node !== 'object')
|
|
1123
|
+
return;
|
|
1124
|
+
for (const [k, v] of Object.entries(node)) {
|
|
1125
|
+
if (k === 'targetClassName' && typeof v === 'string') {
|
|
1126
|
+
const seen = tags.get(path);
|
|
1127
|
+
if (seen !== undefined && seen !== v) {
|
|
1128
|
+
throw new Error(`projection '${path}': the classes resolve it to different target classes ` +
|
|
1129
|
+
`(${seen}, ${v}); query those classes separately`);
|
|
1130
|
+
}
|
|
1131
|
+
tags.set(path, v);
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
collectTags(v, path ? `${path}.${k}` : k);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
for (const input of inputs) {
|
|
1139
|
+
collectTags(input.include, 'include');
|
|
1140
|
+
collectTags(input.projections, 'projections');
|
|
1141
|
+
}
|
|
1142
|
+
const merged = { ...inputs[0] };
|
|
1143
|
+
if (preferClasses)
|
|
1144
|
+
merged.preferClasses = preferClasses;
|
|
1145
|
+
for (const key of ['include', 'projections']) {
|
|
1146
|
+
const combined = Object.assign({}, ...inputs.map((i) => i[key] ?? {}).reverse());
|
|
1147
|
+
if (Object.keys(combined).length)
|
|
1148
|
+
merged[key] = combined;
|
|
1149
|
+
else
|
|
1150
|
+
delete merged[key];
|
|
1151
|
+
}
|
|
1152
|
+
if (parent) {
|
|
1153
|
+
// A model-form scope names its predicate through the relation that
|
|
1154
|
+
// targets the queried class, so each class may resolve it differently
|
|
1155
|
+
// or not at all. One query has one scope.
|
|
1156
|
+
const scopes = [];
|
|
1157
|
+
let firstError;
|
|
1158
|
+
for (const c of classes) {
|
|
1159
|
+
try {
|
|
1160
|
+
scopes.push(JSON.stringify(JSON.parse(c.prepareModelQueryParams({ parent }).queryJson).parent));
|
|
1161
|
+
}
|
|
1162
|
+
catch (e) {
|
|
1163
|
+
firstError ?? (firstError = e);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
if (!scopes.length)
|
|
1167
|
+
throw firstError;
|
|
1168
|
+
if (new Set(scopes).size > 1) {
|
|
1169
|
+
throw new Error('parent(): the classes resolve the parent scope to different predicates; ' +
|
|
1170
|
+
'pass the predicate itself (or a `field`) so they share one scope');
|
|
1171
|
+
}
|
|
1172
|
+
merged.parent = JSON.parse(scopes[0]);
|
|
1173
|
+
}
|
|
1174
|
+
return {
|
|
1175
|
+
classNames: classes.map((c) => c.queriedAs()),
|
|
1176
|
+
queryJson: JSON.stringify(merged),
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Build each row of a union result as the class the executor hydrated it as
|
|
1181
|
+
* (`__subjectClass`). A row of a class not in `classes` stays plain JSON.
|
|
1182
|
+
* @internal
|
|
1183
|
+
*/
|
|
1184
|
+
static parseUnionResult(classes, perspective, raw, include, properties) {
|
|
1185
|
+
const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
1186
|
+
const arr = data.instances || data;
|
|
1187
|
+
if (!Array.isArray(arr))
|
|
1188
|
+
return [];
|
|
1189
|
+
const byName = new Map(classes.map((c) => [c.getModelMetadata().className, c]));
|
|
1190
|
+
return arr.map((json) => {
|
|
1191
|
+
const cls = byName.get(json?.[SUBJECT_CLASS_KEY]);
|
|
1192
|
+
return cls ? jsonToModelInstance(cls, perspective, json, include, properties) : json;
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
/** @internal */
|
|
1196
|
+
static async executeUnionQuery(perspective, classes, query = {}, options) {
|
|
1197
|
+
const { classNames, queryJson } = Ad4mModel.prepareUnionQueryParams(classes, query);
|
|
1198
|
+
const result = await perspective.modelQuery(classNames, queryJson, options);
|
|
1199
|
+
const results = Ad4mModel.parseUnionResult(classes, perspective, result, query.include, query.properties);
|
|
1200
|
+
const snapshotRelations = query.include
|
|
1201
|
+
? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith('$')))
|
|
1202
|
+
: undefined;
|
|
1203
|
+
for (const inst of results) {
|
|
1204
|
+
inst.takeSnapshot?.(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : undefined);
|
|
1205
|
+
}
|
|
1206
|
+
return { results, totalCount: result.totalCount };
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* One query over several model classes (#1238).
|
|
1210
|
+
*
|
|
1211
|
+
* `where`, `order`, `limit` and `offset` apply once, over the union. Each
|
|
1212
|
+
* result is an instance of the class the executor hydrated it as: the first
|
|
1213
|
+
* `preferClasses` entry it conforms to, otherwise the most specific of
|
|
1214
|
+
* `classes` it conforms to. A record that is several of them is returned
|
|
1215
|
+
* once; `__subjectClasses` on it names every class it conforms to.
|
|
1216
|
+
*
|
|
1217
|
+
* - `where` on a property a class does not declare excludes that class's rows.
|
|
1218
|
+
* - `order` on such a property sorts those rows last, in both directions,
|
|
1219
|
+
* then by id.
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```typescript
|
|
1223
|
+
* const items = await Ad4mModel.findAllOf(perspective, [Placement, EdgeRoute], {
|
|
1224
|
+
* parent: { id: canvas.id, predicate: "canvas://item" },
|
|
1225
|
+
* order: { zIndex: "ASC" },
|
|
1226
|
+
* limit: 50,
|
|
1227
|
+
* });
|
|
1228
|
+
* for (const item of items) {
|
|
1229
|
+
* if (item instanceof Placement) { ... }
|
|
1230
|
+
* }
|
|
1231
|
+
* ```
|
|
1232
|
+
*/
|
|
1233
|
+
static async findAllOf(perspective, classes, query, options) {
|
|
1234
|
+
const { results } = await Ad4mModel.executeUnionQuery(perspective, classes, query ?? {}, options);
|
|
1235
|
+
return results;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* A {@link ModelQueryBuilder} over several model classes: the builder form of
|
|
1239
|
+
* {@link findAllOf}. `subscribe()` registers one subscription, which re-runs
|
|
1240
|
+
* when any of the classes changes.
|
|
1241
|
+
*
|
|
1242
|
+
* @example
|
|
1243
|
+
* ```typescript
|
|
1244
|
+
* const builder = Ad4mModel.queryOf(perspective, [Placement, EdgeRoute])
|
|
1245
|
+
* .parent(canvas.id, "canvas://item");
|
|
1246
|
+
* await builder.subscribe((items) => render(items));
|
|
1247
|
+
* ```
|
|
1248
|
+
*/
|
|
1249
|
+
static queryOf(perspective, classes, query) {
|
|
1250
|
+
return new ModelQueryBuilder(perspective, Ad4mModel, query, classes);
|
|
1251
|
+
}
|
|
1089
1252
|
// instancesFromQueryResult — removed (superseded by Rust executeModelQuery pipeline)
|
|
1090
1253
|
/**
|
|
1091
1254
|
* Execute a model query via the executor-side endpoint.
|
|
@@ -1281,12 +1444,26 @@ export class Ad4mModel {
|
|
|
1281
1444
|
return value.id;
|
|
1282
1445
|
return String(value);
|
|
1283
1446
|
}
|
|
1447
|
+
/** A relation write on a row read through an abstract class (#1435). The
|
|
1448
|
+
* relation's predicate is the abstract class's, which no record's class
|
|
1449
|
+
* reads: the executor runs the adder, remover or setter of each of the
|
|
1450
|
+
* record's classes for the relation answering to `key`. */
|
|
1451
|
+
async relationThroughAbstract(abstractName, key, action, value, batchId) {
|
|
1452
|
+
const ids = (Array.isArray(value) ? value : [value]).map((v) => this.resolveRelationId(v));
|
|
1453
|
+
await this._perspective.updateSubject(abstractName, this._baseExpression, { [key]: { action, value: ids } }, batchId);
|
|
1454
|
+
}
|
|
1284
1455
|
async setRelationValues(key, value, batchId) {
|
|
1285
1456
|
const metadata = this.getRelationOptions(key);
|
|
1286
1457
|
if (!metadata) {
|
|
1287
1458
|
console.warn(`Relation "${key}" has no metadata, skipping`);
|
|
1288
1459
|
return;
|
|
1289
1460
|
}
|
|
1461
|
+
const abstractName = this.abstractName();
|
|
1462
|
+
if (abstractName) {
|
|
1463
|
+
if (value != null)
|
|
1464
|
+
await this.relationThroughAbstract(abstractName, key, 'setter', value, batchId);
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1290
1467
|
// Generate actions from metadata (replaces Prolog query)
|
|
1291
1468
|
const actions = this.generateRelationAction(key, 'setter');
|
|
1292
1469
|
if (value != null) {
|
|
@@ -1304,6 +1481,12 @@ export class Ad4mModel {
|
|
|
1304
1481
|
console.warn(`Relation "${key}" has no metadata, skipping`);
|
|
1305
1482
|
return;
|
|
1306
1483
|
}
|
|
1484
|
+
const abstractName = this.abstractName();
|
|
1485
|
+
if (abstractName) {
|
|
1486
|
+
if (value != null)
|
|
1487
|
+
await this.relationThroughAbstract(abstractName, key, 'adder', value, batchId);
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1307
1490
|
// Generate actions from metadata (replaces Prolog query)
|
|
1308
1491
|
const actions = this.generateRelationAction(key, 'adder');
|
|
1309
1492
|
if (value != null) {
|
|
@@ -1321,6 +1504,12 @@ export class Ad4mModel {
|
|
|
1321
1504
|
console.warn(`Relation "${key}" has no metadata, skipping`);
|
|
1322
1505
|
return;
|
|
1323
1506
|
}
|
|
1507
|
+
const abstractName = this.abstractName();
|
|
1508
|
+
if (abstractName) {
|
|
1509
|
+
if (value != null)
|
|
1510
|
+
await this.relationThroughAbstract(abstractName, key, 'remover', value, batchId);
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1324
1513
|
// Generate actions from metadata (replaces Prolog query)
|
|
1325
1514
|
const actions = this.generateRelationAction(key, 'remover');
|
|
1326
1515
|
if (value != null) {
|
|
@@ -1361,7 +1550,13 @@ export class Ad4mModel {
|
|
|
1361
1550
|
async save(batchId) {
|
|
1362
1551
|
// Existing instance → update path (has been fetched / hydrated before)
|
|
1363
1552
|
if (this._snapshot) {
|
|
1364
|
-
|
|
1553
|
+
const abstractName = this.abstractName();
|
|
1554
|
+
if (abstractName) {
|
|
1555
|
+
await this.perspective.updateSubject(abstractName, this._baseExpression, this.changedValuesForDispatch(), batchId);
|
|
1556
|
+
}
|
|
1557
|
+
else {
|
|
1558
|
+
await this.innerUpdate(true, batchId);
|
|
1559
|
+
}
|
|
1365
1560
|
if (batchId) {
|
|
1366
1561
|
// Batch hasn't been committed yet — getData() would fetch stale data
|
|
1367
1562
|
// and overwrite in-memory values. Just refresh the snapshot so further
|
|
@@ -1373,7 +1568,13 @@ export class Ad4mModel {
|
|
|
1373
1568
|
}
|
|
1374
1569
|
return;
|
|
1375
1570
|
}
|
|
1376
|
-
// New instance → create path
|
|
1571
|
+
// New instance → create path. The executor refuses an abstract class
|
|
1572
|
+
// too; refusing here keeps the error ahead of the batch.
|
|
1573
|
+
const abstractName = this.abstractName();
|
|
1574
|
+
if (abstractName) {
|
|
1575
|
+
throw new Error(`'${abstractName}' is an abstract class and cannot be created. Create an instance of ` +
|
|
1576
|
+
`a class that has its properties; querying '${abstractName}' reads it.`);
|
|
1577
|
+
}
|
|
1377
1578
|
let batchCreatedHere = false;
|
|
1378
1579
|
if (!batchId) {
|
|
1379
1580
|
batchId = await this.perspective.createBatch();
|
|
@@ -1429,6 +1630,33 @@ export class Ad4mModel {
|
|
|
1429
1630
|
this.takeSnapshot();
|
|
1430
1631
|
}
|
|
1431
1632
|
}
|
|
1633
|
+
/** The name the executor knows the class by when it is abstract (#1435):
|
|
1634
|
+
* a built-in's URI (#1446). Through an abstract class, the executor
|
|
1635
|
+
* writes to the record's own classes. */
|
|
1636
|
+
abstractName() {
|
|
1637
|
+
const ctor = this.constructor;
|
|
1638
|
+
return ctor.isAbstract ? ctor.queriedAs() : undefined;
|
|
1639
|
+
}
|
|
1640
|
+
changedValues() {
|
|
1641
|
+
return Object.fromEntries(this.changedFields().map((key) => [key, this[key]]));
|
|
1642
|
+
}
|
|
1643
|
+
/** `changedValues()` with each relation's members as IDs, as the relation
|
|
1644
|
+
* helpers send them: a member may be a model instance. An action envelope
|
|
1645
|
+
* (`{ action: "adder", value }`) keeps its action, as `innerUpdate()` runs
|
|
1646
|
+
* it; an action it does not know is a setter there, so it is one here. */
|
|
1647
|
+
changedValuesForDispatch() {
|
|
1648
|
+
const relations = this.constructor.getModelMetadata().relations;
|
|
1649
|
+
const ids = (value) => Array.isArray(value) ? value.map((v) => this.resolveRelationId(v)) : this.resolveRelationId(value);
|
|
1650
|
+
return Object.fromEntries(Object.entries(this.changedValues()).map(([key, value]) => {
|
|
1651
|
+
if (!relations[key] || value == null)
|
|
1652
|
+
return [key, value];
|
|
1653
|
+
if (value.action) {
|
|
1654
|
+
const action = ["adder", "remover", "setter"].includes(value.action) ? value.action : "setter";
|
|
1655
|
+
return [key, { action, value: ids(value.value) }];
|
|
1656
|
+
}
|
|
1657
|
+
return [key, ids(value)];
|
|
1658
|
+
}));
|
|
1659
|
+
}
|
|
1432
1660
|
cleanCopy() {
|
|
1433
1661
|
const ctor = this.constructor;
|
|
1434
1662
|
const metadata = ctor.getModelMetadata();
|
|
@@ -1669,7 +1897,9 @@ export class Ad4mModel {
|
|
|
1669
1897
|
*/
|
|
1670
1898
|
async delete(batchId) {
|
|
1671
1899
|
const metadata = this.constructor.getModelMetadata();
|
|
1672
|
-
|
|
1900
|
+
// Through an abstract class (#1435), `removeSubject` runs the destructors
|
|
1901
|
+
// of the record's own classes.
|
|
1902
|
+
const hasDestructor = !!this.abstractName() || Object.values(metadata.properties).some((p) => p.required || p.flag || p.initial !== undefined);
|
|
1673
1903
|
if (hasDestructor) {
|
|
1674
1904
|
// Remove the subject itself (destructor actions)
|
|
1675
1905
|
await this._perspective.removeSubject(this, this._baseExpression, batchId);
|
|
@@ -33,38 +33,22 @@ export declare class ModelQueryBuilder<T extends Ad4mModel> {
|
|
|
33
33
|
private modelClassName;
|
|
34
34
|
private ctor;
|
|
35
35
|
private currentSubscription?;
|
|
36
|
-
/**
|
|
37
|
-
private
|
|
38
|
-
constructor(perspective: PerspectiveProxy, ctor: typeof Ad4mModel, query?: Query);
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
* subscribers of the same query and only drops it when the last one
|
|
53
|
-
* disposes, so disposing here does not interrupt another builder's updates.
|
|
54
|
-
*
|
|
55
|
-
* You should call this method when you're done with a subscription
|
|
56
|
-
* to prevent memory leaks and ensure proper cleanup.
|
|
57
|
-
*/
|
|
58
|
-
dispose(): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Runs one subscribe variant after every earlier one on this builder has
|
|
61
|
-
* finished. Each variant disposes the previous subscription (awaiting the
|
|
62
|
-
* executor) and then registers its own; two overlapping calls would both
|
|
63
|
-
* find no current subscription, both register, and the builder could only
|
|
64
|
-
* ever dispose the last one. Serializing keeps exactly one subscription
|
|
65
|
-
* per builder.
|
|
66
|
-
*/
|
|
67
|
-
private serialize;
|
|
36
|
+
/** Set for a query over several classes (`Ad4mModel.queryOf`, #1238). */
|
|
37
|
+
private unionClasses?;
|
|
38
|
+
constructor(perspective: PerspectiveProxy, ctor: typeof Ad4mModel, query?: Query, unionClasses?: (typeof Ad4mModel)[]);
|
|
39
|
+
/** The wire parameters for `params`: one class, or the union's class list. */
|
|
40
|
+
private prepare;
|
|
41
|
+
/** Run `params` once and build model instances from the rows. */
|
|
42
|
+
private execute;
|
|
43
|
+
/** Build model instances from a raw result pushed by a subscription. */
|
|
44
|
+
private parse;
|
|
45
|
+
/** Ends the current subscription, if any, on the client and the executor. */
|
|
46
|
+
dispose(): void;
|
|
47
|
+
/** Open a live model query for `params` as the current subscription.
|
|
48
|
+
* Resolves with it and the raw initial result; `onResult` gets every later one.
|
|
49
|
+
* A failed open ends only its own query: a later call may already own
|
|
50
|
+
* `currentSubscription`. */
|
|
51
|
+
private live;
|
|
68
52
|
/**
|
|
69
53
|
* Adds where conditions to the query.
|
|
70
54
|
*
|
|
@@ -331,7 +315,6 @@ export declare class ModelQueryBuilder<T extends Ad4mModel> {
|
|
|
331
315
|
*
|
|
332
316
|
*/
|
|
333
317
|
subscribe(callback: (results: T[]) => void): Promise<T[]>;
|
|
334
|
-
private subscribeNow;
|
|
335
318
|
/**
|
|
336
319
|
* Subscribes to the query and receives updates using SPARQL.
|
|
337
320
|
* @deprecated Use subscribe() instead — now routes through Rust model subscription.
|
|
@@ -384,7 +367,6 @@ export declare class ModelQueryBuilder<T extends Ad4mModel> {
|
|
|
384
367
|
*
|
|
385
368
|
*/
|
|
386
369
|
countSubscribe(callback: (count: number) => void): Promise<number>;
|
|
387
|
-
private countSubscribeNow;
|
|
388
370
|
/**
|
|
389
371
|
* Subscribes to count updates using SPARQL.
|
|
390
372
|
* @deprecated Use countSubscribe() instead — now routes through Rust model subscription.
|
|
@@ -442,7 +424,6 @@ export declare class ModelQueryBuilder<T extends Ad4mModel> {
|
|
|
442
424
|
*
|
|
443
425
|
*/
|
|
444
426
|
paginateSubscribe(pageSize: number, pageNumber: number, callback: (results: PaginationResult<T>) => void): Promise<PaginationResult<T>>;
|
|
445
|
-
private paginateSubscribeNow;
|
|
446
427
|
/**
|
|
447
428
|
* Subscribes to paginated results updates using SPARQL.
|
|
448
429
|
* Delegates to paginateSubscribe().
|