cms-renderer 0.5.2 → 0.6.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.
@@ -850,10 +850,10 @@ var LanguageSchema = z3.object({
850
850
  });
851
851
 
852
852
  // ../../packages/cms-schema/src/documents/unified-registry.ts
853
- import { z as z7 } from "zod";
853
+ import { z as z8 } from "zod";
854
854
 
855
855
  // ../../packages/cms-schema/src/documents/rehydration.ts
856
- import { z as z6 } from "zod";
856
+ import { z as z7 } from "zod";
857
857
 
858
858
  // ../../packages/cms-schema/src/fields/complex/media.ts
859
859
  import { z as z5 } from "zod";
@@ -931,6 +931,38 @@ var fileSchema = z5.object({
931
931
  type: z5.string()
932
932
  });
933
933
 
934
+ // ../../packages/cms-schema/src/fields/complex/richtext.ts
935
+ import { z as z6 } from "zod";
936
+ var textNodeSchema = z6.object({
937
+ type: z6.literal("text"),
938
+ text: z6.string(),
939
+ marks: z6.array(z6.string()).optional()
940
+ });
941
+ var blockSchema = z6.lazy(
942
+ () => z6.object({
943
+ type: z6.string(),
944
+ children: z6.array(z6.union([textNodeSchema, blockSchema])).optional(),
945
+ marks: z6.array(z6.string()).optional(),
946
+ level: z6.number().optional(),
947
+ url: z6.string().optional()
948
+ })
949
+ );
950
+ var richtextSchema = z6.union([z6.array(blockSchema), z6.string()]);
951
+ function richtext(options) {
952
+ const meta = {
953
+ label: options.label,
954
+ component: "richtext",
955
+ required: options.required,
956
+ description: options.description,
957
+ options: {
958
+ formatting: options.formatting ?? ["bold", "italic", "link", "heading", "list"],
959
+ format: "markdown"
960
+ }
961
+ };
962
+ const result = options.required ? richtextSchema : richtextSchema.optional();
963
+ return result.meta(meta);
964
+ }
965
+
934
966
  // ../../packages/cms-schema/src/utils/safe-regex.ts
935
967
  var import_safe_regex2 = __toESM(require_safe_regex2(), 1);
