@coasys/ad4m 0.13.0-test-2 → 0.13.0-test-4

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 (347) hide show
  1. package/README.md +2 -25
  2. package/jest-setup.ts +1 -1
  3. package/lib/index.cjs +2805 -10556
  4. package/lib/index.js +2513 -10322
  5. package/lib/src/Ad4mClient.d.ts +7 -3
  6. package/lib/src/Ad4mClient.js +29 -13
  7. package/lib/src/agent/Agent.js +26 -272
  8. package/lib/src/agent/AgentClient.d.ts +10 -21
  9. package/lib/src/agent/AgentClient.js +75 -427
  10. package/lib/src/agent/AgentStatus.js +2 -37
  11. package/lib/src/ai/AIClient.d.ts +12 -4
  12. package/lib/src/ai/AIClient.js +81 -285
  13. package/lib/src/ai/AITypes.d.ts +55 -0
  14. package/lib/src/ai/AITypes.js +18 -0
  15. package/lib/src/ai/Tasks.js +10 -133
  16. package/lib/src/apiClient.d.ts +52 -0
  17. package/lib/src/apiClient.js +231 -0
  18. package/lib/src/expression/Expression.d.ts +1 -1
  19. package/lib/src/expression/Expression.js +13 -122
  20. package/lib/src/expression/ExpressionClient.d.ts +3 -3
  21. package/lib/src/expression/ExpressionClient.js +13 -76
  22. package/lib/src/expression/ExpressionRef.js +2 -25
  23. package/lib/src/generated/api/AIModelLoadingStatus.d.ts +7 -0
  24. package/lib/src/generated/api/AIModelLoadingStatus.js +2 -0
  25. package/lib/src/generated/api/AddLinkExpressionRequest.d.ts +6 -0
  26. package/lib/src/generated/api/AddLinkExpressionRequest.js +1 -0
  27. package/lib/src/generated/api/AddLinkRequest.d.ts +6 -0
  28. package/lib/src/generated/api/AddLinkRequest.js +1 -0
  29. package/lib/src/generated/api/AddLinksBulkRequest.d.ts +6 -0
  30. package/lib/src/generated/api/AddLinksBulkRequest.js +1 -0
  31. package/lib/src/generated/api/AddSdnaRequest.d.ts +6 -0
  32. package/lib/src/generated/api/AddSdnaRequest.js +2 -0
  33. package/lib/src/generated/api/ApplyTemplateRequest.d.ts +4 -0
  34. package/lib/src/generated/api/ApplyTemplateRequest.js +2 -0
  35. package/lib/src/generated/api/AuthInfoInput.d.ts +10 -0
  36. package/lib/src/generated/api/AuthInfoInput.js +1 -0
  37. package/lib/src/generated/api/CapabilityInput.d.ts +5 -0
  38. package/lib/src/generated/api/CapabilityInput.js +1 -0
  39. package/lib/src/generated/api/CommitBatchRequest.d.ts +3 -0
  40. package/lib/src/generated/api/CommitBatchRequest.js +2 -0
  41. package/lib/src/generated/api/ComputeLogEntry.d.ts +9 -0
  42. package/lib/src/generated/api/ComputeLogEntry.js +2 -0
  43. package/lib/src/generated/api/CreateExpressionRequest.d.ts +4 -0
  44. package/lib/src/generated/api/CreateExpressionRequest.js +2 -0
  45. package/lib/src/generated/api/CreatePerspectiveRequest.d.ts +3 -0
  46. package/lib/src/generated/api/CreatePerspectiveRequest.js +2 -0
  47. package/lib/src/generated/api/CreateSubjectRequest.d.ts +6 -0
  48. package/lib/src/generated/api/CreateSubjectRequest.js +2 -0
  49. package/lib/src/generated/api/EmbedRequest.d.ts +4 -0
  50. package/lib/src/generated/api/EmbedRequest.js +2 -0
  51. package/lib/src/generated/api/EntanglementProofInput.d.ts +6 -0
  52. package/lib/src/generated/api/EntanglementProofInput.js +2 -0
  53. package/lib/src/generated/api/ExecuteCommandsRequest.d.ts +4 -0
  54. package/lib/src/generated/api/ExecuteCommandsRequest.js +2 -0
  55. package/lib/src/generated/api/ExportRequest.d.ts +5 -0
  56. package/lib/src/generated/api/ExportRequest.js +2 -0
  57. package/lib/src/generated/api/ExpressionManyRequest.d.ts +3 -0
  58. package/lib/src/generated/api/ExpressionManyRequest.js +2 -0
  59. package/lib/src/generated/api/ExpressionProof.d.ts +4 -0
  60. package/lib/src/generated/api/ExpressionProof.js +2 -0
  61. package/lib/src/generated/api/ExpressionProofInput.d.ts +6 -0
  62. package/lib/src/generated/api/ExpressionProofInput.js +2 -0
  63. package/lib/src/generated/api/FriendSendMessageRequest.d.ts +3 -0
  64. package/lib/src/generated/api/FriendSendMessageRequest.js +2 -0
  65. package/lib/src/generated/api/FriendsListRequest.d.ts +3 -0
  66. package/lib/src/generated/api/FriendsListRequest.js +2 -0
  67. package/lib/src/generated/api/GenerateAgentRequest.d.ts +3 -0
  68. package/lib/src/generated/api/GenerateAgentRequest.js +2 -0
  69. package/lib/src/generated/api/GenerateJwtRequest.d.ts +4 -0
  70. package/lib/src/generated/api/GenerateJwtRequest.js +2 -0
  71. package/lib/src/generated/api/GetSubjectDataRequest.d.ts +4 -0
  72. package/lib/src/generated/api/GetSubjectDataRequest.js +2 -0
  73. package/lib/src/generated/api/ImportAgentRequest.d.ts +6 -0
  74. package/lib/src/generated/api/ImportAgentRequest.js +2 -0
  75. package/lib/src/generated/api/ImportRequest.d.ts +4 -0
  76. package/lib/src/generated/api/ImportRequest.js +2 -0
  77. package/lib/src/generated/api/JoinNeighbourhoodRequest.d.ts +3 -0
  78. package/lib/src/generated/api/JoinNeighbourhoodRequest.js +2 -0
  79. package/lib/src/generated/api/LanguageMetaInput.d.ts +6 -0
  80. package/lib/src/generated/api/LanguageMetaInput.js +2 -0
  81. package/lib/src/generated/api/Link.d.ts +5 -0
  82. package/lib/src/generated/api/Link.js +2 -0
  83. package/lib/src/generated/api/LinkExpression.d.ts +10 -0
  84. package/lib/src/generated/api/LinkExpression.js +1 -0
  85. package/lib/src/generated/api/LinkExpressionInput.d.ts +10 -0
  86. package/lib/src/generated/api/LinkExpressionInput.js +1 -0
  87. package/lib/src/generated/api/LinkInput.d.ts +5 -0
  88. package/lib/src/generated/api/LinkInput.js +2 -0
  89. package/lib/src/generated/api/LinkLanguageTemplatesRequest.d.ts +3 -0
  90. package/lib/src/generated/api/LinkLanguageTemplatesRequest.js +2 -0
  91. package/lib/src/generated/api/LinkMutations.d.ts +6 -0
  92. package/lib/src/generated/api/LinkMutations.js +1 -0
  93. package/lib/src/generated/api/LinkStatus.d.ts +1 -0
  94. package/lib/src/generated/api/LinkStatus.js +2 -0
  95. package/lib/src/generated/api/LockAgentRequest.d.ts +3 -0
  96. package/lib/src/generated/api/LockAgentRequest.js +2 -0
  97. package/lib/src/generated/api/ModelType.d.ts +1 -0
  98. package/lib/src/generated/api/ModelType.js +2 -0
  99. package/lib/src/generated/api/NotificationInput.d.ts +10 -0
  100. package/lib/src/generated/api/NotificationInput.js +2 -0
  101. package/lib/src/generated/api/OpenLinkRequest.d.ts +3 -0
  102. package/lib/src/generated/api/OpenLinkRequest.js +2 -0
  103. package/lib/src/generated/api/PermitCapabilityRequest.d.ts +3 -0
  104. package/lib/src/generated/api/PermitCapabilityRequest.js +2 -0
  105. package/lib/src/generated/api/PerspectiveInput.d.ts +4 -0
  106. package/lib/src/generated/api/PerspectiveInput.js +1 -0
  107. package/lib/src/generated/api/PromptRequest.d.ts +4 -0
  108. package/lib/src/generated/api/PromptRequest.js +2 -0
  109. package/lib/src/generated/api/PublishLanguageRequest.d.ts +5 -0
  110. package/lib/src/generated/api/PublishLanguageRequest.js +1 -0
  111. package/lib/src/generated/api/PublishNeighbourhoodRequest.d.ts +6 -0
  112. package/lib/src/generated/api/PublishNeighbourhoodRequest.js +1 -0
  113. package/lib/src/generated/api/QueryRequest.d.ts +7 -0
  114. package/lib/src/generated/api/QueryRequest.js +2 -0
  115. package/lib/src/generated/api/RemoveLinkRequest.d.ts +5 -0
  116. package/lib/src/generated/api/RemoveLinkRequest.js +1 -0
  117. package/lib/src/generated/api/RemoveLinksBulkRequest.d.ts +5 -0
  118. package/lib/src/generated/api/RemoveLinksBulkRequest.js +1 -0
  119. package/lib/src/generated/api/ResourceInput.d.ts +4 -0
  120. package/lib/src/generated/api/ResourceInput.js +2 -0
  121. package/lib/src/generated/api/SetDefaultModelRequest.d.ts +4 -0
  122. package/lib/src/generated/api/SetDefaultModelRequest.js +1 -0
  123. package/lib/src/generated/api/SetFreeHostingEnabledRequest.d.ts +3 -0
  124. package/lib/src/generated/api/SetFreeHostingEnabledRequest.js +2 -0
  125. package/lib/src/generated/api/SetMultiUserRequest.d.ts +3 -0
  126. package/lib/src/generated/api/SetMultiUserRequest.js +2 -0
  127. package/lib/src/generated/api/SetStatusRequest.d.ts +3 -0
  128. package/lib/src/generated/api/SetStatusRequest.js +2 -0
  129. package/lib/src/generated/api/SignMessageRequest.d.ts +3 -0
  130. package/lib/src/generated/api/SignMessageRequest.js +2 -0
  131. package/lib/src/generated/api/TrustedAgentsRequest.d.ts +3 -0
  132. package/lib/src/generated/api/TrustedAgentsRequest.js +2 -0
  133. package/lib/src/generated/api/UnlockAgentRequest.d.ts +4 -0
  134. package/lib/src/generated/api/UnlockAgentRequest.js +2 -0
  135. package/lib/src/generated/api/UpdateLinkRequest.d.ts +7 -0
  136. package/lib/src/generated/api/UpdateLinkRequest.js +1 -0
  137. package/lib/src/generated/api/UpdatePerspectiveRequest.d.ts +3 -0
  138. package/lib/src/generated/api/UpdatePerspectiveRequest.js +2 -0
  139. package/lib/src/generated/api/UserStatistics.d.ts +9 -0
  140. package/lib/src/generated/api/UserStatistics.js +2 -0
  141. package/lib/src/generated/api/VerificationRequestResult.d.ts +6 -0
  142. package/lib/src/generated/api/VerificationRequestResult.js +2 -0
  143. package/lib/src/generated/api/VerifySignatureRequest.d.ts +5 -0
  144. package/lib/src/generated/api/VerifySignatureRequest.js +2 -0
  145. package/lib/src/generated/api/WriteSettingsRequest.d.ts +3 -0
  146. package/lib/src/generated/api/WriteSettingsRequest.js +2 -0
  147. package/lib/src/generated/api/index.d.ts +42 -0
  148. package/lib/src/generated/api/index.js +7 -0
  149. package/lib/src/index.d.ts +6 -2
  150. package/lib/src/index.js +6 -2
  151. package/lib/src/jestSetup.d.ts +0 -1
  152. package/lib/src/jestSetup.js +1 -1
  153. package/lib/src/language/Icon.js +2 -21
  154. package/lib/src/language/Language.d.ts +26 -214
  155. package/lib/src/language/Language.js +32 -72
  156. package/lib/src/language/LanguageClient.d.ts +2 -2
  157. package/lib/src/language/LanguageClient.js +15 -105
  158. package/lib/src/language/LanguageHandle.js +2 -41
  159. package/lib/src/language/LanguageMeta.js +4 -75
  160. package/lib/src/language/LanguageRef.js +2 -25
  161. package/lib/src/links/Links.js +14 -111
  162. package/lib/src/model/Ad4mModel.d.ts +81 -38
  163. package/lib/src/model/Ad4mModel.js +651 -408
  164. package/lib/src/model/Ad4mModel.test.js +488 -750
  165. package/lib/src/model/ModelQueryBuilder.d.ts +28 -21
  166. package/lib/src/model/ModelQueryBuilder.js +160 -195
  167. package/lib/src/model/decorators.d.ts +22 -0
  168. package/lib/src/model/decorators.js +7 -0
  169. package/lib/src/model/hydration-batching.test.d.ts +7 -0
  170. package/lib/src/model/hydration-batching.test.js +456 -0
  171. package/lib/src/model/hydration.d.ts +8 -60
  172. package/lib/src/model/hydration.js +41 -541
  173. package/lib/src/model/index.d.ts +0 -4
  174. package/lib/src/model/index.js +0 -4
  175. package/lib/src/model/model-manifest.d.ts +41 -0
  176. package/lib/src/model/model-manifest.js +11 -0
  177. package/lib/src/model/query-sparql.d.ts +36 -22
  178. package/lib/src/model/query-sparql.js +188 -53
  179. package/lib/src/model/query-sparql.test.d.ts +1 -0
  180. package/lib/src/model/query-sparql.test.js +312 -0
  181. package/lib/src/model/query-utils.js +4 -0
  182. package/lib/src/model/shacl-gen.js +4 -0
  183. package/lib/src/model/subscription-delta.test.d.ts +24 -0
  184. package/lib/src/model/subscription-delta.test.js +180 -0
  185. package/lib/src/model/subscription-pool.js +48 -2
  186. package/lib/src/model/types.d.ts +58 -1
  187. package/lib/src/model/types.js +4 -1
  188. package/lib/src/neighbourhood/Neighbourhood.js +4 -32
  189. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +3 -3
  190. package/lib/src/neighbourhood/NeighbourhoodClient.js +40 -203
  191. package/lib/src/perspectives/LinkQuery.js +2 -42
  192. package/lib/src/perspectives/Perspective.d.ts +1 -1
  193. package/lib/src/perspectives/Perspective.js +10 -52
  194. package/lib/src/perspectives/PerspectiveClient.d.ts +12 -15
  195. package/lib/src/perspectives/PerspectiveClient.js +168 -400
  196. package/lib/src/perspectives/PerspectiveClient.test.d.ts +1 -0
  197. package/lib/src/perspectives/PerspectiveClient.test.js +224 -0
  198. package/lib/src/perspectives/PerspectiveDiff.js +4 -31
  199. package/lib/src/perspectives/PerspectiveHandle.js +3 -43
  200. package/lib/src/perspectives/PerspectiveProxy.d.ts +95 -71
  201. package/lib/src/perspectives/PerspectiveProxy.js +288 -310
  202. package/lib/src/runtime/RuntimeClient.d.ts +6 -6
  203. package/lib/src/runtime/RuntimeClient.js +93 -467
  204. package/lib/src/runtime/RuntimeTypes.d.ts +101 -0
  205. package/lib/src/runtime/RuntimeTypes.js +45 -0
  206. package/lib/src/shacl/SHACLShape.d.ts +7 -0
  207. package/lib/src/shacl/SHACLShape.js +19 -0
  208. package/lib/src/shacl/SHACLShape.test.js +82 -0
  209. package/lib/src/typeDefs.js +3 -628
  210. package/package.json +9 -24
  211. package/rollup.config.js +0 -7
  212. package/src/Ad4mClient.test.ts +1182 -1288
  213. package/src/Ad4mClient.ts +30 -15
  214. package/src/agent/Agent.ts +0 -99
  215. package/src/agent/AgentClient.ts +112 -526
  216. package/src/agent/AgentStatus.ts +0 -12
  217. package/src/ai/AIClient.ts +96 -296
  218. package/src/ai/AITypes.ts +66 -0
  219. package/src/ai/Tasks.ts +0 -52
  220. package/src/apiClient.ts +283 -0
  221. package/src/expression/Expression.ts +3 -43
  222. package/src/expression/ExpressionClient.ts +14 -77
  223. package/src/expression/ExpressionRef.ts +0 -6
  224. package/src/generated/api/AIModelLoadingStatus.ts +3 -0
  225. package/src/generated/api/AddLinkExpressionRequest.ts +4 -0
  226. package/src/generated/api/AddLinkRequest.ts +4 -0
  227. package/src/generated/api/AddLinksBulkRequest.ts +4 -0
  228. package/src/generated/api/AddSdnaRequest.ts +3 -0
  229. package/src/generated/api/ApplyTemplateRequest.ts +3 -0
  230. package/src/generated/api/AuthInfoInput.ts +4 -0
  231. package/src/generated/api/CapabilityInput.ts +4 -0
  232. package/src/generated/api/CommitBatchRequest.ts +3 -0
  233. package/src/generated/api/ComputeLogEntry.ts +3 -0
  234. package/src/generated/api/CreateExpressionRequest.ts +3 -0
  235. package/src/generated/api/CreatePerspectiveRequest.ts +3 -0
  236. package/src/generated/api/CreateSubjectRequest.ts +3 -0
  237. package/src/generated/api/EmbedRequest.ts +3 -0
  238. package/src/generated/api/EntanglementProofInput.ts +3 -0
  239. package/src/generated/api/ExecuteCommandsRequest.ts +3 -0
  240. package/src/generated/api/ExportRequest.ts +3 -0
  241. package/src/generated/api/ExpressionManyRequest.ts +3 -0
  242. package/src/generated/api/ExpressionProof.ts +3 -0
  243. package/src/generated/api/ExpressionProofInput.ts +3 -0
  244. package/src/generated/api/FriendSendMessageRequest.ts +3 -0
  245. package/src/generated/api/FriendsListRequest.ts +3 -0
  246. package/src/generated/api/GenerateAgentRequest.ts +3 -0
  247. package/src/generated/api/GenerateJwtRequest.ts +3 -0
  248. package/src/generated/api/GetSubjectDataRequest.ts +3 -0
  249. package/src/generated/api/ImportAgentRequest.ts +3 -0
  250. package/src/generated/api/ImportRequest.ts +3 -0
  251. package/src/generated/api/JoinNeighbourhoodRequest.ts +3 -0
  252. package/src/generated/api/LanguageMetaInput.ts +3 -0
  253. package/src/generated/api/Link.ts +3 -0
  254. package/src/generated/api/LinkExpression.ts +6 -0
  255. package/src/generated/api/LinkExpressionInput.ts +6 -0
  256. package/src/generated/api/LinkInput.ts +3 -0
  257. package/src/generated/api/LinkLanguageTemplatesRequest.ts +3 -0
  258. package/src/generated/api/LinkMutations.ts +5 -0
  259. package/src/generated/api/LinkStatus.ts +3 -0
  260. package/src/generated/api/LockAgentRequest.ts +3 -0
  261. package/src/generated/api/ModelType.ts +3 -0
  262. package/src/generated/api/NotificationInput.ts +3 -0
  263. package/src/generated/api/OpenLinkRequest.ts +3 -0
  264. package/src/generated/api/PermitCapabilityRequest.ts +3 -0
  265. package/src/generated/api/PerspectiveInput.ts +4 -0
  266. package/src/generated/api/PromptRequest.ts +3 -0
  267. package/src/generated/api/PublishLanguageRequest.ts +4 -0
  268. package/src/generated/api/PublishNeighbourhoodRequest.ts +4 -0
  269. package/src/generated/api/QueryRequest.ts +6 -0
  270. package/src/generated/api/RemoveLinkRequest.ts +4 -0
  271. package/src/generated/api/RemoveLinksBulkRequest.ts +4 -0
  272. package/src/generated/api/ResourceInput.ts +3 -0
  273. package/src/generated/api/SetDefaultModelRequest.ts +4 -0
  274. package/src/generated/api/SetFreeHostingEnabledRequest.ts +3 -0
  275. package/src/generated/api/SetMultiUserRequest.ts +3 -0
  276. package/src/generated/api/SetStatusRequest.ts +3 -0
  277. package/src/generated/api/SignMessageRequest.ts +3 -0
  278. package/src/generated/api/TrustedAgentsRequest.ts +3 -0
  279. package/src/generated/api/UnlockAgentRequest.ts +3 -0
  280. package/src/generated/api/UpdateLinkRequest.ts +5 -0
  281. package/src/generated/api/UpdatePerspectiveRequest.ts +3 -0
  282. package/src/generated/api/UserStatistics.ts +3 -0
  283. package/src/generated/api/VerificationRequestResult.ts +3 -0
  284. package/src/generated/api/VerifySignatureRequest.ts +3 -0
  285. package/src/generated/api/WriteSettingsRequest.ts +3 -0
  286. package/src/generated/api/index.ts +49 -0
  287. package/src/index.ts +6 -2
  288. package/src/jestSetup.ts +1 -1
  289. package/src/language/Icon.ts +0 -4
  290. package/src/language/Language.ts +50 -292
  291. package/src/language/LanguageClient.ts +21 -132
  292. package/src/language/LanguageHandle.ts +0 -14
  293. package/src/language/LanguageMeta.ts +0 -29
  294. package/src/language/LanguageRef.ts +0 -7
  295. package/src/links/Links.ts +0 -37
  296. package/src/model/Ad4mModel.test.ts +827 -808
  297. package/src/model/Ad4mModel.ts +676 -457
  298. package/src/model/ModelQueryBuilder.ts +199 -217
  299. package/src/model/decorators.ts +29 -0
  300. package/src/model/hydration.ts +17 -572
  301. package/src/model/index.ts +0 -4
  302. package/src/model/query-sparql.test.ts +360 -0
  303. package/src/model/query-sparql.ts +203 -56
  304. package/src/model/query-utils.ts +4 -0
  305. package/src/model/shacl-gen.ts +5 -0
  306. package/src/model/types.ts +62 -1
  307. package/src/neighbourhood/Neighbourhood.ts +0 -9
  308. package/src/neighbourhood/NeighbourhoodClient.ts +42 -207
  309. package/src/neighbourhood/NeighbourhoodProxy.test.ts +34 -36
  310. package/src/perspectives/LinkQuery.ts +0 -15
  311. package/src/perspectives/Perspective.ts +1 -12
  312. package/src/perspectives/PerspectiveClient.test.ts +262 -0
  313. package/src/perspectives/PerspectiveClient.ts +227 -412
  314. package/src/perspectives/PerspectiveDiff.ts +0 -8
  315. package/src/perspectives/PerspectiveHandle.ts +1 -12
  316. package/src/perspectives/PerspectiveProxy.test.ts +41 -0
  317. package/src/perspectives/PerspectiveProxy.ts +325 -348
  318. package/src/runtime/RuntimeClient.ts +112 -474
  319. package/src/runtime/RuntimeTypes.ts +144 -0
  320. package/src/shacl/SHACLShape.test.ts +94 -0
  321. package/src/shacl/SHACLShape.ts +27 -0
  322. package/src/typeDefs.ts +3 -5
  323. package/tsconfig.json +3 -7
  324. package/lib/src/model/query-surreal.d.ts +0 -44
  325. package/lib/src/model/query-surreal.js +0 -249
  326. package/lib/src/model/surreal-utils.d.ts +0 -42
  327. package/lib/src/model/surreal-utils.js +0 -128
  328. package/shims/reflect-metadata.ts +0 -0
  329. package/shims/type-graphql.ts +0 -75
  330. package/src/PubSub.ts +0 -17
  331. package/src/agent/AgentResolver.ts +0 -263
  332. package/src/ai/AIResolver.ts +0 -372
  333. package/src/buildSchema.ts +0 -43
  334. package/src/expression/ExpressionResolver.ts +0 -64
  335. package/src/language/LanguageContext.ts +0 -37
  336. package/src/language/LanguageResolver.ts +0 -98
  337. package/src/model/Subject.ts +0 -159
  338. package/src/model/hydration-batch.ts +0 -205
  339. package/src/model/prolog-facts.ts +0 -145
  340. package/src/model/query-prolog.ts +0 -148
  341. package/src/model/query-sparql-batch.ts +0 -301
  342. package/src/model/subscription-pool.ts +0 -163
  343. package/src/neighbourhood/NeighbourhoodResolver.ts +0 -100
  344. package/src/perspectives/PerspectiveResolver.ts +0 -364
  345. package/src/runtime/RuntimeResolver.ts +0 -749
  346. package/src/unwrapApolloResult.ts +0 -16
  347. package/tsconfig-browser.json +0 -82
