@velastack/patterns 0.0.57 → 0.0.59

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 (102) hide show
  1. package/README.md +0 -12
  2. package/dist/chunks/{_server-Cv3bTkG0.js → _server-Cie287JZ.js} +1 -1
  3. package/dist/chunks/_server-Cie287JZ.js.map +1 -0
  4. package/dist/chunks/{collections-BwO27pJg.js → collections-DZOoJLVj.js} +5 -5
  5. package/dist/chunks/{collections-BwO27pJg.js.map → collections-DZOoJLVj.js.map} +1 -1
  6. package/dist/chunks/config-target-Co-ij8p3.js +163 -0
  7. package/dist/chunks/config-target-Co-ij8p3.js.map +1 -0
  8. package/dist/chunks/{constants-BMZmCRiI.js → constants-qmioN-7W.js} +1 -1
  9. package/dist/chunks/{constants-BMZmCRiI.js.map → constants-qmioN-7W.js.map} +1 -1
  10. package/dist/chunks/{dedent-C4qKBQXh.js → dedent-Gq6Krl4n.js} +1 -1
  11. package/dist/chunks/{dedent-C4qKBQXh.js.map → dedent-Gq6Krl4n.js.map} +1 -1
  12. package/dist/chunks/{env-Bk-LRVos.js → env-BPfk1VAw.js} +1 -1
  13. package/dist/chunks/{env-Bk-LRVos.js.map → env-BPfk1VAw.js.map} +1 -1
  14. package/dist/chunks/{env.preview-DoY1CJwL.js → env.preview-uMRKT5Pc.js} +1 -1
  15. package/dist/chunks/{env.preview-DoY1CJwL.js.map → env.preview-uMRKT5Pc.js.map} +1 -1
  16. package/dist/chunks/{env.runtime-D46GCIKe.js → env.runtime-BVage9Kk.js} +1 -1
  17. package/dist/chunks/{env.runtime-D46GCIKe.js.map → env.runtime-BVage9Kk.js.map} +1 -1
  18. package/dist/chunks/{errors-Co77I4oK.js → errors-D3Zy3wCg.js} +1 -1
  19. package/dist/chunks/{errors-Co77I4oK.js.map → errors-D3Zy3wCg.js.map} +1 -1
  20. package/dist/chunks/{generate2.runtime-yP14iPwX.js → generate.runtime-6TJoTPg9.js} +21 -15
  21. package/dist/chunks/generate.runtime-6TJoTPg9.js.map +1 -0
  22. package/dist/chunks/{generate.runtime-BnkNmF1g.js → generate.runtime-6qpoLA04.js} +10 -8
  23. package/dist/chunks/{generate.runtime-BnkNmF1g.js.map → generate.runtime-6qpoLA04.js.map} +1 -1
  24. package/dist/chunks/generate.runtime-AmiNbSR3.js +172 -0
  25. package/dist/chunks/generate.runtime-AmiNbSR3.js.map +1 -0
  26. package/dist/chunks/{generate.runtime-DjwRKg8K.js → generate.runtime-BT_bwAtt.js} +124 -198
  27. package/dist/chunks/generate.runtime-BT_bwAtt.js.map +1 -0
  28. package/dist/chunks/{generate.runtime-Cb2vYF1l.js → generate.runtime-BnnsaLsg.js} +5 -5
  29. package/dist/chunks/{generate.runtime-Cb2vYF1l.js.map → generate.runtime-BnnsaLsg.js.map} +1 -1
  30. package/dist/chunks/{generate.runtime-D6oE0Mmf.js → generate.runtime-CGtKTfYU.js} +6 -6
  31. package/dist/chunks/{generate.runtime-D6oE0Mmf.js.map → generate.runtime-CGtKTfYU.js.map} +1 -1
  32. package/dist/chunks/{generate.runtime-BkvtIjgh.js → generate.runtime-CINxHRnJ.js} +5 -5
  33. package/dist/chunks/{generate.runtime-BkvtIjgh.js.map → generate.runtime-CINxHRnJ.js.map} +1 -1
  34. package/dist/chunks/{generate.runtime-DnymXcvu.js → generate.runtime-CNxgU9v1.js} +6 -6
  35. package/dist/chunks/{generate.runtime-DnymXcvu.js.map → generate.runtime-CNxgU9v1.js.map} +1 -1
  36. package/dist/chunks/{generate.runtime-Bpx69a8t.js → generate.runtime-CRS9C9xX.js} +18 -16
  37. package/dist/chunks/{generate.runtime-Bpx69a8t.js.map → generate.runtime-CRS9C9xX.js.map} +1 -1
  38. package/dist/chunks/{generate.runtime-Bbf2YWaA.js → generate.runtime-CYmjlSQp.js} +3 -3
  39. package/dist/chunks/{generate.runtime-Bbf2YWaA.js.map → generate.runtime-CYmjlSQp.js.map} +1 -1
  40. package/dist/chunks/{generate.runtime-D1uQBjeg.js → generate.runtime-CtS6qa_1.js} +76 -76
  41. package/dist/chunks/{generate.runtime-D1uQBjeg.js.map → generate.runtime-CtS6qa_1.js.map} +1 -1
  42. package/dist/chunks/{generate.runtime-Cudp67b-.js → generate.runtime-CtzHFod-.js} +8 -8
  43. package/dist/chunks/{generate.runtime-Cudp67b-.js.map → generate.runtime-CtzHFod-.js.map} +1 -1
  44. package/dist/chunks/{generate.runtime-D1wqmaXU.js → generate.runtime-D9t6eaQd.js} +5 -5
  45. package/dist/chunks/{generate.runtime-D1wqmaXU.js.map → generate.runtime-D9t6eaQd.js.map} +1 -1
  46. package/dist/chunks/{generate.runtime-D8RXOVVA.js → generate.runtime-DBG6kEKb.js} +6 -6
  47. package/dist/chunks/{generate.runtime-D8RXOVVA.js.map → generate.runtime-DBG6kEKb.js.map} +1 -1
  48. package/dist/chunks/{generate.runtime-DFG2C9gc.js → generate.runtime-DfqzMG8Z.js} +6 -6
  49. package/dist/chunks/generate.runtime-DfqzMG8Z.js.map +1 -0
  50. package/dist/chunks/{generate.runtime-CUgleG0U.js → generate.runtime-Di0p-J8l.js} +4 -4
  51. package/dist/chunks/{generate.runtime-CUgleG0U.js.map → generate.runtime-Di0p-J8l.js.map} +1 -1
  52. package/dist/chunks/{generate.runtime-CrAHzaEW.js → generate.runtime-DsLlDfIo.js} +8 -8
  53. package/dist/chunks/{generate.runtime-CrAHzaEW.js.map → generate.runtime-DsLlDfIo.js.map} +1 -1
  54. package/dist/chunks/{generate.runtime-DFDFxHih.js → generate.runtime-EokncTLy.js} +6 -6
  55. package/dist/chunks/{generate.runtime-DFDFxHih.js.map → generate.runtime-EokncTLy.js.map} +1 -1
  56. package/dist/chunks/{generate.runtime-D_JOcL6A.js → generate.runtime-P8IVwJLB.js} +23 -17
  57. package/dist/chunks/{generate.runtime-D_JOcL6A.js.map → generate.runtime-P8IVwJLB.js.map} +1 -1
  58. package/dist/chunks/{generate.runtime-CZALdXt6.js → generate.runtime-a5PXS1Kd.js} +3 -3
  59. package/dist/chunks/{generate.runtime-CZALdXt6.js.map → generate.runtime-a5PXS1Kd.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-DPzrDUU7.js → generate.runtime-qZhYdFI1.js} +9 -9
  61. package/dist/chunks/{generate.runtime-DPzrDUU7.js.map → generate.runtime-qZhYdFI1.js.map} +1 -1
  62. package/dist/chunks/{logger-BpgCb-ZG.js → logger-CQONztPm.js} +1 -1
  63. package/dist/chunks/{logger-BpgCb-ZG.js.map → logger-CQONztPm.js.map} +1 -1
  64. package/dist/chunks/{modify-file-DE7tPADZ.js → modify-file-PVKmDJHk.js} +2 -2
  65. package/dist/chunks/{modify-file-DE7tPADZ.js.map → modify-file-PVKmDJHk.js.map} +1 -1
  66. package/dist/chunks/modify-svelte-config-remote-CDKs_Qi0.js +44 -0
  67. package/dist/chunks/modify-svelte-config-remote-CDKs_Qi0.js.map +1 -0
  68. package/dist/chunks/{modify-utils-CZ9Auvp9.js → modify-utils-Cw-on_cL.js} +13 -13
  69. package/dist/chunks/{modify-utils-CZ9Auvp9.js.map → modify-utils-Cw-on_cL.js.map} +1 -1
  70. package/dist/chunks/{nav-user-_VheJA6n.js → nav-user-CndUO69x.js} +1 -1
  71. package/dist/chunks/nav-user-CndUO69x.js.map +1 -0
  72. package/dist/chunks/{pocketbase-D7GjPuNu.js → pocketbase-BbFvZ4HI.js} +2 -2
  73. package/dist/chunks/{pocketbase-D7GjPuNu.js.map → pocketbase-BbFvZ4HI.js.map} +1 -1
  74. package/dist/chunks/{pocketbase-Bj-cW2Zl.js → pocketbase-C5GS-Dh5.js} +1 -1
  75. package/dist/chunks/{pocketbase-Bj-cW2Zl.js.map → pocketbase-C5GS-Dh5.js.map} +1 -1
  76. package/dist/chunks/{pocketbase-Dm2SF3vM.js → pocketbase-DpudAAmd.js} +1 -1
  77. package/dist/chunks/{pocketbase-Dm2SF3vM.js.map → pocketbase-DpudAAmd.js.map} +1 -1
  78. package/dist/chunks/{shared-C4wJ9sb0.js → shared-C4-NNykV.js} +3 -3
  79. package/dist/chunks/{shared-C4wJ9sb0.js.map → shared-C4-NNykV.js.map} +1 -1
  80. package/dist/chunks/{taggedTemplateLiteral-Bfbldyfk.js → taggedTemplateLiteral-CPUMuLtk.js} +1 -1
  81. package/dist/chunks/{test-setup-C3gvjtTY.js → test-setup-CcD8wSRD.js} +87 -65
  82. package/dist/chunks/test-setup-CcD8wSRD.js.map +1 -0
  83. package/dist/chunks/{ts-morph-helpers-bR0-x04t.js → ts-morph-helpers-Bk82Z2n7.js} +3 -3
  84. package/dist/chunks/{ts-morph-helpers-bR0-x04t.js.map → ts-morph-helpers-Bk82Z2n7.js.map} +1 -1
  85. package/dist/chunks/{util-BNtpm1tP.js → util-Bk7aQQJR.js} +1 -1
  86. package/dist/chunks/{util-BNtpm1tP.js.map → util-Bk7aQQJR.js.map} +1 -1
  87. package/dist/chunks/{write-result-CLSL_F-E.js → write-result-DtTqt0Cs.js} +6 -6
  88. package/dist/chunks/write-result-DtTqt0Cs.js.map +1 -0
  89. package/dist/index.js +406 -360
  90. package/dist/index.js.map +1 -1
  91. package/package.json +8 -8
  92. package/dist/chunks/_server-Cv3bTkG0.js.map +0 -1
  93. package/dist/chunks/generate.runtime-DFG2C9gc.js.map +0 -1
  94. package/dist/chunks/generate.runtime-DjwRKg8K.js.map +0 -1
  95. package/dist/chunks/generate.runtime-M6LNL7Tq.js +0 -197
  96. package/dist/chunks/generate.runtime-M6LNL7Tq.js.map +0 -1
  97. package/dist/chunks/generate2.runtime-yP14iPwX.js.map +0 -1
  98. package/dist/chunks/modify-svelte-config-remote-C3g7Oi6_.js +0 -128
  99. package/dist/chunks/modify-svelte-config-remote-C3g7Oi6_.js.map +0 -1
  100. package/dist/chunks/nav-user-_VheJA6n.js.map +0 -1
  101. package/dist/chunks/test-setup-C3gvjtTY.js.map +0 -1
  102. package/dist/chunks/write-result-CLSL_F-E.js.map +0 -1
