foldkit-cms 0.1.2 → 0.3.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/index.d.mts CHANGED
@@ -2,24 +2,21 @@ import { Option, Pipeable, Schema } from "effect";
2
2
  import { AnyEntity, Entity, EntityField, EntityInput } from "foldkit-entity";
3
3
  import { MutationDescriptor, MutationStatus, OptimisticOperation, RemoteClient, RemoteData, RemoteMessage } from "foldkit-remote";
4
4
  import { Bundle } from "foldkit-bundle";
5
+ import * as ManagedResource from "foldkit/managedResource";
6
+ import "foldkit/message";
7
+ import * as Subscription from "foldkit/subscription";
5
8
  import * as Submodel from "foldkit/submodel";
9
+ import { DisplayWords } from "foldkit-crud";
6
10
  import { Control, Draft, Submitted } from "foldkit-form";
7
- import { Projection } from "foldkit-surface";
11
+ import { ActiveSurface, Projection } from "foldkit-surface";
8
12
  import { Command } from "foldkit/command";
13
+ import * as FieldValidation from "foldkit/fieldValidation";
9
14
  import * as Update from "foldkit/update";
10
- import * as ManagedResource from "foldkit/managedResource";
11
- import * as Subscription from "foldkit/subscription";
12
15
  import { CallableTaggedStruct } from "foldkit/schema";
13
16
  import { Attribute, Html, HtmlBuilder } from "foldkit/html";
14
17
  import "foldkit/url";
18
+ import { SlotView } from "foldkit-mixins";
15
19
  //#region src/lifecycle.d.ts
16
- /**
17
- * The lifecycle of a piece of content, derived. Nothing stores a status: a state
18
- * is a pure function of facts (is there a row, can a visitor see it, is there a
19
- * draft, has the entry been archived) and a clock, so it cannot disagree with
20
- * them. A scheduled publish that failed reads scheduled and overdue, which is
21
- * true, and not published, which would not be.
22
- */
23
20
  /** What is known of one entry. The server gathers it; nothing here reads a database. */
