@velastack/patterns 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{_layout-kkgN0IF7.js → _layout-D-FzWqn0.js} +2 -2
- package/dist/chunks/_layout-D-FzWqn0.js.map +1 -0
- package/dist/chunks/_page-C7kGoW7_.js +6 -0
- package/dist/chunks/_page-C7kGoW7_.js.map +1 -0
- package/dist/chunks/_page-e_I-fdSR.js +6 -0
- package/dist/chunks/_page-e_I-fdSR.js.map +1 -0
- package/dist/chunks/auth-pages-B52ei-4z.js +291 -0
- package/dist/chunks/auth-pages-B52ei-4z.js.map +1 -0
- package/dist/chunks/{collections-Dz2fvKnz.js → collections-zzZ_HQxB.js} +2 -2
- package/dist/chunks/collections-zzZ_HQxB.js.map +1 -0
- package/dist/chunks/{compose-handle-D_Rz3Fzo.js → compose-handle-BDlZ7Pif.js} +2 -2
- package/dist/chunks/compose-handle-BDlZ7Pif.js.map +1 -0
- package/dist/chunks/{config-target-Dx3w6WSk.js → config-target-rHgjaA8u.js} +2 -2
- package/dist/chunks/config-target-rHgjaA8u.js.map +1 -0
- package/dist/chunks/{constants-BjyMU5s8.js → constants-Rq8SCXwH.js} +2 -2
- package/dist/chunks/constants-Rq8SCXwH.js.map +1 -0
- package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
- package/dist/chunks/dispatch-D4TN9pdW.js +6 -0
- package/dist/chunks/dispatch-D4TN9pdW.js.map +1 -0
- package/dist/chunks/env-BPfk1VAw.js.map +1 -1
- package/dist/chunks/{env-vars-C1NUX-bf.js → env-vars-CcE6ODqC.js} +4 -4
- package/dist/chunks/env-vars-CcE6ODqC.js.map +1 -0
- package/dist/chunks/env-vars-Cr4lbMD_.js.map +1 -1
- package/dist/chunks/env-vars-De0Xs0L2.js.map +1 -1
- package/dist/chunks/env-vars-file-B_6esJW3.js.map +1 -1
- package/dist/chunks/env-vars-mnRA0hOe.js.map +1 -1
- package/dist/chunks/env.preview-uMRKT5Pc.js.map +1 -1
- package/dist/chunks/errors-DR3gF_7a.js.map +1 -1
- package/dist/chunks/{format-result-DZ8De8KY.js → format-result-BVoLVknk.js} +2 -2
- package/dist/chunks/format-result-BVoLVknk.js.map +1 -0
- package/dist/chunks/{generate-DeaBlnK6.js → generate-B6Odfk5f.js} +2 -2
- package/dist/chunks/generate-B6Odfk5f.js.map +1 -0
- package/dist/chunks/{generate-WMJo3QGZ.js → generate-Bg0E3eWm.js} +2 -2
- package/dist/chunks/generate-Bg0E3eWm.js.map +1 -0
- package/dist/chunks/{generate-Gcc8iRkZ.js → generate-CFqpRi9D.js} +3 -3
- package/dist/chunks/generate-CFqpRi9D.js.map +1 -0
- package/dist/chunks/{generate-BW3l5Fxw.js → generate-CZGHByV3.js} +2 -2
- package/dist/chunks/generate-CZGHByV3.js.map +1 -0
- package/dist/chunks/generate-DetW_gbr.js.map +1 -1
- package/dist/chunks/{generate.runtime-IlBCcXvv.js → generate.runtime-5rIc-RNL.js} +7 -7
- package/dist/chunks/generate.runtime-5rIc-RNL.js.map +1 -0
- package/dist/chunks/{generate.runtime-CA7Ofjlx.js → generate.runtime-BK3mR0Rj.js} +93 -141
- package/dist/chunks/generate.runtime-BK3mR0Rj.js.map +1 -0
- package/dist/chunks/{generate.runtime-cwvAoKoH.js → generate.runtime-BpMN5Uq-.js} +3 -3
- package/dist/chunks/generate.runtime-BpMN5Uq-.js.map +1 -0
- package/dist/chunks/{generate.runtime-DD51OSuL.js → generate.runtime-CAn1qIQ_.js} +4 -4
- package/dist/chunks/generate.runtime-CAn1qIQ_.js.map +1 -0
- package/dist/chunks/{generate.runtime-CuNhY5hn.js → generate.runtime-CEqLgLT9.js} +16 -11
- package/dist/chunks/generate.runtime-CEqLgLT9.js.map +1 -0
- package/dist/chunks/{generate.runtime-B1jVAnDI.js → generate.runtime-CK10Mum5.js} +8 -8
- package/dist/chunks/generate.runtime-CK10Mum5.js.map +1 -0
- package/dist/chunks/{generate.runtime-DqD3PW-W.js → generate.runtime-CZ46nkSL.js} +3 -3
- package/dist/chunks/generate.runtime-CZ46nkSL.js.map +1 -0
- package/dist/chunks/{generate.runtime-CslAvllQ.js → generate.runtime-CbE9RHcf.js} +5 -5
- package/dist/chunks/generate.runtime-CbE9RHcf.js.map +1 -0
- package/dist/chunks/{generate.runtime-CCr1lvo4.js → generate.runtime-CpMKXBkn.js} +7 -7
- package/dist/chunks/generate.runtime-CpMKXBkn.js.map +1 -0
- package/dist/chunks/{generate.runtime-6FXJM8hT.js → generate.runtime-CqncBFNg.js} +5 -5
- package/dist/chunks/generate.runtime-CqncBFNg.js.map +1 -0
- package/dist/chunks/generate.runtime-DG2z6kqH.js +68 -0
- package/dist/chunks/generate.runtime-DG2z6kqH.js.map +1 -0
- package/dist/chunks/{generate.runtime-C6bSvGMb.js → generate.runtime-DHHlYfTD.js} +6 -6
- package/dist/chunks/generate.runtime-DHHlYfTD.js.map +1 -0
- package/dist/chunks/generate.runtime-DJ9MVVPC.js +325 -0
- package/dist/chunks/generate.runtime-DJ9MVVPC.js.map +1 -0
- package/dist/chunks/{generate.runtime-CnPraLKv.js → generate.runtime-DVB7uuht.js} +4 -4
- package/dist/chunks/generate.runtime-DVB7uuht.js.map +1 -0
- package/dist/chunks/{generate.runtime-kvxmTlQb.js → generate.runtime-Db0HZyj3.js} +3 -3
- package/dist/chunks/{generate.runtime-kvxmTlQb.js.map → generate.runtime-Db0HZyj3.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D_sQOeQa.js → generate.runtime-Djas9UNy.js} +6 -6
- package/dist/chunks/generate.runtime-Djas9UNy.js.map +1 -0
- package/dist/chunks/{generate.runtime-Ce_rwzNa.js → generate.runtime-Dl6OQ7pe.js} +4 -4
- package/dist/chunks/generate.runtime-Dl6OQ7pe.js.map +1 -0
- package/dist/chunks/{generate.runtime-1-91UmM8.js → generate.runtime-DoZJHtZh.js} +4 -4
- package/dist/chunks/generate.runtime-DoZJHtZh.js.map +1 -0
- package/dist/chunks/generate.runtime-Dp7SsCQG.js +42 -0
- package/dist/chunks/generate.runtime-Dp7SsCQG.js.map +1 -0
- package/dist/chunks/{generate.runtime-C8zJRNYG.js → generate.runtime-E-zoeSKW.js} +5 -5
- package/dist/chunks/generate.runtime-E-zoeSKW.js.map +1 -0
- package/dist/chunks/{generate.runtime-pVLzzpUM.js → generate.runtime-EQnytCFL.js} +40 -40
- package/dist/chunks/generate.runtime-EQnytCFL.js.map +1 -0
- package/dist/chunks/generate.runtime-IWEhGhWY.js +218 -0
- package/dist/chunks/generate.runtime-IWEhGhWY.js.map +1 -0
- package/dist/chunks/{generate.runtime-CYagyR5c.js → generate.runtime-a3R4hqFy.js} +6 -6
- package/dist/chunks/generate.runtime-a3R4hqFy.js.map +1 -0
- package/dist/chunks/{generate.runtime-zJpEufTc.js → generate.runtime-aQnBmH8D.js} +9 -9
- package/dist/chunks/generate.runtime-aQnBmH8D.js.map +1 -0
- package/dist/chunks/{generate.runtime-Dtgw9IQO.js → generate.runtime-axm9wcQv.js} +5 -5
- package/dist/chunks/generate.runtime-axm9wcQv.js.map +1 -0
- package/dist/chunks/{generate.runtime-DHBRyMAq.js → generate.runtime-hTKzxH2M.js} +5 -5
- package/dist/chunks/generate.runtime-hTKzxH2M.js.map +1 -0
- package/dist/chunks/{generate.runtime-BA3tDKnn.js → generate.runtime-kciwaXxh.js} +5 -5
- package/dist/chunks/generate.runtime-kciwaXxh.js.map +1 -0
- package/dist/chunks/{generate.runtime-B_UVGa3q.js → generate.runtime-koQxLywh.js} +5 -5
- package/dist/chunks/generate.runtime-koQxLywh.js.map +1 -0
- package/dist/chunks/{generate.runtime-BXkZob1O.js → generate.runtime-rs1ZOIET.js} +6 -6
- package/dist/chunks/{generate.runtime-BXkZob1O.js.map → generate.runtime-rs1ZOIET.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DV3WmZtb.js → generate.runtime-uLUiPgqx.js} +6 -6
- package/dist/chunks/generate.runtime-uLUiPgqx.js.map +1 -0
- package/dist/chunks/lib-specifier-Cngo1zF_.js.map +1 -1
- package/dist/chunks/logger-CQONztPm.js.map +1 -1
- package/dist/chunks/{modify-file-BlDeeurK.js → modify-file-DK-tCH9k.js} +3 -3
- package/dist/chunks/modify-file-DK-tCH9k.js.map +1 -0
- package/dist/chunks/modify-nav-user-BLyrW2sK.js +71 -0
- package/dist/chunks/modify-nav-user-BLyrW2sK.js.map +1 -0
- package/dist/chunks/{modify-svelte-config-remote-p0TfVzxm.js → modify-svelte-config-remote-DhuRX4FI.js} +2 -2
- package/dist/chunks/modify-svelte-config-remote-DhuRX4FI.js.map +1 -0
- package/dist/chunks/modify-user-signup-BbqTiUuA.js +54 -0
- package/dist/chunks/modify-user-signup-BbqTiUuA.js.map +1 -0
- package/dist/chunks/modify-utils-Cw-on_cL.js.map +1 -1
- package/dist/chunks/package-imports-Bbw3iMPg.js.map +1 -1
- package/dist/chunks/pocketbase-C5GS-Dh5.js.map +1 -1
- package/dist/chunks/{pocketbase-Dry6ry17.js → pocketbase-CgwbH1gI.js} +2 -2
- package/dist/chunks/pocketbase-CgwbH1gI.js.map +1 -0
- package/dist/chunks/pocketbase-DpudAAmd.js.map +1 -1
- package/dist/chunks/providers-BHR6-XZ7.js.map +1 -1
- package/dist/chunks/{shared-CZC4d7Uj.js → shared-Cc_ns5-y.js} +2 -2
- package/dist/chunks/shared-Cc_ns5-y.js.map +1 -0
- package/dist/chunks/{site-BwCA18Sv.js → site-lj0CDdQ1.js} +2 -2
- package/dist/chunks/site-lj0CDdQ1.js.map +1 -0
- package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -1
- package/dist/chunks/{table-core-AjBpYi-y.js → table-core-DhDqT03G.js} +2 -2
- package/dist/chunks/table-core-DhDqT03G.js.map +1 -0
- package/dist/chunks/{taggedTemplateLiteral-Dx0fjWiw.js → taggedTemplateLiteral-CswN2AAa.js} +1 -1
- package/dist/chunks/{test-setup-DEmWd9Ul.js → test-setup-B9fQ5L_-.js} +5 -5
- package/dist/chunks/test-setup-B9fQ5L_-.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-CDW4lhox.js → ts-morph-helpers-Bepc-Es2.js} +27 -23
- package/dist/chunks/ts-morph-helpers-Bepc-Es2.js.map +1 -0
- package/dist/chunks/{ui-X698F10c.js → ui-CuCsupFq.js} +3 -3
- package/dist/chunks/ui-CuCsupFq.js.map +1 -0
- package/dist/chunks/ui-DD4NltyN.js.map +1 -1
- package/dist/chunks/{unmodify-load-CyGzC1Hu.js → unmodify-load-Bl5vXQiL.js} +2 -2
- package/dist/chunks/unmodify-load-Bl5vXQiL.js.map +1 -0
- package/dist/chunks/util-BLYliuUK.js.map +1 -1
- package/dist/chunks/whatsapp-CguKGTtw.js +105 -0
- package/dist/chunks/whatsapp-CguKGTtw.js.map +1 -0
- package/dist/chunks/{write-result-B68lvI57.js → write-result-DiZsCS_y.js} +5 -5
- package/dist/chunks/write-result-DiZsCS_y.js.map +1 -0
- package/dist/index.d.ts +133 -1
- package/dist/index.js +2240 -2005
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/_layout-kkgN0IF7.js.map +0 -1
- package/dist/chunks/collections-Dz2fvKnz.js.map +0 -1
- package/dist/chunks/compose-handle-D_Rz3Fzo.js.map +0 -1
- package/dist/chunks/config-target-Dx3w6WSk.js.map +0 -1
- package/dist/chunks/constants-BjyMU5s8.js.map +0 -1
- package/dist/chunks/dispatch-CXOXPLFk.js +0 -6
- package/dist/chunks/dispatch-CXOXPLFk.js.map +0 -1
- package/dist/chunks/env-vars-C1NUX-bf.js.map +0 -1
- package/dist/chunks/format-result-DZ8De8KY.js.map +0 -1
- package/dist/chunks/generate-BW3l5Fxw.js.map +0 -1
- package/dist/chunks/generate-DeaBlnK6.js.map +0 -1
- package/dist/chunks/generate-Gcc8iRkZ.js.map +0 -1
- package/dist/chunks/generate-WMJo3QGZ.js.map +0 -1
- package/dist/chunks/generate.runtime-1-91UmM8.js.map +0 -1
- package/dist/chunks/generate.runtime-6FXJM8hT.js.map +0 -1
- package/dist/chunks/generate.runtime-B1jVAnDI.js.map +0 -1
- package/dist/chunks/generate.runtime-BA3tDKnn.js.map +0 -1
- package/dist/chunks/generate.runtime-BO778G0r.js +0 -188
- package/dist/chunks/generate.runtime-BO778G0r.js.map +0 -1
- package/dist/chunks/generate.runtime-B_UVGa3q.js.map +0 -1
- package/dist/chunks/generate.runtime-C6bSvGMb.js.map +0 -1
- package/dist/chunks/generate.runtime-C8zJRNYG.js.map +0 -1
- package/dist/chunks/generate.runtime-CA7Ofjlx.js.map +0 -1
- package/dist/chunks/generate.runtime-CCr1lvo4.js.map +0 -1
- package/dist/chunks/generate.runtime-CYagyR5c.js.map +0 -1
- package/dist/chunks/generate.runtime-Ce_rwzNa.js.map +0 -1
- package/dist/chunks/generate.runtime-CexC1Oky.js +0 -269
- package/dist/chunks/generate.runtime-CexC1Oky.js.map +0 -1
- package/dist/chunks/generate.runtime-CnPraLKv.js.map +0 -1
- package/dist/chunks/generate.runtime-CslAvllQ.js.map +0 -1
- package/dist/chunks/generate.runtime-CuNhY5hn.js.map +0 -1
- package/dist/chunks/generate.runtime-DD51OSuL.js.map +0 -1
- package/dist/chunks/generate.runtime-DHBRyMAq.js.map +0 -1
- package/dist/chunks/generate.runtime-DV3WmZtb.js.map +0 -1
- package/dist/chunks/generate.runtime-D_sQOeQa.js.map +0 -1
- package/dist/chunks/generate.runtime-DqD3PW-W.js.map +0 -1
- package/dist/chunks/generate.runtime-Dtgw9IQO.js.map +0 -1
- package/dist/chunks/generate.runtime-IlBCcXvv.js.map +0 -1
- package/dist/chunks/generate.runtime-cwvAoKoH.js.map +0 -1
- package/dist/chunks/generate.runtime-pVLzzpUM.js.map +0 -1
- package/dist/chunks/generate.runtime-zJpEufTc.js.map +0 -1
- package/dist/chunks/modify-file-BlDeeurK.js.map +0 -1
- package/dist/chunks/modify-svelte-config-remote-p0TfVzxm.js.map +0 -1
- package/dist/chunks/nav-user-BRIHOOpG.js +0 -6
- package/dist/chunks/nav-user-BRIHOOpG.js.map +0 -1
- package/dist/chunks/pocketbase-Dry6ry17.js.map +0 -1
- package/dist/chunks/shared-CZC4d7Uj.js.map +0 -1
- package/dist/chunks/site-BwCA18Sv.js.map +0 -1
- package/dist/chunks/table-core-AjBpYi-y.js.map +0 -1
- package/dist/chunks/test-setup-DEmWd9Ul.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-CDW4lhox.js.map +0 -1
- package/dist/chunks/ui-X698F10c.js.map +0 -1
- package/dist/chunks/unmodify-load-CyGzC1Hu.js.map +0 -1
- package/dist/chunks/write-result-B68lvI57.js.map +0 -1
|
@@ -1,116 +1,69 @@
|
|
|
1
1
|
import { a as e } from "./util-BLYliuUK.js";
|
|
2
2
|
import { t } from "./dedent-Gq6Krl4n.js";
|
|
3
|
-
import { t as n } from "./taggedTemplateLiteral-
|
|
3
|
+
import { t as n } from "./taggedTemplateLiteral-CswN2AAa.js";
|
|
4
4
|
import { n as r } from "./logger-CQONztPm.js";
|
|
5
5
|
import { t as i } from "./env-BPfk1VAw.js";
|
|
6
|
-
import {
|
|
7
|
-
import { modifyOutcomeToFile as
|
|
8
|
-
import { modifyEnvVarsFiles as
|
|
9
|
-
import { t as
|
|
10
|
-
import { i as
|
|
11
|
-
import { t as
|
|
12
|
-
import {
|
|
6
|
+
import { t as a } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
7
|
+
import { modifyOutcomeToFile as o } from "./modify-file-DK-tCH9k.js";
|
|
8
|
+
import { modifyEnvVarsFiles as s } from "./env-vars-CcE6ODqC.js";
|
|
9
|
+
import { t as c } from "./svelte-file-B3RfgVdt.js";
|
|
10
|
+
import { i as l, n as u, t as d } from "./pocketbase-CgwbH1gI.js";
|
|
11
|
+
import { t as f } from "./env-vars-De0Xs0L2.js";
|
|
12
|
+
import { t as p } from "./modify-user-signup-BbqTiUuA.js";
|
|
13
|
+
import { createCollectionIdempotent as m } from "./collections-zzZ_HQxB.js";
|
|
13
14
|
import h from "node:fs";
|
|
14
15
|
import g from "node:path";
|
|
15
|
-
import
|
|
16
|
-
import b from "stripe";
|
|
16
|
+
import _ from "stripe";
|
|
17
17
|
//#region src/patterns/enable/payments/modifies/modify-nav-user.ts
|
|
18
|
-
var
|
|
18
|
+
var v = [
|
|
19
19
|
"import CreditCardIcon from '@lucide/svelte/icons/credit-card';",
|
|
20
20
|
"",
|
|
21
21
|
"// Add to your navUser array:",
|
|
22
22
|
"{ title: 'Billing', url: '/billing', icon: CreditCardIcon }"
|
|
23
|
-
].join("\n"),
|
|
23
|
+
].join("\n"), y = [
|
|
24
24
|
"Add a Billing nav item to nav-user.svelte:",
|
|
25
25
|
"",
|
|
26
|
-
|
|
27
|
-
].join("\n"),
|
|
26
|
+
v
|
|
27
|
+
].join("\n"), b = [
|
|
28
28
|
"Create nav-user.svelte with a Billing entry:",
|
|
29
29
|
"",
|
|
30
|
-
|
|
30
|
+
v
|
|
31
31
|
].join("\n");
|
|
32
|
-
function
|
|
33
|
-
let
|
|
32
|
+
function x(e, t, n, r, i) {
|
|
33
|
+
let o = new c(e), s = !1, l = (e) => {
|
|
34
34
|
s || e((e) => {
|
|
35
|
-
let
|
|
36
|
-
return
|
|
35
|
+
let o = a(e, t, n, r, i);
|
|
36
|
+
return o.wasAdded && (s = !0), o.source;
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
-
return
|
|
40
|
-
newNavUserSnippet:
|
|
39
|
+
return l((e) => o.modifyModuleScript(e)), s || l((e) => o.modifyScript(e)), {
|
|
40
|
+
newNavUserSnippet: o.toString(),
|
|
41
41
|
wasAdded: s
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function S(e) {
|
|
45
45
|
if (!h.existsSync(e)) return {
|
|
46
46
|
status: "not-found",
|
|
47
|
-
message:
|
|
47
|
+
message: b
|
|
48
48
|
};
|
|
49
49
|
let t = h.readFileSync(e, "utf8");
|
|
50
50
|
if (t.includes("/billing")) return {
|
|
51
51
|
status: "success",
|
|
52
52
|
changed: !1
|
|
53
53
|
};
|
|
54
|
-
let { newNavUserSnippet: n, wasAdded: r } =
|
|
54
|
+
let { newNavUserSnippet: n, wasAdded: r } = x(t, "Billing", "/billing", "CreditCardIcon", "@lucide/svelte/icons/credit-card");
|
|
55
55
|
return r ? (h.writeFileSync(e, n, "utf8"), {
|
|
56
56
|
status: "success",
|
|
57
57
|
changed: !0
|
|
58
58
|
}) : {
|
|
59
59
|
status: "failed",
|
|
60
|
-
message:
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/patterns/enable/payments/modifies/modify-user-signup.ts
|
|
65
|
-
var E = "#lib/workflows/link-stripe-customer.js", D = t`
|
|
66
|
-
// Queued here, done in the background: the Stripe calls retry on their own,
|
|
67
|
-
// and the key means a retry never makes a second customer for this user.
|
|
68
|
-
await linkStripeCustomer.run(
|
|
69
|
-
{ userId: user.id, email: form.data.email },
|
|
70
|
-
{ idempotencyKey: user.id }
|
|
71
|
-
);
|
|
72
|
-
`, O = [
|
|
73
|
-
"Could not locate the requestVerification call in signup +page.server.ts.",
|
|
74
|
-
"Start the workflow once the user exists:",
|
|
75
|
-
"",
|
|
76
|
-
`import { linkStripeCustomer } from '${E}';`,
|
|
77
|
-
"",
|
|
78
|
-
D
|
|
79
|
-
].join("\n"), k = ["Create src/routes/(public)/(auth)/signup/+page.server.ts before enabling payments."].join("\n");
|
|
80
|
-
function A(e) {
|
|
81
|
-
if (!h.existsSync(e)) return {
|
|
82
|
-
status: "not-found",
|
|
83
|
-
message: k
|
|
84
|
-
};
|
|
85
|
-
let t = h.readFileSync(e, "utf8");
|
|
86
|
-
if (t.includes("linkStripeCustomer")) return {
|
|
87
|
-
status: "success",
|
|
88
|
-
changed: !1
|
|
89
|
-
};
|
|
90
|
-
let n = new _({ manipulationSettings: { quoteKind: v.Single } }).addSourceFileAtPath(e), r = n.getDescendantsOfKind(y.CallExpression).find((e) => {
|
|
91
|
-
let t = e.getExpression();
|
|
92
|
-
return t.getKind() === y.PropertyAccessExpression && t.getText().includes("requestVerification");
|
|
93
|
-
});
|
|
94
|
-
if (!r) return {
|
|
95
|
-
status: "failed",
|
|
96
|
-
message: O
|
|
97
|
-
};
|
|
98
|
-
let i = r.getFirstAncestorByKind(y.ExpressionStatement);
|
|
99
|
-
return i ? (n.addImportDeclaration({
|
|
100
|
-
namedImports: ["linkStripeCustomer"],
|
|
101
|
-
moduleSpecifier: E
|
|
102
|
-
}), i.replaceWithText(D + "\n\n" + i.getText()), a(n), n.saveSync(), {
|
|
103
|
-
status: "success",
|
|
104
|
-
changed: n.getFullText() !== t
|
|
105
|
-
}) : {
|
|
106
|
-
status: "failed",
|
|
107
|
-
message: O
|
|
60
|
+
message: y
|
|
108
61
|
};
|
|
109
62
|
}
|
|
110
63
|
//#endregion
|
|
111
64
|
//#region src/patterns/enable/payments/runtime/stripe.ts
|
|
112
|
-
async function
|
|
113
|
-
let r = new
|
|
65
|
+
async function C(e, t, n) {
|
|
66
|
+
let r = new _(t), i = await e.collection("users").getFullList(), a = await e.collection("stripe_customers").getFullList(), o = new Set(a.map((e) => e.user)), s = {
|
|
114
67
|
total: i.length,
|
|
115
68
|
linked: o.size,
|
|
116
69
|
created: 0,
|
|
@@ -122,49 +75,48 @@ async function j(e, t, n) {
|
|
|
122
75
|
s.skipped += 1;
|
|
123
76
|
continue;
|
|
124
77
|
}
|
|
125
|
-
|
|
126
|
-
n.info(`Skipping user ${t.id} with no email`), s.skipped += 1;
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
let i = await r.customers.list({
|
|
78
|
+
let i = t.email ? await r.customers.list({
|
|
130
79
|
email: t.email,
|
|
131
80
|
limit: 1,
|
|
132
81
|
expand: ["data.invoice_settings"]
|
|
133
|
-
}), a, c = !1;
|
|
134
|
-
i.data.length > 0 ? (
|
|
82
|
+
}) : { data: [] }, a = t.email || t.id, c, l = !1;
|
|
83
|
+
i.data.length > 0 ? (c = i.data[0], l = !0, s.reused += 1, n.info(`Reusing Stripe customer ${c.id} for ${a}`)) : (c = await r.customers.create(t.email ? { email: t.email } : {
|
|
84
|
+
name: t.name || void 0,
|
|
85
|
+
phone: t.phone || void 0
|
|
86
|
+
}), s.created += 1, n.info(`Created Stripe customer ${c.id} for ${a}`));
|
|
135
87
|
try {
|
|
136
88
|
await e.collection("stripe_customers").create({
|
|
137
|
-
id:
|
|
89
|
+
id: c.id,
|
|
138
90
|
user: t.id
|
|
139
91
|
});
|
|
140
92
|
} catch (e) {
|
|
141
|
-
n.info(`Failed to create stripe_customers row for ${
|
|
93
|
+
n.info(`Failed to create stripe_customers row for ${a}: ${e.message}`);
|
|
142
94
|
continue;
|
|
143
95
|
}
|
|
144
|
-
if (!
|
|
145
|
-
let
|
|
96
|
+
if (!l) continue;
|
|
97
|
+
let u = await r.customers.listPaymentMethods(c.id, {
|
|
146
98
|
type: "card",
|
|
147
99
|
allow_redisplay: "always"
|
|
148
100
|
});
|
|
149
|
-
for (let t of
|
|
101
|
+
for (let t of u.data) if (t.allow_redisplay !== "unspecified") try {
|
|
150
102
|
await e.collection("stripe_payment_methods").create({
|
|
151
103
|
id: t.id,
|
|
152
|
-
customer:
|
|
104
|
+
customer: c.id,
|
|
153
105
|
brand: t.card?.brand,
|
|
154
106
|
last4: t.card?.last4,
|
|
155
107
|
exp_month: t.card?.exp_month,
|
|
156
108
|
exp_year: t.card?.exp_year
|
|
157
109
|
});
|
|
158
110
|
} catch {}
|
|
159
|
-
let
|
|
160
|
-
if (
|
|
161
|
-
await e.collection("stripe_customers").update(
|
|
111
|
+
let d = c.invoice_settings?.default_payment_method;
|
|
112
|
+
if (d) try {
|
|
113
|
+
await e.collection("stripe_customers").update(c.id, { default_payment_method: typeof d == "string" ? d : d.id });
|
|
162
114
|
} catch {}
|
|
163
115
|
}
|
|
164
116
|
return s;
|
|
165
117
|
}
|
|
166
|
-
async function
|
|
167
|
-
let t = new
|
|
118
|
+
async function w(e) {
|
|
119
|
+
let t = new _(e), n = await t.products.search({
|
|
168
120
|
query: "name:\"Test Product\" AND metadata[\"test\"]:\"true\"",
|
|
169
121
|
limit: 1
|
|
170
122
|
});
|
|
@@ -194,8 +146,8 @@ async function M(e) {
|
|
|
194
146
|
existing: !1
|
|
195
147
|
};
|
|
196
148
|
}
|
|
197
|
-
async function
|
|
198
|
-
let n = new
|
|
149
|
+
async function T(e, t) {
|
|
150
|
+
let n = new _(e), r = await n.prices.retrieve(t, { expand: ["product"] }), i = typeof r.product == "string" ? await n.products.retrieve(r.product) : r.product;
|
|
199
151
|
return r.product = i.id, {
|
|
200
152
|
product: i,
|
|
201
153
|
price: r,
|
|
@@ -204,11 +156,11 @@ async function N(e, t) {
|
|
|
204
156
|
}
|
|
205
157
|
//#endregion
|
|
206
158
|
//#region src/patterns/enable/payments/generate.runtime.ts
|
|
207
|
-
var
|
|
208
|
-
async function
|
|
159
|
+
var E;
|
|
160
|
+
async function D(t, n, r, i, a = !0) {
|
|
209
161
|
if (!a) return;
|
|
210
|
-
await
|
|
211
|
-
let o =
|
|
162
|
+
await u();
|
|
163
|
+
let o = d(n, r, i);
|
|
212
164
|
o && t.push({
|
|
213
165
|
path: o,
|
|
214
166
|
language: e(o),
|
|
@@ -216,15 +168,15 @@ async function F(t, n, r, i, a = !0) {
|
|
|
216
168
|
status: "success"
|
|
217
169
|
});
|
|
218
170
|
}
|
|
219
|
-
function
|
|
220
|
-
return t(
|
|
171
|
+
function O(e) {
|
|
172
|
+
return t(E ||= n(["\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);
|
|
221
173
|
}
|
|
222
|
-
async function
|
|
223
|
-
let { stripeSecretKey: t, stripePublishableKey: n, stripeWebhookSecret: a, stripePriceId:
|
|
224
|
-
e &&
|
|
174
|
+
async function k(e) {
|
|
175
|
+
let { stripeSecretKey: t, stripePublishableKey: n, stripeWebhookSecret: a, stripePriceId: c } = e.input, u = e.features.auth, d = r(e), h = [], _ = [], v = (e) => {
|
|
176
|
+
e && _.push(e);
|
|
225
177
|
};
|
|
226
178
|
d.info("Writing Stripe credentials to .env");
|
|
227
|
-
let
|
|
179
|
+
let y = [
|
|
228
180
|
{
|
|
229
181
|
type: "comment",
|
|
230
182
|
key: "Stripe credentials"
|
|
@@ -244,10 +196,10 @@ async function L(e) {
|
|
|
244
196
|
key: "STRIPE_WEBHOOK_SECRET",
|
|
245
197
|
value: a
|
|
246
198
|
}
|
|
247
|
-
],
|
|
248
|
-
|
|
249
|
-
let
|
|
250
|
-
|
|
199
|
+
], b = g.join(e.root, ".env");
|
|
200
|
+
v(o(b, i(b, y))), d.info("Declaring Stripe variables in src/env.ts");
|
|
201
|
+
let x = s(e.root, f);
|
|
202
|
+
x.create && h.push(x.create), v(x.modify), await l(e.root, async (n) => {
|
|
251
203
|
let r = (e) => m(n, e, d);
|
|
252
204
|
d.info("Creating stripe_products collection");
|
|
253
205
|
let i = await r({
|
|
@@ -291,7 +243,7 @@ async function L(e) {
|
|
|
291
243
|
}
|
|
292
244
|
]
|
|
293
245
|
});
|
|
294
|
-
await
|
|
246
|
+
await D(h, "stripe_products", "created", e, i.created), d.info("Creating stripe_prices collection");
|
|
295
247
|
let a = await r({
|
|
296
248
|
name: "stripe_prices",
|
|
297
249
|
type: "base",
|
|
@@ -353,7 +305,7 @@ async function L(e) {
|
|
|
353
305
|
}
|
|
354
306
|
]
|
|
355
307
|
});
|
|
356
|
-
if (await
|
|
308
|
+
if (await D(h, "stripe_prices", "created", e, a.created), u) {
|
|
357
309
|
d.info("Creating stripe_customers collection");
|
|
358
310
|
let i = await r({
|
|
359
311
|
name: "stripe_customers",
|
|
@@ -389,7 +341,7 @@ async function L(e) {
|
|
|
389
341
|
}
|
|
390
342
|
]
|
|
391
343
|
}), a = i.collection;
|
|
392
|
-
await
|
|
344
|
+
await D(h, "stripe_customers", "created", e, i.created), d.info("Creating stripe_payment_methods collection");
|
|
393
345
|
let o = await r({
|
|
394
346
|
name: "stripe_payment_methods",
|
|
395
347
|
type: "base",
|
|
@@ -445,7 +397,7 @@ async function L(e) {
|
|
|
445
397
|
}
|
|
446
398
|
]
|
|
447
399
|
}), s = o.collection;
|
|
448
|
-
await
|
|
400
|
+
await D(h, "stripe_payment_methods", "created", e, o.created), d.info("Linking default_payment_method on stripe_customers"), await n.collections.update("stripe_customers", { fields: [
|
|
449
401
|
{
|
|
450
402
|
name: "id",
|
|
451
403
|
pattern: "^[a-zA-Z0-9_]+$",
|
|
@@ -482,7 +434,7 @@ async function L(e) {
|
|
|
482
434
|
onUpdate: !0,
|
|
483
435
|
type: "autodate"
|
|
484
436
|
}
|
|
485
|
-
] }), await
|
|
437
|
+
] }), await D(h, "stripe_customers", "updated", e), d.info("Creating transactions collection");
|
|
486
438
|
let c = await r({
|
|
487
439
|
name: "transactions",
|
|
488
440
|
type: "base",
|
|
@@ -553,52 +505,52 @@ async function L(e) {
|
|
|
553
505
|
}
|
|
554
506
|
]
|
|
555
507
|
});
|
|
556
|
-
await
|
|
557
|
-
let l = await
|
|
508
|
+
await D(h, "transactions", "created", e, c.created), d.info("Syncing existing PocketBase users to Stripe customers");
|
|
509
|
+
let l = await C(n, t, d);
|
|
558
510
|
d.info(`Synced ${l.total} users (created ${l.created}, reused ${l.reused}, skipped ${l.skipped})`);
|
|
559
511
|
}
|
|
560
|
-
}),
|
|
561
|
-
let { product:
|
|
562
|
-
if (
|
|
512
|
+
}), c ? d.info(`Fetching Stripe product/price ${c}`) : d.info("Creating test Stripe product and price");
|
|
513
|
+
let { product: E, price: k, existing: A } = c ? await T(t, c) : await w(t);
|
|
514
|
+
if (A && d.info("Stripe product/price already exists, skipping creation"), d.info("Seeding Stripe product/price records"), await l(e.root, async (e) => {
|
|
563
515
|
try {
|
|
564
|
-
await e.collection("stripe_products").getOne(
|
|
516
|
+
await e.collection("stripe_products").getOne(E.id);
|
|
565
517
|
} catch {
|
|
566
518
|
await e.collection("stripe_products").create({
|
|
567
|
-
id:
|
|
568
|
-
name:
|
|
569
|
-
active:
|
|
570
|
-
default_price:
|
|
519
|
+
id: E.id,
|
|
520
|
+
name: E.name,
|
|
521
|
+
active: E.active,
|
|
522
|
+
default_price: E.default_price
|
|
571
523
|
});
|
|
572
524
|
}
|
|
573
525
|
try {
|
|
574
|
-
await e.collection("stripe_prices").getOne(
|
|
526
|
+
await e.collection("stripe_prices").getOne(k.id);
|
|
575
527
|
} catch {
|
|
576
528
|
await e.collection("stripe_prices").create({
|
|
577
|
-
id:
|
|
578
|
-
billing_scheme:
|
|
579
|
-
currency:
|
|
580
|
-
product:
|
|
581
|
-
recurring:
|
|
582
|
-
type:
|
|
583
|
-
unit_amount:
|
|
584
|
-
active:
|
|
529
|
+
id: k.id,
|
|
530
|
+
billing_scheme: k.billing_scheme,
|
|
531
|
+
currency: k.currency,
|
|
532
|
+
product: k.product,
|
|
533
|
+
recurring: k.recurring,
|
|
534
|
+
type: k.type,
|
|
535
|
+
unit_amount: k.unit_amount,
|
|
536
|
+
active: k.active
|
|
585
537
|
});
|
|
586
538
|
}
|
|
587
|
-
}), d.info("Creating payment +page.svelte"),
|
|
539
|
+
}), d.info("Creating payment +page.svelte"), h.push({
|
|
588
540
|
path: "src/routes/(public)/payment/+page.svelte",
|
|
589
541
|
language: "svelte",
|
|
590
|
-
content:
|
|
542
|
+
content: O(k.id),
|
|
591
543
|
status: "success"
|
|
592
|
-
}),
|
|
544
|
+
}), u) {
|
|
593
545
|
d.info("Modifying nav-user.svelte");
|
|
594
546
|
let t = g.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
595
|
-
|
|
547
|
+
v(o(t, S(t))), d.info("Modifying signup +page.server.ts");
|
|
596
548
|
let n = g.join(e.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
|
|
597
|
-
|
|
549
|
+
v(o(n, p(n)));
|
|
598
550
|
}
|
|
599
551
|
return {
|
|
600
|
-
creates:
|
|
601
|
-
modifies:
|
|
552
|
+
creates: h,
|
|
553
|
+
modifies: _,
|
|
602
554
|
deletes: [],
|
|
603
555
|
components: [],
|
|
604
556
|
packages: [],
|
|
@@ -608,6 +560,6 @@ async function L(e) {
|
|
|
608
560
|
};
|
|
609
561
|
}
|
|
610
562
|
//#endregion
|
|
611
|
-
export {
|
|
563
|
+
export { k as generate };
|
|
612
564
|
|
|
613
|
-
//# sourceMappingURL=generate.runtime-
|
|
565
|
+
//# sourceMappingURL=generate.runtime-BK3mR0Rj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-BK3mR0Rj.js","names":["languageFromPath","_taggedTemplateLiteral","getLogger","modifyEnv","addNavItemToScript","SvelteFile","withPocketbase","migrationDelay","getMigrationFile","STRIPE_ENV_VARS","modifyUserSignup","fs","path","Stripe","BILLING_NAV_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","addItemToNavUser","file","navUserSnippet","wasAdded","tryAdd","run","result","source","title","url","icon","iconImportPath","fn","modifyNavUser","navUserPath","newNavUserSnippet","syncUsersToStripeCustomers","stripe","stripeSecretKey","users","pb","existing","linkedUserIds","c","user","matching","label","customer","isExistingCustomer","logger","error","paymentMethods","paymentMethod","defaultPaymentMethod","createTestProductAndPrice","products","product","prices","getProductAndPriceById","price","priceId","_templateObject","pushMigrationCreates","created","migrationFile","collectionName","action","options","creates","paymentPageSnippet","dedent","generate","isAppMode","modifies","pushResult","envEdits","stripePublishableKey","stripeWebhookSecret","envPath","modifyOutcomeToFile","envVars","modifyEnvVarsFiles","create","createCollectionIdempotent","spec","productsResult","pricesResult","customersResult","stripeCustomersCollection","paymentMethodsResult","stripePaymentMethodsCollection","transactionsResult","syncResult","stripePriceId","userSignupPath"],"sources":["../../src/patterns/enable/payments/modifies/modify-nav-user.ts","../../src/patterns/enable/payments/runtime/stripe.ts","../../src/patterns/enable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BILLING_NAV_SNIPPET = [\n \"import CreditCardIcon from '@lucide/svelte/icons/credit-card';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Billing', url: '/billing', icon: CreditCardIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Billing nav item to nav-user.svelte:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Billing entry:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Billing\",\n \"/billing\",\n \"CreditCardIcon\",\n \"@lucide/svelte/icons/credit-card\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\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 { languageFromPath } from \"../../../core/util\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { createCollectionIdempotent } from \"../../../runtime/collections\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { STRIPE_ENV_VARS } from \"./runtime/env-vars\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { modifyEnv, type EnvEdit } from \"./modifies/modify-env\";\nimport {\n createTestProductAndPrice,\n getProductAndPriceById,\n syncUsersToStripeCustomers,\n} from \"./runtime/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\nexport async function generate(options: Options) {\n const {\n stripeSecretKey,\n stripePublishableKey,\n stripeWebhookSecret,\n stripePriceId,\n } = options.input as {\n stripeSecretKey: string;\n stripePublishableKey: string;\n stripeWebhookSecret: string;\n stripePriceId?: string;\n };\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 logger.info(\"Writing Stripe credentials to .env\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\", value: stripeSecretKey },\n {\n type: \"var\",\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n value: stripePublishableKey,\n },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\", value: stripeWebhookSecret },\n ];\n\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnv(envPath, envEdits)));\n\n logger.info(\"Declaring Stripe variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, STRIPE_ENV_VARS);\n if (envVars.create) creates.push(envVars.create);\n pushResult(envVars.modify);\n\n await withPocketbase(options.root, async (pb) => {\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n logger.info(\"Creating stripe_products collection\");\n const productsResult = await create({\n name: \"stripe_products\",\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: \"name\", required: false, type: \"text\" },\n { name: \"active\", required: false, type: \"text\" },\n { name: \"default_price\", required: false, type: \"text\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_products\",\n \"created\",\n options,\n productsResult.created,\n );\n\n logger.info(\"Creating stripe_prices collection\");\n const pricesResult = await create({\n name: \"stripe_prices\",\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: \"billing_scheme\", required: false, type: \"text\" },\n { name: \"currency\", required: false, type: \"text\" },\n { name: \"product\", required: false, type: \"text\" },\n { name: \"recurring\", required: false, type: \"json\" },\n { name: \"type\", required: false, type: \"text\" },\n { name: \"unit_amount\", required: false, type: \"number\" },\n { name: \"active\", required: false, type: \"bool\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_prices\",\n \"created\",\n options,\n pricesResult.created,\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"],"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AAM;IACtB,UAAUA,EAAM;IAChB,SAASA,EAAM;IACf,WAAWA,EAAM;IACjB,MAAMA,EAAM;IACZ,aAAaA,EAAM;IACnB,QAAQA,EAAM;GAChB,CAAC;EACH;CACF,CAAC,GAEDV,EAAO,KAAK,+BAA+B,GAC3CmB,EAAQ,KAAK;EACX,MAAM;EACN,UAAU;EACV,SAASC,EAAmBV,EAAM,EAAE;EACpC,QAAQ;CACV,CAAC,GAEGa,GAAW;EACb,EAAO,KAAK,2BAA2B;EACvC,IAAMtC,IAAcnB,EAAK,KACvBoD,EAAQ,MACR,OACA,OACA,cACA,iBACF;EAGA,AAFAO,EAAWK,EAAoB7C,GAAaD,EAAcC,CAAW,CAAC,CAAC,GAEvEe,EAAO,KAAK,kCAAkC;EAC9C,IAAM6C,IAAiB/E,EAAK,KAC1BoD,EAAQ,MACR,OACA,UACA,YACA,UACA,UACA,iBACF;EACA,EACEY,EAAoBe,GAAgBjF,EAAiBiF,CAAc,CAAC,CACtE;CACF;CAEA,OAAO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { o as n, t as r } from "./ts-morph-helpers-
|
|
4
|
-
import { modifyOutcomeToFile as i } from "./modify-file-
|
|
3
|
+
import { o as n, t as r } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
4
|
+
import { modifyOutcomeToFile as i } from "./modify-file-DK-tCH9k.js";
|
|
5
5
|
import { t as a } from "./svelte-file-B3RfgVdt.js";
|
|
6
6
|
import { t as o } from "./modify-utils-Cw-on_cL.js";
|
|
7
7
|
import s from "node:fs";
|
|
@@ -160,4 +160,4 @@ async function y(e) {
|
|
|
160
160
|
//#endregion
|
|
161
161
|
export { y as generate };
|
|
162
162
|
|
|
163
|
-
//# sourceMappingURL=generate.runtime-
|
|
163
|
+
//# sourceMappingURL=generate.runtime-BpMN5Uq-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-BpMN5Uq-.js","names":["FAILURE_HINT","NOT_FOUND_HINT","dedent","getLogger","formatLikeSource","addNavItemToScript","SvelteFile","modifyUtils","fs","path","FAILURE_HINT$1","NOT_FOUND_HINT$1","modifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","apiInit","apiObj","apiKeysProp","keysInit","keysObj","API_KEYS_NAV_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","addItemToNavUser","file","navUserSnippet","wasAdded","tryAdd","run","result","source","title","url","icon","iconImportPath","fn","modifyNavUser","navUserPath","newNavUserSnippet","generate","logger","options","modifies","pushResult","modifyOutcomeToFile","utilsPath"],"sources":["../../src/patterns/enable/api-keys/modifies/hooks.server.ts","../../src/patterns/enable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/enable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with API keys in hooks.server.ts:\n\n handlePocketbase({\n api: {\n enabled: true,\n apiKeys: { enabled: true },\n },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: {\n enabled: true,\n apiKeys: { enabled: true },\n },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(\n 0,\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true, apiKeys: { enabled: true } }`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n apiObj.addPropertyAssignment({\n name: \"apiKeys\",\n initializer: `{ enabled: true }`,\n });\n } else if (apiKeysProp.getKind() === SyntaxKind.PropertyAssignment) {\n const keysInit = (\n apiKeysProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (\n keysInit &&\n keysInit.getKind() === SyntaxKind.ObjectLiteralExpression\n ) {\n const keysObj =\n keysInit as import(\"ts-morph\").ObjectLiteralExpression;\n const keysEnabled = keysObj.getProperty(\"enabled\");\n if (!keysEnabled) {\n keysObj.addPropertyAssignment({\n name: \"enabled\",\n initializer: \"true\",\n });\n }\n } else {\n (apiKeysProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `{ enabled: true }`,\n );\n }\n }\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst API_KEYS_NAV_SNIPPET = [\n \"import KeyRoundIcon from '@lucide/svelte/icons/key-round';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'API Keys', url: '/api-keys', icon: KeyRoundIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add an API Keys nav item to nav-user.svelte:\",\n \"\",\n API_KEYS_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with an API Keys entry:\",\n \"\",\n API_KEYS_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"API Keys\",\n \"/api-keys\",\n \"KeyRoundIcon\",\n \"@lucide/svelte/icons/key-round\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyUtils } from \"../../../runtime/modify-utils\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifyNavUser } from \"./modifies/nav-user.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, modifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Modifying nav-user\");\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 utils.ts\");\n const utilsPath = path.join(options.root, \"src\", \"lib\", \"utils.ts\");\n pushResult(modifyOutcomeToFile(utilsPath, modifyUtils(utilsPath)));\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":";;;;;;;;;;AAMA,IAAMA,IAAe,CAAM;;;;;;;;;GAWrBC,IAAiB,CAAM;;;;;;;;;;;;AAa7B,SAAgBW,EAAkB,GAAwC;CACxE,IAAI,CAACJ,EAAG,WAAWK,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAa,SAASZ;CAAe;CAGxD,IAAMa,IAAiBN,EAAG,aAAaK,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CAEnE,IAAI,CAACF,GACH,OAAO;EAAE,QAAQ;EAAU,SAASjB;CAAa;CAGnD,IAAMoB,IAAOH,EAAS,aAAa;CACnC,IAAIG,EAAK,WAAW,GAMlB,OALAH,EAAS,YACP,wDACF,GACAb,EAAiBW,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMM,IAAWD,EAAK;CACtB,IAAIC,EAAS,QAAQ,MAAMH,EAAW,yBAOpC,OANAD,EAAS,eACP,GACA,wDACF,GACAb,EAAiBW,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMO,IAAaD,EAAS,cAAcH,EAAW,uBAAuB,GAEtEK,IAAUD,EAAW,YAAY,KAAK;CAC5C,IAAI,CAACC,GAOH,OANAD,EAAW,sBAAsB;EAC/B,MAAM;EACN,aAAa;CACf,CAAC,GACDlB,EAAiBW,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAIQ,EAAQ,QAAQ,MAAML,EAAW,oBAAoB;EAC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,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { _ as n, o as r, r as i } from "./ts-morph-helpers-
|
|
4
|
-
import { modifyOutcomeToFile as a } from "./modify-file-
|
|
3
|
+
import { _ as n, o as r, r as i } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
4
|
+
import { modifyOutcomeToFile as a } from "./modify-file-DK-tCH9k.js";
|
|
5
5
|
import { t as o } from "./svelte-file-B3RfgVdt.js";
|
|
6
|
-
import { t as s } from "./compose-handle-
|
|
6
|
+
import { t as s } from "./compose-handle-BDlZ7Pif.js";
|
|
7
7
|
import c from "node:fs";
|
|
8
8
|
import l from "node:path";
|
|
9
9
|
import { Project as u, QuoteKind as d, SyntaxKind as f } from "ts-morph";
|
|
@@ -189,4 +189,4 @@ async function T(e) {
|
|
|
189
189
|
//#endregion
|
|
190
190
|
export { T as generate };
|
|
191
191
|
|
|
192
|
-
//# sourceMappingURL=generate.runtime-
|
|
192
|
+
//# sourceMappingURL=generate.runtime-CAn1qIQ_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-CAn1qIQ_.js","names":["FAILURE_HINT","dedent","getLogger","withInMemoryScript","formatLikeSource","ensureImports","SvelteFile","addHandle","fs","path","FAILURE_HINT$1","HOOKS_SERVER_SNIPPET","ensureNegotiateHandleImport","existing","sourceFile","d","ni","modifyHooksServerNegotiate","hooksServerPath","original","Project","QuoteKind","NEGOTIATE_ONLY_SNIPPET","FAILURE_HINT","ensureNegotiateImport","modifyHooksNegotiate","hooksPath","rerouteDecl","SyntaxKind","init","hasI18nHelper","initText","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","modifyRootLayoutNegotiate","layoutPath","file","out","source","sf","generate","logger","options","modifies","pushResult","modifyOutcomeToFile","rootLayoutPath"],"sources":["../../src/patterns/enable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/enable/content-negotiation/modifies/hooks.ts","../../src/patterns/enable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/enable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the negotiation handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n\n export const handle = sequence(handleNegotiate, /* your existing handle */);\n`;\n\nconst HOOKS_SERVER_SNIPPET = dedent`\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n\n export const handle = handleNegotiate;\n`;\n\nfunction ensureNegotiateHandleImport(sourceFile: SourceFile) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"#lib/negotiate.js\");\n if (existing) {\n const has = existing.getNamedImports().some((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n if (!has)\n existing.addNamedImport({ name: \"handle\", alias: \"handleNegotiate\" });\n return;\n }\n sourceFile.addImportDeclaration({\n namedImports: [{ name: \"handle\", alias: \"handleNegotiate\" }],\n moduleSpecifier: \"#lib/negotiate.js\",\n });\n}\n\nexport function modifyHooksServerNegotiate(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"handleNegotiate\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const composed = addHandle(sourceFile, { expression: \"handleNegotiate\" });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureNegotiateHandleImport(sourceFile);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst NEGOTIATE_ONLY_SNIPPET = dedent`\n import { reroute as negotiateReroute } from '#lib/negotiate.js';\n\n export const reroute = ({ url }) => negotiateReroute(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the negotiation reroute:\n\n import { reroute as negotiateReroute } from '#lib/negotiate.js';\n\n export const reroute = ({ url }) => existingReroute(negotiateReroute(url.pathname));\n`;\n\nfunction ensureNegotiateImport(sourceFile: SourceFile) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"#lib/negotiate.js\");\n if (existing) {\n const has = existing.getNamedImports().some((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!has) {\n existing.addNamedImport({ name: \"reroute\", alias: \"negotiateReroute\" });\n }\n return;\n }\n sourceFile.addImportDeclaration({\n namedImports: [{ name: \"reroute\", alias: \"negotiateReroute\" }],\n moduleSpecifier: \"#lib/negotiate.js\",\n });\n}\n\nexport function modifyHooksNegotiate(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, NEGOTIATE_ONLY_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (original.includes(\"negotiateReroute\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n\n if (!rerouteDecl) {\n ensureNegotiateImport(sourceFile);\n sourceFile.addStatements(\n `\\nexport const reroute = ({ url }) => negotiateReroute(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n const initText = init.getText();\n\n if (hasI18nHelper && initText.includes(\"rerouteDeLocalize\")) {\n ensureNegotiateImport(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n return { status: \"failed\", message: FAILURE_HINT };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { Negotiate } from '#lib/negotiate.js';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Negotiate />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root +layout.svelte and mount <Negotiate /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nexport function modifyRootLayoutNegotiate(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"Negotiate\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"Negotiate\"],\n moduleSpecifier: \"#lib/negotiate.js\",\n },\n ]);\n });\n return out;\n });\n\n file.appendMarkup(MARKUP_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\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 { modifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { modifyHooksNegotiate } from \"./modifies/hooks\";\nimport { modifyRootLayoutNegotiate } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerNegotiate(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksNegotiate(hooksPath)));\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyRootLayoutNegotiate(rootLayoutPath),\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":";;;;;;;;;;AAQA,IAAMA,IAAe,CAAM;;;;;;;GASrBW,IAAuB,CAAM;;;;;AAMnC,SAASC,EAA4B,GAAwB;CAC3D,IAAMC,IAAWC,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,wBAAwB,MAAM,mBAAmB;CAClE,IAAIF,GAAU;EAOZ,AANYA,EAAS,gBAAgB,CAAC,CAAC,MAAM,MAEzCG,EAAG,QAAQ,MAAM,YACjBA,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAGhC,KACHH,EAAS,eAAe;GAAE,MAAM;GAAU,OAAO;EAAkB,CAAC;EACtE;CACF;CACA,EAAW,qBAAqB;EAC9B,cAAc,CAAC;GAAE,MAAM;GAAU,OAAO;EAAkB,CAAC;EAC3D,iBAAiB;CACnB,CAAC;AACH;AAEA,SAAgBI,EACd,GACe;CACf,IAAI,CAACT,EAAG,WAAWU,CAAe,GAQhC,OALIV,EAAG,WAAWU,EAAgB,QAAQ,SAAS,KAAK,CAAC,IAChD;EAAE,QAAQ;EAAU,SAASlB;CAAa,KAEnDQ,EAAG,UAAUC,EAAK,QAAQS,CAAe,GAAG,EAAE,WAAW,GAAK,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