@velastack/patterns 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/generate-6JS05dWK.js +79 -0
- package/dist/chunks/generate-6JS05dWK.js.map +1 -0
- package/dist/chunks/generate-BZ741GPx.js +177 -0
- package/dist/chunks/generate-BZ741GPx.js.map +1 -0
- package/dist/chunks/{generate.runtime-1ldXcpiD.js → generate.runtime-BC6CBKh6.js} +2 -2
- package/dist/chunks/{generate.runtime-1ldXcpiD.js.map → generate.runtime-BC6CBKh6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-WeDv05E2.js → generate.runtime-BDbotRNZ.js} +2 -2
- package/dist/chunks/{generate.runtime-WeDv05E2.js.map → generate.runtime-BDbotRNZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CHQ_MQJQ.js → generate.runtime-C7tlPKH1.js} +2 -2
- package/dist/chunks/{generate.runtime-CHQ_MQJQ.js.map → generate.runtime-C7tlPKH1.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CGjDfO1P.js → generate.runtime-Cj-5fzbQ.js} +2 -2
- package/dist/chunks/{generate.runtime-CGjDfO1P.js.map → generate.runtime-Cj-5fzbQ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-aKNvrk3M.js → generate.runtime-Dt3Edp8-.js} +85 -74
- package/dist/chunks/generate.runtime-Dt3Edp8-.js.map +1 -0
- package/dist/chunks/{generate.runtime-Dq6yS7tN.js → generate.runtime-Du84quuK.js} +2 -2
- package/dist/chunks/{generate.runtime-Dq6yS7tN.js.map → generate.runtime-Du84quuK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CHS5lyHL.js → generate.runtime-KrQk7mqG.js} +38 -35
- package/dist/chunks/generate.runtime-KrQk7mqG.js.map +1 -0
- package/dist/chunks/root-layout.svelte-CsJ2QJYi.js +93 -0
- package/dist/chunks/root-layout.svelte-CsJ2QJYi.js.map +1 -0
- package/dist/chunks/site-VrqOvuiU.js +149 -0
- package/dist/chunks/site-VrqOvuiU.js.map +1 -0
- package/dist/index.js +678 -675
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/generate-BOQA-Flq.js +0 -171
- package/dist/chunks/generate-BOQA-Flq.js.map +0 -1
- package/dist/chunks/generate-CO88bEvs.js +0 -76
- package/dist/chunks/generate-CO88bEvs.js.map +0 -1
- package/dist/chunks/generate.runtime-CHS5lyHL.js.map +0 -1
- package/dist/chunks/generate.runtime-aKNvrk3M.js.map +0 -1
- package/dist/chunks/site-Dw2KIRJu.js +0 -108
- package/dist/chunks/site-Dw2KIRJu.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import { i as e, r as t, t as n } from "./chunks/rolldown-runtime-5HNE8Q1r.js";
|
|
|
2
2
|
import { n as r, r as i, t as a } from "./chunks/errors-DR3gF_7a.js";
|
|
3
3
|
import { i as o, n as s, r as c, t as l } from "./chunks/lib-specifier-Cngo1zF_.js";
|
|
4
4
|
import { i as u, r as d, t as f } from "./chunks/env-vars-file-B_6esJW3.js";
|
|
5
|
-
import { _ as p, a as m, c as h, d as g, f as _, h as v, l as y, m as
|
|
6
|
-
import { a as
|
|
7
|
-
import { a as
|
|
5
|
+
import { _ as p, a as m, c as h, d as g, f as _, h as v, l as y, m as b, n as ee, o as te, p as ne, t as re, u as ie, v as ae, y as x } from "./chunks/constants-Bdx8mp7v.js";
|
|
6
|
+
import { a as S, i as oe, n as se, o as C, r as w, t as T } from "./chunks/util-BLYliuUK.js";
|
|
7
|
+
import { a as ce, c as E, n as le, o as ue, r as de, s as fe, t as pe, u as me } from "./chunks/providers-CL9kQ4hp.js";
|
|
8
8
|
import { t as D } from "./chunks/format-result-BVoLVknk.js";
|
|
9
9
|
import { t as O } from "./chunks/dedent-Gq6Krl4n.js";
|
|
10
10
|
import { C as he, S as ge, _ as k, b as A, c as _e, i as ve, n as ye, s as be, v as xe, w as Se, x as Ce, y as we } from "./chunks/generate-l2JZTRKb.js";
|
|
@@ -16,19 +16,19 @@ import { $ as Ae, $t as je, A as Me, At as Ne, B as Pe, Bt as Fe, C as Ie, Ct as
|
|
|
16
16
|
import { t as Xn } from "./chunks/env-vars-mnRA0hOe.js";
|
|
17
17
|
import { t as Zn } from "./chunks/generate-DoHn_xJZ.js";
|
|
18
18
|
import { t as Qn } from "./chunks/pocketbase-DpudAAmd.js";
|
|
19
|
-
import { i as $n, n as er, r as tr, t as nr } from "./chunks/generate-
|
|
19
|
+
import { i as $n, n as er, r as tr, t as nr } from "./chunks/generate-BZ741GPx.js";
|
|
20
20
|
import { a as rr, n as ir, t as ar } from "./chunks/collections-BrEA7a62.js";
|
|
21
|
-
import {
|
|
21
|
+
import { o as or } from "./chunks/site-VrqOvuiU.js";
|
|
22
22
|
import { a as sr, i as cr, n as lr, o as ur, r as dr, s as fr, t as pr } from "./chunks/dispatch-BIvOwbKN.js";
|
|
23
23
|
import { t as mr } from "./chunks/pocketbase-C5GS-Dh5.js";
|
|
24
24
|
import { t as hr } from "./chunks/env-vars-Cr4lbMD_.js";
|
|
25
25
|
import { n as N, t as gr } from "./chunks/shared-BbxLil4g.js";
|
|
26
26
|
import { i as _r } from "./chunks/generate-Df7t5Nbk.js";
|
|
27
27
|
import { r as vr } from "./chunks/generate-CNabcEBx.js";
|
|
28
|
-
import { n as yr, t as br } from "./chunks/generate-
|
|
28
|
+
import { n as yr, t as br } from "./chunks/generate-6JS05dWK.js";
|
|
29
29
|
var xr = {
|
|
30
30
|
name: "@velastack/patterns",
|
|
31
|
-
version: "0.
|
|
31
|
+
version: "0.8.0",
|
|
32
32
|
description: "Registry of VelaStack patterns: generators and modifications applied to SvelteKit projects by the VelaStack CLI.",
|
|
33
33
|
type: "module",
|
|
34
34
|
private: !1,
|
|
@@ -1280,12 +1280,12 @@ function gi(e, t, n = {}) {
|
|
|
1280
1280
|
let n = f(e) - f(t);
|
|
1281
1281
|
return n === 0 ? p(e).localeCompare(p(t)) : n;
|
|
1282
1282
|
});
|
|
1283
|
-
let _ = m[0], v = _.map((e) => e.fieldName), y = [t, ..._.map((e) => e.to)],
|
|
1283
|
+
let _ = m[0], v = _.map((e) => e.fieldName), y = [t, ..._.map((e) => e.to)], b = _[_.length - 1].isMulti ? "?=" : "=", ee = v.join(".");
|
|
1284
1284
|
return {
|
|
1285
|
-
rule: `@request.auth.id ${
|
|
1285
|
+
rule: `@request.auth.id ${b} ${n.includeRootPrefix ? (n.rootPrefix ?? t) + "." : ""}${ee}.id`,
|
|
1286
1286
|
ownershipChainCollections: y,
|
|
1287
1287
|
ownershipChainFields: v,
|
|
1288
|
-
operator:
|
|
1288
|
+
operator: b
|
|
1289
1289
|
};
|
|
1290
1290
|
}
|
|
1291
1291
|
//#endregion
|
|
@@ -2413,7 +2413,7 @@ function ma(e, t, n, r, i, a) {
|
|
|
2413
2413
|
function ha(e, t) {
|
|
2414
2414
|
return {
|
|
2415
2415
|
path: e,
|
|
2416
|
-
language:
|
|
2416
|
+
language: S(e),
|
|
2417
2417
|
content: t,
|
|
2418
2418
|
status: "success"
|
|
2419
2419
|
};
|
|
@@ -2433,7 +2433,7 @@ async function ga(e) {
|
|
|
2433
2433
|
modifies: [],
|
|
2434
2434
|
deletes: [],
|
|
2435
2435
|
components: c === "plain" ? [] : L(p),
|
|
2436
|
-
packages: [
|
|
2436
|
+
packages: [ie, x],
|
|
2437
2437
|
collections: [],
|
|
2438
2438
|
collectionPatches: [],
|
|
2439
2439
|
collectionDrops: []
|
|
@@ -2653,7 +2653,7 @@ function za(e, t, n, r, i, a) {
|
|
|
2653
2653
|
function Ba(e, t) {
|
|
2654
2654
|
return {
|
|
2655
2655
|
path: e,
|
|
2656
|
-
language:
|
|
2656
|
+
language: S(e),
|
|
2657
2657
|
content: t,
|
|
2658
2658
|
status: "success"
|
|
2659
2659
|
};
|
|
@@ -2674,7 +2674,7 @@ async function Va(e) {
|
|
|
2674
2674
|
modifies: [],
|
|
2675
2675
|
deletes: [],
|
|
2676
2676
|
components: _,
|
|
2677
|
-
packages: [
|
|
2677
|
+
packages: [x],
|
|
2678
2678
|
collections: [],
|
|
2679
2679
|
collectionPatches: [],
|
|
2680
2680
|
collectionDrops: []
|
|
@@ -2687,10 +2687,10 @@ async function Wa(e) {
|
|
|
2687
2687
|
return {
|
|
2688
2688
|
creates: [],
|
|
2689
2689
|
modifies: Object.entries(Ha).map(([e, t]) => {
|
|
2690
|
-
let n =
|
|
2690
|
+
let n = T(e, Ua);
|
|
2691
2691
|
return {
|
|
2692
2692
|
path: n,
|
|
2693
|
-
language:
|
|
2693
|
+
language: S(n),
|
|
2694
2694
|
content: t,
|
|
2695
2695
|
status: "success"
|
|
2696
2696
|
};
|
|
@@ -2710,7 +2710,7 @@ async function Ya(e) {
|
|
|
2710
2710
|
let t = await Va(e);
|
|
2711
2711
|
if (e.env === "preview") {
|
|
2712
2712
|
let n = await Wa(e);
|
|
2713
|
-
return D(
|
|
2713
|
+
return D(C([t, n]), e);
|
|
2714
2714
|
}
|
|
2715
2715
|
if (e.env !== "runtime") return D(t, e);
|
|
2716
2716
|
let { modifyOutcomeToFile: n } = await import("./chunks/modify-file-B4uJzOEj.js").then((e) => e.i), { modifySvelteConfigRemote: r } = await import("./chunks/modify-svelte-config-remote-CEyYydL7.js");
|
|
@@ -2943,7 +2943,7 @@ function co(e) {
|
|
|
2943
2943
|
function lo(e, t) {
|
|
2944
2944
|
return {
|
|
2945
2945
|
path: e,
|
|
2946
|
-
language:
|
|
2946
|
+
language: S(e),
|
|
2947
2947
|
content: t,
|
|
2948
2948
|
status: "success"
|
|
2949
2949
|
};
|
|
@@ -3244,7 +3244,7 @@ function Lo(e) {
|
|
|
3244
3244
|
function Q(e, t) {
|
|
3245
3245
|
return {
|
|
3246
3246
|
path: e,
|
|
3247
|
-
language:
|
|
3247
|
+
language: S(e),
|
|
3248
3248
|
content: t,
|
|
3249
3249
|
status: "success"
|
|
3250
3250
|
};
|
|
@@ -3551,7 +3551,7 @@ async function is(e) {
|
|
|
3551
3551
|
new: qo(r, d, m, h, f),
|
|
3552
3552
|
show: Qo(r, d, m, f),
|
|
3553
3553
|
edit: Jo(r, d, m, h, f)
|
|
3554
|
-
},
|
|
3554
|
+
}, b = [
|
|
3555
3555
|
Q(`src/lib/schemas/${r.name}.ts`, K(r, i, {
|
|
3556
3556
|
includeModelFields: !0,
|
|
3557
3557
|
forForm: !0
|
|
@@ -3565,7 +3565,7 @@ async function is(e) {
|
|
|
3565
3565
|
Q(`${u.edit}/+page.server.ts`, rs(r, d, m, h, p, f)),
|
|
3566
3566
|
Q(`${u.edit}/+page.svelte`, y.edit),
|
|
3567
3567
|
...v ? [Q(`${u.list}/server.test.ts`, Bi(r, d, i, e, c, f))] : []
|
|
3568
|
-
],
|
|
3568
|
+
], ee = g === "plain" ? [] : [
|
|
3569
3569
|
...L(m),
|
|
3570
3570
|
"button",
|
|
3571
3571
|
"table",
|
|
@@ -3584,13 +3584,13 @@ async function is(e) {
|
|
|
3584
3584
|
"row-actions"
|
|
3585
3585
|
];
|
|
3586
3586
|
return {
|
|
3587
|
-
creates:
|
|
3587
|
+
creates: b,
|
|
3588
3588
|
modifies: [],
|
|
3589
3589
|
deletes: [],
|
|
3590
|
-
components: [...new Set(
|
|
3591
|
-
packages: g === "plain" ? [
|
|
3592
|
-
|
|
3593
|
-
|
|
3590
|
+
components: [...new Set(ee)],
|
|
3591
|
+
packages: g === "plain" ? [ie, x] : [
|
|
3592
|
+
ie,
|
|
3593
|
+
x,
|
|
3594
3594
|
_
|
|
3595
3595
|
],
|
|
3596
3596
|
collections: s ? [ea(r, i, o)] : [],
|
|
@@ -3683,7 +3683,7 @@ function ms(e) {
|
|
|
3683
3683
|
function $(e, t) {
|
|
3684
3684
|
return {
|
|
3685
3685
|
path: e,
|
|
3686
|
-
language:
|
|
3686
|
+
language: S(e),
|
|
3687
3687
|
content: t,
|
|
3688
3688
|
status: "success"
|
|
3689
3689
|
};
|
|
@@ -3934,10 +3934,10 @@ async function Ls(e) {
|
|
|
3934
3934
|
return {
|
|
3935
3935
|
creates: [],
|
|
3936
3936
|
modifies: Object.entries(Fs).map(([e, t]) => {
|
|
3937
|
-
let n =
|
|
3937
|
+
let n = T(e, Is);
|
|
3938
3938
|
return {
|
|
3939
3939
|
path: n,
|
|
3940
|
-
language:
|
|
3940
|
+
language: S(n),
|
|
3941
3941
|
content: t,
|
|
3942
3942
|
status: "success"
|
|
3943
3943
|
};
|
|
@@ -3961,7 +3961,7 @@ async function Hs(e) {
|
|
|
3961
3961
|
let t = await Ps(e);
|
|
3962
3962
|
if (e.env === "preview") {
|
|
3963
3963
|
let n = await Ls(e);
|
|
3964
|
-
return D(
|
|
3964
|
+
return D(C([t, n]), e);
|
|
3965
3965
|
}
|
|
3966
3966
|
if (e.env !== "runtime") return D(t, e);
|
|
3967
3967
|
let { createCollections: n } = await import("./chunks/collections-BYcVyY9O.js").then((e) => e.n), r = await n(t.collections, e), { modifyOutcomeToFile: i } = await import("./chunks/modify-file-B4uJzOEj.js").then((e) => e.i), { modifySvelteConfigRemote: a } = await import("./chunks/modify-svelte-config-remote-CEyYydL7.js");
|
|
@@ -4046,7 +4046,7 @@ function Ws(e) {
|
|
|
4046
4046
|
function Gs(e, t) {
|
|
4047
4047
|
return {
|
|
4048
4048
|
path: e,
|
|
4049
|
-
language:
|
|
4049
|
+
language: S(e),
|
|
4050
4050
|
content: t,
|
|
4051
4051
|
status: "success"
|
|
4052
4052
|
};
|
|
@@ -4061,7 +4061,7 @@ async function Ks(e) {
|
|
|
4061
4061
|
modifies: [],
|
|
4062
4062
|
deletes: [],
|
|
4063
4063
|
components: [],
|
|
4064
|
-
packages: [
|
|
4064
|
+
packages: [x],
|
|
4065
4065
|
collections: [],
|
|
4066
4066
|
collectionPatches: [],
|
|
4067
4067
|
collectionDrops: []
|
|
@@ -4128,7 +4128,7 @@ var Qs = {
|
|
|
4128
4128
|
tests: 0,
|
|
4129
4129
|
baseline: "velastack",
|
|
4130
4130
|
generate: Zs
|
|
4131
|
-
}, $s = "<script lang=\"ts\">\n import { formatMoney } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"mb-6 text-2xl font-semibold\">Shop</h1>\n\n {#if data.products.length === 0}\n <p class=\"text-muted-foreground\">\n Nothing for sale yet. Products live in Shopify admin; publish them to the Headless channel\n the Storefront token belongs to.\n </p>\n {:else}\n <ul class=\"grid gap-6 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.products as product (product.id)}\n <li class=\"rounded-lg border p-4\">\n <a href=\"/shop/{product.handle}\" class=\"flex flex-col gap-3\">\n {#if product.featuredImage}\n <img\n src={product.featuredImage.url}\n alt={product.featuredImage.altText ?? ''}\n class=\"aspect-square w-full rounded object-cover\"\n />\n {/if}\n <div>\n <h2 class=\"font-medium\">{product.title}</h2>\n <p class=\"text-muted-foreground text-sm\">\n From {formatMoney(product.priceRange.minVariantPrice)}\n </p>\n </div>\n </a>\n </li>\n {/each}\n </ul>\n {/if}\n</section>\n", ec = "import { error } from '@sveltejs/kit';\nimport { storefront } from '#lib/shopify.js';\n\nexport interface Money {\n amount: string;\n currencyCode: string;\n}\n\nexport interface ProductCard {\n id: string;\n handle: string;\n title: string;\n featuredImage: { url: string; altText: string | null } | null;\n priceRange: { minVariantPrice: Money };\n}\n\nconst PRODUCTS = `#graphql\n query Products {\n products(first: 100, sortKey: TITLE) {\n nodes {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n`;\n\n// The Storefront token is public, so the same load runs on the server and in\n// the browser. It is not prerendered: the catalog changes without a rebuild.\nexport const prerender = false;\n\nexport const load = async () => {\n const { data, errors } = await storefront().request(PRODUCTS);\n if (errors) error(502, errors.message ?? 'Shopify did not answer.');\n return { products: (data?.products.nodes ?? []) as ProductCard[] };\n};\n", tc = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatMoney } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n\n // One value per option, starting from the first variant that can be bought.\n // The variant for sale is the one whose options all match.\n const first = data.product.variants.nodes.find((v) => v.availableForSale) ??\n data.product.variants.nodes[0];\n let chosen = $state<Record<string, string>>(\n Object.fromEntries(first.selectedOptions.map((option) => [option.name, option.value]))\n );\n const variant = $derived(\n data.product.variants.nodes.find((candidate) =>\n candidate.selectedOptions.every((option) => chosen[option.name] === option.value)\n )\n );\n // A product with one variant has a single option Shopify calls \"Title\".\n const options = $derived(\n data.product.options.filter((option) => option.optionValues.length > 1)\n );\n<\/script>\n\n<section data-role=\"content\" class=\"grid gap-8 md:grid-cols-2\">\n <div class=\"flex flex-col gap-3\">\n {#each data.product.images.nodes.slice(0, 1) as image (image.url)}\n <img src={image.url} alt={image.altText ?? ''} class=\"aspect-square w-full rounded-lg object-cover\" />\n {/each}\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/shop\">Shop</a></p>\n <h1 class=\"text-2xl font-semibold\">{data.product.title}</h1>\n {#if variant}\n <p class=\"mt-2 text-lg\">{formatMoney(variant.price)}</p>\n {/if}\n </div>\n\n {#each options as option (option.name)}\n <div class=\"flex flex-col gap-2\">\n <p class=\"text-sm font-medium\">{option.name}</p>\n <div class=\"flex flex-wrap gap-2\" role=\"radiogroup\" aria-label={option.name}>\n {#each option.optionValues as value (value.name)}\n <Button\n variant={chosen[option.name] === value.name ? 'default' : 'outline'}\n size=\"sm\"\n role=\"radio\"\n aria-checked={chosen[option.name] === value.name}\n onclick={() => (chosen = { ...chosen, [option.name]: value.name })}\n >\n {value.name}\n </Button>\n {/each}\n </div>\n </div>\n {/each}\n\n {#if variant}\n <AddToCart\n merchandiseId={variant.id}\n size=\"lg\"\n disabled={!variant.availableForSale}\n label={variant.availableForSale ? 'Add to cart' : 'Sold out'}\n />\n {:else}\n <p class=\"text-muted-foreground text-sm\">That combination is not available.</p>\n {/if}\n\n {#if data.product.descriptionHtml}\n <!-- The description as written in Shopify admin, which is HTML. -->\n <div class=\"prose prose-sm text-muted-foreground\">{@html data.product.descriptionHtml}</div>\n {/if}\n </div>\n</section>\n", nc = "import { error } from '@sveltejs/kit';\nimport { storefront } from '#lib/shopify.js';\nimport type { Money } from '../+page.js';\n\nexport interface Variant {\n id: string;\n title: string;\n availableForSale: boolean;\n price: Money;\n selectedOptions: { name: string; value: string }[];\n}\n\nexport interface Product {\n id: string;\n title: string;\n descriptionHtml: string;\n images: { nodes: { url: string; altText: string | null }[] };\n options: { name: string; optionValues: { name: string }[] }[];\n variants: { nodes: Variant[] };\n}\n\nconst PRODUCT = `#graphql\n query Product($handle: String!) {\n product(handle: $handle) {\n id\n title\n descriptionHtml\n images(first: 4) {\n nodes {\n url\n altText\n }\n }\n options {\n name\n optionValues {\n name\n }\n }\n variants(first: 100) {\n nodes {\n id\n title\n availableForSale\n price {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n`;\n\nexport const prerender = false;\n\nexport const load = async ({ params }) => {\n const { data, errors } = await storefront().request(PRODUCT, {\n variables: { handle: params.handle }\n });\n if (errors) error(502, errors.message ?? 'Shopify did not answer.');\n const product = data?.product as Product | null | undefined;\n if (!product) error(404, 'Not found');\n return { product };\n};\n", rc = "/** The fields of the synced catalog this page reads. */\ninterface ProductRecord {\n id: string;\n name?: string;\n /** Stripe's boolean, stored by the sync in a text field. */\n active?: unknown;\n default_price?: string;\n description?: string;\n images?: unknown;\n metadata?: unknown;\n}\n\ninterface PriceRecord {\n id: string;\n product?: string;\n unit_amount?: number;\n currency?: string;\n}\n\nconst isActive = (product: ProductRecord) => String(product.active) !== 'false';\n\nconst slugOf = (product: ProductRecord): string => {\n const metadata = product.metadata as { slug?: unknown } | null | undefined;\n return typeof metadata?.slug === 'string' && metadata.slug ? metadata.slug : product.id;\n};\n\nconst firstImage = (product: ProductRecord): string | null =>\n Array.isArray(product.images) && typeof product.images[0] === 'string'\n ? product.images[0]\n : null;\n\n/**\n * The catalog, as the sync copied it from Stripe: every active product with\n * its default one-time price (or its first active one). A product's\n * `metadata.slug`, when set in the Stripe dashboard, names its page.\n */\nexport const load = async ({ locals }) => {\n const [products, prices] = await Promise.all([\n locals.admin.collection('stripe_products').getFullList<ProductRecord>({ sort: 'name' }),\n locals.admin\n .collection('stripe_prices')\n .getFullList<PriceRecord>({ filter: 'active = true && type = \"one_time\"' })\n ]);\n\n return {\n products: products.filter(isActive).flatMap((product) => {\n const price =\n prices.find((candidate) => candidate.id === product.default_price) ??\n prices.find((candidate) => candidate.product === product.id);\n if (!price?.currency) return [];\n const name = product.name ?? product.id;\n return [\n {\n id: product.id,\n slug: slugOf(product),\n name,\n description: product.description ?? null,\n image: firstImage(product),\n price: {\n price: price.id,\n name,\n unitAmount: price.unit_amount ?? 0,\n currency: price.currency\n }\n }\n ];\n })\n };\n};\n", ic = "<script lang=\"ts\">\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatAmount } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"mb-6 text-2xl font-semibold\">Shop</h1>\n\n {#if data.products.length === 0}\n <p class=\"text-muted-foreground\">\n Nothing for sale yet. Products and prices come from your Stripe dashboard; the catalog syncs\n every ten minutes.\n </p>\n {:else}\n <ul class=\"grid gap-6 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.products as product (product.id)}\n <li class=\"flex flex-col gap-3 rounded-lg border p-4\">\n <a href=\"/shop/{product.slug}\" class=\"flex flex-col gap-3\">\n {#if product.image}\n <img src={product.image} alt=\"\" class=\"aspect-square w-full rounded object-cover\" />\n {/if}\n <div>\n <h2 class=\"font-medium\">{product.name}</h2>\n <p class=\"text-muted-foreground text-sm\">\n {formatAmount(product.price.unitAmount, product.price.currency)}\n </p>\n </div>\n </a>\n <AddToCart price={product.price} class=\"mt-auto\" />\n </li>\n {/each}\n </ul>\n {/if}\n</section>\n", ac = "import { error } from '@sveltejs/kit';\n\n/** The fields of the synced catalog this page reads. */\ninterface ProductRecord {\n id: string;\n name?: string;\n /** Stripe's boolean, stored by the sync in a text field. */\n active?: unknown;\n default_price?: string;\n description?: string;\n images?: unknown;\n}\n\ninterface PriceRecord {\n id: string;\n nickname?: string;\n unit_amount?: number;\n currency?: string;\n}\n\nconst isActive = (product: ProductRecord) => String(product.active) !== 'false';\n\nconst images = (product: ProductRecord): string[] =>\n Array.isArray(product.images)\n ? product.images.filter((image): image is string => typeof image === 'string')\n : [];\n\n/**\n * One product and its active one-time prices (sizes, say), by its\n * `metadata.slug` from the Stripe dashboard or its id.\n */\nexport const load = async ({ locals, params }) => {\n const products = locals.admin.collection('stripe_products');\n const product = await products\n .getFirstListItem<ProductRecord>(\n locals.admin.filter('metadata.slug = {:slug}', { slug: params.product })\n )\n .catch(() => products.getOne<ProductRecord>(params.product))\n .catch(() => null);\n if (!product || !isActive(product)) error(404, 'Not found');\n\n const prices = await locals.admin.collection('stripe_prices').getFullList<PriceRecord>({\n filter: locals.admin.filter('product = {:product} && active = true && type = \"one_time\"', {\n product: product.id\n }),\n sort: 'unit_amount'\n });\n const priced = prices.filter((price): price is PriceRecord & { currency: string } =>\n Boolean(price.currency)\n );\n if (priced.length === 0) error(404, 'Not found');\n\n const name = product.name ?? product.id;\n return {\n product: {\n id: product.id,\n name,\n description: product.description ?? null,\n images: images(product),\n defaultPrice: product.default_price ?? null\n },\n prices: priced.map((price) => ({\n price: price.id,\n name,\n // What the dashboard calls this price, when there is more than one.\n nickname: price.nickname ?? null,\n unitAmount: price.unit_amount ?? 0,\n currency: price.currency\n }))\n };\n};\n", oc = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatAmount } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n\n // The default price first, or the cheapest; with one price there is nothing to pick.\n let selectedId = $state(\n data.prices.find((price) => price.price === data.product.defaultPrice)?.price ??\n data.prices[0].price\n );\n const selected = $derived(data.prices.find((price) => price.price === selectedId) ?? data.prices[0]);\n<\/script>\n\n<section data-role=\"content\" class=\"grid gap-8 md:grid-cols-2\">\n <div class=\"flex flex-col gap-3\">\n {#each data.product.images.slice(0, 1) as image (image)}\n <img src={image} alt=\"\" class=\"aspect-square w-full rounded-lg object-cover\" />\n {/each}\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/shop\">Shop</a></p>\n <h1 class=\"text-2xl font-semibold\">{data.product.name}</h1>\n <p class=\"mt-2 text-lg\">{formatAmount(selected.unitAmount, selected.currency)}</p>\n </div>\n\n {#if data.product.description}\n <p class=\"text-muted-foreground\">{data.product.description}</p>\n {/if}\n\n {#if data.prices.length > 1}\n <div class=\"flex flex-wrap gap-2\" role=\"radiogroup\" aria-label=\"Option\">\n {#each data.prices as price (price.price)}\n <Button\n variant={price.price === selectedId ? 'default' : 'outline'}\n size=\"sm\"\n role=\"radio\"\n aria-checked={price.price === selectedId}\n onclick={() => (selectedId = price.price)}\n >\n {price.nickname ?? formatAmount(price.unitAmount, price.currency)}\n </Button>\n {/each}\n </div>\n {/if}\n\n <AddToCart price={selected} size=\"lg\" />\n </div>\n</section>\n", sc = "/**\n * What the shop sells. Edit this list: it is the catalog the `/shop` pages\n * read. Prices are in `site.currency` (src/lib/site.ts), written as you would\n * write them (`4.5`); leave one out to quote in the chat instead.\n */\nexport interface Product {\n /** Your own id for the item (a slug or SKU); it is the item's URL and its cart line. */\n id: string;\n name: string;\n description?: string;\n price?: number;\n /** A URL, or a path under `static/`. */\n image?: string;\n}\n\nexport const catalog: Product[] = [\n {\n id: 'concha',\n name: 'Concha',\n description: 'A sweet bun with a vanilla or cocoa shell.',\n price: 12\n },\n {\n id: 'birthday-cake',\n name: 'Birthday cake',\n description: 'Say the size and the day you need it in the chat.'\n }\n];\n\nexport const product = (id: string): Product | undefined => catalog.find((item) => item.id === id);\n", cc = "<script lang=\"ts\">\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { catalog } from '#lib/catalog.js';\n import { formatPrice } from '#lib/order.js';\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"mb-6 text-2xl font-semibold\">Shop</h1>\n\n <ul class=\"grid gap-6 sm:grid-cols-2 lg:grid-cols-3\">\n {#each catalog as item (item.id)}\n <li class=\"flex flex-col gap-3 rounded-lg border p-4\">\n <a href=\"/shop/{item.id}\" class=\"flex flex-col gap-3\">\n {#if item.image}\n <img src={item.image} alt=\"\" class=\"aspect-square w-full rounded object-cover\" />\n {/if}\n <div>\n <h2 class=\"font-medium\">{item.name}</h2>\n <p class=\"text-muted-foreground text-sm\">\n {#if item.price !== undefined}\n {formatPrice(item.price)}\n {:else}\n Price on request\n {/if}\n </p>\n </div>\n </a>\n <AddToCart id={item.id} name={item.name} price={item.price} class=\"mt-auto\" />\n </li>\n {/each}\n </ul>\n</section>\n", lc = "<script lang=\"ts\">\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatPrice } from '#lib/order.js';\n\n let { data } = $props();\n<\/script>\n\n<section data-role=\"content\" class=\"grid gap-8 md:grid-cols-2\">\n <div>\n {#if data.item.image}\n <img src={data.item.image} alt=\"\" class=\"aspect-square w-full rounded-lg object-cover\" />\n {/if}\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/shop\">Shop</a></p>\n <h1 class=\"text-2xl font-semibold\">{data.item.name}</h1>\n <p class=\"mt-2 text-lg\">\n {#if data.item.price !== undefined}\n {formatPrice(data.item.price)}\n {:else}\n <span class=\"text-muted-foreground\">We'll confirm the price in WhatsApp.</span>\n {/if}\n </p>\n </div>\n\n {#if data.item.description}\n <p class=\"text-muted-foreground\">{data.item.description}</p>\n {/if}\n\n <AddToCart id={data.item.id} name={data.item.name} price={data.item.price} size=\"lg\" />\n </div>\n</section>\n", uc = "import { error } from '@sveltejs/kit';\nimport { catalog, product } from '#lib/catalog.js';\n\n// The catalog is a module, so every item's page can be prerendered.\nexport const entries = () => catalog.map(({ id }) => ({ id }));\n\nexport const load = ({ params }) => {\n const item = product(params.id);\n if (!item) error(404, 'Not found');\n return { item };\n};\n", dc = "<script lang=\"ts\">\n import { CmsCollection, CmsText, type CollectionItem } from '@velastack/cms';\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatPrice } from '#lib/order.js';\n\n // The catalog is edited in place: open the page with `?edit` to add items.\n // It lives in the root layout scope, so the product pages read the same\n // list. Prices are in `site.currency` (src/lib/site.ts); an item without\n // one is quoted in the chat.\n const sample: Partial<CollectionItem>[] = [\n {\n id: 'concha',\n title: 'Concha',\n summary: 'A sweet bun with a vanilla or cocoa shell.',\n price: { amount: 12, currency: '', period: '', prefix: '' }\n },\n {\n id: 'birthday-cake',\n title: 'Birthday cake',\n summary: 'Say the size and the day you need it in the chat.'\n }\n ];\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"mb-6 text-2xl font-semibold\"><CmsText name=\"title\" fallback=\"Shop\" /></h1>\n\n <CmsCollection name=\"catalog\" scope=\"root\" fallback={sample}>\n {#snippet children(items)}\n <ul class=\"grid gap-6 sm:grid-cols-2 lg:grid-cols-3\">\n {#each items as item (item.id)}\n <li class=\"flex flex-col gap-3 rounded-lg border p-4\">\n <a href=\"/shop/{item.id}\" class=\"flex flex-col gap-3\">\n {#if item.image?.url}\n <img src={item.image.url} alt={item.image.alt ?? ''} class=\"aspect-square w-full rounded object-cover\" />\n {/if}\n <div>\n <h2 class=\"font-medium\">{item.title}</h2>\n <p class=\"text-muted-foreground text-sm\">\n {#if item.price.amount !== null}\n {formatPrice(item.price.amount)}\n {:else}\n Price on request\n {/if}\n </p>\n </div>\n </a>\n <AddToCart\n id={item.id}\n name={item.title}\n price={item.price.amount ?? undefined}\n class=\"mt-auto\"\n />\n </li>\n {/each}\n </ul>\n {/snippet}\n </CmsCollection>\n</section>\n", fc = "<script lang=\"ts\">\n import { page } from '$app/state';\n import { CmsCollection } from '@velastack/cms';\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatPrice } from '#lib/order.js';\n<\/script>\n\n<!-- The same catalog the shop page edits, from the root layout scope. -->\n<CmsCollection name=\"catalog\" scope=\"root\">\n {#snippet children(items)}\n {@const item = items.find((candidate) => candidate.id === page.params.id)}\n <section data-role=\"content\" class=\"grid gap-8 md:grid-cols-2\">\n {#if item}\n <div>\n {#if item.image?.url}\n <img src={item.image.url} alt={item.image.alt ?? ''} class=\"aspect-square w-full rounded-lg object-cover\" />\n {/if}\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/shop\">Shop</a></p>\n <h1 class=\"text-2xl font-semibold\">{item.title}</h1>\n <p class=\"mt-2 text-lg\">\n {#if item.price.amount !== null}\n {formatPrice(item.price.amount)}\n {:else}\n <span class=\"text-muted-foreground\">We'll confirm the price in WhatsApp.</span>\n {/if}\n </p>\n </div>\n\n {#if item.summary}\n <p class=\"text-muted-foreground\">{item.summary}</p>\n {/if}\n\n <AddToCart id={item.id} name={item.title} price={item.price.amount ?? undefined} size=\"lg\" />\n </div>\n {:else}\n <div>\n <h1 class=\"text-2xl font-semibold\">Not found</h1>\n <p class=\"text-muted-foreground mt-2\"><a href=\"/shop\">Back to the shop</a></p>\n </div>\n {/if}\n </section>\n {/snippet}\n</CmsCollection>\n", pc = "// The items are CMS content, so there is no list of ids to prerender from;\n// the page renders from the catalog the shop page holds.\nexport const prerender = false;\n", mc = [
|
|
4131
|
+
}, $s = "<script lang=\"ts\">\n import { formatMoney } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"mb-6 text-2xl font-semibold\">Shop</h1>\n\n {#if data.products.length === 0}\n <p class=\"text-muted-foreground\">\n Nothing for sale yet. Products live in Shopify admin; publish them to the Headless channel\n the Storefront token belongs to.\n </p>\n {:else}\n <ul class=\"grid gap-6 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.products as product (product.id)}\n <li class=\"rounded-lg border p-4\">\n <a href=\"/shop/{product.handle}\" class=\"flex flex-col gap-3\">\n {#if product.featuredImage}\n <img\n src={product.featuredImage.url}\n alt={product.featuredImage.altText ?? ''}\n class=\"aspect-square w-full rounded object-cover\"\n />\n {/if}\n <div>\n <h2 class=\"font-medium\">{product.title}</h2>\n <p class=\"text-muted-foreground text-sm\">\n From {formatMoney(product.priceRange.minVariantPrice)}\n </p>\n </div>\n </a>\n </li>\n {/each}\n </ul>\n {/if}\n</section>\n", ec = "import { error } from '@sveltejs/kit';\nimport { storefront } from '#lib/shopify.js';\n\nexport interface Money {\n amount: string;\n currencyCode: string;\n}\n\nexport interface ProductCard {\n id: string;\n handle: string;\n title: string;\n featuredImage: { url: string; altText: string | null } | null;\n priceRange: { minVariantPrice: Money };\n}\n\nconst PRODUCTS = `#graphql\n query Products {\n products(first: 100, sortKey: TITLE) {\n nodes {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n`;\n\n// The Storefront token is public, so the same load runs on the server and in\n// the browser. It is not prerendered: the catalog changes without a rebuild.\nexport const prerender = false;\n\nexport const load = async () => {\n const { data, errors } = await storefront().request(PRODUCTS);\n if (errors) error(502, errors.message ?? 'Shopify did not answer.');\n return { products: (data?.products.nodes ?? []) as ProductCard[] };\n};\n", tc = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatMoney } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n\n // One value per option, starting from the first variant that can be bought.\n // The variant for sale is the one whose options all match.\n const first = data.product.variants.nodes.find((v) => v.availableForSale) ??\n data.product.variants.nodes[0];\n let chosen = $state<Record<string, string>>(\n Object.fromEntries(first.selectedOptions.map((option) => [option.name, option.value]))\n );\n const variant = $derived(\n data.product.variants.nodes.find((candidate) =>\n candidate.selectedOptions.every((option) => chosen[option.name] === option.value)\n )\n );\n // A product with one variant has a single option Shopify calls \"Title\".\n const options = $derived(\n data.product.options.filter((option) => option.optionValues.length > 1)\n );\n<\/script>\n\n<section data-role=\"content\" class=\"grid gap-8 md:grid-cols-2\">\n <div class=\"flex flex-col gap-3\">\n {#each data.product.images.nodes.slice(0, 1) as image (image.url)}\n <img src={image.url} alt={image.altText ?? ''} class=\"aspect-square w-full rounded-lg object-cover\" />\n {/each}\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/shop\">Shop</a></p>\n <h1 class=\"text-2xl font-semibold\">{data.product.title}</h1>\n {#if variant}\n <p class=\"mt-2 text-lg\">{formatMoney(variant.price)}</p>\n {/if}\n </div>\n\n {#each options as option (option.name)}\n <div class=\"flex flex-col gap-2\">\n <p class=\"text-sm font-medium\">{option.name}</p>\n <div class=\"flex flex-wrap gap-2\" role=\"radiogroup\" aria-label={option.name}>\n {#each option.optionValues as value (value.name)}\n <Button\n variant={chosen[option.name] === value.name ? 'default' : 'outline'}\n size=\"sm\"\n role=\"radio\"\n aria-checked={chosen[option.name] === value.name}\n onclick={() => (chosen = { ...chosen, [option.name]: value.name })}\n >\n {value.name}\n </Button>\n {/each}\n </div>\n </div>\n {/each}\n\n {#if variant}\n <AddToCart\n merchandiseId={variant.id}\n size=\"lg\"\n disabled={!variant.availableForSale}\n label={variant.availableForSale ? 'Add to cart' : 'Sold out'}\n />\n {:else}\n <p class=\"text-muted-foreground text-sm\">That combination is not available.</p>\n {/if}\n\n {#if data.product.descriptionHtml}\n <!-- The description as written in Shopify admin, which is HTML. -->\n <div class=\"prose prose-sm text-muted-foreground\">{@html data.product.descriptionHtml}</div>\n {/if}\n </div>\n</section>\n", nc = "import { error } from '@sveltejs/kit';\nimport { storefront } from '#lib/shopify.js';\nimport type { Money } from '../+page.js';\n\nexport interface Variant {\n id: string;\n title: string;\n availableForSale: boolean;\n price: Money;\n selectedOptions: { name: string; value: string }[];\n}\n\nexport interface Product {\n id: string;\n title: string;\n descriptionHtml: string;\n images: { nodes: { url: string; altText: string | null }[] };\n options: { name: string; optionValues: { name: string }[] }[];\n variants: { nodes: Variant[] };\n}\n\nconst PRODUCT = `#graphql\n query Product($handle: String!) {\n product(handle: $handle) {\n id\n title\n descriptionHtml\n images(first: 4) {\n nodes {\n url\n altText\n }\n }\n options {\n name\n optionValues {\n name\n }\n }\n variants(first: 100) {\n nodes {\n id\n title\n availableForSale\n price {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n`;\n\nexport const prerender = false;\n\nexport const load = async ({ params }) => {\n const { data, errors } = await storefront().request(PRODUCT, {\n variables: { handle: params.handle }\n });\n if (errors) error(502, errors.message ?? 'Shopify did not answer.');\n const product = data?.product as Product | null | undefined;\n if (!product) error(404, 'Not found');\n return { product };\n};\n", rc = "/** The fields of the synced catalog this page reads. */\ninterface ProductRecord {\n id: string;\n name?: string;\n /** Stripe's boolean, stored by the sync in a text field. */\n active?: unknown;\n default_price?: string;\n description?: string;\n images?: unknown;\n metadata?: unknown;\n}\n\ninterface PriceRecord {\n id: string;\n product?: string;\n unit_amount?: number;\n currency?: string;\n}\n\nconst isActive = (product: ProductRecord) => String(product.active) !== 'false';\n\nconst slugOf = (product: ProductRecord): string => {\n const metadata = product.metadata as { slug?: unknown } | null | undefined;\n return typeof metadata?.slug === 'string' && metadata.slug ? metadata.slug : product.id;\n};\n\nconst firstImage = (product: ProductRecord): string | null =>\n Array.isArray(product.images) && typeof product.images[0] === 'string'\n ? product.images[0]\n : null;\n\n/**\n * The catalog, as the sync copied it from Stripe: every active product with\n * its default one-time price (or its first active one). A product's\n * `metadata.slug`, when set in the Stripe dashboard, names its page.\n */\nexport const load = async ({ locals }) => {\n const [products, prices] = await Promise.all([\n locals.admin.collection('stripe_products').getFullList<ProductRecord>({ sort: 'name' }),\n locals.admin\n .collection('stripe_prices')\n .getFullList<PriceRecord>({ filter: 'active = true && type = \"one_time\"' })\n ]);\n\n return {\n products: products.filter(isActive).flatMap((product) => {\n const price =\n prices.find((candidate) => candidate.id === product.default_price) ??\n prices.find((candidate) => candidate.product === product.id);\n if (!price?.currency) return [];\n const name = product.name ?? product.id;\n return [\n {\n id: product.id,\n slug: slugOf(product),\n name,\n description: product.description ?? null,\n image: firstImage(product),\n price: {\n price: price.id,\n name,\n unitAmount: price.unit_amount ?? 0,\n currency: price.currency\n }\n }\n ];\n })\n };\n};\n", ic = "<script lang=\"ts\">\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatAmount } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"mb-6 text-2xl font-semibold\">Shop</h1>\n\n {#if data.products.length === 0}\n <p class=\"text-muted-foreground\">\n Nothing for sale yet. Products and prices come from your Stripe dashboard; the catalog syncs\n every ten minutes.\n </p>\n {:else}\n <ul class=\"grid gap-6 sm:grid-cols-2 lg:grid-cols-3\">\n {#each data.products as product (product.id)}\n <li class=\"flex flex-col gap-3 rounded-lg border p-4\">\n <a href=\"/shop/{product.slug}\" class=\"flex flex-col gap-3\">\n {#if product.image}\n <img src={product.image} alt=\"\" class=\"aspect-square w-full rounded object-cover\" />\n {/if}\n <div>\n <h2 class=\"font-medium\">{product.name}</h2>\n <p class=\"text-muted-foreground text-sm\">\n {formatAmount(product.price.unitAmount, product.price.currency)}\n </p>\n </div>\n </a>\n <AddToCart price={product.price} class=\"mt-auto\" />\n </li>\n {/each}\n </ul>\n {/if}\n</section>\n", ac = "import { error } from '@sveltejs/kit';\n\n/** The fields of the synced catalog this page reads. */\ninterface ProductRecord {\n id: string;\n name?: string;\n /** Stripe's boolean, stored by the sync in a text field. */\n active?: unknown;\n default_price?: string;\n description?: string;\n images?: unknown;\n}\n\ninterface PriceRecord {\n id: string;\n nickname?: string;\n unit_amount?: number;\n currency?: string;\n}\n\nconst isActive = (product: ProductRecord) => String(product.active) !== 'false';\n\nconst images = (product: ProductRecord): string[] =>\n Array.isArray(product.images)\n ? product.images.filter((image): image is string => typeof image === 'string')\n : [];\n\n/**\n * One product and its active one-time prices (sizes, say), by its\n * `metadata.slug` from the Stripe dashboard or its id.\n */\nexport const load = async ({ locals, params }) => {\n const products = locals.admin.collection('stripe_products');\n const product = await products\n .getFirstListItem<ProductRecord>(\n locals.admin.filter('metadata.slug = {:slug}', { slug: params.product })\n )\n .catch(() => products.getOne<ProductRecord>(params.product))\n .catch(() => null);\n if (!product || !isActive(product)) error(404, 'Not found');\n\n const prices = await locals.admin.collection('stripe_prices').getFullList<PriceRecord>({\n filter: locals.admin.filter('product = {:product} && active = true && type = \"one_time\"', {\n product: product.id\n }),\n sort: 'unit_amount'\n });\n const priced = prices.filter((price): price is PriceRecord & { currency: string } =>\n Boolean(price.currency)\n );\n if (priced.length === 0) error(404, 'Not found');\n\n const name = product.name ?? product.id;\n return {\n product: {\n id: product.id,\n name,\n description: product.description ?? null,\n images: images(product),\n defaultPrice: product.default_price ?? null\n },\n prices: priced.map((price) => ({\n price: price.id,\n name,\n // What the dashboard calls this price, when there is more than one.\n nickname: price.nickname ?? null,\n unitAmount: price.unit_amount ?? 0,\n currency: price.currency\n }))\n };\n};\n", oc = "<script lang=\"ts\">\n import { Button } from '#lib/components/ui/button/index.js';\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatAmount } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n\n // The default price first, or the cheapest; with one price there is nothing to pick.\n let selectedId = $state(\n data.prices.find((price) => price.price === data.product.defaultPrice)?.price ??\n data.prices[0].price\n );\n const selected = $derived(data.prices.find((price) => price.price === selectedId) ?? data.prices[0]);\n<\/script>\n\n<section data-role=\"content\" class=\"grid gap-8 md:grid-cols-2\">\n <div class=\"flex flex-col gap-3\">\n {#each data.product.images.slice(0, 1) as image (image)}\n <img src={image} alt=\"\" class=\"aspect-square w-full rounded-lg object-cover\" />\n {/each}\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/shop\">Shop</a></p>\n <h1 class=\"text-2xl font-semibold\">{data.product.name}</h1>\n <p class=\"mt-2 text-lg\">{formatAmount(selected.unitAmount, selected.currency)}</p>\n </div>\n\n {#if data.product.description}\n <p class=\"text-muted-foreground\">{data.product.description}</p>\n {/if}\n\n {#if data.prices.length > 1}\n <div class=\"flex flex-wrap gap-2\" role=\"radiogroup\" aria-label=\"Option\">\n {#each data.prices as price (price.price)}\n <Button\n variant={price.price === selectedId ? 'default' : 'outline'}\n size=\"sm\"\n role=\"radio\"\n aria-checked={price.price === selectedId}\n onclick={() => (selectedId = price.price)}\n >\n {price.nickname ?? formatAmount(price.unitAmount, price.currency)}\n </Button>\n {/each}\n </div>\n {/if}\n\n <AddToCart price={selected} size=\"lg\" />\n </div>\n</section>\n", sc = "/**\n * What the shop sells. Edit this list: it is the catalog the `/shop` pages\n * read. Prices are in `site.currency` (src/lib/site.ts), written as you would\n * write them (`4.5`); leave one out to quote in the chat instead.\n */\nexport interface Product {\n /** Your own id for the item (a slug or SKU); it is the item's URL and its cart line. */\n id: string;\n name: string;\n description?: string;\n price?: number;\n /** A URL, or a path under `static/`. */\n image?: string;\n}\n\nexport const catalog: Product[] = [\n {\n id: 'concha',\n name: 'Concha',\n description: 'A sweet bun with a vanilla or cocoa shell.',\n price: 12\n },\n {\n id: 'birthday-cake',\n name: 'Birthday cake',\n description: 'Say the size and the day you need it in the chat.'\n }\n];\n\nexport const product = (id: string): Product | undefined => catalog.find((item) => item.id === id);\n", cc = "<script lang=\"ts\">\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { catalog } from '#lib/catalog.js';\n import { formatPrice } from '#lib/currency.svelte.js';\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"mb-6 text-2xl font-semibold\">Shop</h1>\n\n <ul class=\"grid gap-6 sm:grid-cols-2 lg:grid-cols-3\">\n {#each catalog as item (item.id)}\n <li class=\"flex flex-col gap-3 rounded-lg border p-4\">\n <a href=\"/shop/{item.id}\" class=\"flex flex-col gap-3\">\n {#if item.image}\n <img src={item.image} alt=\"\" class=\"aspect-square w-full rounded object-cover\" />\n {/if}\n <div>\n <h2 class=\"font-medium\">{item.name}</h2>\n <p class=\"text-muted-foreground text-sm\">\n {#if item.price !== undefined}\n {formatPrice(item.price)}\n {:else}\n Price on request\n {/if}\n </p>\n </div>\n </a>\n <AddToCart id={item.id} name={item.name} price={item.price} class=\"mt-auto\" />\n </li>\n {/each}\n </ul>\n</section>\n", lc = "<script lang=\"ts\">\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatPrice } from '#lib/currency.svelte.js';\n\n let { data } = $props();\n<\/script>\n\n<section data-role=\"content\" class=\"grid gap-8 md:grid-cols-2\">\n <div>\n {#if data.item.image}\n <img src={data.item.image} alt=\"\" class=\"aspect-square w-full rounded-lg object-cover\" />\n {/if}\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/shop\">Shop</a></p>\n <h1 class=\"text-2xl font-semibold\">{data.item.name}</h1>\n <p class=\"mt-2 text-lg\">\n {#if data.item.price !== undefined}\n {formatPrice(data.item.price)}\n {:else}\n <span class=\"text-muted-foreground\">We'll confirm the price in WhatsApp.</span>\n {/if}\n </p>\n </div>\n\n {#if data.item.description}\n <p class=\"text-muted-foreground\">{data.item.description}</p>\n {/if}\n\n <AddToCart id={data.item.id} name={data.item.name} price={data.item.price} size=\"lg\" />\n </div>\n</section>\n", uc = "import { error } from '@sveltejs/kit';\nimport { catalog, product } from '#lib/catalog.js';\n\n// The catalog is a module, so every item's page can be prerendered.\nexport const entries = () => catalog.map(({ id }) => ({ id }));\n\nexport const load = ({ params }) => {\n const item = product(params.id);\n if (!item) error(404, 'Not found');\n return { item };\n};\n", dc = "<script lang=\"ts\">\n import { CmsCollection, CmsText, type CollectionItem } from '@velastack/cms';\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatPrice } from '#lib/currency.svelte.js';\n\n // The catalog is edited in place: open the page with `?edit` to add items.\n // It lives in the root layout scope, so the product pages read the same\n // list. Prices are in `site.currency` (src/lib/site.ts); an item without\n // one is quoted in the chat.\n const sample: Partial<CollectionItem>[] = [\n {\n id: 'concha',\n title: 'Concha',\n summary: 'A sweet bun with a vanilla or cocoa shell.',\n price: { amount: 12, currency: '', period: '', prefix: '' }\n },\n {\n id: 'birthday-cake',\n title: 'Birthday cake',\n summary: 'Say the size and the day you need it in the chat.'\n }\n ];\n<\/script>\n\n<section data-role=\"content\">\n <h1 class=\"mb-6 text-2xl font-semibold\"><CmsText name=\"title\" fallback=\"Shop\" /></h1>\n\n <CmsCollection name=\"catalog\" scope=\"root\" fallback={sample}>\n {#snippet children(items)}\n <ul class=\"grid gap-6 sm:grid-cols-2 lg:grid-cols-3\">\n {#each items as item (item.id)}\n <li class=\"flex flex-col gap-3 rounded-lg border p-4\">\n <a href=\"/shop/{item.id}\" class=\"flex flex-col gap-3\">\n {#if item.image?.url}\n <img src={item.image.url} alt={item.image.alt ?? ''} class=\"aspect-square w-full rounded object-cover\" />\n {/if}\n <div>\n <h2 class=\"font-medium\">{item.title}</h2>\n <p class=\"text-muted-foreground text-sm\">\n {#if item.price.amount !== null}\n {formatPrice(item.price.amount)}\n {:else}\n Price on request\n {/if}\n </p>\n </div>\n </a>\n <AddToCart\n id={item.id}\n name={item.title}\n price={item.price.amount ?? undefined}\n class=\"mt-auto\"\n />\n </li>\n {/each}\n </ul>\n {/snippet}\n </CmsCollection>\n</section>\n", fc = "<script lang=\"ts\">\n import { page } from '$app/state';\n import { CmsCollection } from '@velastack/cms';\n import AddToCart from '#lib/components/cart/add-to-cart.svelte';\n import { formatPrice } from '#lib/currency.svelte.js';\n<\/script>\n\n<!-- The same catalog the shop page edits, from the root layout scope. -->\n<CmsCollection name=\"catalog\" scope=\"root\">\n {#snippet children(items)}\n {@const item = items.find((candidate) => candidate.id === page.params.id)}\n <section data-role=\"content\" class=\"grid gap-8 md:grid-cols-2\">\n {#if item}\n <div>\n {#if item.image?.url}\n <img src={item.image.url} alt={item.image.alt ?? ''} class=\"aspect-square w-full rounded-lg object-cover\" />\n {/if}\n </div>\n\n <div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/shop\">Shop</a></p>\n <h1 class=\"text-2xl font-semibold\">{item.title}</h1>\n <p class=\"mt-2 text-lg\">\n {#if item.price.amount !== null}\n {formatPrice(item.price.amount)}\n {:else}\n <span class=\"text-muted-foreground\">We'll confirm the price in WhatsApp.</span>\n {/if}\n </p>\n </div>\n\n {#if item.summary}\n <p class=\"text-muted-foreground\">{item.summary}</p>\n {/if}\n\n <AddToCart id={item.id} name={item.title} price={item.price.amount ?? undefined} size=\"lg\" />\n </div>\n {:else}\n <div>\n <h1 class=\"text-2xl font-semibold\">Not found</h1>\n <p class=\"text-muted-foreground mt-2\"><a href=\"/shop\">Back to the shop</a></p>\n </div>\n {/if}\n </section>\n {/snippet}\n</CmsCollection>\n", pc = "// The items are CMS content, so there is no list of ids to prerender from;\n// the page renders from the catalog the shop page holds.\nexport const prerender = false;\n", mc = [
|
|
4132
4132
|
{
|
|
4133
4133
|
id: "stripe",
|
|
4134
4134
|
label: "Stripe",
|
|
@@ -4165,10 +4165,10 @@ var Qs = {
|
|
|
4165
4165
|
"./providers-cms/whatsapp/src/routes/(public)/shop/[id]/+page.ts": pc
|
|
4166
4166
|
});
|
|
4167
4167
|
function vc(e) {
|
|
4168
|
-
let t =
|
|
4169
|
-
for (let e of
|
|
4168
|
+
let t = E(hc, e), n = /* @__PURE__ */ new Map();
|
|
4169
|
+
for (let e of de(gc, t.id)) n.set(e.path, e);
|
|
4170
4170
|
if (e.features.cms) {
|
|
4171
|
-
let e =
|
|
4171
|
+
let e = de(_c, t.id, "./providers-cms/");
|
|
4172
4172
|
if (e.length > 0) {
|
|
4173
4173
|
n.clear();
|
|
4174
4174
|
for (let t of e) n.set(t.path, t);
|
|
@@ -4190,7 +4190,7 @@ async function yc(e) {
|
|
|
4190
4190
|
}
|
|
4191
4191
|
//#endregion
|
|
4192
4192
|
//#region src/patterns/generate/shop/index.ts
|
|
4193
|
-
var bc = "generate-shop", xc = "1.
|
|
4193
|
+
var bc = "generate-shop", xc = "1.1.0", Sc = "src/patterns/generate/shop", Cc = "/generate/shop";
|
|
4194
4194
|
async function wc(e) {
|
|
4195
4195
|
let t = await yc(e);
|
|
4196
4196
|
if (e.env !== "runtime") return D(t, e);
|
|
@@ -4344,7 +4344,7 @@ function Nc({ name: e, exportName: t, cron: n }) {
|
|
|
4344
4344
|
function Pc(e, t) {
|
|
4345
4345
|
return {
|
|
4346
4346
|
path: e,
|
|
4347
|
-
language:
|
|
4347
|
+
language: S(e),
|
|
4348
4348
|
content: `${t}\n`,
|
|
4349
4349
|
status: "success"
|
|
4350
4350
|
};
|
|
@@ -4420,13 +4420,13 @@ var Vc = {
|
|
|
4420
4420
|
//#endregion
|
|
4421
4421
|
//#region src/patterns/enable/ai/generate.preview.ts
|
|
4422
4422
|
async function Hc(e) {
|
|
4423
|
-
let t =
|
|
4423
|
+
let t = E(ye, e), n = be(t).map((e) => e.type === "comment" ? `# ${e.key}` : `${e.key}=${e.value}`);
|
|
4424
4424
|
return {
|
|
4425
4425
|
creates: [],
|
|
4426
4426
|
modifies: [{
|
|
4427
4427
|
path: "src/env.ts",
|
|
4428
4428
|
language: "ts",
|
|
4429
|
-
content: u(
|
|
4429
|
+
content: u(ce(t)),
|
|
4430
4430
|
status: "success"
|
|
4431
4431
|
}, {
|
|
4432
4432
|
path: ".env",
|
|
@@ -4449,10 +4449,10 @@ async function qc(e) {
|
|
|
4449
4449
|
let t = await _e(e);
|
|
4450
4450
|
if (e.env === "preview") {
|
|
4451
4451
|
let n = await Hc(e);
|
|
4452
|
-
return D(
|
|
4452
|
+
return D(C([t, n]), e);
|
|
4453
4453
|
}
|
|
4454
4454
|
let { generate: n } = await import("./chunks/generate.runtime-gZ4wfYBP.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
4455
|
-
return i(await D(
|
|
4455
|
+
return i(await D(C([t, r]), e), e);
|
|
4456
4456
|
}
|
|
4457
4457
|
var Jc = {
|
|
4458
4458
|
version: Wc,
|
|
@@ -4510,11 +4510,11 @@ var Jc = {
|
|
|
4510
4510
|
generate: qc
|
|
4511
4511
|
}, Yc = /* #__PURE__ */ Object.assign({ "./preview-modifies/src/routes/+layout.svelte": "<script lang=\"ts\">\n import '../app.css';\n\n import favicon from '#lib/assets/favicon.svg';\n import { site } from '#lib/site.js';\n\n import { ModeWatcher } from 'mode-watcher';\n import { getFlash } from 'sveltekit-flash-message';\n import { toast } from 'svelte-sonner';\n import { page } from '$app/state';\n import { Toaster } from '#lib/components/ui/sonner/index.js';\n import { MetaTags, deepMerge } from 'svelte-meta-tags';\n import type { LayoutProps } from './$types';\n // [!code highlight:1]\n import Analytics from '#lib/components/analytics/analytics.svelte';\n\n let { data, children }: LayoutProps = $props();\n const flash = getFlash(page);\n\n $effect(() => {\n if (!$flash || $flash.type !== 'toast') {\n return;\n }\n\n toast.message($flash.message);\n\n $flash = undefined;\n });\n\n let metaTags = $derived(deepMerge(data.baseMetaTags, page.data.pageMetaTags));\n<\/script>\n\n<svelte:head>\n <title>{site.name}</title>\n <link rel=\"icon\" href={favicon} />\n</svelte:head>\n\n<MetaTags {...metaTags} />\n<ModeWatcher />\n<Toaster />\n<!-- [!code highlight:1] -->\n<Analytics />\n\n{@render children?.()}\n" }), Xc = "./preview-modifies/";
|
|
4512
4512
|
async function Zc(e) {
|
|
4513
|
-
let t =
|
|
4514
|
-
let n =
|
|
4513
|
+
let t = E(ke, e), n = Object.entries(Yc).map(([e, t]) => {
|
|
4514
|
+
let n = T(e, Xc);
|
|
4515
4515
|
return {
|
|
4516
4516
|
path: n,
|
|
4517
|
-
language:
|
|
4517
|
+
language: S(n),
|
|
4518
4518
|
content: t,
|
|
4519
4519
|
status: "success"
|
|
4520
4520
|
};
|
|
@@ -4522,7 +4522,7 @@ async function Zc(e) {
|
|
|
4522
4522
|
n.push({
|
|
4523
4523
|
path: "src/env.ts",
|
|
4524
4524
|
language: "ts",
|
|
4525
|
-
content: u(
|
|
4525
|
+
content: u(ce(t)),
|
|
4526
4526
|
status: "success"
|
|
4527
4527
|
});
|
|
4528
4528
|
let r = Oe(t).map((e) => e.type === "comment" ? `# ${e.key}` : `${e.key}=${e.value}`);
|
|
@@ -4549,10 +4549,10 @@ async function nl(e) {
|
|
|
4549
4549
|
let t = await Ee(e);
|
|
4550
4550
|
if (e.env === "preview") {
|
|
4551
4551
|
let n = await Zc(e);
|
|
4552
|
-
return D(
|
|
4552
|
+
return D(C([t, n]), e);
|
|
4553
4553
|
}
|
|
4554
4554
|
let { generate: n } = await import("./chunks/generate.runtime-C4LUUuq7.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
4555
|
-
return i(await D(
|
|
4555
|
+
return i(await D(C([t, r]), e), e);
|
|
4556
4556
|
}
|
|
4557
4557
|
var rl = {
|
|
4558
4558
|
version: $c,
|
|
@@ -4668,7 +4668,7 @@ var rl = {
|
|
|
4668
4668
|
"./variants/split/src/routes/(public)/(auth)/signup/+page.svelte": Mt
|
|
4669
4669
|
}), ol = "./creates/";
|
|
4670
4670
|
async function sl(e) {
|
|
4671
|
-
let t = typeof e.input?.variant == "string" ? e.input.variant : void 0, n =
|
|
4671
|
+
let t = typeof e.input?.variant == "string" ? e.input.variant : void 0, n = se(il, ol, al, t), r = [
|
|
4672
4672
|
"sidebar",
|
|
4673
4673
|
"breadcrumb",
|
|
4674
4674
|
"separator",
|
|
@@ -4692,10 +4692,10 @@ async function sl(e) {
|
|
|
4692
4692
|
deletes: [],
|
|
4693
4693
|
components: r,
|
|
4694
4694
|
packages: [
|
|
4695
|
-
|
|
4695
|
+
te,
|
|
4696
4696
|
m,
|
|
4697
|
-
|
|
4698
|
-
|
|
4697
|
+
ie,
|
|
4698
|
+
x
|
|
4699
4699
|
],
|
|
4700
4700
|
collections: [{
|
|
4701
4701
|
listRule: "@request.auth.id = user.id",
|
|
@@ -4770,10 +4770,10 @@ async function ul(e) {
|
|
|
4770
4770
|
return {
|
|
4771
4771
|
creates: [],
|
|
4772
4772
|
modifies: Object.entries(cl).map(([e, t]) => {
|
|
4773
|
-
let n =
|
|
4773
|
+
let n = T(e, ll);
|
|
4774
4774
|
return {
|
|
4775
4775
|
path: n,
|
|
4776
|
-
language:
|
|
4776
|
+
language: S(n),
|
|
4777
4777
|
content: t,
|
|
4778
4778
|
status: "success"
|
|
4779
4779
|
};
|
|
@@ -4793,13 +4793,13 @@ async function hl(e) {
|
|
|
4793
4793
|
let t = await sl(e);
|
|
4794
4794
|
if (e.env === "preview") {
|
|
4795
4795
|
let n = await ul(e);
|
|
4796
|
-
return D(
|
|
4796
|
+
return D(C([t, n]), e);
|
|
4797
4797
|
}
|
|
4798
4798
|
let { createCollections: n } = await import("./chunks/collections-BYcVyY9O.js").then((e) => e.n), r = await n(t.collections, e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l), a = await i(await D({
|
|
4799
4799
|
...t,
|
|
4800
4800
|
creates: [...t.creates, ...r]
|
|
4801
|
-
}, e), e), { generate: o } = await import("./chunks/generate.runtime-
|
|
4802
|
-
return
|
|
4801
|
+
}, e), e), { generate: o } = await import("./chunks/generate.runtime-Cj-5fzbQ.js"), s = await o(e), c = await i(await D(s, e), e);
|
|
4802
|
+
return C([a, c]);
|
|
4803
4803
|
}
|
|
4804
4804
|
var gl = {
|
|
4805
4805
|
version: fl,
|
|
@@ -4910,10 +4910,10 @@ var gl = {
|
|
|
4910
4910
|
}), vl = "./creates/";
|
|
4911
4911
|
async function yl(e) {
|
|
4912
4912
|
let t = Object.entries(_l).map(([e, t]) => {
|
|
4913
|
-
let n =
|
|
4913
|
+
let n = T(e, vl);
|
|
4914
4914
|
return {
|
|
4915
4915
|
path: n,
|
|
4916
|
-
language:
|
|
4916
|
+
language: S(n),
|
|
4917
4917
|
content: t,
|
|
4918
4918
|
status: "success"
|
|
4919
4919
|
};
|
|
@@ -4938,7 +4938,7 @@ async function yl(e) {
|
|
|
4938
4938
|
modifies: [],
|
|
4939
4939
|
deletes: [],
|
|
4940
4940
|
components: n,
|
|
4941
|
-
packages: [m,
|
|
4941
|
+
packages: [m, x],
|
|
4942
4942
|
collections: [{
|
|
4943
4943
|
listRule: "@request.auth.id = user.id",
|
|
4944
4944
|
viewRule: "@request.auth.id = user.id",
|
|
@@ -5012,10 +5012,10 @@ async function Sl(e) {
|
|
|
5012
5012
|
return {
|
|
5013
5013
|
creates: [],
|
|
5014
5014
|
modifies: Object.entries(bl).map(([e, t]) => {
|
|
5015
|
-
let n =
|
|
5015
|
+
let n = T(e, xl);
|
|
5016
5016
|
return {
|
|
5017
5017
|
path: n,
|
|
5018
|
-
language:
|
|
5018
|
+
language: S(n),
|
|
5019
5019
|
content: t,
|
|
5020
5020
|
status: "success"
|
|
5021
5021
|
};
|
|
@@ -5035,10 +5035,10 @@ async function Dl(e) {
|
|
|
5035
5035
|
let t = await yl(e);
|
|
5036
5036
|
if (e.env === "preview") {
|
|
5037
5037
|
let n = await Sl(e);
|
|
5038
|
-
return D(
|
|
5038
|
+
return D(C([t, n]), e);
|
|
5039
5039
|
}
|
|
5040
|
-
let { createCollections: n } = await import("./chunks/collections-BYcVyY9O.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-
|
|
5041
|
-
return o(await D(
|
|
5040
|
+
let { createCollections: n } = await import("./chunks/collections-BYcVyY9O.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-C7tlPKH1.js"), a = await i(e), { writeResult: o } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
5041
|
+
return o(await D(C([{
|
|
5042
5042
|
...t,
|
|
5043
5043
|
creates: [...t.creates, ...r]
|
|
5044
5044
|
}, a]), e), e);
|
|
@@ -5087,10 +5087,10 @@ var Ol = {
|
|
|
5087
5087
|
async function Ml(e) {
|
|
5088
5088
|
return {
|
|
5089
5089
|
creates: Object.entries(Al).map(([e, t]) => {
|
|
5090
|
-
let n =
|
|
5090
|
+
let n = T(e, jl);
|
|
5091
5091
|
return {
|
|
5092
5092
|
path: n,
|
|
5093
|
-
language:
|
|
5093
|
+
language: S(n),
|
|
5094
5094
|
content: t,
|
|
5095
5095
|
status: "success"
|
|
5096
5096
|
};
|
|
@@ -5111,10 +5111,10 @@ async function Fl(e) {
|
|
|
5111
5111
|
return {
|
|
5112
5112
|
creates: [],
|
|
5113
5113
|
modifies: Object.entries(Nl).map(([e, t]) => {
|
|
5114
|
-
let n =
|
|
5114
|
+
let n = T(e, Pl);
|
|
5115
5115
|
return {
|
|
5116
5116
|
path: n,
|
|
5117
|
-
language:
|
|
5117
|
+
language: S(n),
|
|
5118
5118
|
content: t,
|
|
5119
5119
|
status: "success"
|
|
5120
5120
|
};
|
|
@@ -5134,10 +5134,10 @@ async function Bl(e) {
|
|
|
5134
5134
|
let t = await Ml(e);
|
|
5135
5135
|
if (e.env === "preview") {
|
|
5136
5136
|
let n = await Fl(e);
|
|
5137
|
-
return D(
|
|
5137
|
+
return D(C([t, n]), e);
|
|
5138
5138
|
}
|
|
5139
5139
|
let { generate: n } = await import("./chunks/generate.runtime-WPq7bHRA.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
5140
|
-
return i(await D(
|
|
5140
|
+
return i(await D(C([t, r]), e), e);
|
|
5141
5141
|
}
|
|
5142
5142
|
var Vl = {
|
|
5143
5143
|
version: Ll,
|
|
@@ -5235,10 +5235,10 @@ var Vl = {
|
|
|
5235
5235
|
async function nu(e) {
|
|
5236
5236
|
return {
|
|
5237
5237
|
creates: Object.entries($l).map(([e, t]) => {
|
|
5238
|
-
let n =
|
|
5238
|
+
let n = T(e, eu);
|
|
5239
5239
|
return {
|
|
5240
5240
|
path: n,
|
|
5241
|
-
language:
|
|
5241
|
+
language: S(n),
|
|
5242
5242
|
content: t,
|
|
5243
5243
|
status: "success"
|
|
5244
5244
|
};
|
|
@@ -5266,10 +5266,10 @@ async function au(e) {
|
|
|
5266
5266
|
return {
|
|
5267
5267
|
creates: [],
|
|
5268
5268
|
modifies: Object.entries(ru).map(([e, t]) => {
|
|
5269
|
-
let n =
|
|
5269
|
+
let n = T(e, iu);
|
|
5270
5270
|
return {
|
|
5271
5271
|
path: n,
|
|
5272
|
-
language:
|
|
5272
|
+
language: S(n),
|
|
5273
5273
|
content: t,
|
|
5274
5274
|
status: "success"
|
|
5275
5275
|
};
|
|
@@ -5289,10 +5289,10 @@ async function uu(e) {
|
|
|
5289
5289
|
let t = await nu(e);
|
|
5290
5290
|
if (e.env === "preview") {
|
|
5291
5291
|
let n = await au(e);
|
|
5292
|
-
return D(
|
|
5292
|
+
return D(C([t, n]), e);
|
|
5293
5293
|
}
|
|
5294
5294
|
let { createCollections: n } = await import("./chunks/collections-BYcVyY9O.js").then((e) => e.n), r = await n(t.collections, e), { generate: i } = await import("./chunks/generate.runtime-DiqfbDfk.js"), a = await i(e), { writeResult: o } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
5295
|
-
return o(await D(
|
|
5295
|
+
return o(await D(C([{
|
|
5296
5296
|
...t,
|
|
5297
5297
|
creates: [...t.creates, ...r]
|
|
5298
5298
|
}, a]), e), e);
|
|
@@ -5345,10 +5345,10 @@ var du = {
|
|
|
5345
5345
|
async function vu(e) {
|
|
5346
5346
|
return {
|
|
5347
5347
|
creates: Object.entries(gu).map(([e, t]) => {
|
|
5348
|
-
let n =
|
|
5348
|
+
let n = T(e, _u);
|
|
5349
5349
|
return {
|
|
5350
5350
|
path: n,
|
|
5351
|
-
language:
|
|
5351
|
+
language: S(n),
|
|
5352
5352
|
content: t,
|
|
5353
5353
|
status: "success"
|
|
5354
5354
|
};
|
|
@@ -5358,9 +5358,9 @@ async function vu(e) {
|
|
|
5358
5358
|
components: [],
|
|
5359
5359
|
packages: [
|
|
5360
5360
|
v,
|
|
5361
|
-
|
|
5361
|
+
b,
|
|
5362
5362
|
"pocketbase-sveltekit",
|
|
5363
|
-
|
|
5363
|
+
re,
|
|
5364
5364
|
"vitest@^5.0.1",
|
|
5365
5365
|
"supertest@^7.2.2",
|
|
5366
5366
|
"@types/supertest@^6.0.3"
|
|
@@ -5380,16 +5380,16 @@ async function xu(e) {
|
|
|
5380
5380
|
return {
|
|
5381
5381
|
creates: [],
|
|
5382
5382
|
modifies: Object.entries(yu).map(([e, t]) => {
|
|
5383
|
-
let n =
|
|
5383
|
+
let n = T(e, bu);
|
|
5384
5384
|
return {
|
|
5385
5385
|
path: n,
|
|
5386
|
-
language:
|
|
5386
|
+
language: S(n),
|
|
5387
5387
|
content: t,
|
|
5388
5388
|
status: "success"
|
|
5389
5389
|
};
|
|
5390
5390
|
}).concat({
|
|
5391
5391
|
path: "src/env.ts",
|
|
5392
|
-
language:
|
|
5392
|
+
language: S("src/env.ts"),
|
|
5393
5393
|
content: u(Xn),
|
|
5394
5394
|
status: "success"
|
|
5395
5395
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
@@ -5408,10 +5408,10 @@ async function Eu(e) {
|
|
|
5408
5408
|
let t = await vu(e);
|
|
5409
5409
|
if (e.env === "preview") {
|
|
5410
5410
|
let n = await xu(e);
|
|
5411
|
-
return D(
|
|
5411
|
+
return D(C([t, n]), e);
|
|
5412
5412
|
}
|
|
5413
5413
|
let { generate: n } = await import("./chunks/generate.runtime-B53OTMcE.js"), r = await n(e), { keepMissing: i } = await import("./chunks/modify-file-B4uJzOEj.js").then((e) => e.i), { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
5414
|
-
return a(await D(
|
|
5414
|
+
return a(await D(C([{
|
|
5415
5415
|
...t,
|
|
5416
5416
|
creates: i(t.creates, e.root)
|
|
5417
5417
|
}, r]), e), e);
|
|
@@ -5478,10 +5478,10 @@ var Du = {
|
|
|
5478
5478
|
function ed(e, t) {
|
|
5479
5479
|
let n = {};
|
|
5480
5480
|
for (let [r, i] of Object.entries(e)) {
|
|
5481
|
-
let e =
|
|
5481
|
+
let e = T(r, t);
|
|
5482
5482
|
n[e] = {
|
|
5483
5483
|
path: e,
|
|
5484
|
-
language:
|
|
5484
|
+
language: S(e),
|
|
5485
5485
|
content: i,
|
|
5486
5486
|
status: "success"
|
|
5487
5487
|
};
|
|
@@ -5522,10 +5522,10 @@ async function id(e) {
|
|
|
5522
5522
|
return {
|
|
5523
5523
|
creates: [],
|
|
5524
5524
|
modifies: Object.entries(nd).map(([e, t]) => {
|
|
5525
|
-
let n =
|
|
5525
|
+
let n = T(e, rd);
|
|
5526
5526
|
return {
|
|
5527
5527
|
path: n,
|
|
5528
|
-
language:
|
|
5528
|
+
language: S(n),
|
|
5529
5529
|
content: t,
|
|
5530
5530
|
status: "success"
|
|
5531
5531
|
};
|
|
@@ -5545,10 +5545,10 @@ async function ld(e) {
|
|
|
5545
5545
|
let t = await td(e);
|
|
5546
5546
|
if (e.env === "preview") {
|
|
5547
5547
|
let n = await id(e);
|
|
5548
|
-
return D(
|
|
5548
|
+
return D(C([t, n]), e);
|
|
5549
5549
|
}
|
|
5550
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
5551
|
-
return i(await D(
|
|
5550
|
+
let { generate: n } = await import("./chunks/generate.runtime-BC6CBKh6.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
5551
|
+
return i(await D(C([t, r]), e), e);
|
|
5552
5552
|
}
|
|
5553
5553
|
var ud = {
|
|
5554
5554
|
version: od,
|
|
@@ -5598,10 +5598,10 @@ async function pd(e) {
|
|
|
5598
5598
|
return {
|
|
5599
5599
|
creates: [],
|
|
5600
5600
|
modifies: Object.entries(dd).map(([e, t]) => {
|
|
5601
|
-
let n =
|
|
5601
|
+
let n = T(e, fd);
|
|
5602
5602
|
return {
|
|
5603
5603
|
path: n,
|
|
5604
|
-
language:
|
|
5604
|
+
language: S(n),
|
|
5605
5605
|
content: t,
|
|
5606
5606
|
status: "success"
|
|
5607
5607
|
};
|
|
@@ -5621,10 +5621,10 @@ async function vd(e) {
|
|
|
5621
5621
|
let t = await Zn(e);
|
|
5622
5622
|
if (e.env === "preview") {
|
|
5623
5623
|
let n = await pd(e);
|
|
5624
|
-
return D(
|
|
5624
|
+
return D(C([t, n]), e);
|
|
5625
5625
|
}
|
|
5626
5626
|
let { generate: n } = await import("./chunks/generate.runtime-BOl3LpPB.js"), { keepMissing: r } = await import("./chunks/modify-file-B4uJzOEj.js").then((e) => e.i), i = await n(e), { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
5627
|
-
return a(await D(
|
|
5627
|
+
return a(await D(C([{
|
|
5628
5628
|
...t,
|
|
5629
5629
|
creates: r(t.creates, e.root)
|
|
5630
5630
|
}, i]), e), e);
|
|
@@ -5683,10 +5683,10 @@ var jd = /\/negotiate\/\+page\.ts$/;
|
|
|
5683
5683
|
function Md(e, t) {
|
|
5684
5684
|
let n = {};
|
|
5685
5685
|
for (let [r, i] of Object.entries(e)) {
|
|
5686
|
-
let e =
|
|
5686
|
+
let e = T(r, t);
|
|
5687
5687
|
n[e] = {
|
|
5688
5688
|
path: e,
|
|
5689
|
-
language:
|
|
5689
|
+
language: S(e),
|
|
5690
5690
|
content: i,
|
|
5691
5691
|
status: "success"
|
|
5692
5692
|
};
|
|
@@ -5724,10 +5724,10 @@ async function Id(e) {
|
|
|
5724
5724
|
return {
|
|
5725
5725
|
creates: [],
|
|
5726
5726
|
modifies: Object.entries(Pd).map(([e, t]) => {
|
|
5727
|
-
let n =
|
|
5727
|
+
let n = T(e, Fd);
|
|
5728
5728
|
return {
|
|
5729
5729
|
path: n,
|
|
5730
|
-
language:
|
|
5730
|
+
language: S(n),
|
|
5731
5731
|
content: t,
|
|
5732
5732
|
status: "success"
|
|
5733
5733
|
};
|
|
@@ -5747,10 +5747,10 @@ async function Vd(e) {
|
|
|
5747
5747
|
let t = await Nd(e);
|
|
5748
5748
|
if (e.env === "preview") {
|
|
5749
5749
|
let n = await Id(e);
|
|
5750
|
-
return D(
|
|
5750
|
+
return D(C([t, n]), e);
|
|
5751
5751
|
}
|
|
5752
5752
|
let { generate: n } = await import("./chunks/generate.runtime-D677SB4v.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
5753
|
-
return i(await D(
|
|
5753
|
+
return i(await D(C([t, r]), e), e);
|
|
5754
5754
|
}
|
|
5755
5755
|
var Hd = {
|
|
5756
5756
|
version: Rd,
|
|
@@ -5797,11 +5797,11 @@ var Hd = {
|
|
|
5797
5797
|
async function Xd(e) {
|
|
5798
5798
|
let t = j(e);
|
|
5799
5799
|
return {
|
|
5800
|
-
creates:
|
|
5800
|
+
creates: se(qd, Yd, Jd, t === "plain" ? "plain" : void 0),
|
|
5801
5801
|
modifies: [],
|
|
5802
5802
|
deletes: [],
|
|
5803
5803
|
components: t === "plain" ? [] : ["select"],
|
|
5804
|
-
packages: [p,
|
|
5804
|
+
packages: [p, ae],
|
|
5805
5805
|
collections: [],
|
|
5806
5806
|
collectionPatches: [],
|
|
5807
5807
|
collectionDrops: []
|
|
@@ -5821,10 +5821,10 @@ async function $d(e) {
|
|
|
5821
5821
|
return {
|
|
5822
5822
|
creates: [],
|
|
5823
5823
|
modifies: Object.entries(Zd).map(([e, t]) => {
|
|
5824
|
-
let n =
|
|
5824
|
+
let n = T(e, Qd);
|
|
5825
5825
|
return {
|
|
5826
5826
|
path: n,
|
|
5827
|
-
language:
|
|
5827
|
+
language: S(n),
|
|
5828
5828
|
content: t,
|
|
5829
5829
|
status: "success"
|
|
5830
5830
|
};
|
|
@@ -5844,12 +5844,12 @@ async function af(e) {
|
|
|
5844
5844
|
let t = await Xd(e);
|
|
5845
5845
|
if (e.env === "preview") {
|
|
5846
5846
|
let n = await $d(e);
|
|
5847
|
-
return D(
|
|
5847
|
+
return D(C([t, n]), e);
|
|
5848
5848
|
}
|
|
5849
5849
|
let { generate: n, withLibraryTexts: r } = await import("./chunks/generate.runtime-BoYwV0nt.js");
|
|
5850
5850
|
t.creates = r(e.root, t.creates);
|
|
5851
5851
|
let i = await n(e), { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
5852
|
-
return a(await D(
|
|
5852
|
+
return a(await D(C([t, i]), e), e);
|
|
5853
5853
|
}
|
|
5854
5854
|
var of = {
|
|
5855
5855
|
version: tf,
|
|
@@ -5897,10 +5897,10 @@ var of = {
|
|
|
5897
5897
|
async function pf(e) {
|
|
5898
5898
|
return {
|
|
5899
5899
|
creates: Object.entries(df).map(([e, t]) => {
|
|
5900
|
-
let n =
|
|
5900
|
+
let n = T(e, ff);
|
|
5901
5901
|
return {
|
|
5902
5902
|
path: n,
|
|
5903
|
-
language:
|
|
5903
|
+
language: S(n),
|
|
5904
5904
|
content: t,
|
|
5905
5905
|
status: "success"
|
|
5906
5906
|
};
|
|
@@ -5984,10 +5984,10 @@ async function bf(e) {
|
|
|
5984
5984
|
return {
|
|
5985
5985
|
creates: [],
|
|
5986
5986
|
modifies: Object.entries(vf).map(([e, t]) => {
|
|
5987
|
-
let n =
|
|
5987
|
+
let n = T(e, yf);
|
|
5988
5988
|
return {
|
|
5989
5989
|
path: n,
|
|
5990
|
-
language:
|
|
5990
|
+
language: S(n),
|
|
5991
5991
|
content: t,
|
|
5992
5992
|
status: "success"
|
|
5993
5993
|
};
|
|
@@ -6007,10 +6007,10 @@ async function Tf(e) {
|
|
|
6007
6007
|
let t = await pf(e);
|
|
6008
6008
|
if (e.env === "preview") {
|
|
6009
6009
|
let n = await bf(e);
|
|
6010
|
-
return D(
|
|
6010
|
+
return D(C([t, n]), e);
|
|
6011
6011
|
}
|
|
6012
6012
|
let { generate: n } = await import("./chunks/generate.runtime-DERcpgc-.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
6013
|
-
return i(await D(
|
|
6013
|
+
return i(await D(C([t, r]), e), e);
|
|
6014
6014
|
}
|
|
6015
6015
|
var Ef = {
|
|
6016
6016
|
version: Sf,
|
|
@@ -6065,16 +6065,20 @@ function Rf(e) {
|
|
|
6065
6065
|
return O(Nf ||= M(["\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);
|
|
6066
6066
|
}
|
|
6067
6067
|
async function zf(e) {
|
|
6068
|
-
let t =
|
|
6068
|
+
let t = E(nr, e), n = t.id === "stripe", r = e.features.auth, i = Object.values(oe(Pf, `./preview-modifies/${t.id}/`));
|
|
6069
6069
|
i.push({
|
|
6070
6070
|
path: ".env",
|
|
6071
6071
|
language: "text",
|
|
6072
6072
|
content: tr(t).map((e) => e.type === "comment" ? `# ${e.key}` : `${e.key}=${e.value}`).join("\n") + "\n",
|
|
6073
6073
|
status: "success"
|
|
6074
|
-
}),
|
|
6074
|
+
}), i.push({
|
|
6075
6075
|
path: "src/lib/site.ts",
|
|
6076
6076
|
language: "typescript",
|
|
6077
|
-
content: or("My App", void 0,
|
|
6077
|
+
content: or("My App", void 0, {
|
|
6078
|
+
currency: "MXN",
|
|
6079
|
+
country: "MX",
|
|
6080
|
+
currencies: ["USD"]
|
|
6081
|
+
}),
|
|
6078
6082
|
status: "success"
|
|
6079
6083
|
}), i.sort((e, t) => e.path.localeCompare(t.path));
|
|
6080
6084
|
let a = {
|
|
@@ -6096,14 +6100,14 @@ async function zf(e) {
|
|
|
6096
6100
|
}
|
|
6097
6101
|
//#endregion
|
|
6098
6102
|
//#region src/patterns/enable/payments/index.ts
|
|
6099
|
-
var Bf = "enable-payments", Vf = "2.
|
|
6103
|
+
var Bf = "enable-payments", Vf = "2.3.0", Hf = "src/patterns/enable/payments", Uf = "/enable/payments";
|
|
6100
6104
|
async function Wf(e) {
|
|
6101
6105
|
if (e.env === "preview") {
|
|
6102
6106
|
let t = await $n(e), n = await zf(e);
|
|
6103
|
-
return D(
|
|
6107
|
+
return D(C([t, n]), e);
|
|
6104
6108
|
}
|
|
6105
|
-
let { generate: t, hasVitest: n } = await import("./chunks/generate.runtime-
|
|
6106
|
-
return a(await D(
|
|
6109
|
+
let { generate: t, hasVitest: n } = await import("./chunks/generate.runtime-Dt3Edp8-.js"), r = await $n(e, { unitTests: n(e.root) }), i = await t(e), { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
6110
|
+
return a(await D(C([r, i]), e), e);
|
|
6107
6111
|
}
|
|
6108
6112
|
var Gf = {
|
|
6109
6113
|
version: Vf,
|
|
@@ -6160,7 +6164,7 @@ var Gf = {
|
|
|
6160
6164
|
baseline: "velastack",
|
|
6161
6165
|
providers: er,
|
|
6162
6166
|
generate: Wf
|
|
6163
|
-
}, Kf = "<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", qf = "import { browser } from '$app/env';\nimport { 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!) {\n cart(id: $id) {\n ...CartFields\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_CREATE = `#graphql\n mutation CartCreate($lines: [CartLineInput!]!) {\n cartCreate(input: { lines: $lines }) {\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!]!) {\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!]!) {\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!]!) {\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_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\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 const { data, errors } = await storefront().request(CART_QUERY, { variables: { id } });\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 async add(merchandiseId: string, quantity = 1, attributes?: { key: string; value: string }[]) {\n await this.load();\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, { variables });\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/**\n * The page's language, so a price reads the way the page does (an English\n * page shows MXN as `MX$5.50`, a Mexican Spanish one as `$5.50`) rather than\n * the way the visitor's browser is set.\n */\nfunction pageLocale(): string | undefined {\n return (browser && document.documentElement.lang) || undefined;\n}\n\nexport function formatMoney({ amount, currencyCode }: Money, locale = pageLocale()): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency: currencyCode }).format(\n Number(amount)\n );\n}\n", Jf = "<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", Yf = "<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<\/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", Xf = "import { browser } from '$app/env';\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 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\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/**\n * The page's language, so a price reads the way the page does (an English\n * page shows MXN as `MX$5.50`, a Mexican Spanish one as `$5.50`) rather than\n * the way the visitor's browser is set.\n */\nfunction pageLocale(): string | undefined {\n return (browser && document.documentElement.lang) || undefined;\n}\n\n/**\n * Formats a Stripe amount: Intl knows how many decimals the currency has\n * (none for JPY). A server render passes the request's locale, so the server\n * and the browser agree.\n */\nexport function formatAmount(amount: number, currency: string, locale = pageLocale()): string {\n const format = new Intl.NumberFormat(locale, { style: 'currency', currency });\n const digits = format.resolvedOptions().maximumFractionDigits ?? 2;\n return format.format(amount / 10 ** digits);\n}\n", Zf = "<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", Qf = "<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)}\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)}</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", $f = "<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", ep = "import { fail, redirect } from '@sveltejs/kit';\nimport Stripe from 'stripe';\nimport stripe from '#lib/stripe.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\nexport const actions = {\n checkout: async ({ request, url }) => {\n const items = readItems((await request.formData()).get('items'));\n if (!items) return fail(400, { message: 'Your cart could not be read.' });\n\n let session: Stripe.Checkout.Session;\n try {\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\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", tp = "<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", np = "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 { error } from '@sveltejs/kit';\nimport stripe from '#lib/stripe.js';\n\nexport const load = async ({ url }) => {\n const id = url.searchParams.get('session_id');\n if (!id) error(404, 'Not found');\n\n try {\n const session = await stripe.checkout.sessions.retrieve(id);\n return {\n amountTotal: session.amount_total,\n currency: session.currency,\n paid: session.payment_status === 'paid',\n // The page's language (app.html's `lang`), so the amount is formatted\n // the same on the server and in the browser.\n locale: 'en'\n };\n } catch {\n error(404, 'Not found');\n }\n};\n", ip = "<script lang=\"ts\">\n import { onMount } from 'svelte';\n import { cart, formatAmount } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n\n onMount(() => {\n cart.load();\n if (data.paid) cart.clear();\n });\n<\/script>\n\n<section data-role=\"content\" class=\"max-w-xl\">\n {#if data.paid}\n <h1 class=\"mb-2 text-2xl font-semibold\">Thank you</h1>\n <p class=\"text-muted-foreground\">\n {#if data.amountTotal !== null && data.currency}\n Your payment of {formatAmount(data.amountTotal, data.currency, data.locale)} went through.\n {:else}\n Your payment went through.\n {/if}\n </p>\n {:else}\n <h1 class=\"mb-2 text-2xl font-semibold\">Payment pending</h1>\n <p class=\"text-muted-foreground\">Your order is placed; the payment has not cleared yet.</p>\n {/if}\n</section>\n", ap = "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", 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 /** 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", sp = "<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, 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", cp = "import { fail, redirect } from '@sveltejs/kit';\nimport Stripe from 'stripe';\nimport stripe from '#lib/stripe.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\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 let session: Stripe.Checkout.Session;\n try {\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\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", lp = "import { error } from '@sveltejs/kit';\nimport { getLocale } from '#locales/main.url.js';\nimport stripe from '#lib/stripe.js';\n\nexport const load = async ({ url }) => {\n const id = url.searchParams.get('session_id');\n if (!id) error(404, 'Not found');\n\n try {\n const session = await stripe.checkout.sessions.retrieve(id);\n return {\n amountTotal: session.amount_total,\n currency: session.currency,\n paid: session.payment_status === 'paid',\n // The page's language, so the amount is formatted the same on the\n // server and in the browser.\n locale: getLocale(url)\n };\n } catch {\n error(404, 'Not found');\n }\n};\n", up = [
|
|
6167
|
+
}, Kf = "<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", qf = "import { browser } from '$app/env';\nimport { money } from '#lib/currency.svelte.js';\nimport { 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!) {\n cart(id: $id) {\n ...CartFields\n }\n }\n ${CART_FRAGMENT}\n`;\n\nconst CART_CREATE = `#graphql\n mutation CartCreate($lines: [CartLineInput!]!) {\n cartCreate(input: { lines: $lines }) {\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!]!) {\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!]!) {\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!]!) {\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_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\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 const { data, errors } = await storefront().request(CART_QUERY, { variables: { id } });\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 async add(merchandiseId: string, quantity = 1, attributes?: { key: string; value: string }[]) {\n await this.load();\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, { variables });\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", Jf = "<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", Yf = "<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<\/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", Xf = "import { browser } from '$app/env';\nimport { currency } 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 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\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/**\n * Formats a Stripe amount: Intl knows how many decimals the currency has\n * (none for JPY). Shown the way the visitor reads prices: in the currency they\n * picked, as an estimate, when it isn't the price's own.\n */\nexport function formatAmount(amount: number, code: string): string {\n const digits =\n new Intl.NumberFormat('en', { style: 'currency', currency: code }).resolvedOptions()\n .maximumFractionDigits ?? 2;\n return currency.format(amount / 10 ** digits, code);\n}\n", Zf = "<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", Qf = "<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)}\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)}</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", $f = "<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", ep = "import { fail, redirect } from '@sveltejs/kit';\nimport Stripe from 'stripe';\nimport stripe from '#lib/stripe.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\nexport const actions = {\n checkout: async ({ request, url }) => {\n const items = readItems((await request.formData()).get('items'));\n if (!items) return fail(400, { message: 'Your cart could not be read.' });\n\n let session: Stripe.Checkout.Session;\n try {\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\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", tp = "<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", np = "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 { error } from '@sveltejs/kit';\nimport stripe from '#lib/stripe.js';\n\nexport const load = async ({ url }) => {\n const id = url.searchParams.get('session_id');\n if (!id) error(404, 'Not found');\n\n try {\n const session = await stripe.checkout.sessions.retrieve(id);\n return {\n amountTotal: session.amount_total,\n currency: session.currency,\n paid: session.payment_status === 'paid'\n };\n } catch {\n error(404, 'Not found');\n }\n};\n", ip = "<script lang=\"ts\">\n import { onMount } from 'svelte';\n import { cart, formatAmount } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n\n onMount(() => {\n cart.load();\n if (data.paid) cart.clear();\n });\n<\/script>\n\n<section data-role=\"content\" class=\"max-w-xl\">\n {#if data.paid}\n <h1 class=\"mb-2 text-2xl font-semibold\">Thank you</h1>\n <p class=\"text-muted-foreground\">\n {#if data.amountTotal !== null && data.currency}\n Your payment of {formatAmount(data.amountTotal, data.currency)} went through.\n {:else}\n Your payment went through.\n {/if}\n </p>\n {:else}\n <h1 class=\"mb-2 text-2xl font-semibold\">Payment pending</h1>\n <p class=\"text-muted-foreground\">Your order is placed; the payment has not cleared yet.</p>\n {/if}\n</section>\n", ap = "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", 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 /** 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", sp = "<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", cp = "import { fail, redirect } from '@sveltejs/kit';\nimport Stripe from 'stripe';\nimport stripe from '#lib/stripe.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\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 let session: Stripe.Checkout.Session;\n try {\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\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", lp = [
|
|
6164
6168
|
{
|
|
6165
6169
|
id: "stripe",
|
|
6166
6170
|
label: "Stripe",
|
|
@@ -6174,11 +6178,11 @@ var Gf = {
|
|
|
6174
6178
|
id: "whatsapp",
|
|
6175
6179
|
label: "WhatsApp"
|
|
6176
6180
|
}
|
|
6177
|
-
],
|
|
6181
|
+
], up = {
|
|
6178
6182
|
slug: "enable-ecommerce",
|
|
6179
|
-
providers:
|
|
6183
|
+
providers: lp,
|
|
6180
6184
|
inheritsProvider: "payments"
|
|
6181
|
-
},
|
|
6185
|
+
}, dp = /* #__PURE__ */ Object.assign({ "./creates/src/lib/components/cart/cart-button.svelte": Kf }), fp = /* #__PURE__ */ Object.assign({
|
|
6182
6186
|
"./providers/shopify/src/lib/cart.svelte.ts": qf,
|
|
6183
6187
|
"./providers/shopify/src/lib/components/cart/add-to-cart.svelte": Jf,
|
|
6184
6188
|
"./providers/shopify/src/lib/components/cart/cart-sheet.svelte": Yf,
|
|
@@ -6194,12 +6198,12 @@ var Gf = {
|
|
|
6194
6198
|
"./providers/whatsapp/src/lib/cart.svelte.ts": ap,
|
|
6195
6199
|
"./providers/whatsapp/src/lib/components/cart/add-to-cart.svelte": op,
|
|
6196
6200
|
"./providers/whatsapp/src/lib/components/cart/cart-sheet.svelte": sp
|
|
6197
|
-
}),
|
|
6198
|
-
async function
|
|
6199
|
-
let n =
|
|
6201
|
+
}), pp = /* #__PURE__ */ Object.assign({ "./providers-app-mode/stripe/src/routes/(public)/cart/+page.server.ts": cp });
|
|
6202
|
+
async function mp(e, { stripeCustomer: t = !1 } = {}) {
|
|
6203
|
+
let n = E(up, e), r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
6200
6204
|
for (let t of e) r.set(t.path, t);
|
|
6201
6205
|
};
|
|
6202
|
-
return i(Object.values(
|
|
6206
|
+
return i(Object.values(w(dp, "./creates/"))), i(de(fp, n.id)), n.id === "stripe" && t && i(de(pp, n.id, "./providers-app-mode/")), {
|
|
6203
6207
|
creates: [...r.values()].sort((e, t) => e.path.localeCompare(t.path)),
|
|
6204
6208
|
modifies: [],
|
|
6205
6209
|
deletes: [],
|
|
@@ -6217,11 +6221,11 @@ async function gp(e, { stripeCustomer: t = !1 } = {}) {
|
|
|
6217
6221
|
}
|
|
6218
6222
|
//#endregion
|
|
6219
6223
|
//#region src/patterns/enable/ecommerce/generate.preview.ts
|
|
6220
|
-
var
|
|
6221
|
-
async function
|
|
6222
|
-
return
|
|
6224
|
+
var hp = /* #__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" });
|
|
6225
|
+
async function gp(e) {
|
|
6226
|
+
return E(up, e), {
|
|
6223
6227
|
creates: [],
|
|
6224
|
-
modifies: Object.values(
|
|
6228
|
+
modifies: Object.values(w(hp, "./preview-modifies/")).sort((e, t) => e.path.localeCompare(t.path)),
|
|
6225
6229
|
deletes: [],
|
|
6226
6230
|
components: [],
|
|
6227
6231
|
packages: [],
|
|
@@ -6232,20 +6236,20 @@ async function vp(e) {
|
|
|
6232
6236
|
}
|
|
6233
6237
|
//#endregion
|
|
6234
6238
|
//#region src/patterns/enable/ecommerce/index.ts
|
|
6235
|
-
var
|
|
6236
|
-
async function
|
|
6239
|
+
var _p = "enable-ecommerce", vp = "2.1.0", yp = "src/patterns/enable/ecommerce", bp = "/enable/ecommerce";
|
|
6240
|
+
async function xp(e) {
|
|
6237
6241
|
if (e.env === "preview") {
|
|
6238
|
-
let t = await
|
|
6239
|
-
return D(
|
|
6242
|
+
let t = await mp(e), n = await gp(e);
|
|
6243
|
+
return D(C([t, n]), e);
|
|
6240
6244
|
}
|
|
6241
|
-
let { generate: t, hasStripeCustomer: n } = await import("./chunks/generate.runtime-e_BkDyP0.js"), r = await
|
|
6242
|
-
return a(await D(
|
|
6243
|
-
}
|
|
6244
|
-
var
|
|
6245
|
-
version:
|
|
6246
|
-
slug:
|
|
6247
|
-
source:
|
|
6248
|
-
docs:
|
|
6245
|
+
let { generate: t, hasStripeCustomer: n } = await import("./chunks/generate.runtime-e_BkDyP0.js"), r = await mp(e, { stripeCustomer: n(e.root) }), i = await t(e), { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
6246
|
+
return a(await D(C([r, i]), e), e);
|
|
6247
|
+
}
|
|
6248
|
+
var Sp = {
|
|
6249
|
+
version: vp,
|
|
6250
|
+
slug: _p,
|
|
6251
|
+
source: yp,
|
|
6252
|
+
docs: bp,
|
|
6249
6253
|
plan: "pro",
|
|
6250
6254
|
title: "Enable ecommerce",
|
|
6251
6255
|
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.",
|
|
@@ -6281,16 +6285,16 @@ var wp = {
|
|
|
6281
6285
|
examples: [],
|
|
6282
6286
|
tests: 0,
|
|
6283
6287
|
baseline: "velastack",
|
|
6284
|
-
providers:
|
|
6285
|
-
inheritsProvider:
|
|
6286
|
-
generate:
|
|
6287
|
-
},
|
|
6288
|
-
"./creates/src/lib/workflows/sync-stripe-subscriptions.ts":
|
|
6289
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts":
|
|
6290
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts":
|
|
6291
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts":
|
|
6292
|
-
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts":
|
|
6293
|
-
}),
|
|
6288
|
+
providers: lp,
|
|
6289
|
+
inheritsProvider: up.inheritsProvider,
|
|
6290
|
+
generate: xp
|
|
6291
|
+
}, Cp = "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", wp = "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", Tp = "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", Ep = "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", Dp = "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", Op = /* #__PURE__ */ Object.assign({
|
|
6292
|
+
"./creates/src/lib/workflows/sync-stripe-subscriptions.ts": Cp,
|
|
6293
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": wp,
|
|
6294
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": Tp,
|
|
6295
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": Ep,
|
|
6296
|
+
"./creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": Dp
|
|
6297
|
+
}), kp = "./creates/", Ap = {
|
|
6294
6298
|
name: "stripe_subscriptions",
|
|
6295
6299
|
type: "base",
|
|
6296
6300
|
fields: [
|
|
@@ -6365,13 +6369,13 @@ var wp = {
|
|
|
6365
6369
|
}
|
|
6366
6370
|
]
|
|
6367
6371
|
};
|
|
6368
|
-
async function
|
|
6372
|
+
async function jp(e) {
|
|
6369
6373
|
return {
|
|
6370
|
-
creates: Object.entries(
|
|
6371
|
-
let n =
|
|
6374
|
+
creates: Object.entries(Op).map(([e, t]) => {
|
|
6375
|
+
let n = T(e, kp);
|
|
6372
6376
|
return {
|
|
6373
6377
|
path: n,
|
|
6374
|
-
language:
|
|
6378
|
+
language: S(n),
|
|
6375
6379
|
content: t,
|
|
6376
6380
|
status: "success"
|
|
6377
6381
|
};
|
|
@@ -6380,14 +6384,14 @@ async function Np(e) {
|
|
|
6380
6384
|
deletes: [],
|
|
6381
6385
|
components: [],
|
|
6382
6386
|
packages: [],
|
|
6383
|
-
collections: [
|
|
6387
|
+
collections: [Ap],
|
|
6384
6388
|
collectionPatches: [],
|
|
6385
6389
|
collectionDrops: []
|
|
6386
6390
|
};
|
|
6387
6391
|
}
|
|
6388
6392
|
//#endregion
|
|
6389
6393
|
//#region src/patterns/enable/subscriptions/generate.preview.ts
|
|
6390
|
-
var
|
|
6394
|
+
var Mp = /* #__PURE__ */ Object.assign({
|
|
6391
6395
|
"./preview-modifies/src/lib/components/app-sidebar.svelte": fr,
|
|
6392
6396
|
"./preview-modifies/src/lib/components/nav-user.svelte": ur,
|
|
6393
6397
|
"./preview-modifies/src/routes/(app)/+layout.server.ts": sr,
|
|
@@ -6395,15 +6399,15 @@ var Pp = /* #__PURE__ */ Object.assign({
|
|
|
6395
6399
|
"./preview-modifies/src/routes/(app)/billing/+page.server.ts": dr,
|
|
6396
6400
|
"./preview-modifies/src/routes/(app)/billing/+page.svelte": lr,
|
|
6397
6401
|
"./preview-modifies/src/routes/webhooks/stripe/handlers/dispatch.ts": pr
|
|
6398
|
-
}),
|
|
6399
|
-
async function
|
|
6402
|
+
}), Np = "./preview-modifies/";
|
|
6403
|
+
async function Pp(e) {
|
|
6400
6404
|
return {
|
|
6401
6405
|
creates: [],
|
|
6402
|
-
modifies: Object.entries(
|
|
6403
|
-
let n =
|
|
6406
|
+
modifies: Object.entries(Mp).map(([e, t]) => {
|
|
6407
|
+
let n = T(e, Np);
|
|
6404
6408
|
return {
|
|
6405
6409
|
path: n,
|
|
6406
|
-
language:
|
|
6410
|
+
language: S(n),
|
|
6407
6411
|
content: t,
|
|
6408
6412
|
status: "success"
|
|
6409
6413
|
};
|
|
@@ -6418,26 +6422,26 @@ async function Ip(e) {
|
|
|
6418
6422
|
}
|
|
6419
6423
|
//#endregion
|
|
6420
6424
|
//#region src/patterns/enable/subscriptions/index.ts
|
|
6421
|
-
var
|
|
6422
|
-
async function
|
|
6423
|
-
let t = await
|
|
6425
|
+
var Fp = "enable-subscriptions", Ip = "1.1.2", Lp = "src/patterns/enable/subscriptions", Rp = "/enable/subscriptions";
|
|
6426
|
+
async function zp(e) {
|
|
6427
|
+
let t = await jp(e);
|
|
6424
6428
|
if (e.env === "preview") {
|
|
6425
|
-
let n = await
|
|
6426
|
-
return D(
|
|
6429
|
+
let n = await Pp(e);
|
|
6430
|
+
return D(C([t, n]), e);
|
|
6427
6431
|
}
|
|
6428
6432
|
let { assertPaymentsAppMode: n, generate: r } = await import("./chunks/generate.runtime-DJ5uF6EN.js");
|
|
6429
6433
|
n(e.root);
|
|
6430
6434
|
let { createCollections: i } = await import("./chunks/collections-BYcVyY9O.js").then((e) => e.n), a = await i(t.collections, e), o = await r(e), { writeResult: s } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
6431
|
-
return s(await D(
|
|
6435
|
+
return s(await D(C([{
|
|
6432
6436
|
...t,
|
|
6433
6437
|
creates: [...t.creates, ...a]
|
|
6434
6438
|
}, o]), e), e);
|
|
6435
6439
|
}
|
|
6436
|
-
var
|
|
6437
|
-
version:
|
|
6438
|
-
slug:
|
|
6439
|
-
source:
|
|
6440
|
-
docs:
|
|
6440
|
+
var Bp = {
|
|
6441
|
+
version: Ip,
|
|
6442
|
+
slug: Fp,
|
|
6443
|
+
source: Lp,
|
|
6444
|
+
docs: Rp,
|
|
6441
6445
|
plan: "pro",
|
|
6442
6446
|
title: "Enable subscriptions",
|
|
6443
6447
|
summary: "Adds Stripe subscription billing with plan selection, cancel/resume, and webhook-synced subscription state. Requires enable-payments.",
|
|
@@ -6474,55 +6478,55 @@ var Hp = {
|
|
|
6474
6478
|
examples: [],
|
|
6475
6479
|
tests: 0,
|
|
6476
6480
|
baseline: "velastack",
|
|
6477
|
-
generate:
|
|
6478
|
-
}, Up = "<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", Wp = "import { z } from \"zod\";\n\nexport const teamSchema = z.object({\n name: z.string(),\n});\n", Gp = "import { z } from \"zod\";\n\nexport const teamInviteSchema = z.object({\n email: z.email(),\n});\n", Kp = "import { z } from \"zod\";\n\nexport const teamRoleSchema = z.object({\n role: z.enum([\"owner\", \"admin\", \"member\"]),\n});\n", qp = "<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", Jp = "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", Yp = "<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", Xp = "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", Zp = "<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", Qp = "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", $p = "<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", em = "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", tm = "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", nm = "<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", rm = "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", im = "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", am = "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", om = "<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", sm = "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", cm = "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", lm = "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", um = "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", dm = "<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", fm = "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", pm = "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", mm = "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", hm = "<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", gm = "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", _m = "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", vm = "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", ym = "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", bm = "<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", xm = "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", Sm = "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", Cm = "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", wm = "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", Tm = "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", Em = /* #__PURE__ */ Object.assign({
|
|
6479
|
-
"./creates/src/lib/components/team-switcher.svelte":
|
|
6480
|
-
"./creates/src/lib/schemas/team.ts":
|
|
6481
|
-
"./creates/src/lib/schemas/teamInvite.ts":
|
|
6482
|
-
"./creates/src/lib/schemas/teamRole.ts":
|
|
6483
|
-
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte":
|
|
6484
|
-
"./creates/src/routes/(app)/invite/[id]/+page.server.ts":
|
|
6485
|
-
"./creates/src/routes/(app)/invite/[id]/+page.svelte":
|
|
6486
|
-
"./creates/src/routes/(app)/invite/[id]/+page.ts":
|
|
6487
|
-
"./creates/src/routes/(app)/join/[id]/+layout@.svelte":
|
|
6488
|
-
"./creates/src/routes/(app)/join/[id]/+page.server.ts":
|
|
6489
|
-
"./creates/src/routes/(app)/join/[id]/+page.svelte":
|
|
6490
|
-
"./creates/src/routes/(app)/join/[id]/+page.ts":
|
|
6491
|
-
"./creates/src/routes/(app)/teams/+layout.server.ts":
|
|
6492
|
-
"./creates/src/routes/(app)/teams/+layout.svelte":
|
|
6493
|
-
"./creates/src/routes/(app)/teams/+page.server.ts":
|
|
6481
|
+
generate: zp
|
|
6482
|
+
}, Vp = "<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", Hp = "import { z } from \"zod\";\n\nexport const teamSchema = z.object({\n name: z.string(),\n});\n", Up = "import { z } from \"zod\";\n\nexport const teamInviteSchema = z.object({\n email: z.email(),\n});\n", Wp = "import { z } from \"zod\";\n\nexport const teamRoleSchema = z.object({\n role: z.enum([\"owner\", \"admin\", \"member\"]),\n});\n", Gp = "<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", Kp = "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", qp = "<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", Jp = "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", Yp = "<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", Xp = "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", Zp = "<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", Qp = "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", $p = "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", em = "<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", tm = "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", nm = "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", rm = "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", im = "<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", am = "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", om = "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", sm = "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", cm = "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", lm = "<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", um = "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", dm = "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", fm = "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", pm = "<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", mm = "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", hm = "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", gm = "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", _m = "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", vm = "<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", ym = "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", bm = "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", xm = "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", Sm = "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", Cm = "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", wm = /* #__PURE__ */ Object.assign({
|
|
6483
|
+
"./creates/src/lib/components/team-switcher.svelte": Vp,
|
|
6484
|
+
"./creates/src/lib/schemas/team.ts": Hp,
|
|
6485
|
+
"./creates/src/lib/schemas/teamInvite.ts": Up,
|
|
6486
|
+
"./creates/src/lib/schemas/teamRole.ts": Wp,
|
|
6487
|
+
"./creates/src/routes/(app)/invite/[id]/+layout@.svelte": Gp,
|
|
6488
|
+
"./creates/src/routes/(app)/invite/[id]/+page.server.ts": Kp,
|
|
6489
|
+
"./creates/src/routes/(app)/invite/[id]/+page.svelte": qp,
|
|
6490
|
+
"./creates/src/routes/(app)/invite/[id]/+page.ts": Jp,
|
|
6491
|
+
"./creates/src/routes/(app)/join/[id]/+layout@.svelte": Yp,
|
|
6492
|
+
"./creates/src/routes/(app)/join/[id]/+page.server.ts": Xp,
|
|
6493
|
+
"./creates/src/routes/(app)/join/[id]/+page.svelte": Zp,
|
|
6494
|
+
"./creates/src/routes/(app)/join/[id]/+page.ts": Qp,
|
|
6495
|
+
"./creates/src/routes/(app)/teams/+layout.server.ts": $p,
|
|
6496
|
+
"./creates/src/routes/(app)/teams/+layout.svelte": em,
|
|
6497
|
+
"./creates/src/routes/(app)/teams/+page.server.ts": tm,
|
|
6494
6498
|
"./creates/src/routes/(app)/teams/+page.svelte": "",
|
|
6495
|
-
"./creates/src/routes/(app)/teams/+page.ts":
|
|
6496
|
-
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts":
|
|
6497
|
-
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte":
|
|
6498
|
-
"./creates/src/routes/(app)/teams/[id]/+page.server.ts":
|
|
6499
|
+
"./creates/src/routes/(app)/teams/+page.ts": nm,
|
|
6500
|
+
"./creates/src/routes/(app)/teams/[id]/+layout.server.ts": rm,
|
|
6501
|
+
"./creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": im,
|
|
6502
|
+
"./creates/src/routes/(app)/teams/[id]/+page.server.ts": am,
|
|
6499
6503
|
"./creates/src/routes/(app)/teams/[id]/+page.svelte": "",
|
|
6500
|
-
"./creates/src/routes/(app)/teams/[id]/+page.ts":
|
|
6501
|
-
"./creates/src/routes/(app)/teams/[id]/authorization.ts":
|
|
6502
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts":
|
|
6503
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte":
|
|
6504
|
-
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts":
|
|
6505
|
-
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts":
|
|
6506
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts":
|
|
6507
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte":
|
|
6508
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts":
|
|
6509
|
-
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts":
|
|
6510
|
-
"./creates/src/routes/(app)/teams/[id]/server.test.ts":
|
|
6511
|
-
"./creates/src/routes/(app)/teams/new/+page.server.ts":
|
|
6512
|
-
"./creates/src/routes/(app)/teams/new/+page.svelte":
|
|
6513
|
-
"./creates/src/routes/(app)/teams/new/+page.ts":
|
|
6514
|
-
"./creates/src/routes/(app)/teams/new/server.test.ts":
|
|
6515
|
-
"./creates/src/routes/(app)/teams/server.test.ts":
|
|
6516
|
-
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts":
|
|
6517
|
-
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts":
|
|
6518
|
-
}),
|
|
6519
|
-
async function
|
|
6504
|
+
"./creates/src/routes/(app)/teams/[id]/+page.ts": om,
|
|
6505
|
+
"./creates/src/routes/(app)/teams/[id]/authorization.ts": sm,
|
|
6506
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": cm,
|
|
6507
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.svelte": lm,
|
|
6508
|
+
"./creates/src/routes/(app)/teams/[id]/invite/+page.ts": um,
|
|
6509
|
+
"./creates/src/routes/(app)/teams/[id]/invite/server.test.ts": dm,
|
|
6510
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": fm,
|
|
6511
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": pm,
|
|
6512
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": mm,
|
|
6513
|
+
"./creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": hm,
|
|
6514
|
+
"./creates/src/routes/(app)/teams/[id]/server.test.ts": gm,
|
|
6515
|
+
"./creates/src/routes/(app)/teams/new/+page.server.ts": _m,
|
|
6516
|
+
"./creates/src/routes/(app)/teams/new/+page.svelte": vm,
|
|
6517
|
+
"./creates/src/routes/(app)/teams/new/+page.ts": ym,
|
|
6518
|
+
"./creates/src/routes/(app)/teams/new/server.test.ts": bm,
|
|
6519
|
+
"./creates/src/routes/(app)/teams/server.test.ts": xm,
|
|
6520
|
+
"./creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": Sm,
|
|
6521
|
+
"./creates/src/routes/(app)/teams/switch/[id]/server.test.ts": Cm
|
|
6522
|
+
}), Tm = "./creates/";
|
|
6523
|
+
async function Em(e) {
|
|
6520
6524
|
return {
|
|
6521
|
-
creates: Object.entries(
|
|
6522
|
-
let n =
|
|
6525
|
+
creates: Object.entries(wm).map(([e, t]) => {
|
|
6526
|
+
let n = T(e, Tm);
|
|
6523
6527
|
return {
|
|
6524
6528
|
path: n,
|
|
6525
|
-
language:
|
|
6529
|
+
language: S(n),
|
|
6526
6530
|
content: t,
|
|
6527
6531
|
status: "success"
|
|
6528
6532
|
};
|
|
@@ -6550,8 +6554,8 @@ async function Om(e) {
|
|
|
6550
6554
|
}
|
|
6551
6555
|
//#endregion
|
|
6552
6556
|
//#region src/patterns/enable/teams/preview-modifies/src/lib/components/app-sidebar.svelte?raw
|
|
6553
|
-
var
|
|
6554
|
-
function
|
|
6557
|
+
var Dm = "<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", Om = "<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", km = "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", Am = "<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", jm = "users", Mm = "teams", Nm = "team_memberships";
|
|
6558
|
+
function Pm(e) {
|
|
6555
6559
|
let t = mr.find((t) => t.collectionName === e);
|
|
6556
6560
|
if (!t) throw Error(`teams: missing TEAM_RULE_PATCHES entry for "${e}"`);
|
|
6557
6561
|
return {
|
|
@@ -6562,11 +6566,11 @@ function Im(e) {
|
|
|
6562
6566
|
deleteRule: t.deleteRule
|
|
6563
6567
|
};
|
|
6564
6568
|
}
|
|
6565
|
-
var
|
|
6569
|
+
var Fm = [
|
|
6566
6570
|
{
|
|
6567
6571
|
name: "teams",
|
|
6568
6572
|
type: "base",
|
|
6569
|
-
...
|
|
6573
|
+
...Pm("teams"),
|
|
6570
6574
|
fields: [
|
|
6571
6575
|
{
|
|
6572
6576
|
name: "id",
|
|
@@ -6587,7 +6591,7 @@ var Lm = [
|
|
|
6587
6591
|
name: "owner",
|
|
6588
6592
|
type: "relation",
|
|
6589
6593
|
cascadeDelete: !1,
|
|
6590
|
-
collectionId:
|
|
6594
|
+
collectionId: jm,
|
|
6591
6595
|
maxSelect: 1,
|
|
6592
6596
|
minSelect: 0,
|
|
6593
6597
|
required: !0
|
|
@@ -6609,7 +6613,7 @@ var Lm = [
|
|
|
6609
6613
|
{
|
|
6610
6614
|
name: "team_memberships",
|
|
6611
6615
|
type: "base",
|
|
6612
|
-
...
|
|
6616
|
+
...Pm("team_memberships"),
|
|
6613
6617
|
fields: [
|
|
6614
6618
|
{
|
|
6615
6619
|
name: "id",
|
|
@@ -6624,7 +6628,7 @@ var Lm = [
|
|
|
6624
6628
|
{
|
|
6625
6629
|
name: "team",
|
|
6626
6630
|
cascadeDelete: !0,
|
|
6627
|
-
collectionId:
|
|
6631
|
+
collectionId: Mm,
|
|
6628
6632
|
maxSelect: 1,
|
|
6629
6633
|
minSelect: 0,
|
|
6630
6634
|
required: !0,
|
|
@@ -6633,7 +6637,7 @@ var Lm = [
|
|
|
6633
6637
|
{
|
|
6634
6638
|
name: "user",
|
|
6635
6639
|
cascadeDelete: !0,
|
|
6636
|
-
collectionId:
|
|
6640
|
+
collectionId: jm,
|
|
6637
6641
|
maxSelect: 1,
|
|
6638
6642
|
minSelect: 0,
|
|
6639
6643
|
required: !0,
|
|
@@ -6667,7 +6671,7 @@ var Lm = [
|
|
|
6667
6671
|
{
|
|
6668
6672
|
name: "team_users",
|
|
6669
6673
|
type: "view",
|
|
6670
|
-
...
|
|
6674
|
+
...Pm("team_users"),
|
|
6671
6675
|
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;",
|
|
6672
6676
|
fields: [
|
|
6673
6677
|
{
|
|
@@ -6693,7 +6697,7 @@ var Lm = [
|
|
|
6693
6697
|
{
|
|
6694
6698
|
name: "membership_id",
|
|
6695
6699
|
cascadeDelete: !1,
|
|
6696
|
-
collectionId:
|
|
6700
|
+
collectionId: Nm,
|
|
6697
6701
|
maxSelect: 1,
|
|
6698
6702
|
minSelect: 0,
|
|
6699
6703
|
required: !1,
|
|
@@ -6702,7 +6706,7 @@ var Lm = [
|
|
|
6702
6706
|
{
|
|
6703
6707
|
name: "team",
|
|
6704
6708
|
cascadeDelete: !0,
|
|
6705
|
-
collectionId:
|
|
6709
|
+
collectionId: Mm,
|
|
6706
6710
|
maxSelect: 1,
|
|
6707
6711
|
minSelect: 0,
|
|
6708
6712
|
required: !0,
|
|
@@ -6724,7 +6728,7 @@ var Lm = [
|
|
|
6724
6728
|
{
|
|
6725
6729
|
name: "team_invites",
|
|
6726
6730
|
type: "base",
|
|
6727
|
-
...
|
|
6731
|
+
...Pm("team_invites"),
|
|
6728
6732
|
fields: [
|
|
6729
6733
|
{
|
|
6730
6734
|
name: "id",
|
|
@@ -6740,7 +6744,7 @@ var Lm = [
|
|
|
6740
6744
|
name: "team",
|
|
6741
6745
|
type: "relation",
|
|
6742
6746
|
cascadeDelete: !0,
|
|
6743
|
-
collectionId:
|
|
6747
|
+
collectionId: Mm,
|
|
6744
6748
|
maxSelect: 1,
|
|
6745
6749
|
minSelect: 0,
|
|
6746
6750
|
required: !0
|
|
@@ -6767,7 +6771,7 @@ var Lm = [
|
|
|
6767
6771
|
{
|
|
6768
6772
|
name: "team_invite_links",
|
|
6769
6773
|
type: "base",
|
|
6770
|
-
...
|
|
6774
|
+
...Pm("team_invite_links"),
|
|
6771
6775
|
indexes: ["CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)"],
|
|
6772
6776
|
fields: [
|
|
6773
6777
|
{
|
|
@@ -6783,7 +6787,7 @@ var Lm = [
|
|
|
6783
6787
|
{
|
|
6784
6788
|
name: "team",
|
|
6785
6789
|
cascadeDelete: !0,
|
|
6786
|
-
collectionId:
|
|
6790
|
+
collectionId: Mm,
|
|
6787
6791
|
maxSelect: 1,
|
|
6788
6792
|
minSelect: 0,
|
|
6789
6793
|
required: !0,
|
|
@@ -6803,20 +6807,20 @@ var Lm = [
|
|
|
6803
6807
|
}
|
|
6804
6808
|
]
|
|
6805
6809
|
}
|
|
6806
|
-
],
|
|
6807
|
-
"./preview-modifies/src/lib/components/app-sidebar.svelte":
|
|
6808
|
-
"./preview-modifies/src/lib/components/nav-user.svelte":
|
|
6809
|
-
"./preview-modifies/src/routes/(app)/+layout.server.ts":
|
|
6810
|
-
"./preview-modifies/src/routes/(app)/+layout.svelte":
|
|
6811
|
-
}),
|
|
6812
|
-
async function
|
|
6810
|
+
], Im = /* #__PURE__ */ Object.assign({
|
|
6811
|
+
"./preview-modifies/src/lib/components/app-sidebar.svelte": Dm,
|
|
6812
|
+
"./preview-modifies/src/lib/components/nav-user.svelte": Om,
|
|
6813
|
+
"./preview-modifies/src/routes/(app)/+layout.server.ts": km,
|
|
6814
|
+
"./preview-modifies/src/routes/(app)/+layout.svelte": Am
|
|
6815
|
+
}), Lm = "./preview-modifies/";
|
|
6816
|
+
async function Rm(e) {
|
|
6813
6817
|
return {
|
|
6814
6818
|
creates: [],
|
|
6815
|
-
modifies: Object.entries(
|
|
6816
|
-
let n =
|
|
6819
|
+
modifies: Object.entries(Im).map(([e, t]) => {
|
|
6820
|
+
let n = T(e, Lm);
|
|
6817
6821
|
return {
|
|
6818
6822
|
path: n,
|
|
6819
|
-
language:
|
|
6823
|
+
language: S(n),
|
|
6820
6824
|
content: t,
|
|
6821
6825
|
status: "success"
|
|
6822
6826
|
};
|
|
@@ -6824,28 +6828,28 @@ async function Bm(e) {
|
|
|
6824
6828
|
deletes: [],
|
|
6825
6829
|
components: [],
|
|
6826
6830
|
packages: [],
|
|
6827
|
-
collections:
|
|
6831
|
+
collections: Fm,
|
|
6828
6832
|
collectionPatches: [],
|
|
6829
6833
|
collectionDrops: []
|
|
6830
6834
|
};
|
|
6831
6835
|
}
|
|
6832
6836
|
//#endregion
|
|
6833
6837
|
//#region src/patterns/enable/teams/index.ts
|
|
6834
|
-
var
|
|
6835
|
-
async function
|
|
6836
|
-
let t = await
|
|
6838
|
+
var zm = "enable-teams", Bm = "1.1.1", Vm = "src/patterns/enable/teams", Hm = "/enable/teams";
|
|
6839
|
+
async function Um(e) {
|
|
6840
|
+
let t = await Em(e);
|
|
6837
6841
|
if (e.env === "preview") {
|
|
6838
|
-
let n = await
|
|
6839
|
-
return D(
|
|
6842
|
+
let n = await Rm(e);
|
|
6843
|
+
return D(C([t, n]), e);
|
|
6840
6844
|
}
|
|
6841
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
6842
|
-
return i(await D(
|
|
6843
|
-
}
|
|
6844
|
-
var
|
|
6845
|
-
version:
|
|
6846
|
-
slug:
|
|
6847
|
-
source:
|
|
6848
|
-
docs:
|
|
6845
|
+
let { generate: n } = await import("./chunks/generate.runtime-Du84quuK.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
6846
|
+
return i(await D(C([t, r]), e), e);
|
|
6847
|
+
}
|
|
6848
|
+
var Wm = {
|
|
6849
|
+
version: Bm,
|
|
6850
|
+
slug: zm,
|
|
6851
|
+
source: Vm,
|
|
6852
|
+
docs: Hm,
|
|
6849
6853
|
plan: "pro",
|
|
6850
6854
|
title: "Enable teams",
|
|
6851
6855
|
summary: "Adds multi-tenant teams with memberships, invites, and a sidebar team switcher.",
|
|
@@ -6879,23 +6883,23 @@ var Km = {
|
|
|
6879
6883
|
examples: [],
|
|
6880
6884
|
tests: 36,
|
|
6881
6885
|
baseline: "velastack",
|
|
6882
|
-
generate:
|
|
6883
|
-
}, qm = "/**\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", Jm = "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", Ym = "<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", Xm = "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", Zm = "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", Qm = "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", $m = "<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", eh = "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", th = "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", nh = "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", rh = /* #__PURE__ */ Object.assign({ "./creates/src/lib/server/whatsapp.ts": qm }), ih = /* #__PURE__ */ Object.assign({
|
|
6884
|
-
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
6885
|
-
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
6886
|
-
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
6887
|
-
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
6888
|
-
}),
|
|
6889
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
6890
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
6891
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
6892
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts":
|
|
6893
|
-
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
6886
|
+
generate: Um
|
|
6887
|
+
}, Gm = "/**\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", Km = "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", qm = "<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", Jm = "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", Ym = "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", Xm = "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", Zm = "<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", Qm = "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", $m = "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", eh = "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", th = /* #__PURE__ */ Object.assign({ "./creates/src/lib/server/whatsapp.ts": Gm }), nh = /* #__PURE__ */ Object.assign({
|
|
6888
|
+
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Km,
|
|
6889
|
+
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": qm,
|
|
6890
|
+
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Jm,
|
|
6891
|
+
"./creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Ym
|
|
6892
|
+
}), rh = /* #__PURE__ */ Object.assign({
|
|
6893
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Xm,
|
|
6894
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Zm,
|
|
6895
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Qm,
|
|
6896
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts": $m,
|
|
6897
|
+
"./creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": eh
|
|
6894
6898
|
});
|
|
6895
|
-
async function
|
|
6899
|
+
async function ih(e, t = "superforms") {
|
|
6896
6900
|
let n = {
|
|
6897
|
-
...
|
|
6898
|
-
...t === "remote" ?
|
|
6901
|
+
...w(th, "./creates/"),
|
|
6902
|
+
...t === "remote" ? w(rh, "./creates-remote/") : w(nh, "./creates-superforms/")
|
|
6899
6903
|
};
|
|
6900
6904
|
return {
|
|
6901
6905
|
creates: Object.values(n).sort((e, t) => e.path.localeCompare(t.path)),
|
|
@@ -6910,7 +6914,7 @@ async function oh(e, t = "superforms") {
|
|
|
6910
6914
|
}
|
|
6911
6915
|
//#endregion
|
|
6912
6916
|
//#region src/patterns/enable/whatsapp/generate.preview.ts
|
|
6913
|
-
var
|
|
6917
|
+
var ah = /* #__PURE__ */ Object.assign({
|
|
6914
6918
|
"./templates/base/src/lib/schemas/login.ts": vn,
|
|
6915
6919
|
"./templates/base/src/lib/schemas/signup.ts": Nt,
|
|
6916
6920
|
"./templates/base/src/routes/(public)/(auth)/login/+page.server.ts": tn,
|
|
@@ -6918,10 +6922,10 @@ var sh = /* #__PURE__ */ Object.assign({
|
|
|
6918
6922
|
"./templates/base/src/routes/(public)/(auth)/signup/+page.server.ts": hn,
|
|
6919
6923
|
"./templates/base/src/routes/(public)/(auth)/signup/+page.svelte": Mn
|
|
6920
6924
|
});
|
|
6921
|
-
async function
|
|
6925
|
+
async function oh(e) {
|
|
6922
6926
|
return {
|
|
6923
6927
|
creates: [],
|
|
6924
|
-
modifies: Object.values(
|
|
6928
|
+
modifies: Object.values(w(ah, "./templates/base/")).sort((e, t) => e.path.localeCompare(t.path)),
|
|
6925
6929
|
deletes: [],
|
|
6926
6930
|
components: [],
|
|
6927
6931
|
packages: [],
|
|
@@ -6932,24 +6936,24 @@ async function ch(e) {
|
|
|
6932
6936
|
}
|
|
6933
6937
|
//#endregion
|
|
6934
6938
|
//#region src/patterns/enable/whatsapp/index.ts
|
|
6935
|
-
var
|
|
6936
|
-
async function
|
|
6939
|
+
var sh = "enable-whatsapp", ch = "1.0.0", lh = "src/patterns/enable/whatsapp", uh = "/enable/whatsapp";
|
|
6940
|
+
async function dh(e) {
|
|
6937
6941
|
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.");
|
|
6938
6942
|
if (e.env === "preview") {
|
|
6939
|
-
let t = await
|
|
6940
|
-
return D(
|
|
6943
|
+
let t = await ih(e), n = await oh(e);
|
|
6944
|
+
return D(C([t, n]), e);
|
|
6941
6945
|
}
|
|
6942
|
-
let { detectMode: t } = await import("./chunks/auth-pages-jsyDV1GR.js"), { keepMissing: n } = await import("./chunks/modify-file-B4uJzOEj.js").then((e) => e.i), r = await
|
|
6943
|
-
return s(await D(
|
|
6946
|
+
let { detectMode: t } = await import("./chunks/auth-pages-jsyDV1GR.js"), { keepMissing: n } = await import("./chunks/modify-file-B4uJzOEj.js").then((e) => e.i), r = await ih(e, t(e.root)), { generate: i } = await import("./chunks/generate.runtime-BP31tAcD.js"), o = await i(e), { writeResult: s } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
6947
|
+
return s(await D(C([{
|
|
6944
6948
|
...r,
|
|
6945
6949
|
creates: n(r.creates, e.root)
|
|
6946
6950
|
}, o]), e), e);
|
|
6947
6951
|
}
|
|
6948
|
-
var
|
|
6949
|
-
version:
|
|
6950
|
-
slug:
|
|
6951
|
-
source:
|
|
6952
|
-
docs:
|
|
6952
|
+
var fh = {
|
|
6953
|
+
version: ch,
|
|
6954
|
+
slug: sh,
|
|
6955
|
+
source: lh,
|
|
6956
|
+
docs: uh,
|
|
6953
6957
|
plan: "open",
|
|
6954
6958
|
title: "Enable WhatsApp sign-in",
|
|
6955
6959
|
summary: "Adds sign-in and signup with a code sent on WhatsApp to the login and signup pages, next to email. Requires enable-auth.",
|
|
@@ -6984,22 +6988,22 @@ var mh = {
|
|
|
6984
6988
|
examples: [],
|
|
6985
6989
|
tests: 2,
|
|
6986
6990
|
baseline: "velastack",
|
|
6987
|
-
generate:
|
|
6988
|
-
},
|
|
6991
|
+
generate: dh
|
|
6992
|
+
}, ph = /* #__PURE__ */ Object.assign({
|
|
6989
6993
|
"./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",
|
|
6990
6994
|
"./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"
|
|
6991
|
-
}),
|
|
6995
|
+
}), mh = "./creates/", hh = [
|
|
6992
6996
|
"openworkflow@^0.10.0",
|
|
6993
6997
|
"openworkflow-pocketbase@^0.1.1",
|
|
6994
6998
|
"croner@^10.0.1"
|
|
6995
6999
|
];
|
|
6996
|
-
async function
|
|
7000
|
+
async function gh(e) {
|
|
6997
7001
|
return {
|
|
6998
|
-
creates: Object.entries(
|
|
6999
|
-
let n =
|
|
7002
|
+
creates: Object.entries(ph).map(([e, t]) => {
|
|
7003
|
+
let n = T(e, mh);
|
|
7000
7004
|
return {
|
|
7001
7005
|
path: n,
|
|
7002
|
-
language:
|
|
7006
|
+
language: S(n),
|
|
7003
7007
|
content: t,
|
|
7004
7008
|
status: "success"
|
|
7005
7009
|
};
|
|
@@ -7007,7 +7011,7 @@ async function vh(e) {
|
|
|
7007
7011
|
modifies: [],
|
|
7008
7012
|
deletes: [],
|
|
7009
7013
|
components: [],
|
|
7010
|
-
packages:
|
|
7014
|
+
packages: hh,
|
|
7011
7015
|
collections: [],
|
|
7012
7016
|
collectionPatches: [],
|
|
7013
7017
|
collectionDrops: []
|
|
@@ -7015,21 +7019,21 @@ async function vh(e) {
|
|
|
7015
7019
|
}
|
|
7016
7020
|
//#endregion
|
|
7017
7021
|
//#region src/patterns/enable/workflows/generate.preview.ts
|
|
7018
|
-
var
|
|
7019
|
-
async function
|
|
7022
|
+
var _h = /* #__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" }), vh = "./preview-modifies/";
|
|
7023
|
+
async function yh(e) {
|
|
7020
7024
|
return {
|
|
7021
7025
|
creates: [],
|
|
7022
|
-
modifies: Object.entries(
|
|
7023
|
-
let n =
|
|
7026
|
+
modifies: Object.entries(_h).map(([e, t]) => {
|
|
7027
|
+
let n = T(e, vh);
|
|
7024
7028
|
return {
|
|
7025
7029
|
path: n,
|
|
7026
|
-
language:
|
|
7030
|
+
language: S(n),
|
|
7027
7031
|
content: t,
|
|
7028
7032
|
status: "success"
|
|
7029
7033
|
};
|
|
7030
7034
|
}).concat({
|
|
7031
7035
|
path: "src/env.ts",
|
|
7032
|
-
language:
|
|
7036
|
+
language: S("src/env.ts"),
|
|
7033
7037
|
content: u(hr),
|
|
7034
7038
|
status: "success"
|
|
7035
7039
|
}).sort((e, t) => e.path.localeCompare(t.path)),
|
|
@@ -7043,21 +7047,21 @@ async function xh(e) {
|
|
|
7043
7047
|
}
|
|
7044
7048
|
//#endregion
|
|
7045
7049
|
//#region src/patterns/enable/workflows/index.ts
|
|
7046
|
-
var
|
|
7047
|
-
async function
|
|
7048
|
-
let t = await
|
|
7050
|
+
var bh = "enable-workflows", xh = "1.1.0", Sh = "src/patterns/enable/workflows", Ch = "/enable/workflows";
|
|
7051
|
+
async function wh(e) {
|
|
7052
|
+
let t = await gh(e);
|
|
7049
7053
|
if (e.env === "preview") {
|
|
7050
|
-
let n = await
|
|
7051
|
-
return D(
|
|
7054
|
+
let n = await yh(e);
|
|
7055
|
+
return D(C([t, n]), e);
|
|
7052
7056
|
}
|
|
7053
7057
|
let { generate: n } = await import("./chunks/generate.runtime-T7JLE4Wc.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7054
|
-
return i(await D(
|
|
7058
|
+
return i(await D(C([t, r]), e), e);
|
|
7055
7059
|
}
|
|
7056
|
-
var
|
|
7057
|
-
version:
|
|
7058
|
-
slug:
|
|
7059
|
-
source:
|
|
7060
|
-
docs:
|
|
7060
|
+
var Th = {
|
|
7061
|
+
version: xh,
|
|
7062
|
+
slug: bh,
|
|
7063
|
+
source: Sh,
|
|
7064
|
+
docs: Ch,
|
|
7061
7065
|
plan: "open",
|
|
7062
7066
|
title: "Enable workflows",
|
|
7063
7067
|
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.",
|
|
@@ -7091,11 +7095,11 @@ var Dh = {
|
|
|
7091
7095
|
examples: [],
|
|
7092
7096
|
tests: 0,
|
|
7093
7097
|
baseline: "velastack",
|
|
7094
|
-
generate:
|
|
7098
|
+
generate: wh
|
|
7095
7099
|
};
|
|
7096
7100
|
//#endregion
|
|
7097
7101
|
//#region src/patterns/destroy/schema/generate.ts
|
|
7098
|
-
async function
|
|
7102
|
+
async function Eh(e) {
|
|
7099
7103
|
let [t] = e.argv;
|
|
7100
7104
|
if (!t) throw new a("Invalid command arguments. Expected: <model>");
|
|
7101
7105
|
let n = `src/lib/schemas/${B(t).name}.ts`;
|
|
@@ -7104,7 +7108,7 @@ async function Oh(e) {
|
|
|
7104
7108
|
modifies: [],
|
|
7105
7109
|
deletes: [{
|
|
7106
7110
|
path: n,
|
|
7107
|
-
language:
|
|
7111
|
+
language: S(n),
|
|
7108
7112
|
content: "",
|
|
7109
7113
|
status: "success"
|
|
7110
7114
|
}],
|
|
@@ -7117,18 +7121,18 @@ async function Oh(e) {
|
|
|
7117
7121
|
}
|
|
7118
7122
|
//#endregion
|
|
7119
7123
|
//#region src/patterns/destroy/schema/index.ts
|
|
7120
|
-
var
|
|
7121
|
-
async function
|
|
7122
|
-
let t = await
|
|
7124
|
+
var Dh = "destroy-schema", Oh = "1.0.0", kh = "src/patterns/destroy/schema", Ah = "/destroy/schema";
|
|
7125
|
+
async function jh(e) {
|
|
7126
|
+
let t = await Eh(e), n = await D(t, e);
|
|
7123
7127
|
if (e.env !== "runtime" || e.input.destructive !== !0) return n;
|
|
7124
7128
|
let { writeResult: r } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7125
7129
|
return r(n, e);
|
|
7126
7130
|
}
|
|
7127
|
-
var
|
|
7128
|
-
version:
|
|
7129
|
-
slug:
|
|
7130
|
-
source:
|
|
7131
|
-
docs:
|
|
7131
|
+
var Mh = {
|
|
7132
|
+
version: Oh,
|
|
7133
|
+
slug: Dh,
|
|
7134
|
+
source: kh,
|
|
7135
|
+
docs: Ah,
|
|
7132
7136
|
plan: "open",
|
|
7133
7137
|
title: "Destroy a schema",
|
|
7134
7138
|
summary: "Removes the zod schema file created by generate-schema.",
|
|
@@ -7161,9 +7165,9 @@ var Ph = {
|
|
|
7161
7165
|
}],
|
|
7162
7166
|
tests: 0,
|
|
7163
7167
|
baseline: "velastack",
|
|
7164
|
-
generate:
|
|
7165
|
-
},
|
|
7166
|
-
async function
|
|
7168
|
+
generate: jh
|
|
7169
|
+
}, Nh = "destroy-form", Ph = "1.0.0", Fh = "src/patterns/destroy/form", Ih = "/destroy/form";
|
|
7170
|
+
async function Lh(e) {
|
|
7167
7171
|
let [t] = e.argv;
|
|
7168
7172
|
if (!t) throw new a("Invalid command arguments. Expected: <model>");
|
|
7169
7173
|
let n = B(t), r = k(e.input.route, n, e, "form").fileBase, i = `src/lib/schemas/${n.name}.ts`, o = {
|
|
@@ -7180,11 +7184,11 @@ async function zh(e) {
|
|
|
7180
7184
|
let { writeResult: c } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7181
7185
|
return c(s, e);
|
|
7182
7186
|
}
|
|
7183
|
-
var
|
|
7184
|
-
version:
|
|
7185
|
-
slug:
|
|
7186
|
-
source:
|
|
7187
|
-
docs:
|
|
7187
|
+
var Rh = {
|
|
7188
|
+
version: Ph,
|
|
7189
|
+
slug: Nh,
|
|
7190
|
+
source: Fh,
|
|
7191
|
+
docs: Ih,
|
|
7188
7192
|
plan: "open",
|
|
7189
7193
|
title: "Destroy a form",
|
|
7190
7194
|
summary: "Removes the route directory and schema file created by generate-form.",
|
|
@@ -7220,9 +7224,9 @@ var Bh = {
|
|
|
7220
7224
|
}],
|
|
7221
7225
|
tests: 0,
|
|
7222
7226
|
baseline: "velastack",
|
|
7223
|
-
generate:
|
|
7224
|
-
},
|
|
7225
|
-
async function
|
|
7227
|
+
generate: Lh
|
|
7228
|
+
}, zh = "destroy-resource", Bh = "1.0.0", Vh = "src/patterns/destroy/resource", Hh = "/destroy/resource";
|
|
7229
|
+
async function Uh(e) {
|
|
7226
7230
|
let [t] = e.argv;
|
|
7227
7231
|
if (!t) throw new a("Invalid command arguments. Expected: <model>");
|
|
7228
7232
|
let n = B(t), r = `src/lib/schemas/${n.name}.ts`, i = await gr([n.tableName], e), o = {
|
|
@@ -7239,11 +7243,11 @@ async function Gh(e) {
|
|
|
7239
7243
|
let { writeResult: c } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7240
7244
|
return c(s, e);
|
|
7241
7245
|
}
|
|
7242
|
-
var
|
|
7243
|
-
version:
|
|
7244
|
-
slug:
|
|
7245
|
-
source:
|
|
7246
|
-
docs:
|
|
7246
|
+
var Wh = {
|
|
7247
|
+
version: Bh,
|
|
7248
|
+
slug: zh,
|
|
7249
|
+
source: Vh,
|
|
7250
|
+
docs: Hh,
|
|
7247
7251
|
plan: "open",
|
|
7248
7252
|
title: "Destroy a resource",
|
|
7249
7253
|
summary: "Drops the collection and removes the schema file created by generate-resource.",
|
|
@@ -7276,9 +7280,9 @@ var Kh = {
|
|
|
7276
7280
|
}],
|
|
7277
7281
|
tests: 0,
|
|
7278
7282
|
baseline: "velastack",
|
|
7279
|
-
generate:
|
|
7280
|
-
},
|
|
7281
|
-
async function
|
|
7283
|
+
generate: Uh
|
|
7284
|
+
}, Gh = "destroy-scaffold", Kh = "1.0.0", qh = "src/patterns/destroy/scaffold", Jh = "/destroy/scaffold";
|
|
7285
|
+
async function Yh(e) {
|
|
7282
7286
|
let [t] = e.argv;
|
|
7283
7287
|
if (!t) throw new a("Invalid command arguments. Expected: <model>");
|
|
7284
7288
|
let n = B(t), r = k(e.input.route, n, e, "scaffold"), i = xe(r), o = `src/lib/schemas/${n.name}.ts`, s = await gr([n.tableName], e), c = {
|
|
@@ -7295,11 +7299,11 @@ async function Zh(e) {
|
|
|
7295
7299
|
let { writeResult: u } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7296
7300
|
return u(l, e);
|
|
7297
7301
|
}
|
|
7298
|
-
var
|
|
7299
|
-
version:
|
|
7300
|
-
slug:
|
|
7301
|
-
source:
|
|
7302
|
-
docs:
|
|
7302
|
+
var Xh = {
|
|
7303
|
+
version: Kh,
|
|
7304
|
+
slug: Gh,
|
|
7305
|
+
source: qh,
|
|
7306
|
+
docs: Jh,
|
|
7303
7307
|
plan: "open",
|
|
7304
7308
|
title: "Destroy a scaffold",
|
|
7305
7309
|
summary: "Removes the route directory and schema file created by generate-scaffold and drops the collection. Retains shadcn components.",
|
|
@@ -7336,8 +7340,8 @@ var Qh = {
|
|
|
7336
7340
|
}],
|
|
7337
7341
|
tests: 0,
|
|
7338
7342
|
baseline: "velastack",
|
|
7339
|
-
generate:
|
|
7340
|
-
},
|
|
7343
|
+
generate: Yh
|
|
7344
|
+
}, Zh = "destroy-shop", Qh = "1.0.0", $h = "src/patterns/destroy/shop", eg = "/destroy/shop", tg = /* #__PURE__ */ Object.assign({
|
|
7341
7345
|
"../../generate/shop/providers/shopify/src/routes/(public)/shop/+page.svelte": $s,
|
|
7342
7346
|
"../../generate/shop/providers/shopify/src/routes/(public)/shop/+page.ts": ec,
|
|
7343
7347
|
"../../generate/shop/providers/shopify/src/routes/(public)/shop/[handle]/+page.svelte": tc,
|
|
@@ -7353,12 +7357,12 @@ var Qh = {
|
|
|
7353
7357
|
"../../generate/shop/providers-cms/whatsapp/src/routes/(public)/shop/+page.svelte": dc,
|
|
7354
7358
|
"../../generate/shop/providers-cms/whatsapp/src/routes/(public)/shop/[id]/+page.svelte": fc,
|
|
7355
7359
|
"../../generate/shop/providers-cms/whatsapp/src/routes/(public)/shop/[id]/+page.ts": pc
|
|
7356
|
-
}),
|
|
7357
|
-
async function
|
|
7360
|
+
}), ng = pe(tg);
|
|
7361
|
+
async function rg(e) {
|
|
7358
7362
|
let t = e.providers?.payments, n = {
|
|
7359
7363
|
creates: [],
|
|
7360
7364
|
modifies: [],
|
|
7361
|
-
deletes: (t ? pe(
|
|
7365
|
+
deletes: (t ? pe(tg, t) : ng).map(N),
|
|
7362
7366
|
components: [],
|
|
7363
7367
|
packages: [],
|
|
7364
7368
|
collections: [],
|
|
@@ -7369,11 +7373,11 @@ async function ag(e) {
|
|
|
7369
7373
|
let { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7370
7374
|
return i(r, e);
|
|
7371
7375
|
}
|
|
7372
|
-
var
|
|
7373
|
-
version:
|
|
7374
|
-
slug:
|
|
7375
|
-
source:
|
|
7376
|
-
docs:
|
|
7376
|
+
var ig = {
|
|
7377
|
+
version: Qh,
|
|
7378
|
+
slug: Zh,
|
|
7379
|
+
source: $h,
|
|
7380
|
+
docs: eg,
|
|
7377
7381
|
plan: "pro",
|
|
7378
7382
|
title: "Destroy a shop",
|
|
7379
7383
|
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.",
|
|
@@ -7404,21 +7408,21 @@ var og = {
|
|
|
7404
7408
|
examples: [],
|
|
7405
7409
|
tests: 0,
|
|
7406
7410
|
baseline: "velastack",
|
|
7407
|
-
generate:
|
|
7408
|
-
},
|
|
7409
|
-
async function
|
|
7411
|
+
generate: rg
|
|
7412
|
+
}, ag = "disable-ai", og = "1.1.0", sg = "src/patterns/disable/ai", cg = "/disable/ai";
|
|
7413
|
+
async function lg(e) {
|
|
7410
7414
|
let t = await _r(e);
|
|
7411
7415
|
if (e.env !== "runtime") return D(t, e);
|
|
7412
|
-
let { generate: n } = await import("./chunks/generate.runtime-oUJUQRdg.js"), r = await n(e), i = await D(
|
|
7416
|
+
let { generate: n } = await import("./chunks/generate.runtime-oUJUQRdg.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
7413
7417
|
if (e.input.destructive !== !0) return i;
|
|
7414
7418
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7415
7419
|
return a(i, e);
|
|
7416
7420
|
}
|
|
7417
|
-
var
|
|
7418
|
-
version:
|
|
7419
|
-
slug:
|
|
7420
|
-
source:
|
|
7421
|
-
docs:
|
|
7421
|
+
var ug = {
|
|
7422
|
+
version: og,
|
|
7423
|
+
slug: ag,
|
|
7424
|
+
source: sg,
|
|
7425
|
+
docs: cg,
|
|
7422
7426
|
plan: "open",
|
|
7423
7427
|
title: "Disable AI",
|
|
7424
7428
|
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.",
|
|
@@ -7453,21 +7457,21 @@ var fg = {
|
|
|
7453
7457
|
examples: [],
|
|
7454
7458
|
tests: 0,
|
|
7455
7459
|
baseline: "velastack",
|
|
7456
|
-
generate:
|
|
7457
|
-
},
|
|
7458
|
-
async function
|
|
7460
|
+
generate: lg
|
|
7461
|
+
}, dg = "disable-analytics", fg = "1.1.0", pg = "src/patterns/disable/analytics", mg = "/disable/analytics";
|
|
7462
|
+
async function hg(e) {
|
|
7459
7463
|
let t = await vr(e);
|
|
7460
7464
|
if (e.env !== "runtime") return D(t, e);
|
|
7461
|
-
let { generate: n } = await import("./chunks/generate.runtime-CVWCUn52.js"), r = await n(e), i = await D(
|
|
7465
|
+
let { generate: n } = await import("./chunks/generate.runtime-CVWCUn52.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
7462
7466
|
if (e.input.destructive !== !0) return i;
|
|
7463
7467
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7464
7468
|
return a(i, e);
|
|
7465
7469
|
}
|
|
7466
|
-
var
|
|
7467
|
-
version:
|
|
7468
|
-
slug:
|
|
7469
|
-
source:
|
|
7470
|
-
docs:
|
|
7470
|
+
var gg = {
|
|
7471
|
+
version: fg,
|
|
7472
|
+
slug: dg,
|
|
7473
|
+
source: pg,
|
|
7474
|
+
docs: mg,
|
|
7471
7475
|
plan: "open",
|
|
7472
7476
|
title: "Disable analytics",
|
|
7473
7477
|
summary: "Removes the analytics component and <Analytics /> from the root layout, strips the provider's variables from .env and uninstalls posthog-js.",
|
|
@@ -7500,17 +7504,17 @@ var vg = {
|
|
|
7500
7504
|
examples: [],
|
|
7501
7505
|
tests: 0,
|
|
7502
7506
|
baseline: "velastack",
|
|
7503
|
-
generate:
|
|
7504
|
-
},
|
|
7505
|
-
async function
|
|
7507
|
+
generate: hg
|
|
7508
|
+
}, _g = /* #__PURE__ */ Object.assign({ "../../enable/api/creates/src/routes/api/server.test.ts": kl }), vg = "../../enable/api/creates/";
|
|
7509
|
+
async function yg(e) {
|
|
7506
7510
|
return {
|
|
7507
7511
|
creates: [],
|
|
7508
7512
|
modifies: [],
|
|
7509
|
-
deletes: Object.keys(
|
|
7510
|
-
let t =
|
|
7513
|
+
deletes: Object.keys(_g).map((e) => {
|
|
7514
|
+
let t = T(e, vg);
|
|
7511
7515
|
return {
|
|
7512
7516
|
path: t,
|
|
7513
|
-
language:
|
|
7517
|
+
language: S(t),
|
|
7514
7518
|
content: "",
|
|
7515
7519
|
status: "success"
|
|
7516
7520
|
};
|
|
@@ -7524,20 +7528,20 @@ async function xg(e) {
|
|
|
7524
7528
|
}
|
|
7525
7529
|
//#endregion
|
|
7526
7530
|
//#region src/patterns/disable/api/index.ts
|
|
7527
|
-
var
|
|
7528
|
-
async function
|
|
7529
|
-
let t = await
|
|
7531
|
+
var bg = "disable-api", xg = "1.0.0", Sg = "src/patterns/disable/api", Cg = "/disable/api";
|
|
7532
|
+
async function wg(e) {
|
|
7533
|
+
let t = await yg(e);
|
|
7530
7534
|
if (e.env !== "runtime") return D(t, e);
|
|
7531
|
-
let { generate: n } = await import("./chunks/generate.runtime-zr6uIHCd.js"), r = await n(e), i = await D(
|
|
7535
|
+
let { generate: n } = await import("./chunks/generate.runtime-zr6uIHCd.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
7532
7536
|
if (e.input.destructive !== !0) return i;
|
|
7533
7537
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7534
7538
|
return a(i, e);
|
|
7535
7539
|
}
|
|
7536
|
-
var
|
|
7537
|
-
version:
|
|
7538
|
-
slug:
|
|
7539
|
-
source:
|
|
7540
|
-
docs:
|
|
7540
|
+
var Tg = {
|
|
7541
|
+
version: xg,
|
|
7542
|
+
slug: bg,
|
|
7543
|
+
source: Sg,
|
|
7544
|
+
docs: Cg,
|
|
7541
7545
|
plan: "open",
|
|
7542
7546
|
title: "Disable API",
|
|
7543
7547
|
summary: "Disables the PocketBase API handler.",
|
|
@@ -7570,8 +7574,8 @@ var Dg = {
|
|
|
7570
7574
|
examples: [],
|
|
7571
7575
|
tests: 0,
|
|
7572
7576
|
baseline: "velastack",
|
|
7573
|
-
generate:
|
|
7574
|
-
},
|
|
7577
|
+
generate: wg
|
|
7578
|
+
}, Eg = /* #__PURE__ */ Object.assign({
|
|
7575
7579
|
"../../enable/api-keys/creates/src/lib/schemas/apiKey.ts": Hl,
|
|
7576
7580
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.server.ts": Ul,
|
|
7577
7581
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/+layout.svelte": Wl,
|
|
@@ -7584,16 +7588,16 @@ var Dg = {
|
|
|
7584
7588
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/create-api-key.ts": Xl,
|
|
7585
7589
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/new/server.test.ts": Zl,
|
|
7586
7590
|
"../../enable/api-keys/creates/src/routes/(app)/api-keys/server.test.ts": Ql
|
|
7587
|
-
}),
|
|
7588
|
-
async function
|
|
7591
|
+
}), Dg = "../../enable/api-keys/creates/";
|
|
7592
|
+
async function Og(e) {
|
|
7589
7593
|
return {
|
|
7590
7594
|
creates: [],
|
|
7591
7595
|
modifies: [],
|
|
7592
|
-
deletes: Object.keys(
|
|
7593
|
-
let t =
|
|
7596
|
+
deletes: Object.keys(Eg).map((e) => {
|
|
7597
|
+
let t = T(e, Dg);
|
|
7594
7598
|
return {
|
|
7595
7599
|
path: t,
|
|
7596
|
-
language:
|
|
7600
|
+
language: S(t),
|
|
7597
7601
|
content: "",
|
|
7598
7602
|
status: "success"
|
|
7599
7603
|
};
|
|
@@ -7607,20 +7611,20 @@ async function Ag(e) {
|
|
|
7607
7611
|
}
|
|
7608
7612
|
//#endregion
|
|
7609
7613
|
//#region src/patterns/disable/api-keys/index.ts
|
|
7610
|
-
var
|
|
7611
|
-
async function
|
|
7612
|
-
let t = await
|
|
7614
|
+
var kg = "disable-api-keys", Ag = "1.0.1", jg = "src/patterns/disable/api-keys", Mg = "/disable/api-keys";
|
|
7615
|
+
async function Ng(e) {
|
|
7616
|
+
let t = await Og(e);
|
|
7613
7617
|
if (e.env !== "runtime") return D(t, e);
|
|
7614
|
-
let { generate: n } = await import("./chunks/generate.runtime-BqCbJ-No.js"), r = await n(e), i = await D(
|
|
7618
|
+
let { generate: n } = await import("./chunks/generate.runtime-BqCbJ-No.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
7615
7619
|
if (e.input.destructive !== !0) return i;
|
|
7616
7620
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7617
7621
|
return a(i, e);
|
|
7618
7622
|
}
|
|
7619
|
-
var
|
|
7620
|
-
version:
|
|
7621
|
-
slug:
|
|
7622
|
-
source:
|
|
7623
|
-
docs:
|
|
7623
|
+
var Pg = {
|
|
7624
|
+
version: Ag,
|
|
7625
|
+
slug: kg,
|
|
7626
|
+
source: jg,
|
|
7627
|
+
docs: Mg,
|
|
7624
7628
|
plan: "open",
|
|
7625
7629
|
title: "Disable API keys",
|
|
7626
7630
|
summary: "Removes API key management: drops the api_keys collection, reverts hooks.server and nav-user, deletes generated API key routes.",
|
|
@@ -7653,8 +7657,8 @@ var Ig = {
|
|
|
7653
7657
|
examples: [],
|
|
7654
7658
|
tests: 0,
|
|
7655
7659
|
baseline: "velastack",
|
|
7656
|
-
generate:
|
|
7657
|
-
},
|
|
7660
|
+
generate: Ng
|
|
7661
|
+
}, Fg = /* #__PURE__ */ Object.assign({
|
|
7658
7662
|
"../../enable/auth/creates/src/lib/components/app-sidebar.svelte": Kn,
|
|
7659
7663
|
"../../enable/auth/creates/src/lib/components/nav-main.svelte": zn,
|
|
7660
7664
|
"../../enable/auth/creates/src/lib/components/nav-user.svelte": jt,
|
|
@@ -7711,7 +7715,7 @@ var Ig = {
|
|
|
7711
7715
|
"../../enable/auth/creates/src/routes/(public)/(auth)/welcome/+page.svelte": Wn,
|
|
7712
7716
|
"../../enable/auth/creates/src/routes/(public)/(auth)/welcome/+page.ts": Lt,
|
|
7713
7717
|
"../../enable/auth/creates/src/routes/(public)/(auth)/welcome/server.test.ts": qn
|
|
7714
|
-
}),
|
|
7718
|
+
}), Ig = /* #__PURE__ */ Object.assign({
|
|
7715
7719
|
"../../enable/auth-remote/creates/src/lib/components/app-sidebar.svelte": Zt,
|
|
7716
7720
|
"../../enable/auth-remote/creates/src/lib/components/nav-main.svelte": en,
|
|
7717
7721
|
"../../enable/auth-remote/creates/src/lib/components/nav-user.svelte": mn,
|
|
@@ -7777,29 +7781,29 @@ var Ig = {
|
|
|
7777
7781
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/welcome/form.remote.ts": ln,
|
|
7778
7782
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/welcome/next-url.ts": Rt,
|
|
7779
7783
|
"../../enable/auth-remote/creates/src/routes/(public)/(auth)/welcome/server.test.ts": kn
|
|
7780
|
-
}),
|
|
7781
|
-
"../../enable/whatsapp/creates/src/lib/server/whatsapp.ts":
|
|
7782
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
7783
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
7784
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
7785
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts":
|
|
7786
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
7787
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
7788
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
7789
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
7790
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
7791
|
-
}),
|
|
7792
|
-
async function
|
|
7784
|
+
}), Lg = /* #__PURE__ */ Object.assign({
|
|
7785
|
+
"../../enable/whatsapp/creates/src/lib/server/whatsapp.ts": Gm,
|
|
7786
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Xm,
|
|
7787
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Zm,
|
|
7788
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Qm,
|
|
7789
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts": $m,
|
|
7790
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": eh,
|
|
7791
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Km,
|
|
7792
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": qm,
|
|
7793
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Jm,
|
|
7794
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Ym
|
|
7795
|
+
}), Rg = "../../enable/auth/creates/", zg = "../../enable/auth-remote/creates/", Bg = /^\.\.\/\.\.\/enable\/whatsapp\/creates(-superforms|-remote)?\//;
|
|
7796
|
+
async function Vg(e) {
|
|
7793
7797
|
let t = /* @__PURE__ */ new Set();
|
|
7794
|
-
for (let e of Object.keys(
|
|
7795
|
-
for (let e of Object.keys(
|
|
7796
|
-
for (let e of Object.keys(
|
|
7798
|
+
for (let e of Object.keys(Fg)) t.add(T(e, Rg));
|
|
7799
|
+
for (let e of Object.keys(Ig)) t.add(T(e, zg));
|
|
7800
|
+
for (let e of Object.keys(Lg)) t.add(e.replace(Bg, ""));
|
|
7797
7801
|
return {
|
|
7798
7802
|
creates: [],
|
|
7799
7803
|
modifies: [],
|
|
7800
7804
|
deletes: Array.from(t).map((e) => ({
|
|
7801
7805
|
path: e,
|
|
7802
|
-
language:
|
|
7806
|
+
language: S(e),
|
|
7803
7807
|
content: "",
|
|
7804
7808
|
status: "success"
|
|
7805
7809
|
})).sort((e, t) => e.path.localeCompare(t.path)),
|
|
@@ -7812,20 +7816,20 @@ async function Ug(e) {
|
|
|
7812
7816
|
}
|
|
7813
7817
|
//#endregion
|
|
7814
7818
|
//#region src/patterns/disable/auth/index.ts
|
|
7815
|
-
var
|
|
7816
|
-
async function
|
|
7817
|
-
let t = await
|
|
7819
|
+
var Hg = "disable-auth", Ug = "1.1.1", Wg = "src/patterns/disable/auth", Gg = "/disable/auth";
|
|
7820
|
+
async function Kg(e) {
|
|
7821
|
+
let t = await Vg(e);
|
|
7818
7822
|
if (e.env !== "runtime") return D(t, e);
|
|
7819
|
-
let { generate: n } = await import("./chunks/generate.runtime-ByPcr9vJ.js"), r = await n(e), i = await D(
|
|
7823
|
+
let { generate: n } = await import("./chunks/generate.runtime-ByPcr9vJ.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
7820
7824
|
if (e.input.destructive !== !0) return i;
|
|
7821
7825
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7822
7826
|
return a(i, e);
|
|
7823
7827
|
}
|
|
7824
|
-
var
|
|
7825
|
-
version:
|
|
7826
|
-
slug:
|
|
7827
|
-
source:
|
|
7828
|
-
docs:
|
|
7828
|
+
var qg = {
|
|
7829
|
+
version: Ug,
|
|
7830
|
+
slug: Hg,
|
|
7831
|
+
source: Wg,
|
|
7832
|
+
docs: Gg,
|
|
7829
7833
|
plan: "open",
|
|
7830
7834
|
title: "Disable auth",
|
|
7831
7835
|
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.",
|
|
@@ -7856,38 +7860,38 @@ var Yg = {
|
|
|
7856
7860
|
examples: [],
|
|
7857
7861
|
tests: 0,
|
|
7858
7862
|
baseline: "velastack-auth",
|
|
7859
|
-
generate:
|
|
7860
|
-
},
|
|
7863
|
+
generate: Kg
|
|
7864
|
+
}, Jg = /* #__PURE__ */ Object.assign({
|
|
7861
7865
|
"../../enable/backend/creates/data/fixtures/README.md": fu,
|
|
7862
7866
|
"../../enable/backend/creates/data/hooks/README.md": pu,
|
|
7863
7867
|
"../../enable/backend/creates/data/seeds/README.md": mu,
|
|
7864
7868
|
"../../enable/backend/creates/src/hooks.server.ts": hu
|
|
7865
|
-
}),
|
|
7866
|
-
function
|
|
7869
|
+
}), Yg = "../../enable/backend/creates/", Xg = ["src/lib/server/workflows.ts", "src/lib/workflows"];
|
|
7870
|
+
function Zg(e) {
|
|
7867
7871
|
let t = e.lastIndexOf("@");
|
|
7868
7872
|
return t > 0 ? e.slice(0, t) : e;
|
|
7869
7873
|
}
|
|
7870
|
-
async function
|
|
7874
|
+
async function Qg(e) {
|
|
7871
7875
|
return {
|
|
7872
7876
|
creates: [],
|
|
7873
7877
|
modifies: [],
|
|
7874
|
-
deletes: Object.keys(
|
|
7875
|
-
let t =
|
|
7878
|
+
deletes: Object.keys(Jg).map((e) => {
|
|
7879
|
+
let t = T(e, Yg);
|
|
7876
7880
|
return {
|
|
7877
7881
|
path: t,
|
|
7878
|
-
language:
|
|
7882
|
+
language: S(t),
|
|
7879
7883
|
content: "",
|
|
7880
7884
|
status: "success"
|
|
7881
7885
|
};
|
|
7882
|
-
}).concat(["data", ...
|
|
7886
|
+
}).concat(["data", ...Xg].map((e) => ({
|
|
7883
7887
|
path: e,
|
|
7884
|
-
language:
|
|
7888
|
+
language: S(e),
|
|
7885
7889
|
content: "",
|
|
7886
7890
|
status: "success"
|
|
7887
7891
|
}))).sort((e, t) => e.path.localeCompare(t.path)),
|
|
7888
7892
|
components: [],
|
|
7889
|
-
packages: [
|
|
7890
|
-
uninstalls:
|
|
7893
|
+
packages: [ee],
|
|
7894
|
+
uninstalls: hh.map(Zg),
|
|
7891
7895
|
collections: [],
|
|
7892
7896
|
collectionPatches: [],
|
|
7893
7897
|
collectionDrops: []
|
|
@@ -7895,11 +7899,11 @@ async function e_(e) {
|
|
|
7895
7899
|
}
|
|
7896
7900
|
//#endregion
|
|
7897
7901
|
//#region src/patterns/disable/backend/index.ts
|
|
7898
|
-
var
|
|
7899
|
-
async function
|
|
7900
|
-
let t = await
|
|
7902
|
+
var $g = "disable-backend", e_ = "1.1.0", t_ = "src/patterns/disable/backend", n_ = "/disable/backend";
|
|
7903
|
+
async function r_(e) {
|
|
7904
|
+
let t = await Qg(e);
|
|
7901
7905
|
if (e.env !== "runtime") return D(t, e);
|
|
7902
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
7906
|
+
let { generate: n } = await import("./chunks/generate.runtime-BDbotRNZ.js"), r = await n(e), i = await D(C([{
|
|
7903
7907
|
...t,
|
|
7904
7908
|
deletes: t.deletes.filter((e) => e.path !== "src/hooks.server.ts")
|
|
7905
7909
|
}, r]), e);
|
|
@@ -7907,11 +7911,11 @@ async function a_(e) {
|
|
|
7907
7911
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7908
7912
|
return a(i, e);
|
|
7909
7913
|
}
|
|
7910
|
-
var
|
|
7911
|
-
version:
|
|
7912
|
-
slug:
|
|
7913
|
-
source:
|
|
7914
|
-
docs:
|
|
7914
|
+
var i_ = {
|
|
7915
|
+
version: e_,
|
|
7916
|
+
slug: $g,
|
|
7917
|
+
source: t_,
|
|
7918
|
+
docs: n_,
|
|
7915
7919
|
plan: "open",
|
|
7916
7920
|
title: "Disable Backend",
|
|
7917
7921
|
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.",
|
|
@@ -7942,21 +7946,21 @@ var o_ = {
|
|
|
7942
7946
|
examples: [],
|
|
7943
7947
|
tests: 0,
|
|
7944
7948
|
baseline: "velastack",
|
|
7945
|
-
generate:
|
|
7946
|
-
},
|
|
7949
|
+
generate: r_
|
|
7950
|
+
}, a_ = /* #__PURE__ */ Object.assign({
|
|
7947
7951
|
"../../enable/content-negotiation/creates/src/lib/negotiate.ts": bd,
|
|
7948
7952
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.server.ts": xd,
|
|
7949
7953
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.svelte": Sd,
|
|
7950
7954
|
"../../enable/content-negotiation/creates/src/routes/(public)/negotiate/+page.ts": Cd
|
|
7951
|
-
}),
|
|
7952
|
-
async function
|
|
7953
|
-
let t = [...Object.keys(
|
|
7955
|
+
}), o_ = /* #__PURE__ */ Object.assign({ "../../enable/content-negotiation/creates-with-blog/src/routes/(public)/blog/[slug]/+page.server.ts": wd }), s_ = "../../enable/content-negotiation/creates/", c_ = "../../enable/content-negotiation/creates-with-blog/";
|
|
7956
|
+
async function l_(e) {
|
|
7957
|
+
let t = [...Object.keys(a_).map((e) => T(e, s_)), ...Object.keys(o_).map((e) => T(e, c_))];
|
|
7954
7958
|
return {
|
|
7955
7959
|
creates: [],
|
|
7956
7960
|
modifies: [],
|
|
7957
7961
|
deletes: [...new Set(t)].map((t) => Ad(t, e)).map((e) => ({
|
|
7958
7962
|
path: e,
|
|
7959
|
-
language:
|
|
7963
|
+
language: S(e),
|
|
7960
7964
|
content: "",
|
|
7961
7965
|
status: "success"
|
|
7962
7966
|
})).sort((e, t) => e.path.localeCompare(t.path)),
|
|
@@ -7970,20 +7974,20 @@ async function d_(e) {
|
|
|
7970
7974
|
}
|
|
7971
7975
|
//#endregion
|
|
7972
7976
|
//#region src/patterns/disable/content-negotiation/index.ts
|
|
7973
|
-
var
|
|
7974
|
-
async function
|
|
7975
|
-
let t = await
|
|
7977
|
+
var u_ = "disable-content-negotiation", d_ = "1.1.0", f_ = "src/patterns/disable/content-negotiation", p_ = "/disable/content-negotiation";
|
|
7978
|
+
async function m_(e) {
|
|
7979
|
+
let t = await l_(e);
|
|
7976
7980
|
if (e.env !== "runtime") return D(t, e);
|
|
7977
|
-
let { generate: n } = await import("./chunks/generate.runtime-Cv3unKap.js"), r = await n(e), i = await D(
|
|
7981
|
+
let { generate: n } = await import("./chunks/generate.runtime-Cv3unKap.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
7978
7982
|
if (e.input.destructive !== !0) return i;
|
|
7979
7983
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
7980
7984
|
return a(i, e);
|
|
7981
7985
|
}
|
|
7982
|
-
var
|
|
7983
|
-
version:
|
|
7984
|
-
slug:
|
|
7985
|
-
source:
|
|
7986
|
-
docs:
|
|
7986
|
+
var h_ = {
|
|
7987
|
+
version: d_,
|
|
7988
|
+
slug: u_,
|
|
7989
|
+
source: f_,
|
|
7990
|
+
docs: p_,
|
|
7987
7991
|
plan: "open",
|
|
7988
7992
|
title: "Disable content negotiation",
|
|
7989
7993
|
summary: "Removes sveltekit-negotiate wiring: deletes creates, unwraps hooks.server handle, reverts reroute (preserving i18n compose), removes <Negotiate /> from the root layout.",
|
|
@@ -8015,21 +8019,21 @@ var __ = {
|
|
|
8015
8019
|
examples: [],
|
|
8016
8020
|
tests: 0,
|
|
8017
8021
|
baseline: "velastack",
|
|
8018
|
-
generate:
|
|
8019
|
-
},
|
|
8022
|
+
generate: m_
|
|
8023
|
+
}, g_ = /* #__PURE__ */ Object.assign({
|
|
8020
8024
|
"../../enable/i18n/creates/src/lib/components/language-select.svelte": Ud,
|
|
8021
8025
|
"../../enable/i18n/creates/src/lib/url.ts": Wd,
|
|
8022
8026
|
"../../enable/i18n/creates/wuchale.config.js": Gd
|
|
8023
|
-
}),
|
|
8024
|
-
async function
|
|
8027
|
+
}), __ = "../../enable/i18n/creates/";
|
|
8028
|
+
async function v_(e) {
|
|
8025
8029
|
return {
|
|
8026
8030
|
creates: [],
|
|
8027
8031
|
modifies: [],
|
|
8028
|
-
deletes: Object.keys(
|
|
8029
|
-
let t =
|
|
8032
|
+
deletes: Object.keys(g_).map((e) => {
|
|
8033
|
+
let t = T(e, __);
|
|
8030
8034
|
return {
|
|
8031
8035
|
path: t,
|
|
8032
|
-
language:
|
|
8036
|
+
language: S(t),
|
|
8033
8037
|
content: "",
|
|
8034
8038
|
status: "success"
|
|
8035
8039
|
};
|
|
@@ -8044,20 +8048,20 @@ async function b_(e) {
|
|
|
8044
8048
|
}
|
|
8045
8049
|
//#endregion
|
|
8046
8050
|
//#region src/patterns/disable/i18n/index.ts
|
|
8047
|
-
var
|
|
8048
|
-
async function
|
|
8049
|
-
let t = await
|
|
8051
|
+
var y_ = "disable-i18n", b_ = "1.1.0", x_ = "src/patterns/disable/i18n", S_ = "/disable/i18n";
|
|
8052
|
+
async function C_(e) {
|
|
8053
|
+
let t = await v_(e);
|
|
8050
8054
|
if (e.env !== "runtime") return D(t, e);
|
|
8051
|
-
let { generate: n } = await import("./chunks/generate.runtime-B84ymwlD.js"), r = await n(e), i = await D(
|
|
8055
|
+
let { generate: n } = await import("./chunks/generate.runtime-B84ymwlD.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
8052
8056
|
if (e.input.destructive !== !0) return i;
|
|
8053
8057
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
8054
8058
|
return a(i, e);
|
|
8055
8059
|
}
|
|
8056
|
-
var
|
|
8057
|
-
version:
|
|
8058
|
-
slug:
|
|
8059
|
-
source:
|
|
8060
|
-
docs:
|
|
8060
|
+
var w_ = {
|
|
8061
|
+
version: b_,
|
|
8062
|
+
slug: y_,
|
|
8063
|
+
source: x_,
|
|
8064
|
+
docs: S_,
|
|
8061
8065
|
plan: "open",
|
|
8062
8066
|
title: "Disable i18n",
|
|
8063
8067
|
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 block. The translation catalogs in src/locales stay.",
|
|
@@ -8089,22 +8093,22 @@ var E_ = {
|
|
|
8089
8093
|
examples: [],
|
|
8090
8094
|
tests: 0,
|
|
8091
8095
|
baseline: "velastack",
|
|
8092
|
-
generate:
|
|
8093
|
-
},
|
|
8096
|
+
generate: C_
|
|
8097
|
+
}, T_ = /* #__PURE__ */ Object.assign({
|
|
8094
8098
|
"../../enable/notifications/creates/src/lib/components/notifications-bell.svelte": sf,
|
|
8095
8099
|
"../../enable/notifications/creates/src/lib/server/notifications.ts": cf,
|
|
8096
8100
|
"../../enable/notifications/creates/src/routes/(app)/notifications/+page.server.ts": lf,
|
|
8097
8101
|
"../../enable/notifications/creates/src/routes/(app)/notifications/+page.svelte": uf
|
|
8098
|
-
}),
|
|
8099
|
-
async function
|
|
8102
|
+
}), E_ = "../../enable/notifications/creates/";
|
|
8103
|
+
async function D_(e) {
|
|
8100
8104
|
return {
|
|
8101
8105
|
creates: [],
|
|
8102
8106
|
modifies: [],
|
|
8103
|
-
deletes: Object.keys(
|
|
8104
|
-
let t =
|
|
8107
|
+
deletes: Object.keys(T_).map((e) => {
|
|
8108
|
+
let t = T(e, E_);
|
|
8105
8109
|
return {
|
|
8106
8110
|
path: t,
|
|
8107
|
-
language:
|
|
8111
|
+
language: S(t),
|
|
8108
8112
|
content: "",
|
|
8109
8113
|
status: "success"
|
|
8110
8114
|
};
|
|
@@ -8118,20 +8122,20 @@ async function k_(e) {
|
|
|
8118
8122
|
}
|
|
8119
8123
|
//#endregion
|
|
8120
8124
|
//#region src/patterns/disable/notifications/index.ts
|
|
8121
|
-
var
|
|
8122
|
-
async function
|
|
8123
|
-
let t = await
|
|
8125
|
+
var O_ = "disable-notifications", k_ = "1.1.1", A_ = "src/patterns/disable/notifications", j_ = "/disable/notifications";
|
|
8126
|
+
async function M_(e) {
|
|
8127
|
+
let t = await D_(e);
|
|
8124
8128
|
if (e.env !== "runtime") return D(t, e);
|
|
8125
|
-
let { generate: n } = await import("./chunks/generate.runtime-q17D7QUT.js"), r = await n(e), i = await D(
|
|
8129
|
+
let { generate: n } = await import("./chunks/generate.runtime-q17D7QUT.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
8126
8130
|
if (e.input.destructive !== !0) return i;
|
|
8127
8131
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
8128
8132
|
return a(i, e);
|
|
8129
8133
|
}
|
|
8130
|
-
var
|
|
8131
|
-
version:
|
|
8132
|
-
slug:
|
|
8133
|
-
source:
|
|
8134
|
-
docs:
|
|
8134
|
+
var N_ = {
|
|
8135
|
+
version: k_,
|
|
8136
|
+
slug: O_,
|
|
8137
|
+
source: A_,
|
|
8138
|
+
docs: j_,
|
|
8135
8139
|
plan: "open",
|
|
8136
8140
|
title: "Disable notifications",
|
|
8137
8141
|
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.",
|
|
@@ -8162,57 +8166,57 @@ var F_ = {
|
|
|
8162
8166
|
examples: [],
|
|
8163
8167
|
tests: 0,
|
|
8164
8168
|
baseline: "velastack-auth",
|
|
8165
|
-
generate:
|
|
8166
|
-
},
|
|
8167
|
-
"../../enable/teams/creates/src/lib/components/team-switcher.svelte":
|
|
8168
|
-
"../../enable/teams/creates/src/lib/schemas/team.ts":
|
|
8169
|
-
"../../enable/teams/creates/src/lib/schemas/teamInvite.ts":
|
|
8170
|
-
"../../enable/teams/creates/src/lib/schemas/teamRole.ts":
|
|
8171
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+layout@.svelte":
|
|
8172
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.server.ts":
|
|
8173
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.svelte":
|
|
8174
|
-
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.ts":
|
|
8175
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+layout@.svelte":
|
|
8176
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.server.ts":
|
|
8177
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.svelte":
|
|
8178
|
-
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.ts":
|
|
8179
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+layout.server.ts":
|
|
8180
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+layout.svelte":
|
|
8181
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+page.server.ts":
|
|
8169
|
+
generate: M_
|
|
8170
|
+
}, P_ = /* #__PURE__ */ Object.assign({
|
|
8171
|
+
"../../enable/teams/creates/src/lib/components/team-switcher.svelte": Vp,
|
|
8172
|
+
"../../enable/teams/creates/src/lib/schemas/team.ts": Hp,
|
|
8173
|
+
"../../enable/teams/creates/src/lib/schemas/teamInvite.ts": Up,
|
|
8174
|
+
"../../enable/teams/creates/src/lib/schemas/teamRole.ts": Wp,
|
|
8175
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+layout@.svelte": Gp,
|
|
8176
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.server.ts": Kp,
|
|
8177
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.svelte": qp,
|
|
8178
|
+
"../../enable/teams/creates/src/routes/(app)/invite/[id]/+page.ts": Jp,
|
|
8179
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+layout@.svelte": Yp,
|
|
8180
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.server.ts": Xp,
|
|
8181
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.svelte": Zp,
|
|
8182
|
+
"../../enable/teams/creates/src/routes/(app)/join/[id]/+page.ts": Qp,
|
|
8183
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.server.ts": $p,
|
|
8184
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+layout.svelte": em,
|
|
8185
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.server.ts": tm,
|
|
8182
8186
|
"../../enable/teams/creates/src/routes/(app)/teams/+page.svelte": "",
|
|
8183
|
-
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts":
|
|
8184
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts":
|
|
8185
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte":
|
|
8186
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts":
|
|
8187
|
+
"../../enable/teams/creates/src/routes/(app)/teams/+page.ts": nm,
|
|
8188
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout.server.ts": rm,
|
|
8189
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+layout@(app).svelte": im,
|
|
8190
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.server.ts": am,
|
|
8187
8191
|
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.svelte": "",
|
|
8188
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts":
|
|
8189
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts":
|
|
8190
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts":
|
|
8191
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte":
|
|
8192
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts":
|
|
8193
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts":
|
|
8194
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts":
|
|
8195
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte":
|
|
8196
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts":
|
|
8197
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts":
|
|
8198
|
-
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts":
|
|
8199
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts":
|
|
8200
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte":
|
|
8201
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts":
|
|
8202
|
-
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts":
|
|
8203
|
-
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts":
|
|
8204
|
-
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts":
|
|
8205
|
-
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts":
|
|
8206
|
-
}),
|
|
8207
|
-
async function
|
|
8192
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/+page.ts": om,
|
|
8193
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/authorization.ts": sm,
|
|
8194
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.server.ts": cm,
|
|
8195
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.svelte": lm,
|
|
8196
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/+page.ts": um,
|
|
8197
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/invite/server.test.ts": dm,
|
|
8198
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.server.ts": fm,
|
|
8199
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.svelte": pm,
|
|
8200
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/+page.ts": mm,
|
|
8201
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/member/[member_id]/server.test.ts": hm,
|
|
8202
|
+
"../../enable/teams/creates/src/routes/(app)/teams/[id]/server.test.ts": gm,
|
|
8203
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.server.ts": _m,
|
|
8204
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.svelte": vm,
|
|
8205
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/+page.ts": ym,
|
|
8206
|
+
"../../enable/teams/creates/src/routes/(app)/teams/new/server.test.ts": bm,
|
|
8207
|
+
"../../enable/teams/creates/src/routes/(app)/teams/server.test.ts": xm,
|
|
8208
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/+page.server.ts": Sm,
|
|
8209
|
+
"../../enable/teams/creates/src/routes/(app)/teams/switch/[id]/server.test.ts": Cm
|
|
8210
|
+
}), F_ = "../../enable/teams/creates/";
|
|
8211
|
+
async function I_(e) {
|
|
8208
8212
|
return {
|
|
8209
8213
|
creates: [],
|
|
8210
8214
|
modifies: [],
|
|
8211
|
-
deletes: Object.keys(
|
|
8212
|
-
let t =
|
|
8215
|
+
deletes: Object.keys(P_).map((e) => {
|
|
8216
|
+
let t = T(e, F_);
|
|
8213
8217
|
return {
|
|
8214
8218
|
path: t,
|
|
8215
|
-
language:
|
|
8219
|
+
language: S(t),
|
|
8216
8220
|
content: "",
|
|
8217
8221
|
status: "success"
|
|
8218
8222
|
};
|
|
@@ -8226,20 +8230,20 @@ async function R_(e) {
|
|
|
8226
8230
|
}
|
|
8227
8231
|
//#endregion
|
|
8228
8232
|
//#region src/patterns/disable/teams/index.ts
|
|
8229
|
-
var
|
|
8230
|
-
async function
|
|
8231
|
-
let t = await
|
|
8233
|
+
var L_ = "disable-teams", R_ = "1.1.1", z_ = "src/patterns/disable/teams", B_ = "/disable/teams";
|
|
8234
|
+
async function V_(e) {
|
|
8235
|
+
let t = await I_(e);
|
|
8232
8236
|
if (e.env !== "runtime") return D(t, e);
|
|
8233
|
-
let { generate: n } = await import("./chunks/generate.runtime-Dfz53sSK.js"), r = await n(e), i = await D(
|
|
8237
|
+
let { generate: n } = await import("./chunks/generate.runtime-Dfz53sSK.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
8234
8238
|
if (e.input.destructive !== !0) return i;
|
|
8235
8239
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
8236
8240
|
return a(i, e);
|
|
8237
8241
|
}
|
|
8238
|
-
var
|
|
8239
|
-
version:
|
|
8240
|
-
slug:
|
|
8241
|
-
source:
|
|
8242
|
-
docs:
|
|
8242
|
+
var H_ = {
|
|
8243
|
+
version: R_,
|
|
8244
|
+
slug: L_,
|
|
8245
|
+
source: z_,
|
|
8246
|
+
docs: B_,
|
|
8243
8247
|
plan: "pro",
|
|
8244
8248
|
title: "Disable teams",
|
|
8245
8249
|
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.",
|
|
@@ -8270,20 +8274,20 @@ var W_ = {
|
|
|
8270
8274
|
examples: [],
|
|
8271
8275
|
tests: 0,
|
|
8272
8276
|
baseline: "velastack-auth",
|
|
8273
|
-
generate:
|
|
8274
|
-
},
|
|
8275
|
-
async function
|
|
8277
|
+
generate: V_
|
|
8278
|
+
}, U_ = "disable-payments", W_ = "2.3.0", G_ = "src/patterns/disable/payments", K_ = "/disable/payments";
|
|
8279
|
+
async function q_(e) {
|
|
8276
8280
|
let t = await br(e);
|
|
8277
8281
|
if (e.env !== "runtime") return D(t, e);
|
|
8278
|
-
let { generate: n } = await import("./chunks/generate.runtime-
|
|
8282
|
+
let { generate: n } = await import("./chunks/generate.runtime-KrQk7mqG.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
8279
8283
|
if (e.input.destructive !== !0) return i;
|
|
8280
|
-
let a = yr(e).some((e) => e.id === "stripe") && e.features.backend ? await
|
|
8284
|
+
let a = yr(e).some((e) => e.id === "stripe") && e.features.backend ? await J_(e) : [], o = {
|
|
8281
8285
|
...i,
|
|
8282
8286
|
creates: [...i.creates, ...a]
|
|
8283
8287
|
}, { writeResult: s } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
8284
8288
|
return s(o, e);
|
|
8285
8289
|
}
|
|
8286
|
-
async function
|
|
8290
|
+
async function J_(e) {
|
|
8287
8291
|
let { withPocketbase: t } = await import("./chunks/pocketbase-BtN-wL8f.js").then((e) => e.r), { applyCollectionFieldsPatches: n } = await import("./chunks/collections-BYcVyY9O.js").then((e) => e.n), r = Te(e), i = [];
|
|
8288
8292
|
return await t(e.root, async (t) => {
|
|
8289
8293
|
let a;
|
|
@@ -8302,11 +8306,11 @@ async function X_(e) {
|
|
|
8302
8306
|
}], e, r));
|
|
8303
8307
|
}), i;
|
|
8304
8308
|
}
|
|
8305
|
-
var
|
|
8306
|
-
version:
|
|
8307
|
-
slug:
|
|
8308
|
-
source:
|
|
8309
|
-
docs:
|
|
8309
|
+
var Y_ = {
|
|
8310
|
+
version: W_,
|
|
8311
|
+
slug: U_,
|
|
8312
|
+
source: G_,
|
|
8313
|
+
docs: K_,
|
|
8310
8314
|
plan: "pro",
|
|
8311
8315
|
title: "Disable payments",
|
|
8312
8316
|
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.",
|
|
@@ -8342,8 +8346,8 @@ var Z_ = {
|
|
|
8342
8346
|
examples: [],
|
|
8343
8347
|
tests: 0,
|
|
8344
8348
|
baseline: "velastack",
|
|
8345
|
-
generate:
|
|
8346
|
-
},
|
|
8349
|
+
generate: q_
|
|
8350
|
+
}, X_ = /* #__PURE__ */ Object.assign({ "../../enable/ecommerce/creates/src/lib/components/cart/cart-button.svelte": Kf }), Z_ = /* #__PURE__ */ Object.assign({
|
|
8347
8351
|
"../../enable/ecommerce/providers/shopify/src/lib/cart.svelte.ts": qf,
|
|
8348
8352
|
"../../enable/ecommerce/providers/shopify/src/lib/components/cart/add-to-cart.svelte": Jf,
|
|
8349
8353
|
"../../enable/ecommerce/providers/shopify/src/lib/components/cart/cart-sheet.svelte": Yf,
|
|
@@ -8359,21 +8363,20 @@ var Z_ = {
|
|
|
8359
8363
|
"../../enable/ecommerce/providers/whatsapp/src/lib/cart.svelte.ts": ap,
|
|
8360
8364
|
"../../enable/ecommerce/providers/whatsapp/src/lib/components/cart/add-to-cart.svelte": op,
|
|
8361
8365
|
"../../enable/ecommerce/providers/whatsapp/src/lib/components/cart/cart-sheet.svelte": sp,
|
|
8362
|
-
"../../enable/ecommerce/providers-app-mode/stripe/src/routes/(public)/cart/+page.server.ts": cp
|
|
8363
|
-
"../../enable/ecommerce/providers-i18n/stripe/src/routes/(public)/checkout/success/+page.server.ts": lp
|
|
8366
|
+
"../../enable/ecommerce/providers-app-mode/stripe/src/routes/(public)/cart/+page.server.ts": cp
|
|
8364
8367
|
});
|
|
8365
|
-
async function
|
|
8366
|
-
let t = e.providers?.payments, n =
|
|
8368
|
+
async function Q_(e) {
|
|
8369
|
+
let t = e.providers?.payments, n = lp.some((e) => e.id === t) ? [t] : lp.map((e) => e.id);
|
|
8367
8370
|
return {
|
|
8368
8371
|
creates: [],
|
|
8369
8372
|
modifies: [],
|
|
8370
8373
|
deletes: [.../* @__PURE__ */ new Set([
|
|
8371
|
-
...Object.keys(
|
|
8372
|
-
...n.flatMap((e) => pe(
|
|
8373
|
-
...
|
|
8374
|
+
...Object.keys(w(X_, "../../enable/ecommerce/creates/")),
|
|
8375
|
+
...n.flatMap((e) => pe(Z_, e)),
|
|
8376
|
+
...ng.filter((e) => e !== "src/lib/catalog.ts")
|
|
8374
8377
|
])].sort().map((e) => ({
|
|
8375
8378
|
path: e,
|
|
8376
|
-
language:
|
|
8379
|
+
language: S(e),
|
|
8377
8380
|
content: "",
|
|
8378
8381
|
status: "success"
|
|
8379
8382
|
})),
|
|
@@ -8386,20 +8389,20 @@ async function ev(e) {
|
|
|
8386
8389
|
}
|
|
8387
8390
|
//#endregion
|
|
8388
8391
|
//#region src/patterns/disable/ecommerce/index.ts
|
|
8389
|
-
var
|
|
8390
|
-
async function
|
|
8391
|
-
let t = await
|
|
8392
|
+
var $_ = "disable-ecommerce", ev = "1.2.0", tv = "src/patterns/disable/ecommerce", nv = "/disable/ecommerce";
|
|
8393
|
+
async function rv(e) {
|
|
8394
|
+
let t = await Q_(e);
|
|
8392
8395
|
if (e.env !== "runtime") return D(t, e);
|
|
8393
|
-
let { generate: n } = await import("./chunks/generate.runtime-CHUCMVa2.js"), r = await n(e), i = await D(
|
|
8396
|
+
let { generate: n } = await import("./chunks/generate.runtime-CHUCMVa2.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
8394
8397
|
if (e.input.destructive !== !0) return i;
|
|
8395
8398
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
8396
8399
|
return a(i, e);
|
|
8397
8400
|
}
|
|
8398
|
-
var
|
|
8399
|
-
version:
|
|
8400
|
-
slug:
|
|
8401
|
-
source:
|
|
8402
|
-
docs:
|
|
8401
|
+
var iv = {
|
|
8402
|
+
version: ev,
|
|
8403
|
+
slug: $_,
|
|
8404
|
+
source: tv,
|
|
8405
|
+
docs: nv,
|
|
8403
8406
|
plan: "pro",
|
|
8404
8407
|
title: "Disable ecommerce",
|
|
8405
8408
|
summary: "Removes the cart, the checkout pages and the navbar cart button enable-ecommerce added. Payments, and the shadcn components the cart used, stay.",
|
|
@@ -8433,23 +8436,23 @@ var ov = {
|
|
|
8433
8436
|
examples: [],
|
|
8434
8437
|
tests: 0,
|
|
8435
8438
|
baseline: "velastack",
|
|
8436
|
-
generate:
|
|
8437
|
-
},
|
|
8438
|
-
"../../enable/subscriptions/creates/src/lib/workflows/sync-stripe-subscriptions.ts":
|
|
8439
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts":
|
|
8440
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts":
|
|
8441
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts":
|
|
8442
|
-
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts":
|
|
8443
|
-
}),
|
|
8444
|
-
async function
|
|
8439
|
+
generate: rv
|
|
8440
|
+
}, av = /* #__PURE__ */ Object.assign({
|
|
8441
|
+
"../../enable/subscriptions/creates/src/lib/workflows/sync-stripe-subscriptions.ts": Cp,
|
|
8442
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/created.ts": wp,
|
|
8443
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/deleted.ts": Tp,
|
|
8444
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/shared.ts": Ep,
|
|
8445
|
+
"../../enable/subscriptions/creates/src/routes/webhooks/stripe/handlers/subscription/updated.ts": Dp
|
|
8446
|
+
}), ov = "../../enable/subscriptions/creates/";
|
|
8447
|
+
async function sv(e) {
|
|
8445
8448
|
return {
|
|
8446
8449
|
creates: [],
|
|
8447
8450
|
modifies: [],
|
|
8448
|
-
deletes: Object.keys(
|
|
8449
|
-
let t =
|
|
8451
|
+
deletes: Object.keys(av).map((e) => {
|
|
8452
|
+
let t = T(e, ov);
|
|
8450
8453
|
return {
|
|
8451
8454
|
path: t,
|
|
8452
|
-
language:
|
|
8455
|
+
language: S(t),
|
|
8453
8456
|
content: "",
|
|
8454
8457
|
status: "success"
|
|
8455
8458
|
};
|
|
@@ -8463,20 +8466,20 @@ async function lv(e) {
|
|
|
8463
8466
|
}
|
|
8464
8467
|
//#endregion
|
|
8465
8468
|
//#region src/patterns/disable/subscriptions/index.ts
|
|
8466
|
-
var
|
|
8467
|
-
async function
|
|
8468
|
-
let t = await
|
|
8469
|
+
var cv = "disable-subscriptions", lv = "1.0.1", uv = "src/patterns/disable/subscriptions", dv = "/disable/subscriptions";
|
|
8470
|
+
async function fv(e) {
|
|
8471
|
+
let t = await sv(e);
|
|
8469
8472
|
if (e.env !== "runtime") return D(t, e);
|
|
8470
|
-
let { generate: n } = await import("./chunks/generate.runtime-Bvjj3zn0.js"), r = await n(e), i = await D(
|
|
8473
|
+
let { generate: n } = await import("./chunks/generate.runtime-Bvjj3zn0.js"), r = await n(e), i = await D(C([t, r]), e);
|
|
8471
8474
|
if (e.input.destructive !== !0) return i;
|
|
8472
8475
|
let { writeResult: a } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
8473
8476
|
return a(i, e);
|
|
8474
8477
|
}
|
|
8475
|
-
var
|
|
8476
|
-
version:
|
|
8477
|
-
slug:
|
|
8478
|
-
source:
|
|
8479
|
-
docs:
|
|
8478
|
+
var pv = {
|
|
8479
|
+
version: lv,
|
|
8480
|
+
slug: cv,
|
|
8481
|
+
source: uv,
|
|
8482
|
+
docs: dv,
|
|
8480
8483
|
plan: "pro",
|
|
8481
8484
|
title: "Disable subscriptions",
|
|
8482
8485
|
summary: "Drops the stripe_subscriptions collection, reverts billing / layout / nav edits, and removes subscription webhook handlers and sync endpoint. Leaves the payments pattern intact.",
|
|
@@ -8511,27 +8514,27 @@ var hv = {
|
|
|
8511
8514
|
examples: [],
|
|
8512
8515
|
tests: 0,
|
|
8513
8516
|
baseline: "velastack",
|
|
8514
|
-
generate:
|
|
8515
|
-
},
|
|
8516
|
-
"../../enable/whatsapp/creates/src/lib/server/whatsapp.ts":
|
|
8517
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
8518
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
8519
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
8520
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts":
|
|
8521
|
-
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
8522
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts":
|
|
8523
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte":
|
|
8524
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts":
|
|
8525
|
-
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts":
|
|
8526
|
-
}),
|
|
8527
|
-
async function
|
|
8528
|
-
let t = new Set(Object.keys(
|
|
8517
|
+
generate: fv
|
|
8518
|
+
}, mv = /* #__PURE__ */ Object.assign({
|
|
8519
|
+
"../../enable/whatsapp/creates/src/lib/server/whatsapp.ts": Gm,
|
|
8520
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Xm,
|
|
8521
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": Zm,
|
|
8522
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Qm,
|
|
8523
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/form.remote.ts": $m,
|
|
8524
|
+
"../../enable/whatsapp/creates-remote/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": eh,
|
|
8525
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.server.ts": Km,
|
|
8526
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.svelte": qm,
|
|
8527
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/+page.ts": Jm,
|
|
8528
|
+
"../../enable/whatsapp/creates-superforms/src/routes/(public)/(auth)/whatsapp/[token]/server.test.ts": Ym
|
|
8529
|
+
}), hv = /^\.\.\/\.\.\/enable\/whatsapp\/creates(-superforms|-remote)?\//;
|
|
8530
|
+
async function gv(e) {
|
|
8531
|
+
let t = new Set(Object.keys(mv).map((e) => e.replace(hv, "")));
|
|
8529
8532
|
return {
|
|
8530
8533
|
creates: [],
|
|
8531
8534
|
modifies: [],
|
|
8532
8535
|
deletes: Array.from(t).map((e) => ({
|
|
8533
8536
|
path: e,
|
|
8534
|
-
language:
|
|
8537
|
+
language: S(e),
|
|
8535
8538
|
content: "",
|
|
8536
8539
|
status: "success"
|
|
8537
8540
|
})).sort((e, t) => e.path.localeCompare(t.path)),
|
|
@@ -8544,18 +8547,18 @@ async function vv(e) {
|
|
|
8544
8547
|
}
|
|
8545
8548
|
//#endregion
|
|
8546
8549
|
//#region src/patterns/disable/whatsapp/index.ts
|
|
8547
|
-
var
|
|
8548
|
-
async function
|
|
8549
|
-
let t = await
|
|
8550
|
+
var _v = "disable-whatsapp", vv = "1.0.0", yv = "src/patterns/disable/whatsapp", bv = "/disable/whatsapp";
|
|
8551
|
+
async function xv(e) {
|
|
8552
|
+
let t = await gv(e);
|
|
8550
8553
|
if (e.env !== "runtime" || e.input.destructive !== !0) return D(t, e);
|
|
8551
8554
|
let { generate: n } = await import("./chunks/generate.runtime-rLlDp4R6.js"), r = await n(e), { writeResult: i } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
8552
|
-
return i(await D(
|
|
8555
|
+
return i(await D(C([t, r]), e), e);
|
|
8553
8556
|
}
|
|
8554
|
-
var
|
|
8555
|
-
version:
|
|
8556
|
-
slug:
|
|
8557
|
-
source:
|
|
8558
|
-
docs:
|
|
8557
|
+
var Sv = {
|
|
8558
|
+
version: vv,
|
|
8559
|
+
slug: _v,
|
|
8560
|
+
source: yv,
|
|
8561
|
+
docs: bv,
|
|
8559
8562
|
plan: "open",
|
|
8560
8563
|
title: "Disable WhatsApp sign-in",
|
|
8561
8564
|
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.",
|
|
@@ -8587,8 +8590,8 @@ var wv = {
|
|
|
8587
8590
|
examples: [],
|
|
8588
8591
|
tests: 0,
|
|
8589
8592
|
baseline: "velastack-auth",
|
|
8590
|
-
generate:
|
|
8591
|
-
},
|
|
8593
|
+
generate: xv
|
|
8594
|
+
}, Cv = xr.version, wv = [
|
|
8592
8595
|
Sa,
|
|
8593
8596
|
Xa,
|
|
8594
8597
|
so,
|
|
@@ -8611,79 +8614,79 @@ var wv = {
|
|
|
8611
8614
|
of,
|
|
8612
8615
|
Ef,
|
|
8613
8616
|
Gf,
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
],
|
|
8617
|
+
Sp,
|
|
8618
|
+
Bp,
|
|
8619
|
+
Wm,
|
|
8620
|
+
fh,
|
|
8621
|
+
Th,
|
|
8622
|
+
Mh,
|
|
8623
|
+
Rh,
|
|
8624
|
+
Wh,
|
|
8625
|
+
Xh,
|
|
8626
|
+
ig,
|
|
8627
|
+
ug,
|
|
8628
|
+
gg,
|
|
8629
|
+
Tg,
|
|
8630
|
+
Pg,
|
|
8631
|
+
qg,
|
|
8632
|
+
i_,
|
|
8633
|
+
h_,
|
|
8634
|
+
w_,
|
|
8635
|
+
N_,
|
|
8636
|
+
H_,
|
|
8637
|
+
Y_,
|
|
8638
|
+
iv,
|
|
8639
|
+
pv,
|
|
8640
|
+
Sv
|
|
8641
|
+
], Tv = Object.fromEntries(wv.map((e) => [e.slug, e])), Ev = wv.reduce((e, t) => {
|
|
8639
8642
|
let n = t.category;
|
|
8640
8643
|
return e[n] ??= [], e[n].push(t), e;
|
|
8641
8644
|
}, {});
|
|
8642
|
-
async function
|
|
8645
|
+
async function Dv(e, t) {
|
|
8643
8646
|
let { installComponents: n } = await import("./chunks/write-result-DcqMefuP.js").then((e) => e.l);
|
|
8644
8647
|
return n(e, t);
|
|
8645
8648
|
}
|
|
8646
|
-
async function
|
|
8649
|
+
async function Ov(e, t) {
|
|
8647
8650
|
let { listComponents: n } = await import("./chunks/ui-gG8i_Mzk.js");
|
|
8648
8651
|
return n(e, t);
|
|
8649
8652
|
}
|
|
8650
|
-
async function
|
|
8653
|
+
async function kv(e, t) {
|
|
8651
8654
|
let { switchStyle: n } = await import("./chunks/ui-gG8i_Mzk.js");
|
|
8652
8655
|
return n(e, t);
|
|
8653
8656
|
}
|
|
8654
|
-
async function
|
|
8657
|
+
async function Av(e, t) {
|
|
8655
8658
|
let { applyBaseColor: n } = await import("./chunks/ui-gG8i_Mzk.js");
|
|
8656
8659
|
return n(e, t);
|
|
8657
8660
|
}
|
|
8658
|
-
async function
|
|
8661
|
+
async function jv(e, t) {
|
|
8659
8662
|
let { applyTheme: n } = await import("./chunks/ui-gG8i_Mzk.js");
|
|
8660
8663
|
return n(e, t);
|
|
8661
8664
|
}
|
|
8662
|
-
async function
|
|
8665
|
+
async function Mv(e) {
|
|
8663
8666
|
let { detectProviders: t } = await import("./chunks/providers-DRwJnSzb.js");
|
|
8664
|
-
return t(e,
|
|
8667
|
+
return t(e, wv);
|
|
8665
8668
|
}
|
|
8666
|
-
async function
|
|
8669
|
+
async function Nv(e, t) {
|
|
8667
8670
|
let { modifyEnvVars: n } = await import("./chunks/env-vars-0hvKe55u.js");
|
|
8668
8671
|
return n(e, t);
|
|
8669
8672
|
}
|
|
8670
|
-
async function
|
|
8673
|
+
async function Pv(e, t) {
|
|
8671
8674
|
let { unmodifyEnvVars: n } = await import("./chunks/env-vars-0hvKe55u.js");
|
|
8672
8675
|
return n(e, t);
|
|
8673
8676
|
}
|
|
8674
|
-
async function
|
|
8677
|
+
async function Fv(e, t) {
|
|
8675
8678
|
let { ensurePackageImports: n } = await import("./chunks/package-imports-B9Asv3ZH.js").then((e) => e.n);
|
|
8676
8679
|
return n(e, t);
|
|
8677
8680
|
}
|
|
8678
|
-
async function
|
|
8681
|
+
async function Iv(e, t, n) {
|
|
8679
8682
|
let { removePackageImports: r } = await import("./chunks/package-imports-B9Asv3ZH.js").then((e) => e.n);
|
|
8680
8683
|
return r(e, t, n);
|
|
8681
8684
|
}
|
|
8682
|
-
async function
|
|
8685
|
+
async function Lv(e, t) {
|
|
8683
8686
|
let { ensurePackageOverrides: n } = await import("./chunks/package-imports-B9Asv3ZH.js").then((e) => e.n);
|
|
8684
8687
|
return n(e, t);
|
|
8685
8688
|
}
|
|
8686
8689
|
//#endregion
|
|
8687
|
-
export {
|
|
8690
|
+
export { re as ADAPTER_NODE, ee as ADAPTER_STATIC, f as ENV_DECL_CANDIDATES, m as FLASH, te as FORMSNAP, a as InvalidArgumentError, r as MissingShadcnError, h as NEGOTIATE, i as RegistryUnavailableError, ie as SUPERFORMS, g as SUPERFORMS_VERSION, ne as VELASTACK_CMS, b as VELASTACK_KIT, v as VELASTACK_POCKETBASE, Av as applyBaseColor, jv as applyTheme, Sr as blockingFeatures, Ev as byCategory, Tv as bySlug, le as capabilityName, Mv as detectProviders, Fv as ensurePackageImports, Lv as ensurePackageOverrides, d as envVarEntry, u as envVarsFile, Dv as installComponents, l as isLibSpecifier, s as libAliasPath, c as libModule, o as libSpecifier, Ov as listComponents, Nv as modifyEnvVars, wv as patterns, ce as providerEnvVars, ue as providerFromArgv, fe as providerMarkers, Iv as removePackageImports, E as resolveProvider, kv as switchStyle, me as unknownProviderMessage, Cr as unmetRequirements, Pv as unmodifyEnvVars, Cv as version };
|
|
8688
8691
|
|
|
8689
8692
|
//# sourceMappingURL=index.js.map
|