@columnus/sdk 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { CmsProvider } from '../../chunk-UXUDOFKZ.js';
1
+ import { CmsProvider } from '../../chunk-QN3K6RRP.js';
2
2
  import '../../chunk-ZTWPGA37.js';
3
3
  import '../../chunk-QPQRNIKG.js';
4
4
  import '../../chunk-ICKWVUW7.js';
package/dist/cms/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { CmsCompoundCreate, CmsCreateButton, CmsField, CmsFieldStamp, CmsFloatingToolbar, CmsLoginPage, CmsProvider, CmsRow, DefaultRichtextHostProvider, DraftRowDialog, FieldEditorDialog, HTML_CACHE_BYPASS_HEADER, InsertRowDialog, CmsRichDocView as RichDocView, applyDeleteToDraft, applyFieldToDraft, applyRowToDraft, buildInsertDraft, canProposeField, canProposeOp, cmsReadableTables, createDefaultCmsRichtextAdapters, createDefaultRichtextHostAdapter, createTableRowsRichtextHostAdapter, describeContentRefIntegrity, findContentRefField, inferNavigationTable, isCmsPath, mergeDraftIntoProposal, proposeEditableTable, resolveEditSurface, resolveStampDisplay, shouldBypassHtmlCache, slugifyDe, stampEditKey, uniqueSlug, useCms, useCmsOptional, useCmsProjectedField, useCmsProjectedString, useCmsProjectedTable, useCmsRelatedRow, useCmsRow, useCmsRowOptional } from '../chunk-UXUDOFKZ.js';
1
+ export { CmsCompoundCreate, CmsCreateButton, CmsField, CmsFieldStamp, CmsFloatingToolbar, CmsLoginPage, CmsProvider, CmsRow, DefaultRichtextHostProvider, DraftRowDialog, FieldEditorDialog, HTML_CACHE_BYPASS_HEADER, InsertRowDialog, CmsRichDocView as RichDocView, applyDeleteToDraft, applyFieldToDraft, applyRowToDraft, buildInsertDraft, canProposeField, canProposeOp, cmsReadableTables, createDefaultCmsRichtextAdapters, createDefaultRichtextHostAdapter, createTableRowsRichtextHostAdapter, describeContentRefIntegrity, findContentRefField, inferNavigationTable, isCmsPath, mergeDraftIntoProposal, proposeEditableTable, resolveEditSurface, resolveStampDisplay, shouldBypassHtmlCache, slugifyDe, stampEditKey, uniqueSlug, useCms, useCmsOptional, useCmsProjectedField, useCmsProjectedString, useCmsProjectedTable, useCmsRelatedRow, useCmsRow, useCmsRowOptional } from '../chunk-QN3K6RRP.js';
2
2
  import '../chunk-ZTWPGA37.js';
3
3
  export { CMS_SESSION_COOKIE, CmsAuthError, clearSessionCookie, createCmsAuth, isEditor, readSessionCookie, serializeSessionCookie } from '../chunk-QPQRNIKG.js';
4
4
  export { CMS_STAMP_ATTR, buildStampAttrs } from '../chunk-ICKWVUW7.js';
@@ -1,4 +1,4 @@
1
- import { useCms, readSession, DraftRowDialog, writeSession, mergeDraftIntoProposal } from '../../chunk-UXUDOFKZ.js';
1
+ import { useCms, readSession, DraftRowDialog, writeSession, mergeDraftIntoProposal } from '../../chunk-QN3K6RRP.js';
2
2
  import '../../chunk-ZTWPGA37.js';
3
3
  import '../../chunk-QPQRNIKG.js';
4
4
  import { CMS_TABLES_Z_INDEX, IconTrash } from '../../chunk-ICKWVUW7.js';
package/dist/mcp-cli.js CHANGED
@@ -44472,6 +44472,11 @@ function draftTitle(proposal, mine) {
44472
44472
  if (!mine) return proposal.createdByName ?? "Another editor";
44473
44473
  return proposal.draftLabel ?? (proposal.draftKey ? "Builder session" : "Toolbar edits");
44474
44474
  }
