nextly 0.0.2-alpha.7 → 0.0.2-alpha.8

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 (99) hide show
  1. package/dist/_dts-chunks/{index.d-CknEcQSu.d.ts → index.d-BhMtxT6M.d.ts} +4 -4
  2. package/dist/actions/index.mjs +16 -16
  3. package/dist/api/auth-state.mjs +23 -23
  4. package/dist/api/collections-schema-detail.mjs +23 -23
  5. package/dist/api/collections-schema-export.mjs +23 -23
  6. package/dist/api/collections-schema.mjs +24 -24
  7. package/dist/api/components-detail.mjs +24 -24
  8. package/dist/api/components.mjs +24 -24
  9. package/dist/api/email-providers-default.mjs +24 -24
  10. package/dist/api/email-providers-detail.mjs +25 -25
  11. package/dist/api/email-providers-test.mjs +25 -25
  12. package/dist/api/email-providers.mjs +26 -26
  13. package/dist/api/email-send-template.mjs +26 -26
  14. package/dist/api/email-send.mjs +26 -26
  15. package/dist/api/email-templates-detail.mjs +25 -25
  16. package/dist/api/email-templates-layout.mjs +25 -25
  17. package/dist/api/email-templates-preview.mjs +26 -26
  18. package/dist/api/email-templates.mjs +26 -26
  19. package/dist/api/health.mjs +2 -2
  20. package/dist/api/index.mjs +2 -2
  21. package/dist/api/media-bulk.mjs +20 -20
  22. package/dist/api/media-folders.mjs +24 -24
  23. package/dist/api/media-handlers.mjs +25 -25
  24. package/dist/api/media.mjs +25 -25
  25. package/dist/api/singles-detail.mjs +25 -25
  26. package/dist/api/singles-schema-detail.mjs +24 -24
  27. package/dist/api/singles.mjs +23 -23
  28. package/dist/api/storage-upload-url.mjs +24 -24
  29. package/dist/api/uploads.mjs +23 -23
  30. package/dist/auth/index.mjs +7 -7
  31. package/dist/{boot-apply-5EFSWAMW.mjs → boot-apply-NOFBZ5QY.mjs} +1 -1
  32. package/dist/{chunk-UB4CALU5.mjs → chunk-2QSGNGOB.mjs} +1 -1
  33. package/dist/{chunk-DP3G27G5.mjs → chunk-35LAHTCU.mjs} +12 -2
  34. package/dist/{chunk-KSKKIZDP.mjs → chunk-3IX2NDII.mjs} +4 -4
  35. package/dist/{chunk-3NUAFSDX.mjs → chunk-44JO5BSR.mjs} +1 -1
  36. package/dist/{chunk-L5FA2FAY.mjs → chunk-463A2UDH.mjs} +6 -3
  37. package/dist/{chunk-JXZITQPZ.mjs → chunk-4HUQNXVM.mjs} +1 -1
  38. package/dist/{chunk-NRUWQ5Z7.mjs → chunk-5WWWJCKI.mjs} +3 -5
  39. package/dist/{chunk-SSRCS4NR.mjs → chunk-7KXJ66OR.mjs} +5 -5
  40. package/dist/{chunk-L3SZUFF4.mjs → chunk-7PLW6Z3L.mjs} +1 -1
  41. package/dist/{chunk-LP2CDTCR.mjs → chunk-A75OLKXP.mjs} +1 -1
  42. package/dist/{chunk-D72XH3BG.mjs → chunk-ERJGWWPB.mjs} +2 -2
  43. package/dist/{chunk-UJ2IMJ4W.mjs → chunk-HREB7UR4.mjs} +10 -4
  44. package/dist/{chunk-66ZNVKTF.mjs → chunk-HSIAXEYF.mjs} +274 -45
  45. package/dist/{chunk-QOH5I67F.mjs → chunk-JAOH2TTZ.mjs} +3 -3
  46. package/dist/{chunk-J4KHGYOM.mjs → chunk-JCQMC6HH.mjs} +69 -2
  47. package/dist/{chunk-EBDAFQUX.mjs → chunk-KTGUSU23.mjs} +2 -2
  48. package/dist/{chunk-M52VMPGA.mjs → chunk-KZFYCMBL.mjs} +1 -1
  49. package/dist/{chunk-LPVOTXNV.mjs → chunk-LDUSTBVC.mjs} +1 -1
  50. package/dist/{chunk-FQH647CT.mjs → chunk-NJ3LXLSJ.mjs} +53 -4
  51. package/dist/{chunk-CLBPXLO3.mjs → chunk-NJIUNZVY.mjs} +27 -23
  52. package/dist/{chunk-INV7QKLG.mjs → chunk-PAWMG5BR.mjs} +1 -1
  53. package/dist/{chunk-RKXTA5KC.mjs → chunk-PDMNLA74.mjs} +79 -50
  54. package/dist/{chunk-2W3DVD7S.mjs → chunk-PFRMIEJ3.mjs} +1 -1
  55. package/dist/{chunk-HVH4J6S6.mjs → chunk-QIGAYTZD.mjs} +21 -21
  56. package/dist/{chunk-WZBYMYVW.mjs → chunk-QPYR3TC4.mjs} +1 -1
  57. package/dist/{chunk-ZVN3JILF.mjs → chunk-QSE7KMHI.mjs} +18 -18
  58. package/dist/{chunk-NAP3TDS6.mjs → chunk-SWVNFKWD.mjs} +2 -2
  59. package/dist/{chunk-RNKZALZE.mjs → chunk-TSFCJP57.mjs} +5 -5
  60. package/dist/{chunk-JWAH6ROD.mjs → chunk-TVG3WU6C.mjs} +1 -1
  61. package/dist/{chunk-7YKKCBOC.mjs → chunk-V2W7G5GC.mjs} +3 -3
  62. package/dist/{chunk-TK76W55J.mjs → chunk-X3OHQBMZ.mjs} +6 -2
  63. package/dist/{chunk-TO5AFLVQ.mjs → chunk-XIKEJO27.mjs} +1 -1
  64. package/dist/{chunk-MWW7OUDL.mjs → chunk-XYV27NZL.mjs} +23 -43
  65. package/dist/{chunk-ZE6A3FYH.mjs → chunk-YG2HSZC4.mjs} +1 -1
  66. package/dist/{chunk-VQJQHVEV.mjs → chunk-YLRZTPSK.mjs} +1 -1
  67. package/dist/{chunk-TS7GHTG2.mjs → chunk-YXZH65YV.mjs} +2 -2
  68. package/dist/{chunk-GJNSJU4S.mjs → chunk-Z52OQOZH.mjs} +1 -1
  69. package/dist/cli/nextly.mjs +1 -1
  70. package/dist/cli/utils/index.mjs +3 -3
  71. package/dist/{component-schema-service-JOQIBQGK.mjs → component-schema-service-HUAQQ4H5.mjs} +2 -2
  72. package/dist/{config-loader-23YEMC3Z.mjs → config-loader-MUFY6UMU.mjs} +2 -2
  73. package/dist/database/index.d.ts +1 -1
  74. package/dist/database/index.mjs +4 -4
  75. package/dist/database/seeders/index.mjs +19 -19
  76. package/dist/{db-sync-demote-Z2HOXRZN.mjs → db-sync-demote-2DAQZXLD.mjs} +8 -8
  77. package/dist/{db-sync-promote-FKWZSRYC.mjs → db-sync-promote-SBTPSUEJ.mjs} +7 -7
  78. package/dist/{dynamic-collection-schema-service-KMOP5PGD.mjs → dynamic-collection-schema-service-FIRWOXZI.mjs} +2 -2
  79. package/dist/errors/index.d.ts +2 -0
  80. package/dist/errors/index.mjs +1 -1
  81. package/dist/{factory-IWMBKUJM.mjs → factory-UGJGOZZ7.mjs} +2 -2
  82. package/dist/index.d.ts +1 -1
  83. package/dist/index.mjs +23 -23
  84. package/dist/observability/index.mjs +1 -1
  85. package/dist/{permissions-YZSSFHU4.mjs → permissions-ONWRZAQO.mjs} +17 -17
  86. package/dist/{pipeline-2DWG7LSN.mjs → pipeline-URL33V42.mjs} +11 -11
  87. package/dist/{preview-H6CJBMCP.mjs → preview-3RSMZITY.mjs} +3 -3
  88. package/dist/{program-CEFDADQM.mjs → program-DWF3GBYR.mjs} +29 -29
  89. package/dist/{register-G6I4N6QM.mjs → register-CQU3Z4SW.mjs} +18 -18
  90. package/dist/reload-config-RWRAPMQG.mjs +23 -0
  91. package/dist/{routeHandler-ROBRMRZA.mjs → routeHandler-7JQSAJFL.mjs} +30 -30
  92. package/dist/{runtime-schema-generator-MOPQWGJP.mjs → runtime-schema-generator-NQOLDUDG.mjs} +2 -2
  93. package/dist/runtime.mjs +30 -30
  94. package/dist/{super-admin-WSTXAZSS.mjs → super-admin-ZPB2YQDQ.mjs} +17 -17
  95. package/dist/{system-table-service-WGSRVEGT.mjs → system-table-service-FIX3AVKW.mjs} +6 -6
  96. package/dist/{users-NFD7IUFT.mjs → users-OA643XPO.mjs} +16 -16
  97. package/package.json +8 -8
  98. package/dist/reload-config-VUEIQP5W.mjs +0 -23
  99. /package/dist/{first-run-QIVKWJIF.mjs → first-run-2JTNWFEG.mjs} +0 -0
