@velastack/patterns 0.13.1 → 0.13.3
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/app-d-ts-h33RrYIv.js +198 -0
- package/dist/chunks/app-d-ts-h33RrYIv.js.map +1 -0
- package/dist/chunks/app-layout.svelte-CZ0hw-pi.js +51 -0
- package/dist/chunks/app-layout.svelte-CZ0hw-pi.js.map +1 -0
- package/dist/chunks/{generate.runtime-DHJqOJTr.js → generate.runtime-Bv_16lWi.js} +2 -2
- package/dist/chunks/{generate.runtime-DHJqOJTr.js.map → generate.runtime-Bv_16lWi.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DvTbN-no.js → generate.runtime-CZKIKP3B.js} +213 -175
- package/dist/chunks/generate.runtime-CZKIKP3B.js.map +1 -0
- package/dist/chunks/{generate.runtime-BEmSIAop.js → generate.runtime-C_SdcnRs.js} +2 -2
- package/dist/chunks/{generate.runtime-BEmSIAop.js.map → generate.runtime-C_SdcnRs.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DGnXHELM.js → generate.runtime-CsP4c8GY.js} +78 -77
- package/dist/chunks/generate.runtime-CsP4c8GY.js.map +1 -0
- package/dist/chunks/{generate.runtime-DWHoDisZ.js → generate.runtime-CzYArKUA.js} +2 -2
- package/dist/chunks/{generate.runtime-DWHoDisZ.js.map → generate.runtime-CzYArKUA.js.map} +1 -1
- package/dist/chunks/generate.runtime-DZUPtJVF.js +429 -0
- package/dist/chunks/generate.runtime-DZUPtJVF.js.map +1 -0
- package/dist/chunks/{generate.runtime-Cgam_XCc.js → generate.runtime-DaPA2NNL.js} +2 -2
- package/dist/chunks/{generate.runtime-Cgam_XCc.js.map → generate.runtime-DaPA2NNL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-i3tMIA1A.js → generate.runtime-pbIrEsa7.js} +45 -45
- package/dist/chunks/generate.runtime-pbIrEsa7.js.map +1 -0
- package/dist/chunks/i18n-BHCytiiO.js +28 -0
- package/dist/chunks/i18n-BHCytiiO.js.map +1 -0
- package/dist/chunks/test-setup-cZj1tqaf.js +176 -0
- package/dist/chunks/test-setup-cZj1tqaf.js.map +1 -0
- package/dist/chunks/translations-CiJnl574.js +189 -0
- package/dist/chunks/translations-CiJnl574.js.map +1 -0
- package/dist/chunks/{ui-Ct6YQuPw.js → ui-IkdkLwmB.js} +2 -2
- package/dist/chunks/{ui-Ct6YQuPw.js.map → ui-IkdkLwmB.js.map} +1 -1
- package/dist/chunks/write-result-C1GYInL8.js +499 -0
- package/dist/chunks/write-result-C1GYInL8.js.map +1 -0
- package/dist/index.js +735 -725
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/_layout-Dju9EYqa.js +0 -60
- package/dist/chunks/_layout-Dju9EYqa.js.map +0 -1
- package/dist/chunks/generate.runtime-DGnXHELM.js.map +0 -1
- package/dist/chunks/generate.runtime-Dtf3tF3-.js +0 -316
- package/dist/chunks/generate.runtime-Dtf3tF3-.js.map +0 -1
- package/dist/chunks/generate.runtime-DvTbN-no.js.map +0 -1
- package/dist/chunks/generate.runtime-i3tMIA1A.js.map +0 -1
- package/dist/chunks/test-setup-CbwhAJT4.js +0 -176
- package/dist/chunks/test-setup-CbwhAJT4.js.map +0 -1
- package/dist/chunks/write-result-B5KFCqxw.js +0 -487
- package/dist/chunks/write-result-B5KFCqxw.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ import { r as Vr } from "./chunks/generate-F4FDWvFo.js";
|
|
|
30
30
|
import { n as Hr, t as Ur } from "./chunks/generate-BCYvhyF9.js";
|
|
31
31
|
var Wr = {
|
|
32
32
|
name: "@velastack/patterns",
|
|
33
|
-
version: "0.13.
|
|
33
|
+
version: "0.13.3",
|
|
34
34
|
description: "Registry of VelaStack patterns: generators and modifications applied to SvelteKit projects by the VelaStack CLI.",
|
|
35
35
|
type: "module",
|
|
36
36
|
private: !1,
|
|
@@ -2439,7 +2439,7 @@ var La = "generate-form", Ra = "1.1.0", za = "src/patterns/generate/form", Ba =
|
|
|
2439
2439
|
async function Va(e) {
|
|
2440
2440
|
let t = await Ia(e);
|
|
2441
2441
|
if (e.env !== "runtime") return S(t, e);
|
|
2442
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
2442
|
+
let { writeResult: n } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
2443
2443
|
return n(await S(t, e), e);
|
|
2444
2444
|
}
|
|
2445
2445
|
var Ha = {
|
|
@@ -2709,7 +2709,7 @@ async function go(e) {
|
|
|
2709
2709
|
let i = r(e.root), a = n(i.filePath, i.outcome), o = {
|
|
2710
2710
|
...t,
|
|
2711
2711
|
modifies: [...t.modifies, ...a ? [a] : []]
|
|
2712
|
-
}, { writeResult: s } = await import("./chunks/write-result-
|
|
2712
|
+
}, { writeResult: s } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
2713
2713
|
return s(await S(o, e), e);
|
|
2714
2714
|
}
|
|
2715
2715
|
var _o = {
|
|
@@ -2856,7 +2856,7 @@ async function Do(e) {
|
|
|
2856
2856
|
let o = {
|
|
2857
2857
|
...t,
|
|
2858
2858
|
creates: [...t.creates, ...a]
|
|
2859
|
-
}, { writeResult: s } = await import("./chunks/write-result-
|
|
2859
|
+
}, { writeResult: s } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
2860
2860
|
return s(await S(o, e), e);
|
|
2861
2861
|
}
|
|
2862
2862
|
var Oo = {
|
|
@@ -2962,7 +2962,7 @@ async function Io(e) {
|
|
|
2962
2962
|
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), i = {
|
|
2963
2963
|
...t,
|
|
2964
2964
|
creates: [...t.creates, ...r]
|
|
2965
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
2965
|
+
}, { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
2966
2966
|
return a(await S(i, e), e);
|
|
2967
2967
|
}
|
|
2968
2968
|
var Lo = {
|
|
@@ -3594,7 +3594,7 @@ async function As(e) {
|
|
|
3594
3594
|
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), i = {
|
|
3595
3595
|
...t,
|
|
3596
3596
|
creates: [...t.creates, ...r]
|
|
3597
|
-
}, { writeResult: a } = await import("./chunks/write-result-
|
|
3597
|
+
}, { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
3598
3598
|
return a(await S(i, e), e);
|
|
3599
3599
|
}
|
|
3600
3600
|
var js = {
|
|
@@ -3951,7 +3951,7 @@ async function lc(e) {
|
|
|
3951
3951
|
...t,
|
|
3952
3952
|
creates: [...t.creates, ...r],
|
|
3953
3953
|
modifies: [...t.modifies, ...s ? [s] : []]
|
|
3954
|
-
}, { writeResult: l } = await import("./chunks/write-result-
|
|
3954
|
+
}, { writeResult: l } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
3955
3955
|
return l(await S(c, e), e);
|
|
3956
3956
|
}
|
|
3957
3957
|
var uc = {
|
|
@@ -4052,7 +4052,7 @@ var mc = "generate-schema", hc = "1.0.8", gc = "src/patterns/generate/schema", _
|
|
|
4052
4052
|
async function vc(e) {
|
|
4053
4053
|
let t = await pc(e);
|
|
4054
4054
|
if (e.env !== "runtime") return S(t, e);
|
|
4055
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
4055
|
+
let { writeResult: n } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
4056
4056
|
return n(await S(t, e), e);
|
|
4057
4057
|
}
|
|
4058
4058
|
var yc = {
|
|
@@ -4174,7 +4174,7 @@ async function Gc(e) {
|
|
|
4174
4174
|
if (e.env !== "runtime") return S(t, e);
|
|
4175
4175
|
let { assertNoneExist: n } = await import("./chunks/generate.runtime-D769VJFt.js");
|
|
4176
4176
|
n(e.root, t.creates);
|
|
4177
|
-
let { writeResult: r } = await import("./chunks/write-result-
|
|
4177
|
+
let { writeResult: r } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
4178
4178
|
return r(await S(t, e), e);
|
|
4179
4179
|
}
|
|
4180
4180
|
var Kc = {
|
|
@@ -4346,7 +4346,7 @@ async function sl(e) {
|
|
|
4346
4346
|
if (e.env === "runtime" && !e.features.workflows) throw new a("This project has no workflow runtime yet. Run `vela enable workflows` first.");
|
|
4347
4347
|
let t = await nl(e);
|
|
4348
4348
|
if (e.env !== "runtime") return S(t, e);
|
|
4349
|
-
let { writeResult: n } = await import("./chunks/write-result-
|
|
4349
|
+
let { writeResult: n } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
4350
4350
|
return n(await S(t, e), e);
|
|
4351
4351
|
}
|
|
4352
4352
|
var cl = {
|
|
@@ -4426,7 +4426,7 @@ async function ml(e) {
|
|
|
4426
4426
|
let n = await ll(e);
|
|
4427
4427
|
return S(T([t, n]), e);
|
|
4428
4428
|
}
|
|
4429
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
4429
|
+
let { generate: n } = await import("./chunks/generate.runtime-CzYArKUA.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
4430
4430
|
return i(await S(T([t, r]), e), e);
|
|
4431
4431
|
}
|
|
4432
4432
|
var hl = {
|
|
@@ -4525,7 +4525,7 @@ async function Cl(e) {
|
|
|
4525
4525
|
let n = await vl(e);
|
|
4526
4526
|
return S(T([t, n]), e);
|
|
4527
4527
|
}
|
|
4528
|
-
let { generate: n } = await import("./chunks/generate.runtime-C37djibw.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
4528
|
+
let { generate: n } = await import("./chunks/generate.runtime-C37djibw.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
4529
4529
|
return i(await S(T([t, r]), e), e);
|
|
4530
4530
|
}
|
|
4531
4531
|
var wl = {
|
|
@@ -4760,17 +4760,17 @@ async function jl(e) {
|
|
|
4760
4760
|
};
|
|
4761
4761
|
}
|
|
4762
4762
|
// src/patterns/enable/auth/index.ts
|
|
4763
|
-
var Ml = "enable-auth", Nl = "1.
|
|
4763
|
+
var Ml = "enable-auth", Nl = "1.3.0", Pl = "src/patterns/enable/auth", Fl = "/enable/auth";
|
|
4764
4764
|
async function Il(e) {
|
|
4765
4765
|
let t = await Ol(e);
|
|
4766
4766
|
if (e.env === "preview") {
|
|
4767
4767
|
let n = await jl(e);
|
|
4768
4768
|
return S(T([t, n]), e);
|
|
4769
4769
|
}
|
|
4770
|
-
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), { writeResult: i } = await import("./chunks/write-result-
|
|
4770
|
+
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l), a = await i(await S({
|
|
4771
4771
|
...t,
|
|
4772
4772
|
creates: [...t.creates, ...r]
|
|
4773
|
-
}, e), e), { generate: o } = await import("./chunks/generate.runtime-
|
|
4773
|
+
}, e), e), { generate: o } = await import("./chunks/generate.runtime-CsP4c8GY.js"), s = await o(e), c = await i(await S(s, e), e);
|
|
4774
4774
|
return T([a, c]);
|
|
4775
4775
|
}
|
|
4776
4776
|
var Ll = {
|
|
@@ -4864,7 +4864,7 @@ async function Yl(e) {
|
|
|
4864
4864
|
let n = await Wl(e);
|
|
4865
4865
|
return S(T([t, n]), e);
|
|
4866
4866
|
}
|
|
4867
|
-
let { generate: n } = await import("./chunks/generate.runtime-CjqX4tDg.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
4867
|
+
let { generate: n } = await import("./chunks/generate.runtime-CjqX4tDg.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
4868
4868
|
return i(await S(T([t, r]), e), e);
|
|
4869
4869
|
}
|
|
4870
4870
|
var Xl = {
|
|
@@ -5092,18 +5092,29 @@ async function nu(e) {
|
|
|
5092
5092
|
};
|
|
5093
5093
|
}
|
|
5094
5094
|
// src/patterns/enable/auth-remote/index.ts
|
|
5095
|
-
var ru = "enable-auth-remote", iu = "1.
|
|
5095
|
+
var ru = "enable-auth-remote", iu = "1.3.0", au = "src/patterns/enable/auth-remote", ou = "/enable/auth-remote";
|
|
5096
5096
|
async function su(e) {
|
|
5097
5097
|
let t = await $l(e);
|
|
5098
5098
|
if (e.env === "preview") {
|
|
5099
5099
|
let n = await nu(e);
|
|
5100
5100
|
return S(T([t, n]), e);
|
|
5101
5101
|
}
|
|
5102
|
-
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-
|
|
5103
|
-
return o(await S(T([{
|
|
5102
|
+
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-Bv_16lWi.js"), a = await i(e), { writeResult: o } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l), s = await o(await S(T([{
|
|
5104
5103
|
...t,
|
|
5105
5104
|
creates: [...t.creates, ...r]
|
|
5106
|
-
}, a]), e), e);
|
|
5105
|
+
}, a]), e), e), { localizeAuthPages: c } = await import("./chunks/i18n-BHCytiiO.js"), l = c(e);
|
|
5106
|
+
if (l.creates.length === 0 && l.modifies.length === 0) return s;
|
|
5107
|
+
let u = await o(await S({
|
|
5108
|
+
creates: l.creates,
|
|
5109
|
+
modifies: l.modifies,
|
|
5110
|
+
deletes: [],
|
|
5111
|
+
components: [],
|
|
5112
|
+
packages: [],
|
|
5113
|
+
collections: [],
|
|
5114
|
+
collectionPatches: [],
|
|
5115
|
+
collectionDrops: []
|
|
5116
|
+
}, e), e);
|
|
5117
|
+
return T([s, u]);
|
|
5107
5118
|
}
|
|
5108
5119
|
var cu = {
|
|
5109
5120
|
version: iu,
|
|
@@ -5196,7 +5207,7 @@ async function bu(e) {
|
|
|
5196
5207
|
let n = await hu(e);
|
|
5197
5208
|
return S(T([t, n]), e);
|
|
5198
5209
|
}
|
|
5199
|
-
let { generate: n } = await import("./chunks/generate.runtime-BgGeOqYG.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
5210
|
+
let { generate: n } = await import("./chunks/generate.runtime-BgGeOqYG.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
5200
5211
|
return i(await S(T([t, r]), e), e);
|
|
5201
5212
|
}
|
|
5202
5213
|
var xu = {
|
|
@@ -5349,7 +5360,7 @@ async function Wu(e) {
|
|
|
5349
5360
|
let n = await zu(e);
|
|
5350
5361
|
return S(T([t, n]), e);
|
|
5351
5362
|
}
|
|
5352
|
-
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-DfHFd8xs.js"), a = await i(e), { writeResult: o } = await import("./chunks/write-result-
|
|
5363
|
+
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-DfHFd8xs.js"), a = await i(e), { writeResult: o } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
5353
5364
|
return o(await S(T([{
|
|
5354
5365
|
...t,
|
|
5355
5366
|
creates: [...t.creates, ...r]
|
|
@@ -5430,7 +5441,7 @@ async function Qu(e) {
|
|
|
5430
5441
|
}
|
|
5431
5442
|
// src/patterns/enable/backend/generate.preview.ts
|
|
5432
5443
|
var $u = /* #__PURE__ */ Object.assign({
|
|
5433
|
-
"./preview-modifies/test/setup.ts": "import { beforeEach, afterEach, beforeAll, inject } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase/testing';\nimport type {} from 'vela/testing';\n\n// The servers `vela/testing` started: a throwaway PocketBase and the app.\nconst servers = inject('vela');\nif (!servers) {\n throw new Error(\n
|
|
5444
|
+
"./preview-modifies/test/setup.ts": "import { beforeEach, afterEach, beforeAll, inject } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase/testing';\nimport type {} from 'vela/testing';\n\n// The servers `vela/testing` started: a throwaway PocketBase and the app.\nconst servers = inject('vela');\nif (!servers) {\n throw new Error(\n \"Server tests need the servers `vela/testing` starts. Add `globalSetup: ['vela/testing']` to the test config in vitest.config.ts.\"\n );\n}\n\nconst admin = new PocketBase(servers.pocketbaseUrl) as App.Locals['admin'];\nconst pb = new PocketBase(servers.pocketbaseUrl) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email?: string }) {\n // Logs in with the password, so it needs the email (made optional by\n // enable-whatsapp, for accounts that sign in with a phone number).\n if (!user.email) {\n throw new Error('authenticateUser needs a user with an email');\n }\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(servers.superuser.email, servers.superuser.password);\n});\n\nbeforeEach(async (context: TestContext) => {\n context.request = supertest(servers.appUrl);\n context.agent = supertest.agent(servers.appUrl) as TestContext['agent'];\n context.admin = admin;\n context.pb = pb;\n const email = `test-${Math.random().toString(36).slice(2)}@example.com`;\n context.user = await context.admin.collection('users').create({\n email,\n password: testUserPassword,\n passwordConfirm: testUserPassword\n });\n context.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n await context.pb.collection('users').authWithPassword(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",
|
|
5434
5445
|
"./preview-modifies/vite.config.ts": "import { defineConfig } from 'vite';\nimport tailwindcss from '@tailwindcss/vite';\nimport { sveltekit } from '@sveltejs/kit/vite';\n// [!code highlight:1]\nimport adapter from '@sveltejs/adapter-node';\n\nexport default defineConfig({\n plugins: [\n tailwindcss(),\n sveltekit({\n compilerOptions: {\n runes: ({ filename }) =>\n filename.split(/[/\\\\]/).includes('node_modules') ? undefined : true\n },\n // [!code highlight:1]\n adapter: adapter(),\n // The public origin, which SvelteKit checks form posts against and uses\n // for prerendered pages. `vela deploy` sets VELA_ORIGIN, and the value is\n // baked in at build time. It is left unset for a deploy that serves more\n // than one host, where each request's own origin is used instead.\n ...(process.env.VELA_ORIGIN ? { paths: { origin: process.env.VELA_ORIGIN } } : {})\n })\n ]\n});\n"
|
|
5435
5446
|
}), ed = "./preview-modifies/";
|
|
5436
5447
|
async function td(e) {
|
|
@@ -5466,7 +5477,7 @@ async function od(e) {
|
|
|
5466
5477
|
let n = await td(e);
|
|
5467
5478
|
return S(T([t, n]), e);
|
|
5468
5479
|
}
|
|
5469
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
5480
|
+
let { generate: n } = await import("./chunks/generate.runtime-C_SdcnRs.js"), r = await n(e), { keepMissing: i } = await import("./chunks/modify-file-CRZ_gMg0.js").then((e) => e.i), { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
5470
5481
|
return a(await S(T([{
|
|
5471
5482
|
...t,
|
|
5472
5483
|
creates: i(t.creates, e.root)
|
|
@@ -5601,7 +5612,7 @@ async function Ud(e) {
|
|
|
5601
5612
|
let n = await Rd(e);
|
|
5602
5613
|
return S(T([t, n]), e);
|
|
5603
5614
|
}
|
|
5604
|
-
let { generate: n } = await import("./chunks/generate.runtime-mE0knt2T.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
5615
|
+
let { generate: n } = await import("./chunks/generate.runtime-mE0knt2T.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
5605
5616
|
return i(await S(T([t, r]), e), e);
|
|
5606
5617
|
}
|
|
5607
5618
|
var Wd = {
|
|
@@ -5676,7 +5687,7 @@ async function Qd(e) {
|
|
|
5676
5687
|
let n = await qd(e);
|
|
5677
5688
|
return S(T([t, n]), e);
|
|
5678
5689
|
}
|
|
5679
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
5690
|
+
let { generate: n } = await import("./chunks/generate.runtime-pbIrEsa7.js"), { keepMissing: r } = await import("./chunks/modify-file-CRZ_gMg0.js").then((e) => e.i), i = await n(e), { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
5680
5691
|
return a(await S(T([{
|
|
5681
5692
|
...t,
|
|
5682
5693
|
creates: r(t.creates, e.root)
|
|
@@ -5800,7 +5811,7 @@ async function Sf(e) {
|
|
|
5800
5811
|
let n = await _f(e);
|
|
5801
5812
|
return S(T([t, n]), e);
|
|
5802
5813
|
}
|
|
5803
|
-
let { generate: n } = await import("./chunks/generate.runtime-22jW8aVT.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
5814
|
+
let { generate: n } = await import("./chunks/generate.runtime-22jW8aVT.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
5804
5815
|
return i(await S(T([t, r]), e), e);
|
|
5805
5816
|
}
|
|
5806
5817
|
var Cf = {
|
|
@@ -5840,15 +5851,16 @@ var Cf = {
|
|
|
5840
5851
|
tests: 0,
|
|
5841
5852
|
baseline: "velastack",
|
|
5842
5853
|
generate: Sf
|
|
5843
|
-
}, wf = "<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 {
|
|
5854
|
+
}, wf = "<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, invalidateAll } from \"$app/navigation\";\n import { hasLocalizedUrl, translateUrl } from \"#lib/url.js\";\n import { localeCookie } from \"#lib/locale.js\";\n\n let locale: Locale = $derived(page.data.locale);\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 = async (value: string) => {\n // Remembered for the pages that have no language in their URL.\n document.cookie = localeCookie(value as Locale);\n\n if (hasLocalizedUrl(page.url.pathname)) {\n await goto(translateUrl(page.url.pathname, locale, value as Locale), {\n refreshAll: true,\n });\n } else {\n await invalidateAll();\n }\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", Tf = "import type { Locale } from \"#locales/data.js\";\n\n/**\n * Where a page's language comes from.\n *\n * Public pages (the ones under `url.patterns` in wuchale.config.js) carry it\n * in the URL: `/` is English, `/es` is Spanish. Every other page, such as a\n * sign-in page or a page behind one, has one URL for every language and\n * follows the visitor's preference: this cookie, set by the last public page\n * they opened or by the language select, then the browser's Accept-Language.\n *\n * A second URL per language is what search engines and shared links need, and\n * neither matters behind a login. Keeping those pages out of the URL scheme\n * also means their redirects, form actions and emailed links need no\n * localizing, and that hovering a link to them never preloads another\n * language.\n */\nexport const LOCALE_COOKIE = \"locale\";\n\nconst YEAR = 60 * 60 * 24 * 365;\n\n/**\n * The `Set-Cookie` / `document.cookie` value that remembers `locale`. Not\n * HttpOnly: the language select writes it in the browser.\n */\nexport const localeCookie = (locale: Locale) =>\n `${LOCALE_COOKIE}=${locale}; Path=/; Max-Age=${YEAR}; SameSite=Lax`;\n\n/** The first language of an Accept-Language header that the site has. */\nexport function acceptedLocale<L extends string>(\n header: string | null,\n locales: readonly L[],\n) {\n const wanted = (header ?? \"\")\n .split(\",\")\n .map((part) => {\n const [tag, ...params] = part.trim().split(\";\");\n const q = params.map((p) => p.trim()).find((p) => p.startsWith(\"q=\"));\n return { tag: tag.toLowerCase(), q: q ? Number(q.slice(2)) : 1 };\n })\n .filter(({ tag, q }) => tag && q > 0)\n .sort((a, b) => b.q - a.q);\n\n for (const { tag } of wanted) {\n const match = locales.find(\n (locale) => tag === locale || tag.startsWith(`${locale}-`),\n );\n if (match) return match;\n }\n return null;\n}\n\n/** The language of a request, by the rules above. */\nexport function pickLocale<L extends string>(request: {\n /** The locale prefix of the URL, if it has one. */\n urlLocale: L | null;\n /** Whether the page has a URL per language. */\n localizedUrl: boolean;\n cookie: string | undefined;\n acceptLanguage: string | null;\n locales: readonly L[];\n defaultLocale: L;\n}): L {\n const {\n urlLocale,\n localizedUrl,\n cookie,\n acceptLanguage,\n locales,\n defaultLocale,\n } = request;\n if (urlLocale) return urlLocale;\n if (localizedUrl) return defaultLocale;\n return (\n locales.find((locale) => locale === cookie) ??\n acceptedLocale(acceptLanguage, locales) ??\n defaultLocale\n );\n}\n", Ef = "import { deLocalizeDefault, stringifyPattern } from \"wuchale/url\";\nimport type { Locale } from \"#locales/data.js\";\nimport { matchUrl } from \"#locales/main.url.js\";\nimport { locales } from \"#locales/data.js\";\n\n// wuchale treats locales[0] as the source locale, so it is the one served unprefixed\nexport const defaultLocale: Locale = locales[0];\n\n/**\n * Localizer for wuchale's `url.localize` config. Compiled URLs in components\n * are passed through this, so the default locale stays unprefixed.\n */\nexport function localize(path: string, locale: Locale) {\n if (locale === defaultLocale) {\n return path;\n }\n\n // matches wuchale's localizeDefault, which drops the trailing slash\n const localized = `/${locale}${path}`;\n return localized.endsWith(\"/\") ? localized.slice(0, -1) : localized;\n}\n\n/**\n * Whether a page has a URL per language (it is under `url.patterns` in\n * wuchale.config.js). The other pages follow the visitor's preference: see\n * src/lib/locale.ts.\n */\nexport function hasLocalizedUrl(pathname: string) {\n const [pathOnly] = deLocalizeDefault(pathname, locales);\n return matchUrl(pathOnly, defaultLocale).path !== null;\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 = stringifyPattern(\n result.altPatterns[toLocale],\n result.params,\n );\n return localize(targetPath, toLocale);\n }\n return localize(pathOnly, toLocale);\n}\n", Df = "// @ts-check\nimport { adapter as svelte, createSvelteHeuristic } from \"@wuchale/svelte\";\nimport { adapter as js } from \"wuchale/adapter-vanilla\";\nimport { defaultHeuristicOpts, defineConfig } from \"wuchale\";\n\nexport default defineConfig({\n locales: [\"en\", \"es\"],\n // `vela test:server` stubs every +page.svelte. In the default `refs` dev mode\n // the extractor would take those stubs at face value, drop the pages'\n // references from the .po files and recompile the catalogs while requests\n // are in flight. Under TEST wuchale neither transforms nor writes anything.\n ...(process.env.TEST === \"true\" ? { dev: false } : {}),\n adapters: {\n main: svelte({\n loader: \"sveltekit\",\n // The pages with a URL per language (`/`, `/es`): the public ones. A\n // page that is not listed, such as a sign-in page or one behind it, has\n // one URL and follows the visitor's preference (src/lib/locale.ts).\n url: { localize: \"src/lib/url.ts\", patterns: [\"/\"] },\n // wuchale localizes the `href` of an <a> by default, when the path is\n // one of the `url.patterns` above. Most links are components that render\n // an <a>, and a tag is matched by the name it is written with, so each\n // is listed; without this the navbar on /es points at the English pages.\n // A link component of your own goes here too.\n heuristic: createSvelteHeuristic({\n ...defaultHeuristicOpts,\n urlCalls: [\"asset\", \"goto\", \"pushState\", \"replaceState\", \"resolve\"],\n urlAttribs: [\n [\"a\", \"href\"],\n [\"Button\", \"href\"],\n [\"Badge\", \"href\"],\n [\"Navbar.Brand\", \"href\"],\n [\"Navbar.Link\", \"href\"],\n [\"AuthMenu.Item\", \"href\"],\n [\"Breadcrumb.Link\", \"href\"],\n [\"NavigationMenu.Link\", \"href\"],\n [\"Sidebar.MenuSubButton\", \"href\"],\n [\"Command.LinkItem\", \"href\"],\n [\"HoverCard.Trigger\", \"href\"],\n ],\n }),\n }),\n js: js({\n loader: \"vite\",\n files: [\n \"src/**/+{page,layout}.{js,ts}\",\n \"src/**/+{page,layout}.server.{js,ts}\",\n // Remote functions answer with messages a visitor reads too.\n \"src/**/*.remote.{js,ts}\",\n ],\n }),\n },\n});\n", Of = "<script lang=\"ts\">\n import { locales, type Locale } from \"#locales/data.js\";\n import { page } from \"$app/state\";\n import { goto, invalidateAll } from \"$app/navigation\";\n import { hasLocalizedUrl, translateUrl } from \"#lib/url.js\";\n import { localeCookie } from \"#lib/locale.js\";\n\n let locale: Locale = $derived(page.data.locale);\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 handleChange = async (\n event: Event & { currentTarget: HTMLSelectElement },\n ) => {\n const value = event.currentTarget.value as Locale;\n // Remembered for the pages that have no language in their URL.\n document.cookie = localeCookie(value);\n\n if (hasLocalizedUrl(page.url.pathname)) {\n await goto(translateUrl(page.url.pathname, locale, value), {\n refreshAll: true,\n });\n } else {\n await invalidateAll();\n }\n };\n\n let { class: className }: { class?: string } = $props();\n<\/script>\n\n<select\n class={className}\n aria-label=\"Language\"\n value={locale}\n onchange={handleChange}\n>\n {#each locales as code (code)}\n <option value={code}>{localeNames[code]}</option>\n {/each}\n</select>\n", kf = /* #__PURE__ */ Object.assign({
|
|
5844
5855
|
"./creates/src/lib/components/language-select.svelte": wf,
|
|
5845
|
-
"./creates/src/lib/
|
|
5846
|
-
"./creates/
|
|
5847
|
-
|
|
5848
|
-
|
|
5856
|
+
"./creates/src/lib/locale.ts": Tf,
|
|
5857
|
+
"./creates/src/lib/url.ts": Ef,
|
|
5858
|
+
"./creates/wuchale.config.js": Df
|
|
5859
|
+
}), Af = /* #__PURE__ */ Object.assign({ "./variants/plain/src/lib/components/language-select.svelte": Of }), jf = "./creates/";
|
|
5860
|
+
async function Mf(e) {
|
|
5849
5861
|
let t = Me(e);
|
|
5850
5862
|
return {
|
|
5851
|
-
creates: xe(
|
|
5863
|
+
creates: xe(kf, jf, Af, t === "plain" ? "plain" : void 0),
|
|
5852
5864
|
modifies: [],
|
|
5853
5865
|
deletes: [],
|
|
5854
5866
|
components: t === "plain" ? [] : ["select"],
|
|
@@ -5859,19 +5871,19 @@ async function jf(e) {
|
|
|
5859
5871
|
};
|
|
5860
5872
|
}
|
|
5861
5873
|
// src/patterns/enable/i18n/generate.preview.ts
|
|
5862
|
-
var
|
|
5874
|
+
var Nf = /* #__PURE__ */ Object.assign({
|
|
5863
5875
|
"./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",
|
|
5864
5876
|
"./preview-modifies/src/hooks.server.ts": "// [!code highlight:1]\nimport { sequence, type ServerInit } from \"@sveltejs/kit/hooks\";\nimport {\n POCKETBASE_URL,\n POCKETBASE_SUPERUSER_EMAIL,\n POCKETBASE_SUPERUSER_PASSWORD,\n} from \"$app/env/private\";\nimport { handlePocketbase } from \"@velastack/pocketbase\";\nimport { startWorker } from \"#lib/server/workflows.js\";\n// [!code highlight:5]\nimport { runWithLocale, loadLocales } from \"wuchale/load-utils/server\";\nimport { getLocale } from \"#locales/main.url.js\";\nimport { locales } from \"#locales/data.js\";\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.loadCount, main.loadCatalog, locales);\nloadLocales(js.key, js.loadCount, 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\n// [!code highlight:2]\nexport const handle = sequence(\n handleWuchale,\n handlePocketbase({\n pocketbaseUrl: POCKETBASE_URL,\n superuserEmail: POCKETBASE_SUPERUSER_EMAIL,\n superuserPassword: POCKETBASE_SUPERUSER_PASSWORD,\n }),\n // [!code highlight:1]\n);\n\n// Runs once when the server starts: executes the workflows in src/lib/workflows.\nexport const init: ServerInit = () => startWorker();\n",
|
|
5865
5877
|
"./preview-modifies/src/hooks.ts": "import { deLocalizeDefault } from \"wuchale/url\";\nimport { matchUrl } from \"#locales/main.url.js\";\nimport { locales } from \"#locales/data.js\";\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",
|
|
5866
5878
|
"./preview-modifies/src/routes/(public)/root-layout.svelte": "<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { toggleMode } from 'mode-watcher';\n import * as Navbar from '#lib/components/ui/navbar/index.js';\n import { Button } from '#lib/components/ui/button/index.js';\n // [!code highlight]\n import LanguageSelect from '#lib/components/language-select.svelte';\n\n // Layout data is passed through for navbar items a feature adds; enable auth\n // reads the signed-in user from it.\n let { children }: { children?: Snippet; data?: any } = $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} 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 {site.name}. 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 <!-- Neither route exists yet: `vela legal privacy` and `vela legal terms` generate them. -->\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",
|
|
5867
5879
|
"./preview-modifies/src/routes/+layout.ts": "import { browser } from \"$app/env\";\n// [!code highlight:4]\nimport { loadLocale } from \"wuchale/load-utils\";\nimport { getLocale } from \"#locales/main.url.js\";\nimport \"#locales/main.loader.svelte.js\";\nimport \"#locales/js.loader.js\";\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",
|
|
5868
5880
|
"./preview-modifies/vite.config.ts": "// [!code highlight:1]\nimport { wuchale } from \"wuchale/vite\";\nimport { defineConfig } from \"vite\";\nimport tailwindcss from \"@tailwindcss/vite\";\nimport { sveltekit } from \"@sveltejs/kit/vite\";\nimport adapter from \"@sveltejs/adapter-node\";\n\nexport default defineConfig({\n plugins: [\n // [!code highlight:1]\n wuchale(),\n tailwindcss(),\n sveltekit({\n compilerOptions: {\n runes: ({ filename }) =>\n filename.split(/[/\\\\]/).includes(\"node_modules\") ? undefined : true,\n },\n adapter: adapter(),\n // The public origin, which SvelteKit checks form posts against and uses\n // for prerendered pages. `vela deploy` sets VELA_ORIGIN, and the value is\n // baked in at build time. It is left unset for a deploy that serves more\n // than one host, where each request's own origin is used instead.\n ...(process.env.VELA_ORIGIN\n ? { paths: { origin: process.env.VELA_ORIGIN } }\n : {}),\n }),\n ],\n});\n"
|
|
5869
|
-
}),
|
|
5870
|
-
async function
|
|
5881
|
+
}), Pf = "./preview-modifies/";
|
|
5882
|
+
async function Ff(e) {
|
|
5871
5883
|
return {
|
|
5872
5884
|
creates: [],
|
|
5873
|
-
modifies: Object.entries(
|
|
5874
|
-
let n = D(e,
|
|
5885
|
+
modifies: Object.entries(Nf).map(([e, t]) => {
|
|
5886
|
+
let n = D(e, Pf);
|
|
5875
5887
|
return {
|
|
5876
5888
|
path: n,
|
|
5877
5889
|
language: w(n),
|
|
@@ -5888,23 +5900,23 @@ async function Pf(e) {
|
|
|
5888
5900
|
};
|
|
5889
5901
|
}
|
|
5890
5902
|
// src/patterns/enable/i18n/index.ts
|
|
5891
|
-
var
|
|
5892
|
-
async function
|
|
5893
|
-
let t = await
|
|
5903
|
+
var If = "enable-i18n", Lf = "1.3.0", Rf = "src/patterns/enable/i18n", zf = "/enable/i18n";
|
|
5904
|
+
async function Bf(e) {
|
|
5905
|
+
let t = await Mf(e);
|
|
5894
5906
|
if (e.env === "preview") {
|
|
5895
|
-
let n = await
|
|
5907
|
+
let n = await Ff(e);
|
|
5896
5908
|
return S(T([t, n]), e);
|
|
5897
5909
|
}
|
|
5898
|
-
let { generate: n, withLibraryTexts: r } = await import("./chunks/generate.runtime-
|
|
5910
|
+
let { generate: n, withLibraryTexts: r } = await import("./chunks/generate.runtime-CZKIKP3B.js");
|
|
5899
5911
|
t.creates = r(e.root, t.creates);
|
|
5900
|
-
let i = await n(e), { writeResult: a } = await import("./chunks/write-result-
|
|
5912
|
+
let i = await n(e), { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
5901
5913
|
return a(await S(T([t, i]), e), e);
|
|
5902
5914
|
}
|
|
5903
|
-
var
|
|
5904
|
-
version:
|
|
5905
|
-
slug:
|
|
5906
|
-
source:
|
|
5907
|
-
docs:
|
|
5915
|
+
var Vf = {
|
|
5916
|
+
version: Lf,
|
|
5917
|
+
slug: If,
|
|
5918
|
+
source: Rf,
|
|
5919
|
+
docs: zf,
|
|
5908
5920
|
plan: "open",
|
|
5909
5921
|
title: "Enable i18n",
|
|
5910
5922
|
summary: "Enables i18n with Wuchale and locale-aware routing.",
|
|
@@ -5936,17 +5948,17 @@ var Bf = {
|
|
|
5936
5948
|
examples: [],
|
|
5937
5949
|
tests: 0,
|
|
5938
5950
|
baseline: "velastack",
|
|
5939
|
-
generate:
|
|
5940
|
-
},
|
|
5941
|
-
"./creates/src/lib/components/notifications-bell.svelte":
|
|
5942
|
-
"./creates/src/lib/server/notifications.ts":
|
|
5943
|
-
"./creates/src/routes/(app)/notifications/+page.server.ts":
|
|
5944
|
-
"./creates/src/routes/(app)/notifications/+page.svelte":
|
|
5945
|
-
}),
|
|
5946
|
-
async function
|
|
5951
|
+
generate: Bf
|
|
5952
|
+
}, Hf = "<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/index.js';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';\n import { timeAgo } from '#lib/utils.js';\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", Uf = "export interface NotifyInput {\n title: string;\n body?: string;\n}\n\n/**\n * Drop a notification on a user. Server-only (src/lib/server): from a load or\n * action with `locals.pb`, or from a webhook handler with `locals.admin`.\n */\nexport async function notify(pb: App.Locals['pb'], 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", Wf = "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", Gf = "<script lang=\"ts\">\n import { enhance } from '$app/forms';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { timeAgo } from '#lib/utils.js';\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", Kf = /* #__PURE__ */ Object.assign({
|
|
5953
|
+
"./creates/src/lib/components/notifications-bell.svelte": Hf,
|
|
5954
|
+
"./creates/src/lib/server/notifications.ts": Uf,
|
|
5955
|
+
"./creates/src/routes/(app)/notifications/+page.server.ts": Wf,
|
|
5956
|
+
"./creates/src/routes/(app)/notifications/+page.svelte": Gf
|
|
5957
|
+
}), qf = "./creates/";
|
|
5958
|
+
async function Jf(e) {
|
|
5947
5959
|
return {
|
|
5948
|
-
creates: Object.entries(
|
|
5949
|
-
let n = D(e,
|
|
5960
|
+
creates: Object.entries(Kf).map(([e, t]) => {
|
|
5961
|
+
let n = D(e, qf);
|
|
5950
5962
|
return {
|
|
5951
5963
|
path: n,
|
|
5952
5964
|
language: w(n),
|
|
@@ -5964,8 +5976,8 @@ async function qf(e) {
|
|
|
5964
5976
|
};
|
|
5965
5977
|
}
|
|
5966
5978
|
// src/patterns/enable/notifications/preview-modifies/src/lib/utils.ts?raw
|
|
5967
|
-
var
|
|
5968
|
-
function
|
|
5979
|
+
var Yf = "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", Xf = "users";
|
|
5980
|
+
function Zf(e) {
|
|
5969
5981
|
let t = or.find((t) => t.collectionName === e);
|
|
5970
5982
|
if (!t) throw Error(`notifications: missing NOTIFICATION_RULE_PATCHES entry for "${e}"`);
|
|
5971
5983
|
return {
|
|
@@ -5976,10 +5988,10 @@ function Xf(e) {
|
|
|
5976
5988
|
deleteRule: t.deleteRule
|
|
5977
5989
|
};
|
|
5978
5990
|
}
|
|
5979
|
-
var
|
|
5991
|
+
var Qf = [{
|
|
5980
5992
|
name: "notifications",
|
|
5981
5993
|
type: "base",
|
|
5982
|
-
...
|
|
5994
|
+
...Zf("notifications"),
|
|
5983
5995
|
indexes: ["CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)"],
|
|
5984
5996
|
fields: [
|
|
5985
5997
|
{
|
|
@@ -5996,7 +6008,7 @@ var Zf = [{
|
|
|
5996
6008
|
name: "user",
|
|
5997
6009
|
type: "relation",
|
|
5998
6010
|
cascadeDelete: !0,
|
|
5999
|
-
collectionId:
|
|
6011
|
+
collectionId: Xf,
|
|
6000
6012
|
maxSelect: 1,
|
|
6001
6013
|
minSelect: 0,
|
|
6002
6014
|
required: !0
|
|
@@ -6027,12 +6039,12 @@ var Zf = [{
|
|
|
6027
6039
|
onUpdate: !0
|
|
6028
6040
|
}
|
|
6029
6041
|
]
|
|
6030
|
-
}],
|
|
6031
|
-
async function
|
|
6042
|
+
}], $f = /* #__PURE__ */ Object.assign({ "./preview-modifies/src/lib/utils.ts": Yf }), ep = "./preview-modifies/";
|
|
6043
|
+
async function tp(e) {
|
|
6032
6044
|
return {
|
|
6033
6045
|
creates: [],
|
|
6034
|
-
modifies: Object.entries(
|
|
6035
|
-
let n = D(e,
|
|
6046
|
+
modifies: Object.entries($f).map(([e, t]) => {
|
|
6047
|
+
let n = D(e, ep);
|
|
6036
6048
|
return {
|
|
6037
6049
|
path: n,
|
|
6038
6050
|
language: w(n),
|
|
@@ -6043,27 +6055,27 @@ async function ep(e) {
|
|
|
6043
6055
|
deletes: [],
|
|
6044
6056
|
components: [],
|
|
6045
6057
|
packages: [],
|
|
6046
|
-
collections:
|
|
6058
|
+
collections: Qf,
|
|
6047
6059
|
collectionPatches: [],
|
|
6048
6060
|
collectionDrops: []
|
|
6049
6061
|
};
|
|
6050
6062
|
}
|
|
6051
6063
|
// src/patterns/enable/notifications/index.ts
|
|
6052
|
-
var
|
|
6053
|
-
async function
|
|
6054
|
-
let t = await
|
|
6064
|
+
var np = "enable-notifications", rp = "1.1.1", ip = "src/patterns/enable/notifications", ap = "/enable/notifications";
|
|
6065
|
+
async function op(e) {
|
|
6066
|
+
let t = await Jf(e);
|
|
6055
6067
|
if (e.env === "preview") {
|
|
6056
|
-
let n = await
|
|
6068
|
+
let n = await tp(e);
|
|
6057
6069
|
return S(T([t, n]), e);
|
|
6058
6070
|
}
|
|
6059
|
-
let { generate: n } = await import("./chunks/generate.runtime-Ct7cG8va.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
6071
|
+
let { generate: n } = await import("./chunks/generate.runtime-Ct7cG8va.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
6060
6072
|
return i(await S(T([t, r]), e), e);
|
|
6061
6073
|
}
|
|
6062
|
-
var
|
|
6063
|
-
version:
|
|
6064
|
-
slug:
|
|
6065
|
-
source:
|
|
6066
|
-
docs:
|
|
6074
|
+
var sp = {
|
|
6075
|
+
version: rp,
|
|
6076
|
+
slug: np,
|
|
6077
|
+
source: ip,
|
|
6078
|
+
docs: ap,
|
|
6067
6079
|
plan: "open",
|
|
6068
6080
|
title: "Enable notifications",
|
|
6069
6081
|
summary: "Adds an in-app notifications collection, a bell dropdown with 30s polling, and a /notifications page for managing read state.",
|
|
@@ -6097,22 +6109,22 @@ var op = {
|
|
|
6097
6109
|
examples: [],
|
|
6098
6110
|
tests: 6,
|
|
6099
6111
|
baseline: "velastack",
|
|
6100
|
-
generate:
|
|
6101
|
-
}, sp = "import { defineEnvVars } from '@sveltejs/kit/env';\n\n/**\n * Every environment variable the app reads. SvelteKit exposes only what is\n * declared here, through `$app/env/private` (and `$app/env/public` for\n * `public: true`).\n *\n * Each schema turns a missing value into `''`, so the app builds and starts\n * with an empty `.env`, and a default belongs at the call site as `X || fallback`.\n */\nexport const variables = defineEnvVars({\n PUBLIC_SHOPIFY_STORE_DOMAIN: {\n public: true,\n schema: (value) => value ?? '',\n description: \"The store's `*.myshopify.com` domain the Storefront API is called on.\"\n },\n PUBLIC_SHOPIFY_STOREFRONT_TOKEN: {\n public: true,\n schema: (value) => value ?? '',\n description: \"Public Storefront API access token, from the store's Headless channel.\"\n }\n});\n", cp = "import { defineEnvVars } from '@sveltejs/kit/env';\n\n/**\n * Every environment variable the app reads. SvelteKit exposes only what is\n * declared here, through `$app/env/private` (and `$app/env/public` for\n * `public: true`).\n *\n * Each schema turns a missing value into `''`, so the app builds and starts\n * with an empty `.env`, and a default belongs at the call site as `X || fallback`.\n */\nexport const variables = defineEnvVars({\n POCKETBASE_URL: {\n schema: (value) => value ?? '',\n description: 'Where PocketBase listens. `vela dev` and `vela deploy` set it.'\n },\n POCKETBASE_SUPERUSER_EMAIL: {\n schema: (value) => value ?? '',\n description: 'Superuser email the server signs in with for admin features and workflows.'\n },\n POCKETBASE_SUPERUSER_PASSWORD: {\n schema: (value) => value ?? '',\n description: 'Password for POCKETBASE_SUPERUSER_EMAIL.'\n },\n WORKFLOWS_ENABLED: {\n schema: (value) => value ?? '',\n description: 'Set to `false` to stop this process running workflows; it can still start them.'\n },\n WORKFLOWS_CONCURRENCY: {\n schema: (value) => value ?? '',\n description: 'How many workflow runs this process executes at once. Defaults to 5.'\n },\n TEST: {\n schema: (value) => value ?? '',\n description: '`true` under `vela test:server`, which turns off the workflow cron schedules.'\n },\n // [!code highlight:13]\n STRIPE_SECRET_KEY: {\n schema: (value) => value ?? '',\n description: 'Stripe secret key (`sk_...`) the server calls the Stripe API with.'\n },\n PUBLIC_STRIPE_PUBLISHABLE_KEY: {\n public: true,\n schema: (value) => value ?? '',\n description: 'Stripe publishable key (`pk_...`) that Stripe.js loads in the browser.'\n },\n STRIPE_WEBHOOK_SECRET: {\n schema: (value) => value ?? '',\n description: 'Signing secret (`whsec_...`) that `/webhooks/stripe` verifies events with.'\n }\n});\n", lp = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n // [!code highlight:1]\n import CreditCardIcon from '@lucide/svelte/icons/credit-card';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n import { displayName, type UserIdentity } from '#lib/user.js';\n import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n\n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n },\n // [!code highlight:5]\n {\n title: 'Billing',\n url: '/billing',\n icon: CreditCardIcon\n }\n ]\n };\n\n let {\n user\n }: {\n user: UserIdentity & {\n id: 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 <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</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 <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</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", up = "import { redirect } from '@sveltejs/kit';\nimport { fail, message, superValidate } from 'sveltekit-superforms';\nimport { zod4 } from 'sveltekit-superforms/adapters';\nimport { setFlash } from 'sveltekit-flash-message/server';\nimport { setPocketbaseErrors } from '@velastack/pocketbase/form';\nimport { dev } from '$app/env';\nimport { signupSchema } from '#lib/schemas/signup.js';\nimport { linkStripeCustomer } from '#lib/workflows/link-stripe-customer.js';\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 const type: 'password' | 'otp' =\n !authMethods.password.enabled && authMethods.otp.enabled ? 'otp' : 'password';\n\n return {\n form: await superValidate(\n zod4(\n signupSchema.default({\n type,\n email: '',\n password: '',\n passwordConfirm: ''\n })\n )\n ),\n authMethods\n };\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 // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get('redirect');\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : '';\n\n if (form.data.type === 'otp') {\n // PocketBase only sends codes to existing accounts, so create it first,\n // with a password nobody knows (a reset sets a real one). Checking the\n // code marks the email verified.\n const password = crypto.randomUUID();\n try {\n await locals.admin.collection('users').create({\n email: form.data.email,\n password,\n passwordConfirm: password\n });\n } catch (error: any) {\n // An existing account gets a code too, the same as logging in with one.\n if (error.response?.data?.email?.code !== 'validation_not_unique') {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n }\n\n let otpId: string;\n try {\n ({ otpId } = await locals.pb.collection('users').requestOTP(form.data.email));\n } catch (error: any) {\n return message(\n form,\n {\n type: 'error',\n text: error.response?.message ?? 'Failed to send the code.'\n },\n { status: 400 }\n );\n }\n // A new account has no name yet: ask for one once the code checks out.\n const welcome = `/welcome${redirectQuery}`;\n return redirect(303, `/otp/${otpId}?redirect=${encodeURIComponent(welcome)}`);\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 // Queued here, done in the background: the Stripe calls retry on their own,\n // and the key means a retry never makes a second customer for this user.\n await linkStripeCustomer.run(\n { userId: user.id, email: form.data.email },\n { idempotencyKey: user.id }\n );\n\n await locals.pb.collection('users').requestVerification(user.email!);\n await locals.pb.collection('users').authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = redirectParam ?? '/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({ type: 'toast', message: 'We sent a confirmation link to your email.' }, cookies);\n return redirect(303, redirectUrl);\n }\n};\n", dp = "import { defineEnvVars } from '@sveltejs/kit/env';\n\n/**\n * Every environment variable the app reads. SvelteKit exposes only what is\n * declared here, through `$app/env/private` (and `$app/env/public` for\n * `public: true`).\n *\n * Each schema turns a missing value into `''`, so the app builds and starts\n * with an empty `.env`, and a default belongs at the call site as `X || fallback`.\n */\nexport const variables = defineEnvVars({\n PUBLIC_WHATSAPP_NUMBER: {\n public: true,\n schema: (value) => value ?? '',\n description:\n \"The business's WhatsApp number, with country code, that orders open a chat with.\"\n },\n PUBLIC_WHATSAPP_ORDER_FORM: {\n public: true,\n schema: (value) => value ?? '',\n description:\n 'The hosted VelaStack form each order is recorded to, so it is kept even if the chat is never sent. Empty records nothing.'\n }\n});\n", fp, pp, mp = /* #__PURE__ */ Object.assign({
|
|
6102
|
-
"./preview-modifies/shopify/src/env.ts":
|
|
6103
|
-
"./preview-modifies/stripe/src/env.ts":
|
|
6104
|
-
"./preview-modifies/stripe/src/lib/components/nav-user.svelte":
|
|
6105
|
-
"./preview-modifies/stripe/src/routes/(public)/(auth)/signup/+page.server.ts":
|
|
6106
|
-
"./preview-modifies/whatsapp/src/env.ts":
|
|
6107
|
-
}),
|
|
6108
|
-
function
|
|
6109
|
-
return C(
|
|
6110
|
-
}
|
|
6111
|
-
function
|
|
6112
|
-
return C(
|
|
6113
|
-
}
|
|
6114
|
-
async function
|
|
6115
|
-
let t = x(ur, e), n = t.id === "stripe", r = e.features.auth, i = Object.values(be(
|
|
6112
|
+
generate: op
|
|
6113
|
+
}, cp = "import { defineEnvVars } from '@sveltejs/kit/env';\n\n/**\n * Every environment variable the app reads. SvelteKit exposes only what is\n * declared here, through `$app/env/private` (and `$app/env/public` for\n * `public: true`).\n *\n * Each schema turns a missing value into `''`, so the app builds and starts\n * with an empty `.env`, and a default belongs at the call site as `X || fallback`.\n */\nexport const variables = defineEnvVars({\n PUBLIC_SHOPIFY_STORE_DOMAIN: {\n public: true,\n schema: (value) => value ?? '',\n description: \"The store's `*.myshopify.com` domain the Storefront API is called on.\"\n },\n PUBLIC_SHOPIFY_STOREFRONT_TOKEN: {\n public: true,\n schema: (value) => value ?? '',\n description: \"Public Storefront API access token, from the store's Headless channel.\"\n }\n});\n", lp = "import { defineEnvVars } from '@sveltejs/kit/env';\n\n/**\n * Every environment variable the app reads. SvelteKit exposes only what is\n * declared here, through `$app/env/private` (and `$app/env/public` for\n * `public: true`).\n *\n * Each schema turns a missing value into `''`, so the app builds and starts\n * with an empty `.env`, and a default belongs at the call site as `X || fallback`.\n */\nexport const variables = defineEnvVars({\n POCKETBASE_URL: {\n schema: (value) => value ?? '',\n description: 'Where PocketBase listens. `vela dev` and `vela deploy` set it.'\n },\n POCKETBASE_SUPERUSER_EMAIL: {\n schema: (value) => value ?? '',\n description: 'Superuser email the server signs in with for admin features and workflows.'\n },\n POCKETBASE_SUPERUSER_PASSWORD: {\n schema: (value) => value ?? '',\n description: 'Password for POCKETBASE_SUPERUSER_EMAIL.'\n },\n WORKFLOWS_ENABLED: {\n schema: (value) => value ?? '',\n description: 'Set to `false` to stop this process running workflows; it can still start them.'\n },\n WORKFLOWS_CONCURRENCY: {\n schema: (value) => value ?? '',\n description: 'How many workflow runs this process executes at once. Defaults to 5.'\n },\n TEST: {\n schema: (value) => value ?? '',\n description: '`true` under `vela test:server`, which turns off the workflow cron schedules.'\n },\n // [!code highlight:13]\n STRIPE_SECRET_KEY: {\n schema: (value) => value ?? '',\n description: 'Stripe secret key (`sk_...`) the server calls the Stripe API with.'\n },\n PUBLIC_STRIPE_PUBLISHABLE_KEY: {\n public: true,\n schema: (value) => value ?? '',\n description: 'Stripe publishable key (`pk_...`) that Stripe.js loads in the browser.'\n },\n STRIPE_WEBHOOK_SECRET: {\n schema: (value) => value ?? '',\n description: 'Signing secret (`whsec_...`) that `/webhooks/stripe` verifies events with.'\n }\n});\n", up = "<script lang=\"ts\">\n import { toggleMode, mode } from 'mode-watcher';\n import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\n import Settings2Icon from '@lucide/svelte/icons/settings-2';\n // [!code highlight:1]\n import CreditCardIcon from '@lucide/svelte/icons/credit-card';\n import LogOutIcon from '@lucide/svelte/icons/log-out';\n import MoonIcon from '@lucide/svelte/icons/moon';\n import SunIcon from '@lucide/svelte/icons/sun';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n import { displayName, type UserIdentity } from '#lib/user.js';\n import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n\n let data = {\n navUser: [\n {\n title: 'Settings',\n url: '/settings',\n icon: Settings2Icon\n },\n // [!code highlight:5]\n {\n title: 'Billing',\n url: '/billing',\n icon: CreditCardIcon\n }\n ]\n };\n\n let {\n user\n }: {\n user: UserIdentity & {\n id: 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 <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</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 <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</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", dp = "import { redirect } from '@sveltejs/kit';\nimport { fail, message, superValidate } from 'sveltekit-superforms';\nimport { zod4 } from 'sveltekit-superforms/adapters';\nimport { setFlash } from 'sveltekit-flash-message/server';\nimport { setPocketbaseErrors } from '@velastack/pocketbase/form';\nimport { dev } from '$app/env';\nimport { signupSchema } from '#lib/schemas/signup.js';\nimport { linkStripeCustomer } from '#lib/workflows/link-stripe-customer.js';\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 const type: 'password' | 'otp' =\n !authMethods.password.enabled && authMethods.otp.enabled ? 'otp' : 'password';\n\n return {\n form: await superValidate(\n zod4(\n signupSchema.default({\n type,\n email: '',\n password: '',\n passwordConfirm: ''\n })\n )\n ),\n authMethods\n };\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 // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get('redirect');\n const redirectParam = next && /^\\/(?![/\\\\])/.test(next) ? next : null;\n const redirectQuery = redirectParam ? `?redirect=${encodeURIComponent(redirectParam)}` : '';\n\n if (form.data.type === 'otp') {\n // PocketBase only sends codes to existing accounts, so create it first,\n // with a password nobody knows (a reset sets a real one). Checking the\n // code marks the email verified.\n const password = crypto.randomUUID();\n try {\n await locals.admin.collection('users').create({\n email: form.data.email,\n password,\n passwordConfirm: password\n });\n } catch (error: any) {\n // An existing account gets a code too, the same as logging in with one.\n if (error.response?.data?.email?.code !== 'validation_not_unique') {\n setPocketbaseErrors(form, error);\n return fail(400, { form });\n }\n }\n\n let otpId: string;\n try {\n ({ otpId } = await locals.pb.collection('users').requestOTP(form.data.email));\n } catch (error: any) {\n return message(\n form,\n {\n type: 'error',\n text: error.response?.message ?? 'Failed to send the code.'\n },\n { status: 400 }\n );\n }\n // A new account has no name yet: ask for one once the code checks out.\n const welcome = `/welcome${redirectQuery}`;\n return redirect(303, `/otp/${otpId}?redirect=${encodeURIComponent(welcome)}`);\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 // Queued here, done in the background: the Stripe calls retry on their own,\n // and the key means a retry never makes a second customer for this user.\n await linkStripeCustomer.run(\n { userId: user.id, email: form.data.email },\n { idempotencyKey: user.id }\n );\n\n await locals.pb.collection('users').requestVerification(user.email!);\n await locals.pb.collection('users').authWithPassword(form.data.email, form.data.password);\n\n const redirectUrl = redirectParam ?? '/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({ type: 'toast', message: 'We sent a confirmation link to your email.' }, cookies);\n return redirect(303, redirectUrl);\n }\n};\n", fp = "import { defineEnvVars } from '@sveltejs/kit/env';\n\n/**\n * Every environment variable the app reads. SvelteKit exposes only what is\n * declared here, through `$app/env/private` (and `$app/env/public` for\n * `public: true`).\n *\n * Each schema turns a missing value into `''`, so the app builds and starts\n * with an empty `.env`, and a default belongs at the call site as `X || fallback`.\n */\nexport const variables = defineEnvVars({\n PUBLIC_WHATSAPP_NUMBER: {\n public: true,\n schema: (value) => value ?? '',\n description:\n \"The business's WhatsApp number, with country code, that orders open a chat with.\"\n },\n PUBLIC_WHATSAPP_ORDER_FORM: {\n public: true,\n schema: (value) => value ?? '',\n description:\n 'The hosted VelaStack form each order is recorded to, so it is kept even if the chat is never sent. Empty records nothing.'\n }\n});\n", pp, mp, hp = /* #__PURE__ */ Object.assign({
|
|
6114
|
+
"./preview-modifies/shopify/src/env.ts": cp,
|
|
6115
|
+
"./preview-modifies/stripe/src/env.ts": lp,
|
|
6116
|
+
"./preview-modifies/stripe/src/lib/components/nav-user.svelte": up,
|
|
6117
|
+
"./preview-modifies/stripe/src/routes/(public)/(auth)/signup/+page.server.ts": dp,
|
|
6118
|
+
"./preview-modifies/whatsapp/src/env.ts": fp
|
|
6119
|
+
}), gp = "price_preview_placeholder", _p = "gid://shopify/ProductVariant/preview";
|
|
6120
|
+
function vp() {
|
|
6121
|
+
return C(pp ||= A(["\n <script lang=\"ts\">\n import OrderButton from '#lib/components/payments/order-button.svelte';\n <\/script>\n\n <section data-role=\"content\">\n <OrderButton name=\"Sourdough loaf\" price={4.5} />\n </section>\n "]));
|
|
6122
|
+
}
|
|
6123
|
+
function yp(e) {
|
|
6124
|
+
return C(mp ||= A(["\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);
|
|
6125
|
+
}
|
|
6126
|
+
async function bp(e) {
|
|
6127
|
+
let t = x(ur, e), n = t.id === "stripe", r = e.features.auth, i = Object.values(be(hp, `./preview-modifies/${t.id}/`));
|
|
6116
6128
|
i.push({
|
|
6117
6129
|
path: ".env",
|
|
6118
6130
|
language: "text",
|
|
@@ -6131,7 +6143,7 @@ async function yp(e) {
|
|
|
6131
6143
|
let a = {
|
|
6132
6144
|
path: "src/routes/(public)/payment/+page.svelte",
|
|
6133
6145
|
language: "svelte",
|
|
6134
|
-
content: t.id === "stripe" ?
|
|
6146
|
+
content: t.id === "stripe" ? yp(gp) : t.id === "shopify" ? dr(_p) : vp(),
|
|
6135
6147
|
status: "success"
|
|
6136
6148
|
}, o = n ? [...fr, ...r ? pr : []] : [];
|
|
6137
6149
|
return {
|
|
@@ -6146,20 +6158,20 @@ async function yp(e) {
|
|
|
6146
6158
|
};
|
|
6147
6159
|
}
|
|
6148
6160
|
// src/patterns/enable/payments/index.ts
|
|
6149
|
-
var
|
|
6150
|
-
async function
|
|
6161
|
+
var xp = "enable-payments", Sp = "2.4.0", Cp = "src/patterns/enable/payments", wp = "/enable/payments";
|
|
6162
|
+
async function Tp(e) {
|
|
6151
6163
|
if (e.env === "preview") {
|
|
6152
|
-
let t = await lr(e), n = await
|
|
6164
|
+
let t = await lr(e), n = await bp(e);
|
|
6153
6165
|
return S(T([t, n]), e);
|
|
6154
6166
|
}
|
|
6155
|
-
let { generate: t, hasVitest: n } = await import("./chunks/generate.runtime-B06rPt_j.js"), r = await lr(e, { unitTests: n(e.root) }), i = await t(e), { writeResult: a } = await import("./chunks/write-result-
|
|
6167
|
+
let { generate: t, hasVitest: n } = await import("./chunks/generate.runtime-B06rPt_j.js"), r = await lr(e, { unitTests: n(e.root) }), i = await t(e), { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
6156
6168
|
return a(await S(T([r, i]), e), e);
|
|
6157
6169
|
}
|
|
6158
|
-
var
|
|
6159
|
-
version:
|
|
6160
|
-
slug:
|
|
6161
|
-
source:
|
|
6162
|
-
docs:
|
|
6170
|
+
var Ep = {
|
|
6171
|
+
version: Sp,
|
|
6172
|
+
slug: xp,
|
|
6173
|
+
source: Cp,
|
|
6174
|
+
docs: wp,
|
|
6163
6175
|
plan: "pro",
|
|
6164
6176
|
title: "Enable payments",
|
|
6165
6177
|
summary: "Adds payments with Stripe (product/price sync, a checkout dialog, and saved payment methods when auth is enabled), Shopify (a Storefront client and a Buy button that hands off to Shopify's checkout), or WhatsApp (an Order button that opens a prefilled chat with the business and records the order to a hosted VelaStack form).",
|
|
@@ -6209,8 +6221,8 @@ var Tp = {
|
|
|
6209
6221
|
tests: 0,
|
|
6210
6222
|
baseline: "velastack",
|
|
6211
6223
|
providers: cr,
|
|
6212
|
-
generate:
|
|
6213
|
-
}, Ep = "<script lang=\"ts\">\n import { onMount } from 'svelte';\n import ShoppingCartIcon from '@lucide/svelte/icons/shopping-cart';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import { Button } from '#lib/components/ui/button/index.js';\n import { cart } from '#lib/cart.svelte.js';\n import CartSheet from './cart-sheet.svelte';\n\n // The cart lives in the browser, so the server renders it empty and it\n // fills in here.\n onMount(() => cart.load());\n<\/script>\n\n<Button\n variant=\"ghost\"\n size=\"icon\"\n class=\"relative\"\n aria-label=\"Cart, {cart.count} items\"\n onclick={() => (cart.open = true)}\n>\n <ShoppingCartIcon />\n {#if cart.count > 0}\n <Badge class=\"absolute -top-1 -right-1 h-5 min-w-5 rounded-full px-1 tabular-nums\">\n {cart.count}\n </Badge>\n {/if}\n</Button>\n\n<CartSheet />\n", Dp = "import { browser } from '$app/env';\nimport { currency, money } from '#lib/currency.svelte.js';\nimport { marketCountry, storefront } from '#lib/shopify.js';\n\nexport interface Money {\n amount: string;\n currencyCode: string;\n}\n\nexport interface CartLine {\n id: string;\n quantity: number;\n attributes: { key: string; value: string }[];\n cost: { totalAmount: Money };\n merchandise: {\n id: string;\n title: string;\n image: { url: string; altText: string | null } | null;\n price: Money;\n product: { title: string; handle: string };\n };\n}\n\ninterface ShopifyCart {\n id: string;\n checkoutUrl: string;\n totalQuantity: number;\n cost: { subtotalAmount: Money };\n lines: { nodes: CartLine[] };\n}\n\ninterface CartPayload {\n cart: ShopifyCart | null;\n userErrors: { message: string }[];\n}\n\nconst CART_FRAGMENT = `#graphql\n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n attributes {\n key\n value\n }\n cost {\n totalAmount {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n image {\n url\n altText\n }\n price {\n amount\n currencyCode\n }\n product {\n title\n handle\n }\n }\n }\n }\n }\n }\n`;\n\nconst CART_QUERY = `#graphql\n query Cart($id: ID!, $country: CountryCode) @inContext(country: $country) {\n cart(id: $id) {\n ...CartFields\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_CREATE = `#graphql\n mutation CartCreate($lines: [CartLineInput!]!, $country: CountryCode) @inContext(country: $country) {\n cartCreate(input: { lines: $lines, buyerIdentity: { countryCode: $country } }) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_LINES_ADD = `#graphql\n mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!, $country: CountryCode)\n @inContext(country: $country) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_LINES_UPDATE = `#graphql\n mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $country: CountryCode)\n @inContext(country: $country) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_LINES_REMOVE = `#graphql\n mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!, $country: CountryCode)\n @inContext(country: $country) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_BUYER_IDENTITY_UPDATE = `#graphql\n mutation CartBuyerIdentityUpdate($cartId: ID!, $country: CountryCode)\n @inContext(country: $country) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: { countryCode: $country }) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_ID_KEY = 'shopify_cart_id';\n\n/**\n * The cart lives at Shopify; the browser keeps only its id. Each change sends\n * one Storefront API request and shows the cart Shopify sends back.\n */\nclass Cart {\n lines = $state<CartLine[]>([]);\n subtotal = $state<Money | null>(null);\n checkoutUrl = $state<string | null>(null);\n count = $state(0);\n /** Whether the cart sheet is open. */\n open = $state(false);\n /** True while a request is in flight; the cart's controls wait for it. */\n pending = $state(false);\n error = $state<string | null>(null);\n\n #id: string | null = null;\n #loaded = false;\n /** The market the cart is priced in: the one for the visitor's currency, else the store's default. */\n #country: string | null = null;\n\n /** Fetches the saved cart, once, in the browser. */\n async load() {\n if (!browser || this.#loaded) return;\n this.#loaded = true;\n const id = readCartId();\n if (!id) return;\n\n this.pending = true;\n try {\n this.#country = await marketCountry(currency.current);\n const { data, errors } = await storefront().request(CART_QUERY, {\n variables: { id, country: this.#country }\n });\n if (errors) throw new Error(errors.message);\n // A cart that expired or was checked out comes back as null.\n if (data?.cart) this.#show(data.cart);\n else this.clear();\n } catch (error) {\n console.error('Could not load the Shopify cart:', error);\n } finally {\n this.pending = false;\n }\n }\n\n /**\n * Prices the cart in the market for `code`, the currency the visitor now\n * reads prices in, when the store has one. Shopify reprices the lines and\n * the checkout; nothing is estimated.\n */\n async market(code: string) {\n const country = await marketCountry(code);\n if (country === this.#country) return;\n this.#country = country;\n if (this.#id) {\n await this.#mutate(CART_BUYER_IDENTITY_UPDATE, 'cartBuyerIdentityUpdate', {\n cartId: this.#id\n });\n }\n }\n\n async add(merchandiseId: string, quantity = 1, attributes?: { key: string; value: string }[]) {\n await this.load();\n // A new cart starts in the visitor's market; a saved one was loaded in it.\n if (!this.#id) this.#country = await marketCountry(currency.current);\n const lines = [{ merchandiseId, quantity, attributes }];\n if (this.#id) {\n await this.#mutate(CART_LINES_ADD, 'cartLinesAdd', { cartId: this.#id, lines });\n } else {\n await this.#mutate(CART_CREATE, 'cartCreate', { lines });\n }\n }\n\n /** A quantity of 0 removes the line. */\n async setQuantity(lineId: string, quantity: number) {\n if (quantity <= 0) return this.remove(lineId);\n await this.#mutate(CART_LINES_UPDATE, 'cartLinesUpdate', {\n cartId: this.#id,\n lines: [{ id: lineId, quantity }]\n });\n }\n\n async remove(lineId: string) {\n await this.#mutate(CART_LINES_REMOVE, 'cartLinesRemove', {\n cartId: this.#id,\n lineIds: [lineId]\n });\n }\n\n clear() {\n this.#id = null;\n this.lines = [];\n this.subtotal = null;\n this.checkoutUrl = null;\n this.count = 0;\n try {\n localStorage.removeItem(CART_ID_KEY);\n } catch {\n // Blocked storage: nothing was saved either.\n }\n }\n\n async #mutate(operation: string, field: string, variables: Record<string, unknown>) {\n this.pending = true;\n this.error = null;\n try {\n const { data, errors } = await storefront().request(operation, {\n variables: { ...variables, country: this.#country }\n });\n if (errors) throw new Error(errors.message);\n const payload: CartPayload | undefined = data?.[field];\n if (!payload) throw new Error(`No ${field} in the response`);\n if (payload.userErrors.length > 0) this.error = payload.userErrors[0].message;\n if (payload.cart) this.#show(payload.cart);\n } catch (error) {\n console.error('Shopify cart request failed:', error);\n this.error = 'The cart could not be updated. Try again.';\n } finally {\n this.pending = false;\n }\n }\n\n #show(cart: ShopifyCart) {\n this.#id = cart.id;\n this.lines = cart.lines.nodes;\n this.subtotal = cart.cost.subtotalAmount;\n this.checkoutUrl = cart.checkoutUrl;\n this.count = cart.totalQuantity;\n try {\n localStorage.setItem(CART_ID_KEY, cart.id);\n } catch {\n // The cart still works for this visit.\n }\n }\n}\n\nfunction readCartId(): string | null {\n try {\n return localStorage.getItem(CART_ID_KEY);\n } catch {\n return null;\n }\n}\n\nexport const cart = new Cart();\n\n/** Shopify's money, as it priced it, formatted for the page's language in the business's country. */\nexport function formatMoney({ amount, currencyCode }: Money): string {\n return money(Number(amount), currencyCode);\n}\n", Op = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n import { cart } from '#lib/cart.svelte.js';\n\n interface Props {\n /** The product variant: `gid://shopify/ProductVariant/...`. */\n merchandiseId: string;\n quantity?: number;\n /** Line item properties Shopify keeps with the line, such as an engraving. */\n attributes?: { key: string; value: string }[];\n label?: string;\n }\n\n let {\n merchandiseId,\n quantity = 1,\n attributes,\n label = 'Add to cart',\n disabled,\n ...rest\n }: Props & ButtonProps = $props();\n\n let added = $state(false);\n\n async function add() {\n await cart.add(merchandiseId, quantity, attributes);\n if (cart.error) return;\n added = true;\n cart.open = true;\n setTimeout(() => (added = false), 1500);\n }\n<\/script>\n\n<Button onclick={add} disabled={disabled || cart.pending} {...rest}>\n {added ? 'Added' : label}\n</Button>\n", kp = "<script lang=\"ts\">\n import MinusIcon from '@lucide/svelte/icons/minus';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import XIcon from '@lucide/svelte/icons/x';\n import * as Sheet from '#lib/components/ui/sheet/index.js';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import { cart, formatMoney } from '#lib/cart.svelte.js';\n import { currency } from '#lib/currency.svelte.js';\n\n // A cart is priced in the market for the currency the visitor reads prices in.\n $effect(() => {\n void cart.market(currency.current);\n });\n<\/script>\n\n<Sheet.Root bind:open={cart.open}>\n <Sheet.Content side=\"right\" class=\"flex flex-col\">\n <Sheet.Header>\n <Sheet.Title>Cart</Sheet.Title>\n </Sheet.Header>\n\n <div class=\"flex flex-1 flex-col gap-4 overflow-y-auto px-4 pb-4\">\n {#if cart.error}\n <p class=\"text-destructive text-sm\">{cart.error}</p>\n {/if}\n\n {#if cart.lines.length === 0}\n <p class=\"text-muted-foreground text-sm\">Your cart is empty.</p>\n {:else}\n <ul class=\"divide-y\">\n {#each cart.lines as line (line.id)}\n <li class=\"flex items-center gap-3 py-3\">\n {#if line.merchandise.image}\n <img\n src={line.merchandise.image.url}\n alt={line.merchandise.image.altText ?? line.merchandise.product.title}\n class=\"size-12 rounded object-cover\"\n />\n {/if}\n <div class=\"min-w-0 flex-1\">\n <p class=\"truncate text-sm font-medium\">{line.merchandise.product.title}</p>\n {#if line.merchandise.title !== 'Default Title'}\n <p class=\"text-muted-foreground truncate text-xs\">{line.merchandise.title}</p>\n {/if}\n <p class=\"text-muted-foreground text-sm\">\n {formatMoney(line.cost.totalAmount)}\n </p>\n </div>\n <div class=\"flex items-center gap-1\">\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One fewer {line.merchandise.product.title}\"\n disabled={cart.pending}\n onclick={() => cart.setQuantity(line.id, line.quantity - 1)}\n >\n <MinusIcon />\n </Button>\n <span class=\"w-6 text-center text-sm tabular-nums\">{line.quantity}</span>\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One more {line.merchandise.product.title}\"\n disabled={cart.pending}\n onclick={() => cart.setQuantity(line.id, line.quantity + 1)}\n >\n <PlusIcon />\n </Button>\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"Remove {line.merchandise.product.title}\"\n disabled={cart.pending}\n onclick={() => cart.remove(line.id)}\n >\n <XIcon />\n </Button>\n </li>\n {/each}\n </ul>\n\n <Separator />\n\n {#if cart.subtotal}\n <div class=\"flex justify-between text-sm font-medium\">\n <span>Subtotal</span>\n <span>{formatMoney(cart.subtotal)}</span>\n </div>\n {/if}\n\n <!-- Shopify's checkout takes it from here. -->\n <Button href={cart.checkoutUrl ?? undefined} class=\"w-full\" disabled={cart.pending}>\n Check out\n </Button>\n {/if}\n </div>\n </Sheet.Content>\n</Sheet.Root>\n", Ap = "import { browser } from '$app/env';\nimport { currency, money } from '#lib/currency.svelte.js';\n\nexport interface CartItem {\n /** The Stripe price (`price_...`). */\n price: string;\n name: string;\n /** Stripe's `unit_amount`: the price in the currency's smallest unit. */\n unitAmount: number;\n currency: string;\n /**\n * Fixed amounts in other currencies, from the price's `currency_options` in\n * the dashboard, by upper-cased code: `{ EUR: 1800 }`. A visitor reading\n * prices in one of them sees and pays that amount, not an estimate.\n */\n options?: Record<string, number>;\n quantity: number;\n}\n\nconst STORAGE_KEY = 'cart';\n\n/**\n * The cart is a list of Stripe prices kept in the browser. Stripe sees it only\n * at checkout, where it prices the session itself, so what is stored here is\n * for display and nothing in it can change what is charged.\n */\nclass Cart {\n items = $state<CartItem[]>([]);\n /** Whether the cart sheet is open. */\n open = $state(false);\n count = $derived(this.items.reduce((total, item) => total + item.quantity, 0));\n subtotal = $derived(\n this.items.reduce((total, item) => total + item.unitAmount * item.quantity, 0)\n );\n /** The cart's currency: Stripe refuses a mixed cart, so the first item's. `null` while empty. */\n currency = $derived<string | null>(this.items[0]?.currency ?? null);\n /** Fixed subtotals in the currencies every item has a dashboard amount in. */\n options = $derived.by<Record<string, number>>(() => {\n const [first, ...rest] = this.items;\n if (!first?.options) return {};\n const totals: Record<string, number> = {};\n for (const code of Object.keys(first.options)) {\n if (rest.every((item) => item.options?.[code] !== undefined)) {\n totals[code] = this.items.reduce(\n (total, item) => total + item.options![code] * item.quantity,\n 0\n );\n }\n }\n return totals;\n });\n\n #loaded = false;\n\n /** Reads the saved cart, once, in the browser. */\n load() {\n if (!browser || this.#loaded) return;\n this.#loaded = true;\n try {\n const saved = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '[]');\n if (Array.isArray(saved)) this.items = saved;\n } catch {\n // Unreadable or blocked storage starts an empty cart.\n }\n }\n\n add(item: Omit<CartItem, 'quantity'>, quantity = 1) {\n this.load();\n const line = this.items.find((line) => line.price === item.price);\n if (line) line.quantity += quantity;\n else this.items.push({ ...item, quantity });\n this.#save();\n }\n\n /** A quantity of 0 removes the item. */\n setQuantity(price: string, quantity: number) {\n if (quantity <= 0) return this.remove(price);\n const line = this.items.find((line) => line.price === price);\n if (!line) return;\n line.quantity = quantity;\n this.#save();\n }\n\n remove(price: string) {\n this.items = this.items.filter((line) => line.price !== price);\n this.#save();\n }\n\n clear() {\n this.items = [];\n this.#save();\n }\n\n #save() {\n try {\n localStorage.setItem(STORAGE_KEY, JSON.stringify($state.snapshot(this.items)));\n } catch {\n // Storage can be full or blocked; the cart still works for this visit.\n }\n }\n}\n\nexport const cart = new Cart();\n\n/** Stripe amounts are in the currency's smallest unit; Intl knows how many digits that is (none for JPY). */\nfunction major(amount: number, code: string): number {\n const digits =\n new Intl.NumberFormat('en', { style: 'currency', currency: code }).resolvedOptions()\n .maximumFractionDigits ?? 2;\n return amount / 10 ** digits;\n}\n\n/**\n * Formats a Stripe amount the way the visitor reads prices: the fixed amount\n * in the currency they picked when the dashboard set one (`options`), else\n * the price's own, converted and marked as an estimate when they picked another.\n */\nexport function formatAmount(amount: number, code: string, options?: Record<string, number>): string {\n const fixed = options?.[currency.current];\n if (fixed !== undefined && currency.current !== code) {\n return money(major(fixed, currency.current), currency.current);\n }\n return currency.format(major(amount, code), code);\n}\n\n/**\n * A synced price's `currency_options` as the cart keeps them: upper-cased\n * code to `unit_amount`, leaving out options priced another way (tiers, a\n * customer-chosen amount).\n */\nexport function priceOptions(raw: unknown): Record<string, number> | undefined {\n if (!raw || typeof raw !== 'object') return undefined;\n const options: Record<string, number> = {};\n for (const [code, option] of Object.entries(raw as Record<string, { unit_amount?: unknown }>)) {\n if (typeof option?.unit_amount === 'number') options[code.toUpperCase()] = option.unit_amount;\n }\n return Object.keys(options).length > 0 ? options : undefined;\n}\n", jp = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n import { cart, type CartItem } from '#lib/cart.svelte.js';\n\n interface Props {\n /** The Stripe price, as the page selling it loaded it. */\n price: Omit<CartItem, 'quantity'>;\n quantity?: number;\n label?: string;\n }\n\n let { price, quantity = 1, label = 'Add to cart', ...rest }: Props & ButtonProps = $props();\n\n let added = $state(false);\n\n function add() {\n cart.add(price, quantity);\n added = true;\n cart.open = true;\n setTimeout(() => (added = false), 1500);\n }\n<\/script>\n\n<Button onclick={add} {...rest}>\n {added ? 'Added' : label}\n</Button>\n", Mp = "<script lang=\"ts\">\n import MinusIcon from '@lucide/svelte/icons/minus';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import XIcon from '@lucide/svelte/icons/x';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import { cart, formatAmount } from '#lib/cart.svelte.js';\n\n let { class: className = '' }: { class?: string } = $props();\n\n // What the checkout action reads: the prices and quantities, nothing the\n // browser could misstate.\n const items = $derived(\n JSON.stringify(cart.items.map(({ price, quantity }) => ({ price, quantity })))\n );\n<\/script>\n\n<div class=\"flex flex-col gap-4 {className}\">\n {#if cart.items.length === 0}\n <p class=\"text-muted-foreground text-sm\">Your cart is empty.</p>\n {:else}\n <ul class=\"divide-y\">\n {#each cart.items as item (item.price)}\n <li class=\"flex items-center gap-3 py-3\">\n <div class=\"min-w-0 flex-1\">\n <p class=\"truncate text-sm font-medium\">{item.name}</p>\n <p class=\"text-muted-foreground text-sm\">\n {formatAmount(item.unitAmount, item.currency, item.options)}\n </p>\n </div>\n <div class=\"flex items-center gap-1\">\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One fewer {item.name}\"\n onclick={() => cart.setQuantity(item.price, item.quantity - 1)}\n >\n <MinusIcon />\n </Button>\n <span class=\"w-6 text-center text-sm tabular-nums\">{item.quantity}</span>\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One more {item.name}\"\n onclick={() => cart.setQuantity(item.price, item.quantity + 1)}\n >\n <PlusIcon />\n </Button>\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"Remove {item.name}\"\n onclick={() => cart.remove(item.price)}\n >\n <XIcon />\n </Button>\n </li>\n {/each}\n </ul>\n\n <Separator />\n\n {#if cart.currency}\n <div class=\"flex justify-between text-sm font-medium\">\n <span>Subtotal</span>\n <span>{formatAmount(cart.subtotal, cart.currency, cart.options)}</span>\n </div>\n {/if}\n\n <!-- A plain form post: checkout works before the page has hydrated. -->\n <form method=\"POST\" action=\"/cart?/checkout\">\n <input type=\"hidden\" name=\"items\" value={items} />\n <Button type=\"submit\" class=\"w-full\">Check out</Button>\n </form>\n {/if}\n</div>\n", Np = "<script lang=\"ts\">\n import * as Sheet from '#lib/components/ui/sheet/index.js';\n import CartItems from './cart-items.svelte';\n import { cart } from '#lib/cart.svelte.js';\n<\/script>\n\n<Sheet.Root bind:open={cart.open}>\n <Sheet.Content side=\"right\" class=\"flex flex-col\">\n <Sheet.Header>\n <Sheet.Title>Cart</Sheet.Title>\n </Sheet.Header>\n <CartItems class=\"flex-1 overflow-y-auto px-4 pb-4\" />\n </Sheet.Content>\n</Sheet.Root>\n", Pp = "import { fail, redirect } from '@sveltejs/kit';\nimport Stripe from 'stripe';\nimport stripe from '#lib/stripe.js';\nimport { priceOptions } from '#lib/cart.svelte.js';\n\n/** What the cart posts: prices and quantities. Stripe supplies everything else. */\nfunction readItems(raw: FormDataEntryValue | null): { price: string; quantity: number }[] | null {\n try {\n const items: unknown = JSON.parse(typeof raw === 'string' ? raw : '');\n if (!Array.isArray(items) || items.length === 0 || items.length > 100) return null;\n const valid = items.every(\n (item) =>\n typeof item?.price === 'string' &&\n Number.isInteger(item?.quantity) &&\n item.quantity >= 1 &&\n item.quantity <= 99\n );\n return valid ? items : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The currency to charge in: the one the visitor read prices in, when every\n * price has a fixed amount in it (`currency_options`, set in the dashboard);\n * else the prices' own, and nothing is converted at checkout.\n */\nasync function chargeCurrency(\n locals: App.Locals,\n items: { price: string }[]\n): Promise<string | undefined> {\n const wanted = locals.currency?.toLowerCase();\n if (!wanted) return undefined;\n const prices = await Promise.all(\n items.map((item) =>\n locals.admin\n .collection('stripe_prices')\n .getOne<{ currency?: string; currency_options?: unknown }>(item.price)\n .catch(() => null)\n )\n );\n const priced = prices.every(\n (price) =>\n price &&\n (price.currency === wanted ||\n priceOptions(price.currency_options)?.[wanted.toUpperCase()] !== undefined)\n );\n // Prices already in that currency are charged in it without being told.\n const needed = prices.some((price) => price && price.currency !== wanted);\n return priced && needed ? wanted : undefined;\n}\n\nexport const actions = {\n checkout: async ({ request, url, locals }) => {\n const items = readItems((await request.formData()).get('items'));\n if (!items) return fail(400, { message: 'Your cart could not be read.' });\n\n const currency = await chargeCurrency(locals, items);\n\n let session: Stripe.Checkout.Session;\n try {\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\n currency,\n line_items: items,\n allow_promotion_codes: true,\n success_url: `${url.origin}/checkout/success?session_id={CHECKOUT_SESSION_ID}`,\n cancel_url: `${url.origin}/cart`\n });\n } catch (error) {\n // An inactive or recurring price, or mixed currencies: Stripe says which.\n if (error instanceof Stripe.errors.StripeError) {\n return fail(400, { message: error.message });\n }\n throw error;\n }\n\n // SvelteKit 3 redirects off-site only when told to.\n redirect(303, session.url!, { external: true });\n }\n};\n", Fp = "<script lang=\"ts\">\n import CartItems from '#lib/components/cart/cart-items.svelte';\n\n let { form } = $props();\n<\/script>\n\n<section data-role=\"content\" class=\"max-w-xl\">\n <h1 class=\"mb-6 text-2xl font-semibold\">Cart</h1>\n {#if form?.message}\n <p class=\"text-destructive mb-4 text-sm\">{form.message}</p>\n {/if}\n <CartItems />\n</section>\n", Ip = "import { describe, it, expect, beforeAll, type TestContext } from 'vitest';\nimport * as devalue from 'devalue';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\nimport stripe from '#lib/stripe.js';\nimport type Stripe from 'stripe';\n\ndescribe('POST /cart?/checkout', () => {\n let price: Stripe.Price;\n let inactivePrice: Stripe.Price;\n\n beforeAll(async () => {\n const name = 'Test Product - Cart';\n const found = await stripe.products.search({\n query: `name:\"${name}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1\n });\n const product =\n found.data[0] ?? (await stripe.products.create({ name, metadata: { test: 'true' } }));\n\n const prices = async (active: boolean) =>\n (await stripe.prices.list({ product: product.id, active, limit: 1 })).data[0];\n price =\n (await prices(true)) ??\n (await stripe.prices.create({ product: product.id, unit_amount: 1500, currency: 'usd' }));\n inactivePrice =\n (await prices(false)) ??\n (await stripe.prices.create({\n product: product.id,\n unit_amount: 2500,\n currency: 'usd',\n active: false\n }));\n });\n\n const checkout = (context: TestContext, items: unknown) =>\n context.request\n .post(`${'/cart' satisfies Match<RouteId>}?/checkout`)\n .type('form')\n .send({ items: typeof items === 'string' ? items : JSON.stringify(items) });\n\n it('redirects to a Stripe Checkout Session', async (context) => {\n const response = await checkout(context, [{ price: price.id, quantity: 2 }]);\n expect(response.body.status).toBe(303);\n expect(response.body.location).toMatch(/^https:\\/\\/checkout\\.stripe\\.com\\//);\n });\n\n it('refuses a cart it cannot read', async (context) => {\n for (const items of ['not json', [], [{ price: price.id }], [{ quantity: 1 }]]) {\n const response = await checkout(context, items);\n expect(response.body.status).toBe(400);\n }\n });\n\n it('refuses quantities outside 1 to 99', async (context) => {\n for (const quantity of [0, 100, 1.5]) {\n const response = await checkout(context, [{ price: price.id, quantity }]);\n expect(response.body.status).toBe(400);\n }\n });\n\n it(\"passes on Stripe's reason for a price it won't sell\", async (context) => {\n const response = await checkout(context, [{ price: inactivePrice.id, quantity: 1 }]);\n expect(response.body.status).toBe(400);\n expect(devalue.parse(response.body.data).message).toMatch(/inactive|not active/i);\n });\n});\n", Lp = "import { browser } from '$app/env';\nimport { orderSubtotal, type OrderLine } from '@velastack/whatsapp';\nimport { site } from '#lib/site.js';\n\nexport interface CartItem extends OrderLine {\n /** Your own id for the item (a slug or SKU); lines with the same id merge. */\n id: string;\n}\n\n/** An order sent to WhatsApp, kept until the customer says they're done. */\nexport interface PlacedOrder {\n ref: string;\n /** The chat link, to open it again. */\n href: string;\n}\n\nconst STORAGE_KEY = 'cart';\n\n/**\n * The cart is a list of items kept in the browser. Checkout turns it into a\n * WhatsApp message to the business, where the order is confirmed and paid,\n * so what is stored here is what the customer asked for, not what they pay.\n */\nclass Cart {\n items = $state<CartItem[]>([]);\n /** Whether the cart sheet is open. */\n open = $state(false);\n placed = $state<PlacedOrder | null>(null);\n count = $derived(this.items.reduce((total, item) => total + item.quantity, 0));\n /** In `site.currency`, only when every item has a price; otherwise the business quotes. */\n subtotal = $derived(orderSubtotal(this.items, site.currency));\n\n #loaded = false;\n\n /** Reads the saved cart, once, in the browser. */\n load() {\n if (!browser || this.#loaded) return;\n this.#loaded = true;\n try {\n const saved = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}');\n if (Array.isArray(saved?.items)) this.items = saved.items;\n if (saved?.placed) this.placed = saved.placed;\n } catch {\n // Unreadable or blocked storage starts an empty cart.\n }\n }\n\n add(item: Omit<CartItem, 'quantity'>, quantity = 1) {\n this.load();\n // Adding after an order was sent starts the next one.\n if (this.placed) this.clear();\n const line = this.items.find((line) => line.id === item.id);\n if (line) line.quantity += quantity;\n else this.items.push({ ...item, quantity });\n this.#save();\n }\n\n /** A quantity of 0 removes the item. */\n setQuantity(id: string, quantity: number) {\n if (quantity <= 0) return this.remove(id);\n const line = this.items.find((line) => line.id === id);\n if (!line) return;\n line.quantity = quantity;\n this.#save();\n }\n\n remove(id: string) {\n this.items = this.items.filter((line) => line.id !== id);\n this.#save();\n }\n\n /** Records that the order went to WhatsApp; the sheet shows it until `clear()`. */\n place(order: PlacedOrder) {\n this.placed = order;\n this.#save();\n }\n\n clear() {\n this.items = [];\n this.placed = null;\n this.#save();\n }\n\n #save() {\n try {\n localStorage.setItem(\n STORAGE_KEY,\n JSON.stringify({ items: $state.snapshot(this.items), placed: this.placed })\n );\n } catch {\n // Storage can be full or blocked; the cart still works for this visit.\n }\n }\n}\n\nexport const cart = new Cart();\n", Rp = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n import { cart } from '#lib/cart.svelte.js';\n\n interface Props {\n /** Your own id for the item (a slug or SKU); adding it again raises the quantity. */\n id: string;\n /** What the business will read in the order. */\n name: string;\n /** The unit price in `site.currency`, written as you would (`4.5`). Leave it out to quote in the chat. */\n price?: number;\n quantity?: number;\n label?: string;\n }\n\n let {\n id,\n name,\n price,\n quantity = 1,\n label = 'Add to cart',\n ...rest\n }: Props & ButtonProps = $props();\n\n let added = $state(false);\n\n function add() {\n cart.add({ id, name, price }, quantity);\n added = true;\n cart.open = true;\n setTimeout(() => (added = false), 1500);\n }\n<\/script>\n\n<Button onclick={add} {...rest}>\n {added ? 'Added' : label}\n</Button>\n", zp = "<script lang=\"ts\">\n import MinusIcon from '@lucide/svelte/icons/minus';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import XIcon from '@lucide/svelte/icons/x';\n import { toast } from 'svelte-sonner';\n import { formToken, lineTotal, orderRef } from '@velastack/whatsapp';\n import { Button, buttonVariants } from '#lib/components/ui/button/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import * as Sheet from '#lib/components/ui/sheet/index.js';\n import CustomerFields from '#lib/components/payments/customer-fields.svelte';\n import { cart } from '#lib/cart.svelte.js';\n import { formatPrice } from '#lib/currency.svelte.js';\n import { ORDER_FORM, placeOrder } from '#lib/order.js';\n import { site } from '#lib/site.js';\n\n // Fetched once, the first time the cart opens: the hosted form refuses a\n // token younger than two seconds, and filling the form in takes longer.\n let token: string | null = null;\n\n $effect(() => {\n if (!cart.open || !ORDER_FORM || token) return;\n formToken(ORDER_FORM).then((value) => (token = value));\n });\n\n function checkout(event: SubmitEvent) {\n event.preventDefault();\n const data = new FormData(event.currentTarget as HTMLFormElement);\n const order = {\n ref: orderRef(),\n name: String(data.get('name') ?? ''),\n phone: String(data.get('phone') ?? ''),\n note: String(data.get('note') ?? '') || undefined,\n currency: site.currency,\n lines: cart.items.map(({ name, quantity, price }) => ({ name, quantity, price })),\n subtotal: cart.subtotal\n };\n const href = placeOrder(order, { token, gotcha: String(data.get('_gotcha') ?? '') });\n if (!href) {\n toast.error('WhatsApp ordering is not set up yet');\n return;\n }\n cart.place({ ref: order.ref, href });\n }\n\n function done() {\n cart.clear();\n cart.open = false;\n }\n<\/script>\n\n<Sheet.Root bind:open={cart.open}>\n <Sheet.Content side=\"right\" class=\"flex flex-col\">\n <Sheet.Header>\n <Sheet.Title>Cart</Sheet.Title>\n </Sheet.Header>\n <div class=\"flex flex-1 flex-col gap-4 overflow-y-auto px-4 pb-4\">\n {#if cart.placed}\n <div class=\"flex flex-col gap-2\">\n <p class=\"font-medium\">Order {cart.placed.ref} opened in WhatsApp</p>\n <p class=\"text-muted-foreground text-sm\">\n Send the message in WhatsApp to place your order. We'll reply there.\n </p>\n </div>\n <a\n href={cart.placed.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class={buttonVariants({ variant: 'outline' })}\n >\n Open WhatsApp again\n </a>\n <Button onclick={done}>Done</Button>\n {:else if cart.items.length === 0}\n <p class=\"text-muted-foreground text-sm\">Your cart is empty.</p>\n {:else}\n <ul class=\"divide-y\">\n {#each cart.items as item (item.id)}\n {@const total = lineTotal(item, site.currency)}\n <li class=\"flex items-center gap-3 py-3\">\n <div class=\"min-w-0 flex-1\">\n <p class=\"truncate text-sm font-medium\">{item.name}</p>\n {#if total !== undefined}\n <p class=\"text-muted-foreground text-sm\">{formatPrice(total)}</p>\n {/if}\n </div>\n <div class=\"flex items-center gap-1\">\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One fewer {item.name}\"\n onclick={() => cart.setQuantity(item.id, item.quantity - 1)}\n >\n <MinusIcon />\n </Button>\n <span class=\"w-6 text-center text-sm tabular-nums\">{item.quantity}</span>\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One more {item.name}\"\n onclick={() => cart.setQuantity(item.id, item.quantity + 1)}\n >\n <PlusIcon />\n </Button>\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"Remove {item.name}\"\n onclick={() => cart.remove(item.id)}\n >\n <XIcon />\n </Button>\n </li>\n {/each}\n </ul>\n\n <Separator />\n\n {#if cart.subtotal !== undefined}\n <div class=\"flex justify-between text-sm font-medium\">\n <span>Subtotal</span>\n <span>{formatPrice(cart.subtotal)}</span>\n </div>\n {:else}\n <p class=\"text-muted-foreground text-sm\">We'll confirm the total in WhatsApp.</p>\n {/if}\n\n <form class=\"flex flex-col gap-4\" onsubmit={checkout}>\n <CustomerFields />\n <Button type=\"submit\" class=\"w-full\">Order on WhatsApp</Button>\n </form>\n {/if}\n </div>\n </Sheet.Content>\n</Sheet.Root>\n", Bp = "import { fail, redirect } from '@sveltejs/kit';\nimport Stripe from 'stripe';\nimport stripe from '#lib/stripe.js';\nimport { priceOptions } from '#lib/cart.svelte.js';\nimport { getStripeCustomerId } from '#lib/server/stripe-customer.js';\n\n/** What the cart posts: prices and quantities. Stripe supplies everything else. */\nfunction readItems(raw: FormDataEntryValue | null): { price: string; quantity: number }[] | null {\n try {\n const items: unknown = JSON.parse(typeof raw === 'string' ? raw : '');\n if (!Array.isArray(items) || items.length === 0 || items.length > 100) return null;\n const valid = items.every(\n (item) =>\n typeof item?.price === 'string' &&\n Number.isInteger(item?.quantity) &&\n item.quantity >= 1 &&\n item.quantity <= 99\n );\n return valid ? items : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The currency to charge in: the one the visitor read prices in, when every\n * price has a fixed amount in it (`currency_options`, set in the dashboard);\n * else the prices' own, and nothing is converted at checkout.\n */\nasync function chargeCurrency(\n locals: App.Locals,\n items: { price: string }[]\n): Promise<string | undefined> {\n const wanted = locals.currency?.toLowerCase();\n if (!wanted) return undefined;\n const prices = await Promise.all(\n items.map((item) =>\n locals.admin\n .collection('stripe_prices')\n .getOne<{ currency?: string; currency_options?: unknown }>(item.price)\n .catch(() => null)\n )\n );\n const priced = prices.every(\n (price) =>\n price &&\n (price.currency === wanted ||\n priceOptions(price.currency_options)?.[wanted.toUpperCase()] !== undefined)\n );\n // Prices already in that currency are charged in it without being told.\n const needed = prices.some((price) => price && price.currency !== wanted);\n return priced && needed ? wanted : undefined;\n}\n\nexport const actions = {\n checkout: async ({ request, url, locals }) => {\n const items = readItems((await request.formData()).get('items'));\n if (!items) return fail(400, { message: 'Your cart could not be read.' });\n\n // A signed-in buyer checks out as their Stripe customer, so their saved\n // cards are offered and the payment shows up on their billing page. If\n // the customer isn't linked yet, they check out as a guest.\n const user = locals.pb.authStore.record;\n const customer = user\n ? await getStripeCustomerId(locals.admin, user).catch(() => undefined)\n : undefined;\n\n const currency = await chargeCurrency(locals, items);\n\n let session: Stripe.Checkout.Session;\n try {\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\n currency,\n customer,\n line_items: items,\n allow_promotion_codes: true,\n success_url: `${url.origin}/checkout/success?session_id={CHECKOUT_SESSION_ID}`,\n cancel_url: `${url.origin}/cart`\n });\n } catch (error) {\n // An inactive or recurring price, or mixed currencies: Stripe says which.\n if (error instanceof Stripe.errors.StripeError) {\n return fail(400, { message: error.message });\n }\n throw error;\n }\n\n // SvelteKit 3 redirects off-site only when told to.\n redirect(303, session.url!, { external: true });\n }\n};\n", Vp = [
|
|
6224
|
+
generate: Tp
|
|
6225
|
+
}, Dp = "<script lang=\"ts\">\n import { onMount } from 'svelte';\n import ShoppingCartIcon from '@lucide/svelte/icons/shopping-cart';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import { Button } from '#lib/components/ui/button/index.js';\n import { cart } from '#lib/cart.svelte.js';\n import CartSheet from './cart-sheet.svelte';\n\n // The cart lives in the browser, so the server renders it empty and it\n // fills in here.\n onMount(() => cart.load());\n<\/script>\n\n<Button\n variant=\"ghost\"\n size=\"icon\"\n class=\"relative\"\n aria-label=\"Cart, {cart.count} items\"\n onclick={() => (cart.open = true)}\n>\n <ShoppingCartIcon />\n {#if cart.count > 0}\n <Badge class=\"absolute -top-1 -right-1 h-5 min-w-5 rounded-full px-1 tabular-nums\">\n {cart.count}\n </Badge>\n {/if}\n</Button>\n\n<CartSheet />\n", Op = "import { browser } from '$app/env';\nimport { currency, money } from '#lib/currency.svelte.js';\nimport { marketCountry, storefront } from '#lib/shopify.js';\n\nexport interface Money {\n amount: string;\n currencyCode: string;\n}\n\nexport interface CartLine {\n id: string;\n quantity: number;\n attributes: { key: string; value: string }[];\n cost: { totalAmount: Money };\n merchandise: {\n id: string;\n title: string;\n image: { url: string; altText: string | null } | null;\n price: Money;\n product: { title: string; handle: string };\n };\n}\n\ninterface ShopifyCart {\n id: string;\n checkoutUrl: string;\n totalQuantity: number;\n cost: { subtotalAmount: Money };\n lines: { nodes: CartLine[] };\n}\n\ninterface CartPayload {\n cart: ShopifyCart | null;\n userErrors: { message: string }[];\n}\n\nconst CART_FRAGMENT = `#graphql\n fragment CartFields on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n attributes {\n key\n value\n }\n cost {\n totalAmount {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n image {\n url\n altText\n }\n price {\n amount\n currencyCode\n }\n product {\n title\n handle\n }\n }\n }\n }\n }\n }\n`;\n\nconst CART_QUERY = `#graphql\n query Cart($id: ID!, $country: CountryCode) @inContext(country: $country) {\n cart(id: $id) {\n ...CartFields\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_CREATE = `#graphql\n mutation CartCreate($lines: [CartLineInput!]!, $country: CountryCode) @inContext(country: $country) {\n cartCreate(input: { lines: $lines, buyerIdentity: { countryCode: $country } }) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_LINES_ADD = `#graphql\n mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!, $country: CountryCode)\n @inContext(country: $country) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_LINES_UPDATE = `#graphql\n mutation CartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $country: CountryCode)\n @inContext(country: $country) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_LINES_REMOVE = `#graphql\n mutation CartLinesRemove($cartId: ID!, $lineIds: [ID!]!, $country: CountryCode)\n @inContext(country: $country) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_BUYER_IDENTITY_UPDATE = `#graphql\n mutation CartBuyerIdentityUpdate($cartId: ID!, $country: CountryCode)\n @inContext(country: $country) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: { countryCode: $country }) {\n cart {\n ...CartFields\n }\n userErrors {\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_ID_KEY = 'shopify_cart_id';\n\n/**\n * The cart lives at Shopify; the browser keeps only its id. Each change sends\n * one Storefront API request and shows the cart Shopify sends back.\n */\nclass Cart {\n lines = $state<CartLine[]>([]);\n subtotal = $state<Money | null>(null);\n checkoutUrl = $state<string | null>(null);\n count = $state(0);\n /** Whether the cart sheet is open. */\n open = $state(false);\n /** True while a request is in flight; the cart's controls wait for it. */\n pending = $state(false);\n error = $state<string | null>(null);\n\n #id: string | null = null;\n #loaded = false;\n /** The market the cart is priced in: the one for the visitor's currency, else the store's default. */\n #country: string | null = null;\n\n /** Fetches the saved cart, once, in the browser. */\n async load() {\n if (!browser || this.#loaded) return;\n this.#loaded = true;\n const id = readCartId();\n if (!id) return;\n\n this.pending = true;\n try {\n this.#country = await marketCountry(currency.current);\n const { data, errors } = await storefront().request(CART_QUERY, {\n variables: { id, country: this.#country }\n });\n if (errors) throw new Error(errors.message);\n // A cart that expired or was checked out comes back as null.\n if (data?.cart) this.#show(data.cart);\n else this.clear();\n } catch (error) {\n console.error('Could not load the Shopify cart:', error);\n } finally {\n this.pending = false;\n }\n }\n\n /**\n * Prices the cart in the market for `code`, the currency the visitor now\n * reads prices in, when the store has one. Shopify reprices the lines and\n * the checkout; nothing is estimated.\n */\n async market(code: string) {\n const country = await marketCountry(code);\n if (country === this.#country) return;\n this.#country = country;\n if (this.#id) {\n await this.#mutate(CART_BUYER_IDENTITY_UPDATE, 'cartBuyerIdentityUpdate', {\n cartId: this.#id\n });\n }\n }\n\n async add(merchandiseId: string, quantity = 1, attributes?: { key: string; value: string }[]) {\n await this.load();\n // A new cart starts in the visitor's market; a saved one was loaded in it.\n if (!this.#id) this.#country = await marketCountry(currency.current);\n const lines = [{ merchandiseId, quantity, attributes }];\n if (this.#id) {\n await this.#mutate(CART_LINES_ADD, 'cartLinesAdd', { cartId: this.#id, lines });\n } else {\n await this.#mutate(CART_CREATE, 'cartCreate', { lines });\n }\n }\n\n /** A quantity of 0 removes the line. */\n async setQuantity(lineId: string, quantity: number) {\n if (quantity <= 0) return this.remove(lineId);\n await this.#mutate(CART_LINES_UPDATE, 'cartLinesUpdate', {\n cartId: this.#id,\n lines: [{ id: lineId, quantity }]\n });\n }\n\n async remove(lineId: string) {\n await this.#mutate(CART_LINES_REMOVE, 'cartLinesRemove', {\n cartId: this.#id,\n lineIds: [lineId]\n });\n }\n\n clear() {\n this.#id = null;\n this.lines = [];\n this.subtotal = null;\n this.checkoutUrl = null;\n this.count = 0;\n try {\n localStorage.removeItem(CART_ID_KEY);\n } catch {\n // Blocked storage: nothing was saved either.\n }\n }\n\n async #mutate(operation: string, field: string, variables: Record<string, unknown>) {\n this.pending = true;\n this.error = null;\n try {\n const { data, errors } = await storefront().request(operation, {\n variables: { ...variables, country: this.#country }\n });\n if (errors) throw new Error(errors.message);\n const payload: CartPayload | undefined = data?.[field];\n if (!payload) throw new Error(`No ${field} in the response`);\n if (payload.userErrors.length > 0) this.error = payload.userErrors[0].message;\n if (payload.cart) this.#show(payload.cart);\n } catch (error) {\n console.error('Shopify cart request failed:', error);\n this.error = 'The cart could not be updated. Try again.';\n } finally {\n this.pending = false;\n }\n }\n\n #show(cart: ShopifyCart) {\n this.#id = cart.id;\n this.lines = cart.lines.nodes;\n this.subtotal = cart.cost.subtotalAmount;\n this.checkoutUrl = cart.checkoutUrl;\n this.count = cart.totalQuantity;\n try {\n localStorage.setItem(CART_ID_KEY, cart.id);\n } catch {\n // The cart still works for this visit.\n }\n }\n}\n\nfunction readCartId(): string | null {\n try {\n return localStorage.getItem(CART_ID_KEY);\n } catch {\n return null;\n }\n}\n\nexport const cart = new Cart();\n\n/** Shopify's money, as it priced it, formatted for the page's language in the business's country. */\nexport function formatMoney({ amount, currencyCode }: Money): string {\n return money(Number(amount), currencyCode);\n}\n", kp = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n import { cart } from '#lib/cart.svelte.js';\n\n interface Props {\n /** The product variant: `gid://shopify/ProductVariant/...`. */\n merchandiseId: string;\n quantity?: number;\n /** Line item properties Shopify keeps with the line, such as an engraving. */\n attributes?: { key: string; value: string }[];\n label?: string;\n }\n\n let {\n merchandiseId,\n quantity = 1,\n attributes,\n label = 'Add to cart',\n disabled,\n ...rest\n }: Props & ButtonProps = $props();\n\n let added = $state(false);\n\n async function add() {\n await cart.add(merchandiseId, quantity, attributes);\n if (cart.error) return;\n added = true;\n cart.open = true;\n setTimeout(() => (added = false), 1500);\n }\n<\/script>\n\n<Button onclick={add} disabled={disabled || cart.pending} {...rest}>\n {added ? 'Added' : label}\n</Button>\n", Ap = "<script lang=\"ts\">\n import MinusIcon from '@lucide/svelte/icons/minus';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import XIcon from '@lucide/svelte/icons/x';\n import * as Sheet from '#lib/components/ui/sheet/index.js';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import { cart, formatMoney } from '#lib/cart.svelte.js';\n import { currency } from '#lib/currency.svelte.js';\n\n // A cart is priced in the market for the currency the visitor reads prices in.\n $effect(() => {\n void cart.market(currency.current);\n });\n<\/script>\n\n<Sheet.Root bind:open={cart.open}>\n <Sheet.Content side=\"right\" class=\"flex flex-col\">\n <Sheet.Header>\n <Sheet.Title>Cart</Sheet.Title>\n </Sheet.Header>\n\n <div class=\"flex flex-1 flex-col gap-4 overflow-y-auto px-4 pb-4\">\n {#if cart.error}\n <p class=\"text-destructive text-sm\">{cart.error}</p>\n {/if}\n\n {#if cart.lines.length === 0}\n <p class=\"text-muted-foreground text-sm\">Your cart is empty.</p>\n {:else}\n <ul class=\"divide-y\">\n {#each cart.lines as line (line.id)}\n <li class=\"flex items-center gap-3 py-3\">\n {#if line.merchandise.image}\n <img\n src={line.merchandise.image.url}\n alt={line.merchandise.image.altText ?? line.merchandise.product.title}\n class=\"size-12 rounded object-cover\"\n />\n {/if}\n <div class=\"min-w-0 flex-1\">\n <p class=\"truncate text-sm font-medium\">{line.merchandise.product.title}</p>\n {#if line.merchandise.title !== 'Default Title'}\n <p class=\"text-muted-foreground truncate text-xs\">{line.merchandise.title}</p>\n {/if}\n <p class=\"text-muted-foreground text-sm\">\n {formatMoney(line.cost.totalAmount)}\n </p>\n </div>\n <div class=\"flex items-center gap-1\">\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One fewer {line.merchandise.product.title}\"\n disabled={cart.pending}\n onclick={() => cart.setQuantity(line.id, line.quantity - 1)}\n >\n <MinusIcon />\n </Button>\n <span class=\"w-6 text-center text-sm tabular-nums\">{line.quantity}</span>\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One more {line.merchandise.product.title}\"\n disabled={cart.pending}\n onclick={() => cart.setQuantity(line.id, line.quantity + 1)}\n >\n <PlusIcon />\n </Button>\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"Remove {line.merchandise.product.title}\"\n disabled={cart.pending}\n onclick={() => cart.remove(line.id)}\n >\n <XIcon />\n </Button>\n </li>\n {/each}\n </ul>\n\n <Separator />\n\n {#if cart.subtotal}\n <div class=\"flex justify-between text-sm font-medium\">\n <span>Subtotal</span>\n <span>{formatMoney(cart.subtotal)}</span>\n </div>\n {/if}\n\n <!-- Shopify's checkout takes it from here. -->\n <Button href={cart.checkoutUrl ?? undefined} class=\"w-full\" disabled={cart.pending}>\n Check out\n </Button>\n {/if}\n </div>\n </Sheet.Content>\n</Sheet.Root>\n", jp = "import { browser } from '$app/env';\nimport { currency, money } from '#lib/currency.svelte.js';\n\nexport interface CartItem {\n /** The Stripe price (`price_...`). */\n price: string;\n name: string;\n /** Stripe's `unit_amount`: the price in the currency's smallest unit. */\n unitAmount: number;\n currency: string;\n /**\n * Fixed amounts in other currencies, from the price's `currency_options` in\n * the dashboard, by upper-cased code: `{ EUR: 1800 }`. A visitor reading\n * prices in one of them sees and pays that amount, not an estimate.\n */\n options?: Record<string, number>;\n quantity: number;\n}\n\nconst STORAGE_KEY = 'cart';\n\n/**\n * The cart is a list of Stripe prices kept in the browser. Stripe sees it only\n * at checkout, where it prices the session itself, so what is stored here is\n * for display and nothing in it can change what is charged.\n */\nclass Cart {\n items = $state<CartItem[]>([]);\n /** Whether the cart sheet is open. */\n open = $state(false);\n count = $derived(this.items.reduce((total, item) => total + item.quantity, 0));\n subtotal = $derived(\n this.items.reduce((total, item) => total + item.unitAmount * item.quantity, 0)\n );\n /** The cart's currency: Stripe refuses a mixed cart, so the first item's. `null` while empty. */\n currency = $derived<string | null>(this.items[0]?.currency ?? null);\n /** Fixed subtotals in the currencies every item has a dashboard amount in. */\n options = $derived.by<Record<string, number>>(() => {\n const [first, ...rest] = this.items;\n if (!first?.options) return {};\n const totals: Record<string, number> = {};\n for (const code of Object.keys(first.options)) {\n if (rest.every((item) => item.options?.[code] !== undefined)) {\n totals[code] = this.items.reduce(\n (total, item) => total + item.options![code] * item.quantity,\n 0\n );\n }\n }\n return totals;\n });\n\n #loaded = false;\n\n /** Reads the saved cart, once, in the browser. */\n load() {\n if (!browser || this.#loaded) return;\n this.#loaded = true;\n try {\n const saved = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '[]');\n if (Array.isArray(saved)) this.items = saved;\n } catch {\n // Unreadable or blocked storage starts an empty cart.\n }\n }\n\n add(item: Omit<CartItem, 'quantity'>, quantity = 1) {\n this.load();\n const line = this.items.find((line) => line.price === item.price);\n if (line) line.quantity += quantity;\n else this.items.push({ ...item, quantity });\n this.#save();\n }\n\n /** A quantity of 0 removes the item. */\n setQuantity(price: string, quantity: number) {\n if (quantity <= 0) return this.remove(price);\n const line = this.items.find((line) => line.price === price);\n if (!line) return;\n line.quantity = quantity;\n this.#save();\n }\n\n remove(price: string) {\n this.items = this.items.filter((line) => line.price !== price);\n this.#save();\n }\n\n clear() {\n this.items = [];\n this.#save();\n }\n\n #save() {\n try {\n localStorage.setItem(STORAGE_KEY, JSON.stringify($state.snapshot(this.items)));\n } catch {\n // Storage can be full or blocked; the cart still works for this visit.\n }\n }\n}\n\nexport const cart = new Cart();\n\n/** Stripe amounts are in the currency's smallest unit; Intl knows how many digits that is (none for JPY). */\nfunction major(amount: number, code: string): number {\n const digits =\n new Intl.NumberFormat('en', { style: 'currency', currency: code }).resolvedOptions()\n .maximumFractionDigits ?? 2;\n return amount / 10 ** digits;\n}\n\n/**\n * Formats a Stripe amount the way the visitor reads prices: the fixed amount\n * in the currency they picked when the dashboard set one (`options`), else\n * the price's own, converted and marked as an estimate when they picked another.\n */\nexport function formatAmount(amount: number, code: string, options?: Record<string, number>): string {\n const fixed = options?.[currency.current];\n if (fixed !== undefined && currency.current !== code) {\n return money(major(fixed, currency.current), currency.current);\n }\n return currency.format(major(amount, code), code);\n}\n\n/**\n * A synced price's `currency_options` as the cart keeps them: upper-cased\n * code to `unit_amount`, leaving out options priced another way (tiers, a\n * customer-chosen amount).\n */\nexport function priceOptions(raw: unknown): Record<string, number> | undefined {\n if (!raw || typeof raw !== 'object') return undefined;\n const options: Record<string, number> = {};\n for (const [code, option] of Object.entries(raw as Record<string, { unit_amount?: unknown }>)) {\n if (typeof option?.unit_amount === 'number') options[code.toUpperCase()] = option.unit_amount;\n }\n return Object.keys(options).length > 0 ? options : undefined;\n}\n", Mp = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n import { cart, type CartItem } from '#lib/cart.svelte.js';\n\n interface Props {\n /** The Stripe price, as the page selling it loaded it. */\n price: Omit<CartItem, 'quantity'>;\n quantity?: number;\n label?: string;\n }\n\n let { price, quantity = 1, label = 'Add to cart', ...rest }: Props & ButtonProps = $props();\n\n let added = $state(false);\n\n function add() {\n cart.add(price, quantity);\n added = true;\n cart.open = true;\n setTimeout(() => (added = false), 1500);\n }\n<\/script>\n\n<Button onclick={add} {...rest}>\n {added ? 'Added' : label}\n</Button>\n", Np = "<script lang=\"ts\">\n import MinusIcon from '@lucide/svelte/icons/minus';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import XIcon from '@lucide/svelte/icons/x';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import { cart, formatAmount } from '#lib/cart.svelte.js';\n\n let { class: className = '' }: { class?: string } = $props();\n\n // What the checkout action reads: the prices and quantities, nothing the\n // browser could misstate.\n const items = $derived(\n JSON.stringify(cart.items.map(({ price, quantity }) => ({ price, quantity })))\n );\n<\/script>\n\n<div class=\"flex flex-col gap-4 {className}\">\n {#if cart.items.length === 0}\n <p class=\"text-muted-foreground text-sm\">Your cart is empty.</p>\n {:else}\n <ul class=\"divide-y\">\n {#each cart.items as item (item.price)}\n <li class=\"flex items-center gap-3 py-3\">\n <div class=\"min-w-0 flex-1\">\n <p class=\"truncate text-sm font-medium\">{item.name}</p>\n <p class=\"text-muted-foreground text-sm\">\n {formatAmount(item.unitAmount, item.currency, item.options)}\n </p>\n </div>\n <div class=\"flex items-center gap-1\">\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One fewer {item.name}\"\n onclick={() => cart.setQuantity(item.price, item.quantity - 1)}\n >\n <MinusIcon />\n </Button>\n <span class=\"w-6 text-center text-sm tabular-nums\">{item.quantity}</span>\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One more {item.name}\"\n onclick={() => cart.setQuantity(item.price, item.quantity + 1)}\n >\n <PlusIcon />\n </Button>\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"Remove {item.name}\"\n onclick={() => cart.remove(item.price)}\n >\n <XIcon />\n </Button>\n </li>\n {/each}\n </ul>\n\n <Separator />\n\n {#if cart.currency}\n <div class=\"flex justify-between text-sm font-medium\">\n <span>Subtotal</span>\n <span>{formatAmount(cart.subtotal, cart.currency, cart.options)}</span>\n </div>\n {/if}\n\n <!-- A plain form post: checkout works before the page has hydrated. -->\n <form method=\"POST\" action=\"/cart?/checkout\">\n <input type=\"hidden\" name=\"items\" value={items} />\n <Button type=\"submit\" class=\"w-full\">Check out</Button>\n </form>\n {/if}\n</div>\n", Pp = "<script lang=\"ts\">\n import * as Sheet from '#lib/components/ui/sheet/index.js';\n import CartItems from './cart-items.svelte';\n import { cart } from '#lib/cart.svelte.js';\n<\/script>\n\n<Sheet.Root bind:open={cart.open}>\n <Sheet.Content side=\"right\" class=\"flex flex-col\">\n <Sheet.Header>\n <Sheet.Title>Cart</Sheet.Title>\n </Sheet.Header>\n <CartItems class=\"flex-1 overflow-y-auto px-4 pb-4\" />\n </Sheet.Content>\n</Sheet.Root>\n", Fp = "import { fail, redirect } from '@sveltejs/kit';\nimport Stripe from 'stripe';\nimport stripe from '#lib/stripe.js';\nimport { priceOptions } from '#lib/cart.svelte.js';\n\n/** What the cart posts: prices and quantities. Stripe supplies everything else. */\nfunction readItems(raw: FormDataEntryValue | null): { price: string; quantity: number }[] | null {\n try {\n const items: unknown = JSON.parse(typeof raw === 'string' ? raw : '');\n if (!Array.isArray(items) || items.length === 0 || items.length > 100) return null;\n const valid = items.every(\n (item) =>\n typeof item?.price === 'string' &&\n Number.isInteger(item?.quantity) &&\n item.quantity >= 1 &&\n item.quantity <= 99\n );\n return valid ? items : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The currency to charge in: the one the visitor read prices in, when every\n * price has a fixed amount in it (`currency_options`, set in the dashboard);\n * else the prices' own, and nothing is converted at checkout.\n */\nasync function chargeCurrency(\n locals: App.Locals,\n items: { price: string }[]\n): Promise<string | undefined> {\n const wanted = locals.currency?.toLowerCase();\n if (!wanted) return undefined;\n const prices = await Promise.all(\n items.map((item) =>\n locals.admin\n .collection('stripe_prices')\n .getOne<{ currency?: string; currency_options?: unknown }>(item.price)\n .catch(() => null)\n )\n );\n const priced = prices.every(\n (price) =>\n price &&\n (price.currency === wanted ||\n priceOptions(price.currency_options)?.[wanted.toUpperCase()] !== undefined)\n );\n // Prices already in that currency are charged in it without being told.\n const needed = prices.some((price) => price && price.currency !== wanted);\n return priced && needed ? wanted : undefined;\n}\n\nexport const actions = {\n checkout: async ({ request, url, locals }) => {\n const items = readItems((await request.formData()).get('items'));\n if (!items) return fail(400, { message: 'Your cart could not be read.' });\n\n const currency = await chargeCurrency(locals, items);\n\n let session: Stripe.Checkout.Session;\n try {\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\n currency,\n line_items: items,\n allow_promotion_codes: true,\n success_url: `${url.origin}/checkout/success?session_id={CHECKOUT_SESSION_ID}`,\n cancel_url: `${url.origin}/cart`\n });\n } catch (error) {\n // An inactive or recurring price, or mixed currencies: Stripe says which.\n if (error instanceof Stripe.errors.StripeError) {\n return fail(400, { message: error.message });\n }\n throw error;\n }\n\n // SvelteKit 3 redirects off-site only when told to.\n redirect(303, session.url!, { external: true });\n }\n};\n", Ip = "<script lang=\"ts\">\n import CartItems from '#lib/components/cart/cart-items.svelte';\n\n let { form } = $props();\n<\/script>\n\n<section data-role=\"content\" class=\"max-w-xl\">\n <h1 class=\"mb-6 text-2xl font-semibold\">Cart</h1>\n {#if form?.message}\n <p class=\"text-destructive mb-4 text-sm\">{form.message}</p>\n {/if}\n <CartItems />\n</section>\n", Lp = "import { describe, it, expect, beforeAll, type TestContext } from 'vitest';\nimport * as devalue from 'devalue';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\nimport stripe from '#lib/stripe.js';\nimport type Stripe from 'stripe';\n\ndescribe('POST /cart?/checkout', () => {\n let price: Stripe.Price;\n let inactivePrice: Stripe.Price;\n\n beforeAll(async () => {\n const name = 'Test Product - Cart';\n const found = await stripe.products.search({\n query: `name:\"${name}\" AND metadata[\"test\"]:\"true\"`,\n limit: 1\n });\n const product =\n found.data[0] ?? (await stripe.products.create({ name, metadata: { test: 'true' } }));\n\n const prices = async (active: boolean) =>\n (await stripe.prices.list({ product: product.id, active, limit: 1 })).data[0];\n price =\n (await prices(true)) ??\n (await stripe.prices.create({ product: product.id, unit_amount: 1500, currency: 'usd' }));\n inactivePrice =\n (await prices(false)) ??\n (await stripe.prices.create({\n product: product.id,\n unit_amount: 2500,\n currency: 'usd',\n active: false\n }));\n });\n\n const checkout = (context: TestContext, items: unknown) =>\n context.request\n .post(`${'/cart' satisfies Match<RouteId>}?/checkout`)\n .type('form')\n .send({ items: typeof items === 'string' ? items : JSON.stringify(items) });\n\n it('redirects to a Stripe Checkout Session', async (context) => {\n const response = await checkout(context, [{ price: price.id, quantity: 2 }]);\n expect(response.body.status).toBe(303);\n expect(response.body.location).toMatch(/^https:\\/\\/checkout\\.stripe\\.com\\//);\n });\n\n it('refuses a cart it cannot read', async (context) => {\n for (const items of ['not json', [], [{ price: price.id }], [{ quantity: 1 }]]) {\n const response = await checkout(context, items);\n expect(response.body.status).toBe(400);\n }\n });\n\n it('refuses quantities outside 1 to 99', async (context) => {\n for (const quantity of [0, 100, 1.5]) {\n const response = await checkout(context, [{ price: price.id, quantity }]);\n expect(response.body.status).toBe(400);\n }\n });\n\n it(\"passes on Stripe's reason for a price it won't sell\", async (context) => {\n const response = await checkout(context, [{ price: inactivePrice.id, quantity: 1 }]);\n expect(response.body.status).toBe(400);\n expect(devalue.parse(response.body.data).message).toMatch(/inactive|not active/i);\n });\n});\n", Rp = "import { browser } from '$app/env';\nimport { orderSubtotal, type OrderLine } from '@velastack/whatsapp';\nimport { site } from '#lib/site.js';\n\nexport interface CartItem extends OrderLine {\n /** Your own id for the item (a slug or SKU); lines with the same id merge. */\n id: string;\n}\n\n/** An order sent to WhatsApp, kept until the customer says they're done. */\nexport interface PlacedOrder {\n ref: string;\n /** The chat link, to open it again. */\n href: string;\n}\n\nconst STORAGE_KEY = 'cart';\n\n/**\n * The cart is a list of items kept in the browser. Checkout turns it into a\n * WhatsApp message to the business, where the order is confirmed and paid,\n * so what is stored here is what the customer asked for, not what they pay.\n */\nclass Cart {\n items = $state<CartItem[]>([]);\n /** Whether the cart sheet is open. */\n open = $state(false);\n placed = $state<PlacedOrder | null>(null);\n count = $derived(this.items.reduce((total, item) => total + item.quantity, 0));\n /** In `site.currency`, only when every item has a price; otherwise the business quotes. */\n subtotal = $derived(orderSubtotal(this.items, site.currency));\n\n #loaded = false;\n\n /** Reads the saved cart, once, in the browser. */\n load() {\n if (!browser || this.#loaded) return;\n this.#loaded = true;\n try {\n const saved = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}');\n if (Array.isArray(saved?.items)) this.items = saved.items;\n if (saved?.placed) this.placed = saved.placed;\n } catch {\n // Unreadable or blocked storage starts an empty cart.\n }\n }\n\n add(item: Omit<CartItem, 'quantity'>, quantity = 1) {\n this.load();\n // Adding after an order was sent starts the next one.\n if (this.placed) this.clear();\n const line = this.items.find((line) => line.id === item.id);\n if (line) line.quantity += quantity;\n else this.items.push({ ...item, quantity });\n this.#save();\n }\n\n /** A quantity of 0 removes the item. */\n setQuantity(id: string, quantity: number) {\n if (quantity <= 0) return this.remove(id);\n const line = this.items.find((line) => line.id === id);\n if (!line) return;\n line.quantity = quantity;\n this.#save();\n }\n\n remove(id: string) {\n this.items = this.items.filter((line) => line.id !== id);\n this.#save();\n }\n\n /** Records that the order went to WhatsApp; the sheet shows it until `clear()`. */\n place(order: PlacedOrder) {\n this.placed = order;\n this.#save();\n }\n\n clear() {\n this.items = [];\n this.placed = null;\n this.#save();\n }\n\n #save() {\n try {\n localStorage.setItem(\n STORAGE_KEY,\n JSON.stringify({ items: $state.snapshot(this.items), placed: this.placed })\n );\n } catch {\n // Storage can be full or blocked; the cart still works for this visit.\n }\n }\n}\n\nexport const cart = new Cart();\n", zp = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import type { ButtonProps } from '#lib/components/ui/button/index.js';\n import { cart } from '#lib/cart.svelte.js';\n\n interface Props {\n /** Your own id for the item (a slug or SKU); adding it again raises the quantity. */\n id: string;\n /** What the business will read in the order. */\n name: string;\n /** The unit price in `site.currency`, written as you would (`4.5`). Leave it out to quote in the chat. */\n price?: number;\n quantity?: number;\n label?: string;\n }\n\n let {\n id,\n name,\n price,\n quantity = 1,\n label = 'Add to cart',\n ...rest\n }: Props & ButtonProps = $props();\n\n let added = $state(false);\n\n function add() {\n cart.add({ id, name, price }, quantity);\n added = true;\n cart.open = true;\n setTimeout(() => (added = false), 1500);\n }\n<\/script>\n\n<Button onclick={add} {...rest}>\n {added ? 'Added' : label}\n</Button>\n", Bp = "<script lang=\"ts\">\n import MinusIcon from '@lucide/svelte/icons/minus';\n import PlusIcon from '@lucide/svelte/icons/plus';\n import XIcon from '@lucide/svelte/icons/x';\n import { toast } from 'svelte-sonner';\n import { formToken, lineTotal, orderRef } from '@velastack/whatsapp';\n import { Button, buttonVariants } from '#lib/components/ui/button/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import * as Sheet from '#lib/components/ui/sheet/index.js';\n import CustomerFields from '#lib/components/payments/customer-fields.svelte';\n import { cart } from '#lib/cart.svelte.js';\n import { formatPrice } from '#lib/currency.svelte.js';\n import { ORDER_FORM, placeOrder } from '#lib/order.js';\n import { site } from '#lib/site.js';\n\n // Fetched once, the first time the cart opens: the hosted form refuses a\n // token younger than two seconds, and filling the form in takes longer.\n let token: string | null = null;\n\n $effect(() => {\n if (!cart.open || !ORDER_FORM || token) return;\n formToken(ORDER_FORM).then((value) => (token = value));\n });\n\n function checkout(event: SubmitEvent) {\n event.preventDefault();\n const data = new FormData(event.currentTarget as HTMLFormElement);\n const order = {\n ref: orderRef(),\n name: String(data.get('name') ?? ''),\n phone: String(data.get('phone') ?? ''),\n note: String(data.get('note') ?? '') || undefined,\n currency: site.currency,\n lines: cart.items.map(({ name, quantity, price }) => ({ name, quantity, price })),\n subtotal: cart.subtotal\n };\n const href = placeOrder(order, { token, gotcha: String(data.get('_gotcha') ?? '') });\n if (!href) {\n toast.error('WhatsApp ordering is not set up yet');\n return;\n }\n cart.place({ ref: order.ref, href });\n }\n\n function done() {\n cart.clear();\n cart.open = false;\n }\n<\/script>\n\n<Sheet.Root bind:open={cart.open}>\n <Sheet.Content side=\"right\" class=\"flex flex-col\">\n <Sheet.Header>\n <Sheet.Title>Cart</Sheet.Title>\n </Sheet.Header>\n <div class=\"flex flex-1 flex-col gap-4 overflow-y-auto px-4 pb-4\">\n {#if cart.placed}\n <div class=\"flex flex-col gap-2\">\n <p class=\"font-medium\">Order {cart.placed.ref} opened in WhatsApp</p>\n <p class=\"text-muted-foreground text-sm\">\n Send the message in WhatsApp to place your order. We'll reply there.\n </p>\n </div>\n <a\n href={cart.placed.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class={buttonVariants({ variant: 'outline' })}\n >\n Open WhatsApp again\n </a>\n <Button onclick={done}>Done</Button>\n {:else if cart.items.length === 0}\n <p class=\"text-muted-foreground text-sm\">Your cart is empty.</p>\n {:else}\n <ul class=\"divide-y\">\n {#each cart.items as item (item.id)}\n {@const total = lineTotal(item, site.currency)}\n <li class=\"flex items-center gap-3 py-3\">\n <div class=\"min-w-0 flex-1\">\n <p class=\"truncate text-sm font-medium\">{item.name}</p>\n {#if total !== undefined}\n <p class=\"text-muted-foreground text-sm\">{formatPrice(total)}</p>\n {/if}\n </div>\n <div class=\"flex items-center gap-1\">\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One fewer {item.name}\"\n onclick={() => cart.setQuantity(item.id, item.quantity - 1)}\n >\n <MinusIcon />\n </Button>\n <span class=\"w-6 text-center text-sm tabular-nums\">{item.quantity}</span>\n <Button\n variant=\"outline\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"One more {item.name}\"\n onclick={() => cart.setQuantity(item.id, item.quantity + 1)}\n >\n <PlusIcon />\n </Button>\n </div>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n class=\"size-7\"\n aria-label=\"Remove {item.name}\"\n onclick={() => cart.remove(item.id)}\n >\n <XIcon />\n </Button>\n </li>\n {/each}\n </ul>\n\n <Separator />\n\n {#if cart.subtotal !== undefined}\n <div class=\"flex justify-between text-sm font-medium\">\n <span>Subtotal</span>\n <span>{formatPrice(cart.subtotal)}</span>\n </div>\n {:else}\n <p class=\"text-muted-foreground text-sm\">We'll confirm the total in WhatsApp.</p>\n {/if}\n\n <form class=\"flex flex-col gap-4\" onsubmit={checkout}>\n <CustomerFields />\n <Button type=\"submit\" class=\"w-full\">Order on WhatsApp</Button>\n </form>\n {/if}\n </div>\n </Sheet.Content>\n</Sheet.Root>\n", Vp = "import { fail, redirect } from '@sveltejs/kit';\nimport Stripe from 'stripe';\nimport stripe from '#lib/stripe.js';\nimport { priceOptions } from '#lib/cart.svelte.js';\nimport { getStripeCustomerId } from '#lib/server/stripe-customer.js';\n\n/** What the cart posts: prices and quantities. Stripe supplies everything else. */\nfunction readItems(raw: FormDataEntryValue | null): { price: string; quantity: number }[] | null {\n try {\n const items: unknown = JSON.parse(typeof raw === 'string' ? raw : '');\n if (!Array.isArray(items) || items.length === 0 || items.length > 100) return null;\n const valid = items.every(\n (item) =>\n typeof item?.price === 'string' &&\n Number.isInteger(item?.quantity) &&\n item.quantity >= 1 &&\n item.quantity <= 99\n );\n return valid ? items : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The currency to charge in: the one the visitor read prices in, when every\n * price has a fixed amount in it (`currency_options`, set in the dashboard);\n * else the prices' own, and nothing is converted at checkout.\n */\nasync function chargeCurrency(\n locals: App.Locals,\n items: { price: string }[]\n): Promise<string | undefined> {\n const wanted = locals.currency?.toLowerCase();\n if (!wanted) return undefined;\n const prices = await Promise.all(\n items.map((item) =>\n locals.admin\n .collection('stripe_prices')\n .getOne<{ currency?: string; currency_options?: unknown }>(item.price)\n .catch(() => null)\n )\n );\n const priced = prices.every(\n (price) =>\n price &&\n (price.currency === wanted ||\n priceOptions(price.currency_options)?.[wanted.toUpperCase()] !== undefined)\n );\n // Prices already in that currency are charged in it without being told.\n const needed = prices.some((price) => price && price.currency !== wanted);\n return priced && needed ? wanted : undefined;\n}\n\nexport const actions = {\n checkout: async ({ request, url, locals }) => {\n const items = readItems((await request.formData()).get('items'));\n if (!items) return fail(400, { message: 'Your cart could not be read.' });\n\n // A signed-in buyer checks out as their Stripe customer, so their saved\n // cards are offered and the payment shows up on their billing page. If\n // the customer isn't linked yet, they check out as a guest.\n const user = locals.pb.authStore.record;\n const customer = user\n ? await getStripeCustomerId(locals.admin, user).catch(() => undefined)\n : undefined;\n\n const currency = await chargeCurrency(locals, items);\n\n let session: Stripe.Checkout.Session;\n try {\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\n currency,\n customer,\n line_items: items,\n allow_promotion_codes: true,\n success_url: `${url.origin}/checkout/success?session_id={CHECKOUT_SESSION_ID}`,\n cancel_url: `${url.origin}/cart`\n });\n } catch (error) {\n // An inactive or recurring price, or mixed currencies: Stripe says which.\n if (error instanceof Stripe.errors.StripeError) {\n return fail(400, { message: error.message });\n }\n throw error;\n }\n\n // SvelteKit 3 redirects off-site only when told to.\n redirect(303, session.url!, { external: true });\n }\n};\n", Hp = [
|
|
6214
6226
|
{
|
|
6215
6227
|
id: "stripe",
|
|
6216
6228
|
label: "Stripe",
|
|
@@ -6224,32 +6236,32 @@ var Tp = {
|
|
|
6224
6236
|
id: "whatsapp",
|
|
6225
6237
|
label: "WhatsApp"
|
|
6226
6238
|
}
|
|
6227
|
-
],
|
|
6239
|
+
], Up = {
|
|
6228
6240
|
slug: "enable-ecommerce",
|
|
6229
|
-
providers:
|
|
6241
|
+
providers: Hp,
|
|
6230
6242
|
inheritsProvider: "payments"
|
|
6231
|
-
},
|
|
6232
|
-
"./providers/shopify/src/lib/cart.svelte.ts":
|
|
6233
|
-
"./providers/shopify/src/lib/components/cart/add-to-cart.svelte":
|
|
6234
|
-
"./providers/shopify/src/lib/components/cart/cart-sheet.svelte":
|
|
6235
|
-
"./providers/stripe/src/lib/cart.svelte.ts":
|
|
6236
|
-
"./providers/stripe/src/lib/components/cart/add-to-cart.svelte":
|
|
6237
|
-
"./providers/stripe/src/lib/components/cart/cart-items.svelte":
|
|
6238
|
-
"./providers/stripe/src/lib/components/cart/cart-sheet.svelte":
|
|
6239
|
-
"./providers/stripe/src/routes/(public)/cart/+page.server.ts":
|
|
6240
|
-
"./providers/stripe/src/routes/(public)/cart/+page.svelte":
|
|
6241
|
-
"./providers/stripe/src/routes/(public)/cart/server.test.ts":
|
|
6243
|
+
}, Wp = /* #__PURE__ */ Object.assign({ "./creates/src/lib/components/cart/cart-button.svelte": Dp }), Gp = /* #__PURE__ */ Object.assign({
|
|
6244
|
+
"./providers/shopify/src/lib/cart.svelte.ts": Op,
|
|
6245
|
+
"./providers/shopify/src/lib/components/cart/add-to-cart.svelte": kp,
|
|
6246
|
+
"./providers/shopify/src/lib/components/cart/cart-sheet.svelte": Ap,
|
|
6247
|
+
"./providers/stripe/src/lib/cart.svelte.ts": jp,
|
|
6248
|
+
"./providers/stripe/src/lib/components/cart/add-to-cart.svelte": Mp,
|
|
6249
|
+
"./providers/stripe/src/lib/components/cart/cart-items.svelte": Np,
|
|
6250
|
+
"./providers/stripe/src/lib/components/cart/cart-sheet.svelte": Pp,
|
|
6251
|
+
"./providers/stripe/src/routes/(public)/cart/+page.server.ts": Fp,
|
|
6252
|
+
"./providers/stripe/src/routes/(public)/cart/+page.svelte": Ip,
|
|
6253
|
+
"./providers/stripe/src/routes/(public)/cart/server.test.ts": Lp,
|
|
6242
6254
|
"./providers/stripe/src/routes/(public)/checkout/success/+page.server.ts": xr,
|
|
6243
6255
|
"./providers/stripe/src/routes/(public)/checkout/success/+page.svelte": wr,
|
|
6244
|
-
"./providers/whatsapp/src/lib/cart.svelte.ts":
|
|
6245
|
-
"./providers/whatsapp/src/lib/components/cart/add-to-cart.svelte":
|
|
6246
|
-
"./providers/whatsapp/src/lib/components/cart/cart-sheet.svelte":
|
|
6247
|
-
}),
|
|
6248
|
-
async function
|
|
6249
|
-
let n = x(
|
|
6256
|
+
"./providers/whatsapp/src/lib/cart.svelte.ts": Rp,
|
|
6257
|
+
"./providers/whatsapp/src/lib/components/cart/add-to-cart.svelte": zp,
|
|
6258
|
+
"./providers/whatsapp/src/lib/components/cart/cart-sheet.svelte": Bp
|
|
6259
|
+
}), Kp = /* #__PURE__ */ Object.assign({ "./providers-app-mode/stripe/src/routes/(public)/cart/+page.server.ts": Vp });
|
|
6260
|
+
async function qp(e, { stripeCustomer: t = !1 } = {}) {
|
|
6261
|
+
let n = x(Up, e), r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
6250
6262
|
for (let t of e) r.set(t.path, t);
|
|
6251
6263
|
};
|
|
6252
|
-
return i(Object.values(E(
|
|
6264
|
+
return i(Object.values(E(Wp, "./creates/"))), i(ge(Gp, n.id)), n.id === "stripe" && t && i(ge(Kp, n.id, "./providers-app-mode/")), {
|
|
6253
6265
|
creates: [...r.values()].sort((e, t) => e.path.localeCompare(t.path)),
|
|
6254
6266
|
modifies: [],
|
|
6255
6267
|
deletes: [],
|
|
@@ -6266,11 +6278,11 @@ async function Kp(e, { stripeCustomer: t = !1 } = {}) {
|
|
|
6266
6278
|
};
|
|
6267
6279
|
}
|
|
6268
6280
|
// src/patterns/enable/ecommerce/generate.preview.ts
|
|
6269
|
-
var
|
|
6270
|
-
async function
|
|
6271
|
-
return x(
|
|
6281
|
+
var Jp = /* #__PURE__ */ Object.assign({ "./preview-modifies/src/routes/(public)/root-layout.svelte": "<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { toggleMode } from 'mode-watcher';\n import * as Navbar from '#lib/components/ui/navbar/index.js';\n import { Button } from '#lib/components/ui/button/index.js';\n // [!code highlight]\n import CartButton from '#lib/components/cart/cart-button.svelte';\n\n // Layout data is passed through for navbar items a feature adds; enable auth\n // reads the signed-in user from it.\n let { children }: { children?: Snippet; data?: any } = $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} 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 <CartButton />\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 {site.name}. 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 <!-- Neither route exists yet: `vela legal privacy` and `vela legal terms` generate them. -->\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" });
|
|
6282
|
+
async function Yp(e) {
|
|
6283
|
+
return x(Up, e), {
|
|
6272
6284
|
creates: [],
|
|
6273
|
-
modifies: Object.values(E(
|
|
6285
|
+
modifies: Object.values(E(Jp, "./preview-modifies/")).sort((e, t) => e.path.localeCompare(t.path)),
|
|
6274
6286
|
deletes: [],
|
|
6275
6287
|
components: [],
|
|
6276
6288
|
packages: [],
|
|
@@ -6280,20 +6292,20 @@ async function Jp(e) {
|
|
|
6280
6292
|
};
|
|
6281
6293
|
}
|
|
6282
6294
|
// src/patterns/enable/ecommerce/index.ts
|
|
6283
|
-
var
|
|
6284
|
-
async function
|
|
6295
|
+
var Xp = "enable-ecommerce", Zp = "2.2.0", Qp = "src/patterns/enable/ecommerce", $p = "/enable/ecommerce";
|
|
6296
|
+
async function em(e) {
|
|
6285
6297
|
if (e.env === "preview") {
|
|
6286
|
-
let t = await
|
|
6298
|
+
let t = await qp(e), n = await Yp(e);
|
|
6287
6299
|
return S(T([t, n]), e);
|
|
6288
6300
|
}
|
|
6289
|
-
let { generate: t, hasStripeCustomer: n } = await import("./chunks/generate.runtime-hq8xt0m_.js"), r = await
|
|
6301
|
+
let { generate: t, hasStripeCustomer: n } = await import("./chunks/generate.runtime-hq8xt0m_.js"), r = await qp(e, { stripeCustomer: n(e.root) }), i = await t(e), { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
6290
6302
|
return a(await S(T([r, i]), e), e);
|
|
6291
6303
|
}
|
|
6292
|
-
var
|
|
6293
|
-
version:
|
|
6294
|
-
slug:
|
|
6295
|
-
source:
|
|
6296
|
-
docs:
|
|
6304
|
+
var tm = {
|
|
6305
|
+
version: Zp,
|
|
6306
|
+
slug: Xp,
|
|
6307
|
+
source: Qp,
|
|
6308
|
+
docs: $p,
|
|
6297
6309
|
plan: "pro",
|
|
6298
6310
|
title: "Enable ecommerce",
|
|
6299
6311
|
summary: "Adds a cart to the navbar and a checkout, on the project's payments provider: a browser cart that checks out through Stripe Checkout, a Shopify Storefront cart that hands off to Shopify's checkout, or a browser cart whose checkout opens a WhatsApp chat with the business and records the order to a hosted VelaStack form.",
|
|
@@ -6329,16 +6341,16 @@ var em = {
|
|
|
6329
6341
|
examples: [],
|
|
6330
6342
|
tests: 0,
|
|
6331
6343
|
baseline: "velastack",
|
|
6332
|
-
providers:
|
|
6333
|
-
inheritsProvider:
|
|
6334
|
-
generate:
|
|
6335
|
-
},
|
|
6336
|
-
"./creates/src/lib/workflows/sync-stripe-subscriptions.ts":
|
|
6337
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts":
|
|
6338
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts":
|
|
6339
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts":
|
|
6340
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts":
|
|
6341
|
-
}),
|
|
6344
|
+
providers: Hp,
|
|
6345
|
+
inheritsProvider: Up.inheritsProvider,
|
|
6346
|
+
generate: em
|
|
6347
|
+
}, nm = "import stripe from '#lib/stripe.js';\nimport { getAdmin, ow } from '#lib/server/workflows.js';\nimport { subscriptionRecordFields } from '../../routes/webhooks/stripe/handlers/subscription/shared';\n\n/**\n * Brings stripe_subscriptions in line with Stripe, all of them, so a webhook\n * that never arrived is corrected within ten minutes.\n */\nexport const syncStripeSubscriptions = ow.defineWorkflow(\n { name: 'sync-stripe-subscriptions', retryPolicy: { maximumAttempts: 3 } },\n async ({ step }) => {\n const subscriptions = await step.run({ name: 'list' }, async () => {\n const rows = [];\n for await (const subscription of stripe.subscriptions.list({ status: 'all', limit: 100 })) {\n const fields = subscriptionRecordFields(subscription);\n if (fields) rows.push(fields);\n }\n return rows;\n });\n\n return step.run({ name: 'upsert' }, async () => {\n const admin = await getAdmin();\n let synced = 0;\n let skipped = 0;\n for (const fields of subscriptions) {\n let customer;\n try {\n customer = await admin.collection('stripe_customers').getOne(fields.customer);\n } catch {\n // A customer this app does not know about.\n skipped += 1;\n continue;\n }\n try {\n await admin.collection('stripe_subscriptions').update(fields.id, fields);\n } catch {\n await admin.collection('stripe_subscriptions').create({ ...fields, user: customer.user });\n }\n synced += 1;\n }\n return { synced, skipped };\n });\n }\n);\n\nexport const cron = '*/10 * * * *';\n", rm = "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", im = "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", am = "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", om = "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", sm = /* #__PURE__ */ Object.assign({
|
|
6348
|
+
"./creates/src/lib/workflows/sync-stripe-subscriptions.ts": nm,
|
|
6349
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": rm,
|
|
6350
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": im,
|
|
6351
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": am,
|
|
6352
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": om
|
|
6353
|
+
}), cm = "./creates/", lm = {
|
|
6342
6354
|
name: "stripe_subscriptions",
|
|
6343
6355
|
type: "base",
|
|
6344
6356
|
fields: [
|
|
@@ -6413,10 +6425,10 @@ var em = {
|
|
|
6413
6425
|
}
|
|
6414
6426
|
]
|
|
6415
6427
|
};
|
|
6416
|
-
async function
|
|
6428
|
+
async function um(e) {
|
|
6417
6429
|
return {
|
|
6418
|
-
creates: Object.entries(
|
|
6419
|
-
let n = D(e,
|
|
6430
|
+
creates: Object.entries(sm).map(([e, t]) => {
|
|
6431
|
+
let n = D(e, cm);
|
|
6420
6432
|
return {
|
|
6421
6433
|
path: n,
|
|
6422
6434
|
language: w(n),
|
|
@@ -6428,13 +6440,13 @@ async function lm(e) {
|
|
|
6428
6440
|
deletes: [],
|
|
6429
6441
|
components: [],
|
|
6430
6442
|
packages: [],
|
|
6431
|
-
collections: [
|
|
6443
|
+
collections: [lm],
|
|
6432
6444
|
collectionPatches: [],
|
|
6433
6445
|
collectionDrops: []
|
|
6434
6446
|
};
|
|
6435
6447
|
}
|
|
6436
6448
|
// src/patterns/enable/subscriptions/generate.preview.ts
|
|
6437
|
-
var
|
|
6449
|
+
var dm = /* #__PURE__ */ Object.assign({
|
|
6438
6450
|
"./preview-modifies/src/lib/components/app-sidebar.svelte": Nr,
|
|
6439
6451
|
"./preview-modifies/src/lib/components/nav-user.svelte": jr,
|
|
6440
6452
|
"./preview-modifies/src/routes/(app)/+layout.server.ts": Or,
|
|
@@ -6442,12 +6454,12 @@ var um = /* #__PURE__ */ Object.assign({
|
|
|
6442
6454
|
"./preview-modifies/src/routes/(app)/billing/+page.server.ts": Mr,
|
|
6443
6455
|
"./preview-modifies/src/routes/(app)/billing/+page.svelte": Ar,
|
|
6444
6456
|
"./preview-modifies/src/routes/webhooks/stripe/handlers/dispatch.ts": Pr
|
|
6445
|
-
}),
|
|
6446
|
-
async function
|
|
6457
|
+
}), fm = "./preview-modifies/";
|
|
6458
|
+
async function pm(e) {
|
|
6447
6459
|
return {
|
|
6448
6460
|
creates: [],
|
|
6449
|
-
modifies: Object.entries(
|
|
6450
|
-
let n = D(e,
|
|
6461
|
+
modifies: Object.entries(dm).map(([e, t]) => {
|
|
6462
|
+
let n = D(e, fm);
|
|
6451
6463
|
return {
|
|
6452
6464
|
path: n,
|
|
6453
6465
|
language: w(n),
|
|
@@ -6464,26 +6476,26 @@ async function fm(e) {
|
|
|
6464
6476
|
};
|
|
6465
6477
|
}
|
|
6466
6478
|
// src/patterns/enable/subscriptions/index.ts
|
|
6467
|
-
var
|
|
6468
|
-
async function
|
|
6469
|
-
let t = await
|
|
6479
|
+
var mm = "enable-subscriptions", hm = "1.1.2", gm = "src/patterns/enable/subscriptions", _m = "/enable/subscriptions";
|
|
6480
|
+
async function vm(e) {
|
|
6481
|
+
let t = await um(e);
|
|
6470
6482
|
if (e.env === "preview") {
|
|
6471
|
-
let n = await
|
|
6483
|
+
let n = await pm(e);
|
|
6472
6484
|
return S(T([t, n]), e);
|
|
6473
6485
|
}
|
|
6474
6486
|
let { assertPaymentsAppMode: n, generate: r } = await import("./chunks/generate.runtime-DhNspd-h.js");
|
|
6475
6487
|
n(e.root);
|
|
6476
|
-
let { createCollections: i } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), a = await i(t.collections, e), o = await r(e), { writeResult: s } = await import("./chunks/write-result-
|
|
6488
|
+
let { createCollections: i } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), a = await i(t.collections, e), o = await r(e), { writeResult: s } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
6477
6489
|
return s(await S(T([{
|
|
6478
6490
|
...t,
|
|
6479
6491
|
creates: [...t.creates, ...a]
|
|
6480
6492
|
}, o]), e), e);
|
|
6481
6493
|
}
|
|
6482
|
-
var
|
|
6483
|
-
version:
|
|
6484
|
-
slug:
|
|
6485
|
-
source:
|
|
6486
|
-
docs:
|
|
6494
|
+
var ym = {
|
|
6495
|
+
version: hm,
|
|
6496
|
+
slug: mm,
|
|
6497
|
+
source: gm,
|
|
6498
|
+
docs: _m,
|
|
6487
6499
|
plan: "pro",
|
|
6488
6500
|
title: "Enable subscriptions",
|
|
6489
6501
|
summary: "Adds Stripe subscription billing with plan selection, cancel/resume, and webhook-synced subscription state. Requires enable-payments.",
|
|
@@ -6520,16 +6532,16 @@ var vm = {
|
|
|
6520
6532
|
examples: [],
|
|
6521
6533
|
tests: 0,
|
|
6522
6534
|
baseline: "velastack",
|
|
6523
|
-
generate:
|
|
6524
|
-
},
|
|
6535
|
+
generate: vm
|
|
6536
|
+
}, bm = /* #__PURE__ */ Object.assign({
|
|
6525
6537
|
"./preview-modifies/src/routes/(public)/checkout/success/+page.server.ts": Fr,
|
|
6526
6538
|
"./preview-modifies/src/routes/(public)/checkout/success/+page.svelte": Ir,
|
|
6527
6539
|
"./preview-modifies/src/routes/webhooks/stripe/handlers/dispatch.ts": "import type Stripe from 'stripe';\nimport { handlePaymentIntentSucceeded } from './payment-intent/succeeded';\nimport { handlePaymentMethodAttached } from './payment-method/attached';\nimport { handleCheckoutSessionCompleted } from './checkout/completed';\nimport { handleCheckoutAsyncPayment } from './checkout/async-payment';\n\n/**\n * Routes a verified Stripe event to its handler. Runs inside the stripe-event\n * workflow, so a handler that throws is retried with backoff rather than lost.\n */\nexport async function dispatchStripeEvent(event: Stripe.Event, locals: App.Locals) {\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 case 'checkout.session.completed':\n await handleCheckoutSessionCompleted(event.data.object, locals);\n break;\n\n case 'checkout.session.async_payment_succeeded':\n case 'checkout.session.async_payment_failed':\n await handleCheckoutAsyncPayment(event.data.object, locals);\n break;\n\n default:\n console.log(`Unhandled event type: ${event.type}`);\n }\n}\n"
|
|
6528
6540
|
});
|
|
6529
|
-
async function
|
|
6541
|
+
async function xm(e) {
|
|
6530
6542
|
return {
|
|
6531
6543
|
creates: [],
|
|
6532
|
-
modifies: Object.values(E(
|
|
6544
|
+
modifies: Object.values(E(bm, "./preview-modifies/")).sort((e, t) => e.path.localeCompare(t.path)),
|
|
6533
6545
|
deletes: [],
|
|
6534
6546
|
components: [],
|
|
6535
6547
|
packages: [],
|
|
@@ -6539,24 +6551,24 @@ async function bm(e) {
|
|
|
6539
6551
|
};
|
|
6540
6552
|
}
|
|
6541
6553
|
// src/patterns/enable/orders/index.ts
|
|
6542
|
-
var
|
|
6543
|
-
async function
|
|
6554
|
+
var Sm = "enable-orders", Cm = "1.0.0", wm = "src/patterns/enable/orders", Tm = "/enable/orders";
|
|
6555
|
+
async function Em(e) {
|
|
6544
6556
|
let t = await Sr(e);
|
|
6545
6557
|
if (e.env === "preview") {
|
|
6546
|
-
let n = await
|
|
6558
|
+
let n = await xm(e);
|
|
6547
6559
|
return S(T([t, n]), e);
|
|
6548
6560
|
}
|
|
6549
|
-
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-CVqPHddZ.js"), a = await i(e), { writeResult: o } = await import("./chunks/write-result-
|
|
6561
|
+
let { createCollections: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-CVqPHddZ.js"), a = await i(e), { writeResult: o } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
6550
6562
|
return o(await S(T([{
|
|
6551
6563
|
...t,
|
|
6552
6564
|
creates: [...t.creates, ...r]
|
|
6553
6565
|
}, a]), e), e);
|
|
6554
6566
|
}
|
|
6555
|
-
var
|
|
6556
|
-
version:
|
|
6557
|
-
slug:
|
|
6558
|
-
source:
|
|
6559
|
-
docs:
|
|
6567
|
+
var Dm = {
|
|
6568
|
+
version: Cm,
|
|
6569
|
+
slug: Sm,
|
|
6570
|
+
source: wm,
|
|
6571
|
+
docs: Tm,
|
|
6560
6572
|
plan: "pro",
|
|
6561
6573
|
title: "Enable orders",
|
|
6562
6574
|
summary: "Records what was bought through Stripe Checkout: orders and their lines, written by the webhook so a redelivery updates rather than duplicates. The success page shows the order; with auth, users see their own orders, and a paid order notifies them when notifications are on.",
|
|
@@ -6594,52 +6606,52 @@ var Em = {
|
|
|
6594
6606
|
examples: [],
|
|
6595
6607
|
tests: 0,
|
|
6596
6608
|
baseline: "velastack",
|
|
6597
|
-
generate:
|
|
6598
|
-
}, Dm = "<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", Om = "import { z } from \"zod\";\n\nexport const teamSchema = z.object({\n name: z.string(),\n});\n", km = "import { z } from \"zod\";\n\nexport const teamInviteSchema = z.object({\n email: z.email(),\n});\n", Am = "import { z } from \"zod\";\n\nexport const teamRoleSchema = z.object({\n role: z.enum([\"owner\", \"admin\", \"member\"]),\n});\n", jm = "<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", Mm = "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, \"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, \"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", Nm = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\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} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\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", Pm = "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", Fm = "<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", Im = "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, \"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, \"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", Lm = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\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} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\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", Rm = "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", zm = "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 // Invites go to an email; accounts made with a phone number may have none.\n const pendingInvites = user.email\n ? await locals.pb.collection(\"team_invites\").getFullList({\n filter: locals.pb.filter(\"email = {:email}\", { email: user.email }),\n expand: \"team\",\n })\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", Bm = "<script lang=\"ts\">\n import * as Card from '#lib/components/ui/card/index.js';\n import { Button } from '#lib/components/ui/button/index.js';\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/index.js';\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", Vm = "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, \"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, \"Team not found\");\n }\n\n if (teamMembership.role === \"owner\") {\n return error(400, \"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", Hm = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Teams'\n });\n\n return { pageMetaTags };\n};\n", Um = "import { redirect } from \"@sveltejs/kit\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"#lib/schemas/team.js\";\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", Wm = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Card from '#lib/components/ui/card/index.js';\n import { Button, buttonVariants } from '#lib/components/ui/button/index.js';\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 UserRoundIcon from '@lucide/svelte/icons/user-round';\n import * as Avatar from '#lib/components/ui/avatar/index.js';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import * as Table from '#lib/components/ui/table/index.js';\n import { getAuthorization } from './authorization';\n import { toast } from 'svelte-sonner';\n import * as AlertDialog from '#lib/components/ui/alert-dialog/index.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import TrashIcon from '@lucide/svelte/icons/trash-2';\n import { Input } from '#lib/components/ui/input/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '#lib/schemas/team.js';\n import { page } from '$app/state';\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 // The address this admin is on, so a link copied from staging joins staging.\n const link = `${page.url.origin}/${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 <!-- Accounts made with a phone number may have neither -->\n {@const initial = (member.name || member.email || '').charAt(0).toUpperCase()}\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 {#if initial}\n {initial}\n {:else}\n <UserRoundIcon class=\"size-1/2\" />\n {/if}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {member.name || member.email || 'Unnamed member'}\n </div>\n {#if member.name && member.email}\n <div class=\"text-sm text-muted-foreground\">\n {member.email}\n </div>\n {/if}\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-reset={false}\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 {page.url.origin}/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-reset={false}\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", Gm = "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.js\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\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, \"Member ID is required\");\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").delete(memberId);\n } catch {\n return error(400, \"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 () => {\n // TODO: re-send the invite email once mail delivery is wired up.\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, \"Invite ID is required\");\n }\n\n try {\n await locals.pb.collection(\"team_invites\").delete(inviteId);\n } catch {\n return error(400, \"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, \"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", Km = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team'\n });\n\n return { pageMetaTags };\n};\n", qm = "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", Jm = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamInviteSchema } from \"#lib/schemas/teamInvite.js\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\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", Ym = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\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.js';\n import * as Form from '#lib/components/ui/form/index.js';\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}`, { reset: false });\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", Xm = "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", Zm = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", Qm = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamRoleSchema } from \"#lib/schemas/teamRole.js\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\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", $m = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\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.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import * as Select from '#lib/components/ui/select/index.js';\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}`, { reset: false });\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", eh = "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", th = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", nh = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", rh = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"#lib/schemas/team.js\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\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", ih = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\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.js';\n import * as Form from '#lib/components/ui/form/index.js';\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', { reset: false });\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", ah = "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", oh = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", sh = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", ch = "import { error, redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\n\nexport const load = async ({ params, cookies, url, locals }) => {\n const { id } = params;\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl = next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n\n try {\n await locals.pb.collection(\"teams\").getOne(id);\n } catch {\n return error(404, \"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", lh = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", uh = /* #__PURE__ */ Object.assign({
|
|
6599
|
-
"./creates/src/lib/components/team-switcher.svelte":
|
|
6600
|
-
"./creates/src/lib/schemas/team.ts":
|
|
6601
|
-
"./creates/src/lib/schemas/teamInvite.ts":
|
|
6602
|
-
"./creates/src/lib/schemas/teamRole.ts":
|
|
6603
|
-
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte":
|
|
6604
|
-
"./creates/src/routes/(app)/invite/[id]/+page.server.ts":
|
|
6605
|
-
"./creates/src/routes/(app)/invite/[id]/+page.svelte":
|
|
6606
|
-
"./creates/src/routes/(app)/invite/[id]/+page.ts":
|
|
6607
|
-
"./creates/src/routes/(app)/join/[id]/+layout@.svelte":
|
|
6608
|
-
"./creates/src/routes/(app)/join/[id]/+page.server.ts":
|
|
6609
|
-
"./creates/src/routes/(app)/join/[id]/+page.svelte":
|
|
6610
|
-
"./creates/src/routes/(app)/join/[id]/+page.ts":
|
|
6611
|
-
"./creates/src/routes/(app)/teams/+layout.server.ts":
|
|
6612
|
-
"./creates/src/routes/(app)/teams/+layout.svelte":
|
|
6613
|
-
"./creates/src/routes/(app)/teams/+page.server.ts":
|
|
6609
|
+
generate: Em
|
|
6610
|
+
}, Om = "<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", km = "import { z } from \"zod\";\n\nexport const teamSchema = z.object({\n name: z.string(),\n});\n", Am = "import { z } from \"zod\";\n\nexport const teamInviteSchema = z.object({\n email: z.email(),\n});\n", jm = "import { z } from \"zod\";\n\nexport const teamRoleSchema = z.object({\n role: z.enum([\"owner\", \"admin\", \"member\"]),\n});\n", Mm = "<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", Nm = "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, \"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, \"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", Pm = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\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} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\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", Fm = "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", Im = "<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", Lm = "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, \"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, \"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", Rm = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\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} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\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", zm = "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", Bm = "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 // Invites go to an email; accounts made with a phone number may have none.\n const pendingInvites = user.email\n ? await locals.pb.collection(\"team_invites\").getFullList({\n filter: locals.pb.filter(\"email = {:email}\", { email: user.email }),\n expand: \"team\",\n })\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", Vm = "<script lang=\"ts\">\n import * as Card from '#lib/components/ui/card/index.js';\n import { Button } from '#lib/components/ui/button/index.js';\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/index.js';\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", Hm = "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, \"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, \"Team not found\");\n }\n\n if (teamMembership.role === \"owner\") {\n return error(400, \"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", Um = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Teams'\n });\n\n return { pageMetaTags };\n};\n", Wm = "import { redirect } from \"@sveltejs/kit\";\nimport { superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"#lib/schemas/team.js\";\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", Gm = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Card from '#lib/components/ui/card/index.js';\n import { Button, buttonVariants } from '#lib/components/ui/button/index.js';\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 UserRoundIcon from '@lucide/svelte/icons/user-round';\n import * as Avatar from '#lib/components/ui/avatar/index.js';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import * as Table from '#lib/components/ui/table/index.js';\n import { getAuthorization } from './authorization';\n import { toast } from 'svelte-sonner';\n import * as AlertDialog from '#lib/components/ui/alert-dialog/index.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import TrashIcon from '@lucide/svelte/icons/trash-2';\n import { Input } from '#lib/components/ui/input/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { teamSchema } from '#lib/schemas/team.js';\n import { page } from '$app/state';\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 // The address this admin is on, so a link copied from staging joins staging.\n const link = `${page.url.origin}/${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 <!-- Accounts made with a phone number may have neither -->\n {@const initial = (member.name || member.email || '').charAt(0).toUpperCase()}\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 {#if initial}\n {initial}\n {:else}\n <UserRoundIcon class=\"size-1/2\" />\n {/if}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"flex flex-col\">\n <div class=\"font-medium text-foreground\">\n {member.name || member.email || 'Unnamed member'}\n </div>\n {#if member.name && member.email}\n <div class=\"text-sm text-muted-foreground\">\n {member.email}\n </div>\n {/if}\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-reset={false}\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 {page.url.origin}/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-reset={false}\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", Km = "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.js\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\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, \"Member ID is required\");\n }\n\n try {\n await locals.pb.collection(\"team_memberships\").delete(memberId);\n } catch {\n return error(400, \"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 () => {\n // TODO: re-send the invite email once mail delivery is wired up.\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, \"Invite ID is required\");\n }\n\n try {\n await locals.pb.collection(\"team_invites\").delete(inviteId);\n } catch {\n return error(400, \"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, \"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", qm = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Team'\n });\n\n return { pageMetaTags };\n};\n", Jm = "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", Ym = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamInviteSchema } from \"#lib/schemas/teamInvite.js\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\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", Xm = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\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.js';\n import * as Form from '#lib/components/ui/form/index.js';\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}`, { reset: false });\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", Zm = "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", Qm = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", $m = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamRoleSchema } from \"#lib/schemas/teamRole.js\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\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", eh = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\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.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import * as Select from '#lib/components/ui/select/index.js';\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}`, { reset: false });\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", th = "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", nh = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", rh = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", ih = "import { fail, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { teamSchema } from \"#lib/schemas/team.js\";\nimport { redirect } from \"sveltekit-flash-message/server\";\nimport { setPocketbaseErrors } from \"@velastack/pocketbase/form\";\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", ah = "<script lang=\"ts\">\n import { untrack } from 'svelte';\n import * as Dialog from '#lib/components/ui/dialog/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\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.js';\n import * as Form from '#lib/components/ui/form/index.js';\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', { reset: false });\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", oh = "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", sh = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", ch = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", lh = "import { error, redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\n\nexport const load = async ({ params, cookies, url, locals }) => {\n const { id } = params;\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl = next && /^\\/(?![/\\\\])/.test(next) ? next : \"/dashboard\";\n\n try {\n await locals.pb.collection(\"teams\").getOne(id);\n } catch {\n return error(404, \"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", uh = "import { describe, it, expect, beforeEach, afterEach } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\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", dh = /* #__PURE__ */ Object.assign({
|
|
6611
|
+
"./creates/src/lib/components/team-switcher.svelte": Om,
|
|
6612
|
+
"./creates/src/lib/schemas/team.ts": km,
|
|
6613
|
+
"./creates/src/lib/schemas/teamInvite.ts": Am,
|
|
6614
|
+
"./creates/src/lib/schemas/teamRole.ts": jm,
|
|
6615
|
+
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte": Mm,
|
|
6616
|
+
"./creates/src/routes/(app)/invite/[id]/+page.server.ts": Nm,
|
|
6617
|
+
"./creates/src/routes/(app)/invite/[id]/+page.svelte": Pm,
|
|
6618
|
+
"./creates/src/routes/(app)/invite/[id]/+page.ts": Fm,
|
|
6619
|
+
"./creates/src/routes/(app)/join/[id]/+layout@.svelte": Im,
|
|
6620
|
+
"./creates/src/routes/(app)/join/[id]/+page.server.ts": Lm,
|
|
6621
|
+
"./creates/src/routes/(app)/join/[id]/+page.svelte": Rm,
|
|
6622
|
+
"./creates/src/routes/(app)/join/[id]/+page.ts": zm,
|
|
6623
|
+
"./creates/src/routes/(app)/teams/+layout.server.ts": Bm,
|
|
6624
|
+
"./creates/src/routes/(app)/teams/+layout.svelte": Vm,
|
|
6625
|
+
"./creates/src/routes/(app)/teams/+page.server.ts": Hm,
|
|
6614
6626
|
"./creates/src/routes/(app)/teams/+page.svelte": "",
|
|
6615
|
-
"./creates/src/routes/(app)/teams/+page.ts":
|
|
6616
|
-
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts":
|
|
6617
|
-
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte":
|
|
6618
|
-
"./creates/src/routes/(app)/teams/[id]/+page.server.ts":
|
|
6627
|
+
"./creates/src/routes/(app)/teams/+page.ts": Um,
|
|
6628
|
+
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts": Wm,
|
|
6629
|
+
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": Gm,
|
|
6630
|
+
"./creates/src/routes/(app)/teams/[id]/+page.server.ts": Km,
|
|
6619
6631
|
"./creates/src/routes/(app)/teams/[id]/+page.svelte": "",
|
|
6620
|
-
"./creates/src/routes/(app)/teams/[id]/+page.ts":
|
|
6621
|
-
"./creates/src/routes/(app)/teams/[id]/authorization.ts":
|
|
6622
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts":
|
|
6623
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte":
|
|
6624
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts":
|
|
6625
|
-
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts":
|
|
6626
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts":
|
|
6627
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte":
|
|
6628
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts":
|
|
6629
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts":
|
|
6630
|
-
"./creates/src/routes/(app)/teams/[id]/server.test.ts":
|
|
6631
|
-
"./creates/src/routes/(app)/teams/new/+page.server.ts":
|
|
6632
|
-
"./creates/src/routes/(app)/teams/new/+page.svelte":
|
|
6633
|
-
"./creates/src/routes/(app)/teams/new/+page.ts":
|
|
6634
|
-
"./creates/src/routes/(app)/teams/new/server.test.ts":
|
|
6635
|
-
"./creates/src/routes/(app)/teams/server.test.ts":
|
|
6636
|
-
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts":
|
|
6637
|
-
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts":
|
|
6638
|
-
}),
|
|
6639
|
-
async function
|
|
6632
|
+
"./creates/src/routes/(app)/teams/[id]/+page.ts": qm,
|
|
6633
|
+
"./creates/src/routes/(app)/teams/[id]/authorization.ts": Jm,
|
|
6634
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": Ym,
|
|
6635
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte": Xm,
|
|
6636
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts": Zm,
|
|
6637
|
+
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts": Qm,
|
|
6638
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": $m,
|
|
6639
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": eh,
|
|
6640
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": th,
|
|
6641
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": nh,
|
|
6642
|
+
"./creates/src/routes/(app)/teams/[id]/server.test.ts": rh,
|
|
6643
|
+
"./creates/src/routes/(app)/teams/new/+page.server.ts": ih,
|
|
6644
|
+
"./creates/src/routes/(app)/teams/new/+page.svelte": ah,
|
|
6645
|
+
"./creates/src/routes/(app)/teams/new/+page.ts": oh,
|
|
6646
|
+
"./creates/src/routes/(app)/teams/new/server.test.ts": sh,
|
|
6647
|
+
"./creates/src/routes/(app)/teams/server.test.ts": ch,
|
|
6648
|
+
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": lh,
|
|
6649
|
+
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts": uh
|
|
6650
|
+
}), fh = "./creates/";
|
|
6651
|
+
async function ph(e) {
|
|
6640
6652
|
return {
|
|
6641
|
-
creates: Object.entries(
|
|
6642
|
-
let n = D(e,
|
|
6653
|
+
creates: Object.entries(dh).map(([e, t]) => {
|
|
6654
|
+
let n = D(e, fh);
|
|
6643
6655
|
return {
|
|
6644
6656
|
path: n,
|
|
6645
6657
|
language: w(n),
|
|
@@ -6669,8 +6681,8 @@ async function fh(e) {
|
|
|
6669
6681
|
};
|
|
6670
6682
|
}
|
|
6671
6683
|
// src/patterns/enable/teams/preview-modifies/src/lib/components/app-sidebar.svelte?raw
|
|
6672
|
-
var
|
|
6673
|
-
function
|
|
6684
|
+
var mh = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import type { ComponentProps } from 'svelte';\n import HomeIcon from '@lucide/svelte/icons/home';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\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/index.js';\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 team,\n teams = [],\n ref = $bindable(null),\n ...restProps\n }: ComponentProps<typeof Sidebar.Root> & {\n user: 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} 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\">{site.name}</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", hh = "<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 UserAvatar from '#lib/components/user-avatar.svelte';\n import { displayName, type UserIdentity } from '#lib/user.js';\n import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\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: UserIdentity & {\n id: 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 <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</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 <UserAvatar {user} class=\"size-8 rounded-lg\" fallbackClass=\"rounded-lg\" />\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{displayName(user)}</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", gh = "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", _h = "<script lang=\"ts\">\n import * as Sidebar from '#lib/components/ui/sidebar/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import AppSidebar from '#lib/components/app-sidebar.svelte';\n import * as Breadcrumb from '#lib/components/ui/breadcrumb/index.js';\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} 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", vh = "users", yh = "teams", bh = "team_memberships";
|
|
6685
|
+
function xh(e) {
|
|
6674
6686
|
let t = Lr.find((t) => t.collectionName === e);
|
|
6675
6687
|
if (!t) throw Error(`teams: missing TEAM_RULE_PATCHES entry for "${e}"`);
|
|
6676
6688
|
return {
|
|
@@ -6681,11 +6693,11 @@ function bh(e) {
|
|
|
6681
6693
|
deleteRule: t.deleteRule
|
|
6682
6694
|
};
|
|
6683
6695
|
}
|
|
6684
|
-
var
|
|
6696
|
+
var Sh = [
|
|
6685
6697
|
{
|
|
6686
6698
|
name: "teams",
|
|
6687
6699
|
type: "base",
|
|
6688
|
-
...
|
|
6700
|
+
...xh("teams"),
|
|
6689
6701
|
fields: [
|
|
6690
6702
|
{
|
|
6691
6703
|
name: "id",
|
|
@@ -6706,7 +6718,7 @@ var xh = [
|
|
|
6706
6718
|
name: "owner",
|
|
6707
6719
|
type: "relation",
|
|
6708
6720
|
cascadeDelete: !1,
|
|
6709
|
-
collectionId:
|
|
6721
|
+
collectionId: vh,
|
|
6710
6722
|
maxSelect: 1,
|
|
6711
6723
|
minSelect: 0,
|
|
6712
6724
|
required: !0
|
|
@@ -6728,7 +6740,7 @@ var xh = [
|
|
|
6728
6740
|
{
|
|
6729
6741
|
name: "team_memberships",
|
|
6730
6742
|
type: "base",
|
|
6731
|
-
...
|
|
6743
|
+
...xh("team_memberships"),
|
|
6732
6744
|
fields: [
|
|
6733
6745
|
{
|
|
6734
6746
|
name: "id",
|
|
@@ -6743,7 +6755,7 @@ var xh = [
|
|
|
6743
6755
|
{
|
|
6744
6756
|
name: "team",
|
|
6745
6757
|
cascadeDelete: !0,
|
|
6746
|
-
collectionId:
|
|
6758
|
+
collectionId: yh,
|
|
6747
6759
|
maxSelect: 1,
|
|
6748
6760
|
minSelect: 0,
|
|
6749
6761
|
required: !0,
|
|
@@ -6752,7 +6764,7 @@ var xh = [
|
|
|
6752
6764
|
{
|
|
6753
6765
|
name: "user",
|
|
6754
6766
|
cascadeDelete: !0,
|
|
6755
|
-
collectionId:
|
|
6767
|
+
collectionId: vh,
|
|
6756
6768
|
maxSelect: 1,
|
|
6757
6769
|
minSelect: 0,
|
|
6758
6770
|
required: !0,
|
|
@@ -6786,7 +6798,7 @@ var xh = [
|
|
|
6786
6798
|
{
|
|
6787
6799
|
name: "team_users",
|
|
6788
6800
|
type: "view",
|
|
6789
|
-
...
|
|
6801
|
+
...xh("team_users"),
|
|
6790
6802
|
viewQuery: "select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;",
|
|
6791
6803
|
fields: [
|
|
6792
6804
|
{
|
|
@@ -6812,7 +6824,7 @@ var xh = [
|
|
|
6812
6824
|
{
|
|
6813
6825
|
name: "membership_id",
|
|
6814
6826
|
cascadeDelete: !1,
|
|
6815
|
-
collectionId:
|
|
6827
|
+
collectionId: bh,
|
|
6816
6828
|
maxSelect: 1,
|
|
6817
6829
|
minSelect: 0,
|
|
6818
6830
|
required: !1,
|
|
@@ -6821,7 +6833,7 @@ var xh = [
|
|
|
6821
6833
|
{
|
|
6822
6834
|
name: "team",
|
|
6823
6835
|
cascadeDelete: !0,
|
|
6824
|
-
collectionId:
|
|
6836
|
+
collectionId: yh,
|
|
6825
6837
|
maxSelect: 1,
|
|
6826
6838
|
minSelect: 0,
|
|
6827
6839
|
required: !0,
|
|
@@ -6843,7 +6855,7 @@ var xh = [
|
|
|
6843
6855
|
{
|
|
6844
6856
|
name: "team_invites",
|
|
6845
6857
|
type: "base",
|
|
6846
|
-
...
|
|
6858
|
+
...xh("team_invites"),
|
|
6847
6859
|
fields: [
|
|
6848
6860
|
{
|
|
6849
6861
|
name: "id",
|
|
@@ -6859,7 +6871,7 @@ var xh = [
|
|
|
6859
6871
|
name: "team",
|
|
6860
6872
|
type: "relation",
|
|
6861
6873
|
cascadeDelete: !0,
|
|
6862
|
-
collectionId:
|
|
6874
|
+
collectionId: yh,
|
|
6863
6875
|
maxSelect: 1,
|
|
6864
6876
|
minSelect: 0,
|
|
6865
6877
|
required: !0
|
|
@@ -6886,7 +6898,7 @@ var xh = [
|
|
|
6886
6898
|
{
|
|
6887
6899
|
name: "team_invite_links",
|
|
6888
6900
|
type: "base",
|
|
6889
|
-
...
|
|
6901
|
+
...xh("team_invite_links"),
|
|
6890
6902
|
indexes: ["CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)"],
|
|
6891
6903
|
fields: [
|
|
6892
6904
|
{
|
|
@@ -6902,7 +6914,7 @@ var xh = [
|
|
|
6902
6914
|
{
|
|
6903
6915
|
name: "team",
|
|
6904
6916
|
cascadeDelete: !0,
|
|
6905
|
-
collectionId:
|
|
6917
|
+
collectionId: yh,
|
|
6906
6918
|
maxSelect: 1,
|
|
6907
6919
|
minSelect: 0,
|
|
6908
6920
|
required: !0,
|
|
@@ -6922,17 +6934,17 @@ var xh = [
|
|
|
6922
6934
|
}
|
|
6923
6935
|
]
|
|
6924
6936
|
}
|
|
6925
|
-
],
|
|
6926
|
-
"./preview-modifies/src/lib/components/app-sidebar.svelte":
|
|
6927
|
-
"./preview-modifies/src/lib/components/nav-user.svelte":
|
|
6928
|
-
"./preview-modifies/src/routes/(app)/+layout.server.ts":
|
|
6929
|
-
"./preview-modifies/src/routes/(app)/+layout.svelte":
|
|
6930
|
-
}),
|
|
6931
|
-
async function
|
|
6937
|
+
], Ch = /* #__PURE__ */ Object.assign({
|
|
6938
|
+
"./preview-modifies/src/lib/components/app-sidebar.svelte": mh,
|
|
6939
|
+
"./preview-modifies/src/lib/components/nav-user.svelte": hh,
|
|
6940
|
+
"./preview-modifies/src/routes/(app)/+layout.server.ts": gh,
|
|
6941
|
+
"./preview-modifies/src/routes/(app)/+layout.svelte": _h
|
|
6942
|
+
}), wh = "./preview-modifies/";
|
|
6943
|
+
async function Th(e) {
|
|
6932
6944
|
return {
|
|
6933
6945
|
creates: [],
|
|
6934
|
-
modifies: Object.entries(
|
|
6935
|
-
let n = D(e,
|
|
6946
|
+
modifies: Object.entries(Ch).map(([e, t]) => {
|
|
6947
|
+
let n = D(e, wh);
|
|
6936
6948
|
return {
|
|
6937
6949
|
path: n,
|
|
6938
6950
|
language: w(n),
|
|
@@ -6943,27 +6955,27 @@ async function wh(e) {
|
|
|
6943
6955
|
deletes: [],
|
|
6944
6956
|
components: [],
|
|
6945
6957
|
packages: [],
|
|
6946
|
-
collections:
|
|
6958
|
+
collections: Sh,
|
|
6947
6959
|
collectionPatches: [],
|
|
6948
6960
|
collectionDrops: []
|
|
6949
6961
|
};
|
|
6950
6962
|
}
|
|
6951
6963
|
// src/patterns/enable/teams/index.ts
|
|
6952
|
-
var
|
|
6953
|
-
async function
|
|
6954
|
-
let t = await
|
|
6964
|
+
var Eh = "enable-teams", Dh = "1.1.1", Oh = "src/patterns/enable/teams", kh = "/enable/teams";
|
|
6965
|
+
async function Ah(e) {
|
|
6966
|
+
let t = await ph(e);
|
|
6955
6967
|
if (e.env === "preview") {
|
|
6956
|
-
let n = await
|
|
6968
|
+
let n = await Th(e);
|
|
6957
6969
|
return S(T([t, n]), e);
|
|
6958
6970
|
}
|
|
6959
|
-
let { generate: n } = await import("./chunks/generate.runtime-YFyuyFhh.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
6971
|
+
let { generate: n } = await import("./chunks/generate.runtime-YFyuyFhh.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
6960
6972
|
return i(await S(T([t, r]), e), e);
|
|
6961
6973
|
}
|
|
6962
|
-
var
|
|
6963
|
-
version:
|
|
6964
|
-
slug:
|
|
6965
|
-
source:
|
|
6966
|
-
docs:
|
|
6974
|
+
var jh = {
|
|
6975
|
+
version: Dh,
|
|
6976
|
+
slug: Eh,
|
|
6977
|
+
source: Oh,
|
|
6978
|
+
docs: kh,
|
|
6967
6979
|
plan: "pro",
|
|
6968
6980
|
title: "Enable teams",
|
|
6969
6981
|
summary: "Adds multi-tenant teams with memberships, invites, and a sidebar team switcher.",
|
|
@@ -6997,23 +7009,23 @@ var Ah = {
|
|
|
6997
7009
|
examples: [],
|
|
6998
7010
|
tests: 36,
|
|
6999
7011
|
baseline: "velastack",
|
|
7000
|
-
generate:
|
|
7001
|
-
}, jh = "/**\n * WhatsApp one-time code auth, from the pocketbase-whatsapp plugin that\n * velabase ships. The SDK has no methods for it, so these call the plugin\n * routes directly.\n */\n\n/**\n * The `whatsapp` entry the plugin adds to `listAuthMethods()`.\n *\n * Vanilla PocketBase has no such entry, which reads as disabled.\n */\nexport type WhatsAppAuthMethod = {\n enabled: boolean;\n /**\n * Whether unknown numbers can sign up. Plugin versions without the flag\n * leave it out, which hides WhatsApp on the signup page.\n */\n allowSignup?: boolean;\n codeLength: number;\n duration: number;\n};\n\nexport function whatsappAuthMethod(authMethods: object): WhatsAppAuthMethod {\n const whatsapp = (authMethods as { whatsapp?: WhatsAppAuthMethod })\n .whatsapp;\n return whatsapp ?? { enabled: false, codeLength: 6, duration: 300 };\n}\n\n/**\n * Sends a code to `phone` (international format, eg. +16165550123).\n *\n * Unknown numbers still get an `otpId` when signup is off, so the response\n * never tells whether the number has an account.\n */\nexport async function requestWhatsAppOTP(\n pb: App.Locals[\"pb\"],\n phone: string,\n lang?: string,\n): Promise<{ otpId: string }> {\n return pb.send(\"/api/collections/users/request-whatsapp-otp\", {\n method: \"POST\",\n body: { phone, ...(lang ? { lang } : {}) },\n });\n}\n\n/**\n * Checks the code and signs `pb` in. `isNew` is true when the code created\n * the account (signup on), so the caller can run its new user setup.\n */\nexport async function authWithWhatsApp(\n pb: App.Locals[\"pb\"],\n otpId: string,\n code: string,\n): Promise<{ isNew: boolean }> {\n const auth = await pb.send(\"/api/collections/users/auth-with-whatsapp\", {\n method: \"POST\",\n body: { otpId, password: code },\n });\n // Unlike the SDK auth methods, `send` leaves the auth store alone.\n pb.authStore.save(auth.token, auth.record);\n return { isNew: !!auth.meta?.isNew };\n}\n", Mh = "import { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { otpSchema } from \"#lib/schemas/otp.js\";\nimport { authWithWhatsApp } from \"#lib/server/whatsapp.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(otpSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies, url }) => {\n const form = await superValidate(request, zod4(otpSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let isNew: boolean;\n try {\n // `isNew` is true when this code created the account.\n ({ isNew } = await authWithWhatsApp(\n locals.pb,\n params.token,\n form.data.otp,\n ));\n } catch (error: any) {\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to verify the code.\",\n },\n { status: 400 },\n );\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl =\n next && /^\\/(?![/\\\\])/.test(next) ? next : \"/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 // A new account has only the phone number: ask for a name first.\n redirect(\n 303,\n isNew\n ? `/welcome?redirect=${encodeURIComponent(redirectUrl)}`\n : redirectUrl,\n );\n },\n};\n", Nh = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { otpSchema } from '#lib/schemas/otp.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(otpSchema)\n }\n );\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col 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} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\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\">Check your WhatsApp</Card.Title>\n <Card.Description>Enter the code we sent to your WhatsApp</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 <Form.Field {form} name=\"otp\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Code</Form.Label>\n <Input\n {...props}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n bind:value={$formData.otp}\n required\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === 'error'}\n <div class=\"text-destructive text-sm font-medium -mt-2\">{$message.text}</div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Ph = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", Fh = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /whatsapp/[token]\", () => {\n it(\"should render the code page\", async (context) => {\n const response = await context.request.get(\n \"/whatsapp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /whatsapp/[token]\", () => {\n it(\"should throw an error if the code is invalid\", async (context) => {\n const response = await context.agent\n .post(\"/whatsapp/123456\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ otp: \"123456\" });\n expect(response.body.status).toBe(400);\n });\n});\n", Ih = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", Lh = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { otpForm } from \"./form.remote\";\n<\/script>\n\n<div class=\"h-full flex flex-col 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} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\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\">Check your WhatsApp</Card.Title>\n <Card.Description\n >Enter the code we sent to your WhatsApp</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...otpForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"otp\" class=\"text-sm font-medium\">Code</label>\n <Input\n id=\"otp\"\n {...otpForm.fields.otp.as(\"text\")}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n required\n autofocus\n />\n {#each otpForm.fields.otp.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if otpForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {otpForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Rh = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", zh = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { otpSchema } from \"#lib/schemas/otp.js\";\nimport { authWithWhatsApp } from \"#lib/server/whatsapp.js\";\n\nexport const otpForm = form(otpSchema, async (data) => {\n const { locals, cookies, params, url } = getRequestEvent();\n\n let isNew: boolean;\n try {\n // `isNew` is true when this code created the account.\n ({ isNew } = await authWithWhatsApp(\n locals.pb,\n params.token as string,\n data.otp,\n ));\n } catch (err: any) {\n return {\n message: (err.response?.message as string) ?? \"Failed to verify code.\",\n };\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl =\n next && /^\\/(?![/\\\\])/.test(next) ? next : \"/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 // A new account has only the phone number: ask for a name first.\n redirect(\n 303,\n isNew\n ? `/welcome?redirect=${encodeURIComponent(redirectUrl)}`\n : redirectUrl,\n );\n});\n", Bh = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /whatsapp/[token]\", () => {\n it(\"should render the code page\", async (context) => {\n const response = await context.request.get(\n \"/whatsapp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Vh = /* #__PURE__ */ Object.assign({ "./creates/src/lib/server/whatsapp.ts": jh }), Hh = /* #__PURE__ */ Object.assign({
|
|
7002
|
-
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
7003
|
-
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
7004
|
-
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
7005
|
-
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
7006
|
-
}),
|
|
7007
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
7008
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
7009
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
7010
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts":
|
|
7011
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
7012
|
+
generate: Ah
|
|
7013
|
+
}, Mh = "/**\n * WhatsApp one-time code auth, from the pocketbase-whatsapp plugin that\n * velabase ships. The SDK has no methods for it, so these call the plugin\n * routes directly.\n */\n\n/**\n * The `whatsapp` entry the plugin adds to `listAuthMethods()`.\n *\n * Vanilla PocketBase has no such entry, which reads as disabled.\n */\nexport type WhatsAppAuthMethod = {\n enabled: boolean;\n /**\n * Whether unknown numbers can sign up. Plugin versions without the flag\n * leave it out, which hides WhatsApp on the signup page.\n */\n allowSignup?: boolean;\n codeLength: number;\n duration: number;\n};\n\nexport function whatsappAuthMethod(authMethods: object): WhatsAppAuthMethod {\n const whatsapp = (authMethods as { whatsapp?: WhatsAppAuthMethod })\n .whatsapp;\n return whatsapp ?? { enabled: false, codeLength: 6, duration: 300 };\n}\n\n/**\n * Sends a code to `phone` (international format, eg. +16165550123).\n *\n * Unknown numbers still get an `otpId` when signup is off, so the response\n * never tells whether the number has an account.\n */\nexport async function requestWhatsAppOTP(\n pb: App.Locals[\"pb\"],\n phone: string,\n lang?: string,\n): Promise<{ otpId: string }> {\n return pb.send(\"/api/collections/users/request-whatsapp-otp\", {\n method: \"POST\",\n body: { phone, ...(lang ? { lang } : {}) },\n });\n}\n\n/**\n * Checks the code and signs `pb` in. `isNew` is true when the code created\n * the account (signup on), so the caller can run its new user setup.\n */\nexport async function authWithWhatsApp(\n pb: App.Locals[\"pb\"],\n otpId: string,\n code: string,\n): Promise<{ isNew: boolean }> {\n const auth = await pb.send(\"/api/collections/users/auth-with-whatsapp\", {\n method: \"POST\",\n body: { otpId, password: code },\n });\n // Unlike the SDK auth methods, `send` leaves the auth store alone.\n pb.authStore.save(auth.token, auth.record);\n return { isNew: !!auth.meta?.isNew };\n}\n", Nh = "import { fail, message, superValidate } from \"sveltekit-superforms\";\nimport { zod4 } from \"sveltekit-superforms/adapters\";\nimport { otpSchema } from \"#lib/schemas/otp.js\";\nimport { authWithWhatsApp } from \"#lib/server/whatsapp.js\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return { form: await superValidate(zod4(otpSchema)) };\n};\n\nexport const actions = {\n default: async ({ locals, request, params, cookies, url }) => {\n const form = await superValidate(request, zod4(otpSchema));\n\n if (!form.valid) {\n return fail(400, { form });\n }\n\n let isNew: boolean;\n try {\n // `isNew` is true when this code created the account.\n ({ isNew } = await authWithWhatsApp(\n locals.pb,\n params.token,\n form.data.otp,\n ));\n } catch (error: any) {\n return message(\n form,\n {\n type: \"error\",\n text: error.response?.message ?? \"Failed to verify the code.\",\n },\n { status: 400 },\n );\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl =\n next && /^\\/(?![/\\\\])/.test(next) ? next : \"/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 // A new account has only the phone number: ask for a name first.\n redirect(\n 303,\n isNew\n ? `/welcome?redirect=${encodeURIComponent(redirectUrl)}`\n : redirectUrl,\n );\n },\n};\n", Ph = "<script lang=\"ts\">\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { untrack } from 'svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import * as Card from '#lib/components/ui/card/index.js';\n import { superForm } from 'sveltekit-superforms';\n import { zod4Client } from 'sveltekit-superforms/adapters';\n import { otpSchema } from '#lib/schemas/otp.js';\n import * as Form from '#lib/components/ui/form/index.js';\n import { Input } from '#lib/components/ui/input/index.js';\n\n let { data } = $props();\n\n const form = superForm(\n untrack(() => data.form),\n {\n validators: zod4Client(otpSchema)\n }\n );\n\n const { form: formData, message } = form;\n<\/script>\n\n<div class=\"h-full flex flex-col 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} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\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\">Check your WhatsApp</Card.Title>\n <Card.Description>Enter the code we sent to your WhatsApp</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 <Form.Field {form} name=\"otp\" class=\"col-span-1\">\n <Form.Control>\n {#snippet children({ props })}\n <Form.Label>Code</Form.Label>\n <Input\n {...props}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n bind:value={$formData.otp}\n required\n autofocus\n />\n {/snippet}\n </Form.Control>\n <Form.FieldErrors class=\"contents text-destructive\" />\n </Form.Field>\n\n {#if $message && $message.type === 'error'}\n <div class=\"text-destructive text-sm font-medium -mt-2\">{$message.text}</div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", Fh = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", Ih = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /whatsapp/[token]\", () => {\n it(\"should render the code page\", async (context) => {\n const response = await context.request.get(\n \"/whatsapp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n\ndescribe(\"POST /whatsapp/[token]\", () => {\n it(\"should throw an error if the code is invalid\", async (context) => {\n const response = await context.agent\n .post(\"/whatsapp/123456\" satisfies Match<RouteId>)\n .type(\"form\")\n .send({ otp: \"123456\" });\n expect(response.body.status).toBe(400);\n });\n});\n", Lh = "import { redirect } from \"@sveltejs/kit\";\n\nexport const load = async ({ locals }) => {\n if (locals.pb.authStore.isValid) {\n redirect(303, \"/dashboard\");\n }\n\n return {};\n};\n", Rh = "<script lang=\"ts\">\n import favicon from \"#lib/assets/favicon.svg\";\n import { site } from \"#lib/site.js\";\n\n import { Button } from \"#lib/components/ui/button/index.js\";\n import * as Card from \"#lib/components/ui/card/index.js\";\n import { Input } from \"#lib/components/ui/input/index.js\";\n import { otpForm } from \"./form.remote\";\n<\/script>\n\n<div class=\"h-full flex flex-col 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} alt=\"logo\" class=\"size-4\" />\n </div>\n {site.name}\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\">Check your WhatsApp</Card.Title>\n <Card.Description\n >Enter the code we sent to your WhatsApp</Card.Description\n >\n </Card.Header>\n <Card.Content>\n <form {...otpForm}>\n <div class=\"grid gap-6\">\n <div class=\"grid gap-2\">\n <div class=\"space-y-2 col-span-1\">\n <label for=\"otp\" class=\"text-sm font-medium\">Code</label>\n <Input\n id=\"otp\"\n {...otpForm.fields.otp.as(\"text\")}\n type=\"text\"\n inputmode=\"numeric\"\n autocomplete=\"one-time-code\"\n required\n autofocus\n />\n {#each otpForm.fields.otp.issues() as issue}\n <p class=\"text-destructive text-sm\">{issue.message}</p>\n {/each}\n </div>\n\n {#if otpForm.result?.message}\n <div class=\"text-destructive text-sm font-medium -mt-2\">\n {otpForm.result.message}\n </div>\n {/if}\n\n <Button type=\"submit\" class=\"w-full\">Verify code</Button>\n </div>\n </div>\n </form>\n </Card.Content>\n </Card.Root>\n </div>\n </div>\n</div>\n", zh = "import { definePageMetaTags } from 'svelte-meta-tags';\n\nexport const load = async ({ parent, data }) => {\n await parent();\n\n const { pageMetaTags } = definePageMetaTags({\n title: 'Verify code'\n });\n\n return { ...data, pageMetaTags };\n};\n", Bh = "import { form, getRequestEvent } from \"$app/server\";\nimport { redirect } from \"@sveltejs/kit\";\nimport { dev } from \"$app/env\";\nimport { otpSchema } from \"#lib/schemas/otp.js\";\nimport { authWithWhatsApp } from \"#lib/server/whatsapp.js\";\n\nexport const otpForm = form(otpSchema, async (data) => {\n const { locals, cookies, params, url } = getRequestEvent();\n\n let isNew: boolean;\n try {\n // `isNew` is true when this code created the account.\n ({ isNew } = await authWithWhatsApp(\n locals.pb,\n params.token as string,\n data.otp,\n ));\n } catch (err: any) {\n return {\n message: (err.response?.message as string) ?? \"Failed to verify code.\",\n };\n }\n\n // Follow only a same-site path (`/x`, not `//host` or `/\\host`):\n // `redirect()` throws on an external URL.\n const next = url.searchParams.get(\"redirect\");\n const redirectUrl =\n next && /^\\/(?![/\\\\])/.test(next) ? next : \"/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 // A new account has only the phone number: ask for a name first.\n redirect(\n 303,\n isNew\n ? `/welcome?redirect=${encodeURIComponent(redirectUrl)}`\n : redirectUrl,\n );\n});\n", Vh = "import { describe, it, expect } from \"vitest\";\nimport type { Match } from \"@velastack/kit\";\nimport type { RouteId } from \"./$types\";\n\ndescribe(\"GET /whatsapp/[token]\", () => {\n it(\"should render the code page\", async (context) => {\n const response = await context.request.get(\n \"/whatsapp/123456\" satisfies Match<RouteId>,\n );\n expect(response.status).toBe(200);\n });\n});\n", Hh = /* #__PURE__ */ Object.assign({ "./creates/src/lib/server/whatsapp.ts": Mh }), Uh = /* #__PURE__ */ Object.assign({
|
|
7014
|
+
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Nh,
|
|
7015
|
+
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Ph,
|
|
7016
|
+
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Fh,
|
|
7017
|
+
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Ih
|
|
7018
|
+
}), Wh = /* #__PURE__ */ Object.assign({
|
|
7019
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Lh,
|
|
7020
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Rh,
|
|
7021
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": zh,
|
|
7022
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts": Bh,
|
|
7023
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Vh
|
|
7012
7024
|
});
|
|
7013
|
-
async function
|
|
7025
|
+
async function Gh(e, t = "superforms") {
|
|
7014
7026
|
let n = {
|
|
7015
|
-
...E(
|
|
7016
|
-
...t === "remote" ? E(
|
|
7027
|
+
...E(Hh, "./creates/"),
|
|
7028
|
+
...t === "remote" ? E(Wh, "./creates-remote/") : E(Uh, "./creates-superforms/")
|
|
7017
7029
|
};
|
|
7018
7030
|
return {
|
|
7019
7031
|
creates: Object.values(n).sort((e, t) => e.path.localeCompare(t.path)),
|
|
@@ -7027,7 +7039,7 @@ async function Wh(e, t = "superforms") {
|
|
|
7027
7039
|
};
|
|
7028
7040
|
}
|
|
7029
7041
|
// src/patterns/enable/whatsapp/generate.preview.ts
|
|
7030
|
-
var
|
|
7042
|
+
var Kh = /* #__PURE__ */ Object.assign({
|
|
7031
7043
|
"./templates/base/src/lib/schemas/login.ts": En,
|
|
7032
7044
|
"./templates/base/src/lib/schemas/signup.ts": Vt,
|
|
7033
7045
|
"./templates/base/src/routes/(public)/(auth)/login/+page.server.ts": un,
|
|
@@ -7035,10 +7047,10 @@ var Gh = /* #__PURE__ */ Object.assign({
|
|
|
7035
7047
|
"./templates/base/src/routes/(public)/(auth)/signup/+page.server.ts": Cn,
|
|
7036
7048
|
"./templates/base/src/routes/(public)/(auth)/signup/+page.svelte": Bn
|
|
7037
7049
|
});
|
|
7038
|
-
async function
|
|
7050
|
+
async function qh(e) {
|
|
7039
7051
|
return {
|
|
7040
7052
|
creates: [],
|
|
7041
|
-
modifies: Object.values(E(
|
|
7053
|
+
modifies: Object.values(E(Kh, "./templates/base/")).sort((e, t) => e.path.localeCompare(t.path)),
|
|
7042
7054
|
deletes: [],
|
|
7043
7055
|
components: [],
|
|
7044
7056
|
packages: [],
|
|
@@ -7048,24 +7060,24 @@ async function Kh(e) {
|
|
|
7048
7060
|
};
|
|
7049
7061
|
}
|
|
7050
7062
|
// src/patterns/enable/whatsapp/index.ts
|
|
7051
|
-
var
|
|
7052
|
-
async function
|
|
7063
|
+
var Jh = "enable-whatsapp", Yh = "1.0.0", Xh = "src/patterns/enable/whatsapp", Zh = "/enable/whatsapp";
|
|
7064
|
+
async function Qh(e) {
|
|
7053
7065
|
if (e.env === "runtime" && !e.features.auth) throw new a("WhatsApp sign-in goes on the login and signup pages. Run `vela enable auth` first.");
|
|
7054
7066
|
if (e.env === "preview") {
|
|
7055
|
-
let t = await
|
|
7067
|
+
let t = await Gh(e), n = await qh(e);
|
|
7056
7068
|
return S(T([t, n]), e);
|
|
7057
7069
|
}
|
|
7058
|
-
let { detectMode: t } = await import("./chunks/auth-pages-BW3_yluN.js"), { keepMissing: n } = await import("./chunks/modify-file-CRZ_gMg0.js").then((e) => e.i), r = await
|
|
7070
|
+
let { detectMode: t } = await import("./chunks/auth-pages-BW3_yluN.js"), { keepMissing: n } = await import("./chunks/modify-file-CRZ_gMg0.js").then((e) => e.i), r = await Gh(e, t(e.root)), { generate: i } = await import("./chunks/generate.runtime-DkS7CBmK.js"), o = await i(e), { writeResult: s } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7059
7071
|
return s(await S(T([{
|
|
7060
7072
|
...r,
|
|
7061
7073
|
creates: n(r.creates, e.root)
|
|
7062
7074
|
}, o]), e), e);
|
|
7063
7075
|
}
|
|
7064
|
-
var
|
|
7065
|
-
version:
|
|
7066
|
-
slug:
|
|
7067
|
-
source:
|
|
7068
|
-
docs:
|
|
7076
|
+
var $h = {
|
|
7077
|
+
version: Yh,
|
|
7078
|
+
slug: Jh,
|
|
7079
|
+
source: Xh,
|
|
7080
|
+
docs: Zh,
|
|
7069
7081
|
plan: "open",
|
|
7070
7082
|
title: "Enable WhatsApp sign-in",
|
|
7071
7083
|
summary: "Adds sign-in and signup with a code sent on WhatsApp to the login and signup pages, next to email. Requires enable-auth.",
|
|
@@ -7100,19 +7112,19 @@ var Qh = {
|
|
|
7100
7112
|
examples: [],
|
|
7101
7113
|
tests: 2,
|
|
7102
7114
|
baseline: "velastack",
|
|
7103
|
-
generate:
|
|
7104
|
-
},
|
|
7115
|
+
generate: Qh
|
|
7116
|
+
}, eg = /* #__PURE__ */ Object.assign({
|
|
7105
7117
|
"./creates/src/lib/server/workflows.ts": "import process from 'node:process';\nimport { building } from '$app/env';\nimport {\n POCKETBASE_URL,\n POCKETBASE_SUPERUSER_EMAIL,\n POCKETBASE_SUPERUSER_PASSWORD,\n WORKFLOWS_ENABLED,\n WORKFLOWS_CONCURRENCY,\n TEST\n} from '$app/env/private';\nimport { Cron } from 'croner';\nimport { OpenWorkflow, type Worker } from 'openworkflow';\nimport { BackendPocketBase } from 'openworkflow-pocketbase';\nimport PocketBase from 'pocketbase-sveltekit';\n\n/**\n * Background workflows on the OpenWorkflow engine built into PocketBase.\n *\n * Define one in src/lib/workflows/<name>.ts with `ow.defineWorkflow(...)` and\n * start a run from any server code with `.run(input)`. The worker that `init`\n * in src/hooks.server.ts starts claims runs from PocketBase and executes them\n * in this process; every step's result is saved, so an interrupted run resumes\n * from the last completed step. See src/lib/workflows/README.md.\n */\n\nconst url = POCKETBASE_URL;\nconst email = POCKETBASE_SUPERUSER_EMAIL;\nconst password = POCKETBASE_SUPERUSER_PASSWORD;\n\n/** The OpenWorkflow client: `defineWorkflow`, `runWorkflow`, `cancelWorkflowRun`, `sendSignal`. */\nexport const ow = new OpenWorkflow({\n // Authenticates lazily and again after a 401, so constructing it costs nothing.\n backend: new BackendPocketBase({ url, email, password })\n});\n\nconst admin = new PocketBase(url);\nadmin.autoCancellation(false);\n\n/** A superuser client for workflow steps. Signs in on first use and again once the token expires. */\nexport async function getAdmin(): Promise<App.Locals['admin']> {\n if (!admin.authStore.isValid) {\n await admin.collection('_superusers').authWithPassword(email, password);\n }\n return admin as App.Locals['admin'];\n}\n\n/**\n * Every workflow module, loaded on demand rather than eagerly: an eager glob is\n * hoisted above `ow`, and each module imports `ow` from this file.\n */\nconst modules = import.meta.glob(['../workflows/*.ts', '!../workflows/*.test.ts']);\n\ninterface Runnable {\n run(input?: undefined, options?: { idempotencyKey?: string }): Promise<unknown>;\n workflow: { spec: { name: string } };\n}\n\nfunction isRunnable(value: unknown): value is Runnable {\n const candidate = value as Partial<Runnable> | null;\n return (\n typeof candidate === 'object' &&\n candidate !== null &&\n typeof candidate.run === 'function' &&\n typeof candidate.workflow?.spec?.name === 'string'\n );\n}\n\ninterface WorkflowModule {\n file: string;\n workflows: Runnable[];\n /** A cron expression: every workflow in the module runs on that schedule. */\n cron?: string;\n}\n\nasync function loadModules(): Promise<WorkflowModule[]> {\n return Promise.all(\n Object.entries(modules).map(async ([file, load]) => {\n const mod = (await load()) as Record<string, unknown>;\n return {\n file,\n workflows: Object.values(mod).filter(isRunnable),\n cron: typeof mod.cron === 'string' ? mod.cron : undefined\n };\n })\n );\n}\n\n/**\n * One run per workflow per minute, however many servers are running: the\n * idempotency key makes PocketBase return the existing run to the others.\n */\nasync function runRecurring(workflows: Runnable[], now: Date) {\n const minute = new Date(Math.floor(now.getTime() / 60_000) * 60_000).toISOString();\n for (const workflow of workflows) {\n const name = workflow.workflow.spec.name;\n try {\n await workflow.run(undefined, { idempotencyKey: `cron:${name}:${minute}` });\n } catch (error) {\n console.error(`[workflows] could not start ${name}:`, error);\n }\n }\n}\n\n/** Starts every recurring workflow now, as if each schedule had just fired. For tests. */\nexport async function tickCron(now = new Date()) {\n for (const mod of await loadModules()) {\n if (mod.cron) await runRecurring(mod.workflows, now);\n }\n}\n\ninterface Running {\n worker: Worker;\n stop: () => Promise<void>;\n}\n\n// Keyed on globalThis: in development Vite re-evaluates this module when a\n// workflow file changes, and the previous worker must stop polling.\nconst KEY = Symbol.for('velastack.workflows');\nconst state = globalThis as { [KEY]?: Running };\n\n/**\n * Starts the worker for this process. Returns without doing anything when\n * there are no workflow modules, during `vela build`, or when\n * WORKFLOWS_ENABLED=false, so a project that has no workflows never polls.\n */\nexport async function startWorker() {\n if (building || process.env.VITE_BUILD === 'true') return;\n if (WORKFLOWS_ENABLED === 'false' || !url) return;\n if (Object.keys(modules).length === 0) return;\n\n const loaded = await loadModules();\n const names = loaded.flatMap((mod) => mod.workflows.map((w) => w.workflow.spec.name));\n if (names.length === 0) return;\n\n // Not awaited: runs in flight finish on the old code, new claims stop now.\n void state[KEY]?.stop();\n\n const worker = ow.newWorker({ concurrency: Number(WORKFLOWS_CONCURRENCY || 5) });\n const crons =\n TEST === 'true'\n ? []\n : loaded\n .filter((mod) => mod.cron)\n .map(\n (mod) =>\n new Cron(mod.cron!, { name: mod.file, protect: true, unref: true }, (job: Cron) =>\n runRecurring(mod.workflows, job.currentRun() ?? new Date())\n )\n );\n\n let stopped = false;\n const stop = async () => {\n if (stopped) return;\n stopped = true;\n process.off('sveltekit:shutdown', onShutdown);\n process.off('SIGINT', onShutdown);\n process.off('SIGTERM', onShutdown);\n for (const cron of crons) cron.stop();\n await worker.stop();\n console.log('[workflows] worker stopped');\n };\n const onShutdown = () => void stop();\n\n // adapter-node emits sveltekit:shutdown only once HTTP has drained; the\n // signals come first, so the worker drains alongside the requests.\n process.once('sveltekit:shutdown', onShutdown);\n process.once('SIGINT', onShutdown);\n process.once('SIGTERM', onShutdown);\n\n state[KEY] = { worker, stop };\n await worker.start();\n console.log(`[workflows] worker started: ${names.join(', ')}`);\n}\n\n/** Stops the worker started in this process, waiting for runs in flight. */\nexport async function stopWorker() {\n await state[KEY]?.stop();\n delete state[KEY];\n}\n",
|
|
7106
7118
|
"./creates/src/lib/workflows/README.md": "# Workflows\n\nBackground work that survives restarts. Each workflow runs on the OpenWorkflow engine built into PocketBase: every step's result is saved, a failed run retries with backoff, and an interrupted run resumes from its last completed step. Runs are listed under **Workflows** in the PocketBase dashboard.\n\nAdd one:\n\n```sh\nvela generate workflow send-welcome-email\n```\n\nThat writes `send-welcome-email.ts` here, along with a test:\n\n```ts\nimport { z } from 'zod';\nimport { ow } from '#lib/server/workflows.js';\n\nexport const sendWelcomeEmail = ow.defineWorkflow(\n {\n name: 'send-welcome-email',\n schema: z.object({ userId: z.string() }),\n retryPolicy: { maximumAttempts: 3 }\n },\n async ({ input, step }) => {\n await step.run({ name: 'send' }, async () => {\n // ...\n });\n }\n);\n```\n\nStart a run from any server code, such as a form action, an API route or another workflow:\n\n```ts\nawait sendWelcomeEmail.run({ userId: user.id }, { idempotencyKey: user.id });\n```\n\n`run()` returns as soon as the run is queued. The handle it returns has `result()` to wait for the output and `cancel()`. Pass `availableAt` to delay a run and `idempotencyKey` to make repeated calls reuse one run for 24 hours.\n\nRecurring work is a workflow whose file also exports a cron expression:\n\n```sh\nvela generate workflow sync-prices --cron '*/5 * * * *'\n```\n\nEvery workflow in that file starts on the schedule, once per minute across all servers.\n\nGood to know:\n\n- Steps are the unit of retry, so make each one safe to repeat.\n- A workflow gets one attempt unless `retryPolicy` says otherwise.\n- `getAdmin()` from `#lib/server/workflows.js` is a superuser client for use inside steps.\n- The worker runs inside the web server. `WORKFLOWS_CONCURRENCY` (default 5) caps parallel runs and `WORKFLOWS_ENABLED=false` turns the worker off for a process that should only queue runs.\n"
|
|
7107
|
-
}),
|
|
7119
|
+
}), tg = "./creates/", ng = [
|
|
7108
7120
|
m("openworkflow"),
|
|
7109
7121
|
m("openworkflow-pocketbase"),
|
|
7110
7122
|
m("croner")
|
|
7111
7123
|
];
|
|
7112
|
-
async function
|
|
7124
|
+
async function rg(e) {
|
|
7113
7125
|
return {
|
|
7114
|
-
creates: Object.entries(
|
|
7115
|
-
let n = D(e,
|
|
7126
|
+
creates: Object.entries(eg).map(([e, t]) => {
|
|
7127
|
+
let n = D(e, tg);
|
|
7116
7128
|
return {
|
|
7117
7129
|
path: n,
|
|
7118
7130
|
language: w(n),
|
|
@@ -7123,19 +7135,19 @@ async function ng(e) {
|
|
|
7123
7135
|
modifies: [],
|
|
7124
7136
|
deletes: [],
|
|
7125
7137
|
components: [],
|
|
7126
|
-
packages:
|
|
7138
|
+
packages: ng,
|
|
7127
7139
|
collections: [],
|
|
7128
7140
|
collectionPatches: [],
|
|
7129
7141
|
collectionDrops: []
|
|
7130
7142
|
};
|
|
7131
7143
|
}
|
|
7132
7144
|
// src/patterns/enable/workflows/generate.preview.ts
|
|
7133
|
-
var
|
|
7134
|
-
async function
|
|
7145
|
+
var ig = /* #__PURE__ */ Object.assign({ "./preview-modifies/src/hooks.server.ts": "import type { ServerInit } from '@sveltejs/kit/hooks';\nimport {\n POCKETBASE_URL,\n POCKETBASE_SUPERUSER_EMAIL,\n POCKETBASE_SUPERUSER_PASSWORD\n} from '$app/env/private';\nimport { handlePocketbase } from '@velastack/pocketbase';\nimport { startWorker } from '#lib/server/workflows.js';\n\nexport const handle = handlePocketbase({\n pocketbaseUrl: POCKETBASE_URL,\n superuserEmail: POCKETBASE_SUPERUSER_EMAIL,\n superuserPassword: POCKETBASE_SUPERUSER_PASSWORD\n});\n\n// Runs once when the server starts: executes the workflows in src/lib/workflows.\nexport const init: ServerInit = () => startWorker();\n" }), ag = "./preview-modifies/";
|
|
7146
|
+
async function og(e) {
|
|
7135
7147
|
return {
|
|
7136
7148
|
creates: [],
|
|
7137
|
-
modifies: Object.entries(
|
|
7138
|
-
let n = D(e,
|
|
7149
|
+
modifies: Object.entries(ig).map(([e, t]) => {
|
|
7150
|
+
let n = D(e, ag);
|
|
7139
7151
|
return {
|
|
7140
7152
|
path: n,
|
|
7141
7153
|
language: w(n),
|
|
@@ -7157,21 +7169,21 @@ async function ag(e) {
|
|
|
7157
7169
|
};
|
|
7158
7170
|
}
|
|
7159
7171
|
// src/patterns/enable/workflows/index.ts
|
|
7160
|
-
var
|
|
7161
|
-
async function
|
|
7162
|
-
let t = await
|
|
7172
|
+
var sg = "enable-workflows", cg = "1.1.0", lg = "src/patterns/enable/workflows", ug = "/enable/workflows";
|
|
7173
|
+
async function dg(e) {
|
|
7174
|
+
let t = await rg(e);
|
|
7163
7175
|
if (e.env === "preview") {
|
|
7164
|
-
let n = await
|
|
7176
|
+
let n = await og(e);
|
|
7165
7177
|
return S(T([t, n]), e);
|
|
7166
7178
|
}
|
|
7167
|
-
let { generate: n } = await import("./chunks/generate.runtime-CyWuhV6m.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
7179
|
+
let { generate: n } = await import("./chunks/generate.runtime-CyWuhV6m.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7168
7180
|
return i(await S(T([t, r]), e), e);
|
|
7169
7181
|
}
|
|
7170
|
-
var
|
|
7171
|
-
version:
|
|
7172
|
-
slug:
|
|
7173
|
-
source:
|
|
7174
|
-
docs:
|
|
7182
|
+
var fg = {
|
|
7183
|
+
version: cg,
|
|
7184
|
+
slug: sg,
|
|
7185
|
+
source: lg,
|
|
7186
|
+
docs: ug,
|
|
7175
7187
|
plan: "open",
|
|
7176
7188
|
title: "Enable workflows",
|
|
7177
7189
|
summary: "Adds durable background workflows on the OpenWorkflow engine built into PocketBase: a worker started from hooks.server.ts, src/lib/workflows/ for workflow modules, and cron support for recurring ones.",
|
|
@@ -7205,10 +7217,10 @@ var dg = {
|
|
|
7205
7217
|
examples: [],
|
|
7206
7218
|
tests: 0,
|
|
7207
7219
|
baseline: "velastack",
|
|
7208
|
-
generate:
|
|
7220
|
+
generate: dg
|
|
7209
7221
|
};
|
|
7210
7222
|
// src/patterns/destroy/schema/generate.ts
|
|
7211
|
-
async function
|
|
7223
|
+
async function pg(e) {
|
|
7212
7224
|
let [t] = e.argv;
|
|
7213
7225
|
if (!t) throw new a("Invalid command arguments. Expected: <model>");
|
|
7214
7226
|
let n = `src/lib/schemas/${B(t).name}.ts`;
|
|
@@ -7229,18 +7241,18 @@ async function fg(e) {
|
|
|
7229
7241
|
};
|
|
7230
7242
|
}
|
|
7231
7243
|
// src/patterns/destroy/schema/index.ts
|
|
7232
|
-
var
|
|
7233
|
-
async function
|
|
7234
|
-
let t = await
|
|
7244
|
+
var mg = "destroy-schema", hg = "1.0.0", gg = "src/patterns/destroy/schema", _g = "/destroy/schema";
|
|
7245
|
+
async function vg(e) {
|
|
7246
|
+
let t = await pg(e), n = await S(t, e);
|
|
7235
7247
|
if (e.env !== "runtime" || e.input.destructive !== !0) return n;
|
|
7236
|
-
let { writeResult: r } = await import("./chunks/write-result-
|
|
7248
|
+
let { writeResult: r } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7237
7249
|
return r(n, e);
|
|
7238
7250
|
}
|
|
7239
|
-
var
|
|
7240
|
-
version:
|
|
7241
|
-
slug:
|
|
7242
|
-
source:
|
|
7243
|
-
docs:
|
|
7251
|
+
var yg = {
|
|
7252
|
+
version: hg,
|
|
7253
|
+
slug: mg,
|
|
7254
|
+
source: gg,
|
|
7255
|
+
docs: _g,
|
|
7244
7256
|
plan: "open",
|
|
7245
7257
|
title: "Destroy a schema",
|
|
7246
7258
|
summary: "Removes the zod schema file created by generate-schema.",
|
|
@@ -7273,9 +7285,9 @@ var vg = {
|
|
|
7273
7285
|
}],
|
|
7274
7286
|
tests: 0,
|
|
7275
7287
|
baseline: "velastack",
|
|
7276
|
-
generate:
|
|
7277
|
-
},
|
|
7278
|
-
async function
|
|
7288
|
+
generate: vg
|
|
7289
|
+
}, bg = "destroy-form", xg = "1.0.0", Sg = "src/patterns/destroy/form", Cg = "/destroy/form";
|
|
7290
|
+
async function wg(e) {
|
|
7279
7291
|
let [t] = e.argv;
|
|
7280
7292
|
if (!t) throw new a("Invalid command arguments. Expected: <model>");
|
|
7281
7293
|
let n = B(t), r = O(e.input.route, n, e, "form").fileBase, i = `src/lib/schemas/${n.name}.ts`, o = {
|
|
@@ -7289,14 +7301,14 @@ async function Cg(e) {
|
|
|
7289
7301
|
collectionDrops: []
|
|
7290
7302
|
}, s = await S(o, e);
|
|
7291
7303
|
if (e.env !== "runtime" || e.input.destructive !== !0) return s;
|
|
7292
|
-
let { writeResult: c } = await import("./chunks/write-result-
|
|
7304
|
+
let { writeResult: c } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7293
7305
|
return c(s, e);
|
|
7294
7306
|
}
|
|
7295
|
-
var
|
|
7296
|
-
version:
|
|
7297
|
-
slug:
|
|
7298
|
-
source:
|
|
7299
|
-
docs:
|
|
7307
|
+
var Tg = {
|
|
7308
|
+
version: xg,
|
|
7309
|
+
slug: bg,
|
|
7310
|
+
source: Sg,
|
|
7311
|
+
docs: Cg,
|
|
7300
7312
|
plan: "open",
|
|
7301
7313
|
title: "Destroy a form",
|
|
7302
7314
|
summary: "Removes the route directory and schema file created by generate-form.",
|
|
@@ -7332,9 +7344,9 @@ var wg = {
|
|
|
7332
7344
|
}],
|
|
7333
7345
|
tests: 0,
|
|
7334
7346
|
baseline: "velastack",
|
|
7335
|
-
generate:
|
|
7336
|
-
},
|
|
7337
|
-
async function
|
|
7347
|
+
generate: wg
|
|
7348
|
+
}, Eg = "destroy-resource", Dg = "1.0.0", Og = "src/patterns/destroy/resource", kg = "/destroy/resource";
|
|
7349
|
+
async function Ag(e) {
|
|
7338
7350
|
let [t] = e.argv;
|
|
7339
7351
|
if (!t) throw new a("Invalid command arguments. Expected: <model>");
|
|
7340
7352
|
let n = B(t), r = `src/lib/schemas/${n.name}.ts`, i = await zr([n.tableName], e), o = {
|
|
@@ -7348,14 +7360,14 @@ async function kg(e) {
|
|
|
7348
7360
|
collectionDrops: i
|
|
7349
7361
|
}, s = await S(o, e);
|
|
7350
7362
|
if (e.env !== "runtime" || e.input.destructive !== !0) return s;
|
|
7351
|
-
let { writeResult: c } = await import("./chunks/write-result-
|
|
7363
|
+
let { writeResult: c } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7352
7364
|
return c(s, e);
|
|
7353
7365
|
}
|
|
7354
|
-
var
|
|
7355
|
-
version:
|
|
7356
|
-
slug:
|
|
7357
|
-
source:
|
|
7358
|
-
docs:
|
|
7366
|
+
var jg = {
|
|
7367
|
+
version: Dg,
|
|
7368
|
+
slug: Eg,
|
|
7369
|
+
source: Og,
|
|
7370
|
+
docs: kg,
|
|
7359
7371
|
plan: "open",
|
|
7360
7372
|
title: "Destroy a resource",
|
|
7361
7373
|
summary: "Drops the collection and removes the schema file created by generate-resource.",
|
|
@@ -7388,9 +7400,9 @@ var Ag = {
|
|
|
7388
7400
|
}],
|
|
7389
7401
|
tests: 0,
|
|
7390
7402
|
baseline: "velastack",
|
|
7391
|
-
generate:
|
|
7392
|
-
},
|
|
7393
|
-
async function
|
|
7403
|
+
generate: Ag
|
|
7404
|
+
}, Mg = "destroy-scaffold", Ng = "1.0.0", Pg = "src/patterns/destroy/scaffold", Fg = "/destroy/scaffold";
|
|
7405
|
+
async function Ig(e) {
|
|
7394
7406
|
let [t] = e.argv;
|
|
7395
7407
|
if (!t) throw new a("Invalid command arguments. Expected: <model>");
|
|
7396
7408
|
let n = B(t), r = O(e.input.route, n, e, "scaffold"), i = Oe(r), o = `src/lib/schemas/${n.name}.ts`, s = await zr([n.tableName], e), c = {
|
|
@@ -7404,14 +7416,14 @@ async function Fg(e) {
|
|
|
7404
7416
|
collectionDrops: s
|
|
7405
7417
|
}, l = await S(c, e);
|
|
7406
7418
|
if (e.env !== "runtime" || e.input.destructive !== !0) return l;
|
|
7407
|
-
let { writeResult: u } = await import("./chunks/write-result-
|
|
7419
|
+
let { writeResult: u } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7408
7420
|
return u(l, e);
|
|
7409
7421
|
}
|
|
7410
|
-
var
|
|
7411
|
-
version:
|
|
7412
|
-
slug:
|
|
7413
|
-
source:
|
|
7414
|
-
docs:
|
|
7422
|
+
var Lg = {
|
|
7423
|
+
version: Ng,
|
|
7424
|
+
slug: Mg,
|
|
7425
|
+
source: Pg,
|
|
7426
|
+
docs: Fg,
|
|
7415
7427
|
plan: "open",
|
|
7416
7428
|
title: "Destroy a scaffold",
|
|
7417
7429
|
summary: "Removes the route directory and schema file created by generate-scaffold and drops the collection. Retains shadcn components.",
|
|
@@ -7448,8 +7460,8 @@ var Ig = {
|
|
|
7448
7460
|
}],
|
|
7449
7461
|
tests: 0,
|
|
7450
7462
|
baseline: "velastack",
|
|
7451
|
-
generate:
|
|
7452
|
-
},
|
|
7463
|
+
generate: Ig
|
|
7464
|
+
}, Rg = "destroy-shop", zg = "1.0.0", Bg = "src/patterns/destroy/shop", Vg = "/destroy/shop", Hg = /* #__PURE__ */ Object.assign({
|
|
7453
7465
|
"../../generate/shop/providers/shopify/src/routes/(public)/shop/+page.svelte": bc,
|
|
7454
7466
|
"../../generate/shop/providers/shopify/src/routes/(public)/shop/+page.ts": xc,
|
|
7455
7467
|
"../../generate/shop/providers/shopify/src/routes/(public)/shop/[handle]/+page.svelte": Sc,
|
|
@@ -7465,12 +7477,12 @@ var Ig = {
|
|
|
7465
7477
|
"../../generate/shop/providers-cms/whatsapp/src/routes/(public)/shop/+page.svelte": Mc,
|
|
7466
7478
|
"../../generate/shop/providers-cms/whatsapp/src/routes/(public)/shop/[id]/+page.svelte": Nc,
|
|
7467
7479
|
"../../generate/shop/providers-cms/whatsapp/src/routes/(public)/shop/[id]/+page.ts": Pc
|
|
7468
|
-
}),
|
|
7469
|
-
async function
|
|
7480
|
+
}), Ug = ve(Hg);
|
|
7481
|
+
async function Wg(e) {
|
|
7470
7482
|
let t = e.providers?.payments, n = {
|
|
7471
7483
|
creates: [],
|
|
7472
7484
|
modifies: [],
|
|
7473
|
-
deletes: (t ? ve(
|
|
7485
|
+
deletes: (t ? ve(Hg, t) : Ug).map(j),
|
|
7474
7486
|
components: [],
|
|
7475
7487
|
packages: [],
|
|
7476
7488
|
collections: [],
|
|
@@ -7478,14 +7490,14 @@ async function Ug(e) {
|
|
|
7478
7490
|
collectionDrops: []
|
|
7479
7491
|
}, r = await S(n, e);
|
|
7480
7492
|
if (e.env !== "runtime" || e.input.destructive !== !0) return r;
|
|
7481
|
-
let { writeResult: i } = await import("./chunks/write-result-
|
|
7493
|
+
let { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7482
7494
|
return i(r, e);
|
|
7483
7495
|
}
|
|
7484
|
-
var
|
|
7485
|
-
version:
|
|
7486
|
-
slug:
|
|
7487
|
-
source:
|
|
7488
|
-
docs:
|
|
7496
|
+
var Gg = {
|
|
7497
|
+
version: zg,
|
|
7498
|
+
slug: Rg,
|
|
7499
|
+
source: Bg,
|
|
7500
|
+
docs: Vg,
|
|
7489
7501
|
plan: "pro",
|
|
7490
7502
|
title: "Destroy a shop",
|
|
7491
7503
|
summary: "Removes the shop pages generate-shop wrote (and the catalog module on WhatsApp). The cart, payments and anything in Stripe, Shopify or the CMS stay.",
|
|
@@ -7516,21 +7528,21 @@ var Wg = {
|
|
|
7516
7528
|
examples: [],
|
|
7517
7529
|
tests: 0,
|
|
7518
7530
|
baseline: "velastack",
|
|
7519
|
-
generate:
|
|
7520
|
-
},
|
|
7521
|
-
async function
|
|
7531
|
+
generate: Wg
|
|
7532
|
+
}, Kg = "disable-ai", qg = "1.1.0", Jg = "src/patterns/disable/ai", Yg = "/disable/ai";
|
|
7533
|
+
async function Xg(e) {
|
|
7522
7534
|
let t = await Br(e);
|
|
7523
7535
|
if (e.env !== "runtime") return S(t, e);
|
|
7524
7536
|
let { generate: n } = await import("./chunks/generate.runtime-Dtae524O.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
7525
7537
|
if (e.input.destructive !== !0) return i;
|
|
7526
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
7538
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7527
7539
|
return a(i, e);
|
|
7528
7540
|
}
|
|
7529
|
-
var
|
|
7530
|
-
version:
|
|
7531
|
-
slug:
|
|
7532
|
-
source:
|
|
7533
|
-
docs:
|
|
7541
|
+
var Zg = {
|
|
7542
|
+
version: qg,
|
|
7543
|
+
slug: Kg,
|
|
7544
|
+
source: Jg,
|
|
7545
|
+
docs: Yg,
|
|
7534
7546
|
plan: "open",
|
|
7535
7547
|
title: "Disable AI",
|
|
7536
7548
|
summary: "Removes the AI SDK model module, the /api/chat endpoint and the /ai demo page, strips the provider's API key from .env and uninstalls the AI SDK packages.",
|
|
@@ -7565,21 +7577,21 @@ var Xg = {
|
|
|
7565
7577
|
examples: [],
|
|
7566
7578
|
tests: 0,
|
|
7567
7579
|
baseline: "velastack",
|
|
7568
|
-
generate:
|
|
7569
|
-
},
|
|
7570
|
-
async function
|
|
7580
|
+
generate: Xg
|
|
7581
|
+
}, Qg = "disable-analytics", $g = "1.1.0", e_ = "src/patterns/disable/analytics", t_ = "/disable/analytics";
|
|
7582
|
+
async function n_(e) {
|
|
7571
7583
|
let t = await Vr(e);
|
|
7572
7584
|
if (e.env !== "runtime") return S(t, e);
|
|
7573
7585
|
let { generate: n } = await import("./chunks/generate.runtime-Cco2mFW2.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
7574
7586
|
if (e.input.destructive !== !0) return i;
|
|
7575
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
7587
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7576
7588
|
return a(i, e);
|
|
7577
7589
|
}
|
|
7578
|
-
var
|
|
7579
|
-
version:
|
|
7580
|
-
slug:
|
|
7581
|
-
source:
|
|
7582
|
-
docs:
|
|
7590
|
+
var r_ = {
|
|
7591
|
+
version: $g,
|
|
7592
|
+
slug: Qg,
|
|
7593
|
+
source: e_,
|
|
7594
|
+
docs: t_,
|
|
7583
7595
|
plan: "open",
|
|
7584
7596
|
title: "Disable analytics",
|
|
7585
7597
|
summary: "Removes the analytics component and <Analytics /> from the root layout, strips the provider's variables from .env and uninstalls posthog-js.",
|
|
@@ -7612,10 +7624,10 @@ var n_ = {
|
|
|
7612
7624
|
examples: [],
|
|
7613
7625
|
tests: 0,
|
|
7614
7626
|
baseline: "velastack",
|
|
7615
|
-
generate:
|
|
7627
|
+
generate: n_
|
|
7616
7628
|
};
|
|
7617
7629
|
// src/patterns/disable/og/generate.ts
|
|
7618
|
-
async function
|
|
7630
|
+
async function i_(e) {
|
|
7619
7631
|
return {
|
|
7620
7632
|
creates: [],
|
|
7621
7633
|
modifies: [],
|
|
@@ -7629,20 +7641,20 @@ async function r_(e) {
|
|
|
7629
7641
|
};
|
|
7630
7642
|
}
|
|
7631
7643
|
// src/patterns/disable/og/index.ts
|
|
7632
|
-
var
|
|
7633
|
-
async function
|
|
7634
|
-
let t = await
|
|
7644
|
+
var a_ = "disable-og", o_ = "1.0.0", s_ = "src/patterns/disable/og", c_ = "/disable/og";
|
|
7645
|
+
async function l_(e) {
|
|
7646
|
+
let t = await i_(e);
|
|
7635
7647
|
if (e.env !== "runtime") return S(t, e);
|
|
7636
7648
|
let { generate: n } = await import("./chunks/generate.runtime-Cg-dfN9B.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
7637
7649
|
if (e.input.destructive !== !0) return i;
|
|
7638
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
7650
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7639
7651
|
return a(i, e);
|
|
7640
7652
|
}
|
|
7641
|
-
var
|
|
7642
|
-
version:
|
|
7643
|
-
slug:
|
|
7644
|
-
source:
|
|
7645
|
-
docs:
|
|
7653
|
+
var u_ = {
|
|
7654
|
+
version: o_,
|
|
7655
|
+
slug: a_,
|
|
7656
|
+
source: s_,
|
|
7657
|
+
docs: c_,
|
|
7646
7658
|
plan: "open",
|
|
7647
7659
|
title: "Disable Open Graph images",
|
|
7648
7660
|
summary: "Removes the share card, its route and renderer, takes withCard off the root layout and uninstalls @takumi-rs/core.",
|
|
@@ -7674,14 +7686,14 @@ var l_ = {
|
|
|
7674
7686
|
examples: [],
|
|
7675
7687
|
tests: 0,
|
|
7676
7688
|
baseline: "velastack",
|
|
7677
|
-
generate:
|
|
7678
|
-
},
|
|
7679
|
-
async function
|
|
7689
|
+
generate: l_
|
|
7690
|
+
}, d_ = /* #__PURE__ */ Object.assign({ "../../enable/api/creates/src/routes/api/server.test.ts": lu }), f_ = "../../enable/api/creates/";
|
|
7691
|
+
async function p_(e) {
|
|
7680
7692
|
return {
|
|
7681
7693
|
creates: [],
|
|
7682
7694
|
modifies: [],
|
|
7683
|
-
deletes: Object.keys(
|
|
7684
|
-
let t = D(e,
|
|
7695
|
+
deletes: Object.keys(d_).map((e) => {
|
|
7696
|
+
let t = D(e, f_);
|
|
7685
7697
|
return {
|
|
7686
7698
|
path: t,
|
|
7687
7699
|
language: w(t),
|
|
@@ -7697,20 +7709,20 @@ async function f_(e) {
|
|
|
7697
7709
|
};
|
|
7698
7710
|
}
|
|
7699
7711
|
// src/patterns/disable/api/index.ts
|
|
7700
|
-
var
|
|
7701
|
-
async function
|
|
7702
|
-
let t = await
|
|
7712
|
+
var m_ = "disable-api", h_ = "1.0.0", g_ = "src/patterns/disable/api", __ = "/disable/api";
|
|
7713
|
+
async function v_(e) {
|
|
7714
|
+
let t = await p_(e);
|
|
7703
7715
|
if (e.env !== "runtime") return S(t, e);
|
|
7704
7716
|
let { generate: n } = await import("./chunks/generate.runtime-CM3bj0nP.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
7705
7717
|
if (e.input.destructive !== !0) return i;
|
|
7706
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
7718
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7707
7719
|
return a(i, e);
|
|
7708
7720
|
}
|
|
7709
|
-
var
|
|
7710
|
-
version:
|
|
7711
|
-
slug:
|
|
7712
|
-
source:
|
|
7713
|
-
docs:
|
|
7721
|
+
var y_ = {
|
|
7722
|
+
version: h_,
|
|
7723
|
+
slug: m_,
|
|
7724
|
+
source: g_,
|
|
7725
|
+
docs: __,
|
|
7714
7726
|
plan: "open",
|
|
7715
7727
|
title: "Disable API",
|
|
7716
7728
|
summary: "Disables the PocketBase API handler.",
|
|
@@ -7743,8 +7755,8 @@ var v_ = {
|
|
|
7743
7755
|
examples: [],
|
|
7744
7756
|
tests: 0,
|
|
7745
7757
|
baseline: "velastack",
|
|
7746
|
-
generate:
|
|
7747
|
-
},
|
|
7758
|
+
generate: v_
|
|
7759
|
+
}, b_ = /* #__PURE__ */ Object.assign({
|
|
7748
7760
|
"../../enable/api-keys/creates/src/lib/schemas/apiKey.ts": Su,
|
|
7749
7761
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.server.ts": Cu,
|
|
7750
7762
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.svelte": wu,
|
|
@@ -7757,13 +7769,13 @@ var v_ = {
|
|
|
7757
7769
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/create-api-key.ts": Au,
|
|
7758
7770
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/server.test.ts": ju,
|
|
7759
7771
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/server.test.ts": Mu
|
|
7760
|
-
}),
|
|
7761
|
-
async function
|
|
7772
|
+
}), x_ = "../../enable/api-keys/creates/";
|
|
7773
|
+
async function S_(e) {
|
|
7762
7774
|
return {
|
|
7763
7775
|
creates: [],
|
|
7764
7776
|
modifies: [],
|
|
7765
|
-
deletes: Object.keys(
|
|
7766
|
-
let t = D(e,
|
|
7777
|
+
deletes: Object.keys(b_).map((e) => {
|
|
7778
|
+
let t = D(e, x_);
|
|
7767
7779
|
return {
|
|
7768
7780
|
path: t,
|
|
7769
7781
|
language: w(t),
|
|
@@ -7779,20 +7791,20 @@ async function x_(e) {
|
|
|
7779
7791
|
};
|
|
7780
7792
|
}
|
|
7781
7793
|
// src/patterns/disable/api-keys/index.ts
|
|
7782
|
-
var
|
|
7783
|
-
async function
|
|
7784
|
-
let t = await
|
|
7794
|
+
var C_ = "disable-api-keys", w_ = "1.0.1", T_ = "src/patterns/disable/api-keys", E_ = "/disable/api-keys";
|
|
7795
|
+
async function D_(e) {
|
|
7796
|
+
let t = await S_(e);
|
|
7785
7797
|
if (e.env !== "runtime") return S(t, e);
|
|
7786
7798
|
let { generate: n } = await import("./chunks/generate.runtime-DICcLOts.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
7787
7799
|
if (e.input.destructive !== !0) return i;
|
|
7788
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
7800
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7789
7801
|
return a(i, e);
|
|
7790
7802
|
}
|
|
7791
|
-
var
|
|
7792
|
-
version:
|
|
7793
|
-
slug:
|
|
7794
|
-
source:
|
|
7795
|
-
docs:
|
|
7803
|
+
var O_ = {
|
|
7804
|
+
version: w_,
|
|
7805
|
+
slug: C_,
|
|
7806
|
+
source: T_,
|
|
7807
|
+
docs: E_,
|
|
7796
7808
|
plan: "open",
|
|
7797
7809
|
title: "Disable API keys",
|
|
7798
7810
|
summary: "Removes API key management: drops the api_keys collection, reverts hooks.server and nav-user, deletes generated API key routes.",
|
|
@@ -7825,8 +7837,8 @@ var D_ = {
|
|
|
7825
7837
|
examples: [],
|
|
7826
7838
|
tests: 0,
|
|
7827
7839
|
baseline: "velastack",
|
|
7828
|
-
generate:
|
|
7829
|
-
},
|
|
7840
|
+
generate: D_
|
|
7841
|
+
}, k_ = /* #__PURE__ */ Object.assign({
|
|
7830
7842
|
"../../enable/auth/creates/src/lib/components/app-sidebar.svelte": er,
|
|
7831
7843
|
"../../enable/auth/creates/src/lib/components/nav-main.svelte": qn,
|
|
7832
7844
|
"../../enable/auth/creates/src/lib/components/nav-user.svelte": zt,
|
|
@@ -7883,7 +7895,7 @@ var D_ = {
|
|
|
7883
7895
|
"../../enable/auth/creates/src/routes/(public)/(auth)/welcome/+page.svelte": Qn,
|
|
7884
7896
|
"../../enable/auth/creates/src/routes/(public)/(auth)/welcome/+page.ts": Gt,
|
|
7885
7897
|
"../../enable/auth/creates/src/routes/(public)/(auth)/welcome/server.test.ts": tr
|
|
7886
|
-
}),
|
|
7898
|
+
}), A_ = /* #__PURE__ */ Object.assign({
|
|
7887
7899
|
"../../enable/auth-remote/creates/src/lib/components/app-sidebar.svelte": on,
|
|
7888
7900
|
"../../enable/auth-remote/creates/src/lib/components/nav-main.svelte": ln,
|
|
7889
7901
|
"../../enable/auth-remote/creates/src/lib/components/nav-user.svelte": Sn,
|
|
@@ -7949,23 +7961,23 @@ var D_ = {
|
|
|
7949
7961
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/welcome/form.remote.ts": _n,
|
|
7950
7962
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/welcome/next-url.ts": Kt,
|
|
7951
7963
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/welcome/server.test.ts": Ln
|
|
7952
|
-
}),
|
|
7953
|
-
"../../enable/whatsapp/creates/src/lib/server/whatsapp.ts":
|
|
7954
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
7955
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
7956
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
7957
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts":
|
|
7958
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
7959
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
7960
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
7961
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
7962
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
7963
|
-
}),
|
|
7964
|
-
async function
|
|
7964
|
+
}), j_ = /* #__PURE__ */ Object.assign({
|
|
7965
|
+
"../../enable/whatsapp/creates/src/lib/server/whatsapp.ts": Mh,
|
|
7966
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Lh,
|
|
7967
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Rh,
|
|
7968
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": zh,
|
|
7969
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts": Bh,
|
|
7970
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Vh,
|
|
7971
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Nh,
|
|
7972
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Ph,
|
|
7973
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Fh,
|
|
7974
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Ih
|
|
7975
|
+
}), M_ = "../../enable/auth/creates/", N_ = "../../enable/auth-remote/creates/", P_ = /^\.\.\/\.\.\/enable\/whatsapp\/creates(-superforms|-remote)?\//;
|
|
7976
|
+
async function F_(e) {
|
|
7965
7977
|
let t = /* @__PURE__ */ new Set();
|
|
7966
|
-
for (let e of Object.keys(O_)) t.add(D(e, j_));
|
|
7967
7978
|
for (let e of Object.keys(k_)) t.add(D(e, M_));
|
|
7968
|
-
for (let e of Object.keys(A_)) t.add(e
|
|
7979
|
+
for (let e of Object.keys(A_)) t.add(D(e, N_));
|
|
7980
|
+
for (let e of Object.keys(j_)) t.add(e.replace(P_, ""));
|
|
7969
7981
|
return {
|
|
7970
7982
|
creates: [],
|
|
7971
7983
|
modifies: [],
|
|
@@ -7983,20 +7995,20 @@ async function P_(e) {
|
|
|
7983
7995
|
};
|
|
7984
7996
|
}
|
|
7985
7997
|
// src/patterns/disable/auth/index.ts
|
|
7986
|
-
var
|
|
7987
|
-
async function
|
|
7988
|
-
let t = await
|
|
7998
|
+
var I_ = "disable-auth", L_ = "1.1.1", R_ = "src/patterns/disable/auth", z_ = "/disable/auth";
|
|
7999
|
+
async function B_(e) {
|
|
8000
|
+
let t = await F_(e);
|
|
7989
8001
|
if (e.env !== "runtime") return S(t, e);
|
|
7990
8002
|
let { generate: n } = await import("./chunks/generate.runtime-Bz9z0VPR.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
7991
8003
|
if (e.input.destructive !== !0) return i;
|
|
7992
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8004
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
7993
8005
|
return a(i, e);
|
|
7994
8006
|
}
|
|
7995
|
-
var
|
|
7996
|
-
version:
|
|
7997
|
-
slug:
|
|
7998
|
-
source:
|
|
7999
|
-
docs:
|
|
8007
|
+
var V_ = {
|
|
8008
|
+
version: L_,
|
|
8009
|
+
slug: I_,
|
|
8010
|
+
source: R_,
|
|
8011
|
+
docs: z_,
|
|
8000
8012
|
plan: "open",
|
|
8001
8013
|
title: "Disable auth",
|
|
8002
8014
|
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.",
|
|
@@ -8027,30 +8039,30 @@ var B_ = {
|
|
|
8027
8039
|
examples: [],
|
|
8028
8040
|
tests: 0,
|
|
8029
8041
|
baseline: "velastack-auth",
|
|
8030
|
-
generate:
|
|
8031
|
-
},
|
|
8042
|
+
generate: B_
|
|
8043
|
+
}, H_ = /* #__PURE__ */ Object.assign({
|
|
8032
8044
|
"../../enable/backend/creates/data/fixtures/README.md": Ku,
|
|
8033
8045
|
"../../enable/backend/creates/data/hooks/README.md": qu,
|
|
8034
8046
|
"../../enable/backend/creates/data/seeds/README.md": Ju,
|
|
8035
8047
|
"../../enable/backend/creates/src/hooks.server.ts": Yu
|
|
8036
|
-
}),
|
|
8037
|
-
function
|
|
8048
|
+
}), U_ = "../../enable/backend/creates/", W_ = ["src/lib/server/workflows.ts", "src/lib/workflows"];
|
|
8049
|
+
function G_(e) {
|
|
8038
8050
|
let t = e.lastIndexOf("@");
|
|
8039
8051
|
return t > 0 ? e.slice(0, t) : e;
|
|
8040
8052
|
}
|
|
8041
|
-
async function
|
|
8053
|
+
async function K_(e) {
|
|
8042
8054
|
return {
|
|
8043
8055
|
creates: [],
|
|
8044
8056
|
modifies: [],
|
|
8045
|
-
deletes: Object.keys(
|
|
8046
|
-
let t = D(e,
|
|
8057
|
+
deletes: Object.keys(H_).map((e) => {
|
|
8058
|
+
let t = D(e, U_);
|
|
8047
8059
|
return {
|
|
8048
8060
|
path: t,
|
|
8049
8061
|
language: w(t),
|
|
8050
8062
|
content: "",
|
|
8051
8063
|
status: "success"
|
|
8052
8064
|
};
|
|
8053
|
-
}).concat(["data", ...
|
|
8065
|
+
}).concat(["data", ...W_].map((e) => ({
|
|
8054
8066
|
path: e,
|
|
8055
8067
|
language: w(e),
|
|
8056
8068
|
content: "",
|
|
@@ -8058,30 +8070,30 @@ async function G_(e) {
|
|
|
8058
8070
|
}))).sort((e, t) => e.path.localeCompare(t.path)),
|
|
8059
8071
|
components: [],
|
|
8060
8072
|
packages: [oe],
|
|
8061
|
-
uninstalls:
|
|
8073
|
+
uninstalls: ng.map(G_),
|
|
8062
8074
|
collections: [],
|
|
8063
8075
|
collectionPatches: [],
|
|
8064
8076
|
collectionDrops: []
|
|
8065
8077
|
};
|
|
8066
8078
|
}
|
|
8067
8079
|
// src/patterns/disable/backend/index.ts
|
|
8068
|
-
var
|
|
8069
|
-
async function
|
|
8070
|
-
let t = await
|
|
8080
|
+
var q_ = "disable-backend", J_ = "1.1.0", Y_ = "src/patterns/disable/backend", X_ = "/disable/backend";
|
|
8081
|
+
async function Z_(e) {
|
|
8082
|
+
let t = await K_(e);
|
|
8071
8083
|
if (e.env !== "runtime") return S(t, e);
|
|
8072
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
8084
|
+
let { generate: n } = await import("./chunks/generate.runtime-DaPA2NNL.js"), r = await n(e), i = await S(T([{
|
|
8073
8085
|
...t,
|
|
8074
8086
|
deletes: t.deletes.filter((e) => e.path !== "src/hooks.server.ts")
|
|
8075
8087
|
}, r]), e);
|
|
8076
8088
|
if (e.input.destructive !== !0) return i;
|
|
8077
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8089
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8078
8090
|
return a(i, e);
|
|
8079
8091
|
}
|
|
8080
|
-
var
|
|
8081
|
-
version:
|
|
8082
|
-
slug:
|
|
8083
|
-
source:
|
|
8084
|
-
docs:
|
|
8092
|
+
var Q_ = {
|
|
8093
|
+
version: J_,
|
|
8094
|
+
slug: q_,
|
|
8095
|
+
source: Y_,
|
|
8096
|
+
docs: X_,
|
|
8085
8097
|
plan: "open",
|
|
8086
8098
|
title: "Disable Backend",
|
|
8087
8099
|
summary: "Removes the PocketBase backend: deletes data/ (the local database, fixtures, hooks and seeds), the background workflows (which run on PocketBase, uninstalling their packages) and every server.test.ts, takes the backend out of hooks.server.ts, removes the PocketBase and workflow variables from src/env.ts, switches the SvelteKit adapter back to static with SPA fallback, and reverts test/setup.ts and .gitignore. An older root layout that read the app name from PocketBase is pointed at src/lib/site.ts. Leaves @velastack/pocketbase and pocketbase-sveltekit installed; uninstall manually.",
|
|
@@ -8112,15 +8124,15 @@ var Z_ = {
|
|
|
8112
8124
|
examples: [],
|
|
8113
8125
|
tests: 0,
|
|
8114
8126
|
baseline: "velastack",
|
|
8115
|
-
generate:
|
|
8116
|
-
},
|
|
8127
|
+
generate: Z_
|
|
8128
|
+
}, $_ = /* #__PURE__ */ Object.assign({
|
|
8117
8129
|
"../../enable/content-negotiation/creates/src/lib/negotiate.ts": ef,
|
|
8118
8130
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.server.ts": tf,
|
|
8119
8131
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.svelte": nf,
|
|
8120
8132
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.ts": rf
|
|
8121
|
-
}),
|
|
8122
|
-
async function
|
|
8123
|
-
let t = [...Object.keys(
|
|
8133
|
+
}), ev = /* #__PURE__ */ Object.assign({ "../../enable/content-negotiation/creates-with-blog/src/routes/(public)/blog/[slug]/+page.server.ts": af }), tv = "../../enable/content-negotiation/creates/", nv = "../../enable/content-negotiation/creates-with-blog/";
|
|
8134
|
+
async function rv(e) {
|
|
8135
|
+
let t = [...Object.keys($_).map((e) => D(e, tv)), ...Object.keys(ev).map((e) => D(e, nv))];
|
|
8124
8136
|
return {
|
|
8125
8137
|
creates: [],
|
|
8126
8138
|
modifies: [],
|
|
@@ -8139,20 +8151,20 @@ async function nv(e) {
|
|
|
8139
8151
|
};
|
|
8140
8152
|
}
|
|
8141
8153
|
// src/patterns/disable/content-negotiation/index.ts
|
|
8142
|
-
var
|
|
8143
|
-
async function
|
|
8144
|
-
let t = await
|
|
8154
|
+
var iv = "disable-content-negotiation", av = "1.1.0", ov = "src/patterns/disable/content-negotiation", sv = "/disable/content-negotiation";
|
|
8155
|
+
async function cv(e) {
|
|
8156
|
+
let t = await rv(e);
|
|
8145
8157
|
if (e.env !== "runtime") return S(t, e);
|
|
8146
8158
|
let { generate: n } = await import("./chunks/generate.runtime-j_5K3Uue.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
8147
8159
|
if (e.input.destructive !== !0) return i;
|
|
8148
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8160
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8149
8161
|
return a(i, e);
|
|
8150
8162
|
}
|
|
8151
|
-
var
|
|
8152
|
-
version:
|
|
8153
|
-
slug:
|
|
8154
|
-
source:
|
|
8155
|
-
docs:
|
|
8163
|
+
var lv = {
|
|
8164
|
+
version: av,
|
|
8165
|
+
slug: iv,
|
|
8166
|
+
source: ov,
|
|
8167
|
+
docs: sv,
|
|
8156
8168
|
plan: "open",
|
|
8157
8169
|
title: "Disable content negotiation",
|
|
8158
8170
|
summary: "Removes sveltekit-negotiate wiring: deletes creates, unwraps hooks.server handle, reverts reroute (preserving i18n compose), removes <Negotiate /> from the root layout.",
|
|
@@ -8184,25 +8196,23 @@ var cv = {
|
|
|
8184
8196
|
examples: [],
|
|
8185
8197
|
tests: 0,
|
|
8186
8198
|
baseline: "velastack",
|
|
8187
|
-
generate:
|
|
8188
|
-
},
|
|
8199
|
+
generate: cv
|
|
8200
|
+
}, uv = /* #__PURE__ */ Object.assign({
|
|
8189
8201
|
"../../enable/i18n/creates/src/lib/components/language-select.svelte": wf,
|
|
8190
|
-
"../../enable/i18n/creates/src/lib/
|
|
8191
|
-
"../../enable/i18n/creates/
|
|
8192
|
-
|
|
8193
|
-
|
|
8202
|
+
"../../enable/i18n/creates/src/lib/locale.ts": Tf,
|
|
8203
|
+
"../../enable/i18n/creates/src/lib/url.ts": Ef,
|
|
8204
|
+
"../../enable/i18n/creates/wuchale.config.js": Df
|
|
8205
|
+
}), dv = "../../enable/i18n/creates/", fv = "src/locales/.wuchale";
|
|
8206
|
+
async function pv(e) {
|
|
8194
8207
|
return {
|
|
8195
8208
|
creates: [],
|
|
8196
8209
|
modifies: [],
|
|
8197
|
-
deletes: Object.keys(
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
status: "success"
|
|
8204
|
-
};
|
|
8205
|
-
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
8210
|
+
deletes: [...Object.keys(uv).map((e) => D(e, dv)), fv].map((e) => ({
|
|
8211
|
+
path: e,
|
|
8212
|
+
language: w(e),
|
|
8213
|
+
content: "",
|
|
8214
|
+
status: "success"
|
|
8215
|
+
})).sort((e, t) => e.path.localeCompare(t.path)),
|
|
8206
8216
|
components: [],
|
|
8207
8217
|
packages: [],
|
|
8208
8218
|
uninstalls: ["wuchale", "@wuchale/svelte"],
|
|
@@ -8212,23 +8222,23 @@ async function dv(e) {
|
|
|
8212
8222
|
};
|
|
8213
8223
|
}
|
|
8214
8224
|
// src/patterns/disable/i18n/index.ts
|
|
8215
|
-
var
|
|
8216
|
-
async function
|
|
8217
|
-
let t = await
|
|
8225
|
+
var mv = "disable-i18n", hv = "1.2.0", gv = "src/patterns/disable/i18n", _v = "/disable/i18n";
|
|
8226
|
+
async function vv(e) {
|
|
8227
|
+
let t = await pv(e);
|
|
8218
8228
|
if (e.env !== "runtime") return S(t, e);
|
|
8219
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
8229
|
+
let { generate: n } = await import("./chunks/generate.runtime-DZUPtJVF.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
8220
8230
|
if (e.input.destructive !== !0) return i;
|
|
8221
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8231
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8222
8232
|
return a(i, e);
|
|
8223
8233
|
}
|
|
8224
|
-
var
|
|
8225
|
-
version:
|
|
8226
|
-
slug:
|
|
8227
|
-
source:
|
|
8228
|
-
docs:
|
|
8234
|
+
var yv = {
|
|
8235
|
+
version: hv,
|
|
8236
|
+
slug: mv,
|
|
8237
|
+
source: gv,
|
|
8238
|
+
docs: _v,
|
|
8229
8239
|
plan: "open",
|
|
8230
8240
|
title: "Disable i18n",
|
|
8231
|
-
summary: "Removes i18n: deletes the generated files, uninstalls wuchale, and reverts vite.config, the package.json #locales import, hooks.server, app.html, the root +layout.ts and layout, and the .gitignore
|
|
8241
|
+
summary: "Removes i18n: deletes the generated files, uninstalls wuchale, and reverts vite.config, the package.json #locales import, hooks.server, app.html, the root +layout.ts and layout, and the .gitignore and .prettierignore blocks. The wuchale cache (src/locales/.wuchale) and the loaders wuchale wrote in src/locales go; the translation catalogs there stay.",
|
|
8232
8242
|
requires: {
|
|
8233
8243
|
auth: !1,
|
|
8234
8244
|
api: !1,
|
|
@@ -8257,19 +8267,19 @@ var _v = {
|
|
|
8257
8267
|
examples: [],
|
|
8258
8268
|
tests: 0,
|
|
8259
8269
|
baseline: "velastack",
|
|
8260
|
-
generate:
|
|
8261
|
-
},
|
|
8262
|
-
"../../enable/notifications/creates/src/lib/components/notifications-bell.svelte":
|
|
8263
|
-
"../../enable/notifications/creates/src/lib/server/notifications.ts":
|
|
8264
|
-
"../../enable/notifications/creates/src/routes/(app)/notifications/+page.server.ts":
|
|
8265
|
-
"../../enable/notifications/creates/src/routes/(app)/notifications/+page.svelte":
|
|
8266
|
-
}),
|
|
8267
|
-
async function
|
|
8270
|
+
generate: vv
|
|
8271
|
+
}, bv = /* #__PURE__ */ Object.assign({
|
|
8272
|
+
"../../enable/notifications/creates/src/lib/components/notifications-bell.svelte": Hf,
|
|
8273
|
+
"../../enable/notifications/creates/src/lib/server/notifications.ts": Uf,
|
|
8274
|
+
"../../enable/notifications/creates/src/routes/(app)/notifications/+page.server.ts": Wf,
|
|
8275
|
+
"../../enable/notifications/creates/src/routes/(app)/notifications/+page.svelte": Gf
|
|
8276
|
+
}), xv = "../../enable/notifications/creates/";
|
|
8277
|
+
async function Sv(e) {
|
|
8268
8278
|
return {
|
|
8269
8279
|
creates: [],
|
|
8270
8280
|
modifies: [],
|
|
8271
|
-
deletes: Object.keys(
|
|
8272
|
-
let t = D(e,
|
|
8281
|
+
deletes: Object.keys(bv).map((e) => {
|
|
8282
|
+
let t = D(e, xv);
|
|
8273
8283
|
return {
|
|
8274
8284
|
path: t,
|
|
8275
8285
|
language: w(t),
|
|
@@ -8285,20 +8295,20 @@ async function bv(e) {
|
|
|
8285
8295
|
};
|
|
8286
8296
|
}
|
|
8287
8297
|
// src/patterns/disable/notifications/index.ts
|
|
8288
|
-
var
|
|
8289
|
-
async function
|
|
8290
|
-
let t = await
|
|
8298
|
+
var Cv = "disable-notifications", wv = "1.1.1", Tv = "src/patterns/disable/notifications", Ev = "/disable/notifications";
|
|
8299
|
+
async function Dv(e) {
|
|
8300
|
+
let t = await Sv(e);
|
|
8291
8301
|
if (e.env !== "runtime") return S(t, e);
|
|
8292
8302
|
let { generate: n } = await import("./chunks/generate.runtime-erWI6j7m.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
8293
8303
|
if (e.input.destructive !== !0) return i;
|
|
8294
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8304
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8295
8305
|
return a(i, e);
|
|
8296
8306
|
}
|
|
8297
|
-
var
|
|
8298
|
-
version:
|
|
8299
|
-
slug:
|
|
8300
|
-
source:
|
|
8301
|
-
docs:
|
|
8307
|
+
var Ov = {
|
|
8308
|
+
version: wv,
|
|
8309
|
+
slug: Cv,
|
|
8310
|
+
source: Tv,
|
|
8311
|
+
docs: Ev,
|
|
8302
8312
|
plan: "open",
|
|
8303
8313
|
title: "Disable notifications",
|
|
8304
8314
|
summary: "Drops the notifications collection, deletes the bell component, server helpers and /notifications page, and takes the bell and its loader out of the (app) layout.",
|
|
@@ -8329,54 +8339,54 @@ var Ev = {
|
|
|
8329
8339
|
examples: [],
|
|
8330
8340
|
tests: 0,
|
|
8331
8341
|
baseline: "velastack-auth",
|
|
8332
|
-
generate:
|
|
8333
|
-
},
|
|
8334
|
-
"../../enable/teams/creates/src/lib/components/team-switcher.svelte":
|
|
8335
|
-
"../../enable/teams/creates/src/lib/schemas/team.ts":
|
|
8336
|
-
"../../enable/teams/creates/src/lib/schemas/teamInvite.ts":
|
|
8337
|
-
"../../enable/teams/creates/src/lib/schemas/teamRole.ts":
|
|
8338
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+layout@.svelte":
|
|
8339
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.server.ts":
|
|
8340
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.svelte":
|
|
8341
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.ts":
|
|
8342
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+layout@.svelte":
|
|
8343
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.server.ts":
|
|
8344
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.svelte":
|
|
8345
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.ts":
|
|
8346
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+layout.server.ts":
|
|
8347
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+layout.svelte":
|
|
8348
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+page.server.ts":
|
|
8342
|
+
generate: Dv
|
|
8343
|
+
}, kv = /* #__PURE__ */ Object.assign({
|
|
8344
|
+
"../../enable/teams/creates/src/lib/components/team-switcher.svelte": Om,
|
|
8345
|
+
"../../enable/teams/creates/src/lib/schemas/team.ts": km,
|
|
8346
|
+
"../../enable/teams/creates/src/lib/schemas/teamInvite.ts": Am,
|
|
8347
|
+
"../../enable/teams/creates/src/lib/schemas/teamRole.ts": jm,
|
|
8348
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+layout@.svelte": Mm,
|
|
8349
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.server.ts": Nm,
|
|
8350
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.svelte": Pm,
|
|
8351
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.ts": Fm,
|
|
8352
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+layout@.svelte": Im,
|
|
8353
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.server.ts": Lm,
|
|
8354
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.svelte": Rm,
|
|
8355
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.ts": zm,
|
|
8356
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.server.ts": Bm,
|
|
8357
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.svelte": Vm,
|
|
8358
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.server.ts": Hm,
|
|
8349
8359
|
"../../enable/teams/creates/src/routes/(app)/teams/+page.svelte": "",
|
|
8350
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts":
|
|
8351
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts":
|
|
8352
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte":
|
|
8353
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts":
|
|
8360
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts": Um,
|
|
8361
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts": Wm,
|
|
8362
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": Gm,
|
|
8363
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts": Km,
|
|
8354
8364
|
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.svelte": "",
|
|
8355
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts":
|
|
8356
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts":
|
|
8357
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts":
|
|
8358
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte":
|
|
8359
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts":
|
|
8360
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts":
|
|
8361
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts":
|
|
8362
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte":
|
|
8363
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts":
|
|
8364
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts":
|
|
8365
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts":
|
|
8366
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts":
|
|
8367
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte":
|
|
8368
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts":
|
|
8369
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts":
|
|
8370
|
-
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts":
|
|
8371
|
-
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts":
|
|
8372
|
-
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts":
|
|
8373
|
-
}),
|
|
8374
|
-
async function
|
|
8365
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts": qm,
|
|
8366
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts": Jm,
|
|
8367
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": Ym,
|
|
8368
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte": Xm,
|
|
8369
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts": Zm,
|
|
8370
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts": Qm,
|
|
8371
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": $m,
|
|
8372
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": eh,
|
|
8373
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": th,
|
|
8374
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": nh,
|
|
8375
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts": rh,
|
|
8376
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts": ih,
|
|
8377
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte": ah,
|
|
8378
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts": oh,
|
|
8379
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts": sh,
|
|
8380
|
+
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts": ch,
|
|
8381
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": lh,
|
|
8382
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts": uh
|
|
8383
|
+
}), Av = "../../enable/teams/creates/";
|
|
8384
|
+
async function jv(e) {
|
|
8375
8385
|
return {
|
|
8376
8386
|
creates: [],
|
|
8377
8387
|
modifies: [],
|
|
8378
|
-
deletes: Object.keys(
|
|
8379
|
-
let t = D(e,
|
|
8388
|
+
deletes: Object.keys(kv).map((e) => {
|
|
8389
|
+
let t = D(e, Av);
|
|
8380
8390
|
return {
|
|
8381
8391
|
path: t,
|
|
8382
8392
|
language: w(t),
|
|
@@ -8392,20 +8402,20 @@ async function kv(e) {
|
|
|
8392
8402
|
};
|
|
8393
8403
|
}
|
|
8394
8404
|
// src/patterns/disable/teams/index.ts
|
|
8395
|
-
var
|
|
8396
|
-
async function
|
|
8397
|
-
let t = await
|
|
8405
|
+
var Mv = "disable-teams", Nv = "1.1.1", Pv = "src/patterns/disable/teams", Fv = "/disable/teams";
|
|
8406
|
+
async function Iv(e) {
|
|
8407
|
+
let t = await jv(e);
|
|
8398
8408
|
if (e.env !== "runtime") return S(t, e);
|
|
8399
8409
|
let { generate: n } = await import("./chunks/generate.runtime-cYh0CQ5d.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
8400
8410
|
if (e.input.destructive !== !0) return i;
|
|
8401
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8411
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8402
8412
|
return a(i, e);
|
|
8403
8413
|
}
|
|
8404
|
-
var
|
|
8405
|
-
version:
|
|
8406
|
-
slug:
|
|
8407
|
-
source:
|
|
8408
|
-
docs:
|
|
8414
|
+
var Lv = {
|
|
8415
|
+
version: Nv,
|
|
8416
|
+
slug: Mv,
|
|
8417
|
+
source: Pv,
|
|
8418
|
+
docs: Fv,
|
|
8409
8419
|
plan: "pro",
|
|
8410
8420
|
title: "Disable teams",
|
|
8411
8421
|
summary: "Removes the teams collections and routes, and reverts the Teams nav item, the team switcher in app-sidebar, the team props in the (app) layout, and the team loader in its +layout.server.ts.",
|
|
@@ -8436,20 +8446,20 @@ var Fv = {
|
|
|
8436
8446
|
examples: [],
|
|
8437
8447
|
tests: 0,
|
|
8438
8448
|
baseline: "velastack-auth",
|
|
8439
|
-
generate:
|
|
8440
|
-
},
|
|
8441
|
-
async function
|
|
8449
|
+
generate: Iv
|
|
8450
|
+
}, Rv = "disable-payments", zv = "2.4.0", Bv = "src/patterns/disable/payments", Vv = "/disable/payments";
|
|
8451
|
+
async function Hv(e) {
|
|
8442
8452
|
let t = await Ur(e);
|
|
8443
8453
|
if (e.env !== "runtime") return S(t, e);
|
|
8444
8454
|
let { generate: n } = await import("./chunks/generate.runtime-Cry-DBNl.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
8445
8455
|
if (e.input.destructive !== !0) return i;
|
|
8446
|
-
let a = Hr(e).some((e) => e.id === "stripe") && e.features.backend ? await
|
|
8456
|
+
let a = Hr(e).some((e) => e.id === "stripe") && e.features.backend ? await Uv(e) : [], o = await S({
|
|
8447
8457
|
...i,
|
|
8448
8458
|
creates: [...i.creates, ...a]
|
|
8449
|
-
}, { writeResult: s } = await import("./chunks/write-result-
|
|
8459
|
+
}, e), { writeResult: s } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8450
8460
|
return s(o, e);
|
|
8451
8461
|
}
|
|
8452
|
-
async function
|
|
8462
|
+
async function Uv(e) {
|
|
8453
8463
|
let { withPocketbase: t } = await import("./chunks/pocketbase-gUn2UrDd.js").then((e) => e.r), { applyCollectionFieldsPatches: n } = await import("./chunks/collections-D-xbHi4M.js").then((e) => e.n), r = Ne(e), i = [];
|
|
8454
8464
|
return await t(e.root, async (t) => {
|
|
8455
8465
|
let a;
|
|
@@ -8468,11 +8478,11 @@ async function Vv(e) {
|
|
|
8468
8478
|
}], e, r));
|
|
8469
8479
|
}), i;
|
|
8470
8480
|
}
|
|
8471
|
-
var
|
|
8472
|
-
version:
|
|
8473
|
-
slug:
|
|
8474
|
-
source:
|
|
8475
|
-
docs:
|
|
8481
|
+
var Wv = {
|
|
8482
|
+
version: zv,
|
|
8483
|
+
slug: Rv,
|
|
8484
|
+
source: Bv,
|
|
8485
|
+
docs: Vv,
|
|
8476
8486
|
plan: "pro",
|
|
8477
8487
|
title: "Disable payments",
|
|
8478
8488
|
summary: "Removes the detected payment provider's files and env credentials. For Stripe it also drops the Stripe collections and reverts the nav/signup edits. Does NOT touch products in the Stripe dashboard or Shopify admin, orders recorded to a hosted VelaStack form, or uninstall the provider's packages.",
|
|
@@ -8512,34 +8522,34 @@ var Hv = {
|
|
|
8512
8522
|
examples: [],
|
|
8513
8523
|
tests: 0,
|
|
8514
8524
|
baseline: "velastack",
|
|
8515
|
-
generate:
|
|
8516
|
-
},
|
|
8517
|
-
"../../enable/ecommerce/providers/shopify/src/lib/cart.svelte.ts":
|
|
8518
|
-
"../../enable/ecommerce/providers/shopify/src/lib/components/cart/add-to-cart.svelte":
|
|
8519
|
-
"../../enable/ecommerce/providers/shopify/src/lib/components/cart/cart-sheet.svelte":
|
|
8520
|
-
"../../enable/ecommerce/providers/stripe/src/lib/cart.svelte.ts":
|
|
8521
|
-
"../../enable/ecommerce/providers/stripe/src/lib/components/cart/add-to-cart.svelte":
|
|
8522
|
-
"../../enable/ecommerce/providers/stripe/src/lib/components/cart/cart-items.svelte":
|
|
8523
|
-
"../../enable/ecommerce/providers/stripe/src/lib/components/cart/cart-sheet.svelte":
|
|
8524
|
-
"../../enable/ecommerce/providers/stripe/src/routes/(public)/cart/+page.server.ts":
|
|
8525
|
-
"../../enable/ecommerce/providers/stripe/src/routes/(public)/cart/+page.svelte":
|
|
8526
|
-
"../../enable/ecommerce/providers/stripe/src/routes/(public)/cart/server.test.ts":
|
|
8525
|
+
generate: Hv
|
|
8526
|
+
}, Gv = /* #__PURE__ */ Object.assign({ "../../enable/ecommerce/creates/src/lib/components/cart/cart-button.svelte": Dp }), Kv = /* #__PURE__ */ Object.assign({
|
|
8527
|
+
"../../enable/ecommerce/providers/shopify/src/lib/cart.svelte.ts": Op,
|
|
8528
|
+
"../../enable/ecommerce/providers/shopify/src/lib/components/cart/add-to-cart.svelte": kp,
|
|
8529
|
+
"../../enable/ecommerce/providers/shopify/src/lib/components/cart/cart-sheet.svelte": Ap,
|
|
8530
|
+
"../../enable/ecommerce/providers/stripe/src/lib/cart.svelte.ts": jp,
|
|
8531
|
+
"../../enable/ecommerce/providers/stripe/src/lib/components/cart/add-to-cart.svelte": Mp,
|
|
8532
|
+
"../../enable/ecommerce/providers/stripe/src/lib/components/cart/cart-items.svelte": Np,
|
|
8533
|
+
"../../enable/ecommerce/providers/stripe/src/lib/components/cart/cart-sheet.svelte": Pp,
|
|
8534
|
+
"../../enable/ecommerce/providers/stripe/src/routes/(public)/cart/+page.server.ts": Fp,
|
|
8535
|
+
"../../enable/ecommerce/providers/stripe/src/routes/(public)/cart/+page.svelte": Ip,
|
|
8536
|
+
"../../enable/ecommerce/providers/stripe/src/routes/(public)/cart/server.test.ts": Lp,
|
|
8527
8537
|
"../../enable/ecommerce/providers/stripe/src/routes/(public)/checkout/success/+page.server.ts": xr,
|
|
8528
8538
|
"../../enable/ecommerce/providers/stripe/src/routes/(public)/checkout/success/+page.svelte": wr,
|
|
8529
|
-
"../../enable/ecommerce/providers/whatsapp/src/lib/cart.svelte.ts":
|
|
8530
|
-
"../../enable/ecommerce/providers/whatsapp/src/lib/components/cart/add-to-cart.svelte":
|
|
8531
|
-
"../../enable/ecommerce/providers/whatsapp/src/lib/components/cart/cart-sheet.svelte":
|
|
8532
|
-
"../../enable/ecommerce/providers-app-mode/stripe/src/routes/(public)/cart/+page.server.ts":
|
|
8539
|
+
"../../enable/ecommerce/providers/whatsapp/src/lib/cart.svelte.ts": Rp,
|
|
8540
|
+
"../../enable/ecommerce/providers/whatsapp/src/lib/components/cart/add-to-cart.svelte": zp,
|
|
8541
|
+
"../../enable/ecommerce/providers/whatsapp/src/lib/components/cart/cart-sheet.svelte": Bp,
|
|
8542
|
+
"../../enable/ecommerce/providers-app-mode/stripe/src/routes/(public)/cart/+page.server.ts": Vp
|
|
8533
8543
|
});
|
|
8534
|
-
async function
|
|
8535
|
-
let t = e.providers?.payments, n =
|
|
8544
|
+
async function qv(e) {
|
|
8545
|
+
let t = e.providers?.payments, n = Hp.some((e) => e.id === t) ? [t] : Hp.map((e) => e.id);
|
|
8536
8546
|
return {
|
|
8537
8547
|
creates: [],
|
|
8538
8548
|
modifies: [],
|
|
8539
8549
|
deletes: [.../* @__PURE__ */ new Set([
|
|
8540
|
-
...Object.keys(E(
|
|
8541
|
-
...n.flatMap((e) => ve(
|
|
8542
|
-
...
|
|
8550
|
+
...Object.keys(E(Gv, "../../enable/ecommerce/creates/")),
|
|
8551
|
+
...n.flatMap((e) => ve(Kv, e)),
|
|
8552
|
+
...Ug.filter((e) => e !== "src/lib/catalog.ts")
|
|
8543
8553
|
])].sort().map((e) => ({
|
|
8544
8554
|
path: e,
|
|
8545
8555
|
language: w(e),
|
|
@@ -8554,20 +8564,20 @@ async function Gv(e) {
|
|
|
8554
8564
|
};
|
|
8555
8565
|
}
|
|
8556
8566
|
// src/patterns/disable/ecommerce/index.ts
|
|
8557
|
-
var
|
|
8558
|
-
async function
|
|
8559
|
-
let t = await
|
|
8567
|
+
var Jv = "disable-ecommerce", Yv = "1.2.0", Xv = "src/patterns/disable/ecommerce", Zv = "/disable/ecommerce";
|
|
8568
|
+
async function Qv(e) {
|
|
8569
|
+
let t = await qv(e);
|
|
8560
8570
|
if (e.env !== "runtime") return S(t, e);
|
|
8561
8571
|
let { generate: n } = await import("./chunks/generate.runtime-CMuxVUIY.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
8562
8572
|
if (e.input.destructive !== !0) return i;
|
|
8563
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8573
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8564
8574
|
return a(i, e);
|
|
8565
8575
|
}
|
|
8566
|
-
var
|
|
8567
|
-
version:
|
|
8568
|
-
slug:
|
|
8569
|
-
source:
|
|
8570
|
-
docs:
|
|
8576
|
+
var $v = {
|
|
8577
|
+
version: Yv,
|
|
8578
|
+
slug: Jv,
|
|
8579
|
+
source: Xv,
|
|
8580
|
+
docs: Zv,
|
|
8571
8581
|
plan: "pro",
|
|
8572
8582
|
title: "Disable ecommerce",
|
|
8573
8583
|
summary: "Removes the cart, the checkout pages and the navbar cart button enable-ecommerce added. Payments, and the shadcn components the cart used, stay.",
|
|
@@ -8602,20 +8612,20 @@ var Zv = {
|
|
|
8602
8612
|
examples: [],
|
|
8603
8613
|
tests: 0,
|
|
8604
8614
|
baseline: "velastack",
|
|
8605
|
-
generate:
|
|
8606
|
-
},
|
|
8607
|
-
"../../enable/subscriptions/creates/src/lib/workflows/sync-stripe-subscriptions.ts":
|
|
8608
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts":
|
|
8609
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts":
|
|
8610
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts":
|
|
8611
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts":
|
|
8612
|
-
}),
|
|
8613
|
-
async function
|
|
8615
|
+
generate: Qv
|
|
8616
|
+
}, ey = /* #__PURE__ */ Object.assign({
|
|
8617
|
+
"../../enable/subscriptions/creates/src/lib/workflows/sync-stripe-subscriptions.ts": nm,
|
|
8618
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": rm,
|
|
8619
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": im,
|
|
8620
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": am,
|
|
8621
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": om
|
|
8622
|
+
}), ty = "../../enable/subscriptions/creates/";
|
|
8623
|
+
async function ny(e) {
|
|
8614
8624
|
return {
|
|
8615
8625
|
creates: [],
|
|
8616
8626
|
modifies: [],
|
|
8617
|
-
deletes: Object.keys(
|
|
8618
|
-
let t = D(e,
|
|
8627
|
+
deletes: Object.keys(ey).map((e) => {
|
|
8628
|
+
let t = D(e, ty);
|
|
8619
8629
|
return {
|
|
8620
8630
|
path: t,
|
|
8621
8631
|
language: w(t),
|
|
@@ -8631,20 +8641,20 @@ async function ey(e) {
|
|
|
8631
8641
|
};
|
|
8632
8642
|
}
|
|
8633
8643
|
// src/patterns/disable/subscriptions/index.ts
|
|
8634
|
-
var
|
|
8635
|
-
async function
|
|
8636
|
-
let t = await
|
|
8644
|
+
var ry = "disable-subscriptions", iy = "1.0.1", ay = "src/patterns/disable/subscriptions", oy = "/disable/subscriptions";
|
|
8645
|
+
async function sy(e) {
|
|
8646
|
+
let t = await ny(e);
|
|
8637
8647
|
if (e.env !== "runtime") return S(t, e);
|
|
8638
8648
|
let { generate: n } = await import("./chunks/generate.runtime-EB8vpc7D.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
8639
8649
|
if (e.input.destructive !== !0) return i;
|
|
8640
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8650
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8641
8651
|
return a(i, e);
|
|
8642
8652
|
}
|
|
8643
|
-
var
|
|
8644
|
-
version:
|
|
8645
|
-
slug:
|
|
8646
|
-
source:
|
|
8647
|
-
docs:
|
|
8653
|
+
var cy = {
|
|
8654
|
+
version: iy,
|
|
8655
|
+
slug: ry,
|
|
8656
|
+
source: ay,
|
|
8657
|
+
docs: oy,
|
|
8648
8658
|
plan: "pro",
|
|
8649
8659
|
title: "Disable subscriptions",
|
|
8650
8660
|
summary: "Drops the stripe_subscriptions collection, reverts billing / layout / nav edits, and removes subscription webhook handlers and sync endpoint. Leaves the payments pattern intact.",
|
|
@@ -8679,27 +8689,27 @@ var oy = {
|
|
|
8679
8689
|
examples: [],
|
|
8680
8690
|
tests: 0,
|
|
8681
8691
|
baseline: "velastack",
|
|
8682
|
-
generate:
|
|
8683
|
-
},
|
|
8692
|
+
generate: sy
|
|
8693
|
+
}, ly = /* #__PURE__ */ Object.assign({
|
|
8684
8694
|
"../../enable/orders/creates/src/routes/webhooks/stripe/handlers/checkout/async-payment.ts": vr,
|
|
8685
8695
|
"../../enable/orders/creates/src/routes/webhooks/stripe/handlers/checkout/completed.ts": _r,
|
|
8686
8696
|
"../../enable/orders/creates/src/routes/webhooks/stripe/handlers/checkout/server.test.ts": Dr,
|
|
8687
8697
|
"../../enable/orders/creates/src/routes/webhooks/stripe/handlers/checkout/shared.ts": br
|
|
8688
|
-
}),
|
|
8698
|
+
}), uy = /* #__PURE__ */ Object.assign({
|
|
8689
8699
|
"../../enable/orders/creates-app-mode/src/routes/(app)/orders/+page.server.ts": gr,
|
|
8690
8700
|
"../../enable/orders/creates-app-mode/src/routes/(app)/orders/+page.svelte": Er,
|
|
8691
8701
|
"../../enable/orders/creates-app-mode/src/routes/(app)/orders/[id]/+page.server.ts": Cr,
|
|
8692
8702
|
"../../enable/orders/creates-app-mode/src/routes/(app)/orders/[id]/+page.svelte": hr,
|
|
8693
8703
|
"../../enable/orders/creates-app-mode/src/routes/webhooks/stripe/handlers/checkout/shared.ts": yr
|
|
8694
|
-
}),
|
|
8695
|
-
async function
|
|
8704
|
+
}), dy = /* #__PURE__ */ Object.assign({ "../../enable/orders/creates-notifications/src/routes/webhooks/stripe/handlers/checkout/completed.ts": Tr });
|
|
8705
|
+
async function fy(e) {
|
|
8696
8706
|
return {
|
|
8697
8707
|
creates: [],
|
|
8698
8708
|
modifies: [],
|
|
8699
8709
|
deletes: [.../* @__PURE__ */ new Set([
|
|
8700
|
-
...Object.keys(E(
|
|
8701
|
-
...Object.keys(E(
|
|
8702
|
-
...Object.keys(E(
|
|
8710
|
+
...Object.keys(E(ly, "../../enable/orders/creates/")),
|
|
8711
|
+
...Object.keys(E(uy, "../../enable/orders/creates-app-mode/")),
|
|
8712
|
+
...Object.keys(E(dy, "../../enable/orders/creates-notifications/"))
|
|
8703
8713
|
])].sort().map((e) => ({
|
|
8704
8714
|
path: e,
|
|
8705
8715
|
language: w(e),
|
|
@@ -8714,20 +8724,20 @@ async function uy(e) {
|
|
|
8714
8724
|
};
|
|
8715
8725
|
}
|
|
8716
8726
|
// src/patterns/disable/orders/index.ts
|
|
8717
|
-
var
|
|
8718
|
-
async function
|
|
8719
|
-
let t = await
|
|
8727
|
+
var py = "disable-orders", my = "1.0.0", hy = "src/patterns/disable/orders", gy = "/disable/orders";
|
|
8728
|
+
async function _y(e) {
|
|
8729
|
+
let t = await fy(e);
|
|
8720
8730
|
if (e.env !== "runtime") return S(t, e);
|
|
8721
8731
|
let { generate: n } = await import("./chunks/generate.runtime-Cxg1b_BK.js"), r = await n(e), i = await S(T([t, r]), e);
|
|
8722
8732
|
if (e.input.destructive !== !0) return i;
|
|
8723
|
-
let { writeResult: a } = await import("./chunks/write-result-
|
|
8733
|
+
let { writeResult: a } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8724
8734
|
return a(i, e);
|
|
8725
8735
|
}
|
|
8726
|
-
var
|
|
8727
|
-
version:
|
|
8728
|
-
slug:
|
|
8729
|
-
source:
|
|
8730
|
-
docs:
|
|
8736
|
+
var vy = {
|
|
8737
|
+
version: my,
|
|
8738
|
+
slug: py,
|
|
8739
|
+
source: hy,
|
|
8740
|
+
docs: gy,
|
|
8731
8741
|
plan: "pro",
|
|
8732
8742
|
title: "Disable orders",
|
|
8733
8743
|
summary: "Removes the order handlers, the orders pages and the orders and order_lines collections enable-orders added, and puts the success page back to Stripe's summary. Payments and the cart stay.",
|
|
@@ -8759,21 +8769,21 @@ var gy = {
|
|
|
8759
8769
|
examples: [],
|
|
8760
8770
|
tests: 0,
|
|
8761
8771
|
baseline: "velastack",
|
|
8762
|
-
generate:
|
|
8763
|
-
},
|
|
8764
|
-
"../../enable/whatsapp/creates/src/lib/server/whatsapp.ts":
|
|
8765
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
8766
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
8767
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
8768
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts":
|
|
8769
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
8770
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
8771
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
8772
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
8773
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
8774
|
-
}),
|
|
8775
|
-
async function
|
|
8776
|
-
let t = new Set(Object.keys(
|
|
8772
|
+
generate: _y
|
|
8773
|
+
}, yy = /* #__PURE__ */ Object.assign({
|
|
8774
|
+
"../../enable/whatsapp/creates/src/lib/server/whatsapp.ts": Mh,
|
|
8775
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Lh,
|
|
8776
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Rh,
|
|
8777
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": zh,
|
|
8778
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts": Bh,
|
|
8779
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Vh,
|
|
8780
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Nh,
|
|
8781
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Ph,
|
|
8782
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Fh,
|
|
8783
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Ih
|
|
8784
|
+
}), by = /^\.\.\/\.\.\/enable\/whatsapp\/creates(-superforms|-remote)?\//;
|
|
8785
|
+
async function xy(e) {
|
|
8786
|
+
let t = new Set(Object.keys(yy).map((e) => e.replace(by, "")));
|
|
8777
8787
|
return {
|
|
8778
8788
|
creates: [],
|
|
8779
8789
|
modifies: [],
|
|
@@ -8791,18 +8801,18 @@ async function yy(e) {
|
|
|
8791
8801
|
};
|
|
8792
8802
|
}
|
|
8793
8803
|
// src/patterns/disable/whatsapp/index.ts
|
|
8794
|
-
var
|
|
8795
|
-
async function
|
|
8796
|
-
let t = await
|
|
8804
|
+
var Sy = "disable-whatsapp", Cy = "1.0.0", wy = "src/patterns/disable/whatsapp", Ty = "/disable/whatsapp";
|
|
8805
|
+
async function Ey(e) {
|
|
8806
|
+
let t = await xy(e);
|
|
8797
8807
|
if (e.env !== "runtime" || e.input.destructive !== !0) return S(t, e);
|
|
8798
|
-
let { generate: n } = await import("./chunks/generate.runtime-TCVlsBbJ.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-
|
|
8808
|
+
let { generate: n } = await import("./chunks/generate.runtime-TCVlsBbJ.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8799
8809
|
return i(await S(T([t, r]), e), e);
|
|
8800
8810
|
}
|
|
8801
|
-
var
|
|
8802
|
-
version:
|
|
8803
|
-
slug:
|
|
8804
|
-
source:
|
|
8805
|
-
docs:
|
|
8811
|
+
var Dy = {
|
|
8812
|
+
version: Cy,
|
|
8813
|
+
slug: Sy,
|
|
8814
|
+
source: wy,
|
|
8815
|
+
docs: Ty,
|
|
8806
8816
|
plan: "open",
|
|
8807
8817
|
title: "Disable WhatsApp sign-in",
|
|
8808
8818
|
summary: "Takes WhatsApp sign-in off the login and signup pages and turns it off in PocketBase. Keeps the phone fields on users and email optional, since they hold user data.",
|
|
@@ -8834,8 +8844,8 @@ var Ty = {
|
|
|
8834
8844
|
examples: [],
|
|
8835
8845
|
tests: 0,
|
|
8836
8846
|
baseline: "velastack-auth",
|
|
8837
|
-
generate:
|
|
8838
|
-
},
|
|
8847
|
+
generate: Ey
|
|
8848
|
+
}, Oy = Wr.version, ky = [
|
|
8839
8849
|
Ha,
|
|
8840
8850
|
_o,
|
|
8841
8851
|
Oo,
|
|
@@ -8856,84 +8866,84 @@ var Ty = {
|
|
|
8856
8866
|
Wd,
|
|
8857
8867
|
$d,
|
|
8858
8868
|
Cf,
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
],
|
|
8869
|
+
Vf,
|
|
8870
|
+
sp,
|
|
8871
|
+
Ep,
|
|
8872
|
+
tm,
|
|
8873
|
+
ym,
|
|
8874
|
+
Dm,
|
|
8875
|
+
jh,
|
|
8876
|
+
$h,
|
|
8877
|
+
fg,
|
|
8878
|
+
yg,
|
|
8879
|
+
Tg,
|
|
8880
|
+
jg,
|
|
8881
|
+
Lg,
|
|
8882
|
+
Gg,
|
|
8883
|
+
Zg,
|
|
8884
|
+
r_,
|
|
8885
|
+
u_,
|
|
8886
|
+
y_,
|
|
8887
|
+
O_,
|
|
8888
|
+
V_,
|
|
8889
|
+
Q_,
|
|
8890
|
+
lv,
|
|
8891
|
+
yv,
|
|
8892
|
+
Ov,
|
|
8893
|
+
Lv,
|
|
8894
|
+
Wv,
|
|
8895
|
+
$v,
|
|
8896
|
+
cy,
|
|
8897
|
+
vy,
|
|
8898
|
+
Dy
|
|
8899
|
+
], Ay = Object.fromEntries(ky.map((e) => [e.slug, e])), jy = ky.reduce((e, t) => {
|
|
8890
8900
|
let n = t.category;
|
|
8891
8901
|
return e[n] ??= [], e[n].push(t), e;
|
|
8892
8902
|
}, {});
|
|
8893
|
-
async function
|
|
8894
|
-
let { installComponents: n } = await import("./chunks/write-result-
|
|
8903
|
+
async function My(e, t) {
|
|
8904
|
+
let { installComponents: n } = await import("./chunks/write-result-C1GYInL8.js").then((e) => e.l);
|
|
8895
8905
|
return n(e, t);
|
|
8896
8906
|
}
|
|
8897
|
-
async function
|
|
8898
|
-
let { listComponents: n } = await import("./chunks/ui-
|
|
8907
|
+
async function Ny(e, t) {
|
|
8908
|
+
let { listComponents: n } = await import("./chunks/ui-IkdkLwmB.js");
|
|
8899
8909
|
return n(e, t);
|
|
8900
8910
|
}
|
|
8901
|
-
async function
|
|
8902
|
-
let { switchStyle: n } = await import("./chunks/ui-
|
|
8911
|
+
async function Py(e, t) {
|
|
8912
|
+
let { switchStyle: n } = await import("./chunks/ui-IkdkLwmB.js");
|
|
8903
8913
|
return n(e, t);
|
|
8904
8914
|
}
|
|
8905
|
-
async function
|
|
8906
|
-
let { applyBaseColor: n } = await import("./chunks/ui-
|
|
8915
|
+
async function Fy(e, t) {
|
|
8916
|
+
let { applyBaseColor: n } = await import("./chunks/ui-IkdkLwmB.js");
|
|
8907
8917
|
return n(e, t);
|
|
8908
8918
|
}
|
|
8909
|
-
async function
|
|
8910
|
-
let { applyTheme: n } = await import("./chunks/ui-
|
|
8919
|
+
async function Iy(e, t) {
|
|
8920
|
+
let { applyTheme: n } = await import("./chunks/ui-IkdkLwmB.js");
|
|
8911
8921
|
return n(e, t);
|
|
8912
8922
|
}
|
|
8913
|
-
async function
|
|
8923
|
+
async function Ly(e) {
|
|
8914
8924
|
let { detectProviders: t } = await import("./chunks/providers-BB3Z2TrN.js");
|
|
8915
|
-
return t(e,
|
|
8925
|
+
return t(e, ky);
|
|
8916
8926
|
}
|
|
8917
|
-
async function
|
|
8927
|
+
async function Ry(e, t) {
|
|
8918
8928
|
let { modifyEnvVars: n } = await import("./chunks/env-vars-CVn2076k.js");
|
|
8919
8929
|
return n(e, t);
|
|
8920
8930
|
}
|
|
8921
|
-
async function
|
|
8931
|
+
async function zy(e, t) {
|
|
8922
8932
|
let { unmodifyEnvVars: n } = await import("./chunks/env-vars-CVn2076k.js");
|
|
8923
8933
|
return n(e, t);
|
|
8924
8934
|
}
|
|
8925
|
-
async function
|
|
8935
|
+
async function By(e, t) {
|
|
8926
8936
|
let { ensurePackageImports: n } = await import("./chunks/package-imports-CcIIHbp5.js").then((e) => e.n);
|
|
8927
8937
|
return n(e, t);
|
|
8928
8938
|
}
|
|
8929
|
-
async function
|
|
8939
|
+
async function Vy(e, t, n) {
|
|
8930
8940
|
let { removePackageImports: r } = await import("./chunks/package-imports-CcIIHbp5.js").then((e) => e.n);
|
|
8931
8941
|
return r(e, t, n);
|
|
8932
8942
|
}
|
|
8933
|
-
async function
|
|
8943
|
+
async function Hy(e, t) {
|
|
8934
8944
|
let { ensurePackageOverrides: n } = await import("./chunks/package-imports-CcIIHbp5.js").then((e) => e.n);
|
|
8935
8945
|
return n(e, t);
|
|
8936
8946
|
}
|
|
8937
|
-
export { le as ADAPTER_NODE, oe as ADAPTER_STATIC, f as ENV_DECL_CANDIDATES, v as FLASH, se as FORMSNAP, a as InvalidArgumentError, r as MissingShadcnError, y as NEGOTIATE, h as NODE_FLOOR, i as RegistryUnavailableError, ue as SUPERFORMS, te as SUPERFORMS_VERSION, ie as VELASTACK_CMS, re as VELASTACK_KIT, _ as VELASTACK_POCKETBASE, p as VERSIONS, de as VERSION_HOLDS, g as VERSION_TRACKS,
|
|
8947
|
+
export { le as ADAPTER_NODE, oe as ADAPTER_STATIC, f as ENV_DECL_CANDIDATES, v as FLASH, se as FORMSNAP, a as InvalidArgumentError, r as MissingShadcnError, y as NEGOTIATE, h as NODE_FLOOR, i as RegistryUnavailableError, ue as SUPERFORMS, te as SUPERFORMS_VERSION, ie as VELASTACK_CMS, re as VELASTACK_KIT, _ as VELASTACK_POCKETBASE, p as VERSIONS, de as VERSION_HOLDS, g as VERSION_TRACKS, Fy as applyBaseColor, Iy as applyTheme, Gr as blockingFeatures, jy as byCategory, Ay as bySlug, me as capabilityName, Ly as detectProviders, By as ensurePackageImports, Hy as ensurePackageOverrides, d as envVarEntry, u as envVarsFile, My as installComponents, l as isLibSpecifier, s as libAliasPath, c as libModule, o as libSpecifier, Ny as listComponents, Ry as modifyEnvVars, ky as patterns, pe as providerEnvVars, he as providerFromArgv, _e as providerMarkers, Vy as removePackageImports, x as resolveProvider, m as spec, Py as switchStyle, ye as unknownProviderMessage, Kr as unmetRequirements, zy as unmodifyEnvVars, Oy as version };
|
|
8938
8948
|
|
|
8939
8949
|
//# sourceMappingURL=index.js.map
|