@velastack/patterns 0.0.18 → 0.0.20

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 (37) hide show
  1. package/README.md +12 -0
  2. package/dist/chunks/collections-C7dgGs-E.js +67 -0
  3. package/dist/chunks/collections-C7dgGs-E.js.map +1 -0
  4. package/dist/chunks/{env.runtime-DtXAdiod.js → env.runtime-DwDRkEXV.js} +2 -2
  5. package/dist/chunks/{env.runtime-DtXAdiod.js.map → env.runtime-DwDRkEXV.js.map} +1 -1
  6. package/dist/chunks/generate.runtime-C7g-zL0o.js.map +1 -1
  7. package/dist/chunks/generate.runtime-D21wXYWT.js +172 -0
  8. package/dist/chunks/generate.runtime-D21wXYWT.js.map +1 -0
  9. package/dist/chunks/generate.runtime-DcDyK2xK.js +334 -0
  10. package/dist/chunks/generate.runtime-DcDyK2xK.js.map +1 -0
  11. package/dist/chunks/{generate.runtime-Bhlrr9q4.js → generate.runtime-cNqC7P0N.js} +33 -10
  12. package/dist/chunks/generate.runtime-cNqC7P0N.js.map +1 -0
  13. package/dist/chunks/generate.runtime-toUqgDQY.js +610 -0
  14. package/dist/chunks/generate.runtime-toUqgDQY.js.map +1 -0
  15. package/dist/chunks/{index-DAkiQcTu.js → index-GTS4D08Z.js} +2538 -2248
  16. package/dist/chunks/index-GTS4D08Z.js.map +1 -0
  17. package/dist/chunks/{pocketbase-lfpOUvM5.js → pocketbase-QZ34CciJ.js} +50 -45
  18. package/dist/chunks/pocketbase-QZ34CciJ.js.map +1 -0
  19. package/dist/chunks/ts-morph-helpers-BNCluWTs.js +166 -0
  20. package/dist/chunks/ts-morph-helpers-BNCluWTs.js.map +1 -0
  21. package/dist/chunks/{write-result-CbUTMeAc.js → write-result-DmD7kWlV.js} +81 -70
  22. package/dist/chunks/write-result-DmD7kWlV.js.map +1 -0
  23. package/dist/index.d.ts +67 -0
  24. package/dist/index.js +1 -1
  25. package/package.json +19 -4
  26. package/dist/chunks/collections-CMh5lXoZ.js +0 -62
  27. package/dist/chunks/collections-CMh5lXoZ.js.map +0 -1
  28. package/dist/chunks/generate.runtime-B4YCHeuI.js +0 -227
  29. package/dist/chunks/generate.runtime-B4YCHeuI.js.map +0 -1
  30. package/dist/chunks/generate.runtime-Bhlrr9q4.js.map +0 -1
  31. package/dist/chunks/generate.runtime-C4q7Pq37.js +0 -633
  32. package/dist/chunks/generate.runtime-C4q7Pq37.js.map +0 -1
  33. package/dist/chunks/generate.runtime-MR_6kBLS.js +0 -353
  34. package/dist/chunks/generate.runtime-MR_6kBLS.js.map +0 -1
  35. package/dist/chunks/index-DAkiQcTu.js.map +0 -1
  36. package/dist/chunks/pocketbase-lfpOUvM5.js.map +0 -1
  37. package/dist/chunks/write-result-CbUTMeAc.js.map +0 -1
package/README.md CHANGED
@@ -79,3 +79,15 @@ the modifications work across a wide range of project setups.
79
79
  ### Preview-Modifies
80
80
 
81
81
  The `preview-modifies` directory is the mock modify output used only for previews. It's bundled in the same way as the `creates` directory.
