@fluid-experimental/property-properties 1.0.0 → 1.1.0-76254

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 (44) hide show
  1. package/dist/properties/arrayProperty.d.ts.map +1 -1
  2. package/dist/properties/arrayProperty.js +6 -4
  3. package/dist/properties/arrayProperty.js.map +1 -1
  4. package/dist/properties/baseProperty.js +2 -2
  5. package/dist/properties/baseProperty.js.map +1 -1
  6. package/dist/properties/enumArrayProperty.js +8 -8
  7. package/dist/properties/enumArrayProperty.js.map +1 -1
  8. package/dist/properties/intProperties.d.ts +0 -1
  9. package/dist/properties/intProperties.d.ts.map +1 -1
  10. package/dist/properties/intProperties.js +0 -1
  11. package/dist/properties/intProperties.js.map +1 -1
  12. package/dist/properties/mapProperty.js +2 -2
  13. package/dist/properties/mapProperty.js.map +1 -1
  14. package/dist/properties/referenceArrayProperty.js +1 -1
  15. package/dist/properties/referenceArrayProperty.js.map +1 -1
  16. package/dist/properties/referenceMapProperty.js +1 -1
  17. package/dist/properties/referenceMapProperty.js.map +1 -1
  18. package/dist/properties/referenceProperty.js +1 -1
  19. package/dist/properties/referenceProperty.js.map +1 -1
  20. package/dist/properties/valueArrayProperty.js +2 -2
  21. package/dist/properties/valueArrayProperty.js.map +1 -1
  22. package/dist/test/tsconfig.tsbuildinfo +1 -1
  23. package/lib/properties/arrayProperty.d.ts.map +1 -1
  24. package/lib/properties/arrayProperty.js +6 -4
  25. package/lib/properties/arrayProperty.js.map +1 -1
  26. package/lib/properties/baseProperty.js +2 -2
  27. package/lib/properties/baseProperty.js.map +1 -1
  28. package/lib/properties/enumArrayProperty.js +8 -8
  29. package/lib/properties/enumArrayProperty.js.map +1 -1
  30. package/lib/properties/intProperties.d.ts +0 -1
  31. package/lib/properties/intProperties.d.ts.map +1 -1
  32. package/lib/properties/intProperties.js +0 -1
  33. package/lib/properties/intProperties.js.map +1 -1
  34. package/lib/properties/mapProperty.js +2 -2
  35. package/lib/properties/mapProperty.js.map +1 -1
  36. package/lib/properties/referenceArrayProperty.js +1 -1
  37. package/lib/properties/referenceArrayProperty.js.map +1 -1
  38. package/lib/properties/referenceMapProperty.js +1 -1
  39. package/lib/properties/referenceMapProperty.js.map +1 -1
  40. package/lib/properties/referenceProperty.js +1 -1
  41. package/lib/properties/referenceProperty.js.map +1 -1
  42. package/lib/properties/valueArrayProperty.js +2 -2
  43. package/lib/properties/valueArrayProperty.js.map +1 -1
  44. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"mapProperty.js","sourceRoot":"","sources":["../../src/properties/mapProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACxE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;AACrF,MAAM,EAAE,oBAAoB,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAE7E,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;AAE7C;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,6BAA6B;IAC1D;;;;;;;;OAQG;IACH,YAAY,SAAS,EAAE,QAAQ;QAC3B,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,M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M,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,WAAW,CAAC,SAAS,CAAC,OAAO,GAAG,cAAc,CAAC;AAC/C,WAAW,CAAC,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview Definition of the map property class\n */\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { ConsoleUtils } = require('@fluid-experimental/property-common');\nconst _ = require('lodash');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { BaseProperty } = require('./baseProperty');\nconst { IndexedCollectionBaseProperty } = require('./indexedCollectionBaseProperty');\nconst { LazyLoadedProperties: Property } = require('./lazyLoadedProperties');\n\nconst PATH_TOKENS = BaseProperty.PATH_TOKENS;\n\n/**\n * typedef {property-properties.BaseProperty|string|number|boolean} property-properties.MapProperty~MapValueType\n *\n * The type of the values that are set/inserted into the map. Depending on the type of the map, these can either\n * be property objects or primitive values\n */\n\n/**\n * A MapProperty is a collection class that can contain an dictionary that maps from strings to properties.\n */\nexport class MapProperty extends IndexedCollectionBaseProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n * @param {string|undefined} in_scope - The scope in which the map typeid is defined\n * @constructor\n * @protected\n * @extends property-properties.IndexedCollectionBaseProperty\n * @alias property-properties.MapProperty\n * @category Maps\n */\n constructor(in_params, in_scope) {\n super(in_params);\n\n this._scope = in_scope;\n this._contextKeyType = in_params.contextKeyType || 'string';\n\n /** Contains the actual entries of the map */\n this._dynamicChildren = {};\n }\n\n /**\n * Returns the full property type identifier for the ChangeSet including the enum type id\n * @param {boolean} [in_hideCollection=false] - if true the collection type (if applicable) will be omitted\n * @return {string} The typeid\n */\n getFullTypeid(in_hideCollection = false) {\n if (in_hideCollection) {\n return this._typeid;\n } else {\n return TypeIdHelper.createSerializationTypeId(this._typeid, 'map');\n }\n }\n\n /**\n * Is this property a leaf node with regard to flattening?\n *\n * TODO: Which semantics should flattening have? It stops at primitive types and collections?\n *\n * @return {boolean} Is it a leaf with regard to flattening?\n */\n _isFlattenLeaf() {\n return true;\n }\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @param {Boolean} in_typed - If the map's items have a typeid and a value then create the\n * properties with that typeid, else use the set's typeid (support polymorphic items).\n * @see {setValues}\n * @private\n */\n _setValuesInternal(in_values, in_typed) {\n if (this._containsPrimitiveTypes) {\n var that = this;\n _.each(in_values, function(value, key) {\n if (that.has(key)) {\n that.remove(key);\n }\n\n that.insert(key, value);\n });\n } else {\n var that = this;\n _.each(in_values, function(value, key) {\n var property = that.get(String(key), { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n // if key exists in set replace its value else insert a new key/value\n if (property) {\n if (property instanceof Property.ValueProperty || property instanceof Property.StringProperty) {\n property.setValue(value);\n } else if (property instanceof BaseProperty && _.isObject(value)) {\n property._setValues(value, false, false);\n } else {\n throw new Error(MSG.SET_VALUES_PATH_INVALID + key);\n }\n } else {\n if (value instanceof BaseProperty) {\n that.insert(key, value);\n } else {\n if (in_typed) {\n that.insert(key, Property.PropertyFactory._createProperty(\n value.typeid || that._typeid, null, value.value, that._getScope()));\n } else {\n that.insert(key, Property.PropertyFactory._createProperty(\n that._typeid, null, value, that._getScope()));\n }\n }\n }\n });\n }\n }\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @param {Bool} in_typed - Whether the values are typed/polymorphic.\n * @param {Bool} in_initial - Whether we are setting default/initial values\n * or if the function is called directly with the values to set.\n * @see {setValues}\n * @override\n */\n _setValues(in_values, in_typed, in_initial) {\n if (in_initial) {\n this.clear();\n }\n\n this._setValuesInternal(in_values, in_typed);\n }\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @throws if one of the path in in_values does not exist in this property\n * @throws if trying to set a value to a path that leads to a Property other than ValueProperty or StringProperty\n * @override\n */\n setValues(in_values) {\n var checkoutView = this._getCheckoutView();\n if (checkoutView !== undefined) {\n checkoutView.pushNotificationDelayScope();\n this._setValues(in_values, false, false);\n checkoutView.popNotificationDelayScope();\n } else {\n this._setValues(in_values, false, false);\n }\n }\n\n /**\n * Returns an object with all the nested values contained in this property\n * @return {object} an object representing the values of your property\n * for example: {\n 'firstString': {\n 'stringValue': 'test1'\n },\n 'secondString': {\n 'stringValue': 'test2'\n }\n }\n */\n getValues() {\n var ids = this.getIds();\n var result = {};\n for (var i = 0; i < ids.length; i++) {\n var child = this.get(ids[i]);\n if (child.isPrimitiveType()) {\n result[ids[i]] = this.get(ids[i]).getValue();\n } else {\n result[ids[i]] = child.getValues();\n }\n }\n return result;\n }\n\n /**\n * Returns the path segment for a child\n *\n * @param {property-properties.BaseProperty} in_childNode - The child for which the path is returned\n *\n * @return {string} The path segment to resolve the child property under this property\n * @protected\n */\n _getPathSegmentForChildNode(in_childNode) {\n return '[' + PathHelper.quotePathSegmentIfNeeded(in_childNode._id) + ']';\n }\n\n /**\n * Resolves a direct child node based on the given path segment\n *\n * @param {String} in_segment - The path segment to resolve\n * @param {property-properties.PathHelper.TOKEN_TYPES} in_segmentType - The type of segment in the tokenized path\n *\n * @return {property-properties.BaseProperty|undefined} The child property that has been resolved\n * @protected\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // Base Properties only support paths separated via dots\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this._dynamicChildren[in_segment];\n } else {\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n }\n\n /**\n * Inserts a property or value into the map\n *\n * Note: This will trigger an exception when this key already exists in the map. If you want to overwrite\n * existing entries you can use the set function.\n *\n * @param {string} in_key - The key under which the entry is added\n * @param {property-properties.Property} in_property - The property to insert\n * @throws if the property already exists\n * @throws if the property already has a parent\n * @throws if in_key is not a string\n * @throws if the property is a root property\n */\n insert(in_key, in_property) {\n ConsoleUtils.assert(_.isString(in_key), MSG.KEY_NOT_STRING + in_key);\n if (this._dynamicChildren[in_key] !== undefined) {\n throw new Error(MSG.PROPERTY_ALREADY_EXISTS + in_key);\n }\n if (in_property instanceof BaseProperty) {\n in_property._validateInsertIn(this);\n // Set the ID of the entry, to make sure it corresponds to the used key\n in_property._setId(in_key);\n\n // Insert the entry into the collection\n this._insert(in_key, in_property, true);\n } else {\n throw new Error(MSG.NONVALUE_MAP_INSERT_PROP);\n }\n }\n\n /**\n * Removes the entry with the given key from the map\n *\n * @param {string} in_key - The key of the entry to remove from the map\n * @throws if trying to remove an entry that does not exist\n * @return {*} the item removed\n */\n remove(in_key) {\n var item = this.get(in_key);\n this._removeByKey(in_key, true);\n return item;\n }\n\n /**\n * Sets the entry with the given key to the property passed in\n *\n * Note: this will overwrite an already existing value\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.MapProperty~MapValueType} in_property - The property to store in the map\n * @throws if in_property is not a property\n * @throws if trying to insert a property that has a parent\n * @throws if in_key is not a string or a number\n */\n set(in_key, in_property) {\n this._checkIsNotReadOnly(true);\n if (this._dynamicChildren[in_key] !== in_property) {\n if (this._containsPrimitiveTypes === false && in_property.getParent() !== undefined) {\n throw new Error(MSG.INSERTED_ENTRY_WITH_PARENT);\n }\n if (this._dynamicChildren[in_key] !== undefined) {\n this._removeByKey(in_key, false);\n }\n // Set the ID of the entry, to make sure it corresponds to the used key\n if (this._containsPrimitiveTypes === false) {\n in_property._setId(in_key);\n }\n this._insert(in_key, in_property, false);\n\n // Make one final report\n this._reportDirtinessToView();\n }\n }\n\n /**\n * Returns an Object with all the entries of the map.\n * Contrary ot .getValues, for Property Maps, this will return the Property, not an object with their nested values.\n * WARNING: This is a direct access to the internal data-structure and the collection MUST NOT be modified. It is\n * read only for fast access and iteration. Insertion and deletion MUST be done via the insert and remove functions\n * of this class.\n *\n * @return {Object} The map with all entries in the map.\n */\n getEntriesReadOnly() {\n return this._dynamicChildren;\n }\n\n /**\n * Returns the collection entry with the given key\n *\n * @param {string|array<string>} in_ids - key of the entry to return or an array of keys\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.Property|*|undefined} The entry in the collection or undefined\n * if none could be found\n */\n get(in_ids, in_options) {\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n var prop = this;\n if (in_ids === PATH_TOKENS.ROOT) {\n prop = prop.getRoot();\n } else if (in_ids === PATH_TOKENS.UP) {\n prop = prop.getParent();\n } else if (in_ids === PATH_TOKENS.REF) {\n throw new Error(MSG.NO_GET_DEREFERENCE_ONLY);\n } else {\n prop = prop._dynamicChildren[in_ids];\n }\n\n // Handle automatic reference resolution\n if (in_options.referenceResolutionMode === BaseProperty.REFERENCE_RESOLUTION.ALWAYS) {\n if (prop instanceof Property.ReferenceProperty) {\n prop = prop.ref;\n }\n }\n\n return prop;\n }\n }\n\n /**\n * Checks whether an entry with the given name exists\n *\n * @param {string} in_id - Name of the property\n * @return {boolean} True if the property exists, otherwise false.\n */\n has(in_id) {\n return this._dynamicChildren[in_id] !== undefined;\n }\n\n /**\n * Returns all entries of the map as an array.\n *\n * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n *\n * @return {Array.<property-properties.BaseProperty | *>} Array with all entries of the map. This array\n * is a shallow copy which can be modified by the caller without effects on the map.\n */\n getAsArray() {\n return _.values(this._dynamicChildren);\n }\n\n /**\n * Returns all keys found in the map\n *\n * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n *\n * @return {Array.<string>} The keys\n */\n getIds() {\n return Object.keys(this._dynamicChildren);\n }\n\n /**\n * Get the scope to which this property belongs to.\n * @return {string|undefined} The guid representing the scope in which the\n * map belongs to. If there is a workspace scope return it, else return the scope of this map.\n * @override\n * @private\n */\n _getScope() {\n var scope = IndexedCollectionBaseProperty.prototype._getScope.call(this);\n\n if (scope !== undefined) {\n return scope;\n } else {\n return this._scope;\n }\n }\n\n /**\n * Deletes all values from the Map\n */\n clear() {\n var that = this;\n this.getIds().forEach(function(id) {\n that.remove(id);\n });\n }\n}\n\nMapProperty.prototype._typeid = 'BaseProperty';\nMapProperty.prototype._context = 'map';\n"]}
