@velastack/patterns 0.2.7 → 0.2.8

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 (53) hide show
  1. package/dist/chunks/{collections-B3lAtPlQ.js → collections-DeuRxasZ.js} +37 -21
  2. package/dist/chunks/collections-DeuRxasZ.js.map +1 -0
  3. package/dist/chunks/dispatch-B5PfQ2CA.js +6 -0
  4. package/dist/chunks/dispatch-B5PfQ2CA.js.map +1 -0
  5. package/dist/chunks/{generate.runtime-lqPPXQyS.js → generate.runtime-B0J8waP-.js} +2 -2
  6. package/dist/chunks/{generate.runtime-lqPPXQyS.js.map → generate.runtime-B0J8waP-.js.map} +1 -1
  7. package/dist/chunks/{generate.runtime-tAbxWeq-.js → generate.runtime-BKowHAId.js} +2 -2
  8. package/dist/chunks/{generate.runtime-tAbxWeq-.js.map → generate.runtime-BKowHAId.js.map} +1 -1
  9. package/dist/chunks/{generate.runtime-kH6XaWQz.js → generate.runtime-BUz8qsUk.js} +2 -2
  10. package/dist/chunks/{generate.runtime-kH6XaWQz.js.map → generate.runtime-BUz8qsUk.js.map} +1 -1
  11. package/dist/chunks/{generate.runtime-DWeiewRj.js → generate.runtime-BfRWFGCP.js} +2 -2
  12. package/dist/chunks/{generate.runtime-DWeiewRj.js.map → generate.runtime-BfRWFGCP.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-BjULAL3h.js → generate.runtime-BlwLsK-c.js} +2 -2
  14. package/dist/chunks/{generate.runtime-BjULAL3h.js.map → generate.runtime-BlwLsK-c.js.map} +1 -1
  15. package/dist/chunks/{generate.runtime-DKJaYtVZ.js → generate.runtime-Bo5tOmRg.js} +41 -65
  16. package/dist/chunks/generate.runtime-Bo5tOmRg.js.map +1 -0
  17. package/dist/chunks/{generate.runtime-DCvLLO7w.js → generate.runtime-BywhFAZa.js} +64 -121
  18. package/dist/chunks/generate.runtime-BywhFAZa.js.map +1 -0
  19. package/dist/chunks/{generate.runtime-Dc98DCsh.js → generate.runtime-CVPcn5hc.js} +2 -2
  20. package/dist/chunks/{generate.runtime-Dc98DCsh.js.map → generate.runtime-CVPcn5hc.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-Wssys8A0.js → generate.runtime-DQvDpuU1.js} +17 -17
  22. package/dist/chunks/generate.runtime-DQvDpuU1.js.map +1 -0
  23. package/dist/chunks/{generate.runtime-BdTCMGGB.js → generate.runtime-D_wtBQFh.js} +2 -2
  24. package/dist/chunks/{generate.runtime-BdTCMGGB.js.map → generate.runtime-D_wtBQFh.js.map} +1 -1
  25. package/dist/chunks/{generate.runtime-CGkVUKvz.js → generate.runtime-DqQwe6nL.js} +2 -2
  26. package/dist/chunks/{generate.runtime-CGkVUKvz.js.map → generate.runtime-DqQwe6nL.js.map} +1 -1
  27. package/dist/chunks/generate.runtime-Dtf2BI_5.js +87 -0
  28. package/dist/chunks/generate.runtime-Dtf2BI_5.js.map +1 -0
  29. package/dist/chunks/{generate.runtime-QmFJI7G1.js → generate.runtime-HXI2vYBy.js} +2 -2
  30. package/dist/chunks/{generate.runtime-QmFJI7G1.js.map → generate.runtime-HXI2vYBy.js.map} +1 -1
  31. package/dist/chunks/{generate.runtime-BlQ1vx8j.js → generate.runtime-g9dvfgwT.js} +97 -138
  32. package/dist/chunks/generate.runtime-g9dvfgwT.js.map +1 -0
  33. package/dist/chunks/nav-user-BYI-h8Od.js +6 -0
  34. package/dist/chunks/nav-user-BYI-h8Od.js.map +1 -0
  35. package/dist/chunks/{shared--_BWnGsc.js → shared-DXQcaNNX.js} +2 -2
  36. package/dist/chunks/{shared--_BWnGsc.js.map → shared-DXQcaNNX.js.map} +1 -1
  37. package/dist/chunks/{ui-BsG60gQg.js → ui-B2pSrier.js} +2 -2
  38. package/dist/chunks/{ui-BsG60gQg.js.map → ui-B2pSrier.js.map} +1 -1
  39. package/dist/chunks/{write-result-BN7Ff0rF.js → write-result-CB5oDtjf.js} +2 -2
  40. package/dist/chunks/{write-result-BN7Ff0rF.js.map → write-result-CB5oDtjf.js.map} +1 -1
  41. package/dist/index.d.ts +208 -62
  42. package/dist/index.js +1767 -1493
  43. package/dist/index.js.map +1 -1
  44. package/package.json +1 -1
  45. package/dist/chunks/_server-BSm1eAiY.js +0 -6
  46. package/dist/chunks/_server-BSm1eAiY.js.map +0 -1
  47. package/dist/chunks/collections-B3lAtPlQ.js.map +0 -1
  48. package/dist/chunks/generate.runtime-BlQ1vx8j.js.map +0 -1
  49. package/dist/chunks/generate.runtime-DCvLLO7w.js.map +0 -1
  50. package/dist/chunks/generate.runtime-DKJaYtVZ.js.map +0 -1
  51. package/dist/chunks/generate.runtime-Wssys8A0.js.map +0 -1
  52. package/dist/chunks/nav-user-CndUO69x.js +0 -6
  53. package/dist/chunks/nav-user-CndUO69x.js.map +0 -1
