@velastack/patterns 0.0.45 → 0.0.47
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 +803 -597
- 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.47",
|
|
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,31 +1889,32 @@ 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");
|
|
1896
1896
|
return t(e);
|
|
1897
1897
|
}
|
|
1898
|
-
async function z(
|
|
1899
|
-
lt(
|
|
1900
|
-
let
|
|
1901
|
-
if (
|
|
1902
|
-
let { fields:
|
|
1898
|
+
async function z(t, n, r) {
|
|
1899
|
+
lt(n);
|
|
1900
|
+
let i = A(n, t), a = t.features.backend ? await Kt(t) : [];
|
|
1901
|
+
if (r.length > 0) {
|
|
1902
|
+
let { fields: e, auth: n } = kt(r, i, a, t);
|
|
1903
1903
|
return {
|
|
1904
|
-
model:
|
|
1905
|
-
fields:
|
|
1906
|
-
auth:
|
|
1904
|
+
model: i,
|
|
1905
|
+
fields: e,
|
|
1906
|
+
auth: n,
|
|
1907
1907
|
shouldCreateCollection: !0,
|
|
1908
|
-
collections:
|
|
1908
|
+
collections: a
|
|
1909
1909
|
};
|
|
1910
1910
|
}
|
|
1911
|
+
if (!t.features.backend) throw new e("Cannot derive fields from a collection without a backend. Pass field definitions (e.g. `name:text email:email`) or run `vela enable backend` first.");
|
|
1911
1912
|
return {
|
|
1912
|
-
model:
|
|
1913
|
-
fields: Jt(
|
|
1913
|
+
model: i,
|
|
1914
|
+
fields: Jt(i, a, t),
|
|
1914
1915
|
auth: void 0,
|
|
1915
1916
|
shouldCreateCollection: !1,
|
|
1916
|
-
collections:
|
|
1917
|
+
collections: a
|
|
1917
1918
|
};
|
|
1918
1919
|
}
|
|
1919
1920
|
function B(e, n, r) {
|
|
@@ -2205,7 +2206,7 @@ var sn = "generate-form", cn = "1.0.7", ln = "src/patterns/generate/form", un =
|
|
|
2205
2206
|
async function dn(e) {
|
|
2206
2207
|
let t = await on(e);
|
|
2207
2208
|
if (e.env !== "runtime") return y(t);
|
|
2208
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
2209
|
+
let { writeResult: n } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
2209
2210
|
return n(await y(t), e);
|
|
2210
2211
|
}
|
|
2211
2212
|
var fn = {
|
|
@@ -2220,6 +2221,7 @@ var fn = {
|
|
|
2220
2221
|
auth: !1,
|
|
2221
2222
|
api: !1,
|
|
2222
2223
|
apiKeys: !1,
|
|
2224
|
+
backend: !1,
|
|
2223
2225
|
i18n: !1,
|
|
2224
2226
|
teams: !1,
|
|
2225
2227
|
payments: !1,
|
|
@@ -2496,12 +2498,12 @@ async function zn(e) {
|
|
|
2496
2498
|
let t = await jn(e);
|
|
2497
2499
|
if (e.env === "preview") return y(n([t, await Pn(e)]));
|
|
2498
2500
|
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-
|
|
2501
|
+
let { modifyOutcomeToFile: r } = await import("./chunks/modify-file-DE7tPADZ.js"), { findSvelteConfigPath: i, modifySvelteConfigRemote: a } = await import("./chunks/modify-svelte-config-remote-C3g7Oi6_.js");
|
|
2500
2502
|
u(e).info("Modifying svelte.config for remote");
|
|
2501
2503
|
let o = i(e.root), s = r(o, a(o)), c = {
|
|
2502
2504
|
...t,
|
|
2503
2505
|
modifies: [...t.modifies, ...s ? [s] : []]
|
|
2504
|
-
}, { writeResult: l } = await import("./chunks/write-result-
|
|
2506
|
+
}, { writeResult: l } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
2505
2507
|
return l(await y(c), e);
|
|
2506
2508
|
}
|
|
2507
2509
|
var Bn = {
|
|
@@ -2516,6 +2518,7 @@ var Bn = {
|
|
|
2516
2518
|
auth: !1,
|
|
2517
2519
|
api: !1,
|
|
2518
2520
|
apiKeys: !1,
|
|
2521
|
+
backend: !0,
|
|
2519
2522
|
i18n: !1,
|
|
2520
2523
|
teams: !1,
|
|
2521
2524
|
payments: !1,
|
|
@@ -2636,14 +2639,14 @@ var Kn = "generate-migration", qn = "1.0.0", Jn = "src/patterns/generate/migrati
|
|
|
2636
2639
|
async function Xn(e) {
|
|
2637
2640
|
let t = await Un(e);
|
|
2638
2641
|
if (e.env !== "runtime") return y(t);
|
|
2639
|
-
let { applyCollectionFieldsPatches: n } = await import("./chunks/collections-
|
|
2642
|
+
let { applyCollectionFieldsPatches: n } = await import("./chunks/collections-BwO27pJg.js"), { withPocketbase: r } = await import("./chunks/pocketbase-D7GjPuNu.js"), i = u(e), a = [];
|
|
2640
2643
|
await r(e.root, async (r) => {
|
|
2641
2644
|
a = await n(r, t.collectionPatches, e, i);
|
|
2642
2645
|
});
|
|
2643
2646
|
let o = {
|
|
2644
2647
|
...t,
|
|
2645
2648
|
creates: [...t.creates, ...a]
|
|
2646
|
-
}, { writeResult: s } = await import("./chunks/write-result-
|
|
2649
|
+
}, { writeResult: s } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
2647
2650
|
return s(await y(o), e);
|
|
2648
2651
|
}
|
|
2649
2652
|
var Zn = {
|
|
@@ -2658,6 +2661,7 @@ var Zn = {
|
|
|
2658
2661
|
auth: !1,
|
|
2659
2662
|
api: !1,
|
|
2660
2663
|
apiKeys: !1,
|
|
2664
|
+
backend: !0,
|
|
2661
2665
|
i18n: !1,
|
|
2662
2666
|
teams: !1,
|
|
2663
2667
|
payments: !1,
|
|
@@ -2745,10 +2749,10 @@ var tr = "generate-resource", nr = "1.0.7", rr = "src/patterns/generate/resource
|
|
|
2745
2749
|
async function ar(e) {
|
|
2746
2750
|
let t = await er(e);
|
|
2747
2751
|
if (e.env !== "runtime") return y(t);
|
|
2748
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
2752
|
+
let { createCollections: n } = await import("./chunks/collections-BwO27pJg.js"), r = await n(t.collections, e), i = {
|
|
2749
2753
|
...t,
|
|
2750
2754
|
creates: [...t.creates, ...r]
|
|
2751
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
2755
|
+
}, { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
2752
2756
|
return a(await y(i), e);
|
|
2753
2757
|
}
|
|
2754
2758
|
var or = {
|
|
@@ -2763,6 +2767,7 @@ var or = {
|
|
|
2763
2767
|
auth: !1,
|
|
2764
2768
|
api: !1,
|
|
2765
2769
|
apiKeys: !1,
|
|
2770
|
+
backend: !0,
|
|
2766
2771
|
i18n: !1,
|
|
2767
2772
|
teams: !1,
|
|
2768
2773
|
payments: !1,
|
|
@@ -3132,10 +3137,10 @@ var Dr = "generate-scaffold", Or = "1.0.7", kr = "src/patterns/generate/scaffold
|
|
|
3132
3137
|
async function jr(e) {
|
|
3133
3138
|
let t = await Er(e);
|
|
3134
3139
|
if (e.env !== "runtime") return y(t);
|
|
3135
|
-
let { createCollections: n } = await import("./chunks/collections-
|
|
3140
|
+
let { createCollections: n } = await import("./chunks/collections-BwO27pJg.js"), r = await n(t.collections, e), i = {
|
|
3136
3141
|
...t,
|
|
3137
3142
|
creates: [...t.creates, ...r]
|
|
3138
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
3143
|
+
}, { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
3139
3144
|
return a(await y(i), e);
|
|
3140
3145
|
}
|
|
3141
3146
|
var Mr = {
|
|
@@ -3150,6 +3155,7 @@ var Mr = {
|
|
|
3150
3155
|
auth: !1,
|
|
3151
3156
|
api: !1,
|
|
3152
3157
|
apiKeys: !1,
|
|
3158
|
+
backend: !0,
|
|
3153
3159
|
i18n: !1,
|
|
3154
3160
|
teams: !1,
|
|
3155
3161
|
payments: !1,
|
|
@@ -3501,13 +3507,13 @@ async function ui(e) {
|
|
|
3501
3507
|
let t = await ni(e);
|
|
3502
3508
|
if (e.env === "preview") return y(n([t, await ai(e)]));
|
|
3503
3509
|
if (e.env !== "runtime") return y(t);
|
|
3504
|
-
let { createCollections: r } = await import("./chunks/collections-
|
|
3510
|
+
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
3511
|
u(e).info("Modifying svelte.config for remote");
|
|
3506
3512
|
let c = o(e.root), l = a(c, s(c)), d = {
|
|
3507
3513
|
...t,
|
|
3508
3514
|
creates: [...t.creates, ...i],
|
|
3509
3515
|
modifies: [...t.modifies, ...l ? [l] : []]
|
|
3510
|
-
}, { writeResult: f } = await import("./chunks/write-result-
|
|
3516
|
+
}, { writeResult: f } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
3511
3517
|
return f(await y(d), e);
|
|
3512
3518
|
}
|
|
3513
3519
|
var di = {
|
|
@@ -3522,6 +3528,7 @@ var di = {
|
|
|
3522
3528
|
auth: !1,
|
|
3523
3529
|
api: !1,
|
|
3524
3530
|
apiKeys: !1,
|
|
3531
|
+
backend: !0,
|
|
3525
3532
|
i18n: !1,
|
|
3526
3533
|
teams: !1,
|
|
3527
3534
|
payments: !1,
|
|
@@ -3603,7 +3610,7 @@ var hi = "generate-schema", gi = "1.0.7", _i = "src/patterns/generate/schema", v
|
|
|
3603
3610
|
async function yi(e) {
|
|
3604
3611
|
let t = await mi(e);
|
|
3605
3612
|
if (e.env !== "runtime") return y(t);
|
|
3606
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
3613
|
+
let { writeResult: n } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
3607
3614
|
return n(await y(t), e);
|
|
3608
3615
|
}
|
|
3609
3616
|
var bi = {
|
|
@@ -3618,6 +3625,7 @@ var bi = {
|
|
|
3618
3625
|
auth: !1,
|
|
3619
3626
|
api: !1,
|
|
3620
3627
|
apiKeys: !1,
|
|
3628
|
+
backend: !1,
|
|
3621
3629
|
i18n: !1,
|
|
3622
3630
|
teams: !1,
|
|
3623
3631
|
payments: !1,
|
|
@@ -3830,7 +3838,7 @@ var wa = "enable-auth", Ta = "1.0.8", Ea = "src/patterns/enable/auth", Da = "/en
|
|
|
3830
3838
|
async function Oa(e) {
|
|
3831
3839
|
let t = await ba(e);
|
|
3832
3840
|
if (e.env === "preview") return y(n([t, await Ca(e)]));
|
|
3833
|
-
let { writeResult: r } = await import("./chunks/write-result-
|
|
3841
|
+
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
3842
|
return n([i, await r(await y(await a(e)), e)]);
|
|
3835
3843
|
}
|
|
3836
3844
|
var ka = {
|
|
@@ -3845,6 +3853,7 @@ var ka = {
|
|
|
3845
3853
|
auth: !1,
|
|
3846
3854
|
api: !1,
|
|
3847
3855
|
apiKeys: !1,
|
|
3856
|
+
backend: !0,
|
|
3848
3857
|
i18n: !1,
|
|
3849
3858
|
teams: !1,
|
|
3850
3859
|
payments: !1,
|
|
@@ -4054,7 +4063,7 @@ var Ro = "enable-auth-remote", zo = "1.0.0", Bo = "src/patterns/enable/auth-remo
|
|
|
4054
4063
|
async function Ho(e) {
|
|
4055
4064
|
let t = await Po(e);
|
|
4056
4065
|
if (e.env === "preview") return y(n([t, await Lo(e)]));
|
|
4057
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
4066
|
+
let { generate: r } = await import("./chunks/generate.runtime-D1uQBjeg.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4058
4067
|
return a(await y(n([t, i])), e);
|
|
4059
4068
|
}
|
|
4060
4069
|
var Uo = {
|
|
@@ -4069,6 +4078,7 @@ var Uo = {
|
|
|
4069
4078
|
auth: !1,
|
|
4070
4079
|
api: !1,
|
|
4071
4080
|
apiKeys: !1,
|
|
4081
|
+
backend: !0,
|
|
4072
4082
|
i18n: !1,
|
|
4073
4083
|
teams: !1,
|
|
4074
4084
|
payments: !1,
|
|
@@ -4144,7 +4154,7 @@ var Zo = "enable-api", Qo = "1.0.7", $o = "src/patterns/enable/api", es = "/enab
|
|
|
4144
4154
|
async function ts(e) {
|
|
4145
4155
|
let t = await qo(e);
|
|
4146
4156
|
if (e.env === "preview") return y(n([t, await Xo(e)]));
|
|
4147
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
4157
|
+
let { generate: r } = await import("./chunks/generate.runtime-CUgleG0U.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4148
4158
|
return a(await y(n([t, i])), e);
|
|
4149
4159
|
}
|
|
4150
4160
|
var ns = {
|
|
@@ -4159,6 +4169,7 @@ var ns = {
|
|
|
4159
4169
|
auth: !1,
|
|
4160
4170
|
api: !1,
|
|
4161
4171
|
apiKeys: !1,
|
|
4172
|
+
backend: !0,
|
|
4162
4173
|
i18n: !1,
|
|
4163
4174
|
teams: !1,
|
|
4164
4175
|
payments: !1,
|
|
@@ -4294,7 +4305,7 @@ var xs = "enable-api-keys", Ss = "1.0.0", Cs = "src/patterns/enable/api-keys", w
|
|
|
4294
4305
|
async function Ts(e) {
|
|
4295
4306
|
let t = await _s(e);
|
|
4296
4307
|
if (e.env === "preview") return y(n([t, await bs(e)]));
|
|
4297
|
-
let { createCollections: r } = await import("./chunks/collections-
|
|
4308
|
+
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
4309
|
return s(await y(n([{
|
|
4299
4310
|
...t,
|
|
4300
4311
|
creates: [...t.creates, ...i]
|
|
@@ -4312,6 +4323,7 @@ var Es = {
|
|
|
4312
4323
|
auth: !0,
|
|
4313
4324
|
api: !0,
|
|
4314
4325
|
apiKeys: !1,
|
|
4326
|
+
backend: !0,
|
|
4315
4327
|
i18n: !1,
|
|
4316
4328
|
teams: !1,
|
|
4317
4329
|
payments: !1,
|
|
@@ -4336,30 +4348,126 @@ var Es = {
|
|
|
4336
4348
|
tests: 6,
|
|
4337
4349
|
baseline: "velastack",
|
|
4338
4350
|
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
|
-
|
|
4351
|
+
}, 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({
|
|
4352
|
+
"./creates/data/fixtures/README.md": Ds,
|
|
4353
|
+
"./creates/data/hooks/README.md": Os,
|
|
4354
|
+
"./creates/data/seeds/README.md": ks,
|
|
4355
|
+
"./creates/src/hooks.server.ts": As
|
|
4356
|
+
}), Ms = "./creates/";
|
|
4357
|
+
async function Ns(e) {
|
|
4358
|
+
return {
|
|
4359
|
+
creates: Object.entries(js).map(([e, t]) => {
|
|
4360
|
+
let n = o(e, Ms);
|
|
4361
|
+
return {
|
|
4362
|
+
path: n,
|
|
4363
|
+
language: r(n),
|
|
4364
|
+
content: t,
|
|
4365
|
+
status: "success"
|
|
4366
|
+
};
|
|
4367
|
+
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
4368
|
+
modifies: [],
|
|
4369
|
+
deletes: [],
|
|
4370
|
+
components: [],
|
|
4371
|
+
packages: ["@velastack/pocketbase", "pocketbase-sveltekit"],
|
|
4372
|
+
collections: [],
|
|
4373
|
+
collectionPatches: [],
|
|
4374
|
+
collectionDrops: []
|
|
4375
|
+
};
|
|
4376
|
+
}
|
|
4377
|
+
//#endregion
|
|
4378
|
+
//#region src/patterns/enable/backend/generate.preview.ts
|
|
4379
|
+
var Ps = /* @__PURE__ */ Object.assign({
|
|
4380
|
+
"./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",
|
|
4381
|
+
"./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"
|
|
4382
|
+
}), Fs = "./preview-modifies/";
|
|
4383
|
+
async function Is(e) {
|
|
4384
|
+
return {
|
|
4385
|
+
creates: [],
|
|
4386
|
+
modifies: Object.entries(Ps).map(([e, t]) => {
|
|
4387
|
+
let n = o(e, Fs);
|
|
4388
|
+
return {
|
|
4389
|
+
path: n,
|
|
4390
|
+
language: r(n),
|
|
4391
|
+
content: t,
|
|
4392
|
+
status: "success"
|
|
4393
|
+
};
|
|
4394
|
+
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
4395
|
+
deletes: [],
|
|
4396
|
+
components: [],
|
|
4397
|
+
packages: [],
|
|
4398
|
+
collections: [],
|
|
4399
|
+
collectionPatches: [],
|
|
4400
|
+
collectionDrops: []
|
|
4401
|
+
};
|
|
4402
|
+
}
|
|
4403
|
+
//#endregion
|
|
4404
|
+
//#region src/patterns/enable/backend/index.ts
|
|
4405
|
+
var Ls = "enable-backend", Rs = "1.0.0", zs = "src/patterns/enable/backend", Bs = "/enable/backend";
|
|
4406
|
+
async function Vs(e) {
|
|
4407
|
+
let t = await Ns(e);
|
|
4408
|
+
if (e.env === "preview") return y(n([t, await Is(e)]));
|
|
4409
|
+
let { generate: r } = await import("./chunks/generate.runtime-DFG2C9gc.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4410
|
+
return a(await y(n([t, i])), e);
|
|
4411
|
+
}
|
|
4412
|
+
var Hs = {
|
|
4413
|
+
version: Rs,
|
|
4414
|
+
slug: Ls,
|
|
4415
|
+
source: zs,
|
|
4416
|
+
docs: Bs,
|
|
4417
|
+
plan: "open",
|
|
4418
|
+
title: "Enable Backend",
|
|
4419
|
+
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.",
|
|
4420
|
+
requires: {
|
|
4421
|
+
auth: !1,
|
|
4422
|
+
api: !1,
|
|
4423
|
+
apiKeys: !1,
|
|
4424
|
+
backend: !1,
|
|
4425
|
+
i18n: !1,
|
|
4426
|
+
teams: !1,
|
|
4427
|
+
payments: !1,
|
|
4428
|
+
blog: !1,
|
|
4429
|
+
contentNegotiation: !1
|
|
4430
|
+
},
|
|
4431
|
+
category: "backend",
|
|
4432
|
+
tags: [
|
|
4433
|
+
"sveltekit",
|
|
4434
|
+
"pocketbase",
|
|
4435
|
+
"backend",
|
|
4436
|
+
"velastack"
|
|
4437
|
+
],
|
|
4438
|
+
command: {
|
|
4439
|
+
raw: "vela enable backend",
|
|
4440
|
+
base: "vela enable backend",
|
|
4441
|
+
argv: []
|
|
4442
|
+
},
|
|
4443
|
+
examples: [],
|
|
4444
|
+
tests: 0,
|
|
4445
|
+
baseline: "velastack",
|
|
4446
|
+
generate: Vs
|
|
4447
|
+
}, 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({
|
|
4448
|
+
"./creates/src/css/prism-vsc-dark-plus.css": Us,
|
|
4449
|
+
"./creates/src/lib/components/blog/AuthorChip.svelte": Ws,
|
|
4450
|
+
"./creates/src/lib/components/blog/PostCard.svelte": Gs,
|
|
4451
|
+
"./creates/src/lib/content/blog/design-system-notes.svx": Ks,
|
|
4452
|
+
"./creates/src/lib/content/blog/getting-started-with-sveltekit.svx": qs,
|
|
4453
|
+
"./creates/src/lib/content/blog/performance-checklist.svx": Js,
|
|
4454
|
+
"./creates/src/lib/content/blog/welcome-to-the-blog.svx": Ys,
|
|
4455
|
+
"./creates/src/lib/content/blog/why-we-chose-tailwind-v4.svx": Xs,
|
|
4456
|
+
"./creates/src/lib/content/blog/writing-posts-with-mdsvex.svx": Zs,
|
|
4457
|
+
"./creates/src/lib/content.ts": Qs,
|
|
4458
|
+
"./creates/src/lib/utils/date.ts": $s,
|
|
4459
|
+
"./creates/src/routes/(public)/blog/+layout.svelte": ec,
|
|
4460
|
+
"./creates/src/routes/(public)/blog/+page.svelte": tc,
|
|
4461
|
+
"./creates/src/routes/(public)/blog/+page.ts": nc,
|
|
4462
|
+
"./creates/src/routes/(public)/blog/[slug]/+page.svelte": rc,
|
|
4463
|
+
"./creates/src/routes/(public)/blog/[slug]/+page.ts": ic,
|
|
4464
|
+
"./creates/src/routes/(public)/blog/rss.xml/+server.ts": ac,
|
|
4465
|
+
"./creates/src/routes/(public)/blog/tags/+page.svelte": oc,
|
|
4466
|
+
"./creates/src/routes/(public)/blog/tags/+page.ts": sc,
|
|
4467
|
+
"./creates/src/routes/(public)/blog/tags/[tag]/+page.svelte": cc,
|
|
4468
|
+
"./creates/src/routes/(public)/blog/tags/[tag]/+page.ts": lc
|
|
4469
|
+
}), fc = /* @__PURE__ */ Object.assign({ "./creates-with-negotiation/src/routes/(public)/blog/[slug]/+page.server.ts": uc }), pc = "./creates/", mc = "./creates-with-negotiation/";
|
|
4470
|
+
function hc(e, t) {
|
|
4363
4471
|
let n = {};
|
|
4364
4472
|
for (let [i, a] of Object.entries(e)) {
|
|
4365
4473
|
let e = o(i, t);
|
|
@@ -4372,10 +4480,10 @@ function $s(e, t) {
|
|
|
4372
4480
|
}
|
|
4373
4481
|
return n;
|
|
4374
4482
|
}
|
|
4375
|
-
async function
|
|
4376
|
-
let t = {
|
|
4483
|
+
async function gc(e) {
|
|
4484
|
+
let t = { ...hc(dc, pc) };
|
|
4377
4485
|
if (e.features.contentNegotiation) {
|
|
4378
|
-
let e =
|
|
4486
|
+
let e = hc(fc, mc);
|
|
4379
4487
|
Object.assign(t, e);
|
|
4380
4488
|
}
|
|
4381
4489
|
return {
|
|
@@ -4397,16 +4505,16 @@ async function ec(e) {
|
|
|
4397
4505
|
}
|
|
4398
4506
|
//#endregion
|
|
4399
4507
|
//#region src/patterns/enable/blog/generate.preview.ts
|
|
4400
|
-
var
|
|
4508
|
+
var _c = /* @__PURE__ */ Object.assign({
|
|
4401
4509
|
"./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
4510
|
"./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
4511
|
"./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
|
|
4512
|
+
}), vc = "./preview-modifies/";
|
|
4513
|
+
async function yc(e) {
|
|
4406
4514
|
return {
|
|
4407
4515
|
creates: [],
|
|
4408
|
-
modifies: Object.entries(
|
|
4409
|
-
let n = o(e,
|
|
4516
|
+
modifies: Object.entries(_c).map(([e, t]) => {
|
|
4517
|
+
let n = o(e, vc);
|
|
4410
4518
|
return {
|
|
4411
4519
|
path: n,
|
|
4412
4520
|
language: r(n),
|
|
@@ -4424,18 +4532,18 @@ async function rc(e) {
|
|
|
4424
4532
|
}
|
|
4425
4533
|
//#endregion
|
|
4426
4534
|
//#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-
|
|
4535
|
+
var bc = "enable-blog", xc = "1.0.0", Sc = "src/patterns/enable/blog", Cc = "/enable/blog";
|
|
4536
|
+
async function wc(e) {
|
|
4537
|
+
let t = await gc(e);
|
|
4538
|
+
if (e.env === "preview") return y(n([t, await yc(e)]));
|
|
4539
|
+
let { generate: r } = await import("./chunks/generate.runtime-M6LNL7Tq.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4432
4540
|
return a(await y(n([t, i])), e);
|
|
4433
4541
|
}
|
|
4434
|
-
var
|
|
4435
|
-
version:
|
|
4436
|
-
slug:
|
|
4437
|
-
source:
|
|
4438
|
-
docs:
|
|
4542
|
+
var Tc = {
|
|
4543
|
+
version: xc,
|
|
4544
|
+
slug: bc,
|
|
4545
|
+
source: Sc,
|
|
4546
|
+
docs: Cc,
|
|
4439
4547
|
plan: "open",
|
|
4440
4548
|
title: "Enable blog",
|
|
4441
4549
|
summary: "Adds an mdsvex-powered blog with post list, tags, RSS feed, and example posts.",
|
|
@@ -4443,6 +4551,7 @@ var lc = {
|
|
|
4443
4551
|
auth: !1,
|
|
4444
4552
|
api: !1,
|
|
4445
4553
|
apiKeys: !1,
|
|
4554
|
+
backend: !0,
|
|
4446
4555
|
i18n: !1,
|
|
4447
4556
|
teams: !1,
|
|
4448
4557
|
payments: !1,
|
|
@@ -4466,14 +4575,14 @@ var lc = {
|
|
|
4466
4575
|
examples: [],
|
|
4467
4576
|
tests: 0,
|
|
4468
4577
|
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
|
|
4578
|
+
generate: wc
|
|
4579
|
+
}, 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({
|
|
4580
|
+
"./creates/src/lib/negotiate.ts": Ec,
|
|
4581
|
+
"./creates/src/routes/(public)/negotiate/+page.server.ts": Dc,
|
|
4582
|
+
"./creates/src/routes/(public)/negotiate/+page.svelte": Oc,
|
|
4583
|
+
"./creates/src/routes/(public)/negotiate/+page.ts": kc
|
|
4584
|
+
}), Mc = /* @__PURE__ */ Object.assign({ "./creates-with-blog/src/routes/(public)/blog/[slug]/+page.server.ts": Ac }), Nc = "./creates/", Pc = "./creates-with-blog/";
|
|
4585
|
+
function Fc(e, t) {
|
|
4477
4586
|
let n = {};
|
|
4478
4587
|
for (let [i, a] of Object.entries(e)) {
|
|
4479
4588
|
let e = o(i, t);
|
|
@@ -4486,10 +4595,10 @@ function yc(e, t) {
|
|
|
4486
4595
|
}
|
|
4487
4596
|
return n;
|
|
4488
4597
|
}
|
|
4489
|
-
async function
|
|
4490
|
-
let t = { ...
|
|
4598
|
+
async function Ic(e) {
|
|
4599
|
+
let t = { ...Fc(jc, Nc) };
|
|
4491
4600
|
if (e.features.blog) {
|
|
4492
|
-
let e =
|
|
4601
|
+
let e = Fc(Mc, Pc);
|
|
4493
4602
|
Object.assign(t, e);
|
|
4494
4603
|
}
|
|
4495
4604
|
return {
|
|
@@ -4505,15 +4614,15 @@ async function bc(e) {
|
|
|
4505
4614
|
}
|
|
4506
4615
|
//#endregion
|
|
4507
4616
|
//#region src/patterns/enable/content-negotiation/generate.preview.ts
|
|
4508
|
-
var
|
|
4617
|
+
var Lc = /* @__PURE__ */ Object.assign({
|
|
4509
4618
|
"./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
4619
|
"./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
|
|
4620
|
+
}), Rc = "./preview-modifies/";
|
|
4621
|
+
async function zc(e) {
|
|
4513
4622
|
return {
|
|
4514
4623
|
creates: [],
|
|
4515
|
-
modifies: Object.entries(
|
|
4516
|
-
let n = o(e,
|
|
4624
|
+
modifies: Object.entries(Lc).map(([e, t]) => {
|
|
4625
|
+
let n = o(e, Rc);
|
|
4517
4626
|
return {
|
|
4518
4627
|
path: n,
|
|
4519
4628
|
language: r(n),
|
|
@@ -4531,18 +4640,18 @@ async function Cc(e) {
|
|
|
4531
4640
|
}
|
|
4532
4641
|
//#endregion
|
|
4533
4642
|
//#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-
|
|
4643
|
+
var Bc = "enable-content-negotiation", Vc = "1.0.0", Hc = "src/patterns/enable/content-negotiation", Uc = "/enable/content-negotiation";
|
|
4644
|
+
async function Wc(e) {
|
|
4645
|
+
let t = await Ic(e);
|
|
4646
|
+
if (e.env === "preview") return y(n([t, await zc(e)]));
|
|
4647
|
+
let { generate: r } = await import("./chunks/generate.runtime-Cb2vYF1l.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4539
4648
|
return a(await y(n([t, i])), e);
|
|
4540
4649
|
}
|
|
4541
|
-
var
|
|
4542
|
-
version:
|
|
4543
|
-
slug:
|
|
4544
|
-
source:
|
|
4545
|
-
docs:
|
|
4650
|
+
var Gc = {
|
|
4651
|
+
version: Vc,
|
|
4652
|
+
slug: Bc,
|
|
4653
|
+
source: Hc,
|
|
4654
|
+
docs: Uc,
|
|
4546
4655
|
plan: "open",
|
|
4547
4656
|
title: "Enable content negotiation",
|
|
4548
4657
|
summary: "Serves the same route as HTML, Markdown, or JSON using sveltekit-negotiate.",
|
|
@@ -4550,6 +4659,7 @@ var kc = {
|
|
|
4550
4659
|
auth: !1,
|
|
4551
4660
|
api: !1,
|
|
4552
4661
|
apiKeys: !1,
|
|
4662
|
+
backend: !1,
|
|
4553
4663
|
i18n: !1,
|
|
4554
4664
|
teams: !1,
|
|
4555
4665
|
payments: !1,
|
|
@@ -4572,17 +4682,17 @@ var kc = {
|
|
|
4572
4682
|
examples: [],
|
|
4573
4683
|
tests: 0,
|
|
4574
4684
|
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
|
|
4685
|
+
generate: Wc
|
|
4686
|
+
}, 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({
|
|
4687
|
+
"./creates/src/hooks.ts": Kc,
|
|
4688
|
+
"./creates/src/lib/components/language-select.svelte": qc,
|
|
4689
|
+
"./creates/src/lib/url.ts": Jc,
|
|
4690
|
+
"./creates/wuchale.config.js": Yc
|
|
4691
|
+
}), Zc = "./creates/";
|
|
4692
|
+
async function Qc(e) {
|
|
4583
4693
|
return {
|
|
4584
|
-
creates: Object.entries(
|
|
4585
|
-
let n = o(e,
|
|
4694
|
+
creates: Object.entries(Xc).map(([e, t]) => {
|
|
4695
|
+
let n = o(e, Zc);
|
|
4586
4696
|
return {
|
|
4587
4697
|
path: n,
|
|
4588
4698
|
language: r(n),
|
|
@@ -4601,19 +4711,19 @@ async function Ic(e) {
|
|
|
4601
4711
|
}
|
|
4602
4712
|
//#endregion
|
|
4603
4713
|
//#region src/patterns/enable/i18n/generate.preview.ts
|
|
4604
|
-
var
|
|
4714
|
+
var $c = /* @__PURE__ */ Object.assign({
|
|
4605
4715
|
"./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
4716
|
"./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
4717
|
"./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
4718
|
"./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
4719
|
"./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
4720
|
"./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
|
|
4721
|
+
}), el = "./preview-modifies/";
|
|
4722
|
+
async function tl(e) {
|
|
4613
4723
|
return {
|
|
4614
4724
|
creates: [],
|
|
4615
|
-
modifies: Object.entries(
|
|
4616
|
-
let n = o(e,
|
|
4725
|
+
modifies: Object.entries($c).map(([e, t]) => {
|
|
4726
|
+
let n = o(e, el);
|
|
4617
4727
|
return {
|
|
4618
4728
|
path: n,
|
|
4619
4729
|
language: r(n),
|
|
@@ -4631,18 +4741,18 @@ async function zc(e) {
|
|
|
4631
4741
|
}
|
|
4632
4742
|
//#endregion
|
|
4633
4743
|
//#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-
|
|
4744
|
+
var nl = "enable-i18n", rl = "1.0.0", il = "src/patterns/enable/i18n", al = "/enable/i18n";
|
|
4745
|
+
async function ol(e) {
|
|
4746
|
+
let t = await Qc(e);
|
|
4747
|
+
if (e.env === "preview") return y(n([t, await tl(e)]));
|
|
4748
|
+
let { generate: r } = await import("./chunks/generate.runtime-DjwRKg8K.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4639
4749
|
return a(await y(n([t, i])), e);
|
|
4640
4750
|
}
|
|
4641
|
-
var
|
|
4642
|
-
version:
|
|
4643
|
-
slug:
|
|
4644
|
-
source:
|
|
4645
|
-
docs:
|
|
4751
|
+
var sl = {
|
|
4752
|
+
version: rl,
|
|
4753
|
+
slug: nl,
|
|
4754
|
+
source: il,
|
|
4755
|
+
docs: al,
|
|
4646
4756
|
plan: "open",
|
|
4647
4757
|
title: "Enable i18n",
|
|
4648
4758
|
summary: "Enables i18n with Wuchale and locale-aware routing.",
|
|
@@ -4650,6 +4760,7 @@ var Gc = {
|
|
|
4650
4760
|
auth: !1,
|
|
4651
4761
|
api: !1,
|
|
4652
4762
|
apiKeys: !1,
|
|
4763
|
+
backend: !1,
|
|
4653
4764
|
i18n: !1,
|
|
4654
4765
|
teams: !1,
|
|
4655
4766
|
payments: !1,
|
|
@@ -4672,17 +4783,17 @@ var Gc = {
|
|
|
4672
4783
|
examples: [],
|
|
4673
4784
|
tests: 0,
|
|
4674
4785
|
baseline: "velastack",
|
|
4675
|
-
generate:
|
|
4676
|
-
},
|
|
4786
|
+
generate: ol
|
|
4787
|
+
}, cl = /* @__PURE__ */ Object.assign({
|
|
4677
4788
|
"./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
4789
|
"./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
4790
|
"./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
4791
|
"./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
|
|
4792
|
+
}), ll = "./creates/";
|
|
4793
|
+
async function ul(e) {
|
|
4683
4794
|
return {
|
|
4684
|
-
creates: Object.entries(
|
|
4685
|
-
let n = o(e,
|
|
4795
|
+
creates: Object.entries(cl).map(([e, t]) => {
|
|
4796
|
+
let n = o(e, ll);
|
|
4686
4797
|
return {
|
|
4687
4798
|
path: n,
|
|
4688
4799
|
language: r(n),
|
|
@@ -4701,8 +4812,8 @@ async function Jc(e) {
|
|
|
4701
4812
|
}
|
|
4702
4813
|
//#endregion
|
|
4703
4814
|
//#region src/patterns/enable/notifications/preview-modifies/src/lib/utils.ts?raw
|
|
4704
|
-
var
|
|
4705
|
-
function
|
|
4815
|
+
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";
|
|
4816
|
+
function pl(e) {
|
|
4706
4817
|
let t = d.find((t) => t.collectionName === e);
|
|
4707
4818
|
if (!t) throw Error(`notifications: missing NOTIFICATION_RULE_PATCHES entry for "${e}"`);
|
|
4708
4819
|
return {
|
|
@@ -4713,10 +4824,10 @@ function Zc(e) {
|
|
|
4713
4824
|
deleteRule: t.deleteRule
|
|
4714
4825
|
};
|
|
4715
4826
|
}
|
|
4716
|
-
var
|
|
4827
|
+
var ml = [{
|
|
4717
4828
|
name: "notifications",
|
|
4718
4829
|
type: "base",
|
|
4719
|
-
...
|
|
4830
|
+
...pl("notifications"),
|
|
4720
4831
|
indexes: ["CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)"],
|
|
4721
4832
|
fields: [
|
|
4722
4833
|
{
|
|
@@ -4733,7 +4844,7 @@ var Qc = [{
|
|
|
4733
4844
|
name: "user",
|
|
4734
4845
|
type: "relation",
|
|
4735
4846
|
cascadeDelete: !0,
|
|
4736
|
-
collectionId:
|
|
4847
|
+
collectionId: fl,
|
|
4737
4848
|
maxSelect: 1,
|
|
4738
4849
|
minSelect: 0,
|
|
4739
4850
|
required: !0
|
|
@@ -4764,12 +4875,12 @@ var Qc = [{
|
|
|
4764
4875
|
onUpdate: !0
|
|
4765
4876
|
}
|
|
4766
4877
|
]
|
|
4767
|
-
}],
|
|
4768
|
-
async function
|
|
4878
|
+
}], hl = /* @__PURE__ */ Object.assign({ "./preview-modifies/src/lib/utils.ts": dl }), gl = "./preview-modifies/";
|
|
4879
|
+
async function _l(e) {
|
|
4769
4880
|
return {
|
|
4770
4881
|
creates: [],
|
|
4771
|
-
modifies: Object.entries(
|
|
4772
|
-
let n = o(e,
|
|
4882
|
+
modifies: Object.entries(hl).map(([e, t]) => {
|
|
4883
|
+
let n = o(e, gl);
|
|
4773
4884
|
return {
|
|
4774
4885
|
path: n,
|
|
4775
4886
|
language: r(n),
|
|
@@ -4780,25 +4891,25 @@ async function tl(e) {
|
|
|
4780
4891
|
deletes: [],
|
|
4781
4892
|
components: [],
|
|
4782
4893
|
packages: [],
|
|
4783
|
-
collections:
|
|
4894
|
+
collections: ml,
|
|
4784
4895
|
collectionPatches: [],
|
|
4785
4896
|
collectionDrops: []
|
|
4786
4897
|
};
|
|
4787
4898
|
}
|
|
4788
4899
|
//#endregion
|
|
4789
4900
|
//#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-
|
|
4901
|
+
var vl = "enable-notifications", yl = "1.0.0", bl = "src/patterns/enable/notifications", xl = "/enable/notifications";
|
|
4902
|
+
async function Sl(e) {
|
|
4903
|
+
let t = await ul(e);
|
|
4904
|
+
if (e.env === "preview") return y(n([t, await _l(e)]));
|
|
4905
|
+
let { generate: r } = await import("./chunks/generate.runtime-Bpx69a8t.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
4795
4906
|
return a(await y(n([t, i])), e);
|
|
4796
4907
|
}
|
|
4797
|
-
var
|
|
4798
|
-
version:
|
|
4799
|
-
slug:
|
|
4800
|
-
source:
|
|
4801
|
-
docs:
|
|
4908
|
+
var Cl = {
|
|
4909
|
+
version: yl,
|
|
4910
|
+
slug: vl,
|
|
4911
|
+
source: bl,
|
|
4912
|
+
docs: xl,
|
|
4802
4913
|
plan: "open",
|
|
4803
4914
|
title: "Enable notifications",
|
|
4804
4915
|
summary: "Adds an in-app notifications collection, a bell dropdown with 30s polling, and a /notifications page for managing read state.",
|
|
@@ -4806,6 +4917,7 @@ var sl = {
|
|
|
4806
4917
|
auth: !0,
|
|
4807
4918
|
api: !1,
|
|
4808
4919
|
apiKeys: !1,
|
|
4920
|
+
backend: !0,
|
|
4809
4921
|
i18n: !1,
|
|
4810
4922
|
teams: !1,
|
|
4811
4923
|
payments: !1,
|
|
@@ -4829,50 +4941,50 @@ var sl = {
|
|
|
4829
4941
|
examples: [],
|
|
4830
4942
|
tests: 6,
|
|
4831
4943
|
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":
|
|
4944
|
+
generate: Sl
|
|
4945
|
+
}, 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({
|
|
4946
|
+
"./creates/data/hooks/stripe.pb.js": wl,
|
|
4947
|
+
"./creates/data/hooks/utils.js": Tl,
|
|
4948
|
+
"./creates/src/lib/components/payments/confirm-dialog.svelte": El,
|
|
4949
|
+
"./creates/src/lib/components/payments/payment-button.svelte": Dl,
|
|
4950
|
+
"./creates/src/lib/components/payments/payment-dialog.svelte": Ol,
|
|
4951
|
+
"./creates/src/lib/components/payments/stripe-constants.ts": kl,
|
|
4952
|
+
"./creates/src/lib/components/payments/stripe-payment-form.svelte": Al,
|
|
4953
|
+
"./creates/src/lib/components/payments/use-payment-intent.svelte.ts": jl,
|
|
4954
|
+
"./creates/src/lib/components/payments/use-stripe.svelte.ts": Ml,
|
|
4955
|
+
"./creates/src/lib/stripe.ts": Nl,
|
|
4956
|
+
"./creates/src/routes/api/stripe/payment-intent/+server.ts": Pl,
|
|
4957
|
+
"./creates/src/routes/api/stripe/payment-intent/server.test.ts": Fl,
|
|
4958
|
+
"./creates/src/routes/api/stripe/sync/prices/+server.ts": Il,
|
|
4959
|
+
"./creates/src/routes/api/stripe/sync/products/+server.ts": Ll,
|
|
4960
|
+
"./creates/src/routes/webhooks/stripe/+server.ts": Rl,
|
|
4961
|
+
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": zl,
|
|
4962
|
+
"./creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": Bl,
|
|
4963
|
+
"./creates/src/routes/webhooks/stripe/server.test.ts": Vl
|
|
4964
|
+
}), au = /* @__PURE__ */ Object.assign({
|
|
4965
|
+
"./creates-app-mode/data/hooks/stripe.pb.js": Hl,
|
|
4966
|
+
"./creates-app-mode/data/hooks/utils.js": Ul,
|
|
4967
|
+
"./creates-app-mode/src/lib/components/payments/setup-button.svelte": Wl,
|
|
4968
|
+
"./creates-app-mode/src/lib/components/payments/setup-dialog.svelte": Gl,
|
|
4969
|
+
"./creates-app-mode/src/routes/(app)/billing/+layout.server.ts": Kl,
|
|
4858
4970
|
"./creates-app-mode/src/routes/(app)/billing/+page.server.ts": p,
|
|
4859
4971
|
"./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(
|
|
4972
|
+
"./creates-app-mode/src/routes/(app)/billing/README.md": ql,
|
|
4973
|
+
"./creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts": Jl,
|
|
4974
|
+
"./creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts": Yl,
|
|
4975
|
+
"./creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts": Xl,
|
|
4976
|
+
"./creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts": Zl,
|
|
4977
|
+
"./creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts": Ql,
|
|
4978
|
+
"./creates-app-mode/src/routes/webhooks/stripe/+server.ts": $l,
|
|
4979
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": eu,
|
|
4980
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": tu,
|
|
4981
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": nu,
|
|
4982
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": ru
|
|
4983
|
+
}), ou = "./creates/", su = "./creates-app-mode/";
|
|
4984
|
+
async function cu(e) {
|
|
4985
|
+
let t = e.features.auth, n = { ...a(iu, ou) };
|
|
4874
4986
|
if (t) {
|
|
4875
|
-
let e = a(
|
|
4987
|
+
let e = a(au, su);
|
|
4876
4988
|
Object.assign(n, e);
|
|
4877
4989
|
}
|
|
4878
4990
|
let r = Object.values(n).sort((e, t) => e.path.localeCompare(t.path)), i = [
|
|
@@ -4893,7 +5005,7 @@ async function Kl(e) {
|
|
|
4893
5005
|
}
|
|
4894
5006
|
//#endregion
|
|
4895
5007
|
//#region src/patterns/enable/payments/preview-modifies/src/routes/(public)/signup/+page.server.ts?raw
|
|
4896
|
-
var
|
|
5008
|
+
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
5009
|
name: "stripe_products",
|
|
4898
5010
|
type: "base",
|
|
4899
5011
|
fields: [
|
|
@@ -4932,7 +5044,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
4932
5044
|
type: "autodate"
|
|
4933
5045
|
}
|
|
4934
5046
|
]
|
|
4935
|
-
},
|
|
5047
|
+
}, mu = {
|
|
4936
5048
|
name: "stripe_prices",
|
|
4937
5049
|
type: "base",
|
|
4938
5050
|
fields: [
|
|
@@ -4991,8 +5103,8 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
4991
5103
|
type: "autodate"
|
|
4992
5104
|
}
|
|
4993
5105
|
]
|
|
4994
|
-
},
|
|
4995
|
-
name:
|
|
5106
|
+
}, hu = {
|
|
5107
|
+
name: du,
|
|
4996
5108
|
type: "base",
|
|
4997
5109
|
fields: [
|
|
4998
5110
|
{
|
|
@@ -5003,7 +5115,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5003
5115
|
type: "text"
|
|
5004
5116
|
},
|
|
5005
5117
|
{
|
|
5006
|
-
collectionId:
|
|
5118
|
+
collectionId: uu,
|
|
5007
5119
|
maxSelect: 1,
|
|
5008
5120
|
minSelect: 0,
|
|
5009
5121
|
name: "user",
|
|
@@ -5011,7 +5123,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5011
5123
|
type: "relation"
|
|
5012
5124
|
},
|
|
5013
5125
|
{
|
|
5014
|
-
collectionId:
|
|
5126
|
+
collectionId: fu,
|
|
5015
5127
|
maxSelect: 1,
|
|
5016
5128
|
minSelect: 0,
|
|
5017
5129
|
name: "default_payment_method",
|
|
@@ -5031,8 +5143,8 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5031
5143
|
type: "autodate"
|
|
5032
5144
|
}
|
|
5033
5145
|
]
|
|
5034
|
-
},
|
|
5035
|
-
name:
|
|
5146
|
+
}, gu = {
|
|
5147
|
+
name: fu,
|
|
5036
5148
|
type: "base",
|
|
5037
5149
|
fields: [
|
|
5038
5150
|
{
|
|
@@ -5063,7 +5175,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5063
5175
|
type: "number"
|
|
5064
5176
|
},
|
|
5065
5177
|
{
|
|
5066
|
-
collectionId:
|
|
5178
|
+
collectionId: du,
|
|
5067
5179
|
maxSelect: 1,
|
|
5068
5180
|
minSelect: 0,
|
|
5069
5181
|
name: "customer",
|
|
@@ -5084,7 +5196,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5084
5196
|
type: "autodate"
|
|
5085
5197
|
}
|
|
5086
5198
|
]
|
|
5087
|
-
},
|
|
5199
|
+
}, _u = {
|
|
5088
5200
|
name: "transactions",
|
|
5089
5201
|
type: "base",
|
|
5090
5202
|
fields: [
|
|
@@ -5139,7 +5251,7 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5139
5251
|
type: "text"
|
|
5140
5252
|
},
|
|
5141
5253
|
{
|
|
5142
|
-
collectionId:
|
|
5254
|
+
collectionId: uu,
|
|
5143
5255
|
maxSelect: 1,
|
|
5144
5256
|
minSelect: 0,
|
|
5145
5257
|
name: "user",
|
|
@@ -5152,20 +5264,20 @@ var ql = "import { redirect } from \"@sveltejs/kit\";\nimport { fail, superValid
|
|
|
5152
5264
|
type: "url"
|
|
5153
5265
|
}
|
|
5154
5266
|
]
|
|
5155
|
-
},
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
],
|
|
5267
|
+
}, vu = [pu, mu], yu = [
|
|
5268
|
+
hu,
|
|
5269
|
+
gu,
|
|
5270
|
+
_u
|
|
5271
|
+
], bu, xu = /* @__PURE__ */ Object.assign({
|
|
5160
5272
|
"./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,
|
|
5273
|
+
"./preview-modifies/src/routes/(public)/signup/+page.server.ts": lu
|
|
5274
|
+
}), Su = "./preview-modifies/", Cu = "price_preview_placeholder";
|
|
5275
|
+
function wu(e) {
|
|
5276
|
+
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);
|
|
5277
|
+
}
|
|
5278
|
+
async function Tu(e) {
|
|
5279
|
+
let t = e.features.auth, n = Object.entries(xu).map(([e, t]) => {
|
|
5280
|
+
let n = o(e, Su);
|
|
5169
5281
|
return {
|
|
5170
5282
|
path: n,
|
|
5171
5283
|
language: r(n),
|
|
@@ -5175,9 +5287,9 @@ async function lu(e) {
|
|
|
5175
5287
|
}).sort((e, t) => e.path.localeCompare(t.path)), i = {
|
|
5176
5288
|
path: "src/routes/(public)/payment/+page.svelte",
|
|
5177
5289
|
language: "svelte",
|
|
5178
|
-
content:
|
|
5290
|
+
content: wu(Cu),
|
|
5179
5291
|
status: "success"
|
|
5180
|
-
}, a = [...
|
|
5292
|
+
}, a = [...vu, ...t ? yu : []];
|
|
5181
5293
|
return {
|
|
5182
5294
|
creates: [i],
|
|
5183
5295
|
modifies: n,
|
|
@@ -5191,18 +5303,18 @@ async function lu(e) {
|
|
|
5191
5303
|
}
|
|
5192
5304
|
//#endregion
|
|
5193
5305
|
//#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-
|
|
5306
|
+
var Eu = "enable-payments", Du = "1.0.0", Ou = "src/patterns/enable/payments", ku = "/enable/payments";
|
|
5307
|
+
async function Au(e) {
|
|
5308
|
+
let t = await cu(e);
|
|
5309
|
+
if (e.env === "preview") return y(n([t, await Tu(e)]));
|
|
5310
|
+
let { generate: r } = await import("./chunks/generate.runtime-DQLmiRz6.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5199
5311
|
return a(await y(n([t, i])), e);
|
|
5200
5312
|
}
|
|
5201
|
-
var
|
|
5202
|
-
version:
|
|
5203
|
-
slug:
|
|
5204
|
-
source:
|
|
5205
|
-
docs:
|
|
5313
|
+
var ju = {
|
|
5314
|
+
version: Du,
|
|
5315
|
+
slug: Eu,
|
|
5316
|
+
source: Ou,
|
|
5317
|
+
docs: ku,
|
|
5206
5318
|
plan: "pro",
|
|
5207
5319
|
title: "Enable payments",
|
|
5208
5320
|
summary: "Adds Stripe payments with product/price sync, checkout flow, and optional saved payment methods when auth is enabled.",
|
|
@@ -5210,6 +5322,7 @@ var hu = {
|
|
|
5210
5322
|
auth: !1,
|
|
5211
5323
|
api: !1,
|
|
5212
5324
|
apiKeys: !1,
|
|
5325
|
+
backend: !0,
|
|
5213
5326
|
i18n: !1,
|
|
5214
5327
|
teams: !1,
|
|
5215
5328
|
payments: !1,
|
|
@@ -5233,14 +5346,14 @@ var hu = {
|
|
|
5233
5346
|
examples: [],
|
|
5234
5347
|
tests: 0,
|
|
5235
5348
|
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
|
-
}),
|
|
5349
|
+
generate: Au
|
|
5350
|
+
}, 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({
|
|
5351
|
+
"./creates/src/routes/api/stripe/sync/subscriptions/+server.ts": Mu,
|
|
5352
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": Nu,
|
|
5353
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": Pu,
|
|
5354
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": Fu,
|
|
5355
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": Iu
|
|
5356
|
+
}), Ru = "./creates/", zu = {
|
|
5244
5357
|
name: "stripe_subscriptions",
|
|
5245
5358
|
type: "base",
|
|
5246
5359
|
fields: [
|
|
@@ -5315,10 +5428,10 @@ var hu = {
|
|
|
5315
5428
|
}
|
|
5316
5429
|
]
|
|
5317
5430
|
};
|
|
5318
|
-
async function
|
|
5431
|
+
async function Bu(e) {
|
|
5319
5432
|
return {
|
|
5320
|
-
creates: Object.entries(
|
|
5321
|
-
let n = o(e,
|
|
5433
|
+
creates: Object.entries(Lu).map(([e, t]) => {
|
|
5434
|
+
let n = o(e, Ru);
|
|
5322
5435
|
return {
|
|
5323
5436
|
path: n,
|
|
5324
5437
|
language: r(n),
|
|
@@ -5330,14 +5443,14 @@ async function wu(e) {
|
|
|
5330
5443
|
deletes: [],
|
|
5331
5444
|
components: [],
|
|
5332
5445
|
packages: [],
|
|
5333
|
-
collections: [
|
|
5446
|
+
collections: [zu],
|
|
5334
5447
|
collectionPatches: [],
|
|
5335
5448
|
collectionDrops: []
|
|
5336
5449
|
};
|
|
5337
5450
|
}
|
|
5338
5451
|
//#endregion
|
|
5339
5452
|
//#region src/patterns/enable/subscriptions/generate.preview.ts
|
|
5340
|
-
var
|
|
5453
|
+
var Vu = /* @__PURE__ */ Object.assign({
|
|
5341
5454
|
"./preview-modifies/data/hooks/stripe.pb.js": ee,
|
|
5342
5455
|
"./preview-modifies/src/lib/components/app-sidebar.svelte": re,
|
|
5343
5456
|
"./preview-modifies/src/lib/components/nav-user.svelte": te,
|
|
@@ -5346,12 +5459,12 @@ var Tu = /* @__PURE__ */ Object.assign({
|
|
|
5346
5459
|
"./preview-modifies/src/routes/(app)/billing/+page.server.ts": ne,
|
|
5347
5460
|
"./preview-modifies/src/routes/(app)/billing/+page.svelte": _,
|
|
5348
5461
|
"./preview-modifies/src/routes/webhooks/stripe/+server.ts": ie
|
|
5349
|
-
}),
|
|
5350
|
-
async function
|
|
5462
|
+
}), Hu = "./preview-modifies/";
|
|
5463
|
+
async function Uu(e) {
|
|
5351
5464
|
return {
|
|
5352
5465
|
creates: [],
|
|
5353
|
-
modifies: Object.entries(
|
|
5354
|
-
let n = o(e,
|
|
5466
|
+
modifies: Object.entries(Vu).map(([e, t]) => {
|
|
5467
|
+
let n = o(e, Hu);
|
|
5355
5468
|
return {
|
|
5356
5469
|
path: n,
|
|
5357
5470
|
language: r(n),
|
|
@@ -5369,21 +5482,21 @@ async function Du(e) {
|
|
|
5369
5482
|
}
|
|
5370
5483
|
//#endregion
|
|
5371
5484
|
//#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-
|
|
5485
|
+
var Wu = "enable-subscriptions", Gu = "1.0.0", Ku = "src/patterns/enable/subscriptions", qu = "/enable/subscriptions";
|
|
5486
|
+
async function Ju(e) {
|
|
5487
|
+
let t = await Bu(e);
|
|
5488
|
+
if (e.env === "preview") return y(n([t, await Uu(e)]));
|
|
5489
|
+
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
5490
|
return s(await y(n([{
|
|
5378
5491
|
...t,
|
|
5379
5492
|
creates: [...t.creates, ...i]
|
|
5380
5493
|
}, o])), e);
|
|
5381
5494
|
}
|
|
5382
|
-
var
|
|
5383
|
-
version:
|
|
5384
|
-
slug:
|
|
5385
|
-
source:
|
|
5386
|
-
docs:
|
|
5495
|
+
var Yu = {
|
|
5496
|
+
version: Gu,
|
|
5497
|
+
slug: Wu,
|
|
5498
|
+
source: Ku,
|
|
5499
|
+
docs: qu,
|
|
5387
5500
|
plan: "pro",
|
|
5388
5501
|
title: "Enable subscriptions",
|
|
5389
5502
|
summary: "Adds Stripe subscription billing with plan selection, cancel/resume, and webhook-synced subscription state. Requires enable-payments.",
|
|
@@ -5391,6 +5504,7 @@ var Nu = {
|
|
|
5391
5504
|
auth: !0,
|
|
5392
5505
|
api: !1,
|
|
5393
5506
|
apiKeys: !1,
|
|
5507
|
+
backend: !0,
|
|
5394
5508
|
i18n: !1,
|
|
5395
5509
|
teams: !1,
|
|
5396
5510
|
payments: !0,
|
|
@@ -5415,52 +5529,52 @@ var Nu = {
|
|
|
5415
5529
|
examples: [],
|
|
5416
5530
|
tests: 0,
|
|
5417
5531
|
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":
|
|
5532
|
+
generate: Ju
|
|
5533
|
+
}, 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({
|
|
5534
|
+
"./creates/src/lib/components/team-switcher.svelte": Xu,
|
|
5535
|
+
"./creates/src/lib/schemas/team.ts": Zu,
|
|
5536
|
+
"./creates/src/lib/schemas/teamInvite.ts": Qu,
|
|
5537
|
+
"./creates/src/lib/schemas/teamRole.ts": $u,
|
|
5538
|
+
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte": ed,
|
|
5539
|
+
"./creates/src/routes/(app)/invite/[id]/+page.server.ts": td,
|
|
5540
|
+
"./creates/src/routes/(app)/invite/[id]/+page.svelte": nd,
|
|
5541
|
+
"./creates/src/routes/(app)/invite/[id]/+page.ts": rd,
|
|
5542
|
+
"./creates/src/routes/(app)/join/[id]/+layout@.svelte": id,
|
|
5543
|
+
"./creates/src/routes/(app)/join/[id]/+page.server.ts": ad,
|
|
5544
|
+
"./creates/src/routes/(app)/join/[id]/+page.svelte": od,
|
|
5545
|
+
"./creates/src/routes/(app)/join/[id]/+page.ts": sd,
|
|
5546
|
+
"./creates/src/routes/(app)/teams/+layout.server.ts": cd,
|
|
5547
|
+
"./creates/src/routes/(app)/teams/+layout.svelte": ld,
|
|
5548
|
+
"./creates/src/routes/(app)/teams/+page.server.ts": ud,
|
|
5435
5549
|
"./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":
|
|
5550
|
+
"./creates/src/routes/(app)/teams/+page.ts": dd,
|
|
5551
|
+
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts": fd,
|
|
5552
|
+
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": pd,
|
|
5553
|
+
"./creates/src/routes/(app)/teams/[id]/+page.server.ts": md,
|
|
5440
5554
|
"./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
|
|
5555
|
+
"./creates/src/routes/(app)/teams/[id]/+page.ts": hd,
|
|
5556
|
+
"./creates/src/routes/(app)/teams/[id]/authorization.ts": gd,
|
|
5557
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": _d,
|
|
5558
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte": vd,
|
|
5559
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts": yd,
|
|
5560
|
+
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts": bd,
|
|
5561
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": xd,
|
|
5562
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": Sd,
|
|
5563
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": Cd,
|
|
5564
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": wd,
|
|
5565
|
+
"./creates/src/routes/(app)/teams/[id]/server.test.ts": Td,
|
|
5566
|
+
"./creates/src/routes/(app)/teams/new/+page.server.ts": Ed,
|
|
5567
|
+
"./creates/src/routes/(app)/teams/new/+page.svelte": Dd,
|
|
5568
|
+
"./creates/src/routes/(app)/teams/new/+page.ts": Od,
|
|
5569
|
+
"./creates/src/routes/(app)/teams/new/server.test.ts": kd,
|
|
5570
|
+
"./creates/src/routes/(app)/teams/server.test.ts": Ad,
|
|
5571
|
+
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": jd,
|
|
5572
|
+
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts": Md
|
|
5573
|
+
}), Pd = "./creates/";
|
|
5574
|
+
async function Fd(e) {
|
|
5461
5575
|
return {
|
|
5462
|
-
creates: Object.entries(
|
|
5463
|
-
let n = o(e,
|
|
5576
|
+
creates: Object.entries(Nd).map(([e, t]) => {
|
|
5577
|
+
let n = o(e, Pd);
|
|
5464
5578
|
return {
|
|
5465
5579
|
path: n,
|
|
5466
5580
|
language: r(n),
|
|
@@ -5491,7 +5605,7 @@ async function yd(e) {
|
|
|
5491
5605
|
}
|
|
5492
5606
|
//#endregion
|
|
5493
5607
|
//#region src/patterns/enable/teams/preview-modifies/src/lib/components/app-sidebar.svelte?raw
|
|
5494
|
-
var
|
|
5608
|
+
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
5609
|
function $(e) {
|
|
5496
5610
|
let t = ae.find((t) => t.collectionName === e);
|
|
5497
5611
|
if (!t) throw Error(`teams: missing TEAM_RULE_PATCHES entry for "${e}"`);
|
|
@@ -5503,7 +5617,7 @@ function $(e) {
|
|
|
5503
5617
|
deleteRule: t.deleteRule
|
|
5504
5618
|
};
|
|
5505
5619
|
}
|
|
5506
|
-
var
|
|
5620
|
+
var Hd = [
|
|
5507
5621
|
{
|
|
5508
5622
|
name: "teams",
|
|
5509
5623
|
type: "base",
|
|
@@ -5528,7 +5642,7 @@ var Ed = [
|
|
|
5528
5642
|
name: "owner",
|
|
5529
5643
|
type: "relation",
|
|
5530
5644
|
cascadeDelete: !1,
|
|
5531
|
-
collectionId:
|
|
5645
|
+
collectionId: Bd,
|
|
5532
5646
|
maxSelect: 1,
|
|
5533
5647
|
minSelect: 0,
|
|
5534
5648
|
required: !0
|
|
@@ -5574,7 +5688,7 @@ var Ed = [
|
|
|
5574
5688
|
{
|
|
5575
5689
|
name: "user",
|
|
5576
5690
|
cascadeDelete: !0,
|
|
5577
|
-
collectionId:
|
|
5691
|
+
collectionId: Bd,
|
|
5578
5692
|
maxSelect: 1,
|
|
5579
5693
|
minSelect: 0,
|
|
5580
5694
|
required: !0,
|
|
@@ -5634,7 +5748,7 @@ var Ed = [
|
|
|
5634
5748
|
{
|
|
5635
5749
|
name: "membership_id",
|
|
5636
5750
|
cascadeDelete: !1,
|
|
5637
|
-
collectionId:
|
|
5751
|
+
collectionId: Vd,
|
|
5638
5752
|
maxSelect: 1,
|
|
5639
5753
|
minSelect: 0,
|
|
5640
5754
|
required: !1,
|
|
@@ -5744,17 +5858,17 @@ var Ed = [
|
|
|
5744
5858
|
}
|
|
5745
5859
|
]
|
|
5746
5860
|
}
|
|
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
|
|
5861
|
+
], Ud = /* @__PURE__ */ Object.assign({
|
|
5862
|
+
"./preview-modifies/src/lib/components/app-sidebar.svelte": Id,
|
|
5863
|
+
"./preview-modifies/src/lib/components/nav-user.svelte": Ld,
|
|
5864
|
+
"./preview-modifies/src/routes/(app)/+layout.server.ts": Rd,
|
|
5865
|
+
"./preview-modifies/src/routes/(app)/+layout.svelte": zd
|
|
5866
|
+
}), Wd = "./preview-modifies/";
|
|
5867
|
+
async function Gd(e) {
|
|
5754
5868
|
return {
|
|
5755
5869
|
creates: [],
|
|
5756
|
-
modifies: Object.entries(
|
|
5757
|
-
let n = o(e,
|
|
5870
|
+
modifies: Object.entries(Ud).map(([e, t]) => {
|
|
5871
|
+
let n = o(e, Wd);
|
|
5758
5872
|
return {
|
|
5759
5873
|
path: n,
|
|
5760
5874
|
language: r(n),
|
|
@@ -5765,25 +5879,25 @@ async function kd(e) {
|
|
|
5765
5879
|
deletes: [],
|
|
5766
5880
|
components: [],
|
|
5767
5881
|
packages: [],
|
|
5768
|
-
collections:
|
|
5882
|
+
collections: Hd,
|
|
5769
5883
|
collectionPatches: [],
|
|
5770
5884
|
collectionDrops: []
|
|
5771
5885
|
};
|
|
5772
5886
|
}
|
|
5773
5887
|
//#endregion
|
|
5774
5888
|
//#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/
|
|
5889
|
+
var Kd = "enable-teams", qd = "1.0.0", Jd = "src/patterns/enable/teams", Yd = "/enable/teams";
|
|
5890
|
+
async function Xd(e) {
|
|
5891
|
+
let t = await Fd(e);
|
|
5892
|
+
if (e.env === "preview") return y(n([t, await Gd(e)]));
|
|
5893
|
+
let { generate: r } = await import("./chunks/generate2.runtime-yP14iPwX.js"), i = await r(e), { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5780
5894
|
return a(await y(n([t, i])), e);
|
|
5781
5895
|
}
|
|
5782
|
-
var
|
|
5783
|
-
version:
|
|
5784
|
-
slug:
|
|
5785
|
-
source:
|
|
5786
|
-
docs:
|
|
5896
|
+
var Zd = {
|
|
5897
|
+
version: qd,
|
|
5898
|
+
slug: Kd,
|
|
5899
|
+
source: Jd,
|
|
5900
|
+
docs: Yd,
|
|
5787
5901
|
plan: "pro",
|
|
5788
5902
|
title: "Enable teams",
|
|
5789
5903
|
summary: "Adds multi-tenant teams with memberships, invites, and a sidebar team switcher.",
|
|
@@ -5791,6 +5905,7 @@ var Fd = {
|
|
|
5791
5905
|
auth: !0,
|
|
5792
5906
|
api: !1,
|
|
5793
5907
|
apiKeys: !1,
|
|
5908
|
+
backend: !0,
|
|
5794
5909
|
i18n: !1,
|
|
5795
5910
|
teams: !1,
|
|
5796
5911
|
payments: !1,
|
|
@@ -5814,11 +5929,11 @@ var Fd = {
|
|
|
5814
5929
|
examples: [],
|
|
5815
5930
|
tests: 36,
|
|
5816
5931
|
baseline: "velastack",
|
|
5817
|
-
generate:
|
|
5932
|
+
generate: Xd
|
|
5818
5933
|
};
|
|
5819
5934
|
//#endregion
|
|
5820
5935
|
//#region src/patterns/destroy/schema/generate.ts
|
|
5821
|
-
async function
|
|
5936
|
+
async function Qd(t) {
|
|
5822
5937
|
let [n] = t.argv;
|
|
5823
5938
|
if (!n) throw new e("Invalid command arguments. Expected: <model>");
|
|
5824
5939
|
let i = `src/lib/schemas/${A(n, t).name}.ts`;
|
|
@@ -5840,18 +5955,18 @@ async function Id(t) {
|
|
|
5840
5955
|
}
|
|
5841
5956
|
//#endregion
|
|
5842
5957
|
//#region src/patterns/destroy/schema/index.ts
|
|
5843
|
-
var
|
|
5844
|
-
async function
|
|
5845
|
-
let t = await y(await
|
|
5958
|
+
var $d = "destroy-schema", ef = "1.0.0", tf = "src/patterns/destroy/schema", nf = "/destroy/schema";
|
|
5959
|
+
async function rf(e) {
|
|
5960
|
+
let t = await y(await Qd(e));
|
|
5846
5961
|
if (e.env !== "runtime" || e.input.destructive !== !0) return t;
|
|
5847
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
5962
|
+
let { writeResult: n } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5848
5963
|
return n(t, e);
|
|
5849
5964
|
}
|
|
5850
|
-
var
|
|
5851
|
-
version:
|
|
5852
|
-
slug:
|
|
5853
|
-
source:
|
|
5854
|
-
docs:
|
|
5965
|
+
var af = {
|
|
5966
|
+
version: ef,
|
|
5967
|
+
slug: $d,
|
|
5968
|
+
source: tf,
|
|
5969
|
+
docs: nf,
|
|
5855
5970
|
plan: "open",
|
|
5856
5971
|
title: "Destroy a schema",
|
|
5857
5972
|
summary: "Removes the zod schema file created by generate-schema.",
|
|
@@ -5859,6 +5974,7 @@ var Hd = {
|
|
|
5859
5974
|
auth: !1,
|
|
5860
5975
|
api: !1,
|
|
5861
5976
|
apiKeys: !1,
|
|
5977
|
+
backend: !0,
|
|
5862
5978
|
i18n: !1,
|
|
5863
5979
|
teams: !1,
|
|
5864
5980
|
payments: !1,
|
|
@@ -5882,9 +5998,9 @@ var Hd = {
|
|
|
5882
5998
|
}],
|
|
5883
5999
|
tests: 0,
|
|
5884
6000
|
baseline: "velastack",
|
|
5885
|
-
generate:
|
|
5886
|
-
},
|
|
5887
|
-
async function
|
|
6001
|
+
generate: rf
|
|
6002
|
+
}, of = "destroy-form", sf = "1.0.0", cf = "src/patterns/destroy/form", lf = "/destroy/form";
|
|
6003
|
+
async function uf(t) {
|
|
5888
6004
|
let [n] = t.argv;
|
|
5889
6005
|
if (!n) throw new e("Invalid command arguments. Expected: <model>");
|
|
5890
6006
|
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 +6014,14 @@ async function qd(t) {
|
|
|
5898
6014
|
collectionDrops: []
|
|
5899
6015
|
});
|
|
5900
6016
|
if (t.env !== "runtime" || t.input.destructive !== !0) return s;
|
|
5901
|
-
let { writeResult: c } = await import("./chunks/write-result-
|
|
6017
|
+
let { writeResult: c } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5902
6018
|
return c(s, t);
|
|
5903
6019
|
}
|
|
5904
|
-
var
|
|
5905
|
-
version:
|
|
5906
|
-
slug:
|
|
5907
|
-
source:
|
|
5908
|
-
docs:
|
|
6020
|
+
var df = {
|
|
6021
|
+
version: sf,
|
|
6022
|
+
slug: of,
|
|
6023
|
+
source: cf,
|
|
6024
|
+
docs: lf,
|
|
5909
6025
|
plan: "open",
|
|
5910
6026
|
title: "Destroy a form",
|
|
5911
6027
|
summary: "Removes the route directory and schema file created by generate-form.",
|
|
@@ -5913,6 +6029,7 @@ var Jd = {
|
|
|
5913
6029
|
auth: !1,
|
|
5914
6030
|
api: !1,
|
|
5915
6031
|
apiKeys: !1,
|
|
6032
|
+
backend: !0,
|
|
5916
6033
|
i18n: !1,
|
|
5917
6034
|
teams: !1,
|
|
5918
6035
|
payments: !1,
|
|
@@ -5936,9 +6053,9 @@ var Jd = {
|
|
|
5936
6053
|
}],
|
|
5937
6054
|
tests: 0,
|
|
5938
6055
|
baseline: "velastack",
|
|
5939
|
-
generate:
|
|
5940
|
-
},
|
|
5941
|
-
async function
|
|
6056
|
+
generate: uf
|
|
6057
|
+
}, ff = "destroy-resource", pf = "1.0.0", mf = "src/patterns/destroy/resource", hf = "/destroy/resource";
|
|
6058
|
+
async function gf(t) {
|
|
5942
6059
|
let [n] = t.argv;
|
|
5943
6060
|
if (!n) throw new e("Invalid command arguments. Expected: <model>");
|
|
5944
6061
|
let r = A(n, t), i = `src/lib/schemas/${r.name}.ts`, a = await oe([r.tableName], t), o = await y({
|
|
@@ -5952,14 +6069,14 @@ async function $d(t) {
|
|
|
5952
6069
|
collectionDrops: a
|
|
5953
6070
|
});
|
|
5954
6071
|
if (t.env !== "runtime" || t.input.destructive !== !0) return o;
|
|
5955
|
-
let { writeResult: s } = await import("./chunks/write-result-
|
|
6072
|
+
let { writeResult: s } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
5956
6073
|
return s(o, t);
|
|
5957
6074
|
}
|
|
5958
|
-
var
|
|
5959
|
-
version:
|
|
5960
|
-
slug:
|
|
5961
|
-
source:
|
|
5962
|
-
docs:
|
|
6075
|
+
var _f = {
|
|
6076
|
+
version: pf,
|
|
6077
|
+
slug: ff,
|
|
6078
|
+
source: mf,
|
|
6079
|
+
docs: hf,
|
|
5963
6080
|
plan: "open",
|
|
5964
6081
|
title: "Destroy a resource",
|
|
5965
6082
|
summary: "Drops the collection and removes the schema file created by generate-resource.",
|
|
@@ -5967,6 +6084,7 @@ var ef = {
|
|
|
5967
6084
|
auth: !1,
|
|
5968
6085
|
api: !1,
|
|
5969
6086
|
apiKeys: !1,
|
|
6087
|
+
backend: !0,
|
|
5970
6088
|
i18n: !1,
|
|
5971
6089
|
teams: !1,
|
|
5972
6090
|
payments: !1,
|
|
@@ -5990,9 +6108,9 @@ var ef = {
|
|
|
5990
6108
|
}],
|
|
5991
6109
|
tests: 0,
|
|
5992
6110
|
baseline: "velastack",
|
|
5993
|
-
generate:
|
|
5994
|
-
},
|
|
5995
|
-
async function
|
|
6111
|
+
generate: gf
|
|
6112
|
+
}, vf = "destroy-scaffold", yf = "1.0.0", bf = "src/patterns/destroy/scaffold", xf = "/destroy/scaffold";
|
|
6113
|
+
async function Sf(t) {
|
|
5996
6114
|
let [n] = t.argv;
|
|
5997
6115
|
if (!n) throw new e("Invalid command arguments. Expected: <model>");
|
|
5998
6116
|
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 +6124,14 @@ async function of(t) {
|
|
|
6006
6124
|
collectionDrops: o
|
|
6007
6125
|
});
|
|
6008
6126
|
if (t.env !== "runtime" || t.input.destructive !== !0) return s;
|
|
6009
|
-
let { writeResult: c } = await import("./chunks/write-result-
|
|
6127
|
+
let { writeResult: c } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6010
6128
|
return c(s, t);
|
|
6011
6129
|
}
|
|
6012
|
-
var
|
|
6013
|
-
version:
|
|
6014
|
-
slug:
|
|
6015
|
-
source:
|
|
6016
|
-
docs:
|
|
6130
|
+
var Cf = {
|
|
6131
|
+
version: yf,
|
|
6132
|
+
slug: vf,
|
|
6133
|
+
source: bf,
|
|
6134
|
+
docs: xf,
|
|
6017
6135
|
plan: "open",
|
|
6018
6136
|
title: "Destroy a scaffold",
|
|
6019
6137
|
summary: "Removes the route directory and schema file created by generate-scaffold and drops the collection. Retains shadcn components.",
|
|
@@ -6021,6 +6139,7 @@ var sf = {
|
|
|
6021
6139
|
auth: !1,
|
|
6022
6140
|
api: !1,
|
|
6023
6141
|
apiKeys: !1,
|
|
6142
|
+
backend: !0,
|
|
6024
6143
|
i18n: !1,
|
|
6025
6144
|
teams: !1,
|
|
6026
6145
|
payments: !1,
|
|
@@ -6045,14 +6164,14 @@ var sf = {
|
|
|
6045
6164
|
}],
|
|
6046
6165
|
tests: 0,
|
|
6047
6166
|
baseline: "velastack",
|
|
6048
|
-
generate:
|
|
6049
|
-
},
|
|
6050
|
-
async function
|
|
6167
|
+
generate: Sf
|
|
6168
|
+
}, wf = /* @__PURE__ */ Object.assign({ "../../enable/api/creates/src/routes/api/server.test.ts": Wo }), Tf = "../../enable/api/creates/";
|
|
6169
|
+
async function Ef(e) {
|
|
6051
6170
|
return {
|
|
6052
6171
|
creates: [],
|
|
6053
6172
|
modifies: [],
|
|
6054
|
-
deletes: Object.keys(
|
|
6055
|
-
let t = o(e,
|
|
6173
|
+
deletes: Object.keys(wf).map((e) => {
|
|
6174
|
+
let t = o(e, Tf);
|
|
6056
6175
|
return {
|
|
6057
6176
|
path: t,
|
|
6058
6177
|
language: r(t),
|
|
@@ -6069,20 +6188,20 @@ async function uf(e) {
|
|
|
6069
6188
|
}
|
|
6070
6189
|
//#endregion
|
|
6071
6190
|
//#region src/patterns/disable/api/index.ts
|
|
6072
|
-
var
|
|
6073
|
-
async function
|
|
6074
|
-
let t = await
|
|
6191
|
+
var Df = "disable-api", Of = "1.0.0", kf = "src/patterns/disable/api", Af = "/disable/api";
|
|
6192
|
+
async function jf(e) {
|
|
6193
|
+
let t = await Ef(e);
|
|
6075
6194
|
if (e.env !== "runtime") return y(t);
|
|
6076
6195
|
let { generate: r } = await import("./chunks/generate.runtime-CZALdXt6.js"), i = await y(n([t, await r(e)]));
|
|
6077
6196
|
if (e.input.destructive !== !0) return i;
|
|
6078
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6197
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6079
6198
|
return a(i, e);
|
|
6080
6199
|
}
|
|
6081
|
-
var
|
|
6082
|
-
version:
|
|
6083
|
-
slug:
|
|
6084
|
-
source:
|
|
6085
|
-
docs:
|
|
6200
|
+
var Mf = {
|
|
6201
|
+
version: Of,
|
|
6202
|
+
slug: Df,
|
|
6203
|
+
source: kf,
|
|
6204
|
+
docs: Af,
|
|
6086
6205
|
plan: "open",
|
|
6087
6206
|
title: "Disable API",
|
|
6088
6207
|
summary: "Disables the PocketBase API handler.",
|
|
@@ -6090,6 +6209,7 @@ var gf = {
|
|
|
6090
6209
|
auth: !1,
|
|
6091
6210
|
api: !0,
|
|
6092
6211
|
apiKeys: !1,
|
|
6212
|
+
backend: !0,
|
|
6093
6213
|
i18n: !1,
|
|
6094
6214
|
teams: !1,
|
|
6095
6215
|
payments: !1,
|
|
@@ -6113,8 +6233,8 @@ var gf = {
|
|
|
6113
6233
|
examples: [],
|
|
6114
6234
|
tests: 0,
|
|
6115
6235
|
baseline: "velastack",
|
|
6116
|
-
generate:
|
|
6117
|
-
},
|
|
6236
|
+
generate: jf
|
|
6237
|
+
}, Nf = /* @__PURE__ */ Object.assign({
|
|
6118
6238
|
"../../enable/api-keys/creates/src/lib/schemas/apiKey.ts": rs,
|
|
6119
6239
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.server.ts": is,
|
|
6120
6240
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.svelte": as,
|
|
@@ -6127,13 +6247,13 @@ var gf = {
|
|
|
6127
6247
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/create-api-key.ts": ds,
|
|
6128
6248
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/server.test.ts": fs,
|
|
6129
6249
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/server.test.ts": ps
|
|
6130
|
-
}),
|
|
6131
|
-
async function
|
|
6250
|
+
}), Pf = "../../enable/api-keys/creates/";
|
|
6251
|
+
async function Ff(e) {
|
|
6132
6252
|
return {
|
|
6133
6253
|
creates: [],
|
|
6134
6254
|
modifies: [],
|
|
6135
|
-
deletes: Object.keys(
|
|
6136
|
-
let t = o(e,
|
|
6255
|
+
deletes: Object.keys(Nf).map((e) => {
|
|
6256
|
+
let t = o(e, Pf);
|
|
6137
6257
|
return {
|
|
6138
6258
|
path: t,
|
|
6139
6259
|
language: r(t),
|
|
@@ -6150,20 +6270,20 @@ async function yf(e) {
|
|
|
6150
6270
|
}
|
|
6151
6271
|
//#endregion
|
|
6152
6272
|
//#region src/patterns/disable/api-keys/index.ts
|
|
6153
|
-
var
|
|
6154
|
-
async function
|
|
6155
|
-
let t = await
|
|
6273
|
+
var If = "disable-api-keys", Lf = "1.0.0", Rf = "src/patterns/disable/api-keys", zf = "/disable/api-keys";
|
|
6274
|
+
async function Bf(e) {
|
|
6275
|
+
let t = await Ff(e);
|
|
6156
6276
|
if (e.env !== "runtime") return y(t);
|
|
6157
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6277
|
+
let { generate: r } = await import("./chunks/generate.runtime-D1wqmaXU.js"), i = await y(n([t, await r(e)]));
|
|
6158
6278
|
if (e.input.destructive !== !0) return i;
|
|
6159
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6279
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6160
6280
|
return a(i, e);
|
|
6161
6281
|
}
|
|
6162
|
-
var
|
|
6163
|
-
version:
|
|
6164
|
-
slug:
|
|
6165
|
-
source:
|
|
6166
|
-
docs:
|
|
6282
|
+
var Vf = {
|
|
6283
|
+
version: Lf,
|
|
6284
|
+
slug: If,
|
|
6285
|
+
source: Rf,
|
|
6286
|
+
docs: zf,
|
|
6167
6287
|
plan: "open",
|
|
6168
6288
|
title: "Disable API keys",
|
|
6169
6289
|
summary: "Removes API key management: drops the api_keys collection, reverts hooks.server and nav-user, deletes generated API key routes.",
|
|
@@ -6171,6 +6291,7 @@ var Tf = {
|
|
|
6171
6291
|
auth: !0,
|
|
6172
6292
|
api: !0,
|
|
6173
6293
|
apiKeys: !0,
|
|
6294
|
+
backend: !0,
|
|
6174
6295
|
i18n: !1,
|
|
6175
6296
|
teams: !1,
|
|
6176
6297
|
payments: !1,
|
|
@@ -6194,8 +6315,8 @@ var Tf = {
|
|
|
6194
6315
|
examples: [],
|
|
6195
6316
|
tests: 0,
|
|
6196
6317
|
baseline: "velastack",
|
|
6197
|
-
generate:
|
|
6198
|
-
},
|
|
6318
|
+
generate: Bf
|
|
6319
|
+
}, Hf = /* @__PURE__ */ Object.assign({
|
|
6199
6320
|
"../../enable/auth/creates/src/lib/components/app-sidebar.svelte": xi,
|
|
6200
6321
|
"../../enable/auth/creates/src/lib/components/nav-main.svelte": Si,
|
|
6201
6322
|
"../../enable/auth/creates/src/lib/components/nav-user.svelte": Ci,
|
|
@@ -6245,7 +6366,7 @@ var Tf = {
|
|
|
6245
6366
|
"../../enable/auth/creates/src/routes/(public)/signup/+page.svelte": fa,
|
|
6246
6367
|
"../../enable/auth/creates/src/routes/(public)/signup/+page.ts": pa,
|
|
6247
6368
|
"../../enable/auth/creates/src/routes/(public)/signup/server.test.ts": ma
|
|
6248
|
-
}),
|
|
6369
|
+
}), Uf = /* @__PURE__ */ Object.assign({
|
|
6249
6370
|
"../../enable/auth-remote/creates/src/lib/components/app-sidebar.svelte": Aa,
|
|
6250
6371
|
"../../enable/auth-remote/creates/src/lib/components/nav-main.svelte": ja,
|
|
6251
6372
|
"../../enable/auth-remote/creates/src/lib/components/nav-user.svelte": Ma,
|
|
@@ -6302,11 +6423,11 @@ var Tf = {
|
|
|
6302
6423
|
"../../enable/auth-remote/creates/src/routes/(public)/signup/+page.ts": ko,
|
|
6303
6424
|
"../../enable/auth-remote/creates/src/routes/(public)/signup/form.remote.ts": Ao,
|
|
6304
6425
|
"../../enable/auth-remote/creates/src/routes/(public)/signup/server.test.ts": jo
|
|
6305
|
-
}),
|
|
6306
|
-
async function
|
|
6426
|
+
}), Wf = "../../enable/auth/creates/", Gf = "../../enable/auth-remote/creates/";
|
|
6427
|
+
async function Kf(e) {
|
|
6307
6428
|
let t = /* @__PURE__ */ new Set();
|
|
6308
|
-
for (let e of Object.keys(
|
|
6309
|
-
for (let e of Object.keys(
|
|
6429
|
+
for (let e of Object.keys(Hf)) t.add(o(e, Wf));
|
|
6430
|
+
for (let e of Object.keys(Uf)) t.add(o(e, Gf));
|
|
6310
6431
|
return {
|
|
6311
6432
|
creates: [],
|
|
6312
6433
|
modifies: [],
|
|
@@ -6325,20 +6446,20 @@ async function Af(e) {
|
|
|
6325
6446
|
}
|
|
6326
6447
|
//#endregion
|
|
6327
6448
|
//#region src/patterns/disable/auth/index.ts
|
|
6328
|
-
var
|
|
6329
|
-
async function
|
|
6330
|
-
let t = await
|
|
6449
|
+
var qf = "disable-auth", Jf = "1.0.0", Yf = "src/patterns/disable/auth", Xf = "/disable/auth";
|
|
6450
|
+
async function Zf(e) {
|
|
6451
|
+
let t = await Kf(e);
|
|
6331
6452
|
if (e.env !== "runtime") return y(t);
|
|
6332
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6453
|
+
let { generate: r } = await import("./chunks/generate.runtime-DPzrDUU7.js"), i = await y(n([t, await r(e)]));
|
|
6333
6454
|
if (e.input.destructive !== !0) return i;
|
|
6334
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6455
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6335
6456
|
return a(i, e);
|
|
6336
6457
|
}
|
|
6337
|
-
var
|
|
6338
|
-
version:
|
|
6339
|
-
slug:
|
|
6340
|
-
source:
|
|
6341
|
-
docs:
|
|
6458
|
+
var Qf = {
|
|
6459
|
+
version: Jf,
|
|
6460
|
+
slug: qf,
|
|
6461
|
+
source: Yf,
|
|
6462
|
+
docs: Xf,
|
|
6342
6463
|
plan: "open",
|
|
6343
6464
|
title: "Disable auth",
|
|
6344
6465
|
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 +6467,7 @@ var If = {
|
|
|
6346
6467
|
auth: !0,
|
|
6347
6468
|
api: !1,
|
|
6348
6469
|
apiKeys: !1,
|
|
6470
|
+
backend: !0,
|
|
6349
6471
|
i18n: !1,
|
|
6350
6472
|
teams: !1,
|
|
6351
6473
|
payments: !1,
|
|
@@ -6367,19 +6489,96 @@ var If = {
|
|
|
6367
6489
|
examples: [],
|
|
6368
6490
|
tests: 0,
|
|
6369
6491
|
baseline: "velastack-auth",
|
|
6370
|
-
generate:
|
|
6371
|
-
},
|
|
6372
|
-
"../../enable/
|
|
6373
|
-
"../../enable/
|
|
6374
|
-
"../../enable/
|
|
6375
|
-
"../../enable/
|
|
6376
|
-
}),
|
|
6377
|
-
async function
|
|
6492
|
+
generate: Zf
|
|
6493
|
+
}, $f = /* @__PURE__ */ Object.assign({
|
|
6494
|
+
"../../enable/backend/creates/data/fixtures/README.md": Ds,
|
|
6495
|
+
"../../enable/backend/creates/data/hooks/README.md": Os,
|
|
6496
|
+
"../../enable/backend/creates/data/seeds/README.md": ks,
|
|
6497
|
+
"../../enable/backend/creates/src/hooks.server.ts": As
|
|
6498
|
+
}), ep = "../../enable/backend/creates/";
|
|
6499
|
+
async function tp(e) {
|
|
6500
|
+
return {
|
|
6501
|
+
creates: [],
|
|
6502
|
+
modifies: [],
|
|
6503
|
+
deletes: Object.keys($f).map((e) => {
|
|
6504
|
+
let t = o(e, ep);
|
|
6505
|
+
return {
|
|
6506
|
+
path: t,
|
|
6507
|
+
language: r(t),
|
|
6508
|
+
content: "",
|
|
6509
|
+
status: "success"
|
|
6510
|
+
};
|
|
6511
|
+
}).concat([{
|
|
6512
|
+
path: "data",
|
|
6513
|
+
language: r("data"),
|
|
6514
|
+
content: "",
|
|
6515
|
+
status: "success"
|
|
6516
|
+
}]).sort((e, t) => e.path.localeCompare(t.path)),
|
|
6517
|
+
components: [],
|
|
6518
|
+
packages: [],
|
|
6519
|
+
collections: [],
|
|
6520
|
+
collectionPatches: [],
|
|
6521
|
+
collectionDrops: []
|
|
6522
|
+
};
|
|
6523
|
+
}
|
|
6524
|
+
//#endregion
|
|
6525
|
+
//#region src/patterns/disable/backend/index.ts
|
|
6526
|
+
var np = "disable-backend", rp = "1.0.0", ip = "src/patterns/disable/backend", ap = "/disable/backend";
|
|
6527
|
+
async function op(e) {
|
|
6528
|
+
let t = await tp(e);
|
|
6529
|
+
if (e.env !== "runtime") return y(t);
|
|
6530
|
+
let { generate: r } = await import("./chunks/generate.runtime-D6oE0Mmf.js"), i = await y(n([t, await r(e)]));
|
|
6531
|
+
if (e.input.destructive !== !0) return i;
|
|
6532
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6533
|
+
return a(i, e);
|
|
6534
|
+
}
|
|
6535
|
+
var sp = {
|
|
6536
|
+
version: rp,
|
|
6537
|
+
slug: np,
|
|
6538
|
+
source: ip,
|
|
6539
|
+
docs: ap,
|
|
6540
|
+
plan: "open",
|
|
6541
|
+
title: "Disable Backend",
|
|
6542
|
+
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.",
|
|
6543
|
+
requires: {
|
|
6544
|
+
auth: !1,
|
|
6545
|
+
api: !1,
|
|
6546
|
+
apiKeys: !1,
|
|
6547
|
+
backend: !0,
|
|
6548
|
+
i18n: !1,
|
|
6549
|
+
teams: !1,
|
|
6550
|
+
payments: !1,
|
|
6551
|
+
blog: !1,
|
|
6552
|
+
contentNegotiation: !1
|
|
6553
|
+
},
|
|
6554
|
+
category: "backend",
|
|
6555
|
+
tags: [
|
|
6556
|
+
"sveltekit",
|
|
6557
|
+
"pocketbase",
|
|
6558
|
+
"backend",
|
|
6559
|
+
"velastack"
|
|
6560
|
+
],
|
|
6561
|
+
command: {
|
|
6562
|
+
raw: "vela disable backend",
|
|
6563
|
+
base: "vela disable backend",
|
|
6564
|
+
argv: []
|
|
6565
|
+
},
|
|
6566
|
+
examples: [],
|
|
6567
|
+
tests: 0,
|
|
6568
|
+
baseline: "velastack",
|
|
6569
|
+
generate: op
|
|
6570
|
+
}, cp = /* @__PURE__ */ Object.assign({
|
|
6571
|
+
"../../enable/content-negotiation/creates/src/lib/negotiate.ts": Ec,
|
|
6572
|
+
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.server.ts": Dc,
|
|
6573
|
+
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.svelte": Oc,
|
|
6574
|
+
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.ts": kc
|
|
6575
|
+
}), lp = "../../enable/content-negotiation/creates/";
|
|
6576
|
+
async function up(e) {
|
|
6378
6577
|
return {
|
|
6379
6578
|
creates: [],
|
|
6380
6579
|
modifies: [],
|
|
6381
|
-
deletes: Object.keys(
|
|
6382
|
-
let t = o(e,
|
|
6580
|
+
deletes: Object.keys(cp).map((e) => {
|
|
6581
|
+
let t = o(e, lp);
|
|
6383
6582
|
return {
|
|
6384
6583
|
path: t,
|
|
6385
6584
|
language: r(t),
|
|
@@ -6396,20 +6595,20 @@ async function zf(e) {
|
|
|
6396
6595
|
}
|
|
6397
6596
|
//#endregion
|
|
6398
6597
|
//#region src/patterns/disable/content-negotiation/index.ts
|
|
6399
|
-
var
|
|
6400
|
-
async function
|
|
6401
|
-
let t = await
|
|
6598
|
+
var dp = "disable-content-negotiation", fp = "1.0.0", pp = "src/patterns/disable/content-negotiation", mp = "/disable/content-negotiation";
|
|
6599
|
+
async function hp(e) {
|
|
6600
|
+
let t = await up(e);
|
|
6402
6601
|
if (e.env !== "runtime") return y(t);
|
|
6403
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6602
|
+
let { generate: r } = await import("./chunks/generate.runtime-BnkNmF1g.js"), i = await y(n([t, await r(e)]));
|
|
6404
6603
|
if (e.input.destructive !== !0) return i;
|
|
6405
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6604
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6406
6605
|
return a(i, e);
|
|
6407
6606
|
}
|
|
6408
|
-
var
|
|
6409
|
-
version:
|
|
6410
|
-
slug:
|
|
6411
|
-
source:
|
|
6412
|
-
docs:
|
|
6607
|
+
var gp = {
|
|
6608
|
+
version: fp,
|
|
6609
|
+
slug: dp,
|
|
6610
|
+
source: pp,
|
|
6611
|
+
docs: mp,
|
|
6413
6612
|
plan: "open",
|
|
6414
6613
|
title: "Disable content negotiation",
|
|
6415
6614
|
summary: "Removes sveltekit-negotiate wiring: deletes creates, unwraps hooks.server handle, reverts reroute (preserving i18n compose), removes <Negotiate /> from the root layout.",
|
|
@@ -6417,6 +6616,7 @@ var Gf = {
|
|
|
6417
6616
|
auth: !1,
|
|
6418
6617
|
api: !1,
|
|
6419
6618
|
apiKeys: !1,
|
|
6619
|
+
backend: !1,
|
|
6420
6620
|
i18n: !1,
|
|
6421
6621
|
teams: !1,
|
|
6422
6622
|
payments: !1,
|
|
@@ -6439,19 +6639,19 @@ var Gf = {
|
|
|
6439
6639
|
examples: [],
|
|
6440
6640
|
tests: 0,
|
|
6441
6641
|
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
|
|
6642
|
+
generate: hp
|
|
6643
|
+
}, _p = /* @__PURE__ */ Object.assign({
|
|
6644
|
+
"../../enable/i18n/creates/src/hooks.ts": Kc,
|
|
6645
|
+
"../../enable/i18n/creates/src/lib/components/language-select.svelte": qc,
|
|
6646
|
+
"../../enable/i18n/creates/src/lib/url.ts": Jc,
|
|
6647
|
+
"../../enable/i18n/creates/wuchale.config.js": Yc
|
|
6648
|
+
}), vp = "../../enable/i18n/creates/";
|
|
6649
|
+
async function yp(e) {
|
|
6450
6650
|
return {
|
|
6451
6651
|
creates: [],
|
|
6452
6652
|
modifies: [],
|
|
6453
|
-
deletes: Object.keys(
|
|
6454
|
-
let t = o(e,
|
|
6653
|
+
deletes: Object.keys(_p).map((e) => {
|
|
6654
|
+
let t = o(e, vp);
|
|
6455
6655
|
return {
|
|
6456
6656
|
path: t,
|
|
6457
6657
|
language: r(t),
|
|
@@ -6468,20 +6668,20 @@ async function Jf(e) {
|
|
|
6468
6668
|
}
|
|
6469
6669
|
//#endregion
|
|
6470
6670
|
//#region src/patterns/disable/i18n/index.ts
|
|
6471
|
-
var
|
|
6472
|
-
async function
|
|
6473
|
-
let t = await
|
|
6671
|
+
var bp = "disable-i18n", xp = "1.0.0", Sp = "src/patterns/disable/i18n", Cp = "/disable/i18n";
|
|
6672
|
+
async function wp(e) {
|
|
6673
|
+
let t = await yp(e);
|
|
6474
6674
|
if (e.env !== "runtime") return y(t);
|
|
6475
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6675
|
+
let { generate: r } = await import("./chunks/generate.runtime-Bbf2YWaA.js"), i = await y(n([t, await r(e)]));
|
|
6476
6676
|
if (e.input.destructive !== !0) return i;
|
|
6477
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6677
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6478
6678
|
return a(i, e);
|
|
6479
6679
|
}
|
|
6480
|
-
var
|
|
6481
|
-
version:
|
|
6482
|
-
slug:
|
|
6483
|
-
source:
|
|
6484
|
-
docs:
|
|
6680
|
+
var Tp = {
|
|
6681
|
+
version: xp,
|
|
6682
|
+
slug: bp,
|
|
6683
|
+
source: Sp,
|
|
6684
|
+
docs: Cp,
|
|
6485
6685
|
plan: "open",
|
|
6486
6686
|
title: "Disable i18n",
|
|
6487
6687
|
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 +6689,7 @@ var ep = {
|
|
|
6489
6689
|
auth: !1,
|
|
6490
6690
|
api: !1,
|
|
6491
6691
|
apiKeys: !1,
|
|
6692
|
+
backend: !1,
|
|
6492
6693
|
i18n: !0,
|
|
6493
6694
|
teams: !1,
|
|
6494
6695
|
payments: !1,
|
|
@@ -6511,54 +6712,54 @@ var ep = {
|
|
|
6511
6712
|
examples: [],
|
|
6512
6713
|
tests: 0,
|
|
6513
6714
|
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":
|
|
6715
|
+
generate: wp
|
|
6716
|
+
}, Ep = /* @__PURE__ */ Object.assign({
|
|
6717
|
+
"../../enable/teams/creates/src/lib/components/team-switcher.svelte": Xu,
|
|
6718
|
+
"../../enable/teams/creates/src/lib/schemas/team.ts": Zu,
|
|
6719
|
+
"../../enable/teams/creates/src/lib/schemas/teamInvite.ts": Qu,
|
|
6720
|
+
"../../enable/teams/creates/src/lib/schemas/teamRole.ts": $u,
|
|
6721
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+layout@.svelte": ed,
|
|
6722
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.server.ts": td,
|
|
6723
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.svelte": nd,
|
|
6724
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.ts": rd,
|
|
6725
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+layout@.svelte": id,
|
|
6726
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.server.ts": ad,
|
|
6727
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.svelte": od,
|
|
6728
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.ts": sd,
|
|
6729
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.server.ts": cd,
|
|
6730
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.svelte": ld,
|
|
6731
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.server.ts": ud,
|
|
6531
6732
|
"../../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":
|
|
6733
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts": dd,
|
|
6734
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts": fd,
|
|
6735
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": pd,
|
|
6736
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts": md,
|
|
6536
6737
|
"../../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
|
|
6738
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts": hd,
|
|
6739
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts": gd,
|
|
6740
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": _d,
|
|
6741
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte": vd,
|
|
6742
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts": yd,
|
|
6743
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts": bd,
|
|
6744
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": xd,
|
|
6745
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": Sd,
|
|
6746
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": Cd,
|
|
6747
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": wd,
|
|
6748
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts": Td,
|
|
6749
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts": Ed,
|
|
6750
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte": Dd,
|
|
6751
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts": Od,
|
|
6752
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts": kd,
|
|
6753
|
+
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts": Ad,
|
|
6754
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": jd,
|
|
6755
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts": Md
|
|
6756
|
+
}), Dp = "../../enable/teams/creates/";
|
|
6757
|
+
async function Op(e) {
|
|
6557
6758
|
return {
|
|
6558
6759
|
creates: [],
|
|
6559
6760
|
modifies: [],
|
|
6560
|
-
deletes: Object.keys(
|
|
6561
|
-
let t = o(e,
|
|
6761
|
+
deletes: Object.keys(Ep).map((e) => {
|
|
6762
|
+
let t = o(e, Dp);
|
|
6562
6763
|
return {
|
|
6563
6764
|
path: t,
|
|
6564
6765
|
language: r(t),
|
|
@@ -6575,20 +6776,20 @@ async function rp(e) {
|
|
|
6575
6776
|
}
|
|
6576
6777
|
//#endregion
|
|
6577
6778
|
//#region src/patterns/disable/teams/index.ts
|
|
6578
|
-
var
|
|
6579
|
-
async function
|
|
6580
|
-
let t = await
|
|
6779
|
+
var kp = "disable-teams", Ap = "1.0.0", jp = "src/patterns/disable/teams", Mp = "/disable/teams";
|
|
6780
|
+
async function Np(e) {
|
|
6781
|
+
let t = await Op(e);
|
|
6581
6782
|
if (e.env !== "runtime") return y(t);
|
|
6582
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6783
|
+
let { generate: r } = await import("./chunks/generate.runtime-BkvtIjgh.js"), i = await y(n([t, await r(e)]));
|
|
6583
6784
|
if (e.input.destructive !== !0) return i;
|
|
6584
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6785
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6585
6786
|
return a(i, e);
|
|
6586
6787
|
}
|
|
6587
|
-
var
|
|
6588
|
-
version:
|
|
6589
|
-
slug:
|
|
6590
|
-
source:
|
|
6591
|
-
docs:
|
|
6788
|
+
var Pp = {
|
|
6789
|
+
version: Ap,
|
|
6790
|
+
slug: kp,
|
|
6791
|
+
source: jp,
|
|
6792
|
+
docs: Mp,
|
|
6592
6793
|
plan: "pro",
|
|
6593
6794
|
title: "Disable teams",
|
|
6594
6795
|
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 +6797,7 @@ var lp = {
|
|
|
6596
6797
|
auth: !0,
|
|
6597
6798
|
api: !1,
|
|
6598
6799
|
apiKeys: !1,
|
|
6800
|
+
backend: !0,
|
|
6599
6801
|
i18n: !1,
|
|
6600
6802
|
teams: !0,
|
|
6601
6803
|
payments: !1,
|
|
@@ -6617,47 +6819,47 @@ var lp = {
|
|
|
6617
6819
|
examples: [],
|
|
6618
6820
|
tests: 0,
|
|
6619
6821
|
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":
|
|
6822
|
+
generate: Np
|
|
6823
|
+
}, Fp = /* @__PURE__ */ Object.assign({
|
|
6824
|
+
"../../enable/payments/creates/data/hooks/stripe.pb.js": wl,
|
|
6825
|
+
"../../enable/payments/creates/data/hooks/utils.js": Tl,
|
|
6826
|
+
"../../enable/payments/creates/src/lib/components/payments/confirm-dialog.svelte": El,
|
|
6827
|
+
"../../enable/payments/creates/src/lib/components/payments/payment-button.svelte": Dl,
|
|
6828
|
+
"../../enable/payments/creates/src/lib/components/payments/payment-dialog.svelte": Ol,
|
|
6829
|
+
"../../enable/payments/creates/src/lib/components/payments/stripe-constants.ts": kl,
|
|
6830
|
+
"../../enable/payments/creates/src/lib/components/payments/stripe-payment-form.svelte": Al,
|
|
6831
|
+
"../../enable/payments/creates/src/lib/components/payments/use-payment-intent.svelte.ts": jl,
|
|
6832
|
+
"../../enable/payments/creates/src/lib/components/payments/use-stripe.svelte.ts": Ml,
|
|
6833
|
+
"../../enable/payments/creates/src/lib/stripe.ts": Nl,
|
|
6834
|
+
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/+server.ts": Pl,
|
|
6835
|
+
"../../enable/payments/creates/src/routes/api/stripe/payment-intent/server.test.ts": Fl,
|
|
6836
|
+
"../../enable/payments/creates/src/routes/api/stripe/sync/prices/+server.ts": Il,
|
|
6837
|
+
"../../enable/payments/creates/src/routes/api/stripe/sync/products/+server.ts": Ll,
|
|
6838
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/+server.ts": Rl,
|
|
6839
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": zl,
|
|
6840
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": Bl,
|
|
6841
|
+
"../../enable/payments/creates/src/routes/webhooks/stripe/server.test.ts": Vl
|
|
6842
|
+
}), Ip = /* @__PURE__ */ Object.assign({
|
|
6843
|
+
"../../enable/payments/creates-app-mode/data/hooks/stripe.pb.js": Hl,
|
|
6844
|
+
"../../enable/payments/creates-app-mode/data/hooks/utils.js": Ul,
|
|
6845
|
+
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-button.svelte": Wl,
|
|
6846
|
+
"../../enable/payments/creates-app-mode/src/lib/components/payments/setup-dialog.svelte": Gl,
|
|
6847
|
+
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+layout.server.ts": Kl,
|
|
6646
6848
|
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.server.ts": p,
|
|
6647
6849
|
"../../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
|
|
6850
|
+
"../../enable/payments/creates-app-mode/src/routes/(app)/billing/README.md": ql,
|
|
6851
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/+server.ts": Jl,
|
|
6852
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/payment-intent/server.test.ts": Yl,
|
|
6853
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/+server.ts": Xl,
|
|
6854
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/setup-intent/server.test.ts": Zl,
|
|
6855
|
+
"../../enable/payments/creates-app-mode/src/routes/api/stripe/sync/customers/+server.ts": Ql,
|
|
6856
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/+server.ts": $l,
|
|
6857
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": eu,
|
|
6858
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": tu,
|
|
6859
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": nu,
|
|
6860
|
+
"../../enable/payments/creates-app-mode/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": ru
|
|
6861
|
+
}), Lp = "../../enable/payments/creates/", Rp = "../../enable/payments/creates-app-mode/";
|
|
6862
|
+
function zp(e, t) {
|
|
6661
6863
|
let n = {};
|
|
6662
6864
|
for (let i of Object.keys(e)) {
|
|
6663
6865
|
let e = o(i, t);
|
|
@@ -6670,10 +6872,10 @@ function mp(e, t) {
|
|
|
6670
6872
|
}
|
|
6671
6873
|
return n;
|
|
6672
6874
|
}
|
|
6673
|
-
async function
|
|
6674
|
-
let t = e.features.auth, n = { ...
|
|
6875
|
+
async function Bp(e) {
|
|
6876
|
+
let t = e.features.auth, n = { ...zp(Fp, Lp) };
|
|
6675
6877
|
if (t) {
|
|
6676
|
-
let e =
|
|
6878
|
+
let e = zp(Ip, Rp);
|
|
6677
6879
|
Object.assign(n, e);
|
|
6678
6880
|
}
|
|
6679
6881
|
return {
|
|
@@ -6689,20 +6891,20 @@ async function hp(e) {
|
|
|
6689
6891
|
}
|
|
6690
6892
|
//#endregion
|
|
6691
6893
|
//#region src/patterns/disable/payments/index.ts
|
|
6692
|
-
var
|
|
6693
|
-
async function
|
|
6694
|
-
let t = await
|
|
6894
|
+
var Vp = "disable-payments", Hp = "1.0.0", Up = "src/patterns/disable/payments", Wp = "/disable/payments";
|
|
6895
|
+
async function Gp(e) {
|
|
6896
|
+
let t = await Bp(e);
|
|
6695
6897
|
if (e.env !== "runtime") return y(t);
|
|
6696
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6898
|
+
let { generate: r } = await import("./chunks/generate.runtime-CEtVUz4k.js"), i = await y(n([t, await r(e)]));
|
|
6697
6899
|
if (e.input.destructive !== !0) return i;
|
|
6698
|
-
let a = await
|
|
6900
|
+
let a = await Kp(e), o = {
|
|
6699
6901
|
...i,
|
|
6700
6902
|
creates: [...i.creates, ...a]
|
|
6701
|
-
}, { writeResult: s } = await import("./chunks/write-result-
|
|
6903
|
+
}, { writeResult: s } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6702
6904
|
return s(o, e);
|
|
6703
6905
|
}
|
|
6704
|
-
async function
|
|
6705
|
-
let { withPocketbase: t } = await import("./chunks/pocketbase-
|
|
6906
|
+
async function Kp(e) {
|
|
6907
|
+
let { withPocketbase: t } = await import("./chunks/pocketbase-D7GjPuNu.js"), { applyCollectionFieldsPatches: n } = await import("./chunks/collections-BwO27pJg.js"), r = u(e), i = [];
|
|
6706
6908
|
return await t(e.root, async (t) => {
|
|
6707
6909
|
let a;
|
|
6708
6910
|
try {
|
|
@@ -6720,11 +6922,11 @@ async function xp(e) {
|
|
|
6720
6922
|
}], e, r));
|
|
6721
6923
|
}), i;
|
|
6722
6924
|
}
|
|
6723
|
-
var
|
|
6724
|
-
version:
|
|
6725
|
-
slug:
|
|
6726
|
-
source:
|
|
6727
|
-
docs:
|
|
6925
|
+
var qp = {
|
|
6926
|
+
version: Hp,
|
|
6927
|
+
slug: Vp,
|
|
6928
|
+
source: Up,
|
|
6929
|
+
docs: Wp,
|
|
6728
6930
|
plan: "pro",
|
|
6729
6931
|
title: "Disable payments",
|
|
6730
6932
|
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 +6934,7 @@ var Sp = {
|
|
|
6732
6934
|
auth: !1,
|
|
6733
6935
|
api: !1,
|
|
6734
6936
|
apiKeys: !1,
|
|
6937
|
+
backend: !0,
|
|
6735
6938
|
i18n: !1,
|
|
6736
6939
|
teams: !1,
|
|
6737
6940
|
payments: !0,
|
|
@@ -6755,20 +6958,20 @@ var Sp = {
|
|
|
6755
6958
|
examples: [],
|
|
6756
6959
|
tests: 0,
|
|
6757
6960
|
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
|
|
6961
|
+
generate: Gp
|
|
6962
|
+
}, Jp = /* @__PURE__ */ Object.assign({
|
|
6963
|
+
"../../enable/subscriptions/creates/src/routes/api/stripe/sync/subscriptions/+server.ts": Mu,
|
|
6964
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": Nu,
|
|
6965
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": Pu,
|
|
6966
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": Fu,
|
|
6967
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": Iu
|
|
6968
|
+
}), Yp = "../../enable/subscriptions/creates/";
|
|
6969
|
+
async function Xp(e) {
|
|
6767
6970
|
return {
|
|
6768
6971
|
creates: [],
|
|
6769
6972
|
modifies: [],
|
|
6770
|
-
deletes: Object.keys(
|
|
6771
|
-
let t = o(e,
|
|
6973
|
+
deletes: Object.keys(Jp).map((e) => {
|
|
6974
|
+
let t = o(e, Yp);
|
|
6772
6975
|
return {
|
|
6773
6976
|
path: t,
|
|
6774
6977
|
language: r(t),
|
|
@@ -6785,20 +6988,20 @@ async function Tp(e) {
|
|
|
6785
6988
|
}
|
|
6786
6989
|
//#endregion
|
|
6787
6990
|
//#region src/patterns/disable/subscriptions/index.ts
|
|
6788
|
-
var
|
|
6789
|
-
async function
|
|
6790
|
-
let t = await
|
|
6991
|
+
var Zp = "disable-subscriptions", Qp = "1.0.0", $p = "src/patterns/disable/subscriptions", em = "/disable/subscriptions";
|
|
6992
|
+
async function tm(e) {
|
|
6993
|
+
let t = await Xp(e);
|
|
6791
6994
|
if (e.env !== "runtime") return y(t);
|
|
6792
|
-
let { generate: r } = await import("./chunks/generate.runtime-
|
|
6995
|
+
let { generate: r } = await import("./chunks/generate.runtime-CrAHzaEW.js"), i = await y(n([t, await r(e)]));
|
|
6793
6996
|
if (e.input.destructive !== !0) return i;
|
|
6794
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
6997
|
+
let { writeResult: a } = await import("./chunks/write-result-BmL8uLNd.js");
|
|
6795
6998
|
return a(i, e);
|
|
6796
6999
|
}
|
|
6797
|
-
var
|
|
6798
|
-
version:
|
|
6799
|
-
slug:
|
|
6800
|
-
source:
|
|
6801
|
-
docs:
|
|
7000
|
+
var nm = {
|
|
7001
|
+
version: Qp,
|
|
7002
|
+
slug: Zp,
|
|
7003
|
+
source: $p,
|
|
7004
|
+
docs: em,
|
|
6802
7005
|
plan: "pro",
|
|
6803
7006
|
title: "Disable subscriptions",
|
|
6804
7007
|
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 +7009,7 @@ var jp = {
|
|
|
6806
7009
|
auth: !0,
|
|
6807
7010
|
api: !1,
|
|
6808
7011
|
apiKeys: !1,
|
|
7012
|
+
backend: !0,
|
|
6809
7013
|
i18n: !1,
|
|
6810
7014
|
teams: !1,
|
|
6811
7015
|
payments: !0,
|
|
@@ -6830,8 +7034,8 @@ var jp = {
|
|
|
6830
7034
|
examples: [],
|
|
6831
7035
|
tests: 0,
|
|
6832
7036
|
baseline: "velastack",
|
|
6833
|
-
generate:
|
|
6834
|
-
},
|
|
7037
|
+
generate: tm
|
|
7038
|
+
}, rm = ye.version, im = [
|
|
6835
7039
|
fn,
|
|
6836
7040
|
Bn,
|
|
6837
7041
|
Zn,
|
|
@@ -6843,30 +7047,32 @@ var jp = {
|
|
|
6843
7047
|
Uo,
|
|
6844
7048
|
ns,
|
|
6845
7049
|
Es,
|
|
6846
|
-
|
|
6847
|
-
|
|
7050
|
+
Hs,
|
|
7051
|
+
Tc,
|
|
6848
7052
|
Gc,
|
|
6849
7053
|
sl,
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
7054
|
+
Cl,
|
|
7055
|
+
ju,
|
|
7056
|
+
Yu,
|
|
7057
|
+
Zd,
|
|
7058
|
+
af,
|
|
7059
|
+
df,
|
|
7060
|
+
_f,
|
|
7061
|
+
Cf,
|
|
7062
|
+
Mf,
|
|
7063
|
+
Vf,
|
|
7064
|
+
Qf,
|
|
7065
|
+
sp,
|
|
7066
|
+
gp,
|
|
7067
|
+
Tp,
|
|
7068
|
+
Pp,
|
|
7069
|
+
qp,
|
|
7070
|
+
nm
|
|
7071
|
+
], am = Object.fromEntries(im.map((e) => [e.slug, e])), om = im.reduce((e, t) => {
|
|
6866
7072
|
let n = t.category;
|
|
6867
7073
|
return e[n] ??= [], e[n].push(t), e;
|
|
6868
7074
|
}, {});
|
|
6869
7075
|
//#endregion
|
|
6870
|
-
export { e as InvalidArgumentError,
|
|
7076
|
+
export { e as InvalidArgumentError, om as byCategory, am as bySlug, im as patterns, rm as version };
|
|
6871
7077
|
|
|
6872
7078
|
//# sourceMappingURL=index.js.map
|