@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.
package/lib/index.js CHANGED
@@ -4415,7 +4415,17 @@ var __classPrivateFieldGet$a = (undefined && undefined.__classPrivateFieldGet) |
4415
4415
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4416
4416
  };
4417
4417
  var _Subject_baseExpression, _Subject_subjectClass, _Subject_perspective;
4418
+ /**
4419
+ * Represents a subject in the perspective.
4420
+ * A subject is an entity that has properties and collections.
4421
+ */
4418
4422
  class Subject {
4423
+ /**
4424
+ * Constructs a new subject.
4425
+ * @param perspective - The perspective that the subject belongs to.
4426
+ * @param baseExpression - The base expression of the subject.
4427
+ * @param subjectClass - The class of the subject.
4428
+ */
4419
4429
  constructor(perspective, baseExpression, subjectClass) {
4420
4430
  _Subject_baseExpression.set(this, void 0);
4421
4431
  _Subject_subjectClass.set(this, void 0);
@@ -4424,14 +4434,24 @@ class Subject {
4424
4434
  __classPrivateFieldSet$a(this, _Subject_subjectClass, subjectClass, "f");
4425
4435
  __classPrivateFieldSet$a(this, _Subject_perspective, perspective, "f");
4426
4436
  }
4437
+ /**
4438
+ * Gets the base expression of the subject.
4439
+ */
4427
4440
  get baseExpression() {
4428
4441
  return __classPrivateFieldGet$a(this, _Subject_baseExpression, "f");
4429
4442
  }
4443
+ /**
4444
+ * Initializes the subject by validating it and defining its properties and collections dynamically.
4445
+ *
4446
+ * NOTE: This method should be called before using the subject. All the properties and collections of the subject defined are not type-checked.
4447
+ */
4430
4448
  async init() {
4449
+ // Check if the subject is a valid instance of the subject class
4431
4450
  let isInstance = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").isSubjectInstance(__classPrivateFieldGet$a(this, _Subject_baseExpression, "f"), __classPrivateFieldGet$a(this, _Subject_subjectClass, "f"));
4432
4451
  if (!isInstance) {
4433
4452
  throw `Not a valid subject instance of ${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")} for ${__classPrivateFieldGet$a(this, _Subject_baseExpression, "f")}`;
4434
4453
  }
4454
+ // Define properties and collections dynamically
4435
4455
  let results = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")}", C), property(C, Property)`);
4436
4456
  let properties = results.map(result => result.Property);
4437
4457
  for (let p of properties) {
@@ -4474,8 +4494,8 @@ class Subject {
4474
4494
  }
4475
4495
  });
4476
4496
  }
4497
+ // Define setters
4477
4498
  const setters = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")}", C), property_setter(C, Property, Setter)`);
4478
- //console.log("Subject setters: " + setters.map(setter => setter.Property))
4479
4499
  for (let setter of (setters ? setters : [])) {
4480
4500
  if (setter) {
4481
4501
  const property = setter.Property;
@@ -4493,6 +4513,7 @@ class Subject {
4493
4513
  };
4494
4514
  }
4495
4515
  }
4516
+ // Define collections
4496
4517
  let results2 = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")}", C), collection(C, Collection)`);
4497
4518
  if (!results2)
4498
4519
  results2 = [];
@@ -4512,6 +4533,7 @@ class Subject {
4512
4533
  }
4513
4534
  });
4514
4535
  }
4536
+ // Define collection adders
4515
4537
  let adders = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")}", C), collection_adder(C, Collection, Adder)`);
4516
4538
  if (!adders)
4517
4539
  adders = [];
@@ -4529,6 +4551,7 @@ class Subject {
4529
4551
  };
4530
4552
  }
4531
4553
  }
