@drawnagency/primitives 0.1.95 → 0.1.97

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.
Files changed (86) hide show
  1. package/dist/{chunk-ZKGMLLUQ.js → chunk-5BFPJWIO.js} +5 -5
  2. package/dist/chunk-EUSWEVOA.js +29 -0
  3. package/dist/{chunk-CI624HRS.js → chunk-F2337B35.js} +1 -1
  4. package/dist/{chunk-QQBBYQYD.js → chunk-FOEZNEF5.js} +9 -9
  5. package/dist/chunk-HJSE6SK5.js +27 -0
  6. package/dist/{chunk-YUUUCDXN.js → chunk-II3X7GLJ.js} +1 -1
  7. package/dist/{chunk-DJAJRBPD.js → chunk-KPP2CFW6.js} +2 -2
  8. package/dist/{chunk-ABV7OZB3.js → chunk-QEHPGA5N.js} +26 -8
  9. package/dist/{chunk-SOILPZ7U.js → chunk-S4L3ZFKM.js} +1 -1
  10. package/dist/{chunk-RQPHPAT2.js → chunk-YDXBJR74.js} +2 -2
  11. package/dist/chunk-ZD6XGRQM.js +85 -0
  12. package/dist/collab/rebase.d.ts +20 -0
  13. package/dist/collab/rebase.d.ts.map +1 -1
  14. package/dist/collab/rebase.js +17 -0
  15. package/dist/components/editor/DropEdgeIndicator.d.ts +6 -1
  16. package/dist/components/editor/DropEdgeIndicator.d.ts.map +1 -1
  17. package/dist/components/editor/NavGroupRow.d.ts +21 -0
  18. package/dist/components/editor/NavGroupRow.d.ts.map +1 -0
  19. package/dist/components/editor/PagesModal.d.ts +7 -1
  20. package/dist/components/editor/PagesModal.d.ts.map +1 -1
  21. package/dist/components/editor/index.js +4 -4
  22. package/dist/components/primitives/index.js +7 -7
  23. package/dist/components/sections/brand-guide.js +6 -6
  24. package/dist/components/sections/register-schemas.js +10 -10
  25. package/dist/components/sections/register.js +10 -10
  26. package/dist/components/shared/Navigation.d.ts.map +1 -1
  27. package/dist/components/shell/EditorShell.d.ts.map +1 -1
  28. package/dist/hooks/useSortableNavRow.d.ts +27 -0
  29. package/dist/hooks/useSortableNavRow.d.ts.map +1 -0
  30. package/dist/index.js +60 -38
  31. package/dist/lib/dexie.d.ts.map +1 -1
  32. package/dist/lib/dexie.js +3 -1
  33. package/dist/lib/index-ops.d.ts +77 -0
  34. package/dist/lib/index-ops.d.ts.map +1 -0
  35. package/dist/lib/index-ops.js +223 -0
  36. package/dist/lib/index.d.ts +1 -0
  37. package/dist/lib/index.d.ts.map +1 -1
  38. package/dist/lib/index.js +17 -6
  39. package/dist/lib/loader.d.ts +2 -2
  40. package/dist/lib/loader.d.ts.map +1 -1
  41. package/dist/lib/nav-tree.d.ts +63 -0
  42. package/dist/lib/nav-tree.d.ts.map +1 -0
  43. package/dist/lib/nav.d.ts +13 -2
  44. package/dist/lib/nav.d.ts.map +1 -1
  45. package/dist/lib/pages.d.ts +0 -1
  46. package/dist/lib/pages.d.ts.map +1 -1
  47. package/dist/lib/reorder.d.ts +24 -0
  48. package/dist/lib/reorder.d.ts.map +1 -1
  49. package/dist/media/index.js +2 -2
  50. package/dist/schemas/index.d.ts +1 -0
  51. package/dist/schemas/index.d.ts.map +1 -1
  52. package/dist/schemas/index.js +8 -2
  53. package/dist/schemas/nav.d.ts +40 -0
  54. package/dist/schemas/nav.d.ts.map +1 -0
  55. package/dist/schemas/site-config.d.ts +11 -1
  56. package/dist/schemas/site-config.d.ts.map +1 -1
  57. package/dist/storage/index.d.ts +1 -1
  58. package/dist/storage/index.d.ts.map +1 -1
  59. package/dist/storage/index.js +9 -3
  60. package/dist/storage/types.d.ts +44 -0
  61. package/dist/storage/types.d.ts.map +1 -1
  62. package/package.json +5 -1
  63. package/src/collab/rebase.ts +35 -0
  64. package/src/components/editor/DropEdgeIndicator.tsx +15 -8
  65. package/src/components/editor/NavGroupRow.tsx +126 -0
  66. package/src/components/editor/PagesModal.tsx +150 -29
  67. package/src/components/shared/Navigation.tsx +51 -13
  68. package/src/components/shell/EditorShell.tsx +40 -10
  69. package/src/hooks/useSortableNavRow.ts +139 -0
  70. package/src/lib/dexie.ts +6 -1
  71. package/src/lib/index-ops.ts +309 -0
  72. package/src/lib/index.ts +1 -0
  73. package/src/lib/loader.ts +31 -4
  74. package/src/lib/nav-tree.ts +192 -0
  75. package/src/lib/nav.ts +43 -10
  76. package/src/lib/pages.ts +14 -11
  77. package/src/lib/reorder.ts +56 -0
  78. package/src/schemas/index.ts +1 -0
  79. package/src/schemas/nav.ts +36 -0
  80. package/src/schemas/site-config.ts +9 -1
  81. package/src/storage/index.ts +1 -1
  82. package/src/storage/types.ts +55 -0
  83. package/dist/chunk-VAOW4WXQ.js +0 -15
  84. package/dist/chunk-YBVK254P.js +0 -14
  85. /package/dist/{chunk-53DKVAB6.js → chunk-72CG6AA2.js} +0 -0
  86. /package/dist/{chunk-3HJDMFTB.js → chunk-XYCCXKVC.js} +0 -0
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  allSectionDefs
3
- } from "../../chunk-QQBBYQYD.js";
4
- import "../../chunk-ZKGMLLUQ.js";
5
- import "../../chunk-YUUUCDXN.js";
3
+ } from "../../chunk-FOEZNEF5.js";
4
+ import "../../chunk-5BFPJWIO.js";
5
+ import "../../chunk-II3X7GLJ.js";
6
6
  import "../../chunk-5THS4K5D.js";