@@ -1,323 +1,81 @@
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 { InputType, Field, ObjectType } from "type-graphql";
7
- import { PerspectiveState } from '../perspectives/PerspectiveHandle';
8
- import { LinkQuery } from '../perspectives/LinkQuery';
9
-
10
- /** Interface of AD4M Languages
11
- *
12
- * Any JavaScript module that implements a create() function that returns an object that implements this interface
13
- * is a valid AD4M language.
14
- * So the AD4M-internal representation of a language is an object that implements this interface.
15
- *
16
- * Since there are a few different kinds of languages, this interface is split into optional sub-interfaces.
17
- * The only required property is the name of the language.
18
- *
19
- * The most usual kind of language is the "Expression Language", which is a language that can be used to create
20
- * and share Expressions.
21
- * For that, implement the expressionsAdapter and expressionUI interface.
22
- *
23
- * The second most common kind of language is the "Link Language", which is a language that builds the core
24
- * of AD4M Neighbourhoods.
25
- * For that, implement the linksAdapter interface.
1
+ import { DID } from "../DID";
2
+ import { PerspectiveExpression } from "../perspectives/Perspective";
3
+
4
+ /**
5
+ * # AD4M Language — client-side types
6
+ *
7
+ * This file only contains the client-visible types that the AD4M REST
8
+ * API exposes on top of a running Language — interaction metadata, online
9
+ * agent records, and the telepresence-signal callback shape.
10
+ *
11
+ * **If you're authoring an AD4M Language**, you don't consume types from
12
+ * here — use [`@coasys/ad4m-ldk`](https://www.npmjs.com/package/@coasys/ad4m-ldk)
13
+ * (or the [Rust ALDK](https://crates.io/crates/ad4m-ldk)), which provide
14
+ * the capability traits, typed runtime-import wrappers, and authoring
15
+ * macros/helpers.
16
+ *
17
+ * The normative interface definition lives in
18
+ * [`docs-src/ad4m-lang.wit`](https://github.com/coasys/ad4m/blob/dev/docs-src/ad4m-lang.wit).
19
+ * The prose spec is
20
+ * [`docs-src/language-interface-spec.md`](https://github.com/coasys/ad4m/blob/dev/docs-src/language-interface-spec.md).
26
21
  */
