@fluid-experimental/property-properties 2.81.1 → 2.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/properties/indexedCollectionBaseProperty.js +1 -1
- package/dist/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/dist/properties/mapProperty.d.ts +4 -2
- package/dist/properties/mapProperty.d.ts.map +1 -1
- package/dist/properties/mapProperty.js +4 -2
- package/dist/properties/mapProperty.js.map +1 -1
- package/dist/properties/referenceMapProperty.d.ts +4 -2
- package/dist/properties/referenceMapProperty.d.ts.map +1 -1
- package/dist/properties/referenceMapProperty.js +4 -2
- package/dist/properties/referenceMapProperty.js.map +1 -1
- package/dist/properties/setProperty.d.ts +4 -2
- package/dist/properties/setProperty.d.ts.map +1 -1
- package/dist/properties/setProperty.js +4 -2
- package/dist/properties/setProperty.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/lib/properties/indexedCollectionBaseProperty.js +1 -1
- package/lib/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/lib/properties/mapProperty.d.ts +4 -2
- package/lib/properties/mapProperty.d.ts.map +1 -1
- package/lib/properties/mapProperty.js +4 -2
- package/lib/properties/mapProperty.js.map +1 -1
- package/lib/properties/referenceMapProperty.d.ts +4 -2
- package/lib/properties/referenceMapProperty.d.ts.map +1 -1
- package/lib/properties/referenceMapProperty.js +4 -2
- package/lib/properties/referenceMapProperty.js.map +1 -1
- package/lib/properties/setProperty.d.ts +4 -2
- package/lib/properties/setProperty.d.ts.map +1 -1
- package/lib/properties/setProperty.js +4 -2
- package/lib/properties/setProperty.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setProperty.js","sourceRoot":"","sources":["../../src/properties/setProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AAEH,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,wCAA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AAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1E,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACH,UAAU;QACT,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,SAAS;QACR,IAAI,KAAK,GAAG,6BAA6B,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,KAAK;QACJ,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE;YACjC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,WAAW,CAAC,SAAS,CAAC,OAAO,GAAG,eAAe,CAAC;AAChD,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 set property class\n */\n\nconst { PathHelper, TypeIdHelper } = require(\"@fluid-experimental/property-changeset\");\nconst { MSG } = require(\"@fluid-experimental/property-common\").constants;\nconst _ = require(\"lodash\");\n\nconst { AbstractStaticCollectionProperty } = require(\"./abstractStaticCollectionProperty\");\nconst { BaseProperty } = require(\"./baseProperty\");\nconst { IndexedCollectionBaseProperty } = require(\"./indexedCollectionBaseProperty\");\nconst { LazyLoadedProperties: Property } = require(\"./lazyLoadedProperties\");\n\nvar PATH_TOKENS = BaseProperty.PATH_TOKENS;\n\n/**\n * A SetProperty is a collection class that can contain an unordered set of properties. These properties\n * must derive from NamedProperty and their URN is used to identify them within the set.\n * @internal\n */\nexport class SetProperty extends IndexedCollectionBaseProperty {\n\t/**\n\t * @param {Object} in_params - Input parameters for property creation\n\t * @param {string|undefined} in_scope - The scope in which the map typeid is defined\n\t *\n\t * @constructor\n\t * @protected\n\t * @extends property-properties.IndexedCollectionBaseProperty\n\t * @alias property-properties.SetProperty\n\t * @category Other Collections\n\t */\n\tconstructor(in_params, in_scope) {\n\t\tsuper(in_params);\n\n\t\tthis._scope = in_scope;\n\n\t\t/** Contains the actual entries of the set, indexed by their GUID */\n\t\tthis._dynamicChildren = {};\n\t}\n\n\t// A set property falls back to NamedProperty, if none is specified\n\n\t/**\n\t * Is this property a leaf node with regard to flattening?\n\t *\n\t * TODO: Which semantics should flattening have? It stops at primitive types and collections?\n\t *\n\t * @return {boolean} Is it a leaf with regard to flattening?\n\t */\n\t_isFlattenLeaf() {\n\t\treturn true;\n\t}\n\n\t/**\n\t * Returns an object with all the nested values contained in this property.\n\t * @return {object} An object representing the values of your property.\n\t * For example:\n\t *\n\t * ```json\n\t * {\n\t * position: {\n\t * x: 2,\n\t * y: 5\n\t * }\n\t * }\n\t * ```\n\t */\n\tgetValues() {\n\t\tvar ids = this.getIds();\n\t\tvar result = {};\n\t\tfor (var i = 0; i < ids.length; i++) {\n\t\t\tvar child = this.get(ids[i]);\n\t\t\tresult[ids[i]] =\n\t\t\t\tchild instanceof Property.ValueProperty || child instanceof Property.StringProperty\n\t\t\t\t\t? this.get(ids[i]).getValue()\n\t\t\t\t\t: child.getValues();\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns the full property type identifier for the ChangeSet including the enum type id\n\t * @param {boolean} [in_hideCollection=false] - If true the collection type (if applicable) will be omitted\n\t * @return {string} The typeid\n\t */\n\tgetFullTypeid(in_hideCollection = false) {\n\t\treturn in_hideCollection\n\t\t\t? this._typeid\n\t\t\t: TypeIdHelper.createSerializationTypeId(this._typeid, \"set\");\n\t}\n\n\t/**\n\t * Returns the path segment for a child\n\t *\n\t * @param {property-properties.NamedProperty} in_childNode - The child for which the path is returned\n\t *\n\t * @return {string} The path segment to resolve the child property under this property\n\t * @protected\n\t */\n\t_getPathSegmentForChildNode(in_childNode) {\n\t\treturn \"[\" + in_childNode.getGuid() + \"]\";\n\t}\n\n\t/**\n\t * Resolves a direct child node based on the given path segment\n\t *\n\t * @param {String} in_segment - The path segment to resolve\n\t * @param {property-properties.PathHelper.TOKEN_TYPES} in_segmentType - The type of segment in the tokenized path\n\t *\n\t * @return {BaseProperty | undefined} The child property that has been resolved\n\t * @protected\n\t */\n\t_resolvePathSegment(in_segment, in_segmentType) {\n\t\t// Base Properties only support paths separated via dots\n\t\treturn in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN\n\t\t\t? this._dynamicChildren[in_segment]\n\t\t\t: AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(\n\t\t\t\t\tthis,\n\t\t\t\t\tin_segment,\n\t\t\t\t\tin_segmentType,\n\t\t\t\t);\n\t}\n\n\t/**\n\t * Inserts a property into the set\n\t *\n\t * @param {property-properties.NamedProperty} in_property - The property to insert\n\t * @throws if trying to insert non-named properties\n\t * @throws if trying to insert a property that has a parent\n\t * @throws if a property already exists with the same guid as in_property\n\t */\n\tinsert(in_property) {\n\t\tif (in_property instanceof AbstractStaticCollectionProperty && in_property.has(\"guid\")) {\n\t\t\tvar guid = in_property.getGuid();\n\t\t\tthis._insert(guid, in_property, true);\n\t\t} else {\n\t\t\tthrow new Error(MSG.CANT_INSERT_NON_NAMED_PROPERTIES);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a property to the set.\n\t *\n\t * - If the property's key exists, the entry is replaced with new one.\n\t *\n\t * - If the property's key does not exist, the property is appended.\n\t *\n\t * @param {NamedProperty|NamedNodeProperty|Object} in_property - The property to add to the list.\n\t * @return { BaseProperty }\n\t */\n\tset(in_property) {\n\t\tthis._checkIsNotReadOnly(true);\n\n\t\tif (in_property instanceof AbstractStaticCollectionProperty && in_property.has(\"guid\")) {\n\t\t\tvar guid = in_property.getGuid();\n\t\t\tif (this.has(guid)) {\n\t\t\t\tthis.remove(guid);\n\t\t\t}\n\n\t\t\tthis.insert(in_property);\n\t\t} else {\n\t\t\tthrow new Error(MSG.CANT_INSERT_NON_NAMED_PROPERTIES);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the given property from the set\n\t *\n\t * @param {property-properties.NamedProperty|string} in_entry - The property or its URN to remove from the set\n\t * @return {property-properties.NamedProperty} the property that was removed.\n\t * @throws if trying to remove an entry that does not exist\n\t */\n\tremove(in_entry) {\n\t\tif (_.isString(in_entry)) {\n\t\t\tvar item = this.get(in_entry);\n\t\t\tthis._removeByKey(in_entry, true);\n\t\t\treturn item;\n\t\t} else {\n\t\t\tthis._removeByKey(in_entry.getGuid(), true);\n\t\t\treturn in_entry;\n\t\t}\n\t}\n\n\t/**\n\t * Returns an Object with all the entries of the set.\n\t *\n\t * WARNING: This is a direct access to the internal data-structure and the collection MUST NOT be modified.\n\t * It is read only for fast access and iteration. Insertion and deletion MUST be done via the insert and\n\t * remove functions of this class.\n\t *\n\t * @return {Object<String, property-properties.NamedProperty>} The map with all entries in the set.\n\t */\n\tgetEntriesReadOnly() {\n\t\treturn this._dynamicChildren;\n\t}\n\n\t/**\n\t * Returns the name of all the sub-properties of this property.\n\t *\n\t * @return {Array.<string>} An array of all the property ids\n\t */\n\tgetIds() {\n\t\treturn Object.keys(this._dynamicChildren);\n\t}\n\n\t/**\n\t * Returns the collection entry with the given ID\n\t *\n\t * @param {string | Array<string | number>} in_ids - key of the entry to return or an array of keys if an array is\n\t * passed, the .get function will be performed on each id in sequence for example .get(['position','x']) is\n\t * equivalent to .get('position').get('x'). If .get resolves to a ReferenceProperty, it will return the property\n\t * that the ReferenceProperty refers to.\n\t * @param {Object} in_options - parameter object\n\t * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS] - How\n\t * should this function behave during reference resolution?\n\t *\n\t * @return {BaseProperty | undefined} The entry in the collection or undefined if none could be\n\t * found\n\t */\n\tget(in_ids, in_options) {\n\t\tif (_.isArray(in_ids)) {\n\t\t\t// Forward handling of arrays to the BaseProperty function\n\t\t\treturn AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n\t\t} else {\n\t\t\tvar prop = this;\n\t\t\tin_options = in_options || {};\n\t\t\tin_options.referenceResolutionMode =\n\t\t\t\tin_options.referenceResolutionMode === undefined\n\t\t\t\t\t? BaseProperty.REFERENCE_RESOLUTION.ALWAYS\n\t\t\t\t\t: in_options.referenceResolutionMode;\n\t\t\tswitch (in_ids) {\n\t\t\t\tcase PATH_TOKENS.ROOT: {\n\t\t\t\t\tprop = prop.getRoot();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase PATH_TOKENS.UP: {\n\t\t\t\t\tprop = prop.getParent();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase PATH_TOKENS.REF: {\n\t\t\t\t\tthrow new Error(MSG.NO_GET_DEREFERENCE_ONLY);\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tprop = prop._dynamicChildren[in_ids];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn prop;\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether a property with the given name exists\n\t *\n\t * @param {string} in_id - Name of the property\n\t * @return {boolean} True if the property exists, otherwise false.\n\t */\n\thas(in_id) {\n\t\treturn this._dynamicChildren[in_id] !== undefined;\n\t}\n\n\t/**\n\t * Adds a list of properties to the set.\n\t * See {@link SetProperty.setValues}\n\t * @param {NamedProperty[]|NamedNodeProperty[]|Object[]} in_properties - The list of properties to add to the list\n\t * @param {Boolean} in_typed - If the set's items have a typeid and a value then create the\n\t * properties with that typeid, else use the set's typeid (support polymorphic items).\n\t * @private\n\t */\n\t_setValuesInternal(in_properties, in_typed) {\n\t\tthis._checkIsNotReadOnly(true);\n\n\t\tvar that = this;\n\t\t_.each(in_properties, function (property) {\n\t\t\tif (property instanceof BaseProperty) {\n\t\t\t\tthat.set(property);\n\t\t\t} else {\n\t\t\t\t// If value is a JSON object (i.e: passed through a default value), create the property and add it to the set.\n\t\t\t\tif (in_typed) {\n\t\t\t\t\tthat.set(\n\t\t\t\t\t\tProperty.PropertyFactory._createProperty(\n\t\t\t\t\t\t\tproperty.typeid || that._typeid,\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\tproperty.value,\n\t\t\t\t\t\t\tthat._getScope(),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthat.set(\n\t\t\t\t\t\tProperty.PropertyFactory._createProperty(\n\t\t\t\t\t\t\tthat._typeid,\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\tthat._getScope(),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Adds a list of properties to the set. See {@link SetProperty.setValues}\n\t * @param {NamedProperty[]|NamedNodeProperty[]|Object[]} in_properties - The list of properties to add to the list\n\t * @param {boolean} in_typed - If the set's items have a typeid and a value then create the properties with that\n\t * typeid, else use the set's typeid (support polymorphic items).\n\t * @param {boolean} in_initial - Whether we are setting default/initial values or if the function is called directly\n\t * with the values to set.\n\t * @override\n\t */\n\t_setValues(in_properties, in_typed, in_initial) {\n\t\tif (in_initial) {\n\t\t\tthis.clear();\n\t\t}\n\n\t\tthis._setValuesInternal(in_properties, in_typed);\n\t}\n\n\t/**\n\t * Adds a list of properties to the set.\n\t * - If the property's key exists, the entry is replaced with new one.\n\t * - If the property's key does not exist, the property is appended.\n\t * @param {NamedProperty[]|NamedNodeProperty[]|Object[]} in_properties - The list of properties to add to the list\n\t * @override\n\t */\n\tsetValues(in_properties) {\n\t\tvar checkoutView = this._getCheckoutView();\n\t\tif (checkoutView !== undefined) {\n\t\t\tcheckoutView.pushNotificationDelayScope();\n\t\t\tSetProperty.prototype._setValues.call(this, in_properties, false, false);\n\t\t\tcheckoutView.popNotificationDelayScope();\n\t\t} else {\n\t\t\tSetProperty.prototype._setValues.call(this, in_properties, false, false);\n\t\t}\n\t}\n\n\t/**\n\t * Returns all entries of the set as an array.\n\t *\n\t * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n\t *\n\t * @return {Array.<property-properties.NamedProperty>} Array with all entries of the set. This array is a shallow copy\n\t * which can be modified by the caller without effects on the set.\n\t */\n\tgetAsArray() {\n\t\treturn _.values(this._dynamicChildren);\n\t}\n\n\t/**\n\t * Get the scope to which this property belongs to.\n\t * @return {string|undefined} The guid representing the scope in which the\n\t * set belongs to. If there is a workspace scope return it, else return the scope of this set.\n\t * @override\n\t * @private\n\t */\n\t_getScope() {\n\t\tvar scope = IndexedCollectionBaseProperty.prototype._getScope.call(this);\n\n\t\treturn scope !== undefined ? scope : this._scope;\n\t}\n\n\t/**\n\t * Delete all values from Set\n\t */\n\tclear() {\n\t\tvar that = this;\n\t\tthis.getIds().forEach(function (id) {\n\t\t\tthat.remove(id);\n\t\t});\n\t}\n}\n\nSetProperty.prototype._typeid = \"NamedProperty\";\nSetProperty.prototype._context = \"set\";\n"]}
|
|
1
|
+
{"version":3,"file":"setProperty.js","sourceRoot":"","sources":["../../src/properties/setProperty.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;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;AAE5B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAC3F,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,gBAAgB,CA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AAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,KAAK;QACJ,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE;YACjC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AAED,WAAW,CAAC,SAAS,CAAC,OAAO,GAAG,eAAe,CAAC;AAChD,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 set property class\n */\n\nconst { PathHelper, TypeIdHelper } = require(\"@fluid-experimental/property-changeset\");\nconst { MSG } = require(\"@fluid-experimental/property-common\").constants;\nconst _ = require(\"lodash\");\n\nconst { AbstractStaticCollectionProperty } = require(\"./abstractStaticCollectionProperty\");\nconst { BaseProperty } = require(\"./baseProperty\");\nconst { IndexedCollectionBaseProperty } = require(\"./indexedCollectionBaseProperty\");\nconst { LazyLoadedProperties: Property } = require(\"./lazyLoadedProperties\");\n\nvar PATH_TOKENS = BaseProperty.PATH_TOKENS;\n\n/**\n * A SetProperty is a collection class that can contain an unordered set of properties. These properties\n * must derive from NamedProperty and their URN is used to identify them within the set.\n * @internal\n */\nexport class SetProperty extends IndexedCollectionBaseProperty {\n\t/**\n\t * @param {Object} in_params - Input parameters for property creation\n\t * @param {string|undefined} in_scope - The scope in which the map typeid is defined\n\t *\n\t * @constructor\n\t * @protected\n\t * @extends property-properties.IndexedCollectionBaseProperty\n\t * @alias property-properties.SetProperty\n\t * @category Other Collections\n\t */\n\tconstructor(in_params, in_scope) {\n\t\tsuper(in_params);\n\n\t\tthis._scope = in_scope;\n\n\t\t/** Contains the actual entries of the set, indexed by their GUID */\n\t\tthis._dynamicChildren = {};\n\t}\n\n\t// A set property falls back to NamedProperty, if none is specified\n\n\t/**\n\t * Is this property a leaf node with regard to flattening?\n\t *\n\t * TODO: Which semantics should flattening have? It stops at primitive types and collections?\n\t *\n\t * @return {boolean} Is it a leaf with regard to flattening?\n\t */\n\t_isFlattenLeaf() {\n\t\treturn true;\n\t}\n\n\t/**\n\t * Returns an object with all the nested values contained in this property.\n\t * @return {object} An object representing the values of your property.\n\t * For example:\n\t *\n\t * ```json\n\t * {\n\t * position: {\n\t * x: 2,\n\t * y: 5\n\t * }\n\t * }\n\t * ```\n\t */\n\tgetValues() {\n\t\tvar ids = this.getIds();\n\t\tvar result = {};\n\t\tfor (var i = 0; i < ids.length; i++) {\n\t\t\tvar child = this.get(ids[i]);\n\t\t\tresult[ids[i]] =\n\t\t\t\tchild instanceof Property.ValueProperty || child instanceof Property.StringProperty\n\t\t\t\t\t? this.get(ids[i]).getValue()\n\t\t\t\t\t: child.getValues();\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns the full property type identifier for the ChangeSet including the enum type id\n\t * @param {boolean} [in_hideCollection=false] - If true the collection type (if applicable) will be omitted\n\t * @return {string} The typeid\n\t */\n\tgetFullTypeid(in_hideCollection = false) {\n\t\treturn in_hideCollection\n\t\t\t? this._typeid\n\t\t\t: TypeIdHelper.createSerializationTypeId(this._typeid, \"set\");\n\t}\n\n\t/**\n\t * Returns the path segment for a child\n\t *\n\t * @param {property-properties.NamedProperty} in_childNode - The child for which the path is returned\n\t *\n\t * @return {string} The path segment to resolve the child property under this property\n\t * @protected\n\t */\n\t_getPathSegmentForChildNode(in_childNode) {\n\t\treturn \"[\" + in_childNode.getGuid() + \"]\";\n\t}\n\n\t/**\n\t * Resolves a direct child node based on the given path segment\n\t *\n\t * @param {String} in_segment - The path segment to resolve\n\t * @param {property-properties.PathHelper.TOKEN_TYPES} in_segmentType - The type of segment in the tokenized path\n\t *\n\t * @return {BaseProperty | undefined} The child property that has been resolved\n\t * @protected\n\t */\n\t_resolvePathSegment(in_segment, in_segmentType) {\n\t\t// Base Properties only support paths separated via dots\n\t\treturn in_segmentType === PathHelper.TOKEN_TYPES.ARRAY_TOKEN\n\t\t\t? this._dynamicChildren[in_segment]\n\t\t\t: AbstractStaticCollectionProperty.prototype._resolvePathSegment.call(\n\t\t\t\t\tthis,\n\t\t\t\t\tin_segment,\n\t\t\t\t\tin_segmentType,\n\t\t\t\t);\n\t}\n\n\t/**\n\t * Inserts a property into the set\n\t *\n\t * @param {property-properties.NamedProperty} in_property - The property to insert\n\t * @throws if trying to insert non-named properties\n\t * @throws if trying to insert a property that has a parent\n\t * @throws if a property already exists with the same guid as in_property\n\t */\n\tinsert(in_property) {\n\t\tif (in_property instanceof AbstractStaticCollectionProperty && in_property.has(\"guid\")) {\n\t\t\tvar guid = in_property.getGuid();\n\t\t\tthis._insert(guid, in_property, true);\n\t\t} else {\n\t\t\tthrow new Error(MSG.CANT_INSERT_NON_NAMED_PROPERTIES);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a property to the set.\n\t *\n\t * - If the property's key exists, the entry is replaced with new one.\n\t *\n\t * - If the property's key does not exist, the property is appended.\n\t *\n\t * @param {NamedProperty|NamedNodeProperty|Object} in_property - The property to add to the list.\n\t * @return { BaseProperty }\n\t */\n\tset(in_property) {\n\t\tthis._checkIsNotReadOnly(true);\n\n\t\tif (in_property instanceof AbstractStaticCollectionProperty && in_property.has(\"guid\")) {\n\t\t\tvar guid = in_property.getGuid();\n\t\t\tif (this.has(guid)) {\n\t\t\t\tthis.remove(guid);\n\t\t\t}\n\n\t\t\tthis.insert(in_property);\n\t\t} else {\n\t\t\tthrow new Error(MSG.CANT_INSERT_NON_NAMED_PROPERTIES);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the given property from the set\n\t *\n\t * Note: If the entry does not exist, a warning is logged and no error is thrown.\n\t * This is intentional to support idempotent operations in collaborative editing scenarios.\n\t *\n\t * @param {property-properties.NamedProperty|string} in_entry - The property or its URN to remove from the set\n\t * @return {property-properties.NamedProperty} the property that was removed, or undefined if not found\n\t */\n\tremove(in_entry) {\n\t\tif (_.isString(in_entry)) {\n\t\t\tvar item = this.get(in_entry);\n\t\t\tthis._removeByKey(in_entry, true);\n\t\t\treturn item;\n\t\t} else {\n\t\t\tthis._removeByKey(in_entry.getGuid(), true);\n\t\t\treturn in_entry;\n\t\t}\n\t}\n\n\t/**\n\t * Returns an Object with all the entries of the set.\n\t *\n\t * WARNING: This is a direct access to the internal data-structure and the collection MUST NOT be modified.\n\t * It is read only for fast access and iteration. Insertion and deletion MUST be done via the insert and\n\t * remove functions of this class.\n\t *\n\t * @return {Object<String, property-properties.NamedProperty>} The map with all entries in the set.\n\t */\n\tgetEntriesReadOnly() {\n\t\treturn this._dynamicChildren;\n\t}\n\n\t/**\n\t * Returns the name of all the sub-properties of this property.\n\t *\n\t * @return {Array.<string>} An array of all the property ids\n\t */\n\tgetIds() {\n\t\treturn Object.keys(this._dynamicChildren);\n\t}\n\n\t/**\n\t * Returns the collection entry with the given ID\n\t *\n\t * @param {string | Array<string | number>} in_ids - key of the entry to return or an array of keys if an array is\n\t * passed, the .get function will be performed on each id in sequence for example .get(['position','x']) is\n\t * equivalent to .get('position').get('x'). If .get resolves to a ReferenceProperty, it will return the property\n\t * that the ReferenceProperty refers to.\n\t * @param {Object} in_options - parameter object\n\t * @param {property-properties.BaseProperty.REFERENCE_RESOLUTION} [in_options.referenceResolutionMode=ALWAYS] - How\n\t * should this function behave during reference resolution?\n\t *\n\t * @return {BaseProperty | undefined} The entry in the collection or undefined if none could be\n\t * found\n\t */\n\tget(in_ids, in_options) {\n\t\tif (_.isArray(in_ids)) {\n\t\t\t// Forward handling of arrays to the BaseProperty function\n\t\t\treturn AbstractStaticCollectionProperty.prototype.get.call(this, in_ids, in_options);\n\t\t} else {\n\t\t\tvar prop = this;\n\t\t\tin_options = in_options || {};\n\t\t\tin_options.referenceResolutionMode =\n\t\t\t\tin_options.referenceResolutionMode === undefined\n\t\t\t\t\t? BaseProperty.REFERENCE_RESOLUTION.ALWAYS\n\t\t\t\t\t: in_options.referenceResolutionMode;\n\t\t\tswitch (in_ids) {\n\t\t\t\tcase PATH_TOKENS.ROOT: {\n\t\t\t\t\tprop = prop.getRoot();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase PATH_TOKENS.UP: {\n\t\t\t\t\tprop = prop.getParent();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase PATH_TOKENS.REF: {\n\t\t\t\t\tthrow new Error(MSG.NO_GET_DEREFERENCE_ONLY);\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tprop = prop._dynamicChildren[in_ids];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn prop;\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether a property with the given name exists\n\t *\n\t * @param {string} in_id - Name of the property\n\t * @return {boolean} True if the property exists, otherwise false.\n\t */\n\thas(in_id) {\n\t\treturn this._dynamicChildren[in_id] !== undefined;\n\t}\n\n\t/**\n\t * Adds a list of properties to the set.\n\t * See {@link SetProperty.setValues}\n\t * @param {NamedProperty[]|NamedNodeProperty[]|Object[]} in_properties - The list of properties to add to the list\n\t * @param {Boolean} in_typed - If the set's items have a typeid and a value then create the\n\t * properties with that typeid, else use the set's typeid (support polymorphic items).\n\t * @private\n\t */\n\t_setValuesInternal(in_properties, in_typed) {\n\t\tthis._checkIsNotReadOnly(true);\n\n\t\tvar that = this;\n\t\t_.each(in_properties, function (property) {\n\t\t\tif (property instanceof BaseProperty) {\n\t\t\t\tthat.set(property);\n\t\t\t} else {\n\t\t\t\t// If value is a JSON object (i.e: passed through a default value), create the property and add it to the set.\n\t\t\t\tif (in_typed) {\n\t\t\t\t\tthat.set(\n\t\t\t\t\t\tProperty.PropertyFactory._createProperty(\n\t\t\t\t\t\t\tproperty.typeid || that._typeid,\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\tproperty.value,\n\t\t\t\t\t\t\tthat._getScope(),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthat.set(\n\t\t\t\t\t\tProperty.PropertyFactory._createProperty(\n\t\t\t\t\t\t\tthat._typeid,\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\tthat._getScope(),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Adds a list of properties to the set. See {@link SetProperty.setValues}\n\t * @param {NamedProperty[]|NamedNodeProperty[]|Object[]} in_properties - The list of properties to add to the list\n\t * @param {boolean} in_typed - If the set's items have a typeid and a value then create the properties with that\n\t * typeid, else use the set's typeid (support polymorphic items).\n\t * @param {boolean} in_initial - Whether we are setting default/initial values or if the function is called directly\n\t * with the values to set.\n\t * @override\n\t */\n\t_setValues(in_properties, in_typed, in_initial) {\n\t\tif (in_initial) {\n\t\t\tthis.clear();\n\t\t}\n\n\t\tthis._setValuesInternal(in_properties, in_typed);\n\t}\n\n\t/**\n\t * Adds a list of properties to the set.\n\t * - If the property's key exists, the entry is replaced with new one.\n\t * - If the property's key does not exist, the property is appended.\n\t * @param {NamedProperty[]|NamedNodeProperty[]|Object[]} in_properties - The list of properties to add to the list\n\t * @override\n\t */\n\tsetValues(in_properties) {\n\t\tvar checkoutView = this._getCheckoutView();\n\t\tif (checkoutView !== undefined) {\n\t\t\tcheckoutView.pushNotificationDelayScope();\n\t\t\tSetProperty.prototype._setValues.call(this, in_properties, false, false);\n\t\t\tcheckoutView.popNotificationDelayScope();\n\t\t} else {\n\t\t\tSetProperty.prototype._setValues.call(this, in_properties, false, false);\n\t\t}\n\t}\n\n\t/**\n\t * Returns all entries of the set as an array.\n\t *\n\t * NOTE: This function creates a copy and thus is less efficient as getEntriesReadOnly.\n\t *\n\t * @return {Array.<property-properties.NamedProperty>} Array with all entries of the set. This array is a shallow copy\n\t * which can be modified by the caller without effects on the set.\n\t */\n\tgetAsArray() {\n\t\treturn _.values(this._dynamicChildren);\n\t}\n\n\t/**\n\t * Get the scope to which this property belongs to.\n\t * @return {string|undefined} The guid representing the scope in which the\n\t * set belongs to. If there is a workspace scope return it, else return the scope of this set.\n\t * @override\n\t * @private\n\t */\n\t_getScope() {\n\t\tvar scope = IndexedCollectionBaseProperty.prototype._getScope.call(this);\n\n\t\treturn scope !== undefined ? scope : this._scope;\n\t}\n\n\t/**\n\t * Delete all values from Set\n\t */\n\tclear() {\n\t\tvar that = this;\n\t\tthis.getIds().forEach(function (id) {\n\t\t\tthat.remove(id);\n\t\t});\n\t}\n}\n\nSetProperty.prototype._typeid = \"NamedProperty\";\nSetProperty.prototype._context = \"set\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/property-properties",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.82.0",
|
|
4
4
|
"description": "definitions of properties",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"temp-directory": "nyc/.nyc_output"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@fluid-experimental/property-changeset": "~2.
|
|
45
|
-
"@fluid-experimental/property-common": "~2.
|
|
44
|
+
"@fluid-experimental/property-changeset": "~2.82.0",
|
|
45
|
+
"@fluid-experimental/property-common": "~2.82.0",
|
|
46
46
|
"ajv": "^8.17.1",
|
|
47
47
|
"async": "^3.2.2",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@biomejs/biome": "~1.9.3",
|
|
55
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
55
|
+
"@fluid-internal/mocha-test-setup": "~2.82.0",
|
|
56
56
|
"@fluidframework/build-common": "^2.0.3",
|
|
57
57
|
"@fluidframework/build-tools": "^0.63.0",
|
|
58
58
|
"@types/mocha": "^10.0.10",
|
|
59
|
-
"@types/node": "
|
|
59
|
+
"@types/node": "~20.19.30",
|
|
60
60
|
"@types/sinon": "^17.0.3",
|
|
61
61
|
"c8": "^10.1.3",
|
|
62
62
|
"chai": "^4.2.0",
|