@mapomodule/utils 1.0.0 → 2.0.0-beta.2
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/README.md +33 -0
- package/dist/debounce.js +19 -0
- package/dist/debounce.js.map +1 -0
- package/dist/deepMerge.js +31 -0
- package/dist/deepMerge.js.map +1 -0
- package/dist/formatDate.js +23 -0
- package/dist/formatDate.js.map +1 -0
- package/dist/formatters.js +43 -0
- package/dist/formatters.js.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonSchema/conditionals.js +326 -0
- package/dist/jsonSchema/conditionals.js.map +1 -0
- package/dist/jsonSchema/index.js +3 -0
- package/dist/jsonSchema/index.js.map +1 -0
- package/dist/jsonSchema/resolve.js +133 -0
- package/dist/jsonSchema/resolve.js.map +1 -0
- package/dist/jsonSchema/types.js +2 -0
- package/dist/jsonSchema/types.js.map +1 -0
- package/dist/menuHelpers.js +56 -0
- package/dist/menuHelpers.js.map +1 -0
- package/dist/nestedValue.js +53 -0
- package/dist/nestedValue.js.map +1 -0
- package/dist/normalizeEndpoint.js +39 -0
- package/dist/normalizeEndpoint.js.map +1 -0
- package/dist/objectDiff.js +58 -0
- package/dist/objectDiff.js.map +1 -0
- package/dist/objectHelpers.js +93 -0
- package/dist/objectHelpers.js.map +1 -0
- package/dist/slotNamespace.js +15 -0
- package/dist/slotNamespace.js.map +1 -0
- package/dist/types/debounce.d.ts +11 -0
- package/dist/types/debounce.d.ts.map +1 -0
- package/dist/types/deepMerge.d.ts +12 -0
- package/dist/types/deepMerge.d.ts.map +1 -0
- package/dist/types/formatDate.d.ts +11 -0
- package/dist/types/formatDate.d.ts.map +1 -0
- package/dist/types/formatters.d.ts +15 -0
- package/dist/types/formatters.d.ts.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/jsonSchema/conditionals.d.ts +40 -0
- package/dist/types/jsonSchema/conditionals.d.ts.map +1 -0
- package/dist/types/jsonSchema/index.d.ts +15 -0
- package/dist/types/jsonSchema/index.d.ts.map +1 -0
- package/dist/types/jsonSchema/resolve.d.ts +41 -0
- package/dist/types/jsonSchema/resolve.d.ts.map +1 -0
- package/dist/types/jsonSchema/types.d.ts +43 -0
- package/dist/types/jsonSchema/types.d.ts.map +1 -0
- package/dist/types/menuHelpers.d.ts +22 -0
- package/dist/types/menuHelpers.d.ts.map +1 -0
- package/dist/types/nestedValue.d.ts +25 -0
- package/dist/types/nestedValue.d.ts.map +1 -0
- package/dist/types/normalizeEndpoint.d.ts +28 -0
- package/dist/types/normalizeEndpoint.d.ts.map +1 -0
- package/dist/types/objectDiff.d.ts +12 -0
- package/dist/types/objectDiff.d.ts.map +1 -0
- package/dist/types/objectHelpers.d.ts +33 -0
- package/dist/types/objectHelpers.d.ts.map +1 -0
- package/dist/types/slotNamespace.d.ts +12 -0
- package/dist/types/slotNamespace.d.ts.map +1 -0
- package/package.json +41 -7
- package/CHANGELOG.md +0 -182
- package/helpers/cssVariables.js +0 -12
- package/helpers/datetime.js +0 -68
- package/helpers/debounce.js +0 -42
- package/helpers/formatters.js +0 -52
- package/helpers/menu.js +0 -15
- package/helpers/objHelpers.js +0 -118
- package/helpers/slots.js +0 -9
- package/index.js +0 -13
- package/loaders/dummy-loader.js +0 -1
- package/plugins/v-draggable-modals.js +0 -39
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @mapomodule/utils
|
|
2
|
+
|
|
3
|
+
Typed utility helpers shared across all `@mapomodule/*` packages.
|
|
4
|
+
|
|
5
|
+
## Utilities
|
|
6
|
+
|
|
7
|
+
| Export | Description |
|
|
8
|
+
| ------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `deepMerge` | Recursively merges two plain objects |
|
|
10
|
+
| `getNestedValue` | Reads a value from a dotted path (e.g. `"user.address.city"`) |
|
|
11
|
+
| `setNestedValue` | Returns a new object with a value set at a dotted path |
|
|
12
|
+
| `objectDiff` | Returns only the keys that differ between two objects — used for differential PATCH requests |
|
|
13
|
+
| `formatDate` | Formats a `Date` or ISO string with a token-based format string (`YYYY`, `MM`, `DD`, `HH`, `mm`, `ss`) |
|
|
14
|
+
| `debounce` | Returns a debounced version of a function |
|
|
15
|
+
| `slotNamespace` | Filters and strips a prefix from a Vue `Slots` object — used to forward a slot subset to a child component |
|
|
16
|
+
| `buildRouteTree` | Converts a flat `RouteRecordNormalized[]` into a nested `MenuNode[]` tree for sidebar rendering |
|
|
17
|
+
| `normalizeEndpoint` | Ensures an API endpoint string has exactly one leading and one trailing slash — used by `useCrud` |
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @mapomodule/utils
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Dev workflow
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm dev:utils # from monorepo root — tsc --watch
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
> The helpers in this package are ported from the Mapo v1 legacy codebase. As v2 development progresses, individual helpers may be added, removed, or replaced — and the package itself may be dissolved if its contents are better placed elsewhere.
|
package/dist/debounce.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced wrapper that delays invocation until calls stop for `ms` milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* Each new call clears the pending timer, so only the last call in a burst is executed.
|
|
5
|
+
*
|
|
6
|
+
* @param fn Function to debounce.
|
|
7
|
+
* @param ms Debounce delay in milliseconds.
|
|
8
|
+
* @returns A debounced function with the same argument signature as `fn`.
|
|
9
|
+
*/
|
|
10
|
+
export function debounce(fn, ms) {
|
|
11
|
+
let timer;
|
|
12
|
+
return function (...args) {
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
timer = setTimeout(() => {
|
|
15
|
+
fn.apply(this, args);
|
|
16
|
+
}, ms);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../src/debounce.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CACtB,EAA2B,EAC3B,EAAU;IAEV,IAAI,KAAgD,CAAC;IACrD,OAAO,UAAyB,GAAG,IAAO;QACxC,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true when `val` is a non-null plain object (excluding arrays).
|
|
3
|
+
*/
|
|
4
|
+
function isPlainObject(val) {
|
|
5
|
+
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Deeply merges `override` into `base` and returns a new object.
|
|
9
|
+
*
|
|
10
|
+
* Nested plain objects are merged recursively, while other values replace
|
|
11
|
+
* the corresponding base value when the override value is not `undefined`.
|
|
12
|
+
*
|
|
13
|
+
* @param base Base object.
|
|
14
|
+
* @param override Partial object with values that should override `base`.
|
|
15
|
+
* @returns A new object containing the merged result.
|
|
16
|
+
*/
|
|
17
|
+
export function deepMerge(base, override) {
|
|
18
|
+
const result = { ...base };
|
|
19
|
+
for (const key of Object.keys(override)) {
|
|
20
|
+
const baseVal = result[key];
|
|
21
|
+
const overrideVal = override[key];
|
|
22
|
+
if (isPlainObject(baseVal) && isPlainObject(overrideVal)) {
|
|
23
|
+
result[key] = deepMerge(baseVal, overrideVal);
|
|
24
|
+
}
|
|
25
|
+
else if (overrideVal !== undefined) {
|
|
26
|
+
result[key] = overrideVal;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=deepMerge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepMerge.js","sourceRoot":"","sources":["../src/deepMerge.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,SAAS,aAAa,CAAC,GAAY;IACjC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CACvB,IAAO,EACP,QAAoB;IAEpB,MAAM,MAAM,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAmB,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;YACzD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CACrB,OAAkC,EAClC,WAAsC,CACzB,CAAC;QAClB,CAAC;aAAM,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,CAAC,GAAG,CAAC,GAAG,WAAyB,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
2
|
+
/**
|
|
3
|
+
* Formats a date using a token-based pattern.
|
|
4
|
+
*
|
|
5
|
+
* Supported tokens: `YYYY`, `MM`, `DD`, `HH`, `mm`, `ss`.
|
|
6
|
+
*
|
|
7
|
+
* @param date Date value as a `Date` instance or parseable date string.
|
|
8
|
+
* @param format Output format pattern. Defaults to `"YYYY-MM-DD"`.
|
|
9
|
+
* @returns Formatted date string, or an empty string if the input date is invalid.
|
|
10
|
+
*/
|
|
11
|
+
export function formatDate(date, format = "YYYY-MM-DD") {
|
|
12
|
+
const d = typeof date === "string" ? new Date(date) : date;
|
|
13
|
+
if (isNaN(d.getTime()))
|
|
14
|
+
return "";
|
|
15
|
+
return format
|
|
16
|
+
.replace("YYYY", String(d.getFullYear()))
|
|
17
|
+
.replace("MM", pad(d.getMonth() + 1))
|
|
18
|
+
.replace("DD", pad(d.getDate()))
|
|
19
|
+
.replace("HH", pad(d.getHours()))
|
|
20
|
+
.replace("mm", pad(d.getMinutes()))
|
|
21
|
+
.replace("ss", pad(d.getSeconds()));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=formatDate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDate.js","sourceRoot":"","sources":["../src/formatDate.ts"],"names":[],"mappings":"AAAA,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,IAAmB,EAAE,MAAM,GAAG,YAAY;IACnE,MAAM,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAAE,OAAO,EAAE,CAAC;IAElC,OAAO,MAAM;SACV,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;SACxC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;SACpC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;SAC/B,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;SAChC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;SAClC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a byte count as a human-readable string (ported from Mapo v1).
|
|
3
|
+
*
|
|
4
|
+
* @param bytes Number of bytes.
|
|
5
|
+
* @param si Use metric (powers of 1000, "kB/MB") instead of binary (powers of 1024, "KiB/MiB"). Default `false`.
|
|
6
|
+
* @param dp Decimal places. Default `1`.
|
|
7
|
+
*/
|
|
8
|
+
export function humanFileSize(bytes, si = false, dp = 1) {
|
|
9
|
+
const thresh = si ? 1000 : 1024;
|
|
10
|
+
if (Math.abs(bytes) < thresh) {
|
|
11
|
+
return `${bytes} B`;
|
|
12
|
+
}
|
|
13
|
+
const units = si
|
|
14
|
+
? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
|
15
|
+
: ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
16
|
+
let u = -1;
|
|
17
|
+
const r = 10 ** dp;
|
|
18
|
+
let value = bytes;
|
|
19
|
+
do {
|
|
20
|
+
value /= thresh;
|
|
21
|
+
++u;
|
|
22
|
+
} while (Math.round(Math.abs(value) * r) / r >= thresh &&
|
|
23
|
+
u < units.length - 1);
|
|
24
|
+
return `${value.toFixed(dp)} ${units[u]}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert a string into a URL-safe slug: lowercase, accents stripped,
|
|
28
|
+
* non-alphanumerics collapsed into single dashes (ported from Mapo v1).
|
|
29
|
+
* Camomilla folder payloads require a `slug` derived from the title.
|
|
30
|
+
*/
|
|
31
|
+
export function slugify(str) {
|
|
32
|
+
let s = (str ?? "").trim().toLowerCase();
|
|
33
|
+
const from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
|
|
34
|
+
const to = "aaaaeeeeiiiioooouuuunc------";
|
|
35
|
+
for (let i = 0; i < from.length; i++) {
|
|
36
|
+
s = s.replaceAll(from.charAt(i), to.charAt(i));
|
|
37
|
+
}
|
|
38
|
+
return s
|
|
39
|
+
.replace(/[^a-z0-9 -]/g, "")
|
|
40
|
+
.replace(/\s+/g, "-")
|
|
41
|
+
.replace(/-+/g, "-");
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,CAAC;IAC7D,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEhC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC;QAC7B,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;IAED,MAAM,KAAK,GAAG,EAAE;QACd,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QAClD,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7D,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACX,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IAEnB,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,GAAG,CAAC;QACF,KAAK,IAAI,MAAM,CAAC;QAChB,EAAE,CAAC,CAAC;IACN,CAAC,QACC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,MAAM;QAC7C,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EACpB;IAEF,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAA8B;IACpD,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEzC,MAAM,IAAI,GAAG,8BAA8B,CAAC;IAC5C,MAAM,EAAE,GAAG,8BAA8B,CAAC;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,CAAC;SACL,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { deepMerge } from "./deepMerge.js";
|
|
2
|
+
export { deepClone, isFile, isBlob, isFileOrBlob, findPropPaths, filesInObject, filterObj, } from "./objectHelpers.js";
|
|
3
|
+
export { getNestedValue, setNestedValue, setNestedValueMutating, } from "./nestedValue.js";
|
|
4
|
+
export { objectDiff } from "./objectDiff.js";
|
|
5
|
+
export { formatDate } from "./formatDate.js";
|
|
6
|
+
export { humanFileSize, slugify } from "./formatters.js";
|
|
7
|
+
export { debounce } from "./debounce.js";
|
|
8
|
+
export { slotNamespace } from "./slotNamespace.js";
|
|
9
|
+
export { buildRouteTree, calcMaxMenuNestDepth } from "./menuHelpers.js";
|
|
10
|
+
export { normalizeEndpoint, splitEndpointParams } from "./normalizeEndpoint.js";
|
|
11
|
+
export { matchesSchema, applyConditionals, hasConditionals, resolveSchema, extractDefs, getDefaultForSchema, } from "./jsonSchema/index.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,YAAY,EACZ,aAAa,EACb,aAAa,EACb,SAAS,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,GACpB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
// Cherry-picked from structured-widget-editor (MIT License, Copyright (c) 2026 bnznamco)
|
|
2
|
+
// Source: https://github.com/bnznamco/structured-widget-editor/blob/main/src/conditionals.js
|
|
3
|
+
// Modifications: converted to TypeScript, added type annotations.
|
|
4
|
+
/**
|
|
5
|
+
* Maximum number of resolution passes for cascading conditionals: a merged branch
|
|
6
|
+
* may introduce new `if` rules, so we iterate until the schema stabilises or this
|
|
7
|
+
* cap is hit (whichever comes first).
|
|
8
|
+
*/
|
|
9
|
+
const MAX_CONDITIONAL_PASSES = 8;
|
|
10
|
+
/**
|
|
11
|
+
* Returns `true` if `value` is a non-null object that contains `key` with a
|
|
12
|
+
* non-empty, non-null, non-undefined value.
|
|
13
|
+
*/
|
|
14
|
+
function isPresent(value, key) {
|
|
15
|
+
if (value == null || typeof value !== "object")
|
|
16
|
+
return false;
|
|
17
|
+
if (!(key in value))
|
|
18
|
+
return false;
|
|
19
|
+
const v = value[key];
|
|
20
|
+
return v !== undefined && v !== null && v !== "";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether a single property value satisfies the constraints defined by
|
|
24
|
+
* a JSON Schema node (type, const, enum, numeric/string bounds, not, etc.).
|
|
25
|
+
*/
|
|
26
|
+
function matchesPropertyConstraint(value, constraint) {
|
|
27
|
+
if (!constraint || typeof constraint !== "object")
|
|
28
|
+
return true;
|
|
29
|
+
if ("const" in constraint)
|
|
30
|
+
return value === constraint.const;
|
|
31
|
+
if (Array.isArray(constraint.enum))
|
|
32
|
+
return constraint.enum.includes(value);
|
|
33
|
+
if (constraint.type) {
|
|
34
|
+
const t = constraint.type;
|
|
35
|
+
if (t === "string" && typeof value !== "string")
|
|
36
|
+
return false;
|
|
37
|
+
if (t === "number" && typeof value !== "number")
|
|
38
|
+
return false;
|
|
39
|
+
if (t === "integer" &&
|
|
40
|
+
(typeof value !== "number" || !Number.isInteger(value)))
|
|
41
|
+
return false;
|
|
42
|
+
if (t === "boolean" && typeof value !== "boolean")
|
|
43
|
+
return false;
|
|
44
|
+
if (t === "null" && value !== null)
|
|
45
|
+
return false;
|
|
46
|
+
if (t === "array" && !Array.isArray(value))
|
|
47
|
+
return false;
|
|
48
|
+
if (t === "object" &&
|
|
49
|
+
(value == null || typeof value !== "object" || Array.isArray(value)))
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
if (typeof value === "number") {
|
|
53
|
+
if (typeof constraint.minimum === "number" && value < constraint.minimum)
|
|
54
|
+
return false;
|
|
55
|
+
if (typeof constraint.maximum === "number" && value > constraint.maximum)
|
|
56
|
+
return false;
|
|
57
|
+
if (typeof constraint.exclusiveMinimum === "number" &&
|
|
58
|
+
value <= constraint.exclusiveMinimum)
|
|
59
|
+
return false;
|
|
60
|
+
if (typeof constraint.exclusiveMaximum === "number" &&
|
|
61
|
+
value >= constraint.exclusiveMaximum)
|
|
62
|
+
return false;
|
|
63
|
+
if (typeof constraint.multipleOf === "number" &&
|
|
64
|
+
constraint.multipleOf > 0) {
|
|
65
|
+
const q = value / constraint.multipleOf;
|
|
66
|
+
if (Math.abs(q - Math.round(q)) > 1e-9)
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (typeof value === "string") {
|
|
71
|
+
if (typeof constraint.minLength === "number" &&
|
|
72
|
+
value.length < constraint.minLength)
|
|
73
|
+
return false;
|
|
74
|
+
if (typeof constraint.maxLength === "number" &&
|
|
75
|
+
value.length > constraint.maxLength)
|
|
76
|
+
return false;
|
|
77
|
+
if (typeof constraint.pattern === "string") {
|
|
78
|
+
try {
|
|
79
|
+
if (!new RegExp(constraint.pattern).test(value))
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (constraint.not)
|
|
88
|
+
return !matchesSchema(value, constraint.not);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Evaluates whether `value` satisfies all constraints in `schema`.
|
|
93
|
+
* Handles `required`, `properties`, `not`, `allOf`, `anyOf`, `oneOf`,
|
|
94
|
+
* `dependentRequired`, and nested `if/then/else` rules.
|
|
95
|
+
*
|
|
96
|
+
* @param value - The data value to validate.
|
|
97
|
+
* @param schema - The JSON Schema node to validate against.
|
|
98
|
+
* @returns `true` if the value conforms to the schema.
|
|
99
|
+
*/
|
|
100
|
+
export function matchesSchema(value, schema) {
|
|
101
|
+
if (!schema || typeof schema !== "object")
|
|
102
|
+
return true;
|
|
103
|
+
if (Array.isArray(schema.required)) {
|
|
104
|
+
for (const k of schema.required) {
|
|
105
|
+
if (!isPresent(value, k))
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (schema.properties && typeof schema.properties === "object") {
|
|
110
|
+
for (const [k, constraint] of Object.entries(schema.properties)) {
|
|
111
|
+
if (value == null || !(k in value))
|
|
112
|
+
continue;
|
|
113
|
+
if (!matchesPropertyConstraint(value[k], constraint))
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (schema.not && matchesSchema(value, schema.not))
|
|
118
|
+
return false;
|
|
119
|
+
if (Array.isArray(schema.allOf) &&
|
|
120
|
+
!schema.allOf.every((s) => matchesSchema(value, s)))
|
|
121
|
+
return false;
|
|
122
|
+
if (Array.isArray(schema.anyOf) &&
|
|
123
|
+
!schema.anyOf.some((s) => matchesSchema(value, s)))
|
|
124
|
+
return false;
|
|
125
|
+
if (Array.isArray(schema.oneOf)) {
|
|
126
|
+
const matched = schema.oneOf.filter((s) => matchesSchema(value, s)).length;
|
|
127
|
+
if (matched !== 1)
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Inserts `newEntries` into the `properties` map immediately after `anchorKey`.
|
|
134
|
+
* If `anchorKey` is `null` or not found, entries are appended at the end.
|
|
135
|
+
* Existing keys that appear in `newEntries` are moved to the anchor position
|
|
136
|
+
* rather than duplicated.
|
|
137
|
+
*/
|
|
138
|
+
function insertAfter(properties, anchorKey, newEntries) {
|
|
139
|
+
const existingKeys = Object.keys(properties);
|
|
140
|
+
const anchorIdx = anchorKey ? existingKeys.indexOf(anchorKey) : -1;
|
|
141
|
+
if (anchorIdx === -1) {
|
|
142
|
+
const out = { ...properties };
|
|
143
|
+
for (const [k, v] of newEntries)
|
|
144
|
+
out[k] = v;
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
const out = {};
|
|
148
|
+
for (let i = 0; i < existingKeys.length; i++) {
|
|
149
|
+
const key = existingKeys[i];
|
|
150
|
+
out[key] = properties[key];
|
|
151
|
+
if (i === anchorIdx) {
|
|
152
|
+
for (const [k, v] of newEntries) {
|
|
153
|
+
if (!(k in properties))
|
|
154
|
+
out[k] = v;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const [k, v] of newEntries) {
|
|
159
|
+
if (k in properties)
|
|
160
|
+
out[k] = v;
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Merges a conditional branch schema into `target` in-place.
|
|
166
|
+
* Properties are inserted after `anchorKey` to preserve visual ordering.
|
|
167
|
+
* `required`, `allOf`, `dependentSchemas`, and `dependentRequired` are merged
|
|
168
|
+
* additively rather than replaced.
|
|
169
|
+
*/
|
|
170
|
+
function mergeBranch(target, branch, anchorKey) {
|
|
171
|
+
if (!branch || typeof branch !== "object")
|
|
172
|
+
return target;
|
|
173
|
+
if (branch.properties) {
|
|
174
|
+
const merged = [];
|
|
175
|
+
for (const [k, v] of Object.entries(branch.properties)) {
|
|
176
|
+
const existing = target.properties?.[k];
|
|
177
|
+
merged.push([k, existing ? { ...existing, ...v } : v]);
|
|
178
|
+
}
|
|
179
|
+
target.properties = insertAfter(target.properties || {}, anchorKey, merged);
|
|
180
|
+
}
|
|
181
|
+
if (Array.isArray(branch.required)) {
|
|
182
|
+
const set = new Set(target.required || []);
|
|
183
|
+
for (const k of branch.required)
|
|
184
|
+
set.add(k);
|
|
185
|
+
target.required = Array.from(set);
|
|
186
|
+
}
|
|
187
|
+
if (branch.allOf)
|
|
188
|
+
target.allOf = [...(target.allOf || []), ...branch.allOf];
|
|
189
|
+
if (branch.if)
|
|
190
|
+
target.allOf = [
|
|
191
|
+
...(target.allOf || []),
|
|
192
|
+
{ if: branch.if, then: branch.then, else: branch.else },
|
|
193
|
+
];
|
|
194
|
+
if (branch.dependentSchemas)
|
|
195
|
+
target.dependentSchemas = {
|
|
196
|
+
...(target.dependentSchemas || {}),
|
|
197
|
+
...branch.dependentSchemas,
|
|
198
|
+
};
|
|
199
|
+
if (branch.dependentRequired)
|
|
200
|
+
target.dependentRequired = {
|
|
201
|
+
...(target.dependentRequired || {}),
|
|
202
|
+
...branch.dependentRequired,
|
|
203
|
+
};
|
|
204
|
+
return target;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Evaluates all conditional keywords in `schema` against `value` and returns
|
|
208
|
+
* an effective schema with the appropriate branches merged in.
|
|
209
|
+
*
|
|
210
|
+
* Supported conditional keywords:
|
|
211
|
+
* - `if / then / else` (top-level and inside `allOf`)
|
|
212
|
+
* - `dependentSchemas` / `dependentRequired`
|
|
213
|
+
*
|
|
214
|
+
* Iteration is repeated up to {@link MAX_CONDITIONAL_PASSES} times to handle cascading
|
|
215
|
+
* conditionals where a merged branch introduces new `if` rules. Stops early when the
|
|
216
|
+
* schema stabilises between iterations.
|
|
217
|
+
*
|
|
218
|
+
* @param schema - The base schema to evaluate.
|
|
219
|
+
* @param value - The current form data used to resolve conditionals.
|
|
220
|
+
* @param resolver - Optional function to resolve `$ref` pointers inside branches.
|
|
221
|
+
* @returns A new schema with all applicable branches merged.
|
|
222
|
+
*/
|
|
223
|
+
export function applyConditionals(schema, value, resolver) {
|
|
224
|
+
const resolve = typeof resolver === "function" ? resolver : (s) => s;
|
|
225
|
+
if (!schema || typeof schema !== "object")
|
|
226
|
+
return schema;
|
|
227
|
+
if (schema.type !== "object" && !schema.properties)
|
|
228
|
+
return schema;
|
|
229
|
+
const effective = {
|
|
230
|
+
...schema,
|
|
231
|
+
properties: { ...(schema.properties || {}) },
|
|
232
|
+
required: Array.isArray(schema.required) ? [...schema.required] : [],
|
|
233
|
+
};
|
|
234
|
+
const safeValue = value && typeof value === "object" ? value : {};
|
|
235
|
+
const anchorOf = (ifClause) => {
|
|
236
|
+
if (!ifClause || typeof ifClause !== "object")
|
|
237
|
+
return null;
|
|
238
|
+
const props = ifClause.properties && Object.keys(ifClause.properties);
|
|
239
|
+
if (props && props.length)
|
|
240
|
+
return props[0];
|
|
241
|
+
if (Array.isArray(ifClause.required) && ifClause.required.length)
|
|
242
|
+
return ifClause.required[0];
|
|
243
|
+
return null;
|
|
244
|
+
};
|
|
245
|
+
const rules = [];
|
|
246
|
+
if (effective.if) {
|
|
247
|
+
rules.push({
|
|
248
|
+
if: effective.if,
|
|
249
|
+
then: effective.then,
|
|
250
|
+
else: effective.else,
|
|
251
|
+
anchor: anchorOf(effective.if),
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (Array.isArray(effective.allOf)) {
|
|
255
|
+
for (const entry of effective.allOf) {
|
|
256
|
+
if (entry && typeof entry === "object" && entry.if) {
|
|
257
|
+
rules.push({
|
|
258
|
+
if: entry.if,
|
|
259
|
+
then: entry.then,
|
|
260
|
+
else: entry.else,
|
|
261
|
+
anchor: anchorOf(entry.if),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else if (entry &&
|
|
265
|
+
typeof entry === "object" &&
|
|
266
|
+
(entry.properties || entry.required)) {
|
|
267
|
+
mergeBranch(effective, entry, null);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
for (let i = 0; i < MAX_CONDITIONAL_PASSES; i++) {
|
|
272
|
+
const before = JSON.stringify({
|
|
273
|
+
p: effective.properties,
|
|
274
|
+
r: effective.required,
|
|
275
|
+
});
|
|
276
|
+
for (const rule of rules) {
|
|
277
|
+
const matched = matchesSchema(safeValue, rule.if);
|
|
278
|
+
const branch = matched ? rule.then : rule.else;
|
|
279
|
+
if (branch)
|
|
280
|
+
mergeBranch(effective, resolve(branch), rule.anchor);
|
|
281
|
+
}
|
|
282
|
+
if (effective.dependentSchemas) {
|
|
283
|
+
for (const [key, branch] of Object.entries(effective.dependentSchemas)) {
|
|
284
|
+
if (isPresent(safeValue, key))
|
|
285
|
+
mergeBranch(effective, resolve(branch), key);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (effective.dependentRequired) {
|
|
289
|
+
for (const [key, requiredKeys] of Object.entries(effective.dependentRequired)) {
|
|
290
|
+
if (isPresent(safeValue, key) && Array.isArray(requiredKeys)) {
|
|
291
|
+
const set = new Set(effective.required || []);
|
|
292
|
+
for (const k of requiredKeys)
|
|
293
|
+
set.add(k);
|
|
294
|
+
effective.required = Array.from(set);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const after = JSON.stringify({
|
|
299
|
+
p: effective.properties,
|
|
300
|
+
r: effective.required,
|
|
301
|
+
});
|
|
302
|
+
if (after === before)
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
return effective;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Returns `true` if the schema contains any conditional keywords that could
|
|
309
|
+
* affect the visible set of properties at runtime.
|
|
310
|
+
*
|
|
311
|
+
* Checked keywords: `if`, `dependentSchemas`, `dependentRequired`, and
|
|
312
|
+
* any `if` entries nested inside `allOf`.
|
|
313
|
+
*
|
|
314
|
+
* @param schema - The schema to inspect.
|
|
315
|
+
*/
|
|
316
|
+
export function hasConditionals(schema) {
|
|
317
|
+
if (!schema || typeof schema !== "object")
|
|
318
|
+
return false;
|
|
319
|
+
if (schema.if || schema.dependentSchemas || schema.dependentRequired)
|
|
320
|
+
return true;
|
|
321
|
+
if (Array.isArray(schema.allOf)) {
|
|
322
|
+
return schema.allOf.some((e) => e && typeof e === "object" && (e.if || e.dependentSchemas));
|
|
323
|
+
}
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=conditionals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionals.js","sourceRoot":"","sources":["../../src/jsonSchema/conditionals.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,6FAA6F;AAC7F,kEAAkE;AAIlE;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC;;;GAGG;AACH,SAAS,SAAS,CAAC,KAAc,EAAE,GAAW;IAC5C,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC7D,IAAI,CAAC,CAAC,GAAG,IAAK,KAAiC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/D,MAAM,CAAC,GAAI,KAAiC,CAAC,GAAG,CAAC,CAAC;IAClD,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,SAAS,yBAAyB,CAChC,KAAc,EACd,UAAsB;IAEtB,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC/D,IAAI,OAAO,IAAI,UAAU;QAAE,OAAO,KAAK,KAAK,UAAU,CAAC,KAAK,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3E,IAAI,UAAU,CAAC,IAAI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