@@ -1,13 +1,16 @@
1
1
  import {
2
2
  PromptCancelledError,
3
3
  TTYRequiredError
4
- } from "./chunk-66ZNVKTF.mjs";
4
+ } from "./chunk-HSIAXEYF.mjs";
5
5
 
6
6
  // src/domains/schema/pipeline/prompt-dispatcher/clack-terminal.ts
7
7
  import * as clack from "@clack/prompts";
8
8
  function hasTTY() {
9
9
  return Boolean(process.stdin.isTTY && process.stdout.isTTY);
10
10
  }
11
+ function shouldAutoConfirmDrops() {
12
+ return process.env.NEXTLY_ALLOW_CODE_FIRST_DROPS === "1";
13
+ }
11
14
  var ClackTerminalPromptDispatcher = class {
12
15
  async dispatch(args) {
13
16
  const { candidates, events } = args;
@@ -16,9 +19,18 @@ var ClackTerminalPromptDispatcher = class {
16
19
  }
17
20
  if (!hasTTY()) {
18
21
  const renameSample = candidates.slice(0, 3).map((c) => `${c.fromColumn} -> ${c.toColumn} on ${c.tableName}`).join(", ");
19
- const eventSample = events.slice(0, 3).map(
20
- (e) => e.kind === "type_change" ? `type change on ${e.tableName}.${e.columnName} (${e.fromType} -> ${e.toType})` : `${e.kind === "add_not_null_with_nulls" ? "NOT NULL on" : "required field"} ${e.tableName}.${e.columnName}`
21
- ).join(", ");
22
+ const eventSample = events.slice(0, 3).map((e) => {
23
+ switch (e.kind) {
24
+ case "type_change":
25
+ return `type change on ${e.tableName}.${e.columnName} (${e.fromType} -> ${e.toType})`;
26
+ case "add_not_null_with_nulls":
27
+ return `NOT NULL on ${e.tableName}.${e.columnName}`;
28
+ case "add_required_field_no_default":
29
+ return `required field ${e.tableName}.${e.columnName}`;
30
+ case "destructive_drop":
31
+ return `drop column ${e.tableName}.${e.columnName} (${e.columnType}, ${e.tableRowCount} row(s))`;
32
+ }
33
+ }).join(", ");
22
34
  const parts = [];
23
35
  if (candidates.length > 0) {
24
36
  parts.push(`${candidates.length} rename candidate(s): ${renameSample}`);
@@ -54,8 +66,40 @@ ${parts.join("\n")}`
54
66
  return { resolutions: [], proceed: true };
55
67
  }
56
68
  const resolutions = [];
69
+ const autoConfirmDrops = shouldAutoConfirmDrops();
70
+ const allDestructiveDrops = events.every(
71
+ (e) => e.kind === "destructive_drop"
72
+ );
73
+ if (autoConfirmDrops && allDestructiveDrops) {
74
+ for (const event of events) {
75
+ if (event.kind !== "destructive_drop") continue;
76
+ resolutions.push({ kind: "confirm_drop", eventId: event.id });
77
+ }
78
+ return { resolutions, proceed: true };
79
+ }
57
80
  clack.intro("Schema change requires confirmation");
58
81
  for (const event of events) {
82
+ if (event.kind === "destructive_drop") {
83
+ clack.note(
84
+ `Type: ${event.columnType}
85
+ Rows affected: ${event.tableRowCount}`,
86
+ `Drop column "${event.tableName}.${event.columnName}"`
87
+ );
88
+ if (autoConfirmDrops) {
89
+ resolutions.push({ kind: "confirm_drop", eventId: event.id });
90
+ continue;
91
+ }
92
+ const proceed = await clack.confirm({
93
+ message: `Drop "${event.columnName}" from "${event.tableName}"?`,
94
+ initialValue: false
95
+ });
96
+ if (clack.isCancel(proceed) || proceed === false) {
97
+ clack.outro("Cancelled");
98
+ return { resolutions, proceed: false };
99
+ }
100
+ resolutions.push({ kind: "confirm_drop", eventId: event.id });
101
+ continue;
102
+ }
59
103
  if (event.kind === "type_change") {
60
104
  clack.note(
61
105
  [
@@ -82,6 +126,11 @@ ${event.nullCount} of ${event.tableRowCount} rows have NULL values.` : `New requ
82
126
  provide_default: "Provide a default value for empty rows",
83
127
  make_optional: "Make the field optional (cancel the NOT NULL)",
84
128
  delete_nonconforming: event.kind === "add_not_null_with_nulls" ? `Delete the ${event.nullCount} rows with empty values` : "Delete rows that violate the constraint",
129
+ // Unreachable for NOT-NULL kinds (destructive_drop never lists
130
+ // these resolutions in applicableResolutions), but Record<K,V>
131
+ // requires every key. The label only surfaces if a future event
132
+ // erroneously includes confirm_drop in its applicableResolutions.
133
+ confirm_drop: "Confirm the drop",
85
134
  abort: "Cancel everything"
86
135
  };
87
136
  const options = event.applicableResolutions.map((kind2) => ({
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  routeAuthRequest
3
- } from "./chunk-TK76W55J.mjs";
3
+ } from "./chunk-X3OHQBMZ.mjs";
4
4
  import {
5
5
  POST
6
- } from "./chunk-SSRCS4NR.mjs";
6
+ } from "./chunk-7KXJ66OR.mjs";
7
7
  import {
8
8
  readJsonBody
9
- } from "./chunk-VQJQHVEV.mjs";
9
+ } from "./chunk-YLRZTPSK.mjs";
10
10
  import {
11
11
  POST as POST2
12
- } from "./chunk-RNKZALZE.mjs";
12
+ } from "./chunk-TSFCJP57.mjs";
13
13
  import {
14
14
  createJsonErrorResponse,
15
15
  isErrorResponse,
@@ -18,10 +18,10 @@ import {
18
18
  requireCollectionAccess,
19
19
  requirePermission,
20
20
  toNextlyAuthError
21
- } from "./chunk-7YKKCBOC.mjs";
21
+ } from "./chunk-V2W7G5GC.mjs";
22
22
  import {
23
23
  nextlyValidationFromZod
24
- } from "./chunk-GJNSJU4S.mjs";
24
+ } from "./chunk-Z52OQOZH.mjs";
25
25
  import {
26
26
  getForegroundForBackground,
27
27
  hexToHslTriplet,
@@ -41,16 +41,16 @@ import {
41
41
  } from "./chunk-APKKRD2G.mjs";
42
42
  import {
43
43
  withErrorHandler
44
- } from "./chunk-TO5AFLVQ.mjs";
44
+ } from "./chunk-XIKEJO27.mjs";
45
45
  import {
46
46
  ensureHmrListener,
47
47
  getCachedNextly
48
- } from "./chunk-RKXTA5KC.mjs";
48
+ } from "./chunk-PDMNLA74.mjs";
49
49
  import {
50
50
  getService,
51
51
  isServicesRegistered,
52
52
  registerServices
53
- } from "./chunk-HVH4J6S6.mjs";
53
+ } from "./chunk-QIGAYTZD.mjs";
54
54
  import {
55
55
  readOrGenerateRequestId
56
56
  } from "./chunk-67GXH6PR.mjs";
@@ -61,20 +61,20 @@ import {
61
61
  ImageSizeService,
62
62
  ServiceDispatcher,
63
63
  parseWhereQuery
64
- } from "./chunk-ZVN3JILF.mjs";
64
+ } from "./chunk-QSE7KMHI.mjs";
65
65
  import {
66
66
  containsSuperAdminRole,
67
67
  hasSuperAdminExcluding,
68
68
  isSuperAdmin,
69
69
  listEffectivePermissions
70
- } from "./chunk-NAP3TDS6.mjs";
70
+ } from "./chunk-SWVNFKWD.mjs";
71
71
  import {
72
72
  BaseService,
73
73
  withTimezoneFormatting
74
- } from "./chunk-2W3DVD7S.mjs";
74
+ } from "./chunk-PFRMIEJ3.mjs";
75
75
  import {
76
76
  getDialectTables
77
- } from "./chunk-TS7GHTG2.mjs";
77
+ } from "./chunk-YXZH65YV.mjs";
78
78
  import {
79
79
  nextlyMigrationJournalMysql,
80
80
  nextlyMigrationJournalPg,
@@ -82,7 +82,7 @@ import {
82
82
  } from "./chunk-H26B4FYG.mjs";
83
83
  import {
84
84
  env
85
- } from "./chunk-UJ2IMJ4W.mjs";
85
+ } from "./chunk-HREB7UR4.mjs";
86
86
  import {
87
87
  getImageProcessor,
88
88
  getMediaStorage
@@ -99,7 +99,7 @@ import {
99
99
  } from "./chunk-D5HQBNUB.mjs";
100
100
  import {
101
101
  NextlyError
102
- } from "./chunk-NRUWQ5Z7.mjs";
102
+ } from "./chunk-5WWWJCKI.mjs";
103
103
 
104
104
  // src/api/api-keys.ts
105
105
  import { z } from "zod";
@@ -2154,8 +2154,8 @@ function buildAuthRouterDeps(getService2) {
2154
2154
  }
2155
2155
  },
2156
2156
  createSuperAdmin: async (data) => {
2157
- const { seedPermissions } = await import("./permissions-YZSSFHU4.mjs");
2158
- const { seedSuperAdmin } = await import("./super-admin-WSTXAZSS.mjs");
2157
+ const { seedPermissions } = await import("./permissions-ONWRZAQO.mjs");
2158
+ const { seedSuperAdmin } = await import("./super-admin-ZPB2YQDQ.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-YZSSFHU4.mjs");
2183
+ const { seedPermissions } = await import("./permissions-ONWRZAQO.mjs");
2184
2184
  const adapter = getService2("adapter");
2185
2185
  await seedPermissions(adapter, { silent: true });
2186
2186
  },
@@ -2336,10 +2336,8 @@ async function ensureServicesInitialized() {
2336
2336
  if (nextlyConfig.users) serviceConfig.users = nextlyConfig.users;
2337
2337
  if (nextlyConfig.admin) serviceConfig.admin = nextlyConfig.admin;
2338
2338
  if (nextlyConfig.auth) serviceConfig.auth = nextlyConfig.auth;
2339
- if (nextlyConfig.security)
2340
- serviceConfig.security = nextlyConfig.security;
2341
- if (nextlyConfig.apiKeys)
2342
- serviceConfig.apiKeys = nextlyConfig.apiKeys;
2339
+ if (nextlyConfig.security) serviceConfig.security = nextlyConfig.security;
2340
+ if (nextlyConfig.apiKeys) serviceConfig.apiKeys = nextlyConfig.apiKeys;
2343
2341
  if (nextlyConfig.db) {
2344
2342
  const dbConfig = nextlyConfig.db;
2345
2343
  if (dbConfig.schemasDir) serviceConfig.schemasDir = dbConfig.schemasDir;
@@ -2347,6 +2345,12 @@ async function ensureServicesInitialized() {
2347
2345
  serviceConfig.migrationsDir = dbConfig.migrationsDir;
2348
2346
  }
2349
2347
  }
2348
+ if (process.env.NODE_ENV === "development" && // eslint-disable-next-line turbo/no-undeclared-env-vars
2349
+ process.env.NEXTLY_DISABLE_INSTRUMENTATION_WARNING !== "1") {
2350
+ console.warn(
2351
+ "[nextly] Cold-boot triggered by an incoming request \u2014 no instrumentation.ts detected. Each Next.js worker will now independently run schema introspection and permission seeding against your database, multiplying connection load. Add an `instrumentation.ts` at your project root (see https://nextly.dev/docs/getting-started/instrumentation) to fold this into a single worker-warmup. Suppress with NEXTLY_DISABLE_INSTRUMENTATION_WARNING=1."
2352
+ );
2353
+ }
2350
2354
  await registerServices(serviceConfig);
2351
2355
  try {
2352
2356
  const emailTemplateService = getService("emailTemplateService");
@@ -2392,7 +2396,7 @@ async function ensureServicesInitialized() {
2392
2396
  } else {
2393
2397
  console.log("[Auth Handler] Services auto-initialized with defaults");
2394
2398
  }
2395
- const { runBootTimeApplyIfDev } = await import("./boot-apply-5EFSWAMW.mjs");
2399
+ const { runBootTimeApplyIfDev } = await import("./boot-apply-NOFBZ5QY.mjs");
2396
2400
  await runBootTimeApplyIfDev({ caller: "auth-handler" });
2397
2401
  ensureHmrListener();
2398
2402
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseService
3
- } from "./chunk-2W3DVD7S.mjs";
3
+ } from "./chunk-PFRMIEJ3.mjs";
4
4
 
5
5
  // src/services/system/system-table-service.ts
6
6
  var POSTGRES_SQL = {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  reloadNextlyConfig,
3
3
  resolveCollectionTableName
4
- } from "./chunk-MWW7OUDL.mjs";
4
+ } from "./chunk-XYV27NZL.mjs";
5
5
  import {
6
6
  runBootTimeApplyIfDev
7
- } from "./chunk-L3SZUFF4.mjs";
7
+ } from "./chunk-7PLW6Z3L.mjs";
8
8
  import {
9
9
  buildClaims,
10
10
  signAccessToken
@@ -14,7 +14,7 @@ import {
14
14
  isServicesRegistered,
15
15
  registerServices,
16
16
  shutdownServices
17
- } from "./chunk-HVH4J6S6.mjs";
17
+ } from "./chunk-QIGAYTZD.mjs";
18
18
  import {
19
19
  AuthService,
20
20
  PermissionService,
@@ -22,10 +22,10 @@ import {
22
22
  RoleService,
23
23
  UserAccountService,
24
24
  transformRichTextFields
25
- } from "./chunk-ZVN3JILF.mjs";
25
+ } from "./chunk-QSE7KMHI.mjs";
26
26
  import {
27
27
  env
28
- } from "./chunk-UJ2IMJ4W.mjs";
28
+ } from "./chunk-HREB7UR4.mjs";
29
29
  import {
30
30
  getImageProcessor
31
31
  } from "./chunk-EGXBZCGC.mjs";
@@ -34,7 +34,7 @@ import {
34
34
  } from "./chunk-D5HQBNUB.mjs";
35
35
  import {
36
36
  NextlyError
37
- } from "./chunk-NRUWQ5Z7.mjs";
37
+ } from "./chunk-5WWWJCKI.mjs";
38
38
 
39
39
  // src/direct-api/namespaces/auth.ts
40
40
  async function login(ctx, args) {
@@ -2235,29 +2235,41 @@ async function runDriftCheck(args) {
2235
2235
  const { adapter, collections, logger } = args;
2236
2236
  const deps = await resolveDeps(args.deps);
2237
2237
  if (collections.length === 0) return { kind: "clean" };
2238
- const previewPromises = collections.map(async (collection) => {
2239
- try {
2240
- const preview = await deps.previewDesiredSchema({
2241
- desired: {
2242
- collections: {
2243
- [collection.slug]: collection
2238
+ const DRIFT_CONCURRENCY = 3;
2239
+ const results = [];
2240
+ let cursor = 0;
2241
+ const worker = async () => {
2242
+ while (cursor < collections.length) {
2243
+ const myIndex = cursor++;
2244
+ const collection = collections[myIndex];
2245
+ try {
2246
+ const preview = await deps.previewDesiredSchema({
2247
+ desired: {
2248
+ collections: {
2249
+ [collection.slug]: collection
2250
+ },
2251
+ singles: {},
2252
+ components: {}
2244
2253
  },
2245
- singles: {},
2246
- components: {}
2247
- },
2248
- db: adapter.getDrizzle(),
2249
- dialect: adapter.dialect
2250
- });
2251
- return { ok: true, opCount: preview.operations.length };
2252
- } catch (err) {
2253
- const msg = err instanceof Error ? err.message : String(err);
2254
- logger.debug?.(
2255
- `[nextly] Drift preview failed for '${collection.slug}': ${msg} (continuing).`
2256
- );
2257
- return { ok: false, error: msg };
2254
+ db: adapter.getDrizzle(),
2255
+ dialect: adapter.dialect
2256
+ });
2257
+ results[myIndex] = { ok: true, opCount: preview.operations.length };
2258
+ } catch (err) {
2259
+ const msg = err instanceof Error ? err.message : String(err);
2260
+ logger.debug?.(
2261
+ `[nextly] Drift preview failed for '${collection.slug}': ${msg} (continuing).`
2262
+ );
2263
+ results[myIndex] = { ok: false, error: msg };
2264
+ }
2258
2265
  }
2259
- });
2260
- const results = await Promise.all(previewPromises);
2266
+ };
2267
+ await Promise.all(
2268
+ Array.from(
2269
+ { length: Math.min(DRIFT_CONCURRENCY, collections.length) },
2270
+ () => worker()
2271
+ )
2272
+ );
2261
2273
  let pendingOps = 0;
2262
2274
  let failureCount = 0;
2263
2275
  for (const r of results) {
@@ -2279,7 +2291,7 @@ async function resolveDeps(injected) {
2279
2291
  if (injected?.previewDesiredSchema) {
2280
2292
  return injected;
2281
2293
  }
2282
- const { previewDesiredSchema } = await import("./preview-H6CJBMCP.mjs");
2294
+ const { previewDesiredSchema } = await import("./preview-3RSMZITY.mjs");
2283
2295
  return {
2284
2296
  previewDesiredSchema: injected?.previewDesiredSchema ?? previewDesiredSchema
2285
2297
  };
@@ -2344,35 +2356,52 @@ function ensureHmrListener() {
2344
2356
  const url = process.env.NEXTLY_HMR_URL_OVERRIDE ?? `${protocol}://localhost:${port}${prefix}/_next/webpack-hmr`;
2345
2357
  g.__nextly_hmrWs = new WebSocket(url);
2346
2358
  g.__nextly_hmrWs.onmessage = (event) => {
2347
- if (g.__nextly_hmrReload instanceof Promise) return;
2348
2359
  if (typeof event.data !== "string") return;
2349
- let data;
2350
- try {
2351
- data = JSON.parse(event.data);
2352
- } catch {
2353
- return;
2354
- }
2355
- if (typeof data !== "object" || data === null) return;
2356
- const record = data;
2357
- const isServerChange = record.type === "serverComponentChanges" || record.action === "serverComponentChanges";
2358
- if (isServerChange) {
2359
- if (!(g.__nextly_hmrReload instanceof Promise)) {
2360
- const reload = (async () => {
2361
- try {
2362
- const { reloadNextlyConfig: reloadNextlyConfig2 } = await import("./reload-config-VUEIQP5W.mjs");
2363
- await reloadNextlyConfig2();
2364
- } catch {
2365
- }
2366
- })();
2367
- markHmrReloadInFlight(reload);
2368
- }
2369
- }
2360
+ handleHmrMessage(event.data);
2370
2361
  };
2371
2362
  g.__nextly_hmrWs.onerror = () => {
2372
2363
  };
2373
2364
  } catch {
2374
2365
  }
2375
2366
  }
2367
+ var HMR_DEBOUNCE_MS = 300;
2368
+ var debounceCache = globalThis;
2369
+ var _reloaderFn = null;
2370
+ async function getReloader() {
2371
+ if (_reloaderFn) return _reloaderFn;
2372
+ const { reloadNextlyConfig: reloadNextlyConfig2 } = await import("./reload-config-RWRAPMQG.mjs");
2373
+ return reloadNextlyConfig2;
2374
+ }
2375
+ function scheduleReload() {
2376
+ if (g.__nextly_hmrReload instanceof Promise) return;
2377
+ if (debounceCache.__nextly_hmrDebounce) {
2378
+ clearTimeout(debounceCache.__nextly_hmrDebounce);
2379
+ }
2380
+ debounceCache.__nextly_hmrDebounce = setTimeout(() => {
2381
+ delete debounceCache.__nextly_hmrDebounce;
2382
+ if (g.__nextly_hmrReload instanceof Promise) return;
2383
+ const reload = (async () => {
2384
+ try {
2385
+ const reloadFn = await getReloader();
2386
+ await reloadFn();
2387
+ } catch {
2388
+ }
2389
+ })();
2390
+ markHmrReloadInFlight(reload);
2391
+ }, HMR_DEBOUNCE_MS);
2392
+ }
2393
+ function handleHmrMessage(raw) {
2394
+ let data;
2395
+ try {
2396
+ data = JSON.parse(raw);
2397
+ } catch {
2398
+ return;
2399
+ }
2400
+ if (typeof data !== "object" || data === null) return;
2401
+ const record = data;
2402
+ const isServerChange = record.type === "serverComponentChanges" || record.action === "serverComponentChanges";
2403
+ if (isServerChange) scheduleReload();
2404
+ }
2376
2405
  function consumeHmrReloadFlag() {
2377
2406
  if (g.__nextly_hmrReload === true) {
2378
2407
  g.__nextly_hmrReload = false;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getDialectTables
3
- } from "./chunk-TS7GHTG2.mjs";
3
+ } from "./chunk-YXZH65YV.mjs";
4
4
  import {
5
5
  container
6
6
  } from "./chunk-D5HQBNUB.mjs";
@@ -2,7 +2,7 @@ import {
2
2
  ComponentRegistryService,
3
3
  PermissionSeedService,
4
4
  SingleRegistryService
5
- } from "./chunk-KSKKIZDP.mjs";
5
+ } from "./chunk-3IX2NDII.mjs";
6
6
  import {
7
7
  AccessControlService,
8
8
  ApiKeyService,
@@ -31,22 +31,22 @@ import {
31
31
  keysToSnakeCase,
32
32
  resolveStatusFilter,
33
33
  sanitizeEntryData
34
- } from "./chunk-ZVN3JILF.mjs";
34
+ } from "./chunk-QSE7KMHI.mjs";
35
35
  import {
36
36
  CollectionRegistryService
37
- } from "./chunk-D72XH3BG.mjs";
37
+ } from "./chunk-ERJGWWPB.mjs";
38
38
  import {
39
39
  ComponentSchemaService
40
- } from "./chunk-JXZITQPZ.mjs";
40
+ } from "./chunk-4HUQNXVM.mjs";
41
41
  import {
42
42
  hasPermission,
43
43
  isSuperAdmin,
44
44
  listEffectivePermissions,
45
45
  listRoleSlugsForUser
46
- } from "./chunk-NAP3TDS6.mjs";
46
+ } from "./chunk-SWVNFKWD.mjs";
47
47
  import {
48
48
  BaseService
49
- } from "./chunk-2W3DVD7S.mjs";
49
+ } from "./chunk-PFRMIEJ3.mjs";
50
50
  import {
51
51
  emailProvidersMysql,
52
52
  emailProvidersPg,
@@ -60,14 +60,14 @@ import {
60
60
  siteSettingsMysql,
61
61
  siteSettingsPg,
62
62
  siteSettingsSqlite
63
- } from "./chunk-TS7GHTG2.mjs";
63
+ } from "./chunk-YXZH65YV.mjs";
64
64
  import {
65
65
  createAdapterFromEnv,
66
66
  validateDatabaseEnv
67
- } from "./chunk-DP3G27G5.mjs";
67
+ } from "./chunk-35LAHTCU.mjs";
68
68
  import {
69
69
  env
70
- } from "./chunk-UJ2IMJ4W.mjs";
70
+ } from "./chunk-HREB7UR4.mjs";
71
71
  import {
72
72
  initializeMediaStorage
73
73
  } from "./chunk-EGXBZCGC.mjs";
