@fluid-experimental/property-properties 0.54.2 → 0.56.0-49831

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/properties/arrayProperty.d.ts.map +1 -1
  2. package/dist/properties/arrayProperty.js +4 -4
  3. package/dist/properties/arrayProperty.js.map +1 -1
  4. package/dist/properties/baseProperty.d.ts +1 -1
  5. package/dist/properties/baseProperty.d.ts.map +1 -1
  6. package/dist/properties/baseProperty.js +13 -12
  7. package/dist/properties/baseProperty.js.map +1 -1
  8. package/dist/properties/boolProperty.d.ts.map +1 -1
  9. package/dist/properties/boolProperty.js +3 -2
  10. package/dist/properties/boolProperty.js.map +1 -1
  11. package/dist/properties/containerProperty.d.ts +1 -1
  12. package/dist/properties/containerProperty.d.ts.map +1 -1
  13. package/dist/properties/containerProperty.js +12 -3
  14. package/dist/properties/containerProperty.js.map +1 -1
  15. package/dist/properties/enumArrayProperty.js +2 -1
  16. package/dist/properties/enumArrayProperty.js.map +1 -1
  17. package/dist/properties/enumProperty.d.ts.map +1 -1
  18. package/dist/properties/enumProperty.js +2 -1
  19. package/dist/properties/enumProperty.js.map +1 -1
  20. package/dist/properties/floatProperties.d.ts.map +1 -1
  21. package/dist/properties/floatProperties.js +6 -4
  22. package/dist/properties/floatProperties.js.map +1 -1
  23. package/dist/properties/indexedCollectionBaseProperty.d.ts +2 -2
  24. package/dist/properties/indexedCollectionBaseProperty.d.ts.map +1 -1
  25. package/dist/properties/indexedCollectionBaseProperty.js +2 -2
  26. package/dist/properties/indexedCollectionBaseProperty.js.map +1 -1
  27. package/dist/properties/intProperties.d.ts.map +1 -1
  28. package/dist/properties/intProperties.js +15 -10
  29. package/dist/properties/intProperties.js.map +1 -1
  30. package/dist/properties/mapProperty.d.ts.map +1 -1
  31. package/dist/properties/mapProperty.js +2 -1
  32. package/dist/properties/mapProperty.js.map +1 -1
  33. package/dist/properties/namedNodeProperty.js +2 -1
  34. package/dist/properties/namedNodeProperty.js.map +1 -1
  35. package/dist/properties/namedProperty.js +2 -1
  36. package/dist/properties/namedProperty.js.map +1 -1
  37. package/dist/properties/nodeProperty.d.ts.map +1 -1
  38. package/dist/properties/nodeProperty.js +3 -1
  39. package/dist/properties/nodeProperty.js.map +1 -1
  40. package/dist/properties/referenceArrayProperty.js +2 -1
  41. package/dist/properties/referenceArrayProperty.js.map +1 -1
  42. package/dist/properties/referenceMapProperty.js +2 -1
  43. package/dist/properties/referenceMapProperty.js.map +1 -1
  44. package/dist/properties/referenceProperty.d.ts +1 -1
  45. package/dist/properties/referenceProperty.d.ts.map +1 -1
  46. package/dist/properties/referenceProperty.js +3 -2
  47. package/dist/properties/referenceProperty.js.map +1 -1
  48. package/dist/properties/setProperty.d.ts.map +1 -1
  49. package/dist/properties/setProperty.js +3 -2
  50. package/dist/properties/setProperty.js.map +1 -1
  51. package/dist/properties/stringProperty.d.ts.map +1 -1
  52. package/dist/properties/stringProperty.js +12 -3
  53. package/dist/properties/stringProperty.js.map +1 -1
  54. package/dist/properties/uintProperties.d.ts.map +1 -1
  55. package/dist/properties/uintProperties.js +9 -6
  56. package/dist/properties/uintProperties.js.map +1 -1
  57. package/dist/properties/valueArrayProperty.d.ts +1 -1
  58. package/dist/properties/valueArrayProperty.d.ts.map +1 -1
  59. package/dist/properties/valueArrayProperty.js +25 -13
  60. package/dist/properties/valueArrayProperty.js.map +1 -1
  61. package/dist/properties/valueMapProperty.d.ts.map +1 -1
  62. package/dist/properties/valueMapProperty.js +38 -26
  63. package/dist/properties/valueMapProperty.js.map +1 -1
  64. package/dist/propertyFactory.d.ts.map +1 -1
  65. package/dist/propertyFactory.js +442 -86
  66. package/dist/propertyFactory.js.map +1 -1
  67. package/dist/propertyTemplateWrapper.d.ts +0 -34
  68. package/dist/propertyTemplateWrapper.d.ts.map +1 -1
  69. package/dist/propertyTemplateWrapper.js +0 -108
  70. package/dist/propertyTemplateWrapper.js.map +1 -1
  71. package/dist/test/propertyFactory.spec.js +5 -2
  72. package/dist/test/propertyFactory.spec.js.map +1 -1
  73. package/dist/test/tsconfig.tsbuildinfo +11 -11
  74. package/lib/properties/arrayProperty.js +4 -4
  75. package/lib/properties/arrayProperty.js.map +1 -1
  76. package/lib/properties/baseProperty.js +13 -12
  77. package/lib/properties/baseProperty.js.map +1 -1
  78. package/lib/properties/boolProperty.js +3 -2
  79. package/lib/properties/boolProperty.js.map +1 -1
  80. package/lib/properties/containerProperty.js +12 -3
  81. package/lib/properties/containerProperty.js.map +1 -1
  82. package/lib/properties/enumArrayProperty.js +2 -1
  83. package/lib/properties/enumArrayProperty.js.map +1 -1
  84. package/lib/properties/enumProperty.js +2 -1
  85. package/lib/properties/enumProperty.js.map +1 -1
  86. package/lib/properties/floatProperties.js +6 -4
  87. package/lib/properties/floatProperties.js.map +1 -1
  88. package/lib/properties/indexedCollectionBaseProperty.js +2 -2
  89. package/lib/properties/indexedCollectionBaseProperty.js.map +1 -1
  90. package/lib/properties/intProperties.js +15 -10
  91. package/lib/properties/intProperties.js.map +1 -1
  92. package/lib/properties/mapProperty.js +2 -1
  93. package/lib/properties/mapProperty.js.map +1 -1
  94. package/lib/properties/namedNodeProperty.js +2 -1
  95. package/lib/properties/namedNodeProperty.js.map +1 -1
  96. package/lib/properties/namedProperty.js +2 -1
  97. package/lib/properties/namedProperty.js.map +1 -1
  98. package/lib/properties/nodeProperty.js +3 -1
  99. package/lib/properties/nodeProperty.js.map +1 -1
  100. package/lib/properties/referenceArrayProperty.js +2 -1
  101. package/lib/properties/referenceArrayProperty.js.map +1 -1
  102. package/lib/properties/referenceMapProperty.js +2 -1
  103. package/lib/properties/referenceMapProperty.js.map +1 -1
  104. package/lib/properties/referenceProperty.js +3 -2
  105. package/lib/properties/referenceProperty.js.map +1 -1
  106. package/lib/properties/setProperty.js +3 -2
  107. package/lib/properties/setProperty.js.map +1 -1
  108. package/lib/properties/stringProperty.js +12 -3
  109. package/lib/properties/stringProperty.js.map +1 -1
  110. package/lib/properties/uintProperties.js +9 -6
  111. package/lib/properties/uintProperties.js.map +1 -1
  112. package/lib/properties/valueArrayProperty.js +25 -13
  113. package/lib/properties/valueArrayProperty.js.map +1 -1
  114. package/lib/properties/valueMapProperty.js +38 -26
  115. package/lib/properties/valueMapProperty.js.map +1 -1
  116. package/lib/propertyFactory.js +442 -86
  117. package/lib/propertyFactory.js.map +1 -1
  118. package/lib/propertyTemplateWrapper.js +0 -108
  119. package/lib/propertyTemplateWrapper.js.map +1 -1
  120. package/package.json +5 -5
