riverbankcms 0.30.0 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,505 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { Pn as ICON_PICKER_PRESETS, a as classifySdkEventSchedule, g as normalizeLinkValue, h as linkSchema, i as sdkEventUpsertOptionalFieldSchemas, n as sdkCourseBookingSettingsSchema, o as classifySdkEventBookingOffer, s as RESOLVED_INTERNAL_LINK_ENTITY_TYPES } from "./sdk-event-upsert-mPJpEQ2x.mjs";
3
- import { m as EVENT_PRESET_VALUES, r as isRecord$3 } from "./src-DOwrYdTk.mjs";
2
+ import { Cn as ICON_PICKER_PRESETS, _r as linkSchema, a as classifySdkEventSchedule, i as sdkEventUpsertOptionalFieldSchemas, n as sdkCourseBookingSettingsSchema, o as classifySdkEventBookingOffer, or as createRichTextDoc, vr as normalizeLinkValue } from "./sdk-event-upsert-RMUvPiD5.mjs";
3
+ import { m as EVENT_PRESET_VALUES } from "./src-BntuEwG8.mjs";
4
4
  import { z } from "zod";
5
5
 
6
- //#region ../core/src/rich-text-href.ts
7
- const SAFE_PROTOCOLS = new Set([
8
- "http:",
9
- "https:",
10
- "mailto:",
11
- "tel:"
12
- ]);
13
- const CONTROL_CHARS_PATTERN = /[\u0000-\u001F\u007F]+/g;
14
- function normalizeInput(value) {
15
- return value.replace(CONTROL_CHARS_PATTERN, "").trim();
16
- }
17
- function decodeForSchemeCheck(value) {
18
- try {
19
- return decodeURIComponent(value);
20
- } catch {
21
- return value;
22
- }
23
- }
24
- /**
25
- * Returns a safe href for rich-text anchors, or null when the value should not be rendered.
26
- *
27
- * Policy:
28
- * - Allow absolute URLs with protocols: http, https, mailto, tel.
29
- * - Allow root-relative ("/path") and hash-only ("#section") links.
30
- * - Reject protocol-relative URLs ("//example.com"), bare domains ("example.com"),
31
- * backslashes, executable schemes (javascript/data/vbscript), malformed URLs, and empty values.
32
- * - Preserve percent-encoding from the original normalized input.
33
- */
34
- function sanitizeHref(raw) {
35
- if (typeof raw !== "string") return null;
36
- const normalized = normalizeInput(raw);
37
- if (!normalized) return null;
38
- if (normalized.includes("\\") || normalized.startsWith("//")) return null;
39
- if (normalized.startsWith("/")) return normalized;
40
- if (normalized.startsWith("#")) return normalized;
41
- return sanitizeAbsoluteHref(normalized);
42
- }
43
- function sanitizeAbsoluteHref(normalized) {
44
- const decoded = normalizeInput(decodeForSchemeCheck(normalized));
45
- const schemeMatch = decoded.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);
46
- if (schemeMatch === null) return null;
47
- const rawScheme = schemeMatch[1];
48
- if (rawScheme === undefined || rawScheme.length === 0) return null;
49
- const protocol = `${rawScheme.toLowerCase()}:`;
50
- if (!SAFE_PROTOCOLS.has(protocol)) return null;
51
- try {
52
- const parsed = new URL(normalized);
53
- if (!SAFE_PROTOCOLS.has(parsed.protocol.toLowerCase())) {
54
- return null;
55
- }
56
- } catch {
57
- return null;
58
- }
59
- return normalized;
60
- }
61
- /** Strict authoring admission; existing stored links keep the renderer's normalization. */
62
- function isSafeRichTextHref(raw) {
63
- const decoded = decodeForSchemeCheck(raw);
64
- return !/[\u0000-\u001F\u007F\\]/.test(decoded) && !decoded.startsWith("//") && sanitizeHref(raw) === raw;
65
- }
66
-
67
- //#endregion
68
- //#region ../core/src/rich-text-authoring.ts
69
- const optionalText = z.string().max(2048).nullable().optional();
70
- const destination = z.string().max(2048).refine(isSafeRichTextHref, "Use http, https, mailto, tel, a single-root-relative path or a #fragment without controls or backslashes");
71
- const linkAttributes = z.object({
72
- href: destination.nullable().optional(),
73
- target: z.enum([
74
- "_blank",
75
- "_self",
76
- "_parent",
77
- "_top"
78
- ]).nullable().optional(),
79
- rel: optionalText,
80
- class: optionalText,
81
- kind: z.enum([
82
- "internal",
83
- "page",
84
- "entry",
85
- "external",
86
- "url"
87
- ]).nullable().optional(),
88
- identifier: optionalText,
89
- contentType: optionalText,
90
- routeId: optionalText,
91
- entityId: optionalText,
92
- entityType: z.enum(RESOLVED_INTERNAL_LINK_ENTITY_TYPES).nullable().optional(),
93
- title: optionalText,
94
- typeLabel: optionalText,
95
- contentTypeKey: optionalText,
96
- contentTypeName: optionalText,
97
- updatedAt: optionalText
98
- }).strict().refine((attrs) => Boolean(attrs.href) || (attrs.kind === "internal" || attrs.kind === "page" || attrs.kind === "entry") && [attrs.routeId, attrs.identifier].some((value) => typeof value === "string" && value.trim().length > 0), {
99
- message: "Links require a safe href, or an internal kind with a routeId or identifier",
100
- path: ["href"]
101
- });
102
- const noAttributes = z.object({}).strict().optional();
103
- const markSchema = z.discriminatedUnion("type", [
104
- z.object({
105
- type: z.literal("bold"),
106
- attrs: noAttributes
107
- }).strict(),
108
- z.object({
109
- type: z.literal("italic"),
110
- attrs: noAttributes
111
- }).strict(),
112
- z.object({
113
- type: z.literal("strike"),
114
- attrs: noAttributes
115
- }).strict(),
116
- z.object({
117
- type: z.literal("code"),
118
- attrs: noAttributes
119
- }).strict(),
120
- z.object({
121
- type: z.literal("link"),
122
- attrs: linkAttributes
123
- }).strict()
124
- ]);
125
- const marksSchema = z.array(markSchema).max(5).superRefine((marks, ctx) => {
126
- if (new Set(marks.map((mark) => mark.type)).size !== marks.length) {
127
- ctx.addIssue({
128
- code: "custom",
129
- message: "Use each mark type at most once"
130
- });
131
- }
132
- if (marks.some((mark) => mark.type === "code") && marks.length !== 1) {
133
- ctx.addIssue({
134
- code: "custom",
135
- message: "Code cannot be combined with other marks"
136
- });
137
- }
138
- });
139
- const textSchema = z.object({
140
- type: z.literal("text"),
141
- text: z.string().min(1).max(5e4),
142
- marks: marksSchema.optional()
143
- }).strict();
144
- const hardBreakSchema = z.object({
145
- type: z.literal("hardBreak"),
146
- attrs: noAttributes
147
- }).strict();
148
- const inlineSchema = z.discriminatedUnion("type", [textSchema, hardBreakSchema]);
149
- const paragraphSchema = z.object({
150
- type: z.literal("paragraph"),
151
- attrs: noAttributes,
152
- content: z.array(inlineSchema).max(1e3).optional()
153
- }).strict();
154
- const headingSchema = z.object({
155
- type: z.literal("heading"),
156
- attrs: z.object({ level: z.union([
157
- z.literal(1),
158
- z.literal(2),
159
- z.literal(3),
160
- z.literal(4),
161
- z.literal(5)
162
- ]) }).strict(),
163
- content: z.array(inlineSchema).max(1e3).optional()
164
- }).strict();
165
- const codeBlockSchema = z.object({
166
- type: z.literal("codeBlock"),
167
- attrs: z.object({ language: optionalText }).strict().optional(),
168
- content: z.array(z.object({
169
- type: z.literal("text"),
170
- text: z.string().min(1).max(5e4)
171
- }).strict()).max(1e3).optional()
172
- }).strict();
173
- const imageSchema = z.object({
174
- type: z.literal("image"),
175
- attrs: z.object({
176
- src: destination.nullable().optional(),
177
- identifier: optionalText,
178
- alt: optionalText,
179
- title: optionalText,
180
- width: z.number().positive().nullable().optional(),
181
- height: z.number().positive().nullable().optional()
182
- }).strict()
183
- }).strict();
184
- const horizontalRuleSchema = z.object({
185
- type: z.literal("horizontalRule"),
186
- attrs: noAttributes
187
- }).strict();
188
- const blockSchema = z.lazy(() => z.discriminatedUnion("type", [
189
- paragraphSchema,
190
- headingSchema,
191
- codeBlockSchema,
192
- imageSchema,
193
- horizontalRuleSchema,
194
- z.object({
195
- type: z.literal("blockquote"),
196
- attrs: noAttributes,
197
- content: z.array(blockSchema).min(1).max(1e3)
198
- }).strict(),
199
- z.object({
200
- type: z.literal("bulletList"),
201
- attrs: noAttributes,
202
- content: z.array(listItemSchema).min(1).max(1e3)
203
- }).strict(),
204
- z.object({
205
- type: z.literal("orderedList"),
206
- attrs: z.object({
207
- start: z.number().int().positive().optional(),
208
- type: z.enum([
209
- "1",
210
- "a",
211
- "A",
212
- "i",
213
- "I"
214
- ]).nullable().optional()
215
- }).strict().optional(),
216
- content: z.array(listItemSchema).min(1).max(1e3)
217
- }).strict()
218
- ]));
219
- const listItemSchema = z.lazy(() => z.object({
220
- type: z.literal("listItem"),
221
- attrs: noAttributes,
222
- content: z.tuple([paragraphSchema]).rest(blockSchema)
223
- }).strict());
224
- function treeSize(value, depth = 0) {
225
- if (depth > 12) return {
226
- depth,
227
- nodes: 0,
228
- text: 0
229
- };
230
- if (!isRecord$3(value)) return {
231
- depth,
232
- nodes: 0,
233
- text: 0
234
- };
235
- const nodes = Array.isArray(value.content) ? value.content : [];
236
- if (nodes.length > 2e3) return {
237
- depth,
238
- nodes: 2001,
239
- text: 0
240
- };
241
- return nodes.reduce((total, node) => {
242
- if (exceedsBounds(total)) return total;
243
- const child = treeSize(node, depth + 1);
244
- return {
245
- depth: Math.max(total.depth, child.depth),
246
- nodes: total.nodes + child.nodes,
247
- text: total.text + child.text
248
- };
249
- }, {
250
- depth,
251
- nodes: depth === 0 ? 0 : 1,
252
- text: typeof value.text === "string" ? value.text.length : 0
253
- });
254
- }
255
- function exceedsBounds(size) {
256
- return size.depth > 12 || size.nodes > 2e3 || size.text > 1e5;
257
- }
258
- /** Closed authoring contract for generated content. Stored legacy documents keep their existing reader. */
259
- const RichTextAuthoringDocSchema = z.preprocess((value, ctx) => {
260
- if (exceedsBounds(treeSize(value))) {
261
- ctx.addIssue({
262
- code: "custom",
263
- message: "Rich text must have at most 12 levels, 2000 nodes and 100000 text characters"
264
- });
265
- return z.NEVER;
266
- }
267
- return value;
268
- }, z.object({
269
- type: z.literal("doc"),
270
- content: z.array(blockSchema).max(1e3)
271
- }).strict());
272
- const inlineNodes = [
273
- "paragraph",
274
- "text",
275
- "hardBreak"
276
- ];
277
- const inlineMarks = [
278
- "bold",
279
- "italic",
280
- "strike",
281
- "code",
282
- "link"
283
- ];
284
- const fullCapabilities = {
285
- nodes: [
286
- ...inlineNodes,
287
- "heading",
288
- "blockquote",
289
- "bulletList",
290
- "orderedList",
291
- "listItem",
292
- "codeBlock",
293
- "horizontalRule",
294
- "image"
295
- ],
296
- marks: inlineMarks,
297
- headingLevels: [
298
- 1,
299
- 2,
300
- 3,
301
- 4,
302
- 5
303
- ]
304
- };
305
- const inlineCapabilities = {
306
- nodes: inlineNodes,
307
- marks: inlineMarks,
308
- headingLevels: []
309
- };
310
- const variantCapabilities = {
311
- full: fullCapabilities,
312
- media: fullCapabilities,
313
- inline: inlineCapabilities,
314
- limited: inlineCapabilities,
315
- notes: {
316
- ...inlineCapabilities,
317
- nodes: [
318
- ...inlineNodes,
319
- "bulletList",
320
- "orderedList",
321
- "listItem"
322
- ]
323
- },
324
- consent: {
325
- ...inlineCapabilities,
326
- marks: [
327
- "bold",
328
- "italic",
329
- "link"
330
- ]
331
- }
332
- };
333
- /** One capability description for editor configuration, admission and model guidance. */
334
- function richTextVariantCapabilities(variant) {
335
- const capabilities = variantCapabilities[variant];
336
- return {
337
- nodes: [...capabilities.nodes],
338
- marks: [...capabilities.marks],
339
- headingLevels: [...capabilities.headingLevels]
340
- };
341
- }
342
- function richTextDocumentSupportsVariant(doc, variant) {
343
- const capabilities = richTextVariantCapabilities(variant);
344
- const supports = (nodes) => nodes.every((node) => capabilities.nodes.some((type) => type === node.type) && (node.marks ?? []).every((mark) => capabilities.marks.some((type) => type === mark.type)) && (node.type !== "heading" || capabilities.headingLevels.some((level) => level === node.attrs?.level)) && supports(node.content ?? []));
345
- return supports(doc.content);
346
- }
347
- /** Measured product allowance for whole-document edits; output-token limits remain separately enforced. */
348
- function richTextEditingBudget(doc) {
349
- const serializedBytes = new TextEncoder().encode(JSON.stringify(doc)).length;
350
- const nodes = treeSize(doc).nodes;
351
- return {
352
- kind: serializedBytes <= 8e3 && nodes <= 120 ? "supported" : "too-large",
353
- serializedBytes,
354
- nodes
355
- };
356
- }
357
-
358
- //#endregion
359
- //#region ../core/src/rich-text-schema.ts
360
- /**
361
- * Shared Rich Text Schema
362
- *
363
- * This module provides a single source of truth for TipTap rich text validation
364
- * across both the block-form editor and the block rendering system.
365
- *
366
- * Rich-text fields use one canonical root shape:
367
- * `{ type: 'doc', content: [...] }`.
368
- */
369
- /**
370
- * TipTap document node schema (recursive structure)
371
- *
372
- * Supports the full TipTap document structure including:
373
- * - type: Node type (e.g., 'doc', 'paragraph', 'text')
374
- * - content: Nested array of child nodes
375
- * - text: Text content for text nodes
376
- * - attrs: Node attributes (e.g., alignment, color)
377
- * - marks: Text formatting marks (e.g., bold, italic)
378
- */
379
- const TipTapMarkSchema = z.object({
380
- type: z.string().min(1),
381
- attrs: z.record(z.string(), z.unknown()).optional()
382
- }).strict();
383
- const TipTapNodeSchema = z.lazy(() => z.object({
384
- type: z.string().min(1),
385
- content: z.array(TipTapNodeSchema).optional(),
386
- text: z.string().optional(),
387
- attrs: z.record(z.string(), z.unknown()).optional(),
388
- marks: z.array(TipTapMarkSchema).optional()
389
- }).strict().superRefine((node, ctx) => {
390
- if (node.type === "doc") {
391
- ctx.addIssue({
392
- code: "custom",
393
- path: ["type"],
394
- message: "Document nodes are only valid at the rich-text root"
395
- });
396
- }
397
- if (node.type === "text") {
398
- if (node.text === undefined || node.text.length === 0) {
399
- ctx.addIssue({
400
- code: "custom",
401
- path: ["text"],
402
- message: "Text nodes require a non-empty text value"
403
- });
404
- }
405
- if (node.content !== undefined) {
406
- ctx.addIssue({
407
- code: "custom",
408
- path: ["content"],
409
- message: "Text nodes cannot contain child nodes"
410
- });
411
- }
412
- return;
413
- }
414
- if (node.text !== undefined) {
415
- ctx.addIssue({
416
- code: "custom",
417
- path: ["text"],
418
- message: "Only text nodes can contain a text value"
419
- });
420
- }
421
- }));
422
- /**
423
- * Canonical schema for a TipTap rich-text document root.
424
- *
425
- * Stricter than {@link TipTapNodeSchema}: `type` is literally `'doc'` and
426
- * `content` is required (possibly empty). This is the shape every producer
427
- * (dummy content, editor output, migrations) must emit, and the shape every
428
- * non-legacy consumer can rely on.
429
- *
430
- */
431
- const RichTextDocSchema = z.object({
432
- type: z.literal("doc"),
433
- content: z.array(TipTapNodeSchema)
434
- }).strict();
435
- /**
436
- * Type guard for {@link RichTextDoc}.
437
- *
438
- * Returns `true` only for the canonical unwrapped form. The shared structural
439
- * contract lives in `@riverbankcms/core`; parity tests keep its dependency-free
440
- * guard aligned with this detailed Zod validator.
441
- */
442
- function isRichTextDoc(value) {
443
- return RichTextDocSchema.safeParse(value).success;
444
- }
445
- /**
446
- * Build a canonical {@link RichTextDoc} from plain-text paragraphs.
447
- *
448
- * Single source of truth for constructing a TipTap doc from strings.
449
- * Used by:
450
- * - `@riverbankcms/dummy-content` (fixture body generators)
451
- * - `@riverbankcms/content-model` (default template `cta-full` content)
452
- *
453
- * Empty strings produce a paragraph with no `content` array — matching
454
- * the TipTap convention for empty paragraphs. The shape is exactly what
455
- * {@link RichTextDocSchema} validates, so the type and runtime check
456
- * never drift from the constructor.
457
- */
458
- function createRichTextDoc(paragraphs) {
459
- return {
460
- type: "doc",
461
- content: paragraphs.map((text) => text ? {
462
- type: "paragraph",
463
- content: [{
464
- type: "text",
465
- text
466
- }]
467
- } : { type: "paragraph" })
468
- };
469
- }
470
- /**
471
- * Build Zod validation schema for rich text fields
472
- *
473
- * @param options - Optional configuration
474
- * @param options.required - If true, validates that content is not empty
475
- * @param options.label - Field label for error messages (defaults to 'This field')
476
- * @returns Zod schema for rich text validation
477
- *
478
- * @example
479
- * // Basic usage
480
- * const schema = buildRichTextSchema()
481
- *
482
- * @example
483
- * // Required field with custom label
484
- * const schema = buildRichTextSchema({ required: true, label: 'Description' })
485
- */
486
- function buildRichTextSchema(options) {
487
- if (options?.required === true) {
488
- const label = options.label ?? "This field";
489
- return RichTextDocSchema.refine((val) => {
490
- const content = val.content;
491
- if (!Array.isArray(content) || content.length === 0) return false;
492
- const first = content[0];
493
- if (content.length === 1 && isRecord$3(first) && first.type === "paragraph" && (!("content" in first) || first.content == null)) {
494
- return false;
495
- }
496
- return true;
497
- }, { message: `${label} is required` });
498
- }
499
- return RichTextDocSchema;
500
- }
501
-
502
- //#endregion
503
6
  //#region ../content-model/src/title-resolution.ts
