@coasys/ad4m 0.10.0-rc6 → 0.10.0-rc6.fix1

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.cjs CHANGED
@@ -4961,65 +4961,70 @@ class PerspectiveProxy {
4961
4961
  return instances;
4962
4962
  }
4963
4963
  buildQueryFromTemplate(obj) {
4964
- // Collect all string properties of the object in a list
4965
- let properties = [];
4966
- // Collect all collections of the object in a list
4967
- let collections = [];
4968
- // Collect all string properties of the object in a list
4969
- if (Object.getPrototypeOf(obj).__properties) {
4970
- Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p));
4971
- }
4972
- else {
4973
- properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])));
4974
- }
4975
- // Collect all collections of the object in a list
4976
- if (Object.getPrototypeOf(obj).__collections) {
4977
- Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c));
4978
- }
4979
- else {
4980
- collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
4981
- }
4982
- // Collect all set functions of the object in a list
4983
- let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"));
4984
- // Add all set functions of the object's prototype to that list
4985
- setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection")));
4986
- // Collect all add functions of the object in a list
4987
- let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"));
4988
- // Add all add functions of the object's prototype to that list
4989
- addFunctions = addFunctions.concat(Object.keys(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("add")));
4990
- // Collect all remove functions of the object in a list
4991
- let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"));
4992
- // Add all remove functions of the object's prototype to that list
4993
- removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("remove")));
4994
- // Collect all add functions of the object in a list
4995
- let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"));
4996
- // Add all add functions of the object's prototype to that list
4997
- setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("setCollection")));
4998
- // Construct query to find all subject classes that have the given properties and collections
4999
- let query = `subject_class(Class, C)`;
5000
- for (let property of properties) {
5001
- query += `, property(C, "${property}")`;
5002
- }
5003
- for (let collection of collections) {
5004
- query += `, collection(C, "${collection}")`;
5005
- }
5006
- for (let setFunction of setFunctions) {
5007
- // e.g. "setState" -> "state"
5008
- let property = setFunction.substring(3);
5009
- property = property.charAt(0).toLowerCase() + property.slice(1);
5010
- query += `, property_setter(C, "${property}", _)`;
5011
- }
5012
- for (let addFunction of addFunctions) {
5013
- query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`;
5014
- }
5015
- for (let removeFunction of removeFunctions) {
5016
- query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`;
5017
- }
5018
- for (let setCollectionFunction of setCollectionFunctions) {
5019
- query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`;
5020
- }
5021
- query += ".";
5022
- return query;
4964
+ let result;
4965
+ // We need to avoid strict mode for the following intropsective code
4966
+ (function () {
4967
+ // Collect all string properties of the object in a list
4968
+ let properties = [];
4969
+ // Collect all collections of the object in a list
4970
+ let collections = [];
4971
+ // Collect all string properties of the object in a list
4972
+ if (Object.getPrototypeOf(obj).__properties) {
4973
+ Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p));
4974
+ }
4975
+ else {
4976
+ properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])));
4977
+ }
4978
+ // Collect all collections of the object in a list
4979
+ if (Object.getPrototypeOf(obj).__collections) {
4980
+ Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c));
4981
+ }
4982
+ else {
4983
+ collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
4984
+ }
4985
+ // Collect all set functions of the object in a list
4986
+ let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"));
4987
+ // Add all set functions of the object's prototype to that list
4988
+ setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection")));
4989
+ // Collect all add functions of the object in a list
4990
+ let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"));
4991
+ // Add all add functions of the object's prototype to that list
4992
+ addFunctions = addFunctions.concat(Object.keys(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("add")));
4993
+ // Collect all remove functions of the object in a list
4994
+ let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"));
4995
+ // Add all remove functions of the object's prototype to that list
4996
+ removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("remove")));
4997
+ // Collect all add functions of the object in a list
4998
+ let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"));
4999
+ // Add all add functions of the object's prototype to that list
5000
+ setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("setCollection")));
5001
+ // Construct query to find all subject classes that have the given properties and collections
5002
+ let query = `subject_class(Class, C)`;
5003
+ for (let property of properties) {
5004
+ query += `, property(C, "${property}")`;
5005
+ }
5006
+ for (let collection of collections) {
5007
+ query += `, collection(C, "${collection}")`;
5008
+ }
5009
+ for (let setFunction of setFunctions) {
5010
+ // e.g. "setState" -> "state"
5011
+ let property = setFunction.substring(3);
5012
+ property = property.charAt(0).toLowerCase() + property.slice(1);
5013
+ query += `, property_setter(C, "${property}", _)`;
5014
+ }
5015
+ for (let addFunction of addFunctions) {
5016
+ query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`;
5017
+ }
5018
+ for (let removeFunction of removeFunctions) {
5019
+ query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`;
5020
+ }
5021
+ for (let setCollectionFunction of setCollectionFunctions) {
5022
+ query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`;
5023
+ }
5024
+ query += ".";
5025
+ result = query;
5026
+ }());
5027
+ return result;
5023
5028
  }
