foldkit-cms 0.6.2 → 0.7.1

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
@@ -1,21 +1,65 @@
1
- import { Option, Pipeable, Schema } from "effect";
1
+ import { Effect, Option, 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
5
  import * as Subscription from "foldkit/subscription";
8
6
  import * as Submodel from "foldkit/submodel";
9
7
  import { DisplayWords } from "foldkit-crud";
10
8
  import { Control, Draft, Submitted } from "foldkit-form";
9
+ import { Attribute, Html, HtmlBuilder } from "foldkit/html";
11
10
  import { ActiveSurface, Projection } from "foldkit-surface";
12
11
  import { Command } from "foldkit/command";
13
12
  import * as FieldValidation from "foldkit/fieldValidation";
14
13
  import * as Update from "foldkit/update";
15
- import { CallableTaggedStruct } from "foldkit/schema";
16
- import { Attribute, Html, HtmlBuilder } from "foldkit/html";
17
- import "foldkit/url";
18
14
  import { SlotView } from "foldkit-mixins";
15
+ //#region src/kinds.d.ts
16
+ /** Text as an address: lower case, unaccented, words joined by `-`. */
17
+ declare const slugify: (text: string) => string;
18
+ interface StateWords {
19
+ readonly New?: string;
20
+ readonly Published?: string;
21
+ readonly Changed?: string;
22
+ readonly Unpublished?: string;
23
+ readonly Archived?: string;
24
+ readonly scheduled?: string;
25
+ readonly overdue?: string;
26
+ /** A state with what its schedule adds: `{state}` and `{schedule}`. */
27
+ readonly withSchedule?: string;
28
+ }
29
+ /** What `foldkit-mixins-form` gives a control's renderer, as far as these read it. */
30
+ interface ControlContext<Message> {
31
+ readonly control: Control;
32
+ readonly draft: Draft;
33
+ readonly change: (value: Draft) => Message;
34
+ readonly blurred: Message;
35
+ readonly state: ReadonlyArray<Attribute<Message>>;
36
+ readonly slots: {
37
+ readonly text: {
38
+ readonly attrs: (attrs: ReadonlyArray<any>) => any;
39
+ };
40
+ readonly group: {
41
+ readonly attrs: () => any;
42
+ };
43
+ readonly affix: {
44
+ readonly attrs: () => any;
45
+ };
46
+ };
47
+ readonly h: HtmlBuilder<Message>;
48
+ }
49
+ /** What `foldkit-mixins-crud` gives a display's renderer, as far as these read it. */
50
+ interface DisplayContext<Message> {
51
+ readonly display: {
52
+ readonly kind: string;
53
+ readonly text: (value: unknown, words: DisplayWords) => string;
54
+ };
55
+ readonly value: unknown;
56
+ readonly words: DisplayWords;
57
+ readonly h: HtmlBuilder<Message>;
58
+ readonly badge: {
59
+ readonly attrs: (attrs: ReadonlyArray<any>) => any;
60
+ };
61
+ }
62
+ //#endregion
19
63
  //#region src/lifecycle.d.ts
20
64
  /** What is known of one entry. The server gathers it; nothing here reads a database. */
21
65
  interface Facts {
@@ -217,7 +261,7 @@ interface EditorContent<FormModel, FormMessage, Value, Resources = {}, Services
217
261
  }
218
262
  declare const EditorMessage: import("foldkit/message").MessageUnion<{
219
263
  readonly Rested: {
220
- readonly edit: Schema.Number;
264
+ edit: Schema.Number;
221
265
  };
222
266
  readonly PublishAsked: {};
223
267
  /** Lays what is in the form over the store, until `PreviewHidden`. Nothing is sent. */
@@ -225,7 +269,7 @@ declare const EditorMessage: import("foldkit/message").MessageUnion<{
225
269
  readonly PreviewHidden: {};
226
270
  /** Publishes later: the form is submitted and saved now, and the server keeps the promise. */
227
271
  readonly ScheduleAsked: {
228
- readonly at: Schema.String;
272
+ at: Schema.String;
229
273
  };
230
274
  readonly UnscheduleAsked: {};
231
275
  readonly ArchiveAsked: {};
@@ -233,7 +277,7 @@ declare const EditorMessage: import("foldkit/message").MessageUnion<{
233
277
  readonly DiscardAsked: {};
234
278
  /** Makes a revision's value the working copy. It replaces what is here, and publishes nothing. */
235
279
  readonly RestoreAsked: {
236
- readonly revision: Schema.Number;
280
+ revision: Schema.Number;
237
281
  };
238
282
  readonly UnpublishAsked: {};
239
283
  /** After a conflict: drop what is here and show the server's copy. */
@@ -242,428 +286,25 @@ declare const EditorMessage: import("foldkit/message").MessageUnion<{
242
286
  readonly OverwriteAsked: {};
243
287
  }>;
244
288
  type EditorMessage = typeof EditorMessage.Type;
245
- //#endregion
246
- //#region ../bundle/src/placed.d.ts
247
- declare const PlacedTypeId: unique symbol;
248
289
  /**
249
- * Args for a placement: a static value, or a factory deriving them from the
250
- * parent seed — the fields `assembly.initial(rest)` was given, before any
251
- * placement initialised. A factory runs once per initialization and its result
252
- * is retained for the placement's `init`, `update`, helpers, Subscriptions,
253
- * and resources; it never re-runs against changing parent state, so keep it
254
- * pure of its seed.
255
- *
256
- * When no initialization ran — a hand-built Model in a test, which never went
257
- * through `initial` — `update` derives from the given parent per use, without
258
- * retaining, so each Model is folded with its own seed.
290
+ * A form's Submodel view as the view of the editor that wraps it, for
291
+ * `Bundle.withView`: the editor's Model holds the form's under `form`, and what
292
+ * the form's view sends is among the editor's Messages.
259
293
  *
260
- * Read only seed fields (route, auth, workspace, ...), never sibling
261
- * placement fields: every factory sees the same base seed, so a sibling read
262
- * is consistently absent rather than order-dependent.
263
- */
264
- type ArgsSource<Seed, Args> = Args | ((seed: Seed) => Args);
265
- interface PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed = Parent> {
266
- /**
267
- * The bundle's args: a static value, or a factory from the parent seed (the
268
- * fields `assembly.initial(rest)` was given, minus this placement's own
269
- * field). A factory is computed once per initialization and retained for
270
- * `init`, `update`, and helpers. Subscriptions and resources built from it
271
- * require `initial`/`config` to have run first; a bundle with neither
272
- * contributes empty records either way.
273
- */
274
- readonly args?: ArgsSource<ParentSeed, Args>;
275
- /** Handles the child's OutMessage in parent terms, with the child already written back. */
276
- readonly onOut?: (outMessage: OutMessage, context: Update.FoldContext<Message, LinkMessage>) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
277
- /**
278
- * Observes each of the child's Messages in parent terms, after the child has
279
- * handled it and its `onOut` has run, so the parent's own update needs no arm
280
- * for the wrapper. Helpers are not Messages and do not reach it.
281
- */
282
- readonly onMessage?: (message: Message) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
283
- /** Prefix for the placement's Subscription and resource keys. Defaults to `Name@path`. */
284
- readonly key?: string;
285
- /** A gate beside the Link's own: Subscriptions and resources run only while both hold. */
286
- readonly when?: (parent: Parent) => boolean;
287
- }
288
- /** A lifted resource record: each child entry in parent terms, keyed by the placement. */
289
- 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]>>;
290
- 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; };
291
- interface Placed<Name extends string, Parent, ParentMessage, Model, Message, R, S, ViewInputs, Resources, Helpers, Field extends string = string, Claimed extends string = string> {
292
- readonly [PlacedTypeId]: typeof PlacedTypeId;
293
- /** Types only: the top-level Model field this placement owns, or `string` when unknown. */
294
- readonly field?: Field;
295
- /** Types only: the parent Message tag this placement routes, or `string` when unknown. */
296
- readonly claims?: Claimed;
297
- readonly name: Name;
298
- /** `Name@path`, or the configured `key`: the prefix of every Subscription and resource key. */
299
- readonly key: string;
300
- /** The encoded args as text, when the bundle has an args Schema. */
301
- readonly argsSummary: string | undefined;
302
- /** Whether `args` was given as a seed factory; resolved once per initialization. */
303
- readonly hasDynamicArgs: boolean;
304
- /**
305
- * Derives the factory's args from `seed`, validates them against the
306
- * bundle's args Schema, and retains them for `init`, `update`, helpers,
307
- * Subscriptions, and resources. A no-op for static args. The assembly calls
308
- * this with the base seed before running inits, so every factory sees the
309
- * same parent state whatever the placement order.
310
- */
311
- readonly resolveArgs: (seed: unknown) => void;
312
- /**
313
- * Assembly use: marks the placement skipped because `rest` provides its
314
- * top-level field, so its factory never runs and its records contribute
315
- * nothing while the child is absent. Cleared by the next `resolveArgs`.
316
- */
317
- readonly skipArgs: () => void;
318
- readonly link: Link<Parent, ParentMessage, Model, Message>;
319
- /** Writes the child's initial Model and starts its `init` Commands. */
320
- readonly init: Update.Step<Parent, ParentMessage, R>;
321
- /** Folds the Message when it belongs to this placement; `None` otherwise. */
322
- readonly update: (parent: Parent, message: AnyMessage) => Option.Option<Update.Return<Parent, ParentMessage, R>>;
323
- readonly subscriptions: Subscription.Subscriptions<Parent, ParentMessage, S>;
324
- readonly resources: PlacedResources<Parent, ParentMessage, Resources>;
325
- /**
326
- * Renders the child through `h.submodel`; nothing while the child is absent.
327
- * Generic over the parent's whole Message, which must include this placement's.
328
- */
329
- readonly view: PlacedView<Parent, ParentMessage, ViewInputs>;
330
- /**
331
- * The same view in another slot, for rendering one placement in two DOM
332
- * positions (desktop and mobile). `h.submodel` throws on a repeated slot.
333
- */
334
- readonly viewIn: (slot: string) => PlacedView<Parent, ParentMessage, ViewInputs>;
335
- readonly helpers: PlacedHelpers<Parent, ParentMessage, R, Helpers>;
336
- }
337
- /**
338
- * What a placement's view needs of a builder: `submodel`, and `OnClick` to
339
- * read its Message from. A wrapper of Foldkit's builder that keeps both, such
340
- * as `foldkit-ssr`'s resumable builder, is one.
341
- */
342
- type BuilderLike = Pick<HtmlBuilder<any>, 'submodel' | 'OnClick'>;
343
- 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;
344
- /** A readable type error: intersected onto a parameter, its message names the fix. */
345
- interface Invalid<Message extends string> {
346
- readonly invalid: Message;
347
- }
348
- type BuilderMessage<H> = H extends {
349
- readonly OnClick: (message: infer M, ...rest: any) => any;
350
- } ? M : never;
351
- /**
352
- * The parent's `h`, checked to accept this placement's Messages. Generic over the
353
- * whole builder rather than its Message: inferring a Message through
354
- * `HtmlBuilder` costs thousands of type instantiations per call, while the
355
- * builder infers as itself and its Message is extracted once per builder type.
356
- */
357
- 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">);
358
- /** The tag of a Link's parent variant, or `string` when it cannot be read. */
359
- type TagOf<LinkMessage> = LinkMessage extends {
360
- readonly _tag: infer Tag extends string;
361
- } ? Tag : string;
362
- //#endregion
363
- //#region ../bundle/src/link.d.ts
364
- declare const LinkTypeId: unique symbol;
365
- /** The parent Message variant `Tag({ message })` that carries a child's Messages. */
366
- type Wrapped<Tag extends string, ChildMessage> = {
367
- readonly _tag: Tag;
368
- readonly message: ChildMessage;
369
- };
370
- /**
371
- * Both directions between a child Message and its parent variant. Spread
372
- * `cases` into the parent's `defineMessageUnion` so the variant is part of the
373
- * parent Message.
374
- */
375
- interface Wrapper<Tag extends string, ChildMessage> {
376
- readonly tag: Tag;
377
- readonly Schema: CallableTaggedStruct<Tag, {
378
- readonly message: Schema.Codec<ChildMessage, unknown>;
379
- }>;
380
- readonly cases: { readonly [K in Tag]: {
381
- readonly message: Schema.Codec<ChildMessage, unknown>;
382
- }; };
383
- readonly make: (message: ChildMessage) => Wrapped<Tag, ChildMessage>;
384
- readonly toParentMessage: (message: ChildMessage) => Wrapped<Tag, ChildMessage>;
385
- readonly fromParentMessage: (message: AnyMessage) => Option.Option<ChildMessage>;
386
- }
387
- /** Every Foldkit Message is tagged; routing only needs the tag. */
388
- type AnyMessage = {
389
- readonly _tag: string;
390
- };
391
- /**
392
- * `Field` is the parent's top-level field the child is written into, when the
393
- * Link is one: `never` for a child nested deeper, and `string` when unknown.
394
- */
395
- interface Link<Parent, ParentMessage, Child, ChildMessage, Field extends string = string> extends Pipeable.Pipeable {
396
- readonly [LinkTypeId]: typeof LinkTypeId;
397
- /** Types only: the top-level field, so `placements.initial` knows who writes it. */
398
- readonly field?: Field;
399
- readonly read: (parent: Parent) => Option.Option<Child>;
400
- readonly write: (parent: Parent, child: Child) => Parent;
401
- readonly toParentMessage: (message: ChildMessage) => ParentMessage;
402
- /** Recognises this child's variant among all of the parent's Messages. */
403
- readonly fromParentMessage: (message: AnyMessage) => Option.Option<ChildMessage>;
404
- /** The parent's own gate: while it returns `false`, the child's Subscriptions and resources stop. */
405
- readonly when: Option.Option<(parent: Parent) => boolean>;
406
- /** Where the child lives, for placement keys and diagnostics. */
407
- readonly path: ReadonlyArray<string>;
408
- /** The parent Message tags this link's Messages travel under, outermost first. */
409
- readonly messages: ReadonlyArray<string>;
410
- /** The application a Link built from a Surface field ref belongs to, for its Module contract. */
411
- readonly owner?: object | undefined;
412
- }
413
- /** A Message union's variant `Tag({ message })`, as `defineMessageUnion` declares it. */
414
- type Variant = {
415
- readonly fields: {
416
- readonly _tag: Schema.tag<string>;
417
- readonly message: Schema.Top;
418
- };
419
- };
420
- type VariantTag<V extends Variant> = V['fields']['_tag'] extends Schema.tag<infer Tag extends string> ? Tag : never;
421
- 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'>;
422
- /**
423
- * The parent variant `Tag({ message })` for a child's Messages: from a tag and
424
- * the child's Message Schema, whose `cases` then go into the parent's union, or
425
- * from a variant the parent's union already declares.
426
- */
427
- declare function wrapper<const Tag extends string, ChildMessage>(tag: Tag, childMessage: Schema.Codec<ChildMessage, unknown>): Wrapper<Tag, ChildMessage>;
428
- declare function wrapper<V extends Variant>(variant: V & OnlyMessage<V>): Wrapper<VariantTag<V>, V['fields']['message']['Type']>;
429
- interface MakeConfig<Parent, Tag extends string, Child, ChildMessage, Path> {
430
- readonly read: (parent: Parent) => Option.Option<Child>;
431
- readonly write: (parent: Parent, child: Child) => Parent;
432
- readonly wrapper: Wrapper<Tag, ChildMessage>;
433
- readonly when?: (parent: Parent) => boolean;
434
- readonly path: Path;
435
- readonly owner?: object | undefined;
436
- }
437
- /**
438
- * The top-level field a path names. `initial` treats a one-segment path as the
439
- * field the placement writes, so a longer one names none.
440
- */
441
- type FieldOfPath<Path> = Path extends readonly [infer Field extends string] ? Field : Path extends readonly [string, ...ReadonlyArray<string>] ? never : string;
442
- type OptionKeys<Parent> = { [K in keyof Parent]: Parent[K] extends Option.Option<unknown> ? K : never; }[keyof Parent] & string;
443
- type OptionValue<A> = A extends Option.Option<infer Value> ? Value : never;
444
- /** The parent Message variant `Tag({ key, message })` that carries one collection item's Messages. */
445
- type KeyedWrapped<Tag extends string, ChildMessage, Key extends string = string> = {
446
- readonly _tag: Tag;
447
- readonly key: Key;
448
- readonly message: ChildMessage;
449
- };
450
- type KeyedFields<ChildMessage, Key extends string> = {
451
- readonly key: Schema.Codec<Key, string>;
452
- readonly message: Schema.Codec<ChildMessage, unknown>;
453
- };
454
- /** Both directions between an item's Message and its keyed parent variant. */
455
- interface KeyedWrapper<Tag extends string, ChildMessage, Key extends string = string> {
456
- readonly tag: Tag;
457
- readonly Schema: CallableTaggedStruct<Tag, KeyedFields<ChildMessage, Key>>;
458
- readonly cases: { readonly [K in Tag]: KeyedFields<ChildMessage, Key>; };
459
- readonly make: (key: Key, message: ChildMessage) => KeyedWrapped<Tag, ChildMessage, Key>;
460
- readonly fromParentMessage: (message: AnyMessage) => Option.Option<readonly [key: Key, message: ChildMessage]>;
461
- }
462
- /**
463
- * Where a keyed collection of children lives. The storage is the Link's
464
- * business: a record by key, an array identified by id, or anything with these
465
- * operations. `entries` is the order views and Subscriptions follow.
294
+ * ```ts
295
+ * Editor.bundle.pipe(Bundle.withView(Cms.editorView(FormView.submodel(form, view))))
296
+ * ```
466
297
  */
467
- interface CollectionLink<Parent, ParentMessage, Child, ChildMessage, Key extends string = string, Field extends string = string> {
468
- /** Types only: the top-level field holding the items, or `string` when unknown. */
469
- readonly field?: Field;
470
- /** The storage with no items, for a parent's initial Model. */
471
- readonly empty: unknown;
472
- readonly entries: (parent: Parent) => ReadonlyArray<readonly [key: Key, child: Child]>;
473
- readonly get: (parent: Parent, key: Key) => Option.Option<Child>;
474
- /** Writes one item; `None` removes it. */
475
- readonly write: (parent: Parent, key: Key, child: Option.Option<Child>) => Parent;
476
- readonly toParentMessage: (key: Key, message: ChildMessage) => ParentMessage;
477
- readonly fromParentMessage: (message: AnyMessage) => Option.Option<readonly [key: Key, message: ChildMessage]>;
478
- /** The parent's gate per item: while it returns `false`, that item's Subscriptions stop. */
479
- readonly when: Option.Option<(parent: Parent, key: Key) => boolean>;
480
- readonly path: ReadonlyArray<string>;
481
- /** The parent Message tag this collection's Messages travel under. */
482
- readonly messages: ReadonlyArray<string>;
483
- }
484
- type RecordKeys<Parent> = { [K in keyof Parent]: Parent[K] extends Readonly<Record<string, unknown>> ? K : never; }[keyof Parent] & string;
485
- type RecordValue<A> = A extends Readonly<Record<string, infer Value>> ? Value : never;
486
- type ArrayKeys<Parent> = { [K in keyof Parent]: Parent[K] extends ReadonlyArray<unknown> ? K : never; }[keyof Parent] & string;
487
- type ArrayItem<A> = A extends ReadonlyArray<infer Item> ? Item : never;
488
- declare const Link: {
489
- readonly wrapper: typeof wrapper;
490
- 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>>;
491
- readonly field: <Parent>() => <const Key extends keyof Parent & string, const Tag extends string, ChildMessage>(key: Key, wrap: Wrapper<Tag, ChildMessage>, options?: {
492
- readonly when?: (parent: Parent) => boolean;
493
- }) => Link<Parent, Wrapped<Tag, ChildMessage>, Parent[Key], ChildMessage, Key>;
494
- readonly optional: <Parent>() => <const Key extends OptionKeys<Parent>, const Tag extends string, ChildMessage>(key: Key, wrap: Wrapper<Tag, ChildMessage>, options?: {
495
- readonly when?: (parent: Parent) => boolean;
496
- }) => Link<Parent, Wrapped<Tag, ChildMessage>, OptionValue<Parent[Key]>, ChildMessage, Key>;
497
- 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>;
498
- readonly andThen: {
499
- <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>;
500
- <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>;
501
- };
502
- readonly when: {
503
- <Parent>(predicate: (parent: Parent) => boolean): <ParentMessage, Child, ChildMessage, Field extends string>(self: Link<Parent, ParentMessage, Child, ChildMessage, Field>) => Link<Parent, ParentMessage, Child, ChildMessage, Field>;
504
- <Parent, ParentMessage, Child, ChildMessage, Field extends string>(self: Link<Parent, ParentMessage, Child, ChildMessage, Field>, predicate: (parent: Parent) => boolean): Link<Parent, ParentMessage, Child, ChildMessage, Field>;
505
- };
506
- readonly foldInit: <Parent, ParentMessage, Child, ChildMessage, Field extends string>(link: Link<Parent, ParentMessage, Child, ChildMessage, Field>, rest: Omit<Parent, Field>) => {
507
- readonly toParentModel: (child: Child) => Parent;
508
- readonly toParentMessage: (message: ChildMessage) => ParentMessage;
509
- };
510
- 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>;
511
- readonly collection: <Parent>() => <const Field extends RecordKeys<Parent>, const Tag extends string, ChildMessage, Key extends string>(field: Field, wrap: KeyedWrapper<Tag, ChildMessage, Key>, options?: {
512
- readonly when?: (parent: Parent, key: Key) => boolean;
513
- }) => CollectionLink<Parent, KeyedWrapped<Tag, ChildMessage, Key>, RecordValue<Parent[Field]>, ChildMessage, Key, Field>;
514
- readonly collectionById: <Parent>() => <const Field extends ArrayKeys<Parent>, const Tag extends string, ChildMessage, Key extends string>(field: Field, wrap: KeyedWrapper<Tag, ChildMessage, Key>, options: {
515
- readonly id: (item: ArrayItem<Parent[Field]>) => Key;
516
- readonly when?: (parent: Parent, key: Key) => boolean;
517
- }) => CollectionLink<Parent, KeyedWrapped<Tag, ChildMessage, Key>, ArrayItem<Parent[Field]>, ChildMessage, Key, Field>;
518
- readonly child: <Parent, ParentMessage, Child, ChildMessage, Services>(link: Link<Parent, ParentMessage, Child, ChildMessage, string>, update: (model: Child, message: ChildMessage) => Update.Return<Child, ChildMessage, Services>, view: (model: Child, h: HtmlBuilder<ChildMessage>) => Html, slotId: string) => {
519
- readonly update: (parent: Parent, message: ChildMessage) => Update.Return<Parent, ParentMessage, Services>;
520
- readonly view: PlacedView<Parent, ParentMessage, void>;
521
- };
522
- };
523
- //#endregion
524
- //#region ../bundle/src/collection.d.ts
525
- declare const PlacedCollectionTypeId: unique symbol;
526
- interface EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string, ParentSeed = Parent> {
527
- /**
528
- * The args every item's `init` and `update` receive: a static value, or a
529
- * factory from the parent seed, computed once per initialization and
530
- * retained. Adding items requires `initial`/`config` to have run; `update`
531
- * on a Model no initialization produced derives per use instead.
532
- */
533
- readonly args?: ArgsSource<ParentSeed, Args>;
534
- /** Handles an item's OutMessage in parent terms, with the item already written back. */
535
- readonly onOut?: (outMessage: OutMessage, key: Key, context: Update.FoldContext<Message, LinkMessage>) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
536
- /** Observes each item's Messages in parent terms, after the item has handled it and its `onOut` has run. */
537
- readonly onMessage?: (message: Message, key: Key) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
538
- /** Prefix for the collection's Subscription keys. Defaults to `Name@path[]`. */
539
- readonly key?: string;
540
- readonly when?: (parent: Parent, key: Key) => boolean;
541
- }
542
- 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;
543
- 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; };
544
- 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> {
545
- readonly [PlacedCollectionTypeId]: typeof PlacedCollectionTypeId;
546
- /** Types only: the record field this collection owns, or `string` when unknown. */
547
- readonly field?: Field;
548
- /** Types only: the parent Message tag this collection routes, or `string` when unknown. */
549
- readonly claims?: Claimed;
550
- readonly name: Name;
551
- /** `Name@path[]`, or the configured `key`: the prefix of every Subscription key. */
552
- readonly key: string;
553
- /** The encoded args as text, when the bundle has an args Schema. */
554
- readonly argsSummary: string | undefined;
555
- /** Whether `args` was given as a seed factory; resolved once per initialization. */
556
- readonly hasDynamicArgs: boolean;
557
- /**
558
- * Derives the factory's args from `seed` and retains them for `add`,
559
- * `update`, and Subscriptions. A no-op for static args.
560
- */
561
- readonly resolveArgs: (seed: unknown) => void;
562
- readonly link: CollectionLink<Parent, ParentMessage, Model, Message, Key>;
563
- /** Folds the Message into its item; `None` when it is not this collection's. A missing key leaves the parent unchanged. */
564
- readonly update: (parent: Parent, message: AnyMessage) => Option.Option<Update.Return<Parent, ParentMessage, R>>;
565
- /**
566
- * Writes a new item from `init` and starts its Commands. `prepare` adjusts the
567
- * initial Model first, for what only the parent knows, such as the item's id.
568
- * An existing item is replaced.
569
- */
570
- readonly add: (key: Key, prepare?: (model: Model) => Model) => Update.Step<Parent, ParentMessage, R>;
571
- /** Removes an item; its Subscriptions stop with it, and later Messages for it are ignored. */
572
- readonly remove: (key: Key) => Update.Step<Parent, ParentMessage, never>;
573
- readonly subscriptions: Subscription.Subscriptions<Parent, ParentMessage, S>;
574
- /** One item's view; nothing when the key is missing. */
575
- readonly view: CollectionView<Parent, ParentMessage, ViewInputs, Key>;
576
- /** Every item's view, in the order of the Link's `entries`. */
577
- readonly viewAll: <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, ...viewInputs: [ViewInputs] extends [void] ? [] : [viewInputs: ViewInputs]) => ReadonlyArray<Html>;
578
- readonly helpers: CollectionHelpers<Parent, ParentMessage, R, Helpers, Key>;
579
- }
298
+ declare const editorView: <FormModel, FormMessage, ViewInputs>(view: Submodel.View<FormModel, FormMessage, ViewInputs>) => Submodel.View<EditorModel<FormModel>, FormMessage | EditorMessage, ViewInputs>;
580
299
  //#endregion
