@kyro-cms/core 0.1.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 (88) hide show
  1. package/README.md +241 -0
  2. package/dist/base-CQkFzqQl.d.ts +62 -0
  3. package/dist/base-DlhVlwnN.d.cts +62 -0
  4. package/dist/chunk-3Q3FS5J4.cjs +273 -0
  5. package/dist/chunk-3Q3FS5J4.cjs.map +1 -0
  6. package/dist/chunk-3TPQ2BU6.js +423 -0
  7. package/dist/chunk-3TPQ2BU6.js.map +1 -0
  8. package/dist/chunk-3VZCX4DF.cjs +384 -0
  9. package/dist/chunk-3VZCX4DF.cjs.map +1 -0
  10. package/dist/chunk-BXMWDUED.js +115 -0
  11. package/dist/chunk-BXMWDUED.js.map +1 -0
  12. package/dist/chunk-DIC236EW.js +290 -0
  13. package/dist/chunk-DIC236EW.js.map +1 -0
  14. package/dist/chunk-DKSMFC3L.js +268 -0
  15. package/dist/chunk-DKSMFC3L.js.map +1 -0
  16. package/dist/chunk-DVD5P72E.cjs +428 -0
  17. package/dist/chunk-DVD5P72E.cjs.map +1 -0
  18. package/dist/chunk-HT6VE4NW.cjs +293 -0
  19. package/dist/chunk-HT6VE4NW.cjs.map +1 -0
  20. package/dist/chunk-K7QF2QCM.cjs +311 -0
  21. package/dist/chunk-K7QF2QCM.cjs.map +1 -0
  22. package/dist/chunk-OG3KX56O.js +308 -0
  23. package/dist/chunk-OG3KX56O.js.map +1 -0
  24. package/dist/chunk-R3XIBBAW.cjs +34 -0
  25. package/dist/chunk-R3XIBBAW.cjs.map +1 -0
  26. package/dist/chunk-RLTG4YZM.cjs +117 -0
  27. package/dist/chunk-RLTG4YZM.cjs.map +1 -0
  28. package/dist/chunk-SDMNUYVU.js +30 -0
  29. package/dist/chunk-SDMNUYVU.js.map +1 -0
  30. package/dist/chunk-UEG7KMKC.cjs +228 -0
  31. package/dist/chunk-UEG7KMKC.cjs.map +1 -0
  32. package/dist/chunk-UEYC46RL.js +374 -0
  33. package/dist/chunk-UEYC46RL.js.map +1 -0
  34. package/dist/chunk-YPAFJ7EV.js +225 -0
  35. package/dist/chunk-YPAFJ7EV.js.map +1 -0
  36. package/dist/cli/index.cjs +306 -0
  37. package/dist/cli/index.cjs.map +1 -0
  38. package/dist/cli/index.d.cts +1 -0
  39. package/dist/cli/index.d.ts +1 -0
  40. package/dist/cli/index.js +303 -0
  41. package/dist/cli/index.js.map +1 -0
  42. package/dist/drizzle/index.cjs +25 -0
  43. package/dist/drizzle/index.cjs.map +1 -0
  44. package/dist/drizzle/index.d.cts +49 -0
  45. package/dist/drizzle/index.d.ts +49 -0
  46. package/dist/drizzle/index.js +4 -0
  47. package/dist/drizzle/index.js.map +1 -0
  48. package/dist/graphql/index.cjs +16 -0
  49. package/dist/graphql/index.cjs.map +1 -0
  50. package/dist/graphql/index.d.cts +20 -0
  51. package/dist/graphql/index.d.ts +20 -0
  52. package/dist/graphql/index.js +3 -0
  53. package/dist/graphql/index.js.map +1 -0
  54. package/dist/index-4fJKLFK2.d.ts +63 -0
  55. package/dist/index-DI0DRPNv.d.cts +63 -0
  56. package/dist/index.cjs +2506 -0
  57. package/dist/index.cjs.map +1 -0
  58. package/dist/index.d.cts +525 -0
  59. package/dist/index.d.ts +525 -0
  60. package/dist/index.js +2334 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/mongodb/index.cjs +17 -0
  63. package/dist/mongodb/index.cjs.map +1 -0
  64. package/dist/mongodb/index.d.cts +49 -0
  65. package/dist/mongodb/index.d.ts +49 -0
  66. package/dist/mongodb/index.js +4 -0
  67. package/dist/mongodb/index.js.map +1 -0
  68. package/dist/rest/index.cjs +17 -0
  69. package/dist/rest/index.cjs.map +1 -0
  70. package/dist/rest/index.d.cts +28 -0
  71. package/dist/rest/index.d.ts +28 -0
  72. package/dist/rest/index.js +4 -0
  73. package/dist/rest/index.js.map +1 -0
  74. package/dist/trpc/index.cjs +45 -0
  75. package/dist/trpc/index.cjs.map +1 -0
  76. package/dist/trpc/index.d.cts +130 -0
  77. package/dist/trpc/index.d.ts +130 -0
  78. package/dist/trpc/index.js +4 -0
  79. package/dist/trpc/index.js.map +1 -0
  80. package/dist/types-BGM5MV_K.d.cts +589 -0
  81. package/dist/types-BGM5MV_K.d.ts +589 -0
  82. package/dist/ws/index.cjs +24 -0
  83. package/dist/ws/index.cjs.map +1 -0
  84. package/dist/ws/index.d.cts +88 -0
  85. package/dist/ws/index.d.ts +88 -0
  86. package/dist/ws/index.js +3 -0
  87. package/dist/ws/index.js.map +1 -0
  88. package/package.json +120 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,2506 @@
