@angular-devkit/core 12.0.0 → 12.0.4
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/node/host.js
CHANGED
|
@@ -85,7 +85,7 @@ class NodeJsAsyncHost {
|
|
|
85
85
|
return rxjs_1.from(fs_1.promises.readdir(src_1.getSystemPath(path))).pipe(operators_1.map((names) => names.map((name) => src_1.fragment(name))));
|
|
86
86
|
}
|
|
87
87
|
exists(path) {
|
|
88
|
-
return rxjs_1.from(exists(path));
|
|
88
|
+
return rxjs_1.from(exists(src_1.getSystemPath(path)));
|
|
89
89
|
}
|
|
90
90
|
isDirectory(path) {
|
|
91
91
|
return this.stat(path).pipe(operators_1.map((stat) => stat.isDirectory()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/core",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.4",
|
|
4
4
|
"description": "Angular DevKit - Core Utility Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"typings": "src/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/angular/angular-cli.git"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": "^12.14.1 ||
|
|
28
|
+
"node": "^12.14.1 || >=14.0.0",
|
|
29
29
|
"npm": "^6.11.0 || ^7.5.6",
|
|
30
30
|
"yarn": ">= 1.13.0"
|
|
31
31
|
},
|
|
@@ -16,7 +16,7 @@ export interface SchemaValidatorResult {
|
|
|
16
16
|
success: boolean;
|
|
17
17
|
errors?: SchemaValidatorError[];
|
|
18
18
|
}
|
|
19
|
-
export declare type SchemaValidatorError = ErrorObject
|
|
19
|
+
export declare type SchemaValidatorError = Partial<ErrorObject>;
|
|
20
20
|
export interface SchemaValidatorOptions {
|
|
21
21
|
applyPreTransforms?: boolean;
|
|
22
22
|
applyPostTransforms?: boolean;
|
|
@@ -36,9 +36,17 @@ class SchemaValidationException extends exception_1.BaseException {
|
|
|
36
36
|
return [];
|
|
37
37
|
}
|
|
38
38
|
const messages = errors.map((err) => {
|
|
39
|
+
var _a;
|
|
39
40
|
let message = `Data path ${JSON.stringify(err.instancePath)} ${err.message}`;
|
|
40
|
-
if (err.
|
|
41
|
-
|
|
41
|
+
if (err.params) {
|
|
42
|
+
switch (err.keyword) {
|
|
43
|
+
case 'additionalProperties':
|
|
44
|
+
message += `(${err.params.additionalProperty})`;
|
|
45
|
+
break;
|
|
46
|
+
case 'enum':
|
|
47
|
+
message += `. Allowed values are: ${(_a = err.params.allowedValues) === null || _a === void 0 ? void 0 : _a.map((v) => `"${v}"`).join(', ')}`;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
42
50
|
}
|
|
43
51
|
return message + '.';
|
|
44
52
|
});
|
|
@@ -212,6 +220,13 @@ class CoreSchemaRegistry {
|
|
|
212
220
|
let validator;
|
|
213
221
|
try {
|
|
214
222
|
this._currentCompilationSchemaInfo = schemaInfo;
|
|
223
|
+
validator = this._ajv.compile(schema);
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
// This should eventually be refactored so that we we handle race condition where the same schema is validated at the same time.
|
|
227
|
+
if (!(e instanceof ajv_1.default.MissingRefError)) {
|
|
228
|
+
throw e;
|
|
229
|
+
}
|
|
215
230
|
validator = await this._ajv.compileAsync(schema);
|
|
216
231
|
}
|
|
217
232
|
finally {
|
|
@@ -253,9 +268,17 @@ class CoreSchemaRegistry {
|
|
|
253
268
|
}
|
|
254
269
|
}
|
|
255
270
|
// Validate using ajv
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
271
|
+
try {
|
|
272
|
+
const success = await validator.call(validationContext, data);
|
|
273
|
+
if (!success) {
|
|
274
|
+
return { data, success, errors: (_a = validator.errors) !== null && _a !== void 0 ? _a : [] };
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
if (error instanceof ajv_1.default.ValidationError) {
|
|
279
|
+
return { data, success: false, errors: error.errors };
|
|
280
|
+
}
|
|
281
|
+
throw error;
|
|
259
282
|
}
|
|
260
283
|
// Apply post-validation transforms
|
|
261
284
|
if (validationOptions.applyPostTransforms) {
|
|
@@ -286,9 +309,7 @@ class CoreSchemaRegistry {
|
|
|
286
309
|
return () => true;
|
|
287
310
|
}
|
|
288
311
|
// We cheat, heavily.
|
|
289
|
-
const pathArray = it
|
|
290
|
-
.slice(1, it.dataLevel + 1)
|
|
291
|
-
.map((p) => (typeof p === 'number' ? p : p.str.slice(1, -1)));
|
|
312
|
+
const pathArray = this.normalizeDataPathArr(it);
|
|
292
313
|
compilationSchemInfo.smartDefaultRecord.set(JSON.stringify(pathArray), schema);
|
|
293
314
|
return () => true;
|
|
294
315
|
},
|
|
@@ -321,11 +342,7 @@ class CoreSchemaRegistry {
|
|
|
321
342
|
if (!compilationSchemInfo) {
|
|
322
343
|
return () => true;
|
|
323
344
|
}
|
|
324
|
-
const path = '/' +
|
|
325
|
-
it.dataPathArr
|
|
326
|
-
.slice(1, it.dataLevel + 1)
|
|
327
|
-
.map((p) => (typeof p === 'number' ? p : p.str.slice(1, -1)))
|
|
328
|
-
.join('/');
|
|
345
|
+
const path = '/' + this.normalizeDataPathArr(it).join('/');
|
|
329
346
|
let type;
|
|
330
347
|
let items;
|
|
331
348
|
let message;
|
|
@@ -454,8 +471,20 @@ class CoreSchemaRegistry {
|
|
|
454
471
|
}
|
|
455
472
|
static _set(
|
|
456
473
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
457
|
-
data, fragments, value,
|
|
458
|
-
|
|
474
|
+
data, fragments, value,
|
|
475
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
476
|
+
parent = null, parentProperty, force) {
|
|
477
|
+
for (let index = 0; index < fragments.length; index++) {
|
|
478
|
+
const fragment = fragments[index];
|
|
479
|
+
if (/^i\d+$/.test(fragment)) {
|
|
480
|
+
if (!Array.isArray(data)) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
for (let dataIndex = 0; dataIndex < data.length; dataIndex++) {
|
|
484
|
+
CoreSchemaRegistry._set(data[dataIndex], fragments.slice(index + 1), value, data, `${dataIndex}`);
|
|
485
|
+
}
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
459
488
|
if (!data && parent !== null && parentProperty) {
|
|
460
489
|
data = parent[parentProperty] = {};
|
|
461
490
|
}
|
|
@@ -505,5 +534,10 @@ class CoreSchemaRegistry {
|
|
|
505
534
|
console.warn(`"${schema.$id}" schema is using the keyword "id" which its support is deprecated. Use "$id" for schema ID.`);
|
|
506
535
|
}
|
|
507
536
|
}
|
|
537
|
+
normalizeDataPathArr(it) {
|
|
538
|
+
return it.dataPathArr
|
|
539
|
+
.slice(1, it.dataLevel + 1)
|
|
540
|
+
.map((p) => (typeof p === 'number' ? p : p.str.replace(/\"/g, '')));
|
|
541
|
+
}
|
|
508
542
|
}
|
|
509
543
|
exports.CoreSchemaRegistry = CoreSchemaRegistry;
|