936
968
  function validateSafeRegex(pattern) {
@@ -975,34 +1007,39 @@ function rehydrateField(field) {
975
1007
  function createBaseSchema(type, constraints) {
976
1008
  switch (type) {
977
1009
  case "string":
978
- return applyStringConstraints(z6.string(), constraints);
1010
+ return applyStringConstraints(z7.string(), constraints);
1011
+ case "richtext":
1012
+ return richtext({ label: "Rich Text", required: true });
979
1013
  case "number":
980
- return applyNumberConstraints(z6.number(), constraints);
1014
+ return applyNumberConstraints(z7.number(), constraints);
981
1015
  case "boolean":
982
- return z6.boolean();
1016
+ return z7.boolean();
983
1017
  case "image":
984
1018
  return ImageReferenceSchema;
985
1019
  case "date":
986
- return z6.string().date("Invalid date format. Expected YYYY-MM-DD");
1020
+ return z7.iso.date("Invalid date format. Expected YYYY-MM-DD");
987
1021
  case "datetime":
988
- return z6.string().datetime({ offset: true, message: "Invalid datetime format. Expected ISO 8601" });
1022
+ return z7.iso.datetime({
1023
+ offset: true,
1024
+ message: "Invalid datetime format. Expected ISO 8601"
1025
+ });
989
1026
  case "url":
990
- return applyStringConstraints(z6.string().url("Invalid URL format"), constraints);
1027
+ return applyStringConstraints(z7.string(), constraints).pipe(z7.url("Invalid URL format"));
991
1028
  case "email":
992
- return applyStringConstraints(z6.string().email("Invalid email format"), constraints);
1029
+ return applyStringConstraints(z7.string(), constraints).pipe(z7.email("Invalid email format"));
993
1030
  case "enum": {
994
1031
  const values = constraints?.enumValues;
995
1032
  if (!values || values.length === 0) {
996
1033
  throw new Error("Enum field requires at least one enumValues in constraints");
997
1034
  }
998
- return z6.enum(values);
1035
+ return z7.enum(values);
999
1036
  }
1000
1037
  case "reference":
1001
- return z6.record(z6.string(), z6.unknown());
1038
+ return z7.record(z7.string(), z7.unknown());
1002
1039
  case "array": {
1003
1040
  const itemType = constraints?.arrayItemType ?? "string";
1004
- const itemSchema = itemType === "reference" ? z6.record(z6.string(), z6.unknown()) : createPrimitiveSchema(itemType);
1005
- return applyArrayConstraints(z6.array(itemSchema), constraints);
1041
+ const itemSchema = itemType === "reference" ? z7.record(z7.string(), z7.unknown()) : createPrimitiveSchema(itemType);
1042
+ return applyArrayConstraints(z7.array(itemSchema), constraints);
1006
1043
  }
1007
1044
  default:
1008
1045
  throw new Error(`Unknown field type: ${type}`);
@@ -1011,11 +1048,11 @@ function createBaseSchema(type, constraints) {
1011
1048
  function createPrimitiveSchema(type) {
1012
1049
  switch (type) {
1013
1050
  case "string":
1014
- return z6.string();
1051
+ return z7.string();
1015
1052
  case "number":
1016
- return z6.number();
1053
+ return z7.number();
1017
1054
  case "boolean":
1018
- return z6.boolean();
1055
+ return z7.boolean();
1019
1056
  default:
1020
1057
  throw new Error(`Unsupported array item type: ${type}`);
1021
1058
  }
@@ -1107,7 +1144,7 @@ function rehydrateSchema(fields) {
1107
1144
  }
1108
1145
  shape[field.name] = rehydrateField(field);
1109
1146
  }
1110
- return z6.object(shape);
1147
+ return z7.object(shape);
1111
1148
  }
1112
1149
 
1113
1150
  // ../../packages/cms-schema/src/documents/schema-hash.ts
@@ -1117,25 +1154,26 @@ import hash from "object-hash";
1117
1154
  import { TRPCError } from "@trpc/server";
1118
1155
 
1119
1156
  // ../../packages/cms-schema/src/documents/parse-field-definitions-json.ts
1120
- import { z as z8 } from "zod";
1157
+ import { z as z9 } from "zod";
1121
1158
  var SNAKE_CASE = /^[a-z][a-z0-9_]*$/;
1122
- var fieldConstraintsSchema = z8.object({
1123
- minLength: z8.number().int().min(0).optional(),
1124
- maxLength: z8.number().int().min(0).optional(),
1125
- pattern: z8.string().max(500).optional(),
1126
- min: z8.number().optional(),
1127
- max: z8.number().optional(),
1128
- integer: z8.boolean().optional(),
1129
- enumValues: z8.array(z8.string()).optional(),
1130
- arrayItemType: z8.enum(["string", "number", "boolean", "reference"]).optional(),
1131
- minItems: z8.number().int().min(0).optional(),
1132
- maxItems: z8.number().int().min(0).optional(),
1133
- refSchema: z8.string().regex(SNAKE_CASE, "refSchema must be snake_case").optional()
1159
+ var fieldConstraintsSchema = z9.object({
1160
+ minLength: z9.number().int().min(0).optional(),
1161
+ maxLength: z9.number().int().min(0).optional(),
1162
+ pattern: z9.string().max(500).optional(),
1163
+ min: z9.number().optional(),
1164
+ max: z9.number().optional(),
1165
+ integer: z9.boolean().optional(),
1166
+ enumValues: z9.array(z9.string()).optional(),
1167
+ arrayItemType: z9.enum(["string", "number", "boolean", "reference"]).optional(),
1168
+ minItems: z9.number().int().min(0).optional(),
1169
+ maxItems: z9.number().int().min(0).optional(),
1170
+ refSchema: z9.string().regex(SNAKE_CASE, "refSchema must be snake_case").optional()
1134
1171
  });
1135
- var fieldDefinitionSchema = z8.object({
1136
- name: z8.string().regex(SNAKE_CASE, "must be snake_case (lowercase letters, digits, underscores only)"),
1137
- type: z8.enum([
1172
+ var fieldDefinitionSchema = z9.object({
1173
+ name: z9.string().regex(SNAKE_CASE, "must be snake_case (lowercase letters, digits, underscores only)"),
1174
+ type: z9.enum([
1138
1175
  "string",
1176
+ "richtext",
1139
1177
  "number",
1140
1178
  "boolean",
1141
1179
  "date",
@@ -1147,14 +1185,14 @@ var fieldDefinitionSchema = z8.object({
1147
1185
  "array",
1148
1186
  "image"
1149
1187
  ]),
1150
- displayName: z8.string().optional(),
1151
- description: z8.string().optional(),
1152
- required: z8.boolean(),
1188
+ displayName: z9.string().optional(),
1189
+ description: z9.string().optional(),
1190
+ required: z9.boolean(),
1153
1191
  constraints: fieldConstraintsSchema.optional()
1154
1192
  });
1155
- var fieldArraySchema = z8.array(fieldDefinitionSchema).min(1, "Schema must have at least one field");
1156
- var multiSchemaFieldDefSchema = z8.record(
1157
- z8.string().regex(SNAKE_CASE, "schema name must be snake_case"),
1193
+ var fieldArraySchema = z9.array(fieldDefinitionSchema).min(1, "Schema must have at least one field");
1194
+ var multiSchemaFieldDefSchema = z9.record(
1195
+ z9.string().regex(SNAKE_CASE, "schema name must be snake_case"),
1158
1196
  fieldArraySchema
1159
1197
  );
1160
1198