@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,178 @@
1
+ import { LinkCallback, PerspectiveClient, SyncStateChangeCallback } from "./PerspectiveClient";
2
+ import { Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkMutations } from "../links/Links";
3
+ import { LinkQuery } from "./LinkQuery";
4
+ import { PerspectiveHandle, PerspectiveState } from './PerspectiveHandle';
5
+ import { Perspective } from "./Perspective";
6
+ import { ExpressionRendered } from "../expression/Expression";
7
+ import { NeighbourhoodProxy } from "../neighbourhood/NeighbourhoodProxy";
8
+ import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
9
+ type PerspectiveListenerTypes = "link-added" | "link-removed" | "link-updated";
10
+ export type LinkStatus = "shared" | "local";
11
+ interface Parameter {
12
+ name: string;
13
+ value: string;
14
+ }
15
+ /** Perspective UI proxy object
16
+ *
17
+ * Convenience object for UIs to interact with a perspective.
18
+ * It is created by some of the methods in the PerspectiveClient class and includes
19
+ * a reference to the PerspectiveClient object that created it.
20
+ */
21
+ export declare class PerspectiveProxy {
22
+ #private;
23
+ constructor(handle: PerspectiveHandle, ad4m: PerspectiveClient);
24
+ executeAction(actions: any, expression: any, parameters: Parameter[]): Promise<void>;
25
+ /** Unique ID of the perspective */
26
+ get uuid(): string;
27
+ /** Given name of the perspective */
28
+ get name(): string;
29
+ /** If the perspective is shared as a Neighbourhood, this is the Neighbourhood URL */
30
+ get sharedUrl(): string | void;
31
+ /** If the perspective is shared as a Neighbourhood, this is the Neighbourhood Expression */
32
+ get neighbourhood(): NeighbourhoodExpression | void;
33
+ /** Returns the state of the perspective **/
34
+ get state(): PerspectiveState;
35
+ /** Returns all the links of this perspective that matches the LinkQuery */
36
+ get(query: LinkQuery): Promise<LinkExpression[]>;
37
+ /** Runs a Prolog query on the perspective's Prolog engine */
38
+ infer(query: string): Promise<any>;
39
+ /** Adds a link to this perspective */
40
+ add(link: Link, status?: LinkStatus): Promise<LinkExpression>;
41
+ /** Adds multiple links to this perspective **/
42
+ addLinks(links: Link[], status?: LinkStatus): Promise<LinkExpression[]>;
43
+ /** Removes multiple links from this perspective **/
44
+ removeLinks(links: LinkExpressionInput[]): Promise<LinkExpression[]>;
45
+ /** Adds and removes multiple links from this perspective **/
46
+ linkMutations(mutations: LinkMutations, status?: LinkStatus): Promise<LinkExpressionMutations>;
47
+ /** Adds a linkExpression to this perspective */
48
+ addLinkExpression(link: LinkExpression, status?: LinkStatus): Promise<LinkExpression>;
49
+ update(oldLink: LinkExpressionInput, newLink: Link): Promise<LinkExpression>;
50
+ remove(link: LinkExpressionInput): Promise<{
51
+ perspectiveRemoveLink: boolean;
52
+ }>;
53
+ getExpression(expressionURI: string): Promise<ExpressionRendered>;
54
+ createExpression(content: any, languageAddress: string): Promise<string>;
55
+ /** Adds a link listener
56
+ * @param type Can be 'link-added' or 'link-removed'
57
+ * @param cb Callback function that is called when a link is added to the perspective
58
+ */
59
+ addListener(type: PerspectiveListenerTypes, cb: LinkCallback): Promise<void>;
60
+ /** Adds a sync state listener
61
+ * @param cb Callback function that is called when the sync state of the perspective changes
62
+ * @returns A function that can be called to remove the listener
63
+ */
64
+ addSyncStateChangeListener(cb: SyncStateChangeCallback): Promise<void>;
65
+ /** Removes a previously added link listener
66
+ * @param type Can be 'link-added' or 'link-removed'
67
+ * @param cb Callback function that is called when a link is added to the perspective
68
+ */
69
+ removeListener(type: PerspectiveListenerTypes, cb: LinkCallback): Promise<void>;
70
+ /** Create and return a snapshot of this perspective
71
+ * A snapshot is a rendered Perspectie object that contains all the links of the perspective.
72
+ */
73
+ snapshot(): Promise<Perspective>;
74
+ /** Take and load all the links from the given snapshot */
75
+ loadSnapshot(snapshot: Perspective): Promise<void>;
76
+ /** Convenience function to get the target of the first link that matches the given query
77
+ * This makes sense when the query is expected to return only one link
78
+ * and the target of that link is what you are looking for.
79
+ *
80
+ * Works best together with @member setSingelTarget()
81
+ */
82
+ getSingleTarget(query: LinkQuery): Promise<string | void>;
83
+ /** Convenience function to ensure there is only one link with given source and predicate
84
+ * This function will remove all links with the same source and predicate as the given link,
85
+ * and then add the given link.
86
+ * This ensures there is only one target for the given source and predicate.
87
+ *
88
+ * Works best together with @member getSingleTarget()
89
+ */
90
+ setSingleTarget(link: Link, status?: LinkStatus): Promise<void>;
91
+ /** Returns all the Social DNA flows defined in this perspective */
92
+ sdnaFlows(): Promise<string[]>;
93
+ /** Returns all Social DNA flows that can be started from the given expression */
94
+ availableFlows(exprAddr: string): Promise<string[]>;
95
+ /** Starts the Social DNA flow @param flowName on the expression @param exprAddr */
96
+ startFlow(flowName: string, exprAddr: string): Promise<void>;
97
+ /** Returns all expressions in the given state of given Social DNA flow */
98
+ expressionsInFlowState(flowName: string, flowState: number): Promise<string[]>;
99
+ /** Returns the given expression's flow state with regard to given Social DNA flow */
100
+ flowState(flowName: string, exprAddr: string): Promise<number>;
101
+ /** Returns available action names, with regard to Social DNA flow and expression's flow state */
102
+ flowActions(flowName: string, exprAddr: string): Promise<string[]>;
103
+ /** Runs given Social DNA flow action */
104
+ runFlowAction(flowName: string, exprAddr: string, actionName: string): Promise<void>;
105
+ /** Returns the perspective's Social DNA code
106
+ * This will return all SDNA code elements in an array.
107
+ */
108
+ getSdna(): Promise<string[]>;
109
+ /** Adds the given Social DNA code to the perspective's SDNA code */
110
+ addSdna(name: string, sdnaCode: string, type: "subject_class" | "flow" | "custom"): Promise<void>;
111
+ /** Returns all the Subject classes defined in this perspectives SDNA */
112
+ subjectClasses(): Promise<string[]>;
113
+ stringOrTemplateObjectToSubjectClass<T>(subjectClass: T): Promise<string>;
114
+ /** Creates a new subject instance by running its (SDNA defined) constructor,
115
+ * which means adding links around the given expression address so that it
116
+ * conforms to the given subject class.
117
+ *
118
+ * @param subjectClass Either a string with the name of the subject class, or an object
119
+ * with the properties of the subject class. In the latter case, the first subject class
120
+ * that matches the given properties will be used.
121
+ * @param exprAddr The address of the expression to be turned into a subject instance
122
+ */
123
+ createSubject<T>(subjectClass: T, exprAddr: string): Promise<T>;
124
+ /** Removes a subject instance by running its (SDNA defined) destructor,
125
+ * which means removing links around the given expression address
126
+ *
127
+ * @param subjectClass Either a string with the name of the subject class, or an object
128
+ * with the properties of the subject class. In the latter case, the first subject class
129
+ * that matches the given properties will be used.
130
+ * @param exprAddr The address of the expression to be turned into a subject instance
131
+ */
132
+ removeSubject<T>(subjectClass: T, exprAddr: string): Promise<void>;
133
+ /** Checks if the given expression is a subject instance of the given subject class
134
+ * @param expression The expression to be checked
135
+ * @param subjectClass Either a string with the name of the subject class, or an object
136
+ * with the properties of the subject class. In the latter case, the first subject class
137
+ * that matches the given properties will be used.
138
+ */
139
+ isSubjectInstance<T>(expression: string, subjectClass: T): Promise<boolean>;
140
+ /** For an existing subject instance (existing in the perspective's links)
141
+ * this function returns a proxy object that can be used to access the subject's
142
+ * properties and methods.
143
+ *
144
+ * @param base URI of the subject's root expression
145
+ * @param subjectClass Either a string with the name of the subject class, or an object
146
+ * with the properties of the subject class. In the latter case, the first subject class
147
+ * that matches the given properties will be used.
148
+ */
149
+ getSubjectProxy<T>(base: string, subjectClass: T): Promise<T>;
150
+ /** Returns all subject instances of the given subject class as proxy objects.
151
+ * @param subjectClass Either a string with the name of the subject class, or an object
152
+ * with the properties of the subject class. In the latter case, all subject classes
153
+ * that match the given properties will be used.
154
+ */
155
+ getAllSubjectInstances<T>(subjectClass: T): Promise<T[]>;
156
+ getAllSubjectProxies<T>(subjectClass: T): Promise<T[]>;
157
+ /** Returns all subject classes that match the given template object.
158
+ * This function looks at the properties of the template object and
159
+ * its setters and collections to create a Prolog query that finds
160
+ * all subject classes that would be converted to a proxy object
161
+ * with exactly the same properties and collections.
162
+ *
163
+ * Since there could be multiple subject classes that match the given
164
+ * criteria, this function returns a list of class names.
165
+ *
166
+ * @param obj The template object
167
+ */
168
+ subjectClassesByTemplate(obj: object): Promise<string[]>;
169
+ /** Takes a JS class (its constructor) and assumes that it was decorated by
170
+ * the @subjectClass etc. decorators. It then tests if there is a subject class
171
+ * already present in the perspective's SDNA that matches the given class.
172
+ * If there is no such class, it gets the JS class's SDNA by calling its
173
+ * static generateSDNA() function and adds it to the perspective's SDNA.
174
+ */
175
+ ensureSDNASubjectClass(jsClass: any): Promise<void>;
176
+ getNeighbourhoodProxy(): NeighbourhoodProxy;
177
+ }
178
+ export {};