@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.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 (153) hide show
  1. package/jest.config.js +10 -3
  2. package/lib/index.cjs +6893 -5884
  3. package/lib/index.js +6889 -5872
  4. package/lib/src/Ad4mClient.d.ts +9 -16
  5. package/lib/src/Ad4mClient.js +46 -25
  6. package/lib/src/Literal.d.ts +1 -2
  7. package/lib/src/Literal.js +38 -35
  8. package/lib/src/SmartLiteral.d.ts +1 -2
  9. package/lib/src/SmartLiteral.js +30 -15
  10. package/lib/src/agent/AgentClient.d.ts +1 -4
  11. package/lib/src/agent/AgentClient.js +79 -99
  12. package/lib/src/ai/AIClient.d.ts +1 -2
  13. package/lib/src/ai/AIClient.js +224 -220
  14. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  15. package/lib/src/expression/ExpressionClient.js +73 -86
  16. package/lib/src/index.d.ts +1 -1
  17. package/lib/src/index.js +1 -1
  18. package/lib/src/language/LanguageClient.d.ts +1 -1
  19. package/lib/src/language/LanguageClient.js +52 -52
  20. package/lib/src/model/Ad4mModel.d.ts +1351 -144
  21. package/lib/src/model/Ad4mModel.js +3760 -228
  22. package/lib/src/model/Ad4mModel.test.js +522 -979
  23. package/lib/src/model/Subject.d.ts +3 -3
  24. package/lib/src/model/Subject.js +25 -25
  25. package/lib/src/model/decorators.d.ts +444 -100
  26. package/lib/src/model/decorators.js +686 -321
  27. package/lib/src/model/util.d.ts +6 -6
  28. package/lib/src/model/util.js +24 -24
  29. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
  30. package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
  31. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
  32. package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
  33. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
  34. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  35. package/lib/src/perspectives/PerspectiveClient.js +240 -316
  36. package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
  37. package/lib/src/perspectives/PerspectiveProxy.js +485 -832
  38. package/lib/src/runtime/RuntimeClient.d.ts +1 -5
  39. package/lib/src/runtime/RuntimeClient.js +238 -412
  40. package/lib/src/shacl/SHACLFlow.test.js +105 -164
  41. package/lib/src/shacl/SHACLShape.d.ts +12 -17
  42. package/lib/src/shacl/SHACLShape.js +115 -128
  43. package/lib/src/shacl/SHACLShape.test.js +176 -244
  44. package/lib/src/shims/reflect-metadata.d.ts +0 -0
  45. package/lib/src/shims/type-graphql.d.ts +32 -0
  46. package/lib/src/src/Ad4mClient.d.ts +28 -0
  47. package/lib/src/src/Address.d.ts +1 -0
  48. package/lib/src/src/DID.d.ts +1 -0
  49. package/lib/src/src/Exception.d.ts +7 -0
  50. package/lib/src/src/Literal.d.ts +7 -0
  51. package/lib/src/src/PubSub.d.ts +17 -0
  52. package/lib/src/src/SmartLiteral.d.ts +12 -0
  53. package/lib/src/src/agent/Agent.d.ts +110 -0
  54. package/lib/src/src/agent/AgentClient.d.ts +62 -0
  55. package/lib/src/src/agent/AgentResolver.d.ts +30 -0
  56. package/lib/src/src/agent/AgentStatus.d.ts +8 -0
  57. package/lib/src/src/ai/AIClient.d.ts +32 -0
  58. package/lib/src/src/ai/AIResolver.d.ts +75 -0
  59. package/lib/src/src/ai/Tasks.d.ts +37 -0
  60. package/lib/src/src/buildSchema.d.ts +1 -0
  61. package/lib/src/src/expression/Expression.d.ts +28 -0
  62. package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
  63. package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
  64. package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
  65. package/lib/src/src/index.d.ts +35 -0
  66. package/lib/src/src/jestSetup.d.ts +1 -0
  67. package/lib/src/src/language/Icon.d.ts +4 -0
  68. package/lib/src/src/language/Language.d.ts +206 -0
  69. package/lib/src/src/language/LanguageClient.d.ts +17 -0
  70. package/lib/src/src/language/LanguageContext.d.ts +37 -0
  71. package/lib/src/src/language/LanguageHandle.d.ts +9 -0
  72. package/lib/src/src/language/LanguageMeta.d.ts +35 -0
  73. package/lib/src/src/language/LanguageRef.d.ts +6 -0
  74. package/lib/src/src/language/LanguageResolver.d.ts +19 -0
  75. package/lib/src/src/links/Links.d.ts +39 -0
  76. package/lib/src/src/links/Links.test.d.ts +1 -0
  77. package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
  78. package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
  79. package/lib/src/src/model/Subject.d.ts +25 -0
  80. package/lib/src/src/model/decorators.d.ts +545 -0
  81. package/lib/src/src/model/util.d.ts +12 -0
  82. package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
  83. package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
  84. package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
  85. package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  86. package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
  87. package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
  88. package/lib/src/src/perspectives/Perspective.d.ts +38 -0
  89. package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
  90. package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
  91. package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
  92. package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
  93. package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
  94. package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
  95. package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
  96. package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
  97. package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
  98. package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
  99. package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
  100. package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
  101. package/lib/src/src/typeDefs.d.ts +1 -0
  102. package/lib/src/src/unwrapApolloResult.d.ts +2 -0
  103. package/lib/src/src/utils.d.ts +25 -0
  104. package/lib/src/utils.d.ts +0 -8
  105. package/lib/src/utils.js +7 -21
  106. package/package.json +15 -14
  107. package/src/Ad4mClient.test.ts +1315 -1564
  108. package/src/Ad4mClient.ts +54 -55
  109. package/src/Literal.test.ts +26 -45
  110. package/src/Literal.ts +66 -82
  111. package/src/SmartLiteral.ts +58 -74
  112. package/src/agent/AgentClient.ts +99 -144
  113. package/src/ai/AIClient.ts +359 -409
  114. package/src/expression/ExpressionClient.ts +96 -142
  115. package/src/index.ts +1 -1
  116. package/src/language/LanguageClient.ts +113 -137
  117. package/src/model/Ad4mModel.test.ts +616 -1114
  118. package/src/model/Ad4mModel.ts +4386 -451
  119. package/src/model/Subject.ts +159 -0
  120. package/src/model/decorators.ts +1168 -667
  121. package/src/model/util.ts +54 -53
  122. package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
  123. package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
  124. package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
  125. package/src/perspectives/PerspectiveClient.ts +540 -779
  126. package/src/perspectives/PerspectiveProxy.ts +2067 -2860
  127. package/src/runtime/RuntimeClient.ts +476 -775
  128. package/src/shacl/SHACLFlow.test.ts +129 -196
  129. package/src/shacl/SHACLShape.test.ts +190 -284
  130. package/src/shacl/SHACLShape.ts +200 -224
  131. package/src/utils.ts +17 -31
  132. package/tsconfig.json +10 -9
  133. package/src/model/IMPROVEMENTS.md +0 -482
  134. package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
  135. package/src/model/README.md +0 -317
  136. package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
  137. package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
  138. package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
  139. package/src/model/mutation.ts +0 -461
  140. package/src/model/parentUtils.ts +0 -91
  141. package/src/model/prolog/generatePrologFacts.ts +0 -176
  142. package/src/model/prolog/index.ts +0 -1
  143. package/src/model/query/ModelQueryBuilder.ts +0 -173
  144. package/src/model/query/fetchInstance.ts +0 -181
  145. package/src/model/query/hydration.ts +0 -273
  146. package/src/model/query/operations.ts +0 -510
  147. package/src/model/query/snapshot.ts +0 -126
  148. package/src/model/query/surrealCompiler.ts +0 -376
  149. package/src/model/schema/fromJSONSchema.ts +0 -411
  150. package/src/model/schema/metadata.ts +0 -148
  151. package/src/model/subscription.ts +0 -307
  152. package/src/model/transaction.ts +0 -60
  153. package/src/model/types.ts +0 -207
