Skip to content

Commit 35c2908

Browse files
author
Angular Builds
committed
8954d1152 feat(@angular-devkit/schematics): remove deprecated isAction
1 parent 7bcd548 commit 35c2908

24 files changed

+65
-68
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"core"
1414
],
1515
"dependencies": {
16-
"ajv-formats": "2.1.1",
1716
"ajv": "8.6.2",
17+
"ajv-formats": "2.1.0",
1818
"fast-json-stable-stringify": "2.1.0",
1919
"magic-string": "0.25.7",
2020
"rxjs": "6.6.7",

src/json/index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import * as schema from './schema/index';
9-
export * from './utils';
9+
export * from './interface';
10+
export * from './parser';
1011
export { schema };

src/json/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3232
exports.schema = void 0;
3333
const schema = __importStar(require("./schema/index"));
3434
exports.schema = schema;
35-
__exportStar(require("./utils"), exports);
35+
__exportStar(require("./interface"), exports);
36+
__exportStar(require("./parser"), exports);

src/json/parser_ast.d.ts renamed to src/json/interface.d.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonArray, JsonObject } from './utils';
98
export interface Position {
109
readonly offset: number;
1110
readonly line: number;
@@ -30,11 +29,16 @@ export interface JsonAstIdentifier extends JsonAstNodeBase {
3029
readonly kind: 'identifier';
3130
readonly value: string;
3231
}
32+
export interface JsonArray extends Array<JsonValue> {
33+
}
3334
export interface JsonAstArray extends JsonAstNodeBase {
3435
readonly kind: 'array';
3536
readonly elements: JsonAstNode[];
3637
readonly value: JsonArray;
3738
}
39+
export interface JsonObject {
40+
[prop: string]: JsonValue;
41+
}
3842
export interface JsonAstKeyValue extends JsonAstNodeBase {
3943
readonly kind: 'keyvalue';
4044
readonly key: JsonAstString | JsonAstIdentifier;
@@ -65,3 +69,6 @@ export interface JsonAstComment extends JsonAstNodeBase {
6569
readonly kind: 'comment';
6670
readonly content: string;
6771
}
72+
export declare type JsonValue = JsonAstNode['value'];
73+
export declare function isJsonObject(value: JsonValue): value is JsonObject;
74+
export declare function isJsonArray(value: JsonValue): value is JsonArray;
File renamed without changes.

src/json/parser.d.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { BaseException } from '../exception';
9-
import { JsonAstNode, Position } from './parser_ast';
10-
import { JsonValue } from './utils';
9+
import { JsonAstNode, JsonValue, Position } from './interface';
1110
export declare class JsonException extends BaseException {
1211
}
1312
/**
1413
* A character was invalid in this context.
15-
* @deprecated
16-
* @private
14+
* @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
1715
*/
1816
export declare class InvalidJsonCharacterException extends JsonException {
1917
invalidChar: string;
@@ -24,8 +22,7 @@ export declare class InvalidJsonCharacterException extends JsonException {
2422
}
2523
/**
2624
* More input was expected, but we reached the end of the stream.
27-
* @deprecated
28-
* @private
25+
* @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
2926
*/
3027
export declare class UnexpectedEndOfInputException extends JsonException {
3128
constructor(_context: JsonParserContext);

src/json/parser.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class JsonException extends exception_1.BaseException {
1515
exports.JsonException = JsonException;
1616
/**
1717
* A character was invalid in this context.
18-
* @deprecated
19-
* @private
18+
* @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
2019
*/
2120
class InvalidJsonCharacterException extends JsonException {
2221
constructor(context) {
@@ -32,8 +31,7 @@ class InvalidJsonCharacterException extends JsonException {
3231
exports.InvalidJsonCharacterException = InvalidJsonCharacterException;
3332
/**
3433
* More input was expected, but we reached the end of the stream.
35-
* @deprecated
36-
* @private
34+
* @deprecated Deprecated since version 11. Use 3rd party JSON parsers such as `jsonc-parser` instead.
3735
*/
3836
class UnexpectedEndOfInputException extends JsonException {
3937
constructor(_context) {

src/json/parser_ast.js

-9
This file was deleted.

src/json/schema/interface.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { ErrorObject, Format } from 'ajv';
99
import { Observable, SubscribableOrPromise } from 'rxjs';
10-
import { JsonArray, JsonObject, JsonValue } from '../utils';
10+
import { JsonArray, JsonObject, JsonValue } from '../interface';
1111
export declare type JsonPointer = string & {
1212
__PRIVATE_DEVKIT_JSON_POINTER: void;
1313
};

src/json/schema/registry.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { ValidateFunction } from 'ajv';
99
import { Observable } from 'rxjs';
1010
import { BaseException } from '../../exception/exception';
11-
import { JsonObject } from '../utils';
11+
import { JsonObject } from '../interface';
1212
import { JsonVisitor, PromptProvider, SchemaFormat, SchemaRegistry, SchemaValidator, SchemaValidatorError, SmartDefaultProvider } from './interface';
1313
import { JsonSchema } from './schema';
1414
export declare type UriHandler = (uri: string) => Observable<JsonObject> | Promise<JsonObject> | null | undefined;
@@ -76,5 +76,10 @@ export declare class CoreSchemaRegistry implements SchemaRegistry {
7676
private static _set;
7777
private _applySmartDefaults;
7878
useXDeprecatedProvider(onUsage: (message: string) => void): void;
79+
/**
80+
* Workaround to avoid a breaking change in downstream schematics.
81+
* @deprecated will be removed in version 13.
82+
*/
83+
private _replaceDeprecatedSchemaIdKeyword;
7984
private normalizeDataPathArr;
8085
}

src/json/schema/registry.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const operators_1 = require("rxjs/operators");
3939
const Url = __importStar(require("url"));
4040
const exception_1 = require("../../exception/exception");
4141
const utils_1 = require("../../utils");
42-
const utils_2 = require("../utils");
42+
const interface_1 = require("../interface");
4343
const utility_1 = require("./utility");
4444
const visitor_1 = require("./visitor");
4545
class SchemaValidationException extends exception_1.BaseException {
@@ -196,6 +196,7 @@ class CoreSchemaRegistry {
196196
return rxjs_1.from(this._flatten(schema));
197197
}
198198
async _flatten(schema) {
199+
this._replaceDeprecatedSchemaIdKeyword(schema);
199200
this._ajv.removeSchema(schema);
200201
this._currentCompilationSchemaInfo = undefined;
201202
const validate = await this._ajv.compileAsync(schema);
@@ -205,7 +206,7 @@ class CoreSchemaRegistry {
205206
if (current &&
206207
parentSchema &&
207208
index &&
208-
utils_2.isJsonObject(current) &&
209+
interface_1.isJsonObject(current) &&
209210
Object.prototype.hasOwnProperty.call(current, '$ref') &&
210211
typeof current['$ref'] == 'string') {
211212
const resolved = self._resolver(current['$ref'], validate);
@@ -232,6 +233,7 @@ class CoreSchemaRegistry {
232233
if (typeof schema === 'boolean') {
233234
return async (data) => ({ success: schema, data });
234235
}
236+
this._replaceDeprecatedSchemaIdKeyword(schema);
235237
const schemaInfo = {
236238
smartDefaultRecord: new Map(),
237239
promptDefinitions: [],
@@ -542,6 +544,18 @@ class CoreSchemaRegistry {
542544
errors: false,
543545
});
544546
}
547+
/**
548+
* Workaround to avoid a breaking change in downstream schematics.
549+
* @deprecated will be removed in version 13.
550+
*/
551+
_replaceDeprecatedSchemaIdKeyword(schema) {
552+
if (typeof schema.id === 'string') {
553+
schema.$id = schema.id;
554+
delete schema.id;
555+
// eslint-disable-next-line no-console
556+
console.warn(`"${schema.$id}" schema is using the keyword "id" which its support is deprecated. Use "$id" for schema ID.`);
557+
}
558+
}
545559
normalizeDataPathArr(it) {
546560
return it.dataPathArr
547561
.slice(1, it.dataLevel + 1)

src/json/schema/schema.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonObject } from '../utils';
8+
import { JsonObject } from '../interface';
99
/**
1010
* A specialized interface for JsonSchema (to come). JsonSchemas are also JsonObject.
1111
*

src/json/schema/schema.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
*/
99
Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.mergeSchemas = exports.isJsonSchema = void 0;
11-
const utils_1 = require("../utils");
11+
const interface_1 = require("../interface");
1212
function isJsonSchema(value) {
13-
return utils_1.isJsonObject(value) || value === false || value === true;
13+
return interface_1.isJsonObject(value) || value === false || value === true;
1414
}
1515
exports.isJsonSchema = isJsonSchema;
1616
/**

src/json/schema/transforms.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonValue } from '../utils';
8+
import { JsonValue } from '../interface';
99
import { JsonPointer } from './interface';
1010
import { JsonSchema } from './schema';
1111
export declare function addUndefinedDefaults(value: JsonValue, _pointer: JsonPointer, schema?: JsonSchema): JsonValue;

src/json/schema/transforms.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.addUndefinedDefaults = void 0;
11-
const utils_1 = require("../utils");
11+
const interface_1 = require("../interface");
1212
const utility_1 = require("./utility");
1313
function addUndefinedDefaults(value, _pointer, schema) {
1414
if (typeof schema === 'boolean' || schema === undefined) {
@@ -47,41 +47,41 @@ function addUndefinedDefaults(value, _pointer, schema) {
4747
if (value == undefined) {
4848
newValue = {};
4949
}
50-
else if (utils_1.isJsonObject(value)) {
50+
else if (interface_1.isJsonObject(value)) {
5151
newValue = value;
5252
}
5353
else {
5454
return value;
5555
}
56-
if (!utils_1.isJsonObject(schema.properties)) {
56+
if (!interface_1.isJsonObject(schema.properties)) {
5757
return newValue;
5858
}
5959
for (const [propName, schemaObject] of Object.entries(schema.properties)) {
60-
if (propName === '$schema' || !utils_1.isJsonObject(schemaObject)) {
60+
if (propName === '$schema' || !interface_1.isJsonObject(schemaObject)) {
6161
continue;
6262
}
6363
const value = newValue[propName];
6464
if (value === undefined) {
6565
newValue[propName] = schemaObject.default;
6666
}
67-
else if (utils_1.isJsonObject(value)) {
67+
else if (interface_1.isJsonObject(value)) {
6868
// Basic support for oneOf and anyOf.
6969
const propertySchemas = schemaObject.oneOf || schemaObject.anyOf;
7070
const allProperties = Object.keys(value);
7171
// Locate a schema which declares all the properties that the object contains.
72-
const adjustedSchema = utils_1.isJsonArray(propertySchemas) &&
72+
const adjustedSchema = interface_1.isJsonArray(propertySchemas) &&
7373
propertySchemas.find((s) => {
74-
if (!utils_1.isJsonObject(s)) {
74+
if (!interface_1.isJsonObject(s)) {
7575
return false;
7676
}
7777
const schemaType = utility_1.getTypesOfSchema(s);
78-
if (schemaType.size === 1 && schemaType.has('object') && utils_1.isJsonObject(s.properties)) {
78+
if (schemaType.size === 1 && schemaType.has('object') && interface_1.isJsonObject(s.properties)) {
7979
const properties = Object.keys(s.properties);
8080
return allProperties.every((key) => properties.includes(key));
8181
}
8282
return false;
8383
});
84-
if (adjustedSchema && utils_1.isJsonObject(adjustedSchema)) {
84+
if (adjustedSchema && interface_1.isJsonObject(adjustedSchema)) {
8585
newValue[propName] = addUndefinedDefaults(value, _pointer, adjustedSchema);
8686
}
8787
}

src/json/schema/utility.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.getTypesOfSchema = void 0;
11-
const utils_1 = require("../utils");
11+
const interface_1 = require("../interface");
1212
const allTypes = ['string', 'integer', 'number', 'object', 'array', 'boolean', 'null'];
1313
function getTypesOfSchema(schema) {
1414
if (!schema) {
@@ -24,7 +24,7 @@ function getTypesOfSchema(schema) {
2424
else if (Array.isArray(schema.type)) {
2525
potentials = new Set(schema.type);
2626
}
27-
else if (utils_1.isJsonArray(schema.enum)) {
27+
else if (interface_1.isJsonArray(schema.enum)) {
2828
potentials = new Set();
2929
// Gather the type of each enum values, and use that as a starter for potential types.
3030
for (const v of schema.enum) {
@@ -51,7 +51,7 @@ function getTypesOfSchema(schema) {
5151
else {
5252
potentials = new Set(allTypes);
5353
}
54-
if (utils_1.isJsonObject(schema.not)) {
54+
if (interface_1.isJsonObject(schema.not)) {
5555
const notTypes = getTypesOfSchema(schema.not);
5656
potentials = new Set([...potentials].filter((p) => !notTypes.has(p)));
5757
}

src/json/schema/visitor.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { Observable } from 'rxjs';
9-
import { JsonObject, JsonValue } from '../utils';
9+
import { JsonObject, JsonValue } from '../interface';
1010
import { JsonSchemaVisitor, JsonVisitor } from './interface';
1111
import { JsonSchema } from './schema';
1212
export interface ReferenceResolver<ContextT> {

src/json/utils.d.ts

-15
This file was deleted.

src/logger/level.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonObject } from '../json/utils';
8+
import { JsonObject } from '../json/interface';
99
import { LogLevel, Logger } from './logger';
1010
export declare class LevelTransformLogger extends Logger {
1111
readonly name: string;

src/logger/logger.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { Observable, Operator, PartialObserver, Subject, Subscription } from 'rxjs';
9-
import { JsonObject } from '../json/utils';
9+
import { JsonObject } from '../json/interface';
1010
export interface LoggerMetadata extends JsonObject {
1111
name: string;
1212
path: string[];

src/workspace/json/metadata.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonValue } from '../../json';
9-
import { JsonAstArray, JsonAstKeyValue, JsonAstNode, JsonAstObject } from '../../json/parser_ast';
8+
import { JsonAstArray, JsonAstKeyValue, JsonAstNode, JsonAstObject, JsonValue } from '../../json';
109
import { ProjectDefinition, TargetDefinition, WorkspaceDefinition } from '../definitions';
1110
export declare const JsonWorkspaceSymbol: unique symbol;
1211
export interface JsonWorkspaceDefinition extends WorkspaceDefinition {

src/workspace/json/reader.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.readJsonWorkspace = void 0;
11-
const parser_1 = require("../../json/parser");
11+
const json_1 = require("../../json");
1212
const definitions_1 = require("../definitions");
1313
const metadata_1 = require("./metadata");
1414
const utilities_1 = require("./utilities");
@@ -17,7 +17,7 @@ async function readJsonWorkspace(path, host) {
1717
if (raw === undefined) {
1818
throw new Error('Unable to read workspace file.');
1919
}
20-
const ast = parser_1.parseJsonAst(raw, parser_1.JsonParseMode.Loose);
20+
const ast = json_1.parseJsonAst(raw, json_1.JsonParseMode.Loose);
2121
if (ast.kind !== 'object') {
2222
throw new Error('Invalid workspace file - expected JSON object.');
2323
}

src/workspace/json/utilities.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { JsonObject, JsonValue } from '../../json';
9-
import { JsonAstArray, JsonAstKeyValue, JsonAstObject } from '../../json/parser_ast';
8+
import { JsonAstArray, JsonAstKeyValue, JsonAstObject, JsonObject, JsonValue } from '../../json';
109
export declare type ChangeListener = (op: 'add' | 'remove' | 'replace', path: string, node: JsonAstArray | JsonAstObject | JsonAstKeyValue, value?: JsonValue) => void;
1110
export declare function escapeKey(key: string | number): string | number;
1211
export declare function unescapeKey(key: string | number): string | number;

uniqueId

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Tue Aug 17 2021 17:05:46 GMT+0000 (Coordinated Universal Time)
1+
Tue Aug 17 2021 19:30:17 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)