nextly 0.0.2-alpha.0 → 0.0.2-alpha.2

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 (74) hide show
  1. package/README.md +1 -1
  2. package/dist/_dts-chunks/{collections-handler.d-DjgO74Wt.d.ts → collections-handler.d-nXHXeVJG.d.ts} +7 -2
  3. package/dist/_dts-chunks/{config.d-DNwsDnjs.d.ts → config.d-CWOwFVLW.d.ts} +1 -1
  4. package/dist/_dts-chunks/{define-component.d-BUgTHmt3.d.ts → define-component.d-DptZZAGj.d.ts} +2 -2
  5. package/dist/_dts-chunks/{index.d-axCAzZ7m.d.ts → index.d-DutLjyet.d.ts} +1 -1
  6. package/dist/actions/index.mjs +7 -7
  7. package/dist/api/auth-state.mjs +13 -13
  8. package/dist/api/collections-schema-detail.mjs +13 -13
  9. package/dist/api/collections-schema-export.mjs +13 -13
  10. package/dist/api/collections-schema.mjs +13 -13
  11. package/dist/api/components-detail.mjs +13 -13
  12. package/dist/api/components.mjs +13 -13
  13. package/dist/api/email-providers-default.mjs +13 -13
  14. package/dist/api/email-providers-detail.mjs +13 -13
  15. package/dist/api/email-providers-test.mjs +13 -13
  16. package/dist/api/email-providers.mjs +13 -13
  17. package/dist/api/email-send-template.mjs +14 -14
  18. package/dist/api/email-send.mjs +14 -14
  19. package/dist/api/email-templates-detail.mjs +13 -13
  20. package/dist/api/email-templates-layout.mjs +13 -13
  21. package/dist/api/email-templates-preview.mjs +13 -13
  22. package/dist/api/email-templates.mjs +13 -13
  23. package/dist/api/media-bulk.mjs +9 -9
  24. package/dist/api/media-folders.mjs +13 -13
  25. package/dist/api/media-handlers.d.ts +2 -2
  26. package/dist/api/media-handlers.mjs +13 -13
  27. package/dist/api/media.mjs +13 -13
  28. package/dist/api/singles-detail.mjs +13 -13
  29. package/dist/api/singles-schema-detail.mjs +13 -13
  30. package/dist/api/singles.mjs +13 -13
  31. package/dist/api/storage-upload-url.mjs +13 -13
  32. package/dist/api/uploads.mjs +13 -13
  33. package/dist/{boot-apply-PQSYLDIN.mjs → boot-apply-XAPSV4FE.mjs} +1 -1
  34. package/dist/{chunk-B2GV2BWH.mjs → chunk-23ZZHDSW.mjs} +2 -2
  35. package/dist/{chunk-O3QHXMOX.mjs → chunk-3F7O5UEU.mjs} +9 -9
  36. package/dist/{chunk-R6JJQHFC.mjs → chunk-5EZ2DIN7.mjs} +1 -1
  37. package/dist/{chunk-LDKCUMHK.mjs → chunk-DGIKWO5B.mjs} +1 -1
  38. package/dist/{chunk-YV4Y7SDL.mjs → chunk-EXOKW4X3.mjs} +1 -1
  39. package/dist/{chunk-UOP63Q54.mjs → chunk-IRXVQ57E.mjs} +1 -1
  40. package/dist/{chunk-AK6Z23OX.mjs → chunk-IU7BK3OH.mjs} +2 -2
  41. package/dist/{chunk-SBACDPNX.mjs → chunk-J4KHGYOM.mjs} +148 -26
  42. package/dist/{chunk-GZ6DCQKC.mjs → chunk-JWAH6ROD.mjs} +5 -3
  43. package/dist/{chunk-YZNBLFIW.mjs → chunk-KP7YBKPO.mjs} +1 -1
  44. package/dist/{chunk-DNNG377Z.mjs → chunk-L5FA2FAY.mjs} +76 -13
  45. package/dist/{chunk-XZKLBMN6.mjs → chunk-LP2CDTCR.mjs} +43 -15
  46. package/dist/{chunk-NSEFNNU4.mjs → chunk-LPCXH5IV.mjs} +49 -26
  47. package/dist/{chunk-XGI4EMS3.mjs → chunk-NYUB4YDK.mjs} +3 -3
  48. package/dist/{chunk-P7NH2OSC.mjs → chunk-PDFDT5CD.mjs} +6 -6
  49. package/dist/{chunk-VJ66NCL4.mjs → chunk-SKPLPSPW.mjs} +1 -1
  50. package/dist/{chunk-2OALJTK6.mjs → chunk-TT45EN5O.mjs} +5 -5
  51. package/dist/{chunk-IZWPRDC3.mjs → chunk-UB4CALU5.mjs} +1 -1
  52. package/dist/{chunk-PKMABBB5.mjs → chunk-VRFDQ3GL.mjs} +1 -1
  53. package/dist/{chunk-X7TXCYYN.mjs → chunk-XL4TY4AR.mjs} +10 -10
  54. package/dist/cli/nextly.mjs +1 -1
  55. package/dist/cli/utils/index.d.ts +2 -2
  56. package/dist/config.d.ts +3 -3
  57. package/dist/database/index.d.ts +2 -2
  58. package/dist/database/seeders/index.mjs +10 -10
  59. package/dist/{dynamic-collection-schema-service-IEXTPIZ7.mjs → dynamic-collection-schema-service-KMOP5PGD.mjs} +1 -1
  60. package/dist/index.d.ts +6 -6
  61. package/dist/index.mjs +14 -14
  62. package/dist/{permissions-3DZZQZMI.mjs → permissions-RNFFU67D.mjs} +8 -8
  63. package/dist/{pipeline-YOML7SWF.mjs → pipeline-M2RINZTN.mjs} +6 -6
  64. package/dist/{preview-ZZTR3QGS.mjs → preview-H6CJBMCP.mjs} +3 -3
  65. package/dist/{program-PW6UB2ZC.mjs → program-DLLB26JU.mjs} +14 -14
  66. package/dist/{register-SF6E6FVU.mjs → register-5DT3GACU.mjs} +9 -9
  67. package/dist/{reload-config-HWQ4G5MM.mjs → reload-config-4V5ZG2UQ.mjs} +6 -6
  68. package/dist/{routeHandler-UNMMJIBM.mjs → routeHandler-M4WVJSN5.mjs} +16 -16
  69. package/dist/{runtime-schema-generator-NRA6A6Z6.mjs → runtime-schema-generator-MOPQWGJP.mjs} +2 -2
  70. package/dist/runtime.d.ts +2 -2
  71. package/dist/runtime.mjs +16 -16
  72. package/dist/{super-admin-G5ZK5F4T.mjs → super-admin-MNQYIXGL.mjs} +8 -8
  73. package/dist/{users-7KELGRYJ.mjs → users-YEB4FVCR.mjs} +7 -7
  74. package/package.json +8 -8
