@riverbankcms/sdk 0.124.0 → 0.126.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.
Files changed (130) hide show
  1. package/README.md +3 -1
  2. package/dist/{PreviewEditorSidebar-DBmAJJkQ.mjs → PreviewEditorSidebar-DcYJxTgc.mjs} +67 -266
  3. package/dist/{PreviewEditorUI-CfGaz9cY.mjs → PreviewEditorUI-Ctt1yTJr.mjs} +3 -3
  4. package/dist/{PreviewQueryProvider-BH-3-jSj.mjs → PreviewQueryProvider-DgFDIwvK.mjs} +1 -1
  5. package/dist/{SdkPreviewModeRuntime-BW9Z8j8T.mjs → SdkPreviewModeRuntime-CvW1vdQ4.mjs} +38 -30
  6. package/dist/{SiteChromeCustomizeContext-2z8moxYf.mjs → SiteChromeCustomizeContext-C87qlKWw.mjs} +493 -1378
  7. package/dist/_dts/ai/src/contracts/proposals.d.ts +1354 -202
  8. package/dist/_dts/api/src/accessAdmin.d.ts +2 -14
  9. package/dist/_dts/api/src/common/envelope.d.ts +1 -1
  10. package/dist/_dts/api/src/contentRuntime.d.ts +0 -2
  11. package/dist/_dts/api/src/endpoints.d.ts +0 -7
  12. package/dist/_dts/api/src/sdk-event-upsert.d.ts +42 -0
  13. package/dist/_dts/api/src/sdkContracts.d.ts +11 -9
  14. package/dist/_dts/api/src/siteAccessAdmin.d.ts +23 -0
  15. package/dist/_dts/api/src/siteOperations.d.ts +18 -1
  16. package/dist/_dts/api/src/siteRuntimeEndpoints.d.ts +1 -14
  17. package/dist/_dts/billing/src/plans/types.d.ts +24 -5
  18. package/dist/_dts/blocks/src/contracts/non-block-islands.d.ts +4 -0
  19. package/dist/_dts/blocks/src/contracts/proof-block-islands.d.ts +2 -0
  20. package/dist/_dts/blocks/src/system/runtime/components/registry.client.d.ts +1 -0
  21. package/dist/_dts/blocks/src/system/runtime/nodes/event-details/logic.d.ts +2 -0
  22. package/dist/_dts/blocks/src/system/runtime/nodes/event-details.client.d.ts +3 -1
  23. package/dist/_dts/blocks/src/system/runtime/nodes/event-details.server.d.ts +2 -1
  24. package/dist/_dts/blocks/src/system/runtime/nodes/event-registration/useEventRegistrationStripeReturn.d.ts +15 -2
  25. package/dist/_dts/db/src/generated/supabase/database.types.d.ts +331 -19
  26. package/dist/_dts/preview-next/src/client/preview/PreviewEditorSidebar.d.ts +1 -2
  27. package/dist/_dts/preview-next/src/client/preview/PreviewShell.d.ts +2 -3
  28. package/dist/_dts/preview-next/src/client/preview/PreviewShellLayout.d.ts +1 -2
  29. package/dist/_dts/preview-next/src/client/preview/SiteChromeCustomizeContext.d.ts +3 -12
  30. package/dist/_dts/preview-next/src/client/preview/StyleConfigurator.d.ts +3 -13
  31. package/dist/_dts/preview-next/src/client/preview/StyleConfigurator.state.d.ts +8 -100
  32. package/dist/_dts/preview-next/src/client/preview/siteStylePreviewPlanner.d.ts +1 -4
  33. package/dist/_dts/preview-next/src/client/preview/styleConfiguratorApplyPayload.d.ts +1 -15
  34. package/dist/_dts/preview-next/src/client/preview/styleConfiguratorSnapshot.d.ts +11 -21
  35. package/dist/_dts/sdk/src/cli/commands/event.d.ts +2 -2
  36. package/dist/_dts/sdk/src/cli/commands/eventOccurrenceSchedule.d.ts +12 -0
  37. package/dist/_dts/sdk/src/cli/commands/push/pushAllExtras.d.ts +6 -0
  38. package/dist/_dts/sdk/src/cli/commands/style.d.ts +1 -1
  39. package/dist/_dts/sdk/src/cli/content/legacyEventScheduleShapeError.d.ts +5 -0
  40. package/dist/_dts/sdk/src/cli/content/localEventSchedule.d.ts +17 -0
  41. package/dist/_dts/sdk/src/cli/content/reader.d.ts +5 -10
  42. package/dist/_dts/sdk/src/cli/migrations/events.d.ts +1 -1
  43. package/dist/_dts/sdk/src/cli/site-commands/eventScheduleCompiler.d.ts +24 -0
  44. package/dist/_dts/sdk/src/client/management/http.d.ts +1 -1
  45. package/dist/_dts/sdk/src/client/management/types.d.ts +3 -28
  46. package/dist/_dts/sdk/src/config/index.d.ts +1 -1
  47. package/dist/_dts/sdk/src/public-api/contracts.d.ts +5 -20
  48. package/dist/_dts/sdk/src/rendering/index.d.ts +1 -1
  49. package/dist/_dts/sdk/src/version.d.ts +1 -1
  50. package/dist/_dts/site-commands/src/commandContract.d.ts +33 -5
  51. package/dist/_dts/site-commands/src/commandDomain.d.ts +2 -2
  52. package/dist/_dts/site-commands/src/commands.d.ts +38 -9
  53. package/dist/_dts/site-commands/src/siteStyleCommandSchema.d.ts +28 -1
  54. package/dist/_dts/site-commands/src/siteStyleSelectionSchemaBuilder.d.ts +4 -4
  55. package/dist/_dts/theme-core/src/palette/concretePalette.d.ts +20 -0
  56. package/dist/_dts/theme-core/src/palette/curated/index.d.ts +2 -17
  57. package/dist/_dts/theme-core/src/palette/index.d.ts +1 -6
  58. package/dist/_dts/theme-core/src/palette/schema.d.ts +39 -0
  59. package/dist/_dts/theme-core/src/schema.d.ts +38 -26
  60. package/dist/_dts/theme-core/src/site-styles/previewCompiler.d.ts +4 -6
  61. package/dist/_dts/theme-core/src/site-styles/runtimeCompiler.d.ts +5 -6
  62. package/dist/cli/index.mjs +631 -525
  63. package/dist/cli/init-docs/content/cli-reference.md +6 -3
  64. package/dist/cli/init-docs/content/content-management.md +24 -13
  65. package/dist/client/{DiscountCodeDisclosure-DxvjKvck.mjs → DiscountCodeDisclosure-DS0AuFWW.mjs} +1 -1
  66. package/dist/client/{EventCombined.client-BydMGc4c.mjs → EventCombined.client-DtMxLr7q.mjs} +2 -2
  67. package/dist/client/{EventListing.client-vpzhhysN.mjs → EventListing.client-BdLSRNg1.mjs} +2 -2
  68. package/dist/client/{LeafletStaticMap-CB07rpf8.mjs → LeafletStaticMap-BrpC6vsT.mjs} +1 -1
  69. package/dist/client/{MagicLinkForm-BzyRJ8VF.mjs → MagicLinkForm-Bt3IuLMy.mjs} +1 -1
  70. package/dist/client/{StepIndicator-CTcGf8Be.mjs → StepIndicator-CBYPFVoy.mjs} +2 -2
  71. package/dist/client/{accordion-B-DUDLRD.mjs → accordion-BqqwPJWM.mjs} +1 -1
  72. package/dist/client/{bookingForm-DSbClLcZ.mjs → bookingForm-SneP3yxC.mjs} +5 -6
  73. package/dist/client/bookings.mjs +190 -24
  74. package/dist/client/{carousel-B6Ccdx8M.mjs → carousel-BTIR9L3I.mjs} +1 -1
  75. package/dist/client/{cart-BZh8G8wM.mjs → cart-bqiqd8SX.mjs} +3 -3
  76. package/dist/client/{checkout-o6zaC-kM.mjs → checkout-WbTFV5v4.mjs} +3 -3
  77. package/dist/client/client.mjs +175 -223
  78. package/dist/client/{courseRegistration-Cf11pNDs.mjs → courseRegistration-BcemLAdN.mjs} +6 -7
  79. package/dist/client/{eventCalendar-BeXrdsSE.mjs → eventCalendar-CsxIw0V_.mjs} +4 -4
  80. package/dist/client/{eventCombined-DA76PZgG.mjs → eventCombined-B6XMoHfa.mjs} +2 -2
  81. package/dist/client/{eventDetails-BLxg0rok.mjs → eventDetails-BJaoPPfo.mjs} +10 -5
  82. package/dist/client/{eventListing-tO9LheBX.mjs → eventListing-DgwdYHRT.mjs} +2 -2
  83. package/dist/client/{eventRegistration-Cnene9D9.mjs → eventRegistration-C0O3folu.mjs} +30 -22
  84. package/dist/client/{form-DZf72CHB.mjs → form-Bk9txGFt.mjs} +1 -1
  85. package/dist/client/{headerSection-Hioja5Cr.mjs → headerSection-yIBt0yTv.mjs} +2 -2
  86. package/dist/client/hooks.mjs +54 -102
  87. package/dist/client/{locationMap-DwhUXEix.mjs → locationMap-C-3KIpv-.mjs} +2 -2
  88. package/dist/client/{newsletterForm-C350bEQf.mjs → newsletterForm-CzB8g8h2.mjs} +1 -1
  89. package/dist/client/{pricing-BYWN_ATa.mjs → pricing-C1QeDes_.mjs} +1 -1
  90. package/dist/client/{productDetail-CCqCyXgU.mjs → productDetail-w7SBp5uc.mjs} +3 -3
  91. package/dist/client/{productList-BAiNJrOU.mjs → productList-D0tGKHGf.mjs} +3 -3
  92. package/dist/client/{propsDecoder-DeunRj6m.mjs → propsDecoder-Bcin2DB3.mjs} +172 -11
  93. package/dist/client/rendering/client.mjs +322 -363
  94. package/dist/client/rendering/islands.mjs +18 -18
  95. package/dist/client/rendering.mjs +231 -272
  96. package/dist/client/{useDiscountCodeUi-I-92-x2V.mjs → scrollToBlock-h-o_STf_.mjs} +18 -2
  97. package/dist/client/{shop-DUmCdBtw.mjs → shop-BGzmL8O_.mjs} +5 -6
  98. package/dist/client/{shop-commerce-CY27mEUr.mjs → shop-commerce-lX8QxjX-.mjs} +4 -4
  99. package/dist/client/{shop-commerce-store-ChXPbWfa.mjs → shop-commerce-store-CEurARtu.mjs} +1 -1
  100. package/dist/client/{shopShared-q0kin1cv.mjs → shopShared-DXxH8xxw.mjs} +2 -2
  101. package/dist/client/{useEventFilters-DlcVluZh.mjs → useEventFilters-B591g9vd.mjs} +2 -2
  102. package/dist/client/{usePolling-Bz7GFV_a.mjs → usePolling-BvnChV4m.mjs} +2 -2
  103. package/dist/preview-next/before-render.mjs +0 -7
  104. package/dist/preview-next/client/runtime.mjs +4 -4
  105. package/dist/preview-next/middleware.mjs +0 -7
  106. package/dist/{previewAuthStore-CJX21dGi.mjs → previewAuthStore-Dev9CdG9.mjs} +0 -7
  107. package/dist/{sdk-runtime-OnPM8Z69.mjs → sdk-runtime-M__i3Jce.mjs} +2 -2
  108. package/dist/{separator-CPtfzHqA.mjs → separator-VSlnI9bc.mjs} +1 -1
  109. package/dist/server/components.mjs +99 -141
  110. package/dist/server/config-validation.mjs +54 -102
  111. package/dist/server/config.mjs +54 -102
  112. package/dist/server/data.mjs +54 -102
  113. package/dist/server/index.mjs +1 -8
  114. package/dist/server/next.mjs +103 -152
  115. package/dist/server/page-converter.mjs +54 -102
  116. package/dist/server/prebuild.mjs +1 -1
  117. package/dist/server/rendering/server.mjs +62 -104
  118. package/dist/server/rendering.mjs +100 -142
  119. package/dist/server/routing.mjs +75 -147
  120. package/dist/server/server.mjs +55 -110
  121. package/dist/server/theme-bridge.mjs +172 -162
  122. package/dist/server/theme.mjs +167 -11
  123. package/package.json +1 -1
  124. package/dist/_dts/theme-core/src/palette/editorState.d.ts +0 -75
  125. package/dist/_dts/theme-core/src/palette/libraryModel.d.ts +0 -64
  126. package/dist/_dts/theme-core/src/palette/persistenceReadSource.d.ts +0 -81
  127. package/dist/_dts/theme-core/src/palette/resolveSelection.d.ts +0 -75
  128. package/dist/_dts/theme-core/src/palette/selection.d.ts +0 -74
  129. package/dist/_dts/theme-core/src/palette/sitePalettePersistence.d.ts +0 -34
  130. package/dist/client/scrollToBlock-C86BYkyV.mjs +0 -17
