@velastack/patterns 0.4.0 → 0.4.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 (196) hide show
  1. package/dist/chunks/{_layout-kkgN0IF7.js → _layout-D-FzWqn0.js} +2 -2
  2. package/dist/chunks/_layout-D-FzWqn0.js.map +1 -0
  3. package/dist/chunks/_page-C7kGoW7_.js +6 -0
  4. package/dist/chunks/_page-C7kGoW7_.js.map +1 -0
  5. package/dist/chunks/_page-e_I-fdSR.js +6 -0
  6. package/dist/chunks/_page-e_I-fdSR.js.map +1 -0
  7. package/dist/chunks/auth-pages-B52ei-4z.js +291 -0
  8. package/dist/chunks/auth-pages-B52ei-4z.js.map +1 -0
  9. package/dist/chunks/{collections-Dz2fvKnz.js → collections-zzZ_HQxB.js} +2 -2
  10. package/dist/chunks/collections-zzZ_HQxB.js.map +1 -0
  11. package/dist/chunks/{compose-handle-D_Rz3Fzo.js → compose-handle-BDlZ7Pif.js} +2 -2
  12. package/dist/chunks/compose-handle-BDlZ7Pif.js.map +1 -0
  13. package/dist/chunks/{config-target-Dx3w6WSk.js → config-target-rHgjaA8u.js} +2 -2
  14. package/dist/chunks/config-target-rHgjaA8u.js.map +1 -0
  15. package/dist/chunks/{constants-BjyMU5s8.js → constants-Rq8SCXwH.js} +2 -2
  16. package/dist/chunks/constants-Rq8SCXwH.js.map +1 -0
  17. package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
  18. package/dist/chunks/dispatch-D4TN9pdW.js +6 -0
  19. package/dist/chunks/dispatch-D4TN9pdW.js.map +1 -0
  20. package/dist/chunks/env-BPfk1VAw.js.map +1 -1
  21. package/dist/chunks/{env-vars-C1NUX-bf.js → env-vars-CcE6ODqC.js} +4 -4
  22. package/dist/chunks/env-vars-CcE6ODqC.js.map +1 -0
  23. package/dist/chunks/env-vars-Cr4lbMD_.js.map +1 -1
  24. package/dist/chunks/env-vars-De0Xs0L2.js.map +1 -1
  25. package/dist/chunks/env-vars-file-B_6esJW3.js.map +1 -1
  26. package/dist/chunks/env-vars-mnRA0hOe.js.map +1 -1
  27. package/dist/chunks/env.preview-uMRKT5Pc.js.map +1 -1
  28. package/dist/chunks/errors-DR3gF_7a.js.map +1 -1
  29. package/dist/chunks/{format-result-DZ8De8KY.js → format-result-BVoLVknk.js} +2 -2
  30. package/dist/chunks/format-result-BVoLVknk.js.map +1 -0
  31. package/dist/chunks/{generate-DeaBlnK6.js → generate-B6Odfk5f.js} +2 -2
  32. package/dist/chunks/generate-B6Odfk5f.js.map +1 -0
  33. package/dist/chunks/{generate-WMJo3QGZ.js → generate-Bg0E3eWm.js} +2 -2
  34. package/dist/chunks/generate-Bg0E3eWm.js.map +1 -0
  35. package/dist/chunks/{generate-Gcc8iRkZ.js → generate-CFqpRi9D.js} +3 -3
  36. package/dist/chunks/generate-CFqpRi9D.js.map +1 -0
  37. package/dist/chunks/{generate-BW3l5Fxw.js → generate-CZGHByV3.js} +2 -2
  38. package/dist/chunks/generate-CZGHByV3.js.map +1 -0
  39. package/dist/chunks/generate-DetW_gbr.js.map +1 -1
  40. package/dist/chunks/{generate.runtime-IlBCcXvv.js → generate.runtime-5rIc-RNL.js} +7 -7
  41. package/dist/chunks/generate.runtime-5rIc-RNL.js.map +1 -0
  42. package/dist/chunks/{generate.runtime-CA7Ofjlx.js → generate.runtime-BK3mR0Rj.js} +93 -141
  43. package/dist/chunks/generate.runtime-BK3mR0Rj.js.map +1 -0
  44. package/dist/chunks/{generate.runtime-cwvAoKoH.js → generate.runtime-BpMN5Uq-.js} +3 -3
  45. package/dist/chunks/generate.runtime-BpMN5Uq-.js.map +1 -0
  46. package/dist/chunks/{generate.runtime-DD51OSuL.js → generate.runtime-CAn1qIQ_.js} +4 -4
  47. package/dist/chunks/generate.runtime-CAn1qIQ_.js.map +1 -0
  48. package/dist/chunks/{generate.runtime-CuNhY5hn.js → generate.runtime-CEqLgLT9.js} +16 -11
  49. package/dist/chunks/generate.runtime-CEqLgLT9.js.map +1 -0
  50. package/dist/chunks/{generate.runtime-B1jVAnDI.js → generate.runtime-CK10Mum5.js} +8 -8
  51. package/dist/chunks/generate.runtime-CK10Mum5.js.map +1 -0
  52. package/dist/chunks/{generate.runtime-DqD3PW-W.js → generate.runtime-CZ46nkSL.js} +3 -3
  53. package/dist/chunks/generate.runtime-CZ46nkSL.js.map +1 -0
  54. package/dist/chunks/{generate.runtime-CslAvllQ.js → generate.runtime-CbE9RHcf.js} +5 -5
  55. package/dist/chunks/generate.runtime-CbE9RHcf.js.map +1 -0
  56. package/dist/chunks/{generate.runtime-CCr1lvo4.js → generate.runtime-CpMKXBkn.js} +7 -7
  57. package/dist/chunks/generate.runtime-CpMKXBkn.js.map +1 -0
  58. package/dist/chunks/{generate.runtime-6FXJM8hT.js → generate.runtime-CqncBFNg.js} +5 -5
  59. package/dist/chunks/generate.runtime-CqncBFNg.js.map +1 -0
  60. package/dist/chunks/generate.runtime-DG2z6kqH.js +68 -0
  61. package/dist/chunks/generate.runtime-DG2z6kqH.js.map +1 -0
  62. package/dist/chunks/{generate.runtime-C6bSvGMb.js → generate.runtime-DHHlYfTD.js} +6 -6
  63. package/dist/chunks/generate.runtime-DHHlYfTD.js.map +1 -0
  64. package/dist/chunks/generate.runtime-DJ9MVVPC.js +325 -0
  65. package/dist/chunks/generate.runtime-DJ9MVVPC.js.map +1 -0
  66. package/dist/chunks/{generate.runtime-CnPraLKv.js → generate.runtime-DVB7uuht.js} +4 -4
  67. package/dist/chunks/generate.runtime-DVB7uuht.js.map +1 -0
  68. package/dist/chunks/{generate.runtime-kvxmTlQb.js → generate.runtime-Db0HZyj3.js} +3 -3
  69. package/dist/chunks/{generate.runtime-kvxmTlQb.js.map → generate.runtime-Db0HZyj3.js.map} +1 -1
  70. package/dist/chunks/{generate.runtime-D_sQOeQa.js → generate.runtime-Djas9UNy.js} +6 -6
  71. package/dist/chunks/generate.runtime-Djas9UNy.js.map +1 -0
  72. package/dist/chunks/{generate.runtime-Ce_rwzNa.js → generate.runtime-Dl6OQ7pe.js} +4 -4
  73. package/dist/chunks/generate.runtime-Dl6OQ7pe.js.map +1 -0
  74. package/dist/chunks/{generate.runtime-1-91UmM8.js → generate.runtime-DoZJHtZh.js} +4 -4
  75. package/dist/chunks/generate.runtime-DoZJHtZh.js.map +1 -0
  76. package/dist/chunks/generate.runtime-Dp7SsCQG.js +42 -0
  77. package/dist/chunks/generate.runtime-Dp7SsCQG.js.map +1 -0
  78. package/dist/chunks/{generate.runtime-C8zJRNYG.js → generate.runtime-E-zoeSKW.js} +5 -5
  79. package/dist/chunks/generate.runtime-E-zoeSKW.js.map +1 -0
  80. package/dist/chunks/{generate.runtime-pVLzzpUM.js → generate.runtime-EQnytCFL.js} +40 -40
  81. package/dist/chunks/generate.runtime-EQnytCFL.js.map +1 -0
  82. package/dist/chunks/generate.runtime-IWEhGhWY.js +218 -0
  83. package/dist/chunks/generate.runtime-IWEhGhWY.js.map +1 -0
  84. package/dist/chunks/{generate.runtime-CYagyR5c.js → generate.runtime-a3R4hqFy.js} +6 -6
  85. package/dist/chunks/generate.runtime-a3R4hqFy.js.map +1 -0
  86. package/dist/chunks/{generate.runtime-zJpEufTc.js → generate.runtime-aQnBmH8D.js} +9 -9
  87. package/dist/chunks/generate.runtime-aQnBmH8D.js.map +1 -0
  88. package/dist/chunks/{generate.runtime-Dtgw9IQO.js → generate.runtime-axm9wcQv.js} +5 -5
  89. package/dist/chunks/generate.runtime-axm9wcQv.js.map +1 -0
  90. package/dist/chunks/{generate.runtime-DHBRyMAq.js → generate.runtime-hTKzxH2M.js} +5 -5
  91. package/dist/chunks/generate.runtime-hTKzxH2M.js.map +1 -0
  92. package/dist/chunks/{generate.runtime-BA3tDKnn.js → generate.runtime-kciwaXxh.js} +5 -5
  93. package/dist/chunks/generate.runtime-kciwaXxh.js.map +1 -0
  94. package/dist/chunks/{generate.runtime-B_UVGa3q.js → generate.runtime-koQxLywh.js} +5 -5
  95. package/dist/chunks/generate.runtime-koQxLywh.js.map +1 -0
  96. package/dist/chunks/{generate.runtime-BXkZob1O.js → generate.runtime-rs1ZOIET.js} +6 -6
  97. package/dist/chunks/{generate.runtime-BXkZob1O.js.map → generate.runtime-rs1ZOIET.js.map} +1 -1
  98. package/dist/chunks/{generate.runtime-DV3WmZtb.js → generate.runtime-uLUiPgqx.js} +6 -6
  99. package/dist/chunks/generate.runtime-uLUiPgqx.js.map +1 -0
  100. package/dist/chunks/lib-specifier-Cngo1zF_.js.map +1 -1
  101. package/dist/chunks/logger-CQONztPm.js.map +1 -1
  102. package/dist/chunks/{modify-file-BlDeeurK.js → modify-file-DK-tCH9k.js} +3 -3
  103. package/dist/chunks/modify-file-DK-tCH9k.js.map +1 -0
  104. package/dist/chunks/modify-nav-user-BLyrW2sK.js +71 -0
  105. package/dist/chunks/modify-nav-user-BLyrW2sK.js.map +1 -0
  106. package/dist/chunks/{modify-svelte-config-remote-p0TfVzxm.js → modify-svelte-config-remote-DhuRX4FI.js} +2 -2
  107. package/dist/chunks/modify-svelte-config-remote-DhuRX4FI.js.map +1 -0
  108. package/dist/chunks/modify-user-signup-BbqTiUuA.js +54 -0
  109. package/dist/chunks/modify-user-signup-BbqTiUuA.js.map +1 -0
  110. package/dist/chunks/modify-utils-Cw-on_cL.js.map +1 -1
  111. package/dist/chunks/package-imports-Bbw3iMPg.js.map +1 -1
  112. package/dist/chunks/pocketbase-C5GS-Dh5.js.map +1 -1
  113. package/dist/chunks/{pocketbase-Dry6ry17.js → pocketbase-CgwbH1gI.js} +2 -2
  114. package/dist/chunks/pocketbase-CgwbH1gI.js.map +1 -0
  115. package/dist/chunks/pocketbase-DpudAAmd.js.map +1 -1
  116. package/dist/chunks/providers-BHR6-XZ7.js.map +1 -1
  117. package/dist/chunks/{shared-CZC4d7Uj.js → shared-Cc_ns5-y.js} +2 -2
  118. package/dist/chunks/shared-Cc_ns5-y.js.map +1 -0
  119. package/dist/chunks/{site-BwCA18Sv.js → site-lj0CDdQ1.js} +2 -2
  120. package/dist/chunks/site-lj0CDdQ1.js.map +1 -0
  121. package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -1
  122. package/dist/chunks/{table-core-AjBpYi-y.js → table-core-DhDqT03G.js} +2 -2
  123. package/dist/chunks/table-core-DhDqT03G.js.map +1 -0
  124. package/dist/chunks/{taggedTemplateLiteral-Dx0fjWiw.js → taggedTemplateLiteral-CswN2AAa.js} +1 -1
  125. package/dist/chunks/{test-setup-DEmWd9Ul.js → test-setup-B9fQ5L_-.js} +5 -5
  126. package/dist/chunks/test-setup-B9fQ5L_-.js.map +1 -0
  127. package/dist/chunks/{ts-morph-helpers-CDW4lhox.js → ts-morph-helpers-Bepc-Es2.js} +27 -23
  128. package/dist/chunks/ts-morph-helpers-Bepc-Es2.js.map +1 -0
  129. package/dist/chunks/{ui-X698F10c.js → ui-CuCsupFq.js} +3 -3
  130. package/dist/chunks/ui-CuCsupFq.js.map +1 -0
  131. package/dist/chunks/ui-DD4NltyN.js.map +1 -1
  132. package/dist/chunks/{unmodify-load-CyGzC1Hu.js → unmodify-load-Bl5vXQiL.js} +2 -2
  133. package/dist/chunks/unmodify-load-Bl5vXQiL.js.map +1 -0
  134. package/dist/chunks/util-BLYliuUK.js.map +1 -1
  135. package/dist/chunks/whatsapp-CguKGTtw.js +105 -0
  136. package/dist/chunks/whatsapp-CguKGTtw.js.map +1 -0
  137. package/dist/chunks/{write-result-B68lvI57.js → write-result-DiZsCS_y.js} +5 -5
  138. package/dist/chunks/write-result-DiZsCS_y.js.map +1 -0
  139. package/dist/index.d.ts +133 -1
  140. package/dist/index.js +2240 -2005
  141. package/dist/index.js.map +1 -1
  142. package/package.json +2 -2
  143. package/dist/chunks/_layout-kkgN0IF7.js.map +0 -1
  144. package/dist/chunks/collections-Dz2fvKnz.js.map +0 -1
  145. package/dist/chunks/compose-handle-D_Rz3Fzo.js.map +0 -1
  146. package/dist/chunks/config-target-Dx3w6WSk.js.map +0 -1
  147. package/dist/chunks/constants-BjyMU5s8.js.map +0 -1
  148. package/dist/chunks/dispatch-CXOXPLFk.js +0 -6
  149. package/dist/chunks/dispatch-CXOXPLFk.js.map +0 -1
  150. package/dist/chunks/env-vars-C1NUX-bf.js.map +0 -1
  151. package/dist/chunks/format-result-DZ8De8KY.js.map +0 -1
  152. package/dist/chunks/generate-BW3l5Fxw.js.map +0 -1
  153. package/dist/chunks/generate-DeaBlnK6.js.map +0 -1
  154. package/dist/chunks/generate-Gcc8iRkZ.js.map +0 -1
  155. package/dist/chunks/generate-WMJo3QGZ.js.map +0 -1
  156. package/dist/chunks/generate.runtime-1-91UmM8.js.map +0 -1
  157. package/dist/chunks/generate.runtime-6FXJM8hT.js.map +0 -1
  158. package/dist/chunks/generate.runtime-B1jVAnDI.js.map +0 -1
  159. package/dist/chunks/generate.runtime-BA3tDKnn.js.map +0 -1
  160. package/dist/chunks/generate.runtime-BO778G0r.js +0 -188
  161. package/dist/chunks/generate.runtime-BO778G0r.js.map +0 -1
  162. package/dist/chunks/generate.runtime-B_UVGa3q.js.map +0 -1
  163. package/dist/chunks/generate.runtime-C6bSvGMb.js.map +0 -1
  164. package/dist/chunks/generate.runtime-C8zJRNYG.js.map +0 -1
  165. package/dist/chunks/generate.runtime-CA7Ofjlx.js.map +0 -1
  166. package/dist/chunks/generate.runtime-CCr1lvo4.js.map +0 -1
  167. package/dist/chunks/generate.runtime-CYagyR5c.js.map +0 -1
  168. package/dist/chunks/generate.runtime-Ce_rwzNa.js.map +0 -1
  169. package/dist/chunks/generate.runtime-CexC1Oky.js +0 -269
  170. package/dist/chunks/generate.runtime-CexC1Oky.js.map +0 -1
  171. package/dist/chunks/generate.runtime-CnPraLKv.js.map +0 -1
  172. package/dist/chunks/generate.runtime-CslAvllQ.js.map +0 -1
  173. package/dist/chunks/generate.runtime-CuNhY5hn.js.map +0 -1
  174. package/dist/chunks/generate.runtime-DD51OSuL.js.map +0 -1
  175. package/dist/chunks/generate.runtime-DHBRyMAq.js.map +0 -1
  176. package/dist/chunks/generate.runtime-DV3WmZtb.js.map +0 -1
  177. package/dist/chunks/generate.runtime-D_sQOeQa.js.map +0 -1
  178. package/dist/chunks/generate.runtime-DqD3PW-W.js.map +0 -1
  179. package/dist/chunks/generate.runtime-Dtgw9IQO.js.map +0 -1
  180. package/dist/chunks/generate.runtime-IlBCcXvv.js.map +0 -1
  181. package/dist/chunks/generate.runtime-cwvAoKoH.js.map +0 -1
  182. package/dist/chunks/generate.runtime-pVLzzpUM.js.map +0 -1
  183. package/dist/chunks/generate.runtime-zJpEufTc.js.map +0 -1
  184. package/dist/chunks/modify-file-BlDeeurK.js.map +0 -1
  185. package/dist/chunks/modify-svelte-config-remote-p0TfVzxm.js.map +0 -1
  186. package/dist/chunks/nav-user-BRIHOOpG.js +0 -6
  187. package/dist/chunks/nav-user-BRIHOOpG.js.map +0 -1
  188. package/dist/chunks/pocketbase-Dry6ry17.js.map +0 -1
  189. package/dist/chunks/shared-CZC4d7Uj.js.map +0 -1
  190. package/dist/chunks/site-BwCA18Sv.js.map +0 -1
  191. package/dist/chunks/table-core-AjBpYi-y.js.map +0 -1
  192. package/dist/chunks/test-setup-DEmWd9Ul.js.map +0 -1
  193. package/dist/chunks/ts-morph-helpers-CDW4lhox.js.map +0 -1
  194. package/dist/chunks/ui-X698F10c.js.map +0 -1
  195. package/dist/chunks/unmodify-load-CyGzC1Hu.js.map +0 -1
  196. package/dist/chunks/write-result-B68lvI57.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { _ as n, a as r, o as i, r as a } from "./ts-morph-helpers-CDW4lhox.js";
