@geekmidas/cli 10.0.0-alpha.125 → 10.0.0-alpha.126

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 (148) hide show
  1. package/dist/{GoDaddyProvider-BN1dODm9.mjs → GoDaddyProvider-CvRVmN4W.mjs} +2 -2
  2. package/dist/{GoDaddyProvider-BN1dODm9.mjs.map → GoDaddyProvider-CvRVmN4W.mjs.map} +1 -1
  3. package/dist/{GoDaddyProvider-BTdtqhI_.cjs → GoDaddyProvider-DFfpzCOP.cjs} +2 -2
  4. package/dist/{GoDaddyProvider-BTdtqhI_.cjs.map → GoDaddyProvider-DFfpzCOP.cjs.map} +1 -1
  5. package/dist/{LegacyStateStore-C2S8TGwx.cjs → LegacyStateStore-BFrCHrFQ.cjs} +3 -3
  6. package/dist/{LegacyStateStore-C2S8TGwx.cjs.map → LegacyStateStore-BFrCHrFQ.cjs.map} +1 -1
  7. package/dist/{LegacyStateStore-DgXmuG87.mjs → LegacyStateStore-CgfENrXF.mjs} +3 -3
  8. package/dist/{LegacyStateStore-DgXmuG87.mjs.map → LegacyStateStore-CgfENrXF.mjs.map} +1 -1
  9. package/dist/{LocalStateStore-CaJw9H-3.cjs → LocalStateStore-BU5z_IOE.cjs} +2 -2
  10. package/dist/{LocalStateStore-CaJw9H-3.cjs.map → LocalStateStore-BU5z_IOE.cjs.map} +1 -1
  11. package/dist/{LocalStateStore-ojY_BiMK.mjs → LocalStateStore-DxoNpiBg.mjs} +2 -2
  12. package/dist/{LocalStateStore-ojY_BiMK.mjs.map → LocalStateStore-DxoNpiBg.mjs.map} +1 -1
  13. package/dist/{S3StateStore-BSPkxhrx.mjs → S3StateStore-CGMSDilh.mjs} +2 -2
  14. package/dist/{S3StateStore-BSPkxhrx.mjs.map → S3StateStore-CGMSDilh.mjs.map} +1 -1
  15. package/dist/{S3StateStore-BqugXIcb.cjs → S3StateStore-DiekMLpn.cjs} +2 -2
  16. package/dist/{S3StateStore-BqugXIcb.cjs.map → S3StateStore-DiekMLpn.cjs.map} +1 -1
  17. package/dist/{SSMStateStore-B0OsuT_k.cjs → SSMStateStore-BDCOFdKq.cjs} +2 -2
  18. package/dist/{SSMStateStore-B0OsuT_k.cjs.map → SSMStateStore-BDCOFdKq.cjs.map} +1 -1
  19. package/dist/{SSMStateStore-DM85OiH0.mjs → SSMStateStore-Cq2H9MlF.mjs} +2 -2
  20. package/dist/{SSMStateStore-DM85OiH0.mjs.map → SSMStateStore-Cq2H9MlF.mjs.map} +1 -1
  21. package/dist/{SubscriberGenerator-ocQ2yj0K.mjs → SubscriberGenerator-BALddfuW.mjs} +2 -60
  22. package/dist/SubscriberGenerator-BALddfuW.mjs.map +1 -0
  23. package/dist/{SubscriberGenerator-BDUp7OeY.cjs → SubscriberGenerator-LgyTxZ8r.cjs} +1 -89
  24. package/dist/SubscriberGenerator-LgyTxZ8r.cjs.map +1 -0
  25. package/dist/{add-CrxvmSpq.cjs → add-BsiBYkAW.cjs} +3 -3
  26. package/dist/{add-CrxvmSpq.cjs.map → add-BsiBYkAW.cjs.map} +1 -1
  27. package/dist/{add-C7ZBXIzM.mjs → add-CamA9Uqv.mjs} +3 -3
  28. package/dist/{add-C7ZBXIzM.mjs.map → add-CamA9Uqv.mjs.map} +1 -1
  29. package/dist/{bundler-DpZ9uBGN.mjs → bundler-2V2PR_E-.mjs} +5 -5
  30. package/dist/{bundler-DpZ9uBGN.mjs.map → bundler-2V2PR_E-.mjs.map} +1 -1
  31. package/dist/{bundler-DVUXW95p.cjs → bundler-CijtdIZ2.cjs} +5 -5
  32. package/dist/{bundler-DVUXW95p.cjs.map → bundler-CijtdIZ2.cjs.map} +1 -1
  33. package/dist/{cli-BMRhE6cZ.cjs → cli-7gc1QG8X.cjs} +2 -2
  34. package/dist/{cli-BMRhE6cZ.cjs.map → cli-7gc1QG8X.cjs.map} +1 -1
  35. package/dist/{cli-BWfYyy1k.mjs → cli-PiyYqHGx.mjs} +2 -2
  36. package/dist/{cli-BWfYyy1k.mjs.map → cli-PiyYqHGx.mjs.map} +1 -1
  37. package/dist/{compose-Bqcy0lqo.cjs → compose-8e2xJ61E.cjs} +9 -8
  38. package/dist/compose-8e2xJ61E.cjs.map +1 -0
  39. package/dist/{compose-BFmdLig3.mjs → compose-CvHIjMDd.mjs} +8 -7
  40. package/dist/{compose-BFmdLig3.mjs.map → compose-CvHIjMDd.mjs.map} +1 -1
  41. package/dist/{databases-BPOgTn1u.mjs → databases-6GD0tI2F.mjs} +65 -3
  42. package/dist/databases-6GD0tI2F.mjs.map +1 -0
  43. package/dist/{databases-fOaoBInm.cjs → databases-CuVGf7-M.cjs} +75 -1
  44. package/dist/databases-CuVGf7-M.cjs.map +1 -0
  45. package/dist/deploy/public.cjs +6 -6
  46. package/dist/deploy/public.d.cts.map +1 -1
  47. package/dist/deploy/public.d.mts.map +1 -1
  48. package/dist/deploy/public.mjs +6 -6
  49. package/dist/{deploy-D8pUA9Y0.mjs → deploy-CIPwTJ47.mjs} +6 -6
  50. package/dist/{deploy-D8pUA9Y0.mjs.map → deploy-CIPwTJ47.mjs.map} +1 -1
  51. package/dist/{deploy-DVrNjX1X.cjs → deploy-wSlIRPn5.cjs} +6 -6
  52. package/dist/{deploy-DVrNjX1X.cjs.map → deploy-wSlIRPn5.cjs.map} +1 -1
  53. package/dist/{dokploy-TtK6Zyl3.cjs → dokploy-BKbUrz05.cjs} +2 -2
  54. package/dist/{dokploy-TtK6Zyl3.cjs.map → dokploy-BKbUrz05.cjs.map} +1 -1
  55. package/dist/{dokploy-CzDGNB6A.mjs → dokploy-BZf1AHd0.mjs} +2 -2
  56. package/dist/{dokploy-CzDGNB6A.mjs.map → dokploy-BZf1AHd0.mjs.map} +1 -1
  57. package/dist/{drivers-L29WvE95.cjs → drivers-C47nm-wB.cjs} +91 -4
  58. package/dist/drivers-C47nm-wB.cjs.map +1 -0
  59. package/dist/{drivers-C-VqMtld.mjs → drivers-CDjpjakg.mjs} +60 -3
  60. package/dist/drivers-CDjpjakg.mjs.map +1 -0
  61. package/dist/{eas-DaobzDks.mjs → eas-CxX2RCE_.mjs} +2 -2
  62. package/dist/{eas-DaobzDks.mjs.map → eas-CxX2RCE_.mjs.map} +1 -1
  63. package/dist/{eas-D3clzkni.cjs → eas-DzDMGzfc.cjs} +2 -2
  64. package/dist/{eas-D3clzkni.cjs.map → eas-DzDMGzfc.cjs.map} +1 -1
  65. package/dist/{encryption-DV31gEY8.mjs → encryption-BFSrt89F.mjs} +2 -2
  66. package/dist/{encryption-DV31gEY8.mjs.map → encryption-BFSrt89F.mjs.map} +1 -1
  67. package/dist/{encryption-DBkIFiR2.cjs → encryption-RNcBnG4Z.cjs} +2 -2
  68. package/dist/{encryption-DBkIFiR2.cjs.map → encryption-RNcBnG4Z.cjs.map} +1 -1
  69. package/dist/{engine-CuZUGbEh.cjs → engine-Dqe9KQCm.cjs} +7 -5
  70. package/dist/engine-Dqe9KQCm.cjs.map +1 -0
  71. package/dist/{engine-CFOR9h6X.mjs → engine-_0pjyCd_.mjs} +7 -5
  72. package/dist/engine-_0pjyCd_.mjs.map +1 -0
  73. package/dist/{github-CsvtWSBW.cjs → github-Csev5EFf.cjs} +4 -4
  74. package/dist/{github-CsvtWSBW.cjs.map → github-Csev5EFf.cjs.map} +1 -1
  75. package/dist/{github-Nep8pI4_.mjs → github-Dck0nLW9.mjs} +4 -4
  76. package/dist/{github-Nep8pI4_.mjs.map → github-Dck0nLW9.mjs.map} +1 -1
  77. package/dist/{googlePlay-C-UfBXJU.cjs → googlePlay-DBtDAGBk.cjs} +3 -3
  78. package/dist/{googlePlay-C-UfBXJU.cjs.map → googlePlay-DBtDAGBk.cjs.map} +1 -1
  79. package/dist/{googlePlay-lF7Atm_N.mjs → googlePlay-DTuvDHi5.mjs} +3 -3
  80. package/dist/{googlePlay-lF7Atm_N.mjs.map → googlePlay-DTuvDHi5.mjs.map} +1 -1
  81. package/dist/index.cjs +58 -57
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.mjs +57 -56
  84. package/dist/index.mjs.map +1 -1
  85. package/dist/{migrate-hlNKNWmg.cjs → migrate-3ZEoqx5q.cjs} +2 -2
  86. package/dist/{migrate-hlNKNWmg.cjs.map → migrate-3ZEoqx5q.cjs.map} +1 -1
  87. package/dist/{migrate-_sBX0pve.mjs → migrate-BABIuzQj.mjs} +2 -2
  88. package/dist/{migrate-_sBX0pve.mjs.map → migrate-BABIuzQj.mjs.map} +1 -1
  89. package/dist/{migrate-NfbPVhi9.mjs → migrate-DZeNpuX2.mjs} +6 -4
  90. package/dist/migrate-DZeNpuX2.mjs.map +1 -0
  91. package/dist/{migrate-Dp3GhFnf.cjs → migrate-pGiUqvBi.cjs} +6 -4
  92. package/dist/migrate-pGiUqvBi.cjs.map +1 -0
  93. package/dist/{publish-BuUVaZVy.mjs → publish-BsnDeOVL.mjs} +2 -2
  94. package/dist/{publish-BuUVaZVy.mjs.map → publish-BsnDeOVL.mjs.map} +1 -1
  95. package/dist/{publish-ZOo4xEuZ.cjs → publish-CS6xDvGT.cjs} +2 -2
  96. package/dist/{publish-ZOo4xEuZ.cjs.map → publish-CS6xDvGT.cjs.map} +1 -1
  97. package/dist/{ready-qnqp6JAY.cjs → ready-CxPJm0Hc.cjs} +3 -3
  98. package/dist/{ready-qnqp6JAY.cjs.map → ready-CxPJm0Hc.cjs.map} +1 -1
  99. package/dist/{ready-Ca883OvY.mjs → ready-DrvaAwKv.mjs} +3 -3
  100. package/dist/{ready-Ca883OvY.mjs.map → ready-DrvaAwKv.mjs.map} +1 -1
  101. package/dist/{resolve-BCU9pYDx.mjs → resolve-fCGJmM-R.mjs} +3 -3
  102. package/dist/{resolve-BCU9pYDx.mjs.map → resolve-fCGJmM-R.mjs.map} +1 -1
  103. package/dist/{resolve-C9QqOl5t.cjs → resolve-zqCMFio0.cjs} +3 -3
  104. package/dist/{resolve-C9QqOl5t.cjs.map → resolve-zqCMFio0.cjs.map} +1 -1
  105. package/dist/{rollback-CWyyTQ0B.mjs → rollback-BkhVrtAf.mjs} +4 -4
  106. package/dist/{rollback-CWyyTQ0B.mjs.map → rollback-BkhVrtAf.mjs.map} +1 -1
  107. package/dist/{rollback-CTWdDBgB.cjs → rollback-qc79mj6L.cjs} +4 -4
  108. package/dist/{rollback-CTWdDBgB.cjs.map → rollback-qc79mj6L.cjs.map} +1 -1
  109. package/dist/sandbox/migrate-worker.cjs +4 -3
  110. package/dist/sandbox/migrate-worker.cjs.map +1 -1
  111. package/dist/sandbox/migrate-worker.mjs +4 -3
  112. package/dist/sandbox/migrate-worker.mjs.map +1 -1
  113. package/dist/{seeds-CPEcmoPn.cjs → seeds-3awh33Wz.cjs} +12 -11
  114. package/dist/{seeds-CPEcmoPn.cjs.map → seeds-3awh33Wz.cjs.map} +1 -1
  115. package/dist/{seeds-CK7w79VC.mjs → seeds-Cfejy8wj.mjs} +5 -4
  116. package/dist/{seeds-CK7w79VC.mjs.map → seeds-Cfejy8wj.mjs.map} +1 -1
  117. package/dist/{serverSetup-C6t6Vtt7.cjs → serverSetup-BFQuwUeL.cjs} +5 -5
  118. package/dist/{serverSetup-C6t6Vtt7.cjs.map → serverSetup-BFQuwUeL.cjs.map} +1 -1
  119. package/dist/{serverSetup-BAPNuNEX.mjs → serverSetup-C8ZbHTm_.mjs} +5 -5
  120. package/dist/{serverSetup-BAPNuNEX.mjs.map → serverSetup-C8ZbHTm_.mjs.map} +1 -1
  121. package/dist/{sniffer-g9v7cqDN.mjs → sniffer-CCkdzjiU.mjs} +6 -6
  122. package/dist/{sniffer-g9v7cqDN.mjs.map → sniffer-CCkdzjiU.mjs.map} +1 -1
  123. package/dist/{sniffer-DdX_WN_-.cjs → sniffer-Cq1nhxIB.cjs} +6 -6
  124. package/dist/{sniffer-DdX_WN_-.cjs.map → sniffer-Cq1nhxIB.cjs.map} +1 -1
  125. package/dist/{snsSubscriptions-5Cqww8S7.cjs → snsSubscriptions-DYyYP0Xf.cjs} +2 -2
  126. package/dist/{snsSubscriptions-5Cqww8S7.cjs.map → snsSubscriptions-DYyYP0Xf.cjs.map} +1 -1
  127. package/dist/{snsSubscriptions-BmYeeTH8.mjs → snsSubscriptions-R_AKBZYK.mjs} +2 -2
  128. package/dist/{snsSubscriptions-BmYeeTH8.mjs.map → snsSubscriptions-R_AKBZYK.mjs.map} +1 -1
  129. package/dist/{stage-CUE5pMmw.cjs → stage-BkgbVJ9Z.cjs} +4 -4
  130. package/dist/{stage-CUE5pMmw.cjs.map → stage-BkgbVJ9Z.cjs.map} +1 -1
  131. package/dist/{stage-C-I2dVw1.mjs → stage-DCaxqm-G.mjs} +4 -4
  132. package/dist/{stage-C-I2dVw1.mjs.map → stage-DCaxqm-G.mjs.map} +1 -1
  133. package/dist/target/public.cjs +1 -1
  134. package/dist/target/public.mjs +1 -1
  135. package/dist/vitest.cjs +1 -1
  136. package/dist/vitest.mjs +1 -1
  137. package/package.json +15 -15
  138. package/dist/SubscriberGenerator-BDUp7OeY.cjs.map +0 -1
  139. package/dist/SubscriberGenerator-ocQ2yj0K.mjs.map +0 -1
  140. package/dist/compose-Bqcy0lqo.cjs.map +0 -1
  141. package/dist/databases-BPOgTn1u.mjs.map +0 -1
  142. package/dist/databases-fOaoBInm.cjs.map +0 -1
  143. package/dist/drivers-C-VqMtld.mjs.map +0 -1
  144. package/dist/drivers-L29WvE95.cjs.map +0 -1
  145. package/dist/engine-CFOR9h6X.mjs.map +0 -1
  146. package/dist/engine-CuZUGbEh.cjs.map +0 -1
  147. package/dist/migrate-Dp3GhFnf.cjs.map +0 -1
  148. package/dist/migrate-NfbPVhi9.mjs.map +0 -1
