@coasys/ad4m 0.8.0-fix

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 (167) hide show
  1. package/README.md +229 -0
  2. package/jest-setup.ts +1 -0
  3. package/jest.config.js +6 -0
  4. package/jsdoc.json +28 -0
  5. package/lib/index.cjs +8165 -0
  6. package/lib/index.js +8130 -0
  7. package/lib/shims/reflect-metadata.d.ts +0 -0
  8. package/lib/shims/reflect-metadata.js +0 -0
  9. package/lib/shims/type-graphql.d.ts +32 -0
  10. package/lib/shims/type-graphql.js +70 -0
  11. package/lib/src/Ad4mClient.d.ts +26 -0
  12. package/lib/src/Ad4mClient.js +66 -0
  13. package/lib/src/Address.d.ts +1 -0
  14. package/lib/src/Address.js +1 -0
  15. package/lib/src/DID.d.ts +1 -0
  16. package/lib/src/DID.js +1 -0
  17. package/lib/src/Exception.d.ts +6 -0
  18. package/lib/src/Exception.js +7 -0
  19. package/lib/src/Literal.d.ts +7 -0
  20. package/lib/src/Literal.js +76 -0
  21. package/lib/src/PubSub.d.ts +14 -0
  22. package/lib/src/PubSub.js +14 -0
  23. package/lib/src/SmartLiteral.d.ts +12 -0
  24. package/lib/src/SmartLiteral.js +74 -0
  25. package/lib/src/agent/Agent.d.ts +104 -0
  26. package/lib/src/agent/Agent.js +337 -0
  27. package/lib/src/agent/AgentClient.d.ts +57 -0
  28. package/lib/src/agent/AgentClient.js +431 -0
  29. package/lib/src/agent/AgentResolver.d.ts +30 -0
  30. package/lib/src/agent/AgentResolver.js +325 -0
  31. package/lib/src/agent/AgentStatus.d.ts +8 -0
  32. package/lib/src/agent/AgentStatus.js +61 -0
  33. package/lib/src/buildSchema.d.ts +1 -0
  34. package/lib/src/buildSchema.js +36 -0
  35. package/lib/src/expression/Expression.d.ts +28 -0
  36. package/lib/src/expression/Expression.js +143 -0
  37. package/lib/src/expression/ExpressionClient.d.ts +13 -0
  38. package/lib/src/expression/ExpressionClient.js +102 -0
  39. package/lib/src/expression/ExpressionRef.d.ts +9 -0
  40. package/lib/src/expression/ExpressionRef.js +67 -0
  41. package/lib/src/expression/ExpressionResolver.d.ts +10 -0
  42. package/lib/src/expression/ExpressionResolver.js +106 -0
  43. package/lib/src/index.d.ts +30 -0
  44. package/lib/src/index.js +30 -0
  45. package/lib/src/jestSetup.d.ts +1 -0
  46. package/lib/src/jestSetup.js +1 -0
  47. package/lib/src/language/Icon.d.ts +4 -0
  48. package/lib/src/language/Icon.js +24 -0
  49. package/lib/src/language/Language.d.ts +195 -0
  50. package/lib/src/language/Language.js +79 -0
  51. package/lib/src/language/LanguageClient.d.ts +17 -0
  52. package/lib/src/language/LanguageClient.js +137 -0
  53. package/lib/src/language/LanguageContext.d.ts +37 -0
  54. package/lib/src/language/LanguageContext.js +2 -0
  55. package/lib/src/language/LanguageHandle.d.ts +9 -0
  56. package/lib/src/language/LanguageHandle.js +41 -0
  57. package/lib/src/language/LanguageMeta.d.ts +35 -0
  58. package/lib/src/language/LanguageMeta.js +89 -0
  59. package/lib/src/language/LanguageRef.d.ts +6 -0
  60. package/lib/src/language/LanguageRef.js +30 -0
  61. package/lib/src/language/LanguageResolver.d.ts +19 -0
  62. package/lib/src/language/LanguageResolver.js +143 -0
  63. package/lib/src/links/Links.d.ts +39 -0
  64. package/lib/src/links/Links.js +148 -0
  65. package/lib/src/links/Links.test.d.ts +1 -0
  66. package/lib/src/links/Links.test.js +33 -0
  67. package/lib/src/neighbourhood/Neighbourhood.d.ts +10 -0
  68. package/lib/src/neighbourhood/Neighbourhood.js +38 -0
  69. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
  70. package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -0
  71. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
  72. package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -0
  73. package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
  74. package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -0
  75. package/lib/src/perspectives/LinkQuery.d.ts +11 -0
  76. package/lib/src/perspectives/LinkQuery.js +80 -0
  77. package/lib/src/perspectives/Perspective.d.ts +38 -0
  78. package/lib/src/perspectives/Perspective.js +144 -0
  79. package/lib/src/perspectives/Perspective.test.d.ts +1 -0
  80. package/lib/src/perspectives/Perspective.test.js +20 -0
  81. package/lib/src/perspectives/PerspectiveClient.d.ts +54 -0
  82. package/lib/src/perspectives/PerspectiveClient.js +410 -0
  83. package/lib/src/perspectives/PerspectiveDiff.d.ts +9 -0
  84. package/lib/src/perspectives/PerspectiveDiff.js +33 -0
  85. package/lib/src/perspectives/PerspectiveHandle.d.ts +16 -0
  86. package/lib/src/perspectives/PerspectiveHandle.js +59 -0
  87. package/lib/src/perspectives/PerspectiveProxy.d.ts +178 -0
  88. package/lib/src/perspectives/PerspectiveProxy.js +540 -0
  89. package/lib/src/perspectives/PerspectiveResolver.d.ts +37 -0
  90. package/lib/src/perspectives/PerspectiveResolver.js +362 -0
  91. package/lib/src/runtime/RuntimeClient.d.ts +33 -0
  92. package/lib/src/runtime/RuntimeClient.js +263 -0
  93. package/lib/src/runtime/RuntimeResolver.d.ts +47 -0
  94. package/lib/src/runtime/RuntimeResolver.js +328 -0
  95. package/lib/src/schema.gql +382 -0
  96. package/lib/src/subject/SDNADecorators.d.ts +45 -0
  97. package/lib/src/subject/SDNADecorators.js +250 -0
  98. package/lib/src/subject/Subject.d.ts +7 -0
  99. package/lib/src/subject/Subject.js +160 -0
  100. package/lib/src/subject/SubjectEntity.d.ts +31 -0
  101. package/lib/src/subject/SubjectEntity.js +250 -0
  102. package/lib/src/subject/util.d.ts +12 -0
  103. package/lib/src/subject/util.js +73 -0
  104. package/lib/src/typeDefs.d.ts +1 -0
  105. package/lib/src/typeDefs.js +379 -0
  106. package/lib/src/unwrapApolloResult.d.ts +2 -0
  107. package/lib/src/unwrapApolloResult.js +12 -0
  108. package/lib/src/utils.d.ts +2 -0
  109. package/lib/src/utils.js +21 -0
  110. package/package.json +61 -0
  111. package/rollup.config.js +27 -0
  112. package/shims/reflect-metadata.ts +0 -0
  113. package/shims/type-graphql.ts +75 -0
  114. package/src/Ad4mClient.test.ts +1085 -0
  115. package/src/Ad4mClient.ts +63 -0
  116. package/src/Address.ts +1 -0
  117. package/src/DID.ts +1 -0
  118. package/src/Exception.ts +6 -0
  119. package/src/Literal.test.ts +31 -0
  120. package/src/Literal.ts +81 -0
  121. package/src/PubSub.ts +14 -0
  122. package/src/SmartLiteral.ts +75 -0
  123. package/src/agent/Agent.ts +293 -0
  124. package/src/agent/AgentClient.ts +531 -0
  125. package/src/agent/AgentResolver.ts +263 -0
  126. package/src/agent/AgentStatus.ts +44 -0
  127. package/src/buildSchema.ts +41 -0
  128. package/src/expression/Expression.ts +99 -0
  129. package/src/expression/ExpressionClient.ts +99 -0
  130. package/src/expression/ExpressionRef.ts +63 -0
  131. package/src/expression/ExpressionResolver.ts +64 -0
  132. package/src/index.ts +30 -0
  133. package/src/jestSetup.ts +1 -0
  134. package/src/language/Icon.ts +11 -0
  135. package/src/language/Language.ts +266 -0
  136. package/src/language/LanguageClient.ts +160 -0
  137. package/src/language/LanguageContext.ts +37 -0
  138. package/src/language/LanguageHandle.ts +23 -0
  139. package/src/language/LanguageMeta.ts +70 -0
  140. package/src/language/LanguageRef.ts +18 -0
  141. package/src/language/LanguageResolver.ts +98 -0
  142. package/src/links/Links.test.ts +40 -0
  143. package/src/links/Links.ts +107 -0
  144. package/src/neighbourhood/Neighbourhood.ts +22 -0
  145. package/src/neighbourhood/NeighbourhoodClient.ts +276 -0
  146. package/src/neighbourhood/NeighbourhoodProxy.ts +58 -0
  147. package/src/neighbourhood/NeighbourhoodResolver.ts +100 -0
  148. package/src/perspectives/LinkQuery.ts +66 -0
  149. package/src/perspectives/Perspective.test.ts +23 -0
  150. package/src/perspectives/Perspective.ts +118 -0
  151. package/src/perspectives/PerspectiveClient.ts +444 -0
  152. package/src/perspectives/PerspectiveDiff.ts +15 -0
  153. package/src/perspectives/PerspectiveHandle.ts +39 -0
  154. package/src/perspectives/PerspectiveProxy.ts +611 -0
  155. package/src/perspectives/PerspectiveResolver.ts +220 -0
  156. package/src/runtime/RuntimeClient.ts +283 -0
  157. package/src/runtime/RuntimeResolver.ts +193 -0
  158. package/src/subject/SDNADecorators.ts +334 -0
  159. package/src/subject/Subject.ts +153 -0
  160. package/src/subject/SubjectEntity.ts +292 -0
  161. package/src/subject/util.ts +85 -0
  162. package/src/typeDefs.ts +6 -0
  163. package/src/unwrapApolloResult.ts +14 -0
  164. package/src/utils.ts +25 -0
  165. package/tsconfig-browser.json +82 -0
  166. package/tsconfig.json +80 -0
  167. package/yarn-error.log +22814 -0
