@yahoo/uds-create-config 5.63.0 → 5.64.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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Ref } from "../../framework/utils/refs.js";
|
|
2
2
|
import { SourceResolver, SourceState } from "../../framework/sources.js";
|
|
3
3
|
import { ComputedInput } from "../../framework/registry.js";
|
|
4
|
-
import { RegisteredComponentContracts, RegisteredEntities } from "../../framework/registered.js";
|
|
4
|
+
import { RegisteredComponentContracts, RegisteredEntities, RegisteredGroupPaths } from "../../framework/registered.js";
|
|
5
5
|
import { EntityClass, ItemOf } from "../../framework/defineEntity.js";
|
|
6
|
-
import { PartialBodyOf } from "../../framework/defineConfig.js";
|
|
6
|
+
import { PartialBodyOf, PartialGroupBodyOf } from "../../framework/defineConfig.js";
|
|
7
7
|
import { Named } from "../../framework/named.js";
|
|
8
8
|
import { LayerMap, StyleRuleInput } from "./defineComponent.js";
|
|
9
9
|
import { ContractStyleRules } from "./Component.js";
|
|
@@ -248,19 +248,39 @@ type PinOptions = { [A in keyof RegisteredEntities]?: Record<string, PinAdjustme
|
|
|
248
248
|
/**
|
|
249
249
|
* {@link PinOptions} as `LinkedSystem.item` takes it: a component entry's `override` and `extend` also
|
|
250
250
|
* take their `styles` as the rule list `defineComponent.styles` takes (`[{ when?, layers }]`), which
|
|
251
|
-
* the item stores as the record.
|
|
251
|
+
* the item stores as the record, and an entry at a group path takes the kind's group fields.
|
|
252
252
|
*
|
|
253
|
-
* `K` is the
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
253
|
+
* `K` is the paths the entries name, inferred at the call, which is what lets each entry be checked
|
|
254
|
+
* against its own path: an index signature would type every path alike. A rule's layers come from the
|
|
255
|
+
* contract `uds-env.d.ts` registers for that path (`Badge@yos`), and a group is a path it registers
|
|
256
|
+
* among `RegisteredGroupPaths`. Both stay open where nothing is registered yet, as a config that has
|
|
257
|
+
* not built keeps the open record.
|
|
257
258
|
*
|
|
258
259
|
* OPEN: the item does not know the slug it is declared under, so a path is matched against a contract
|
|
259
|
-
* of that name from any source, and one registered by several is held to any one of theirs.
|
|
260
|
+
* or a group of that name from any source, and one registered by several is held to any one of theirs.
|
|
261
|
+
*
|
|
262
|
+
* OPEN: an item field at a group path still type-checks when the whole call also fits `item`'s
|
|
263
|
+
* overload for the stored body, whose {@link PinOptions} types every path as an item. A call with a
|
|
264
|
+
* rule-list `styles` doesn't fit it, so there the field is refused.
|
|
260
265
|
*/
|
|
261
266
|
type PinOptionsInput<K extends string = string> = { [A in keyof RegisteredEntities]?: RegisteredEntities[A] extends {
|
|
262
267
|
readonly kind: 'component';
|
|
263
|
-
} ? { [P in K]?: PinComponentAdjustment<RegisteredEntities[A], P
|
|
268
|
+
} ? { [P in K]?: PinPathAdjustment<RegisteredEntities[A], P, PinComponentAdjustment<RegisteredEntities[A], P>> } : { [P in K]?: PinPathAdjustment<RegisteredEntities[A], P, PinAdjustment<RegisteredEntities[A]>> } };
|
|
269
|
+
/** The entry for one path of `E`'s kind: the group fields where `P` is a registered group, else
|
|
270
|
+
* `Item`. A path is one or the other, never both. */
|
|
271
|
+
type PinPathAdjustment<E, P extends string, Item> = string extends P ? Item : [RegisteredGroupOf<E, P>] extends [never] ? Item : PinGroupAdjustment<E>;
|
|
272
|
+
/** The group paths registered for `E`'s kind that `P` names, as this config spells it or as a source
|
|
273
|
+
* does (`spectrum@yos`). */
|
|
274
|
+
type RegisteredGroupOf<E, P extends string> = E extends {
|
|
275
|
+
readonly kind: infer Kind extends keyof RegisteredGroupPaths;
|
|
276
|
+
} ? Extract<RegisteredGroupPaths[Kind], P | `${P}@${string}`> : never;
|
|
277
|
+
/** An entry at a group path. Its fields lay over the group's inherited ones, `override` and `extend`
|
|
278
|
+
* alike, so neither takes a ref. */
|
|
279
|
+
type PinGroupAdjustment<E> = {
|
|
280
|
+
override?: PartialGroupBodyOf<E>;
|
|
281
|
+
extend?: PartialGroupBodyOf<E>;
|
|
282
|
+
hidden?: boolean;
|
|
283
|
+
};
|
|
264
284
|
/** A ref to another entity of `E`'s kind, which re-points the path to it. */
|
|
265
285
|
type KindRefOf<E> = E extends {
|
|
266
286
|
readonly kind: infer K extends string;
|
|
@@ -45,6 +45,9 @@ type ConfigKind<C> = C extends {
|
|
|
45
45
|
*/
|
|
46
46
|
type Matched = any;
|
|
47
47
|
type PartialBodyOf<E> = E extends Omit<EntityClass<infer F extends FieldsSchema, infer _G extends FieldsSchema, infer _K, Matched, Matched, Matched>, 'ref'> ? DeepPartial<CreateInput<F>> : never;
|
|
48
|
+
/** One entity's group fields as a partial at every depth — what a delta against one of its group
|
|
49
|
+
* nodes may say. */
|
|
50
|
+
type PartialGroupBodyOf<E> = E extends Omit<EntityClass<infer _F extends FieldsSchema, infer G extends FieldsSchema, infer _K, Matched, Matched, Matched>, 'ref'> ? DeepPartial<CreateInput<G>> : never;
|
|
48
51
|
/** Optional at every depth, stopping at refs, arrays and primitives. */
|
|
49
52
|
type DeepPartial<T> = T extends Ref | readonly unknown[] ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
|
|
50
53
|
/**
|
|
@@ -196,4 +199,4 @@ declare function defineConfig<Owned extends EntityMap, Derived extends EntityMap
|
|
|
196
199
|
extendsBase?: boolean;
|
|
197
200
|
}): ConfigClass<Owned, Derived, Sources>;
|
|
198
201
|
//#endregion
|
|
199
|
-
export { Collection, ConfigClass, ConfigInstance, ConfigKind, EntityMap, OwnedRecords, PartialBodyOf, SourceMap, SourcesOf, defineConfig, kindsOf };
|
|
202
|
+
export { Collection, ConfigClass, ConfigInstance, ConfigKind, EntityMap, OwnedRecords, PartialBodyOf, PartialGroupBodyOf, SourceMap, SourcesOf, defineConfig, kindsOf };
|