1
+ {"version":3,"file":"mapProperty.js","sourceRoot":"","sources":["../../src/properties/mapProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACxE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAC;AACrF,MAAM,EAAE,oBAAoB,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAE7E,MA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AO,KAAK,CAAC;SAChB;aAAM;YACH,OAAO,IAAI,CAAC,MAAM,CAAC;SACtB;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACD,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAS,EAAE;YAC7B,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,WAAW,CAAC,SAAS,CAAC,OAAO,GAAG,cAAc,CAAC;AAC/C,WAAW,CAAC,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview Definition of the map property class\n */\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { ConsoleUtils } = require('@fluid-experimental/property-common');\nconst _ = require('lodash');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { BaseProperty } = require('./baseProperty');\nconst { IndexedCollectionBaseProperty } = require('./indexedCollectionBaseProperty');\nconst { LazyLoadedProperties: Property } = require('./lazyLoadedProperties');\n\nconst PATH_TOKENS = BaseProperty.PATH_TOKENS;\n\n/**\n * typedef {property-properties.BaseProperty|string|number|boolean} property-properties.MapProperty~MapValueType\n *\n * The type of the values that are set/inserted into the map. Depending on the type of the map, these can either\n * be property objects or primitive values\n */\n\n/**\n * A MapProperty is a collection class that can contain an dictionary that maps from strings to properties.\n */\nexport class MapProperty extends IndexedCollectionBaseProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n * @param {string|undefined} in_scope - The scope in which the map typeid is defined\n * @constructor\n * @protected\n * @extends property-properties.IndexedCollectionBaseProperty\n * @alias property-properties.MapProperty\n * @category Maps\n */\n constructor(in_params, in_scope) {\n super(in_params);\n\n this._scope = in_scope;\n this._contextKeyType = in_params.contextKeyType || 'string';\n\n /** Contains the actual entries of the map */\n this._dynamicChildren = {};\n }\n\n /**\n * Returns the full property type identifier for the ChangeSet including the enum type id\n * @param {boolean} [in_hideCollection=false] - if true the collection type (if applicable) will be omitted\n * @return {string} The typeid\n */\n getFullTypeid(in_hideCollection = false) {\n if (in_hideCollection) {\n return this._typeid;\n } else {\n return TypeIdHelper.createSerializationTypeId(this._typeid, 'map');\n }\n }\n\n /**\n * Is this property a leaf node with regard to flattening?\n *\n * TODO: Which semantics should flattening have? It stops at primitive types and collections?\n *\n * @return {boolean} Is it a leaf with regard to flattening?\n */\n _isFlattenLeaf() {\n return true;\n }\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @param {Boolean} in_typed - If the map's items have a typeid and a value then create the\n * properties with that typeid, else use the set's typeid (support polymorphic items).\n * @see {setValues}\n * @private\n */\n _setValuesInternal(in_values, in_typed) {\n if (this._containsPrimitiveTypes) {\n var that = this;\n _.each(in_values, function(value, key) {\n if (that.has(key)) {\n that.remove(key);\n }\n\n that.insert(key, value);\n });\n } else {\n var that = this;\n _.each(in_values, function(value, key) {\n var property = that.get(String(key), { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n // if key exists in set replace its value else insert a new key/value\n if (property) {\n if (property instanceof Property.ValueProperty || property instanceof Property.StringProperty) {\n property.setValue(value);\n } else if (property instanceof BaseProperty && _.isObject(value)) {\n property._setValues(value, false, false);\n } else {\n throw new TypeError(MSG.SET_VALUES_PATH_INVALID + key);\n }\n } else {\n if (value instanceof BaseProperty) {\n that.insert(key, value);\n } else {\n if (in_typed) {\n that.insert(key, Property.PropertyFactory._createProperty(\n value.typeid || that._typeid, null, value.value, that._getScope()));\n } else {\n that.insert(key, Property.PropertyFactory._createProperty(\n that._typeid, null, value, that._getScope()));\n }\n }\n }\n });\n }\n }\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @param {Bool} in_typed - Whether the values are typed/polymorphic.\n * @param {Bool} in_initial - Whether we are setting default/initial values\n * or if the function is called directly with the values to set.\n * @see {setValues}\n * @override\n */\n _setValues(in_values, in_typed, in_initial) {\n if (in_initial) {\n this.clear();\n }\n\n this._setValuesInternal(in_values, in_typed);\n }\n\n /**\n * Sets multiple values in a map.\n *\n * @param {object} in_values to assign to the collection\n * @throws if one of the path in in_values does not exist in this property\n * @throws if trying to set a value to a path that leads to a Property other than ValueProperty or StringProperty\n * @override\n */\n setValues(in_values) {\n var checkoutView = this._getCheckoutView();\n if (checkoutView !== undefined) {\n checkoutView.pushNotificationDelayScope();\n this._setValues(in_values, false, false);\n checkoutView.popNotificationDelayScope();\n } else {\n this._setValues(in_values, false, false);\n }\n }\n\n /**\n * Returns an object with all the nested values contained in this property\n * @return {object} an object representing the values of your property\n * for example: {\n 'firstString': {\n 'stringValue': 'test1'\n },\n 'secondString': {\n 'stringValue': 'test2'\n }\n }\n */\n getValues() {\n var ids = this.getIds();\n var result = {};\n for (var i = 0; i < ids.length; i++) {\n var child = this.get(ids[i]);\n if (child.isPrimitiveType()) {\n result[ids[i]] = this.get(ids[i]).getValue();\n } else {\n result[ids[i]] = child.getValues();\n }\n }\n return result;\n }\n\n /**\n * Returns the path segment for a child\n *\n * @param {property-properties.BaseProperty} in_childNode - The child for which the path is returned\n *\n * @return {string} The path segment to resolve the child property under this property\n * @protected\n */\n _getPathSegmentForChildNode(in_childNode) {\n return '[' + PathHelper.quotePathSegmentIfNeeded(in_childNode._id) + ']';\n }\n\n /**\n * Resolves a direct child node based on the given path segment\n *\n * @param {String} in_segment - The path segment to resolve\n * @param {property-properties.PathHelper.TOKEN_TYPES} in_segmentType - The type of segment in the tokenized path\n *\n * @return {property-properties.BaseProperty|undefined} The child property that has been resolved\n * @protected\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // Base Properties only support paths separated via dots\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this._dynamicChildren[in_segment];\n } else {\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n }\n\n /**\n * Inserts a property or value into the map\n *\n * Note: This will trigger an exception when this key already exists in the map. If you want to overwrite\n * existing entries you can use the set function.\n *\n * @param {string} in_key - The key under which the entry is added\n * @param {property-properties.Property} in_property - The property to insert\n * @throws if the property already exists\n * @throws if the property already has a parent\n * @throws if in_key is not a string\n * @throws if the property is a root property\n */\n insert(in_key, in_property) {\n ConsoleUtils.assert(_.isString(in_key), MSG.KEY_NOT_STRING + in_key);\n if (this._dynamicChildren[in_key] !== undefined) {\n throw new Error(MSG.PROPERTY_ALREADY_EXISTS + in_key);\n }\n if (in_property instanceof BaseProperty) {\n in_property._validateInsertIn(this);\n // Set the ID of the entry, to make sure it corresponds to the used key\n in_property._setId(in_key);\n\n // Insert the entry into the collection\n this._insert(in_key, in_property, true);\n } else {\n throw new TypeError(MSG.NONVALUE_MAP_INSERT_PROP);\n }\n }\n\n /**\n * Removes the entry with the given key from the map\n *\n * @param {string} in_key - The key of the entry to remove from the map\n * @throws if trying to remove an entry that does not exist\n * @return {*} the item removed\n */\n remove(in_key) {\n var item = this.get(in_key);\n this._removeByKey(in_key, true);\n return item;\n }\n\n /**\n * Sets the entry with the given key to the property passed in\n *\n * Note: this will overwrite an already existing value\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.MapProperty~MapValueType} in_property - The property to store in the map\n * @throws if in_property is not a property\n * @throws if trying to insert a property that has a parent\n * @throws if in_key is not a string or a number\n */\n set(in_key, in_property) {\n this._checkIsNotReadOnly(true);\n if (this._dynamicChildren[in_key] !== in_property) {\n if (this._containsPrimitiveTypes === false && in_property.getParent() !== undefined) {\n throw new Error(MSG.INSERTED_ENTRY_WITH_PARENT);\n }\n if (this._dynamicChildren[in_key] !== undefined) {\n this._removeByKey(in_key, false);\n }\n // Set the ID of the entry, to make sure it corresponds to the used key\n if (this._containsPrimitiveTypes === false) {\n in_property._setId(in_key);\n }\n this._insert(in_key, in_property, false);\n\n // Make one final report\n this._reportDirtinessToView();\n }\n }\n\n /**\n * Returns an Object with all the entries of the map.\n * Contrary ot .getValues, for Property Maps, this will return the Property, not an object with their nested values.\n * WARNING: This is a direct access to the internal data-structure and the collection MUST NOT be modified. It is\n * read only for fast access and iteration. Insertion and deletion MUST be done via the insert and remove functions\n * of this class.\n *\n * @return {Object} The map with all entries in the map.\n */\n getEntriesReadOnly() {\n return this._dynamicChildren;\n }\n\n /**\n * Returns the collection entry with the given key\n *\n * @param {string|array<string>} in_ids - key of the entry to return or an array of keys\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.Property|*|undefined} The entry in the collection or undefined\n * if none could be found\n */\n get(in_ids, in_options) {\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n var prop = this;\n if (in_ids === PATH_TOKENS.ROOT) {\n prop = prop.getRoot();\n } else if (in_ids === PATH_TOKENS.UP) {\n prop = prop.getParent();\n } else if (in_ids === PATH_TOKENS.REF) {\n throw new Error(MSG.NO_GET_DEREFERENCE_ONLY);\n } else {\n prop = prop._dynamicChildren[in_ids];\n }\n\n // Handle automatic reference resolution\n if (in_options.referenceResolutionMode === BaseProperty.REFERENCE_RESOLUTION.ALWAYS) {\n if (prop instanceof Property.ReferenceProperty) {\n prop = prop.ref;\n }\n }\n\n return prop;\n }\n }\n\n /**\n * Checks whether an entry with the given name exists\n *\n * @param {string} in_id - Name of the property\n * @return {boolean} True if the property exists, otherwise false.\n */\n has(in_id) {\n return this._dynamicChildren[in_id] !== undefined;\n }\n\n /**\n * Returns all entries of the map as an array.\n *\n * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n *\n * @return {Array.<property-properties.BaseProperty | *>} Array with all entries of the map. This array\n * is a shallow copy which can be modified by the caller without effects on the map.\n */\n getAsArray() {\n return _.values(this._dynamicChildren);\n }\n\n /**\n * Returns all keys found in the map\n *\n * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n *\n * @return {Array.<string>} The keys\n */\n getIds() {\n return Object.keys(this._dynamicChildren);\n }\n\n /**\n * Get the scope to which this property belongs to.\n * @return {string|undefined} The guid representing the scope in which the\n * map belongs to. If there is a workspace scope return it, else return the scope of this map.\n * @override\n * @private\n */\n _getScope() {\n var scope = IndexedCollectionBaseProperty.prototype._getScope.call(this);\n\n if (scope !== undefined) {\n return scope;\n } else {\n return this._scope;\n }\n }\n\n /**\n * Deletes all values from the Map\n */\n clear() {\n var that = this;\n this.getIds().forEach(function(id) {\n that.remove(id);\n });\n }\n}\n\nMapProperty.prototype._typeid = 'BaseProperty';\nMapProperty.prototype._context = 'map';\n"]}
@@ -224,7 +224,7 @@ export class ReferenceArrayProperty extends ValueArrayProperty {
224
224
  */
225
225
  ReferenceArrayProperty._convertInputToPaths = function (in_array, in_callerName) {
226
226
  if (!_.isArray(in_array)) {
227
- throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'ReferenceArrayProperty.' + in_callerName);
227
+ throw new TypeError(MSG.IN_ARRAY_NOT_ARRAY + 'ReferenceArrayProperty.' + in_callerName);
228
228
  }
229
229
  var len = in_array.length;
230
230
  var arr = new Array(len);
@@ -1 +1 @@
1
- {"version":3,"file":"referenceArrayProperty.js","sourceRoot":"","sources":["../../src/properties/referenceArrayProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AACH,MAAM,EAAE,UAAU,EAAE,Y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AAE,aAAa;IAC1D,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,kBAAkB,GAAG,yBAAyB,GAAG,aAAa,CAAC,CAAC;KACvF;IACD,IAAI,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/D;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEN,sBAAsB,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the reference array property class\n */\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { UniversalDataArray, ConsoleUtils } = require('@fluid-experimental/property-common');\nconst _ = require('lodash');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { BaseProperty } = require('./baseProperty');\nconst { ReferenceProperty } = require('./referenceProperty');\nconst { ValueArrayProperty } = require('./valueArrayProperty');\n\n/**\n * An ArrayProperty which stores reference values\n */\nexport class ReferenceArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ArrayProperty\n * @alias property-properties.ReferenceArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n }\n\n /**\n * Resolves the referenced property for the given key\n *\n * @param {number|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get([0, 'position','x']) is equivalent to .get(0).get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will, by default, return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the AbstractStaticCollectionProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n var value = this._dataArrayRef.getValue(in_ids);\n if (value === undefined ||\n value === '') {\n return undefined;\n }\n\n return this.getParent().resolvePath(value, in_options);\n }\n }\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @param {number} in_position the target index\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid(in_position) {\n return ValueArrayProperty.prototype.get.call(this, in_position) === '' ||\n this.get(in_position) !== undefined;\n }\n\n /**\n * Sets the range in the array to point to the given property objects or to be equal to the given paths\n *\n * @param {number} in_offset - target start index\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n setRange(in_offset, in_array) {\n var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'setRange');\n ValueArrayProperty.prototype.setRange.call(this, in_offset, arr);\n }\n\n /**\n * Insert a range which points to the given property objects into the array\n *\n * @param {number} in_offset - target start index\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n insertRange(in_offset, in_array) {\n var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'insertRange');\n ValueArrayProperty.prototype.insertRange.call(this, in_offset, arr);\n }\n\n /**\n * returns the path value of a reference.\n * @param {number} in_id the index of the property\n * @return {string} the path string\n */\n getValue(in_id) {\n return this._dataArrayRef.getValue(in_id);\n }\n\n /**\n * Returns an object with all the nested values contained in this property\n * @return {array<String>} an array of strings representing the paths listed in this array\n * for example: ['/path1', '/path2']\n */\n getValues() {\n var result = [];\n var ids = this.getIds();\n for (var i = 0; i < ids.length; i++) {\n result.push(this.getValue(ids[i]));\n }\n return result;\n }\n\n /**\n * Removes the last element of the array\n * @throws if trying to modify a referenced property\n * @return {String} deleted element (string path)\n */\n pop() {\n if (this._dataArrayRef.length > 0) {\n var item = this.getValue(this._dataArrayRef.length - 1);\n this.remove(this._dataArrayRef.length - 1);\n return item;\n } else {\n return undefined;\n }\n }\n\n /**\n * Removes an element of the array and shift remaining elements to the left\n * @param {number} in_position the index that will be removed\n * @throws if in_position is not a number\n * @throws if trying to remove an item with a parent\n * @throws if trying to remove something that does not exist\n * @return {String} the value that was removed (string path).\n */\n remove(in_position) {\n var value = this.getValue(in_position);\n this.removeRange(in_position, 1);\n return value;\n }\n\n /**\n * Removes a given number of elements from the array and shifts remaining values to the left.\n * @param {number} in_offset target start index\n * @param {number} in_deleteCount number of elements to be deleted\n * @throws if in_offset is not a number\n * @throws if in_deleteCount is not a number\n * @throws if trying to remove an item with a parent\n * @throws if in_offset is smaller than zero or if in_offset + in_delete count is larger than the length of the array\n * @return {Array<String>} an array containing the values removed (string paths)\n */\n removeRange(in_offset, in_deleteCount) {\n ConsoleUtils.assert(_.isNumber(in_offset),\n MSG.NOT_NUMBER + 'in_offset, method: ArrayProperty.removeRange or .remove');\n ConsoleUtils.assert(_.isNumber(in_deleteCount),\n MSG.NOT_NUMBER + 'in_deleteCount, method: ArrayProperty.removeRange or .remove');\n ConsoleUtils.assert(in_offset + in_deleteCount < this.length + 1 && in_offset >= 0 && in_deleteCount > 0,\n MSG.REMOVE_OUT_OF_BOUNDS + 'Cannot remove ' + in_deleteCount + ' items starting at index ' + in_offset);\n var result = [];\n for (var i = in_offset; i < in_offset + in_deleteCount; i++) {\n result.push(this.getValue(i));\n }\n this._checkIsNotReadOnly(true);\n this._removeRangeWithoutDirtying(in_offset, in_deleteCount);\n this._setDirty();\n return result;\n }\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // Array tokens are automatically resolved\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n } else {\n // Everything else is handled by the implementation in the base property\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, '');\n }\n }\n\n /**\n * Validates the array and returns a sanitized version of it containing only strings.\n *\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @param {String} in_callerName - the name of the function that called, to make it appear in\n * the error message if any\n * @return {Array<string>} the array of paths\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n static _convertInputToPaths = function(in_array, in_callerName) {\n if (!_.isArray(in_array)) {\n throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'ReferenceArrayProperty.' + in_callerName);\n }\n var len = in_array.length;\n var arr = new Array(len);\n for (var i = 0; i < len; i++) {\n arr[i] = ReferenceProperty._convertInputToPath(in_array[i]);\n }\n return arr;\n };\n}\nReferenceArrayProperty.prototype._typeid = 'Reference';\n"]}
1
+ {"version":3,"file":"referenceArrayProperty.js","sourceRoot":"","sources":["../../src/properties/referenceArrayProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AACH,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAC5F,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7D,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC1D;;;;;;;;OAQG;IACH,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,wBAAwB;QACpB,OAAO,YAAY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AC,CAAC;SACrG;aAAM;YACH,wEAAwE;YACxE,OAAO,gCAAgC,CAAC,SAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;SAChH;IACL,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,SAAS;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;YAChC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SAClC;IACL,CAAC;;AAED;;;;;;;;;;;GAWG;AACI,2CAAoB,GAAG,UAAS,QAAQ,EAAE,aAAa;IAC1D,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACtB,MAAM,IAAI,SAAS,CAAC,GAAG,CAAC,kBAAkB,GAAG,yBAAyB,GAAG,aAAa,CAAC,CAAC;KAC3F;IACD,IAAI,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC1B,IAAI,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/D;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEN,sBAAsB,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the reference array property class\n */\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst { UniversalDataArray, ConsoleUtils } = require('@fluid-experimental/property-common');\nconst _ = require('lodash');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { BaseProperty } = require('./baseProperty');\nconst { ReferenceProperty } = require('./referenceProperty');\nconst { ValueArrayProperty } = require('./valueArrayProperty');\n\n/**\n * An ArrayProperty which stores reference values\n */\nexport class ReferenceArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ArrayProperty\n * @alias property-properties.ReferenceArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n }\n\n /**\n * Resolves the referenced property for the given key\n *\n * @param {number|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get([0, 'position','x']) is equivalent to .get(0).get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will, by default, return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the AbstractStaticCollectionProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n var value = this._dataArrayRef.getValue(in_ids);\n if (value === undefined ||\n value === '') {\n return undefined;\n }\n\n return this.getParent().resolvePath(value, in_options);\n }\n }\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @param {number} in_position the target index\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid(in_position) {\n return ValueArrayProperty.prototype.get.call(this, in_position) === '' ||\n this.get(in_position) !== undefined;\n }\n\n /**\n * Sets the range in the array to point to the given property objects or to be equal to the given paths\n *\n * @param {number} in_offset - target start index\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n setRange(in_offset, in_array) {\n var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'setRange');\n ValueArrayProperty.prototype.setRange.call(this, in_offset, arr);\n }\n\n /**\n * Insert a range which points to the given property objects into the array\n *\n * @param {number} in_offset - target start index\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n insertRange(in_offset, in_array) {\n var arr = ReferenceArrayProperty._convertInputToPaths(in_array, 'insertRange');\n ValueArrayProperty.prototype.insertRange.call(this, in_offset, arr);\n }\n\n /**\n * returns the path value of a reference.\n * @param {number} in_id the index of the property\n * @return {string} the path string\n */\n getValue(in_id) {\n return this._dataArrayRef.getValue(in_id);\n }\n\n /**\n * Returns an object with all the nested values contained in this property\n * @return {array<String>} an array of strings representing the paths listed in this array\n * for example: ['/path1', '/path2']\n */\n getValues() {\n var result = [];\n var ids = this.getIds();\n for (var i = 0; i < ids.length; i++) {\n result.push(this.getValue(ids[i]));\n }\n return result;\n }\n\n /**\n * Removes the last element of the array\n * @throws if trying to modify a referenced property\n * @return {String} deleted element (string path)\n */\n pop() {\n if (this._dataArrayRef.length > 0) {\n var item = this.getValue(this._dataArrayRef.length - 1);\n this.remove(this._dataArrayRef.length - 1);\n return item;\n } else {\n return undefined;\n }\n }\n\n /**\n * Removes an element of the array and shift remaining elements to the left\n * @param {number} in_position the index that will be removed\n * @throws if in_position is not a number\n * @throws if trying to remove an item with a parent\n * @throws if trying to remove something that does not exist\n * @return {String} the value that was removed (string path).\n */\n remove(in_position) {\n var value = this.getValue(in_position);\n this.removeRange(in_position, 1);\n return value;\n }\n\n /**\n * Removes a given number of elements from the array and shifts remaining values to the left.\n * @param {number} in_offset target start index\n * @param {number} in_deleteCount number of elements to be deleted\n * @throws if in_offset is not a number\n * @throws if in_deleteCount is not a number\n * @throws if trying to remove an item with a parent\n * @throws if in_offset is smaller than zero or if in_offset + in_delete count is larger than the length of the array\n * @return {Array<String>} an array containing the values removed (string paths)\n */\n removeRange(in_offset, in_deleteCount) {\n ConsoleUtils.assert(_.isNumber(in_offset),\n MSG.NOT_NUMBER + 'in_offset, method: ArrayProperty.removeRange or .remove');\n ConsoleUtils.assert(_.isNumber(in_deleteCount),\n MSG.NOT_NUMBER + 'in_deleteCount, method: ArrayProperty.removeRange or .remove');\n ConsoleUtils.assert(in_offset + in_deleteCount < this.length + 1 && in_offset >= 0 && in_deleteCount > 0,\n MSG.REMOVE_OUT_OF_BOUNDS + 'Cannot remove ' + in_deleteCount + ' items starting at index ' + in_offset);\n var result = [];\n for (var i = in_offset; i < in_offset + in_deleteCount; i++) {\n result.push(this.getValue(i));\n }\n this._checkIsNotReadOnly(true);\n this._removeRangeWithoutDirtying(in_offset, in_deleteCount);\n this._setDirty();\n return result;\n }\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // Array tokens are automatically resolved\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n } else {\n // Everything else is handled by the implementation in the base property\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, '');\n }\n }\n\n /**\n * Validates the array and returns a sanitized version of it containing only strings.\n *\n * @param {Array<property-properties.BaseProperty|undefined|String>} in_array - contains the properties to be set or\n * the paths to those properties. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @param {String} in_callerName - the name of the function that called, to make it appear in\n * the error message if any\n * @return {Array<string>} the array of paths\n * @throws if in_array is not an array\n * @throws if one of the items in in_array is defined, but is not a property or a string.\n */\n static _convertInputToPaths = function(in_array, in_callerName) {\n if (!_.isArray(in_array)) {\n throw new TypeError(MSG.IN_ARRAY_NOT_ARRAY + 'ReferenceArrayProperty.' + in_callerName);\n }\n var len = in_array.length;\n var arr = new Array(len);\n for (var i = 0; i < len; i++) {\n arr[i] = ReferenceProperty._convertInputToPath(in_array[i]);\n }\n return arr;\n };\n}\nReferenceArrayProperty.prototype._typeid = 'Reference';\n"]}
@@ -113,7 +113,7 @@ export class ReferenceMapProperty extends StringMapProperty {
113
113
  */
114
114
  set(in_key, in_value) {
115
115
  if (!_.isString(in_key)) {
116
- throw new Error(MSG.KEY_NOT_STRING + in_key);
116
+ throw new TypeError(MSG.KEY_NOT_STRING + in_key);
117
117
  }
118
118
  var value = ReferenceProperty._convertInputToPath(in_value);
119
119
  StringMapProperty.prototype.set.call(this, in_key, value);
@@ -1 +1 @@
1
- {"version":3,"file":"referenceMapProperty.js","sourceRoot":"","sources":["../../src/properties/referenceMapProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AACH,MAAM,EAAE,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;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,MAAM,EAAE,QAAQ;QACnB,IAAI,KAAK,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,gBAAgB,CAAC,MAAM;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;YACnB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE;gBACzB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAAM;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,UAAU,EAAE,cAAc;QAC1C,0CAA0C;QAC1C,IAAI,cAAc,KAAK,UAAU,CAAC,WAAW,CAAC,WAAW,EAAE;YACvD,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,uBAAuB,EAAE,YAAY,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC;SACrG;aAAM;YACH,wEAAwE;YACxE,OAAO,gCAAgC,CAAC,SAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;SAChH;IACL,CAAC;CACJ;AAED,oBAAoB,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the reference map property class\n */\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst _ = require('lodash');\nconst { BaseProperty } = require('./baseProperty');\nconst { ContainerProperty } = require('./containerProperty');\nconst { ReferenceProperty } = require('./referenceProperty');\nconst { StringMapProperty } = require('./valueMapProperty');\n\n/**\n * A StringMapProperty which stores reference values\n */\nexport class ReferenceMapProperty extends StringMapProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.StringMapProperty\n * @alias property-properties.ReferenceMapProperty\n * @category Maps\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n }\n\n /**\n * Resolves the referenced property for the given key\n *\n * @param {string|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n var value = this._dynamicChildren[in_ids];\n if (value === undefined ||\n value === '') {\n return undefined;\n }\n return this.getParent().resolvePath(value, in_options);\n }\n }\n\n /**\n * Removes the entry with the given key from the map\n *\n * @param {string} in_key - The key of the entry to remove from the map\n * @throws if trying to remove an entry that does not exist\n * @return {String} the item removed (a string path)\n */\n remove(in_key) {\n var item = this.getValue(in_key);\n this._removeByKey(in_key, true);\n return item;\n }\n\n /**\n * Returns an object with all the nested path values\n * @return {object} an object representing the values of your property\n * for example: {\n 'firstPath': '/path',\n 'secondPath': '/path2'\n }\n */\n getValues() {\n var ids = this.getIds();\n var result = {};\n for (var i = 0; i < ids.length; i++) {\n result[ids[i]] = this.getValue(ids[i]);\n }\n return result;\n }\n\n /**\n * Sets or inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_key is not a string\n * @throws if in_value is defined, but is not a property or a string.\n * @throws if map is read only\n */\n set(in_key, in_value) {\n if (!_.isString(in_key)) {\n throw new Error(MSG.KEY_NOT_STRING + in_key);\n }\n var value = ReferenceProperty._convertInputToPath(in_value);\n StringMapProperty.prototype.set.call(this, in_key, value);\n }\n\n /**\n * Sets or inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_key is not a string\n * @throws if in_value is defined, but is not a property or a string.\n * @deprecated\n */\n setValue(...args) {\n return this.set(...args);\n }\n\n /**\n * Inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if there is already an entry under in_key\n * @throws if in_value is defined, but is not a property or a string.\n */\n insert(in_key, in_value) {\n var value = ReferenceProperty._convertInputToPath(in_value);\n this._insert(in_key, value, true);\n }\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @param {string} in_key - key of the entry to check\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid(in_key) {\n return this.has(in_key) &&\n (this.getValue(in_key) === '' ||\n this.get(in_key) !== undefined);\n }\n\n /**\n * Returns the string value stored in the map\n * @param {string} in_key the key of the reference\n * @return {string} the path string\n */\n getValue(in_key) {\n return this._getValue(in_key);\n }\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // Array tokens are automatically resolved\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n } else {\n // Everything else is handled by the implementation in the base property\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n }\n}\n\nReferenceMapProperty.prototype._typeid = 'Reference';\n"]}
1
+ {"version":3,"file":"referenceMapProperty.js","sourceRoot":"","sources":["../../src/properties/referenceMapProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AACH,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7D,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7D,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAA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,CAAC,KAAK,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAAM;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,UAAU,EAAE,cAAc;QAC1C,0CAA0C;QAC1C,IAAI,cAAc,KAAK,UAAU,CAAC,WAAW,CAAC,WAAW,EAAE;YACvD,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,uBAAuB,EAAE,YAAY,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC;SACrG;aAAM;YACH,wEAAwE;YACxE,OAAO,gCAAgC,CAAC,SAAS,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;SAChH;IACL,CAAC;CACJ;AAED,oBAAoB,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the reference map property class\n */\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst _ = require('lodash');\nconst { BaseProperty } = require('./baseProperty');\nconst { ContainerProperty } = require('./containerProperty');\nconst { ReferenceProperty } = require('./referenceProperty');\nconst { StringMapProperty } = require('./valueMapProperty');\n\n/**\n * A StringMapProperty which stores reference values\n */\nexport class ReferenceMapProperty extends StringMapProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.StringMapProperty\n * @alias property-properties.ReferenceMapProperty\n * @category Maps\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n }\n\n /**\n * Resolves the referenced property for the given key\n *\n * @param {string|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n *\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n } else {\n var value = this._dynamicChildren[in_ids];\n if (value === undefined ||\n value === '') {\n return undefined;\n }\n return this.getParent().resolvePath(value, in_options);\n }\n }\n\n /**\n * Removes the entry with the given key from the map\n *\n * @param {string} in_key - The key of the entry to remove from the map\n * @throws if trying to remove an entry that does not exist\n * @return {String} the item removed (a string path)\n */\n remove(in_key) {\n var item = this.getValue(in_key);\n this._removeByKey(in_key, true);\n return item;\n }\n\n /**\n * Returns an object with all the nested path values\n * @return {object} an object representing the values of your property\n * for example: {\n 'firstPath': '/path',\n 'secondPath': '/path2'\n }\n */\n getValues() {\n var ids = this.getIds();\n var result = {};\n for (var i = 0; i < ids.length; i++) {\n result[ids[i]] = this.getValue(ids[i]);\n }\n return result;\n }\n\n /**\n * Sets or inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_key is not a string\n * @throws if in_value is defined, but is not a property or a string.\n * @throws if map is read only\n */\n set(in_key, in_value) {\n if (!_.isString(in_key)) {\n throw new TypeError(MSG.KEY_NOT_STRING + in_key);\n }\n var value = ReferenceProperty._convertInputToPath(in_value);\n StringMapProperty.prototype.set.call(this, in_key, value);\n }\n\n /**\n * Sets or inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if in_key is not a string\n * @throws if in_value is defined, but is not a property or a string.\n * @deprecated\n */\n setValue(...args) {\n return this.set(...args);\n }\n\n /**\n * Inserts the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {string} in_key - The key under which the entry is stored\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if there is already an entry under in_key\n * @throws if in_value is defined, but is not a property or a string.\n */\n insert(in_key, in_value) {\n var value = ReferenceProperty._convertInputToPath(in_value);\n this._insert(in_key, value, true);\n }\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @param {string} in_key - key of the entry to check\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid(in_key) {\n return this.has(in_key) &&\n (this.getValue(in_key) === '' ||\n this.get(in_key) !== undefined);\n }\n\n /**\n * Returns the string value stored in the map\n * @param {string} in_key the key of the reference\n * @return {string} the path string\n */\n getValue(in_key) {\n return this._getValue(in_key);\n }\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // Array tokens are automatically resolved\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN) {\n return this.get(in_segment, { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.NEVER });\n } else {\n // Everything else is handled by the implementation in the base property\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n }\n}\n\nReferenceMapProperty.prototype._typeid = 'Reference';\n"]}
@@ -191,7 +191,7 @@ export class ReferenceProperty extends ValueProperty {
191
191
  path = String(in_value);
192
192
  }
193
193
  else {
194
- throw new Error(MSG.PROPERTY_OR_UNDEFINED + '(' + typeof in_value + ') ' + in_value);
194
+ throw new TypeError(MSG.PROPERTY_OR_UNDEFINED + '(' + typeof in_value + ') ' + in_value);
195
195
  }
196
196
  return path;
197
197
  }
@@ -1 +1 @@
1
- {"version":3,"file":"referenceProperty.js","sourceRoot":"","sources":["../../src/properties/referenceProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAEH,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnD,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC1D,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAErD;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAChD;;;;;;;;MAQE;IACF,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,oDAAoD;QACpD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,eAAe;QACX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,IAAI,EAAE,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,GAAG,CAAC,GAAG;QACP,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ;QAC/B,IAAI,IAAI,CAAC;QACT,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAC9B,IAAI,GAAG,QAAQ,CAAC;SACnB;aAAM,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC/B,IAAI,GAAG,EAAE,CAAC;SACb;aAAM,IAAI,QAAQ,YAAY,YAAY,EAAE;YACzC,oGAAoG;YACpG,IAAI,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;SACrC;aAAM,IAAI,QAAQ,YAAY,MAAM,EAAE;YACnC,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;SAC3B;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,qBAAqB,GAAG,GAAG,GAAG,OAAO,QAAQ,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;SACxF;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AACD,iBAAiB,CAAC,SAAS,CAAC,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC;AAChE,iBAAiB,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the ReferenceProperty class\n */\n\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst _ = require('lodash');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { BaseProperty } = require('./baseProperty');\nconst { _castFunctors } = require('./primitiveTypeCasts');\nconst { ValueProperty } = require('./valueProperty');\n\n/**\n * This class serves as a view to read, write and listen to changes in an\n * object's value field. To do this we simply keep a pointer to the object and\n * it's associated data field that we are interested in. If no data field is\n * present this property will have an undefined value.\n */\nexport class ReferenceProperty extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.ReferenceProperty\n * @category Properties\n */\n constructor(in_params) {\n super(in_params);\n // default for this property type is an empty string\n this._data = '';\n }\n\n /**\n * Evaluates Reference properties as primitives.\n * @return {boolean} true since Reference properties are primitives.\n */\n isPrimitiveType() {\n return true;\n }\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n }\n\n /**\n * Resolves the referenced property\n *\n * @param {string|number|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids) && in_ids.length === 0) {\n return this;\n }\n\n // Since this is a reference property, we return undefined, if reference resolution is disabled\n if (in_options.referenceResolutionMode !== BaseProperty.REFERENCE_RESOLUTION.ALWAYS) {\n return undefined;\n }\n\n if (this.value === '') {\n return undefined;\n }\n\n if (this.getParent() === undefined) {\n return undefined;\n }\n var resolvedProperty = this.getParent().resolvePath(this.value,\n { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS });\n\n if (resolvedProperty !== undefined && _.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return resolvedProperty.get(in_ids, in_options);\n } else {\n return resolvedProperty;\n }\n }\n\n /**\n * Expand a path returning the value or property at the end.\n *\n * @param {string} in_path the path\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n * @return {property-properties.BaseProperty|undefined} resolved path\n * @throws if the path resolves to a primitive value\n * @throws if in_path is not a valid path\n */\n resolvePath(in_path, in_options) {\n if (in_options && in_options.referenceResolutionMode &&\n in_options.referenceResolutionMode === BaseProperty.REFERENCE_RESOLUTION.NEVER) {\n return undefined;\n }\n return AbstractStaticCollectionProperty.prototype.resolvePath.call(this, in_path, in_options);\n }\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid() {\n return this.value === '' || this.ref !== undefined;\n }\n\n /**\n * Sets the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if property is read only\n * @throws if in_value is defined, but is not a property or a string.\n */\n setValue(in_value) {\n this._checkIsNotReadOnly(true);\n var value = ReferenceProperty._convertInputToPath(in_value);\n // Forward the call to setValue\n ValueProperty.prototype.setValue.call(this, value);\n }\n\n /**\n * Sets the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if property is read only\n * @throws if in_value is defined but is not a property or a string.\n */\n set(...args) {\n return this.setValue(...args);\n }\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // path segments and array tokens are no longer automatically forwarded to the referenced node\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN ||\n in_segmentType === PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN) {\n return undefined;\n } else {\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n }\n\n // Define a property to simplify accessing the referenced path\n get ref() {\n return this.get.apply(this, arguments);\n }\n\n set ref(val) {\n this.set.call(this, val);\n }\n\n /**\n * Validates the input and does as much as possible to return a string representing a path.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - contains the property to be set or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @return {string} the path\n * @throws if in_value is defined, but is not a property or a string.\n */\n static _convertInputToPath(in_value) {\n var path;\n if (typeof in_value === 'string') {\n path = in_value;\n } else if (in_value === undefined) {\n path = '';\n } else if (in_value instanceof BaseProperty) {\n // TODO: Check whether this is still the correct path once we start to support repository references\n path = in_value.getAbsolutePath();\n } else if (in_value instanceof String) {\n path = String(in_value);\n } else {\n throw new Error(MSG.PROPERTY_OR_UNDEFINED + '(' + typeof in_value + ') ' + in_value);\n }\n return path;\n }\n}\nReferenceProperty.prototype._castFunctor = _castFunctors.String;\nReferenceProperty.prototype._typeid = \"Reference\";\n"]}
1
+ {"version":3,"file":"referenceProperty.js","sourceRoot":"","sources":["../../src/properties/referenceProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAEH,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACvF,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,g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AC;IAChB,CAAC;CACJ;AACD,iBAAiB,CAAC,SAAS,CAAC,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC;AAChE,iBAAiB,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Definition of the ReferenceProperty class\n */\n\nconst { PathHelper, TypeIdHelper } = require('@fluid-experimental/property-changeset');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst _ = require('lodash');\nconst { AbstractStaticCollectionProperty } = require('./abstractStaticCollectionProperty');\nconst { BaseProperty } = require('./baseProperty');\nconst { _castFunctors } = require('./primitiveTypeCasts');\nconst { ValueProperty } = require('./valueProperty');\n\n/**\n * This class serves as a view to read, write and listen to changes in an\n * object's value field. To do this we simply keep a pointer to the object and\n * it's associated data field that we are interested in. If no data field is\n * present this property will have an undefined value.\n */\nexport class ReferenceProperty extends ValueProperty {\n /**\n * @param {Object=} in_params - the parameters\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueProperty\n * @alias property-properties.ReferenceProperty\n * @category Properties\n */\n constructor(in_params) {\n super(in_params);\n // default for this property type is an empty string\n this._data = '';\n }\n\n /**\n * Evaluates Reference properties as primitives.\n * @return {boolean} true since Reference properties are primitives.\n */\n isPrimitiveType() {\n return true;\n }\n\n /**\n * Returns the typeid for the target of this reference\n *\n * Note: This is the type that is specified in the typeid of this reference and not the actual type\n * of the referenced object, which might inherit from that typeid.\n *\n * @return {string} The typeid of the nodes this reference may point to\n */\n getReferenceTargetTypeId() {\n return TypeIdHelper.extractReferenceTargetTypeIdFromReference(this.getTypeid());\n }\n\n /**\n * Resolves the referenced property\n *\n * @param {string|number|array<string|number>} in_ids the ID of the property or an array of IDs\n * if an array is passed, the .get function will be performed on each id in sequence\n * for example .get(['position','x']) is equivalent to .get('position').get('x').\n * If .get resolves to a ReferenceProperty, it will return the property that the ReferenceProperty\n * refers to.\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n * @return {property-properties.BaseProperty|undefined} The property object the reference points to or undefined if it\n * could not be resolved\n */\n get(in_ids, in_options) {\n in_options = in_options || {};\n in_options.referenceResolutionMode =\n in_options.referenceResolutionMode === undefined ? BaseProperty.REFERENCE_RESOLUTION.ALWAYS :\n in_options.referenceResolutionMode;\n\n if (_.isArray(in_ids) && in_ids.length === 0) {\n return this;\n }\n\n // Since this is a reference property, we return undefined, if reference resolution is disabled\n if (in_options.referenceResolutionMode !== BaseProperty.REFERENCE_RESOLUTION.ALWAYS) {\n return undefined;\n }\n\n if (this.value === '') {\n return undefined;\n }\n\n if (this.getParent() === undefined) {\n return undefined;\n }\n var resolvedProperty = this.getParent().resolvePath(this.value,\n { referenceResolutionMode: BaseProperty.REFERENCE_RESOLUTION.ALWAYS });\n\n if (resolvedProperty !== undefined && _.isArray(in_ids)) {\n // Forward handling of arrays to the BaseProperty function\n return resolvedProperty.get(in_ids, in_options);\n } else {\n return resolvedProperty;\n }\n }\n\n /**\n * Expand a path returning the value or property at the end.\n *\n * @param {string} in_path the path\n * @param {Object} in_options - parameter object\n * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS]\n * How should this function behave during reference resolution?\n * @return {property-properties.BaseProperty|undefined} resolved path\n * @throws if the path resolves to a primitive value\n * @throws if in_path is not a valid path\n */\n resolvePath(in_path, in_options) {\n if (in_options && in_options.referenceResolutionMode &&\n in_options.referenceResolutionMode === BaseProperty.REFERENCE_RESOLUTION.NEVER) {\n return undefined;\n }\n return AbstractStaticCollectionProperty.prototype.resolvePath.call(this, in_path, in_options);\n }\n\n /**\n * Checks whether the reference is valid. This is either the case when it is empty or when the referenced\n * property exists.\n *\n * @return {boolean} True if the reference is valid, otherwise false.\n */\n isReferenceValid() {\n return this.value === '' || this.ref !== undefined;\n }\n\n /**\n * Sets the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if property is read only\n * @throws if in_value is defined, but is not a property or a string.\n */\n setValue(in_value) {\n this._checkIsNotReadOnly(true);\n var value = ReferenceProperty._convertInputToPath(in_value);\n // Forward the call to setValue\n ValueProperty.prototype.setValue.call(this, value);\n }\n\n /**\n * Sets the reference to point to the given property object or to be equal to the given path string.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - The property to assign to the reference or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @throws if property is read only\n * @throws if in_value is defined but is not a property or a string.\n */\n set(...args) {\n return this.setValue(...args);\n }\n\n /**\n * @inheritdoc\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n // path segments and array tokens are no longer automatically forwarded to the referenced node\n if (in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN ||\n in_segmentType === PathHelper.TOKEN_TYPES.PATH_SEGMENT_TOKEN) {\n return undefined;\n } else {\n return AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(this, in_segment, in_segmentType);\n }\n }\n\n // Define a property to simplify accessing the referenced path\n get ref() {\n return this.get.apply(this, arguments);\n }\n\n set ref(val) {\n this.set.call(this, val);\n }\n\n /**\n * Validates the input and does as much as possible to return a string representing a path.\n *\n * @param {property-properties.BaseProperty|undefined|String} in_value - contains the property to be set or\n * the path to this property. If undefined is passed, the reference will be set to an empty string to\n * indicate an empty reference.\n * @return {string} the path\n * @throws if in_value is defined, but is not a property or a string.\n */\n static _convertInputToPath(in_value) {\n var path;\n if (typeof in_value === 'string') {\n path = in_value;\n } else if (in_value === undefined) {\n path = '';\n } else if (in_value instanceof BaseProperty) {\n // TODO: Check whether this is still the correct path once we start to support repository references\n path = in_value.getAbsolutePath();\n } else if (in_value instanceof String) {\n path = String(in_value);\n } else {\n throw new TypeError(MSG.PROPERTY_OR_UNDEFINED + '(' + typeof in_value + ') ' + in_value);\n }\n return path;\n }\n}\nReferenceProperty.prototype._castFunctor = _castFunctors.String;\nReferenceProperty.prototype._typeid = \"Reference\";\n"]}
@@ -402,7 +402,7 @@ export class Int64ArrayProperty extends Integer64ArrayProperty {
402
402
  */
403
403
  setRange(in_offset, in_array) {
404
404
  if (!_.isArray(in_array)) {
405
- throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'Int64ArrayProperty.setRange');
405
+ throw new TypeError(MSG.IN_ARRAY_NOT_ARRAY + 'Int64ArrayProperty.setRange');
406
406
  }
407
407
  var out_array = in_array.map((element) => {
408
408
  return _castFunctors.Int64(element);
@@ -485,7 +485,7 @@ export class Uint64ArrayProperty extends Integer64ArrayProperty {
485
485
  */
486
486
  setRange(in_offset, in_array) {
487
487
  if (!_.isArray(in_array)) {
488
- throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'Uint64ArrayProperty.setRange');
488
+ throw new TypeError(MSG.IN_ARRAY_NOT_ARRAY + 'Uint64ArrayProperty.setRange');
489
489
  }
490
490
  var out_array = in_array.map((element) => {
491
491
  return _castFunctors.Uint64(element);
@@ -1 +1 @@
1
- {"version":3,"file":"valueArrayProperty.js","sourceRoot":"","sources":["../../src/properties/valueArrayProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,4BAA4B;AAC5B;;GAEG;AAEH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EACF,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,KAAK,GACR,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACnD,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACjF,MAAM,EAAE,aAAa,EAAE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BAAoB,SAAQ,kBAAkB;IACvD;;;;;;;;OAQG;IACH,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,SAAS;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;YAChC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SAClC;IACL,CAAC;CACJ;AACD,mBAAmB,CAAC,SAAS,CAAC,OAAO,GAAG,QAAQ,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,kBAAkB;IACrD;;;;;;;;OAQG;IACH,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,SAAS;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;YAChC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;SACrC;IACL,CAAC;CACJ;AACD,iBAAiB,CAAC,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable new-cap */\n/**\n * @fileoverview Definition of the valuearray property class\n */\n\nconst _ = require('lodash');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst {\n BaseDataArray,\n UniversalDataArray,\n BoolDataArray,\n Uint64,\n Int64,\n} = require('@fluid-experimental/property-common');\nconst { Int64Property, Uint64Property } = require('../properties/intProperties');\nconst { _castFunctors } = require('./primitiveTypeCasts');\nconst { ArrayProperty } = require('./arrayProperty');\n\n/**\n * An array property which stores primitive values\n */\nexport class ValueArrayProperty extends ArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n * @constructor\n * @protected\n * @extends property-properties.ArrayProperty\n * @alias property-properties.ValueArrayProperty\n */\n constructor(in_params) {\n super(in_params, true);\n }\n\n /**\n * returns the value at in_position for a primitive array\n * @param {number} in_position the array index\n * @return {*} the value\n */\n _getValue(in_position) {\n return this._dataArrayRef.getValue(in_position);\n }\n\n /**\n * returns the array of primitive values.\n * @return {Array<*>} the array of values.\n * For example: ['string1', 'string2']\n */\n getValues() {\n var result = [];\n var ids = this.getIds();\n for (var i = 0; i < ids.length; i++) {\n result.push(this.get(ids[i]));\n }\n return result;\n }\n\n /**\n * Resolves a direct child node based on the given path segment\n *\n * @param {String} in_segment - The path segment to resolve\n * @param {property-properties.PathHelper.TOKEN_TYPES} in_segmentType - The type of segment in the tokenized path\n *\n * @return {property-properties.BaseProperty|undefined} The child property that has been resolved\n * @protected\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n return this.get(in_segment);\n }\n\n /**\n * Function to serialize special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on serialization. For supported types, we can just return the input here.\n *\n * @param {*} in_obj - The object to be serialized\n * @return {property-properties.SerializedChangeSet} the serialized object\n */\n _serializeValue(in_obj) {\n return in_obj;\n }\n\n /**\n * Function to serialize arrays of special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on serialization. For supported types, we can just return the input here.\n *\n * @param {Array} in_array - The array of special objects to be serialized\n * @return {Array<property-properties.SerializedChangeSet>} the serialized object\n */\n _serializeArray(in_array) {\n return in_array;\n }\n\n /**\n * Function to deserialize arrays of special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on deserialization. For supported types, we can just return the input here.\n *\n * @param {Array<property-properties.SerializedChangeSet>} in_serializedObj the serialized object\n * @return {Array} in_array - The array of special objects that were deserialized\n */\n _deserializeArray(in_serializedObj) {\n return in_serializedObj;\n }\n}\nValueArrayProperty.prototype._isPrimitive = true;\n\n/**\n * An ArrayProperty which stores Float32 values\n */\nexport class Float32ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Float32ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Float32Array, in_length);\n }\n}\nFloat32ArrayProperty.prototype._typeid = 'Float32';\n\n/**\n * An ArrayProperty which stores Float64 values\n */\nexport class Float64ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Float64ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Float64Array, in_length);\n }\n}\nFloat64ArrayProperty.prototype._typeid = 'Float64';\n\n/**\n * An ArrayProperty which stores Uint8 values\n */\nexport class Uint8ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Uint8ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Uint8Array, in_length);\n }\n}\nUint8ArrayProperty.prototype._typeid = 'Uint8';\n\n/**\n * An ArrayProperty which stores Int8 values\n *\n*/\nexport class Int8ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Int8ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Int8Array, in_length);\n }\n}\nInt8ArrayProperty.prototype._typeid = 'Int8';\n\n/**\n * An ArrayProperty which stores Uint16 values\n */\nexport class Uint16ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Uint16ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Uint16Array, in_length);\n }\n}\nUint16ArrayProperty.prototype._typeid = 'Uint16';\n\n/**\n * An ArrayProperty which stores Int16 values\n */\nexport class Int16ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Int16ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Int16Array, in_length);\n }\n}\nInt16ArrayProperty.prototype._typeid = 'Int16';\n\n/**\n * An ArrayProperty which stores Uint32 values\n */\nexport class Uint32ArrayProperty extends ValueArrayProperty {\n /** @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Uint32ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Uint32Array, in_length);\n }\n}\nUint32ArrayProperty.prototype._typeid = 'Uint32';\n\n/**\n * An ArrayProperty which stores Int32 values\n */\nexport class Int32ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Int32ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Int32Array, in_length);\n }\n}\nInt32ArrayProperty.prototype._typeid = 'Int32';\n\n/**\n * An ArrayProperty which stores Int64 values\n */\nexport class Integer64ArrayProperty extends ValueArrayProperty {\n /** @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Integer64ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Function to serialize special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on serialization. For supported types, we can just return the input here.\n *\n * @param {*} in_obj - The object to be serialized\n * @return {property-properties.SerializedChangeSet} the serialized object\n */\n _serializeValue(in_obj) {\n if (in_obj instanceof Int64 || in_obj instanceof Uint64) {\n return [in_obj.getValueLow(), in_obj.getValueHigh()];\n }\n return in_obj;\n }\n\n /**\n * Function to serialize arrays of special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on serialization. For supported types, we can just return the input here.\n *\n * @param {Array} in_array - The array of special objects to be serialized\n * @return {Array<property-properties.SerializedChangeSet>} the serialized object\n */\n _serializeArray(in_array) {\n var result = [];\n for (var i = 0; i < in_array.length; i++) {\n result.push(this._serializeValue(in_array[i]));\n }\n return result;\n }\n\n /**\n * Function to deserialize arrays of special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on deserialization. For supported types, we can just return the input here.\n *\n * @param {Array<property-properties.SerializedChangeSet>} in_serializedObj the serialized object\n * @return {Array} in_array - The array of special objects that were deserialized\n */\n _deserializeArray(in_serializedObj) {\n var result = [];\n for (var i = 0; i < in_serializedObj.length; i++) {\n result.push(this._deserializeValue(in_serializedObj[i]));\n }\n return result;\n }\n\n /**\n * @inheritdoc\n */\n _prettyPrint(indent, externalId, printFct) {\n printFct(indent + externalId + this.getId() + ' (Array of ' + this.getTypeid() + '): [');\n var childIndent = indent + ' ';\n var int64Prop;\n for (var i = 0; i < this._dataArrayGetLength(); i++) {\n // TODO: The 'toString()' function is defined on Integer64Property, so we need to create\n // such object to use it. It would be better to have it in Integer64.prototype.toString\n if (this._dataArrayGetValue(i) instanceof Int64) {\n int64Prop = new Int64Property({});\n } else {\n int64Prop = new Uint64Property({});\n }\n int64Prop.setValueLow(this._dataArrayGetValue(i).getValueLow());\n int64Prop.setValueHigh(this._dataArrayGetValue(i).getValueHigh());\n printFct(childIndent + i + ': ' + int64Prop);\n }\n printFct(indent + ']');\n }\n}\n/**\n * An ArrayProperty which stores Int64 values\n */\nexport class Int64ArrayProperty extends Integer64ArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.Integer64ArrayProperty\n * @alias property-properties.Int64ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Sets the array properties elements to the content of the given array\n * All changed elements must already exist. This will overwrite existing elements.\n * @param {number} in_offset target start index\n * @param {Array<*>|Array<property-properties.BaseProperty>} in_array contains the elements to be set\n * @throws if in_offset is not a number\n * @throws if in_offset is smaller than zero or higher than the length of the array\n */\n setRange(in_offset, in_array) {\n if (!_.isArray(in_array)) {\n throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'Int64ArrayProperty.setRange');\n }\n var out_array = in_array.map((element) => {\n return _castFunctors.Int64(element);\n });\n ArrayProperty.prototype.setRange.call(this, in_offset, out_array);\n }\n\n /**\n * Inserts the content of a given array into the array property\n * It will not overwrite the existing values but push them to the right instead.\n * E.g. [1, 2, 3] .insertRange(1, [9, 8]) => [1, 9, 8, 2, 3]\n * @param {number} in_offset target index\n * @param {Array<*>} in_array the array to be inserted\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number.\n * @throws if trying to insert a property that already has a parent.\n * @throws if tyring to modify a referenced property.\n */\n insertRange(in_offset, in_array) {\n var out_array = in_array.map((element) => {\n return _castFunctors.Int64(element);\n });\n ArrayProperty.prototype.insertRange.call(this, in_offset, out_array);\n }\n\n /**\n * Specialized function to deserialize Int64 primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on deserialization. For supported types, we can just return the input here.\n *\n * @param {property-properties.SerializedChangeSet} in_serializedObj - The object to be deserialized\n * @return {Int64} the deserialized value\n */\n _deserializeValue(in_serializedObj) {\n return new Int64(in_serializedObj[0], in_serializedObj[1]);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, new Int64());\n }\n }\n}\nInt64ArrayProperty.prototype._typeid = 'Int64';\n\n/**\n * An ArrayProperty which stores Uint64 values\n */\nexport class Uint64ArrayProperty extends Integer64ArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.Integer64ArrayProperty\n * @alias property-properties.Uint64ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Specialized function to deserialize Uint64 primitive types.\n * Some primitive types (e.g. Uint64, which is not natively supported by javascript) require\n * special treatment on deserialization. For supported types, we can just return the input here.\n *\n * @param {property-properties.SerializedChangeSet} in_serializedObj - The object to be deserialized\n * @return {Uint64} the deserialized value\n */\n _deserializeValue(in_serializedObj) {\n return new Uint64(in_serializedObj[0], in_serializedObj[1]);\n }\n\n /**\n * Sets the array properties elements to the content of the given array\n * All changed elements must already exist. This will overwrite existing elements.\n * @param {number} in_offset target start index\n * @param {Array<*>|Array<property-properties.BaseProperty>} in_array contains the elements to be set\n * @throws if in_offset is not a number\n * @throws if in_offset is smaller than zero or higher than the length of the array\n */\n setRange(in_offset, in_array) {\n if (!_.isArray(in_array)) {\n throw new Error(MSG.IN_ARRAY_NOT_ARRAY + 'Uint64ArrayProperty.setRange');\n }\n var out_array = in_array.map((element) => {\n return _castFunctors.Uint64(element);\n });\n ArrayProperty.prototype.setRange.call(this, in_offset, out_array);\n }\n\n /**\n * Inserts the content of a given array into the array property\n * It will not overwrite the existing values but push them to the right instead.\n * E.g. [1, 2, 3] .insertRange(1, [9, 8]) => [1, 9, 8, 2, 3]\n * @param {number} in_offset target index\n * @param {Array<*>} in_array the array to be inserted\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number.\n * @throws if trying to insert a property that already has a parent.\n * @throws if tyring to modify a referenced property.\n */\n insertRange(in_offset, in_array) {\n var out_array = in_array.map((element) => {\n return _castFunctors.Uint64(element);\n });\n ArrayProperty.prototype.insertRange.call(this, in_offset, out_array);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, new Uint64());\n }\n }\n}\nUint64ArrayProperty.prototype._typeid = 'Uint64';\n\n/**\n * An ArrayProperty which stores String values\n */\nexport class StringArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.StringArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, '');\n }\n }\n}\nStringArrayProperty.prototype._typeid = 'String';\n\n/**\n * An ArrayProperty which stores Boolean values\n */\nexport class BoolArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.BoolArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params, Array, true);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BoolDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, false);\n }\n }\n}\nBoolArrayProperty.prototype._typeid = 'Bool';\n"]}
1
+ {"version":3,"file":"valueArrayProperty.js","sourceRoot":"","sources":["../../src/properties/valueArrayProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,4BAA4B;AAC5B;;GAEG;AAEH,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC,SAAS,CAAC;AACzE,MAAM,EACF,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,KAAK,GACR,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACnD,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AACjF,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC1D,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,aAAa;IACjD;;;;;;OAMG;IACH,YAAY,SAAS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,SAAS,CAAC,CAAC;QACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;YAChC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SAClC;IACL,CAAC;CACJ;AACD,mBAAmB,CAAC,SAAS,CAAC,OAAO,GAAG,QAAQ,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,kBAAkB;IACrD;;;;;;;;OAQG;IACH,YAAY,SAAS;QACjB,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,SAAS;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;YAChC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;SACrC;IACL,CAAC;CACJ;AACD,iBAAiB,CAAC,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable new-cap */\n/**\n * @fileoverview Definition of the valuearray property class\n */\n\nconst _ = require('lodash');\nconst { MSG } = require('@fluid-experimental/property-common').constants;\nconst {\n BaseDataArray,\n UniversalDataArray,\n BoolDataArray,\n Uint64,\n Int64,\n} = require('@fluid-experimental/property-common');\nconst { Int64Property, Uint64Property } = require('../properties/intProperties');\nconst { _castFunctors } = require('./primitiveTypeCasts');\nconst { ArrayProperty } = require('./arrayProperty');\n\n/**\n * An array property which stores primitive values\n */\nexport class ValueArrayProperty extends ArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n * @constructor\n * @protected\n * @extends property-properties.ArrayProperty\n * @alias property-properties.ValueArrayProperty\n */\n constructor(in_params) {\n super(in_params, true);\n }\n\n /**\n * returns the value at in_position for a primitive array\n * @param {number} in_position the array index\n * @return {*} the value\n */\n _getValue(in_position) {\n return this._dataArrayRef.getValue(in_position);\n }\n\n /**\n * returns the array of primitive values.\n * @return {Array<*>} the array of values.\n * For example: ['string1', 'string2']\n */\n getValues() {\n var result = [];\n var ids = this.getIds();\n for (var i = 0; i < ids.length; i++) {\n result.push(this.get(ids[i]));\n }\n return result;\n }\n\n /**\n * Resolves a direct child node based on the given path segment\n *\n * @param {String} in_segment - The path segment to resolve\n * @param {property-properties.PathHelper.TOKEN_TYPES} in_segmentType - The type of segment in the tokenized path\n *\n * @return {property-properties.BaseProperty|undefined} The child property that has been resolved\n * @protected\n */\n _resolvePathSegment(in_segment, in_segmentType) {\n return this.get(in_segment);\n }\n\n /**\n * Function to serialize special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on serialization. For supported types, we can just return the input here.\n *\n * @param {*} in_obj - The object to be serialized\n * @return {property-properties.SerializedChangeSet} the serialized object\n */\n _serializeValue(in_obj) {\n return in_obj;\n }\n\n /**\n * Function to serialize arrays of special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on serialization. For supported types, we can just return the input here.\n *\n * @param {Array} in_array - The array of special objects to be serialized\n * @return {Array<property-properties.SerializedChangeSet>} the serialized object\n */\n _serializeArray(in_array) {\n return in_array;\n }\n\n /**\n * Function to deserialize arrays of special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on deserialization. For supported types, we can just return the input here.\n *\n * @param {Array<property-properties.SerializedChangeSet>} in_serializedObj the serialized object\n * @return {Array} in_array - The array of special objects that were deserialized\n */\n _deserializeArray(in_serializedObj) {\n return in_serializedObj;\n }\n}\nValueArrayProperty.prototype._isPrimitive = true;\n\n/**\n * An ArrayProperty which stores Float32 values\n */\nexport class Float32ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Float32ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Float32Array, in_length);\n }\n}\nFloat32ArrayProperty.prototype._typeid = 'Float32';\n\n/**\n * An ArrayProperty which stores Float64 values\n */\nexport class Float64ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Float64ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Float64Array, in_length);\n }\n}\nFloat64ArrayProperty.prototype._typeid = 'Float64';\n\n/**\n * An ArrayProperty which stores Uint8 values\n */\nexport class Uint8ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Uint8ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Uint8Array, in_length);\n }\n}\nUint8ArrayProperty.prototype._typeid = 'Uint8';\n\n/**\n * An ArrayProperty which stores Int8 values\n *\n*/\nexport class Int8ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Int8ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Int8Array, in_length);\n }\n}\nInt8ArrayProperty.prototype._typeid = 'Int8';\n\n/**\n * An ArrayProperty which stores Uint16 values\n */\nexport class Uint16ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Uint16ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Uint16Array, in_length);\n }\n}\nUint16ArrayProperty.prototype._typeid = 'Uint16';\n\n/**\n * An ArrayProperty which stores Int16 values\n */\nexport class Int16ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Int16ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Int16Array, in_length);\n }\n}\nInt16ArrayProperty.prototype._typeid = 'Int16';\n\n/**\n * An ArrayProperty which stores Uint32 values\n */\nexport class Uint32ArrayProperty extends ValueArrayProperty {\n /** @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Uint32ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Uint32Array, in_length);\n }\n}\nUint32ArrayProperty.prototype._typeid = 'Uint32';\n\n/**\n * An ArrayProperty which stores Int32 values\n */\nexport class Int32ArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Int32ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BaseDataArray(Int32Array, in_length);\n }\n}\nInt32ArrayProperty.prototype._typeid = 'Int32';\n\n/**\n * An ArrayProperty which stores Int64 values\n */\nexport class Integer64ArrayProperty extends ValueArrayProperty {\n /** @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.Integer64ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Function to serialize special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on serialization. For supported types, we can just return the input here.\n *\n * @param {*} in_obj - The object to be serialized\n * @return {property-properties.SerializedChangeSet} the serialized object\n */\n _serializeValue(in_obj) {\n if (in_obj instanceof Int64 || in_obj instanceof Uint64) {\n return [in_obj.getValueLow(), in_obj.getValueHigh()];\n }\n return in_obj;\n }\n\n /**\n * Function to serialize arrays of special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on serialization. For supported types, we can just return the input here.\n *\n * @param {Array} in_array - The array of special objects to be serialized\n * @return {Array<property-properties.SerializedChangeSet>} the serialized object\n */\n _serializeArray(in_array) {\n var result = [];\n for (var i = 0; i < in_array.length; i++) {\n result.push(this._serializeValue(in_array[i]));\n }\n return result;\n }\n\n /**\n * Function to deserialize arrays of special primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on deserialization. For supported types, we can just return the input here.\n *\n * @param {Array<property-properties.SerializedChangeSet>} in_serializedObj the serialized object\n * @return {Array} in_array - The array of special objects that were deserialized\n */\n _deserializeArray(in_serializedObj) {\n var result = [];\n for (var i = 0; i < in_serializedObj.length; i++) {\n result.push(this._deserializeValue(in_serializedObj[i]));\n }\n return result;\n }\n\n /**\n * @inheritdoc\n */\n _prettyPrint(indent, externalId, printFct) {\n printFct(indent + externalId + this.getId() + ' (Array of ' + this.getTypeid() + '): [');\n var childIndent = indent + ' ';\n var int64Prop;\n for (var i = 0; i < this._dataArrayGetLength(); i++) {\n // TODO: The 'toString()' function is defined on Integer64Property, so we need to create\n // such object to use it. It would be better to have it in Integer64.prototype.toString\n if (this._dataArrayGetValue(i) instanceof Int64) {\n int64Prop = new Int64Property({});\n } else {\n int64Prop = new Uint64Property({});\n }\n int64Prop.setValueLow(this._dataArrayGetValue(i).getValueLow());\n int64Prop.setValueHigh(this._dataArrayGetValue(i).getValueHigh());\n printFct(childIndent + i + ': ' + int64Prop);\n }\n printFct(indent + ']');\n }\n}\n/**\n * An ArrayProperty which stores Int64 values\n */\nexport class Int64ArrayProperty extends Integer64ArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.Integer64ArrayProperty\n * @alias property-properties.Int64ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Sets the array properties elements to the content of the given array\n * All changed elements must already exist. This will overwrite existing elements.\n * @param {number} in_offset target start index\n * @param {Array<*>|Array<property-properties.BaseProperty>} in_array contains the elements to be set\n * @throws if in_offset is not a number\n * @throws if in_offset is smaller than zero or higher than the length of the array\n */\n setRange(in_offset, in_array) {\n if (!_.isArray(in_array)) {\n throw new TypeError(MSG.IN_ARRAY_NOT_ARRAY + 'Int64ArrayProperty.setRange');\n }\n var out_array = in_array.map((element) => {\n return _castFunctors.Int64(element);\n });\n ArrayProperty.prototype.setRange.call(this, in_offset, out_array);\n }\n\n /**\n * Inserts the content of a given array into the array property\n * It will not overwrite the existing values but push them to the right instead.\n * E.g. [1, 2, 3] .insertRange(1, [9, 8]) => [1, 9, 8, 2, 3]\n * @param {number} in_offset target index\n * @param {Array<*>} in_array the array to be inserted\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number.\n * @throws if trying to insert a property that already has a parent.\n * @throws if tyring to modify a referenced property.\n */\n insertRange(in_offset, in_array) {\n var out_array = in_array.map((element) => {\n return _castFunctors.Int64(element);\n });\n ArrayProperty.prototype.insertRange.call(this, in_offset, out_array);\n }\n\n /**\n * Specialized function to deserialize Int64 primitive types.\n * Some primitive types (e.g. Int64, which is not natively supported by javascript) require\n * special treatment on deserialization. For supported types, we can just return the input here.\n *\n * @param {property-properties.SerializedChangeSet} in_serializedObj - The object to be deserialized\n * @return {Int64} the deserialized value\n */\n _deserializeValue(in_serializedObj) {\n return new Int64(in_serializedObj[0], in_serializedObj[1]);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, new Int64());\n }\n }\n}\nInt64ArrayProperty.prototype._typeid = 'Int64';\n\n/**\n * An ArrayProperty which stores Uint64 values\n */\nexport class Uint64ArrayProperty extends Integer64ArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.Integer64ArrayProperty\n * @alias property-properties.Uint64ArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Specialized function to deserialize Uint64 primitive types.\n * Some primitive types (e.g. Uint64, which is not natively supported by javascript) require\n * special treatment on deserialization. For supported types, we can just return the input here.\n *\n * @param {property-properties.SerializedChangeSet} in_serializedObj - The object to be deserialized\n * @return {Uint64} the deserialized value\n */\n _deserializeValue(in_serializedObj) {\n return new Uint64(in_serializedObj[0], in_serializedObj[1]);\n }\n\n /**\n * Sets the array properties elements to the content of the given array\n * All changed elements must already exist. This will overwrite existing elements.\n * @param {number} in_offset target start index\n * @param {Array<*>|Array<property-properties.BaseProperty>} in_array contains the elements to be set\n * @throws if in_offset is not a number\n * @throws if in_offset is smaller than zero or higher than the length of the array\n */\n setRange(in_offset, in_array) {\n if (!_.isArray(in_array)) {\n throw new TypeError(MSG.IN_ARRAY_NOT_ARRAY + 'Uint64ArrayProperty.setRange');\n }\n var out_array = in_array.map((element) => {\n return _castFunctors.Uint64(element);\n });\n ArrayProperty.prototype.setRange.call(this, in_offset, out_array);\n }\n\n /**\n * Inserts the content of a given array into the array property\n * It will not overwrite the existing values but push them to the right instead.\n * E.g. [1, 2, 3] .insertRange(1, [9, 8]) => [1, 9, 8, 2, 3]\n * @param {number} in_offset target index\n * @param {Array<*>} in_array the array to be inserted\n * @throws if in_offset is smaller than zero, larger than the length of the array or not a number.\n * @throws if trying to insert a property that already has a parent.\n * @throws if tyring to modify a referenced property.\n */\n insertRange(in_offset, in_array) {\n var out_array = in_array.map((element) => {\n return _castFunctors.Uint64(element);\n });\n ArrayProperty.prototype.insertRange.call(this, in_offset, out_array);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, new Uint64());\n }\n }\n}\nUint64ArrayProperty.prototype._typeid = 'Uint64';\n\n/**\n * An ArrayProperty which stores String values\n */\nexport class StringArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.StringArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new UniversalDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, '');\n }\n }\n}\nStringArrayProperty.prototype._typeid = 'String';\n\n/**\n * An ArrayProperty which stores Boolean values\n */\nexport class BoolArrayProperty extends ValueArrayProperty {\n /**\n * @param {Object} in_params - Input parameters for property creation\n *\n * @constructor\n * @protected\n * @extends property-properties.ValueArrayProperty\n * @alias property-properties.BoolArrayProperty\n * @category Arrays\n */\n constructor(in_params) {\n super(in_params, Array, true);\n }\n\n /**\n * Creates and initializes the data array\n * @param {Number} in_length the initial length of the array\n */\n _dataArrayCreate(in_length) {\n this._dataArrayRef = new BoolDataArray(in_length);\n for (var i = 0; i < in_length; i++) {\n this._dataArraySetValue(i, false);\n }\n }\n}\nBoolArrayProperty.prototype._typeid = 'Bool';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/property-properties",
3
- "version": "1.0.0",
3
+ "version": "1.1.0-76254",
4
4
  "description": "definitions of properties",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -61,8 +61,8 @@
61
61
  "temp-directory": "nyc/.nyc_output"
62
62
  },
63
63
  "dependencies": {
64
- "@fluid-experimental/property-changeset": "^1.0.0",
65
- "@fluid-experimental/property-common": "^1.0.0",
64
+ "@fluid-experimental/property-changeset": "1.1.0-76254",
65
+ "@fluid-experimental/property-common": "1.1.0-76254",
66
66
  "ajv": "7.1.1",
67
67
  "async": "^3.2.0",
68
68
  "fastest-json-copy": "^1.0.1",
@@ -72,8 +72,8 @@
72
72
  "underscore": "^1.12.1"
73
73
  },
74
74
  "devDependencies": {
75
- "@fluidframework/build-common": "^0.23.0",
76
- "@fluidframework/mocha-test-setup": "^1.0.0",
75
+ "@fluidframework/build-common": "^0.24.0-0",
76
+ "@fluidframework/mocha-test-setup": "1.1.0-76254",
77
77
  "@types/mocha": "^9.1.1",
78
78
  "chai": "^4.2.0",
79
79
  "concurrently": "^6.2.0",