4554
+ // Define collection removers
4532
4555
  let removers = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")}", C), collection_remover(C, Collection, Remover)`);
4533
4556
  if (!removers)
4534
4557
  removers = [];
@@ -4546,6 +4569,7 @@ class Subject {
4546
4569
  };
4547
4570
  }
4548
4571
  }
4572
+ // Define collection setters
4549
4573
  let collectionSetters = await __classPrivateFieldGet$a(this, _Subject_perspective, "f").infer(`subject_class("${__classPrivateFieldGet$a(this, _Subject_subjectClass, "f")}", C), collection_setter(C, Collection, Setter)`);
4550
4574
  if (!collectionSetters)
4551
4575
  collectionSetters = [];
@@ -4952,6 +4976,11 @@ class PerspectiveProxy {
4952
4976
  }
4953
4977
  return instances;
4954
4978
  }
4979
+ /** Returns all subject proxies of the given subject class.
4980
+ * @param subjectClass Either a string with the name of the subject class, or an object
4981
+ * with the properties of the subject class. In the latter case, all subject classes
4982
+ * that match the given properties will be used.
4983
+ */
4955
4984
  async getAllSubjectProxies(subjectClass) {
4956
4985
  let classes = [];
4957
4986
  if (typeof subjectClass === "string") {
@@ -6723,10 +6752,10 @@ _Ad4mClient_apolloClient = new WeakMap(), _Ad4mClient_agentClient = new WeakMap(
6723
6752
 
6724
6753
  var ExceptionType;
6725
6754
  (function (ExceptionType) {
6726
- ExceptionType[ExceptionType["LanguageIsNotLoaded"] = 0] = "LanguageIsNotLoaded";
6727
- ExceptionType[ExceptionType["ExpressionIsNotVerified"] = 1] = "ExpressionIsNotVerified";
6728
- ExceptionType[ExceptionType["AgentIsUntrusted"] = 2] = "AgentIsUntrusted";
6729
- ExceptionType[ExceptionType["CapabilityRequested"] = 3] = "CapabilityRequested";
6755
+ ExceptionType["LanguageIsNotLoaded"] = "LANGUAGE_IS_NOT_LOADED";
6756
+ ExceptionType["ExpressionIsNotVerified"] = "EXPRESSION_IS_NOT_VERIFIED";
6757
+ ExceptionType["AgentIsUntrusted"] = "AGENT_IS_UNTRUSTED";
6758
+ ExceptionType["CapabilityRequested"] = "CAPABILITY_REQUESTED";
6730
6759
  })(ExceptionType || (ExceptionType = {}));
6731
6760
 
6732
6761
  var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
@@ -7039,11 +7068,12 @@ var __metadata$1 = (undefined && undefined.__metadata) || function (k, v) {
7039
7068
  };
7040
7069
  var PerspectiveState;
7041
7070
  (function (PerspectiveState) {
7042
- PerspectiveState["Private"] = "Private";
7043
- PerspectiveState["NeighbourhoodJoinInitiated"] = "NeighbourhoodJoinInitiated";
7044
- PerspectiveState["LinkLanguageFailedToInstall"] = "LinkLanguageFailedToInstall";
7045
- PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LinkLanguageInstalledButNotSynced";
7046
- PerspectiveState["Synced"] = "Synced";
7071
+ PerspectiveState["Private"] = "PRIVATE";
7072
+ PerspectiveState["NeighboudhoodCreationInitiated"] = "NEIGHBOURHOOD_CREATION_INITIATED";
7073
+ PerspectiveState["NeighbourhoodJoinInitiated"] = "NEIGHBOURHOOD_JOIN_INITIATED";
7074
+ PerspectiveState["LinkLanguageFailedToInstall"] = "LINK_LANGUAGE_FAILED_TO_INSTALL";
7075
+ PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
7076
+ PerspectiveState["Synced"] = "SYNCED";
7047
7077
  })(PerspectiveState || (PerspectiveState = {}));
7048
7078
  // This type is used in the GraphQL interface to reference a mutable
7049
7079
  // prespective that is implemented locally by the Ad4m runtime.
@@ -7198,11 +7228,30 @@ function addLink(source, predicate, target) {
7198
7228
  function hasLink(predicate) {
7199
7229
  return `triple(this, "${predicate}", _)`;
7200
7230
  }
7201
- function instanceQuery(options) {
7231
+ /**
7232
+ * Decorator for querying instances of a subject class.
7233
+ *
7234
+ * @category Decorators
7235
+ *
7236
+ * @description
7237
+ * NOTE: Only works on methods that return a promise and will throw an error if not used on a method that returns a promise.
7238
+ * This will allow you to query for instances of a subject class with custom clauses within the instance clauses.
7239
+ *
7240
+ * @example
7241
+ * // Usage with where clause
7242
+ * InstanceQuery({ where: { name: "John" }}) // this will return all the properties of the subject class with the name "John"
7243
+ *
7244
+ * @example
7245
+ * // Usage with condition clause
7246
+ * InstanceQuery({ condition: "triple(Instance, 'age', Age), Age > 18" }) // this will return all the properties of the subject class with the age greater than 18
7247
+ *
7248
+ * @param {Object} [options] - Query options.
7249
+ */
7250
+ function InstanceQuery(options) {
7202
7251
  return function (target, key, descriptor) {
7203
7252
  const originalMethod = descriptor.value;
7204
7253
  if (typeof originalMethod !== "function") {
7205
- throw new Error("instanceQuery decorator can only be applied to methods");
7254
+ throw new Error("InstanceQuery decorator can only be applied to methods");
7206
7255
  }
7207
7256
  descriptor.value = async function (perspective) {
7208
7257
  let instances = [];
@@ -7235,8 +7284,35 @@ function instanceQuery(options) {
7235
7284
  };
7236
7285
  };
7237
7286
  }
7238
- function subjectProperty(opts) {
7287
+ /**
7288
+ * Decorator for defining properties of a subject class.
7289
+ *
7290
+ * @category Decorators
7291
+ *
7292
+ * @description
7293
+ * This will allow you to define properties with different conditions and how they would be defined in proflog engine.
7294
+ *
7295
+ * - All properties must have a `through` option which is the predicate of the property.
7296
+ * -e If the property is required, it must have an `initial` option which is the initial value of the property.
7297
+ * - If the property is writable, it will have a setter in prolog engine. A custom setter can be defined with the `setter` option.
7298
+ * - 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.
7299
+ * - 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.
7300
+ * - 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
7301
+ *
7302
+ * @example
7303
+ * // Usage
7304
+ * SubjectProperty({ through: "ad4m://name", initial: "John", required: true }) // this will define a property with the name "ad4m://name" and the initial value "John"
7305
+ *
7306
+ * @param {PropertyOptions} [opts] - Property options.
7307
+ */
7308
+ function SubjectProperty(opts) {
7239
7309
  return function (target, key) {
7310
+ if (opts.required && !opts.initial) {
7311
+ throw new Error("SubjectProperty requires an 'initial' option if 'required' is true");
7312
+ }
7313
+ if (!opts.through && !opts.getter) {
7314
+ throw new Error("SubjectProperty requires either 'through' or 'getter' option");
7315
+ }
7240
7316
  target["__properties"] = target["__properties"] || {};
7241
7317
  target["__properties"][key] = target["__properties"][key] || {};
7242
7318
  target["__properties"][key] = { ...target["__properties"][key], ...opts };
@@ -7247,8 +7323,36 @@ function subjectProperty(opts) {
7247
7323
  Object.defineProperty(target, key, { configurable: true, writable: true });
7248
7324
  };
7249
7325
  }
7250
- function subjectFlag(opts) {
7326
+ /**
7327
+ * Decorator for defining flags of a subject class
7328
+ *
7329
+ * @category Decorators
7330
+ *
7331
+ * @description
7332
+ * The idea behind flag decorator is to define a property that is required and has an initial value.
7333
+ * 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.
7334
+ *
7335
+ * NOTE: Use of Flag is discouraged and should be used only when necessary.
7336
+ *
7337
+ * - All properties must have a `through` & `initial` option which is the predicate of the property.
7338
+ *
7339
+ * @example
7340
+ * // Usage
7341
+ * SubjectFlag({ through: "ad4m://name", value: "John" }) // this will define a flag with the name "ad4m://name" and the initial value "John"
7342
+ *
7343
+ * @param {FlagOptions} [opts] Flag options.
7344
+ */
7345
+ function SubjectFlag(opts) {
7251
7346
  return function (target, key) {
7347
+ if (!opts.through && !opts.value) {
7348
+ throw new Error("SubjectFlag requires a 'through' and 'value' option");
7349
+ }
7350
+ if (!opts.through) {
7351
+ throw new Error("SubjectFlag requires a 'through' option");
7352
+ }
7353
+ if (!opts.value) {
7354
+ throw new Error("SubjectFlag requires a 'value' option");
7355
+ }
7252
7356
  target["__properties"] = target["__properties"] || {};
7253
7357
  target["__properties"][key] = target["__properties"][key] || {};
7254
7358
  target["__properties"][key] = {
@@ -7263,7 +7367,27 @@ function subjectFlag(opts) {
7263
7367
  Object.defineProperty(target, key, { configurable: true, writable: true });
7264
7368
  };
7265
7369
  }
7266
- function subjectCollection(opts) {
7370
+ /**
7371
+ * Decorator for defining collections of a subject class.
7372
+ *
7373
+ * @category Decorators
7374
+ *
7375
+ * @description
7376
+ * This will allow you to define collections with different conditions and how they would be defined in proflog engine.
7377
+ *
7378
+ * NOTE: The property needs to be an array for it to picked up during the initialization phase.
7379
+ *
7380
+ * - All collections must have a `through` option which is the predicate of the collection.
7381
+ * - If the collection has a `where` option, it can be used to define a custom condition for the collection.
7382
+ * - 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.
7383
+ *
7384
+ * @example
7385
+ * // Usage
7386
+ * SubjectCollection({ through: "ad4m://friends" }) // this will define a collection with the name "ad4m://friends"
7387
+ *
7388
+ * @param opts Collection options.
7389
+ */
7390
+ function SubjectCollection(opts) {
7267
7391
  return function (target, key) {
7268
7392
  target["__collections"] = target["__collections"] || {};
7269
7393
  target["__collections"][key] = opts;
@@ -7283,6 +7407,22 @@ function makeRandomPrologAtom(length) {
7283
7407
  }
7284
7408
  return result;
7285
7409
  }
7410
+ /**
7411
+ * Decorator for defining an SDNA class.
7412
+ *
7413
+ * @category Decorators
7414
+ *
7415
+ * @description
7416
+ * 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`.
7417
+ *
7418
+ * Note: This decorator is required for the class to be picked up during the initialization phase.
7419
+ *
7420
+ * @example
7421
+ * // Usage
7422
+ * SDNAClass({ name: "Person" }) // this will create a new SDNA class with the name "Person"
7423
+ *
7424
+ * @param opts SDNA class options.
7425
+ */
7286
7426
  function SDNAClass(opts) {
7287
7427
  return function (target) {
7288
7428
  target.prototype.className = opts.name;
@@ -7512,7 +7652,7 @@ type ExceptionInfo {
7512
7652
  addon: String
7513
7653
  message: String!
7514
7654
  title: String!
7515
- type: Float!
7655
+ type: Int!
7516
7656
  }
7517
7657
 
7518
7658
  type ExpressionProof {
@@ -7847,7 +7987,17 @@ var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) ||
7847
7987
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
7848
7988
  };
7849
7989
  var _SubjectEntity_baseExpression, _SubjectEntity_subjectClass, _SubjectEntity_source, _SubjectEntity_perspective;
7990
+ /**
7991
+ * Class representing a subject entity.
7992
+ * 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.
7993
+ */
7850
7994
  class SubjectEntity {
7995
+ /**
7996
+ * Constructs a new subject.
7997
+ * @param perspective - The perspective that the subject belongs to.
7998
+ * @param baseExpression - The base expression of the subject.
7999
+ * @param soruce - The source of the subject, the expression this instance is linked too.
8000
+ */
7851
8001
  constructor(perspective, baseExpression, source) {
7852
8002
  _SubjectEntity_baseExpression.set(this, void 0);
7853
8003
  _SubjectEntity_subjectClass.set(this, void 0);
@@ -7857,6 +8007,9 @@ class SubjectEntity {
7857
8007
  __classPrivateFieldSet(this, _SubjectEntity_perspective, perspective, "f");
7858
8008
  __classPrivateFieldSet(this, _SubjectEntity_source, source || "ad4m://self", "f");
7859
8009
  }
8010
+ /**
8011
+ * Gets the base expression of the subject.
8012
+ */
7860
8013
  get baseExpression() {
7861
8014
  return __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f");
7862
8015
  }
@@ -7983,6 +8136,17 @@ class SubjectEntity {
7983
8136
  }
7984
8137
  }
7985
8138
  }
8139
+ /**
8140
+ * Save the subject entity.
8141
+ * 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".
8142
+ *
8143
+ * If a property has an action, it will perform the action (Only for collections).
8144
+ * If a property is an array and is not empty, it will set the collection.
8145
+ * If a property is not undefined, not null, and not an empty string, it will set the property.
8146
+ *
8147
+ *
8148
+ * @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.
8149
+ */
7986
8150
  async save() {
7987
8151
  __classPrivateFieldSet(this, _SubjectEntity_subjectClass, await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").stringOrTemplateObjectToSubjectClass(this), "f");
7988
8152
  await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").createSubject(this, __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f"));
@@ -7993,11 +8157,22 @@ class SubjectEntity {
7993
8157
  }));