@@ -1,7 +1,7 @@
1
1
  import { PerspectiveProxy } from "../perspectives/PerspectiveProxy";
2
2
  /**
3
3
  * Represents a subject in the perspective.
4
- * A subject is an entity that has properties and collections.
4
+ * A subject is an entity that has properties and relations.
5
5
  */
6
6
  export declare class Subject {
7
7
  #private;
@@ -17,9 +17,9 @@ export declare class Subject {
17
17
  */
18
18
  get baseExpression(): string;
19
19
  /**
20
- * Initializes the subject by validating it and defining its properties and collections dynamically.
20
+ * Initializes the subject by validating it and defining its properties and relations dynamically.
21
21
  *
22
- * NOTE: This method should be called before using the subject. All the properties and collections of the subject defined are not type-checked.
22
+ * NOTE: This method should be called before using the subject. All the properties and relations of the subject defined are not type-checked.
23
23
  */
24
24
  init(): Promise<void>;
25
25
  }
@@ -10,10 +10,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _Subject_baseExpression, _Subject_subjectClassName, _Subject_perspective;
13
- import { collectionToAdderName, collectionToRemoverName, collectionToSetterName, propertyNameToSetterName } from "./util";
13
+ import { relationToAdderName, relationToRemoverName, relationToSetterName, propertyNameToSetterName } from "./util";
14
14
  /**
15
15
  * Represents a subject in the perspective.
16
- * A subject is an entity that has properties and collections.
16
+ * A subject is an entity that has properties and relations.
17
17
  */
18
18
  export class Subject {
19
19
  /**
@@ -37,9 +37,9 @@ export class Subject {
37
37
  return __classPrivateFieldGet(this, _Subject_baseExpression, "f");
38
38
  }
39
39
  /**
40
- * Initializes the subject by validating it and defining its properties and collections dynamically.
40
+ * Initializes the subject by validating it and defining its properties and relations dynamically.
41
41
  *
42
- * NOTE: This method should be called before using the subject. All the properties and collections of the subject defined are not type-checked.
42
+ * NOTE: This method should be called before using the subject. All the properties and relations of the subject defined are not type-checked.
43
43
  */
44
44
  async init() {
45
45
  // Check if the subject is a valid instance of the subject class
@@ -47,7 +47,7 @@ export class Subject {
47
47
  if (!isInstance) {
48
48
  throw `Not a valid subject instance of ${__classPrivateFieldGet(this, _Subject_subjectClassName, "f")} for ${__classPrivateFieldGet(this, _Subject_baseExpression, "f")}`;
49
49
  }
50
- // Define properties and collections dynamically
50
+ // Define properties and relations dynamically
51
51
  let results = await __classPrivateFieldGet(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _Subject_subjectClassName, "f")}", C), property(C, Property)`);
52
52
  let properties = results.map(result => result.Property);
53
53
  for (let p of properties) {
@@ -85,35 +85,35 @@ export class Subject {
85
85
  };
86
86
  }
87
87
  }
88
- // Define collections
88
+ // Define relations
89
89
  let results2 = await __classPrivateFieldGet(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _Subject_subjectClassName, "f")}", C), collection(C, Collection)`);
90
90
  if (!results2)
91
91
  results2 = [];
92
- let collections = results2.map(result => result.Collection);
93
- for (let c of collections) {
92
+ let relations = results2.map(result => result.Collection);
93
+ for (let c of relations) {
94
94
  Object.defineProperty(this, c, {
95
95
  configurable: true,
96
96
  get: async () => {
97
97
  // Use SurrealDB for data queries
98
98
  try {
99
- return await __classPrivateFieldGet(this, _Subject_perspective, "f").getCollectionValuesViaSurreal(__classPrivateFieldGet(this, _Subject_baseExpression, "f"), __classPrivateFieldGet(this, _Subject_subjectClassName, "f"), c);
99
+ return await __classPrivateFieldGet(this, _Subject_perspective, "f").getRelationValuesViaSurreal(__classPrivateFieldGet(this, _Subject_baseExpression, "f"), __classPrivateFieldGet(this, _Subject_subjectClassName, "f"), c);
100
100
  }
101
101
  catch (err) {
102
- console.warn(`Failed to get collection ${c} via SurrealDB:`, err);
102
+ console.warn(`Failed to get relation ${c} via SurrealDB:`, err);
103
103
  return [];
104
104
  }
105
105
  }
106
106
  });
107
107
  }
108
- // Define collection adders
108
+ // Define relation adders
109
109
  let adders = await __classPrivateFieldGet(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _Subject_subjectClassName, "f")}", C), collection_adder(C, Collection, Adder)`);
110
110
  if (!adders)
111
111
  adders = [];
112
112
  for (let adder of adders) {
113
113
  if (adder) {
114
- const collection = adder.Collection;
114
+ const relation = adder.Collection;
115
115
  const actions = eval(adder.Adder);
116
- this[collectionToAdderName(collection)] = async (value) => {
116
+ this[relationToAdderName(relation)] = async (value) => {
117
117
  if (Array.isArray(value)) {
118
118
  await Promise.all(value.map(v => __classPrivateFieldGet(this, _Subject_perspective, "f").executeAction(actions, __classPrivateFieldGet(this, _Subject_baseExpression, "f"), [{ name: "value", value: v }])));
119
119
  }
@@ -123,15 +123,15 @@ export class Subject {
123
123
  };
124
124
  }
125
125
  }
126
- // Define collection removers
126
+ // Define relation removers
127
127
  let removers = await __classPrivateFieldGet(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _Subject_subjectClassName, "f")}", C), collection_remover(C, Collection, Remover)`);
128
128
  if (!removers)
129
129
  removers = [];
130
130
  for (let remover of removers) {
131
131
  if (remover) {
132
- const collection = remover.Collection;
132
+ const relation = remover.Collection;
133
133
  const actions = eval(remover.Remover);
134
- this[collectionToRemoverName(collection)] = async (value) => {
134
+ this[relationToRemoverName(relation)] = async (value) => {
135
135
  if (Array.isArray(value)) {
136
136
  await Promise.all(value.map(v => __classPrivateFieldGet(this, _Subject_perspective, "f").executeAction(actions, __classPrivateFieldGet(this, _Subject_baseExpression, "f"), [{ name: "value", value: v }])));
137
137
  }
@@ -141,15 +141,15 @@ export class Subject {
141
141
  };
142
142
  }
143
143
  }
144
- // Define collection setters
145
- let collectionSetters = await __classPrivateFieldGet(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _Subject_subjectClassName, "f")}", C), collection_setter(C, Collection, Setter)`);
146
- if (!collectionSetters)
147
- collectionSetters = [];
148
- for (let collectionSetter of collectionSetters) {
149
- if (collectionSetter) {
150
- const collection = collectionSetter.Collection;
151
- const actions = eval(collectionSetter.Setter);
152
- this[collectionToSetterName(collection)] = async (value) => {
144
+ // Define relation setters
145
+ let relationSetters = await __classPrivateFieldGet(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet(this, _Subject_subjectClassName, "f")}", C), collection_setter(C, Collection, Setter)`);
146
+ if (!relationSetters)
147
+ relationSetters = [];
148
+ for (let relationSetter of relationSetters) {
149
+ if (relationSetter) {
150
+ const relation = relationSetter.Collection;
151
+ const actions = eval(relationSetter.Setter);
152
+ this[relationToSetterName(relation)] = async (value) => {
153
153
  if (Array.isArray(value)) {
154
154
  await __classPrivateFieldGet(this, _Subject_perspective, "f").executeAction(actions, __classPrivateFieldGet(this, _Subject_baseExpression, "f"), value.map(v => ({ name: "value", value: v })));
155
155
  }