581
- //#region ../bundle/src/bundle.d.ts
582
- /**
583
- * The parent seed a factory observes: the parent without the placement's own
584
- * field, or the whole parent where the field is unknown (`string`).
585
- */
586
- type SeedFor<Parent, Field extends string> = string extends Field ? Parent : Omit<Parent, Field>;
587
- declare const BundleTypeId: unique symbol;
588
- /** A child Managed Resource entry: its requirements are an `Option`, so the entry can release. */
589
- type ResourceEntry<Model, Message> = ManagedResource.Entry<Model, Message, Option.Option<any>, any, any>;
590
- type ResourceEntries<Model, Message> = Readonly<Record<string, ResourceEntry<Model, Message>>>;
591
- /** A programmatic entry point, like `Dialog.open`: the child Model plus any input. */
592
- type Helper<Model, Message, OutMessage, R> = (model: Model, ...input: ReadonlyArray<any>) => Update.ReturnWithOutMessage<Model, Message, OutMessage, R>;
593
- interface BundleSpec<Name extends string, Args, Model, Message extends AnyMessage, OutMessage, R, S, ViewInputs, Resources extends ResourceEntries<Model, Message>, Helpers extends Readonly<Record<string, Helper<Model, Message, OutMessage, R>>>> {
594
- readonly name: Name;
595
- readonly Model: Schema.Codec<Model, unknown>;
596
- readonly Message: Schema.Codec<Message, unknown>;
597
- /**
598
- * The args Schema. When given, `Args` is inferred from it, a placement's args
599
- * are checked against it, and Module lists them.
600
- */
601
- readonly args?: Schema.Codec<Args, unknown>;
602
- /** Set by `with`: the bound args, encoded as text, for Module. */
603
- readonly preset?: string | undefined;
604
- /** Runs when the bundle is placed; its Commands start with the placement. */
605
- readonly init: (args: Args) => Update.Return<Model, Message, R>;
606
- readonly update: (model: Model, message: Message, args: Args) => Update.ReturnWithOutMessage<Model, Message, OutMessage, R>;
607
- readonly subscriptions?: (args: Args) => Subscription.Subscriptions<Model, Message, S>;
608
- readonly resources?: (args: Args) => Resources;
609
- readonly view?: Submodel.View<Model, Message, ViewInputs>;
610
- readonly helpers?: Helpers;
611
- }
612
- interface Bundle$1<Name extends string, Args, Model, Message extends AnyMessage, OutMessage, R, S, ViewInputs, Resources extends ResourceEntries<Model, Message>, Helpers extends Readonly<Record<string, Helper<Model, Message, OutMessage, R>>>> extends BundleSpec<Name, Args, Model, Message, OutMessage, R, S, ViewInputs, Resources, Helpers>, Pipeable.Pipeable {
613
- readonly [BundleTypeId]: typeof BundleTypeId;
614
- /**
615
- * A preset: the same bundle with its args bound, so placements need no `args`.
616
- * The args are checked against the args Schema when there is one.
617
- */
618
- readonly with: (args: Args) => Bundle$1<Name, void, Model, Message, OutMessage, R, S, ViewInputs, Resources, Helpers>;
619
- /** Places the bundle where `link` points. */
620
- 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>>;
621
- /** Places the bundle once per key of the collection `link` points at. */
622
- 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'>;
623
- }
300
+ //#region src/views.d.ts
301
+ /** Whether the entry's state is one of `tags`; an entry with no state yet is none of them. */
302
+ declare const stateIs: (state: Option.Option<State>, ...tags: ReadonlyArray<State['_tag']>) => boolean;
624
303
  /**
625
- * What placing needs: `args` when `init` takes them, and `onOut` when the
626
- * bundle has an OutMessage, so an OutMessage is never dropped by omission.
627
- * `args` is a static value or a factory from the parent seed (the parent
628
- * without this placement's own field); the seed type defaults to the whole
629
- * parent where the field is unknown.
304
+ * An entry's state as a badge: its tag is its color, its words the CMS's. The
305
+ * tag is in `stateAttribute`, as a list's state cell writes it.
630
306
  */