27
- export interface Language {
28
- readonly name: string;
29
-
30
- /** Flagging expressions as immutable to enable
31
- * expression caching in the ad4m-executor
32
- */
33
- isImmutableExpression?(expression: Address): boolean;
34
-
35
- // Adapter implementations:
36
-
37
- /** ExpressionAdapter implements means of getting an Expression
38
- * by address and putting an expression
39
- */
40
- readonly expressionAdapter?: ExpressionAdapter;
41
-
42
- /** Interface for getting UI/web components for rendering Expressions of this Language */
43
- readonly expressionUI?: ExpressionUI;
44
-
45
- // TODO: Rename linksAdapter to perspectiveSyncAdapter needs a lot of changes elsewhere...
46
- /** Interface of LinkLanguages for the core implementation of Neighbourhoods */
47
- readonly perspectiveSyncAdapter?: PerspectiveSyncAdapter;
48
-
49
- /** Interface for Languages that implement a query return a Perspective (snapshot)
50
- * Used for back-links and wrapping of APIs that implement queries.
51
- */
52
- readonly pespectiveQueryAdapter?: PerspectiveQueryAdapter;
53
22
 
54
- /** Additional Interface of LinkLanguages that support telepresence features,
55
- * that is:
56
- * - seeing who is online and getting a status
57
- * - sending/receiveing p2p signals to other online agents without affecting
58
- * the shared Perspective of the Neighbourhood
59
- * (see TelepresenceAdapter for more details)
60
- */
61
- readonly telepresenceAdapter?: TelepresenceAdapter;
62
-
63
- /** Implementation of a Language that defines and stores Languages*/
64
- readonly languageAdapter?: LanguageAdapter;
65
-
66
- /** Optional adapter for getting Expressions by author */
67
- readonly getByAuthorAdapter?: GetByAuthorAdapter;
68
- /** Optional adapter for getting all Expressions */
69
- readonly getAllAdapter?: GetAllAdapter;
70
-
71
- /** Optional adapter for direct messaging between agents */
72
- readonly directMessageAdapter?: DirectMessageAdapter;
73
-
74
- /** Interface for providing UI components for the settings of this Language */
75
- readonly settingsUI?: SettingsUI;
76
-
77
- /** Optional function to make any cleanup/teardown if your language gets deleting in the ad4m-executor */
78
- readonly teardown?: () => void;
79
-
80
- /** All available interactions this agent could execute on given expression */
81
- interactions(expression: Address): Interaction[];
82
- }
83
-
84
- /** UI factories returning web components */
85
- export interface ExpressionUI {
86
- /** Returns JS code of a web component that renders the given expression */
87
- icon(): string;
88
- /** Returns JS code of a web component used to create new expressions */
89
- constructorIcon(): string;
90
- }
23
+ // ----- Interaction metadata --------------------------------------------------
24
+ //
25
+ // Languages optionally publish a list of user-invocable actions per
26
+ // Expression ("interactions"). The runtime surfaces these to UIs via
27
+ // the API as first-class objects.
91
28
 
