@velastack/patterns 0.0.30 → 0.0.32

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 (47) hide show
  1. package/dist/chunks/collections-BRIAYJ-Q.js +94 -0
  2. package/dist/chunks/collections-BRIAYJ-Q.js.map +1 -0
  3. package/dist/chunks/{constants-B5Ub2oFy.js → constants-BMZmCRiI.js} +1 -1
  4. package/dist/chunks/{constants-B5Ub2oFy.js.map → constants-BMZmCRiI.js.map} +1 -1
  5. package/dist/chunks/{dedent-BFNYR8cb.js → dedent-C4qKBQXh.js} +1 -1
  6. package/dist/chunks/{dedent-BFNYR8cb.js.map → dedent-C4qKBQXh.js.map} +1 -1
  7. package/dist/chunks/{env.preview-kw0hC6y8.js → env.preview-NYMljYNr.js} +1 -1
  8. package/dist/chunks/{env.preview-kw0hC6y8.js.map → env.preview-NYMljYNr.js.map} +1 -1
  9. package/dist/chunks/{env.runtime-CJS54CZX.js → env.runtime-ZUZgxjxf.js} +2 -2
  10. package/dist/chunks/{env.runtime-CJS54CZX.js.map → env.runtime-ZUZgxjxf.js.map} +1 -1
  11. package/dist/chunks/errors-Co77I4oK.js +10 -0
  12. package/dist/chunks/errors-Co77I4oK.js.map +1 -0
  13. package/dist/chunks/{generate.runtime-InE8X2Ly.js → generate.runtime-4zd9-8H_.js} +17 -16
  14. package/dist/chunks/{generate.runtime-InE8X2Ly.js.map → generate.runtime-4zd9-8H_.js.map} +1 -1
  15. package/dist/chunks/{generate.runtime-6QnXtCSG.js → generate.runtime-BKrtBCRk.js} +14 -13
  16. package/dist/chunks/{generate.runtime-6QnXtCSG.js.map → generate.runtime-BKrtBCRk.js.map} +1 -1
  17. package/dist/chunks/{generate.runtime-BayXS2PL.js → generate.runtime-BkjQiaP_.js} +12 -11
  18. package/dist/chunks/{generate.runtime-BayXS2PL.js.map → generate.runtime-BkjQiaP_.js.map} +1 -1
  19. package/dist/chunks/{generate.runtime-BpZPXyba.js → generate.runtime-CXqD8em8.js} +13 -12
  20. package/dist/chunks/{generate.runtime-BpZPXyba.js.map → generate.runtime-CXqD8em8.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-DpT7Jzh4.js → generate.runtime-CbiQhqdL.js} +5 -4
  22. package/dist/chunks/{generate.runtime-DpT7Jzh4.js.map → generate.runtime-CbiQhqdL.js.map} +1 -1
  23. package/dist/chunks/{generate.runtime-BUbI1GmK.js → generate.runtime-DpeB3h-P.js} +15 -14
  24. package/dist/chunks/{generate.runtime-BUbI1GmK.js.map → generate.runtime-DpeB3h-P.js.map} +1 -1
  25. package/dist/chunks/{generate.runtime-B8_5O6Qr.js → generate.runtime-uk9-KOP-.js} +19 -18
  26. package/dist/chunks/{generate.runtime-B8_5O6Qr.js.map → generate.runtime-uk9-KOP-.js.map} +1 -1
  27. package/dist/chunks/{modify-file-CpqC7kMR.js → modify-file-D3OuKUEp.js} +2 -2
  28. package/dist/chunks/{modify-file-CpqC7kMR.js.map → modify-file-D3OuKUEp.js.map} +1 -1
  29. package/dist/chunks/{modify-svelte-config-remote-DWsScM6m.js → modify-svelte-config-remote-Dzgk1OIN.js} +1 -1
  30. package/dist/chunks/{modify-svelte-config-remote-DWsScM6m.js.map → modify-svelte-config-remote-Dzgk1OIN.js.map} +1 -1
  31. package/dist/chunks/{pocketbase-CDu4GzZD.js → pocketbase--dNkFDJ5.js} +1 -1
  32. package/dist/chunks/{pocketbase-CDu4GzZD.js.map → pocketbase--dNkFDJ5.js.map} +1 -1
  33. package/dist/chunks/{pocketbase-CmKcAXDf.js → pocketbase-W_FJaYZ3.js} +3 -3
  34. package/dist/chunks/{pocketbase-CmKcAXDf.js.map → pocketbase-W_FJaYZ3.js.map} +1 -1
  35. package/dist/chunks/{ts-morph-helpers-BMxk6lHK.js → ts-morph-helpers-digNcfBD.js} +1 -1
  36. package/dist/chunks/{ts-morph-helpers-BMxk6lHK.js.map → ts-morph-helpers-digNcfBD.js.map} +1 -1
  37. package/dist/chunks/{util-k-qPjL06.js → util-C064WO8o.js} +4 -3
  38. package/dist/chunks/{util-k-qPjL06.js.map → util-C064WO8o.js.map} +1 -1
  39. package/dist/chunks/{write-result-ENWLDQtP.js → write-result-C80dpjr-.js} +1 -1
  40. package/dist/chunks/{write-result-ENWLDQtP.js.map → write-result-C80dpjr-.js.map} +1 -1
  41. package/dist/index.d.ts +102 -22
  42. package/dist/index.js +1102 -937
  43. package/dist/index.js.map +1 -1
  44. package/package.json +1 -1
  45. package/dist/chunks/collections-Bs9xy7nU.js +0 -54
  46. package/dist/chunks/collections-Bs9xy7nU.js.map +0 -1
  47. /package/dist/chunks/{taggedTemplateLiteral-BLWebVbJ.js → taggedTemplateLiteral-Bfbldyfk.js} +0 -0