504
7
  /**
505
8
  * Content title resolution utilities.
@@ -5101,4 +4604,4 @@ const eventUpsertInputSchema = z.object({
5101
4604
  }));
5102
4605
 
5103
4606
  //#endregion
5104
- export { RichTextDocSchema as a, findUnfilledSentinels as i, buildEntryScaffold as n, isRichTextDoc as o, validateEntryInstance as r, sanitizeHref as s, eventUpsertInputSchema as t };
4607
+ export { findUnfilledSentinels as i, buildEntryScaffold as n, validateEntryInstance as r, eventUpsertInputSchema as t };
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { t as loadConfigFile } from "./load-config-C4powIPE.mjs";
3
+
4
+ export { loadConfigFile };
@@ -7,7 +7,7 @@ import { existsSync as existsSync$1 } from "fs";
7
7
  import { fileURLToPath } from "url";
8
8
 
9
9
  //#region package.json
10
- var version = "0.30.0";
10
+ var version = "0.30.1";
11
11
  var peerDependencies = { "@riverbankcms/sdk": ">=0.157.0 <1.0.0" };
12
12
  var package_default = {
13
13
  name: "riverbankcms",
@@ -93,7 +93,7 @@ var package_default = {
93
93
  //#endregion
94
94
  //#region src/version.ts
95
95
  /** The package manifest is the source-run fallback; builds inject this value. */