@@ -77,7 +77,7 @@ import {
77
77
  import {
78
78
  NextlyError,
79
79
  toDbError
80
- } from "./chunk-NRUWQ5Z7.mjs";
80
+ } from "./chunk-5WWWJCKI.mjs";
81
81
  import {
82
82
  isComponentField
83
83
  } from "./chunk-5APFUGAD.mjs";
@@ -5900,7 +5900,7 @@ async function initializeSchemaRegistry(adapter) {
5900
5900
  registry.registerStaticSchemas(getDialectTables(dialect));
5901
5901
  adapter.setTableResolver(registry);
5902
5902
  try {
5903
- const { ensureFirstRunSetup } = await import("./first-run-QIVKWJIF.mjs");
5903
+ const { ensureFirstRunSetup } = await import("./first-run-2JTNWFEG.mjs");
5904
5904
  await ensureFirstRunSetup({
5905
5905
  adapter,
5906
5906
  logger: {
@@ -5920,7 +5920,7 @@ async function initializeSchemaRegistry(adapter) {
5920
5920
  adapter,
5921
5921
  "dynamic_collections",
5922
5922
  async (tableName, fields, hasStatus) => {
5923
- const { generateRuntimeSchema } = await import("./runtime-schema-generator-MOPQWGJP.mjs");
5923
+ const { generateRuntimeSchema } = await import("./runtime-schema-generator-NQOLDUDG.mjs");
5924
5924
  const { table } = generateRuntimeSchema(
5925
5925
  tableName,
5926
5926
  fields,
@@ -5934,7 +5934,7 @@ async function initializeSchemaRegistry(adapter) {
5934
5934
  adapter,
5935
5935
  "dynamic_singles",
5936
5936
  async (tableName, fields, hasStatus) => {
5937
- const { generateRuntimeSchema } = await import("./runtime-schema-generator-MOPQWGJP.mjs");
5937
+ const { generateRuntimeSchema } = await import("./runtime-schema-generator-NQOLDUDG.mjs");
5938
5938
  const { table } = generateRuntimeSchema(
5939
5939
  tableName,
5940
5940
  fields,
@@ -5948,7 +5948,7 @@ async function initializeSchemaRegistry(adapter) {
5948
5948
  adapter,
5949
5949
  "dynamic_components",
5950
5950
  async (tableName, fields) => {
5951
- const { ComponentSchemaService: ComponentSchemaService2 } = await import("./component-schema-service-JOQIBQGK.mjs");
5951
+ const { ComponentSchemaService: ComponentSchemaService2 } = await import("./component-schema-service-HUAQQ4H5.mjs");
5952
5952
  const compSchemaService = new ComponentSchemaService2(dialect);
5953
5953
  const runtimeTable = compSchemaService.generateRuntimeSchema(
5954
5954
  tableName,
@@ -5973,7 +5973,7 @@ async function registerConfigTablesInResolver(registry, config, adapter, logger)
5973
5973
  const baseTableName = dbName ?? slug.replace(/-/g, "_");
5974
5974
  const tableName = baseTableName.startsWith("dc_") ? baseTableName : `dc_${baseTableName}`;
5975
5975
  const hasStatus = collection.status === true;
5976
- const { generateRuntimeSchema } = await import("./runtime-schema-generator-MOPQWGJP.mjs");
5976
+ const { generateRuntimeSchema } = await import("./runtime-schema-generator-NQOLDUDG.mjs");
5977
5977
  const { table } = generateRuntimeSchema(
5978
5978
  tableName,
5979
5979
  fields,
@@ -5996,7 +5996,7 @@ async function registerConfigTablesInResolver(registry, config, adapter, logger)
5996
5996
  if (!slug || !Array.isArray(fields) || fields.length === 0) continue;
5997
5997
  const tableName = resolveSingleTableName({ slug, dbName });
5998
5998
  const hasStatus = single.status === true;
5999
- const { generateRuntimeSchema } = await import("./runtime-schema-generator-MOPQWGJP.mjs");
5999
+ const { generateRuntimeSchema } = await import("./runtime-schema-generator-NQOLDUDG.mjs");
6000
6000
  const { table } = generateRuntimeSchema(
6001
6001
  tableName,
6002
6002
  fields,
@@ -6119,8 +6119,8 @@ ${errorDetails}`);
6119
6119
  `Auto-syncing ${collectionsNeedingTableSync.length} collection table(s)...`
6120
6120
  );
6121
6121
  try {
6122
- const { applyDesiredSchema } = await import("./pipeline-2DWG7LSN.mjs");
6123
- const { generateRuntimeSchema } = await import("./runtime-schema-generator-MOPQWGJP.mjs");
6122
+ const { applyDesiredSchema } = await import("./pipeline-URL33V42.mjs");
6123
+ const { generateRuntimeSchema } = await import("./runtime-schema-generator-NQOLDUDG.mjs");
6124
6124
  const collectionsToSyncSet = new Set(collectionsNeedingTableSync);
6125
6125
  const desiredCollections = {};
6126
6126
  const slugsAfterFilter = [];
@@ -6250,7 +6250,7 @@ ${errorDetails}`);
6250
6250
  `Auto-syncing ${componentsNeedingTableSync.length} component table(s)...`
6251
6251
  );
6252
6252
  try {
6253
- const { ComponentSchemaService: CompSchemaService } = await import("./component-schema-service-JOQIBQGK.mjs");
6253
+ const { ComponentSchemaService: CompSchemaService } = await import("./component-schema-service-HUAQQ4H5.mjs");
6254
6254
  const dialect = adapter.getCapabilities().dialect;
6255
6255
  const compSchemaService = new CompSchemaService(dialect);
6256
6256
  for (const slug of componentsNeedingTableSync) {
@@ -6342,7 +6342,7 @@ async function syncCodeFirstSingles(adapter, logger, transformedConfig) {
6342
6342
  async function reconcileSingleTablesForBoot(adapter, logger, transformedConfig) {
6343
6343
  try {
6344
6344
  const { reconcileSingleTables } = await import("./reconcile-single-tables-7ENVXJGB.mjs");
6345
- const { DynamicCollectionSchemaService } = await import("./dynamic-collection-schema-service-KMOP5PGD.mjs");
6345
+ const { DynamicCollectionSchemaService } = await import("./dynamic-collection-schema-service-FIRWOXZI.mjs");
6346
6346
  const schemaService = new DynamicCollectionSchemaService();
6347
6347
  const singleRegistry = container.get(
6348
6348
  "singleRegistryService"
@@ -6392,7 +6392,7 @@ async function reconcileSingleTablesForBoot(adapter, logger, transformedConfig)
6392
6392
  if (tableExists) {
6393
6393
  try {
6394
6394
  const dialect = adapter.getCapabilities().dialect;
6395
- const { generateRuntimeSchema: genRt } = await import("./runtime-schema-generator-MOPQWGJP.mjs");
6395
+ const { generateRuntimeSchema: genRt } = await import("./runtime-schema-generator-NQOLDUDG.mjs");
6396
6396
  const { table } = genRt(single.tableName, fields, dialect, {
6397
6397
  status: hasStatus
6398
6398
  });
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NextlyError
3
- } from "./chunk-NRUWQ5Z7.mjs";
3
+ } from "./chunk-5WWWJCKI.mjs";
4
4
 
5
5
  // src/api/auth-header-only.ts
6
6
  function requireAuthHeader(request) {