7
- import "../../chunk-RQPHPAT2.js";
8
- import "../../chunk-DJAJRBPD.js";
7
+ import "../../chunk-YDXBJR74.js";
8
+ import "../../chunk-KPP2CFW6.js";
9
9
  import "../../chunk-ZSPCE6MZ.js";
10
- import "../../chunk-CI624HRS.js";
10
+ import "../../chunk-F2337B35.js";
11
11
  import "../../chunk-Y4JQGO6G.js";
12
- import "../../chunk-SOILPZ7U.js";
12
+ import "../../chunk-S4L3ZFKM.js";
13
13
  import "../../chunk-PZJL2S3Z.js";
14
14
  import "../../chunk-WDSVHKAH.js";
15
- import "../../chunk-53DKVAB6.js";
15
+ import "../../chunk-72CG6AA2.js";
16
16
  import "../../chunk-7EOSDFS3.js";
17
- import "../../chunk-YBVK254P.js";
17
+ import "../../chunk-ZD6XGRQM.js";
18
18
  import "../../chunk-TZQPOR5A.js";
19
- import "../../chunk-RHWWQV3J.js";
20
19
  import {
21
20
  registerSection
22
21
  } from "../../chunk-VKAGMEKE.js";
22
+ import "../../chunk-RHWWQV3J.js";
23
23
  import "../../chunk-FM4M4Q2W.js";
24
24
  import "../../chunk-NSCT3AMV.js";
25
25
  import "../../chunk-JSBRDJBE.js";