@@ -1,57 +1,19 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { a as n, c as r, i, n as a, o, r as s, s as c, t as l } from "./_server-BSm1eAiY.js";
4
- import { modifyOutcomeToFile as u } from "./modify-file-Cgu_WeFk.js";
5
- import { c as d, l as f, r as p } from "./ts-morph-helpers-Bf5iuQW8.js";
6
- import m from "node:path";
7
- import h from "node:fs";
8
- import { SyntaxKind as g } from "ts-morph";
9
- //#region src/patterns/enable/subscriptions/modifies/modify-stripe-hooks.ts
10
- var _ = e`
11
- cronAdd("stripe-subscriptions", "*/2 * * * *", () => {
12
- const utils = require(\`\${__hooks}/utils.js\`);
13
- utils.triggerJob("/api/stripe/sync/subscriptions");
14
- });
15
- `, v = [
16
- "Append the stripe-subscriptions cron to data/hooks/stripe.pb.js:",
17
- "",
18
- _
19
- ].join("\n"), y = [
20
- "Enable payments first — data/hooks/stripe.pb.js is created by enable-payments.",
21
- "",
22
- "Once present, append:",
23
- "",
24
- _
25
- ].join("\n");
26
- function b(e) {
27
- if (!h.existsSync(e)) return {
28
- status: "not-found",
29
- message: y
30
- };
31
- let t = h.readFileSync(e, "utf8");
32
- if (t.includes("stripe-subscriptions")) return {
33
- status: "success",
34
- changed: !1
35
- };
36
- if (!t.includes("cronAdd(")) return {
37
- status: "failed",
38
- message: v
39
- };
40
- let n = `${t}${t.endsWith("\n") ? "" : "\n"}\n${_}\n`;
41
- return h.writeFileSync(e, n, "utf8"), {
42
- status: "success",
43
- changed: !0
44
- };
45
- }
46
- //#endregion
3
+ import { a as n, i as r, n as i, o as a, r as o, s, t as c } from "./dispatch-B5PfQ2CA.js";
4
+ import { modifyOutcomeToFile as l } from "./modify-file-Cgu_WeFk.js";
5
+ import { c as u, l as d, r as f } from "./ts-morph-helpers-Bf5iuQW8.js";
6
+ import p from "node:path";
7
+ import m from "node:fs";
8
+ import { SyntaxKind as h } from "ts-morph";
47
9
  //#region src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts
48
- var x = e`
49
- Wire the subscription event handlers into src/routes/webhooks/stripe/+server.ts:
10
+ var g = e`
11
+ Wire the subscription event handlers into src/routes/webhooks/stripe/handlers/dispatch.ts:
50
12
 
51
13
  Add imports:
52
- import { handleSubscriptionCreated } from "./handlers/subscription/created";
53
- import { handleSubscriptionUpdated } from "./handlers/subscription/updated";
54
- import { handleSubscriptionDeleted } from "./handlers/subscription/deleted";
14
+ import { handleSubscriptionCreated } from "./subscription/created";
15
+ import { handleSubscriptionUpdated } from "./subscription/updated";
16
+ import { handleSubscriptionDeleted } from "./subscription/deleted";
55
17
 
56
18
  Add switch cases inside the event.type switch:
57
19
  case "customer.subscription.created":
@@ -63,7 +25,7 @@ var x = e`
63
25
  case "customer.subscription.deleted":
64
26
  await handleSubscriptionDeleted(event.data.object, locals);
65
27
  break;
66
- `, S = "Enable payments first — src/routes/webhooks/stripe/+server.ts is created by enable-payments.", C = e`
28
+ `, _ = "Enable payments first — src/routes/webhooks/stripe/handlers/dispatch.ts is created by enable-payments.", v = e`
67
29
  case "customer.subscription.created":
68
30
  await handleSubscriptionCreated(event.data.object, locals);
69
31
  break;
@@ -76,57 +38,57 @@ var x = e`
76
38
  await handleSubscriptionDeleted(event.data.object, locals);
77
39
  break;
