@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,382 @@
1
+ # -----------------------------------------------
2
+ # !!! THIS FILE WAS GENERATED BY TYPE-GRAPHQL !!!
3
+ # !!! DO NOT MODIFY THIS FILE BY YOURSELF !!!
4
+ # -----------------------------------------------
5
+
6
+ type Agent {
7
+ did: String!
8
+ directMessageLanguage: String
9
+ perspective: Perspective
10
+ }
11
+
12
+ type AgentSignature {
13
+ publicKey: String!
14
+ signature: String!
15
+ }
16
+
17
+ type AgentStatus {
18
+ did: String
19
+ didDocument: String
20
+ error: String
21
+ isInitialized: Boolean!
22
+ isUnlocked: Boolean!
23
+ }
24
+
25
+ type Apps {
26
+ auth: AuthInfo!
27
+ requestId: String!
28
+ revoked: Boolean
29
+ token: String!
30
+ }
31
+
32
+ type AuthInfo {
33
+ appDesc: String!
34
+ appIconPath: String
35
+ appName: String!
36
+ appUrl: String!
37
+ capabilities: [Capability!]!
38
+ }
39
+
40
+ input AuthInfoInput {
41
+ appDesc: String!
42
+ appDomain: String!
43
+ appIconPath: String
44
+ appName: String!
45
+ appUrl: String
46
+ capabilities: [CapabilityInput!]
47
+ }
48
+
49
+ type Capability {
50
+ can: [String!]!
51
+ with: Resource!
52
+ }
53
+
54
+ input CapabilityInput {
55
+ can: [String!]!
56
+ with: ResourceInput!
57
+ }
58
+
59
+ # The javascript `Date` as string. Type represents date and time as the ISO Date string.
60
+ scalar DateTime
61
+
62
+ type EntanglementProof {
63
+ deviceKey: String!
64
+ deviceKeySignedByDid: String!
65
+ deviceKeyType: String!
66
+ did: String!
67
+ didSignedByDeviceKey: String
68
+ didSigningKeyId: String!
69
+ }
70
+
71
+ input EntanglementProofInput {
72
+ deviceKey: String!
73
+ deviceKeySignedByDid: String!
74
+ deviceKeyType: String!
75
+ did: String!
76
+ didSignedByDeviceKey: String!
77
+ didSigningKeyId: String!
78
+ }
79
+
80
+ type ExceptionInfo {
81
+ addon: String
82
+ message: String!
83
+ title: String!
84
+ type: Float!
85
+ }
86
+
87
+ type ExpressionProof {
88
+ invalid: Boolean
89
+ key: String
90
+ signature: String
91
+ valid: Boolean
92
+ }
93
+
94
+ input ExpressionProofInput {
95
+ invalid: Boolean
96
+ key: String
97
+ signature: String
98
+ valid: Boolean
99
+ }
100
+
101
+ type ExpressionRendered {
102
+ author: String!
103
+ data: String!
104
+ icon: Icon!
105
+ language: LanguageRef!
106
+ proof: ExpressionProof!
107
+ timestamp: String!
108
+ }
109
+
110
+ type Icon {
111
+ code: String!
112
+ }
113
+
114
+ input InteractionCall {
115
+ name: String!
116
+ parametersStringified: String!
117
+ }
118
+
119
+ type InteractionMeta {
120
+ label: String!
121
+ name: String!
122
+ parameters: [InteractionParameter!]!
123
+ }
124
+
125
+ type InteractionParameter {
126
+ name: String!
127
+ type: String!
128
+ }
129
+
130
+ type LanguageHandle {
131
+ address: String!
132
+ constructorIcon: Icon
133
+ icon: Icon
134
+ name: String!
135
+ settings: String
136
+ settingsIcon: Icon
137
+ }
138
+
139
+ type LanguageMeta {
140
+ address: String!
141
+ author: String!
142
+ description: String
143
+ name: String!
144
+ possibleTemplateParams: [String!]
145
+ sourceCodeLink: String
146
+ templateAppliedParams: String
147
+ templateSourceLanguageAddress: String
148
+ templated: Boolean
149
+ }
150
+
151
+ input LanguageMetaInput {
152
+ description: String = ""
153
+ name: String!
154
+ possibleTemplateParams: [String!]
155
+ sourceCodeLink: String
156
+ }
157
+
158
+ type LanguageRef {
159
+ address: String!
160
+ name: String!
161
+ }
162
+
163
+ type Link {
164
+ predicate: String
165
+ source: String!
166
+ target: String!
167
+ }
168
+
169
+ type LinkExpression {
170
+ author: String!
171
+ data: Link!
172
+ proof: ExpressionProof!
173
+ status: String
174
+ timestamp: String!
175
+ }
176
+
177
+ input LinkExpressionInput {
178
+ author: String!
179
+ data: LinkInput!
180
+ proof: ExpressionProofInput!
181
+ status: String = "shared"
182
+ timestamp: String!
183
+ }
184
+
185
+ type LinkExpressionMutations {
186
+ additions: [LinkExpression!]!
187
+ removals: [LinkExpression!]!
188
+ }
189
+
190
+ type LinkExpressionUpdated {
191
+ newLink: LinkExpression!
192
+ oldLink: LinkExpression!
193
+ }
194
+
195
+ input LinkInput {
196
+ predicate: String
197
+ source: String!
198
+ target: String!
199
+ }
200
+
201
+ input LinkMutations {
202
+ additions: [LinkInput!]!
203
+ removals: [LinkExpressionInput!]!
204
+ }
205
+
206
+ input LinkQuery {
207
+ fromDate: DateTime
208
+ limit: Float
209
+ predicate: String
210
+ source: String
211
+ target: String
212
+ untilDate: DateTime
213
+ }
214
+
215
+ type Mutation {
216
+ addTrustedAgents(agents: [String!]!): [String!]!
217
+ agentAddEntanglementProofs(proofs: [EntanglementProofInput!]!): [EntanglementProof!]!
218
+ agentDeleteEntanglementProofs(proofs: [EntanglementProofInput!]!): [EntanglementProof!]!
219
+ agentEntanglementProofPreFlight(deviceKey: String!, deviceKeyType: String!): EntanglementProof!
220
+ agentGenerate(passphrase: String!): AgentStatus!
221
+ agentGenerateJwt(rand: String!, requestId: String!): String!
222
+ agentImport(did: String!, didDocument: String!, keystore: String!, passphrase: String!): AgentStatus!
223
+ agentLock(passphrase: String!): AgentStatus!
224
+ agentPermitCapability(auth: String!): String!
225
+ agentRemoveApp(requestId: String!): [Apps!]!
226
+ agentRequestCapability(authInfo: AuthInfoInput!): String!
227
+ agentRevokeToken(requestId: String!): [Apps!]!
228
+ agentSignMessage(message: String!): AgentSignature!
229
+ agentUnlock(holochain: Boolean!, passphrase: String!): AgentStatus!
230
+ agentUpdateDirectMessageLanguage(directMessageLanguage: String!): Agent!
231
+ agentUpdatePublicPerspective(perspective: PerspectiveInput!): Agent!
232
+ deleteTrustedAgents(agents: [String!]!): [String!]!
233
+ expressionCreate(content: String!, languageAddress: String!): String!
234
+ expressionInteract(interactionCall: InteractionCall!, url: String!): String
235
+ languageApplyTemplateAndPublish(sourceLanguageHash: String!, templateData: String!): LanguageRef!
236
+ languagePublish(languageMeta: LanguageMetaInput!, languagePath: String!): LanguageMeta!
237
+ languageRemove(address: String!): Boolean!
238
+ languageWriteSettings(languageAddress: String!, settings: String!): Boolean!
239
+ neighbourhoodJoinFromUrl(url: String!): PerspectiveHandle!
240
+ neighbourhoodPublishFromPerspective(linkLanguage: String!, meta: PerspectiveInput!, perspectiveUUID: String!): String!
241
+ neighbourhoodSendBroadcast(payload: PerspectiveInput!, perspectiveUUID: String!): Boolean!
242
+ neighbourhoodSendBroadcastU(payload: PerspectiveUnsignedInput!, perspectiveUUID: String!): Boolean!
243
+ neighbourhoodSendSignal(payload: PerspectiveInput!, perspectiveUUID: String!, remoteAgentDid: String!): Boolean!
244
+ neighbourhoodSendSignalU(payload: PerspectiveUnsignedInput!, perspectiveUUID: String!, remoteAgentDid: String!): Boolean!
245
+ neighbourhoodSetOnlineStatus(perspectiveUUID: String!, status: PerspectiveInput!): Boolean!
246
+ neighbourhoodSetOnlineStatusU(perspectiveUUID: String!, status: PerspectiveUnsignedInput!): Boolean!
247
+ perspectiveAdd(name: String!): PerspectiveHandle!
248
+ perspectiveAddLink(link: LinkInput!, status: String = "shared", uuid: String!): LinkExpression!
249
+ perspectiveAddLinkExpression(link: LinkExpressionInput!, status: String, uuid: String!): LinkExpression!
250
+ perspectiveAddLinks(links: [LinkInput!]!, status: String, uuid: String!): [LinkExpression!]!
251
+ perspectiveLinkMutations(mutations: LinkMutations!, status: String, uuid: String!): LinkExpressionMutations!
252
+ perspectivePublishSnapshot(uuid: String!): String
253
+ perspectiveRemove(uuid: String!): Boolean!
254
+ perspectiveRemoveLink(link: LinkExpressionInput!, uuid: String!): Boolean!
255
+ perspectiveRemoveLinks(links: [LinkExpressionInput!]!, uuid: String!): [LinkExpression!]!
256
+ perspectiveUpdate(name: String!, uuid: String!): PerspectiveHandle
257
+ perspectiveUpdateLink(newLink: LinkInput!, oldLink: LinkExpressionInput!, uuid: String!): LinkExpression!
258
+ runtimeAddFriends(dids: [String!]!): [String!]!
259
+ runtimeAddKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
260
+ runtimeFriendSendMessage(did: String!, message: PerspectiveInput!): Boolean!
261
+ runtimeHcAddAgentInfos(agentInfos: String!): Boolean!
262
+ runtimeOpenLink(url: String!): Boolean!
263
+ runtimeQuit: Boolean!
264
+ runtimeRemoveFriends(dids: [String!]!): [String!]!
265
+ runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
266
+ runtimeSetStatus(status: PerspectiveInput!): Boolean!
267
+ }
268
+
269
+ type Neighbourhood {
270
+ linkLanguage: String!
271
+ meta: Perspective!
272
+ }
273
+
274
+ type NeighbourhoodExpression {
275
+ author: String!
276
+ data: Neighbourhood!
277
+ proof: ExpressionProof!
278
+ timestamp: String!
279
+ }
280
+
281
+ type OnlineAgent {
282
+ did: String!
283
+ status: PerspectiveExpression!
284
+ }
285
+
286
+ type Perspective {
287
+ links: [LinkExpression!]!
288
+ }
289
+
290
+ type PerspectiveExpression {
291
+ author: String!
292
+ data: Perspective!
293
+ proof: ExpressionProof!
294
+ timestamp: String!
295
+ }
296
+
297
+ type PerspectiveHandle {
298
+ name: String!
299
+ neighbourhood: NeighbourhoodExpression
300
+ sharedUrl: String
301
+ state: String!
302
+ uuid: String!
303
+ }
304
+
305
+ input PerspectiveInput {
306
+ links: [LinkExpressionInput!]!
307
+ }
308
+
309
+ input PerspectiveUnsignedInput {
310
+ links: [LinkInput!] = []
311
+ }
312
+
313
+ type Query {
314
+ agent: Agent!
315
+ agentByDID(did: String!): Agent
316
+ agentGetApps: [Apps!]!
317
+ agentGetEntanglementProofs: [EntanglementProof!]!
318
+ agentIsLocked: Boolean!
319
+ agentStatus: AgentStatus!
320
+ expression(url: String!): ExpressionRendered
321
+ expressionInteractions(url: String!): [InteractionMeta!]!
322
+ expressionMany(urls: [String!]!): [ExpressionRendered]!
323
+ expressionRaw(url: String!): String
324
+ getTrustedAgents: [String!]!
325
+ language(address: String!): LanguageHandle
326
+ languageMeta(address: String!): LanguageMeta!
327
+ languageSource(address: String!): String!
328
+ languages(filter: String): [LanguageHandle!]!
329
+ neighbourhoodHasTelepresenceAdapter(perspectiveUUID: String!): Boolean!
330
+ neighbourhoodOnlineAgents(perspectiveUUID: String!): [OnlineAgent!]!
331
+ neighbourhoodOtherAgents(perspectiveUUID: String!): [String!]!
332
+ perspective(uuid: String!): PerspectiveHandle
333
+ perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!]
334
+ perspectiveQueryProlog(query: String!, uuid: String!): String!
335
+ perspectiveSnapshot(uuid: String!): Perspective
336
+ perspectives: [PerspectiveHandle!]!
337
+ runtimeFriendStatus(did: String!): PerspectiveExpression
338
+ runtimeFriends: [String!]!
339
+ runtimeHcAgentInfos: String!
340
+ runtimeInfo: RuntimeInfo!
341
+ runtimeKnownLinkLanguageTemplates: [String!]!
342
+ runtimeMessageInbox(filter: String): [PerspectiveExpression!]!
343
+ runtimeMessageOutbox(filter: String): [SentMessage!]!
344
+ runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
345
+ }
346
+
347
+ type Resource {
348
+ domain: String!
349
+ pointers: [String!]!
350
+ }
351
+
352
+ input ResourceInput {
353
+ domain: String!
354
+ pointers: [String!]!
355
+ }
356
+
357
+ type RuntimeInfo {
358
+ ad4mExecutorVersion: String!
359
+ isInitialized: Boolean!
360
+ isUnlocked: Boolean!
361
+ }
362
+
363
+ type SentMessage {
364
+ message: PerspectiveExpression!
365
+ recipient: String!
366
+ }
367
+
368
+ type Subscription {
369
+ agentAppsChanged: [Apps!]
370
+ agentStatusChanged: AgentStatus
371
+ agentUpdated: Agent
372
+ exceptionOccurred: ExceptionInfo
373
+ neighbourhoodSignal(perspectiveUUID: String!): PerspectiveExpression
374
+ perspectiveAdded: PerspectiveHandle
375
+ perspectiveLinkAdded(uuid: String!): LinkExpression
376
+ perspectiveLinkRemoved(uuid: String!): LinkExpression
377
+ perspectiveLinkUpdated(uuid: String!): LinkExpressionUpdated
378
+ perspectiveRemoved: String
379
+ perspectiveSyncStateChange(uuid: String!): String!
380
+ perspectiveUpdated: PerspectiveHandle
381
+ runtimeMessageReceived: PerspectiveExpression
382
+ }
@@ -0,0 +1,45 @@
1
+ export declare class PerspectiveAction {
2
+ action: string;
3
+ source: string;
4
+ predicate: string;
5
+ target: string;
6
+ }
7
+ export declare function addLink(source: string, predicate: string, target: string): PerspectiveAction;
8
+ export declare function hasLink(predicate: string): string;
9
+ interface InstanceQueryParams {
10
+ where?: object;
11
+ condition?: string;
12
+ }
13
+ export declare function instanceQuery(options?: InstanceQueryParams): <T>(target: T, key: keyof T, descriptor: PropertyDescriptor) => void;
14
+ interface PropertyOptions {
15
+ through?: string;
16
+ initial?: string;
17
+ required?: boolean;
18
+ writable?: boolean;
19
+ resolveLanguage?: string;
20
+ getter?: string;
21
+ setter?: string;
22
+ local?: boolean;
23
+ }
24
+ export declare function subjectProperty(opts: PropertyOptions): <T>(target: T, key: keyof T) => void;
25
+ interface FlagOptions {
26
+ through: string;
27
+ value: string;
28
+ }
29
+ export declare function subjectFlag(opts: FlagOptions): <T>(target: T, key: keyof T) => void;
30
+ interface WhereOptions {
31
+ isInstance?: any;
32
+ condition?: string;
33
+ }
34
+ interface CollectionOptions {
35
+ through: string;
36
+ where?: WhereOptions;
37
+ local?: boolean;
38
+ }
39
+ export declare function subjectCollection(opts: CollectionOptions): <T>(target: T, key: keyof T) => void;
40
+ export declare function makeRandomPrologAtom(length: number): string;
41
+ interface SDNAClassOptions {
42
+ name: string;
43
+ }
44
+ export declare function SDNAClass(opts: SDNAClassOptions): (target: any) => void;
45
+ export {};
@@ -0,0 +1,250 @@
1
+ import { Subject } from "./Subject";
2
+ import { capitalize, propertyNameToSetterName, singularToPlural, stringifyObjectLiteral } from "./util";
3
+ export class PerspectiveAction {
4
+ }
5
+ export function addLink(source, predicate, target) {
6
+ return {
7
+ action: "addLink",
8
+ source,
9
+ predicate,
10
+ target,
11
+ };
12
+ }
13
+ export function hasLink(predicate) {
14
+ return `triple(this, "${predicate}", _)`;
15
+ }
16
+ export function instanceQuery(options) {
17
+ return function (target, key, descriptor) {
18
+ const originalMethod = descriptor.value;
19
+ if (typeof originalMethod !== "function") {
20
+ throw new Error("instanceQuery decorator can only be applied to methods");
21
+ }
22
+ descriptor.value = async function (perspective) {
23
+ let instances = [];
24
+ //@ts-ignore
25
+ let subjectClassName = target.name;
26
+ let query = `subject_class("${subjectClassName}", C), instance(C, Instance)`;
27
+ if (options && options.where) {
28
+ for (let prop in options.where) {
29
+ let value = options.where[prop];
30
+ query += `, property_getter(C, Instance, "${prop}", "${value}")`;
31
+ }
32
+ }
33
+ if (options && options.condition) {
34
+ query += ', ' + options.condition;
35
+ }
36
+ let results = await perspective.infer(query);
37
+ if (results == false) {
38
+ return instances;
39
+ }
40
+ if (typeof results == "string") {
41
+ throw results;
42
+ }
43
+ for (let result of results) {
44
+ let instance = result.Instance;
45
+ let subject = new Subject(perspective, instance, subjectClassName);
46
+ await subject.init();
47
+ instances.push(subject);
48
+ }
49
+ return instances;
50
+ };
51
+ };
52
+ }
53
+ export function subjectProperty(opts) {
54
+ return function (target, key) {
55
+ target["__properties"] = target["__properties"] || {};
56
+ target["__properties"][key] = target["__properties"][key] || {};
57
+ target["__properties"][key] = { ...target["__properties"][key], ...opts };
58
+ if (opts.writable) {
59
+ const value = key;
60
+ target[`set${capitalize(value)}`] = () => { };
61
+ }
62
+ Object.defineProperty(target, key, { configurable: true, writable: true });
63
+ };
64
+ }
65
+ export function subjectFlag(opts) {
66
+ return function (target, key) {
67
+ target["__properties"] = target["__properties"] || {};
68
+ target["__properties"][key] = target["__properties"][key] || {};
69
+ target["__properties"][key] = {
70
+ ...target["__properties"][key],
71
+ through: opts.through,
72
+ required: true,
73
+ initial: opts.value,
74
+ flag: true
75
+ };
76
+ // @ts-ignore
77
+ target[key] = opts.value;
78
+ Object.defineProperty(target, key, { configurable: true, writable: true });
79
+ };
80
+ }
81
+ export function subjectCollection(opts) {
82
+ return function (target, key) {
83
+ target["__collections"] = target["__collections"] || {};
84
+ target["__collections"][key] = opts;
85
+ const value = key;
86
+ target[`add${capitalize(value)}`] = () => { };
87
+ target[`remove${capitalize(value)}`] = () => { };
88
+ target[`setCollection${capitalize(value)}`] = () => { };
89
+ Object.defineProperty(target, key, { configurable: true, writable: true });
90
+ };
91
+ }
92
+ export function makeRandomPrologAtom(length) {
93
+ let result = '';
94
+ let characters = 'abcdefghijklmnopqrstuvwxyz';
95
+ let charactersLength = characters.length;
96
+ for (let i = 0; i < length; i++) {
97
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
98
+ }
99
+ return result;
100
+ }
101
+ export function SDNAClass(opts) {
102
+ return function (target) {
103
+ target.prototype.className = opts.name;
104
+ target.className = opts.name;
105
+ target.generateSDNA = function () {
106
+ let sdna = "";
107
+ let subjectName = opts.name;
108
+ let obj = target.prototype;
109
+ let uuid = makeRandomPrologAtom(8);
110
+ sdna += `subject_class("${subjectName}", ${uuid}).\n`;
111
+ let classRemoverActions = [];
112
+ let constructorActions = [];
113
+ if (obj.subjectConstructor && obj.subjectConstructor.length) {
114
+ constructorActions = constructorActions.concat(obj.subjectConstructor);
115
+ }
116
+ let instanceConditions = [];
117
+ if (obj.isSubjectInstance && obj.isSubjectInstance.length) {
118
+ instanceConditions = instanceConditions.concat(obj.isSubjectInstance);
119
+ }
120
+ let propertiesCode = [];
121
+ let properties = obj.__properties || {};
122
+ for (let property in properties) {
123
+ let propertyCode = `property(${uuid}, "${property}").\n`;
124
+ let { through, initial, required, resolveLanguage, writable, flag, getter, setter, local } = properties[property];
125
+ if (resolveLanguage) {
126
+ propertyCode += `property_resolve(${uuid}, "${property}").\n`;
127
+ propertyCode += `property_resolve_language(${uuid}, "${property}", "${resolveLanguage}").\n`;
128
+ }
129
+ if (getter) {
130
+ propertyCode += `property_getter(${uuid}, Base, "${property}", Value) :- ${getter}.\n`;
131
+ }
132
+ else if (through) {
133
+ propertyCode += `property_getter(${uuid}, Base, "${property}", Value) :- triple(Base, "${through}", Value).\n`;
134
+ if (required) {
135
+ if (flag) {
136
+ instanceConditions.push(`triple(Base, "${through}", "${initial}")`);
137
+ }
138
+ else {
139
+ instanceConditions.push(`triple(Base, "${through}", _)`);
140
+ }
141
+ }
142
+ }
143
+ if (setter) {
144
+ propertyCode += `property_setter(${uuid}, "${property}", Actions) :- ${setter}.\n`;
145
+ }
146
+ else if (writable) {
147
+ let setter = obj[propertyNameToSetterName(property)];
148
+ if (typeof setter === "function") {
149
+ let action = [{
150
+ action: "setSingleTarget",
151
+ source: "this",
152
+ predicate: through,
153
+ target: "value",
154
+ ...(local && { local: true })
155
+ }];
156
+ propertyCode += `property_setter(${uuid}, "${property}", '${stringifyObjectLiteral(action)}').\n`;
157
+ }
158
+ }
159
+ propertiesCode.push(propertyCode);
160
+ if (initial) {
161
+ constructorActions.push({
162
+ action: "addLink",
163
+ source: "this",
164
+ predicate: through,
165
+ target: initial,
166
+ });
167
+ classRemoverActions.push({
168
+ action: "removeLink",
169
+ source: "this",
170
+ predicate: through,
171
+ target: initial,
172
+ });
173
+ }
174
+ }
175
+ let collectionsCode = [];
176
+ let collections = obj.__collections || {};
177
+ for (let collection in collections) {
178
+ let collectionCode = `collection(${uuid}, "${collection}").\n`;
179
+ let { through, where, local } = collections[collection];
180
+ if (through) {
181
+ if (where) {
182
+ if (!where.isInstance && !where.condition) {
183
+ throw "'where' needs one of 'isInstance' or 'condition'";
184
+ }
185
+ let conditions = [];
186
+ if (where.isInstance) {
187
+ let otherClass;
188
+ if (where.isInstance.name) {
189
+ otherClass = where.isInstance.name;
190
+ }
191
+ else {
192
+ otherClass = where.isInstance;
193
+ }
194
+ conditions.push(`instance(OtherClass, Target), subject_class("${otherClass}", OtherClass)`);
195
+ }
196
+ if (where.condition) {
197
+ conditions.push(where.condition);
198
+ }
199
+ const conditionString = conditions.join(", ");
200
+ collectionCode += `collection_getter(${uuid}, Base, "${collection}", List) :- setof(Target, (triple(Base, "${through}", Target), ${conditionString}), List).\n`;
201
+ }
202
+ else {
203
+ collectionCode += `collection_getter(${uuid}, Base, "${collection}", List) :- findall(C, triple(Base, "${through}", C), List).\n`;
204
+ }
205
+ let collectionAdderAction = [{
206
+ action: "addLink",
207
+ source: "this",
208
+ predicate: through,
209
+ target: "value",
210
+ ...(local && { local: true })
211
+ }];
212
+ let collectionRemoverAction = [{
213
+ action: "removeLink",
214
+ source: "this",
215
+ predicate: through,
216
+ target: "value",
217
+ }];
218
+ let collectionSetterAction = [{
219
+ action: "collectionSetter",
220
+ source: "this",
221
+ predicate: through,
222
+ target: "value",
223
+ ...(local && { local: true })
224
+ }];
225
+ collectionCode += `collection_adder(${uuid}, "${singularToPlural(collection)}", '${stringifyObjectLiteral(collectionAdderAction)}').\n`;
226
+ collectionCode += `collection_remover(${uuid}, "${singularToPlural(collection)}", '${stringifyObjectLiteral(collectionRemoverAction)}').\n`;
227
+ collectionCode += `collection_setter(${uuid}, "${singularToPlural(collection)}", '${stringifyObjectLiteral(collectionSetterAction)}').\n`;
228
+ }
229
+ collectionsCode.push(collectionCode);
230
+ }
231
+ let subjectContructorJSONString = stringifyObjectLiteral(constructorActions);
232
+ sdna += `constructor(${uuid}, '${subjectContructorJSONString}').\n`;
233
+ if (instanceConditions.length > 0) {
234
+ let instanceConditionProlog = instanceConditions.join(", ");
235
+ sdna += `instance(${uuid}, Base) :- ${instanceConditionProlog}.\n`;
236
+ sdna += "\n";
237
+ }
238
+ sdna += `destructor(${uuid}, '${stringifyObjectLiteral(classRemoverActions)}').\n`;
239
+ sdna += "\n";
240
+ sdna += propertiesCode.join("\n");
241
+ sdna += "\n";
242
+ sdna += collectionsCode.join("\n");
243
+ return {
244
+ sdna,
245
+ name: subjectName
246
+ };
247
+ };
248
+ Object.defineProperty(target, 'type', { configurable: true });
249
+ };
250
+ }
@@ -0,0 +1,7 @@
1
+ import { PerspectiveProxy } from "../perspectives/PerspectiveProxy";
2
+ export declare class Subject {
3
+ #private;
4
+ constructor(perspective: PerspectiveProxy, baseExpression: string, subjectClass: string);
5
+ get baseExpression(): string;
6
+ init(): Promise<void>;
7
+ }