@coasys/ad4m 0.8.2-prerelease-2 → 0.9.0-rc2

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.
@@ -14,7 +14,17 @@ import { Literal } from "../Literal";
14
14
  import { Link } from "../links/Links";
15
15
  import { makeRandomPrologAtom } from "./SDNADecorators";
16
16
  import { singularToPlural } from "./util";
17
+ /**
18
+ * Class representing a subject entity.
19
+ * Can extend this class to create a new subject entity to add methods interact with SDNA and much better experience then using the bare bone methods.
20
+ */
17
21
  export class SubjectEntity {
22
+ /**
23
+ * Constructs a new subject.
24
+ * @param perspective - The perspective that the subject belongs to.
25
+ * @param baseExpression - The base expression of the subject.
26
+ * @param soruce - The source of the subject, the expression this instance is linked too.
27
+ */
18
28
  constructor(perspective, baseExpression, source) {
19
29
  _SubjectEntity_baseExpression.set(this, void 0);
20
30
  _SubjectEntity_subjectClass.set(this, void 0);
@@ -24,6 +34,9 @@ export class SubjectEntity {
24
34
  __classPrivateFieldSet(this, _SubjectEntity_perspective, perspective, "f");
25
35
  __classPrivateFieldSet(this, _SubjectEntity_source, source || "ad4m://self", "f");
26
36
  }
37
+ /**
38
+ * Gets the base expression of the subject.
39
+ */
27
40
  get baseExpression() {
28
41
  return __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f");
29
42
  }
@@ -150,6 +163,17 @@ export class SubjectEntity {
150
163
  }
151
164
  }
152
165
  }
166
+ /**
167
+ * Save the subject entity.
168
+ * This method will create a new subject with the base expression and add a new link from the source to the base expression with the predicate "ad4m://has_child".
169
+ *
170
+ * If a property has an action, it will perform the action (Only for collections).
171
+ * If a property is an array and is not empty, it will set the collection.
172
+ * If a property is not undefined, not null, and not an empty string, it will set the property.
173
+ *
174
+ *
175
+ * @throws Will throw an error if the subject entity cannot be converted to a subject class, or if the subject cannot be created, or if the link cannot be added, or if the subject entity cannot be updated.
176
+ */
153
177
  async save() {
154
178
  __classPrivateFieldSet(this, _SubjectEntity_subjectClass, await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").stringOrTemplateObjectToSubjectClass(this), "f");
155
179
  await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").createSubject(this, __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f"));
@@ -160,11 +184,22 @@ export class SubjectEntity {
160
184
  }));
161
185
  await this.update();
162
186
  }