@@ -42,8 +42,6 @@ export class PropertyTemplateWrapper {
42
42
  * from templates this template inherits from.
43
43
  */
44
44
  this._compiledPropertyTemplate = undefined;
45
- /** Constants saved in a tree like structure */
46
- this.constantTree = undefined;
47
45
  /* What type of base object is created for this template*/
48
46
  this._objectCreationType = undefined;
49
47
  /* The scope of this template*/
@@ -290,111 +288,5 @@ export class PropertyTemplateWrapper {
290
288
  mergeSubProperties(in_childProperty, in_parentProperty, 'constants');
291
289
  }
292
290
  ;
293
- /**
294
- * @return {Boolean} true if a constant tree was already created and stored here
295
- */
296
- hasConstantTree() {
297
- return this.constantTree !== undefined;
298
- }
299
- ;
300
- /**
301
- * Creates the constant tree if it doesn't exist yet, then apply it to the passed in property
302
- * @param {property-properties.BaseProperty} in_property The property which will have constants applied to
303
- */
304
- loadConstants(in_property) {
305
- if (this.hasConstantTree()) {
306
- this._applyConstants(in_property);
307
- }
308
- else {
309
- this._saveConstants(in_property);
310
- this._applyConstants(in_property);
311
- }
312
- }
313
- ;
314
- /**
315
- * Begins the process of creating and saving the constant tree.
316
- * @param {property-properties.BaseProperty} in_property The property which has constants to be saved
317
- */
318
- _saveConstants(in_property) {
319
- this._saveConstantsRecursive(in_property, {});
320
- // Object.freeze(this.constantTree);
321
- }
322
- ;
323
- /**
324
- * Recursive function which extracts all constants from in_property and saves them.
325
- * @param {property-properties.BaseProperty} in_property The property whose constants will be saved
326
- * @param {Object} out_property A tree like series of nested objects which holds all constants of in_property
327
- * @return {Boolean} returns true if there is a constant within the subtree passed in as in_property
328
- */
329
- _saveConstantsRecursive(in_property, out_property) {
330
- if (in_property instanceof ContainerProperty) {
331
- const children = in_property._staticChildren;
332
- let isConstant = false;
333
- if (children !== undefined) {
334
- if (out_property._constantChildren === undefined) {
335
- out_property._constantChildren = {};
336
- }
337
- if (out_property._staticChildren === undefined) {
338
- out_property._staticChildren = {};
339
- }
340
- const keys = Object.keys(children);
341
- for (let i = 0; i < keys.length; ++i) {
342
- const key = keys[i];
343
- const child = children[key];
344
- if (child._isConstant) {
345
- child._cleanDirty();
346
- if (child._parent && !child._parent._isConstant) {
347
- child._parent = undefined;
348
- }
349
- out_property._constantChildren[key] = child;
350
- // Object.freeze(out_property._constantChildren[key]);
351
- isConstant = true;
352
- delete in_property._staticChildren[key];
353
- }
354
- else {
355
- out_property._staticChildren[key] = {};
356
- const isThereAConstantInChild = this._saveConstantsRecursive(child, out_property._staticChildren[key]);
357
- isConstant = isConstant || isThereAConstantInChild;
358
- if (!isThereAConstantInChild) {
359
- delete out_property._staticChildren[key];
360
- }
361
- }
362
- }
363
- }
364
- this.constantTree = out_property;
365
- return isConstant;
366
- }
367
- return false;
368
- }
369
- ;
370
- /**
371
- * Applies save constants to the property passed in
372
- * @param {property-properties.BaseProperty} in_property The property that constants are being applied to
373
- */
374
- _applyConstants(in_property) {
375
- this._applyConstantsRecursive(this.constantTree, in_property);
376
- }
377
- ;
378
- /**
379
- * Applies constants from the in_property on to the out_property
380
- * @param {Object} in_property The property whose constants will be transfered
381
- * @param {property-properties.BaseProperty} out_property The property that constants are being applied to
382
- */
383
- _applyConstantsRecursive(in_property, out_property) {
384
- if (out_property instanceof ContainerProperty) {
385
- if (in_property._constantChildren) {
386
- out_property._setConstants(in_property._constantChildren);
387
- }
388
- const children = in_property._staticChildren;
389
- if (!_.isUndefined(children)) {
390
- const keys = Object.keys(children);
391
- for (let i = 0; i < keys.length; ++i) {
392
- const key = keys[i];
393
- this._applyConstantsRecursive(children[key], out_property.get([key]));
394
- }
395
- }
396
- }
397
- }
398
- ;
399
291
  }