@@ -1,7 +1,9 @@
1
1
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
+ import { n as driversFor, r as eventsBackendsIn, t as cacheBackendsIn } from "./drivers-CDjpjakg.mjs";
2
3
  import { createRequire } from "node:module";
3
4
  import { extname, join } from "node:path";
4
- import { readFile, readdir, stat } from "node:fs/promises";
5
+ import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
6
+ import { createHash } from "node:crypto";
5
7
  import { DATABASE_FOLDERS, MIGRATIONS_ROOT, canonicalId, migrationTargets, provideKey } from "@geekmidas/manifest";
6
8
  import { pathToFileURL } from "node:url";
7
9
  import pg from "pg";
@@ -137,6 +139,58 @@ async function sqlMigration(file, raw) {
137
139
  } };
138
140
  }
139
141
  //#endregion
142
+ //#region src/migrate/seedDrivers.ts
143
+ /**
144
+ * The drivers a seed run registers before any seed runs.
145
+ *
146
+ * The seed runner is an entry point gkm owns, like the generated server and
147
+ * the test harness, so it registers what they register — from the same
148
+ * {@link driversFor}, so the two cannot drift. A seed then reaches a bucket or
149
+ * a cache through the construct's service, exactly as a handler does, and no
150
+ * application code names a provider.
151
+ *
152
+ * The registrations are written to a module under `.gkm/` and imported from
153
+ * there, rather than imported by gkm itself: a registry is a module-level map,
154
+ * so it has to be the copy the app's constructs resolve — which is the one a
155
+ * bare specifier finds from the project root, not the one beside gkm.
156
+ */
157
+ /** The drivers a seed run needs could not be loaded from the project. */
158
+ var SeedDriversUnresolved = class extends GkmError {
159
+ root;
160
+ cause;
161
+ constructor(root, cause) {
162
+ super(`Could not load the drivers seeds run with from ${root} — ${cause instanceof Error ? cause.message : String(cause)}. They are the ones the app's own entry registers; install the package it names where the project's constructs are declared.`);
163
+ this.root = root;
164
+ this.cause = cause;
165
+ this.name = "SeedDriversUnresolved";
166
+ }
167
+ };
168
+ /**
169
+ * Register the drivers a generated entry for this project would: storage when
170
+ * it installs `@geekmidas/storage`, the cache backend its caches resolve to,
171
+ * and the broker its topics and queues do. Nothing when it declares none.
172
+ */
173
+ async function registerSeedDrivers(options) {
174
+ const drivers = driversFor({
175
+ appRoot: options.root,
176
+ cache: cacheBackendsIn(options.manifest, options.backends.cache),
177
+ events: eventsBackendsIn(options.manifest, options.backends.events)
178
+ });
179
+ if (!drivers.setup) return;
180
+ const content = `${drivers.imports}\n\n${drivers.setup}\n`;
181
+ const dir = join(options.root, ".gkm");
182
+ const file = join(dir, "seed-drivers.mjs");
183
+ await mkdir(dir, { recursive: true });
184
+ await writeFile(file, content);
185
+ const url = pathToFileURL(file);
186
+ url.searchParams.set("v", createHash("sha256").update(content).digest("hex").slice(0, 12));
187
+ try {
188
+ await import(url.href);
189
+ } catch (error) {
190
+ throw new SeedDriversUnresolved(options.root, error);
191
+ }
192
+ }
193
+ //#endregion
140
194
  //#region src/migrate/databases.ts
141
195
  /**
142
196
  * Bring each construct's schema up to its migrations folder.
@@ -279,9 +333,13 @@ async function migrateDatabases(options) {
279
333
  * plugins included — on the owner's connection. One written against
280
334
  * `Kysely<DB>` with a `CamelCasePlugin` writes `isEditable` here as it does in
281
335
  * a handler or a test.
336
+ *
337
+ * And with the drivers the stage's entry registers, so a seed reaching a
338
+ * bucket or a cache through its construct gets the client a handler would.
282
339
  */
