@velastack/patterns 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/chunks/_page-B6yd6_Vl.js +6 -0
  2. package/dist/chunks/_page-B6yd6_Vl.js.map +1 -0
  3. package/dist/chunks/{collections-BrEA7a62.js → collections-DZOuRpvS.js} +6 -1
  4. package/dist/chunks/collections-DZOuRpvS.js.map +1 -0
  5. package/dist/chunks/{generate-BZ741GPx.js → currency.server-Bb2Ndutg.js} +6 -3
  6. package/dist/chunks/{generate-BZ741GPx.js.map → currency.server-Bb2Ndutg.js.map} +1 -1
  7. package/dist/chunks/{generate-6JS05dWK.js → generate-B-cqjI-U.js} +62 -55
  8. package/dist/chunks/generate-B-cqjI-U.js.map +1 -0
  9. package/dist/chunks/generate-BrOPb9tW.js +175 -0
  10. package/dist/chunks/generate-BrOPb9tW.js.map +1 -0
  11. package/dist/chunks/{generate.runtime-BOl3LpPB.js → generate.runtime-BnqS_Zq8.js} +84 -158
  12. package/dist/chunks/generate.runtime-BnqS_Zq8.js.map +1 -0
  13. package/dist/chunks/{generate.runtime-KrQk7mqG.js → generate.runtime-DG9Lp3vR.js} +39 -37
  14. package/dist/chunks/generate.runtime-DG9Lp3vR.js.map +1 -0
  15. package/dist/chunks/generate.runtime-DuDcKDUl.js +162 -0
  16. package/dist/chunks/generate.runtime-DuDcKDUl.js.map +1 -0
  17. package/dist/chunks/{generate.runtime-Dt3Edp8-.js → generate.runtime-J2lLMjDn.js} +97 -126
  18. package/dist/chunks/generate.runtime-J2lLMjDn.js.map +1 -0
  19. package/dist/chunks/generate.runtime-nyJ6v56q.js +64 -0
  20. package/dist/chunks/generate.runtime-nyJ6v56q.js.map +1 -0
  21. package/dist/chunks/load-function-Dmkhg1pQ.js +79 -0
  22. package/dist/chunks/load-function-Dmkhg1pQ.js.map +1 -0
  23. package/dist/chunks/modify-nav-user-iUpv2lm-.js +53 -0
  24. package/dist/chunks/modify-nav-user-iUpv2lm-.js.map +1 -0
  25. package/dist/chunks/root-layout.svelte-CUVbnlX-.js +302 -0
  26. package/dist/chunks/root-layout.svelte-CUVbnlX-.js.map +1 -0
  27. package/dist/index.d.ts +156 -2
  28. package/dist/index.js +1972 -1807
  29. package/dist/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunks/collections-BrEA7a62.js.map +0 -1
  32. package/dist/chunks/generate-6JS05dWK.js.map +0 -1
  33. package/dist/chunks/generate.runtime-BOl3LpPB.js.map +0 -1
  34. package/dist/chunks/generate.runtime-Dt3Edp8-.js.map +0 -1
  35. package/dist/chunks/generate.runtime-KrQk7mqG.js.map +0 -1
  36. package/dist/chunks/root-layout.svelte-CsJ2QJYi.js +0 -93
  37. package/dist/chunks/root-layout.svelte-CsJ2QJYi.js.map +0 -1
@@ -1,32 +1,31 @@
1
1
  import { t as e } from "./errors-DR3gF_7a.js";
2
- import { a as t, o as n } from "./util-BLYliuUK.js";
3
- import { a as r, c as i, l as a } from "./providers-CL9kQ4hp.js";
4
- import { t as o } from "./dedent-Gq6Krl4n.js";
5
- import { t as s } from "./taggedTemplateLiteral-KSUnuvOk.js";
6
- import { n as c } from "./logger-CQONztPm.js";
7
- import { r as l, t as u } from "./generate-BZ741GPx.js";
8
- import { a as d, i as f, r as p } from "./collections-BrEA7a62.js";
9
- import { i as m, n as h, t as g } from "./pocketbase-BtN-wL8f.js";
10
- import { a as _, i as v, r as y, s as b, t as x } from "./site-VrqOvuiU.js";
11
- import { t as S } from "./env-BugddEjd.js";
12
- import { t as C } from "./ts-morph-helpers-CHI9wAil.js";
13
- import { r as w } from "./modify-file-B4uJzOEj.js";
14
- import { modifyEnvVarsFiles as T } from "./env-vars-0hvKe55u.js";
15
- import { t as E } from "./svelte-file-Dv5-bl79.js";
16
- import { t as D } from "./root-layout.svelte-CsJ2QJYi.js";
17
- import { n as O, t as k } from "./wuchale-config-c3Q4JVSF.js";
18
- import { t as A } from "./modify-user-signup-DLtopazD.js";
19
- import { i as j, r as M } from "./collections-BYcVyY9O.js";
20
- import N from "node:fs";
21
- import P from "node:path";
22
- import F from "stripe";
2
+ import { a as t, o as n, r } from "./util-BLYliuUK.js";
3
+ import { a as i, c as a, l as o } from "./providers-CL9kQ4hp.js";
4
+ import { t as s } from "./dedent-Gq6Krl4n.js";
5
+ import { t as c } from "./taggedTemplateLiteral-KSUnuvOk.js";
6
+ import { n as l } from "./logger-CQONztPm.js";
7
+ import { a as u, n as d, r as f, t as p } from "./currency.server-Bb2Ndutg.js";
8
+ import { a as m, i as h, r as g } from "./collections-DZOuRpvS.js";
9
+ import { i as _, n as v, t as y } from "./pocketbase-BtN-wL8f.js";
10
+ import { a as b, i as x, r as S, s as C, t as w } from "./site-VrqOvuiU.js";
11
+ import { t as T } from "./env-BugddEjd.js";
12
+ import { r as E } from "./modify-file-B4uJzOEj.js";
13
+ import { modifyEnvVarsFiles as D } from "./env-vars-0hvKe55u.js";
14
+ import { n as O } from "./modify-nav-user-iUpv2lm-.js";
15
+ import { a as k, r as A, s as j, t as M } from "./root-layout.svelte-CUVbnlX-.js";
16
+ import { n as N, t as P } from "./wuchale-config-c3Q4JVSF.js";
17
+ import { t as F } from "./modify-user-signup-DLtopazD.js";
18
+ import { i as I, r as L } from "./collections-BYcVyY9O.js";
19
+ import R from "node:fs";
20
+ import z from "node:path";
21
+ import B from "stripe";
23
22
  //#region src/patterns/enable/payments/runtime/setup-shopify.ts