400
292
  //# sourceMappingURL=propertyTemplateWrapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"propertyTemplateWrapper.js","sourceRoot":"","sources":["../src/propertyTemplateWrapper.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AACxE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AAEzE,MAAM,6BAA6B,GAAG;IAClC,cAAc,EAAE,IAAI;IACpB,mBAAmB,EAAE,IAAI;IACzB,cAAc,EAAE,IAAI;IACpB,MAAM,EAAE,IAAI;CACf,CAAC;AACF;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,EAAE;IACxC,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,OAAO,uBAAuB;IAEhC;;;;;;;;;OASG;IACH,YAAY,iBAAiB,EAAE,QAAQ;QACnC,oDAAoD;QACpD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAE3C;;WAEG;QACH,IAAI,CAAC,yBAAyB,GAAG,SAAS,CAAC;QAE3C,+CAA+C;QAC/C,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAE9B,0DAA0D;QAC1D,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;QAErC,+BAA+B;QAC/B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAAA,CAAC;IAGF;;;;OAIG;IACH,mBAAmB;QACf,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;IAAA,CAAC;IAEF;;;;;;;OAOG;IACH,mBAAmB,CAAC,kBAAkB;QACl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aACJ;SACJ;IACL,CAAC;IAAA,CAAC;CACL","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview\n * Declaration of the PropertyTemplateWrapper module\n * PropertyTemplateWrapper is used to wrap a property template and perform internal optimizations\n */\nconst _ = require('lodash');\nconst { ContainerProperty } = require('./properties/containerProperty');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\n\nconst reservedTypesWithoutTemplates = {\n 'BaseProperty': true,\n 'ContainerProperty': true,\n 'NodeProperty': true,\n 'Enum': true\n};\n/**\n * Utility function that validates if the typeid is a reserved type without a template.\n * @param {string} in_typeid The typeid to validate.\n * @return {boolean} True if the typeid is a reserved type without a template, false otherwise.\n */\nconst hasAssociatedTemplate = (in_typeid) => {\n return !reservedTypesWithoutTemplates[in_typeid];\n};\n\nexport class PropertyTemplateWrapper {\n\n /**\n * Constructor for creating a PropertyTemplateWrapper based on the given template.\n * @param {PropertyTemplate} in_remoteTemplate A property template\n * @param {string} in_scope The scope of the template\n *\n * @constructor\n * @package\n * @alias property-properties.PropertyTemplateWrapper\n * @category Properties\n */\n constructor(in_remoteTemplate, in_scope) {\n /** The property template this object is wrapping */\n this._propertyTemplate = in_remoteTemplate;\n\n /** A property template created from this.propertyTemplate with the addition of all information\n * from templates this template inherits from.\n */\n this._compiledPropertyTemplate = undefined;\n\n /** Constants saved in a tree like structure */\n this.constantTree = undefined;\n\n /* What type of base object is created for this template*/\n this._objectCreationType = undefined;\n\n /* The scope of this template*/\n this._scope = in_scope;\n };\n\n\n /**\n * To get the property template that this is wrapping.\n * @return {property-properties.PropertyTemplate} The template this wrapper contains\n * @package\n */\n getPropertyTemplate() {\n return this._propertyTemplate;\n };\n\n /**\n * Gets the compiled template or creates it then returns it.\n * @param {property-properties.PropertyFactory} in_propertyFactory The assosiated PropertyFactory.\n * @return {property-properties.PropertyTemplate} The compiled template\n * A compiled template is the template which is actually used for creating objects.\n * It has all information from parent Templates, and other changes.\n * @package\n */\n getCompiledTemplate(in_propertyFactory) {\n if (this._compiledPropertyTemplate === undefined) {\n this._compiledPropertyTemplate = this._contructCompiledTemplate(in_propertyFactory);\n }\n return this._compiledPropertyTemplate;\n };\n\n /**\n * Returns if the compiled template has been created.\n * @return {boolean} if the compiled template has been created\n * @package\n */\n hasCompiledTemplate() {\n return !!this._compiledPropertyTemplate;\n };\n\n /**\n * To get the creation type of the template this wraps.\n * @return {string} A typeid which represents the creation type of this template\n * @package\n */\n getCreationType() {\n return this._objectCreationType;\n };\n\n /**\n * If current creation type is undefined, sets it to in_typeid if in_typeid is a creation type.\n * If current creation type is defined, throws if in_typeid is a creation type.\n *\n * @param {string} in_typeid A typeid\n * @package\n */\n setCreationType(in_typeid) {\n // This function could be moved somewhere else, an enum could be made if this information is widely needed.\n const isCreationType = (typeid) => {\n const creationTypes =\n ['ContainerProperty', 'NodeProperty', 'Enum', 'BinaryProperty', 'Binary', 'RepositoryReferenceProperty'];\n return creationTypes.indexOf(typeid) !== -1;\n };\n\n if (isCreationType(in_typeid)) {\n const currentCreationType = this._objectCreationType;\n if (currentCreationType === undefined) {\n this._objectCreationType = in_typeid;\n } else if (currentCreationType !== in_typeid) {\n throw new Error(MSG.ONLY_ONE_CREATION_TYPE + currentCreationType + ', ' + in_typeid);\n }\n }\n };\n\n /**\n * Contructs the compiled template from the template this wraps\n * @param {property-properties.PropertyFactory} in_propertyFactory The associated PropertyFactory.\n * @return {property-properties.PropertyTemplate} The compiled template\n * A compiled template is the template which is actually used for creating objects.\n * It has all information from parent Templates, and other changes.\n * @package\n */\n _contructCompiledTemplate(in_propertyFactory) {\n const originalTemplate = this.getPropertyTemplate();\n\n this.setCreationType(originalTemplate.typeid);\n\n /* Because we treat templates and contructor functions for base types the same way :( */\n if (_.isFunction(originalTemplate)) {\n return originalTemplate;\n }\n\n let parentTemplateIds = originalTemplate.inherits;\n\n /* template.inherits can be a string, if so convert it to array of strings */\n if (typeof parentTemplateIds === 'string') {\n parentTemplateIds = [parentTemplateIds];\n }\n\n /* Cloning the original template to avoid modifying it */\n const template = originalTemplate.clone();\n\n /* Copy the proccesed list of parents to not modify the original */\n const typeInheritence = parentTemplateIds ? parentTemplateIds.slice() : [];\n\n /* Look ups to efficiently check what properties/constants parents have */\n const parentsPropertiesById = {};\n const parentsConstantsById = {};\n\n if (parentTemplateIds !== undefined) {\n for (let i = 0; i < parentTemplateIds.length; ++i) {\n const parentTemplateId = parentTemplateIds[i];\n this.setCreationType(parentTemplateId);\n\n if (hasAssociatedTemplate(parentTemplateId)) {\n const parentTemplateWrapper = in_propertyFactory._getWrapper(parentTemplateId, undefined, this._scope);\n if (parentTemplateWrapper) {\n const parentTemplate = parentTemplateWrapper.getCompiledTemplate(in_propertyFactory);\n const parentCreationType = parentTemplateWrapper.getCreationType();\n\n if (parentCreationType !== 'ContainerProperty') {\n this.setCreationType(parentCreationType);\n }\n\n if (parentTemplate.inherits) {\n typeInheritence.concat(parentTemplateId);\n }\n\n /* Fills parentsPropertiesById and makes sure there are no two properties or constants with the same id */\n if (parentTemplate.hasNestedProperties()) {\n const parentProperties = parentTemplate.properties;\n for (let j = 0; j < parentProperties.length; ++j) {\n const parentProperty = parentProperties[j];\n /* Two parents has child property with same id */\n if (parentsPropertiesById[parentProperty.id] || parentsConstantsById[parentProperty.id]) {\n throw new Error(MSG.OVERWRITING_ID + parentProperty.id);\n }\n parentsPropertiesById[parentProperty.id] = parentProperty;\n }\n }\n\n /* Fills parentsConsantsById and makes sure there are no two properties or constants with the same id */\n if (parentTemplate.hasNestedConstants()) {\n const parentConstants = parentTemplate.constants;\n for (let j = 0; j < parentConstants.length; ++j) {\n const parentConstant = parentConstants[j];\n /* Two parents has child property with same id */\n if (parentsConstantsById[parentConstant.id] || parentsPropertiesById[parentConstant.id]) {\n throw new Error(MSG.OVERWRITING_ID + parentConstant.id);\n }\n parentsConstantsById[parentConstant.id] = parentConstant;\n }\n }\n }\n }\n }\n }\n\n if (this._objectCreationType === undefined) {\n this.setCreationType('ContainerProperty');\n }\n\n /* Merges properties from parents into the properties of the child */\n const constructSubProperties = (in_template, in_parentsPropertiesById, fieldName) => {\n const propertyKeys = Object.keys(in_parentsPropertiesById);\n\n if (in_template[fieldName] === undefined && propertyKeys.length !== 0) {\n in_template[fieldName] = [];\n }\n\n const properties = in_template[fieldName] || [];\n\n for (let i = 0; i < properties.length; ++i) {\n const property = properties[i];\n const id = property.id;\n if (in_parentsPropertiesById[id]) {\n this._mergeProperty(property, in_parentsPropertiesById[id]);\n delete in_parentsPropertiesById[id];\n }\n }\n\n for (let i = 0; i < propertyKeys.length; ++i) {\n const insertProperty = in_parentsPropertiesById[propertyKeys[i]];\n if (insertProperty) {\n properties.push(insertProperty);\n }\n }\n\n if (properties.length > 0) {\n template[fieldName] = properties;\n }\n };\n\n constructSubProperties(template, parentsPropertiesById, 'properties');\n constructSubProperties(template, parentsConstantsById, 'constants');\n\n if (typeInheritence.length > 0) {\n template.inherits = typeInheritence;\n }\n\n return template;\n };\n\n /**\n * A helper function which merges a child and parent property.\n * The changes are applied directly to the in_childProperty.\n * @param {object} in_childProperty The child's property defition.\n * @param {object} in_parentProperty The parent's property defition.\n * @package\n */\n _mergeProperty(in_childProperty, in_parentProperty) {\n const mergeField = (child, parent, fieldName, defaultValue) => {\n if (child[fieldName] === undefined) {\n if (parent[fieldName] !== undefined) {\n child[fieldName] = parent[fieldName];\n }\n } else if (child[fieldName] !== parent[fieldName] &&\n (child[fieldName] !== defaultValue || parent[fieldName] !== undefined)) {\n throw new Error(MSG.OVERRIDEN_PROP_MUST_HAVE_SAME_FIELD_VALUES_AS_BASE_TYPE + fieldName +\n ' as the base type: ' + child.id + ': ' + child[fieldName] + ' != ' + parent[fieldName]);\n }\n };\n\n mergeField(in_childProperty, in_parentProperty, 'context', 'single');\n mergeField(in_childProperty, in_parentProperty, 'contextKeyType', 'string');\n mergeField(in_childProperty, in_parentProperty, 'length', 0);\n mergeField(in_childProperty, in_parentProperty, 'optional', false);\n mergeField(in_childProperty, in_parentProperty, 'typeid', undefined);\n\n if (in_parentProperty.typedValue !== undefined) {\n if (in_childProperty.typedValue === undefined) {\n in_childProperty.typedValue = in_parentProperty.typedValue;\n }\n }\n\n if (in_parentProperty.value !== undefined) {\n if (in_childProperty.value === undefined) {\n in_childProperty.value = in_parentProperty.value;\n }\n }\n\n const mergeSubProperties = (child, parent, fieldName) => {\n const parentPropertiesById = {};\n let parentProperties = parent[fieldName];\n let properties = child[fieldName] || [];\n if (parentProperties) {\n for (let j = 0; j < parentProperties.length; ++j) {\n const parentProperty = parentProperties[j];\n parentPropertiesById[parentProperty.id] = parentProperty;\n }\n\n for (let i = 0; i < properties.length; ++i) {\n const property = properties[i];\n const id = property.id;\n if (parentPropertiesById[id]) {\n this._mergeProperty(property, parentPropertiesById[id]);\n delete parentPropertiesById[id];\n }\n }\n\n const propertyKeys = Object.keys(parentPropertiesById);\n for (let i = 0; i < propertyKeys.length; ++i) {\n const insertProperty = parentPropertiesById[propertyKeys[i]];\n if (insertProperty) {\n properties.push(insertProperty);\n }\n }\n }\n\n if (properties.length > 0) {\n child[fieldName] = properties;\n }\n };\n\n mergeSubProperties(in_childProperty, in_parentProperty, 'properties');\n mergeSubProperties(in_childProperty, in_parentProperty, 'constants');\n };\n\n\n /**\n * @return {Boolean} true if a constant tree was already created and stored here\n */\n hasConstantTree() {\n return this.constantTree !== undefined;\n };\n\n /**\n * Creates the constant tree if it doesn't exist yet, then apply it to the passed in property\n * @param {property-properties.BaseProperty} in_property The property which will have constants applied to\n */\n loadConstants(in_property) {\n if (this.hasConstantTree()) {\n this._applyConstants(in_property);\n } else {\n this._saveConstants(in_property);\n this._applyConstants(in_property);\n }\n };\n\n /**\n * Begins the process of creating and saving the constant tree.\n * @param {property-properties.BaseProperty} in_property The property which has constants to be saved\n */\n _saveConstants(in_property) {\n this._saveConstantsRecursive(in_property, {});\n // Object.freeze(this.constantTree);\n };\n\n /**\n * Recursive function which extracts all constants from in_property and saves them.\n * @param {property-properties.BaseProperty} in_property The property whose constants will be saved\n * @param {Object} out_property A tree like series of nested objects which holds all constants of in_property\n * @return {Boolean} returns true if there is a constant within the subtree passed in as in_property\n */\n _saveConstantsRecursive(in_property, out_property) {\n if (in_property instanceof ContainerProperty) {\n const children = in_property._staticChildren;\n let isConstant = false;\n if (children !== undefined) {\n if (out_property._constantChildren === undefined) {\n out_property._constantChildren = {};\n }\n if (out_property._staticChildren === undefined) {\n out_property._staticChildren = {};\n }\n const keys = Object.keys(children);\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const child = children[key];\n if (child._isConstant) {\n\n child._cleanDirty();\n if (child._parent && !child._parent._isConstant) {\n child._parent = undefined;\n }\n out_property._constantChildren[key] = child;\n // Object.freeze(out_property._constantChildren[key]);\n isConstant = true;\n delete in_property._staticChildren[key];\n } else {\n out_property._staticChildren[key] = {};\n const isThereAConstantInChild = this._saveConstantsRecursive(\n child,\n out_property._staticChildren[key]);\n\n isConstant = isConstant || isThereAConstantInChild;\n if (!isThereAConstantInChild) {\n delete out_property._staticChildren[key];\n }\n }\n }\n }\n this.constantTree = out_property;\n return isConstant;\n }\n return false;\n };\n\n /**\n * Applies save constants to the property passed in\n * @param {property-properties.BaseProperty} in_property The property that constants are being applied to\n */\n _applyConstants(in_property) {\n this._applyConstantsRecursive(this.constantTree, in_property);\n };\n\n /**\n * Applies constants from the in_property on to the out_property\n * @param {Object} in_property The property whose constants will be transfered\n * @param {property-properties.BaseProperty} out_property The property that constants are being applied to\n */\n _applyConstantsRecursive(in_property, out_property) {\n if (out_property instanceof ContainerProperty) {\n if (in_property._constantChildren) {\n out_property._setConstants(in_property._constantChildren);\n }\n const children = in_property._staticChildren;\n if (!_.isUndefined(children)) {\n const keys = Object.keys(children);\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n this._applyConstantsRecursive(children[key], out_property.get([key]));\n }\n }\n }\n };\n}\n"]}
