@velastack/patterns 0.3.1 → 0.3.2

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 (144) hide show
  1. package/README.md +32 -2
  2. package/dist/chunks/_layout-B7ujvjnA.js +55 -0
  3. package/dist/chunks/_layout-B7ujvjnA.js.map +1 -0
  4. package/dist/chunks/{collections-CgdvZXmh.js → collections-UPqYto13.js} +2 -2
  5. package/dist/chunks/{collections-CgdvZXmh.js.map → collections-UPqYto13.js.map} +1 -1
  6. package/dist/chunks/{compose-handle-Cg9jnCsS.js → compose-handle-B-CkDcQD.js} +23 -23
  7. package/dist/chunks/{compose-handle-Cg9jnCsS.js.map → compose-handle-B-CkDcQD.js.map} +1 -1
  8. package/dist/chunks/config-target-Bln26FJe.js +164 -0
  9. package/dist/chunks/config-target-Bln26FJe.js.map +1 -0
  10. package/dist/chunks/errors-DR3gF_7a.js +18 -0
  11. package/dist/chunks/errors-DR3gF_7a.js.map +1 -0
  12. package/dist/chunks/{generate-DRA63W0r.js → generate-6snrlnpA.js} +2 -2
  13. package/dist/chunks/{generate-DRA63W0r.js.map → generate-6snrlnpA.js.map} +1 -1
  14. package/dist/chunks/{generate-BkQ1xMDp.js → generate-C6xi5S5L.js} +4 -4
  15. package/dist/chunks/{generate-BkQ1xMDp.js.map → generate-C6xi5S5L.js.map} +1 -1
  16. package/dist/chunks/{generate-tOkjJFUf.js → generate-CyuY2Ci7.js} +4 -3
  17. package/dist/chunks/generate-CyuY2Ci7.js.map +1 -0
  18. package/dist/chunks/{generate-iQP31-m1.js → generate-DHgKgHb7.js} +4 -4
  19. package/dist/chunks/{generate-iQP31-m1.js.map → generate-DHgKgHb7.js.map} +1 -1
  20. package/dist/chunks/{generate-_LvrYK6i.js → generate-jsB_oO0b.js} +4 -4
  21. package/dist/chunks/{generate-_LvrYK6i.js.map → generate-jsB_oO0b.js.map} +1 -1
  22. package/dist/chunks/{generate.runtime-DAmYsIvF.js → generate.runtime-9R2AUKLS.js} +5 -5
  23. package/dist/chunks/{generate.runtime-DAmYsIvF.js.map → generate.runtime-9R2AUKLS.js.map} +1 -1
  24. package/dist/chunks/generate.runtime-B3yX6kl2.js +87 -0
  25. package/dist/chunks/generate.runtime-B3yX6kl2.js.map +1 -0
  26. package/dist/chunks/{generate.runtime-BKo-Nidn.js → generate.runtime-B7wkyj-8.js} +6 -6
  27. package/dist/chunks/{generate.runtime-BKo-Nidn.js.map → generate.runtime-B7wkyj-8.js.map} +1 -1
  28. package/dist/chunks/generate.runtime-BHf8p_3K.js +94 -0
  29. package/dist/chunks/generate.runtime-BHf8p_3K.js.map +1 -0
  30. package/dist/chunks/{generate.runtime-BbIN0tUZ.js → generate.runtime-BSFIwX58.js} +67 -66
  31. package/dist/chunks/generate.runtime-BSFIwX58.js.map +1 -0
  32. package/dist/chunks/{generate.runtime-BnWE4qsu.js → generate.runtime-Bb9CCwQm.js} +55 -54
  33. package/dist/chunks/generate.runtime-Bb9CCwQm.js.map +1 -0
  34. package/dist/chunks/{generate.runtime-D8vgh5MH.js → generate.runtime-BjciAjq7.js} +156 -76
  35. package/dist/chunks/generate.runtime-BjciAjq7.js.map +1 -0
  36. package/dist/chunks/{generate.runtime-BwhGDnGu.js → generate.runtime-BpTpRBdH.js} +151 -150
  37. package/dist/chunks/generate.runtime-BpTpRBdH.js.map +1 -0
  38. package/dist/chunks/{generate.runtime-D0icLb5j.js → generate.runtime-Brf08fMW.js} +11 -10
  39. package/dist/chunks/{generate.runtime-D0icLb5j.js.map → generate.runtime-Brf08fMW.js.map} +1 -1
  40. package/dist/chunks/{generate.runtime-S5RIgbQx.js → generate.runtime-C6DfW_NO.js} +98 -92
  41. package/dist/chunks/generate.runtime-C6DfW_NO.js.map +1 -0
  42. package/dist/chunks/{generate.runtime-DhkaXTq3.js → generate.runtime-C9fSqy6a.js} +61 -59
  43. package/dist/chunks/generate.runtime-C9fSqy6a.js.map +1 -0
  44. package/dist/chunks/{generate.runtime-CRYjWJRe.js → generate.runtime-CawvLUoV.js} +89 -88
  45. package/dist/chunks/generate.runtime-CawvLUoV.js.map +1 -0
  46. package/dist/chunks/{generate.runtime-DNaQxed-.js → generate.runtime-CzS7PuPN.js} +84 -83
  47. package/dist/chunks/generate.runtime-CzS7PuPN.js.map +1 -0
  48. package/dist/chunks/{generate.runtime-B0hhtyAL.js → generate.runtime-D1NZPV6C.js} +27 -26
  49. package/dist/chunks/generate.runtime-D1NZPV6C.js.map +1 -0
  50. package/dist/chunks/generate.runtime-D3baqo6a.js +111 -0
  51. package/dist/chunks/generate.runtime-D3baqo6a.js.map +1 -0
  52. package/dist/chunks/{generate.runtime-DSqkXvps.js → generate.runtime-D47djbeG.js} +15 -14
  53. package/dist/chunks/{generate.runtime-DSqkXvps.js.map → generate.runtime-D47djbeG.js.map} +1 -1
  54. package/dist/chunks/generate.runtime-D72UBiwD.js +313 -0
  55. package/dist/chunks/generate.runtime-D72UBiwD.js.map +1 -0
  56. package/dist/chunks/{generate.runtime-CcuAXuV2.js → generate.runtime-DDPoXmqN.js} +15 -14
  57. package/dist/chunks/{generate.runtime-CcuAXuV2.js.map → generate.runtime-DDPoXmqN.js.map} +1 -1
  58. package/dist/chunks/{generate.runtime-acRmiU7e.js → generate.runtime-DEnn0HKw.js} +9 -8
  59. package/dist/chunks/{generate.runtime-acRmiU7e.js.map → generate.runtime-DEnn0HKw.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-wA1G3tQ4.js → generate.runtime-DHXkw2gf.js} +38 -37
  61. package/dist/chunks/generate.runtime-DHXkw2gf.js.map +1 -0
  62. package/dist/chunks/{generate.runtime-DOuufRLr.js → generate.runtime-DIuCrH6l.js} +82 -81
  63. package/dist/chunks/generate.runtime-DIuCrH6l.js.map +1 -0
  64. package/dist/chunks/generate.runtime-DOB4U-Sa.js +57 -0
  65. package/dist/chunks/generate.runtime-DOB4U-Sa.js.map +1 -0
  66. package/dist/chunks/generate.runtime-DPAy7Cav.js +328 -0
  67. package/dist/chunks/generate.runtime-DPAy7Cav.js.map +1 -0
  68. package/dist/chunks/{generate.runtime-BORbegw_.js → generate.runtime-D_ZqiYt-.js} +123 -122
  69. package/dist/chunks/generate.runtime-D_ZqiYt-.js.map +1 -0
  70. package/dist/chunks/{generate.runtime-B49wetSx.js → generate.runtime-Dm7g_WTN.js} +43 -42
  71. package/dist/chunks/generate.runtime-Dm7g_WTN.js.map +1 -0
  72. package/dist/chunks/{generate.runtime-DoZdSh9W.js → generate.runtime-HE9rzfXz.js} +58 -57
  73. package/dist/chunks/generate.runtime-HE9rzfXz.js.map +1 -0
  74. package/dist/chunks/{generate.runtime-flFRYzpi.js → generate.runtime-ejrt1o6M.js} +62 -61
  75. package/dist/chunks/generate.runtime-ejrt1o6M.js.map +1 -0
  76. package/dist/chunks/generate.runtime-l6I-St2R.js +94 -0
  77. package/dist/chunks/generate.runtime-l6I-St2R.js.map +1 -0
  78. package/dist/chunks/modify-file-DGe7MJu_.js +46 -0
  79. package/dist/chunks/modify-file-DGe7MJu_.js.map +1 -0
  80. package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js → modify-svelte-config-remote-BUU_EaDf.js} +2 -2
  81. package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js.map → modify-svelte-config-remote-BUU_EaDf.js.map} +1 -1
  82. package/dist/chunks/{providers-DO9kMyzB.js → providers-BL9vJP_9.js} +2 -2
  83. package/dist/chunks/{providers-DO9kMyzB.js.map → providers-BL9vJP_9.js.map} +1 -1
  84. package/dist/chunks/{shared-BwHQM-a9.js → shared-DkGfltvn.js} +2 -2
  85. package/dist/chunks/{shared-BwHQM-a9.js.map → shared-DkGfltvn.js.map} +1 -1
  86. package/dist/chunks/{test-setup-B2hd8I-s.js → test-setup-DHEFKEHE.js} +23 -10
  87. package/dist/chunks/test-setup-DHEFKEHE.js.map +1 -0
  88. package/dist/chunks/ts-morph-helpers-CeduA--o.js +253 -0
  89. package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +1 -0
  90. package/dist/chunks/{ui-B4Tuit-7.js → ui-B3-B3sE2.js} +3 -3
  91. package/dist/chunks/{ui-B4Tuit-7.js.map → ui-B3-B3sE2.js.map} +1 -1
  92. package/dist/chunks/{ui-jhXrsw4T.js → ui-DD4NltyN.js} +2 -2
  93. package/dist/chunks/{ui-jhXrsw4T.js.map → ui-DD4NltyN.js.map} +1 -1
  94. package/dist/chunks/unmodify-load-jfdcVZ_a.js +81 -0
  95. package/dist/chunks/unmodify-load-jfdcVZ_a.js.map +1 -0
  96. package/dist/chunks/write-result-DRwceOV3.js +452 -0
  97. package/dist/chunks/write-result-DRwceOV3.js.map +1 -0
  98. package/dist/index.d.ts +34 -0
  99. package/dist/index.js +1918 -1901
  100. package/dist/index.js.map +1 -1
  101. package/package.json +1 -1
  102. package/dist/chunks/_layout-DqH4lA_r.js +0 -47
  103. package/dist/chunks/_layout-DqH4lA_r.js.map +0 -1
  104. package/dist/chunks/config-target-Co-ij8p3.js +0 -163
  105. package/dist/chunks/config-target-Co-ij8p3.js.map +0 -1
  106. package/dist/chunks/errors-D6gyegUK.js +0 -14
  107. package/dist/chunks/errors-D6gyegUK.js.map +0 -1
  108. package/dist/chunks/generate-tOkjJFUf.js.map +0 -1
  109. package/dist/chunks/generate.runtime-B0hhtyAL.js.map +0 -1
  110. package/dist/chunks/generate.runtime-B49wetSx.js.map +0 -1
  111. package/dist/chunks/generate.runtime-B7LRx-BU.js +0 -86
  112. package/dist/chunks/generate.runtime-B7LRx-BU.js.map +0 -1
  113. package/dist/chunks/generate.runtime-BORbegw_.js.map +0 -1
  114. package/dist/chunks/generate.runtime-BbIN0tUZ.js.map +0 -1
  115. package/dist/chunks/generate.runtime-BnWE4qsu.js.map +0 -1
  116. package/dist/chunks/generate.runtime-BwhGDnGu.js.map +0 -1
  117. package/dist/chunks/generate.runtime-CCg2Pjcv.js +0 -257
  118. package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +0 -1
  119. package/dist/chunks/generate.runtime-CRYjWJRe.js.map +0 -1
  120. package/dist/chunks/generate.runtime-D2e_KRj0.js +0 -56
  121. package/dist/chunks/generate.runtime-D2e_KRj0.js.map +0 -1
  122. package/dist/chunks/generate.runtime-D44gjxRA.js +0 -332
  123. package/dist/chunks/generate.runtime-D44gjxRA.js.map +0 -1
  124. package/dist/chunks/generate.runtime-D8vgh5MH.js.map +0 -1
  125. package/dist/chunks/generate.runtime-DNaQxed-.js.map +0 -1
  126. package/dist/chunks/generate.runtime-DOuufRLr.js.map +0 -1
  127. package/dist/chunks/generate.runtime-DhkaXTq3.js.map +0 -1
  128. package/dist/chunks/generate.runtime-DoZdSh9W.js.map +0 -1
  129. package/dist/chunks/generate.runtime-S5RIgbQx.js.map +0 -1
  130. package/dist/chunks/generate.runtime-WmSMWL15.js +0 -82
  131. package/dist/chunks/generate.runtime-WmSMWL15.js.map +0 -1
  132. package/dist/chunks/generate.runtime-flFRYzpi.js.map +0 -1
  133. package/dist/chunks/generate.runtime-gtpOuLNO.js +0 -110
  134. package/dist/chunks/generate.runtime-gtpOuLNO.js.map +0 -1
  135. package/dist/chunks/generate.runtime-kLxeDGnS.js +0 -93
  136. package/dist/chunks/generate.runtime-kLxeDGnS.js.map +0 -1
  137. package/dist/chunks/generate.runtime-wA1G3tQ4.js.map +0 -1
  138. package/dist/chunks/modify-file-GQD6uNgI.js +0 -254
  139. package/dist/chunks/modify-file-GQD6uNgI.js.map +0 -1
  140. package/dist/chunks/test-setup-B2hd8I-s.js.map +0 -1
  141. package/dist/chunks/unmodify-load-W1ePZQHr.js +0 -80
  142. package/dist/chunks/unmodify-load-W1ePZQHr.js.map +0 -1
  143. package/dist/chunks/write-result-DewHCNhM.js +0 -451
  144. package/dist/chunks/write-result-DewHCNhM.js.map +0 -1
