@velastack/patterns 0.0.45 → 0.0.46
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/{collections-DeT38X6O.js → collections-BwO27pJg.js} +2 -2
- package/dist/chunks/{collections-DeT38X6O.js.map → collections-BwO27pJg.js.map} +1 -1
- package/dist/chunks/{env-KcKcG4Mg.js → env-Bk-LRVos.js} +1 -1
- package/dist/chunks/{env-KcKcG4Mg.js.map → env-Bk-LRVos.js.map} +1 -1
- package/dist/chunks/env.runtime-D46GCIKe.js +31 -0
- package/dist/chunks/env.runtime-D46GCIKe.js.map +1 -0
- package/dist/chunks/{generate.runtime-AgF-_CuZ.js → generate.runtime-Bbf2YWaA.js} +1 -1
- package/dist/chunks/{generate.runtime-AgF-_CuZ.js.map → generate.runtime-Bbf2YWaA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BhJKZmLN.js → generate.runtime-BkvtIjgh.js} +2 -2
- package/dist/chunks/{generate.runtime-BhJKZmLN.js.map → generate.runtime-BkvtIjgh.js.map} +1 -1
- package/dist/chunks/{generate.runtime-VhD6Bmgq.js → generate.runtime-BnkNmF1g.js} +1 -1
- package/dist/chunks/{generate.runtime-VhD6Bmgq.js.map → generate.runtime-BnkNmF1g.js.map} +1 -1
- package/dist/chunks/{generate.runtime-RfPLo7XV.js → generate.runtime-Bpx69a8t.js} +4 -4
- package/dist/chunks/{generate.runtime-RfPLo7XV.js.map → generate.runtime-Bpx69a8t.js.map} +1 -1
- package/dist/chunks/{generate.runtime-WWvlaFF2.js → generate.runtime-CEtVUz4k.js} +3 -3
- package/dist/chunks/{generate.runtime-WWvlaFF2.js.map → generate.runtime-CEtVUz4k.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C0kTnsI4.js → generate.runtime-CUgleG0U.js} +1 -1
- package/dist/chunks/{generate.runtime-C0kTnsI4.js.map → generate.runtime-CUgleG0U.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DL1Ik7b6.js → generate.runtime-Cb2vYF1l.js} +1 -1
- package/dist/chunks/{generate.runtime-DL1Ik7b6.js.map → generate.runtime-Cb2vYF1l.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DBAtF_T_.js → generate.runtime-CrAHzaEW.js} +2 -2
- package/dist/chunks/{generate.runtime-DBAtF_T_.js.map → generate.runtime-CrAHzaEW.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cp5n_QqA.js → generate.runtime-Cudp67b-.js} +1 -1
- package/dist/chunks/{generate.runtime-Cp5n_QqA.js.map → generate.runtime-Cudp67b-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DprX2Upp.js → generate.runtime-D1uQBjeg.js} +3 -3
- package/dist/chunks/{generate.runtime-DprX2Upp.js.map → generate.runtime-D1uQBjeg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cjr2Xa3e.js → generate.runtime-D1wqmaXU.js} +2 -2
- package/dist/chunks/{generate.runtime-Cjr2Xa3e.js.map → generate.runtime-D1wqmaXU.js.map} +1 -1
- package/dist/chunks/generate.runtime-D6oE0Mmf.js +28 -0
- package/dist/chunks/generate.runtime-D6oE0Mmf.js.map +1 -0
- package/dist/chunks/{generate.runtime-Dqa95On4.js → generate.runtime-DFDFxHih.js} +2 -2
- package/dist/chunks/{generate.runtime-Dqa95On4.js.map → generate.runtime-DFDFxHih.js.map} +1 -1
- package/dist/chunks/generate.runtime-DFG2C9gc.js +28 -0
- package/dist/chunks/generate.runtime-DFG2C9gc.js.map +1 -0
- package/dist/chunks/{generate.runtime-Cf_EwiYf.js → generate.runtime-DPzrDUU7.js} +2 -2
- package/dist/chunks/{generate.runtime-Cf_EwiYf.js.map → generate.runtime-DPzrDUU7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-8Ciy0dLy.js → generate.runtime-DQLmiRz6.js} +4 -4
- package/dist/chunks/{generate.runtime-8Ciy0dLy.js.map → generate.runtime-DQLmiRz6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-kovRoEUU.js → generate.runtime-DjwRKg8K.js} +1 -1
- package/dist/chunks/{generate.runtime-kovRoEUU.js.map → generate.runtime-DjwRKg8K.js.map} +1 -1
- package/dist/chunks/{generate.runtime-4F-eepmc.js → generate.runtime-DnymXcvu.js} +2 -2
- package/dist/chunks/{generate.runtime-4F-eepmc.js.map → generate.runtime-DnymXcvu.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BM00PfQB.js → generate.runtime-M6LNL7Tq.js} +2 -2
- package/dist/chunks/{generate.runtime-BM00PfQB.js.map → generate.runtime-M6LNL7Tq.js.map} +1 -1
- package/dist/chunks/{generate.runtime-JZeLiMFO.js → generate2.runtime-yP14iPwX.js} +3 -3
- package/dist/chunks/generate2.runtime-yP14iPwX.js.map +1 -0
- package/dist/chunks/{modify-svelte-config-remote-DenOsWro.js → modify-svelte-config-remote-C3g7Oi6_.js} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-DenOsWro.js.map → modify-svelte-config-remote-C3g7Oi6_.js.map} +1 -1
- package/dist/chunks/{modify-utils-FsEBGzju.js → modify-utils-CZ9Auvp9.js} +1 -1
- package/dist/chunks/{modify-utils-FsEBGzju.js.map → modify-utils-CZ9Auvp9.js.map} +1 -1
- package/dist/chunks/{pocketbase-DYaSZ9lS.js → pocketbase-D7GjPuNu.js} +1 -1
- package/dist/chunks/{pocketbase-DYaSZ9lS.js.map → pocketbase-D7GjPuNu.js.map} +1 -1
- package/dist/chunks/{shared-B_6tQpQF.js → shared-C4wJ9sb0.js} +2 -2
- package/dist/chunks/{shared-B_6tQpQF.js.map → shared-C4wJ9sb0.js.map} +1 -1
- package/dist/chunks/test-setup-C3gvjtTY.js +140 -0
- package/dist/chunks/test-setup-C3gvjtTY.js.map +1 -0
- package/dist/chunks/{write-result-B5eX8Cjw.js → write-result-BmL8uLNd.js} +2 -2
- package/dist/chunks/{write-result-B5eX8Cjw.js.map → write-result-BmL8uLNd.js.map} +1 -1
- package/dist/index.d.ts +224 -39
- package/dist/index.js +790 -585
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/env.runtime-N65jqPxq.js +0 -32
- package/dist/chunks/env.runtime-N65jqPxq.js.map +0 -1
- package/dist/chunks/generate.runtime-JZeLiMFO.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { t as d } from "./chunks/pocketbase-Dm2SF3vM.js";
|
|
|
8
8
|
import { n as f, r as p, t as m } from "./chunks/nav-user-_VheJA6n.js";
|
|
9
9
|
import { a as h, c as ee, i as g, n as _, o as te, r as ne, s as re, t as ie } from "./chunks/_server-Cv3bTkG0.js";
|
|
10
10
|
import { t as ae } from "./chunks/pocketbase-Bj-cW2Zl.js";
|
|
11
|
-
import { n as v, t as oe } from "./chunks/shared-
|
|
11
|
+
import { n as v, t as oe } from "./chunks/shared-C4wJ9sb0.js";
|
|
12
12
|
import se from "prettier";
|
|
13
13
|
import ce from "prettier-plugin-svelte";
|
|
14
14
|
//#region \0rolldown/runtime.js
|
|
@@ -26,7 +26,7 @@ var le = Object.create, ue = Object.defineProperty, de = Object.getOwnPropertyDe
|
|
|
26
26
|
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
27
27
|
}), ye = {
|
|
28
28
|
name: "@velastack/patterns",
|
|
29
|
-
version: "0.0.
|
|
29
|
+
version: "0.0.46",
|
|
30
30
|
description: "Registry of VelaStack patterns: generators and modifications applied to SvelteKit projects by the VelaStack CLI.",
|
|
31
31
|
type: "module",
|
|
32
32
|
private: !1,
|
|
@@ -1889,7 +1889,7 @@ function R(e, n) {
|
|
|
1889
1889
|
}
|
|
1890
1890
|
async function Kt(e) {
|
|
1891
1891
|
if (e.env === "runtime") {
|
|
1892
|
-
let { getCollections: e } = await import("./chunks/env.runtime-
|
|
1892
|
+
let { getCollections: e } = await import("./chunks/env.runtime-D46GCIKe.js");
|
|
1893
1893
|
return await e();
|
|
1894
1894
|
}
|
|
1895
1895
|
let { getPreviewCollections: t } = await import("./chunks/env.preview-u7rnWI2E.js");
|
|
@@ -2205,7 +2205,7 @@ var sn = "generate-form", cn = "1.0.7", ln = "src/patterns/generate/form", un =
|
|
|
2205
2205
|
async function dn(e) {
|
|
2206
2206
|
let t = await on(e);
|
|
2207
2207
|
if (e.env !== "runtime") return y(t);
|
|
2208
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
2208
|
+
let { writeResult: n } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
2209
2209
|
return n(await y(t), e);
|
|
2210
2210
|
}
|
|
2211
2211
|
var fn = {
|
|
@@ -2220,6 +2220,7 @@ var fn = {
|
|
|
2220
2220
|
auth: !1,
|
|
2221
2221
|
api: !1,
|
|
2222
2222
|
apiKeys: !1,
|
|
2223
|
+
backend: !0,
|
|
2223
2224
|
i18n: !1,
|
|
2224
2225
|
teams: !1,
|
|
2225
2226
|
payments: !1,
|
|
@@ -2496,12 +2497,12 @@ async function zn(e) {
|
|
|
2496
2497
|
let t = await jn(e);
|
|
2497
2498
|
if (e.env === "preview") return y(n([t, await Pn(e)]));
|
|
2498
2499
|
if (e.env !== "runtime") return y(t);
|
|
2499
|
-
let { modifyOutcomeToFile: r } = await import("./chunks/modify-file-DE7tPADZ.js"), { findSvelteConfigPath: i, modifySvelteConfigRemote: a } = await import("./chunks/modify-svelte-config-remote-
|
|
2500
|
+
let { modifyOutcomeToFile: r } = await import("./chunks/modify-file-DE7tPADZ.js"), { findSvelteConfigPath: i, modifySvelteConfigRemote: a } = await import("./chunks/modify-svelte-config-remote-C3g7Oi6_.js");
|
|
2500
2501
|
u(e).info("Modifying svelte.config for remote");
|
|
2501
2502
|
let o = i(e.root), s = r(o, a(o)), c = {
|
|
2502
2503
|
...t,
|
|
2503
2504
|
modifies: [...t.modifies, ...s ? [s] : []]
|
|
2504
|
-
}, { writeResult: l } = await import("./chunks/write-result-
|
|
2505
|
+
}, { writeResult: l } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
2505
2506
|
return l(await y(c), e);
|
|
2506
2507
|
}
|
|
2507
2508
|
var Bn = {
|
|
@@ -2516,6 +2517,7 @@ var Bn = {
|
|
|
2516
2517
|
auth: !1,
|
|
2517
2518
|
api: !1,
|
|
2518
2519
|
apiKeys: !1,
|
|
2520
|
+
backend: !0,
|
|
2519
2521
|
i18n: !1,
|
|
2520
2522
|
teams: !1,
|
|
2521
2523
|
payments: !1,
|
|
@@ -2636,14 +2638,14 @@ var Kn = "generate-migration", qn = "1.0.0", Jn = "src/patterns/generate/migrati
|
|
|
2636
2638
|
async function Xn(e) {
|
|
2637
2639
|
let t = await Un(e);
|
|
2638
2640
|
if (e.env !== "runtime") return y(t);
|
|
2639
|
-
let { applyCollectionFieldsPatches: n } = await import("./chunks/collections-
|
|
2641
|
+
let { applyCollectionFieldsPatches: n } = await import("./chunks/collections-BwO27pJg.js"), { withPocketbase: r } = await import("./chunks/pocketbase-D7GjPuNu.js"), i = u(e), a = [];
|
|
2640
2642
|
await r(e.root, async (r) => {
|
|
2641
2643
|
a = await n(r, t.collectionPatches, e, i);
|
|
2642
2644
|
});
|
|
2643
2645
|
let o = {
|
|
2644
2646
|
...t,
|
|
2645
2647
|
creates: [...t.creates, ...a]
|
|
2646
|
-
}, { writeResult: s } = await import("./chunks/write-result-
|
|
2648
|
+
}, { writeResult: s } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
2647
2649
|
return s(await y(o), e);
|
|
2648
2650
|
}
|
|
2649
2651
|
var Zn = {
|
|
@@ -2658,6 +2660,7 @@ var Zn = {
|
|
|
2658
2660
|
auth: !1,
|
|
2659
2661
|
api: !1,
|
|
2660
2662
|
apiKeys: !1,
|
|
2663
|
+
backend: !0,
|
|
2661
2664
|
i18n: !1,
|
|
2662
2665
|
teams: !1,
|
|
2663
2666
|
payments: !1,
|
|
@@ -2745,10 +2748,10 @@ var tr = "generate-resource", nr = "1.0.7", rr = "src/patterns/generate/resource
|
|
|
2745
2748
|
async function ar(e) {
|
|
2746
2749
|
let t = await er(e);
|
|
2747
2750
|
if (e.env !== "runtime") return y(t);
|
|
2748
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
2751
|
+
let { createCollections: n } = await import("./chunks/collections-BwO27pJg.js"), r = await n(t.collections, e), i = {
|
|
2749
2752
|
...t,
|
|
2750
2753
|
creates: [...t.creates, ...r]
|
|
2751
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
2754
|
+
}, { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
2752
2755
|
return a(await y(i), e);
|
|
2753
2756
|
}
|
|
2754
2757
|
var or = {
|
|
@@ -2763,6 +2766,7 @@ var or = {
|
|
|
2763
2766
|
auth: !1,
|
|
2764
2767
|
api: !1,
|
|
2765
2768
|
apiKeys: !1,
|
|
2769
|
+
backend: !0,
|
|
2766
2770
|
i18n: !1,
|
|
2767
2771
|
teams: !1,
|
|
2768
2772
|
payments: !1,
|
|
@@ -3132,10 +3136,10 @@ var Dr = "generate-scaffold", Or = "1.0.7", kr = "src/patterns/generate/scaffold
|
|
|
3132
3136
|
async function jr(e) {
|
|
3133
3137
|
let t = await Er(e);
|
|
3134
3138
|
if (e.env !== "runtime") return y(t);
|
|
3135
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
3139
|
+
let { createCollections: n } = await import("./chunks/collections-BwO27pJg.js"), r = await n(t.collections, e), i = {
|
|
3136
3140
|
...t,
|
|
3137
3141
|
creates: [...t.creates, ...r]
|
|
3138
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
3142
|
+
}, { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
3139
3143
|
return a(await y(i), e);
|
|
3140
3144
|
}
|
|
3141
3145
|
var Mr = {
|
|
@@ -3150,6 +3154,7 @@ var Mr = {
|
|
|
3150
3154
|
auth: !1,
|
|
3151
3155
|
api: !1,
|
|
3152
3156
|
apiKeys: !1,
|
|
3157
|
+
backend: !0,
|
|
3153
3158
|
i18n: !1,
|
|
3154
3159
|
teams: !1,
|
|
3155
3160
|
payments: !1,
|
|
@@ -3501,13 +3506,13 @@ async function ui(e) {
|
|
|
3501
3506
|
let t = await ni(e);
|
|
3502
3507
|
if (e.env === "preview") return y(n([t, await ai(e)]));
|
|
3503
3508
|
if (e.env !== "runtime") return y(t);
|
|
3504
|
-
let { createCollections: r } = await import("./chunks/collections-
|
|
3509
|
+
let { createCollections: r } = await import("./chunks/collections-BwO27pJg.js"), i = await r(t.collections, e), { modifyOutcomeToFile: a } = await import("./chunks/modify-file-DE7tPADZ.js"), { findSvelteConfigPath: o, modifySvelteConfigRemote: s } = await import("./chunks/modify-svelte-config-remote-C3g7Oi6_.js");
|
|
3505
3510
|
u(e).info("Modifying svelte.config for remote");
|
|
3506
3511
|
let c = o(e.root), l = a(c, s(c)), d = {
|
|
3507
3512
|
...t,
|
|
3508
3513
|
creates: [...t.creates, ...i],
|
|
3509
3514
|
modifies: [...t.modifies, ...l ? [l] : []]
|
|
3510
|
-
}, { writeResult: f } = await import("./chunks/write-result-
|
|
3515
|
+
}, { writeResult: f } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
3511
3516
|
return f(await y(d), e);
|
|
3512
3517
|
}
|
|
3513
3518
|
var di = {
|
|
@@ -3522,6 +3527,7 @@ var di = {
|
|
|
3522
3527
|
auth: !1,
|
|
3523
3528
|
api: !1,
|
|
3524
3529
|
apiKeys: !1,
|
|
3530
|
+
backend: !0,
|
|
3525
3531
|
i18n: !1,
|
|
3526
3532
|
teams: !1,
|
|
3527
3533
|
payments: !1,
|
|
@@ -3603,7 +3609,7 @@ var hi = "generate-schema", gi = "1.0.7", _i = "src/patterns/generate/schema", v
|
|
|
3603
3609
|
async function yi(e) {
|
|
3604
3610
|
let t = await mi(e);
|
|
3605
3611
|
if (e.env !== "runtime") return y(t);
|
|
3606
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
3612
|
+
let { writeResult: n } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
3607
3613
|
return n(await y(t), e);
|
|
3608
3614
|
}
|
|
3609
3615
|
var bi = {
|
|
@@ -3618,6 +3624,7 @@ var bi = {
|
|
|
3618
3624
|
auth: !1,
|
|
3619
3625
|
api: !1,
|
|
3620
3626
|
apiKeys: !1,
|
|
3627
|
+
backend: !1,
|
|
3621
3628
|
i18n: !1,
|
|
3622
3629
|
teams: !1,
|
|
3623
3630
|
payments: !1,
|
|
@@ -3830,7 +3837,7 @@ var wa = "enable-auth", Ta = "1.0.8", Ea = "src/patterns/enable/auth", Da = "/en
|
|
|
3830
3837
|
async function Oa(e) {
|
|
3831
3838
|
let t = await ba(e);
|
|
3832
3839
|
if (e.env === "preview") return y(n([t, await Ca(e)]));
|
|
3833
|
-
let { writeResult: r } = await import("./chunks/write-result-
|
|
3840
|
+
let { writeResult: r } = await import("./chunks/write-result-BmL8uLNd.js"), i = await r(await y(t), e), { generate: a } = await import("./chunks/generate.runtime-DFDFxHih.js");
|
|
3834
3841
|
return n([i, await r(await y(await a(e)), e)]);
|
|
3835
3842
|
}
|
|
3836
3843
|
var ka = {
|
|
@@ -3845,6 +3852,7 @@ var ka = {
|
|
|
3845
3852
|
auth: !1,
|
|
3846
3853
|
api: !1,
|
|
3847
3854
|
apiKeys: !1,
|
|
3855
|
+
backend: !0,
|
|
3848
3856
|
i18n: !1,
|
|
3849
3857
|
teams: !1,
|
|
3850
3858
|
payments: !1,
|
|
@@ -4054,7 +4062,7 @@ var Ro = "enable-auth-remote", zo = "1.0.0", Bo = "src/patterns/enable/auth-remo
|
|
|
4054
4062
|
async function Ho(e) {
|
|
4055
4063
|
let t = await Po(e);
|
|
4056
4064
|
if (e.env === "preview") return y(n([t, await Lo(e)]));
|
|
4057
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
4065
|
+
let { generate: r } = await import("./chunks/generate.runtime-D1uQBjeg.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4058
4066
|
return a(await y(n([t, i])), e);
|
|
4059
4067
|
}
|
|
4060
4068
|
var Uo = {
|
|
@@ -4069,6 +4077,7 @@ var Uo = {
|
|
|
4069
4077
|
auth: !1,
|
|
4070
4078
|
api: !1,
|
|
4071
4079
|
apiKeys: !1,
|
|
4080
|
+
backend: !0,
|
|
4072
4081
|
i18n: !1,
|
|
4073
4082
|
teams: !1,
|
|
4074
4083
|
payments: !1,
|
|
@@ -4144,7 +4153,7 @@ var Zo = "enable-api", Qo = "1.0.7", $o = "src/patterns/enable/api", es = "/enab
|
|
|
4144
4153
|
async function ts(e) {
|
|
4145
4154
|
let t = await qo(e);
|
|
4146
4155
|
if (e.env === "preview") return y(n([t, await Xo(e)]));
|
|
4147
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
4156
|
+
let { generate: r } = await import("./chunks/generate.runtime-CUgleG0U.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4148
4157
|
return a(await y(n([t, i])), e);
|
|
4149
4158
|
}
|
|
4150
4159
|
var ns = {
|
|
@@ -4159,6 +4168,7 @@ var ns = {
|
|
|
4159
4168
|
auth: !1,
|
|
4160
4169
|
api: !1,
|
|
4161
4170
|
apiKeys: !1,
|
|
4171
|
+
backend: !0,
|
|
4162
4172
|
i18n: !1,
|
|
4163
4173
|
teams: !1,
|
|
4164
4174
|
payments: !1,
|
|
@@ -4294,7 +4304,7 @@ var xs = "enable-api-keys", Ss = "1.0.0", Cs = "src/patterns/enable/api-keys", w
|
|
|
4294
4304
|
async function Ts(e) {
|
|
4295
4305
|
let t = await _s(e);
|
|
4296
4306
|
if (e.env === "preview") return y(n([t, await bs(e)]));
|
|
4297
|
-
let { createCollections: r } = await import("./chunks/collections-
|
|
4307
|
+
let { createCollections: r } = await import("./chunks/collections-BwO27pJg.js"), i = await r(t.collections, e), { generate: a } = await import("./chunks/generate.runtime-DnymXcvu.js"), o = await a(e), { writeResult: s } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4298
4308
|
return s(await y(n([{
|
|
4299
4309
|
...t,
|
|
4300
4310
|
creates: [...t.creates, ...i]
|
|
@@ -4312,6 +4322,7 @@ var Es = {
|
|
|
4312
4322
|
auth: !0,
|
|
4313
4323
|
api: !0,
|
|
4314
4324
|
apiKeys: !1,
|
|
4325
|
+
backend: !0,
|
|
4315
4326
|
i18n: !1,
|
|
4316
4327
|
teams: !1,
|
|
4317
4328
|
payments: !1,
|
|
@@ -4336,30 +4347,126 @@ var Es = {
|
|
|
4336
4347
|
tests: 6,
|
|
4337
4348
|
baseline: "velastack",
|
|
4338
4349
|
generate: Ts
|
|
4339
|
-
}, Ds = "pre[class*='language-'],\ncode[class*='language-'] {\n color: #d4d4d4;\n font-size: 13px;\n text-shadow: none;\n font-family: Menlo, Monaco, Consolas, 'Andale Mono', 'Ubuntu Mono', 'Courier New', monospace;\n direction: ltr;\n text-align: left;\n white-space: pre;\n word-spacing: normal;\n word-break: normal;\n line-height: 1.5;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n -webkit-hyphens: none;\n -moz-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n}\n\npre[class*='language-']::selection,\ncode[class*='language-']::selection,\npre[class*='language-'] *::selection,\ncode[class*='language-'] *::selection {\n text-shadow: none;\n background: #264f78;\n}\n\n@media print {\n pre[class*='language-'],\n code[class*='language-'] {\n text-shadow: none;\n }\n}\n\npre[class*='language-'] {\n padding: 1em;\n margin: 0.5em 0;\n overflow: auto;\n background: oklch(0.21 0.034 264.665);\n}\n\n:not(pre) > code[class*='language-'] {\n padding: 0.1em 0.3em;\n border-radius: 0.3em;\n color: #db4c69;\n background: oklch(0.21 0.034 264.665);\n}\n/*********************************************************\n* Tokens\n*/\n.namespace {\n opacity: 0.7;\n}\n\n.token.doctype .token.doctype-tag {\n color: #569cd6;\n}\n\n.token.doctype .token.name {\n color: #9cdcfe;\n}\n\n.token.comment,\n.token.prolog {\n color: #6a9955;\n}\n\n.token.punctuation,\n.language-html .language-css .token.punctuation,\n.language-html .language-javascript .token.punctuation {\n color: #d4d4d4;\n}\n\n.token.property,\n.token.tag,\n.token.boolean,\n.token.number,\n.token.constant,\n.token.symbol,\n.token.inserted,\n.token.unit {\n color: #b5cea8;\n}\n\n.token.selector,\n.token.attr-name,\n.token.string,\n.token.char,\n.token.builtin,\n.token.deleted {\n color: #ce9178;\n}\n\n.language-css .token.string.url {\n text-decoration: underline;\n}\n\n.token.operator,\n.token.entity {\n color: #d4d4d4;\n}\n\n.token.operator.arrow {\n color: #569cd6;\n}\n\n.token.atrule {\n color: #ce9178;\n}\n\n.token.atrule .token.rule {\n color: #c586c0;\n}\n\n.token.atrule .token.url {\n color: #9cdcfe;\n}\n\n.token.atrule .token.url .token.function {\n color: #dcdcaa;\n}\n\n.token.atrule .token.url .token.punctuation {\n color: #d4d4d4;\n}\n\n.token.keyword {\n color: #569cd6;\n}\n\n.token.keyword.module,\n.token.keyword.control-flow {\n color: #c586c0;\n}\n\n.token.function,\n.token.function .token.maybe-class-name {\n color: #dcdcaa;\n}\n\n.token.regex {\n color: #d16969;\n}\n\n.token.important {\n color: #569cd6;\n}\n\n.token.italic {\n font-style: italic;\n}\n\n.token.constant {\n color: #9cdcfe;\n}\n\n.token.class-name,\n.token.maybe-class-name {\n color: #4ec9b0;\n}\n\n.token.console {\n color: #9cdcfe;\n}\n\n.token.parameter {\n color: #9cdcfe;\n}\n\n.token.interpolation {\n color: #9cdcfe;\n}\n\n.token.punctuation.interpolation-punctuation {\n color: #569cd6;\n}\n\n.token.boolean {\n color: #569cd6;\n}\n\n.token.property,\n.token.variable,\n.token.imports .token.maybe-class-name,\n.token.exports .token.maybe-class-name {\n color: #9cdcfe;\n}\n\n.token.selector {\n color: #d7ba7d;\n}\n\n.token.escape {\n color: #d7ba7d;\n}\n\n.token.tag {\n color: #569cd6;\n}\n\n.token.tag .token.punctuation {\n color: #808080;\n}\n\n.token.cdata {\n color: #808080;\n}\n\n.token.attr-name {\n color: #9cdcfe;\n}\n\n.token.attr-value,\n.token.attr-value .token.punctuation {\n color: #ce9178;\n}\n\n.token.attr-value .token.punctuation.attr-equals {\n color: #d4d4d4;\n}\n\n.token.entity {\n color: #569cd6;\n}\n\n.token.namespace {\n color: #4ec9b0;\n}\n/*********************************************************\n* Language Specific\n*/\n\npre[class*='language-javascript'],\ncode[class*='language-javascript'],\npre[class*='language-jsx'],\ncode[class*='language-jsx'],\npre[class*='language-typescript'],\ncode[class*='language-typescript'],\npre[class*='language-tsx'],\ncode[class*='language-tsx'] {\n color: #9cdcfe;\n}\n\npre[class*='language-css'],\ncode[class*='language-css'] {\n color: #ce9178;\n}\n\npre[class*='language-html'],\ncode[class*='language-html'] {\n color: #d4d4d4;\n}\n\n.language-regex .token.anchor {\n color: #dcdcaa;\n}\n\n.language-html .token.punctuation {\n color: #808080;\n}\n/*********************************************************\n* Line highlighting\n*/\npre[class*='language-'] > code[class*='language-'] {\n position: relative;\n z-index: 1;\n}\n\n.line-highlight.line-highlight {\n background: #f7ebc6;\n box-shadow: inset 5px 0 0 #f7d87c;\n z-index: 0;\n}\n", Os = "<script lang=\"ts\">\n import * as Avatar from '$lib/components/ui/avatar';\n import type { BlogAuthor } from '$lib/content';\n\n let {\n author,\n size = 'sm'\n }: { author: BlogAuthor; size?: 'sm' | 'default' | 'lg' } = $props();\n\n const initials = $derived(\n author.name\n .split(/\\s+/)\n .map((part) => part[0])\n .filter(Boolean)\n .slice(0, 2)\n .join('')\n .toUpperCase()\n );\n<\/script>\n\n<span class=\"inline-flex items-center gap-2\">\n <Avatar.Root {size}>\n {#if author.avatar}\n <Avatar.Image src={author.avatar} alt={author.name} />\n {/if}\n <Avatar.Fallback class=\"text-xs\">{initials}</Avatar.Fallback>\n </Avatar.Root>\n <span class=\"text-foreground text-sm font-medium\">{author.name}</span>\n</span>\n", ks = "<script lang=\"ts\">\n import * as Card from \"$lib/components/ui/card\";\n import { Badge } from \"$lib/components/ui/badge\";\n import AuthorChip from \"./AuthorChip.svelte\";\n import { formatDate } from \"$lib/utils/date\";\n import type { BlogPost, BlogPostSummary } from \"$lib/content\";\n\n let { post }: { post: BlogPost | BlogPostSummary } = $props();\n<\/script>\n\n<Card.Root class=\"hover:ring-foreground/20 h-full transition-shadow w-full\">\n <Card.Header>\n <Card.Title class=\"text-lg leading-snug\">\n <a href={`/blog/${post.slug}`} class=\"hover:underline\">\n {post.title}\n </a>\n </Card.Title>\n <Card.Description class=\"line-clamp-2\">\n {post.description}\n </Card.Description>\n </Card.Header>\n <Card.Content class=\"flex flex-1 flex-col justify-end gap-3\">\n {#if post.tags?.length}\n <div class=\"flex flex-wrap gap-1.5\">\n {#each post.tags as tag (tag)}\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">{tag}</Badge>\n {/each}\n </div>\n {/if}\n <div\n class=\"text-muted-foreground flex items-center justify-between gap-3 text-xs\"\n >\n {#if post.author}\n <AuthorChip author={post.author} />\n {:else}\n <span></span>\n {/if}\n <span class=\"whitespace-nowrap\">\n <time datetime={post.createdDate.toISOString()}\n >{formatDate(post.createdDate)}</time\n >\n <span aria-hidden=\"true\">•</span>\n <span>{post.readingTime} min read</span>\n </span>\n </div>\n </Card.Content>\n</Card.Root>\n", As = "---\ntitle: Design System Notes\ndescription: Small choices that make a design system feel coherent — spacing, radius, and the case for fewer variants.\ncreatedDate: 2025-12-15\ntags:\n - design\n - shadcn\nauthor:\n name: Ada Chen\n---\n\nWe've been cleaning up the design system recently. A few notes from the\npass, mostly for ourselves, partially in case they're useful to anyone\nelse building on top of shadcn.\n\n## The variants we actually use\n\nEvery primitive ships with a dozen variants. In practice our product\nleans on two or three per component:\n\n- **Buttons** — `default`, `ghost`, and `outline`. Destructive shows up\n rarely enough to be worth the extra click.\n- **Badges** — `default` and `secondary`. Tags and counts, nothing else.\n- **Cards** — one shape, with optional footer. Multiple card styles\n became indistinguishable from \"padded div,\" so we stopped.\n\nIf a variant hasn't appeared in a design in six months, it gets deleted.\nThe point isn't minimalism; it's that every extra variant is a decision\na future designer has to relitigate.\n\n## Spacing\n\nTailwind's default scale is good. We only locked in one rule: never use\nodd gaps. `gap-3` and `gap-5` stay; `gap-2.5` goes. It's a small thing\nthat quietly keeps vertical rhythm predictable across pages.\n\n## Radius\n\nOne radius token, applied everywhere. If a surface needs to feel\ndifferent, that's a structural decision — a card, a sheet, a popover —\nnot a one-off `rounded-md`. We ended up at `0.625rem` as our default\nand haven't wanted to change it.\n\n## Dark mode\n\nWe treat dark mode as a different palette, not a filter. Every token\nhas an explicit OKLCH value in both themes. When a component looks\noff in dark mode, the fix is almost always a token, not a tweak.\n", js = "---\ntitle: Getting Started with SvelteKit\ndescription: The smallest useful SvelteKit project, explained end to end — routing, loading data, and the dev loop.\ncreatedDate: 2026-03-12\ntags:\n - sveltekit\n - tutorial\nauthor:\n name: Marco Alvarez\n---\n\nSvelteKit is the piece that turns Svelte — a component library — into\nsomething you can ship. Routing, server endpoints, data loading, builds,\nand deployment adapters all live in one place.\n\n## Creating a project\n\nThe fastest path is the CLI. It scaffolds a minimal project, installs\ndependencies, and leaves you with a working dev server.\n\n```bash\nnpx sv create my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\n## Routes are files\n\nA route is a folder under `src/routes` with a `+page.svelte` inside.\nNested folders produce nested URLs. Dynamic segments use `[brackets]`.\n\n```\nsrc/routes/\n +page.svelte # /\n about/\n +page.svelte # /about\n blog/\n [slug]/\n +page.svelte # /blog/:slug\n```\n\n## Loading data\n\nA route's `+page.ts` (or `+page.server.ts` for server-only data) exports\na `load` function. Whatever it returns becomes `data` on the page.\n\n```ts\n// src/routes/blog/[slug]/+page.ts\nimport { error } from '@sveltejs/kit';\n\nexport const load = async ({ params }) => {\n const post = await fetchPost(params.slug);\n if (!post) throw error(404, 'Not found');\n return { post };\n};\n```\n\nThat's most of SvelteKit. The rest — form actions, hooks, adapters — are\nopt-in once you need them.\n", Ms = "---\ntitle: A Pragmatic Performance Checklist\ndescription: The small set of things that have given us the biggest performance wins — in rough order of impact.\ncreatedDate: 2025-11-03\ntags:\n - performance\n - tutorial\nauthor:\n name: Marco Alvarez\n---\n\nWe don't have a performance budget so much as a performance allergy.\nWhen something feels slow, we profile, fix the obvious thing, and move\non. The list below is what \"the obvious thing\" usually is.\n\n> Premature optimization is the root of all evil, but ignoring a 3s\n> cold-start isn't optimization — it's negligence.\n\n## The checklist\n\n1. **Measure with real numbers.** Lighthouse and the Network tab answer\n most questions. If you're not measuring, you're guessing.\n2. **Serve fewer bytes.** Compress images (AVIF or WebP), remove unused\n fonts, and audit any dependency over 50KB gzipped.\n3. **Defer the non-critical.** Scripts that aren't needed above the\n fold can wait. `loading=\"lazy\"` on images, `defer` on scripts, and\n dynamic `import()` for interactive widgets.\n4. **Cache at the edge.** If the same HTML could serve a thousand users,\n it should. Use your adapter's cache headers; don't hand-roll it.\n5. **Avoid waterfalls.** If page load depends on three sequential fetches,\n collapse them into one endpoint or preload the critical ones.\n6. **Trust the framework.** SvelteKit's `load` functions run in parallel\n by default and the compiler already strips unused code. Most hand-rolled\n cleverness just gets in the way.\n\n## What we stopped worrying about\n\n- Micro-optimizations inside component code — the bundle is small, the\n diff is fast. The savings are real but rarely matter.\n- Third-party tooling that promises \"speed.\" If it adds a build step,\n the benefit needs to be measurable, not theoretical.\n\n## When to go deeper\n\nIf the checklist doesn't move the needle, the next step is almost\nalways a deeper look at the data layer — query plans, N+1 fetches, cold\ncache behavior. But you should have exhausted the list above before\ngetting there. Most slowness is boring, and most fixes are too.\n", Ns = "---\ntitle: Welcome to the Blog\ndescription: A quick note on what this space is for and what to expect from us.\ncreatedDate: 2026-04-20\ntags:\n - announcements\nauthor:\n name: Ada Chen\n---\n\nWelcome in. This blog is where we write about the things we build, the\ndecisions behind them, and what we learn when they go sideways.\n\nYou can expect a mix of short notes and longer walkthroughs. No schedule,\nno filler. If a post exists it's because something was worth writing down.\n\nA few threads you'll see pop up often:\n\n- Product notes on what we're shipping and why\n- Practical tutorials for the tools we use every day\n- Design and engineering decisions that took more than five minutes\n\nIf you'd rather not check back manually, the [RSS feed](/blog/rss.xml)\nhas every post. Thanks for reading.\n", Ps = "---\ntitle: Why We Chose Tailwind v4\ndescription: Notes on moving from a traditional CSS pipeline to Tailwind v4's zero-config, CSS-first setup.\ncreatedDate: 2026-02-18\ntags:\n - tailwind\n - design\nauthor:\n name: Ada Chen\n---\n\nTailwind v4 is a meaningful rewrite. The surface API still looks the same\n— utility classes on elements — but the compiler, configuration model,\nand theming story all changed in ways that made us want to adopt it.\n\n> The point of a design system isn't to ship fewer classes. It's to make\n> the next decision easier than the last.\n\n## What changed for us\n\nThree things mattered:\n\n1. **CSS-first config.** `tailwind.config.js` is gone. Tokens live in\n `app.css` as real CSS custom properties, which means they also work\n outside of Tailwind — SVG fills, inline styles, wherever.\n2. **OKLCH colors.** Designers can reason about lightness and chroma\n independently. Contrast checks become much easier to eyeball.\n3. **Speed.** The new engine compiles fast enough that we stopped\n thinking about purge lists. Dev feedback is effectively instant.\n\n## The config we kept\n\nWe pinned two things in `app.css`:\n\n```css\n@import 'tailwindcss';\n@plugin '@tailwindcss/typography';\n\n:root {\n --radius: 0.625rem;\n --background: oklch(1 0 0);\n --foreground: oklch(0.129 0.042 264.695);\n}\n```\n\nEverything else — spacing, typography, breakpoints — falls back to\ndefaults until we have a reason to override it.\n\n## What we'd tell a team evaluating it\n\nIf you're already using Tailwind v3, the migration is mostly a config\nmove. If you're starting from scratch, v4 removes a pile of decisions\nyou'd otherwise be making on day one. That alone made it worth it.\n", Fs = "---\ntitle: Writing Posts with MDsveX\ndescription: How this blog turns markdown files into real Svelte components — frontmatter, code, and embedded UI.\ncreatedDate: 2026-01-28\nupdatedDate: 2026-02-02\ntags:\n - mdsvex\n - tutorial\nauthor:\n name: Priya Shah\n---\n\nPosts on this blog are `.svx` files. Each one is a real Svelte component\nat build time, so Markdown and Svelte sit side by side with no glue\ncode.\n\n## Frontmatter\n\nYAML at the top of a post becomes the `metadata` export. The loader\nreads it to build the list view, tag pages, and RSS feed.\n\n```yaml\n---\ntitle: Writing Posts with MDsveX\ndescription: A short description shown in previews.\ncreatedDate: 2026-01-28\ntags:\n - mdsvex\n - tutorial\nauthor:\n name: Priya Shah\n---\n```\n\n## Markdown works the way you'd expect\n\nHeadings, lists, links, blockquotes, and inline `code` all render.\nFenced code blocks pick up language hints for syntax highlighting when a\nplugin is enabled.\n\n```ts\nfunction greet(name: string) {\n return `hello, ${name}`;\n}\n```\n\n## Images\n\nPut images in `static/` and reference them with a root-relative path:\n\n```md\n\n```\n\n## Svelte in your posts\n\nThe superpower is that you can drop components straight into a post —\na chart, an interactive demo, a call-to-action card. The rules are the\nsame as any other Svelte file:\n\n```svelte\n<script>\n import Callout from '$lib/components/Callout.svelte';\n<\/script>\n\n<Callout>This is a real component inside a markdown post.</Callout>\n```\n\nThat's the whole pipeline. Write markdown, sprinkle in components when\nplain text stops being enough, and the rest is just Svelte.\n", Is = "import type { Component } from \"svelte\";\n\nexport type BlogAuthor = {\n name: string;\n avatar?: string;\n};\n\nexport type BlogMetadata = {\n title: string;\n description: string;\n createdDate: string;\n updatedDate?: string;\n tags?: string[];\n author?: BlogAuthor;\n};\n\nexport type BlogModules = Record<\n string,\n { default: Component; metadata: BlogMetadata }\n>;\n\nexport type BlogRawModules = Record<string, string>;\n\nexport type BlogPost = {\n slug: string;\n title: string;\n description: string;\n createdDate: Date;\n updatedDate?: Date;\n tags?: string[];\n author?: BlogAuthor;\n readingTime: number;\n component: Component;\n};\n\nexport type BlogPostSummary = Omit<BlogPost, \"component\">;\n\nconst WORDS_PER_MINUTE = 220;\n\nfunction getBlogModules() {\n return import.meta.glob(\"$lib/content/blog/*.svx\", {\n eager: true,\n }) as BlogModules;\n}\n\nfunction getBlogRawModules() {\n return import.meta.glob(\"$lib/content/blog/*.svx\", {\n eager: true,\n query: \"?raw\",\n import: \"default\",\n }) as BlogRawModules;\n}\n\nfunction stripFrontmatter(raw: string) {\n if (!raw.startsWith(\"---\")) return raw;\n const end = raw.indexOf(\"\\n---\", 3);\n if (end === -1) return raw;\n return raw.slice(end + 4);\n}\n\nfunction computeReadingTime(raw: string) {\n const body = stripFrontmatter(raw);\n const words = body.split(/\\s+/).filter(Boolean).length;\n return Math.max(1, Math.ceil(words / WORDS_PER_MINUTE));\n}\n\nexport function getBlogPosts(): BlogPost[] {\n const modules = getBlogModules();\n const rawModules = getBlogRawModules();\n\n const posts = Object.entries(modules).map(([path, module]) => {\n const filename = path.split(\"/\").pop() ?? \"\";\n const slug = filename.replace(\".svx\", \"\");\n const raw = rawModules[path] ?? \"\";\n\n return {\n slug,\n title: module.metadata.title,\n description: module.metadata.description,\n createdDate: new Date(module.metadata.createdDate),\n updatedDate: module.metadata.updatedDate\n ? new Date(module.metadata.updatedDate)\n : undefined,\n tags: module.metadata.tags,\n author: module.metadata.author,\n readingTime: computeReadingTime(raw),\n component: module.default,\n };\n });\n\n posts.sort((a, b) => b.createdDate.getTime() - a.createdDate.getTime());\n return posts;\n}\n\nexport function getBlogPost(slug: string) {\n const posts = getBlogPosts();\n return posts.find((post) => post.slug === slug) ?? null;\n}\n\nexport function getBlogPostRaw(slug: string): string | null {\n const rawModules = getBlogRawModules();\n for (const [path, raw] of Object.entries(rawModules)) {\n const filename = path.split(\"/\").pop() ?? \"\";\n if (filename.replace(\".svx\", \"\") === slug) return raw;\n }\n return null;\n}\n\nexport function getBlogPostsByTag(tag: string) {\n return getBlogPosts().filter((post) => post.tags?.includes(tag));\n}\n\nexport function getAllTags(): { tag: string; count: number }[] {\n const counts = new Map<string, number>();\n for (const post of getBlogPosts()) {\n for (const tag of post.tags ?? []) {\n counts.set(tag, (counts.get(tag) ?? 0) + 1);\n }\n }\n return [...counts.entries()]\n .map(([tag, count]) => ({ tag, count }))\n .sort((a, b) => b.count - a.count || a.tag.localeCompare(b.tag));\n}\n\nexport function getAdjacentPosts(slug: string): {\n prev: BlogPost | null;\n next: BlogPost | null;\n} {\n const posts = getBlogPosts();\n const index = posts.findIndex((post) => post.slug === slug);\n if (index === -1) return { prev: null, next: null };\n return {\n next: index > 0 ? posts[index - 1] : null,\n prev: index < posts.length - 1 ? posts[index + 1] : null,\n };\n}\n\nexport function getRelatedPosts(slug: string, limit = 3): BlogPost[] {\n const posts = getBlogPosts();\n const current = posts.find((post) => post.slug === slug);\n if (!current?.tags?.length) return [];\n\n const currentTags = new Set(current.tags);\n\n return posts\n .filter((post) => post.slug !== slug && post.tags?.length)\n .map((post) => ({\n post,\n overlap: post.tags!.filter((tag) => currentTags.has(tag)).length,\n }))\n .filter(({ overlap }) => overlap > 0)\n .sort(\n (a, b) =>\n b.overlap - a.overlap ||\n b.post.createdDate.getTime() - a.post.createdDate.getTime(),\n )\n .slice(0, limit)\n .map(({ post }) => post);\n}\n", Ls = "const formatter = new Intl.DateTimeFormat(\"en-US\", {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n});\n\nexport function formatDate(date: Date) {\n return formatter.format(date);\n}\n", Rs = "<script lang=\"ts\">\n import * as Breadcrumb from \"$lib/components/ui/breadcrumb\";\n import { page } from \"$app/state\";\n\n let { children } = $props();\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as {\n title: string;\n url: string;\n }[];\n<\/script>\n\n<section data-role=\"content\">\n <Breadcrumb.Root class=\"mb-6\">\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}\n >{breadcrumb.title}</Breadcrumb.Link\n >\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n\n {@render children?.()}\n</section>\n", zs = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n import { Button } from \"$lib/components/ui/button\";\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n import Rss from \"@lucide/svelte/icons/rss\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-10\">\n <header\n class=\"flex flex-col gap-4 md:flex-row md:items-end md:justify-between\"\n >\n <div class=\"max-w-2xl\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">Blog</h1>\n <p class=\"text-muted-foreground mt-2 text-base\">\n Product notes, tutorials, and engineering posts from the team.\n </p>\n </div>\n <Button href=\"/blog/rss.xml\" variant=\"outline\" size=\"sm\" class=\"w-fit\">\n <Rss class=\"size-4\" />\n RSS\n </Button>\n </header>\n\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.blogPosts as post (post.slug)}\n <li class=\"flex w-full\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n</div>\n", Bs = "import { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags, getBlogPosts } from \"$lib/content\";\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const blogPosts = getBlogPosts();\n const allTags = getAllTags();\n\n const pageMetaTags = definePageMetaTags({\n title: \"Blog\",\n description: \"Product notes, tutorials, and engineering posts.\",\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n ];\n\n return { blogPosts, allTags, breadcrumbs, ...pageMetaTags };\n};\n", Vs = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n import { Separator } from \"$lib/components/ui/separator\";\n import AuthorChip from \"$lib/components/blog/AuthorChip.svelte\";\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n import { formatDate } from \"$lib/utils/date\";\n import * as Breadcrumb from \"$lib/components/ui/breadcrumb\";\n import ArrowLeft from \"@lucide/svelte/icons/arrow-left\";\n import ArrowRight from \"@lucide/svelte/icons/arrow-right\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as {\n title: string;\n url: string;\n }[];\n<\/script>\n\n<div class=\"flex flex-col gap-6\">\n <header class=\"flex flex-col gap-5 border-b border-border pb-8\">\n <div class=\"flex flex-col gap-3\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">\n {data.blogPost.title}\n </h1>\n <p class=\"text-muted-foreground text-lg\">\n {data.blogPost.description}\n </p>\n </div>\n\n <div\n class=\"text-muted-foreground flex flex-wrap items-center gap-x-1 gap-y-2 text-sm\"\n >\n {#if data.blogPost.author}\n <AuthorChip author={data.blogPost.author} />\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n {/if}\n <time datetime={data.blogPost.createdDate.toISOString()}>\n {formatDate(data.blogPost.createdDate)}\n </time>\n {#if data.blogPost.updatedDate}\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n <span>Updated {formatDate(data.blogPost.updatedDate)}</span>\n {/if}\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n <span>{data.blogPost.readingTime} min read</span>\n </div>\n\n {#if data.blogPost.tags?.length}\n <div class=\"flex flex-wrap gap-1.5\">\n {#each data.blogPost.tags as tag (tag)}\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">{tag}</Badge>\n {/each}\n </div>\n {/if}\n </header>\n\n <article\n class=\"prose dark:prose-invert max-w-prose prose-headings:mb-0 prose-headings:mt-4\"\n >\n <data.blogPost.component />\n </article>\n\n <Separator />\n\n <nav class=\"grid gap-3 sm:grid-cols-2\" aria-label=\"Post navigation\">\n {#if data.adjacent.prev}\n <a\n href={`/blog/${data.adjacent.prev.slug}`}\n class=\"ring-foreground/10 hover:ring-foreground/20 bg-card text-card-foreground group flex flex-col gap-1 rounded-xl p-4 ring-1 transition-shadow\"\n >\n <span\n class=\"text-muted-foreground inline-flex items-center gap-1 text-xs font-medium uppercase tracking-wide\"\n >\n <ArrowLeft class=\"size-3.5\" />\n Previous\n </span>\n <span class=\"font-medium group-hover:underline\"\n >{data.adjacent.prev.title}</span\n >\n </a>\n {:else}\n <div></div>\n {/if}\n\n {#if data.adjacent.next}\n <a\n href={`/blog/${data.adjacent.next.slug}`}\n class=\"ring-foreground/10 hover:ring-foreground/20 bg-card text-card-foreground group flex flex-col gap-1 rounded-xl p-4 text-right ring-1 transition-shadow sm:col-start-2\"\n >\n <span\n class=\"text-muted-foreground inline-flex items-center justify-end gap-1 text-xs font-medium uppercase tracking-wide\"\n >\n Next\n <ArrowRight class=\"size-3.5\" />\n </span>\n <span class=\"font-medium group-hover:underline\"\n >{data.adjacent.next.title}</span\n >\n </a>\n {/if}\n </nav>\n\n {#if data.related.length}\n <section class=\"flex flex-col gap-4\">\n <Separator />\n <h2 class=\"text-xl font-semibold tracking-tight\">Related posts</h2>\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.related as post (post.slug)}\n <li class=\"flex\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n </section>\n {/if}\n</div>\n", Hs = "import { error } from \"@sveltejs/kit\";\nimport { definePageMetaTags } from \"svelte-meta-tags\";\nimport {\n getAdjacentPosts,\n getBlogPost,\n getBlogPosts,\n getRelatedPosts,\n} from \"$lib/content\";\n\nexport const load = async ({ params, parent }) => {\n await parent();\n\n const blogPost = getBlogPost(params.slug);\n\n if (blogPost === null) {\n throw error(404, \"Page not found\");\n }\n\n const adjacent = getAdjacentPosts(params.slug);\n const related = getRelatedPosts(params.slug);\n\n const pageMetaTags = definePageMetaTags({\n title: blogPost.title,\n description: blogPost.description,\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: blogPost.title, url: `/blog/${blogPost.slug}` },\n ];\n\n return { blogPost, adjacent, related, breadcrumbs, ...pageMetaTags };\n};\n\nexport const entries = async () => {\n return getBlogPosts().map((post) => ({ slug: post.slug }));\n};\n", Us = "import { getBlogPosts } from \"$lib/content\";\n\nexport const prerender = true;\n\nfunction escapeXml(value: string) {\n return value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nexport const GET = async ({ locals }) => {\n const { appName, appURL } = locals.meta;\n const posts = getBlogPosts();\n const siteURL = appURL.replace(/\\/$/, \"\");\n const feedURL = `${siteURL}/blog/rss.xml`;\n const lastBuild = (\n posts[0]?.updatedDate ??\n posts[0]?.createdDate ??\n new Date()\n ).toUTCString();\n\n const items = posts\n .map((post) => {\n const link = `${siteURL}/blog/${post.slug}`;\n const pubDate = post.createdDate.toUTCString();\n const categories = (post.tags ?? [])\n .map((tag) => ` <category>${escapeXml(tag)}</category>`)\n .join(\"\\n\");\n const creator = post.author\n ? ` <dc:creator>${escapeXml(post.author.name)}</dc:creator>`\n : \"\";\n\n return [\n \" <item>\",\n ` <title>${escapeXml(post.title)}</title>`,\n ` <link>${escapeXml(link)}</link>`,\n ` <guid isPermaLink=\"true\">${escapeXml(link)}</guid>`,\n ` <description>${escapeXml(post.description)}</description>`,\n ` <pubDate>${pubDate}</pubDate>`,\n creator,\n categories,\n \" </item>\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n })\n .join(\"\\n\");\n\n const xml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n<channel>\n <title>${escapeXml(appName)}</title>\n <link>${escapeXml(`${siteURL}/blog`)}</link>\n <atom:link href=\"${escapeXml(feedURL)}\" rel=\"self\" type=\"application/rss+xml\" />\n <description>${escapeXml(`Latest posts from ${appName}.`)}</description>\n <language>en</language>\n <lastBuildDate>${lastBuild}</lastBuildDate>\n${items}\n</channel>\n</rss>\n`;\n\n return new Response(xml, {\n headers: {\n \"Content-Type\": \"application/xml; charset=utf-8\",\n \"Cache-Control\": \"max-age=0, s-maxage=3600\",\n },\n });\n};\n", Ws = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-8\">\n <header class=\"flex flex-col gap-2\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">Tags</h1>\n <p class=\"text-muted-foreground text-base\">\n {data.allTags.length}\n {data.allTags.length === 1 ? \"tag\" : \"tags\"} used across the blog.\n </p>\n </header>\n\n {#if data.allTags.length}\n <ul class=\"flex flex-wrap gap-2\">\n {#each data.allTags as { tag, count } (tag)}\n <li>\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">\n {tag}\n <span class=\"text-muted-foreground ml-0.5\">{count}</span>\n </Badge>\n </li>\n {/each}\n </ul>\n {:else}\n <p class=\"text-muted-foreground\">No tags yet.</p>\n {/if}\n</div>\n", Gs = "import { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags } from \"$lib/content\";\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const allTags = getAllTags();\n\n const pageMetaTags = definePageMetaTags({\n title: \"Tags\",\n description: \"All tags used on the blog.\",\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: \"Tags\", url: \"/blog/tags\" },\n ];\n\n return { allTags, breadcrumbs, ...pageMetaTags };\n};\n", Ks = "<script lang=\"ts\">\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-8\">\n <header class=\"flex flex-col gap-2\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">\n {data.tag}\n </h1>\n <p class=\"text-muted-foreground text-base\">\n {data.blogPosts.length}\n {data.blogPosts.length === 1 ? \"post\" : \"posts\"} tagged \"{data.tag}\".\n </p>\n </header>\n\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.blogPosts as post (post.slug)}\n <li class=\"flex\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n</div>\n", qs = "import { error } from \"@sveltejs/kit\";\nimport { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags, getBlogPostsByTag } from \"$lib/content\";\n\nexport const load = async ({ params, parent }) => {\n await parent();\n\n const blogPosts = getBlogPostsByTag(params.tag);\n\n if (blogPosts.length === 0) {\n throw error(404, \"Tag not found\");\n }\n\n const pageMetaTags = definePageMetaTags({\n title: `Posts tagged \"${params.tag}\"`,\n description: `Blog posts tagged \"${params.tag}\".`,\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: \"Tags\", url: \"/blog/tags\" },\n { title: params.tag, url: `/blog/tags/${params.tag}` },\n ];\n\n return { blogPosts, tag: params.tag, breadcrumbs, ...pageMetaTags };\n};\n\nexport const entries = async () => {\n return getAllTags().map(({ tag }) => ({ tag }));\n};\n", Js = "import { negotiate } from \"$lib/negotiate\";\nimport { getBlogPostRaw } from \"$lib/content\";\n\nexport const load = async ({ params, locals }) => {\n return {\n ...negotiate(locals, {\n \"text/markdown\": () => getBlogPostRaw(params.slug) ?? \"\",\n }),\n };\n};\n", Ys = /* @__PURE__ */ Object.assign({
|
|
4340
|
-
"./creates/
|
|
4341
|
-
"./creates/
|
|
4342
|
-
"./creates/
|
|
4343
|
-
"./creates/src/
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4350
|
+
}, Ds = "Sample data for development\n", Os = "# Hooks\n\nAdd \\*.pb.js hooks here to extend PocketBase: https://pocketbase.io/docs/js-overview/\n", ks = "Essential system-level data (e.g., roles, locales)\n", As = "import { env } from '$env/dynamic/private';\nimport { handlePocketbase } from '@velastack/pocketbase';\n\nexport const handle = handlePocketbase({\n pocketbaseUrl: env.POCKETBASE_URL,\n superuserEmail: env.POCKETBASE_SUPERUSER_EMAIL,\n superuserPassword: env.POCKETBASE_SUPERUSER_PASSWORD\n});\n", js = /* @__PURE__ */ Object.assign({
|
|
4351
|
+
"./creates/data/fixtures/README.md": Ds,
|
|
4352
|
+
"./creates/data/hooks/README.md": Os,
|
|
4353
|
+
"./creates/data/seeds/README.md": ks,
|
|
4354
|
+
"./creates/src/hooks.server.ts": As
|
|
4355
|
+
}), Ms = "./creates/";
|
|
4356
|
+
async function Ns(e) {
|
|
4357
|
+
return {
|
|
4358
|
+
creates: Object.entries(js).map(([e, t]) => {
|
|
4359
|
+
let n = o(e, Ms);
|
|
4360
|
+
return {
|
|
4361
|
+
path: n,
|
|
4362
|
+
language: r(n),
|
|
4363
|
+
content: t,
|
|
4364
|
+
status: "success"
|
|
4365
|
+
};
|
|
4366
|
+
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
4367
|
+
modifies: [],
|
|
4368
|
+
deletes: [],
|
|
4369
|
+
components: [],
|
|
4370
|
+
packages: ["@velastack/pocketbase", "pocketbase-sveltekit"],
|
|
4371
|
+
collections: [],
|
|
4372
|
+
collectionPatches: [],
|
|
4373
|
+
collectionDrops: []
|
|
4374
|
+
};
|
|
4375
|
+
}
|
|
4376
|
+
//#endregion
|
|
4377
|
+
//#region src/patterns/enable/backend/generate.preview.ts
|
|
4378
|
+
var Ps = /* @__PURE__ */ Object.assign({
|
|
4379
|
+
"./preview-modifies/svelte.config.js": "import adapter from '@sveltejs/adapter-auto';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n compilerOptions: {\n runes: ({ filename }) => (filename.split(/[/\\\\]/).includes('node_modules') ? undefined : true)\n },\n kit: {\n adapter: adapter()\n }\n};\n\nexport default config;\n",
|
|
4380
|
+
"./preview-modifies/test/setup.ts": "import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase';\n\nconst admin = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['admin'];\nconst pb = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email: string }) {\n await agent.post('/login').type('form').send({\n type: 'password',\n email: user.email,\n password: testUserPassword\n });\n}\n\nbeforeAll(async () => {\n await admin\n // @ts-ignore\n .collection('_superusers')\n .authWithPassword(\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!\n );\n});\n\nbeforeEach(async (context: TestContext) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!) as TestContext['agent'];\n context.admin = admin;\n context.pb = pb;\n context.user = await context.admin.collection('users').create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: testUserPassword,\n passwordConfirm: testUserPassword\n });\n context.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n await context.pb.collection('users').authWithPassword(context.user.email, testUserPassword);\n});\n\nafterEach(async (context: TestContext) => {\n await context.pb.authStore.clear();\n await context.admin.collection('users').delete(context.user.id);\n});\n"
|
|
4381
|
+
}), Fs = "./preview-modifies/";
|
|
4382
|
+
async function Is(e) {
|
|
4383
|
+
return {
|
|
4384
|
+
creates: [],
|
|
4385
|
+
modifies: Object.entries(Ps).map(([e, t]) => {
|
|
4386
|
+
let n = o(e, Fs);
|
|
4387
|
+
return {
|
|
4388
|
+
path: n,
|
|
4389
|
+
language: r(n),
|
|
4390
|
+
content: t,
|
|
4391
|
+
status: "success"
|
|
4392
|
+
};
|
|
4393
|
+
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
4394
|
+
deletes: [],
|
|
4395
|
+
components: [],
|
|
4396
|
+
packages: [],
|
|
4397
|
+
collections: [],
|
|
4398
|
+
collectionPatches: [],
|
|
4399
|
+
collectionDrops: []
|
|
4400
|
+
};
|
|
4401
|
+
}
|
|
4402
|
+
//#endregion
|
|
4403
|
+
//#region src/patterns/enable/backend/index.ts
|
|
4404
|
+
var Ls = "enable-backend", Rs = "1.0.0", zs = "src/patterns/enable/backend", Bs = "/enable/backend";
|
|
4405
|
+
async function Vs(e) {
|
|
4406
|
+
let t = await Ns(e);
|
|
4407
|
+
if (e.env === "preview") return y(n([t, await Is(e)]));
|
|
4408
|
+
let { generate: r } = await import("./chunks/generate.runtime-DFG2C9gc.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4409
|
+
return a(await y(n([t, i])), e);
|
|
4410
|
+
}
|
|
4411
|
+
var Hs = {
|
|
4412
|
+
version: Rs,
|
|
4413
|
+
slug: Ls,
|
|
4414
|
+
source: zs,
|
|
4415
|
+
docs: Bs,
|
|
4416
|
+
plan: "open",
|
|
4417
|
+
title: "Enable Backend",
|
|
4418
|
+
summary: "Adds the PocketBase backend: installs @velastack/pocketbase and pocketbase-sveltekit, wires up hooks.server.ts, scaffolds the data/ directory, and switches the SvelteKit adapter from static to auto.",
|
|
4419
|
+
requires: {
|
|
4420
|
+
auth: !1,
|
|
4421
|
+
api: !1,
|
|
4422
|
+
apiKeys: !1,
|
|
4423
|
+
backend: !1,
|
|
4424
|
+
i18n: !1,
|
|
4425
|
+
teams: !1,
|
|
4426
|
+
payments: !1,
|
|
4427
|
+
blog: !1,
|
|
4428
|
+
contentNegotiation: !1
|
|
4429
|
+
},
|
|
4430
|
+
category: "backend",
|
|
4431
|
+
tags: [
|
|
4432
|
+
"sveltekit",
|
|
4433
|
+
"pocketbase",
|
|
4434
|
+
"backend",
|
|
4435
|
+
"velastack"
|
|
4436
|
+
],
|
|
4437
|
+
command: {
|
|
4438
|
+
raw: "vela enable backend",
|
|
4439
|
+
base: "vela enable backend",
|
|
4440
|
+
argv: []
|
|
4441
|
+
},
|
|
4442
|
+
examples: [],
|
|
4443
|
+
tests: 0,
|
|
4444
|
+
baseline: "velastack",
|
|
4445
|
+
generate: Vs
|
|
4446
|
+
}, Us = "pre[class*='language-'],\ncode[class*='language-'] {\n color: #d4d4d4;\n font-size: 13px;\n text-shadow: none;\n font-family: Menlo, Monaco, Consolas, 'Andale Mono', 'Ubuntu Mono', 'Courier New', monospace;\n direction: ltr;\n text-align: left;\n white-space: pre;\n word-spacing: normal;\n word-break: normal;\n line-height: 1.5;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n -webkit-hyphens: none;\n -moz-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n}\n\npre[class*='language-']::selection,\ncode[class*='language-']::selection,\npre[class*='language-'] *::selection,\ncode[class*='language-'] *::selection {\n text-shadow: none;\n background: #264f78;\n}\n\n@media print {\n pre[class*='language-'],\n code[class*='language-'] {\n text-shadow: none;\n }\n}\n\npre[class*='language-'] {\n padding: 1em;\n margin: 0.5em 0;\n overflow: auto;\n background: oklch(0.21 0.034 264.665);\n}\n\n:not(pre) > code[class*='language-'] {\n padding: 0.1em 0.3em;\n border-radius: 0.3em;\n color: #db4c69;\n background: oklch(0.21 0.034 264.665);\n}\n/*********************************************************\n* Tokens\n*/\n.namespace {\n opacity: 0.7;\n}\n\n.token.doctype .token.doctype-tag {\n color: #569cd6;\n}\n\n.token.doctype .token.name {\n color: #9cdcfe;\n}\n\n.token.comment,\n.token.prolog {\n color: #6a9955;\n}\n\n.token.punctuation,\n.language-html .language-css .token.punctuation,\n.language-html .language-javascript .token.punctuation {\n color: #d4d4d4;\n}\n\n.token.property,\n.token.tag,\n.token.boolean,\n.token.number,\n.token.constant,\n.token.symbol,\n.token.inserted,\n.token.unit {\n color: #b5cea8;\n}\n\n.token.selector,\n.token.attr-name,\n.token.string,\n.token.char,\n.token.builtin,\n.token.deleted {\n color: #ce9178;\n}\n\n.language-css .token.string.url {\n text-decoration: underline;\n}\n\n.token.operator,\n.token.entity {\n color: #d4d4d4;\n}\n\n.token.operator.arrow {\n color: #569cd6;\n}\n\n.token.atrule {\n color: #ce9178;\n}\n\n.token.atrule .token.rule {\n color: #c586c0;\n}\n\n.token.atrule .token.url {\n color: #9cdcfe;\n}\n\n.token.atrule .token.url .token.function {\n color: #dcdcaa;\n}\n\n.token.atrule .token.url .token.punctuation {\n color: #d4d4d4;\n}\n\n.token.keyword {\n color: #569cd6;\n}\n\n.token.keyword.module,\n.token.keyword.control-flow {\n color: #c586c0;\n}\n\n.token.function,\n.token.function .token.maybe-class-name {\n color: #dcdcaa;\n}\n\n.token.regex {\n color: #d16969;\n}\n\n.token.important {\n color: #569cd6;\n}\n\n.token.italic {\n font-style: italic;\n}\n\n.token.constant {\n color: #9cdcfe;\n}\n\n.token.class-name,\n.token.maybe-class-name {\n color: #4ec9b0;\n}\n\n.token.console {\n color: #9cdcfe;\n}\n\n.token.parameter {\n color: #9cdcfe;\n}\n\n.token.interpolation {\n color: #9cdcfe;\n}\n\n.token.punctuation.interpolation-punctuation {\n color: #569cd6;\n}\n\n.token.boolean {\n color: #569cd6;\n}\n\n.token.property,\n.token.variable,\n.token.imports .token.maybe-class-name,\n.token.exports .token.maybe-class-name {\n color: #9cdcfe;\n}\n\n.token.selector {\n color: #d7ba7d;\n}\n\n.token.escape {\n color: #d7ba7d;\n}\n\n.token.tag {\n color: #569cd6;\n}\n\n.token.tag .token.punctuation {\n color: #808080;\n}\n\n.token.cdata {\n color: #808080;\n}\n\n.token.attr-name {\n color: #9cdcfe;\n}\n\n.token.attr-value,\n.token.attr-value .token.punctuation {\n color: #ce9178;\n}\n\n.token.attr-value .token.punctuation.attr-equals {\n color: #d4d4d4;\n}\n\n.token.entity {\n color: #569cd6;\n}\n\n.token.namespace {\n color: #4ec9b0;\n}\n/*********************************************************\n* Language Specific\n*/\n\npre[class*='language-javascript'],\ncode[class*='language-javascript'],\npre[class*='language-jsx'],\ncode[class*='language-jsx'],\npre[class*='language-typescript'],\ncode[class*='language-typescript'],\npre[class*='language-tsx'],\ncode[class*='language-tsx'] {\n color: #9cdcfe;\n}\n\npre[class*='language-css'],\ncode[class*='language-css'] {\n color: #ce9178;\n}\n\npre[class*='language-html'],\ncode[class*='language-html'] {\n color: #d4d4d4;\n}\n\n.language-regex .token.anchor {\n color: #dcdcaa;\n}\n\n.language-html .token.punctuation {\n color: #808080;\n}\n/*********************************************************\n* Line highlighting\n*/\npre[class*='language-'] > code[class*='language-'] {\n position: relative;\n z-index: 1;\n}\n\n.line-highlight.line-highlight {\n background: #f7ebc6;\n box-shadow: inset 5px 0 0 #f7d87c;\n z-index: 0;\n}\n", Ws = "<script lang=\"ts\">\n import * as Avatar from '$lib/components/ui/avatar';\n import type { BlogAuthor } from '$lib/content';\n\n let {\n author,\n size = 'sm'\n }: { author: BlogAuthor; size?: 'sm' | 'default' | 'lg' } = $props();\n\n const initials = $derived(\n author.name\n .split(/\\s+/)\n .map((part) => part[0])\n .filter(Boolean)\n .slice(0, 2)\n .join('')\n .toUpperCase()\n );\n<\/script>\n\n<span class=\"inline-flex items-center gap-2\">\n <Avatar.Root {size}>\n {#if author.avatar}\n <Avatar.Image src={author.avatar} alt={author.name} />\n {/if}\n <Avatar.Fallback class=\"text-xs\">{initials}</Avatar.Fallback>\n </Avatar.Root>\n <span class=\"text-foreground text-sm font-medium\">{author.name}</span>\n</span>\n", Gs = "<script lang=\"ts\">\n import * as Card from \"$lib/components/ui/card\";\n import { Badge } from \"$lib/components/ui/badge\";\n import AuthorChip from \"./AuthorChip.svelte\";\n import { formatDate } from \"$lib/utils/date\";\n import type { BlogPost, BlogPostSummary } from \"$lib/content\";\n\n let { post }: { post: BlogPost | BlogPostSummary } = $props();\n<\/script>\n\n<Card.Root class=\"hover:ring-foreground/20 h-full transition-shadow w-full\">\n <Card.Header>\n <Card.Title class=\"text-lg leading-snug\">\n <a href={`/blog/${post.slug}`} class=\"hover:underline\">\n {post.title}\n </a>\n </Card.Title>\n <Card.Description class=\"line-clamp-2\">\n {post.description}\n </Card.Description>\n </Card.Header>\n <Card.Content class=\"flex flex-1 flex-col justify-end gap-3\">\n {#if post.tags?.length}\n <div class=\"flex flex-wrap gap-1.5\">\n {#each post.tags as tag (tag)}\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">{tag}</Badge>\n {/each}\n </div>\n {/if}\n <div\n class=\"text-muted-foreground flex items-center justify-between gap-3 text-xs\"\n >\n {#if post.author}\n <AuthorChip author={post.author} />\n {:else}\n <span></span>\n {/if}\n <span class=\"whitespace-nowrap\">\n <time datetime={post.createdDate.toISOString()}\n >{formatDate(post.createdDate)}</time\n >\n <span aria-hidden=\"true\">•</span>\n <span>{post.readingTime} min read</span>\n </span>\n </div>\n </Card.Content>\n</Card.Root>\n", Ks = "---\ntitle: Design System Notes\ndescription: Small choices that make a design system feel coherent — spacing, radius, and the case for fewer variants.\ncreatedDate: 2025-12-15\ntags:\n - design\n - shadcn\nauthor:\n name: Ada Chen\n---\n\nWe've been cleaning up the design system recently. A few notes from the\npass, mostly for ourselves, partially in case they're useful to anyone\nelse building on top of shadcn.\n\n## The variants we actually use\n\nEvery primitive ships with a dozen variants. In practice our product\nleans on two or three per component:\n\n- **Buttons** — `default`, `ghost`, and `outline`. Destructive shows up\n rarely enough to be worth the extra click.\n- **Badges** — `default` and `secondary`. Tags and counts, nothing else.\n- **Cards** — one shape, with optional footer. Multiple card styles\n became indistinguishable from \"padded div,\" so we stopped.\n\nIf a variant hasn't appeared in a design in six months, it gets deleted.\nThe point isn't minimalism; it's that every extra variant is a decision\na future designer has to relitigate.\n\n## Spacing\n\nTailwind's default scale is good. We only locked in one rule: never use\nodd gaps. `gap-3` and `gap-5` stay; `gap-2.5` goes. It's a small thing\nthat quietly keeps vertical rhythm predictable across pages.\n\n## Radius\n\nOne radius token, applied everywhere. If a surface needs to feel\ndifferent, that's a structural decision — a card, a sheet, a popover —\nnot a one-off `rounded-md`. We ended up at `0.625rem` as our default\nand haven't wanted to change it.\n\n## Dark mode\n\nWe treat dark mode as a different palette, not a filter. Every token\nhas an explicit OKLCH value in both themes. When a component looks\noff in dark mode, the fix is almost always a token, not a tweak.\n", qs = "---\ntitle: Getting Started with SvelteKit\ndescription: The smallest useful SvelteKit project, explained end to end — routing, loading data, and the dev loop.\ncreatedDate: 2026-03-12\ntags:\n - sveltekit\n - tutorial\nauthor:\n name: Marco Alvarez\n---\n\nSvelteKit is the piece that turns Svelte — a component library — into\nsomething you can ship. Routing, server endpoints, data loading, builds,\nand deployment adapters all live in one place.\n\n## Creating a project\n\nThe fastest path is the CLI. It scaffolds a minimal project, installs\ndependencies, and leaves you with a working dev server.\n\n```bash\nnpx sv create my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\n## Routes are files\n\nA route is a folder under `src/routes` with a `+page.svelte` inside.\nNested folders produce nested URLs. Dynamic segments use `[brackets]`.\n\n```\nsrc/routes/\n +page.svelte # /\n about/\n +page.svelte # /about\n blog/\n [slug]/\n +page.svelte # /blog/:slug\n```\n\n## Loading data\n\nA route's `+page.ts` (or `+page.server.ts` for server-only data) exports\na `load` function. Whatever it returns becomes `data` on the page.\n\n```ts\n// src/routes/blog/[slug]/+page.ts\nimport { error } from '@sveltejs/kit';\n\nexport const load = async ({ params }) => {\n const post = await fetchPost(params.slug);\n if (!post) throw error(404, 'Not found');\n return { post };\n};\n```\n\nThat's most of SvelteKit. The rest — form actions, hooks, adapters — are\nopt-in once you need them.\n", Js = "---\ntitle: A Pragmatic Performance Checklist\ndescription: The small set of things that have given us the biggest performance wins — in rough order of impact.\ncreatedDate: 2025-11-03\ntags:\n - performance\n - tutorial\nauthor:\n name: Marco Alvarez\n---\n\nWe don't have a performance budget so much as a performance allergy.\nWhen something feels slow, we profile, fix the obvious thing, and move\non. The list below is what \"the obvious thing\" usually is.\n\n> Premature optimization is the root of all evil, but ignoring a 3s\n> cold-start isn't optimization — it's negligence.\n\n## The checklist\n\n1. **Measure with real numbers.** Lighthouse and the Network tab answer\n most questions. If you're not measuring, you're guessing.\n2. **Serve fewer bytes.** Compress images (AVIF or WebP), remove unused\n fonts, and audit any dependency over 50KB gzipped.\n3. **Defer the non-critical.** Scripts that aren't needed above the\n fold can wait. `loading=\"lazy\"` on images, `defer` on scripts, and\n dynamic `import()` for interactive widgets.\n4. **Cache at the edge.** If the same HTML could serve a thousand users,\n it should. Use your adapter's cache headers; don't hand-roll it.\n5. **Avoid waterfalls.** If page load depends on three sequential fetches,\n collapse them into one endpoint or preload the critical ones.\n6. **Trust the framework.** SvelteKit's `load` functions run in parallel\n by default and the compiler already strips unused code. Most hand-rolled\n cleverness just gets in the way.\n\n## What we stopped worrying about\n\n- Micro-optimizations inside component code — the bundle is small, the\n diff is fast. The savings are real but rarely matter.\n- Third-party tooling that promises \"speed.\" If it adds a build step,\n the benefit needs to be measurable, not theoretical.\n\n## When to go deeper\n\nIf the checklist doesn't move the needle, the next step is almost\nalways a deeper look at the data layer — query plans, N+1 fetches, cold\ncache behavior. But you should have exhausted the list above before\ngetting there. Most slowness is boring, and most fixes are too.\n", Ys = "---\ntitle: Welcome to the Blog\ndescription: A quick note on what this space is for and what to expect from us.\ncreatedDate: 2026-04-20\ntags:\n - announcements\nauthor:\n name: Ada Chen\n---\n\nWelcome in. This blog is where we write about the things we build, the\ndecisions behind them, and what we learn when they go sideways.\n\nYou can expect a mix of short notes and longer walkthroughs. No schedule,\nno filler. If a post exists it's because something was worth writing down.\n\nA few threads you'll see pop up often:\n\n- Product notes on what we're shipping and why\n- Practical tutorials for the tools we use every day\n- Design and engineering decisions that took more than five minutes\n\nIf you'd rather not check back manually, the [RSS feed](/blog/rss.xml)\nhas every post. Thanks for reading.\n", Xs = "---\ntitle: Why We Chose Tailwind v4\ndescription: Notes on moving from a traditional CSS pipeline to Tailwind v4's zero-config, CSS-first setup.\ncreatedDate: 2026-02-18\ntags:\n - tailwind\n - design\nauthor:\n name: Ada Chen\n---\n\nTailwind v4 is a meaningful rewrite. The surface API still looks the same\n— utility classes on elements — but the compiler, configuration model,\nand theming story all changed in ways that made us want to adopt it.\n\n> The point of a design system isn't to ship fewer classes. It's to make\n> the next decision easier than the last.\n\n## What changed for us\n\nThree things mattered:\n\n1. **CSS-first config.** `tailwind.config.js` is gone. Tokens live in\n `app.css` as real CSS custom properties, which means they also work\n outside of Tailwind — SVG fills, inline styles, wherever.\n2. **OKLCH colors.** Designers can reason about lightness and chroma\n independently. Contrast checks become much easier to eyeball.\n3. **Speed.** The new engine compiles fast enough that we stopped\n thinking about purge lists. Dev feedback is effectively instant.\n\n## The config we kept\n\nWe pinned two things in `app.css`:\n\n```css\n@import 'tailwindcss';\n@plugin '@tailwindcss/typography';\n\n:root {\n --radius: 0.625rem;\n --background: oklch(1 0 0);\n --foreground: oklch(0.129 0.042 264.695);\n}\n```\n\nEverything else — spacing, typography, breakpoints — falls back to\ndefaults until we have a reason to override it.\n\n## What we'd tell a team evaluating it\n\nIf you're already using Tailwind v3, the migration is mostly a config\nmove. If you're starting from scratch, v4 removes a pile of decisions\nyou'd otherwise be making on day one. That alone made it worth it.\n", Zs = "---\ntitle: Writing Posts with MDsveX\ndescription: How this blog turns markdown files into real Svelte components — frontmatter, code, and embedded UI.\ncreatedDate: 2026-01-28\nupdatedDate: 2026-02-02\ntags:\n - mdsvex\n - tutorial\nauthor:\n name: Priya Shah\n---\n\nPosts on this blog are `.svx` files. Each one is a real Svelte component\nat build time, so Markdown and Svelte sit side by side with no glue\ncode.\n\n## Frontmatter\n\nYAML at the top of a post becomes the `metadata` export. The loader\nreads it to build the list view, tag pages, and RSS feed.\n\n```yaml\n---\ntitle: Writing Posts with MDsveX\ndescription: A short description shown in previews.\ncreatedDate: 2026-01-28\ntags:\n - mdsvex\n - tutorial\nauthor:\n name: Priya Shah\n---\n```\n\n## Markdown works the way you'd expect\n\nHeadings, lists, links, blockquotes, and inline `code` all render.\nFenced code blocks pick up language hints for syntax highlighting when a\nplugin is enabled.\n\n```ts\nfunction greet(name: string) {\n return `hello, ${name}`;\n}\n```\n\n## Images\n\nPut images in `static/` and reference them with a root-relative path:\n\n```md\n\n```\n\n## Svelte in your posts\n\nThe superpower is that you can drop components straight into a post —\na chart, an interactive demo, a call-to-action card. The rules are the\nsame as any other Svelte file:\n\n```svelte\n<script>\n import Callout from '$lib/components/Callout.svelte';\n<\/script>\n\n<Callout>This is a real component inside a markdown post.</Callout>\n```\n\nThat's the whole pipeline. Write markdown, sprinkle in components when\nplain text stops being enough, and the rest is just Svelte.\n", Qs = "import type { Component } from \"svelte\";\n\nexport type BlogAuthor = {\n name: string;\n avatar?: string;\n};\n\nexport type BlogMetadata = {\n title: string;\n description: string;\n createdDate: string;\n updatedDate?: string;\n tags?: string[];\n author?: BlogAuthor;\n};\n\nexport type BlogModules = Record<\n string,\n { default: Component; metadata: BlogMetadata }\n>;\n\nexport type BlogRawModules = Record<string, string>;\n\nexport type BlogPost = {\n slug: string;\n title: string;\n description: string;\n createdDate: Date;\n updatedDate?: Date;\n tags?: string[];\n author?: BlogAuthor;\n readingTime: number;\n component: Component;\n};\n\nexport type BlogPostSummary = Omit<BlogPost, \"component\">;\n\nconst WORDS_PER_MINUTE = 220;\n\nfunction getBlogModules() {\n return import.meta.glob(\"$lib/content/blog/*.svx\", {\n eager: true,\n }) as BlogModules;\n}\n\nfunction getBlogRawModules() {\n return import.meta.glob(\"$lib/content/blog/*.svx\", {\n eager: true,\n query: \"?raw\",\n import: \"default\",\n }) as BlogRawModules;\n}\n\nfunction stripFrontmatter(raw: string) {\n if (!raw.startsWith(\"---\")) return raw;\n const end = raw.indexOf(\"\\n---\", 3);\n if (end === -1) return raw;\n return raw.slice(end + 4);\n}\n\nfunction computeReadingTime(raw: string) {\n const body = stripFrontmatter(raw);\n const words = body.split(/\\s+/).filter(Boolean).length;\n return Math.max(1, Math.ceil(words / WORDS_PER_MINUTE));\n}\n\nexport function getBlogPosts(): BlogPost[] {\n const modules = getBlogModules();\n const rawModules = getBlogRawModules();\n\n const posts = Object.entries(modules).map(([path, module]) => {\n const filename = path.split(\"/\").pop() ?? \"\";\n const slug = filename.replace(\".svx\", \"\");\n const raw = rawModules[path] ?? \"\";\n\n return {\n slug,\n title: module.metadata.title,\n description: module.metadata.description,\n createdDate: new Date(module.metadata.createdDate),\n updatedDate: module.metadata.updatedDate\n ? new Date(module.metadata.updatedDate)\n : undefined,\n tags: module.metadata.tags,\n author: module.metadata.author,\n readingTime: computeReadingTime(raw),\n component: module.default,\n };\n });\n\n posts.sort((a, b) => b.createdDate.getTime() - a.createdDate.getTime());\n return posts;\n}\n\nexport function getBlogPost(slug: string) {\n const posts = getBlogPosts();\n return posts.find((post) => post.slug === slug) ?? null;\n}\n\nexport function getBlogPostRaw(slug: string): string | null {\n const rawModules = getBlogRawModules();\n for (const [path, raw] of Object.entries(rawModules)) {\n const filename = path.split(\"/\").pop() ?? \"\";\n if (filename.replace(\".svx\", \"\") === slug) return raw;\n }\n return null;\n}\n\nexport function getBlogPostsByTag(tag: string) {\n return getBlogPosts().filter((post) => post.tags?.includes(tag));\n}\n\nexport function getAllTags(): { tag: string; count: number }[] {\n const counts = new Map<string, number>();\n for (const post of getBlogPosts()) {\n for (const tag of post.tags ?? []) {\n counts.set(tag, (counts.get(tag) ?? 0) + 1);\n }\n }\n return [...counts.entries()]\n .map(([tag, count]) => ({ tag, count }))\n .sort((a, b) => b.count - a.count || a.tag.localeCompare(b.tag));\n}\n\nexport function getAdjacentPosts(slug: string): {\n prev: BlogPost | null;\n next: BlogPost | null;\n} {\n const posts = getBlogPosts();\n const index = posts.findIndex((post) => post.slug === slug);\n if (index === -1) return { prev: null, next: null };\n return {\n next: index > 0 ? posts[index - 1] : null,\n prev: index < posts.length - 1 ? posts[index + 1] : null,\n };\n}\n\nexport function getRelatedPosts(slug: string, limit = 3): BlogPost[] {\n const posts = getBlogPosts();\n const current = posts.find((post) => post.slug === slug);\n if (!current?.tags?.length) return [];\n\n const currentTags = new Set(current.tags);\n\n return posts\n .filter((post) => post.slug !== slug && post.tags?.length)\n .map((post) => ({\n post,\n overlap: post.tags!.filter((tag) => currentTags.has(tag)).length,\n }))\n .filter(({ overlap }) => overlap > 0)\n .sort(\n (a, b) =>\n b.overlap - a.overlap ||\n b.post.createdDate.getTime() - a.post.createdDate.getTime(),\n )\n .slice(0, limit)\n .map(({ post }) => post);\n}\n", $s = "const formatter = new Intl.DateTimeFormat(\"en-US\", {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n});\n\nexport function formatDate(date: Date) {\n return formatter.format(date);\n}\n", ec = "<script lang=\"ts\">\n import * as Breadcrumb from \"$lib/components/ui/breadcrumb\";\n import { page } from \"$app/state\";\n\n let { children } = $props();\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as {\n title: string;\n url: string;\n }[];\n<\/script>\n\n<section data-role=\"content\">\n <Breadcrumb.Root class=\"mb-6\">\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}\n >{breadcrumb.title}</Breadcrumb.Link\n >\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n\n {@render children?.()}\n</section>\n", tc = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n import { Button } from \"$lib/components/ui/button\";\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n import Rss from \"@lucide/svelte/icons/rss\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-10\">\n <header\n class=\"flex flex-col gap-4 md:flex-row md:items-end md:justify-between\"\n >\n <div class=\"max-w-2xl\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">Blog</h1>\n <p class=\"text-muted-foreground mt-2 text-base\">\n Product notes, tutorials, and engineering posts from the team.\n </p>\n </div>\n <Button href=\"/blog/rss.xml\" variant=\"outline\" size=\"sm\" class=\"w-fit\">\n <Rss class=\"size-4\" />\n RSS\n </Button>\n </header>\n\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.blogPosts as post (post.slug)}\n <li class=\"flex w-full\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n</div>\n", nc = "import { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags, getBlogPosts } from \"$lib/content\";\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const blogPosts = getBlogPosts();\n const allTags = getAllTags();\n\n const pageMetaTags = definePageMetaTags({\n title: \"Blog\",\n description: \"Product notes, tutorials, and engineering posts.\",\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n ];\n\n return { blogPosts, allTags, breadcrumbs, ...pageMetaTags };\n};\n", rc = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n import { Separator } from \"$lib/components/ui/separator\";\n import AuthorChip from \"$lib/components/blog/AuthorChip.svelte\";\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n import { formatDate } from \"$lib/utils/date\";\n import * as Breadcrumb from \"$lib/components/ui/breadcrumb\";\n import ArrowLeft from \"@lucide/svelte/icons/arrow-left\";\n import ArrowRight from \"@lucide/svelte/icons/arrow-right\";\n import { page } from \"$app/state\";\n\n let { data } = $props();\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as {\n title: string;\n url: string;\n }[];\n<\/script>\n\n<div class=\"flex flex-col gap-6\">\n <header class=\"flex flex-col gap-5 border-b border-border pb-8\">\n <div class=\"flex flex-col gap-3\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">\n {data.blogPost.title}\n </h1>\n <p class=\"text-muted-foreground text-lg\">\n {data.blogPost.description}\n </p>\n </div>\n\n <div\n class=\"text-muted-foreground flex flex-wrap items-center gap-x-1 gap-y-2 text-sm\"\n >\n {#if data.blogPost.author}\n <AuthorChip author={data.blogPost.author} />\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n {/if}\n <time datetime={data.blogPost.createdDate.toISOString()}>\n {formatDate(data.blogPost.createdDate)}\n </time>\n {#if data.blogPost.updatedDate}\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n <span>Updated {formatDate(data.blogPost.updatedDate)}</span>\n {/if}\n <span aria-hidden=\"true\" class=\"text-muted-foreground/50\">•</span>\n <span>{data.blogPost.readingTime} min read</span>\n </div>\n\n {#if data.blogPost.tags?.length}\n <div class=\"flex flex-wrap gap-1.5\">\n {#each data.blogPost.tags as tag (tag)}\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">{tag}</Badge>\n {/each}\n </div>\n {/if}\n </header>\n\n <article\n class=\"prose dark:prose-invert max-w-prose prose-headings:mb-0 prose-headings:mt-4\"\n >\n <data.blogPost.component />\n </article>\n\n <Separator />\n\n <nav class=\"grid gap-3 sm:grid-cols-2\" aria-label=\"Post navigation\">\n {#if data.adjacent.prev}\n <a\n href={`/blog/${data.adjacent.prev.slug}`}\n class=\"ring-foreground/10 hover:ring-foreground/20 bg-card text-card-foreground group flex flex-col gap-1 rounded-xl p-4 ring-1 transition-shadow\"\n >\n <span\n class=\"text-muted-foreground inline-flex items-center gap-1 text-xs font-medium uppercase tracking-wide\"\n >\n <ArrowLeft class=\"size-3.5\" />\n Previous\n </span>\n <span class=\"font-medium group-hover:underline\"\n >{data.adjacent.prev.title}</span\n >\n </a>\n {:else}\n <div></div>\n {/if}\n\n {#if data.adjacent.next}\n <a\n href={`/blog/${data.adjacent.next.slug}`}\n class=\"ring-foreground/10 hover:ring-foreground/20 bg-card text-card-foreground group flex flex-col gap-1 rounded-xl p-4 text-right ring-1 transition-shadow sm:col-start-2\"\n >\n <span\n class=\"text-muted-foreground inline-flex items-center justify-end gap-1 text-xs font-medium uppercase tracking-wide\"\n >\n Next\n <ArrowRight class=\"size-3.5\" />\n </span>\n <span class=\"font-medium group-hover:underline\"\n >{data.adjacent.next.title}</span\n >\n </a>\n {/if}\n </nav>\n\n {#if data.related.length}\n <section class=\"flex flex-col gap-4\">\n <Separator />\n <h2 class=\"text-xl font-semibold tracking-tight\">Related posts</h2>\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.related as post (post.slug)}\n <li class=\"flex\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n </section>\n {/if}\n</div>\n", ic = "import { error } from \"@sveltejs/kit\";\nimport { definePageMetaTags } from \"svelte-meta-tags\";\nimport {\n getAdjacentPosts,\n getBlogPost,\n getBlogPosts,\n getRelatedPosts,\n} from \"$lib/content\";\n\nexport const load = async ({ params, parent }) => {\n await parent();\n\n const blogPost = getBlogPost(params.slug);\n\n if (blogPost === null) {\n throw error(404, \"Page not found\");\n }\n\n const adjacent = getAdjacentPosts(params.slug);\n const related = getRelatedPosts(params.slug);\n\n const pageMetaTags = definePageMetaTags({\n title: blogPost.title,\n description: blogPost.description,\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: blogPost.title, url: `/blog/${blogPost.slug}` },\n ];\n\n return { blogPost, adjacent, related, breadcrumbs, ...pageMetaTags };\n};\n\nexport const entries = async () => {\n return getBlogPosts().map((post) => ({ slug: post.slug }));\n};\n", ac = "import { getBlogPosts } from \"$lib/content\";\n\nexport const prerender = true;\n\nfunction escapeXml(value: string) {\n return value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nexport const GET = async ({ locals }) => {\n const { appName, appURL } = locals.meta;\n const posts = getBlogPosts();\n const siteURL = appURL.replace(/\\/$/, \"\");\n const feedURL = `${siteURL}/blog/rss.xml`;\n const lastBuild = (\n posts[0]?.updatedDate ??\n posts[0]?.createdDate ??\n new Date()\n ).toUTCString();\n\n const items = posts\n .map((post) => {\n const link = `${siteURL}/blog/${post.slug}`;\n const pubDate = post.createdDate.toUTCString();\n const categories = (post.tags ?? [])\n .map((tag) => ` <category>${escapeXml(tag)}</category>`)\n .join(\"\\n\");\n const creator = post.author\n ? ` <dc:creator>${escapeXml(post.author.name)}</dc:creator>`\n : \"\";\n\n return [\n \" <item>\",\n ` <title>${escapeXml(post.title)}</title>`,\n ` <link>${escapeXml(link)}</link>`,\n ` <guid isPermaLink=\"true\">${escapeXml(link)}</guid>`,\n ` <description>${escapeXml(post.description)}</description>`,\n ` <pubDate>${pubDate}</pubDate>`,\n creator,\n categories,\n \" </item>\",\n ]\n .filter(Boolean)\n .join(\"\\n\");\n })\n .join(\"\\n\");\n\n const xml = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n<channel>\n <title>${escapeXml(appName)}</title>\n <link>${escapeXml(`${siteURL}/blog`)}</link>\n <atom:link href=\"${escapeXml(feedURL)}\" rel=\"self\" type=\"application/rss+xml\" />\n <description>${escapeXml(`Latest posts from ${appName}.`)}</description>\n <language>en</language>\n <lastBuildDate>${lastBuild}</lastBuildDate>\n${items}\n</channel>\n</rss>\n`;\n\n return new Response(xml, {\n headers: {\n \"Content-Type\": \"application/xml; charset=utf-8\",\n \"Cache-Control\": \"max-age=0, s-maxage=3600\",\n },\n });\n};\n", oc = "<script lang=\"ts\">\n import { Badge } from \"$lib/components/ui/badge\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-8\">\n <header class=\"flex flex-col gap-2\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">Tags</h1>\n <p class=\"text-muted-foreground text-base\">\n {data.allTags.length}\n {data.allTags.length === 1 ? \"tag\" : \"tags\"} used across the blog.\n </p>\n </header>\n\n {#if data.allTags.length}\n <ul class=\"flex flex-wrap gap-2\">\n {#each data.allTags as { tag, count } (tag)}\n <li>\n <Badge href={`/blog/tags/${tag}`} variant=\"secondary\">\n {tag}\n <span class=\"text-muted-foreground ml-0.5\">{count}</span>\n </Badge>\n </li>\n {/each}\n </ul>\n {:else}\n <p class=\"text-muted-foreground\">No tags yet.</p>\n {/if}\n</div>\n", sc = "import { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags } from \"$lib/content\";\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const allTags = getAllTags();\n\n const pageMetaTags = definePageMetaTags({\n title: \"Tags\",\n description: \"All tags used on the blog.\",\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: \"Tags\", url: \"/blog/tags\" },\n ];\n\n return { allTags, breadcrumbs, ...pageMetaTags };\n};\n", cc = "<script lang=\"ts\">\n import PostCard from \"$lib/components/blog/PostCard.svelte\";\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-8\">\n <header class=\"flex flex-col gap-2\">\n <h1 class=\"text-3xl font-semibold tracking-tight sm:text-4xl\">\n {data.tag}\n </h1>\n <p class=\"text-muted-foreground text-base\">\n {data.blogPosts.length}\n {data.blogPosts.length === 1 ? \"post\" : \"posts\"} tagged \"{data.tag}\".\n </p>\n </header>\n\n <ul class=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.blogPosts as post (post.slug)}\n <li class=\"flex\">\n <PostCard {post} />\n </li>\n {/each}\n </ul>\n</div>\n", lc = "import { error } from \"@sveltejs/kit\";\nimport { definePageMetaTags } from \"svelte-meta-tags\";\nimport { getAllTags, getBlogPostsByTag } from \"$lib/content\";\n\nexport const load = async ({ params, parent }) => {\n await parent();\n\n const blogPosts = getBlogPostsByTag(params.tag);\n\n if (blogPosts.length === 0) {\n throw error(404, \"Tag not found\");\n }\n\n const pageMetaTags = definePageMetaTags({\n title: `Posts tagged \"${params.tag}\"`,\n description: `Blog posts tagged \"${params.tag}\".`,\n });\n\n const breadcrumbs = [\n { title: \"Home\", url: \"/\" },\n { title: \"Blog\", url: \"/blog\" },\n { title: \"Tags\", url: \"/blog/tags\" },\n { title: params.tag, url: `/blog/tags/${params.tag}` },\n ];\n\n return { blogPosts, tag: params.tag, breadcrumbs, ...pageMetaTags };\n};\n\nexport const entries = async () => {\n return getAllTags().map(({ tag }) => ({ tag }));\n};\n", uc = "import { negotiate } from \"$lib/negotiate\";\nimport { getBlogPostRaw } from \"$lib/content\";\n\nexport const load = async ({ params, locals }) => {\n return {\n ...negotiate(locals, {\n \"text/markdown\": () => getBlogPostRaw(params.slug) ?? \"\",\n }),\n };\n};\n", dc = /* @__PURE__ */ Object.assign({
|
|
4447
|
+
"./creates/src/css/prism-vsc-dark-plus.css": Us,
|
|
4448
|
+
"./creates/src/lib/components/blog/AuthorChip.svelte": Ws,
|
|
4449
|
+
"./creates/src/lib/components/blog/PostCard.svelte": Gs,
|
|
4450
|
+
"./creates/src/lib/content/blog/design-system-notes.svx": Ks,
|
|
4451
|
+
"./creates/src/lib/content/blog/getting-started-with-sveltekit.svx": qs,
|
|
4452
|
+
"./creates/src/lib/content/blog/performance-checklist.svx": Js,
|
|
4453
|
+
"./creates/src/lib/content/blog/welcome-to-the-blog.svx": Ys,
|
|
4454
|
+
"./creates/src/lib/content/blog/why-we-chose-tailwind-v4.svx": Xs,
|
|
4455
|
+
"./creates/src/lib/content/blog/writing-posts-with-mdsvex.svx": Zs,
|
|
4456
|
+
"./creates/src/lib/content.ts": Qs,
|
|
4457
|
+
"./creates/src/lib/utils/date.ts": $s,
|
|
4458
|
+
"./creates/src/routes/(public)/blog/+layout.svelte": ec,
|
|
4459
|
+
"./creates/src/routes/(public)/blog/+page.svelte": tc,
|
|
4460
|
+
"./creates/src/routes/(public)/blog/+page.ts": nc,
|
|
4461
|
+
"./creates/src/routes/(public)/blog/[slug]/+page.svelte": rc,
|
|
4462
|
+
"./creates/src/routes/(public)/blog/[slug]/+page.ts": ic,
|
|
4463
|
+
"./creates/src/routes/(public)/blog/rss.xml/+server.ts": ac,
|
|
4464
|
+
"./creates/src/routes/(public)/blog/tags/+page.svelte": oc,
|
|
4465
|
+
"./creates/src/routes/(public)/blog/tags/+page.ts": sc,
|
|
4466
|
+
"./creates/src/routes/(public)/blog/tags/[tag]/+page.svelte": cc,
|
|
4467
|
+
"./creates/src/routes/(public)/blog/tags/[tag]/+page.ts": lc
|
|
4468
|
+
}), fc = /* @__PURE__ */ Object.assign({ "./creates-with-negotiation/src/routes/(public)/blog/[slug]/+page.server.ts": uc }), pc = "./creates/", mc = "./creates-with-negotiation/";
|
|
4469
|
+
function hc(e, t) {
|
|
4363
4470
|
let n = {};
|
|
4364
4471
|
for (let [i, a] of Object.entries(e)) {
|
|
4365
4472
|
let e = o(i, t);
|
|
@@ -4372,10 +4479,10 @@ function $s(e, t) {
|
|
|
4372
4479
|
}
|
|
4373
4480
|
return n;
|
|
4374
4481
|
}
|
|
4375
|
-
async function
|
|
4376
|
-
let t = {
|
|
4482
|
+
async function gc(e) {
|
|
4483
|
+
let t = { ...hc(dc, pc) };
|
|
4377
4484
|
if (e.features.contentNegotiation) {
|
|
4378
|
-
let e =
|
|
4485
|
+
let e = hc(fc, mc);
|
|
4379
4486
|
Object.assign(t, e);
|
|
4380
4487
|
}
|
|
4381
4488
|
return {
|
|
@@ -4397,16 +4504,16 @@ async function ec(e) {
|
|
|
4397
4504
|
}
|
|
4398
4505
|
//#endregion
|
|
4399
4506
|
//#region src/patterns/enable/blog/generate.preview.ts
|
|
4400
|
-
var
|
|
4507
|
+
var _c = /* @__PURE__ */ Object.assign({
|
|
4401
4508
|
"./preview-modifies/src/routes/(public)/root-layout.svelte": "<script lang=\"ts\">\n import { toggleMode } from 'mode-watcher';\n import * as Navbar from '$lib/components/ui/navbar';\n import { Button } from '$lib/components/ui/button';\n\n let { children, data } = $props();\n<\/script>\n\n<div class=\"min-h-dvh grid grid-rows-[max-content_1fr_max-content] root-layout\">\n <Navbar.Root>\n <Navbar.Brand href=\"/\">\n <Navbar.Logo src=\"/favicon.svg\" alt=\"Logo\" />\n </Navbar.Brand>\n\n <Navbar.MobileToggle />\n\n <Navbar.List>\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/\" variant=\"ghost\">\n Home\n </Button>\n </Navbar.Item>\n <!-- [!code highlight:5] -->\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n </Navbar.List>\n </Navbar.Root>\n\n {@render children?.()}\n\n <footer class=\"border-t border-border py-4\">\n <div\n class=\"mx-auto flex max-w-7xl px-4 flex-col items-center justify-between gap-3 sm:flex-row\"\n >\n <p class=\"text-muted-foreground text-sm\">\n © {new Date().getFullYear()}\n {data.meta.appName}. All rights reserved.\n </p>\n <nav class=\"flex items-center gap-4 text-sm\">\n <Button onclick={toggleMode} variant=\"ghost\" size=\"icon\">\n <Navbar.Mode />\n </Button>\n <a href=\"/privacy\" class=\"underline-offset-4 hover:underline\">Privacy</a>\n <a href=\"/terms\" class=\"underline-offset-4 hover:underline\">Terms</a>\n </nav>\n </div>\n </footer>\n</div>\n\n<style lang=\"postcss\">\n @reference \"tailwindcss\";\n\n .root-layout :global(section[data-role='content']) {\n @apply container mx-auto max-w-7xl px-4 py-8 w-full;\n }\n</style>\n",
|
|
4402
4509
|
"./preview-modifies/src/routes/+layout.svelte": "<script lang=\"ts\">\n import '../app.css';\n // [!code highlight:1]\n import '../css/prism-vsc-dark-plus.css';\n\n import { ModeWatcher } from 'mode-watcher';\n import { getFlash } from 'sveltekit-flash-message';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { Toaster } from '$lib/components/ui/sonner';\n import { MetaTags, deepMerge } from 'svelte-meta-tags';\n\n let { data, children } = $props();\n const flash = getFlash(page);\n\n $effect(() => {\n if (!$flash || $flash.type !== 'toast') {\n return;\n }\n\n toast.message($flash.message);\n\n $flash = undefined;\n });\n\n let metaTags = $derived(deepMerge(data.baseMetaTags, page.data.pageMetaTags));\n<\/script>\n\n<svelte:head>\n <title>{data.meta.appName}</title>\n</svelte:head>\n\n<MetaTags {...metaTags} />\n<ModeWatcher />\n<Toaster />\n\n{@render children?.()}\n",
|
|
4403
4510
|
"./preview-modifies/svelte.config.js": "import adapter from \"@sveltejs/adapter-auto\";\n// [!code highlight:1]\nimport { mdsvex } from \"mdsvex\";\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n // [!code highlight:2]\n extensions: [\".svelte\", \".svx\"],\n preprocess: [mdsvex()],\n compilerOptions: {\n // Force runes mode for the project, except for libraries. Can be removed in svelte 6.\n runes: ({ filename }) =>\n filename.split(/[/\\\\]/).includes(\"node_modules\") ? undefined : true,\n },\n kit: {\n // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n // If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n // See https://svelte.dev/docs/kit/adapters for more information about adapters.\n adapter: adapter(),\n },\n};\n\nexport default config;\n"
|
|
4404
|
-
}),
|
|
4405
|
-
async function
|
|
4511
|
+
}), vc = "./preview-modifies/";
|
|
4512
|
+
async function yc(e) {
|
|
4406
4513
|
return {
|
|
4407
4514
|
creates: [],
|
|
4408
|
-
modifies: Object.entries(
|
|
4409
|
-
let n = o(e,
|
|
4515
|
+
modifies: Object.entries(_c).map(([e, t]) => {
|
|
4516
|
+
let n = o(e, vc);
|
|
4410
4517
|
return {
|
|
4411
4518
|
path: n,
|
|
4412
4519
|
language: r(n),
|
|
@@ -4424,18 +4531,18 @@ async function rc(e) {
|
|
|
4424
4531
|
}
|
|
4425
4532
|
//#endregion
|
|
4426
4533
|
//#region src/patterns/enable/blog/index.ts
|
|
4427
|
-
var
|
|
4428
|
-
async function
|
|
4429
|
-
let t = await
|
|
4430
|
-
if (e.env === "preview") return y(n([t, await
|
|
4431
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
4534
|
+
var bc = "enable-blog", xc = "1.0.0", Sc = "src/patterns/enable/blog", Cc = "/enable/blog";
|
|
4535
|
+
async function wc(e) {
|
|
4536
|
+
let t = await gc(e);
|
|
4537
|
+
if (e.env === "preview") return y(n([t, await yc(e)]));
|
|
4538
|
+
let { generate: r } = await import("./chunks/generate.runtime-M6LNL7Tq.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4432
4539
|
return a(await y(n([t, i])), e);
|
|
4433
4540
|
}
|
|
4434
|
-
var
|
|
4435
|
-
version:
|
|
4436
|
-
slug:
|
|
4437
|
-
source:
|
|
4438
|
-
docs:
|
|
4541
|
+
var Tc = {
|
|
4542
|
+
version: xc,
|
|
4543
|
+
slug: bc,
|
|
4544
|
+
source: Sc,
|
|
4545
|
+
docs: Cc,
|
|
4439
4546
|
plan: "open",
|
|
4440
4547
|
title: "Enable blog",
|
|
4441
4548
|
summary: "Adds an mdsvex-powered blog with post list, tags, RSS feed, and example posts.",
|
|
@@ -4443,6 +4550,7 @@ var lc = {
|
|
|
4443
4550
|
auth: !1,
|
|
4444
4551
|
api: !1,
|
|
4445
4552
|
apiKeys: !1,
|
|
4553
|
+
backend: !0,
|
|
4446
4554
|
i18n: !1,
|
|
4447
4555
|
teams: !1,
|
|
4448
4556
|
payments: !1,
|
|
@@ -4466,14 +4574,14 @@ var lc = {
|
|
|
4466
4574
|
examples: [],
|
|
4467
4575
|
tests: 0,
|
|
4468
4576
|
baseline: "velastack",
|
|
4469
|
-
generate:
|
|
4470
|
-
},
|
|
4471
|
-
"./creates/src/lib/negotiate.ts":
|
|
4472
|
-
"./creates/src/routes/(public)/negotiate/+page.server.ts":
|
|
4473
|
-
"./creates/src/routes/(public)/negotiate/+page.svelte":
|
|
4474
|
-
"./creates/src/routes/(public)/negotiate/+page.ts":
|
|
4475
|
-
}),
|
|
4476
|
-
function
|
|
4577
|
+
generate: wc
|
|
4578
|
+
}, Ec = "import { createNegotiation } from \"sveltekit-negotiate\";\n\nexport const { handle, reroute, negotiate, Negotiate } = createNegotiation({\n \"text/markdown\": { extension: \".md\" },\n \"application/json\": { extension: \".json\" },\n});\n", Dc = "import { negotiate } from \"$lib/negotiate\";\n\nexport const load = async ({ locals }) => {\n const message = \"Hello, content negotiation!\";\n\n return {\n message,\n ...negotiate(locals, {\n \"text/markdown\": () => `# ${message}`,\n }),\n };\n};\n", Oc = "<script lang=\"ts\">\n let { data } = $props();\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"text-2xl font-bold\">{data.message}</h1>\n</section>\n", kc = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Negotiate'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ac = "import { negotiate } from \"$lib/negotiate\";\nimport { getBlogPostRaw } from \"$lib/content\";\n\nexport const load = async ({ params, locals }) => {\n return {\n ...negotiate(locals, {\n \"text/markdown\": () => getBlogPostRaw(params.slug) ?? \"\",\n }),\n };\n};\n", jc = /* @__PURE__ */ Object.assign({
|
|
4579
|
+
"./creates/src/lib/negotiate.ts": Ec,
|
|
4580
|
+
"./creates/src/routes/(public)/negotiate/+page.server.ts": Dc,
|
|
4581
|
+
"./creates/src/routes/(public)/negotiate/+page.svelte": Oc,
|
|
4582
|
+
"./creates/src/routes/(public)/negotiate/+page.ts": kc
|
|
4583
|
+
}), Mc = /* @__PURE__ */ Object.assign({ "./creates-with-blog/src/routes/(public)/blog/[slug]/+page.server.ts": Ac }), Nc = "./creates/", Pc = "./creates-with-blog/";
|
|
4584
|
+
function Fc(e, t) {
|
|
4477
4585
|
let n = {};
|
|
4478
4586
|
for (let [i, a] of Object.entries(e)) {
|
|
4479
4587
|
let e = o(i, t);
|
|
@@ -4486,10 +4594,10 @@ function yc(e, t) {
|
|
|
4486
4594
|
}
|
|
4487
4595
|
return n;
|
|
4488
4596
|
}
|
|
4489
|
-
async function
|
|
4490
|
-
let t = { ...
|
|
4597
|
+
async function Ic(e) {
|
|
4598
|
+
let t = { ...Fc(jc, Nc) };
|
|
4491
4599
|
if (e.features.blog) {
|
|
4492
|
-
let e =
|
|
4600
|
+
let e = Fc(Mc, Pc);
|
|
4493
4601
|
Object.assign(t, e);
|
|
4494
4602
|
}
|
|
4495
4603
|
return {
|
|
@@ -4505,15 +4613,15 @@ async function bc(e) {
|
|
|
4505
4613
|
}
|
|
4506
4614
|
//#endregion
|
|
4507
4615
|
//#region src/patterns/enable/content-negotiation/generate.preview.ts
|
|
4508
|
-
var
|
|
4616
|
+
var Lc = /* @__PURE__ */ Object.assign({
|
|
4509
4617
|
"./preview-modifies/src/hooks.server.ts": "import { env } from \"$env/dynamic/private\";\nimport { sequence } from \"@sveltejs/kit/hooks\";\nimport { handlePocketbase } from \"@velastack/pocketbase\";\n// [!code highlight:1]\nimport { handle as handleNegotiate } from \"$lib/negotiate\";\n\nexport const handle = sequence(\n // [!code highlight:1]\n handleNegotiate,\n handlePocketbase({\n pocketbaseUrl: env.POCKETBASE_URL,\n superuserEmail: env.POCKETBASE_SUPERUSER_EMAIL,\n superuserPassword: env.POCKETBASE_SUPERUSER_PASSWORD,\n }),\n);\n",
|
|
4510
4618
|
"./preview-modifies/src/hooks.ts": "import { reroute as negotiateReroute } from \"$lib/negotiate\";\n\nexport const reroute = ({ url }) => negotiateReroute(url.pathname);\n"
|
|
4511
|
-
}),
|
|
4512
|
-
async function
|
|
4619
|
+
}), Rc = "./preview-modifies/";
|
|
4620
|
+
async function zc(e) {
|
|
4513
4621
|
return {
|
|
4514
4622
|
creates: [],
|
|
4515
|
-
modifies: Object.entries(
|
|
4516
|
-
let n = o(e,
|
|
4623
|
+
modifies: Object.entries(Lc).map(([e, t]) => {
|
|
4624
|
+
let n = o(e, Rc);
|
|
4517
4625
|
return {
|
|
4518
4626
|
path: n,
|
|
4519
4627
|
language: r(n),
|
|
@@ -4531,18 +4639,18 @@ async function Cc(e) {
|
|
|
4531
4639
|
}
|
|
4532
4640
|
//#endregion
|
|
4533
4641
|
//#region src/patterns/enable/content-negotiation/index.ts
|
|
4534
|
-
var
|
|
4535
|
-
async function
|
|
4536
|
-
let t = await
|
|
4537
|
-
if (e.env === "preview") return y(n([t, await
|
|
4538
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
4642
|
+
var Bc = "enable-content-negotiation", Vc = "1.0.0", Hc = "src/patterns/enable/content-negotiation", Uc = "/enable/content-negotiation";
|
|
4643
|
+
async function Wc(e) {
|
|
4644
|
+
let t = await Ic(e);
|
|
4645
|
+
if (e.env === "preview") return y(n([t, await zc(e)]));
|
|
4646
|
+
let { generate: r } = await import("./chunks/generate.runtime-Cb2vYF1l.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4539
4647
|
return a(await y(n([t, i])), e);
|
|
4540
4648
|
}
|
|
4541
|
-
var
|
|
4542
|
-
version:
|
|
4543
|
-
slug:
|
|
4544
|
-
source:
|
|
4545
|
-
docs:
|
|
4649
|
+
var Gc = {
|
|
4650
|
+
version: Vc,
|
|
4651
|
+
slug: Bc,
|
|
4652
|
+
source: Hc,
|
|
4653
|
+
docs: Uc,
|
|
4546
4654
|
plan: "open",
|
|
4547
4655
|
title: "Enable content negotiation",
|
|
4548
4656
|
summary: "Serves the same route as HTML, Markdown, or JSON using sveltekit-negotiate.",
|
|
@@ -4550,6 +4658,7 @@ var kc = {
|
|
|
4550
4658
|
auth: !1,
|
|
4551
4659
|
api: !1,
|
|
4552
4660
|
apiKeys: !1,
|
|
4661
|
+
backend: !1,
|
|
4553
4662
|
i18n: !1,
|
|
4554
4663
|
teams: !1,
|
|
4555
4664
|
payments: !1,
|
|
@@ -4572,17 +4681,17 @@ var kc = {
|
|
|
4572
4681
|
examples: [],
|
|
4573
4682
|
tests: 0,
|
|
4574
4683
|
baseline: "velastack",
|
|
4575
|
-
generate:
|
|
4576
|
-
},
|
|
4577
|
-
"./creates/src/hooks.ts":
|
|
4578
|
-
"./creates/src/lib/components/language-select.svelte":
|
|
4579
|
-
"./creates/src/lib/url.ts":
|
|
4580
|
-
"./creates/wuchale.config.js":
|
|
4581
|
-
}),
|
|
4582
|
-
async function
|
|
4684
|
+
generate: Wc
|
|
4685
|
+
}, Kc = "import { deLocalizeDefault } from \"wuchale/url\";\nimport { matchUrl } from \"$locales/main.url\";\nimport { locales } from \"$locales/data\";\n\nconst rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n};\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n", qc = "<script lang=\"ts\">\n import * as Select from \"$lib/components/ui/select/index.js\";\n import { locales, type Locale } from \"$locales/data.js\";\n import { page } from \"$app/state\";\n import { goto } from \"$app/navigation\";\n import { deLocalizeDefault } from \"wuchale/url\";\n import { defaultLocale, translateUrl } from \"$lib/url\";\n\n let locale: Locale = $derived.by(() => {\n const [_, locale] = deLocalizeDefault(page.url.pathname, locales);\n return locale ?? defaultLocale;\n });\n\n function localeDisplayName(code: Locale): string {\n const names = new Intl.DisplayNames([code], { type: \"language\" });\n const raw = names.of(code);\n if (!raw) return code;\n return raw.charAt(0).toLocaleUpperCase(code) + raw.slice(1);\n }\n\n const localeNames: Record<string, string> = locales.reduce(\n (acc, loc) => {\n acc[loc] = localeDisplayName(loc);\n return acc;\n },\n {} as Record<string, string>,\n );\n\n const handleValueChange = (value: string) => {\n const translatedUrl = translateUrl(\n page.url.pathname,\n locale,\n value as Locale,\n );\n goto(translatedUrl, { invalidateAll: true });\n };\n\n let { class: className }: { class?: string } = $props();\n<\/script>\n\n<Select.Root type=\"single\" value={locale} onValueChange={handleValueChange}>\n <Select.Trigger class={className}>{localeNames[locale]}</Select.Trigger>\n <Select.Content>\n {#each locales as locale}\n <Select.Item value={locale}>{localeNames[locale]}</Select.Item>\n {/each}\n </Select.Content>\n</Select.Root>\n", Jc = "import { deLocalizeDefault, fillParams } from \"wuchale/url\";\nimport type { Locale } from \"../locales/data\";\nimport { matchUrl } from \"../locales/main.url\";\nimport { locales } from \"../locales/data\";\n\nexport const defaultLocale = \"en\";\n\nexport function localize(path: string, locale: Locale) {\n if (locale === defaultLocale) {\n return path;\n }\n\n return `/${locale}${path}`;\n}\n\nexport function translateUrl(\n url: string,\n fromLocale: Locale,\n toLocale: Locale,\n) {\n const [pathOnly] = deLocalizeDefault(url, locales);\n const result = matchUrl(pathOnly, fromLocale);\n if (result.path !== null) {\n const targetPath = fillParams(result.params, result.altPatterns[toLocale]);\n return localize(targetPath, toLocale);\n }\n return localize(url, toLocale);\n}\n", Yc = "// @ts-check\nimport { adapter as svelte } from \"@wuchale/svelte\";\nimport { adapter as js } from \"wuchale/adapter-vanilla\";\nimport { defineConfig } from \"wuchale\";\n\nexport default defineConfig({\n locales: [\"en\", \"es\"],\n adapters: {\n main: svelte({\n loader: \"sveltekit\",\n url: { localize: true, patterns: [\"/\"] },\n }),\n js: js({\n loader: \"vite\",\n files: [\n \"src/**/+{page,layout}.{js,ts}\",\n \"src/**/+{page,layout}.server.{js,ts}\",\n ],\n }),\n },\n});\n", Xc = /* @__PURE__ */ Object.assign({
|
|
4686
|
+
"./creates/src/hooks.ts": Kc,
|
|
4687
|
+
"./creates/src/lib/components/language-select.svelte": qc,
|
|
4688
|
+
"./creates/src/lib/url.ts": Jc,
|
|
4689
|
+
"./creates/wuchale.config.js": Yc
|
|
4690
|
+
}), Zc = "./creates/";
|
|
4691
|
+
async function Qc(e) {
|
|
4583
4692
|
return {
|
|
4584
|
-
creates: Object.entries(
|
|
4585
|
-
let n = o(e,
|
|
4693
|
+
creates: Object.entries(Xc).map(([e, t]) => {
|
|
4694
|
+
let n = o(e, Zc);
|
|
4586
4695
|
return {
|
|
4587
4696
|
path: n,
|
|
4588
4697
|
language: r(n),
|
|
@@ -4601,19 +4710,19 @@ async function Ic(e) {
|
|
|
4601
4710
|
}
|
|
4602
4711
|
//#endregion
|
|
4603
4712
|
//#region src/patterns/enable/i18n/generate.preview.ts
|
|
4604
|
-
var
|
|
4713
|
+
var $c = /* @__PURE__ */ Object.assign({
|
|
4605
4714
|
"./preview-modifies/src/app.html": "<!doctype html>\n<!-- [!code highlight:1] -->\n<html lang=\"%sveltekit.lang%\">\n <head>\n <meta charset=\"utf-8\" />\n </head>\n\n <body>\n <div style=\"display: contents\">%sveltekit.body%</div>\n </body>\n</html>\n",
|
|
4606
4715
|
"./preview-modifies/src/hooks.server.ts": "import { env } from \"$env/dynamic/private\";\nimport { handlePocketbase } from \"@velastack/pocketbase\";\n// [!code highlight:6]\nimport { sequence } from \"@sveltejs/kit/hooks\";\nimport { runWithLocale, loadLocales } from \"wuchale/load-utils/server\";\nimport { getLocale } from \"$locales/main.url\";\nimport { locales } from \"$locales/data\";\nimport * as main from \"$locales/main.loader.server.svelte.js\";\nimport * as js from \"$locales/js.loader.server.js\";\n\n// [!code highlight:2]\nloadLocales(main.key, main.loadIDs, main.loadCatalog, locales);\nloadLocales(js.key, js.loadIDs, js.loadCatalog, locales);\n\n// [!code highlight:9]\nconst handleWuchale = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace(\"%sveltekit.lang%\", locale),\n }),\n );\n};\n\nexport const handle = sequence(\n // [!code highlight:1]\n handleWuchale,\n handlePocketbase({\n pocketbaseUrl: env.POCKETBASE_URL,\n superuserEmail: env.POCKETBASE_SUPERUSER_EMAIL,\n superuserPassword: env.POCKETBASE_SUPERUSER_PASSWORD,\n }),\n);\n",
|
|
4607
4716
|
"./preview-modifies/src/routes/(public)/root-layout.svelte": "<script lang=\"ts\">\n import { toggleMode } from 'mode-watcher';\n import * as Navbar from '$lib/components/ui/navbar';\n import { Button } from '$lib/components/ui/button';\n // [!code highlight]\n import LanguageSelect from '$lib/components/language-select.svelte';\n\n let { children, data } = $props();\n<\/script>\n\n<div class=\"min-h-dvh grid grid-rows-[max-content_1fr_max-content] root-layout\">\n <Navbar.Root>\n <Navbar.Brand href=\"/\">\n <Navbar.Logo src=\"/favicon.svg\" alt=\"Logo\" />\n </Navbar.Brand>\n\n <Navbar.MobileToggle />\n\n <Navbar.List>\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/\" variant=\"ghost\">\n Home\n </Button>\n </Navbar.Item>\n <!-- [!code highlight:3] -->\n <Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n </Navbar.List>\n </Navbar.Root>\n\n {@render children?.()}\n\n <footer class=\"border-t border-border py-4\">\n <div\n class=\"mx-auto flex max-w-7xl px-4 flex-col items-center justify-between gap-3 sm:flex-row\"\n >\n <p class=\"text-muted-foreground text-sm\">\n © {new Date().getFullYear()}\n {data.meta.appName}. All rights reserved.\n </p>\n <nav class=\"flex items-center gap-4 text-sm\">\n <Button onclick={toggleMode} variant=\"ghost\" size=\"icon\">\n <Navbar.Mode />\n </Button>\n <a href=\"/privacy\" class=\"underline-offset-4 hover:underline\">Privacy</a>\n <a href=\"/terms\" class=\"underline-offset-4 hover:underline\">Terms</a>\n </nav>\n </div>\n </footer>\n</div>\n\n<style lang=\"postcss\">\n @reference \"tailwindcss\";\n\n .root-layout :global(section[data-role='content']) {\n @apply container mx-auto max-w-7xl px-4 py-8 w-full;\n }\n</style>\n",
|
|
4608
4717
|
"./preview-modifies/src/routes/+layout.ts": "import { browser } from \"$app/environment\";\n// [!code highlight:4]\nimport { loadLocale } from \"wuchale/load-utils\";\nimport { getLocale } from \"$locales/main.url\";\nimport \"$locales/main.loader.svelte\";\nimport \"$locales/js.loader\";\n\nexport const load = async ({ url, data }) => {\n // [!code highlight:5]\n const locale = getLocale(url);\n\n if (browser) {\n await loadLocale(locale);\n }\n\n return data;\n};\n",
|
|
4609
4718
|
"./preview-modifies/svelte.config.js": "import adapter from \"@sveltejs/adapter-auto\";\nimport { vitePreprocess } from \"@sveltejs/vite-plugin-svelte\";\n\nconst config = {\n preprocess: vitePreprocess(),\n kit: {\n adapter,\n // [!code highlight:3]\n alias: {\n $locales: \"src/locales\",\n },\n },\n};\n\nexport default config;\n",
|
|
4610
4719
|
"./preview-modifies/vite.config.ts": "import { defineConfig } from \"vite\";\nimport { sveltekit } from \"@sveltejs/kit/vite\";\nimport tailwindcss from \"@tailwindcss/vite\";\n// [!code highlight:1]\nimport { wuchale } from \"wuchale/vite\";\n\nexport default defineConfig({\n // [!code highlight:1]\n plugins: [wuchale(), tailwindcss(), sveltekit()],\n});\n"
|
|
4611
|
-
}),
|
|
4612
|
-
async function
|
|
4720
|
+
}), el = "./preview-modifies/";
|
|
4721
|
+
async function tl(e) {
|
|
4613
4722
|
return {
|
|
4614
4723
|
creates: [],
|
|
4615
|
-
modifies: Object.entries(
|
|
4616
|
-
let n = o(e,
|
|
4724
|
+
modifies: Object.entries($c).map(([e, t]) => {
|
|
4725
|
+
let n = o(e, el);
|
|
4617
4726
|
return {
|
|
4618
4727
|
path: n,
|
|
4619
4728
|
language: r(n),
|
|
@@ -4631,18 +4740,18 @@ async function zc(e) {
|
|
|
4631
4740
|
}
|
|
4632
4741
|
//#endregion
|
|
4633
4742
|
//#region src/patterns/enable/i18n/index.ts
|
|
4634
|
-
var
|
|
4635
|
-
async function
|
|
4636
|
-
let t = await
|
|
4637
|
-
if (e.env === "preview") return y(n([t, await
|
|
4638
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
4743
|
+
var nl = "enable-i18n", rl = "1.0.0", il = "src/patterns/enable/i18n", al = "/enable/i18n";
|
|
4744
|
+
async function ol(e) {
|
|
4745
|
+
let t = await Qc(e);
|
|
4746
|
+
if (e.env === "preview") return y(n([t, await tl(e)]));
|
|
4747
|
+
let { generate: r } = await import("./chunks/generate.runtime-DjwRKg8K.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4639
4748
|
return a(await y(n([t, i])), e);
|
|
4640
4749
|
}
|
|
4641
|
-
var
|
|
4642
|
-
version:
|
|
4643
|
-
slug:
|
|
4644
|
-
source:
|
|
4645
|
-
docs:
|
|
4750
|
+
var sl = {
|
|
4751
|
+
version: rl,
|
|
4752
|
+
slug: nl,
|
|
4753
|
+
source: il,
|
|
4754
|
+
docs: al,
|
|
4646
4755
|
plan: "open",
|
|
4647
4756
|
title: "Enable i18n",
|
|
4648
4757
|
summary: "Enables i18n with Wuchale and locale-aware routing.",
|
|
@@ -4650,6 +4759,7 @@ var Gc = {
|
|
|
4650
4759
|
auth: !1,
|
|
4651
4760
|
api: !1,
|
|
4652
4761
|
apiKeys: !1,
|
|
4762
|
+
backend: !1,
|
|
4653
4763
|
i18n: !1,
|
|
4654
4764
|
teams: !1,
|
|
4655
4765
|
payments: !1,
|
|
@@ -4672,17 +4782,17 @@ var Gc = {
|
|
|
4672
4782
|
examples: [],
|
|
4673
4783
|
tests: 0,
|
|
4674
4784
|
baseline: "velastack",
|
|
4675
|
-
generate:
|
|
4676
|
-
},
|
|
4785
|
+
generate: ol
|
|
4786
|
+
}, cl = /* @__PURE__ */ Object.assign({
|
|
4677
4787
|
"./creates/src/lib/components/notifications-bell.svelte": "<script lang=\"ts\">\n import { onMount } from 'svelte';\n import { goto, invalidate } from '$app/navigation';\n import { page } from '$app/state';\n import { toast } from 'svelte-sonner';\n import BellIcon from '@lucide/svelte/icons/bell';\n import { Button } from '$lib/components/ui/button';\n import { Badge } from '$lib/components/ui/badge';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import { timeAgo } from '$lib/utils';\n\n interface NotificationItem {\n id: string;\n title: string;\n body: string;\n read: boolean;\n created: string;\n }\n\n const POLL_MS = 30_000;\n const INVALIDATE_KEY = 'app:notifications';\n\n const notifications = $derived(\n (page.data.notifications ?? { count: 0, items: [] }) as {\n count: number;\n items: NotificationItem[];\n }\n );\n const badgeText = $derived(notifications.count > 99 ? '99+' : String(notifications.count));\n\n let lastSeenId: string | null = null;\n let primed = false;\n\n $effect(() => {\n const newest = notifications.items[0]?.id ?? null;\n if (!primed) {\n primed = true;\n lastSeenId = newest;\n return;\n }\n if (!newest || newest === lastSeenId) return;\n for (const item of notifications.items) {\n if (lastSeenId && item.id <= lastSeenId) break;\n toast.info(item.title, {\n description: item.body || undefined,\n action: { label: 'View', onClick: () => goto('/notifications') }\n });\n }\n lastSeenId = newest;\n });\n\n onMount(() => {\n const id = setInterval(() => {\n if (document.visibilityState === 'hidden') return;\n invalidate(INVALIDATE_KEY);\n }, POLL_MS);\n const onVisible = () => {\n if (document.visibilityState === 'visible') invalidate(INVALIDATE_KEY);\n };\n document.addEventListener('visibilitychange', onVisible);\n return () => {\n clearInterval(id);\n document.removeEventListener('visibilitychange', onVisible);\n };\n });\n<\/script>\n\n<DropdownMenu.Root onOpenChange={(open) => open && invalidate(INVALIDATE_KEY)}>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Button variant=\"ghost\" size=\"icon\" class=\"relative\" aria-label=\"Notifications\" {...props}>\n <BellIcon class=\"size-5\" />\n {#if notifications.count > 0}\n <Badge\n variant=\"destructive\"\n class=\"absolute -top-1 -right-1 h-4 min-w-4 px-1 text-[10px] leading-none\"\n >\n {badgeText}\n </Badge>\n {/if}\n </Button>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\" class=\"w-80 shadow-2xl shadow-black/40\">\n <DropdownMenu.Label>Notifications</DropdownMenu.Label>\n <DropdownMenu.Separator />\n {#if notifications.items.length === 0}\n <div class=\"px-2 py-6 text-center text-sm text-muted-foreground\">\n You're all caught up.\n </div>\n {:else}\n {#each notifications.items as item (item.id)}\n <DropdownMenu.Item class=\"p-0\">\n <a\n href=\"/notifications\"\n class=\"flex w-full flex-col gap-0.5 px-2 py-2 cursor-default\"\n >\n <div class=\"flex items-center justify-between gap-2\">\n <span class=\"text-sm font-medium truncate\">{item.title}</span>\n <span\n class=\"shrink-0 text-[10px] text-muted-foreground tabular-nums\"\n title={new Date(item.created).toLocaleString()}\n >\n {timeAgo(item.created)}\n </span>\n </div>\n {#if item.body}\n <span class=\"text-xs text-muted-foreground line-clamp-2\">{item.body}</span>\n {/if}\n </a>\n </DropdownMenu.Item>\n {/each}\n {/if}\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <a href=\"/notifications\" class=\"flex w-full justify-center px-2 py-1.5 text-sm cursor-default\">\n View all\n </a>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n</DropdownMenu.Root>\n",
|
|
4678
4788
|
"./creates/src/lib/server/notifications.ts": "import type PocketBase from \"pocketbase-sveltekit\";\n\nexport interface NotifyInput {\n title: string;\n body?: string;\n}\n\n/** Drop a notification on a user. Server-only ($lib/server). */\nexport async function notify(pb: PocketBase, userId: string, input: NotifyInput) {\n return pb.collection('notifications').create({\n user: userId,\n title: input.title,\n body: input.body ?? '',\n read: false\n });\n}\n",
|
|
4679
4789
|
"./creates/src/routes/(app)/notifications/+page.server.ts": "import { fail } from '@sveltejs/kit';\n\nexport const load = async ({ locals }) => {\n const userId = locals.pb.authStore.record!.id;\n const items = await locals.pb.collection('notifications').getFullList({\n filter: `user = \"${userId}\"`,\n sort: '-created',\n requestKey: 'notifications'\n });\n const unread = items.filter((n) => !n.read).length;\n const breadcrumbs = [\n { title: 'Home', url: '/dashboard' },\n { title: 'Notifications', url: '/notifications' }\n ];\n return { items, unread, breadcrumbs };\n};\n\nexport const actions = {\n markRead: async ({ request, locals }) => {\n const form = await request.formData();\n const id = form.get('id');\n if (typeof id !== 'string' || !id) return fail(400, { error: 'missing id' });\n await locals.pb.collection('notifications').update(id, { read: true });\n return { success: true };\n },\n markAllRead: async ({ locals }) => {\n const userId = locals.pb.authStore.record!.id;\n const unread = await locals.pb.collection('notifications').getFullList({\n filter: `user = \"${userId}\" && read = false`\n });\n for (const n of unread) {\n await locals.pb.collection('notifications').update(n.id, { read: true });\n }\n return { success: true, count: unread.length };\n }\n};\n",
|
|
4680
4790
|
"./creates/src/routes/(app)/notifications/+page.svelte": "<script lang=\"ts\">\n import { enhance } from '$app/forms';\n import { Button } from '$lib/components/ui/button';\n import { Badge } from '$lib/components/ui/badge';\n import * as Card from '$lib/components/ui/card';\n import { timeAgo } from '$lib/utils';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col gap-4\">\n <div class=\"flex items-center justify-between\">\n <div class=\"flex items-center gap-2\">\n <h1 class=\"text-2xl font-semibold\">Notifications</h1>\n {#if data.unread > 0}\n <Badge variant=\"secondary\">{data.unread} unread</Badge>\n {/if}\n </div>\n {#if data.unread > 0}\n <form method=\"post\" action=\"?/markAllRead\" use:enhance>\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Mark all read</Button>\n </form>\n {/if}\n </div>\n\n {#if data.items.length === 0}\n <Card.Root>\n <Card.Content class=\"py-10 text-center text-sm text-muted-foreground\">\n You don't have any notifications yet.\n </Card.Content>\n </Card.Root>\n {:else}\n <div class=\"flex flex-col gap-2\">\n {#each data.items as item (item.id)}\n <Card.Root\n size=\"sm\"\n class={['relative transition-colors', item.read ? 'opacity-70' : '']}\n >\n <Card.Content class=\"flex items-start justify-between gap-4\">\n <div class=\"flex min-w-0 flex-col gap-0.5\">\n <div class=\"flex items-center gap-2\">\n <span class=\"font-medium\">{item.title}</span>\n {#if !item.read}\n <span class=\"size-2 rounded-full bg-primary\" aria-label=\"unread\"></span>\n {/if}\n </div>\n {#if item.body}\n <p class=\"text-sm text-muted-foreground\">{item.body}</p>\n {/if}\n {#if item.created}\n <span\n class=\"text-xs text-muted-foreground\"\n title={new Date(item.created).toLocaleString()}\n >\n {timeAgo(item.created)}\n </span>\n {/if}\n </div>\n {#if !item.read}\n <form method=\"post\" action=\"?/markRead\" use:enhance>\n <input type=\"hidden\" name=\"id\" value={item.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Mark read</Button>\n </form>\n {/if}\n </Card.Content>\n </Card.Root>\n {/each}\n </div>\n {/if}\n</div>\n"
|
|
4681
|
-
}),
|
|
4682
|
-
async function
|
|
4791
|
+
}), ll = "./creates/";
|
|
4792
|
+
async function ul(e) {
|
|
4683
4793
|
return {
|
|
4684
|
-
creates: Object.entries(
|
|
4685
|
-
let n = o(e,
|
|
4794
|
+
creates: Object.entries(cl).map(([e, t]) => {
|
|
4795
|
+
let n = o(e, ll);
|
|
4686
4796
|
return {
|
|
4687
4797
|
path: n,
|
|
4688
4798
|
language: r(n),
|
|
@@ -4701,8 +4811,8 @@ async function Jc(e) {
|
|
|
4701
4811
|
}
|
|
4702
4812
|
//#endregion
|
|
4703
4813
|
//#region src/patterns/enable/notifications/preview-modifies/src/lib/utils.ts?raw
|
|
4704
|
-
var
|
|
4705
|
-
function
|
|
4814
|
+
var dl = "import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WithoutChild<T> = T extends { child?: any } ? Omit<T, \"child\"> : T;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WithoutChildren<T> = T extends { children?: any }\n ? Omit<T, \"children\">\n : T;\nexport type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;\nexport type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & {\n ref?: U | null;\n};\n\n// [!code highlight:9]\nconst TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n [\"year\", 60 * 60 * 24 * 365],\n [\"month\", 60 * 60 * 24 * 30],\n [\"day\", 60 * 60 * 24],\n [\"hour\", 60 * 60],\n [\"minute\", 60],\n [\"second\", 1],\n];\n\n// [!code highlight:10]\nexport function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === \"second\") {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n}\n", fl = "users";
|
|
4815
|
+
function pl(e) {
|
|
4706
4816
|
let t = d.find((t) => t.collectionName === e);
|
|
4707
4817
|
if (!t) throw Error(`notifications: missing NOTIFICATION_RULE_PATCHES entry for "${e}"`);
|
|
4708
4818
|
return {
|
|
@@ -4713,10 +4823,10 @@ function Zc(e) {
|
|
|
4713
4823
|
deleteRule: t.deleteRule
|
|
4714
4824
|
};
|
|
4715
4825
|
}
|
|
4716
|
-
var
|
|
4826
|
+
var ml = [{
|
|
4717
4827
|
name: "notifications",
|
|
4718
4828
|
type: "base",
|
|
4719
|
-
...
|
|
4829
|
+
...pl("notifications"),
|
|
4720
4830
|
indexes: ["CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)"],
|
|
4721
4831
|
fields: [
|
|
4722
4832
|
{
|
|
@@ -4733,7 +4843,7 @@ var Qc = [{
|
|
|
4733
4843
|
name: "user",
|
|
4734
4844
|
type: "relation",
|
|
4735
4845
|
cascadeDelete: !0,
|
|
4736
|
-
collectionId:
|
|
4846
|
+
collectionId: fl,
|
|
4737
4847
|
maxSelect: 1,
|
|
4738
4848
|
minSelect: 0,
|
|
4739
4849
|
required: !0
|
|
@@ -4764,12 +4874,12 @@ var Qc = [{
|
|
|
4764
4874
|
onUpdate: !0
|
|
4765
4875
|
}
|
|
4766
4876
|
]
|
|
4767
|
-
}],
|
|
4768
|
-
async function
|
|
4877
|
+
}], hl = /* @__PURE__ */ Object.assign({ "./preview-modifies/src/lib/utils.ts": dl }), gl = "./preview-modifies/";
|
|
4878
|
+
async function _l(e) {
|
|
4769
4879
|
return {
|
|
4770
4880
|
creates: [],
|
|
4771
|
-
modifies: Object.entries(
|
|
4772
|
-
let n = o(e,
|
|
4881
|
+
modifies: Object.entries(hl).map(([e, t]) => {
|
|
4882
|
+
let n = o(e, gl);
|
|
4773
4883
|
return {
|
|
4774
4884
|
path: n,
|
|
4775
4885
|
language: r(n),
|
|
@@ -4780,25 +4890,25 @@ async function tl(e) {
|
|
|
4780
4890
|
deletes: [],
|
|
4781
4891
|
components: [],
|
|
4782
4892
|
packages: [],
|
|
4783
|
-
collections:
|
|
4893
|
+
collections: ml,
|
|
4784
4894
|
collectionPatches: [],
|
|
4785
4895
|
collectionDrops: []
|
|
4786
4896
|
};
|
|
4787
4897
|
}
|
|
4788
4898
|
//#endregion
|
|
4789
4899
|
//#region src/patterns/enable/notifications/index.ts
|
|
4790
|
-
var
|
|
4791
|
-
async function
|
|
4792
|
-
let t = await
|
|
4793
|
-
if (e.env === "preview") return y(n([t, await
|
|
4794
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
4900
|
+
var vl = "enable-notifications", yl = "1.0.0", bl = "src/patterns/enable/notifications", xl = "/enable/notifications";
|
|
4901
|
+
async function Sl(e) {
|
|
4902
|
+
let t = await ul(e);
|
|
4903
|
+
if (e.env === "preview") return y(n([t, await _l(e)]));
|
|
4904
|
+
let { generate: r } = await import("./chunks/generate.runtime-Bpx69a8t.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4795
4905
|
return a(await y(n([t, i])), e);
|
|
4796
4906
|
}
|
|
4797
|
-
var
|
|
4798
|
-
version:
|
|
4799
|
-
slug:
|
|
4800
|
-
source:
|
|
4801
|
-
docs:
|
|
4907
|
+
var Cl = {
|
|
4908
|
+
version: yl,
|
|
4909
|
+
slug: vl,
|
|
4910
|
+
source: bl,
|
|
4911
|
+
docs: xl,
|
|
4802
4912
|
plan: "open",
|
|
4803
4913
|
title: "Enable notifications",
|
|
4804
4914
|
summary: "Adds an in-app notifications collection, a bell dropdown with 30s polling, and a /notifications page for managing read state.",
|
|
@@ -4806,6 +4916,7 @@ var sl = {
|
|
|
4806
4916
|
auth: !0,
|
|
4807
4917
|
api: !1,
|
|
4808
4918
|
apiKeys: !1,
|
|
4919
|
+
backend: !0,
|
|
4809
4920
|
i18n: !1,
|
|
4810
4921
|
teams: !1,
|
|
4811
4922
|
payments: !1,
|
|
@@ -4829,50 +4940,50 @@ var sl = {
|
|
|
4829
4940
|
examples: [],
|
|
4830
4941
|
tests: 6,
|
|
4831
4942
|
baseline: "velastack",
|
|
4832
|
-
generate:
|
|
4833
|
-
}, cl = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/products\");\n});\n\ncronAdd(\"stripe-prices\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/prices\");\n});\n", ll = "/// <reference path=\"../types.d.ts\" />\n\nmodule.exports = {\n triggerJob: (jobUrl) => {\n $http.send({\n method: \"POST\",\n url: `${$app.settings().meta.appURL}${jobUrl}`,\n headers: {\n Authorization: `Bearer ${$os.getenv(\"INTERNAL_JOB_SECRET\")}`,\n },\n });\n },\n};\n", ul = "<script lang=\"ts\">\n import type { Stripe } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n brand?: string;\n last4?: string;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n brand,\n last4,\n clientSecret,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n const brandNames = {\n amex: 'American Express',\n cartes_bancaires: 'Cartes Bancaires',\n diners: 'Diners',\n discover: 'Discover',\n eftpos_au: 'Eftpos Au',\n jcb: 'Jcb',\n link: 'Link',\n mastercard: 'Mastercard',\n unionpay: 'Unionpay',\n visa: 'Visa',\n unknown: 'Unknown'\n };\n\n let isProcessing = $state(false);\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !clientSecret) return;\n\n isProcessing = true;\n\n try {\n const { error: confirmError } = await stripe.confirmPayment({\n clientSecret,\n confirmParams: {\n return_url: page.url.toString()\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Confirm payment</Dialog.Title>\n <Dialog.Description>\n Are you sure you want to pay {amountFormatted} with your\n {brandNames[brand as keyof typeof brandNames]}\n credit card ending in **** {last4}?\n </Dialog.Description>\n </Dialog.Header>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", dl = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import PaymentDialog from '$lib/components/payments/payment-dialog.svelte';\n import ConfirmDialog from '$lib/components/payments/confirm-dialog.svelte';\n import { useStripe } from '$lib/components/payments/use-stripe.svelte';\n import { usePaymentIntent } from '$lib/components/payments/use-payment-intent.svelte';\n import type { ButtonProps } from '$lib/components/ui/button';\n\n interface Props {\n priceId: string;\n user?: { email: string; name: string } | null;\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n priceId,\n user,\n disabled = false,\n isProcessing = false,\n label = 'Purchase',\n processingLabel = 'Processing...',\n onsuccess,\n ...rest\n }: Props & ButtonProps = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let mode = $state<'payment' | 'confirm'>('payment');\n let showDialog = $state(false);\n let amount = $state<number>(0);\n let currency = $state<string>('usd');\n let clientSecret = $state<string>();\n let brand = $state<string>();\n let last4 = $state<string>();\n\n async function handleBuyClick() {\n const result = await paymentIntentManager.fetchPaymentIntent({\n priceId\n });\n\n if (!result) return;\n\n if (result.type === 'confirm') {\n mode = 'confirm';\n brand = result.brand;\n last4 = result.last4;\n } else if (result.type === 'payment') {\n mode = 'payment';\n }\n\n amount = result.amount || 0;\n currency = result.currency || 'usd';\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleBuyClick} {...rest}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n{#if mode === 'confirm'}\n <ConfirmDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {brand}\n {last4}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{:else if mode === 'payment'}\n <PaymentDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {clientSecret}\n {user}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{/if}\n", fl = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { Label } from '$lib/components/ui/label';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n clientSecret?: string;\n user?: { email: string; name: string } | null;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n clientSecret,\n user = null,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let savePaymentMethod = $state(false);\n let email = $state<string>();\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to pay for your purchase');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmPayment({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n billing_details: {\n email: email || user?.email\n },\n allow_redisplay: savePaymentMethod ? 'always' : 'unspecified'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>{amountFormatted}</Dialog.Title>\n <Dialog.Description>Enter your card details to pay for your purchase.</Dialog.Description>\n </Dialog.Header>\n {#if !user}\n <div class=\"space-y-2\">\n <Label for=\"email\">Email</Label>\n <Input type=\"email\" bind:value={email} />\n </div>\n {/if}\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"payment\"\n {stripe}\n {amount}\n {currency}\n {savePaymentMethod}\n {user}\n onchange={handleCardChange}\n />\n {/if}\n </div>\n {#if user}\n <div class=\"flex items-center gap-2\">\n <input type=\"checkbox\" id=\"savePaymentMethod\" bind:checked={savePaymentMethod} />\n <label for=\"savePaymentMethod\" class=\"text-sm text-muted-foreground\">\n Save payment method for future purchases\n </label>\n </div>\n {/if}\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", pl = "export const TERMS_AUTO = {\n applePay: \"auto\" as const,\n auBecsDebit: \"auto\" as const,\n bancontact: \"auto\" as const,\n card: \"auto\" as const,\n cashapp: \"auto\" as const,\n googlePay: \"auto\" as const,\n ideal: \"auto\" as const,\n paypal: \"auto\" as const,\n sepaDebit: \"auto\" as const,\n sofort: \"auto\" as const,\n usBankAccount: \"auto\" as const,\n};\n\nexport const TERMS_NEVER = {\n applePay: \"never\" as const,\n auBecsDebit: \"never\" as const,\n bancontact: \"never\" as const,\n card: \"never\" as const,\n cashapp: \"never\" as const,\n googlePay: \"never\" as const,\n ideal: \"never\" as const,\n paypal: \"never\" as const,\n sepaDebit: \"never\" as const,\n sofort: \"never\" as const,\n usBankAccount: \"never\" as const,\n};\n", ml = "<script lang=\"ts\">\n import type {\n Stripe,\n StripeElements,\n StripePaymentElement,\n StripeElementsOptionsMode\n } from '@stripe/stripe-js';\n import { mode as modeWatcher } from 'mode-watcher';\n import { TERMS_AUTO, TERMS_NEVER } from './stripe-constants';\n import { onMount } from 'svelte';\n\n interface Props {\n stripe: Stripe;\n mode: 'payment' | 'setup';\n amount?: number;\n currency?: string;\n savePaymentMethod?: boolean;\n user?: { email: string; name: string } | null;\n onchange: (complete: boolean) => void;\n }\n\n let {\n stripe,\n mode,\n amount = 0,\n currency = 'usd',\n savePaymentMethod = false,\n user,\n onchange\n }: Props = $props();\n\n let cardContainer = $state<HTMLDivElement | null>(null);\n let elements = $state<StripeElements | null>(null);\n let paymentElement = $state<StripePaymentElement | null>(null);\n\n function initializeElements() {\n if (!stripe) return;\n\n // Clean up previous elements\n if (paymentElement) {\n paymentElement.destroy();\n paymentElement = null;\n }\n\n const appearance = {\n theme: modeWatcher.current === 'dark' ? ('night' as const) : ('stripe' as const),\n inputs: 'condensed' as const,\n labels: 'floating' as const\n };\n\n elements = stripe.elements({\n mode,\n appearance,\n currency,\n ...(mode === 'payment' && {\n amount: amount\n }),\n ...(user || mode === 'setup'\n ? {\n setupFutureUsage: 'off_session' as const\n }\n : {})\n } as StripeElementsOptionsMode);\n\n paymentElement = elements.create('payment', {\n layout: 'tabs',\n defaultValues: {\n billingDetails: {\n email: user?.email,\n name: user?.name\n }\n },\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n\n if (cardContainer && paymentElement) {\n paymentElement.mount(cardContainer);\n paymentElement.on('change', (event: any) => {\n onchange(event.complete);\n });\n }\n }\n\n // Initialize elements when component mounts\n onMount(() => {\n initializeElements();\n\n return () => {\n if (paymentElement) {\n paymentElement.destroy();\n }\n };\n });\n\n // Update terms when savePaymentMethod changes\n $effect(() => {\n if (paymentElement) {\n paymentElement.update({\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n }\n });\n\n export function getElements() {\n return elements;\n }\n<\/script>\n\n<div bind:this={cardContainer}></div>\n", hl = "import { toast } from \"svelte-sonner\";\n\nexport interface PaymentIntentResult {\n type: \"payment\" | \"confirm\";\n amount?: number;\n currency?: string;\n clientSecret?: string;\n brand?: string;\n last4?: string;\n}\n\nexport function usePaymentIntent() {\n let isLoading = $state(false);\n\n async function fetchPaymentIntent({\n priceId,\n }: {\n priceId: string;\n }): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/payment-intent\", {\n method: \"POST\",\n body: JSON.stringify({\n priceId: priceId,\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize payment\");\n return null;\n }\n\n return res.json();\n }\n\n async function fetchSetupIntent(): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/setup-intent\", {\n method: \"POST\",\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize setup\");\n return null;\n }\n\n return res.json();\n }\n\n return {\n get isLoading() {\n return isLoading;\n },\n fetchPaymentIntent,\n fetchSetupIntent,\n };\n}\n", gl = "import { loadStripe, type Stripe } from \"@stripe/stripe-js\";\nimport { toast } from \"svelte-sonner\";\nimport { env } from \"$env/dynamic/public\";\n\nexport function useStripe() {\n let stripe = $state<Stripe | null>(null);\n let isLoading = $state(true);\n let error = $state<string | null>(null);\n\n async function initialize() {\n try {\n stripe = await loadStripe(env.PUBLIC_STRIPE_PUBLISHABLE_KEY);\n isLoading = false;\n } catch (err) {\n console.error(\"Failed to load Stripe:\", err);\n error = \"Failed to initialize payment system\";\n toast.error(\"Failed to initialize payment system\");\n isLoading = false;\n }\n }\n\n // Auto-initialize\n initialize();\n\n return {\n get stripe() {\n return stripe;\n },\n get isLoading() {\n return isLoading;\n },\n get error() {\n return error;\n },\n };\n}\n", _l = "import { env } from \"$env/dynamic/private\";\nimport Stripe from \"stripe\";\n\nconst stripe = new Stripe(env.STRIPE_SECRET_KEY, {\n apiVersion: \"2026-04-22.dahlia\",\n});\n\nexport default stripe;\n", vl = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (price: Stripe.Price) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n try {\n const res = await createPaymentIntent(price);\n return json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return json({ error: errorMessage }, { status: 500 });\n }\n};\n", yl = "import { describe, it, expect, beforeAll } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"$lib/stripe\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", bl = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const prices = await stripe.prices.list();\n\n for (const price of prices.data) {\n try {\n await locals.admin\n .collection(\"stripe_prices\")\n .getFirstListItem(`id = \"${price.id}\"`);\n continue;\n } catch {}\n\n await locals.admin.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 console.log(\"Prices synced\");\n return json({ message: \"Prices synced\" });\n};\n", xl = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const products = await stripe.products.list();\n\n for (const product of products.data) {\n try {\n await locals.admin\n .collection(\"stripe_products\")\n .getFirstListItem(`id = \"${product.id}\"`);\n continue;\n } catch {}\n\n await locals.admin.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 console.log(\"Products synced\");\n return json({ message: \"Products synced\" });\n};\n", Sl = "import Stripe from \"stripe\";\nimport { json } from \"@sveltejs/kit\";\nimport { env } from \"$env/dynamic/private\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./handlers/payment-intent/succeeded\";\n\nconst processedEvents = new Set<string>();\n\nasync function verifyWebhookSignature(\n request: Request,\n webhookSecret: string,\n): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get(\"stripe-signature\");\n\n if (!signature) {\n throw new Error(\"Missing stripe-signature header\");\n }\n\n if (!webhookSecret) {\n throw new Error(\"Missing webhook secret\");\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error(\"Webhook signature verification failed:\", err);\n throw new Error(\"Invalid signature\");\n }\n}\n\nexport const POST = async ({ request, locals }) => {\n try {\n const event = await verifyWebhookSignature(\n request,\n env.STRIPE_WEBHOOK_SECRET,\n );\n\n if (processedEvents.has(event.id)) {\n console.log(`Event ${event.id} already processed, skipping`);\n return json({ received: true, message: \"Event already processed\" });\n }\n\n processedEvents.add(event.id);\n\n console.log(`Processing webhook event: ${event.type} (${event.id})`);\n\n switch (event.type) {\n case \"payment_intent.succeeded\":\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n\n return json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n });\n } catch (error) {\n console.error(\"Webhook processing error:\", error);\n\n return json(\n {\n error: \"Webhook processing failed\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n { status: 400 },\n );\n }\n};\n", Cl = "import { describe, it, expect } from \"vitest\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n it(\"handles a payment intent successfully\", async (context) => {\n const paymentIntent = await stripe.paymentIntents.create({\n amount: 2000,\n currency: \"usd\",\n });\n const locals = { admin: context.admin } as App.Locals;\n const result = await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n expect(result).toEqual({});\n });\n});\n", wl = "import Stripe from \"stripe\";\n\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n return {};\n}\n", Tl = "import { describe, it, expect } from \"vitest\";\nimport type { RouteId } from \"./$types\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n\ndescribe(\"POST /webhooks/stripe\", () => {\n it(\"accepts valid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(200);\n expect(response.body.received).toBe(true);\n expect(response.body.eventId).toBe(event.id);\n expect(response.body.eventType).toBe(\"test.event\");\n });\n\n it(\"rejects invalid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", \"invalid_signature\")\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n });\n\n it(\"rejects request without signature header\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n expect(response.body.message).toBe(\"Missing stripe-signature header\");\n });\n\n it(\"handles duplicate webhook events\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n // Send first webhook\n const response1 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response1.status).toBe(200);\n expect(response1.body.received).toBe(true);\n\n // Send duplicate webhook\n const response2 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response2.status).toBe(200);\n expect(response2.body.received).toBe(true);\n expect(response2.body.message).toBe(\"Event already processed\");\n });\n});\n", El = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/products\");\n});\n\ncronAdd(\"stripe-prices\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/prices\");\n});\n\ncronAdd(\"stripe-customers\", \"* * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/customers\");\n});\n", Dl = "/// <reference path=\"../types.d.ts\" />\n\nmodule.exports = {\n triggerJob: (jobUrl) => {\n $http.send({\n method: \"POST\",\n url: `${$app.settings().meta.appURL}${jobUrl}`,\n headers: {\n Authorization: `Bearer ${$os.getenv(\"INTERNAL_JOB_SECRET\")}`,\n },\n });\n },\n};\n", Ol = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import SetupDialog from '$lib/components/payments/setup-dialog.svelte';\n import { useStripe } from '$lib/components/payments/use-stripe.svelte';\n import { usePaymentIntent } from '$lib/components/payments/use-payment-intent.svelte';\n\n interface Props {\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n disabled = false,\n isProcessing = false,\n label,\n processingLabel,\n onsuccess\n }: Props = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let showDialog = $state(false);\n let clientSecret = $state<string>();\n\n async function handleSetupClick() {\n const result = await paymentIntentManager.fetchSetupIntent();\n\n if (!result) return;\n\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleSetupClick}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n<SetupDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n/>\n", kl = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let { stripe, open = $bindable(), clientSecret, onopenchange, onsuccess }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handleSetupPaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to add payment method');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmSetup({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n allow_redisplay: 'always'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to add payment method');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment method added successfully');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error adding payment method:', err);\n toast.error('Failed to add payment method');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Add payment method</Dialog.Title>\n <Dialog.Description>Enter your card details to add a new payment method.</Dialog.Description>\n </Dialog.Header>\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"setup\"\n {stripe}\n onchange={handleCardChange}\n savePaymentMethod={true}\n />\n {/if}\n </div>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handleSetupPaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Add Card'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", Al = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Billing\", url: \"/billing\" }],\n };\n};\n", jl = "# Billing Page - Stripe Payment Methods\n\nThis billing page provides a modern UI for managing payment methods with Stripe.\n\n## Features\n\n✅ **Display Payment Methods** - Shows all saved cards with brand, last 4 digits, and expiration\n✅ **Add Payment Methods** - Secure card input using Stripe Elements\n✅ **Remove Payment Methods** - Delete cards with confirmation dialog\n✅ **Default Payment Method** - Set and display the default payment method\n✅ **Responsive Design** - Mobile-friendly layout\n✅ **Error Handling** - Toast notifications for user feedback\n\n## Current Status\n\nThe frontend is **fully functional** with mock data. To connect to your backend, follow the integration steps below.\n\n## Backend Integration\n\n### 1. Update Stripe Publishable Key\n\nIn `+page.svelte`, replace the placeholder with your actual Stripe publishable key:\n\n```typescript\nconst STRIPE_PUBLISHABLE_KEY = \"pk_test_YOUR_KEY_HERE\";\n```\n\nOr better yet, load it from environment variables:\n\n```typescript\nimport { env } from \"$env/dynamic/public\";\nconst STRIPE_PUBLISHABLE_KEY = env.PUBLIC_STRIPE_PUBLISHABLE_KEY;\n```\n\n### 2. Fetch Payment Methods on Load\n\nUpdate `+page.server.ts` to fetch payment methods:\n\n```typescript\nexport const load: PageServerLoad = async ({ locals }) => {\n const user = locals.user;\n\n if (!user?.stripeCustomerId) {\n return { paymentMethods: [] };\n }\n\n // Fetch payment methods from Stripe\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n const paymentMethods = await stripe.paymentMethods.list({\n customer: user.stripeCustomerId,\n type: \"card\",\n });\n\n return {\n paymentMethods: paymentMethods.data.map((pm) => ({\n id: pm.id,\n brand: pm.card?.brand || \"unknown\",\n last4: pm.card?.last4 || \"0000\",\n expMonth: pm.card?.exp_month || 1,\n expYear: pm.card?.exp_year || 2025,\n isDefault: false, // You'll need to track this separately\n })),\n };\n};\n```\n\n### 3. Create API Endpoints\n\nCreate the following server endpoints:\n\n#### Add Payment Method: `+page.server.ts`\n\n```typescript\nexport const actions = {\n addPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Attach payment method to customer\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.paymentMethods.attach(paymentMethodId, {\n customer: locals.user.stripeCustomerId,\n });\n\n return { success: true };\n },\n\n removePaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Detach payment method from customer\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.paymentMethods.detach(paymentMethodId);\n\n return { success: true };\n },\n\n setDefaultPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Update customer's default payment method\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.customers.update(locals.user.stripeCustomerId, {\n invoice_settings: {\n default_payment_method: paymentMethodId,\n },\n });\n\n return { success: true };\n },\n};\n```\n\n### 4. Update Frontend to Use Actions\n\nReplace the mock functions in `+page.svelte`:\n\n```typescript\nasync function handleAddPaymentMethod() {\n if (!stripe || !cardElement || !cardComplete) return;\n\n isProcessing = true;\n\n try {\n const { error, paymentMethod } = await stripe.createPaymentMethod({\n type: \"card\",\n card: cardElement,\n });\n\n if (error) {\n toast.error(error.message);\n return;\n }\n\n // Submit to your backend\n const formData = new FormData();\n formData.append(\"paymentMethodId\", paymentMethod.id);\n\n const response = await fetch(\"?/addPaymentMethod\", {\n method: \"POST\",\n body: formData,\n });\n\n if (response.ok) {\n toast.success(\"Payment method added\");\n // Reload page to fetch updated payment methods\n window.location.reload();\n }\n } finally {\n isProcessing = false;\n }\n}\n```\n\n## Security Considerations\n\n⚠️ **Important**: Never expose your Stripe secret key on the frontend\n✅ All sensitive operations should happen on your backend\n✅ Use Stripe's publishable key for frontend operations\n✅ Validate user permissions before modifying payment methods\n✅ Use HTTPS in production\n\n## Testing\n\nUse [Stripe's test cards](https://stripe.com/docs/testing) for testing:\n\n- **Success**: 4242 4242 4242 4242\n- **Decline**: 4000 0000 0000 0002\n- **Requires authentication**: 4000 0025 0000 3155\n\nUse any future expiration date and any 3-digit CVC.\n\n## Styling\n\nThe page uses Tailwind CSS and shadcn/ui components. All components are styled to match your existing design system with support for light/dark modes.\n\n### Stripe Elements Styling\n\nSince Stripe Elements render in an iframe, they cannot access CSS variables directly. Additionally, Stripe only accepts HEX, RGB, or HSL colors (not modern formats like OKLCH).\n\nThe implementation:\n\n1. **Creates temporary DOM elements** with CSS variables applied\n2. **Lets the browser compute colors** - converts OKLCH/HSL/any format to RGB\n3. **Extracts RGB values** that Stripe Elements can understand\n4. **Passes computed colors** to Stripe Elements on initialization\n5. **Matches the current theme** automatically (light/dark mode)\n\nThis approach works with any CSS color format (oklch, hsl, rgb, hex) and ensures Stripe Elements always match your theme when the \"Add Payment Method\" dialog opens.\n\n## Dependencies\n\n- `@stripe/stripe-js` - Stripe.js for frontend\n- `stripe` - Stripe Node.js SDK for backend\n- `svelte-sonner` - Toast notifications\n- `@lucide/svelte` - Icons\n- shadcn/ui components\n", Ml = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (\n price: Stripe.Price,\n customer?: { id: string; default_payment_method?: string },\n) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n // Guest\n if (!customer) {\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n }\n\n // Customer with saved payment method\n if (customer.default_payment_method) {\n const paymentMethod = await stripe.customers.retrievePaymentMethod(\n customer.id,\n customer.default_payment_method,\n );\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n payment_method: customer.default_payment_method,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return {\n type: \"confirm\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n };\n }\n\n // Customer without saved payment method\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n setup_future_usage: \"off_session\",\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n const user = locals.pb.authStore.record?.id;\n\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n let customer;\n\n if (user) {\n try {\n customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n locals.admin.filter(\"user = {:user}\", { user: user }),\n );\n } catch (error) {\n // Customer not found is expected for new users, log for debugging only\n console.log(\"No Stripe customer found for user:\", user);\n }\n }\n\n try {\n const res = await createPaymentIntent(price, customer);\n return json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return json({ error: errorMessage }, { status: 500 });\n }\n};\n", Nl = "import { describe, it, expect, beforeAll, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"$lib/stripe\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n beforeEach(async (context) => {\n // Create a Stripe customer for authenticated user tests\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Create a payment method for the customer\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n });\n\n afterEach(async () => {\n if (paymentMethod?.id) {\n await stripe.paymentMethods.detach(paymentMethod.id);\n }\n\n if (stripeCustomer?.id) {\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user without Stripe customer\", () => {\n it(\"should create payment intent for user without Stripe customer\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n\n // Verify the payment intent\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.setup_future_usage).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user with Stripe customer\", () => {\n let customerRecord: { id: string };\n\n beforeEach(async (context) => {\n // Link the Stripe customer to the PocketBase user\n customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .create({\n user: context.user.id,\n id: stripeCustomer.id,\n email: stripeCustomer.email,\n });\n });\n\n afterEach(async (context) => {\n // Clean up the PocketBase customer record\n await context.admin\n .collection(\"stripe_customers\")\n .delete(customerRecord.id);\n });\n\n it(\"should create payment intent with setup_future_usage for user without default payment method\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent has setup_future_usage\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.setup_future_usage).toBe(\"off_session\");\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n\n it(\"should create payment intent with default payment method for customer with saved payment method\", async (context) => {\n // Set default payment method\n await stripe.customers.update(stripeCustomer.id, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n const customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n context.admin.filter(\"user = {:user}\", { user: context.user.id }),\n );\n\n await context.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customerRecord.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\n await context.admin\n .collection(\"stripe_customers\")\n .update(customerRecord.id, {\n default_payment_method: paymentMethod.id,\n });\n\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"confirm\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBe(\"visa\");\n expect(response.body.last4).toBeDefined();\n expect(response.body.last4).toMatch(/^\\d{4}$/);\n\n // Verify the payment intent has the payment method attached\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.payment_method).toBe(paymentMethod.id);\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", Pl = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\n\nexport const POST = async ({ locals }) => {\n const user = locals.pb.authStore.record?.id;\n\n if (!user) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(locals.admin.filter(\"user = {:user}\", { user }));\n\n if (!customer) {\n return json({ error: \"Customer not found\" }, { status: 404 });\n }\n\n const setupIntent = await stripe.setupIntents.create({\n customer: customer.id,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return json({ clientSecret: setupIntent.client_secret });\n};\n", Fl = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /api/stripe/setup-intent\", () => {\n let stripeCustomer: Stripe.Customer;\n\n beforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n });\n\n afterEach(async (context) => {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n });\n\n it(\"creates a setup intent\", async (context) => {\n const response = await context.agent.post(\n \"/api/stripe/setup-intent\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n expect(response.body.clientSecret).toBeDefined();\n });\n});\n", Il = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\n// Sync users to Stripe customers\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n // Ensure all users have a Stripe customer\n const users = await locals.admin\n .collection(\"users\")\n .getFullList({ filter: \"stripe_customers_via_user.id = null\" });\n\n for (const user of users) {\n const customer = await stripe.customers.create({\n email: user.email,\n name: user.name,\n });\n\n await locals.admin.collection(\"stripe_customers\").create({\n id: customer.id,\n user: user.id,\n });\n }\n\n console.log(\"Customers synced\");\n return json({ message: \"Customers synced\" });\n};\n", Ll = "import Stripe from \"stripe\";\nimport { json } from \"@sveltejs/kit\";\nimport { env } from \"$env/dynamic/private\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./handlers/payment-intent/succeeded\";\nimport { handlePaymentMethodAttached } from \"./handlers/payment-method/attached\";\n\nconst processedEvents = new Set<string>();\n\nasync function verifyWebhookSignature(\n request: Request,\n webhookSecret: string,\n): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get(\"stripe-signature\");\n\n if (!signature) {\n throw new Error(\"Missing stripe-signature header\");\n }\n\n if (!webhookSecret) {\n throw new Error(\"Missing webhook secret\");\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error(\"Webhook signature verification failed:\", err);\n throw new Error(\"Invalid signature\");\n }\n}\n\nexport const POST = async ({ request, locals }) => {\n try {\n const event = await verifyWebhookSignature(\n request,\n env.STRIPE_WEBHOOK_SECRET,\n );\n\n if (processedEvents.has(event.id)) {\n console.log(`Event ${event.id} already processed, skipping`);\n return json({ received: true, message: \"Event already processed\" });\n }\n\n processedEvents.add(event.id);\n\n console.log(`Processing webhook event: ${event.type} (${event.id})`);\n\n switch (event.type) {\n case \"payment_intent.succeeded\":\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n case \"payment_method.attached\":\n await handlePaymentMethodAttached(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n\n return json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n });\n } catch (error) {\n console.error(\"Webhook processing error:\", error);\n\n return json(\n {\n error: \"Webhook processing failed\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n { status: 400 },\n );\n }\n};\n", Rl = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentIntent: Stripe.PaymentIntent;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n // Create a Stripe customer\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Link the Stripe customer to the test user\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n // Create a payment method for testing\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n // Attach payment method to customer\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n // Create a payment intent\n paymentIntent = await stripe.paymentIntents.create({\n amount: 2000, // $20.00\n currency: \"usd\",\n customer: stripeCustomer.id,\n payment_method: paymentMethod.id,\n confirm: true,\n return_url: \"https://example.com/return\",\n });\n });\n\n afterEach(async (context) => {\n // Clean up transactions\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\"stripe_customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n for (const transaction of transactions) {\n await context.admin.collection(\"transactions\").delete(transaction.id);\n }\n\n // Clean up Stripe resources\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch (e) {\n // Payment method may already be detached\n }\n }\n\n // Delete customer (this will also delete associated payment methods)\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a transaction record when payment intent succeeds\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_customer).toBe(stripeCustomer.id);\n expect(transaction.amount).toBe(2000);\n expect(transaction.currency).toBe(\"usd\");\n expect(transaction.user).toBe(context.user.id);\n expect(transaction.stripe_charge).toBeDefined();\n expect(transaction.last4).toBeDefined();\n expect(transaction.brand).toBeDefined();\n expect(transaction.created).toBeDefined();\n expect(transaction.receipt_url).toBeDefined();\n });\n\n it(\"handles payment intent with charge object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded charge\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"latest_charge\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_charge).toBeDefined();\n });\n\n it(\"handles payment intent with customer object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded customer\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n expect(transactions[0].stripe_customer).toBe(stripeCustomer.id);\n });\n\n it(\"handles missing charge ID gracefully\", async (context) => {\n const paymentIntentWithoutCharge = {\n ...paymentIntent,\n latest_charge: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCharge, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n\n it(\"handles missing customer ID gracefully\", async (context) => {\n const paymentIntentWithoutCustomer = {\n ...paymentIntent,\n customer: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCustomer, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n});\n", zl = "import Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n const chargeId =\n typeof paymentIntent.latest_charge === \"string\"\n ? paymentIntent.latest_charge\n : paymentIntent.latest_charge?.id;\n\n if (!chargeId) {\n console.error(\"No charge ID found for payment intent\");\n return;\n }\n\n const charge = await stripe.charges.retrieve(chargeId);\n\n const customerId =\n typeof paymentIntent.customer === \"string\"\n ? paymentIntent.customer\n : paymentIntent.customer?.id;\n\n if (!customerId) {\n console.error(\"No customer ID found for payment intent\");\n return;\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(customerId);\n const created = new Date(charge.created * 1000);\n\n await locals.admin.collection(\"transactions\").create({\n stripe_payment_intent: paymentIntent.id,\n stripe_charge: chargeId,\n stripe_customer: customerId,\n amount: paymentIntent.amount,\n currency: paymentIntent.currency,\n created: created.toISOString(),\n last4: charge.payment_method_details?.card?.last4,\n brand: charge.payment_method_details?.card?.brand,\n receipt_url: charge.receipt_url,\n user: customer.user,\n });\n}\n", Bl = "import Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n\n/**\n * Handles payment_method.attached event\n */\nexport async function handlePaymentMethodAttached(\n paymentMethod: Stripe.PaymentMethod,\n locals: App.Locals,\n) {\n if (\n paymentMethod.allow_redisplay === \"unspecified\" ||\n !paymentMethod.customer\n ) {\n return;\n }\n\n const customer =\n typeof paymentMethod.customer === \"string\"\n ? paymentMethod.customer\n : paymentMethod.customer?.id;\n\n await locals.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customer,\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\n const paymentMethodRecords = await locals.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: locals.admin.filter(\"customer = {:customer}\", {\n customer: customer,\n }),\n });\n\n if (paymentMethodRecords.length === 1) {\n const paymentMethod = paymentMethodRecords[0];\n\n await stripe.customers.update(customer, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n await locals.admin.collection(\"stripe_customers\").update(customer, {\n default_payment_method: paymentMethod.id,\n });\n }\n}\n", Vl = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentMethodAttached } from \"./attached\";\n\ndescribe(\"payment_method.attached\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n paymentMethod = await stripe.paymentMethods.update(paymentMethod.id, {\n allow_redisplay: \"always\",\n });\n });\n\n afterEach(async (context) => {\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n\n for (const pm of paymentMethods) {\n await context.admin.collection(\"stripe_payment_methods\").delete(pm.id);\n }\n\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch {}\n }\n\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a payment method record when payment method is attached\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n const pm = paymentMethods[0];\n\n expect(pm.id).toBe(paymentMethod.id);\n expect(pm.customer).toBe(stripeCustomer.id);\n expect(pm.brand).toBe(paymentMethod.card?.brand);\n expect(pm.last4).toBe(paymentMethod.card?.last4);\n expect(pm.exp_month).toBe(paymentMethod.card?.exp_month);\n expect(pm.exp_year).toBe(paymentMethod.card?.exp_year);\n });\n\n it(\"sets payment method as default when it is the first one\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default in database\n const customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Verify it was set as default in Stripe\n const stripeCustomerUpdated = await stripe.customers.retrieve(\n stripeCustomer.id,\n );\n if (\"deleted\" in stripeCustomerUpdated) {\n throw new Error(\"Customer should not be deleted\");\n }\n expect(stripeCustomerUpdated.invoice_settings.default_payment_method).toBe(\n paymentMethod.id,\n );\n });\n\n it(\"does not set as default when there are already payment methods\", async (context) => {\n // Handle the first payment method\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default\n let customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Create and attach a first payment method\n let secondPaymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_mastercard\",\n },\n });\n\n await stripe.paymentMethods.attach(secondPaymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n secondPaymentMethod = await stripe.paymentMethods.update(\n secondPaymentMethod.id,\n {\n allow_redisplay: \"always\",\n },\n );\n\n // Now handle the second payment method\n await handlePaymentMethodAttached(secondPaymentMethod, locals);\n\n // Verify the default did NOT change\n customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Clean up the second payment method\n await context.admin\n .collection(\"stripe_payment_methods\")\n .delete(secondPaymentMethod.id);\n await stripe.paymentMethods.detach(secondPaymentMethod.id);\n });\n\n it(\"handles payment method with customer object instead of string\", async (context) => {\n // Retrieve the payment method with expanded customer\n const expandedPaymentMethod = await stripe.paymentMethods.retrieve(\n paymentMethod.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(expandedPaymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n expect(paymentMethods[0].customer).toBe(stripeCustomer.id);\n });\n\n it(\"does not create record when allow_redisplay is unspecified\", async (context) => {\n // Update payment method to have unspecified allow_redisplay\n const unspecifiedPaymentMethod = await stripe.paymentMethods.update(\n paymentMethod.id,\n {\n allow_redisplay: \"unspecified\",\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(unspecifiedPaymentMethod, locals);\n\n // Verify no payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(0);\n });\n});\n", Hl = /* @__PURE__ */ Object.assign({
|
|
4834
|
-
"./creates/data/hooks/stripe.pb.js":
|
|
4835
|
-
"./creates/data/hooks/utils.js":
|
|
4836
|
-
"./creates/src/lib/components/payments/confirm-dialog.svelte":
|
|
4837
|
-
"./creates/src/lib/components/payments/payment-button.svelte":
|
|
4838
|
-
"./creates/src/lib/components/payments/payment-dialog.svelte":
|
|
4839
|
-
"./creates/src/lib/components/payments/stripe-constants.ts":
|
|
4840
|
-
"./creates/src/lib/components/payments/stripe-payment-form.svelte":
|
|
4841
|
-
"./creates/src/lib/components/payments/use-payment-intent.svelte.ts":
|
|
4842
|
-
"./creates/src/lib/components/payments/use-stripe.svelte.ts":
|
|
4843
|
-
"./creates/src/lib/stripe.ts":
|
|
4844
|
-
"./creates/src/routes/api/stripe/payment-intent/+server.ts":
|
|
4845
|
-
"./creates/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
4846
|
-
"./creates/src/routes/api/stripe/sync/prices/+server.ts":
|
|
4847
|
-
"./creates/src/routes/api/stripe/sync/products/+server.ts":
|
|
4848
|
-
"./creates/src/routes/webhooks/stripe/+server.ts":
|
|
4849
|
-
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
4850
|
-
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
4851
|
-
"./creates/src/routes/webhooks/stripe/server.test.ts":
|
|
4852
|
-
}),
|
|
4853
|
-
"./creates-app-mode/data/hooks/stripe.pb.js":
|
|
4854
|
-
"./creates-app-mode/data/hooks/utils.js":
|
|
4855
|
-
"./creates-app-mode/src/lib/components/payments/setup-button.svelte":
|
|
4856
|
-
"./creates-app-mode/src/lib/components/payments/setup-dialog.svelte":
|
|
4857
|
-
"./creates-app-mode/src/routes/(app)/billing/+layout.server.ts":
|
|
4943
|
+
generate: Sl
|
|
4944
|
+
}, wl = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/products\");\n});\n\ncronAdd(\"stripe-prices\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/prices\");\n});\n", Tl = "/// <reference path=\"../types.d.ts\" />\n\nmodule.exports = {\n triggerJob: (jobUrl) => {\n $http.send({\n method: \"POST\",\n url: `${$app.settings().meta.appURL}${jobUrl}`,\n headers: {\n Authorization: `Bearer ${$os.getenv(\"INTERNAL_JOB_SECRET\")}`,\n },\n });\n },\n};\n", El = "<script lang=\"ts\">\n import type { Stripe } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n brand?: string;\n last4?: string;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n brand,\n last4,\n clientSecret,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n const brandNames = {\n amex: 'American Express',\n cartes_bancaires: 'Cartes Bancaires',\n diners: 'Diners',\n discover: 'Discover',\n eftpos_au: 'Eftpos Au',\n jcb: 'Jcb',\n link: 'Link',\n mastercard: 'Mastercard',\n unionpay: 'Unionpay',\n visa: 'Visa',\n unknown: 'Unknown'\n };\n\n let isProcessing = $state(false);\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !clientSecret) return;\n\n isProcessing = true;\n\n try {\n const { error: confirmError } = await stripe.confirmPayment({\n clientSecret,\n confirmParams: {\n return_url: page.url.toString()\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Confirm payment</Dialog.Title>\n <Dialog.Description>\n Are you sure you want to pay {amountFormatted} with your\n {brandNames[brand as keyof typeof brandNames]}\n credit card ending in **** {last4}?\n </Dialog.Description>\n </Dialog.Header>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", Dl = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import PaymentDialog from '$lib/components/payments/payment-dialog.svelte';\n import ConfirmDialog from '$lib/components/payments/confirm-dialog.svelte';\n import { useStripe } from '$lib/components/payments/use-stripe.svelte';\n import { usePaymentIntent } from '$lib/components/payments/use-payment-intent.svelte';\n import type { ButtonProps } from '$lib/components/ui/button';\n\n interface Props {\n priceId: string;\n user?: { email: string; name: string } | null;\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n priceId,\n user,\n disabled = false,\n isProcessing = false,\n label = 'Purchase',\n processingLabel = 'Processing...',\n onsuccess,\n ...rest\n }: Props & ButtonProps = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let mode = $state<'payment' | 'confirm'>('payment');\n let showDialog = $state(false);\n let amount = $state<number>(0);\n let currency = $state<string>('usd');\n let clientSecret = $state<string>();\n let brand = $state<string>();\n let last4 = $state<string>();\n\n async function handleBuyClick() {\n const result = await paymentIntentManager.fetchPaymentIntent({\n priceId\n });\n\n if (!result) return;\n\n if (result.type === 'confirm') {\n mode = 'confirm';\n brand = result.brand;\n last4 = result.last4;\n } else if (result.type === 'payment') {\n mode = 'payment';\n }\n\n amount = result.amount || 0;\n currency = result.currency || 'usd';\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleBuyClick} {...rest}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n{#if mode === 'confirm'}\n <ConfirmDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {brand}\n {last4}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{:else if mode === 'payment'}\n <PaymentDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {amount}\n {currency}\n {clientSecret}\n {user}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n />\n{/if}\n", Ol = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { Label } from '$lib/components/ui/label';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n amount: number;\n currency: string;\n clientSecret?: string;\n user?: { email: string; name: string } | null;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let {\n stripe,\n open = $bindable(),\n amount,\n currency,\n clientSecret,\n user = null,\n onopenchange,\n onsuccess\n }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let savePaymentMethod = $state(false);\n let email = $state<string>();\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n let amountFormatted = $derived.by(() => {\n let formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: currency });\n return formatter.format(amount / 100);\n });\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handlePaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to pay for your purchase');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmPayment({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n billing_details: {\n email: email || user?.email\n },\n allow_redisplay: savePaymentMethod ? 'always' : 'unspecified'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to pay for your purchase');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment successful');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error paying for your purchase:', err);\n toast.error('Failed to pay for your purchase');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>{amountFormatted}</Dialog.Title>\n <Dialog.Description>Enter your card details to pay for your purchase.</Dialog.Description>\n </Dialog.Header>\n {#if !user}\n <div class=\"space-y-2\">\n <Label for=\"email\">Email</Label>\n <Input type=\"email\" bind:value={email} />\n </div>\n {/if}\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"payment\"\n {stripe}\n {amount}\n {currency}\n {savePaymentMethod}\n {user}\n onchange={handleCardChange}\n />\n {/if}\n </div>\n {#if user}\n <div class=\"flex items-center gap-2\">\n <input type=\"checkbox\" id=\"savePaymentMethod\" bind:checked={savePaymentMethod} />\n <label for=\"savePaymentMethod\" class=\"text-sm text-muted-foreground\">\n Save payment method for future purchases\n </label>\n </div>\n {/if}\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handlePaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Pay Now'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", kl = "export const TERMS_AUTO = {\n applePay: \"auto\" as const,\n auBecsDebit: \"auto\" as const,\n bancontact: \"auto\" as const,\n card: \"auto\" as const,\n cashapp: \"auto\" as const,\n googlePay: \"auto\" as const,\n ideal: \"auto\" as const,\n paypal: \"auto\" as const,\n sepaDebit: \"auto\" as const,\n sofort: \"auto\" as const,\n usBankAccount: \"auto\" as const,\n};\n\nexport const TERMS_NEVER = {\n applePay: \"never\" as const,\n auBecsDebit: \"never\" as const,\n bancontact: \"never\" as const,\n card: \"never\" as const,\n cashapp: \"never\" as const,\n googlePay: \"never\" as const,\n ideal: \"never\" as const,\n paypal: \"never\" as const,\n sepaDebit: \"never\" as const,\n sofort: \"never\" as const,\n usBankAccount: \"never\" as const,\n};\n", Al = "<script lang=\"ts\">\n import type {\n Stripe,\n StripeElements,\n StripePaymentElement,\n StripeElementsOptionsMode\n } from '@stripe/stripe-js';\n import { mode as modeWatcher } from 'mode-watcher';\n import { TERMS_AUTO, TERMS_NEVER } from './stripe-constants';\n import { onMount } from 'svelte';\n\n interface Props {\n stripe: Stripe;\n mode: 'payment' | 'setup';\n amount?: number;\n currency?: string;\n savePaymentMethod?: boolean;\n user?: { email: string; name: string } | null;\n onchange: (complete: boolean) => void;\n }\n\n let {\n stripe,\n mode,\n amount = 0,\n currency = 'usd',\n savePaymentMethod = false,\n user,\n onchange\n }: Props = $props();\n\n let cardContainer = $state<HTMLDivElement | null>(null);\n let elements = $state<StripeElements | null>(null);\n let paymentElement = $state<StripePaymentElement | null>(null);\n\n function initializeElements() {\n if (!stripe) return;\n\n // Clean up previous elements\n if (paymentElement) {\n paymentElement.destroy();\n paymentElement = null;\n }\n\n const appearance = {\n theme: modeWatcher.current === 'dark' ? ('night' as const) : ('stripe' as const),\n inputs: 'condensed' as const,\n labels: 'floating' as const\n };\n\n elements = stripe.elements({\n mode,\n appearance,\n currency,\n ...(mode === 'payment' && {\n amount: amount\n }),\n ...(user || mode === 'setup'\n ? {\n setupFutureUsage: 'off_session' as const\n }\n : {})\n } as StripeElementsOptionsMode);\n\n paymentElement = elements.create('payment', {\n layout: 'tabs',\n defaultValues: {\n billingDetails: {\n email: user?.email,\n name: user?.name\n }\n },\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n\n if (cardContainer && paymentElement) {\n paymentElement.mount(cardContainer);\n paymentElement.on('change', (event: any) => {\n onchange(event.complete);\n });\n }\n }\n\n // Initialize elements when component mounts\n onMount(() => {\n initializeElements();\n\n return () => {\n if (paymentElement) {\n paymentElement.destroy();\n }\n };\n });\n\n // Update terms when savePaymentMethod changes\n $effect(() => {\n if (paymentElement) {\n paymentElement.update({\n terms: savePaymentMethod ? TERMS_AUTO : TERMS_NEVER\n });\n }\n });\n\n export function getElements() {\n return elements;\n }\n<\/script>\n\n<div bind:this={cardContainer}></div>\n", jl = "import { toast } from \"svelte-sonner\";\n\nexport interface PaymentIntentResult {\n type: \"payment\" | \"confirm\";\n amount?: number;\n currency?: string;\n clientSecret?: string;\n brand?: string;\n last4?: string;\n}\n\nexport function usePaymentIntent() {\n let isLoading = $state(false);\n\n async function fetchPaymentIntent({\n priceId,\n }: {\n priceId: string;\n }): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/payment-intent\", {\n method: \"POST\",\n body: JSON.stringify({\n priceId: priceId,\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize payment\");\n return null;\n }\n\n return res.json();\n }\n\n async function fetchSetupIntent(): Promise<PaymentIntentResult | null> {\n isLoading = true;\n\n const res = await fetch(\"/api/stripe/setup-intent\", {\n method: \"POST\",\n });\n\n if (!res.ok) {\n toast.error(\"Failed to initialize setup\");\n return null;\n }\n\n return res.json();\n }\n\n return {\n get isLoading() {\n return isLoading;\n },\n fetchPaymentIntent,\n fetchSetupIntent,\n };\n}\n", Ml = "import { loadStripe, type Stripe } from \"@stripe/stripe-js\";\nimport { toast } from \"svelte-sonner\";\nimport { env } from \"$env/dynamic/public\";\n\nexport function useStripe() {\n let stripe = $state<Stripe | null>(null);\n let isLoading = $state(true);\n let error = $state<string | null>(null);\n\n async function initialize() {\n try {\n stripe = await loadStripe(env.PUBLIC_STRIPE_PUBLISHABLE_KEY);\n isLoading = false;\n } catch (err) {\n console.error(\"Failed to load Stripe:\", err);\n error = \"Failed to initialize payment system\";\n toast.error(\"Failed to initialize payment system\");\n isLoading = false;\n }\n }\n\n // Auto-initialize\n initialize();\n\n return {\n get stripe() {\n return stripe;\n },\n get isLoading() {\n return isLoading;\n },\n get error() {\n return error;\n },\n };\n}\n", Nl = "import { env } from \"$env/dynamic/private\";\nimport Stripe from \"stripe\";\n\nconst stripe = new Stripe(env.STRIPE_SECRET_KEY, {\n apiVersion: \"2026-04-22.dahlia\",\n});\n\nexport default stripe;\n", Pl = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (price: Stripe.Price) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n try {\n const res = await createPaymentIntent(price);\n return json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return json({ error: errorMessage }, { status: 500 });\n }\n};\n", Fl = "import { describe, it, expect, beforeAll } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"$lib/stripe\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", Il = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const prices = await stripe.prices.list();\n\n for (const price of prices.data) {\n try {\n await locals.admin\n .collection(\"stripe_prices\")\n .getFirstListItem(`id = \"${price.id}\"`);\n continue;\n } catch {}\n\n await locals.admin.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 console.log(\"Prices synced\");\n return json({ message: \"Prices synced\" });\n};\n", Ll = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const products = await stripe.products.list();\n\n for (const product of products.data) {\n try {\n await locals.admin\n .collection(\"stripe_products\")\n .getFirstListItem(`id = \"${product.id}\"`);\n continue;\n } catch {}\n\n await locals.admin.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 console.log(\"Products synced\");\n return json({ message: \"Products synced\" });\n};\n", Rl = "import Stripe from \"stripe\";\nimport { json } from \"@sveltejs/kit\";\nimport { env } from \"$env/dynamic/private\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./handlers/payment-intent/succeeded\";\n\nconst processedEvents = new Set<string>();\n\nasync function verifyWebhookSignature(\n request: Request,\n webhookSecret: string,\n): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get(\"stripe-signature\");\n\n if (!signature) {\n throw new Error(\"Missing stripe-signature header\");\n }\n\n if (!webhookSecret) {\n throw new Error(\"Missing webhook secret\");\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error(\"Webhook signature verification failed:\", err);\n throw new Error(\"Invalid signature\");\n }\n}\n\nexport const POST = async ({ request, locals }) => {\n try {\n const event = await verifyWebhookSignature(\n request,\n env.STRIPE_WEBHOOK_SECRET,\n );\n\n if (processedEvents.has(event.id)) {\n console.log(`Event ${event.id} already processed, skipping`);\n return json({ received: true, message: \"Event already processed\" });\n }\n\n processedEvents.add(event.id);\n\n console.log(`Processing webhook event: ${event.type} (${event.id})`);\n\n switch (event.type) {\n case \"payment_intent.succeeded\":\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n\n return json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n });\n } catch (error) {\n console.error(\"Webhook processing error:\", error);\n\n return json(\n {\n error: \"Webhook processing failed\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n { status: 400 },\n );\n }\n};\n", zl = "import { describe, it, expect } from \"vitest\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n it(\"handles a payment intent successfully\", async (context) => {\n const paymentIntent = await stripe.paymentIntents.create({\n amount: 2000,\n currency: \"usd\",\n });\n const locals = { admin: context.admin } as App.Locals;\n const result = await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n expect(result).toEqual({});\n });\n});\n", Bl = "import Stripe from \"stripe\";\n\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n return {};\n}\n", Vl = "import { describe, it, expect } from \"vitest\";\nimport type { RouteId } from \"./$types\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n\ndescribe(\"POST /webhooks/stripe\", () => {\n it(\"accepts valid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(200);\n expect(response.body.received).toBe(true);\n expect(response.body.eventId).toBe(event.id);\n expect(response.body.eventType).toBe(\"test.event\");\n });\n\n it(\"rejects invalid webhook signature\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", \"invalid_signature\")\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n });\n\n it(\"rejects request without signature header\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n\n const response = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Webhook processing failed\");\n expect(response.body.message).toBe(\"Missing stripe-signature header\");\n });\n\n it(\"handles duplicate webhook events\", async (context) => {\n const event = {\n id: `evt_test_${Date.now()}`,\n object: \"event\",\n api_version: \"2024-11-20.acacia\",\n created: Math.floor(Date.now() / 1000),\n type: \"test.event\",\n data: {\n object: {},\n },\n livemode: false,\n pending_webhooks: 0,\n request: {\n id: null,\n idempotency_key: null,\n },\n } as unknown as Stripe.Event;\n\n const payload = JSON.stringify(event);\n const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;\n const signature = stripe.webhooks.generateTestHeaderString({\n payload,\n secret: webhookSecret,\n });\n\n // Send first webhook\n const response1 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response1.status).toBe(200);\n expect(response1.body.received).toBe(true);\n\n // Send duplicate webhook\n const response2 = await context.request\n .post(\"/webhooks/stripe\" satisfies Match<RouteId>)\n .set(\"stripe-signature\", signature)\n .send(payload)\n .set(\"Content-Type\", \"application/json\");\n\n expect(response2.status).toBe(200);\n expect(response2.body.received).toBe(true);\n expect(response2.body.message).toBe(\"Event already processed\");\n });\n});\n", Hl = "/// <reference path=\"../types.d.ts\" />\n\ncronAdd(\"stripe-products\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/products\");\n});\n\ncronAdd(\"stripe-prices\", \"*/2 * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/prices\");\n});\n\ncronAdd(\"stripe-customers\", \"* * * * *\", () => {\n const utils = require(`${__hooks}/utils.js`);\n utils.triggerJob(\"/api/stripe/sync/customers\");\n});\n", Ul = "/// <reference path=\"../types.d.ts\" />\n\nmodule.exports = {\n triggerJob: (jobUrl) => {\n $http.send({\n method: \"POST\",\n url: `${$app.settings().meta.appURL}${jobUrl}`,\n headers: {\n Authorization: `Bearer ${$os.getenv(\"INTERNAL_JOB_SECRET\")}`,\n },\n });\n },\n};\n", Wl = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import SetupDialog from '$lib/components/payments/setup-dialog.svelte';\n import { useStripe } from '$lib/components/payments/use-stripe.svelte';\n import { usePaymentIntent } from '$lib/components/payments/use-payment-intent.svelte';\n\n interface Props {\n disabled?: boolean;\n isProcessing?: boolean;\n label?: string;\n processingLabel?: string;\n onsuccess?: () => void;\n }\n\n let {\n disabled = false,\n isProcessing = false,\n label,\n processingLabel,\n onsuccess\n }: Props = $props();\n\n const stripeManager = useStripe();\n const paymentIntentManager = usePaymentIntent();\n\n let showDialog = $state(false);\n let clientSecret = $state<string>();\n\n async function handleSetupClick() {\n const result = await paymentIntentManager.fetchSetupIntent();\n\n if (!result) return;\n\n clientSecret = result.clientSecret;\n showDialog = true;\n }\n\n function handleDialogOpenChange(open: boolean) {\n showDialog = open;\n }\n\n function handlePaymentSuccess() {\n onsuccess?.();\n }\n<\/script>\n\n<Button disabled={disabled || isProcessing} onclick={handleSetupClick}>\n {#if isProcessing}\n {processingLabel}\n {:else}\n {label}\n {/if}\n</Button>\n\n<SetupDialog\n bind:open={showDialog}\n stripe={stripeManager.stripe}\n {clientSecret}\n onopenchange={handleDialogOpenChange}\n onsuccess={handlePaymentSuccess}\n/>\n", Gl = "<script lang=\"ts\">\n import type { Stripe, StripeElements } from '@stripe/stripe-js';\n import { Button } from '$lib/components/ui/button';\n import * as Dialog from '$lib/components/ui/dialog';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { invalidate } from '$app/navigation';\n import StripePaymentForm from './stripe-payment-form.svelte';\n\n interface Props {\n stripe: Stripe | null;\n open: boolean;\n clientSecret?: string;\n onopenchange: (open: boolean) => void;\n onsuccess: () => void;\n }\n\n let { stripe, open = $bindable(), clientSecret, onopenchange, onsuccess }: Props = $props();\n\n let isProcessing = $state(false);\n let cardComplete = $state(false);\n let formRef = $state<{\n getElements: () => StripeElements | null;\n }>();\n\n const handleOpenChangeComplete = (isOpen: boolean) => {\n if (!isOpen) {\n resetDialog();\n }\n onopenchange(isOpen);\n };\n\n function resetDialog() {\n open = false;\n isProcessing = false;\n cardComplete = false;\n }\n\n function handleCardChange(complete: boolean) {\n cardComplete = complete;\n }\n\n async function handleSetupPaymentMethod() {\n if (!stripe || !formRef || !cardComplete || !clientSecret) return;\n\n const elements = formRef.getElements();\n if (!elements) return;\n\n isProcessing = true;\n\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n toast.error(submitError.message || 'Failed to add payment method');\n return;\n }\n\n const { error: confirmError } = await stripe.confirmSetup({\n elements,\n clientSecret,\n confirmParams: {\n return_url: page.url.toString(),\n payment_method_data: {\n allow_redisplay: 'always'\n }\n },\n redirect: 'if_required'\n });\n\n if (confirmError) {\n toast.error(confirmError.message || 'Failed to add payment method');\n return;\n }\n\n await invalidate('app:billing');\n toast.success('Payment method added successfully');\n onsuccess();\n resetDialog();\n } catch (err) {\n console.error('Error adding payment method:', err);\n toast.error('Failed to add payment method');\n } finally {\n isProcessing = false;\n }\n }\n<\/script>\n\n<Dialog.Root bind:open onOpenChangeComplete={handleOpenChangeComplete}>\n <Dialog.Content class=\"sm:max-w-[500px]\">\n <Dialog.Header>\n <Dialog.Title>Add payment method</Dialog.Title>\n <Dialog.Description>Enter your card details to add a new payment method.</Dialog.Description>\n </Dialog.Header>\n <div>\n {#if stripe && open}\n <StripePaymentForm\n bind:this={formRef}\n mode=\"setup\"\n {stripe}\n onchange={handleCardChange}\n savePaymentMethod={true}\n />\n {/if}\n </div>\n <Dialog.Footer>\n <Button variant=\"outline\" onclick={resetDialog} disabled={isProcessing}>Cancel</Button>\n <Button onclick={handleSetupPaymentMethod} disabled={!cardComplete || isProcessing}>\n {isProcessing ? 'Processing...' : 'Add Card'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n</Dialog.Root>\n", Kl = "export const load = async ({ parent }) => {\n const { breadcrumbs } = await parent();\n\n return {\n breadcrumbs: [...breadcrumbs, { title: \"Billing\", url: \"/billing\" }],\n };\n};\n", ql = "# Billing Page - Stripe Payment Methods\n\nThis billing page provides a modern UI for managing payment methods with Stripe.\n\n## Features\n\n✅ **Display Payment Methods** - Shows all saved cards with brand, last 4 digits, and expiration\n✅ **Add Payment Methods** - Secure card input using Stripe Elements\n✅ **Remove Payment Methods** - Delete cards with confirmation dialog\n✅ **Default Payment Method** - Set and display the default payment method\n✅ **Responsive Design** - Mobile-friendly layout\n✅ **Error Handling** - Toast notifications for user feedback\n\n## Current Status\n\nThe frontend is **fully functional** with mock data. To connect to your backend, follow the integration steps below.\n\n## Backend Integration\n\n### 1. Update Stripe Publishable Key\n\nIn `+page.svelte`, replace the placeholder with your actual Stripe publishable key:\n\n```typescript\nconst STRIPE_PUBLISHABLE_KEY = \"pk_test_YOUR_KEY_HERE\";\n```\n\nOr better yet, load it from environment variables:\n\n```typescript\nimport { env } from \"$env/dynamic/public\";\nconst STRIPE_PUBLISHABLE_KEY = env.PUBLIC_STRIPE_PUBLISHABLE_KEY;\n```\n\n### 2. Fetch Payment Methods on Load\n\nUpdate `+page.server.ts` to fetch payment methods:\n\n```typescript\nexport const load: PageServerLoad = async ({ locals }) => {\n const user = locals.user;\n\n if (!user?.stripeCustomerId) {\n return { paymentMethods: [] };\n }\n\n // Fetch payment methods from Stripe\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n const paymentMethods = await stripe.paymentMethods.list({\n customer: user.stripeCustomerId,\n type: \"card\",\n });\n\n return {\n paymentMethods: paymentMethods.data.map((pm) => ({\n id: pm.id,\n brand: pm.card?.brand || \"unknown\",\n last4: pm.card?.last4 || \"0000\",\n expMonth: pm.card?.exp_month || 1,\n expYear: pm.card?.exp_year || 2025,\n isDefault: false, // You'll need to track this separately\n })),\n };\n};\n```\n\n### 3. Create API Endpoints\n\nCreate the following server endpoints:\n\n#### Add Payment Method: `+page.server.ts`\n\n```typescript\nexport const actions = {\n addPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Attach payment method to customer\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.paymentMethods.attach(paymentMethodId, {\n customer: locals.user.stripeCustomerId,\n });\n\n return { success: true };\n },\n\n removePaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Detach payment method from customer\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.paymentMethods.detach(paymentMethodId);\n\n return { success: true };\n },\n\n setDefaultPaymentMethod: async ({ request, locals }) => {\n const formData = await request.formData();\n const paymentMethodId = formData.get(\"paymentMethodId\");\n\n // Update customer's default payment method\n const stripe = await import(\"$lib/stripe\").then((m) => m.default);\n await stripe.customers.update(locals.user.stripeCustomerId, {\n invoice_settings: {\n default_payment_method: paymentMethodId,\n },\n });\n\n return { success: true };\n },\n};\n```\n\n### 4. Update Frontend to Use Actions\n\nReplace the mock functions in `+page.svelte`:\n\n```typescript\nasync function handleAddPaymentMethod() {\n if (!stripe || !cardElement || !cardComplete) return;\n\n isProcessing = true;\n\n try {\n const { error, paymentMethod } = await stripe.createPaymentMethod({\n type: \"card\",\n card: cardElement,\n });\n\n if (error) {\n toast.error(error.message);\n return;\n }\n\n // Submit to your backend\n const formData = new FormData();\n formData.append(\"paymentMethodId\", paymentMethod.id);\n\n const response = await fetch(\"?/addPaymentMethod\", {\n method: \"POST\",\n body: formData,\n });\n\n if (response.ok) {\n toast.success(\"Payment method added\");\n // Reload page to fetch updated payment methods\n window.location.reload();\n }\n } finally {\n isProcessing = false;\n }\n}\n```\n\n## Security Considerations\n\n⚠️ **Important**: Never expose your Stripe secret key on the frontend\n✅ All sensitive operations should happen on your backend\n✅ Use Stripe's publishable key for frontend operations\n✅ Validate user permissions before modifying payment methods\n✅ Use HTTPS in production\n\n## Testing\n\nUse [Stripe's test cards](https://stripe.com/docs/testing) for testing:\n\n- **Success**: 4242 4242 4242 4242\n- **Decline**: 4000 0000 0000 0002\n- **Requires authentication**: 4000 0025 0000 3155\n\nUse any future expiration date and any 3-digit CVC.\n\n## Styling\n\nThe page uses Tailwind CSS and shadcn/ui components. All components are styled to match your existing design system with support for light/dark modes.\n\n### Stripe Elements Styling\n\nSince Stripe Elements render in an iframe, they cannot access CSS variables directly. Additionally, Stripe only accepts HEX, RGB, or HSL colors (not modern formats like OKLCH).\n\nThe implementation:\n\n1. **Creates temporary DOM elements** with CSS variables applied\n2. **Lets the browser compute colors** - converts OKLCH/HSL/any format to RGB\n3. **Extracts RGB values** that Stripe Elements can understand\n4. **Passes computed colors** to Stripe Elements on initialization\n5. **Matches the current theme** automatically (light/dark mode)\n\nThis approach works with any CSS color format (oklch, hsl, rgb, hex) and ensures Stripe Elements always match your theme when the \"Add Payment Method\" dialog opens.\n\n## Dependencies\n\n- `@stripe/stripe-js` - Stripe.js for frontend\n- `stripe` - Stripe Node.js SDK for backend\n- `svelte-sonner` - Toast notifications\n- `@lucide/svelte` - Icons\n- shadcn/ui components\n", Jl = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport type { Stripe } from \"stripe\";\n\nconst createPaymentIntent = async (\n price: Stripe.Price,\n customer?: { id: string; default_payment_method?: string },\n) => {\n if (price.unit_amount === null || price.unit_amount === undefined) {\n console.error(\"Price does not have a per unit amount\");\n throw new Error(\"Price does not have a per unit amount\");\n }\n\n // Guest\n if (!customer) {\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n }\n\n // Customer with saved payment method\n if (customer.default_payment_method) {\n const paymentMethod = await stripe.customers.retrievePaymentMethod(\n customer.id,\n customer.default_payment_method,\n );\n\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n payment_method: customer.default_payment_method,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return {\n type: \"confirm\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n };\n }\n\n // Customer without saved payment method\n const intent = await stripe.paymentIntents.create({\n amount: price.unit_amount,\n currency: price.currency,\n customer: customer.id,\n setup_future_usage: \"off_session\",\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n if (!intent.client_secret) {\n console.error(\"Payment intent created without client secret\");\n throw new Error(\"Failed to create payment intent\");\n }\n\n return {\n type: \"payment\",\n clientSecret: intent.client_secret,\n amount: price.unit_amount,\n currency: price.currency,\n };\n};\n\nexport const POST = async ({ request, locals }) => {\n const user = locals.pb.authStore.record?.id;\n\n let body;\n try {\n body = await request.json();\n } catch (error) {\n console.error(\"Invalid JSON in request body\");\n return json({ error: \"Invalid request body\" }, { status: 400 });\n }\n\n const { priceId } = body as { priceId?: string };\n\n // Validate required fields\n if (!priceId || typeof priceId !== \"string\" || priceId === \"\") {\n console.error(\"Missing or invalid priceId\");\n return json({ error: \"Price ID is required\" }, { status: 400 });\n }\n\n // Retrieve price from Stripe\n let price;\n try {\n price = await stripe.prices.retrieve(priceId);\n } catch (error) {\n console.error(\"Failed to retrieve price from Stripe:\", priceId);\n return json(\n { error: \"Invalid price ID or price not found\" },\n { status: 404 },\n );\n }\n\n // Validate price is active\n if (!price.active) {\n console.error(\"Price is not active:\", priceId);\n return json(\n { error: \"This price is no longer available\" },\n { status: 400 },\n );\n }\n\n let customer;\n\n if (user) {\n try {\n customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n locals.admin.filter(\"user = {:user}\", { user: user }),\n );\n } catch (error) {\n // Customer not found is expected for new users, log for debugging only\n console.log(\"No Stripe customer found for user:\", user);\n }\n }\n\n try {\n const res = await createPaymentIntent(price, customer);\n return json(res, { status: 200 });\n } catch (error) {\n console.error(\"Error creating payment intent for price:\", priceId);\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to create payment intent\";\n return json({ error: errorMessage }, { status: 500 });\n }\n};\n", Yl = "import { describe, it, expect, beforeAll, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\nimport stripe from \"$lib/stripe\";\nimport type Stripe from \"stripe\";\n\ndescribe(\"POST /api/stripe/payment-intent\", () => {\n let product: Stripe.Product;\n let activePrice: Stripe.Price;\n let inactivePrice: Stripe.Price;\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeAll(async () => {\n const productName = \"Test Product - Payment Intent\";\n const products = await stripe.products.search({\n query: `name:\"${productName}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n product = products.data[0];\n\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n\n if (prices.data.length > 0) {\n activePrice = prices.data[0];\n }\n\n const inactivePrices = await stripe.prices.list({\n product: product.id,\n active: false,\n limit: 1,\n });\n\n if (inactivePrices.data.length > 0) {\n inactivePrice = inactivePrices.data[0];\n }\n }\n\n // Create if not found or no active price\n if (!product) {\n product = await stripe.products.create({\n name: productName,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!activePrice) {\n activePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n metadata: {\n test: \"true\",\n test_type: \"payment-intent\",\n },\n });\n }\n\n if (!inactivePrice) {\n inactivePrice = await stripe.prices.create({\n product: product.id,\n unit_amount: 2000,\n currency: \"usd\",\n active: false,\n metadata: {\n test: \"true\",\n test_type: \"payment-intent-inactive\",\n },\n });\n }\n });\n\n beforeEach(async (context) => {\n // Create a Stripe customer for authenticated user tests\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Create a payment method for the customer\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n });\n\n afterEach(async () => {\n if (paymentMethod?.id) {\n await stripe.paymentMethods.detach(paymentMethod.id);\n }\n\n if (stripeCustomer?.id) {\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n describe(\"Request validation\", () => {\n it(\"should return 400 if request body is not valid JSON\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .set(\"Content-Type\", \"application/json\")\n .send(\"invalid json\");\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Invalid request body\");\n });\n\n it(\"should return 400 if priceId is missing\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({});\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is not a string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: 12345 });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 400 if priceId is an empty string\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"\" });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"Price ID is required\");\n });\n\n it(\"should return 404 if price does not exist\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: \"price_nonexistent123\" });\n\n expect(response.status).toBe(404);\n expect(response.body.error).toBe(\"Invalid price ID or price not found\");\n });\n\n it(\"should return 400 if price is not active\", async (context) => {\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: inactivePrice.id });\n\n expect(response.status).toBe(400);\n expect(response.body.error).toBe(\"This price is no longer available\");\n });\n });\n\n describe(\"Guest user (unauthenticated)\", () => {\n it(\"should create payment intent for guest user\", async (context) => {\n const response = await context.request\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent was created in Stripe\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.currency).toBe(\"usd\");\n expect(intent.customer).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user without Stripe customer\", () => {\n it(\"should create payment intent for user without Stripe customer\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n\n // Verify the payment intent\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.amount).toBe(1000);\n expect(intent.setup_future_usage).toBeNull();\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n\n describe(\"Authenticated user with Stripe customer\", () => {\n let customerRecord: { id: string };\n\n beforeEach(async (context) => {\n // Link the Stripe customer to the PocketBase user\n customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .create({\n user: context.user.id,\n id: stripeCustomer.id,\n email: stripeCustomer.email,\n });\n });\n\n afterEach(async (context) => {\n // Clean up the PocketBase customer record\n await context.admin\n .collection(\"stripe_customers\")\n .delete(customerRecord.id);\n });\n\n it(\"should create payment intent with setup_future_usage for user without default payment method\", async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"payment\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBeUndefined();\n expect(response.body.last4).toBeUndefined();\n\n // Verify the payment intent has setup_future_usage\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.setup_future_usage).toBe(\"off_session\");\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n\n it(\"should create payment intent with default payment method for customer with saved payment method\", async (context) => {\n // Set default payment method\n await stripe.customers.update(stripeCustomer.id, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n const customerRecord = await context.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(\n context.admin.filter(\"user = {:user}\", { user: context.user.id }),\n );\n\n await context.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customerRecord.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\n await context.admin\n .collection(\"stripe_customers\")\n .update(customerRecord.id, {\n default_payment_method: paymentMethod.id,\n });\n\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post(\"/api/stripe/payment-intent\" satisfies Match<RouteId>)\n .send({ priceId: activePrice.id });\n\n expect(response.status).toBe(200);\n expect(response.body.type).toBe(\"confirm\");\n expect(response.body.clientSecret).toBeDefined();\n expect(response.body.amount).toBe(1000);\n expect(response.body.currency).toBe(\"usd\");\n expect(response.body.brand).toBe(\"visa\");\n expect(response.body.last4).toBeDefined();\n expect(response.body.last4).toMatch(/^\\d{4}$/);\n\n // Verify the payment intent has the payment method attached\n const intentId = response.body.clientSecret.split(\"_secret_\")[0];\n const intent = await stripe.paymentIntents.retrieve(intentId);\n expect(intent.customer).toBe(stripeCustomer.id);\n expect(intent.payment_method).toBe(paymentMethod.id);\n\n // Clean up\n await stripe.paymentIntents.cancel(intent.id);\n });\n });\n});\n", Xl = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\n\nexport const POST = async ({ locals }) => {\n const user = locals.pb.authStore.record?.id;\n\n if (!user) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getFirstListItem(locals.admin.filter(\"user = {:user}\", { user }));\n\n if (!customer) {\n return json({ error: \"Customer not found\" }, { status: 404 });\n }\n\n const setupIntent = await stripe.setupIntents.create({\n customer: customer.id,\n automatic_payment_methods: {\n enabled: true,\n allow_redirects: \"never\",\n },\n });\n\n return json({ clientSecret: setupIntent.client_secret });\n};\n", Zl = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"POST /api/stripe/setup-intent\", () => {\n let stripeCustomer: Stripe.Customer;\n\n beforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n });\n\n afterEach(async (context) => {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n });\n\n it(\"creates a setup intent\", async (context) => {\n const response = await context.agent.post(\n \"/api/stripe/setup-intent\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n expect(response.body.clientSecret).toBeDefined();\n });\n});\n", Ql = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\n\n// Sync users to Stripe customers\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n // Ensure all users have a Stripe customer\n const users = await locals.admin\n .collection(\"users\")\n .getFullList({ filter: \"stripe_customers_via_user.id = null\" });\n\n for (const user of users) {\n const customer = await stripe.customers.create({\n email: user.email,\n name: user.name,\n });\n\n await locals.admin.collection(\"stripe_customers\").create({\n id: customer.id,\n user: user.id,\n });\n }\n\n console.log(\"Customers synced\");\n return json({ message: \"Customers synced\" });\n};\n", $l = "import Stripe from \"stripe\";\nimport { json } from \"@sveltejs/kit\";\nimport { env } from \"$env/dynamic/private\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./handlers/payment-intent/succeeded\";\nimport { handlePaymentMethodAttached } from \"./handlers/payment-method/attached\";\n\nconst processedEvents = new Set<string>();\n\nasync function verifyWebhookSignature(\n request: Request,\n webhookSecret: string,\n): Promise<Stripe.Event> {\n const body = await request.text();\n const signature = request.headers.get(\"stripe-signature\");\n\n if (!signature) {\n throw new Error(\"Missing stripe-signature header\");\n }\n\n if (!webhookSecret) {\n throw new Error(\"Missing webhook secret\");\n }\n\n try {\n return stripe.webhooks.constructEvent(body, signature, webhookSecret);\n } catch (err) {\n console.error(\"Webhook signature verification failed:\", err);\n throw new Error(\"Invalid signature\");\n }\n}\n\nexport const POST = async ({ request, locals }) => {\n try {\n const event = await verifyWebhookSignature(\n request,\n env.STRIPE_WEBHOOK_SECRET,\n );\n\n if (processedEvents.has(event.id)) {\n console.log(`Event ${event.id} already processed, skipping`);\n return json({ received: true, message: \"Event already processed\" });\n }\n\n processedEvents.add(event.id);\n\n console.log(`Processing webhook event: ${event.type} (${event.id})`);\n\n switch (event.type) {\n case \"payment_intent.succeeded\":\n await handlePaymentIntentSucceeded(event.data.object, locals);\n break;\n\n case \"payment_method.attached\":\n await handlePaymentMethodAttached(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n\n return json({\n received: true,\n eventId: event.id,\n eventType: event.type,\n });\n } catch (error) {\n console.error(\"Webhook processing error:\", error);\n\n return json(\n {\n error: \"Webhook processing failed\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n },\n { status: 400 },\n );\n }\n};\n", eu = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentIntentSucceeded } from \"./succeeded\";\n\ndescribe(\"payment_intent.succeeded\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentIntent: Stripe.PaymentIntent;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n // Create a Stripe customer\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n // Link the Stripe customer to the test user\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n // Create a payment method for testing\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n // Attach payment method to customer\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n // Create a payment intent\n paymentIntent = await stripe.paymentIntents.create({\n amount: 2000, // $20.00\n currency: \"usd\",\n customer: stripeCustomer.id,\n payment_method: paymentMethod.id,\n confirm: true,\n return_url: \"https://example.com/return\",\n });\n });\n\n afterEach(async (context) => {\n // Clean up transactions\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\"stripe_customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n for (const transaction of transactions) {\n await context.admin.collection(\"transactions\").delete(transaction.id);\n }\n\n // Clean up Stripe resources\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch (e) {\n // Payment method may already be detached\n }\n }\n\n // Delete customer (this will also delete associated payment methods)\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a transaction record when payment intent succeeds\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_customer).toBe(stripeCustomer.id);\n expect(transaction.amount).toBe(2000);\n expect(transaction.currency).toBe(\"usd\");\n expect(transaction.user).toBe(context.user.id);\n expect(transaction.stripe_charge).toBeDefined();\n expect(transaction.last4).toBeDefined();\n expect(transaction.brand).toBeDefined();\n expect(transaction.created).toBeDefined();\n expect(transaction.receipt_url).toBeDefined();\n });\n\n it(\"handles payment intent with charge object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded charge\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"latest_charge\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n const transaction = transactions[0];\n\n expect(transaction.stripe_payment_intent).toBe(paymentIntent.id);\n expect(transaction.stripe_charge).toBeDefined();\n });\n\n it(\"handles payment intent with customer object instead of string\", async (context) => {\n // Retrieve the payment intent with expanded customer\n const expandedPaymentIntent = await stripe.paymentIntents.retrieve(\n paymentIntent.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(expandedPaymentIntent, locals);\n\n // Verify transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(1);\n expect(transactions[0].stripe_customer).toBe(stripeCustomer.id);\n });\n\n it(\"handles missing charge ID gracefully\", async (context) => {\n const paymentIntentWithoutCharge = {\n ...paymentIntent,\n latest_charge: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCharge, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n\n it(\"handles missing customer ID gracefully\", async (context) => {\n const paymentIntentWithoutCustomer = {\n ...paymentIntent,\n customer: null,\n } as Stripe.PaymentIntent;\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentIntentSucceeded(paymentIntentWithoutCustomer, locals);\n\n // Verify no transaction was created\n const transactions = await context.admin\n .collection(\"transactions\")\n .getFullList({\n filter: context.admin.filter(\n \"stripe_payment_intent = {:paymentIntent}\",\n {\n paymentIntent: paymentIntent.id,\n },\n ),\n });\n\n expect(transactions).toHaveLength(0);\n });\n});\n", tu = "import Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n/**\n * Handles payment_intent.succeeded event\n */\nexport async function handlePaymentIntentSucceeded(\n paymentIntent: Stripe.PaymentIntent,\n locals: App.Locals,\n) {\n const chargeId =\n typeof paymentIntent.latest_charge === \"string\"\n ? paymentIntent.latest_charge\n : paymentIntent.latest_charge?.id;\n\n if (!chargeId) {\n console.error(\"No charge ID found for payment intent\");\n return;\n }\n\n const charge = await stripe.charges.retrieve(chargeId);\n\n const customerId =\n typeof paymentIntent.customer === \"string\"\n ? paymentIntent.customer\n : paymentIntent.customer?.id;\n\n if (!customerId) {\n console.error(\"No customer ID found for payment intent\");\n return;\n }\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(customerId);\n const created = new Date(charge.created * 1000);\n\n await locals.admin.collection(\"transactions\").create({\n stripe_payment_intent: paymentIntent.id,\n stripe_charge: chargeId,\n stripe_customer: customerId,\n amount: paymentIntent.amount,\n currency: paymentIntent.currency,\n created: created.toISOString(),\n last4: charge.payment_method_details?.card?.last4,\n brand: charge.payment_method_details?.card?.brand,\n receipt_url: charge.receipt_url,\n user: customer.user,\n });\n}\n", nu = "import Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\n\n/**\n * Handles payment_method.attached event\n */\nexport async function handlePaymentMethodAttached(\n paymentMethod: Stripe.PaymentMethod,\n locals: App.Locals,\n) {\n if (\n paymentMethod.allow_redisplay === \"unspecified\" ||\n !paymentMethod.customer\n ) {\n return;\n }\n\n const customer =\n typeof paymentMethod.customer === \"string\"\n ? paymentMethod.customer\n : paymentMethod.customer?.id;\n\n await locals.admin.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customer,\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\n const paymentMethodRecords = await locals.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: locals.admin.filter(\"customer = {:customer}\", {\n customer: customer,\n }),\n });\n\n if (paymentMethodRecords.length === 1) {\n const paymentMethod = paymentMethodRecords[0];\n\n await stripe.customers.update(customer, {\n invoice_settings: {\n default_payment_method: paymentMethod.id,\n },\n });\n\n await locals.admin.collection(\"stripe_customers\").update(customer, {\n default_payment_method: paymentMethod.id,\n });\n }\n}\n", ru = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type Stripe from \"stripe\";\nimport stripe from \"$lib/stripe\";\nimport { handlePaymentMethodAttached } from \"./attached\";\n\ndescribe(\"payment_method.attached\", () => {\n let stripeCustomer: Stripe.Customer;\n let paymentMethod: Stripe.PaymentMethod;\n\n beforeEach(async (context) => {\n stripeCustomer = await stripe.customers.create({\n email: context.user.email,\n metadata: {\n test: \"true\",\n },\n });\n\n await context.admin.collection(\"stripe_customers\").create({\n id: stripeCustomer.id,\n user: context.user.id,\n });\n\n paymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_visa\",\n },\n });\n\n await stripe.paymentMethods.attach(paymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n paymentMethod = await stripe.paymentMethods.update(paymentMethod.id, {\n allow_redisplay: \"always\",\n });\n });\n\n afterEach(async (context) => {\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"customer = {:stripeCustomer}\", {\n stripeCustomer: stripeCustomer.id,\n }),\n });\n\n for (const pm of paymentMethods) {\n await context.admin.collection(\"stripe_payment_methods\").delete(pm.id);\n }\n\n if (paymentMethod?.id) {\n try {\n await stripe.paymentMethods.detach(paymentMethod.id);\n } catch {}\n }\n\n if (stripeCustomer?.id) {\n await context.admin\n .collection(\"stripe_customers\")\n .delete(stripeCustomer.id);\n await stripe.customers.del(stripeCustomer.id);\n }\n });\n\n it(\"creates a payment method record when payment method is attached\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n const pm = paymentMethods[0];\n\n expect(pm.id).toBe(paymentMethod.id);\n expect(pm.customer).toBe(stripeCustomer.id);\n expect(pm.brand).toBe(paymentMethod.card?.brand);\n expect(pm.last4).toBe(paymentMethod.card?.last4);\n expect(pm.exp_month).toBe(paymentMethod.card?.exp_month);\n expect(pm.exp_year).toBe(paymentMethod.card?.exp_year);\n });\n\n it(\"sets payment method as default when it is the first one\", async (context) => {\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default in database\n const customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Verify it was set as default in Stripe\n const stripeCustomerUpdated = await stripe.customers.retrieve(\n stripeCustomer.id,\n );\n if (\"deleted\" in stripeCustomerUpdated) {\n throw new Error(\"Customer should not be deleted\");\n }\n expect(stripeCustomerUpdated.invoice_settings.default_payment_method).toBe(\n paymentMethod.id,\n );\n });\n\n it(\"does not set as default when there are already payment methods\", async (context) => {\n // Handle the first payment method\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(paymentMethod, locals);\n\n // Verify it was set as default\n let customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Create and attach a first payment method\n let secondPaymentMethod = await stripe.paymentMethods.create({\n type: \"card\",\n card: {\n token: \"tok_mastercard\",\n },\n });\n\n await stripe.paymentMethods.attach(secondPaymentMethod.id, {\n customer: stripeCustomer.id,\n });\n\n secondPaymentMethod = await stripe.paymentMethods.update(\n secondPaymentMethod.id,\n {\n allow_redisplay: \"always\",\n },\n );\n\n // Now handle the second payment method\n await handlePaymentMethodAttached(secondPaymentMethod, locals);\n\n // Verify the default did NOT change\n customer = await context.admin\n .collection(\"stripe_customers\")\n .getOne(stripeCustomer.id);\n expect(customer.default_payment_method).toBe(paymentMethod.id);\n\n // Clean up the second payment method\n await context.admin\n .collection(\"stripe_payment_methods\")\n .delete(secondPaymentMethod.id);\n await stripe.paymentMethods.detach(secondPaymentMethod.id);\n });\n\n it(\"handles payment method with customer object instead of string\", async (context) => {\n // Retrieve the payment method with expanded customer\n const expandedPaymentMethod = await stripe.paymentMethods.retrieve(\n paymentMethod.id,\n {\n expand: [\"customer\"],\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(expandedPaymentMethod, locals);\n\n // Verify payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(1);\n expect(paymentMethods[0].customer).toBe(stripeCustomer.id);\n });\n\n it(\"does not create record when allow_redisplay is unspecified\", async (context) => {\n // Update payment method to have unspecified allow_redisplay\n const unspecifiedPaymentMethod = await stripe.paymentMethods.update(\n paymentMethod.id,\n {\n allow_redisplay: \"unspecified\",\n },\n );\n\n const locals = { admin: context.admin } as App.Locals;\n await handlePaymentMethodAttached(unspecifiedPaymentMethod, locals);\n\n // Verify no payment method was created\n const paymentMethods = await context.admin\n .collection(\"stripe_payment_methods\")\n .getFullList({\n filter: context.admin.filter(\"id = {:paymentMethod}\", {\n paymentMethod: paymentMethod.id,\n }),\n });\n\n expect(paymentMethods).toHaveLength(0);\n });\n});\n", iu = /* @__PURE__ */ Object.assign({
|
|
4945
|
+
"./creates/data/hooks/stripe.pb.js": wl,
|
|
4946
|
+
"./creates/data/hooks/utils.js": Tl,
|
|
4947
|
+
"./creates/src/lib/components/payments/confirm-dialog.svelte": El,
|
|
4948
|
+
"./creates/src/lib/components/payments/payment-button.svelte": Dl,
|
|
4949
|
+
"./creates/src/lib/components/payments/payment-dialog.svelte": Ol,
|
|
4950
|
+
"./creates/src/lib/components/payments/stripe-constants.ts": kl,
|
|
4951
|
+
"./creates/src/lib/components/payments/stripe-payment-form.svelte": Al,
|
|
4952
|
+
"./creates/src/lib/components/payments/use-payment-intent.svelte.ts": jl,
|
|
4953
|
+
"./creates/src/lib/components/payments/use-stripe.svelte.ts": Ml,
|
|
4954
|
+
"./creates/src/lib/stripe.ts": Nl,
|
|
4955
|
+
"./creates/src/routes/api/stripe/payment-intent/+server.ts": Pl,
|
|
4956
|
+
"./creates/src/routes/api/stripe/payment-intent/server.test.ts": Fl,
|
|
4957
|
+
"./creates/src/routes/api/stripe/sync/prices/+server.ts": Il,
|
|
4958
|
+
"./creates/src/routes/api/stripe/sync/products/+server.ts": Ll,
|
|
4959
|
+
"./creates/src/routes/webhooks/stripe/+server.ts": Rl,
|
|
4960
|
+
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": zl,
|
|
4961
|
+
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": Bl,
|
|
4962
|
+
"./creates/src/routes/webhooks/stripe/server.test.ts": Vl
|
|
4963
|
+
}), au = /* @__PURE__ */ Object.assign({
|
|
4964
|
+
"./creates-app-mode/data/hooks/stripe.pb.js": Hl,
|
|
4965
|
+
"./creates-app-mode/data/hooks/utils.js": Ul,
|
|
4966
|
+
"./creates-app-mode/src/lib/components/payments/setup-button.svelte": Wl,
|
|
4967
|
+
"./creates-app-mode/src/lib/components/payments/setup-dialog.svelte": Gl,
|
|
4968
|
+
"./creates-app-mode/src/routes/(app)/billing/+layout.server.ts": Kl,
|
|
4858
4969
|
"./creates-app-mode/src/routes/(app)/billing/+page.server.ts": p,
|
|
4859
4970
|
"./creates-app-mode/src/routes/(app)/billing/+page.svelte": f,
|
|
4860
|
-
"./creates-app-mode/src/routes/(app)/billing/README.md":
|
|
4861
|
-
"./creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts":
|
|
4862
|
-
"./creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
4863
|
-
"./creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts":
|
|
4864
|
-
"./creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts":
|
|
4865
|
-
"./creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts":
|
|
4866
|
-
"./creates-app-mode/src/routes/webhooks/stripe/+server.ts":
|
|
4867
|
-
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
4868
|
-
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
4869
|
-
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts":
|
|
4870
|
-
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts":
|
|
4871
|
-
}),
|
|
4872
|
-
async function
|
|
4873
|
-
let t = e.features.auth, n = { ...a(
|
|
4971
|
+
"./creates-app-mode/src/routes/(app)/billing/README.md": ql,
|
|
4972
|
+
"./creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts": Jl,
|
|
4973
|
+
"./creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts": Yl,
|
|
4974
|
+
"./creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts": Xl,
|
|
4975
|
+
"./creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts": Zl,
|
|
4976
|
+
"./creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts": Ql,
|
|
4977
|
+
"./creates-app-mode/src/routes/webhooks/stripe/+server.ts": $l,
|
|
4978
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": eu,
|
|
4979
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": tu,
|
|
4980
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": nu,
|
|
4981
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": ru
|
|
4982
|
+
}), ou = "./creates/", su = "./creates-app-mode/";
|
|
4983
|
+
async function cu(e) {
|
|
4984
|
+
let t = e.features.auth, n = { ...a(iu, ou) };
|
|
4874
4985
|
if (t) {
|
|
4875
|
-
let e = a(
|
|
4986
|
+
let e = a(au, su);
|
|
4876
4987
|
Object.assign(n, e);
|
|
4877
4988
|
}
|
|
4878
4989
|
let r = Object.values(n).sort((e, t) => e.path.localeCompare(t.path)), i = [
|
|
@@ -4893,7 +5004,7 @@ async function Kl(e) {
|
|
|
4893
5004
|
}
|
|
4894
5005
|
//#endregion
|
|
4895
5006
|
//#region src/patterns/enable/payments/preview-modifies/src/routes/(public)/signup/+page.server.ts?raw
|
|
4896
|
-
var
|
|
5007
|
+
var lu = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { setFlash } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\nimport { dev } from \"$app/environment\";\nimport { signupSchema } from \"$lib/schemas/signup\";\n// [!code highlight:1]\nimport stripe from \"$lib/stripe\";\n\nexport const load = async ({ locals }) => {\n const authMethods = await locals.admin.collection(\"users\").listAuthMethods();\n\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(signupSchema)), authMethods };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies, url }) => {\n const form = await superValidate(request, zod4(signupSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let user;\n\n try {\n user = await locals.admin.collection(\"users\").create({\n email: form.data.email,\n password: form.data.password,\n passwordConfirm: form.data.passwordConfirm,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n // [!code highlight:1]\n await linkStripeCustomer(form.data.email, user, locals);\n\n await locals.pb.collection(\"users\").requestVerification(user.email);\n await locals.pb\n .collection(\"users\")\n .authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n const cookie = locals.pb.authStore.getCookie();\n cookies.set(\"pb_auth\", cookie, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n setFlash(\n { type: \"toast\", message: \"We sent a confirmation link to your email.\" },\n cookies,\n );\n return redirect(303, redirectUrl);\n },\n};\n\n// [!code highlight:66]\nconst linkStripeCustomer = async (\n email: string,\n user: { id: string },\n locals: App.Locals,\n) => {\n const matchingCustomer = await stripe.customers.list({\n email: email,\n limit: 1,\n expand: [\"data.invoice_settings\"],\n });\n\n let customer;\n let isExistingCustomer = false;\n\n if (matchingCustomer.data.length > 0) {\n isExistingCustomer = true;\n customer = matchingCustomer.data[0];\n } else {\n customer = await stripe.customers.create({\n email: email,\n });\n }\n\n await locals.admin.collection(\"stripe_customers\").create({\n id: customer.id,\n user: user.id,\n });\n\n if (!isExistingCustomer) {\n return;\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(\n customer.id,\n {\n type: \"card\",\n allow_redisplay: \"always\",\n },\n );\n\n for (const paymentMethod of paymentMethods.data) {\n if (paymentMethod.allow_redisplay === \"unspecified\") {\n continue;\n }\n\n await locals.admin.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 }\n\n const defaultPaymentMethod =\n customer.invoice_settings?.default_payment_method;\n\n if (defaultPaymentMethod) {\n try {\n await locals.admin.collection(\"stripe_customers\").update(customer.id, {\n default_payment_method: defaultPaymentMethod,\n });\n } catch {}\n }\n};\n", uu = "users", du = "stripe_customers", fu = "stripe_payment_methods", pu = {
|
|
4897
5008
|
name: "stripe_products",
|
|
4898
5009
|
type: "base",
|
|
4899
5010
|
fields: [
|
|
@@ -4932,7 +5043,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
4932
5043
|
type: "autodate"
|
|
4933
5044
|
}
|
|
4934
5045
|
]
|
|
4935
|
-
},
|
|
5046
|
+
}, mu = {
|
|
4936
5047
|
name: "stripe_prices",
|
|
4937
5048
|
type: "base",
|
|
4938
5049
|
fields: [
|
|
@@ -4991,8 +5102,8 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
4991
5102
|
type: "autodate"
|
|
4992
5103
|
}
|
|
4993
5104
|
]
|
|
4994
|
-
},
|
|
4995
|
-
name:
|
|
5105
|
+
}, hu = {
|
|
5106
|
+
name: du,
|
|
4996
5107
|
type: "base",
|
|
4997
5108
|
fields: [
|
|
4998
5109
|
{
|
|
@@ -5003,7 +5114,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5003
5114
|
type: "text"
|
|
5004
5115
|
},
|
|
5005
5116
|
{
|
|
5006
|
-
collectionId:
|
|
5117
|
+
collectionId: uu,
|
|
5007
5118
|
maxSelect: 1,
|
|
5008
5119
|
minSelect: 0,
|
|
5009
5120
|
name: "user",
|
|
@@ -5011,7 +5122,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5011
5122
|
type: "relation"
|
|
5012
5123
|
},
|
|
5013
5124
|
{
|
|
5014
|
-
collectionId:
|
|
5125
|
+
collectionId: fu,
|
|
5015
5126
|
maxSelect: 1,
|
|
5016
5127
|
minSelect: 0,
|
|
5017
5128
|
name: "default_payment_method",
|
|
@@ -5031,8 +5142,8 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5031
5142
|
type: "autodate"
|
|
5032
5143
|
}
|
|
5033
5144
|
]
|
|
5034
|
-
},
|
|
5035
|
-
name:
|
|
5145
|
+
}, gu = {
|
|
5146
|
+
name: fu,
|
|
5036
5147
|
type: "base",
|
|
5037
5148
|
fields: [
|
|
5038
5149
|
{
|
|
@@ -5063,7 +5174,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5063
5174
|
type: "number"
|
|
5064
5175
|
},
|
|
5065
5176
|
{
|
|
5066
|
-
collectionId:
|
|
5177
|
+
collectionId: du,
|
|
5067
5178
|
maxSelect: 1,
|
|
5068
5179
|
minSelect: 0,
|
|
5069
5180
|
name: "customer",
|
|
@@ -5084,7 +5195,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5084
5195
|
type: "autodate"
|
|
5085
5196
|
}
|
|
5086
5197
|
]
|
|
5087
|
-
},
|
|
5198
|
+
}, _u = {
|
|
5088
5199
|
name: "transactions",
|
|
5089
5200
|
type: "base",
|
|
5090
5201
|
fields: [
|
|
@@ -5139,7 +5250,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5139
5250
|
type: "text"
|
|
5140
5251
|
},
|
|
5141
5252
|
{
|
|
5142
|
-
collectionId:
|
|
5253
|
+
collectionId: uu,
|
|
5143
5254
|
maxSelect: 1,
|
|
5144
5255
|
minSelect: 0,
|
|
5145
5256
|
name: "user",
|
|
@@ -5152,20 +5263,20 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5152
5263
|
type: "url"
|
|
5153
5264
|
}
|
|
5154
5265
|
]
|
|
5155
|
-
},
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
],
|
|
5266
|
+
}, vu = [pu, mu], yu = [
|
|
5267
|
+
hu,
|
|
5268
|
+
gu,
|
|
5269
|
+
_u
|
|
5270
|
+
], bu, xu = /* @__PURE__ */ Object.assign({
|
|
5160
5271
|
"./preview-modifies/src/lib/components/nav-user.svelte": m,
|
|
5161
|
-
"./preview-modifies/src/routes/(public)/signup/+page.server.ts":
|
|
5162
|
-
}),
|
|
5163
|
-
function
|
|
5164
|
-
return t(
|
|
5165
|
-
}
|
|
5166
|
-
async function
|
|
5167
|
-
let t = e.features.auth, n = Object.entries(
|
|
5168
|
-
let n = o(e,
|
|
5272
|
+
"./preview-modifies/src/routes/(public)/signup/+page.server.ts": lu
|
|
5273
|
+
}), Su = "./preview-modifies/", Cu = "price_preview_placeholder";
|
|
5274
|
+
function wu(e) {
|
|
5275
|
+
return t(bu ||= l(["\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);
|
|
5276
|
+
}
|
|
5277
|
+
async function Tu(e) {
|
|
5278
|
+
let t = e.features.auth, n = Object.entries(xu).map(([e, t]) => {
|
|
5279
|
+
let n = o(e, Su);
|
|
5169
5280
|
return {
|
|
5170
5281
|
path: n,
|
|
5171
5282
|
language: r(n),
|
|
@@ -5175,9 +5286,9 @@ async function lu(e) {
|
|
|
5175
5286
|
}).sort((e, t) => e.path.localeCompare(t.path)), i = {
|
|
5176
5287
|
path: "src/routes/(public)/payment/+page.svelte",
|
|
5177
5288
|
language: "svelte",
|
|
5178
|
-
content:
|
|
5289
|
+
content: wu(Cu),
|
|
5179
5290
|
status: "success"
|
|
5180
|
-
}, a = [...
|
|
5291
|
+
}, a = [...vu, ...t ? yu : []];
|
|
5181
5292
|
return {
|
|
5182
5293
|
creates: [i],
|
|
5183
5294
|
modifies: n,
|
|
@@ -5191,18 +5302,18 @@ async function lu(e) {
|
|
|
5191
5302
|
}
|
|
5192
5303
|
//#endregion
|
|
5193
5304
|
//#region src/patterns/enable/payments/index.ts
|
|
5194
|
-
var
|
|
5195
|
-
async function
|
|
5196
|
-
let t = await
|
|
5197
|
-
if (e.env === "preview") return y(n([t, await
|
|
5198
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
5305
|
+
var Eu = "enable-payments", Du = "1.0.0", Ou = "src/patterns/enable/payments", ku = "/enable/payments";
|
|
5306
|
+
async function Au(e) {
|
|
5307
|
+
let t = await cu(e);
|
|
5308
|
+
if (e.env === "preview") return y(n([t, await Tu(e)]));
|
|
5309
|
+
let { generate: r } = await import("./chunks/generate.runtime-DQLmiRz6.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5199
5310
|
return a(await y(n([t, i])), e);
|
|
5200
5311
|
}
|
|
5201
|
-
var
|
|
5202
|
-
version:
|
|
5203
|
-
slug:
|
|
5204
|
-
source:
|
|
5205
|
-
docs:
|
|
5312
|
+
var ju = {
|
|
5313
|
+
version: Du,
|
|
5314
|
+
slug: Eu,
|
|
5315
|
+
source: Ou,
|
|
5316
|
+
docs: ku,
|
|
5206
5317
|
plan: "pro",
|
|
5207
5318
|
title: "Enable payments",
|
|
5208
5319
|
summary: "Adds Stripe payments with product/price sync, checkout flow, and optional saved payment methods when auth is enabled.",
|
|
@@ -5210,6 +5321,7 @@ var hu = {
|
|
|
5210
5321
|
auth: !1,
|
|
5211
5322
|
api: !1,
|
|
5212
5323
|
apiKeys: !1,
|
|
5324
|
+
backend: !0,
|
|
5213
5325
|
i18n: !1,
|
|
5214
5326
|
teams: !1,
|
|
5215
5327
|
payments: !1,
|
|
@@ -5233,14 +5345,14 @@ var hu = {
|
|
|
5233
5345
|
examples: [],
|
|
5234
5346
|
tests: 0,
|
|
5235
5347
|
baseline: "velastack",
|
|
5236
|
-
generate:
|
|
5237
|
-
},
|
|
5238
|
-
"./creates/src/routes/api/stripe/sync/subscriptions/+server.ts":
|
|
5239
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts":
|
|
5240
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts":
|
|
5241
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts":
|
|
5242
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts":
|
|
5243
|
-
}),
|
|
5348
|
+
generate: Au
|
|
5349
|
+
}, Mu = "import { json } from \"@sveltejs/kit\";\nimport stripe from \"$lib/stripe\";\nimport { env } from \"$env/dynamic/private\";\nimport { subscriptionRecordFields } from \"../../../../webhooks/stripe/handlers/subscription/shared\";\n\nexport const POST = async ({ request, locals }) => {\n const authHeader = request.headers.get(\"Authorization\");\n if (authHeader !== `Bearer ${env.INTERNAL_JOB_SECRET}`) {\n return json({ error: \"Unauthorized\" }, { status: 401 });\n }\n\n const subscriptions = await stripe.subscriptions.list({\n status: \"all\",\n limit: 100,\n });\n\n for (const subscription of subscriptions.data) {\n const fields = subscriptionRecordFields(subscription);\n if (!fields) continue;\n\n let customer;\n try {\n customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(fields.customer);\n } catch {\n console.log(\n `Skipping subscription ${subscription.id}: customer ${fields.customer} not found locally`,\n );\n continue;\n }\n\n try {\n await locals.admin\n .collection(\"stripe_subscriptions\")\n .update(subscription.id, fields);\n } catch {\n await locals.admin.collection(\"stripe_subscriptions\").create({\n ...fields,\n user: customer.user,\n });\n }\n }\n\n console.log(\"Subscriptions synced\");\n return json({ message: \"Subscriptions synced\" });\n};\n", Nu = "import Stripe from \"stripe\";\nimport { subscriptionRecordFields } from \"./shared\";\n\n/**\n * Handles customer.subscription.created event\n */\nexport async function handleSubscriptionCreated(\n subscription: Stripe.Subscription,\n locals: App.Locals,\n) {\n const fields = subscriptionRecordFields(subscription);\n if (!fields) return;\n\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(fields.customer);\n\n await locals.admin.collection(\"stripe_subscriptions\").create({\n ...fields,\n user: customer.user,\n });\n}\n", Pu = "import Stripe from \"stripe\";\nimport { subscriptionRecordFields } from \"./shared\";\n\n/**\n * Handles customer.subscription.deleted event\n */\nexport async function handleSubscriptionDeleted(\n subscription: Stripe.Subscription,\n locals: App.Locals,\n) {\n const fields = subscriptionRecordFields(subscription);\n if (!fields) return;\n\n try {\n await locals.admin\n .collection(\"stripe_subscriptions\")\n .update(subscription.id, {\n ...fields,\n status: \"canceled\",\n canceled_at: fields.canceled_at ?? new Date().toISOString(),\n });\n } catch {\n // Row may not exist; ignore.\n console.log(`Subscription ${subscription.id} not found for deletion`);\n }\n}\n", Fu = "import Stripe from \"stripe\";\n\nfunction unixToIso(unix: number | null | undefined): string | null {\n if (!unix) return null;\n return new Date(unix * 1000).toISOString();\n}\n\n/**\n * Extracts the subset of Stripe.Subscription fields that map to a\n * stripe_subscriptions row. Returns null if the subscription has no\n * price (shouldn't happen, but guard).\n *\n * `current_period_start`/`current_period_end` live on the subscription item\n * in API versions >= 2025-03-31 — read from there with a fallback to the\n * subscription-level field for older events.\n */\nexport function subscriptionRecordFields(subscription: Stripe.Subscription) {\n const item = subscription.items.data[0];\n const priceId = item?.price.id;\n if (!priceId) {\n console.error(`Subscription ${subscription.id} has no price`);\n return null;\n }\n\n const customerId =\n typeof subscription.customer === \"string\"\n ? subscription.customer\n : subscription.customer.id;\n\n const itemPeriodStart = (item as unknown as { current_period_start?: number })\n .current_period_start;\n const itemPeriodEnd = (item as unknown as { current_period_end?: number })\n .current_period_end;\n const subPeriodStart = (\n subscription as unknown as { current_period_start?: number }\n ).current_period_start;\n const subPeriodEnd = (\n subscription as unknown as { current_period_end?: number }\n ).current_period_end;\n\n return {\n id: subscription.id,\n customer: customerId,\n price: priceId,\n status: subscription.status,\n current_period_start: unixToIso(itemPeriodStart ?? subPeriodStart),\n current_period_end: unixToIso(itemPeriodEnd ?? subPeriodEnd),\n cancel_at_period_end: subscription.cancel_at_period_end,\n canceled_at: unixToIso(subscription.canceled_at),\n };\n}\n", Iu = "import Stripe from \"stripe\";\nimport { subscriptionRecordFields } from \"./shared\";\n\n/**\n * Handles customer.subscription.updated event\n */\nexport async function handleSubscriptionUpdated(\n subscription: Stripe.Subscription,\n locals: App.Locals,\n) {\n const fields = subscriptionRecordFields(subscription);\n if (!fields) return;\n\n try {\n await locals.admin\n .collection(\"stripe_subscriptions\")\n .update(subscription.id, fields);\n } catch {\n // Row may not exist if the created event was missed; upsert instead.\n const customer = await locals.admin\n .collection(\"stripe_customers\")\n .getOne(fields.customer);\n\n await locals.admin.collection(\"stripe_subscriptions\").create({\n ...fields,\n user: customer.user,\n });\n }\n}\n", Lu = /* @__PURE__ */ Object.assign({
|
|
5350
|
+
"./creates/src/routes/api/stripe/sync/subscriptions/+server.ts": Mu,
|
|
5351
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": Nu,
|
|
5352
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": Pu,
|
|
5353
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": Fu,
|
|
5354
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": Iu
|
|
5355
|
+
}), Ru = "./creates/", zu = {
|
|
5244
5356
|
name: "stripe_subscriptions",
|
|
5245
5357
|
type: "base",
|
|
5246
5358
|
fields: [
|
|
@@ -5315,10 +5427,10 @@ var hu = {
|
|
|
5315
5427
|
}
|
|
5316
5428
|
]
|
|
5317
5429
|
};
|
|
5318
|
-
async function
|
|
5430
|
+
async function Bu(e) {
|
|
5319
5431
|
return {
|
|
5320
|
-
creates: Object.entries(
|
|
5321
|
-
let n = o(e,
|
|
5432
|
+
creates: Object.entries(Lu).map(([e, t]) => {
|
|
5433
|
+
let n = o(e, Ru);
|
|
5322
5434
|
return {
|
|
5323
5435
|
path: n,
|
|
5324
5436
|
language: r(n),
|
|
@@ -5330,14 +5442,14 @@ async function wu(e) {
|
|
|
5330
5442
|
deletes: [],
|
|
5331
5443
|
components: [],
|
|
5332
5444
|
packages: [],
|
|
5333
|
-
collections: [
|
|
5445
|
+
collections: [zu],
|
|
5334
5446
|
collectionPatches: [],
|
|
5335
5447
|
collectionDrops: []
|
|
5336
5448
|
};
|
|
5337
5449
|
}
|
|
5338
5450
|
//#endregion
|
|
5339
5451
|
//#region src/patterns/enable/subscriptions/generate.preview.ts
|
|
5340
|
-
var
|
|
5452
|
+
var Vu = /* @__PURE__ */ Object.assign({
|
|
5341
5453
|
"./preview-modifies/data/hooks/stripe.pb.js": ee,
|
|
5342
5454
|
"./preview-modifies/src/lib/components/app-sidebar.svelte": re,
|
|
5343
5455
|
"./preview-modifies/src/lib/components/nav-user.svelte": te,
|
|
@@ -5346,12 +5458,12 @@ var Tu = /* @__PURE__ */ Object.assign({
|
|
|
5346
5458
|
"./preview-modifies/src/routes/(app)/billing/+page.server.ts": ne,
|
|
5347
5459
|
"./preview-modifies/src/routes/(app)/billing/+page.svelte": _,
|
|
5348
5460
|
"./preview-modifies/src/routes/webhooks/stripe/+server.ts": ie
|
|
5349
|
-
}),
|
|
5350
|
-
async function
|
|
5461
|
+
}), Hu = "./preview-modifies/";
|
|
5462
|
+
async function Uu(e) {
|
|
5351
5463
|
return {
|
|
5352
5464
|
creates: [],
|
|
5353
|
-
modifies: Object.entries(
|
|
5354
|
-
let n = o(e,
|
|
5465
|
+
modifies: Object.entries(Vu).map(([e, t]) => {
|
|
5466
|
+
let n = o(e, Hu);
|
|
5355
5467
|
return {
|
|
5356
5468
|
path: n,
|
|
5357
5469
|
language: r(n),
|
|
@@ -5369,21 +5481,21 @@ async function Du(e) {
|
|
|
5369
5481
|
}
|
|
5370
5482
|
//#endregion
|
|
5371
5483
|
//#region src/patterns/enable/subscriptions/index.ts
|
|
5372
|
-
var
|
|
5373
|
-
async function
|
|
5374
|
-
let t = await
|
|
5375
|
-
if (e.env === "preview") return y(n([t, await
|
|
5376
|
-
let { createCollections: r } = await import("./chunks/collections-
|
|
5484
|
+
var Wu = "enable-subscriptions", Gu = "1.0.0", Ku = "src/patterns/enable/subscriptions", qu = "/enable/subscriptions";
|
|
5485
|
+
async function Ju(e) {
|
|
5486
|
+
let t = await Bu(e);
|
|
5487
|
+
if (e.env === "preview") return y(n([t, await Uu(e)]));
|
|
5488
|
+
let { createCollections: r } = await import("./chunks/collections-BwO27pJg.js"), i = await r(t.collections, e), { generate: a } = await import("./chunks/generate.runtime-Cudp67b-.js"), o = await a(e), { writeResult: s } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5377
5489
|
return s(await y(n([{
|
|
5378
5490
|
...t,
|
|
5379
5491
|
creates: [...t.creates, ...i]
|
|
5380
5492
|
}, o])), e);
|
|
5381
5493
|
}
|
|
5382
|
-
var
|
|
5383
|
-
version:
|
|
5384
|
-
slug:
|
|
5385
|
-
source:
|
|
5386
|
-
docs:
|
|
5494
|
+
var Yu = {
|
|
5495
|
+
version: Gu,
|
|
5496
|
+
slug: Wu,
|
|
5497
|
+
source: Ku,
|
|
5498
|
+
docs: qu,
|
|
5387
5499
|
plan: "pro",
|
|
5388
5500
|
title: "Enable subscriptions",
|
|
5389
5501
|
summary: "Adds Stripe subscription billing with plan selection, cancel/resume, and webhook-synced subscription state. Requires enable-payments.",
|
|
@@ -5391,6 +5503,7 @@ var Nu = {
|
|
|
5391
5503
|
auth: !0,
|
|
5392
5504
|
api: !1,
|
|
5393
5505
|
apiKeys: !1,
|
|
5506
|
+
backend: !0,
|
|
5394
5507
|
i18n: !1,
|
|
5395
5508
|
teams: !1,
|
|
5396
5509
|
payments: !0,
|
|
@@ -5415,52 +5528,52 @@ var Nu = {
|
|
|
5415
5528
|
examples: [],
|
|
5416
5529
|
tests: 0,
|
|
5417
5530
|
baseline: "velastack",
|
|
5418
|
-
generate:
|
|
5419
|
-
}, Pu = "<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '$lib/components/ui/sidebar/index.js';\n import { useSidebar } from '$lib/components/ui/sidebar/index.js';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import UsersIcon from '@lucide/svelte/icons/users';\n import { page } from '$app/state';\n import { goto, invalidate } from '$app/navigation';\n\n let { teams, children }: { teams: { id: string; name: string }[] } & { children: Snippet } =\n $props();\n\n const switchTeam = async (teamId: string) => {\n await goto(`/teams/switch/${teamId}?redirect=${encodeURIComponent(page.url.pathname)}`);\n invalidate('app:team');\n };\n\n const sidebar = useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n {...props}\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n >\n {@render children?.()}\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n align=\"start\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"text-muted-foreground text-xs\">Teams</DropdownMenu.Label>\n {#each teams as team (team.name)}\n <DropdownMenu.Item onSelect={() => switchTeam(team.id)} class=\"gap-2 p-2\">\n <div class=\"flex size-6 items-center justify-center rounded-md border\">\n <UsersIcon class=\"size-3.5 shrink-0\" />\n </div>\n {team.name}\n </DropdownMenu.Item>\n {/each}\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"gap-2 p-2\">\n <div class=\"flex size-6 items-center justify-center rounded-md border bg-transparent\">\n <PlusIcon class=\"size-4\" />\n </div>\n <a href=\"/teams/new\" class=\"text-muted-foreground font-medium\">Add team</a>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", Fu = "import { z } from \"zod\";\n\nexport const teamSchema = z.object({\n name: z.string(),\n});\n", Iu = "import { z } from \"zod\";\n\nexport const teamInviteSchema = z.object({\n email: z.email(),\n});\n", Lu = "import { z } from \"zod\";\n\nexport const teamRoleSchema = z.object({\n role: z.enum([\"owner\", \"admin\", \"member\"]),\n});\n", Ru = "<script lang=\"ts\">\n import RootLayout from '../../../(public)/root-layout.svelte';\n\n let { data, children } = $props();\n<\/script>\n\n<RootLayout {data}>\n {@render children?.()}\n</RootLayout>\n", zu = "import { error } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ params, locals }) => {\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n return { invite };\n};\n\nexport const actions = {\n default: async ({ locals, params, cookies }) => {\n const user = locals.pb.authStore.record!;\n\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(params.id);\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n await locals.admin.collection(\"team_invites\").delete(invite.id);\n\n redirect(\n 303,\n `/dashboard`,\n { type: \"toast\", message: \"Joined team\" },\n cookies,\n );\n },\n};\n", Bu = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src=\"/favicon.svg\" alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\"\n >{data.invite.expand?.team.name} invited you to join their team</Card.Title\n >\n <Card.Description>Accept the invite to join the team</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Button type=\"submit\" class=\"w-full\">Accept Invite</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Vu = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Invitation'\n });\n\n return { ...data, pageMetaTags };\n};\n", Hu = "<script lang=\"ts\">\n import RootLayout from '../../../(public)/root-layout.svelte';\n\n let { data, children } = $props();\n<\/script>\n\n<RootLayout {data}>\n {@render children?.()}\n</RootLayout>\n", Uu = "import { error } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ params, locals }) => {\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invite_links\").getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite link not found\" });\n }\n\n return { invite };\n};\n\nexport const actions = {\n default: async ({ locals, params, cookies }) => {\n const user = locals.pb.authStore.record!;\n\n let invite;\n try {\n invite = await locals.pb\n .collection(\"team_invite_links\")\n .getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite link not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n redirect(\n 303,\n `/dashboard`,\n { type: \"toast\", message: \"Joined team\" },\n cookies,\n );\n },\n};\n", Wu = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src=\"/favicon.svg\" alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\"\n >{data.invite.expand?.team.name} invited you to join their team</Card.Title\n >\n <Card.Description>Accept the invite to join the team</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Button type=\"submit\" class=\"w-full\">Accept Invite</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Gu = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Join team'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ku = "export const load = async ({ locals, parent }) => {\n const { user, breadcrumbs } = await parent();\n\n const ownedTeams = await locals.pb.collection(\"teams\").getFullList({\n filter: locals.pb.filter(\"owner = {:owner}\", { owner: user.id }),\n expand: \"team_users_via_team\",\n });\n\n const memberships = await locals.pb\n .collection(\"team_memberships\")\n .getFullList({\n filter: locals.pb.filter(\"user = {:user}\", { user: user.id }),\n expand: \"team\",\n });\n\n const pendingInvites = await locals.pb\n .collection(\"team_invites\")\n .getFullList({\n filter: locals.pb.filter(\"email = {:email}\", { email: user.email }),\n expand: \"team\",\n });\n\n const teams = [\n ...ownedTeams.map((team) => ({\n type: \"team\" as const,\n id: team.id,\n name: team.name,\n role: \"owner\" as const,\n members: team.expand?.team_users_via_team?.length || 0,\n })),\n ...memberships\n .filter((membership) => membership.expand?.team.owner !== membership.user)\n .map((membership) => ({\n type: \"membership\" as const,\n id: membership.team,\n name: membership.expand?.team.name,\n role: membership.role,\n })),\n ...pendingInvites.map((invite) => ({\n type: \"invite\" as const,\n id: invite.team,\n name: invite.expand?.team.name,\n role: null,\n invite_id: invite.id,\n })),\n ];\n\n return {\n teams,\n breadcrumbs: [...breadcrumbs, { title: \"Teams\", url: \"/teams\" }],\n };\n};\n", qu = "<script lang=\"ts\">\n import * as Card from '$lib/components/ui/card';\n import { Button } from '$lib/components/ui/button';\n import UserIcon from '@lucide/svelte/icons/user';\n import UserPlusIcon from '@lucide/svelte/icons/user-plus';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import * as Avatar from '$lib/components/ui/avatar';\n\n const roleLabels = {\n owner: 'Owner',\n admin: 'Admin',\n member: 'Member'\n };\n\n let { data, children } = $props();\n<\/script>\n\n<section data-slot=\"content\">\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Management</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Organize your workspace with teams. Collaborate with members, manage permissions, and\n streamline your workflow.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Your Teams</Card.Title>\n <Card.Description>Manage and view your team memberships</Card.Description>\n </Card.Header>\n <Card.Content class=\"space-y-4\">\n {#if data.teams && data.teams.length > 0}\n <div class=\"grid gap-3\">\n {#each data.teams as team}\n <div\n class=\"flex items-center justify-between p-4 border rounded-lg hover:bg-muted/50 transition-colors\"\n >\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-10 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-primary text-primary-foreground font-medium\"\n >\n {team.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n {#if team.role === 'owner' || team.role === 'admin'}\n <a\n href=\"/teams/{team.id}\"\n class=\"font-medium text-foreground hover:text-primary transition-colors\"\n >\n {team.name}\n </a>\n {:else}\n <span class=\"font-medium text-foreground\">\n {team.name}\n </span>\n {/if}\n <p class=\"text-sm text-muted-foreground\">\n {team.role ? roleLabels[team.role] : 'Pending'}\n </p>\n </div>\n </div>\n {#if team.type === 'team'}\n <div class=\"flex items-center space-x-2 text-sm text-muted-foreground\">\n <UserIcon class=\"w-4 h-4\" />\n <span class=\"font-medium\">\n {team.members} member{team.members !== 1 ? 's' : ''}\n </span>\n </div>\n {:else if team.type === 'membership'}\n <div class=\"flex items-center\">\n <form method=\"POST\" action=\"?/leaveTeam\">\n <input type=\"hidden\" name=\"team_id\" value={team.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">\n <LogOutIcon class=\"w-4 h-4\" />\n Leave team\n </Button>\n </form>\n </div>\n {:else if team.type === 'invite'}\n <div class=\"flex items-center\">\n <form method=\"POST\" action=\"?/acceptInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={team.invite_id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">\n <UserPlusIcon class=\"w-4 h-4\" />\n Accept invitation\n </Button>\n </form>\n </div>\n {/if}\n </div>\n {/each}\n </div>\n {:else}\n <div class=\"text-center py-8\">\n <div\n class=\"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4\"\n >\n <UserIcon class=\"w-6 h-6 text-muted-foreground\" />\n </div>\n <h3 class=\"text-lg font-medium text-foreground mb-2\">No teams yet</h3>\n <p class=\"text-muted-foreground mb-4\">Get started by creating your first team</p>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {data.teams?.length || 0} team{(data.teams?.length || 0) !== 1 ? 's' : ''}\n </div>\n <Button size=\"sm\" href=\"/teams/new\" class=\"ml-auto\">Create new team</Button>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n</section>\n\n{@render children?.()}\n", Ju = "import { error, fail } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const actions = {\n acceptInvite: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await request.formData();\n const inviteId = form.get(\"invite_id\") as string;\n if (!inviteId) {\n return fail(400, { error: \"Invite ID is required\" });\n }\n\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(inviteId);\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n await locals.admin.collection(\"team_invites\").delete(invite.id);\n\n redirect(303, `/teams`, { type: \"toast\", message: \"Joined team\" }, cookies);\n },\n leaveTeam: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await request.formData();\n const teamId = form.get(\"team_id\") as string;\n if (!teamId) {\n return fail(400, { error: \"Team ID is required\" });\n }\n\n let teamMembership;\n try {\n teamMembership = await locals.pb\n .collection(\"team_memberships\")\n .getFirstListItem(\n locals.pb.filter(\"team = {:team} && user = {:user}\", {\n team: teamId,\n user: user.id,\n }),\n );\n } catch {\n return error(404, { message: \"Team not found\" });\n }\n\n if (teamMembership.role === \"owner\") {\n return error(400, { message: \"You cannot leave a team you own\" });\n }\n\n await locals.pb.collection(\"team_memberships\").delete(teamMembership.id);\n\n redirect(303, `/teams`, { type: \"toast\", message: \"Left team\" }, cookies);\n },\n};\n", Yu = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Teams'\n });\n\n return { ...data, pageMetaTags };\n};\n", Xu = "import { redirect } from \"@sveltejs/kit\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"$lib/schemas/team\";\n\nexport const load = async ({ params, locals, parent }) => {\n const { user, breadcrumbs } = await parent();\n const { id } = params;\n\n let team;\n try {\n team = await locals.pb.collection(\"teams\").getOne(id, {\n expand: \"team_invite_links_via_team\",\n });\n } catch {\n redirect(303, \"/teams\");\n }\n\n let userMembership;\n try {\n userMembership = await locals.pb.collection(\"team_users\").getFirstListItem(\n locals.pb.filter(\n 'team = {:team} && id = {:user} && (role = \"admin\" || role = \"owner\")',\n {\n team: id,\n user: user.id,\n },\n ),\n );\n } catch (error) {\n redirect(303, \"/teams\");\n }\n\n const role = userMembership.role;\n\n // Get all team members with their roles\n const teamMembers = await locals.pb.collection(\"team_users\").getFullList({\n filter: locals.pb.filter(\"team = {:team}\", { team: id }),\n });\n\n // Get pending invites for this team\n const pendingInvites = await locals.pb\n .collection(\"team_invites\")\n .getFullList({\n filter: locals.pb.filter(\"team = {:team}\", { team: id }),\n });\n\n const form = await superValidate(team, zod4(teamSchema));\n\n return {\n team,\n role,\n teamMembers,\n pendingInvites,\n inviteLink: team.expand?.team_invite_links_via_team,\n form,\n breadcrumbs: [\n ...breadcrumbs,\n { title: \"Teams\", url: \"/teams\" },\n { title: team.name, url: `/teams/${id}` },\n ],\n };\n};\n", Zu = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Card from '$lib/components/ui/card';\n import { Button, buttonVariants } from '$lib/components/ui/button';\n import CrownIcon from '@lucide/svelte/icons/crown';\n import ShieldIcon from '@lucide/svelte/icons/shield';\n import UserCheckIcon from '@lucide/svelte/icons/user-check';\n import UserPlusIcon from '@lucide/svelte/icons/user-plus';\n import CopyIcon from '@lucide/svelte/icons/copy';\n import MailIcon from '@lucide/svelte/icons/mail';\n import ClockIcon from '@lucide/svelte/icons/clock';\n import * as Avatar from '$lib/components/ui/avatar';\n import { Badge } from '$lib/components/ui/badge';\n import * as Table from '$lib/components/ui/table';\n import { getAuthorization } from './authorization';\n import { toast } from 'svelte-sonner';\n import * as AlertDialog from '$lib/components/ui/alert-dialog';\n import * as Form from '$lib/components/ui/form';\n import TrashIcon from '@lucide/svelte/icons/trash-2';\n import { Input } from '$lib/components/ui/input';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '$lib/schemas/team';\n\n let { data, children } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamSchema),\n warnings: {\n duplicateId: false\n }\n }\n );\n\n const { form: formData } = form;\n\n function getRoleIcon(role: 'owner' | 'admin' | 'member') {\n switch (role) {\n case 'owner':\n return CrownIcon;\n case 'admin':\n return ShieldIcon;\n case 'member':\n return UserCheckIcon;\n }\n }\n\n function handleCopyLink(inviteStr: string) {\n const link = `${data.meta.appURL}/${inviteStr}`;\n navigator.clipboard.writeText(link);\n toast.success('Link copied to clipboard');\n }\n<\/script>\n\n<section data-slot=\"content\">\n {#if data.role === 'owner'}\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Settings</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Update your team name and manage basic team settings.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <form method=\"POST\" action=\"?/updateTeam\" class=\"space-y-4\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Team Name</Card.Title>\n <Card.Description>Update your team's display name</Card.Description>\n </Card.Header>\n <Card.Content>\n <div class=\"space-y-2\">\n <Form.Field {form} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Input {...props} type=\"text\" bind:value={$formData.name} required />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </Card.Content>\n <Card.Footer class=\"flex justify-end pt-4 border-t\">\n <Button type=\"submit\" class=\"flex items-center\" size=\"sm\">Save changes</Button>\n </Card.Footer>\n </form>\n </Card.Root>\n </div>\n </div>\n {/if}\n\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Members</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Manage team members and their roles. Control access permissions and organize your team\n effectively.\n </p>\n <div class=\"mt-4 space-y-2\">\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Owner - Full team control</span>\n </div>\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Admin - Manage members</span>\n </div>\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Member - Team access</span>\n </div>\n </div>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">{data.team.name} Members</Card.Title>\n <Card.Description>Manage team members and their roles</Card.Description>\n </Card.Header>\n <Card.Content>\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.Head>Member</Table.Head>\n <Table.Head>Role</Table.Head>\n <Table.Head></Table.Head>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n <!-- Team Members -->\n {#each data.teamMembers as member}\n {@const { canRemove, canChangeRole } = getAuthorization({\n user: data.user,\n role: data.role,\n member\n })}\n <Table.Row>\n <Table.Cell>\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-primary text-primary-foreground font-medium\"\n >\n {member.name?.charAt(0).toUpperCase() ||\n member.email.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {member.name || member.email}\n </div>\n <div class=\"text-sm text-muted-foreground\">\n {member.email}\n </div>\n </div>\n </div>\n </Table.Cell>\n <Table.Cell>\n <Badge variant=\"outline\" class=\"flex items-center space-x-1 w-fit\">\n {@const Icon = getRoleIcon(member.role)}\n <Icon class=\"w-3 h-3\" />\n <span class=\"capitalize\">{member.role}</span>\n </Badge>\n </Table.Cell>\n <Table.Cell>\n <div class=\"flex space-x-2 justify-end\">\n {#if canChangeRole}\n <Button\n href=\"/teams/{data.team.id}/member/{member.membership_id}\"\n variant=\"outline\"\n size=\"sm\"\n data-sveltekit-noscroll\n >\n Change Role\n </Button>\n {/if}\n {#if canRemove}\n <form method=\"POST\" action=\"?/removeMember\">\n <input type=\"hidden\" name=\"member_id\" value={member.membership_id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Remove</Button>\n </form>\n {/if}\n </div>\n </Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n </Table.Root>\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {data.teamMembers?.length || 0} member{(data.teamMembers?.length || 0) !== 1 ? 's' : ''}\n total\n </div>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Invites</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Invitations that have been sent but not yet accepted. You can resend or cancel pending\n invites.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Invitations</Card.Title>\n <Card.Description>Manage pending team invitations</Card.Description>\n </Card.Header>\n <Card.Content>\n {#if data.pendingInvites && data.pendingInvites.length > 0}\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.Head>Email</Table.Head>\n <Table.Head>Status</Table.Head>\n <Table.Head></Table.Head>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n {#each data.pendingInvites as invite}\n <Table.Row>\n <Table.Cell>\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-muted text-muted-foreground font-medium\"\n >\n <MailIcon class=\"w-4 h-4\" />\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {invite.email}\n </div>\n <div class=\"text-sm text-muted-foreground\">Pending invitation</div>\n </div>\n </div>\n </Table.Cell>\n <Table.Cell>\n <Badge variant=\"outline\" class=\"flex items-center space-x-1 w-fit\">\n <ClockIcon class=\"w-3 h-3\" />\n <span>Pending</span>\n </Badge>\n </Table.Cell>\n <Table.Cell>\n <div class=\"flex space-x-2 justify-end\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => handleCopyLink(`invite/${invite.id}`)}>Copy link</Button\n >\n <form method=\"POST\" action=\"?/resendInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={invite.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Resend</Button>\n </form>\n <form method=\"POST\" action=\"?/cancelInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={invite.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Cancel</Button>\n </form>\n </div>\n </Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n </Table.Root>\n {:else}\n <div class=\"text-center py-8\">\n <div\n class=\"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4\"\n >\n <MailIcon class=\"w-6 h-6 text-muted-foreground\" />\n </div>\n <h3 class=\"text-lg font-medium text-foreground mb-2\">No pending invites</h3>\n <p class=\"text-muted-foreground mb-4\">\n All invitations have been accepted or there are no pending invites\n </p>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {#if data.inviteLink}\n <div class=\"text-sm text-muted-foreground\">\n {data.meta.appURL}/join/{data.inviteLink.id}\n </div>\n {/if}\n </div>\n <div class=\"flex items-center space-x-2\">\n {#if data.inviteLink}\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => handleCopyLink(`join/${data.inviteLink.id}`)}\n >\n <CopyIcon class=\"w-4 h-4\" />\n Copy invite link\n </Button>\n {/if}\n\n <Button\n size=\"sm\"\n href=\"/teams/{data.team.id}/invite\"\n class=\"ml-auto\"\n data-sveltekit-noscroll\n >\n <UserPlusIcon class=\"w-4 h-4\" />\n Invite member\n </Button>\n </div>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n\n {#if data.role === 'owner'}\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Danger Zone</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Permanently delete this team and all associated data. This action cannot be undone.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Delete Team</Card.Title>\n <Card.Description>\n Remove this team and all associated data permanently\n </Card.Description>\n </Card.Header>\n <Card.Content>\n <div\n class=\"flex items-center space-x-3 p-4 bg-destructive/10 rounded-lg border border-destructive/20\"\n >\n <div class=\"flex-shrink-0\">\n <TrashIcon class=\"w-5 h-5 text-destructive\" />\n </div>\n <div class=\"flex-1\">\n <p class=\"text-sm font-medium text-destructive\">Delete this team</p>\n <p class=\"text-sm text-muted-foreground\">\n This will permanently delete the team, remove all members, and delete all\n associated data.\n </p>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"flex justify-end pt-4 border-t\">\n <AlertDialog.Root>\n <AlertDialog.Trigger class={buttonVariants({ variant: 'destructive', size: 'sm' })}>\n <TrashIcon class=\"w-4 h-4\" />\n Delete team\n </AlertDialog.Trigger>\n <AlertDialog.Content>\n <AlertDialog.Header>\n <AlertDialog.Title>Delete Team</AlertDialog.Title>\n <AlertDialog.Description>\n Are you sure you want to delete \"{data.team.name}\"? This action cannot be\n undone. This will permanently delete the team, remove all members, and delete\n all associated data.\n </AlertDialog.Description>\n </AlertDialog.Header>\n <AlertDialog.Footer>\n <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>\n <form method=\"POST\" action=\"?/deleteTeam\" class=\"inline\">\n <AlertDialog.Action>\n <TrashIcon class=\"w-4 h-4\" />\n Delete team\n </AlertDialog.Action>\n </form>\n </AlertDialog.Footer>\n </AlertDialog.Content>\n </AlertDialog.Root>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n {/if}\n</section>\n\n{@render children?.()}\n", Qu = "import { error, fail } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { teamSchema } from \"$lib/schemas/team\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\n\nexport const actions = {\n updateTeam: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb\n .collection(\"teams\")\n .update(params.id, { name: form.data.name });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Team updated\" },\n cookies,\n );\n },\n removeMember: async ({ locals, params, request, cookies }) => {\n const formData = await request.formData();\n const memberId = formData.get(\"member_id\") as string;\n if (!memberId) {\n return error(400, { message: \"Member ID is required\" });\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").delete(memberId);\n } catch {\n return error(400, { message: \"Failed to remove member\" });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Member removed\" },\n cookies,\n );\n },\n resendInvite: async ({ locals }) => {\n const user = locals.pb.authStore.record!;\n },\n cancelInvite: async ({ locals, params, request, cookies }) => {\n const formData = await request.formData();\n const inviteId = formData.get(\"invite_id\") as string;\n if (!inviteId) {\n return error(400, { message: \"Invite ID is required\" });\n }\n\n try {\n await locals.pb.collection(\"team_invites\").delete(inviteId);\n } catch {\n return error(400, { message: \"Failed to cancel invite\" });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Invite cancelled\" },\n cookies,\n );\n },\n deleteTeam: async ({ locals, params, cookies }) => {\n try {\n await locals.pb.collection(\"teams\").delete(params.id);\n } catch {\n return error(400, { message: \"Failed to delete team\" });\n }\n\n const team = cookies.get(\"team\");\n if (team === params.id) {\n cookies.delete(\"team\", { path: \"/\" });\n }\n\n redirect(\n 303,\n `/teams`,\n { type: \"toast\", message: \"Team deleted successfully\" },\n cookies,\n );\n },\n};\n", $u = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team'\n });\n\n return { ...data, pageMetaTags };\n};\n", ed = "type Role = \"owner\" | \"admin\" | \"member\";\n\ninterface User {\n id: string;\n}\n\ninterface Member {\n id: string;\n role: Role;\n}\n\nexport const getAuthorization = ({\n user,\n role,\n member,\n}: {\n user: User;\n role: Role;\n member?: Member;\n}) => {\n const isSelf = member ? user.id === member.id : false;\n const isOwner = role === \"owner\";\n const isAdmin = role === \"admin\";\n\n if (isSelf) {\n return {\n canRemove: false,\n canChangeRole: false,\n };\n } else if (isOwner) {\n return {\n canRemove: true,\n canChangeRole: true,\n };\n } else if (isAdmin) {\n if (member && member.role === \"member\") {\n return {\n canRemove: true,\n canChangeRole: false,\n };\n }\n\n return {\n canRemove: false,\n canChangeRole: false,\n };\n }\n\n return {\n canRemove: false,\n canChangeRole: false,\n };\n};\n", td = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamInviteSchema } from \"$lib/schemas/teamInvite\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\n\nexport const load = async () => {\n const form = await superValidate(zod4(teamInviteSchema));\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamInviteSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n const team = await locals.pb.collection(\"teams\").getOne(params.id);\n\n try {\n await locals.pb.collection(\"team_invites\").create({\n email: form.data.email,\n team: params.id,\n name: team.name,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Invite sent\" },\n cookies,\n );\n },\n};\n", nd = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamInviteSchema } from '$lib/schemas/teamInvite';\n import * as Form from '$lib/components/ui/form';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamInviteSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto(`/teams/${data.team.id}`, { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Invite to Team</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"email\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input {...props} type=\"email\" bind:value={$formData.email} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Send Invite</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", rd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Invite to team'\n });\n\n return { ...data, pageMetaTags };\n};\n", id = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]/invite\", () => {\n it(\"authenticated user should be able to access invite page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}/invite` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]/invite\", () => {\n it(\"owner should be able to create invite with valid email\", async (context) => {\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(1);\n expect(invites.items[0].email).toBe(inviteEmail);\n expect(invites.items[0].team).toBe(team.id);\n });\n\n it(\"admin should be able to create invite with valid email\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(1);\n expect(invites.items[0].email).toBe(inviteEmail);\n expect(invites.items[0].team).toBe(team.id);\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to create invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(0);\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return 400 for invalid email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: \"invalid-email\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for missing email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for empty email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", ad = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamRoleSchema } from \"$lib/schemas/teamRole\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\n\nexport const load = async ({ locals, params }) => {\n const member = await locals.pb\n .collection(\"team_memberships\")\n .getOne(params.member_id);\n const form = await superValidate(member, zod4(teamRoleSchema));\n\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamRoleSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").update(params.member_id, {\n role: form.data.role,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Role updated successfully\" },\n cookies,\n );\n },\n};\n", od = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamRoleSchema } from '$lib/schemas/teamRole';\n import * as Form from '$lib/components/ui/form';\n import * as Select from '$lib/components/ui/select';\n\n let { data } = $props();\n\n const roleLabels = {\n owner: {\n label: 'Owner',\n value: 'owner'\n },\n admin: {\n label: 'Admin',\n value: 'admin'\n },\n member: {\n label: 'Member',\n value: 'member'\n }\n } as const;\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamRoleSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto(`/teams/${data.team.id}`, { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Change Role</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"role\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Role</Form.Label>\n <Select.Root type=\"single\" {...props} bind:value={$formData.role}>\n <Select.Trigger class=\"w-full\">\n {roleLabels[$formData.role].label}\n </Select.Trigger>\n <Select.Content>\n {#each Object.values(roleLabels) as role}\n <Select.Item value={role.value}>{role.label}</Select.Item>\n {/each}\n </Select.Content>\n </Select.Root>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Update Role</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", sd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team member'\n });\n\n return { ...data, pageMetaTags };\n};\n", cd = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\nlet member: { id: string; user: string; role: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n\n // Create a test member\n const memberUser = await context.admin.collection(\"users\").create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n\n member = await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]/member/[member_id]\", () => {\n it(\"authenticated user should be able to access member page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]/member/[member_id]\", () => {\n it(\"owner should be able to update member role\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n // Verify role was updated\n const updatedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(updatedMember.role).toBe(\"admin\");\n });\n\n it(\"admin should be able to update member role\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"member\",\n });\n\n // Verify role was updated\n const updatedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(updatedMember.role).toBe(\"member\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to update member role\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n // Verify role was not updated\n const unchangedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(unchangedMember.role).toBe(\"member\");\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return 400 for invalid role\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"invalid-role\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for empty role\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for invalid member ID\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/invalid-id` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", ld = "import {\n describe,\n it,\n expect,\n beforeEach,\n afterEach,\n type TestContext,\n} from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]\", () => {\n it(\"authenticated user should be able to access a team page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]?/updateTeam\", () => {\n it(\"owner should be able to update team\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}?/updateTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"Updated Team Name\",\n });\n\n const updatedTeam = await context.admin.collection(\"teams\").getOne(team.id);\n expect(updatedTeam.name).toBe(\"Updated Team Name\");\n });\n\n it(\"admin should not be able to update team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/updateTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"Updated Team Name\",\n });\n\n const updatedTeam = await context.admin.collection(\"teams\").getOne(team.id);\n expect(updatedTeam.name).not.toBe(\"Updated Team Name\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n});\n\ndescribe(\"POST /teams/[id]?/removeMember\", () => {\n it(\"owner should be able to remove member\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n const member = await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: member.id,\n });\n\n await expect(\n context.admin.collection(\"team_memberships\").getOne(member.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"admin should be able to remove member\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n const memberUser = await context.admin.collection(\"users\").create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: memberUser.id,\n });\n\n await expect(\n context.admin.collection(\"team_memberships\").getOne(memberUser.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"admin should not be able to remove owner\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: context.user.id,\n });\n\n const teamMembership = await context.admin\n .collection(\"team_memberships\")\n .getFirstListItem(\n context.pb.filter(\"team = {:team} && user = {:user}\", {\n team: team.id,\n user: context.user.id,\n }),\n );\n expect(teamMembership.role).toBe(\"owner\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n});\n\ndescribe(\"POST /teams/[id]?/cancelInvite\", () => {\n it(\"owner should be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email,\n role: \"member\",\n });\n\n await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n await expect(\n context.admin.collection(\"team_invites\").getOne(invite.id),\n ).rejects.toThrow();\n });\n\n it(\"admin should be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email: inviteEmail,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n await expect(\n context.admin.collection(\"team_invites\").getOne(invite.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email: inviteEmail,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: memberUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n expect(response.status).toBe(400);\n\n // Verify invite still exists\n const existingInvite = await context.admin\n .collection(\"team_invites\")\n .getOne(invite.id);\n expect(existingInvite).toBeDefined();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return error for invalid invite ID\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: \"invalid-id\",\n });\n\n expect(response.status).toBe(400);\n });\n});\n\ndescribe(\"POST /teams/[id]?/deleteTeam\", () => {\n it(\"owner should be able to delete team\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n await expect(\n context.admin.collection(\"teams\").getOne(team.id),\n ).rejects.toThrow();\n });\n\n it(\"admin should not be able to delete team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n expect(response.status).toBe(400);\n\n // Verify team still exists\n const existingTeam = await context.admin\n .collection(\"teams\")\n .getOne(team.id);\n expect(existingTeam).toBeDefined();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to delete team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: memberUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n expect(response.status).toBe(400);\n\n // Verify team still exists\n const existingTeam = await context.admin\n .collection(\"teams\")\n .getOne(team.id);\n expect(existingTeam).toBeDefined();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n});\n", ud = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"$lib/schemas/team\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\n\nexport const load = async () => {\n const form = await superValidate(zod4(teamSchema));\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await superValidate(request, zod4(teamSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let team;\n\n try {\n team = await locals.pb.collection(\"teams\").create({\n name: form.data.name,\n owner: user.id,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: team.id,\n role: \"owner\",\n });\n\n await locals.admin.collection(\"team_invite_links\").create({\n team: team.id,\n name: team.name,\n });\n\n redirect(\"/teams\", { type: \"toast\", message: \"Team created\" }, cookies);\n },\n};\n", dd = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '$lib/schemas/team';\n import * as Form from '$lib/components/ui/form';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto('/teams', { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Create Team</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Team Name</Form.Label>\n <Input {...props} type=\"text\" bind:value={$formData.name} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Create</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", fd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'New team'\n });\n\n return { ...data, pageMetaTags };\n};\n", pd = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string; owner: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/new\", () => {\n it(\"authenticated user should be able to access new team page\", async (context) => {\n const response = await context.agent.get(\n \"/teams/new\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/new\", () => {\n it(\"authenticated user should be able to create team with valid name\", async (context) => {\n const teamName = `Test Team ${Math.random().toString(36).slice(2)}`;\n\n await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: teamName,\n });\n\n // Verify team was created\n const teams = await context.admin.collection(\"teams\").getList(1, 1, {\n filter: `owner = \"${context.user.id}\" && name = \"${teamName}\"`,\n });\n expect(teams.items).toHaveLength(1);\n team = teams.items[0];\n expect(team.name).toBe(teamName);\n expect(team.owner).toBe(context.user.id);\n\n // Verify team membership was created\n const memberships = await context.admin\n .collection(\"team_memberships\")\n .getList(1, 1, {\n filter: `user = \"${context.user.id}\" && team = \"${team.id}\"`,\n });\n expect(memberships.items).toHaveLength(1);\n expect(memberships.items[0].role).toBe(\"owner\");\n });\n\n it(\"should return 400 for empty name\", async (context) => {\n const response = await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for missing name\", async (context) => {\n const response = await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", md = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /teams\", () => {\n it(\"authenticated user should be able to access the teams page\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/teams\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n});\n", hd = "import { error, redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\n\nexport const load = async ({ params, cookies, url, locals }) => {\n const { id } = params;\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n\n try {\n await locals.pb.collection(\"teams\").getOne(id);\n } catch {\n return error(404, { message: \"Team not found\" });\n }\n\n cookies.set(\"team\", id, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n return redirect(303, redirectUrl);\n};\n", gd = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string; owner: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n // Create a test team for the user\n const teamName = `Test Team ${Math.random().toString(36).slice(2)}`;\n team = await context.admin.collection(\"teams\").create({\n name: teamName,\n owner: context.user.id,\n });\n\n // Create team membership\n await context.admin.collection(\"team_memberships\").create({\n user: context.user.id,\n team: team.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/switch/[id]\", () => {\n it(\"should set team cookie and redirect to dashboard for valid team\", async (context) => {\n const response = await context.agent.get(\n `/teams/switch/${team.id}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n\n // Check that the team cookie is set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeDefined();\n expect(cookies).toContain(`team=${team.id}`);\n });\n\n it(\"should redirect to custom redirect URL when provided\", async (context) => {\n const customRedirect = \"/teams\";\n const response = await context.agent.get(\n `/teams/switch/${team.id}?redirect=${encodeURIComponent(customRedirect)}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(customRedirect);\n\n // Check that the team cookie is still set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeDefined();\n expect(cookies).toContain(\"team=\" + team.id);\n });\n\n it(\"should return 404 error for non-existent team\", async (context) => {\n const nonExistentTeamId = \"non-existent-team-id\";\n const response = await context.agent.get(\n `/teams/switch/${nonExistentTeamId}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(404);\n\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeUndefined();\n });\n\n it(\"should return 404 error for invalid team ID format\", async (context) => {\n const invalidTeamId = \"invalid-id-format\";\n const response = await context.agent.get(\n `/teams/switch/${invalidTeamId}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(404);\n\n // Check that no team cookie is set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeUndefined();\n });\n});\n", _d = /* @__PURE__ */ Object.assign({
|
|
5420
|
-
"./creates/src/lib/components/team-switcher.svelte":
|
|
5421
|
-
"./creates/src/lib/schemas/team.ts":
|
|
5422
|
-
"./creates/src/lib/schemas/teamInvite.ts":
|
|
5423
|
-
"./creates/src/lib/schemas/teamRole.ts":
|
|
5424
|
-
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte":
|
|
5425
|
-
"./creates/src/routes/(app)/invite/[id]/+page.server.ts":
|
|
5426
|
-
"./creates/src/routes/(app)/invite/[id]/+page.svelte":
|
|
5427
|
-
"./creates/src/routes/(app)/invite/[id]/+page.ts":
|
|
5428
|
-
"./creates/src/routes/(app)/join/[id]/+layout@.svelte":
|
|
5429
|
-
"./creates/src/routes/(app)/join/[id]/+page.server.ts":
|
|
5430
|
-
"./creates/src/routes/(app)/join/[id]/+page.svelte":
|
|
5431
|
-
"./creates/src/routes/(app)/join/[id]/+page.ts":
|
|
5432
|
-
"./creates/src/routes/(app)/teams/+layout.server.ts":
|
|
5433
|
-
"./creates/src/routes/(app)/teams/+layout.svelte":
|
|
5434
|
-
"./creates/src/routes/(app)/teams/+page.server.ts":
|
|
5531
|
+
generate: Ju
|
|
5532
|
+
}, Xu = "<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '$lib/components/ui/sidebar/index.js';\n import { useSidebar } from '$lib/components/ui/sidebar/index.js';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import UsersIcon from '@lucide/svelte/icons/users';\n import { page } from '$app/state';\n import { goto, invalidate } from '$app/navigation';\n\n let { teams, children }: { teams: { id: string; name: string }[] } & { children: Snippet } =\n $props();\n\n const switchTeam = async (teamId: string) => {\n await goto(`/teams/switch/${teamId}?redirect=${encodeURIComponent(page.url.pathname)}`);\n invalidate('app:team');\n };\n\n const sidebar = useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n {...props}\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n >\n {@render children?.()}\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n align=\"start\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"text-muted-foreground text-xs\">Teams</DropdownMenu.Label>\n {#each teams as team (team.name)}\n <DropdownMenu.Item onSelect={() => switchTeam(team.id)} class=\"gap-2 p-2\">\n <div class=\"flex size-6 items-center justify-center rounded-md border\">\n <UsersIcon class=\"size-3.5 shrink-0\" />\n </div>\n {team.name}\n </DropdownMenu.Item>\n {/each}\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"gap-2 p-2\">\n <div class=\"flex size-6 items-center justify-center rounded-md border bg-transparent\">\n <PlusIcon class=\"size-4\" />\n </div>\n <a href=\"/teams/new\" class=\"text-muted-foreground font-medium\">Add team</a>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", Zu = "import { z } from \"zod\";\n\nexport const teamSchema = z.object({\n name: z.string(),\n});\n", Qu = "import { z } from \"zod\";\n\nexport const teamInviteSchema = z.object({\n email: z.email(),\n});\n", $u = "import { z } from \"zod\";\n\nexport const teamRoleSchema = z.object({\n role: z.enum([\"owner\", \"admin\", \"member\"]),\n});\n", ed = "<script lang=\"ts\">\n import RootLayout from '../../../(public)/root-layout.svelte';\n\n let { data, children } = $props();\n<\/script>\n\n<RootLayout {data}>\n {@render children?.()}\n</RootLayout>\n", td = "import { error } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ params, locals }) => {\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n return { invite };\n};\n\nexport const actions = {\n default: async ({ locals, params, cookies }) => {\n const user = locals.pb.authStore.record!;\n\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(params.id);\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n await locals.admin.collection(\"team_invites\").delete(invite.id);\n\n redirect(\n 303,\n `/dashboard`,\n { type: \"toast\", message: \"Joined team\" },\n cookies,\n );\n },\n};\n", nd = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src=\"/favicon.svg\" alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\"\n >{data.invite.expand?.team.name} invited you to join their team</Card.Title\n >\n <Card.Description>Accept the invite to join the team</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Button type=\"submit\" class=\"w-full\">Accept Invite</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", rd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Invitation'\n });\n\n return { ...data, pageMetaTags };\n};\n", id = "<script lang=\"ts\">\n import RootLayout from '../../../(public)/root-layout.svelte';\n\n let { data, children } = $props();\n<\/script>\n\n<RootLayout {data}>\n {@render children?.()}\n</RootLayout>\n", ad = "import { error } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const load = async ({ params, locals }) => {\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invite_links\").getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite link not found\" });\n }\n\n return { invite };\n};\n\nexport const actions = {\n default: async ({ locals, params, cookies }) => {\n const user = locals.pb.authStore.record!;\n\n let invite;\n try {\n invite = await locals.pb\n .collection(\"team_invite_links\")\n .getOne(params.id, {\n expand: \"team\",\n });\n } catch {\n return error(404, { message: \"Invite link not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n redirect(\n 303,\n `/dashboard`,\n { type: \"toast\", message: \"Joined team\" },\n cookies,\n );\n },\n};\n", od = "<script lang=\"ts\">\n import { Button } from '$lib/components/ui/button';\n import * as Card from '$lib/components/ui/card';\n\n let { data } = $props();\n<\/script>\n\n<div class=\"flex flex-col flex-1 items-center justify-center gap-6 p-6 md:p-10\">\n <div class=\"flex w-full max-w-sm flex-col gap-6\">\n <a href=\"/\" class=\"flex items-center gap-2 self-center font-medium\">\n <div\n class=\"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md\"\n >\n <img src=\"/favicon.svg\" alt=\"logo\" class=\"size-4\" />\n </div>\n {data.meta.appName}\n </a>\n\n <div class=\"flex flex-col gap-6\">\n <Card.Root>\n <Card.Header class=\"text-center\">\n <Card.Title class=\"text-xl\"\n >{data.invite.expand?.team.name} invited you to join their team</Card.Title\n >\n <Card.Description>Accept the invite to join the team</Card.Description>\n </Card.Header>\n <Card.Content>\n <form method=\"POST\">\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <Button type=\"submit\" class=\"w-full\">Accept Invite</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", sd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Join team'\n });\n\n return { ...data, pageMetaTags };\n};\n", cd = "export const load = async ({ locals, parent }) => {\n const { user, breadcrumbs } = await parent();\n\n const ownedTeams = await locals.pb.collection(\"teams\").getFullList({\n filter: locals.pb.filter(\"owner = {:owner}\", { owner: user.id }),\n expand: \"team_users_via_team\",\n });\n\n const memberships = await locals.pb\n .collection(\"team_memberships\")\n .getFullList({\n filter: locals.pb.filter(\"user = {:user}\", { user: user.id }),\n expand: \"team\",\n });\n\n const pendingInvites = await locals.pb\n .collection(\"team_invites\")\n .getFullList({\n filter: locals.pb.filter(\"email = {:email}\", { email: user.email }),\n expand: \"team\",\n });\n\n const teams = [\n ...ownedTeams.map((team) => ({\n type: \"team\" as const,\n id: team.id,\n name: team.name,\n role: \"owner\" as const,\n members: team.expand?.team_users_via_team?.length || 0,\n })),\n ...memberships\n .filter((membership) => membership.expand?.team.owner !== membership.user)\n .map((membership) => ({\n type: \"membership\" as const,\n id: membership.team,\n name: membership.expand?.team.name,\n role: membership.role,\n })),\n ...pendingInvites.map((invite) => ({\n type: \"invite\" as const,\n id: invite.team,\n name: invite.expand?.team.name,\n role: null,\n invite_id: invite.id,\n })),\n ];\n\n return {\n teams,\n breadcrumbs: [...breadcrumbs, { title: \"Teams\", url: \"/teams\" }],\n };\n};\n", ld = "<script lang=\"ts\">\n import * as Card from '$lib/components/ui/card';\n import { Button } from '$lib/components/ui/button';\n import UserIcon from '@lucide/svelte/icons/user';\n import UserPlusIcon from '@lucide/svelte/icons/user-plus';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import * as Avatar from '$lib/components/ui/avatar';\n\n const roleLabels = {\n owner: 'Owner',\n admin: 'Admin',\n member: 'Member'\n };\n\n let { data, children } = $props();\n<\/script>\n\n<section data-slot=\"content\">\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Management</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Organize your workspace with teams. Collaborate with members, manage permissions, and\n streamline your workflow.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Your Teams</Card.Title>\n <Card.Description>Manage and view your team memberships</Card.Description>\n </Card.Header>\n <Card.Content class=\"space-y-4\">\n {#if data.teams && data.teams.length > 0}\n <div class=\"grid gap-3\">\n {#each data.teams as team}\n <div\n class=\"flex items-center justify-between p-4 border rounded-lg hover:bg-muted/50 transition-colors\"\n >\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-10 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-primary text-primary-foreground font-medium\"\n >\n {team.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n {#if team.role === 'owner' || team.role === 'admin'}\n <a\n href=\"/teams/{team.id}\"\n class=\"font-medium text-foreground hover:text-primary transition-colors\"\n >\n {team.name}\n </a>\n {:else}\n <span class=\"font-medium text-foreground\">\n {team.name}\n </span>\n {/if}\n <p class=\"text-sm text-muted-foreground\">\n {team.role ? roleLabels[team.role] : 'Pending'}\n </p>\n </div>\n </div>\n {#if team.type === 'team'}\n <div class=\"flex items-center space-x-2 text-sm text-muted-foreground\">\n <UserIcon class=\"w-4 h-4\" />\n <span class=\"font-medium\">\n {team.members} member{team.members !== 1 ? 's' : ''}\n </span>\n </div>\n {:else if team.type === 'membership'}\n <div class=\"flex items-center\">\n <form method=\"POST\" action=\"?/leaveTeam\">\n <input type=\"hidden\" name=\"team_id\" value={team.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">\n <LogOutIcon class=\"w-4 h-4\" />\n Leave team\n </Button>\n </form>\n </div>\n {:else if team.type === 'invite'}\n <div class=\"flex items-center\">\n <form method=\"POST\" action=\"?/acceptInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={team.invite_id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">\n <UserPlusIcon class=\"w-4 h-4\" />\n Accept invitation\n </Button>\n </form>\n </div>\n {/if}\n </div>\n {/each}\n </div>\n {:else}\n <div class=\"text-center py-8\">\n <div\n class=\"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4\"\n >\n <UserIcon class=\"w-6 h-6 text-muted-foreground\" />\n </div>\n <h3 class=\"text-lg font-medium text-foreground mb-2\">No teams yet</h3>\n <p class=\"text-muted-foreground mb-4\">Get started by creating your first team</p>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {data.teams?.length || 0} team{(data.teams?.length || 0) !== 1 ? 's' : ''}\n </div>\n <Button size=\"sm\" href=\"/teams/new\" class=\"ml-auto\">Create new team</Button>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n</section>\n\n{@render children?.()}\n", ud = "import { error, fail } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\n\nexport const actions = {\n acceptInvite: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await request.formData();\n const inviteId = form.get(\"invite_id\") as string;\n if (!inviteId) {\n return fail(400, { error: \"Invite ID is required\" });\n }\n\n let invite;\n try {\n invite = await locals.pb.collection(\"team_invites\").getOne(inviteId);\n } catch {\n return error(404, { message: \"Invite not found\" });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: invite.team,\n role: \"member\",\n });\n\n await locals.admin.collection(\"team_invites\").delete(invite.id);\n\n redirect(303, `/teams`, { type: \"toast\", message: \"Joined team\" }, cookies);\n },\n leaveTeam: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await request.formData();\n const teamId = form.get(\"team_id\") as string;\n if (!teamId) {\n return fail(400, { error: \"Team ID is required\" });\n }\n\n let teamMembership;\n try {\n teamMembership = await locals.pb\n .collection(\"team_memberships\")\n .getFirstListItem(\n locals.pb.filter(\"team = {:team} && user = {:user}\", {\n team: teamId,\n user: user.id,\n }),\n );\n } catch {\n return error(404, { message: \"Team not found\" });\n }\n\n if (teamMembership.role === \"owner\") {\n return error(400, { message: \"You cannot leave a team you own\" });\n }\n\n await locals.pb.collection(\"team_memberships\").delete(teamMembership.id);\n\n redirect(303, `/teams`, { type: \"toast\", message: \"Left team\" }, cookies);\n },\n};\n", dd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Teams'\n });\n\n return { ...data, pageMetaTags };\n};\n", fd = "import { redirect } from \"@sveltejs/kit\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"$lib/schemas/team\";\n\nexport const load = async ({ params, locals, parent }) => {\n const { user, breadcrumbs } = await parent();\n const { id } = params;\n\n let team;\n try {\n team = await locals.pb.collection(\"teams\").getOne(id, {\n expand: \"team_invite_links_via_team\",\n });\n } catch {\n redirect(303, \"/teams\");\n }\n\n let userMembership;\n try {\n userMembership = await locals.pb.collection(\"team_users\").getFirstListItem(\n locals.pb.filter(\n 'team = {:team} && id = {:user} && (role = \"admin\" || role = \"owner\")',\n {\n team: id,\n user: user.id,\n },\n ),\n );\n } catch (error) {\n redirect(303, \"/teams\");\n }\n\n const role = userMembership.role;\n\n // Get all team members with their roles\n const teamMembers = await locals.pb.collection(\"team_users\").getFullList({\n filter: locals.pb.filter(\"team = {:team}\", { team: id }),\n });\n\n // Get pending invites for this team\n const pendingInvites = await locals.pb\n .collection(\"team_invites\")\n .getFullList({\n filter: locals.pb.filter(\"team = {:team}\", { team: id }),\n });\n\n const form = await superValidate(team, zod4(teamSchema));\n\n return {\n team,\n role,\n teamMembers,\n pendingInvites,\n inviteLink: team.expand?.team_invite_links_via_team,\n form,\n breadcrumbs: [\n ...breadcrumbs,\n { title: \"Teams\", url: \"/teams\" },\n { title: team.name, url: `/teams/${id}` },\n ],\n };\n};\n", pd = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Card from '$lib/components/ui/card';\n import { Button, buttonVariants } from '$lib/components/ui/button';\n import CrownIcon from '@lucide/svelte/icons/crown';\n import ShieldIcon from '@lucide/svelte/icons/shield';\n import UserCheckIcon from '@lucide/svelte/icons/user-check';\n import UserPlusIcon from '@lucide/svelte/icons/user-plus';\n import CopyIcon from '@lucide/svelte/icons/copy';\n import MailIcon from '@lucide/svelte/icons/mail';\n import ClockIcon from '@lucide/svelte/icons/clock';\n import * as Avatar from '$lib/components/ui/avatar';\n import { Badge } from '$lib/components/ui/badge';\n import * as Table from '$lib/components/ui/table';\n import { getAuthorization } from './authorization';\n import { toast } from 'svelte-sonner';\n import * as AlertDialog from '$lib/components/ui/alert-dialog';\n import * as Form from '$lib/components/ui/form';\n import TrashIcon from '@lucide/svelte/icons/trash-2';\n import { Input } from '$lib/components/ui/input';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '$lib/schemas/team';\n\n let { data, children } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamSchema),\n warnings: {\n duplicateId: false\n }\n }\n );\n\n const { form: formData } = form;\n\n function getRoleIcon(role: 'owner' | 'admin' | 'member') {\n switch (role) {\n case 'owner':\n return CrownIcon;\n case 'admin':\n return ShieldIcon;\n case 'member':\n return UserCheckIcon;\n }\n }\n\n function handleCopyLink(inviteStr: string) {\n const link = `${data.meta.appURL}/${inviteStr}`;\n navigator.clipboard.writeText(link);\n toast.success('Link copied to clipboard');\n }\n<\/script>\n\n<section data-slot=\"content\">\n {#if data.role === 'owner'}\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Settings</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Update your team name and manage basic team settings.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <form method=\"POST\" action=\"?/updateTeam\" class=\"space-y-4\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Team Name</Card.Title>\n <Card.Description>Update your team's display name</Card.Description>\n </Card.Header>\n <Card.Content>\n <div class=\"space-y-2\">\n <Form.Field {form} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Input {...props} type=\"text\" bind:value={$formData.name} required />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n </div>\n </Card.Content>\n <Card.Footer class=\"flex justify-end pt-4 border-t\">\n <Button type=\"submit\" class=\"flex items-center\" size=\"sm\">Save changes</Button>\n </Card.Footer>\n </form>\n </Card.Root>\n </div>\n </div>\n {/if}\n\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Members</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Manage team members and their roles. Control access permissions and organize your team\n effectively.\n </p>\n <div class=\"mt-4 space-y-2\">\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Owner - Full team control</span>\n </div>\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Admin - Manage members</span>\n </div>\n <div class=\"flex items-center text-sm text-muted-foreground\">\n <div class=\"w-2 h-2 bg-muted-foreground rounded-full mr-2\"></div>\n <span>Member - Team access</span>\n </div>\n </div>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">{data.team.name} Members</Card.Title>\n <Card.Description>Manage team members and their roles</Card.Description>\n </Card.Header>\n <Card.Content>\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.Head>Member</Table.Head>\n <Table.Head>Role</Table.Head>\n <Table.Head></Table.Head>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n <!-- Team Members -->\n {#each data.teamMembers as member}\n {@const { canRemove, canChangeRole } = getAuthorization({\n user: data.user,\n role: data.role,\n member\n })}\n <Table.Row>\n <Table.Cell>\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-primary text-primary-foreground font-medium\"\n >\n {member.name?.charAt(0).toUpperCase() ||\n member.email.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {member.name || member.email}\n </div>\n <div class=\"text-sm text-muted-foreground\">\n {member.email}\n </div>\n </div>\n </div>\n </Table.Cell>\n <Table.Cell>\n <Badge variant=\"outline\" class=\"flex items-center space-x-1 w-fit\">\n {@const Icon = getRoleIcon(member.role)}\n <Icon class=\"w-3 h-3\" />\n <span class=\"capitalize\">{member.role}</span>\n </Badge>\n </Table.Cell>\n <Table.Cell>\n <div class=\"flex space-x-2 justify-end\">\n {#if canChangeRole}\n <Button\n href=\"/teams/{data.team.id}/member/{member.membership_id}\"\n variant=\"outline\"\n size=\"sm\"\n data-sveltekit-noscroll\n >\n Change Role\n </Button>\n {/if}\n {#if canRemove}\n <form method=\"POST\" action=\"?/removeMember\">\n <input type=\"hidden\" name=\"member_id\" value={member.membership_id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Remove</Button>\n </form>\n {/if}\n </div>\n </Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n </Table.Root>\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {data.teamMembers?.length || 0} member{(data.teamMembers?.length || 0) !== 1 ? 's' : ''}\n total\n </div>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Team Invites</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Invitations that have been sent but not yet accepted. You can resend or cancel pending\n invites.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Invitations</Card.Title>\n <Card.Description>Manage pending team invitations</Card.Description>\n </Card.Header>\n <Card.Content>\n {#if data.pendingInvites && data.pendingInvites.length > 0}\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.Head>Email</Table.Head>\n <Table.Head>Status</Table.Head>\n <Table.Head></Table.Head>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n {#each data.pendingInvites as invite}\n <Table.Row>\n <Table.Cell>\n <div class=\"flex items-center space-x-3\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback\n class=\"rounded-lg bg-muted text-muted-foreground font-medium\"\n >\n <MailIcon class=\"w-4 h-4\" />\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {invite.email}\n </div>\n <div class=\"text-sm text-muted-foreground\">Pending invitation</div>\n </div>\n </div>\n </Table.Cell>\n <Table.Cell>\n <Badge variant=\"outline\" class=\"flex items-center space-x-1 w-fit\">\n <ClockIcon class=\"w-3 h-3\" />\n <span>Pending</span>\n </Badge>\n </Table.Cell>\n <Table.Cell>\n <div class=\"flex space-x-2 justify-end\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => handleCopyLink(`invite/${invite.id}`)}>Copy link</Button\n >\n <form method=\"POST\" action=\"?/resendInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={invite.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Resend</Button>\n </form>\n <form method=\"POST\" action=\"?/cancelInvite\">\n <input type=\"hidden\" name=\"invite_id\" value={invite.id} />\n <Button type=\"submit\" variant=\"outline\" size=\"sm\">Cancel</Button>\n </form>\n </div>\n </Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n </Table.Root>\n {:else}\n <div class=\"text-center py-8\">\n <div\n class=\"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4\"\n >\n <MailIcon class=\"w-6 h-6 text-muted-foreground\" />\n </div>\n <h3 class=\"text-lg font-medium text-foreground mb-2\">No pending invites</h3>\n <p class=\"text-muted-foreground mb-4\">\n All invitations have been accepted or there are no pending invites\n </p>\n </div>\n {/if}\n </Card.Content>\n <Card.Footer class=\"flex justify-between items-center pt-4 border-t\">\n <div class=\"text-sm text-muted-foreground\">\n {#if data.inviteLink}\n <div class=\"text-sm text-muted-foreground\">\n {data.meta.appURL}/join/{data.inviteLink.id}\n </div>\n {/if}\n </div>\n <div class=\"flex items-center space-x-2\">\n {#if data.inviteLink}\n <Button\n variant=\"outline\"\n size=\"sm\"\n onclick={() => handleCopyLink(`join/${data.inviteLink.id}`)}\n >\n <CopyIcon class=\"w-4 h-4\" />\n Copy invite link\n </Button>\n {/if}\n\n <Button\n size=\"sm\"\n href=\"/teams/{data.team.id}/invite\"\n class=\"ml-auto\"\n data-sveltekit-noscroll\n >\n <UserPlusIcon class=\"w-4 h-4\" />\n Invite member\n </Button>\n </div>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n\n {#if data.role === 'owner'}\n <div class=\"divide-y divide-border\">\n <div class=\"grid grid-cols-1 gap-x-8 gap-y-8 py-10 md:grid-cols-3\">\n <div class=\"px-4 sm:px-0\">\n <h2 class=\"text-base/7 font-semibold text-foreground\">Danger Zone</h2>\n <p class=\"mt-1 text-sm/6 text-muted-foreground\">\n Permanently delete this team and all associated data. This action cannot be undone.\n </p>\n </div>\n\n <Card.Root class=\"md:col-span-2\">\n <Card.Header>\n <Card.Title class=\"text-lg font-semibold\">Delete Team</Card.Title>\n <Card.Description>\n Remove this team and all associated data permanently\n </Card.Description>\n </Card.Header>\n <Card.Content>\n <div\n class=\"flex items-center space-x-3 p-4 bg-destructive/10 rounded-lg border border-destructive/20\"\n >\n <div class=\"flex-shrink-0\">\n <TrashIcon class=\"w-5 h-5 text-destructive\" />\n </div>\n <div class=\"flex-1\">\n <p class=\"text-sm font-medium text-destructive\">Delete this team</p>\n <p class=\"text-sm text-muted-foreground\">\n This will permanently delete the team, remove all members, and delete all\n associated data.\n </p>\n </div>\n </div>\n </Card.Content>\n <Card.Footer class=\"flex justify-end pt-4 border-t\">\n <AlertDialog.Root>\n <AlertDialog.Trigger class={buttonVariants({ variant: 'destructive', size: 'sm' })}>\n <TrashIcon class=\"w-4 h-4\" />\n Delete team\n </AlertDialog.Trigger>\n <AlertDialog.Content>\n <AlertDialog.Header>\n <AlertDialog.Title>Delete Team</AlertDialog.Title>\n <AlertDialog.Description>\n Are you sure you want to delete \"{data.team.name}\"? This action cannot be\n undone. This will permanently delete the team, remove all members, and delete\n all associated data.\n </AlertDialog.Description>\n </AlertDialog.Header>\n <AlertDialog.Footer>\n <AlertDialog.Cancel>Cancel</AlertDialog.Cancel>\n <form method=\"POST\" action=\"?/deleteTeam\" class=\"inline\">\n <AlertDialog.Action>\n <TrashIcon class=\"w-4 h-4\" />\n Delete team\n </AlertDialog.Action>\n </form>\n </AlertDialog.Footer>\n </AlertDialog.Content>\n </AlertDialog.Root>\n </Card.Footer>\n </Card.Root>\n </div>\n </div>\n {/if}\n</section>\n\n{@render children?.()}\n", md = "import { error, fail } from \"@sveltejs/kit\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { teamSchema } from \"$lib/schemas/team\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\n\nexport const actions = {\n updateTeam: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb\n .collection(\"teams\")\n .update(params.id, { name: form.data.name });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Team updated\" },\n cookies,\n );\n },\n removeMember: async ({ locals, params, request, cookies }) => {\n const formData = await request.formData();\n const memberId = formData.get(\"member_id\") as string;\n if (!memberId) {\n return error(400, { message: \"Member ID is required\" });\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").delete(memberId);\n } catch {\n return error(400, { message: \"Failed to remove member\" });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Member removed\" },\n cookies,\n );\n },\n resendInvite: async ({ locals }) => {\n const user = locals.pb.authStore.record!;\n },\n cancelInvite: async ({ locals, params, request, cookies }) => {\n const formData = await request.formData();\n const inviteId = formData.get(\"invite_id\") as string;\n if (!inviteId) {\n return error(400, { message: \"Invite ID is required\" });\n }\n\n try {\n await locals.pb.collection(\"team_invites\").delete(inviteId);\n } catch {\n return error(400, { message: \"Failed to cancel invite\" });\n }\n\n redirect(\n 303,\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Invite cancelled\" },\n cookies,\n );\n },\n deleteTeam: async ({ locals, params, cookies }) => {\n try {\n await locals.pb.collection(\"teams\").delete(params.id);\n } catch {\n return error(400, { message: \"Failed to delete team\" });\n }\n\n const team = cookies.get(\"team\");\n if (team === params.id) {\n cookies.delete(\"team\", { path: \"/\" });\n }\n\n redirect(\n 303,\n `/teams`,\n { type: \"toast\", message: \"Team deleted successfully\" },\n cookies,\n );\n },\n};\n", hd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team'\n });\n\n return { ...data, pageMetaTags };\n};\n", gd = "type Role = \"owner\" | \"admin\" | \"member\";\n\ninterface User {\n id: string;\n}\n\ninterface Member {\n id: string;\n role: Role;\n}\n\nexport const getAuthorization = ({\n user,\n role,\n member,\n}: {\n user: User;\n role: Role;\n member?: Member;\n}) => {\n const isSelf = member ? user.id === member.id : false;\n const isOwner = role === \"owner\";\n const isAdmin = role === \"admin\";\n\n if (isSelf) {\n return {\n canRemove: false,\n canChangeRole: false,\n };\n } else if (isOwner) {\n return {\n canRemove: true,\n canChangeRole: true,\n };\n } else if (isAdmin) {\n if (member && member.role === \"member\") {\n return {\n canRemove: true,\n canChangeRole: false,\n };\n }\n\n return {\n canRemove: false,\n canChangeRole: false,\n };\n }\n\n return {\n canRemove: false,\n canChangeRole: false,\n };\n};\n", _d = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamInviteSchema } from \"$lib/schemas/teamInvite\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\n\nexport const load = async () => {\n const form = await superValidate(zod4(teamInviteSchema));\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamInviteSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n const team = await locals.pb.collection(\"teams\").getOne(params.id);\n\n try {\n await locals.pb.collection(\"team_invites\").create({\n email: form.data.email,\n team: params.id,\n name: team.name,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Invite sent\" },\n cookies,\n );\n },\n};\n", vd = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamInviteSchema } from '$lib/schemas/teamInvite';\n import * as Form from '$lib/components/ui/form';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamInviteSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto(`/teams/${data.team.id}`, { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Invite to Team</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"email\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Email</Form.Label>\n <Input {...props} type=\"email\" bind:value={$formData.email} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Send Invite</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", yd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Invite to team'\n });\n\n return { ...data, pageMetaTags };\n};\n", bd = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]/invite\", () => {\n it(\"authenticated user should be able to access invite page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}/invite` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]/invite\", () => {\n it(\"owner should be able to create invite with valid email\", async (context) => {\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(1);\n expect(invites.items[0].email).toBe(inviteEmail);\n expect(invites.items[0].team).toBe(team.id);\n });\n\n it(\"admin should be able to create invite with valid email\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(1);\n expect(invites.items[0].email).toBe(inviteEmail);\n expect(invites.items[0].team).toBe(team.id);\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to create invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: inviteEmail,\n });\n\n const invites = await context.admin\n .collection(\"team_invites\")\n .getList(1, 1, {\n filter: `team = \"${team.id}\" && email = \"${inviteEmail}\"`,\n });\n expect(invites.items).toHaveLength(0);\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return 400 for invalid email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: \"invalid-email\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for missing email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for empty email\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/invite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n email: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", xd = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamRoleSchema } from \"$lib/schemas/teamRole\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\n\nexport const load = async ({ locals, params }) => {\n const member = await locals.pb\n .collection(\"team_memberships\")\n .getOne(params.member_id);\n const form = await superValidate(member, zod4(teamRoleSchema));\n\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, params, request, cookies }) => {\n const form = await superValidate(request, zod4(teamRoleSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").update(params.member_id, {\n role: form.data.role,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n redirect(\n `/teams/${params.id}`,\n { type: \"toast\", message: \"Role updated successfully\" },\n cookies,\n );\n },\n};\n", Sd = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamRoleSchema } from '$lib/schemas/teamRole';\n import * as Form from '$lib/components/ui/form';\n import * as Select from '$lib/components/ui/select';\n\n let { data } = $props();\n\n const roleLabels = {\n owner: {\n label: 'Owner',\n value: 'owner'\n },\n admin: {\n label: 'Admin',\n value: 'admin'\n },\n member: {\n label: 'Member',\n value: 'member'\n }\n } as const;\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamRoleSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto(`/teams/${data.team.id}`, { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Change Role</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"role\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Role</Form.Label>\n <Select.Root type=\"single\" {...props} bind:value={$formData.role}>\n <Select.Trigger class=\"w-full\">\n {roleLabels[$formData.role].label}\n </Select.Trigger>\n <Select.Content>\n {#each Object.values(roleLabels) as role}\n <Select.Item value={role.value}>{role.label}</Select.Item>\n {/each}\n </Select.Content>\n </Select.Root>\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Update Role</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", Cd = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team member'\n });\n\n return { ...data, pageMetaTags };\n};\n", wd = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\nlet member: { id: string; user: string; role: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n\n // Create a test member\n const memberUser = await context.admin.collection(\"users\").create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: \"password\",\n passwordConfirm: \"password\",\n });\n\n member = await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]/member/[member_id]\", () => {\n it(\"authenticated user should be able to access member page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]/member/[member_id]\", () => {\n it(\"owner should be able to update member role\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n // Verify role was updated\n const updatedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(updatedMember.role).toBe(\"admin\");\n });\n\n it(\"admin should be able to update member role\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"member\",\n });\n\n // Verify role was updated\n const updatedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(updatedMember.role).toBe(\"member\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to update member role\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n // Verify role was not updated\n const unchangedMember = await context.admin\n .collection(\"team_memberships\")\n .getOne(member.id);\n expect(unchangedMember.role).toBe(\"member\");\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return 400 for invalid role\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"invalid-role\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for empty role\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/${member.id}` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for invalid member ID\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}/member/invalid-id` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n role: \"admin\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", Td = "import {\n describe,\n it,\n expect,\n beforeEach,\n afterEach,\n type TestContext,\n} from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n team = await context.admin.collection(\"teams\").create({\n name: \"Test Team\",\n owner: context.user.id,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: context.user.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/[id]\", () => {\n it(\"authenticated user should be able to access a team page\", async (context) => {\n const response = await context.agent.get(\n `/teams/${team.id}` satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/[id]?/updateTeam\", () => {\n it(\"owner should be able to update team\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}?/updateTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"Updated Team Name\",\n });\n\n const updatedTeam = await context.admin.collection(\"teams\").getOne(team.id);\n expect(updatedTeam.name).toBe(\"Updated Team Name\");\n });\n\n it(\"admin should not be able to update team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/updateTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"Updated Team Name\",\n });\n\n const updatedTeam = await context.admin.collection(\"teams\").getOne(team.id);\n expect(updatedTeam.name).not.toBe(\"Updated Team Name\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n});\n\ndescribe(\"POST /teams/[id]?/removeMember\", () => {\n it(\"owner should be able to remove member\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n const member = await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: member.id,\n });\n\n await expect(\n context.admin.collection(\"team_memberships\").getOne(member.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"admin should be able to remove member\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n const memberUser = await context.admin.collection(\"users\").create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: memberUser.id,\n });\n\n await expect(\n context.admin.collection(\"team_memberships\").getOne(memberUser.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"admin should not be able to remove owner\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/removeMember` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n member_id: context.user.id,\n });\n\n const teamMembership = await context.admin\n .collection(\"team_memberships\")\n .getFirstListItem(\n context.pb.filter(\"team = {:team} && user = {:user}\", {\n team: team.id,\n user: context.user.id,\n }),\n );\n expect(teamMembership.role).toBe(\"owner\");\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n});\n\ndescribe(\"POST /teams/[id]?/cancelInvite\", () => {\n it(\"owner should be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email,\n role: \"member\",\n });\n\n await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n await expect(\n context.admin.collection(\"team_invites\").getOne(invite.id),\n ).rejects.toThrow();\n });\n\n it(\"admin should be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email: inviteEmail,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n await expect(\n context.admin.collection(\"team_invites\").getOne(invite.id),\n ).rejects.toThrow();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to cancel invite\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n const inviteEmail = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const invite = await context.admin.collection(\"team_invites\").create({\n team: team.id,\n email: inviteEmail,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: memberUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: invite.id,\n });\n\n expect(response.status).toBe(400);\n\n // Verify invite still exists\n const existingInvite = await context.admin\n .collection(\"team_invites\")\n .getOne(invite.id);\n expect(existingInvite).toBeDefined();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n\n it(\"should return error for invalid invite ID\", async (context) => {\n const response = await context.agent\n .post(`/teams/${team.id}?/cancelInvite` satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n invite_id: \"invalid-id\",\n });\n\n expect(response.status).toBe(400);\n });\n});\n\ndescribe(\"POST /teams/[id]?/deleteTeam\", () => {\n it(\"owner should be able to delete team\", async (context) => {\n await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n await expect(\n context.admin.collection(\"teams\").getOne(team.id),\n ).rejects.toThrow();\n });\n\n it(\"admin should not be able to delete team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const adminUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: adminUser.id,\n role: \"admin\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: adminUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n expect(response.status).toBe(400);\n\n // Verify team still exists\n const existingTeam = await context.admin\n .collection(\"teams\")\n .getOne(team.id);\n expect(existingTeam).toBeDefined();\n\n context.admin.collection(\"users\").delete(adminUser.id);\n });\n\n it(\"member should not be able to delete team\", async (context) => {\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n const password = \"password\";\n\n const memberUser = await context.admin.collection(\"users\").create({\n email,\n password,\n passwordConfirm: password,\n });\n\n await context.admin.collection(\"team_memberships\").create({\n team: team.id,\n user: memberUser.id,\n role: \"member\",\n });\n\n await context.agent.post(\"/login\").type(\"form\").send({\n type: \"password\",\n email: memberUser.email,\n password,\n });\n\n const response = await context.agent\n .post(`/teams/${team.id}?/deleteTeam` satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n expect(response.status).toBe(400);\n\n // Verify team still exists\n const existingTeam = await context.admin\n .collection(\"teams\")\n .getOne(team.id);\n expect(existingTeam).toBeDefined();\n\n context.admin.collection(\"users\").delete(memberUser.id);\n });\n});\n", Ed = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"$lib/schemas/team\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase\";\n\nexport const load = async () => {\n const form = await superValidate(zod4(teamSchema));\n return { form };\n};\n\nexport const actions = {\n default: async ({ locals, request, cookies }) => {\n const user = locals.pb.authStore.record!;\n const form = await superValidate(request, zod4(teamSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let team;\n\n try {\n team = await locals.pb.collection(\"teams\").create({\n name: form.data.name,\n owner: user.id,\n });\n } catch (error) {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n\n await locals.admin.collection(\"team_memberships\").create({\n user: user.id,\n team: team.id,\n role: \"owner\",\n });\n\n await locals.admin.collection(\"team_invite_links\").create({\n team: team.id,\n name: team.name,\n });\n\n redirect(\"/teams\", { type: \"toast\", message: \"Team created\" }, cookies);\n },\n};\n", Dd = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '$lib/components/ui/dialog';\n import { Input } from '$lib/components/ui/input';\n import { goto } from '$app/navigation';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '$lib/schemas/team';\n import * as Form from '$lib/components/ui/form';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(teamSchema)\n }\n );\n\n const { form: formData } = form;\n\n const handleOpenChange = (open: boolean) => {\n if (!open) {\n goto('/teams', { noScroll: true });\n }\n };\n<\/script>\n\n<Dialog.Root open onOpenChange={handleOpenChange}>\n <Dialog.Content>\n <form method=\"POST\">\n <Dialog.Header class=\"mb-4\">\n <Dialog.Title>Create Team</Dialog.Title>\n </Dialog.Header>\n <Form.Field {form} name=\"name\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Team Name</Form.Label>\n <Input {...props} type=\"text\" bind:value={$formData.name} />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n <Dialog.Footer class=\"mt-4\">\n <Form.Button>Create</Form.Button>\n </Dialog.Footer>\n </form>\n </Dialog.Content>\n</Dialog.Root>\n", Od = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'New team'\n });\n\n return { ...data, pageMetaTags };\n};\n", kd = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport * as devalue from \"devalue\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string; owner: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/new\", () => {\n it(\"authenticated user should be able to access new team page\", async (context) => {\n const response = await context.agent.get(\n \"/teams/new\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /teams/new\", () => {\n it(\"authenticated user should be able to create team with valid name\", async (context) => {\n const teamName = `Test Team ${Math.random().toString(36).slice(2)}`;\n\n await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: teamName,\n });\n\n // Verify team was created\n const teams = await context.admin.collection(\"teams\").getList(1, 1, {\n filter: `owner = \"${context.user.id}\" && name = \"${teamName}\"`,\n });\n expect(teams.items).toHaveLength(1);\n team = teams.items[0];\n expect(team.name).toBe(teamName);\n expect(team.owner).toBe(context.user.id);\n\n // Verify team membership was created\n const memberships = await context.admin\n .collection(\"team_memberships\")\n .getList(1, 1, {\n filter: `user = \"${context.user.id}\" && team = \"${team.id}\"`,\n });\n expect(memberships.items).toHaveLength(1);\n expect(memberships.items[0].role).toBe(\"owner\");\n });\n\n it(\"should return 400 for empty name\", async (context) => {\n const response = await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({\n name: \"\",\n });\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n\n it(\"should return 400 for missing name\", async (context) => {\n const response = await context.agent\n .post(\"/teams/new\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({});\n\n const data = devalue.parse(response.body.data);\n expect(data.form.valid).toBe(false);\n });\n});\n", Ad = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /teams\", () => {\n it(\"authenticated user should be able to access the teams page\", async (context) => {\n await context.agent.authenticateUser();\n const response = await context.agent.get(\"/teams\" satisfies Match<RouteId>);\n expect(response.status).toBe(200);\n });\n});\n", jd = "import { error, redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/environment\";\n\nexport const load = async ({ params, cookies, url, locals }) => {\n const { id } = params;\n const redirectUrl = url.searchParams.get(\"redirect\") ?? \"/dashboard\";\n\n try {\n await locals.pb.collection(\"teams\").getOne(id);\n } catch {\n return error(404, { message: \"Team not found\" });\n }\n\n cookies.set(\"team\", id, {\n path: \"/\",\n httpOnly: true,\n sameSite: \"lax\",\n secure: !dev,\n maxAge: 60 * 60 * 24 * 30,\n });\n\n return redirect(303, redirectUrl);\n};\n", Md = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/pocketbase\";\nimport type { RouteId } from \"./$types\";\n\nlet team: { id: string; name: string; owner: string };\n\nbeforeEach(async (context) => {\n await context.agent.authenticateUser();\n\n // Create a test team for the user\n const teamName = `Test Team ${Math.random().toString(36).slice(2)}`;\n team = await context.admin.collection(\"teams\").create({\n name: teamName,\n owner: context.user.id,\n });\n\n // Create team membership\n await context.admin.collection(\"team_memberships\").create({\n user: context.user.id,\n team: team.id,\n role: \"owner\",\n });\n});\n\nafterEach(async (context) => {\n try {\n await context.admin.collection(\"teams\").delete(team.id);\n } catch {}\n});\n\ndescribe(\"GET /teams/switch/[id]\", () => {\n it(\"should set team cookie and redirect to dashboard for valid team\", async (context) => {\n const response = await context.agent.get(\n `/teams/switch/${team.id}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(\"/dashboard\");\n\n // Check that the team cookie is set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeDefined();\n expect(cookies).toContain(`team=${team.id}`);\n });\n\n it(\"should redirect to custom redirect URL when provided\", async (context) => {\n const customRedirect = \"/teams\";\n const response = await context.agent.get(\n `/teams/switch/${team.id}?redirect=${encodeURIComponent(customRedirect)}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(303);\n expect(response.headers.location).toBe(customRedirect);\n\n // Check that the team cookie is still set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeDefined();\n expect(cookies).toContain(\"team=\" + team.id);\n });\n\n it(\"should return 404 error for non-existent team\", async (context) => {\n const nonExistentTeamId = \"non-existent-team-id\";\n const response = await context.agent.get(\n `/teams/switch/${nonExistentTeamId}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(404);\n\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeUndefined();\n });\n\n it(\"should return 404 error for invalid team ID format\", async (context) => {\n const invalidTeamId = \"invalid-id-format\";\n const response = await context.agent.get(\n `/teams/switch/${invalidTeamId}` satisfies Match<RouteId>,\n );\n\n expect(response.status).toBe(404);\n\n // Check that no team cookie is set\n const cookies = response.headers[\"set-cookie\"]?.[0];\n expect(cookies).toBeUndefined();\n });\n});\n", Nd = /* @__PURE__ */ Object.assign({
|
|
5533
|
+
"./creates/src/lib/components/team-switcher.svelte": Xu,
|
|
5534
|
+
"./creates/src/lib/schemas/team.ts": Zu,
|
|
5535
|
+
"./creates/src/lib/schemas/teamInvite.ts": Qu,
|
|
5536
|
+
"./creates/src/lib/schemas/teamRole.ts": $u,
|
|
5537
|
+
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte": ed,
|
|
5538
|
+
"./creates/src/routes/(app)/invite/[id]/+page.server.ts": td,
|
|
5539
|
+
"./creates/src/routes/(app)/invite/[id]/+page.svelte": nd,
|
|
5540
|
+
"./creates/src/routes/(app)/invite/[id]/+page.ts": rd,
|
|
5541
|
+
"./creates/src/routes/(app)/join/[id]/+layout@.svelte": id,
|
|
5542
|
+
"./creates/src/routes/(app)/join/[id]/+page.server.ts": ad,
|
|
5543
|
+
"./creates/src/routes/(app)/join/[id]/+page.svelte": od,
|
|
5544
|
+
"./creates/src/routes/(app)/join/[id]/+page.ts": sd,
|
|
5545
|
+
"./creates/src/routes/(app)/teams/+layout.server.ts": cd,
|
|
5546
|
+
"./creates/src/routes/(app)/teams/+layout.svelte": ld,
|
|
5547
|
+
"./creates/src/routes/(app)/teams/+page.server.ts": ud,
|
|
5435
5548
|
"./creates/src/routes/(app)/teams/+page.svelte": "",
|
|
5436
|
-
"./creates/src/routes/(app)/teams/+page.ts":
|
|
5437
|
-
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts":
|
|
5438
|
-
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte":
|
|
5439
|
-
"./creates/src/routes/(app)/teams/[id]/+page.server.ts":
|
|
5549
|
+
"./creates/src/routes/(app)/teams/+page.ts": dd,
|
|
5550
|
+
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts": fd,
|
|
5551
|
+
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": pd,
|
|
5552
|
+
"./creates/src/routes/(app)/teams/[id]/+page.server.ts": md,
|
|
5440
5553
|
"./creates/src/routes/(app)/teams/[id]/+page.svelte": "",
|
|
5441
|
-
"./creates/src/routes/(app)/teams/[id]/+page.ts":
|
|
5442
|
-
"./creates/src/routes/(app)/teams/[id]/authorization.ts":
|
|
5443
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts":
|
|
5444
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte":
|
|
5445
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts":
|
|
5446
|
-
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts":
|
|
5447
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts":
|
|
5448
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte":
|
|
5449
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts":
|
|
5450
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts":
|
|
5451
|
-
"./creates/src/routes/(app)/teams/[id]/server.test.ts":
|
|
5452
|
-
"./creates/src/routes/(app)/teams/new/+page.server.ts":
|
|
5453
|
-
"./creates/src/routes/(app)/teams/new/+page.svelte":
|
|
5454
|
-
"./creates/src/routes/(app)/teams/new/+page.ts":
|
|
5455
|
-
"./creates/src/routes/(app)/teams/new/server.test.ts":
|
|
5456
|
-
"./creates/src/routes/(app)/teams/server.test.ts":
|
|
5457
|
-
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts":
|
|
5458
|
-
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts":
|
|
5459
|
-
}),
|
|
5460
|
-
async function
|
|
5554
|
+
"./creates/src/routes/(app)/teams/[id]/+page.ts": hd,
|
|
5555
|
+
"./creates/src/routes/(app)/teams/[id]/authorization.ts": gd,
|
|
5556
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": _d,
|
|
5557
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte": vd,
|
|
5558
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts": yd,
|
|
5559
|
+
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts": bd,
|
|
5560
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": xd,
|
|
5561
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": Sd,
|
|
5562
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": Cd,
|
|
5563
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": wd,
|
|
5564
|
+
"./creates/src/routes/(app)/teams/[id]/server.test.ts": Td,
|
|
5565
|
+
"./creates/src/routes/(app)/teams/new/+page.server.ts": Ed,
|
|
5566
|
+
"./creates/src/routes/(app)/teams/new/+page.svelte": Dd,
|
|
5567
|
+
"./creates/src/routes/(app)/teams/new/+page.ts": Od,
|
|
5568
|
+
"./creates/src/routes/(app)/teams/new/server.test.ts": kd,
|
|
5569
|
+
"./creates/src/routes/(app)/teams/server.test.ts": Ad,
|
|
5570
|
+
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": jd,
|
|
5571
|
+
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts": Md
|
|
5572
|
+
}), Pd = "./creates/";
|
|
5573
|
+
async function Fd(e) {
|
|
5461
5574
|
return {
|
|
5462
|
-
creates: Object.entries(
|
|
5463
|
-
let n = o(e,
|
|
5575
|
+
creates: Object.entries(Nd).map(([e, t]) => {
|
|
5576
|
+
let n = o(e, Pd);
|
|
5464
5577
|
return {
|
|
5465
5578
|
path: n,
|
|
5466
5579
|
language: r(n),
|
|
@@ -5491,7 +5604,7 @@ async function yd(e) {
|
|
|
5491
5604
|
}
|
|
5492
5605
|
//#endregion
|
|
5493
5606
|
//#region src/patterns/enable/teams/preview-modifies/src/lib/components/app-sidebar.svelte?raw
|
|
5494
|
-
var
|
|
5607
|
+
var Id = "<script lang=\"ts\">\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '$lib/components/ui/sidebar';\n import NavMain from './nav-main.svelte';\n import NavUser from './nav-user.svelte';\n // [!code highlight:3]\n import TeamSwitcher from '$lib/components/team-switcher.svelte';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import * as Avatar from '$lib/components/ui/avatar';\n\n let data = {\n navMain: [\n {\n title: 'Dashboard',\n url: '/dashboard',\n icon: HomeIcon\n }\n ]\n };\n\n let {\n user,\n meta,\n team,\n teams = [],\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & {\n user: any;\n meta: any;\n team?: string | undefined;\n teams?: { id: string; name: string }[];\n } = $props();\n<\/script>\n\n<Sidebar.Root bind:ref variant=\"inset\" {...restProps}>\n <Sidebar.Header>\n <Sidebar.Menu>\n <TeamSwitcher {teams}>\n {#snippet children()}\n {@const activeTeam = teams.find((t) => t.id === team)}\n {#if activeTeam}\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n {activeTeam.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">\n {activeTeam.name}\n </span>\n </div>\n {:else}\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src=\"/favicon.svg\" alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{meta.appName}</span>\n </div>\n {/if}\n <ChevronsUpDownIcon class=\"ml-auto\" />\n {/snippet}\n </TeamSwitcher>\n </Sidebar.Menu>\n </Sidebar.Header>\n <Sidebar.Content>\n <NavMain items={data.navMain} />\n </Sidebar.Content>\n <Sidebar.Footer>\n <NavUser {user} />\n </Sidebar.Footer>\n</Sidebar.Root>\n", Ld = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n // [!code highlight:1]\n import UsersIcon from '@lucide/svelte/icons/users';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import * as Avatar from '$lib/components/ui/avatar';\n import * as DropdownMenu from '$lib/components/ui/dropdown-menu';\n import * as Sidebar from '$lib/components/ui/sidebar';\n\n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n },\n // [!code highlight:5]\n {\n title: 'Teams',\n url: '/teams',\n icon: UsersIcon\n }\n ]\n };\n\n let {\n user\n }: {\n user: {\n id: string;\n name: string;\n email: string;\n avatar: string;\n };\n } = $props();\n\n const sidebar = Sidebar.useSidebar();\n<\/script>\n\n<Sidebar.Menu>\n <Sidebar.MenuItem>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger>\n {#snippet child({ props })}\n <Sidebar.MenuButton\n size=\"lg\"\n class=\"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground\"\n {...props}\n >\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n <ChevronsUpDownIcon class=\"ml-auto size-4\" />\n </Sidebar.MenuButton>\n {/snippet}\n </DropdownMenu.Trigger>\n <DropdownMenu.Content\n class=\"w-(--bits-dropdown-menu-anchor-width) min-w-56 rounded-lg\"\n side={sidebar.isMobile ? 'bottom' : 'right'}\n align=\"end\"\n sideOffset={4}\n >\n <DropdownMenu.Label class=\"p-0 font-normal\">\n <div class=\"flex items-center gap-2 px-1 py-1.5 text-left text-sm\">\n <Avatar.Root class=\"size-8 rounded-lg\">\n {#if user.avatar}\n <Avatar.Image src=\"/api/files/users/{user.id}/{user.avatar}\" alt={user.name} />\n {/if}\n <Avatar.Fallback class=\"rounded-lg\">\n {user.name?.charAt(0).toUpperCase() || user.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{user.name || user.email}</span>\n </div>\n </div>\n </DropdownMenu.Label>\n <DropdownMenu.Separator />\n <DropdownMenu.Group>\n <DropdownMenu.Item onclick={toggleMode}>\n {#if mode.current === 'dark'}\n <SunIcon />\n Light mode\n {:else}\n <MoonIcon />\n Dark mode\n {/if}\n </DropdownMenu.Item>\n {#each data.navUser as item}\n <DropdownMenu.Item class=\"p-0\">\n <a href={item.url} class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <item.icon />\n {item.title}\n </a>\n </DropdownMenu.Item>\n {/each}\n </DropdownMenu.Group>\n <DropdownMenu.Separator />\n <DropdownMenu.Item class=\"p-0\">\n <form action=\"/logout\" method=\"post\" class=\"w-full\">\n <button type=\"submit\" class=\"flex cursor-default items-center gap-2 px-2 py-1.5 w-full\">\n <LogOutIcon />\n Log out\n </button>\n </form>\n </DropdownMenu.Item>\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </Sidebar.MenuItem>\n</Sidebar.Menu>\n", Rd = "export const load = async ({ locals, depends }) => {\n const user = locals.pb.authStore.record!;\n // [!code highlight:3]\n const team = locals.team;\n const teams = await locals.pb.collection(\"teams\").getFullList();\n depends(\"app:team\");\n\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n\n return { user, team, teams, breadcrumbs };\n};\n", zd = "<script lang=\"ts\">\n import * as Sidebar from '$lib/components/ui/sidebar';\n import { Separator } from '$lib/components/ui/separator';\n import AppSidebar from '$lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '$lib/components/ui/breadcrumb';\n import { page } from '$app/state';\n\n let breadcrumbs = $derived(page.data.breadcrumbs || []) as { title: string; url: string }[];\n let { data, children } = $props();\n<\/script>\n\n<div class=\"min-h-dvh dashboard\">\n <Sidebar.Provider>\n <!-- [!code highlight:1] -->\n <AppSidebar user={data.user} meta={data.meta} team={data.team} teams={data.teams ?? []} />\n <Sidebar.Inset>\n <header class=\"flex h-16 shrink-0 items-center gap-2\">\n <div class=\"flex items-center gap-2 px-4\">\n <Sidebar.Trigger class=\"-ml-1\" />\n <Separator orientation=\"vertical\" class=\"mr-2 data-[orientation=vertical]:h-4\" />\n {#if breadcrumbs.length > 0}\n <Breadcrumb.Root>\n <Breadcrumb.List>\n {#if breadcrumbs.length > 1}\n {#each breadcrumbs.slice(0, -1) as breadcrumb}\n <Breadcrumb.Item>\n <Breadcrumb.Link href={breadcrumb.url}>{breadcrumb.title}</Breadcrumb.Link>\n </Breadcrumb.Item>\n <Breadcrumb.Separator />\n {/each}\n {/if}\n <Breadcrumb.Page>\n {breadcrumbs[breadcrumbs.length - 1].title}\n </Breadcrumb.Page>\n </Breadcrumb.List>\n </Breadcrumb.Root>\n {/if}\n </div>\n </header>\n <div class=\"flex flex-1 flex-col p-4 pt-0\">\n {@render children?.()}\n </div>\n </Sidebar.Inset>\n </Sidebar.Provider>\n</div>\n\n<style>\n :global(body:has(div.dashboard)) {\n background-color: var(--color-sidebar);\n }\n</style>\n", Bd = "users", Q = "teams", Vd = "team_memberships";
|
|
5495
5608
|
function $(e) {
|
|
5496
5609
|
let t = ae.find((t) => t.collectionName === e);
|
|
5497
5610
|
if (!t) throw Error(`teams: missing TEAM_RULE_PATCHES entry for "${e}"`);
|
|
@@ -5503,7 +5616,7 @@ function $(e) {
|
|
|
5503
5616
|
deleteRule: t.deleteRule
|
|
5504
5617
|
};
|
|
5505
5618
|
}
|
|
5506
|
-
var
|
|
5619
|
+
var Hd = [
|
|
5507
5620
|
{
|
|
5508
5621
|
name: "teams",
|
|
5509
5622
|
type: "base",
|
|
@@ -5528,7 +5641,7 @@ var Ed = [
|
|
|
5528
5641
|
name: "owner",
|
|
5529
5642
|
type: "relation",
|
|
5530
5643
|
cascadeDelete: !1,
|
|
5531
|
-
collectionId:
|
|
5644
|
+
collectionId: Bd,
|
|
5532
5645
|
maxSelect: 1,
|
|
5533
5646
|
minSelect: 0,
|
|
5534
5647
|
required: !0
|
|
@@ -5574,7 +5687,7 @@ var Ed = [
|
|
|
5574
5687
|
{
|
|
5575
5688
|
name: "user",
|
|
5576
5689
|
cascadeDelete: !0,
|
|
5577
|
-
collectionId:
|
|
5690
|
+
collectionId: Bd,
|
|
5578
5691
|
maxSelect: 1,
|
|
5579
5692
|
minSelect: 0,
|
|
5580
5693
|
required: !0,
|
|
@@ -5634,7 +5747,7 @@ var Ed = [
|
|
|
5634
5747
|
{
|
|
5635
5748
|
name: "membership_id",
|
|
5636
5749
|
cascadeDelete: !1,
|
|
5637
|
-
collectionId:
|
|
5750
|
+
collectionId: Vd,
|
|
5638
5751
|
maxSelect: 1,
|
|
5639
5752
|
minSelect: 0,
|
|
5640
5753
|
required: !1,
|
|
@@ -5744,17 +5857,17 @@ var Ed = [
|
|
|
5744
5857
|
}
|
|
5745
5858
|
]
|
|
5746
5859
|
}
|
|
5747
|
-
],
|
|
5748
|
-
"./preview-modifies/src/lib/components/app-sidebar.svelte":
|
|
5749
|
-
"./preview-modifies/src/lib/components/nav-user.svelte":
|
|
5750
|
-
"./preview-modifies/src/routes/(app)/+layout.server.ts":
|
|
5751
|
-
"./preview-modifies/src/routes/(app)/+layout.svelte":
|
|
5752
|
-
}),
|
|
5753
|
-
async function
|
|
5860
|
+
], Ud = /* @__PURE__ */ Object.assign({
|
|
5861
|
+
"./preview-modifies/src/lib/components/app-sidebar.svelte": Id,
|
|
5862
|
+
"./preview-modifies/src/lib/components/nav-user.svelte": Ld,
|
|
5863
|
+
"./preview-modifies/src/routes/(app)/+layout.server.ts": Rd,
|
|
5864
|
+
"./preview-modifies/src/routes/(app)/+layout.svelte": zd
|
|
5865
|
+
}), Wd = "./preview-modifies/";
|
|
5866
|
+
async function Gd(e) {
|
|
5754
5867
|
return {
|
|
5755
5868
|
creates: [],
|
|
5756
|
-
modifies: Object.entries(
|
|
5757
|
-
let n = o(e,
|
|
5869
|
+
modifies: Object.entries(Ud).map(([e, t]) => {
|
|
5870
|
+
let n = o(e, Wd);
|
|
5758
5871
|
return {
|
|
5759
5872
|
path: n,
|
|
5760
5873
|
language: r(n),
|
|
@@ -5765,25 +5878,25 @@ async function kd(e) {
|
|
|
5765
5878
|
deletes: [],
|
|
5766
5879
|
components: [],
|
|
5767
5880
|
packages: [],
|
|
5768
|
-
collections:
|
|
5881
|
+
collections: Hd,
|
|
5769
5882
|
collectionPatches: [],
|
|
5770
5883
|
collectionDrops: []
|
|
5771
5884
|
};
|
|
5772
5885
|
}
|
|
5773
5886
|
//#endregion
|
|
5774
5887
|
//#region src/patterns/enable/teams/index.ts
|
|
5775
|
-
var
|
|
5776
|
-
async function
|
|
5777
|
-
let t = await
|
|
5778
|
-
if (e.env === "preview") return y(n([t, await
|
|
5779
|
-
let { generate: r } = await import("./chunks/
|
|
5888
|
+
var Kd = "enable-teams", qd = "1.0.0", Jd = "src/patterns/enable/teams", Yd = "/enable/teams";
|
|
5889
|
+
async function Xd(e) {
|
|
5890
|
+
let t = await Fd(e);
|
|
5891
|
+
if (e.env === "preview") return y(n([t, await Gd(e)]));
|
|
5892
|
+
let { generate: r } = await import("./chunks/generate2.runtime-yP14iPwX.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5780
5893
|
return a(await y(n([t, i])), e);
|
|
5781
5894
|
}
|
|
5782
|
-
var
|
|
5783
|
-
version:
|
|
5784
|
-
slug:
|
|
5785
|
-
source:
|
|
5786
|
-
docs:
|
|
5895
|
+
var Zd = {
|
|
5896
|
+
version: qd,
|
|
5897
|
+
slug: Kd,
|
|
5898
|
+
source: Jd,
|
|
5899
|
+
docs: Yd,
|
|
5787
5900
|
plan: "pro",
|
|
5788
5901
|
title: "Enable teams",
|
|
5789
5902
|
summary: "Adds multi-tenant teams with memberships, invites, and a sidebar team switcher.",
|
|
@@ -5791,6 +5904,7 @@ var Fd = {
|
|
|
5791
5904
|
auth: !0,
|
|
5792
5905
|
api: !1,
|
|
5793
5906
|
apiKeys: !1,
|
|
5907
|
+
backend: !0,
|
|
5794
5908
|
i18n: !1,
|
|
5795
5909
|
teams: !1,
|
|
5796
5910
|
payments: !1,
|
|
@@ -5814,11 +5928,11 @@ var Fd = {
|
|
|
5814
5928
|
examples: [],
|
|
5815
5929
|
tests: 36,
|
|
5816
5930
|
baseline: "velastack",
|
|
5817
|
-
generate:
|
|
5931
|
+
generate: Xd
|
|
5818
5932
|
};
|
|
5819
5933
|
//#endregion
|
|
5820
5934
|
//#region src/patterns/destroy/schema/generate.ts
|
|
5821
|
-
async function
|
|
5935
|
+
async function Qd(t) {
|
|
5822
5936
|
let [n] = t.argv;
|
|
5823
5937
|
if (!n) throw new e("Invalid command arguments. Expected: <model>");
|
|
5824
5938
|
let i = `src/lib/schemas/${A(n, t).name}.ts`;
|
|
@@ -5840,18 +5954,18 @@ async function Id(t) {
|
|
|
5840
5954
|
}
|
|
5841
5955
|
//#endregion
|
|
5842
5956
|
//#region src/patterns/destroy/schema/index.ts
|
|
5843
|
-
var
|
|
5844
|
-
async function
|
|
5845
|
-
let t = await y(await
|
|
5957
|
+
var $d = "destroy-schema", ef = "1.0.0", tf = "src/patterns/destroy/schema", nf = "/destroy/schema";
|
|
5958
|
+
async function rf(e) {
|
|
5959
|
+
let t = await y(await Qd(e));
|
|
5846
5960
|
if (e.env !== "runtime" || e.input.destructive !== !0) return t;
|
|
5847
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
5961
|
+
let { writeResult: n } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5848
5962
|
return n(t, e);
|
|
5849
5963
|
}
|
|
5850
|
-
var
|
|
5851
|
-
version:
|
|
5852
|
-
slug:
|
|
5853
|
-
source:
|
|
5854
|
-
docs:
|
|
5964
|
+
var af = {
|
|
5965
|
+
version: ef,
|
|
5966
|
+
slug: $d,
|
|
5967
|
+
source: tf,
|
|
5968
|
+
docs: nf,
|
|
5855
5969
|
plan: "open",
|
|
5856
5970
|
title: "Destroy a schema",
|
|
5857
5971
|
summary: "Removes the zod schema file created by generate-schema.",
|
|
@@ -5859,6 +5973,7 @@ var Hd = {
|
|
|
5859
5973
|
auth: !1,
|
|
5860
5974
|
api: !1,
|
|
5861
5975
|
apiKeys: !1,
|
|
5976
|
+
backend: !0,
|
|
5862
5977
|
i18n: !1,
|
|
5863
5978
|
teams: !1,
|
|
5864
5979
|
payments: !1,
|
|
@@ -5882,9 +5997,9 @@ var Hd = {
|
|
|
5882
5997
|
}],
|
|
5883
5998
|
tests: 0,
|
|
5884
5999
|
baseline: "velastack",
|
|
5885
|
-
generate:
|
|
5886
|
-
},
|
|
5887
|
-
async function
|
|
6000
|
+
generate: rf
|
|
6001
|
+
}, of = "destroy-form", sf = "1.0.0", cf = "src/patterns/destroy/form", lf = "/destroy/form";
|
|
6002
|
+
async function uf(t) {
|
|
5888
6003
|
let [n] = t.argv;
|
|
5889
6004
|
if (!n) throw new e("Invalid command arguments. Expected: <model>");
|
|
5890
6005
|
let r = A(n, t), i = n.replace(/^\/+|\/+$/g, ""), a = `${r.routesDir}/${i}`, o = `src/lib/schemas/${r.name}.ts`, s = await y({
|
|
@@ -5898,14 +6013,14 @@ async function qd(t) {
|
|
|
5898
6013
|
collectionDrops: []
|
|
5899
6014
|
});
|
|
5900
6015
|
if (t.env !== "runtime" || t.input.destructive !== !0) return s;
|
|
5901
|
-
let { writeResult: c } = await import("./chunks/write-result-
|
|
6016
|
+
let { writeResult: c } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5902
6017
|
return c(s, t);
|
|
5903
6018
|
}
|
|
5904
|
-
var
|
|
5905
|
-
version:
|
|
5906
|
-
slug:
|
|
5907
|
-
source:
|
|
5908
|
-
docs:
|
|
6019
|
+
var df = {
|
|
6020
|
+
version: sf,
|
|
6021
|
+
slug: of,
|
|
6022
|
+
source: cf,
|
|
6023
|
+
docs: lf,
|
|
5909
6024
|
plan: "open",
|
|
5910
6025
|
title: "Destroy a form",
|
|
5911
6026
|
summary: "Removes the route directory and schema file created by generate-form.",
|
|
@@ -5913,6 +6028,7 @@ var Jd = {
|
|
|
5913
6028
|
auth: !1,
|
|
5914
6029
|
api: !1,
|
|
5915
6030
|
apiKeys: !1,
|
|
6031
|
+
backend: !0,
|
|
5916
6032
|
i18n: !1,
|
|
5917
6033
|
teams: !1,
|
|
5918
6034
|
payments: !1,
|
|
@@ -5936,9 +6052,9 @@ var Jd = {
|
|
|
5936
6052
|
}],
|
|
5937
6053
|
tests: 0,
|
|
5938
6054
|
baseline: "velastack",
|
|
5939
|
-
generate:
|
|
5940
|
-
},
|
|
5941
|
-
async function
|
|
6055
|
+
generate: uf
|
|
6056
|
+
}, ff = "destroy-resource", pf = "1.0.0", mf = "src/patterns/destroy/resource", hf = "/destroy/resource";
|
|
6057
|
+
async function gf(t) {
|
|
5942
6058
|
let [n] = t.argv;
|
|
5943
6059
|
if (!n) throw new e("Invalid command arguments. Expected: <model>");
|
|
5944
6060
|
let r = A(n, t), i = `src/lib/schemas/${r.name}.ts`, a = await oe([r.tableName], t), o = await y({
|
|
@@ -5952,14 +6068,14 @@ async function $d(t) {
|
|
|
5952
6068
|
collectionDrops: a
|
|
5953
6069
|
});
|
|
5954
6070
|
if (t.env !== "runtime" || t.input.destructive !== !0) return o;
|
|
5955
|
-
let { writeResult: s } = await import("./chunks/write-result-
|
|
6071
|
+
let { writeResult: s } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5956
6072
|
return s(o, t);
|
|
5957
6073
|
}
|
|
5958
|
-
var
|
|
5959
|
-
version:
|
|
5960
|
-
slug:
|
|
5961
|
-
source:
|
|
5962
|
-
docs:
|
|
6074
|
+
var _f = {
|
|
6075
|
+
version: pf,
|
|
6076
|
+
slug: ff,
|
|
6077
|
+
source: mf,
|
|
6078
|
+
docs: hf,
|
|
5963
6079
|
plan: "open",
|
|
5964
6080
|
title: "Destroy a resource",
|
|
5965
6081
|
summary: "Drops the collection and removes the schema file created by generate-resource.",
|
|
@@ -5967,6 +6083,7 @@ var ef = {
|
|
|
5967
6083
|
auth: !1,
|
|
5968
6084
|
api: !1,
|
|
5969
6085
|
apiKeys: !1,
|
|
6086
|
+
backend: !0,
|
|
5970
6087
|
i18n: !1,
|
|
5971
6088
|
teams: !1,
|
|
5972
6089
|
payments: !1,
|
|
@@ -5990,9 +6107,9 @@ var ef = {
|
|
|
5990
6107
|
}],
|
|
5991
6108
|
tests: 0,
|
|
5992
6109
|
baseline: "velastack",
|
|
5993
|
-
generate:
|
|
5994
|
-
},
|
|
5995
|
-
async function
|
|
6110
|
+
generate: gf
|
|
6111
|
+
}, vf = "destroy-scaffold", yf = "1.0.0", bf = "src/patterns/destroy/scaffold", xf = "/destroy/scaffold";
|
|
6112
|
+
async function Sf(t) {
|
|
5996
6113
|
let [n] = t.argv;
|
|
5997
6114
|
if (!n) throw new e("Invalid command arguments. Expected: <model>");
|
|
5998
6115
|
let r = A(n, t), i = dt(r), a = `src/lib/schemas/${r.name}.ts`, o = await oe([r.tableName], t), s = await y({
|
|
@@ -6006,14 +6123,14 @@ async function of(t) {
|
|
|
6006
6123
|
collectionDrops: o
|
|
6007
6124
|
});
|
|
6008
6125
|
if (t.env !== "runtime" || t.input.destructive !== !0) return s;
|
|
6009
|
-
let { writeResult: c } = await import("./chunks/write-result-
|
|
6126
|
+
let { writeResult: c } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6010
6127
|
return c(s, t);
|
|
6011
6128
|
}
|
|
6012
|
-
var
|
|
6013
|
-
version:
|
|
6014
|
-
slug:
|
|
6015
|
-
source:
|
|
6016
|
-
docs:
|
|
6129
|
+
var Cf = {
|
|
6130
|
+
version: yf,
|
|
6131
|
+
slug: vf,
|
|
6132
|
+
source: bf,
|
|
6133
|
+
docs: xf,
|
|
6017
6134
|
plan: "open",
|
|
6018
6135
|
title: "Destroy a scaffold",
|
|
6019
6136
|
summary: "Removes the route directory and schema file created by generate-scaffold and drops the collection. Retains shadcn components.",
|
|
@@ -6021,6 +6138,7 @@ var sf = {
|
|
|
6021
6138
|
auth: !1,
|
|
6022
6139
|
api: !1,
|
|
6023
6140
|
apiKeys: !1,
|
|
6141
|
+
backend: !0,
|
|
6024
6142
|
i18n: !1,
|
|
6025
6143
|
teams: !1,
|
|
6026
6144
|
payments: !1,
|
|
@@ -6045,14 +6163,14 @@ var sf = {
|
|
|
6045
6163
|
}],
|
|
6046
6164
|
tests: 0,
|
|
6047
6165
|
baseline: "velastack",
|
|
6048
|
-
generate:
|
|
6049
|
-
},
|
|
6050
|
-
async function
|
|
6166
|
+
generate: Sf
|
|
6167
|
+
}, wf = /* @__PURE__ */ Object.assign({ "../../enable/api/creates/src/routes/api/server.test.ts": Wo }), Tf = "../../enable/api/creates/";
|
|
6168
|
+
async function Ef(e) {
|
|
6051
6169
|
return {
|
|
6052
6170
|
creates: [],
|
|
6053
6171
|
modifies: [],
|
|
6054
|
-
deletes: Object.keys(
|
|
6055
|
-
let t = o(e,
|
|
6172
|
+
deletes: Object.keys(wf).map((e) => {
|
|
6173
|
+
let t = o(e, Tf);
|
|
6056
6174
|
return {
|
|
6057
6175
|
path: t,
|
|
6058
6176
|
language: r(t),
|
|
@@ -6069,20 +6187,20 @@ async function uf(e) {
|
|
|
6069
6187
|
}
|
|
6070
6188
|
//#endregion
|
|
6071
6189
|
//#region src/patterns/disable/api/index.ts
|
|
6072
|
-
var
|
|
6073
|
-
async function
|
|
6074
|
-
let t = await
|
|
6190
|
+
var Df = "disable-api", Of = "1.0.0", kf = "src/patterns/disable/api", Af = "/disable/api";
|
|
6191
|
+
async function jf(e) {
|
|
6192
|
+
let t = await Ef(e);
|
|
6075
6193
|
if (e.env !== "runtime") return y(t);
|
|
6076
6194
|
let { generate: r } = await import("./chunks/generate.runtime-CZALdXt6.js"), i = await y(n([t, await r(e)]));
|
|
6077
6195
|
if (e.input.destructive !== !0) return i;
|
|
6078
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6196
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6079
6197
|
return a(i, e);
|
|
6080
6198
|
}
|
|
6081
|
-
var
|
|
6082
|
-
version:
|
|
6083
|
-
slug:
|
|
6084
|
-
source:
|
|
6085
|
-
docs:
|
|
6199
|
+
var Mf = {
|
|
6200
|
+
version: Of,
|
|
6201
|
+
slug: Df,
|
|
6202
|
+
source: kf,
|
|
6203
|
+
docs: Af,
|
|
6086
6204
|
plan: "open",
|
|
6087
6205
|
title: "Disable API",
|
|
6088
6206
|
summary: "Disables the PocketBase API handler.",
|
|
@@ -6090,6 +6208,7 @@ var gf = {
|
|
|
6090
6208
|
auth: !1,
|
|
6091
6209
|
api: !0,
|
|
6092
6210
|
apiKeys: !1,
|
|
6211
|
+
backend: !0,
|
|
6093
6212
|
i18n: !1,
|
|
6094
6213
|
teams: !1,
|
|
6095
6214
|
payments: !1,
|
|
@@ -6113,8 +6232,8 @@ var gf = {
|
|
|
6113
6232
|
examples: [],
|
|
6114
6233
|
tests: 0,
|
|
6115
6234
|
baseline: "velastack",
|
|
6116
|
-
generate:
|
|
6117
|
-
},
|
|
6235
|
+
generate: jf
|
|
6236
|
+
}, Nf = /* @__PURE__ */ Object.assign({
|
|
6118
6237
|
"../../enable/api-keys/creates/src/lib/schemas/apiKey.ts": rs,
|
|
6119
6238
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.server.ts": is,
|
|
6120
6239
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.svelte": as,
|
|
@@ -6127,13 +6246,13 @@ var gf = {
|
|
|
6127
6246
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/create-api-key.ts": ds,
|
|
6128
6247
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/server.test.ts": fs,
|
|
6129
6248
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/server.test.ts": ps
|
|
6130
|
-
}),
|
|
6131
|
-
async function
|
|
6249
|
+
}), Pf = "../../enable/api-keys/creates/";
|
|
6250
|
+
async function Ff(e) {
|
|
6132
6251
|
return {
|
|
6133
6252
|
creates: [],
|
|
6134
6253
|
modifies: [],
|
|
6135
|
-
deletes: Object.keys(
|
|
6136
|
-
let t = o(e,
|
|
6254
|
+
deletes: Object.keys(Nf).map((e) => {
|
|
6255
|
+
let t = o(e, Pf);
|
|
6137
6256
|
return {
|
|
6138
6257
|
path: t,
|
|
6139
6258
|
language: r(t),
|
|
@@ -6150,20 +6269,20 @@ async function yf(e) {
|
|
|
6150
6269
|
}
|
|
6151
6270
|
//#endregion
|
|
6152
6271
|
//#region src/patterns/disable/api-keys/index.ts
|
|
6153
|
-
var
|
|
6154
|
-
async function
|
|
6155
|
-
let t = await
|
|
6272
|
+
var If = "disable-api-keys", Lf = "1.0.0", Rf = "src/patterns/disable/api-keys", zf = "/disable/api-keys";
|
|
6273
|
+
async function Bf(e) {
|
|
6274
|
+
let t = await Ff(e);
|
|
6156
6275
|
if (e.env !== "runtime") return y(t);
|
|
6157
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6276
|
+
let { generate: r } = await import("./chunks/generate.runtime-D1wqmaXU.js"), i = await y(n([t, await r(e)]));
|
|
6158
6277
|
if (e.input.destructive !== !0) return i;
|
|
6159
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6278
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6160
6279
|
return a(i, e);
|
|
6161
6280
|
}
|
|
6162
|
-
var
|
|
6163
|
-
version:
|
|
6164
|
-
slug:
|
|
6165
|
-
source:
|
|
6166
|
-
docs:
|
|
6281
|
+
var Vf = {
|
|
6282
|
+
version: Lf,
|
|
6283
|
+
slug: If,
|
|
6284
|
+
source: Rf,
|
|
6285
|
+
docs: zf,
|
|
6167
6286
|
plan: "open",
|
|
6168
6287
|
title: "Disable API keys",
|
|
6169
6288
|
summary: "Removes API key management: drops the api_keys collection, reverts hooks.server and nav-user, deletes generated API key routes.",
|
|
@@ -6171,6 +6290,7 @@ var Tf = {
|
|
|
6171
6290
|
auth: !0,
|
|
6172
6291
|
api: !0,
|
|
6173
6292
|
apiKeys: !0,
|
|
6293
|
+
backend: !0,
|
|
6174
6294
|
i18n: !1,
|
|
6175
6295
|
teams: !1,
|
|
6176
6296
|
payments: !1,
|
|
@@ -6194,8 +6314,8 @@ var Tf = {
|
|
|
6194
6314
|
examples: [],
|
|
6195
6315
|
tests: 0,
|
|
6196
6316
|
baseline: "velastack",
|
|
6197
|
-
generate:
|
|
6198
|
-
},
|
|
6317
|
+
generate: Bf
|
|
6318
|
+
}, Hf = /* @__PURE__ */ Object.assign({
|
|
6199
6319
|
"../../enable/auth/creates/src/lib/components/app-sidebar.svelte": xi,
|
|
6200
6320
|
"../../enable/auth/creates/src/lib/components/nav-main.svelte": Si,
|
|
6201
6321
|
"../../enable/auth/creates/src/lib/components/nav-user.svelte": Ci,
|
|
@@ -6245,7 +6365,7 @@ var Tf = {
|
|
|
6245
6365
|
"../../enable/auth/creates/src/routes/(public)/signup/+page.svelte": fa,
|
|
6246
6366
|
"../../enable/auth/creates/src/routes/(public)/signup/+page.ts": pa,
|
|
6247
6367
|
"../../enable/auth/creates/src/routes/(public)/signup/server.test.ts": ma
|
|
6248
|
-
}),
|
|
6368
|
+
}), Uf = /* @__PURE__ */ Object.assign({
|
|
6249
6369
|
"../../enable/auth-remote/creates/src/lib/components/app-sidebar.svelte": Aa,
|
|
6250
6370
|
"../../enable/auth-remote/creates/src/lib/components/nav-main.svelte": ja,
|
|
6251
6371
|
"../../enable/auth-remote/creates/src/lib/components/nav-user.svelte": Ma,
|
|
@@ -6302,11 +6422,11 @@ var Tf = {
|
|
|
6302
6422
|
"../../enable/auth-remote/creates/src/routes/(public)/signup/+page.ts": ko,
|
|
6303
6423
|
"../../enable/auth-remote/creates/src/routes/(public)/signup/form.remote.ts": Ao,
|
|
6304
6424
|
"../../enable/auth-remote/creates/src/routes/(public)/signup/server.test.ts": jo
|
|
6305
|
-
}),
|
|
6306
|
-
async function
|
|
6425
|
+
}), Wf = "../../enable/auth/creates/", Gf = "../../enable/auth-remote/creates/";
|
|
6426
|
+
async function Kf(e) {
|
|
6307
6427
|
let t = /* @__PURE__ */ new Set();
|
|
6308
|
-
for (let e of Object.keys(
|
|
6309
|
-
for (let e of Object.keys(
|
|
6428
|
+
for (let e of Object.keys(Hf)) t.add(o(e, Wf));
|
|
6429
|
+
for (let e of Object.keys(Uf)) t.add(o(e, Gf));
|
|
6310
6430
|
return {
|
|
6311
6431
|
creates: [],
|
|
6312
6432
|
modifies: [],
|
|
@@ -6325,20 +6445,20 @@ async function Af(e) {
|
|
|
6325
6445
|
}
|
|
6326
6446
|
//#endregion
|
|
6327
6447
|
//#region src/patterns/disable/auth/index.ts
|
|
6328
|
-
var
|
|
6329
|
-
async function
|
|
6330
|
-
let t = await
|
|
6448
|
+
var qf = "disable-auth", Jf = "1.0.0", Yf = "src/patterns/disable/auth", Xf = "/disable/auth";
|
|
6449
|
+
async function Zf(e) {
|
|
6450
|
+
let t = await Kf(e);
|
|
6331
6451
|
if (e.env !== "runtime") return y(t);
|
|
6332
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6452
|
+
let { generate: r } = await import("./chunks/generate.runtime-DPzrDUU7.js"), i = await y(n([t, await r(e)]));
|
|
6333
6453
|
if (e.input.destructive !== !0) return i;
|
|
6334
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6454
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6335
6455
|
return a(i, e);
|
|
6336
6456
|
}
|
|
6337
|
-
var
|
|
6338
|
-
version:
|
|
6339
|
-
slug:
|
|
6340
|
-
source:
|
|
6341
|
-
docs:
|
|
6457
|
+
var Qf = {
|
|
6458
|
+
version: Jf,
|
|
6459
|
+
slug: qf,
|
|
6460
|
+
source: Yf,
|
|
6461
|
+
docs: Xf,
|
|
6342
6462
|
plan: "open",
|
|
6343
6463
|
title: "Disable auth",
|
|
6344
6464
|
summary: "Reverts auth integration (including the remote-functions variant): removes auth routes, reverts layout/hooks edits, drops oauth_accounts. Does NOT delete the users collection or user data.",
|
|
@@ -6346,6 +6466,7 @@ var If = {
|
|
|
6346
6466
|
auth: !0,
|
|
6347
6467
|
api: !1,
|
|
6348
6468
|
apiKeys: !1,
|
|
6469
|
+
backend: !0,
|
|
6349
6470
|
i18n: !1,
|
|
6350
6471
|
teams: !1,
|
|
6351
6472
|
payments: !1,
|
|
@@ -6367,19 +6488,96 @@ var If = {
|
|
|
6367
6488
|
examples: [],
|
|
6368
6489
|
tests: 0,
|
|
6369
6490
|
baseline: "velastack-auth",
|
|
6370
|
-
generate:
|
|
6371
|
-
},
|
|
6372
|
-
"../../enable/
|
|
6373
|
-
"../../enable/
|
|
6374
|
-
"../../enable/
|
|
6375
|
-
"../../enable/
|
|
6376
|
-
}),
|
|
6377
|
-
async function
|
|
6491
|
+
generate: Zf
|
|
6492
|
+
}, $f = /* @__PURE__ */ Object.assign({
|
|
6493
|
+
"../../enable/backend/creates/data/fixtures/README.md": Ds,
|
|
6494
|
+
"../../enable/backend/creates/data/hooks/README.md": Os,
|
|
6495
|
+
"../../enable/backend/creates/data/seeds/README.md": ks,
|
|
6496
|
+
"../../enable/backend/creates/src/hooks.server.ts": As
|
|
6497
|
+
}), ep = "../../enable/backend/creates/";
|
|
6498
|
+
async function tp(e) {
|
|
6499
|
+
return {
|
|
6500
|
+
creates: [],
|
|
6501
|
+
modifies: [],
|
|
6502
|
+
deletes: Object.keys($f).map((e) => {
|
|
6503
|
+
let t = o(e, ep);
|
|
6504
|
+
return {
|
|
6505
|
+
path: t,
|
|
6506
|
+
language: r(t),
|
|
6507
|
+
content: "",
|
|
6508
|
+
status: "success"
|
|
6509
|
+
};
|
|
6510
|
+
}).concat([{
|
|
6511
|
+
path: "data",
|
|
6512
|
+
language: r("data"),
|
|
6513
|
+
content: "",
|
|
6514
|
+
status: "success"
|
|
6515
|
+
}]).sort((e, t) => e.path.localeCompare(t.path)),
|
|
6516
|
+
components: [],
|
|
6517
|
+
packages: [],
|
|
6518
|
+
collections: [],
|
|
6519
|
+
collectionPatches: [],
|
|
6520
|
+
collectionDrops: []
|
|
6521
|
+
};
|
|
6522
|
+
}
|
|
6523
|
+
//#endregion
|
|
6524
|
+
//#region src/patterns/disable/backend/index.ts
|
|
6525
|
+
var np = "disable-backend", rp = "1.0.0", ip = "src/patterns/disable/backend", ap = "/disable/backend";
|
|
6526
|
+
async function op(e) {
|
|
6527
|
+
let t = await tp(e);
|
|
6528
|
+
if (e.env !== "runtime") return y(t);
|
|
6529
|
+
let { generate: r } = await import("./chunks/generate.runtime-D6oE0Mmf.js"), i = await y(n([t, await r(e)]));
|
|
6530
|
+
if (e.input.destructive !== !0) return i;
|
|
6531
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6532
|
+
return a(i, e);
|
|
6533
|
+
}
|
|
6534
|
+
var sp = {
|
|
6535
|
+
version: rp,
|
|
6536
|
+
slug: np,
|
|
6537
|
+
source: ip,
|
|
6538
|
+
docs: ap,
|
|
6539
|
+
plan: "open",
|
|
6540
|
+
title: "Disable Backend",
|
|
6541
|
+
summary: "Removes the PocketBase backend wiring: deletes hooks.server.ts and the data/ scaffold, switches the SvelteKit adapter back to static with SPA fallback, and reverts test/setup.ts. Leaves @velastack/pocketbase and pocketbase-sveltekit installed; uninstall manually.",
|
|
6542
|
+
requires: {
|
|
6543
|
+
auth: !1,
|
|
6544
|
+
api: !1,
|
|
6545
|
+
apiKeys: !1,
|
|
6546
|
+
backend: !0,
|
|
6547
|
+
i18n: !1,
|
|
6548
|
+
teams: !1,
|
|
6549
|
+
payments: !1,
|
|
6550
|
+
blog: !1,
|
|
6551
|
+
contentNegotiation: !1
|
|
6552
|
+
},
|
|
6553
|
+
category: "backend",
|
|
6554
|
+
tags: [
|
|
6555
|
+
"sveltekit",
|
|
6556
|
+
"pocketbase",
|
|
6557
|
+
"backend",
|
|
6558
|
+
"velastack"
|
|
6559
|
+
],
|
|
6560
|
+
command: {
|
|
6561
|
+
raw: "vela disable backend",
|
|
6562
|
+
base: "vela disable backend",
|
|
6563
|
+
argv: []
|
|
6564
|
+
},
|
|
6565
|
+
examples: [],
|
|
6566
|
+
tests: 0,
|
|
6567
|
+
baseline: "velastack",
|
|
6568
|
+
generate: op
|
|
6569
|
+
}, cp = /* @__PURE__ */ Object.assign({
|
|
6570
|
+
"../../enable/content-negotiation/creates/src/lib/negotiate.ts": Ec,
|
|
6571
|
+
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.server.ts": Dc,
|
|
6572
|
+
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.svelte": Oc,
|
|
6573
|
+
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.ts": kc
|
|
6574
|
+
}), lp = "../../enable/content-negotiation/creates/";
|
|
6575
|
+
async function up(e) {
|
|
6378
6576
|
return {
|
|
6379
6577
|
creates: [],
|
|
6380
6578
|
modifies: [],
|
|
6381
|
-
deletes: Object.keys(
|
|
6382
|
-
let t = o(e,
|
|
6579
|
+
deletes: Object.keys(cp).map((e) => {
|
|
6580
|
+
let t = o(e, lp);
|
|
6383
6581
|
return {
|
|
6384
6582
|
path: t,
|
|
6385
6583
|
language: r(t),
|
|
@@ -6396,20 +6594,20 @@ async function zf(e) {
|
|
|
6396
6594
|
}
|
|
6397
6595
|
//#endregion
|
|
6398
6596
|
//#region src/patterns/disable/content-negotiation/index.ts
|
|
6399
|
-
var
|
|
6400
|
-
async function
|
|
6401
|
-
let t = await
|
|
6597
|
+
var dp = "disable-content-negotiation", fp = "1.0.0", pp = "src/patterns/disable/content-negotiation", mp = "/disable/content-negotiation";
|
|
6598
|
+
async function hp(e) {
|
|
6599
|
+
let t = await up(e);
|
|
6402
6600
|
if (e.env !== "runtime") return y(t);
|
|
6403
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6601
|
+
let { generate: r } = await import("./chunks/generate.runtime-BnkNmF1g.js"), i = await y(n([t, await r(e)]));
|
|
6404
6602
|
if (e.input.destructive !== !0) return i;
|
|
6405
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6603
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6406
6604
|
return a(i, e);
|
|
6407
6605
|
}
|
|
6408
|
-
var
|
|
6409
|
-
version:
|
|
6410
|
-
slug:
|
|
6411
|
-
source:
|
|
6412
|
-
docs:
|
|
6606
|
+
var gp = {
|
|
6607
|
+
version: fp,
|
|
6608
|
+
slug: dp,
|
|
6609
|
+
source: pp,
|
|
6610
|
+
docs: mp,
|
|
6413
6611
|
plan: "open",
|
|
6414
6612
|
title: "Disable content negotiation",
|
|
6415
6613
|
summary: "Removes sveltekit-negotiate wiring: deletes creates, unwraps hooks.server handle, reverts reroute (preserving i18n compose), removes <Negotiate /> from the root layout.",
|
|
@@ -6417,6 +6615,7 @@ var Gf = {
|
|
|
6417
6615
|
auth: !1,
|
|
6418
6616
|
api: !1,
|
|
6419
6617
|
apiKeys: !1,
|
|
6618
|
+
backend: !1,
|
|
6420
6619
|
i18n: !1,
|
|
6421
6620
|
teams: !1,
|
|
6422
6621
|
payments: !1,
|
|
@@ -6439,19 +6638,19 @@ var Gf = {
|
|
|
6439
6638
|
examples: [],
|
|
6440
6639
|
tests: 0,
|
|
6441
6640
|
baseline: "velastack",
|
|
6442
|
-
generate:
|
|
6443
|
-
},
|
|
6444
|
-
"../../enable/i18n/creates/src/hooks.ts":
|
|
6445
|
-
"../../enable/i18n/creates/src/lib/components/language-select.svelte":
|
|
6446
|
-
"../../enable/i18n/creates/src/lib/url.ts":
|
|
6447
|
-
"../../enable/i18n/creates/wuchale.config.js":
|
|
6448
|
-
}),
|
|
6449
|
-
async function
|
|
6641
|
+
generate: hp
|
|
6642
|
+
}, _p = /* @__PURE__ */ Object.assign({
|
|
6643
|
+
"../../enable/i18n/creates/src/hooks.ts": Kc,
|
|
6644
|
+
"../../enable/i18n/creates/src/lib/components/language-select.svelte": qc,
|
|
6645
|
+
"../../enable/i18n/creates/src/lib/url.ts": Jc,
|
|
6646
|
+
"../../enable/i18n/creates/wuchale.config.js": Yc
|
|
6647
|
+
}), vp = "../../enable/i18n/creates/";
|
|
6648
|
+
async function yp(e) {
|
|
6450
6649
|
return {
|
|
6451
6650
|
creates: [],
|
|
6452
6651
|
modifies: [],
|
|
6453
|
-
deletes: Object.keys(
|
|
6454
|
-
let t = o(e,
|
|
6652
|
+
deletes: Object.keys(_p).map((e) => {
|
|
6653
|
+
let t = o(e, vp);
|
|
6455
6654
|
return {
|
|
6456
6655
|
path: t,
|
|
6457
6656
|
language: r(t),
|
|
@@ -6468,20 +6667,20 @@ async function Jf(e) {
|
|
|
6468
6667
|
}
|
|
6469
6668
|
//#endregion
|
|
6470
6669
|
//#region src/patterns/disable/i18n/index.ts
|
|
6471
|
-
var
|
|
6472
|
-
async function
|
|
6473
|
-
let t = await
|
|
6670
|
+
var bp = "disable-i18n", xp = "1.0.0", Sp = "src/patterns/disable/i18n", Cp = "/disable/i18n";
|
|
6671
|
+
async function wp(e) {
|
|
6672
|
+
let t = await yp(e);
|
|
6474
6673
|
if (e.env !== "runtime") return y(t);
|
|
6475
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6674
|
+
let { generate: r } = await import("./chunks/generate.runtime-Bbf2YWaA.js"), i = await y(n([t, await r(e)]));
|
|
6476
6675
|
if (e.input.destructive !== !0) return i;
|
|
6477
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6676
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6478
6677
|
return a(i, e);
|
|
6479
6678
|
}
|
|
6480
|
-
var
|
|
6481
|
-
version:
|
|
6482
|
-
slug:
|
|
6483
|
-
source:
|
|
6484
|
-
docs:
|
|
6679
|
+
var Tp = {
|
|
6680
|
+
version: xp,
|
|
6681
|
+
slug: bp,
|
|
6682
|
+
source: Sp,
|
|
6683
|
+
docs: Cp,
|
|
6485
6684
|
plan: "open",
|
|
6486
6685
|
title: "Disable i18n",
|
|
6487
6686
|
summary: "Removes i18n scaffolding files and the Wuchale .gitignore block. vite.config, svelte.config, hooks.server, app.html, and +layout.ts must be reverted manually.",
|
|
@@ -6489,6 +6688,7 @@ var ep = {
|
|
|
6489
6688
|
auth: !1,
|
|
6490
6689
|
api: !1,
|
|
6491
6690
|
apiKeys: !1,
|
|
6691
|
+
backend: !1,
|
|
6492
6692
|
i18n: !0,
|
|
6493
6693
|
teams: !1,
|
|
6494
6694
|
payments: !1,
|
|
@@ -6511,54 +6711,54 @@ var ep = {
|
|
|
6511
6711
|
examples: [],
|
|
6512
6712
|
tests: 0,
|
|
6513
6713
|
baseline: "velastack",
|
|
6514
|
-
generate:
|
|
6515
|
-
},
|
|
6516
|
-
"../../enable/teams/creates/src/lib/components/team-switcher.svelte":
|
|
6517
|
-
"../../enable/teams/creates/src/lib/schemas/team.ts":
|
|
6518
|
-
"../../enable/teams/creates/src/lib/schemas/teamInvite.ts":
|
|
6519
|
-
"../../enable/teams/creates/src/lib/schemas/teamRole.ts":
|
|
6520
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+layout@.svelte":
|
|
6521
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.server.ts":
|
|
6522
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.svelte":
|
|
6523
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.ts":
|
|
6524
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+layout@.svelte":
|
|
6525
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.server.ts":
|
|
6526
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.svelte":
|
|
6527
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.ts":
|
|
6528
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+layout.server.ts":
|
|
6529
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+layout.svelte":
|
|
6530
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+page.server.ts":
|
|
6714
|
+
generate: wp
|
|
6715
|
+
}, Ep = /* @__PURE__ */ Object.assign({
|
|
6716
|
+
"../../enable/teams/creates/src/lib/components/team-switcher.svelte": Xu,
|
|
6717
|
+
"../../enable/teams/creates/src/lib/schemas/team.ts": Zu,
|
|
6718
|
+
"../../enable/teams/creates/src/lib/schemas/teamInvite.ts": Qu,
|
|
6719
|
+
"../../enable/teams/creates/src/lib/schemas/teamRole.ts": $u,
|
|
6720
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+layout@.svelte": ed,
|
|
6721
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.server.ts": td,
|
|
6722
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.svelte": nd,
|
|
6723
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.ts": rd,
|
|
6724
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+layout@.svelte": id,
|
|
6725
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.server.ts": ad,
|
|
6726
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.svelte": od,
|
|
6727
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.ts": sd,
|
|
6728
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.server.ts": cd,
|
|
6729
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.svelte": ld,
|
|
6730
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.server.ts": ud,
|
|
6531
6731
|
"../../enable/teams/creates/src/routes/(app)/teams/+page.svelte": "",
|
|
6532
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts":
|
|
6533
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts":
|
|
6534
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte":
|
|
6535
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts":
|
|
6732
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts": dd,
|
|
6733
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts": fd,
|
|
6734
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": pd,
|
|
6735
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts": md,
|
|
6536
6736
|
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.svelte": "",
|
|
6537
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts":
|
|
6538
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts":
|
|
6539
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts":
|
|
6540
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte":
|
|
6541
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts":
|
|
6542
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts":
|
|
6543
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts":
|
|
6544
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte":
|
|
6545
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts":
|
|
6546
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts":
|
|
6547
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts":
|
|
6548
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts":
|
|
6549
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte":
|
|
6550
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts":
|
|
6551
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts":
|
|
6552
|
-
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts":
|
|
6553
|
-
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts":
|
|
6554
|
-
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts":
|
|
6555
|
-
}),
|
|
6556
|
-
async function
|
|
6737
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts": hd,
|
|
6738
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts": gd,
|
|
6739
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": _d,
|
|
6740
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte": vd,
|
|
6741
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts": yd,
|
|
6742
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts": bd,
|
|
6743
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": xd,
|
|
6744
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": Sd,
|
|
6745
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": Cd,
|
|
6746
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": wd,
|
|
6747
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts": Td,
|
|
6748
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts": Ed,
|
|
6749
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte": Dd,
|
|
6750
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts": Od,
|
|
6751
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts": kd,
|
|
6752
|
+
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts": Ad,
|
|
6753
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": jd,
|
|
6754
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts": Md
|
|
6755
|
+
}), Dp = "../../enable/teams/creates/";
|
|
6756
|
+
async function Op(e) {
|
|
6557
6757
|
return {
|
|
6558
6758
|
creates: [],
|
|
6559
6759
|
modifies: [],
|
|
6560
|
-
deletes: Object.keys(
|
|
6561
|
-
let t = o(e,
|
|
6760
|
+
deletes: Object.keys(Ep).map((e) => {
|
|
6761
|
+
let t = o(e, Dp);
|
|
6562
6762
|
return {
|
|
6563
6763
|
path: t,
|
|
6564
6764
|
language: r(t),
|
|
@@ -6575,20 +6775,20 @@ async function rp(e) {
|
|
|
6575
6775
|
}
|
|
6576
6776
|
//#endregion
|
|
6577
6777
|
//#region src/patterns/disable/teams/index.ts
|
|
6578
|
-
var
|
|
6579
|
-
async function
|
|
6580
|
-
let t = await
|
|
6778
|
+
var kp = "disable-teams", Ap = "1.0.0", jp = "src/patterns/disable/teams", Mp = "/disable/teams";
|
|
6779
|
+
async function Np(e) {
|
|
6780
|
+
let t = await Op(e);
|
|
6581
6781
|
if (e.env !== "runtime") return y(t);
|
|
6582
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6782
|
+
let { generate: r } = await import("./chunks/generate.runtime-BkvtIjgh.js"), i = await y(n([t, await r(e)]));
|
|
6583
6783
|
if (e.input.destructive !== !0) return i;
|
|
6584
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6784
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6585
6785
|
return a(i, e);
|
|
6586
6786
|
}
|
|
6587
|
-
var
|
|
6588
|
-
version:
|
|
6589
|
-
slug:
|
|
6590
|
-
source:
|
|
6591
|
-
docs:
|
|
6787
|
+
var Pp = {
|
|
6788
|
+
version: Ap,
|
|
6789
|
+
slug: kp,
|
|
6790
|
+
source: jp,
|
|
6791
|
+
docs: Mp,
|
|
6592
6792
|
plan: "pro",
|
|
6593
6793
|
title: "Disable teams",
|
|
6594
6794
|
summary: "Removes teams collections (teams, team_memberships, team_invites, team_invite_links), reverts the Teams nav item, and deletes team routes. app-sidebar and +layout.server.ts must be reverted manually.",
|
|
@@ -6596,6 +6796,7 @@ var lp = {
|
|
|
6596
6796
|
auth: !0,
|
|
6597
6797
|
api: !1,
|
|
6598
6798
|
apiKeys: !1,
|
|
6799
|
+
backend: !0,
|
|
6599
6800
|
i18n: !1,
|
|
6600
6801
|
teams: !0,
|
|
6601
6802
|
payments: !1,
|
|
@@ -6617,47 +6818,47 @@ var lp = {
|
|
|
6617
6818
|
examples: [],
|
|
6618
6819
|
tests: 0,
|
|
6619
6820
|
baseline: "velastack-auth",
|
|
6620
|
-
generate:
|
|
6621
|
-
},
|
|
6622
|
-
"../../enable/payments/creates/data/hooks/stripe.pb.js":
|
|
6623
|
-
"../../enable/payments/creates/data/hooks/utils.js":
|
|
6624
|
-
"../../enable/payments/creates/src/lib/components/payments/confirm-dialog.svelte":
|
|
6625
|
-
"../../enable/payments/creates/src/lib/components/payments/payment-button.svelte":
|
|
6626
|
-
"../../enable/payments/creates/src/lib/components/payments/payment-dialog.svelte":
|
|
6627
|
-
"../../enable/payments/creates/src/lib/components/payments/stripe-constants.ts":
|
|
6628
|
-
"../../enable/payments/creates/src/lib/components/payments/stripe-payment-form.svelte":
|
|
6629
|
-
"../../enable/payments/creates/src/lib/components/payments/use-payment-intent.svelte.ts":
|
|
6630
|
-
"../../enable/payments/creates/src/lib/components/payments/use-stripe.svelte.ts":
|
|
6631
|
-
"../../enable/payments/creates/src/lib/stripe.ts":
|
|
6632
|
-
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/+server.ts":
|
|
6633
|
-
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
6634
|
-
"../../enable/payments/creates/src/routes/api/stripe/sync/prices/+server.ts":
|
|
6635
|
-
"../../enable/payments/creates/src/routes/api/stripe/sync/products/+server.ts":
|
|
6636
|
-
"../../enable/payments/creates/src/routes/webhooks/stripe/+server.ts":
|
|
6637
|
-
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
6638
|
-
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
6639
|
-
"../../enable/payments/creates/src/routes/webhooks/stripe/server.test.ts":
|
|
6640
|
-
}),
|
|
6641
|
-
"../../enable/payments/creates-app-mode/data/hooks/stripe.pb.js":
|
|
6642
|
-
"../../enable/payments/creates-app-mode/data/hooks/utils.js":
|
|
6643
|
-
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-button.svelte":
|
|
6644
|
-
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-dialog.svelte":
|
|
6645
|
-
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+layout.server.ts":
|
|
6821
|
+
generate: Np
|
|
6822
|
+
}, Fp = /* @__PURE__ */ Object.assign({
|
|
6823
|
+
"../../enable/payments/creates/data/hooks/stripe.pb.js": wl,
|
|
6824
|
+
"../../enable/payments/creates/data/hooks/utils.js": Tl,
|
|
6825
|
+
"../../enable/payments/creates/src/lib/components/payments/confirm-dialog.svelte": El,
|
|
6826
|
+
"../../enable/payments/creates/src/lib/components/payments/payment-button.svelte": Dl,
|
|
6827
|
+
"../../enable/payments/creates/src/lib/components/payments/payment-dialog.svelte": Ol,
|
|
6828
|
+
"../../enable/payments/creates/src/lib/components/payments/stripe-constants.ts": kl,
|
|
6829
|
+
"../../enable/payments/creates/src/lib/components/payments/stripe-payment-form.svelte": Al,
|
|
6830
|
+
"../../enable/payments/creates/src/lib/components/payments/use-payment-intent.svelte.ts": jl,
|
|
6831
|
+
"../../enable/payments/creates/src/lib/components/payments/use-stripe.svelte.ts": Ml,
|
|
6832
|
+
"../../enable/payments/creates/src/lib/stripe.ts": Nl,
|
|
6833
|
+
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/+server.ts": Pl,
|
|
6834
|
+
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/server.test.ts": Fl,
|
|
6835
|
+
"../../enable/payments/creates/src/routes/api/stripe/sync/prices/+server.ts": Il,
|
|
6836
|
+
"../../enable/payments/creates/src/routes/api/stripe/sync/products/+server.ts": Ll,
|
|
6837
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/+server.ts": Rl,
|
|
6838
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": zl,
|
|
6839
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": Bl,
|
|
6840
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/server.test.ts": Vl
|
|
6841
|
+
}), Ip = /* @__PURE__ */ Object.assign({
|
|
6842
|
+
"../../enable/payments/creates-app-mode/data/hooks/stripe.pb.js": Hl,
|
|
6843
|
+
"../../enable/payments/creates-app-mode/data/hooks/utils.js": Ul,
|
|
6844
|
+
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-button.svelte": Wl,
|
|
6845
|
+
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-dialog.svelte": Gl,
|
|
6846
|
+
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+layout.server.ts": Kl,
|
|
6646
6847
|
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.server.ts": p,
|
|
6647
6848
|
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.svelte": f,
|
|
6648
|
-
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/README.md":
|
|
6649
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts":
|
|
6650
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
6651
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts":
|
|
6652
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts":
|
|
6653
|
-
"../../enable/payments/creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts":
|
|
6654
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/+server.ts":
|
|
6655
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
6656
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
6657
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts":
|
|
6658
|
-
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts":
|
|
6659
|
-
}),
|
|
6660
|
-
function
|
|
6849
|
+
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/README.md": ql,
|
|
6850
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts": Jl,
|
|
6851
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts": Yl,
|
|
6852
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts": Xl,
|
|
6853
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts": Zl,
|
|
6854
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts": Ql,
|
|
6855
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/+server.ts": $l,
|
|
6856
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": eu,
|
|
6857
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": tu,
|
|
6858
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": nu,
|
|
6859
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": ru
|
|
6860
|
+
}), Lp = "../../enable/payments/creates/", Rp = "../../enable/payments/creates-app-mode/";
|
|
6861
|
+
function zp(e, t) {
|
|
6661
6862
|
let n = {};
|
|
6662
6863
|
for (let i of Object.keys(e)) {
|
|
6663
6864
|
let e = o(i, t);
|
|
@@ -6670,10 +6871,10 @@ function mp(e, t) {
|
|
|
6670
6871
|
}
|
|
6671
6872
|
return n;
|
|
6672
6873
|
}
|
|
6673
|
-
async function
|
|
6674
|
-
let t = e.features.auth, n = { ...
|
|
6874
|
+
async function Bp(e) {
|
|
6875
|
+
let t = e.features.auth, n = { ...zp(Fp, Lp) };
|
|
6675
6876
|
if (t) {
|
|
6676
|
-
let e =
|
|
6877
|
+
let e = zp(Ip, Rp);
|
|
6677
6878
|
Object.assign(n, e);
|
|
6678
6879
|
}
|
|
6679
6880
|
return {
|
|
@@ -6689,20 +6890,20 @@ async function hp(e) {
|
|
|
6689
6890
|
}
|
|
6690
6891
|
//#endregion
|
|
6691
6892
|
//#region src/patterns/disable/payments/index.ts
|
|
6692
|
-
var
|
|
6693
|
-
async function
|
|
6694
|
-
let t = await
|
|
6893
|
+
var Vp = "disable-payments", Hp = "1.0.0", Up = "src/patterns/disable/payments", Wp = "/disable/payments";
|
|
6894
|
+
async function Gp(e) {
|
|
6895
|
+
let t = await Bp(e);
|
|
6695
6896
|
if (e.env !== "runtime") return y(t);
|
|
6696
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6897
|
+
let { generate: r } = await import("./chunks/generate.runtime-CEtVUz4k.js"), i = await y(n([t, await r(e)]));
|
|
6697
6898
|
if (e.input.destructive !== !0) return i;
|
|
6698
|
-
let a = await
|
|
6899
|
+
let a = await Kp(e), o = {
|
|
6699
6900
|
...i,
|
|
6700
6901
|
creates: [...i.creates, ...a]
|
|
6701
|
-
}, { writeResult: s } = await import("./chunks/write-result-
|
|
6902
|
+
}, { writeResult: s } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6702
6903
|
return s(o, e);
|
|
6703
6904
|
}
|
|
6704
|
-
async function
|
|
6705
|
-
let { withPocketbase: t } = await import("./chunks/pocketbase-
|
|
6905
|
+
async function Kp(e) {
|
|
6906
|
+
let { withPocketbase: t } = await import("./chunks/pocketbase-D7GjPuNu.js"), { applyCollectionFieldsPatches: n } = await import("./chunks/collections-BwO27pJg.js"), r = u(e), i = [];
|
|
6706
6907
|
return await t(e.root, async (t) => {
|
|
6707
6908
|
let a;
|
|
6708
6909
|
try {
|
|
@@ -6720,11 +6921,11 @@ async function xp(e) {
|
|
|
6720
6921
|
}], e, r));
|
|
6721
6922
|
}), i;
|
|
6722
6923
|
}
|
|
6723
|
-
var
|
|
6724
|
-
version:
|
|
6725
|
-
slug:
|
|
6726
|
-
source:
|
|
6727
|
-
docs:
|
|
6924
|
+
var qp = {
|
|
6925
|
+
version: Hp,
|
|
6926
|
+
slug: Vp,
|
|
6927
|
+
source: Up,
|
|
6928
|
+
docs: Wp,
|
|
6728
6929
|
plan: "pro",
|
|
6729
6930
|
title: "Disable payments",
|
|
6730
6931
|
summary: "Drops Stripe collections, strips Stripe env credentials, reverts nav/signup edits, and deletes generated payment files. Does NOT delete Stripe products/prices in the Stripe dashboard, or uninstall stripe/@stripe/stripe-js packages.",
|
|
@@ -6732,6 +6933,7 @@ var Sp = {
|
|
|
6732
6933
|
auth: !1,
|
|
6733
6934
|
api: !1,
|
|
6734
6935
|
apiKeys: !1,
|
|
6936
|
+
backend: !0,
|
|
6735
6937
|
i18n: !1,
|
|
6736
6938
|
teams: !1,
|
|
6737
6939
|
payments: !0,
|
|
@@ -6755,20 +6957,20 @@ var Sp = {
|
|
|
6755
6957
|
examples: [],
|
|
6756
6958
|
tests: 0,
|
|
6757
6959
|
baseline: "velastack",
|
|
6758
|
-
generate:
|
|
6759
|
-
},
|
|
6760
|
-
"../../enable/subscriptions/creates/src/routes/api/stripe/sync/subscriptions/+server.ts":
|
|
6761
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts":
|
|
6762
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts":
|
|
6763
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts":
|
|
6764
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts":
|
|
6765
|
-
}),
|
|
6766
|
-
async function
|
|
6960
|
+
generate: Gp
|
|
6961
|
+
}, Jp = /* @__PURE__ */ Object.assign({
|
|
6962
|
+
"../../enable/subscriptions/creates/src/routes/api/stripe/sync/subscriptions/+server.ts": Mu,
|
|
6963
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": Nu,
|
|
6964
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": Pu,
|
|
6965
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": Fu,
|
|
6966
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": Iu
|
|
6967
|
+
}), Yp = "../../enable/subscriptions/creates/";
|
|
6968
|
+
async function Xp(e) {
|
|
6767
6969
|
return {
|
|
6768
6970
|
creates: [],
|
|
6769
6971
|
modifies: [],
|
|
6770
|
-
deletes: Object.keys(
|
|
6771
|
-
let t = o(e,
|
|
6972
|
+
deletes: Object.keys(Jp).map((e) => {
|
|
6973
|
+
let t = o(e, Yp);
|
|
6772
6974
|
return {
|
|
6773
6975
|
path: t,
|
|
6774
6976
|
language: r(t),
|
|
@@ -6785,20 +6987,20 @@ async function Tp(e) {
|
|
|
6785
6987
|
}
|
|
6786
6988
|
//#endregion
|
|
6787
6989
|
//#region src/patterns/disable/subscriptions/index.ts
|
|
6788
|
-
var
|
|
6789
|
-
async function
|
|
6790
|
-
let t = await
|
|
6990
|
+
var Zp = "disable-subscriptions", Qp = "1.0.0", $p = "src/patterns/disable/subscriptions", em = "/disable/subscriptions";
|
|
6991
|
+
async function tm(e) {
|
|
6992
|
+
let t = await Xp(e);
|
|
6791
6993
|
if (e.env !== "runtime") return y(t);
|
|
6792
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6994
|
+
let { generate: r } = await import("./chunks/generate.runtime-CrAHzaEW.js"), i = await y(n([t, await r(e)]));
|
|
6793
6995
|
if (e.input.destructive !== !0) return i;
|
|
6794
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6996
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6795
6997
|
return a(i, e);
|
|
6796
6998
|
}
|
|
6797
|
-
var
|
|
6798
|
-
version:
|
|
6799
|
-
slug:
|
|
6800
|
-
source:
|
|
6801
|
-
docs:
|
|
6999
|
+
var nm = {
|
|
7000
|
+
version: Qp,
|
|
7001
|
+
slug: Zp,
|
|
7002
|
+
source: $p,
|
|
7003
|
+
docs: em,
|
|
6802
7004
|
plan: "pro",
|
|
6803
7005
|
title: "Disable subscriptions",
|
|
6804
7006
|
summary: "Drops the stripe_subscriptions collection, reverts billing / layout / nav edits, and removes subscription webhook handlers and sync endpoint. Leaves the payments pattern intact.",
|
|
@@ -6806,6 +7008,7 @@ var jp = {
|
|
|
6806
7008
|
auth: !0,
|
|
6807
7009
|
api: !1,
|
|
6808
7010
|
apiKeys: !1,
|
|
7011
|
+
backend: !0,
|
|
6809
7012
|
i18n: !1,
|
|
6810
7013
|
teams: !1,
|
|
6811
7014
|
payments: !0,
|
|
@@ -6830,8 +7033,8 @@ var jp = {
|
|
|
6830
7033
|
examples: [],
|
|
6831
7034
|
tests: 0,
|
|
6832
7035
|
baseline: "velastack",
|
|
6833
|
-
generate:
|
|
6834
|
-
},
|
|
7036
|
+
generate: tm
|
|
7037
|
+
}, rm = ye.version, im = [
|
|
6835
7038
|
fn,
|
|
6836
7039
|
Bn,
|
|
6837
7040
|
Zn,
|
|
@@ -6843,30 +7046,32 @@ var jp = {
|
|
|
6843
7046
|
Uo,
|
|
6844
7047
|
ns,
|
|
6845
7048
|
Es,
|
|
6846
|
-
|
|
6847
|
-
|
|
7049
|
+
Hs,
|
|
7050
|
+
Tc,
|
|
6848
7051
|
Gc,
|
|
6849
7052
|
sl,
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
7053
|
+
Cl,
|
|
7054
|
+
ju,
|
|
7055
|
+
Yu,
|
|
7056
|
+
Zd,
|
|
7057
|
+
af,
|
|
7058
|
+
df,
|
|
7059
|
+
_f,
|
|
7060
|
+
Cf,
|
|
7061
|
+
Mf,
|
|
7062
|
+
Vf,
|
|
7063
|
+
Qf,
|
|
7064
|
+
sp,
|
|
7065
|
+
gp,
|
|
7066
|
+
Tp,
|
|
7067
|
+
Pp,
|
|
7068
|
+
qp,
|
|
7069
|
+
nm
|
|
7070
|
+
], am = Object.fromEntries(im.map((e) => [e.slug, e])), om = im.reduce((e, t) => {
|
|
6866
7071
|
let n = t.category;
|
|
6867
7072
|
return e[n] ??= [], e[n].push(t), e;
|
|
6868
7073
|
}, {});
|
|
6869
7074
|
//#endregion
|
|
6870
|
-
export { e as InvalidArgumentError,
|
|
7075
|
+
export { e as InvalidArgumentError, om as byCategory, am as bySlug, im as patterns, rm as version };
|
|
6871
7076
|
|
|
6872
7077
|
//# sourceMappingURL=index.js.map
|