@@ -3,16 +3,16 @@ import {
3
3
  } from "../chunk-TO5AFLVQ.mjs";
4
4
  import {
5
5
  getCachedNextly
6
- } from "../chunk-P7NH2OSC.mjs";
7
- import "../chunk-2OALJTK6.mjs";
8
- import "../chunk-VJ66NCL4.mjs";
9
- import "../chunk-R6JJQHFC.mjs";
6
+ } from "../chunk-PDFDT5CD.mjs";
7
+ import "../chunk-TT45EN5O.mjs";
8
+ import "../chunk-SKPLPSPW.mjs";
9
+ import "../chunk-5EZ2DIN7.mjs";
10
10
  import "../chunk-X23WKS3Z.mjs";
11
11
  import {
12
12
  getService,
13
13
  isServicesRegistered
14
- } from "../chunk-X7TXCYYN.mjs";
15
- import "../chunk-YZNBLFIW.mjs";
14
+ } from "../chunk-XL4TY4AR.mjs";
15
+ import "../chunk-KP7YBKPO.mjs";
16
16
  import "../chunk-FQULBZ53.mjs";
17
17
  import "../chunk-67GXH6PR.mjs";
18
18
  import "../chunk-2TFX4ND3.mjs";
@@ -20,20 +20,20 @@ import "../chunk-W4MGXIRR.mjs";
20
20
  import {
21
21
  UploadService,
22
22
  clampLimit2 as clampLimit
23
- } from "../chunk-NSEFNNU4.mjs";
23
+ } from "../chunk-LPCXH5IV.mjs";
24
24
  import "../chunk-3FA7FKAV.mjs";
25
25
  import "../chunk-AGJ6F2T3.mjs";
26
26
  import "../chunk-KIMNCZGV.mjs";
27
- import "../chunk-AK6Z23OX.mjs";
27
+ import "../chunk-IU7BK3OH.mjs";
28
28
  import "../chunk-INV7QKLG.mjs";
29
- import "../chunk-GZ6DCQKC.mjs";
30
- import "../chunk-SBACDPNX.mjs";
29
+ import "../chunk-JWAH6ROD.mjs";
30
+ import "../chunk-J4KHGYOM.mjs";
31
31
  import "../chunk-RJLLGGPG.mjs";
32
32
  import "../chunk-V4EQTOA4.mjs";
33
33
  import "../chunk-I4JMR3UR.mjs";