78
40
  `;
79
- function w(e) {
80
- if (!h.existsSync(e)) return {
41
+ function y(e) {
42
+ if (!m.existsSync(e)) return {
81
43
  status: "not-found",
82
- message: S
44
+ message: _
83
45
  };
84
- let t = h.readFileSync(e, "utf8");
46
+ let t = m.readFileSync(e, "utf8");
85
47
  if (t.includes("handleSubscriptionCreated")) return {
86
48
  status: "success",
87
49
  changed: !1
88
50
  };
89
- let n = !1, { source: r } = d(t, (e) => {
90
- p(e, [
51
+ let n = !1, { source: r } = u(t, (e) => {
52
+ f(e, [
91
53
  {
92
54
  namedImports: ["handleSubscriptionCreated"],
93
- moduleSpecifier: "./handlers/subscription/created"
55
+ moduleSpecifier: "./subscription/created"
94
56
  },
95
57
  {
96
58
  namedImports: ["handleSubscriptionUpdated"],
97
- moduleSpecifier: "./handlers/subscription/updated"
59
+ moduleSpecifier: "./subscription/updated"
98
60
  },
99
61
  {
100
62
  namedImports: ["handleSubscriptionDeleted"],
101
- moduleSpecifier: "./handlers/subscription/deleted"
63
+ moduleSpecifier: "./subscription/deleted"
102
64
  }
103
65
  ]);
104
- let t = e.getDescendantsOfKind(g.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
66
+ let t = e.getDescendantsOfKind(h.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
105
67
  if (!t) return;
106
- let r = t.getCaseBlock().getClauses(), i = r.find((e) => e.getKind() === g.DefaultClause), a = `${C}\n\n`;
68
+ let r = t.getCaseBlock().getClauses(), i = r.find((e) => e.getKind() === h.DefaultClause), a = `${v}\n\n`;
107
69
  if (i) i.replaceWithText(a + i.getText());
108
70
  else if (r.length > 0) {
109
71
  let e = r[r.length - 1];
110
- e.replaceWithText(e.getText() + `\n\n${C}`);
72
+ e.replaceWithText(e.getText() + `\n\n${v}`);
111
73
  } else return;
112
74
  e.formatText(), n = !0;
113
75
  });
114
- return n ? (h.writeFileSync(e, r, "utf8"), {
76
+ return n ? (m.writeFileSync(e, r, "utf8"), {
115
77
  status: "success",
116
78
  changed: !0
117
79
  }) : {
118
80
  status: "failed",
119
- message: x
81
+ message: g
120
82
  };
121
83
  }
122
84
  //#endregion
123
85
  //#region src/patterns/enable/subscriptions/modifies/modify-by-template.ts
124
- function T(e, t, n, r) {
125
- if (!h.existsSync(e)) return {
86
+ function b(e, t, n, r) {
87
+ if (!m.existsSync(e)) return {
126
88
  status: "not-found",
127
89
  message: r
128
90
  };
129
- let i = h.readFileSync(e, "utf8");
91
+ let i = m.readFileSync(e, "utf8");
130
92
  if (i.includes(n)) return {
131
93
  status: "success",
132
94
  changed: !1
@@ -135,30 +97,30 @@ function T(e, t, n, r) {
135
97
  return i === a ? {
136
98
  status: "success",
137
99
  changed: !1
138
- } : (h.writeFileSync(e, a, "utf8"), {
100
+ } : (m.writeFileSync(e, a, "utf8"), {
139
101
  status: "success",
140
102
  changed: !0
141
103
  });
142
104
  }
143
105
  //#endregion
144
106
  //#region src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts
145
- var E = ["Create src/routes/(app)/+layout.server.ts before enabling subscriptions.", "Enable auth first — the (app) layout is provided by the velastack-auth baseline."].join("\n");
146
- function D(e, t) {
147
- return T(e, t, "loadActiveSubscription", E);
107
+ var x = ["Create src/routes/(app)/+layout.server.ts before enabling subscriptions.", "Enable auth first — the (app) layout is provided by the velastack-auth baseline."].join("\n");
108
+ function S(e, t) {
109
+ return b(e, t, "loadActiveSubscription", x);
148
110
  }
149
111
  //#endregion
150
112
  //#region src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts
151
- var O = [
113
+ var C = [
152
114
  "Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:",
153
115
  "",
154
116
  "<AppSidebar user={data.user} meta={data.meta} subscription={data.subscription} />"
155
- ].join("\n"), k = ["Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop."].join("\n");
156
- function A(e) {
157
- if (!h.existsSync(e)) return {
117
+ ].join("\n"), w = ["Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop."].join("\n");
118
+ function T(e) {
119
+ if (!m.existsSync(e)) return {
158
120
  status: "not-found",
159
- message: k
121
+ message: w
160
122
  };
161
- let t = f.fromPath(e);
123
+ let t = d.fromPath(e);
162
124
  return t.hasElement("AppSidebar") ? t.hasAttribute("AppSidebar", "subscription") ? {
163
125
  status: "success",
164
126
  changed: !1
@@ -167,38 +129,38 @@ function A(e) {
167
129
  changed: t.hasChanged()
168
130
  }) : {
169
131
  status: "failed",
170
- message: O
132
+ message: C
171
133
  } : {
172
134
  status: "failed",
173
- message: O
135
+ message: C
174
136
  };
175
137
  }
176
138
  //#endregion
177
139
  //#region src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts
178
- var j = "{ id: string; productName: string | null } | null", M = [
140
+ var E = "{ id: string; productName: string | null } | null", D = [
179
141
  "Update src/lib/components/app-sidebar.svelte to forward a subscription prop:",
180
142
  "",
181
143
  "1. Add `subscription = null` to the destructured $props() call.",
182
- `2. Add \`subscription?: ${j}\` to the props type.`,
144
+ `2. Add \`subscription?: ${E}\` to the props type.`,
183
145
  "3. Pass `{subscription}` to <NavUser>."