4
- import { modifyOutcomeToFile as o } from "./modify-file-BlDeeurK.js";
3
+ import { _ as n, a as r, o as i, r as a } from "./ts-morph-helpers-Bepc-Es2.js";
4
+ import { modifyOutcomeToFile as o } from "./modify-file-DK-tCH9k.js";
5
5
  import { t as s } from "./svelte-file-B3RfgVdt.js";
6
- import { i as c, n as l, t as u } from "./pocketbase-Dry6ry17.js";
7
- import { t as d } from "./site-BwCA18Sv.js";
8
- import { modifySvelteConfigRemote as f } from "./modify-svelte-config-remote-p0TfVzxm.js";
6
+ import { i as c, n as l, t as u } from "./pocketbase-CgwbH1gI.js";
7
+ import { t as d } from "./site-lj0CDdQ1.js";
8
+ import { modifySvelteConfigRemote as f } from "./modify-svelte-config-remote-DhuRX4FI.js";
9
9
  import p from "node:fs";
10
10
  import m from "node:path";
11
11
  import { Project as h, SyntaxKind as g } from "ts-morph";
@@ -119,9 +119,9 @@ function _(t) {
119
119
  }
120
120
  //#endregion
121
121
  //#region src/patterns/enable/auth-remote/modifies/root-layout.svelte.ts
