@coasys/ad4m 0.8.0 → 0.8.2-prerelease

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 (66) hide show
  1. package/lib/index.cjs +29 -53
  2. package/lib/index.js +8085 -0
  3. package/lib/shims/reflect-metadata.js +0 -0
  4. package/lib/shims/type-graphql.js +70 -0
  5. package/lib/src/Ad4mClient.js +66 -0
  6. package/lib/src/Address.js +1 -0
  7. package/lib/src/DID.js +1 -0
  8. package/lib/src/Exception.js +7 -0
  9. package/lib/src/Literal.js +76 -0
  10. package/lib/src/PubSub.js +14 -0
  11. package/lib/src/SmartLiteral.js +74 -0
  12. package/lib/src/agent/Agent.js +337 -0
  13. package/lib/src/agent/AgentClient.js +431 -0
  14. package/lib/src/agent/AgentResolver.js +325 -0
  15. package/lib/src/agent/AgentStatus.js +61 -0
  16. package/lib/src/buildSchema.js +36 -0
  17. package/lib/src/expression/Expression.js +143 -0
  18. package/lib/src/expression/ExpressionClient.js +102 -0
  19. package/lib/src/expression/ExpressionRef.js +67 -0
  20. package/lib/src/expression/ExpressionResolver.js +106 -0
  21. package/lib/src/index.js +30 -0
  22. package/lib/src/jestSetup.js +1 -0
  23. package/lib/src/language/Icon.js +24 -0
  24. package/lib/src/language/Language.js +79 -0
  25. package/lib/src/language/LanguageClient.js +137 -0
  26. package/lib/src/language/LanguageContext.js +2 -0
  27. package/lib/src/language/LanguageHandle.js +41 -0
  28. package/lib/src/language/LanguageMeta.js +89 -0
  29. package/lib/src/language/LanguageRef.js +30 -0
  30. package/lib/src/language/LanguageResolver.js +143 -0
  31. package/lib/src/links/Links.js +148 -0
  32. package/lib/src/links/Links.test.js +33 -0
  33. package/lib/src/neighbourhood/Neighbourhood.js +38 -0
  34. package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -0
  35. package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -0
  36. package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -0
  37. package/lib/src/perspectives/LinkQuery.js +80 -0
  38. package/lib/src/perspectives/Perspective.js +144 -0
  39. package/lib/src/perspectives/Perspective.test.js +20 -0
  40. package/lib/src/perspectives/PerspectiveClient.d.ts +1 -0
  41. package/lib/src/perspectives/PerspectiveClient.js +418 -0
  42. package/lib/src/perspectives/PerspectiveDiff.js +33 -0
  43. package/lib/src/perspectives/PerspectiveHandle.js +59 -0
  44. package/lib/src/perspectives/PerspectiveProxy.d.ts +8 -8
  45. package/lib/src/perspectives/PerspectiveProxy.js +501 -0
  46. package/lib/src/perspectives/PerspectiveResolver.d.ts +1 -0
  47. package/lib/src/perspectives/PerspectiveResolver.js +376 -0
  48. package/lib/src/runtime/RuntimeClient.js +263 -0
  49. package/lib/src/runtime/RuntimeResolver.js +328 -0
  50. package/lib/src/schema.gql +1 -0
  51. package/lib/src/subject/SDNADecorators.js +250 -0
  52. package/lib/src/subject/Subject.js +164 -0
  53. package/lib/src/subject/SubjectEntity.js +250 -0
  54. package/lib/src/subject/util.js +73 -0
  55. package/lib/src/typeDefs.js +380 -0
  56. package/lib/src/unwrapApolloResult.js +14 -0
  57. package/lib/src/utils.js +21 -0
  58. package/package.json +9 -2
  59. package/patches/graphql@15.7.2.patch +39 -0
  60. package/pnpm-workspace.yaml +19 -0
  61. package/src/Ad4mClient.test.ts +5 -0
  62. package/src/perspectives/PerspectiveClient.ts +9 -0
  63. package/src/perspectives/PerspectiveProxy.ts +22 -56
  64. package/src/perspectives/PerspectiveResolver.ts +5 -0
  65. package/src/subject/Subject.ts +9 -6
  66. package/src/unwrapApolloResult.ts +3 -1