92
- export interface SettingsUI {
93
- settingsIcon(): string;
94
- }
95
- /** Interface for the most common Expression Languages */
96
- export interface ExpressionAdapter {
97
- /** Returns an Expression by address, or null if there is no Expression
98
- * with that given address
99
- */
100
- get(address: Address): Promise<Expression | null>;
101
-
102
- /** Strategy for putting an expression with needs to be different
103
- * for those two cases:
104
- * 1. PublicSharing means that this language supports the creation
105
- * and sharing of Expressions, which is the common use-case
106
- * 2. ReadOnlyLanguage means that the Language implements a pre-defined
107
- * set of expressions (which can be infinite or finite).
108
- * For example the url-iframe Language which directly maps URLs to
109
- * addresses - meaning every well formed URL is an address in this
110
- * Language. Or a potential Language implementing the verbs/predicates
111
- * of a spec like FOAF.
112
- */
113
- putAdapter: PublicSharing | ReadOnlyLanguage;
114
- }
115
-
116
- /** Implement this interface if your Language supports creation of sharing
117
- * of Expressions.
118
- * See ExpressionAdapter
119
- */
120
- export interface PublicSharing {
121
- /** Create an Expression and shares it.
122
- * Return the Expression's address.
123
- * @param content is the object created by the constructorIcon component
124
- */
125
- createPublic(content: object): Promise<Address>;
126
- }
127
-
128
- /** Implement this interface if your Language is defined over a static
129
- * set of pre-defined Expressions.
130
- */
131
- export interface ReadOnlyLanguage {
132
- /** This just calculates the address of an object
133
- * @param content is the object created by the constructorIcon component
134
- */
135
- addressOf(content: object): Promise<Address>;
136
- }
137
-
138
- export interface LanguageAdapter {
139
- getLanguageSource(address: Address): Promise<string>;
140
- }
141
-
142
- // Implement this if your Language supports retrieval of all Expressions
143
- // authored by a given agent
144
- export interface GetByAuthorAdapter {
145
- /// Get expressions authored by a given Agent/Identity
146
- getByAuthor(author: DID, count: number, page: number): Promise<Expression[] | null>;
147
- }
148
-
149
- // Implement this if your Language supports retrieval of all Expressions
150
- // stored in the space of that Language.
151
- // Might not be trivial (without trade-off) for Holochain or DHTs
152
- // in general - hence not a required interface.
153
- export interface GetAllAdapter {
154
- /// Get expressions authored by a given Agent/Identity
155
- getAll(filter: any, count: number, page: number): Promise<Expression[] | null>;
156
- }
157
-
158
- export type PerspectiveDiffObserver = (diff: PerspectiveDiff)=>void;
159
- export type SyncStateChangeObserver = (state: PerspectiveState)=>void;
160
-
161
- /** Interface for "Link Languages" that facilitate the synchronization
162
- * between agents' local Perspectives inside a Neighbourhood.
163
- * The assumption is that every version of the shared Perspective
164
- * is labeled with a unique revision string.
165
- * Changes are committed and retrieved through diffs.
166
- * Think of a PerspectiveSyncAdapter as a git branch to which agents commit
167
- * their changes to and pull diffs from their current revision
168
- * to the latest one.
169
- */
170
- export interface PerspectiveSyncAdapter {
171
- writable(): boolean;
172
- public(): boolean;
173
- others(): Promise<DID[]>;
174
-
175
- /** What revision are we on now -> what changes are included in output of render() */
176
- currentRevision(): Promise<string>;
177
-
178
- /**
179
- * Check for and get new changes,
180
- * notify others of local changes.
181
- * This function will be called every
182
- * few seconds by the ad4m-executor.
183
- * */
184
- sync(): Promise<PerspectiveDiff>;
185
-
186
- /** Returns the full, rendered Perspective at currentRevision */
187
- render(): Promise<Perspective>;
188
-
189
- /** Publish changes */
190
- commit(diff: PerspectiveDiff): Promise<string>;
191
-
192
- /** Get push notification when a diff got published */
193
- addCallback(callback: PerspectiveDiffObserver);
194
-
195
- /** Add a sync state callback method */
196
- addSyncStateChangeCallback(callback: SyncStateChangeObserver);
197
-
198
- /**
199
- * Set the local agents (DIDs) that own this perspective/neighbourhood.
200
- * This is used to determine which agents should be registered in the DHT.
201
- * Optional - if not implemented, all local agents may be registered.
202
- *
203
- * This is a temporary hack to support multiple users on one node joining the same neighbourhood.
204
- * Once we migrate the LanguageController to Rust and run Languages per user, each user will get their
205
- * own language instance and we won't need to explicitly set local agents. This will provide better
206
- * isolation and avoid the need to share language state between users.
207
- */
208
- setLocalAgents?(agents: DID[]): void;
209
- }
210
-
211
- export type MessageCallback = (message: PerspectiveExpression) => void;
212
- export type StatusCallback = (caller: DID) => Perspective;
213
- export interface DirectMessageAdapter {
214
- recipient(): DID;
215
-
216
- status(): Promise<PerspectiveExpression | void>;
217
- sendP2P(message: Perspective): Promise<PerspectiveExpression|void>;
218
- sendInbox(message: Perspective): Promise<PerspectiveExpression|void>;
219
-
220
- setStatus(status: PerspectiveExpression);
221
- inbox(filter?: string): Promise<PerspectiveExpression[]>
222
- addMessageCallback(callback: MessageCallback);
223
- }
224
-
225
- @ObjectType()
226
29
  export class InteractionParameter {
227
- @Field()
228
- name: string
229
-
230
- @Field()
231
- type: string
30
+ name: string;
31
+ type: string;
232
32
  }
