@adobe/data 0.1.2 → 0.1.3
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/cache/blob-store.d.ts +1 -1
- package/cache/managed-array.d.ts +1 -1
- package/core/functions/deep-merge.d.ts +3 -2
- package/core/functions/deep-merge.js +10 -7
- package/core/functions/deep-merge.js.map +1 -1
- package/core/functions/index.d.ts +0 -1
- package/core/functions/index.js +0 -1
- package/core/functions/index.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/schema/dynamic/dynamic-schema.d.ts +27 -0
- package/core/schema/dynamic/dynamic-schema.js +2 -0
- package/core/schema/dynamic/dynamic-schema.js.map +1 -0
- package/core/schema/dynamic/enumerate-patches.d.ts +9 -0
- package/core/schema/dynamic/enumerate-patches.js +50 -0
- package/core/schema/dynamic/enumerate-patches.js.map +1 -0
- package/core/schema/dynamic/enumerate-patches.test.d.ts +134 -0
- package/core/schema/dynamic/enumerate-patches.test.js +209 -0
- package/core/schema/dynamic/enumerate-patches.test.js.map +1 -0
- package/core/schema/dynamic/get-dynamic-schema.d.ts +5 -0
- package/core/schema/dynamic/get-dynamic-schema.js +26 -0
- package/core/schema/dynamic/get-dynamic-schema.js.map +1 -0
- package/core/schema/dynamic/get-dynamic-schema.test.d.ts +1 -0
- package/core/schema/dynamic/get-dynamic-schema.test.js +94 -0
- package/core/schema/dynamic/get-dynamic-schema.test.js.map +1 -0
- package/core/schema/dynamic/index.d.ts +1 -0
- package/core/schema/dynamic/index.js +2 -0
- package/core/schema/dynamic/index.js.map +1 -0
- package/core/schema/dynamic/schema-path-value-path.d.ts +5 -0
- package/core/schema/dynamic/schema-path-value-path.js +12 -0
- package/core/schema/dynamic/schema-path-value-path.js.map +1 -0
- package/core/schema/dynamic-schema.d.ts +27 -0
- package/core/schema/dynamic-schema.js +2 -0
- package/core/schema/dynamic-schema.js.map +1 -0
- package/core/schema/index.d.ts +4 -0
- package/core/schema/index.js +26 -0
- package/core/schema/index.js.map +1 -0
- package/core/schema/schema.d.ts +122 -0
- package/core/schema/schema.js +34 -0
- package/core/schema/schema.js.map +1 -0
- package/core/schema/schemas.d.ts +45 -0
- package/core/schema/schemas.js +39 -0
- package/core/schema/schemas.js.map +1 -0
- package/core/schema/ui-schema.d.ts +25 -0
- package/core/schema/ui-schema.js +2 -0
- package/core/schema/ui-schema.js.map +1 -0
- package/core/schema/validation/is-valid.d.ts +2 -0
- package/core/schema/validation/is-valid.js +14 -0
- package/core/schema/validation/is-valid.js.map +1 -0
- package/core/schema/validation/is-valid.test.d.ts +1 -0
- package/core/schema/validation/is-valid.test.js +40 -0
- package/core/schema/validation/is-valid.test.js.map +1 -0
- package/core/schema/validation/validate.d.ts +2 -0
- package/core/schema/validation/validate.js +38 -0
- package/core/schema/validation/validate.js.map +1 -0
- package/core/schema/validation/validate.test.d.ts +1 -0
- package/core/schema/validation/validate.test.js +106 -0
- package/core/schema/validation/validate.test.js.map +1 -0
- package/core/schema/validation/with-validation.d.ts +5 -0
- package/core/schema/validation/with-validation.js +16 -0
- package/core/schema/validation/with-validation.js.map +1 -0
- package/core/schema/validation/with-validation.test.d.ts +1 -0
- package/core/schema/validation/with-validation.test.js +96 -0
- package/core/schema/validation/with-validation.test.js.map +1 -0
- package/core/schemas.d.ts +45 -0
- package/core/schemas.js +39 -0
- package/core/schemas.js.map +1 -0
- package/ecs/action-ecs/action-ecs.test.js +1 -1
- package/ecs/action-ecs/action-ecs.test.js.map +1 -1
- package/ecs/core-ecs/core-ecs.js +3 -3
- package/ecs/core-ecs/core-ecs.js.map +1 -1
- package/ecs/core-ecs/core-ecs.test.js +22 -1
- package/ecs/core-ecs/core-ecs.test.js.map +1 -1
- package/ecs/ecs/ecs.test.js +1 -1
- package/ecs/ecs/ecs.test.js.map +1 -1
- package/package.json +3 -2
- package/perftest/ecs-perf.js +1 -1
- package/perftest/ecs-perf.js.map +1 -1
- package/schemas/index.d.ts +1 -1
- package/schemas/index.js +1 -1
- package/schemas/index.js.map +1 -1
- package/service/progressive-result.d.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/cache/blob-store.d.ts
CHANGED
package/cache/managed-array.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MemoryAllocator } from "./memory-allocator.js";
|
|
2
|
-
import { FromSchema, Schema } from "../core/schema.js";
|
|
2
|
+
import { FromSchema, Schema } from "../core/schema/schema.js";
|
|
3
3
|
import { Data } from "../core/index.js";
|
|
4
4
|
export interface NativeArray<T> {
|
|
5
5
|
readonly length: number;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type Data } from '../data.js';
|
|
2
1
|
/**
|
|
3
2
|
* Uses datacache to store results so we can avoid expensive recomputations of the same input.
|
|
4
3
|
* This function also uses preventParallelExecution to prevent multiple executions of the same function at the same time with the same arguments.
|
|
@@ -28,4 +27,6 @@ import { type Data } from '../data.js';
|
|
|
28
27
|
* deepMerge(one, other);
|
|
29
28
|
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
|
|
30
29
|
*/
|
|
31
|
-
export declare const deepMerge: <A
|
|
30
|
+
export declare const deepMerge: <A, B>(a: A, b: B, options?: {
|
|
31
|
+
mergeArrays?: boolean;
|
|
32
|
+
}) => A & B;
|
|
@@ -27,23 +27,26 @@
|
|
|
27
27
|
* deepMerge(one, other);
|
|
28
28
|
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
|
|
29
29
|
*/
|
|
30
|
-
export const deepMerge = (a, b) => {
|
|
30
|
+
export const deepMerge = (a, b, options = {}) => {
|
|
31
|
+
const { mergeArrays = true } = options;
|
|
31
32
|
// Handle null/undefined cases
|
|
32
|
-
if (a == null)
|
|
33
|
-
return b;
|
|
34
|
-
// Handle primitive values
|
|
35
|
-
if (typeof a !== 'object' || typeof b !== 'object')
|
|
33
|
+
if (a == null || typeof a !== 'object' || typeof b !== 'object')
|
|
36
34
|
return b;
|
|
37
35
|
// Handle arrays
|
|
38
36
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
39
|
-
|
|
37
|
+
if (mergeArrays) {
|
|
38
|
+
return [...a, ...b];
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return b;
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
44
|
// Handle objects
|
|
42
45
|
const result = { ...a };
|
|
43
46
|
for (const key in b) {
|
|
44
47
|
if (Object.prototype.hasOwnProperty.call(b, key)) {
|
|
45
48
|
const value = b[key];
|
|
46
|
-
result[key] = deepMerge(a[key], value);
|
|
49
|
+
result[key] = deepMerge(a[key], value, options);
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-merge.js","sourceRoot":"","sources":["../../../src/core/functions/deep-merge.ts"],"names":[],"mappings":"AAuBA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"deep-merge.js","sourceRoot":"","sources":["../../../src/core/functions/deep-merge.ts"],"names":[],"mappings":"AAuBA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAO,CAAI,EAAE,CAAI,EAAE,UAAqC,EAAE,EAAS,EAAE;IAC5F,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACvC,8BAA8B;IAC9B,IAAI,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAU,CAAC;IAEnF,gBAAgB;IAChB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAqB,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,OAAO,CAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAED,iBAAiB;IACjB,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,EAA0B,CAAC;IAChD,KAAK,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;QACpB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;YACjD,MAAM,KAAK,GAAI,CAA0B,CAAC,GAAG,CAAC,CAAC;YAC/C,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,CAA0B,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IACD,OAAO,MAAe,CAAC;AACzB,CAAC,CAAC"}
|
package/core/functions/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/functions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/functions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAA"}
|
package/core/index.d.ts
CHANGED
package/core/index.js
CHANGED
|
@@ -20,6 +20,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.*/
|
|
22
22
|
export * from "./data.js";
|
|
23
|
-
export * from "./schema.js";
|
|
23
|
+
export * from "./schema/index.js";
|
|
24
24
|
export * from "./functions/index.js";
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
package/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Data } from "../../../index.js";
|
|
2
|
+
import { Schema } from "../schema.js";
|
|
3
|
+
type JSONPath = string;
|
|
4
|
+
type JSONMergePatch = Data;
|
|
5
|
+
/**
|
|
6
|
+
* Conditional patch applied to the path when the enclosing schema branch is active
|
|
7
|
+
* and `match` is not present or validates against the root.
|
|
8
|
+
*/
|
|
9
|
+
export interface Conditional {
|
|
10
|
+
readonly match?: Schema;
|
|
11
|
+
readonly path: JSONPath;
|
|
12
|
+
readonly value: JSONMergePatch;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A Dynamic Schema extends a base schema with conditional behaviour
|
|
16
|
+
* based upon the current state of the data the schema describes.
|
|
17
|
+
*/
|
|
18
|
+
export type DynamicSchema<B extends Schema> = B & {
|
|
19
|
+
readonly conditionals?: readonly Conditional[];
|
|
20
|
+
readonly items?: DynamicSchema<B>;
|
|
21
|
+
readonly properties?: {
|
|
22
|
+
readonly [key: string]: DynamicSchema<B>;
|
|
23
|
+
};
|
|
24
|
+
readonly additionalProperties?: boolean | DynamicSchema<B>;
|
|
25
|
+
readonly oneOf?: readonly DynamicSchema<B>[];
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-schema.js","sourceRoot":"","sources":["../../../../src/core/schema/dynamic/dynamic-schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from "../schema.js";
|
|
2
|
+
import { PathComponent } from "jsonpath";
|
|
3
|
+
export type EnumeratePatch = {
|
|
4
|
+
/** The path to the target node. */
|
|
5
|
+
path: PathComponent[];
|
|
6
|
+
/** The fragment that will be patched into the target. */
|
|
7
|
+
fragment: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare function enumeratePatches(currentSchema: Schema, currentValue: unknown, rootValue?: unknown, rootSchema?: Schema, currentPath?: PathComponent[], localPath?: PathComponent[]): Generator<EnumeratePatch>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import jp from "jsonpath";
|
|
2
|
+
import { isValid } from "../validation/is-valid.js";
|
|
3
|
+
export function* enumeratePatches(currentSchema, currentValue, rootValue = currentValue, rootSchema = currentSchema, currentPath = ["$"], localPath = ["$"]) {
|
|
4
|
+
if (currentValue === undefined || currentValue === null) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
// local conditionals
|
|
8
|
+
for (const c of currentSchema.conditionals ?? []) {
|
|
9
|
+
// get the value of the current path
|
|
10
|
+
const localValue = jp.value(rootValue, jp.stringify(localPath));
|
|
11
|
+
// if (currentSchema.conditionals) {
|
|
12
|
+
// console.log("enumeratePatches", JSON.stringify(c, null, 2));
|
|
13
|
+
// // console.log("currentPath", currentPath);
|
|
14
|
+
// // console.log("localPath", localPath);
|
|
15
|
+
// console.log("localValue", localValue);
|
|
16
|
+
// }
|
|
17
|
+
if (!c.match || isValid(c.match, localValue)) {
|
|
18
|
+
// jsonpath.query returns *values*, not references to
|
|
19
|
+
// the parent object. We use jp.paths to get the JSONPaths
|
|
20
|
+
// of selected nodes, then query again to fetch each node.
|
|
21
|
+
for (const p of jp.paths(rootSchema, c.path)) {
|
|
22
|
+
yield { path: p, fragment: c.value };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// recurse
|
|
27
|
+
// items
|
|
28
|
+
if (currentSchema.items && Array.isArray(currentValue)) {
|
|
29
|
+
for (const [i, childSchema] of Object.entries(currentSchema.items)) {
|
|
30
|
+
for (const val of currentValue) {
|
|
31
|
+
yield* enumeratePatches(childSchema, val, rootValue, rootSchema, [...currentPath, "items", i], [...localPath, i]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// properties
|
|
36
|
+
if (currentSchema.properties && typeof currentValue === "object") {
|
|
37
|
+
for (const [k, childSchema] of Object.entries(currentSchema.properties)) {
|
|
38
|
+
yield* enumeratePatches(childSchema, currentValue[k], rootValue, rootSchema, [...currentPath, "properties", k], [...localPath, k]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// oneOf
|
|
42
|
+
if (currentSchema.oneOf?.length) {
|
|
43
|
+
for (const branch of currentSchema.oneOf) {
|
|
44
|
+
if (isValid(branch, currentValue)) {
|
|
45
|
+
yield* enumeratePatches(branch, currentValue, rootValue, rootSchema, [...currentPath, "oneOf"], [...localPath]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=enumerate-patches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumerate-patches.js","sourceRoot":"","sources":["../../../../src/core/schema/dynamic/enumerate-patches.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AASpD,MAAM,SAAS,CAAC,CAAC,gBAAgB,CAC7B,aAAqB,EACrB,YAAqB,EACrB,YAAqB,YAAY,EACjC,aAAqB,aAAa,EAClC,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,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACtH,CAAC;QACL,CAAC;IACL,CAAC;IAED,aAAa;IACb,IAAI,aAAa,CAAC,UAAU,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC/D,KAAK,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;YACtE,KAAK,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAG,YAAoB,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,GAAG,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;QAChJ,CAAC;IACL,CAAC;IAED,SAAS;IACT,IAAI,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QAC9B,KAAK,MAAM,MAAM,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;YACvC,IAAI,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;gBAChC,KAAK,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,GAAG,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;YACpH,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export declare const PersonSchema: {
|
|
2
|
+
readonly type: "object";
|
|
3
|
+
readonly properties: {
|
|
4
|
+
readonly name: {
|
|
5
|
+
readonly type: "string";
|
|
6
|
+
readonly ui: {
|
|
7
|
+
readonly name: "Name";
|
|
8
|
+
readonly placeholder: "John Doe";
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
readonly age: {
|
|
12
|
+
readonly type: "number";
|
|
13
|
+
readonly default: 30;
|
|
14
|
+
readonly minimum: 0;
|
|
15
|
+
readonly maximum: 100;
|
|
16
|
+
readonly ui: {
|
|
17
|
+
readonly name: "Age";
|
|
18
|
+
};
|
|
19
|
+
readonly conditionals: readonly [{
|
|
20
|
+
readonly path: "$.properties.email.ui";
|
|
21
|
+
readonly value: {
|
|
22
|
+
readonly visible: false;
|
|
23
|
+
};
|
|
24
|
+
readonly match: {
|
|
25
|
+
readonly exclusiveMaximum: 18;
|
|
26
|
+
};
|
|
27
|
+
}];
|
|
28
|
+
};
|
|
29
|
+
readonly email: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly ui: {
|
|
32
|
+
readonly name: "Email";
|
|
33
|
+
readonly placeholder: "john.doe@example.com";
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
readonly additionalProperties: false;
|
|
38
|
+
};
|
|
39
|
+
export declare const PersonSchemaWithOneOf: {
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
readonly properties: {
|
|
42
|
+
readonly name: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly ui: {
|
|
45
|
+
readonly name: "Name";
|
|
46
|
+
readonly placeholder: "John Doe";
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly species: {
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly oneOf: readonly [{
|
|
52
|
+
readonly const: "human";
|
|
53
|
+
readonly conditionals: readonly [{
|
|
54
|
+
readonly path: "$.properties.email.ui";
|
|
55
|
+
readonly value: {
|
|
56
|
+
readonly visible: true;
|
|
57
|
+
};
|
|
58
|
+
}];
|
|
59
|
+
}, {
|
|
60
|
+
readonly const: "robot";
|
|
61
|
+
readonly conditionals: readonly [{
|
|
62
|
+
readonly path: "$.properties.email.ui";
|
|
63
|
+
readonly value: {
|
|
64
|
+
readonly enabled: false;
|
|
65
|
+
};
|
|
66
|
+
}];
|
|
67
|
+
}];
|
|
68
|
+
};
|
|
69
|
+
readonly email: {
|
|
70
|
+
readonly type: "string";
|
|
71
|
+
readonly ui: {
|
|
72
|
+
readonly name: "Email";
|
|
73
|
+
readonly placeholder: "john.doe@example.com";
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
readonly additionalProperties: false;
|
|
78
|
+
};
|
|
79
|
+
export declare const PersonSchemaRootConditions: {
|
|
80
|
+
readonly type: "object";
|
|
81
|
+
readonly properties: {
|
|
82
|
+
readonly name: {
|
|
83
|
+
readonly type: "string";
|
|
84
|
+
readonly ui: {
|
|
85
|
+
readonly name: "Name";
|
|
86
|
+
readonly placeholder: "John Doe";
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly species: {
|
|
90
|
+
readonly type: "string";
|
|
91
|
+
readonly oneOf: readonly [{
|
|
92
|
+
readonly const: "human";
|
|
93
|
+
}, {
|
|
94
|
+
readonly const: "robot";
|
|
95
|
+
}];
|
|
96
|
+
};
|
|
97
|
+
readonly email: {
|
|
98
|
+
readonly type: "string";
|
|
99
|
+
readonly ui: {
|
|
100
|
+
readonly name: "Email";
|
|
101
|
+
readonly placeholder: "john.doe@example.com";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly conditionals: readonly [{
|
|
106
|
+
readonly path: "$.properties.email.ui";
|
|
107
|
+
readonly value: {
|
|
108
|
+
readonly visible: false;
|
|
109
|
+
};
|
|
110
|
+
readonly match: {
|
|
111
|
+
readonly properties: {
|
|
112
|
+
readonly name: {
|
|
113
|
+
readonly maxLength: 2;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}, {
|
|
118
|
+
readonly path: "$.properties.email.ui";
|
|
119
|
+
readonly value: {
|
|
120
|
+
readonly visible: true;
|
|
121
|
+
};
|
|
122
|
+
readonly match: {
|
|
123
|
+
readonly properties: {
|
|
124
|
+
readonly name: {
|
|
125
|
+
readonly minLength: 3;
|
|
126
|
+
};
|
|
127
|
+
readonly species: {
|
|
128
|
+
readonly const: "human";
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
}];
|
|
133
|
+
readonly additionalProperties: false;
|
|
134
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { enumeratePatches } from './enumerate-patches.js';
|
|
3
|
+
export const PersonSchema = {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
name: {
|
|
7
|
+
type: "string",
|
|
8
|
+
ui: {
|
|
9
|
+
name: "Name",
|
|
10
|
+
placeholder: "John Doe",
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
age: {
|
|
14
|
+
type: "number",
|
|
15
|
+
default: 30,
|
|
16
|
+
minimum: 0,
|
|
17
|
+
maximum: 100,
|
|
18
|
+
ui: {
|
|
19
|
+
name: "Age",
|
|
20
|
+
},
|
|
21
|
+
conditionals: [
|
|
22
|
+
// when the age is less than 18 then email is not visible.
|
|
23
|
+
{
|
|
24
|
+
path: "$.properties.email.ui",
|
|
25
|
+
value: {
|
|
26
|
+
visible: false,
|
|
27
|
+
},
|
|
28
|
+
match: {
|
|
29
|
+
exclusiveMaximum: 18,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
email: {
|
|
35
|
+
type: "string",
|
|
36
|
+
ui: {
|
|
37
|
+
name: "Email",
|
|
38
|
+
placeholder: "john.doe@example.com",
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
};
|
|
44
|
+
export const PersonSchemaWithOneOf = {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
name: {
|
|
48
|
+
type: "string",
|
|
49
|
+
ui: {
|
|
50
|
+
name: "Name",
|
|
51
|
+
placeholder: "John Doe",
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
species: {
|
|
55
|
+
type: "string",
|
|
56
|
+
oneOf: [
|
|
57
|
+
{
|
|
58
|
+
const: "human",
|
|
59
|
+
conditionals: [
|
|
60
|
+
{
|
|
61
|
+
path: "$.properties.email.ui",
|
|
62
|
+
value: {
|
|
63
|
+
visible: true,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
const: "robot",
|
|
70
|
+
conditionals: [
|
|
71
|
+
{
|
|
72
|
+
path: "$.properties.email.ui",
|
|
73
|
+
value: {
|
|
74
|
+
enabled: false,
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
email: {
|
|
82
|
+
type: "string",
|
|
83
|
+
ui: {
|
|
84
|
+
name: "Email",
|
|
85
|
+
placeholder: "john.doe@example.com",
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
additionalProperties: false,
|
|
90
|
+
};
|
|
91
|
+
export const PersonSchemaRootConditions = {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
name: {
|
|
95
|
+
type: "string",
|
|
96
|
+
ui: {
|
|
97
|
+
name: "Name",
|
|
98
|
+
placeholder: "John Doe",
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
species: {
|
|
102
|
+
type: "string",
|
|
103
|
+
oneOf: [
|
|
104
|
+
{
|
|
105
|
+
const: "human",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
const: "robot",
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
email: {
|
|
113
|
+
type: "string",
|
|
114
|
+
ui: {
|
|
115
|
+
name: "Email",
|
|
116
|
+
placeholder: "john.doe@example.com",
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
conditionals: [
|
|
121
|
+
// if the name length is less than 3 then the email is not visible.
|
|
122
|
+
{
|
|
123
|
+
path: "$.properties.email.ui",
|
|
124
|
+
value: {
|
|
125
|
+
visible: false,
|
|
126
|
+
},
|
|
127
|
+
match: {
|
|
128
|
+
properties: {
|
|
129
|
+
name: {
|
|
130
|
+
maxLength: 2,
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
// if the name length is greater than 3 and the species is human then the email is visible.
|
|
136
|
+
{
|
|
137
|
+
path: "$.properties.email.ui",
|
|
138
|
+
value: {
|
|
139
|
+
visible: true,
|
|
140
|
+
},
|
|
141
|
+
match: {
|
|
142
|
+
properties: {
|
|
143
|
+
name: {
|
|
144
|
+
minLength: 3,
|
|
145
|
+
},
|
|
146
|
+
species: {
|
|
147
|
+
const: "human",
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
additionalProperties: false,
|
|
154
|
+
};
|
|
155
|
+
describe('enumeratePatches', () => {
|
|
156
|
+
it('should not enumerate patches when the local condition is not met', () => {
|
|
157
|
+
const patches = [...enumeratePatches(PersonSchema, {
|
|
158
|
+
name: "John Doe",
|
|
159
|
+
age: 20,
|
|
160
|
+
})];
|
|
161
|
+
expect(patches).toEqual([]);
|
|
162
|
+
});
|
|
163
|
+
it('should enumerate patches when the local condition is met', () => {
|
|
164
|
+
const patches = [...enumeratePatches(PersonSchema, {
|
|
165
|
+
name: "John Doe",
|
|
166
|
+
age: 10,
|
|
167
|
+
})];
|
|
168
|
+
expect(patches).toEqual([
|
|
169
|
+
{ path: ["$", "properties", "email", "ui"], fragment: { visible: false } },
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
it('should match on oneOf cases for human', () => {
|
|
173
|
+
const patches = [...enumeratePatches(PersonSchemaWithOneOf, {
|
|
174
|
+
name: "John Doe",
|
|
175
|
+
species: "human",
|
|
176
|
+
})];
|
|
177
|
+
expect(patches).toEqual([
|
|
178
|
+
{ path: ["$", "properties", "email", "ui"], fragment: { visible: true } },
|
|
179
|
+
]);
|
|
180
|
+
});
|
|
181
|
+
it('should match on oneOf cases for robot', () => {
|
|
182
|
+
const patches = [...enumeratePatches(PersonSchemaWithOneOf, {
|
|
183
|
+
name: "John Doe",
|
|
184
|
+
species: "robot",
|
|
185
|
+
})];
|
|
186
|
+
expect(patches).toEqual([
|
|
187
|
+
{ path: ["$", "properties", "email", "ui"], fragment: { enabled: false } },
|
|
188
|
+
]);
|
|
189
|
+
});
|
|
190
|
+
it('should match on complex root conditions', () => {
|
|
191
|
+
const patches = [...enumeratePatches(PersonSchemaRootConditions, {
|
|
192
|
+
name: "John Doe",
|
|
193
|
+
species: "human",
|
|
194
|
+
})];
|
|
195
|
+
expect(patches).toEqual([
|
|
196
|
+
{ path: ["$", "properties", "email", "ui"], fragment: { visible: true } },
|
|
197
|
+
]);
|
|
198
|
+
});
|
|
199
|
+
it('should match on simple root conditions', () => {
|
|
200
|
+
const patches = [...enumeratePatches(PersonSchemaRootConditions, {
|
|
201
|
+
name: "ab",
|
|
202
|
+
species: "human",
|
|
203
|
+
})];
|
|
204
|
+
expect(patches).toEqual([
|
|
205
|
+
{ path: ["$", "properties", "email", "ui"], fragment: { visible: false } },
|
|
206
|
+
]);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
//# sourceMappingURL=enumerate-patches.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumerate-patches.test.js","sourceRoot":"","sources":["../../../../src/core/schema/dynamic/enumerate-patches.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,IAAI,EAAE;YACF,IAAI,EAAE,QAAQ;YACd,EAAE,EAAE;gBACA,IAAI,EAAE,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EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;SAC7E,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,MAAM,OAAO,GAAG,CAAC,GAAG,gBAAgB,CAAC,0BAA0B,EAAE;gBAC7D,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,OAAO;aACnB,CAAC,CAAC,CAAC;QACJ,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YACpB,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;SAC5E,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAC9C,MAAM,OAAO,GAAG,CAAC,GAAG,gBAAgB,CAAC,0BAA0B,EAAE;gBAC7D,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,OAAO;aACnB,CAAC,CAAC,CAAC;QACJ,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YACpB,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;SAC7E,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { normalize } from "../../data.js";
|
|
2
|
+
import { deepMerge } from "../../functions/deep-merge.js";
|
|
3
|
+
import { enumeratePatches } from "./enumerate-patches.js";
|
|
4
|
+
import jp from "jsonpath";
|
|
5
|
+
/**
|
|
6
|
+
* Gets a dynamic schema from a static schema with conditionals and a current value.
|
|
7
|
+
*/
|
|
8
|
+
export function getDynamicSchema(schema, value) {
|
|
9
|
+
let input = schema;
|
|
10
|
+
for (let i = 0; i < 20; i++) {
|
|
11
|
+
const output = structuredClone(input);
|
|
12
|
+
for (const { path, fragment } of enumeratePatches(input, value)) {
|
|
13
|
+
const node = jp.value(output, jp.stringify(path));
|
|
14
|
+
if (typeof node !== "object" || node === null) {
|
|
15
|
+
throw new Error(`Target node MUST be an object, found: ${JSON.stringify(node)} at ${jp.stringify(path)}`);
|
|
16
|
+
}
|
|
17
|
+
Object.assign(node, deepMerge(node, fragment, { mergeArrays: false }));
|
|
18
|
+
}
|
|
19
|
+
if (JSON.stringify(normalize(input)) === JSON.stringify(normalize(output))) {
|
|
20
|
+
return output;
|
|
21
|
+
}
|
|
22
|
+
input = output;
|
|
23
|
+
}
|
|
24
|
+
throw new Error("Failed resolve stable dynamic schema");
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=get-dynamic-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-dynamic-schema.js","sourceRoot":"","sources":["../../../../src/core/schema/dynamic/get-dynamic-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,KAAc;IAC3D,IAAI,KAAK,GAAG,MAAM,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACtC,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;YAC9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