44475
+ var changeKey = (proposalId, target) => JSON.stringify([proposalId, target.table, target.rowId, target.field ?? null]);
44476
+ function isOnPage(proposal, editorUserId, draftKey) {
44477
+ const mine = editorUserId !== null && proposal.createdByUserId === editorUserId;
44478
+ return !mine || proposal.draftKey === draftKey;
44479
+ }
44475
44480
  var EMPTY_FIELD = { value: void 0, origin: null };
44476
44481
  function tableRowsFor(tables, table) {
44477
44482
  let rows = tables.get(table);
@@ -44498,26 +44503,26 @@ function rowFor(tables, table, rowId) {
44498
44503
  }
44499
44504
  return row;
44500
44505
  }
44501
- function applyFields(row, patch, origin) {
44506
+ function applyFields(row, patch, origin, skip) {
44502
44507
  for (const [field, value] of Object.entries(patch.fields)) {
44503
- if (field === "_id") continue;
44508
+ if (field === "_id" || skip?.has(field)) continue;
44504
44509
  row.value[field] = value;
44505
44510
  row.origins.set(field, origin);
44506
44511
  }
44507
44512
  for (const field of patch.clearFields ?? []) {
44508
- if (field === "_id") continue;
44513
+ if (field === "_id" || skip?.has(field)) continue;
44509
44514
  delete row.value[field];
44510
44515
  row.origins.set(field, origin);
44511
44516
  }
44512
44517
  }
44513
- function applyPatch(row, patch, origin, placement) {
44518
+ function applyPatch(row, patch, origin, placement, skip) {
44514
44519
  if (patch.op === "delete") {
44515
44520
  row.deletedBy = origin;
44516
44521
  return;
44517
44522
  }
44518
44523
  if (patch.op === "update" && !row.placement) {
44519
44524
  row.deletedBy = null;
44520
- applyFields(row, patch, origin);
44525
+ applyFields(row, patch, origin, skip);
44521
44526
  return;
44522
44527
  }
44523
44528
  if (patch.op === "insert" && !row.live) {
@@ -44526,7 +44531,7 @@ function applyPatch(row, patch, origin, placement) {
44526
44531
  row.placement = placement;
44527
44532
  }
44528
44533
  row.deletedBy = null;
44529
- applyFields(row, patch, origin);
44534
+ applyFields(row, patch, origin, skip);
44530
44535
  }
44531
44536
  function sortedProposalPatches(proposal) {
44532
44537
  return proposal.patches.map((patch, index) => ({ patch, index })).sort(
@@ -44538,7 +44543,8 @@ function createCmsProjection({
44538
44543
  draft,
44539
44544
  proposals,
44540
44545
  editorUserId,
44541
- draftKey
44546
+ draftKey,
44547
+ hidden
44542
44548
  }) {
44543
44549
  const tables = /* @__PURE__ */ new Map();
44544
44550
  for (const [table, rows] of Object.entries(liveRows)) {
@@ -44557,7 +44563,8 @@ function createCmsProjection({
44557
44563
  }
44558
44564
  const isMine = (proposal) => editorUserId !== null && proposal.createdByUserId === editorUserId;
44559
44565
  const activeProposals = proposals.filter((proposal) => proposal.status === "active").sort((a, b) => a.createdAt - b.createdAt || a.id.localeCompare(b.id));
44560
- activeProposals.filter((proposal) => !isMine(proposal) || proposal.draftKey === draftKey).forEach((proposal, rank) => {
44566
+ let hidesChanges = false;
44567
+ activeProposals.filter((proposal) => isOnPage(proposal, editorUserId, draftKey)).forEach((proposal, rank) => {
44561
44568
  const mine2 = isMine(proposal);
44562
44569
  const origin = {
44563
44570
  kind: "proposal",
@@ -44567,7 +44574,13 @@ function createCmsProjection({
44567
44574
  label: draftTitle(proposal, mine2)
44568
44575
  };
44569
44576
  for (const patch of sortedProposalPatches(proposal)) {
44570
- applyPatch(rowFor(tables, patch.table, patch.rowId), patch, origin, [1, -rank]);
44577
+ const isHidden = (field) => hidden?.has(changeKey(proposal.id, { table: patch.table, rowId: patch.rowId, field })) ?? false;
44578
+ const fields = [...Object.keys(patch.fields), ...patch.clearFields ?? []];
44579
+ const skip = new Set(patch.op === "update" ? fields.filter(isHidden) : []);
44580
+ const whole = patch.op === "update" ? skip.size > 0 && skip.size === fields.length : isHidden();
44581
+ hidesChanges ||= whole || skip.size > 0;
44582
+ if (whole) continue;
44583
+ applyPatch(rowFor(tables, patch.table, patch.rowId), patch, origin, [1, -rank], skip);
44571
44584
  }
44572
44585
  });
44573
44586
  const proposalDeletes = /* @__PURE__ */ new Map();
@@ -44595,6 +44608,7 @@ function createCmsProjection({
44595
44608
  );
44596
44609
  return {
44597
44610
  conflictsWithMine,
44611
+ hidesChanges,
44598
44612
  field({ table, rowId, field }) {
44599
44613
  const row = tables.get(table)?.get(rowId);
44600
44614
  if (!row) return EMPTY_FIELD;
@@ -14,6 +14,14 @@ export type CmsProjectionOrigin = {
14
14
  };
15
15
  /** My draft's label (else "Builder session" or "Toolbar edits"), or another editor's name. */
16
16
  export declare function draftTitle(proposal: CmsProposalSummary, mine: boolean): string;
17
+ /** A proposal's change (a field of an update, or a whole insert or delete) as one key. */
18
+ export declare const changeKey: (proposalId: string, target: {
19
+ table: string;
20
+ rowId: string;
21
+ field?: string;
22
+ }) => string;
23
+ /** Q4: the page shows other editors' drafts and, of mine, only the one for `draftKey`. */
24
+ export declare function isOnPage(proposal: CmsProposalSummary, editorUserId: string | null, draftKey: string | undefined | null): boolean;
17
25
  export type CmsProjectedField = {
18
26
  value: unknown;
19
27
  /** Null means the effective value comes from the live row or is absent. */
@@ -46,6 +54,8 @@ export type CmsProjection = {
46
54
  * Precomputed once when the projection is built.
47
55
  */
48
56
  conflictsWithMine: ReadonlySet<string>;
57
+ /** Some change on the page was left out by `hidden`. */
58
+ hidesChanges: boolean;
49
59
  };
50
60
  type ProjectionInput = {
51
61
  liveRows: Readonly<Record<string, readonly CmsTableRow[]>>;
@@ -57,7 +67,9 @@ type ProjectionInput = {
57
67
  * builder first answers); my other drafts are left out (plan 112 Q4).
58
68
  */
59
69
  draftKey: string | undefined | null;
70
+ /** Proposal changes left off the page, by `changeKey`. */
71
+ hidden?: ReadonlySet<string>;
60
72
  };
61
73
  /** Effective CMS presentation: live rows, then active proposals, then local draft. */
62
- export declare function createCmsProjection({ liveRows, draft, proposals, editorUserId, draftKey, }: ProjectionInput): CmsProjection;
74
+ export declare function createCmsProjection({ liveRows, draft, proposals, editorUserId, draftKey, hidden, }: ProjectionInput): CmsProjection;
63
75
  export {};
@@ -161,7 +161,18 @@ export type CmsContextValue = {
161
161
  resolve: (key: string | undefined, expectedRevision: number, choices: CmsResolveChoice[]) => Promise<boolean>;
162
162
  /** The Changes view is open: stamps outline proposal changes (Q27). */
163
163
  changesOpen: boolean;
164
+ /** Closing the view shows changes on the page again. */
164
165
  setChangesOpen: (open: boolean) => void;
166
+ /**
167
+ * How much of the drafts the page shows: all, some (changes hidden one by
168
+ * one), or none (the live site). Editing pauses unless it shows all.
169
+ */
170
+ pageShows: "all" | "some" | "none";
171
+ /** Show all changes on the page, or none. */
172
+ setShowChanges: (show: boolean) => void;
173
+ /** Changes hidden from the page one by one, by `changeKey`. */
174
+ hiddenChanges: ReadonlySet<string>;
175
+ setChangeShown: (key: string, shown: boolean) => void;
165
176
  /** The change hovered in the Changes view, outlined on the page. */
166
177
  highlight: CmsChangeTarget | null;
167
178
  setHighlight: (target: CmsChangeTarget | null) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columnus/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "Columnus SDK: the embedded CMS (@columnus/sdk/cms) for host apps.",
6
6
  "license": "MIT",