184
- ].join("\n"), N = ["Create src/lib/components/app-sidebar.svelte before enabling subscriptions."].join("\n");
185
- function P(e) {
186
- let t = !1, { source: n } = d(e, (e) => {
146
+ ].join("\n"), O = ["Create src/lib/components/app-sidebar.svelte before enabling subscriptions."].join("\n");
147
+ function k(e) {
148
+ let t = !1, { source: n } = u(e, (e) => {
187
149
  for (let n of e.getVariableDeclarations()) {
188
150
  let e = n.getInitializer();
189
151
  if (!e || e.getText() !== "$props()") continue;
190
152
  let r = n.getNameNode();
191
- if (r.getKind() !== g.ObjectBindingPattern) continue;
192
- let i = r.asKindOrThrow(g.ObjectBindingPattern), a = i.getElements();
153
+ if (r.getKind() !== h.ObjectBindingPattern) continue;
154
+ let i = r.asKindOrThrow(h.ObjectBindingPattern), a = i.getElements();
193
155
  if (a.some((e) => e.getName() === "subscription")) return;
194
156
  let o = n.getTypeNode();
195
- if (o?.getKind() === g.IntersectionType) {
196
- let e = o.asKindOrThrow(g.IntersectionType);
157
+ if (o?.getKind() === h.IntersectionType) {
158
+ let e = o.asKindOrThrow(h.IntersectionType);
197
159
  for (let t of e.getTypeNodes()) {
198
- if (t.getKind() !== g.TypeLiteral) continue;
199
- let e = t.asKindOrThrow(g.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, ""));
160
+ if (t.getKind() !== h.TypeLiteral) continue;
161
+ let e = t.asKindOrThrow(h.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, ""));
200
162
  if (!n.some((e) => /^\s*subscription\??\s*:/.test(e))) {
201
- n.push(`subscription?: ${j}`), e.replaceWithText(`{ ${n.join("; ")}; }`);
163
+ n.push(`subscription?: ${E}`), e.replaceWithText(`{ ${n.join("; ")}; }`);
202
164
  break;
203
165
  }
204
166
  }
@@ -213,25 +175,25 @@ function P(e) {
213
175
  wasAdded: t
214
176
  };
215
177
  }
216
- function F(e) {
217
- if (!h.existsSync(e)) return {
178
+ function A(e) {
179
+ if (!m.existsSync(e)) return {
218
180
  status: "not-found",
219
- message: N
181
+ message: O
220
182
  };
221
- let t = h.readFileSync(e, "utf8");
183
+ let t = m.readFileSync(e, "utf8");
222
184
  if (t.includes("subscription?: {") || t.includes("subscription={subscription}") || t.includes("{subscription}")) return {
223
185
  status: "success",
224
186
  changed: !1
225
187
  };
226
- let n = new f(t);
188
+ let n = new d(t);
227
189
  if (!n.hasElement("NavUser")) return {
228
190
  status: "failed",
229
- message: M
191
+ message: D
230
192
  };
231
- let r = n.modifyScript((e) => P(e).source), i = !n.hasAttribute("NavUser", "subscription") && n.appendToAttributes("NavUser", " {subscription}");
193
+ let r = n.modifyScript((e) => k(e).source), i = !n.hasAttribute("NavUser", "subscription") && n.appendToAttributes("NavUser", " {subscription}");
232
194
  return !r && !i ? {
233
195
  status: "failed",
234
- message: M
196
+ message: D
235
197
  } : (n.writeTo(e), {
236
198
  status: "success",
237
199
  changed: n.hasChanged()
@@ -239,60 +201,57 @@ function F(e) {
239
201
  }
240
202
  //#endregion
241
203
  //#region src/patterns/enable/subscriptions/modifies/modify-nav-user.ts
242
- var I = ["src/lib/components/nav-user.svelte is missing.", "Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user."].join("\n");
243
- function L(e, t) {
244
- return T(e, t, "planLabel", I);
204
+ var j = ["src/lib/components/nav-user.svelte is missing.", "Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user."].join("\n");
205
+ function M(e, t) {
206
+ return b(e, t, "planLabel", j);
245
207
  }
246
208
  //#endregion
247
209
  //#region src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts
248
- var R = ["src/routes/(app)/billing/+page.server.ts is missing.", "Enable payments first — subscriptions extends the billing page with plan management."].join("\n");
249
- function z(e, t) {
250
- return T(e, t, "selectPlan", R);
210
+ var N = ["src/routes/(app)/billing/+page.server.ts is missing.", "Enable payments first — subscriptions extends the billing page with plan management."].join("\n");
211
+ function P(e, t) {
212
+ return b(e, t, "selectPlan", N);
251
213
  }
252
214
  //#endregion
253
215
  //#region src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts
254
- var B = ["src/routes/(app)/billing/+page.svelte is missing.", "Enable payments first — subscriptions extends the billing page with plan management."].join("\n");
255
- function V(e, t) {
256
- return T(e, t, "availablePlans", B);
216
+ var F = ["src/routes/(app)/billing/+page.svelte is missing.", "Enable payments first — subscriptions extends the billing page with plan management."].join("\n");
217
+ function I(e, t) {
218
+ return b(e, t, "availablePlans", F);
257
219
  }
258
220
  //#endregion
259
221
  //#region src/patterns/enable/subscriptions/generate.runtime.ts
260
- var H = /* #__PURE__ */ Object.assign({
261
- "./preview-modifies/data/hooks/stripe.pb.js": r,
262
- "./preview-modifies/src/lib/components/app-sidebar.svelte": c,
263
- "./preview-modifies/src/lib/components/nav-user.svelte": o,
222
+ var L = /* #__PURE__ */ Object.assign({
223
+ "./preview-modifies/src/lib/components/app-sidebar.svelte": s,
224
+ "./preview-modifies/src/lib/components/nav-user.svelte": a,
264
225
  "./preview-modifies/src/routes/(app)/+layout.server.ts": n,
265
- "./preview-modifies/src/routes/(app)/+layout.svelte": i,
266
- "./preview-modifies/src/routes/(app)/billing/+page.server.ts": s,
267
- "./preview-modifies/src/routes/(app)/billing/+page.svelte": a,
268
- "./preview-modifies/src/routes/webhooks/stripe/+server.ts": l
226
+ "./preview-modifies/src/routes/(app)/+layout.svelte": r,
227
+ "./preview-modifies/src/routes/(app)/billing/+page.server.ts": o,
228
+ "./preview-modifies/src/routes/(app)/billing/+page.svelte": i,
229
+ "./preview-modifies/src/routes/webhooks/stripe/handlers/dispatch.ts": c
269
230
  });
270
- function U(e) {
271
- let t = H[`./preview-modifies/${e}`];
231
+ function R(e) {
232
+ let t = L[`./preview-modifies/${e}`];
272
233
  if (t === void 0) throw Error(`Missing template for ${e} in subscriptions preview-modifies`);
273
234
  return t;
274
235
  }
275
- async function W(e) {
236
+ async function z(e) {
276
237
  let n = t(e), r = [], i = (e) => {
277
238
  e && r.push(e);
278
239
  };
279
- n.info("Modifying data/hooks/stripe.pb.js");
280
- let a = m.join(e.root, "data", "hooks", "stripe.pb.js");
281
- i(u(a, b(a))), n.info("Modifying webhooks/stripe/+server.ts");
282
- let o = m.join(e.root, "src", "routes", "webhooks", "stripe", "+server.ts");
283
- i(u(o, w(o))), n.info("Modifying (app)/+layout.server.ts");
284
- let s = m.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
285
- i(u(s, D(s, U("src/routes/(app)/+layout.server.ts")))), n.info("Modifying (app)/+layout.svelte");
286
- let c = m.join(e.root, "src", "routes", "(app)", "+layout.svelte");
287
- i(u(c, A(c))), n.info("Modifying app-sidebar.svelte");
288
- let l = m.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
289
- i(u(l, F(l))), n.info("Modifying nav-user.svelte");
290
- let d = m.join(e.root, "src", "lib", "components", "nav-user.svelte");
291
- i(u(d, L(d, U("src/lib/components/nav-user.svelte")))), n.info("Modifying billing/+page.server.ts");
292
- let f = m.join(e.root, "src", "routes", "(app)", "billing", "+page.server.ts");
293
- i(u(f, z(f, U("src/routes/(app)/billing/+page.server.ts")))), n.info("Modifying billing/+page.svelte");
294
- let p = m.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
295
- return i(u(p, V(p, U("src/routes/(app)/billing/+page.svelte")))), {
240
+ n.info("Modifying webhooks/stripe/handlers/dispatch.ts");
241
+ let a = p.join(e.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
242
+ i(l(a, y(a))), n.info("Modifying (app)/+layout.server.ts");
243
+ let o = p.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
244
+ i(l(o, S(o, R("src/routes/(app)/+layout.server.ts")))), n.info("Modifying (app)/+layout.svelte");
245
+ let s = p.join(e.root, "src", "routes", "(app)", "+layout.svelte");
246
+ i(l(s, T(s))), n.info("Modifying app-sidebar.svelte");
247
+ let c = p.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
248
+ i(l(c, A(c))), n.info("Modifying nav-user.svelte");
249
+ let u = p.join(e.root, "src", "lib", "components", "nav-user.svelte");
250
+ i(l(u, M(u, R("src/lib/components/nav-user.svelte")))), n.info("Modifying billing/+page.server.ts");
251
+ let d = p.join(e.root, "src", "routes", "(app)", "billing", "+page.server.ts");
252
+ i(l(d, P(d, R("src/routes/(app)/billing/+page.server.ts")))), n.info("Modifying billing/+page.svelte");
253
+ let f = p.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
254
+ return i(l(f, I(f, R("src/routes/(app)/billing/+page.svelte")))), {
296
255
  creates: [],
297
256
  modifies: r,
298
257
  deletes: [],
@@ -304,6 +263,6 @@ async function W(e) {
304
263
  };
305
264
  }
306
265
  //#endregion
307
- export { W as generate };
266
+ export { z as generate };
308
267
 
309
- //# sourceMappingURL=generate.runtime-BlQ1vx8j.js.map
268
+ //# sourceMappingURL=generate.runtime-g9dvfgwT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-g9dvfgwT.js","names":[],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-by-template.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/enable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/enable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wire the subscription event handlers into src/routes/webhooks/stripe/handlers/dispatch.ts:\n\n Add imports:\n import { handleSubscriptionCreated } from \"./subscription/created\";\n import { handleSubscriptionUpdated } from \"./subscription/updated\";\n import { handleSubscriptionDeleted } from \"./subscription/deleted\";\n\n Add switch cases inside the event.type switch:\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nconst NOT_FOUND_HINT =\n \"Enable payments first — src/routes/webhooks/stripe/handlers/dispatch.ts is created by enable-payments.\";\n\nconst SUBSCRIPTION_CASES_SNIPPET = dedent`\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nexport function modifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n let addedCases = false;\n const { source } = withInMemoryScript(original, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"handleSubscriptionCreated\"],\n moduleSpecifier: \"./subscription/created\",\n },\n {\n namedImports: [\"handleSubscriptionUpdated\"],\n moduleSpecifier: \"./subscription/updated\",\n },\n {\n namedImports: [\"handleSubscriptionDeleted\"],\n moduleSpecifier: \"./subscription/deleted\",\n },\n ]);\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n const clauses = caseBlock.getClauses();\n const defaultClause = clauses.find(\n (c) => c.getKind() === SyntaxKind.DefaultClause,\n );\n\n // Prepend subscription cases in front of the default clause, or append\n // before the closing brace of the case block if there's no default.\n const prefix = `${SUBSCRIPTION_CASES_SNIPPET}\\n\\n`;\n if (defaultClause) {\n defaultClause.replaceWithText(prefix + defaultClause.getText());\n } else if (clauses.length > 0) {\n const last = clauses[clauses.length - 1];\n last.replaceWithText(\n last.getText() + `\\n\\n${SUBSCRIPTION_CASES_SNIPPET}`,\n );\n } else {\n return;\n }\n\n sf.formatText();\n addedCases = true;\n });\n\n if (!addedCases) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Overwrites a file with the given template content, guarded by an idempotency\n * marker: if the current file already contains the marker, the modify is a\n * no-op. Used for complex rewrites where surgical AST changes aren't worth it\n * (e.g. pages that are largely replaced).\n *\n * Strips leading `// [!code highlight:N]` and `<!-- [!code highlight:N] -->`\n * lines so the same content can be shared with preview-modifies, which uses\n * those comments for documentation highlighting.\n */\nexport function modifyByTemplate(\n filePath: string,\n template: string,\n idempotencyMarker: string,\n notFoundHint: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: notFoundHint };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(idempotencyMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\",\n \"Enable auth first — the (app) layout is provided by the velastack-auth baseline.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(\n filePath,\n template,\n \"loadActiveSubscription\",\n NOT_FOUND_HINT,\n );\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\",\n \"\",\n \"<AppSidebar user={data.user} meta={data.meta} subscription={data.subscription} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const appended = file.appendToAttributes(\n \"AppSidebar\",\n \" subscription={data.subscription}\",\n );\n if (!appended) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\n\nconst FAILURE_HINT = [\n \"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:\",\n \"\",\n \"1. Add `subscription = null` to the destructured $props() call.\",\n `2. Add \\`subscription?: ${SUBSCRIPTION_TYPE}\\` to the props type.`,\n \"3. Pass `{subscription}` to <NavUser>.\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/lib/components/app-sidebar.svelte before enabling subscriptions.\",\n].join(\"\\n\");\n\nfunction updateScript(source: string): {\n source: string;\n wasAdded: boolean;\n} {\n let wasAdded = false;\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n if (elements.some((e) => e.getName() === \"subscription\")) {\n // Already has subscription prop — no-op.\n return;\n }\n\n // Insert subscription?: ... into the props type literal if present.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^\\s*subscription\\??\\s*:/.test(t))) {\n continue;\n }\n propTexts.push(`subscription?: ${SUBSCRIPTION_TYPE}`);\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Insert `subscription = null` before the first rest/default-only element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elementTexts.length;\n elementTexts.splice(insertIdx, 0, \"subscription = null\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n wasAdded = true;\n }\n sf.formatText();\n });\n return { source: out, wasAdded };\n}\n\nexport function modifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (\n original.includes(\"subscription?: {\") ||\n original.includes(\"subscription={subscription}\") ||\n original.includes(\"{subscription}\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n if (!file.hasElement(\"NavUser\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const scriptChanged = file.modifyScript((src) => updateScript(src).source);\n\n const templateChanged = !file.hasAttribute(\"NavUser\", \"subscription\")\n ? file.appendToAttributes(\"NavUser\", \" {subscription}\")\n : false;\n\n if (!scriptChanged && !templateChanged) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/lib/components/nav-user.svelte is missing.\",\n \"Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user.\",\n].join(\"\\n\");\n\nexport function modifyNavUser(\n filePath: string,\n template: string,\n): ModifyOutcome {\n // `planLabel` is unique to subscriptions — safe idempotency marker.\n return modifyByTemplate(filePath, template, \"planLabel\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.server.ts is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"selectPlan\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.svelte is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageSvelte(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"availablePlans\", NOT_FOUND_HINT);\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 { modifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { modifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { modifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Share the final-state files between preview (rendered as-is) and runtime\n// (used as overwrite templates for modifies that amount to full rewrites).\nconst previewRaw = import.meta.glob<string>(\"./preview-modifies/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nfunction template(relativePath: string): string {\n const key = `./preview-modifies/${relativePath}`;\n const content = previewRaw[key];\n if (content === undefined) {\n throw new Error(\n `Missing template for ${relativePath} in subscriptions preview-modifies`,\n );\n }\n return content;\n}\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(\"Modifying webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n modifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Modifying (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 modifyAppLayoutServer(\n appLayoutServerPath,\n template(\"src/routes/(app)/+layout.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n modifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Modifying app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n modifyNavUser(\n navUserPath,\n template(\"src/lib/components/nav-user.svelte\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n modifyBillingPageServer(\n billingPageServerPath,\n template(\"src/routes/(app)/billing/+page.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n modifyBillingPageSvelte(\n billingPageSveltePath,\n template(\"src/routes/(app)/billing/+page.svelte\"),\n ),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AASA,IAAM,IAAe,CAAM;;;;;;;;;;;;;;;;;;GAoBrB,IACJ,0GAEI,IAA6B,CAAM;;;;;;;;;;;;;AAczC,SAAgB,EAAoB,GAAiC;CACnE,IAAI,CAAC,EAAG,WAAW,CAAQ,GACzB,OAAO;EAAE,QAAQ;EAAa,SAAS;CAAe;CAGxD,IAAM,IAAW,EAAG,aAAa,GAAU,MAAM;CACjD,IAAI,EAAS,SAAS,2BAA2B,GAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAI,IAAa,IACX,EAAE,cAAW,EAAmB,IAAW,MAAO;EACtD,EAAc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iB,CAAC;CACpB;AACF"}
@@ -0,0 +1,6 @@
1
+ //#region src/patterns/enable/payments/creates-app-mode/src/routes/(app)/billing/+page.server.ts?raw
2
+ var e = "import { error } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\n\nexport const load = async ({ locals, depends, parent }) => {\n const { user } = await parent();\n depends(\"app:billing\");\n\n let customer;\n try {\n customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n locals.admin.filter(\"user = {:user}\", { user: user.id }),\n );\n } catch {\n // The link-stripe-customer workflow started at signup has not finished.\n return { paymentMethods: [], user, billingReady: false };\n }\n\n const stripeCustomer = await stripe.customers.retrieve(customer.id);\n if (stripeCustomer.deleted) {\n return error(400, \"Customer not found\");\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(\n customer.id,\n {\n type: \"card\",\n allow_redisplay: \"always\",\n },\n );\n\n return {\n billingReady: true,\n paymentMethods: paymentMethods.data.map((pm) => ({\n id: pm.id,\n brand: pm.card!.brand,\n last4: pm.card!.last4,\n expMonth: pm.card!.exp_month,\n expYear: pm.card!.exp_year,\n isDefault: pm.id === customer.default_payment_method,\n })),\n user,\n };\n};\n\nexport const actions = {\n setDefaultPaymentMethod: async ({ locals, request }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\") as string;\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(`user.id = \"${locals.pb.authStore.record?.id}\"`);\n\n if (!customer || !customer.id) {\n return error(400, \"Customer not found\");\n }\n\n await stripe.customers.update(customer.id, {\n invoice_settings: {\n default_payment_method: paymentMethodId,\n },\n });\n\n await locals.admin.collection(\"stripe_customers\").update(customer.id, {\n default_payment_method: paymentMethodId,\n });\n },\n deletePaymentMethod: async ({ locals, request }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\") as string;\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(`user.id = \"${locals.pb.authStore.record?.id}\"`);\n\n const defaultPaymentMethod = customer.default_payment_method;\n\n await stripe.paymentMethods.detach(paymentMethodId);\n\n // If default payment method was deleted, update default payment method\n if (defaultPaymentMethod === paymentMethodId) {\n const paymentMethods = await stripe.paymentMethods.list({\n customer: customer.id,\n });\n\n if (paymentMethods.data.length > 0) {\n const defaultPaymentMethod = paymentMethods.data[0];\n\n await stripe.customers.update(customer.id, {\n invoice_settings: {\n default_payment_method: defaultPaymentMethod.id,\n },\n });\n\n await locals.admin.collection(\"stripe_customers\").update(customer.id, {\n default_payment_method: defaultPaymentMethod.id,\n });\n } else {\n await locals.admin.collection(\"stripe_customers\").update(customer.id, {\n default_payment_method: null,\n });\n }\n }\n },\n};\n", t = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n import { Badge } from '$lib/components/ui/badge';\n import * as AlertDialog from '$lib/components/ui/alert-dialog';\n import SetupButton from '$lib/components/payments/setup-button.svelte';\n import { CreditCard, Trash2, Check } from '@lucide/svelte';\n import { toast } from 'svelte-sonner';\n import { invalidate } from '$app/navigation';\n\n let { data } = $props();\n let paymentMethods = $derived(data.paymentMethods);\n let showDeleteDialog = $state(false);\n let selectedPaymentMethodId = $state<string | null>(null);\n let isProcessing = $state(false);\n\n function openDeleteDialog(paymentMethodId: string) {\n selectedPaymentMethodId = paymentMethodId;\n showDeleteDialog = true;\n }\n\n function closeDeleteDialog() {\n showDeleteDialog = false;\n selectedPaymentMethodId = null;\n }\n\n async function handleDeletePaymentMethod() {\n if (!selectedPaymentMethodId) return;\n isProcessing = true;\n\n try {\n const formData = new FormData();\n formData.append('paymentMethodId', selectedPaymentMethodId);\n\n await fetch('?/deletePaymentMethod', {\n method: 'POST',\n body: formData\n });\n\n await invalidate('app:billing');\n toast.success('Payment method removed successfully');\n closeDeleteDialog();\n } catch (err) {\n console.error('Error deleting payment method:', err);\n toast.error('Failed to remove payment method');\n } finally {\n isProcessing = false;\n }\n }\n\n async function setDefaultPaymentMethod(paymentMethodId: string) {\n try {\n const formData = new FormData();\n formData.append('paymentMethodId', paymentMethodId);\n\n await fetch('?/setDefaultPaymentMethod', {\n method: 'POST',\n body: formData\n });\n\n await invalidate('app:billing');\n toast.success('Default payment method updated');\n } catch (err) {\n console.error('Error setting default payment method:', err);\n toast.error('Failed to update default payment method');\n }\n }\n\n function getCardBrandIcon(brand: string) {\n // You can customize these icons or use actual card brand icons\n const brands: Record<string, string> = {\n visa: '💳',\n mastercard: '💳',\n amex: '💳',\n discover: '💳',\n unknown: '💳'\n };\n return brands[brand.toLowerCase()] || brands.unknown;\n }\n\n function formatCardBrand(brand: string) {\n return brand.charAt(0).toUpperCase() + brand.slice(1);\n }\n<\/script>\n\n<div class=\"divide-y divide-gray-900/10 dark:divide-white/10\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-gray-900 dark:text-white\">Payment Methods</h2>\n <p class=\"mt-1 text-sm/6 text-gray-600 dark:text-gray-400\">\n Manage your payment methods for subscriptions and purchases.\n </p>\n </div>\n\n <div class=\"md:col-span-2\">\n <Card.Root>\n <Card.Content>\n {#if !data.billingReady}\n <div\n class=\"text-muted-foreground flex flex-col items-center justify-center py-12 text-center\"\n >\n <CreditCard class=\"mb-4 size-12 opacity-50\" />\n <p class=\"mb-2 text-lg font-medium\">Setting up billing</p>\n <p class=\"text-sm\">This takes a moment after signing up. Refresh to check again.</p>\n </div>\n {:else if paymentMethods.length === 0}\n <div\n class=\"text-muted-foreground flex flex-col items-center justify-center py-12 text-center\"\n >\n <CreditCard class=\"mb-4 size-12 opacity-50\" />\n <p class=\"mb-2 text-lg font-medium\">No payment methods</p>\n <p class=\"text-sm\">Add a payment method to get started</p>\n </div>\n {:else}\n <div class=\"space-y-4\">\n {#each paymentMethods as method (method.id)}\n <div\n class=\"border-border hover:bg-accent/50 flex items-center justify-between rounded-lg border p-4 transition-colors\"\n >\n <div class=\"flex items-center gap-4\">\n <div\n class=\"bg-muted flex size-12 items-center justify-center rounded-lg text-2xl\"\n >\n {getCardBrandIcon(method.brand)}\n </div>\n <div>\n <div class=\"flex items-center gap-2\">\n <p class=\"font-medium\">\n {formatCardBrand(method.brand)} •••• {method.last4}\n </p>\n {#if method.isDefault}\n <Badge variant=\"secondary\">\n <Check class=\"mr-1 size-3\" />\n Default\n </Badge>\n {/if}\n </div>\n <p class=\"text-muted-foreground text-sm\">\n Expires {method.expMonth.toString().padStart(2, '0')}/{method.expYear}\n </p>\n </div>\n </div>\n <div class=\"flex items-center gap-2\">\n {#if !method.isDefault}\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => setDefaultPaymentMethod(method.id)}\n >\n Set as Default\n </Button>\n {/if}\n <Button\n variant=\"outline\"\n size=\"icon-sm\"\n onclick={() => openDeleteDialog(method.id)}\n disabled={method.isDefault && paymentMethods.length === 1}\n >\n <Trash2 class=\"size-4\" />\n </Button>\n </div>\n </div>\n {/each}\n </div>\n {/if}\n </Card.Content>\n {#if data.billingReady}\n <Card.Footer class=\"border-t justify-end\">\n <SetupButton\n label=\"Add Payment Method\"\n processingLabel=\"Adding...\"\n onsuccess={() => invalidate('app:billing')}\n />\n </Card.Footer>\n {/if}\n </Card.Root>\n </div>\n </div>\n</div>\n\n<!-- Delete Confirmation Dialog -->\n<AlertDialog.Root bind:open={showDeleteDialog}>\n <AlertDialog.Content>\n <AlertDialog.Header>\n <AlertDialog.Title>Remove Payment Method</AlertDialog.Title>\n <AlertDialog.Description>\n Are you sure you want to remove this payment method? This action cannot be undone.\n </AlertDialog.Description>\n </AlertDialog.Header>\n <AlertDialog.Footer>\n <AlertDialog.Cancel onclick={closeDeleteDialog}>Cancel</AlertDialog.Cancel>\n <AlertDialog.Action onclick={handleDeletePaymentMethod} disabled={isProcessing}>\n {isProcessing ? 'Removing...' : 'Remove'}\n </AlertDialog.Action>\n </AlertDialog.Footer>\n </AlertDialog.Content>\n</AlertDialog.Root>\n", n = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n // [!code highlight:1]\n import CreditCardIcon from '@lucide/svelte/icons/credit-card';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n\n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n },\n // [!code highlight:5]\n {\n title: 'Billing',\n url: '/billing',\n icon: CreditCardIcon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n";
3
+ //#endregion
4
+ export { t as n, e as r, n as t };
5
+
6
+ //# sourceMappingURL=nav-user-BYI-h8Od.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nav-user-BYI-h8Od.js","names":[],"sources":[],"mappings":""}
@@ -15,7 +15,7 @@ async function n(e, t) {
15
15
  exists: !0,
16
16
  rowCount: 0
17
17
  }));
18
- let { withPocketbase: n } = await import("./pocketbase-059B1oot.js"), { planCollectionDrops: r } = await import("./collections-B3lAtPlQ.js"), i = [];
18
+ let { withPocketbase: n } = await import("./pocketbase-059B1oot.js"), { planCollectionDrops: r } = await import("./collections-DeuRxasZ.js"), i = [];
19
19
  return await n(t.root, async (t) => {
20
20
  let n = await r(t, e);
21
21
  i.push(...n);
@@ -24,4 +24,4 @@ async function n(e, t) {
24
24
  //#endregion
25
25
  export { t as n, n as t };
26
26
 
27
- //# sourceMappingURL=shared--_BWnGsc.js.map
27
+ //# sourceMappingURL=shared-DXQcaNNX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared--_BWnGsc.js","names":[],"sources":["../../src/patterns/destroy/shared.ts"],"sourcesContent":["import type { CollectionDropSpec, File, Options } from \"../../core/types\";\nimport { languageFromPath } from \"../../core/util\";\n\nexport function toDeleteEntry(path: string): File {\n return {\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n };\n}\n\n/**\n * Build `CollectionDropSpec` entries for each collection name, with live row\n * counts from PocketBase when `env === \"runtime\"`. In preview mode, returns\n * `{ exists: true, rowCount: 0 }` placeholders.\n */\nexport async function planDropsForCollections(\n collectionNames: string[],\n options: Options,\n): Promise<CollectionDropSpec[]> {\n if (collectionNames.length === 0) return [];\n\n if (options.env !== \"runtime\") {\n return collectionNames.map((name) => ({\n name,\n exists: true,\n rowCount: 0,\n }));\n }\n\n const { withPocketbase } = await import(\"../../runtime/pocketbase\");\n const { planCollectionDrops } = await import(\"../../runtime/collections\");\n const drops: CollectionDropSpec[] = [];\n await withPocketbase(options.root, async (pb) => {\n const plans = await planCollectionDrops(pb, collectionNames);\n drops.push(...plans);\n });\n return drops;\n}\n"],"mappings":";;AAGA,SAAgB,EAAc,GAAoB;CAChD,OAAO;EACL;EACA,UAAU,EAAiB,CAAI;EAC/B,SAAS;EACT,QAAQ;CACV;AACF;AAOA,eAAsB,EACpB,GACA,GAC+B;CAC/B,IAAI,EAAgB,WAAW,GAAG,OAAO,CAAC;CAE1C,IAAI,EAAQ,QAAQ,WAClB,OAAO,EAAgB,KAAK,OAAU;EACpC;EACA,QAAQ;EACR,UAAU;CACZ,EAAE;CAGJ,IAAM,EAAE,sBAAmB,MAAM,OAAO,6BAClC,EAAE,2BAAwB,MAAM,OAAO,8BACvC,IAA8B,CAAC;CAKrC,OAJA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAM,IAAQ,MAAM,EAAoB,GAAI,CAAe;EAC3D,EAAM,KAAK,GAAG,CAAK;CACrB,CAAC,GACM;AACT"}
1
+ {"version":3,"file":"shared-DXQcaNNX.js","names":[],"sources":["../../src/patterns/destroy/shared.ts"],"sourcesContent":["import type { CollectionDropSpec, File, Options } from \"../../core/types\";\nimport { languageFromPath } from \"../../core/util\";\n\nexport function toDeleteEntry(path: string): File {\n return {\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n };\n}\n\n/**\n * Build `CollectionDropSpec` entries for each collection name, with live row\n * counts from PocketBase when `env === \"runtime\"`. In preview mode, returns\n * `{ exists: true, rowCount: 0 }` placeholders.\n */\nexport async function planDropsForCollections(\n collectionNames: string[],\n options: Options,\n): Promise<CollectionDropSpec[]> {\n if (collectionNames.length === 0) return [];\n\n if (options.env !== \"runtime\") {\n return collectionNames.map((name) => ({\n name,\n exists: true,\n rowCount: 0,\n }));\n }\n\n const { withPocketbase } = await import(\"../../runtime/pocketbase\");\n const { planCollectionDrops } = await import(\"../../runtime/collections\");\n const drops: CollectionDropSpec[] = [];\n await withPocketbase(options.root, async (pb) => {\n const plans = await planCollectionDrops(pb, collectionNames);\n drops.push(...plans);\n });\n return drops;\n}\n"],"mappings":";;AAGA,SAAgB,EAAc,GAAoB;CAChD,OAAO;EACL;EACA,UAAU,EAAiB,CAAI;EAC/B,SAAS;EACT,QAAQ;CACV;AACF;AAOA,eAAsB,EACpB,GACA,GAC+B;CAC/B,IAAI,EAAgB,WAAW,GAAG,OAAO,CAAC;CAE1C,IAAI,EAAQ,QAAQ,WAClB,OAAO,EAAgB,KAAK,OAAU;EACpC;EACA,QAAQ;EACR,UAAU;CACZ,EAAE;CAGJ,IAAM,EAAE,sBAAmB,MAAM,OAAO,6BAClC,EAAE,2BAAwB,MAAM,OAAO,8BACvC,IAA8B,CAAC;CAKrC,OAJA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAM,IAAQ,MAAM,EAAoB,GAAI,CAAe;EAC3D,EAAM,KAAK,GAAG,CAAK;CACrB,CAAC,GACM;AACT"}
@@ -1,6 +1,6 @@
1
1
  import { n as e, t } from "./errors-D6gyegUK.js";
2
2
  import { n } from "./logger-CQONztPm.js";
3
- import { executeCommand as r, formatPaths as i, getAllCustomComponents as a, installComponents as o, installedComponents as s, installedPackagesFromProject as c, isCustomComponent as l, n as u, t as d } from "./write-result-BN7Ff0rF.js";
3
+ import { executeCommand as r, formatPaths as i, getAllCustomComponents as a, installComponents as o, installedComponents as s, installedPackagesFromProject as c, isCustomComponent as l, n as u, t as d } from "./write-result-CB5oDtjf.js";
4
4
  import f from "node:path";
5
5
  import { existsSync as p, readFileSync as m, writeFileSync as h } from "node:fs";
6
6
  import { createRequire as g } from "node:module";
@@ -170,4 +170,4 @@ async function N(e, t) {
170
170
  //#endregion
171
171
  export { M as applyBaseColor, N as applyTheme, C as listComponents, D as switchStyle };
172
172
 
173
- //# sourceMappingURL=ui-BsG60gQg.js.map
173
+ //# sourceMappingURL=ui-B2pSrier.js.map