1
+ {"version":3,"file":"propertyTemplateWrapper.js","sourceRoot":"","sources":["../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C;qBACnC;iBACJ;gBAED,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;gBACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;oBAC1C,MAAM,cAAc,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC7D,IAAI,cAAc,EAAE;wBAChB,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;qBACnC;iBACJ;aACJ;YAED,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;gBACvB,KAAK,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC;aACjC;QACL,CAAC,CAAC;QAEF,kBAAkB,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;QACtE,kBAAkB,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC;IAAA,CAAC;CACL","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview\n * Declaration of the PropertyTemplateWrapper module\n * PropertyTemplateWrapper is used to wrap a property template and perform internal optimizations\n */\nconst _ = require('lodash');\nconst { ContainerProperty } = require('./properties/containerProperty');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\n\nconst reservedTypesWithoutTemplates = {\n 'BaseProperty': true,\n 'ContainerProperty': true,\n 'NodeProperty': true,\n 'Enum': true\n};\n/**\n * Utility function that validates if the typeid is a reserved type without a template.\n * @param {string} in_typeid The typeid to validate.\n * @return {boolean} True if the typeid is a reserved type without a template, false otherwise.\n */\nconst hasAssociatedTemplate = (in_typeid) => {\n return !reservedTypesWithoutTemplates[in_typeid];\n};\n\nexport class PropertyTemplateWrapper {\n\n /**\n * Constructor for creating a PropertyTemplateWrapper based on the given template.\n * @param {PropertyTemplate} in_remoteTemplate A property template\n * @param {string} in_scope The scope of the template\n *\n * @constructor\n * @package\n * @alias property-properties.PropertyTemplateWrapper\n * @category Properties\n */\n constructor(in_remoteTemplate, in_scope) {\n /** The property template this object is wrapping */\n this._propertyTemplate = in_remoteTemplate;\n\n /** A property template created from this.propertyTemplate with the addition of all information\n * from templates this template inherits from.\n */\n this._compiledPropertyTemplate = undefined;\n\n /* What type of base object is created for this template*/\n this._objectCreationType = undefined;\n\n /* The scope of this template*/\n this._scope = in_scope;\n };\n\n\n /**\n * To get the property template that this is wrapping.\n * @return {property-properties.PropertyTemplate} The template this wrapper contains\n * @package\n */\n getPropertyTemplate() {\n return this._propertyTemplate;\n };\n\n /**\n * Gets the compiled template or creates it then returns it.\n * @param {property-properties.PropertyFactory} in_propertyFactory The assosiated PropertyFactory.\n * @return {property-properties.PropertyTemplate} The compiled template\n * A compiled template is the template which is actually used for creating objects.\n * It has all information from parent Templates, and other changes.\n * @package\n */\n getCompiledTemplate(in_propertyFactory) {\n if (this._compiledPropertyTemplate === undefined) {\n this._compiledPropertyTemplate = this._contructCompiledTemplate(in_propertyFactory);\n }\n return this._compiledPropertyTemplate;\n };\n\n /**\n * Returns if the compiled template has been created.\n * @return {boolean} if the compiled template has been created\n * @package\n */\n hasCompiledTemplate() {\n return !!this._compiledPropertyTemplate;\n };\n\n /**\n * To get the creation type of the template this wraps.\n * @return {string} A typeid which represents the creation type of this template\n * @package\n */\n getCreationType() {\n return this._objectCreationType;\n };\n\n /**\n * If current creation type is undefined, sets it to in_typeid if in_typeid is a creation type.\n * If current creation type is defined, throws if in_typeid is a creation type.\n *\n * @param {string} in_typeid A typeid\n * @package\n */\n setCreationType(in_typeid) {\n // This function could be moved somewhere else, an enum could be made if this information is widely needed.\n const isCreationType = (typeid) => {\n const creationTypes =\n ['ContainerProperty', 'NodeProperty', 'Enum', 'BinaryProperty', 'Binary', 'RepositoryReferenceProperty'];\n return creationTypes.indexOf(typeid) !== -1;\n };\n\n if (isCreationType(in_typeid)) {\n const currentCreationType = this._objectCreationType;\n if (currentCreationType === undefined) {\n this._objectCreationType = in_typeid;\n } else if (currentCreationType !== in_typeid) {\n throw new Error(MSG.ONLY_ONE_CREATION_TYPE + currentCreationType + ', ' + in_typeid);\n }\n }\n };\n\n /**\n * Contructs the compiled template from the template this wraps\n * @param {property-properties.PropertyFactory} in_propertyFactory The associated PropertyFactory.\n * @return {property-properties.PropertyTemplate} The compiled template\n * A compiled template is the template which is actually used for creating objects.\n * It has all information from parent Templates, and other changes.\n * @package\n */\n _contructCompiledTemplate(in_propertyFactory) {\n const originalTemplate = this.getPropertyTemplate();\n\n this.setCreationType(originalTemplate.typeid);\n\n /* Because we treat templates and contructor functions for base types the same way :( */\n if (_.isFunction(originalTemplate)) {\n return originalTemplate;\n }\n\n let parentTemplateIds = originalTemplate.inherits;\n\n /* template.inherits can be a string, if so convert it to array of strings */\n if (typeof parentTemplateIds === 'string') {\n parentTemplateIds = [parentTemplateIds];\n }\n\n /* Cloning the original template to avoid modifying it */\n const template = originalTemplate.clone();\n\n /* Copy the proccesed list of parents to not modify the original */\n const typeInheritence = parentTemplateIds ? parentTemplateIds.slice() : [];\n\n /* Look ups to efficiently check what properties/constants parents have */\n const parentsPropertiesById = {};\n const parentsConstantsById = {};\n\n if (parentTemplateIds !== undefined) {\n for (let i = 0; i < parentTemplateIds.length; ++i) {\n const parentTemplateId = parentTemplateIds[i];\n this.setCreationType(parentTemplateId);\n\n if (hasAssociatedTemplate(parentTemplateId)) {\n const parentTemplateWrapper = in_propertyFactory._getWrapper(parentTemplateId, undefined, this._scope);\n if (parentTemplateWrapper) {\n const parentTemplate = parentTemplateWrapper.getCompiledTemplate(in_propertyFactory);\n const parentCreationType = parentTemplateWrapper.getCreationType();\n\n if (parentCreationType !== 'ContainerProperty') {\n this.setCreationType(parentCreationType);\n }\n\n if (parentTemplate.inherits) {\n typeInheritence.concat(parentTemplateId);\n }\n\n /* Fills parentsPropertiesById and makes sure there are no two properties or constants with the same id */\n if (parentTemplate.hasNestedProperties()) {\n const parentProperties = parentTemplate.properties;\n for (let j = 0; j < parentProperties.length; ++j) {\n const parentProperty = parentProperties[j];\n /* Two parents has child property with same id */\n if (parentsPropertiesById[parentProperty.id] || parentsConstantsById[parentProperty.id]) {\n throw new Error(MSG.OVERWRITING_ID + parentProperty.id);\n }\n parentsPropertiesById[parentProperty.id] = parentProperty;\n }\n }\n\n /* Fills parentsConsantsById and makes sure there are no two properties or constants with the same id */\n if (parentTemplate.hasNestedConstants()) {\n const parentConstants = parentTemplate.constants;\n for (let j = 0; j < parentConstants.length; ++j) {\n const parentConstant = parentConstants[j];\n /* Two parents has child property with same id */\n if (parentsConstantsById[parentConstant.id] || parentsPropertiesById[parentConstant.id]) {\n throw new Error(MSG.OVERWRITING_ID + parentConstant.id);\n }\n parentsConstantsById[parentConstant.id] = parentConstant;\n }\n }\n }\n }\n }\n }\n\n if (this._objectCreationType === undefined) {\n this.setCreationType('ContainerProperty');\n }\n\n /* Merges properties from parents into the properties of the child */\n const constructSubProperties = (in_template, in_parentsPropertiesById, fieldName) => {\n const propertyKeys = Object.keys(in_parentsPropertiesById);\n\n if (in_template[fieldName] === undefined && propertyKeys.length !== 0) {\n in_template[fieldName] = [];\n }\n\n const properties = in_template[fieldName] || [];\n\n for (let i = 0; i < properties.length; ++i) {\n const property = properties[i];\n const id = property.id;\n if (in_parentsPropertiesById[id]) {\n this._mergeProperty(property, in_parentsPropertiesById[id]);\n delete in_parentsPropertiesById[id];\n }\n }\n\n for (let i = 0; i < propertyKeys.length; ++i) {\n const insertProperty = in_parentsPropertiesById[propertyKeys[i]];\n if (insertProperty) {\n properties.push(insertProperty);\n }\n }\n\n if (properties.length > 0) {\n template[fieldName] = properties;\n }\n };\n\n constructSubProperties(template, parentsPropertiesById, 'properties');\n constructSubProperties(template, parentsConstantsById, 'constants');\n\n if (typeInheritence.length > 0) {\n template.inherits = typeInheritence;\n }\n\n return template;\n };\n\n /**\n * A helper function which merges a child and parent property.\n * The changes are applied directly to the in_childProperty.\n * @param {object} in_childProperty The child's property defition.\n * @param {object} in_parentProperty The parent's property defition.\n * @package\n */\n _mergeProperty(in_childProperty, in_parentProperty) {\n const mergeField = (child, parent, fieldName, defaultValue) => {\n if (child[fieldName] === undefined) {\n if (parent[fieldName] !== undefined) {\n child[fieldName] = parent[fieldName];\n }\n } else if (child[fieldName] !== parent[fieldName] &&\n (child[fieldName] !== defaultValue || parent[fieldName] !== undefined)) {\n throw new Error(MSG.OVERRIDEN_PROP_MUST_HAVE_SAME_FIELD_VALUES_AS_BASE_TYPE + fieldName +\n ' as the base type: ' + child.id + ': ' + child[fieldName] + ' != ' + parent[fieldName]);\n }\n };\n\n mergeField(in_childProperty, in_parentProperty, 'context', 'single');\n mergeField(in_childProperty, in_parentProperty, 'contextKeyType', 'string');\n mergeField(in_childProperty, in_parentProperty, 'length', 0);\n mergeField(in_childProperty, in_parentProperty, 'optional', false);\n mergeField(in_childProperty, in_parentProperty, 'typeid', undefined);\n\n if (in_parentProperty.typedValue !== undefined) {\n if (in_childProperty.typedValue === undefined) {\n in_childProperty.typedValue = in_parentProperty.typedValue;\n }\n }\n\n if (in_parentProperty.value !== undefined) {\n if (in_childProperty.value === undefined) {\n in_childProperty.value = in_parentProperty.value;\n }\n }\n\n const mergeSubProperties = (child, parent, fieldName) => {\n const parentPropertiesById = {};\n let parentProperties = parent[fieldName];\n let properties = child[fieldName] || [];\n if (parentProperties) {\n for (let j = 0; j < parentProperties.length; ++j) {\n const parentProperty = parentProperties[j];\n parentPropertiesById[parentProperty.id] = parentProperty;\n }\n\n for (let i = 0; i < properties.length; ++i) {\n const property = properties[i];\n const id = property.id;\n if (parentPropertiesById[id]) {\n this._mergeProperty(property, parentPropertiesById[id]);\n delete parentPropertiesById[id];\n }\n }\n\n const propertyKeys = Object.keys(parentPropertiesById);\n for (let i = 0; i < propertyKeys.length; ++i) {\n const insertProperty = parentPropertiesById[propertyKeys[i]];\n if (insertProperty) {\n properties.push(insertProperty);\n }\n }\n }\n\n if (properties.length > 0) {\n child[fieldName] = properties;\n }\n };\n\n mergeSubProperties(in_childProperty, in_parentProperty, 'properties');\n mergeSubProperties(in_childProperty, in_parentProperty, 'constants');\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/property-properties",
3
- "version": "0.54.2",
3
+ "version": "0.56.0-49831",
4
4
  "description": "definitions of properties",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": "https://github.com/microsoft/FluidFramework",
@@ -25,7 +25,7 @@
25
25
  "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
26
26
  "coverage": "npx nyc --silent --cwd .. --nycrc-path `pwd`/.nycrc npm run test && npx nyc --no-clean --silent --cwd .. --nycrc-path `pwd`/.nycrc npm run test:changeset && npx nyc --no-clean --cwd .. --nycrc-path `pwd`/.nycrc npm run test:common",
27
27
  "eslint": "eslint --format stylish src",
28
- "eslint:fix": "eslint --format stylish src --fix",
28
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
29
29
  "lint:fix": "npm run eslint:fix",
30
30
  "test": "npm run test:mocha",
31
31
  "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
@@ -56,8 +56,8 @@
56
56
  "temp-directory": "nyc/.nyc_output"
57
57
  },
58
58
  "dependencies": {
59
- "@fluid-experimental/property-changeset": "^0.54.2",
60
- "@fluid-experimental/property-common": "^0.54.2",
59
+ "@fluid-experimental/property-changeset": "0.56.0-49831",
60
+ "@fluid-experimental/property-common": "0.56.0-49831",
61
61
  "ajv": "7.1.1",
62
62
  "async": "^3.2.0",
63
63
  "lodash": "^4.17.21",
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "devDependencies": {
68
68
  "@fluidframework/build-common": "^0.23.0",
69
- "@fluidframework/mocha-test-setup": "^0.54.2",
69
+ "@fluidframework/mocha-test-setup": "0.56.0-49831",
70
70
  "chai": "^4.2.0",
71
71
  "concurrently": "^6.2.0",
72
72
  "cross-env": "^7.0.2",