283
340
  async function seedDatabases(options) {
284
341
  const runs = [];
342
+ let registered = false;
285
343
  for (const target of await targetsFor(options)) {
286
344
  const folder = join(options.root, target.seeds);
287
345
  if ((await migrationFiles(folder)).size === 0) {
@@ -291,6 +349,10 @@ async function seedDatabases(options) {
291
349
  });
292
350
  continue;
293
351
  }
352
+ if (!registered) {
353
+ await registerSeedDrivers(options);
354
+ registered = true;
355
+ }
294
356
  const seeded = await withOwner(options, target, clientConfigOf(options, target), async (db, kysely) => {
295
357
  const names = [];
296
358
  for (const seed of await loadSeeds(folder, kysely.sql)) {
@@ -517,6 +579,6 @@ async function kyselyFrom(from) {
517
579
  }
518
580
  }
519
581
  //#endregion
520
- export { migrationFiles as _, NoSuchMigrationTarget as a, UnknownMigrationFolder as c, pendingMigrations as d, plannedSeeds as f, SeedHasNoSeed as g, MigrationHasNoUp as h, NoOwnerCredential as i, migrateAndSeed as l, DuplicateMigration as m, MigrationFailed as n, SeedFailed as o, seedDatabases as p, MigrationsOutsideFolder as r, UnknownDatabaseFolder as s, KyselyNotFound as t, migrateDatabases as u };
582
+ export { MigrationHasNoUp as _, NoSuchMigrationTarget as a, UnknownMigrationFolder as c, pendingMigrations as d, plannedSeeds as f, DuplicateMigration as g, registerSeedDrivers as h, NoOwnerCredential as i, migrateAndSeed as l, SeedDriversUnresolved as m, MigrationFailed as n, SeedFailed as o, seedDatabases as p, MigrationsOutsideFolder as r, UnknownDatabaseFolder as s, KyselyNotFound as t, migrateDatabases as u, SeedHasNoSeed as v, migrationFiles as y };
521
583
 
522
- //# sourceMappingURL=databases-BPOgTn1u.mjs.map
584
+ //# sourceMappingURL=databases-6GD0tI2F.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databases-6GD0tI2F.mjs","names":[],"sources":["../src/migrate/provider.ts","../src/migrate/seedDrivers.ts","../src/migrate/databases.ts"],"sourcesContent":["/**\n * One construct's migrations and seeds, read from its folders.\n *\n * Two kinds of file, told apart by extension rather than by configuration: a\n * script exports `up` (and may export `down`) — or `seed(db, { stage })`, in\n * `seeds/` — and a\n * `.sql` file is run whole. The second is what makes a folder independent of\n * the client the app uses — Better Auth's schema is SQL whatever the\n * application queries with.\n */\n\nimport { readdir, readFile, stat } from 'node:fs/promises';\nimport { extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { SeedContext } from '@geekmidas/constructs';\nimport type { Kysely, sql } from 'kysely';\nimport type { Migration, MigrationProvider } from 'kysely/migration';\nimport { GkmError } from '../errors';\n\nconst SCRIPTS = new Set(['.ts', '.mts', '.js', '.mjs']);\n\n/** Two files in one folder that would be one migration. */\nexport class DuplicateMigration extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly migration: string,\n\t) {\n\t\tsuper(\n\t\t\t`${folder} has two migrations named '${migration}' — a script and a .sql file ` +\n\t\t\t\t`with the same name. A migration is recorded by name, so only one of ` +\n\t\t\t\t`them could ever run; rename or remove the other.`,\n\t\t);\n\t\tthis.name = 'DuplicateMigration';\n\t}\n}\n\n/** A script in a migrations folder that exports no `up`. */\nexport class MigrationHasNoUp extends GkmError {\n\tconstructor(readonly file: string) {\n\t\tsuper(\n\t\t\t`${file} is in a migrations folder but exports no \\`up\\` function. ` +\n\t\t\t\t`Export \\`async function up(db: Kysely<unknown>)\\`, or move the file ` +\n\t\t\t\t`out of the folder if it is not a migration.`,\n\t\t);\n\t\tthis.name = 'MigrationHasNoUp';\n\t}\n}\n\n/** A script in a seeds folder that exports no `seed`. */\nexport class SeedHasNoSeed extends GkmError {\n\tconstructor(readonly file: string) {\n\t\tsuper(\n\t\t\t`${file} is in a seeds folder but exports no \\`seed\\` function. ` +\n\t\t\t\t`Export \\`async function seed(db, { stage })\\`, or move the ` +\n\t\t\t\t`file out of the folder if it is not a seed.`,\n\t\t);\n\t\tthis.name = 'SeedHasNoSeed';\n\t}\n}\n\n/**\n * What a seed is handed beside its database — `@geekmidas/constructs`'\n * `SeedContext`, whose `stage` is the union of the declared stages once\n * `.gkm/stages.d.ts` is generated.\n */\nexport type { SeedContext };\n\n/** One seed: what it is called, and what it does. */\nexport interface Seed {\n\tname: string;\n\trun: (db: Kysely<unknown>, context: SeedContext) => Promise<void>;\n}\n\n/**\n * The migration files in a folder, by name, without reading them.\n *\n * Also what `gkm dev` compares against a construct's history to report what\n * is pending, which is why it is separate from loading them.\n */\nexport async function migrationFiles(\n\tfolder: string,\n): Promise<Map<string, string>> {\n\tconst entries = await readdir(folder, { withFileTypes: true }).catch(\n\t\t(error: NodeJS.ErrnoException) => {\n\t\t\tif (error.code === 'ENOENT') return [];\n\t\t\tthrow error;\n\t\t},\n\t);\n\n\tconst files = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tif (!entry.isFile() || !isMigration(entry.name)) continue;\n\n\t\tconst name = entry.name.slice(0, -extname(entry.name).length);\n\t\tif (files.has(name)) throw new DuplicateMigration(folder, name);\n\n\t\tfiles.set(name, join(folder, entry.name));\n\t}\n\n\treturn files;\n}\n\n/** A Kysely provider over one construct's folder. */\nexport function folderProvider(\n\tfolder: string,\n\traw: typeof sql,\n): MigrationProvider {\n\treturn {\n\t\tasync getMigrations() {\n\t\t\tconst migrations: Record<string, Migration> = {};\n\n\t\t\tfor (const [name, file] of await migrationFiles(folder)) {\n\t\t\t\tmigrations[name] =\n\t\t\t\t\textname(file) === '.sql'\n\t\t\t\t\t\t? await sqlMigration(file, raw)\n\t\t\t\t\t\t: await scriptMigration(file);\n\t\t\t}\n\n\t\t\treturn migrations;\n\t\t},\n\t};\n}\n\n/**\n * The seeds in a folder, loaded, in name order.\n *\n * Every one runs on every pass — there is no history to consult — so the order\n * is the only thing between two seeds where one reads what another writes.\n * Name them to sort that way.\n */\nexport async function loadSeeds(\n\tfolder: string,\n\traw: typeof sql,\n): Promise<Seed[]> {\n\tconst files = [...(await migrationFiles(folder))].sort(([a], [b]) =>\n\t\ta < b ? -1 : a > b ? 1 : 0,\n\t);\n\n\tconst seeds: Seed[] = [];\n\tfor (const [name, file] of files) {\n\t\tseeds.push({\n\t\t\tname,\n\t\t\trun:\n\t\t\t\textname(file) === '.sql'\n\t\t\t\t\t? (await sqlMigration(file, raw)).up\n\t\t\t\t\t: await scriptSeed(file),\n\t\t});\n\t}\n\n\treturn seeds;\n}\n\n/**\n * A seed script, imported as it is on disk now.\n *\n * Keyed by its modification time: a seed is run again after it is edited, and\n * a process that has imported it once would otherwise run the old one.\n */\nasync function scriptSeed(file: string): Promise<Seed['run']> {\n\tconst url = pathToFileURL(file);\n\turl.searchParams.set('mtime', String((await stat(file)).mtimeMs));\n\tconst module = (await import(url.href)) as { seed?: unknown };\n\tif (typeof module.seed !== 'function') throw new SeedHasNoSeed(file);\n\n\treturn module.seed as Seed['run'];\n}\n\nfunction isMigration(file: string): boolean {\n\tif (file.endsWith('.d.ts')) return false;\n\tif (/\\.(spec|test)\\.[cm]?[jt]s$/.test(file)) return false;\n\n\tconst extension = extname(file);\n\treturn extension === '.sql' || SCRIPTS.has(extension);\n}\n\nasync function scriptMigration(file: string): Promise<Migration> {\n\tconst module = (await import(pathToFileURL(file).href)) as Partial<Migration>;\n\tif (typeof module.up !== 'function') throw new MigrationHasNoUp(file);\n\n\treturn {\n\t\tup: module.up,\n\t\t...(typeof module.down === 'function' ? { down: module.down } : {}),\n\t};\n}\n\n/**\n * A `.sql` file, run whole.\n *\n * One query rather than split on `;`: with no parameters, Postgres takes\n * several statements in one message, and splitting by hand breaks on the first\n * `;` inside a string or a function body. There is no `down` — a generated\n * schema is rolled back by a migration that says how, not by guessing.\n */\nasync function sqlMigration(file: string, raw: typeof sql): Promise<Migration> {\n\tconst statements = await readFile(file, 'utf-8');\n\n\treturn {\n\t\tup: async (db: Kysely<unknown>) => {\n\t\t\tawait raw.raw(statements).execute(db);\n\t\t},\n\t};\n}\n","/**\n * The drivers a seed run registers before any seed runs.\n *\n * The seed runner is an entry point gkm owns, like the generated server and\n * the test harness, so it registers what they register — from the same\n * {@link driversFor}, so the two cannot drift. A seed then reaches a bucket or\n * a cache through the construct's service, exactly as a handler does, and no\n * application code names a provider.\n *\n * The registrations are written to a module under `.gkm/` and imported from\n * there, rather than imported by gkm itself: a registry is a module-level map,\n * so it has to be the copy the app's constructs resolve — which is the one a\n * bare specifier finds from the project root, not the one beside gkm.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport {\n\tcacheBackendsIn,\n\tdriversFor,\n\teventsBackendsIn,\n} from '../generators/drivers';\nimport type { CacheBackend, EventsBackend } from '../types';\n\n/** Which backends the stage being seeded resolves its declarations to. */\nexport interface SeedBackends {\n\tcache: CacheBackend;\n\tevents: EventsBackend;\n}\n\n/** The drivers a seed run needs could not be loaded from the project. */\nexport class SeedDriversUnresolved extends GkmError {\n\tconstructor(\n\t\treadonly root: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Could not load the drivers seeds run with from ${root} — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t`They are the ones the app's own entry registers; install the ` +\n\t\t\t\t`package it names where the project's constructs are declared.`,\n\t\t);\n\t\tthis.name = 'SeedDriversUnresolved';\n\t}\n}\n\n/**\n * Register the drivers a generated entry for this project would: storage when\n * it installs `@geekmidas/storage`, the cache backend its caches resolve to,\n * and the broker its topics and queues do. Nothing when it declares none.\n */\nexport async function registerSeedDrivers(options: {\n\troot: string;\n\tmanifest: ConstructManifest;\n\tbackends: SeedBackends;\n}): Promise<void> {\n\tconst drivers = driversFor({\n\t\tappRoot: options.root,\n\t\tcache: cacheBackendsIn(options.manifest, options.backends.cache),\n\t\tevents: eventsBackendsIn(options.manifest, options.backends.events),\n\t});\n\tif (!drivers.setup) return;\n\n\tconst content = `${drivers.imports}\\n\\n${drivers.setup}\\n`;\n\tconst dir = join(options.root, '.gkm');\n\tconst file = join(dir, 'seed-drivers.mjs');\n\tawait mkdir(dir, { recursive: true });\n\tawait writeFile(file, content);\n\n\t// Keyed by content: registration is idempotent, but a process seeding\n\t// twice after the declarations changed must load the new set.\n\tconst url = pathToFileURL(file);\n\turl.searchParams.set(\n\t\t'v',\n\t\tcreateHash('sha256').update(content).digest('hex').slice(0, 12),\n\t);\n\n\ttry {\n\t\tawait import(url.href);\n\t} catch (error) {\n\t\tthrow new SeedDriversUnresolved(options.root, error);\n\t}\n}\n","/**\n * Bring each construct's schema up to its migrations folder.\n *\n * Which constructs, in what order, from which folder, is `migrationTargets`'\n * answer and nobody else's. What is decided here is only how one target is\n * run: as its owner, in its own schema, with a history of its own.\n */\n\nimport { readdir } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n\ttype ConstructManifest,\n\tcanonicalId,\n\tDATABASE_FOLDERS,\n\tMIGRATIONS_ROOT,\n\ttype MigrationTarget,\n\tmigrationTargets,\n\tprovideKey,\n} from '@geekmidas/manifest';\nimport type { Kysely, KyselyConfig } from 'kysely';\nimport type { Migrator } from 'kysely/migration';\nimport pg from 'pg';\nimport { GkmError } from '../errors';\nimport type { ConstructSource } from '../reconcile/discover';\nimport { folderProvider, loadSeeds, migrationFiles } from './provider';\nimport { registerSeedDrivers, type SeedBackends } from './seedDrivers';\n\nexport interface DatabasesOptions {\n\t/** The project root — where `db/` lives. */\n\troot: string;\n\tmanifest: ConstructManifest;\n\t/**\n\t * Where each construct was declared. A construct's migrations run with the\n\t * Kysely its own file resolves, which is the one its migrations import.\n\t */\n\tsources?: Readonly<Record<string, ConstructSource>>;\n\t/** The resolved environment: each construct's owner URL is read from it. */\n\tenv: Readonly<Record<string, string | undefined>>;\n\t/** One construct, by name. All of them when absent. */\n\tonly?: string;\n}\n\nexport interface MigrationRun {\n\ttarget: MigrationTarget;\n\t/** The migrations this run applied, in order. */\n\tapplied: string[];\n}\n\nexport interface SeedOptions extends DatabasesOptions {\n\t/** The stage being seeded, handed to every seed. */\n\tstage: string;\n\t/**\n\t * What the stage's caches and topics resolve to — which drivers a seed is\n\t * run with, as the stage's own entry would register them.\n\t */\n\tbackends: SeedBackends;\n}\n\nexport interface SeedRun {\n\ttarget: MigrationTarget;\n\t/** The seeds this run ran, in order — every one, every time. */\n\tseeded: string[];\n}\n\n/** The seeds a run would run for one construct, read without connecting. */\nexport interface PlannedSeeds {\n\ttarget: MigrationTarget;\n\t/** In the order they would run. */\n\tseeds: string[];\n}\n\nexport interface PendingMigrations {\n\ttarget: MigrationTarget;\n\tpending: string[];\n}\n\n/** A folder under `db/` that names no construct. */\nexport class UnknownMigrationFolder extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${folder} names no database construct, so its migrations would never ` +\n\t\t\t\t`run. ${known.length > 0 ? `The folders that do: ${known.join(', ')}.` : 'This project declares no database.'} ` +\n\t\t\t\t`Rename the folder after the construct it belongs to.`,\n\t\t);\n\t\tthis.name = 'UnknownMigrationFolder';\n\t}\n}\n\n/** A construct was asked for by a name that takes no migrations. */\nexport class NoSuchMigrationTarget extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${construct}' is not a database construct. ` +\n\t\t\t\t(known.length > 0\n\t\t\t\t\t? `The ones with migrations: ${known.join(', ')}.`\n\t\t\t\t\t: 'This project declares no database.'),\n\t\t);\n\t\tthis.name = 'NoSuchMigrationTarget';\n\t}\n}\n\n/**\n * A migration left directly in a construct's folder, where nothing reads it.\n *\n * Migrations moved into `migrations/` so seeds could sit beside them. A file\n * still at the old level would otherwise never run, and nothing would say so.\n */\nexport class MigrationsOutsideFolder extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly files: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${folder} has ${files.join(', ')} directly inside it, where nothing ` +\n\t\t\t\t`runs them. Migrations live in ${folder}/migrations/ and seeds in ` +\n\t\t\t\t`${folder}/seeds/ — move ${files.length === 1 ? 'it' : 'them'} there.`,\n\t\t);\n\t\tthis.name = 'MigrationsOutsideFolder';\n\t}\n}\n\n/** A folder inside a construct's folder that is neither `migrations` nor `seeds`. */\nexport class UnknownDatabaseFolder extends GkmError {\n\tconstructor(readonly folder: string) {\n\t\tsuper(\n\t\t\t`${folder} is neither migrations/ nor seeds/, so nothing in it would ` +\n\t\t\t\t`ever run. A construct's folder holds those two; rename or remove it.`,\n\t\t);\n\t\tthis.name = 'UnknownDatabaseFolder';\n\t}\n}\n\n/** A seed failed; its own writes are rolled back, the ones before it stay. */\nexport class SeedFailed extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}: seed '${seed}' failed — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t`Its writes were rolled back; fix it and run it again.`,\n\t\t);\n\t\tthis.name = 'SeedFailed';\n\t}\n}\n\n/** A construct with roles has no owner URL to migrate with. */\nexport class NoOwnerCredential extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct} has no ${key} to migrate with. Migrations run as the owner ` +\n\t\t\t\t`role — the runtime one cannot create a table — and nothing ` +\n\t\t\t\t`resolved its URL. Is the stage reconciled?`,\n\t\t);\n\t\tthis.name = 'NoOwnerCredential';\n\t}\n}\n\n/** A migration failed; the ones before it in the run stay applied. */\nexport class MigrationFailed extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly migration: string | undefined,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}: migration ${migration ? `'${migration}' ` : ''}failed — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}`,\n\t\t);\n\t\tthis.name = 'MigrationFailed';\n\t}\n}\n\n/** The project's Kysely could not be found from where a database is declared. */\nexport class KyselyNotFound extends GkmError {\n\tconstructor(readonly from: string) {\n\t\tsuper(\n\t\t\t`Could not resolve 'kysely' from ${from}. Migrations run with the ` +\n\t\t\t\t`project's own Kysely — install it where the database is declared.`,\n\t\t);\n\t\tthis.name = 'KyselyNotFound';\n\t}\n}\n\n/** Apply every pending migration, construct by construct, parents first. */\nexport async function migrateDatabases(\n\toptions: DatabasesOptions,\n): Promise<MigrationRun[]> {\n\tconst runs: MigrationRun[] = [];\n\n\tfor (const target of await targetsFor(options)) {\n\t\t// No folder, or an empty one, is nothing to do — and no reason to\n\t\t// connect, which a construct nobody has written a migration for yet\n\t\t// should not need.\n\t\tconst files = await migrationFiles(join(options.root, target.migrations));\n\t\tif (files.size === 0) {\n\t\t\truns.push({ target, applied: [] });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst applied = await withMigrator(options, target, async (migrator) => {\n\t\t\tconst { error, results = [] } = await migrator.migrateToLatest();\n\t\t\tif (error) {\n\t\t\t\tconst failed = results.find((result) => result.status === 'Error');\n\t\t\t\tthrow new MigrationFailed(target.id, failed?.migrationName, error);\n\t\t\t}\n\n\t\t\treturn results\n\t\t\t\t.filter((result) => result.status === 'Success')\n\t\t\t\t.map((result) => result.migrationName);\n\t\t});\n\n\t\truns.push({ target, applied });\n\t}\n\n\treturn runs;\n}\n\n/**\n * Run every construct's seeds, parents first — each one, every time, on every\n * stage, production included. Each is handed the stage, so a seed decides\n * what belongs where.\n *\n * Seeds are reference data kept up to date by being run again, so there is no\n * history: a seed is an upsert, and a changed one is applied by the next run.\n * Each runs in its own transaction, as the construct's owner, so a failure\n * leaves nothing half-written. Assumes the schema is migrated —\n * {@link migrateAndSeed} is what makes that true.\n *\n * A seed is handed the client the app gets — the construct's `clientConfig`,\n * plugins included — on the owner's connection. One written against\n * `Kysely<DB>` with a `CamelCasePlugin` writes `isEditable` here as it does in\n * a handler or a test.\n *\n * And with the drivers the stage's entry registers, so a seed reaching a\n * bucket or a cache through its construct gets the client a handler would.\n */\nexport async function seedDatabases(options: SeedOptions): Promise<SeedRun[]> {\n\tconst runs: SeedRun[] = [];\n\tlet registered = false;\n\n\tfor (const target of await targetsFor(options)) {\n\t\tconst folder = join(options.root, target.seeds);\n\t\tif ((await migrationFiles(folder)).size === 0) {\n\t\t\truns.push({ target, seeded: [] });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!registered) {\n\t\t\tawait registerSeedDrivers(options);\n\t\t\tregistered = true;\n\t\t}\n\n\t\tconst config = clientConfigOf(options, target);\n\t\tconst seeded = await withOwner(\n\t\t\toptions,\n\t\t\ttarget,\n\t\t\tconfig,\n\t\t\tasync (db, kysely) => {\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (const seed of await loadSeeds(folder, kysely.sql)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait db\n\t\t\t\t\t\t\t.transaction()\n\t\t\t\t\t\t\t.execute((trx) => seed.run(trx, { stage: options.stage }));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow new SeedFailed(target.id, seed.name, error);\n\t\t\t\t\t}\n\t\t\t\t\tnames.push(seed.name);\n\t\t\t\t}\n\t\t\t\treturn names;\n\t\t\t},\n\t\t);\n\n\t\truns.push({ target, seeded });\n\t}\n\n\treturn runs;\n}\n\n/**\n * The seeds {@link seedDatabases} would run, construct by construct, parents\n * first, in the order it would run them — read from the folders alone, with\n * no connection. What a dry run lists. Constructs with none are left out.\n */\nexport async function plannedSeeds(\n\toptions: Pick<DatabasesOptions, 'root' | 'manifest' | 'only'>,\n): Promise<PlannedSeeds[]> {\n\tconst planned: PlannedSeeds[] = [];\n\tfor (const target of await targetsFor(options)) {\n\t\tconst files = await migrationFiles(join(options.root, target.seeds));\n\t\tif (files.size === 0) continue;\n\t\tplanned.push({ target, seeds: [...files.keys()].sort() });\n\t}\n\treturn planned;\n}\n\n/**\n * Migrate, then seed: a seed only ever runs against the schema it was written\n * for.\n *\n * With `only`, the constructs it lives in are migrated too — a tenant's seed\n * cannot run before the database that owns its schema exists — and only it is\n * seeded.\n */\nexport async function migrateAndSeed(options: SeedOptions): Promise<{\n\tmigrations: MigrationRun[];\n\tseeds: SeedRun[];\n}> {\n\tconst migrations: MigrationRun[] = [];\n\tfor (const target of await withParents(options)) {\n\t\tmigrations.push(\n\t\t\t...(await migrateDatabases({ ...options, only: target.id })),\n\t\t);\n\t}\n\n\treturn { migrations, seeds: await seedDatabases(options) };\n}\n\n/** The targets `only` names, after the ones it lives in; all without it. */\nasync function withParents(\n\toptions: DatabasesOptions,\n): Promise<MigrationTarget[]> {\n\tconst chosen = await targetsFor(options);\n\tif (!options.only) return chosen;\n\n\tconst all = migrationTargets(options.manifest);\n\tconst ids = new Set<string>();\n\tfor (const target of chosen) {\n\t\tlet current: MigrationTarget | undefined = target;\n\t\twhile (current) {\n\t\t\tids.add(current.id);\n\t\t\tconst parent: string | undefined = current.of;\n\t\t\tcurrent = parent ? all.find((t) => t.id === parent) : undefined;\n\t\t}\n\t}\n\n\treturn all.filter((target) => ids.has(target.id));\n}\n\n/**\n * What each construct's folder has that its history does not — without\n * applying any of it. What `gkm dev` reports.\n */\nexport async function pendingMigrations(\n\toptions: DatabasesOptions,\n): Promise<PendingMigrations[]> {\n\tconst found: PendingMigrations[] = [];\n\n\tfor (const target of await targetsFor(options)) {\n\t\tconst files = await migrationFiles(join(options.root, target.migrations));\n\t\tif (files.size === 0) continue;\n\n\t\tconst pending = await withMigrator(options, target, async (migrator) =>\n\t\t\t(await migrator.getMigrations())\n\t\t\t\t.filter((migration) => migration.executedAt === undefined)\n\t\t\t\t.map((migration) => migration.name),\n\t\t);\n\n\t\tif (pending.length > 0) found.push({ target, pending });\n\t}\n\n\treturn found;\n}\n\n/**\n * The targets this run covers, with every folder under `db/` accounted for.\n *\n * A folder that names no construct is an error rather than something to skip:\n * a typo in its name is otherwise a migration that silently never runs.\n */\nasync function targetsFor(\n\toptions: Pick<DatabasesOptions, 'root' | 'manifest' | 'only'>,\n): Promise<MigrationTarget[]> {\n\tconst targets = migrationTargets(options.manifest);\n\tconst folders = targets.map((target) => target.folder);\n\n\tfor (const folder of await foldersIn(join(options.root, MIGRATIONS_ROOT))) {\n\t\tconst relative = `${MIGRATIONS_ROOT}/${folder}`;\n\t\tif (!folders.includes(relative)) {\n\t\t\tthrow new UnknownMigrationFolder(relative, folders);\n\t\t}\n\t\tawait checkLayout(options.root, relative);\n\t}\n\n\tif (!options.only) return targets;\n\n\tconst id = canonicalId(options.only);\n\tconst chosen = targets.filter((target) => target.id === id);\n\tif (chosen.length === 0) {\n\t\tthrow new NoSuchMigrationTarget(\n\t\t\toptions.only,\n\t\t\ttargets.map((target) => target.id),\n\t\t);\n\t}\n\n\treturn chosen;\n}\n\n/**\n * A construct's folder holds `migrations/` and `seeds/`, and nothing else —\n * anything beside them is a file or folder nothing would ever run.\n */\nasync function checkLayout(root: string, folder: string): Promise<void> {\n\tconst entries = await readdir(join(root, folder), { withFileTypes: true });\n\n\tconst loose = entries\n\t\t.filter((entry) => entry.isFile() && !entry.name.startsWith('.'))\n\t\t.map((entry) => entry.name);\n\tif (loose.length > 0) throw new MigrationsOutsideFolder(folder, loose);\n\n\tfor (const entry of entries) {\n\t\tif (\n\t\t\tentry.isDirectory() &&\n\t\t\t!(DATABASE_FOLDERS as readonly string[]).includes(entry.name)\n\t\t) {\n\t\t\tthrow new UnknownDatabaseFolder(`${folder}/${entry.name}`);\n\t\t}\n\t}\n}\n\nasync function foldersIn(dir: string): Promise<string[]> {\n\tconst entries = await readdir(dir, { withFileTypes: true }).catch(\n\t\t(error: NodeJS.ErrnoException) => {\n\t\t\tif (error.code === 'ENOENT') return [];\n\t\t\tthrow error;\n\t\t},\n\t);\n\n\treturn entries\n\t\t.filter((entry) => entry.isDirectory())\n\t\t.map((entry) => entry.name);\n}\n\n/**\n * A migrator for one target, connected as its owner.\n *\n * No `migrationTableSchema`: the owner role's `search_path` is pinned to the\n * construct's schema, so the history lands there — `app.kysely_migration` for\n * the database, `auth_database.kysely_migration` for its tenant — and two\n * constructs in one Postgres never share one.\n *\n * Unordered migrations are allowed. Files are timestamped, so a branch merged\n * after another's migration ran carries an older one; refusing it would make\n * every such merge a manual repair.\n *\n * The client is bare — none of the construct's plugins. A casing plugin\n * rewrites identifiers in schema-builder DDL too, and a migration must do the\n * same thing forever after it has run, so it cannot depend on configuration\n * that may change.\n */\nasync function withMigrator<T>(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n\trun: (migrator: Migrator) => Promise<T>,\n): Promise<T> {\n\treturn withOwner(options, target, {}, (db, { Migrator, sql }) =>\n\t\trun(\n\t\t\tnew Migrator({\n\t\t\t\tdb,\n\t\t\t\tprovider: folderProvider(join(options.root, target.migrations), sql),\n\t\t\t\tallowUnorderedMigrations: true,\n\t\t\t}),\n\t\t),\n\t);\n}\n\n/**\n * One target's database, connected as its owner and closed afterwards — what\n * migrations and seeds both run as, each with the client config it needs.\n */\nasync function withOwner<T>(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n\tconfig: Omit<KyselyConfig, 'dialect'>,\n\trun: (\n\t\tdb: Kysely<unknown>,\n\t\tkysely: Awaited<ReturnType<typeof kyselyFrom>>,\n\t) => Promise<T>,\n): Promise<T> {\n\tconst from =\n\t\toptions.sources?.[target.id]?.file ??\n\t\t(target.of ? options.sources?.[target.of]?.file : undefined) ??\n\t\tjoin(options.root, 'package.json');\n\tconst kysely = await kyselyFrom(from);\n\n\tconst db: Kysely<unknown> = new kysely.Kysely<unknown>({\n\t\t...config,\n\t\tdialect: new kysely.PostgresDialect({\n\t\t\tpool: new pg.Pool(poolConfig(ownerUrl(options, target))),\n\t\t}),\n\t});\n\n\ttry {\n\t\treturn await run(db, kysely);\n\t} finally {\n\t\tawait db.destroy();\n\t}\n}\n\n/**\n * What the construct builds its clients with besides a dialect — its plugins\n * and logging — read from the construct discovery already imported.\n *\n * A tenant's is its own: `database.schema('Auth', { plugins })` declares the\n * client for its tables, not the parent's. With no construct to ask (a\n * manifest without sources), the client is bare.\n */\nfunction clientConfigOf(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n): Omit<KyselyConfig, 'dialect'> {\n\tconst construct = options.sources?.[target.id]?.construct;\n\tif (typeof construct !== 'object' || construct === null) return {};\n\tif (!('clientConfig' in construct)) return {};\n\treturn (construct.clientConfig as Omit<KyselyConfig, 'dialect'>) ?? {};\n}\n\n/**\n * The owner's URL, with no fallback to the runtime one.\n *\n * The runtime role can create nothing, so falling back would only move the\n * failure to the first `CREATE TABLE` and make it read like a permissions\n * bug. The one exception is a database declared `roles: false`, where there is\n * no owner — both URLs are the master credential by design.\n */\nfunction ownerUrl(options: DatabasesOptions, target: MigrationTarget): string {\n\tconst key = provideKey(target.id, 'ownerUrl');\n\tconst owner = options.env[key];\n\tif (owner) return owner;\n\n\tconst database = options.manifest[target.of ?? target.id];\n\tif (database?.kind === 'database' && database.roles === false) {\n\t\tconst url = options.env[provideKey(target.id, 'url')];\n\t\tif (url) return url;\n\t}\n\n\tthrow new NoOwnerCredential(target.id, key);\n}\n\n/**\n * Pool settings for a URL, with `?search_path=` as the startup option Postgres\n * reads. Only a `roles: false` URL carries it — a role pins its own.\n */\nfunction poolConfig(url: string): pg.PoolConfig {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\tif (!searchPath) return { connectionString: url };\n\n\tparsed.searchParams.delete('search_path');\n\treturn {\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t};\n}\n\n/** Kysely as the project resolves it from `from`. */\nasync function kyselyFrom(from: string) {\n\tconst require = createRequire(from);\n\n\ttry {\n\t\tconst [main, migration] = await Promise.all([\n\t\t\timport(pathToFileURL(require.resolve('kysely')).href),\n\t\t\timport(pathToFileURL(require.resolve('kysely/migration')).href),\n\t\t]);\n\n\t\treturn {\n\t\t\tKysely: main.Kysely as typeof import('kysely').Kysely,\n\t\t\tPostgresDialect:\n\t\t\t\tmain.PostgresDialect as typeof import('kysely').PostgresDialect,\n\t\t\tsql: main.sql as typeof import('kysely').sql,\n\t\t\tMigrator:\n\t\t\t\tmigration.Migrator as typeof import('kysely/migration').Migrator,\n\t\t};\n\t} catch {\n\t\tthrow new KyselyNotFound(from);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,0BAAU,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAO;AAAM,CAAC;;AAGtD,IAAa,qBAAb,cAAwC,SAAS;CAEtC;CACA;CAFV,YACC,QACA,WACC;EACD,MACC,GAAG,OAAO,6BAA6B,UAAU,kJAGlD;EAPS,KAAA,SAAA;EACA,KAAA,YAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,mBAAb,cAAsC,SAAS;CACzB;CAArB,YAAY,MAAuB;EAClC,MACC,GAAG,KAAK,2KAGT;EALoB,KAAA,OAAA;EAMpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,gBAAb,cAAmC,SAAS;CACtB;CAArB,YAAY,MAAuB;EAClC,MACC,GAAG,KAAK,+JAGT;EALoB,KAAA,OAAA;EAMpB,KAAK,OAAO;CACb;AACD;;;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 +1,9 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
2
2
  const require_errors = require("./errors-DMC4Umsb.cjs");
3
+ const require_drivers = require("./drivers-C47nm-wB.cjs");
3
4
  let node_path = require("node:path");
4
5
  let node_fs_promises = require("node:fs/promises");
6
+ let node_crypto = require("node:crypto");
5
7
  let _geekmidas_manifest = require("@geekmidas/manifest");
6
8
  let node_module = require("node:module");
7
9
  let node_url = require("node:url");
@@ -139,6 +141,58 @@ async function sqlMigration(file, raw) {
139
141
  } };
140
142
  }
141
143
  //#endregion
144
+ //#region src/migrate/seedDrivers.ts
145
+ /**
146
+ * The drivers a seed run registers before any seed runs.
147
+ *
148
+ * The seed runner is an entry point gkm owns, like the generated server and
149
+ * the test harness, so it registers what they register — from the same
150
+ * {@link driversFor}, so the two cannot drift. A seed then reaches a bucket or
151
+ * a cache through the construct's service, exactly as a handler does, and no
152
+ * application code names a provider.
153
+ *
154
+ * The registrations are written to a module under `.gkm/` and imported from
155
+ * there, rather than imported by gkm itself: a registry is a module-level map,
156
+ * so it has to be the copy the app's constructs resolve — which is the one a
157
+ * bare specifier finds from the project root, not the one beside gkm.
158
+ */
159
+ /** The drivers a seed run needs could not be loaded from the project. */
160
+ var SeedDriversUnresolved = class extends require_errors.GkmError {
161
+ root;
162
+ cause;
163
+ constructor(root, cause) {
164
+ super(`Could not load the drivers seeds run with from ${root} — ${cause instanceof Error ? cause.message : String(cause)}. They are the ones the app's own entry registers; install the package it names where the project's constructs are declared.`);
165
+ this.root = root;
166
+ this.cause = cause;
167
+ this.name = "SeedDriversUnresolved";
168
+ }
169
+ };
170
+ /**
171
+ * Register the drivers a generated entry for this project would: storage when
172
+ * it installs `@geekmidas/storage`, the cache backend its caches resolve to,
173
+ * and the broker its topics and queues do. Nothing when it declares none.
174
+ */
175
+ async function registerSeedDrivers(options) {
176
+ const drivers = require_drivers.driversFor({
177
+ appRoot: options.root,
178
+ cache: require_drivers.cacheBackendsIn(options.manifest, options.backends.cache),
179
+ events: require_drivers.eventsBackendsIn(options.manifest, options.backends.events)
180
+ });
181
+ if (!drivers.setup) return;
182
+ const content = `${drivers.imports}\n\n${drivers.setup}\n`;
183
+ const dir = (0, node_path.join)(options.root, ".gkm");
184
+ const file = (0, node_path.join)(dir, "seed-drivers.mjs");
185
+ await (0, node_fs_promises.mkdir)(dir, { recursive: true });
186
+ await (0, node_fs_promises.writeFile)(file, content);
187
+ const url = (0, node_url.pathToFileURL)(file);
188
+ url.searchParams.set("v", (0, node_crypto.createHash)("sha256").update(content).digest("hex").slice(0, 12));
189
+ try {
190
+ await import(url.href);
191
+ } catch (error) {
192
+ throw new SeedDriversUnresolved(options.root, error);
193
+ }
194
+ }
195
+ //#endregion
142
196
  //#region src/migrate/databases.ts
143
197
  /**
144
198
  * Bring each construct's schema up to its migrations folder.
@@ -281,9 +335,13 @@ async function migrateDatabases(options) {
281
335
  * plugins included — on the owner's connection. One written against
282
336
  * `Kysely<DB>` with a `CamelCasePlugin` writes `isEditable` here as it does in
283
337
  * a handler or a test.
338
+ *
339
+ * And with the drivers the stage's entry registers, so a seed reaching a
340
+ * bucket or a cache through its construct gets the client a handler would.
284
341
  */
285
342
  async function seedDatabases(options) {
286
343
  const runs = [];
344
+ let registered = false;
287
345
  for (const target of await targetsFor(options)) {
288
346
  const folder = (0, node_path.join)(options.root, target.seeds);
289
347
  if ((await migrationFiles(folder)).size === 0) {
@@ -293,6 +351,10 @@ async function seedDatabases(options) {
293
351
  });
294
352
  continue;
295
353
  }
354
+ if (!registered) {
355
+ await registerSeedDrivers(options);
356
+ registered = true;
357
+ }
296
358
  const seeded = await withOwner(options, target, clientConfigOf(options, target), async (db, kysely) => {
297
359
  const names = [];
298
360
  for (const seed of await loadSeeds(folder, kysely.sql)) {
@@ -561,6 +623,12 @@ Object.defineProperty(exports, "NoSuchMigrationTarget", {
561
623
  return NoSuchMigrationTarget;
562
624
  }
563
625
  });
626
+ Object.defineProperty(exports, "SeedDriversUnresolved", {
627
+ enumerable: true,
628
+ get: function() {
629
+ return SeedDriversUnresolved;
630
+ }
631
+ });
564
632
  Object.defineProperty(exports, "SeedFailed", {
565
633
  enumerable: true,
566
634
  get: function() {
@@ -615,6 +683,12 @@ Object.defineProperty(exports, "plannedSeeds", {
615
683
  return plannedSeeds;
616
684
  }
617
685
  });
686
+ Object.defineProperty(exports, "registerSeedDrivers", {
687
+ enumerable: true,
688
+ get: function() {
689
+ return registerSeedDrivers;
690
+ }
691
+ });
618
692
  Object.defineProperty(exports, "seedDatabases", {
619
693
  enumerable: true,
620
694
  get: function() {
@@ -622,4 +696,4 @@ Object.defineProperty(exports, "seedDatabases", {
622
696
  }
623
697
  });
624
698
 
625
- //# sourceMappingURL=databases-fOaoBInm.cjs.map
699
+ //# sourceMappingURL=databases-CuVGf7-M.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databases-CuVGf7-M.cjs","names":["GkmError","readdir","extname","join","pathToFileURL","stat","readFile","GkmError","driversFor","cacheBackendsIn","eventsBackendsIn","join","mkdir","writeFile","pathToFileURL","createHash","GkmError","join","migrationTargets","MIGRATIONS_ROOT","canonicalId","readdir","DATABASE_FOLDERS","provideKey","require","createRequire","pathToFileURL"],"sources":["../src/migrate/provider.ts","../src/migrate/seedDrivers.ts","../src/migrate/databases.ts"],"sourcesContent":["/**\n * One construct's migrations and seeds, read from its folders.\n *\n * Two kinds of file, told apart by extension rather than by configuration: a\n * script exports `up` (and may export `down`) — or `seed(db, { stage })`, in\n * `seeds/` — and a\n * `.sql` file is run whole. The second is what makes a folder independent of\n * the client the app uses — Better Auth's schema is SQL whatever the\n * application queries with.\n */\n\nimport { readdir, readFile, stat } from 'node:fs/promises';\nimport { extname, join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { SeedContext } from '@geekmidas/constructs';\nimport type { Kysely, sql } from 'kysely';\nimport type { Migration, MigrationProvider } from 'kysely/migration';\nimport { GkmError } from '../errors';\n\nconst SCRIPTS = new Set(['.ts', '.mts', '.js', '.mjs']);\n\n/** Two files in one folder that would be one migration. */\nexport class DuplicateMigration extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly migration: string,\n\t) {\n\t\tsuper(\n\t\t\t`${folder} has two migrations named '${migration}' — a script and a .sql file ` +\n\t\t\t\t`with the same name. A migration is recorded by name, so only one of ` +\n\t\t\t\t`them could ever run; rename or remove the other.`,\n\t\t);\n\t\tthis.name = 'DuplicateMigration';\n\t}\n}\n\n/** A script in a migrations folder that exports no `up`. */\nexport class MigrationHasNoUp extends GkmError {\n\tconstructor(readonly file: string) {\n\t\tsuper(\n\t\t\t`${file} is in a migrations folder but exports no \\`up\\` function. ` +\n\t\t\t\t`Export \\`async function up(db: Kysely<unknown>)\\`, or move the file ` +\n\t\t\t\t`out of the folder if it is not a migration.`,\n\t\t);\n\t\tthis.name = 'MigrationHasNoUp';\n\t}\n}\n\n/** A script in a seeds folder that exports no `seed`. */\nexport class SeedHasNoSeed extends GkmError {\n\tconstructor(readonly file: string) {\n\t\tsuper(\n\t\t\t`${file} is in a seeds folder but exports no \\`seed\\` function. ` +\n\t\t\t\t`Export \\`async function seed(db, { stage })\\`, or move the ` +\n\t\t\t\t`file out of the folder if it is not a seed.`,\n\t\t);\n\t\tthis.name = 'SeedHasNoSeed';\n\t}\n}\n\n/**\n * What a seed is handed beside its database — `@geekmidas/constructs`'\n * `SeedContext`, whose `stage` is the union of the declared stages once\n * `.gkm/stages.d.ts` is generated.\n */\nexport type { SeedContext };\n\n/** One seed: what it is called, and what it does. */\nexport interface Seed {\n\tname: string;\n\trun: (db: Kysely<unknown>, context: SeedContext) => Promise<void>;\n}\n\n/**\n * The migration files in a folder, by name, without reading them.\n *\n * Also what `gkm dev` compares against a construct's history to report what\n * is pending, which is why it is separate from loading them.\n */\nexport async function migrationFiles(\n\tfolder: string,\n): Promise<Map<string, string>> {\n\tconst entries = await readdir(folder, { withFileTypes: true }).catch(\n\t\t(error: NodeJS.ErrnoException) => {\n\t\t\tif (error.code === 'ENOENT') return [];\n\t\t\tthrow error;\n\t\t},\n\t);\n\n\tconst files = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tif (!entry.isFile() || !isMigration(entry.name)) continue;\n\n\t\tconst name = entry.name.slice(0, -extname(entry.name).length);\n\t\tif (files.has(name)) throw new DuplicateMigration(folder, name);\n\n\t\tfiles.set(name, join(folder, entry.name));\n\t}\n\n\treturn files;\n}\n\n/** A Kysely provider over one construct's folder. */\nexport function folderProvider(\n\tfolder: string,\n\traw: typeof sql,\n): MigrationProvider {\n\treturn {\n\t\tasync getMigrations() {\n\t\t\tconst migrations: Record<string, Migration> = {};\n\n\t\t\tfor (const [name, file] of await migrationFiles(folder)) {\n\t\t\t\tmigrations[name] =\n\t\t\t\t\textname(file) === '.sql'\n\t\t\t\t\t\t? await sqlMigration(file, raw)\n\t\t\t\t\t\t: await scriptMigration(file);\n\t\t\t}\n\n\t\t\treturn migrations;\n\t\t},\n\t};\n}\n\n/**\n * The seeds in a folder, loaded, in name order.\n *\n * Every one runs on every pass — there is no history to consult — so the order\n * is the only thing between two seeds where one reads what another writes.\n * Name them to sort that way.\n */\nexport async function loadSeeds(\n\tfolder: string,\n\traw: typeof sql,\n): Promise<Seed[]> {\n\tconst files = [...(await migrationFiles(folder))].sort(([a], [b]) =>\n\t\ta < b ? -1 : a > b ? 1 : 0,\n\t);\n\n\tconst seeds: Seed[] = [];\n\tfor (const [name, file] of files) {\n\t\tseeds.push({\n\t\t\tname,\n\t\t\trun:\n\t\t\t\textname(file) === '.sql'\n\t\t\t\t\t? (await sqlMigration(file, raw)).up\n\t\t\t\t\t: await scriptSeed(file),\n\t\t});\n\t}\n\n\treturn seeds;\n}\n\n/**\n * A seed script, imported as it is on disk now.\n *\n * Keyed by its modification time: a seed is run again after it is edited, and\n * a process that has imported it once would otherwise run the old one.\n */\nasync function scriptSeed(file: string): Promise<Seed['run']> {\n\tconst url = pathToFileURL(file);\n\turl.searchParams.set('mtime', String((await stat(file)).mtimeMs));\n\tconst module = (await import(url.href)) as { seed?: unknown };\n\tif (typeof module.seed !== 'function') throw new SeedHasNoSeed(file);\n\n\treturn module.seed as Seed['run'];\n}\n\nfunction isMigration(file: string): boolean {\n\tif (file.endsWith('.d.ts')) return false;\n\tif (/\\.(spec|test)\\.[cm]?[jt]s$/.test(file)) return false;\n\n\tconst extension = extname(file);\n\treturn extension === '.sql' || SCRIPTS.has(extension);\n}\n\nasync function scriptMigration(file: string): Promise<Migration> {\n\tconst module = (await import(pathToFileURL(file).href)) as Partial<Migration>;\n\tif (typeof module.up !== 'function') throw new MigrationHasNoUp(file);\n\n\treturn {\n\t\tup: module.up,\n\t\t...(typeof module.down === 'function' ? { down: module.down } : {}),\n\t};\n}\n\n/**\n * A `.sql` file, run whole.\n *\n * One query rather than split on `;`: with no parameters, Postgres takes\n * several statements in one message, and splitting by hand breaks on the first\n * `;` inside a string or a function body. There is no `down` — a generated\n * schema is rolled back by a migration that says how, not by guessing.\n */\nasync function sqlMigration(file: string, raw: typeof sql): Promise<Migration> {\n\tconst statements = await readFile(file, 'utf-8');\n\n\treturn {\n\t\tup: async (db: Kysely<unknown>) => {\n\t\t\tawait raw.raw(statements).execute(db);\n\t\t},\n\t};\n}\n","/**\n * The drivers a seed run registers before any seed runs.\n *\n * The seed runner is an entry point gkm owns, like the generated server and\n * the test harness, so it registers what they register — from the same\n * {@link driversFor}, so the two cannot drift. A seed then reaches a bucket or\n * a cache through the construct's service, exactly as a handler does, and no\n * application code names a provider.\n *\n * The registrations are written to a module under `.gkm/` and imported from\n * there, rather than imported by gkm itself: a registry is a module-level map,\n * so it has to be the copy the app's constructs resolve — which is the one a\n * bare specifier finds from the project root, not the one beside gkm.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { ConstructManifest } from '@geekmidas/manifest';\nimport { GkmError } from '../errors';\nimport {\n\tcacheBackendsIn,\n\tdriversFor,\n\teventsBackendsIn,\n} from '../generators/drivers';\nimport type { CacheBackend, EventsBackend } from '../types';\n\n/** Which backends the stage being seeded resolves its declarations to. */\nexport interface SeedBackends {\n\tcache: CacheBackend;\n\tevents: EventsBackend;\n}\n\n/** The drivers a seed run needs could not be loaded from the project. */\nexport class SeedDriversUnresolved extends GkmError {\n\tconstructor(\n\t\treadonly root: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Could not load the drivers seeds run with from ${root} — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t`They are the ones the app's own entry registers; install the ` +\n\t\t\t\t`package it names where the project's constructs are declared.`,\n\t\t);\n\t\tthis.name = 'SeedDriversUnresolved';\n\t}\n}\n\n/**\n * Register the drivers a generated entry for this project would: storage when\n * it installs `@geekmidas/storage`, the cache backend its caches resolve to,\n * and the broker its topics and queues do. Nothing when it declares none.\n */\nexport async function registerSeedDrivers(options: {\n\troot: string;\n\tmanifest: ConstructManifest;\n\tbackends: SeedBackends;\n}): Promise<void> {\n\tconst drivers = driversFor({\n\t\tappRoot: options.root,\n\t\tcache: cacheBackendsIn(options.manifest, options.backends.cache),\n\t\tevents: eventsBackendsIn(options.manifest, options.backends.events),\n\t});\n\tif (!drivers.setup) return;\n\n\tconst content = `${drivers.imports}\\n\\n${drivers.setup}\\n`;\n\tconst dir = join(options.root, '.gkm');\n\tconst file = join(dir, 'seed-drivers.mjs');\n\tawait mkdir(dir, { recursive: true });\n\tawait writeFile(file, content);\n\n\t// Keyed by content: registration is idempotent, but a process seeding\n\t// twice after the declarations changed must load the new set.\n\tconst url = pathToFileURL(file);\n\turl.searchParams.set(\n\t\t'v',\n\t\tcreateHash('sha256').update(content).digest('hex').slice(0, 12),\n\t);\n\n\ttry {\n\t\tawait import(url.href);\n\t} catch (error) {\n\t\tthrow new SeedDriversUnresolved(options.root, error);\n\t}\n}\n","/**\n * Bring each construct's schema up to its migrations folder.\n *\n * Which constructs, in what order, from which folder, is `migrationTargets`'\n * answer and nobody else's. What is decided here is only how one target is\n * run: as its owner, in its own schema, with a history of its own.\n */\n\nimport { readdir } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n\ttype ConstructManifest,\n\tcanonicalId,\n\tDATABASE_FOLDERS,\n\tMIGRATIONS_ROOT,\n\ttype MigrationTarget,\n\tmigrationTargets,\n\tprovideKey,\n} from '@geekmidas/manifest';\nimport type { Kysely, KyselyConfig } from 'kysely';\nimport type { Migrator } from 'kysely/migration';\nimport pg from 'pg';\nimport { GkmError } from '../errors';\nimport type { ConstructSource } from '../reconcile/discover';\nimport { folderProvider, loadSeeds, migrationFiles } from './provider';\nimport { registerSeedDrivers, type SeedBackends } from './seedDrivers';\n\nexport interface DatabasesOptions {\n\t/** The project root — where `db/` lives. */\n\troot: string;\n\tmanifest: ConstructManifest;\n\t/**\n\t * Where each construct was declared. A construct's migrations run with the\n\t * Kysely its own file resolves, which is the one its migrations import.\n\t */\n\tsources?: Readonly<Record<string, ConstructSource>>;\n\t/** The resolved environment: each construct's owner URL is read from it. */\n\tenv: Readonly<Record<string, string | undefined>>;\n\t/** One construct, by name. All of them when absent. */\n\tonly?: string;\n}\n\nexport interface MigrationRun {\n\ttarget: MigrationTarget;\n\t/** The migrations this run applied, in order. */\n\tapplied: string[];\n}\n\nexport interface SeedOptions extends DatabasesOptions {\n\t/** The stage being seeded, handed to every seed. */\n\tstage: string;\n\t/**\n\t * What the stage's caches and topics resolve to — which drivers a seed is\n\t * run with, as the stage's own entry would register them.\n\t */\n\tbackends: SeedBackends;\n}\n\nexport interface SeedRun {\n\ttarget: MigrationTarget;\n\t/** The seeds this run ran, in order — every one, every time. */\n\tseeded: string[];\n}\n\n/** The seeds a run would run for one construct, read without connecting. */\nexport interface PlannedSeeds {\n\ttarget: MigrationTarget;\n\t/** In the order they would run. */\n\tseeds: string[];\n}\n\nexport interface PendingMigrations {\n\ttarget: MigrationTarget;\n\tpending: string[];\n}\n\n/** A folder under `db/` that names no construct. */\nexport class UnknownMigrationFolder extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${folder} names no database construct, so its migrations would never ` +\n\t\t\t\t`run. ${known.length > 0 ? `The folders that do: ${known.join(', ')}.` : 'This project declares no database.'} ` +\n\t\t\t\t`Rename the folder after the construct it belongs to.`,\n\t\t);\n\t\tthis.name = 'UnknownMigrationFolder';\n\t}\n}\n\n/** A construct was asked for by a name that takes no migrations. */\nexport class NoSuchMigrationTarget extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly known: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`'${construct}' is not a database construct. ` +\n\t\t\t\t(known.length > 0\n\t\t\t\t\t? `The ones with migrations: ${known.join(', ')}.`\n\t\t\t\t\t: 'This project declares no database.'),\n\t\t);\n\t\tthis.name = 'NoSuchMigrationTarget';\n\t}\n}\n\n/**\n * A migration left directly in a construct's folder, where nothing reads it.\n *\n * Migrations moved into `migrations/` so seeds could sit beside them. A file\n * still at the old level would otherwise never run, and nothing would say so.\n */\nexport class MigrationsOutsideFolder extends GkmError {\n\tconstructor(\n\t\treadonly folder: string,\n\t\treadonly files: readonly string[],\n\t) {\n\t\tsuper(\n\t\t\t`${folder} has ${files.join(', ')} directly inside it, where nothing ` +\n\t\t\t\t`runs them. Migrations live in ${folder}/migrations/ and seeds in ` +\n\t\t\t\t`${folder}/seeds/ — move ${files.length === 1 ? 'it' : 'them'} there.`,\n\t\t);\n\t\tthis.name = 'MigrationsOutsideFolder';\n\t}\n}\n\n/** A folder inside a construct's folder that is neither `migrations` nor `seeds`. */\nexport class UnknownDatabaseFolder extends GkmError {\n\tconstructor(readonly folder: string) {\n\t\tsuper(\n\t\t\t`${folder} is neither migrations/ nor seeds/, so nothing in it would ` +\n\t\t\t\t`ever run. A construct's folder holds those two; rename or remove it.`,\n\t\t);\n\t\tthis.name = 'UnknownDatabaseFolder';\n\t}\n}\n\n/** A seed failed; its own writes are rolled back, the ones before it stay. */\nexport class SeedFailed extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}: seed '${seed}' failed — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}. ` +\n\t\t\t\t`Its writes were rolled back; fix it and run it again.`,\n\t\t);\n\t\tthis.name = 'SeedFailed';\n\t}\n}\n\n/** A construct with roles has no owner URL to migrate with. */\nexport class NoOwnerCredential extends GkmError {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct} has no ${key} to migrate with. Migrations run as the owner ` +\n\t\t\t\t`role — the runtime one cannot create a table — and nothing ` +\n\t\t\t\t`resolved its URL. Is the stage reconciled?`,\n\t\t);\n\t\tthis.name = 'NoOwnerCredential';\n\t}\n}\n\n/** A migration failed; the ones before it in the run stay applied. */\nexport class MigrationFailed extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly migration: string | undefined,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}: migration ${migration ? `'${migration}' ` : ''}failed — ` +\n\t\t\t\t`${cause instanceof Error ? cause.message : String(cause)}`,\n\t\t);\n\t\tthis.name = 'MigrationFailed';\n\t}\n}\n\n/** The project's Kysely could not be found from where a database is declared. */\nexport class KyselyNotFound extends GkmError {\n\tconstructor(readonly from: string) {\n\t\tsuper(\n\t\t\t`Could not resolve 'kysely' from ${from}. Migrations run with the ` +\n\t\t\t\t`project's own Kysely — install it where the database is declared.`,\n\t\t);\n\t\tthis.name = 'KyselyNotFound';\n\t}\n}\n\n/** Apply every pending migration, construct by construct, parents first. */\nexport async function migrateDatabases(\n\toptions: DatabasesOptions,\n): Promise<MigrationRun[]> {\n\tconst runs: MigrationRun[] = [];\n\n\tfor (const target of await targetsFor(options)) {\n\t\t// No folder, or an empty one, is nothing to do — and no reason to\n\t\t// connect, which a construct nobody has written a migration for yet\n\t\t// should not need.\n\t\tconst files = await migrationFiles(join(options.root, target.migrations));\n\t\tif (files.size === 0) {\n\t\t\truns.push({ target, applied: [] });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst applied = await withMigrator(options, target, async (migrator) => {\n\t\t\tconst { error, results = [] } = await migrator.migrateToLatest();\n\t\t\tif (error) {\n\t\t\t\tconst failed = results.find((result) => result.status === 'Error');\n\t\t\t\tthrow new MigrationFailed(target.id, failed?.migrationName, error);\n\t\t\t}\n\n\t\t\treturn results\n\t\t\t\t.filter((result) => result.status === 'Success')\n\t\t\t\t.map((result) => result.migrationName);\n\t\t});\n\n\t\truns.push({ target, applied });\n\t}\n\n\treturn runs;\n}\n\n/**\n * Run every construct's seeds, parents first — each one, every time, on every\n * stage, production included. Each is handed the stage, so a seed decides\n * what belongs where.\n *\n * Seeds are reference data kept up to date by being run again, so there is no\n * history: a seed is an upsert, and a changed one is applied by the next run.\n * Each runs in its own transaction, as the construct's owner, so a failure\n * leaves nothing half-written. Assumes the schema is migrated —\n * {@link migrateAndSeed} is what makes that true.\n *\n * A seed is handed the client the app gets — the construct's `clientConfig`,\n * plugins included — on the owner's connection. One written against\n * `Kysely<DB>` with a `CamelCasePlugin` writes `isEditable` here as it does in\n * a handler or a test.\n *\n * And with the drivers the stage's entry registers, so a seed reaching a\n * bucket or a cache through its construct gets the client a handler would.\n */\nexport async function seedDatabases(options: SeedOptions): Promise<SeedRun[]> {\n\tconst runs: SeedRun[] = [];\n\tlet registered = false;\n\n\tfor (const target of await targetsFor(options)) {\n\t\tconst folder = join(options.root, target.seeds);\n\t\tif ((await migrationFiles(folder)).size === 0) {\n\t\t\truns.push({ target, seeded: [] });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!registered) {\n\t\t\tawait registerSeedDrivers(options);\n\t\t\tregistered = true;\n\t\t}\n\n\t\tconst config = clientConfigOf(options, target);\n\t\tconst seeded = await withOwner(\n\t\t\toptions,\n\t\t\ttarget,\n\t\t\tconfig,\n\t\t\tasync (db, kysely) => {\n\t\t\t\tconst names: string[] = [];\n\t\t\t\tfor (const seed of await loadSeeds(folder, kysely.sql)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait db\n\t\t\t\t\t\t\t.transaction()\n\t\t\t\t\t\t\t.execute((trx) => seed.run(trx, { stage: options.stage }));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow new SeedFailed(target.id, seed.name, error);\n\t\t\t\t\t}\n\t\t\t\t\tnames.push(seed.name);\n\t\t\t\t}\n\t\t\t\treturn names;\n\t\t\t},\n\t\t);\n\n\t\truns.push({ target, seeded });\n\t}\n\n\treturn runs;\n}\n\n/**\n * The seeds {@link seedDatabases} would run, construct by construct, parents\n * first, in the order it would run them — read from the folders alone, with\n * no connection. What a dry run lists. Constructs with none are left out.\n */\nexport async function plannedSeeds(\n\toptions: Pick<DatabasesOptions, 'root' | 'manifest' | 'only'>,\n): Promise<PlannedSeeds[]> {\n\tconst planned: PlannedSeeds[] = [];\n\tfor (const target of await targetsFor(options)) {\n\t\tconst files = await migrationFiles(join(options.root, target.seeds));\n\t\tif (files.size === 0) continue;\n\t\tplanned.push({ target, seeds: [...files.keys()].sort() });\n\t}\n\treturn planned;\n}\n\n/**\n * Migrate, then seed: a seed only ever runs against the schema it was written\n * for.\n *\n * With `only`, the constructs it lives in are migrated too — a tenant's seed\n * cannot run before the database that owns its schema exists — and only it is\n * seeded.\n */\nexport async function migrateAndSeed(options: SeedOptions): Promise<{\n\tmigrations: MigrationRun[];\n\tseeds: SeedRun[];\n}> {\n\tconst migrations: MigrationRun[] = [];\n\tfor (const target of await withParents(options)) {\n\t\tmigrations.push(\n\t\t\t...(await migrateDatabases({ ...options, only: target.id })),\n\t\t);\n\t}\n\n\treturn { migrations, seeds: await seedDatabases(options) };\n}\n\n/** The targets `only` names, after the ones it lives in; all without it. */\nasync function withParents(\n\toptions: DatabasesOptions,\n): Promise<MigrationTarget[]> {\n\tconst chosen = await targetsFor(options);\n\tif (!options.only) return chosen;\n\n\tconst all = migrationTargets(options.manifest);\n\tconst ids = new Set<string>();\n\tfor (const target of chosen) {\n\t\tlet current: MigrationTarget | undefined = target;\n\t\twhile (current) {\n\t\t\tids.add(current.id);\n\t\t\tconst parent: string | undefined = current.of;\n\t\t\tcurrent = parent ? all.find((t) => t.id === parent) : undefined;\n\t\t}\n\t}\n\n\treturn all.filter((target) => ids.has(target.id));\n}\n\n/**\n * What each construct's folder has that its history does not — without\n * applying any of it. What `gkm dev` reports.\n */\nexport async function pendingMigrations(\n\toptions: DatabasesOptions,\n): Promise<PendingMigrations[]> {\n\tconst found: PendingMigrations[] = [];\n\n\tfor (const target of await targetsFor(options)) {\n\t\tconst files = await migrationFiles(join(options.root, target.migrations));\n\t\tif (files.size === 0) continue;\n\n\t\tconst pending = await withMigrator(options, target, async (migrator) =>\n\t\t\t(await migrator.getMigrations())\n\t\t\t\t.filter((migration) => migration.executedAt === undefined)\n\t\t\t\t.map((migration) => migration.name),\n\t\t);\n\n\t\tif (pending.length > 0) found.push({ target, pending });\n\t}\n\n\treturn found;\n}\n\n/**\n * The targets this run covers, with every folder under `db/` accounted for.\n *\n * A folder that names no construct is an error rather than something to skip:\n * a typo in its name is otherwise a migration that silently never runs.\n */\nasync function targetsFor(\n\toptions: Pick<DatabasesOptions, 'root' | 'manifest' | 'only'>,\n): Promise<MigrationTarget[]> {\n\tconst targets = migrationTargets(options.manifest);\n\tconst folders = targets.map((target) => target.folder);\n\n\tfor (const folder of await foldersIn(join(options.root, MIGRATIONS_ROOT))) {\n\t\tconst relative = `${MIGRATIONS_ROOT}/${folder}`;\n\t\tif (!folders.includes(relative)) {\n\t\t\tthrow new UnknownMigrationFolder(relative, folders);\n\t\t}\n\t\tawait checkLayout(options.root, relative);\n\t}\n\n\tif (!options.only) return targets;\n\n\tconst id = canonicalId(options.only);\n\tconst chosen = targets.filter((target) => target.id === id);\n\tif (chosen.length === 0) {\n\t\tthrow new NoSuchMigrationTarget(\n\t\t\toptions.only,\n\t\t\ttargets.map((target) => target.id),\n\t\t);\n\t}\n\n\treturn chosen;\n}\n\n/**\n * A construct's folder holds `migrations/` and `seeds/`, and nothing else —\n * anything beside them is a file or folder nothing would ever run.\n */\nasync function checkLayout(root: string, folder: string): Promise<void> {\n\tconst entries = await readdir(join(root, folder), { withFileTypes: true });\n\n\tconst loose = entries\n\t\t.filter((entry) => entry.isFile() && !entry.name.startsWith('.'))\n\t\t.map((entry) => entry.name);\n\tif (loose.length > 0) throw new MigrationsOutsideFolder(folder, loose);\n\n\tfor (const entry of entries) {\n\t\tif (\n\t\t\tentry.isDirectory() &&\n\t\t\t!(DATABASE_FOLDERS as readonly string[]).includes(entry.name)\n\t\t) {\n\t\t\tthrow new UnknownDatabaseFolder(`${folder}/${entry.name}`);\n\t\t}\n\t}\n}\n\nasync function foldersIn(dir: string): Promise<string[]> {\n\tconst entries = await readdir(dir, { withFileTypes: true }).catch(\n\t\t(error: NodeJS.ErrnoException) => {\n\t\t\tif (error.code === 'ENOENT') return [];\n\t\t\tthrow error;\n\t\t},\n\t);\n\n\treturn entries\n\t\t.filter((entry) => entry.isDirectory())\n\t\t.map((entry) => entry.name);\n}\n\n/**\n * A migrator for one target, connected as its owner.\n *\n * No `migrationTableSchema`: the owner role's `search_path` is pinned to the\n * construct's schema, so the history lands there — `app.kysely_migration` for\n * the database, `auth_database.kysely_migration` for its tenant — and two\n * constructs in one Postgres never share one.\n *\n * Unordered migrations are allowed. Files are timestamped, so a branch merged\n * after another's migration ran carries an older one; refusing it would make\n * every such merge a manual repair.\n *\n * The client is bare — none of the construct's plugins. A casing plugin\n * rewrites identifiers in schema-builder DDL too, and a migration must do the\n * same thing forever after it has run, so it cannot depend on configuration\n * that may change.\n */\nasync function withMigrator<T>(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n\trun: (migrator: Migrator) => Promise<T>,\n): Promise<T> {\n\treturn withOwner(options, target, {}, (db, { Migrator, sql }) =>\n\t\trun(\n\t\t\tnew Migrator({\n\t\t\t\tdb,\n\t\t\t\tprovider: folderProvider(join(options.root, target.migrations), sql),\n\t\t\t\tallowUnorderedMigrations: true,\n\t\t\t}),\n\t\t),\n\t);\n}\n\n/**\n * One target's database, connected as its owner and closed afterwards — what\n * migrations and seeds both run as, each with the client config it needs.\n */\nasync function withOwner<T>(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n\tconfig: Omit<KyselyConfig, 'dialect'>,\n\trun: (\n\t\tdb: Kysely<unknown>,\n\t\tkysely: Awaited<ReturnType<typeof kyselyFrom>>,\n\t) => Promise<T>,\n): Promise<T> {\n\tconst from =\n\t\toptions.sources?.[target.id]?.file ??\n\t\t(target.of ? options.sources?.[target.of]?.file : undefined) ??\n\t\tjoin(options.root, 'package.json');\n\tconst kysely = await kyselyFrom(from);\n\n\tconst db: Kysely<unknown> = new kysely.Kysely<unknown>({\n\t\t...config,\n\t\tdialect: new kysely.PostgresDialect({\n\t\t\tpool: new pg.Pool(poolConfig(ownerUrl(options, target))),\n\t\t}),\n\t});\n\n\ttry {\n\t\treturn await run(db, kysely);\n\t} finally {\n\t\tawait db.destroy();\n\t}\n}\n\n/**\n * What the construct builds its clients with besides a dialect — its plugins\n * and logging — read from the construct discovery already imported.\n *\n * A tenant's is its own: `database.schema('Auth', { plugins })` declares the\n * client for its tables, not the parent's. With no construct to ask (a\n * manifest without sources), the client is bare.\n */\nfunction clientConfigOf(\n\toptions: DatabasesOptions,\n\ttarget: MigrationTarget,\n): Omit<KyselyConfig, 'dialect'> {\n\tconst construct = options.sources?.[target.id]?.construct;\n\tif (typeof construct !== 'object' || construct === null) return {};\n\tif (!('clientConfig' in construct)) return {};\n\treturn (construct.clientConfig as Omit<KyselyConfig, 'dialect'>) ?? {};\n}\n\n/**\n * The owner's URL, with no fallback to the runtime one.\n *\n * The runtime role can create nothing, so falling back would only move the\n * failure to the first `CREATE TABLE` and make it read like a permissions\n * bug. The one exception is a database declared `roles: false`, where there is\n * no owner — both URLs are the master credential by design.\n */\nfunction ownerUrl(options: DatabasesOptions, target: MigrationTarget): string {\n\tconst key = provideKey(target.id, 'ownerUrl');\n\tconst owner = options.env[key];\n\tif (owner) return owner;\n\n\tconst database = options.manifest[target.of ?? target.id];\n\tif (database?.kind === 'database' && database.roles === false) {\n\t\tconst url = options.env[provideKey(target.id, 'url')];\n\t\tif (url) return url;\n\t}\n\n\tthrow new NoOwnerCredential(target.id, key);\n}\n\n/**\n * Pool settings for a URL, with `?search_path=` as the startup option Postgres\n * reads. Only a `roles: false` URL carries it — a role pins its own.\n */\nfunction poolConfig(url: string): pg.PoolConfig {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\tif (!searchPath) return { connectionString: url };\n\n\tparsed.searchParams.delete('search_path');\n\treturn {\n\t\tconnectionString: parsed.toString(),\n\t\toptions: `-c search_path=${searchPath}`,\n\t};\n}\n\n/** Kysely as the project resolves it from `from`. */\nasync function kyselyFrom(from: string) {\n\tconst require = createRequire(from);\n\n\ttry {\n\t\tconst [main, migration] = await Promise.all([\n\t\t\timport(pathToFileURL(require.resolve('kysely')).href),\n\t\t\timport(pathToFileURL(require.resolve('kysely/migration')).href),\n\t\t]);\n\n\t\treturn {\n\t\t\tKysely: main.Kysely as typeof import('kysely').Kysely,\n\t\t\tPostgresDialect:\n\t\t\t\tmain.PostgresDialect as typeof import('kysely').PostgresDialect,\n\t\t\tsql: main.sql as typeof import('kysely').sql,\n\t\t\tMigrator:\n\t\t\t\tmigration.Migrator as typeof import('kysely/migration').Migrator,\n\t\t};\n\t} catch {\n\t\tthrow new KyselyNotFound(from);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,0BAAU,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAO;AAAM,CAAC;;AAGtD,IAAa,qBAAb,cAAwCA,eAAAA,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V,UACC,UAAU;EACZ;CACD,QAAQ;EACP,MAAM,IAAI,eAAe,IAAI;CAC9B;AACD"}
@@ -3,17 +3,17 @@ const require_errors = require("../errors-DMC4Umsb.cjs");
3
3
  const require_credentials = require("../credentials-D7XJypNd.cjs");
4
4
  const require_workspace = require("../workspace-Du4Afb03.cjs");
5
5
  const require_define = require("../define-crmMcXFS.cjs");
6
- const require_seeds = require("../seeds-CPEcmoPn.cjs");
6
+ const require_seeds = require("../seeds-3awh33Wz.cjs");
7
7
  const require_identity = require("../identity-CbLfgQNT.cjs");
8
8
  const require_discover = require("../discover-DL6h-J97.cjs");
9
9
  const require_sandbox = require("../sandbox-CHv3OYXg.cjs");
10
10
  const require_config = require("../config.cjs");
11
- const require_resolve = require("../resolve-C9QqOl5t.cjs");
11
+ const require_resolve = require("../resolve-zqCMFio0.cjs");
12
12
  const require_local = require("../local-OPC9BCZt.cjs");
13
- const require_sniffer = require("../sniffer-DdX_WN_-.cjs");
14
- const require_deploy = require("../deploy-DVrNjX1X.cjs");
15
- const require_engine = require("../engine-CuZUGbEh.cjs");
16
- const require_rollback = require("../rollback-CTWdDBgB.cjs");
13
+ const require_sniffer = require("../sniffer-Cq1nhxIB.cjs");
14
+ const require_deploy = require("../deploy-wSlIRPn5.cjs");
15
+ const require_engine = require("../engine-Dqe9KQCm.cjs");
16
+ const require_rollback = require("../rollback-qc79mj6L.cjs");
17
17
  const require_provider = require("../provider-BqpjG9QM.cjs");
18
18
  const require_sst = require("../sst-lEkBwzGc.cjs");
19
19
  let node_path = require("node:path");
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.cts","names":[],"sources":["../../src/home.ts","../../src/providers/types.ts","../../src/providers/config.ts","../../src/deploy/devServices.ts","../../src/providers/notes.ts","../../src/providers/s3/errors.ts","../../src/run.ts","../../src/sandbox/env.ts","../../src/docker/templates.ts","../../src/sandbox/install.ts","../../src/sandbox/local.ts","../../src/sandbox/worker.ts","../../src/target/dokploy/dokploy-api.ts","../../src/target/dokploy/engine.ts","../../src/target/dokploy/health.ts","../../src/target/dokploy/migrations.ts","../../src/target/dokploy/rollback.ts","../../src/target/seeds.ts","../../src/target/sst/health.ts","../../src/target/sst/outputs.ts","../../src/target/sst/index.ts","../../src/deploy/deploy.ts","../../src/deploy/orchestrate.ts","../../src/deploy/ownership.ts","../../src/deploy/registry.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAaa;;wBAGG,QAAQ,MAAK,OAAO;;;;cCavB;KAED,uBAAuB;;;;qBC6BtB,6BAA6B;WAE/B,MAAM;WACN;WACA;EAHV,YACU,MAAM,cACN,eACA;;;;;;;;;qBCpBE;KAED,qBAAqB;;qBAcpB,oCAAoC;WAC3B;EAArB,YAAqB;;;;;;;qBAeT,qCAAqC;WAC5B;EAArB,YAAqB;;;UAiCL;EAChB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,UAAU;;EAEV;;EAEA;;;;;;qBAOY,sCAAsC;WAExC;WACA,kBAAkB;EAF5B,YACU,eACA,kBAAkB;;;;;qBCjHhB,8BAA8B;WAEhC,MAAM;WACN;WACA;EAHV,YACU,MAAM,cACN,eACA;;;;;qBCyHE,qCAAqC;WAEvC;WACA;WACA;WACA;EAJV,YACU,YACA,gBACA,eACA;;;;;qBCjHE,sBAAsB;WAExB;WACA;WACA;WACA,QAAQ,OAAO;EAJzB,YACU,iBACA,yBACA,yBACA,QAAQ,OAAO;;;qBAUb,wBAAwB;WAE1B;WACA;WACA;EAHV,YACU,iBACA,yBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBC3BE,0CAA0C;;;;;wBAyDvC,eACf,SAAQ,OAAO,YACf,4BACE;;;KClFS;;;;qBCWC;UAEI;;EAEhB;;EAEA,iBAAiB;;;;;;;EAOjB;;;;;EAKA;;EAEA,MAAM,SAAS;;EAEf;;EAEA,SAAS;EACT,SAAS;;;qBAIG,oCAAoC;WAC3B;EAArB,YAAqB;;;qBAWT,2CAA2C;WAE7C;WACA;EAFV,YACU,wBACA;;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R;IACA;IACA;IACA;;EAPF,YACU,eAEA;;EAAA;IACR;IACA;IACA;IACA;;;;;;qBCZU,6BAA6B;WAE/B;WACA;EAFV,YACU,cACA;;;;;qBC2BE,0BAA0B;WACjB;EAArB,YAAqB;;;;;;;;UCtBL;EAChB,KAAK;EACL,KAAK;EACL,OAAO;;UAGS;;;;;EAKhB;;;;;EAKA;;;;;EAKA;;;;;;EAMA,UAAU,eAAe;;EAEzB;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,cAAc;;;;;;;;;;EAUd;;;;;;EAMA;;EAEA;;EAEA;;EAEA,SAAS;;;;;;EAMT,SAAS;;;;;EAKT;;;;;EAKA;;;;;;;;;;;;EAYA,UAAU;;;UAIM,kBAAkB,cAAc;;;;;;WAMvC,QAAQ,QAAQ;;;;;;;;;;;;;;;;;;wBAqEV,OAAO,OAAO,cAAc;;;;qBC/G/B,0BAA0B;WAE5B;WACA;EAFV,YACU,yBACA;;;qBAWE,yBAAyB;WAE3B;WACA;EAFV,YACU,eACA;;;qBAUE,4BAA4B;WACnB;EAArB,YAAqB;;;qBAST,uBAAuB;WAEzB;;WAEA;EAHV,YACU,gBAEA;;EAAA,kBACT;;;;;;;;qBCpHW,wBAAwB;WAE1B;WACA;WACA;;WAEA;EALV,YACU,qBACA,mBACA,kBAEA;;EAAA;;;;;qBChBE,8BAA8B;WACrB;EAArB,YAAqB;;;qBAUT,yBAAyB;WAChB;EAArB,YAAqB;;;qBAUT,0BAA0B;WAE5B;WACA;EAFV,YACU,kBACA"}
1
+ {"version":3,"file":"public.d.cts","names":[],"sources":["../../src/home.ts","../../src/providers/types.ts","../../src/providers/config.ts","../../src/deploy/devServices.ts","../../src/providers/notes.ts","../../src/providers/s3/errors.ts","../../src/run.ts","../../src/sandbox/env.ts","../../src/docker/templates.ts","../../src/sandbox/install.ts","../../src/sandbox/local.ts","../../src/sandbox/worker.ts","../../src/target/dokploy/dokploy-api.ts","../../src/target/dokploy/engine.ts","../../src/target/dokploy/health.ts","../../src/target/dokploy/migrations.ts","../../src/target/dokploy/rollback.ts","../../src/target/seeds.ts","../../src/target/sst/health.ts","../../src/target/sst/outputs.ts","../../src/target/sst/index.ts","../../src/deploy/deploy.ts","../../src/deploy/orchestrate.ts","../../src/deploy/ownership.ts","../../src/deploy/registry.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAaa;;wBAGG,QAAQ,MAAK,OAAO;;;;cCavB;KAED,uBAAuB;;;;qBC6BtB,6BAA6B;WAE/B,MAAM;WACN;WACA;EAHV,YACU,MAAM,cACN,eACA;;;;;;;;;qBCpBE;KAED,qBAAqB;;qBAcpB,oCAAoC;WAC3B;EAArB,YAAqB;;;;;;;qBAeT,qCAAqC;WAC5B;EAArB,YAAqB;;;UAiCL;EAChB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,UAAU;;EAEV;;EAEA;;;;;;qBAOY,sCAAsC;WAExC;WACA,kBAAkB;EAF5B,YACU,eACA,kBAAkB;;;;;qBCjHhB,8BAA8B;WAEhC,MAAM;WACN;WACA;EAHV,YACU,MAAM,cACN,eACA;;;;;qBCyHE,qCAAqC;WAEvC;WACA;WACA;WACA;EAJV,YACU,YACA,gBACA,eACA;;;;;qBCjHE,sBAAsB;WAExB;WACA;WACA;WACA,QAAQ,OAAO;EAJzB,YACU,iBACA,yBACA,yBACA,QAAQ,OAAO;;;qBAUb,wBAAwB;WAE1B;WACA;WACA;EAHV,YACU,iBACA,yBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBC3BE,0CAA0C;;;;;wBAyDvC,eACf,SAAQ,OAAO,YACf,4BACE;;;KClFS;;;;qBCWC;UAEI;;EAEhB;;EAEA,iBAAiB;;;;;;;EAOjB;;;;;EAKA;;EAEA,MAAM,SAAS;;EAEf;;EAEA,SAAS;EACT,SAAS;;;qBAIG,oCAAoC;WAC3B;EAArB,YAAqB;;;qBAWT,2CAA2C;WAE7C;WACA;EAFV,YACU,wBACA;;;;;;;;;;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A;IACA;;EAPF,YACU,eAEA;;EAAA;IACR;IACA;IACA;IACA;;;;;;qBCZU,6BAA6B;WAE/B;WACA;EAFV,YACU,cACA;;;;;qBC2BE,0BAA0B;WACjB;EAArB,YAAqB;;;;;;;;UCtBL;EAChB,KAAK;EACL,KAAK;EACL,OAAO;;UAGS;;;;;EAKhB;;;;;EAKA;;;;;EAKA;;;;;;EAMA,UAAU,eAAe;;EAEzB;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,cAAc;;;;;;;;;;EAUd;;;;;;EAMA;;EAEA;;EAEA;;EAEA,SAAS;;;;;;EAMT,SAAS;;;;;EAKT;;;;;EAKA;;;;;;;;;;;;EAYA,UAAU;;;UAIM,kBAAkB,cAAc;;;;;;WAMvC,QAAQ,QAAQ;;;;;;;;;;;;;;;;;;wBAqEV,OAAO,OAAO,cAAc;;;;qBC/G/B,0BAA0B;WAE5B;WACA;EAFV,YACU,yBACA;;;qBAWE,yBAAyB;WAE3B;WACA;EAFV,YACU,eACA;;;qBAUE,4BAA4B;WACnB;EAArB,YAAqB;;;qBAST,uBAAuB;WAEzB;;WAEA;EAHV,YACU,gBAEA;;EAAA,kBACT;;;;;;;;qBCpHW,wBAAwB;WAE1B;WACA;WACA;;WAEA;EALV,YACU,qBACA,mBACA,kBAEA;;EAAA;;;;;qBChBE,8BAA8B;WACrB;EAArB,YAAqB;;;qBAUT,yBAAyB;WAChB;EAArB,YAAqB;;;qBAUT,0BAA0B;WAE5B;WACA;EAFV,YACU,kBACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.mts","names":[],"sources":["../../src/home.ts","../../src/providers/types.ts","../../src/providers/config.ts","../../src/deploy/devServices.ts","../../src/providers/notes.ts","../../src/providers/s3/errors.ts","../../src/run.ts","../../src/sandbox/env.ts","../../src/docker/templates.ts","../../src/sandbox/install.ts","../../src/sandbox/local.ts","../../src/sandbox/worker.ts","../../src/target/dokploy/dokploy-api.ts","../../src/target/dokploy/engine.ts","../../src/target/dokploy/health.ts","../../src/target/dokploy/migrations.ts","../../src/target/dokploy/rollback.ts","../../src/target/seeds.ts","../../src/target/sst/health.ts","../../src/target/sst/outputs.ts","../../src/target/sst/index.ts","../../src/deploy/deploy.ts","../../src/deploy/orchestrate.ts","../../src/deploy/ownership.ts","../../src/deploy/registry.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAaa;;wBAGG,QAAQ,MAAK,OAAO;;;;cCavB;KAED,uBAAuB;;;;qBC6BtB,6BAA6B;WAE/B,MAAM;WACN;WACA;EAHV,YACU,MAAM,cACN,eACA;;;;;;;;;qBCpBE;KAED,qBAAqB;;qBAcpB,oCAAoC;WAC3B;EAArB,YAAqB;;;;;;;qBAeT,qCAAqC;WAC5B;EAArB,YAAqB;;;UAiCL;EAChB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,UAAU;;EAEV;;EAEA;;;;;;qBAOY,sCAAsC;WAExC;WACA,kBAAkB;EAF5B,YACU,eACA,kBAAkB;;;;;qBCjHhB,8BAA8B;WAEhC,MAAM;WACN;WACA;EAHV,YACU,MAAM,cACN,eACA;;;;;qBCyHE,qCAAqC;WAEvC;WACA;WACA;WACA;EAJV,YACU,YACA,gBACA,eACA;;;;;qBCjHE,sBAAsB;WAExB;WACA;WACA;WACA,QAAQ,OAAO;EAJzB,YACU,iBACA,yBACA,yBACA,QAAQ,OAAO;;;qBAUb,wBAAwB;WAE1B;WACA;WACA;EAHV,YACU,iBACA,yBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBC3BE,0CAA0C;;;;;wBAyDvC,eACf,SAAQ,OAAO,YACf,4BACE;;;KClFS;;;;qBCWC;UAEI;;EAEhB;;EAEA,iBAAiB;;;;;;;EAOjB;;;;;EAKA;;EAEA,MAAM,SAAS;;EAEf;;EAEA,SAAS;EACT,SAAS;;;qBAIG,oCAAoC;WAC3B;EAArB,YAAqB;;;qBAWT,2CAA2C;WAE7C;WACA;EAFV,YACU,wBACA;;;;;;;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;IACA;IACA;;EAPF,YACU,eAEA;;EAAA;IACR;IACA;IACA;IACA;;;;;;qBCZU,6BAA6B;WAE/B;WACA;EAFV,YACU,cACA;;;;;qBC2BE,0BAA0B;WACjB;EAArB,YAAqB;;;;;;;;UCtBL;EAChB,KAAK;EACL,KAAK;EACL,OAAO;;UAGS;;;;;EAKhB;;;;;EAKA;;;;;EAKA;;;;;;EAMA,UAAU,eAAe;;EAEzB;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,cAAc;;;;;;;;;;EAUd;;;;;;EAMA;;EAEA;;EAEA;;EAEA,SAAS;;;;;;EAMT,SAAS;;;;;EAKT;;;;;EAKA;;;;;;;;;;;;EAYA,UAAU;;;UAIM,kBAAkB,cAAc;;;;;;WAMvC,QAAQ,QAAQ;;;;;;;;;;;;;;;;;;wBAqEV,OAAO,OAAO,cAAc;;;;qBC/G/B,0BAA0B;WAE5B;WACA;EAFV,YACU,yBACA;;;qBAWE,yBAAyB;WAE3B;WACA;EAFV,YACU,eACA;;;qBAUE,4BAA4B;WACnB;EAArB,YAAqB;;;qBAST,uBAAuB;WAEzB;;WAEA;EAHV,YACU,gBAEA;;EAAA,kBACT;;;;;;;;qBCpHW,wBAAwB;WAE1B;WACA;WACA;;WAEA;EALV,YACU,qBACA,mBACA,kBAEA;;EAAA;;;;;qBChBE,8BAA8B;WACrB;EAArB,YAAqB;;;qBAUT,yBAAyB;WAChB;EAArB,YAAqB;;;qBAUT,0BAA0B;WAE5B;WACA;EAFV,YACU,kBACA"}
1
+ {"version":3,"file":"public.d.mts","names":[],"sources":["../../src/home.ts","../../src/providers/types.ts","../../src/providers/config.ts","../../src/deploy/devServices.ts","../../src/providers/notes.ts","../../src/providers/s3/errors.ts","../../src/run.ts","../../src/sandbox/env.ts","../../src/docker/templates.ts","../../src/sandbox/install.ts","../../src/sandbox/local.ts","../../src/sandbox/worker.ts","../../src/target/dokploy/dokploy-api.ts","../../src/target/dokploy/engine.ts","../../src/target/dokploy/health.ts","../../src/target/dokploy/migrations.ts","../../src/target/dokploy/rollback.ts","../../src/target/seeds.ts","../../src/target/sst/health.ts","../../src/target/sst/outputs.ts","../../src/target/sst/index.ts","../../src/deploy/deploy.ts","../../src/deploy/orchestrate.ts","../../src/deploy/ownership.ts","../../src/deploy/registry.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAaa;;wBAGG,QAAQ,MAAK,OAAO;;;;cCavB;KAED,uBAAuB;;;;qBC6BtB,6BAA6B;WAE/B,MAAM;WACN;WACA;EAHV,YACU,MAAM,cACN,eACA;;;;;;;;;qBCpBE;KAED,qBAAqB;;qBAcpB,oCAAoC;WAC3B;EAArB,YAAqB;;;;;;;qBAeT,qCAAqC;WAC5B;EAArB,YAAqB;;;UAiCL;EAChB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,UAAU;;EAEV;;EAEA;;;;;;qBAOY,sCAAsC;WAExC;WACA,kBAAkB;EAF5B,YACU,eACA,kBAAkB;;;;;qBCjHhB,8BAA8B;WAEhC,MAAM;WACN;WACA;EAHV,YACU,MAAM,cACN,eACA;;;;;qBCyHE,qCAAqC;WAEvC;WACA;WACA;WACA;EAJV,YACU,YACA,gBACA,eACA;;;;;qBCjHE,sBAAsB;WAExB;WACA;WACA;WACA,QAAQ,OAAO;EAJzB,YACU,iBACA,yBACA,yBACA,QAAQ,OAAO;;;qBAUb,wBAAwB;WAE1B;WACA;WACA;EAHV,YACU,iBACA,yBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBC3BE,0CAA0C;;;;;wBAyDvC,eACf,SAAQ,OAAO,YACf,4BACE;;;KClFS;;;;qBCWC;UAEI;;EAEhB;;EAEA,iBAAiB;;;;;;;EAOjB;;;;;EAKA;;EAEA,MAAM,SAAS;;EAEf;;EAEA,SAAS;EACT,SAAS;;;qBAIG,oCAAoC;WAC3B;EAArB,YAAqB;;;qBAWT,2CAA2C;WAE7C;WACA;EAFV,YACU,wBACA;;;;;;;;;;;;;;;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;;EAPF,YACU,eAEA;;EAAA;IACR;IACA;IACA;IACA;;;;;;qBCZU,6BAA6B;WAE/B;WACA;EAFV,YACU,cACA;;;;;qBC2BE,0BAA0B;WACjB;EAArB,YAAqB;;;;;;;;UCtBL;EAChB,KAAK;EACL,KAAK;EACL,OAAO;;UAGS;;;;;EAKhB;;;;;EAKA;;;;;EAKA;;;;;;EAMA,UAAU,eAAe;;EAEzB;;EAEA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,cAAc;;;;;;;;;;EAUd;;;;;;EAMA;;EAEA;;EAEA;;EAEA,SAAS;;;;;;EAMT,SAAS;;;;;EAKT;;;;;EAKA;;;;;;;;;;;;EAYA,UAAU;;;UAIM,kBAAkB,cAAc;;;;;;WAMvC,QAAQ,QAAQ;;;;;;;;;;;;;;;;;;wBAqEV,OAAO,OAAO,cAAc;;;;qBC/G/B,0BAA0B;WAE5B;WACA;EAFV,YACU,yBACA;;;qBAWE,yBAAyB;WAE3B;WACA;EAFV,YACU,eACA;;;qBAUE,4BAA4B;WACnB;EAArB,YAAqB;;;qBAST,uBAAuB;WAEzB;;WAEA;EAHV,YACU,gBAEA;;EAAA,kBACT;;;;;;;;qBCpHW,wBAAwB;WAE1B;WACA;WACA;;WAEA;EALV,YACU,qBACA,mBACA,kBAEA;;EAAA;;;;;qBChBE,8BAA8B;WACrB;EAArB,YAAqB;;;qBAUT,yBAAyB;WAChB;EAArB,YAAqB;;;qBAUT,0BAA0B;WAE5B;WACA;EAFV,YACU,kBACA"}
@@ -2,17 +2,17 @@ import { t as GkmError } from "../errors-D8Gwp5kU.mjs";
2
2
  import { a as CommandTimedOut, b as GKM_HOME_ENV, i as CommandFailed, n as chainCredentials, r as storedCredentials, t as MissingCredential, x as gkmHome } from "../credentials-DpfnUvIR.mjs";
3
3
  import { V as UnknownStageProvider, et as ProvisionedBucketUnreachable } from "../workspace-DBHF9Gba.mjs";
4
4
  import { a as UnknownDeployTarget, i as DeployTargetNotYetSupported } from "../define-6poNqm5O.mjs";
5
- import { A as StageProviderDisabled, at as AllowDevServicesTakesNoValue, cn as detectPackageManager, ct as ExternalServicesNotConfigured, ot as DEV_SERVICES, st as DevServicesNeedServerTarget, t as DeploySeedsFailed } from "../seeds-CK7w79VC.mjs";
5
+ import { A as StageProviderDisabled, at as AllowDevServicesTakesNoValue, cn as detectPackageManager, ct as ExternalServicesNotConfigured, ot as DEV_SERVICES, st as DevServicesNeedServerTarget, t as DeploySeedsFailed } from "../seeds-Cfejy8wj.mjs";
6
6
  import { n as deployIdentity } from "../identity-CBXr4wNi.mjs";
7
7
  import { n as ConstructsNotSerializable, s as SandboxWorkerFailed, t as ConstructDiscoveryFailed } from "../discover-CzGM5P3p.mjs";
8
8
  import { n as SandboxCwdEscape, o as confineCwd, r as SecretNameInvalid, t as SECRETS_DIR_ENV } from "../sandbox-CbVB7uOD.mjs";
9
9
  import { ConfigLoadFailed, ConfigObjectNotSerializable } from "../config.mjs";
10
- import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-BCU9pYDx.mjs";
10
+ import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-fCGJmM-R.mjs";
11
11
  import { n as SANDBOX_ENV_ALLOWLIST, r as allowlistedEnv, t as LocalSandbox } from "../local-B7Zv1NoA.mjs";
12
- import { a as DeploymentTimedOut, f as StateLocked, g as StateVersionConflict, i as DeploymentFailed, u as LocalStateInCi } from "../sniffer-g9v7cqDN.mjs";
13
- import { a as UnknownDeployApps, i as TargetBuildsNothing, n as NoDeployableApps, r as RollbackFailed, t as deploy } from "../deploy-D8pUA9Y0.mjs";
14
- import { _ as RegistryNotConfigured, g as RegistryAmbiguous, h as HealthCheckTimedOut, m as DeployMigrationsFailed, n as FrontendDeployFailed, r as MissingEnvVars, t as BackendDeployFailed, v as RegistryNotFound, y as ProjectNotOwned } from "../engine-CFOR9h6X.mjs";
15
- import { i as rollbackStage, n as RollbackNeedsApp, r as StageNeverDeployed, t as NothingToRollBack } from "../rollback-CWyyTQ0B.mjs";
12
+ import { a as DeploymentTimedOut, f as StateLocked, g as StateVersionConflict, i as DeploymentFailed, u as LocalStateInCi } from "../sniffer-CCkdzjiU.mjs";
13
+ import { a as UnknownDeployApps, i as TargetBuildsNothing, n as NoDeployableApps, r as RollbackFailed, t as deploy } from "../deploy-CIPwTJ47.mjs";
14
+ import { _ as RegistryNotConfigured, g as RegistryAmbiguous, h as HealthCheckTimedOut, m as DeployMigrationsFailed, n as FrontendDeployFailed, r as MissingEnvVars, t as BackendDeployFailed, v as RegistryNotFound, y as ProjectNotOwned } from "../engine-_0pjyCd_.mjs";
15
+ import { i as rollbackStage, n as RollbackNeedsApp, r as StageNeverDeployed, t as NothingToRollBack } from "../rollback-BkhVrtAf.mjs";
16
16
  import { t as ProviderRemoved } from "../provider-CEOKk8NS.mjs";
17
17
  import { i as SurfacesUnhealthy, r as SstOutputsUnreadable, t as SstConfigNotFound } from "../sst-CTqZZl1_.mjs";
18
18
  import { join, resolve } from "node:path";
@@ -1,18 +1,18 @@
1
1
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
2
2
  import { r as storedCredentials, x as gkmHome } from "./credentials-DpfnUvIR.mjs";
3
3
  import { $ as IamUserNotOwned, G as checkS3Config, J as BucketNameUnavailable, K as AccessKeyLimit, L as resolveStageTelemetry, N as assertDeployedStage, Q as BucketRegionUnknown, U as stageProvider, W as S3_PROVISIONING, X as BucketProbeFailed, Y as BucketOwnedByAnotherProject, Z as BucketRegionMismatch, et as ProvisionedBucketUnreachable, ht as isReservedStageKey, nt as RotationInProgress, q as BucketKeySetElsewhere, rt as S3RegionRequired, tt as RecordedBucketUnreachable, u as getAppBuildOrder } from "./workspace-DBHF9Gba.mjs";
4
- import { D as BACKUPS_SERVICE, I as backupsPrefix, O as BACKUPS_URL_KEY, P as backupExpiries, R as stageBackups, S as assertSitePasswordTarget, _ as stageDnsDomains, a as subscriptionKey, b as awsEndpoint, d as recordTtl, l as dnsCredentials, m as settleStackDns, o as subscriptionResource, x as awsProvisioningCredentials, y as awsClientConfig, z as deploysWithCompose } from "./snsSubscriptions-BmYeeTH8.mjs";
4
+ import { D as BACKUPS_SERVICE, I as backupsPrefix, O as BACKUPS_URL_KEY, P as backupExpiries, R as stageBackups, S as assertSitePasswordTarget, _ as stageDnsDomains, a as subscriptionKey, b as awsEndpoint, d as recordTtl, l as dnsCredentials, m as settleStackDns, o as subscriptionResource, x as awsProvisioningCredentials, y as awsClientConfig, z as deploysWithCompose } from "./snsSubscriptions-R_AKBZYK.mjs";
5
5
  import { o as builtinTarget } from "./define-6poNqm5O.mjs";
6
- import { $ as ORIGIN_VERIFY_HEADER, En as mergeLifecycle, N as stageProviderNotes, P as PROVIDER_KINDS, Qt as initStageSecrets, Yt as secretsStoreFor, _t as appEnvKeys, br as resolveHost, ct as ExternalServicesNotConfigured, d as DeployJournal, dt as devServicesUsed, er as usesTelemetry, f as extractSubdomain, ft as externalServices, ht as stageServiceDeclarations, j as assertStageProvidersEnabled, m as normalizeDnsConfig, nt as originSecretKey, p as findRootDomain, pt as reportDevServices, rt as processorOriginHost, st as DevServicesNeedServerTarget, tt as newOriginSecret, v as createComposeState, vr as NoDomainForStage, wt as constructGlobs, y as createEmptyState, yr as isMainFrontendApp } from "./seeds-CK7w79VC.mjs";
6
+ import { $ as ORIGIN_VERIFY_HEADER, En as mergeLifecycle, N as stageProviderNotes, P as PROVIDER_KINDS, Qt as initStageSecrets, Yt as secretsStoreFor, _t as appEnvKeys, br as resolveHost, ct as ExternalServicesNotConfigured, d as DeployJournal, dt as devServicesUsed, er as usesTelemetry, f as extractSubdomain, ft as externalServices, ht as stageServiceDeclarations, j as assertStageProvidersEnabled, m as normalizeDnsConfig, nt as originSecretKey, p as findRootDomain, pt as reportDevServices, rt as processorOriginHost, st as DevServicesNeedServerTarget, tt as newOriginSecret, v as createComposeState, vr as NoDomainForStage, wt as constructGlobs, y as createEmptyState, yr as isMainFrontendApp } from "./seeds-Cfejy8wj.mjs";
7
7
  import { n as derivedApps, t as appKey } from "./derive-B4vDpzgP.mjs";
8
- import { s as subscriberRoute } from "./SubscriberGenerator-ocQ2yj0K.mjs";
9
8
  import { n as deployIdentity, t as applicationName } from "./identity-CBXr4wNi.mjs";
10
9
  import { i as discover, m as eventsEdge, p as withOutput } from "./discover-CzGM5P3p.mjs";
11
10
  import { c as withSandbox } from "./sandbox-CbVB7uOD.mjs";
12
11
  import { findWorkspaceRoot, loadWorkspaceConfig } from "./config.mjs";
13
- import { a as parseTargetOptions, o as resolveTarget } from "./resolve-BCU9pYDx.mjs";
12
+ import { s as subscriberRoute } from "./SubscriberGenerator-BALddfuW.mjs";
13
+ import { a as parseTargetOptions, o as resolveTarget } from "./resolve-fCGJmM-R.mjs";
14
14
  import { t as LocalSandbox } from "./local-B7Zv1NoA.mjs";
15
- import { E as eventError, S as createStateStore, v as assertStateOutlivesRun, y as assertStateRoom } from "./sniffer-g9v7cqDN.mjs";
15
+ import { E as eventError, S as createStateStore, v as assertStateOutlivesRun, y as assertStateRoom } from "./sniffer-CCkdzjiU.mjs";
16
16
  import { a as findProjectBucket, i as ensureProjectBucket, o as projectBucketName, r as callerAccountId, s as reconcileProjectBucketLifecycle } from "./projectBucket-C_DN4WzF.mjs";
17
17
  import { n as assertStageCredentials } from "./credentialSchemas-DaMpt-Dx.mjs";
18
18
  import { resolve } from "node:path";
@@ -3436,4 +3436,4 @@ async function load(input, sandbox) {
3436
3436
  //#endregion
3437
3437
  export { UnknownDeployApps as a, bucketName as c, TargetBuildsNothing as i, iamUserName as l, NoDeployableApps as n, backupsUserName as o, RollbackFailed as r, IAM_USER_PATH as s, deploy as t };
3438
3438
 
3439
- //# sourceMappingURL=deploy-D8pUA9Y0.mjs.map
3439
+ //# sourceMappingURL=deploy-CIPwTJ47.mjs.map