82
+
83
+ ## Baselines
84
+
85
+ The `src/baselines/` directory contains template SvelteKit projects that patterns are applied on top of:
86
+
87
+ - `sv` — minimal SvelteKit starter
88
+ - `velastack` — full VelaStack with components, UI, and database setup
89
+ - `velastack-auth` — VelaStack with authentication pre-configured
90
+
91
+ 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.
92
+
93
+ Baselines are not bundled into the published package — they are used by the VelaStack CLI's `create` command and by the velastack.dev website.
@@ -0,0 +1,67 @@
1
+ import { readFileSync as s } from "node:fs";
2
+ import { l as u } from "./index-GTS4D08Z.js";
3
+ import { w as f, m as c, g as d } from "./pocketbase-QZ34CciJ.js";
4
+ function m(e) {
5
+ var a, n, i, o;
6
+ if (((i = (n = (a = e.response) == null ? void 0 : a.data) == null ? void 0 : n.name) == null ? void 0 : i.code) === "validation_not_unique")
7
+ return !0;
8
+ const t = ((o = e.message) == null ? void 0 : o.toLowerCase()) ?? "";
9
+ return t.includes("already exists") || t.includes("must be unique");
10
+ }
11
+ function g(e) {
12
+ const 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 v(e, t, a) {
16
+ const n = [];
17
+ for (const i of t) {
18
+ const o = i.collectionName.replace(/'/g, "''"), l = await e.collections.getFirstListItem(`name='${o}'`);
19
+ if (await e.collections.update(l.id, g(i)), await c(), a) {
20
+ const r = d(
21
+ i.collectionName,
22
+ "updated",
23
+ a
24
+ );
25
+ r && n.push({
26
+ path: r,
27
+ language: u(r),
28
+ content: s(r, "utf8")
29
+ });
30
+ }
31
+ }
32
+ return n;
33
+ }
34
+ async function p(e, t) {
35
+ if (e.length === 0)
36
+ return [];
37
+ const a = [];
38
+ return await f(t.root, async (n) => {
39
+ for (const i of e) {
40
+ try {
41
+ await n.collections.create(i);
42
+ } catch (l) {
43
+ throw m(
44
+ l
45
+ ) ? new Error(
46
+ `Collection "${i.name}" already exists. Choose a different model name or remove the existing collection first.`
47
+ ) : l;
48
+ }
49
+ await c();
50
+ const o = d(
51
+ i.name,
52
+ "created",
53
+ t
54
+ );
55
+ o && a.push({
56
+ path: o,
57
+ language: u(o),
58
+ content: s(o, "utf8")
59
+ });
60
+ }
61
+ }), a;
62
+ }
63
+ export {
64
+ v as applyCollectionRulePatches,
65
+ p as createCollections
66
+ };
67
+ //# sourceMappingURL=collections-C7dgGs-E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections-C7dgGs-E.js","sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type {\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\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 });\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\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 });\n }\n });\n\n return migrations;\n}\n"],"names":["isCollectionAlreadyExistsError","error","_c","_b","_a","message","_d","rulePayloadFromPatch","patch","payload","applyCollectionRulePatches","pb","patches","options","migrations","escaped","col","migrationDelay","migrationFile","getMigrationFile","languageFromPath","readFileSync","createCollections","collections","withPocketbase","collection"],"mappings":";;;AAqBA,SAASA,EACPC,GACS;;AACT,QAAIC,KAAAC,KAAAC,IAAAH,EAAM,aAAN,gBAAAG,EAAgB,SAAhB,gBAAAD,EAAsB,SAAtB,gBAAAD,EAA4B,UAAS;AACvC,WAAO;AAGT,QAAMG,MAAUC,IAAAL,EAAM,YAAN,gBAAAK,EAAe,kBAAiB;AAChD,SACED,EAAQ,SAAS,gBAAgB,KAAKA,EAAQ,SAAS,gBAAgB;AAE3E;AAEA,SAASE,EACPC,GACyB;AACzB,QAAMC,IAAmC,CAAA;AACzC,SAAID,EAAM,aAAa,WAAWC,EAAQ,WAAWD,EAAM,WACvDA,EAAM,aAAa,WAAWC,EAAQ,WAAWD,EAAM,WACvDA,EAAM,eAAe,WAAWC,EAAQ,aAAaD,EAAM,aAC3DA,EAAM,eAAe,WAAWC,EAAQ,aAAaD,EAAM,aAC3DA,EAAM,eAAe,WAAWC,EAAQ,aAAaD,EAAM,aACxDC;AACT;AAMA,eAAsBC,EACpBC,GAMAC,GACAC,GACiB;AACjB,QAAMC,IAAqB,CAAA;AAE3B,aAAWN,KAASI,GAAS;AAC3B,UAAMG,IAAUP,EAAM,eAAe,QAAQ,MAAM,IAAI,GACjDQ,IAAM,MAAML,EAAG,YAAY,iBAAiB,SAASI,CAAO,GAAG;AAIrE,QAHA,MAAMJ,EAAG,YAAY,OAAOK,EAAI,IAAIT,EAAqBC,CAAK,CAAC,GAC/D,MAAMS,EAAA,GAEFJ,GAAS;AACX,YAAMK,IAAgBC;AAAA,QACpBX,EAAM;AAAA,QACN;AAAA,QACAK;AAAA,MAAA;AAEF,MAAIK,KACFJ,EAAW,KAAK;AAAA,QACd,MAAMI;AAAA,QACN,UAAUE,EAAiBF,CAAa;AAAA,QACxC,SAASG,EAAaH,GAAe,MAAM;AAAA,MAAA,CAC5C;AAAA,IAEL;AAAA,EACF;AAEA,SAAOJ;AACT;AAEA,eAAsBQ,EACpBC,GACAV,GACiB;AACjB,MAAIU,EAAY,WAAW;AACzB,WAAO,CAAA;AAGT,QAAMT,IAAqB,CAAA;AAE3B,eAAMU,EAAeX,EAAQ,MAAM,OAAOF,MAAO;AAC/C,eAAWc,KAAcF,GAAa;AACpC,UAAI;AACF,cAAMZ,EAAG,YAAY,OAAOc,CAAU;AAAA,MACxC,SAASxB,GAAO;AACd,cACED;AAAA,UACEC;AAAA,QAAA,IAGI,IAAI;AAAA,UACR,eAAewB,EAAW,IAAI;AAAA,QAAA,IAG5BxB;AAAA,MACR;AACA,YAAMgB,EAAA;AAEN,YAAMC,IAAgBC;AAAA,QACpBM,EAAW;AAAA,QACX;AAAA,QACAZ;AAAA,MAAA;AAEF,MAAKK,KAILJ,EAAW,KAAK;AAAA,QACd,MAAMI;AAAA,QACN,UAAUE,EAAiBF,CAAa;AAAA,QACxC,SAASG,EAAaH,GAAe,MAAM;AAAA,MAAA,CAC5C;AAAA,IACH;AAAA,EACF,CAAC,GAEMJ;AACT;"}
@@ -2,7 +2,7 @@ import { getCollections as i } from "@velastack/pocketbase/internal";
2
2
  import s from "node:fs";
3
3
  import r from "node:path";
4
4
  import t from "node:process";
5
- import { D as c } from "./index-DAkiQcTu.js";
5
+ import { D as c } from "./index-GTS4D08Z.js";
6
6
  function a(o) {
7
7
  return s.existsSync(r.join(o, "package.json")) && s.existsSync(r.join(o, c));
8
8
  }
@@ -33,4 +33,4 @@ export {
33
33
  S as getCollections,
34
34
  p as resolveProjectRoot
35
35
  };
36
- //# sourceMappingURL=env.runtime-DtXAdiod.js.map
36
+ //# sourceMappingURL=env.runtime-DwDRkEXV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env.runtime-DtXAdiod.js","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"],"names":["hasProjectMarkers","dir","fs","path","DATA_DIR","resolveProjectRoot","startDir","process","current","parent","getCollections","root","getCollectionsFromPB"],"mappings":";;;;;AAOA,SAASA,EAAkBC,GAAsB;AAC/C,SACEC,EAAG,WAAWC,EAAK,KAAKF,GAAK,cAAc,CAAC,KAC5CC,EAAG,WAAWC,EAAK,KAAKF,GAAKG,CAAQ,CAAC;AAE1C;AAEO,SAASC,EAAmBC,IAAWC,EAAQ,OAAe;AACnE,MAAIC,IAAUL,EAAK,QAAQG,CAAQ;AAEnC,aAAa;AACX,QAAIN,EAAkBQ,CAAO;AAC3B,aAAOA;AAGT,UAAMC,IAASN,EAAK,QAAQK,CAAO;AACnC,QAAIC,MAAWD;AACb;AAEF,IAAAA,IAAUC;AAAA,EACZ;AAEA,QAAM,IAAI;AAAA,IACR,wCAAwCH,CAAQ,iCAAiCF,CAAQ;AAAA,EAAA;AAE7F;AAEA,eAAsBM,IAAwC;AAC5D,QAAMC,IAAON,EAAA;AAEb,SAAOO,EAAqB;AAAA,IAC1B,eAAe;AAAA,IACf,gBAAgBL,EAAQ,IAAI;AAAA,IAC5B,mBAAmBA,EAAQ,IAAI;AAAA,IAC/B,MAAAI;AAAA,EAAA,CACD;AACH;"}
1
+ {"version":3,"file":"env.runtime-DwDRkEXV.js","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"],"names":["hasProjectMarkers","dir","fs","path","DATA_DIR","resolveProjectRoot","startDir","process","current","parent","getCollections","root","getCollectionsFromPB"],"mappings":";;;;;AAOA,SAASA,EAAkBC,GAAsB;AAC/C,SACEC,EAAG,WAAWC,EAAK,KAAKF,GAAK,cAAc,CAAC,KAC5CC,EAAG,WAAWC,EAAK,KAAKF,GAAKG,CAAQ,CAAC;AAE1C;AAEO,SAASC,EAAmBC,IAAWC,EAAQ,OAAe;AACnE,MAAIC,IAAUL,EAAK,QAAQG,CAAQ;AAEnC,aAAa;AACX,QAAIN,EAAkBQ,CAAO;AAC3B,aAAOA;AAGT,UAAMC,IAASN,EAAK,QAAQK,CAAO;AACnC,QAAIC,MAAWD;AACb;AAEF,IAAAA,IAAUC;AAAA,EACZ;AAEA,QAAM,IAAI;AAAA,IACR,wCAAwCH,CAAQ,iCAAiCF,CAAQ;AAAA,EAAA;AAE7F;AAEA,eAAsBM,IAAwC;AAC5D,QAAMC,IAAON,EAAA;AAEb,SAAOO,EAAqB;AAAA,IAC1B,eAAe;AAAA,IACf,gBAAgBL,EAAQ,IAAI;AAAA,IAC5B,mBAAmBA,EAAQ,IAAI;AAAA,IAC/B,MAAAI;AAAA,EAAA,CACD;AACH;"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-C7g-zL0o.js","sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (apiProp as import(\"ts-morph\").PropertyAssignment).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const modifies: File[] = [];\n\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n if (fs.existsSync(hooksServerPath)) {\n modifyHooksServer(hooksServerPath);\n modifies.push({\n path: hooksServerPath,\n language: \"ts\",\n content: fs.readFileSync(hooksServerPath, \"utf8\"),\n });\n }\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"names":["modifyHooksServer","hooksServerPath","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","apiInit","apiObj","generate","options","mod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MAAM,OAAO,iBAAiB;AACxE,SAAIG,EAAG,WAAWhB,CAAe,MAC/BD,EAAkBC,CAAe,GACjCc,EAAS,KAAK;AAAA,IACZ,MAAMd;AAAA,IACN,UAAU;AAAA,IACV,SAASgB,EAAG,aAAahB,GAAiB,MAAM;AAAA,EAAA,CACjD,IAGI;AAAA,IACL,SAAS,CAAA;AAAA,IACT,UAAAc;AAAA,IACA,SAAS,CAAA;AAAA,IACT,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,IACV,aAAa,CAAA;AAAA,EAAC;AAElB;"}
1
+ {"version":3,"file":"generate.runtime-C7g-zL0o.js","sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const modifies: File[] = [];\n\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n if (fs.existsSync(hooksServerPath)) {\n modifyHooksServer(hooksServerPath);\n modifies.push({\n path: hooksServerPath,\n language: \"ts\",\n content: fs.readFileSync(hooksServerPath, \"utf8\"),\n });\n }\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"names":["modifyHooksServer","hooksServerPath","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","apiInit","apiObj","generate","options","modifies","path","fs"],"mappings":";;;AAEO,SAASA,EAAkBC,GAAyB;AAEzD,QAAMC,IADU,IAAIC,EAAA,EACO,oBAAoBF,CAAe,GAExDG,IAAWF,EACd,qBAAqBG,EAAW,cAAc,EAC9C,KAAK,CAACC,MAAOA,EAAG,cAAA,EAAgB,QAAA,MAAc,kBAAkB;AAEnE,MAAI,CAACF,GAAU;AACb,IAAAF,EAAW,SAAA;AACX;AAAA,EACF;AAEA,QAAMK,IAAOH,EAAS,aAAA;AACtB,MAAIG,EAAK,WAAW,GAAG;AACrB,IAAAH,EAAS,YAAY,4BAA4B,GACjDF,EAAW,WAAA,GACXA,EAAW,SAAA;AACX;AAAA,EACF;AAEA,QAAMM,IAAWD,EAAK,CAAC;AACvB,MAAIC,EAAS,cAAcH,EAAW,yBAAyB;AAC7D,IAAAD,EAAS,eAAe,GAAG,4BAA4B,GACvDF,EAAW,WAAA,GACXA,EAAW,SAAA;AACX;AAAA,EACF;AAEA,QAAMO,IAAaD,EAAS,cAAcH,EAAW,uBAAuB,GACtEK,IAAUD,EAAW,YAAY,KAAK;AAE5C,MAAI,CAACC,GAAS;AACZ,IAAAD,EAAW,sBAAsB;AAAA,MAC/B,MAAM;AAAA,MACN,aAAa;AAAA,IAAA,CACd,GACDP,EAAW,WAAA,GACXA,EAAW,SAAA;AACX;AAAA,EACF;AAEA,MAAIQ,EAAQ,cAAcL,EAAW,oBAAoB;AACvD,UAAMM,IACJD,EACA,eAAA;AACF,QAAIC,KAAWA,EAAQ,QAAA,MAAcN,EAAW,yBAAyB;AACvE,YAAMO,IAASD;AAEf,MADoBC,EAAO,YAAY,SAAS,KAE9CA,EAAO,sBAAsB,EAAE,MAAM,WAAW,aAAa,QAAQ;AAAA,IAEzE;AAAA,EACF;AAEA,EAAAV,EAAW,WAAA,GACXA,EAAW,SAAA;AACb;ACtDA,eAAsBW,EAASC,GAAkB;AAC/C,QAAMC,IAAmB,CAAA,GAEnBd,IAAkBe,EAAK,KAAKF,EAAQ,MAAM,OAAO,iBAAiB;AACxE,SAAIG,EAAG,WAAWhB,CAAe,MAC/BD,EAAkBC,CAAe,GACjCc,EAAS,KAAK;AAAA,IACZ,MAAMd;AAAA,IACN,UAAU;AAAA,IACV,SAASgB,EAAG,aAAahB,GAAiB,MAAM;AAAA,EAAA,CACjD,IAGI;AAAA,IACL,SAAS,CAAA;AAAA,IACT,UAAAc;AAAA,IACA,SAAS,CAAA;AAAA,IACT,YAAY,CAAA;AAAA,IACZ,UAAU,CAAA;AAAA,IACV,aAAa,CAAA;AAAA,EAAC;AAElB;"}
@@ -0,0 +1,172 @@
1
+ import l from "node:fs";
2
+ import g from "node:path";
3
+ import { w as b, m as S, g as h } from "./pocketbase-QZ34CciJ.js";
4
+ import { Project as v, SyntaxKind as c } from "ts-morph";
5
+ import { S as x, a as P } from "./ts-morph-helpers-BNCluWTs.js";
6
+ function w(n) {
7
+ const e = new v().addSourceFileAtPath(n), t = e.getDescendantsOfKind(c.CallExpression).find((i) => i.getExpression().getText() === "handlePocketbase");
8
+ if (!t) {
9
+ e.saveSync();
10
+ return;
11
+ }
12
+ const o = t.getArguments();
13
+ if (o.length === 0) {
14
+ t.addArgument(
15
+ "{ api: { enabled: true, apiKeys: { enabled: true } } }"
16
+ ), e.formatText(), e.saveSync();
17
+ return;
18
+ }
19
+ const a = o[0];
20
+ if (a.getKind() !== c.ObjectLiteralExpression) {
21
+ t.insertArgument(
22
+ 0,
23
+ "{ api: { enabled: true, apiKeys: { enabled: true } } }"
24
+ ), e.formatText(), e.saveSync();
25
+ return;
26
+ }
27
+ const s = a.asKindOrThrow(c.ObjectLiteralExpression), r = s.getProperty("api");
28
+ if (!r) {
29
+ s.addPropertyAssignment({
30
+ name: "api",
31
+ initializer: "{ enabled: true, apiKeys: { enabled: true } }"
32
+ }), e.formatText(), e.saveSync();
33
+ return;
34
+ }
35
+ if (r.getKind() === c.PropertyAssignment) {
36
+ const i = r.getInitializer();
37
+ if (i && i.getKind() === c.ObjectLiteralExpression) {
38
+ const u = i;
39
+ u.getProperty("enabled") || u.addPropertyAssignment({ name: "enabled", initializer: "true" });
40
+ const p = u.getProperty("apiKeys");
41
+ if (!p)
42
+ u.addPropertyAssignment({
43
+ name: "apiKeys",
44
+ initializer: "{ enabled: true }"
45
+ });
46
+ else if (p.getKind() === c.PropertyAssignment) {
47
+ const f = p.getInitializer();
48
+ if (f && f.getKind() === c.ObjectLiteralExpression) {
49
+ const m = f;
50
+ m.getProperty("enabled") || m.addPropertyAssignment({
51
+ name: "enabled",
52
+ initializer: "true"
53
+ });
54
+ } else
55
+ p.setInitializer(
56
+ "{ enabled: true }"
57
+ );
58
+ }
59
+ }
60
+ }
61
+ e.formatText(), e.saveSync();
62
+ }
63
+ function A(n, d, e, t, o) {
64
+ const a = new x(n);
65
+ let s = !1;
66
+ const r = (i) => {
67
+ s || i((u) => {
68
+ const y = P(
69
+ u,
70
+ d,
71
+ e,
72
+ t,
73
+ o
74
+ );
75
+ return y.wasAdded && (s = !0), y.source;
76
+ });
77
+ };
78
+ return r((i) => a.modifyModuleScript(i)), s || r((i) => a.modifyScript(i)), { newNavUserSnippet: a.toString(), wasAdded: s };
79
+ }
80
+ function K(n) {
81
+ if (!l.existsSync(n)) return !1;
82
+ const d = l.readFileSync(n, "utf8"), { newNavUserSnippet: e, wasAdded: t } = A(
83
+ d,
84
+ "API Keys",
85
+ "/api-keys",
86
+ "KeyRoundIcon",
87
+ "@lucide/svelte/icons/key-round"
88
+ );
89
+ return t && l.writeFileSync(n, e, "utf8"), t;
90
+ }
91
+ async function T(n) {
92
+ const d = [];
93
+ await b(n.root, async (a) => {
94
+ const s = await a.collections.getOne("users");
95
+ await a.collections.create({
96
+ listRule: "@request.auth.id = user.id",
97
+ viewRule: "@request.auth.id = user.id",
98
+ createRule: "@request.auth.id = user.id",
99
+ updateRule: "@request.auth.id = user.id",
100
+ deleteRule: "@request.auth.id = user.id",
101
+ name: "api_keys",
102
+ type: "base",
103
+ fields: [
104
+ {
105
+ collectionId: s.id,
106
+ maxSelect: 1,
107
+ name: "user",
108
+ type: "relation"
109
+ },
110
+ {
111
+ name: "key_hash",
112
+ type: "text"
113
+ },
114
+ {
115
+ name: "label",
116
+ type: "text"
117
+ },
118
+ {
119
+ name: "last_used",
120
+ type: "date"
121
+ },
122
+ {
123
+ name: "created",
124
+ onCreate: !0,
125
+ onUpdate: !1,
126
+ type: "autodate"
127
+ },
128
+ {
129
+ name: "updated",
130
+ onCreate: !0,
131
+ onUpdate: !0,
132
+ type: "autodate"
133
+ }
134
+ ]
135
+ }), await S();
136
+ const r = h("api_keys", "created", n);
137
+ r && d.push({
138
+ path: r,
139
+ language: "ts",
140
+ content: l.readFileSync(r, "utf8")
141
+ });
142
+ });
143
+ const e = [], t = g.join(n.root, "src", "hooks.server.ts");
144
+ l.existsSync(t) && (w(t), e.push({
145
+ path: t,
146
+ language: "ts",
147
+ content: l.readFileSync(t, "utf8")
148
+ }));
149
+ const o = g.join(
150
+ n.root,
151
+ "src",
152
+ "lib",
153
+ "components",
154
+ "nav-user.svelte"
155
+ );
156
+ return K(o) && e.push({
157
+ path: o,
158
+ language: "svelte",
159
+ content: l.readFileSync(o, "utf8")
160
+ }), {
161
+ creates: d,
162
+ modifies: e,
163
+ deletes: [],
164
+ components: [],
165
+ packages: [],
166
+ collections: []
167
+ };
168
+ }
169
+ export {
170
+ T as generate
171
+ };
172
+ //# sourceMappingURL=generate.runtime-D21wXYWT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-D21wXYWT.js","sources":["../../src/patterns/enable/api-keys/modifies/hooks.server.ts","../../src/patterns/enable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/enable/api-keys/generate.runtime.ts"],"sourcesContent":["import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(\n 0,\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true, apiKeys: { enabled: true } }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n apiObj.addPropertyAssignment({\n name: \"apiKeys\",\n initializer: `{ enabled: true }`,\n });\n } else if (apiKeysProp.getKind() === SyntaxKind.PropertyAssignment) {\n const keysInit = (\n apiKeysProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (\n keysInit &&\n keysInit.getKind() === SyntaxKind.ObjectLiteralExpression\n ) {\n const keysObj =\n keysInit as import(\"ts-morph\").ObjectLiteralExpression;\n const keysEnabled = keysObj.getProperty(\"enabled\");\n if (!keysEnabled) {\n keysObj.addPropertyAssignment({\n name: \"enabled\",\n initializer: \"true\",\n });\n }\n } else {\n (apiKeysProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `{ enabled: true }`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\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): boolean {\n if (!fs.existsSync(navUserPath)) return false;\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"API Keys\",\n \"/api-keys\",\n \"KeyRoundIcon\",\n \"@lucide/svelte/icons/key-round\",\n );\n\n if (wasAdded) {\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n }\n\n return wasAdded;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifyNavUser } from \"./modifies/nav-user.svelte\";\n\nexport async function generate(options: Options) {\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n\n await pb.collections.create({\n listRule: \"@request.auth.id = user.id\",\n viewRule: \"@request.auth.id = user.id\",\n createRule: \"@request.auth.id = user.id\",\n updateRule: \"@request.auth.id = user.id\",\n deleteRule: \"@request.auth.id = user.id\",\n name: \"api_keys\",\n type: \"base\",\n fields: [\n {\n collectionId: userCollection.id,\n maxSelect: 1,\n name: \"user\",\n type: \"relation\",\n },\n {\n name: \"key_hash\",\n type: \"text\",\n },\n {\n name: \"label\",\n type: \"text\",\n },\n {\n name: \"last_used\",\n type: \"date\",\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 migrationDelay();\n\n const migrationFile = getMigrationFile(\"api_keys\", \"created\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n const modifies: File[] = [];\n\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n if (fs.existsSync(hooksServerPath)) {\n modifyHooksServer(hooksServerPath);\n modifies.push({\n path: hooksServerPath,\n language: \"ts\",\n content: fs.readFileSync(hooksServerPath, \"utf8\"),\n });\n }\n\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n if (modifyNavUser(navUserPath)) {\n modifies.push({\n path: navUserPath,\n language: \"svelte\",\n content: fs.readFileSync(navUserPath, \"utf8\"),\n });\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"names":["modifyHooksServer","hooksServerPath","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","apiInit","apiObj","apiKeysProp","keysInit","keysObj","addItemToNavUser","navUserSnippet","title","url","icon","iconImportPath","file","SvelteFile","wasAdded","tryAdd","run","source","result","addNavItemToScript","fn","modifyNavUser","navUserPath","fs","newNavUserSnippet","generate","options","creates","withPocketbase","pb","userCollection","migrationDelay","migrationFile","getMigrationFile","modifies","path"],"mappings":";;;;;AAEO,SAASA,EAAkBC,GAAyB;AAEzD,QAAMC,IADU,IAAIC,EAAA,EACO,oBAAoBF,CAAe,GAExDG,IAAWF,EACd,qBAAqBG,EAAW,cAAc,EAC9C,KAAK,CAACC,MAAOA,EAAG,cAAA,EAAgB,QAAA,MAAc,kBAAkB;AAEnE,MAAI,CAACF,GAAU;AACb,IAAAF,EAAW,SAAA;AACX;AAAA,EACF;AAEA,QAAMK,IAAOH,EAAS,aAAA;AACtB,MAAIG,EAAK,WAAW,GAAG;AACrB,IAAAH,EAAS;AAAA,MACP;AAAA,IAAA,GAEFF,EAAW,WAAA,GACXA,EAAW,SAAA;AACX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