1
+ 'use strict';
2
+
3
+ var chunk3VZCX4DF_cjs = require('./chunk-3VZCX4DF.cjs');
4
+ var chunkK7QF2QCM_cjs = require('./chunk-K7QF2QCM.cjs');
5
+ var chunkUEG7KMKC_cjs = require('./chunk-UEG7KMKC.cjs');
6
+ var chunkR3XIBBAW_cjs = require('./chunk-R3XIBBAW.cjs');
7
+ var chunkDVD5P72E_cjs = require('./chunk-DVD5P72E.cjs');
8
+ var chunk3Q3FS5J4_cjs = require('./chunk-3Q3FS5J4.cjs');
9
+ var chunkHT6VE4NW_cjs = require('./chunk-HT6VE4NW.cjs');
10
+ var chunkRLTG4YZM_cjs = require('./chunk-RLTG4YZM.cjs');
11
+ var zod = require('zod');
12
+ var bcrypt = require('bcrypt');
13
+ var jwt = require('jsonwebtoken');
14
+ var crypto = require('crypto');
15
+
16
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
17
+
18
+ var bcrypt__default = /*#__PURE__*/_interopDefault(bcrypt);
19
+ var jwt__default = /*#__PURE__*/_interopDefault(jwt);
20
+
21
+ // src/registry/validator.ts
22
+ var ConfigValidationError = class extends Error {
23
+ errors;
24
+ constructor(errors) {
25
+ super(`Configuration validation failed:
26
+ ${errors.join("\n")}`);
27
+ this.name = "ConfigValidationError";
28
+ this.errors = errors;
29
+ }
30
+ };
31
+ function validateCollection(config) {
32
+ const errors = [];
33
+ if (!config.slug) {
34
+ errors.push(`Collection is missing a "slug" property`);
35
+ } else if (!/^[a-z][a-z0-9_-]*$/.test(config.slug)) {
36
+ errors.push(`Collection slug "${config.slug}" must be lowercase alphanumeric with dashes`);
37
+ }
38
+ if (!config.fields || config.fields.length === 0) {
39
+ errors.push(`Collection "${config.slug}" has no fields defined`);
40
+ } else {
41
+ const fieldErrors = validateFields(config.fields, config.slug);
42
+ errors.push(...fieldErrors);
43
+ }
44
+ if (config.access) {
45
+ for (const [action, handler] of Object.entries(config.access)) {
46
+ if (typeof handler !== "boolean" && typeof handler !== "function") {
47
+ errors.push(`Collection "${config.slug}" has invalid access.${action} (must be boolean or function)`);
48
+ }
49
+ }
50
+ }
51
+ if (config.admin?.useAsTitle) {
52
+ const fieldExists = config.fields.some((f) => f.name === config.admin.useAsTitle);
53
+ if (!fieldExists) {
54
+ errors.push(`Collection "${config.slug}" admin.useAsTitle references unknown field "${config.admin.useAsTitle}"`);
55
+ }
56
+ }
57
+ if (config.admin?.defaultColumns) {
58
+ for (const col of config.admin.defaultColumns) {
59
+ const fieldExists = config.fields.some((f) => f.name === col);
60
+ if (!fieldExists) {
61
+ errors.push(`Collection "${config.slug}" admin.defaultColumns references unknown field "${col}"`);
62
+ }
63
+ }
64
+ }
65
+ if (config.upload) {
66
+ if (config.upload.fileSize && config.upload.fileSize <= 0) {
67
+ errors.push(`Collection "${config.slug}" upload.fileSize must be positive`);
68
+ }
69
+ }
70
+ if (config.versions) {
71
+ if (config.versions.maxPerDoc && config.versions.maxPerDoc <= 0) {
72
+ errors.push(`Collection "${config.slug}" versions.maxPerDoc must be positive`);
73
+ }
74
+ }
75
+ if (config.auth) {
76
+ const hasEmailField = config.fields.some((f) => f.name === "email");
77
+ const hasPasswordField = config.fields.some((f) => f.name === "password");
78
+ if (!hasEmailField) {
79
+ errors.push(`Collection "${config.slug}" with auth enabled requires an "email" field`);
80
+ }
81
+ if (!hasPasswordField) {
82
+ errors.push(`Collection "${config.slug}" with auth enabled requires a "password" field`);
83
+ }
84
+ }
85
+ return errors;
86
+ }
87
+ function validateGlobal(config) {
88
+ const errors = [];
89
+ if (!config.slug) {
90
+ errors.push(`Global is missing a "slug" property`);
91
+ } else if (!/^[a-z][a-z0-9_-]*$/.test(config.slug)) {
92
+ errors.push(`Global slug "${config.slug}" must be lowercase alphanumeric with dashes`);
93
+ }
94
+ if (!config.fields || config.fields.length === 0) {
95
+ errors.push(`Global "${config.slug}" has no fields defined`);
96
+ } else {
97
+ const fieldErrors = validateFields(config.fields, `global:${config.slug}`);
98
+ errors.push(...fieldErrors);
99
+ }
100
+ return errors;
101
+ }
102
+ function validateFields(fields, context) {
103
+ const errors = [];
104
+ const fieldNames = /* @__PURE__ */ new Set();
105
+ for (let i = 0; i < fields.length; i++) {
106
+ const field = fields[i];
107
+ if (field.type === "row" || field.type === "collapsible" || field.type === "tabs") {
108
+ if ("fields" in field && field.fields) {
109
+ const nestedErrors = validateFields(field.fields, context);
110
+ errors.push(...nestedErrors);
111
+ } else if ("tabs" in field) {
112
+ for (const tab of field.tabs) {
113
+ const tabErrors = validateFields(tab.fields, context);
114
+ errors.push(...tabErrors);
115
+ }
116
+ }
117
+ continue;
118
+ }
119
+ const fieldName = field.name;
120
+ if (!fieldName) {
121
+ errors.push(`${context}: Field at index ${i} is missing a "name" property`);
122
+ continue;
123
+ }
124
+ if (fieldNames.has(fieldName)) {
125
+ errors.push(`${context}: Duplicate field name "${fieldName}"`);
126
+ }
127
+ fieldNames.add(fieldName);
128
+ if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(fieldName)) {
129
+ errors.push(`${context}: Field name "${fieldName}" must be alphanumeric with underscores`);
130
+ }
131
+ if (!field.type) {
132
+ errors.push(`${context}: Field "${fieldName}" is missing a "type" property`);
133
+ continue;
134
+ }
135
+ switch (field.type) {
136
+ case "relationship":
137
+ if (!field.relationTo) {
138
+ errors.push(`${context}: Relationship field "${fieldName}" is missing "relationTo"`);
139
+ }
140
+ break;
141
+ case "array":
142
+ if (!field.fields || field.fields.length === 0) {
143
+ errors.push(`${context}: Array field "${fieldName}" has no fields defined`);
144
+ } else {
145
+ const arrayErrors = validateFields(field.fields, `${context}.${fieldName}`);
146
+ errors.push(...arrayErrors);
147
+ }
148
+ break;
149
+ case "group":
150
+ if (!field.fields || field.fields.length === 0) {
151
+ errors.push(`${context}: Group field "${fieldName}" has no fields defined`);
152
+ } else {
153
+ const groupErrors = validateFields(field.fields, `${context}.${fieldName}`);
154
+ errors.push(...groupErrors);
155
+ }
156
+ break;
157
+ case "blocks":
158
+ if (!field.blocks || field.blocks.length === 0) {
159
+ errors.push(`${context}: Blocks field "${fieldName}" has no blocks defined`);
160
+ } else {
161
+ const blockErrors = validateBlocks(field.blocks, `${context}.${fieldName}`);
162
+ errors.push(...blockErrors);
163
+ }
164
+ break;
165
+ case "select":
166
+ case "radio":
167
+ if (!field.options || field.options.length === 0) {
168
+ errors.push(`${context}: ${field.type} field "${fieldName}" has no options defined`);
169
+ } else {
170
+ const values = field.options.map((o) => o.value);
171
+ const uniqueValues = new Set(values);
172
+ if (values.length !== uniqueValues.size) {
173
+ errors.push(`${context}: ${field.type} field "${fieldName}" has duplicate option values`);
174
+ }
175
+ }
176
+ break;
177
+ case "upload":
178
+ if (!field.relationTo) {
179
+ errors.push(`${context}: Upload field "${fieldName}" is missing "relationTo"`);
180
+ }
181
+ break;
182
+ }
183
+ if ("min" in field && "max" in field && field.min > field.max) {
184
+ errors.push(`${context}: Field "${fieldName}" has min greater than max`);
185
+ }
186
+ if ("minLength" in field && "maxLength" in field && field.minLength > field.maxLength) {
187
+ errors.push(`${context}: Field "${fieldName}" has minLength greater than maxLength`);
188
+ }
189
+ if ("minRows" in field && "maxRows" in field && field.minRows > field.maxRows) {
190
+ errors.push(`${context}: Field "${fieldName}" has minRows greater than maxRows`);
191
+ }
192
+ }
193
+ return errors;
194
+ }
195
+ function validateBlocks(blocks, context) {
196
+ const errors = [];
197
+ const slugs = /* @__PURE__ */ new Set();
198
+ for (const block of blocks) {
199
+ if (!block.slug) {
200
+ errors.push(`${context}: Block is missing a "slug" property`);
201
+ continue;
202
+ }
203
+ if (slugs.has(block.slug)) {
204
+ errors.push(`${context}: Duplicate block slug "${block.slug}"`);
205
+ }
206
+ slugs.add(block.slug);
207
+ if (!block.label) {
208
+ errors.push(`${context}: Block "${block.slug}" is missing a "label" property`);
209
+ }
210
+ if (!block.fields || block.fields.length === 0) {
211
+ errors.push(`${context}: Block "${block.slug}" has no fields defined`);
212
+ } else {
213
+ const blockErrors = validateFields(block.fields, `${context}.${block.slug}`);
214
+ errors.push(...blockErrors);
215
+ }
216
+ }
217
+ return errors;
218
+ }
219
+ function validateConfig(collections, globals = []) {
220
+ const errors = [];
221
+ const slugs = /* @__PURE__ */ new Set();
222
+ for (const collection of collections) {
223
+ if (slugs.has(collection.slug)) {
224
+ errors.push(`Duplicate collection slug "${collection.slug}"`);
225
+ }
226
+ slugs.add(collection.slug);
227
+ }
228
+ for (const global of globals) {
229
+ if (slugs.has(global.slug)) {
230
+ errors.push(`Duplicate global slug "${global.slug}"`);
231
+ }
232
+ slugs.add(global.slug);
233
+ }
234
+ for (const collection of collections) {
235
+ const collectionErrors = validateCollection(collection);
236
+ errors.push(...collectionErrors);
237
+ }
238
+ for (const global of globals) {
239
+ const globalErrors = validateGlobal(global);
240
+ errors.push(...globalErrors);
241
+ }
242
+ for (const collection of collections) {
243
+ const relationshipErrors = validateRelationships(collection.fields, collections);
244
+ errors.push(...relationshipErrors);
245
+ }
246
+ if (errors.length > 0) {
247
+ throw new ConfigValidationError(errors);
248
+ }
249
+ }
250
+ function validateRelationships(fields, collections) {
251
+ const errors = [];
252
+ const collectionSlugs = new Set(collections.map((c) => c.slug));
253
+ for (const field of fields) {
254
+ if (field.type === "relationship") {
255
+ const targets = Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo];
256
+ for (const target of targets) {
257
+ if (!collectionSlugs.has(target)) {
258
+ errors.push(`Relationship field "${field.name}" references unknown collection "${target}"`);
259
+ }
260
+ }
261
+ }
262
+ if (field.type === "upload") {
263
+ const targets = Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo];
264
+ for (const target of targets) {
265
+ if (!collectionSlugs.has(target)) {
266
+ errors.push(`Upload field "${field.name}" references unknown collection "${target}"`);
267
+ }
268
+ }
269
+ }
270
+ if ("fields" in field && field.fields) {
271
+ const nestedErrors = validateRelationships(field.fields, collections);
272
+ errors.push(...nestedErrors);
273
+ }
274
+ if ("tabs" in field) {
275
+ for (const tab of field.tabs) {
276
+ const tabErrors = validateRelationships(tab.fields, collections);
277
+ errors.push(...tabErrors);
278
+ }
279
+ }
280
+ if ("blocks" in field) {
281
+ for (const block of field.blocks) {
282
+ const blockErrors = validateRelationships(block.fields, collections);
283
+ errors.push(...blockErrors);
284
+ }
285
+ }
286
+ }
287
+ return errors;
288
+ }
289
+ function fieldToZod(field) {
290
+ switch (field.type) {
291
+ case "text":
292
+ return textToZod(field);
293
+ case "number":
294
+ return numberToZod(field);
295
+ case "checkbox":
296
+ return checkboxToZod(field);
297
+ case "date":
298
+ return dateToZod(field);
299
+ case "email":
300
+ return emailToZod(field);
301
+ case "password":
302
+ return passwordToZod(field);
303
+ case "textarea":
304
+ return textareaToZod(field);
305
+ case "select":
306
+ return selectToZod(field);
307
+ case "radio":
308
+ return radioToZod(field);
309
+ case "color":
310
+ return colorToZod(field);
311
+ case "richtext":
312
+ return richTextToZod(field);
313
+ case "json":
314
+ return jsonToZod(field);
315
+ case "code":
316
+ return codeToZod(field);
317
+ case "upload":
318
+ return uploadToZod(field);
319
+ case "markdown":
320
+ return markdownToZod(field);
321
+ case "relationship":
322
+ return relationshipToZod(field);
323
+ case "array":
324
+ return arrayToZod(field);
325
+ case "group":
326
+ return groupToZod(field);
327
+ case "blocks":
328
+ return blocksToZod(field);
329
+ case "row":
330
+ return rowToZod(field);
331
+ case "collapsible":
332
+ return collapsibleToZod(field);
333
+ case "tabs":
334
+ return tabsToZod(field);
335
+ default:
336
+ return zod.z.any();
337
+ }
338
+ }
339
+ function textToZod(field) {
340
+ let schema = zod.z.string();
341
+ if (field.minLength) schema = schema.min(field.minLength);
342
+ if (field.maxLength) schema = schema.max(field.maxLength);
343
+ if (field.pattern) schema = schema.regex(new RegExp(field.pattern));
344
+ if (field.variant === "email") schema = schema.email();
345
+ if (field.variant === "url") schema = schema.url();
346
+ if (field.hasMany) schema = zod.z.array(schema);
347
+ if (!field.required) schema = schema.optional();
348
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
349
+ return schema;
350
+ }
351
+ function numberToZod(field) {
352
+ let schema = field.integer ? zod.z.number().int() : zod.z.number();
353
+ if (field.min !== void 0) schema = schema.min(field.min);
354
+ if (field.max !== void 0) schema = schema.max(field.max);
355
+ if (field.step) {
356
+ schema = schema.refine(
357
+ (val) => Number.isInteger(val / field.step),
358
+ `Value must be divisible by ${field.step}`
359
+ );
360
+ }
361
+ if (field.hasMany) schema = zod.z.array(schema);
362
+ if (!field.required) schema = schema.optional();
363
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
364
+ return schema;
365
+ }
366
+ function checkboxToZod(field) {
367
+ let schema = zod.z.boolean();
368
+ if (!field.required) schema = schema.optional();
369
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
370
+ return schema;
371
+ }
372
+ function dateToZod(field) {
373
+ let schema = zod.z.string().refine(
374
+ (val) => !isNaN(Date.parse(val)),
375
+ "Invalid date format"
376
+ );
377
+ if (field.minDate) {
378
+ schema = schema.refine(
379
+ (val) => new Date(val) >= new Date(field.minDate),
380
+ `Date must be after ${field.minDate}`
381
+ );
382
+ }
383
+ if (field.maxDate) {
384
+ schema = schema.refine(
385
+ (val) => new Date(val) <= new Date(field.maxDate),
386
+ `Date must be before ${field.maxDate}`
387
+ );
388
+ }
389
+ if (!field.required) schema = schema.optional();
390
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
391
+ return schema;
392
+ }
393
+ function emailToZod(field) {
394
+ let schema = zod.z.string().email("Invalid email");
395
+ if (!field.required) schema = schema.optional();
396
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
397
+ return schema;
398
+ }
399
+ function passwordToZod(field) {
400
+ let schema = zod.z.string().min(6, "Password must be at least 6 characters");
401
+ if (!field.required) schema = schema.optional();
402
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
403
+ return schema;
404
+ }
405
+ function textareaToZod(field) {
406
+ let schema = zod.z.string();
407
+ if (field.minLength) schema = schema.min(field.minLength);
408
+ if (field.maxLength) schema = schema.max(field.maxLength);
409
+ if (!field.required) schema = schema.optional();
410
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
411
+ return schema;
412
+ }
413
+ function selectToZod(field) {
414
+ const values = field.options.map((opt) => opt.value);
415
+ let schema;
416
+ if (field.hasMany) {
417
+ schema = zod.z.array(zod.z.enum(values));
418
+ } else {
419
+ schema = zod.z.enum(values);
420
+ }
421
+ if (!field.required) schema = schema.optional();
422
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
423
+ return schema;
424
+ }
425
+ function radioToZod(field) {
426
+ const values = field.options.map((opt) => opt.value);
427
+ let schema = zod.z.enum(values);
428
+ if (!field.required) schema = schema.optional();
429
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
430
+ return schema;
431
+ }
432
+ function colorToZod(field) {
433
+ let schema = zod.z.string();
434
+ if (field.format === "hex") schema = schema.regex(/^#[0-9A-Fa-f]{6}$/);
435
+ if (field.format === "rgb") schema = schema.regex(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/);
436
+ if (field.format === "hsl") schema = schema.regex(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/);
437
+ if (!field.required) schema = schema.optional();
438
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
439
+ return schema;
440
+ }
441
+ function richTextToZod(field) {
442
+ let schema = zod.z.array(zod.z.object({
443
+ type: zod.z.string(),
444
+ data: zod.z.record(zod.z.any()),
445
+ children: zod.z.array(zod.z.any()).optional()
446
+ }));
447
+ if (!field.required) schema = schema.optional();
448
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
449
+ return schema;
450
+ }
451
+ function jsonToZod(field) {
452
+ let schema = zod.z.record(zod.z.any());
453
+ if (!field.required) schema = schema.optional();
454
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
455
+ return schema;
456
+ }
457
+ function codeToZod(field) {
458
+ let schema = zod.z.string();
459
+ if (!field.required) schema = schema.optional();
460
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
461
+ return schema;
462
+ }
463
+ function uploadToZod(field) {
464
+ let schema = zod.z.string();
465
+ if (field.hasMany) schema = zod.z.array(zod.z.string());
466
+ if (!field.required) schema = schema.optional();
467
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
468
+ return schema;
469
+ }
470
+ function markdownToZod(field) {
471
+ let schema = zod.z.string();
472
+ if (!field.required) schema = schema.optional();
473
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
474
+ return schema;
475
+ }
476
+ function relationshipToZod(field) {
477
+ let schema = zod.z.string();
478
+ if (Array.isArray(field.relationTo)) {
479
+ schema = zod.z.object({
480
+ relationTo: zod.z.enum(field.relationTo),
481
+ value: zod.z.string()
482
+ });
483
+ }
484
+ if (field.hasMany) schema = zod.z.array(schema);
485
+ if (!field.required) schema = schema.optional();
486
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
487
+ return schema;
488
+ }
489
+ function arrayToZod(field) {
490
+ const itemSchema = zod.z.object(
491
+ Object.fromEntries(
492
+ field.fields.filter((f) => f.name).map((f) => [f.name, fieldToZod(f)])
493
+ )
494
+ );
495
+ let schema = zod.z.array(itemSchema);
496
+ if (field.minRows) schema = schema.min(field.minRows);
497
+ if (field.maxRows) schema = schema.max(field.maxRows);
498
+ if (!field.required) schema = schema.optional();
499
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
500
+ return schema;
501
+ }
502
+ function groupToZod(field) {
503
+ const schema = zod.z.object(
504
+ Object.fromEntries(
505
+ field.fields.filter((f) => f.name).map((f) => [f.name, fieldToZod(f)])
506
+ )
507
+ );
508
+ if (!field.required) return schema.optional();
509
+ return schema;
510
+ }
511
+ function blocksToZod(field) {
512
+ const blockSchemas = field.blocks.map((block) => {
513
+ return zod.z.object({
514
+ blockType: zod.z.literal(block.slug),
515
+ ...Object.fromEntries(
516
+ block.fields.filter((f) => f.name).map((f) => [f.name, fieldToZod(f)])
517
+ )
518
+ });
519
+ });
520
+ let schema = zod.z.array(zod.z.discriminatedUnion("blockType", blockSchemas));
521
+ if (field.minRows) schema = schema.min(field.minRows);
522
+ if (field.maxRows) schema = schema.max(field.maxRows);
523
+ if (!field.required) schema = schema.optional();
524
+ if (field.validate) schema = addCustomValidation(schema, field.validate);
525
+ return schema;
526
+ }
527
+ function rowToZod(field) {
528
+ const schema = zod.z.object(
529
+ Object.fromEntries(
530
+ field.fields.filter((f) => f.name).map((f) => [f.name, fieldToZod(f)])
531
+ )
532
+ );
533
+ return schema;
534
+ }
535
+ function collapsibleToZod(field) {
536
+ const schema = zod.z.object(
537
+ Object.fromEntries(
538
+ field.fields.filter((f) => f.name).map((f) => [f.name, fieldToZod(f)])
539
+ )
540
+ );
541
+ return schema;
542
+ }
543
+ function tabsToZod(field) {
544
+ const schemas = {};
545
+ for (const tab of field.tabs) {
546
+ for (const f of tab.fields) {
547
+ if (f.name) {
548
+ schemas[f.name] = fieldToZod(f);
549
+ }
550
+ }
551
+ }
552
+ return zod.z.object(schemas);
553
+ }
554
+ function addCustomValidation(schema, validate) {
555
+ return schema.refine(
556
+ async (val) => {
557
+ const result = await validate(val, { required: false });
558
+ return result === true;
559
+ },
560
+ {
561
+ message: "Custom validation failed"
562
+ }
563
+ );
564
+ }
565
+ function collectionToZod(collection) {
566
+ const shape = {};
567
+ for (const field of collection.fields) {
568
+ if (field.name) {
569
+ shape[field.name] = fieldToZod(field);
570
+ }
571
+ }
572
+ if (collection.timestamps) {
573
+ shape["createdAt"] = zod.z.string().optional();
574
+ shape["updatedAt"] = zod.z.string().optional();
575
+ }
576
+ if (collection.tenantScoped) {
577
+ shape["tenantID"] = zod.z.string().optional();
578
+ }
579
+ shape["id"] = zod.z.string().optional();
580
+ return zod.z.object(shape);
581
+ }
582
+ function collectionToCreateZod(collection) {
583
+ const shape = {};
584
+ for (const field of collection.fields) {
585
+ if (field.name) {
586
+ shape[field.name] = fieldToZod(field);
587
+ }
588
+ }
589
+ return zod.z.object(shape);
590
+ }
591
+ function collectionToUpdateZod(collection) {
592
+ const shape = {};
593
+ for (const field of collection.fields) {
594
+ if (field.name) {
595
+ shape[field.name] = fieldToZod(field).optional();
596
+ }
597
+ }
598
+ return zod.z.object(shape);
599
+ }
600
+ function collectionToWhereZod(collection) {
601
+ const shape = {};
602
+ for (const field of collection.fields) {
603
+ if (field.name) {
604
+ shape[field.name] = zod.z.object({
605
+ equals: zod.z.any().optional(),
606
+ not_equals: zod.z.any().optional(),
607
+ in: zod.z.array(zod.z.any()).optional(),
608
+ not_in: zod.z.array(zod.z.any()).optional(),
609
+ greater_than: zod.z.number().optional(),
610
+ greater_than_equal: zod.z.number().optional(),
611
+ less_than: zod.z.number().optional(),
612
+ less_than_equal: zod.z.number().optional(),
613
+ like: zod.z.string().optional(),
614
+ not_like: zod.z.string().optional(),
615
+ contains: zod.z.string().optional(),
616
+ exists: zod.z.boolean().optional()
617
+ }).optional();
618
+ }
619
+ }
620
+ shape["AND"] = zod.z.array(zod.z.lazy(() => zod.z.object(shape))).optional();
621
+ shape["OR"] = zod.z.array(zod.z.lazy(() => zod.z.object(shape))).optional();
622
+ return zod.z.object(shape).optional();
623
+ }
624
+ function globalToZod(global) {
625
+ const shape = {};
626
+ for (const field of global.fields) {
627
+ if (field.name) {
628
+ shape[field.name] = fieldToZod(field);
629
+ }
630
+ }
631
+ shape["id"] = zod.z.string().optional();
632
+ return zod.z.object(shape);
633
+ }
634
+
635
+ // src/registry/index.ts
636
+ var Registry = class {
637
+ collections = /* @__PURE__ */ new Map();
638
+ globals = /* @__PURE__ */ new Map();
639
+ plugins = [];
640
+ schemaCache = /* @__PURE__ */ new Map();
641
+ initialized = false;
642
+ // ========================================================================
643
+ // Collection Management
644
+ // ========================================================================
645
+ addCollection(config) {
646
+ if (this.initialized) {
647
+ throw new Error("Cannot add collections after Registry has been initialized");
648
+ }
649
+ const errors = validateCollection(config);
650
+ if (errors.length > 0) {
651
+ throw new Error(`Invalid collection config: ${errors.join(", ")}`);
652
+ }
653
+ let finalConfig = { ...config };
654
+ for (const plugin of this.plugins) {
655
+ if (plugin.extendCollection) {
656
+ finalConfig = plugin.extendCollection(finalConfig.slug, finalConfig);
657
+ }
658
+ }
659
+ finalConfig.fields = this.applyFieldDefaults(finalConfig);
660
+ this.collections.set(finalConfig.slug, finalConfig);
661
+ this.clearSchemaCache(finalConfig.slug);
662
+ }
663
+ addCollections(configs) {
664
+ for (const config of configs) {
665
+ this.addCollection(config);
666
+ }
667
+ }
668
+ getCollection(slug) {
669
+ return this.collections.get(slug);
670
+ }
671
+ getCollections() {
672
+ return Array.from(this.collections.values());
673
+ }
674
+ getCollectionSlugs() {
675
+ return Array.from(this.collections.keys());
676
+ }
677
+ hasCollection(slug) {
678
+ return this.collections.has(slug);
679
+ }
680
+ removeCollection(slug) {
681
+ if (this.initialized) {
682
+ throw new Error("Cannot remove collections after Registry has been initialized");
683
+ }
684
+ this.clearSchemaCache(slug);
685
+ return this.collections.delete(slug);
686
+ }
687
+ // ========================================================================
688
+ // Global Management
689
+ // ========================================================================
690
+ addGlobal(config) {
691
+ if (this.initialized) {
692
+ throw new Error("Cannot add globals after Registry has been initialized");
693
+ }
694
+ const errors = validateGlobal(config);
695
+ if (errors.length > 0) {
696
+ throw new Error(`Invalid global config: ${errors.join(", ")}`);
697
+ }
698
+ let finalConfig = { ...config };
699
+ for (const plugin of this.plugins) {
700
+ if (plugin.extendGlobal) {
701
+ finalConfig = plugin.extendGlobal(finalConfig.slug, finalConfig);
702
+ }
703
+ }
704
+ this.globals.set(finalConfig.slug, finalConfig);
705
+ this.clearSchemaCache(`global:${finalConfig.slug}`);
706
+ }
707
+ addGlobals(configs) {
708
+ for (const config of configs) {
709
+ this.addGlobal(config);
710
+ }
711
+ }
712
+ getGlobal(slug) {
713
+ return this.globals.get(slug);
714
+ }
715
+ getGlobals() {
716
+ return Array.from(this.globals.values());
717
+ }
718
+ getGlobalSlugs() {
719
+ return Array.from(this.globals.keys());
720
+ }
721
+ hasGlobal(slug) {
722
+ return this.globals.has(slug);
723
+ }
724
+ removeGlobal(slug) {
725
+ if (this.initialized) {
726
+ throw new Error("Cannot remove globals after Registry has been initialized");
727
+ }
728
+ this.clearSchemaCache(`global:${slug}`);
729
+ return this.globals.delete(slug);
730
+ }
731
+ // ========================================================================
732
+ // Plugin Management
733
+ // ========================================================================
734
+ addPlugin(plugin) {
735
+ if (this.initialized) {
736
+ throw new Error("Cannot add plugins after Registry has been initialized");
737
+ }
738
+ this.plugins.push(plugin);
739
+ }
740
+ getPlugins() {
741
+ return [...this.plugins];
742
+ }
743
+ // ========================================================================
744
+ // Schema Generation
745
+ // ========================================================================
746
+ getZodSchema(slug) {
747
+ const cached = this.schemaCache.get(slug);
748
+ if (cached) return cached;
749
+ const collection = this.collections.get(slug);
750
+ if (collection) {
751
+ const schema = collectionToZod(collection);
752
+ this.schemaCache.set(slug, schema);
753
+ return schema;
754
+ }
755
+ const global = this.globals.get(slug);
756
+ if (global) {
757
+ const schema = globalToZod(global);
758
+ this.schemaCache.set(`global:${slug}`, schema);
759
+ return schema;
760
+ }
761
+ throw new Error(`No collection or global found with slug "${slug}"`);
762
+ }
763
+ getCreateZodSchema(slug) {
764
+ const cacheKey = `${slug}:create`;
765
+ const cached = this.schemaCache.get(cacheKey);
766
+ if (cached) return cached;
767
+ const collection = this.collections.get(slug);
768
+ if (collection) {
769
+ const schema = collectionToCreateZod(collection);
770
+ this.schemaCache.set(cacheKey, schema);
771
+ return schema;
772
+ }
773
+ throw new Error(`No collection found with slug "${slug}"`);
774
+ }
775
+ getUpdateZodSchema(slug) {
776
+ const cacheKey = `${slug}:update`;
777
+ const cached = this.schemaCache.get(cacheKey);
778
+ if (cached) return cached;
779
+ const collection = this.collections.get(slug);
780
+ if (collection) {
781
+ const schema = collectionToUpdateZod(collection);
782
+ this.schemaCache.set(cacheKey, schema);
783
+ return schema;
784
+ }
785
+ throw new Error(`No collection found with slug "${slug}"`);
786
+ }
787
+ getWhereZodSchema(slug) {
788
+ const cacheKey = `${slug}:where`;
789
+ const cached = this.schemaCache.get(cacheKey);
790
+ if (cached) return cached;
791
+ const collection = this.collections.get(slug);
792
+ if (collection) {
793
+ const schema = collectionToWhereZod(collection);
794
+ this.schemaCache.set(cacheKey, schema);
795
+ return schema;
796
+ }
797
+ throw new Error(`No collection found with slug "${slug}"`);
798
+ }
799
+ getFieldZodSchema(field) {
800
+ return fieldToZod(field);
801
+ }
802
+ clearSchemaCache(slug) {
803
+ this.schemaCache.delete(slug);
804
+ this.schemaCache.delete(`${slug}:create`);
805
+ this.schemaCache.delete(`${slug}:update`);
806
+ this.schemaCache.delete(`${slug}:where`);
807
+ }
808
+ // ========================================================================
809
+ // Field Helpers
810
+ // ========================================================================
811
+ applyFieldDefaults(config) {
812
+ const fields = [...config.fields];
813
+ if (!fields.some((f) => f.name === "id")) {
814
+ fields.unshift({
815
+ name: "id",
816
+ type: "text",
817
+ admin: { readOnly: true, hidden: true }
818
+ });
819
+ }
820
+ if (config.tenantScoped && !fields.some((f) => f.name === "tenantID")) {
821
+ fields.push({
822
+ name: "tenantID",
823
+ type: "text",
824
+ required: true,
825
+ admin: { readOnly: true, hidden: true }
826
+ });
827
+ }
828
+ if (config.timestamps && !fields.some((f) => f.name === "createdAt")) {
829
+ fields.push({
830
+ name: "createdAt",
831
+ type: "date",
832
+ admin: { readOnly: true, hidden: true }
833
+ });
834
+ fields.push({
835
+ name: "updatedAt",
836
+ type: "date",
837
+ admin: { readOnly: true, hidden: true }
838
+ });
839
+ }
840
+ return fields;
841
+ }
842
+ getFields(slug) {
843
+ const collection = this.collections.get(slug);
844
+ if (collection) return collection.fields;
845
+ const global = this.globals.get(slug);
846
+ if (global) return global.fields;
847
+ throw new Error(`No collection or global found with slug "${slug}"`);
848
+ }
849
+ getFieldMap(slug) {
850
+ const fields = this.getFields(slug);
851
+ const map = /* @__PURE__ */ new Map();
852
+ const addFields = (fields2) => {
853
+ for (const field of fields2) {
854
+ if (field.name) {
855
+ map.set(field.name, field);
856
+ }
857
+ if ("fields" in field && field.fields) {
858
+ addFields(field.fields);
859
+ }
860
+ if ("tabs" in field) {
861
+ for (const tab of field.tabs) {
862
+ addFields(tab.fields);
863
+ }
864
+ }
865
+ if ("blocks" in field) {
866
+ for (const block of field.blocks) {
867
+ addFields(block.fields);
868
+ }
869
+ }
870
+ }
871
+ };
872
+ addFields(fields);
873
+ return map;
874
+ }
875
+ getVisibleFields(slug) {
876
+ const fields = this.getFields(slug);
877
+ return fields.filter((f) => !f.admin?.hidden);
878
+ }
879
+ // ========================================================================
880
+ // Initialization
881
+ // ========================================================================
882
+ validate() {
883
+ const collections = this.getCollections();
884
+ const globals = this.getGlobals();
885
+ validateConfig(collections, globals);
886
+ }
887
+ async init() {
888
+ this.validate();
889
+ for (const plugin of this.plugins) {
890
+ if (plugin.init) {
891
+ await plugin.init(this);
892
+ }
893
+ }
894
+ this.initialized = true;
895
+ }
896
+ isInitialized() {
897
+ return this.initialized;
898
+ }
899
+ // ========================================================================
900
+ // Query Helpers
901
+ // ========================================================================
902
+ getPaginationDefaults(slug) {
903
+ const collection = this.collections.get(slug);
904
+ return {
905
+ defaultLimit: collection?.admin?.pagination?.defaultLimit || 10,
906
+ limits: collection?.admin?.pagination?.limits || [10, 25, 50, 100]
907
+ };
908
+ }
909
+ getDefaultSort(slug) {
910
+ const collection = this.collections.get(slug);
911
+ const useAsTitle = collection?.admin?.useAsTitle;
912
+ if (useAsTitle) return useAsTitle;
913
+ return "createdAt";
914
+ }
915
+ getDefaultColumns(slug) {
916
+ const collection = this.collections.get(slug);
917
+ if (collection?.admin?.defaultColumns) {
918
+ return collection.admin.defaultColumns;
919
+ }
920
+ const fields = this.getVisibleFields(slug);
921
+ return fields.slice(0, 4).map((f) => f.name);
922
+ }
923
+ // ========================================================================
924
+ // Admin Helpers
925
+ // ========================================================================
926
+ getAdminTitle(slug) {
927
+ const collection = this.collections.get(slug);
928
+ return collection?.label || collection?.admin?.description || slug;
929
+ }
930
+ getAdminLabel(slug) {
931
+ const collection = this.collections.get(slug);
932
+ return collection?.singularLabel || collection?.label || slug;
933
+ }
934
+ getAdminGroup(slug) {
935
+ return this.collections.get(slug)?.admin?.group;
936
+ }
937
+ // ========================================================================
938
+ // Debug / Stats
939
+ // ========================================================================
940
+ getStats() {
941
+ let totalFields = 0;
942
+ for (const collection of this.collections.values()) {
943
+ totalFields += collection.fields.length;
944
+ }
945
+ for (const global of this.globals.values()) {
946
+ totalFields += global.fields.length;
947
+ }
948
+ return {
949
+ collections: this.collections.size,
950
+ globals: this.globals.size,
951
+ plugins: this.plugins.length,
952
+ fields: totalFields
953
+ };
954
+ }
955
+ toJSON() {
956
+ return {
957
+ collections: this.getCollections(),
958
+ globals: this.getGlobals()
959
+ };
960
+ }
961
+ };
962
+ var instance = null;
963
+ function getRegistry() {
964
+ if (!instance) {
965
+ instance = new Registry();
966
+ }
967
+ return instance;
968
+ }
969
+ function resetRegistry() {
970
+ instance = null;
971
+ }
972
+ function createRegistry() {
973
+ instance = new Registry();
974
+ return instance;
975
+ }
976
+ var Kyro = class {
977
+ registry;
978
+ db;
979
+ pubsub;
980
+ wsServer;
981
+ config;
982
+ constructor(config) {
983
+ this.config = config;
984
+ this.registry = createRegistry();
985
+ this.db = config.adapter;
986
+ this.pubsub = new chunkDVD5P72E_cjs.KyroPubSub(this.registry);
987
+ if (config.collections) {
988
+ this.registry.addCollections(config.collections);
989
+ }
990
+ if (config.globals) {
991
+ this.registry.addGlobals(config.globals);
992
+ }
993
+ if (config.plugins) {
994
+ for (const plugin of config.plugins) {
995
+ this.registry.addPlugin(plugin);
996
+ }
997
+ }
998
+ }
999
+ async init() {
1000
+ await this.registry.init();
1001
+ await this.db.init(this.registry.getCollections(), this.registry.getGlobals());
1002
+ this.pubsub.autoRegisterHooks();
1003
+ console.log("\u2705 Kyro CMS initialized");
1004
+ console.log(` Collections: ${this.registry.getCollections().length}`);
1005
+ console.log(` Globals: ${this.registry.getGlobals().length}`);
1006
+ }
1007
+ // ============================================================================
1008
+ // API Methods
1009
+ // ============================================================================
1010
+ getREST(options) {
1011
+ return chunkUEG7KMKC_cjs.createHonoApp({
1012
+ registry: this.registry,
1013
+ db: this.db,
1014
+ ...options,
1015
+ cors: this.config.cors
1016
+ });
1017
+ }
1018
+ getGraphQL(options) {
1019
+ return chunkK7QF2QCM_cjs.buildGraphQLSchema({
1020
+ registry: this.registry,
1021
+ db: this.db,
1022
+ ...options
1023
+ });
1024
+ }
1025
+ getTRPC(options) {
1026
+ return chunk3VZCX4DF_cjs.createKyroServer({
1027
+ registry: this.registry,
1028
+ db: this.db,
1029
+ req: options?.req || { headers: {} },
1030
+ ...options
1031
+ });
1032
+ }
1033
+ async startWebSocket(options) {
1034
+ this.wsServer = chunkDVD5P72E_cjs.createWSServer({
1035
+ pubsub: this.pubsub,
1036
+ port: options?.port || 8080,
1037
+ requireAuth: options?.requireAuth,
1038
+ verifyToken: options?.verifyToken
1039
+ });
1040
+ console.log(`\u{1F50C} WebSocket server started on port ${options?.port || 8080}`);
1041
+ return this.wsServer;
1042
+ }
1043
+ // ============================================================================
1044
+ // Lifecycle
1045
+ // ============================================================================
1046
+ async shutdown() {
1047
+ if (this.wsServer) {
1048
+ await this.wsServer.close();
1049
+ }
1050
+ await this.db.disconnect();
1051
+ console.log("\u{1F44B} Kyro CMS shut down");
1052
+ }
1053
+ };
1054
+ function createKyro(config) {
1055
+ return new Kyro(config);
1056
+ }
1057
+
1058
+ // src/fields/types.ts
1059
+ function isTextField(field) {
1060
+ return field.type === "text";
1061
+ }
1062
+ function isNumberField(field) {
1063
+ return field.type === "number";
1064
+ }
1065
+ function isRelationshipField(field) {
1066
+ return field.type === "relationship";
1067
+ }
1068
+ function isArrayField(field) {
1069
+ return field.type === "array";
1070
+ }
1071
+ function isGroupField(field) {
1072
+ return field.type === "group";
1073
+ }
1074
+ function isBlocksField(field) {
1075
+ return field.type === "blocks";
1076
+ }
1077
+ function isUploadField(field) {
1078
+ return field.type === "upload";
1079
+ }
1080
+ function isRichTextField(field) {
1081
+ return field.type === "richtext";
1082
+ }
1083
+ function isSelectField(field) {
1084
+ return field.type === "select";
1085
+ }
1086
+ function isLayoutField(field) {
1087
+ return field.type === "row" || field.type === "collapsible" || field.type === "tabs";
1088
+ }
1089
+ var PRIMITIVE_FIELD_TYPES = [
1090
+ "text",
1091
+ "number",
1092
+ "checkbox",
1093
+ "date",
1094
+ "email",
1095
+ "password",
1096
+ "textarea",
1097
+ "select",
1098
+ "radio",
1099
+ "color"
1100
+ ];
1101
+ var COMPLEX_FIELD_TYPES = [
1102
+ "richtext",
1103
+ "json",
1104
+ "code",
1105
+ "upload",
1106
+ "markdown"
1107
+ ];
1108
+ var RELATIONAL_FIELD_TYPES = [
1109
+ "relationship",
1110
+ "array",
1111
+ "group",
1112
+ "blocks"
1113
+ ];
1114
+ var LAYOUT_FIELD_TYPES = [
1115
+ "row",
1116
+ "collapsible",
1117
+ "tabs"
1118
+ ];
1119
+ var ALL_FIELD_TYPES = [
1120
+ ...PRIMITIVE_FIELD_TYPES,
1121
+ ...COMPLEX_FIELD_TYPES,
1122
+ ...RELATIONAL_FIELD_TYPES,
1123
+ ...LAYOUT_FIELD_TYPES
1124
+ ];
1125
+
1126
+ // src/hooks/types.ts
1127
+ async function runHooks(hooks, args) {
1128
+ let result = args.data;
1129
+ for (const hook of hooks) {
1130
+ const hookResult = await hook({
1131
+ ...args,
1132
+ data: result
1133
+ });
1134
+ if (hookResult !== void 0) {
1135
+ result = hookResult;
1136
+ }
1137
+ }
1138
+ return result;
1139
+ }
1140
+ async function runFieldHooks(hooks, args) {
1141
+ return runHooks(hooks, args);
1142
+ }
1143
+
1144
+ // src/database/local/adapter.ts
1145
+ var LocalAdapter = class extends chunkRLTG4YZM_cjs.AbstractBaseAdapter {
1146
+ db;
1147
+ migrations = /* @__PURE__ */ new Map();
1148
+ constructor(options) {
1149
+ super();
1150
+ if (options.db) {
1151
+ this.db = options.db;
1152
+ } else if (options.path) {
1153
+ this.db = null;
1154
+ } else {
1155
+ this.db = null;
1156
+ }
1157
+ }
1158
+ async connect() {
1159
+ if (!this.db) {
1160
+ const Database = (await import('better-sqlite3')).default;
1161
+ this.db = new Database(":memory:");
1162
+ }
1163
+ this.db.pragma("journal_mode = WAL");
1164
+ this.db.pragma("foreign_keys = ON");
1165
+ this.connected = true;
1166
+ console.log("[LocalAdapter] Connected to SQLite");
1167
+ }
1168
+ async disconnect() {
1169
+ if (this.db) {
1170
+ this.db.close();
1171
+ }
1172
+ this.connected = false;
1173
+ console.log("[LocalAdapter] Disconnected");
1174
+ }
1175
+ // ========================================================================
1176
+ // Schema Management
1177
+ // ========================================================================
1178
+ ensureTable(config) {
1179
+ const tableName = this.getTableNameFor(config.slug);
1180
+ if (this.migrations.has(tableName)) return;
1181
+ const columns = [
1182
+ `id TEXT PRIMARY KEY`
1183
+ ];
1184
+ for (const field of config.fields) {
1185
+ if (!field.name || field.name === "id") continue;
1186
+ const colDef = this.fieldToSQL(field);
1187
+ if (colDef) columns.push(colDef);
1188
+ }
1189
+ if (config.timestamps) {
1190
+ columns.push(`created_at TEXT DEFAULT (datetime('now'))`);
1191
+ columns.push(`updated_at TEXT DEFAULT (datetime('now'))`);
1192
+ }
1193
+ if (config.tenantScoped) {
1194
+ columns.push(`tenant_id TEXT NOT NULL`);
1195
+ }
1196
+ const createSQL = `CREATE TABLE IF NOT EXISTS ${tableName} (${columns.join(", ")})`;
1197
+ this.db.exec(createSQL);
1198
+ for (const field of config.fields) {
1199
+ if (field.name && field.indexed) {
1200
+ this.db.exec(`CREATE INDEX IF NOT EXISTS idx_${tableName}_${field.name} ON ${tableName}(${field.name})`);
1201
+ }
1202
+ if (field.name && field.unique) {
1203
+ this.db.exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_${tableName}_${field.name}_unique ON ${tableName}(${field.name})`);
1204
+ }
1205
+ }
1206
+ this.migrations.set(tableName, true);
1207
+ }
1208
+ fieldToSQL(field) {
1209
+ switch (field.type) {
1210
+ case "text":
1211
+ case "email":
1212
+ case "password":
1213
+ case "textarea":
1214
+ case "color":
1215
+ case "code":
1216
+ case "markdown":
1217
+ case "url":
1218
+ return `${field.name} TEXT`;
1219
+ case "number":
1220
+ return `${field.name} REAL`;
1221
+ case "checkbox":
1222
+ return `${field.name} INTEGER DEFAULT 0`;
1223
+ case "date":
1224
+ return `${field.name} TEXT`;
1225
+ case "select":
1226
+ case "radio":
1227
+ return `${field.name} TEXT`;
1228
+ case "relationship":
1229
+ case "upload":
1230
+ return `${field.name} TEXT`;
1231
+ case "json":
1232
+ case "richtext":
1233
+ case "array":
1234
+ case "group":
1235
+ case "blocks":
1236
+ return `${field.name} TEXT`;
1237
+ default:
1238
+ return null;
1239
+ }
1240
+ }
1241
+ // ========================================================================
1242
+ // CRUD Operations
1243
+ // ========================================================================
1244
+ async find(args) {
1245
+ const { collection: slug, where = {}, sort, limit = 10, page = 1, tenantID } = args;
1246
+ const config = this.getCollection(slug);
1247
+ this.ensureTable(config);
1248
+ const tableName = this.getTableNameFor(slug);
1249
+ let sql = `SELECT * FROM ${tableName}`;
1250
+ const params = [];
1251
+ const conditions = [];
1252
+ if (tenantID && config.tenantScoped) {
1253
+ conditions.push(`tenant_id = ?`);
1254
+ params.push(tenantID);
1255
+ }
1256
+ for (const [key, value] of Object.entries(where)) {
1257
+ if (key === "AND" || key === "OR") continue;
1258
+ if (typeof value === "object" && value !== null) {
1259
+ if (value.equals !== void 0) {
1260
+ conditions.push(`${key} = ?`);
1261
+ params.push(value.equals);
1262
+ }
1263
+ if (value.in !== void 0) {
1264
+ conditions.push(`${key} IN (${value.in.map(() => "?").join(", ")})`);
1265
+ params.push(...value.in);
1266
+ }
1267
+ if (value.not_equals !== void 0) {
1268
+ conditions.push(`${key} != ?`);
1269
+ params.push(value.not_equals);
1270
+ }
1271
+ } else {
1272
+ conditions.push(`${key} = ?`);
1273
+ params.push(value);
1274
+ }
1275
+ }
1276
+ if (conditions.length > 0) {
1277
+ sql += ` WHERE ${conditions.join(" AND ")}`;
1278
+ }
1279
+ const sortField = sort?.replace("-", "") || "created_at";
1280
+ const sortDir = sort?.startsWith("-") ? "DESC" : "ASC";
1281
+ sql += ` ORDER BY ${sortField} ${sortDir}`;
1282
+ const countSql = sql.replace("SELECT *", "SELECT COUNT(*) as count");
1283
+ const countResult = this.db.prepare(countSql).get(...params);
1284
+ const totalDocs = countResult?.count || 0;
1285
+ sql += ` LIMIT ? OFFSET ?`;
1286
+ params.push(limit, (page - 1) * limit);
1287
+ const rows = this.db.prepare(sql).all(...params);
1288
+ const docs = rows.map((row) => this.rowToDoc(row, config));
1289
+ return {
1290
+ docs,
1291
+ totalDocs,
1292
+ limit,
1293
+ totalPages: Math.ceil(totalDocs / limit),
1294
+ page,
1295
+ pagingCounter: (page - 1) * limit + 1,
1296
+ hasPrevPage: page > 1,
1297
+ hasNextPage: page < Math.ceil(totalDocs / limit),
1298
+ prevPage: page > 1 ? page - 1 : null,
1299
+ nextPage: page < Math.ceil(totalDocs / limit) ? page + 1 : null
1300
+ };
1301
+ }
1302
+ async findByID(args) {
1303
+ const { collection: slug, id, tenantID } = args;
1304
+ const config = this.getCollection(slug);
1305
+ this.ensureTable(config);
1306
+ const tableName = this.getTableNameFor(slug);
1307
+ let sql = `SELECT * FROM ${tableName} WHERE id = ?`;
1308
+ const params = [id];
1309
+ if (tenantID && config.tenantScoped) {
1310
+ sql += ` AND tenant_id = ?`;
1311
+ params.push(tenantID);
1312
+ }
1313
+ const row = this.db.prepare(sql).get(...params);
1314
+ if (!row) return null;
1315
+ return this.rowToDoc(row, config);
1316
+ }
1317
+ async create(args) {
1318
+ const { collection: slug, data, tenantID } = args;
1319
+ const config = this.getCollection(slug);
1320
+ this.ensureTable(config);
1321
+ const tableName = this.getTableNameFor(slug);
1322
+ const id = data.id || this.generateId();
1323
+ const insertData = this.prepareData(data, config);
1324
+ insertData.id = id;
1325
+ insertData.created_at = (/* @__PURE__ */ new Date()).toISOString();
1326
+ insertData.updated_at = (/* @__PURE__ */ new Date()).toISOString();
1327
+ if (tenantID && config.tenantScoped) {
1328
+ insertData.tenant_id = tenantID;
1329
+ }
1330
+ const columns = Object.keys(insertData);
1331
+ const placeholders = columns.map(() => "?").join(", ");
1332
+ const values = Object.values(insertData).map(
1333
+ (v) => typeof v === "object" ? JSON.stringify(v) : v
1334
+ );
1335
+ this.db.prepare(
1336
+ `INSERT INTO ${tableName} (${columns.join(", ")}) VALUES (${placeholders})`
1337
+ ).run(...values);
1338
+ return { ...insertData, id };
1339
+ }
1340
+ async update(args) {
1341
+ const { collection: slug, id, data, tenantID } = args;
1342
+ const config = this.getCollection(slug);
1343
+ this.ensureTable(config);
1344
+ const tableName = this.getTableNameFor(slug);
1345
+ const updateData = this.prepareData(data, config);
1346
+ updateData.updated_at = (/* @__PURE__ */ new Date()).toISOString();
1347
+ const columns = Object.keys(updateData);
1348
+ const setClause = columns.map((c) => `${c} = ?`).join(", ");
1349
+ const values = Object.values(updateData).map(
1350
+ (v) => typeof v === "object" ? JSON.stringify(v) : v
1351
+ );
1352
+ let sql = `UPDATE ${tableName} SET ${setClause} WHERE id = ?`;
1353
+ const params = [...values, id];
1354
+ if (tenantID && config.tenantScoped) {
1355
+ sql += ` AND tenant_id = ?`;
1356
+ params.push(tenantID);
1357
+ }
1358
+ this.db.prepare(sql).run(...params);
1359
+ return this.findByID({ collection: slug, id, tenantID });
1360
+ }
1361
+ async delete(args) {
1362
+ const { collection: slug, id, tenantID } = args;
1363
+ const config = this.getCollection(slug);
1364
+ this.ensureTable(config);
1365
+ const doc = await this.findByID({ collection: slug, id, tenantID });
1366
+ if (!doc) throw new Error(`Document not found: ${slug}/${id}`);
1367
+ const tableName = this.getTableNameFor(slug);
1368
+ let sql = `DELETE FROM ${tableName} WHERE id = ?`;
1369
+ const params = [id];
1370
+ if (tenantID && config.tenantScoped) {
1371
+ sql += ` AND tenant_id = ?`;
1372
+ params.push(tenantID);
1373
+ }
1374
+ this.db.prepare(sql).run(...params);
1375
+ return doc;
1376
+ }
1377
+ async count(args) {
1378
+ const { collection: slug, tenantID } = args;
1379
+ const config = this.getCollection(slug);
1380
+ this.ensureTable(config);
1381
+ const tableName = this.getTableNameFor(slug);
1382
+ let sql = `SELECT COUNT(*) as count FROM ${tableName}`;
1383
+ const params = [];
1384
+ if (tenantID && config.tenantScoped) {
1385
+ sql += ` WHERE tenant_id = ?`;
1386
+ params.push(tenantID);
1387
+ }
1388
+ const result = this.db.prepare(sql).get(...params);
1389
+ return result?.count || 0;
1390
+ }
1391
+ async findOne(args) {
1392
+ const result = await this.find({ ...args, limit: 1 });
1393
+ return result.docs[0] || null;
1394
+ }
1395
+ // ========================================================================
1396
+ // Version Support (Placeholder)
1397
+ // ========================================================================
1398
+ async findVersions() {
1399
+ return { docs: [], totalDocs: 0, limit: 10, totalPages: 0, page: 1, pagingCounter: 0, hasPrevPage: false, hasNextPage: false, prevPage: null, nextPage: null };
1400
+ }
1401
+ async findVersionByID() {
1402
+ return null;
1403
+ }
1404
+ async createVersion() {
1405
+ return {};
1406
+ }
1407
+ async deleteVersions() {
1408
+ }
1409
+ // ========================================================================
1410
+ // Helpers
1411
+ // ========================================================================
1412
+ rowToDoc(row, config) {
1413
+ const doc = { id: row.id };
1414
+ for (const field of config.fields) {
1415
+ if (!field.name || field.name === "id") continue;
1416
+ let value = row[field.name];
1417
+ if (field.type === "json" || field.type === "richtext" || field.type === "array" || field.type === "group" || field.type === "blocks") {
1418
+ try {
1419
+ value = value ? JSON.parse(value) : null;
1420
+ } catch {
1421
+ value = null;
1422
+ }
1423
+ }
1424
+ if (field.type === "checkbox") {
1425
+ value = Boolean(value);
1426
+ }
1427
+ if (field.type === "date" && value) {
1428
+ value = new Date(value).toISOString();
1429
+ }
1430
+ doc[field.name] = value;
1431
+ }
1432
+ if (config.timestamps) {
1433
+ doc.createdAt = row.created_at;
1434
+ doc.updatedAt = row.updated_at;
1435
+ }
1436
+ if (config.tenantScoped) {
1437
+ doc.tenantID = row.tenant_id;
1438
+ }
1439
+ return doc;
1440
+ }
1441
+ generateId() {
1442
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 9)}`;
1443
+ }
1444
+ getTableNameFor(slug) {
1445
+ return slug.replace(/-/g, "_");
1446
+ }
1447
+ // ========================================================================
1448
+ // Migrations
1449
+ // ========================================================================
1450
+ async migrate() {
1451
+ for (const config of this.collections.values()) {
1452
+ this.ensureTable(config);
1453
+ }
1454
+ console.log("[LocalAdapter] Migrations complete");
1455
+ }
1456
+ async rollback() {
1457
+ console.log("[LocalAdapter] Rollback not supported for schema changes");
1458
+ }
1459
+ // ========================================================================
1460
+ // Transaction Support
1461
+ // ========================================================================
1462
+ async transaction(fn) {
1463
+ return new Promise((resolve, reject) => {
1464
+ const tx = this.db.transaction(async () => {
1465
+ return fn({ db: this.db });
1466
+ });
1467
+ try {
1468
+ const result = tx();
1469
+ resolve(result);
1470
+ } catch (error) {
1471
+ reject(error);
1472
+ }
1473
+ });
1474
+ }
1475
+ // ========================================================================
1476
+ // Direct DB Access
1477
+ // ========================================================================
1478
+ getDatabase() {
1479
+ return this.db;
1480
+ }
1481
+ exec(sql) {
1482
+ this.db.exec(sql);
1483
+ }
1484
+ prepare(sql) {
1485
+ return this.db.prepare(sql);
1486
+ }
1487
+ };
1488
+ function createLocalAdapter(options) {
1489
+ return new LocalAdapter(options || {});
1490
+ }
1491
+
1492
+ // src/plugins/index.ts
1493
+ var KyroPlugin = class {
1494
+ name;
1495
+ version;
1496
+ description;
1497
+ hooks = {};
1498
+ collections = [];
1499
+ globals = [];
1500
+ fields = [];
1501
+ extensions = { collections: [], globals: [] };
1502
+ adminComponents = {};
1503
+ adminStyles = [];
1504
+ serverMiddleware;
1505
+ clientMiddleware;
1506
+ constructor(name) {
1507
+ this.name = name;
1508
+ }
1509
+ async init(api) {
1510
+ }
1511
+ async beforeInit(api) {
1512
+ }
1513
+ async afterInit(api) {
1514
+ }
1515
+ getCollections() {
1516
+ return this.collections;
1517
+ }
1518
+ getGlobals() {
1519
+ return this.globals;
1520
+ }
1521
+ getHooks() {
1522
+ return this.hooks;
1523
+ }
1524
+ };
1525
+ var PluginManager = class {
1526
+ plugins = /* @__PURE__ */ new Map();
1527
+ hooks = /* @__PURE__ */ new Map();
1528
+ register(plugin) {
1529
+ if (this.plugins.has(plugin.name)) {
1530
+ throw new Error(`Plugin "${plugin.name}" is already registered`);
1531
+ }
1532
+ this.plugins.set(plugin.name, plugin);
1533
+ const pluginHooks = plugin.getHooks?.() || {};
1534
+ for (const [event, handlers] of Object.entries(pluginHooks)) {
1535
+ if (Array.isArray(handlers)) {
1536
+ for (const handler of handlers) {
1537
+ this.registerHook(event, handler);
1538
+ }
1539
+ }
1540
+ }
1541
+ console.log(`[PluginManager] Registered plugin: ${plugin.name}`);
1542
+ }
1543
+ unregister(name) {
1544
+ const plugin = this.plugins.get(name);
1545
+ if (!plugin) return;
1546
+ const pluginHooks = plugin.getHooks?.() || {};
1547
+ for (const [event, handlers] of Object.entries(pluginHooks)) {
1548
+ if (Array.isArray(handlers)) {
1549
+ for (const handler of handlers) {
1550
+ this.unregisterHook(event, handler);
1551
+ }
1552
+ }
1553
+ }
1554
+ this.plugins.delete(name);
1555
+ console.log(`[PluginManager] Unregistered plugin: ${name}`);
1556
+ }
1557
+ get(name) {
1558
+ return this.plugins.get(name);
1559
+ }
1560
+ getAll() {
1561
+ return Array.from(this.plugins.values());
1562
+ }
1563
+ has(name) {
1564
+ return this.plugins.has(name);
1565
+ }
1566
+ registerHook(event, handler) {
1567
+ if (!this.hooks.has(event)) {
1568
+ this.hooks.set(event, []);
1569
+ }
1570
+ this.hooks.get(event).push(handler);
1571
+ }
1572
+ unregisterHook(event, handler) {
1573
+ const handlers = this.hooks.get(event);
1574
+ if (handlers) {
1575
+ const index = handlers.indexOf(handler);
1576
+ if (index > -1) {
1577
+ handlers.splice(index, 1);
1578
+ }
1579
+ }
1580
+ }
1581
+ async executeHook(event, args) {
1582
+ const handlers = this.hooks.get(event) || [];
1583
+ let result = args;
1584
+ for (const handler of handlers) {
1585
+ try {
1586
+ const hookResult = await handler({ ...args, data: result });
1587
+ if (hookResult !== void 0) {
1588
+ result = hookResult;
1589
+ }
1590
+ } catch (error) {
1591
+ console.error(`[PluginManager] Error in hook "${event}":`, error);
1592
+ }
1593
+ }
1594
+ return result;
1595
+ }
1596
+ // ========================================================================
1597
+ // Collection/Field Extensions
1598
+ // ========================================================================
1599
+ getAllCollections() {
1600
+ const collections = [];
1601
+ for (const plugin of this.plugins.values()) {
1602
+ const pluginCollections = plugin.getCollections?.() || [];
1603
+ collections.push(...pluginCollections);
1604
+ }
1605
+ return collections;
1606
+ }
1607
+ getAllGlobals() {
1608
+ const globals = [];
1609
+ for (const plugin of this.plugins.values()) {
1610
+ const pluginGlobals = plugin.getGlobals?.() || [];
1611
+ globals.push(...pluginGlobals);
1612
+ }
1613
+ return globals;
1614
+ }
1615
+ getAllFields() {
1616
+ const fields = [];
1617
+ for (const plugin of this.plugins.values()) {
1618
+ fields.push(...plugin.fields);
1619
+ }
1620
+ return fields;
1621
+ }
1622
+ getAdminComponents() {
1623
+ const components = {};
1624
+ for (const plugin of this.plugins.values()) {
1625
+ Object.assign(components, plugin.adminComponents);
1626
+ }
1627
+ return components;
1628
+ }
1629
+ getAdminStyles() {
1630
+ const styles = [];
1631
+ for (const plugin of this.plugins.values()) {
1632
+ styles.push(...plugin.adminStyles);
1633
+ }
1634
+ return styles;
1635
+ }
1636
+ };
1637
+ var SEOPLugin = class extends KyroPlugin {
1638
+ constructor() {
1639
+ super("seo");
1640
+ this.description = "Advanced SEO features including sitemaps, robots.txt, and structured data";
1641
+ this.collections.push({
1642
+ slug: "seo-settings",
1643
+ label: "SEO Settings",
1644
+ fields: [
1645
+ { name: "sitemap", type: "checkbox", label: "Enable Sitemap", defaultValue: true },
1646
+ { name: "robotsTxt", type: "textarea", label: "robots.txt Content" },
1647
+ { name: "canonicalUrl", type: "text", variant: "url", label: "Canonical URL" },
1648
+ { name: "ogImage", type: "text", label: "Default OG Image URL" }
1649
+ ]
1650
+ });
1651
+ }
1652
+ };
1653
+ var AnalyticsPlugin = class extends KyroPlugin {
1654
+ constructor() {
1655
+ super("analytics");
1656
+ this.description = "Analytics integration for tracking page views and events";
1657
+ this.collections.push({
1658
+ slug: "analytics-events",
1659
+ label: "Analytics Events",
1660
+ fields: [
1661
+ { name: "name", type: "text", required: true },
1662
+ { name: "properties", type: "json", label: "Event Properties" },
1663
+ { name: "timestamp", type: "date", required: true },
1664
+ { name: "userId", type: "text", label: "User ID" },
1665
+ { name: "sessionId", type: "text", label: "Session ID" }
1666
+ ]
1667
+ });
1668
+ this.adminComponents["AnalyticsDashboard"] = {};
1669
+ }
1670
+ };
1671
+ var CommentsPlugin = class extends KyroPlugin {
1672
+ constructor() {
1673
+ super("comments");
1674
+ this.description = "Commenting system for products and posts";
1675
+ this.collections.push({
1676
+ slug: "comments",
1677
+ label: "Comments",
1678
+ fields: [
1679
+ { name: "content", type: "textarea", required: true },
1680
+ { name: "author", type: "text", required: true },
1681
+ { name: "email", type: "email" },
1682
+ { name: "approved", type: "checkbox", defaultValue: false },
1683
+ { name: "parent", type: "text", label: "Parent Comment ID" },
1684
+ { name: "resourceType", type: "text", required: true },
1685
+ { name: "resourceId", type: "text", required: true }
1686
+ ]
1687
+ });
1688
+ this.adminComponents["CommentModeration"] = {};
1689
+ }
1690
+ };
1691
+ var ReviewsPlugin = class extends KyroPlugin {
1692
+ constructor() {
1693
+ super("reviews");
1694
+ this.description = "Product reviews and ratings";
1695
+ this.collections.push({
1696
+ slug: "reviews",
1697
+ label: "Reviews",
1698
+ fields: [
1699
+ { name: "rating", type: "number", required: true, min: 1, max: 5 },
1700
+ { name: "title", type: "text" },
1701
+ { name: "content", type: "textarea", required: true },
1702
+ { name: "author", type: "relationship", relationTo: "customers" },
1703
+ { name: "product", type: "relationship", relationTo: "products", required: true },
1704
+ { name: "approved", type: "checkbox", defaultValue: false },
1705
+ { name: "verified", type: "checkbox", label: "Verified Purchase" },
1706
+ { name: "helpful", type: "number", label: "Helpful Count", defaultValue: 0 }
1707
+ ]
1708
+ });
1709
+ this.adminComponents["ReviewModeration"] = {};
1710
+ }
1711
+ };
1712
+ var WishlistPlugin = class extends KyroPlugin {
1713
+ constructor() {
1714
+ super("wishlist");
1715
+ this.description = "Customer wishlists";
1716
+ this.collections.push({
1717
+ slug: "wishlists",
1718
+ label: "Wishlists",
1719
+ fields: [
1720
+ { name: "customer", type: "relationship", relationTo: "customers", required: true },
1721
+ { name: "name", type: "text", label: "Wishlist Name", defaultValue: "My Wishlist" },
1722
+ { name: "items", type: "blocks", label: "Items", blocks: [
1723
+ {
1724
+ slug: "wishlist-item",
1725
+ label: "Item",
1726
+ fields: [
1727
+ { name: "product", type: "relationship", relationTo: "products" },
1728
+ { name: "quantity", type: "number", defaultValue: 1 },
1729
+ { name: "addedAt", type: "date" },
1730
+ { name: "priority", type: "select", options: [
1731
+ { label: "Low", value: "low" },
1732
+ { label: "Medium", value: "medium" },
1733
+ { label: "High", value: "high" }
1734
+ ] }
1735
+ ]
1736
+ }
1737
+ ] }
1738
+ ]
1739
+ });
1740
+ }
1741
+ };
1742
+ var presetPlugins = {
1743
+ SEO: SEOPLugin,
1744
+ Analytics: AnalyticsPlugin,
1745
+ Comments: CommentsPlugin,
1746
+ Reviews: ReviewsPlugin,
1747
+ Wishlist: WishlistPlugin
1748
+ };
1749
+
1750
+ // src/styling/index.ts
1751
+ var CSSGenerator = class {
1752
+ constructor(config) {
1753
+ this.config = config;
1754
+ }
1755
+ config;
1756
+ css = [];
1757
+ addRule(selector, properties) {
1758
+ const props = Object.entries(properties).map(([k, v]) => ` ${k}: ${v};`).join("\n");
1759
+ this.css.push(`${selector} {
1760
+ ${props}
1761
+ }`);
1762
+ return this;
1763
+ }
1764
+ addMediaQuery(breakpoint, rules) {
1765
+ this.css.push(`@media (min-width: ${breakpoint}) {
1766
+ ${rules.join("\n ")}
1767
+ }`);
1768
+ return this;
1769
+ }
1770
+ generate() {
1771
+ return this.css.join("\n\n");
1772
+ }
1773
+ };
1774
+ function generateTailwindConfig(theme) {
1775
+ return {
1776
+ theme: {
1777
+ extend: {
1778
+ colors: theme.colors || {},
1779
+ fontFamily: theme.fonts || {},
1780
+ spacing: theme.spacing || {},
1781
+ borderRadius: theme.borderRadius || {},
1782
+ boxShadow: theme.shadows || {},
1783
+ screens: theme.breakpoints || {}
1784
+ }
1785
+ }
1786
+ };
1787
+ }
1788
+ var defaultLightTheme = {
1789
+ colors: {
1790
+ primary: "#3b82f6",
1791
+ secondary: "#6366f1",
1792
+ accent: "#ec4899",
1793
+ background: "#ffffff",
1794
+ surface: "#f9fafb",
1795
+ text: "#111827",
1796
+ textMuted: "#6b7280",
1797
+ border: "#e5e7eb",
1798
+ error: "#ef4444",
1799
+ warning: "#f59e0b",
1800
+ success: "#10b981",
1801
+ info: "#3b82f6"
1802
+ },
1803
+ fonts: {
1804
+ sans: "system-ui, -apple-system, sans-serif",
1805
+ serif: "Georgia, serif",
1806
+ mono: "Menlo, monospace"
1807
+ },
1808
+ spacing: {
1809
+ xs: "0.25rem",
1810
+ sm: "0.5rem",
1811
+ md: "1rem",
1812
+ lg: "1.5rem",
1813
+ xl: "2rem",
1814
+ "2xl": "3rem",
1815
+ "3xl": "4rem"
1816
+ },
1817
+ borderRadius: {
1818
+ sm: "0.125rem",
1819
+ md: "0.375rem",
1820
+ lg: "0.5rem",
1821
+ xl: "0.75rem",
1822
+ full: "9999px"
1823
+ },
1824
+ shadows: {
1825
+ sm: "0 1px 2px 0 rgb(0 0 0 / 0.05)",
1826
+ md: "0 4px 6px -1px rgb(0 0 0 / 0.1)",
1827
+ lg: "0 10px 15px -3px rgb(0 0 0 / 0.1)",
1828
+ xl: "0 20px 25px -5px rgb(0 0 0 / 0.1)"
1829
+ }
1830
+ };
1831
+ var defaultDarkTheme = {
1832
+ colors: {
1833
+ primary: "#60a5fa",
1834
+ secondary: "#818cf8",
1835
+ accent: "#f472b6",
1836
+ background: "#111827",
1837
+ surface: "#1f2937",
1838
+ text: "#f9fafb",
1839
+ textMuted: "#9ca3af",
1840
+ border: "#374151",
1841
+ error: "#f87171",
1842
+ warning: "#fbbf24",
1843
+ success: "#34d399",
1844
+ info: "#60a5fa"
1845
+ },
1846
+ fonts: defaultLightTheme.fonts,
1847
+ spacing: defaultLightTheme.spacing,
1848
+ borderRadius: defaultLightTheme.borderRadius,
1849
+ shadows: {
1850
+ sm: "0 1px 2px 0 rgb(0 0 0 / 0.3)",
1851
+ md: "0 4px 6px -1px rgb(0 0 0 / 0.4)",
1852
+ lg: "0 10px 15px -3px rgb(0 0 0 / 0.5)",
1853
+ xl: "0 20px 25px -5px rgb(0 0 0 / 0.6)"
1854
+ }
1855
+ };
1856
+ var ecommerce2026Theme = {
1857
+ colors: {
1858
+ primary: "#FF6B35",
1859
+ secondary: "#1A1A2E",
1860
+ accent: "#16C79A",
1861
+ background: "#FFFFFF",
1862
+ surface: "#F8F9FA",
1863
+ text: "#1A1A2E",
1864
+ textMuted: "#6B7280",
1865
+ border: "#E5E7EB",
1866
+ error: "#EF4444",
1867
+ warning: "#F59E0B",
1868
+ success: "#16C79A",
1869
+ info: "#3B82F6"
1870
+ },
1871
+ fonts: {
1872
+ sans: '"Inter", "Satoshi", system-ui, sans-serif',
1873
+ serif: '"Playfair Display", Georgia, serif',
1874
+ mono: '"JetBrains Mono", monospace'
1875
+ },
1876
+ spacing: {
1877
+ xs: "0.125rem",
1878
+ sm: "0.25rem",
1879
+ md: "0.5rem",
1880
+ lg: "1rem",
1881
+ xl: "1.5rem",
1882
+ "2xl": "2rem",
1883
+ "3xl": "3rem",
1884
+ "4xl": "4rem"
1885
+ },
1886
+ borderRadius: {
1887
+ sm: "0",
1888
+ md: "0",
1889
+ lg: "0",
1890
+ xl: "0",
1891
+ full: "9999px"
1892
+ },
1893
+ shadows: {
1894
+ sm: "0 1px 2px rgba(0,0,0,0.05)",
1895
+ md: "0 4px 6px rgba(0,0,0,0.07)",
1896
+ lg: "0 10px 15px rgba(0,0,0,0.1)",
1897
+ xl: "0 20px 25px rgba(0,0,0,0.15)"
1898
+ }
1899
+ };
1900
+ function generateCSSVariables(theme) {
1901
+ const variables = [];
1902
+ if (theme.colors) {
1903
+ for (const [key, value] of Object.entries(theme.colors)) {
1904
+ variables.push(` --color-${key}: ${value};`);
1905
+ }
1906
+ }
1907
+ if (theme.fonts) {
1908
+ for (const [key, value] of Object.entries(theme.fonts)) {
1909
+ variables.push(` --font-${key}: ${value};`);
1910
+ }
1911
+ }
1912
+ if (theme.spacing) {
1913
+ for (const [key, value] of Object.entries(theme.spacing)) {
1914
+ variables.push(` --spacing-${key}: ${value};`);
1915
+ }
1916
+ }
1917
+ if (theme.borderRadius) {
1918
+ for (const [key, value] of Object.entries(theme.borderRadius)) {
1919
+ variables.push(` --radius-${key}: ${value};`);
1920
+ }
1921
+ }
1922
+ if (theme.shadows) {
1923
+ for (const [key, value] of Object.entries(theme.shadows)) {
1924
+ variables.push(` --shadow-${key}: ${value};`);
1925
+ }
1926
+ }
1927
+ return `:root {
1928
+ ${variables.join("\n")}
1929
+ }`;
1930
+ }
1931
+ function createAdminStyling(config) {
1932
+ const cssVars = generateCSSVariables(config.theme || defaultLightTheme);
1933
+ const componentStyles = [];
1934
+ if (config.componentOverrides) {
1935
+ for (const [selector, styles] of Object.entries(config.componentOverrides)) {
1936
+ const props = Object.entries(styles).map(([k, v]) => ` ${k}: ${v};`).join("\n");
1937
+ componentStyles.push(`${selector} {
1938
+ ${props}
1939
+ }`);
1940
+ }
1941
+ }
1942
+ return `
1943
+ ${cssVars}
1944
+ ${config.customStyles || ""}
1945
+ ${componentStyles.join("\n")}
1946
+ `;
1947
+ }
1948
+ var defaultFieldStyling = {
1949
+ text: {
1950
+ wrapper: { marginBottom: "var(--spacing-md)" },
1951
+ label: {
1952
+ display: "block",
1953
+ marginBottom: "var(--spacing-xs)",
1954
+ fontWeight: "500",
1955
+ color: "var(--color-text)"
1956
+ },
1957
+ input: {
1958
+ width: "100%",
1959
+ padding: "var(--spacing-sm) var(--spacing-md)",
1960
+ border: "1px solid var(--color-border)",
1961
+ borderRadius: "var(--radius-md)",
1962
+ fontSize: "0.875rem"
1963
+ },
1964
+ error: {
1965
+ color: "var(--color-error)",
1966
+ fontSize: "0.75rem",
1967
+ marginTop: "var(--spacing-xs)"
1968
+ }
1969
+ },
1970
+ number: {
1971
+ wrapper: { marginBottom: "var(--spacing-md)" },
1972
+ label: { display: "block", marginBottom: "var(--spacing-xs)", fontWeight: "500" },
1973
+ input: {
1974
+ width: "100%",
1975
+ padding: "var(--spacing-sm) var(--spacing-md)",
1976
+ border: "1px solid var(--color-border)",
1977
+ borderRadius: "var(--radius-md)"
1978
+ }
1979
+ },
1980
+ checkbox: {
1981
+ wrapper: { display: "flex", alignItems: "center", gap: "var(--spacing-sm)" },
1982
+ input: { width: "1rem", height: "1rem" },
1983
+ label: { cursor: "pointer" }
1984
+ },
1985
+ select: {
1986
+ wrapper: { marginBottom: "var(--spacing-md)" },
1987
+ input: {
1988
+ width: "100%",
1989
+ padding: "var(--spacing-sm) var(--spacing-md)",
1990
+ border: "1px solid var(--color-border)",
1991
+ borderRadius: "var(--radius-md)",
1992
+ backgroundColor: "white"
1993
+ }
1994
+ }
1995
+ };
1996
+ var DEFAULT_SALT_ROUNDS = 12;
1997
+ var DEFAULT_EXPIRES_IN = "24h";
1998
+ var DEFAULT_REFRESH_EXPIRES_IN = "7d";
1999
+ var Auth = class {
2000
+ adapter;
2001
+ config;
2002
+ constructor(adapter, config) {
2003
+ this.adapter = adapter;
2004
+ this.config = {
2005
+ secret: config.secret,
2006
+ expiresIn: config.expiresIn ?? DEFAULT_EXPIRES_IN,
2007
+ refreshExpiresIn: config.refreshExpiresIn ?? DEFAULT_REFRESH_EXPIRES_IN,
2008
+ issuer: config.issuer ?? "kyro-cms",
2009
+ audience: config.audience ?? [],
2010
+ saltRounds: config.saltRounds ?? DEFAULT_SALT_ROUNDS
2011
+ };
2012
+ }
2013
+ async register(data) {
2014
+ try {
2015
+ const existing = await this.adapter.findUserByEmail(data.email);
2016
+ if (existing) {
2017
+ return { success: false, error: "Email already registered" };
2018
+ }
2019
+ const passwordHash = await this.hashPassword(data.password);
2020
+ const user = await this.adapter.createUser({
2021
+ email: data.email,
2022
+ passwordHash,
2023
+ role: data.role ?? "customer",
2024
+ tenant: data.tenant
2025
+ });
2026
+ return this.createSessionForUser(user);
2027
+ } catch (error) {
2028
+ return { success: false, error: String(error) };
2029
+ }
2030
+ }
2031
+ async login(credentials) {
2032
+ try {
2033
+ const user = await this.adapter.findUserByEmail(credentials.email);
2034
+ if (!user || !user.passwordHash) {
2035
+ return { success: false, error: "Invalid credentials" };
2036
+ }
2037
+ const valid = await this.adapter.verifyPassword(
2038
+ credentials.password,
2039
+ user.passwordHash
2040
+ );
2041
+ if (!valid) {
2042
+ return { success: false, error: "Invalid credentials" };
2043
+ }
2044
+ return this.createSessionForUser(user);
2045
+ } catch (error) {
2046
+ return { success: false, error: String(error) };
2047
+ }
2048
+ }
2049
+ async logout(token) {
2050
+ await this.adapter.deleteSession(token);
2051
+ }
2052
+ async refreshToken(refreshToken) {
2053
+ try {
2054
+ const session = await this.adapter.findSessionByToken(refreshToken);
2055
+ if (!session || session.expiresAt < /* @__PURE__ */ new Date()) {
2056
+ return { success: false, error: "Invalid or expired refresh token" };
2057
+ }
2058
+ const user = await this.adapter.findUserById(session.userId);
2059
+ if (!user) {
2060
+ return { success: false, error: "User not found" };
2061
+ }
2062
+ await this.adapter.deleteSession(refreshToken);
2063
+ return this.createSessionForUser(user);
2064
+ } catch (error) {
2065
+ return { success: false, error: String(error) };
2066
+ }
2067
+ }
2068
+ async verifyToken(token) {
2069
+ try {
2070
+ const decoded = jwt__default.default.verify(token, this.config.secret, {
2071
+ issuer: this.config.issuer,
2072
+ audience: this.config.audience.length > 0 ? this.config.audience[0] : void 0
2073
+ });
2074
+ return decoded;
2075
+ } catch {
2076
+ return null;
2077
+ }
2078
+ }
2079
+ async getUserFromToken(token) {
2080
+ const payload = await this.verifyToken(token);
2081
+ if (!payload) return null;
2082
+ return this.adapter.findUserById(payload.sub);
2083
+ }
2084
+ async changePassword(userId, currentPassword, newPassword) {
2085
+ try {
2086
+ const user = await this.adapter.findUserById(userId);
2087
+ if (!user || !user.passwordHash) {
2088
+ return { success: false, error: "User not found" };
2089
+ }
2090
+ const valid = await this.adapter.verifyPassword(
2091
+ currentPassword,
2092
+ user.passwordHash
2093
+ );
2094
+ if (!valid) {
2095
+ return { success: false, error: "Current password is incorrect" };
2096
+ }
2097
+ const newHash = await this.hashPassword(newPassword);
2098
+ await this.adapter.updateUser(userId, { passwordHash: newHash });
2099
+ await this.adapter.deleteUserSessions(userId);
2100
+ return { success: true, user };
2101
+ } catch (error) {
2102
+ return { success: false, error: String(error) };
2103
+ }
2104
+ }
2105
+ async resetPassword(email, newPassword) {
2106
+ try {
2107
+ const user = await this.adapter.findUserByEmail(email);
2108
+ if (!user) {
2109
+ return { success: false, error: "User not found" };
2110
+ }
2111
+ const passwordHash = await this.hashPassword(newPassword);
2112
+ await this.adapter.updateUser(user.id, { passwordHash });
2113
+ await this.adapter.deleteUserSessions(user.id);
2114
+ return { success: true, user };
2115
+ } catch (error) {
2116
+ return { success: false, error: String(error) };
2117
+ }
2118
+ }
2119
+ async deleteAccount(userId) {
2120
+ try {
2121
+ const user = await this.adapter.findUserById(userId);
2122
+ if (!user) {
2123
+ return { success: false, error: "User not found" };
2124
+ }
2125
+ await this.adapter.deleteUserSessions(userId);
2126
+ await this.adapter.deleteUser(userId);
2127
+ return { success: true };
2128
+ } catch (error) {
2129
+ return { success: false, error: String(error) };
2130
+ }
2131
+ }
2132
+ async createSessionForUser(user) {
2133
+ const token = this.generateToken(user);
2134
+ const refreshToken = crypto.randomUUID();
2135
+ const expiresAt = new Date(Date.now() + this.parseExpiresIn(this.config.refreshExpiresIn));
2136
+ const session = await this.adapter.createSession(user.id, refreshToken, expiresAt);
2137
+ return {
2138
+ success: true,
2139
+ user,
2140
+ session,
2141
+ token
2142
+ };
2143
+ }
2144
+ generateToken(user) {
2145
+ const payload = {
2146
+ sub: user.id,
2147
+ email: user.email,
2148
+ role: user.role,
2149
+ tenant: user.tenant
2150
+ };
2151
+ const signOptions = {
2152
+ expiresIn: this.parseExpiresIn(this.config.expiresIn) / 1e3,
2153
+ issuer: this.config.issuer
2154
+ };
2155
+ if (this.config.audience.length > 0) {
2156
+ signOptions.audience = this.config.audience[0];
2157
+ }
2158
+ return jwt__default.default.sign(payload, this.config.secret, signOptions);
2159
+ }
2160
+ async hashPassword(password) {
2161
+ return bcrypt__default.default.hash(password, this.config.saltRounds);
2162
+ }
2163
+ parseExpiresIn(value) {
2164
+ if (typeof value === "number") return value;
2165
+ const match = value.match(/^(\d+)([smhd])$/);
2166
+ if (!match) return 864e5;
2167
+ const num = parseInt(match[1], 10);
2168
+ switch (match[2]) {
2169
+ case "s":
2170
+ return num * 1e3;
2171
+ case "m":
2172
+ return num * 6e4;
2173
+ case "h":
2174
+ return num * 36e5;
2175
+ case "d":
2176
+ return num * 864e5;
2177
+ default:
2178
+ return 864e5;
2179
+ }
2180
+ }
2181
+ };
2182
+ function createAuth(adapter, config) {
2183
+ return new Auth(adapter, config);
2184
+ }
2185
+
2186
+ // src/versions/types.ts
2187
+ function getDefaultDraftPublishConfig() {
2188
+ return {
2189
+ enabled: true,
2190
+ draftsEnabled: true,
2191
+ publishEnabled: true,
2192
+ scheduleEnabled: false,
2193
+ versioningEnabled: true,
2194
+ maxVersionsPerDocument: 50,
2195
+ autoPublish: false,
2196
+ requirePublishPermission: true
2197
+ };
2198
+ }
2199
+
2200
+ // src/versions/index.ts
2201
+ var VersionManager = class {
2202
+ adapter;
2203
+ config;
2204
+ constructor(adapter, config) {
2205
+ this.adapter = adapter;
2206
+ this.config = { ...getDefaultDraftPublishConfig(), ...config };
2207
+ }
2208
+ async createVersion(options) {
2209
+ const latestVersion = await this.adapter.getLatestVersion(options.collection, options.documentId);
2210
+ const nextVersion = (latestVersion?.version ?? 0) + 1;
2211
+ const versionOptions = {
2212
+ ...options,
2213
+ version: nextVersion
2214
+ };
2215
+ const version = await this.adapter.createVersion(versionOptions);
2216
+ if (this.config.maxVersionsPerDocument > 0) {
2217
+ await this.pruneOldVersions(options.collection, options.documentId);
2218
+ }
2219
+ return version;
2220
+ }
2221
+ async publishVersion(options) {
2222
+ const version = await this.adapter.getVersion(options.collection, options.versionId);
2223
+ if (!version) {
2224
+ throw new Error("Version not found");
2225
+ }
2226
+ if (version.status === "published") {
2227
+ throw new Error("Version is already published");
2228
+ }
2229
+ await this.adapter.publishVersion(options);
2230
+ }
2231
+ async unpublishDocument(collection, documentId) {
2232
+ const versions = await this.adapter.getVersions({
2233
+ collection,
2234
+ documentId,
2235
+ limit: 1e3
2236
+ });
2237
+ for (const version of versions) {
2238
+ if (version.status === "published") {
2239
+ await this.createVersion({
2240
+ collection,
2241
+ documentId,
2242
+ data: version.data,
2243
+ status: "draft",
2244
+ createdBy: "system",
2245
+ changeDescription: "Unpublished document"
2246
+ });
2247
+ break;
2248
+ }
2249
+ }
2250
+ }
2251
+ async revertToVersion(collection, documentId, versionId, userId) {
2252
+ const targetVersion = await this.adapter.getVersion(collection, versionId);
2253
+ if (!targetVersion) {
2254
+ throw new Error("Version not found");
2255
+ }
2256
+ const newVersion = await this.adapter.revertToVersion({
2257
+ collection,
2258
+ documentId,
2259
+ versionId,
2260
+ userId
2261
+ });
2262
+ return newVersion;
2263
+ }
2264
+ async getVersionHistory(collection, documentId, limit = 20, offset = 0) {
2265
+ return this.adapter.getVersions({
2266
+ collection,
2267
+ documentId,
2268
+ limit,
2269
+ offset
2270
+ });
2271
+ }
2272
+ async compareTwoVersions(collection, documentId, versionA, versionB) {
2273
+ return this.adapter.compareVersions({
2274
+ collection,
2275
+ documentId,
2276
+ versionA,
2277
+ versionB
2278
+ });
2279
+ }
2280
+ async getLatestDraft(collection, documentId) {
2281
+ return this.adapter.getLatestVersion(collection, documentId);
2282
+ }
2283
+ async getPublishedVersion(collection, documentId) {
2284
+ return this.adapter.getPublishedVersion(collection, documentId);
2285
+ }
2286
+ async getVersion(collection, versionId) {
2287
+ return this.adapter.getVersion(collection, versionId);
2288
+ }
2289
+ async schedulePublish(collection, documentId, versionId, scheduledFor) {
2290
+ if (!this.config.scheduleEnabled) {
2291
+ throw new Error("Scheduled publishing is not enabled");
2292
+ }
2293
+ const version = await this.adapter.getVersion(collection, versionId);
2294
+ if (!version) {
2295
+ throw new Error("Version not found");
2296
+ }
2297
+ }
2298
+ async deleteVersionHistory(collection, documentId) {
2299
+ await this.adapter.deleteVersions(collection, documentId);
2300
+ }
2301
+ async pruneOldVersions(collection, documentId) {
2302
+ const versions = await this.adapter.getVersions({
2303
+ collection,
2304
+ documentId,
2305
+ limit: this.config.maxVersionsPerDocument + 100
2306
+ });
2307
+ if (versions.length <= this.config.maxVersionsPerDocument) {
2308
+ return;
2309
+ }
2310
+ versions.slice(0, this.config.maxVersionsPerDocument);
2311
+ const versionsToDelete = versions.slice(this.config.maxVersionsPerDocument);
2312
+ for (const version of versionsToDelete) {
2313
+ if (version.status !== "published") {
2314
+ await this.adapter.deleteVersions(collection, documentId);
2315
+ break;
2316
+ }
2317
+ }
2318
+ }
2319
+ };
2320
+ function createVersionManager(adapter, config) {
2321
+ return new VersionManager(adapter, config);
2322
+ }
2323
+ function isPublished(status) {
2324
+ return status === "published";
2325
+ }
2326
+ function isDraft(status) {
2327
+ return status === "draft";
2328
+ }
2329
+ function isArchived(status) {
2330
+ return status === "archived";
2331
+ }
2332
+
2333
+ Object.defineProperty(exports, "createContext", {
2334
+ enumerable: true,
2335
+ get: function () { return chunk3VZCX4DF_cjs.createContext; }
2336
+ });
2337
+ Object.defineProperty(exports, "createCountProcedure", {
2338
+ enumerable: true,
2339
+ get: function () { return chunk3VZCX4DF_cjs.createCountProcedure; }
2340
+ });
2341
+ Object.defineProperty(exports, "createCreateProcedure", {
2342
+ enumerable: true,
2343
+ get: function () { return chunk3VZCX4DF_cjs.createCreateProcedure; }
2344
+ });
2345
+ Object.defineProperty(exports, "createDeleteProcedure", {
2346
+ enumerable: true,
2347
+ get: function () { return chunk3VZCX4DF_cjs.createDeleteProcedure; }
2348
+ });
2349
+ Object.defineProperty(exports, "createDynamicRouter", {
2350
+ enumerable: true,
2351
+ get: function () { return chunk3VZCX4DF_cjs.createDynamicRouter; }
2352
+ });
2353
+ Object.defineProperty(exports, "createFindByIDProcedure", {
2354
+ enumerable: true,
2355
+ get: function () { return chunk3VZCX4DF_cjs.createFindByIDProcedure; }
2356
+ });
2357
+ Object.defineProperty(exports, "createFindProcedure", {
2358
+ enumerable: true,
2359
+ get: function () { return chunk3VZCX4DF_cjs.createFindProcedure; }
2360
+ });
2361
+ Object.defineProperty(exports, "createKyroServer", {
2362
+ enumerable: true,
2363
+ get: function () { return chunk3VZCX4DF_cjs.createKyroServer; }
2364
+ });
2365
+ Object.defineProperty(exports, "createUpdateProcedure", {
2366
+ enumerable: true,
2367
+ get: function () { return chunk3VZCX4DF_cjs.createUpdateProcedure; }
2368
+ });
2369
+ Object.defineProperty(exports, "buildGraphQLSchema", {
2370
+ enumerable: true,
2371
+ get: function () { return chunkK7QF2QCM_cjs.buildGraphQLSchema; }
2372
+ });
2373
+ Object.defineProperty(exports, "createGraphQLSchema", {
2374
+ enumerable: true,
2375
+ get: function () { return chunkK7QF2QCM_cjs.createGraphQLSchema; }
2376
+ });
2377
+ Object.defineProperty(exports, "createHonoApp", {
2378
+ enumerable: true,
2379
+ get: function () { return chunkUEG7KMKC_cjs.createHonoApp; }
2380
+ });
2381
+ Object.defineProperty(exports, "createRESTAPI", {
2382
+ enumerable: true,
2383
+ get: function () { return chunkUEG7KMKC_cjs.createRESTAPI; }
2384
+ });
2385
+ Object.defineProperty(exports, "evaluateAccess", {
2386
+ enumerable: true,
2387
+ get: function () { return chunkR3XIBBAW_cjs.evaluateAccess; }
2388
+ });
2389
+ Object.defineProperty(exports, "getWhereClause", {
2390
+ enumerable: true,
2391
+ get: function () { return chunkR3XIBBAW_cjs.getWhereClause; }
2392
+ });
2393
+ Object.defineProperty(exports, "mergeWhereClauses", {
2394
+ enumerable: true,
2395
+ get: function () { return chunkR3XIBBAW_cjs.mergeWhereClauses; }
2396
+ });
2397
+ Object.defineProperty(exports, "KyroPubSub", {
2398
+ enumerable: true,
2399
+ get: function () { return chunkDVD5P72E_cjs.KyroPubSub; }
2400
+ });
2401
+ Object.defineProperty(exports, "KyroWSServer", {
2402
+ enumerable: true,
2403
+ get: function () { return chunkDVD5P72E_cjs.KyroWSServer; }
2404
+ });
2405
+ Object.defineProperty(exports, "PubSub", {
2406
+ enumerable: true,
2407
+ get: function () { return chunkDVD5P72E_cjs.PubSub; }
2408
+ });
2409
+ Object.defineProperty(exports, "createWSServer", {
2410
+ enumerable: true,
2411
+ get: function () { return chunkDVD5P72E_cjs.createWSServer; }
2412
+ });
2413
+ Object.defineProperty(exports, "DrizzleAdapter", {
2414
+ enumerable: true,
2415
+ get: function () { return chunk3Q3FS5J4_cjs.DrizzleAdapter; }
2416
+ });
2417
+ Object.defineProperty(exports, "collectionToDrizzleSchema", {
2418
+ enumerable: true,
2419
+ get: function () { return chunk3Q3FS5J4_cjs.collectionToDrizzleSchema; }
2420
+ });
2421
+ Object.defineProperty(exports, "createDrizzleAdapter", {
2422
+ enumerable: true,
2423
+ get: function () { return chunk3Q3FS5J4_cjs.createDrizzleAdapter; }
2424
+ });
2425
+ Object.defineProperty(exports, "fieldToDrizzleType", {
2426
+ enumerable: true,
2427
+ get: function () { return chunk3Q3FS5J4_cjs.fieldToDrizzleType; }
2428
+ });
2429
+ Object.defineProperty(exports, "MongoDBAdapter", {
2430
+ enumerable: true,
2431
+ get: function () { return chunkHT6VE4NW_cjs.MongoDBAdapter; }
2432
+ });
2433
+ Object.defineProperty(exports, "createMongoDBAdapter", {
2434
+ enumerable: true,
2435
+ get: function () { return chunkHT6VE4NW_cjs.createMongoDBAdapter; }
2436
+ });
2437
+ Object.defineProperty(exports, "AbstractBaseAdapter", {
2438
+ enumerable: true,
2439
+ get: function () { return chunkRLTG4YZM_cjs.AbstractBaseAdapter; }
2440
+ });
2441
+ Object.defineProperty(exports, "z", {
2442
+ enumerable: true,
2443
+ get: function () { return zod.z; }
2444
+ });
2445
+ exports.ALL_FIELD_TYPES = ALL_FIELD_TYPES;
2446
+ exports.AnalyticsPlugin = AnalyticsPlugin;
2447
+ exports.Auth = Auth;
2448
+ exports.COMPLEX_FIELD_TYPES = COMPLEX_FIELD_TYPES;
2449
+ exports.CSSGenerator = CSSGenerator;
2450
+ exports.CommentsPlugin = CommentsPlugin;
2451
+ exports.ConfigValidationError = ConfigValidationError;
2452
+ exports.Kyro = Kyro;
2453
+ exports.KyroPlugin = KyroPlugin;
2454
+ exports.LAYOUT_FIELD_TYPES = LAYOUT_FIELD_TYPES;
2455
+ exports.LocalAdapter = LocalAdapter;
2456
+ exports.PRIMITIVE_FIELD_TYPES = PRIMITIVE_FIELD_TYPES;
2457
+ exports.PluginManager = PluginManager;
2458
+ exports.RELATIONAL_FIELD_TYPES = RELATIONAL_FIELD_TYPES;
2459
+ exports.Registry = Registry;
2460
+ exports.ReviewsPlugin = ReviewsPlugin;
2461
+ exports.SEOPLugin = SEOPLugin;
2462
+ exports.VersionManager = VersionManager;
2463
+ exports.WishlistPlugin = WishlistPlugin;
2464
+ exports.collectionToCreateZod = collectionToCreateZod;
2465
+ exports.collectionToUpdateZod = collectionToUpdateZod;
2466
+ exports.collectionToWhereZod = collectionToWhereZod;
2467
+ exports.collectionToZod = collectionToZod;
2468
+ exports.createAdminStyling = createAdminStyling;
2469
+ exports.createAuth = createAuth;
2470
+ exports.createKyro = createKyro;
2471
+ exports.createLocalAdapter = createLocalAdapter;
2472
+ exports.createRegistry = createRegistry;
2473
+ exports.createVersionManager = createVersionManager;
2474
+ exports.defaultDarkTheme = defaultDarkTheme;
2475
+ exports.defaultFieldStyling = defaultFieldStyling;
2476
+ exports.defaultLightTheme = defaultLightTheme;
2477
+ exports.ecommerce2026Theme = ecommerce2026Theme;
2478
+ exports.fieldToZod = fieldToZod;
2479
+ exports.generateCSSVariables = generateCSSVariables;
2480
+ exports.generateTailwindConfig = generateTailwindConfig;
2481
+ exports.getDefaultDraftPublishConfig = getDefaultDraftPublishConfig;
2482
+ exports.getRegistry = getRegistry;
2483
+ exports.globalToZod = globalToZod;
2484
+ exports.isArchived = isArchived;
2485
+ exports.isArrayField = isArrayField;
2486
+ exports.isBlocksField = isBlocksField;
2487
+ exports.isDraft = isDraft;
2488
+ exports.isGroupField = isGroupField;
2489
+ exports.isLayoutField = isLayoutField;
2490
+ exports.isNumberField = isNumberField;
2491
+ exports.isPublished = isPublished;
2492
+ exports.isRelationshipField = isRelationshipField;
2493
+ exports.isRichTextField = isRichTextField;
2494
+ exports.isSelectField = isSelectField;
2495
+ exports.isTextField = isTextField;
2496
+ exports.isUploadField = isUploadField;
2497
+ exports.presetPlugins = presetPlugins;
2498
+ exports.resetRegistry = resetRegistry;
2499
+ exports.runFieldHooks = runFieldHooks;
2500
+ exports.runHooks = runHooks;
2501
+ exports.validateCollection = validateCollection;
2502
+ exports.validateConfig = validateConfig;
2503
+ exports.validateFields = validateFields;
2504
+ exports.validateGlobal = validateGlobal;
2505
+ //# sourceMappingURL=index.cjs.map
2506
+ //# sourceMappingURL=index.cjs.map