@coasys/ad4m 0.13.0-test-1 → 0.13.0-test-3

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.
Files changed (115) hide show
  1. package/lib/index.cjs +2377 -849
  2. package/lib/index.js +2354 -846
  3. package/lib/src/Literal.js +6 -5
  4. package/lib/src/agent/AgentClient.d.ts +5 -1
  5. package/lib/src/agent/AgentClient.js +48 -2
  6. package/lib/src/expression/ExpressionRef.js +2 -2
  7. package/lib/src/index.d.ts +0 -1
  8. package/lib/src/index.js +0 -1
  9. package/lib/src/language/Language.d.ts +26 -176
  10. package/lib/src/language/Language.js +28 -2
  11. package/lib/src/model/Ad4mModel.d.ts +52 -28
  12. package/lib/src/model/Ad4mModel.js +255 -118
  13. package/lib/src/model/Ad4mModel.test.js +1727 -537
  14. package/lib/src/model/ModelQueryBuilder.d.ts +67 -34
  15. package/lib/src/model/ModelQueryBuilder.js +208 -79
  16. package/lib/src/model/Subject.js +6 -6
  17. package/lib/src/model/decorators.d.ts +14 -8
  18. package/lib/src/model/decorators.js +41 -14
  19. package/lib/src/model/hydration-batch.d.ts +34 -0
  20. package/lib/src/model/hydration-batch.js +147 -0
  21. package/lib/src/model/hydration-batching.test.d.ts +7 -0
  22. package/lib/src/model/hydration-batching.test.js +456 -0
  23. package/lib/src/model/hydration.d.ts +4 -3
  24. package/lib/src/model/hydration.js +365 -86
  25. package/lib/src/model/index.d.ts +4 -1
  26. package/lib/src/model/index.js +4 -1
  27. package/lib/src/model/json-schema.js +2 -2
  28. package/lib/src/model/query-cache.d.ts +30 -0
  29. package/lib/src/model/query-cache.js +66 -0
  30. package/lib/src/model/query-cache.test.d.ts +1 -0
  31. package/lib/src/model/query-cache.test.js +43 -0
  32. package/lib/src/model/query-common.d.ts +1 -1
  33. package/lib/src/model/query-common.js +1 -1
  34. package/lib/src/model/query-sparql-batch.d.ts +17 -0
  35. package/lib/src/model/query-sparql-batch.js +260 -0
  36. package/lib/src/model/query-sparql.d.ts +124 -0
  37. package/lib/src/model/query-sparql.js +767 -0
  38. package/lib/src/model/query-sparql.test.d.ts +1 -0
  39. package/lib/src/model/query-sparql.test.js +495 -0
  40. package/lib/src/model/{surreal-utils.d.ts → query-utils.d.ts} +12 -9
  41. package/lib/src/model/{surreal-utils.js → query-utils.js} +43 -27
  42. package/lib/src/model/relation-filtering.test.js +15 -15
  43. package/lib/src/model/sdna.js +1 -1
  44. package/lib/src/model/shacl-gen.js +42 -18
  45. package/lib/src/model/subscription-delta.test.d.ts +24 -0
  46. package/lib/src/model/subscription-delta.test.js +180 -0
  47. package/lib/src/model/subscription-pool.d.ts +39 -0
  48. package/lib/src/model/subscription-pool.js +165 -0
  49. package/lib/src/model/types.d.ts +52 -4
  50. package/lib/src/model/types.js +1 -1
  51. package/lib/src/perspectives/PerspectiveClient.d.ts +3 -17
  52. package/lib/src/perspectives/PerspectiveClient.js +42 -66
  53. package/lib/src/perspectives/PerspectiveClient.test.d.ts +1 -0
  54. package/lib/src/perspectives/PerspectiveClient.test.js +169 -0
  55. package/lib/src/perspectives/PerspectiveProxy.d.ts +54 -30
  56. package/lib/src/perspectives/PerspectiveProxy.js +239 -177
  57. package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
  58. package/lib/src/perspectives/PerspectiveResolver.js +0 -11
  59. package/lib/src/perspectives/WakerSubscriptionManager.d.ts +3 -3
  60. package/lib/src/perspectives/WakerSubscriptionManager.js +7 -8
  61. package/lib/src/runtime/RuntimeResolver.d.ts +11 -0
  62. package/lib/src/runtime/RuntimeResolver.js +56 -0
  63. package/lib/src/schema.gql +11 -1
  64. package/lib/src/shacl/SHACLFlow.d.ts +1 -1
  65. package/lib/src/shacl/SHACLFlow.js +9 -9
  66. package/lib/src/shacl/SHACLShape.d.ts +1 -1
  67. package/lib/src/shacl/SHACLShape.js +38 -38
  68. package/lib/src/typeDefs.js +11 -1
  69. package/lib/src/utils.d.ts +6 -6
  70. package/lib/src/utils.js +6 -6
  71. package/package.json +1 -1
  72. package/src/Ad4mClient.test.ts +56 -1
  73. package/src/Literal.test.ts +10 -5
  74. package/src/Literal.ts +6 -5
  75. package/src/agent/AgentClient.ts +53 -1
  76. package/src/expression/ExpressionRef.ts +2 -2
  77. package/src/index.ts +0 -1
  78. package/src/language/Language.ts +55 -231
  79. package/src/model/Ad4mModel.test.ts +1709 -572
  80. package/src/model/Ad4mModel.ts +274 -120
  81. package/src/model/ModelQueryBuilder.ts +234 -87
  82. package/src/model/Subject.ts +6 -6
  83. package/src/model/decorators.ts +51 -22
  84. package/src/model/hydration-batch.ts +205 -0
  85. package/src/model/hydration-batching.test.ts +563 -0
  86. package/src/model/hydration.ts +349 -84
  87. package/src/model/index.ts +4 -1
  88. package/src/model/json-schema.ts +2 -2
  89. package/src/model/query-cache.test.ts +54 -0
  90. package/src/model/query-cache.ts +79 -0
  91. package/src/model/query-common.ts +1 -1
  92. package/src/model/query-sparql-batch.ts +301 -0
  93. package/src/model/query-sparql.test.ts +568 -0
  94. package/src/model/query-sparql.ts +820 -0
  95. package/src/model/{surreal-utils.ts → query-utils.ts} +44 -27
  96. package/src/model/relation-filtering.test.ts +15 -15
  97. package/src/model/sdna.ts +1 -1
  98. package/src/model/shacl-gen.ts +42 -17
  99. package/src/model/subscription-delta.test.ts +207 -0
  100. package/src/model/subscription-pool.ts +211 -0
  101. package/src/model/types.ts +53 -4
  102. package/src/perspectives/PerspectiveClient.test.ts +204 -0
  103. package/src/perspectives/PerspectiveClient.ts +41 -68
  104. package/src/perspectives/PerspectiveProxy.ts +244 -181
  105. package/src/perspectives/PerspectiveResolver.ts +0 -8
  106. package/src/perspectives/WakerSubscriptionManager.ts +8 -9
  107. package/src/runtime/RuntimeResolver.ts +43 -0
  108. package/src/shacl/SHACLFlow.ts +9 -9
  109. package/src/shacl/SHACLShape.ts +39 -39
  110. package/src/utils.ts +6 -6
  111. package/lib/src/model/query-surreal.d.ts +0 -44
  112. package/lib/src/model/query-surreal.js +0 -249
  113. package/src/language/LanguageContext.ts +0 -37
  114. package/src/model/query-surreal.ts +0 -280
  115. package/tsconfig-browser.json +0 -82