@@ -0,0 +1,94 @@
1
+ import { t as e } from "./errors-Co77I4oK.js";
2
+ import { n as t } from "./util-C064WO8o.js";
3
+ import { getMigrationFile as n, migrationDelay as r, withPocketbase as i } from "./pocketbase-W_FJaYZ3.js";
4
+ import { readFileSync as a } from "node:fs";
5
+ //#region src/runtime/collections.ts
6
+ function o(e) {
7
+ if (e.response?.data?.name?.code === "validation_not_unique") return !0;
8
+ let t = e.message?.toLowerCase() ?? "";
9
+ return t.includes("already exists") || t.includes("must be unique");
10
+ }
11
+ function s(e) {
12
+ let t = {};
13
+ return e.listRule !== void 0 && (t.listRule = e.listRule), e.viewRule !== void 0 && (t.viewRule = e.viewRule), e.createRule !== void 0 && (t.createRule = e.createRule), e.updateRule !== void 0 && (t.updateRule = e.updateRule), e.deleteRule !== void 0 && (t.deleteRule = e.deleteRule), t;
14
+ }
15
+ async function c(e, i, o) {
16
+ let c = [];
17
+ for (let l of i) {
18
+ let i = l.collectionName.replace(/'/g, "''"), u = await e.collections.getFirstListItem(`name='${i}'`);
19
+ if (await e.collections.update(u.id, s(l)), await r(), o) {
20
+ let e = n(l.collectionName, "updated", o);
21
+ e && c.push({
22
+ path: e,
23
+ language: t(e),
24
+ content: a(e, "utf8"),
25
+ status: "success"
26
+ });
27
+ }
28
+ }
29
+ return c;
30
+ }
31
+ function l(t, n) {
32
+ let r = t.map((e) => ({ ...e }));
33
+ for (let t of n.changes) {
34
+ if (t.op === "add") {
35
+ if (r.some((e) => e.name === t.field.name)) throw new e(`Field "${t.field.name}" already exists on collection "${n.collectionName}"`);
36
+ r.push(t.field);
37
+ continue;
38
+ }
39
+ if (t.op === "remove") {
40
+ let i = r.findIndex((e) => e.name === t.fieldName);
41
+ if (i === -1) throw new e(`Field "${t.fieldName}" does not exist on collection "${n.collectionName}"`);
42
+ r.splice(i, 1);
43
+ continue;
44
+ }
45
+ if (t.op === "rename") {
46
+ let i = r.find((e) => e.name === t.from);
47
+ if (!i) throw new e(`Field "${t.from}" does not exist on collection "${n.collectionName}"`);
48
+ if (r.some((e) => e.name === t.to)) throw new e(`Field "${t.to}" already exists on collection "${n.collectionName}"`);
49
+ i.name = t.to;
50
+ continue;
51
+ }
52
+ }
53
+ return r;
54
+ }
55
+ async function u(e, i, o) {
56
+ let s = [];
57
+ for (let c of i) {
58
+ let i = await e.collections.getOne(c.collectionName), u = l(i.fields, c);
59
+ await e.collections.update(i.id, { fields: u }), await r();
60
+ let d = n(c.collectionName, "updated", o);
61
+ d && s.push({
62
+ path: d,
63
+ language: t(d),
64
+ content: a(d, "utf8"),
65
+ status: "success"
66
+ });
67
+ }
68
+ return s;
69
+ }
70
+ async function d(e, s) {
71
+ if (e.length === 0) return [];
72
+ let c = [];
73
+ return await i(s.root, async (i) => {
74
+ for (let l of e) {
75
+ try {
76
+ await i.collections.create(l);
77
+ } catch (e) {
78
+ throw o(e) ? Error(`Collection "${l.name}" already exists. Choose a different model name or remove the existing collection first.`) : e;
79
+ }
80
+ await r();
81
+ let e = n(l.name, "created", s);
82
+ e && c.push({
83
+ path: e,
84
+ language: t(e),
85
+ content: a(e, "utf8"),
86
+ status: "success"
87
+ });
88
+ }
89
+ }), c;
90
+ }
91
+ //#endregion
92
+ export { u as applyCollectionFieldsPatches, c as applyCollectionRulePatches, d as createCollections };
93
+
94
+ //# sourceMappingURL=collections-BRIAYJ-Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections-BRIAYJ-Q.js","names":[],"sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type {\n CollectionFieldSpec,\n CollectionFieldsPatch,\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\nimport { InvalidArgumentError } from \"../core/errors\";\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 (error.response?.data?.name?.code === \"validation_not_unique\") {\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\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): 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 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): 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 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 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\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n try {\n await pb.collections.create(collection);\n } catch (error) {\n if (\n isCollectionAlreadyExistsError(\n error as PocketBaseCollectionCreateError,\n )\n ) {\n throw new Error(\n `Collection \"${collection.name}\" already exists. Choose a different model name or remove the existing collection first.`,\n );\n }\n throw error;\n }\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":";;;;;AAwBA,SAAS,EACP,GACS;AACT,KAAI,EAAM,UAAU,MAAM,MAAM,SAAS,wBACvC,QAAO;CAGT,IAAM,IAAU,EAAM,SAAS,aAAa,IAAI;AAChD,QACE,EAAQ,SAAS,iBAAiB,IAAI,EAAQ,SAAS,iBAAiB;;AAI5E,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,aAAa,EAAM,aAC3D,EAAM,eAAe,KAAA,MAAW,EAAQ,aAAa,EAAM,aAC3D,EAAM,eAAe,KAAA,MAAW,EAAQ,aAAa,EAAM,aACxD;;AAOT,eAAsB,EACpB,GAMA,GACA,GACiB;CACjB,IAAM,IAAq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AO,GAAG,kCAAkC,EAAM,eAAe,GAC5E;AAEH,KAAM,OAAO,EAAO;AACpB;;;AAIJ,QAAO;;AAGT,eAAsB,EACpB,GAQA,GACA,GACiB;CACjB,IAAM,IAAqB,EAAE;AAE7B,MAAK,IAAM,KAAS,GAAS;EAC3B,IAAM,IAAa,MAAM,EAAG,YAAY,OAAO,EAAM,eAAe,EAC9D,IAAY,EAAkB,EAAW,QAAQ,EAAM;AAE7D,EADA,MAAM,EAAG,YAAY,OAAO,EAAW,IAAI,EAAE,QAAQ,GAAW,CAAC,EACjE,MAAM,GAAgB;EAEtB,IAAM,IAAgB,EACpB,EAAM,gBACN,WACA,EACD;AACI,OAEL,EAAW,KAAK;GACd,MAAM;GACN,UAAU,EAAiB,EAAc;GACzC,SAAS,EAAa,GAAe,OAAO;GAC5C,QAAQ;GACT,CAAC;;AAGJ,QAAO;;AAGT,eAAsB,EACpB,GACA,GACiB;AACjB,KAAI,EAAY,WAAW,EACzB,QAAO,EAAE;CAGX,IAAM,IAAqB,EAAE;AAsC7B,QApCA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;AAC/C,OAAK,IAAM,KAAc,GAAa;AACpC,OAAI;AACF,UAAM,EAAG,YAAY,OAAO,EAAW;YAChC,GAAO;AAUd,UARE,EACE,EACD,GAES,MACR,eAAe,EAAW,KAAK,0FAChC,GAEG;;AAER,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"}
@@ -3,4 +3,4 @@ var e = "data", t = "migrations", n = "(public)", r = "(app)";
3
3
  //#endregion
4
4
  export { n as i, e as n, t as r, r as t };
5
5
 
6
- //# sourceMappingURL=constants-B5Ub2oFy.js.map
6
+ //# sourceMappingURL=constants-BMZmCRiI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants-B5Ub2oFy.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-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"}
@@ -84,4 +84,4 @@ function s(e, t) {
84
84
  //#endregion
85
85
  export { a as t };
86
86
 
87
- //# sourceMappingURL=dedent-BFNYR8cb.js.map
87
+ //# sourceMappingURL=dedent-C4qKBQXh.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dedent-BFNYR8cb.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 = indentMat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;;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-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,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AAS,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"}
@@ -16,4 +16,4 @@ function e(e) {
16
16
  //#endregion
17
17
  export { e as getPreviewCollections };
18
18
 
19
- //# sourceMappingURL=env.preview-kw0hC6y8.js.map
19
+ //# sourceMappingURL=env.preview-NYMljYNr.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.preview-kw0hC6y8.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 if (options.features.auth) {\n return [\n {\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 }\n return [];\n}\n"],"mappings":";AAGA,SAAgB,EACd,GACc;AAcd,QAbI,EAAQ,SAAS,OACZ,CACL;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAS,MAAM;GAAS,EAChC;GAAE,MAAM;GAAQ,MAAM;GAAQ,CAC/B;EACF,CACF,GAEI,EAAE"}
1
+ {"version":3,"file":"env.preview-NYMljYNr.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 if (options.features.auth) {\n return [\n {\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 }\n return [];\n}\n"],"mappings":";AAGA,SAAgB,EACd,GACc;AAcd,QAbI,EAAQ,SAAS,OACZ,CACL;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAS,MAAM;GAAS,EAChC;GAAE,MAAM;GAAQ,MAAM;GAAQ,CAC/B;EACF,CACF,GAEI,EAAE"}
@@ -1,4 +1,4 @@
1
- import { n as e } from "./constants-B5Ub2oFy.js";
1
+ import { n as e } from "./constants-BMZmCRiI.js";
2
2
  import { getCollections as t } from "@velastack/pocketbase/internal";
3
3
  import n from "node:fs";
4
4
  import r from "node:path";
@@ -29,4 +29,4 @@ async function s() {
29
29
  //#endregion
30
30
  export { s as getCollections };
31
31
 
32
- //# sourceMappingURL=env.runtime-CJS54CZX.js.map
32
+ //# sourceMappingURL=env.runtime-ZUZgxjxf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.runtime-CJS54CZX.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 { DATA_DIR } from \"../core/constants\";\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, DATA_DIR))\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 ${DATA_DIR}.`,\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":";;;;;;AAOA,SAAS,EAAkB,GAAsB;AAC/C,QACE,EAAG,WAAW,EAAK,KAAK,GAAK,eAAe,CAAC,IAC7C,EAAG,WAAW,EAAK,KAAK,GAAA,OAAc,CAAC;;AAI3C,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,gCAAgC,EAAS,GAC3F;;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-ZUZgxjxf.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 { DATA_DIR } from \"../core/constants\";\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, DATA_DIR))\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 ${DATA_DIR}.`,\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":";;;;;;AAOA,SAAS,EAAkB,GAAsB;AAC/C,QACE,EAAG,WAAW,EAAK,KAAK,GAAK,eAAe,CAAC,IAC7C,EAAG,WAAW,EAAK,KAAK,GAAA,OAAc,CAAC;;AAI3C,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,gCAAgC,EAAS,GAC3F;;AAGH,eAAsB,IAAwC;CAC5D,IAAM,IAAO,GAAoB;AAEjC,QAAO,EAAqB;EAC1B,eAAe;EACf,gBAAgB,EAAQ,IAAI;EAC5B,mBAAmB,EAAQ,IAAI;EAC/B;EACD,CAAC"}
@@ -0,0 +1,10 @@
1
+ //#region src/core/errors.ts
2
+ var e = class extends Error {
3
+ constructor(e) {
4
+ super(e), this.name = "InvalidArgumentError";
5
+ }
6
+ };
7
+ //#endregion
8
+ export { e as t };
9
+
10
+ //# sourceMappingURL=errors-Co77I4oK.js.map
@@ -0,0 +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,9 +1,9 @@
1
- import { t as e } from "./dedent-BFNYR8cb.js";
2
- import { n as t } from "./util-k-qPjL06.js";
3
- import { t as n } from "./taggedTemplateLiteral-BLWebVbJ.js";
4
- import { n as r, r as i, t as a } from "./pocketbase-CmKcAXDf.js";
5
- import { modifyOutcomeToFile as o } from "./modify-file-CpqC7kMR.js";
6
- import { i as s, t as c } from "./ts-morph-helpers-BMxk6lHK.js";
1
+ import { t as e } from "./dedent-C4qKBQXh.js";
2
+ import { n as t } from "./util-C064WO8o.js";
3
+ import { t as n } from "./taggedTemplateLiteral-Bfbldyfk.js";
4
+ import { getMigrationFile as r, migrationDelay as i, withPocketbase as a } from "./pocketbase-W_FJaYZ3.js";
5
+ import { modifyOutcomeToFile as o } from "./modify-file-D3OuKUEp.js";
6
+ import { i as s, t as c } from "./ts-morph-helpers-digNcfBD.js";
7
7
  import l from "node:fs";
8
8
  import u from "node:path";
9
9
  import { Project as d, QuoteKind as f, SyntaxKind as p } from "ts-morph";
@@ -216,9 +216,9 @@ async function O(e) {
216
216
  //#endregion
217
217
  //#region src/patterns/enable/payments/generate.runtime.ts
218
218
  var k;
219
- async function A(e, n, i, o) {
220
- await r();
221
- let s = a(n, i, o);
219
+ async function A(e, n, a, o) {
220
+ await i();
221
+ let s = r(n, a, o);
222
222
  s && e.push({
223
223
  path: s,
224
224
  language: t(s),
@@ -230,7 +230,7 @@ function j(t) {
230
230
  return e(k ||= n(["\n <script lang=\"ts\">\n import PaymentButton from '$lib/components/payments/payment-button.svelte';\n <\/script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"", "\" />\n </section>\n "]), t);
231
231
  }
232
232
  async function M(e) {
233
- let { stripeSecretKey: t, stripePublishableKey: n, stripeWebhookSecret: r } = e.input, a = e.features.auth, s = [], c = [], l = (e) => {
233
+ let { stripeSecretKey: t, stripePublishableKey: n, stripeWebhookSecret: r } = e.input, i = e.features.auth, s = [], c = [], l = (e) => {
234
234
  e && c.push(e);
235
235
  }, d = m(16).toString("hex"), f = [
236
236
  {
@@ -258,7 +258,7 @@ async function M(e) {
258
258
  value: d
259
259
  }
260
260
  ], p = u.join(e.root, ".env");
261
- l(o(p, D(p, f))), await i(e.root, async (t) => {
261
+ l(o(p, D(p, f))), await a(e.root, async (t) => {
262
262
  if (await t.collections.create({
263
263
  name: "stripe_products",
264
264
  type: "base",
@@ -359,7 +359,7 @@ async function M(e) {
359
359
  type: "autodate"
360
360
  }
361
361
  ]
362
- }), await A(s, "stripe_prices", "created", e), a) {
362
+ }), await A(s, "stripe_prices", "created", e), i) {
363
363
  let n = await t.collections.create({
364
364
  name: "stripe_customers",
365
365
  type: "base",
@@ -560,7 +560,7 @@ async function M(e) {
560
560
  }
561
561
  });
562
562
  let { product: h, price: g } = await O(t);
563
- if (await i(e.root, async (e) => {
563
+ if (await a(e.root, async (e) => {
564
564
  await e.collection("stripe_products").create({
565
565
  id: h.id,
566
566
  name: h.name,
@@ -581,7 +581,7 @@ async function M(e) {
581
581
  language: "svelte",
582
582
  content: j(g.id),
583
583
  status: "success"
584
- }), a) {
584
+ }), i) {
585
585
  let t = u.join(e.root, "src", "lib", "components", "nav-user.svelte");
586
586
  l(o(t, b(t)));
587
587
  let n = u.join(e.root, "src", "routes", "(public)", "signup", "+page.server.ts");
@@ -593,10 +593,11 @@ async function M(e) {
593
593
  deletes: [],
594
594
  components: [],
595
595
  packages: [],
596
- collections: []
596
+ collections: [],
597
+ collectionPatches: []
597
598
  };
598
599
  }
599
600
  //#endregion
600
601
  export { M as generate };
601
602
 
602
- //# sourceMappingURL=generate.runtime-InE8X2Ly.js.map
603
+ //# sourceMappingURL=generate.runtime-4zd9-8H_.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-InE8X2Ly.js","names":[],"sources":["../../src/patterns/enable/payments/modifies/modify-nav-user.ts","../../src/patterns/enable/payments/modifies/modify-user-signup.ts","../../src/patterns/enable/payments/modifies/modify-env.ts","../../src/patterns/enable/payments/runtime/stripe.ts","../../src/patterns/enable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BILLING_NAV_SNIPPET = [\n \"import CreditCardIcon from '@lucide/svelte/icons/credit-card';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Billing', url: '/billing', icon: CreditCardIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Billing nav item to nav-user.svelte:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Billing entry:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Billing\",\n \"/billing\",\n \"CreditCardIcon\",\n \"@lucide/svelte/icons/credit-card\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst LINK_STRIPE_CUSTOMER_SNIPPET = dedent`\n const linkStripeCustomer = async (email: string, user: { id: string }, locals: App.Locals) => {\n const matchingCustomer = await stripe.customers.list({\n email: email,\n limit: 1,\n expand: ['data.invoice_settings']\n });\n\n let customer;\n let isExistingCustomer = false;\n\n if (matchingCustomer.data.length > 0) {\n isExistingCustomer = true;\n customer = matchingCustomer.data[0];\n } else {\n customer = await stripe.customers.create({\n email: email\n });\n }\n\n await locals.admin.collection('stripe_customers').create({\n id: customer.id,\n user: user.id\n });\n\n if (!isExistingCustomer) {\n return;\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(customer.id, {\n type: 'card',\n allow_redisplay: 'always'\n });\n\n for (const paymentMethod of paymentMethods.data) {\n if (paymentMethod.allow_redisplay === 'unspecified') {\n continue;\n }\n\n await locals.admin.collection('stripe_payment_methods').create({\n id: paymentMethod.id,\n customer: customer.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year\n });\n }\n\n const defaultPaymentMethod = customer.invoice_settings?.default_payment_method;\n\n if (defaultPaymentMethod) {\n try {\n await locals.admin.collection('stripe_customers').update(customer.id, {\n default_payment_method: defaultPaymentMethod\n });\n } catch {}\n }\n };\n`;\n\nconst FAILURE_HINT = [\n \"Could not locate the requestVerification call in signup +page.server.ts.\",\n \"Add a linkStripeCustomer helper and call it before requestVerification().\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(public)/signup/+page.server.ts before enabling payments.\",\n].join(\"\\n\");\n\nexport function modifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n const hasStripeImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"$lib/stripe\");\n\n if (hasStripeImport) {\n return { status: \"success\", changed: false };\n }\n\n sourceFile.addImportDeclaration({\n defaultImport: \"stripe\",\n moduleSpecifier: \"$lib/stripe\",\n });\n\n const requestVerificationCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => {\n const expr = ce.getExpression();\n return (\n expr.getKind() === SyntaxKind.PropertyAccessExpression &&\n expr.getText().includes(\"requestVerification\")\n );\n });\n\n if (!requestVerificationCall) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const statement = requestVerificationCall.getFirstAncestorByKind(\n SyntaxKind.ExpressionStatement,\n );\n\n if (!statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n sourceFile.addStatements(LINK_STRIPE_CUSTOMER_SNIPPET);\n\n const stripeCall = dedent`\n await linkStripeCustomer(form.data.email, user, locals);\n `;\n\n statement.replaceWithText(stripeCall + \"\\n\\n\" + statement.getText());\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","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","import Stripe from \"stripe\";\n\nexport interface StripeTestFixture {\n product: Stripe.Product;\n price: Stripe.Price;\n existing: boolean;\n}\n\nexport async function createTestProductAndPrice(\n stripeSecretKey: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n\n const products = await stripe.products.search({\n query: `name:\"Test Product\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n const product = products.data[0];\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n if (prices.data.length > 0) {\n return { product, price: prices.data[0], existing: true };\n }\n }\n\n const product = await stripe.products.create({\n name: \"Test Product\",\n metadata: { test: \"true\" },\n });\n\n const price = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n });\n\n return { product, price, existing: false };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { randomBytes } from \"node:crypto\";\nimport dedent from \"dedent\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { modifyEnv, type EnvEdit } from \"./modifies/modify-env\";\nimport { createTestProductAndPrice } from \"./runtime/stripe\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n action: \"created\" | \"updated\",\n options: Options,\n) {\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, action, options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nfunction paymentPageSnippet(priceId: string): string {\n return dedent`\n <script lang=\"ts\">\n import PaymentButton from '$lib/components/payments/payment-button.svelte';\n </script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"${priceId}\" />\n </section>\n `;\n}\n\nexport async function generate(options: Options) {\n const { stripeSecretKey, stripePublishableKey, stripeWebhookSecret } =\n options.input as {\n stripeSecretKey: string;\n stripePublishableKey: string;\n stripeWebhookSecret: string;\n };\n\n const isAppMode = options.features.auth;\n const creates: File[] = [];\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n const internalJobSecret = randomBytes(16).toString(\"hex\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\", value: stripeSecretKey },\n {\n type: \"var\",\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n value: stripePublishableKey,\n },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\", value: stripeWebhookSecret },\n { type: \"var\", key: \"INTERNAL_JOB_SECRET\", value: internalJobSecret },\n ];\n\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnv(envPath, envEdits)));\n\n await withPocketbase(options.root, async (pb) => {\n await pb.collections.create({\n name: \"stripe_products\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"name\", required: false, type: \"text\" },\n { name: \"active\", required: false, type: \"text\" },\n { name: \"default_price\", required: false, type: \"text\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(creates, \"stripe_products\", \"created\", options);\n\n await pb.collections.create({\n name: \"stripe_prices\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"billing_scheme\", required: false, type: \"text\" },\n { name: \"currency\", required: false, type: \"text\" },\n { name: \"product\", required: false, type: \"text\" },\n { name: \"recurring\", required: false, type: \"text\" },\n { name: \"type\", required: false, type: \"text\" },\n { name: \"unit_amount\", required: false, type: \"number\" },\n { name: \"active\", required: false, type: \"bool\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(creates, \"stripe_prices\", \"created\", options);\n\n if (isAppMode) {\n const stripeCustomersCollection = await pb.collections.create({\n name: \"stripe_customers\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"created\",\n options,\n );\n\n const stripePaymentMethodsCollection = await pb.collections.create({\n name: \"stripe_payment_methods\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"exp_month\", required: true, type: \"number\" },\n { name: \"exp_year\", required: true, type: \"number\" },\n {\n collectionId: stripeCustomersCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"customer\",\n required: true,\n type: \"relation\",\n cascadeDelete: true,\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_payment_methods\",\n \"created\",\n options,\n );\n\n await pb.collections.update(\"stripe_customers\", {\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n collectionId: stripePaymentMethodsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"default_payment_method\",\n required: false,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"updated\",\n options,\n );\n\n await pb.collections.create({\n name: \"transactions\",\n type: \"base\",\n fields: [\n {\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"stripe_payment_intent\", required: true, type: \"text\" },\n { name: \"amount\", required: true, type: \"number\" },\n { name: \"currency\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"created\", required: true, type: \"date\" },\n { name: \"stripe_charge\", required: true, type: \"text\" },\n { name: \"stripe_customer\", required: true, type: \"text\" },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n { name: \"receipt_url\", required: true, type: \"url\" },\n ],\n });\n await pushMigrationCreates(creates, \"transactions\", \"created\", options);\n }\n });\n\n const { product, price } = await createTestProductAndPrice(stripeSecretKey);\n\n await withPocketbase(options.root, async (pb) => {\n await pb.collection(\"stripe_products\").create({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price: product.default_price,\n });\n\n await pb.collection(\"stripe_prices\").create({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: price.product,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n });\n });\n\n creates.push({\n path: \"src/routes/(public)/payment/+page.svelte\",\n language: \"svelte\",\n content: paymentPageSnippet(price.id),\n status: \"success\",\n });\n\n if (isAppMode) {\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, modifyUserSignup(userSignupPath)),\n );\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAKA,IAAM,IAAsB;CAC1B;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAe;CACnB;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAiB;CACrB;CACA;CACA;CACD,CAAC,KAAK,KAAK;AAEZ,SAAgB,EACd,GACA,GACA,GACA,GACA,GACkD;CAClD,IAAM,IAAO,IAAI,EAAW,EAAe,EACvC,IAAW,IAET,KAAU,MAAgD;AAC1D,OACJ,GAAK,MAAW;GACd,IAAM,IAAS,EACb,GACA,GACA,GACA,GACA,EACD;AAED,UADI,EAAO,aAAU,IAAW,KACzB,EAAO;IACd;;AAMJ,QAHA,GAAQ,MAAO,EAAK,mBAAmB,EAAG,CAAC,EACtC,KAAU,GAAQ,MAAO,EAAK,aAAa,EAAG,CAAC,EAE7C;EAAE,mBAAmB,EAAK,UAAU;EAAE;EAAU;;AAGzD,SAAgB,EAAc,GAAoC;AAChE,KAAI,CAAC,EAAG,WAAW,EAAY,CAC7B,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;CAGzD,IAAM,IAAiB,EAAG,aAAa,GAAa,OAAO;AAC3D,KAAI,EAAe,SAAS,WA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EF,MAAM,EAAG,WAAW,gBAAgB,CAAC,OAAO;GAC1C,IAAI,EAAM;GACV,gBAAgB,EAAM;GACtB,UAAU,EAAM;GAChB,SAAS,EAAM;GACf,WAAW,EAAM;GACjB,MAAM,EAAM;GACZ,aAAa,EAAM;GACnB,QAAQ,EAAM;GACf,CAAC;GACF,EAEF,EAAQ,KAAK;EACX,MAAM;EACN,UAAU;EACV,SAAS,EAAmB,EAAM,GAAG;EACrC,QAAQ;EACT,CAAC,EAEE,GAAW;EACb,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,kBACD;AACD,IAAW,EAAoB,GAAa,EAAc,EAAY,CAAC,CAAC;EAExE,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,YACA,UACA,kBACD;AACD,IACE,EAAoB,GAAgB,EAAiB,EAAe,CAAC,CACtE;;AAGH,QAAO;EACL;EACA;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EAChB"}
1
+ {"version":3,"file":"generate.runtime-4zd9-8H_.js","names":[],"sources":["../../src/patterns/enable/payments/modifies/modify-nav-user.ts","../../src/patterns/enable/payments/modifies/modify-user-signup.ts","../../src/patterns/enable/payments/modifies/modify-env.ts","../../src/patterns/enable/payments/runtime/stripe.ts","../../src/patterns/enable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BILLING_NAV_SNIPPET = [\n \"import CreditCardIcon from '@lucide/svelte/icons/credit-card';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Billing', url: '/billing', icon: CreditCardIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Billing nav item to nav-user.svelte:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Billing entry:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Billing\",\n \"/billing\",\n \"CreditCardIcon\",\n \"@lucide/svelte/icons/credit-card\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst LINK_STRIPE_CUSTOMER_SNIPPET = dedent`\n const linkStripeCustomer = async (email: string, user: { id: string }, locals: App.Locals) => {\n const matchingCustomer = await stripe.customers.list({\n email: email,\n limit: 1,\n expand: ['data.invoice_settings']\n });\n\n let customer;\n let isExistingCustomer = false;\n\n if (matchingCustomer.data.length > 0) {\n isExistingCustomer = true;\n customer = matchingCustomer.data[0];\n } else {\n customer = await stripe.customers.create({\n email: email\n });\n }\n\n await locals.admin.collection('stripe_customers').create({\n id: customer.id,\n user: user.id\n });\n\n if (!isExistingCustomer) {\n return;\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(customer.id, {\n type: 'card',\n allow_redisplay: 'always'\n });\n\n for (const paymentMethod of paymentMethods.data) {\n if (paymentMethod.allow_redisplay === 'unspecified') {\n continue;\n }\n\n await locals.admin.collection('stripe_payment_methods').create({\n id: paymentMethod.id,\n customer: customer.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year\n });\n }\n\n const defaultPaymentMethod = customer.invoice_settings?.default_payment_method;\n\n if (defaultPaymentMethod) {\n try {\n await locals.admin.collection('stripe_customers').update(customer.id, {\n default_payment_method: defaultPaymentMethod\n });\n } catch {}\n }\n };\n`;\n\nconst FAILURE_HINT = [\n \"Could not locate the requestVerification call in signup +page.server.ts.\",\n \"Add a linkStripeCustomer helper and call it before requestVerification().\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(public)/signup/+page.server.ts before enabling payments.\",\n].join(\"\\n\");\n\nexport function modifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n const hasStripeImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"$lib/stripe\");\n\n if (hasStripeImport) {\n return { status: \"success\", changed: false };\n }\n\n sourceFile.addImportDeclaration({\n defaultImport: \"stripe\",\n moduleSpecifier: \"$lib/stripe\",\n });\n\n const requestVerificationCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => {\n const expr = ce.getExpression();\n return (\n expr.getKind() === SyntaxKind.PropertyAccessExpression &&\n expr.getText().includes(\"requestVerification\")\n );\n });\n\n if (!requestVerificationCall) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const statement = requestVerificationCall.getFirstAncestorByKind(\n SyntaxKind.ExpressionStatement,\n );\n\n if (!statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n sourceFile.addStatements(LINK_STRIPE_CUSTOMER_SNIPPET);\n\n const stripeCall = dedent`\n await linkStripeCustomer(form.data.email, user, locals);\n `;\n\n statement.replaceWithText(stripeCall + \"\\n\\n\" + statement.getText());\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","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","import Stripe from \"stripe\";\n\nexport interface StripeTestFixture {\n product: Stripe.Product;\n price: Stripe.Price;\n existing: boolean;\n}\n\nexport async function createTestProductAndPrice(\n stripeSecretKey: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n\n const products = await stripe.products.search({\n query: `name:\"Test Product\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n const product = products.data[0];\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n if (prices.data.length > 0) {\n return { product, price: prices.data[0], existing: true };\n }\n }\n\n const product = await stripe.products.create({\n name: \"Test Product\",\n metadata: { test: \"true\" },\n });\n\n const price = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n });\n\n return { product, price, existing: false };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { randomBytes } from \"node:crypto\";\nimport dedent from \"dedent\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { modifyEnv, type EnvEdit } from \"./modifies/modify-env\";\nimport { createTestProductAndPrice } from \"./runtime/stripe\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n action: \"created\" | \"updated\",\n options: Options,\n) {\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, action, options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nfunction paymentPageSnippet(priceId: string): string {\n return dedent`\n <script lang=\"ts\">\n import PaymentButton from '$lib/components/payments/payment-button.svelte';\n </script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"${priceId}\" />\n </section>\n `;\n}\n\nexport async function generate(options: Options) {\n const { stripeSecretKey, stripePublishableKey, stripeWebhookSecret } =\n options.input as {\n stripeSecretKey: string;\n stripePublishableKey: string;\n stripeWebhookSecret: string;\n };\n\n const isAppMode = options.features.auth;\n const creates: File[] = [];\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n const internalJobSecret = randomBytes(16).toString(\"hex\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\", value: stripeSecretKey },\n {\n type: \"var\",\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n value: stripePublishableKey,\n },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\", value: stripeWebhookSecret },\n { type: \"var\", key: \"INTERNAL_JOB_SECRET\", value: internalJobSecret },\n ];\n\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnv(envPath, envEdits)));\n\n await withPocketbase(options.root, async (pb) => {\n await pb.collections.create({\n name: \"stripe_products\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"name\", required: false, type: \"text\" },\n { name: \"active\", required: false, type: \"text\" },\n { name: \"default_price\", required: false, type: \"text\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(creates, \"stripe_products\", \"created\", options);\n\n await pb.collections.create({\n name: \"stripe_prices\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"billing_scheme\", required: false, type: \"text\" },\n { name: \"currency\", required: false, type: \"text\" },\n { name: \"product\", required: false, type: \"text\" },\n { name: \"recurring\", required: false, type: \"text\" },\n { name: \"type\", required: false, type: \"text\" },\n { name: \"unit_amount\", required: false, type: \"number\" },\n { name: \"active\", required: false, type: \"bool\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(creates, \"stripe_prices\", \"created\", options);\n\n if (isAppMode) {\n const stripeCustomersCollection = await pb.collections.create({\n name: \"stripe_customers\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"created\",\n options,\n );\n\n const stripePaymentMethodsCollection = await pb.collections.create({\n name: \"stripe_payment_methods\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"exp_month\", required: true, type: \"number\" },\n { name: \"exp_year\", required: true, type: \"number\" },\n {\n collectionId: stripeCustomersCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"customer\",\n required: true,\n type: \"relation\",\n cascadeDelete: true,\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_payment_methods\",\n \"created\",\n options,\n );\n\n await pb.collections.update(\"stripe_customers\", {\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n collectionId: stripePaymentMethodsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"default_payment_method\",\n required: false,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"updated\",\n options,\n );\n\n await pb.collections.create({\n name: \"transactions\",\n type: \"base\",\n fields: [\n {\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"stripe_payment_intent\", required: true, type: \"text\" },\n { name: \"amount\", required: true, type: \"number\" },\n { name: \"currency\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"created\", required: true, type: \"date\" },\n { name: \"stripe_charge\", required: true, type: \"text\" },\n { name: \"stripe_customer\", required: true, type: \"text\" },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n { name: \"receipt_url\", required: true, type: \"url\" },\n ],\n });\n await pushMigrationCreates(creates, \"transactions\", \"created\", options);\n }\n });\n\n const { product, price } = await createTestProductAndPrice(stripeSecretKey);\n\n await withPocketbase(options.root, async (pb) => {\n await pb.collection(\"stripe_products\").create({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price: product.default_price,\n });\n\n await pb.collection(\"stripe_prices\").create({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: price.product,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n });\n });\n\n creates.push({\n path: \"src/routes/(public)/payment/+page.svelte\",\n language: \"svelte\",\n content: paymentPageSnippet(price.id),\n status: \"success\",\n });\n\n if (isAppMode) {\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, modifyUserSignup(userSignupPath)),\n );\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAKA,IAAM,IAAsB;CAC1B;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAe;CACnB;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAiB;CACrB;CACA;CACA;CACD,CAAC,KAAK,KAAK;AAEZ,SAAgB,EACd,GACA,GACA,GACA,GACA,GACkD;CAClD,IAAM,IAAO,IAAI,EAAW,EAAe,EACvC,IAAW,IAET,KAAU,MAAgD;AAC1D,OACJ,GAAK,MAAW;GACd,IAAM,IAAS,EACb,GACA,GACA,GACA,GACA,EACD;AAED,UADI,EAAO,aAAU,IAAW,KACzB,EAAO;IACd;;AAMJ,QAHA,GAAQ,MAAO,EAAK,mBAAmB,EAAG,CAAC,EACtC,KAAU,GAAQ,MAAO,EAAK,aAAa,EAAG,CAAC,EAE7C;EAAE,mBAAmB,EAAK,UAAU;EAAE;EAAU;;AAGzD,SAAgB,EAAc,GAAoC;AAChE,KAAI,CAA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,EAPA,MAAM,EAAG,WAAW,kBAAkB,CAAC,OAAO;GAC5C,IAAI,EAAQ;GACZ,MAAM,EAAQ;GACd,QAAQ,EAAQ;GAChB,eAAe,EAAQ;GACxB,CAAC,EAEF,MAAM,EAAG,WAAW,gBAAgB,CAAC,OAAO;GAC1C,IAAI,EAAM;GACV,gBAAgB,EAAM;GACtB,UAAU,EAAM;GAChB,SAAS,EAAM;GACf,WAAW,EAAM;GACjB,MAAM,EAAM;GACZ,aAAa,EAAM;GACnB,QAAQ,EAAM;GACf,CAAC;GACF,EAEF,EAAQ,KAAK;EACX,MAAM;EACN,UAAU;EACV,SAAS,EAAmB,EAAM,GAAG;EACrC,QAAQ;EACT,CAAC,EAEE,GAAW;EACb,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,kBACD;AACD,IAAW,EAAoB,GAAa,EAAc,EAAY,CAAC,CAAC;EAExE,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,YACA,UACA,kBACD;AACD,IACE,EAAoB,GAAgB,EAAiB,EAAe,CAAC,CACtE;;AAGH,QAAO;EACL;EACA;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACtB"}
@@ -1,7 +1,7 @@
1
- import { t as e } from "./dedent-BFNYR8cb.js";
2
- import { n as t, r as n, t as r } from "./pocketbase-CmKcAXDf.js";
3
- import { modifyOutcomeToFile as i } from "./modify-file-CpqC7kMR.js";
4
- import { i as a, n as o, r as s } from "./ts-morph-helpers-BMxk6lHK.js";
1
+ import { t as e } from "./dedent-C4qKBQXh.js";
2
+ import { getMigrationFile as t, migrationDelay as n, withPocketbase as r } from "./pocketbase-W_FJaYZ3.js";
3
+ import { modifyOutcomeToFile as i } from "./modify-file-D3OuKUEp.js";
4
+ import { i as a, n as o, r as s } from "./ts-morph-helpers-digNcfBD.js";
5
5
  import c from "node:fs";
6
6
  import l from "node:path";
7
7
  import { Project as u, SyntaxKind as d } from "ts-morph";
@@ -236,15 +236,15 @@ function b(e) {
236
236
  //#region src/patterns/enable/auth/generate.runtime.ts
237
237
  async function x(e) {
238
238
  let { input: a } = e, o = [];
239
- await n(e.root, async (n) => {
240
- await n.settings.update({ meta: {
239
+ await r(e.root, async (r) => {
240
+ await r.settings.update({ meta: {
241
241
  senderName: a.senderName,
242
242
  senderAddress: a.senderAddress
243
- } }), await t();
244
- let i = await n.collections.getOne("users");
243
+ } }), await n();
244
+ let i = await r.collections.getOne("users");
245
245
  if (!i) throw Error("Users collection not found");
246
246
  let s = i.verificationTemplate.body.replace("{APP_URL}/_/#/auth/confirm-verification/{TOKEN}", "{APP_URL}/confirm-verification/{TOKEN}"), l = i.resetPasswordTemplate.body.replace("{APP_URL}/_/#/auth/confirm-reset/{TOKEN}", "{APP_URL}/confirm-reset/{TOKEN}"), u = i.confirmEmailChangeTemplate.body.replace("{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}", "{APP_URL}/confirm-email-change/{TOKEN}");
247
- await n.collections.update("users", {
247
+ await r.collections.update("users", {
248
248
  listRule: "@request.auth.id = id",
249
249
  viewRule: "@request.auth.id = id",
250
250
  createRule: "@request.auth.id = id",
@@ -253,8 +253,8 @@ async function x(e) {
253
253
  verificationTemplate: { body: s },
254
254
  resetPasswordTemplate: { body: l },
255
255
  confirmEmailChangeTemplate: { body: u }
256
- }), await t();
257
- let d = r("users", "updated", e);
256
+ }), await n();
257
+ let d = t("users", "updated", e);
258
258
  d && o.push({
259
259
  path: d,
260
260
  language: "ts",
@@ -280,10 +280,11 @@ async function x(e) {
280
280
  deletes: [],
281
281
  components: [],
282
282
  packages: [],
283
- collections: []
283
+ collections: [],
284
+ collectionPatches: []
284
285
  };
285
286
  }
286
287
  //#endregion
287
288
  export { x as generate };
288
289
 
289
- //# sourceMappingURL=generate.runtime-6QnXtCSG.js.map
290
+ //# sourceMappingURL=generate.runtime-BKrtBCRk.js.map