@coasys/ad4m 0.13.0-test-5 → 0.13.0-test-7
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 +721 -373
- package/lib/index.js +719 -374
- package/lib/src/Ad4mClient.d.ts +1 -1
- package/lib/src/Ad4mClient.js +2 -1
- package/lib/src/agent/AgentClient.d.ts +16 -0
- package/lib/src/agent/AgentClient.js +74 -4
- package/lib/src/cache/PersistentCache.d.ts +40 -0
- package/lib/src/cache/PersistentCache.js +139 -0
- package/lib/src/expression/ExpressionClient.d.ts +8 -0
- package/lib/src/expression/ExpressionClient.js +113 -5
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +1 -0
- package/lib/src/model/Ad4mModel.d.ts +15 -0
- package/lib/src/model/Ad4mModel.js +123 -85
- package/lib/src/model/ModelQueryBuilder.js +17 -17
- package/lib/src/model/types.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveClient.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveClient.js +5 -13
- package/lib/src/perspectives/PerspectiveProxy.js +0 -3
- package/package.json +8 -11
- package/src/Ad4mClient.test.ts +14 -4
- package/src/Ad4mClient.ts +2 -1
- package/src/agent/AgentClient.ts +84 -2
- package/src/cache/PersistentCache.ts +145 -0
- package/src/cache/cache.test.ts +713 -0
- package/src/expression/ExpressionClient.ts +137 -3
- package/src/index.ts +1 -0
- package/src/model/Ad4mModel.test.ts +1 -61
- package/src/model/Ad4mModel.ts +128 -83
- package/src/model/ModelQueryBuilder.ts +17 -13
- package/src/model/types.ts +1 -1
- package/src/perspectives/PerspectiveClient.ts +7 -17
- package/src/perspectives/PerspectiveProxy.ts +0 -3
package/lib/index.cjs
CHANGED
|
@@ -555,13 +555,13 @@ class AgentStatus {
|
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
-
var __classPrivateFieldSet$
|
|
558
|
+
var __classPrivateFieldSet$c = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
559
559
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
560
560
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
561
561
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
562
562
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
563
563
|
};
|
|
564
|
-
var __classPrivateFieldGet$
|
|
564
|
+
var __classPrivateFieldGet$c = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
565
565
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
566
566
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
567
567
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -571,41 +571,41 @@ class NeighbourhoodProxy {
|
|
|
571
571
|
constructor(client, pID) {
|
|
572
572
|
_NeighbourhoodProxy_client.set(this, void 0);
|
|
573
573
|
_NeighbourhoodProxy_pID.set(this, void 0);
|
|
574
|
-
__classPrivateFieldSet$
|
|
575
|
-
__classPrivateFieldSet$
|
|
574
|
+
__classPrivateFieldSet$c(this, _NeighbourhoodProxy_client, client, "f");
|
|
575
|
+
__classPrivateFieldSet$c(this, _NeighbourhoodProxy_pID, pID, "f");
|
|
576
576
|
}
|
|
577
577
|
async otherAgents() {
|
|
578
|
-
return await __classPrivateFieldGet$
|
|
578
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"));
|
|
579
579
|
}
|
|
580
580
|
async hasTelepresenceAdapter() {
|
|
581
|
-
return await __classPrivateFieldGet$
|
|
581
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"));
|
|
582
582
|
}
|
|
583
583
|
async onlineAgents() {
|
|
584
|
-
return await __classPrivateFieldGet$
|
|
584
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"));
|
|
585
585
|
}
|
|
586
586
|
async setOnlineStatus(status) {
|
|
587
|
-
return await __classPrivateFieldGet$
|
|
587
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), status);
|
|
588
588
|
}
|
|
589
589
|
async setOnlineStatusU(status) {
|
|
590
|
-
return await __classPrivateFieldGet$
|
|
590
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), status);
|
|
591
591
|
}
|
|
592
592
|
async sendSignal(remoteAgentDid, payload) {
|
|
593
|
-
return await __classPrivateFieldGet$
|
|
593
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
|
|
594
594
|
}
|
|
595
595
|
async sendSignalU(remoteAgentDid, payload) {
|
|
596
|
-
return await __classPrivateFieldGet$
|
|
596
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
|
|
597
597
|
}
|
|
598
598
|
async sendBroadcast(payload, loopback = false) {
|
|
599
|
-
return await __classPrivateFieldGet$
|
|
599
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
|
|
600
600
|
}
|
|
601
601
|
async sendBroadcastU(payload, loopback = false) {
|
|
602
|
-
return await __classPrivateFieldGet$
|
|
602
|
+
return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
|
|
603
603
|
}
|
|
604
604
|
async addSignalHandler(handler) {
|
|
605
|
-
await __classPrivateFieldGet$
|
|
605
|
+
await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), handler);
|
|
606
606
|
}
|
|
607
607
|
removeSignalHandler(handler) {
|
|
608
|
-
__classPrivateFieldGet$
|
|
608
|
+
__classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), handler);
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
611
|
_NeighbourhoodProxy_client = new WeakMap(), _NeighbourhoodProxy_pID = new WeakMap();
|
|
@@ -699,13 +699,13 @@ class LinkQuery {
|
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
701
|
|
|
702
|
-
var __classPrivateFieldSet$
|
|
702
|
+
var __classPrivateFieldSet$b = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
703
703
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
704
704
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
705
705
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
706
706
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
707
707
|
};
|
|
708
|
-
var __classPrivateFieldGet$
|
|
708
|
+
var __classPrivateFieldGet$b = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
709
709
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
710
710
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
711
711
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -726,44 +726,44 @@ class Literal {
|
|
|
726
726
|
if (url.startsWith("literal://"))
|
|
727
727
|
throw new Error("literal:// format is no longer supported. Use literal: instead.");
|
|
728
728
|
const l = new Literal();
|
|
729
|
-
__classPrivateFieldSet$
|
|
729
|
+
__classPrivateFieldSet$b(l, _Literal_url, url, "f");
|
|
730
730
|
return l;
|
|
731
731
|
}
|
|
732
732
|
static from(literal) {
|
|
733
733
|
const l = new Literal();
|
|
734
|
-
__classPrivateFieldSet$
|
|
734
|
+
__classPrivateFieldSet$b(l, _Literal_literal, literal, "f");
|
|
735
735
|
return l;
|
|
736
736
|
}
|
|
737
737
|
toUrl() {
|
|
738
|
-
if (__classPrivateFieldGet$
|
|
739
|
-
return __classPrivateFieldGet$
|
|
740
|
-
if (!__classPrivateFieldGet$
|
|
738
|
+
if (__classPrivateFieldGet$b(this, _Literal_url, "f") && !__classPrivateFieldGet$b(this, _Literal_literal, "f"))
|
|
739
|
+
return __classPrivateFieldGet$b(this, _Literal_url, "f");
|
|
740
|
+
if (!__classPrivateFieldGet$b(this, _Literal_url, "f") && (__classPrivateFieldGet$b(this, _Literal_literal, "f") === undefined || __classPrivateFieldGet$b(this, _Literal_literal, "f") === "" || __classPrivateFieldGet$b(this, _Literal_literal, "f") === null))
|
|
741
741
|
throw new Error("Can't turn empty Literal into URL");
|
|
742
742
|
let encoded;
|
|
743
|
-
switch (typeof __classPrivateFieldGet$
|
|
743
|
+
switch (typeof __classPrivateFieldGet$b(this, _Literal_literal, "f")) {
|
|
744
744
|
case 'string':
|
|
745
|
-
encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$
|
|
745
|
+
encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$b(this, _Literal_literal, "f"))}`;
|
|
746
746
|
break;
|
|
747
747
|
case 'number':
|
|
748
|
-
encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$
|
|
748
|
+
encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$b(this, _Literal_literal, "f"))}`;
|
|
749
749
|
break;
|
|
750
750
|
case 'boolean':
|
|
751
|
-
encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$
|
|
751
|
+
encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$b(this, _Literal_literal, "f"))}`;
|
|
752
752
|
break;
|
|
753
753
|
case 'object':
|
|
754
|
-
encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$
|
|
754
|
+
encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$b(this, _Literal_literal, "f")))}`;
|
|
755
755
|
break;
|
|
756
756
|
}
|
|
757
757
|
return `literal:${encoded}`;
|
|
758
758
|
}
|
|
759
759
|
get() {
|
|
760
|
-
if (__classPrivateFieldGet$
|
|
761
|
-
return __classPrivateFieldGet$
|
|
762
|
-
if (!__classPrivateFieldGet$
|
|
760
|
+
if (__classPrivateFieldGet$b(this, _Literal_literal, "f"))
|
|
761
|
+
return __classPrivateFieldGet$b(this, _Literal_literal, "f");
|
|
762
|
+
if (!__classPrivateFieldGet$b(this, _Literal_url, "f"))
|
|
763
763
|
throw new Error("Can't render empty Literal");
|
|
764
|
-
if (!__classPrivateFieldGet$
|
|
764
|
+
if (!__classPrivateFieldGet$b(this, _Literal_url, "f").startsWith("literal:"))
|
|
765
765
|
throw new Error("Can't render Literal from non-literal URL");
|
|
766
|
-
const body = __classPrivateFieldGet$
|
|
766
|
+
const body = __classPrivateFieldGet$b(this, _Literal_url, "f").substring(8);
|
|
767
767
|
if (body.startsWith("string:")) {
|
|
768
768
|
return decodeURIComponent(body.substring(7));
|
|
769
769
|
}
|
|
@@ -3210,13 +3210,13 @@ class SHACLFlow {
|
|
|
3210
3210
|
}
|
|
3211
3211
|
}
|
|
3212
3212
|
|
|
3213
|
-
var __classPrivateFieldSet$
|
|
3213
|
+
var __classPrivateFieldSet$a = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3214
3214
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3215
3215
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
3216
3216
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3217
3217
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
3218
3218
|
};
|
|
3219
|
-
var __classPrivateFieldGet$
|
|
3219
|
+
var __classPrivateFieldGet$a = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3220
3220
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3221
3221
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
3222
3222
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -3289,56 +3289,56 @@ class QuerySubscriptionProxy {
|
|
|
3289
3289
|
_QuerySubscriptionProxy_initReject.set(this, void 0);
|
|
3290
3290
|
_QuerySubscriptionProxy_initTimeoutId.set(this, void 0);
|
|
3291
3291
|
_QuerySubscriptionProxy_query.set(this, void 0);
|
|
3292
|
-
__classPrivateFieldSet$
|
|
3293
|
-
__classPrivateFieldSet$
|
|
3294
|
-
__classPrivateFieldSet$
|
|
3295
|
-
__classPrivateFieldSet$
|
|
3296
|
-
__classPrivateFieldSet$
|
|
3292
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_uuid, uuid, "f");
|
|
3293
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_query, query, "f");
|
|
3294
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_client, client, "f");
|
|
3295
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_callbacks, new Set(), "f");
|
|
3296
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, null, "f");
|
|
3297
3297
|
// Create the promise once and store its resolve/reject
|
|
3298
|
-
__classPrivateFieldSet$
|
|
3299
|
-
__classPrivateFieldSet$
|
|
3300
|
-
__classPrivateFieldSet$
|
|
3298
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
|
|
3299
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
|
|
3300
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initReject, reject, "f");
|
|
3301
3301
|
}), "f");
|
|
3302
3302
|
}
|
|
3303
3303
|
async subscribe() {
|
|
3304
3304
|
// Clean up previous subscription attempt if retrying
|
|
3305
|
-
if (__classPrivateFieldGet$
|
|
3306
|
-
__classPrivateFieldGet$
|
|
3307
|
-
__classPrivateFieldSet$
|
|
3305
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_unsubscribe, "f")) {
|
|
3306
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_unsubscribe, "f").call(this);
|
|
3307
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_unsubscribe, undefined, "f");
|
|
3308
3308
|
}
|
|
3309
3309
|
// Clear any existing timeout
|
|
3310
|
-
if (__classPrivateFieldGet$
|
|
3311
|
-
clearTimeout(__classPrivateFieldGet$
|
|
3312
|
-
__classPrivateFieldSet$
|
|
3310
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
|
|
3311
|
+
clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
|
|
3312
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
|
|
3313
3313
|
}
|
|
3314
3314
|
// Clear any existing keepalive timer to prevent accumulation
|
|
3315
|
-
if (__classPrivateFieldGet$
|
|
3316
|
-
clearTimeout(__classPrivateFieldGet$
|
|
3317
|
-
__classPrivateFieldSet$
|
|
3315
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_keepaliveTimer, "f")) {
|
|
3316
|
+
clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_keepaliveTimer, "f"));
|
|
3317
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_keepaliveTimer, undefined, "f");
|
|
3318
3318
|
}
|
|
3319
3319
|
try {
|
|
3320
3320
|
// Initialize the query subscription
|
|
3321
3321
|
let initialResult;
|
|
3322
|
-
initialResult = await __classPrivateFieldGet$
|
|
3323
|
-
__classPrivateFieldSet$
|
|
3322
|
+
initialResult = await __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").subscribeQuery(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_query, "f"));
|
|
3323
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_subscriptionId, initialResult.subscriptionId, "f");
|
|
3324
3324
|
// Process the initial result immediately for fast UX.
|
|
3325
3325
|
// The subscribeQuery() RPC call already returns the initial result,
|
|
3326
3326
|
// so treat that as successful initialization instead of waiting for a
|
|
3327
3327
|
// follow-up WebSocket update that may never arrive until the query changes.
|
|
3328
3328
|
if (initialResult.result !== undefined) {
|
|
3329
|
-
__classPrivateFieldSet$
|
|
3330
|
-
__classPrivateFieldGet$
|
|
3331
|
-
if (__classPrivateFieldGet$
|
|
3332
|
-
__classPrivateFieldGet$
|
|
3333
|
-
__classPrivateFieldSet$
|
|
3334
|
-
__classPrivateFieldSet$
|
|
3329
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, initialResult.result, "f");
|
|
3330
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, initialResult.result);
|
|
3331
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initResolve, "f")) {
|
|
3332
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initResolve, "f").call(this, true);
|
|
3333
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initResolve, undefined, "f");
|
|
3334
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initReject, undefined, "f");
|
|
3335
3335
|
}
|
|
3336
3336
|
}
|
|
3337
3337
|
else {
|
|
3338
3338
|
console.warn('⚠️ No initial result returned from subscribeQuery!');
|
|
3339
3339
|
// Only keep the initialization timeout when the backend did not
|
|
3340
3340
|
// provide an initial result up front.
|
|
3341
|
-
__classPrivateFieldSet$
|
|
3341
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, setTimeout(() => {
|
|
3342
3342
|
console.error('Subscription initialization timed out after 30 seconds. Resubscribing...');
|
|
3343
3343
|
// Recursively retry subscription, catching any errors
|
|
3344
3344
|
this.subscribe().catch(error => {
|
|
@@ -3347,46 +3347,43 @@ class QuerySubscriptionProxy {
|
|
|
3347
3347
|
}, 30000), "f");
|
|
3348
3348
|
}
|
|
3349
3349
|
// Subscribe to query updates
|
|
3350
|
-
__classPrivateFieldSet$
|
|
3350
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_unsubscribe, __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").subscribeToQueryUpdates(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f"), (updateResult) => {
|
|
3351
3351
|
// Clear timeout on first message
|
|
3352
|
-
if (__classPrivateFieldGet$
|
|
3353
|
-
clearTimeout(__classPrivateFieldGet$
|
|
3354
|
-
__classPrivateFieldSet$
|
|
3352
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
|
|
3353
|
+
clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
|
|
3354
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
|
|
3355
3355
|
}
|
|
3356
3356
|
// Resolve the initialization promise (only resolves once)
|
|
3357
|
-
if (__classPrivateFieldGet$
|
|
3358
|
-
__classPrivateFieldGet$
|
|
3359
|
-
__classPrivateFieldSet$
|
|
3360
|
-
__classPrivateFieldSet$
|
|
3357
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initResolve, "f")) {
|
|
3358
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initResolve, "f").call(this, true);
|
|
3359
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initResolve, undefined, "f"); // Prevent double-resolve
|
|
3360
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initReject, undefined, "f");
|
|
3361
3361
|
}
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
return;
|
|
3365
|
-
__classPrivateFieldSet$9(this, _QuerySubscriptionProxy_latestResult, updateResult, "f");
|
|
3366
|
-
__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, updateResult);
|
|
3362
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, updateResult, "f");
|
|
3363
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, updateResult);
|
|
3367
3364
|
}), "f");
|
|
3368
3365
|
}
|
|
3369
3366
|
catch (error) {
|
|
3370
3367
|
console.error('Error setting up subscription:', error);
|
|
3371
3368
|
// Reject the promise if this is the first attempt
|
|
3372
|
-
if (__classPrivateFieldGet$
|
|
3373
|
-
__classPrivateFieldGet$
|
|
3374
|
-
__classPrivateFieldSet$
|
|
3375
|
-
__classPrivateFieldSet$
|
|
3369
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initReject, "f")) {
|
|
3370
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initReject, "f").call(this, error);
|
|
3371
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initResolve, undefined, "f");
|
|
3372
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initReject, undefined, "f");
|
|
3376
3373
|
}
|
|
3377
3374
|
throw error; // Re-throw so caller knows it failed
|
|
3378
3375
|
}
|
|
3379
3376
|
// Start keepalive loop using platform-agnostic setTimeout
|
|
3380
3377
|
const keepaliveLoop = async () => {
|
|
3381
|
-
if (__classPrivateFieldGet$
|
|
3378
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_disposed, "f"))
|
|
3382
3379
|
return;
|
|
3383
3380
|
try {
|
|
3384
|
-
await __classPrivateFieldGet$
|
|
3381
|
+
await __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").keepAliveQuery(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f"));
|
|
3385
3382
|
}
|
|
3386
3383
|
catch (e) {
|
|
3387
3384
|
console.error('Error in keepalive:', e);
|
|
3388
3385
|
// try to reinitialize the subscription
|
|
3389
|
-
console.log('Reinitializing subscription for query:', __classPrivateFieldGet$
|
|
3386
|
+
console.log('Reinitializing subscription for query:', __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_query, "f"));
|
|
3390
3387
|
try {
|
|
3391
3388
|
await this.subscribe();
|
|
3392
3389
|
console.log('Subscription reinitialized');
|
|
@@ -3398,12 +3395,12 @@ class QuerySubscriptionProxy {
|
|
|
3398
3395
|
}
|
|
3399
3396
|
}
|
|
3400
3397
|
// Schedule next keepalive if not disposed
|
|
3401
|
-
if (!__classPrivateFieldGet$
|
|
3402
|
-
__classPrivateFieldSet$
|
|
3398
|
+
if (!__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_disposed, "f")) {
|
|
3399
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_keepaliveTimer, setTimeout(keepaliveLoop, 30000), "f");
|
|
3403
3400
|
}
|
|
3404
3401
|
};
|
|
3405
3402
|
// Start the first keepalive loop
|
|
3406
|
-
__classPrivateFieldSet$
|
|
3403
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_keepaliveTimer, setTimeout(keepaliveLoop, 30000), "f");
|
|
3407
3404
|
}
|
|
3408
3405
|
/** Get the subscription ID for this query subscription
|
|
3409
3406
|
*
|
|
@@ -3414,7 +3411,7 @@ class QuerySubscriptionProxy {
|
|
|
3414
3411
|
* @returns The subscription ID string
|
|
3415
3412
|
*/
|
|
3416
3413
|
get id() {
|
|
3417
|
-
return __classPrivateFieldGet$
|
|
3414
|
+
return __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f");
|
|
3418
3415
|
}
|
|
3419
3416
|
/** Promise that resolves when the subscription has received its first result
|
|
3420
3417
|
* through the subscription channel. This ensures the subscription is fully
|
|
@@ -3428,7 +3425,7 @@ class QuerySubscriptionProxy {
|
|
|
3428
3425
|
* creation methods (like subscribeInfer) already wait for initialization.
|
|
3429
3426
|
*/
|
|
3430
3427
|
get initialized() {
|
|
3431
|
-
return __classPrivateFieldGet$
|
|
3428
|
+
return __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initialized, "f");
|
|
3432
3429
|
}
|
|
3433
3430
|
/** Get the latest query result
|
|
3434
3431
|
*
|
|
@@ -3439,7 +3436,7 @@ class QuerySubscriptionProxy {
|
|
|
3439
3436
|
* @returns The latest query result as a string (usually a JSON array of bindings)
|
|
3440
3437
|
*/
|
|
3441
3438
|
get result() {
|
|
3442
|
-
return __classPrivateFieldGet$
|
|
3439
|
+
return __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_latestResult, "f");
|
|
3443
3440
|
}
|
|
3444
3441
|
/** Add a callback that will be called whenever new results arrive
|
|
3445
3442
|
*
|
|
@@ -3461,8 +3458,8 @@ class QuerySubscriptionProxy {
|
|
|
3461
3458
|
* ```
|
|
3462
3459
|
*/
|
|
3463
3460
|
onResult(callback) {
|
|
3464
|
-
__classPrivateFieldGet$
|
|
3465
|
-
return () => __classPrivateFieldGet$
|
|
3461
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
|
|
3462
|
+
return () => __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
|
|
3466
3463
|
}
|
|
3467
3464
|
/** Clean up the subscription and stop keepalive signals
|
|
3468
3465
|
*
|
|
@@ -3476,25 +3473,25 @@ class QuerySubscriptionProxy {
|
|
|
3476
3473
|
* will not receive any more updates. The instance should be discarded.
|
|
3477
3474
|
*/
|
|
3478
3475
|
dispose() {
|
|
3479
|
-
__classPrivateFieldSet$
|
|
3480
|
-
clearTimeout(__classPrivateFieldGet$
|
|
3481
|
-
if (__classPrivateFieldGet$
|
|
3482
|
-
__classPrivateFieldGet$
|
|
3476
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_disposed, true, "f");
|
|
3477
|
+
clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_keepaliveTimer, "f"));
|
|
3478
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_unsubscribe, "f")) {
|
|
3479
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_unsubscribe, "f").call(this);
|
|
3483
3480
|
}
|
|
3484
|
-
__classPrivateFieldGet$
|
|
3485
|
-
if (__classPrivateFieldGet$
|
|
3486
|
-
clearTimeout(__classPrivateFieldGet$
|
|
3487
|
-
__classPrivateFieldSet$
|
|
3481
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_callbacks, "f").clear();
|
|
3482
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
|
|
3483
|
+
clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
|
|
3484
|
+
__classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
|
|
3488
3485
|
}
|
|
3489
3486
|
// Tell the backend to dispose of the subscription
|
|
3490
|
-
if (__classPrivateFieldGet$
|
|
3491
|
-
__classPrivateFieldGet$
|
|
3487
|
+
if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f")) {
|
|
3488
|
+
__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").disposeQuerySubscription(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f"))
|
|
3492
3489
|
.catch(e => console.error('Error disposing query subscription:', e));
|
|
3493
3490
|
}
|
|
3494
3491
|
}
|
|
3495
3492
|
}
|
|
3496
3493
|
_QuerySubscriptionProxy_uuid = new WeakMap(), _QuerySubscriptionProxy_subscriptionId = new WeakMap(), _QuerySubscriptionProxy_client = new WeakMap(), _QuerySubscriptionProxy_callbacks = new WeakMap(), _QuerySubscriptionProxy_keepaliveTimer = new WeakMap(), _QuerySubscriptionProxy_unsubscribe = new WeakMap(), _QuerySubscriptionProxy_latestResult = new WeakMap(), _QuerySubscriptionProxy_disposed = new WeakMap(), _QuerySubscriptionProxy_initialized = new WeakMap(), _QuerySubscriptionProxy_initResolve = new WeakMap(), _QuerySubscriptionProxy_initReject = new WeakMap(), _QuerySubscriptionProxy_initTimeoutId = new WeakMap(), _QuerySubscriptionProxy_query = new WeakMap(), _QuerySubscriptionProxy_instances = new WeakSet(), _QuerySubscriptionProxy_notifyCallbacks = function _QuerySubscriptionProxy_notifyCallbacks(result) {
|
|
3497
|
-
for (const callback of __classPrivateFieldGet$
|
|
3494
|
+
for (const callback of __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_callbacks, "f")) {
|
|
3498
3495
|
try {
|
|
3499
3496
|
callback(result);
|
|
3500
3497
|
}
|
|
@@ -3544,7 +3541,7 @@ _QuerySubscriptionProxy_uuid = new WeakMap(), _QuerySubscriptionProxy_subscripti
|
|
|
3544
3541
|
*/
|
|
3545
3542
|
class PerspectiveProxy {
|
|
3546
3543
|
/** @internal Exposed for ModelQueryBuilder subscription management */
|
|
3547
|
-
get client() { return __classPrivateFieldGet$
|
|
3544
|
+
get client() { return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f"); }
|
|
3548
3545
|
/**
|
|
3549
3546
|
* Creates a new PerspectiveProxy instance.
|
|
3550
3547
|
* Note: Don't create this directly, use ad4m.perspective.add() instead.
|
|
@@ -3562,31 +3559,31 @@ class PerspectiveProxy {
|
|
|
3562
3559
|
* Note: Don't create this directly, use ad4m.perspective.add() instead.
|
|
3563
3560
|
*/
|
|
3564
3561
|
);
|
|
3565
|
-
__classPrivateFieldSet$
|
|
3566
|
-
__classPrivateFieldSet$
|
|
3567
|
-
__classPrivateFieldSet$
|
|
3568
|
-
__classPrivateFieldSet$
|
|
3569
|
-
__classPrivateFieldSet$
|
|
3570
|
-
__classPrivateFieldSet$
|
|
3571
|
-
this.uuid = __classPrivateFieldGet$
|
|
3572
|
-
this.name = __classPrivateFieldGet$
|
|
3573
|
-
this.owners = __classPrivateFieldGet$
|
|
3574
|
-
this.sharedUrl = __classPrivateFieldGet$
|
|
3575
|
-
this.neighbourhood = __classPrivateFieldGet$
|
|
3576
|
-
this.state = __classPrivateFieldGet$
|
|
3577
|
-
__classPrivateFieldGet$
|
|
3578
|
-
__classPrivateFieldGet$
|
|
3579
|
-
__classPrivateFieldGet$
|
|
3580
|
-
__classPrivateFieldGet$
|
|
3562
|
+
__classPrivateFieldSet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, [], "f");
|
|
3563
|
+
__classPrivateFieldSet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, [], "f");
|
|
3564
|
+
__classPrivateFieldSet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, [], "f");
|
|
3565
|
+
__classPrivateFieldSet$a(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, [], "f");
|
|
3566
|
+
__classPrivateFieldSet$a(this, _PerspectiveProxy_handle, handle, "f");
|
|
3567
|
+
__classPrivateFieldSet$a(this, _PerspectiveProxy_client, ad4m, "f");
|
|
3568
|
+
this.uuid = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid;
|
|
3569
|
+
this.name = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").name;
|
|
3570
|
+
this.owners = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").owners;
|
|
3571
|
+
this.sharedUrl = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").sharedUrl;
|
|
3572
|
+
this.neighbourhood = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").neighbourhood;
|
|
3573
|
+
this.state = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").state;
|
|
3574
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addPerspectiveLinkAddedListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f"));
|
|
3575
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addPerspectiveLinkRemovedListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f"));
|
|
3576
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addPerspectiveLinkUpdatedListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f"));
|
|
3577
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addPerspectiveSyncStateChangeListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, "f"));
|
|
3581
3578
|
}
|
|
3582
3579
|
/** Update the proxy's internal handle and public fields in-place.
|
|
3583
3580
|
* Keeps the same object reference so all holders see the update. */
|
|
3584
3581
|
updateHandle(handle) {
|
|
3585
|
-
if (handle.uuid !== __classPrivateFieldGet$
|
|
3586
|
-
throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch — proxy is bound to "${__classPrivateFieldGet$
|
|
3582
|
+
if (handle.uuid !== __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid) {
|
|
3583
|
+
throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch — proxy is bound to "${__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid}" but received handle with UUID "${handle.uuid}". ` +
|
|
3587
3584
|
`This would silently diverge from listeners registered under the original UUID.`);
|
|
3588
3585
|
}
|
|
3589
|
-
__classPrivateFieldSet$
|
|
3586
|
+
__classPrivateFieldSet$a(this, _PerspectiveProxy_handle, handle, "f");
|
|
3590
3587
|
this.uuid = handle.uuid;
|
|
3591
3588
|
this.name = handle.name;
|
|
3592
3589
|
this.owners = handle.owners;
|
|
@@ -3667,8 +3664,8 @@ class PerspectiveProxy {
|
|
|
3667
3664
|
* @param batchId - Optional batch ID to group this operation with others
|
|
3668
3665
|
*/
|
|
3669
3666
|
async executeAction(actions, expression, parameters, batchId) {
|
|
3670
|
-
const result = await __classPrivateFieldGet$
|
|
3671
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
3667
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters), batchId);
|
|
3668
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3672
3669
|
return result;
|
|
3673
3670
|
}
|
|
3674
3671
|
/**
|
|
@@ -3693,7 +3690,7 @@ class PerspectiveProxy {
|
|
|
3693
3690
|
* ```
|
|
3694
3691
|
*/
|
|
3695
3692
|
async get(query) {
|
|
3696
|
-
return await __classPrivateFieldGet$
|
|
3693
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
|
|
3697
3694
|
}
|
|
3698
3695
|
/**
|
|
3699
3696
|
* Executes a Prolog query against the perspective's knowledge base.
|
|
@@ -3719,7 +3716,7 @@ class PerspectiveProxy {
|
|
|
3719
3716
|
* ```
|
|
3720
3717
|
*/
|
|
3721
3718
|
async infer(query) {
|
|
3722
|
-
return await __classPrivateFieldGet$
|
|
3719
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
|
|
3723
3720
|
}
|
|
3724
3721
|
/**
|
|
3725
3722
|
* Executes a SPARQL query against the perspective's link cache.
|
|
@@ -3738,11 +3735,11 @@ class PerspectiveProxy {
|
|
|
3738
3735
|
* @returns Query results as parsed JSON
|
|
3739
3736
|
*/
|
|
3740
3737
|
async querySparql(query) {
|
|
3741
|
-
const cached = getCachedResult(__classPrivateFieldGet$
|
|
3738
|
+
const cached = getCachedResult(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
|
|
3742
3739
|
if (cached !== undefined)
|
|
3743
3740
|
return cached;
|
|
3744
|
-
const result = await __classPrivateFieldGet$
|
|
3745
|
-
setCachedResult(__classPrivateFieldGet$
|
|
3741
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").querySparql(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
|
|
3742
|
+
setCachedResult(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query, result);
|
|
3746
3743
|
return result;
|
|
3747
3744
|
}
|
|
3748
3745
|
/**
|
|
@@ -3754,7 +3751,7 @@ class PerspectiveProxy {
|
|
|
3754
3751
|
* @returns Object with `instances` array and `totalCount`
|
|
3755
3752
|
*/
|
|
3756
3753
|
async modelQuery(className, queryJson, shapeJson) {
|
|
3757
|
-
return await __classPrivateFieldGet$
|
|
3754
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").modelQuery(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, shapeJson);
|
|
3758
3755
|
}
|
|
3759
3756
|
/**
|
|
3760
3757
|
* Evaluate property getters for a batch of instances in a single RPC call.
|
|
@@ -3770,7 +3767,7 @@ class PerspectiveProxy {
|
|
|
3770
3767
|
* @returns Map of instance ID → evaluated property values
|
|
3771
3768
|
*/
|
|
3772
3769
|
async evaluateGetters(className, instanceIds, shapeJson, propertyNames) {
|
|
3773
|
-
return await __classPrivateFieldGet$
|
|
3770
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").evaluateGetters(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, className, instanceIds, shapeJson, propertyNames);
|
|
3774
3771
|
}
|
|
3775
3772
|
/**
|
|
3776
3773
|
* Subscribe to model query changes. Builds trigger SPARQL from the model shape
|
|
@@ -3786,7 +3783,7 @@ class PerspectiveProxy {
|
|
|
3786
3783
|
* @returns Object with `subscriptionId` and initial `result`
|
|
3787
3784
|
*/
|
|
3788
3785
|
async modelSubscribe(className, queryJson, shapeJson) {
|
|
3789
|
-
return await __classPrivateFieldGet$
|
|
3786
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").modelSubscribe(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, shapeJson);
|
|
3790
3787
|
}
|
|
3791
3788
|
/**
|
|
3792
3789
|
* Adds a new link to the perspective.
|
|
@@ -3814,8 +3811,8 @@ class PerspectiveProxy {
|
|
|
3814
3811
|
* ```
|
|
3815
3812
|
*/
|
|
3816
3813
|
async add(link, status = 'shared', batchId) {
|
|
3817
|
-
const result = await __classPrivateFieldGet$
|
|
3818
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
3814
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
|
|
3815
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3819
3816
|
return result;
|
|
3820
3817
|
}
|
|
3821
3818
|
/**
|
|
@@ -3828,8 +3825,8 @@ class PerspectiveProxy {
|
|
|
3828
3825
|
* @returns Array of created LinkExpressions
|
|
3829
3826
|
*/
|
|
3830
3827
|
async addLinks(links, status = 'shared', batchId) {
|
|
3831
|
-
const result = await __classPrivateFieldGet$
|
|
3832
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
3828
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, links, status, batchId);
|
|
3829
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3833
3830
|
return result;
|
|
3834
3831
|
}
|
|
3835
3832
|
/**
|
|
@@ -3840,8 +3837,8 @@ class PerspectiveProxy {
|
|
|
3840
3837
|
* @returns Array of removed LinkExpressions
|
|
3841
3838
|
*/
|
|
3842
3839
|
async removeLinks(links, batchId) {
|
|
3843
|
-
const result = await __classPrivateFieldGet$
|
|
3844
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
3840
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").removeLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, links, batchId);
|
|
3841
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3845
3842
|
return result;
|
|
3846
3843
|
}
|
|
3847
3844
|
/**
|
|
@@ -3853,8 +3850,8 @@ class PerspectiveProxy {
|
|
|
3853
3850
|
* @returns Object containing results of the mutations
|
|
3854
3851
|
*/
|
|
3855
3852
|
async linkMutations(mutations, status = 'shared') {
|
|
3856
|
-
const result = await __classPrivateFieldGet$
|
|
3857
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
3853
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").linkMutations(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, mutations, status);
|
|
3854
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3858
3855
|
return result;
|
|
3859
3856
|
}
|
|
3860
3857
|
/**
|
|
@@ -3866,7 +3863,7 @@ class PerspectiveProxy {
|
|
|
3866
3863
|
* @returns The added LinkExpression
|
|
3867
3864
|
*/
|
|
3868
3865
|
async addLinkExpression(link, status = 'shared', batchId) {
|
|
3869
|
-
return await __classPrivateFieldGet$
|
|
3866
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addLinkExpression(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
|
|
3870
3867
|
}
|
|
3871
3868
|
/**
|
|
3872
3869
|
* Updates an existing link with new data.
|
|
@@ -3876,8 +3873,8 @@ class PerspectiveProxy {
|
|
|
3876
3873
|
* @param batchId - Optional batch ID to group this operation with others
|
|
3877
3874
|
*/
|
|
3878
3875
|
async update(oldLink, newLink, batchId) {
|
|
3879
|
-
const result = await __classPrivateFieldGet$
|
|
3880
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
3876
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").updateLink(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, oldLink, newLink, batchId);
|
|
3877
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3881
3878
|
return result;
|
|
3882
3879
|
}
|
|
3883
3880
|
/**
|
|
@@ -3887,18 +3884,18 @@ class PerspectiveProxy {
|
|
|
3887
3884
|
* @param batchId - Optional batch ID to group this operation with others
|
|
3888
3885
|
*/
|
|
3889
3886
|
async remove(link, batchId) {
|
|
3890
|
-
const result = await __classPrivateFieldGet$
|
|
3891
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
3887
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").removeLink(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, link, batchId);
|
|
3888
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3892
3889
|
return result;
|
|
3893
3890
|
}
|
|
3894
3891
|
/** Creates a new batch for grouping operations */
|
|
3895
3892
|
async createBatch() {
|
|
3896
|
-
return await __classPrivateFieldGet$
|
|
3893
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").createBatch(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3897
3894
|
}
|
|
3898
3895
|
/** Commits a batch of operations */
|
|
3899
3896
|
async commitBatch(batchId) {
|
|
3900
|
-
const result = await __classPrivateFieldGet$
|
|
3901
|
-
invalidatePerspectiveCache(__classPrivateFieldGet$
|
|
3897
|
+
const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").commitBatch(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, batchId);
|
|
3898
|
+
invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3902
3899
|
return result;
|
|
3903
3900
|
}
|
|
3904
3901
|
/**
|
|
@@ -3908,7 +3905,7 @@ class PerspectiveProxy {
|
|
|
3908
3905
|
* @returns The rendered Expression
|
|
3909
3906
|
*/
|
|
3910
3907
|
async getExpression(expressionURI) {
|
|
3911
|
-
return await __classPrivateFieldGet$
|
|
3908
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").getExpression(expressionURI);
|
|
3912
3909
|
}
|
|
3913
3910
|
/**
|
|
3914
3911
|
* Creates a new Expression in the specified Language.
|
|
@@ -3918,7 +3915,7 @@ class PerspectiveProxy {
|
|
|
3918
3915
|
* @returns URI of the created Expression
|
|
3919
3916
|
*/
|
|
3920
3917
|
async createExpression(content, languageAddress) {
|
|
3921
|
-
return await __classPrivateFieldGet$
|
|
3918
|
+
return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").createExpression(content, languageAddress);
|
|
3922
3919
|
}
|
|
3923
3920
|
/**
|
|
3924
3921
|
* Subscribes to link changes in the perspective.
|
|
@@ -3941,13 +3938,13 @@ class PerspectiveProxy {
|
|
|
3941
3938
|
*/
|
|
3942
3939
|
async addListener(type, cb) {
|
|
3943
3940
|
if (type === 'link-added') {
|
|
3944
|
-
__classPrivateFieldGet$
|
|
3941
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").push(cb);
|
|
3945
3942
|
}
|
|
3946
3943
|
else if (type === 'link-removed') {
|
|
3947
|
-
__classPrivateFieldGet$
|
|
3944
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").push(cb);
|
|
3948
3945
|
}
|
|
3949
3946
|
else if (type === 'link-updated') {
|
|
3950
|
-
__classPrivateFieldGet$
|
|
3947
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").push(cb);
|
|
3951
3948
|
}
|
|
3952
3949
|
}
|
|
3953
3950
|
/**
|
|
@@ -3963,7 +3960,7 @@ class PerspectiveProxy {
|
|
|
3963
3960
|
* ```
|
|
3964
3961
|
*/
|
|
3965
3962
|
async addSyncStateChangeListener(cb) {
|
|
3966
|
-
__classPrivateFieldGet$
|
|
3963
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, "f").push(cb);
|
|
3967
3964
|
}
|
|
3968
3965
|
/**
|
|
3969
3966
|
* Unsubscribes from link changes.
|
|
@@ -3973,16 +3970,16 @@ class PerspectiveProxy {
|
|
|
3973
3970
|
*/
|
|
3974
3971
|
async removeListener(type, cb) {
|
|
3975
3972
|
if (type === 'link-added') {
|
|
3976
|
-
const index = __classPrivateFieldGet$
|
|
3977
|
-
__classPrivateFieldGet$
|
|
3973
|
+
const index = __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").indexOf(cb);
|
|
3974
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").splice(index, 1);
|
|
3978
3975
|
}
|
|
3979
3976
|
else if (type === 'link-removed') {
|
|
3980
|
-
const index = __classPrivateFieldGet$
|
|
3981
|
-
__classPrivateFieldGet$
|
|
3977
|
+
const index = __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").indexOf(cb);
|
|
3978
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").splice(index, 1);
|
|
3982
3979
|
}
|
|
3983
3980
|
else if (type === 'link-updated') {
|
|
3984
|
-
const index = __classPrivateFieldGet$
|
|
3985
|
-
__classPrivateFieldGet$
|
|
3981
|
+
const index = __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").indexOf(cb);
|
|
3982
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").splice(index, 1);
|
|
3986
3983
|
}
|
|
3987
3984
|
}
|
|
3988
3985
|
/**
|
|
@@ -3992,7 +3989,7 @@ class PerspectiveProxy {
|
|
|
3992
3989
|
* @returns Perspective object containing all links
|
|
3993
3990
|
*/
|
|
3994
3991
|
async snapshot() {
|
|
3995
|
-
return __classPrivateFieldGet$
|
|
3992
|
+
return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").snapshotByUUID(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
3996
3993
|
}
|
|
3997
3994
|
/**
|
|
3998
3995
|
* Loads a perspective snapshot, replacing current content.
|
|
@@ -4272,7 +4269,7 @@ class PerspectiveProxy {
|
|
|
4272
4269
|
* await perspective.addSdna('Recipe', prologCode, 'subject_class');
|
|
4273
4270
|
*/
|
|
4274
4271
|
async addSdna(name, sdnaCode, sdnaType, shaclJson) {
|
|
4275
|
-
return __classPrivateFieldGet$
|
|
4272
|
+
return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType, shaclJson);
|
|
4276
4273
|
}
|
|
4277
4274
|
/**
|
|
4278
4275
|
* Adds a subject class to the perspective.
|
|
@@ -4542,7 +4539,7 @@ class PerspectiveProxy {
|
|
|
4542
4539
|
let className;
|
|
4543
4540
|
if (typeof subjectClass === "string") {
|
|
4544
4541
|
className = subjectClass;
|
|
4545
|
-
await __classPrivateFieldGet$
|
|
4542
|
+
await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
|
|
4546
4543
|
className,
|
|
4547
4544
|
initialValues
|
|
4548
4545
|
}), exprAddr, initialValues ? JSON.stringify(initialValues) : undefined, batchId);
|
|
@@ -4554,7 +4551,7 @@ class PerspectiveProxy {
|
|
|
4554
4551
|
if (!resolvedClassName) {
|
|
4555
4552
|
throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
|
|
4556
4553
|
}
|
|
4557
|
-
await __classPrivateFieldGet$
|
|
4554
|
+
await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
|
|
4558
4555
|
className: resolvedClassName,
|
|
4559
4556
|
initialValues
|
|
4560
4557
|
}), exprAddr, initialValues ? JSON.stringify(initialValues) : undefined, batchId);
|
|
@@ -4569,7 +4566,7 @@ class PerspectiveProxy {
|
|
|
4569
4566
|
}
|
|
4570
4567
|
async getSubjectData(subjectClass, exprAddr) {
|
|
4571
4568
|
if (typeof subjectClass === "string") {
|
|
4572
|
-
return JSON.parse(await __classPrivateFieldGet$
|
|
4569
|
+
return JSON.parse(await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
|
|
4573
4570
|
}
|
|
4574
4571
|
const obj = subjectClass;
|
|
4575
4572
|
const resolvedClassName = obj.className || obj.constructor?.className || obj.constructor?.prototype?.className
|
|
@@ -4577,7 +4574,7 @@ class PerspectiveProxy {
|
|
|
4577
4574
|
if (!resolvedClassName) {
|
|
4578
4575
|
throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
|
|
4579
4576
|
}
|
|
4580
|
-
return JSON.parse(await __classPrivateFieldGet$
|
|
4577
|
+
return JSON.parse(await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: resolvedClassName }), exprAddr));
|
|
4581
4578
|
}
|
|
4582
4579
|
/**
|
|
4583
4580
|
* Gets actions from SHACL links for a given predicate (e.g., ad4m://constructor, ad4m://destructor).
|
|
@@ -4941,7 +4938,7 @@ class PerspectiveProxy {
|
|
|
4941
4938
|
// Get the class name from the JS class
|
|
4942
4939
|
const className = jsClass.className || jsClass.prototype?.className || jsClass.name;
|
|
4943
4940
|
// Skip if already registered for this perspective instance
|
|
4944
|
-
if (__classPrivateFieldGet$
|
|
4941
|
+
if (__classPrivateFieldGet$a(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
|
|
4945
4942
|
return;
|
|
4946
4943
|
// Note: Duplicate checking is handled on the Rust side in add_sdna
|
|
4947
4944
|
// Generate SHACL SDNA (Prolog-free)
|
|
@@ -4956,13 +4953,13 @@ class PerspectiveProxy {
|
|
|
4956
4953
|
// Backend stores SHACL links directly
|
|
4957
4954
|
await this.addSdna(className, '', 'subject_class', shaclJson);
|
|
4958
4955
|
// Mark as registered for this perspective instance
|
|
4959
|
-
__classPrivateFieldGet$
|
|
4956
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(className);
|
|
4960
4957
|
}
|
|
4961
4958
|
/** Clear the per-instance ensured subject class cache.
|
|
4962
4959
|
* Call this after wiping a perspective's links so that
|
|
4963
4960
|
* subsequent register() calls re-add SHACL definitions. */
|
|
4964
4961
|
clearEnsuredSubjectClasses() {
|
|
4965
|
-
__classPrivateFieldGet$
|
|
4962
|
+
__classPrivateFieldGet$a(this, _PerspectiveProxy_ensuredSubjectClasses, "f").clear();
|
|
4966
4963
|
}
|
|
4967
4964
|
/**
|
|
4968
4965
|
* Returns a list of all class names that have been registered as SHACL
|
|
@@ -5137,7 +5134,7 @@ class PerspectiveProxy {
|
|
|
5137
5134
|
}));
|
|
5138
5135
|
}
|
|
5139
5136
|
getNeighbourhoodProxy() {
|
|
5140
|
-
return __classPrivateFieldGet$
|
|
5137
|
+
return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").getNeighbourhoodProxy(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
|
|
5141
5138
|
}
|
|
5142
5139
|
/**
|
|
5143
5140
|
* Returns a proxy object for working with AI capabilities.
|
|
@@ -5154,7 +5151,7 @@ class PerspectiveProxy {
|
|
|
5154
5151
|
* ```
|
|
5155
5152
|
*/
|
|
5156
5153
|
get ai() {
|
|
5157
|
-
return __classPrivateFieldGet$
|
|
5154
|
+
return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").aiClient;
|
|
5158
5155
|
}
|
|
5159
5156
|
/**
|
|
5160
5157
|
* Creates a subscription for a Prolog query that updates in real-time.
|
|
@@ -5196,7 +5193,7 @@ class PerspectiveProxy {
|
|
|
5196
5193
|
* ```
|
|
5197
5194
|
*/
|
|
5198
5195
|
async subscribeInfer(query) {
|
|
5199
|
-
const subscriptionProxy = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$
|
|
5196
|
+
const subscriptionProxy = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f"));
|
|
5200
5197
|
// Start the subscription on the Rust side first to get the real subscription ID
|
|
5201
5198
|
await subscriptionProxy.subscribe();
|
|
5202
5199
|
// Wait for the initial result
|
|
@@ -5224,7 +5221,7 @@ class PerspectiveProxy {
|
|
|
5224
5221
|
* @returns Initialized QuerySubscriptionProxy instance
|
|
5225
5222
|
*/
|
|
5226
5223
|
async subscribeQuery(query) {
|
|
5227
|
-
const subscriptionProxy = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$
|
|
5224
|
+
const subscriptionProxy = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f"));
|
|
5228
5225
|
// Start the subscription on the Rust side first to get the real subscription ID
|
|
5229
5226
|
await subscriptionProxy.subscribe();
|
|
5230
5227
|
// Wait for the initial result
|
|
@@ -5234,13 +5231,13 @@ class PerspectiveProxy {
|
|
|
5234
5231
|
}
|
|
5235
5232
|
_PerspectiveProxy_handle = new WeakMap(), _PerspectiveProxy_client = new WeakMap(), _PerspectiveProxy_perspectiveLinkAddedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveLinkRemovedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveLinkUpdatedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveSyncStateChangeCallbacks = new WeakMap(), _PerspectiveProxy_ensuredSubjectClasses = new WeakMap();
|
|
5236
5233
|
|
|
5237
|
-
var __classPrivateFieldSet$
|
|
5234
|
+
var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
5238
5235
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
5239
5236
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5240
5237
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5241
5238
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
5242
5239
|
};
|
|
5243
|
-
var __classPrivateFieldGet$
|
|
5240
|
+
var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
5244
5241
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
5245
5242
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5246
5243
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -5248,11 +5245,6 @@ var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) |
|
|
|
5248
5245
|
var _PerspectiveClient_apiClient, _PerspectiveClient_perspectiveAddedCallbacks, _PerspectiveClient_perspectiveUpdatedCallbacks, _PerspectiveClient_perspectiveRemovedCallbacks, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, _PerspectiveClient_expressionClient, _PerspectiveClient_neighbourhoodClient, _PerspectiveClient_aiClient, _PerspectiveClient_unsubscribers, _PerspectiveClient_linkUnsubscribers, _PerspectiveClient_querySubscriptionUnsubscribers;
|
|
5249
5246
|
function normalizeQueryResult(raw, errorContext) {
|
|
5250
5247
|
let finalResult = raw;
|
|
5251
|
-
let isInit = false;
|
|
5252
|
-
if (typeof finalResult === 'string' && finalResult.startsWith('#init#')) {
|
|
5253
|
-
finalResult = finalResult.substring(6);
|
|
5254
|
-
isInit = true;
|
|
5255
|
-
}
|
|
5256
5248
|
if (typeof finalResult === 'string') {
|
|
5257
5249
|
try {
|
|
5258
5250
|
finalResult = JSON.parse(finalResult);
|
|
@@ -5261,10 +5253,7 @@ function normalizeQueryResult(raw, errorContext) {
|
|
|
5261
5253
|
console.error(errorContext, e);
|
|
5262
5254
|
}
|
|
5263
5255
|
}
|
|
5264
|
-
|
|
5265
|
-
finalResult.isInit = true;
|
|
5266
|
-
}
|
|
5267
|
-
return { result: finalResult, isInit };
|
|
5256
|
+
return finalResult;
|
|
5268
5257
|
}
|
|
5269
5258
|
class PerspectiveClient {
|
|
5270
5259
|
constructor(baseUrl, token, subscribe = true, sharedApiClient) {
|
|
@@ -5279,14 +5268,14 @@ class PerspectiveClient {
|
|
|
5279
5268
|
_PerspectiveClient_unsubscribers.set(this, void 0);
|
|
5280
5269
|
_PerspectiveClient_linkUnsubscribers.set(this, void 0);
|
|
5281
5270
|
_PerspectiveClient_querySubscriptionUnsubscribers.set(this, void 0);
|
|
5282
|
-
__classPrivateFieldSet$
|
|
5283
|
-
__classPrivateFieldSet$
|
|
5284
|
-
__classPrivateFieldSet$
|
|
5285
|
-
__classPrivateFieldSet$
|
|
5286
|
-
__classPrivateFieldSet$
|
|
5287
|
-
__classPrivateFieldSet$
|
|
5288
|
-
__classPrivateFieldSet$
|
|
5289
|
-
__classPrivateFieldSet$
|
|
5271
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
5272
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_perspectiveAddedCallbacks, [], "f");
|
|
5273
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_perspectiveUpdatedCallbacks, [], "f");
|
|
5274
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_perspectiveRemovedCallbacks, [], "f");
|
|
5275
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, [], "f");
|
|
5276
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_unsubscribers, [], "f");
|
|
5277
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_linkUnsubscribers, new Map(), "f");
|
|
5278
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_querySubscriptionUnsubscribers, new Map(), "f");
|
|
5290
5279
|
if (subscribe) {
|
|
5291
5280
|
this.subscribePerspectiveAdded();
|
|
5292
5281
|
this.subscribePerspectiveUpdated();
|
|
@@ -5294,24 +5283,24 @@ class PerspectiveClient {
|
|
|
5294
5283
|
}
|
|
5295
5284
|
}
|
|
5296
5285
|
setExpressionClient(client) {
|
|
5297
|
-
__classPrivateFieldSet$
|
|
5286
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_expressionClient, client, "f");
|
|
5298
5287
|
}
|
|
5299
5288
|
setNeighbourhoodClient(client) {
|
|
5300
|
-
__classPrivateFieldSet$
|
|
5289
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_neighbourhoodClient, client, "f");
|
|
5301
5290
|
}
|
|
5302
5291
|
setAIClient(client) {
|
|
5303
|
-
__classPrivateFieldSet$
|
|
5292
|
+
__classPrivateFieldSet$9(this, _PerspectiveClient_aiClient, client, "f");
|
|
5304
5293
|
}
|
|
5305
5294
|
get aiClient() {
|
|
5306
|
-
return __classPrivateFieldGet$
|
|
5295
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_aiClient, "f");
|
|
5307
5296
|
}
|
|
5308
5297
|
async all() {
|
|
5309
|
-
const perspectives = await __classPrivateFieldGet$
|
|
5298
|
+
const perspectives = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.all');
|
|
5310
5299
|
return perspectives.map(handle => new PerspectiveProxy(handle, this));
|
|
5311
5300
|
}
|
|
5312
5301
|
async byUUID(uuid) {
|
|
5313
5302
|
try {
|
|
5314
|
-
const perspective = await __classPrivateFieldGet$
|
|
5303
|
+
const perspective = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.get', { uuid });
|
|
5315
5304
|
if (!perspective)
|
|
5316
5305
|
return null;
|
|
5317
5306
|
return new PerspectiveProxy(perspective, this);
|
|
@@ -5323,10 +5312,10 @@ class PerspectiveClient {
|
|
|
5323
5312
|
}
|
|
5324
5313
|
}
|
|
5325
5314
|
async snapshotByUUID(uuid) {
|
|
5326
|
-
return __classPrivateFieldGet$
|
|
5315
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.snapshot', { uuid });
|
|
5327
5316
|
}
|
|
5328
5317
|
async publishSnapshotByUUID(uuid) {
|
|
5329
|
-
return __classPrivateFieldGet$
|
|
5318
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.publishSnapshot', { uuid });
|
|
5330
5319
|
}
|
|
5331
5320
|
async queryLinks(uuid, query) {
|
|
5332
5321
|
const params = { uuid };
|
|
@@ -5342,59 +5331,59 @@ class PerspectiveClient {
|
|
|
5342
5331
|
params.untilDate = query.untilDate instanceof Date ? query.untilDate.toISOString() : String(query.untilDate);
|
|
5343
5332
|
if (query.limit !== undefined)
|
|
5344
5333
|
params.limit = query.limit;
|
|
5345
|
-
return __classPrivateFieldGet$
|
|
5334
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.queryLinks', params);
|
|
5346
5335
|
}
|
|
5347
5336
|
async queryProlog(uuid, query) {
|
|
5348
|
-
const result = await __classPrivateFieldGet$
|
|
5337
|
+
const result = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.queryProlog', { uuid, query });
|
|
5349
5338
|
return JSON.parse(result);
|
|
5350
5339
|
}
|
|
5351
5340
|
async querySparql(uuid, query) {
|
|
5352
|
-
const result = await __classPrivateFieldGet$
|
|
5341
|
+
const result = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.querySparql', { uuid, engine: 'sparql', query });
|
|
5353
5342
|
return JSON.parse(result);
|
|
5354
5343
|
}
|
|
5355
5344
|
async subscribeQuery(uuid, query) {
|
|
5356
|
-
const response = await __classPrivateFieldGet$
|
|
5345
|
+
const response = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.subscribeQuery', { uuid, query });
|
|
5357
5346
|
const { subscriptionId, result } = response;
|
|
5358
|
-
const
|
|
5359
|
-
return { subscriptionId, result:
|
|
5347
|
+
const parsed = normalizeQueryResult(result, 'Error parsing subscribeQuery result:');
|
|
5348
|
+
return { subscriptionId, result: parsed };
|
|
5360
5349
|
}
|
|
5361
5350
|
async perspectiveKeepAliveQuery(uuid, subscriptionId) {
|
|
5362
|
-
return __classPrivateFieldGet$
|
|
5351
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.keepAliveQuery', { uuid, subscriptionId });
|
|
5363
5352
|
}
|
|
5364
5353
|
async perspectiveDisposeQuerySubscription(uuid, subscriptionId) {
|
|
5365
|
-
return __classPrivateFieldGet$
|
|
5354
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
|
|
5366
5355
|
}
|
|
5367
5356
|
subscribeToQueryUpdates(subscriptionId, onData) {
|
|
5368
|
-
const unsub = __classPrivateFieldGet$
|
|
5357
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5369
5358
|
const event = data;
|
|
5370
5359
|
if (event.type !== 'query-subscription-update')
|
|
5371
5360
|
return;
|
|
5372
5361
|
const eventSubscriptionId = event.subscriptionId || event.subscription_id;
|
|
5373
5362
|
if (eventSubscriptionId !== subscriptionId)
|
|
5374
5363
|
return;
|
|
5375
|
-
const
|
|
5376
|
-
onData(
|
|
5364
|
+
const parsed = normalizeQueryResult(event.result, 'Error parsing query subscription:');
|
|
5365
|
+
onData(parsed);
|
|
5377
5366
|
});
|
|
5378
|
-
__classPrivateFieldGet$
|
|
5367
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").set(subscriptionId, unsub);
|
|
5379
5368
|
return unsub;
|
|
5380
5369
|
}
|
|
5381
5370
|
async keepAliveQuery(uuid, subscriptionId) {
|
|
5382
|
-
return __classPrivateFieldGet$
|
|
5371
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.keepAliveQuery', { uuid, subscriptionId });
|
|
5383
5372
|
}
|
|
5384
5373
|
async disposeQuerySubscription(uuid, subscriptionId) {
|
|
5385
|
-
const unsub = __classPrivateFieldGet$
|
|
5374
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").get(subscriptionId);
|
|
5386
5375
|
if (unsub) {
|
|
5387
5376
|
unsub();
|
|
5388
|
-
__classPrivateFieldGet$
|
|
5377
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").delete(subscriptionId);
|
|
5389
5378
|
}
|
|
5390
|
-
return __classPrivateFieldGet$
|
|
5379
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
|
|
5391
5380
|
}
|
|
5392
5381
|
async modelQuery(uuid, className, queryJson, shapeJson) {
|
|
5393
|
-
const resultJson = await __classPrivateFieldGet$
|
|
5382
|
+
const resultJson = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.modelQuery', { uuid, class_name: className, query_json: queryJson, shape_json: shapeJson });
|
|
5394
5383
|
return JSON.parse(resultJson);
|
|
5395
5384
|
}
|
|
5396
5385
|
async evaluateGetters(uuid, className, instanceIds, shapeJson, propertyNames) {
|
|
5397
|
-
const resultJson = await __classPrivateFieldGet$
|
|
5386
|
+
const resultJson = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.evaluateGetters', {
|
|
5398
5387
|
uuid,
|
|
5399
5388
|
class_name: className,
|
|
5400
5389
|
instance_ids: instanceIds,
|
|
@@ -5404,127 +5393,127 @@ class PerspectiveClient {
|
|
|
5404
5393
|
return JSON.parse(resultJson);
|
|
5405
5394
|
}
|
|
5406
5395
|
async modelSubscribe(uuid, className, queryJson, shapeJson) {
|
|
5407
|
-
const response = await __classPrivateFieldGet$
|
|
5396
|
+
const response = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.modelSubscribe', { uuid, class_name: className, query_json: queryJson, shape_json: shapeJson });
|
|
5408
5397
|
return {
|
|
5409
5398
|
subscriptionId: response.subscription_id,
|
|
5410
5399
|
result: JSON.parse(response.result)
|
|
5411
5400
|
};
|
|
5412
5401
|
}
|
|
5413
5402
|
async add(name) {
|
|
5414
|
-
const handle = await __classPrivateFieldGet$
|
|
5403
|
+
const handle = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.create', { name });
|
|
5415
5404
|
return new PerspectiveProxy(handle, this);
|
|
5416
5405
|
}
|
|
5417
5406
|
async update(uuid, name) {
|
|
5418
|
-
const handle = await __classPrivateFieldGet$
|
|
5407
|
+
const handle = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.update', { uuid, name });
|
|
5419
5408
|
return new PerspectiveProxy(handle, this);
|
|
5420
5409
|
}
|
|
5421
5410
|
async remove(uuid) {
|
|
5422
|
-
const result = await __classPrivateFieldGet$
|
|
5411
|
+
const result = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.remove', { uuid });
|
|
5423
5412
|
return { perspectiveRemove: result };
|
|
5424
5413
|
}
|
|
5425
5414
|
async addLink(uuid, link, status = 'shared', batchId) {
|
|
5426
|
-
return __classPrivateFieldGet$
|
|
5415
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLink', { uuid, link, status, batchId });
|
|
5427
5416
|
}
|
|
5428
5417
|
async addLinks(uuid, links, status = 'shared', batchId) {
|
|
5429
|
-
return __classPrivateFieldGet$
|
|
5418
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status, batchId });
|
|
5430
5419
|
}
|
|
5431
5420
|
async removeLinks(uuid, links, batchId) {
|
|
5432
|
-
return __classPrivateFieldGet$
|
|
5421
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLinks', { uuid, links, batchId });
|
|
5433
5422
|
}
|
|
5434
5423
|
async linkMutations(uuid, mutations, status) {
|
|
5435
|
-
return __classPrivateFieldGet$
|
|
5424
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations, status });
|
|
5436
5425
|
}
|
|
5437
5426
|
async addLinkExpression(uuid, link, status = 'shared', batchId) {
|
|
5438
|
-
return __classPrivateFieldGet$
|
|
5427
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link, status, batchId });
|
|
5439
5428
|
}
|
|
5440
5429
|
async updateLink(uuid, oldLink, newLink, batchId) {
|
|
5441
|
-
return __classPrivateFieldGet$
|
|
5430
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.updateLink', { uuid, oldLink, newLink, batchId });
|
|
5442
5431
|
}
|
|
5443
5432
|
async removeLink(uuid, link, batchId) {
|
|
5444
5433
|
delete link.__typename;
|
|
5445
5434
|
delete link.data.__typename;
|
|
5446
5435
|
delete link.proof.__typename;
|
|
5447
5436
|
delete link.status;
|
|
5448
|
-
return __classPrivateFieldGet$
|
|
5437
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLink', { uuid, link, batchId });
|
|
5449
5438
|
}
|
|
5450
5439
|
async addSdna(uuid, name, sdnaCode, sdnaType, shaclJson) {
|
|
5451
|
-
return __classPrivateFieldGet$
|
|
5440
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson });
|
|
5452
5441
|
}
|
|
5453
5442
|
async executeCommands(uuid, commands, expression, parameters, batchId) {
|
|
5454
|
-
return __classPrivateFieldGet$
|
|
5443
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.executeCommands', { uuid, commands, expression, parameters, batchId });
|
|
5455
5444
|
}
|
|
5456
5445
|
async createSubject(uuid, subjectClass, expressionAddress, initialValues, batchId) {
|
|
5457
|
-
return __classPrivateFieldGet$
|
|
5446
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.createSubject', { uuid, subjectClass, expressionAddress, initialValues, batchId });
|
|
5458
5447
|
}
|
|
5459
5448
|
async getSubjectData(uuid, subjectClass, expressionAddress) {
|
|
5460
|
-
return __classPrivateFieldGet$
|
|
5449
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.getSubjectData', { uuid, subjectClass, expressionAddress });
|
|
5461
5450
|
}
|
|
5462
5451
|
// ExpressionClient functions, needed for Subjects:
|
|
5463
5452
|
async getExpression(expressionURI) {
|
|
5464
|
-
return await __classPrivateFieldGet$
|
|
5453
|
+
return await __classPrivateFieldGet$9(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
|
|
5465
5454
|
}
|
|
5466
5455
|
async createExpression(content, languageAddress) {
|
|
5467
|
-
return await __classPrivateFieldGet$
|
|
5456
|
+
return await __classPrivateFieldGet$9(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
|
|
5468
5457
|
}
|
|
5469
5458
|
// Subscriptions:
|
|
5470
5459
|
addPerspectiveAddedListener(cb) {
|
|
5471
|
-
__classPrivateFieldGet$
|
|
5460
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").push(cb);
|
|
5472
5461
|
}
|
|
5473
5462
|
subscribePerspectiveAdded() {
|
|
5474
|
-
const unsub = __classPrivateFieldGet$
|
|
5463
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5475
5464
|
if (data.type === 'perspective-added') {
|
|
5476
|
-
__classPrivateFieldGet$
|
|
5465
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").forEach(cb => cb(data.perspective));
|
|
5477
5466
|
}
|
|
5478
5467
|
});
|
|
5479
|
-
__classPrivateFieldGet$
|
|
5468
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
|
|
5480
5469
|
}
|
|
5481
5470
|
addPerspectiveUpdatedListener(cb) {
|
|
5482
|
-
__classPrivateFieldGet$
|
|
5471
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").push(cb);
|
|
5483
5472
|
}
|
|
5484
5473
|
subscribePerspectiveUpdated() {
|
|
5485
|
-
const unsub = __classPrivateFieldGet$
|
|
5474
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5486
5475
|
if (data.type === 'perspective-updated') {
|
|
5487
|
-
__classPrivateFieldGet$
|
|
5476
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").forEach(cb => cb(data.perspective));
|
|
5488
5477
|
}
|
|
5489
5478
|
});
|
|
5490
|
-
__classPrivateFieldGet$
|
|
5479
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
|
|
5491
5480
|
}
|
|
5492
5481
|
addPerspectiveSyncedListener(cb) {
|
|
5493
|
-
__classPrivateFieldGet$
|
|
5482
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, "f").push(cb);
|
|
5494
5483
|
}
|
|
5495
5484
|
async addPerspectiveSyncStateChangeListener(uuid, cb) {
|
|
5496
|
-
const unsub = __classPrivateFieldGet$
|
|
5485
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5497
5486
|
if (data.type === 'sync-state-change' && data.uuid === uuid) {
|
|
5498
5487
|
cb.forEach(c => c(data.state));
|
|
5499
5488
|
}
|
|
5500
5489
|
});
|
|
5501
|
-
__classPrivateFieldGet$
|
|
5490
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
|
|
5502
5491
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
5503
5492
|
}
|
|
5504
5493
|
addPerspectiveRemovedListener(cb) {
|
|
5505
|
-
__classPrivateFieldGet$
|
|
5494
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").push(cb);
|
|
5506
5495
|
}
|
|
5507
5496
|
subscribePerspectiveRemoved() {
|
|
5508
|
-
const unsub = __classPrivateFieldGet$
|
|
5497
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5509
5498
|
if (data.type === 'perspective-removed') {
|
|
5510
|
-
__classPrivateFieldGet$
|
|
5499
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").forEach(cb => cb(data.uuid));
|
|
5511
5500
|
}
|
|
5512
5501
|
});
|
|
5513
|
-
__classPrivateFieldGet$
|
|
5502
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
|
|
5514
5503
|
}
|
|
5515
5504
|
async addPerspectiveLinkAddedListener(uuid, cb) {
|
|
5516
|
-
const unsub = __classPrivateFieldGet$
|
|
5505
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5517
5506
|
if (data.type === 'link-added' && data.perspectiveUuid === uuid) {
|
|
5518
5507
|
cb.forEach(c => c(data.link));
|
|
5519
5508
|
}
|
|
5520
5509
|
});
|
|
5521
|
-
let existing = __classPrivateFieldGet$
|
|
5510
|
+
let existing = __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
|
|
5522
5511
|
existing.push(unsub);
|
|
5523
|
-
__classPrivateFieldGet$
|
|
5524
|
-
await __classPrivateFieldGet$
|
|
5512
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
|
|
5513
|
+
await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
|
|
5525
5514
|
}
|
|
5526
5515
|
async addPerspectiveLinkRemovedListener(uuid, cb) {
|
|
5527
|
-
const unsub = __classPrivateFieldGet$
|
|
5516
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5528
5517
|
if (data.type === 'link-removed' && data.perspectiveUuid === uuid) {
|
|
5529
5518
|
const link = data.link;
|
|
5530
5519
|
if (!link.status) {
|
|
@@ -5533,13 +5522,13 @@ class PerspectiveClient {
|
|
|
5533
5522
|
cb.forEach(c => c(link));
|
|
5534
5523
|
}
|
|
5535
5524
|
});
|
|
5536
|
-
let existing = __classPrivateFieldGet$
|
|
5525
|
+
let existing = __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
|
|
5537
5526
|
existing.push(unsub);
|
|
5538
|
-
__classPrivateFieldGet$
|
|
5539
|
-
await __classPrivateFieldGet$
|
|
5527
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
|
|
5528
|
+
await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
|
|
5540
5529
|
}
|
|
5541
5530
|
async addPerspectiveLinkUpdatedListener(uuid, cb) {
|
|
5542
|
-
const unsub = __classPrivateFieldGet$
|
|
5531
|
+
const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
|
|
5543
5532
|
if (data.type === 'link-updated' && data.perspectiveUuid === uuid) {
|
|
5544
5533
|
const newLink = data.newLink;
|
|
5545
5534
|
const oldLink = data.oldLink;
|
|
@@ -5552,23 +5541,163 @@ class PerspectiveClient {
|
|
|
5552
5541
|
cb.forEach(c => c(data));
|
|
5553
5542
|
}
|
|
5554
5543
|
});
|
|
5555
|
-
let existing = __classPrivateFieldGet$
|
|
5544
|
+
let existing = __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
|
|
5556
5545
|
existing.push(unsub);
|
|
5557
|
-
__classPrivateFieldGet$
|
|
5558
|
-
await __classPrivateFieldGet$
|
|
5546
|
+
__classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
|
|
5547
|
+
await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
|
|
5559
5548
|
}
|
|
5560
5549
|
getNeighbourhoodProxy(uuid) {
|
|
5561
|
-
return new NeighbourhoodProxy(__classPrivateFieldGet$
|
|
5550
|
+
return new NeighbourhoodProxy(__classPrivateFieldGet$9(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
|
|
5562
5551
|
}
|
|
5563
5552
|
async createBatch(uuid) {
|
|
5564
|
-
return __classPrivateFieldGet$
|
|
5553
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.createBatch', { uuid });
|
|
5565
5554
|
}
|
|
5566
5555
|
async commitBatch(uuid, batchId) {
|
|
5567
|
-
return __classPrivateFieldGet$
|
|
5556
|
+
return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.commitBatch', { uuid, batchId });
|
|
5568
5557
|
}
|
|
5569
5558
|
}
|
|
5570
5559
|
_PerspectiveClient_apiClient = new WeakMap(), _PerspectiveClient_perspectiveAddedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveUpdatedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveRemovedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveSyncStateChangeCallbacks = new WeakMap(), _PerspectiveClient_expressionClient = new WeakMap(), _PerspectiveClient_neighbourhoodClient = new WeakMap(), _PerspectiveClient_aiClient = new WeakMap(), _PerspectiveClient_unsubscribers = new WeakMap(), _PerspectiveClient_linkUnsubscribers = new WeakMap(), _PerspectiveClient_querySubscriptionUnsubscribers = new WeakMap();
|
|
5571
5560
|
|
|
5561
|
+
/**
|
|
5562
|
+
* PersistentCache — two-tier persistent key-value cache abstraction.
|
|
5563
|
+
*
|
|
5564
|
+
* Provides an IndexedDB-backed implementation for browsers and a no-op
|
|
5565
|
+
* NullCache fallback for Node.js / environments without IndexedDB.
|
|
5566
|
+
*
|
|
5567
|
+
* Design goals:
|
|
5568
|
+
* - Lazy open: IDB connection is deferred until first access
|
|
5569
|
+
* - Fire-and-forget writes: put() resolves immediately (best-effort persistence)
|
|
5570
|
+
* - Graceful degradation: all IDB errors resolve (never reject), so callers
|
|
5571
|
+
* never need try/catch around cache operations
|
|
5572
|
+
* - Tree-shakeable: import only what you need
|
|
5573
|
+
*/
|
|
5574
|
+
var __classPrivateFieldSet$8 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
5575
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
5576
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5577
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5578
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
5579
|
+
};
|
|
5580
|
+
var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
5581
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
5582
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5583
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5584
|
+
};
|
|
5585
|
+
var _IDBCache_instances, _IDBCache_dbName, _IDBCache_storeName, _IDBCache_dbPromise, _IDBCache_version, _IDBCache_open;
|
|
5586
|
+
// ── IndexedDB Implementation ─────────────────────────────────────────
|
|
5587
|
+
class IDBCache {
|
|
5588
|
+
constructor(dbName, storeName) {
|
|
5589
|
+
_IDBCache_instances.add(this);
|
|
5590
|
+
_IDBCache_dbName.set(this, void 0);
|
|
5591
|
+
_IDBCache_storeName.set(this, void 0);
|
|
5592
|
+
_IDBCache_dbPromise.set(this, null);
|
|
5593
|
+
_IDBCache_version.set(this, 1);
|
|
5594
|
+
__classPrivateFieldSet$8(this, _IDBCache_dbName, dbName, "f");
|
|
5595
|
+
__classPrivateFieldSet$8(this, _IDBCache_storeName, storeName, "f");
|
|
5596
|
+
}
|
|
5597
|
+
async get(key) {
|
|
5598
|
+
try {
|
|
5599
|
+
const db = await __classPrivateFieldGet$8(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
|
|
5600
|
+
return new Promise((resolve) => {
|
|
5601
|
+
const tx = db.transaction(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"), 'readonly');
|
|
5602
|
+
const store = tx.objectStore(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"));
|
|
5603
|
+
const req = store.get(key);
|
|
5604
|
+
req.onsuccess = () => resolve(req.result ?? undefined);
|
|
5605
|
+
req.onerror = () => resolve(undefined);
|
|
5606
|
+
});
|
|
5607
|
+
}
|
|
5608
|
+
catch {
|
|
5609
|
+
return undefined;
|
|
5610
|
+
}
|
|
5611
|
+
}
|
|
5612
|
+
async put(key, value) {
|
|
5613
|
+
try {
|
|
5614
|
+
const db = await __classPrivateFieldGet$8(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
|
|
5615
|
+
return new Promise((resolve) => {
|
|
5616
|
+
const tx = db.transaction(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"), 'readwrite');
|
|
5617
|
+
const store = tx.objectStore(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"));
|
|
5618
|
+
store.put(value, key);
|
|
5619
|
+
tx.oncomplete = () => resolve();
|
|
5620
|
+
tx.onerror = () => resolve(); // fire-and-forget
|
|
5621
|
+
});
|
|
5622
|
+
}
|
|
5623
|
+
catch {
|
|
5624
|
+
// degrade gracefully
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
async delete(key) {
|
|
5628
|
+
try {
|
|
5629
|
+
const db = await __classPrivateFieldGet$8(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
|
|
5630
|
+
return new Promise((resolve) => {
|
|
5631
|
+
const tx = db.transaction(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"), 'readwrite');
|
|
5632
|
+
const store = tx.objectStore(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"));
|
|
5633
|
+
store.delete(key);
|
|
5634
|
+
tx.oncomplete = () => resolve();
|
|
5635
|
+
tx.onerror = () => resolve();
|
|
5636
|
+
});
|
|
5637
|
+
}
|
|
5638
|
+
catch {
|
|
5639
|
+
// degrade gracefully
|
|
5640
|
+
}
|
|
5641
|
+
}
|
|
5642
|
+
async clear() {
|
|
5643
|
+
try {
|
|
5644
|
+
const db = await __classPrivateFieldGet$8(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
|
|
5645
|
+
return new Promise((resolve) => {
|
|
5646
|
+
const tx = db.transaction(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"), 'readwrite');
|
|
5647
|
+
const store = tx.objectStore(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"));
|
|
5648
|
+
store.clear();
|
|
5649
|
+
tx.oncomplete = () => resolve();
|
|
5650
|
+
tx.onerror = () => resolve();
|
|
5651
|
+
});
|
|
5652
|
+
}
|
|
5653
|
+
catch {
|
|
5654
|
+
// degrade gracefully
|
|
5655
|
+
}
|
|
5656
|
+
}
|
|
5657
|
+
}
|
|
5658
|
+
_IDBCache_dbName = new WeakMap(), _IDBCache_storeName = new WeakMap(), _IDBCache_dbPromise = new WeakMap(), _IDBCache_version = new WeakMap(), _IDBCache_instances = new WeakSet(), _IDBCache_open = function _IDBCache_open() {
|
|
5659
|
+
if (!__classPrivateFieldGet$8(this, _IDBCache_dbPromise, "f")) {
|
|
5660
|
+
__classPrivateFieldSet$8(this, _IDBCache_dbPromise, new Promise((resolve, reject) => {
|
|
5661
|
+
const storeName = __classPrivateFieldGet$8(this, _IDBCache_storeName, "f");
|
|
5662
|
+
const req = indexedDB.open(__classPrivateFieldGet$8(this, _IDBCache_dbName, "f"), __classPrivateFieldGet$8(this, _IDBCache_version, "f"));
|
|
5663
|
+
req.onupgradeneeded = () => {
|
|
5664
|
+
const db = req.result;
|
|
5665
|
+
if (!db.objectStoreNames.contains(storeName)) {
|
|
5666
|
+
db.createObjectStore(storeName);
|
|
5667
|
+
}
|
|
5668
|
+
};
|
|
5669
|
+
req.onsuccess = () => resolve(req.result);
|
|
5670
|
+
req.onerror = () => reject(req.error);
|
|
5671
|
+
}), "f");
|
|
5672
|
+
}
|
|
5673
|
+
return __classPrivateFieldGet$8(this, _IDBCache_dbPromise, "f");
|
|
5674
|
+
};
|
|
5675
|
+
// ── NullCache (no-op fallback for Node.js) ───────────────────────────
|
|
5676
|
+
class NullCache {
|
|
5677
|
+
async get(_key) { return undefined; }
|
|
5678
|
+
async put(_key, _value) { }
|
|
5679
|
+
async delete(_key) { }
|
|
5680
|
+
async clear() { }
|
|
5681
|
+
}
|
|
5682
|
+
// ── Factory ──────────────────────────────────────────────────────────
|
|
5683
|
+
/**
|
|
5684
|
+
* Create a PersistentCache backed by IndexedDB (browser) or NullCache (Node.js).
|
|
5685
|
+
*
|
|
5686
|
+
* @param dbName - IndexedDB database name
|
|
5687
|
+
* @param storeName - IndexedDB object store name
|
|
5688
|
+
*/
|
|
5689
|
+
function createPersistentCache(dbName, storeName) {
|
|
5690
|
+
try {
|
|
5691
|
+
if (typeof indexedDB !== 'undefined') {
|
|
5692
|
+
return new IDBCache(dbName, storeName);
|
|
5693
|
+
}
|
|
5694
|
+
}
|
|
5695
|
+
catch {
|
|
5696
|
+
// indexedDB access threw (e.g. in a worker with restricted globals)
|
|
5697
|
+
}
|
|
5698
|
+
return new NullCache();
|
|
5699
|
+
}
|
|
5700
|
+
|
|
5572
5701
|
var __classPrivateFieldSet$7 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
5573
5702
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
5574
5703
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -5580,7 +5709,7 @@ var __classPrivateFieldGet$7 = (undefined && undefined.__classPrivateFieldGet) |
|
|
|
5580
5709
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5581
5710
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5582
5711
|
};
|
|
5583
|
-
var _AgentClient_apiClient, _AgentClient_baseUrl, _AgentClient_token, _AgentClient_appsChangedCallback, _AgentClient_updatedCallbacks, _AgentClient_agentStatusChangedCallbacks, _AgentClient_hostingUserInfoChangedCallbacks, _AgentClient_computeLogUpdatedCallbacks, _AgentClient_unsubscribers;
|
|
5712
|
+
var _AgentClient_apiClient, _AgentClient_baseUrl, _AgentClient_token, _AgentClient_appsChangedCallback, _AgentClient_updatedCallbacks, _AgentClient_agentStatusChangedCallbacks, _AgentClient_hostingUserInfoChangedCallbacks, _AgentClient_computeLogUpdatedCallbacks, _AgentClient_unsubscribers, _AgentClient_memCache, _AgentClient_persistent, _AgentClient_selfDid;
|
|
5584
5713
|
class AgentClient {
|
|
5585
5714
|
constructor(baseUrl, token, subscribe = true, sharedApiClient) {
|
|
5586
5715
|
_AgentClient_apiClient.set(this, void 0);
|
|
@@ -5592,6 +5721,13 @@ class AgentClient {
|
|
|
5592
5721
|
_AgentClient_hostingUserInfoChangedCallbacks.set(this, void 0);
|
|
5593
5722
|
_AgentClient_computeLogUpdatedCallbacks.set(this, void 0);
|
|
5594
5723
|
_AgentClient_unsubscribers.set(this, void 0);
|
|
5724
|
+
// ── byDID cache ────────────────────────────────────────────────────
|
|
5725
|
+
// L1: in-memory promise cache with timestamps for TTL
|
|
5726
|
+
_AgentClient_memCache.set(this, new Map());
|
|
5727
|
+
// L2: persistent cache (IndexedDB in browser, NullCache in Node)
|
|
5728
|
+
_AgentClient_persistent.set(this, void 0);
|
|
5729
|
+
// Self-DID for event-driven invalidation (no TTL for own profile)
|
|
5730
|
+
_AgentClient_selfDid.set(this, null);
|
|
5595
5731
|
__classPrivateFieldSet$7(this, _AgentClient_baseUrl, baseUrl, "f");
|
|
5596
5732
|
__classPrivateFieldSet$7(this, _AgentClient_token, token, "f");
|
|
5597
5733
|
__classPrivateFieldSet$7(this, _AgentClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
@@ -5601,6 +5737,7 @@ class AgentClient {
|
|
|
5601
5737
|
__classPrivateFieldSet$7(this, _AgentClient_hostingUserInfoChangedCallbacks, [], "f");
|
|
5602
5738
|
__classPrivateFieldSet$7(this, _AgentClient_computeLogUpdatedCallbacks, [], "f");
|
|
5603
5739
|
__classPrivateFieldSet$7(this, _AgentClient_unsubscribers, [], "f");
|
|
5740
|
+
__classPrivateFieldSet$7(this, _AgentClient_persistent, createPersistentCache('ad4m-agent-cache', 'agents'), "f");
|
|
5604
5741
|
if (subscribe) {
|
|
5605
5742
|
this.subscribeAgentUpdated();
|
|
5606
5743
|
this.subscribeAgentStatusChanged();
|
|
@@ -5634,7 +5771,57 @@ class AgentClient {
|
|
|
5634
5771
|
return new AgentStatus(result);
|
|
5635
5772
|
}
|
|
5636
5773
|
async byDID(did) {
|
|
5637
|
-
|
|
5774
|
+
const now = Date.now();
|
|
5775
|
+
const cached = __classPrivateFieldGet$7(this, _AgentClient_memCache, "f").get(did);
|
|
5776
|
+
if (cached) {
|
|
5777
|
+
const isSelf = did === __classPrivateFieldGet$7(this, _AgentClient_selfDid, "f");
|
|
5778
|
+
// Self-DID: L1 always valid (event-driven invalidation)
|
|
5779
|
+
// Remote DID: L1 valid within TTL
|
|
5780
|
+
if (isSelf || (now - cached.ts) < AgentClient.REMOTE_AGENT_TTL_MS) {
|
|
5781
|
+
return cached.promise;
|
|
5782
|
+
}
|
|
5783
|
+
}
|
|
5784
|
+
// Deduplicate: store the promise immediately so concurrent calls share one RPC
|
|
5785
|
+
const promise = (async () => {
|
|
5786
|
+
// L2: check persistent cache before network
|
|
5787
|
+
const persisted = await __classPrivateFieldGet$7(this, _AgentClient_persistent, "f").get(did);
|
|
5788
|
+
if (persisted) {
|
|
5789
|
+
return persisted;
|
|
5790
|
+
}
|
|
5791
|
+
// L3: network fetch
|
|
5792
|
+
const result = await __classPrivateFieldGet$7(this, _AgentClient_apiClient, "f").call('agent.byDid', { did });
|
|
5793
|
+
__classPrivateFieldGet$7(this, _AgentClient_persistent, "f").put(did, result); // fire-and-forget write to L2
|
|
5794
|
+
return result;
|
|
5795
|
+
})();
|
|
5796
|
+
__classPrivateFieldGet$7(this, _AgentClient_memCache, "f").set(did, { promise, ts: now });
|
|
5797
|
+
// Clean up on failure so next call retries
|
|
5798
|
+
promise.catch(() => {
|
|
5799
|
+
if (__classPrivateFieldGet$7(this, _AgentClient_memCache, "f").get(did)?.promise === promise) {
|
|
5800
|
+
__classPrivateFieldGet$7(this, _AgentClient_memCache, "f").delete(did);
|
|
5801
|
+
}
|
|
5802
|
+
});
|
|
5803
|
+
return promise;
|
|
5804
|
+
}
|
|
5805
|
+
/**
|
|
5806
|
+
* Set the current agent's own DID.
|
|
5807
|
+
* The self-DID receives event-driven invalidation and is never TTL-expired.
|
|
5808
|
+
*/
|
|
5809
|
+
setSelfDid(did) {
|
|
5810
|
+
__classPrivateFieldSet$7(this, _AgentClient_selfDid, did, "f");
|
|
5811
|
+
}
|
|
5812
|
+
/**
|
|
5813
|
+
* Invalidate a specific DID's cache entry in both L1 and L2.
|
|
5814
|
+
*/
|
|
5815
|
+
invalidateByDid(did) {
|
|
5816
|
+
__classPrivateFieldGet$7(this, _AgentClient_memCache, "f").delete(did);
|
|
5817
|
+
__classPrivateFieldGet$7(this, _AgentClient_persistent, "f").delete(did); // fire-and-forget
|
|
5818
|
+
}
|
|
5819
|
+
/**
|
|
5820
|
+
* Clear the entire L1 (memory) byDID cache.
|
|
5821
|
+
* L2 (IndexedDB) is preserved — agent data remains valid across sessions.
|
|
5822
|
+
*/
|
|
5823
|
+
clearByDidCache() {
|
|
5824
|
+
__classPrivateFieldGet$7(this, _AgentClient_memCache, "f").clear();
|
|
5638
5825
|
}
|
|
5639
5826
|
async updatePublicPerspective(perspective) {
|
|
5640
5827
|
const cleanedPerspective = JSON.parse(JSON.stringify(perspective));
|
|
@@ -5695,7 +5882,16 @@ class AgentClient {
|
|
|
5695
5882
|
subscribeAgentUpdated() {
|
|
5696
5883
|
const unsub = __classPrivateFieldGet$7(this, _AgentClient_apiClient, "f").subscribe((data) => {
|
|
5697
5884
|
if (data.type === 'agent-updated') {
|
|
5698
|
-
|
|
5885
|
+
const agent = (data.agent || data);
|
|
5886
|
+
// Update L1 and L2 cache from the event payload
|
|
5887
|
+
if (agent.did) {
|
|
5888
|
+
__classPrivateFieldGet$7(this, _AgentClient_memCache, "f").set(agent.did, {
|
|
5889
|
+
promise: Promise.resolve(agent),
|
|
5890
|
+
ts: Date.now(),
|
|
5891
|
+
});
|
|
5892
|
+
__classPrivateFieldGet$7(this, _AgentClient_persistent, "f").put(agent.did, agent); // fire-and-forget
|
|
5893
|
+
}
|
|
5894
|
+
__classPrivateFieldGet$7(this, _AgentClient_updatedCallbacks, "f").forEach((cb) => cb(agent));
|
|
5699
5895
|
}
|
|
5700
5896
|
});
|
|
5701
5897
|
__classPrivateFieldGet$7(this, _AgentClient_unsubscribers, "f").push(unsub);
|
|
@@ -5794,7 +5990,9 @@ class AgentClient {
|
|
|
5794
5990
|
return __classPrivateFieldGet$7(this, _AgentClient_apiClient, "f").call('hosting.requestPayment', { amountHOT });
|
|
5795
5991
|
}
|
|
5796
5992
|
}
|
|
5797
|
-
_AgentClient_apiClient = new WeakMap(), _AgentClient_baseUrl = new WeakMap(), _AgentClient_token = new WeakMap(), _AgentClient_appsChangedCallback = new WeakMap(), _AgentClient_updatedCallbacks = new WeakMap(), _AgentClient_agentStatusChangedCallbacks = new WeakMap(), _AgentClient_hostingUserInfoChangedCallbacks = new WeakMap(), _AgentClient_computeLogUpdatedCallbacks = new WeakMap(), _AgentClient_unsubscribers = new WeakMap();
|
|
5993
|
+
_AgentClient_apiClient = new WeakMap(), _AgentClient_baseUrl = new WeakMap(), _AgentClient_token = new WeakMap(), _AgentClient_appsChangedCallback = new WeakMap(), _AgentClient_updatedCallbacks = new WeakMap(), _AgentClient_agentStatusChangedCallbacks = new WeakMap(), _AgentClient_hostingUserInfoChangedCallbacks = new WeakMap(), _AgentClient_computeLogUpdatedCallbacks = new WeakMap(), _AgentClient_unsubscribers = new WeakMap(), _AgentClient_memCache = new WeakMap(), _AgentClient_persistent = new WeakMap(), _AgentClient_selfDid = new WeakMap();
|
|
5994
|
+
/** TTL for remote (non-self) agent profiles in L1 cache (ms). */
|
|
5995
|
+
AgentClient.REMOTE_AGENT_TTL_MS = 5 * 60000; // 5 minutes
|
|
5798
5996
|
|
|
5799
5997
|
var __classPrivateFieldSet$6 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
5800
5998
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
@@ -6223,13 +6421,22 @@ var __classPrivateFieldGet$3 = (undefined && undefined.__classPrivateFieldGet) |
|
|
|
6223
6421
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
6224
6422
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6225
6423
|
};
|
|
6226
|
-
var _ExpressionClient_apiClient;
|
|
6424
|
+
var _ExpressionClient_instances, _ExpressionClient_apiClient, _ExpressionClient_memCache, _ExpressionClient_inflight, _ExpressionClient_totalMemBytes, _ExpressionClient_persistent, _ExpressionClient_memCacheResult;
|
|
6227
6425
|
class ExpressionClient {
|
|
6228
6426
|
constructor(baseUrl, token, sharedApiClient) {
|
|
6427
|
+
_ExpressionClient_instances.add(this);
|
|
6229
6428
|
_ExpressionClient_apiClient.set(this, void 0);
|
|
6429
|
+
// L1: in-memory LRU cache (hot path, sub-ms)
|
|
6430
|
+
_ExpressionClient_memCache.set(this, new Map());
|
|
6431
|
+
_ExpressionClient_inflight.set(this, new Map());
|
|
6432
|
+
_ExpressionClient_totalMemBytes.set(this, 0);
|
|
6433
|
+
// L2: persistent cache (IndexedDB in browser, NullCache in Node)
|
|
6434
|
+
_ExpressionClient_persistent.set(this, void 0);
|
|
6230
6435
|
__classPrivateFieldSet$3(this, _ExpressionClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
6436
|
+
__classPrivateFieldSet$3(this, _ExpressionClient_persistent, createPersistentCache('ad4m-expression-cache', 'expressions'), "f");
|
|
6231
6437
|
}
|
|
6232
6438
|
async get(url, alwaysGet = false) {
|
|
6439
|
+
// Existing literal fast-path
|
|
6233
6440
|
if (!alwaysGet) {
|
|
6234
6441
|
try {
|
|
6235
6442
|
let literalValue = Literal.fromUrl(url).get();
|
|
@@ -6241,10 +6448,85 @@ class ExpressionClient {
|
|
|
6241
6448
|
}
|
|
6242
6449
|
catch (e) { }
|
|
6243
6450
|
}
|
|
6244
|
-
|
|
6451
|
+
// L1: memory hit
|
|
6452
|
+
if (!alwaysGet) {
|
|
6453
|
+
const memHit = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(url);
|
|
6454
|
+
if (memHit)
|
|
6455
|
+
return memHit.data;
|
|
6456
|
+
}
|
|
6457
|
+
// Deduplicate in-flight requests
|
|
6458
|
+
if (!alwaysGet) {
|
|
6459
|
+
const existing = __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").get(url);
|
|
6460
|
+
if (existing)
|
|
6461
|
+
return existing;
|
|
6462
|
+
}
|
|
6463
|
+
// L2 check + L3 network
|
|
6464
|
+
const promise = (async () => {
|
|
6465
|
+
if (!alwaysGet) {
|
|
6466
|
+
const persisted = await __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").get(url);
|
|
6467
|
+
if (persisted) {
|
|
6468
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, persisted); // promote to L1
|
|
6469
|
+
return persisted;
|
|
6470
|
+
}
|
|
6471
|
+
}
|
|
6472
|
+
// L3: network fetch
|
|
6473
|
+
const result = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.get', { url });
|
|
6474
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, result);
|
|
6475
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").put(url, result); // fire-and-forget write to L2
|
|
6476
|
+
return result;
|
|
6477
|
+
})();
|
|
6478
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").set(url, promise);
|
|
6479
|
+
try {
|
|
6480
|
+
return await promise;
|
|
6481
|
+
}
|
|
6482
|
+
finally {
|
|
6483
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").delete(url);
|
|
6484
|
+
}
|
|
6245
6485
|
}
|
|
6246
6486
|
async getMany(urls) {
|
|
6247
|
-
|
|
6487
|
+
// Check L1 first
|
|
6488
|
+
const results = urls.map(u => __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(u)?.data ?? null);
|
|
6489
|
+
let uncachedIndices = results
|
|
6490
|
+
.map((r, i) => r === null ? i : -1)
|
|
6491
|
+
.filter(i => i >= 0);
|
|
6492
|
+
if (uncachedIndices.length === 0)
|
|
6493
|
+
return results;
|
|
6494
|
+
// Check L2 for remaining misses
|
|
6495
|
+
const l2Results = await Promise.all(uncachedIndices.map(i => __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").get(urls[i])));
|
|
6496
|
+
const stillMissing = [];
|
|
6497
|
+
for (let j = 0; j < uncachedIndices.length; j++) {
|
|
6498
|
+
const idx = uncachedIndices[j];
|
|
6499
|
+
if (l2Results[j]) {
|
|
6500
|
+
results[idx] = l2Results[j];
|
|
6501
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, urls[idx], l2Results[j]); // promote to L1
|
|
6502
|
+
}
|
|
6503
|
+
else {
|
|
6504
|
+
stillMissing.push(idx);
|
|
6505
|
+
}
|
|
6506
|
+
}
|
|
6507
|
+
if (stillMissing.length === 0)
|
|
6508
|
+
return results;
|
|
6509
|
+
// L3: fetch only truly uncached URLs
|
|
6510
|
+
const uncachedUrls = stillMissing.map(i => urls[i]);
|
|
6511
|
+
const fetched = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.getMany', { urls: uncachedUrls });
|
|
6512
|
+
for (let i = 0; i < stillMissing.length; i++) {
|
|
6513
|
+
const idx = stillMissing[i];
|
|
6514
|
+
results[idx] = fetched[i];
|
|
6515
|
+
if (fetched[i]) {
|
|
6516
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, uncachedUrls[i], fetched[i]);
|
|
6517
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").put(uncachedUrls[i], fetched[i]); // fire-and-forget
|
|
6518
|
+
}
|
|
6519
|
+
}
|
|
6520
|
+
return results;
|
|
6521
|
+
}
|
|
6522
|
+
/**
|
|
6523
|
+
* Clear both L1 (memory) and L2 (persistent) expression caches.
|
|
6524
|
+
*/
|
|
6525
|
+
clearCache() {
|
|
6526
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").clear();
|
|
6527
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").clear();
|
|
6528
|
+
__classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, 0, "f");
|
|
6529
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").clear(); // fire-and-forget
|
|
6248
6530
|
}
|
|
6249
6531
|
async getRaw(url) {
|
|
6250
6532
|
return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.get', { url, raw: true });
|
|
@@ -6257,10 +6539,33 @@ class ExpressionClient {
|
|
|
6257
6539
|
return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.interactions', { url });
|
|
6258
6540
|
}
|
|
6259
6541
|
async interact(url, interactionCall) {
|
|
6260
|
-
|
|
6542
|
+
const result = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.interact', { url, interactionCall });
|
|
6543
|
+
// Interactions can mutate the expression — invalidate cache so next get() fetches fresh
|
|
6544
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").delete(url);
|
|
6545
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").delete(url);
|
|
6546
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").delete(url); // fire-and-forget
|
|
6547
|
+
return result;
|
|
6261
6548
|
}
|
|
6262
6549
|
}
|
|
6263
|
-
_ExpressionClient_apiClient = new WeakMap()
|
|
6550
|
+
_ExpressionClient_apiClient = new WeakMap(), _ExpressionClient_memCache = new WeakMap(), _ExpressionClient_inflight = new WeakMap(), _ExpressionClient_totalMemBytes = new WeakMap(), _ExpressionClient_persistent = new WeakMap(), _ExpressionClient_instances = new WeakSet(), _ExpressionClient_memCacheResult = function _ExpressionClient_memCacheResult(url, data) {
|
|
6551
|
+
const size = JSON.stringify(data).length;
|
|
6552
|
+
// Evict oldest entries if we'd exceed limits
|
|
6553
|
+
while (__classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").size >= ExpressionClient.MAX_MEM_ENTRIES ||
|
|
6554
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") + size > ExpressionClient.MAX_MEM_BYTES) {
|
|
6555
|
+
const oldest = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").keys().next().value;
|
|
6556
|
+
if (!oldest)
|
|
6557
|
+
break;
|
|
6558
|
+
const entry = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(oldest);
|
|
6559
|
+
__classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") - entry.size, "f");
|
|
6560
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").delete(oldest);
|
|
6561
|
+
}
|
|
6562
|
+
__classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").set(url, { data, size });
|
|
6563
|
+
__classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") + size, "f");
|
|
6564
|
+
};
|
|
6565
|
+
/** Maximum number of entries in the L1 memory cache. */
|
|
6566
|
+
ExpressionClient.MAX_MEM_ENTRIES = 200;
|
|
6567
|
+
/** Maximum total size (in bytes) of L1 memory cache values. */
|
|
6568
|
+
ExpressionClient.MAX_MEM_BYTES = 5 * 1024 * 1024; // 5 MB
|
|
6264
6569
|
|
|
6265
6570
|
var base64Js = {};
|
|
6266
6571
|
|
|
@@ -14625,8 +14930,14 @@ class ModelQueryBuilder {
|
|
|
14625
14930
|
const parseResults = (raw) => {
|
|
14626
14931
|
return ctor.parseModelResult(this.perspective, raw, this.queryParams.include, this.queryParams.properties);
|
|
14627
14932
|
};
|
|
14628
|
-
//
|
|
14629
|
-
|
|
14933
|
+
// Resolve non-literal (file-language) properties — handles both raw URI strings
|
|
14934
|
+
// and already-resolved FileData objects returned by the Rust executor.
|
|
14935
|
+
const resolveAndReturn = async (instances) => {
|
|
14936
|
+
await ctor.resolveNonLiteralProps(this.perspective, instances);
|
|
14937
|
+
return instances;
|
|
14938
|
+
};
|
|
14939
|
+
// Parse initial results (with non-literal resolution)
|
|
14940
|
+
const initialResults = await resolveAndReturn(parseResults(initialModelResult));
|
|
14630
14941
|
// Track last emitted result fingerprint to suppress duplicate callbacks
|
|
14631
14942
|
let lastResultFingerprint = null;
|
|
14632
14943
|
const buildFingerprint = (results) => {
|
|
@@ -14638,18 +14949,16 @@ class ModelQueryBuilder {
|
|
|
14638
14949
|
// Listen for subscription updates via the same GraphQL subscription channel.
|
|
14639
14950
|
// When Rust re-runs the model query and finds changed results, it pushes them.
|
|
14640
14951
|
const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
|
|
14641
|
-
// Skip delayed #init# messages — initial data was already returned
|
|
14642
|
-
// synchronously from modelSubscribe(). Late init messages contain stale
|
|
14643
|
-
// data that would overwrite real subscription updates.
|
|
14644
|
-
if (rawResult && rawResult.isInit)
|
|
14645
|
-
return;
|
|
14646
14952
|
try {
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14953
|
+
resolveAndReturn(parseResults(rawResult)).then((results) => {
|
|
14954
|
+
const fp = buildFingerprint(results);
|
|
14955
|
+
if (fp === lastResultFingerprint)
|
|
14956
|
+
return;
|
|
14957
|
+
lastResultFingerprint = fp;
|
|
14958
|
+
callback(results);
|
|
14959
|
+
}).catch((e) => {
|
|
14960
|
+
console.error('Model subscription update resolve error:', e);
|
|
14961
|
+
});
|
|
14653
14962
|
}
|
|
14654
14963
|
catch (e) {
|
|
14655
14964
|
console.error('Model subscription update parse error:', e);
|
|
@@ -14749,8 +15058,6 @@ class ModelQueryBuilder {
|
|
|
14749
15058
|
};
|
|
14750
15059
|
const initialCount = parseCount(initialModelResult);
|
|
14751
15060
|
const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
|
|
14752
|
-
if (rawResult && rawResult.isInit)
|
|
14753
|
-
return;
|
|
14754
15061
|
try {
|
|
14755
15062
|
callback(parseCount(rawResult));
|
|
14756
15063
|
}
|
|
@@ -14864,8 +15171,6 @@ class ModelQueryBuilder {
|
|
|
14864
15171
|
callback({ results, totalCount, pageSize, pageNumber });
|
|
14865
15172
|
};
|
|
14866
15173
|
const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
|
|
14867
|
-
if (rawResult && rawResult.isInit)
|
|
14868
|
-
return;
|
|
14869
15174
|
processResults().catch(e => console.error('Paginate subscription error:', e));
|
|
14870
15175
|
});
|
|
14871
15176
|
let keepaliveFailures = 0;
|
|
@@ -14919,6 +15224,48 @@ function normalizeValue(value) {
|
|
|
14919
15224
|
return value;
|
|
14920
15225
|
}
|
|
14921
15226
|
|
|
15227
|
+
// ---------------------------------------------------------------------------
|
|
15228
|
+
// Default decoder for file-storage (non-literal resolveLanguage) properties
|
|
15229
|
+
// ---------------------------------------------------------------------------
|
|
15230
|
+
/**
|
|
15231
|
+
* When the Rust executor resolves a non-literal expression it may return a
|
|
15232
|
+
* `FileData`-shaped object (`{ data_base64, file_type, ... }`) rather than a
|
|
15233
|
+
* raw URI string. If the model class has no custom `transform` registered
|
|
15234
|
+
* (e.g. it was synthesised from a SHACL shape at runtime) we still want to
|
|
15235
|
+
* decode the content rather than passing raw `FileData` to callers.
|
|
15236
|
+
*
|
|
15237
|
+
* Decoding rules (mirrors the JS `decodeFileAsJson` / `decodeFileAsString` helpers):
|
|
15238
|
+
* - `application/json` (default when `file_type` is absent) → JSON.parse
|
|
15239
|
+
* - anything else → raw decoded string
|
|
15240
|
+
*
|
|
15241
|
+
* If `resolved` is not a `FileData` object the value is returned unchanged so
|
|
15242
|
+
* that callers can use this as a safe unconditional fallback.
|
|
15243
|
+
*/
|
|
15244
|
+
function defaultFileDecode(resolved) {
|
|
15245
|
+
if (resolved !== null &&
|
|
15246
|
+
typeof resolved === 'object' &&
|
|
15247
|
+
'data_base64' in resolved) {
|
|
15248
|
+
const fd = resolved;
|
|
15249
|
+
let raw;
|
|
15250
|
+
try {
|
|
15251
|
+
raw = atob(fd.data_base64);
|
|
15252
|
+
}
|
|
15253
|
+
catch {
|
|
15254
|
+
return resolved; // malformed base64 — keep as-is
|
|
15255
|
+
}
|
|
15256
|
+
const isJson = !fd.file_type || fd.file_type === 'application/json';
|
|
15257
|
+
if (isJson) {
|
|
15258
|
+
try {
|
|
15259
|
+
return JSON.parse(raw);
|
|
15260
|
+
}
|
|
15261
|
+
catch {
|
|
15262
|
+
return raw;
|
|
15263
|
+
}
|
|
15264
|
+
}
|
|
15265
|
+
return raw;
|
|
15266
|
+
}
|
|
15267
|
+
return resolved;
|
|
15268
|
+
}
|
|
14922
15269
|
// ---------------------------------------------------------------------------
|
|
14923
15270
|
// Helpers for Rust-side include resolution
|
|
14924
15271
|
// ---------------------------------------------------------------------------
|
|
@@ -15671,7 +16018,11 @@ class Ad4mModel {
|
|
|
15671
16018
|
const allRelMeta = getRelationsMetadata(this);
|
|
15672
16019
|
enrichShapeForIncludes(metadata, query.include, allRelMeta);
|
|
15673
16020
|
}
|
|
15674
|
-
// Pre-compute conformance getters
|
|
16021
|
+
// Pre-compute conformance getters for Rust-side evaluation.
|
|
16022
|
+
// Where clauses are NOT compiled into getter SPARQL because stored
|
|
16023
|
+
// property values are signed expression envelopes (literal:json:...),
|
|
16024
|
+
// not simple literal:string:X values. Instead, where clauses are
|
|
16025
|
+
// attached as metadata for Rust-side post-evaluation filtering.
|
|
15675
16026
|
{
|
|
15676
16027
|
const allRelMeta = getRelationsMetadata(this);
|
|
15677
16028
|
for (const [relName, relMeta] of Object.entries(metadata.relations)) {
|
|
@@ -15684,43 +16035,31 @@ class Ad4mModel {
|
|
|
15684
16035
|
try {
|
|
15685
16036
|
const TargetClass = meta.target();
|
|
15686
16037
|
const filter = buildConformanceFilter(meta.predicate, TargetClass);
|
|
15687
|
-
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
//
|
|
15691
|
-
let whereConditions = [];
|
|
16038
|
+
if (filter) {
|
|
16039
|
+
rel.getter = filter.getter;
|
|
16040
|
+
}
|
|
16041
|
+
// Attach where-clause metadata for Rust-side post-getter filtering
|
|
15692
16042
|
if (rel.where) {
|
|
15693
16043
|
try {
|
|
15694
16044
|
const targetMetadata = TargetClass.getModelMetadata?.() ?? null;
|
|
15695
|
-
let allSparqlFilterable = true;
|
|
15696
16045
|
if (targetMetadata) {
|
|
16046
|
+
const predicates = {};
|
|
15697
16047
|
for (const propName of Object.keys(rel.where)) {
|
|
15698
16048
|
if (['id', 'author', 'timestamp'].includes(propName))
|
|
15699
16049
|
continue;
|
|
15700
16050
|
const propMeta = targetMetadata.properties[propName];
|
|
15701
|
-
if (propMeta?.
|
|
15702
|
-
|
|
15703
|
-
break;
|
|
16051
|
+
if (propMeta?.predicate) {
|
|
16052
|
+
predicates[propName] = propMeta.predicate;
|
|
15704
16053
|
}
|
|
15705
16054
|
}
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
16055
|
+
if (Object.keys(predicates).length > 0) {
|
|
16056
|
+
rel.whereFilter = rel.where;
|
|
16057
|
+
rel.wherePredicates = predicates;
|
|
16058
|
+
}
|
|
15709
16059
|
}
|
|
15710
16060
|
}
|
|
15711
16061
|
catch (_) { }
|
|
15712
16062
|
}
|
|
15713
|
-
if (filter) {
|
|
15714
|
-
let getter = filter.getter;
|
|
15715
|
-
if (whereConditions.length > 0) {
|
|
15716
|
-
getter = getter.replace(/ \}$/, ` ${whereConditions.join(' ')} }`);
|
|
15717
|
-
}
|
|
15718
|
-
rel.getter = getter;
|
|
15719
|
-
}
|
|
15720
|
-
else if (whereConditions.length > 0) {
|
|
15721
|
-
const escapedPred = meta.predicate.replace(/[<>"{}|\\^`\u0000-\u0020]/g, '');
|
|
15722
|
-
rel.getter = `SELECT ?target WHERE { <Base> <${escapedPred}> ?target . ${whereConditions.join(' ')} }`;
|
|
15723
|
-
}
|
|
15724
16063
|
}
|
|
15725
16064
|
catch (_) { }
|
|
15726
16065
|
}
|
|
@@ -15743,6 +16082,55 @@ class Ad4mModel {
|
|
|
15743
16082
|
return [];
|
|
15744
16083
|
return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
|
|
15745
16084
|
}
|
|
16085
|
+
/**
|
|
16086
|
+
* Resolve non-literal (file-language) properties on an array of already-constructed
|
|
16087
|
+
* model instances. Handles two cases:
|
|
16088
|
+
*
|
|
16089
|
+
* 1. The Rust executor returned a raw URI string → fetch via `getExpression` then apply transform.
|
|
16090
|
+
* 2. The Rust executor already resolved the expression and returned a `FileData` object
|
|
16091
|
+
* (happens when the perspective backend eagerly fetches file content) → apply transform
|
|
16092
|
+
* (or `defaultFileDecode` if no transform is registered on the class, e.g. for SHACL-
|
|
16093
|
+
* synthesised model classes).
|
|
16094
|
+
*
|
|
16095
|
+
* Extracted as a public static so `ModelQueryBuilder.subscribe()` can reuse it without
|
|
16096
|
+
* duplicating logic or introducing a circular dependency.
|
|
16097
|
+
* @internal
|
|
16098
|
+
*/
|
|
16099
|
+
static async resolveNonLiteralProps(perspective, instances) {
|
|
16100
|
+
const propsMeta = getPropertiesMetadata(this);
|
|
16101
|
+
const resolveProps = Object.entries(propsMeta).filter(([, opts]) => opts.resolveLanguage != null &&
|
|
16102
|
+
opts.resolveLanguage !== 'literal');
|
|
16103
|
+
if (resolveProps.length === 0)
|
|
16104
|
+
return;
|
|
16105
|
+
await Promise.all(instances.map(async (inst) => {
|
|
16106
|
+
for (const [propName, opts] of resolveProps) {
|
|
16107
|
+
const val = inst[propName];
|
|
16108
|
+
const transform = opts.transform;
|
|
16109
|
+
const applyTransform = (resolved) => typeof transform === 'function' ? transform(resolved) : defaultFileDecode(resolved);
|
|
16110
|
+
if (typeof val === 'string' && val && !val.startsWith('literal:')) {
|
|
16111
|
+
// Case 1: raw URI — fetch from language runtime
|
|
16112
|
+
try {
|
|
16113
|
+
const expression = await perspective.getExpression(val);
|
|
16114
|
+
if (expression) {
|
|
16115
|
+
let resolved;
|
|
16116
|
+
try {
|
|
16117
|
+
resolved = JSON.parse(expression.data);
|
|
16118
|
+
}
|
|
16119
|
+
catch {
|
|
16120
|
+
resolved = expression.data;
|
|
16121
|
+
}
|
|
16122
|
+
inst[propName] = applyTransform(resolved);
|
|
16123
|
+
}
|
|
16124
|
+
}
|
|
16125
|
+
catch (_) { /* resolution failed — keep raw value */ }
|
|
16126
|
+
}
|
|
16127
|
+
else if (val !== null && val !== undefined && typeof val === 'object') {
|
|
16128
|
+
// Case 2: already resolved by Rust — apply transform / default decode
|
|
16129
|
+
inst[propName] = applyTransform(val);
|
|
16130
|
+
}
|
|
16131
|
+
}
|
|
16132
|
+
}));
|
|
16133
|
+
}
|
|
15746
16134
|
// instancesFromQueryResult — removed (superseded by Rust executeModelQuery pipeline)
|
|
15747
16135
|
/**
|
|
15748
16136
|
* Execute a model query via the executor-side endpoint.
|
|
@@ -15853,45 +16241,33 @@ class Ad4mModel {
|
|
|
15853
16241
|
try {
|
|
15854
16242
|
const TargetClass = meta.target();
|
|
15855
16243
|
const filter = buildConformanceFilter(meta.predicate, TargetClass);
|
|
15856
|
-
|
|
15857
|
-
|
|
15858
|
-
|
|
15859
|
-
//
|
|
15860
|
-
|
|
16244
|
+
if (filter) {
|
|
16245
|
+
rel.getter = filter.getter;
|
|
16246
|
+
}
|
|
16247
|
+
// Attach where-clause metadata for Rust-side post-getter filtering.
|
|
16248
|
+
// Property values are signed expression envelopes (literal:json:...)
|
|
16249
|
+
// and cannot be matched by SPARQL FILTER on the raw IRI.
|
|
15861
16250
|
if (rel.where) {
|
|
15862
16251
|
try {
|
|
15863
16252
|
const targetMetadata = TargetClass.getModelMetadata?.() ?? null;
|
|
15864
|
-
let allSparqlFilterable = true;
|
|
15865
16253
|
if (targetMetadata) {
|
|
16254
|
+
const predicates = {};
|
|
15866
16255
|
for (const propName of Object.keys(rel.where)) {
|
|
15867
16256
|
if (['id', 'author', 'timestamp'].includes(propName))
|
|
15868
16257
|
continue;
|
|
15869
16258
|
const propMeta = targetMetadata.properties[propName];
|
|
15870
|
-
if (propMeta?.
|
|
15871
|
-
|
|
15872
|
-
break;
|
|
16259
|
+
if (propMeta?.predicate) {
|
|
16260
|
+
predicates[propName] = propMeta.predicate;
|
|
15873
16261
|
}
|
|
15874
16262
|
}
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
16263
|
+
if (Object.keys(predicates).length > 0) {
|
|
16264
|
+
rel.whereFilter = rel.where;
|
|
16265
|
+
rel.wherePredicates = predicates;
|
|
16266
|
+
}
|
|
15878
16267
|
}
|
|
15879
16268
|
}
|
|
15880
16269
|
catch (_) { /* target metadata unavailable */ }
|
|
15881
16270
|
}
|
|
15882
|
-
if (filter) {
|
|
15883
|
-
let getter = filter.getter;
|
|
15884
|
-
if (whereConditions.length > 0) {
|
|
15885
|
-
// Append where conditions before the closing }
|
|
15886
|
-
getter = getter.replace(/ \}$/, ` ${whereConditions.join(' ')} }`);
|
|
15887
|
-
}
|
|
15888
|
-
rel.getter = getter;
|
|
15889
|
-
}
|
|
15890
|
-
else if (whereConditions.length > 0) {
|
|
15891
|
-
// No conformance filter but where clause exists — build getter from where alone
|
|
15892
|
-
const escapedPred = meta.predicate.replace(/[<>"{}|\\^`\u0000-\u0020]/g, '');
|
|
15893
|
-
rel.getter = `SELECT ?target WHERE { <Base> <${escapedPred}> ?target . ${whereConditions.join(' ')} }`;
|
|
15894
|
-
}
|
|
15895
16271
|
}
|
|
15896
16272
|
catch (e) {
|
|
15897
16273
|
// Target class may not be available; skip silently
|
|
@@ -15903,13 +16279,6 @@ class Ad4mModel {
|
|
|
15903
16279
|
// the TS decorators are the definitive source of truth.
|
|
15904
16280
|
const shapeJson = JSON.stringify(metadata);
|
|
15905
16281
|
const queryJson = JSON.stringify(queryInput);
|
|
15906
|
-
// TEMP DEBUG: Log getters with where-clause filters to diagnose CI failure
|
|
15907
|
-
for (const [relName, relMeta] of Object.entries(metadata.relations)) {
|
|
15908
|
-
const rel = relMeta;
|
|
15909
|
-
if (rel.where) {
|
|
15910
|
-
console.log(`[MODEL_QUERY_DEBUG] relation="${relName}" getter=${rel.getter ?? 'NONE'} where=${JSON.stringify(rel.where)}`);
|
|
15911
|
-
}
|
|
15912
|
-
}
|
|
15913
16282
|
const result = await perspective.modelQuery(className, queryJson, shapeJson);
|
|
15914
16283
|
// Convert JSON instances to model class instances, recursively constructing
|
|
15915
16284
|
// class instances for any included relations resolved by Rust.
|
|
@@ -15918,34 +16287,9 @@ class Ad4mModel {
|
|
|
15918
16287
|
});
|
|
15919
16288
|
// Resolve non-literal expressions (e.g. file languages where the stored
|
|
15920
16289
|
// value is a content-addressed hash that must be fetched from the language
|
|
15921
|
-
// runtime). The Rust endpoint
|
|
15922
|
-
|
|
15923
|
-
|
|
15924
|
-
opts.resolveLanguage !== 'literal');
|
|
15925
|
-
if (resolveProps.length > 0) {
|
|
15926
|
-
await Promise.all(instances.map(async (inst) => {
|
|
15927
|
-
for (const [propName, opts] of resolveProps) {
|
|
15928
|
-
const val = inst[propName];
|
|
15929
|
-
if (typeof val !== 'string' || !val || val.startsWith('literal:'))
|
|
15930
|
-
continue;
|
|
15931
|
-
try {
|
|
15932
|
-
const expression = await perspective.getExpression(val);
|
|
15933
|
-
if (expression) {
|
|
15934
|
-
let resolved;
|
|
15935
|
-
try {
|
|
15936
|
-
resolved = JSON.parse(expression.data);
|
|
15937
|
-
}
|
|
15938
|
-
catch {
|
|
15939
|
-
resolved = expression.data;
|
|
15940
|
-
}
|
|
15941
|
-
const transform = opts.transform;
|
|
15942
|
-
inst[propName] = typeof transform === 'function' ? transform(resolved) : resolved;
|
|
15943
|
-
}
|
|
15944
|
-
}
|
|
15945
|
-
catch (_) { /* resolution failed — keep raw value */ }
|
|
15946
|
-
}
|
|
15947
|
-
}));
|
|
15948
|
-
}
|
|
16290
|
+
// runtime). The Rust endpoint may return either a raw target URI (string)
|
|
16291
|
+
// or an already-resolved FileData object — both cases are handled here.
|
|
16292
|
+
await this.resolveNonLiteralProps(perspective, instances);
|
|
15949
16293
|
// Take snapshots for dirty tracking
|
|
15950
16294
|
const snapshotRelations = queryInput.include;
|
|
15951
16295
|
for (const inst of instances) {
|
|
@@ -17014,8 +17358,9 @@ class Ad4mClient {
|
|
|
17014
17358
|
__classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").subscribeAgentStatusChanged();
|
|
17015
17359
|
__classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").subscribeAppsChanged();
|
|
17016
17360
|
}
|
|
17017
|
-
/** Close all event connections */
|
|
17361
|
+
/** Close all event connections and clear in-memory caches */
|
|
17018
17362
|
close() {
|
|
17363
|
+
__classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").clearByDidCache();
|
|
17019
17364
|
__classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").closeAll();
|
|
17020
17365
|
}
|
|
17021
17366
|
}
|
|
@@ -17526,6 +17871,7 @@ exports.Flag = Flag;
|
|
|
17526
17871
|
exports.HasMany = HasMany;
|
|
17527
17872
|
exports.HasOne = HasOne;
|
|
17528
17873
|
exports.HostingUserInfo = HostingUserInfo;
|
|
17874
|
+
exports.IDBCache = IDBCache;
|
|
17529
17875
|
exports.Icon = Icon;
|
|
17530
17876
|
exports.ImportResult = ImportResult;
|
|
17531
17877
|
exports.ImportStats = ImportStats;
|
|
@@ -17560,6 +17906,7 @@ exports.NeighbourhoodExpression = NeighbourhoodExpression;
|
|
|
17560
17906
|
exports.NeighbourhoodProxy = NeighbourhoodProxy;
|
|
17561
17907
|
exports.Notification = Notification;
|
|
17562
17908
|
exports.NotificationInput = NotificationInput;
|
|
17909
|
+
exports.NullCache = NullCache;
|
|
17563
17910
|
exports.OnlineAgent = OnlineAgent;
|
|
17564
17911
|
exports.Optional = Optional;
|
|
17565
17912
|
exports.PaymentRequestResult = PaymentRequestResult;
|
|
@@ -17603,6 +17950,7 @@ exports.buildWhereCondition = buildWhereCondition;
|
|
|
17603
17950
|
exports.capSentence = capSentence;
|
|
17604
17951
|
exports.clearQueryCache = clearQueryCache;
|
|
17605
17952
|
exports.compileWhereClause = compileWhereClause;
|
|
17953
|
+
exports.createPersistentCache = createPersistentCache;
|
|
17606
17954
|
exports.determineNamespace = determineNamespace;
|
|
17607
17955
|
exports.determinePredicate = determinePredicate;
|
|
17608
17956
|
exports.escapeQueryString = escapeQueryString;
|