24
21
  interface Facts {
25
22
  /** When the entry was archived, if it was. */
@@ -55,7 +52,8 @@ interface State {
55
52
  readonly schedule: Schedule | null;
56
53
  }
57
54
  /** What an author may ask of an entry. Each is an operation the server runs after asking `allow`. */
58
- type Transition = 'save' | 'discard' | 'publish' | 'schedule' | 'unschedule' | 'unpublish' | 'archive' | 'unarchive' | 'restore';
55
+ declare const Transitions: Schema.Literals<readonly ["save", "discard", "publish", "schedule", "unschedule", "unpublish", "archive", "unarchive", "restore"]>;
56
+ type Transition = typeof Transitions.Type;
59
57
  //#endregion
60
58
  //#region src/editor.d.ts
61
59
  /** How the form came to hold what it holds. */
@@ -76,7 +74,12 @@ type EditorStatus = 'Closed' | 'Loading' | 'NotFound' | 'LoadFailed' |
76
74
  /** Edited since the last save. */
77
75
  'Editing' | 'Saving' | 'Saved' |
78
76
  /** Someone else saved or published in between. The author's text is still in the form. */
79
- 'Conflict' | 'SaveFailed' | 'Publishing' | 'Published' | 'PublishFailed' | 'Scheduling' |
77
+ 'Conflict' | 'SaveFailed' | 'Publishing' | 'Published' | 'PublishFailed' |
78
+ /**
79
+ * A publish or a schedule the form's own checks stopped before anything was
80
+ * sent: the fields that fail say why. Until the next edit.
81
+ */
82
+ 'Incomplete' | 'Scheduling' |
80
83
  /** Promised for later. The entry's `state` says for when, and whether it happened. */
81
84
  'Scheduled' | 'ScheduleFailed';
82
85
  /**
@@ -96,6 +99,11 @@ interface EditorModel<FormModel> {
96
99
  readonly saveWanted: boolean;
97
100
  readonly publishId: string | null;
98
101
  readonly publishWanted: boolean;
102
+ /**
103
+ * The last publish or schedule asked, as the form took it: waiting for a
104
+ * check still running, or stopped by one and not edited since; else idle.
105
+ */
106
+ readonly submit: 'idle' | 'waiting' | 'stopped';
99
107
  /** When the publish that is wanted, under way or last settled is a promise for later: for when. */
100
108
  readonly scheduleAt: string | null;
101
109
  /** The discard or unpublish in progress or last settled. */
@@ -131,7 +139,8 @@ type EditorOut = {
131
139
  readonly _tag: 'Overwrite';
132
140
  };
133
141
  /** The parts of a `Form.make` result the editor drives. */
134
- interface EditorForm<FormModel, FormMessage, Value> {
142
+ /** `Services` is what the form's Commands and Subscriptions require, which the editor's then do. */
143
+ interface EditorForm<FormModel, FormMessage, Value, Resources = {}, Services = never> {
135
144
  readonly name: string;
136
145
  readonly input: {
137
146
  readonly schema: Schema.Struct<any>;
@@ -139,7 +148,11 @@ interface EditorForm<FormModel, FormMessage, Value> {
139
148
  readonly bundle: {
140
149
  readonly Model: Schema.Codec<FormModel, unknown>;
141
150
  readonly Message: Schema.Codec<FormMessage, unknown>;
142
- readonly update: (model: FormModel, message: FormMessage, args: void) => Update.ReturnWithOutMessage<FormModel, FormMessage, Submitted<Value>, any>;
151
+ readonly update: (model: FormModel, message: FormMessage, args: void) => Update.ReturnWithOutMessage<FormModel, FormMessage, Submitted<Value>, Services>;
152
+ /** The Subscriptions of the form's controls backed by a Bundle, which the editor runs while open. */
153
+ readonly subscriptions?: (args: void) => Subscription.Subscriptions<FormModel, FormMessage, Services>;
154
+ /** Their Resources, which the editor holds while open. */
155
+ readonly resources?: (args: void) => Resources;
143
156
  };
144
157
  readonly Message: {
145
158
  readonly Submitted: () => FormMessage;
@@ -159,11 +172,18 @@ interface EditorForm<FormModel, FormMessage, Value> {
159
172
  readonly settled: (model: FormModel) => FormModel;
160
173
  /** What the form is editing; `{}` while it creates. See `Form.FormModel.subject`. */
161
174
  readonly subject: (model: FormModel) => Readonly<Record<string, string>>;
162
- readonly field: (model: FormModel, key: never) => {
163
- readonly _tag: string;
164
- readonly value: unknown;
165
- readonly errors?: ReadonlyArray<string>;
175
+ /**
176
+ * Whether a completed transition changed authored content (§45). The editor
177
+ * asks this instead of recognizing the form's Message tags, so a control it
178
+ * does not know about — a Bundle-backed one, a stateful one — autosaves the
179
+ * same way a text field does, and a blur or a refused edit does not.
180
+ */
181
+ authoredChanged(before: FormModel, after: FormModel): boolean;
182
+ /** Whether a check is still running, which a submit waits for. */
183
+ readonly engine: {
184
+ readonly isValidating: (model: FormModel) => boolean;
166
185
  };
186
+ readonly field: (model: FormModel, key: never) => FieldValidation.Field<unknown>;
167
187
  }
168
188
  /** The parts of a bound Remote domain the editor uses. */
169
189
  interface EditorDomain<Root> {
@@ -177,14 +197,13 @@ interface EditorDomain<Root> {
177
197
  refresh(model: Root, target: any): Root;
178
198
  overlay(model: Root, id: string, optimistic: ReadonlyArray<OptimisticOperation>): Root;
179
199
  lift(model: Root, id: string): Root;
180
- readonly contract: {
181
- readonly owner?: object | undefined;
182
- };
200
+ /** `Data.active`: a read of the domain as an active Surface of its application. */
201
+ active(name: string, projectionOf: (model: Root) => Option.Option<Projection<Root, any>>): ActiveSurface<Root>;
183
202
  }
184
- interface EditorContent<FormModel, FormMessage, Value> {
203
+ interface EditorContent<FormModel, FormMessage, Value, Resources = {}, Services = never> {
185
204
  readonly name: string;
186
205
  readonly entity: AnyEntity;
187
- readonly form: EditorForm<FormModel, FormMessage, Value>;
206
+ readonly form: EditorForm<FormModel, FormMessage, Value, Resources, Services>;
188
207
  readonly roles: {
189
208
  readonly label: {
190
209
  readonly key: string;
@@ -223,6 +242,123 @@ declare const EditorMessage: import("foldkit/message").MessageUnion<{
223
242
  }>;
224
243
  type EditorMessage = typeof EditorMessage.Type;
225
244
  //#endregion
245
+ //#region ../bundle/src/placed.d.ts
246
+ declare const PlacedTypeId: unique symbol;
247
+ /**
248
+ * Args for a placement: a static value, or a factory deriving them from the
249
+ * parent seed — the fields `assembly.initial(rest)` was given, before any
250
+ * placement initialised. A factory runs once per initialization and its result
251
+ * is retained for the placement's `init`, `update`, helpers, Subscriptions,
252
+ * and resources; it never re-runs against changing parent state, so keep it
253
+ * pure of its seed.
254
+ *
255
+ * When no initialization ran — a hand-built Model in a test, which never went
256
+ * through `initial` — `update` derives from the given parent per use, without
257
+ * retaining, so each Model is folded with its own seed.
258
+ *
259
+ * Read only seed fields (route, auth, workspace, ...), never sibling
260
+ * placement fields: every factory sees the same base seed, so a sibling read
261
+ * is consistently absent rather than order-dependent.
262
+ */
263
+ type ArgsSource<Seed, Args> = Args | ((seed: Seed) => Args);
264
+ interface PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed = Parent> {
265
+ /**
266
+ * The bundle's args: a static value, or a factory from the parent seed (the
267
+ * fields `assembly.initial(rest)` was given, minus this placement's own
268
+ * field). A factory is computed once per initialization and retained for
269
+ * `init`, `update`, and helpers. Subscriptions and resources built from it
270
+ * require `initial`/`config` to have run first; a bundle with neither
271
+ * contributes empty records either way.
272
+ */
273
+ readonly args?: ArgsSource<ParentSeed, Args>;
274
+ /** Handles the child's OutMessage in parent terms, with the child already written back. */
275
+ readonly onOut?: (outMessage: OutMessage, context: Update.FoldContext<Message, LinkMessage>) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
276
+ /**
277
+ * Observes each of the child's Messages in parent terms, after the child has
278
+ * handled it and its `onOut` has run, so the parent's own update needs no arm
279
+ * for the wrapper. Helpers are not Messages and do not reach it.
280
+ */
281
+ readonly onMessage?: (message: Message) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
282
+ /** Prefix for the placement's Subscription and resource keys. Defaults to `Name@path`. */
283
+ readonly key?: string;
284
+ /** A gate beside the Link's own: Subscriptions and resources run only while both hold. */
285
+ readonly when?: (parent: Parent) => boolean;
286
+ }
287
+ /** A lifted resource record: each child entry in parent terms, keyed by the placement. */
288
+ type PlacedResources<Parent, ParentMessage, Resources> = Readonly<Record<string, { readonly [K in keyof Resources]: Resources[K] extends ManagedResource.Entry<any, any, infer Requirements, infer Value, infer Service, infer OnAcquired extends (...args: ReadonlyArray<any>) => any> ? ManagedResource.Entry<Parent, ParentMessage, Requirements, Value, Service, (...args: Parameters<OnAcquired>) => ParentMessage> : never; }[keyof Resources]>>;
289
+ type PlacedHelpers<Parent, ParentMessage, R, Helpers> = { readonly [K in keyof Helpers]: Helpers[K] extends ((model: any, ...input: infer Input) => any) ? (...input: Input) => Update.Step<Parent, ParentMessage, R> : never; };
290
+ interface Placed<Name extends string, Parent, ParentMessage, Model, Message, R, S, ViewInputs, Resources, Helpers, Field extends string = string, Claimed extends string = string> {
291
+ readonly [PlacedTypeId]: typeof PlacedTypeId;
292
+ /** Types only: the top-level Model field this placement owns, or `string` when unknown. */
293
+ readonly field?: Field;
294
+ /** Types only: the parent Message tag this placement routes, or `string` when unknown. */
295
+ readonly claims?: Claimed;
296
+ readonly name: Name;
297
+ /** `Name@path`, or the configured `key`: the prefix of every Subscription and resource key. */
298
+ readonly key: string;
299
+ /** The encoded args as text, when the bundle has an args Schema. */
300
+ readonly argsSummary: string | undefined;
301
+ /** Whether `args` was given as a seed factory; resolved once per initialization. */
302
+ readonly hasDynamicArgs: boolean;
303
+ /**
304
+ * Derives the factory's args from `seed`, validates them against the
305
+ * bundle's args Schema, and retains them for `init`, `update`, helpers,
306
+ * Subscriptions, and resources. A no-op for static args. The assembly calls
307
+ * this with the base seed before running inits, so every factory sees the
308
+ * same parent state whatever the placement order.
309
+ */
310
+ readonly resolveArgs: (seed: unknown) => void;
311
+ /**
312
+ * Assembly use: marks the placement skipped because `rest` provides its
313
+ * top-level field, so its factory never runs and its records contribute
314
+ * nothing while the child is absent. Cleared by the next `resolveArgs`.
315
+ */
316
+ readonly skipArgs: () => void;
317
+ readonly link: Link<Parent, ParentMessage, Model, Message>;
318
+ /** Writes the child's initial Model and starts its `init` Commands. */
319
+ readonly init: Update.Step<Parent, ParentMessage, R>;
320
+ /** Folds the Message when it belongs to this placement; `None` otherwise. */
321
+ readonly update: (parent: Parent, message: AnyMessage) => Option.Option<Update.Return<Parent, ParentMessage, R>>;
322
+ readonly subscriptions: Subscription.Subscriptions<Parent, ParentMessage, S>;
323
+ readonly resources: PlacedResources<Parent, ParentMessage, Resources>;
324
+ /**
325
+ * Renders the child through `h.submodel`; nothing while the child is absent.
326
+ * Generic over the parent's whole Message, which must include this placement's.
327
+ */
328
+ readonly view: PlacedView<Parent, ParentMessage, ViewInputs>;
329
+ /**
330
+ * The same view in another slot, for rendering one placement in two DOM
331
+ * positions (desktop and mobile). `h.submodel` throws on a repeated slot.
332
+ */
333
+ readonly viewIn: (slot: string) => PlacedView<Parent, ParentMessage, ViewInputs>;
334
+ readonly helpers: PlacedHelpers<Parent, ParentMessage, R, Helpers>;
335
+ }
336
+ /**
337
+ * What a placement's view needs of a builder: `submodel`, and `OnClick` to
338
+ * read its Message from. A wrapper of Foldkit's builder that keeps both, such
339
+ * as `foldkit-ssr`'s resumable builder, is one.
340
+ */
341
+ type BuilderLike = Pick<HtmlBuilder<any>, 'submodel' | 'OnClick'>;
342
+ type PlacedView<Parent, ParentMessage, ViewInputs> = [ViewInputs] extends [void] ? <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>) => Html : <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, viewInputs: ViewInputs) => Html;
343
+ /** A readable type error: intersected onto a parameter, its message names the fix. */
344
+ interface Invalid<Message extends string> {
345
+ readonly invalid: Message;
346
+ }
347
+ type BuilderMessage<H> = H extends {
348
+ readonly OnClick: (message: infer M, ...rest: any) => any;
349
+ } ? M : never;
350
+ /**
351
+ * The parent's `h`, checked to accept this placement's Messages. Generic over the
352
+ * whole builder rather than its Message: inferring a Message through
353
+ * `HtmlBuilder` costs thousands of type instantiations per call, while the
354
+ * builder infers as itself and its Message is extracted once per builder type.
355
+ */
356
+ type ViewBuilder<H, ParentMessage> = H & ([ParentMessage] extends [BuilderMessage<H>] ? unknown : Invalid<"The parent Message does not include this placement's wrapper variant; spread its Link.wrapper(...).cases into defineMessageUnion">);
357
+ /** The tag of a Link's parent variant, or `string` when it cannot be read. */
358
+ type TagOf<LinkMessage> = LinkMessage extends {
359
+ readonly _tag: infer Tag extends string;
360
+ } ? Tag : string;
361
+ //#endregion
226
362
  //#region ../bundle/src/link.d.ts
227
363
  declare const LinkTypeId: unique symbol;
228
364
  /** The parent Message variant `Tag({ message })` that carries a child's Messages. */
@@ -251,8 +387,14 @@ interface Wrapper<Tag extends string, ChildMessage> {
251
387
  type AnyMessage = {
252
388
  readonly _tag: string;
253
389
  };
254
- interface Link<Parent, ParentMessage, Child, ChildMessage> extends Pipeable.Pipeable {
390
+ /**
391
+ * `Field` is the parent's top-level field the child is written into, when the
392
+ * Link is one: `never` for a child nested deeper, and `string` when unknown.
393
+ */
394
+ interface Link<Parent, ParentMessage, Child, ChildMessage, Field extends string = string> extends Pipeable.Pipeable {
255
395
  readonly [LinkTypeId]: typeof LinkTypeId;
396
+ /** Types only: the top-level field, so `placements.initial` knows who writes it. */
397
+ readonly field?: Field;
256
398
  readonly read: (parent: Parent) => Option.Option<Child>;
257
399
  readonly write: (parent: Parent, child: Child) => Parent;
258
400
  readonly toParentMessage: (message: ChildMessage) => ParentMessage;
@@ -267,14 +409,35 @@ interface Link<Parent, ParentMessage, Child, ChildMessage> extends Pipeable.Pipe
267
409
  /** The application a Link built from a Surface field ref belongs to, for its Module contract. */
268
410
  readonly owner?: object | undefined;
269
411
  }
270
- interface MakeConfig<Parent, Tag extends string, Child, ChildMessage> {
412
+ /** A Message union's variant `Tag({ message })`, as `defineMessageUnion` declares it. */
413
+ type Variant = {
414
+ readonly fields: {
415
+ readonly _tag: Schema.tag<string>;
416
+ readonly message: Schema.Top;
417
+ };
418
+ };
419
+ type VariantTag<V extends Variant> = V['fields']['_tag'] extends Schema.tag<infer Tag extends string> ? Tag : never;
420
+ type OnlyMessage<V extends Variant> = [Exclude<keyof V['fields'], '_tag' | 'message'>] extends [never] ? unknown : Invalid<'A wrapper variant carries only `message`; this variant has other fields'>;
421
+ /**
422
+ * The parent variant `Tag({ message })` for a child's Messages: from a tag and
423
+ * the child's Message Schema, whose `cases` then go into the parent's union, or
424
+ * from a variant the parent's union already declares.
425
+ */
426
+ declare function wrapper<const Tag extends string, ChildMessage>(tag: Tag, childMessage: Schema.Codec<ChildMessage, unknown>): Wrapper<Tag, ChildMessage>;
427
+ declare function wrapper<V extends Variant>(variant: V & OnlyMessage<V>): Wrapper<VariantTag<V>, V['fields']['message']['Type']>;
428
+ interface MakeConfig<Parent, Tag extends string, Child, ChildMessage, Path> {
271
429
  readonly read: (parent: Parent) => Option.Option<Child>;
272
430
  readonly write: (parent: Parent, child: Child) => Parent;
273
431
  readonly wrapper: Wrapper<Tag, ChildMessage>;
274
432
  readonly when?: (parent: Parent) => boolean;
275
- readonly path: ReadonlyArray<string>;
433
+ readonly path: Path;
276
434
  readonly owner?: object | undefined;
277
435
  }
436
+ /**
437
+ * The top-level field a path names. `initial` treats a one-segment path as the
438
+ * field the placement writes, so a longer one names none.
439
+ */
440
+ type FieldOfPath<Path> = Path extends readonly [infer Field extends string] ? Field : Path extends readonly [string, ...ReadonlyArray<string>] ? never : string;
278
441
  type OptionKeys<Parent> = { [K in keyof Parent]: Parent[K] extends Option.Option<unknown> ? K : never; }[keyof Parent] & string;
279
442
  type OptionValue<A> = A extends Option.Option<infer Value> ? Value : never;
280
443
  /** The parent Message variant `Tag({ key, message })` that carries one collection item's Messages. */
@@ -300,7 +463,9 @@ interface KeyedWrapper<Tag extends string, ChildMessage, Key extends string = st
300
463
  * business: a record by key, an array identified by id, or anything with these
301
464
  * operations. `entries` is the order views and Subscriptions follow.
302
465
  */
303
- interface CollectionLink<Parent, ParentMessage, Child, ChildMessage, Key extends string = string> {
466
+ interface CollectionLink<Parent, ParentMessage, Child, ChildMessage, Key extends string = string, Field extends string = string> {
467
+ /** Types only: the top-level field holding the items, or `string` when unknown. */
468
+ readonly field?: Field;
304
469
  /** The storage with no items, for a parent's initial Model. */
305
470
  readonly empty: unknown;
306
471
  readonly entries: (parent: Parent) => ReadonlyArray<readonly [key: Key, child: Child]>;
@@ -320,111 +485,75 @@ type RecordValue<A> = A extends Readonly<Record<string, infer Value>> ? Value :
320
485
  type ArrayKeys<Parent> = { [K in keyof Parent]: Parent[K] extends ReadonlyArray<unknown> ? K : never; }[keyof Parent] & string;
321
486
  type ArrayItem<A> = A extends ReadonlyArray<infer Item> ? Item : never;
322
487
  declare const Link: {
323
- readonly wrapper: <const Tag extends string, ChildMessage>(tag: Tag, childMessage: Schema.Codec<ChildMessage, unknown>) => Wrapper<Tag, ChildMessage>;
324
- readonly make: <Parent, const Tag extends string, Child, ChildMessage>(config: MakeConfig<Parent, Tag, Child, ChildMessage>) => Link<Parent, Wrapped<Tag, ChildMessage>, Child, ChildMessage>;
488
+ readonly wrapper: typeof wrapper;
489
+ readonly make: <Parent, const Tag extends string, Child, ChildMessage, const Path extends ReadonlyArray<string> = readonly string[]>(config: MakeConfig<Parent, Tag, Child, ChildMessage, Path>) => Link<Parent, Wrapped<Tag, ChildMessage>, Child, ChildMessage, FieldOfPath<Path>>;
325
490
  readonly field: <Parent>() => <const Key extends keyof Parent & string, const Tag extends string, ChildMessage>(key: Key, wrap: Wrapper<Tag, ChildMessage>, options?: {
326
491
  readonly when?: (parent: Parent) => boolean;
327
- }) => Link<Parent, Wrapped<Tag, ChildMessage>, Parent[Key], ChildMessage>;
492
+ }) => Link<Parent, Wrapped<Tag, ChildMessage>, Parent[Key], ChildMessage, Key>;
328
493
  readonly optional: <Parent>() => <const Key extends OptionKeys<Parent>, const Tag extends string, ChildMessage>(key: Key, wrap: Wrapper<Tag, ChildMessage>, options?: {
329
494
  readonly when?: (parent: Parent) => boolean;
330
- }) => Link<Parent, Wrapped<Tag, ChildMessage>, OptionValue<Parent[Key]>, ChildMessage>;
331
- readonly compose: <A, AMessage, B, BMessage extends AnyMessage, C, CMessage>(outer: Link<A, AMessage, B, BMessage>, inner: Link<B, BMessage, C, CMessage>) => Link<A, AMessage, C, CMessage>;
495
+ }) => Link<Parent, Wrapped<Tag, ChildMessage>, OptionValue<Parent[Key]>, ChildMessage, Key>;
496
+ readonly compose: <A, AMessage, B, BMessage extends AnyMessage, C, CMessage>(outer: Link<A, AMessage, B, BMessage, string>, inner: Link<B, BMessage, C, CMessage, string>) => Link<A, AMessage, C, CMessage, never>;
332
497
  readonly andThen: {
333
- <B, BMessage extends AnyMessage, C, CMessage>(inner: Link<B, BMessage, C, CMessage>): <A, AMessage>(outer: Link<A, AMessage, B, BMessage>) => Link<A, AMessage, C, CMessage>;
334
- <A, AMessage, B, BMessage extends AnyMessage, C, CMessage>(outer: Link<A, AMessage, B, BMessage>, inner: Link<B, BMessage, C, CMessage>): Link<A, AMessage, C, CMessage>;
498
+ <B, BMessage extends AnyMessage, C, CMessage>(inner: Link<B, BMessage, C, CMessage, string>): <A, AMessage>(outer: Link<A, AMessage, B, BMessage, string>) => Link<A, AMessage, C, CMessage, never>;
499
+ <A, AMessage, B, BMessage extends AnyMessage, C, CMessage>(outer: Link<A, AMessage, B, BMessage, string>, inner: Link<B, BMessage, C, CMessage, string>): Link<A, AMessage, C, CMessage, never>;
335
500
  };
336
501
  readonly when: {
337
- <Parent>(predicate: (parent: Parent) => boolean): <ParentMessage, Child, ChildMessage>(self: Link<Parent, ParentMessage, Child, ChildMessage>) => Link<Parent, ParentMessage, Child, ChildMessage>;
338
- <Parent, ParentMessage, Child, ChildMessage>(self: Link<Parent, ParentMessage, Child, ChildMessage>, predicate: (parent: Parent) => boolean): Link<Parent, ParentMessage, Child, ChildMessage>;
502
+ <Parent>(predicate: (parent: Parent) => boolean): <ParentMessage, Child, ChildMessage, Field extends string>(self: Link<Parent, ParentMessage, Child, ChildMessage, Field>) => Link<Parent, ParentMessage, Child, ChildMessage, Field>;
503
+ <Parent, ParentMessage, Child, ChildMessage, Field extends string>(self: Link<Parent, ParentMessage, Child, ChildMessage, Field>, predicate: (parent: Parent) => boolean): Link<Parent, ParentMessage, Child, ChildMessage, Field>;
504
+ };
505
+ readonly foldInit: <Parent, ParentMessage, Child, ChildMessage, Field extends string>(link: Link<Parent, ParentMessage, Child, ChildMessage, Field>, rest: Omit<Parent, Field>) => {
506
+ readonly toParentModel: (child: Child) => Parent;
507
+ readonly toParentMessage: (message: ChildMessage) => ParentMessage;
339
508
  };
340
509
  readonly keyedWrapper: <const Tag extends string, ChildMessage, Key extends string = string>(tag: Tag, childMessage: Schema.Codec<ChildMessage, unknown>, key?: Schema.Codec<Key, string>) => KeyedWrapper<Tag, ChildMessage, Key>;
341
510
  readonly collection: <Parent>() => <const Field extends RecordKeys<Parent>, const Tag extends string, ChildMessage, Key extends string>(field: Field, wrap: KeyedWrapper<Tag, ChildMessage, Key>, options?: {
342
511
  readonly when?: (parent: Parent, key: Key) => boolean;
343
- }) => CollectionLink<Parent, KeyedWrapped<Tag, ChildMessage, Key>, RecordValue<Parent[Field]>, ChildMessage, Key>;
512
+ }) => CollectionLink<Parent, KeyedWrapped<Tag, ChildMessage, Key>, RecordValue<Parent[Field]>, ChildMessage, Key, Field>;
344
513
  readonly collectionById: <Parent>() => <const Field extends ArrayKeys<Parent>, const Tag extends string, ChildMessage, Key extends string>(field: Field, wrap: KeyedWrapper<Tag, ChildMessage, Key>, options: {
345
514
  readonly id: (item: ArrayItem<Parent[Field]>) => Key;
346
515
  readonly when?: (parent: Parent, key: Key) => boolean;
347
- }) => CollectionLink<Parent, KeyedWrapped<Tag, ChildMessage, Key>, ArrayItem<Parent[Field]>, ChildMessage, Key>;
516
+ }) => CollectionLink<Parent, KeyedWrapped<Tag, ChildMessage, Key>, ArrayItem<Parent[Field]>, ChildMessage, Key, Field>;
348
517
  };
349
518
  //#endregion
350
- //#region ../bundle/src/placed.d.ts
351
- declare const PlacedTypeId: unique symbol;
352
- interface PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2> {
353
- readonly args?: Args;
354
- /** Handles the child's OutMessage in parent terms, with the child already written back. */
355
- readonly onOut?: (outMessage: OutMessage, context: Update.FoldContext<Message, LinkMessage>) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
356
- /** Prefix for the placement's Subscription and resource keys. Defaults to `Name@path`. */
357
- readonly key?: string;
358
- /** A gate beside the Link's own: Subscriptions and resources run only while both hold. */
359
- readonly when?: (parent: Parent) => boolean;
360
- }
361
- /** A lifted resource record: each child entry in parent terms, keyed by the placement. */
362
- type PlacedResources<Parent, ParentMessage, Resources> = Readonly<Record<string, { readonly [K in keyof Resources]: Resources[K] extends ManagedResource.Entry<any, any, infer Requirements, infer Value, infer Service, any> ? ManagedResource.Entry<Parent, ParentMessage, Requirements, Value, Service> : never; }[keyof Resources]>>;
363
- type PlacedHelpers<Parent, ParentMessage, R, Helpers> = { readonly [K in keyof Helpers]: Helpers[K] extends ((model: any, ...input: infer Input) => any) ? (...input: Input) => Update.Step<Parent, ParentMessage, R> : never; };
364
- interface Placed<Name extends string, Parent, ParentMessage, Model, Message, R, S, ViewInputs, Resources, Helpers, Field extends string = string> {
365
- readonly [PlacedTypeId]: typeof PlacedTypeId;
366
- /** Types only: the top-level Model field this placement owns, or `string` when unknown. */
367
- readonly field?: Field;
368
- readonly name: Name;
369
- /** `Name@path`, or the configured `key`: the prefix of every Subscription and resource key. */
370
- readonly key: string;
371
- /** The encoded args as text, when the bundle has an args Schema. */
372
- readonly argsSummary: string | undefined;
373
- readonly link: Link<Parent, ParentMessage, Model, Message>;
374
- /** Writes the child's initial Model and starts its `init` Commands. */
375
- readonly init: Update.Step<Parent, ParentMessage, R>;
376
- /** Folds the Message when it belongs to this placement; `None` otherwise. */
377
- readonly update: (parent: Parent, message: AnyMessage) => Option.Option<Update.Return<Parent, ParentMessage, R>>;
378
- readonly subscriptions: Subscription.Subscriptions<Parent, ParentMessage, S>;
379
- readonly resources: PlacedResources<Parent, ParentMessage, Resources>;
380
- /**
381
- * Renders the child through `h.submodel`; nothing while the child is absent.
382
- * Generic over the parent's whole Message, which must include this placement's.
383
- */
384
- readonly view: PlacedView<Parent, ParentMessage, ViewInputs>;
385
- /**
386
- * The same view in another slot, for rendering one placement in two DOM
387
- * positions (desktop and mobile). `h.submodel` throws on a repeated slot.
388
- */
389
- readonly viewIn: (slot: string) => PlacedView<Parent, ParentMessage, ViewInputs>;
390
- readonly helpers: PlacedHelpers<Parent, ParentMessage, R, Helpers>;
391
- }
392
- type PlacedView<Parent, ParentMessage, ViewInputs> = [ViewInputs] extends [void] ? <H extends HtmlBuilder<any>>(parent: Parent, h: ViewBuilder<H, ParentMessage>) => Html : <H extends HtmlBuilder<any>>(parent: Parent, h: ViewBuilder<H, ParentMessage>, viewInputs: ViewInputs) => Html;
393
- /** A readable type error: intersected onto a parameter, its message names the fix. */
394
- interface Invalid<Message extends string> {
395
- readonly invalid: Message;
396
- }
397
- type BuilderMessage<H> = H extends HtmlBuilder<infer M> ? M : never;
398
- /**
399
- * The parent's `h`, checked to accept this placement's Messages. Generic over the
400
- * whole builder rather than its Message: inferring a Message through
401
- * `HtmlBuilder` costs thousands of type instantiations per call, while the
402
- * builder infers as itself and its Message is extracted once per builder type.
403
- */
404
- type ViewBuilder<H, ParentMessage> = H & ([ParentMessage] extends [BuilderMessage<H>] ? unknown : Invalid<"The parent Message does not include this placement's wrapper variant; spread its Link.wrapper(...).cases into defineMessageUnion">);
405
- //#endregion
406
519
  //#region ../bundle/src/collection.d.ts
407
520
  declare const PlacedCollectionTypeId: unique symbol;
408
- interface EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string> {
409
- /** The args every item's `init` and `update` receive. */
410
- readonly args?: Args;
521
+ interface EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string, ParentSeed = Parent> {
522
+ /**
523
+ * The args every item's `init` and `update` receive: a static value, or a
524
+ * factory from the parent seed, computed once per initialization and
525
+ * retained. Adding items requires `initial`/`config` to have run; `update`
526
+ * on a Model no initialization produced derives per use instead.
527
+ */
528
+ readonly args?: ArgsSource<ParentSeed, Args>;
411
529
  /** Handles an item's OutMessage in parent terms, with the item already written back. */
412
530
  readonly onOut?: (outMessage: OutMessage, key: Key, context: Update.FoldContext<Message, LinkMessage>) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
531
+ /** Observes each item's Messages in parent terms, after the item has handled it and its `onOut` has run. */
532
+ readonly onMessage?: (message: Message, key: Key) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
413
533
  /** Prefix for the collection's Subscription keys. Defaults to `Name@path[]`. */
414
534
  readonly key?: string;
415
535
  readonly when?: (parent: Parent, key: Key) => boolean;
416
536
  }
417
- type CollectionView<Parent, ParentMessage, ViewInputs, Key extends string = string> = [ViewInputs] extends [void] ? <H extends HtmlBuilder<any>>(parent: Parent, h: ViewBuilder<H, ParentMessage>, key: Key) => Html : <H extends HtmlBuilder<any>>(parent: Parent, h: ViewBuilder<H, ParentMessage>, key: Key, viewInputs: ViewInputs) => Html;
537
+ type CollectionView<Parent, ParentMessage, ViewInputs, Key extends string = string> = [ViewInputs] extends [void] ? <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, key: Key) => Html : <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, key: Key, viewInputs: ViewInputs) => Html;
418
538
  type CollectionHelpers<Parent, ParentMessage, R, Helpers, Key extends string = string> = { readonly [K in keyof Helpers]: Helpers[K] extends ((model: any, ...input: infer Input) => any) ? (key: Key, ...input: Input) => Update.Step<Parent, ParentMessage, R> : never; };
419
- interface PlacedCollection<Name extends string, Parent, ParentMessage, Model, Message, R, S, ViewInputs, Helpers, Field extends string = string, Key extends string = string> {
539
+ interface PlacedCollection<Name extends string, Parent, ParentMessage, Model, Message, R, S, ViewInputs, Helpers, Field extends string = string, Key extends string = string, Claimed extends string = string> {
420
540
  readonly [PlacedCollectionTypeId]: typeof PlacedCollectionTypeId;
421
541
  /** Types only: the record field this collection owns, or `string` when unknown. */
422
542
  readonly field?: Field;
543
+ /** Types only: the parent Message tag this collection routes, or `string` when unknown. */
544
+ readonly claims?: Claimed;
423
545
  readonly name: Name;
424
546
  /** `Name@path[]`, or the configured `key`: the prefix of every Subscription key. */
425
547
  readonly key: string;
426
548
  /** The encoded args as text, when the bundle has an args Schema. */
427
549
  readonly argsSummary: string | undefined;
550
+ /** Whether `args` was given as a seed factory; resolved once per initialization. */
551
+ readonly hasDynamicArgs: boolean;
552
+ /**
553
+ * Derives the factory's args from `seed` and retains them for `add`,
554
+ * `update`, and Subscriptions. A no-op for static args.
555
+ */
556
+ readonly resolveArgs: (seed: unknown) => void;
428
557
  readonly link: CollectionLink<Parent, ParentMessage, Model, Message, Key>;
429
558
  /** Folds the Message into its item; `None` when it is not this collection's. A missing key leaves the parent unchanged. */
430
559
  readonly update: (parent: Parent, message: AnyMessage) => Option.Option<Update.Return<Parent, ParentMessage, R>>;
@@ -440,11 +569,16 @@ interface PlacedCollection<Name extends string, Parent, ParentMessage, Model, Me
440
569
  /** One item's view; nothing when the key is missing. */
441
570
  readonly view: CollectionView<Parent, ParentMessage, ViewInputs, Key>;
442
571
  /** Every item's view, in the order of the Link's `entries`. */
443
- readonly viewAll: <H extends HtmlBuilder<any>>(parent: Parent, h: ViewBuilder<H, ParentMessage>, ...viewInputs: [ViewInputs] extends [void] ? [] : [viewInputs: ViewInputs]) => ReadonlyArray<Html>;
572
+ readonly viewAll: <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, ...viewInputs: [ViewInputs] extends [void] ? [] : [viewInputs: ViewInputs]) => ReadonlyArray<Html>;
444
573
  readonly helpers: CollectionHelpers<Parent, ParentMessage, R, Helpers, Key>;
445
574
  }
446
575
  //#endregion
447
576
  //#region ../bundle/src/bundle.d.ts
577
+ /**
578
+ * The parent seed a factory observes: the parent without the placement's own
579
+ * field, or the whole parent where the field is unknown (`string`).
580
+ */
581
+ type SeedFor<Parent, Field extends string> = string extends Field ? Parent : Omit<Parent, Field>;
448
582
  declare const BundleTypeId: unique symbol;
449
583
  /** A child Managed Resource entry: its requirements are an `Option`, so the entry can release. */
450
584
  type ResourceEntry<Model, Message> = ManagedResource.Entry<Model, Message, Option.Option<any>, any, any>;
@@ -478,44 +612,96 @@ interface Bundle$1<Name extends string, Args, Model, Message extends AnyMessage,
478
612
  */
479
613
  readonly with: (args: Args) => Bundle$1<Name, void, Model, Message, OutMessage, R, S, ViewInputs, Resources, Helpers>;
480
614
  /** Places the bundle where `link` points. */
481
- readonly at: <Parent, LinkMessage, OutStepMessage = never, R2 = never>(link: Link<Parent, LinkMessage, Model, Message>, ...config: PlaceConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2>) => Placed<Name, Parent, LinkMessage | OutStepMessage, Model, Message, R | R2, S, ViewInputs, Resources, Helpers>;
615
+ readonly at: <Parent, LinkMessage, Field extends string, OutStepMessage = never, R2 = never>(link: Link<Parent, LinkMessage, Model, Message, Field>, ...config: PlaceConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, SeedFor<Parent, Field>>) => Placed<Name, Parent, LinkMessage | OutStepMessage, Model, Message, R | R2, S, ViewInputs, Resources, Helpers, Field, TagOf<LinkMessage>>;
482
616
  /** Places the bundle once per key of the collection `link` points at. */
483
- readonly each: [keyof Resources] extends [never] ? <Parent, LinkMessage, Key extends string, OutStepMessage = never, R2 = never>(link: CollectionLink<Parent, LinkMessage, Model, Message, Key>, ...config: EachConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key>) => PlacedCollection<Name, Parent, LinkMessage | OutStepMessage, Model, Message, R | R2, S, ViewInputs, Helpers, string, Key> : Invalid<'Bundle.each does not support Managed Resources yet: the runtime provides a resource by one tag, so items would share it'>;
617
+ readonly each: [keyof Resources] extends [never] ? <Parent, LinkMessage, Key extends string, Field extends string, OutStepMessage = never, R2 = never>(link: CollectionLink<Parent, LinkMessage, Model, Message, Key, Field>, ...config: EachConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, SeedFor<Parent, Field>>) => PlacedCollection<Name, Parent, LinkMessage | OutStepMessage, Model, Message, R | R2, S, ViewInputs, Helpers, Field, Key, TagOf<LinkMessage>> : Invalid<'Bundle.each does not support Managed Resources yet: the runtime provides a resource by one tag, so items would share it'>;
484
618
  }
485
619
  /**
486
620
  * What placing needs: `args` when `init` takes them, and `onOut` when the
487
621
  * bundle has an OutMessage, so an OutMessage is never dropped by omission.
622
+ * `args` is a static value or a factory from the parent seed (the parent
623
+ * without this placement's own field); the seed type defaults to the whole
624
+ * parent where the field is unknown.
488
625
  */
489
- type PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2> = {
626
+ type PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed = Parent> = {
490
627
  /** Prefix for the placement's Subscription and resource keys. Defaults to `Name@path`. */
491
628
  readonly key?: string;
492
629
  /** A gate beside the Link's own: the child's Subscriptions and resources run only while both hold. */
493
630
  readonly when?: (parent: Parent) => boolean;
631
+ /** Observes each of the child's Messages in parent terms, after the child handled it. */
632
+ readonly onMessage?: Required<PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>>['onMessage'];
494
633
  } & ([Args] extends [void] ? {
495
634
  readonly args?: never;
496
635
  } : {
497
- readonly args: Args;
636
+ readonly args: ArgsSource<ParentSeed, Args>;
498
637
  }) & ([OutMessage] extends [never] ? {
499
638
  readonly onOut?: never;
500
639
  } : {
501
- readonly onOut: Required<PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2>>['onOut'];
640
+ readonly onOut: Required<PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>>['onOut'];
502
641
  });
503
642
  /** The config argument is optional only when it would be empty. */
504
- type PlaceConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2> = [Args] extends [void] ? [OutMessage] extends [never] ? [config?: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2>] : [config: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2>] : [config: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2>];
505
- type EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string> = {
643
+ type PlaceConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed = Parent> = [Args] extends [void] ? [OutMessage] extends [never] ? [config?: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>] : [config: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>] : [config: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>];
644
+ type EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string, ParentSeed = Parent> = {
506
645
  readonly key?: string;
507
646
  /** A gate per item beside the Link's own: an item's Subscriptions run only while both hold. */
508
647
  readonly when?: (parent: Parent, key: Key) => boolean;
648
+ /** Observes each item's Messages in parent terms, after the item handled it. */
649
+ readonly onMessage?: Required<EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>>['onMessage'];
509
650
  } & ([Args] extends [void] ? {
510
651
  readonly args?: never;
511
652
  } : {
512
- readonly args: Args;
653
+ readonly args: ArgsSource<ParentSeed, Args>;
513
654
  }) & ([OutMessage] extends [never] ? {
514
655
  readonly onOut?: never;
515
656
  } : {
516
- readonly onOut: Required<EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key>>['onOut'];
657
+ readonly onOut: Required<EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>>['onOut'];
517
658
  });
518
- type EachConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string> = [Args] extends [void] ? [OutMessage] extends [never] ? [config?: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key>] : [config: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key>] : [config: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key>];
659
+ type EachConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string, ParentSeed = Parent> = [Args] extends [void] ? [OutMessage] extends [never] ? [config?: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>] : [config: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>] : [config: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>];
660
+ //#endregion
661
+ //#region src/views.d.ts
662
+ /** A published revision, as an editor's History lists it. */
663
+ interface RevisionRow {
664
+ readonly n: number;
665
+ readonly publishedAt: string;
666
+ readonly publishedBy: string | null;
667
+ }
668
+ /**
669
+ * The open entry's published revisions, as they have been read. A posts'
670
+ * history and a pages' revisions read through the same shape, so one helper
671
+ * serves both: which read is the section's to name. A read that failed, or
672
+ * that has no answer yet, is its own state rather than an empty list, so the
673
+ * card cannot mistake either for nothing published.
674
+ */
675
+ type RevisionHistory = {
676
+ readonly _tag: 'Ready';
677
+ readonly revisions: ReadonlyArray<RevisionRow>;
678
+ } | {
679
+ readonly _tag: 'Loading';
680
+ } | {
681
+ readonly _tag: 'Failed';
682
+ };
683
+ /** The builders `historyCard` reads. */
684
+ interface HistoryCardSlots<M> {
685
+ readonly card: SlotView.SlotBuilder<M>;
686
+ readonly cardTitle: SlotView.SlotBuilder<M>;
687
+ readonly muted: SlotView.SlotBuilder<M>;
688
+ readonly timeline: SlotView.SlotBuilder<M>;
689
+ readonly revision: SlotView.SlotBuilder<M>;
690
+ readonly revisionMark: SlotView.SlotBuilder<M>;
691
+ readonly revisionBody: SlotView.SlotBuilder<M>;
692
+ readonly revisionTitle: SlotView.SlotBuilder<M>;
693
+ readonly revisionLive: SlotView.SlotBuilder<M>;
694
+ readonly revisionMeta: SlotView.SlotBuilder<M>;
695
+ readonly revisionRestore: SlotView.SlotBuilder<M>;
696
+ }
697
+ /** The builders `moreCard` reads. */
698
+ interface MoreCardSlots<M> {
699
+ readonly card: SlotView.SlotBuilder<M>;
700
+ readonly cardTitle: SlotView.SlotBuilder<M>;
701
+ readonly toolbar: SlotView.SlotBuilder<M>;
702
+ readonly button: SlotView.SlotBuilder<M>;
703
+ readonly danger: SlotView.SlotBuilder<M>;
704
+ }
519
705
  //#endregion
520
706
  //#region src/kinds.d.ts
521
707
  interface StateWords {
@@ -526,6 +712,8 @@ interface StateWords {
526
712
  readonly Archived?: string;
527
713
  readonly scheduled?: string;
528
714
  readonly overdue?: string;
715
+ /** A state with what its schedule adds: `{state}` and `{schedule}`. */
716
+ readonly withSchedule?: string;
529
717
  }
530
718
  /** What `foldkit-mixins-form` gives a control's renderer, as far as these read it. */
531
719
  interface ControlContext<Message> {
@@ -538,6 +726,12 @@ interface ControlContext<Message> {
538
726
  readonly text: {
539
727
  readonly attrs: (attrs: ReadonlyArray<any>) => any;
540
728
  };
729
+ readonly group: {
730
+ readonly attrs: () => any;
731
+ };
732
+ readonly affix: {
733
+ readonly attrs: () => any;
734
+ };
541
735
  };
542
736
  readonly h: HtmlBuilder<Message>;
543
737
  }
@@ -545,11 +739,14 @@ interface ControlContext<Message> {
545
739
  interface DisplayContext<Message> {
546
740
  readonly display: {
547
741
  readonly kind: string;
548
- readonly text: (value: unknown, words: any) => string;
742
+ readonly text: (value: unknown, words: DisplayWords) => string;
549
743
  };
550
744
  readonly value: unknown;
551
- readonly words: unknown;
745
+ readonly words: DisplayWords;
552
746
  readonly h: HtmlBuilder<Message>;
747
+ readonly badge: {
748
+ readonly attrs: (attrs: ReadonlyArray<any>) => any;
749
+ };
553
750
  }
554
751
  //#endregion
555
752
  //#region src/index.d.ts
@@ -625,9 +822,13 @@ export declare const Cms: {
625
822
  */
626
823
  editor: <const Name extends string, FormModel, FormMessage extends {
627
824
  readonly _tag: string;
628
- }, Value>(name: Name, config: {
629
- readonly content: EditorContent<FormModel, FormMessage, Value>;
630
- readonly rest?: import("effect/Duration").Input;
825
+ }, Value, Resources = {}, Services = never>(name: Name, config: {
826
+ readonly content: EditorContent<FormModel, FormMessage, Value, Resources, Services>;
827
+ readonly rest? /**
828
+ * A pipe step naming the members of an Entity that play a CMS part. It is
829
+ * metadata: the Entity is the same Entity, and anything may read it with
830
+ * `Cms.rolesOf`. A member that cannot play the part is refused here.
831
+ */ : import("effect/Duration").Input;
631
832
  readonly version?: string;
632
833
  readonly untitled?: string;
633
834
  }) => {
@@ -660,7 +861,7 @@ export declare const Cms: {
660
861
  readonly _tag: "ReloadAsked";
661
862
  } | {
662
863
  readonly _tag: "OverwriteAsked";
663
- }, EditorOut, any, never, void, {}, {
864
+ }, EditorOut, Services, Services, void, [keyof Resources] extends [never] ? {} : Readonly<Record<string, never>>, {
664
865
  open: (_: EditorModel<FormModel>, entry: string) => {
665
866
  model: {
666
867
  mode: "edit";
@@ -674,6 +875,7 @@ export declare const Cms: {
674
875
  saveWanted: boolean;
675
876
  publishId: string | null;
676
877
  publishWanted: boolean;
878
+ submit: "idle" | "waiting" | "stopped";
677
879
  scheduleAt: string | null;
678
880
  otherId: string | null;
679
881
  previewing: boolean;
@@ -694,6 +896,7 @@ export declare const Cms: {
694
896
  saveWanted: boolean;
695
897
  publishId: string | null;
696
898
  publishWanted: boolean;
899
+ submit: "idle" | "waiting" | "stopped";
697
900
  scheduleAt: string | null;
698
901
  otherId: string | null;
699
902
  previewing: boolean;
@@ -745,18 +948,52 @@ export declare const Cms: {
745
948
  }>(update: (model: Root, message: Message) => Result) => (model: Root, message: Message) => Result;
746
949
  canPreview: boolean;
747
950
  previewing: (root: Root) => boolean;
748
- pageId: (root: Root) => string | null;
749
- entry: (root: Root) => string | null;
750
- resumed: (root: Root) => Resumed | null;
751
- state: (root: Root) => State | undefined;
752
- error: (root: Root) => import("foldkit-remote").RemoteError | undefined;
951
+ pageId: (root: Root) => import("effect/Option").Option<string>;
952
+ entry: (root: Root) => import("effect/Option").Option<string>;
953
+ storedEntry: (root: Root) => import("effect/Option").Option<string>;
954
+ resumed: (root: Root) => import("effect/Option").Option<Resumed>;
955
+ state: (root: Root) => import("effect/Option").Option<State>;
956
+ may: (root: Root, transition: Transition) => boolean;
957
+ error: (root: Root) => import("effect/Option").Option<import("foldkit-remote").RemoteError>;
753
958
  status: (root: Root) => EditorStatus;
754
959
  };
755
960
  };
756
961
  /** A form's Submodel view as its editor's, for `Bundle.withView`. */
757
962
  editorView: <FormModel, FormMessage, ViewInputs>(view: import("foldkit/submodel").View<FormModel, FormMessage, ViewInputs>) => import("foldkit/submodel").View<EditorModel<FormModel>, FormMessage | EditorMessage, ViewInputs>;
963
+ /**
964
+ * The entry-level views every studio draws, on its own slot builders: its
965
+ * state badge, its published revisions, what was published, and the rest of
966
+ * what can happen to it. Words for states come from `Cms.Display`, so a
967
+ * studio and its lists say them one way.
968
+ */
969
+ stateBadge: <M>(badge: import("foldkit-mixins").SlotBuilder<M>, h: import("foldkit/html").HtmlBuilder<M>, state: import("effect/Option").Option<State>, attribute?: string) => import("foldkit/html").Html;
970
+ /** Whether the entry's state is one of the given tags; no state yet is none of them. */
971
+ stateIs: (state: import("effect/Option").Option<State>, ...tags: ReadonlyArray<State["_tag"]>) => boolean;
972
+ revisionsOf: <M, Value extends {
973
+ readonly revisions: ReadonlyArray<RevisionRow>;
974
+ }>(model: M, history: (model: M) => import("effect/Option").Option<{
975
+ readonly read: (model: M) => import("foldkit-remote").RemoteData<Value>;
976
+ }>) => RevisionHistory;
977
+ historyCard: <M>(slots: HistoryCardSlots<M>, h: import("foldkit/html").HtmlBuilder<M>, history: RevisionHistory, entry: {
978
+ readonly state: import("effect/Option").Option<State>;
979
+ readonly restore: (revision: number) => M;
980
+ readonly authorName: (name: string) => string;
981
+ }) => import("foldkit/html").Html;
982
+ moreCard: <M>(slots: MoreCardSlots<M>, h: import("foldkit/html").HtmlBuilder<M>, entry: {
983
+ readonly state: import("effect/Option").Option<State>;
984
+ readonly may: (transition: Transition) => boolean;
985
+ readonly asks: {
986
+ readonly discard: M;
987
+ readonly unpublish: M;
988
+ readonly archive: M;
989
+ readonly unarchive: M;
990
+ };
991
+ readonly archiveIcon: import("foldkit/html").Html;
992
+ }) => ReadonlyArray<import("foldkit/html").Html>;
758
993
  /** The state of an entry, from what is known of it and a clock. */
759
994
  state: (facts: Facts, now: Date) => State;
995
+ /** Every transition an author may ask, in order: what `allow` is asked about. */
996
+ transitions: readonly ["save", "discard", "publish", "schedule", "unschedule", "unpublish", "archive", "unarchive", "restore"];
760
997
  /** The transitions an entry offers now, before anyone asks who is asking. */
761
998
  offers: (facts: Facts, now: Date, content: {
762
999
  readonly roles: Roles;
@@ -843,6 +1080,7 @@ export declare const Cms: {
843
1080
  readonly error: Schema.NullOr<Schema.String>;
844
1081
  }>>;
845
1082
  }>>;
1083
+ readonly may: import("foldkit-entity").DerivedSpec<Schema.$Array<Schema.Literals<readonly ["save", "discard", "publish", "schedule", "unschedule", "unpublish", "archive", "unarchive", "restore"]>>>;
846
1084
  }>;
847
1085
  readonly Draft: Entity<"CmsDraft", {
848
1086
  /** The entry's id: an entry has at most one draft. */
@@ -902,6 +1140,7 @@ export declare const Cms: {
902
1140
  readonly error: Schema.NullOr<Schema.String>;
903
1141
  }>>;
904
1142
  }>>;
1143
+ readonly may: import("foldkit-entity").DerivedSpec<Schema.$Array<Schema.Literals<readonly ["save", "discard", "publish", "schedule", "unschedule", "unpublish", "archive", "unarchive", "restore"]>>>;
905
1144
  }>;
906
1145
  readonly Draft: Entity<"CmsDraft", {
907
1146
  /** The entry's id: an entry has at most one draft. */
@@ -939,6 +1178,7 @@ export declare const Cms: {
939
1178
  readonly error: Schema.NullOr<Schema.String>;
940
1179
  }>>;
941
1180
  }>>;
1181
+ readonly may: import("foldkit-entity").DerivedSpec<Schema.$Array<Schema.Literals<readonly ["save", "discard", "publish", "schedule", "unschedule", "unpublish", "archive", "unarchive", "restore"]>>>;
942
1182
  }>;
943
1183
  readonly Draft: Entity<"CmsDraft", {
944
1184
  /** The entry's id: an entry has at most one draft. */
@@ -1017,6 +1257,7 @@ export declare const Cms: {
1017
1257
  readonly error: Schema.NullOr<Schema.String>;
1018
1258
  }>>;
1019
1259
  }>>;
1260
+ readonly may: import("foldkit-entity").DerivedSpec<Schema.$Array<Schema.Literals<readonly ["save", "discard", "publish", "schedule", "unschedule", "unpublish", "archive", "unarchive", "restore"]>>>;
1020
1261
  }>;
1021
1262
  readonly Draft: Entity<"CmsDraft", {
1022
1263
  /** The entry's id: an entry has at most one draft. */
@@ -1200,5 +1441,5 @@ export declare const Cms: {
1200
1441
  }) => import("effect/Effect").Effect<string | undefined, never, import("foldkit-remote").RemoteClient>);
1201
1442
  };
1202
1443
  //#endregion
1203
- export type { ControlContext, DisplayContext, EditorContent, EditorDomain, EditorForm, EditorMessage, EditorModel, EditorOut, EditorStatus, Facts, Resumed, Schedule, State, StateTag, StateWords, Transition };
1444
+ export type { ControlContext, DisplayContext, EditorContent, EditorDomain, EditorForm, EditorMessage, EditorModel, EditorOut, EditorStatus, Facts, HistoryCardSlots, MoreCardSlots, Resumed, RevisionHistory, RevisionRow, Schedule, State, StateTag, StateWords, Transition };
1204
1445
  //# sourceMappingURL=index.d.mts.map