@esri/hub-common 14.79.0 → 14.79.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/core/schemas/internal/subsetSchema.js +28 -6
- package/dist/esm/core/schemas/internal/subsetSchema.js.map +1 -1
- package/dist/node/core/schemas/internal/subsetSchema.js +28 -6
- package/dist/node/core/schemas/internal/subsetSchema.js.map +1 -1
- package/dist/types/core/schemas/internal/subsetSchema.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,17 +4,39 @@ import { cloneObject } from "../../../util";
|
|
|
4
4
|
* @param schema
|
|
5
5
|
* @param props
|
|
6
6
|
* @returns
|
|
7
|
+
*
|
|
7
8
|
*/
|
|
8
9
|
export function subsetSchema(schema, props) {
|
|
9
10
|
const subset = cloneObject(schema);
|
|
10
11
|
// 1. remove un-specified properties from the "required" array
|
|
11
|
-
|
|
12
|
+
if (subset.required) {
|
|
13
|
+
subset.required = [...subset.required].filter((required) => props.includes(required));
|
|
14
|
+
}
|
|
12
15
|
// 2. filter the rest of the schema down to the specified properties
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (subset.properties) {
|
|
17
|
+
Object.keys(subset.properties).forEach((key) => {
|
|
18
|
+
if (props.indexOf(key) === -1) {
|
|
19
|
+
delete subset.properties[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// 3. filter schema compositions (anyOf, allOf, oneOf) down
|
|
24
|
+
// to specified properties
|
|
25
|
+
// TODO: enhance subset functionality to filter more complex
|
|
26
|
+
// compositional schemas (anyOf, oneOf) and non-if/then/else conditional structures.
|
|
27
|
+
// Also enhance to account for whole compositions versus individual clauses.
|
|
28
|
+
if (subset.allOf) {
|
|
29
|
+
subset.allOf = subset.allOf.map((s) => subsetSchema(s, props));
|
|
30
|
+
}
|
|
31
|
+
if (subset.if) {
|
|
32
|
+
subset.if = subsetSchema(subset.if, props);
|
|
33
|
+
}
|
|
34
|
+
if (subset.then) {
|
|
35
|
+
subset.then = subsetSchema(subset.then, props);
|
|
36
|
+
}
|
|
37
|
+
if (subset.else) {
|
|
38
|
+
subset.else = subsetSchema(subset.else, props);
|
|
39
|
+
}
|
|
18
40
|
return subset;
|
|
19
41
|
}
|
|
20
42
|
//# sourceMappingURL=subsetSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subsetSchema.js","sourceRoot":"","sources":["../../../../../src/core/schemas/internal/subsetSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C
|
|
1
|
+
{"version":3,"file":"subsetSchema.js","sourceRoot":"","sources":["../../../../../src/core/schemas/internal/subsetSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,MAA4B,EAC5B,KAAe;IAEf,MAAM,MAAM,GAAyB,WAAW,CAAC,MAAM,CAAC,CAAC;IAEzD,8DAA8D;IAC9D,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CACzD,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACzB,CAAC;KACH;IAED,oEAAoE;IACpE,IAAI,MAAM,CAAC,UAAU,EAAE;QACrB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC7B,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aAC/B;QACH,CAAC,CAAC,CAAC;KACJ;IAED,2DAA2D;IAC3D,0BAA0B;IAE1B,4DAA4D;IAC5D,oFAAoF;IACpF,4EAA4E;IAE5E,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACpC,YAAY,CAAC,CAAyB,EAAE,KAAK,CAAC,CAC/C,CAAC;KACH;IAED,IAAI,MAAM,CAAC,EAAE,EAAE;QACb,MAAM,CAAC,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,EAA0B,EAAE,KAAK,CAAC,CAAC;KACpE;IAED,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,IAA4B,EAAE,KAAK,CAAC,CAAC;KACxE;IAED,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,IAA4B,EAAE,KAAK,CAAC,CAAC;KACxE;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -7,17 +7,39 @@ const util_1 = require("../../../util");
|
|
|
7
7
|
* @param schema
|
|
8
8
|
* @param props
|
|
9
9
|
* @returns
|
|
10
|
+
*
|
|
10
11
|
*/
|
|
11
12
|
function subsetSchema(schema, props) {
|
|
12
13
|
const subset = util_1.cloneObject(schema);
|
|
13
14
|
// 1. remove un-specified properties from the "required" array
|
|
14
|
-
|
|
15
|
+
if (subset.required) {
|
|
16
|
+
subset.required = [...subset.required].filter((required) => props.includes(required));
|
|
17
|
+
}
|
|
15
18
|
// 2. filter the rest of the schema down to the specified properties
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (subset.properties) {
|
|
20
|
+
Object.keys(subset.properties).forEach((key) => {
|
|
21
|
+
if (props.indexOf(key) === -1) {
|
|
22
|
+
delete subset.properties[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// 3. filter schema compositions (anyOf, allOf, oneOf) down
|
|
27
|
+
// to specified properties
|
|
28
|
+
// TODO: enhance subset functionality to filter more complex
|
|
29
|
+
// compositional schemas (anyOf, oneOf) and non-if/then/else conditional structures.
|
|
30
|
+
// Also enhance to account for whole compositions versus individual clauses.
|
|
31
|
+
if (subset.allOf) {
|
|
32
|
+
subset.allOf = subset.allOf.map((s) => subsetSchema(s, props));
|
|
33
|
+
}
|
|
34
|
+
if (subset.if) {
|
|
35
|
+
subset.if = subsetSchema(subset.if, props);
|
|
36
|
+
}
|
|
37
|
+
if (subset.then) {
|
|
38
|
+
subset.then = subsetSchema(subset.then, props);
|
|
39
|
+
}
|
|
40
|
+
if (subset.else) {
|
|
41
|
+
subset.else = subsetSchema(subset.else, props);
|
|
42
|
+
}
|
|
21
43
|
return subset;
|
|
22
44
|
}
|
|
23
45
|
exports.subsetSchema = subsetSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subsetSchema.js","sourceRoot":"","sources":["../../../../../src/core/schemas/internal/subsetSchema.ts"],"names":[],"mappings":";;;AAAA,wCAA4C;AAG5C
|
|
1
|
+
{"version":3,"file":"subsetSchema.js","sourceRoot":"","sources":["../../../../../src/core/schemas/internal/subsetSchema.ts"],"names":[],"mappings":";;;AAAA,wCAA4C;AAG5C;;;;;;GAMG;AACH,SAAgB,YAAY,CAC1B,MAA4B,EAC5B,KAAe;IAEf,MAAM,MAAM,GAAyB,kBAAW,CAAC,MAAM,CAAC,CAAC;IAEzD,8DAA8D;IAC9D,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CACzD,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACzB,CAAC;KACH;IAED,oEAAoE;IACpE,IAAI,MAAM,CAAC,UAAU,E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