@fluid-experimental/property-changeset 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1
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/changeset.d.ts +2 -2
- package/dist/changeset.d.ts.map +1 -1
- package/dist/changeset.js +61 -45
- package/dist/changeset.js.map +1 -1
- package/dist/changeset_operations/array.d.ts +6 -6
- package/dist/changeset_operations/array.d.ts.map +1 -1
- package/dist/changeset_operations/array.js +87 -56
- package/dist/changeset_operations/array.js.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.js +43 -41
- package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/dist/changeset_operations/indexedCollection.js +76 -44
- package/dist/changeset_operations/indexedCollection.js.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.js +2 -1
- package/dist/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/dist/changeset_operations/operationTypes.d.ts.map +1 -1
- package/dist/changeset_operations/operationTypes.js.map +1 -1
- package/dist/helpers/typeidHelper.d.ts +10 -10
- package/dist/helpers/typeidHelper.d.ts.map +1 -1
- package/dist/helpers/typeidHelper.js +19 -17
- package/dist/helpers/typeidHelper.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/isReservedKeyword.d.ts.map +1 -1
- package/dist/isReservedKeyword.js.map +1 -1
- package/dist/pathHelper.d.ts.map +1 -1
- package/dist/pathHelper.js +16 -10
- package/dist/pathHelper.js.map +1 -1
- package/dist/rebase.d.ts.map +1 -1
- package/dist/rebase.js +20 -13
- package/dist/rebase.js.map +1 -1
- package/dist/templateSchema.d.ts.map +1 -1
- package/dist/templateSchema.js +10 -11
- package/dist/templateSchema.js.map +1 -1
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +135 -102
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +141 -343
- package/dist/test/array.spec.js.map +1 -1
- package/dist/test/pathHelper.spec.js +299 -166
- package/dist/test/pathHelper.spec.js.map +1 -1
- package/dist/test/reversibleCs.spec.js.map +1 -1
- package/dist/test/schemaValidator.js +3 -1
- package/dist/test/schemaValidator.js.map +1 -1
- package/dist/test/schemas/badBothPropertiesAndTypeid.js +8 -8
- package/dist/test/schemas/badBothPropertiesAndTypeid.js.map +1 -1
- package/dist/test/schemas/badInvalidSemverInTypeid.js +18 -16
- package/dist/test/schemas/badInvalidSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badMissingSemverInTypeid.js +18 -16
- package/dist/test/schemas/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badNestedProperties.js +18 -17
- package/dist/test/schemas/badNestedProperties.js.map +1 -1
- package/dist/test/schemas/badPrimitiveTypeid.js +9 -8
- package/dist/test/schemas/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/schemas/badVersionedTypeid.js +19 -17
- package/dist/test/schemas/badVersionedTypeid.js.map +1 -1
- package/dist/test/schemas/goodColorPalette.js +4 -4
- package/dist/test/schemas/goodColorPalette.js.map +1 -1
- package/dist/test/schemas/goodDraftAsVersion.js +2 -4
- package/dist/test/schemas/goodDraftAsVersion.js.map +1 -1
- package/dist/test/schemas/goodPointId.js +18 -16
- package/dist/test/schemas/goodPointId.js.map +1 -1
- package/dist/test/schemas/goodReferenceAndRegular.js +5 -5
- package/dist/test/schemas/goodReferenceAndRegular.js.map +1 -1
- package/dist/test/schemas/goodReservedTypes.js +8 -7
- package/dist/test/schemas/goodReservedTypes.js.map +1 -1
- package/dist/test/schemas/goodUIBorder.js +19 -16
- package/dist/test/schemas/goodUIBorder.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/test/validator/templateSyntax.spec.js.map +1 -1
- package/dist/test/validator/templateValidator.spec.js +329 -306
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/test/validator/typeidHelper.spec.js +98 -65
- package/dist/test/validator/typeidHelper.spec.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +149 -95
- package/dist/utils.js.map +1 -1
- package/dist/validationResultBuilder.d.ts.map +1 -1
- package/dist/validationResultBuilder.js.map +1 -1
- package/lib/changeset.js +63 -47
- package/lib/changeset.js.map +1 -1
- package/lib/changeset_operations/array.js +88 -57
- package/lib/changeset_operations/array.js.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.js +43 -41
- package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/lib/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/lib/changeset_operations/indexedCollection.js +76 -44
- package/lib/changeset_operations/indexedCollection.js.map +1 -1
- package/lib/changeset_operations/isEmptyChangeset.js +2 -1
- package/lib/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/lib/changeset_operations/operationTypes.js.map +1 -1
- package/lib/helpers/typeidHelper.js +19 -17
- package/lib/helpers/typeidHelper.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/isReservedKeyword.js.map +1 -1
- package/lib/pathHelper.js +17 -11
- package/lib/pathHelper.js.map +1 -1
- package/lib/rebase.js +20 -13
- package/lib/rebase.js.map +1 -1
- package/lib/templateSchema.js +10 -11
- package/lib/templateSchema.js.map +1 -1
- package/lib/templateValidator.js +135 -102
- package/lib/templateValidator.js.map +1 -1
- package/lib/utils.js +149 -95
- package/lib/utils.js.map +1 -1
- package/lib/validationResultBuilder.js.map +1 -1
- package/package.json +100 -100
|
@@ -184,8 +184,10 @@ const _psetDeepEquals = function (in_source, in_target) {
|
|
|
184
184
|
// A template with abstract properties must equal one with an empty properties array
|
|
185
185
|
// We check the difference in keys between the source and target and if the only difference is the
|
|
186
186
|
// properties array we check if it's empty. Then we reverse the condition so it work both ways.
|
|
187
|
-
if (((0, isEqual_1.default)((0, difference_1.default)(keysTarget, keysSource), ["properties"]) &&
|
|
188
|
-
|
|
187
|
+
if (((0, isEqual_1.default)((0, difference_1.default)(keysTarget, keysSource), ["properties"]) &&
|
|
188
|
+
!target.properties.length) ||
|
|
189
|
+
((0, isEqual_1.default)((0, difference_1.default)(keysSource, keysTarget), ["properties"]) &&
|
|
190
|
+
!source.properties.length)) {
|
|
189
191
|
return _getPSetDeepEqualsResult(true);
|
|
190
192
|
}
|
|
191
193
|
return _getPSetDeepEqualsResult(false);
|
|
@@ -297,40 +299,42 @@ const _validatePositiveIncrement = function (in_template, in_templatePrevious, i
|
|
|
297
299
|
}
|
|
298
300
|
if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {
|
|
299
301
|
// Violates rule 6 (warning).
|
|
300
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
302
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
303
|
+
JSON.stringify({
|
|
304
|
+
mutation,
|
|
305
|
+
id: idPath.join("."),
|
|
306
|
+
level: {
|
|
307
|
+
expected: minimumLevel,
|
|
308
|
+
actual: versionDiff,
|
|
309
|
+
},
|
|
310
|
+
version: {
|
|
311
|
+
current: in_version,
|
|
312
|
+
previous: in_versionPrevious,
|
|
313
|
+
},
|
|
314
|
+
}));
|
|
312
315
|
}
|
|
313
316
|
}
|
|
314
317
|
else {
|
|
315
318
|
const sourceObjType = _getType.call(this, sourceObj);
|
|
316
319
|
const targetObjType = _getType.call(this, targetObj);
|
|
317
320
|
if (sourceObjType !== targetObjType) {
|
|
318
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
321
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
322
|
+
JSON.stringify({
|
|
323
|
+
mutation: "change",
|
|
324
|
+
id: idPath.join("."),
|
|
325
|
+
type: {
|
|
326
|
+
current: targetObjType,
|
|
327
|
+
previous: sourceObjType,
|
|
328
|
+
},
|
|
329
|
+
level: {
|
|
330
|
+
expected: "major",
|
|
331
|
+
actual: versionDiff,
|
|
332
|
+
},
|
|
333
|
+
version: {
|
|
334
|
+
current: in_version,
|
|
335
|
+
previous: in_versionPrevious,
|
|
336
|
+
},
|
|
337
|
+
}));
|
|
334
338
|
}
|
|
335
339
|
if (Array.isArray(sourceObj)) {
|
|
336
340
|
let targetMap = {};
|
|
@@ -348,18 +352,19 @@ const _validatePositiveIncrement = function (in_template, in_templatePrevious, i
|
|
|
348
352
|
if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {
|
|
349
353
|
// Violates rule 5 (warning)
|
|
350
354
|
idPath.push(Object.keys(targetMap)[0]);
|
|
351
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
355
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
356
|
+
JSON.stringify({
|
|
357
|
+
mutation: "add",
|
|
358
|
+
id: idPath.join("."),
|
|
359
|
+
level: {
|
|
360
|
+
expected: minimumLevel,
|
|
361
|
+
actual: versionDiff,
|
|
362
|
+
},
|
|
363
|
+
version: {
|
|
364
|
+
current: in_version,
|
|
365
|
+
previous: in_versionPrevious,
|
|
366
|
+
},
|
|
367
|
+
}));
|
|
363
368
|
idPath.pop();
|
|
364
369
|
}
|
|
365
370
|
}
|
|
@@ -380,22 +385,25 @@ const _validatePositiveIncrement = function (in_template, in_templatePrevious, i
|
|
|
380
385
|
if (!(0, isEmpty_1.default)(remainingKeys)) {
|
|
381
386
|
// Added new keys to the target. This is a MINOR change, unless they new key is a
|
|
382
387
|
// comment, in which case this is a PATCH level change.
|
|
383
|
-
let minimumLevel = remainingKeys.length === 1 && remainingKeys[0] === "annotation"
|
|
388
|
+
let minimumLevel = remainingKeys.length === 1 && remainingKeys[0] === "annotation"
|
|
389
|
+
? "patch"
|
|
390
|
+
: "minor";
|
|
384
391
|
if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {
|
|
385
392
|
// Violates rule 5 (warning)
|
|
386
393
|
idPath.push(remainingKeys[0]);
|
|
387
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
394
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
395
|
+
JSON.stringify({
|
|
396
|
+
mutation: "add",
|
|
397
|
+
id: idPath.join("."),
|
|
398
|
+
level: {
|
|
399
|
+
expected: minimumLevel,
|
|
400
|
+
actual: versionDiff,
|
|
401
|
+
},
|
|
402
|
+
version: {
|
|
403
|
+
current: in_version,
|
|
404
|
+
previous: in_versionPrevious,
|
|
405
|
+
},
|
|
406
|
+
}));
|
|
399
407
|
idPath.pop();
|
|
400
408
|
}
|
|
401
409
|
}
|
|
@@ -409,22 +417,23 @@ const _validatePositiveIncrement = function (in_template, in_templatePrevious, i
|
|
|
409
417
|
if (sourceObj !== targetObj) {
|
|
410
418
|
let minimumLevel = id === "value" ? "minor" : "major";
|
|
411
419
|
if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {
|
|
412
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
420
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
421
|
+
JSON.stringify({
|
|
422
|
+
mutation: "change",
|
|
423
|
+
id: idPath.join("."),
|
|
424
|
+
level: {
|
|
425
|
+
expected: minimumLevel,
|
|
426
|
+
actual: versionDiff,
|
|
427
|
+
},
|
|
428
|
+
value: {
|
|
429
|
+
current: targetObj,
|
|
430
|
+
previous: sourceObj,
|
|
431
|
+
},
|
|
432
|
+
version: {
|
|
433
|
+
current: in_version,
|
|
434
|
+
previous: in_versionPrevious,
|
|
435
|
+
},
|
|
436
|
+
}));
|
|
428
437
|
}
|
|
429
438
|
}
|
|
430
439
|
}
|
|
@@ -588,30 +597,36 @@ const _validateContextAsync = async function (in_template) {
|
|
|
588
597
|
return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));
|
|
589
598
|
}
|
|
590
599
|
// Since context is 'set' the template must eventually inherit from NamedProperty (same as above)
|
|
591
|
-
if ((0, includes_1.default)(in_template.inherits, "NamedProperty") ||
|
|
600
|
+
if ((0, includes_1.default)(in_template.inherits, "NamedProperty") ||
|
|
601
|
+
in_template.inherits === "NamedProperty") {
|
|
592
602
|
return Promise.resolve();
|
|
593
603
|
}
|
|
594
604
|
}
|
|
595
605
|
const typedValuePromise = Promise.all(typedValuePromises);
|
|
596
606
|
let parents = [];
|
|
597
607
|
if (in_template.inherits) {
|
|
598
|
-
parents = Array.isArray(in_template.inherits)
|
|
608
|
+
parents = Array.isArray(in_template.inherits)
|
|
609
|
+
? in_template.inherits
|
|
610
|
+
: [in_template.inherits];
|
|
599
611
|
}
|
|
600
612
|
const inheritsPromises = parents.map((typeid) => this._inheritsFromAsync(typeid, "NamedProperty"));
|
|
601
613
|
// Combine results from inheritsPromises and typedValuePromise
|
|
602
614
|
inheritsPromises.push(typedValuePromise);
|
|
603
|
-
return Promise.all(inheritsPromises)
|
|
615
|
+
return Promise.all(inheritsPromises)
|
|
616
|
+
.then(function (results) {
|
|
604
617
|
const foundNamedPropertyDescendant = (0, find_1.default)(results, (res) => res);
|
|
605
618
|
if (!foundNamedPropertyDescendant) {
|
|
606
619
|
return Promise.reject(Error(MSG.SET_ONLY_NAMED_PROPS));
|
|
607
620
|
}
|
|
608
621
|
return that._hasSchemaAsync(in_template.typeid);
|
|
609
|
-
})
|
|
622
|
+
})
|
|
623
|
+
.then(function (hasIt) {
|
|
610
624
|
if (!hasIt) {
|
|
611
625
|
return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));
|
|
612
626
|
}
|
|
613
627
|
return that._inheritsFromAsync(in_template.typeid, "NamedProperty");
|
|
614
|
-
})
|
|
628
|
+
})
|
|
629
|
+
.then(async function (res) {
|
|
615
630
|
if (res) {
|
|
616
631
|
return undefined;
|
|
617
632
|
}
|
|
@@ -662,13 +677,14 @@ const _processValidationResults = function (in_template) {
|
|
|
662
677
|
error.message = `typeid should have a pattern like: my.example:point-1.0.0 ${error.data} does not match that pattern`;
|
|
663
678
|
}
|
|
664
679
|
else if ("pattern" && regexTypeId.test(error.dataPath)) {
|
|
665
|
-
error.message =
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
680
|
+
error.message =
|
|
681
|
+
error.schemaPath === "#/definitions/typed-reference-typeid/pattern"
|
|
682
|
+
? ""
|
|
683
|
+
: `${error.dataPath} should follow this pattern: <namespace>:<typeid>-<version> ` +
|
|
684
|
+
`(for example: Sample:Rectangle-1.0.0) or match one of the Primitive Types (Float32, Float64, ` +
|
|
685
|
+
`Int8, Uint8, Int16, Uint16, Int32, Uint32, Bool, String, Reference, Enum, Int64, Uint64) or ` +
|
|
686
|
+
`Reserved Types (BaseProperty, NamedProperty, NodeProperty, NamedNodeProperty, ` +
|
|
687
|
+
`RelationshipProperty). '${error.data}' is not valid`;
|
|
672
688
|
}
|
|
673
689
|
break;
|
|
674
690
|
case "enum":
|
|
@@ -734,9 +750,12 @@ const createContextCheckAsyncQueue = function () {
|
|
|
734
750
|
const that = this;
|
|
735
751
|
const contextCheckWorker = function (in_task, in_callback) {
|
|
736
752
|
const property = in_task.property;
|
|
737
|
-
_validateContextAsync
|
|
753
|
+
_validateContextAsync
|
|
754
|
+
.call(that, property)
|
|
755
|
+
.then(function (response) {
|
|
738
756
|
in_callback();
|
|
739
|
-
})
|
|
757
|
+
})
|
|
758
|
+
.catch(function (error) {
|
|
740
759
|
in_callback({ error });
|
|
741
760
|
});
|
|
742
761
|
};
|
|
@@ -800,11 +819,15 @@ class TemplateValidator {
|
|
|
800
819
|
this._skipSemver = in_params ? !!in_params.skipSemver : false;
|
|
801
820
|
this._allowDraft = in_params ? !!in_params.allowDraft : false;
|
|
802
821
|
// Used by validate()
|
|
803
|
-
if (in_params &&
|
|
822
|
+
if (in_params &&
|
|
823
|
+
in_params.inheritsFrom !== undefined &&
|
|
824
|
+
in_params.hasSchema !== undefined) {
|
|
804
825
|
this._inheritsFrom = in_params.inheritsFrom;
|
|
805
826
|
this._hasSchema = in_params.hasSchema;
|
|
806
827
|
}
|
|
807
|
-
else if (in_params &&
|
|
828
|
+
else if (in_params &&
|
|
829
|
+
in_params.inheritsFromAsync !== undefined &&
|
|
830
|
+
in_params.hasSchemaAsync !== undefined) {
|
|
808
831
|
this._inheritsFromAsync = in_params.inheritsFromAsync;
|
|
809
832
|
this._hasSchemaAsync = in_params.hasSchemaAsync;
|
|
810
833
|
}
|
|
@@ -853,7 +876,8 @@ class TemplateValidator {
|
|
|
853
876
|
validate(in_template, in_templatePrevious) {
|
|
854
877
|
this._resultBuilder = new validationResultBuilder_1.ValidationResultBuilder(in_template ? in_template.typeid : "");
|
|
855
878
|
let isDraft = false;
|
|
856
|
-
if (in_template &&
|
|
879
|
+
if (in_template &&
|
|
880
|
+
in_template.typeid &&
|
|
857
881
|
typeidHelper_1.TypeIdHelper.extractVersion(in_template.typeid).version === "draft") {
|
|
858
882
|
if (this._allowDraft) {
|
|
859
883
|
isDraft = true;
|
|
@@ -889,7 +913,9 @@ class TemplateValidator {
|
|
|
889
913
|
}
|
|
890
914
|
// semver format validation
|
|
891
915
|
const version = _validateSemverFormat.call(this, in_template);
|
|
892
|
-
const versionPrevious = in_templatePrevious
|
|
916
|
+
const versionPrevious = in_templatePrevious
|
|
917
|
+
? _validateSemverFormat.call(this, in_templatePrevious)
|
|
918
|
+
: null;
|
|
893
919
|
// semver format validation must pass.
|
|
894
920
|
if (!this._resultBuilder.isValid()) {
|
|
895
921
|
return this._resultBuilder.result;
|
|
@@ -907,10 +933,11 @@ class TemplateValidator {
|
|
|
907
933
|
default:
|
|
908
934
|
case -1:
|
|
909
935
|
// previousVersion is greater. Violates rule 3b.
|
|
910
|
-
this._resultBuilder.addError(new Error(MSG.VERSION_REGRESSION_1 +
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
936
|
+
this._resultBuilder.addError(new Error(MSG.VERSION_REGRESSION_1 +
|
|
937
|
+
JSON.stringify({
|
|
938
|
+
current: version,
|
|
939
|
+
previous: versionPrevious,
|
|
940
|
+
})));
|
|
914
941
|
break;
|
|
915
942
|
}
|
|
916
943
|
}
|
|
@@ -963,9 +990,9 @@ class TemplateValidator {
|
|
|
963
990
|
if (!this._resultBuilder.isValid()) {
|
|
964
991
|
return Promise.resolve(this._resultBuilder.result);
|
|
965
992
|
}
|
|
966
|
-
return
|
|
967
|
-
this._validateAsyncWithPreviousSchema(in_template, in_templatePrevious)
|
|
968
|
-
_validateSemanticAndSyntaxAsync.call(this, in_template);
|
|
993
|
+
return in_templatePrevious
|
|
994
|
+
? this._validateAsyncWithPreviousSchema(in_template, in_templatePrevious)
|
|
995
|
+
: _validateSemanticAndSyntaxAsync.call(this, in_template);
|
|
969
996
|
}
|
|
970
997
|
/**
|
|
971
998
|
* Called by validateAsync if a previous schema is passed in argument
|
|
@@ -978,7 +1005,10 @@ class TemplateValidator {
|
|
|
978
1005
|
*/
|
|
979
1006
|
async _validateAsyncWithPreviousSchema(in_template, in_templatePrevious) {
|
|
980
1007
|
const that = this;
|
|
981
|
-
return _validateSemanticAndSyntaxAsync
|
|
1008
|
+
return _validateSemanticAndSyntaxAsync
|
|
1009
|
+
.call(that, in_template)
|
|
1010
|
+
.then(() => _validateSemanticAndSyntaxAsync.call(that, in_templatePrevious))
|
|
1011
|
+
.then(function () {
|
|
982
1012
|
if (!that._resultBuilder.isValid()) {
|
|
983
1013
|
// Here the previous template is not valid. Make sure the typeid in the returned info is
|
|
984
1014
|
// the root of the template that failed validation.
|
|
@@ -988,7 +1018,9 @@ class TemplateValidator {
|
|
|
988
1018
|
_validateSkipSemver.call(that, in_template, in_templatePrevious);
|
|
989
1019
|
}
|
|
990
1020
|
const version = _validateSemverFormat.call(that, in_template);
|
|
991
|
-
const versionPrevious = in_templatePrevious
|
|
1021
|
+
const versionPrevious = in_templatePrevious
|
|
1022
|
+
? _validateSemverFormat.call(that, in_templatePrevious)
|
|
1023
|
+
: null;
|
|
992
1024
|
// Validate that the semver change is valid.
|
|
993
1025
|
switch ((0, semver_1.compare)(version, versionPrevious)) {
|
|
994
1026
|
case 0:
|
|
@@ -1001,10 +1033,11 @@ class TemplateValidator {
|
|
|
1001
1033
|
default:
|
|
1002
1034
|
case -1:
|
|
1003
1035
|
// previousVersion is greater. Violates rule 3b.
|
|
1004
|
-
that._resultBuilder.addError(new Error(MSG.VERSION_REGRESSION_1 +
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1036
|
+
that._resultBuilder.addError(new Error(MSG.VERSION_REGRESSION_1 +
|
|
1037
|
+
JSON.stringify({
|
|
1038
|
+
current: version,
|
|
1039
|
+
previous: versionPrevious,
|
|
1040
|
+
})));
|
|
1008
1041
|
break;
|
|
1009
1042
|
}
|
|
1010
1043
|
return that._resultBuilder.result;
|