122
- var v = "\n <Navbar.Item\n class=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n >\n <AuthMenu.Root>\n {#snippet user()}\n <AuthMenu.Trigger>\n <Avatar.Root>\n {#if data.user?.avatar}\n <Avatar.Image\n src=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n alt={data.user?.email}\n />\n {/if}\n <Avatar.Fallback>\n {data.user?.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n </AuthMenu.Trigger>\n\n <AuthMenu.Content align=\"end\">\n <AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n <AuthMenu.Group>\n <AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n <AuthMenu.Item>\n <form action=\"/logout\" method=\"post\">\n <button type=\"submit\" class=\"contents\">Logout</button>\n </form>\n </AuthMenu.Item>\n </AuthMenu.Group>\n </AuthMenu.Content>\n {/snippet}\n\n {#snippet guest()}\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"ghost\"\n href=\"/login\">Login</Button\n >\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"outline\"\n href=\"/signup\">Sign up</Button\n >\n {/snippet}\n </AuthMenu.Root>\n </Navbar.Item>\n ", y = e`
122
+ var v = "\n <Navbar.Item\n class=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n >\n <AuthMenu.Root>\n {#snippet user()}\n <AuthMenu.Trigger>\n <UserAvatar user={data.user} />\n </AuthMenu.Trigger>\n\n <AuthMenu.Content align=\"end\">\n <AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n <AuthMenu.Group>\n <AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n <AuthMenu.Item>\n <form action=\"/logout\" method=\"post\">\n <button type=\"submit\" class=\"contents\">Logout</button>\n </form>\n </AuthMenu.Item>\n </AuthMenu.Group>\n </AuthMenu.Content>\n {/snippet}\n\n {#snippet guest()}\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"ghost\"\n href=\"/login\">Login</Button\n >\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"outline\"\n href=\"/signup\">Sign up</Button\n >\n {/snippet}\n </AuthMenu.Root>\n </Navbar.Item>\n ", y = e`
123
123
  import * as AuthMenu from '#lib/components/ui/auth-menu/index.js';
124
- import * as Avatar from '#lib/components/ui/avatar/index.js';
124
+ import UserAvatar from '#lib/components/user-avatar.svelte';
125
125
  `, b = [
126
126
  "Add the auth menu inside your <Navbar.List> in the root layout.",
127
127
  "",
@@ -156,8 +156,8 @@ function S(e) {
156
156
  namespaceImport: "AuthMenu",
157
157
  moduleSpecifier: "#lib/components/ui/auth-menu/index.js"
158
158
  }, {
159
- namespaceImport: "Avatar",
160
- moduleSpecifier: "#lib/components/ui/avatar/index.js"
159
+ defaultImport: "UserAvatar",
160
+ moduleSpecifier: "#lib/components/user-avatar.svelte"
161
161
  }]), r(e, "data");
162
162
  });
163
163
  return t;
@@ -241,7 +241,12 @@ function T(e) {
241
241
  var E = e`
242
242
  // Login is a remote function, so there is no form action to post to: carry
243
243
  // the session the way the browser does, in the \`pb_auth\` cookie.