233
33
 
234
- @ObjectType()
235
34
  export class InteractionMeta {
236
- @Field()
237
35
  label: string;
238
-
239
- @Field()
240
36
  name: string;
241
-
242
- @Field(type => [InteractionParameter])
243
- parameters: InteractionParameter[]
37
+ parameters: InteractionParameter[];
244
38
  }
39
+
40
+ /**
41
+ * Runtime-side interaction object. The runtime constructs one of these
42
+ * from a Language's `interactions(address)` description and exposes
43
+ * `execute()` to UI callers. Language authors describe interactions
44
+ * via the ALDK, not by constructing this type directly.
45
+ */
245
46
  export interface Interaction {
246
47
  readonly label: string;
247
48
  readonly name: string;
248
49
  readonly parameters: InteractionParameter[];
249
- execute(parameters: object): Promise<string|null>;
50
+ execute(parameters: object): Promise<string | null>;
250
51
  }
251
52
 
252
- @InputType()
253
53
  export class InteractionCall {
254
- @Field()
255
54
  name: string;
256
- @Field()
257
55
  parametersStringified: string;
258
56
 
259
57
  public get parameters(): object {
260
- return JSON.parse(this.parametersStringified)
58
+ return JSON.parse(this.parametersStringified);
261
59
  }
262
60
 
263
61
  constructor(name: string, parameters: object) {
264
- this.name = name
265
- this.parametersStringified = JSON.stringify(parameters)
62
+ this.name = name;
63
+ this.parametersStringified = JSON.stringify(parameters);
266
64
  }
267
65
  }