631
- type PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed = Parent> = {
632
- /** Prefix for the placement's Subscription and resource keys. Defaults to `Name@path`. */
633
- readonly key?: string;
634
- /** A gate beside the Link's own: the child's Subscriptions and resources run only while both hold. */
635
- readonly when?: (parent: Parent) => boolean;
636
- /** Observes each of the child's Messages in parent terms, after the child handled it. */
637
- readonly onMessage?: Required<PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>>['onMessage'];
638
- } & ([Args] extends [void] ? {
639
- readonly args?: never;
640
- } : {
641
- readonly args: ArgsSource<ParentSeed, Args>;
642
- }) & ([OutMessage] extends [never] ? {
643
- readonly onOut?: never;
644
- } : {
645
- readonly onOut: Required<PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>>['onOut'];
646
- });
647
- /** The config argument is optional only when it would be empty. */
648
- 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>];
649
- type EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string, ParentSeed = Parent> = {
650
- readonly key?: string;
651
- /** A gate per item beside the Link's own: an item's Subscriptions run only while both hold. */
652
- readonly when?: (parent: Parent, key: Key) => boolean;
653
- /** Observes each item's Messages in parent terms, after the item handled it. */
654
- readonly onMessage?: Required<EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>>['onMessage'];
655
- } & ([Args] extends [void] ? {
656
- readonly args?: never;
657
- } : {
658
- readonly args: ArgsSource<ParentSeed, Args>;
659
- }) & ([OutMessage] extends [never] ? {
660
- readonly onOut?: never;
661
- } : {
662
- readonly onOut: Required<EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>>['onOut'];
663
- });
664
- 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>];
665
- //#endregion
666
- //#region src/views.d.ts
307
+ declare const stateBadge: <M>(badge: SlotView.SlotBuilder<M>, h: HtmlBuilder<M>, state: Option.Option<State>) => Html;
667
308
  /** A published revision, as an editor's History lists it. */