@@ -0,0 +1,87 @@
1
+ import { t as e } from "./dedent-Gq6Krl4n.js";
2
+ import { n as t } from "./logger-CQONztPm.js";
3
+ import { o as n } from "./ts-morph-helpers-CeduA--o.js";
4
+ import { modifyOutcomeToFile as r } from "./modify-file-DGe7MJu_.js";
5
+ import i from "node:fs";
6
+ import a from "node:path";
7
+ import { Project as o, SyntaxKind as s } from "ts-morph";
8
+ //#region src/patterns/enable/api/modifies/hooks.server.ts
9
+ var c = e`
10
+ Configure handlePocketbase() with the api option in hooks.server.ts:
11
+
12
+ handlePocketbase({
13
+ api: { enabled: true },
14
+ });
15
+ `, l = e`
16
+ Create src/hooks.server.ts with handlePocketbase:
17
+
18
+ import { handlePocketbase } from 'velastack/handle';
19
+
20
+ export const handle = handlePocketbase({
21
+ api: { enabled: true },
22
+ });
23
+ `;
24
+ function u(e) {
25
+ if (!i.existsSync(e)) return {
26
+ status: "not-found",
27
+ message: l
28
+ };
29
+ let t = i.readFileSync(e, "utf8"), r = new o().addSourceFileAtPath(e), a = r.getDescendantsOfKind(s.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
30
+ if (!a) return {
31
+ status: "failed",
32
+ message: c
33
+ };
34
+ let u = a.getArguments();
35
+ if (u.length === 0) return a.addArgument("{ api: { enabled: true } }"), n(r), r.saveSync(), {
36
+ status: "success",
37
+ changed: !0
38
+ };
39
+ let d = u[0];
40
+ if (d.getKind() !== s.ObjectLiteralExpression) return a.insertArgument(0, "{ api: { enabled: true } }"), n(r), r.saveSync(), {
41
+ status: "success",
42
+ changed: !0
43
+ };
44
+ let f = d.asKindOrThrow(s.ObjectLiteralExpression), p = f.getProperty("api");
45
+ if (!p) return f.addPropertyAssignment({
46
+ name: "api",
47
+ initializer: "{ enabled: true }"
48
+ }), n(r), r.saveSync(), {
49
+ status: "success",
50
+ changed: !0
51
+ };
52
+ if (p.getKind() === s.PropertyAssignment) {
53
+ let e = p.getInitializer();
54
+ if (e && e.getKind() === s.ObjectLiteralExpression) {
55
+ let t = e;
56
+ t.getProperty("enabled") || t.addPropertyAssignment({
57
+ name: "enabled",
58
+ initializer: "true"
59
+ });
60
+ }
61
+ }
62
+ return n(r), r.saveSync(), {
63
+ status: "success",
64
+ changed: r.getFullText() !== t
65
+ };
66
+ }
67
+ //#endregion
68
+ //#region src/patterns/enable/api/generate.runtime.ts
69
+ async function d(e) {
70
+ let n = t(e), i = [];
71
+ n.info("Modifying hooks.server.ts");
72
+ let o = a.join(e.root, "src", "hooks.server.ts"), s = r(o, u(o));
73
+ return s && i.push(s), {
74
+ creates: [],
75
+ modifies: i,
76
+ deletes: [],
77
+ components: [],
78
+ packages: [],
79
+ collections: [],
80
+ collectionPatches: [],
81
+ collectionDrops: []
82
+ };
83
+ }
84
+ //#endregion
85
+ export { d as generate };
86
+
87
+ //# sourceMappingURL=generate.runtime-B3yX6kl2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-B3yX6kl2.js","names":[],"sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with the api option in hooks.server.ts:\n\n handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\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 return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\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 formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\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 formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],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B,EAAO,YAAY,SAClC,KACH,EAAO,sBAAsB;IAAE,MAAM;IAAW,aAAa;GAAO,CAAC;EAEzE;CACF;CAIA,OAFA,EAAiB,CAAU,GAC3B,EAAW,SAAS,GACb;EACL,QAAQ;EACR,SAAS,EAAW,YAAY,MAAM;CACxC;AACF;;;ACnFA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,iBAAiB,GAClE,IAAO,EACX,GACA,EAAkB,CAAe,CACnC;CAGA,OAFI,KAAM,EAAS,KAAK,CAAI,GAErB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,10 +1,10 @@
1
- import { t as e } from "./errors-D6gyegUK.js";
2
- import { a as t, o as n } from "./providers-DO9kMyzB.js";
3
- import { n as r, s as i } from "./generate-iQP31-m1.js";
1
+ import { t as e } from "./errors-DR3gF_7a.js";
2
+ import { a as t, o as n } from "./providers-BL9vJP_9.js";
3
+ import { n as r, s as i } from "./generate-DHgKgHb7.js";
4
4
  import { n as a } from "./logger-CQONztPm.js";
5
5
  import { t as o } from "./env-BPfk1VAw.js";
6
- import { modifyOutcomeToFile as s } from "./modify-file-GQD6uNgI.js";
7
- import { o as c } from "./config-target-Co-ij8p3.js";
6
+ import { modifyOutcomeToFile as s } from "./modify-file-DGe7MJu_.js";
7
+ import { o as c } from "./config-target-Bln26FJe.js";
8
8
  import l from "node:path";
9
9
  //#region src/patterns/enable/ai/generate.runtime.ts
10
10
  var u = "@sveltejs/adapter-static", d = [
@@ -35,4 +35,4 @@ async function p(c) {
35
35
  //#endregion
36
36
  export { p as generate };
37
37
 
38
- //# sourceMappingURL=generate.runtime-BKo-Nidn.js.map
38
+ //# sourceMappingURL=generate.runtime-B7wkyj-8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-BKo-Nidn.js","names":[],"sources":["../../src/patterns/enable/ai/generate.runtime.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { getLogger } from \"../../../core/logger\";\nimport { resolveProvider, suppliedProviderEnv } from \"../../../core/providers\";\nimport { resolveConfigTarget } from \"../../../runtime/config-target\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { envEditsFor, META } from \"./generate\";\n\nconst ADAPTER_STATIC = \"@sveltejs/adapter-static\";\n\nexport const STATIC_ADAPTER_MESSAGE = [\n `AI needs a server, and this project builds with ${ADAPTER_STATIC}.`,\n \"The chat endpoint streams each reply from the server with a private API key, which a static site cannot do.\",\n \"Switch to a server adapter first: `vela enable backend` moves the project to @sveltejs/adapter-node.\",\n].join(\"\\n\");\n\n/**\n * Whether the SvelteKit config the project builds with imports\n * adapter-static. A config that cannot be resolved does not count: the\n * pattern only refuses what it can see.\n */\nexport function usesStaticAdapter(root: string): boolean {\n const res = resolveConfigTarget(root);\n if (res.status !== \"resolved\") return false;\n return res.target.sourceFile\n .getImportDeclarations()\n .some((decl) => decl.getModuleSpecifierValue() === ADAPTER_STATIC);\n}\n\nexport async function generate(options: Options) {\n if (usesStaticAdapter(options.root)) {\n throw new InvalidArgumentError(STATIC_ADAPTER_MESSAGE);\n }\n\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const modifies: File[] = [];\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n const envFile = modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n );\n if (envFile) modifies.push(envFile);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAUA,IAAM,IAAiB,4BAEV,IAAyB;CACpC,mDAAmD,EAAe;CAClE;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAOX,SAAgB,EAAkB,GAAuB;CACvD,IAAM,IAAM,EAAoB,CAAI;CAEpC,OADI,EAAI,WAAW,cACZ,EAAI,OAAO,WACf,sBAAsB,CAAC,CACvB,MAAM,MAAS,EAAK,wBAAwB,MAAM,CAAc;AACrE;AAEA,eAAsB,EAAS,GAAkB;CAC/C,IAAI,EAAkB,EAAQ,IAAI,GAChC,MAAM,IAAI,EAAqB,CAAsB;CAGvD,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAW,EAAgB,GAAM,CAAO,GACxC,IAAmB,CAAC;CAE1B,EAAO,KAAK,eAAe;CAC3B,IAAM,IAAU,EAAK,KAAK,EAAQ,MAAM,MAAM,GACxC,IAAU,EACd,GACA,EAAU,GAAS,EAAY,GAAU,EAAoB,CAAO,CAAC,CAAC,CACxE;CAGA,OAFI,KAAS,EAAS,KAAK,CAAO,GAE3B;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate.runtime-B7wkyj-8.js","names":[],"sources":["../../src/patterns/enable/ai/generate.runtime.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { getLogger } from \"../../../core/logger\";\nimport { resolveProvider, suppliedProviderEnv } from \"../../../core/providers\";\nimport { resolveConfigTarget } from \"../../../runtime/config-target\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { envEditsFor, META } from \"./generate\";\n\nconst ADAPTER_STATIC = \"@sveltejs/adapter-static\";\n\nexport const STATIC_ADAPTER_MESSAGE = [\n `AI needs a server, and this project builds with ${ADAPTER_STATIC}.`,\n \"The chat endpoint streams each reply from the server with a private API key, which a static site cannot do.\",\n \"Switch to a server adapter first: `vela enable backend` moves the project to @sveltejs/adapter-node.\",\n].join(\"\\n\");\n\n/**\n * Whether the SvelteKit config the project builds with imports\n * adapter-static. A config that cannot be resolved does not count: the\n * pattern only refuses what it can see.\n */\nexport function usesStaticAdapter(root: string): boolean {\n const res = resolveConfigTarget(root);\n if (res.status !== \"resolved\") return false;\n return res.target.sourceFile\n .getImportDeclarations()\n .some((decl) => decl.getModuleSpecifierValue() === ADAPTER_STATIC);\n}\n\nexport async function generate(options: Options) {\n if (usesStaticAdapter(options.root)) {\n throw new InvalidArgumentError(STATIC_ADAPTER_MESSAGE);\n }\n\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const modifies: File[] = [];\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n const envFile = modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n );\n if (envFile) modifies.push(envFile);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAUA,IAAM,IAAiB,4BAEV,IAAyB;CACpC,mDAAmD,EAAe;CAClE;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAOX,SAAgB,EAAkB,GAAuB;CACvD,IAAM,IAAM,EAAoB,CAAI;CAEpC,OADI,EAAI,WAAW,cACZ,EAAI,OAAO,WACf,sBAAsB,CAAC,CACvB,MAAM,MAAS,EAAK,wBAAwB,MAAM,CAAc;AACrE;AAEA,eAAsB,EAAS,GAAkB;CAC/C,IAAI,EAAkB,EAAQ,IAAI,GAChC,MAAM,IAAI,EAAqB,CAAsB;CAGvD,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAW,EAAgB,GAAM,CAAO,GACxC,IAAmB,CAAC;CAE1B,EAAO,KAAK,eAAe;CAC3B,IAAM,IAAU,EAAK,KAAK,EAAQ,MAAM,MAAM,GACxC,IAAU,EACd,GACA,EAAU,GAAS,EAAY,GAAU,EAAoB,CAAO,CAAC,CAAC,CACxE;CAGA,OAFI,KAAS,EAAS,KAAK,CAAO,GAE3B;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -0,0 +1,94 @@
1
+ import { n as e } from "./logger-CQONztPm.js";
2
+ import { t } from "./shared-DkGfltvn.js";
3
+ import { f as n, o as r } from "./ts-morph-helpers-CeduA--o.js";
4
+ import { modifyOutcomeToFile as i } from "./modify-file-DGe7MJu_.js";
5
+ import { t as a } from "./svelte-file-B3RfgVdt.js";
6
+ import o from "node:fs";
7
+ import s from "node:path";
8
+ import { Project as c, SyntaxKind as l } from "ts-morph";
9
+ //#region src/patterns/disable/api-keys/modifies/hooks.server.ts
10
+ function u(e) {
11
+ if (!o.existsSync(e)) return {
12
+ status: "success",
13
+ changed: !1
14
+ };
15
+ let t = o.readFileSync(e, "utf8"), n = new c().addSourceFileAtPath(e), i = n.getDescendantsOfKind(l.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
16
+ if (!i) return {
17
+ status: "success",
18
+ changed: !1
19
+ };
20
+ let [a] = i.getArguments();
21
+ if (!a || a.getKind() !== l.ObjectLiteralExpression) return {
22
+ status: "success",
23
+ changed: !1
24
+ };
25
+ let s = a.asKindOrThrow(l.ObjectLiteralExpression).getProperty("api");
26
+ if (!s || s.getKind() !== l.PropertyAssignment) return {
27
+ status: "success",
28
+ changed: !1
29
+ };
30
+ let u = s.getInitializer();
31
+ if (!u || u.getKind() !== l.ObjectLiteralExpression) return {
32
+ status: "success",
33
+ changed: !1
34
+ };
35
+ let d = u.getProperty("apiKeys");
36
+ return d ? (d.remove(), r(n), n.saveSync(), {
37
+ status: "success",
38
+ changed: n.getFullText() !== t
39
+ }) : {
40
+ status: "success",
41
+ changed: !1
42
+ };
43
+ }
44
+ //#endregion
45
+ //#region src/patterns/disable/api-keys/modifies/nav-user.svelte.ts
46
+ function d(e) {
47
+ if (!o.existsSync(e)) return {
48
+ status: "success",
49
+ changed: !1
50
+ };
51
+ let t = o.readFileSync(e, "utf8");
52
+ if (!t.includes("/api-keys")) return {
53
+ status: "success",
54
+ changed: !1
55
+ };
56
+ let r = new a(t), i = !1, s = (e) => {
57
+ i || e((e) => {
58
+ let t = n(e, "API Keys", "@lucide/svelte/icons/key-round");
59
+ return t.wasRemoved && (i = !0), t.source;
60
+ });
61
+ };
62
+ return s((e) => r.modifyModuleScript(e)), i || s((e) => r.modifyScript(e)), i ? (o.writeFileSync(e, r.toString(), "utf8"), {
63
+ status: "success",
64
+ changed: !0
65
+ }) : {
66
+ status: "success",
67
+ changed: !1
68
+ };
69
+ }
70
+ //#endregion
71
+ //#region src/patterns/disable/api-keys/generate.runtime.ts
72
+ async function f(n) {
73
+ let r = e(n), a = [], o = (e) => {
74
+ e && a.push(e);
75
+ };
76
+ r.info("Reverting hooks.server.ts");
77
+ let c = s.join(n.root, "src", "hooks.server.ts");
78
+ o(i(c, u(c))), r.info("Reverting nav-user.svelte");
79
+ let l = s.join(n.root, "src", "lib", "components", "nav-user.svelte");
80
+ return o(i(l, d(l))), {
81
+ creates: [],
82
+ modifies: a,
83
+ deletes: [],
84
+ components: [],
85
+ packages: [],
86
+ collections: [],
87
+ collectionPatches: [],
88
+ collectionDrops: await t(["api_keys"], n)
89
+ };
90
+ }
91
+ //#endregion
92
+ export { f as generate };
93
+
94
+ //# sourceMappingURL=generate.runtime-BHf8p_3K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-BHf8p_3K.js","names":[],"sources":["../../src/patterns/disable/api-keys/modifies/hooks.server.ts","../../src/patterns/disable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/disable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\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 if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp || apiProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { status: \"success\", changed: false };\n }\n\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!apiInit || apiInit.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n return { status: \"success\", changed: false };\n }\n\n apiKeysProp.remove();\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"API Keys\",\n \"@lucide/svelte/icons/key-round\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { unmodifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, unmodifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n const collectionDrops = await planDropsForCollections([\"api_keys\"], options);\n\n return {\n creates: [],\n modifies,\n deletes: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{ n, r, t as i } from "./nav-user-BYI-h8Od.js";
4
- import { t as a } from "./shared-BwHQM-a9.js";
5
- import { c as o, h as s, modifyOutcomeToFile as c } from "./modify-file-GQD6uNgI.js";
6
- import { t as l } from "./svelte-file-B3RfgVdt.js";
7
- import u from "node:fs";
8
- import d from "node:path";
9
- import { SyntaxKind as f } from "ts-morph";
4
+ import { t as a } from "./shared-DkGfltvn.js";
5
+ import { _ as o, o as s, u as c } from "./ts-morph-helpers-CeduA--o.js";
6
+ import { modifyOutcomeToFile as l } from "./modify-file-DGe7MJu_.js";
7
+ import { t as u } from "./svelte-file-B3RfgVdt.js";
8
+ import d from "node:fs";
9
+ import f from "node:path";
10
+ import { SyntaxKind as p } from "ts-morph";
10
11
  //#region src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts
11
- var p = /* @__PURE__ */ new Set([
12
+ var m = /* @__PURE__ */ new Set([
12
13
  "customer.subscription.created",
13
14
  "customer.subscription.updated",
14
15
  "customer.subscription.deleted"
15
16
  ]);
16
- function m(e) {
17
- if (!u.existsSync(e)) return {
17
+ function h(e) {
18
+ if (!d.existsSync(e)) return {
18
19
  status: "success",
19
20
  changed: !1
20
21
  };
21
- let t = u.readFileSync(e, "utf8");
22
+ let t = d.readFileSync(e, "utf8");
22
23
  if (!t.includes("handleSubscriptionCreated")) return {
23
24
  status: "success",
24
25
  changed: !1
25
26
  };
26
- let { source: n } = s(t, (e) => {
27
- o(e, "./subscription/created"), o(e, "./subscription/updated"), o(e, "./subscription/deleted");
28
- let t = e.getDescendantsOfKind(f.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
27
+ let { source: n } = o(t, (e) => {
28
+ c(e, "./subscription/created"), c(e, "./subscription/updated"), c(e, "./subscription/deleted");
29
+ let t = e.getDescendantsOfKind(p.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
29
30
  if (!t) return;
30
31
  let n = t.getCaseBlock().getClauses().filter((e) => {
31
- if (e.getKind() !== f.CaseClause) return !1;
32
- let t = e.asKindOrThrow(f.CaseClause).getExpression(), n = t.asKind(f.StringLiteral) ?? t.asKind(f.NoSubstitutionTemplateLiteral);
33
- return n ? p.has(n.getLiteralValue()) : !1;
34
- }).map((e) => e.asKindOrThrow(f.CaseClause));
32
+ if (e.getKind() !== p.CaseClause) return !1;
33
+ let t = e.asKindOrThrow(p.CaseClause).getExpression(), n = t.asKind(p.StringLiteral) ?? t.asKind(p.NoSubstitutionTemplateLiteral);
34
+ return n ? m.has(n.getLiteralValue()) : !1;
35
+ }).map((e) => e.asKindOrThrow(p.CaseClause));
35
36
  for (let e of n.reverse()) e.remove();
36
- e.formatText();
37
+ s(e);
37
38
  }), r = n.replace(/(break;)\n(\s*default:)/, "$1\n\n$2");
38
39
  return r === t ? {
39
40
  status: "success",
40
41
  changed: !1
41
- } : (u.writeFileSync(e, r, "utf8"), {
42
+ } : (d.writeFileSync(e, r, "utf8"), {
42
43
  status: "success",
43
44
  changed: !0
44
45
  });
45
46
  }
46
47
  //#endregion
47
48
  //#region src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts
48
- function h(e) {
49
- if (!u.existsSync(e)) return {
49
+ function g(e) {
50
+ if (!d.existsSync(e)) return {
50
51
  status: "success",
51
52
  changed: !1
52
53
  };
53
- let t = l.fromPath(e);
54
+ let t = u.fromPath(e);
54
55
  return !t.hasElement("AppSidebar") || !t.hasAttribute("AppSidebar", "subscription") || !t.removeAttribute("AppSidebar", "subscription") ? {
55
56
  status: "success",
56
57
  changed: !1
@@ -61,19 +62,19 @@ function h(e) {
61
62
  }
62
63
  //#endregion
63
64
  //#region src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts
64
- function g(e) {
65
- let { source: t } = s(e, (e) => {
65
+ function _(e) {
66
+ let { source: t } = o(e, (e) => {
66
67
  for (let t of e.getVariableDeclarations()) {
67
68
  let e = t.getInitializer();
68
69
  if (!e || e.getText() !== "$props()") continue;
69
70
  let n = t.getNameNode();
70
- if (n.getKind() !== f.ObjectBindingPattern) continue;
71
- let r = n.asKindOrThrow(f.ObjectBindingPattern), i = r.getElements(), a = i.some((e) => e.getName() === "subscription"), o = t.getTypeNode();
72
- if (o?.getKind() === f.IntersectionType) {
73
- let e = o.asKindOrThrow(f.IntersectionType);
71
+ if (n.getKind() !== p.ObjectBindingPattern) continue;
72
+ let r = n.asKindOrThrow(p.ObjectBindingPattern), i = r.getElements(), a = i.some((e) => e.getName() === "subscription"), o = t.getTypeNode();
73
+ if (o?.getKind() === p.IntersectionType) {
74
+ let e = o.asKindOrThrow(p.IntersectionType);
74
75
  for (let t of e.getTypeNodes()) {
75
- if (t.getKind() !== f.TypeLiteral) continue;
76
- let e = t.asKindOrThrow(f.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, "")).filter((e) => !/^\s*subscription\??\s*:/.test(e));
76
+ if (t.getKind() !== p.TypeLiteral) continue;
77
+ let e = t.asKindOrThrow(p.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, "")).filter((e) => !/^\s*subscription\??\s*:/.test(e));
77
78
  e.replaceWithText(n.length ? `{ ${n.join("; ")}; }` : "{}");
78
79
  break;
79
80
  }
@@ -83,32 +84,32 @@ function g(e) {
83
84
  r.replaceWithText(`{ ${e.join(", ")} }`);
84
85
  }
85
86
  }
86
- e.formatText();
87
+ s(e);
87
88
  });
88
89
  return t;
89
90
  }
90
- function _(e) {
91
- if (!u.existsSync(e)) return {
91
+ function v(e) {
92
+ if (!d.existsSync(e)) return {
92
93
  status: "success",
93
94
  changed: !1
94
95
  };
95
- let t = u.readFileSync(e, "utf8"), n = /subscription\??\s*:\s*\{/.test(t), r = /\bsubscription\s*=\s*null\b/.test(t), i = new l(t), a = i.hasElement("NavUser") && i.hasAttribute("NavUser", "subscription");
96
+ let t = d.readFileSync(e, "utf8"), n = /subscription\??\s*:\s*\{/.test(t), r = /\bsubscription\s*=\s*null\b/.test(t), i = new u(t), a = i.hasElement("NavUser") && i.hasAttribute("NavUser", "subscription");
96
97
  return !n && !r && !a ? {
97
98
  status: "success",
98
99
  changed: !1
99
- } : ((n || r) && i.modifyScript(g), a && i.removeAttribute("NavUser", "subscription"), i.writeTo(e), {
100
+ } : ((n || r) && i.modifyScript(_), a && i.removeAttribute("NavUser", "subscription"), i.writeTo(e), {
100
101
  status: "success",
101
102
  changed: i.hasChanged()
102
103
  });
103
104
  }
104
105
  //#endregion
105
106
  //#region src/patterns/disable/subscriptions/modifies/revert-by-template.ts
106
- function v(e, t, n) {
107
- if (!u.existsSync(e)) return {
107
+ function y(e, t, n) {
108
+ if (!d.existsSync(e)) return {
108
109
  status: "success",
109
110
  changed: !1
110
111
  };
111
- let r = u.readFileSync(e, "utf8");
112
+ let r = d.readFileSync(e, "utf8");
112
113
  if (!r.includes(n)) return {
113
114
  status: "success",
114
115
  changed: !1
@@ -117,14 +118,14 @@ function v(e, t, n) {
117
118
  return r === i ? {
118
119
  status: "success",
119
120
  changed: !1
120
- } : (u.writeFileSync(e, i, "utf8"), {
121
+ } : (d.writeFileSync(e, i, "utf8"), {
121
122
  status: "success",
122
123
  changed: !0
123
124
  });
124
125
  }
125
126
  //#endregion
126
127
  //#region src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts
127
- var y = e`
128
+ var b = e`
128
129
  export const load = ({ locals }) => {
129
130
  \tconst user = locals.pb.authStore.record!;
130
131
  \tconst breadcrumbs = [{ title: 'Home', url: '/dashboard' }];
@@ -132,45 +133,45 @@ var y = e`
132
133
  \treturn { user, breadcrumbs };
133
134
  };
134
135
  ` + "\n";
135
- function b(e) {
136
- return v(e, y, "loadActiveSubscription");
136
+ function x(e) {
137
+ return y(e, b, "loadActiveSubscription");
137
138
  }
138
139
  //#endregion
139
140
  //#region src/patterns/disable/subscriptions/modifies/modify-nav-user.ts
140
- function x(e, t) {
141
- return v(e, t, "planLabel");
141
+ function S(e, t) {
142
+ return y(e, t, "planLabel");
142
143
  }
143
144
  //#endregion
144
145
  //#region src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts
145
- function S(e, t) {
146
- return v(e, t, "selectPlan");
146
+ function C(e, t) {
147
+ return y(e, t, "selectPlan");
147
148
  }
148
149
  //#endregion
149
150
  //#region src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts
150
- function C(e, t) {
151
- return v(e, t, "availablePlans");
151
+ function w(e, t) {
152
+ return y(e, t, "availablePlans");
152
153
  }
153
154
  //#endregion
154
155
  //#region src/patterns/disable/subscriptions/generate.runtime.ts
155
- async function w(e) {
156
- let o = t(e), s = [], l = (e) => {
156
+ async function T(e) {
157
+ let o = t(e), s = [], c = (e) => {
157
158
  e && s.push(e);
158
159
  };
159
160
  o.info("Reverting webhooks/stripe/handlers/dispatch.ts");
160
- let u = d.join(e.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
161
- l(c(u, m(u))), o.info("Reverting (app)/+layout.server.ts");
162
- let f = d.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
163
- l(c(f, b(f))), o.info("Reverting (app)/+layout.svelte");
164
- let p = d.join(e.root, "src", "routes", "(app)", "+layout.svelte");
165
- l(c(p, h(p))), o.info("Reverting app-sidebar.svelte");
166
- let g = d.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
167
- l(c(g, _(g))), o.info("Reverting nav-user.svelte");
168
- let v = d.join(e.root, "src", "lib", "components", "nav-user.svelte");
169
- l(c(v, x(v, i))), o.info("Reverting billing/+page.server.ts");
170
- let y = d.join(e.root, "src", "routes", "(app)", "billing", "+page.server.ts");
171
- l(c(y, S(y, r))), o.info("Reverting billing/+page.svelte");
172
- let w = d.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
173
- return l(c(w, C(w, n))), {
161
+ let u = f.join(e.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
162
+ c(l(u, h(u))), o.info("Reverting (app)/+layout.server.ts");
163
+ let d = f.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
164
+ c(l(d, x(d))), o.info("Reverting (app)/+layout.svelte");
165
+ let p = f.join(e.root, "src", "routes", "(app)", "+layout.svelte");
166
+ c(l(p, g(p))), o.info("Reverting app-sidebar.svelte");
167
+ let m = f.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
168
+ c(l(m, v(m))), o.info("Reverting nav-user.svelte");
169
+ let _ = f.join(e.root, "src", "lib", "components", "nav-user.svelte");
170
+ c(l(_, S(_, i))), o.info("Reverting billing/+page.server.ts");
171
+ let y = f.join(e.root, "src", "routes", "(app)", "billing", "+page.server.ts");
172
+ c(l(y, C(y, r))), o.info("Reverting billing/+page.svelte");
173
+ let b = f.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
174
+ return c(l(b, w(b, n))), {
174
175
  creates: [],
175
176
  modifies: s,
176
177
  deletes: [],
@@ -182,6 +183,6 @@ async function w(e) {
182
183
  };
183
184
  }
184
185
  //#endregion
185
- export { w as generate };
186
+ export { T as generate };
186
187
 
187
- //# sourceMappingURL=generate.runtime-BbIN0tUZ.js.map
188
+ //# sourceMappingURL=generate.runtime-BSFIwX58.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-BSFIwX58.js","names":[],"sources":["../../src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/disable/subscriptions/modifies/revert-by-template.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/disable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst SUBSCRIPTION_CASE_VALUES = new Set([\n \"customer.subscription.created\",\n \"customer.subscription.updated\",\n \"customer.subscription.deleted\",\n]);\n\nexport function unmodifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n const { source } = withInMemoryScript(original, (sf) => {\n removeImportByModuleSpecifier(sf, \"./subscription/created\");\n removeImportByModuleSpecifier(sf, \"./subscription/updated\");\n removeImportByModuleSpecifier(sf, \"./subscription/deleted\");\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n // Collect matching case clauses first — removing invalidates node refs.\n const toRemove = caseBlock\n .getClauses()\n .filter((clause) => {\n if (clause.getKind() !== SyntaxKind.CaseClause) return false;\n const caseClause = clause.asKindOrThrow(SyntaxKind.CaseClause);\n const expr = caseClause.getExpression();\n const literal =\n expr.asKind(SyntaxKind.StringLiteral) ??\n expr.asKind(SyntaxKind.NoSubstitutionTemplateLiteral);\n if (!literal) return false;\n return SUBSCRIPTION_CASE_VALUES.has(literal.getLiteralValue());\n })\n .map((c) => c.asKindOrThrow(SyntaxKind.CaseClause));\n\n for (const clause of toRemove.reverse()) {\n clause.remove();\n }\n\n formatLikeSource(sf);\n });\n\n // Removing the clauses takes the blank line before `default:` with them.\n const spaced = source.replace(/(break;)\\n(\\s*default:)/, \"$1\\n\\n$2\");\n\n if (spaced === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, spaced, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const removed = file.removeAttribute(\"AppSidebar\", \"subscription\");\n if (!removed) {\n return { status: \"success\", changed: false };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction updateScript(source: string): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n const hasSub = elements.some((e) => e.getName() === \"subscription\");\n\n // Strip subscription from the props type literal (the specific type\n // added by enable-subscriptions — leave unrelated `subscription` props\n // alone).\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"))\n .filter((t) => !/^\\s*subscription\\??\\s*:/.test(t));\n lit.replaceWithText(\n propTexts.length ? `{ ${propTexts.join(\"; \")}; }` : \"{}\",\n );\n break;\n }\n }\n\n if (hasSub) {\n const remaining = elements\n .filter((e) => e.getName() !== \"subscription\")\n .map((e) => e.getText());\n pattern.replaceWithText(`{ ${remaining.join(\", \")} }`);\n }\n }\n formatLikeSource(sf);\n });\n return out;\n}\n\nexport function unmodifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(filePath, \"utf8\");\n const hasSubPropType = /subscription\\??\\s*:\\s*\\{/.test(source);\n const hasSubProp = /\\bsubscription\\s*=\\s*null\\b/.test(source);\n\n const file = new SvelteFile(source);\n const hasNavUserSubAttr =\n file.hasElement(\"NavUser\") && file.hasAttribute(\"NavUser\", \"subscription\");\n\n if (!hasSubPropType && !hasSubProp && !hasNavUserSubAttr) {\n return { status: \"success\", changed: false };\n }\n\n if (hasSubPropType || hasSubProp) {\n file.modifyScript(updateScript);\n }\n if (hasNavUserSubAttr) {\n file.removeAttribute(\"NavUser\", \"subscription\");\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Rewrites a file to the given `template` if the current content still shows\n * the `enabledMarker` (meaning enable-subscriptions is applied). If the marker\n * is absent (already reverted or never applied), it's a no-op.\n *\n * Strips leading `// [!code highlight:N]` / `<!-- [!code highlight:N] -->`\n * lines so templates can be pulled from `preview-modifies/` directories which\n * use those for documentation highlighting.\n */\nexport function revertByTemplate(\n filePath: string,\n template: string,\n enabledMarker: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (!current.includes(enabledMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import dedent from \"dedent\";\nimport { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Baseline velastack-auth (app)/+layout.server.ts — the state of the file\n// before enable-subscriptions wrapped it with loadActiveSubscription.\nconst BASELINE =\n dedent`\n export const load = ({ locals }) => {\n \\tconst user = locals.pb.authStore.record!;\n \\tconst breadcrumbs = [{ title: 'Home', url: '/dashboard' }];\n\n \\treturn { user, breadcrumbs };\n };\n` + \"\\n\";\n\nexport function unmodifyAppLayoutServer(filePath: string): ModifyOutcome {\n return revertByTemplate(filePath, BASELINE, \"loadActiveSubscription\");\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(\n filePath: string,\n paymentsNavUserTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(filePath, paymentsNavUserTemplate, \"planLabel\");\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageServer(\n filePath: string,\n paymentsBillingPageServerTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageServerTemplate,\n \"selectPlan\",\n );\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageSvelte(\n filePath: string,\n paymentsBillingPageSvelteTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageSvelteTemplate,\n \"availablePlans\",\n );\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\nimport { unmodifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { unmodifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { unmodifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { unmodifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { unmodifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Pull the \"post-payments\" state of files that enable-subscriptions fully\n// overwrote. For the billing pages, that's exactly what enable-payments\n// writes in creates-app-mode; for nav-user it's the payments preview-modifies\n// snapshot (with highlight annotations stripped by the revert helper).\nimport paymentsNavUserTemplate from \"../../enable/payments/preview-modifies/src/lib/components/nav-user.svelte?raw\";\nimport paymentsBillingPageServerTemplate from \"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.server.ts?raw\";\nimport paymentsBillingPageSvelteTemplate from \"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.svelte?raw\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n unmodifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n unmodifyAppLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Reverting (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n unmodifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Reverting app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, unmodifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n unmodifyNavUser(navUserPath, paymentsNavUserTemplate),\n ),\n );\n\n logger.info(\"Reverting billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n unmodifyBillingPageServer(\n billingPageServerPath,\n paymentsBillingPageServerTemplate,\n ),\n ),\n );\n\n logger.info(\"Reverting billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n unmodifyBillingPageSvelte(\n billingPageSveltePath,\n paymentsBillingPageSvelteTemplate,\n ),\n ),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"stripe_subscriptions\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAM,oBAA2B,IAAI,IAAI;CACvC;CACA;CACA;AACF,CAAC;AAED,SAAgB,EAAsB,GAAiC;CACr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