244
- async function authenticateUser(agent: Agent, user: { email: string }) {
244
+ async function authenticateUser(agent: Agent, user: { email?: string }) {
245
+ // Logs in with the password, so it needs the email (made optional by
246
+ // enable-whatsapp, for accounts that sign in with a phone number).
247
+ if (!user.email) {
248
+ throw new Error('authenticateUser needs a user with an email');
249
+ }
245
250
  const client = new PocketBase(process.env.POCKETBASE_URL!);
246
251
  await client.collection("users").authWithPassword(user.email, testUserPassword);
247
252
  agent.set("Cookie", client.authStore.exportToCookie().split(";")[0]);
@@ -325,4 +330,4 @@ async function O(e) {
325
330
  //#endregion
326
331
  export { O as generate };
327
332
 
328
- //# sourceMappingURL=generate.runtime-CuNhY5hn.js.map
333
+ //# sourceMappingURL=generate.runtime-CEqLgLT9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CEqLgLT9.js","names":["FAILURE_HINT","NOT_FOUND_HINT","dedent","getLogger","withInMemoryScript","ensurePropsBinding","formatLikeSource","ensureImports","SvelteFile","withPocketbase","migrationDelay","getMigrationFile","ensureSiteFile","fs","path","modifyLayoutServer","layoutPath","snippet","originalSource","sourceFile","Project","addUserProp","obj","loadArrow","loadFn","varDecl","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","el","parts","tail","currentName","body","expr","ret","inner","bodyExpr","AUTH_MENU_NAVBAR_ITEM","IMPORT_SNIPPET","FAILURE_HINT$1","NOT_FOUND_HINT$1","modifyRootLayoutSvelte","file","out","source","sf","FAILURE_HINT","NOT_FOUND_HINT","modifyHooksServer","hooksServerPath","callExpr","ce","args","firstArg","optionsObj","authProp","authInit","authObj","prProp","prInit","arr","COOKIE_LOGIN","modifyTestSetup","setupPath","helper","generate","options","logger","creates","pb","input","userCollection","verificationTemplate","resetPasswordTemplate","confirmEmailChangeTemplate","migrationFile","modifies","pushResult","layoutServerFile","modifyOutcomeToFile","layoutCandidates","layoutFile","p","hooksServerFile","testSetupFile","remote","modifySvelteConfigRemote","siteFile"],"sources":["../../src/patterns/enable/auth-remote/modifies/+layout.server.ts","../../src/patterns/enable/auth-remote/modifies/root-layout.svelte.ts","../../src/patterns/enable/auth-remote/modifies/hooks.server.ts","../../src/patterns/enable/auth-remote/modifies/test-setup.ts","../../src/patterns/enable/auth-remote/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\nexport function modifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n // if no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\n const bodyExpr = body as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n ensurePropsBinding,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst AUTH_MENU_NAVBAR_ITEM = `\n\t\t<Navbar.Item\n\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t>\n\t\t\t<AuthMenu.Root>\n\t\t\t\t{#snippet user()}\n\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t<UserAvatar user={data.user} />\n\t\t\t\t\t</AuthMenu.Trigger>\n\n\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t{/snippet}\n\n\t\t\t\t{#snippet guest()}\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t>\n\t\t\t\t{/snippet}\n\t\t\t</AuthMenu.Root>\n\t\t</Navbar.Item>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import * as AuthMenu from '#lib/components/ui/auth-menu/index.js';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the auth menu inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes an auth menu inside <Navbar.List>.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nexport function modifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namespaceImport: \"AuthMenu\",\n moduleSpecifier: \"#lib/components/ui/auth-menu/index.js\",\n },\n {\n defaultImport: \"UserAvatar\",\n moduleSpecifier: \"#lib/components/user-avatar.svelte\",\n },\n ]);\n // The menu reads `data.user`; the template's layout takes no props.\n ensurePropsBinding(sf, \"data\");\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"Navbar.List\", AUTH_MENU_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","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 auth option in hooks.server.ts:\n\n handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from '@velastack/pocketbase';\n\n export const handle = handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\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 // Find the handlePocketbase(...) call\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(`{ auth: { protectedRoutes: ['/(app)'] } }`);\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, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst COOKIE_LOGIN = dedent`\n // Login is a remote function, so there is no form action to post to: carry\n // the session the way the browser does, in the \\`pb_auth\\` cookie.\n async function authenticateUser(agent: Agent, user: { email?: string }) {\n // Logs in with the password, so it needs the email (made optional by\n // enable-whatsapp, for accounts that sign in with a phone number).\n if (!user.email) {\n throw new Error('authenticateUser needs a user with an email');\n }\n const client = new PocketBase(process.env.POCKETBASE_URL!);\n await client.collection(\"users\").authWithPassword(user.email, testUserPassword);\n agent.set(\"Cookie\", client.authStore.exportToCookie().split(\";\")[0]);\n }\n`;\n\n/**\n * The template's server-test helper logs in by posting the `/login` form\n * action, which this pattern replaces with a remote function. A project\n * without the helper (or with its own) has nothing to fix.\n */\nexport function modifyTestSetup(setupPath: string): ModifyOutcome {\n if (!fs.existsSync(setupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(setupPath);\n const helper = sourceFile.getFunction(\"authenticateUser\");\n\n if (!helper || !/\\.post\\(\\s*[\"'`]\\/login[\"'`]\\s*\\)/.test(helper.getText())) {\n return { status: \"success\", changed: false };\n }\n\n helper.replaceWithText(COOKIE_LOGIN);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { modifySvelteConfigRemote } from \"../../../runtime/modify-svelte-config-remote\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifyTestSetup } from \"./modifies/test-setup\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n const logger = getLogger(options);\n\n let creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n logger.info(\"Updating PocketBase mail settings\");\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n await migrationDelay();\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-reset/{TOKEN}\",\n \"{APP_URL}/confirm-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n logger.info(\"Locking down users collection rules and email templates\");\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n // Modify files\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(layoutServerFile, modifyLayoutServer(layoutServerFile)),\n );\n\n logger.info(\"Modifying root layout\");\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, modifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, modifyHooksServer(hooksServerFile)),\n );\n\n logger.info(\"Modifying test/setup.ts\");\n const testSetupFile = path.join(options.root, \"test\", \"setup.ts\");\n pushResult(\n modifyOutcomeToFile(testSetupFile, modifyTestSetup(testSetupFile)),\n );\n\n logger.info(\"Modifying config for remote functions\");\n const remote = modifySvelteConfigRemote(options.root);\n pushResult(modifyOutcomeToFile(remote.filePath, remote.outcome));\n\n // The auth pages and the app sidebar show `site.name`.\n const siteFile = await ensureSiteFile(options);\n\n return {\n creates: siteFile ? [siteFile] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAgBe,EAAmB,GAAmC;CACpE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAAG;EAC9B,IAAMC,IAAU,CAAM;;;;;EAOtB,OADAJ,EAAG,cAAcG,GAAYC,CAAO,GAC7B;GAAE,QAAQ;GAAW,SAAS;EAAK;CAC5C;CAEA,IAAMC,IAAiBL,EAAG,aAAaG,GAAY,MAAM,GAEnDG,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBJ,CAAU,GAGnDK,KAAe,MAAoD;EAEvE,AADkBC,EAAI,YAAY,MAAM,KAEtCA,EAAI,sBAAsB;GACxB,MAAM;GACN,aAAa;EACf,CAAC;CAEL,GAGIC,GACAC,GAKEC,IAAUN,EAAW,uBAAuB,MAAM;CACxD,IAAIM,KACSA,EAAQ,uBAAuBC,EAAW,iBAChC,CAAA,EAAI,iBAAiB,GAC1B;EACd,IAAMC,IAAcF,EAAQ,qBAC1BC,EAAW,aACb;EACA,IAAIC,GACF,IAAYA;OACP;GACL,IAAMC,IAAOH,EAAQ,eAAe;GACpC,IAAIG,GAAM;IACR,IAAMC,IAAaD,EAAK,yBACtBF,EAAW,aACb;IACA,IAAIG,GACF,IAAYA;S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Q,MAAM,OAAO,iBAAiB;CAKxE,AAJAW,EACEE,EAAoBI,GAAiBnC,EAAkBmC,CAAe,CAAC,CACzE,GAEAhB,EAAO,KAAK,yBAAyB;CACrC,IAAMiB,IAAgBhF,EAAK,KAAK8D,EAAQ,MAAM,QAAQ,UAAU;CAKhE,AAJAW,EACEE,EAAoBK,GAAetB,EAAgBsB,CAAa,CAAC,CACnE,GAEAjB,EAAO,KAAK,uCAAuC;CACnD,IAAMkB,IAASC,EAAyBpB,EAAQ,IAAI;CACpD,EAAWa,EAAoBM,EAAO,UAAUA,EAAO,OAAO,CAAC;CAG/D,IAAME,IAAW,MAAMrF,EAAegE,CAAO;CAE7C,OAAO;EACL,SAASqB,IAAW,CAACA,CAAQ,IAAI,CAAC;EAClC;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -3,13 +3,13 @@ import { t as n } from "./dedent-Gq6Krl4n.js";
3
3
  import { n as r } from "./logger-CQONztPm.js";
4
4
  import { t as i } from "./env-vars-mnRA0hOe.js";
5
5
  import { t as a } from "./env-vars-Cr4lbMD_.js";
6
- import { n as o } from "./shared-CZC4d7Uj.js";
7
- import { c as s, m as c, n as l, o as u } from "./ts-morph-helpers-CDW4lhox.js";
8
- import { modifyOutcomeToFile as d, revertOutcomeToFile as f } from "./modify-file-BlDeeurK.js";
9
- import { unmodifyEnvVarsFiles as p } from "./env-vars-C1NUX-bf.js";
10
- import { t as m } from "./site-BwCA18Sv.js";
11
- import { n as h } from "./compose-handle-D_Rz3Fzo.js";
12
- import { a as g, l as _, s as v } from "./test-setup-DEmWd9Ul.js";
6
+ import { n as o } from "./shared-Cc_ns5-y.js";
7
+ import { c as s, m as c, n as l, o as u } from "./ts-morph-helpers-Bepc-Es2.js";
8
+ import { modifyOutcomeToFile as d, revertOutcomeToFile as f } from "./modify-file-DK-tCH9k.js";
9
+ import { unmodifyEnvVarsFiles as p } from "./env-vars-CcE6ODqC.js";
10
+ import { t as m } from "./site-lj0CDdQ1.js";
11
+ import { n as h } from "./compose-handle-BDlZ7Pif.js";
12
+ import { a as g, l as _, s as v } from "./test-setup-B9fQ5L_-.js";
13
13
  import y from "node:fs";
14
14
  import b from "node:path";
15
15
  import { Node as x, Project as S, QuoteKind as C } from "ts-morph";
@@ -152,4 +152,4 @@ async function P(e) {
152
152
  //#endregion
153
153
  export { P as generate };
154
154
 
155
- //# sourceMappingURL=generate.runtime-B1jVAnDI.js.map
155
+ //# sourceMappingURL=generate.runtime-CK10Mum5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CK10Mum5.js","names":["libModule","dedent","getLogger","BACKEND_ENV_VARS","WORKFLOWS_ENV_VARS","toDeleteEntry","pruneUnusedImports","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","ensureSiteFile","removeHandle","unmodifyTestSetup","unmodifySvelteConfig","unmodifyGitignore","fs","path","HANDLE_HINT","INIT_HINT","BACKEND_MODULES","isStartWorkerCall","node","Node","onlyStartsWorker","fn","body","statements","workerInit","sf","decl","target","unmodifyHooksServerBackend","hooksServerPath","original","sourceFile","Project","QuoteKind","init","FAILURE_HINT","unmodifyLayoutServerMeta","layoutServerPath","updated","withoutParam","isLibSpecifier","m","serverTestFiles","dir","found","entry","full","generate","logger","options","creates","modifies","deletes","revert","svelteConfigFile","modifyOutcomeToFile","hooksServerRevert","revertOutcomeToFile","hasWorkflows","envVars","unmodifyEnvVarsFiles","spec","gitignorePath","gitignoreFile","layoutServerFile","siteFile","testFile","testSetupPath","testSetupFile"],"sources":["../../src/patterns/disable/backend/modifies/hooks.server.ts","../../src/patterns/disable/backend/modifies/layout-server.ts","../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport {\n Node,\n Project,\n QuoteKind,\n type SourceFile,\n type Statement,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n pruneUnusedImports,\n removeStatementWithComments,\n formatLikeSource,\n type ModuleMatch,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nconst HANDLE_HINT = dedent`\n Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,\n and its imports from '@velastack/pocketbase' and '$app/env/private'.\n`;\n\nconst INIT_HINT = dedent`\n The workflows are removed with the backend. Take the startWorker() call out\n of the init hook in src/hooks.server.ts, and its import:\n\n import { startWorker } from '#lib/server/workflows.js';\n`;\n\n/**\n * Modules only the backend's handle and init import from. An import nothing\n * references any more is dropped; a variable other code still reads stays.\n * `$env/dynamic/private` is the `env` object hooks written before SvelteKit 3\n * read the PocketBase variables from.\n */\nconst BACKEND_MODULES: ModuleMatch[] = [\n \"@velastack/pocketbase\",\n \"$app/env/private\",\n \"$env/dynamic/private\",\n libModule(\"server/workflows\"),\n \"@sveltejs/kit\",\n \"@sveltejs/kit/hooks\",\n];\n\n/** `startWorker()`, `await startWorker()` or `return startWorker()`. */\nfunction isStartWorkerCall(node: Node | undefined): boolean {\n if (!node) return false;\n if (Node.isAwaitExpression(node))\n return isStartWorkerCall(node.getExpression());\n if (Node.isExpressionStatement(node) || Node.isReturnStatement(node)) {\n return isStartWorkerCall(node.getExpression());\n }\n return (\n Node.isCallExpression(node) &&\n node.getExpression().getText() === \"startWorker\" &&\n node.getArguments().length === 0\n );\n}\n\n/** A function whose whole body starts the worker. */\nfunction onlyStartsWorker(fn: Node | undefined): boolean {\n if (\n !Node.isArrowFunction(fn) &&\n !Node.isFunctionExpression(fn) &&\n !Node.isFunctionDeclaration(fn)\n ) {\n return false;\n }\n const body = fn.getBody();\n if (!body) return false;\n if (!Node.isBlock(body)) return isStartWorkerCall(body);\n const statements = body.getStatements();\n return statements.length === 1 && isStartWorkerCall(statements[0]);\n}\n\n/**\n * The `init` export when all it does is start the workflow worker, the way\n * the minimal template and enable-workflows write it. `\"custom\"` when an init\n * starts the worker among other things; null when there is nothing to do.\n */\nfunction workerInit(sf: SourceFile): Statement | \"custom\" | null {\n const fn = sf.getFunction(\"init\");\n const decl = sf.getVariableDeclaration(\"init\");\n const target = fn ?? decl?.getVariableStatement();\n if (!target || !target.getText().includes(\"startWorker\")) return null;\n const onlyWorker = fn\n ? onlyStartsWorker(fn)\n : decl?.getVariableStatement()?.getDeclarations().length === 1 &&\n onlyStartsWorker(decl.getInitializer());\n return onlyWorker ? target : \"custom\";\n}\n\n/**\n * Undo what the backend put in `hooks.server.ts`: the PocketBase handle, and\n * the `init` that starts the workflow worker, which is deleted along with the\n * backend. Whatever else the file holds (i18n, content negotiation) stays; a\n * file with nothing else comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (\n !original.includes(\"handlePocketbase\") &&\n !original.includes(\"startWorker\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Checked before anything changes, so a failure leaves the file as it was.\n if (workerInit(sourceFile) === \"custom\") {\n return { status: \"failed\", message: INIT_HINT };\n }\n\n const removed = removeHandle(sourceFile, \"handlePocketbase\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: HANDLE_HINT };\n }\n // Looked up again: edits to the file forget the nodes found before them.\n const init = workerInit(sourceFile);\n if (init && init !== \"custom\") removeStatementWithComments(sourceFile, init);\n\n pruneUnusedImports(sourceFile, BACKEND_MODULES);\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.server.ts still reads locals.meta, which only the\n PocketBase hook provides. Read the values from a static module instead:\n\n import { site } from '#lib/site.js';\n\n // locals.meta.appName -> site.name\n // locals.meta.appURL -> site.url\n // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }\n`;\n\n/**\n * Point an older root layout's meta at `#lib/site.js` instead of `locals.meta`.\n * Templates from before `src/lib/site.ts` read the app name and URL off the\n * PocketBase hook; without the backend nothing sets them, and `App.Locals` no\n * longer declares them. Current templates read `#lib/site.js` already, so this\n * leaves them alone.\n */\nexport function unmodifyLayoutServerMeta(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"locals.meta\")) {\n return { status: \"success\", changed: false };\n }\n\n let updated = original\n .replace(/\\blocals\\.meta\\.appName\\b/g, \"site.name\")\n .replace(/\\blocals\\.meta\\.appURL\\b/g, \"site.url\")\n .replace(\n /\\bmeta:\\s*locals\\.meta\\b/g,\n \"meta: { appName: site.name, appURL: site.url }\",\n );\n\n if (updated.includes(\"locals.meta\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // `locals` usually only carried meta; drop it from the destructuring when\n // nothing else reads it.\n const withoutParam = updated\n .replace(/\\(\\{\\s*locals\\s*,\\s*/g, \"({ \")\n .replace(/,\\s*locals\\s*\\}/g, \" }\");\n if (!/\\blocals\\b/.test(withoutParam)) {\n updated = withoutParam;\n }\n\n const importsSite = [...updated.matchAll(/from\\s+['\"]([^'\"]+)['\"]/g)].some(\n (m) => isLibSpecifier(m[1], \"site\"),\n );\n if (!importsSite) {\n updated = \"import { site } from '#lib/site.js';\\n\" + updated;\n }\n\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { unmodifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { unmodifyLayoutServerMeta } from \"./modifies/layout-server\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\nimport { BACKEND_ENV_VARS } from \"../../enable/backend/env-vars\";\nimport { WORKFLOWS_ENV_VARS } from \"../../enable/workflows/env-vars\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\n\n/** Every server test under a directory; they need the PocketBase test context. */\nfunction serverTestFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const found: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) found.push(...serverTestFiles(full));\n else if (entry.name === \"server.test.ts\") found.push(full);\n }\n return found;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // Only the backend's handle and worker come out; handles other patterns\n // composed in stay. The file goes when nothing else was in it.\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerRevert.modify) modifies.push(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n // The file goes when these were all it declared. The workflow runtime\n // (deleted with the backend) is the only reader of its switches, so they\n // go too, but only from a project that has it: `TEST` is a common name.\n const hasWorkflows = fs.existsSync(\n path.join(options.root, \"src\", \"lib\", \"server\", \"workflows.ts\"),\n );\n logger.info(\n hasWorkflows\n ? \"Removing the PocketBase and workflow variables from src/env.ts\"\n : \"Removing the PocketBase variables from src/env.ts\",\n );\n const envVars = unmodifyEnvVarsFiles(\n options.root,\n (hasWorkflows ? WORKFLOWS_ENV_VARS : BACKEND_ENV_VARS).map(\n (spec) => spec.name,\n ),\n );\n if (envVars.modify) modifies.push(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const layoutServerFile = modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerMeta(layoutServerPath),\n );\n if (layoutServerFile) modifies.push(layoutServerFile);\n\n // The converted layout reads `src/lib/site.ts`. Every template ships it; a\n // project from before that gets one here, named as PocketBase knew it.\n if (layoutServerFile?.status === \"success\") {\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\n }\n\n // Server tests run against the PocketBase-backed test context that the\n // backend's test/setup.ts provides; without it they neither type-check nor\n // run.\n for (const testFile of serverTestFiles(path.join(options.root, \"src\"))) {\n logger.info(`Removing ${path.relative(options.root, testFile)}`);\n deletes.push(toDeleteEntry(testFile));\n }\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\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":";;;;;;;;;;;;;;;;AAoBA,IAAMiB,IAAc,CAAM;;;GAKpBC,IAAY,CAAM;;;;;GAalBC,IAAiC;CACrC;CACA;CACA;CACAnB,EAAU,kBAAkB;CAC5B;CACA;AACF;AAGA,SAASoB,EAAkB,GAAiC;CAO1D,OANKC,IACDC,EAAK,kBAAkBD,CAAI,KAE3BC,EAAK,sBAAsBD,CAAI,KAAKC,EAAK,kBAAkBD,CAAI,IAC1DD,EAAkBC,EAAK,cAAc,CAAC,IAG7CC,EAAK,iBAAiBD,CAAI,KAC1BA,EAAK,cAAc,CAAC,CAAC,QAAQ,MAAM,iBACnCA,EAAK,aAAa,CAAC,CAAC,WAAW,IATf;AAWpB;AAGA,SAASE,EAAiB,GAA+B;CACvD,IACE,CAACD,EAAK,gBAAgBE,CAAE,KACxB,CAACF,EAAK,qBAAqBE,CAAE,KAC7B,CAACF,EAAK,sBAAsBE,CAAE,GAE9B,OAAO;CAET,IAAMC,IAAOD,EAAG,QAAQ;CACxB,IAAI,CAACC,GAAM,OAAO;CAClB,IAAI,CAACH,EAAK,QAAQG,CAAI,GAAG,OAAOL,EAAkBK,CAAI;CACtD,IAAMC,IAAaD,EAAK,cAAc;CACtC,OAAOC,EAAW,WAAW,KAAKN,EAAkBM,EAAW,EAAE;AACnE;AAOA,SAASC,EAAW,GAA6C;CAC/D,IAAMH,IAAKI,EAAG,YAAY,MAAM,GAC1BC,IAAOD,EAAG,uBAAuB,MAAM,GACvCE,IAASN,KAAMK,GAAM,qBAAqB;CAMhD,OALI,CAACC,KAAU,CAACA,EAAO,QAAQ,CA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nC,EAAK,SAASoC,EAAQ,MAAMiB,CAAQ,GAAG,GAC/Dd,EAAQ,KAAKlD,EAAcgE,CAAQ,CAAC;CAGtC,EAAO,KAAK,yBAAyB;CACrC,IAAMC,IAAgBtD,EAAK,KAAKoC,EAAQ,MAAM,QAAQ,UAAU,GAC1DmB,IAAgBb,EACpBY,GACA1D,EAAkB0D,CAAa,CACjC;CAGA,OAFIC,KAAejB,EAAS,KAAKiB,CAAa,GAEvC;EACL;EACA;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { n as e } from "./logger-CQONztPm.js";
2
- import { o as t } from "./ts-morph-helpers-CDW4lhox.js";
3
- import { modifyOutcomeToFile as n } from "./modify-file-BlDeeurK.js";
2
+ import { o as t } from "./ts-morph-helpers-Bepc-Es2.js";
3
+ import { modifyOutcomeToFile as n } from "./modify-file-DK-tCH9k.js";
4
4
  import r from "node:fs";
5
5
  import i from "node:path";
6
6
  import { Project as a, SyntaxKind as o } from "ts-morph";
@@ -54,4 +54,4 @@ async function c(t) {
54
54
  //#endregion
55
55
  export { c as generate };
56
56
 
57
- //# sourceMappingURL=generate.runtime-DqD3PW-W.js.map
57
+ //# sourceMappingURL=generate.runtime-CZ46nkSL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CZ46nkSL.js","names":["getLogger","formatLikeSource","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","generate","logger","options","modifies","file","modifyOutcomeToFile"],"sources":["../../src/patterns/disable/api/modifies/hooks.server.ts","../../src/patterns/disable/api/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\n if (!callExpr) {\n return { status: \"success\", changed: false };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n return { status: \"success\", changed: false };\n }\n\n const firstArg = args[0];\n if (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) {\n return { status: \"success\", changed: false };\n }\n\n apiProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\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 { unmodifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\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":";;;;;;;AAKA,SAAgBI,EAAoB,GAA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UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,8 +1,8 @@
1
1
  import { r as e } from "./lib-specifier-Cngo1zF_.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { t as n } from "./shared-CZC4d7Uj.js";
4
- import { _ as r, g as i, n as a, o, p as s, u as c } from "./ts-morph-helpers-CDW4lhox.js";
5
- import { modifyOutcomeToFile as l } from "./modify-file-BlDeeurK.js";
3
+ import { t as n } from "./shared-Cc_ns5-y.js";
4
+ import { _ as r, g as i, n as a, o, p as s, u as c } from "./ts-morph-helpers-Bepc-Es2.js";
5
+ import { modifyOutcomeToFile as l } from "./modify-file-DK-tCH9k.js";
6
6
  import { t as u } from "./svelte-file-B3RfgVdt.js";
7
7
  import d from "node:fs";
8
8
  import f from "node:path";
@@ -44,7 +44,7 @@ function g(t) {
44
44
  let o = i.toString().replace(/<script[\s\S]*?<\/script>/g, "");
45
45
  return i.modifyScript((t) => {
46
46
  let { source: n } = r(t, (t) => {
47
- c(t, e("components/ui/auth-menu")), c(t, e("components/ui/avatar")), s(t, "data", o), a(t);
47
+ c(t, e("components/ui/auth-menu")), c(t, e("components/user-avatar.svelte")), c(t, e("components/ui/avatar")), s(t, "data", o), a(t);
48
48
  });
49
49
  return n;
50
50
  }), i.writeTo(t), {
@@ -109,4 +109,4 @@ async function v(e) {
109
109
  //#endregion
110
110
  export { v as generate };
111
111
 
112
- //# sourceMappingURL=generate.runtime-CslAvllQ.js.map
112
+ //# sourceMappingURL=generate.runtime-CbE9RHcf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CbE9RHcf.js","names":["libModule","getLogger","planDropsForCollections","withInMemoryScript","removeUnusedBindingElement","ensureBlankLineAfterImports","removePropsBindingIfUnused","removeImportByModuleSpecifier","SvelteFile","fs","path","unmodifyLayoutServer","layoutPath","originalSource","sourceFile","Project","literals","SyntaxKind","obj","userProp","formatLikeSource","unmodifyRootLayoutSvelte","source","file","markup","out","content","sf","unmodifyHooksServer","hooksServerPath","callExpr","ce","firstArg","optionsObj","authProp","generate","logger","options","modifies","pushResult","layoutServerFile","modifyOutcomeToFile","layoutCandidates","layoutFile","p","hooksServerFile"],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeUnusedBindingElement,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\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 {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.removeElement(\"AuthMenu.Root\");\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/auth-menu\"));\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/user-avatar.svelte\"),\n );\n // Layouts from before UserAvatar import the avatar parts directly.\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/avatar\"));\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","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 authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\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 +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\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":";;;;;;;;;;AAQA,SAAgBW,EAAqB,GAAmC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAY,MAAM;CACzD,IAAI,CAACC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMC,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAU,GAEnDI,IAAWF,EAAW,qBAC1BG,EAAW,uBACb;CACA,KAAK,IAAMC,KAAOF,GAAU;EAC1B,IAAMG,IAAWD,EAAI,YAAY,MAAM;EACvC,AAAKC,KAAYA,EAAS,QAAQ,MAAMF,EAAW,sBAGpCE,EACZ,eAAe,CAAC,EACf,QAAQ,MACE,gCACZA,EAAS,OAAO;CAEpB;CAQA,OALAf,EAA2BU,GAAY,QAAQ,GAE/CM,EAAiBN,CAAU,GAC3BA,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC;AACF;;;ACpCA,SAAgBQ,EAAyB,GAAmC;CAC1E,IAAI,CAACZ,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMU,IAASb,EAAG,aAAaG,GAAY,MAAM,GAC3CW,IAAO,IAAIf,EAAWc,CAAM;CAClC,IAAI,CAACC,EAAK,WAAW,eAAe,GAClC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CA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@
1
1
  import { t as e } from "./errors-DR3gF_7a.js";
2
- import { n as t } from "./constants-BjyMU5s8.js";
2
+ import { n as t } from "./constants-Rq8SCXwH.js";
3
3
  import { i as n, o as r, s as i } from "./providers-BHR6-XZ7.js";
4
- import { n as a, s as o } from "./generate-BW3l5Fxw.js";
4
+ import { n as a, s as o } from "./generate-CZGHByV3.js";
5
5
  import { n as s } from "./logger-CQONztPm.js";
6
6
  import { t as c } from "./env-BPfk1VAw.js";
7
- import { modifyOutcomeToFile as l } from "./modify-file-BlDeeurK.js";
8
- import { modifyEnvVarsFiles as u } from "./env-vars-C1NUX-bf.js";
9
- import { o as d } from "./config-target-Dx3w6WSk.js";
10
- import { c as f } from "./write-result-B68lvI57.js";
7
+ import { modifyOutcomeToFile as l } from "./modify-file-DK-tCH9k.js";
8
+ import { modifyEnvVarsFiles as u } from "./env-vars-CcE6ODqC.js";
9
+ import { o as d } from "./config-target-rHgjaA8u.js";
10
+ import { c as f } from "./write-result-DiZsCS_y.js";
11
11
  import p from "node:path";
12
12
  //#region src/patterns/enable/ai/generate.runtime.ts
13
13
  var m = f(t), h = [
@@ -40,4 +40,4 @@ async function _(t) {
40
40
  //#endregion
41
41
  export { _ as generate };
42
42
 
43
- //# sourceMappingURL=generate.runtime-CCr1lvo4.js.map
43
+ //# sourceMappingURL=generate.runtime-CpMKXBkn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CpMKXBkn.js","names":["ADAPTER_STATIC_SPEC","InvalidArgumentError","ADAPTER_STATIC$1","providerEnvVars","resolveProvider","suppliedProviderEnv","META","envEditsFor","getLogger","modifyEnv","resolveConfigTarget","packageName","path","ADAPTER_STATIC","STATIC_ADAPTER_MESSAGE","usesStaticAdapter","res","root","decl","generate","options","logger","provider","creates","modifies","envVars","modifyEnvVarsFiles","envPath","envFile","modifyOutcomeToFile"],"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 { ADAPTER_STATIC as ADAPTER_STATIC_SPEC } from \"../../../core/constants\";\nimport {\n providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { resolveConfigTarget } from \"../../../runtime/config-target\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { packageName } from \"../../../runtime/write-result\";\nimport { envEditsFor, META } from \"./generate\";\n\n// The config imports the package, not the versioned spec the constant installs.\nconst ADAPTER_STATIC = packageName(ADAPTER_STATIC_SPEC);\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 creates: File[] = [];\n const modifies: File[] = [];\n\n // SvelteKit 3 exposes only declared variables: `src/lib/server/ai.ts`\n // imports the provider's key from `$app/env/private`.\n logger.info(\"Declaring the API key in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n if (envVars.modify) modifies.push(envVars.modify);\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":";;;;;;;;;;;;AAkBA,IAAMa,IAAiBF,EAAYX,CAAmB,GAEzCc,IAAyB;CACpC,mDAAmDD,EAAe;CAClE;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAOX,SAAgBE,EAAkB,GAAuB;CACvD,IAAMC,IAAMN,EAAoBO,CAAI;CAEpC,OADID,EAAI,WAAW,cACZA,EAAI,OAAO,WACf,sBAAsB,CAAC,CACvB,MAAM,MAASE,EAAK,wBAAwB,MAAML,CAAc;AACrE;AAEA,eAAsBM,EAAS,GAAkB;CAC/C,IAAIJ,EAAkBK,EAAQ,IAAI,GAChC,MAAM,IAAInB,EAAqBa,CAAsB;CAGvD,IAAMO,IAASb,EAAUY,CAAO,GAC1BE,IAAWlB,EAAgBE,GAAMc,CAAO,GACxCG,IAAkB,CAAC,GACnBC,IAAmB,CAAC;CAI1B,EAAO,KAAK,qCAAqC;CACjD,IAAMC,IAAUC,EAAmBN,EAAQ,MAAMjB,EAAgBmB,CAAQ,CAAC;CAI1E,AAHIG,EAAQ,UAAQF,EAAQ,KAAKE,EAAQ,MAAM,GAC3CA,EAAQ,UAAQD,EAAS,KAAKC,EAAQ,MAAM,GAEhDJ,EAAO,KAAK,eAAe;CAC3B,IAAMM,IAAUf,EAAK,KAAKQ,EAAQ,MAAM,MAAM,GACxCQ,IAAUC,EACdF,GACAlB,EAAUkB,GAASpB,EAAYe,GAAUjB,EAAoBe,CAAO,CAAC,CAAC,CACxE;CAGA,OAFIQ,KAASJ,EAAS,KAAKI,CAAO,GAE3B;EACL;EACA;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
1
  import { r as e } from "./lib-specifier-Cngo1zF_.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { t as n } from "./shared-CZC4d7Uj.js";
4
- import { _ as r, n as i, u as a } from "./ts-morph-helpers-CDW4lhox.js";
5
- import { modifyOutcomeToFile as o } from "./modify-file-BlDeeurK.js";
3
+ import { t as n } from "./shared-Cc_ns5-y.js";
4
+ import { _ as r, n as i, u as a } from "./ts-morph-helpers-Bepc-Es2.js";
5
+ import { modifyOutcomeToFile as o } from "./modify-file-DK-tCH9k.js";
6
6
  import { t as s } from "./svelte-file-B3RfgVdt.js";
7
- import { t as c } from "./unmodify-load-CyGzC1Hu.js";
7
+ import { t as c } from "./unmodify-load-Bl5vXQiL.js";
8
8
  import l from "node:fs";
9
9
  import u from "node:path";
10
10
  //#region src/patterns/disable/notifications/modifies/modify-app-layout.ts
@@ -64,4 +64,4 @@ async function p(e) {
64
64
  //#endregion
65
65
  export { p as generate };
66
66
 
67
- //# sourceMappingURL=generate.runtime-6FXJM8hT.js.map
67
+ //# sourceMappingURL=generate.runtime-CqncBFNg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CqncBFNg.js","names":["libModule","getLogger","planDropsForCollections","withInMemoryScript","ensureBlankLineAfterImports","removeImportByModuleSpecifier","SvelteFile","removeFromLoad","fs","path","unmodifyAppLayout","layoutPath","original","file","out","source","sf","updated","unmodifyLayoutServer","layoutServerPath","generate","logger","options","modifies","pushResult","appLayoutPath","modifyOutcomeToFile","appLayoutServerPath"],"sources":["../../src/patterns/disable/notifications/modifies/modify-app-layout.ts","../../src/patterns/disable/notifications/modifies/+layout.server.ts","../../src/patterns/disable/notifications/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\n/** Take the bell (and the wrapper enable-notifications put it in) out of the header. */\nexport function unmodifyAppLayout(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"NotificationsBell\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/notifications-bell.svelte\"),\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n let updated = file.toString();\n updated = updated.replace(\n /\\n*[ \\t]*<div class=\"ml-auto px-4\">\\s*<NotificationsBell\\s*\\/>\\s*<\\/div>[ \\t]*/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<NotificationsBell\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeFromLoad } from \"../../../../runtime/unmodify-load\";\n\n/** Take the unread-notifications query back out of the (app) layout's load. */\nexport function unmodifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n return removeFromLoad(layoutServerPath, {\n variables: [\"notificationsList\", \"notifications\"],\n dependsKeys: [\"app:notifications\"],\n returnProps: [\"notifications\"],\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 { unmodifyAppLayout } from \"./modifies/modify-app-layout\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\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 (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, unmodifyAppLayout(appLayoutPath)),\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 unmodifyLayoutServer(appLayoutServerPath),\n ),\n );\n\n // The timeAgo helper enable-notifications added to #lib/utils.js stays: it is\n // generic, and other code may have started using it.\n\n const collectionDrops = await planDropsForCollections(\n [\"notifications\"],\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":";;;;;;;;;;AAWA,SAAgBU,EAAkB,GAAmC;CACnE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWJ,EAAG,aAAaG,GAAY,MAAM;CACnD,IAAI,CAACC,EAAS,SAAS,mBAAmB,GACxC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAOP,EAAW,SAASK,CAAU;CAC3C,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQG,MAAQX,EAAmBY,IAAS,MAAO;GAKzD,AAJAV,EACEW,GACAhB,EAAU,sCAAsC,CAClD,GACAI,EAA4BY,CAAE;EAChC,CAAC;EACD,OAAOF;CACT,CAAC;CAED,IAAIG,IAAUJ,EAAK,SAAS;CAQ5B,OAPA,IAAUI,EAAQ,QAChB,mFACA,EACF,GACA,IAAUA,EAAQ,QAAQ,+CAA+C,EAAE,GAE3ET,EAAG,cAAcG,GAAYM,GAAS,MAAM,GACrC;EAAE,QAAQ;EAAW,SAASA,MAAYL;CAAS;AAC5D;;;ACtCA,SAAgBM,EAAqB,GAAyC;CAC5E,OAAOX,EAAeY,GAAkB;EACtC,WAAW,CAAC,qBAAqB,eAAe;EAChD,aAAa,CAAC,mBAAmB;EACjC,aAAa,CAAC,eAAe;CAC/B,CAAC;AACH;;;ACFA,eAAsBC,EAAS,GAAkB;CAC/C,IAAMC,IAASpB,EAAUqB,CAAO,GAC1BC,IAAmB,CAAC,GACpBC,KAAc,MAAsB;EACxC,AAAIX,KAAMU,EAAS,KAAKV,CAAI;CAC9B;CAEA,EAAO,KAAK,gCAAgC;CAC5C,IAAMY,IAAgBhB,EAAK,KACzBa,EAAQ,MACR,OACA,UACA,SACA,gBACF;CAKA,AAJAE,EACEE,EAAoBD,GAAef,EAAkBe,CAAa,CAAC,CACrE,GAEAJ,EAAO,KAAK,mCAAmC;CAC/C,IAAMM,IAAsBlB,EAAK,KAC/Ba,EAAQ,MACR,OACA,UACA,SACA,mBACF;CAgBA,OAfAE,EACEE,EACEC,GACAT,EAAqBS,CAAmB,CAC1C,CACF,GAUO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4BzB,EAC5B,CAAC,eAAe,GAChBoB,CACF;CAWA;AACF"}
@@ -0,0 +1,68 @@
1
+ import { n as e } from "./logger-CQONztPm.js";
2
+ import { modifyOutcomeToFile as t } from "./modify-file-DK-tCH9k.js";
3
+ import { i as n, n as r, t as i } from "./pocketbase-CgwbH1gI.js";
4
+ import { a, i as o, o as s, r as c, t as l } from "./whatsapp-CguKGTtw.js";
5
+ import { swapAuthPages as u } from "./auth-pages-B52ei-4z.js";
6
+ import d from "node:fs";
7
+ import f from "node:path";
8
+ //#region src/patterns/enable/whatsapp/modifies/modify-test-setup.ts
9
+ function p(e) {
10
+ if (!d.existsSync(e)) return {
11
+ status: "success",
12
+ changed: !1
13
+ };
14
+ let t = d.readFileSync(e, "utf8"), n = t;
15
+ return n = n.replace(/^([ \t]*)(async function authenticateUser\(agent: Agent, user: \{ )email: string( \}\) \{\n)([ \t]*)/m, (e, t, n, r, i) => `${t}${n}email?: string${r}${i}// Logs in with the password, so it needs the email (made optional by\n${i}// enable-whatsapp, for accounts that sign in with a phone number).\n${i}if (!user.email) {\n${i}${i.includes(" ") ? " " : " "}throw new Error('authenticateUser needs a user with an email');\n${i}}\n` + i), n = n.replace(/^([ \t]*)context\.user = await context\.admin\.collection\('users'\)\.create\(\{\n([ \t]*)email: (`test-\$\{Math\.random\(\)\.toString\(36\)\.slice\(2\)\}@example\.com`),/m, (e, t, n, r) => `${t}const email = ${r};\n${t}context.user = await context.admin.collection('users').create({\n${n}email,`), n.includes("const email = `test-") && (n = n.replace(".authWithPassword(context.user.email, testUserPassword)", ".authWithPassword(email, testUserPassword)")), n === t ? {
16
+ status: "success",
17
+ changed: !1
18
+ } : (d.writeFileSync(e, n, "utf8"), {
19
+ status: "success",
20
+ changed: !0
21
+ });
22
+ }
23
+ //#endregion
24
+ //#region src/patterns/enable/whatsapp/generate.runtime.ts
25
+ var m = "https://docs.velastack.dev/enable/whatsapp";
26
+ function h(e) {
27
+ return {
28
+ path: e,
29
+ language: "js",
30
+ content: d.readFileSync(e, "utf8"),
31
+ status: "success"
32
+ };
33
+ }
34
+ async function g(d) {
35
+ let g = e(d), _ = [];
36
+ await n(d.root, async (e) => {
37
+ if (!await o(e)) throw Error(`This PocketBase has no WhatsApp sign-in. It comes with pocketbase-server ${l} and later: run \`npm install -D pocketbase-server@^${l}\`, then \`vela enable whatsapp\` again.`);
38
+ if (g.info("Adding the phone fields to users and making email optional"), await a(e)) {
39
+ await r();
40
+ let e = i("users", "updated", d);
41
+ e && _.push(h(e));
42
+ }
43
+ g.info("Turning on WhatsApp sign-in for users"), await c(e), await r();
44
+ let t = s(d, !0);
45
+ t && _.push(h(t));
46
+ }), g.info("Adding WhatsApp to the login and signup pages");
47
+ let v = [], y = await u(d.root, "enable", (e) => `${f.relative(d.root, e)} is not the page enable-auth wrote, so it was left as it is. Add the WhatsApp option to it by hand: ${m}`);
48
+ for (let [e, n] of y) {
49
+ let r = t(e, n);
50
+ r && v.push(r);
51
+ }
52
+ g.info("Updating test/setup.ts for an optional email");
53
+ let b = f.join(d.root, "test", "setup.ts"), x = t(b, p(b));
54
+ return x && v.push(x), {
55
+ creates: _,
56
+ modifies: v,
57
+ deletes: [],
58
+ components: [],
59
+ packages: [],
60
+ collections: [],
61
+ collectionPatches: [],
62
+ collectionDrops: []
63
+ };
64
+ }
65
+ //#endregion
66
+ export { g as generate };
67
+
68
+ //# sourceMappingURL=generate.runtime-DG2z6kqH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-DG2z6kqH.js","names":["getLogger","withPocketbase","migrationDelay","getMigrationFile","hasWhatsAppPlugin","writeWhatsAppConfigMigration","enableWhatsAppAuth","MIN_POCKETBASE_SERVER","fs","path","modifyTestSetup","setupPath","original","content","indent","head","tail","bodyIndent","value","fieldIndent","DOCS_URL","migrationCreate","file","generate","logger","options","creates","pb","setupWhatsAppFields","configMigration","modifies","outcomes","swapAuthPages","filePath","outcome","modifyOutcomeToFile","testSetup","testSetupFile"],"sources":["../../src/patterns/enable/whatsapp/modifies/modify-test-setup.ts","../../src/patterns/enable/whatsapp/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * `email` turns optional on `users`, which the generated types follow, so a\n * test setup from before enable-backend handled that no longer type-checks:\n * its `authenticateUser` takes `{ email: string }` and it signs the test\n * user in with `context.user.email`. Brings those two spots up to the\n * current setup; anything else in the file is the project's own.\n */\nexport function modifyTestSetup(setupPath: string): ModifyOutcome {\n if (!fs.existsSync(setupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(setupPath, \"utf8\");\n let content = original;\n\n content = content.replace(\n /^([ \\t]*)(async function authenticateUser\\(agent: Agent, user: \\{ )email: string( \\}\\) \\{\\n)([ \\t]*)/m,\n (_, indent, head, tail, bodyIndent) =>\n `${indent}${head}email?: string${tail}` +\n `${bodyIndent}// Logs in with the password, so it needs the email (made optional by\\n` +\n `${bodyIndent}// enable-whatsapp, for accounts that sign in with a phone number).\\n` +\n `${bodyIndent}if (!user.email) {\\n` +\n `${bodyIndent}${bodyIndent.includes(\"\\t\") ? \"\\t\" : \" \"}throw new Error('authenticateUser needs a user with an email');\\n` +\n `${bodyIndent}}\\n` +\n bodyIndent,\n );\n\n // The user is made with a known email: sign in with that.\n content = content.replace(\n /^([ \\t]*)context\\.user = await context\\.admin\\.collection\\('users'\\)\\.create\\(\\{\\n([ \\t]*)email: (`test-\\$\\{Math\\.random\\(\\)\\.toString\\(36\\)\\.slice\\(2\\)\\}@example\\.com`),/m,\n (_, indent, fieldIndent, value) =>\n `${indent}const email = ${value};\\n` +\n `${indent}context.user = await context.admin.collection('users').create({\\n` +\n `${fieldIndent}email,`,\n );\n if (content.includes(\"const email = `test-\")) {\n content = content.replace(\n \".authWithPassword(context.user.email, testUserPassword)\",\n \".authWithPassword(email, testUserPassword)\",\n );\n }\n\n if (content === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(setupPath, content, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n MIN_POCKETBASE_SERVER,\n enableWhatsAppAuth,\n hasWhatsAppPlugin,\n setupWhatsAppFields,\n writeWhatsAppConfigMigration,\n} from \"./runtime/whatsapp\";\nimport { swapAuthPages } from \"./modifies/auth-pages\";\nimport { modifyTestSetup } from \"./modifies/modify-test-setup\";\n\nexport const DOCS_URL = \"https://docs.velastack.dev/enable/whatsapp\";\n\nfunction migrationCreate(file: string): File {\n return {\n path: file,\n language: \"js\",\n content: fs.readFileSync(file, \"utf8\"),\n status: \"success\",\n };\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n if (!(await hasWhatsAppPlugin(pb))) {\n throw new Error(\n `This PocketBase has no WhatsApp sign-in. It comes with pocketbase-server ${MIN_POCKETBASE_SERVER} and later: run \\`npm install -D pocketbase-server@^${MIN_POCKETBASE_SERVER}\\`, then \\`vela enable whatsapp\\` again.`,\n );\n }\n\n logger.info(\"Adding the phone fields to users and making email optional\");\n if (await setupWhatsAppFields(pb)) {\n await migrationDelay();\n const file = getMigrationFile(\"users\", \"updated\", options);\n if (file) creates.push(migrationCreate(file));\n }\n\n logger.info(\"Turning on WhatsApp sign-in for users\");\n await enableWhatsAppAuth(pb);\n await migrationDelay();\n const configMigration = writeWhatsAppConfigMigration(options, true);\n if (configMigration) creates.push(migrationCreate(configMigration));\n });\n\n logger.info(\"Adding WhatsApp to the login and signup pages\");\n const modifies: File[] = [];\n const outcomes = await swapAuthPages(\n options.root,\n \"enable\",\n (filePath) =>\n `${path.relative(options.root, filePath)} is not the page enable-auth wrote, so it was left as it is. Add the WhatsApp option to it by hand: ${DOCS_URL}`,\n );\n for (const [filePath, outcome] of outcomes) {\n const file = modifyOutcomeToFile(filePath, outcome);\n if (file) modifies.push(file);\n }\n\n logger.info(\"Updating test/setup.ts for an optional email\");\n const testSetup = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetup,\n modifyTestSetup(testSetup),\n );\n if (testSetupFile) modifies.push(testSetupFile);\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collect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GACjC,MAAMzB,EAAe;GACrB,IAAMoB,IAAOnB,EAAiB,SAAS,WAAWsB,CAAO;GACzD,AAAIH,KAAMI,EAAQ,KAAKL,EAAgBC,CAAI,CAAC;EAC9C;EAIA,AAFAE,EAAO,KAAK,uCAAuC,GACnD,MAAMlB,EAAmBqB,CAAE,GAC3B,MAAMzB,EAAe;EACrB,IAAM2B,IAAkBxB,EAA6BoB,GAAS,EAAI;EAClE,AAAII,KAAiBH,EAAQ,KAAKL,EAAgBQ,CAAe,CAAC;CACpE,CAAC,GAEDL,EAAO,KAAK,+CAA+C;CAC3D,IAAMM,IAAmB,CAAC,GACpBC,IAAW,MAAMC,EACrBP,EAAQ,MACR,WACC,MACC,GAAGhB,EAAK,SAASgB,EAAQ,MAAMQ,CAAQ,EAAE,sGAAsGb,GACnJ;CACA,KAAK,IAAM,CAACa,GAAUC,MAAYH,GAAU;EAC1C,IAAMT,IAAOa,EAAoBF,GAAUC,CAAO;EAClD,AAAIZ,KAAMQ,EAAS,KAAKR,CAAI;CAC9B;CAEA,EAAO,KAAK,8CAA8C;CAC1D,IAAMc,IAAY3B,EAAK,KAAKgB,EAAQ,MAAM,QAAQ,UAAU,GACtDY,IAAgBF,EACpBC,GACA1B,EAAgB0B,CAAS,CAC3B;CAGA,OAFIC,KAAeP,EAAS,KAAKO,CAAa,GAEvC;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,12 +1,12 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { t } from "./ui-DD4NltyN.js";
3
3
  import { n } from "./logger-CQONztPm.js";
4
- import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-CDW4lhox.js";
5
- import { modifyOutcomeToFile as s } from "./modify-file-BlDeeurK.js";
4
+ import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-Bepc-Es2.js";
5
+ import { modifyOutcomeToFile as s } from "./modify-file-DK-tCH9k.js";
6
6
  import { t as c } from "./svelte-file-B3RfgVdt.js";
7
- import { t as l } from "./compose-handle-D_Rz3Fzo.js";
8
- import { a as u, t as d } from "./config-target-Dx3w6WSk.js";
9
- import { i as f, n as p } from "./_layout-kkgN0IF7.js";
7
+ import { t as l } from "./compose-handle-BDlZ7Pif.js";
8
+ import { a as u, t as d } from "./config-target-rHgjaA8u.js";
9
+ import { i as f, n as p } from "./_layout-D-FzWqn0.js";
10
10
  import m from "node:fs";
11
11
  import h from "node:path";
12
12
  import { Project as g, QuoteKind as _, SyntaxKind as v } from "ts-morph";
@@ -468,4 +468,4 @@ async function ne(e) {
468
468
  //#endregion
469
469
  export { ne as generate };
470
470
 
471
- //# sourceMappingURL=generate.runtime-C6bSvGMb.js.map
471
+ //# sourceMappingURL=generate.runtime-DHHlYfTD.js.map