@fluid-experimental/property-properties 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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/README.md +1 -0
- package/dist/containerSerializer.d.ts.map +1 -1
- package/dist/containerSerializer.js +5 -5
- package/dist/containerSerializer.js.map +1 -1
- package/dist/enableValidations.js.map +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/properties/abstractStaticCollectionProperty.d.ts +10 -10
- package/dist/properties/abstractStaticCollectionProperty.d.ts.map +1 -1
- package/dist/properties/abstractStaticCollectionProperty.js +70 -53
- package/dist/properties/abstractStaticCollectionProperty.js.map +1 -1
- package/dist/properties/arrayProperty.d.ts.map +1 -1
- package/dist/properties/arrayProperty.js +152 -103
- package/dist/properties/arrayProperty.js.map +1 -1
- package/dist/properties/baseProperty.d.ts +4 -4
- package/dist/properties/baseProperty.d.ts.map +1 -1
- package/dist/properties/baseProperty.js +69 -47
- package/dist/properties/baseProperty.js.map +1 -1
- package/dist/properties/boolProperty.d.ts.map +1 -1
- package/dist/properties/boolProperty.js +3 -3
- package/dist/properties/boolProperty.js.map +1 -1
- package/dist/properties/containerProperty.d.ts +8 -8
- package/dist/properties/containerProperty.d.ts.map +1 -1
- package/dist/properties/containerProperty.js +33 -26
- package/dist/properties/containerProperty.js.map +1 -1
- package/dist/properties/enumArrayProperty.d.ts.map +1 -1
- package/dist/properties/enumArrayProperty.js +14 -14
- package/dist/properties/enumArrayProperty.js.map +1 -1
- package/dist/properties/enumProperty.d.ts.map +1 -1
- package/dist/properties/enumProperty.js +17 -17
- package/dist/properties/enumProperty.js.map +1 -1
- package/dist/properties/floatProperties.js +4 -4
- package/dist/properties/floatProperties.js.map +1 -1
- package/dist/properties/index.d.ts +23 -23
- package/dist/properties/index.d.ts.map +1 -1
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/indexedCollectionBaseProperty.d.ts.map +1 -1
- package/dist/properties/indexedCollectionBaseProperty.js +47 -37
- package/dist/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/dist/properties/intProperties.d.ts.map +1 -1
- package/dist/properties/intProperties.js +10 -10
- package/dist/properties/intProperties.js.map +1 -1
- package/dist/properties/lazyLoadedProperties.js.map +1 -1
- package/dist/properties/mapProperty.d.ts.map +1 -1
- package/dist/properties/mapProperty.js +21 -17
- package/dist/properties/mapProperty.js.map +1 -1
- package/dist/properties/namedNodeProperty.d.ts.map +1 -1
- package/dist/properties/namedNodeProperty.js +3 -3
- package/dist/properties/namedNodeProperty.js.map +1 -1
- package/dist/properties/namedProperty.d.ts.map +1 -1
- package/dist/properties/namedProperty.js +7 -5
- package/dist/properties/namedProperty.js.map +1 -1
- package/dist/properties/nodeProperty.d.ts.map +1 -1
- package/dist/properties/nodeProperty.js +5 -3
- package/dist/properties/nodeProperty.js.map +1 -1
- package/dist/properties/primitiveTypeCasts.d.ts.map +1 -1
- package/dist/properties/primitiveTypeCasts.js +9 -9
- package/dist/properties/primitiveTypeCasts.js.map +1 -1
- package/dist/properties/referenceArrayProperty.d.ts.map +1 -1
- package/dist/properties/referenceArrayProperty.js +31 -25
- package/dist/properties/referenceArrayProperty.js.map +1 -1
- package/dist/properties/referenceMapProperty.d.ts.map +1 -1
- package/dist/properties/referenceMapProperty.js +18 -18
- package/dist/properties/referenceMapProperty.js.map +1 -1
- package/dist/properties/referenceProperty.d.ts.map +1 -1
- package/dist/properties/referenceProperty.js +33 -29
- package/dist/properties/referenceProperty.js.map +1 -1
- package/dist/properties/setProperty.d.ts.map +1 -1
- package/dist/properties/setProperty.js +31 -29
- package/dist/properties/setProperty.js.map +1 -1
- package/dist/properties/stringProperty.d.ts.map +1 -1
- package/dist/properties/stringProperty.js +56 -40
- package/dist/properties/stringProperty.js.map +1 -1
- package/dist/properties/uintProperties.js +5 -5
- package/dist/properties/uintProperties.js.map +1 -1
- package/dist/properties/valueArrayProperty.d.ts +1 -1
- package/dist/properties/valueArrayProperty.d.ts.map +1 -1
- package/dist/properties/valueArrayProperty.js +30 -29
- package/dist/properties/valueArrayProperty.js.map +1 -1
- package/dist/properties/valueMapProperty.d.ts.map +1 -1
- package/dist/properties/valueMapProperty.js +31 -29
- package/dist/properties/valueMapProperty.js.map +1 -1
- package/dist/properties/valueProperty.d.ts.map +1 -1
- package/dist/properties/valueProperty.js +11 -9
- package/dist/properties/valueProperty.js.map +1 -1
- package/dist/propertyFactory.d.ts.map +1 -1
- package/dist/propertyFactory.js +309 -252
- package/dist/propertyFactory.js.map +1 -1
- package/dist/propertyTemplate.d.ts +17 -17
- package/dist/propertyTemplate.d.ts.map +1 -1
- package/dist/propertyTemplate.js +64 -45
- package/dist/propertyTemplate.js.map +1 -1
- package/dist/propertyTemplateWrapper.d.ts.map +1 -1
- package/dist/propertyTemplateWrapper.js +40 -25
- package/dist/propertyTemplateWrapper.js.map +1 -1
- package/dist/propertyUtils.d.ts.map +1 -1
- package/dist/propertyUtils.js.map +1 -1
- package/dist/test/properties/arrayProperty.spec.js +566 -490
- package/dist/test/properties/arrayProperty.spec.js.map +1 -1
- package/dist/test/properties/baseProperty.spec.js +293 -280
- package/dist/test/properties/baseProperty.spec.js.map +1 -1
- package/dist/test/properties/containerProperty.spec.js +100 -94
- package/dist/test/properties/containerProperty.spec.js.map +1 -1
- package/dist/test/properties/customArrayProperty.spec.js +174 -147
- package/dist/test/properties/customArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/enumArrayProperty.spec.js +67 -63
- package/dist/test/properties/enumArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/enumProperty.spec.js +115 -97
- package/dist/test/properties/enumProperty.spec.js.map +1 -1
- package/dist/test/properties/float32.spec.js +5 -5
- package/dist/test/properties/float32.spec.js.map +1 -1
- package/dist/test/properties/int64ArrayProperty.spec.js +157 -93
- package/dist/test/properties/int64ArrayProperty.spec.js.map +1 -1
- package/dist/test/properties/int64MapProperty.spec.js +185 -166
- package/dist/test/properties/int64MapProperty.spec.js.map +1 -1
- package/dist/test/properties/int64Property.spec.js +109 -109
- package/dist/test/properties/int64Property.spec.js.map +1 -1
- package/dist/test/properties/isLeafNode.spec.js +75 -76
- package/dist/test/properties/isLeafNode.spec.js.map +1 -1
- package/dist/test/properties/mapProperty.spec.js +571 -531
- package/dist/test/properties/mapProperty.spec.js.map +1 -1
- package/dist/test/properties/namedNodeProperty.spec.js +31 -31
- package/dist/test/properties/namedNodeProperty.spec.js.map +1 -1
- package/dist/test/properties/nodeProperty.spec.js +805 -795
- package/dist/test/properties/nodeProperty.spec.js.map +1 -1
- package/dist/test/properties/referenceProperty.spec.js +729 -679
- package/dist/test/properties/referenceProperty.spec.js.map +1 -1
- package/dist/test/properties/relationshipProperty.spec.js +16 -16
- package/dist/test/properties/relationshipProperty.spec.js.map +1 -1
- package/dist/test/properties/setProperty.spec.js +288 -227
- package/dist/test/properties/setProperty.spec.js.map +1 -1
- package/dist/test/properties/stringProperty.spec.js +326 -318
- package/dist/test/properties/stringProperty.spec.js.map +1 -1
- package/dist/test/properties/uint64Property.spec.js +46 -36
- package/dist/test/properties/uint64Property.spec.js.map +1 -1
- package/dist/test/properties/valueMapProperty.spec.js +259 -246
- package/dist/test/properties/valueMapProperty.spec.js.map +1 -1
- package/dist/test/properties/valueProperty.spec.js +49 -43
- package/dist/test/properties/valueProperty.spec.js.map +1 -1
- package/dist/test/propertyFactory.spec.js +2038 -1631
- package/dist/test/propertyFactory.spec.js.map +1 -1
- package/dist/test/propertyTemplateWrapper.spec.js +72 -102
- package/dist/test/propertyTemplateWrapper.spec.js.map +1 -1
- package/dist/test/propertyUtils.spec.js +22 -21
- package/dist/test/propertyUtils.spec.js.map +1 -1
- package/dist/test/reversibleChangeset.spec.js +857 -703
- package/dist/test/reversibleChangeset.spec.js.map +1 -1
- package/dist/test/setup.js +5 -5
- package/dist/test/setup.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/test/utils.spec.js +1334 -1144
- package/dist/test/utils.spec.js.map +1 -1
- package/dist/test/validation/badMissingSemverInTypeid.js +20 -20
- package/dist/test/validation/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/validation/badPrimitiveTypeid.js +12 -12
- package/dist/test/validation/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/validation/goodColorId.js +91 -91
- package/dist/test/validation/goodColorId.js.map +1 -1
- package/dist/test/validation/goodColorPalette.js +4 -4
- package/dist/test/validation/goodColorPalette.js.map +1 -1
- package/dist/test/validation/goodPointId.js +20 -20
- package/dist/test/validation/goodPointId.js.map +1 -1
- package/dist/test/validation/reversibleChangeSetTestData.js +23841 -2
- package/dist/test/validation/reversibleChangeSetTestData.js.map +1 -1
- package/lib/containerSerializer.d.ts.map +1 -1
- package/lib/containerSerializer.js +5 -5
- package/lib/containerSerializer.js.map +1 -1
- package/lib/enableValidations.js.map +1 -1
- package/lib/index.d.ts +19 -19
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -19
- package/lib/index.js.map +1 -1
- package/lib/properties/abstractStaticCollectionProperty.d.ts +10 -10
- package/lib/properties/abstractStaticCollectionProperty.d.ts.map +1 -1
- package/lib/properties/abstractStaticCollectionProperty.js +70 -53
- package/lib/properties/abstractStaticCollectionProperty.js.map +1 -1
- package/lib/properties/arrayProperty.d.ts.map +1 -1
- package/lib/properties/arrayProperty.js +152 -103
- package/lib/properties/arrayProperty.js.map +1 -1
- package/lib/properties/baseProperty.d.ts +4 -4
- package/lib/properties/baseProperty.d.ts.map +1 -1
- package/lib/properties/baseProperty.js +73 -51
- package/lib/properties/baseProperty.js.map +1 -1
- package/lib/properties/boolProperty.d.ts.map +1 -1
- package/lib/properties/boolProperty.js +3 -3
- package/lib/properties/boolProperty.js.map +1 -1
- package/lib/properties/containerProperty.d.ts +8 -8
- package/lib/properties/containerProperty.d.ts.map +1 -1
- package/lib/properties/containerProperty.js +33 -26
- package/lib/properties/containerProperty.js.map +1 -1
- package/lib/properties/enumArrayProperty.d.ts.map +1 -1
- package/lib/properties/enumArrayProperty.js +14 -14
- package/lib/properties/enumArrayProperty.js.map +1 -1
- package/lib/properties/enumProperty.d.ts.map +1 -1
- package/lib/properties/enumProperty.js +17 -17
- package/lib/properties/enumProperty.js.map +1 -1
- package/lib/properties/floatProperties.js +4 -4
- package/lib/properties/floatProperties.js.map +1 -1
- package/lib/properties/index.d.ts +23 -23
- package/lib/properties/index.d.ts.map +1 -1
- package/lib/properties/index.js +23 -23
- package/lib/properties/index.js.map +1 -1
- package/lib/properties/indexedCollectionBaseProperty.d.ts.map +1 -1
- package/lib/properties/indexedCollectionBaseProperty.js +47 -37
- package/lib/properties/indexedCollectionBaseProperty.js.map +1 -1
- package/lib/properties/intProperties.d.ts.map +1 -1
- package/lib/properties/intProperties.js +10 -10
- package/lib/properties/intProperties.js.map +1 -1
- package/lib/properties/lazyLoadedProperties.js.map +1 -1
- package/lib/properties/mapProperty.d.ts.map +1 -1
- package/lib/properties/mapProperty.js +21 -17
- package/lib/properties/mapProperty.js.map +1 -1
- package/lib/properties/namedNodeProperty.d.ts.map +1 -1
- package/lib/properties/namedNodeProperty.js +3 -3
- package/lib/properties/namedNodeProperty.js.map +1 -1
- package/lib/properties/namedProperty.d.ts.map +1 -1
- package/lib/properties/namedProperty.js +7 -5
- package/lib/properties/namedProperty.js.map +1 -1
- package/lib/properties/nodeProperty.d.ts.map +1 -1
- package/lib/properties/nodeProperty.js +5 -3
- package/lib/properties/nodeProperty.js.map +1 -1
- package/lib/properties/primitiveTypeCasts.d.ts.map +1 -1
- package/lib/properties/primitiveTypeCasts.js +9 -9
- package/lib/properties/primitiveTypeCasts.js.map +1 -1
- package/lib/properties/referenceArrayProperty.d.ts.map +1 -1
- package/lib/properties/referenceArrayProperty.js +31 -25
- package/lib/properties/referenceArrayProperty.js.map +1 -1
- package/lib/properties/referenceMapProperty.d.ts.map +1 -1
- package/lib/properties/referenceMapProperty.js +18 -18
- package/lib/properties/referenceMapProperty.js.map +1 -1
- package/lib/properties/referenceProperty.d.ts.map +1 -1
- package/lib/properties/referenceProperty.js +33 -29
- package/lib/properties/referenceProperty.js.map +1 -1
- package/lib/properties/setProperty.d.ts.map +1 -1
- package/lib/properties/setProperty.js +31 -29
- package/lib/properties/setProperty.js.map +1 -1
- package/lib/properties/stringProperty.d.ts.map +1 -1
- package/lib/properties/stringProperty.js +56 -40
- package/lib/properties/stringProperty.js.map +1 -1
- package/lib/properties/uintProperties.js +5 -5
- package/lib/properties/uintProperties.js.map +1 -1
- package/lib/properties/valueArrayProperty.d.ts +1 -1
- package/lib/properties/valueArrayProperty.d.ts.map +1 -1
- package/lib/properties/valueArrayProperty.js +30 -29
- package/lib/properties/valueArrayProperty.js.map +1 -1
- package/lib/properties/valueMapProperty.d.ts.map +1 -1
- package/lib/properties/valueMapProperty.js +31 -29
- package/lib/properties/valueMapProperty.js.map +1 -1
- package/lib/properties/valueProperty.d.ts.map +1 -1
- package/lib/properties/valueProperty.js +11 -9
- package/lib/properties/valueProperty.js.map +1 -1
- package/lib/propertyFactory.d.ts.map +1 -1
- package/lib/propertyFactory.js +309 -252
- package/lib/propertyFactory.js.map +1 -1
- package/lib/propertyTemplate.d.ts +17 -17
- package/lib/propertyTemplate.d.ts.map +1 -1
- package/lib/propertyTemplate.js +64 -45
- package/lib/propertyTemplate.js.map +1 -1
- package/lib/propertyTemplateWrapper.d.ts.map +1 -1
- package/lib/propertyTemplateWrapper.js +40 -25
- package/lib/propertyTemplateWrapper.js.map +1 -1
- package/lib/propertyUtils.d.ts.map +1 -1
- package/lib/propertyUtils.js.map +1 -1
- package/package.json +28 -28
- package/src/index.d.ts +2750 -2681
package/lib/propertyFactory.js
CHANGED
|
@@ -6,44 +6,44 @@
|
|
|
6
6
|
* @fileoverview Declaration of the PropertyFactory class.
|
|
7
7
|
* Responsible for creating property sets and registering property templates
|
|
8
8
|
*/
|
|
9
|
-
const _ = require(
|
|
10
|
-
const fastestJSONCopy = require(
|
|
9
|
+
const _ = require("lodash");
|
|
10
|
+
const fastestJSONCopy = require("fastest-json-copy");
|
|
11
11
|
const deepCopy = fastestJSONCopy.copy;
|
|
12
|
-
const { Collection, ConsoleUtils, EventEmitter, SortedCollection, constants, GuidUtils, } = require(
|
|
12
|
+
const { Collection, ConsoleUtils, EventEmitter, SortedCollection, constants, GuidUtils, } = require("@fluid-experimental/property-common");
|
|
13
13
|
const { MSG } = constants;
|
|
14
|
-
const { TypeIdHelper, TemplateValidator, PathHelper, ChangeSet, } = require(
|
|
15
|
-
const semver = require(
|
|
16
|
-
const async = require(
|
|
17
|
-
const { PropertyTemplate } = require(
|
|
18
|
-
const { PropertyTemplateWrapper } = require(
|
|
14
|
+
const { TypeIdHelper, TemplateValidator, PathHelper, ChangeSet, } = require("@fluid-experimental/property-changeset");
|
|
15
|
+
const semver = require("semver");
|
|
16
|
+
const async = require("async");
|
|
17
|
+
const { PropertyTemplate } = require("./propertyTemplate");
|
|
18
|
+
const { PropertyTemplateWrapper } = require("./propertyTemplateWrapper");
|
|
19
19
|
// Include the property classes
|
|
20
|
-
const { BaseProperty } = require(
|
|
21
|
-
const { NamedProperty } = require(
|
|
22
|
-
const { NodeProperty } = require(
|
|
23
|
-
const { NamedNodeProperty } = require(
|
|
24
|
-
const { ContainerProperty } = require(
|
|
25
|
-
const { ValueProperty } = require(
|
|
20
|
+
const { BaseProperty } = require("./properties/baseProperty");
|
|
21
|
+
const { NamedProperty } = require("./properties/namedProperty");
|
|
22
|
+
const { NodeProperty } = require("./properties/nodeProperty");
|
|
23
|
+
const { NamedNodeProperty } = require("./properties/namedNodeProperty");
|
|
24
|
+
const { ContainerProperty } = require("./properties/containerProperty");
|
|
25
|
+
const { ValueProperty } = require("./properties/valueProperty");
|
|
26
26
|
// Include all primitive properties –- will register at the end.
|
|
27
|
-
const { Uint8Property, Uint16Property, Uint32Property
|
|
28
|
-
const { Float32Property, Float64Property
|
|
29
|
-
const { Int8Property, Int16Property, Int32Property, Int64Property, Uint64Property, } = require(
|
|
30
|
-
const { StringProperty } = require(
|
|
31
|
-
const { BoolProperty } = require(
|
|
32
|
-
const { ReferenceProperty } = require(
|
|
33
|
-
const { EnumProperty } = require(
|
|
27
|
+
const { Uint8Property, Uint16Property, Uint32Property } = require("./properties/uintProperties");
|
|
28
|
+
const { Float32Property, Float64Property } = require("./properties/floatProperties");
|
|
29
|
+
const { Int8Property, Int16Property, Int32Property, Int64Property, Uint64Property, } = require("./properties/intProperties");
|
|
30
|
+
const { StringProperty } = require("./properties/stringProperty");
|
|
31
|
+
const { BoolProperty } = require("./properties/boolProperty");
|
|
32
|
+
const { ReferenceProperty } = require("./properties/referenceProperty");
|
|
33
|
+
const { EnumProperty } = require("./properties/enumProperty");
|
|
34
34
|
// Include collection properties
|
|
35
|
-
const { ArrayProperty } = require(
|
|
36
|
-
const { SetProperty } = require(
|
|
37
|
-
const { MapProperty } = require(
|
|
38
|
-
const { ValueMapProperty } = require(
|
|
39
|
-
const { IndexedCollectionBaseProperty } = require(
|
|
40
|
-
const { AbstractStaticCollectionProperty } = require(
|
|
41
|
-
const { Float32ArrayProperty, Float64ArrayProperty, Uint32ArrayProperty, Int32ArrayProperty, Uint64ArrayProperty, Int64ArrayProperty, Uint16ArrayProperty, Int16ArrayProperty, Uint8ArrayProperty, Int8ArrayProperty, StringArrayProperty, BoolArrayProperty, } = require(
|
|
42
|
-
const { ReferenceMapProperty } = require(
|
|
43
|
-
const { ReferenceArrayProperty } = require(
|
|
44
|
-
const { EnumArrayProperty } = require(
|
|
45
|
-
const { Float64MapProperty, Float32MapProperty, Uint32MapProperty, Uint64MapProperty, Uint16MapProperty, Uint8MapProperty, Int32MapProperty, Int64MapProperty, Int16MapProperty, Int8MapProperty, StringMapProperty, BoolMapProperty, } = require(
|
|
46
|
-
const { LazyLoadedProperties } = require(
|
|
35
|
+
const { ArrayProperty } = require("./properties/arrayProperty");
|
|
36
|
+
const { SetProperty } = require("./properties/setProperty");
|
|
37
|
+
const { MapProperty } = require("./properties/mapProperty");
|
|
38
|
+
const { ValueMapProperty } = require("./properties/valueMapProperty");
|
|
39
|
+
const { IndexedCollectionBaseProperty } = require("./properties/indexedCollectionBaseProperty");
|
|
40
|
+
const { AbstractStaticCollectionProperty, } = require("./properties/abstractStaticCollectionProperty");
|
|
41
|
+
const { Float32ArrayProperty, Float64ArrayProperty, Uint32ArrayProperty, Int32ArrayProperty, Uint64ArrayProperty, Int64ArrayProperty, Uint16ArrayProperty, Int16ArrayProperty, Uint8ArrayProperty, Int8ArrayProperty, StringArrayProperty, BoolArrayProperty, } = require("./properties/valueArrayProperty");
|
|
42
|
+
const { ReferenceMapProperty } = require("./properties/referenceMapProperty");
|
|
43
|
+
const { ReferenceArrayProperty } = require("./properties/referenceArrayProperty");
|
|
44
|
+
const { EnumArrayProperty } = require("./properties/enumArrayProperty");
|
|
45
|
+
const { Float64MapProperty, Float32MapProperty, Uint32MapProperty, Uint64MapProperty, Uint16MapProperty, Uint8MapProperty, Int32MapProperty, Int64MapProperty, Int16MapProperty, Int8MapProperty, StringMapProperty, BoolMapProperty, } = require("./properties/valueMapProperty");
|
|
46
|
+
const { LazyLoadedProperties } = require("./properties/lazyLoadedProperties");
|
|
47
47
|
/**
|
|
48
48
|
* Creates an instance of the TemplateValidator
|
|
49
49
|
*
|
|
@@ -97,7 +97,9 @@ var registerLocal = function (in_template) {
|
|
|
97
97
|
var serializedInTemplate = in_template.serializeCanonical();
|
|
98
98
|
var localValidationResults = { isValid: true };
|
|
99
99
|
if (this._localPrimitivePropertiesAndTemplates.has(typeid)) {
|
|
100
|
-
var localRegisteredTemplate = this._localPrimitivePropertiesAndTemplates
|
|
100
|
+
var localRegisteredTemplate = this._localPrimitivePropertiesAndTemplates
|
|
101
|
+
.item(typeid)
|
|
102
|
+
.getPropertyTemplate();
|
|
101
103
|
localValidationResults = templateValidator.validate(localRegisteredTemplate.serializeCanonical(), serializedInTemplate);
|
|
102
104
|
}
|
|
103
105
|
if (localValidationResults.isValid) {
|
|
@@ -110,12 +112,16 @@ var registerLocal = function (in_template) {
|
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
if (!localValidationResults.isValid) {
|
|
113
|
-
throw new Error(MSG.TEMPLATE_MISMATCH +
|
|
114
|
-
|
|
115
|
+
throw new Error(MSG.TEMPLATE_MISMATCH +
|
|
116
|
+
typeid +
|
|
117
|
+
"\n errors = " +
|
|
118
|
+
JSON.stringify(_extractErrorMessage(localValidationResults.errors), 0, 2));
|
|
115
119
|
}
|
|
116
120
|
else if (!remoteValidationResults.isValid) {
|
|
117
|
-
throw new Error(MSG.REMOTE_TEMPLATE_MISMATCH +
|
|
118
|
-
|
|
121
|
+
throw new Error(MSG.REMOTE_TEMPLATE_MISMATCH +
|
|
122
|
+
typeid +
|
|
123
|
+
"\n errors = " +
|
|
124
|
+
JSON.stringify(_extractErrorMessage(remoteValidationResults.errors), 0, 2));
|
|
119
125
|
}
|
|
120
126
|
else if (this._localPrimitivePropertiesAndTemplates.has(typeid)) {
|
|
121
127
|
// Template is already registered. Do nothing.
|
|
@@ -130,7 +136,9 @@ var registerLocal = function (in_template) {
|
|
|
130
136
|
this._validateSemver(in_template, true);
|
|
131
137
|
// Semver validation passed. Add the template to the local versioned templates collection
|
|
132
138
|
if (this._localVersionedTemplates.has(typeidWithoutVersion)) {
|
|
133
|
-
this._localVersionedTemplates
|
|
139
|
+
this._localVersionedTemplates
|
|
140
|
+
.item(typeidWithoutVersion)
|
|
141
|
+
.add(version, in_template);
|
|
134
142
|
}
|
|
135
143
|
else {
|
|
136
144
|
var collection = _createVersionedSortedCollection();
|
|
@@ -139,12 +147,17 @@ var registerLocal = function (in_template) {
|
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
149
|
else {
|
|
142
|
-
throw new Error(MSG.FAILED_TO_REGISTER +
|
|
143
|
-
|
|
150
|
+
throw new Error(MSG.FAILED_TO_REGISTER +
|
|
151
|
+
typeid +
|
|
152
|
+
"\n errors = " +
|
|
153
|
+
JSON.stringify(_extractErrorMessage(validationResult.errors), 0, 2));
|
|
144
154
|
}
|
|
145
155
|
}
|
|
146
156
|
else {
|
|
147
|
-
throw new Error(MSG.UNVERSIONED_TEMPLATE +
|
|
157
|
+
throw new Error(MSG.UNVERSIONED_TEMPLATE +
|
|
158
|
+
" Template with typeid = " +
|
|
159
|
+
typeid +
|
|
160
|
+
" is not versioned.");
|
|
148
161
|
}
|
|
149
162
|
// Forward to the internal function
|
|
150
163
|
this._registerTypeId(typeid, in_template);
|
|
@@ -293,26 +306,26 @@ class PropertyFactory {
|
|
|
293
306
|
this._init();
|
|
294
307
|
}
|
|
295
308
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
309
|
+
* Add a listener for a given type of event.
|
|
310
|
+
*
|
|
311
|
+
* @param {string} eventName - A string representing the type of event upon which the
|
|
312
|
+
* listener will be notified.
|
|
313
|
+
* @param {function} eventListener - The function to call when the "type" of event
|
|
314
|
+
* is emitted.
|
|
315
|
+
* @public
|
|
316
|
+
*/
|
|
304
317
|
addListener(eventName, eventListener) {
|
|
305
318
|
this._eventEmitter.addListener(eventName, eventListener);
|
|
306
319
|
}
|
|
307
320
|
/**
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
321
|
+
* Remove a listener for a given type of event. Iff a listener was removed,
|
|
322
|
+
* an event 'removeListener' will be emitted.
|
|
323
|
+
*
|
|
324
|
+
* @param {string} eventName - A string representing the type of event on which the
|
|
325
|
+
* listener was attached.
|
|
326
|
+
* @param {function} eventListener - The function to remove from the list of functions
|
|
327
|
+
* @public
|
|
328
|
+
*/
|
|
316
329
|
removeListener(eventName, eventListener) {
|
|
317
330
|
this._eventEmitter.removeListener(eventName, eventListener);
|
|
318
331
|
}
|
|
@@ -321,70 +334,66 @@ class PropertyFactory {
|
|
|
321
334
|
*/
|
|
322
335
|
_init() {
|
|
323
336
|
// Register all primitive properties
|
|
324
|
-
this._registerTypeId(
|
|
325
|
-
this._registerTypeId(
|
|
326
|
-
this._registerTypeId(
|
|
337
|
+
this._registerTypeId("BaseProperty", BaseProperty, "all");
|
|
338
|
+
this._registerTypeId("NodeProperty", NodeProperty, "all");
|
|
339
|
+
this._registerTypeId("ContainerProperty", ContainerProperty, "all");
|
|
327
340
|
// Register the primitive types for the context single
|
|
328
|
-
this._registerTypeId(
|
|
329
|
-
this._registerTypeId(
|
|
330
|
-
this._registerTypeId(
|
|
331
|
-
this._registerTypeId(
|
|
332
|
-
this._registerTypeId(
|
|
333
|
-
this._registerTypeId(
|
|
334
|
-
this._registerTypeId(
|
|
335
|
-
this._registerTypeId(
|
|
336
|
-
this._registerTypeId(
|
|
337
|
-
this._registerTypeId(
|
|
338
|
-
this._registerTypeId(
|
|
339
|
-
this._registerTypeId(
|
|
340
|
-
this._registerTypeId(
|
|
341
|
-
this._registerTypeId(
|
|
341
|
+
this._registerTypeId("Int8", Int8Property);
|
|
342
|
+
this._registerTypeId("Uint8", Uint8Property);
|
|
343
|
+
this._registerTypeId("Int16", Int16Property);
|
|
344
|
+
this._registerTypeId("Uint16", Uint16Property);
|
|
345
|
+
this._registerTypeId("Int32", Int32Property);
|
|
346
|
+
this._registerTypeId("Int64", Int64Property);
|
|
347
|
+
this._registerTypeId("Uint64", Uint64Property);
|
|
348
|
+
this._registerTypeId("Uint32", Uint32Property);
|
|
349
|
+
this._registerTypeId("Float32", Float32Property);
|
|
350
|
+
this._registerTypeId("Float64", Float64Property);
|
|
351
|
+
this._registerTypeId("Bool", BoolProperty);
|
|
352
|
+
this._registerTypeId("String", StringProperty);
|
|
353
|
+
this._registerTypeId("Reference", ReferenceProperty);
|
|
354
|
+
this._registerTypeId("Enum", EnumProperty);
|
|
342
355
|
// Register the primitive types for the context array
|
|
343
|
-
this._registerTypeId(
|
|
344
|
-
this._registerTypeId(
|
|
345
|
-
this._registerTypeId(
|
|
346
|
-
this._registerTypeId(
|
|
347
|
-
this._registerTypeId(
|
|
348
|
-
this._registerTypeId(
|
|
349
|
-
this._registerTypeId(
|
|
350
|
-
this._registerTypeId(
|
|
351
|
-
this._registerTypeId(
|
|
352
|
-
this._registerTypeId(
|
|
353
|
-
this._registerTypeId(
|
|
354
|
-
this._registerTypeId(
|
|
355
|
-
this._registerTypeId(
|
|
356
|
-
this._registerTypeId(
|
|
356
|
+
this._registerTypeId("Int8", Int8ArrayProperty, "array");
|
|
357
|
+
this._registerTypeId("Uint8", Uint8ArrayProperty, "array");
|
|
358
|
+
this._registerTypeId("Int16", Int16ArrayProperty, "array");
|
|
359
|
+
this._registerTypeId("Uint16", Uint16ArrayProperty, "array");
|
|
360
|
+
this._registerTypeId("Int32", Int32ArrayProperty, "array");
|
|
361
|
+
this._registerTypeId("Uint32", Uint32ArrayProperty, "array");
|
|
362
|
+
this._registerTypeId("Int64", Int64ArrayProperty, "array");
|
|
363
|
+
this._registerTypeId("Uint64", Uint64ArrayProperty, "array");
|
|
364
|
+
this._registerTypeId("Float32", Float32ArrayProperty, "array");
|
|
365
|
+
this._registerTypeId("Float64", Float64ArrayProperty, "array");
|
|
366
|
+
this._registerTypeId("String", StringArrayProperty, "array");
|
|
367
|
+
this._registerTypeId("Bool", BoolArrayProperty, "array");
|
|
368
|
+
this._registerTypeId("Reference", ReferenceArrayProperty, "array");
|
|
369
|
+
this._registerTypeId("Enum", EnumArrayProperty, "array");
|
|
357
370
|
// Register the primitive types for the context map
|
|
358
|
-
this._registerTypeId(
|
|
359
|
-
this._registerTypeId(
|
|
360
|
-
this._registerTypeId(
|
|
361
|
-
this._registerTypeId(
|
|
362
|
-
this._registerTypeId(
|
|
363
|
-
this._registerTypeId(
|
|
364
|
-
this._registerTypeId(
|
|
365
|
-
this._registerTypeId(
|
|
366
|
-
this._registerTypeId(
|
|
367
|
-
this._registerTypeId(
|
|
368
|
-
this._registerTypeId(
|
|
369
|
-
this._registerTypeId(
|
|
370
|
-
this._registerTypeId(
|
|
371
|
+
this._registerTypeId("Int8", Int8MapProperty, "map");
|
|
372
|
+
this._registerTypeId("Uint8", Uint8MapProperty, "map");
|
|
373
|
+
this._registerTypeId("Int16", Int16MapProperty, "map");
|
|
374
|
+
this._registerTypeId("Uint16", Uint16MapProperty, "map");
|
|
375
|
+
this._registerTypeId("Int32", Int32MapProperty, "map");
|
|
376
|
+
this._registerTypeId("Uint32", Uint32MapProperty, "map");
|
|
377
|
+
this._registerTypeId("Int64", Int64MapProperty, "map");
|
|
378
|
+
this._registerTypeId("Uint64", Uint64MapProperty, "map");
|
|
379
|
+
this._registerTypeId("Float32", Float32MapProperty, "map");
|
|
380
|
+
this._registerTypeId("Float64", Float64MapProperty, "map");
|
|
381
|
+
this._registerTypeId("Bool", BoolMapProperty, "map");
|
|
382
|
+
this._registerTypeId("String", StringMapProperty, "map");
|
|
383
|
+
this._registerTypeId("Reference", ReferenceMapProperty, "map");
|
|
371
384
|
// Register the default templates
|
|
372
385
|
var NamedPropertyTemplate = {
|
|
373
|
-
typeid:
|
|
374
|
-
properties: [
|
|
375
|
-
{ id: 'guid', typeid: 'String' },
|
|
376
|
-
],
|
|
386
|
+
typeid: "NamedProperty",
|
|
387
|
+
properties: [{ id: "guid", typeid: "String" }],
|
|
377
388
|
};
|
|
378
389
|
var NamedNodePropertyTemplate = {
|
|
379
|
-
typeid:
|
|
380
|
-
inherits: [
|
|
390
|
+
typeid: "NamedNodeProperty",
|
|
391
|
+
inherits: ["NodeProperty", "NamedProperty"],
|
|
381
392
|
};
|
|
382
393
|
var RelationshipPropertyTemplate = {
|
|
383
|
-
typeid:
|
|
384
|
-
inherits: [
|
|
385
|
-
properties: [
|
|
386
|
-
{ id: 'to', typeid: 'Reference' },
|
|
387
|
-
],
|
|
394
|
+
typeid: "RelationshipProperty",
|
|
395
|
+
inherits: ["NodeProperty", "NamedProperty"],
|
|
396
|
+
properties: [{ id: "to", typeid: "Reference" }],
|
|
388
397
|
};
|
|
389
398
|
this._registerTypeId(NamedPropertyTemplate.typeid, NamedPropertyTemplate);
|
|
390
399
|
this._registerTypeId(NamedNodePropertyTemplate.typeid, NamedNodePropertyTemplate);
|
|
@@ -423,21 +432,21 @@ class PropertyFactory {
|
|
|
423
432
|
return !isInvalid;
|
|
424
433
|
};
|
|
425
434
|
var input_array = undefined;
|
|
426
|
-
if (PropertyTemplate.isTemplate(in_input) || typeof in_input ===
|
|
435
|
+
if (PropertyTemplate.isTemplate(in_input) || typeof in_input === "string") {
|
|
427
436
|
input_array = [in_input];
|
|
428
437
|
}
|
|
429
438
|
else if (_.isArray(in_input)) {
|
|
430
439
|
input_array = in_input;
|
|
431
440
|
}
|
|
432
441
|
else {
|
|
433
|
-
throw
|
|
442
|
+
throw new TypeError(MSG.ATTEMPT_TO_REGISTER_WITH_BAD_ARGUMENT);
|
|
434
443
|
}
|
|
435
444
|
if (!validateArray(input_array)) {
|
|
436
|
-
throw
|
|
445
|
+
throw new Error(MSG.ATTEMPT_TO_REGISTER_WITH_BAD_ARGUMENT);
|
|
437
446
|
}
|
|
438
447
|
for (var i = 0; i < input_array.length; i++) {
|
|
439
448
|
var elem = input_array[i];
|
|
440
|
-
if (typeof elem ===
|
|
449
|
+
if (typeof elem === "string") {
|
|
441
450
|
if (!this._localPrimitivePropertiesAndTemplates.has(elem)) {
|
|
442
451
|
if (this.missingDependencies[elem] === undefined) {
|
|
443
452
|
this.missingDependencies[elem] = { requested: false };
|
|
@@ -519,18 +528,19 @@ class PropertyFactory {
|
|
|
519
528
|
var validationResults;
|
|
520
529
|
var warnings = [];
|
|
521
530
|
if (this._localVersionedTemplates.has(typeidWithoutVersion)) {
|
|
522
|
-
var previousLocalVersion = this._localVersionedTemplates
|
|
531
|
+
var previousLocalVersion = this._localVersionedTemplates
|
|
532
|
+
.item(typeidWithoutVersion)
|
|
523
533
|
.getNearestPreviousItem(version);
|
|
524
534
|
if (previousLocalVersion) {
|
|
525
|
-
validationResults = this._templateValidator
|
|
526
|
-
.validate(in_template.serializeCanonical(), previousLocalVersion.serializeCanonical());
|
|
535
|
+
validationResults = this._templateValidator.validate(in_template.serializeCanonical(), previousLocalVersion.serializeCanonical());
|
|
527
536
|
warnings.push.apply(warnings, validationResults.warnings);
|
|
528
537
|
}
|
|
529
538
|
else {
|
|
530
|
-
var nextLocalVersion = this._localVersionedTemplates
|
|
539
|
+
var nextLocalVersion = this._localVersionedTemplates
|
|
540
|
+
.item(typeidWithoutVersion)
|
|
541
|
+
.getNearestNextItem(version);
|
|
531
542
|
if (nextLocalVersion) {
|
|
532
|
-
validationResults = this._templateValidator
|
|
533
|
-
.validate(nextLocalVersion.serializeCanonical(), in_template.serializeCanonical());
|
|
543
|
+
validationResults = this._templateValidator.validate(nextLocalVersion.serializeCanonical(), in_template.serializeCanonical());
|
|
534
544
|
warnings.push.apply(warnings, validationResults.warnings);
|
|
535
545
|
}
|
|
536
546
|
}
|
|
@@ -539,14 +549,17 @@ class PropertyFactory {
|
|
|
539
549
|
var that = this;
|
|
540
550
|
this._remoteScopedAndVersionedTemplates.iterate(function (scope, remoteVersionedTemplates) {
|
|
541
551
|
if (remoteVersionedTemplates.has(typeidWithoutVersion)) {
|
|
542
|
-
var previousRemoteVersion = remoteVersionedTemplates
|
|
552
|
+
var previousRemoteVersion = remoteVersionedTemplates
|
|
553
|
+
.item(typeidWithoutVersion)
|
|
543
554
|
.getNearestPreviousItem(version);
|
|
544
555
|
if (previousRemoteVersion) {
|
|
545
556
|
validationResults = that._templateValidator.validate(in_template.serializeCanonical(), previousRemoteVersion.getPropertyTemplate().serializeCanonical());
|
|
546
557
|
warnings.push.apply(warnings, validationResults.warnings);
|
|
547
558
|
}
|
|
548
559
|
else {
|
|
549
|
-
var nextRemoteVersion = remoteVersionedTemplates
|
|
560
|
+
var nextRemoteVersion = remoteVersionedTemplates
|
|
561
|
+
.item(typeidWithoutVersion)
|
|
562
|
+
.getNearestNextItem(version);
|
|
550
563
|
if (nextRemoteVersion) {
|
|
551
564
|
validationResults = that._templateValidator.validate(nextRemoteVersion.getPropertyTemplate().serializeCanonical(), in_template.serializeCanonical());
|
|
552
565
|
warnings.push.apply(warnings, validationResults.warnings);
|
|
@@ -556,8 +569,10 @@ class PropertyFactory {
|
|
|
556
569
|
});
|
|
557
570
|
}
|
|
558
571
|
if (!_.isEmpty(warnings)) {
|
|
559
|
-
console.warn(
|
|
560
|
-
|
|
572
|
+
console.warn("Template with typeid = " +
|
|
573
|
+
typeid +
|
|
574
|
+
" is valid but with the following warnings = " +
|
|
575
|
+
JSON.stringify(warnings, 0, 2));
|
|
561
576
|
}
|
|
562
577
|
}
|
|
563
578
|
/**
|
|
@@ -579,12 +594,16 @@ class PropertyFactory {
|
|
|
579
594
|
// Template already exists. The incoming template MUST match what is registered.
|
|
580
595
|
// If they do not match, throw an error letting the user know that the templates are incompatible.
|
|
581
596
|
// This is likely due to the fact that the developer did not bump its version.
|
|
582
|
-
var registeredTemplate = this._localPrimitivePropertiesAndTemplates
|
|
597
|
+
var registeredTemplate = this._localPrimitivePropertiesAndTemplates
|
|
598
|
+
.item(typeid)
|
|
599
|
+
.getPropertyTemplate();
|
|
583
600
|
var templateValidator = _createTemplateValidator.call(this);
|
|
584
601
|
var validationResults = templateValidator.validate(registeredTemplate.serializeCanonical(), in_remoteTemplate.serializeCanonical());
|
|
585
602
|
if (!validationResults.isValid) {
|
|
586
|
-
throw new Error(MSG.TEMPLATE_MISMATCH +
|
|
587
|
-
|
|
603
|
+
throw new Error(MSG.TEMPLATE_MISMATCH +
|
|
604
|
+
typeid +
|
|
605
|
+
"\n errors = " +
|
|
606
|
+
JSON.stringify(_extractErrorMessage(validationResults.errors), 0, 2));
|
|
588
607
|
}
|
|
589
608
|
}
|
|
590
609
|
else if (in_remoteTemplate._isVersioned()) {
|
|
@@ -592,8 +611,12 @@ class PropertyFactory {
|
|
|
592
611
|
var wrappedTemplate = new PropertyTemplateWrapper(in_remoteTemplate, in_scope);
|
|
593
612
|
if (this._remoteScopedAndVersionedTemplates.has(in_scope)) {
|
|
594
613
|
if (this._remoteScopedAndVersionedTemplates.item(in_scope).has(typeidWithoutVersion)) {
|
|
595
|
-
if (!this._remoteScopedAndVersionedTemplates
|
|
596
|
-
|
|
614
|
+
if (!this._remoteScopedAndVersionedTemplates
|
|
615
|
+
.item(in_scope)
|
|
616
|
+
.item(typeidWithoutVersion)
|
|
617
|
+
.has(version)) {
|
|
618
|
+
this._remoteScopedAndVersionedTemplates
|
|
619
|
+
.item(in_scope)
|
|
597
620
|
.item(typeidWithoutVersion)
|
|
598
621
|
.add(version, wrappedTemplate);
|
|
599
622
|
}
|
|
@@ -601,7 +624,9 @@ class PropertyFactory {
|
|
|
601
624
|
else {
|
|
602
625
|
var versionCollection = _createVersionedSortedCollection();
|
|
603
626
|
versionCollection.add(version, wrappedTemplate);
|
|
604
|
-
this._remoteScopedAndVersionedTemplates
|
|
627
|
+
this._remoteScopedAndVersionedTemplates
|
|
628
|
+
.item(in_scope)
|
|
629
|
+
.add(typeidWithoutVersion, versionCollection);
|
|
605
630
|
}
|
|
606
631
|
}
|
|
607
632
|
else {
|
|
@@ -613,7 +638,7 @@ class PropertyFactory {
|
|
|
613
638
|
}
|
|
614
639
|
}
|
|
615
640
|
else {
|
|
616
|
-
throw new Error(MSG.UNVERSIONED_REMOTE_TEMPLATE +
|
|
641
|
+
throw new Error(MSG.UNVERSIONED_REMOTE_TEMPLATE + " \n" + JSON.stringify(in_remoteTemplate, 0, 2));
|
|
617
642
|
}
|
|
618
643
|
}
|
|
619
644
|
/**
|
|
@@ -662,19 +687,21 @@ class PropertyFactory {
|
|
|
662
687
|
// If no context is specified we assign one
|
|
663
688
|
if (!in_context) {
|
|
664
689
|
// By default templates are registered for all contexts together, BaseProperties are registered separately
|
|
665
|
-
in_context = in_templateOrProperty instanceof PropertyTemplate ?
|
|
690
|
+
in_context = in_templateOrProperty instanceof PropertyTemplate ? "all" : "single";
|
|
666
691
|
}
|
|
667
|
-
if (in_context !==
|
|
692
|
+
if (in_context !== "all") {
|
|
668
693
|
if (!this._localPrimitivePropertiesAndTemplates.has(in_typeid)) {
|
|
669
694
|
this._localPrimitivePropertiesAndTemplates.add(in_typeid, new Collection());
|
|
670
695
|
}
|
|
671
|
-
this._localPrimitivePropertiesAndTemplates
|
|
696
|
+
this._localPrimitivePropertiesAndTemplates
|
|
697
|
+
.item(in_typeid)
|
|
698
|
+
.add(in_context, in_templateOrProperty);
|
|
672
699
|
}
|
|
673
700
|
else if (!this._localPrimitivePropertiesAndTemplates.has(in_typeid)) {
|
|
674
701
|
var wrapper = new PropertyTemplateWrapper(in_templateOrProperty);
|
|
675
702
|
this._localPrimitivePropertiesAndTemplates.add(in_typeid, wrapper);
|
|
676
703
|
}
|
|
677
|
-
this._eventEmitter.emit(
|
|
704
|
+
this._eventEmitter.emit("registered", in_templateOrProperty);
|
|
678
705
|
}
|
|
679
706
|
/**
|
|
680
707
|
* Validate a template.
|
|
@@ -738,7 +765,7 @@ class PropertyFactory {
|
|
|
738
765
|
return typeidItem;
|
|
739
766
|
}
|
|
740
767
|
else {
|
|
741
|
-
var context = in_context ||
|
|
768
|
+
var context = in_context || "single";
|
|
742
769
|
return this._localPrimitivePropertiesAndTemplates.item(in_typeid).item(context);
|
|
743
770
|
}
|
|
744
771
|
}
|
|
@@ -747,9 +774,17 @@ class PropertyFactory {
|
|
|
747
774
|
if (splitTypeId.version) {
|
|
748
775
|
var typeidWithoutVersion = splitTypeId.typeidWithoutVersion;
|
|
749
776
|
var version = splitTypeId.version;
|
|
750
|
-
if (this._remoteScopedAndVersionedTemplates
|
|
751
|
-
|
|
752
|
-
|
|
777
|
+
if (this._remoteScopedAndVersionedTemplates
|
|
778
|
+
.item(in_scope)
|
|
779
|
+
.has(typeidWithoutVersion) &&
|
|
780
|
+
this._remoteScopedAndVersionedTemplates
|
|
781
|
+
.item(in_scope)
|
|
782
|
+
.item(typeidWithoutVersion)
|
|
783
|
+
.has(version)) {
|
|
784
|
+
return this._remoteScopedAndVersionedTemplates
|
|
785
|
+
.item(in_scope)
|
|
786
|
+
.item(typeidWithoutVersion)
|
|
787
|
+
.item(version);
|
|
753
788
|
}
|
|
754
789
|
}
|
|
755
790
|
}
|
|
@@ -762,7 +797,8 @@ class PropertyFactory {
|
|
|
762
797
|
* @returns {property-properties.PropertyTemplate|undefined} Template identified by the typeid.
|
|
763
798
|
*/
|
|
764
799
|
getTemplate(in_typeid) {
|
|
765
|
-
return this._localPrimitivePropertiesAndTemplates.has(in_typeid) &&
|
|
800
|
+
return this._localPrimitivePropertiesAndTemplates.has(in_typeid) &&
|
|
801
|
+
!TypeIdHelper.isPrimitiveType(in_typeid)
|
|
766
802
|
? this._localPrimitivePropertiesAndTemplates.item(in_typeid).getPropertyTemplate()
|
|
767
803
|
: undefined;
|
|
768
804
|
}
|
|
@@ -780,7 +816,10 @@ class PropertyFactory {
|
|
|
780
816
|
this._remoteScopedAndVersionedTemplates.iterate(function (scope, remoteVersionedTemplates) {
|
|
781
817
|
if (remoteVersionedTemplates.has(typeidWithoutVersion) &&
|
|
782
818
|
remoteVersionedTemplates.item(typeidWithoutVersion).item(version)) {
|
|
783
|
-
templatesFound.push(remoteVersionedTemplates
|
|
819
|
+
templatesFound.push(remoteVersionedTemplates
|
|
820
|
+
.item(typeidWithoutVersion)
|
|
821
|
+
.item(version)
|
|
822
|
+
.getPropertyTemplate());
|
|
784
823
|
}
|
|
785
824
|
});
|
|
786
825
|
return templatesFound;
|
|
@@ -798,7 +837,7 @@ class PropertyFactory {
|
|
|
798
837
|
* @private
|
|
799
838
|
*/
|
|
800
839
|
_createProperty(in_typeid, in_context, in_initialProperties, in_scope) {
|
|
801
|
-
const ifNotSingleOrUndefined = (in_context ||
|
|
840
|
+
const ifNotSingleOrUndefined = (in_context || "single") !== "single";
|
|
802
841
|
ConsoleUtils.assert(ifNotSingleOrUndefined || _.isString(in_typeid), MSG.UNKNOWN_TYPEID_SPECIFIED + in_typeid);
|
|
803
842
|
let context = in_context;
|
|
804
843
|
if (!context) {
|
|
@@ -824,14 +863,15 @@ class PropertyFactory {
|
|
|
824
863
|
propertyDef = {};
|
|
825
864
|
this._createDefFromPropertyDeclaration({
|
|
826
865
|
typeid: in_typeid,
|
|
827
|
-
context: context ||
|
|
866
|
+
context: context || "single",
|
|
828
867
|
}, in_scope, propertyDef);
|
|
829
868
|
}
|
|
830
869
|
let property;
|
|
831
870
|
if (!this._forceInstantion) {
|
|
832
871
|
// If we don't yet have a creation function, we will create one here
|
|
833
|
-
propertyCreationFunction =
|
|
834
|
-
|
|
872
|
+
propertyCreationFunction =
|
|
873
|
+
propertyCreationFunction ||
|
|
874
|
+
this._definePropertyCreationFunction(propertyDef, in_typeid, in_scope, context);
|
|
835
875
|
// Create the property by invoking the precompiled creation function
|
|
836
876
|
property = propertyCreationFunction();
|
|
837
877
|
// If initial properties have been provided, we will assign them to the
|
|
@@ -866,11 +906,13 @@ class PropertyFactory {
|
|
|
866
906
|
_instantiatePropertyDef(propertyDef, in_scope, in_initialProperties) {
|
|
867
907
|
let rootProperty = undefined;
|
|
868
908
|
// This stack is used to recursively iterate over the property definition
|
|
869
|
-
const creationStack = [
|
|
909
|
+
const creationStack = [
|
|
910
|
+
{
|
|
870
911
|
id: undefined,
|
|
871
912
|
entry: propertyDef,
|
|
872
913
|
parent: undefined,
|
|
873
|
-
}
|
|
914
|
+
},
|
|
915
|
+
];
|
|
874
916
|
while (creationStack.length > 0) {
|
|
875
917
|
const currentEntry = creationStack.pop();
|
|
876
918
|
// We have an entry on the stack that is just waiting for its children to finish, but has already
|
|
@@ -883,7 +925,7 @@ class PropertyFactory {
|
|
|
883
925
|
continue;
|
|
884
926
|
}
|
|
885
927
|
// Create the property instance
|
|
886
|
-
let property = new
|
|
928
|
+
let property = new currentEntry.entry.constructorFunction(currentEntry.entry.entry);
|
|
887
929
|
// Insert / append the property to the parent
|
|
888
930
|
if (currentEntry.parent) {
|
|
889
931
|
if (currentEntry.entry.optional) {
|
|
@@ -923,8 +965,7 @@ class PropertyFactory {
|
|
|
923
965
|
parent: property,
|
|
924
966
|
id: id,
|
|
925
967
|
entry: child,
|
|
926
|
-
setGuid: currentEntry.entry.assignGuid && id ===
|
|
927
|
-
'guid',
|
|
968
|
+
setGuid: currentEntry.entry.assignGuid && id === "guid",
|
|
928
969
|
});
|
|
929
970
|
}
|
|
930
971
|
}
|
|
@@ -956,11 +997,13 @@ class PropertyFactory {
|
|
|
956
997
|
*/
|
|
957
998
|
_definePropertyCreationFunction(propertyDef, in_typeid, in_scope, in_context) {
|
|
958
999
|
// This stack is used to recursively iterate over the property definition
|
|
959
|
-
const creationStack = [
|
|
1000
|
+
const creationStack = [
|
|
1001
|
+
{
|
|
960
1002
|
id: null,
|
|
961
1003
|
def: propertyDef,
|
|
962
1004
|
parent: undefined,
|
|
963
|
-
}
|
|
1005
|
+
},
|
|
1006
|
+
];
|
|
964
1007
|
let creationFunctionSource = "";
|
|
965
1008
|
let currentParameterIndex = 0;
|
|
966
1009
|
let parameters = [];
|
|
@@ -973,14 +1016,13 @@ class PropertyFactory {
|
|
|
973
1016
|
// been created
|
|
974
1017
|
if (currentEntry.signalChildrenFinished) {
|
|
975
1018
|
// Add the signalling function
|
|
976
|
-
creationFunctionSource +=
|
|
977
|
-
`${currentEntry.propertyVarname}._signalAllStaticMembersHaveBeenAdded(${JSON.stringify(in_scope)});\n`;
|
|
1019
|
+
creationFunctionSource += `${currentEntry.propertyVarname}._signalAllStaticMembersHaveBeenAdded(${JSON.stringify(in_scope)});\n`;
|
|
978
1020
|
continue;
|
|
979
1021
|
}
|
|
980
1022
|
// Determine the initial value for this property
|
|
981
|
-
let initialValue = currentEntry.def.initialValue !== undefined
|
|
982
|
-
currentEntry.def.initialValue
|
|
983
|
-
undefined;
|
|
1023
|
+
let initialValue = currentEntry.def.initialValue !== undefined
|
|
1024
|
+
? currentEntry.def.initialValue
|
|
1025
|
+
: undefined;
|
|
984
1026
|
if (currentEntry.def.entry.id) {
|
|
985
1027
|
let parentEntry = currentEntry.parentStackEntry;
|
|
986
1028
|
let path = [currentEntry.def.entry.id];
|
|
@@ -1006,7 +1048,7 @@ class PropertyFactory {
|
|
|
1006
1048
|
Object.assign(initialValue.value, filteredChangeSet);
|
|
1007
1049
|
}
|
|
1008
1050
|
else {
|
|
1009
|
-
throw new TypeError(
|
|
1051
|
+
throw new TypeError("Invalid default values specified");
|
|
1010
1052
|
}
|
|
1011
1053
|
}
|
|
1012
1054
|
else if (filteredChangeSet !== undefined) {
|
|
@@ -1037,8 +1079,7 @@ class PropertyFactory {
|
|
|
1037
1079
|
// we use this flag to indicate that for all nested properties, we do not want to use
|
|
1038
1080
|
// the precompiled instantiation functions.
|
|
1039
1081
|
this._forceInstantion = true;
|
|
1040
|
-
instantiatedChild =
|
|
1041
|
-
this._instantiatePropertyDef(currentEntry.def, in_scope, currentEntry.def.initialValue);
|
|
1082
|
+
instantiatedChild = this._instantiatePropertyDef(currentEntry.def, in_scope, currentEntry.def.initialValue);
|
|
1042
1083
|
}
|
|
1043
1084
|
finally {
|
|
1044
1085
|
this._forceInstantion = false;
|
|
@@ -1060,8 +1101,7 @@ class PropertyFactory {
|
|
|
1060
1101
|
// and add the instantiation call to the generated function
|
|
1061
1102
|
currentPropertyNumber++;
|
|
1062
1103
|
currentPropertyVarName = `property${currentPropertyNumber}`;
|
|
1063
|
-
creationFunctionSource +=
|
|
1064
|
-
`const ${currentPropertyVarName} =
|
|
1104
|
+
creationFunctionSource += `const ${currentPropertyVarName} =
|
|
1065
1105
|
new parameters[${currentParameterIndex}](parameters[${currentParameterIndex + 1}]);\n`;
|
|
1066
1106
|
currentParameterIndex += 2;
|
|
1067
1107
|
// Insert / append the property to the parent
|
|
@@ -1110,7 +1150,7 @@ class PropertyFactory {
|
|
|
1110
1150
|
id: id,
|
|
1111
1151
|
def: child,
|
|
1112
1152
|
signalParent: false,
|
|
1113
|
-
setGuid: currentEntry.def.assignGuid && id ===
|
|
1153
|
+
setGuid: currentEntry.def.assignGuid && id === "guid",
|
|
1114
1154
|
parentStackEntry,
|
|
1115
1155
|
});
|
|
1116
1156
|
}
|
|
@@ -1120,12 +1160,12 @@ class PropertyFactory {
|
|
|
1120
1160
|
// we directly assign it here
|
|
1121
1161
|
if (initialValue !== undefined) {
|
|
1122
1162
|
creationFunctionSource += !_.isObject(initialValue.value)
|
|
1123
|
-
// We have a primitive property and thus direclty invoke the setValue function
|
|
1124
|
-
|
|
1125
|
-
// For non primitive properties, we currently use the member on the property factory,
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1163
|
+
? // We have a primitive property and thus direclty invoke the setValue function
|
|
1164
|
+
`${currentPropertyVarName}.setValue(${JSON.stringify(initialValue.value)})\n`
|
|
1165
|
+
: // For non primitive properties, we currently use the member on the property factory,
|
|
1166
|
+
// probably we could further optimize this to directly call the correct function on the
|
|
1167
|
+
// property
|
|
1168
|
+
`this._setInitialValue(${currentPropertyVarName},
|
|
1129
1169
|
${JSON.stringify(initialValue)},
|
|
1130
1170
|
false);\n`;
|
|
1131
1171
|
}
|
|
@@ -1145,7 +1185,7 @@ class PropertyFactory {
|
|
|
1145
1185
|
// Add the return statement at the end of the function
|
|
1146
1186
|
creationFunctionSource += ` return ${resultVarName};`;
|
|
1147
1187
|
// Finally, create the actual JS function with the source we compiled above
|
|
1148
|
-
let creationFunction = new Function(
|
|
1188
|
+
let creationFunction = new Function("parameters", " GuidUtils", creationFunctionSource).bind(this, parameters, GuidUtils);
|
|
1149
1189
|
// Add the created function to the cache
|
|
1150
1190
|
let scopesFunction = this._cachedCreationFunctions.get(in_typeid);
|
|
1151
1191
|
if (!scopesFunction) {
|
|
@@ -1180,11 +1220,12 @@ class PropertyFactory {
|
|
|
1180
1220
|
else if (valueParsed.typed) {
|
|
1181
1221
|
property._setValues(valueParsed.value, true, true);
|
|
1182
1222
|
}
|
|
1183
|
-
else if (
|
|
1223
|
+
else if (property.getTypeid() !== "ContainerProperty" ||
|
|
1224
|
+
property._getChildrenCount() > 0) {
|
|
1184
1225
|
property._setValues(valueParsed.value, false, true);
|
|
1185
1226
|
}
|
|
1186
1227
|
else if (!valueParsed.typeid) {
|
|
1187
|
-
throw new Error(MSG.FIELD_TYPEID_IS_REQUIRED + property._id +
|
|
1228
|
+
throw new Error(MSG.FIELD_TYPEID_IS_REQUIRED + property._id + ".typeid");
|
|
1188
1229
|
}
|
|
1189
1230
|
else {
|
|
1190
1231
|
property._setValues(valueParsed.value, false, true);
|
|
@@ -1220,14 +1261,12 @@ class PropertyFactory {
|
|
|
1220
1261
|
*/
|
|
1221
1262
|
_getConstructorFunctionForTypeidAndID(in_context, in_typeid, in_baseConstructor, in_id, in_scope) {
|
|
1222
1263
|
// Create a unique key for this constructor
|
|
1223
|
-
let key = in_context ===
|
|
1224
|
-
in_typeid :
|
|
1225
|
-
in_context + '<' + in_typeid + '>';
|
|
1264
|
+
let key = in_context === "single" ? in_typeid : in_context + "<" + in_typeid + ">";
|
|
1226
1265
|
if (in_id !== undefined) {
|
|
1227
|
-
key = key +
|
|
1266
|
+
key = key + "-" + in_id;
|
|
1228
1267
|
}
|
|
1229
1268
|
if (in_scope && !this._localPrimitivePropertiesAndTemplates.has(in_typeid)) {
|
|
1230
|
-
key +=
|
|
1269
|
+
key += "-" + in_scope;
|
|
1231
1270
|
}
|
|
1232
1271
|
// Check, whether we already have this function in the cache
|
|
1233
1272
|
if (this._typedPropertyConstructorCache[key]) {
|
|
@@ -1241,7 +1280,9 @@ class PropertyFactory {
|
|
|
1241
1280
|
var propertyConstructorFunction = class extends in_baseConstructor {
|
|
1242
1281
|
};
|
|
1243
1282
|
propertyConstructorFunction.prototype._typeid = in_typeid;
|
|
1244
|
-
Object.defineProperty(propertyConstructorFunction,
|
|
1283
|
+
Object.defineProperty(propertyConstructorFunction, "name", {
|
|
1284
|
+
value: in_baseConstructor.name,
|
|
1285
|
+
});
|
|
1245
1286
|
if (in_id !== undefined) {
|
|
1246
1287
|
propertyConstructorFunction.prototype._id = in_id;
|
|
1247
1288
|
}
|
|
@@ -1267,34 +1308,34 @@ class PropertyFactory {
|
|
|
1267
1308
|
typeid: in_typeid,
|
|
1268
1309
|
id: in_id,
|
|
1269
1310
|
};
|
|
1270
|
-
if (this.inheritsFrom(in_typeid,
|
|
1311
|
+
if (this.inheritsFrom(in_typeid, "NamedProperty", { scope: in_scope })) {
|
|
1271
1312
|
// An id of NULL means that the GUID of the property is used if it is a named property
|
|
1272
1313
|
params.id = in_id || null;
|
|
1273
1314
|
}
|
|
1274
1315
|
const wrapper = this._getWrapper(in_typeid, undefined, in_scope);
|
|
1275
1316
|
const creationType = wrapper.getCreationType();
|
|
1276
1317
|
switch (creationType) {
|
|
1277
|
-
case
|
|
1318
|
+
case "Enum":
|
|
1278
1319
|
params._enumDictionary = in_templateOrConstructor._enumDictionary;
|
|
1279
1320
|
ConstructorFunction = EnumProperty;
|
|
1280
1321
|
break;
|
|
1281
|
-
case
|
|
1322
|
+
case "NodeProperty":
|
|
1282
1323
|
ConstructorFunction = NodeProperty;
|
|
1283
|
-
params.typeid = params.typeid ||
|
|
1324
|
+
params.typeid = params.typeid || "NodeProperty";
|
|
1284
1325
|
break;
|
|
1285
|
-
case
|
|
1326
|
+
case "NamedProperty":
|
|
1286
1327
|
ConstructorFunction = NamedProperty;
|
|
1287
|
-
params.typeid = params.typeid ||
|
|
1328
|
+
params.typeid = params.typeid || "NamedProperty";
|
|
1288
1329
|
break;
|
|
1289
1330
|
default:
|
|
1290
1331
|
ConstructorFunction = ContainerProperty;
|
|
1291
|
-
params.typeid = params.typeid ||
|
|
1332
|
+
params.typeid = params.typeid || "ContainerProperty";
|
|
1292
1333
|
}
|
|
1293
|
-
ConstructorFunction = this._getConstructorFunctionForTypeidAndID(
|
|
1334
|
+
ConstructorFunction = this._getConstructorFunctionForTypeidAndID("single", in_typeid, ConstructorFunction, in_id, in_scope);
|
|
1294
1335
|
propertyDef.constructorFunction = ConstructorFunction;
|
|
1295
1336
|
propertyDef.signal = true;
|
|
1296
1337
|
propertyDef.entry = params;
|
|
1297
|
-
propertyDef.context =
|
|
1338
|
+
propertyDef.context = "single";
|
|
1298
1339
|
propertyDef.typeid = in_typeid;
|
|
1299
1340
|
}
|
|
1300
1341
|
/**
|
|
@@ -1317,7 +1358,7 @@ class PropertyFactory {
|
|
|
1317
1358
|
* @private
|
|
1318
1359
|
*/
|
|
1319
1360
|
_hasCorrespondingRegisteredTypeid(in_typeid, in_scope) {
|
|
1320
|
-
if (in_typeid.includes(
|
|
1361
|
+
if (in_typeid.includes("-")) {
|
|
1321
1362
|
return this._isRegisteredTypeid(in_typeid, in_scope);
|
|
1322
1363
|
}
|
|
1323
1364
|
var registered = this._localVersionedTemplates.has(in_typeid) ||
|
|
@@ -1353,19 +1394,20 @@ class PropertyFactory {
|
|
|
1353
1394
|
*/
|
|
1354
1395
|
_computeTypeid(in_propertiesEntry, in_scope, context) {
|
|
1355
1396
|
var typeid = in_propertiesEntry.typeid;
|
|
1356
|
-
if (context ===
|
|
1397
|
+
if (context === "single") {
|
|
1357
1398
|
var valueParsed = this._parseTypedValue(in_propertiesEntry, in_scope, context);
|
|
1358
|
-
if (
|
|
1399
|
+
if (valueParsed.typed && valueParsed.typeid) {
|
|
1359
1400
|
typeid = in_propertiesEntry.typedValue.typeid;
|
|
1360
1401
|
}
|
|
1361
1402
|
}
|
|
1362
1403
|
// We create a polymorphic collection (one inheriting from BaseProperty), if no typeid is specified
|
|
1363
1404
|
// but a context is given
|
|
1364
|
-
if (!typeid && context !==
|
|
1365
|
-
typeid = context !==
|
|
1405
|
+
if (!typeid && context !== "single") {
|
|
1406
|
+
typeid = context !== "set" ? "ContainerProperty" : "NamedProperty";
|
|
1366
1407
|
}
|
|
1367
|
-
if (in_propertiesEntry.typeid &&
|
|
1368
|
-
typeid
|
|
1408
|
+
if (in_propertiesEntry.typeid &&
|
|
1409
|
+
TypeIdHelper.isReferenceTypeId(in_propertiesEntry.typeid)) {
|
|
1410
|
+
typeid = "Reference";
|
|
1369
1411
|
}
|
|
1370
1412
|
return typeid;
|
|
1371
1413
|
}
|
|
@@ -1382,18 +1424,21 @@ class PropertyFactory {
|
|
|
1382
1424
|
* @param {Object} out_propertyDef - The created property definition
|
|
1383
1425
|
*/
|
|
1384
1426
|
_createDefFromPropertyDeclaration(in_propertiesEntry, in_scope, out_propertyDef) {
|
|
1385
|
-
var context = in_propertiesEntry.context !== undefined ? in_propertiesEntry.context :
|
|
1427
|
+
var context = in_propertiesEntry.context !== undefined ? in_propertiesEntry.context : "single";
|
|
1386
1428
|
var typeid = this._computeTypeid(in_propertiesEntry, in_scope, context);
|
|
1387
|
-
var referenceTarget = typeid ===
|
|
1388
|
-
TypeIdHelper.extractReferenceTargetTypeIdFromReference(in_propertiesEntry.typeid)
|
|
1429
|
+
var referenceTarget = typeid === "Reference"
|
|
1430
|
+
? TypeIdHelper.extractReferenceTargetTypeIdFromReference(in_propertiesEntry.typeid)
|
|
1431
|
+
: undefined;
|
|
1389
1432
|
if (typeid) {
|
|
1390
1433
|
if (this._isRegisteredTypeid(typeid, in_scope) &&
|
|
1391
|
-
(!referenceTarget ||
|
|
1434
|
+
(!referenceTarget ||
|
|
1435
|
+
this._hasCorrespondingRegisteredTypeid(referenceTarget, in_scope))) {
|
|
1392
1436
|
var templateOrConstructor = this._get(typeid, context, in_scope);
|
|
1393
1437
|
var isSpecializedConstructor = this._isSpecializedConstructor(typeid);
|
|
1394
1438
|
if (this._isNativePropertyConstructor(templateOrConstructor) &&
|
|
1395
|
-
(isSpecializedConstructor || context ===
|
|
1396
|
-
if (TypeIdHelper.isReferenceTypeId(typeid) ||
|
|
1439
|
+
(isSpecializedConstructor || context === "single")) {
|
|
1440
|
+
if (TypeIdHelper.isReferenceTypeId(typeid) ||
|
|
1441
|
+
in_propertiesEntry.id !== undefined) {
|
|
1397
1442
|
templateOrConstructor = this._getConstructorFunctionForTypeidAndID(in_propertiesEntry.context, in_propertiesEntry.typeid, templateOrConstructor, in_propertiesEntry.id, in_scope);
|
|
1398
1443
|
}
|
|
1399
1444
|
out_propertyDef.constructorFunction = templateOrConstructor;
|
|
@@ -1408,22 +1453,23 @@ class PropertyFactory {
|
|
|
1408
1453
|
else {
|
|
1409
1454
|
const templateWrapper = this._getWrapper(typeid, context, in_scope);
|
|
1410
1455
|
templateOrConstructor = templateWrapper.getCompiledTemplate(this);
|
|
1411
|
-
if (context ===
|
|
1456
|
+
if (context === "single") {
|
|
1412
1457
|
// If we have a template in a single context, we create it directly here
|
|
1413
1458
|
// Create the base object
|
|
1414
1459
|
this._createNonCollectionPropertyDef(typeid, in_propertiesEntry.id, templateOrConstructor, in_scope, out_propertyDef);
|
|
1415
|
-
this._parseTemplate(templateOrConstructor, in_scope, !!
|
|
1460
|
+
this._parseTemplate(templateOrConstructor, in_scope, !!templateOrConstructor.inherits, out_propertyDef);
|
|
1416
1461
|
}
|
|
1417
1462
|
else {
|
|
1418
1463
|
// If we have other contexts, we have to create the corresponding property object for that context
|
|
1419
1464
|
// check if a specialized collection is needed
|
|
1420
|
-
var isEnum = this.inheritsFrom(typeid,
|
|
1465
|
+
var isEnum = this.inheritsFrom(typeid, "Enum", { scope: in_scope });
|
|
1421
1466
|
var constructorFunction;
|
|
1422
1467
|
switch (context) {
|
|
1423
|
-
case
|
|
1468
|
+
case "array":
|
|
1424
1469
|
if (isEnum) {
|
|
1425
1470
|
var enumPropertyEntry = deepCopy(in_propertiesEntry);
|
|
1426
|
-
enumPropertyEntry._enumDictionary =
|
|
1471
|
+
enumPropertyEntry._enumDictionary =
|
|
1472
|
+
templateOrConstructor._enumDictionary;
|
|
1427
1473
|
in_propertiesEntry = enumPropertyEntry;
|
|
1428
1474
|
constructorFunction = EnumArrayProperty;
|
|
1429
1475
|
}
|
|
@@ -1431,15 +1477,15 @@ class PropertyFactory {
|
|
|
1431
1477
|
constructorFunction = ArrayProperty;
|
|
1432
1478
|
}
|
|
1433
1479
|
break;
|
|
1434
|
-
case
|
|
1480
|
+
case "set":
|
|
1435
1481
|
// Validate that a set inherit from a NamedProperty
|
|
1436
1482
|
var typeid = in_propertiesEntry.typeid;
|
|
1437
|
-
if (!this.inheritsFrom(typeid,
|
|
1483
|
+
if (!this.inheritsFrom(typeid, "NamedProperty", { scope: in_scope })) {
|
|
1438
1484
|
throw new Error(MSG.SET_ONLY_NAMED_PROPS + typeid);
|
|
1439
1485
|
}
|
|
1440
1486
|
constructorFunction = SetProperty;
|
|
1441
1487
|
break;
|
|
1442
|
-
case
|
|
1488
|
+
case "map":
|
|
1443
1489
|
constructorFunction = MapProperty;
|
|
1444
1490
|
break;
|
|
1445
1491
|
default:
|
|
@@ -1466,17 +1512,17 @@ class PropertyFactory {
|
|
|
1466
1512
|
in_propertiesEntry.properties = [];
|
|
1467
1513
|
}
|
|
1468
1514
|
// If this is a declaration which contains a properties list, we have to create a new container property for it
|
|
1469
|
-
let copiedPropertyEntry = Object.assign({ typeid:
|
|
1515
|
+
let copiedPropertyEntry = Object.assign({ typeid: "ContainerProperty" }, in_propertiesEntry);
|
|
1470
1516
|
out_propertyDef.constructorFunction = ContainerProperty;
|
|
1471
1517
|
out_propertyDef.entry = copiedPropertyEntry;
|
|
1472
1518
|
out_propertyDef.signal = false;
|
|
1473
1519
|
out_propertyDef.typeid = copiedPropertyEntry.typeid;
|
|
1474
|
-
out_propertyDef.context =
|
|
1520
|
+
out_propertyDef.context = "single";
|
|
1475
1521
|
// And then parse the entry like a template
|
|
1476
1522
|
this._parseTemplate(in_propertiesEntry, in_scope, false, out_propertyDef);
|
|
1477
1523
|
}
|
|
1478
1524
|
// If this property inherits from NamedProperty we assign a random GUID
|
|
1479
|
-
if (typeid && this.inheritsFrom(typeid,
|
|
1525
|
+
if (typeid && this.inheritsFrom(typeid, "NamedProperty", { scope: in_scope })) {
|
|
1480
1526
|
out_propertyDef.assignGuid = true;
|
|
1481
1527
|
}
|
|
1482
1528
|
}
|
|
@@ -1490,7 +1536,7 @@ class PropertyFactory {
|
|
|
1490
1536
|
_isNativePropertyConstructor(in_obj) {
|
|
1491
1537
|
// TODO: This tests seems dangerous. I think it is based on the assumption that constructor is not
|
|
1492
1538
|
// overwritten in the derived classes (which it probably should be)
|
|
1493
|
-
return
|
|
1539
|
+
return in_obj.constructor && in_obj.constructor === ContainerProperty.constructor;
|
|
1494
1540
|
}
|
|
1495
1541
|
/**
|
|
1496
1542
|
* Checks whether the property has a typedValue and replaces the value and the typeid
|
|
@@ -1509,19 +1555,21 @@ class PropertyFactory {
|
|
|
1509
1555
|
typeid: in_property.typeid,
|
|
1510
1556
|
};
|
|
1511
1557
|
if (in_property.typedValue) {
|
|
1512
|
-
var typeid = in_property.typeid ||
|
|
1558
|
+
var typeid = in_property.typeid || "ContainerProperty";
|
|
1513
1559
|
// Setting typedValue to a primitive is not supported
|
|
1514
1560
|
if (TypeIdHelper.isPrimitiveType(typeid)) {
|
|
1515
1561
|
throw new Error(MSG.TYPED_VALUES_FOR_PRIMITIVES_NOT_SUPPORTED + in_property.id);
|
|
1516
1562
|
}
|
|
1517
1563
|
res.typed = true;
|
|
1518
|
-
if (in_context ===
|
|
1564
|
+
if (in_context === "single") {
|
|
1519
1565
|
if (!in_property.typedValue.typeid) {
|
|
1520
|
-
throw new Error(MSG.FIELD_TYPEID_IS_REQUIRED +
|
|
1566
|
+
throw new Error(MSG.FIELD_TYPEID_IS_REQUIRED + "typedValue " + typeid);
|
|
1521
1567
|
}
|
|
1522
1568
|
if (!this.inheritsFrom(in_property.typedValue.typeid, typeid, { scope: in_scope })) {
|
|
1523
1569
|
throw new Error(MSG.TYPED_VALUES_MUST_DERIVE_FROM_BASE_TYPE +
|
|
1524
|
-
in_property.typedValue.typeid +
|
|
1570
|
+
in_property.typedValue.typeid +
|
|
1571
|
+
" must be a subclass of " +
|
|
1572
|
+
typeid);
|
|
1525
1573
|
}
|
|
1526
1574
|
res.value = in_property.typedValue.value;
|
|
1527
1575
|
res.typeid = in_property.typedValue.typeid;
|
|
@@ -1544,13 +1592,13 @@ class PropertyFactory {
|
|
|
1544
1592
|
*/
|
|
1545
1593
|
_parseTemplate(in_template, in_scope, in_allowChildMerges, propertyDef) {
|
|
1546
1594
|
// Check if there are nested property arrays
|
|
1547
|
-
if (!(in_template.inherits && in_template.inherits.indexOf(
|
|
1595
|
+
if (!(in_template.inherits && in_template.inherits.indexOf("Enum") !== -1)) {
|
|
1548
1596
|
if (in_template.properties) {
|
|
1549
1597
|
const properties = in_template.properties;
|
|
1550
1598
|
for (let i = 0; i < properties.length; i++) {
|
|
1551
1599
|
const id = properties[i].id;
|
|
1552
|
-
const typeid = properties[i].typeid ||
|
|
1553
|
-
const context = properties[i].context ||
|
|
1600
|
+
const typeid = properties[i].typeid || "ContainerProperty";
|
|
1601
|
+
const context = properties[i].context || "single";
|
|
1554
1602
|
const optional = properties[i].optional || false;
|
|
1555
1603
|
const valueParsed = this._parseTypedValue(properties[i], in_scope, context);
|
|
1556
1604
|
if (optional) {
|
|
@@ -1581,7 +1629,7 @@ class PropertyFactory {
|
|
|
1581
1629
|
if (in_template.constants) {
|
|
1582
1630
|
const constants = in_template.constants;
|
|
1583
1631
|
for (let i = 0; i < constants.length; i++) {
|
|
1584
|
-
const context = constants[i].context ||
|
|
1632
|
+
const context = constants[i].context || "single";
|
|
1585
1633
|
const valueParsed = this._parseTypedValue(constants[i], in_scope, context);
|
|
1586
1634
|
const newChildEntry = {
|
|
1587
1635
|
initialValue: undefined,
|
|
@@ -1662,9 +1710,9 @@ class PropertyFactory {
|
|
|
1662
1710
|
in_options = in_options || {};
|
|
1663
1711
|
// We just forward the request to the internal function
|
|
1664
1712
|
var parents = {};
|
|
1665
|
-
var scope = in_options.workspace
|
|
1666
|
-
in_options.workspace.getRoot()._getCheckedOutRepositoryInfo().getScope()
|
|
1667
|
-
in_options.scope;
|
|
1713
|
+
var scope = in_options.workspace
|
|
1714
|
+
? in_options.workspace.getRoot()._getCheckedOutRepositoryInfo().getScope()
|
|
1715
|
+
: in_options.scope;
|
|
1668
1716
|
this._getAllParentsForTemplateInternal(in_typeid, parents, !!in_options.includeBaseProperty, scope);
|
|
1669
1717
|
return _.keys(parents);
|
|
1670
1718
|
}
|
|
@@ -1681,8 +1729,8 @@ class PropertyFactory {
|
|
|
1681
1729
|
if (TypeIdHelper.isPrimitiveType(in_typeid)) {
|
|
1682
1730
|
// Everything inherits from BaseProperty.
|
|
1683
1731
|
if (in_includeBaseProperty) {
|
|
1684
|
-
out_parents[
|
|
1685
|
-
out_parents[
|
|
1732
|
+
out_parents["AbstractStaticCollectionProperty"] = true;
|
|
1733
|
+
out_parents["BaseProperty"] = true;
|
|
1686
1734
|
}
|
|
1687
1735
|
return;
|
|
1688
1736
|
}
|
|
@@ -1692,8 +1740,8 @@ class PropertyFactory {
|
|
|
1692
1740
|
}
|
|
1693
1741
|
// Everything inherits from BaseProperty.
|
|
1694
1742
|
if (in_includeBaseProperty) {
|
|
1695
|
-
out_parents[
|
|
1696
|
-
out_parents[
|
|
1743
|
+
out_parents["AbstractStaticCollectionProperty"] = true;
|
|
1744
|
+
out_parents["BaseProperty"] = true;
|
|
1697
1745
|
}
|
|
1698
1746
|
// Run over all parents and insert them into the parents array
|
|
1699
1747
|
if (template.inherits) {
|
|
@@ -1758,26 +1806,29 @@ class PropertyFactory {
|
|
|
1758
1806
|
registerLocal.call(this, in_template);
|
|
1759
1807
|
}
|
|
1760
1808
|
/**
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1809
|
+
* Initializes the schema store.
|
|
1810
|
+
* @public
|
|
1811
|
+
* @param {Object} in_options - the store settings.
|
|
1812
|
+
* @param {getBearerTokenFn} in_options.getBearerToken - Function that accepts a callback.
|
|
1813
|
+
* Function that should be called with an error or the OAuth2 bearer token representing the user.
|
|
1814
|
+
* @param {string} in_options.url - The root of the url used in the request to retrieve PropertySet schemas.
|
|
1815
|
+
*
|
|
1816
|
+
* @returns {Promise} Return an empty promise when checkout resolve or reject with error.
|
|
1817
|
+
*/
|
|
1770
1818
|
async initializeSchemaStore(in_options) {
|
|
1771
1819
|
// https://regex101.com/r/TlgGJp/2
|
|
1772
1820
|
var regexBaseUrl = /^(https?:)?\/\/((.[-a-zA-Z0-9@:%_+~#=.]{2,256}){1,2}\.[a-z]{2,6}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d{1,5})?(\/[-a-zA-Z0-9@:%_+.~#?&/=]*)*$/;
|
|
1773
|
-
if (!in_options ||
|
|
1821
|
+
if (!in_options ||
|
|
1822
|
+
!in_options.getBearerToken ||
|
|
1823
|
+
!_.isFunction(in_options.getBearerToken) ||
|
|
1824
|
+
!in_options.url) {
|
|
1774
1825
|
return Promise.reject(new Error(MSG.MISSING_FSS_INIT_OPTIONS));
|
|
1775
1826
|
}
|
|
1776
1827
|
if (!regexBaseUrl.test(in_options.url)) {
|
|
1777
1828
|
return Promise.reject(new Error(MSG.FSS_BASEURL_WRONG));
|
|
1778
1829
|
}
|
|
1779
|
-
if (in_options.url.slice(-1) !==
|
|
1780
|
-
in_options.url = in_options.url +
|
|
1830
|
+
if (in_options.url.slice(-1) !== "/") {
|
|
1831
|
+
in_options.url = in_options.url + "/";
|
|
1781
1832
|
}
|
|
1782
1833
|
this._templateStore = new ForgeSchemaStore(in_options);
|
|
1783
1834
|
return Promise.resolve();
|
|
@@ -1793,9 +1844,12 @@ class PropertyFactory {
|
|
|
1793
1844
|
_retrieveTemplateRequestWorker(in_task, in_callback) {
|
|
1794
1845
|
var store = in_task.context;
|
|
1795
1846
|
if (store) {
|
|
1796
|
-
store
|
|
1847
|
+
store
|
|
1848
|
+
.retrieveTemplate(in_task.typeid)
|
|
1849
|
+
.then(function (response) {
|
|
1797
1850
|
in_callback(response);
|
|
1798
|
-
})
|
|
1851
|
+
})
|
|
1852
|
+
.catch(function (error) {
|
|
1799
1853
|
in_callback({ error: error });
|
|
1800
1854
|
});
|
|
1801
1855
|
}
|
|
@@ -1834,7 +1888,8 @@ class PropertyFactory {
|
|
|
1834
1888
|
var that = this;
|
|
1835
1889
|
// 0. Inspect locally registered templates for unknown dependencies
|
|
1836
1890
|
this._localPrimitivePropertiesAndTemplates.iterate(function (key, type) {
|
|
1837
|
-
if (!that._isSpecializedConstructor(key) &&
|
|
1891
|
+
if (!that._isSpecializedConstructor(key) &&
|
|
1892
|
+
PropertyTemplate.isTemplate(type.getPropertyTemplate())) {
|
|
1838
1893
|
var unknownDeps = _extractUnknownDependencies.call(that, type.getPropertyTemplate());
|
|
1839
1894
|
for (var d = 0; d < unknownDeps.length; d++) {
|
|
1840
1895
|
var dep = unknownDeps[d];
|
|
@@ -1864,7 +1919,7 @@ class PropertyFactory {
|
|
|
1864
1919
|
}
|
|
1865
1920
|
else {
|
|
1866
1921
|
that.templateRequestsQueue.drain = function () {
|
|
1867
|
-
var errors = _.compact(_.pluck(that.templateRequestsResults.errors,
|
|
1922
|
+
var errors = _.compact(_.pluck(that.templateRequestsResults.errors, "typeid"));
|
|
1868
1923
|
var results = that.templateRequestsResults;
|
|
1869
1924
|
var resultsKeys = Object.keys(that.templateRequestsResults.schemas);
|
|
1870
1925
|
var tempMissingDependencies = [];
|
|
@@ -1877,14 +1932,15 @@ class PropertyFactory {
|
|
|
1877
1932
|
if (compiledTemplate.constants) {
|
|
1878
1933
|
for (var s = 0; s < compiledTemplate.constants.length; s++) {
|
|
1879
1934
|
tempConstant = compiledTemplate.constants[s];
|
|
1880
|
-
if (tempConstant.contextKeyType ===
|
|
1881
|
-
tempConstant.context ===
|
|
1935
|
+
if (tempConstant.contextKeyType === "typeid" &&
|
|
1936
|
+
tempConstant.context === "map" &&
|
|
1882
1937
|
tempConstant.value) {
|
|
1883
1938
|
var valueKeys = Object.keys(tempConstant.value);
|
|
1884
1939
|
for (var z = 0; z < valueKeys.length; z++) {
|
|
1885
1940
|
if (TypeIdHelper.isTemplateTypeid(valueKeys[z]) &&
|
|
1886
|
-
!(valueKeys[z] in
|
|
1887
|
-
|
|
1941
|
+
!(valueKeys[z] in
|
|
1942
|
+
that.templateRequestsResults.schemas) &&
|
|
1943
|
+
!tempMissingDependencies.includes(valueKeys[z])) {
|
|
1888
1944
|
tempMissingDependencies.push(valueKeys[z]);
|
|
1889
1945
|
}
|
|
1890
1946
|
}
|
|
@@ -1901,7 +1957,8 @@ class PropertyFactory {
|
|
|
1901
1957
|
if (that.templateRequestsResults.errors[missingTypeid] === undefined) {
|
|
1902
1958
|
that.templateRequestsResults.errors[missingTypeid] = {};
|
|
1903
1959
|
}
|
|
1904
|
-
if (that.templateRequestsResults.schemas[missingTypeid] ===
|
|
1960
|
+
if (that.templateRequestsResults.schemas[missingTypeid] ===
|
|
1961
|
+
undefined) {
|
|
1905
1962
|
that.templateRequestsResults.schemas[missingTypeid] = {};
|
|
1906
1963
|
}
|
|
1907
1964
|
}
|
|
@@ -1911,7 +1968,7 @@ class PropertyFactory {
|
|
|
1911
1968
|
if (that.templateRequestsQueue.length() === 0) {
|
|
1912
1969
|
that.templateRequestsResults = { errors: {}, schemas: {} };
|
|
1913
1970
|
if (errors.length && errors.length > 0) {
|
|
1914
|
-
reject(new Error(
|
|
1971
|
+
reject(new Error("Some errors occured"));
|
|
1915
1972
|
}
|
|
1916
1973
|
else {
|
|
1917
1974
|
that.missingDependencies = {};
|