34
- import "../chunk-XZKLBMN6.mjs";
35
- import "../chunk-IZWPRDC3.mjs";
36
- import "../chunk-DNNG377Z.mjs";
34
+ import "../chunk-LP2CDTCR.mjs";
35
+ import "../chunk-UB4CALU5.mjs";
36
+ import "../chunk-L5FA2FAY.mjs";
37
37
  import "../chunk-5HMZ644B.mjs";
38
38
  import "../chunk-W5KKPZT5.mjs";
39
39
  import "../chunk-56WO4WX7.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runBootTimeApplyIfDev
3
- } from "./chunk-R6JJQHFC.mjs";
3
+ } from "./chunk-5EZ2DIN7.mjs";
4
4
  import "./chunk-7P6ASYW6.mjs";
5
5
  export {
6
6
  runBootTimeApplyIfDev
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  seedPermissions
3
- } from "./chunk-UOP63Q54.mjs";
3
+ } from "./chunk-IRXVQ57E.mjs";
4
4
  import {
5
5
  seedSuperAdmin
6
- } from "./chunk-PKMABBB5.mjs";
6
+ } from "./chunk-VRFDQ3GL.mjs";
7
7
 
8
8
  // src/database/seeders/index.ts
9
9
  async function seedAll(adapter, options) {
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-A3WPLSDT.mjs";
4
4
  import {
5
5
  POST
6
- } from "./chunk-YV4Y7SDL.mjs";
6
+ } from "./chunk-EXOKW4X3.mjs";
7
7
  import {
8
8
  readJsonBody
9
9
  } from "./chunk-VQJQHVEV.mjs";
10
10
  import {
11
11
  POST as POST2
12
- } from "./chunk-LDKCUMHK.mjs";
12
+ } from "./chunk-DGIKWO5B.mjs";
13
13
  import {
14
14
  createJsonErrorResponse,
15
15
  isErrorResponse,
@@ -45,12 +45,12 @@ import {
45
45
  import {
46
46
  ensureHmrListener,
47
47
  getCachedNextly
48
- } from "./chunk-P7NH2OSC.mjs";
48
+ } from "./chunk-PDFDT5CD.mjs";
49
49
  import {
50
50
  getService,
51
51
  isServicesRegistered,
52
52
  registerServices
53
- } from "./chunk-X7TXCYYN.mjs";
53
+ } from "./chunk-XL4TY4AR.mjs";
54
54
  import {
55
55
  readOrGenerateRequestId
56
56
  } from "./chunk-67GXH6PR.mjs";
@@ -61,7 +61,7 @@ import {
61
61
  ImageSizeService,
62
62
  ServiceDispatcher,
63
63
  parseWhereQuery
64
- } from "./chunk-NSEFNNU4.mjs";
64
+ } from "./chunk-LPCXH5IV.mjs";
65
65
  import {
66
66
  containsSuperAdminRole,
67
67
  hasSuperAdminExcluding,
@@ -2154,8 +2154,8 @@ function buildAuthRouterDeps(getService2) {
2154
2154
  }
2155
2155
  },