package/README.md CHANGED
@@ -66,18 +66,6 @@ the modifications work across a wide range of project setups.
66
66
 
67
67
  The `preview-modifies` directory is the mock modify output used only for previews. It's bundled in the same way as the `creates` directory.
68
68
 
69
- ## Baselines
70
-
71
- The `src/baselines/` directory contains template SvelteKit projects that patterns are applied on top of:
72
-
73
- - `sv` — minimal SvelteKit starter
74
- - `velastack` — full VelaStack with components, UI, and database setup
75
- - `velastack-auth` — VelaStack with authentication pre-configured
76
-
77
- Each baseline is a standalone project with its own `package.json`. When working with a baseline locally, run `npm install` inside its directory. The `node_modules` and `.svelte-kit` directories inside baselines are gitignored and must be installed locally before running or testing.
78
-
79
- Baselines are not bundled into the published package — they are used by the VelaStack CLI's `create` command and by the velastack.dev website.
80
-
81
69
  # Workflow for adding new patterns
82
70
 
83
71
  - Develop the pattern in the `src/patterns` directory.
@@ -3,4 +3,4 @@ var e = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\"
3
3
  //#endregion
4
4
  export { r as a, e as c, i, o as n, n as o, a as r, t as s, s as t };
5
5
 
6
- //# sourceMappingURL=_server-Cv3bTkG0.js.map
6
+ //# sourceMappingURL=_server-Cie287JZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_server-Cie287JZ.js","names":[],"sources":[],"mappings":""}
@@ -1,7 +1,7 @@
1
- import { t as e } from "./errors-Co77I4oK.js";
2
- import { i as t } from "./util-BNtpm1tP.js";
3
- import { n, t as r } from "./logger-BpgCb-ZG.js";
4
- import { getMigrationFile as i, migrationDelay as a, withPocketbase as o } from "./pocketbase-D7GjPuNu.js";
1
+ import { t as e } from "./errors-D3Zy3wCg.js";
2
+ import { i as t } from "./util-Bk7aQQJR.js";
3
+ import { n, t as r } from "./logger-CQONztPm.js";
4
+ import { getMigrationFile as i, migrationDelay as a, withPocketbase as o } from "./pocketbase-BbFvZ4HI.js";
5
5
  import { readFileSync as s } from "node:fs";
6
6
  //#region src/runtime/collections.ts