96
- const CLI_VERSION = typeof "0.30.0" === "string" ? "0.30.0" : version;
96
+ const CLI_VERSION = typeof "0.30.1" === "string" ? "0.30.1" : version;
97
97
  /**
98
98
  * The CLI's SDK peer range is bundled from the CLI manifest alongside its
99
99
  * version. Runtime config loading uses this value as the single compatibility
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Zn as parseSiteId, cr as err, lr as ok } from "./src-DOwrYdTk.mjs";
2
+ import { Zn as parseSiteId, cr as err, lr as ok } from "./src-BntuEwG8.mjs";
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { dirname, isAbsolute, join, parse, relative, resolve, sep } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "../src-DOwrYdTk.mjs";
3
- import { a as prepareScaffoldExecution, d as loadGeneratedPackageRanges, i as preflightScaffoldTargets, l as deriveGeneratedPackageRanges, o as writeScaffoldFiles, r as preflightScaffoldPlan, s as deriveScaffoldLocalManifest, t as deriveScaffoldPlan, u as findPackageManifestPath } from "../plan-cE7TKMc1.mjs";
2
+ import "../src-BntuEwG8.mjs";
3
+ import { a as prepareScaffoldExecution, d as loadGeneratedPackageRanges, i as preflightScaffoldTargets, l as deriveGeneratedPackageRanges, o as writeScaffoldFiles, r as preflightScaffoldPlan, s as deriveScaffoldLocalManifest, t as deriveScaffoldPlan, u as findPackageManifestPath } from "../plan-AJDYca86.mjs";
4
4
 
5
5
  export { deriveGeneratedPackageRanges, deriveScaffoldLocalManifest, deriveScaffoldPlan, findPackageManifestPath, loadGeneratedPackageRanges, preflightScaffoldPlan, preflightScaffoldTargets, prepareScaffoldExecution, writeScaffoldFiles };