2156
2156
  createSuperAdmin: async (data) => {
2157
- const { seedPermissions } = await import("./permissions-3DZZQZMI.mjs");
2158
- const { seedSuperAdmin } = await import("./super-admin-G5ZK5F4T.mjs");
2157
+ const { seedPermissions } = await import("./permissions-RNFFU67D.mjs");
2158
+ const { seedSuperAdmin } = await import("./super-admin-MNQYIXGL.mjs");
2159
2159
  const adapter = getService2("adapter");
2160
2160
  await seedPermissions(adapter, { silent: true });
2161
2161
  const result = await seedSuperAdmin(adapter, {
@@ -2180,7 +2180,7 @@ function buildAuthRouterDeps(getService2) {
2180
2180
  };
2181
2181
  },
2182
2182
  seedPermissions: async () => {
2183
- const { seedPermissions } = await import("./permissions-3DZZQZMI.mjs");
2183
+ const { seedPermissions } = await import("./permissions-RNFFU67D.mjs");
2184
2184
  const adapter = getService2("adapter");
2185
2185
  await seedPermissions(adapter, { silent: true });
2186
2186
  },
@@ -2392,7 +2392,7 @@ async function ensureServicesInitialized() {
2392
2392
  } else {
2393
2393
  console.log("[Auth Handler] Services auto-initialized with defaults");
2394
2394
  }
2395
- const { runBootTimeApplyIfDev } = await import("./boot-apply-PQSYLDIN.mjs");
2395
+ const { runBootTimeApplyIfDev } = await import("./boot-apply-XAPSV4FE.mjs");
2396
2396
  await runBootTimeApplyIfDev({ caller: "auth-handler" });
2397
2397
  ensureHmrListener();
2398
2398
  }
@@ -5,7 +5,7 @@ async function runBootTimeApplyIfDev(opts) {
5
5
  if (process.env.NEXTLY_DISABLE_BOOT_APPLY === "1") return;
6
6
  const label = callerLabel(opts?.caller);
7
7
  try {
8
- const { reloadNextlyConfig } = await import("./reload-config-HWQ4G5MM.mjs");
8
+ const { reloadNextlyConfig } = await import("./reload-config-4V5ZG2UQ.mjs");
9
9
  await reloadNextlyConfig();
10
10
  } catch (err) {
11
11
  const msg = err instanceof Error ? err.message : String(err);
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-TO5AFLVQ.mjs";
12
12
  import {
13
13
  getCachedNextly
14
- } from "./chunk-P7NH2OSC.mjs";
14
+ } from "./chunk-PDFDT5CD.mjs";
15
15
  import {
16
16
  respondAction
17
17
  } from "./chunk-IUDOC7N7.mjs";
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-TO5AFLVQ.mjs";
12
12
  import {
13
13
  getCachedNextly
14
- } from "./chunk-P7NH2OSC.mjs";
14
+ } from "./chunk-PDFDT5CD.mjs";
15
15
  import {
16
16
  respondAction
17
17
  } from "./chunk-IUDOC7N7.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CreatePermissionSchema,
3
3
  ServiceContainer
4
- } from "./chunk-NSEFNNU4.mjs";
4
+ } from "./chunk-LPCXH5IV.mjs";
5
5
 
6
6
  // src/database/seeders/permissions.ts
7
7
  var RESOURCES = ["users", "roles", "permissions"];
@@ -5,13 +5,13 @@ import {
5
5
  countRows,
6
6
  diffSnapshots,
7
7
  introspectLiveSnapshot
8
- } from "./chunk-SBACDPNX.mjs";
8
+ } from "./chunk-J4KHGYOM.mjs";
9
9
  import {
10
10
  ComponentSchemaService
11
11
  } from "./chunk-V4EQTOA4.mjs";
12
12
  import {
13
13
  generateRuntimeSchema
14
- } from "./chunk-IZWPRDC3.mjs";
14
+ } from "./chunk-UB4CALU5.mjs";
15
15
  import {
16
16
  getDialectTables
17
17
  } from "./chunk-TS7GHTG2.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getColumnDescriptor,
3
3
  getSystemColumnDescriptors
4
- } from "./chunk-DNNG377Z.mjs";
4
+ } from "./chunk-L5FA2FAY.mjs";
5
5
 
6
6
  // src/domains/schema/pipeline/classifier/count-helpers.ts
7
7
  import { sql } from "drizzle-orm";
@@ -236,7 +236,9 @@ function buildDesiredTableFromFields(tableName, fields, dialect, options = {}) {
236
236
  name: reserved.name,
237
237
  type: reserved.dialectType,
238
238
  nullable: reserved.nullable,
239
- default: void 0
239
+ // Forward descriptor default so the classifier doesn't flag status as
240
+ // `add_required_field_no_default` and require TTY confirmation.
241
+ default: reserved.default
240
242
  });
241
243
  }