@@ -195,6 +195,177 @@ function parseThemeColorToken(value) {
195
195
  }
196
196
  const themeColorTokenSchema = z$1.string().min(1).refine((value) => Boolean(isThemeColorToken(value)), "Expected a known Theme V2 color token");
197
197
  //#endregion
198
+ //#region ../theme-core/src/palette/colors.ts
199
+ const HEX_COLOR_REGEX = /^#[0-9a-f]{6}$/;
200
+ const NORMALIZABLE_HEX_REGEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
201
+ const THEME_PALETTE_COLOR_ORDER = [
202
+ "primary",
203
+ "secondary",
204
+ "accent",
205
+ "success",
206
+ "warning",
207
+ "destructive",
208
+ "background",
209
+ "surface",
210
+ "surfaceAlt",
211
+ "muted",
212
+ "text",
213
+ "primaryForeground",
214
+ "border"
215
+ ];
216
+ const hexColorSchema = z$1.string().regex(HEX_COLOR_REGEX, "Hex must be #RRGGBB (lowercase)").transform((value) => value);
217
+ const paletteModeSchema = z$1.enum(["light", "dark"]);
218
+ const PALETTE_VALUE_KEY_PREFIX = "palette-value:v1|";
219
+ z$1.string().regex(/^[0-9a-f]{64}$/, "Palette hash must be a lowercase SHA-256 value").transform((value) => value);
220
+ const paletteColorsSchema = z$1.object({
221
+ primary: hexColorSchema,
222
+ primaryForeground: hexColorSchema,
223
+ secondary: hexColorSchema,
224
+ accent: hexColorSchema,
225
+ success: hexColorSchema,
226
+ warning: hexColorSchema,
227
+ destructive: hexColorSchema,
228
+ background: hexColorSchema,
229
+ surface: hexColorSchema,
230
+ surfaceAlt: hexColorSchema,
231
+ muted: hexColorSchema,
232
+ text: hexColorSchema,
233
+ border: hexColorSchema
234
+ }).strict().transform((value) => value);
235
+ function normalizePaletteHex(value) {
236
+ if (!NORMALIZABLE_HEX_REGEX.test(value)) return null;
237
+ const normalized = value.toLowerCase();
238
+ if (normalized.length === 7) return normalized;
239
+ const triplet = normalized.slice(1);
240
+ const red = triplet.charAt(0);
241
+ const green = triplet.charAt(1);
242
+ const blue = triplet.charAt(2);
243
+ return `#${red}${red}${green}${green}${blue}${blue}`;
244
+ }
245
+ function paletteColorsFromEntries(entries) {
246
+ const values = {};
247
+ for (const entry of entries) {
248
+ const parsedRole = paletteTokenNameSchema.safeParse(entry.name);
249
+ if (!parsedRole.success) return {
250
+ ok: false,
251
+ error: {
252
+ kind: "unknown-role",
253
+ role: entry.name
254
+ }
255
+ };
256
+ const role = parsedRole.data;
257
+ if (values[role] !== void 0) return {
258
+ ok: false,
259
+ error: {
260
+ kind: "duplicate-role",
261
+ role
262
+ }
263
+ };
264
+ const hex = normalizePaletteHex(entry.hex);
265
+ if (!hex) return {
266
+ ok: false,
267
+ error: {
268
+ kind: "invalid-color",
269
+ role,
270
+ value: entry.hex
271
+ }
272
+ };
273
+ values[role] = hex;
274
+ }
275
+ const missing = PALETTE_TOKEN_NAMES.filter((role) => values[role] === void 0);
276
+ if (missing.length > 0) return {
277
+ ok: false,
278
+ error: {
279
+ kind: "missing-roles",
280
+ roles: missing
281
+ }
282
+ };
283
+ return {
284
+ ok: true,
285
+ colors: paletteColorsSchema.parse(values)
286
+ };
287
+ }
288
+ function requirePaletteColorsFromEntries(entries) {
289
+ const result = paletteColorsFromEntries(entries);
290
+ if (result.ok) return result.colors;
291
+ throw new Error(`Invalid complete palette: ${result.error.kind}`);
292
+ }
293
+ function paletteColorEntries(colors) {
294
+ return THEME_PALETTE_COLOR_ORDER.map((name) => ({
295
+ name,
296
+ hex: colors[name]
297
+ }));
298
+ }
299
+ function paletteColorFingerprint(colors) {
300
+ return PALETTE_TOKEN_NAMES.map((name) => `${name}:${colors[name]}`).join("|");
301
+ }
302
+ function canonicalPaletteHashInput(colors, mode) {
303
+ return `${mode}|${paletteColorFingerprint(colors)}`;
304
+ }
305
+ /**
306
+ * The shared TypeScript/SQL protocol. Do not reorder roles: the order comes
307
+ * from PALETTE_TOKEN_NAMES through canonicalPaletteHashInput.
308
+ */
309
+ function paletteValueKey(colors, mode) {
310
+ return `${PALETTE_VALUE_KEY_PREFIX}${canonicalPaletteHashInput(colors, mode)}`;
311
+ }
312
+ /** Parses only the exact v1 canonical form emitted by paletteValueKey. */
313
+ function parsePaletteValueKey(value) {
314
+ if (typeof value !== "string" || !value.startsWith(PALETTE_VALUE_KEY_PREFIX)) return null;
315
+ const [rawMode, ...rawRoles] = value.slice(17).split("|");
316
+ const mode = paletteModeSchema.safeParse(rawMode);
317
+ if (!mode.success || rawRoles.length !== PALETTE_TOKEN_NAMES.length) return null;
318
+ const colors = paletteColorsFromEntries(rawRoles.map((roleValue) => {
319
+ const separator = roleValue.indexOf(":");
320
+ return separator === -1 ? {
321
+ name: "",
322
+ hex: ""
323
+ } : {
324
+ name: roleValue.slice(0, separator),
325
+ hex: roleValue.slice(separator + 1)
326
+ };
327
+ }));
328
+ if (!colors.ok || paletteValueKey(colors.colors, mode.data) !== value) return null;
329
+ return value;
330
+ }
331
+ const paletteValueKeySchema = z$1.string().transform((value, ctx) => {
332
+ const parsed = parsePaletteValueKey(value);
333
+ if (parsed) return parsed;
334
+ ctx.addIssue({
335
+ code: "custom",
336
+ message: "Invalid canonical palette value key"
337
+ });
338
+ return z$1.NEVER;
339
+ });
340
+ //#endregion
341
+ //#region ../theme-core/src/palette/schema.ts
342
+ const colourHexString = z$1.string().regex(/^#([0-9A-Fa-f]{3}){1,2}$/);
343
+ const paletteColorSchema = z$1.object({
344
+ name: z$1.string().min(1),
345
+ hex: colourHexString
346
+ });
347
+ const paletteMetaSchema = z$1.object({ mode: z$1.enum(["light", "dark"]) });
348
+ const paletteSchema = z$1.object({
349
+ colors: z$1.array(paletteColorSchema),
350
+ meta: paletteMetaSchema
351
+ }).transform((palette, ctx) => {
352
+ const colors = paletteColorsFromEntries(palette.colors);
353
+ if (!colors.ok) {
354
+ ctx.addIssue({
355
+ code: "custom",
356
+ message: `Invalid complete palette: ${colors.error.kind}`
357
+ });
358
+ return z$1.NEVER;
359
+ }
360
+ return {
361
+ colors: paletteColorEntries(colors.colors).map(({ name, hex }) => ({
362
+ name: String(name),
363
+ hex: String(hex)
364
+ })),
365
+ meta: palette.meta
366
+ };
367
+ });
368
+ //#endregion
198
369
  //#region ../theme-core/src/buttons/types.ts
199
370
  /**
200
371
  * Standard semantic variant roles a theme exposes.
@@ -4116,16 +4287,6 @@ const axesSchema = z$1.object({
4116
4287
  "expressive"
4117
4288
  ])
4118
4289
  });
4119
- const colourHexString = z$1.string().regex(/^#([0-9A-Fa-f]{3}){1,2}$/);
4120
- const paletteColorSchema = z$1.object({
4121
- name: z$1.string().min(1),
4122
- hex: colourHexString
4123
- });
4124
- const paletteMetaSchema = z$1.object({ mode: z$1.enum(["light", "dark"]) });
4125
- const paletteSchema = z$1.object({
4126
- colors: z$1.array(paletteColorSchema),
4127
- meta: paletteMetaSchema
4128
- });
4129
4290
  const typographyStyleSchema = z$1.object({
4130
4291
  family: z$1.string().min(1),
4131
4292
  weight: z$1.enum([
@@ -5030,128 +5191,6 @@ function generateShadowCssVars(theme) {
5030
5191
  };
5031
5192
  }
5032
5193
  //#endregion
5033
- //#region ../theme-core/src/palette/colors.ts
5034
- const HEX_COLOR_REGEX = /^#[0-9a-f]{6}$/;
5035
- const NORMALIZABLE_HEX_REGEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
5036
- const hexColorSchema = z$1.string().regex(HEX_COLOR_REGEX, "Hex must be #RRGGBB (lowercase)").transform((value) => value);
5037
- const paletteModeSchema = z$1.enum(["light", "dark"]);
5038
- const PALETTE_VALUE_KEY_PREFIX = "palette-value:v1|";
5039
- z$1.string().regex(/^[0-9a-f]{64}$/, "Palette hash must be a lowercase SHA-256 value").transform((value) => value);
5040
- const paletteColorsSchema = z$1.object({
5041
- primary: hexColorSchema,
5042
- primaryForeground: hexColorSchema,
5043
- secondary: hexColorSchema,
5044
- accent: hexColorSchema,
5045
- success: hexColorSchema,
5046
- warning: hexColorSchema,
5047
- destructive: hexColorSchema,
5048
- background: hexColorSchema,
5049
- surface: hexColorSchema,
5050
- surfaceAlt: hexColorSchema,
5051
- muted: hexColorSchema,
5052
- text: hexColorSchema,
5053
- border: hexColorSchema
5054
- }).strict().transform((value) => value);
5055
- function normalizePaletteHex(value) {
5056
- if (!NORMALIZABLE_HEX_REGEX.test(value)) return null;
5057
- const normalized = value.toLowerCase();
5058
- if (normalized.length === 7) return normalized;
5059
- const triplet = normalized.slice(1);
5060
- const red = triplet.charAt(0);
5061
- const green = triplet.charAt(1);
5062
- const blue = triplet.charAt(2);
5063
- return `#${red}${red}${green}${green}${blue}${blue}`;
5064
- }
5065
- function paletteColorsFromEntries(entries) {
5066
- const values = {};
5067
- for (const entry of entries) {
5068
- const parsedRole = paletteTokenNameSchema.safeParse(entry.name);
5069
- if (!parsedRole.success) return {
5070
- ok: false,
5071
- error: {
5072
- kind: "unknown-role",
5073
- role: entry.name
5074
- }
5075
- };
5076
- const role = parsedRole.data;
5077
- if (values[role] !== void 0) return {
5078
- ok: false,
5079
- error: {
5080
- kind: "duplicate-role",
5081
- role
5082
- }
5083
- };
5084
- const hex = normalizePaletteHex(entry.hex);
5085
- if (!hex) return {
5086
- ok: false,
5087
- error: {
5088
- kind: "invalid-color",
5089
- role,
5090
- value: entry.hex
5091
- }
5092
- };
5093
- values[role] = hex;
5094
- }
5095
- const missing = PALETTE_TOKEN_NAMES.filter((role) => values[role] === void 0);
5096
- if (missing.length > 0) return {
5097
- ok: false,
5098
- error: {
5099
- kind: "missing-roles",
5100
- roles: missing
5101
- }
5102
- };
5103
- return {
5104
- ok: true,
5105
- colors: paletteColorsSchema.parse(values)
5106
- };
5107
- }
5108
- function requirePaletteColorsFromEntries(entries) {
5109
- const result = paletteColorsFromEntries(entries);
5110
- if (result.ok) return result.colors;
5111
- throw new Error(`Invalid complete palette: ${result.error.kind}`);
5112
- }
5113
- function paletteColorFingerprint(colors) {
5114
- return PALETTE_TOKEN_NAMES.map((name) => `${name}:${colors[name]}`).join("|");
5115
- }
5116
- function canonicalPaletteHashInput(colors, mode) {
5117
- return `${mode}|${paletteColorFingerprint(colors)}`;
5118
- }
5119
- /**
5120
- * The shared TypeScript/SQL protocol. Do not reorder roles: the order comes
5121
- * from PALETTE_TOKEN_NAMES through canonicalPaletteHashInput.
5122
- */
5123
- function paletteValueKey(colors, mode) {
5124
- return `${PALETTE_VALUE_KEY_PREFIX}${canonicalPaletteHashInput(colors, mode)}`;
5125
- }
5126
- /** Parses only the exact v1 canonical form emitted by paletteValueKey. */
5127
- function parsePaletteValueKey(value) {
5128
- if (typeof value !== "string" || !value.startsWith(PALETTE_VALUE_KEY_PREFIX)) return null;
5129
- const [rawMode, ...rawRoles] = value.slice(17).split("|");
5130
- const mode = paletteModeSchema.safeParse(rawMode);
5131
- if (!mode.success || rawRoles.length !== PALETTE_TOKEN_NAMES.length) return null;
5132
- const colors = paletteColorsFromEntries(rawRoles.map((roleValue) => {
5133
- const separator = roleValue.indexOf(":");
5134
- return separator === -1 ? {
5135
- name: "",
5136
- hex: ""
5137
- } : {
5138
- name: roleValue.slice(0, separator),
5139
- hex: roleValue.slice(separator + 1)
5140
- };
5141
- }));
5142
- if (!colors.ok || paletteValueKey(colors.colors, mode.data) !== value) return null;
5143
- return value;
5144
- }
5145
- const paletteValueKeySchema = z$1.string().transform((value, ctx) => {
5146
- const parsed = parsePaletteValueKey(value);
5147
- if (parsed) return parsed;
5148
- ctx.addIssue({
5149
- code: "custom",
5150
- message: "Invalid canonical palette value key"
5151
- });
5152
- return z$1.NEVER;
5153
- });
5154
- //#endregion
5155
5194
  //#region ../theme-core/src/site-styles/styleTags.ts
5156
5195
  /**
5157
5196
  * Descriptive style-axis metadata for button personalities and palette
@@ -6443,13 +6482,6 @@ const warmDarkKirtanGold = defineCuratedPalette({
6443
6482
  });
6444
6483
  //#endregion
6445
6484
  //#region ../theme-core/src/palette/curated/index.ts
6446
- /**
6447
- * Curated palette library.
6448
- *
6449
- * Authoring keys are readable source aliases. Value keys are derived from the
6450
- * complete mode and semantic colours and are the only curated identity used at
6451
- * persistence and runtime boundaries.
6452
- */
6453
6485
  function admitCuratedPaletteDefinition(definition) {
6454
6486
  return {
6455
6487
  ...definition,
@@ -6476,11 +6508,8 @@ const curatedPalettes = [
6476
6508
  admitCuratedPaletteDefinition(warmDarkEmber),
6477
6509
  admitCuratedPaletteDefinition(warmDarkKirtanGold)
6478
6510
  ];
6479
- const curatedPalettesByValueKey = new Map(curatedPalettes.map((palette) => [palette.valueKey, palette]));
6511
+ new Map(curatedPalettes.map((palette) => [palette.valueKey, palette]));
6480
6512
  const curatedPalettesByAuthoringKey = new Map(curatedPalettes.map((palette) => [palette.authoringKey, palette]));
6481
- function findCuratedPalette(valueKey) {
6482
- return curatedPalettesByValueKey.get(valueKey);
6483
- }
6484
6513
  function findCuratedPaletteByAuthoringKey(authoringKey) {
6485
6514
  return curatedPalettesByAuthoringKey.get(authoringKey);
6486
6515
  }
@@ -6489,25 +6518,6 @@ function requireCuratedPaletteValueKey(authoringKey) {
6489
6518
  if (!palette) throw new Error(`Unknown curated palette authoring key "${authoringKey}"`);
6490
6519
  return palette.valueKey;
6491
6520
  }
6492
- z$1.string().transform((value, ctx) => {
6493
- const valueKey = parsePaletteValueKey(value);
6494
- if (!valueKey) {
6495
- ctx.addIssue({
6496
- code: "custom",
6497
- message: "Invalid canonical palette value key"
6498
- });
6499
- return z$1.NEVER;
6500
- }
6501
- const palette = findCuratedPalette(valueKey);
6502
- if (!palette) {
6503
- ctx.addIssue({
6504
- code: "custom",
6505
- message: "Unknown curated palette value key"
6506
- });
6507
- return z$1.NEVER;
6508
- }
6509
- return palette.valueKey;
6510
- });
6511
6521
  //#endregion
6512
6522
  //#region ../theme-core/src/accordions/siteStyleDefaults.ts
6513
6523
  /**
@@ -431,7 +431,7 @@ const PALETTE_TOKEN_NAMES = [
431
431
  "text",
432
432
  "border"
433
433
  ];
434
- z$1.enum(PALETTE_TOKEN_NAMES);
434
+ const paletteTokenNameSchema = z$1.enum(PALETTE_TOKEN_NAMES);
435
435
  const themeColorBaseTokenNames = [
436
436
  ...PALETTE_TOKEN_NAMES,
437
437
  ...blockColorTokenNames,
@@ -478,6 +478,144 @@ function parseThemeColorToken(value) {
478
478
  }
479
479
  const themeColorTokenSchema = z$1.string().min(1).refine((value) => Boolean(isThemeColorToken(value)), "Expected a known Theme V2 color token");
480
480
  //#endregion
481
+ //#region ../theme-core/src/palette/colors.ts
482
+ const HEX_COLOR_REGEX = /^#[0-9a-f]{6}$/;
483
+ const NORMALIZABLE_HEX_REGEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
484
+ const THEME_PALETTE_COLOR_ORDER = [
485
+ "primary",
486
+ "secondary",
487
+ "accent",
488
+ "success",
489
+ "warning",
490
+ "destructive",
491
+ "background",
492
+ "surface",
493
+ "surfaceAlt",
494
+ "muted",
495
+ "text",
496
+ "primaryForeground",
497
+ "border"
498
+ ];
499
+ const hexColorSchema = z$1.string().regex(HEX_COLOR_REGEX, "Hex must be #RRGGBB (lowercase)").transform((value) => value);
500
+ const paletteModeSchema = z$1.enum(["light", "dark"]);
501
+ const PALETTE_VALUE_KEY_PREFIX = "palette-value:v1|";
502
+ z$1.string().regex(/^[0-9a-f]{64}$/, "Palette hash must be a lowercase SHA-256 value").transform((value) => value);
503
+ const paletteColorsSchema = z$1.object({
504
+ primary: hexColorSchema,
505
+ primaryForeground: hexColorSchema,
506
+ secondary: hexColorSchema,
507
+ accent: hexColorSchema,
508
+ success: hexColorSchema,
509
+ warning: hexColorSchema,
510
+ destructive: hexColorSchema,
511
+ background: hexColorSchema,
512
+ surface: hexColorSchema,
513
+ surfaceAlt: hexColorSchema,
514
+ muted: hexColorSchema,
515
+ text: hexColorSchema,
516
+ border: hexColorSchema
517
+ }).strict().transform((value) => value);
518
+ function normalizePaletteHex(value) {
519
+ if (!NORMALIZABLE_HEX_REGEX.test(value)) return null;
520
+ const normalized = value.toLowerCase();
521
+ if (normalized.length === 7) return normalized;
522
+ const triplet = normalized.slice(1);
523
+ const red = triplet.charAt(0);
524
+ const green = triplet.charAt(1);
525
+ const blue = triplet.charAt(2);
526
+ return `#${red}${red}${green}${green}${blue}${blue}`;
527
+ }
528
+ function paletteColorsFromEntries(entries) {
529
+ const values = {};
530
+ for (const entry of entries) {
531
+ const parsedRole = paletteTokenNameSchema.safeParse(entry.name);
532
+ if (!parsedRole.success) return {
533
+ ok: false,
534
+ error: {
535
+ kind: "unknown-role",
536
+ role: entry.name
537
+ }
538
+ };
539
+ const role = parsedRole.data;
540
+ if (values[role] !== void 0) return {
541
+ ok: false,
542
+ error: {
543
+ kind: "duplicate-role",
544
+ role
545
+ }
546
+ };
547
+ const hex = normalizePaletteHex(entry.hex);
548
+ if (!hex) return {
549
+ ok: false,
550
+ error: {
551
+ kind: "invalid-color",
552
+ role,
553
+ value: entry.hex
554
+ }
555
+ };
556
+ values[role] = hex;
557
+ }
558
+ const missing = PALETTE_TOKEN_NAMES.filter((role) => values[role] === void 0);
559
+ if (missing.length > 0) return {
560
+ ok: false,
561
+ error: {
562
+ kind: "missing-roles",
563
+ roles: missing
564
+ }
565
+ };
566
+ return {
567
+ ok: true,
568
+ colors: paletteColorsSchema.parse(values)
569
+ };
570
+ }
571
+ function paletteColorEntries(colors) {
572
+ return THEME_PALETTE_COLOR_ORDER.map((name) => ({
573
+ name,
574
+ hex: colors[name]
575
+ }));
576
+ }
577
+ function paletteColorFingerprint(colors) {
578
+ return PALETTE_TOKEN_NAMES.map((name) => `${name}:${colors[name]}`).join("|");
579
+ }
580
+ function canonicalPaletteHashInput(colors, mode) {
581
+ return `${mode}|${paletteColorFingerprint(colors)}`;
582
+ }
583
+ /**
584
+ * The shared TypeScript/SQL protocol. Do not reorder roles: the order comes
585
+ * from PALETTE_TOKEN_NAMES through canonicalPaletteHashInput.
586
+ */
587
+ function paletteValueKey(colors, mode) {
588
+ return `${PALETTE_VALUE_KEY_PREFIX}${canonicalPaletteHashInput(colors, mode)}`;
589
+ }
590
+ /** Parses only the exact v1 canonical form emitted by paletteValueKey. */
591
+ function parsePaletteValueKey(value) {
592
+ if (typeof value !== "string" || !value.startsWith(PALETTE_VALUE_KEY_PREFIX)) return null;
593
+ const [rawMode, ...rawRoles] = value.slice(17).split("|");
594
+ const mode = paletteModeSchema.safeParse(rawMode);
595
+ if (!mode.success || rawRoles.length !== PALETTE_TOKEN_NAMES.length) return null;
596
+ const colors = paletteColorsFromEntries(rawRoles.map((roleValue) => {
597
+ const separator = roleValue.indexOf(":");
598
+ return separator === -1 ? {
599
+ name: "",
600
+ hex: ""
601
+ } : {
602
+ name: roleValue.slice(0, separator),
603
+ hex: roleValue.slice(separator + 1)
604
+ };
605
+ }));
606
+ if (!colors.ok || paletteValueKey(colors.colors, mode.data) !== value) return null;
607
+ return value;
608
+ }
609
+ z$1.string().transform((value, ctx) => {
610
+ const parsed = parsePaletteValueKey(value);
611
+ if (parsed) return parsed;
612
+ ctx.addIssue({
613
+ code: "custom",
614
+ message: "Invalid canonical palette value key"
615
+ });
616
+ return z$1.NEVER;
617
+ });
618
+ //#endregion
481
619
  //#region ../theme-core/src/lib/media.ts
482
620
  const hotspotSchema = z.object({
483
621
  x: z.number().min(0).max(1),
@@ -535,6 +673,34 @@ const mediaSchema = z.object({
535
673
  transform: transformSchema.optional()
536
674
  });
537
675
  //#endregion
676
+ //#region ../theme-core/src/palette/schema.ts
677
+ const colourHexString = z$1.string().regex(/^#([0-9A-Fa-f]{3}){1,2}$/);
678
+ const paletteColorSchema = z$1.object({
679
+ name: z$1.string().min(1),
680
+ hex: colourHexString
681
+ });
682
+ const paletteMetaSchema = z$1.object({ mode: z$1.enum(["light", "dark"]) });
683
+ const paletteSchema = z$1.object({
684
+ colors: z$1.array(paletteColorSchema),
685
+ meta: paletteMetaSchema
686
+ }).transform((palette, ctx) => {
687
+ const colors = paletteColorsFromEntries(palette.colors);
688
+ if (!colors.ok) {
689
+ ctx.addIssue({
690
+ code: "custom",
691
+ message: `Invalid complete palette: ${colors.error.kind}`
692
+ });
693
+ return z$1.NEVER;
694
+ }
695
+ return {
696
+ colors: paletteColorEntries(colors.colors).map(({ name, hex }) => ({
697
+ name: String(name),
698
+ hex: String(hex)
699
+ })),
700
+ meta: palette.meta
701
+ };
702
+ });
703
+ //#endregion
538
704
  //#region ../theme-core/src/buttons/types.ts
539
705
  /**
540
706
  * Standard semantic variant roles a theme exposes.
@@ -4051,16 +4217,6 @@ const axesSchema = z$1.object({
4051
4217
  "expressive"
4052
4218
  ])
4053
4219
  });
4054
- const colourHexString = z$1.string().regex(/^#([0-9A-Fa-f]{3}){1,2}$/);
4055
- const paletteColorSchema = z$1.object({
4056
- name: z$1.string().min(1),
4057
- hex: colourHexString
4058
- });
4059
- const paletteMetaSchema = z$1.object({ mode: z$1.enum(["light", "dark"]) });
4060
- const paletteSchema = z$1.object({
4061
- colors: z$1.array(paletteColorSchema),
4062
- meta: paletteMetaSchema
4063
- });
4064
4220
  const typographyStyleSchema = z$1.object({
4065
4221
  family: z$1.string().min(1),
4066
4222
  weight: z$1.enum([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riverbankcms/sdk",
3
- "version": "0.124.0",
3
+ "version": "0.126.0",
4
4
  "description": "Riverbank CMS SDK for headless content consumption",
5
5
  "main": "./dist/server/index.mjs",
6
6
  "module": "./dist/server/index.mjs",
@@ -1,75 +0,0 @@
1
- import type { PaletteColors, PaletteMode } from './colors';
2
- import type { KnownCuratedPaletteValueKey } from './curated';
3
- import type { ResolvedPaletteSelection } from './resolveSelection';
4
- import type { PaletteCommand, PaletteSelection, SitePaletteId, SitePaletteVersion } from './selection';
5
- export type PalettePreview = Readonly<{
6
- kind: 'clean';
7
- resolved: ResolvedPaletteSelection;
8
- }> | Readonly<{
9
- kind: 'selected';
10
- resolved: ResolvedPaletteSelection;
11
- }> | Readonly<{
12
- kind: 'edited-curated';
13
- sourceValueKey: KnownCuratedPaletteValueKey;
14
- colors: PaletteColors;
15
- mode: PaletteMode;
16
- }> | Readonly<{
17
- kind: 'edited-site';
18
- paletteId: SitePaletteId;
19
- expectedVersion: SitePaletteVersion;
20
- colors: PaletteColors;
21
- mode: PaletteMode;
22
- }> | Readonly<{
23
- kind: 'new-site';
24
- colors: PaletteColors;
25
- mode: PaletteMode;
26
- }>;
27
- export type PaletteEditorState = Readonly<{
28
- committed: ResolvedPaletteSelection;
29
- preview: PalettePreview;
30
- }>;
31
- /**
32
- * A complete palette projection for consumers which render a draft. Unlike a
33
- * command, this is always enough to compile the preview without reaching back
34
- * to a curated base plus a sparse overrides map.
35
- */
36
- export type CompletePaletteEditorPreview = Readonly<{
37
- kind: 'selected';
38
- selection: PaletteSelection;
39
- colors: PaletteColors;
40
- mode: PaletteMode;
41
- version: SitePaletteVersion | null;
42
- }> | Readonly<{
43
- kind: 'edited-curated';
44
- sourceValueKey: KnownCuratedPaletteValueKey;
45
- colors: PaletteColors;
46
- mode: PaletteMode;
47
- }> | Readonly<{
48
- kind: 'edited-site';
49
- selection: Extract<PaletteSelection, {
50
- kind: 'site';
51
- }>;
52
- expectedVersion: SitePaletteVersion;
53
- colors: PaletteColors;
54
- mode: PaletteMode;
55
- }> | Readonly<{
56
- kind: 'new-site';
57
- colors: PaletteColors;
58
- mode: PaletteMode;
59
- }>;
60
- export type PaletteEditorAction = Readonly<{
61
- kind: 'select';
62
- resolved: ResolvedPaletteSelection;
63
- }> | Readonly<{
64
- kind: 'edit';
65
- colors: PaletteColors;
66
- mode: PaletteMode;
67
- }> | Readonly<{
68
- kind: 'create';
69
- }> | Readonly<{
70
- kind: 'cancel';
71
- }>;
72
- export declare function createPaletteEditorState(committed: ResolvedPaletteSelection): PaletteEditorState;
73
- export declare function reducePaletteEditorState(state: PaletteEditorState, action: PaletteEditorAction): PaletteEditorState;
74
- export declare function planPaletteCommand(state: PaletteEditorState): PaletteCommand;
75
- export declare function completePaletteEditorPreview(state: PaletteEditorState): CompletePaletteEditorPreview;