7
7
  function c(e) {
@@ -173,4 +173,4 @@ async function v(e, r) {
173
173
  //#endregion
174
174
  export { p as applyCollectionFieldsPatches, d as applyCollectionRulePatches, l as createCollectionIdempotent, v as createCollections, _ as dropCollections, g as planCollectionDrops };
175
175
 
176
- //# sourceMappingURL=collections-BwO27pJg.js.map
176
+ //# sourceMappingURL=collections-DZOoJLVj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collections-BwO27pJg.js","names":[],"sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type PocketBase from \"pocketbase\";\nimport type { CollectionModel } from \"pocketbase\";\nimport type {\n CollectionDropSpec,\n CollectionFieldSpec,\n CollectionFieldsPatch,\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\nimport { InvalidArgumentError } from \"../core/errors\";\nimport { getLogger, NOOP_LOGGER, type Logger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, migrationDelay, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (\n error.response?.data?.name?.code === \"validation_collection_name_exists\"\n ) {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return (\n message.includes(\"already exists\") || message.includes(\"must be unique\")\n );\n}\n\ntype CollectionCreateInput = Parameters<PocketBase[\"collections\"][\"create\"]>[0];\n\nexport interface CreateCollectionResult {\n collection: CollectionModel;\n created: boolean;\n}\n\n/**\n * Idempotent wrapper around `pb.collections.create`. If the collection already\n * exists, logs and returns the existing model with `created: false` so callers\n * can skip work tied to a fresh create (e.g. appending a newly-generated\n * migration file to the result).\n */\nexport async function createCollectionIdempotent(\n pb: PocketBase,\n spec: CollectionCreateInput,\n logger: Logger = NOOP_LOGGER,\n): Promise<CreateCollectionResult> {\n const name = (spec as { name: string }).name;\n try {\n const collection = await pb.collections.create(spec);\n return { collection, created: true };\n } catch (error) {\n if (\n !isCollectionAlreadyExistsError(error as PocketBaseCollectionCreateError)\n ) {\n throw error;\n }\n logger.info(`Collection \"${name}\" already exists, skipping`);\n const collection = await pb.collections.getOne(name);\n return { collection, created: false };\n }\n}\n\nfunction rulePayloadFromPatch(\n patch: CollectionRulesPatch,\n): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n if (patch.listRule !== undefined) payload.listRule = patch.listRule;\n if (patch.viewRule !== undefined) payload.viewRule = patch.viewRule;\n if (patch.createRule !== undefined) payload.createRule = patch.createRule;\n if (patch.updateRule !== undefined) payload.updateRule = patch.updateRule;\n if (patch.deleteRule !== undefined) payload.deleteRule = patch.deleteRule;\n return payload;\n}\n\n/**\n * Applies API rule updates in array order. Call after all referenced collections exist.\n * Collects migration files produced by each update when `options` is provided.\n */\nexport async function applyCollectionRulePatches(\n pb: {\n collections: {\n getFirstListItem: (filter: string) => Promise<{ id: string }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionRulesPatch[],\n options?: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const escaped = patch.collectionName.replace(/'/g, \"''\");\n const col = await pb.collections.getFirstListItem(`name='${escaped}'`);\n logger.info(`Updating rules on collection \"${patch.collectionName}\"`);\n await pb.collections.update(col.id, rulePayloadFromPatch(patch));\n await migrationDelay();\n\n if (options) {\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (migrationFile) {\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n }\n }\n\n return migrations;\n}\n\nfunction applyFieldChanges(\n existing: CollectionFieldSpec[],\n patch: CollectionFieldsPatch,\n): CollectionFieldSpec[] {\n const fields = existing.map((field) => ({ ...field }));\n\n for (const change of patch.changes) {\n if (change.op === \"add\") {\n if (fields.some((f) => f.name === change.field.name)) {\n throw new InvalidArgumentError(\n `Field \"${change.field.name}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n fields.push(change.field);\n continue;\n }\n if (change.op === \"remove\") {\n const index = fields.findIndex((f) => f.name === change.fieldName);\n if (index === -1) {\n throw new InvalidArgumentError(\n `Field \"${change.fieldName}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n fields.splice(index, 1);\n continue;\n }\n if (change.op === \"rename\") {\n const field = fields.find((f) => f.name === change.from);\n if (!field) {\n throw new InvalidArgumentError(\n `Field \"${change.from}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n if (fields.some((f) => f.name === change.to)) {\n throw new InvalidArgumentError(\n `Field \"${change.to}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n field.name = change.to;\n continue;\n }\n }\n\n return fields;\n}\n\nexport async function applyCollectionFieldsPatches(\n pb: {\n collections: {\n getOne: (\n name: string,\n ) => Promise<{ id: string; fields: CollectionFieldSpec[] }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionFieldsPatch[],\n options: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const collection = await pb.collections.getOne(patch.collectionName);\n const newFields = applyFieldChanges(collection.fields, patch);\n logger.info(`Updating fields on collection \"${patch.collectionName}\"`);\n await pb.collections.update(collection.id, { fields: newFields });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n\n return migrations;\n}\n\nexport interface DropCollectionResult {\n dropped: boolean;\n existed: boolean;\n}\n\n/**\n * Idempotent collection drop. Returns `{ existed: false, dropped: false }` if\n * the collection is already gone, matching the idempotency contract of\n * `createCollectionIdempotent`.\n */\nexport async function dropCollectionIdempotent(\n pb: PocketBase,\n name: string,\n logger: Logger = NOOP_LOGGER,\n): Promise<DropCollectionResult> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n logger.info(`Collection \"${name}\" does not exist, skipping drop`);\n return { dropped: false, existed: false };\n }\n throw error;\n }\n await pb.collections.delete(name);\n return { dropped: true, existed: true };\n}\n\nexport interface CollectionStats {\n exists: boolean;\n rowCount: number;\n}\n\nexport async function getCollectionStats(\n pb: PocketBase,\n name: string,\n): Promise<CollectionStats> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n return { exists: false, rowCount: 0 };\n }\n throw error;\n }\n\n try {\n const result = await pb\n .collection(name)\n .getList(1, 1, { skipTotal: false });\n return { exists: true, rowCount: result.totalItems };\n } catch {\n return { exists: true, rowCount: 0 };\n }\n}\n\n/**\n * Resolve the set of collections to drop, with current row counts. Missing\n * collections are included with `exists: false, rowCount: 0` so callers can\n * display the full reversal plan even when some collections were already gone.\n */\nexport async function planCollectionDrops(\n pb: PocketBase,\n names: string[],\n): Promise<CollectionDropSpec[]> {\n const plans: CollectionDropSpec[] = [];\n for (const name of names) {\n const stats = await getCollectionStats(pb, name);\n plans.push({ name, exists: stats.exists, rowCount: stats.rowCount });\n }\n return plans;\n}\n\n/**\n * Drop each of the given collections (skipping those that are already gone)\n * and collect the `_deleted_<name>.js` migration file PocketBase emits for\n * each successful drop. Symmetric to `createCollections`.\n */\nexport async function dropCollections(\n specs: CollectionDropSpec[],\n options: Options,\n): Promise<File[]> {\n if (specs.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const spec of specs) {\n logger.info(`Dropping collection \"${spec.name}\"`);\n const { dropped } = await dropCollectionIdempotent(pb, spec.name, logger);\n if (!dropped) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(spec.name, \"deleted\", options);\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n logger.info(`Creating collection \"${collection.name}\"`);\n const { created } = await createCollectionIdempotent(\n pb,\n collection,\n logger,\n );\n if (!created) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n collection.name,\n \"created\",\n options,\n );\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n"],"mappings":";;;;;;AA4BA,SAAS,EACP,GACS;AACT,KACE,EAAM,UAAU,MAAM,MAAM,SAAS,oCAErC,QAAO;CAGT,IAAM,IAAU,EAAM,SAAS,aAAa,IAAI;AAChD,QACE,EAAQ,SAAS,iBAAiB,IAAI,EAAQ,SAAS,iBAAiB;;AAiB5E,eAAsB,EACpB,GACA,GACA,IAAiB,GACgB;CACjC,IAAM,IAAQ,EAA0B;AACxC,KAAI;AAEF,SAAO;GAAE,YADU,MAAM,EAAG,YAAY,OAAO,EAAK;GAC/B,SAAS;GAAM;UAC7B,GAAO;AACd,MACE,CAAC,EAA+B,EAAyC,CAEzE,OAAM;AAIR,SAFA,EAAO,KAAK,eAAe,EAAK,4BAA4B,EAErD;GAAE,YADU,MAAM,EAAG,YAAY,OAAO,EAAK;GAC/B,SAAS;GAAO;;;AAIzC,SAAS,EACP,GACyB;CACzB,IAAM,IAAmC,EAAE;AAM3C,QALI,EAAM,aAAa,KAAA,MAAW,EAAQ,WAAW,EAAM,WACvD,EAAM,aAAa,KAAA,MAAW,EAAQ,WAAW,EAAM,WACvD,EAAM,eAAe,KAAA,MAAW,EAAQ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;AACpC,KAAO,KAAK,wBAAwB,EAAW,KAAK,GAAG;GACvD,IAAM,EAAE,eAAY,MAAM,EACxB,GACA,GACA,EACD;AACD,OAAI,CAAC,EAAS;AACd,SAAM,GAAgB;GAEtB,IAAM,IAAgB,EACpB,EAAW,MACX,WACA,EACD;AACI,QAIL,EAAW,KAAK;IACd,MAAM;IACN,UAAU,EAAiB,EAAc;IACzC,SAAS,EAAa,GAAe,OAAO;IAC5C,QAAQ;IACT,CAAC;;GAEJ,EAEK"}
1
+ {"version":3,"file":"collections-DZOoJLVj.js","names":[],"sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type PocketBase from \"pocketbase\";\nimport type { CollectionModel } from \"pocketbase\";\nimport type {\n CollectionDropSpec,\n CollectionFieldSpec,\n CollectionFieldsPatch,\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\nimport { InvalidArgumentError } from \"../core/errors\";\nimport { getLogger, NOOP_LOGGER, type Logger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, migrationDelay, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (\n error.response?.data?.name?.code === \"validation_collection_name_exists\"\n ) {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return (\n message.includes(\"already exists\") || message.includes(\"must be unique\")\n );\n}\n\ntype CollectionCreateInput = Parameters<PocketBase[\"collections\"][\"create\"]>[0];\n\nexport interface CreateCollectionResult {\n collection: CollectionModel;\n created: boolean;\n}\n\n/**\n * Idempotent wrapper around `pb.collections.create`. If the collection already\n * exists, logs and returns the existing model with `created: false` so callers\n * can skip work tied to a fresh create (e.g. appending a newly-generated\n * migration file to the result).\n */\nexport async function createCollectionIdempotent(\n pb: PocketBase,\n spec: CollectionCreateInput,\n logger: Logger = NOOP_LOGGER,\n): Promise<CreateCollectionResult> {\n const name = (spec as { name: string }).name;\n try {\n const collection = await pb.collections.create(spec);\n return { collection, created: true };\n } catch (error) {\n if (\n !isCollectionAlreadyExistsError(error as PocketBaseCollectionCreateError)\n ) {\n throw error;\n }\n logger.info(`Collection \"${name}\" already exists, skipping`);\n const collection = await pb.collections.getOne(name);\n return { collection, created: false };\n }\n}\n\nfunction rulePayloadFromPatch(\n patch: CollectionRulesPatch,\n): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n if (patch.listRule !== undefined) payload.listRule = patch.listRule;\n if (patch.viewRule !== undefined) payload.viewRule = patch.viewRule;\n if (patch.createRule !== undefined) payload.createRule = patch.createRule;\n if (patch.updateRule !== undefined) payload.updateRule = patch.updateRule;\n if (patch.deleteRule !== undefined) payload.deleteRule = patch.deleteRule;\n return payload;\n}\n\n/**\n * Applies API rule updates in array order. Call after all referenced collections exist.\n * Collects migration files produced by each update when `options` is provided.\n */\nexport async function applyCollectionRulePatches(\n pb: {\n collections: {\n getFirstListItem: (filter: string) => Promise<{ id: string }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionRulesPatch[],\n options?: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const escaped = patch.collectionName.replace(/'/g, \"''\");\n const col = await pb.collections.getFirstListItem(`name='${escaped}'`);\n logger.info(`Updating rules on collection \"${patch.collectionName}\"`);\n await pb.collections.update(col.id, rulePayloadFromPatch(patch));\n await migrationDelay();\n\n if (options) {\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (migrationFile) {\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n }\n }\n\n return migrations;\n}\n\nfunction applyFieldChanges(\n existing: CollectionFieldSpec[],\n patch: CollectionFieldsPatch,\n): CollectionFieldSpec[] {\n const fields = existing.map((field) => ({ ...field }));\n\n for (const change of patch.changes) {\n if (change.op === \"add\") {\n if (fields.some((f) => f.name === change.field.name)) {\n throw new InvalidArgumentError(\n `Field \"${change.field.name}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n fields.push(change.field);\n continue;\n }\n if (change.op === \"remove\") {\n const index = fields.findIndex((f) => f.name === change.fieldName);\n if (index === -1) {\n throw new InvalidArgumentError(\n `Field \"${change.fieldName}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n fields.splice(index, 1);\n continue;\n }\n if (change.op === \"rename\") {\n const field = fields.find((f) => f.name === change.from);\n if (!field) {\n throw new InvalidArgumentError(\n `Field \"${change.from}\" does not exist on collection \"${patch.collectionName}\"`,\n );\n }\n if (fields.some((f) => f.name === change.to)) {\n throw new InvalidArgumentError(\n `Field \"${change.to}\" already exists on collection \"${patch.collectionName}\"`,\n );\n }\n field.name = change.to;\n continue;\n }\n }\n\n return fields;\n}\n\nexport async function applyCollectionFieldsPatches(\n pb: {\n collections: {\n getOne: (\n name: string,\n ) => Promise<{ id: string; fields: CollectionFieldSpec[] }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionFieldsPatch[],\n options: Options,\n logger: Logger = NOOP_LOGGER,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const collection = await pb.collections.getOne(patch.collectionName);\n const newFields = applyFieldChanges(collection.fields, patch);\n logger.info(`Updating fields on collection \"${patch.collectionName}\"`);\n await pb.collections.update(collection.id, { fields: newFields });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n\n return migrations;\n}\n\nexport interface DropCollectionResult {\n dropped: boolean;\n existed: boolean;\n}\n\n/**\n * Idempotent collection drop. Returns `{ existed: false, dropped: false }` if\n * the collection is already gone, matching the idempotency contract of\n * `createCollectionIdempotent`.\n */\nexport async function dropCollectionIdempotent(\n pb: PocketBase,\n name: string,\n logger: Logger = NOOP_LOGGER,\n): Promise<DropCollectionResult> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n logger.info(`Collection \"${name}\" does not exist, skipping drop`);\n return { dropped: false, existed: false };\n }\n throw error;\n }\n await pb.collections.delete(name);\n return { dropped: true, existed: true };\n}\n\nexport interface CollectionStats {\n exists: boolean;\n rowCount: number;\n}\n\nexport async function getCollectionStats(\n pb: PocketBase,\n name: string,\n): Promise<CollectionStats> {\n try {\n await pb.collections.getOne(name);\n } catch (error) {\n const status = (error as { status?: number }).status;\n if (status === 404) {\n return { exists: false, rowCount: 0 };\n }\n throw error;\n }\n\n try {\n const result = await pb\n .collection(name)\n .getList(1, 1, { skipTotal: false });\n return { exists: true, rowCount: result.totalItems };\n } catch {\n return { exists: true, rowCount: 0 };\n }\n}\n\n/**\n * Resolve the set of collections to drop, with current row counts. Missing\n * collections are included with `exists: false, rowCount: 0` so callers can\n * display the full reversal plan even when some collections were already gone.\n */\nexport async function planCollectionDrops(\n pb: PocketBase,\n names: string[],\n): Promise<CollectionDropSpec[]> {\n const plans: CollectionDropSpec[] = [];\n for (const name of names) {\n const stats = await getCollectionStats(pb, name);\n plans.push({ name, exists: stats.exists, rowCount: stats.rowCount });\n }\n return plans;\n}\n\n/**\n * Drop each of the given collections (skipping those that are already gone)\n * and collect the `_deleted_<name>.js` migration file PocketBase emits for\n * each successful drop. Symmetric to `createCollections`.\n */\nexport async function dropCollections(\n specs: CollectionDropSpec[],\n options: Options,\n): Promise<File[]> {\n if (specs.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const spec of specs) {\n logger.info(`Dropping collection \"${spec.name}\"`);\n const { dropped } = await dropCollectionIdempotent(pb, spec.name, logger);\n if (!dropped) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(spec.name, \"deleted\", options);\n if (!migrationFile) continue;\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n const logger = getLogger(options);\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n logger.info(`Creating collection \"${collection.name}\"`);\n const { created } = await createCollectionIdempotent(\n pb,\n collection,\n logger,\n );\n if (!created) continue;\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n collection.name,\n \"created\",\n options,\n );\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n return migrations;\n}\n"],"mappings":";;;;;;AA4BA,SAAS,EACP,GACS;CACT,IACE,EAAM,UAAU,MAAM,MAAM,SAAS,qCAErC,OAAO;CAGT,IAAM,IAAU,EAAM,SAAS,YAAY,KAAK;CAChD,OACE,EAAQ,SAAS,gBAAgB,KAAK,EAAQ,SAAS,gBAAgB;AAE3E;AAeA,eAAsB,EACpB,GACA,GACA,IAAiB,GACgB;CACjC,IAAM,IAAQ,EAA0B;CACxC,IAAI;EAEF,OAAO;GAAE,YAAA,MADgB,EAAG,YAAY,OAAO,CAAI;GAC9B,SAAS;EAAK;CACrC,SAAS,GAAO;EACd,IACE,CAAC,EAA+B,CAAwC,GAExE,MAAM;EAIR,OAFA,EAAO,KAAK,eAAe,EAAK,2BAA2B,GAEpD;GAAE,YAAA,MADgB,EAAG,YAAY,OAAO,CAAI;GAC9B,SAAS;EAAM;CACtC;AACF;AAEA,SAAS,E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Ae,MAAM;IAC3C,QAAQ;GACV,CAAC;EACH;CACF,CAAC,GAEM;AACT;AAEA,eAAsB,EACpB,GACA,GACiB;CACjB,IAAI,EAAY,WAAW,GACzB,OAAO,CAAC;CAGV,IAAM,IAAqB,CAAC,GACtB,IAAS,EAAU,CAAO;CA+BhC,OA7BA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;EAC/C,KAAK,IAAM,KAAc,GAAa;GACpC,EAAO,KAAK,wBAAwB,EAAW,KAAK,EAAE;GACtD,IAAM,EAAE,eAAY,MAAM,EACxB,GACA,GACA,CACF;GACA,IAAI,CAAC,GAAS;GACd,MAAM,EAAe;GAErB,IAAM,IAAgB,EACpB,EAAW,MACX,WACA,CACF;GACK,KAIL,EAAW,KAAK;IACd,MAAM;IACN,UAAU,EAAiB,CAAa;IACxC,SAAS,EAAa,GAAe,MAAM;IAC3C,QAAQ;GACV,CAAC;EACH;CACF,CAAC,GAEM;AACT"}
@@ -0,0 +1,163 @@
1
+ import e from "node:fs";
2
+ import t from "node:path";
3
+ import { Project as n, QuoteKind as r, SyntaxKind as i } from "ts-morph";
4
+ //#region src/runtime/config-target.ts
5
+ var a = [
6
+ "vite.config.ts",
7
+ "vite.config.js",
8
+ "vite.config.mjs",
9
+ "vite.config.cjs"
10
+ ], o = [
11
+ "svelte.config.ts",
12
+ "svelte.config.js",
13
+ "svelte.config.mjs",
14
+ "svelte.config.cjs"
15
+ ];
16
+ function s(n, r) {
17
+ for (let i of r) {
18
+ let r = t.join(n, i);
19
+ if (e.existsSync(r)) return r;
20
+ }
21
+ return null;
22
+ }
23
+ function c() {
24
+ return new n({
25
+ compilerOptions: { allowJs: !0 },
26
+ manipulationSettings: { quoteKind: r.Single }
27
+ });
28
+ }
29
+ function l(e) {
30
+ let t = e.getExportAssignment((e) => !e.isExportEquals())?.getExpression();
31
+ if (t?.getKind() === i.ObjectLiteralExpression) return t;
32
+ if (t?.getKind() === i.Identifier) {
33
+ let n = t.getText(), r = e.getVariableDeclaration(n)?.getInitializer();
34
+ if (r?.getKind() === i.ObjectLiteralExpression) return r;
35
+ }
36
+ return null;
37
+ }
38
+ function u(e, t, n) {
39
+ let r = e.getProperty(t);
40
+ if (!r) {
41
+ e.addPropertyAssignment({
42
+ name: t,
43
+ initializer: n
44
+ });
45
+ let r = e.getProperty(t);
46
+ if (!r || r.getKind() !== i.PropertyAssignment) return null;
47
+ let a = r.getInitializer();
48
+ return !a || a.getKind() !== i.ObjectLiteralExpression ? null : a;
49
+ }
50
+ if (r.getKind() !== i.PropertyAssignment) return null;
51
+ let a = r.getInitializer();
52
+ if (!a) return null;
53
+ if (a.getKind() !== i.ObjectLiteralExpression) {
54
+ r.setInitializer(n);
55
+ let e = r.getInitializer();
56
+ return e && e.getKind() === i.ObjectLiteralExpression ? e : null;
57
+ }
58
+ return a;
59
+ }
60
+ function d(e, t) {
61
+ let n = e.getProperty(t);
62
+ return n ? n.getKind() !== i.PropertyAssignment || n.getInitializer()?.getText() === "true" ? !1 : (n.setInitializer("true"), !0) : (e.addPropertyAssignment({
63
+ name: t,
64
+ initializer: "true"
65
+ }), !0);
66
+ }
67
+ function f(e) {
68
+ return e.getDescendantsOfKind(i.CallExpression).find((e) => e.getExpression().getText() === "sveltekit") ?? null;
69
+ }
70
+ function p(e, t, n, r) {
71
+ return {
72
+ kind: "vite-inline",
73
+ sourceFile: e,
74
+ filePath: t,
75
+ configObject: n,
76
+ originalText: r,
77
+ kitContainer: () => n
78
+ };
79
+ }
80
+ function m(e, t, n, r) {
81
+ return {
82
+ kind: "svelte-config",
83
+ sourceFile: e,
84
+ filePath: t,
85
+ configObject: n,
86
+ originalText: r,
87
+ kitContainer: () => u(n, "kit", "{}")
88
+ };
89
+ }
90
+ function h(e, n) {
91
+ let r = n?.notFound ?? "Could not find a Svelte or Vite config to modify.", u = n?.failed ?? "Could not modify the Svelte or Vite config.", d = s(e, a), h = null, g = "", _ = null, v = null, y = !1;
92
+ if (d) {
93
+ h = c().addSourceFileAtPath(d), g = h.getFullText(), _ = f(h);
94
+ let e = _?.getArguments()[0];
95
+ e && (e.getKind() === i.ObjectLiteralExpression ? v = e : y = !0);
96
+ }
97
+ if (h && d && v) return {
98
+ status: "resolved",
99
+ target: p(h, d, v, g)
100
+ };
101
+ let b = s(e, o), x = null, S = "", C = null;
102
+ if (b && (x = c().addSourceFileAtPath(b), S = x.getFullText(), C = l(x)), x && b && C) return {
103
+ status: "resolved",
104
+ target: m(x, b, C, S)
105
+ };
106
+ if (h && d && _) {
107
+ if (y) return {
108
+ status: "failed",
109
+ message: u,
110
+ filePath: d
111
+ };
112
+ let e = _.addArgument("{}").asKind(i.ObjectLiteralExpression);
113
+ return e ? {
114
+ status: "resolved",
115
+ target: p(h, d, e, g)
116
+ } : {
117
+ status: "failed",
118
+ message: u,
119
+ filePath: d
120
+ };
121
+ }
122
+ return b && !C ? {
123
+ status: "failed",
124
+ message: u,
125
+ filePath: b
126
+ } : {
127
+ status: "not-found",
128
+ message: r,
129
+ filePath: d ?? b ?? t.join(e, a[0])
130
+ };
131
+ }
132
+ function g(e) {
133
+ return e.sourceFile.formatText(), e.sourceFile.getFullText() === e.originalText ? {
134
+ status: "success",
135
+ changed: !1
136
+ } : (e.sourceFile.saveSync(), {
137
+ status: "success",
138
+ changed: !0
139
+ });
140
+ }
141
+ function _(e, t, n) {
142
+ let r = h(e, t);
143
+ return r.status === "resolved" ? n(r.target) ? {
144
+ filePath: r.target.filePath,
145
+ outcome: g(r.target)
146
+ } : {
147
+ filePath: r.target.filePath,
148
+ outcome: {
149
+ status: "failed",
150
+ message: t.failed
151
+ }
152
+ } : {
153
+ filePath: r.filePath,
154
+ outcome: {
155
+ status: r.status,
156
+ message: r.message
157
+ }
158
+ };
159
+ }
160
+ //#endregion
161
+ export { s as a, _ as i, d as n, h as o, u as r, g as s, a as t };
162
+
163
+ //# sourceMappingURL=config-target-Co-ij8p3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-target-Co-ij8p3.js","names":[],"sources":["../../src/runtime/config-target.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n Project,\n QuoteKind,\n SyntaxKind,\n type CallExpression,\n type ObjectLiteralExpression,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../core/types\";\n\nexport const VITE_CONFIG_CANDIDATES = [\n \"vite.config.ts\",\n \"vite.config.js\",\n \"vite.config.mjs\",\n \"vite.config.cjs\",\n];\n\nexport const SVELTE_CONFIG_CANDIDATES = [\n \"svelte.config.ts\",\n \"svelte.config.js\",\n \"svelte.config.mjs\",\n \"svelte.config.cjs\",\n];\n\nexport type ConfigKind = \"svelte-config\" | \"vite-inline\";\n\n/**\n * A resolved place to read/write SvelteKit configuration. Either the default\n * export object of a `svelte.config.*` file, or the inline argument object of\n * the `sveltekit()` call inside a `vite.config.*` file.\n *\n * The only structural difference between the two is where kit-namespaced\n * settings (adapter, alias, experimental) live: under `config.kit` in\n * svelte.config, but flattened onto the `sveltekit()` arg in vite-inline.\n * `kitContainer()` papers over that; everything else (`compilerOptions`,\n * `preprocess`, `extensions`) sits at the root of `configObject` in both.\n */\nexport interface ConfigTarget {\n kind: ConfigKind;\n /** The file to add imports to and save. */\n sourceFile: SourceFile;\n /** Absolute path of the resolved file. */\n filePath: string;\n /** svelte.config default-export object OR the `sveltekit()` arg object. */\n configObject: ObjectLiteralExpression;\n /** Full text captured before any mutation, for change detection. */\n originalText: string;\n /** Object that owns kit-namespaced settings (adapter, alias, experimental). */\n kitContainer(): ObjectLiteralExpression | null;\n}\n\nexport type ResolveResult =\n | { status: \"resolved\"; target: ConfigTarget }\n | { status: \"not-found\"; message: string; filePath: string }\n | { status: \"failed\"; message: string; filePath: string };\n\n/** Result shape returned by every config modifier so call sites can build a File. */\nexport interface ConfigModifyResult {\n filePath: string;\n outcome: ModifyOutcome;\n}\n\n/** First candidate that exists under `root`, or null. */\nexport function probeFirstExisting(\n root: string,\n candidates: string[],\n): string | null {\n for (const rel of candidates) {\n const abs = path.join(root, rel);\n if (fs.existsSync(abs)) return abs;\n }\n return null;\n}\n\nfunction newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\n/**\n * Resolve the config object exported as default — handles both\n * `export default { ... }` and `const config = { ... }; export default config`.\n */\nexport function getDefaultExportObject(\n sourceFile: SourceFile,\n): ObjectLiteralExpression | null {\n const defaultExport = sourceFile.getExportAssignment(\n (ea) => !ea.isExportEquals(),\n );\n const exportedExpr = defaultExport?.getExpression();\n if (exportedExpr?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n return exportedExpr as ObjectLiteralExpression;\n }\n if (exportedExpr?.getKind() === SyntaxKind.Identifier) {\n const ident = exportedExpr.getText();\n const varDecl = sourceFile.getVariableDeclaration(ident);\n const init = varDecl?.getInitializer();\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n return init as ObjectLiteralExpression;\n }\n }\n return null;\n}\n\n/**\n * Get the object-literal value of property `name` on `obj`, creating it as an\n * empty object if missing (or replacing a non-object initializer). Returns null\n * if the property can't be coerced to an object literal.\n */\nexport function getOrCreateObjectLiteralProperty(\n obj: ObjectLiteralExpression,\n name: string,\n initializer: string,\n): ObjectLiteralExpression | null {\n const prop = obj.getProperty(name);\n if (!prop) {\n obj.addPropertyAssignment({ name, initializer });\n const added = obj.getProperty(name);\n if (!added || added.getKind() !== SyntaxKind.PropertyAssignment)\n return null;\n const init = (\n added as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ObjectLiteralExpression)\n return null;\n return init as ObjectLiteralExpression;\n }\n\n if (prop.getKind() !== SyntaxKind.PropertyAssignment) return null;\n const init = (prop as import(\"ts-morph\").PropertyAssignment).getInitializer();\n if (!init) return null;\n if (init.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n (prop as import(\"ts-morph\").PropertyAssignment).setInitializer(initializer);\n const init2 = (\n prop as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n return init2 && init2.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (init2 as ObjectLiteralExpression)\n : null;\n }\n\n return init as ObjectLiteralExpression;\n}\n\n/** Ensure `obj[name] === true`. Returns whether a change was made. */\nexport function ensureBooleanTrue(\n obj: ObjectLiteralExpression,\n name: string,\n): boolean {\n const existing = obj.getProperty(name);\n if (!existing) {\n obj.addPropertyAssignment({ name, initializer: \"true\" });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (init?.getText() === \"true\") return false;\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\"true\");\n return true;\n}\n\nfunction findSveltekitCall(sourceFile: SourceFile): CallExpression | null {\n return (\n sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"sveltekit\") ?? null\n );\n}\n\nfunction makeViteTarget(\n sourceFile: SourceFile,\n filePath: string,\n configObject: ObjectLiteralExpression,\n originalText: string,\n): ConfigTarget {\n return {\n kind: \"vite-inline\",\n sourceFile,\n filePath,\n configObject,\n originalText,\n // kit-namespaced settings are flattened onto the sveltekit() arg.\n kitContainer: () => configObject,\n };\n}\n\nfunction makeSvelteTarget(\n sourceFile: SourceFile,\n filePath: string,\n configObject: ObjectLiteralExpression,\n originalText: string,\n): ConfigTarget {\n return {\n kind: \"svelte-config\",\n sourceFile,\n filePath,\n configObject,\n originalText,\n kitContainer: () =>\n getOrCreateObjectLiteralProperty(configObject, \"kit\", \"{}\"),\n };\n}\n\n/**\n * Resolve where SvelteKit config should be read/written, mirroring SvelteKit's\n * own resolution order:\n * 1. `vite.config.*` has a `sveltekit(<object>)` call with an inline arg → use it\n * (svelte.config is ignored by Kit when this exists).\n * 2. else a `svelte.config.*` with a parseable default-export object → use it.\n * 3. else a bare `sveltekit()` in vite.config → create `{}` and use it (the new default).\n */\nexport function resolveConfigTarget(\n root: string,\n hints?: { notFound?: string; failed?: string },\n): ResolveResult {\n const notFound =\n hints?.notFound ?? \"Could not find a Svelte or Vite config to modify.\";\n const failed = hints?.failed ?? \"Could not modify the Svelte or Vite config.\";\n\n // --- Inspect vite.config.* ---\n const vitePath = probeFirstExisting(root, VITE_CONFIG_CANDIDATES);\n let viteSourceFile: SourceFile | null = null;\n let viteOriginal = \"\";\n let sveltekitCall: CallExpression | null = null;\n let viteInlineArg: ObjectLiteralExpression | null = null;\n let viteNonObjectArg = false;\n\n if (vitePath) {\n viteSourceFile = newProject().addSourceFileAtPath(vitePath);\n viteOriginal = viteSourceFile.getFullText();\n sveltekitCall = findSveltekitCall(viteSourceFile);\n const arg = sveltekitCall?.getArguments()[0];\n if (arg) {\n if (arg.getKind() === SyntaxKind.ObjectLiteralExpression) {\n viteInlineArg = arg as ObjectLiteralExpression;\n } else {\n viteNonObjectArg = true;\n }\n }\n }\n\n // Rule 1: vite.config carries an inline object arg → target it.\n if (viteSourceFile && vitePath && viteInlineArg) {\n return {\n status: \"resolved\",\n target: makeViteTarget(\n viteSourceFile,\n vitePath,\n viteInlineArg,\n viteOriginal,\n ),\n };\n }\n\n // --- Inspect svelte.config.* ---\n const sveltePath = probeFirstExisting(root, SVELTE_CONFIG_CANDIDATES);\n let svelteSourceFile: SourceFile | null = null;\n let svelteOriginal = \"\";\n let svelteConfigObj: ObjectLiteralExpression | null = null;\n if (sveltePath) {\n svelteSourceFile = newProject().addSourceFileAtPath(sveltePath);\n svelteOriginal = svelteSourceFile.getFullText();\n svelteConfigObj = getDefaultExportObject(svelteSourceFile);\n }\n\n // Rule 2: svelte.config with a parseable config object → target it.\n if (svelteSourceFile && sveltePath && svelteConfigObj) {\n return {\n status: \"resolved\",\n target: makeSvelteTarget(\n svelteSourceFile,\n sveltePath,\n svelteConfigObj,\n svelteOriginal,\n ),\n };\n }\n\n // Rule 3: bare `sveltekit()` in vite.config → create `{}` arg and target it.\n if (viteSourceFile && vitePath && sveltekitCall) {\n if (viteNonObjectArg) {\n return { status: \"failed\", message: failed, filePath: vitePath };\n }\n const created = sveltekitCall\n .addArgument(\"{}\")\n .asKind(SyntaxKind.ObjectLiteralExpression);\n if (!created) {\n return { status: \"failed\", message: failed, filePath: vitePath };\n }\n return {\n status: \"resolved\",\n target: makeViteTarget(viteSourceFile, vitePath, created, viteOriginal),\n };\n }\n\n // svelte.config exists but its shape is unparseable.\n if (sveltePath && !svelteConfigObj) {\n return { status: \"failed\", message: failed, filePath: sveltePath };\n }\n\n const reportPath =\n vitePath ?? sveltePath ?? path.join(root, VITE_CONFIG_CANDIDATES[0]);\n return { status: \"not-found\", message: notFound, filePath: reportPath };\n}\n\n/** Format, compare against the captured original, and save only if changed. */\nexport function saveTarget(target: ConfigTarget): ModifyOutcome {\n target.sourceFile.formatText();\n const newText = target.sourceFile.getFullText();\n if (newText === target.originalText) {\n return { status: \"success\", changed: false };\n }\n target.sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n\n/**\n * Resolve a config target and run `mutate` against it. Handles the\n * not-found/failed branches and change detection uniformly. `mutate` returns\n * `false` when the config shape can't be safely edited (→ failed).\n */\nexport function modifyConfig(\n root: string,\n hints: { notFound: string; failed: string },\n mutate: (target: ConfigTarget) => boolean,\n): ConfigModifyResult {\n const res = resolveConfigTarget(root, hints);\n if (res.status !== \"resolved\") {\n return {\n filePath: res.filePath,\n outcome: { status: res.status, message: res.message },\n };\n }\n const ok = mutate(res.target);\n if (!ok) {\n return {\n filePath: res.target.filePath,\n outcome: { status: \"failed\", message: hints.failed },\n };\n }\n return { filePath: res.target.filePath, outcome: saveTarget(res.target) };\n}\n"],"mappings":";;;;AAYA,IAAa,IAAyB;CACpC;CACA;CACA;CACA;AACF,GAEa,IAA2B;CACtC;CACA;CACA;CACA;AACF;AAyCA,SAAgB,EACd,GACA,GACe;CACf,KAAK,IAAM,KAAO,GAAY;EAC5B,IAAM,IAAM,EAAK,KAAK,GAAM,CAAG;EAC/B,IAAI,EAAG,WAAW,CAAG,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, r as t };
5
5
 
6
- //# sourceMappingURL=constants-BMZmCRiI.js.map
6
+ //# sourceMappingURL=constants-qmioN-7W.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants-BMZmCRiI.js","names":[],"sources":["../../src/core/constants.ts"],"sourcesContent":["export const DATA_DIR = \"data\";\nexport const MIGRATIONS_DIR = \"migrations\";\nexport const FIXTURE_PREFIX = \"vela\";\nexport const PUBLIC_DIR = \"(public)\";\nexport const APP_DIR = \"(app)\";\nexport const AUTHED_REDIRECT_PATH = \"/dashboard\";\nexport const API_URL = \"http://localhost:5173\";\n"],"mappings":";AAAA,IAAa,IAAW,QACX,IAAiB,cAEjB,IAAa,YACb,IAAU"}
1
+ {"version":3,"file":"constants-qmioN-7W.js","names":[],"sources":["../../src/core/constants.ts"],"sourcesContent":["export const DATA_DIR = \"data\";\nexport const MIGRATIONS_DIR = \"migrations\";\nexport const FIXTURE_PREFIX = \"vela\";\nexport const PUBLIC_DIR = \"(public)\";\nexport const APP_DIR = \"(app)\";\nexport const AUTHED_REDIRECT_PATH = \"/dashboard\";\nexport const API_URL = \"http://localhost:5173\";\n"],"mappings":";AAAA,IAAa,IAAW,QACX,IAAiB,cAEjB,IAAa,YACb,IAAU"}
@@ -84,4 +84,4 @@ function s(e, t) {
84
84
  //#endregion
85
85
  export { a as t };
86
86
 
87
- //# sourceMappingURL=dedent-C4qKBQXh.js.map
87
+ //# sourceMappingURL=dedent-Gq6Krl4n.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dedent-C4qKBQXh.js","names":[],"sources":["../../node_modules/dedent/dist/dedent.mjs"],"sourcesContent":["function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return typeof key === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (typeof input !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (typeof res !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nconst dedent = createDedent({});\nexport default dedent;\nfunction createDedent(options) {\n dedent.withOptions = newOptions => createDedent(_objectSpread(_objectSpread({}, options), newOptions));\n return dedent;\n function dedent(strings, ...values) {\n const raw = typeof strings === \"string\" ? [strings] : strings.raw;\n const {\n alignValues = false,\n escapeSpecialCharacters = Array.isArray(strings),\n trimWhitespace = true\n } = options;\n\n // first, perform interpolation\n let result = \"\";\n for (let i = 0; i < raw.length; i++) {\n let next = raw[i];\n if (escapeSpecialCharacters) {\n // handle escaped newlines, backticks, and interpolation characters\n next = next.replace(/\\\\\\n[ \\t]*/g, \"\").replace(/\\\\`/g, \"`\").replace(/\\\\\\$/g, \"$\").replace(/\\\\\\{/g, \"{\");\n }\n result += next;\n if (i < values.length) {\n const value = alignValues ? alignValue(values[i], result) : values[i];\n\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n result += value;\n }\n }\n\n // now strip indentation\n const lines = result.split(\"\\n\");\n let mindent = null;\n for (const l of lines) {\n const m = l.match(/^(\\s+)\\S+/);\n if (m) {\n const indent = m[1].length;\n if (!mindent) {\n // this is the first indented line\n mindent = indent;\n } else {\n mindent = Math.min(mindent, indent);\n }\n }\n }\n if (mindent !== null) {\n const m = mindent; // appease TypeScript\n result = lines\n // https://github.com/typescript-eslint/typescript-eslint/issues/7140\n // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with\n .map(l => l[0] === \" \" || l[0] === \"\\t\" ? l.slice(m) : l).join(\"\\n\");\n }\n\n // dedent eats leading and trailing whitespace too\n if (trimWhitespace) {\n result = result.trim();\n }\n\n // Unescape escapes after trimming so sequences like `\\n`, `\\t`,\n // `\\xHH` and `\\u{...}` are preserved (fixes #24)\n if (escapeSpecialCharacters) {\n result = result.replace(/\\\\n/g, \"\\n\").replace(/\\\\t/g, \"\\t\").replace(/\\\\r/g, \"\\r\").replace(/\\\\v/g, \"\\v\").replace(/\\\\b/g, \"\\b\").replace(/\\\\f/g, \"\\f\").replace(/\\\\0/g, \"\\0\").replace(/\\\\x([\\da-fA-F]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\\\u\\{([\\da-fA-F]{1,6})\\}/g, (_, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\\\u([\\da-fA-F]{4})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));\n }\n\n // Workaround for Bun issue with Unicode characters\n // https://github.com/oven-sh/bun/issues/8745\n if (typeof Bun !== \"undefined\") {\n result = result.replace(\n // Matches e.g. \\\\u{1f60a} or \\\\u5F1F\n /\\\\u(?:\\{([\\da-fA-F]{1,6})\\}|([\\da-fA-F]{4}))/g, (_, braced, unbraced) => {\n var _ref;\n const hex = (_ref = braced !== null && braced !== void 0 ? braced : unbraced) !== null && _ref !== void 0 ? _ref : \"\";\n return String.fromCodePoint(parseInt(hex, 16));\n });\n }\n return result;\n }\n}\n\n/**\n * Adjusts the indentation of a multi-line interpolated value to match the current line.\n */\nfunction alignValue(value, precedingText) {\n if (typeof value !== \"string\" || !value.includes(\"\\n\")) {\n return value;\n }\n const currentLine = precedingText.slice(precedingText.lastIndexOf(\"\\n\") + 1);\n const indentMatch = currentLine.match(/^(\\s+)/);\n if (indentMatch) {\n const indent = indentMatch[1];\n return value.replace(/\\n/g, `\\n${indent}`);\n }\n return value;\n}\n"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,EAAQ,GAAQ,GAAgB;CAAE,IAAI,IAAO,OAAO,KAAK,EAAO;AAAE,KAAI,OAAO,uBAAuB;EAAE,IAAI,IAAU,OAAO,sBAAsB,EAAO;AAAE,QAAmB,IAAU,EAAQ,OAAO,SAAU,GAAK;AAAE,UAAO,OAAO,yBAAyB,GAAQ,EAAI,CAAC;IAAc,GAAG,EAAK,KAAK,MAAM,GAAM,EAAQ;;AAAI,QAAO;;AAC9U,SAAS,EAAc,GAAQ;AAAE,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EAAE,IAAI,IAAiB,UAAU,MAAlB,OAAsC,EAAE,GAAjB,UAAU;AAAS,MAAI,IAAI,EAAQ,OAAO,EAAO,EAAE,CAAC,EAAE,CAAC,QAAQ,SAAU,GAAK;AAAE,KAAgB,GAAQ,GAAK,EAAO,GAAK;IAAI,GAAG,OAAO,4BAA4B,OAAO,iBAAiB,GAAQ,OAAO,0BAA0B,EAAO,CAAC,GAAG,EAAQ,OAAO,EAAO,CAAC,CAAC,QAAQ,SAAU,GAAK;AAAE,UAAO,eAAe,GAAQ,GAAK,OAAO,yBAAyB,GAAQ,EAAI,CAAC;IAAI;;AAAI,QAAO;;AACjf,SAAS,EAAgB,GAAK,GAAK,GAAO;AAAqL,QAAnL,IAAM,EAAe,EAAI,EAAM,KAAO,IAAO,OAAO,eAAe,GAAK,GAAK;EAAS;EAAO,YAAY;EAAM,cAAc;EAAM,UAAU;EAAM,CAAC,GAAW,EAAI,KAAO,GAAgB;;AACtO,SAAS,EAAe,GAAK;CAAE,IAAI,IAAM,EAAa,GAAK,SAAS;AAAE,QAAO,OAAO,KAAQ,WAAW,IAAM,OAA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,EAGR,KAAI,MAAK,EAAE,OAAO,OAAO,EAAE,OAAO,MAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,KAAK;;AAyBtE,SArBI,MACF,IAAS,EAAO,MAAM,GAKpB,MACF,IAAS,EAAO,QAAQ,QAAQ,KAAK,CAAC,QAAQ,QAAQ,IAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,QAAQ,wBAAwB,GAAG,MAAM,OAAO,aAAa,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,8BAA8B,GAAG,MAAM,OAAO,cAAc,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,wBAAwB,GAAG,MAAM,OAAO,aAAa,SAAS,GAAG,GAAG,CAAC,CAAC,GAK3Z,OAAO,MAAQ,QACjB,IAAS,EAAO,QAEhB,kDAAkD,GAAG,GAAQ,MAAa;GAExE,IAAM,IAAc,KAAgD,KAA+C;AACnH,UAAO,OAAO,cAAc,SAAS,GAAK,GAAG,CAAC;IAC9C,GAEG;;;AAOX,SAAS,EAAW,GAAO,GAAe;AACxC,KAAI,OAAO,KAAU,YAAY,CAAC,EAAM,SAAS,KAAK,CACpD,QAAO;CAGT,IAAM,IADc,EAAc,MAAM,EAAc,YAAY,KAAK,GAAG,EAAE,CAC5C,MAAM,SAAS;AAC/C,KAAI,GAAa;EACf,IAAM,IAAS,EAAY;AAC3B,SAAO,EAAM,QAAQ,OAAO,KAAK,IAAS;;AAE5C,QAAO"}
1
+ {"version":3,"file":"dedent-Gq6Krl4n.js","names":[],"sources":["../../node_modules/dedent/dist/dedent.mjs"],"sourcesContent":["function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return typeof key === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (typeof input !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (typeof res !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nconst dedent = createDedent({});\nexport default dedent;\nfunction createDedent(options) {\n dedent.withOptions = newOptions => createDedent(_objectSpread(_objectSpread({}, options), newOptions));\n return dedent;\n function dedent(strings, ...values) {\n const raw = typeof strings === \"string\" ? [strings] : strings.raw;\n const {\n alignValues = false,\n escapeSpecialCharacters = Array.isArray(strings),\n trimWhitespace = true\n } = options;\n\n // first, perform interpolation\n let result = \"\";\n for (let i = 0; i < raw.length; i++) {\n let next = raw[i];\n if (escapeSpecialCharacters) {\n // handle escaped newlines, backticks, and interpolation characters\n next = next.replace(/\\\\\\n[ \\t]*/g, \"\").replace(/\\\\`/g, \"`\").replace(/\\\\\\$/g, \"$\").replace(/\\\\\\{/g, \"{\");\n }\n result += next;\n if (i < values.length) {\n const value = alignValues ? alignValue(values[i], result) : values[i];\n\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n result += value;\n }\n }\n\n // now strip indentation\n const lines = result.split(\"\\n\");\n let mindent = null;\n for (const l of lines) {\n const m = l.match(/^(\\s+)\\S+/);\n if (m) {\n const indent = m[1].length;\n if (!mindent) {\n // this is the first indented line\n mindent = indent;\n } else {\n mindent = Math.min(mindent, indent);\n }\n }\n }\n if (mindent !== null) {\n const m = mindent; // appease TypeScript\n result = lines\n // https://github.com/typescript-eslint/typescript-eslint/issues/7140\n // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with\n .map(l => l[0] === \" \" || l[0] === \"\\t\" ? l.slice(m) : l).join(\"\\n\");\n }\n\n // dedent eats leading and trailing whitespace too\n if (trimWhitespace) {\n result = result.trim();\n }\n\n // Unescape escapes after trimming so sequences like `\\n`, `\\t`,\n // `\\xHH` and `\\u{...}` are preserved (fixes #24)\n if (escapeSpecialCharacters) {\n result = result.replace(/\\\\n/g, \"\\n\").replace(/\\\\t/g, \"\\t\").replace(/\\\\r/g, \"\\r\").replace(/\\\\v/g, \"\\v\").replace(/\\\\b/g, \"\\b\").replace(/\\\\f/g, \"\\f\").replace(/\\\\0/g, \"\\0\").replace(/\\\\x([\\da-fA-F]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\\\u\\{([\\da-fA-F]{1,6})\\}/g, (_, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\\\u([\\da-fA-F]{4})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));\n }\n\n // Workaround for Bun issue with Unicode characters\n // https://github.com/oven-sh/bun/issues/8745\n if (typeof Bun !== \"undefined\") {\n result = result.replace(\n // Matches e.g. \\\\u{1f60a} or \\\\u5F1F\n /\\\\u(?:\\{([\\da-fA-F]{1,6})\\}|([\\da-fA-F]{4}))/g, (_, braced, unbraced) => {\n var _ref;\n const hex = (_ref = braced !== null && braced !== void 0 ? braced : unbraced) !== null && _ref !== void 0 ? _ref : \"\";\n return String.fromCodePoint(parseInt(hex, 16));\n });\n }\n return result;\n }\n}\n\n/**\n * Adjusts the indentation of a multi-line interpolated value to match the current line.\n */\nfunction alignValue(value, precedingText) {\n if (typeof value !== \"string\" || !value.includes(\"\\n\")) {\n return value;\n }\n const currentLine = precedingText.slice(precedingText.lastIndexOf(\"\\n\") + 1);\n const indentMatch = currentLine.match(/^(\\s+)/);\n if (indentMatch) {\n const indent = indentMatch[1];\n return value.replace(/\\n/g, `\\n${indent}`);\n }\n return value;\n}\n"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,EAAQ,GAAQ,GAAgB;CAAE,IAAI,IAAO,OAAO,KAAK,CAAM;CAAG,IAAI,OAAO,uBAAuB;EAAE,IAAI,IAAU,OAAO,sBAAsB,CAAM;EAAG,MAAmB,IAAU,EAAQ,OAAO,SAAU,GAAK;GAAE,OAAO,OAAO,yBAAyB,GAAQ,CAAG,CAAC,CAAC;EAAY,CAAC,IAAI,EAAK,KAAK,MAAM,GAAM,CAAO;CAAG;CAAE,OAAO;AAAM;AACpV,SAAS,EAAc,GAAQ;CAAE,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EAAE,IAAI,IAAiB,UAAU,MAAlB,OAAsC,CAAC,IAAhB,UAAU;EAAS,IAAI,IAAI,EAAQ,OAAO,CAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,SAAU,GAAK;GAAE,EAAgB,GAAQ,GAAK,EAAO,EAAI;EAAG,CAAC,IAAI,OAAO,4BAA4B,OAAO,iBAAiB,GAAQ,OAAO,0BAA0B,CAAM,CAAC,IAAI,EAAQ,OAAO,CAAM,CAAC,CAAC,CAAC,QAAQ,SAAU,GAAK;GAAE,OAAO,eAAe,GAAQ,GAAK,OAAO,yBAAyB,GAAQ,CAAG,CAAC;EAAG,CAAC;CAAG;CAAE,OAAO;AAAQ;AACzf,SAAS,EAAgB,GAAK,GAAK,GAAO;CAAqL,OAAnL,IAAM,EAAe,CAAG,GAAO,KAAO,IAAO,OAAO,eAAe,GAAK,GAAK;EAAS;EAAO,YAAY;EA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,IAAI,GAAa;EACf,IAAM,IAAS,EAAY;EAC3B,OAAO,EAAM,QAAQ,OAAO,KAAK,GAAQ;CAC3C;CACA,OAAO;AACT"}
@@ -64,4 +64,4 @@ function a(t, n) {
64
64
  //#endregion
65
65
  export { a as n, r as t };
66
66
 
67
- //# sourceMappingURL=env-Bk-LRVos.js.map
67
+ //# sourceMappingURL=env-BPfk1VAw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env-Bk-LRVos.js","names":[],"sources":["../../src/runtime/env.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../core/types\";\n\nexport interface EnvEdit {\n type: \"comment\" | \"var\";\n /** For \"comment\": the text after `# `. For \"var\": the KEY. */\n key: string;\n /** Only for \"var\" entries. */\n value?: string;\n}\n\nfunction appendEnvContent(existing: string, content: string): string {\n const withNewLine =\n !existing.length || existing.endsWith(\"\\n\") ? existing : existing + \"\\n\";\n return withNewLine + content + \"\\n\";\n}\n\nexport function applyEnvEdits(source: string, edits: EnvEdit[]): string {\n let next = source;\n for (const edit of edits) {\n if (edit.type === \"comment\") {\n const commented = `# ${edit.key}`;\n if (!next.includes(commented)) {\n next = appendEnvContent(next, commented);\n }\n continue;\n }\n if (!next.includes(`${edit.key}=`)) {\n next = appendEnvContent(next, `${edit.key}=${edit.value ?? \"\"}`);\n }\n }\n return next;\n}\n\nexport function modifyEnv(envPath: string, edits: EnvEdit[]): ModifyOutcome {\n const existing = fs.existsSync(envPath)\n ? fs.readFileSync(envPath, \"utf8\")\n : \"\";\n const next = applyEnvEdits(existing, edits);\n if (next === existing) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(envPath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\n/**\n * Remove lines matching the given edits from env source. Var edits remove the\n * exact `KEY=...` line (anchored, so `FOO` does not match `FOO_BAR`). Comment\n * edits remove the `# key` line only when it has become orphaned — i.e. the\n * next non-blank line is another comment, another orphaned block, or EOF.\n */\nexport function removeEnvEdits(source: string, edits: EnvEdit[]): string {\n const lines = source.split(\"\\n\");\n const keep: boolean[] = lines.map(() => true);\n\n for (const edit of edits) {\n if (edit.type !== \"var\") continue;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i]) continue;\n const line = lines[i];\n if (\n line === `${edit.key}=${edit.value ?? \"\"}` ||\n line.startsWith(`${edit.key}=`)\n ) {\n keep[i] = false;\n }\n }\n }\n\n for (const edit of edits) {\n if (edit.type !== \"comment\") continue;\n const target = `# ${edit.key}`;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i] || lines[i] !== target) continue;\n let j = i + 1;\n while (j < lines.length && (!keep[j] || lines[j].trim() === \"\")) j++;\n const nextIsComment = j >= lines.length || lines[j].startsWith(\"#\");\n if (nextIsComment) {\n keep[i] = false;\n }\n }\n }\n\n const result: string[] = [];\n let lastWasBlank = false;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i]) continue;\n const isBlank = lines[i].trim() === \"\";\n if (isBlank && lastWasBlank) continue;\n result.push(lines[i]);\n lastWasBlank = isBlank;\n }\n\n while (result.length > 0 && result[result.length - 1].trim() === \"\") {\n result.pop();\n }\n\n return result.length === 0 ? \"\" : result.join(\"\\n\") + \"\\n\";\n}\n\nexport function modifyEnvRemove(\n envPath: string,\n edits: EnvEdit[],\n): ModifyOutcome {\n const existing = fs.existsSync(envPath)\n ? fs.readFileSync(envPath, \"utf8\")\n : \"\";\n const next = removeEnvEdits(existing, edits);\n if (next === existing) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(envPath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;AAWA,SAAS,EAAiB,GAAkB,GAAyB;AAGnE,SADE,CAAC,EAAS,UAAU,EAAS,SAAS,KAAK,GAAG,IAAW,IAAW,QACjD,IAAU;;AAGjC,SAAgB,EAAc,GAAgB,GAA0B;CACtE,IAAI,IAAO;AACX,MAAK,IAAM,KAAQ,GAAO;AACxB,MAAI,EAAK,SAAS,WAAW;GAC3B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,EAAK,KAAK;;;CAKhB,IAAM,IAAmB,EAAE,EACvB,IAAe;AACnB,MAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;AACrC,MAAI,CAAC,EAAK,GAAI;EACd,IAAM,IAAU,EAAM,GAAG,MAAM,KAAK;AAChC,OAAW,MACf,EAAO,KAAK,EAAM,GAAG,EACrB,IAAe;;AAGjB,QAAO,EAAO,SAAS,KAAK,EAAO,EAAO,SAAS,GAAG,MAAM,KAAK,IAC/D,GAAO,KAAK;AAGd,QAAO,EAAO,WAAW,IAAI,KAAK,EAAO,KAAK,KAAK,GAAG;;AAGxD,SAAgB,EACd,GACA,GACe;CACf,IAAM,IAAW,EAAG,WAAW,EAAQ,GACnC,EAAG,aAAa,GAAS,OAAO,GAChC,IACE,IAAO,EAAe,GAAU,EAAM;AAK5C,QAJI,MAAS,IACJ;EAAE,QAAQ;EAAW,SAAS;EAAO,IAE9C,EAAG,cAAc,GAAS,GAAM,OAAO,EAChC;EAAE,QAAQ;EAAW,SAAS;EAAM"}
1
+ {"version":3,"file":"env-BPfk1VAw.js","names":[],"sources":["../../src/runtime/env.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../core/types\";\n\nexport interface EnvEdit {\n type: \"comment\" | \"var\";\n /** For \"comment\": the text after `# `. For \"var\": the KEY. */\n key: string;\n /** Only for \"var\" entries. */\n value?: string;\n}\n\nfunction appendEnvContent(existing: string, content: string): string {\n const withNewLine =\n !existing.length || existing.endsWith(\"\\n\") ? existing : existing + \"\\n\";\n return withNewLine + content + \"\\n\";\n}\n\nexport function applyEnvEdits(source: string, edits: EnvEdit[]): string {\n let next = source;\n for (const edit of edits) {\n if (edit.type === \"comment\") {\n const commented = `# ${edit.key}`;\n if (!next.includes(commented)) {\n next = appendEnvContent(next, commented);\n }\n continue;\n }\n if (!next.includes(`${edit.key}=`)) {\n next = appendEnvContent(next, `${edit.key}=${edit.value ?? \"\"}`);\n }\n }\n return next;\n}\n\nexport function modifyEnv(envPath: string, edits: EnvEdit[]): ModifyOutcome {\n const existing = fs.existsSync(envPath)\n ? fs.readFileSync(envPath, \"utf8\")\n : \"\";\n const next = applyEnvEdits(existing, edits);\n if (next === existing) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(envPath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\n/**\n * Remove lines matching the given edits from env source. Var edits remove the\n * exact `KEY=...` line (anchored, so `FOO` does not match `FOO_BAR`). Comment\n * edits remove the `# key` line only when it has become orphaned — i.e. the\n * next non-blank line is another comment, another orphaned block, or EOF.\n */\nexport function removeEnvEdits(source: string, edits: EnvEdit[]): string {\n const lines = source.split(\"\\n\");\n const keep: boolean[] = lines.map(() => true);\n\n for (const edit of edits) {\n if (edit.type !== \"var\") continue;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i]) continue;\n const line = lines[i];\n if (\n line === `${edit.key}=${edit.value ?? \"\"}` ||\n line.startsWith(`${edit.key}=`)\n ) {\n keep[i] = false;\n }\n }\n }\n\n for (const edit of edits) {\n if (edit.type !== \"comment\") continue;\n const target = `# ${edit.key}`;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i] || lines[i] !== target) continue;\n let j = i + 1;\n while (j < lines.length && (!keep[j] || lines[j].trim() === \"\")) j++;\n const nextIsComment = j >= lines.length || lines[j].startsWith(\"#\");\n if (nextIsComment) {\n keep[i] = false;\n }\n }\n }\n\n const result: string[] = [];\n let lastWasBlank = false;\n for (let i = 0; i < lines.length; i++) {\n if (!keep[i]) continue;\n const isBlank = lines[i].trim() === \"\";\n if (isBlank && lastWasBlank) continue;\n result.push(lines[i]);\n lastWasBlank = isBlank;\n }\n\n while (result.length > 0 && result[result.length - 1].trim() === \"\") {\n result.pop();\n }\n\n return result.length === 0 ? \"\" : result.join(\"\\n\") + \"\\n\";\n}\n\nexport function modifyEnvRemove(\n envPath: string,\n edits: EnvEdit[],\n): ModifyOutcome {\n const existing = fs.existsSync(envPath)\n ? fs.readFileSync(envPath, \"utf8\")\n : \"\";\n const next = removeEnvEdits(existing, edits);\n if (next === existing) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(envPath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;AAWA,SAAS,EAAiB,GAAkB,GAAyB;CAGnE,QADE,CAAC,EAAS,UAAU,EAAS,SAAS,IAAI,IAAI,IAAW,IAAW,QACjD,IAAU;AACjC;AAEA,SAAgB,EAAc,GAAgB,GAA0B;CACtE,IAAI,IAAO;CACX,KAAK,IAAM,KAAQ,GAAO;EACxB,IAAI,EAAK,SAAS,WAAW;GAC3B,IAAM,IAAY,KAAK,EAAK;GAC5B,AAAK,EAAK,SAAS,CAAS,MAC1B,IAAO,EAAiB,GAAM,CAAS;GAEzC;EACF;EACA,AAAK,EAAK,SAAS,GAAG,EAAK,IAAI,EAAE,MAC/B,IAAO,EAAiB,GAAM,GAAG,EAAK,IAAI,GAAG,EAAK,SAAS,IAAI;CAEnE;CACA,OAAO;AACT;AAEA,SAAgB,EAAU,GAAiB,GAAiC;CAC1E,IAAM,IAAW,EAAG,WAAW,CAAO,IAClC,EAAG,aAAa,GAAS,MAAM,IAC/B,IACE,IAAO,EAAc,GAAU,CAAK;CAK1C,OAJI,MAAS,IACJ;EAAE,QAAQ;EAAW,SAAS;CAAM,KAE7C,EAAG,cAAc,GAAS,GAAM,MAAM,GAC/B;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;AAQA,SAAgB,EAAe,GAAgB,GAA0B;CACvE,IAAM,IAAQ,EAAO,MAAM,IAAI,GACzB,IAAkB,EAAM,UAAU,EAAI;CAE5C,KAAK,IAAM,KAAQ,GACb,MAAK,SAAS,OAClB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;EACrC,IAAI,CAAC,EAAK,IAAI;EACd,IAAM,IAAO,EAAM;EACnB,CACE,MAAS,GAAG,EAAK,IAAI,GAAG,EAAK,SAAS,QACtC,EAAK,WAAW,GAAG,EAAK,IAAI,EAAE,OAE9B,EAAK,KAAK;CAEd;CAGF,KAAK,IAAM,KAAQ,GAAO;EACxB,IAAI,EAAK,SAAS,WAAW;EAC7B,IAAM,IAAS,KAAK,EAAK;EACzB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;GACrC,IAAI,CAAC,EAAK,MAAM,EAAM,OAAO,GAAQ;GACrC,IAAI,IAAI,IAAI;GACZ,OAAO,IAAI,EAAM,WAAW,CAAC,EAAK,MAAM,EAAM,EAAE,CAAC,KAAK,MAAM,MAAK;GAEjE,CADsB,KAAK,EAAM,UAAU,EAAM,EAAE,CAAC,WAAW,GAAG,OAEhE,EAAK,KAAK;EAEd;CACF;CAEA,IAAM,IAAmB,CAAC,GACtB,IAAe;CACnB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;EACrC,IAAI,CAAC,EAAK,IAAI;EACd,IAAM,IAAU,EAAM,EAAE,CAAC,KAAK,MAAM;EAChC,KAAW,MACf,EAAO,KAAK,EAAM,EAAE,GACpB,IAAe;CACjB;CAEA,OAAO,EAAO,SAAS,KAAK,EAAO,EAAO,SAAS,EAAE,CAAC,KAAK,MAAM,KAC/D,EAAO,IAAI;CAGb,OAAO,EAAO,WAAW,IAAI,KAAK,EAAO,KAAK,IAAI,IAAI;AACxD;AAEA,SAAgB,EACd,GACA,GACe;CACf,IAAM,IAAW,EAAG,WAAW,CAAO,IAClC,EAAG,aAAa,GAAS,MAAM,IAC/B,IACE,IAAO,EAAe,GAAU,CAAK;CAK3C,OAJI,MAAS,IACJ;EAAE,QAAQ;EAAW,SAAS;CAAM,KAE7C,EAAG,cAAc,GAAS,GAAM,MAAM,GAC/B;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C"}
@@ -29,4 +29,4 @@ function e(e) {
29
29
  //#endregion
30
30
  export { e as getPreviewCollections };
31
31
 
32
- //# sourceMappingURL=env.preview-DoY1CJwL.js.map
32
+ //# sourceMappingURL=env.preview-uMRKT5Pc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.preview-DoY1CJwL.js","names":[],"sources":["../../src/parse/env.preview.ts"],"sourcesContent":["import type { Options } from \"../core/types\";\nimport type { Collection } from \"./types\";\n\nexport function getPreviewCollections(\n options: Pick<Options, \"features\">,\n): Collection[] {\n const collections: Collection[] = [];\n if (options.features.auth) {\n collections.push({\n id: \"users_preview\",\n name: \"users\",\n type: \"auth\",\n fields: [\n { name: \"email\", type: \"email\" },\n { name: \"name\", type: \"text\" },\n ],\n });\n }\n if (options.features.teams) {\n collections.push({\n id: \"teams_preview\",\n name: \"teams\",\n type: \"base\",\n fields: [\n { name: \"name\", type: \"text\" },\n { name: \"owner\", type: \"relation\", collectionId: \"users_preview\" },\n ],\n });\n }\n return collections;\n}\n"],"mappings":";AAGA,SAAgB,EACd,GACc;CACd,IAAM,IAA4B,EAAE;AAuBpC,QAtBI,EAAQ,SAAS,QACnB,EAAY,KAAK;EACf,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAS,MAAM;GAAS,EAChC;GAAE,MAAM;GAAQ,MAAM;GAAQ,CAC/B;EACF,CAAC,EAEA,EAAQ,SAAS,SACnB,EAAY,KAAK;EACf,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAQ,MAAM;GAAQ,EAC9B;GAAE,MAAM;GAAS,MAAM;GAAY,cAAc;GAAiB,CACnE;EACF,CAAC,EAEG"}
1
+ {"version":3,"file":"env.preview-uMRKT5Pc.js","names":[],"sources":["../../src/parse/env.preview.ts"],"sourcesContent":["import type { Options } from \"../core/types\";\nimport type { Collection } from \"./types\";\n\nexport function getPreviewCollections(\n options: Pick<Options, \"features\">,\n): Collection[] {\n const collections: Collection[] = [];\n if (options.features.auth) {\n collections.push({\n id: \"users_preview\",\n name: \"users\",\n type: \"auth\",\n fields: [\n { name: \"email\", type: \"email\" },\n { name: \"name\", type: \"text\" },\n ],\n });\n }\n if (options.features.teams) {\n collections.push({\n id: \"teams_preview\",\n name: \"teams\",\n type: \"base\",\n fields: [\n { name: \"name\", type: \"text\" },\n { name: \"owner\", type: \"relation\", collectionId: \"users_preview\" },\n ],\n });\n }\n return collections;\n}\n"],"mappings":";AAGA,SAAgB,EACd,GACc;CACd,IAAM,IAA4B,CAAC;CAuBnC,OAtBI,EAAQ,SAAS,QACnB,EAAY,KAAK;EACf,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAS,MAAM;EAAQ,GAC/B;GAAE,MAAM;GAAQ,MAAM;EAAO,CAC/B;CACF,CAAC,GAEC,EAAQ,SAAS,SACnB,EAAY,KAAK;EACf,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAQ,MAAM;EAAO,GAC7B;GAAE,MAAM;GAAS,MAAM;GAAY,cAAc;EAAgB,CACnE;CACF,CAAC,GAEI;AACT"}
@@ -28,4 +28,4 @@ async function o() {
28
28
  //#endregion
29
29
  export { o as getCollections };
30
30
 
31
- //# sourceMappingURL=env.runtime-D46GCIKe.js.map
31
+ //# sourceMappingURL=env.runtime-BVage9Kk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.runtime-D46GCIKe.js","names":[],"sources":["../../src/parse/env.runtime.ts"],"sourcesContent":["import { getCollections as getCollectionsFromPB } from \"@velastack/pocketbase/internal\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\nimport type { Collection } from \"./types\";\n\nfunction hasProjectMarkers(dir: string): boolean {\n return (\n fs.existsSync(path.join(dir, \"package.json\")) &&\n fs.existsSync(path.join(dir, \"src\", \"routes\"))\n );\n}\n\nexport function resolveProjectRoot(startDir = process.cwd()): string {\n let current = path.resolve(startDir);\n\n while (true) {\n if (hasProjectMarkers(current)) {\n return current;\n }\n\n const parent = path.dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n\n throw new Error(\n `Could not resolve project root from \"${startDir}\". Expected package.json and src/routes.`,\n );\n}\n\nexport async function getCollections(): Promise<Collection[]> {\n const root = resolveProjectRoot();\n\n return getCollectionsFromPB({\n pocketbaseUrl: \"\",\n superuserEmail: process.env.POCKETBASE_SUPERUSER_EMAIL!,\n superuserPassword: process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n root,\n }) as Promise<Collection[]>;\n}\n"],"mappings":";;;;;AAMA,SAAS,EAAkB,GAAsB;AAC/C,QACE,EAAG,WAAW,EAAK,KAAK,GAAK,eAAe,CAAC,IAC7C,EAAG,WAAW,EAAK,KAAK,GAAK,OAAO,SAAS,CAAC;;AAIlD,SAAgB,EAAmB,IAAW,EAAQ,KAAK,EAAU;CACnE,IAAI,IAAU,EAAK,QAAQ,EAAS;AAEpC,UAAa;AACX,MAAI,EAAkB,EAAQ,CAC5B,QAAO;EAGT,IAAM,IAAS,EAAK,QAAQ,EAAQ;AACpC,MAAI,MAAW,EACb;AAEF,MAAU;;AAGZ,OAAU,MACR,wCAAwC,EAAS,0CAClD;;AAGH,eAAsB,IAAwC;CAC5D,IAAM,IAAO,GAAoB;AAEjC,QAAO,EAAqB;EAC1B,eAAe;EACf,gBAAgB,EAAQ,IAAI;EAC5B,mBAAmB,EAAQ,IAAI;EAC/B;EACD,CAAC"}
1
+ {"version":3,"file":"env.runtime-BVage9Kk.js","names":[],"sources":["../../src/parse/env.runtime.ts"],"sourcesContent":["import { getCollections as getCollectionsFromPB } from \"@velastack/pocketbase/internal\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\nimport type { Collection } from \"./types\";\n\nfunction hasProjectMarkers(dir: string): boolean {\n return (\n fs.existsSync(path.join(dir, \"package.json\")) &&\n fs.existsSync(path.join(dir, \"src\", \"routes\"))\n );\n}\n\nexport function resolveProjectRoot(startDir = process.cwd()): string {\n let current = path.resolve(startDir);\n\n while (true) {\n if (hasProjectMarkers(current)) {\n return current;\n }\n\n const parent = path.dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n\n throw new Error(\n `Could not resolve project root from \"${startDir}\". Expected package.json and src/routes.`,\n );\n}\n\nexport async function getCollections(): Promise<Collection[]> {\n const root = resolveProjectRoot();\n\n return getCollectionsFromPB({\n pocketbaseUrl: \"\",\n superuserEmail: process.env.POCKETBASE_SUPERUSER_EMAIL!,\n superuserPassword: process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n root,\n }) as Promise<Collection[]>;\n}\n"],"mappings":";;;;;AAMA,SAAS,EAAkB,GAAsB;CAC/C,OACE,EAAG,WAAW,EAAK,KAAK,GAAK,cAAc,CAAC,KAC5C,EAAG,WAAW,EAAK,KAAK,GAAK,OAAO,QAAQ,CAAC;AAEjD;AAEA,SAAgB,EAAmB,IAAW,EAAQ,IAAI,GAAW;CACnE,IAAI,IAAU,EAAK,QAAQ,CAAQ;CAEnC,SAAa;EACX,IAAI,EAAkB,CAAO,GAC3B,OAAO;EAGT,IAAM,IAAS,EAAK,QAAQ,CAAO;EACnC,IAAI,MAAW,GACb;EAEF,IAAU;CACZ;CAEA,MAAU,MACR,wCAAwC,EAAS,yCACnD;AACF;AAEA,eAAsB,IAAwC;CAC5D,IAAM,IAAO,EAAmB;CAEhC,OAAO,EAAqB;EAC1B,eAAe;EACf,gBAAgB,EAAQ,IAAI;EAC5B,mBAAmB,EAAQ,IAAI;EAC/B;CACF,CAAC;AACH"}
@@ -7,4 +7,4 @@ var e = class extends Error {
7
7
  //#endregion
8
8
  export { e as t };
9
9
 
10
- //# sourceMappingURL=errors-Co77I4oK.js.map
10
+ //# sourceMappingURL=errors-D3Zy3wCg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-Co77I4oK.js","names":[],"sources":["../../src/core/errors.ts"],"sourcesContent":["export class InvalidArgumentError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidArgumentError\";\n }\n}\n"],"mappings":";AAAA,IAAa,IAAb,cAA0C,MAAM;CAC9C,YAAY,GAAiB;AAE3B,EADA,MAAM,EAAQ,EACd,KAAK,OAAO"}
1
+ {"version":3,"file":"errors-D3Zy3wCg.js","names":[],"sources":["../../src/core/errors.ts"],"sourcesContent":["export class InvalidArgumentError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidArgumentError\";\n }\n}\n"],"mappings":";AAAA,IAAa,IAAb,cAA0C,MAAM;CAC9C,YAAY,GAAiB;EAE3B,AADA,MAAM,CAAO,GACb,KAAK,OAAO;CACd;AACF"}
@@ -1,11 +1,11 @@
1
- import { t as e } from "./dedent-C4qKBQXh.js";
2
- import { i as t } from "./util-BNtpm1tP.js";
3
- import { n } from "./logger-BpgCb-ZG.js";
4
- import { t as r } from "./pocketbase-Bj-cW2Zl.js";
5
- import { modifyOutcomeToFile as i } from "./modify-file-DE7tPADZ.js";
6
- import { a, n as o, o as s, t as c } from "./ts-morph-helpers-bR0-x04t.js";
7
- import { getMigrationFile as l, migrationDelay as u, withPocketbase as d } from "./pocketbase-D7GjPuNu.js";
8
- import { applyCollectionRulePatches as f, createCollectionIdempotent as p } from "./collections-BwO27pJg.js";
1
+ import { t as e } from "./dedent-Gq6Krl4n.js";
2
+ import { i as t } from "./util-Bk7aQQJR.js";
3
+ import { n } from "./logger-CQONztPm.js";
4
+ import { t as r } from "./pocketbase-C5GS-Dh5.js";
5
+ import { modifyOutcomeToFile as i } from "./modify-file-PVKmDJHk.js";
6
+ import { a, n as o, o as s, t as c } from "./ts-morph-helpers-Bk82Z2n7.js";
7
+ import { getMigrationFile as l, migrationDelay as u, withPocketbase as d } from "./pocketbase-BbFvZ4HI.js";
8
+ import { applyCollectionRulePatches as f, createCollectionIdempotent as p } from "./collections-DZOoJLVj.js";
9
9
  import m from "node:fs";
10
10
  import h from "node:path";
11
11
  import { Project as g, SyntaxKind as _ } from "ts-morph";
@@ -443,7 +443,8 @@ async function P(e) {
443
443
  }
444
444
  ]
445
445
  }), u = l.collection;
446
- await N(a, "team_memberships", e, l.created), t.info("Creating team_users view"), await N(a, "team_users", e, (await o({
446
+ await N(a, "team_memberships", e, l.created), t.info("Creating team_users view");
447
+ let d = await o({
447
448
  name: "team_users",
448
449
  type: "view",
449
450
  fields: [
@@ -498,7 +499,9 @@ async function P(e) {
498
499
  }
499
500
  ],
500
501
  viewQuery: "select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;"
501
- })).created), t.info("Creating team_invites collection"), await N(a, "team_invites", e, (await o({
502
+ });
503
+ await N(a, "team_users", e, d.created), t.info("Creating team_invites collection");
504
+ let m = await o({
502
505
  name: "team_invites",
503
506
  type: "base",
504
507
  fields: [
@@ -539,7 +542,9 @@ async function P(e) {
539
542
  type: "autodate"
540
543
  }
541
544
  ]
542
- })).created), t.info("Creating team_invite_links collection"), await N(a, "team_invite_links", e, (await o({
545
+ });
546
+ await N(a, "team_invites", e, m.created), t.info("Creating team_invite_links collection");
547
+ let h = await o({
543
548
  name: "team_invite_links",
544
549
  type: "base",
545
550
  fields: [
@@ -576,9 +581,10 @@ async function P(e) {
576
581
  }
577
582
  ],
578
583
  indexes: ["CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)"]
579
- })).created), t.info("Applying team rule patches");
580
- let d = await f(n, r, e, t);
581
- a.push(...d);
584
+ });
585
+ await N(a, "team_invite_links", e, h.created), t.info("Applying team rule patches");
586
+ let g = await f(n, r, e, t);
587
+ a.push(...g);
582
588
  });
583
589
  let o = [], s = (e) => {
584
590
  e && o.push(e);
@@ -605,4 +611,4 @@ async function P(e) {
605
611
  //#endregion
606
612
  export { P as generate };
607
613
 
608
- //# sourceMappingURL=generate2.runtime-yP14iPwX.js.map
614
+ //# sourceMappingURL=generate.runtime-6TJoTPg9.js.map