268
66
 
269
- @ObjectType()
270
- export class OnlineAgent {
271
- @Field()
272
- did: DID
273
- @Field()
274
- status: PerspectiveExpression
275
- }
276
-
277
- export type TelepresenceSignalCallback = (payload: PerspectiveExpression, recipientDid?: string) => void;
278
- export interface TelepresenceAdapter {
279
- setOnlineStatus(status: PerspectiveExpression): Promise<void>;
280
- getOnlineAgents(): Promise<OnlineAgent[]>;
67
+ // ----- Telepresence ----------------------------------------------------------
281
68
 
282
- sendSignal(remoteAgentDid: string, payload: PerspectiveExpression): Promise<object>;
283
- sendBroadcast(payload: PerspectiveExpression): Promise<object>;
284
- registerSignalCallback(callback: TelepresenceSignalCallback): Promise<void>;
69
+ export class OnlineAgent {
70
+ did: DID;
71
+ status: PerspectiveExpression;
285
72
  }
286
73
 
287
-
288
- /** Interface for Languages that implement queries returning links, i.e. a Perspective (-snapshot)
289
- * Main differentiation between these Languages and LinkLanguages is that this enables
290
- * access to other shared perspectives without forcing a full-sync.
291
- *
292
- * All PerspectiveQuery Languages are supposed to implement `linkQuery` which is a simple graph query
293
- * specifying non or all of source, predicate, target of the links we want to get.
294
- * This is enough to implement simple back-links.
295
- *
296
- * Prolog queries are optional since this requires a Prolog engine to be available.
297
- *
74
+ /**
75
+ * Callback shape used by the client to receive telepresence signals
76
+ * from a Neighbourhood's link Language.
298
77
  */
299
- export interface PerspectiveQueryAdapter {
300
- /** Same semantic as PerspectiveProxy.get(LinkQuery) */
301
- linkQuery(query: LinkQuery): Promise<Perspective>;
302
-
303
- /** Tells ADAM if Prolog queries are implemented by this Language.
304
- * If not, prologQuery won't be used, instead in some circumstances,
305
- * linkQuery() might be called with an all-query, followed by using
306
- * ADAM's internal Prolog engine on the result.
307
- */
308
- supportsPrologQueries(): boolean;
309
-
310
- /** Same semantic as PerspectiveProxy.infer, will return plain Prolog results */
311
- infer(prologQuery: string): Promise<any>
312
-
313
- /** Specify which links shall be returned through Prolog.
314
- * Assumes unbound variables in query that describe a LinkExpression:
315
- * - Source
316
- * - Predicate
317
- * - Target
318
- * - Author
319
- * - Timestamp
320
- * Will construct a Perspective where each link is a solution to the query.
321
- */
322
- prologQuery(query: string): Promise<Perspective>;
323
- }
78
+ export type TelepresenceSignalCallback = (
79
+ payload: PerspectiveExpression,
80
+ recipientDid?: string,
81
+ ) => void;
@@ -1,160 +1,49 @@
1
- import { ApolloClient, gql } from "@apollo/client/core"
2
- import unwrapApolloResult from "../unwrapApolloResult"
1
+ import { ApiClient } from "../apiClient"
3
2
  import { LanguageHandle } from "./LanguageHandle"
4
3
  import { LanguageMeta, LanguageMetaInput } from "./LanguageMeta"
5
4
  import { LanguageRef } from "./LanguageRef"
6
-
7
- const LANGUAGE_COMPLETE = `
8
- name
9
- address
10
- settings
11
- icon { code }
12
- constructorIcon { code }
13
- settingsIcon { code }
14
- `
15
-
16
- const LANGUAGE_META = `
17
- name
18
- address
19
- description
20
- author
21
- templated
22
- templateSourceLanguageAddress
23
- templateAppliedParams
24
- possibleTemplateParams
25
- sourceCodeLink
26
- `
5
+ import type { ApplyTemplateRequest, PublishLanguageRequest, WriteSettingsRequest } from "../generated/api"
27
6
 
28
7
  export class LanguageClient {
29
- #apolloClient: ApolloClient<any>
8
+ #apiClient: ApiClient
30
9
 
31
- constructor(apolloClient: ApolloClient<any>) {
32
- this.#apolloClient = apolloClient
10
+ constructor(baseUrl: string, token?: string, sharedApiClient?: ApiClient) {
11
+ this.#apiClient = sharedApiClient || new ApiClient(baseUrl, token)
33
12
  }
34
13
 
35
14
  async byAddress(address: string): Promise<LanguageHandle> {
36
- const { language } = unwrapApolloResult(await this.#apolloClient.query({
37
- query: gql`query byAddress($address: String!) {
38
- language(address: $address) {
39
- ${LANGUAGE_COMPLETE}
40
- }
41
- }`,
42
- variables: { address }
43
- }))
44
- return language
15
+ return this.#apiClient.call<LanguageHandle>('language.get', { address })
45
16
  }
46
17
 
47
18
  async byFilter(filter: string): Promise<LanguageHandle[]> {
48
- const { languages } = unwrapApolloResult(await this.#apolloClient.query({
49
- query: gql`query byFilter($filter: String!) {
50
- languages(filter: $filter) {
51
- ${LANGUAGE_COMPLETE}
52
- }
53
- }`,
54
- variables: { filter }
55
- }))
56
- return languages
19
+ return this.#apiClient.call<LanguageHandle[]>('language.all', { filter })
57
20
  }
