@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
package/lib/templateValidator.js
CHANGED
|
@@ -178,8 +178,10 @@ const _psetDeepEquals = function (in_source, in_target) {
|
|
|
178
178
|
// A template with abstract properties must equal one with an empty properties array
|
|
179
179
|
// We check the difference in keys between the source and target and if the only difference is the
|
|
180
180
|
// properties array we check if it's empty. Then we reverse the condition so it work both ways.
|
|
181
|
-
if ((isEqual(difference(keysTarget, keysSource), ["properties"]) &&
|
|
182
|
-
|
|
181
|
+
if ((isEqual(difference(keysTarget, keysSource), ["properties"]) &&
|
|
182
|
+
!target.properties.length) ||
|
|
183
|
+
(isEqual(difference(keysSource, keysTarget), ["properties"]) &&
|
|
184
|
+
!source.properties.length)) {
|
|
183
185
|
return _getPSetDeepEqualsResult(true);
|
|
184
186
|
}
|
|
185
187
|
return _getPSetDeepEqualsResult(false);
|
|
@@ -291,40 +293,42 @@ const _validatePositiveIncrement = function (in_template, in_templatePrevious, i
|
|
|
291
293
|
}
|
|
292
294
|
if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {
|
|
293
295
|
// Violates rule 6 (warning).
|
|
294
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
296
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
297
|
+
JSON.stringify({
|
|
298
|
+
mutation,
|
|
299
|
+
id: idPath.join("."),
|
|
300
|
+
level: {
|
|
301
|
+
expected: minimumLevel,
|
|
302
|
+
actual: versionDiff,
|
|
303
|
+
},
|
|
304
|
+
version: {
|
|
305
|
+
current: in_version,
|
|
306
|
+
previous: in_versionPrevious,
|
|
307
|
+
},
|
|
308
|
+
}));
|
|
306
309
|
}
|
|
307
310
|
}
|
|
308
311
|
else {
|
|
309
312
|
const sourceObjType = _getType.call(this, sourceObj);
|
|
310
313
|
const targetObjType = _getType.call(this, targetObj);
|
|
311
314
|
if (sourceObjType !== targetObjType) {
|
|
312
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
315
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
316
|
+
JSON.stringify({
|
|
317
|
+
mutation: "change",
|
|
318
|
+
id: idPath.join("."),
|
|
319
|
+
type: {
|
|
320
|
+
current: targetObjType,
|
|
321
|
+
previous: sourceObjType,
|
|
322
|
+
},
|
|
323
|
+
level: {
|
|
324
|
+
expected: "major",
|
|
325
|
+
actual: versionDiff,
|
|
326
|
+
},
|
|
327
|
+
version: {
|
|
328
|
+
current: in_version,
|
|
329
|
+
previous: in_versionPrevious,
|
|
330
|
+
},
|
|
331
|
+
}));
|
|
328
332
|
}
|
|
329
333
|
if (Array.isArray(sourceObj)) {
|
|
330
334
|
let targetMap = {};
|
|
@@ -342,18 +346,19 @@ const _validatePositiveIncrement = function (in_template, in_templatePrevious, i
|
|
|
342
346
|
if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {
|
|
343
347
|
// Violates rule 5 (warning)
|
|
344
348
|
idPath.push(Object.keys(targetMap)[0]);
|
|
345
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
349
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
350
|
+
JSON.stringify({
|
|
351
|
+
mutation: "add",
|
|
352
|
+
id: idPath.join("."),
|
|
353
|
+
level: {
|
|
354
|
+
expected: minimumLevel,
|
|
355
|
+
actual: versionDiff,
|
|
356
|
+
},
|
|
357
|
+
version: {
|
|
358
|
+
current: in_version,
|
|
359
|
+
previous: in_versionPrevious,
|
|
360
|
+
},
|
|
361
|
+
}));
|
|
357
362
|
idPath.pop();
|
|
358
363
|
}
|
|
359
364
|
}
|
|
@@ -374,22 +379,25 @@ const _validatePositiveIncrement = function (in_template, in_templatePrevious, i
|
|
|
374
379
|
if (!isEmpty(remainingKeys)) {
|
|
375
380
|
// Added new keys to the target. This is a MINOR change, unless they new key is a
|
|
376
381
|
// comment, in which case this is a PATCH level change.
|
|
377
|
-
let minimumLevel = remainingKeys.length === 1 && remainingKeys[0] === "annotation"
|
|
382
|
+
let minimumLevel = remainingKeys.length === 1 && remainingKeys[0] === "annotation"
|
|
383
|
+
? "patch"
|
|
384
|
+
: "minor";
|
|
378
385
|
if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {
|
|
379
386
|
// Violates rule 5 (warning)
|
|
380
387
|
idPath.push(remainingKeys[0]);
|
|
381
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
388
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
389
|
+
JSON.stringify({
|
|
390
|
+
mutation: "add",
|
|
391
|
+
id: idPath.join("."),
|
|
392
|
+
level: {
|
|
393
|
+
expected: minimumLevel,
|
|
394
|
+
actual: versionDiff,
|
|
395
|
+
},
|
|
396
|
+
version: {
|
|
397
|
+
current: in_version,
|
|
398
|
+
previous: in_versionPrevious,
|
|
399
|
+
},
|
|
400
|
+
}));
|
|
393
401
|
idPath.pop();
|
|
394
402
|
}
|
|
395
403
|
}
|
|
@@ -403,22 +411,23 @@ const _validatePositiveIncrement = function (in_template, in_templatePrevious, i
|
|
|
403
411
|
if (sourceObj !== targetObj) {
|
|
404
412
|
let minimumLevel = id === "value" ? "minor" : "major";
|
|
405
413
|
if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {
|
|
406
|
-
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
414
|
+
this._resultBuilder.addWarning(MSG.CHANGE_LEVEL_TOO_LOW_1 +
|
|
415
|
+
JSON.stringify({
|
|
416
|
+
mutation: "change",
|
|
417
|
+
id: idPath.join("."),
|
|
418
|
+
level: {
|
|
419
|
+
expected: minimumLevel,
|
|
420
|
+
actual: versionDiff,
|
|
421
|
+
},
|
|
422
|
+
value: {
|
|
423
|
+
current: targetObj,
|
|
424
|
+
previous: sourceObj,
|
|
425
|
+
},
|
|
426
|
+
version: {
|
|
427
|
+
current: in_version,
|
|
428
|
+
previous: in_versionPrevious,
|
|
429
|
+
},
|
|
430
|
+
}));
|
|
422
431
|
}
|
|
423
432
|
}
|
|
424
433
|
}
|
|
@@ -582,30 +591,36 @@ const _validateContextAsync = async function (in_template) {
|
|
|
582
591
|
return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));
|
|
583
592
|
}
|
|
584
593
|
// Since context is 'set' the template must eventually inherit from NamedProperty (same as above)
|
|
585
|
-
if (includes(in_template.inherits, "NamedProperty") ||
|
|
594
|
+
if (includes(in_template.inherits, "NamedProperty") ||
|
|
595
|
+
in_template.inherits === "NamedProperty") {
|
|
586
596
|
return Promise.resolve();
|
|
587
597
|
}
|
|
588
598
|
}
|
|
589
599
|
const typedValuePromise = Promise.all(typedValuePromises);
|
|
590
600
|
let parents = [];
|
|
591
601
|
if (in_template.inherits) {
|
|
592
|
-
parents = Array.isArray(in_template.inherits)
|
|
602
|
+
parents = Array.isArray(in_template.inherits)
|
|
603
|
+
? in_template.inherits
|
|
604
|
+
: [in_template.inherits];
|
|
593
605
|
}
|
|
594
606
|
const inheritsPromises = parents.map((typeid) => this._inheritsFromAsync(typeid, "NamedProperty"));
|
|
595
607
|
// Combine results from inheritsPromises and typedValuePromise
|
|
596
608
|
inheritsPromises.push(typedValuePromise);
|
|
597
|
-
return Promise.all(inheritsPromises)
|
|
609
|
+
return Promise.all(inheritsPromises)
|
|
610
|
+
.then(function (results) {
|
|
598
611
|
const foundNamedPropertyDescendant = find(results, (res) => res);
|
|
599
612
|
if (!foundNamedPropertyDescendant) {
|
|
600
613
|
return Promise.reject(Error(MSG.SET_ONLY_NAMED_PROPS));
|
|
601
614
|
}
|
|
602
615
|
return that._hasSchemaAsync(in_template.typeid);
|
|
603
|
-
})
|
|
616
|
+
})
|
|
617
|
+
.then(function (hasIt) {
|
|
604
618
|
if (!hasIt) {
|
|
605
619
|
return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));
|
|
606
620
|
}
|
|
607
621
|
return that._inheritsFromAsync(in_template.typeid, "NamedProperty");
|
|
608
|
-
})
|
|
622
|
+
})
|
|
623
|
+
.then(async function (res) {
|
|
609
624
|
if (res) {
|
|
610
625
|
return undefined;
|
|
611
626
|
}
|
|
@@ -656,13 +671,14 @@ const _processValidationResults = function (in_template) {
|
|
|
656
671
|
error.message = `typeid should have a pattern like: my.example:point-1.0.0 ${error.data} does not match that pattern`;
|
|
657
672
|
}
|
|
658
673
|
else if ("pattern" && regexTypeId.test(error.dataPath)) {
|
|
659
|
-
error.message =
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
674
|
+
error.message =
|
|
675
|
+
error.schemaPath === "#/definitions/typed-reference-typeid/pattern"
|
|
676
|
+
? ""
|
|
677
|
+
: `${error.dataPath} should follow this pattern: <namespace>:<typeid>-<version> ` +
|
|
678
|
+
`(for example: Sample:Rectangle-1.0.0) or match one of the Primitive Types (Float32, Float64, ` +
|
|
679
|
+
`Int8, Uint8, Int16, Uint16, Int32, Uint32, Bool, String, Reference, Enum, Int64, Uint64) or ` +
|
|
680
|
+
`Reserved Types (BaseProperty, NamedProperty, NodeProperty, NamedNodeProperty, ` +
|
|
681
|
+
`RelationshipProperty). '${error.data}' is not valid`;
|
|
666
682
|
}
|
|
667
683
|
break;
|
|
668
684
|
case "enum":
|
|
@@ -728,9 +744,12 @@ const createContextCheckAsyncQueue = function () {
|
|
|
728
744
|
const that = this;
|
|
729
745
|
const contextCheckWorker = function (in_task, in_callback) {
|
|
730
746
|
const property = in_task.property;
|
|
731
|
-
_validateContextAsync
|
|
747
|
+
_validateContextAsync
|
|
748
|
+
.call(that, property)
|
|
749
|
+
.then(function (response) {
|
|
732
750
|
in_callback();
|
|
733
|
-
})
|
|
751
|
+
})
|
|
752
|
+
.catch(function (error) {
|
|
734
753
|
in_callback({ error });
|
|
735
754
|
});
|
|
736
755
|
};
|
|
@@ -794,11 +813,15 @@ export class TemplateValidator {
|
|
|
794
813
|
this._skipSemver = in_params ? !!in_params.skipSemver : false;
|
|
795
814
|
this._allowDraft = in_params ? !!in_params.allowDraft : false;
|
|
796
815
|
// Used by validate()
|
|
797
|
-
if (in_params &&
|
|
816
|
+
if (in_params &&
|
|
817
|
+
in_params.inheritsFrom !== undefined &&
|
|
818
|
+
in_params.hasSchema !== undefined) {
|
|
798
819
|
this._inheritsFrom = in_params.inheritsFrom;
|
|
799
820
|
this._hasSchema = in_params.hasSchema;
|
|
800
821
|
}
|
|
801
|
-
else if (in_params &&
|
|
822
|
+
else if (in_params &&
|
|
823
|
+
in_params.inheritsFromAsync !== undefined &&
|
|
824
|
+
in_params.hasSchemaAsync !== undefined) {
|
|
802
825
|
this._inheritsFromAsync = in_params.inheritsFromAsync;
|
|
803
826
|
this._hasSchemaAsync = in_params.hasSchemaAsync;
|
|
804
827
|
}
|
|
@@ -847,7 +870,8 @@ export class TemplateValidator {
|
|
|
847
870
|
validate(in_template, in_templatePrevious) {
|
|
848
871
|
this._resultBuilder = new ValidationResultBuilder(in_template ? in_template.typeid : "");
|
|
849
872
|
let isDraft = false;
|
|
850
|
-
if (in_template &&
|
|
873
|
+
if (in_template &&
|
|
874
|
+
in_template.typeid &&
|
|
851
875
|
TypeIdHelper.extractVersion(in_template.typeid).version === "draft") {
|
|
852
876
|
if (this._allowDraft) {
|
|
853
877
|
isDraft = true;
|
|
@@ -883,7 +907,9 @@ export class TemplateValidator {
|
|
|
883
907
|
}
|
|
884
908
|
// semver format validation
|
|
885
909
|
const version = _validateSemverFormat.call(this, in_template);
|
|
886
|
-
const versionPrevious = in_templatePrevious
|
|
910
|
+
const versionPrevious = in_templatePrevious
|
|
911
|
+
? _validateSemverFormat.call(this, in_templatePrevious)
|
|
912
|
+
: null;
|
|
887
913
|
// semver format validation must pass.
|
|
888
914
|
if (!this._resultBuilder.isValid()) {
|
|
889
915
|
return this._resultBuilder.result;
|
|
@@ -901,10 +927,11 @@ export class TemplateValidator {
|
|
|
901
927
|
default:
|
|
902
928
|
case -1:
|
|
903
929
|
// previousVersion is greater. Violates rule 3b.
|
|
904
|
-
this._resultBuilder.addError(new Error(MSG.VERSION_REGRESSION_1 +
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
930
|
+
this._resultBuilder.addError(new Error(MSG.VERSION_REGRESSION_1 +
|
|
931
|
+
JSON.stringify({
|
|
932
|
+
current: version,
|
|
933
|
+
previous: versionPrevious,
|
|
934
|
+
})));
|
|
908
935
|
break;
|
|
909
936
|
}
|
|
910
937
|
}
|
|
@@ -957,9 +984,9 @@ export class TemplateValidator {
|
|
|
957
984
|
if (!this._resultBuilder.isValid()) {
|
|
958
985
|
return Promise.resolve(this._resultBuilder.result);
|
|
959
986
|
}
|
|
960
|
-
return
|
|
961
|
-
this._validateAsyncWithPreviousSchema(in_template, in_templatePrevious)
|
|
962
|
-
_validateSemanticAndSyntaxAsync.call(this, in_template);
|
|
987
|
+
return in_templatePrevious
|
|
988
|
+
? this._validateAsyncWithPreviousSchema(in_template, in_templatePrevious)
|
|
989
|
+
: _validateSemanticAndSyntaxAsync.call(this, in_template);
|
|
963
990
|
}
|
|
964
991
|
/**
|
|
965
992
|
* Called by validateAsync if a previous schema is passed in argument
|
|
@@ -972,7 +999,10 @@ export class TemplateValidator {
|
|
|
972
999
|
*/
|
|
973
1000
|
async _validateAsyncWithPreviousSchema(in_template, in_templatePrevious) {
|
|
974
1001
|
const that = this;
|
|
975
|
-
return _validateSemanticAndSyntaxAsync
|
|
1002
|
+
return _validateSemanticAndSyntaxAsync
|
|
1003
|
+
.call(that, in_template)
|
|
1004
|
+
.then(() => _validateSemanticAndSyntaxAsync.call(that, in_templatePrevious))
|
|
1005
|
+
.then(function () {
|
|
976
1006
|
if (!that._resultBuilder.isValid()) {
|
|
977
1007
|
// Here the previous template is not valid. Make sure the typeid in the returned info is
|
|
978
1008
|
// the root of the template that failed validation.
|
|
@@ -982,7 +1012,9 @@ export class TemplateValidator {
|
|
|
982
1012
|
_validateSkipSemver.call(that, in_template, in_templatePrevious);
|
|
983
1013
|
}
|
|
984
1014
|
const version = _validateSemverFormat.call(that, in_template);
|
|
985
|
-
const versionPrevious = in_templatePrevious
|
|
1015
|
+
const versionPrevious = in_templatePrevious
|
|
1016
|
+
? _validateSemverFormat.call(that, in_templatePrevious)
|
|
1017
|
+
: null;
|
|
986
1018
|
// Validate that the semver change is valid.
|
|
987
1019
|
switch (compare(version, versionPrevious)) {
|
|
988
1020
|
case 0:
|
|
@@ -995,10 +1027,11 @@ export class TemplateValidator {
|
|
|
995
1027
|
default:
|
|
996
1028
|
case -1:
|
|
997
1029
|
// previousVersion is greater. Violates rule 3b.
|
|
998
|
-
that._resultBuilder.addError(new Error(MSG.VERSION_REGRESSION_1 +
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1030
|
+
that._resultBuilder.addError(new Error(MSG.VERSION_REGRESSION_1 +
|
|
1031
|
+
JSON.stringify({
|
|
1032
|
+
current: version,
|
|
1033
|
+
previous: versionPrevious,
|
|
1034
|
+
})));
|
|
1002
1035
|
break;
|
|
1003
1036
|
}
|
|
1004
1037
|
return that._resultBuilder.result;
|