7994
8158
  await this.update();
7995
8159
  }
8160
+ /**
8161
+ * Update the subject entity.
8162
+ *
8163
+ * It will iterate over the properties of the subject entity.
8164
+ *
8165
+ * If a property has an action, it will perform the action (Only for collections).
8166
+ * If a property is an array and is not empty, it will set the collection.
8167
+ * If a property is not undefined, not null, and not an empty string, it will set the property.
8168
+ *
8169
+ * @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.
8170
+ */
7996
8171
  async update() {
7997
8172
  __classPrivateFieldSet(this, _SubjectEntity_subjectClass, await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").stringOrTemplateObjectToSubjectClass(this), "f");
7998
8173
  const entries = Object.entries(this);
7999
8174
  for (const [key, value] of entries) {
8000
- if (value) {
8175
+ if (value !== undefined && value !== null) {
8001
8176
  if (value?.action) {
8002
8177
  switch (value.action) {
8003
8178
  case 'setter':
@@ -8016,21 +8191,44 @@ class SubjectEntity {
8016
8191
  else if (Array.isArray(value) && value.length > 0) {
8017
8192
  await this.setCollectionSetter(key, value);
8018
8193
  }
8019
- else {
8194
+ else if (value !== undefined && value !== null && value !== "") {
8020
8195
  await this.setProperty(key, value);
8021
8196
  }
8022
8197
  }
8023
8198
  }
8024
8199
  await this.getData();
8025
8200
  }
8201
+ /**
8202
+ * Get the subject entity with all the properties & collection populated.
8203
+ *
8204
+ * @returns The subject entity.
8205
+ *
8206
+ * @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.
8207
+ */
8026
8208
  async get() {
8027
8209
  __classPrivateFieldSet(this, _SubjectEntity_subjectClass, await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").stringOrTemplateObjectToSubjectClass(this), "f");
8028
8210
  return await this.getData();
8029
8211
  }
8212
+ /**
8213
+ * Delete the subject entity.
8214
+ * This method will remove the subject from the perspective.
8215
+ *
8216
+ * @throws Will throw an error if the subject entity cannot be removed.
8217
+ */
8030
8218
  async delete() {
8031
8219
  await __classPrivateFieldGet(this, _SubjectEntity_perspective, "f").removeSubject(this, __classPrivateFieldGet(this, _SubjectEntity_baseExpression, "f"));
8032
8220
  }
8033
- // TODO: implement simple quering like limit, skip etc.
8221
+ /**
8222
+ * Get all the subject entities of the subject class.
8223
+ *
8224
+ * NOTE: this is a static method and should be called on the class itself.
8225
+ *
8226
+ * @param perspective - The perspective that the subject belongs to.
8227
+ *
8228
+ * @returns The subject entities.
8229
+ *
8230
+ * @throws Will throw an error if the subject entity cannot be converted to a subject class, or if the subject proxies cannot be gotten.
8231
+ */
8034
8232
  static async all(perspective) {
8035
8233
  let subjectClass = await perspective.stringOrTemplateObjectToSubjectClass(this);
8036
8234
  const proxies = await perspective.getAllSubjectProxies(subjectClass);
@@ -8045,6 +8243,18 @@ class SubjectEntity {
8045
8243
  }
8046
8244
  return [];
8047
8245
  }
8246
+ /**
8247
+ * Query the subject entities of the subject class.
8248
+ *
8249
+ * NOTE: this is a static method and should be called on the class itself.
8250
+ *
8251
+ * @param perspective - The perspective that the subject belongs to.
8252
+ * @param query - The query of the subject entities.
8253
+ *
8254
+ * @returns The subject entities.
8255
+ *
8256
+ * @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.
8257
+ */
8048
8258
  static async query(perspective, query) {
8049
8259
  const source = query?.source || "ad4m://self";
8050
8260
  let subjectClass = await perspective.stringOrTemplateObjectToSubjectClass(this);
@@ -8082,4 +8292,4 @@ class SubjectEntity {
8082
8292
  }
8083
8293
  _SubjectEntity_baseExpression = new WeakMap(), _SubjectEntity_subjectClass = new WeakMap(), _SubjectEntity_source = new WeakMap(), _SubjectEntity_perspective = new WeakMap();
8084
8294
 
8085
- export { Ad4mClient, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, Capability, CapabilityInput, Dna, EntanglementProof, EntanglementProofInput, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Icon, InteractionCall, InteractionMeta, InteractionParameter, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, OnlineAgent, Perspective, PerspectiveAction, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Resource, ResourceInput, SDNAClass, SMART_LITERAL_CONTENT_PREDICATE, SmartLiteral, Subject, SubjectEntity, addLink, capSentence, exprRef2String, formatList, hasLink, instanceQuery, isExpression, isLink, linkEqual, makeRandomPrologAtom, parseExprUrl, subjectCollection, subjectFlag, subjectProperty, typeDefsString };
8295
+ export { Ad4mClient, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, Capability, CapabilityInput, Dna, EntanglementProof, EntanglementProofInput, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Icon, InstanceQuery, InteractionCall, InteractionMeta, InteractionParameter, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, OnlineAgent, Perspective, PerspectiveAction, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Resource, ResourceInput, SDNAClass, SMART_LITERAL_CONTENT_PREDICATE, SmartLiteral, Subject, SubjectCollection, SubjectEntity, SubjectFlag, SubjectProperty, addLink, capSentence, exprRef2String, formatList, hasLink, isExpression, isLink, linkEqual, makeRandomPrologAtom, parseExprUrl, typeDefsString };
@@ -1,6 +1,6 @@
1
1
  export declare enum ExceptionType {
2
- LanguageIsNotLoaded = 0,
3
- ExpressionIsNotVerified = 1,
4
- AgentIsUntrusted = 2,
5
- CapabilityRequested = 3
2
+ LanguageIsNotLoaded = "LANGUAGE_IS_NOT_LOADED",
3
+ ExpressionIsNotVerified = "EXPRESSION_IS_NOT_VERIFIED",
4
+ AgentIsUntrusted = "AGENT_IS_UNTRUSTED",
5
+ CapabilityRequested = "CAPABILITY_REQUESTED"
6
6
  }
@@ -1,7 +1,7 @@
1
1
  export var ExceptionType;
2
2
  (function (ExceptionType) {
3
- ExceptionType[ExceptionType["LanguageIsNotLoaded"] = 0] = "LanguageIsNotLoaded";
4
- ExceptionType[ExceptionType["ExpressionIsNotVerified"] = 1] = "ExpressionIsNotVerified";
5
- ExceptionType[ExceptionType["AgentIsUntrusted"] = 2] = "AgentIsUntrusted";
6
- ExceptionType[ExceptionType["CapabilityRequested"] = 3] = "CapabilityRequested";
3
+ ExceptionType["LanguageIsNotLoaded"] = "LANGUAGE_IS_NOT_LOADED";
4
+ ExceptionType["ExpressionIsNotVerified"] = "EXPRESSION_IS_NOT_VERIFIED";
5
+ ExceptionType["AgentIsUntrusted"] = "AGENT_IS_UNTRUSTED";
6
+ ExceptionType["CapabilityRequested"] = "CAPABILITY_REQUESTED";
7
7
  })(ExceptionType || (ExceptionType = {}));
@@ -1,10 +1,11 @@
1
1
  import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
2
2
  export declare enum PerspectiveState {
3
- Private = "Private",
4
- NeighbourhoodJoinInitiated = "NeighbourhoodJoinInitiated",
5
- LinkLanguageFailedToInstall = "LinkLanguageFailedToInstall",
6
- LinkLanguageInstalledButNotSynced = "LinkLanguageInstalledButNotSynced",
7
- Synced = "Synced"
3
+ Private = "PRIVATE",
4
+ NeighboudhoodCreationInitiated = "NEIGHBOURHOOD_CREATION_INITIATED",
5
+ NeighbourhoodJoinInitiated = "NEIGHBOURHOOD_JOIN_INITIATED",
6
+ LinkLanguageFailedToInstall = "LINK_LANGUAGE_FAILED_TO_INSTALL",
7
+ LinkLanguageInstalledButNotSynced = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",
8
+ Synced = "SYNCED"
8
9
  }
9
10
  export declare class PerspectiveHandle {
10
11
  uuid: string;
@@ -11,11 +11,12 @@ import { Field, ObjectType } from "type-graphql";
11
11
  import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
12
12
  export var PerspectiveState;
13
13
  (function (PerspectiveState) {
14
- PerspectiveState["Private"] = "Private";
15
- PerspectiveState["NeighbourhoodJoinInitiated"] = "NeighbourhoodJoinInitiated";
16
- PerspectiveState["LinkLanguageFailedToInstall"] = "LinkLanguageFailedToInstall";
17
- PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LinkLanguageInstalledButNotSynced";
18
- PerspectiveState["Synced"] = "Synced";
14
+ PerspectiveState["Private"] = "PRIVATE";
15
+ PerspectiveState["NeighboudhoodCreationInitiated"] = "NEIGHBOURHOOD_CREATION_INITIATED";
16
+ PerspectiveState["NeighbourhoodJoinInitiated"] = "NEIGHBOURHOOD_JOIN_INITIATED";
17
+ PerspectiveState["LinkLanguageFailedToInstall"] = "LINK_LANGUAGE_FAILED_TO_INSTALL";
18
+ PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
19
+ PerspectiveState["Synced"] = "SYNCED";
19
20
  })(PerspectiveState || (PerspectiveState = {}));
20
21
  // This type is used in the GraphQL interface to reference a mutable
21
22
  // prespective that is implemented locally by the Ad4m runtime.
@@ -153,6 +153,11 @@ export declare class PerspectiveProxy {
153
153
  * that match the given properties will be used.
154
154
  */
155
155
  getAllSubjectInstances<T>(subjectClass: T): Promise<T[]>;
156
+ /** Returns all subject proxies of the given subject class.
157
+ * @param subjectClass Either a string with the name of the subject class, or an object
158
+ * with the properties of the subject class. In the latter case, all subject classes
159
+ * that match the given properties will be used.
160
+ */
156
161
  getAllSubjectProxies<T>(subjectClass: T): Promise<T[]>;
157
162
  /** Returns all subject classes that match the given template object.
158
163
  * This function looks at the properties of the template object and
@@ -388,6 +388,11 @@ export class PerspectiveProxy {
388
388
  }
389
389
  return instances;
390
390
  }
391
+ /** Returns all subject proxies of the given subject class.
392
+ * @param subjectClass Either a string with the name of the subject class, or an object
393
+ * with the properties of the subject class. In the latter case, all subject classes
394
+ * that match the given properties will be used.
395
+ */
391
396
  async getAllSubjectProxies(subjectClass) {
392
397
  let classes = [];
393
398
  if (typeof subjectClass === "string") {
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- import { Arg, Mutation, Resolver, Query, Subscription, ObjectType, Field } from "type-graphql";
13
+ import { Arg, Mutation, Resolver, Query, Subscription, ObjectType, Field, Int } from "type-graphql";
14
14
  import { Perspective, PerspectiveExpression, PerspectiveInput } from "../perspectives/Perspective";
15
15
  import { ExpressionProof } from "../expression/Expression";
16
16
  import { LinkExpression } from "../links/Links";
@@ -76,8 +76,8 @@ __decorate([
76
76
  __metadata("design:type", String)
77
77
  ], ExceptionInfo.prototype, "message", void 0);
78
78
  __decorate([
79
- Field(),
80
- __metadata("design:type", Number)
79
+ Field(type => Int),
80
+ __metadata("design:type", String)
81
81
  ], ExceptionInfo.prototype, "type", void 0);
82
82
  __decorate([
83
83
  Field({ nullable: true }),
@@ -81,7 +81,7 @@ type ExceptionInfo {
81
81
  addon: String
82
82
  message: String!
83
83
  title: String!
84
- type: Float!
84
+ type: Int!
85
85
  }
86
86
 
87
87
  type ExpressionProof {