@@ -1 +1 @@
1
- {"version":3,"file":"Navigation.d.ts","sourceRoot":"","sources":["../../../src/components/shared/Navigation.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,eAAe,CAAC;AAOtD,UAAU,KAAK;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;IACxC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAGlF,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;kFAG8E;IAC9E,iBAAiB,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACjC;AAQD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,iBAAwB,EAAE,EAAE,KAAK,2CAgR/I"}
1
+ {"version":3,"file":"Navigation.d.ts","sourceRoot":"","sources":["../../../src/components/shared/Navigation.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAsC,MAAM,eAAe,CAAC;AAQjF,UAAU,KAAK;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,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,EAAE,OAAO,CAAC;QACxB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;IACF,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAA;KAAE,GAAG,IAAI,CAAC;IAIhE,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAKjC,eAAe,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CAC1C;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,YAAY,EACZ,MAAM,EACN,SAAS,EAAE,gBAAgB,EAC3B,YAAY,EACZ,WAAW,EACX,sBAA8B,EAC9B,eAAe,GAChB,EAAE,KAAK,2CAqsDP;AAuED;6EAC6E;AAC7E,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,EACvC,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,eAAe,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK/B"}
@@ -0,0 +1,27 @@
1
+ import type { NavLocation, NavRow } from "../lib/nav-tree";
2
+ interface Options {
3
+ /** This row's identity — supplies the source location and the drop container. */
4
+ row: NavRow;
5
+ /** The row's index in the TOP-LEVEL entry list (a member row: its group's index). */
6
+ entryIndex: number;
7
+ kind: "page" | "group";
8
+ onMove: (from: NavLocation, to: NavLocation) => void;
9
+ enabled?: boolean;
10
+ }
11
+ /**
12
+ * Closest-edge drag wiring for one Pages-modal nav row. A sibling of
13
+ * useSortableRow that speaks NavLocation instead of a flat index; the section
14
+ * modal keeps using the original, so this cannot regress it.
15
+ *
16
+ * Loads the atlaskit adapter lazily, matching useSortableRow, so it stays out
17
+ * of the SSR and initial bundles.
18
+ */
19
+ export declare function useSortableNavRow<R extends HTMLElement, H extends HTMLElement>({ row, entryIndex, kind, onMove, enabled, }: Options): {
20
+ rowRef: import("react").RefObject<R | null>;
21
+ handleRef: import("react").RefObject<H | null>;
22
+ isDragging: boolean;
23
+ closestEdge: "top" | "bottom" | null;
24
+ isDropTarget: boolean;
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=useSortableNavRow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSortableNavRow.d.ts","sourceRoot":"","sources":["../../src/hooks/useSortableNavRow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE3D,UAAU,OAAO;IACf,iFAAiF;IACjF,GAAG,EAAE,MAAM,CAAC;IACZ,qFAAqF;IACrF,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;IACrD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAID;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,WAAW,EAAE,EAC9E,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAc,GAC9C,EAAE,OAAO;;;;;;EAgHT"}
package/dist/index.js CHANGED
@@ -1,21 +1,14 @@
1
1
  import {
2
2
  ASSET_CACHE_CONTROL,
3
- StorageConflictError
4
- } from "./chunk-VAOW4WXQ.js";
3
+ IDEMPOTENCY_KEY_RE,
4
+ IDEMPOTENCY_TRAILER,
5
+ StorageConflictError,
6
+ withIdempotencyTrailer
7
+ } from "./chunk-EUSWEVOA.js";
5
8
  import {
6
- AUDIENCE_COOKIE,
7
- AUDIENCE_MAX_AGE_SECONDS,
8
- LastOwnerError,
9
- SESSION_COOKIE,
10
- SESSION_MAX_AGE_SECONDS,
11
- SessionExpiredError,
12
- deriveUiCapabilities,
13
- setSessionCookie,
14
- signAudienceToken,
15
- signSessionToken,
16
- verifyAudienceToken,
17
- verifySessionToken
18
- } from "./chunk-EM5DFHDZ.js";
9
+ getCollabProvider,
10
+ setCollabProvider
11
+ } from "./chunk-2G2S36SY.js";
19
12
  import {
20
13
  BAKED_MEDIA_KEYS,
21
14
  EXT_TO_MIME,
@@ -36,7 +29,21 @@ import {
36
29
  resolveMedia,
37
30
  sanitizeMediaName,
38
31
  setMediaProvider
39
- } from "./chunk-SOILPZ7U.js";
32
+ } from "./chunk-S4L3ZFKM.js";
33
+ import {
34
+ AUDIENCE_COOKIE,
35
+ AUDIENCE_MAX_AGE_SECONDS,
36
+ LastOwnerError,
37
+ SESSION_COOKIE,
38
+ SESSION_MAX_AGE_SECONDS,
39
+ SessionExpiredError,
40
+ deriveUiCapabilities,
41
+ setSessionCookie,
42
+ signAudienceToken,
43
+ signSessionToken,
44
+ verifyAudienceToken,
45
+ verifySessionToken
46
+ } from "./chunk-EM5DFHDZ.js";
40
47
  import {
41
48
  CollabPeerSchema,
42
49
  HEARTBEAT_INTERVAL_MS,
@@ -46,16 +53,12 @@ import {
46
53
  SectionUpdateMessageSchema,
47
54
  TakeoverMessageSchema
48
55
  } from "./chunk-REM2NH7K.js";
49
- import {
50
- getCollabProvider,
51
- setCollabProvider
52
- } from "./chunk-2G2S36SY.js";
53
56
  import {
54
57
  AudienceColorSchema,
55
58
  AudienceNameSchema,
56
59
  MediaGridOptionsSchema,
57
60
  slugifyAudienceName
58
- } from "./chunk-3HJDMFTB.js";
61
+ } from "./chunk-XYCCXKVC.js";
59
62
  import {
60
63
  AudienceSchema,
61
64
  RoleSchema,
@@ -88,7 +91,7 @@ import {
88
91
  safeRedirect,
89
92
  suggestAccessibleOn,
90
93
  wcagLevel
91
- } from "./chunk-ABV7OZB3.js";
94
+ } from "./chunk-QEHPGA5N.js";
92
95
  import {
93
96
  curatedIcons,
94
97
  getIcon
@@ -104,23 +107,43 @@ import {
104
107
  generateNavLinks,
105
108
  sanitizeHtml,
106
109
  toSectionId
107
- } from "./chunk-53DKVAB6.js";
110
+ } from "./chunk-72CG6AA2.js";
108
111
  import {
109
112
  cn
110
113
  } from "./chunk-7EOSDFS3.js";
114
+ import {
115
+ audiencePasses,
116
+ groupDisplayLabel,
117
+ groupOfPage,
118
+ navEntries,
119
+ pagesInNavOrder,
120
+ reconcileNav
121
+ } from "./chunk-ZD6XGRQM.js";
111
122
  import {
112
123
  isSameOriginRequest,
113
124
  requireSessionSecret,
114
125
  safeNextPath
115
126
  } from "./chunk-S2L3BPLS.js";
116
- import {
117
- audiencePasses
118
- } from "./chunk-YBVK254P.js";
119
127
  import "./chunk-5BM2Y3NJ.js";
128
+ import {
129
+ NavEntrySchema,
130
+ NavFileSchema
131
+ } from "./chunk-HJSE6SK5.js";
120
132
  import {
121
133
  getSectionContentSchema,
122
134
  getSectionSchema
123
135
  } from "./chunk-TZQPOR5A.js";
136
+ import {
137
+ clearRegistry,
138
+ createRegistry,
139
+ defineSection,
140
+ getAllSchemas,
141
+ getAllSections,
142
+ getSchema,
143
+ getSection,
144
+ registerSchema,
145
+ registerSection
146
+ } from "./chunk-VKAGMEKE.js";
124
147
  import {
125
148
  ChatbotConfigSchema,
126
149
  ChatbotTaskSchema,
@@ -143,17 +166,6 @@ import {
143
166
  VariantSchema,
144
167
  normalizeSiteIndex
145
168
  } from "./chunk-RHWWQV3J.js";
146
- import {
147
- clearRegistry,
148
- createRegistry,
149
- defineSection,
150
- getAllSchemas,
151
- getAllSections,
152
- getSchema,
153
- getSection,
154
- registerSchema,
155
- registerSection
156
- } from "./chunk-VKAGMEKE.js";
157
169
  import "./chunk-FM4M4Q2W.js";
158
170
  import "./chunk-NSCT3AMV.js";
159
171
  import {
@@ -177,6 +189,8 @@ export {
177
189
  FontNameSchema,
178
190
  HEARTBEAT_INTERVAL_MS,
179
191
  HexColorSchema,
192
+ IDEMPOTENCY_KEY_RE,
193
+ IDEMPOTENCY_TRAILER,
180
194
  ImageManifestSchema,
181
195
  IndexSchema,
182
196
  IndexUpdateMessageSchema,
@@ -190,6 +204,8 @@ export {
190
204
  MediaGridOptionsSchema,
191
205
  MediaItemSchema,
192
206
  MediaReferenceSchema,
207
+ NavEntrySchema,
208
+ NavFileSchema,
193
209
  PageSchema,
194
210
  PageStatusSchema,
195
211
  ProcessingQueue,
@@ -245,6 +261,8 @@ export {
245
261
  getSectionContentSchema,
246
262
  getSectionSchema,
247
263
  gridColsClass,
264
+ groupDisplayLabel,
265
+ groupOfPage,
248
266
  hashFileBuffer,
249
267
  isSafeHref,
250
268
  isSameOriginRequest,
@@ -253,10 +271,13 @@ export {
253
271
  mergeSiteContent,
254
272
  mimeToExt,
255
273
  navChangeEvent,
274
+ navEntries,
256
275
  normalizeSiteIndex,
257
276
  onPrimaryVarValue,
277
+ pagesInNavOrder,
258
278
  primaryVarValue,
259
279
  rebindImageRef,
280
+ reconcileNav,
260
281
  registerSchema,
261
282
  registerSection,
262
283
  relativeLuminance,
@@ -280,5 +301,6 @@ export {
280
301
  toSectionId,
281
302
  verifyAudienceToken,
282
303
  verifySessionToken,
283
- wcagLevel
304
+ wcagLevel,
305
+ withIdempotencyTrailer
284
306
  };
@@ -1 +1 @@
1
- {"version":3,"file":"dexie.d.ts","sourceRoot":"","sources":["../../src/lib/dexie.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAe,UAAU,EAAQ,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAiE/D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;CACrB;A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,EACvB,MAAM,EAAE,UAAU,GAAG,UAAU,GAC9B,OAAO,CAAC,MAAM,CAAC,CAKjB;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAEtE;AAED,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE"}
package/dist/lib/dexie.js CHANGED
@@ -137,7 +137,7 @@ async function restoreLocalChanges() {
137
137
  const siteId = metaRow?.siteId ?? "";
138
138
  return {
139
139
  sections,
140
- siteIndex: { siteId, pages: indexRow.pages, sections: indexRow.sections },
140
+ siteIndex: { siteId, pages: indexRow.pages, sections: indexRow.sections, nav: indexRow.nav },
141
141
  siteConfig: configRow?.config,
142
142
  deletedSections: indexRow.deletedSections ?? []
143
143
  };
@@ -163,6 +163,7 @@ async function persistSiteIndex(index, deletedSections = []) {
163
163
  key: "current",
164
164
  pages: index.pages,
165
165
  sections: index.sections,
166
+ nav: index.nav,
166
167
  deletedSections,
167
168
  updatedAt: now
168
169
  });
@@ -249,6 +250,7 @@ async function persistAll(sections, siteIndex, deletedSectionIds, siteConfig) {
249
250
  key: "current",
250
251
  pages: siteIndex.pages,
251
252
  sections: siteIndex.sections,
253
+ nav: siteIndex.nav,
252
254
  deletedSections: [],
253
255
  updatedAt: now
254
256
  });
@@ -0,0 +1,77 @@
1
+ import { z } from "zod";
2
+ import { type SiteIndex } from "../schemas/site-config";
3
+ export declare const IndexOpSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
+ op: z.ZodLiteral<"insertAfter">;
5
+ pageId: z.ZodString;
6
+ afterId: z.ZodNullable<z.ZodString>;
7
+ sections: z.ZodArray<z.ZodObject<{
8
+ id: z.ZodString;
9
+ status: z.ZodOptional<z.ZodEnum<{
10
+ draft: "draft";
11
+ live: "live";
12
+ archived: "archived";
13
+ }>>;
14
+ access: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
+ }, z.core.$strip>>;
16
+ }, z.core.$strip>, z.ZodObject<{
17
+ op: z.ZodLiteral<"insertAt">;
18
+ pageId: z.ZodString;
19
+ position: z.ZodNumber;
20
+ sections: z.ZodArray<z.ZodObject<{
21
+ id: z.ZodString;
22
+ status: z.ZodOptional<z.ZodEnum<{
23
+ draft: "draft";
24
+ live: "live";
25
+ archived: "archived";
26
+ }>>;
27
+ access: z.ZodOptional<z.ZodArray<z.ZodString>>;
28
+ }, z.core.$strip>>;
29
+ }, z.core.$strip>, z.ZodObject<{
30
+ op: z.ZodLiteral<"move">;
31
+ pageId: z.ZodString;
32
+ id: z.ZodString;
33
+ afterId: z.ZodNullable<z.ZodString>;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ op: z.ZodLiteral<"remove">;
36
+ ids: z.ZodArray<z.ZodString>;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ op: z.ZodLiteral<"setMeta">;
39
+ id: z.ZodString;
40
+ status: z.ZodOptional<z.ZodEnum<{
41
+ draft: "draft";
42
+ live: "live";
43
+ archived: "archived";
44
+ }>>;
45
+ access: z.ZodOptional<z.ZodArray<z.ZodString>>;
46
+ }, z.core.$strip>, z.ZodObject<{
47
+ op: z.ZodLiteral<"setPageMeta">;
48
+ pageId: z.ZodString;
49
+ title: z.ZodOptional<z.ZodString>;
50
+ slug: z.ZodOptional<z.ZodString>;
51
+ showInNav: z.ZodOptional<z.ZodBoolean>;
52
+ access: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ }, z.core.$strip>], "op">;
54
+ export type IndexOp = z.infer<typeof IndexOpSchema>;
55
+ export type ApplyIndexOpsResult = {
56
+ ok: true;
57
+ index: SiteIndex;
58
+ removedIds: string[];
59
+ warnings: string[];
60
+ } | {
61
+ ok: false;
62
+ error: string;
63
+ };
64
+ /** Section-body types keyed by id, for the ids an insert op creates. */
65
+ export declare function collectPostedTypes(sections: {
66
+ id: string;
67
+ content: unknown;
68
+ }[] | undefined): Record<string, string>;
69
+ /**
70
+ * Every section id the ops name, derivable from the ops ALONE (no index read).
71
+ * Callers need this before applying anything: the collab broadcast has to tell
72
+ * browser editors which rows moved, and the audit trail has to record that an
73
+ * ops-only save touched anything at all. `setPageMeta` names no section.
74
+ */
75
+ export declare function opTouchedSectionIds(ops: IndexOp[]): string[];
76
+ export declare function applyIndexOps(rawIndex: unknown, ops: IndexOp[], newSectionTypes: Record<string, string>): ApplyIndexOpsResult;
77
+ //# sourceMappingURL=index-ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-ops.d.ts","sourceRoot":"","sources":["../../src/lib/index-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA+B,KAAK,SAAS,EAAoB,MAAM,wBAAwB,CAAC;AAgCvG,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAqCxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAC3B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GACxE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,EAAE,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOnH;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAQ5D;AAID,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,OAAO,EAAE,EACd,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtC,mBAAmB,CAsMrB"}
@@ -0,0 +1,223 @@
1
+ import {
2
+ IndexSchema,
3
+ RESERVED_SLUGS
4
+ } from "../chunk-RHWWQV3J.js";
5
+ import "../chunk-FM4M4Q2W.js";
6
+ import "../chunk-JSBRDJBE.js";
7
+
8
+ // src/lib/index-ops.ts
9
+ import { z } from "zod";
10
+ var OpStatusSchema = z.enum(["draft", "live", "archived"]);
11
+ var SAFE_SECTION_ID = /^[a-zA-Z0-9_-]{1,64}$/;
12
+ var SectionInsertSchema = z.object({
13
+ id: z.string().regex(SAFE_SECTION_ID, "Section ids may only contain letters, numbers, dashes and underscores (max 64 chars) \u2014 they become filenames.").describe("The new section's id: letters, numbers, dashes, underscores; max 64 chars. Must not already exist in the index."),
14
+ status: OpStatusSchema.optional().describe('Defaults to "draft" \u2014 invisible to viewers until promoted to "live".'),
15
+ access: z.array(z.string()).optional().describe("Audience slugs from list_audiences. Defaults to [] (everyone).")
16
+ });
17
+ var IndexOpSchema = z.discriminatedUnion("op", [
18
+ z.object({
19
+ op: z.literal("insertAfter"),
20
+ pageId: z.string().describe("The page whose order receives the sections."),
21
+ afterId: z.string().nullable().describe("Insert directly after this section id, or null for the start of the page."),
22
+ sections: z.array(SectionInsertSchema).min(1).describe("Sections to create, in the order they should appear. Each needs its body in this call's `sections`.")
23
+ }),
24
+ z.object({
25
+ op: z.literal("insertAt"),
26
+ pageId: z.string().describe("The page whose order receives the sections."),
27
+ position: z.number().int().min(0).describe("0-based index in the page's order; equal to the order's length appends."),
28
+ sections: z.array(SectionInsertSchema).min(1).describe("Sections to create, in the order they should appear. Each needs its body in this call's `sections`.")
29
+ }),
30
+ z.object({
31
+ op: z.literal("move"),
32
+ pageId: z.string().describe("Destination page id (may be the section's current page)."),
33
+ id: z.string().describe("The existing section to move."),
34
+ afterId: z.string().nullable().describe("Place it directly after this section id in the destination page, or null for the start.")
35
+ }),
36
+ z.object({
37
+ op: z.literal("remove"),
38
+ ids: z.array(z.string()).min(1).describe("Sections to delete: removed from the page order AND from sections{}, and their content files are deleted.")
39
+ }),
40
+ z.object({
41
+ op: z.literal("setMeta"),
42
+ id: z.string().describe("An existing section id."),
43
+ status: OpStatusSchema.optional().describe('New status. "live" is what makes a section visible to viewers.'),
44
+ access: z.array(z.string()).optional().describe("New audience slugs from list_audiences; [] means everyone.")
45
+ }),
46
+ z.object({
47
+ op: z.literal("setPageMeta"),
48
+ pageId: z.string().describe("An existing page id."),
49
+ title: z.string().optional().describe("New page title."),
50
+ slug: z.string().optional().describe("New URL slug (lowercase words joined by dashes). Not settable on the home page, whose slug is always empty."),
51
+ showInNav: z.boolean().optional().describe("Whether the page appears in site navigation."),
52
+ access: z.array(z.string()).optional().describe("New audience slugs from list_audiences; [] means everyone.")
53
+ })
54
+ ]);
55
+ function collectPostedTypes(sections) {
56
+ const types = {};
57
+ for (const s of sections ?? []) {
58
+ const type = s.content?.type;
59
+ if (typeof type === "string") types[s.id] = type;
60
+ }
61
+ return types;
62
+ }
63
+ function opTouchedSectionIds(ops) {
64
+ const ids = /* @__PURE__ */ new Set();
65
+ for (const op of ops) {
66
+ if (op.op === "insertAfter" || op.op === "insertAt") for (const s of op.sections) ids.add(s.id);
67
+ else if (op.op === "move" || op.op === "setMeta") ids.add(op.id);
68
+ else if (op.op === "remove") for (const id of op.ids) ids.add(id);
69
+ }
70
+ return [...ids];
71
+ }
72
+ var fmt = (ids) => ids.map((id) => `"${id}"`).join(", ");
73
+ function applyIndexOps(rawIndex, ops, newSectionTypes) {
74
+ const base = IndexSchema.safeParse(rawIndex);
75
+ if (!base.success) {
76
+ return {
77
+ ok: false,
78
+ error: "the site's current index could not be parsed, so indexOps cannot be applied \u2014 read it with get_site_index and post a repaired full `index` instead. " + base.error.issues.map((i) => i.message).join("; ")
79
+ };
80
+ }
81
+ const index = {
82
+ ...base.data,
83
+ pages: base.data.pages.map((p) => ({ ...p, order: [...p.order] })),
84
+ sections: Object.fromEntries(Object.entries(base.data.sections).map(([k, v]) => [k, { ...v }]))
85
+ };
86
+ const removed = /* @__PURE__ */ new Set();
87
+ const warnings = [];
88
+ const fail = (error) => ({ ok: false, error });
89
+ for (const [i, op] of ops.entries()) {
90
+ const at = `indexOps[${i}] ${op.op}`;
91
+ if (op.op === "insertAfter" || op.op === "insertAt") {
92
+ const page2 = index.pages.find((p) => p.id === op.pageId);
93
+ if (!page2) return fail(`${at}: no page with id "${op.pageId}" \u2014 page ids come from get_site_index.`);
94
+ let position;
95
+ if (op.op === "insertAfter") {
96
+ if (op.afterId === null) position = 0;
97
+ else {
98
+ const idx = page2.order.indexOf(op.afterId);
99
+ if (idx === -1) return fail(`${at}: afterId "${op.afterId}" is not in page "${op.pageId}"'s order.`);
100
+ position = idx + 1;
101
+ }
102
+ } else {
103
+ if (op.position > page2.order.length) {
104
+ return fail(`${at}: position ${op.position} is out of range for page "${op.pageId}" (valid: 0..${page2.order.length}).`);
105
+ }
106
+ position = op.position;
107
+ }
108
+ const metas = [];
109
+ const seen = /* @__PURE__ */ new Set();
110
+ for (const s of op.sections) {
111
+ if (seen.has(s.id)) return fail(`${at}: section "${s.id}" is listed twice in this op's \`sections\`.`);
112
+ seen.add(s.id);
113
+ if (index.sections[s.id]) {
114
+ return fail(`${at}: section "${s.id}" already exists in the index \u2014 use move to relocate it, or setMeta to change its status/access.`);
115
+ }
116
+ if (!SAFE_SECTION_ID.test(s.id)) {
117
+ return fail(`${at}: section id "${s.id}" is not usable \u2014 ids become filenames, so they may only contain letters, numbers, dashes and underscores (max 64 chars).`);
118
+ }
119
+ const type = newSectionTypes[s.id];
120
+ if (!type) {
121
+ return fail(`${at}: section "${s.id}" has no usable body in this call \u2014 post its full body ({ "type": "...", "content": {...} }) in \`sections\` in the same save; an inserted section's type comes from the body.`);
122
+ }
123
+ const meta = { type, status: s.status ?? "draft", access: s.access ?? [] };
124
+ const stranded = page2.access.length > 0 ? meta.access.filter((a) => !page2.access.includes(a)) : [];
125
+ if (stranded.length > 0) {
126
+ warnings.push(
127
+ `${at}: section "${s.id}" carries audience(s) ${fmt(stranded)} that page "${op.pageId}" does not allow, so no audienced viewer will see it \u2014 clear it with setMeta, or widen the page's access.`
128
+ );
129
+ }
130
+ metas.push([s.id, meta]);
131
+ }
132
+ page2.order.splice(position, 0, ...metas.map(([id]) => id));
133
+ for (const [id, meta] of metas) index.sections[id] = meta;
134
+ continue;
135
+ }
136
+ if (op.op === "move") {
137
+ const meta = index.sections[op.id];
138
+ if (!meta) return fail(`${at}: section "${op.id}" is not in the index.`);
139
+ const dest = index.pages.find((p) => p.id === op.pageId);
140
+ if (!dest) return fail(`${at}: no page with id "${op.pageId}" \u2014 page ids come from get_site_index.`);
141
+ if (op.afterId === op.id) return fail(`${at}: cannot move section "${op.id}" after itself.`);
142
+ for (const p of index.pages) {
143
+ const idx = p.order.indexOf(op.id);
144
+ if (idx !== -1) p.order.splice(idx, 1);
145
+ }
146
+ let position;
147
+ if (op.afterId === null) position = 0;
148
+ else {
149
+ const idx = dest.order.indexOf(op.afterId);
150
+ if (idx === -1) return fail(`${at}: afterId "${op.afterId}" is not in destination page "${op.pageId}"'s order.`);
151
+ position = idx + 1;
152
+ }
153
+ dest.order.splice(position, 0, op.id);
154
+ const stranded = dest.access.length > 0 ? meta.access.filter((a) => !dest.access.includes(a)) : [];
155
+ if (stranded.length > 0) {
156
+ warnings.push(
157
+ `${at}: section "${op.id}" carries audience(s) ${fmt(stranded)} that page "${op.pageId}" does not allow, so no audienced viewer will see it \u2014 clear it with setMeta, or widen the page's access.`
158
+ );
159
+ }
160
+ continue;
161
+ }
162
+ if (op.op === "remove") {
163
+ for (const id of op.ids) {
164
+ if (!index.sections[id]) return fail(`${at}: section "${id}" is not in the index.`);
165
+ delete index.sections[id];
166
+ for (const p of index.pages) {
167
+ const idx = p.order.indexOf(id);
168
+ if (idx !== -1) p.order.splice(idx, 1);
169
+ }
170
+ removed.add(id);
171
+ }
172
+ continue;
173
+ }
174
+ if (op.op === "setMeta") {
175
+ if (op.status === void 0 && op.access === void 0) {
176
+ return fail(`${at}: nothing to set \u2014 provide status and/or access.`);
177
+ }
178
+ const meta = index.sections[op.id];
179
+ if (!meta) return fail(`${at}: section "${op.id}" is not in the index.`);
180
+ if (op.status !== void 0) meta.status = op.status;
181
+ if (op.access !== void 0) meta.access = op.access;
182
+ continue;
183
+ }
184
+ if (op.title === void 0 && op.slug === void 0 && op.showInNav === void 0 && op.access === void 0) {
185
+ return fail(`${at}: nothing to set \u2014 provide title, slug, showInNav and/or access.`);
186
+ }
187
+ const page = index.pages.find((p) => p.id === op.pageId);
188
+ if (!page) return fail(`${at}: no page with id "${op.pageId}" \u2014 page ids come from get_site_index.`);
189
+ if (op.slug !== void 0 && page.isHome) {
190
+ return fail(`${at}: the home page's slug is always empty and cannot be set. Promote a different page to home in the editor if you need to change which page is the root.`);
191
+ }
192
+ if (op.slug !== void 0 && RESERVED_SLUGS.includes(op.slug)) {
193
+ return fail(`${at}: slug "${op.slug}" is reserved by a platform route and would shadow this page. Pick another slug.`);
194
+ }
195
+ if (op.title !== void 0) page.title = op.title;
196
+ if (op.slug !== void 0) page.slug = op.slug;
197
+ if (op.showInNav !== void 0) page.showInNav = op.showInNav;
198
+ if (op.access !== void 0) {
199
+ const dropped = page.access.filter((a) => !op.access.includes(a));
200
+ page.access = op.access;
201
+ if (dropped.length > 0 && op.access.length > 0) {
202
+ const stranded = page.order.filter((id) => index.sections[id]?.access.some((a) => dropped.includes(a)));
203
+ if (stranded.length > 0) {
204
+ warnings.push(
205
+ `${at}: section(s) ${fmt(stranded)} still carry audience(s) ${fmt(dropped)} that page "${op.pageId}" no longer allows, so no audienced viewer will see them \u2014 clear them with setMeta.`
206
+ );
207
+ }
208
+ }
209
+ }
210
+ }
211
+ const removedIds = [...removed].filter((id) => !index.sections[id]);
212
+ const validated = IndexSchema.safeParse(index);
213
+ if (!validated.success) {
214
+ return fail(`applying indexOps produced an invalid index: ${validated.error.issues.map((issue) => issue.message).join("; ")}`);
215
+ }
216
+ return { ok: true, index: validated.data, removedIds, warnings };
217
+ }
218
+ export {
219
+ IndexOpSchema,
220
+ applyIndexOps,
221
+ collectPostedTypes,
222
+ opTouchedSectionIds
223
+ };
@@ -3,6 +3,7 @@ export { cn } from "./cn";
3
3
  export { audiencePasses } from "./pages";
4
4
  export { resolveChatbotName, resolveThinkingPhrases, DEFAULT_CHATBOT_NAME } from "./chatbot";
5
5
  export { generateNavLinks, toSectionId, type NavItem } from "./nav";
6
+ export { navEntries, pagesInNavOrder, groupOfPage, groupDisplayLabel, reconcileNav } from "./nav-tree";
6
7
  export { deriveContrast, contrastColor, relativeLuminance, contrastRatio, wcagLevel, suggestAccessibleOn, type WcagLevel, } from "./contrast";
7
8
  export { primaryVarValue, accentVarValue, onPrimaryVarValue } from "./theme-vars";
8
9
  export { sanitizeHtml, ensureSanitizer } from "./sanitize";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,KAAK,SAAS,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAA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