@coasys/ad4m 0.13.0-test-5 → 0.13.0-test-6
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 +610 -337
- package/lib/index.js +608 -338
- 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.js +29 -57
- package/lib/src/model/Ad4mModel.test.js +688 -1434
- package/lib/src/model/ModelQueryBuilder.js +0 -9
- package/lib/src/model/Subject.js +6 -6
- package/lib/src/model/query-surreal.d.ts +44 -0
- package/lib/src/model/query-surreal.js +249 -0
- package/lib/src/model/relation-filtering.test.js +15 -15
- package/lib/src/model/surreal-utils.d.ts +42 -0
- package/lib/src/model/surreal-utils.js +128 -0
- 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/lib/src/perspectives/PerspectiveResolver.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveResolver.js +11 -0
- package/lib/src/runtime/RuntimeResolver.d.ts +1 -28
- package/lib/src/runtime/RuntimeResolver.js +4 -197
- package/lib/src/schema.gql +1 -27
- package/lib/src/shacl/SHACLShape.test.js +0 -82
- package/package.json +1 -1
- 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 +31 -57
- package/src/model/ModelQueryBuilder.ts +0 -6
- package/src/model/types.ts +1 -1
- package/src/perspectives/PerspectiveClient.ts +7 -17
- package/src/perspectives/PerspectiveProxy.ts +0 -3
- package/lib/src/model/hydration-batch.d.ts +0 -34
- package/lib/src/model/hydration-batch.js +0 -147
- package/lib/src/model/hydration-batching.test.d.ts +0 -7
- package/lib/src/model/hydration-batching.test.js +0 -456
- package/lib/src/model/model-manifest.d.ts +0 -41
- package/lib/src/model/model-manifest.js +0 -11
- package/lib/src/model/query-cache.test.d.ts +0 -1
- package/lib/src/model/query-cache.test.js +0 -43
- package/lib/src/model/query-sparql-batch.d.ts +0 -17
- package/lib/src/model/query-sparql-batch.js +0 -260
- package/lib/src/model/query-sparql.test.d.ts +0 -1
- package/lib/src/model/query-sparql.test.js +0 -312
- package/lib/src/model/subscription-delta.test.d.ts +0 -24
- package/lib/src/model/subscription-delta.test.js +0 -180
- package/lib/src/model/subscription-pool.d.ts +0 -39
- package/lib/src/model/subscription-pool.js +0 -165
- package/lib/src/perspectives/PerspectiveClient.test.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveClient.test.js +0 -224
|
@@ -31,7 +31,6 @@ export declare class PerspectiveClient {
|
|
|
31
31
|
subscribeQuery(uuid: string, query: string): Promise<{
|
|
32
32
|
subscriptionId: string;
|
|
33
33
|
result: AllInstancesResult;
|
|
34
|
-
isInit?: boolean;
|
|
35
34
|
}>;
|
|
36
35
|
perspectiveKeepAliveQuery(uuid: string, subscriptionId: string): Promise<boolean>;
|
|
37
36
|
perspectiveDisposeQuerySubscription(uuid: string, subscriptionId: string): Promise<boolean>;
|
|
@@ -15,11 +15,6 @@ import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
|
|
|
15
15
|
import { PerspectiveProxy } from './PerspectiveProxy';
|
|
16
16
|
function normalizeQueryResult(raw, errorContext) {
|
|
17
17
|
let finalResult = raw;
|
|
18
|
-
let isInit = false;
|
|
19
|
-
if (typeof finalResult === 'string' && finalResult.startsWith('#init#')) {
|
|
20
|
-
finalResult = finalResult.substring(6);
|
|
21
|
-
isInit = true;
|
|
22
|
-
}
|
|
23
18
|
if (typeof finalResult === 'string') {
|
|
24
19
|
try {
|
|
25
20
|
finalResult = JSON.parse(finalResult);
|
|
@@ -28,10 +23,7 @@ function normalizeQueryResult(raw, errorContext) {
|
|
|
28
23
|
console.error(errorContext, e);
|
|
29
24
|
}
|
|
30
25
|
}
|
|
31
|
-
|
|
32
|
-
finalResult.isInit = true;
|
|
33
|
-
}
|
|
34
|
-
return { result: finalResult, isInit };
|
|
26
|
+
return finalResult;
|
|
35
27
|
}
|
|
36
28
|
export class PerspectiveClient {
|
|
37
29
|
constructor(baseUrl, token, subscribe = true, sharedApiClient) {
|
|
@@ -122,8 +114,8 @@ export class PerspectiveClient {
|
|
|
122
114
|
async subscribeQuery(uuid, query) {
|
|
123
115
|
const response = await __classPrivateFieldGet(this, _PerspectiveClient_apiClient, "f").call('perspective.subscribeQuery', { uuid, query });
|
|
124
116
|
const { subscriptionId, result } = response;
|
|
125
|
-
const
|
|
126
|
-
return { subscriptionId, result:
|
|
117
|
+
const parsed = normalizeQueryResult(result, 'Error parsing subscribeQuery result:');
|
|
118
|
+
return { subscriptionId, result: parsed };
|
|
127
119
|
}
|
|
128
120
|
async perspectiveKeepAliveQuery(uuid, subscriptionId) {
|
|
129
121
|
return __classPrivateFieldGet(this, _PerspectiveClient_apiClient, "f").call('perspective.keepAliveQuery', { uuid, subscriptionId });
|
|
@@ -139,8 +131,8 @@ export class PerspectiveClient {
|
|
|
139
131
|
const eventSubscriptionId = event.subscriptionId || event.subscription_id;
|
|
140
132
|
if (eventSubscriptionId !== subscriptionId)
|
|
141
133
|
return;
|
|
142
|
-
const
|
|
143
|
-
onData(
|
|
134
|
+
const parsed = normalizeQueryResult(event.result, 'Error parsing query subscription:');
|
|
135
|
+
onData(parsed);
|
|
144
136
|
});
|
|
145
137
|
__classPrivateFieldGet(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").set(subscriptionId, unsub);
|
|
146
138
|
return unsub;
|
|
@@ -154,9 +154,6 @@ export class QuerySubscriptionProxy {
|
|
|
154
154
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_initResolve, undefined, "f"); // Prevent double-resolve
|
|
155
155
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_initReject, undefined, "f");
|
|
156
156
|
}
|
|
157
|
-
// Skip duplicate init messages
|
|
158
|
-
if (updateResult.isInit && __classPrivateFieldGet(this, _QuerySubscriptionProxy_latestResult, "f"))
|
|
159
|
-
return;
|
|
160
157
|
__classPrivateFieldSet(this, _QuerySubscriptionProxy_latestResult, updateResult, "f");
|
|
161
158
|
__classPrivateFieldGet(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, updateResult);
|
|
162
159
|
}), "f");
|
|
@@ -22,6 +22,7 @@ export default class PerspectiveResolver {
|
|
|
22
22
|
perspectivePublishSnapshot(uuid: string): String | null;
|
|
23
23
|
perspectiveQueryLinks(uuid: string, query: LinkQuery): LinkExpression[];
|
|
24
24
|
perspectiveQueryProlog(uuid: string, query: string): Promise<string>;
|
|
25
|
+
perspectiveQuerySurrealDB(uuid: string, query: string): Promise<string>;
|
|
25
26
|
perspectiveSubscribeQuery(uuid: string, query: string): Promise<QuerySubscription>;
|
|
26
27
|
perspectiveAdd(name: string, pubSub: any): PerspectiveHandle;
|
|
27
28
|
perspectiveUpdate(uuid: string, name: string, pubSub: any): PerspectiveHandle;
|
|
@@ -87,6 +87,9 @@ let PerspectiveResolver = class PerspectiveResolver {
|
|
|
87
87
|
async perspectiveQueryProlog(uuid, query) {
|
|
88
88
|
return `[{"X": 1}]`;
|
|
89
89
|
}
|
|
90
|
+
async perspectiveQuerySurrealDB(uuid, query) {
|
|
91
|
+
return `[]`;
|
|
92
|
+
}
|
|
90
93
|
async perspectiveSubscribeQuery(uuid, query) {
|
|
91
94
|
const result = `[{"X": 1}]`;
|
|
92
95
|
return {
|
|
@@ -274,6 +277,14 @@ __decorate([
|
|
|
274
277
|
__metadata("design:paramtypes", [String, String]),
|
|
275
278
|
__metadata("design:returntype", Promise)
|
|
276
279
|
], PerspectiveResolver.prototype, "perspectiveQueryProlog", null);
|
|
280
|
+
__decorate([
|
|
281
|
+
Query(returns => String),
|
|
282
|
+
__param(0, Arg('uuid')),
|
|
283
|
+
__param(1, Arg('query')),
|
|
284
|
+
__metadata("design:type", Function),
|
|
285
|
+
__metadata("design:paramtypes", [String, String]),
|
|
286
|
+
__metadata("design:returntype", Promise)
|
|
287
|
+
], PerspectiveResolver.prototype, "perspectiveQuerySurrealDB", null);
|
|
277
288
|
__decorate([
|
|
278
289
|
Mutation(returns => QuerySubscription),
|
|
279
290
|
__param(0, Arg('uuid')),
|
|
@@ -68,9 +68,6 @@ export declare class UserStatistics {
|
|
|
68
68
|
did: string;
|
|
69
69
|
lastSeen?: string;
|
|
70
70
|
perspectiveCount: number;
|
|
71
|
-
remainingCredits: string;
|
|
72
|
-
freeAccess: boolean;
|
|
73
|
-
hotWalletAddress?: string;
|
|
74
71
|
}
|
|
75
72
|
export declare class VerificationRequestResult {
|
|
76
73
|
success: boolean;
|
|
@@ -82,24 +79,13 @@ export declare class HostingUserInfo {
|
|
|
82
79
|
email: string;
|
|
83
80
|
remainingCredits: string;
|
|
84
81
|
hotWalletAddress?: string;
|
|
85
|
-
|
|
86
|
-
constructor(email: string, remainingCredits: string, hotWalletAddress?: string, freeAccess?: boolean);
|
|
82
|
+
constructor(email: string, remainingCredits: string, hotWalletAddress?: string);
|
|
87
83
|
}
|
|
88
84
|
export declare class PaymentRequestResult {
|
|
89
85
|
success: boolean;
|
|
90
86
|
message: string;
|
|
91
87
|
constructor(success: boolean, message: string);
|
|
92
88
|
}
|
|
93
|
-
export declare class ComputeLogEntry {
|
|
94
|
-
id: number;
|
|
95
|
-
userEmail: string;
|
|
96
|
-
timestamp: string;
|
|
97
|
-
operation: string;
|
|
98
|
-
summary?: string;
|
|
99
|
-
cost: number;
|
|
100
|
-
creditsAfter: number;
|
|
101
|
-
constructor(id: number, userEmail: string, timestamp: string, operation: string, cost: number, creditsAfter: number, summary?: string);
|
|
102
|
-
}
|
|
103
89
|
/**
|
|
104
90
|
* Resolver classes are used here to define the GraphQL schema
|
|
105
91
|
* (through the type-graphql annotations)
|
|
@@ -143,8 +129,6 @@ export default class RuntimeResolver {
|
|
|
143
129
|
runtimeImportPerspective(filePath: string): boolean;
|
|
144
130
|
runtimeMultiUserEnabled(): boolean;
|
|
145
131
|
runtimeSetMultiUserEnabled(enabled: boolean): boolean;
|
|
146
|
-
runtimeFreeHostingEnabled(): boolean;
|
|
147
|
-
runtimeSetFreeHostingEnabled(enabled: boolean): boolean;
|
|
148
132
|
runtimeListUsers(): UserStatistics[];
|
|
149
133
|
runtimeRequestLoginVerification(email: string, appInfo?: AuthInfoInput): VerificationRequestResult;
|
|
150
134
|
runtimeVerifyEmailCode(email: string, code: string, verificationType: string): string;
|
|
@@ -157,17 +141,6 @@ export default class RuntimeResolver {
|
|
|
157
141
|
runtimeEmailTestClearCodes(): boolean;
|
|
158
142
|
runtimeEmailTestSetExpiry(email: string, verificationType: string, expiresAt: number): boolean;
|
|
159
143
|
runtimeHostingUserInfo(): HostingUserInfo;
|
|
160
|
-
runtimeComputeLog(since?: string, limit?: number, userEmail?: string): ComputeLogEntry[];
|
|
161
144
|
runtimeSetHotWalletAddress(address: string): boolean;
|
|
162
145
|
runtimeRequestPayment(amountHOT: string): PaymentRequestResult;
|
|
163
|
-
runtimeSetUserCredits(email: string, amount: number): boolean;
|
|
164
|
-
runtimeSetUserFreeAccess(email: string, enabled: boolean): boolean;
|
|
165
|
-
runtimeReinstallUnytDna(): PaymentRequestResult;
|
|
166
|
-
runtimeSendHot(recipient: string, amount: string): PaymentRequestResult;
|
|
167
|
-
runtimeSetUnytMembraneProof(proof: string): PaymentRequestResult;
|
|
168
|
-
runtimeHotWalletBalance(): string;
|
|
169
|
-
runtimeHotWalletHistory(page?: number, perPage?: number): string;
|
|
170
|
-
runtimeHotAgentPubkey(): string;
|
|
171
|
-
runtimeUnytAgentKey(): string;
|
|
172
|
-
runtimeUnytVersionInfo(): string;
|
|
173
146
|
}
|
|
@@ -289,18 +289,6 @@ __decorate([
|
|
|
289
289
|
Field(type => Int),
|
|
290
290
|
__metadata("design:type", Number)
|
|
291
291
|
], UserStatistics.prototype, "perspectiveCount", void 0);
|
|
292
|
-
__decorate([
|
|
293
|
-
Field(),
|
|
294
|
-
__metadata("design:type", String)
|
|
295
|
-
], UserStatistics.prototype, "remainingCredits", void 0);
|
|
296
|
-
__decorate([
|
|
297
|
-
Field(),
|
|
298
|
-
__metadata("design:type", Boolean)
|
|
299
|
-
], UserStatistics.prototype, "freeAccess", void 0);
|
|
300
|
-
__decorate([
|
|
301
|
-
Field({ nullable: true }),
|
|
302
|
-
__metadata("design:type", String)
|
|
303
|
-
], UserStatistics.prototype, "hotWalletAddress", void 0);
|
|
304
292
|
UserStatistics = __decorate([
|
|
305
293
|
ObjectType()
|
|
306
294
|
], UserStatistics);
|
|
@@ -328,11 +316,10 @@ VerificationRequestResult = __decorate([
|
|
|
328
316
|
], VerificationRequestResult);
|
|
329
317
|
export { VerificationRequestResult };
|
|
330
318
|
let HostingUserInfo = class HostingUserInfo {
|
|
331
|
-
constructor(email, remainingCredits, hotWalletAddress
|
|
319
|
+
constructor(email, remainingCredits, hotWalletAddress) {
|
|
332
320
|
this.email = email;
|
|
333
321
|
this.remainingCredits = remainingCredits;
|
|
334
322
|
this.hotWalletAddress = hotWalletAddress;
|
|
335
|
-
this.freeAccess = freeAccess;
|
|
336
323
|
}
|
|
337
324
|
};
|
|
338
325
|
__decorate([
|
|
@@ -347,13 +334,9 @@ __decorate([
|
|
|
347
334
|
Field({ nullable: true }),
|
|
348
335
|
__metadata("design:type", String)
|
|
349
336
|
], HostingUserInfo.prototype, "hotWalletAddress", void 0);
|
|
350
|
-
__decorate([
|
|
351
|
-
Field(),
|
|
352
|
-
__metadata("design:type", Boolean)
|
|
353
|
-
], HostingUserInfo.prototype, "freeAccess", void 0);
|
|
354
337
|
HostingUserInfo = __decorate([
|
|
355
338
|
ObjectType(),
|
|
356
|
-
__metadata("design:paramtypes", [String, String, String
|
|
339
|
+
__metadata("design:paramtypes", [String, String, String])
|
|
357
340
|
], HostingUserInfo);
|
|
358
341
|
export { HostingUserInfo };
|
|
359
342
|
let PaymentRequestResult = class PaymentRequestResult {
|
|
@@ -375,50 +358,6 @@ PaymentRequestResult = __decorate([
|
|
|
375
358
|
__metadata("design:paramtypes", [Boolean, String])
|
|
376
359
|
], PaymentRequestResult);
|
|
377
360
|
export { PaymentRequestResult };
|
|
378
|
-
let ComputeLogEntry = class ComputeLogEntry {
|
|
379
|
-
constructor(id, userEmail, timestamp, operation, cost, creditsAfter, summary) {
|
|
380
|
-
this.id = id;
|
|
381
|
-
this.userEmail = userEmail;
|
|
382
|
-
this.timestamp = timestamp;
|
|
383
|
-
this.operation = operation;
|
|
384
|
-
this.cost = cost;
|
|
385
|
-
this.creditsAfter = creditsAfter;
|
|
386
|
-
this.summary = summary;
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
__decorate([
|
|
390
|
-
Field(),
|
|
391
|
-
__metadata("design:type", Number)
|
|
392
|
-
], ComputeLogEntry.prototype, "id", void 0);
|
|
393
|
-
__decorate([
|
|
394
|
-
Field(),
|
|
395
|
-
__metadata("design:type", String)
|
|
396
|
-
], ComputeLogEntry.prototype, "userEmail", void 0);
|
|
397
|
-
__decorate([
|
|
398
|
-
Field(),
|
|
399
|
-
__metadata("design:type", String)
|
|
400
|
-
], ComputeLogEntry.prototype, "timestamp", void 0);
|
|
401
|
-
__decorate([
|
|
402
|
-
Field(),
|
|
403
|
-
__metadata("design:type", String)
|
|
404
|
-
], ComputeLogEntry.prototype, "operation", void 0);
|
|
405
|
-
__decorate([
|
|
406
|
-
Field({ nullable: true }),
|
|
407
|
-
__metadata("design:type", String)
|
|
408
|
-
], ComputeLogEntry.prototype, "summary", void 0);
|
|
409
|
-
__decorate([
|
|
410
|
-
Field(),
|
|
411
|
-
__metadata("design:type", Number)
|
|
412
|
-
], ComputeLogEntry.prototype, "cost", void 0);
|
|
413
|
-
__decorate([
|
|
414
|
-
Field(),
|
|
415
|
-
__metadata("design:type", Number)
|
|
416
|
-
], ComputeLogEntry.prototype, "creditsAfter", void 0);
|
|
417
|
-
ComputeLogEntry = __decorate([
|
|
418
|
-
ObjectType(),
|
|
419
|
-
__metadata("design:paramtypes", [Number, String, String, String, Number, Number, String])
|
|
420
|
-
], ComputeLogEntry);
|
|
421
|
-
export { ComputeLogEntry };
|
|
422
361
|
/**
|
|
423
362
|
* Resolver classes are used here to define the GraphQL schema
|
|
424
363
|
* (through the type-graphql annotations)
|
|
@@ -574,20 +513,12 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
574
513
|
runtimeSetMultiUserEnabled(enabled) {
|
|
575
514
|
return enabled;
|
|
576
515
|
}
|
|
577
|
-
runtimeFreeHostingEnabled() {
|
|
578
|
-
return true;
|
|
579
|
-
}
|
|
580
|
-
runtimeSetFreeHostingEnabled(enabled) {
|
|
581
|
-
return enabled;
|
|
582
|
-
}
|
|
583
516
|
runtimeListUsers() {
|
|
584
517
|
return [{
|
|
585
518
|
email: "test@example.com",
|
|
586
519
|
did: "did:key:test123",
|
|
587
520
|
lastSeen: new Date().toISOString(),
|
|
588
|
-
perspectiveCount: 5
|
|
589
|
-
remainingCredits: "0",
|
|
590
|
-
freeAccess: false
|
|
521
|
+
perspectiveCount: 5
|
|
591
522
|
}];
|
|
592
523
|
}
|
|
593
524
|
runtimeRequestLoginVerification(email, appInfo) {
|
|
@@ -637,10 +568,7 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
637
568
|
}
|
|
638
569
|
// Hosting mutations & queries
|
|
639
570
|
runtimeHostingUserInfo() {
|
|
640
|
-
return new HostingUserInfo("test@example.com", "100000000", null
|
|
641
|
-
}
|
|
642
|
-
runtimeComputeLog(since, limit, userEmail) {
|
|
643
|
-
return [];
|
|
571
|
+
return new HostingUserInfo("test@example.com", "100000000", null);
|
|
644
572
|
}
|
|
645
573
|
runtimeSetHotWalletAddress(address) {
|
|
646
574
|
return true;
|
|
@@ -648,36 +576,6 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
648
576
|
runtimeRequestPayment(amountHOT) {
|
|
649
577
|
return new PaymentRequestResult(true, "Mock payment of " + amountHOT + " base units credited");
|
|
650
578
|
}
|
|
651
|
-
runtimeSetUserCredits(email, amount) {
|
|
652
|
-
return true;
|
|
653
|
-
}
|
|
654
|
-
runtimeSetUserFreeAccess(email, enabled) {
|
|
655
|
-
return true;
|
|
656
|
-
}
|
|
657
|
-
runtimeReinstallUnytDna() {
|
|
658
|
-
return new PaymentRequestResult(true, "");
|
|
659
|
-
}
|
|
660
|
-
runtimeSendHot(recipient, amount) {
|
|
661
|
-
return new PaymentRequestResult(true, "");
|
|
662
|
-
}
|
|
663
|
-
runtimeSetUnytMembraneProof(proof) {
|
|
664
|
-
return new PaymentRequestResult(true, "");
|
|
665
|
-
}
|
|
666
|
-
runtimeHotWalletBalance() {
|
|
667
|
-
return "";
|
|
668
|
-
}
|
|
669
|
-
runtimeHotWalletHistory(page, perPage) {
|
|
670
|
-
return "";
|
|
671
|
-
}
|
|
672
|
-
runtimeHotAgentPubkey() {
|
|
673
|
-
return "";
|
|
674
|
-
}
|
|
675
|
-
runtimeUnytAgentKey() {
|
|
676
|
-
return "";
|
|
677
|
-
}
|
|
678
|
-
runtimeUnytVersionInfo() {
|
|
679
|
-
return "";
|
|
680
|
-
}
|
|
681
579
|
};
|
|
682
580
|
__decorate([
|
|
683
581
|
Mutation(returns => Boolean),
|
|
@@ -924,19 +822,6 @@ __decorate([
|
|
|
924
822
|
__metadata("design:paramtypes", [Boolean]),
|
|
925
823
|
__metadata("design:returntype", Boolean)
|
|
926
824
|
], RuntimeResolver.prototype, "runtimeSetMultiUserEnabled", null);
|
|
927
|
-
__decorate([
|
|
928
|
-
Query(returns => Boolean),
|
|
929
|
-
__metadata("design:type", Function),
|
|
930
|
-
__metadata("design:paramtypes", []),
|
|
931
|
-
__metadata("design:returntype", Boolean)
|
|
932
|
-
], RuntimeResolver.prototype, "runtimeFreeHostingEnabled", null);
|
|
933
|
-
__decorate([
|
|
934
|
-
Mutation(returns => Boolean),
|
|
935
|
-
__param(0, Arg("enabled")),
|
|
936
|
-
__metadata("design:type", Function),
|
|
937
|
-
__metadata("design:paramtypes", [Boolean]),
|
|
938
|
-
__metadata("design:returntype", Boolean)
|
|
939
|
-
], RuntimeResolver.prototype, "runtimeSetFreeHostingEnabled", null);
|
|
940
825
|
__decorate([
|
|
941
826
|
Query(returns => [UserStatistics]),
|
|
942
827
|
__metadata("design:type", Function),
|
|
@@ -1024,15 +909,6 @@ __decorate([
|
|
|
1024
909
|
__metadata("design:paramtypes", []),
|
|
1025
910
|
__metadata("design:returntype", HostingUserInfo)
|
|
1026
911
|
], RuntimeResolver.prototype, "runtimeHostingUserInfo", null);
|
|
1027
|
-
__decorate([
|
|
1028
|
-
Query(returns => [ComputeLogEntry]),
|
|
1029
|
-
__param(0, Arg("since", { nullable: true })),
|
|
1030
|
-
__param(1, Arg("limit", { nullable: true })),
|
|
1031
|
-
__param(2, Arg("userEmail", { nullable: true })),
|
|
1032
|
-
__metadata("design:type", Function),
|
|
1033
|
-
__metadata("design:paramtypes", [String, Number, String]),
|
|
1034
|
-
__metadata("design:returntype", Array)
|
|
1035
|
-
], RuntimeResolver.prototype, "runtimeComputeLog", null);
|
|
1036
912
|
__decorate([
|
|
1037
913
|
Mutation(returns => Boolean),
|
|
1038
914
|
__param(0, Arg("address")),
|
|
@@ -1047,75 +923,6 @@ __decorate([
|
|
|
1047
923
|
__metadata("design:paramtypes", [String]),
|
|
1048
924
|
__metadata("design:returntype", PaymentRequestResult)
|
|
1049
925
|
], RuntimeResolver.prototype, "runtimeRequestPayment", null);
|
|
1050
|
-
__decorate([
|
|
1051
|
-
Mutation(returns => Boolean),
|
|
1052
|
-
__param(0, Arg("email")),
|
|
1053
|
-
__param(1, Arg("amount")),
|
|
1054
|
-
__metadata("design:type", Function),
|
|
1055
|
-
__metadata("design:paramtypes", [String, Number]),
|
|
1056
|
-
__metadata("design:returntype", Boolean)
|
|
1057
|
-
], RuntimeResolver.prototype, "runtimeSetUserCredits", null);
|
|
1058
|
-
__decorate([
|
|
1059
|
-
Mutation(returns => Boolean),
|
|
1060
|
-
__param(0, Arg("email")),
|
|
1061
|
-
__param(1, Arg("enabled")),
|
|
1062
|
-
__metadata("design:type", Function),
|
|
1063
|
-
__metadata("design:paramtypes", [String, Boolean]),
|
|
1064
|
-
__metadata("design:returntype", Boolean)
|
|
1065
|
-
], RuntimeResolver.prototype, "runtimeSetUserFreeAccess", null);
|
|
1066
|
-
__decorate([
|
|
1067
|
-
Mutation(returns => PaymentRequestResult),
|
|
1068
|
-
__metadata("design:type", Function),
|
|
1069
|
-
__metadata("design:paramtypes", []),
|
|
1070
|
-
__metadata("design:returntype", PaymentRequestResult)
|
|
1071
|
-
], RuntimeResolver.prototype, "runtimeReinstallUnytDna", null);
|
|
1072
|
-
__decorate([
|
|
1073
|
-
Mutation(returns => PaymentRequestResult),
|
|
1074
|
-
__param(0, Arg("recipient")),
|
|
1075
|
-
__param(1, Arg("amount")),
|
|
1076
|
-
__metadata("design:type", Function),
|
|
1077
|
-
__metadata("design:paramtypes", [String, String]),
|
|
1078
|
-
__metadata("design:returntype", PaymentRequestResult)
|
|
1079
|
-
], RuntimeResolver.prototype, "runtimeSendHot", null);
|
|
1080
|
-
__decorate([
|
|
1081
|
-
Mutation(returns => PaymentRequestResult),
|
|
1082
|
-
__param(0, Arg("proof")),
|
|
1083
|
-
__metadata("design:type", Function),
|
|
1084
|
-
__metadata("design:paramtypes", [String]),
|
|
1085
|
-
__metadata("design:returntype", PaymentRequestResult)
|
|
1086
|
-
], RuntimeResolver.prototype, "runtimeSetUnytMembraneProof", null);
|
|
1087
|
-
__decorate([
|
|
1088
|
-
Query(returns => String),
|
|
1089
|
-
__metadata("design:type", Function),
|
|
1090
|
-
__metadata("design:paramtypes", []),
|
|
1091
|
-
__metadata("design:returntype", String)
|
|
1092
|
-
], RuntimeResolver.prototype, "runtimeHotWalletBalance", null);
|
|
1093
|
-
__decorate([
|
|
1094
|
-
Query(returns => String),
|
|
1095
|
-
__param(0, Arg("page", { nullable: true })),
|
|
1096
|
-
__param(1, Arg("perPage", { nullable: true })),
|
|
1097
|
-
__metadata("design:type", Function),
|
|
1098
|
-
__metadata("design:paramtypes", [Number, Number]),
|
|
1099
|
-
__metadata("design:returntype", String)
|
|
1100
|
-
], RuntimeResolver.prototype, "runtimeHotWalletHistory", null);
|
|
1101
|
-
__decorate([
|
|
1102
|
-
Query(returns => String),
|
|
1103
|
-
__metadata("design:type", Function),
|
|
1104
|
-
__metadata("design:paramtypes", []),
|
|
1105
|
-
__metadata("design:returntype", String)
|
|
1106
|
-
], RuntimeResolver.prototype, "runtimeHotAgentPubkey", null);
|
|
1107
|
-
__decorate([
|
|
1108
|
-
Query(returns => String),
|
|
1109
|
-
__metadata("design:type", Function),
|
|
1110
|
-
__metadata("design:paramtypes", []),
|
|
1111
|
-
__metadata("design:returntype", String)
|
|
1112
|
-
], RuntimeResolver.prototype, "runtimeUnytAgentKey", null);
|
|
1113
|
-
__decorate([
|
|
1114
|
-
Query(returns => String),
|
|
1115
|
-
__metadata("design:type", Function),
|
|
1116
|
-
__metadata("design:paramtypes", []),
|
|
1117
|
-
__metadata("design:returntype", String)
|
|
1118
|
-
], RuntimeResolver.prototype, "runtimeUnytVersionInfo", null);
|
|
1119
926
|
RuntimeResolver = __decorate([
|
|
1120
927
|
Resolver()
|
|
1121
928
|
], RuntimeResolver);
|
package/lib/src/schema.gql
CHANGED
|
@@ -93,16 +93,6 @@ input CapabilityInput {
|
|
|
93
93
|
with: ResourceInput!
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
type ComputeLogEntry {
|
|
97
|
-
cost: Float!
|
|
98
|
-
creditsAfter: Float!
|
|
99
|
-
id: Float!
|
|
100
|
-
operation: String!
|
|
101
|
-
summary: String
|
|
102
|
-
timestamp: String!
|
|
103
|
-
userEmail: String!
|
|
104
|
-
}
|
|
105
|
-
|
|
106
96
|
# The javascript `Date` as string. Type represents date and time as the ISO Date string.
|
|
107
97
|
scalar DateTime
|
|
108
98
|
|
|
@@ -156,7 +146,6 @@ type ExpressionRendered {
|
|
|
156
146
|
|
|
157
147
|
type HostingUserInfo {
|
|
158
148
|
email: String!
|
|
159
|
-
freeAccess: Boolean!
|
|
160
149
|
hotWalletAddress: String
|
|
161
150
|
remainingCredits: String!
|
|
162
151
|
}
|
|
@@ -391,7 +380,6 @@ type Mutation {
|
|
|
391
380
|
runtimeLoginUser(email: String!, password: String!): String!
|
|
392
381
|
runtimeOpenLink(url: String!): Boolean!
|
|
393
382
|
runtimeQuit: Boolean!
|
|
394
|
-
runtimeReinstallUnytDna: PaymentRequestResult!
|
|
395
383
|
runtimeRemoveFriends(dids: [String!]!): [String!]!
|
|
396
384
|
runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
|
|
397
385
|
runtimeRemoveNotification(id: String!): Boolean!
|
|
@@ -399,14 +387,9 @@ type Mutation {
|
|
|
399
387
|
runtimeRequestLoginVerification(appInfo: AuthInfoInput, email: String!): VerificationRequestResult!
|
|
400
388
|
runtimeRequestPayment(amountHOT: String!): PaymentRequestResult!
|
|
401
389
|
runtimeRestartHolochain: Boolean!
|
|
402
|
-
runtimeSendHot(amount: String!, recipient: String!): PaymentRequestResult!
|
|
403
|
-
runtimeSetFreeHostingEnabled(enabled: Boolean!): Boolean!
|
|
404
390
|
runtimeSetHotWalletAddress(address: String!): Boolean!
|
|
405
391
|
runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
|
|
406
392
|
runtimeSetStatus(status: PerspectiveInput!): Boolean!
|
|
407
|
-
runtimeSetUnytMembraneProof(proof: String!): PaymentRequestResult!
|
|
408
|
-
runtimeSetUserCredits(amount: Float!, email: String!): Boolean!
|
|
409
|
-
runtimeSetUserFreeAccess(email: String!, enabled: Boolean!): Boolean!
|
|
410
393
|
runtimeTestEmail(to: String!): Boolean!
|
|
411
394
|
runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
|
|
412
395
|
runtimeVerifyEmailCode(code: String!, email: String!, verificationType: String!): String!
|
|
@@ -512,18 +495,14 @@ type Query {
|
|
|
512
495
|
perspective(uuid: String!): PerspectiveHandle
|
|
513
496
|
perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!]
|
|
514
497
|
perspectiveQueryProlog(query: String!, uuid: String!): String!
|
|
498
|
+
perspectiveQuerySurrealDB(query: String!, uuid: String!): String!
|
|
515
499
|
perspectiveSnapshot(uuid: String!): Perspective
|
|
516
500
|
perspectives: [PerspectiveHandle!]!
|
|
517
|
-
runtimeComputeLog(limit: Float, since: String, userEmail: String): [ComputeLogEntry!]!
|
|
518
|
-
runtimeFreeHostingEnabled: Boolean!
|
|
519
501
|
runtimeFriendStatus(did: String!): PerspectiveExpression
|
|
520
502
|
runtimeFriends: [String!]!
|
|
521
503
|
runtimeGetNetworkMetrics: String!
|
|
522
504
|
runtimeHcAgentInfos: String!
|
|
523
505
|
runtimeHostingUserInfo: HostingUserInfo!
|
|
524
|
-
runtimeHotAgentPubkey: String!
|
|
525
|
-
runtimeHotWalletBalance: String!
|
|
526
|
-
runtimeHotWalletHistory(page: Float, perPage: Float): String!
|
|
527
506
|
runtimeInfo: RuntimeInfo!
|
|
528
507
|
runtimeKnownLinkLanguageTemplates: [String!]!
|
|
529
508
|
runtimeListUsers: [UserStatistics!]!
|
|
@@ -531,8 +510,6 @@ type Query {
|
|
|
531
510
|
runtimeMessageOutbox(filter: String): [SentMessage!]!
|
|
532
511
|
runtimeMultiUserEnabled: Boolean!
|
|
533
512
|
runtimeNotifications: [Notification!]!
|
|
534
|
-
runtimeUnytAgentKey: String!
|
|
535
|
-
runtimeUnytVersionInfo: String!
|
|
536
513
|
runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
|
|
537
514
|
}
|
|
538
515
|
|
|
@@ -608,11 +585,8 @@ type UserCreationResult {
|
|
|
608
585
|
type UserStatistics {
|
|
609
586
|
did: String!
|
|
610
587
|
email: String!
|
|
611
|
-
freeAccess: Boolean!
|
|
612
|
-
hotWalletAddress: String
|
|
613
588
|
lastSeen: String
|
|
614
589
|
perspectiveCount: Int!
|
|
615
|
-
remainingCredits: String!
|
|
616
590
|
}
|
|
617
591
|
|
|
618
592
|
type VerificationRequestResult {
|
|
@@ -333,86 +333,4 @@ describe('SHACLShape', () => {
|
|
|
333
333
|
expect(prop.remover).toEqual(original.properties[0].remover);
|
|
334
334
|
});
|
|
335
335
|
});
|
|
336
|
-
describe('sh:in round-trip', () => {
|
|
337
|
-
it('preserves sh:in enum values through toLinks() → fromLinks()', () => {
|
|
338
|
-
const original = new SHACLShape('test://Model');
|
|
339
|
-
original.addProperty({
|
|
340
|
-
name: 'status',
|
|
341
|
-
path: 'test://status',
|
|
342
|
-
datatype: 'xsd:string',
|
|
343
|
-
in: [
|
|
344
|
-
{ value: 'active', label: 'Active' },
|
|
345
|
-
{ value: 'inactive', label: 'Inactive' },
|
|
346
|
-
{ value: 'archived' },
|
|
347
|
-
],
|
|
348
|
-
});
|
|
349
|
-
const links = original.toLinks();
|
|
350
|
-
// Verify sh:in link was created
|
|
351
|
-
const inLink = links.find(l => l.predicate === 'sh://in');
|
|
352
|
-
expect(inLink).toBeDefined();
|
|
353
|
-
expect(inLink.target).toContain('literal:string:');
|
|
354
|
-
// Reconstruct and verify
|
|
355
|
-
const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
|
|
356
|
-
expect(reconstructed.properties[0].in).toBeDefined();
|
|
357
|
-
expect(reconstructed.properties[0].in).toEqual([
|
|
358
|
-
{ value: 'active', label: 'Active' },
|
|
359
|
-
{ value: 'inactive', label: 'Inactive' },
|
|
360
|
-
{ value: 'archived' },
|
|
361
|
-
]);
|
|
362
|
-
});
|
|
363
|
-
it('handles sh:in with special characters in values', () => {
|
|
364
|
-
const original = new SHACLShape('test://Model');
|
|
365
|
-
original.addProperty({
|
|
366
|
-
name: 'category',
|
|
367
|
-
path: 'test://category',
|
|
368
|
-
in: [
|
|
369
|
-
{ value: 'food & drink', label: 'Food & Drink' },
|
|
370
|
-
{ value: 'arts/crafts' },
|
|
371
|
-
],
|
|
372
|
-
});
|
|
373
|
-
const links = original.toLinks();
|
|
374
|
-
const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
|
|
375
|
-
expect(reconstructed.properties[0].in).toEqual(original.properties[0].in);
|
|
376
|
-
});
|
|
377
|
-
it('handles sh:in with empty array (no link created)', () => {
|
|
378
|
-
const original = new SHACLShape('test://Model');
|
|
379
|
-
original.addProperty({
|
|
380
|
-
name: 'field',
|
|
381
|
-
path: 'test://field',
|
|
382
|
-
in: [],
|
|
383
|
-
});
|
|
384
|
-
const links = original.toLinks();
|
|
385
|
-
const inLink = links.find(l => l.predicate === 'sh://in');
|
|
386
|
-
expect(inLink).toBeUndefined();
|
|
387
|
-
});
|
|
388
|
-
it('handles sh:in with literal://string: prefix variant', () => {
|
|
389
|
-
// fromLinks should handle both `literal:string:` and `literal://string:` prefixes
|
|
390
|
-
const links = [
|
|
391
|
-
{ source: 'test://ModelShape', predicate: 'sh://targetClass', target: 'test://Model' },
|
|
392
|
-
{ source: 'test://ModelShape', predicate: 'sh://property', target: 'test://Model.status' },
|
|
393
|
-
{ source: 'test://Model.status', predicate: 'sh://path', target: 'test://status' },
|
|
394
|
-
{ source: 'test://Model.status', predicate: 'sh://in', target: 'literal://string:[{"value":"a"},{"value":"b"}]' },
|
|
395
|
-
];
|
|
396
|
-
const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
|
|
397
|
-
expect(reconstructed.properties[0].in).toEqual([
|
|
398
|
-
{ value: 'a' },
|
|
399
|
-
{ value: 'b' },
|
|
400
|
-
]);
|
|
401
|
-
});
|
|
402
|
-
it('preserves sh:in through toJSON() → fromJSON()', () => {
|
|
403
|
-
const original = new SHACLShape('test://Model');
|
|
404
|
-
original.addProperty({
|
|
405
|
-
name: 'priority',
|
|
406
|
-
path: 'test://priority',
|
|
407
|
-
in: [
|
|
408
|
-
{ value: 'high', label: 'High' },
|
|
409
|
-
{ value: 'medium', label: 'Medium' },
|
|
410
|
-
{ value: 'low', label: 'Low' },
|
|
411
|
-
],
|
|
412
|
-
});
|
|
413
|
-
const json = original.toJSON();
|
|
414
|
-
const reconstructed = SHACLShape.fromJSON(json);
|
|
415
|
-
expect(reconstructed.properties[0].in).toEqual(original.properties[0].in);
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
336
|
});
|
package/package.json
CHANGED
package/src/Ad4mClient.test.ts
CHANGED
|
@@ -148,9 +148,14 @@ const MOCK_RESPONSES: Record<string, RpcHandler> = {
|
|
|
148
148
|
language: { address: 'lang://test' }, proof: { valid: true },
|
|
149
149
|
};
|
|
150
150
|
},
|
|
151
|
-
'expression.getMany':
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
'expression.getMany': (p: Record<string, unknown>) => {
|
|
152
|
+
// Return one result per URL (aligned by index), matching real API behavior
|
|
153
|
+
const urls = (p.urls || []) as string[];
|
|
154
|
+
return urls.map((url: string) => ({
|
|
155
|
+
author: 'did:test:1', timestamp: '2023-01-01', data: { type: 'test' },
|
|
156
|
+
language: { address: 'lang://test' }, proof: { valid: true },
|
|
157
|
+
}));
|
|
158
|
+
},
|
|
154
159
|
'expression.create': 'Qm-expression-hash',
|
|
155
160
|
'expression.interactions': [{ label: 'interact1', name: 'doSomething', parameters: [] }],
|
|
156
161
|
'expression.interact': 'interaction-result',
|
|
@@ -348,6 +353,9 @@ afterAll(() => {
|
|
|
348
353
|
beforeEach(() => {
|
|
349
354
|
lastRpcCall = null;
|
|
350
355
|
MockWebSocket.instances = [];
|
|
356
|
+
// Clear caches to prevent cross-test interference
|
|
357
|
+
ad4m.agent.clearByDidCache();
|
|
358
|
+
ad4m.expression.clearCache();
|
|
351
359
|
});
|
|
352
360
|
|
|
353
361
|
// ===================== AGENT TESTS =====================
|
|
@@ -857,7 +865,9 @@ describe('ExpressionClient', () => {
|
|
|
857
865
|
|
|
858
866
|
test('getMany() returns multiple expressions', async () => {
|
|
859
867
|
const exprs = await ad4m.expression.getMany(['url1', 'url2']);
|
|
860
|
-
expect(exprs).toHaveLength(
|
|
868
|
+
expect(exprs).toHaveLength(2);
|
|
869
|
+
expect(exprs[0].author).toBe('did:test:1');
|
|
870
|
+
expect(exprs[1].author).toBe('did:test:1');
|
|
861
871
|
});
|
|
862
872
|
|
|
863
873
|
test('getRaw() returns raw expression', async () => {
|
package/src/Ad4mClient.ts
CHANGED
|
@@ -90,8 +90,9 @@ export class Ad4mClient {
|
|
|
90
90
|
this.#agentClient.subscribeAppsChanged()
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
/** Close all event connections */
|
|
93
|
+
/** Close all event connections and clear in-memory caches */
|
|
94
94
|
close(): void {
|
|
95
|
+
this.#agentClient.clearByDidCache()
|
|
95
96
|
this.#apiClient.closeAll()
|
|
96
97
|
}
|
|
97
98
|
}
|