24
- async function I(e) {
25
- let t = c(e), n = typeof e.input.demoId == "string" ? e.input.demoId.trim() : "", r = [];
23
+ async function V(e) {
24
+ let t = l(e), n = typeof e.input.demoId == "string" ? e.input.demoId.trim() : "", r = [];
26
25
  return n && (t.info("Creating payment +page.svelte"), r.push({
27
26
  path: "src/routes/(public)/payment/+page.svelte",
28
27
  language: "svelte",
29
- content: d(n),
28
+ content: m(n),
30
29
  status: "success"
31
30
  })), {
32
31
  creates: r,
@@ -40,56 +39,9 @@ async function I(e) {
40
39
  };
41
40
  }
42
41
  //#endregion
43
- //#region src/patterns/enable/payments/modifies/modify-nav-user.ts
44
- var L = [
45
- "import CreditCardIcon from '@lucide/svelte/icons/credit-card';",
46
- "",
47
- "// Add to your navUser array:",
48
- "{ title: 'Billing', url: '/billing', icon: CreditCardIcon }"
49
- ].join("\n"), R = [
50
- "Add a Billing nav item to nav-user.svelte:",
51
- "",
52
- L
53
- ].join("\n"), z = [
54
- "Create nav-user.svelte with a Billing entry:",
55
- "",
56
- L
57
- ].join("\n");
58
- function B(e, t, n, r, i) {
59
- let a = new E(e), o = !1, s = (e) => {
60
- o || e((e) => {
61
- let a = C(e, t, n, r, i);
62
- return a.wasAdded && (o = !0), a.source;
63
- });
64
- };
65
- return s((e) => a.modifyModuleScript(e)), o || s((e) => a.modifyScript(e)), {
66
- newNavUserSnippet: a.toString(),
67
- wasAdded: o
68
- };
69
- }
70
- function V(e) {
71
- if (!N.existsSync(e)) return {
72
- status: "not-found",
73
- message: z
74
- };
75
- let t = N.readFileSync(e, "utf8");
76
- if (t.includes("/billing")) return {
77
- status: "success",
78
- changed: !1
79
- };
80
- let { newNavUserSnippet: n, wasAdded: r } = B(t, "Billing", "/billing", "CreditCardIcon", "@lucide/svelte/icons/credit-card");
81
- return r ? (N.writeFileSync(e, n, "utf8"), {
82
- status: "success",
83
- changed: !0
84
- }) : {
85
- status: "failed",
86
- message: R
87
- };
88
- }
89
- //#endregion
90
42
  //#region src/patterns/enable/payments/runtime/stripe.ts
91
43
  async function H(e, t, n) {
92
- let r = new F(t), i = await e.collection("users").getFullList(), a = await e.collection("stripe_customers").getFullList(), o = new Set(a.map((e) => e.user)), s = {
44
+ let r = new B(t), i = await e.collection("users").getFullList(), a = await e.collection("stripe_customers").getFullList(), o = new Set(a.map((e) => e.user)), s = {
93
45
  total: i.length,
94
46
  linked: o.size,
95
47
  created: 0,
@@ -142,7 +94,7 @@ async function H(e, t, n) {
142
94
  return s;
143
95
  }
144
96
  async function U(e) {
145
- let t = new F(e), n = await t.products.search({
97
+ let t = new B(e), n = await t.products.search({
146
98
  query: "name:\"Test Product\" AND metadata[\"test\"]:\"true\"",
147
99
  limit: 1
148
100
  });
@@ -173,7 +125,7 @@ async function U(e) {
173
125
  };
174
126
  }
175
127
  async function W(e, t) {
176
- let n = new F(e), r = await n.prices.retrieve(t, { expand: ["product"] }), i = typeof r.product == "string" ? await n.products.retrieve(r.product) : r.product;
128
+ let n = new B(e), r = await n.prices.retrieve(t, { expand: ["product"] }), i = typeof r.product == "string" ? await n.products.retrieve(r.product) : r.product;
177
129
  return r.product = i.id, {
178
130
  product: i,
179
131
  price: r,
@@ -185,32 +137,32 @@ async function W(e, t) {
185
137
  var G;
186
138
  async function K(e, n, r, i, a = !0) {
187
139
  if (!a) return;
188
- await h();
189
- let o = g(n, r, i);
140
+ await v();
141
+ let o = y(n, r, i);
190
142
  o && e.push({
191
143
  path: o,
192
144
  language: t(o),
193
- content: N.readFileSync(o, "utf8"),
145
+ content: R.readFileSync(o, "utf8"),
194
146
  status: "success"
195
147
  });
196
148
  }
197
149
  function q(e) {
198
- return o(G ||= s(["\n <script lang=\"ts\">\n import PaymentButton from '#lib/components/payments/payment-button.svelte';\n <\/script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"", "\" />\n </section>\n "]), e);
150
+ return s(G ||= c(["\n <script lang=\"ts\">\n import PaymentButton from '#lib/components/payments/payment-button.svelte';\n <\/script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"", "\" />\n </section>\n "]), e);
199
151
  }
200
152
  async function J(e) {
201
- let t = a(e).STRIPE_SECRET_KEY ?? "", n = typeof e.input.demoId == "string" && e.input.demoId !== "" ? e.input.demoId : void 0, r = e.features.auth, i = c(e), o = [], s = [], l = (e) => {
153
+ let t = o(e).STRIPE_SECRET_KEY ?? "", n = typeof e.input.demoId == "string" && e.input.demoId !== "" ? e.input.demoId : void 0, r = e.features.auth, i = l(e), a = [], s = [], c = (e) => {
202
154
  e && s.push(e);
203
155
  };
204
- await m(e.root, async (n) => {
205
- let a = (e) => M(n, e, i);
206
- for (let t of [f, p]) {
156
+ await _(e.root, async (n) => {
157
+ let o = (e) => L(n, e, i);
158
+ for (let t of [h, g]) {
207
159
  i.info(`Creating ${t.name} collection`);
208
- let r = await a(t);
209
- await K(o, t.name, "created", e, r.created), r.created || o.push(...await j(n, t, e, i));
160
+ let r = await o(t);
161
+ await K(a, t.name, "created", e, r.created), r.created || a.push(...await I(n, t, e, i));
210
162
  }
211
163
  if (r) {
212
164
  i.info("Creating stripe_customers collection");
213
- let r = await a({
165
+ let r = await o({
214
166
  name: "stripe_customers",
215
167
  type: "base",
216
168
  fields: [
@@ -244,8 +196,8 @@ async function J(e) {
244
196
  }
245
197
  ]
246
198
  }), s = r.collection;
247
- await K(o, "stripe_customers", "created", e, r.created), i.info("Creating stripe_payment_methods collection");
248
- let c = await a({
199
+ await K(a, "stripe_customers", "created", e, r.created), i.info("Creating stripe_payment_methods collection");
200
+ let c = await o({
249
201
  name: "stripe_payment_methods",
250
202
  type: "base",
251
203
  fields: [
@@ -300,7 +252,7 @@ async function J(e) {
300
252
  }
301
253
  ]
302
254
  }), l = c.collection;
303
- await K(o, "stripe_payment_methods", "created", e, c.created), i.info("Linking default_payment_method on stripe_customers"), await n.collections.update("stripe_customers", { fields: [
255
+ await K(a, "stripe_payment_methods", "created", e, c.created), i.info("Linking default_payment_method on stripe_customers"), await n.collections.update("stripe_customers", { fields: [
304
256
  {
305
257
  name: "id",
306
258
  pattern: "^[a-zA-Z0-9_]+$",
@@ -337,8 +289,8 @@ async function J(e) {
337
289
  onUpdate: !0,
338
290
  type: "autodate"
339
291
  }
340
- ] }), await K(o, "stripe_customers", "updated", e), i.info("Creating transactions collection");
341
- let u = await a({
292
+ ] }), await K(a, "stripe_customers", "updated", e), i.info("Creating transactions collection");
293
+ let u = await o({
342
294
  name: "transactions",
343
295
  type: "base",
344
296
  fields: [
@@ -408,13 +360,13 @@ async function J(e) {
408
360
  }
409
361
  ]
410
362
  });
411
- await K(o, "transactions", "created", e, u.created), i.info("Syncing existing PocketBase users to Stripe customers");
363
+ await K(a, "transactions", "created", e, u.created), i.info("Syncing existing PocketBase users to Stripe customers");
412
364
  let d = await H(n, t, i);
413
365
  i.info(`Synced ${d.total} users (created ${d.created}, reused ${d.reused}, skipped ${d.skipped})`);
414
366
  }
415
367
  }), n ? i.info(`Fetching Stripe product/price ${n}`) : i.info("Creating test Stripe product and price");
416
- let { product: u, price: d, existing: h } = n ? await W(t, n) : await U(t);
417
- if (h && i.info("Stripe product/price already exists, skipping creation"), i.info("Seeding Stripe product/price records"), await m(e.root, async (e) => {
368
+ let { product: u, price: d, existing: f } = n ? await W(t, n) : await U(t);
369
+ if (f && i.info("Stripe product/price already exists, skipping creation"), i.info("Seeding Stripe product/price records"), await _(e.root, async (e) => {
418
370
  try {
419
371
  await e.collection("stripe_products").getOne(u.id);
420
372
  } catch {
@@ -439,20 +391,20 @@ async function J(e) {
439
391
  active: d.active
440
392
  });
441
393
  }
442
- }), i.info("Creating payment +page.svelte"), o.push({
394
+ }), i.info("Creating payment +page.svelte"), a.push({
443
395
  path: "src/routes/(public)/payment/+page.svelte",
444
396
  language: "svelte",
445
397
  content: q(d.id),
446
398
  status: "success"
447
399
  }), r) {
448
400
  i.info("Modifying nav-user.svelte");
449
- let t = P.join(e.root, "src", "lib", "components", "nav-user.svelte");
450
- l(w(t, V(t))), i.info("Modifying signup +page.server.ts");
451
- let n = P.join(e.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
452
- l(w(n, A(n)));
401
+ let t = z.join(e.root, "src", "lib", "components", "nav-user.svelte");
402
+ c(E(t, O(t))), i.info("Modifying signup +page.server.ts");
403
+ let n = z.join(e.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
404
+ c(E(n, F(n)));
453
405
  }
454
406
  return {
455
- creates: o,
407
+ creates: a,
456
408
  modifies: s,
457
409
  deletes: [],
458
410
  components: [],
@@ -469,10 +421,10 @@ async function Y(t, n) {
469
421
  let n = t.input.currency;
470
422
  throw new e(n === void 0 || n === "" ? "Payments on WhatsApp need the business's currency, the one it prices in (an ISO 4217 code such as MXN or EUR). Pass --currency, or set `currency` in src/lib/site.ts." : `${String(n)} is not an ISO 4217 currency code, such as MXN or EUR.`);
471
423
  }
472
- let r = [], i = P.join(t.root, "wuchale.config.js");
473
- if (N.existsSync(i)) {
474
- c(t).info("Adding src/lib/order.ts to wuchale's js adapter");
475
- let e = w(i, O(i, k));
424
+ let r = [], i = z.join(t.root, "wuchale.config.js");
425
+ if (R.existsSync(i)) {
426
+ l(t).info("Adding src/lib/order.ts to wuchale's js adapter");
427
+ let e = E(i, N(i, P));
476
428
  e && r.push(e);
477
429
  }
478
430
  return {
@@ -488,44 +440,63 @@ async function Y(t, n) {
488
440
  }
489
441
  //#endregion
490
442
  //#region src/patterns/enable/payments/generate.runtime.ts
491
- function X(e) {
443
+ var X = /* #__PURE__ */ Object.assign({
444
+ "./creates-server/src/lib/currency.server.test.ts": d,
445
+ "./creates-server/src/lib/currency.server.ts": p
446
+ });
447
+ function Z(e) {
448
+ return Object.values(r(X, "./creates-server/")).filter((t) => e || !t.path.endsWith(".test.ts")).sort((e, t) => e.path.localeCompare(t.path));
449
+ }
450
+ function Q(e) {
492
451
  try {
493
- let t = JSON.parse(N.readFileSync(P.join(e, "package.json"), "utf8"));
452
+ let t = JSON.parse(R.readFileSync(z.join(e, "package.json"), "utf8"));
494
453
  return !!(t.devDependencies?.vitest || t.dependencies?.vitest);
495
454
  } catch {
496
455
  return !1;
497
456
  }
498
457
  }
499
- async function Z(e) {
500
- let t = c(e), o = i(u, e), s = [], d = [], f = (e) => {
501
- e && d.push(e);
458
+ async function $(e) {
459
+ let t = l(e), r = a(f, e), s = [], c = [], d = (e) => {
460
+ e && c.push(e);
502
461
  };
503
- t.info(`Writing ${o.label} credentials to .env`);
504
- let p = P.join(e.root, ".env");
505
- f(w(p, S(p, l(o, a(e))))), t.info(`Declaring ${o.label} variables in src/env.ts`);
506
- let m = T(e.root, r(o));
507
- m.create && s.push(m.create), f(m.modify);
508
- let { currency: h, country: g, currencies: C } = e.input, E = N.existsSync(b(e.root)), { file: O, business: k } = await x(e, {
509
- currency: _(h) ?? void 0,
510
- country: y(g) ?? void 0,
511
- currencies: v(C, _(h) ?? void 0) ?? void 0
462
+ t.info(`Writing ${r.label} credentials to .env`);
463
+ let p = z.join(e.root, ".env");
464
+ d(E(p, T(p, u(r, o(e))))), t.info(`Declaring ${r.label} variables in src/env.ts`);
465
+ let m = D(e.root, i(r));
466
+ m.create && s.push(m.create), d(m.modify);
467
+ let { currency: h, country: g, currencies: _ } = e.input, v = R.existsSync(C(e.root)), { file: y, business: O } = await w(e, {
468
+ currency: b(h) ?? void 0,
469
+ country: S(g) ?? void 0,
470
+ currencies: x(_, b(h) ?? void 0) ?? void 0
512
471
  });
513
- O && (E ? d : s).push(O), t.info("Adding the currency select to the navbar");
514
- let A = P.join(e.root, "src", "routes", "(public)", "root-layout.svelte");
515
- f(w(A, D(A)));
516
- let j = {
472
+ y && (v ? c : s).push(y), t.info("Adding the currency select to the navbar");
473
+ let N = z.join(e.root, "src", "routes", "(public)", "root-layout.svelte");
474
+ d(E(N, M(N)));
475
+ let P = z.join(e.root, "src", "routes", "+layout.server.ts");
476
+ if (R.existsSync(P)) {
477
+ t.info("Resolving the visitor's currency on the server");
478
+ let n = k(P);
479
+ if (d(E(P, n)), n.status === "success") {
480
+ let t = z.join(e.root, "src", "hooks.server.ts");
481
+ d(E(t, j(t)));
482
+ let n = z.join(e.root, "src", "routes", "+layout.svelte");
483
+ d(E(n, A(n)));
484
+ for (let t of Z(Q(e.root))) s.push(t);
485
+ }
486
+ }
487
+ let F = {
517
488
  creates: s,
518
- modifies: d,
489
+ modifies: c,
519
490
  deletes: [],
520
491
  components: [],
521
492
  packages: [],
522
493
  collections: [],
523
494
  collectionPatches: [],
524
495
  collectionDrops: []
525
- }, M = o.id === "stripe" ? await J(e) : o.id === "shopify" ? await I(e) : await Y(e, k);
526
- return n([j, M]);
496
+ }, I = r.id === "stripe" ? await J(e) : r.id === "shopify" ? await V(e) : await Y(e, O);
497
+ return n([F, I]);
527
498
  }
528
499
  //#endregion
529
- export { Z as generate, X as hasVitest };
500
+ export { $ as generate, Q as hasVitest };
530
501
 
531
- //# sourceMappingURL=generate.runtime-Dt3Edp8-.js.map
502
+ //# sourceMappingURL=generate.runtime-J2lLMjDn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-J2lLMjDn.js","names":["__import_glob__0_0_","__import_glob__0_1_","InvalidArgumentError","languageFromPath","mergeResults","providerEnvVars","resolveProvider","suppliedProviderEnv","dedent","_taggedTemplateLiteral","getLogger","envEditsFor","currency_server_test_default","META","currency_server_default","buyPageSnippet","STRIPE_PRODUCTS","STRIPE_PRICES","withPocketbase","migrationDelay","getMigrationFile","normalizeCurrency","normalizeCurrencies","normalizeCountry","sitePath","ensureSiteBusiness","modifyEnv","modifyOutcomeToFile","modifyNavUser","modifyLayoutServerCurrency","modifyLayoutSvelteCurrency","modifyHooksServerCurrency","modifyRootLayoutCurrencySelect","modifyWuchaleJsFiles","TRANSLATED_LIB_FILES","modifyUserSignup","ensureCollectionFields","createCollectionIdempotent","fs","path","Stripe","setupShopify","logger","options","variantId","creates","syncUsersToStripeCustomers","stripe","stripeSecretKey","users","pb","existing","linkedUserIds","c","result","user","matching","label","customer","isExistingCustomer","error","paymentMethods","paymentMethod","defaultPaymentMethod","createTestProductAndPrice","products","product","prices","getProductAndPriceById","price","priceId","_templateObject","pushMigrationCreates","created","migrationFile","collectionName","action","paymentPageSnippet","setupStripe","stripePriceId","isAppMode","modifies","pushResult","file","create","spec","customersResult","stripeCustomersCollection","paymentMethodsResult","stripePaymentMethodsCollection","transactionsResult","syncResult","navUserPath","userSignupPath","setupWhatsApp","business","given","wuchaleConfig","edit","createsServerRaw","serverCreates","filesFromGlob","unitTests","a","b","hasVitest","pkg","root","generate","provider","envPath","envVars","modifyEnvVarsFiles","siteExisted","siteFile","currency","country","currencies","layoutPath","layoutServerPath","layoutServer","hooksServerPath","rootLayoutPath","env","setup"],"sources":["../../src/patterns/enable/payments/runtime/setup-shopify.ts","../../src/patterns/enable/payments/runtime/stripe.ts","../../src/patterns/enable/payments/runtime/setup-stripe.ts","../../src/patterns/enable/payments/runtime/setup-whatsapp.ts","../../src/patterns/enable/payments/generate.runtime.ts"],"sourcesContent":["import type { Options, Result } from \"../../../../core/types\";\nimport { getLogger } from \"../../../../core/logger\";\nimport { buyPageSnippet } from \"../shopify-page\";\n\n/**\n * Shopify keeps products, customers and checkout on its side, so past the env\n * there is only the demo page, and only when a variant to sell was given.\n */\nexport async function setupShopify(options: Options) {\n const logger = getLogger(options);\n const variantId =\n typeof options.input.demoId === \"string\" ? options.input.demoId.trim() : \"\";\n\n const creates = [];\n if (variantId) {\n logger.info(\"Creating payment +page.svelte\");\n creates.push({\n path: \"src/routes/(public)/payment/+page.svelte\",\n language: \"svelte\",\n content: buyPageSnippet(variantId),\n status: \"success\" as const,\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","import Stripe from \"stripe\";\nimport type PocketBase from \"pocketbase\";\nimport type { Logger } from \"../../../../core/logger\";\n\nexport interface StripeTestFixture {\n product: Stripe.Product;\n price: Stripe.Price;\n existing: boolean;\n}\n\nexport interface SyncUsersResult {\n total: number;\n linked: number;\n created: number;\n reused: number;\n skipped: number;\n}\n\nexport async function syncUsersToStripeCustomers(\n pb: PocketBase,\n stripeSecretKey: string,\n logger: Logger,\n): Promise<SyncUsersResult> {\n const stripe = new Stripe(stripeSecretKey);\n const users = await pb.collection(\"users\").getFullList<{\n id: string;\n email?: string;\n name?: string;\n phone?: string;\n }>();\n\n const existing = await pb\n .collection(\"stripe_customers\")\n .getFullList<{ id: string; user: string }>();\n const linkedUserIds = new Set(existing.map((c) => c.user));\n\n const result: SyncUsersResult = {\n total: users.length,\n linked: linkedUserIds.size,\n created: 0,\n reused: 0,\n skipped: 0,\n };\n\n for (const user of users) {\n if (linkedUserIds.has(user.id)) {\n result.skipped += 1;\n continue;\n }\n\n // A user made with a phone number may have no email to match on.\n const matching = user.email\n ? await stripe.customers.list({\n email: user.email,\n limit: 1,\n expand: [\"data.invoice_settings\"],\n })\n : { data: [] };\n const label = user.email || user.id;\n\n let customer: Stripe.Customer;\n let isExistingCustomer = false;\n\n if (matching.data.length > 0) {\n customer = matching.data[0];\n isExistingCustomer = true;\n result.reused += 1;\n logger.info(`Reusing Stripe customer ${customer.id} for ${label}`);\n } else {\n customer = await stripe.customers.create(\n user.email\n ? { email: user.email }\n : { name: user.name || undefined, phone: user.phone || undefined },\n );\n result.created += 1;\n logger.info(`Created Stripe customer ${customer.id} for ${label}`);\n }\n\n try {\n await pb.collection(\"stripe_customers\").create({\n id: customer.id,\n user: user.id,\n });\n } catch (error) {\n logger.info(\n `Failed to create stripe_customers row for ${label}: ${(error as Error).message}`,\n );\n continue;\n }\n\n if (!isExistingCustomer) {\n continue;\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(\n customer.id,\n { type: \"card\", allow_redisplay: \"always\" },\n );\n\n for (const paymentMethod of paymentMethods.data) {\n if (paymentMethod.allow_redisplay === \"unspecified\") continue;\n try {\n await pb.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customer.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n } catch {}\n }\n\n const defaultPaymentMethod =\n customer.invoice_settings?.default_payment_method;\n if (defaultPaymentMethod) {\n try {\n await pb.collection(\"stripe_customers\").update(customer.id, {\n default_payment_method:\n typeof defaultPaymentMethod === \"string\"\n ? defaultPaymentMethod\n : defaultPaymentMethod.id,\n });\n } catch {}\n }\n }\n\n return result;\n}\n\nexport async function createTestProductAndPrice(\n stripeSecretKey: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n\n const products = await stripe.products.search({\n query: `name:\"Test Product\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n const product = products.data[0];\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n if (prices.data.length > 0) {\n return { product, price: prices.data[0], existing: true };\n }\n }\n\n const product = await stripe.products.create({\n name: \"Test Product\",\n metadata: { test: \"true\" },\n });\n\n const price = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n });\n\n return { product, price, existing: false };\n}\n\nexport async function getProductAndPriceById(\n stripeSecretKey: string,\n priceId: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n const price = await stripe.prices.retrieve(priceId, { expand: [\"product\"] });\n const product =\n typeof price.product === \"string\"\n ? await stripe.products.retrieve(price.product)\n : (price.product as Stripe.Product);\n price.product = product.id;\n return { product, price, existing: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport type { File, Options, Result } from \"../../../../core/types\";\nimport { getLogger } from \"../../../../core/logger\";\nimport { suppliedProviderEnv } from \"../../../../core/providers\";\nimport { languageFromPath } from \"../../../../core/util\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../../runtime/pocketbase\";\nimport {\n createCollectionIdempotent,\n ensureCollectionFields,\n} from \"../../../../runtime/collections\";\nimport { STRIPE_PRICES, STRIPE_PRODUCTS } from \"./collections\";\nimport { modifyOutcomeToFile } from \"../../../../runtime/modify-file\";\nimport { modifyNavUser } from \"../modifies/modify-nav-user\";\nimport { modifyUserSignup } from \"../modifies/modify-user-signup\";\nimport {\n createTestProductAndPrice,\n getProductAndPriceById,\n syncUsersToStripeCustomers,\n} from \"./stripe\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n action: \"created\" | \"updated\",\n options: Options,\n created = true,\n) {\n if (!created) return;\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, action, options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nfunction paymentPageSnippet(priceId: string): string {\n return dedent`\n <script lang=\"ts\">\n import PaymentButton from '#lib/components/payments/payment-button.svelte';\n </script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"${priceId}\" />\n </section>\n `;\n}\n\n/**\n * Everything Stripe needs past its env: the catalog and customer collections,\n * the existing users as Stripe customers, a product/price for the demo page,\n * and, with auth, the billing nav item and the signup link to Stripe.\n */\nexport async function setupStripe(options: Options) {\n const stripeSecretKey = suppliedProviderEnv(options).STRIPE_SECRET_KEY ?? \"\";\n const stripePriceId =\n typeof options.input.demoId === \"string\" && options.input.demoId !== \"\"\n ? options.input.demoId\n : undefined;\n\n const isAppMode = options.features.auth;\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n await withPocketbase(options.root, async (pb) => {\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n // The catalog: created, or, when a project enabled payments before a\n // field existed, brought up to the spec (the next sync fills the field).\n for (const spec of [STRIPE_PRODUCTS, STRIPE_PRICES]) {\n logger.info(`Creating ${spec.name} collection`);\n const result = await create(spec);\n await pushMigrationCreates(\n creates,\n spec.name,\n \"created\",\n options,\n result.created,\n );\n if (!result.created) {\n creates.push(\n ...(await ensureCollectionFields(pb, spec, options, logger)),\n );\n }\n }\n\n if (isAppMode) {\n logger.info(\"Creating stripe_customers collection\");\n const customersResult = await create({\n name: \"stripe_customers\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n const stripeCustomersCollection = customersResult.collection;\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"created\",\n options,\n customersResult.created,\n );\n\n logger.info(\"Creating stripe_payment_methods collection\");\n const paymentMethodsResult = await create({\n name: \"stripe_payment_methods\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"exp_month\", required: true, type: \"number\" },\n { name: \"exp_year\", required: true, type: \"number\" },\n {\n collectionId: stripeCustomersCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"customer\",\n required: true,\n type: \"relation\",\n cascadeDelete: true,\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n const stripePaymentMethodsCollection = paymentMethodsResult.collection;\n await pushMigrationCreates(\n creates,\n \"stripe_payment_methods\",\n \"created\",\n options,\n paymentMethodsResult.created,\n );\n\n logger.info(\"Linking default_payment_method on stripe_customers\");\n await pb.collections.update(\"stripe_customers\", {\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n collectionId: stripePaymentMethodsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"default_payment_method\",\n required: false,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"updated\",\n options,\n );\n\n logger.info(\"Creating transactions collection\");\n const transactionsResult = await create({\n name: \"transactions\",\n type: \"base\",\n fields: [\n {\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"stripe_payment_intent\", required: true, type: \"text\" },\n { name: \"amount\", required: true, type: \"number\" },\n { name: \"currency\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"created\", required: true, type: \"date\" },\n { name: \"stripe_charge\", required: true, type: \"text\" },\n { name: \"stripe_customer\", required: true, type: \"text\" },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n { name: \"receipt_url\", required: true, type: \"url\" },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"transactions\",\n \"created\",\n options,\n transactionsResult.created,\n );\n\n logger.info(\"Syncing existing PocketBase users to Stripe customers\");\n const syncResult = await syncUsersToStripeCustomers(\n pb,\n stripeSecretKey,\n logger,\n );\n logger.info(\n `Synced ${syncResult.total} users (created ${syncResult.created}, reused ${syncResult.reused}, skipped ${syncResult.skipped})`,\n );\n }\n });\n\n if (stripePriceId) {\n logger.info(`Fetching Stripe product/price ${stripePriceId}`);\n } else {\n logger.info(\"Creating test Stripe product and price\");\n }\n const { product, price, existing } = stripePriceId\n ? await getProductAndPriceById(stripeSecretKey, stripePriceId)\n : await createTestProductAndPrice(stripeSecretKey);\n\n if (existing) {\n logger.info(\"Stripe product/price already exists, skipping creation\");\n }\n\n logger.info(\"Seeding Stripe product/price records\");\n await withPocketbase(options.root, async (pb) => {\n try {\n await pb.collection(\"stripe_products\").getOne(product.id);\n } catch (error) {\n await pb.collection(\"stripe_products\").create({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price: product.default_price,\n });\n }\n\n try {\n await pb.collection(\"stripe_prices\").getOne(price.id);\n } catch (error) {\n await pb.collection(\"stripe_prices\").create({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: price.product,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n });\n }\n });\n\n logger.info(\"Creating payment +page.svelte\");\n creates.push({\n path: \"src/routes/(public)/payment/+page.svelte\",\n language: \"svelte\",\n content: paymentPageSnippet(price.id),\n status: \"success\",\n });\n\n if (isAppMode) {\n 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(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n logger.info(\"Modifying signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, modifyUserSignup(userSignupPath)),\n );\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../../core/types\";\nimport { InvalidArgumentError } from \"../../../../core/errors\";\nimport { getLogger } from \"../../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../../runtime/modify-file\";\nimport type { SiteBusiness } from \"../../../../runtime/site\";\nimport {\n modifyWuchaleJsFiles,\n TRANSLATED_LIB_FILES,\n} from \"../../../../runtime/wuchale-config\";\n\n/**\n * WhatsApp keeps nothing past the env: orders go to the business's chat, and\n * the hosted form they are recorded to is created by the CLI. Every price is\n * in `site.currency`, so a project without one can't take orders: `business`\n * is what `src/lib/site.ts` declares after the shared step wrote it.\n */\nexport async function setupWhatsApp(options: Options, business: SiteBusiness) {\n if (!business.currency) {\n const given = options.input.currency;\n throw new InvalidArgumentError(\n given === undefined || given === \"\"\n ? \"Payments on WhatsApp need the business's currency, the one it prices in (an ISO 4217 code such as MXN or EUR). Pass --currency, or set `currency` in src/lib/site.ts.\"\n : `${String(given)} is not an ISO 4217 currency code, such as MXN or EUR.`,\n );\n }\n const modifies: File[] = [];\n\n // The order message is text a visitor sends, so with wuchale on it is\n // translated like the pages: the js adapter has to be told about the module.\n const wuchaleConfig = path.join(options.root, \"wuchale.config.js\");\n if (fs.existsSync(wuchaleConfig)) {\n getLogger(options).info(\"Adding src/lib/order.ts to wuchale's js adapter\");\n const edit = modifyOutcomeToFile(\n wuchaleConfig,\n modifyWuchaleJsFiles(wuchaleConfig, TRANSLATED_LIB_FILES),\n );\n if (edit) modifies.push(edit);\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","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 providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { filesFromGlob, mergeResults } from \"../../../core/util\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport {\n ensureSiteBusiness,\n normalizeCountry,\n normalizeCurrencies,\n normalizeCurrency,\n sitePath,\n} from \"../../../runtime/site\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyHooksServerCurrency } from \"./modifies/hooks.server\";\nimport { modifyLayoutServerCurrency } from \"./modifies/layout.server\";\nimport { modifyLayoutSvelteCurrency } from \"./modifies/layout.svelte\";\nimport { modifyRootLayoutCurrencySelect } from \"./modifies/root-layout.svelte\";\nimport { setupShopify } from \"./runtime/setup-shopify\";\nimport { setupStripe } from \"./runtime/setup-stripe\";\nimport { setupWhatsApp } from \"./runtime/setup-whatsapp\";\n\nconst createsServerRaw = import.meta.glob<string>(\"./creates-server/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\n/** The server half of the currency store, for a project with a server load. */\nexport function serverCreates(unitTests: boolean): File[] {\n return Object.values(filesFromGlob(createsServerRaw, \"./creates-server/\"))\n .filter((file) => unitTests || !file.path.endsWith(\".test.ts\"))\n .sort((a, b) => a.path.localeCompare(b.path));\n}\n\n/** Whether the project can run a unit test (`vitest` in package.json). */\nexport function hasVitest(root: string): boolean {\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n ) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n return Boolean(pkg.devDependencies?.vitest || pkg.dependencies?.vitest);\n } catch {\n return false;\n }\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(`Writing ${provider.label} credentials to .env`);\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n ),\n );\n\n // SvelteKit 3 exposes only declared variables, and only `public: true`\n // ones through `$app/env/public`.\n logger.info(`Declaring ${provider.label} variables in src/env.ts`);\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n pushResult(envVars.modify);\n\n // What the business declares in src/lib/site.ts: the currency it prices\n // in, the country it is in, and the other currencies it shows prices in.\n // Asked for by the CLI; a value already there is kept.\n const { currency, country, currencies } = options.input;\n const siteExisted = fs.existsSync(sitePath(options.root));\n const { file: siteFile, business } = await ensureSiteBusiness(options, {\n currency: normalizeCurrency(currency) ?? undefined,\n country: normalizeCountry(country) ?? undefined,\n currencies:\n normalizeCurrencies(\n currencies,\n normalizeCurrency(currency) ?? undefined,\n ) ?? undefined,\n });\n if (siteFile) (siteExisted ? modifies : creates).push(siteFile);\n\n logger.info(\"Adding the currency select to the navbar\");\n const layoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(layoutPath, modifyRootLayoutCurrencySelect(layoutPath)),\n );\n\n // With a server, the visitor's currency is decided per request and the\n // first render already shows it. A static site (a universal root load) keeps\n // the store's browser-side start.\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n if (fs.existsSync(layoutServerPath)) {\n logger.info(\"Resolving the visitor's currency on the server\");\n const layoutServer = modifyLayoutServerCurrency(layoutServerPath);\n pushResult(modifyOutcomeToFile(layoutServerPath, layoutServer));\n if (layoutServer.status === \"success\") {\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerCurrency(hooksServerPath),\n ),\n );\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyLayoutSvelteCurrency(rootLayoutPath),\n ),\n );\n for (const file of serverCreates(hasVitest(options.root)))\n creates.push(file);\n }\n }\n\n const env: Result = {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n };\n\n const setup =\n provider.id === \"stripe\"\n ? await setupStripe(options)\n : provider.id === \"shopify\"\n ? await setupShopify(options)\n : await setupWhatsApp(options, business);\n\n return mergeResults([env, setup]) satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;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,EAAG,WAAWiF,CAAgB,GAAG;EACnC,EAAO,KAAK,gDAAgD;EAC5D,IAAMC,IAAe3F,EAA2B0F,CAAgB;EAEhE,IADArC,EAAWvD,EAAoB4F,GAAkBC,CAAY,CAAC,GAC1DA,EAAa,WAAW,WAAW;GACrC,IAAMC,IAAkBlF,EAAK,KAAKI,EAAQ,MAAM,OAAO,iBAAiB;GACxE,EACEhB,EACE8F,GACA1F,EAA0B0F,CAAe,CAC3C,CACF;GACA,IAAMC,IAAiBnF,EAAK,KAC1BI,EAAQ,MACR,OACA,UACA,gBACF;GACA,EACEhB,EACE+F,GACA5F,EAA2B4F,CAAc,CAC3C,CACF;GACA,KAAK,IAAMvC,KAAQiB,EAAcK,EAAU9D,EAAQ,IAAI,CAAC,GACtD,EAAQ,KAAKwC,CAAI;EACrB;CACF;CAEA,IAAMwC,IAAc;EAClB;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB,GAEMC,IACJf,EAAS,OAAO,WACZ,MAAM/B,EAAYnC,CAAO,IACzBkE,EAAS,OAAO,YACd,MAAMpE,EAAaE,CAAO,IAC1B,MAAMmD,EAAcnD,GAASoD,CAAQ;CAE7C,OAAO3F,EAAa,CAACuH,GAAKC,CAAK,CAAC;AAClC"}
@@ -0,0 +1,64 @@
1
+ import { a as e } from "./util-BLYliuUK.js";
2
+ import { n as t } from "./logger-CQONztPm.js";
3
+ import { m as n, p as r, t as i } from "./generate-BrOPb9tW.js";
4
+ import { t as a } from "./shared-BbxLil4g.js";
5
+ import { f as o } from "./ts-morph-helpers-CHI9wAil.js";
6
+ import { r as s } from "./modify-file-B4uJzOEj.js";
7
+ import { t as c } from "./svelte-file-Dv5-bl79.js";
8
+ import { SUCCESS_PAGE as l, t as u } from "./generate.runtime-DuDcKDUl.js";
9
+ import d from "node:fs";
10
+ import f from "node:path";
11
+ //#region src/patterns/disable/orders/generate.runtime.ts
12
+ async function p(p) {
13
+ let m = t(p), h = [], g = (e) => {
14
+ e && h.push(e);
15
+ };
16
+ m.info("Reverting webhooks/stripe/handlers/dispatch.ts");
17
+ let _ = f.join(p.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
18
+ g(s(_, u(_))), m.info("Reverting /checkout/success");
19
+ for (let [t, i] of [["+page.server.ts", n], ["+page.svelte", r]]) {
20
+ let n = f.join(p.root, l, t);
21
+ d.existsSync(n) && d.readFileSync(n, "utf8") !== i && h.push({
22
+ path: n,
23
+ language: e(n),
24
+ content: i,
25
+ status: "success"
26
+ });
27
+ }
28
+ m.info("Removing Orders from the user menu");
29
+ let v = f.join(p.root, "src", "lib", "components", "nav-user.svelte");
30
+ if (d.existsSync(v)) {
31
+ let t = d.readFileSync(v, "utf8");
32
+ if (t.includes("'/orders'")) {
33
+ let n = new c(t), r = !1, i = (e) => {
34
+ r || e((e) => {
35
+ let t = o(e, "Orders", "@lucide/svelte/icons/package");
36
+ return t.wasRemoved && (r = !0), t.source;
37
+ });
38
+ };
39
+ if (i((e) => n.modifyModuleScript(e)), r || i((e) => n.modifyScript(e)), r) {
40
+ let t = n.toString();
41
+ d.writeFileSync(v, t, "utf8"), h.push({
42
+ path: v,
43
+ language: e(v),
44
+ content: t,
45
+ status: "success"
46
+ });
47
+ }
48
+ }
49
+ }
50
+ return {
51
+ creates: [],
52
+ modifies: h,
53
+ deletes: [],
54
+ components: [],
55
+ packages: [],
56
+ collections: [],
57
+ collectionPatches: [],
58
+ collectionDrops: await a([...i].reverse(), p)
59
+ };
60
+ }
61
+ //#endregion
62
+ export { p as generate };
63
+
64
+ //# sourceMappingURL=generate.runtime-nyJ6v56q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-nyJ6v56q.js","names":["successServer","successSvelte","languageFromPath","getLogger","_page_server_default","_page_default","ORDER_COLLECTIONS","planDropsForCollections","removeNavItemFromScript","modifyOutcomeToFile","SvelteFile","unmodifyWebhookServer","fs","path","generate","logger","options","modifies","pushResult","file","dispatchPath","name","content","SUCCESS_PAGE","navUserPath","source","removed","tryRemove","run","result","src","fn","updated"],"sources":["../../src/patterns/disable/orders/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { languageFromPath } from \"../../../core/util\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { SvelteFile } from \"../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../runtime/ts-morph-helpers\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\nimport { ORDER_COLLECTIONS } from \"../../enable/orders/generate\";\nimport { SUCCESS_PAGE } from \"../../enable/orders/generate.runtime\";\nimport { unmodifyWebhookServer } from \"../../enable/orders/modifies/modify-webhook-server\";\n// The success page as enable-ecommerce wrote it, before orders rewrote it.\nimport successServer from \"../../enable/ecommerce/providers/stripe/src/routes/(public)/checkout/success/+page.server.ts?raw\";\nimport successSvelte from \"../../enable/ecommerce/providers/stripe/src/routes/(public)/checkout/success/+page.svelte?raw\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting webhooks/stripe/handlers/dispatch.ts\");\n const dispatchPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(dispatchPath, unmodifyWebhookServer(dispatchPath)),\n );\n\n // Back to Stripe's summary alone, as enable-ecommerce wrote the page; a\n // project without the cart has no page to restore.\n logger.info(\"Reverting /checkout/success\");\n for (const [name, content] of [\n [\"+page.server.ts\", successServer],\n [\"+page.svelte\", successSvelte],\n ] as const) {\n const file = path.join(options.root, SUCCESS_PAGE, name);\n if (!fs.existsSync(file) || fs.readFileSync(file, \"utf8\") === content) {\n continue;\n }\n modifies.push({\n path: file,\n language: languageFromPath(file),\n content,\n status: \"success\",\n });\n }\n\n logger.info(\"Removing Orders from the user menu\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n if (fs.existsSync(navUserPath)) {\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (source.includes(\"'/orders'\")) {\n const file = new SvelteFile(source);\n let removed = false;\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (removed) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Orders\",\n \"@lucide/svelte/icons/package\",\n );\n if (result.wasRemoved) removed = true;\n return result.source;\n });\n };\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!removed) tryRemove((fn) => file.modifyScript(fn));\n if (removed) {\n const updated = file.toString();\n fs.writeFileSync(navUserPath, updated, \"utf8\");\n modifies.push({\n path: navUserPath,\n language: languageFromPath(navUserPath),\n content: updated,\n status: \"success\",\n });\n }\n }\n }\n\n // Lines before orders: PocketBase refuses to drop a collection another\n // relation still points at. One never created is planned as missing.\n const collectionDrops = await planDropsForCollections(\n [...ORDER_COLLECTIONS].reverse(),\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":";;;;;;;;;;;AAgBA,eAAsBc,EAAS,GAAkB;CAC/C,IAAMC,IAASZ,EAAUa,CAAO,GAC1BC,IAAmB,CAAC,GACpBC,KAAc,MAAsB;EACxC,AAAIC,KAAMF,EAAS,KAAKE,CAAI;CAC9B;CAEA,EAAO,KAAK,gDAAgD;CAC5D,IAAMC,IAAeP,EAAK,KACxBG,EAAQ,MACR,OACA,UACA,YACA,UACA,YACA,aACF;CAOA,AANAE,EACET,EAAoBW,GAAcT,EAAsBS,CAAY,CAAC,CACvE,GAIAL,EAAO,KAAK,6BAA6B;CACzC,KAAK,IAA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C,QAAQ,GAC/BU,CACF;CAWA;AACF"}
@@ -0,0 +1,79 @@
1
+ import { Node as e, Project as t, QuoteKind as n, SyntaxKind as r } from "ts-morph";
2
+ //#region src/runtime/load-function.ts
3
+ function i() {
4
+ return new t({
5
+ compilerOptions: { allowJs: !0 },
6
+ manipulationSettings: { quoteKind: n.Single }
7
+ });
8
+ }
9
+ function a(e, t, n) {
10
+ let r = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t);
11
+ if (!r) e.addImportDeclaration({
12
+ namedImports: n,
13
+ moduleSpecifier: t
14
+ });
15
+ else for (let e of n) r.getNamedImports().some((t) => t.getName() === e) || r.addNamedImport(e);
16
+ }
17
+ function o(e, t) {
18
+ t.namedImports?.length && a(e, t.moduleSpecifier, t.namedImports), !e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t.moduleSpecifier) && e.addImportDeclaration({
19
+ moduleSpecifier: t.moduleSpecifier,
20
+ defaultImport: t.defaultImport,
21
+ namespaceImport: t.namespaceImport
22
+ });
23
+ }
24
+ function s(t) {
25
+ if (e.isArrowFunction(t) || e.isFunctionExpression(t)) return t;
26
+ if (e.isParenthesizedExpression(t) || e.isAsExpression(t) || e.isSatisfiesExpression(t)) return s(t.getExpression());
27
+ if (e.isCallExpression(t)) for (let e of t.getArguments()) {
28
+ let t = s(e);
29
+ if (t) return t;
30
+ }
31
+ return null;
32
+ }
33
+ function c(e) {
34
+ let t = e.getFunction("load");
35
+ if (t) return t.isExported() ? t : null;
36
+ let n = e.getVariableDeclaration("load");
37
+ if (!n || !n.getVariableStatement()?.isExported()) return null;
38
+ let r = n.getInitializer();
39
+ return r ? s(r) : null;
40
+ }
41
+ function l(t) {
42
+ return e.isArrowFunction(t) || e.isFunctionExpression(t) || e.isFunctionDeclaration(t) || e.isMethodDeclaration(t);
43
+ }
44
+ function u(t, n) {
45
+ let i = n.getStatements(), a = i[i.length - 1];
46
+ return !a || !e.isReturnStatement(a) || n.getDescendantsOfKind(r.ReturnStatement).filter((e) => e.getFirstAncestor(l) === t).length !== 1 ? null : a;
47
+ }
48
+ function d(t) {
49
+ let n = t.getExpression();
50
+ for (; n && e.isParenthesizedExpression(n);) n = n.getExpression();
51
+ return !n || !e.isObjectLiteralExpression(n) ? null : n;
52
+ }
53
+ function f(t, n) {
54
+ return t.getProperties().some((t) => e.isPropertyAssignment(t) || e.isShorthandPropertyAssignment(t) ? t.getName() === n : !1);
55
+ }
56
+ function p(t, n) {
57
+ return t.getProperties().some((t) => e.isSpreadAssignment(t) && t.getExpression().getText() === n);
58
+ }
59
+ function m(t) {
60
+ let n = t.getParameters();
61
+ if (n.length === 0) return { kind: "none" };
62
+ if (n.length > 1) return { kind: "unsupported" };
63
+ let r = n[0];
64
+ if (r.getInitializer() || r.isRestParameter()) return { kind: "unsupported" };
65
+ let i = r.getNameNode();
66
+ return e.isIdentifier(i) ? {
67
+ kind: "identifier",
68
+ name: i.getText(),
69
+ param: r
70
+ } : e.isObjectBindingPattern(i) ? {
71
+ kind: "binding",
72
+ pattern: i,
73
+ param: r
74
+ } : { kind: "unsupported" };
75
+ }
76
+ //#endregion
77
+ export { f as a, i as c, c as i, d as l, a as n, p as o, u as r, m as s, o as t };
78
+
79
+ //# sourceMappingURL=load-function-Dmkhg1pQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-function-Dmkhg1pQ.js","names":["newProject","Project","QuoteKind","ensureNamedImports","existing","sourceFile","d","moduleSpecifier","names","name","ni","ensureImportSpec","spec","unwrapFunction","Node","node","arg","fn","findLoadFunction","declaration","variable","initializer","isFunctionNode","findFinalReturn","statements","body","last","SyntaxKind","r","returnedObject","expression","statement","hasProperty","object","property","hasSpreadOf","expressionText","inspectEventParameter","params","param","nameNode"],"sources":["../../src/runtime/load-function.ts"],"sourcesContent":["import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrowFunction,\n type Block,\n type FunctionDeclaration,\n type FunctionExpression,\n type ObjectLiteralExpression,\n type ParameterDeclaration,\n type ReturnStatement,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ImportSpec } from \"./ts-morph-helpers\";\n\n/**\n * What the two layout modifiers have in common: finding a SvelteKit `load`,\n * working out how it receives its event, and locating the object it returns.\n */\n\nexport type LoadFunction =\n ArrowFunction | FunctionExpression | FunctionDeclaration;\n\nexport function newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\nexport function ensureNamedImports(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n names: string[],\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({ namedImports: names, moduleSpecifier });\n return;\n }\n for (const name of names) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n }\n}\n\nexport function ensureImportSpec(sourceFile: SourceFile, spec: ImportSpec) {\n if (spec.namedImports?.length) {\n ensureNamedImports(sourceFile, spec.moduleSpecifier, spec.namedImports);\n }\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({\n moduleSpecifier: spec.moduleSpecifier,\n defaultImport: spec.defaultImport,\n namespaceImport: spec.namespaceImport,\n });\n}\n\n/** Peel wrappers (`loadFlash(fn)`, `(fn)`, `fn satisfies X`) down to the function. */\nfunction unwrapFunction(node: Node): ArrowFunction | FunctionExpression | null {\n if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {\n return node;\n }\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isSatisfiesExpression(node)\n ) {\n return unwrapFunction(node.getExpression());\n }\n if (Node.isCallExpression(node)) {\n for (const arg of node.getArguments()) {\n const fn = unwrapFunction(arg);\n if (fn) return fn;\n }\n }\n return null;\n}\n\n/** The exported `load`, whether declared as a function or wrapped in a const. */\nexport function findLoadFunction(sourceFile: SourceFile): LoadFunction | null {\n const declaration = sourceFile.getFunction(\"load\");\n if (declaration) {\n return declaration.isExported() ? declaration : null;\n }\n\n const variable = sourceFile.getVariableDeclaration(\"load\");\n if (!variable) return null;\n if (!variable.getVariableStatement()?.isExported()) return null;\n\n const initializer = variable.getInitializer();\n return initializer ? unwrapFunction(initializer) : null;\n}\n\nfunction isFunctionNode(node: Node): boolean {\n return (\n Node.isArrowFunction(node) ||\n Node.isFunctionExpression(node) ||\n Node.isFunctionDeclaration(node) ||\n Node.isMethodDeclaration(node)\n );\n}\n\n/**\n * The single, final `return <expression>` of the load body, or null when the\n * body has early returns — those would need any insertion hoisted above them,\n * and guessing where is worse than refusing.\n */\nexport function findFinalReturn(\n fn: LoadFunction,\n body: Block,\n): ReturnStatement | null {\n const statements = body.getStatements();\n const last = statements[statements.length - 1];\n if (!last || !Node.isReturnStatement(last)) return null;\n\n const returns = body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((r) => r.getFirstAncestor(isFunctionNode) === fn);\n if (returns.length !== 1) return null;\n\n return last;\n}\n\n/** The object literal a return statement yields, unwrapping parentheses. */\nexport function returnedObject(\n statement: ReturnStatement,\n): ObjectLiteralExpression | null {\n let expression = statement.getExpression();\n while (expression && Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n if (!expression || !Node.isObjectLiteralExpression(expression)) return null;\n return expression;\n}\n\nexport function hasProperty(\n object: ObjectLiteralExpression,\n name: string,\n): boolean {\n return object.getProperties().some((property) => {\n if (\n Node.isPropertyAssignment(property) ||\n Node.isShorthandPropertyAssignment(property)\n ) {\n return property.getName() === name;\n }\n return false;\n });\n}\n\nexport function hasSpreadOf(\n object: ObjectLiteralExpression,\n expressionText: string,\n): boolean {\n return object\n .getProperties()\n .some(\n (property) =>\n Node.isSpreadAssignment(property) &&\n property.getExpression().getText() === expressionText,\n );\n}\n\n/** How a load receives its event: not at all, by name, or destructured. */\nexport type EventParameter =\n | { kind: \"none\" }\n | { kind: \"identifier\"; name: string; param: ParameterDeclaration }\n | {\n kind: \"binding\";\n pattern: import(\"ts-morph\").ObjectBindingPattern;\n param: ParameterDeclaration;\n }\n | { kind: \"unsupported\" };\n\nexport function inspectEventParameter(fn: LoadFunction): EventParameter {\n const params = fn.getParameters();\n if (params.length === 0) return { kind: \"none\" };\n if (params.length > 1) return { kind: \"unsupported\" };\n\n const param = params[0];\n if (param.getInitializer() || param.isRestParameter()) {\n return { kind: \"unsupported\" };\n }\n const nameNode = param.getNameNode();\n if (Node.isIdentifier(nameNode)) {\n return { kind: \"identifier\", name: nameNode.getText(), param };\n }\n if (Node.isObjectBindingPattern(nameNode)) {\n return { kind: \"binding\", pattern: nameNode, param };\n }\n return { kind: \"unsupported\" };\n}\n"],"mappings":";;AAwBA,SAAgBA,IAAsB;CACpC,OAAO,IAAIC,EAAQ;EACjB,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CAAC;AACH;AAEA,SAAgBC,EACd,GACA,GACA,GACA;CACA,IAAMC,IAAWC,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,wBAAwB,MAAMC,CAAe;CAC9D,IAAI,CAACH,GACH,EAAW,qBAAqB;EAAE,cAAcI;EAAO;CAAgB,CAAC;MAG1E,KAAK,IAAMC,KAAQD,GAEjB,AADYJ,EAAS,gBAAgB,CAAC,CAAC,MAAM,MAAOM,EAAG,QAAQ,MAAMD,CAChE,KAAKL,EAAS,eAAeK,CAAI;AAE1C;AAEA,SAAgBE,EAAiB,GAAwB,GAAkB;CAOzE,AANIC,EAAK,cAAc,UACrBT,EAAmBE,GAAYO,EAAK,iBAAiBA,EAAK,YAAY,GAEvD,GACd,sBAAsB,CAAC,CACvB,MAAM,MAAMN,EAAE,wBAAwB,MAAMM,EAAK,eAChD,KACJP,EAAW,qBAAqB;EAC9B,iBAAiBO,EAAK;EACtB,eAAeA,EAAK;EACpB,iBAAiBA,EAAK;C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