242
244
  for (const field of fields) {
@@ -261,26 +263,116 @@ function buildDesiredTableFromFields(tableName, fields, dialect, options = {}) {
261
263
  function buildDesiredTableFromComponentFields(tableName, fields, dialect) {
262
264
  const columns = [];
263
265
  if (dialect === "postgresql") {
264
- columns.push({ name: "id", type: "text", nullable: false, default: void 0 });
265
- columns.push({ name: "_parent_id", type: "text", nullable: false, default: void 0 });
266
- columns.push({ name: "_parent_table", type: "varchar", nullable: false, default: void 0 });
267
- columns.push({ name: "_parent_field", type: "varchar", nullable: false, default: void 0 });
268
- columns.push({ name: "_order", type: "int4", nullable: true, default: void 0 });
269
- columns.push({ name: "_component_type", type: "varchar", nullable: true, default: void 0 });
266
+ columns.push({
267
+ name: "id",
268
+ type: "text",
269
+ nullable: false,
270
+ default: void 0
271
+ });
272
+ columns.push({
273
+ name: "_parent_id",
274
+ type: "text",
275
+ nullable: false,
276
+ default: void 0
277
+ });
278
+ columns.push({
279
+ name: "_parent_table",
280
+ type: "varchar",
281
+ nullable: false,
282
+ default: void 0
283
+ });
284
+ columns.push({
285
+ name: "_parent_field",
286
+ type: "varchar",
287
+ nullable: false,
288
+ default: void 0
289
+ });
290
+ columns.push({
291
+ name: "_order",
292
+ type: "int4",
293
+ nullable: true,
294
+ default: void 0
295
+ });
296
+ columns.push({
297
+ name: "_component_type",
298
+ type: "varchar",
299
+ nullable: true,
300
+ default: void 0
301
+ });
270
302
  } else if (dialect === "mysql") {
271
- columns.push({ name: "id", type: "varchar(36)", nullable: false, default: void 0 });
272
- columns.push({ name: "_parent_id", type: "varchar(36)", nullable: false, default: void 0 });
273
- columns.push({ name: "_parent_table", type: "varchar(255)", nullable: false, default: void 0 });
274
- columns.push({ name: "_parent_field", type: "varchar(255)", nullable: false, default: void 0 });
275
- columns.push({ name: "_order", type: "int(11)", nullable: true, default: void 0 });
276
- columns.push({ name: "_component_type", type: "varchar(255)", nullable: true, default: void 0 });
303
+ columns.push({
304
+ name: "id",
305
+ type: "varchar(36)",
306
+ nullable: false,
307
+ default: void 0
308
+ });
309
+ columns.push({
310
+ name: "_parent_id",
311
+ type: "varchar(36)",
312
+ nullable: false,
313
+ default: void 0
314
+ });
315
+ columns.push({
316
+ name: "_parent_table",
317
+ type: "varchar(255)",
318
+ nullable: false,
319
+ default: void 0
320
+ });
321
+ columns.push({
322
+ name: "_parent_field",
323
+ type: "varchar(255)",
324
+ nullable: false,
325
+ default: void 0
326
+ });
327
+ columns.push({
328
+ name: "_order",
329
+ type: "int(11)",
330
+ nullable: true,
331
+ default: void 0
332
+ });
333
+ columns.push({
334
+ name: "_component_type",
335
+ type: "varchar(255)",
336
+ nullable: true,
337
+ default: void 0
338
+ });
277
339
  } else {
278
- columns.push({ name: "id", type: "text", nullable: false, default: void 0 });
279
- columns.push({ name: "_parent_id", type: "text", nullable: false, default: void 0 });
280
- columns.push({ name: "_parent_table", type: "text", nullable: false, default: void 0 });
281
- columns.push({ name: "_parent_field", type: "text", nullable: false, default: void 0 });
282
- columns.push({ name: "_order", type: "integer", nullable: true, default: void 0 });
283
- columns.push({ name: "_component_type", type: "text", nullable: true, default: void 0 });
340
+ columns.push({
341
+ name: "id",
342
+ type: "text",
343
+ nullable: false,
344
+ default: void 0
345
+ });
346
+ columns.push({
347
+ name: "_parent_id",
348
+ type: "text",
349
+ nullable: false,
350
+ default: void 0
351
+ });
352
+ columns.push({
353
+ name: "_parent_table",
354
+ type: "text",
355
+ nullable: false,
356
+ default: void 0
357
+ });
358
+ columns.push({
359
+ name: "_parent_field",
360
+ type: "text",
361
+ nullable: false,
362
+ default: void 0
363
+ });
364
+ columns.push({
365
+ name: "_order",
366
+ type: "integer",
367
+ nullable: true,
368
+ default: void 0
369
+ });
370
+ columns.push({
371
+ name: "_component_type",
372
+ type: "text",
373
+ nullable: true,
374
+ default: void 0
375
+ });
284
376
  }
285
377
  for (const field of fields) {
286
378
  const desc = getColumnDescriptor(
@@ -296,14 +388,44 @@ function buildDesiredTableFromComponentFields(tableName, fields, dialect) {
296
388
  });
297
389
  }
298
390
  if (dialect === "postgresql") {
299
- columns.push({ name: "created_at", type: "timestamp", nullable: false, default: void 0 });
300
- columns.push({ name: "updated_at", type: "timestamp", nullable: false, default: void 0 });
391
+ columns.push({
392
+ name: "created_at",
393
+ type: "timestamp",
394
+ nullable: false,
395
+ default: void 0
396
+ });
397
+ columns.push({
398
+ name: "updated_at",
399
+ type: "timestamp",
400
+ nullable: false,
401
+ default: void 0
402
+ });
301
403
  } else if (dialect === "mysql") {
302
- columns.push({ name: "created_at", type: "datetime", nullable: false, default: void 0 });
303
- columns.push({ name: "updated_at", type: "datetime", nullable: false, default: void 0 });
404
+ columns.push({
405
+ name: "created_at",
406
+ type: "datetime",
407
+ nullable: false,
408
+ default: void 0
409
+ });
410
+ columns.push({
411
+ name: "updated_at",
412
+ type: "datetime",
413
+ nullable: false,
414
+ default: void 0
415
+ });
304
416
  } else {
305
- columns.push({ name: "created_at", type: "integer", nullable: false, default: void 0 });
306
- columns.push({ name: "updated_at", type: "integer", nullable: false, default: void 0 });
417
+ columns.push({
418
+ name: "created_at",
419
+ type: "integer",
420
+ nullable: false,
421
+ default: void 0
422
+ });
423
+ columns.push({
424
+ name: "updated_at",
425
+ type: "integer",
426
+ nullable: false,
427
+ default: void 0
428
+ });
307
429
  }
308
430
  return { name: tableName, columns };
309
431
  }
@@ -7,7 +7,7 @@ import {
7
7
  countRows,
8
8
  diffSnapshots,
9
9
  introspectLiveSnapshot
10
- } from "./chunk-SBACDPNX.mjs";
10
+ } from "./chunk-J4KHGYOM.mjs";
11
11
 
12
12
  // src/domains/schema/pipeline/preview.ts
13
13
  async function previewDesiredSchema(args, deps = {}) {
@@ -25,14 +25,16 @@ async function previewDesiredSchema(args, deps = {}) {
25
25
  (c) => buildDesiredTableFromFields(
26
26
  c.tableName,
27
27
  c.fields,
28
- dialect
28
+ dialect,
29
+ { hasStatus: c.status === true }
29
30
  )
30
31
  );
31
32
  const singleTables = Object.values(desired.singles).map(
32
33
  (s) => buildDesiredTableFromFields(
33
34
  s.tableName,
34
35
  s.fields,
35
- dialect
36
+ dialect,
37
+ { hasStatus: s.status === true }
36
38
  )
37
39
  );
38
40
  const componentTables = Object.values(desired.components).map(
@@ -5,7 +5,7 @@ import {
5
5
  PermissionService,
6
6
  RolePermissionService,
7
7
  SYSTEM_RESOURCES
8
- } from "./chunk-NSEFNNU4.mjs";
8
+ } from "./chunk-LPCXH5IV.mjs";
9
9
  import {
10
10
  BaseRegistryService,
11
11
  assertGlobalResourceSlugAvailable
@@ -122,17 +122,48 @@ function lengthForKind(kind) {
122
122
  function getSystemColumnDescriptors(dialect, opts) {
123
123
  const cols = [];
124
124
  if (dialect === "postgresql") {
125
- cols.push({ name: "id", dialectType: "text", nullable: false, primaryKey: true });
125
+ cols.push({
126
+ name: "id",
127
+ dialectType: "text",
128
+ nullable: false,
129
+ primaryKey: true
130
+ });
126
131
  if (!opts.hasTitleField) {
127
- cols.push({ name: "title", dialectType: "text", nullable: false, primaryKey: false });
132
+ cols.push({
133
+ name: "title",
134
+ dialectType: "text",
135
+ nullable: false,
136
+ primaryKey: false
137
+ });
128
138
  }
129
139
  if (!opts.hasSlugField) {
130
- cols.push({ name: "slug", dialectType: "text", nullable: false, primaryKey: false });
140
+ cols.push({
141
+ name: "slug",
142
+ dialectType: "text",
143
+ nullable: false,
144
+ primaryKey: false
145
+ });
131
146
  }
132
- cols.push({ name: "created_at", dialectType: "timestamp", nullable: true, primaryKey: false });
133
- cols.push({ name: "updated_at", dialectType: "timestamp", nullable: true, primaryKey: false });
147
+ cols.push({
148
+ name: "created_at",
149
+ dialectType: "timestamp",
150
+ nullable: true,
151
+ primaryKey: false
152
+ });
153
+ cols.push({
154
+ name: "updated_at",
155
+ dialectType: "timestamp",
156
+ nullable: true,
157
+ primaryKey: false
158
+ });
134
159
  if (opts.hasStatus) {
135
- cols.push({ name: "status", dialectType: "text", nullable: false, primaryKey: false });
160
+ cols.push({
161
+ name: "status",
162
+ dialectType: "text",
163
+ nullable: false,
164
+ primaryKey: false,
165
+ default: "'draft'"
166
+ });
136
167
  }
137
168
  } else if (dialect === "mysql") {
138
169
  cols.push({
@@ -178,21 +209,53 @@ function getSystemColumnDescriptors(dialect, opts) {
178
209
  dialectType: "varchar(20)",
179
210
  length: 20,
180
211
  nullable: false,
181
- primaryKey: false
212
+ primaryKey: false,
213
+ default: "'draft'"
182
214
  });
183
215
  }
184
216
  } else {
185
- cols.push({ name: "id", dialectType: "text", nullable: false, primaryKey: true });
217
+ cols.push({
218
+ name: "id",
219
+ dialectType: "text",
220
+ nullable: false,
221
+ primaryKey: true
222
+ });
186
223
  if (!opts.hasTitleField) {
187
- cols.push({ name: "title", dialectType: "text", nullable: false, primaryKey: false });
224
+ cols.push({
225
+ name: "title",
226
+ dialectType: "text",
227
+ nullable: false,
228
+ primaryKey: false
229
+ });
188
230
  }
189
231
  if (!opts.hasSlugField) {
190
- cols.push({ name: "slug", dialectType: "text", nullable: false, primaryKey: false });
232
+ cols.push({
233
+ name: "slug",
234
+ dialectType: "text",
235
+ nullable: false,
236
+ primaryKey: false
237
+ });
191
238
  }
192
- cols.push({ name: "created_at", dialectType: "integer", nullable: true, primaryKey: false });
193
- cols.push({ name: "updated_at", dialectType: "integer", nullable: true, primaryKey: false });
239
+ cols.push({
240
+ name: "created_at",
241
+ dialectType: "integer",
242
+ nullable: true,
243
+ primaryKey: false
244
+ });
245
+ cols.push({
246
+ name: "updated_at",
247
+ dialectType: "integer",
248
+ nullable: true,
249
+ primaryKey: false
250
+ });
194
251
  if (opts.hasStatus) {
195
- cols.push({ name: "status", dialectType: "text", nullable: false, primaryKey: false });
252
+ cols.push({
253
+ name: "status",
254
+ dialectType: "text",
255
+ nullable: false,
256
+ primaryKey: false,
257
+ default: "'draft'"
258
+ });
196
259
  }
197
260
  }
198
261
  return cols;
@@ -336,14 +336,20 @@ var DynamicCollectionSchemaService = class {
336
336
  }).filter(Boolean).join(",\n");
337
337
  const allColumnDefs = [];
338
338
  if (this.dialect === "mysql") {
339
- allColumnDefs.push(` ${this.quoteIdentifier("id")} varchar(36) PRIMARY KEY NOT NULL`);
339
+ allColumnDefs.push(
340
+ ` ${this.quoteIdentifier("id")} varchar(36) PRIMARY KEY NOT NULL`
341
+ );
340
342
  } else {
341
- allColumnDefs.push(` ${this.quoteIdentifier("id")} text PRIMARY KEY NOT NULL`);
343
+ allColumnDefs.push(
344
+ ` ${this.quoteIdentifier("id")} text PRIMARY KEY NOT NULL`
345
+ );
342
346
  }
343
347
  const hasTitleField = fields.some((f) => f.name === "title");
344
348
  if (!hasTitleField) {
345
349
  if (this.dialect === "mysql") {
346
- allColumnDefs.push(` ${this.quoteIdentifier("title")} varchar(255) NOT NULL`);
350
+ allColumnDefs.push(
351
+ ` ${this.quoteIdentifier("title")} varchar(255) NOT NULL`
352
+ );
347
353
  } else {
348
354
  allColumnDefs.push(` ${this.quoteIdentifier("title")} text NOT NULL`);
349
355
  }
@@ -351,7 +357,9 @@ var DynamicCollectionSchemaService = class {
351
357
  const hasSlugField = fields.some((f) => f.name === "slug");
352
358
  if (!hasSlugField) {
353
359
  if (this.dialect === "mysql") {
354
- allColumnDefs.push(` ${this.quoteIdentifier("slug")} varchar(255) NOT NULL`);
360
+ allColumnDefs.push(
361
+ ` ${this.quoteIdentifier("slug")} varchar(255) NOT NULL`
362
+ );
355
363
  } else {
356
364
  allColumnDefs.push(` ${this.quoteIdentifier("slug")} text NOT NULL`);
357
365
  }
@@ -375,20 +383,34 @@ var DynamicCollectionSchemaService = class {
375
383
  }
376
384
  }
377
385
  if (checks.length > 0) {
378
- allColumnDefs.push(` CONSTRAINT ${this.quoteIdentifier(`chk_${tableName}_validation`)} CHECK (${checks.join(" AND ")})`);
386
+ allColumnDefs.push(
387
+ ` CONSTRAINT ${this.quoteIdentifier(`chk_${tableName}_validation`)} CHECK (${checks.join(" AND ")})`
388
+ );
379
389
  }
380
390
  for (const c of constraints) {
381
391
  allColumnDefs.push(c);
382
392
  }
383
393
  if (this.dialect === "sqlite") {
384
- allColumnDefs.push(` ${this.quoteIdentifier("created_at")} integer DEFAULT (strftime('%s', 'now')) NOT NULL`);
385
- allColumnDefs.push(` ${this.quoteIdentifier("updated_at")} integer DEFAULT (strftime('%s', 'now')) NOT NULL`);
394
+ allColumnDefs.push(
395
+ ` ${this.quoteIdentifier("created_at")} integer DEFAULT (strftime('%s', 'now')) NOT NULL`
396
+ );
397
+ allColumnDefs.push(
398
+ ` ${this.quoteIdentifier("updated_at")} integer DEFAULT (strftime('%s', 'now')) NOT NULL`
399
+ );
386
400
  } else if (this.dialect === "mysql") {
387
- allColumnDefs.push(` ${this.quoteIdentifier("created_at")} timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL`);
388
- allColumnDefs.push(` ${this.quoteIdentifier("updated_at")} timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL`);
401
+ allColumnDefs.push(
402
+ ` ${this.quoteIdentifier("created_at")} timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL`
403
+ );
404
+ allColumnDefs.push(
405
+ ` ${this.quoteIdentifier("updated_at")} timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL`
406
+ );
389
407
  } else {
390
- allColumnDefs.push(` ${this.quoteIdentifier("created_at")} timestamp DEFAULT now() NOT NULL`);
391
- allColumnDefs.push(` ${this.quoteIdentifier("updated_at")} timestamp DEFAULT now() NOT NULL`);
408
+ allColumnDefs.push(
409
+ ` ${this.quoteIdentifier("created_at")} timestamp DEFAULT now() NOT NULL`
410
+ );
411
+ allColumnDefs.push(
412
+ ` ${this.quoteIdentifier("updated_at")} timestamp DEFAULT now() NOT NULL`
413
+ );
392
414
  }
393
415
  let sql = `-- Create dynamic collection: ${tableName}
394
416
  CREATE TABLE IF NOT EXISTS ${this.quoteIdentifier(tableName)} (
@@ -478,7 +500,7 @@ ${allColumnDefs.join(",\n")}
478
500
  statements.push(
479
501
  `ALTER TABLE ${this.quoteIdentifier(tableName)} ADD COLUMN ${this.quoteIdentifier("status")} ${statusType} DEFAULT 'draft' NOT NULL;`
480
502
  );
481
- } else if (wasStatus && !hasStatus) {
503
+ } else if (wasStatus && options?.hasStatus === false) {
482
504
  statements.push(
483
505
  `ALTER TABLE ${this.quoteIdentifier(tableName)} DROP COLUMN ${this.quoteIdentifier("status")};`
484
506
  );
@@ -679,9 +701,12 @@ ${allColumnDefs.join(",\n")}
679
701
  return true;
680
702
  }
681
703
  /**
682
- * Generate TypeScript/Drizzle schema code for a collection
704
+ * Generate TypeScript/Drizzle schema code for a collection. Pass
705
+ * `hasStatus: true` for Draft/Published collections so the generated
706
+ * file includes the `status` column — without it, `drizzle-kit
707
+ * pushSchema` later sees the live `status` column as extra and drops it.
683
708
  */
684
- generateSchemaCode(tableName, collectionName, fields) {
709
+ generateSchemaCode(tableName, collectionName, fields, options) {
685
710
  const dialectConfig = this.getDialectConfig();
686
711
  const jsonbFieldTypes = [
687
712
  "json",
@@ -750,6 +775,9 @@ import { relations } from 'drizzle-orm';`;
750
775
  const allIndexes = fieldIndexes ? ` createdAtIdx: index('idx_${tableName}_created_at').on(table.createdAt),
751
776
  ${fieldIndexes}` : ` createdAtIdx: index('idx_${tableName}_created_at').on(table.createdAt),`;
752
777
  const timestampColumns = this.generateTimestampColumnsForDialect();
778
+ const statusColumn = options?.hasStatus ? this.dialect === "sqlite" ? ` status: text('status').notNull().default('draft'),
779
+ ` : ` status: varchar('status', { length: 20 }).notNull().default('draft'),
780
+ ` : "";
753
781
  return `${imports}
754
782
 
755
783
  /**
@@ -761,7 +789,7 @@ export const ${tableName} = ${dialectConfig.tableFunction}('${tableName}', {
761
789
  title: text('title').notNull(),
762
790
  slug: text('slug').notNull(),
763
791
  ${columns}
764
- ${timestampColumns}
792
+ ${statusColumn}${timestampColumns}
765
793
  }, (table) => ({
766
794
  slugIdx: uniqueIndex('idx_${tableName}_slug').on(table.slug),
767
795
  ${allIndexes}