58
21
 
59
22
  async all(): Promise<LanguageHandle[]> {
60
- return this.byFilter('')
23
+ return this.#apiClient.call<LanguageHandle[]>('language.all')
61
24
  }
62
25
 
63
- async writeSettings(
64
- languageAddress: string,
65
- settings: string
66
- ): Promise<Boolean> {
67
- const { languageWriteSettings } = unwrapApolloResult(await this.#apolloClient.mutate({
68
- mutation: gql`mutation writeSettings($languageAddress: String!, $settings: String!) {
69
- languageWriteSettings(languageAddress: $languageAddress, settings: $settings)
70
- }`,
71
- variables: { languageAddress, settings }
72
- }))
73
- return languageWriteSettings
26
+ async writeSettings(languageAddress: string, settings: string): Promise<Boolean> {
27
+ return this.#apiClient.call<Boolean>('language.writeSettings', { address: languageAddress, settings })
74
28
  }
75
29
 
76
- async applyTemplateAndPublish(
77
- sourceLanguageHash: string,
78
- templateData: string
79
- ): Promise<LanguageRef> {
80
- const { languageApplyTemplateAndPublish } = unwrapApolloResult(await this.#apolloClient.mutate({
81
- mutation: gql`mutation languageApplyTemplateAndPublish(
82
- $sourceLanguageHash: String!,
83
- $templateData: String!,
84
- ) {
85
- languageApplyTemplateAndPublish(sourceLanguageHash: $sourceLanguageHash, templateData: $templateData) {
86
- name, address
87
- }
88
- }`,
89
- variables: { sourceLanguageHash, templateData }
90
- }))
91
-
92
- return languageApplyTemplateAndPublish
30
+ async applyTemplateAndPublish(sourceLanguageHash: string, templateData: string): Promise<LanguageRef> {
31
+ return this.#apiClient.call<LanguageRef>('language.applyTemplate', { sourceLanguageHash, templateData })
93
32
  }