187
+ /**
188
+ * Update the subject entity.
189
+ *
190
+ * It will iterate over the properties of the subject entity.
191
+ *
192
+ * If a property has an action, it will perform the action (Only for collections).
193
+ * If a property is an array and is not empty, it will set the collection.
194
+ * If a property is not undefined, not null, and not an empty string, it will set the property.
195
+ *
196
+ * @throws Will throw an error if the subject entity cannot be converted to a subject class, or if a property cannot be set, or if a collection cannot be set, or if the data of the subject entity cannot be gotten.
197
+ */
163
198
  async update() {
164
199
  __classPrivateFieldSet(this, _SubjectEntity_subjectClass, await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").stringOrTemplateObjectToSubjectClass(this), "f");
165
200
  const entries = Object.entries(this);
166
201
  for (const [key, value] of entries) {
167
- if (value) {
202
+ if (value !== undefined && value !== null) {
168
203
  if (value?.action) {
169
204
  switch (value.action) {
170
205
  case 'setter':
@@ -183,21 +218,44 @@ export class SubjectEntity {
183
218
  else if (Array.isArray(value) && value.length > 0) {
184
219
  await this.setCollectionSetter(key, value);
185
220
  }
186
- else {
221
+ else if (value !== undefined && value !== null && value !== "") {
187
222
  await this.setProperty(key, value);
188
223
  }
189
224
  }
190
225
  }
191
226
  await this.getData();
192
227
  }
228
+ /**
229
+ * Get the subject entity with all the properties & collection populated.
230
+ *
231
+ * @returns The subject entity.
232
+ *
233
+ * @throws Will throw an error if the subject entity cannot be converted to a subject class, or if the data of the subject entity cannot be gotten.
234
+ */
193
235
  async get() {
194
236
  __classPrivateFieldSet(this, _SubjectEntity_subjectClass, await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").stringOrTemplateObjectToSubjectClass(this), "f");
195
237
  return await this.getData();
196
238
  }
239
+ /**
240
+ * Delete the subject entity.
241
+ * This method will remove the subject from the perspective.
242
+ *
243
+ * @throws Will throw an error if the subject entity cannot be removed.
244
+ */
197
245
  async delete() {
198
246
  await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").removeSubject(this, __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f"));
199
247
  }
200
- // TODO: implement simple quering like limit, skip etc.
248
+ /**
249
+ * Get all the subject entities of the subject class.
250
+ *
251
+ * NOTE: this is a static method and should be called on the class itself.
252
+ *
253
+ * @param perspective - The perspective that the subject belongs to.
254
+ *
255
+ * @returns The subject entities.
256
+ *
257
+ * @throws Will throw an error if the subject entity cannot be converted to a subject class, or if the subject proxies cannot be gotten.
258
+ */
201
259
  static async all(perspective) {
202
260
  let subjectClass = await perspective.stringOrTemplateObjectToSubjectClass(this);
203
261
  const proxies = await perspective.getAllSubjectProxies(subjectClass);
@@ -212,6 +270,18 @@ export class SubjectEntity {
212
270
  }
213
271
  return [];
214
272
  }
273
+ /**
274
+ * Query the subject entities of the subject class.
275
+ *
276
+ * NOTE: this is a static method and should be called on the class itself.
277
+ *
278
+ * @param perspective - The perspective that the subject belongs to.
279
+ * @param query - The query of the subject entities.
280
+ *
281
+ * @returns The subject entities.
282
+ *
283
+ * @throws Will throw an error if the subject entity cannot be converted to a subject class, or if the query cannot be inferred, or if the data of the subject entities cannot be gotten.
284
+ */
215
285
  static async query(perspective, query) {
216
286
  const source = query?.source || "ad4m://self";
217
287
  let subjectClass = await perspective.stringOrTemplateObjectToSubjectClass(this);
@@ -77,7 +77,7 @@ type ExceptionInfo {
77
77
  addon: String
78
78
  message: String!
79
79
  title: String!
80
- type: Float!
80
+ type: Int!
81
81
  }
82
82
 
83
83
  type ExpressionProof {
package/package.json CHANGED
@@ -55,10 +55,12 @@
55
55
  "rollup": "^2.56.3",
56
56
  "ts-jest": "^26.5.6",
57
57
  "typescript": "^4.6.2",
58
- "ws": "8.13.0"
58
+ "ws": "8.13.0",
59
+ "@types/node": "*",
60
+ "@types/yargs": "*"
59
61
  },
60
62
  "patchedDependencies": {},
61
- "version": "0.8.2-prerelease-2",
63
+ "version": "0.9.0-rc2",
62
64
  "pnpm": {
63
65
  "patchedDependencies": {
64
66
  "graphql@15.7.2": "patches/graphql@15.7.2.patch"
package/src/Exception.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export enum ExceptionType {
2
- LanguageIsNotLoaded,
3
- ExpressionIsNotVerified,
4
- AgentIsUntrusted,
5
- CapabilityRequested,
2
+ LanguageIsNotLoaded = "LANGUAGE_IS_NOT_LOADED",
3
+ ExpressionIsNotVerified = "EXPRESSION_IS_NOT_VERIFIED",
4
+ AgentIsUntrusted = "AGENT_IS_UNTRUSTED",
5
+ CapabilityRequested = "CAPABILITY_REQUESTED",
6
6
  }
@@ -2,13 +2,13 @@ import { Field, ObjectType } from "type-graphql";
2
2
  import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
3
3
 
4
4
  export enum PerspectiveState {
5
- Private = "Private",
6
- NeighbourhoodJoinInitiated = "NeighbourhoodJoinInitiated",
7
- LinkLanguageFailedToInstall = "LinkLanguageFailedToInstall",
8
- LinkLanguageInstalledButNotSynced = "LinkLanguageInstalledButNotSynced",
9
- Synced = "Synced",
5
+ Private = "PRIVATE",
6
+ NeighboudhoodCreationInitiated = "NEIGHBOURHOOD_CREATION_INITIATED",
7
+ NeighbourhoodJoinInitiated = "NEIGHBOURHOOD_JOIN_INITIATED",
8
+ LinkLanguageFailedToInstall = "LINK_LANGUAGE_FAILED_TO_INSTALL",
9
+ LinkLanguageInstalledButNotSynced = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",
10
+ Synced = "SYNCED",
10
11
  }
11
-
12
12
  // This type is used in the GraphQL interface to reference a mutable
13
13
  // prespective that is implemented locally by the Ad4m runtime.
14
14
  // The UUID is used in mutations to identify the perspective that gets mutated.
@@ -447,6 +447,11 @@ export class PerspectiveProxy {
447
447
  return instances
448
448
  }
449
449
 
450
+ /** Returns all subject proxies of the given subject class.
451
+ * @param subjectClass Either a string with the name of the subject class, or an object
452
+ * with the properties of the subject class. In the latter case, all subject classes
453
+ * that match the given properties will be used.
454
+ */
450
455
  async getAllSubjectProxies<T>(subjectClass: T): Promise<T[]> {
451
456
  let classes = []
452
457
  if(typeof subjectClass === "string") {
@@ -1,4 +1,4 @@
1
- import { Arg, Mutation, Resolver, Query, Subscription, ObjectType, Field } from "type-graphql";
1
+ import { Arg, Mutation, Resolver, Query, Subscription, ObjectType, Field, Int } from "type-graphql";
2
2
  import { Perspective, PerspectiveExpression, PerspectiveInput } from "../perspectives/Perspective";
3
3
  import { ExpressionProof } from "../expression/Expression";
4
4
  import { LinkExpression } from "../links/Links";
@@ -48,7 +48,7 @@ export class ExceptionInfo {
48
48
  title: string;
49
49
  @Field()
50
50
  message: string;
51
- @Field()
51
+ @Field(type => Int)
52
52
  type: ExceptionType;
53
53
  @Field({ nullable: true })
54
54
  addon?: string;
@@ -22,16 +22,42 @@ export function hasLink(predicate: string): string {
22
22
  return `triple(this, "${predicate}", _)`
23
23
  }
24
24
 
25
- interface InstanceQueryParams {
26
- where?: object;
27
- condition?: string;
25
+ export interface InstanceQueryParams {
26
+ /**
27
+ * An object representing the WHERE clause of the query.
28
+ */
29
+ where?: object;
30
+
31
+ /**
32
+ * A string representing the condition clause of the query.
33
+ */
34
+ condition?: string;
28
35
  }
29
36
 
30
- export function instanceQuery(options?: InstanceQueryParams) {
37
+ /**
38
+ * Decorator for querying instances of a subject class.
39
+ *
40
+ * @category Decorators
41
+ *
42
+ * @description
43
+ * NOTE: Only works on methods that return a promise and will throw an error if not used on a method that returns a promise.
44
+ * This will allow you to query for instances of a subject class with custom clauses within the instance clauses.
45
+ *
46
+ * @example
47
+ * // Usage with where clause
48
+ * InstanceQuery({ where: { name: "John" }}) // this will return all the properties of the subject class with the name "John"
49
+ *
50
+ * @example
51
+ * // Usage with condition clause
52
+ * InstanceQuery({ condition: "triple(Instance, 'age', Age), Age > 18" }) // this will return all the properties of the subject class with the age greater than 18
53
+ *
54
+ * @param {Object} [options] - Query options.
55
+ */
56
+ export function InstanceQuery(options?: InstanceQueryParams) {
31
57
  return function <T>(target: T, key: keyof T, descriptor: PropertyDescriptor) {
32
58
  const originalMethod = descriptor.value;
33
59
  if(typeof originalMethod !== "function") {
34
- throw new Error("instanceQuery decorator can only be applied to methods");
60
+ throw new Error("InstanceQuery decorator can only be applied to methods");
35
61
  }
36
62
 
37
63
  descriptor.value = async function(perspective: PerspectiveProxy): Promise<T[]> {
@@ -70,18 +96,79 @@ export function instanceQuery(options?: InstanceQueryParams) {
70
96
  }
71
97
 
72
98
 
73
- interface PropertyOptions {
99
+ export interface PropertyOptions {
100
+ /**
101
+ * The predicate of the property. All properties must have this option.
102
+ */
74
103
  through?: string;
75
- initial?: string,
76
- required?: boolean,
77
- writable?: boolean,
104
+
105
+ /**
106
+ * The initial value of the property. Required if the property is marked as required.
107
+ */
108
+ initial?: string;
109
+
110
+ /**
111
+ * Indicates whether the property is required. If true, an initial value must be provided.
112
+ */
113
+ required?: boolean;
114
+
115
+ /**
116
+ * Indicates whether the property is writable. If true, a setter will be available in the prolog engine.
117
+ */
118
+ writable?: boolean;
119
+
120
+ /**
121
+ * The language used to store the property. Can be the default `Literal` Language or a custom language address.
122
+ */
78
123
  resolveLanguage?: string;
124
+
125
+ /**
126
+ * Custom getter to get the value of the property in the prolog engine. If not provided, the default getter will be used.
127
+ */
79
128
  getter?: string;
129
+
130
+ /**
131
+ * Custom setter to set the value of the property in the prolog engine. Only available if the property is writable.
132
+ */
80
133
  setter?: string;
81
- local?: boolean
134
+
135
+ /**
136
+ * Indicates whether the property is stored locally in the perspective and not in the network. Useful for properties that are not meant to be shared with the network.
137
+ */
138
+ local?: boolean;
82
139
  }
83
- export function subjectProperty(opts: PropertyOptions) {
140
+
141
+ /**
142
+ * Decorator for defining properties of a subject class.
143
+ *
144
+ * @category Decorators
145
+ *
146
+ * @description
147
+ * This will allow you to define properties with different conditions and how they would be defined in proflog engine.
148
+ *
149
+ * - All properties must have a `through` option which is the predicate of the property.
150
+ * -e If the property is required, it must have an `initial` option which is the initial value of the property.
151
+ * - If the property is writable, it will have a setter in prolog engine. A custom setter can be defined with the `setter` option.
152
+ * - If resolveLanguage is defined, you can use the default `Literal` Language or use your custom language address that can be used to store the property.
153
+ * - If a custom getter is defined, it will be used to get the value of the property in prolog engine. If not, the default getter will be used.
154
+ * - If local is defined, the property will be stored locally in the perspective and not in the network. This is useful for properties that are not meant to be shared with the network
155
+ *
156
+ * @example
157
+ * // Usage
158
+ * SubjectProperty({ through: "ad4m://name", initial: "John", required: true }) // this will define a property with the name "ad4m://name" and the initial value "John"
159
+ *
160
+ * @param {PropertyOptions} [opts] - Property options.
161
+ */
162
+ export function SubjectProperty(opts: PropertyOptions) {
84
163
  return function <T>(target: T, key: keyof T) {
164
+ if (opts.required && !opts.initial) {
165
+ throw new Error("SubjectProperty requires an 'initial' option if 'required' is true");
166
+ }
167
+
168
+ if (!opts.through && !opts.getter) {
169
+ throw new Error("SubjectProperty requires either 'through' or 'getter' option")
170
+ }
171
+
85
172
  target["__properties"] = target["__properties"] || {};
86
173
  target["__properties"][key] = target["__properties"][key] || {};
87
174
  target["__properties"][key] = { ...target["__properties"][key], ...opts }
@@ -95,12 +182,51 @@ export function subjectProperty(opts: PropertyOptions) {
95
182
  };
96
183
  }
97
184
 
98
- interface FlagOptions {
185
+ export interface FlagOptions {
186
+ /**
187
+ * The predicate of the property. All properties must have this option.
188
+ */
99
189
  through: string;
190
+
191
+ /**
192
+ * The value of the property.
193
+ */
100
194
  value: string;
101
195
  }
102
- export function subjectFlag(opts: FlagOptions) {
196
+
197
+ /**
198
+ * Decorator for defining flags of a subject class
199
+ *
200
+ * @category Decorators
201
+ *
202
+ * @description
203
+ * The idea behind flag decorator is to define a property that is required and has an initial value.
204
+ * This will allow you to define a strict instance query. This behaviour can also be achieved with the `SubjectProperty` decorator but the `SubjectFlag` decorator is a shorthand for that.
205
+ *
206
+ * NOTE: Use of Flag is discouraged and should be used only when necessary.
207
+ *
208
+ * - All properties must have a `through` & `initial` option which is the predicate of the property.
209
+ *
210
+ * @example
211
+ * // Usage
212
+ * SubjectFlag({ through: "ad4m://name", value: "John" }) // this will define a flag with the name "ad4m://name" and the initial value "John"
213
+ *
214
+ * @param {FlagOptions} [opts] Flag options.
215
+ */
216
+ export function SubjectFlag(opts: FlagOptions) {
103
217
  return function <T>(target: T, key: keyof T) {
218
+ if (!opts.through && !opts.value) {
219
+ throw new Error("SubjectFlag requires a 'through' and 'value' option")
220
+ }
221
+
222
+ if (!opts.through) {
223
+ throw new Error("SubjectFlag requires a 'through' option")
224
+ }
225
+
226
+ if (!opts.value) {
227
+ throw new Error("SubjectFlag requires a 'value' option")
228
+ }
229
+
104
230
  target["__properties"] = target["__properties"] || {};
105
231
  target["__properties"][key] = target["__properties"][key] || {};
106
232
  target["__properties"][key] = {
@@ -122,13 +248,45 @@ interface WhereOptions {
122
248
  isInstance?: any
123
249
  condition?: string
124
250
  }
125
- interface CollectionOptions {
126
- through: string,
127
- where?: WhereOptions,
128
- local?: boolean
251
+
252
+ export interface CollectionOptions {
253
+ /**
254
+ * The predicate of the property. All properties must have this option.
255
+ */
256
+ through: string;
257
+
258
+ /**
259
+ * An object representing the WHERE clause of the query.
260
+ */
261
+ where?: WhereOptions;
262
+
263
+ /**
264
+ * Indicates whether the property is stored locally in the perspective and not in the network. Useful for properties that are not meant to be shared with the network.
265
+ */
266
+ local?: boolean;
129
267
  }
130
268
 
131
- export function subjectCollection(opts: CollectionOptions) {
269
+ /**
270
+ * Decorator for defining collections of a subject class.
271
+ *
272
+ * @category Decorators
273
+ *
274
+ * @description
275
+ * This will allow you to define collections with different conditions and how they would be defined in proflog engine.
276
+ *
277
+ * NOTE: The property needs to be an array for it to picked up during the initialization phase.
278
+ *
279
+ * - All collections must have a `through` option which is the predicate of the collection.
280
+ * - If the collection has a `where` option, it can be used to define a custom condition for the collection.
281
+ * - If the collection has a `local` option, the collection will be stored locally in the perspective and not in the network. This is useful for collections that are not meant to be shared with the network.
282
+ *
283
+ * @example
284
+ * // Usage
285
+ * SubjectCollection({ through: "ad4m://friends" }) // this will define a collection with the name "ad4m://friends"
286
+ *
287
+ * @param opts Collection options.
288
+ */
289
+ export function SubjectCollection(opts: CollectionOptions) {
132
290
  return function <T>(target: T, key: keyof T) {
133
291
  target["__collections"] = target["__collections"] || {};
134
292
  target["__collections"][key] = opts;
@@ -152,10 +310,29 @@ export function makeRandomPrologAtom(length: number): string {
152
310
  return result;
153
311
  }
154
312
 
155
- interface SDNAClassOptions {
313
+ export interface SDNAClassOptions {
314
+ /**
315
+ * The name of the entity.
316
+ */
156
317
  name: string;
157
318
  }
158
319
 
320
+ /**
321
+ * Decorator for defining an SDNA class.
322
+ *
323
+ * @category Decorators
324
+ *
325
+ * @description
326
+ * This will create a new SDNA class with the given name and add custom methods to generate the SDNA for the class, for this to work the class need to have the properties defined using the decorators like `SubjectProperty`.
327
+ *
328
+ * Note: This decorator is required for the class to be picked up during the initialization phase.
329
+ *
330
+ * @example
331
+ * // Usage
332
+ * SDNAClass({ name: "Person" }) // this will create a new SDNA class with the name "Person"
333
+ *
334
+ * @param opts SDNA class options.
335
+ */
159
336
  export function SDNAClass(opts: SDNAClassOptions) {
160
337
  return function (target: any) {
161
338
  target.prototype.className = opts.name;
@@ -1,31 +1,50 @@
1
1
  import { PerspectiveProxy } from "../perspectives/PerspectiveProxy";
2
2
  import { collectionSetterToName, collectionToAdderName, collectionToRemoverName, collectionToSetterName, propertyNameToSetterName } from "./util";
3
3
 
4
+ /**
5
+ * Represents a subject in the perspective.
6
+ * A subject is an entity that has properties and collections.
7
+ */
4
8
  export class Subject {
5
9
  #baseExpression: string;
6
10
  #subjectClass: string;
7
11
  #perspective: PerspectiveProxy
8
12
 
13
+ /**
14
+ * Constructs a new subject.
15
+ * @param perspective - The perspective that the subject belongs to.
16
+ * @param baseExpression - The base expression of the subject.
17
+ * @param subjectClass - The class of the subject.
18
+ */
9
19
  constructor(perspective: PerspectiveProxy, baseExpression: string, subjectClass: string) {
10
20
  this.#baseExpression = baseExpression
11
21
  this.#subjectClass = subjectClass
12
22
  this.#perspective = perspective
13
23
  }
14
24
 
25
+ /**
26
+ * Gets the base expression of the subject.
27
+ */
15
28
  get baseExpression() {
16
29
  return this.#baseExpression
17
30
  }
18
31
 
32
+ /**
33
+ * Initializes the subject by validating it and defining its properties and collections dynamically.
34
+ *
35
+ * NOTE: This method should be called before using the subject. All the properties and collections of the subject defined are not type-checked.
36
+ */
19
37
  async init() {
38
+ // Check if the subject is a valid instance of the subject class
20
39
  let isInstance = await this.#perspective.isSubjectInstance(this.#baseExpression, this.#subjectClass)
21
40
  if(!isInstance) {
22
41
  throw `Not a valid subject instance of ${this.#subjectClass} for ${this.#baseExpression}`
23
42
  }
24
43
 
44
+ // Define properties and collections dynamically
25
45
  let results = await this.#perspective.infer(`subject_class("${this.#subjectClass}", C), property(C, Property)`)
26
46
  let properties = results.map(result => result.Property)
27
47
 
28
-
29
48
  for(let p of properties) {
30
49
  const resolveExpressionURI = await this.#perspective.infer(`subject_class("${this.#subjectClass}", C), property_resolve(C, "${p}")`)
31
50
  Object.defineProperty(this, p, {
@@ -61,10 +80,9 @@ export class Subject {
61
80
  })
62
81
  }
63
82
 
64
-
83
+ // Define setters
65
84
  const setters = await this.#perspective.infer(`subject_class("${this.#subjectClass}", C), property_setter(C, Property, Setter)`)
66
-
67
- //console.log("Subject setters: " + setters.map(setter => setter.Property))
85
+
68
86
  for(let setter of (setters ? setters : [])) {
69
87
  if(setter) {
70
88
  const property = setter.Property
@@ -83,6 +101,7 @@ export class Subject {
83
101
  }
84
102
  }
85
103
 
104
+ // Define collections
86
105
  let results2 = await this.#perspective.infer(`subject_class("${this.#subjectClass}", C), collection(C, Collection)`)
87
106
  if(!results2) results2 = []
88
107
  let collections = results2.map(result => result.Collection)
@@ -102,6 +121,7 @@ export class Subject {
102
121
  })
103
122
  }
104
123
 
124
+ // Define collection adders
105
125
  let adders = await this.#perspective.infer(`subject_class("${this.#subjectClass}", C), collection_adder(C, Collection, Adder)`)
106
126
  if(!adders) adders = []
107
127
 
@@ -119,6 +139,7 @@ export class Subject {
119
139
  }
120
140
  }
121
141
 
142
+ // Define collection removers
122
143
  let removers = await this.#perspective.infer(`subject_class("${this.#subjectClass}", C), collection_remover(C, Collection, Remover)`)
123
144
  if(!removers) removers = []
124
145
 
@@ -136,6 +157,7 @@ export class Subject {
136
157
  }
137
158
  }
138
159
 
160
+ // Define collection setters
139
161
  let collectionSetters = await this.#perspective.infer(`subject_class("${this.#subjectClass}", C), collection_setter(C, Collection, Setter)`)
140
162
  if(!collectionSetters) collectionSetters = []
141
163