@cratis/components 4.28.0 → 4.29.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/compat-manifest.json +11 -11
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditor.js +3 -1
- package/dist/esm/SchemaEditor/SchemaEditor.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/KeywordFamily.d.ts +14 -0
- package/dist/esm/SchemaEditor/Tree/KeywordFamily.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/KeywordFamily.js +11 -0
- package/dist/esm/SchemaEditor/Tree/KeywordFamily.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/Property.d.ts +8 -0
- package/dist/esm/SchemaEditor/Tree/Property.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/Property.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.d.ts +9 -2
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.js +7 -5
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaOriginalShape.d.ts +21 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOriginalShape.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOriginalShape.js +4 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOriginalShape.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/keywordApplicability.d.ts +41 -0
- package/dist/esm/SchemaEditor/Tree/keywordApplicability.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/keywordApplicability.js +56 -0
- package/dist/esm/SchemaEditor/Tree/keywordApplicability.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/originalShape.d.ts +30 -0
- package/dist/esm/SchemaEditor/Tree/originalShape.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/originalShape.js +70 -0
- package/dist/esm/SchemaEditor/Tree/originalShape.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaConversion.d.ts +5 -3
- package/dist/esm/SchemaEditor/Tree/schemaConversion.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/schemaConversion.js +43 -43
- package/dist/esm/SchemaEditor/Tree/schemaConversion.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.d.ts +2 -0
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.js +4 -1
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/schemaPropertyType.d.ts +11 -0
- package/dist/esm/SchemaEditor/Tree/schemaPropertyType.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaPropertyType.js +31 -0
- package/dist/esm/SchemaEditor/Tree/schemaPropertyType.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/standardKeywords.d.ts +18 -0
- package/dist/esm/SchemaEditor/Tree/standardKeywords.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/standardKeywords.js +22 -0
- package/dist/esm/SchemaEditor/Tree/standardKeywords.js.map +1 -0
- package/dist/esm/SchemaEditor/schemaHelpers.d.ts +9 -0
- package/dist/esm/SchemaEditor/schemaHelpers.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/schemaHelpers.js +20 -1
- package/dist/esm/SchemaEditor/schemaHelpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PropertyType } from './PropertyType.js';
|
|
2
|
+
/**
|
|
3
|
+
* The `type` and `format` of a property node exactly as read, so an untouched property is written back
|
|
4
|
+
* identically even where the editor models it more coarsely: `integer`, a type array, no type at all, or
|
|
5
|
+
* a format other than date and time.
|
|
6
|
+
*/
|
|
7
|
+
export interface SchemaOriginalShape {
|
|
8
|
+
/** The type the property had when it was read; the shape only applies while the property still has it. */
|
|
9
|
+
propertyType: PropertyType;
|
|
10
|
+
/** The `type` and `format` of the property node, only those present. */
|
|
11
|
+
node: Readonly<Record<string, unknown>>;
|
|
12
|
+
/** The `type` and `format` of an array's items node; absent when the array had no items node object. */
|
|
13
|
+
item?: Readonly<Record<string, unknown>>;
|
|
14
|
+
/** The `items` of an array when it is not an object, such as `true`, `false` or a tuple list, kept verbatim. */
|
|
15
|
+
rawItems?: {
|
|
16
|
+
readonly value: unknown;
|
|
17
|
+
};
|
|
18
|
+
/** Whether an object, or the items of an object list, had no `properties` keyword. */
|
|
19
|
+
withoutProperties?: boolean;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=SchemaOriginalShape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaOriginalShape.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaOriginalShape.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,0GAA0G;IAC1G,YAAY,EAAE,YAAY,CAAC;IAE3B,wEAAwE;IACxE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAExC,wGAAwG;IACxG,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEzC,gHAAgH;IAChH,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAEvC,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaOriginalShape.js","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaOriginalShape.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { PropertyType } from './PropertyType';\n\n/**\n * The `type` and `format` of a property node exactly as read, so an untouched property is written back\n * identically even where the editor models it more coarsely: `integer`, a type array, no type at all, or\n * a format other than date and time.\n */\nexport interface SchemaOriginalShape {\n /** The type the property had when it was read; the shape only applies while the property still has it. */\n propertyType: PropertyType;\n\n /** The `type` and `format` of the property node, only those present. */\n node: Readonly<Record<string, unknown>>;\n\n /** The `type` and `format` of an array's items node; absent when the array had no items node object. */\n item?: Readonly<Record<string, unknown>>;\n\n /** The `items` of an array when it is not an object, such as `true`, `false` or a tuple list, kept verbatim. */\n rawItems?: { readonly value: unknown };\n\n /** Whether an object, or the items of an object list, had no `properties` keyword. */\n withoutProperties?: boolean;\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { KeywordFamily } from './KeywordFamily.js';
|
|
2
|
+
import { PropertyType } from './PropertyType.js';
|
|
3
|
+
/**
|
|
4
|
+
* The keyword family of a property type.
|
|
5
|
+
* @param type The property type.
|
|
6
|
+
* @returns The family whose constraints apply to values of the type.
|
|
7
|
+
*/
|
|
8
|
+
export declare function propertyTypeFamily(type: PropertyType): KeywordFamily;
|
|
9
|
+
/**
|
|
10
|
+
* The keyword family of a JSON Schema `type` value.
|
|
11
|
+
* @param type The `type` keyword of a schema node.
|
|
12
|
+
* @returns The family whose constraints apply to values of the type.
|
|
13
|
+
*/
|
|
14
|
+
export declare function jsonTypeFamily(type: unknown): KeywordFamily;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a standard keyword that the editor does not model still applies after the type changed.
|
|
17
|
+
* Annotations always apply and a family's constraints apply while the family stays the same; value
|
|
18
|
+
* keywords (default, enum, const, examples), type refinements and every other keyword do not. The modelled
|
|
19
|
+
* keywords (type, format, items, properties, required) and `x-` keywords are not decided here.
|
|
20
|
+
* @param keyword The keyword name.
|
|
21
|
+
* @param from The family of the type before the change.
|
|
22
|
+
* @param to The family of the type after the change.
|
|
23
|
+
* @returns True when the keyword applies to the new type.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isKeywordApplicable(keyword: string, from: KeywordFamily, to: KeywordFamily): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Keeps the keywords that still apply after the type changed.
|
|
28
|
+
* @param keywords The standard keywords the editor does not model.
|
|
29
|
+
* @param from The family of the type before the change.
|
|
30
|
+
* @param to The family of the type after the change.
|
|
31
|
+
* @returns The keywords that apply; empty when none do.
|
|
32
|
+
*/
|
|
33
|
+
export declare function keywordsAfterTypeChange(keywords: Readonly<Record<string, unknown>>, from: KeywordFamily, to: KeywordFamily): Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a keyword survives a change between refinements of one type, such as integer and number: the
|
|
36
|
+
* constraints stay, but the value keywords and `multipleOf` described the old refinement.
|
|
37
|
+
* @param keyword The keyword name.
|
|
38
|
+
* @returns True when the keyword still applies.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isKeywordApplicableToRefinement(keyword: string): boolean;
|
|
41
|
+
//# sourceMappingURL=keywordApplicability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keywordApplicability.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/keywordApplicability.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AA6B9C;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,aAAa,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,CAc3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,aAAa,GAAG,OAAO,CAEpG;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC3C,IAAI,EAAE,aAAa,EACnB,EAAE,EAAE,aAAa,GAClB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { KeywordFamily } from './KeywordFamily.js';
|
|
2
|
+
import { PropertyType } from './PropertyType.js';
|
|
3
|
+
|
|
4
|
+
const annotations = new Set(['title', 'description', '$comment', 'deprecated', 'readOnly', 'writeOnly']);
|
|
5
|
+
const refinementKeywords = new Set(['default', 'enum', 'const', 'examples', 'multipleOf']);
|
|
6
|
+
const familyKeywords = {
|
|
7
|
+
[KeywordFamily.None]: new Set(),
|
|
8
|
+
[KeywordFamily.String]: new Set(['minLength', 'maxLength', 'pattern', 'contentEncoding', 'contentMediaType']),
|
|
9
|
+
[KeywordFamily.Number]: new Set(['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'multipleOf']),
|
|
10
|
+
[KeywordFamily.Array]: new Set(['minItems', 'maxItems', 'uniqueItems', 'contains', 'minContains', 'maxContains']),
|
|
11
|
+
[KeywordFamily.Object]: new Set([
|
|
12
|
+
'minProperties', 'maxProperties', 'additionalProperties', 'patternProperties', 'propertyNames',
|
|
13
|
+
'dependentRequired', 'dependentSchemas', 'unevaluatedProperties',
|
|
14
|
+
]),
|
|
15
|
+
};
|
|
16
|
+
const typeFamilies = {
|
|
17
|
+
[PropertyType.String]: KeywordFamily.String,
|
|
18
|
+
[PropertyType.Date]: KeywordFamily.String,
|
|
19
|
+
[PropertyType.Time]: KeywordFamily.String,
|
|
20
|
+
[PropertyType.Number]: KeywordFamily.Number,
|
|
21
|
+
[PropertyType.Boolean]: KeywordFamily.None,
|
|
22
|
+
[PropertyType.Object]: KeywordFamily.Object,
|
|
23
|
+
[PropertyType.StringArray]: KeywordFamily.Array,
|
|
24
|
+
[PropertyType.NumberArray]: KeywordFamily.Array,
|
|
25
|
+
[PropertyType.ObjectArray]: KeywordFamily.Array,
|
|
26
|
+
};
|
|
27
|
+
function propertyTypeFamily(type) {
|
|
28
|
+
return typeFamilies[type];
|
|
29
|
+
}
|
|
30
|
+
function jsonTypeFamily(type) {
|
|
31
|
+
switch (type) {
|
|
32
|
+
case 'string':
|
|
33
|
+
return KeywordFamily.String;
|
|
34
|
+
case 'number':
|
|
35
|
+
case 'integer':
|
|
36
|
+
return KeywordFamily.Number;
|
|
37
|
+
case 'array':
|
|
38
|
+
return KeywordFamily.Array;
|
|
39
|
+
case 'object':
|
|
40
|
+
return KeywordFamily.Object;
|
|
41
|
+
default:
|
|
42
|
+
return KeywordFamily.None;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function isKeywordApplicable(keyword, from, to) {
|
|
46
|
+
return annotations.has(keyword) || (from === to && familyKeywords[to].has(keyword));
|
|
47
|
+
}
|
|
48
|
+
function keywordsAfterTypeChange(keywords, from, to) {
|
|
49
|
+
return Object.fromEntries(Object.entries(keywords).filter(([keyword]) => isKeywordApplicable(keyword, from, to)));
|
|
50
|
+
}
|
|
51
|
+
function isKeywordApplicableToRefinement(keyword) {
|
|
52
|
+
return !refinementKeywords.has(keyword);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { isKeywordApplicable, isKeywordApplicableToRefinement, jsonTypeFamily, keywordsAfterTypeChange, propertyTypeFamily };
|
|
56
|
+
//# sourceMappingURL=keywordApplicability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keywordApplicability.js","sources":["../../../../SchemaEditor/Tree/keywordApplicability.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { KeywordFamily } from './KeywordFamily';\nimport { PropertyType } from './PropertyType';\n\nconst annotations: ReadonlySet<string> = new Set(['title', 'description', '$comment', 'deprecated', 'readOnly', 'writeOnly']);\n\nconst refinementKeywords: ReadonlySet<string> = new Set(['default', 'enum', 'const', 'examples', 'multipleOf']);\n\nconst familyKeywords: Readonly<Record<KeywordFamily, ReadonlySet<string>>> = {\n [KeywordFamily.None]: new Set(),\n [KeywordFamily.String]: new Set(['minLength', 'maxLength', 'pattern', 'contentEncoding', 'contentMediaType']),\n [KeywordFamily.Number]: new Set(['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'multipleOf']),\n [KeywordFamily.Array]: new Set(['minItems', 'maxItems', 'uniqueItems', 'contains', 'minContains', 'maxContains']),\n [KeywordFamily.Object]: new Set([\n 'minProperties', 'maxProperties', 'additionalProperties', 'patternProperties', 'propertyNames',\n 'dependentRequired', 'dependentSchemas', 'unevaluatedProperties',\n ]),\n};\n\nconst typeFamilies: Readonly<Record<PropertyType, KeywordFamily>> = {\n [PropertyType.String]: KeywordFamily.String,\n [PropertyType.Date]: KeywordFamily.String,\n [PropertyType.Time]: KeywordFamily.String,\n [PropertyType.Number]: KeywordFamily.Number,\n [PropertyType.Boolean]: KeywordFamily.None,\n [PropertyType.Object]: KeywordFamily.Object,\n [PropertyType.StringArray]: KeywordFamily.Array,\n [PropertyType.NumberArray]: KeywordFamily.Array,\n [PropertyType.ObjectArray]: KeywordFamily.Array,\n};\n\n/**\n * The keyword family of a property type.\n * @param type The property type.\n * @returns The family whose constraints apply to values of the type.\n */\nexport function propertyTypeFamily(type: PropertyType): KeywordFamily {\n return typeFamilies[type];\n}\n\n/**\n * The keyword family of a JSON Schema `type` value.\n * @param type The `type` keyword of a schema node.\n * @returns The family whose constraints apply to values of the type.\n */\nexport function jsonTypeFamily(type: unknown): KeywordFamily {\n switch (type) {\n case 'string':\n return KeywordFamily.String;\n case 'number':\n case 'integer':\n return KeywordFamily.Number;\n case 'array':\n return KeywordFamily.Array;\n case 'object':\n return KeywordFamily.Object;\n default:\n return KeywordFamily.None;\n }\n}\n\n/**\n * Whether a standard keyword that the editor does not model still applies after the type changed.\n * Annotations always apply and a family's constraints apply while the family stays the same; value\n * keywords (default, enum, const, examples), type refinements and every other keyword do not. The modelled\n * keywords (type, format, items, properties, required) and `x-` keywords are not decided here.\n * @param keyword The keyword name.\n * @param from The family of the type before the change.\n * @param to The family of the type after the change.\n * @returns True when the keyword applies to the new type.\n */\nexport function isKeywordApplicable(keyword: string, from: KeywordFamily, to: KeywordFamily): boolean {\n return annotations.has(keyword) || (from === to && familyKeywords[to].has(keyword));\n}\n\n/**\n * Keeps the keywords that still apply after the type changed.\n * @param keywords The standard keywords the editor does not model.\n * @param from The family of the type before the change.\n * @param to The family of the type after the change.\n * @returns The keywords that apply; empty when none do.\n */\nexport function keywordsAfterTypeChange(\n keywords: Readonly<Record<string, unknown>>,\n from: KeywordFamily,\n to: KeywordFamily,\n): Record<string, unknown> {\n return Object.fromEntries(Object.entries(keywords).filter(([keyword]) => isKeywordApplicable(keyword, from, to)));\n}\n\n/**\n * Whether a keyword survives a change between refinements of one type, such as integer and number: the\n * constraints stay, but the value keywords and `multipleOf` described the old refinement.\n * @param keyword The keyword name.\n * @returns True when the keyword still applies.\n */\nexport function isKeywordApplicableToRefinement(keyword: string): boolean {\n return !refinementKeywords.has(keyword);\n}\n"],"names":[],"mappings":";;;AAMA,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAE7H,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAE/G,MAAM,cAAc,GAAyD;AACzE,IAAA,CAAC,aAAa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SAAU,kBAAkB,CAAC,IAAkB,EAAA;AACjD,IAAA,OAAO,YAAY,CAAC,IAAI,CAAC;AAC7B;AAOM,SAAU,cAAc,CAAC,IAAa,EAAA;IACxC,QAAQ,IAAI;AACR,QAAA,KAAK,QAAQ;YACT,OAAO,aAAa,CAAC,MAAM;AAC/B,QAAA,KAAK,QAAQ;AACb,QAAA,KAAK,SAAS;YACV,OAAO,aAAa,CAAC,MAAM;AAC/B,QAAA,KAAK,OAAO;YACR,OAAO,aAAa,CAAC,KAAK;AAC9B,QAAA,KAAK,QAAQ;YACT,OAAO,aAAa,CAAC,MAAM;AAC/B,QAAA;YACI,OAAO,aAAa,CAAC,IAAI;;AAErC;SAYgB,mBAAmB,CAAC,OAAe,EAAE,IAAmB,EAAE,EAAiB,EAAA;IACvF,OAAO,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,EAAE,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACvF;SASgB,uBAAuB,CACnC,QAA2C,EAC3C,IAAmB,EACnB,EAAiB,EAAA;AAEjB,IAAA,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,mBAAmB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AACrH;AAQM,SAAU,+BAA+B,CAAC,OAAe,EAAA;AAC3D,IAAA,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC;AAC3C;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PropertyType } from './PropertyType.js';
|
|
2
|
+
import { type SchemaOrderedProperty } from './SchemaOrderedProperty.js';
|
|
3
|
+
import type { SchemaOriginalShape } from './SchemaOriginalShape.js';
|
|
4
|
+
type SchemaNode = Record<string, unknown>;
|
|
5
|
+
/** Whether a schema value is an object node rather than a boolean, an array or a scalar. */
|
|
6
|
+
export declare function isNode(value: unknown): value is SchemaNode;
|
|
7
|
+
/**
|
|
8
|
+
* Reads the `type` and `format` of a property node, and of its items node, exactly as they are written.
|
|
9
|
+
* @param node The property schema node.
|
|
10
|
+
* @param type The property type the node reads as.
|
|
11
|
+
* @returns The shape to restore while the property type is unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readOriginalShape(node: SchemaNode, type: PropertyType): SchemaOriginalShape;
|
|
14
|
+
/**
|
|
15
|
+
* Reads the order of the `required` names of an object, or of the items of an object list.
|
|
16
|
+
* @param node The property schema node.
|
|
17
|
+
* @param type The property type the node reads as.
|
|
18
|
+
* @returns The names in their original order, or undefined when there is no list.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readRequiredOrder(node: SchemaNode, type: PropertyType): readonly string[] | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Puts the original `type`, `format` and items of a property node back, while the property still has the
|
|
23
|
+
* type it was read with. A property whose type changed, or that was created in the editor, is returned as is.
|
|
24
|
+
* @param schema The node the editor would write.
|
|
25
|
+
* @param property The property the node is written for.
|
|
26
|
+
* @returns The node with its original shape.
|
|
27
|
+
*/
|
|
28
|
+
export declare function restoreOriginalShape(schema: SchemaNode, property: SchemaOrderedProperty): SchemaNode;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=originalShape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"originalShape.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/originalShape.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AAC9C,OAAO,EAAuB,KAAK,qBAAqB,EAAE,MAAM,4BAAyB,CAAC;AAC1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,4FAA4F;AAC5F,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAE1D;AAgBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,GAAG,mBAAmB,CAQ3F;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAGrG;AA4BD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,qBAAqB,GAAG,UAAU,CAKpG"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { KeywordFamily } from './KeywordFamily.js';
|
|
2
|
+
import { propertyTypeFamily } from './keywordApplicability.js';
|
|
3
|
+
import { PropertyType } from './PropertyType.js';
|
|
4
|
+
import { schemaOriginalShape } from './SchemaOrderedProperty.js';
|
|
5
|
+
|
|
6
|
+
function isNode(value) {
|
|
7
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function present(node, names) {
|
|
10
|
+
return Object.fromEntries(names.filter(name => Object.hasOwn(node, name)).map(name => [name, node[name]]));
|
|
11
|
+
}
|
|
12
|
+
function itemsShape(node) {
|
|
13
|
+
if (node.type !== 'array' || !Object.hasOwn(node, 'items'))
|
|
14
|
+
return {};
|
|
15
|
+
return isNode(node.items) ? { item: present(node.items, ['type', 'format']) } : { rawItems: { value: node.items } };
|
|
16
|
+
}
|
|
17
|
+
function containerOf(node, type) {
|
|
18
|
+
if (type === PropertyType.Object)
|
|
19
|
+
return node;
|
|
20
|
+
return type === PropertyType.ObjectArray && isNode(node.items) ? node.items : undefined;
|
|
21
|
+
}
|
|
22
|
+
function readOriginalShape(node, type) {
|
|
23
|
+
const container = containerOf(node, type);
|
|
24
|
+
return {
|
|
25
|
+
propertyType: type,
|
|
26
|
+
node: present(node, ['type', 'format']),
|
|
27
|
+
...itemsShape(node),
|
|
28
|
+
...(container && !isNode(container.properties) ? { withoutProperties: true } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function readRequiredOrder(node, type) {
|
|
32
|
+
const required = containerOf(node, type)?.required;
|
|
33
|
+
return Array.isArray(required) ? required.filter((name) => typeof name === 'string') : undefined;
|
|
34
|
+
}
|
|
35
|
+
function restoreNode(node, original) {
|
|
36
|
+
const restored = { ...node };
|
|
37
|
+
delete restored.type;
|
|
38
|
+
delete restored.format;
|
|
39
|
+
return { ...restored, ...original };
|
|
40
|
+
}
|
|
41
|
+
function restoreItems(schema, shape) {
|
|
42
|
+
if (propertyTypeFamily(shape.propertyType) !== KeywordFamily.Array)
|
|
43
|
+
return schema;
|
|
44
|
+
const { items, ...rest } = schema;
|
|
45
|
+
if (shape.rawItems)
|
|
46
|
+
return { ...rest, items: shape.rawItems.value };
|
|
47
|
+
return shape.item ? { ...rest, items: restoreNode(items, shape.item) } : rest;
|
|
48
|
+
}
|
|
49
|
+
function withoutProperties(node) {
|
|
50
|
+
const copy = { ...node };
|
|
51
|
+
delete copy.properties;
|
|
52
|
+
return copy;
|
|
53
|
+
}
|
|
54
|
+
function restoreContainer(schema, shape, hasChildren) {
|
|
55
|
+
if (!shape.withoutProperties || hasChildren)
|
|
56
|
+
return schema;
|
|
57
|
+
if (shape.propertyType === PropertyType.ObjectArray)
|
|
58
|
+
return { ...schema, items: withoutProperties(schema.items) };
|
|
59
|
+
return withoutProperties(schema);
|
|
60
|
+
}
|
|
61
|
+
function restoreOriginalShape(schema, property) {
|
|
62
|
+
const shape = property[schemaOriginalShape];
|
|
63
|
+
if (!shape || shape.propertyType !== property.type)
|
|
64
|
+
return schema;
|
|
65
|
+
const restored = restoreItems(restoreNode(schema, shape.node), shape);
|
|
66
|
+
return restoreContainer(restored, shape, (property.children ?? []).length > 0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { isNode, readOriginalShape, readRequiredOrder, restoreOriginalShape };
|
|
70
|
+
//# sourceMappingURL=originalShape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"originalShape.js","sources":["../../../../SchemaEditor/Tree/originalShape.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { KeywordFamily } from './KeywordFamily';\nimport { propertyTypeFamily } from './keywordApplicability';\nimport { PropertyType } from './PropertyType';\nimport { schemaOriginalShape, type SchemaOrderedProperty } from './SchemaOrderedProperty';\nimport type { SchemaOriginalShape } from './SchemaOriginalShape';\n\ntype SchemaNode = Record<string, unknown>;\n\n/** Whether a schema value is an object node rather than a boolean, an array or a scalar. */\nexport function isNode(value: unknown): value is SchemaNode {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction present(node: SchemaNode, names: readonly string[]): Record<string, unknown> {\n return Object.fromEntries(names.filter(name => Object.hasOwn(node, name)).map(name => [name, node[name]]));\n}\n\nfunction itemsShape(node: SchemaNode): Pick<SchemaOriginalShape, 'item' | 'rawItems'> {\n if (node.type !== 'array' || !Object.hasOwn(node, 'items')) return {};\n return isNode(node.items) ? { item: present(node.items, ['type', 'format']) } : { rawItems: { value: node.items } };\n}\n\nfunction containerOf(node: SchemaNode, type: PropertyType): SchemaNode | undefined {\n if (type === PropertyType.Object) return node;\n return type === PropertyType.ObjectArray && isNode(node.items) ? node.items : undefined;\n}\n\n/**\n * Reads the `type` and `format` of a property node, and of its items node, exactly as they are written.\n * @param node The property schema node.\n * @param type The property type the node reads as.\n * @returns The shape to restore while the property type is unchanged.\n */\nexport function readOriginalShape(node: SchemaNode, type: PropertyType): SchemaOriginalShape {\n const container = containerOf(node, type);\n return {\n propertyType: type,\n node: present(node, ['type', 'format']),\n ...itemsShape(node),\n ...(container && !isNode(container.properties) ? { withoutProperties: true } : {}),\n };\n}\n\n/**\n * Reads the order of the `required` names of an object, or of the items of an object list.\n * @param node The property schema node.\n * @param type The property type the node reads as.\n * @returns The names in their original order, or undefined when there is no list.\n */\nexport function readRequiredOrder(node: SchemaNode, type: PropertyType): readonly string[] | undefined {\n const required = containerOf(node, type)?.required;\n return Array.isArray(required) ? required.filter((name): name is string => typeof name === 'string') : undefined;\n}\n\nfunction restoreNode(node: SchemaNode, original: Readonly<Record<string, unknown>>): SchemaNode {\n const restored = { ...node };\n delete restored.type;\n delete restored.format;\n return { ...restored, ...original };\n}\n\nfunction restoreItems(schema: SchemaNode, shape: SchemaOriginalShape): SchemaNode {\n if (propertyTypeFamily(shape.propertyType) !== KeywordFamily.Array) return schema;\n const { items, ...rest } = schema;\n if (shape.rawItems) return { ...rest, items: shape.rawItems.value };\n return shape.item ? { ...rest, items: restoreNode(items as SchemaNode, shape.item) } : rest;\n}\n\nfunction withoutProperties(node: SchemaNode): SchemaNode {\n const copy = { ...node };\n delete copy.properties;\n return copy;\n}\n\nfunction restoreContainer(schema: SchemaNode, shape: SchemaOriginalShape, hasChildren: boolean): SchemaNode {\n if (!shape.withoutProperties || hasChildren) return schema;\n if (shape.propertyType === PropertyType.ObjectArray) return { ...schema, items: withoutProperties(schema.items as SchemaNode) };\n return withoutProperties(schema);\n}\n\n/**\n * Puts the original `type`, `format` and items of a property node back, while the property still has the\n * type it was read with. A property whose type changed, or that was created in the editor, is returned as is.\n * @param schema The node the editor would write.\n * @param property The property the node is written for.\n * @returns The node with its original shape.\n */\nexport function restoreOriginalShape(schema: SchemaNode, property: SchemaOrderedProperty): SchemaNode {\n const shape = property[schemaOriginalShape];\n if (!shape || shape.propertyType !== property.type) return schema;\n const restored = restoreItems(restoreNode(schema, shape.node), shape);\n return restoreContainer(restored, shape, (property.children ?? []).length > 0);\n}\n"],"names":[],"mappings":";;;;;AAYM,SAAU,MAAM,CAAC,KAAc,EAAA;AACjC,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAA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OAAO,IAAI,CAAC,UAAU;AACtB,IAAA,OAAO,IAAI;AACf;AAEA,SAAS,gBAAgB,CAAC,MAAkB,EAAE,KAA0B,EAAE,WAAoB,EAAA;AAC1F,IAAA,IAAI,CAAC,KAAK,CAAC,iBAAiB,IAAI,WAAW;AAAE,QAAA,OAAO,MAAM;AAC1D,IAAA,IAAI,KAAK,CAAC,YAAY,KAAK,YAAY,CAAC,WAAW;AAAE,QAAA,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,KAAmB,CAAC,EAAE;AAC/H,IAAA,OAAO,iBAAiB,CAAC,MAAM,CAAC;AACpC;AASM,SAAU,oBAAoB,CAAC,MAAkB,EAAE,QAA+B,EAAA;AACpF,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,mBAAmB,CAAC;IAC3C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,YAAY,KAAK,QAAQ,CAAC,IAAI;AAAE,QAAA,OAAO,MAAM;AACjE,IAAA,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;AACrE,IAAA,OAAO,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAClF;;"}
|
|
@@ -22,8 +22,8 @@ export declare const GENERATED_KEYWORD = "x-generated";
|
|
|
22
22
|
export declare function jsonSchemaToProperties(schema: JsonSchema | undefined): Property[];
|
|
23
23
|
/**
|
|
24
24
|
* Converts a property tree into a JSON Schema object. Empty `required` lists are omitted, and a property
|
|
25
|
-
* typed as a concept or marked as the key carries the `x-concept` and `x-key` keywords. Vendor keywords
|
|
26
|
-
* preserved on properties and array items; generated values carry `x-generated: true`.
|
|
25
|
+
* typed as a concept or marked as the key carries the `x-concept` and `x-key` keywords. Vendor keywords and the
|
|
26
|
+
* standard keywords the editor does not model are preserved on properties and array items; generated values carry `x-generated: true`.
|
|
27
27
|
* @param properties The root properties.
|
|
28
28
|
* @param base The incoming schema. Root keys other than type, properties and required are preserved.
|
|
29
29
|
* @returns The schema.
|
|
@@ -65,7 +65,9 @@ export declare function removeProperty(properties: Property[], targetId: string)
|
|
|
65
65
|
export declare function renameProperty(properties: Property[], targetId: string, newName: string): Property[];
|
|
66
66
|
/**
|
|
67
67
|
* Changes the type of a property. Choosing a plain primitive drops the concept; choosing an object or
|
|
68
|
-
* object list keeps the children, and any other type drops them. A different
|
|
68
|
+
* object list keeps the children, and any other type drops them. A different type keeps the annotations and the
|
|
69
|
+
* constraints of the same keyword family, and drops value keywords, the original type and format, item metadata
|
|
70
|
+
* and every other standard keyword that no longer applies. The same type keeps everything.
|
|
69
71
|
* @param properties The root properties.
|
|
70
72
|
* @param targetId The id of the property.
|
|
71
73
|
* @param newType The new type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaConversion.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/schemaConversion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,2BAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"schemaConversion.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/schemaConversion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,2BAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AAiB9C;;;;GAIG;AACH,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,mGA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AgB,mBAAmB,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,QAAQ,EAAE,CAE7G;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,QAAQ,EAAE,CAQ/G;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAOnF"}
|
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
import { PropertyType } from './PropertyType.js';
|
|
2
2
|
import { uniquePropertyName, conceptPropertyName } from './propertyNaming.js';
|
|
3
3
|
import { findPropertyById } from './propertyTree.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { keywordsAfterTypeChange, propertyTypeFamily } from './keywordApplicability.js';
|
|
5
|
+
import { copySchemaKeywordOrder, schemaOriginalShape, schemaKeywordOrder, itemSchemaKeywordOrder, schemaRequiredOrder } from './SchemaOrderedProperty.js';
|
|
6
|
+
import { readOriginalShape, isNode, readRequiredOrder, restoreOriginalShape } from './originalShape.js';
|
|
7
|
+
import { schemaPropertyType } from './schemaPropertyType.js';
|
|
8
|
+
import { standardPropertyKeywords, standardItemKeywords } from './standardKeywords.js';
|
|
9
|
+
import { schemaInOriginalOrder, requiredInOriginalOrder } from './schemaInOriginalOrder.js';
|
|
6
10
|
|
|
7
11
|
const CONCEPT_KEYWORD = 'x-concept';
|
|
8
12
|
const KEY_KEYWORD = 'x-key';
|
|
9
13
|
const GENERATED_KEYWORD = 'x-generated';
|
|
10
14
|
const isComplex = (type) => type === PropertyType.Object || type === PropertyType.ObjectArray;
|
|
11
15
|
const identifier = () => Math.random().toString(36).slice(2, 10) + Math.random().toString(36).slice(2, 6);
|
|
12
|
-
function schemaPropertyType(value) {
|
|
13
|
-
const items = value.items;
|
|
14
|
-
switch (value.type) {
|
|
15
|
-
case 'string':
|
|
16
|
-
if (value.format === 'date')
|
|
17
|
-
return PropertyType.Date;
|
|
18
|
-
if (value.format === 'time')
|
|
19
|
-
return PropertyType.Time;
|
|
20
|
-
return PropertyType.String;
|
|
21
|
-
case 'number':
|
|
22
|
-
case 'integer':
|
|
23
|
-
return PropertyType.Number;
|
|
24
|
-
case 'boolean':
|
|
25
|
-
return PropertyType.Boolean;
|
|
26
|
-
case 'object':
|
|
27
|
-
return PropertyType.Object;
|
|
28
|
-
case 'array':
|
|
29
|
-
if (items?.type === 'number' || items?.type === 'integer')
|
|
30
|
-
return PropertyType.NumberArray;
|
|
31
|
-
if (items?.type === 'object')
|
|
32
|
-
return PropertyType.ObjectArray;
|
|
33
|
-
return PropertyType.StringArray;
|
|
34
|
-
default:
|
|
35
|
-
return PropertyType.String;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
16
|
function vendorKeywords(node, isProperty) {
|
|
39
17
|
const entries = Object.entries(node).filter(([name, value]) => {
|
|
40
18
|
if (!name.startsWith('x-'))
|
|
@@ -45,19 +23,32 @@ function vendorKeywords(node, isProperty) {
|
|
|
45
23
|
});
|
|
46
24
|
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
47
25
|
}
|
|
48
|
-
function readItemKeywords(node) {
|
|
49
|
-
if (node.type !== 'array' ||
|
|
26
|
+
function readItemKeywords(node, type) {
|
|
27
|
+
if (node.type !== 'array' || !isNode(node.items))
|
|
50
28
|
return {};
|
|
51
29
|
const items = node.items;
|
|
52
30
|
const keywords = vendorKeywords(items, false);
|
|
53
|
-
|
|
31
|
+
const standard = standardItemKeywords(items, type);
|
|
32
|
+
return {
|
|
33
|
+
[itemSchemaKeywordOrder]: Object.keys(items),
|
|
34
|
+
...(keywords ? { itemVendorKeywords: keywords } : {}),
|
|
35
|
+
...(standard ? { itemSchemaKeywords: standard } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function requiredOrder(node, type) {
|
|
39
|
+
const order = readRequiredOrder(node, type);
|
|
40
|
+
return order ? { [schemaRequiredOrder]: order } : {};
|
|
54
41
|
}
|
|
55
|
-
function readFlags(node, isRequired) {
|
|
42
|
+
function readFlags(node, type, isRequired) {
|
|
56
43
|
const keywords = vendorKeywords(node, true);
|
|
44
|
+
const standard = standardPropertyKeywords(node, type);
|
|
57
45
|
return {
|
|
58
46
|
[schemaKeywordOrder]: Object.keys(node),
|
|
59
|
-
|
|
47
|
+
[schemaOriginalShape]: readOriginalShape(node, type),
|
|
48
|
+
...requiredOrder(node, type),
|
|
49
|
+
...readItemKeywords(node, type),
|
|
60
50
|
...(keywords ? { vendorKeywords: keywords } : {}),
|
|
51
|
+
...(standard ? { schemaKeywords: standard } : {}),
|
|
61
52
|
...(node[GENERATED_KEYWORD] === true ? { isGenerated: true } : {}),
|
|
62
53
|
...(isRequired ? { isRequired: true } : {}),
|
|
63
54
|
...(node[KEY_KEYWORD] === true ? { isKey: true } : {}),
|
|
@@ -67,7 +58,7 @@ function schemaPropertyToProperty(name, value, required) {
|
|
|
67
58
|
const node = value;
|
|
68
59
|
const type = schemaPropertyType(node);
|
|
69
60
|
const concept = node[CONCEPT_KEYWORD];
|
|
70
|
-
const flags = readFlags(node, required.has(name));
|
|
61
|
+
const flags = readFlags(node, type, required.has(name));
|
|
71
62
|
const container = (type === PropertyType.Object ? node : type === PropertyType.ObjectArray ? node.items : undefined);
|
|
72
63
|
if (container?.properties) {
|
|
73
64
|
const childRequired = new Set(container.required ?? []);
|
|
@@ -93,6 +84,9 @@ function jsonSchemaToProperties(schema) {
|
|
|
93
84
|
const required = new Set(schema.required ?? []);
|
|
94
85
|
return Object.entries(schema.properties).map(([name, value]) => schemaPropertyToProperty(name, value, required));
|
|
95
86
|
}
|
|
87
|
+
function itemSchema(property, type, extra = {}) {
|
|
88
|
+
return { ...property.itemSchemaKeywords, type, ...extra, ...property.itemVendorKeywords };
|
|
89
|
+
}
|
|
96
90
|
function primitiveSchema(property) {
|
|
97
91
|
switch (property.type) {
|
|
98
92
|
case PropertyType.Number:
|
|
@@ -104,20 +98,20 @@ function primitiveSchema(property) {
|
|
|
104
98
|
case PropertyType.Time:
|
|
105
99
|
return { type: 'string', format: 'time' };
|
|
106
100
|
case PropertyType.Object:
|
|
107
|
-
return { type: 'object', ...objectSchema(property.children ?? []) };
|
|
101
|
+
return { type: 'object', ...objectSchema(property.children ?? [], property[schemaRequiredOrder]) };
|
|
108
102
|
case PropertyType.StringArray:
|
|
109
|
-
return { type: 'array', items:
|
|
103
|
+
return { type: 'array', items: itemSchema(property, 'string') };
|
|
110
104
|
case PropertyType.NumberArray:
|
|
111
|
-
return { type: 'array', items:
|
|
105
|
+
return { type: 'array', items: itemSchema(property, 'number') };
|
|
112
106
|
case PropertyType.ObjectArray:
|
|
113
|
-
return { type: 'array', items:
|
|
107
|
+
return { type: 'array', items: itemSchema(property, 'object', objectSchema(property.children ?? [], property[schemaRequiredOrder])) };
|
|
114
108
|
default:
|
|
115
109
|
return { type: 'string' };
|
|
116
110
|
}
|
|
117
111
|
}
|
|
118
112
|
function orderedPrimitiveSchema(property) {
|
|
119
|
-
const schema = primitiveSchema(property);
|
|
120
|
-
if (schema.items)
|
|
113
|
+
const schema = restoreOriginalShape({ ...property.schemaKeywords, ...primitiveSchema(property) }, property);
|
|
114
|
+
if (isNode(schema.items))
|
|
121
115
|
schema.items = schemaInOriginalOrder(schema.items, property[itemSchemaKeywordOrder]);
|
|
122
116
|
return schema;
|
|
123
117
|
}
|
|
@@ -132,17 +126,17 @@ function propertyAnnotations(property) {
|
|
|
132
126
|
function propertySchema(property) {
|
|
133
127
|
return schemaInOriginalOrder({ ...orderedPrimitiveSchema(property), ...propertyAnnotations(property) }, property[schemaKeywordOrder]);
|
|
134
128
|
}
|
|
135
|
-
function objectSchema(properties) {
|
|
129
|
+
function objectSchema(properties, requiredOrder) {
|
|
136
130
|
const schemaProperties = {};
|
|
137
131
|
for (const property of properties) {
|
|
138
132
|
schemaProperties[property.name] = propertySchema(property);
|
|
139
133
|
}
|
|
140
|
-
const required = properties.filter(property => property.isRequired === true).map(property => property.name);
|
|
134
|
+
const required = requiredInOriginalOrder(properties.filter(property => property.isRequired === true).map(property => property.name), requiredOrder);
|
|
141
135
|
return { properties: schemaProperties, ...(required.length > 0 ? { required } : {}) };
|
|
142
136
|
}
|
|
143
137
|
function propertiesToJsonSchema(properties, base = {}) {
|
|
144
138
|
const root = Object.fromEntries(Object.entries(base).filter(([name]) => !['properties', 'required'].includes(name)));
|
|
145
|
-
return schemaInOriginalOrder({ ...root, type: 'object', ...objectSchema(properties) }, Object.keys(base));
|
|
139
|
+
return schemaInOriginalOrder({ ...root, type: 'object', ...objectSchema(properties, base.required) }, Object.keys(base));
|
|
146
140
|
}
|
|
147
141
|
function newProperty(siblings, type, existingCount, concept) {
|
|
148
142
|
const base = isComplex(type) ? 'nested' : 'property';
|
|
@@ -191,8 +185,14 @@ function retypedProperty(property, newType, concept) {
|
|
|
191
185
|
children: isComplex(newType) ? (property.children ?? []) : undefined,
|
|
192
186
|
});
|
|
193
187
|
if (property.type !== newType) {
|
|
188
|
+
const kept = keywordsAfterTypeChange(property.schemaKeywords ?? {}, propertyTypeFamily(property.type), propertyTypeFamily(newType));
|
|
189
|
+
delete next.schemaKeywords;
|
|
190
|
+
if (Object.keys(kept).length > 0)
|
|
191
|
+
next.schemaKeywords = kept;
|
|
194
192
|
delete next.itemVendorKeywords;
|
|
193
|
+
delete next.itemSchemaKeywords;
|
|
195
194
|
delete next[itemSchemaKeywordOrder];
|
|
195
|
+
delete next[schemaOriginalShape];
|
|
196
196
|
}
|
|
197
197
|
return next;
|
|
198
198
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaConversion.js","sources":["../../../../SchemaEditor/Tree/schemaConversion.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { JsonSchema, JsonSchemaProperty } from '../../types/JsonSchema';\nimport type { Property } from './Property';\nimport { PropertyType } from './PropertyType';\nimport { conceptPropertyName, uniquePropertyName } from './propertyNaming';\nimport { findPropertyById } from './propertyTree';\nimport { copySchemaKeywordOrder, itemSchemaKeywordOrder, schemaKeywordOrder, type SchemaOrderedProperty } from './SchemaOrderedProperty';\nimport { schemaInOriginalOrder } from './schemaInOriginalOrder';\n\n/**\n * The JSON Schema keyword carrying the concept a property is typed as. It annotates the primitive node the\n * concept wraps rather than replacing it, so anything that does not know about concepts — code generation,\n * an export, another tool — still reads a valid schema of the underlying primitive.\n */\nexport const CONCEPT_KEYWORD = 'x-concept';\n\n/**\n * The JSON Schema keyword marking the property that identifies its parent object. Written as `true` on the\n * property; at most one property of an object carries it.\n */\nexport const KEY_KEYWORD = 'x-key';\n\n/** The JSON Schema keyword marking a value generated when the command runs rather than entered. */\nexport const GENERATED_KEYWORD = 'x-generated';\n\ntype SchemaNode = Record<string, unknown>;\n\nconst isComplex = (type: PropertyType): boolean => type === PropertyType.Object || type === PropertyType.ObjectArray;\n\nconst identifier = (): string => Math.random().toString(36).slice(2, 10) + Math.random().toString(36).slice(2, 6);\n\n// ── JsonSchema → Property[] ─────────────────────────────────────────\n\nfunction schemaPropertyType(value: SchemaNode): PropertyType {\n const items = value.items as { type?: string } | undefined;\n\n switch (value.type) {\n case 'string':\n if (value.format === 'date') return PropertyType.Date;\n if (value.format === 'time') return PropertyType.Time;\n return PropertyType.String;\n case 'number':\n case 'integer':\n return PropertyType.Number;\n case 'boolean':\n return PropertyType.Boolean;\n case 'object':\n return PropertyType.Object;\n case 'array':\n if (items?.type === 'number' || items?.type === 'integer') return PropertyType.NumberArray;\n if (items?.type === 'object') return PropertyType.ObjectArray;\n return PropertyType.StringArray;\n default:\n return PropertyType.String;\n }\n}\n\nfunction vendorKeywords(node: SchemaNode, isProperty: boolean): Readonly<Record<string, unknown>> | undefined {\n const entries = Object.entries(node).filter(([name, value]) => {\n if (!name.startsWith('x-')) return false;\n if (!isProperty) return true;\n return name !== CONCEPT_KEYWORD && name !== KEY_KEYWORD && !(name === GENERATED_KEYWORD && value === true);\n });\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n}\n\nfunction readItemKeywords(node: SchemaNode): Partial<SchemaOrderedProperty> {\n if (node.type !== 'array' || typeof node.items !== 'object' || node.items === null) return {};\n const items = node.items as SchemaNode;\n const keywords = vendorKeywords(items, false);\n return { [itemSchemaKeywordOrder]: Object.keys(items), ...(keywords ? { itemVendorKeywords: keywords } : {}) };\n}\n\nfunction readFlags(node: SchemaNode, isRequired: boolean): Partial<SchemaOrderedProperty> {\n const keywords = vendorKeywords(node, true);\n return {\n [schemaKeywordOrder]: Object.keys(node),\n ...readItemKeywords(node),\n ...(keywords ? { vendorKeywords: keywords } : {}),\n ...(node[GENERATED_KEYWORD] === true ? { isGenerated: true } : {}),\n ...(isRequired ? { isRequired: true } : {}),\n ...(node[KEY_KEYWORD] === true ? { isKey: true } : {}),\n };\n}\n\nfunction schemaPropertyToProperty(name: string, value: JsonSchemaProperty, required: ReadonlySet<string>): Property {\n const node = value as unknown as SchemaNode;\n const type = schemaPropertyType(node);\n const concept = node[CONCEPT_KEYWORD];\n const flags = readFlags(node, required.has(name));\n\n const container = (type === PropertyType.Object ? node : type === PropertyType.ObjectArray ? node.items : undefined) as\n | { properties?: Record<string, JsonSchemaProperty>; required?: string[] }\n | undefined;\n\n if (container?.properties) {\n const childRequired = new Set(container.required ?? []);\n return copySchemaKeywordOrder(flags, {\n id: identifier(),\n name,\n type,\n ...flags,\n children: Object.entries(container.properties).map(([childName, child]) =>\n schemaPropertyToProperty(childName, child, childRequired)),\n });\n }\n\n return copySchemaKeywordOrder(flags, {\n id: identifier(),\n name,\n type,\n ...flags,\n ...(typeof concept === 'string' && concept.length > 0 ? { concept } : {}),\n });\n}\n\n/**\n * Converts a JSON Schema object into a property tree. Generates a new id for every property.\n * @param schema The schema to read; `undefined` and schemas without properties give an empty tree.\n * @returns The root properties.\n */\nexport function jsonSchemaToProperties(schema: JsonSchema | undefined): Property[] {\n if (!schema?.properties) return [];\n const required = new Set(schema.required ?? []);\n return Object.entries(schema.properties).map(([name, value]) => schemaPropertyToProperty(name, value, required));\n}\n\n// ── Property[] → JsonSchema ─────────────────────────────────────────\n\nfunction primitiveSchema(property: Property): SchemaNode {\n switch (property.type) {\n case PropertyType.Number:\n return { type: 'number' };\n case PropertyType.Boolean:\n return { type: 'boolean' };\n case PropertyType.Date:\n return { type: 'string', format: 'date' };\n case PropertyType.Time:\n return { type: 'string', format: 'time' };\n case PropertyType.Object:\n return { type: 'object', ...objectSchema(property.children ?? []) };\n case PropertyType.StringArray:\n return { type: 'array', items: { type: 'string', ...property.itemVendorKeywords } };\n case PropertyType.NumberArray:\n return { type: 'array', items: { type: 'number', ...property.itemVendorKeywords } };\n case PropertyType.ObjectArray:\n return { type: 'array', items: { type: 'object', ...objectSchema(property.children ?? []), ...property.itemVendorKeywords } };\n default:\n return { type: 'string' };\n }\n}\n\nfunction orderedPrimitiveSchema(property: SchemaOrderedProperty): SchemaNode {\n const schema = primitiveSchema(property);\n if (schema.items) schema.items = schemaInOriginalOrder(schema.items as SchemaNode, property[itemSchemaKeywordOrder]);\n return schema;\n}\n\nfunction propertyAnnotations(property: Property): SchemaNode {\n return {\n ...property.vendorKeywords,\n ...(property.isGenerated === true ? { [GENERATED_KEYWORD]: true } : {}),\n ...(property.concept ? { [CONCEPT_KEYWORD]: property.concept } : {}),\n ...(property.isKey === true ? { [KEY_KEYWORD]: true } : {}),\n };\n}\n\nfunction propertySchema(property: SchemaOrderedProperty): JsonSchemaProperty {\n return schemaInOriginalOrder({ ...orderedPrimitiveSchema(property), ...propertyAnnotations(property) }, property[schemaKeywordOrder]) as unknown as JsonSchemaProperty;\n}\n\nfunction objectSchema(properties: Property[]): { properties: Record<string, JsonSchemaProperty>; required?: string[] } {\n const schemaProperties: Record<string, JsonSchemaProperty> = {};\n for (const property of properties) {\n schemaProperties[property.name] = propertySchema(property);\n }\n const required = properties.filter(property => property.isRequired === true).map(property => property.name);\n return { properties: schemaProperties, ...(required.length > 0 ? { required } : {}) };\n}\n\n/**\n * Converts a property tree into a JSON Schema object. Empty `required` lists are omitted, and a property\n * typed as a concept or marked as the key carries the `x-concept` and `x-key` keywords. Vendor keywords are\n * preserved on properties and array items; generated values carry `x-generated: true`.\n * @param properties The root properties.\n * @param base The incoming schema. Root keys other than type, properties and required are preserved.\n * @returns The schema.\n */\nexport function propertiesToJsonSchema(properties: Property[], base: JsonSchema = {}): JsonSchema {\n const root = Object.fromEntries(Object.entries(base).filter(([name]) => !['properties', 'required'].includes(name)));\n return schemaInOriginalOrder({ ...root, type: 'object', ...objectSchema(properties) }, Object.keys(base)) as JsonSchema;\n}\n\n// ── Pure tree edits ─────────────────────────────────────────────────\n\nfunction newProperty(siblings: Property[], type: PropertyType, existingCount: number, concept?: string): Property {\n const base = isComplex(type) ? 'nested' : 'property';\n const name = concept ? uniquePropertyName(siblings, conceptPropertyName(concept)) : `${base}${existingCount + 1}`;\n\n return {\n id: identifier(),\n name,\n type,\n ...(concept ? { concept } : {}),\n ...(isComplex(type) ? { children: [] } : {}),\n };\n}\n\n/**\n * Appends a property to the root.\n * @param properties The root properties.\n * @param type The type of the new property.\n * @param existingCount The number of properties already in the tree, used to generate the default name; see {@link totalPropertyCount}.\n * @param concept The concept the property is typed as. When given the property is named after it.\n * @returns The new tree.\n */\nexport function addProperty(properties: Property[], type: PropertyType, existingCount: number, concept?: string): Property[] {\n return [...properties, newProperty(properties, type, existingCount, concept)];\n}\n\n/**\n * Appends a property to a nested object or object list.\n * @param properties The root properties.\n * @param parentId The id of the parent property.\n * @param type The type of the new property.\n * @param existingCount The number of properties already in the tree, used to generate the default name.\n * @param concept The concept the property is typed as.\n * @returns The new tree.\n */\nexport function addChildProperty(\n properties: Property[],\n parentId: string,\n type: PropertyType,\n existingCount: number,\n concept?: string,\n): Property[] {\n const siblings = findPropertyById(properties, parentId)?.children ?? [];\n const child = newProperty(siblings, type, existingCount, concept);\n const insert = (level: Property[]): Property[] => level.map(property => {\n if (property.id === parentId) return copySchemaKeywordOrder(property, { ...property, children: [...(property.children ?? []), child] });\n return property.children ? copySchemaKeywordOrder(property, { ...property, children: insert(property.children) }) : property;\n });\n return insert(properties);\n}\n\n/**\n * Removes a property, and everything nested under it.\n * @param properties The root properties.\n * @param targetId The id of the property to remove.\n * @returns The new tree.\n */\nexport function removeProperty(properties: Property[], targetId: string): Property[] {\n return properties\n .filter(property => property.id !== targetId)\n .map(property => property.children ? copySchemaKeywordOrder(property, { ...property, children: removeProperty(property.children, targetId) }) : property);\n}\n\nfunction updateProperty(properties: Property[], targetId: string, update: (property: Property) => Property): Property[] {\n return properties.map(property => {\n if (property.id === targetId) return update(property);\n return property.children ? copySchemaKeywordOrder(property, { ...property, children: updateProperty(property.children, targetId, update) }) : property;\n });\n}\n\n/**\n * Renames a property. Its requiredness travels with it, because both are stored against the property.\n * @param properties The root properties.\n * @param targetId The id of the property to rename.\n * @param newName The new name.\n * @returns The new tree.\n */\nexport function renameProperty(properties: Property[], targetId: string, newName: string): Property[] {\n return updateProperty(properties, targetId, property => copySchemaKeywordOrder(property, { ...property, name: newName }));\n}\n\nfunction retypedProperty(property: Property, newType: PropertyType, concept?: string): Property {\n const next: SchemaOrderedProperty = copySchemaKeywordOrder(property, {\n ...property,\n type: newType,\n concept,\n children: isComplex(newType) ? (property.children ?? []) : undefined,\n });\n if (property.type !== newType) {\n delete next.itemVendorKeywords;\n delete next[itemSchemaKeywordOrder];\n }\n return next;\n}\n\n/**\n * Changes the type of a property. Choosing a plain primitive drops the concept; choosing an object or\n * object list keeps the children, and any other type drops them. A different item kind clears item metadata.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @param newType The new type.\n * @param concept The concept the property is now typed as, if any.\n * @returns The new tree.\n */\nexport function changePropertyType(properties: Property[], targetId: string, newType: PropertyType, concept?: string): Property[] {\n return updateProperty(properties, targetId, property => retypedProperty(property, newType, concept));\n}\n\n/**\n * Flips whether a property is required.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @returns The new tree.\n */\nexport function toggleRequiredProperty(properties: Property[], targetId: string): Property[] {\n return updateProperty(properties, targetId, property => copySchemaKeywordOrder(property, { ...property, isRequired: !property.isRequired || undefined }));\n}\n\n/**\n * Sets whether a property is required. Requiring a nested property does not require its parent.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @param isRequired Whether the property must be present.\n * @returns The new tree.\n */\nexport function setRequiredProperty(properties: Property[], targetId: string, isRequired: boolean): Property[] {\n return updateProperty(properties, targetId, property => copySchemaKeywordOrder(property, { ...property, isRequired }));\n}\n\n/**\n * Sets whether a property's value is generated. An explicit edit replaces any non-true x-generated value.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @param isGenerated Whether the value is generated.\n * @returns The new tree.\n */\nexport function setGeneratedProperty(properties: Property[], targetId: string, isGenerated: boolean): Property[] {\n return updateProperty(properties, targetId, property => {\n const keywords = Object.fromEntries(Object.entries(property.vendorKeywords ?? {}).filter(([name]) => name !== GENERATED_KEYWORD));\n const next = { ...property };\n delete next.isGenerated;\n delete next.vendorKeywords;\n return copySchemaKeywordOrder(property, { ...next, ...(isGenerated ? { isGenerated: true } : {}), ...(Object.keys(keywords).length > 0 ? { vendorKeywords: keywords } : {}) });\n });\n}\n\n/**\n * Makes a property the key of its parent object, moving the key when a sibling held it. Choosing the\n * property that already is the key clears it, so an object can also have no key.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @returns The new tree.\n */\nexport function setKeyProperty(properties: Property[], targetId: string): Property[] {\n const target = properties.find(property => property.id === targetId);\n return properties.map(property => copySchemaKeywordOrder(property, {\n ...property,\n ...(target ? { isKey: property.id === targetId && target.isKey !== true ? true : undefined } : {}),\n ...(property.children ? { children: setKeyProperty(property.children, targetId) } : {}),\n }));\n}\n"],"names":[],"mappings":";;;;;;AAgBO,MAAM,eAAe,GAAG;AAMxB,MAAM,WAAW,GAAG;AA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G,EAAE,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;AAC1F,KAAA,CAAC,CAAC;AACP;;"}
|
|
1
|
+
{"version":3,"file":"schemaConversion.js","sources":["../../../../SchemaEditor/Tree/schemaConversion.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { JsonSchema, JsonSchemaProperty } from '../../types/JsonSchema';\nimport type { Property } from './Property';\nimport { PropertyType } from './PropertyType';\nimport { conceptPropertyName, uniquePropertyName } from './propertyNaming';\nimport { findPropertyById } from './propertyTree';\nimport { keywordsAfterTypeChange, propertyTypeFamily } from './keywordApplicability';\nimport {\n copySchemaKeywordOrder,\n itemSchemaKeywordOrder,\n schemaKeywordOrder,\n schemaOriginalShape,\n schemaRequiredOrder,\n type SchemaOrderedProperty,\n} from './SchemaOrderedProperty';\nimport { isNode, readOriginalShape, readRequiredOrder, restoreOriginalShape } from './originalShape';\nimport { schemaPropertyType } from './schemaPropertyType';\nimport { standardItemKeywords, standardPropertyKeywords } from './standardKeywords';\nimport { requiredInOriginalOrder, schemaInOriginalOrder } from './schemaInOriginalOrder';\n\n/**\n * The JSON Schema keyword carrying the concept a property is typed as. It annotates the primitive node the\n * concept wraps rather than replacing it, so anything that does not know about concepts — code generation,\n * an export, another tool — still reads a valid schema of the underlying primitive.\n */\nexport const CONCEPT_KEYWORD = 'x-concept';\n\n/**\n * The JSON Schema keyword marking the property that identifies its parent object. Written as `true` on the\n * property; at most one property of an object carries it.\n */\nexport const KEY_KEYWORD = 'x-key';\n\n/** The JSON Schema keyword marking a value generated when the command runs rather than entered. */\nexport const GENERATED_KEYWORD = 'x-generated';\n\ntype SchemaNode = Record<string, unknown>;\n\nconst isComplex = (type: PropertyType): boolean => type === PropertyType.Object || type === PropertyType.ObjectArray;\n\nconst identifier = (): string => Math.random().toString(36).slice(2, 10) + Math.random().toString(36).slice(2, 6);\n\n// ── JsonSchema → Property[] ─────────────────────────────────────────\n\nfunction vendorKeywords(node: SchemaNode, isProperty: boolean): Readonly<Record<string, unknown>> | undefined {\n const entries = Object.entries(node).filter(([name, value]) => {\n if (!name.startsWith('x-')) return false;\n if (!isProperty) return true;\n return name !== CONCEPT_KEYWORD && name !== KEY_KEYWORD && !(name === GENERATED_KEYWORD && value === true);\n });\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n}\n\nfunction readItemKeywords(node: SchemaNode, type: PropertyType): Partial<SchemaOrderedProperty> {\n if (node.type !== 'array' || !isNode(node.items)) return {};\n const items = node.items;\n const keywords = vendorKeywords(items, false);\n const standard = standardItemKeywords(items, type);\n return {\n [itemSchemaKeywordOrder]: Object.keys(items),\n ...(keywords ? { itemVendorKeywords: keywords } : {}),\n ...(standard ? { itemSchemaKeywords: standard } : {}),\n };\n}\n\nfunction requiredOrder(node: SchemaNode, type: PropertyType): Partial<SchemaOrderedProperty> {\n const order = readRequiredOrder(node, type);\n return order ? { [schemaRequiredOrder]: order } : {};\n}\n\nfunction readFlags(node: SchemaNode, type: PropertyType, isRequired: boolean): Partial<SchemaOrderedProperty> {\n const keywords = vendorKeywords(node, true);\n const standard = standardPropertyKeywords(node, type);\n return {\n [schemaKeywordOrder]: Object.keys(node),\n [schemaOriginalShape]: readOriginalShape(node, type),\n ...requiredOrder(node, type),\n ...readItemKeywords(node, type),\n ...(keywords ? { vendorKeywords: keywords } : {}),\n ...(standard ? { schemaKeywords: standard } : {}),\n ...(node[GENERATED_KEYWORD] === true ? { isGenerated: true } : {}),\n ...(isRequired ? { isRequired: true } : {}),\n ...(node[KEY_KEYWORD] === true ? { isKey: true } : {}),\n };\n}\n\nfunction schemaPropertyToProperty(name: string, value: JsonSchemaProperty, required: ReadonlySet<string>): Property {\n const node = value as unknown as SchemaNode;\n const type = schemaPropertyType(node);\n const concept = node[CONCEPT_KEYWORD];\n const flags = readFlags(node, type, required.has(name));\n\n const container = (type === PropertyType.Object ? node : type === PropertyType.ObjectArray ? node.items : undefined) as\n | { properties?: Record<string, JsonSchemaProperty>; required?: string[] }\n | undefined;\n\n if (container?.properties) {\n const childRequired = new Set(container.required ?? []);\n return copySchemaKeywordOrder(flags, {\n id: identifier(),\n name,\n type,\n ...flags,\n children: Object.entries(container.properties).map(([childName, child]) =>\n schemaPropertyToProperty(childName, child, childRequired)),\n });\n }\n\n return copySchemaKeywordOrder(flags, {\n id: identifier(),\n name,\n type,\n ...flags,\n ...(typeof concept === 'string' && concept.length > 0 ? { concept } : {}),\n });\n}\n\n/**\n * Converts a JSON Schema object into a property tree. Generates a new id for every property.\n * @param schema The schema to read; `undefined` and schemas without properties give an empty tree.\n * @returns The root properties.\n */\nexport function jsonSchemaToProperties(schema: JsonSchema | undefined): Property[] {\n if (!schema?.properties) return [];\n const required = new Set(schema.required ?? []);\n return Object.entries(schema.properties).map(([name, value]) => schemaPropertyToProperty(name, value, required));\n}\n\n// ── Property[] → JsonSchema ─────────────────────────────────────────\n\nfunction itemSchema(property: Property, type: string, extra: SchemaNode = {}): SchemaNode {\n return { ...property.itemSchemaKeywords, type, ...extra, ...property.itemVendorKeywords };\n}\n\nfunction primitiveSchema(property: Property): SchemaNode {\n switch (property.type) {\n case PropertyType.Number:\n return { type: 'number' };\n case PropertyType.Boolean:\n return { type: 'boolean' };\n case PropertyType.Date:\n return { type: 'string', format: 'date' };\n case PropertyType.Time:\n return { type: 'string', format: 'time' };\n case PropertyType.Object:\n return { type: 'object', ...objectSchema(property.children ?? [], (property as SchemaOrderedProperty)[schemaRequiredOrder]) };\n case PropertyType.StringArray:\n return { type: 'array', items: itemSchema(property, 'string') };\n case PropertyType.NumberArray:\n return { type: 'array', items: itemSchema(property, 'number') };\n case PropertyType.ObjectArray:\n return { type: 'array', items: itemSchema(property, 'object', objectSchema(property.children ?? [], (property as SchemaOrderedProperty)[schemaRequiredOrder])) };\n default:\n return { type: 'string' };\n }\n}\n\nfunction orderedPrimitiveSchema(property: SchemaOrderedProperty): SchemaNode {\n const schema = restoreOriginalShape({ ...property.schemaKeywords, ...primitiveSchema(property) }, property);\n if (isNode(schema.items)) schema.items = schemaInOriginalOrder(schema.items as SchemaNode, property[itemSchemaKeywordOrder]);\n return schema;\n}\n\nfunction propertyAnnotations(property: Property): SchemaNode {\n return {\n ...property.vendorKeywords,\n ...(property.isGenerated === true ? { [GENERATED_KEYWORD]: true } : {}),\n ...(property.concept ? { [CONCEPT_KEYWORD]: property.concept } : {}),\n ...(property.isKey === true ? { [KEY_KEYWORD]: true } : {}),\n };\n}\n\nfunction propertySchema(property: SchemaOrderedProperty): JsonSchemaProperty {\n return schemaInOriginalOrder({ ...orderedPrimitiveSchema(property), ...propertyAnnotations(property) }, property[schemaKeywordOrder]) as unknown as JsonSchemaProperty;\n}\n\nfunction objectSchema(properties: Property[], requiredOrder?: readonly string[]): { properties: Record<string, JsonSchemaProperty>; required?: string[] } {\n const schemaProperties: Record<string, JsonSchemaProperty> = {};\n for (const property of properties) {\n schemaProperties[property.name] = propertySchema(property);\n }\n const required = requiredInOriginalOrder(properties.filter(property => property.isRequired === true).map(property => property.name), requiredOrder);\n return { properties: schemaProperties, ...(required.length > 0 ? { required } : {}) };\n}\n\n/**\n * Converts a property tree into a JSON Schema object. Empty `required` lists are omitted, and a property\n * typed as a concept or marked as the key carries the `x-concept` and `x-key` keywords. Vendor keywords and the\n * standard keywords the editor does not model are preserved on properties and array items; generated values carry `x-generated: true`.\n * @param properties The root properties.\n * @param base The incoming schema. Root keys other than type, properties and required are preserved.\n * @returns The schema.\n */\nexport function propertiesToJsonSchema(properties: Property[], base: JsonSchema = {}): JsonSchema {\n const root = Object.fromEntries(Object.entries(base).filter(([name]) => !['properties', 'required'].includes(name)));\n return schemaInOriginalOrder({ ...root, type: 'object', ...objectSchema(properties, base.required) }, Object.keys(base)) as JsonSchema;\n}\n\n// ── Pure tree edits ─────────────────────────────────────────────────\n\nfunction newProperty(siblings: Property[], type: PropertyType, existingCount: number, concept?: string): Property {\n const base = isComplex(type) ? 'nested' : 'property';\n const name = concept ? uniquePropertyName(siblings, conceptPropertyName(concept)) : `${base}${existingCount + 1}`;\n\n return {\n id: identifier(),\n name,\n type,\n ...(concept ? { concept } : {}),\n ...(isComplex(type) ? { children: [] } : {}),\n };\n}\n\n/**\n * Appends a property to the root.\n * @param properties The root properties.\n * @param type The type of the new property.\n * @param existingCount The number of properties already in the tree, used to generate the default name; see {@link totalPropertyCount}.\n * @param concept The concept the property is typed as. When given the property is named after it.\n * @returns The new tree.\n */\nexport function addProperty(properties: Property[], type: PropertyType, existingCount: number, concept?: string): Property[] {\n return [...properties, newProperty(properties, type, existingCount, concept)];\n}\n\n/**\n * Appends a property to a nested object or object list.\n * @param properties The root properties.\n * @param parentId The id of the parent property.\n * @param type The type of the new property.\n * @param existingCount The number of properties already in the tree, used to generate the default name.\n * @param concept The concept the property is typed as.\n * @returns The new tree.\n */\nexport function addChildProperty(\n properties: Property[],\n parentId: string,\n type: PropertyType,\n existingCount: number,\n concept?: string,\n): Property[] {\n const siblings = findPropertyById(properties, parentId)?.children ?? [];\n const child = newProperty(siblings, type, existingCount, concept);\n const insert = (level: Property[]): Property[] => level.map(property => {\n if (property.id === parentId) return copySchemaKeywordOrder(property, { ...property, children: [...(property.children ?? []), child] });\n return property.children ? copySchemaKeywordOrder(property, { ...property, children: insert(property.children) }) : property;\n });\n return insert(properties);\n}\n\n/**\n * Removes a property, and everything nested under it.\n * @param properties The root properties.\n * @param targetId The id of the property to remove.\n * @returns The new tree.\n */\nexport function removeProperty(properties: Property[], targetId: string): Property[] {\n return properties\n .filter(property => property.id !== targetId)\n .map(property => property.children ? copySchemaKeywordOrder(property, { ...property, children: removeProperty(property.children, targetId) }) : property);\n}\n\nfunction updateProperty(properties: Property[], targetId: string, update: (property: Property) => Property): Property[] {\n return properties.map(property => {\n if (property.id === targetId) return update(property);\n return property.children ? copySchemaKeywordOrder(property, { ...property, children: updateProperty(property.children, targetId, update) }) : property;\n });\n}\n\n/**\n * Renames a property. Its requiredness travels with it, because both are stored against the property.\n * @param properties The root properties.\n * @param targetId The id of the property to rename.\n * @param newName The new name.\n * @returns The new tree.\n */\nexport function renameProperty(properties: Property[], targetId: string, newName: string): Property[] {\n return updateProperty(properties, targetId, property => copySchemaKeywordOrder(property, { ...property, name: newName }));\n}\n\nfunction retypedProperty(property: Property, newType: PropertyType, concept?: string): Property {\n const next: SchemaOrderedProperty = copySchemaKeywordOrder(property, {\n ...property,\n type: newType,\n concept,\n children: isComplex(newType) ? (property.children ?? []) : undefined,\n });\n if (property.type !== newType) {\n const kept = keywordsAfterTypeChange(property.schemaKeywords ?? {}, propertyTypeFamily(property.type), propertyTypeFamily(newType));\n delete next.schemaKeywords;\n if (Object.keys(kept).length > 0) next.schemaKeywords = kept;\n delete next.itemVendorKeywords;\n delete next.itemSchemaKeywords;\n delete next[itemSchemaKeywordOrder];\n delete next[schemaOriginalShape];\n }\n return next;\n}\n\n/**\n * Changes the type of a property. Choosing a plain primitive drops the concept; choosing an object or\n * object list keeps the children, and any other type drops them. A different type keeps the annotations and the\n * constraints of the same keyword family, and drops value keywords, the original type and format, item metadata\n * and every other standard keyword that no longer applies. The same type keeps everything.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @param newType The new type.\n * @param concept The concept the property is now typed as, if any.\n * @returns The new tree.\n */\nexport function changePropertyType(properties: Property[], targetId: string, newType: PropertyType, concept?: string): Property[] {\n return updateProperty(properties, targetId, property => retypedProperty(property, newType, concept));\n}\n\n/**\n * Flips whether a property is required.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @returns The new tree.\n */\nexport function toggleRequiredProperty(properties: Property[], targetId: string): Property[] {\n return updateProperty(properties, targetId, property => copySchemaKeywordOrder(property, { ...property, isRequired: !property.isRequired || undefined }));\n}\n\n/**\n * Sets whether a property is required. Requiring a nested property does not require its parent.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @param isRequired Whether the property must be present.\n * @returns The new tree.\n */\nexport function setRequiredProperty(properties: Property[], targetId: string, isRequired: boolean): Property[] {\n return updateProperty(properties, targetId, property => copySchemaKeywordOrder(property, { ...property, isRequired }));\n}\n\n/**\n * Sets whether a property's value is generated. An explicit edit replaces any non-true x-generated value.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @param isGenerated Whether the value is generated.\n * @returns The new tree.\n */\nexport function setGeneratedProperty(properties: Property[], targetId: string, isGenerated: boolean): Property[] {\n return updateProperty(properties, targetId, property => {\n const keywords = Object.fromEntries(Object.entries(property.vendorKeywords ?? {}).filter(([name]) => name !== GENERATED_KEYWORD));\n const next = { ...property };\n delete next.isGenerated;\n delete next.vendorKeywords;\n return copySchemaKeywordOrder(property, { ...next, ...(isGenerated ? { isGenerated: true } : {}), ...(Object.keys(keywords).length > 0 ? { vendorKeywords: keywords } : {}) });\n });\n}\n\n/**\n * Makes a property the key of its parent object, moving the key when a sibling held it. Choosing the\n * property that already is the key clears it, so an object can also have no key.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @returns The new tree.\n */\nexport function setKeyProperty(properties: Property[], targetId: string): Property[] {\n const target = properties.find(property => property.id === targetId);\n return properties.map(property => copySchemaKeywordOrder(property, {\n ...property,\n ...(target ? { isKey: property.id === targetId && target.isKey !== true ? true : undefined } : {}),\n ...(property.children ? { children: setKeyProperty(property.children, targetId) } : {}),\n }));\n}\n"],"names":[],"mappings":";;;;;;;;;;AA2BO,MAAM,eAAe,GAAG;AAMxB,MAAM,WAAW,GAAG;AAGpB,MAAM,iBAAiB,GAAG;AAIjC,MAAM,SAAS,GAAG,CAAC,IAAkB,KAAc,IAAI,KAAK,YAAY,CAAC,MAAM,IAAI,IAAI,KAAK,YAAY,CAAC,WAAW;AAEpH,MAAM,UAAU,GAAG,MAAc,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE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