@@ -0,0 +1,102 @@
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 _ExpressionClient_apolloClient;
13
+ import { gql } from "@apollo/client/core";
14
+ import unwrapApolloResult from "../unwrapApolloResult";
15
+ export class ExpressionClient {
16
+ constructor(client) {
17
+ _ExpressionClient_apolloClient.set(this, void 0);
18
+ __classPrivateFieldSet(this, _ExpressionClient_apolloClient, client, "f");
19
+ }
20
+ async get(url) {
21
+ const { expression } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
22
+ query: gql `query expression($url: String!) {
23
+ expression(url: $url) {
24
+ author
25
+ timestamp
26
+ data
27
+ language {
28
+ address
29
+ }
30
+ proof {
31
+ valid
32
+ invalid
33
+ }
34
+ }
35
+ }`,
36
+ variables: { url }
37
+ }));
38
+ return expression;
39
+ }
40
+ async getMany(urls) {
41
+ const { expressionMany } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
42
+ query: gql `query expressionMany($urls: [String!]!) {
43
+ expressionMany(urls: $urls) {
44
+ author
45
+ timestamp
46
+ data
47
+ language {
48
+ address
49
+ }
50
+ proof {
51
+ valid
52
+ invalid
53
+ }
54
+ }
55
+ }`,
56
+ variables: { urls }
57
+ }));
58
+ return expressionMany;
59
+ }
60
+ async getRaw(url) {
61
+ const { expressionRaw } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
62
+ query: gql `query expressionRaw($url: String!) {
63
+ expressionRaw(url: $url)
64
+ }`,
65
+ variables: { url }
66
+ }));
67
+ return expressionRaw;
68
+ }
69
+ async create(content, languageAddress) {
70
+ content = JSON.stringify(content);
71
+ const { expressionCreate } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").mutate({
72
+ mutation: gql `mutation expressionCreate($content: String!, $languageAddress: String!){
73
+ expressionCreate(content: $content, languageAddress: $languageAddress)
74
+ }`,
75
+ variables: { content, languageAddress }
76
+ }));
77
+ return expressionCreate;
78
+ }
79
+ async interactions(url) {
80
+ const { expressionInteractions } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
81
+ query: gql `query expressionInteractions($url: String!) {
82
+ expressionInteractions(url: $url) {
83
+ label
84
+ name
85
+ parameters { name, type }
86
+ }
87
+ }`,
88
+ variables: { url }
89
+ }));
90
+ return expressionInteractions;
91
+ }
92
+ async interact(url, interactionCall) {
93
+ const { expressionInteract } = unwrapApolloResult(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").mutate({
94
+ mutation: gql `mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
95
+ expressionInteract(url: $url, interactionCall: $interactionCall)
96
+ }`,
97
+ variables: { url, interactionCall }
98
+ }));
99
+ return expressionInteract;
100
+ }
101
+ }
102
+ _ExpressionClient_apolloClient = new WeakMap();
@@ -0,0 +1,9 @@
1
+ import type { Address } from '../Address';
2
+ import { LanguageRef } from '../language/LanguageRef';
3
+ export declare class ExpressionRef {
4
+ language: LanguageRef;
5
+ expression: Address;
6
+ constructor(lang: LanguageRef, expr: Address);
7
+ }
8
+ export declare function exprRef2String(ref: ExpressionRef): string;
9
+ export declare function parseExprUrl(url: string): ExpressionRef;
@@ -0,0 +1,67 @@
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 { LanguageRef } from '../language/LanguageRef';
11
+ import { Field, ObjectType } from "type-graphql";
12
+ // Expression address + unique Language ID = global expression URL
13
+ let ExpressionRef = class ExpressionRef {
14
+ constructor(lang, expr) {
15
+ this.language = lang;
16
+ this.expression = expr;
17
+ }
18
+ };
19
+ __decorate([
20
+ Field(),
21
+ __metadata("design:type", LanguageRef)
22
+ ], ExpressionRef.prototype, "language", void 0);
23
+ __decorate([
24
+ Field(),
25
+ __metadata("design:type", String)
26
+ ], ExpressionRef.prototype, "expression", void 0);
27
+ ExpressionRef = __decorate([
28
+ ObjectType(),
29
+ __metadata("design:paramtypes", [LanguageRef, String])
30
+ ], ExpressionRef);
31
+ export { ExpressionRef };
32
+ // Creates unique expression URI like this:
33
+ // expr:Qm3490gfwe489hf34:Qm90ghjoaw4iehioefwe4ort
34
+ export function exprRef2String(ref) {
35
+ if (ref.language.address === 'did')
36
+ return ref.expression.toString();
37
+ else
38
+ return `${ref.language.address}://${ref.expression}`;
39
+ }
40
+ export function parseExprUrl(url) {
41
+ if (url.startsWith("literal://")) {
42
+ const languageRef = new LanguageRef();
43
+ languageRef.address = 'literal';
44
+ languageRef.name = 'literal';
45
+ const content = url.substring(10);
46
+ return new ExpressionRef(languageRef, content);
47
+ }
48
+ const URIregexp = /^([^:^\s]+):\/\/([\s\S]+)$/;
49
+ const URImatches = URIregexp.exec(url);
50
+ if (URImatches && URImatches.length == 3) {
51
+ const language = URImatches[1];
52
+ const expression = URImatches[2];
53
+ const languageRef = new LanguageRef();
54
+ languageRef.address = language;
55
+ const ref = new ExpressionRef(languageRef, expression);
56
+ return ref;
57
+ }
58
+ const DIDregexp = /^did:([^\s]+)$/;
59
+ const DIDmatches = DIDregexp.exec(url);
60
+ if (DIDmatches && DIDmatches.length == 2) {
61
+ const languageRef = new LanguageRef();
62
+ languageRef.address = 'did';
63
+ const ref = new ExpressionRef(languageRef, url);
64
+ return ref;
65
+ }
66
+ throw new Error("Couldn't parse string as expression URL or DID: " + url);
67
+ }
@@ -0,0 +1,10 @@
1
+ import { ExpressionRendered } from "./Expression";
2
+ import { InteractionCall, InteractionMeta } from "../language/Language";
3
+ export default class ExpressionResolver {
4
+ expression(url: string): ExpressionRendered;
5
+ expressionMany(urls: string[]): (ExpressionRendered | null)[];
6
+ expressionRaw(url: string): string;
7
+ expressionCreate(content: string, languageAddress: string): string;
8
+ expressionInteractions(url: string): InteractionMeta[];
9
+ expressionInteract(url: string, interactionCall: InteractionCall): string | null;
10
+ }
@@ -0,0 +1,106 @@
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 { LanguageRef } from "../language/LanguageRef";
15
+ import { ExpressionProof, ExpressionRendered } from "./Expression";
16
+ import { InteractionCall, InteractionMeta } from "../language/Language";
17
+ const e = new ExpressionRendered();
18
+ e.author = 'did:ad4m:test';
19
+ e.timestamp = Date.now().toString();
20
+ e.proof = new ExpressionProof('', '');
21
+ e.data = JSON.stringify({ type: 'test expression', content: 'test' });
22
+ e.language = new LanguageRef('test-language-address');
23
+ const testExpression = e;
24
+ let ExpressionResolver = class ExpressionResolver {
25
+ expression(url) {
26
+ if (url === 'neighbourhood://Qm123') {
27
+ return testExpression;
28
+ }
29
+ else {
30
+ return null;
31
+ }
32
+ }
33
+ expressionMany(urls) {
34
+ return [testExpression, null];
35
+ }
36
+ expressionRaw(url) {
37
+ if (url === 'neighbourhood://Qm123') {
38
+ return JSON.stringify(testExpression);
39
+ }
40
+ else {
41
+ return null;
42
+ }
43
+ }
44
+ expressionCreate(content, languageAddress) {
45
+ return "Qm1234";
46
+ }
47
+ expressionInteractions(url) {
48
+ const interaction = {
49
+ label: "Add a comment",
50
+ name: "add_comment",
51
+ parameters: [{ name: 'comment', type: 'string' }]
52
+ };
53
+ return [interaction];
54
+ }
55
+ expressionInteract(url, interactionCall) {
56
+ return "test result";
57
+ }
58
+ };
59
+ __decorate([
60
+ Query(returns => ExpressionRendered, { nullable: true }),
61
+ __param(0, Arg('url')),
62
+ __metadata("design:type", Function),
63
+ __metadata("design:paramtypes", [String]),
64
+ __metadata("design:returntype", ExpressionRendered)
65
+ ], ExpressionResolver.prototype, "expression", null);
66
+ __decorate([
67
+ Query(returns => [ExpressionRendered], { nullable: "items" }),
68
+ __param(0, Arg('urls', type => [String])),
69
+ __metadata("design:type", Function),
70
+ __metadata("design:paramtypes", [Array]),
71
+ __metadata("design:returntype", Array)
72
+ ], ExpressionResolver.prototype, "expressionMany", null);
73
+ __decorate([
74
+ Query(returns => String, { nullable: true }),
75
+ __param(0, Arg('url')),
76
+ __metadata("design:type", Function),
77
+ __metadata("design:paramtypes", [String]),
78
+ __metadata("design:returntype", String)
79
+ ], ExpressionResolver.prototype, "expressionRaw", null);
80
+ __decorate([
81
+ Mutation(returns => String),
82
+ __param(0, Arg('content')),
83
+ __param(1, Arg('languageAddress')),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", [String, String]),
86
+ __metadata("design:returntype", String)
87
+ ], ExpressionResolver.prototype, "expressionCreate", null);
88
+ __decorate([
89
+ Query(returns => [InteractionMeta]),
90
+ __param(0, Arg('url')),
91
+ __metadata("design:type", Function),
92
+ __metadata("design:paramtypes", [String]),
93
+ __metadata("design:returntype", Array)
94
+ ], ExpressionResolver.prototype, "expressionInteractions", null);
95
+ __decorate([
96
+ Mutation(returns => String, { nullable: true }),
97
+ __param(0, Arg('url')),
98
+ __param(1, Arg('interactionCall')),
99
+ __metadata("design:type", Function),
100
+ __metadata("design:paramtypes", [String, InteractionCall]),
101
+ __metadata("design:returntype", String)
102
+ ], ExpressionResolver.prototype, "expressionInteract", null);
103
+ ExpressionResolver = __decorate([
104
+ Resolver()
105
+ ], ExpressionResolver);
106
+ export default ExpressionResolver;
@@ -0,0 +1,30 @@
1
+ export * from "./Ad4mClient";
2
+ export * from "./Address";
3
+ export * from "./agent/Agent";
4
+ export * from "./agent/AgentStatus";
5
+ export * from "./Exception";
6
+ export * from "./expression/Expression";
7
+ export * from "./expression/ExpressionRef";
8
+ export * from "./language/Icon";
9
+ export * from "./language/Language";
10
+ export * from "./language/LanguageRef";
11
+ export * from "./language/LanguageContext";
12
+ export * from "./language/LanguageHandle";
13
+ export * from "./language/LanguageMeta";
14
+ export * from "./links/Links";
15
+ export * from "./Literal";
16
+ export * from "./perspectives/Perspective";
17
+ export * from "./perspectives/PerspectiveHandle";
18
+ export * from "./perspectives/PerspectiveProxy";
19
+ export * from "./perspectives/PerspectiveDiff";
20
+ export * from "./perspectives/LinkQuery";
21
+ export * from "./SmartLiteral";
22
+ export * from "./subject/SDNADecorators";
23
+ export * from "./subject/Subject";
24
+ export * from "./neighbourhood/Neighbourhood";
25
+ export * from "./neighbourhood/NeighbourhoodProxy";
26
+ export * from "./typeDefs";
27
+ export * from "./DID";
28
+ export * from "./utils";
29
+ export * from './subject/SubjectEntity';
30
+ export * from "./agent/AgentClient";
@@ -0,0 +1,30 @@
1
+ export * from "./Ad4mClient";
2
+ export * from "./Address";
3
+ export * from "./agent/Agent";
4
+ export * from "./agent/AgentStatus";
5
+ export * from "./Exception";
6
+ export * from "./expression/Expression";
7
+ export * from "./expression/ExpressionRef";
8
+ export * from "./language/Icon";
9
+ export * from "./language/Language";
10
+ export * from "./language/LanguageRef";
11
+ export * from "./language/LanguageContext";
12
+ export * from "./language/LanguageHandle";
13
+ export * from "./language/LanguageMeta";
14
+ export * from "./links/Links";
15
+ export * from "./Literal";
16
+ export * from "./perspectives/Perspective";
17
+ export * from "./perspectives/PerspectiveHandle";
18
+ export * from "./perspectives/PerspectiveProxy";
19
+ export * from "./perspectives/PerspectiveDiff";
20
+ export * from "./perspectives/LinkQuery";
21
+ export * from "./SmartLiteral";
22
+ export * from "./subject/SDNADecorators";
23
+ export * from "./subject/Subject";
24
+ export * from "./neighbourhood/Neighbourhood";
25
+ export * from "./neighbourhood/NeighbourhoodProxy";
26
+ export * from "./typeDefs";
27
+ export * from "./DID";
28
+ export * from "./utils";
29
+ export * from './subject/SubjectEntity';
30
+ export * from "./agent/AgentClient";
@@ -0,0 +1 @@
1
+ import 'reflect-metadata';
@@ -0,0 +1 @@
1
+ import 'reflect-metadata';
@@ -0,0 +1,4 @@
1
+ export declare class Icon {
2
+ code: string;
3
+ constructor(code: string);
4
+ }
@@ -0,0 +1,24 @@
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
+ let Icon = class Icon {
12
+ constructor(code) {
13
+ this.code = code;
14
+ }
15
+ };
16
+ __decorate([
17
+ Field(),
18
+ __metadata("design:type", String)
19
+ ], Icon.prototype, "code", void 0);
20
+ Icon = __decorate([
21
+ ObjectType(),
22
+ __metadata("design:paramtypes", [String])
23
+ ], Icon);
24
+ export { Icon };
@@ -0,0 +1,195 @@
1
+ import type { Address } from '../Address';
2
+ import { DID } from '../DID';
3
+ import type { Expression } from '../expression/Expression';
4
+ import { Perspective, PerspectiveExpression } from '../perspectives/Perspective';
5
+ import { PerspectiveDiff } from '../perspectives/PerspectiveDiff';
6
+ import { PerspectiveState } from '../perspectives/PerspectiveHandle';
7
+ /** Interface of AD4M Languages
8
+ *
9
+ * Any JavaScript module that implements a create() function that returns an object that implements this interface
10
+ * is a valid AD4M language.
11
+ * So the AD4M-internal representation of a language is an object that implements this interface.
12
+ *
13
+ * Since there are a few different kinds of languages, this interface is split into optional sub-interfaces.
14
+ * The only required property is the name of the language.
15
+ *
16
+ * The most usual kind of language is the "Expression Language", which is a language that can be used to create
17
+ * and share Expressions.
18
+ * For that, implement the expressionsAdapter and expressionUI interface.
19
+ *
20
+ * The second most common kind of language is the "Link Language", which is a language that builds the core
21
+ * of AD4M Neighbourhoods.
22
+ * For that, implement the linksAdapter interface.
23
+ */
24
+ export interface Language {
25
+ readonly name: string;
26
+ /** Flagging expressions as immutable to enable
27
+ * expression caching in the ad4m-executor
28
+ */
29
+ isImmutableExpression?(expression: Address): boolean;
30
+ /** ExpressionAdapter implements means of getting an Expression
31
+ * by address and putting an expression
32
+ */
33
+ readonly expressionAdapter?: ExpressionAdapter;
34
+ /** Interface for getting UI/web components for rendering Expressions of this Language */
35
+ readonly expressionUI?: ExpressionUI;
36
+ /** Interface of LinkLanguages for the core implementation of Neighbourhoods */
37
+ readonly linksAdapter?: LinkSyncAdapter;
38
+ /** Additional Interface of LinkLanguages that support telepresence features,
39
+ * that is:
40
+ * - seeing who is online and getting a status
41
+ * - sending/receiveing p2p signals to other online agents without affecting
42
+ * the shared Perspective of the Neighbourhood
43
+ * (see TelepresenceAdapter for more details)
44
+ */
45
+ readonly telepresenceAdapter?: TelepresenceAdapter;
46
+ /** Implementation of a Language that defines and stores Languages*/
47
+ readonly languageAdapter?: LanguageAdapter;
48
+ /** Optional adapter for getting Expressions by author */
49
+ readonly getByAuthorAdapter?: GetByAuthorAdapter;
50
+ /** Optional adapter for getting all Expressions */
51
+ readonly getAllAdapter?: GetAllAdapter;
52
+ /** Optional adapter for direct messaging between agents */
53
+ readonly directMessageAdapter?: DirectMessageAdapter;
54
+ /** Interface for providing UI components for the settings of this Language */
55
+ readonly settingsUI?: SettingsUI;
56
+ /** Optional function to make any cleanup/teardown if your language gets deleting in the ad4m-executor */
57
+ readonly teardown?: () => void;
58
+ /** All available interactions this agent could execute on given expression */
59
+ interactions(expression: Address): Interaction[];
60
+ }
61
+ /** UI factories returning web components */
62
+ export interface ExpressionUI {
63
+ /** Returns JS code of a web component that renders the given expression */
64
+ icon(): string;
65
+ /** Returns JS code of a web component used to create new expressions */
66
+ constructorIcon(): string;
67
+ }
68
+ export interface SettingsUI {
69
+ settingsIcon(): string;
70
+ }
71
+ /** Interface for the most common Expression Languages */
72
+ export interface ExpressionAdapter {
73
+ /** Returns an Expression by address, or null if there is no Expression
74
+ * with that given address
75
+ */
76
+ get(address: Address): Promise<Expression | null>;
77
+ /** Strategy for putting an expression with needs to be different
78
+ * for those two cases:
79
+ * 1. PublicSharing means that this language supports the creation
80
+ * and sharing of Expressions, which is the common use-case
81
+ * 2. ReadOnlyLanguage means that the Language implements a pre-defined
82
+ * set of expressions (which can be infinite or finite).
83
+ * For example the url-iframe Language which directly maps URLs to
84
+ * addresses - meaning every well formed URL is an address in this
85
+ * Language. Or a potential Language implementing the verbs/predicates
86
+ * of a spec like FOAF.
87
+ */
88
+ putAdapter: PublicSharing | ReadOnlyLanguage;
89
+ }
90
+ /** Implement this interface if your Language supports creation of sharing
91
+ * of Expressions.
92
+ * See ExpressionAdapter
93
+ */
94
+ export interface PublicSharing {
95
+ /** Create an Expression and shares it.
96
+ * Return the Expression's address.
97
+ * @param content is the object created by the constructorIcon component
98
+ */
99
+ createPublic(content: object): Promise<Address>;
100
+ }
101
+ /** Implement this interface if your Language is defined over a static
102
+ * set of pre-defined Expressions.
103
+ */
104
+ export interface ReadOnlyLanguage {
105
+ /** This just calculates the address of an object
106
+ * @param content is the object created by the constructorIcon component
107
+ */
108
+ addressOf(content: object): Promise<Address>;
109
+ }
110
+ export interface LanguageAdapter {
111
+ getLanguageSource(address: Address): Promise<string>;
112
+ }
113
+ export interface GetByAuthorAdapter {
114
+ getByAuthor(author: DID, count: number, page: number): Promise<Expression[] | null>;
115
+ }
116
+ export interface GetAllAdapter {
117
+ getAll(filter: any, count: number, page: number): Promise<Expression[] | null>;
118
+ }
119
+ export type PerspectiveDiffObserver = (diff: PerspectiveDiff) => void;
120
+ export type SyncStateChangeObserver = (state: PerspectiveState) => void;
121
+ /** Interface for "Link Languages" that facilitate the synchronization
122
+ * between agents' local Perspectives inside a Neighbourhood.
123
+ * The assumption is that every version of the shared Perspective
124
+ * is labeled with a unique revision string.
125
+ * Changes are committed and retrieved through diffs.
126
+ * Think of a LinkSyncAdapter as a git branch to which agents commit
127
+ * their changes to and pull diffs from their current revision
128
+ * to the latest one.
129
+ */
130
+ export interface LinkSyncAdapter {
131
+ writable(): boolean;
132
+ public(): boolean;
133
+ others(): Promise<DID[]>;
134
+ /** What revision are we on now -> what changes are included in output of render() */
135
+ currentRevision(): Promise<string>;
136
+ /**
137
+ * Check for and get new changes,
138
+ * notify others of local changes.
139
+ * This function will be called every
140
+ * few seconds by the ad4m-executor.
141
+ * */
142
+ sync(): Promise<PerspectiveDiff>;
143
+ /** Returns the full, rendered Perspective at currentRevision */
144
+ render(): Promise<Perspective>;
145
+ /** Publish changes */
146
+ commit(diff: PerspectiveDiff): Promise<string>;
147
+ /** Get push notification when a diff got published */
148
+ addCallback(callback: PerspectiveDiffObserver): any;
149
+ /** Add a sync state callback method */
150
+ addSyncStateChangeCallback(callback: SyncStateChangeObserver): any;
151
+ }
152
+ export type MessageCallback = (message: PerspectiveExpression) => void;
153
+ export type StatusCallback = (caller: DID) => Perspective;
154
+ export interface DirectMessageAdapter {
155
+ recipient(): DID;
156
+ status(): Promise<PerspectiveExpression | void>;
157
+ sendP2P(message: Perspective): Promise<PerspectiveExpression | void>;
158
+ sendInbox(message: Perspective): Promise<PerspectiveExpression | void>;
159
+ setStatus(status: PerspectiveExpression): any;
160
+ inbox(filter?: string): Promise<PerspectiveExpression[]>;
161
+ addMessageCallback(callback: MessageCallback): any;
162
+ }
163
+ export declare class InteractionParameter {
164
+ name: string;
165
+ type: string;
166
+ }
167
+ export declare class InteractionMeta {
168
+ label: string;
169
+ name: string;
170
+ parameters: InteractionParameter[];
171
+ }
172
+ export interface Interaction {
173
+ readonly label: string;
174
+ readonly name: string;
175
+ readonly parameters: InteractionParameter[];
176
+ execute(parameters: object): Promise<string | null>;
177
+ }
178
+ export declare class InteractionCall {
179
+ name: string;
180
+ parametersStringified: string;
181
+ get parameters(): object;
182
+ constructor(name: string, parameters: object);
183
+ }
184
+ export declare class OnlineAgent {
185
+ did: DID;
186
+ status: PerspectiveExpression;
187
+ }
188
+ export type TelepresenceSignalCallback = (payload: PerspectiveExpression) => void;
189
+ export interface TelepresenceAdapter {
190
+ setOnlineStatus(status: PerspectiveExpression): Promise<void>;
191
+ getOnlineAgents(): Promise<OnlineAgent[]>;
192
+ sendSignal(remoteAgentDid: string, payload: PerspectiveExpression): Promise<object>;
193
+ sendBroadcast(payload: PerspectiveExpression): Promise<object>;
194
+ registerSignalCallback(callback: TelepresenceSignalCallback): Promise<void>;
195
+ }
@@ -0,0 +1,79 @@
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 { PerspectiveExpression } from '../perspectives/Perspective';
11
+ import { InputType, Field, ObjectType } from "type-graphql";
12
+ let InteractionParameter = class InteractionParameter {
13
+ };
14
+ __decorate([
15
+ Field(),
16
+ __metadata("design:type", String)
17
+ ], InteractionParameter.prototype, "name", void 0);
18
+ __decorate([
19
+ Field(),
20
+ __metadata("design:type", String)
21
+ ], InteractionParameter.prototype, "type", void 0);
22
+ InteractionParameter = __decorate([
23
+ ObjectType()
24
+ ], InteractionParameter);
25
+ export { InteractionParameter };
26
+ let InteractionMeta = class InteractionMeta {
27
+ };
28
+ __decorate([
29
+ Field(),
30
+ __metadata("design:type", String)
31
+ ], InteractionMeta.prototype, "label", void 0);
32
+ __decorate([
33
+ Field(),
34
+ __metadata("design:type", String)
35
+ ], InteractionMeta.prototype, "name", void 0);
36
+ __decorate([
37
+ Field(type => [InteractionParameter]),
38
+ __metadata("design:type", Array)
39
+ ], InteractionMeta.prototype, "parameters", void 0);
40
+ InteractionMeta = __decorate([
41
+ ObjectType()
42
+ ], InteractionMeta);
43
+ export { InteractionMeta };
44
+ let InteractionCall = class InteractionCall {
45
+ get parameters() {
46
+ return JSON.parse(this.parametersStringified);
47
+ }
48
+ constructor(name, parameters) {
49
+ this.name = name;
50
+ this.parametersStringified = JSON.stringify(parameters);
51
+ }
52
+ };
53
+ __decorate([
54
+ Field(),
55
+ __metadata("design:type", String)
56
+ ], InteractionCall.prototype, "name", void 0);
57
+ __decorate([
58
+ Field(),
59
+ __metadata("design:type", String)
60
+ ], InteractionCall.prototype, "parametersStringified", void 0);
61
+ InteractionCall = __decorate([
62
+ InputType(),
63
+ __metadata("design:paramtypes", [String, Object])
64
+ ], InteractionCall);
65
+ export { InteractionCall };
66
+ let OnlineAgent = class OnlineAgent {
67
+ };
68
+ __decorate([
69
+ Field(),
70
+ __metadata("design:type", String)
71
+ ], OnlineAgent.prototype, "did", void 0);
72
+ __decorate([
73
+ Field(),
74
+ __metadata("design:type", PerspectiveExpression)
75
+ ], OnlineAgent.prototype, "status", void 0);
76
+ OnlineAgent = __decorate([
77
+ ObjectType()
78
+ ], OnlineAgent);
79
+ export { OnlineAgent };