@yahoo/uds-create-config 5.117.0 → 5.118.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/dist/configs/system.js +2 -0
- package/dist/entities/system/defineComponent.d.ts +2 -0
- package/dist/framework/Config.d.ts +5 -3
- package/dist/framework/Config.js +45 -9
- package/dist/framework/Entity.d.ts +1 -0
- package/dist/framework/Entity.js +3 -0
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/framework/utils/field-schema.d.ts +1 -0
- package/dist/framework/utils/field-schema.js +2 -1
- package/dist/migrations/20261124191049_guidance_append_mode.d.ts +6 -0
- package/dist/migrations/20261124191049_guidance_append_mode.js +10 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/configs/system.js
CHANGED
|
@@ -54,6 +54,7 @@ import { variantBooleansMigration } from "../migrations/20261112154943_variant_b
|
|
|
54
54
|
import { vendorLinkTypeMigration } from "../migrations/20261112163439_vendor_link_type.js";
|
|
55
55
|
import { styleSetOwnRuleOnlyMigration } from "../migrations/20261113131930_style_set_own_rule_only.js";
|
|
56
56
|
import { lintNamesRemovedMigration } from "../migrations/20261118171253_lint_names_removed.js";
|
|
57
|
+
import { guidanceAppendModeMigration } from "../migrations/20261124191049_guidance_append_mode.js";
|
|
57
58
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
58
59
|
import { GlobalStyle } from "../entities/system/GlobalStyle.js";
|
|
59
60
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
@@ -246,5 +247,6 @@ if (!registeredSchemaMigrations().has(20261112163439)) registerSchemaMigrations(
|
|
|
246
247
|
if (!registeredSchemaMigrations().has(20261113131930)) registerSchemaMigrations(styleSetOwnRuleOnlyMigration);
|
|
247
248
|
if (!registeredSchemaMigrations().has(20261117234103)) registerSchemaMigrations(uds6038McpInputsMigration);
|
|
248
249
|
if (!registeredSchemaMigrations().has(20261118171253)) registerSchemaMigrations(lintNamesRemovedMigration);
|
|
250
|
+
if (!registeredSchemaMigrations().has(20261124191049)) registerSchemaMigrations(guidanceAppendModeMigration);
|
|
249
251
|
//#endregion
|
|
250
252
|
export { System };
|
|
@@ -893,6 +893,7 @@ in out F extends string = never, /** The states `.states()` declared — what th
|
|
|
893
893
|
label?: string;
|
|
894
894
|
description?: string;
|
|
895
895
|
guidance?: string;
|
|
896
|
+
guidanceMode?: 'replace' | 'append';
|
|
896
897
|
hidden?: boolean;
|
|
897
898
|
deprecated?: boolean;
|
|
898
899
|
}): ComponentBuilder<L, P, E, D, F, S>;
|
|
@@ -1006,6 +1007,7 @@ interface ComponentHandle<in out L extends LayerMap, in out P extends PropMap, i
|
|
|
1006
1007
|
label?: string;
|
|
1007
1008
|
description?: string;
|
|
1008
1009
|
guidance?: string;
|
|
1010
|
+
guidanceMode?: 'replace' | 'append';
|
|
1009
1011
|
hidden?: boolean;
|
|
1010
1012
|
deprecated?: boolean;
|
|
1011
1013
|
}): ComponentBuilder<L, P, E, D, F, S>;
|
|
@@ -74,7 +74,7 @@ interface RecordedSource {
|
|
|
74
74
|
* The dense-counter `2` a short-lived scheme stamped before the chain existed reads as the mint
|
|
75
75
|
* that replaced it (see `detectedWireVersion`).
|
|
76
76
|
*/
|
|
77
|
-
declare const SERIALIZED_CONFIG_VERSION =
|
|
77
|
+
declare const SERIALIZED_CONFIG_VERSION = 20261124191049;
|
|
78
78
|
interface SerializedConfig {
|
|
79
79
|
/** See {@link SERIALIZED_CONFIG_VERSION}. Always written; a stored artifact may lack it. */
|
|
80
80
|
readonly version: number;
|
|
@@ -1476,13 +1476,15 @@ declare class Config {
|
|
|
1476
1476
|
path,
|
|
1477
1477
|
body,
|
|
1478
1478
|
extend,
|
|
1479
|
-
source
|
|
1479
|
+
source,
|
|
1480
|
+
resolveGuidance
|
|
1480
1481
|
}: {
|
|
1481
1482
|
kind: string;
|
|
1482
1483
|
path: string;
|
|
1483
1484
|
body: Record<string, unknown>;
|
|
1484
1485
|
extend: Record<string, unknown>;
|
|
1485
|
-
source?: Config;
|
|
1486
|
+
source?: Config; /** Validation must retain the authored addition rather than persist its resolved source text. */
|
|
1487
|
+
resolveGuidance?: boolean;
|
|
1486
1488
|
}): Record<string, unknown>;
|
|
1487
1489
|
/** The body of the entity a re-pointed path names, or `undefined` when there is none to read. */
|
|
1488
1490
|
private redirectedBody;
|
package/dist/framework/Config.js
CHANGED
|
@@ -2346,6 +2346,7 @@ var Config = class Config {
|
|
|
2346
2346
|
retired: entry.retiredFields
|
|
2347
2347
|
}) : parsedDelta;
|
|
2348
2348
|
const touched = touchedFields(delta, isField);
|
|
2349
|
+
validateGuidanceAppend(delta, extension !== void 0);
|
|
2349
2350
|
if (extension) {
|
|
2350
2351
|
this.at(snapshot).refuseVendorEdit(patch.kind, patch.path);
|
|
2351
2352
|
const resolved = this.at(snapshot).resolveExtension({
|
|
@@ -2381,7 +2382,8 @@ var Config = class Config {
|
|
|
2381
2382
|
path: pathOf(extension),
|
|
2382
2383
|
body: sourceBody,
|
|
2383
2384
|
extend: local,
|
|
2384
|
-
source: this.configFor(extension)
|
|
2385
|
+
source: this.configFor(extension),
|
|
2386
|
+
resolveGuidance: false
|
|
2385
2387
|
});
|
|
2386
2388
|
const createSchema = wholeBodySchema(entry, { config: this });
|
|
2387
2389
|
let merged = candidate;
|
|
@@ -2412,8 +2414,13 @@ var Config = class Config {
|
|
|
2412
2414
|
const accessor = view.accessorOf(patch.kind) ?? patch.kind;
|
|
2413
2415
|
const existing = view.sourceOverlay(slug, patch.kind, patch.path);
|
|
2414
2416
|
const { target: redirect, rest } = redirectOf(local);
|
|
2417
|
+
const comparison = {
|
|
2418
|
+
...sourceBody,
|
|
2419
|
+
guidanceMode: void 0
|
|
2420
|
+
};
|
|
2421
|
+
if (local.guidanceMode === "append") comparison.guidance = void 0;
|
|
2415
2422
|
const overlay = {
|
|
2416
|
-
...redirect === void 0 ? classifyOverlay(local,
|
|
2423
|
+
...redirect === void 0 ? classifyOverlay(local, comparison) : {
|
|
2417
2424
|
override: { __ref: redirect },
|
|
2418
2425
|
...Object.keys(rest).length > 0 ? { extend: rest } : {}
|
|
2419
2426
|
},
|
|
@@ -2914,6 +2921,7 @@ var Config = class Config {
|
|
|
2914
2921
|
rejectData(`Cannot set "${key}" on ${kind} group "${path}" — a ${kind} group holds ${[...entry.groupFieldKeys, ...METADATA_KEYS].map((field) => `"${field}"`).join(", ")}.`, [key]);
|
|
2915
2922
|
}
|
|
2916
2923
|
const current = snapshot.group(kind, path)?.toJSON() ?? {};
|
|
2924
|
+
validateGuidanceAppend(delta, isRef(Object.hasOwn(delta, "ref") ? delta.ref : current.ref));
|
|
2917
2925
|
const groupRef = current.ref;
|
|
2918
2926
|
if (isMintedRow(current) && isRef(groupRef) && !Object.hasOwn(delta, "ref")) {
|
|
2919
2927
|
const slug = sourceOf(groupRef);
|
|
@@ -2930,9 +2938,14 @@ var Config = class Config {
|
|
|
2930
2938
|
...delta
|
|
2931
2939
|
};
|
|
2932
2940
|
for (const key of Object.keys(local)) if (local[key] === null) delete local[key];
|
|
2941
|
+
const comparison = {
|
|
2942
|
+
...theirs,
|
|
2943
|
+
guidanceMode: void 0
|
|
2944
|
+
};
|
|
2945
|
+
if (local.guidanceMode === "append") comparison.guidance = void 0;
|
|
2933
2946
|
const accessor = view.accessorOf(kind) ?? kind;
|
|
2934
2947
|
const overlay = {
|
|
2935
|
-
...classifyOverlay(local,
|
|
2948
|
+
...classifyOverlay(local, comparison),
|
|
2936
2949
|
...existing?.hidden ? { hidden: true } : {}
|
|
2937
2950
|
};
|
|
2938
2951
|
if (view.sourceTypeOf(slug) === "vendor" && (overlay.override !== void 0 || overlay.extend !== void 0)) reject("UNSUPPORTED", `Cannot update ${kind} group "${path}" — it comes from the vendor source "${slug}", which is used as shipped.`);
|
|
@@ -3199,21 +3212,27 @@ var Config = class Config {
|
|
|
3199
3212
|
* nothing. The pin's invariants refuse the last two when they're written, and the build reports a
|
|
3200
3213
|
* missing target (`brokenLinkRedirects`).
|
|
3201
3214
|
*/
|
|
3202
|
-
laidLinkedBody({ kind, path, body, extend, source }) {
|
|
3215
|
+
laidLinkedBody({ kind, path, body, extend, source, resolveGuidance = true }) {
|
|
3203
3216
|
const { target, rest } = redirectOf(extend);
|
|
3204
3217
|
const base = target === void 0 ? body : this.redirectedBody({
|
|
3205
3218
|
kind,
|
|
3206
3219
|
path,
|
|
3207
3220
|
target
|
|
3208
3221
|
}) ?? {};
|
|
3209
|
-
|
|
3222
|
+
const inherited = rebasedLinkedBody({
|
|
3210
3223
|
entry: this.entityOf(kind),
|
|
3211
3224
|
path,
|
|
3212
3225
|
body: base,
|
|
3213
3226
|
extend: rest,
|
|
3214
3227
|
config: this,
|
|
3215
3228
|
source: target === void 0 ? source : this.configFor({ __ref: target })
|
|
3216
|
-
})
|
|
3229
|
+
});
|
|
3230
|
+
return withLocalGuidance({
|
|
3231
|
+
merged: extendBody(inherited, rest),
|
|
3232
|
+
inherited,
|
|
3233
|
+
local: rest,
|
|
3234
|
+
resolve: resolveGuidance
|
|
3235
|
+
});
|
|
3217
3236
|
}
|
|
3218
3237
|
/** The body of the entity a re-pointed path names, or `undefined` when there is none to read. */
|
|
3219
3238
|
redirectedBody({ kind, path, target }) {
|
|
@@ -4608,12 +4627,19 @@ var Config = class Config {
|
|
|
4608
4627
|
owns: (refKind) => from.entityOf(refKind) !== void 0
|
|
4609
4628
|
});
|
|
4610
4629
|
}
|
|
4611
|
-
|
|
4612
|
-
...inherited,
|
|
4630
|
+
const own = {
|
|
4613
4631
|
...overlay?.override,
|
|
4614
4632
|
...overlay?.extend,
|
|
4615
4633
|
...body
|
|
4616
4634
|
};
|
|
4635
|
+
return withLocalGuidance({
|
|
4636
|
+
merged: {
|
|
4637
|
+
...inherited,
|
|
4638
|
+
...own
|
|
4639
|
+
},
|
|
4640
|
+
inherited,
|
|
4641
|
+
local: own
|
|
4642
|
+
});
|
|
4617
4643
|
}
|
|
4618
4644
|
/** Every group node of a kind, total by default; `{ retired: false }` leaves out retired folders,
|
|
4619
4645
|
* the same way {@link list} leaves out retired items. */
|
|
@@ -6686,7 +6712,7 @@ var Config = class Config {
|
|
|
6686
6712
|
* links from the provided sources. A declared `linkedKind` with no provided source throws. */
|
|
6687
6713
|
hydrateFrom(stored, options) {
|
|
6688
6714
|
const claimed = schemaVersionOf(stored);
|
|
6689
|
-
if (claimed >
|
|
6715
|
+
if (claimed > 20261124191049) throw new SchemaVersionTooNew(claimed);
|
|
6690
6716
|
const wire = upgradeSerializedConfig(stored);
|
|
6691
6717
|
if (!Array.isArray(wire.ownedKinds) || typeof wire.items !== "object" || wire.items === null) throw new ConfigFormatError(`Config "${stored.name ?? "system-config"}" cannot be hydrated: this is not a serialized config-v2 config (no "ownedKinds"/"items"). A pre-cutover build artifact converts through the registered cutover migration — import the config type's module (e.g. \`configs/system\`) before hydrating.`);
|
|
6692
6718
|
const leftover = wire.options;
|
|
@@ -6839,6 +6865,16 @@ function extendBody(base, delta) {
|
|
|
6839
6865
|
for (const [field, value] of Object.entries(delta)) merged[field] = extendBody(merged[field], value);
|
|
6840
6866
|
return merged;
|
|
6841
6867
|
}
|
|
6868
|
+
/** Append describes inheritance, never concatenation with the previous local string. */
|
|
6869
|
+
function validateGuidanceAppend(delta, linked) {
|
|
6870
|
+
if (delta.guidanceMode === "append" && !linked) rejectData("Append mode requires linked guidance. To add advice to this local entity, read its existing guidance and write the complete combined text without append mode. Preserve existing advice unless replacement or removal was requested.", ["guidanceMode"]);
|
|
6871
|
+
}
|
|
6872
|
+
/** Append resolves on reads; validation keeps only the authored addition. */
|
|
6873
|
+
function withLocalGuidance({ merged, inherited, local, resolve = true }) {
|
|
6874
|
+
if (!Object.hasOwn(local, "guidanceMode")) delete merged.guidanceMode;
|
|
6875
|
+
if (resolve && local.guidanceMode === "append" && typeof local.guidance === "string") merged.guidance = [inherited.guidance, local.guidance].filter((text) => typeof text === "string" && text.trim() !== "").join("\n\n");
|
|
6876
|
+
return merged;
|
|
6877
|
+
}
|
|
6842
6878
|
/**
|
|
6843
6879
|
* One stored `extend` from a pin's two verbs.
|
|
6844
6880
|
*
|
|
@@ -30,6 +30,7 @@ declare class Entity {
|
|
|
30
30
|
readonly deprecated?: boolean;
|
|
31
31
|
/** How to use this entity, as prose for a model. Collected into the guidance document per kind. */
|
|
32
32
|
readonly guidance?: string;
|
|
33
|
+
readonly guidanceMode?: 'replace' | 'append';
|
|
33
34
|
/**
|
|
34
35
|
* The DEPENDENCIES this item's own fields point through, deduped and sorted — the framework installs
|
|
35
36
|
* this computed on every kind, so it is declared here rather than per kind.
|
package/dist/framework/Entity.js
CHANGED
|
@@ -17,6 +17,7 @@ var Entity = class {
|
|
|
17
17
|
deprecated;
|
|
18
18
|
/** How to use this entity, as prose for a model. Collected into the guidance document per kind. */
|
|
19
19
|
guidance;
|
|
20
|
+
guidanceMode;
|
|
20
21
|
constructor(path, raw, fieldKeys, computedKeys = []) {
|
|
21
22
|
this.path = path;
|
|
22
23
|
this.fieldKeys = fieldKeys;
|
|
@@ -30,6 +31,7 @@ var Entity = class {
|
|
|
30
31
|
this.hidden = raw.hidden;
|
|
31
32
|
this.deprecated = raw.deprecated;
|
|
32
33
|
this.guidance = raw.guidance;
|
|
34
|
+
this.guidanceMode = raw.guidanceMode;
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* The ONE source this item comes from, or `undefined` when it comes from none — what a surface names
|
|
@@ -118,6 +120,7 @@ var Entity = class {
|
|
|
118
120
|
if (this.hidden !== void 0) out.hidden = this.hidden;
|
|
119
121
|
if (this.deprecated !== void 0) out.deprecated = this.deprecated;
|
|
120
122
|
if (this.guidance !== void 0) out.guidance = this.guidance;
|
|
123
|
+
if (this.guidanceMode !== void 0) out.guidanceMode = this.guidanceMode;
|
|
121
124
|
return out;
|
|
122
125
|
}
|
|
123
126
|
};
|
|
@@ -15,7 +15,7 @@ import { Patch, SerializedConfig } from "./Config.js";
|
|
|
15
15
|
* sets this constant to its own older timestamp; the merge ref then carries a registered migration
|
|
16
16
|
* newer than the constant, and the assertion fails until the author re-mints.
|
|
17
17
|
*/
|
|
18
|
-
declare const CURRENT_SCHEMA_VERSION =
|
|
18
|
+
declare const CURRENT_SCHEMA_VERSION = 20261124191049;
|
|
19
19
|
/** What the walkers need to see of an envelope — loose on purpose, so a typed `SerializedConfig`
|
|
20
20
|
* and a raw old-shape record both flow in without casts. */
|
|
21
21
|
interface VersionStamped {
|
|
@@ -13,7 +13,7 @@ import { ConfigFormatError } from "./rejection.js";
|
|
|
13
13
|
* sets this constant to its own older timestamp; the merge ref then carries a registered migration
|
|
14
14
|
* newer than the constant, and the assertion fails until the author re-mints.
|
|
15
15
|
*/
|
|
16
|
-
const CURRENT_SCHEMA_VERSION =
|
|
16
|
+
const CURRENT_SCHEMA_VERSION = 20261124191049;
|
|
17
17
|
/** The mint that moved `options` into the `settings` kind — restated here, rather than imported
|
|
18
18
|
* from the migration that owns it, because that migration imports this module. */
|
|
19
19
|
const SETTINGS_AS_KIND_VERSION = 20260908171448;
|
|
@@ -45,7 +45,7 @@ function registerSchemaMigrations(...migrations) {
|
|
|
45
45
|
for (const migration of migrations) {
|
|
46
46
|
if (migration.version !== 1 && !isMintTimestamp(migration.version)) throw new Error(`Schema migration version ${migration.version} is not a mint timestamp — mint one with \`date +%Y%m%d%H%M%S\`, like a supabase migration.`);
|
|
47
47
|
if (REGISTERED.has(migration.version)) throw new Error(`A schema migration at version ${migration.version} is already registered.`);
|
|
48
|
-
if (migration.version >
|
|
48
|
+
if (migration.version > 20261124191049) throw new Error(`Schema migration ${migration.version} is newer than CURRENT_SCHEMA_VERSION (${CURRENT_SCHEMA_VERSION}) — a stale branch merged, or the mint forgot to bump the constant. Re-mint: set CURRENT_SCHEMA_VERSION to the newest migration version.`);
|
|
49
49
|
REGISTERED.set(migration.version, migration);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -102,7 +102,7 @@ function pendingFor(version, target, options) {
|
|
|
102
102
|
* Already-current input passes through untouched — same reference, so hot paths pay nothing.
|
|
103
103
|
*/
|
|
104
104
|
function upgradeSerializedConfig(json, options) {
|
|
105
|
-
const target = options?.target ??
|
|
105
|
+
const target = options?.target ?? 20261124191049;
|
|
106
106
|
const version = detectedWireVersion(json);
|
|
107
107
|
if (version > target) throw new SchemaVersionTooNew(version, target);
|
|
108
108
|
const raw = json;
|
|
@@ -160,7 +160,7 @@ function upgradedSources(json, options) {
|
|
|
160
160
|
* meaning under the current schema and replay skips it — reported by the caller, not swallowed here.
|
|
161
161
|
*/
|
|
162
162
|
function upgradePatch(patch, writtenAt, options) {
|
|
163
|
-
const target = options?.target ??
|
|
163
|
+
const target = options?.target ?? 20261124191049;
|
|
164
164
|
if (writtenAt > target) throw new SchemaVersionTooNew(writtenAt, target);
|
|
165
165
|
let current = patch;
|
|
166
166
|
for (const migration of pendingFor(writtenAt, target, options)) {
|
|
@@ -179,7 +179,7 @@ function upgradePatch(patch, writtenAt, options) {
|
|
|
179
179
|
* stamp would cause.
|
|
180
180
|
*/
|
|
181
181
|
function upgradeDraftEntries(draft, options) {
|
|
182
|
-
const target = options?.target ??
|
|
182
|
+
const target = options?.target ?? 20261124191049;
|
|
183
183
|
const entries = [];
|
|
184
184
|
const held = [];
|
|
185
185
|
const retired = [];
|
|
@@ -19,6 +19,7 @@ type CreateInput<S extends FieldsSchema> = RemoveIndex<z.input<S>> & {
|
|
|
19
19
|
hidden?: boolean;
|
|
20
20
|
deprecated?: boolean;
|
|
21
21
|
guidance?: string;
|
|
22
|
+
guidanceMode?: 'replace' | 'append';
|
|
22
23
|
};
|
|
23
24
|
/** The create validator — the field schema plus metadata (the storage shape; a value
|
|
24
25
|
* storage accepts is creatable — no artificial narrowing at the entity layer). A union
|
|
@@ -36,7 +36,8 @@ const METADATA = {
|
|
|
36
36
|
copiedFrom: z.string().optional(),
|
|
37
37
|
hidden: z.boolean().optional(),
|
|
38
38
|
deprecated: z.boolean().optional(),
|
|
39
|
-
guidance: z.string().optional()
|
|
39
|
+
guidance: z.string().optional(),
|
|
40
|
+
guidanceMode: z.enum(["replace", "append"]).optional().describe("How local guidance combines with a linked entity: append keeps inherited text and adds the local text after it. Omitted or replace preserves whole-string replacement; an empty replacement suppresses inherited guidance.")
|
|
40
41
|
};
|
|
41
42
|
/**
|
|
42
43
|
* The metadata names a body may carry on top of its kind's own fields — read off {@link metadata}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Optional guidanceMode metadata adds explicit append semantics; existing text and patches retain
|
|
2
|
+
* replacement semantics. Retire when support for configs older than this version is removed.
|
|
3
|
+
*/
|
|
4
|
+
import type { SchemaMigration } from '../framework/schema-version';
|
|
5
|
+
export declare const GUIDANCE_APPEND_MODE_VERSION = 20261124191049;
|
|
6
|
+
export declare const guidanceAppendModeMigration: SchemaMigration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/migrations/20261124191049_guidance_append_mode.ts
|
|
2
|
+
const GUIDANCE_APPEND_MODE_VERSION = 20261124191049;
|
|
3
|
+
const guidanceAppendModeMigration = {
|
|
4
|
+
version: GUIDANCE_APPEND_MODE_VERSION,
|
|
5
|
+
up(json) {
|
|
6
|
+
return json;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { GUIDANCE_APPEND_MODE_VERSION, guidanceAppendModeMigration };
|