@@ -0,0 +1,143 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Arg, Mutation, Query, Resolver } from "type-graphql";
14
+ import { Icon } from "./Icon";
15
+ import { LanguageHandle } from "./LanguageHandle";
16
+ import { LanguageMeta, LanguageMetaInput } from "./LanguageMeta";
17
+ import { LanguageRef } from "./LanguageRef";
18
+ /**
19
+ * Resolver classes are used here to define the GraphQL schema
20
+ * (through the type-graphql annotations)
21
+ * and are spawned in the client tests in Ad4mClient.test.ts.
22
+ * For the latter, they return test fixtures.
23
+ */
24
+ let LanguageResolver = class LanguageResolver {
25
+ language(address) {
26
+ let language = new LanguageHandle();
27
+ language.address = address;
28
+ language.name = 'test-language';
29
+ language.settings = JSON.stringify({ testSetting: 'test' });
30
+ language.icon = new Icon('test-code');
31
+ language.settingsIcon = new Icon('test-code');
32
+ language.constructorIcon = new Icon('test-code');
33
+ return language;
34
+ }
35
+ languages(filter) {
36
+ let language = new LanguageHandle();
37
+ language.address = 'test-address';
38
+ language.name = 'test-links-language';
39
+ if (!filter || filter === 'linksAdapter')
40
+ return [language];
41
+ else
42
+ return [];
43
+ }
44
+ languageWriteSettings(languageAddress, settings) {
45
+ return true;
46
+ }
47
+ languageApplyTemplateAndPublish(sourceLanguageHash, templateData) {
48
+ return new LanguageRef('test-address', `${sourceLanguageHash}-clone`);
49
+ }
50
+ languagePublish(languagePath, languageMeta) {
51
+ let meta = new LanguageMeta();
52
+ meta.name = languageMeta.name;
53
+ meta.address = "Qm12345";
54
+ meta.description = languageMeta.description;
55
+ meta.author = "did:test:me";
56
+ meta.templated = true;
57
+ meta.templateSourceLanguageAddress = "Qm12345";
58
+ meta.templateAppliedParams = JSON.stringify({ uuid: 'asdfsdaf', name: 'test template' });
59
+ meta.possibleTemplateParams = languageMeta.possibleTemplateParams;
60
+ meta.sourceCodeLink = languageMeta.sourceCodeLink;
61
+ return meta;
62
+ }
63
+ languageMeta(address) {
64
+ let meta = new LanguageMeta();
65
+ meta.name = "test-language";
66
+ meta.address = address;
67
+ meta.description = "Language meta for testing";
68
+ meta.author = "did:test:me";
69
+ meta.templated = true;
70
+ meta.templateSourceLanguageAddress = "Qm12345";
71
+ meta.templateAppliedParams = JSON.stringify({ uuid: 'asdfsdaf', name: 'test template' });
72
+ meta.possibleTemplateParams = ['uuid', 'name'];
73
+ meta.sourceCodeLink = "https://github.com/perspect3vism/ad4m";
74
+ return meta;
75
+ }
76
+ languageSource(address) {
77
+ return "var test = 'language source code'";
78
+ }
79
+ languageRemove(address) { return true; }
80
+ };
81
+ __decorate([
82
+ Query(returns => LanguageHandle, { nullable: true }),
83
+ __param(0, Arg('address')),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", [String]),
86
+ __metadata("design:returntype", LanguageHandle)
87
+ ], LanguageResolver.prototype, "language", null);
88
+ __decorate([
89
+ Query(returns => [LanguageHandle]),
90
+ __param(0, Arg('filter', { nullable: true })),
91
+ __metadata("design:type", Function),
92
+ __metadata("design:paramtypes", [String]),
93
+ __metadata("design:returntype", Array)
94
+ ], LanguageResolver.prototype, "languages", null);
95
+ __decorate([
96
+ Mutation(returns => Boolean),
97
+ __param(0, Arg('languageAddress')),
98
+ __param(1, Arg('settings')),
99
+ __metadata("design:type", Function),
100
+ __metadata("design:paramtypes", [String, String]),
101
+ __metadata("design:returntype", Boolean)
102
+ ], LanguageResolver.prototype, "languageWriteSettings", null);
103
+ __decorate([
104
+ Mutation(),
105
+ __param(0, Arg('sourceLanguageHash')),
106
+ __param(1, Arg('templateData')),
107
+ __metadata("design:type", Function),
108
+ __metadata("design:paramtypes", [String, String]),
109
+ __metadata("design:returntype", LanguageRef)
110
+ ], LanguageResolver.prototype, "languageApplyTemplateAndPublish", null);
111
+ __decorate([
112
+ Mutation(),
113
+ __param(0, Arg('languagePath')),
114
+ __param(1, Arg('languageMeta')),
115
+ __metadata("design:type", Function),
116
+ __metadata("design:paramtypes", [String, LanguageMetaInput]),
117
+ __metadata("design:returntype", LanguageMeta)
118
+ ], LanguageResolver.prototype, "languagePublish", null);
119
+ __decorate([
120
+ Query(),
121
+ __param(0, Arg('address')),
122
+ __metadata("design:type", Function),
123
+ __metadata("design:paramtypes", [String]),
124
+ __metadata("design:returntype", LanguageMeta)
125
+ ], LanguageResolver.prototype, "languageMeta", null);
126
+ __decorate([
127
+ Query(),
128
+ __param(0, Arg('address')),
129
+ __metadata("design:type", Function),
130
+ __metadata("design:paramtypes", [String]),
131
+ __metadata("design:returntype", String)
132
+ ], LanguageResolver.prototype, "languageSource", null);
133
+ __decorate([
134
+ Mutation(),
135
+ __param(0, Arg('address')),
136
+ __metadata("design:type", Function),
137
+ __metadata("design:paramtypes", [String]),
138
+ __metadata("design:returntype", Boolean)
139
+ ], LanguageResolver.prototype, "languageRemove", null);
140
+ LanguageResolver = __decorate([
141
+ Resolver()
142
+ ], LanguageResolver);
143
+ export default LanguageResolver;
@@ -0,0 +1,148 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Field, InputType, ObjectType } from "type-graphql";
11
+ import { ExpressionGeneric, ExpressionGenericInput } from '../expression/Expression';
12
+ let Link = class Link {
13
+ constructor(obj) {
14
+ this.source = obj.source ? obj.source : '';
15
+ this.target = obj.target ? obj.target : '';
16
+ this.predicate = obj.predicate ? obj.predicate : '';
17
+ }
18
+ };
19
+ __decorate([
20
+ Field(),
21
+ __metadata("design:type", String)
22
+ ], Link.prototype, "source", void 0);
23
+ __decorate([
24
+ Field(),
25
+ __metadata("design:type", String)
26
+ ], Link.prototype, "target", void 0);
27
+ __decorate([
28
+ Field({ nullable: true }),
29
+ __metadata("design:type", String)
30
+ ], Link.prototype, "predicate", void 0);
31
+ Link = __decorate([
32
+ ObjectType(),
33
+ __metadata("design:paramtypes", [Object])
34
+ ], Link);
35
+ export { Link };
36
+ let LinkMutations = class LinkMutations {
37
+ };
38
+ __decorate([
39
+ Field(type => [LinkInput]),
40
+ __metadata("design:type", Array)
41
+ ], LinkMutations.prototype, "additions", void 0);
42
+ __decorate([
43
+ Field(type => [LinkExpressionInput]),
44
+ __metadata("design:type", Array)
45
+ ], LinkMutations.prototype, "removals", void 0);
46
+ LinkMutations = __decorate([
47
+ InputType()
48
+ ], LinkMutations);
49
+ export { LinkMutations };
50
+ let LinkExpressionMutations = class LinkExpressionMutations {
51
+ constructor(additions, removals) {
52
+ this.additions = additions;
53
+ this.removals = removals;
54
+ }
55
+ };
56
+ __decorate([
57
+ Field(type => [LinkExpression]),
58
+ __metadata("design:type", Array)
59
+ ], LinkExpressionMutations.prototype, "additions", void 0);
60
+ __decorate([
61
+ Field(type => [LinkExpression]),
62
+ __metadata("design:type", Array)
63
+ ], LinkExpressionMutations.prototype, "removals", void 0);
64
+ LinkExpressionMutations = __decorate([
65
+ ObjectType(),
66
+ __metadata("design:paramtypes", [Array, Array])
67
+ ], LinkExpressionMutations);
68
+ export { LinkExpressionMutations };
69
+ let LinkInput = class LinkInput {
70
+ };
71
+ __decorate([
72
+ Field(),
73
+ __metadata("design:type", String)
74
+ ], LinkInput.prototype, "source", void 0);
75
+ __decorate([
76
+ Field(),
77
+ __metadata("design:type", String)
78
+ ], LinkInput.prototype, "target", void 0);
79
+ __decorate([
80
+ Field({ nullable: true }),
81
+ __metadata("design:type", String)
82
+ ], LinkInput.prototype, "predicate", void 0);
83
+ LinkInput = __decorate([
84
+ InputType()
85
+ ], LinkInput);
86
+ export { LinkInput };
87
+ let LinkExpression = class LinkExpression extends ExpressionGeneric(Link) {
88
+ hash() {
89
+ const mash = JSON.stringify(this.data, Object.keys(this.data).sort()) +
90
+ JSON.stringify(this.author) + this.timestamp;
91
+ let hash = 0, i, chr;
92
+ for (i = 0; i < mash.length; i++) {
93
+ chr = mash.charCodeAt(i);
94
+ hash = ((hash << 5) - hash) + chr;
95
+ hash |= 0; // Convert to 32bit integer
96
+ }
97
+ return hash;
98
+ }
99
+ };
100
+ __decorate([
101
+ Field({ nullable: true, defaultValue: 'shared' }),
102
+ __metadata("design:type", String)
103
+ ], LinkExpression.prototype, "status", void 0);
104
+ LinkExpression = __decorate([
105
+ ObjectType()
106
+ ], LinkExpression);
107
+ export { LinkExpression };
108
+ ;
109
+ let LinkExpressionInput = class LinkExpressionInput extends ExpressionGenericInput(LinkInput) {
110
+ };
111
+ __decorate([
112
+ Field({ nullable: true, defaultValue: 'shared' }),
113
+ __metadata("design:type", String)
114
+ ], LinkExpressionInput.prototype, "status", void 0);
115
+ LinkExpressionInput = __decorate([
116
+ InputType()
117
+ ], LinkExpressionInput);
118
+ export { LinkExpressionInput };
119
+ ;
120
+ export function linkEqual(l1, l2) {
121
+ return l1.author == l2.author &&
122
+ l1.timestamp == l2.timestamp &&
123
+ l1.data.source == l2.data.source &&
124
+ l1.data.predicate == l2.data.predicate &&
125
+ l1.data.target == l2.data.target;
126
+ }
127
+ export function isLink(l) {
128
+ return l && l.source && l.target;
129
+ }
130
+ let LinkExpressionUpdated = class LinkExpressionUpdated {
131
+ constructor(oldLink, newLink) {
132
+ this.oldLink = oldLink;
133
+ this.newLink = newLink;
134
+ }
135
+ };
136
+ __decorate([
137
+ Field(type => LinkExpression),
138
+ __metadata("design:type", LinkExpression)
139
+ ], LinkExpressionUpdated.prototype, "oldLink", void 0);
140
+ __decorate([
141
+ Field(type => LinkExpression),
142
+ __metadata("design:type", LinkExpression)
143
+ ], LinkExpressionUpdated.prototype, "newLink", void 0);
144
+ LinkExpressionUpdated = __decorate([
145
+ ObjectType(),
146
+ __metadata("design:paramtypes", [LinkExpression, LinkExpression])
147
+ ], LinkExpressionUpdated);
148
+ export { LinkExpressionUpdated };
@@ -0,0 +1,33 @@
1
+ import { LinkQuery } from '../perspectives/LinkQuery';
2
+ const query = new LinkQuery({
3
+ source: 'a'
4
+ });
5
+ describe('LinkQuery', () => {
6
+ it('can match positively', () => {
7
+ expect(query.isMatch({
8
+ source: 'a',
9
+ predicate: 'b',
10
+ target: 'c'
11
+ })).toBe(true);
12
+ expect(query.isMatch({
13
+ source: 'a',
14
+ target: 'c'
15
+ })).toBe(true);
16
+ expect(query.isMatch({
17
+ source: 'a',
18
+ predicate: 'b',
19
+ target: 'c'
20
+ })).toBe(true);
21
+ });
22
+ it('can match negatively', () => {
23
+ expect(query.isMatch({
24
+ source: 'c',
25
+ predicate: 'b',
26
+ target: 'c'
27
+ })).toBe(false);
28
+ expect(query.isMatch({
29
+ source: 'c',
30
+ target: 'b'
31
+ })).toBe(false);
32
+ });
33
+ });
@@ -0,0 +1,38 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Field, ObjectType } from "type-graphql";
11
+ import { ExpressionGeneric } from "../expression/Expression";
12
+ import { Perspective } from "../perspectives/Perspective";
13
+ let Neighbourhood = class Neighbourhood {
14
+ constructor(linkLanguage, meta) {
15
+ this.linkLanguage = linkLanguage;
16
+ this.meta = meta;
17
+ }
18
+ };
19
+ __decorate([
20
+ Field(),
21
+ __metadata("design:type", String)
22
+ ], Neighbourhood.prototype, "linkLanguage", void 0);
23
+ __decorate([
24
+ Field(),
25
+ __metadata("design:type", Perspective)
26
+ ], Neighbourhood.prototype, "meta", void 0);
27
+ Neighbourhood = __decorate([
28
+ ObjectType(),
29
+ __metadata("design:paramtypes", [String, Perspective])
30
+ ], Neighbourhood);
31
+ export { Neighbourhood };
32
+ let NeighbourhoodExpression = class NeighbourhoodExpression extends ExpressionGeneric(Neighbourhood) {
33
+ };
34
+ NeighbourhoodExpression = __decorate([
35
+ ObjectType()
36
+ ], NeighbourhoodExpression);
37
+ export { NeighbourhoodExpression };
38
+ ;
@@ -0,0 +1,256 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _NeighbourhoodClient_apolloClient, _NeighbourhoodClient_signalHandlers;
13
+ import { gql } from "@apollo/client/core";
14
+ import unwrapApolloResult from "../unwrapApolloResult";
15
+ export class NeighbourhoodClient {
16
+ constructor(client) {
17
+ _NeighbourhoodClient_apolloClient.set(this, void 0);
18
+ _NeighbourhoodClient_signalHandlers.set(this, new Map());
19
+ __classPrivateFieldSet(this, _NeighbourhoodClient_apolloClient, client, "f");
20
+ }
21
+ async publishFromPerspective(perspectiveUUID, linkLanguage, meta) {
22
+ const { neighbourhoodPublishFromPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
23
+ mutation: gql `mutation neighbourhoodPublishFromPerspective(
24
+ $linkLanguage: String!,
25
+ $meta: PerspectiveInput!,
26
+ $perspectiveUUID: String!
27
+ ) {
28
+ neighbourhoodPublishFromPerspective(
29
+ linkLanguage: $linkLanguage,
30
+ meta: $meta,
31
+ perspectiveUUID: $perspectiveUUID
32
+ )
33
+ }`,
34
+ variables: { perspectiveUUID, linkLanguage, meta: meta }
35
+ }));
36
+ return neighbourhoodPublishFromPerspective;
37
+ }
38
+ async joinFromUrl(url) {
39
+ const { neighbourhoodJoinFromUrl } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
40
+ mutation: gql `mutation neighbourhoodJoinFromUrl($url: String!) {
41
+ neighbourhoodJoinFromUrl(url: $url) {
42
+ uuid
43
+ name
44
+ sharedUrl
45
+ state
46
+ neighbourhood {
47
+ data {
48
+ linkLanguage
49
+ meta {
50
+ links
51
+ {
52
+ author
53
+ timestamp
54
+ data { source, predicate, target }
55
+ proof { valid, invalid, signature, key }
56
+ }
57
+ }
58
+ }
59
+ author
60
+ }
61
+ }
62
+ }`,
63
+ variables: { url }
64
+ }));
65
+ return neighbourhoodJoinFromUrl;
66
+ }
67
+ async otherAgents(perspectiveUUID) {
68
+ const { neighbourhoodOtherAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
69
+ query: gql `query neighbourhoodOtherAgents($perspectiveUUID: String!) {
70
+ neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
71
+ }`,
72
+ variables: { perspectiveUUID }
73
+ }));
74
+ return neighbourhoodOtherAgents;
75
+ }
76
+ async hasTelepresenceAdapter(perspectiveUUID) {
77
+ const { neighbourhoodHasTelepresenceAdapter } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
78
+ query: gql `query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
79
+ neighbourhoodHasTelepresenceAdapter(perspectiveUUID: $perspectiveUUID)
80
+ }`,
81
+ variables: { perspectiveUUID }
82
+ }));
83
+ return neighbourhoodHasTelepresenceAdapter;
84
+ }
85
+ async onlineAgents(perspectiveUUID) {
86
+ const { neighbourhoodOnlineAgents } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").query({
87
+ query: gql `query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
88
+ neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
89
+ did
90
+ status {
91
+ author
92
+ timestamp
93
+ data {
94
+ links {
95
+ author
96
+ timestamp
97
+ data { source, predicate, target }
98
+ proof { valid, invalid, signature, key }
99
+ }
100
+ }
101
+ proof { valid, invalid, signature, key }
102
+ }
103
+ }
104
+ }`,
105
+ variables: { perspectiveUUID }
106
+ }));
107
+ return neighbourhoodOnlineAgents;
108
+ }
109
+ async setOnlineStatus(perspectiveUUID, status) {
110
+ const { neighbourhoodSetOnlineStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
111
+ mutation: gql `mutation neighbourhoodSetOnlineStatus(
112
+ $perspectiveUUID: String!,
113
+ $status: PerspectiveInput!
114
+ ) {
115
+ neighbourhoodSetOnlineStatus(
116
+ perspectiveUUID: $perspectiveUUID,
117
+ status: $status
118
+ )
119
+ }`,
120
+ variables: { perspectiveUUID, status }
121
+ }));
122
+ return neighbourhoodSetOnlineStatus;
123
+ }
124
+ async setOnlineStatusU(perspectiveUUID, status) {
125
+ const { neighbourhoodSetOnlineStatusU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
126
+ mutation: gql `mutation neighbourhoodSetOnlineStatusU(
127
+ $perspectiveUUID: String!,
128
+ $status: PerspectiveUnsignedInput!
129
+ ) {
130
+ neighbourhoodSetOnlineStatusU(
131
+ perspectiveUUID: $perspectiveUUID,
132
+ status: $status
133
+ )
134
+ }`,
135
+ variables: { perspectiveUUID, status }
136
+ }));
137
+ return neighbourhoodSetOnlineStatusU;
138
+ }
139
+ async sendSignal(perspectiveUUID, remoteAgentDid, payload) {
140
+ const { neighbourhoodSendSignal } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
141
+ mutation: gql `mutation neighbourhoodSendSignal(
142
+ $perspectiveUUID: String!,
143
+ $remoteAgentDid: String!,
144
+ $payload: PerspectiveInput!
145
+ ) {
146
+ neighbourhoodSendSignal(
147
+ perspectiveUUID: $perspectiveUUID,
148
+ remoteAgentDid: $remoteAgentDid,
149
+ payload: $payload
150
+ )
151
+ }`,
152
+ variables: { perspectiveUUID, remoteAgentDid, payload }
153
+ }));
154
+ return neighbourhoodSendSignal;
155
+ }
156
+ async sendSignalU(perspectiveUUID, remoteAgentDid, payload) {
157
+ const { neighbourhoodSendSignalU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
158
+ mutation: gql `mutation neighbourhoodSendSignalU(
159
+ $perspectiveUUID: String!,
160
+ $remoteAgentDid: String!,
161
+ $payload: PerspectiveUnsignedInput!
162
+ ) {
163
+ neighbourhoodSendSignalU(
164
+ perspectiveUUID: $perspectiveUUID,
165
+ remoteAgentDid: $remoteAgentDid,
166
+ payload: $payload
167
+ )
168
+ }`,
169
+ variables: { perspectiveUUID, remoteAgentDid, payload }
170
+ }));
171
+ return neighbourhoodSendSignalU;
172
+ }
173
+ async sendBroadcast(perspectiveUUID, payload) {
174
+ const { neighbourhoodSendBroadcast } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
175
+ mutation: gql `mutation neighbourhoodSendBroadcast(
176
+ $perspectiveUUID: String!,
177
+ $payload: PerspectiveInput!
178
+ ) {
179
+ neighbourhoodSendBroadcast(
180
+ perspectiveUUID: $perspectiveUUID,
181
+ payload: $payload
182
+ )
183
+ }`,
184
+ variables: { perspectiveUUID, payload }
185
+ }));
186
+ return neighbourhoodSendBroadcast;
187
+ }
188
+ async sendBroadcastU(perspectiveUUID, payload) {
189
+ const { neighbourhoodSendBroadcastU } = unwrapApolloResult(await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").mutate({
190
+ mutation: gql `mutation neighbourhoodSendBroadcastU(
191
+ $perspectiveUUID: String!,
192
+ $payload: PerspectiveUnsignedInput!
193
+ ) {
194
+ neighbourhoodSendBroadcastU(
195
+ perspectiveUUID: $perspectiveUUID,
196
+ payload: $payload
197
+ )
198
+ }`,
199
+ variables: { perspectiveUUID, payload }
200
+ }));
201
+ return neighbourhoodSendBroadcastU;
202
+ }
203
+ dispatchSignal(perspectiveUUID, signal) {
204
+ const handlers = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
205
+ if (handlers) {
206
+ handlers.forEach(handler => handler(signal));
207
+ }
208
+ }
209
+ async subscribeToSignals(perspectiveUUID) {
210
+ const that = this;
211
+ await __classPrivateFieldGet(this, _NeighbourhoodClient_apolloClient, "f").subscribe({
212
+ query: gql `subscription neighbourhoodSignal($perspectiveUUID: String!) {
213
+ neighbourhoodSignal(perspectiveUUID: $perspectiveUUID) {
214
+ author
215
+ timestamp
216
+ data {
217
+ links
218
+ {
219
+ author
220
+ timestamp
221
+ data { source, predicate, target }
222
+ proof { valid, invalid, signature, key }
223
+ }
224
+ }
225
+ proof { valid, invalid, signature, key }
226
+ }
227
+ }`,
228
+ variables: { perspectiveUUID }
229
+ }).subscribe({
230
+ next: (result) => {
231
+ const { neighbourhoodSignal } = unwrapApolloResult(result);
232
+ that.dispatchSignal(perspectiveUUID, neighbourhoodSignal);
233
+ }
234
+ });
235
+ }
236
+ async addSignalHandler(perspectiveUUID, handler) {
237
+ let handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
238
+ if (!handlersForPerspective) {
239
+ handlersForPerspective = [];
240
+ await this.subscribeToSignals(perspectiveUUID);
241
+ }
242
+ handlersForPerspective.push(handler);
243
+ __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
244
+ }
245
+ removeSignalHandler(perspectiveUUID, handler) {
246
+ const handlersForPerspective = __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
247
+ if (handlersForPerspective) {
248
+ const index = handlersForPerspective.indexOf(handler);
249
+ if (index > -1) {
250
+ handlersForPerspective.splice(index, 1);
251
+ }
252
+ }
253
+ __classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
254
+ }
255
+ }
256
+ _NeighbourhoodClient_apolloClient = new WeakMap(), _NeighbourhoodClient_signalHandlers = new WeakMap();
@@ -0,0 +1,54 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _NeighbourhoodProxy_client, _NeighbourhoodProxy_pID;
13
+ export class NeighbourhoodProxy {
14
+ constructor(client, pID) {
15
+ _NeighbourhoodProxy_client.set(this, void 0);
16
+ _NeighbourhoodProxy_pID.set(this, void 0);
17
+ __classPrivateFieldSet(this, _NeighbourhoodProxy_client, client, "f");
18
+ __classPrivateFieldSet(this, _NeighbourhoodProxy_pID, pID, "f");
19
+ }
20
+ async otherAgents() {
21
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"));
22
+ }
23
+ async hasTelepresenceAdapter() {
24
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"));
25
+ }
26
+ async onlineAgents() {
27
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"));
28
+ }
29
+ async setOnlineStatus(status) {
30
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), status);
31
+ }
32
+ async setOnlineStatusU(status) {
33
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), status);
34
+ }
35
+ async sendSignal(remoteAgentDid, payload) {
36
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
37
+ }
38
+ async sendSignalU(remoteAgentDid, payload) {
39
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
40
+ }
41
+ async sendBroadcast(payload) {
42
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), payload);
43
+ }
44
+ async sendBroadcastU(payload) {
45
+ return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), payload);
46
+ }
47
+ async addSignalHandler(handler) {
48
+ await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), handler);
49
+ }
50
+ removeSignalHandler(handler) {
51
+ __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), handler);
52
+ }
53
+ }
54
+ _NeighbourhoodProxy_client = new WeakMap(), _NeighbourhoodProxy_pID = new WeakMap();