@yahoo/uds-create-config 5.89.5 → 5.89.6
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/entities/system/Component.js +1 -1
- package/dist/entities/system/Source.js +1 -1
- package/dist/entities/system/component-source-fields.js +1 -1
- package/dist/entities/system/link-declaration.js +1 -1
- package/dist/entities/system/motion-variants.js +1 -1
- package/dist/framework/Config.js +1 -1
- package/dist/framework/retired-fields.js +1 -1
- package/dist/framework/schemas.js +4 -4
- package/dist/framework/utils/field-path.d.ts +13 -2
- package/dist/framework/utils/field-path.js +72 -4
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { canonicalCondition, collectRefs, isRef, kindOf, memberRef, pathOf, ref, refLeaf, refSchema, sourceOf, splitRef } from "../../framework/utils/refs.js";
|
|
2
2
|
import "../../configs/platform.js";
|
|
3
|
+
import { reject, rejectData } from "../../framework/rejection.js";
|
|
3
4
|
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
4
5
|
import { storedDefaultConditions } from "../../framework/default-conditions.js";
|
|
5
|
-
import { reject, rejectData } from "../../framework/rejection.js";
|
|
6
6
|
import { pathInput } from "../../framework/schemas.js";
|
|
7
7
|
import { derivedColor, gradient, oklchColor } from "./color.js";
|
|
8
8
|
import { shadowValue } from "./shadow.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isRef, kindOf, pathOf, refSchema } from "../../framework/utils/refs.js";
|
|
2
|
-
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
3
2
|
import { rejectData } from "../../framework/rejection.js";
|
|
3
|
+
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
4
4
|
import { pathInput } from "../../framework/schemas.js";
|
|
5
5
|
import { kindBorrowable } from "../../framework/registry.js";
|
|
6
6
|
import { defineEntity } from "../../framework/defineEntity.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
2
1
|
import { rejectData } from "../../framework/rejection.js";
|
|
2
|
+
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
3
3
|
//#region src/entities/system/component-source-fields.ts
|
|
4
4
|
/** Source constructors leave these facts to the render extractor and module build.
|
|
5
5
|
* Stored component bodies, including Create drafts, still carry them. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
2
1
|
import { rejectData } from "../../framework/rejection.js";
|
|
2
|
+
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
3
3
|
//#region src/entities/system/link-declaration.ts
|
|
4
4
|
const PIN_KIND = "source";
|
|
5
5
|
/** The key of `options` that holds what a source includes. Every other key is an accessor. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isRef, kindOf, pathOf } from "../../framework/utils/refs.js";
|
|
2
|
-
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
3
2
|
import { reject } from "../../framework/rejection.js";
|
|
3
|
+
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
4
4
|
import { createSliceMemo } from "../../framework/memo.js";
|
|
5
5
|
import { drawnMotionBody, drawnMotionName } from "./drawn-motion.js";
|
|
6
6
|
import { webMotionBody } from "./motion-types.js";
|
package/dist/framework/Config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MINTED, collectRefs, entityPathProblem, entityRefOf, isExtendedRef, isMintedRow, isRef, kindOf, memberOf, memberRef, pathOf, qualifyRefs, ref, rewriteRefNamespace, rewriteRefSource, rewriteRefs, routedSource, singletonRef, sourceHops, sourceOf, splitRef } from "./utils/refs.js";
|
|
2
|
+
import { ConfigFormatError, ConfigRejection, isConfigRejection, issuePath, refusalIssues, reject, rejectData, rejectInvalid, rejectReferrers } from "./rejection.js";
|
|
2
3
|
import { applyPathDelta, isPlainObject, namedFields, pathSegments, sectionDelta, touchedFields } from "./utils/field-path.js";
|
|
3
4
|
import "./config-operation-kind.js";
|
|
4
|
-
import { ConfigFormatError, ConfigRejection, isConfigRejection, issuePath, refusalIssues, reject, rejectData, rejectInvalid, rejectReferrers } from "./rejection.js";
|
|
5
5
|
import { describePatch } from "./plan.js";
|
|
6
6
|
import { METADATA_KEYS, declaredField } from "./utils/field-schema.js";
|
|
7
7
|
import { dataSchema, resolveInputSchema } from "./schemas.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isPlainObject, setAtPath } from "./utils/field-path.js";
|
|
2
1
|
import { rejectData } from "./rejection.js";
|
|
2
|
+
import { isPlainObject, setAtPath } from "./utils/field-path.js";
|
|
3
3
|
//#region src/framework/retired-fields.ts
|
|
4
4
|
/**
|
|
5
5
|
* A field a kind stores under a new path, still taken under the one it had: a source stores what it
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref } from "./utils/refs.js";
|
|
2
|
-
import { sectionDelta } from "./utils/field-path.js";
|
|
3
2
|
import { reject } from "./rejection.js";
|
|
3
|
+
import { sectionDelta } from "./utils/field-path.js";
|
|
4
4
|
import { planDelete, planRename } from "./plan.js";
|
|
5
5
|
import { compileSchema } from "./utils/compiled-schema.js";
|
|
6
6
|
import { deriveCreateSchema, deriveMemberUpdateSchema, deriveUpdateSchema } from "./utils/field-schema.js";
|
|
@@ -109,7 +109,7 @@ function defaultSchemas(kind, declaredFields, groupFields, subEntities, { single
|
|
|
109
109
|
input: bodyInput(false),
|
|
110
110
|
readOnly: false,
|
|
111
111
|
label: "Update",
|
|
112
|
-
description: `Update a ${kind} — a partial \`data\` whose KEYS ARE FIELD PATHS. \`{ "value": … }\` replaces that field; \`{ "value.brand": … }\` reaches inside and changes only that, leaving its siblings alone; \`null\` at either address removes what is there. Nothing you don't name is touched.`,
|
|
112
|
+
description: `Update a ${kind} — a partial \`data\` whose KEYS ARE FIELD PATHS. \`{ "value": … }\` replaces that field; \`{ "value.brand": … }\` reaches inside and changes only that, leaving its siblings alone; \`null\` at either address removes what is there. In a list, a number addresses one entry: \`{ "content.2": … }\` replaces entry 2, the list's length or \`-\` appends, and \`null\` removes that entry. Nothing you don't name is touched.`,
|
|
113
113
|
scope: "item",
|
|
114
114
|
handler: (i, c) => c.apply({
|
|
115
115
|
kind,
|
|
@@ -370,7 +370,7 @@ function defaultSchemas(kind, declaredFields, groupFields, subEntities, { single
|
|
|
370
370
|
input: envelope(memberUpdate, { ...address }),
|
|
371
371
|
readOnly: false,
|
|
372
372
|
label: "Update",
|
|
373
|
-
description: `Update a ${kind}'s \`${field}\` section — a partial \`data\` whose KEYS ARE FIELD PATHS. \`{ "prefix": … }\` sets that field and leaves every sibling alone; \`null\` removes what is there.`,
|
|
373
|
+
description: `Update a ${kind}'s \`${field}\` section — a partial \`data\` whose KEYS ARE FIELD PATHS. \`{ "prefix": … }\` sets that field and leaves every sibling alone; \`null\` removes what is there. In a list, a number addresses one entry: \`{ "content.2": … }\` replaces entry 2, the list's length or \`-\` appends, and \`null\` removes that entry.`,
|
|
374
374
|
scope: "item",
|
|
375
375
|
handler: (i, c) => c.apply({
|
|
376
376
|
kind,
|
|
@@ -443,7 +443,7 @@ function defaultSchemas(kind, declaredFields, groupFields, subEntities, { single
|
|
|
443
443
|
}),
|
|
444
444
|
readOnly: false,
|
|
445
445
|
label: "Update",
|
|
446
|
-
description: `Update a ${kind}'s \`${field}\` member \`key\`${inside}${derivesKey ? " (leave `key` out to address the member `data` identifies, created when absent)" : ""} — a partial \`data\` whose KEYS ARE FIELD PATHS. \`{ "layers": … }\` replaces that field; \`{ "layers.root.bg": … }\` changes only that leaf and leaves every sibling alone; \`null\` at either address removes what is there. Nothing you don't name is touched, so two edits to one member compose in a single batch. Use \`sub-upsert/${field}\` to replace the member whole.`,
|
|
446
|
+
description: `Update a ${kind}'s \`${field}\` member \`key\`${inside}${derivesKey ? " (leave `key` out to address the member `data` identifies, created when absent)" : ""} — a partial \`data\` whose KEYS ARE FIELD PATHS. \`{ "layers": … }\` replaces that field; \`{ "layers.root.bg": … }\` changes only that leaf and leaves every sibling alone; \`null\` at either address removes what is there. In a list, a number addresses one entry: \`{ "content.2": … }\` replaces entry 2, the list's length or \`-\` appends, and \`null\` removes that entry. Nothing you don't name is touched, so two edits to one member compose in a single batch. Use \`sub-upsert/${field}\` to replace the member whole.`,
|
|
447
447
|
scope: "item",
|
|
448
448
|
handler: (i, c) => c.apply({
|
|
449
449
|
kind,
|
|
@@ -24,6 +24,17 @@
|
|
|
24
24
|
* The one thing an address cannot spell is a member key that itself contains a dot (`spacing.2`,
|
|
25
25
|
* which nothing names today — paths separate with `/`). Such a key is reachable by `sub-upsert`,
|
|
26
26
|
* which addresses it whole.
|
|
27
|
+
*
|
|
28
|
+
* A segment that meets an array addresses one of its entries, by index or as `-`:
|
|
29
|
+
*
|
|
30
|
+
* { 'content.1': 'src/**' } → replaces entry 1
|
|
31
|
+
* { 'content.2': 'src/**' } → appends, when the list has two entries
|
|
32
|
+
* { 'content.-': 'src/**' } → appends, whatever the length
|
|
33
|
+
* { 'content.1': null } → removes entry 1, and the later ones move up
|
|
34
|
+
*
|
|
35
|
+
* Whether a segment is an index is decided by the container being an array, so a record keyed `2`
|
|
36
|
+
* is still a record. An index past the end, or a segment that isn't one, is refused. `-` into a field
|
|
37
|
+
* that isn't set starts the list.
|
|
27
38
|
*/
|
|
28
39
|
/** A JSON object — not an array, not a class instance. */
|
|
29
40
|
declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
@@ -49,9 +60,9 @@ declare function pathSegments(key: string, isField: (name: string) => boolean):
|
|
|
49
60
|
* those are the target's own declared fields, and a rule whose `layers` bag has been cleared is
|
|
50
61
|
* still a rule with an empty bag, not a rule missing a required field. Removing the field itself
|
|
51
62
|
* is what `null` AT that segment says. A SET never prunes: an empty object a caller wrote is a
|
|
52
|
-
* value.
|
|
63
|
+
* value. Neither does a list: removing its last entry leaves `[]`.
|
|
53
64
|
*/
|
|
54
|
-
declare function setAtPath(body: Record<string, unknown>, segments: readonly string[], value: unknown
|
|
65
|
+
declare function setAtPath(body: Record<string, unknown>, segments: readonly string[], value: unknown): Record<string, unknown>;
|
|
55
66
|
/**
|
|
56
67
|
* A path-keyed delta applied to a body, entry by entry in the order the caller wrote them.
|
|
57
68
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reject } from "../rejection.js";
|
|
1
2
|
//#region src/framework/utils/field-path.ts
|
|
2
3
|
/**
|
|
3
4
|
* A write's ADDRESS, carried in the delta's KEY.
|
|
@@ -24,6 +25,17 @@
|
|
|
24
25
|
* The one thing an address cannot spell is a member key that itself contains a dot (`spacing.2`,
|
|
25
26
|
* which nothing names today — paths separate with `/`). Such a key is reachable by `sub-upsert`,
|
|
26
27
|
* which addresses it whole.
|
|
28
|
+
*
|
|
29
|
+
* A segment that meets an array addresses one of its entries, by index or as `-`:
|
|
30
|
+
*
|
|
31
|
+
* { 'content.1': 'src/**' } → replaces entry 1
|
|
32
|
+
* { 'content.2': 'src/**' } → appends, when the list has two entries
|
|
33
|
+
* { 'content.-': 'src/**' } → appends, whatever the length
|
|
34
|
+
* { 'content.1': null } → removes entry 1, and the later ones move up
|
|
35
|
+
*
|
|
36
|
+
* Whether a segment is an index is decided by the container being an array, so a record keyed `2`
|
|
37
|
+
* is still a record. An index past the end, or a segment that isn't one, is refused. `-` into a field
|
|
38
|
+
* that isn't set starts the list.
|
|
27
39
|
*/
|
|
28
40
|
/** A JSON object — not an array, not a class instance. */
|
|
29
41
|
function isPlainObject(value) {
|
|
@@ -64,9 +76,18 @@ function sectionDelta(field, data) {
|
|
|
64
76
|
* those are the target's own declared fields, and a rule whose `layers` bag has been cleared is
|
|
65
77
|
* still a rule with an empty bag, not a rule missing a required field. Removing the field itself
|
|
66
78
|
* is what `null` AT that segment says. A SET never prunes: an empty object a caller wrote is a
|
|
67
|
-
* value.
|
|
79
|
+
* value. Neither does a list: removing its last entry leaves `[]`.
|
|
68
80
|
*/
|
|
69
|
-
function setAtPath(body, segments, value
|
|
81
|
+
function setAtPath(body, segments, value) {
|
|
82
|
+
return setInRecord({
|
|
83
|
+
body,
|
|
84
|
+
segments,
|
|
85
|
+
value,
|
|
86
|
+
above: []
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** {@link setAtPath} below `above`, the segments already descended through. */
|
|
90
|
+
function setInRecord({ body, segments, value, above }) {
|
|
70
91
|
const [head, ...rest] = segments;
|
|
71
92
|
if (head === void 0) return body;
|
|
72
93
|
const next = { ...body };
|
|
@@ -75,11 +96,58 @@ function setAtPath(body, segments, value, depth = 0) {
|
|
|
75
96
|
else next[head] = value;
|
|
76
97
|
return next;
|
|
77
98
|
}
|
|
78
|
-
const written =
|
|
79
|
-
|
|
99
|
+
const written = setInside({
|
|
100
|
+
container: next[head],
|
|
101
|
+
segments: rest,
|
|
102
|
+
value,
|
|
103
|
+
above: [...above, head]
|
|
104
|
+
});
|
|
105
|
+
if (above.length > 0 && value === null && isPlainObject(written) && Object.keys(written).length === 0) delete next[head];
|
|
80
106
|
else next[head] = written;
|
|
81
107
|
return next;
|
|
82
108
|
}
|
|
109
|
+
/** `container` with `value` set at `segments` below it. An array keeps being an array, and so does
|
|
110
|
+
* anything that isn't a record when the next segment is `-`; anything else that isn't a record
|
|
111
|
+
* becomes one. */
|
|
112
|
+
function setInside({ container, segments, value, above }) {
|
|
113
|
+
let list;
|
|
114
|
+
if (Array.isArray(container)) list = container;
|
|
115
|
+
else if (segments[0] === "-" && !isPlainObject(container)) list = [];
|
|
116
|
+
if (!list) return setInRecord({
|
|
117
|
+
body: isPlainObject(container) ? container : {},
|
|
118
|
+
segments,
|
|
119
|
+
value,
|
|
120
|
+
above
|
|
121
|
+
});
|
|
122
|
+
const [head, ...rest] = segments;
|
|
123
|
+
const index = entryIndex({
|
|
124
|
+
list,
|
|
125
|
+
segment: head,
|
|
126
|
+
at: above
|
|
127
|
+
});
|
|
128
|
+
if (value === null && index === list.length) return container;
|
|
129
|
+
const next = [...list];
|
|
130
|
+
if (rest.length === 0) {
|
|
131
|
+
if (value === null) next.splice(index, 1);
|
|
132
|
+
else next[index] = value;
|
|
133
|
+
return next;
|
|
134
|
+
}
|
|
135
|
+
next[index] = setInside({
|
|
136
|
+
container: next[index],
|
|
137
|
+
segments: rest,
|
|
138
|
+
value,
|
|
139
|
+
above: [...above, head]
|
|
140
|
+
});
|
|
141
|
+
return next;
|
|
142
|
+
}
|
|
143
|
+
/** The entry `segment` addresses in `list`: an index up to its length, where the length appends,
|
|
144
|
+
* or `-`, which always does. */
|
|
145
|
+
function entryIndex({ list, segment, at }) {
|
|
146
|
+
if (segment === "-") return list.length;
|
|
147
|
+
const index = /^(0|[1-9]\d*)$/.test(segment) ? Number(segment) : void 0;
|
|
148
|
+
if (index === void 0 || index > list.length) reject("NOT_FOUND", `"${at.join(".")}" is a list of ${list.length}, so "${segment}" addresses nothing in it. Address an entry by its index (0–${list.length}, where ${list.length} appends) or append with "-".`);
|
|
149
|
+
return index;
|
|
150
|
+
}
|
|
83
151
|
/**
|
|
84
152
|
* A path-keyed delta applied to a body, entry by entry in the order the caller wrote them.
|
|
85
153
|
*
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import { Presence } from "./authoring/presence.js";
|
|
|
3
3
|
import { ENTITY_PATH_MESSAGE, MINTED, collectRefs, declarationText, entityPathProblem, entityRefOf, isEntityPath, isExtendedRef, isMintedRow, isRef, kindOf, memberOf, memberRef, orRef, pathOf, ref, refKey, refLeaf, refOfKey, refSchema, refTo, replaceRefMarkers, rewriteRefNamespace, rewriteRefSource, rewriteRefs, routedSource, sourceHops, sourceOf, splitRef, splitRefMarkers } from "./framework/utils/refs.js";
|
|
4
4
|
import { CSS_PROPERTY_NAMES, CSS_WIDE_KEYWORDS, cssProperty, cssValueIssue, isCssProperty } from "./css/values.js";
|
|
5
5
|
import { isNativeConfig, isSystemConfig } from "./configs/platform.js";
|
|
6
|
+
import { ConfigFormatError, ConfigRejection, isConfigFormatError, isConfigRejection } from "./framework/rejection.js";
|
|
6
7
|
import { applyPathDelta, isPlainObject, namedFields, pathDelta, pathSegments, setAtPath, touchedFields } from "./framework/utils/field-path.js";
|
|
7
8
|
import { defaultsFor, propDefaultConditions, storedDefaultConditions, withPropDefaultConditions } from "./framework/default-conditions.js";
|
|
8
9
|
import { CONFIG_OPERATION_KIND } from "./framework/config-operation-kind.js";
|
|
9
|
-
import { ConfigFormatError, ConfigRejection, isConfigFormatError, isConfigRejection } from "./framework/rejection.js";
|
|
10
10
|
import { describePatch } from "./framework/plan.js";
|
|
11
11
|
import { declaredField, deriveCreateSchema, deriveUpdateSchema, fieldKeys } from "./framework/utils/field-schema.js";
|
|
12
12
|
import { add, calcFunction, calcOperands, calcOperator, divide, evaluateCalc, isAdd, isCalc, isDivide, isMax, isMin, isMultiply, isSubtract, max, min, multiply, subtract } from "./entities/system/calc.js";
|