@coasys/ad4m 0.10.0-prerelease → 0.10.0-rc2

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 CHANGED
@@ -6375,12 +6375,10 @@ class RuntimeClient {
6375
6375
  __classPrivateFieldSet$4(this, _RuntimeClient_messageReceivedCallbacks, [], "f");
6376
6376
  __classPrivateFieldSet$4(this, _RuntimeClient_exceptionOccurredCallbacks, [], "f");
6377
6377
  __classPrivateFieldSet$4(this, _RuntimeClient_notificationTriggeredCallbacks, [], "f");
6378
- __classPrivateFieldSet$4(this, _RuntimeClient_notificationRequestedCallbacks, [], "f");
6379
6378
  if (subscribe) {
6380
6379
  this.subscribeMessageReceived();
6381
6380
  this.subscribeExceptionOccurred();
6382
6381
  this.subscribeNotificationTriggered();
6383
- this.subscribeNotificationRequested();
6384
6382
  }
6385
6383
  }
6386
6384
  async info() {
@@ -6611,9 +6609,6 @@ class RuntimeClient {
6611
6609
  addNotificationTriggeredCallback(cb) {
6612
6610
  __classPrivateFieldGet$4(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
6613
6611
  }
6614
- addNotificationRequestedCallback(cb) {
6615
- __classPrivateFieldGet$4(this, _RuntimeClient_notificationRequestedCallbacks, "f").push(cb);
6616
- }
6617
6612
  subscribeNotificationTriggered() {
6618
6613
  __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").subscribe({
6619
6614
  query: gql ` subscription {
@@ -6629,21 +6624,6 @@ class RuntimeClient {
6629
6624
  error: (e) => console.error(e)
6630
6625
  });
6631
6626
  }
6632
- subscribeNotificationRequested() {
6633
- __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").subscribe({
6634
- query: gql ` subscription {
6635
- runtimeNotificationRequested { ${NOTIFICATION_FIELDS} }
6636
- }
6637
- `
6638
- }).subscribe({
6639
- next: result => {
6640
- __classPrivateFieldGet$4(this, _RuntimeClient_notificationRequestedCallbacks, "f").forEach(cb => {
6641
- cb(result.data.runtimeNotificationRequested);
6642
- });
6643
- },
6644
- error: (e) => console.error(e)
6645
- });
6646
- }
6647
6627
  addMessageCallback(cb) {
6648
6628
  __classPrivateFieldGet$4(this, _RuntimeClient_messageReceivedCallbacks, "f").push(cb);
6649
6629
  }
@@ -6704,7 +6684,18 @@ class ExpressionClient {
6704
6684
  _ExpressionClient_apolloClient.set(this, void 0);
6705
6685
  __classPrivateFieldSet$3(this, _ExpressionClient_apolloClient, client, "f");
6706
6686
  }
6707
- async get(url) {
6687
+ async get(url, alwaysGet = false) {
6688
+ if (!alwaysGet) {
6689
+ try {
6690
+ let literalValue = Literal.fromUrl(url).get();
6691
+ if (typeof literalValue === 'object' && literalValue !== null) {
6692
+ if ('author' in literalValue && 'timestamp' in literalValue && 'data' in literalValue && 'proof' in literalValue) {
6693
+ return literalValue;
6694
+ }
6695
+ }
6696
+ }
6697
+ catch (e) { }
6698
+ }
6708
6699
  const { expression } = unwrapApolloResult(await __classPrivateFieldGet$3(this, _ExpressionClient_apolloClient, "f").query({
6709
6700
  query: gql `query expression($url: String!) {
6710
6701
  expression(url: $url) {
@@ -8083,7 +8074,6 @@ type Subscription {
8083
8074
  perspectiveSyncStateChange(uuid: String!): String!
8084
8075
  perspectiveUpdated: PerspectiveHandle
8085
8076
  runtimeMessageReceived: PerspectiveExpression
8086
- runtimeNotificationRequested: Notification
8087
8077
  runtimeNotificationTriggered: TriggeredNotification
8088
8078
  }
8089
8079
 
@@ -8155,9 +8145,7 @@ class SubjectEntity {
8155
8145
  }
8156
8146
  async getData(id) {
8157
8147
  const tempId = id ?? __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f");
8158
- console.log("SubjectEntity: getData");
8159
8148
  let data = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").getSubjectData(__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f"), tempId);
8160
- console.log("SubjectEntity got data:", data);
8161
8149
  Object.assign(this, data);
8162
8150
  __classPrivateFieldSet(this, _SubjectEntity_baseExpression, tempId, "f");
8163
8151
  return this;
package/lib/index.js CHANGED
@@ -6371,12 +6371,10 @@ class RuntimeClient {
6371
6371
  __classPrivateFieldSet$4(this, _RuntimeClient_messageReceivedCallbacks, [], "f");
6372
6372
  __classPrivateFieldSet$4(this, _RuntimeClient_exceptionOccurredCallbacks, [], "f");
6373
6373
  __classPrivateFieldSet$4(this, _RuntimeClient_notificationTriggeredCallbacks, [], "f");
6374
- __classPrivateFieldSet$4(this, _RuntimeClient_notificationRequestedCallbacks, [], "f");
6375
6374
  if (subscribe) {
6376
6375
  this.subscribeMessageReceived();
6377
6376
  this.subscribeExceptionOccurred();
6378
6377
  this.subscribeNotificationTriggered();
6379
- this.subscribeNotificationRequested();
6380
6378
  }
6381
6379
  }
6382
6380
  async info() {
@@ -6607,9 +6605,6 @@ class RuntimeClient {
6607
6605
  addNotificationTriggeredCallback(cb) {
6608
6606
  __classPrivateFieldGet$4(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
6609
6607
  }
6610
- addNotificationRequestedCallback(cb) {
6611
- __classPrivateFieldGet$4(this, _RuntimeClient_notificationRequestedCallbacks, "f").push(cb);
6612
- }
6613
6608
  subscribeNotificationTriggered() {
6614
6609
  __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").subscribe({
6615
6610
  query: gql ` subscription {
@@ -6625,21 +6620,6 @@ class RuntimeClient {
6625
6620
  error: (e) => console.error(e)
6626
6621
  });
6627
6622
  }
6628
- subscribeNotificationRequested() {
6629
- __classPrivateFieldGet$4(this, _RuntimeClient_apolloClient, "f").subscribe({
6630
- query: gql ` subscription {
6631
- runtimeNotificationRequested { ${NOTIFICATION_FIELDS} }
6632
- }
6633
- `
6634
- }).subscribe({
6635
- next: result => {
6636
- __classPrivateFieldGet$4(this, _RuntimeClient_notificationRequestedCallbacks, "f").forEach(cb => {
6637
- cb(result.data.runtimeNotificationRequested);
6638
- });
6639
- },
6640
- error: (e) => console.error(e)
6641
- });
6642
- }
6643
6623
  addMessageCallback(cb) {
6644
6624
  __classPrivateFieldGet$4(this, _RuntimeClient_messageReceivedCallbacks, "f").push(cb);
6645
6625
  }
@@ -6700,7 +6680,18 @@ class ExpressionClient {
6700
6680
  _ExpressionClient_apolloClient.set(this, void 0);
6701
6681
  __classPrivateFieldSet$3(this, _ExpressionClient_apolloClient, client, "f");
6702
6682
  }
6703
- async get(url) {
6683
+ async get(url, alwaysGet = false) {
6684
+ if (!alwaysGet) {
6685
+ try {
6686
+ let literalValue = Literal.fromUrl(url).get();
6687
+ if (typeof literalValue === 'object' && literalValue !== null) {
6688
+ if ('author' in literalValue && 'timestamp' in literalValue && 'data' in literalValue && 'proof' in literalValue) {
6689
+ return literalValue;
6690
+ }
6691
+ }
6692
+ }
6693
+ catch (e) { }
6694
+ }
6704
6695
  const { expression } = unwrapApolloResult(await __classPrivateFieldGet$3(this, _ExpressionClient_apolloClient, "f").query({
6705
6696
  query: gql `query expression($url: String!) {
6706
6697
  expression(url: $url) {
@@ -8079,7 +8070,6 @@ type Subscription {
8079
8070
  perspectiveSyncStateChange(uuid: String!): String!
8080
8071
  perspectiveUpdated: PerspectiveHandle
8081
8072
  runtimeMessageReceived: PerspectiveExpression
8082
- runtimeNotificationRequested: Notification
8083
8073
  runtimeNotificationTriggered: TriggeredNotification
8084
8074
  }
8085
8075
 
@@ -8151,9 +8141,7 @@ class SubjectEntity {
8151
8141
  }
8152
8142
  async getData(id) {
8153
8143
  const tempId = id ?? __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f");
8154
- console.log("SubjectEntity: getData");
8155
8144
  let data = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").getSubjectData(__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f"), tempId);
8156
- console.log("SubjectEntity got data:", data);
8157
8145
  Object.assign(this, data);
8158
8146
  __classPrivateFieldSet(this, _SubjectEntity_baseExpression, tempId, "f");
8159
8147
  return this;
@@ -4,7 +4,7 @@ import { ExpressionRendered } from "./Expression";
4
4
  export declare class ExpressionClient {
5
5
  #private;
6
6
  constructor(client: ApolloClient<any>);
7
- get(url: string): Promise<ExpressionRendered>;
7
+ get(url: string, alwaysGet?: boolean): Promise<ExpressionRendered>;
8
8
  getMany(urls: string[]): Promise<ExpressionRendered[]>;
9
9
  getRaw(url: string): Promise<string>;
10
10
  create(content: any, languageAddress: string): Promise<string>;
@@ -12,12 +12,24 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  var _ExpressionClient_apolloClient;
13
13
  import { gql } from "@apollo/client/core";
14
14
  import unwrapApolloResult from "../unwrapApolloResult";
15
+ import { Literal } from "../Literal";
15
16
  export class ExpressionClient {
16
17
  constructor(client) {
17
18
  _ExpressionClient_apolloClient.set(this, void 0);
18
19
  __classPrivateFieldSet(this, _ExpressionClient_apolloClient, client, "f");
19
20
  }
20
- async get(url) {
21
+ async get(url, alwaysGet = false) {
22
+ if (!alwaysGet) {
23
+ try {
24
+ let literalValue = Literal.fromUrl(url).get();
25
+ if (typeof literalValue === 'object' && literalValue !== null) {
26
+ if ('author' in literalValue && 'timestamp' in literalValue && 'data' in literalValue && 'proof' in literalValue) {
27
+ return literalValue;
28
+ }
29
+ }
30
+ }
31
+ catch (e) { }
32
+ }
21
33
  const { expression } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
22
34
  query: gql `query expression($url: String!) {
23
35
  expression(url: $url) {
@@ -34,9 +34,7 @@ export declare class RuntimeClient {
34
34
  updateNotification(id: string, notification: NotificationInput): Promise<boolean>;
35
35
  removeNotification(id: string): Promise<boolean>;
36
36
  addNotificationTriggeredCallback(cb: NotificationTriggeredCallback): void;
37
- addNotificationRequestedCallback(cb: NotificationRequestedCallback): void;
38
37
  subscribeNotificationTriggered(): void;
39
- subscribeNotificationRequested(): void;
40
38
  addMessageCallback(cb: MessageCallback): void;
41
39
  subscribeMessageReceived(): void;
42
40
  addExceptionCallback(cb: ExceptionCallback): void;
@@ -56,12 +56,10 @@ export class RuntimeClient {
56
56
  __classPrivateFieldSet(this, _RuntimeClient_messageReceivedCallbacks, [], "f");
57
57
  __classPrivateFieldSet(this, _RuntimeClient_exceptionOccurredCallbacks, [], "f");
58
58
  __classPrivateFieldSet(this, _RuntimeClient_notificationTriggeredCallbacks, [], "f");
59
- __classPrivateFieldSet(this, _RuntimeClient_notificationRequestedCallbacks, [], "f");
60
59
  if (subscribe) {
61
60
  this.subscribeMessageReceived();
62
61
  this.subscribeExceptionOccurred();
63
62
  this.subscribeNotificationTriggered();
64
- this.subscribeNotificationRequested();
65
63
  }
66
64
  }
67
65
  async info() {
@@ -292,9 +290,6 @@ export class RuntimeClient {
292
290
  addNotificationTriggeredCallback(cb) {
293
291
  __classPrivateFieldGet(this, _RuntimeClient_notificationTriggeredCallbacks, "f").push(cb);
294
292
  }
295
- addNotificationRequestedCallback(cb) {
296
- __classPrivateFieldGet(this, _RuntimeClient_notificationRequestedCallbacks, "f").push(cb);
297
- }
298
293
  subscribeNotificationTriggered() {
299
294
  __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
300
295
  query: gql ` subscription {
@@ -310,21 +305,6 @@ export class RuntimeClient {
310
305
  error: (e) => console.error(e)
311
306
  });
312
307
  }
313
- subscribeNotificationRequested() {
314
- __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").subscribe({
315
- query: gql ` subscription {
316
- runtimeNotificationRequested { ${NOTIFICATION_FIELDS} }
317
- }
318
- `
319
- }).subscribe({
320
- next: result => {
321
- __classPrivateFieldGet(this, _RuntimeClient_notificationRequestedCallbacks, "f").forEach(cb => {
322
- cb(result.data.runtimeNotificationRequested);
323
- });
324
- },
325
- error: (e) => console.error(e)
326
- });
327
- }
328
308
  addMessageCallback(cb) {
329
309
  __classPrivateFieldGet(this, _RuntimeClient_messageReceivedCallbacks, "f").push(cb);
330
310
  }
@@ -76,6 +76,5 @@ export default class RuntimeResolver {
76
76
  runtimeUpdateNotification(id: string, notification: NotificationInput): boolean;
77
77
  runtimeRemoveNotification(id: string): boolean;
78
78
  runtimeGrantNotification(id: string): boolean;
79
- runtimeNotificationRequested(): Notification;
80
79
  runtimeNotificationTriggered(): TriggeredNotification;
81
80
  }
@@ -15,7 +15,7 @@ import { Perspective, PerspectiveExpression, PerspectiveInput } from "../perspec
15
15
  import { ExpressionProof } from "../expression/Expression";
16
16
  import { LinkExpression } from "../links/Links";
17
17
  import { ExceptionType } from "../Exception";
18
- import { RUNTIME_MESSAGED_RECEIVED_TOPIC, EXCEPTION_OCCURRED_TOPIC, RUNTIME_NOTIFICATION_REQUESTED_TOPIC, RUNTIME_NOTIFICATION_TRIGGERED_TOPIC } from '../PubSub';
18
+ import { RUNTIME_MESSAGED_RECEIVED_TOPIC, EXCEPTION_OCCURRED_TOPIC, RUNTIME_NOTIFICATION_TRIGGERED_TOPIC } from '../PubSub';
19
19
  const testLink = new LinkExpression();
20
20
  testLink.author = "did:ad4m:test";
21
21
  testLink.timestamp = Date.now();
@@ -304,20 +304,6 @@ let RuntimeResolver = class RuntimeResolver {
304
304
  runtimeGrantNotification(id) {
305
305
  return true;
306
306
  }
307
- runtimeNotificationRequested() {
308
- return {
309
- id: "test-id",
310
- granted: false,
311
- description: "Test description",
312
- appName: "Test app name",
313
- appUrl: "https://example.com",
314
- appIconPath: "https://fluxsocial.io/favicon",
315
- trigger: "triple(X, ad4m://has_type, flux://message)",
316
- perspectiveIds: ["u983ud-jdhh38d"],
317
- webhookUrl: "https://example.com/webhook",
318
- webhookAuth: "test-auth",
319
- };
320
- }
321
307
  runtimeNotificationTriggered() {
322
308
  return {
323
309
  perspectiveId: "test-perspective-id",
@@ -522,12 +508,6 @@ __decorate([
522
508
  __metadata("design:paramtypes", [String]),
523
509
  __metadata("design:returntype", Boolean)
524
510
  ], RuntimeResolver.prototype, "runtimeGrantNotification", null);
525
- __decorate([
526
- Subscription({ topics: RUNTIME_NOTIFICATION_REQUESTED_TOPIC, nullable: true }),
527
- __metadata("design:type", Function),
528
- __metadata("design:paramtypes", []),
529
- __metadata("design:returntype", Notification)
530
- ], RuntimeResolver.prototype, "runtimeNotificationRequested", null);
531
511
  __decorate([
532
512
  Subscription({ topics: RUNTIME_NOTIFICATION_TRIGGERED_TOPIC, nullable: true }),
533
513
  __metadata("design:type", Function),
@@ -412,7 +412,6 @@ type Subscription {
412
412
  perspectiveSyncStateChange(uuid: String!): String!
413
413
  perspectiveUpdated: PerspectiveHandle
414
414
  runtimeMessageReceived: PerspectiveExpression
415
- runtimeNotificationRequested: Notification
416
415
  runtimeNotificationTriggered: TriggeredNotification
417
416
  }
418
417
 
@@ -42,9 +42,7 @@ export class SubjectEntity {
42
42
  }
43
43
  async getData(id) {
44
44
  const tempId = id ?? __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f");
45
- console.log("SubjectEntity: getData");
46
45
  let data = await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").getSubjectData(__classPrivateFieldGet(this, _SubjectEntity_subjectClass, "f"), tempId);
47
- console.log("SubjectEntity got data:", data);
48
46
  Object.assign(this, data);
49
47
  __classPrivateFieldSet(this, _SubjectEntity_baseExpression, tempId, "f");
50
48
  return this;
@@ -408,7 +408,6 @@ type Subscription {
408
408
  perspectiveSyncStateChange(uuid: String!): String!
409
409
  perspectiveUpdated: PerspectiveHandle
410
410
  runtimeMessageReceived: PerspectiveExpression
411
- runtimeNotificationRequested: Notification
412
411
  runtimeNotificationTriggered: TriggeredNotification
413
412
  }
414
413
 
package/package.json CHANGED
@@ -60,7 +60,7 @@
60
60
  "@types/yargs": "*"
61
61
  },
62
62
  "patchedDependencies": {},
63
- "version": "0.10.0-prerelease",
63
+ "version": "0.10.0-rc2",
64
64
  "pnpm": {
65
65
  "patchedDependencies": {
66
66
  "graphql@15.7.2": "patches/graphql@15.7.2.patch"
@@ -2,6 +2,7 @@ import { ApolloClient, gql } from "@apollo/client/core";
2
2
  import { InteractionCall, InteractionMeta } from "../language/Language";
3
3
  import unwrapApolloResult from "../unwrapApolloResult";
4
4
  import { ExpressionRendered } from "./Expression";
5
+ import { Literal } from "../Literal";
5
6
 
6
7
  export class ExpressionClient {
7
8
  #apolloClient: ApolloClient<any>
@@ -10,7 +11,19 @@ export class ExpressionClient {
10
11
  this.#apolloClient = client
11
12
  }
12
13
 
13
- async get(url: string): Promise<ExpressionRendered> {
14
+ async get(url: string, alwaysGet: boolean = false): Promise<ExpressionRendered> {
15
+ if(!alwaysGet){
16
+ try {
17
+ let literalValue = Literal.fromUrl(url).get();
18
+ if (typeof literalValue === 'object' && literalValue !== null) {
19
+ if ('author' in literalValue && 'timestamp' in literalValue && 'data' in literalValue && 'proof' in literalValue) {
20
+ return literalValue;
21
+ }
22
+ }
23
+ } catch(e) {}
24
+ }
25
+
26
+
14
27
  const { expression } = unwrapApolloResult(await this.#apolloClient.query({
15
28
  query: gql`query expression($url: String!) {
16
29
  expression(url: $url) {
@@ -57,13 +57,11 @@ export class RuntimeClient {
57
57
  this.#messageReceivedCallbacks = []
58
58
  this.#exceptionOccurredCallbacks = []
59
59
  this.#notificationTriggeredCallbacks = []
60
- this.#notificationRequestedCallbacks = []
61
60
 
62
61
  if(subscribe) {
63
62
  this.subscribeMessageReceived()
64
63
  this.subscribeExceptionOccurred()
65
64
  this.subscribeNotificationTriggered()
66
- this.subscribeNotificationRequested()
67
65
  }
68
66
  }
69
67
 
@@ -323,10 +321,6 @@ export class RuntimeClient {
323
321
  this.#notificationTriggeredCallbacks.push(cb)
324
322
  }
325
323
 
326
- addNotificationRequestedCallback(cb: NotificationRequestedCallback) {
327
- this.#notificationRequestedCallbacks.push(cb)
328
- }
329
-
330
324
  subscribeNotificationTriggered() {
331
325
  this.#apolloClient.subscribe({
332
326
  query: gql` subscription {
@@ -342,21 +336,6 @@ export class RuntimeClient {
342
336
  })
343
337
  }
344
338
 
345
- subscribeNotificationRequested() {
346
- this.#apolloClient.subscribe({
347
- query: gql` subscription {
348
- runtimeNotificationRequested { ${NOTIFICATION_FIELDS} }
349
- }
350
- `}).subscribe({
351
- next: result => {
352
- this.#notificationRequestedCallbacks.forEach(cb => {
353
- cb(result.data.runtimeNotificationRequested)
354
- })
355
- },
356
- error: (e) => console.error(e)
357
- })
358
- }
359
-
360
339
  addMessageCallback(cb: MessageCallback) {
361
340
  this.#messageReceivedCallbacks.push(cb)
362
341
  }
@@ -317,23 +317,6 @@ export default class RuntimeResolver {
317
317
  return true
318
318
  }
319
319
 
320
- @Subscription({topics: RUNTIME_NOTIFICATION_REQUESTED_TOPIC, nullable: true})
321
- runtimeNotificationRequested(): Notification {
322
- return {
323
- id: "test-id",
324
- granted: false,
325
- description: "Test description",
326
- appName: "Test app name",
327
- appUrl: "https://example.com",
328
- appIconPath: "https://fluxsocial.io/favicon",
329
- trigger: "triple(X, ad4m://has_type, flux://message)",
330
- perspectiveIds: ["u983ud-jdhh38d"],
331
- webhookUrl: "https://example.com/webhook",
332
- webhookAuth: "test-auth",
333
-
334
- }
335
- }
336
-
337
320
  @Subscription({topics: RUNTIME_NOTIFICATION_TRIGGERED_TOPIC, nullable: true})
338
321
  runtimeNotificationTriggered(): TriggeredNotification {
339
322
  return {
@@ -43,9 +43,7 @@ export class SubjectEntity {
43
43
 
44
44
  private async getData(id?: string) {
45
45
  const tempId = id ?? this.#baseExpression;
46
- console.log("SubjectEntity: getData")
47
46
  let data = await this.#perspective.getSubjectData(this.#subjectClass, tempId)
48
- console.log("SubjectEntity got data:", data)
49
47
  Object.assign(this, data);
50
48
  this.#baseExpression = tempId;
51
49
  return this