94
33
 
95
- async publish(
96
- languagePath: string,
97
- languageMeta: LanguageMetaInput
98
- ): Promise<LanguageMeta> {
99
- const { languagePublish } = unwrapApolloResult(await this.#apolloClient.mutate({
100
- mutation: gql`mutation languagePublish(
101
- $languagePath: String!,
102
- $languageMeta: LanguageMetaInput!,
103
- ) {
104
- languagePublish(languagePath: $languagePath, languageMeta: $languageMeta) {
105
- ${LANGUAGE_META}
106
- }
107
- }`,
108
- variables: { languagePath, languageMeta }
109
- }))
110
-
111
- return languagePublish
34
+ async publish(languagePath: string, languageMeta: LanguageMetaInput): Promise<LanguageMeta> {
35
+ return this.#apiClient.call<LanguageMeta>('language.publish', { languagePath, languageMeta })
112
36
  }
113
37
 
114
- async meta(
115
- address: string,
116
- ): Promise<LanguageMeta> {
117
- const { languageMeta } = unwrapApolloResult(await this.#apolloClient.query({
118
- query: gql`query languageMeta(
119
- $address: String!,
120
- ) {
121
- languageMeta(address: $address) {
122
- ${LANGUAGE_META}
123
- }
124
- }`,
125
- variables: { address }
126
- }))
127
-
128
- return languageMeta
38
+ async meta(address: string): Promise<LanguageMeta> {
39
+ return this.#apiClient.call<LanguageMeta>('language.meta', { address })
129
40
  }
130
41
 
131
- async source(
132
- address: string,
133
- ): Promise<string> {
134
- const { languageSource } = unwrapApolloResult(await this.#apolloClient.query({
135
- query: gql`query languageSource(
136
- $address: String!,
137
- ) {
138
- languageSource(address: $address)
139
- }`,
140
- variables: { address }
141
- }))
142
-
143
- return languageSource
42
+ async source(address: string): Promise<string> {
43
+ return this.#apiClient.call<string>('language.source', { address })
144
44
  }
145
45
 
146
- async remove(
147
- address: string
148
- ): Promise<Boolean> {
149
- const { languageRemove } = unwrapApolloResult(await this.#apolloClient.mutate({
150
- mutation: gql`mutation languageRemove(
151
- $address: String!,
152
- ) {
153
- languageRemove(address: $address)
154
- }`,
155
- variables: { address }
156
- }))
157
-
158
- return languageRemove
46
+ async remove(address: string): Promise<Boolean> {
47
+ return this.#apiClient.call<Boolean>('language.remove', { address })
159
48
  }
160
- }
49
+ }
@@ -1,23 +1,9 @@
1
- import { Field, ObjectType } from "type-graphql";
2
1
  import { Icon } from "./Icon";
3
-
4
- @ObjectType()
5
2
  export class LanguageHandle {
6
- @Field()
7
3
  name: string;
8
-
9
- @Field()
10
4
  address: string;
11
-
12
- @Field({nullable: true})
13
5
  settings?: string;
14
-
15
- @Field({nullable: true})
16
6
  icon?: Icon;
17
-
18
- @Field({nullable: true})
19
7
  constructorIcon?: Icon;
20
-
21
- @Field({nullable: true})
22
8
  settingsIcon?: Icon;
23
9
  }
@@ -1,48 +1,19 @@
1
- import { Field, InputType, ObjectType } from "type-graphql";
2
1
  import { ExpressionGeneric } from "../expression/Expression";
3
-
4
- @ObjectType()
5
2
  export class LanguageMeta {
6
- @Field()
7
3
  name: string;
8
-
9
- @Field()
10
4
  address: string;
11
-
12
- @Field({nullable: true})
13
5
  description: string;
14
-
15
- @Field()
16
6
  author: string;
17
-
18
- @Field({nullable: true})
19
7
  templated: boolean
20
-
21
- @Field({nullable: true})
22
8
  templateSourceLanguageAddress?: string;
23
-
24
- @Field({nullable: true})
25
9
  templateAppliedParams?: string;
26
-
27
- @Field(type => [String], {nullable: true})
28
10
  possibleTemplateParams?: string[];
29
-
30
- @Field({nullable: true})
31
11
  sourceCodeLink?: string;
32
12
  }
33
-
34
- @InputType()
35
13
  export class LanguageMetaInput {
36
- @Field()
37
14
  name: string;
38
-
39
- @Field()
40
15
  description: string;
41
-
42
- @Field(type => [String], {nullable: true})
43
16
  possibleTemplateParams?: string[];
44
-
45
- @Field({nullable: true})
46
17
  sourceCodeLink?: string;
47
18
 
48
19
  constructor(name?: string, description?: string) {
@@ -1,14 +1,7 @@
1
1
  import type { Address } from '../Address'
2
- import { Field, ObjectType } from "type-graphql";
3
-
4
-
5
2
  // Unique Language ID with option type
6
- @ObjectType()
7
3
  export class LanguageRef {
8
- @Field()
9
4
  address: Address;
10
-
11
- @Field()
12
5
  name: string;
13
6
 
14
7
  constructor(address?: Address, name?: string) {