@@ -22,7 +22,6 @@ 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>;
26
25
  perspectiveSubscribeQuery(uuid: string, query: string): Promise<QuerySubscription>;
27
26
  perspectiveAdd(name: string, pubSub: any): PerspectiveHandle;
28
27
  perspectiveUpdate(uuid: string, name: string, pubSub: any): PerspectiveHandle;
@@ -87,9 +87,6 @@ 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
- }
93
90
  async perspectiveSubscribeQuery(uuid, query) {
94
91
  const result = `[{"X": 1}]`;
95
92
  return {
@@ -277,14 +274,6 @@ __decorate([
277
274
  __metadata("design:paramtypes", [String, String]),
278
275
  __metadata("design:returntype", Promise)
279
276
  ], 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);
288
277
  __decorate([
289
278
  Mutation(returns => QuerySubscription),
290
279
  __param(0, Arg('uuid')),
@@ -1,5 +1,5 @@
1
1
  /**
2
- * WakerSubscriptionManager — manages live SurrealDB subscriptions for the waker.
2
+ * WakerSubscriptionManager — manages live query subscriptions for the waker.
3
3
  *
4
4
  * Lives in core so it can be imported by both the plugin and integration tests
5
5
  * without ESM/CJS import issues.
@@ -28,7 +28,7 @@ export interface WakerLogger {
28
28
  debug(msg: string): void;
29
29
  }
30
30
  export interface WakerSubscriptionManagerOptions {
31
- /** PerspectiveClient from Ad4mClient (provides perspectiveSubscribeSurrealQuery etc.) */
31
+ /** PerspectiveClient from Ad4mClient (provides subscribeQuery etc.) */
32
32
  perspectiveClient: any;
33
33
  /** Logger instance */
34
34
  logger: WakerLogger;
@@ -60,7 +60,7 @@ export declare class WakerSubscriptionManager {
60
60
  private seenMessages;
61
61
  constructor(options: WakerSubscriptionManagerOptions);
62
62
  /**
63
- * Create a live SurrealDB subscription.
63
+ * Create a live SPARQL subscription.
64
64
  * If a subscription with the same id already exists, it is disposed first.
65
65
  */
66
66
  subscribe(sub: WakerSubscription): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * WakerSubscriptionManager — manages live SurrealDB subscriptions for the waker.
2
+ * WakerSubscriptionManager — manages live query subscriptions for the waker.
3
3
  *
4
4
  * Lives in core so it can be imported by both the plugin and integration tests
5
5
  * without ESM/CJS import issues.
@@ -23,7 +23,7 @@ export class WakerSubscriptionManager {
23
23
  this.previousSeenMessages = options.previousSeenMessages ?? {};
24
24
  }
25
25
  /**
26
- * Create a live SurrealDB subscription.
26
+ * Create a live SPARQL subscription.
27
27
  * If a subscription with the same id already exists, it is disposed first.
28
28
  */
29
29
  async subscribe(sub) {
@@ -34,9 +34,9 @@ export class WakerSubscriptionManager {
34
34
  }
35
35
  const QuerySubscriptionProxy = this.QuerySubscriptionProxyCtor;
36
36
  this.logger.info(`[waker] ${sub.id}: creating subscription (perspective=${sub.perspective}, type=${sub.type})`);
37
- this.logger.info(`[waker] ${sub.id}: SurrealQL query:\n${sub.query}`);
37
+ this.logger.info(`[waker] ${sub.id}: SPARQL query:\n${sub.query}`);
38
38
  const proxy = new QuerySubscriptionProxy(sub.perspective, sub.query, this.perspectiveClient);
39
- proxy.isSurrealDB = true;
39
+ proxy.isSPARQL = true;
40
40
  // Suppress unhandled rejection from proxy.initialized — QuerySubscriptionProxy
41
41
  // rejects this promise internally when subscribe() fails, and if nobody catches
42
42
  // it before the next microtask it crashes the process.
@@ -69,7 +69,7 @@ export class WakerSubscriptionManager {
69
69
  }
70
70
  proxy.onResult(async (result) => {
71
71
  this.logger.info(`[waker] ${sub.id}: onResult fired — type=${typeof result}, isArray=${Array.isArray(result)}, value=${String(JSON.stringify(result)).substring(0, 500)}`);
72
- // SurrealDB can deliver non-array values (e.g. false) on disconnect/reconnect — ignore them
72
+ // Query engine can deliver non-array values (e.g. false) on disconnect/reconnect — ignore them
73
73
  if (!Array.isArray(result)) {
74
74
  this.logger.warn(`[waker] ${sub.id}: ignoring non-array result: ${JSON.stringify(result)}`);
75
75
  return;
@@ -94,10 +94,9 @@ export class WakerSubscriptionManager {
94
94
  for (const msgAddr of newMessages) {
95
95
  const parents = [];
96
96
  try {
97
- const escaped = msgAddr.replace(/'/g, "\\'");
98
- const parentQuery = `SELECT * FROM link WHERE predicate = 'ad4m://has_child' AND target = '${escaped}'`;
97
+ const parentQuery = `SELECT ?source WHERE { ?source <ad4m://has_child> <${msgAddr}> . }`;
99
98
  this.logger.info(`[waker] ${sub.id}: resolving parents for ${msgAddr}`);
100
- const parentResult = await this.perspectiveClient.querySurrealDB(sub.perspective, parentQuery);
99
+ const parentResult = await this.perspectiveClient.querySparql(sub.perspective, parentQuery);
101
100
  if (Array.isArray(parentResult)) {
102
101
  for (const link of parentResult) {
103
102
  if (link && link.source) {
@@ -90,6 +90,16 @@ export declare class PaymentRequestResult {
90
90
  message: string;
91
91
  constructor(success: boolean, message: string);
92
92
  }
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
+ }
93
103
  /**
94
104
  * Resolver classes are used here to define the GraphQL schema
95
105
  * (through the type-graphql annotations)
@@ -147,6 +157,7 @@ export default class RuntimeResolver {
147
157
  runtimeEmailTestClearCodes(): boolean;
148
158
  runtimeEmailTestSetExpiry(email: string, verificationType: string, expiresAt: number): boolean;
149
159
  runtimeHostingUserInfo(): HostingUserInfo;
160
+ runtimeComputeLog(since?: string, limit?: number, userEmail?: string): ComputeLogEntry[];
150
161
  runtimeSetHotWalletAddress(address: string): boolean;
151
162
  runtimeRequestPayment(amountHOT: string): PaymentRequestResult;
152
163
  runtimeSetUserCredits(email: string, amount: number): boolean;
@@ -375,6 +375,50 @@ PaymentRequestResult = __decorate([
375
375
  __metadata("design:paramtypes", [Boolean, String])
376
376
  ], PaymentRequestResult);
377
377
  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 };
378
422
  /**
379
423
  * Resolver classes are used here to define the GraphQL schema
380
424
  * (through the type-graphql annotations)
@@ -595,6 +639,9 @@ let RuntimeResolver = class RuntimeResolver {
595
639
  runtimeHostingUserInfo() {
596
640
  return new HostingUserInfo("test@example.com", "100000000", null, false);
597
641
  }
642
+ runtimeComputeLog(since, limit, userEmail) {
643
+ return [];
644
+ }
598
645
  runtimeSetHotWalletAddress(address) {
599
646
  return true;
600
647
  }
@@ -977,6 +1024,15 @@ __decorate([
977
1024
  __metadata("design:paramtypes", []),
978
1025
  __metadata("design:returntype", HostingUserInfo)
979
1026
  ], 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);
980
1036
  __decorate([
981
1037
  Mutation(returns => Boolean),
982
1038
  __param(0, Arg("address")),
@@ -93,6 +93,16 @@ 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
+
96
106
  # The javascript `Date` as string. Type represents date and time as the ISO Date string.
97
107
  scalar DateTime
98
108
 
@@ -502,9 +512,9 @@ type Query {
502
512
  perspective(uuid: String!): PerspectiveHandle
503
513
  perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!]
504
514
  perspectiveQueryProlog(query: String!, uuid: String!): String!
505
- perspectiveQuerySurrealDB(query: String!, uuid: String!): String!
506
515
  perspectiveSnapshot(uuid: String!): Perspective
507
516
  perspectives: [PerspectiveHandle!]!
517
+ runtimeComputeLog(limit: Float, since: String, userEmail: String): [ComputeLogEntry!]!
508
518
  runtimeFreeHostingEnabled: Boolean!
509
519
  runtimeFriendStatus(did: String!): PerspectiveExpression
510
520
  runtimeFriends: [String!]!
@@ -147,7 +147,7 @@ export declare class SHACLFlow {
147
147
  transitionUri(fromState: string, toState: string): string;
148
148
  /**
149
149
  * Serialize the flow to AD4M links
150
- * These links can be stored in a perspective and queried via SurrealDB
150
+ * These links can be stored in a perspective and queried via SPARQL
151
151
  *
152
152
  * @returns Array of Link objects representing the flow
153
153
  */
@@ -114,7 +114,7 @@ export class SHACLFlow {
114
114
  }
115
115
  /**
116
116
  * Serialize the flow to AD4M links
117
- * These links can be stored in a perspective and queried via SurrealDB
117
+ * These links can be stored in a perspective and queried via SPARQL
118
118
  *
119
119
  * @returns Array of Link objects representing the flow
120
120
  */
@@ -145,7 +145,7 @@ export class SHACLFlow {
145
145
  links.push({
146
146
  source: flowUri,
147
147
  predicate: "ad4m://flowable",
148
- target: `literal://string:${encodeURIComponent(JSON.stringify(this.flowable))}`
148
+ target: `literal:string:${encodeURIComponent(JSON.stringify(this.flowable))}`
149
149
  });
150
150
  }
151
151
  // Start action
@@ -153,7 +153,7 @@ export class SHACLFlow {
153
153
  links.push({
154
154
  source: flowUri,
155
155
  predicate: "ad4m://startAction",
156
- target: `literal://string:${encodeURIComponent(JSON.stringify(this.startAction))}`
156
+ target: `literal:string:${encodeURIComponent(JSON.stringify(this.startAction))}`
157
157
  });
158
158
  }
159
159
  // States
@@ -187,7 +187,7 @@ export class SHACLFlow {
187
187
  links.push({
188
188
  source: stateUri,
189
189
  predicate: "ad4m://stateCheck",
190
- target: `literal://string:${encodeURIComponent(JSON.stringify(state.stateCheck))}`
190
+ target: `literal:string:${encodeURIComponent(JSON.stringify(state.stateCheck))}`
191
191
  });
192
192
  }
193
193
  // Transitions
@@ -229,7 +229,7 @@ export class SHACLFlow {
229
229
  links.push({
230
230
  source: transitionUri,
231
231
  predicate: "ad4m://transitionActions",
232
- target: `literal://string:${encodeURIComponent(JSON.stringify(transition.actions))}`
232
+ target: `literal:string:${encodeURIComponent(JSON.stringify(transition.actions))}`
233
233
  });
234
234
  }
235
235
  return links;
@@ -261,7 +261,7 @@ export class SHACLFlow {
261
261
  }
262
262
  else {
263
263
  try {
264
- const jsonStr = flowableLink.target.replace('literal://string:', '');
264
+ const jsonStr = flowableLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
265
265
  flow.flowable = JSON.parse(decodeURIComponent(jsonStr));
266
266
  }
267
267
  catch {
@@ -273,7 +273,7 @@ export class SHACLFlow {
273
273
  const startActionLink = links.find(l => l.source === flowUri && l.predicate === "ad4m://startAction");
274
274
  if (startActionLink) {
275
275
  try {
276
- const jsonStr = startActionLink.target.replace('literal://string:', '');
276
+ const jsonStr = startActionLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
277
277
  flow.startAction = JSON.parse(decodeURIComponent(jsonStr));
278
278
  }
279
279
  catch {
@@ -299,7 +299,7 @@ export class SHACLFlow {
299
299
  let stateCheck = { predicate: "", target: "" };
300
300
  if (checkLink) {
301
301
  try {
302
- const jsonStr = checkLink.target.replace('literal://string:', '');
302
+ const jsonStr = checkLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
303
303
  stateCheck = JSON.parse(decodeURIComponent(jsonStr));
304
304
  }
305
305
  catch {
@@ -328,7 +328,7 @@ export class SHACLFlow {
328
328
  let actions = [];
329
329
  if (actionsLink) {
330
330
  try {
331
- const jsonStr = actionsLink.target.replace('literal://string:', '');
331
+ const jsonStr = actionsLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
332
332
  actions = JSON.parse(decodeURIComponent(jsonStr));
333
333
  }
334
334
  catch {
@@ -58,7 +58,7 @@ export interface SHACLPropertyShape {
58
58
  adder?: AD4MAction[];
59
59
  /** AD4M-specific: Remover action for collection properties */
60
60
  remover?: AD4MAction[];
61
- /** AD4M-specific: Pre-computed SurrealQL getter expression for reading this relation/property.
61
+ /** AD4M-specific: Pre-computed SPARQL getter expression for reading this relation/property.
62
62
  * For relations with a target model, this encodes conformance filtering
63
63
  * so that Rust/MCP can execute the exact same query as the JS runtime. */
64
64
  getter?: string;
@@ -217,7 +217,7 @@ export class SHACLShape {
217
217
  links.push({
218
218
  source: this.nodeShapeUri,
219
219
  predicate: "ad4m://constructor",
220
- target: `literal://string:${JSON.stringify(this.constructor_actions)}`
220
+ target: `literal:string:${JSON.stringify(this.constructor_actions)}`
221
221
  });
222
222
  }
223
223
  // Destructor actions — same rationale as constructor.
@@ -225,7 +225,7 @@ export class SHACLShape {
225
225
  links.push({
226
226
  source: this.nodeShapeUri,
227
227
  predicate: "ad4m://destructor",
228
- target: `literal://string:${JSON.stringify(this.destructor_actions)}`
228
+ target: `literal:string:${JSON.stringify(this.destructor_actions)}`
229
229
  });
230
230
  }
231
231
  // Property shapes (each gets a named URI: {namespace}/{ClassName}.{propertyName})
@@ -275,42 +275,42 @@ export class SHACLShape {
275
275
  links.push({
276
276
  source: propShapeId,
277
277
  predicate: "sh://minCount",
278
- target: `literal://${prop.minCount}^^xsd:integer`
278
+ target: `literal:${prop.minCount}^^xsd:integer`
279
279
  });
280
280
  }
281
281
  if (prop.maxCount !== undefined) {
282
282
  links.push({
283
283
  source: propShapeId,
284
284
  predicate: "sh://maxCount",
285
- target: `literal://${prop.maxCount}^^xsd:integer`
285
+ target: `literal:${prop.maxCount}^^xsd:integer`
286
286
  });
287
287
  }
288
288
  if (prop.pattern) {
289
289
  links.push({
290
290
  source: propShapeId,
291
291
  predicate: "sh://pattern",
292
- target: `literal://${prop.pattern}`
292
+ target: `literal:${prop.pattern}`
293
293
  });
294
294
  }
295
295
  if (prop.minInclusive !== undefined) {
296
296
  links.push({
297
297
  source: propShapeId,
298
298
  predicate: "sh://minInclusive",
299
- target: `literal://${prop.minInclusive}`
299
+ target: `literal:${prop.minInclusive}`
300
300
  });
301
301
  }
302
302
  if (prop.maxInclusive !== undefined) {
303
303
  links.push({
304
304
  source: propShapeId,
305
305
  predicate: "sh://maxInclusive",
306
- target: `literal://${prop.maxInclusive}`
306
+ target: `literal:${prop.maxInclusive}`
307
307
  });
308
308
  }
309
309
  if (prop.hasValue) {
310
310
  links.push({
311
311
  source: propShapeId,
312
312
  predicate: "sh://hasValue",
313
- target: `literal://${prop.hasValue}`
313
+ target: `literal:${prop.hasValue}`
314
314
  });
315
315
  }
316
316
  // AD4M-specific metadata
@@ -318,21 +318,21 @@ export class SHACLShape {
318
318
  links.push({
319
319
  source: propShapeId,
320
320
  predicate: "ad4m://local",
321
- target: `literal://${prop.local}`
321
+ target: `literal:${prop.local}`
322
322
  });
323
323
  }
324
324
  if (prop.writable !== undefined) {
325
325
  links.push({
326
326
  source: propShapeId,
327
327
  predicate: "ad4m://writable",
328
- target: `literal://${prop.writable}`
328
+ target: `literal:${prop.writable}`
329
329
  });
330
330
  }
331
331
  if (prop.resolveLanguage) {
332
332
  links.push({
333
333
  source: propShapeId,
334
334
  predicate: "ad4m://resolveLanguage",
335
- target: `literal://string:${prop.resolveLanguage}`
335
+ target: `literal:string:${prop.resolveLanguage}`
336
336
  });
337
337
  }
338
338
  // AD4M-specific actions
@@ -340,35 +340,35 @@ export class SHACLShape {
340
340
  links.push({
341
341
  source: propShapeId,
342
342
  predicate: "ad4m://setter",
343
- target: `literal://string:${JSON.stringify(prop.setter)}`
343
+ target: `literal:string:${JSON.stringify(prop.setter)}`
344
344
  });
345
345
  }
346
346
  if (prop.adder && prop.adder.length > 0) {
347
347
  links.push({
348
348
  source: propShapeId,
349
349
  predicate: "ad4m://adder",
350
- target: `literal://string:${JSON.stringify(prop.adder)}`
350
+ target: `literal:string:${JSON.stringify(prop.adder)}`
351
351
  });
352
352
  }
353
353
  if (prop.remover && prop.remover.length > 0) {
354
354
  links.push({
355
355
  source: propShapeId,
356
356
  predicate: "ad4m://remover",
357
- target: `literal://string:${JSON.stringify(prop.remover)}`
357
+ target: `literal:string:${JSON.stringify(prop.remover)}`
358
358
  });
359
359
  }
360
360
  if (prop.getter) {
361
361
  links.push({
362
362
  source: propShapeId,
363
363
  predicate: "ad4m://getter",
364
- target: `literal://string:${prop.getter}`
364
+ target: `literal:string:${prop.getter}`
365
365
  });
366
366
  }
367
367
  if (prop.conformanceConditions && prop.conformanceConditions.length > 0) {
368
368
  links.push({
369
369
  source: propShapeId,
370
370
  predicate: "ad4m://conformanceConditions",
371
- target: `literal://string:${JSON.stringify(prop.conformanceConditions)}`
371
+ target: `literal:string:${JSON.stringify(prop.conformanceConditions)}`
372
372
  });
373
373
  }
374
374
  if (prop.class) {
@@ -392,7 +392,7 @@ export class SHACLShape {
392
392
  const constructorLink = links.find(l => l.source === shapeUri && l.predicate === "ad4m://constructor");
393
393
  if (constructorLink) {
394
394
  try {
395
- const jsonStr = constructorLink.target.replace('literal://string:', '');
395
+ const jsonStr = constructorLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
396
396
  shape.constructor_actions = JSON.parse(jsonStr);
397
397
  }
398
398
  catch (e) {
@@ -403,7 +403,7 @@ export class SHACLShape {
403
403
  const destructorLink = links.find(l => l.source === shapeUri && l.predicate === "ad4m://destructor");
404
404
  if (destructorLink) {
405
405
  try {
406
- const jsonStr = destructorLink.target.replace('literal://string:', '');
406
+ const jsonStr = destructorLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
407
407
  shape.destructor_actions = JSON.parse(jsonStr);
408
408
  }
409
409
  catch (e) {
@@ -441,70 +441,70 @@ export class SHACLShape {
441
441
  }
442
442
  const minCountLink = links.find(l => l.source === propShapeId && l.predicate === "sh://minCount");
443
443
  if (minCountLink) {
444
- // Handle both formats: literal://5^^xsd:integer and literal://number:5
445
- let val = minCountLink.target.replace('literal://', '').replace(/\^\^.*$/, '');
444
+ // Handle both formats: literal:5^^xsd:integer and literal:number:5
445
+ let val = minCountLink.target.replace(/^literal:\/\/|^literal:/, '').replace(/\^\^.*$/, '');
446
446
  if (val.startsWith('number:'))
447
447
  val = val.substring(7);
448
448
  prop.minCount = parseInt(val);
449
449
  }
450
450
  const maxCountLink = links.find(l => l.source === propShapeId && l.predicate === "sh://maxCount");
451
451
  if (maxCountLink) {
452
- // Handle both formats: literal://5^^xsd:integer and literal://number:5
453
- let val = maxCountLink.target.replace('literal://', '').replace(/\^\^.*$/, '');
452
+ // Handle both formats: literal:5^^xsd:integer and literal:number:5
453
+ let val = maxCountLink.target.replace(/^literal:\/\/|^literal:/, '').replace(/\^\^.*$/, '');
454
454
  if (val.startsWith('number:'))
455
455
  val = val.substring(7);
456
456
  prop.maxCount = parseInt(val);
457
457
  }
458
458
  const patternLink = links.find(l => l.source === propShapeId && l.predicate === "sh://pattern");
459
459
  if (patternLink) {
460
- prop.pattern = patternLink.target.replace('literal://', '');
460
+ prop.pattern = patternLink.target.replace(/^literal:\/\/|^literal:/, '');
461
461
  }
462
462
  const minInclusiveLink = links.find(l => l.source === propShapeId && l.predicate === "sh://minInclusive");
463
463
  if (minInclusiveLink) {
464
- // Handle both formats: literal://5 and literal://number:5
465
- let val = minInclusiveLink.target.replace('literal://', '');
464
+ // Handle both formats: literal:5 and literal:number:5
465
+ let val = minInclusiveLink.target.replace(/^literal:\/\/|^literal:/, '');
466
466
  if (val.startsWith('number:'))
467
467
  val = val.substring(7);
468
468
  prop.minInclusive = parseFloat(val);
469
469
  }
470
470
  const maxInclusiveLink = links.find(l => l.source === propShapeId && l.predicate === "sh://maxInclusive");
471
471
  if (maxInclusiveLink) {
472
- // Handle both formats: literal://5 and literal://number:5
473
- let val = maxInclusiveLink.target.replace('literal://', '');
472
+ // Handle both formats: literal:5 and literal:number:5
473
+ let val = maxInclusiveLink.target.replace(/^literal:\/\/|^literal:/, '');
474
474
  if (val.startsWith('number:'))
475
475
  val = val.substring(7);
476
476
  prop.maxInclusive = parseFloat(val);
477
477
  }
478
478
  const hasValueLink = links.find(l => l.source === propShapeId && l.predicate === "sh://hasValue");
479
479
  if (hasValueLink) {
480
- prop.hasValue = hasValueLink.target.replace('literal://', '');
480
+ prop.hasValue = hasValueLink.target.replace(/^literal:\/\/|^literal:/, '');
481
481
  }
482
482
  // AD4M-specific
483
483
  const localLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://local");
484
484
  if (localLink) {
485
- // Handle both formats: literal://true and literal://boolean:true
486
- let val = localLink.target.replace('literal://', '');
485
+ // Handle both formats: literal:true and literal:boolean:true
486
+ let val = localLink.target.replace(/^literal:\/\/|^literal:/, '');
487
487
  if (val.startsWith('boolean:'))
488
488
  val = val.substring(8);
489
489
  prop.local = val === 'true';
490
490
  }
491
491
  const writableLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://writable");
492
492
  if (writableLink) {
493
- // Handle both formats: literal://true and literal://boolean:true
494
- let val = writableLink.target.replace('literal://', '');
493
+ // Handle both formats: literal:true and literal:boolean:true
494
+ let val = writableLink.target.replace(/^literal:\/\/|^literal:/, '');
495
495
  if (val.startsWith('boolean:'))
496
496
  val = val.substring(8);
497
497
  prop.writable = val === 'true';
498
498
  }
499
499
  const resolveLangLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://resolveLanguage");
500
500
  if (resolveLangLink) {
501
- prop.resolveLanguage = resolveLangLink.target.replace('literal://string:', '');
501
+ prop.resolveLanguage = resolveLangLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
502
502
  }
503
503
  // Parse action arrays
504
504
  const setterLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://setter");
505
505
  if (setterLink) {
506
506
  try {
507
- const jsonStr = setterLink.target.replace('literal://string:', '');
507
+ const jsonStr = setterLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
508
508
  prop.setter = JSON.parse(jsonStr);
509
509
  }
510
510
  catch (e) {
@@ -514,7 +514,7 @@ export class SHACLShape {
514
514
  const adderLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://adder");
515
515
  if (adderLink) {
516
516
  try {
517
- const jsonStr = adderLink.target.replace('literal://string:', '');
517
+ const jsonStr = adderLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
518
518
  prop.adder = JSON.parse(jsonStr);
519
519
  }
520
520
  catch (e) {
@@ -524,7 +524,7 @@ export class SHACLShape {
524
524
  const removerLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://remover");
525
525
  if (removerLink) {
526
526
  try {
527
- const jsonStr = removerLink.target.replace('literal://string:', '');
527
+ const jsonStr = removerLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
528
528
  prop.remover = JSON.parse(jsonStr);
529
529
  }
530
530
  catch (e) {
@@ -533,12 +533,12 @@ export class SHACLShape {
533
533
  }
534
534
  const getterLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://getter");
535
535
  if (getterLink) {
536
- prop.getter = getterLink.target.replace('literal://string:', '');
536
+ prop.getter = getterLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
537
537
  }
538
538
  const conditionsLink = links.find(l => l.source === propShapeId && l.predicate === "ad4m://conformanceConditions");
539
539
  if (conditionsLink) {
540
540
  try {
541
- const jsonStr = conditionsLink.target.replace('literal://string:', '');
541
+ const jsonStr = conditionsLink.target.replace(/^literal:\/\/string:|^literal:string:/, '');
542
542
  prop.conformanceConditions = JSON.parse(jsonStr);
543
543
  }
544
544
  catch (e) {
@@ -90,6 +90,16 @@ input CapabilityInput {
90
90
  with: ResourceInput!
91
91
  }
92
92
 
93
+ type ComputeLogEntry {
94
+ cost: Float!
95
+ creditsAfter: Float!
96
+ id: Float!
97
+ operation: String!
98
+ summary: String
99
+ timestamp: String!
100
+ userEmail: String!
101
+ }
102
+
93
103
  scalar DateTime
94
104
 
95
105
  type EntanglementProof {
@@ -498,9 +508,9 @@ type Query {
498
508
  perspective(uuid: String!): PerspectiveHandle
499
509
  perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!]
500
510
  perspectiveQueryProlog(query: String!, uuid: String!): String!
501
- perspectiveQuerySurrealDB(query: String!, uuid: String!): String!
502
511
  perspectiveSnapshot(uuid: String!): Perspective
503
512
  perspectives: [PerspectiveHandle!]!
513
+ runtimeComputeLog(limit: Float, since: String, userEmail: String): [ComputeLogEntry!]!
504
514
  runtimeFreeHostingEnabled: Boolean!
505
515
  runtimeFriendStatus(did: String!): PerspectiveExpression
506
516
  runtimeFriends: [String!]!