668
309
  interface RevisionRow {
669
310
  readonly n: number;
@@ -685,6 +326,11 @@ type RevisionHistory = {
685
326
  } | {
686
327
  readonly _tag: 'Failed';
687
328
  };
329
+ declare const revisionsOf: <M, Value extends {
330
+ readonly revisions: ReadonlyArray<RevisionRow>;
331
+ }>(model: M, history: (model: M) => Option.Option<{
332
+ readonly read: (model: M) => RemoteData<Value>;
333
+ }>) => RevisionHistory;
688
334
  /** The builders `historyCard` reads. */
689
335
  interface HistoryCardSlots<M> {
690
336
  readonly card: SlotView.SlotBuilder<M>;
@@ -699,6 +345,31 @@ interface HistoryCardSlots<M> {
699
345
  readonly revisionMeta: SlotView.SlotBuilder<M>;
700
346
  readonly revisionRestore: SlotView.SlotBuilder<M>;
701
347
  }
348
+ /**
349
+ * What was published, newest first, as a timeline: each revision on a line
350
+ * down to the first, with when and by whom. The newest is marked Live while
351
+ * the entry is on the site; restoring it is offered only while a draft sits
352
+ * over it, since otherwise it changes nothing. A history still being read
353
+ * says so as a busy status, and one that failed as an alert, so neither is
354
+ * mistaken for nothing published nor read as plain text. A failed read is not
355
+ * retried on its own: given `onRetry`, a button sends it, drawn on the
356
+ * restore slot so no new builder is required of every studio. Who published
357
+ * is the application's to name (`authorName`), as only it knows its chairs.
358
+ */
359
+ declare const historyCard: <M>(slots: HistoryCardSlots<M>, h: HtmlBuilder<M>, history: RevisionHistory, entry: {
360
+ readonly state: Option.Option<State>;
361
+ readonly restore: (revision: number) => M;
362
+ readonly authorName: (name: string) => string;
363
+ /**
364
+ * Asks again after a failed read. Given, a failed history shows a button
365
+ * that sends it; a failed read is not retried on its own.
366
+ */
367
+ readonly onRetry?: M | undefined;
368
+ /** What the retry button says. Default `Try again`. */
369
+ readonly words?: {
370
+ readonly retry?: string | undefined;
371
+ } | undefined;
372
+ }) => Html;
702
373
  /** The builders `moreCard` reads. */
703
374
  interface MoreCardSlots<M> {
704
375
  readonly card: SlotView.SlotBuilder<M>;
@@ -707,52 +378,48 @@ interface MoreCardSlots<M> {
707
378
  readonly button: SlotView.SlotBuilder<M>;
708
379
  readonly danger: SlotView.SlotBuilder<M>;
709
380
  }
710
- //#endregion
711
- //#region src/kinds.d.ts
712
- interface StateWords {
713
- readonly New?: string;
714
- readonly Published?: string;
715
- readonly Changed?: string;
716
- readonly Unpublished?: string;
717
- readonly Archived?: string;
718
- readonly scheduled?: string;
719
- readonly overdue?: string;
720
- /** A state with what its schedule adds: `{state}` and `{schedule}`. */
721
- readonly withSchedule?: string;
722
- }
723
- /** What `foldkit-mixins-form` gives a control's renderer, as far as these read it. */
724
- interface ControlContext<Message> {
725
- readonly control: Control;
726
- readonly draft: Draft;
727
- readonly change: (value: Draft) => Message;
728
- readonly blurred: Message;
729
- readonly state: ReadonlyArray<Attribute<Message>>;
730
- readonly slots: {
731
- readonly text: {
732
- readonly attrs: (attrs: ReadonlyArray<any>) => any;
733
- };
734
- readonly group: {
735
- readonly attrs: () => any;
736
- };
737
- readonly affix: {
738
- readonly attrs: () => any;
739
- };
740
- };
741
- readonly h: HtmlBuilder<Message>;
742
- }
743
- /** What `foldkit-mixins-crud` gives a display's renderer, as far as these read it. */
744
- interface DisplayContext<Message> {
745
- readonly display: {
746
- readonly kind: string;
747
- readonly text: (value: unknown, words: DisplayWords) => string;
748
- };
749
- readonly value: unknown;
750
- readonly words: DisplayWords;
751
- readonly h: HtmlBuilder<Message>;
752
- readonly badge: {
753
- readonly attrs: (attrs: ReadonlyArray<any>) => any;
381
+ /**
382
+ * The rest of what can happen to an entry: its draft discarded, taken off the
383
+ * site, put away or brought back. Discard and unpublish are each offered only
384
+ * where the server would allow them; archive is always offered, with unarchive
385
+ * taking its place once put away. None for something never saved, which has
386
+ * nothing to discard or put away. The archive button's icon is the
387
+ * application's, drawn its way.
388
+ */
389
+ declare const moreCard: <M>(slots: MoreCardSlots<M>, h: HtmlBuilder<M>, entry: {
390
+ readonly state: Option.Option<State>;
391
+ readonly may: (transition: Transition) => boolean;
392
+ readonly asks: {
393
+ readonly discard: M;
394
+ readonly unpublish: M;
395
+ readonly archive: M;
396
+ readonly unarchive: M;
754
397
  };
755
- }
398
+ readonly archiveIcon: Html;
399
+ }) => ReadonlyArray<Html>;
400
+ //#endregion
401
+ //#region src/slug.d.ts
402
+ /**
403
+ * A form check that says, while the author types, what a publish would refuse:
404
+ * this address belongs to something else. It asks the content type's `bySlug`
405
+ * query, which an author reads through the same binding as everyone else — so it
406
+ * sees unpublished rows too, and an address taken by work not yet shown is taken.
407
+ *
408
+ * It is named by the content type, not given it, so a form can be made with it
409
+ * before the content type that nests the form exists.
410
+ *
411
+ * Put it in the form's `checks` under the slug key:
412
+ * `checks: { slug: Cms.addressFree('posts') }`. The form must know which row it
413
+ * is editing for the row to keep its own address; `Cms.editor` tells it.
414
+ *
415
+ * This is advice, and deliberately not the rule. Two authors can both be told an
416
+ * address is free and both publish; the server refuses the second on the same
417
+ * key, through `Form.Message.Refused`. Asking earlier makes that rarer, never
418
+ * impossible.
419
+ */
420
+ declare const addressFree: (content: string) => ((slug: string, context: {
421
+ readonly subject: Readonly<Record<string, string>>;
422
+ }) => Effect.Effect<string | undefined, never, RemoteClient>);
756
423
  //#endregion
757
424
  //#region src/index.d.ts
758
425
  /** The members of an Entity that play a part a CMS knows: by key. */
@@ -820,194 +487,6 @@ export interface Content<Name extends string, E extends AnyEntity, Value, Target
820
487
  readonly preview?: ((value: Partial<Value>, id: string) => ReadonlyArray<OptimisticOperation>) | undefined;
821
488
  }
822
489
  export declare const Cms: {
823
- /**
824
- * The authoring editor of a content type: its form, the entry, and the draft
825
- * that keeps what the author has entered. Saving is automatic and is not
826
- * publishing; publishing submits the form.
827
- */
828
- editor: <const Name extends string, FormModel, FormMessage extends {
829
- readonly _tag: string;
830
- }, Value, Resources = {}, Services = never>(name: Name, config: {
831
- readonly content: EditorContent<FormModel, FormMessage, Value, Resources, Services>;
832
- readonly rest?: import("effect/Duration").Input;
833
- readonly version?: string;
834
- readonly untitled?: string;
835
- }) => {
836
- bundle: Bundle$1<Name, void, EditorModel<FormModel>, FormMessage | {
837
- readonly _tag: "Rested";
838
- readonly edit: number;
839
- } | {
840
- readonly _tag: "PublishAsked";
841
- } | {
842
- readonly _tag: "PreviewShown";
843
- } | {
844
- readonly _tag: "PreviewHidden";
845
- } | {
846
- readonly _tag: "ScheduleAsked";
847
- readonly at: string;
848
- } | {
849
- readonly _tag: "UnscheduleAsked";
850
- } | {
851
- readonly _tag: "ArchiveAsked";
852
- } | {
853
- readonly _tag: "UnarchiveAsked";
854
- } | {
855
- readonly _tag: "DiscardAsked";
856
- } | {
857
- readonly _tag: "RestoreAsked";
858
- readonly revision: number;
859
- } | {
860
- readonly _tag: "UnpublishAsked";
861
- } | {
862
- readonly _tag: "ReloadAsked";
863
- } | {
864
- readonly _tag: "OverwriteAsked";
865
- }, EditorOut, Services, Services, void, [keyof Resources] extends [never] ? {} : Readonly<Record<string, never>>, {
866
- open: (_: EditorModel<FormModel>, entry: string) => {
867
- model: {
868
- mode: "edit";
869
- entry: string;
870
- form: FormModel;
871
- filled: boolean;
872
- resumed: Resumed | null;
873
- edits: number;
874
- savedEdit: number;
875
- saveId: string | null;
876
- saveWanted: boolean;
877
- publishId: string | null;
878
- publishWanted: boolean;
879
- submit: "idle" | "waiting" | "stopped";
880
- scheduleAt: string | null;
881
- otherId: string | null;
882
- previewing: boolean;
883
- previewedAs: string | null;
884
- settling: "reload" | "overwrite" | null;
885
- };
886
- };
887
- create: (_: EditorModel<FormModel>, entry: string) => {
888
- model: {
889
- mode: "new";
890
- entry: string;
891
- filled: boolean;
892
- resumed: "Blank";
893
- form: FormModel;
894
- edits: number;
895
- savedEdit: number;
896
- saveId: string | null;
897
- saveWanted: boolean;
898
- publishId: string | null;
899
- publishWanted: boolean;
900
- submit: "idle" | "waiting" | "stopped";
901
- scheduleAt: string | null;
902
- otherId: string | null;
903
- previewing: boolean;
904
- previewedAs: string | null;
905
- settling: "reload" | "overwrite" | null;
906
- };
907
- };
908
- close: () => {
909
- model: EditorModel<FormModel>;
910
- };
911
- }>;
912
- Message: import("foldkit/message").MessageUnion<{
913
- readonly Rested: {
914
- readonly edit: Schema.Number;
915
- };
916
- readonly PublishAsked: {};
917
- readonly PreviewShown: {};
918
- readonly PreviewHidden: {};
919
- readonly ScheduleAsked: {
920
- readonly at: Schema.String;
921
- };
922
- readonly UnscheduleAsked: {};
923
- readonly ArchiveAsked: {};
924
- readonly UnarchiveAsked: {};
925
- readonly DiscardAsked: {};
926
- readonly RestoreAsked: {
927
- readonly revision: Schema.Number;
928
- };
929
- readonly UnpublishAsked: {};
930
- readonly ReloadAsked: {};
931
- readonly OverwriteAsked: {};
932
- }>;
933
- formTag: string;
934
- at: <Root>(where: {
935
- readonly data: EditorDomain<Root>;
936
- readonly model: import("foldkit-surface").ModelRef<Root, EditorModel<FormModel>>;
937
- }) => {
938
- onOut: (out: EditorOut) => import("foldkit/update").Step<Root, import("foldkit-remote").RemoteMessage, import("foldkit-remote").RemoteClient>;
939
- actives: Readonly<Record<`${Name}.${"entry" | "state" | "draft" | "row"}`, import("foldkit-surface").ActiveSurface<Root>>>;
940
- sync: import("foldkit/update").Step<Root, import("foldkit-remote").RemoteMessage, import("foldkit-remote").RemoteClient>;
941
- flush: (root: Root) => Readonly<{
942
- model: Root;
943
- commands?: import("foldkit/update").Commands<import("foldkit-remote").RemoteMessage, import("foldkit-remote").RemoteClient>;
944
- outMessage?: never;
945
- }>;
946
- after: <Message, Result extends {
947
- readonly model: Root;
948
- readonly commands?: ReadonlyArray<any>;
949
- }>(update: (model: Root, message: Message) => Result) => (model: Root, message: Message) => Result;
950
- canPreview: boolean;
951
- previewing: (root: Root) => boolean;
952
- pageId: (root: Root) => import("effect/Option").Option<string>;
953
- entry: (root: Root) => import("effect/Option").Option<string>;
954
- storedEntry: (root: Root) => import("effect/Option").Option<string>;
955
- resumed: (root: Root) => import("effect/Option").Option<Resumed>;
956
- state: (root: Root) => import("effect/Option").Option<State>;
957
- may: (root: Root, transition: Transition) => boolean;
958
- error: (root: Root) => import("effect/Option").Option<import("foldkit-remote").RemoteError>;
959
- status: (root: Root) => EditorStatus;
960
- };
961
- };
962
- /** A form's Submodel view as its editor's, for `Bundle.withView`. */
963
- editorView: <FormModel, FormMessage, ViewInputs>(view: import("foldkit/submodel").View<FormModel, FormMessage, ViewInputs>) => import("foldkit/submodel").View<EditorModel<FormModel>, FormMessage | EditorMessage, ViewInputs>;
964
- /**
965
- * The entry-level views every studio draws, on its own slot builders: its
966
- * state badge, its published revisions, what was published, and the rest of
967
- * what can happen to it. Words for states come from `Cms.Display`, so a
968
- * studio and its lists say them one way.
969
- */
970
- stateBadge: <M>(badge: import("foldkit-mixins").SlotBuilder<M>, h: import("foldkit/html").HtmlBuilder<M>, state: import("effect/Option").Option<State>) => import("foldkit/html").Html;
971
- /**
972
- * The attribute every state the CMS draws is written in, `data-cms-state`:
973
- * a badge's tone rules select on it, `[${Cms.stateAttribute}="Published"]`.
974
- */
975
- stateAttribute: string;
976
- /** Whether the entry's state is one of the given tags; no state yet is none of them. */
977
- stateIs: (state: import("effect/Option").Option<State>, ...tags: ReadonlyArray<State["_tag"]>) => boolean;
978
- revisionsOf: <M, Value extends {
979
- readonly revisions: ReadonlyArray<RevisionRow>;
980
- }>(model: M, history: (model: M) => import("effect/Option").Option<{
981
- readonly read: (model: M) => import("foldkit-remote").RemoteData<Value>;
982
- }>) => RevisionHistory;
983
- historyCard: <M>(slots: HistoryCardSlots<M>, h: import("foldkit/html").HtmlBuilder<M>, history: RevisionHistory, entry: {
984
- readonly state: import("effect/Option").Option<State>;
985
- readonly restore: (revision: number) => M;
986
- readonly authorName: (name: string) => string;
987
- readonly onRetry?: M | undefined;
988
- readonly words?: {
989
- readonly retry? /** The form's whole Model, encoded: what resumes unfinished work. */ : string | undefined;
990
- } | undefined;
991
- }) => import("foldkit/html").Html;
992
- moreCard: <M>(slots: MoreCardSlots<M>, h: import("foldkit/html").HtmlBuilder<M>, entry: {
993
- readonly state: import("effect/Option").Option<State>;
994
- readonly may: (transition: Transition) => boolean;
995
- readonly asks: {
996
- readonly discard: M;
997
- readonly unpublish: M;
998
- readonly archive: M;
999
- readonly unarchive: M;
1000
- };
1001
- readonly archiveIcon: import("foldkit/html").Html;
1002
- }) => ReadonlyArray<import("foldkit/html").Html>;
1003
- /** The state of an entry, from what is known of it and a clock. */
1004
- state: (facts: Facts, now: Date) => State;
1005
- /** Every transition an author may ask, in order: what `allow` is asked about. */
1006
- transitions: readonly ["save", "discard", "publish", "schedule", "unschedule", "unpublish", "archive", "unarchive", "restore"];
1007
- /** The transitions an entry offers now, before anyone asks who is asking. */
1008
- offers: (facts: Facts, now: Date, content: {
1009
- readonly roles: Roles;
1010
- }) => ReadonlyArray<Transition>;
1011
490
  Input: {
1012
491
  Slug: import("foldkit-form").ControlKind<{
1013
492
  readonly prefix: string;
@@ -1023,7 +502,7 @@ export declare const Cms: {
1023
502
  readonly locale?: string | undefined;
1024
503
  }>;
1025
504
  };
1026
- slugify: (text: string) => string;
505
+ slugify: typeof slugify;
1027
506
  slug: (from: string, options?: {
1028
507
  readonly prefix?: string;
1029
508
  readonly through?: (text: string) => string;
@@ -1047,12 +526,12 @@ export declare const Cms: {
1047
526
  content: <const Name extends string, E extends AnyEntity, Value, TargetId extends string = string, F extends ContentForm<NoInfer<E>, Value> = ContentForm<NoInfer<E>, Value>>(name: Name, config: {
1048
527
  readonly entity: E;
1049
528
  readonly form: F & ContentForm<NoInfer<E>, Value>;
1050
- readonly publish: Content<Name, E, NoInfer<Value>, TargetId>["publish"];
529
+ readonly publish: Content<Name, E, NoInfer<Value>, TargetId>['publish'];
1051
530
  readonly words: {
1052
531
  readonly one: string;
1053
532
  readonly many: string;
1054
533
  };
1055
- readonly preview?: Content<Name, E, NoInfer<Value>, TargetId>["preview"];
534
+ readonly preview?: Content<Name, E, NoInfer<Value>, TargetId>['preview'];
1056
535
  }) => Content<Name, E, Value, TargetId, F>;
1057
536
  /** An id for something new, made where it is written: the first save of it makes the entry. */
1058
537
  newEntryId: () => EntryId;
@@ -1117,7 +596,7 @@ export declare const Cms: {
1117
596
  }, {}, {}>;
1118
597
  }, {
1119
598
  readonly Entry: {
1120
- readonly draft: import("foldkit-entity").RelationSpec<Entity<"CmsDraft", {
599
+ draft: import("foldkit-entity").RelationSpec<Entity<"CmsDraft", {
1121
600
  /** The entry's id: an entry has at most one draft. */
1122
601
  readonly id: Schema.brand<Schema.String, "CmsEntryId">;
1123
602
  /** The keys of the form's value that decode, as the operation's input encodes them. */
@@ -1133,7 +612,7 @@ export declare const Cms: {
1133
612
  readonly scheduledFor: Schema.NullOr<Schema.String>;
1134
613
  readonly scheduleError: Schema.NullOr<Schema.String>;
1135
614
  }, {}, {}>, "one", true>;
1136
- readonly revisions: import("foldkit-entity").RelationSpec<Entity<"CmsRevision", {
615
+ revisions: import("foldkit-entity").RelationSpec<Entity<"CmsRevision", {
1137
616
  readonly id: Schema.String;
1138
617
  readonly n: Schema.Number;
1139
618
  readonly values: Schema.Unknown;
@@ -1215,7 +694,7 @@ export declare const Cms: {
1215
694
  }, {}, {}>;
1216
695
  }, {
1217
696
  readonly Entry: {
1218
- readonly draft: import("foldkit-entity").RelationSpec<Entity<"CmsDraft", {
697
+ draft: import("foldkit-entity").RelationSpec<Entity<"CmsDraft", {
1219
698
  /** The entry's id: an entry has at most one draft. */
1220
699
  readonly id: Schema.brand<Schema.String, "CmsEntryId">;
1221
700
  /** The keys of the form's value that decode, as the operation's input encodes them. */
@@ -1231,7 +710,7 @@ export declare const Cms: {
1231
710
  readonly scheduledFor: Schema.NullOr<Schema.String>;
1232
711
  readonly scheduleError: Schema.NullOr<Schema.String>;
1233
712
  }, {}, {}>, "one", true>;
1234
- readonly revisions: import("foldkit-entity").RelationSpec<Entity<"CmsRevision", {
713
+ revisions: import("foldkit-entity").RelationSpec<Entity<"CmsRevision", {
1235
714
  readonly id: Schema.String;
1236
715
  readonly n: Schema.Number;
1237
716
  readonly values: Schema.Unknown;
@@ -1294,7 +773,7 @@ export declare const Cms: {
1294
773
  }, {}, {}>;
1295
774
  }, {
1296
775
  readonly Entry: {
1297
- readonly draft: import("foldkit-entity").RelationSpec<Entity<"CmsDraft", {
776
+ draft: import("foldkit-entity").RelationSpec<Entity<"CmsDraft", {
1298
777
  /** The entry's id: an entry has at most one draft. */
1299
778
  readonly id: Schema.brand<Schema.String, "CmsEntryId">;
1300
779
  /** The keys of the form's value that decode, as the operation's input encodes them. */
@@ -1310,7 +789,7 @@ export declare const Cms: {
1310
789
  readonly scheduledFor: Schema.NullOr<Schema.String>;
1311
790
  readonly scheduleError: Schema.NullOr<Schema.String>;
1312
791
  }, {}, {}>, "one", true>;
1313
- readonly revisions: import("foldkit-entity").RelationSpec<Entity<"CmsRevision", {
792
+ revisions: import("foldkit-entity").RelationSpec<Entity<"CmsRevision", {
1314
793
  readonly id: Schema.String;
1315
794
  readonly n: Schema.Number;
1316
795
  readonly values: Schema.Unknown;
@@ -1391,55 +870,55 @@ export declare const Cms: {
1391
870
  readonly updatedAt: string;
1392
871
  }, never>;
1393
872
  };
1394
- operations: (MutationDescriptor<"CmsSaveDraft", {
873
+ operations: (MutationDescriptor<"CmsArchive", {
1395
874
  readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1396
- readonly type: string;
1397
- readonly label: string;
1398
- readonly values: unknown;
1399
- readonly model: unknown;
1400
- readonly form: string;
1401
- readonly basedOn: string | null;
875
+ }, {}, never> | MutationDescriptor<"CmsDiscardDraft", {
876
+ readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
877
+ }, {}, never> | MutationDescriptor<"CmsPublish", {
878
+ readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
879
+ readonly basedOn: number | null;
1402
880
  }, {
1403
881
  readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1404
- readonly updatedAt: string;
882
+ readonly targetId: string;
883
+ readonly revision: number;
1405
884
  }, {
1406
885
  readonly _tag: "Field";
1407
886
  readonly key: string;
1408
887
  readonly reason: string;
1409
888
  } | {
1410
889
  readonly _tag: "Conflict";
1411
- }> | MutationDescriptor<"CmsDiscardDraft", {
890
+ }> | MutationDescriptor<"CmsRestore", {
1412
891
  readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1413
- }, {}, never> | MutationDescriptor<"CmsPublish", {
892
+ readonly revision: number;
893
+ }, {
894
+ readonly updatedAt: string;
895
+ }, never> | MutationDescriptor<"CmsSaveDraft", {
1414
896
  readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1415
- readonly basedOn: number | null;
897
+ readonly type: string;
898
+ readonly label: string;
899
+ readonly values: unknown;
900
+ readonly model: unknown;
901
+ readonly form: string;
902
+ readonly basedOn: string | null;
1416
903
  }, {
1417
904
  readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1418
- readonly targetId: string;
1419
- readonly revision: number;
905
+ readonly updatedAt: string;
1420
906
  }, {
1421
907
  readonly _tag: "Field";
1422
908
  readonly key: string;
1423
909
  readonly reason: string;
1424
910
  } | {
1425
911
  readonly _tag: "Conflict";
1426
- }> | MutationDescriptor<"CmsUnpublish", {
1427
- readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1428
- }, {}, never> | MutationDescriptor<"CmsSchedule", {
912
+ }> | MutationDescriptor<"CmsSchedule", {
1429
913
  readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1430
914
  readonly at: string;
1431
- }, {}, never> | MutationDescriptor<"CmsUnschedule", {
1432
- readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1433
- }, {}, never> | MutationDescriptor<"CmsArchive", {
1434
- readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1435
915
  }, {}, never> | MutationDescriptor<"CmsUnarchive", {
1436
916
  readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1437
- }, {}, never> | MutationDescriptor<"CmsRestore", {
917
+ }, {}, never> | MutationDescriptor<"CmsUnpublish", {
1438
918
  readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
1439
- readonly revision: number;
1440
- }, {
1441
- readonly updatedAt: string;
1442
- }, never>)[];
919
+ }, {}, never> | MutationDescriptor<"CmsUnschedule", {
920
+ readonly entry: string & import("effect/Brand").Brand<"CmsEntryId">;
921
+ }, {}, never>)[];
1443
922
  /**
1444
923
  * What a server refuses `SaveDraft` and `Publish` with: `refusal.field(key,
1445
924
  * reason)` for one key of the content's form, `refusal.conflict` for work
@@ -1477,9 +956,173 @@ export declare const Cms: {
1477
956
  * type's `bySlug` query registered, which `CmsServer` does for a content type
1478
957
  * with a slug role.
1479
958
  */
1480
- addressFree: (content: string) => ((slug: string, context: {
1481
- readonly subject: Readonly<Record<string, string>>;
1482
- }) => import("effect/Effect").Effect<string | undefined, never, import("foldkit-remote").RemoteClient>);
959
+ addressFree: typeof addressFree;
960
+ /**
961
+ * The authoring editor of a content type: its form, the entry, and the draft
962
+ * that keeps what the author has entered. Saving is automatic and is not
963
+ * publishing; publishing submits the form.
964
+ */
965
+ editor: <const Name extends string, FormModel, FormMessage extends {
966
+ readonly _tag: string;
967
+ }, Value, Resources = {}, Services = never>(name: Name, config: {
968
+ readonly content: EditorContent<FormModel, FormMessage, Value, Resources, Services>;
969
+ readonly rest?: import("effect/Duration").Input;
970
+ readonly version?: string;
971
+ readonly untitled?: string;
972
+ }) => {
973
+ bundle: import("foldkit-bundle").BundleShape<Name, void, EditorModel<FormModel>, FormMessage | {
974
+ readonly _tag: "ArchiveAsked";
975
+ } | {
976
+ readonly _tag: "DiscardAsked";
977
+ } | {
978
+ readonly _tag: "OverwriteAsked";
979
+ } | {
980
+ readonly _tag: "PreviewHidden";
981
+ } | {
982
+ readonly _tag: "PreviewShown";
983
+ } | {
984
+ readonly _tag: "PublishAsked";
985
+ } | {
986
+ readonly _tag: "ReloadAsked";
987
+ } | {
988
+ readonly _tag: "Rested";
989
+ readonly edit: number;
990
+ } | {
991
+ readonly _tag: "RestoreAsked";
992
+ readonly revision: number;
993
+ } | {
994
+ readonly _tag: "ScheduleAsked";
995
+ readonly at: string;
996
+ } | {
997
+ readonly _tag: "UnarchiveAsked";
998
+ } | {
999
+ readonly _tag: "UnpublishAsked";
1000
+ } | {
1001
+ readonly _tag: "UnscheduleAsked";
1002
+ }, EditorOut, Services, Services, void, [keyof Resources] extends [never] ? {} : Readonly<Record<string, never>>, {
1003
+ open: (_: EditorModel<FormModel>, entry: string) => {
1004
+ model: {
1005
+ form: FormModel;
1006
+ filled: boolean;
1007
+ resumed: Resumed | null;
1008
+ edits: number;
1009
+ savedEdit: number;
1010
+ saveId: string | null;
1011
+ saveWanted: boolean;
1012
+ publishId: string | null;
1013
+ publishWanted: boolean;
1014
+ submit: 'idle' | 'waiting' | 'stopped';
1015
+ scheduleAt: string | null;
1016
+ otherId: string | null;
1017
+ previewing: boolean;
1018
+ previewedAs: string | null;
1019
+ settling: 'reload' | 'overwrite' | null;
1020
+ mode: 'edit';
1021
+ entry: string;
1022
+ };
1023
+ };
1024
+ create: (_: EditorModel<FormModel>, entry: string) => {
1025
+ model: {
1026
+ form: FormModel;
1027
+ edits: number;
1028
+ savedEdit: number;
1029
+ saveId: string | null;
1030
+ saveWanted: boolean;
1031
+ publishId: string | null;
1032
+ publishWanted: boolean;
1033
+ submit: 'idle' | 'waiting' | 'stopped';
1034
+ scheduleAt: string | null;
1035
+ otherId: string | null;
1036
+ previewing: boolean;
1037
+ previewedAs: string | null;
1038
+ settling: 'reload' | 'overwrite' | null;
1039
+ mode: 'new';
1040
+ entry: string;
1041
+ filled: boolean;
1042
+ resumed: 'Blank';
1043
+ };
1044
+ };
1045
+ close: () => {
1046
+ model: EditorModel<FormModel>;
1047
+ };
1048
+ }>;
1049
+ Message: import("foldkit/message").MessageUnion<{
1050
+ readonly Rested: {
1051
+ edit: Schema.Number;
1052
+ };
1053
+ readonly PublishAsked: {};
1054
+ readonly PreviewShown: {};
1055
+ readonly PreviewHidden: {};
1056
+ readonly ScheduleAsked: {
1057
+ at: Schema.String;
1058
+ };
1059
+ readonly UnscheduleAsked: {};
1060
+ readonly ArchiveAsked: {};
1061
+ readonly UnarchiveAsked: {};
1062
+ readonly DiscardAsked: {};
1063
+ readonly RestoreAsked: {
1064
+ revision: Schema.Number;
1065
+ };
1066
+ readonly UnpublishAsked: {};
1067
+ readonly ReloadAsked: {};
1068
+ readonly OverwriteAsked: {};
1069
+ }>;
1070
+ formTag: string;
1071
+ at: <Root>(where: {
1072
+ readonly data: EditorDomain<Root>;
1073
+ readonly model: import("foldkit-surface").ModelRef<Root, EditorModel<FormModel>>;
1074
+ }) => {
1075
+ onOut: (out: EditorOut) => import("foldkit/update").Step<Root, import("foldkit-remote").RemoteMessage, import("foldkit-remote").RemoteClient>;
1076
+ actives: Readonly<Record<`${Name}.${'entry' | 'state' | 'draft' | 'row'}`, import("foldkit-surface").ActiveSurface<Root>>>;
1077
+ sync: import("foldkit/update").Step<Root, import("foldkit-remote").RemoteMessage, import("foldkit-remote").RemoteClient>;
1078
+ flush: (root: Root) => Readonly<{
1079
+ model: Root;
1080
+ commands?: import("foldkit/update").Commands<import("foldkit-remote").RemoteMessage, import("foldkit-remote").RemoteClient>;
1081
+ outMessage?: never;
1082
+ }>;
1083
+ after: <Message, Result extends {
1084
+ readonly model: Root;
1085
+ readonly commands?: ReadonlyArray<any>;
1086
+ }>(update: (model: Root, message: Message) => Result) => (model: Root, message: Message) => Result;
1087
+ canPreview: boolean;
1088
+ previewing: (root: Root) => boolean;
1089
+ pageId: (root: Root) => import("effect/Option").Option<string>;
1090
+ entry: (root: Root) => import("effect/Option").Option<string>;
1091
+ storedEntry: (root: Root) => import("effect/Option").Option<string>;
1092
+ resumed: (root: Root) => import("effect/Option").Option<Resumed>;
1093
+ state: (root: Root) => import("effect/Option").Option<State>;
1094
+ may: (root: Root, transition: Transition) => boolean;
1095
+ error: (root: Root) => import("effect/Option").Option<import("foldkit-remote").RemoteError>;
1096
+ status: (root: Root) => EditorStatus;
1097
+ };
1098
+ };
1099
+ /** A form's Submodel view as its editor's, for `Bundle.withView`. */
1100
+ editorView: typeof editorView;
1101
+ /**
1102
+ * The entry-level views every studio draws, on its own slot builders: its
1103
+ * state badge, its published revisions, what was published, and the rest of
1104
+ * what can happen to it. Words for states come from `Cms.Display`, so a
1105
+ * studio and its lists say them one way.
1106
+ */
1107
+ stateBadge: typeof stateBadge;
1108
+ /**
1109
+ * The attribute every state the CMS draws is written in, `data-cms-state`:
1110
+ * a badge's tone rules select on it, `[${Cms.stateAttribute}="Published"]`.
1111
+ */
1112
+ stateAttribute: string;
1113
+ /** Whether the entry's state is one of the given tags; no state yet is none of them. */
1114
+ stateIs: typeof stateIs;
1115
+ revisionsOf: typeof revisionsOf;
1116
+ historyCard: typeof historyCard;
1117
+ moreCard: typeof moreCard;
1118
+ /** The state of an entry, from what is known of it and a clock. */
1119
+ state: (facts: Facts, now: Date) => State;
1120
+ /** Every transition an author may ask, in order: what `allow` is asked about. */
1121
+ transitions: readonly ["save", "discard", "publish", "schedule", "unschedule", "unpublish", "archive", "unarchive", "restore"];
1122
+ /** The transitions an entry offers now, before anyone asks who is asking. */
1123
+ offers: (facts: Facts, now: Date, content: {
1124
+ readonly roles: Roles;
1125
+ }) => ReadonlyArray<Transition>;
1483
1126
  };
1484
1127
  //#endregion
1485
1128
  export type { ControlContext, DisplayContext, EditorContent, EditorDomain, EditorForm, EditorMessage, EditorModel, EditorOut, EditorStatus, Facts, HistoryCardSlots, MoreCardSlots, Resumed, RevisionHistory, RevisionRow, Schedule, State, StateTag, StateWords, Transition };