5024
5029
  /** Returns all subject classes that match the given template object.
5025
5030
  * This function looks at the properties of the template object and
package/lib/index.js CHANGED
@@ -4957,65 +4957,70 @@ class PerspectiveProxy {
4957
4957
  return instances;
4958
4958
  }
4959
4959
  buildQueryFromTemplate(obj) {
4960
- // Collect all string properties of the object in a list
4961
- let properties = [];
4962
- // Collect all collections of the object in a list
4963
- let collections = [];
4964
- // Collect all string properties of the object in a list
4965
- if (Object.getPrototypeOf(obj).__properties) {
4966
- Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p));
4967
- }
4968
- else {
4969
- properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])));
4970
- }
4971
- // Collect all collections of the object in a list
4972
- if (Object.getPrototypeOf(obj).__collections) {
4973
- Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c));
4974
- }
4975
- else {
4976
- collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
4977
- }
4978
- // Collect all set functions of the object in a list
4979
- let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"));
4980
- // Add all set functions of the object's prototype to that list
4981
- setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection")));
4982
- // Collect all add functions of the object in a list
4983
- let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"));
4984
- // Add all add functions of the object's prototype to that list
4985
- addFunctions = addFunctions.concat(Object.keys(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("add")));
4986
- // Collect all remove functions of the object in a list
4987
- let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"));
4988
- // Add all remove functions of the object's prototype to that list
4989
- removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("remove")));
4990
- // Collect all add functions of the object in a list
4991
- let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"));
4992
- // Add all add functions of the object's prototype to that list
4993
- setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("setCollection")));
4994
- // Construct query to find all subject classes that have the given properties and collections
4995
- let query = `subject_class(Class, C)`;
4996
- for (let property of properties) {
4997
- query += `, property(C, "${property}")`;
4998
- }
4999
- for (let collection of collections) {
5000
- query += `, collection(C, "${collection}")`;
5001
- }
5002
- for (let setFunction of setFunctions) {
5003
- // e.g. "setState" -> "state"
5004
- let property = setFunction.substring(3);
5005
- property = property.charAt(0).toLowerCase() + property.slice(1);
5006
- query += `, property_setter(C, "${property}", _)`;
5007
- }
5008
- for (let addFunction of addFunctions) {
5009
- query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`;
5010
- }
5011
- for (let removeFunction of removeFunctions) {
5012
- query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`;
5013
- }
5014
- for (let setCollectionFunction of setCollectionFunctions) {
5015
- query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`;
5016
- }
5017
- query += ".";
5018
- return query;
4960
+ let result;
4961
+ // We need to avoid strict mode for the following intropsective code
4962
+ (function () {
4963
+ // Collect all string properties of the object in a list
4964
+ let properties = [];
4965
+ // Collect all collections of the object in a list
4966
+ let collections = [];
4967
+ // Collect all string properties of the object in a list
4968
+ if (Object.getPrototypeOf(obj).__properties) {
4969
+ Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p));
4970
+ }
4971
+ else {
4972
+ properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])));
4973
+ }
4974
+ // Collect all collections of the object in a list
4975
+ if (Object.getPrototypeOf(obj).__collections) {
4976
+ Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c));
4977
+ }
4978
+ else {
4979
+ collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
4980
+ }
4981
+ // Collect all set functions of the object in a list
4982
+ let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"));
4983
+ // Add all set functions of the object's prototype to that list
4984
+ setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection")));
4985
+ // Collect all add functions of the object in a list
4986
+ let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"));
4987
+ // Add all add functions of the object's prototype to that list
4988
+ addFunctions = addFunctions.concat(Object.keys(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("add")));
4989
+ // Collect all remove functions of the object in a list
4990
+ let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"));
4991
+ // Add all remove functions of the object's prototype to that list
4992
+ removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("remove")));
4993
+ // Collect all add functions of the object in a list
4994
+ let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"));
4995
+ // Add all add functions of the object's prototype to that list
4996
+ setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("setCollection")));
4997
+ // Construct query to find all subject classes that have the given properties and collections
4998
+ let query = `subject_class(Class, C)`;
4999
+ for (let property of properties) {
5000
+ query += `, property(C, "${property}")`;
5001
+ }
5002
+ for (let collection of collections) {
5003
+ query += `, collection(C, "${collection}")`;
5004
+ }
5005
+ for (let setFunction of setFunctions) {
5006
+ // e.g. "setState" -> "state"
5007
+ let property = setFunction.substring(3);
5008
+ property = property.charAt(0).toLowerCase() + property.slice(1);
5009
+ query += `, property_setter(C, "${property}", _)`;
5010
+ }
5011
+ for (let addFunction of addFunctions) {
5012
+ query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`;
5013
+ }
5014
+ for (let removeFunction of removeFunctions) {
5015
+ query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`;
5016
+ }
5017
+ for (let setCollectionFunction of setCollectionFunctions) {
5018
+ query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`;
5019
+ }
5020
+ query += ".";
5021
+ result = query;
5022
+ }());
5023
+ return result;
5019
5024
  }
5020
5025
  /** Returns all subject classes that match the given template object.
5021
5026
  * This function looks at the properties of the template object and
@@ -368,65 +368,70 @@ export class PerspectiveProxy {
368
368
  return instances;
369
369
  }
370
370
  buildQueryFromTemplate(obj) {
371
- // Collect all string properties of the object in a list
372
- let properties = [];
373
- // Collect all collections of the object in a list
374
- let collections = [];
375
- // Collect all string properties of the object in a list
376
- if (Object.getPrototypeOf(obj).__properties) {
377
- Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p));
378
- }
379
- else {
380
- properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])));
381
- }
382
- // Collect all collections of the object in a list
383
- if (Object.getPrototypeOf(obj).__collections) {
384
- Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c));
385
- }
386
- else {
387
- collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
388
- }
389
- // Collect all set functions of the object in a list
390
- let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"));
391
- // Add all set functions of the object's prototype to that list
392
- setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection")));
393
- // Collect all add functions of the object in a list
394
- let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"));
395
- // Add all add functions of the object's prototype to that list
396
- addFunctions = addFunctions.concat(Object.keys(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("add")));
397
- // Collect all remove functions of the object in a list
398
- let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"));
399
- // Add all remove functions of the object's prototype to that list
400
- removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("remove")));
401
- // Collect all add functions of the object in a list
402
- let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"));
403
- // Add all add functions of the object's prototype to that list
404
- setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("setCollection")));
405
- // Construct query to find all subject classes that have the given properties and collections
406
- let query = `subject_class(Class, C)`;
407
- for (let property of properties) {
408
- query += `, property(C, "${property}")`;
409
- }
410
- for (let collection of collections) {
411
- query += `, collection(C, "${collection}")`;
412
- }
413
- for (let setFunction of setFunctions) {
414
- // e.g. "setState" -> "state"
415
- let property = setFunction.substring(3);
416
- property = property.charAt(0).toLowerCase() + property.slice(1);
417
- query += `, property_setter(C, "${property}", _)`;
418
- }
419
- for (let addFunction of addFunctions) {
420
- query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`;
421
- }
422
- for (let removeFunction of removeFunctions) {
423
- query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`;
424
- }
425
- for (let setCollectionFunction of setCollectionFunctions) {
426
- query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`;
427
- }
428
- query += ".";
429
- return query;
371
+ let result;
372
+ // We need to avoid strict mode for the following intropsective code
373
+ (function () {
374
+ // Collect all string properties of the object in a list
375
+ let properties = [];
376
+ // Collect all collections of the object in a list
377
+ let collections = [];
378
+ // Collect all string properties of the object in a list
379
+ if (Object.getPrototypeOf(obj).__properties) {
380
+ Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p));
381
+ }
382
+ else {
383
+ properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])));
384
+ }
385
+ // Collect all collections of the object in a list
386
+ if (Object.getPrototypeOf(obj).__collections) {
387
+ Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c));
388
+ }
389
+ else {
390
+ collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
391
+ }
392
+ // Collect all set functions of the object in a list
393
+ let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"));
394
+ // Add all set functions of the object's prototype to that list
395
+ setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection")));
396
+ // Collect all add functions of the object in a list
397
+ let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"));
398
+ // Add all add functions of the object's prototype to that list
399
+ addFunctions = addFunctions.concat(Object.keys(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("add")));
400
+ // Collect all remove functions of the object in a list
401
+ let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"));
402
+ // Add all remove functions of the object's prototype to that list
403
+ removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("remove")));
404
+ // Collect all add functions of the object in a list
405
+ let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"));
406
+ // Add all add functions of the object's prototype to that list
407
+ setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("setCollection")));
408
+ // Construct query to find all subject classes that have the given properties and collections
409
+ let query = `subject_class(Class, C)`;
410
+ for (let property of properties) {
411
+ query += `, property(C, "${property}")`;
412
+ }
413
+ for (let collection of collections) {
414
+ query += `, collection(C, "${collection}")`;
415
+ }
416
+ for (let setFunction of setFunctions) {
417
+ // e.g. "setState" -> "state"
418
+ let property = setFunction.substring(3);
419
+ property = property.charAt(0).toLowerCase() + property.slice(1);
420
+ query += `, property_setter(C, "${property}", _)`;
421
+ }
422
+ for (let addFunction of addFunctions) {
423
+ query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`;
424
+ }
425
+ for (let removeFunction of removeFunctions) {
426
+ query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`;
427
+ }
428
+ for (let setCollectionFunction of setCollectionFunctions) {
429
+ query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`;
430
+ }
431
+ query += ".";
432
+ result = query;
433
+ }());
434
+ return result;
430
435
  }
431
436
  /** Returns all subject classes that match the given template object.
432
437
  * This function looks at the properties of the template object and
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "lib/index.js",
6
6
  "types": "lib/src/index.d.ts",
7
7
  "type": "module",
8
- "private": false,
8
+
9
9
  "scripts": {
10
10
  "build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
11
11
  "buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
@@ -60,7 +60,7 @@
60
60
  "@types/yargs": "*"
61
61
  },
62
62
  "patchedDependencies": {},
63
- "version": "0.10.0-rc6",
63
+ "version": "0.10.0-rc6.fix1",
64
64
  "pnpm": {
65
65
  "patchedDependencies": {
66
66
  "graphql@15.7.2": "patches/graphql@15.7.2.patch"
@@ -432,78 +432,81 @@ export class PerspectiveProxy {
432
432
 
433
433
 
434
434
  private buildQueryFromTemplate(obj: object): string {
435
- // Collect all string properties of the object in a list
436
- let properties = []
437
-
438
- // Collect all collections of the object in a list
439
- let collections = []
440
-
441
- // Collect all string properties of the object in a list
442
- if(Object.getPrototypeOf(obj).__properties) {
443
- Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p))
444
- } else {
445
- properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])))
446
- }
447
-
448
- // Collect all collections of the object in a list
449
- if (Object.getPrototypeOf(obj).__collections) {
450
- Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c))
451
- } else {
452
- collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'))
453
- }
454
-
455
- // Collect all set functions of the object in a list
456
- let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"))
457
- // Add all set functions of the object's prototype to that list
458
- setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection")))
435
+ let result
436
+ // We need to avoid strict mode for the following intropsective code
437
+ (function() {
438
+ // Collect all string properties of the object in a list
439
+ let properties = []
440
+
441
+ // Collect all collections of the object in a list
442
+ let collections = []
443
+
444
+ // Collect all string properties of the object in a list
445
+ if(Object.getPrototypeOf(obj).__properties) {
446
+ Object.keys(Object.getPrototypeOf(obj).__properties).forEach(p => properties.push(p))
447
+ } else {
448
+ properties.push(...Object.keys(obj).filter(key => !Array.isArray(obj[key])))
449
+ }
459
450
 
460
- // Collect all add functions of the object in a list
461
- let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"))
462
- // Add all add functions of the object's prototype to that list
463
- addFunctions = addFunctions.concat(Object.keys(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("add")))
451
+ // Collect all collections of the object in a list
452
+ if (Object.getPrototypeOf(obj).__collections) {
453
+ Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => !collections.includes(c) ?? collections.push(c))
454
+ } else {
455
+ collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'))
456
+ }
464
457
 
465
- // Collect all remove functions of the object in a list
466
- let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"))
467
- // Add all remove functions of the object's prototype to that list
468
- removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("remove")))
458
+ // Collect all set functions of the object in a list
459
+ let setFunctions = Object.getOwnPropertyNames(obj).filter(key => (typeof obj[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection"))
460
+ // Add all set functions of the object's prototype to that list
461
+ setFunctions = setFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("set") && !key.startsWith("setCollection")))
469
462
 
470
- // Collect all add functions of the object in a list
471
- let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"))
472
- // Add all add functions of the object's prototype to that list
473
- setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("setCollection")))
463
+ // Collect all add functions of the object in a list
464
+ let addFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("add"))
465
+ // Add all add functions of the object's prototype to that list
466
+ addFunctions = addFunctions.concat(Object.keys(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("add")))
474
467
 
475
- // Construct query to find all subject classes that have the given properties and collections
476
- let query = `subject_class(Class, C)`
468
+ // Collect all remove functions of the object in a list
469
+ let removeFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("remove"))
470
+ // Add all remove functions of the object's prototype to that list
471
+ removeFunctions = removeFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("remove")))
477
472
 
478
- for(let property of properties) {
479
- query += `, property(C, "${property}")`
480
- }
481
- for(let collection of collections) {
482
- query += `, collection(C, "${collection}")`
483
- }
473
+ // Collect all add functions of the object in a list
474
+ let setCollectionFunctions = Object.getOwnPropertyNames(obj).filter(key => (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] === "function") && key.startsWith("setCollection"))
475
+ // Add all add functions of the object's prototype to that list
476
+ setCollectionFunctions = setCollectionFunctions.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj)).filter(key => (Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(obj), key) && typeof Object.getPrototypeOf(obj)[key] === "function") && key.startsWith("setCollection")))
484
477
 
485
- for(let setFunction of setFunctions) {
486
- // e.g. "setState" -> "state"
487
- let property = setFunction.substring(3)
488
- property = property.charAt(0).toLowerCase() + property.slice(1)
489
- query += `, property_setter(C, "${property}", _)`
490
- }
491
- for(let addFunction of addFunctions) {
492
- query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`
493
- }
478
+ // Construct query to find all subject classes that have the given properties and collections
479
+ let query = `subject_class(Class, C)`
494
480
 
495
- for(let removeFunction of removeFunctions) {
496
- query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`
497
- }
481
+ for(let property of properties) {
482
+ query += `, property(C, "${property}")`
483
+ }
484
+ for(let collection of collections) {
485
+ query += `, collection(C, "${collection}")`
486
+ }
498
487
 
499
- for(let setCollectionFunction of setCollectionFunctions) {
500
- query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`
501
- }
488
+ for(let setFunction of setFunctions) {
489
+ // e.g. "setState" -> "state"
490
+ let property = setFunction.substring(3)
491
+ property = property.charAt(0).toLowerCase() + property.slice(1)
492
+ query += `, property_setter(C, "${property}", _)`
493
+ }
494
+ for(let addFunction of addFunctions) {
495
+ query += `, collection_adder(C, "${collectionAdderToName(addFunction)}", _)`
496
+ }
502
497
 
498
+ for(let removeFunction of removeFunctions) {
499
+ query += `, collection_remover(C, "${collectionRemoverToName(removeFunction)}", _)`
500
+ }
503
501
 
504
- query += "."
502
+ for(let setCollectionFunction of setCollectionFunctions) {
503
+ query += `, collection_setter(C, "${collectionSetterToName(setCollectionFunction)}", _)`
504
+ }
505
505
 
506
- return query;
506
+ query += "."
507
+ result = query
508
+ }())
509
+ return result
507
510
  }
508
511
 
509
512
  /** Returns all subject classes that match the given template object.
package/yarn-error.log ADDED
@@ -0,0 +1,90 @@
1
+ Arguments:
2
+ /Users/nicolasluck/.nvm/versions/node/v18.16.1/bin/node /Users/nicolasluck/.nvm/versions/node/v18.16.1/bin/yarn install
3
+
4
+ PATH:
5
+ /Users/nicolasluck/Library/pnpm:/Users/nicolasluck/.nvm/versions/node/v18.16.1/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/Users/nicolasluck/.cargo/bin
6
+
7
+ Yarn version:
8
+ 1.22.19
9
+
10
+ Node version:
11
+ 18.16.1
12
+
13
+ Platform:
14
+ darwin arm64
15
+
16
+ Trace:
17
+ Error: ENOENT: no such file or directory, copyfile '/Users/nicolasluck/Library/Caches/Yarn/v6/npm-has-flag-3.0.0-b5d454dc2199ae225699f3467e5a07f3b955bafd-integrity/node_modules/has-flag/index.js' -> '/Users/nicolasluck/Coasys/code/ad4m/node_modules/@changesets/cli/node_modules/has-flag/index.js'
18
+
19
+ npm manifest:
20
+ {
21
+ "name": "@coasys/ad4m",
22
+ "description": "*The Agent-Centric Distributed Application Meta-ontology* or just: *Agent-Centric DApp Meta-ontology* * A new meta-ontology for interoperable, decentralized application design * A spanning-layer to enable seamless integration between Holochain DNAs, blockchains, linked-data structures/ontologies and centralized back-ends * The basis for turning distinct, monolithic and siloed apps into a global, open and interoperable sense-making network",
23
+ "main": "lib/index.cjs",
24
+ "module": "lib/index.js",
25
+ "types": "lib/src/index.d.ts",
26
+ "type": "module",
27
+ "private": true,
28
+ "scripts": {
29
+ "build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
30
+ "buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
31
+ "bundle": "rollup -c rollup.config.js",
32
+ "test": "jest --forceExit"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/perspect3vism/ad4m.git"
37
+ },
38
+ "author": {
39
+ "name": "Nicolas Luck",
40
+ "email": "nicolas@lucksus.eu"
41
+ },
42
+ "contributors": [
43
+ {
44
+ "name": "Joshua Parkin",
45
+ "email": "joshuadparkin@gmail.com"
46
+ }
47
+ ],
48
+ "license": "CAL-1.0",
49
+ "bugs": {
50
+ "url": "https://github.com/perspect3vism/ad4m/issues"
51
+ },
52
+ "homepage": "https://ad4m.dev",
53
+ "dependencies": {
54
+ "@apollo/client": "3.7.10",
55
+ "@holochain/client": "0.16.0",
56
+ "@types/jest": "^26.0.14",
57
+ "class-validator": "^0.13.1",
58
+ "express": "4.18.2",
59
+ "graphql": "15.7.2",
60
+ "reflect-metadata": "^0.1.13",
61
+ "type-graphql": "1.1.1"
62
+ },
63
+ "devDependencies": {
64
+ "@apollo/server": "^4.9.4",
65
+ "@rollup/plugin-alias": "^3.1.5",
66
+ "@rollup/plugin-commonjs": "^20.0.0",
67
+ "@rollup/plugin-node-resolve": "^13.0.4",
68
+ "concat-md": "^0.5.0",
69
+ "cross-fetch": "^3.1.4",
70
+ "graphql-ws": "5.12.0",
71
+ "honkit": "^4.0.0",
72
+ "jest": "^26.6.0",
73
+ "patch-package": "^8.0.0",
74
+ "rollup": "^2.56.3",
75
+ "ts-jest": "^26.5.6",
76
+ "typescript": "^4.6.2",
77
+ "ws": "8.13.0",
78
+ "@types/node": "*",
79
+ "@types/yargs": "*"
80
+ },
81
+ "patchedDependencies": {},
82
+ "version": "0.9.1-prerelease"
83
+
84
+ }
85
+
86
+ yarn manifest:
87
+ No manifest
88
+
89
+ Lockfile:
90
+ No lockfile