@yahoo/uds-create-config 5.78.0 → 5.80.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/CanvasConfig.d.ts +1 -1
- package/dist/configs/react-native-system.d.ts +1 -1
- package/dist/configs/react-native-system.js +1 -1
- package/dist/configs/system.d.ts +1 -1
- package/dist/configs/system.js +3 -1
- package/dist/entities/system/{LinkedSystem.d.ts → Source.d.ts} +19 -11
- package/dist/entities/system/{LinkedSystem.js → Source.js} +127 -130
- package/dist/entities/system/component-module.js +2 -2
- package/dist/entities/system/copy-plan.js +5 -2
- package/dist/entities/system/css-motion-reach.js +6 -6
- package/dist/entities/system/link-declaration.d.ts +6 -68
- package/dist/entities/system/link-declaration.js +30 -4
- package/dist/entities/system/link-plan.d.ts +2 -2
- package/dist/entities/system/link-plan.js +44 -15
- package/dist/entities/system/motion-variants.js +2 -2
- package/dist/framework/Config.d.ts +44 -24
- package/dist/framework/Config.js +140 -41
- package/dist/framework/defineConfig.d.ts +3 -3
- package/dist/framework/defineEntity.d.ts +4 -3
- package/dist/framework/defineEntity.js +2 -1
- package/dist/framework/derived-mutations.d.ts +1 -1
- package/dist/framework/derived-mutations.js +1 -1
- package/dist/framework/inline-sources.js +2 -2
- package/dist/framework/registry.d.ts +13 -7
- package/dist/framework/registry.js +3 -2
- package/dist/framework/retired-fields.d.ts +33 -0
- package/dist/framework/retired-fields.js +148 -0
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/framework/schemas.js +1 -1
- package/dist/framework/signature.js +4 -1
- package/dist/framework/source-integrity.d.ts +2 -2
- package/dist/framework/source-integrity.js +2 -2
- package/dist/framework/sources.d.ts +3 -3
- package/dist/framework/sources.js +1 -1
- package/dist/framework/utils/field-schema.js +7 -2
- package/dist/framework/utils/refs.d.ts +1 -1
- package/dist/framework/utils/refs.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -3
- package/dist/migrations/2.0.0/v1-artifact.d.ts +1 -1
- package/dist/migrations/20261105185042_sources_stored.d.ts +19 -0
- package/dist/migrations/20261105185042_sources_stored.js +125 -0
- package/dist/spec/links.d.ts +1 -1
- package/dist/spec/links.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/framework/authored-at.d.ts +0 -31
- package/dist/framework/authored-at.js +0 -73
|
@@ -16,7 +16,7 @@ import { z } from "zod";
|
|
|
16
16
|
|
|
17
17
|
//#region src/configs/CanvasConfig.d.ts
|
|
18
18
|
/**
|
|
19
|
-
* `SystemSource` — this canvas's pointer at the ONE system it belongs to, in full. `
|
|
19
|
+
* `SystemSource` — this canvas's pointer at the ONE system it belongs to, in full. `Source` is
|
|
20
20
|
* the wrong mechanism here: it exists for a design system partially borrowing PIECES of another
|
|
21
21
|
* (`link`, per-entity `options`, override/extend), and a canvas never does that — a node's `type`
|
|
22
22
|
* always resolves against the whole of exactly one system.
|
|
@@ -12,7 +12,7 @@ import { CompositeClass } from "../entities/system/Composite.js";
|
|
|
12
12
|
import { OverrideCondition } from "../entities/system/Token.js";
|
|
13
13
|
import { StylePropValue } from "../entities/system/StyleProperty.js";
|
|
14
14
|
import { ComponentClass } from "../entities/system/Component.js";
|
|
15
|
-
import { SourceClass } from "../entities/system/
|
|
15
|
+
import { SourceClass } from "../entities/system/Source.js";
|
|
16
16
|
import { IconClass } from "../entities/system/Icon.js";
|
|
17
17
|
import { NativeModifierClass } from "../entities/native/NativeModifier.js";
|
|
18
18
|
import { CanvasRoleClass } from "../entities/system/CanvasRole.js";
|
|
@@ -18,7 +18,7 @@ import { motionJsonSchemaMigration } from "../migrations/20261015221052_motion_j
|
|
|
18
18
|
import { motionTypeOnlyMigration } from "../migrations/20261016135620_motion_type_only.js";
|
|
19
19
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
20
20
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
21
|
-
import { Source } from "../entities/system/
|
|
21
|
+
import { Source } from "../entities/system/Source.js";
|
|
22
22
|
import { settingsAsKindMigration } from "../migrations/20260908171448_settings_as_kind.js";
|
|
23
23
|
import { visibleStatePointerMigration } from "../migrations/20260908194245_visible_state_pointer.js";
|
|
24
24
|
import { iconKnockoutVariantsMigration } from "../migrations/20260909183001_icon_knockout_variants.js";
|
package/dist/configs/system.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ModifierClass } from "../entities/system/Modifier.js";
|
|
|
6
6
|
import { TokenClass } from "../entities/system/Token.js";
|
|
7
7
|
import { StylePropertyClass } from "../entities/system/StyleProperty.js";
|
|
8
8
|
import { ComponentClass } from "../entities/system/Component.js";
|
|
9
|
-
import { SourceClass } from "../entities/system/
|
|
9
|
+
import { SourceClass } from "../entities/system/Source.js";
|
|
10
10
|
import { IconClass } from "../entities/system/Icon.js";
|
|
11
11
|
import { CanvasRoleClass } from "../entities/system/CanvasRole.js";
|
|
12
12
|
import { DeviceClass } from "../entities/system/Device.js";
|
package/dist/configs/system.js
CHANGED
|
@@ -40,11 +40,12 @@ import { linkReplaceMigration } from "../migrations/20261102185610_link_replace.
|
|
|
40
40
|
import { mapPropsFromMigration } from "../migrations/20261102193912_map_props_from.js";
|
|
41
41
|
import { sourcesAuthoringMigration } from "../migrations/20261103115059_sources_authoring.js";
|
|
42
42
|
import { buildDebugMigration } from "../migrations/20261104151013_build_debug.js";
|
|
43
|
+
import { sourcesStoredMigration } from "../migrations/20261105185042_sources_stored.js";
|
|
43
44
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
44
45
|
import { GlobalStyle } from "../entities/system/GlobalStyle.js";
|
|
45
46
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
46
47
|
import { GuidanceStyle } from "../entities/system/GuidanceStyle.js";
|
|
47
|
-
import { Source } from "../entities/system/
|
|
48
|
+
import { Source } from "../entities/system/Source.js";
|
|
48
49
|
import { loadV1Artifact } from "../migrations/2.0.0/v1-artifact.js";
|
|
49
50
|
import { settingsAsKindMigration } from "../migrations/20260908171448_settings_as_kind.js";
|
|
50
51
|
import { visibleStatePointerMigration } from "../migrations/20260908194245_visible_state_pointer.js";
|
|
@@ -216,5 +217,6 @@ if (!registeredSchemaMigrations().has(20261102185610)) registerSchemaMigrations(
|
|
|
216
217
|
if (!registeredSchemaMigrations().has(20261102193912)) registerSchemaMigrations(mapPropsFromMigration);
|
|
217
218
|
if (!registeredSchemaMigrations().has(20261103115059)) registerSchemaMigrations(sourcesAuthoringMigration);
|
|
218
219
|
if (!registeredSchemaMigrations().has(20261104151013)) registerSchemaMigrations(buildDebugMigration);
|
|
220
|
+
if (!registeredSchemaMigrations().has(20261105185042)) registerSchemaMigrations(sourcesStoredMigration);
|
|
219
221
|
//#endregion
|
|
220
222
|
export { System };
|
|
@@ -10,7 +10,7 @@ import { ContractStyleRules } from "./Component.js";
|
|
|
10
10
|
import { Config } from "../../framework/Config.js";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
-
//#region src/entities/system/
|
|
13
|
+
//#region src/entities/system/Source.d.ts
|
|
14
14
|
/**
|
|
15
15
|
* A link's slug, as a single path segment.
|
|
16
16
|
*
|
|
@@ -103,8 +103,8 @@ type SourceUnavailable = z.infer<typeof sourceUnavailable>;
|
|
|
103
103
|
type PinOptionsField = z.ZodOptional<z.ZodType<PinOptions, PinOptions>>;
|
|
104
104
|
declare const LinkedSystemDefinition: EntityClass<z.ZodObject<{
|
|
105
105
|
configPath: z.ZodOptional<z.ZodString>;
|
|
106
|
-
link: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>]>>;
|
|
107
106
|
options: PinOptionsField;
|
|
107
|
+
link: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>]>>;
|
|
108
108
|
package: z.ZodOptional<z.ZodString>;
|
|
109
109
|
systemId: z.ZodOptional<z.ZodString>;
|
|
110
110
|
modules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -114,7 +114,7 @@ declare const LinkedSystemDefinition: EntityClass<z.ZodObject<{
|
|
|
114
114
|
hybrid: "hybrid";
|
|
115
115
|
}>>;
|
|
116
116
|
version: z.ZodOptional<z.ZodString>;
|
|
117
|
-
}, z.core.$strict>, z.ZodObject<Record<never, never>, z.core.$strip>, "
|
|
117
|
+
}, z.core.$strict>, z.ZodObject<Record<never, never>, z.core.$strip>, "source", {
|
|
118
118
|
readonly link: {
|
|
119
119
|
readonly input: z.ZodObject<{
|
|
120
120
|
path: z.ZodType<string, string | undefined, z.core.$ZodTypeInternals<string, string | undefined>>;
|
|
@@ -273,9 +273,13 @@ declare const LinkedSystem: SourceClass;
|
|
|
273
273
|
* The paths are still `string`. A source's catalogue lives in its installed artifact, so typing those
|
|
274
274
|
* needs a declaration per source — see the source-model doc.
|
|
275
275
|
*/
|
|
276
|
-
type PinOptions = {
|
|
276
|
+
type PinOptions = {
|
|
277
|
+
/** What the system draws from the source. See {@link LinkDeclaration}. */readonly include?: LinkDeclaration;
|
|
278
|
+
} & ([keyof RegisteredEntities] extends [never] ? {
|
|
279
|
+
readonly [accessor: string]: unknown;
|
|
280
|
+
} : { [A in keyof RegisteredEntities]?: Record<string, PinAdjustment<RegisteredEntities[A]>> });
|
|
277
281
|
/**
|
|
278
|
-
* {@link PinOptions} as `
|
|
282
|
+
* {@link PinOptions} as `Source.item` takes it: a component entry's `override` and `extend` also
|
|
279
283
|
* take their `styles` as the rule list `defineComponent.styles` takes (`[{ when?, layers }]`), which
|
|
280
284
|
* the item stores as the record, and an entry at a group path takes the kind's group fields.
|
|
281
285
|
*
|
|
@@ -361,22 +365,26 @@ interface PinDirective {
|
|
|
361
365
|
/** One declared source, typed off this kind's own schema — what the readers below hand back. */
|
|
362
366
|
type Source = ItemOf<typeof Source>;
|
|
363
367
|
/**
|
|
364
|
-
* A
|
|
368
|
+
* A source's state as `Config.sourceStates()` reports it, narrowed to this kind's vocabulary.
|
|
365
369
|
*
|
|
366
370
|
* `Config` spans every source kind a config declares, so it can only type the payloads as `unknown`;
|
|
367
371
|
* only the kind knows them. This is that knowledge, named once so no surface restates the union or
|
|
368
372
|
* casts its way to it. Pick states out of `config.sourceStates()` by their `source` accessor name, then read
|
|
369
373
|
* them as this.
|
|
370
374
|
*/
|
|
371
|
-
type
|
|
375
|
+
type SystemSourceState = SourceState<ResolvedSource, SourceUnavailable>;
|
|
376
|
+
/** @deprecated Use {@link SystemSourceState}. */
|
|
377
|
+
type LinkedSystemState = SystemSourceState;
|
|
372
378
|
/**
|
|
373
|
-
* The resolver `Config.load` wants for `
|
|
379
|
+
* The resolver `Config.load` wants for `sources`, typed both ways: handed a {@link Source}, and
|
|
374
380
|
* held to this kind's own two payloads.
|
|
375
381
|
*
|
|
376
382
|
* The build's disk resolver and Studio's storage resolver both implement this, which is what makes them
|
|
377
383
|
* answer in one vocabulary rather than two that agree by convention.
|
|
378
384
|
*/
|
|
379
|
-
type
|
|
385
|
+
type SystemSourceResolver = SourceResolver<Source, ResolvedSource, SourceUnavailable>;
|
|
386
|
+
/** @deprecated Use {@link SystemSourceResolver}. */
|
|
387
|
+
type LinkedSystemResolver = SystemSourceResolver;
|
|
380
388
|
/**
|
|
381
389
|
* The source an entity comes from — `undefined` for one wholly this config's own, and for one that
|
|
382
390
|
* involves two systems, since naming either would label the other wrongly. See `Entity.source`.
|
|
@@ -458,7 +466,7 @@ declare function borrowedGroup({
|
|
|
458
466
|
* Takes either way a source can be named, because the same system reached two ways is the same system:
|
|
459
467
|
* a form offering to draw on one that is already a source should say so and name the slug it lives
|
|
460
468
|
* under, rather than offering a second declaration under another name. Which fields those are is this
|
|
461
|
-
* kind's to know ({@link
|
|
469
|
+
* kind's to know ({@link Source.sourceIdentity}); a caller that indexed them itself would be
|
|
462
470
|
* restating the schema.
|
|
463
471
|
*/
|
|
464
472
|
declare function sourceSlugFor({
|
|
@@ -505,4 +513,4 @@ declare function linkRedirects(config: Config): LinkRedirect[];
|
|
|
505
513
|
/** One sentence for a re-pointed path that can't be read. */
|
|
506
514
|
declare function redirectSentence(redirect: LinkRedirect): string;
|
|
507
515
|
//#endregion
|
|
508
|
-
export { LINK_SLUG, LINK_SLUG_MESSAGE, LinkDeclaration, LinkRedirect, LinkedSystem, LinkedSystemClass, LinkedSystemCreateInput, LinkedSystemItemInput, LinkedSystemResolver, LinkedSystemState, PinDirective, PinOptions, PinOptionsField, PinOptionsInput, ResolvedSource, Source, SourceClass, SourceCreateInput, SourceItemInput, SourceUnavailable, borrowedGroup, borrowedItem, isLinkSlug, linkRedirects, redirectSentence, resolvedSource, sourceOfGroup, sourceOfItem, sourceSlugFor, sourceUnavailable, suggestLinkSlug };
|
|
516
|
+
export { LINK_SLUG, LINK_SLUG_MESSAGE, LinkDeclaration, LinkRedirect, LinkedSystem, LinkedSystemClass, LinkedSystemCreateInput, LinkedSystemItemInput, LinkedSystemResolver, LinkedSystemState, PinDirective, PinOptions, PinOptionsField, PinOptionsInput, ResolvedSource, Source, SourceClass, SourceCreateInput, SourceItemInput, SourceUnavailable, SystemSourceResolver, SystemSourceState, borrowedGroup, borrowedItem, isLinkSlug, linkRedirects, redirectSentence, resolvedSource, sourceOfGroup, sourceOfItem, sourceSlugFor, sourceUnavailable, suggestLinkSlug };
|
|
@@ -5,15 +5,15 @@ import { pathInput } from "../../framework/schemas.js";
|
|
|
5
5
|
import { kindBorrowable } from "../../framework/registry.js";
|
|
6
6
|
import { defineEntity } from "../../framework/defineEntity.js";
|
|
7
7
|
import { storedStyleRules } from "./Component.js";
|
|
8
|
-
import {
|
|
8
|
+
import { foldRetiredFields } from "../../framework/retired-fields.js";
|
|
9
9
|
import { sourceUnreachable } from "../../framework/sources.js";
|
|
10
|
-
import { covers, excludes } from "./link-declaration.js";
|
|
10
|
+
import { covers, directivesOf, excludes, includeOf } from "./link-declaration.js";
|
|
11
11
|
import { planCopy } from "./copy-plan.js";
|
|
12
12
|
import { planBreak, planExclude, planLink, planLinkApplied, planUnlink, sourceRowStates } from "./link-plan.js";
|
|
13
13
|
import { z } from "zod";
|
|
14
|
-
//#region src/entities/system/
|
|
14
|
+
//#region src/entities/system/Source.ts
|
|
15
15
|
/**
|
|
16
|
-
* `
|
|
16
|
+
* `Source` (`yahoo-os`) — another team's design system, drawn from at an exact version.
|
|
17
17
|
*
|
|
18
18
|
* Two questions kept apart, and this entity answers only the first:
|
|
19
19
|
*
|
|
@@ -71,7 +71,7 @@ function isLinkSlug(slug) {
|
|
|
71
71
|
* example a create or a rename would take. */
|
|
72
72
|
function freeExampleSlug(config, besides) {
|
|
73
73
|
let slug = "design-system";
|
|
74
|
-
for (let n = 2; slug === besides || config.resolve("
|
|
74
|
+
for (let n = 2; slug === besides || config.resolve("source", slug); n += 1) slug = `design-system-${n}`;
|
|
75
75
|
return slug;
|
|
76
76
|
}
|
|
77
77
|
/** A rename from a link this config holds (or a placeholder slug when it holds none) onto a free one. */
|
|
@@ -150,9 +150,9 @@ const sourceUnavailable = z.discriminatedUnion("code", [
|
|
|
150
150
|
/** What one accessor of a copy names: every entry of the kind, or the source's paths — items or folders. */
|
|
151
151
|
const copyPaths = z.union([z.literal("*"), z.array(z.string().min(1)).min(1)]);
|
|
152
152
|
const copyInput = z.object({
|
|
153
|
-
path: pathInput("
|
|
153
|
+
path: pathInput("source"),
|
|
154
154
|
/**
|
|
155
|
-
* What to take, keyed by accessor the way the pin's `
|
|
155
|
+
* What to take, keyed by accessor the way the pin's `options.include` is — `{ tokens: ['color/brand', 'color'],
|
|
156
156
|
* icons: '*' }` — or `'*'` for every kind the source offers and this config can hold. A path that
|
|
157
157
|
* names a folder in the source takes its members. Copied rows keep the source's own names.
|
|
158
158
|
*/
|
|
@@ -166,8 +166,8 @@ const copyInput = z.object({
|
|
|
166
166
|
onConflict: z.enum(["skip", "replace"]).optional()
|
|
167
167
|
});
|
|
168
168
|
const linkInput = z.object({
|
|
169
|
-
path: pathInput("
|
|
170
|
-
/** What to draw, keyed by accessor the way the pin's `
|
|
169
|
+
path: pathInput("source"),
|
|
170
|
+
/** What to draw, keyed by accessor the way the pin's `options.include` is, or `'*'` for everything the source
|
|
171
171
|
* offers. A path that names a folder in the source covers its members. */
|
|
172
172
|
data: z.union([z.literal("*"), z.record(z.string(), copyPaths)]),
|
|
173
173
|
/** What to do at a path another linked system provides: `'take'` makes it follow this source,
|
|
@@ -184,28 +184,28 @@ const linkInput = z.object({
|
|
|
184
184
|
replace: z.record(z.string(), z.record(z.string().min(1), z.string().min(1))).optional()
|
|
185
185
|
});
|
|
186
186
|
const unlinkInput = z.object({
|
|
187
|
-
path: pathInput("
|
|
187
|
+
path: pathInput("source"),
|
|
188
188
|
/** What to stop drawing, in `link`'s shape; everything when omitted. */
|
|
189
189
|
data: z.union([z.literal("*"), z.record(z.string(), copyPaths)]).optional()
|
|
190
190
|
});
|
|
191
191
|
const excludeInput = z.object({
|
|
192
|
-
path: pathInput("
|
|
193
|
-
/** What to leave out, keyed by accessor the way the pin's `
|
|
192
|
+
path: pathInput("source"),
|
|
193
|
+
/** What to leave out, keyed by accessor the way the pin's `options.include` is: the source's paths, where a
|
|
194
194
|
* folder leaves out its members. */
|
|
195
195
|
data: z.record(z.string(), z.array(z.string().min(1)).min(1))
|
|
196
196
|
});
|
|
197
197
|
const breakInput = z.object({
|
|
198
|
-
path: pathInput("
|
|
198
|
+
path: pathInput("source"),
|
|
199
199
|
/** Whether every value drawn through the pin becomes this config's own first. */
|
|
200
200
|
keep: z.boolean()
|
|
201
201
|
});
|
|
202
202
|
const breakPlanInput = z.object({
|
|
203
|
-
path: pathInput("
|
|
203
|
+
path: pathInput("source"),
|
|
204
204
|
keep: z.boolean().optional(),
|
|
205
205
|
/** One entity or folder detached through `copy` rather than the whole pin. */
|
|
206
206
|
data: z.union([z.literal("*"), z.record(z.string(), copyPaths)]).optional()
|
|
207
207
|
});
|
|
208
|
-
const rowsInput = z.object({ path: pathInput("
|
|
208
|
+
const rowsInput = z.object({ path: pathInput("source") });
|
|
209
209
|
/** The parsed op input as the plan takes it. */
|
|
210
210
|
function copyInputOf(input) {
|
|
211
211
|
return {
|
|
@@ -286,26 +286,88 @@ function exampleBorrowable(config, slug) {
|
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
|
|
289
|
+
/**
|
|
290
|
+
* What this system draws from that source — a standing declaration, and the thing the build turns
|
|
291
|
+
* into rows.
|
|
292
|
+
* ```ts
|
|
293
|
+
* include: '*' // everything, every kind
|
|
294
|
+
* include: { tokens: '*', icons: '*' } // those kinds whole
|
|
295
|
+
* include: { tokens: ['color/brand', 'color/paper'] } // those entities
|
|
296
|
+
* include: { components: ['actions'] } // a folder: its members
|
|
297
|
+
* include: { '*': '*', modifiers: ['*', '!text'] } // everything but one folder
|
|
298
|
+
* ```
|
|
299
|
+
* `Config.withDerivedRows` reads it and makes a pointer row per entity it covers — on every build,
|
|
300
|
+
* and inside the apply of any patch to this pin — so a link's cost in authored source is this one
|
|
301
|
+
* declaration whatever the source's size, and the rows come and go with it.
|
|
302
|
+
*
|
|
303
|
+
* Keyed by accessor (`tokens`, `components`) rather than by kind (`token`, `component`), because
|
|
304
|
+
* this is read in a config file, and a config file is keyed by accessor everywhere else —
|
|
305
|
+
* `register({ tokens, components, sources })`. Ops and refs use the kind.
|
|
306
|
+
* `Config.accessorOf` maps between them, off the config type's own manifest, so no kind is named
|
|
307
|
+
* here. Paths are the source's own; a path that names a folder there covers its members.
|
|
308
|
+
*
|
|
309
|
+
* **Standing, so a source that grows is covered without re-running anything.** The declaration is
|
|
310
|
+
* read on every build, and what it produces is an ordinary stored row — indistinguishable from a
|
|
311
|
+
* borrow written by hand, which is what keeps the rename gate, `inlineAllSources` when it seals an
|
|
312
|
+
* artifact and `emitBorrowedComponents` when it emits a module all working unchanged.
|
|
313
|
+
*
|
|
314
|
+
* A path this config already holds is left alone, silently, whether it authored that row or
|
|
315
|
+
* borrowed it. Local shadows a source, and that is what makes deriving over a grown source
|
|
316
|
+
* additive rather than a set of conflicts to resolve. It is also how one of their entities is kept
|
|
317
|
+
* out: author your own at that path, or narrow what this declares.
|
|
318
|
+
*
|
|
319
|
+
* Deleting a row this covers is refused ({@link EntityKind.bulkAdopts} is what reads it): the
|
|
320
|
+
* build would make it again on the next pass, and a delete that comes back is worse than one that
|
|
321
|
+
* was refused. To own one of their entities, `copy` it; to stop drawing it, `unlink` it.
|
|
322
|
+
*
|
|
323
|
+
* The gestures that write this are the kind's own ops — `link`, `unlink`, `exclude`, `break` —
|
|
324
|
+
* each with a `-plan` read beside it, so a surface never assembles the declaration by hand.
|
|
325
|
+
*
|
|
326
|
+
* `'*'` means every kind that may be drawn on, which is every kind that may be borrowed — each
|
|
327
|
+
* kind says which it is (`EntityKind.linkable`). Nothing is subtracted: a pin and a `file` aren't
|
|
328
|
+
* borrowable, so no borrow of one exists for this to cover.
|
|
329
|
+
*
|
|
330
|
+
* **Leaving part of a kind out.** A record's `'*'` key stands for every accessor it doesn't name,
|
|
331
|
+
* and a list entry `'*'` for every path, so everything but one folder is spelled
|
|
332
|
+
* ```ts
|
|
333
|
+
* include: { '*': '*', modifiers: ['*', '!text'] }
|
|
334
|
+
* ```
|
|
335
|
+
* A `!` entry leaves that path out, or a folder's members, whatever else in the list reaches it.
|
|
336
|
+
* Unlike a path a list doesn't name, an excluded path derives no row however the link reaches it —
|
|
337
|
+
* a linked token whose override is under a `text` modifier names that modifier, and it still
|
|
338
|
+
* stays out — so the name is free for this config to author, and the source's entity stays
|
|
339
|
+
* reachable qualified. A token's overrides under an excluded modifier are left out of the build
|
|
340
|
+
* rather than refused (`unstatableConditions`), which is what a consumer without one of the
|
|
341
|
+
* source's mode axes means. A linked component's rule keyed on one still reaches the source's
|
|
342
|
+
* modifier, as a rule on any modifier the link doesn't take does. See `covers` and `excludes`.
|
|
343
|
+
*
|
|
344
|
+
* Exclusions win wherever they sit, so `['!text', '*']` is `['*', '!text']`, and a list of them
|
|
345
|
+
* alone (`['!text']`) takes nothing by name and still keeps `text` out. An `options` entry at an
|
|
346
|
+
* excluded path is refused (an invariant), since no row derives there for it to adjust. `exclude`
|
|
347
|
+
* writes one (and drops such entries with it), and `link` lifts one over what it takes. `unlink`
|
|
348
|
+
* keeps them and writes none, because a `!` also drops the overrides under the path, which
|
|
349
|
+
* unlinking never has.
|
|
350
|
+
*
|
|
351
|
+
* No entity path can be misread here: `entityPathProblem` refuses a segment that starts with `!`,
|
|
352
|
+
* a segment that is `*`, and an empty segment, wherever a path becomes an identity.
|
|
353
|
+
*/
|
|
354
|
+
const linkDeclarationSchema = z.union([z.literal("*"), z.record(z.string(), z.union([z.literal("*"), z.array(z.string().min(1)).min(1)]))]).describe("What this system draws from the source, standing: `'*'` for everything, or a record by kind (`'*'` keys every kind it doesn't name). A list's `'!path'` entry leaves that path out.");
|
|
355
|
+
const pinOptions = z.object({ include: linkDeclarationSchema.optional() }).catchall(z.record(z.string(), z.strictObject({
|
|
290
356
|
override: z.union([refSchema, z.record(z.string(), z.unknown())]).optional(),
|
|
291
357
|
extend: z.record(z.string(), z.unknown()).optional(),
|
|
292
358
|
hidden: z.boolean().optional()
|
|
293
|
-
}).refine((entry) => entry.override !== void 0 || entry.extend !== void 0 || entry.hidden !== void 0, { message: "An `options` entry needs `override`, `extend` or `hidden`." }))).optional().describe("
|
|
294
|
-
/**
|
|
295
|
-
|
|
296
|
-
* `options.include`, beside the directives, and stored as `link`; `link` is still taken in a body.
|
|
297
|
-
* `include` sits among `options`' accessor keys, and no config type registers an accessor called
|
|
298
|
-
* `include`.
|
|
299
|
-
*/
|
|
300
|
-
const SOURCE_AUTHORED_AT = { link: "options.include" };
|
|
359
|
+
}).refine((entry) => entry.override !== void 0 || entry.extend !== void 0 || entry.hidden !== void 0, { message: "An `options` entry needs `override`, `extend` or `hidden`." }))).optional().describe("What the system includes from the source (`include`), and per-entity adjustments, keyed by accessor, then path, then verb.");
|
|
360
|
+
/** `link` is the spelling `options.include` had, still taken in a body and an op's data. */
|
|
361
|
+
const SOURCE_RETIRED_FIELDS = { link: "options.include" };
|
|
301
362
|
const LinkedSystemDefinition = defineEntity({
|
|
302
|
-
kind: "
|
|
303
|
-
label: "
|
|
304
|
-
labelPlural: "
|
|
363
|
+
kind: "source",
|
|
364
|
+
label: "Source",
|
|
365
|
+
labelPlural: "Sources",
|
|
305
366
|
entityName: "Source",
|
|
306
|
-
|
|
367
|
+
retiredKinds: ["linked-system"],
|
|
368
|
+
retiredFields: SOURCE_RETIRED_FIELDS,
|
|
307
369
|
invariants: (config) => [
|
|
308
|
-
...config.list("
|
|
370
|
+
...config.list("source").filter(({ path }) => !isLinkSlug(path)).map(({ path }) => `Link "${path}": ${LINK_SLUG_MESSAGE}`),
|
|
309
371
|
...linkRedirects(config).filter((redirect) => redirect.problem !== void 0 && redirect.problem !== "missing").map(redirectSentence),
|
|
310
372
|
...excludedDirectives(config)
|
|
311
373
|
],
|
|
@@ -320,7 +382,7 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
320
382
|
rename: { example: renameExample },
|
|
321
383
|
"rename-plan": { example: renameExample },
|
|
322
384
|
/**
|
|
323
|
-
* Draw entities from a linked system: the pin's `
|
|
385
|
+
* Draw entities from a linked system: the pin's `options.include` declaration grows to cover them and the
|
|
324
386
|
* build mints a pointer row per entity, in this one op. A row of this config's own at a covered
|
|
325
387
|
* path is deleted so theirs shows through; a row held through another pin becomes an extension
|
|
326
388
|
* through this one when `onLinked` is `'take'`, and the other pin's `options` entry there goes with
|
|
@@ -330,7 +392,7 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
330
392
|
input: linkInput,
|
|
331
393
|
readOnly: false,
|
|
332
394
|
label: "Link from",
|
|
333
|
-
description: "Draw entities from a linked system, following the source: `data` names them by accessor — `{ tokens: ['color/brand', 'color'] }` takes an entity and a folder's members, `{ tokens: '*' }` every token, and `'*'` the whole system. What this config already holds at those paths is replaced by theirs, so run `
|
|
395
|
+
description: "Draw entities from a linked system, following the source: `data` names them by accessor — `{ tokens: ['color/brand', 'color'] }` takes an entity and a folder's members, `{ tokens: '*' }` every token, and `'*'` the whole system. What this config already holds at those paths is replaced by theirs, so run `source/link-plan` with the same input first to see what that is. To replace something this config holds under another name (the `SelectContent` it has with the source's `SelectMenu`), name the pair in `replace` (`{ components: { SelectContent: 'SelectMenu' } }`): every reference to the old name moves to the new one, in design files and code too. To hold their values as your own instead, `copy`.",
|
|
334
396
|
scope: "item",
|
|
335
397
|
approval: "reference-change",
|
|
336
398
|
title: (entity) => `Link something from ${entity}`,
|
|
@@ -411,7 +473,7 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
411
473
|
}
|
|
412
474
|
},
|
|
413
475
|
/**
|
|
414
|
-
* Leave part of a linked system out for good: a `!` entry per path in the pin's `
|
|
476
|
+
* Leave part of a linked system out for good: a `!` entry per path in the pin's `options.include`. Unlike
|
|
415
477
|
* `unlink`, nothing derives there however the link reaches it, and the linked tokens' overrides
|
|
416
478
|
* under an excluded modifier are left out of the build. `link` with the same path lifts it.
|
|
417
479
|
*/
|
|
@@ -457,7 +519,7 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
457
519
|
input: breakInput,
|
|
458
520
|
readOnly: false,
|
|
459
521
|
label: "Break link",
|
|
460
|
-
description: "Remove a linked system. With `keep: true` every value drawn through it is copied in as your own first, and a row of yours that pointed through the pin points at the copies; with `keep: false` the rows it minted go, and a row of yours still pointing through it refuses the break. Run `
|
|
522
|
+
description: "Remove a linked system. With `keep: true` every value drawn through it is copied in as your own first, and a row of yours that pointed through the pin points at the copies; with `keep: false` the rows it minted go, and a row of yours still pointing through it refuses the break. Run `source/break-plan` first to see every row it reaches.",
|
|
461
523
|
scope: "item",
|
|
462
524
|
approval: "destructive",
|
|
463
525
|
title: (entity) => `Break the link to ${entity}`,
|
|
@@ -528,7 +590,7 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
528
590
|
* `extend` laid over the source's body. A folder's meta comes with its members, so a label the
|
|
529
591
|
* folder was inheriting becomes its own.
|
|
530
592
|
*
|
|
531
|
-
* `data` is keyed the way the pin's `
|
|
593
|
+
* `data` is keyed the way the pin's `options.include` is: by accessor, then `'*'` for every entry of the kind
|
|
532
594
|
* or the source's paths — an item, or a folder, which takes its members. `'*'` alone takes every
|
|
533
595
|
* kind the source offers and this config can hold. Kinds taken in one edit are copied together,
|
|
534
596
|
* which is what lets a copied component point at the copied tokens rather than back through the
|
|
@@ -541,7 +603,7 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
541
603
|
input: copyInput,
|
|
542
604
|
readOnly: false,
|
|
543
605
|
label: "Copy from",
|
|
544
|
-
description: "Take entities from a linked system as your own, holding the values the source has now and no longer following it. `data` names them by accessor: `{ tokens: ['color/brand', 'color'] }` takes an entity and a folder's members, `{ tokens: '*' }` every token, and `'*'` the whole system. What a copied entity points at comes with it, so run `
|
|
606
|
+
description: "Take entities from a linked system as your own, holding the values the source has now and no longer following it. `data` names them by accessor: `{ tokens: ['color/brand', 'color'] }` takes an entity and a folder's members, `{ tokens: '*' }` every token, and `'*'` the whole system. What a copied entity points at comes with it, so run `source/copy-plan` with the same input first and see everything that lands. To use theirs without owning it, declare it in the pin's `options.include` instead. A whole-system copy is thousands of rows, and on a repo-backed system each one is written into `uds.config.ts`.",
|
|
545
607
|
scope: "item",
|
|
546
608
|
approval: "reference-change",
|
|
547
609
|
title: (entity) => `Copy something from ${entity}`,
|
|
@@ -590,9 +652,9 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
590
652
|
* rather than a silent wrong answer.
|
|
591
653
|
*
|
|
592
654
|
* ```ts
|
|
593
|
-
*
|
|
655
|
+
* sources: {
|
|
594
656
|
* ds: '../design-system/uds.config.ts', // repo-local
|
|
595
|
-
* yahooOs:
|
|
657
|
+
* yahooOs: Source.item({ systemId, name, version }), // published
|
|
596
658
|
* }
|
|
597
659
|
* ```
|
|
598
660
|
*
|
|
@@ -612,72 +674,6 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
612
674
|
*/
|
|
613
675
|
configPath: z.string().min(1).optional().describe("The sibling config this link reads, as a path to its `uds.config.ts`. Wins for resolution when set."),
|
|
614
676
|
/**
|
|
615
|
-
* What this system draws from that source — a standing declaration, and the thing the build turns
|
|
616
|
-
* into rows.
|
|
617
|
-
* ```ts
|
|
618
|
-
* link: '*' // everything, every kind
|
|
619
|
-
* link: { tokens: '*', icons: '*' } // those kinds whole
|
|
620
|
-
* link: { tokens: ['color/brand', 'color/paper'] } // those entities
|
|
621
|
-
* link: { components: ['actions'] } // a folder: its members
|
|
622
|
-
* link: { '*': '*', modifiers: ['*', '!text'] } // everything but one folder
|
|
623
|
-
* ```
|
|
624
|
-
* `Config.withDerivedRows` reads it and makes a pointer row per entity it covers — on every build,
|
|
625
|
-
* and inside the apply of any patch to this pin — so a link's cost in authored source is this one
|
|
626
|
-
* declaration whatever the source's size, and the rows come and go with it.
|
|
627
|
-
*
|
|
628
|
-
* Keyed by accessor (`tokens`, `components`) rather than by kind (`token`, `component`), because
|
|
629
|
-
* this is read in a config file, and a config file is keyed by accessor everywhere else —
|
|
630
|
-
* `register({ tokens, components })`, `sources: { linkedSystems: … }`. Ops and refs use the kind.
|
|
631
|
-
* `Config.accessorOf` maps between them, off the config type's own manifest, so no kind is named
|
|
632
|
-
* here. Paths are the source's own; a path that names a folder there covers its members.
|
|
633
|
-
*
|
|
634
|
-
* **Standing, so a source that grows is covered without re-running anything.** The declaration is
|
|
635
|
-
* read on every build, and what it produces is an ordinary stored row — indistinguishable from a
|
|
636
|
-
* borrow written by hand, which is what keeps the rename gate, `inlineAllSources` when it seals an
|
|
637
|
-
* artifact and `emitBorrowedComponents` when it emits a module all working unchanged.
|
|
638
|
-
*
|
|
639
|
-
* A path this config already holds is left alone, silently, whether it authored that row or
|
|
640
|
-
* borrowed it. Local shadows a source, and that is what makes deriving over a grown source
|
|
641
|
-
* additive rather than a set of conflicts to resolve. It is also how one of their entities is kept
|
|
642
|
-
* out: author your own at that path, or narrow what this declares.
|
|
643
|
-
*
|
|
644
|
-
* Deleting a row this covers is refused ({@link EntityKind.bulkAdopts} is what reads it): the
|
|
645
|
-
* build would make it again on the next pass, and a delete that comes back is worse than one that
|
|
646
|
-
* was refused. To own one of their entities, `copy` it; to stop drawing it, `unlink` it.
|
|
647
|
-
*
|
|
648
|
-
* The gestures that write this are the kind's own ops — `link`, `unlink`, `exclude`, `break` —
|
|
649
|
-
* each with a `-plan` read beside it, so a surface never assembles the declaration by hand.
|
|
650
|
-
*
|
|
651
|
-
* `'*'` means every kind that may be drawn on, which is every kind that may be borrowed — each
|
|
652
|
-
* kind says which it is (`EntityKind.linkable`). Nothing is subtracted: a pin and a `file` aren't
|
|
653
|
-
* borrowable, so no borrow of one exists for this to cover.
|
|
654
|
-
*
|
|
655
|
-
* **Leaving part of a kind out.** A record's `'*'` key stands for every accessor it doesn't name,
|
|
656
|
-
* and a list entry `'*'` for every path, so everything but one folder is spelled
|
|
657
|
-
* ```ts
|
|
658
|
-
* link: { '*': '*', modifiers: ['*', '!text'] }
|
|
659
|
-
* ```
|
|
660
|
-
* A `!` entry leaves that path out, or a folder's members, whatever else in the list reaches it.
|
|
661
|
-
* Unlike a path a list doesn't name, an excluded path derives no row however the link reaches it —
|
|
662
|
-
* a linked token whose override is under a `text` modifier names that modifier, and it still
|
|
663
|
-
* stays out — so the name is free for this config to author, and the source's entity stays
|
|
664
|
-
* reachable qualified. A token's overrides under an excluded modifier are left out of the build
|
|
665
|
-
* rather than refused (`unstatableConditions`), which is what a consumer without one of the
|
|
666
|
-
* source's mode axes means. A linked component's rule keyed on one still reaches the source's
|
|
667
|
-
* modifier, as a rule on any modifier the link doesn't take does. See `covers` and `excludes`.
|
|
668
|
-
*
|
|
669
|
-
* Exclusions win wherever they sit, so `['!text', '*']` is `['*', '!text']`, and a list of them
|
|
670
|
-
* alone (`['!text']`) takes nothing by name and still keeps `text` out. An `options` entry at an
|
|
671
|
-
* excluded path is refused (an invariant), since no row derives there for it to adjust. `exclude`
|
|
672
|
-
* writes one (and drops such entries with it), and `link` lifts one over what it takes. `unlink`
|
|
673
|
-
* keeps them and writes none, because a `!` also drops the overrides under the path, which
|
|
674
|
-
* unlinking never has.
|
|
675
|
-
*
|
|
676
|
-
* No entity path can be misread here: `entityPathProblem` refuses a segment that starts with `!`,
|
|
677
|
-
* a segment that is `*`, and an empty segment, wherever a path becomes an identity.
|
|
678
|
-
*/
|
|
679
|
-
link: z.union([z.literal("*"), z.record(z.string(), z.union([z.literal("*"), z.array(z.string().min(1)).min(1)]))]).optional().describe("What this system draws from the source, standing: `'*'` for everything, or a record by kind (`'*'` keys every kind it doesn't name). A list's `'!path'` entry leaves that path out."),
|
|
680
|
-
/**
|
|
681
677
|
* What this system does to individual entities of the source, keyed by accessor, then by the path
|
|
682
678
|
* the source spells, then by verb.
|
|
683
679
|
*
|
|
@@ -720,6 +716,11 @@ const LinkedSystemDefinition = defineEntity({
|
|
|
720
716
|
*/
|
|
721
717
|
options: pinOptions,
|
|
722
718
|
/**
|
|
719
|
+
* The spelling `options.include` had. Still typed for a body written that way, and moved to
|
|
720
|
+
* `options.include` wherever one is written (`EntityKind.retiredFields`), so it's never stored.
|
|
721
|
+
*/
|
|
722
|
+
link: linkDeclarationSchema.optional().meta({ deprecated: true }).describe("Deprecated: what the source includes is `options.include`."),
|
|
723
|
+
/**
|
|
723
724
|
* An npm package that ships a built system — `@acme/design-system`.
|
|
724
725
|
*
|
|
725
726
|
* The third origin, and the one a consumer outside the publisher's monorepo and off their Create
|
|
@@ -830,7 +831,7 @@ displayName: ({ member, path }) => typeof member.name === "string" && member.nam
|
|
|
830
831
|
unavailable: sourceUnavailable
|
|
831
832
|
},
|
|
832
833
|
/**
|
|
833
|
-
* Whether this pin's `
|
|
834
|
+
* Whether this pin's `options.include` covers one of the source's entities — the derive pass's
|
|
834
835
|
* question and the delete gate's, answered here because `link` is this kind's field and its shape
|
|
835
836
|
* is this kind's to interpret.
|
|
836
837
|
*
|
|
@@ -841,13 +842,13 @@ displayName: ({ member, path }) => typeof member.name === "string" && member.nam
|
|
|
841
842
|
* (`EntityKind.linkable`), so the claim is unreachable rather than filtered.
|
|
842
843
|
*/
|
|
843
844
|
bulkAdopts: ({ body, kind, accessor, path }) => covers({
|
|
844
|
-
declared: body
|
|
845
|
+
declared: includeOf(body),
|
|
845
846
|
accessor: accessor ?? kind,
|
|
846
847
|
path
|
|
847
848
|
}),
|
|
848
849
|
sourceType: (body) => body.type === "hybrid" ? "hybrid" : "linked",
|
|
849
850
|
bulkExcludes: ({ body, kind, accessor, path }) => excludes({
|
|
850
|
-
declared: body
|
|
851
|
+
declared: includeOf(body),
|
|
851
852
|
accessor: accessor ?? kind,
|
|
852
853
|
path
|
|
853
854
|
}),
|
|
@@ -864,14 +865,10 @@ displayName: ({ member, path }) => typeof member.name === "string" && member.nam
|
|
|
864
865
|
* The field-path address `options` stores one entry at — accessor, then the path the source
|
|
865
866
|
* spells, so an edit to a minted row lands on the same key {@link directiveAt} reads back.
|
|
866
867
|
*/
|
|
867
|
-
bulkDirectives: (body) => {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
accessor,
|
|
872
|
-
path
|
|
873
|
-
})) : []);
|
|
874
|
-
},
|
|
868
|
+
bulkDirectives: (body) => directivesOf(body).flatMap(([accessor, entries]) => isPlainObject(entries) ? Object.keys(entries).map((path) => ({
|
|
869
|
+
accessor,
|
|
870
|
+
path
|
|
871
|
+
})) : []),
|
|
875
872
|
bulkOverlayWrite: ({ accessor, path, overlay }) => ({ [`options.${accessor}.${path}`]: overlay })
|
|
876
873
|
});
|
|
877
874
|
/** An `override` or `extend` body with its `styles` as a list, in the stored form: the record keyed by
|
|
@@ -888,7 +885,7 @@ function storedPinBody(body) {
|
|
|
888
885
|
function storedPinOptions(options) {
|
|
889
886
|
const stored = {};
|
|
890
887
|
for (const [accessor, entries] of Object.entries(options)) {
|
|
891
|
-
if (!isPlainObject(entries)) {
|
|
888
|
+
if (accessor === "include" || !isPlainObject(entries)) {
|
|
892
889
|
stored[accessor] = entries;
|
|
893
890
|
continue;
|
|
894
891
|
}
|
|
@@ -909,9 +906,9 @@ function storedPinOptions(options) {
|
|
|
909
906
|
}
|
|
910
907
|
function sourceItem(def) {
|
|
911
908
|
if (typeof def !== "object" || def === null || isRef(def)) return def;
|
|
912
|
-
const body =
|
|
909
|
+
const body = foldRetiredFields({
|
|
913
910
|
body: def,
|
|
914
|
-
|
|
911
|
+
retired: SOURCE_RETIRED_FIELDS
|
|
915
912
|
});
|
|
916
913
|
if (!isPlainObject(body.options)) return body;
|
|
917
914
|
return {
|
|
@@ -928,14 +925,14 @@ const Source = Object.assign(LinkedSystemDefinition, { item: sourceItem });
|
|
|
928
925
|
const LinkedSystem = Source;
|
|
929
926
|
/** Each `options` entry at a path its pin's `link` excludes, which derives no row for it to adjust. */
|
|
930
927
|
function excludedDirectives(config) {
|
|
931
|
-
return config.list("
|
|
932
|
-
const body = config.storedBody("
|
|
933
|
-
|
|
934
|
-
return
|
|
935
|
-
declared
|
|
928
|
+
return config.list("source").flatMap(({ path: slug }) => {
|
|
929
|
+
const body = config.storedBody("source", slug);
|
|
930
|
+
const declared = includeOf(body);
|
|
931
|
+
return directivesOf(body).flatMap(([accessor, entries]) => isPlainObject(entries) ? Object.keys(entries).filter((path) => excludes({
|
|
932
|
+
declared,
|
|
936
933
|
accessor,
|
|
937
934
|
path
|
|
938
|
-
})).map((path) => `Link "${slug}": options.${accessor}["${path}"] adjusts a path its \`
|
|
935
|
+
})).map((path) => `Link "${slug}": options.${accessor}["${path}"] adjusts a path its \`options.include\` excludes, which derives no row. Drop the entry, or the exclusion.`) : []);
|
|
939
936
|
});
|
|
940
937
|
}
|
|
941
938
|
/** The `options` entry for one path, or `undefined` where the pin says nothing about it. */
|
|
@@ -961,7 +958,7 @@ function directiveAt(body, accessor, path) {
|
|
|
961
958
|
*/
|
|
962
959
|
function sourceOfItem({ config, kind, path }) {
|
|
963
960
|
const slug = config.resolve(kind, path)?.source;
|
|
964
|
-
return slug === void 0 ? void 0 :
|
|
961
|
+
return slug === void 0 ? void 0 : Source.get(config, slug);
|
|
965
962
|
}
|
|
966
963
|
/**
|
|
967
964
|
* The source a group draws through — set only when every member agrees on one.
|
|
@@ -975,7 +972,7 @@ function sourceOfGroup({ config, kind, groupPath }) {
|
|
|
975
972
|
kind,
|
|
976
973
|
groupPath
|
|
977
974
|
});
|
|
978
|
-
return slug === void 0 ? void 0 :
|
|
975
|
+
return slug === void 0 ? void 0 : Source.get(config, slug);
|
|
979
976
|
}
|
|
980
977
|
/**
|
|
981
978
|
* The source an item is — `undefined` for one this config authored, including one whose own fields
|
|
@@ -991,7 +988,7 @@ function sourceOfGroup({ config, kind, groupPath }) {
|
|
|
991
988
|
*/
|
|
992
989
|
function borrowedItem({ config, kind, path }) {
|
|
993
990
|
const slug = config.resolve(kind, path)?.borrowedFrom;
|
|
994
|
-
return slug === void 0 ? void 0 :
|
|
991
|
+
return slug === void 0 ? void 0 : Source.get(config, slug);
|
|
995
992
|
}
|
|
996
993
|
/** The source a whole group is borrowed from — {@link borrowedItem}'s group form, and the same second
|
|
997
994
|
* hop {@link sourceOfGroup} makes. Set only when every member agrees, which is `Config`'s rule to
|
|
@@ -1001,7 +998,7 @@ function borrowedGroup({ config, kind, groupPath }) {
|
|
|
1001
998
|
kind,
|
|
1002
999
|
groupPath
|
|
1003
1000
|
});
|
|
1004
|
-
return slug === void 0 ? void 0 :
|
|
1001
|
+
return slug === void 0 ? void 0 : Source.get(config, slug);
|
|
1005
1002
|
}
|
|
1006
1003
|
/**
|
|
1007
1004
|
* A config path as a source is indexed by — separators normalized and a leading `./` dropped, so
|
|
@@ -1018,13 +1015,13 @@ const configPathKey = (value) => value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
|
1018
1015
|
* Takes either way a source can be named, because the same system reached two ways is the same system:
|
|
1019
1016
|
* a form offering to draw on one that is already a source should say so and name the slug it lives
|
|
1020
1017
|
* under, rather than offering a second declaration under another name. Which fields those are is this
|
|
1021
|
-
* kind's to know ({@link
|
|
1018
|
+
* kind's to know ({@link Source.sourceIdentity}); a caller that indexed them itself would be
|
|
1022
1019
|
* restating the schema.
|
|
1023
1020
|
*/
|
|
1024
1021
|
function sourceSlugFor({ config, configPath, systemId }) {
|
|
1025
1022
|
if (!config) return void 0;
|
|
1026
1023
|
const wanted = configPath ? configPathKey(configPath) : void 0;
|
|
1027
|
-
for (const entry of
|
|
1024
|
+
for (const entry of Source.list(config)) {
|
|
1028
1025
|
if (wanted !== void 0 && entry.configPath !== void 0 && configPathKey(entry.configPath) === wanted) return entry.path;
|
|
1029
1026
|
if (systemId && entry.systemId === systemId) return entry.path;
|
|
1030
1027
|
}
|
|
@@ -1052,7 +1049,7 @@ function suggestLinkSlug({ name, taken }) {
|
|
|
1052
1049
|
function linkRedirects(config) {
|
|
1053
1050
|
const kindOfAccessor = (accessor) => config.accessors()[accessor]?.kind ?? accessor;
|
|
1054
1051
|
const declared = [];
|
|
1055
|
-
for (const link of config.list("
|
|
1052
|
+
for (const link of config.list("source")) {
|
|
1056
1053
|
const { options } = link.toJSON();
|
|
1057
1054
|
for (const [accessor, entries] of Object.entries(options ?? {})) for (const [path, entry] of Object.entries(entries ?? {})) {
|
|
1058
1055
|
const override = isPlainObject(entry) ? entry.override : void 0;
|