@knkcs/contenthub-ui 0.3.1 → 0.5.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/testing.d.ts CHANGED
@@ -14,6 +14,19 @@ declare interface BlockReason {
14
14
  updateTime: string;
15
15
  }
16
16
 
17
+ /** One Blueprint's override of the workspace's editing settings. */
18
+ declare interface BlueprintEditingOverride {
19
+ blueprintAccessor: string;
20
+ /** null follows the workspace's. */
21
+ editingMode: EditingMode | null;
22
+ /** null follows the workspace's. */
23
+ editingBlock: boolean | null;
24
+ /** The people beside the admins; null follows the workspace's, [] is the admins alone. */
25
+ forceGroup: string[] | null;
26
+ /** What applies to the Blueprint's Content: this override over the workspace's. */
27
+ effective: EditingSettings;
28
+ }
29
+
17
30
  /** A content Blueprint, as the `BlueprintSource` port names it. */
18
31
  declare interface BlueprintInfo {
19
32
  id: string;
@@ -72,6 +85,13 @@ declare interface BlueprintSource {
72
85
  /** What a Branch is for: one an editor works on, or a Carry-forward link. */
73
86
  declare type BranchKind = "editorial" | "carry_forward";
74
87
 
88
+ /** Whether a Direct Edit's change carries forward into one later wording (#270). */
89
+ declare interface CarryForwardAnswer {
90
+ /** The later wording: the Release a Carry-forward link carries. */
91
+ releaseId: string;
92
+ carry: boolean;
93
+ }
94
+
75
95
  /** What a Chain on Dated Content, effective on a date, would be and meet (PreviewChain). */
76
96
  declare interface ChainPreview {
77
97
  /** The Release it would fork from; "" in a gap. */
@@ -116,6 +136,10 @@ declare interface ChangeSet {
116
136
  * planned. Empty in a list.
117
137
  */
118
138
  plannedReleases: PlannedRelease[];
139
+ /** A Direct Edit, or one editors build; absent reads as "change_set". */
140
+ kind?: ChangeSetKind;
141
+ /** A Direct Edit's editor, an odon user id; absent or "" for any other kind. */
142
+ editorId?: string;
119
143
  }
120
144
 
121
145
  /** One Branch of a Chain, with the head a save on it names. */
@@ -151,6 +175,12 @@ declare interface ChangeSetChain {
151
175
  branches: ChangeSetBranch[];
152
176
  }
153
177
 
178
+ /**
179
+ * What kind of Change Set one is (ADR 0022): a Direct Edit, opened from one
180
+ * Content for one editor, or one editors build Chain by Chain.
181
+ */
182
+ declare type ChangeSetKind = "change_set" | "direct_edit";
183
+
154
184
  /** One page of `listChangeSets`. */
155
185
  declare interface ChangeSetList {
156
186
  changeSets: ChangeSet[];
@@ -307,6 +337,8 @@ declare interface ContentAttributes {
307
337
  block?: ContentBlock;
308
338
  /** When it was archived, ISO 8601; absent while it is not Archived. */
309
339
  archiveTime?: string;
340
+ /** Its Editing Block; absent while no open Direct Edit holds one. */
341
+ editingBlock?: EditingBlock;
310
342
  }
311
343
 
312
344
  /**
@@ -375,6 +407,10 @@ declare interface ContenthubClient {
375
407
  assigneeId?: string;
376
408
  /** Only those with a Chain on this Content. */
377
409
  contentId?: string;
410
+ /** Only those of this kind: the index asks for "change_set", hiding Direct Edits. */
411
+ kind?: ChangeSetKind;
412
+ /** Only the Direct Edits of this odon user. */
413
+ editorId?: string;
378
414
  /** At most 200; 50 when absent. */
379
415
  pageSize?: number;
380
416
  pageToken?: string;
@@ -457,6 +493,29 @@ declare interface ContenthubClient {
457
493
  id: string;
458
494
  reviewedHeads: Record<string, string>;
459
495
  }): Promise<PublishOutcome>;
496
+ /**
497
+ * Change validity (ADR 0022): corrects only a published Release's
498
+ * Validity Period, in one request and without a Direct Edit. It opens a
499
+ * Change Set, plans the date-only Release re-pinning the Release's
500
+ * Revision and superseding it, and publishes it with the proposals for
501
+ * the neighbouring Releases; the outcome is that Publish's. Refused as a
502
+ * whole, it leaves no Change Set behind: rejects with
503
+ * `EditingModeRefusedError` where the Content's Blueprint is "Change Sets
504
+ * only", `CoversReleaseError` (`changeSetRequired`) when the period would
505
+ * cover another Release entirely, `PublishRefusedError` with every
506
+ * blocker (an outstanding Required Check among them),
507
+ * `AccessDeniedError` for a caller who may not publish,
508
+ * `ContentBlockedError` and `InvalidInputError` for what else the service
509
+ * refuses.
510
+ */
511
+ changeValidity(input: {
512
+ releaseId: string;
513
+ validityPeriod: ValidityPeriod;
514
+ /** The Change Set's name; the service names it after the Content when absent. */
515
+ changeSetName?: string;
516
+ /** Makes a retry safe (CONTEXT.md, Idempotency Key). */
517
+ idempotencyKey?: string;
518
+ }): Promise<PublishOutcome>;
460
519
  /**
461
520
  * Merges what Main (and each dependency) gained since into every Chain
462
521
  * of the Change Set. A Branch whose merge has Conflicts, or fails its
@@ -549,6 +608,41 @@ declare interface ContenthubClient {
549
608
  requiredCheckId: string;
550
609
  recorder: RecorderGrant;
551
610
  }): Promise<void>;
611
+ /**
612
+ * How the workspace's Content may be changed (ADR 0022): its own Editing
613
+ * Mode and Editing Block, and every per-Blueprint override with the
614
+ * values it makes effective. A workspace that never set them reads as
615
+ * "Change Sets only" without an Editing Block.
616
+ */
617
+ getEditingSettings(): Promise<WorkspaceEditingSettings>;
618
+ /**
619
+ * The editing settings in effect for the Content of the Blueprint with
620
+ * `blueprintAccessor`: its override over the workspace's, field by
621
+ * field. A host's Blueprint page reads it.
622
+ */
623
+ getEffectiveEditingSettings(blueprintAccessor: string): Promise<EffectiveEditingSettings>;
624
+ /**
625
+ * Replaces the workspace's own editing settings; admin only. It takes
626
+ * effect at once. Rejects with `AccessDeniedError` for a non-admin and
627
+ * `InvalidInputError` for what the service refuses.
628
+ */
629
+ setEditingSettings(settings: EditingSettings): Promise<EditingSettings>;
630
+ /**
631
+ * Replaces one Blueprint's override; admin only. A null field follows the
632
+ * workspace's, and at least one must be set. Rejects as
633
+ * `setEditingSettings` does.
634
+ */
635
+ setBlueprintEditingOverride(input: {
636
+ blueprintAccessor: string;
637
+ editingMode: EditingMode | null;
638
+ editingBlock: boolean | null;
639
+ /** null follows the workspace's; [] is the admins alone. */
640
+ forceGroup: string[] | null;
641
+ }): Promise<BlueprintEditingOverride>;
642
+ /** Removes one Blueprint's override, so it follows the workspace's; admin only. */
643
+ deleteBlueprintEditingOverride(input: {
644
+ blueprintAccessor: string;
645
+ }): Promise<void>;
552
646
  /** Every Collection of the workspace, by name, then id: a tree by `parentId`. */
553
647
  listCollections(): Promise<Collection[]>;
554
648
  /**
@@ -803,6 +897,115 @@ declare interface ContenthubClient {
803
897
  * `ChangeSetClosedError`, and `InvalidInputError` for anything else the
804
898
  * service refuses (a missing or needless effective date).
805
899
  */
900
+ /**
901
+ * Opens a Direct Edit of a published Content for the caller (ADR 0022),
902
+ * or answers the one the caller has open on it, with `reopened`. Answers
903
+ * the Direct Edit and the Content as read on its Branch. Rejects with
904
+ * `EditingModeRefusedError` where the Editing Mode is "Change Sets only",
905
+ * `DirectEditRefusedError` where another editor's Direct Edit holds its
906
+ * Editing Block (naming them), `ContentBlockedError`, `ContentArchivedError`,
907
+ * and `InvalidInputError` for anything else the service refuses (a day
908
+ * for undated Content among it).
909
+ */
910
+ openDirectEdit(input: {
911
+ contentId: string;
912
+ /**
913
+ * Dated Content only (#270): the day the change takes effect, as
914
+ * YYYY-MM-DD; absent is today. Its Branch forks from the Release In
915
+ * Force that day: on today it corrects that Release, on a later day
916
+ * it is a new wording.
917
+ */
918
+ effectiveOn?: string;
919
+ /** Makes a retry safe (CONTEXT.md, Idempotency Key). */
920
+ idempotencyKey?: string;
921
+ }): Promise<{
922
+ changeSet: ChangeSet;
923
+ content: Content;
924
+ reopened: boolean;
925
+ }>;
926
+ /**
927
+ * What a Direct Edit's Publish of Dated Content would plan (#270): its
928
+ * Release's Validity Period with `validityLastDay` as Publish takes it,
929
+ * the Release it corrects, the date-only Releases contenthub derives and
930
+ * the later wordings Publish asks about. Writes nothing. Rejects with
931
+ * `CoversReleaseError` (`changeSetRequired`) when the period would cover
932
+ * a Release entirely.
933
+ */
934
+ previewDirectEditPublish(input: {
935
+ id: string;
936
+ validityLastDay?: string;
937
+ }): Promise<DirectEditPublishPreview>;
938
+ /**
939
+ * Publishes a Direct Edit at `expectedHeadId`, the head of its Branch the
940
+ * editor saw: one Release, In Force from its Publish, carrying
941
+ * `releaseSpec`. Rejects as `publish` does, with `ContentRefusedError`
942
+ * for Release Spec values the Blueprint Release refuses (a required one
943
+ * missing among them), and with `DirectEditRefusedError` for a Change
944
+ * Set that is not a Direct Edit. On Dated Content (#270) it takes the
945
+ * Validity Period's last day and one carry-forward answer per later
946
+ * wording, and rejects with `CoversReleaseError` (`changeSetRequired`)
947
+ * when the period would cover a Release entirely.
948
+ */
949
+ publishDirectEdit(input: {
950
+ id: string;
951
+ expectedHeadId: string;
952
+ /** The Release's Release Spec values; absent is none. */
953
+ releaseSpec?: Record<string, unknown>;
954
+ /** Dated Content: the period's last day, "" for an open end; absent keeps the default. */
955
+ validityLastDay?: string;
956
+ /** Dated Content: whether the change carries into each later wording. */
957
+ carryForward?: CarryForwardAnswer[];
958
+ idempotencyKey?: string;
959
+ }): Promise<PublishOutcome>;
960
+ /**
961
+ * Saves on a Direct Edit's Branch on top of `expectedHeadId`, as
962
+ * `saveRevision` does, and publishes the Revision saved, as
963
+ * `publishDirectEdit` does, in one request (ADR 0022). Refused as a
964
+ * whole, with nothing saved: rejects as either does (`StaleHeadError`,
965
+ * `ContentRefusedError` for the data or the Release Spec values,
966
+ * `PublishRefusedError` with every blocker).
967
+ */
968
+ saveAndPublishDirectEdit(input: {
969
+ id: string;
970
+ expectedHeadId: string;
971
+ data: Record<string, unknown>;
972
+ /** Top-level field accessors; absent saves `data` as the whole Revision. */
973
+ fieldMask?: string[];
974
+ releaseSpec?: Record<string, unknown>;
975
+ /** As `publishDirectEdit`'s. */
976
+ validityLastDay?: string;
977
+ carryForward?: CarryForwardAnswer[];
978
+ idempotencyKey?: string;
979
+ }): Promise<{
980
+ content: Content;
981
+ outcome: PublishOutcome;
982
+ }>;
983
+ /**
984
+ * Discards a Direct Edit: its work is dropped, Main and the Releases stay.
985
+ * Rejects as `discardChangeSet` does, and with `DirectEditRefusedError`
986
+ * for a Change Set that is not a Direct Edit.
987
+ */
988
+ discardDirectEdit(input: {
989
+ id: string;
990
+ idempotencyKey?: string;
991
+ }): Promise<ChangeSet>;
992
+ /**
993
+ * Forces an Editing Block (ADR 0022): hands the Direct Edit `id` holding
994
+ * it, with its work and its Editing Block, to the caller. Answers it with
995
+ * the caller as its editor, the Content as read on its Branch, and who
996
+ * edited it until now. Rejects with `AccessDeniedError` outside the
997
+ * Force Group, `DirectEditRefusedError` where the caller has a Direct
998
+ * Edit of the Content of their own or it holds no Editing Block any more,
999
+ * and as `discardDirectEdit` does otherwise.
1000
+ */
1001
+ forceDirectEdit(input: {
1002
+ id: string;
1003
+ idempotencyKey?: string;
1004
+ }): Promise<{
1005
+ changeSet: ChangeSet;
1006
+ content: Content;
1007
+ previousEditorId: string;
1008
+ }>;
806
1009
  startEditing(input: {
807
1010
  contentId: string;
808
1011
  changeSetId?: string;
@@ -963,6 +1166,21 @@ export declare function createStubContenthubClient(options?: StubContenthubClien
963
1166
 
964
1167
  export declare function createStubStatusSource(statuses?: ChangeSetStatusInfo[]): StatusSource;
965
1168
 
1169
+ /**
1170
+ * What a Direct Edit's Publish of Dated Content would plan (#270), for its
1171
+ * Publish dialog: nothing of it is written.
1172
+ */
1173
+ declare interface DirectEditPublishPreview {
1174
+ /** Its Release's Validity Period; an empty last day is an open end. */
1175
+ validityPeriod?: ValidityPeriod;
1176
+ /** The Release it corrects and Supersedes; "" for a new wording. */
1177
+ correctsReleaseId: string;
1178
+ /** The date-only Releases contenthub derives, read-only. */
1179
+ dateOnlyReleases: PlannedRelease[];
1180
+ /** The later wordings Publish asks about, by first day. */
1181
+ laterWordings: LaterWording[];
1182
+ }
1183
+
966
1184
  /** One edge of one Revision. */
967
1185
  declare interface Edge {
968
1186
  sourceContentId: string;
@@ -981,6 +1199,56 @@ declare interface Edge {
981
1199
  /** What kind of edge of the Content Graph (ADR 0009). */
982
1200
  declare type EdgeKind = "reference" | "toc" | "include" | "exclude" | "replace" | "annotate" | "link" | "footnote" | "anchor" | "media" | "blueprint" | "unspecified";
983
1201
 
1202
+ /**
1203
+ * The Block a Direct Edit sets on its Content (CONTEXT.md, Editing Block):
1204
+ * "being edited by" its editor. It keeps out only other editors' Direct
1205
+ * Edits, ends with its Direct Edit's Publish or Discard, and can't be
1206
+ * lifted. It is independent of `block`: a Content can hold both.
1207
+ */
1208
+ declare interface EditingBlock {
1209
+ /** The Direct Edit's editor, an odon user id. */
1210
+ editorId: string;
1211
+ /** The Direct Edit holding it. */
1212
+ changeSetId: string;
1213
+ /** ISO 8601. */
1214
+ blockTime: string;
1215
+ }
1216
+
1217
+ /**
1218
+ * Which ways of changing a Blueprint's Content the workspace offers (ADR
1219
+ * 0022, CONTEXT.md Editing Mode): Direct Edits only, Change Sets only, or
1220
+ * both. Only "change_sets" is a rule: contenthub refuses a Direct Edit on
1221
+ * such Content.
1222
+ */
1223
+ declare type EditingMode = "direct_edits" | "change_sets" | "both";
1224
+
1225
+ /** The workspace's editing settings, or the ones in effect for a Blueprint. */
1226
+ declare interface EditingSettings {
1227
+ editingMode: EditingMode;
1228
+ /** Whether opening a Direct Edit sets an Editing Block on its Content. */
1229
+ editingBlock: boolean;
1230
+ /**
1231
+ * The Force Group: who may force an Editing Block (ADR 0022). The
1232
+ * workspace's admins always may; these are the people beside them, by
1233
+ * odon user id, sorted. Empty is the admins alone.
1234
+ */
1235
+ forceGroup: string[];
1236
+ }
1237
+
1238
+ /** The editing settings in effect for one Blueprint, and which its override decides. */
1239
+ declare interface EffectiveEditingSettings {
1240
+ effective: EditingSettings;
1241
+ editingModeOverridden: boolean;
1242
+ editingBlockOverridden: boolean;
1243
+ forceGroupOverridden: boolean;
1244
+ /**
1245
+ * Whether the caller is in the effective Force Group: an admin, or named
1246
+ * by it. It is how a screen knows to offer Force (#269); the service
1247
+ * asks the same when it is used.
1248
+ */
1249
+ callerInForceGroup: boolean;
1250
+ }
1251
+
984
1252
  /** One field that differs between two Revisions. */
985
1253
  declare interface FieldChange {
986
1254
  /** "/" and the field's accessor. */
@@ -1007,6 +1275,12 @@ declare interface GapReferrer {
1007
1275
  releaseId: string;
1008
1276
  }
1009
1277
 
1278
+ /** A later wording a Direct Edit's change may carry into (#270). */
1279
+ declare interface LaterWording {
1280
+ releaseId: string;
1281
+ validityPeriod?: ValidityPeriod;
1282
+ }
1283
+
1010
1284
  /** One field a merge resolution must decide, with each side's value. */
1011
1285
  declare interface MergeField {
1012
1286
  /** "/" and the field's accessor, as a Violation spells it. */
@@ -1260,6 +1534,11 @@ declare interface RequiredCheckRecorders {
1260
1534
  declare interface ResolvedBlueprintRelease {
1261
1535
  /** The Blueprint's name, as the released Revision holds it; "" if it holds none. */
1262
1536
  displayName: string;
1537
+ /**
1538
+ * The Blueprint's accessor, which its editing settings are keyed by;
1539
+ * "" or absent when the Resolved Release names none.
1540
+ */
1541
+ accessor?: string;
1263
1542
  /** Whether its Content is Dated: its Releases carry a Validity Period. */
1264
1543
  dated: boolean;
1265
1544
  /** fieldkit's Resolved Spec fields, in Blueprint order. */
@@ -1407,6 +1686,8 @@ export declare interface StubContent {
1407
1686
  assigneeIds?: string[];
1408
1687
  /** Its Block; absent while it is not blocked. */
1409
1688
  block?: ContentBlock;
1689
+ /** Its Editing Block; absent while no open Direct Edit holds one. */
1690
+ editingBlock?: EditingBlock;
1410
1691
  /** When it was archived, ISO 8601; absent while it is not Archived. */
1411
1692
  archiveTime?: string;
1412
1693
  /** Its Main head; absent while it was born in an open Change Set. */
@@ -1484,6 +1765,13 @@ export declare interface StubContenthubClientOptions {
1484
1765
  * derive (moved_head, the dependencies', outstanding_check).
1485
1766
  */
1486
1767
  publishBlockers?: Record<string, PublishBlocker[]>;
1768
+ /**
1769
+ * The Branches behind their base, by id, as a Change Set published past
1770
+ * them leaves them (#268): `validatePublish` and `publish` report
1771
+ * behind_base for each until `updateFromMain` merges it or a resolution
1772
+ * of its Pending Merge does. An aborted merge leaves it behind.
1773
+ */
1774
+ behind?: string[];
1487
1775
  /** The Pending Merges `updateFromMain` leaves, by Change Set id; none by default. */
1488
1776
  pendingMerges?: Record<string, PendingMergeRef[]>;
1489
1777
  /**
@@ -1526,6 +1814,16 @@ export declare interface StubContenthubClientOptions {
1526
1814
  userId?: string;
1527
1815
  /** The time every write stamps; STUB_NOW by default. */
1528
1816
  now?: () => string;
1817
+ /**
1818
+ * The workspace's own editing settings; "Change Sets only" without an
1819
+ * Editing Block by default, as for a workspace that never set them. A
1820
+ * Force Group left out is the admins alone.
1821
+ */
1822
+ editingSettings?: Omit<EditingSettings, "forceGroup"> & {
1823
+ forceGroup?: string[];
1824
+ };
1825
+ /** The per-Blueprint overrides of the editing settings; none by default. */
1826
+ editingOverrides?: StubEditingOverride[];
1529
1827
  }
1530
1828
 
1531
1829
  /**
@@ -1536,6 +1834,15 @@ export declare interface StubContenthubClientOptions {
1536
1834
  */
1537
1835
  export declare function stubContents(): StubContent[];
1538
1836
 
1837
+ /** One stored override: a null field follows the workspace's. */
1838
+ export declare interface StubEditingOverride {
1839
+ blueprintAccessor: string;
1840
+ editingMode: EditingMode | null;
1841
+ editingBlock: boolean | null;
1842
+ /** The people beside the admins; null follows the workspace's. Absent is null. */
1843
+ forceGroup?: string[] | null;
1844
+ }
1845
+
1539
1846
  /** One head of a Content: its Revision, data and when it was written. */
1540
1847
  export declare interface StubHead {
1541
1848
  revisionId: string;
@@ -1576,6 +1883,14 @@ export declare function stubResolvedReleases(): Record<string, ResolvedBlueprint
1576
1883
  */
1577
1884
  export declare function stubStatusTransitions(): Record<string, string[]>;
1578
1885
 
1886
+ /**
1887
+ * An editorial note, undated and published, whose Blueprint `note` is what a
1888
+ * Direct Edit edits (ADR 0022, #264): Dated Content takes none yet. Not among
1889
+ * `stubContents()`, so the Library's fixtures stay as they are; pass it in
1890
+ * with `contents`, and set the stub's `editingSettings` to offer Edit.
1891
+ */
1892
+ export declare function stubUndatedContent(): StubContent;
1893
+
1579
1894
  /** One Release of a Content's Timeline (CONTEXT.md, Timeline), without its data. */
1580
1895
  declare interface TimelineEntry {
1581
1896
  /** Its place in the Timeline, from 1. */
@@ -1613,4 +1928,10 @@ declare interface ValidityPeriod {
1613
1928
  lastDay: string;
1614
1929
  }
1615
1930
 
1931
+ /** The workspace's editing settings and every per-Blueprint override, by accessor. */
1932
+ declare interface WorkspaceEditingSettings {
1933
+ workspace: EditingSettings;
1934
+ overrides: BlueprintEditingOverride[];
1935
+ }
1936
+
1616
1937
  export { }