@velastack/patterns 0.8.0 → 0.10.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/_page-B6yd6_Vl.js +6 -0
- package/dist/chunks/_page-B6yd6_Vl.js.map +1 -0
- package/dist/chunks/{collections-BrEA7a62.js → collections-DZOuRpvS.js} +6 -1
- package/dist/chunks/collections-DZOuRpvS.js.map +1 -0
- package/dist/chunks/{generate-BZ741GPx.js → currency.server-Bb2Ndutg.js} +6 -3
- package/dist/chunks/{generate-BZ741GPx.js.map → currency.server-Bb2Ndutg.js.map} +1 -1
- package/dist/chunks/{generate-6JS05dWK.js → generate-B-cqjI-U.js} +62 -55
- package/dist/chunks/generate-B-cqjI-U.js.map +1 -0
- package/dist/chunks/generate-BrOPb9tW.js +175 -0
- package/dist/chunks/generate-BrOPb9tW.js.map +1 -0
- package/dist/chunks/{generate.runtime-BOl3LpPB.js → generate.runtime-BnqS_Zq8.js} +84 -158
- package/dist/chunks/generate.runtime-BnqS_Zq8.js.map +1 -0
- package/dist/chunks/{generate.runtime-KrQk7mqG.js → generate.runtime-DG9Lp3vR.js} +39 -37
- package/dist/chunks/generate.runtime-DG9Lp3vR.js.map +1 -0
- package/dist/chunks/generate.runtime-DuDcKDUl.js +162 -0
- package/dist/chunks/generate.runtime-DuDcKDUl.js.map +1 -0
- package/dist/chunks/{generate.runtime-Dt3Edp8-.js → generate.runtime-J2lLMjDn.js} +97 -126
- package/dist/chunks/generate.runtime-J2lLMjDn.js.map +1 -0
- package/dist/chunks/generate.runtime-nyJ6v56q.js +64 -0
- package/dist/chunks/generate.runtime-nyJ6v56q.js.map +1 -0
- package/dist/chunks/load-function-Dmkhg1pQ.js +79 -0
- package/dist/chunks/load-function-Dmkhg1pQ.js.map +1 -0
- package/dist/chunks/modify-nav-user-iUpv2lm-.js +53 -0
- package/dist/chunks/modify-nav-user-iUpv2lm-.js.map +1 -0
- package/dist/chunks/root-layout.svelte-CUVbnlX-.js +302 -0
- package/dist/chunks/root-layout.svelte-CUVbnlX-.js.map +1 -0
- package/dist/index.d.ts +156 -2
- package/dist/index.js +1972 -1807
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/collections-BrEA7a62.js.map +0 -1
- package/dist/chunks/generate-6JS05dWK.js.map +0 -1
- package/dist/chunks/generate.runtime-BOl3LpPB.js.map +0 -1
- package/dist/chunks/generate.runtime-Dt3Edp8-.js.map +0 -1
- package/dist/chunks/generate.runtime-KrQk7mqG.js.map +0 -1
- package/dist/chunks/root-layout.svelte-CsJ2QJYi.js +0 -93
- package/dist/chunks/root-layout.svelte-CsJ2QJYi.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-BZ741GPx.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__1_2_","__import_glob__1_3_","__import_glob__1_4_","__import_glob__1_5_","__import_glob__1_6_","__import_glob__1_7_","__import_glob__1_8_","__import_glob__1_9_","__import_glob__1_10_","__import_glob__1_11_","__import_glob__1_12_","__import_glob__1_13_","__import_glob__1_14_","__import_glob__1_15_","__import_glob__1_16_","__import_glob__1_17_","__import_glob__1_18_","__import_glob__1_19_","__import_glob__1_20_","__import_glob__1_21_","__import_glob__1_22_","__import_glob__2_0_","__import_glob__2_1_","__import_glob__2_2_","__import_glob__2_3_","__import_glob__2_4_","__import_glob__2_5_","__import_glob__2_6_","__import_glob__2_7_","__import_glob__2_8_","__import_glob__2_9_","__import_glob__2_10_","__import_glob__2_11_","__import_glob__2_12_","__import_glob__2_13_","__import_glob__2_14_","__import_glob__2_15_","__import_glob__2_16_","__import_glob__2_17_","InvalidArgumentError","VELASTACK_WHATSAPP","filesFromGlob","resolveProvider","providerCreates","stripe_customer_default","_page_server_default","_page_default","currency_select_default","currency_svelte_default","buy_button_default","shopify_default","confirm_dialog_default","payment_button_default","payment_dialog_default","stripe_constants_default","stripe_payment_form_default","use_payment_intent_svelte_default","use_stripe_svelte_default","stripe_default","stripe_event_default","sync_stripe_catalog_default","_server_default$3","server_test_default$6","_server_default$2","dispatch_default$1","server_test_default$5","succeeded_default$1","server_test_default$4","customer_fields_default","order_button_default","order_test_default","order_default","setup_button_default","setup_dialog_default","link_stripe_customer_default","sync_stripe_customers_default","_layout_server_default","README_default","_server_default$1","server_test_default$3","_server_default","server_test_default$2","dispatch_default","server_test_default$1","succeeded_default","attached_default","server_test_default","PROVIDERS","META","envEditsFor","providerEnvEdits","provider","supplied","COMPONENTS","PACKAGES","createsRaw","providersRaw","providersAppModeRaw","isUnitTest","path","generate","options","current","label","candidate","isAppMode","creates","unitTests","file","components","a","b"],"sources":["../../src/patterns/enable/payments/generate.ts"],"sourcesContent":["import type {\n Component,\n Options,\n Package,\n Provider,\n Result,\n} from \"../../../core/types\";\nimport type { EnvEdit } from \"../../../runtime/env\";\nimport {\n providerCreates,\n providerEnvEdits,\n resolveProvider,\n} from \"../../../core/providers\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { VELASTACK_WHATSAPP } from \"../../../core/constants\";\nimport { filesFromGlob } from \"../../../core/util\";\n\n/**\n * The providers in prompt order. Each one's `env` keys are what the CLI asks\n * for, what `generate.runtime.ts` writes to `.env` (in this order, under a\n * `# <Label> credentials` heading) and declares in `src/env.ts`.\n */\nexport const PROVIDERS: Provider[] = [\n {\n id: \"stripe\",\n label: \"Stripe\",\n env: [\n {\n key: \"STRIPE_SECRET_KEY\",\n label: \"Stripe secret key\",\n placeholder: \"sk_...\",\n secret: true,\n required: true,\n description:\n \"Stripe secret key (`sk_...`) the server calls the Stripe API with.\",\n },\n {\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n label: \"Stripe publishable key\",\n placeholder: \"pk_...\",\n public: true,\n required: true,\n description:\n \"Stripe publishable key (`pk_...`) that Stripe.js loads in the browser.\",\n },\n {\n key: \"STRIPE_WEBHOOK_SECRET\",\n label: \"Stripe webhook signing secret\",\n placeholder: \"whsec_...\",\n secret: true,\n required: true,\n description:\n \"Signing secret (`whsec_...`) that `/webhooks/stripe` verifies events with.\",\n },\n ],\n // The webhook route predates the `src/env.ts` declarations, so a project\n // that enabled payments before them is still recognised.\n markers: [\n { env: \"STRIPE_SECRET_KEY\" },\n { path: \"src/routes/webhooks/stripe\" },\n ],\n // Products, prices and customers are synced into PocketBase by workflows.\n requires: { backend: true, workflows: true },\n },\n {\n id: \"shopify\",\n label: \"Shopify\",\n env: [\n {\n key: \"PUBLIC_SHOPIFY_STORE_DOMAIN\",\n label: \"Shopify store domain\",\n placeholder: \"your-store.myshopify.com\",\n public: true,\n required: true,\n description:\n \"The store's `*.myshopify.com` domain the Storefront API is called on.\",\n },\n {\n key: \"PUBLIC_SHOPIFY_STOREFRONT_TOKEN\",\n label: \"Shopify Storefront API public access token\",\n public: true,\n required: true,\n description:\n \"Public Storefront API access token, from the store's Headless channel.\",\n },\n ],\n },\n {\n id: \"whatsapp\",\n label: \"WhatsApp\",\n env: [\n {\n key: \"PUBLIC_WHATSAPP_NUMBER\",\n label: \"WhatsApp number orders are sent to\",\n placeholder: \"+353 1 555 0100\",\n public: true,\n required: true,\n description:\n \"The business's WhatsApp number, with country code, that orders open a chat with.\",\n },\n {\n key: \"PUBLIC_WHATSAPP_ORDER_FORM\",\n label: \"Hosted VelaStack form orders are recorded to\",\n placeholder: \"https://velastack.dev/v1/projects/<project>/forms/order\",\n public: true,\n description:\n \"The hosted VelaStack form each order is recorded to, so it is kept even if the chat is never sent. Empty records nothing.\",\n },\n ],\n },\n];\n\n/** What `resolveProvider` needs; `index.ts` spreads the rest of the metadata. */\nexport const META = { slug: \"enable-payments\", providers: PROVIDERS };\n\n/** The `.env` lines for a provider, under a `# <Label> credentials` heading. */\nexport function envEditsFor(\n provider: Provider,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return providerEnvEdits(provider, `${provider.label} credentials`, supplied);\n}\n\n// `select` is the currency select every provider gets.\nconst COMPONENTS: Record<string, Component[]> = {\n stripe: [\"dialog\", \"input\", \"label\", \"select\"],\n shopify: [\"button\", \"select\"],\n whatsapp: [\"button\", \"dialog\", \"input\", \"label\", \"textarea\", \"select\"],\n};\n\nconst PACKAGES: Record<string, Package[]> = {\n stripe: [\"stripe\", \"@stripe/stripe-js\"],\n shopify: [\"@shopify/storefront-api-client\"],\n whatsapp: [VELASTACK_WHATSAPP],\n};\n\n// Shared by every provider: the currency prices show in, and its select.\nconst createsRaw = import.meta.glob<string>(\"./creates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersRaw = import.meta.glob<string>(\"./providers/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersAppModeRaw = import.meta.glob<string>(\n \"./providers-app-mode/**\",\n { query: \"?raw\", import: \"default\", eager: true },\n);\n\nexport interface GenerateContext {\n /**\n * The project can run unit tests (vitest is installed), so a provider's\n * `*.test.ts` beside its code is written too. Server tests (`server.test.ts`)\n * always are: they run under `vela test:server`, which brings its own runner.\n */\n unitTests?: boolean;\n}\n\nconst isUnitTest = (path: string) =>\n path.endsWith(\".test.ts\") && !path.endsWith(\"server.test.ts\");\n\nexport async function generate(\n options: Options,\n { unitTests = false }: GenerateContext = {},\n) {\n const provider = resolveProvider(META, options);\n\n // A second provider would leave the project with both, and the patterns\n // built on payments could no longer tell which one it uses.\n const current = options.providers?.payments;\n if (current !== undefined && current !== provider.id) {\n const label =\n PROVIDERS.find((candidate) => candidate.id === current)?.label ?? current;\n throw new InvalidArgumentError(\n `This project already uses ${label} payments. To switch to ${provider.label}, ` +\n \"run `vela disable payments` first, then enable payments again.\",\n );\n }\n // Stripe keeps cards and customers for signed-in users; Shopify's checkout\n // owns its customers and WhatsApp has none, so neither has app-mode files.\n const isAppMode = options.features.auth;\n\n const creates = new Map(\n [\n ...Object.values(filesFromGlob(createsRaw, \"./creates/\")),\n ...providerCreates(providersRaw, provider.id),\n ]\n .filter((file) => unitTests || !isUnitTest(file.path))\n .map((file) => [file.path, file]),\n );\n if (isAppMode) {\n for (const file of providerCreates(\n providersAppModeRaw,\n provider.id,\n \"./providers-app-mode/\",\n )) {\n creates.set(file.path, file);\n }\n }\n\n const components = [...(COMPONENTS[provider.id] ?? [])];\n if (isAppMode && provider.id === \"stripe\") components.push(\"alert-dialog\");\n\n return {\n creates: [...creates.values()].sort((a, b) => a.path.localeCompare(b.path)),\n modifies: [],\n deletes: [],\n components,\n packages: PACKAGES[provider.id] ?? [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;A,0rwGAsBa2F,IAAwB;CACnC;EACE,IAAI;EACJ,OAAO;EACP,KAAK;GACH;IACE,KAAK;IACL,OAAO;IACP,aAAa;IACb,QAAQ;IACR,UAAU;IACV,aACE;GACJ;GACA;IACE,KAAK;IACL,OAAO;IACP,aAAa;IACb,QAAQ;IACR,UAAU;IACV,aACE;GACJ;GACA;IACE,KAAK;IACL,OAAO;IACP,aAAa;IACb,QAAQ;IACR,UAAU;IACV,aACE;GACJ;EACF;EAGA,SAAS,CACP,EAAE,KAAK,oBAAoB,GAC3B,EAAE,MAAM,6BAA6B,CACvC;EAEA,UAAU;GAAE,SAAS;GAAM,WAAW;EAAK;CAC7C;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,OAAO;GACP,aAAa;GACb,QAAQ;GACR,UAAU;GACV,aACE;EACJ,GACA;GACE,KAAK;GACL,OAAO;GACP,QAAQ;GACR,UAAU;GACV,aACE;EACJ,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,OAAO;GACP,aAAa;GACb,QAAQ;GACR,UAAU;GACV,aACE;EACJ,GACA;GACE,KAAK;GACL,OAAO;GACP,aAAa;GACb,QAAQ;GACR,aACE;EACJ,CACF;CACF;AACF,GAGaC,IAAO;CAAE,MAAM;CAAmB,WAAWD;AAAU;AAGpE,SAAgBE,EACd,GAC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,GAC1C;CACA,IAAMT,IAAWjD,EAAgB8C,GAAMa,CAAO,GAIxCC,IAAUD,EAAQ,WAAW;CACnC,IAAIC,MAAY,KAAA,KAAaA,MAAYX,EAAS,IAAI;EACpD,IAAMY,IACJhB,EAAU,MAAM,MAAciB,EAAU,OAAOF,CAAO,CAAC,EAAE,SAASA;EACpE,MAAM,IAAI/D,EACR,6BAA6BgE,EAAM,0BAA0BZ,EAAS,MAAM,mEAE9E;CACF;CAGA,IAAMc,IAAYJ,EAAQ,SAAS,MAE7BK,IAAU,IAAI,IAClB,CACE,GAAG,OAAO,OAAOjE,EAAcsD,IAAY,YAAY,CAAC,GACxD,GAAGpD,EAAgBqD,IAAcL,EAAS,EAAE,CAC9C,CAAC,CACE,QAAQ,MAASgB,KAAa,CAACT,GAAWU,EAAK,IAAI,CAAC,CAAC,CACrD,KAAK,MAAS,CAACA,EAAK,MAAMA,CAAI,CAAC,CACpC;CACA,IAAIH,GACF,KAAK,IAAMG,KAAQjE,EACjBsD,IACAN,EAAS,IACT,uBACF,GACE,EAAQ,IAAIiB,EAAK,MAAMA,CAAI;CAI/B,IAAMC,IAAa,CAAC,GAAIhB,EAAWF,EAAS,OAAO,CAAC,CAAE;CAGtD,OAFIc,KAAad,EAAS,OAAO,YAAUkB,EAAW,KAAK,cAAc,GAElE;EACL,SAAS,CAAC,GAAGH,EAAQ,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,MAAMI,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC;EAC1E,UAAU,CAAC;EACX,SAAS,CAAC;EACV;EACA,UAAUjB,EAASH,EAAS,OAAO,CAAC;EACpC,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"currency.server-Bb2Ndutg.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__1_2_","__import_glob__1_3_","__import_glob__1_4_","__import_glob__1_5_","__import_glob__1_6_","__import_glob__1_7_","__import_glob__1_8_","__import_glob__1_9_","__import_glob__1_10_","__import_glob__1_11_","__import_glob__1_12_","__import_glob__1_13_","__import_glob__1_14_","__import_glob__1_15_","__import_glob__1_16_","__import_glob__1_17_","__import_glob__1_18_","__import_glob__1_19_","__import_glob__1_20_","__import_glob__1_21_","__import_glob__1_22_","__import_glob__2_0_","__import_glob__2_1_","__import_glob__2_2_","__import_glob__2_3_","__import_glob__2_4_","__import_glob__2_5_","__import_glob__2_6_","__import_glob__2_7_","__import_glob__2_8_","__import_glob__2_9_","__import_glob__2_10_","__import_glob__2_11_","__import_glob__2_12_","__import_glob__2_13_","__import_glob__2_14_","__import_glob__2_15_","__import_glob__2_16_","__import_glob__2_17_","InvalidArgumentError","VELASTACK_WHATSAPP","filesFromGlob","resolveProvider","providerCreates","stripe_customer_default","_page_server_default","_page_default","currency_select_default","currency_svelte_default","buy_button_default","shopify_default","confirm_dialog_default","payment_button_default","payment_dialog_default","stripe_constants_default","stripe_payment_form_default","use_payment_intent_svelte_default","use_stripe_svelte_default","stripe_default","stripe_event_default","sync_stripe_catalog_default","_server_default$3","server_test_default$6","_server_default$2","dispatch_default$1","server_test_default$5","succeeded_default$1","server_test_default$4","customer_fields_default","order_button_default","order_test_default","order_default","setup_button_default","setup_dialog_default","link_stripe_customer_default","sync_stripe_customers_default","_layout_server_default","README_default","_server_default$1","server_test_default$3","_server_default","server_test_default$2","dispatch_default","server_test_default$1","succeeded_default","attached_default","server_test_default","PROVIDERS","META","envEditsFor","providerEnvEdits","provider","supplied","COMPONENTS","PACKAGES","createsRaw","providersRaw","providersAppModeRaw","isUnitTest","path","generate","options","current","label","candidate","isAppMode","creates","unitTests","file","components","a","b","currency_server_test_default","currency_server_default"],"sources":["../../src/patterns/enable/payments/generate.ts"],"sourcesContent":["import type {\n Component,\n Options,\n Package,\n Provider,\n Result,\n} from \"../../../core/types\";\nimport type { EnvEdit } from \"../../../runtime/env\";\nimport {\n providerCreates,\n providerEnvEdits,\n resolveProvider,\n} from \"../../../core/providers\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { VELASTACK_WHATSAPP } from \"../../../core/constants\";\nimport { filesFromGlob } from \"../../../core/util\";\n\n/**\n * The providers in prompt order. Each one's `env` keys are what the CLI asks\n * for, what `generate.runtime.ts` writes to `.env` (in this order, under a\n * `# <Label> credentials` heading) and declares in `src/env.ts`.\n */\nexport const PROVIDERS: Provider[] = [\n {\n id: \"stripe\",\n label: \"Stripe\",\n env: [\n {\n key: \"STRIPE_SECRET_KEY\",\n label: \"Stripe secret key\",\n placeholder: \"sk_...\",\n secret: true,\n required: true,\n description:\n \"Stripe secret key (`sk_...`) the server calls the Stripe API with.\",\n },\n {\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n label: \"Stripe publishable key\",\n placeholder: \"pk_...\",\n public: true,\n required: true,\n description:\n \"Stripe publishable key (`pk_...`) that Stripe.js loads in the browser.\",\n },\n {\n key: \"STRIPE_WEBHOOK_SECRET\",\n label: \"Stripe webhook signing secret\",\n placeholder: \"whsec_...\",\n secret: true,\n required: true,\n description:\n \"Signing secret (`whsec_...`) that `/webhooks/stripe` verifies events with.\",\n },\n ],\n // The webhook route predates the `src/env.ts` declarations, so a project\n // that enabled payments before them is still recognised.\n markers: [\n { env: \"STRIPE_SECRET_KEY\" },\n { path: \"src/routes/webhooks/stripe\" },\n ],\n // Products, prices and customers are synced into PocketBase by workflows.\n requires: { backend: true, workflows: true },\n },\n {\n id: \"shopify\",\n label: \"Shopify\",\n env: [\n {\n key: \"PUBLIC_SHOPIFY_STORE_DOMAIN\",\n label: \"Shopify store domain\",\n placeholder: \"your-store.myshopify.com\",\n public: true,\n required: true,\n description:\n \"The store's `*.myshopify.com` domain the Storefront API is called on.\",\n },\n {\n key: \"PUBLIC_SHOPIFY_STOREFRONT_TOKEN\",\n label: \"Shopify Storefront API public access token\",\n public: true,\n required: true,\n description:\n \"Public Storefront API access token, from the store's Headless channel.\",\n },\n ],\n },\n {\n id: \"whatsapp\",\n label: \"WhatsApp\",\n env: [\n {\n key: \"PUBLIC_WHATSAPP_NUMBER\",\n label: \"WhatsApp number orders are sent to\",\n placeholder: \"+353 1 555 0100\",\n public: true,\n required: true,\n description:\n \"The business's WhatsApp number, with country code, that orders open a chat with.\",\n },\n {\n key: \"PUBLIC_WHATSAPP_ORDER_FORM\",\n label: \"Hosted VelaStack form orders are recorded to\",\n placeholder: \"https://velastack.dev/v1/projects/<project>/forms/order\",\n public: true,\n description:\n \"The hosted VelaStack form each order is recorded to, so it is kept even if the chat is never sent. Empty records nothing.\",\n },\n ],\n },\n];\n\n/** What `resolveProvider` needs; `index.ts` spreads the rest of the metadata. */\nexport const META = { slug: \"enable-payments\", providers: PROVIDERS };\n\n/** The `.env` lines for a provider, under a `# <Label> credentials` heading. */\nexport function envEditsFor(\n provider: Provider,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return providerEnvEdits(provider, `${provider.label} credentials`, supplied);\n}\n\n// `select` is the currency select every provider gets.\nconst COMPONENTS: Record<string, Component[]> = {\n stripe: [\"dialog\", \"input\", \"label\", \"select\"],\n shopify: [\"button\", \"select\"],\n whatsapp: [\"button\", \"dialog\", \"input\", \"label\", \"textarea\", \"select\"],\n};\n\nconst PACKAGES: Record<string, Package[]> = {\n stripe: [\"stripe\", \"@stripe/stripe-js\"],\n shopify: [\"@shopify/storefront-api-client\"],\n whatsapp: [VELASTACK_WHATSAPP],\n};\n\n// Shared by every provider: the currency prices show in, and its select.\nconst createsRaw = import.meta.glob<string>(\"./creates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersRaw = import.meta.glob<string>(\"./providers/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersAppModeRaw = import.meta.glob<string>(\n \"./providers-app-mode/**\",\n { query: \"?raw\", import: \"default\", eager: true },\n);\n\nexport interface GenerateContext {\n /**\n * The project can run unit tests (vitest is installed), so a provider's\n * `*.test.ts` beside its code is written too. Server tests (`server.test.ts`)\n * always are: they run under `vela test:server`, which brings its own runner.\n */\n unitTests?: boolean;\n}\n\nconst isUnitTest = (path: string) =>\n path.endsWith(\".test.ts\") && !path.endsWith(\"server.test.ts\");\n\nexport async function generate(\n options: Options,\n { unitTests = false }: GenerateContext = {},\n) {\n const provider = resolveProvider(META, options);\n\n // A second provider would leave the project with both, and the patterns\n // built on payments could no longer tell which one it uses.\n const current = options.providers?.payments;\n if (current !== undefined && current !== provider.id) {\n const label =\n PROVIDERS.find((candidate) => candidate.id === current)?.label ?? current;\n throw new InvalidArgumentError(\n `This project already uses ${label} payments. To switch to ${provider.label}, ` +\n \"run `vela disable payments` first, then enable payments again.\",\n );\n }\n // Stripe keeps cards and customers for signed-in users; Shopify's checkout\n // owns its customers and WhatsApp has none, so neither has app-mode files.\n const isAppMode = options.features.auth;\n\n const creates = new Map(\n [\n ...Object.values(filesFromGlob(createsRaw, \"./creates/\")),\n ...providerCreates(providersRaw, provider.id),\n ]\n .filter((file) => unitTests || !isUnitTest(file.path))\n .map((file) => [file.path, file]),\n );\n if (isAppMode) {\n for (const file of providerCreates(\n providersAppModeRaw,\n provider.id,\n \"./providers-app-mode/\",\n )) {\n creates.set(file.path, file);\n }\n }\n\n const components = [...(COMPONENTS[provider.id] ?? [])];\n if (isAppMode && provider.id === \"stripe\") components.push(\"alert-dialog\");\n\n return {\n creates: [...creates.values()].sort((a, b) => a.path.localeCompare(b.path)),\n modifies: [],\n deletes: [],\n components,\n packages: PACKAGES[provider.id] ?? [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;A,0n2GAsBa2F,IAAwB;CACnC;EACE,IAAI;EACJ,OAAO;EACP,KAAK;GACH;IACE,KAAK;IACL,OAAO;IACP,aAAa;IACb,QAAQ;IACR,UAAU;IACV,aACE;GACJ;GACA;IACE,KAAK;IACL,OAAO;IACP,aAAa;IACb,QAAQ;IACR,UAAU;IACV,aACE;GACJ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A,IAAIH,GACF,KAAK,IAAMG,KAAQjE,EACjBsD,IACAN,EAAS,IACT,uBACF,GACE,EAAQ,IAAIiB,EAAK,MAAMA,CAAI;CAI/B,IAAMC,IAAa,CAAC,GAAIhB,EAAWF,EAAS,OAAO,CAAC,CAAE;CAGtD,OAFIc,KAAad,EAAS,OAAO,YAAUkB,EAAW,KAAK,cAAc,GAElE;EACL,SAAS,CAAC,GAAGH,EAAQ,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,MAAMI,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC;EAC1E,UAAU,CAAC;EACX,SAAS,CAAC;EACV;EACA,UAAUjB,EAASH,EAAS,OAAO,CAAC;EACpC,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,62 +1,69 @@
|
|
|
1
1
|
import { a as e, r as t } from "./util-BLYliuUK.js";
|
|
2
2
|
import { t as n } from "./providers-CL9kQ4hp.js";
|
|
3
|
-
import { A as r, B as i, C as a, D as o, E as s, F as c,
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as
|
|
3
|
+
import { A as r, B as i, C as a, D as o, E as s, F as c, G as l, H as u, I as d, K as f, L as p, M as m, N as h, O as g, P as _, R as v, S as y, T as b, U as x, V as S, W as C, _ as w, b as T, c as E, d as D, f as ee, g as O, h as k, i as A, j, k as M, l as N, m as P, n as F, p as I, s as L, t as R, u as z, v as B, w as V, x as H, y as U, z as W } from "./currency.server-Bb2Ndutg.js";
|
|
4
|
+
import { t as G } from "./stripe-customer-B3tP8gtD.js";
|
|
5
|
+
import { n as K, t as q } from "./_page-DoPdZgZv.js";
|
|
6
6
|
//#region src/patterns/disable/payments/generate.ts
|
|
7
|
-
var
|
|
8
|
-
"../../enable/payments/providers/shopify/src/lib/components/payments/buy-button.svelte":
|
|
9
|
-
"../../enable/payments/providers/shopify/src/lib/shopify.ts":
|
|
10
|
-
"../../enable/payments/providers/stripe/src/lib/components/payments/confirm-dialog.svelte":
|
|
11
|
-
"../../enable/payments/providers/stripe/src/lib/components/payments/payment-button.svelte":
|
|
12
|
-
"../../enable/payments/providers/stripe/src/lib/components/payments/payment-dialog.svelte":
|
|
13
|
-
"../../enable/payments/providers/stripe/src/lib/components/payments/stripe-constants.ts":
|
|
14
|
-
"../../enable/payments/providers/stripe/src/lib/components/payments/stripe-payment-form.svelte":
|
|
15
|
-
"../../enable/payments/providers/stripe/src/lib/components/payments/use-payment-intent.svelte.ts":
|
|
16
|
-
"../../enable/payments/providers/stripe/src/lib/components/payments/use-stripe.svelte.ts":
|
|
17
|
-
"../../enable/payments/providers/stripe/src/lib/stripe.ts":
|
|
18
|
-
"../../enable/payments/providers/stripe/src/lib/workflows/stripe-event.ts":
|
|
19
|
-
"../../enable/payments/providers/stripe/src/lib/workflows/sync-stripe-catalog.ts":
|
|
20
|
-
"../../enable/payments/providers/stripe/src/routes/api/stripe/payment-intent/+server.ts":
|
|
7
|
+
var J = /* #__PURE__ */ Object.assign({
|
|
8
|
+
"../../enable/payments/providers/shopify/src/lib/components/payments/buy-button.svelte": C,
|
|
9
|
+
"../../enable/payments/providers/shopify/src/lib/shopify.ts": x,
|
|
10
|
+
"../../enable/payments/providers/stripe/src/lib/components/payments/confirm-dialog.svelte": u,
|
|
11
|
+
"../../enable/payments/providers/stripe/src/lib/components/payments/payment-button.svelte": S,
|
|
12
|
+
"../../enable/payments/providers/stripe/src/lib/components/payments/payment-dialog.svelte": i,
|
|
13
|
+
"../../enable/payments/providers/stripe/src/lib/components/payments/stripe-constants.ts": W,
|
|
14
|
+
"../../enable/payments/providers/stripe/src/lib/components/payments/stripe-payment-form.svelte": v,
|
|
15
|
+
"../../enable/payments/providers/stripe/src/lib/components/payments/use-payment-intent.svelte.ts": p,
|
|
16
|
+
"../../enable/payments/providers/stripe/src/lib/components/payments/use-stripe.svelte.ts": d,
|
|
17
|
+
"../../enable/payments/providers/stripe/src/lib/stripe.ts": c,
|
|
18
|
+
"../../enable/payments/providers/stripe/src/lib/workflows/stripe-event.ts": _,
|
|
19
|
+
"../../enable/payments/providers/stripe/src/lib/workflows/sync-stripe-catalog.ts": h,
|
|
20
|
+
"../../enable/payments/providers/stripe/src/routes/api/stripe/payment-intent/+server.ts": m,
|
|
21
21
|
"../../enable/payments/providers/stripe/src/routes/api/stripe/payment-intent/server.test.ts": j,
|
|
22
|
-
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/+server.ts":
|
|
23
|
-
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/dispatch.ts":
|
|
24
|
-
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
25
|
-
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
26
|
-
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/server.test.ts":
|
|
27
|
-
"../../enable/payments/providers/whatsapp/src/lib/components/payments/customer-fields.svelte":
|
|
28
|
-
"../../enable/payments/providers/whatsapp/src/lib/components/payments/order-button.svelte":
|
|
29
|
-
"../../enable/payments/providers/whatsapp/src/lib/order.test.ts":
|
|
30
|
-
"../../enable/payments/providers/whatsapp/src/lib/order.ts":
|
|
22
|
+
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/+server.ts": r,
|
|
23
|
+
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/dispatch.ts": M,
|
|
24
|
+
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": g,
|
|
25
|
+
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": o,
|
|
26
|
+
"../../enable/payments/providers/stripe/src/routes/webhooks/stripe/server.test.ts": s,
|
|
27
|
+
"../../enable/payments/providers/whatsapp/src/lib/components/payments/customer-fields.svelte": b,
|
|
28
|
+
"../../enable/payments/providers/whatsapp/src/lib/components/payments/order-button.svelte": V,
|
|
29
|
+
"../../enable/payments/providers/whatsapp/src/lib/order.test.ts": a,
|
|
30
|
+
"../../enable/payments/providers/whatsapp/src/lib/order.ts": y,
|
|
31
31
|
"../../enable/payments/providers-app-mode/stripe/src/lib/components/payments/setup-button.svelte": H,
|
|
32
|
-
"../../enable/payments/providers-app-mode/stripe/src/lib/components/payments/setup-dialog.svelte":
|
|
33
|
-
"../../enable/payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts":
|
|
34
|
-
"../../enable/payments/providers-app-mode/stripe/src/lib/workflows/link-stripe-customer.ts":
|
|
35
|
-
"../../enable/payments/providers-app-mode/stripe/src/lib/workflows/sync-stripe-customers.ts":
|
|
36
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+layout.server.ts":
|
|
37
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.server.ts":
|
|
38
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.svelte":
|
|
39
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/README.md":
|
|
40
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/payment-intent/+server.ts":
|
|
41
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/payment-intent/server.test.ts":
|
|
42
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/setup-intent/+server.ts":
|
|
43
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/setup-intent/server.test.ts":
|
|
44
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/dispatch.ts":
|
|
45
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts":
|
|
46
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts":
|
|
47
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-method/attached.ts":
|
|
48
|
-
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts":
|
|
49
|
-
}),
|
|
50
|
-
"../../enable/payments/creates/src/lib/components/currency-select.svelte":
|
|
51
|
-
"../../enable/payments/creates/src/lib/currency.svelte.ts":
|
|
52
|
-
}),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
"../../enable/payments/providers-app-mode/stripe/src/lib/components/payments/setup-dialog.svelte": T,
|
|
33
|
+
"../../enable/payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts": G,
|
|
34
|
+
"../../enable/payments/providers-app-mode/stripe/src/lib/workflows/link-stripe-customer.ts": U,
|
|
35
|
+
"../../enable/payments/providers-app-mode/stripe/src/lib/workflows/sync-stripe-customers.ts": B,
|
|
36
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+layout.server.ts": w,
|
|
37
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.server.ts": K,
|
|
38
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.svelte": q,
|
|
39
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/README.md": O,
|
|
40
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/payment-intent/+server.ts": k,
|
|
41
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/payment-intent/server.test.ts": P,
|
|
42
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/setup-intent/+server.ts": I,
|
|
43
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/setup-intent/server.test.ts": ee,
|
|
44
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/dispatch.ts": D,
|
|
45
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": z,
|
|
46
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": N,
|
|
47
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": E,
|
|
48
|
+
"../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": L
|
|
49
|
+
}), Y = /* #__PURE__ */ Object.assign({
|
|
50
|
+
"../../enable/payments/creates/src/lib/components/currency-select.svelte": f,
|
|
51
|
+
"../../enable/payments/creates/src/lib/currency.svelte.ts": l
|
|
52
|
+
}), X = /* #__PURE__ */ Object.assign({
|
|
53
|
+
"../../enable/payments/creates-server/src/lib/currency.server.test.ts": F,
|
|
54
|
+
"../../enable/payments/creates-server/src/lib/currency.server.ts": R
|
|
55
|
+
}), Z = "src/routes/(public)/payment/+page.svelte";
|
|
56
|
+
function Q(e) {
|
|
57
|
+
let t = e.providers?.payments, n = A.filter((e) => e.id === t);
|
|
58
|
+
return n.length > 0 ? n : A;
|
|
56
59
|
}
|
|
57
|
-
async function
|
|
58
|
-
let i = /* @__PURE__ */ new Set([
|
|
59
|
-
|
|
60
|
+
async function $(r) {
|
|
61
|
+
let i = /* @__PURE__ */ new Set([
|
|
62
|
+
Z,
|
|
63
|
+
...Object.keys(t(Y, "../../enable/payments/creates/")),
|
|
64
|
+
...Object.keys(t(X, "../../enable/payments/creates-server/"))
|
|
65
|
+
]);
|
|
66
|
+
for (let e of Q(r)) for (let t of n(J, e.id)) i.add(t);
|
|
60
67
|
return {
|
|
61
68
|
creates: [],
|
|
62
69
|
modifies: [],
|
|
@@ -74,6 +81,6 @@ async function Z(r) {
|
|
|
74
81
|
};
|
|
75
82
|
}
|
|
76
83
|
//#endregion
|
|
77
|
-
export {
|
|
84
|
+
export { Q as n, $ as t };
|
|
78
85
|
|
|
79
|
-
//# sourceMappingURL=generate-
|
|
86
|
+
//# sourceMappingURL=generate-B-cqjI-U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-B-cqjI-U.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","__import_glob__0_7_","__import_glob__0_8_","__import_glob__0_9_","__import_glob__0_10_","__import_glob__0_11_","__import_glob__0_12_","__import_glob__0_13_","__import_glob__0_14_","__import_glob__0_15_","__import_glob__0_16_","__import_glob__0_17_","__import_glob__0_18_","__import_glob__0_19_","__import_glob__0_20_","__import_glob__0_21_","__import_glob__0_22_","__import_glob__0_23_","__import_glob__0_24_","__import_glob__0_25_","__import_glob__0_26_","__import_glob__0_27_","__import_glob__0_28_","__import_glob__0_29_","__import_glob__0_30_","__import_glob__0_31_","__import_glob__0_32_","__import_glob__0_33_","__import_glob__0_34_","__import_glob__0_35_","__import_glob__0_36_","__import_glob__0_37_","__import_glob__0_38_","__import_glob__0_39_","__import_glob__0_40_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__2_0_","__import_glob__2_1_","languageFromPath","filesFromGlob","allProviderPaths","_server_default$1","payment_dialog_default","order_test_default","succeeded_default","server_test_default$2","stripe_default","currency_svelte_default","confirm_dialog_default","use_stripe_svelte_default","currency_select_default","use_payment_intent_svelte_default","_server_default","sync_stripe_catalog_default","server_test_default$1","stripe_event_default","stripe_payment_form_default","order_default","customer_fields_default","shopify_default","payment_button_default","buy_button_default","_layout_server_default","setup_dialog_default","attached_default","dispatch_default$1","server_test_default$4","README_default","_server_default$2","PROVIDERS","dispatch_default","succeeded_default$1","server_test_default$3","currency_server_test_default","_server_default$3","server_test_default$6","currency_server_default","server_test_default$5","sync_stripe_customers_default","order_button_default","setup_button_default","link_stripe_customer_default","stripe_constants_default","stripe_customer_default","_page_server_default","_page_default","providersRaw","server_test_default","createsRaw","createsServerRaw","DEMO_PAGE","providersToRemove","detected","options","match","provider","generate","paths","path"],"sources":["../../src/patterns/disable/payments/generate.ts"],"sourcesContent":["import type { File, Options, Provider, Result } from \"../../../core/types\";\nimport { allProviderPaths } from \"../../../core/providers\";\nimport { filesFromGlob, languageFromPath } from \"../../../core/util\";\nimport { PROVIDERS } from \"../../enable/payments/generate\";\n\nconst providersRaw = import.meta.glob<string>(\n [\n \"../../enable/payments/providers/**\",\n \"../../enable/payments/providers-app-mode/**\",\n ],\n { query: \"?raw\", import: \"default\", eager: true },\n);\n\n// Shared by every provider: the currency store and its select, and the server\n// half enable-payments adds to a project with a server load.\nconst createsRaw = import.meta.glob<string>(\n \"../../enable/payments/creates/**\",\n { query: \"?raw\", import: \"default\", eager: true },\n);\nconst createsServerRaw = import.meta.glob<string>(\n \"../../enable/payments/creates-server/**\",\n { query: \"?raw\", import: \"default\", eager: true },\n);\n\n// The demo page enable-payments writes at runtime (it carries the price or\n// variant id), so it is in no template tree: without the payment components it\n// would no longer build.\nconst DEMO_PAGE = \"src/routes/(public)/payment/+page.svelte\";\n\n/**\n * The provider whose files to remove: the one detected, else every one.\n * Removing every provider's files is safe, since a missing path is skipped.\n */\nexport function providersToRemove(\n options: Pick<Options, \"providers\">,\n): Provider[] {\n const detected = options.providers?.payments;\n const match = PROVIDERS.filter((provider) => provider.id === detected);\n return match.length > 0 ? match : PROVIDERS;\n}\n\nexport async function generate(options: Options) {\n // Both the plain and the app-mode files go, whatever auth is now: auth may\n // have been turned on or off since payments was enabled.\n const paths = new Set([\n DEMO_PAGE,\n ...Object.keys(filesFromGlob(createsRaw, \"../../enable/payments/creates/\")),\n ...Object.keys(\n filesFromGlob(createsServerRaw, \"../../enable/payments/creates-server/\"),\n ),\n ]);\n for (const provider of providersToRemove(options)) {\n for (const path of allProviderPaths(providersRaw, provider.id)) {\n paths.add(path);\n }\n }\n\n const deletes: File[] = [...paths].sort().map((path) => ({\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n }));\n\n return {\n creates: [],\n modifies: [],\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;AAKA,IAAM6F,IAAe,uBAAA,OAAA;CAAA,yFAAA7F;CAAA,8DAAA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,SAAS,CAAC;EACV,UAAU,CAAC;EACX,SAVsB,CAAC,GAAGD,CAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,OAAU;GACvD;GACA,UAAU3D,EAAiB4D,CAAI;GAC/B,SAAS;GACT,QAAQ;EACV,EAKE;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { r as e } from "./util-BLYliuUK.js";
|
|
2
|
+
//#region src/patterns/enable/ecommerce/providers/stripe/src/routes/(public)/checkout/success/+page.server.ts?raw
|
|
3
|
+
var t = "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", n = "<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", r = "import type Stripe from 'stripe';\nimport { syncOrder } from './shared';\n\n/**\n * `checkout.session.async_payment_succeeded` and `_failed`: a payment that\n * settles after Checkout (a bank debit, a voucher) is now final either way,\n * and the order's status follows the session's.\n */\nexport async function handleCheckoutAsyncPayment(\n session: Stripe.Checkout.Session,\n locals: App.Locals\n) {\n await syncOrder(session, locals);\n}\n", i = "import type Stripe from 'stripe';\nimport { syncOrder } from './shared';\n\n/** `checkout.session.completed`: the buyer finished Checkout; the payment may still be settling. */\nexport async function handleCheckoutSessionCompleted(\n session: Stripe.Checkout.Session,\n locals: App.Locals\n) {\n await syncOrder(session, locals);\n}\n", a = "import { beforeAll, describe, expect, it } from 'vitest';\nimport type Stripe from 'stripe';\nimport stripe from '#lib/stripe.js';\nimport { handleCheckoutSessionCompleted } from './completed';\n\n/**\n * A real test-mode Checkout Session stands in for the webhook's payload: its\n * line items come from Stripe either way, and an unpaid session lists them\n * just as a paid one does.\n */\ndescribe('checkout.session.completed', () => {\n let session: Stripe.Checkout.Session;\n\n beforeAll(async () => {\n const name = 'Test Product - Orders';\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 const price =\n (await stripe.prices.list({ product: product.id, active: true, limit: 1 })).data[0] ??\n (await stripe.prices.create({ product: product.id, unit_amount: 1500, currency: 'usd' }));\n session = await stripe.checkout.sessions.create({\n mode: 'payment',\n line_items: [{ price: price.id, quantity: 2 }],\n success_url: 'https://example.com/checkout/success',\n cancel_url: 'https://example.com/cart'\n });\n });\n\n it('records the order and its lines, and a redelivery updates them', async (context) => {\n await handleCheckoutSessionCompleted(session, { admin: context.admin } as App.Locals);\n\n const order = await context.admin.collection('orders').getOne(session.id);\n expect(order.status).toBe('unpaid');\n expect(order.amount_total).toBe(3000);\n expect(order.currency).toBe('USD');\n\n const lines = await context.admin.collection('order_lines').getFullList({\n filter: context.admin.filter('order = {:order}', { order: session.id })\n });\n expect(lines).toHaveLength(1);\n expect(lines[0].quantity).toBe(2);\n expect(lines[0].unit_amount).toBe(1500);\n expect(lines[0].name).toBe('Test Product - Orders');\n\n await handleCheckoutSessionCompleted(session, { admin: context.admin } as App.Locals);\n expect(\n await context.admin.collection('order_lines').getFullList({\n filter: context.admin.filter('order = {:order}', { order: session.id })\n })\n ).toHaveLength(1);\n\n // The lines go with the order.\n await context.admin.collection('orders').delete(session.id);\n });\n});\n", o = "import type Stripe from 'stripe';\nimport type { RecordModel } from 'pocketbase';\nimport stripe from '#lib/stripe.js';\n\n/**\n * What a Checkout Session becomes in `orders`: keyed by the session id, so a\n * redelivered or replayed event updates the row it already made. `status` is\n * Stripe's `payment_status` (`paid`, `unpaid`, `no_payment_required`); an\n * order whose payment clears later (a bank debit) is created `unpaid` and\n * updated by the async payment event.\n */\nexport function orderRecordFields(session: Stripe.Checkout.Session) {\n const paymentIntent =\n typeof session.payment_intent === 'string'\n ? session.payment_intent\n : (session.payment_intent?.id ?? null);\n return {\n status: session.payment_status,\n amount_total: session.amount_total ?? 0,\n currency: (session.currency ?? '').toUpperCase(),\n email: session.customer_details?.email ?? null,\n payment_intent: paymentIntent\n };\n}\n\n/**\n * Records the session as an order with its lines, from Stripe's own line\n * items (the webhook payload carries none). Returns the stored order.\n */\nexport async function syncOrder(\n session: Stripe.Checkout.Session,\n locals: App.Locals\n): Promise<RecordModel> {\n const orders = locals.admin.collection('orders');\n const fields = orderRecordFields(session);\n let order: RecordModel;\n try {\n order = await orders.update(session.id, fields);\n } catch {\n order = await orders.create({ id: session.id, ...fields });\n }\n\n const lines = locals.admin.collection('order_lines');\n for await (const line of stripe.checkout.sessions.listLineItems(session.id, {\n limit: 100,\n expand: ['data.price.product']\n })) {\n const product = line.price?.product;\n const lineFields = {\n order: session.id,\n price: line.price?.id ?? null,\n product: typeof product === 'string' ? product : (product?.id ?? null),\n name: line.description,\n unit_amount: line.price?.unit_amount ?? null,\n quantity: line.quantity ?? 1,\n amount_total: line.amount_total,\n currency: line.currency.toUpperCase()\n };\n try {\n await lines.update(line.id, lineFields);\n } catch {\n await lines.create({ id: line.id, ...lineFields });\n }\n }\n return order;\n}\n", s = "import { redirect } from '@sveltejs/kit';\n\n/** The fields of an order this page reads. */\ninterface OrderRecord {\n id: string;\n status: string;\n amount_total: number;\n currency: string;\n created: string;\n}\n\n/** The signed-in user's orders, newest first. */\nexport const load = async ({ locals, parent }) => {\n const { user } = await parent();\n if (!user) redirect(303, '/login');\n\n const orders = await locals.admin.collection('orders').getFullList<OrderRecord>({\n filter: locals.admin.filter('user = {:user}', { user: user.id }),\n sort: '-created'\n });\n\n return {\n orders: orders.map((order) => ({\n id: order.id,\n status: order.status,\n amountTotal: order.amount_total,\n currency: order.currency,\n created: order.created\n }))\n };\n};\n", c = "<script lang=\"ts\">\n import * as Card from '#lib/components/ui/card/index.js';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import { formatAmount } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n\n const when = (iso: string) =>\n new Date(iso).toLocaleDateString(undefined, { dateStyle: 'medium' });\n<\/script>\n\n<div class=\"flex flex-col gap-6\">\n <div>\n <h1 class=\"text-2xl font-semibold\">Orders</h1>\n <p class=\"text-muted-foreground text-sm\">What you have bought here.</p>\n </div>\n\n {#if data.orders.length === 0}\n <p class=\"text-muted-foreground text-sm\">No orders yet.</p>\n {:else}\n <Card.Root>\n <Card.Content class=\"p-0\">\n <ul class=\"divide-y\">\n {#each data.orders as order (order.id)}\n <li>\n <a\n href=\"/orders/{order.id}\"\n class=\"hover:bg-muted/50 flex items-center justify-between gap-4 px-6 py-4\"\n >\n <div class=\"flex flex-col\">\n <span class=\"font-medium\">{when(order.created)}</span>\n <span class=\"text-muted-foreground text-xs\">{order.id}</span>\n </div>\n <div class=\"flex items-center gap-3\">\n <Badge variant={order.status === 'paid' ? 'default' : 'secondary'}>\n {order.status === 'paid' ? 'Paid' : 'Pending'}\n </Badge>\n <span class=\"font-medium\">{formatAmount(order.amountTotal, order.currency)}</span>\n </div>\n </a>\n </li>\n {/each}\n </ul>\n </Card.Content>\n </Card.Root>\n {/if}\n</div>\n", l = "import { error, redirect } from '@sveltejs/kit';\n\ninterface OrderRecord {\n id: string;\n status: string;\n amount_total: number;\n currency: string;\n email: string | null;\n user: string;\n created: string;\n}\n\ninterface OrderLineRecord {\n id: string;\n name: string;\n quantity: number;\n unit_amount: number | null;\n amount_total: number;\n currency: string;\n}\n\n/** One of the signed-in user's orders, with its lines. Anyone else's is not found. */\nexport const load = async ({ locals, params, parent }) => {\n const { user } = await parent();\n if (!user) redirect(303, '/login');\n\n const order = await locals.admin\n .collection('orders')\n .getOne<OrderRecord>(params.id)\n .catch(() => null);\n if (!order || order.user !== user.id) error(404, 'Not found');\n\n const lines = await locals.admin.collection('order_lines').getFullList<OrderLineRecord>({\n filter: locals.admin.filter('order = {:order}', { order: order.id }),\n sort: 'created'\n });\n\n return {\n order: {\n id: order.id,\n status: order.status,\n amountTotal: order.amount_total,\n currency: order.currency,\n email: order.email,\n created: order.created\n },\n lines: lines.map((line) => ({\n id: line.id,\n name: line.name,\n quantity: line.quantity,\n unitAmount: line.unit_amount,\n amountTotal: line.amount_total,\n currency: line.currency\n }))\n };\n};\n", u = "<script lang=\"ts\">\n import * as Card from '#lib/components/ui/card/index.js';\n import { Badge } from '#lib/components/ui/badge/index.js';\n import { Separator } from '#lib/components/ui/separator/index.js';\n import { formatAmount } from '#lib/cart.svelte.js';\n\n let { data } = $props();\n\n const when = new Date(data.order.created).toLocaleDateString(undefined, { dateStyle: 'long' });\n<\/script>\n\n<div class=\"flex flex-col gap-6\">\n <div>\n <p class=\"text-muted-foreground mb-2 text-sm\"><a href=\"/orders\">Orders</a></p>\n <h1 class=\"text-2xl font-semibold\">Order of {when}</h1>\n <p class=\"text-muted-foreground text-xs\">{data.order.id}</p>\n </div>\n\n <Card.Root>\n <Card.Header class=\"flex flex-row items-center justify-between\">\n <Card.Title>Items</Card.Title>\n <Badge variant={data.order.status === 'paid' ? 'default' : 'secondary'}>\n {data.order.status === 'paid' ? 'Paid' : 'Pending'}\n </Badge>\n </Card.Header>\n <Card.Content class=\"flex flex-col gap-4\">\n <ul class=\"divide-y\">\n {#each data.lines as line (line.id)}\n <li class=\"flex items-center justify-between gap-4 py-3\">\n <div class=\"flex flex-col\">\n <span class=\"font-medium\">{line.name}</span>\n {#if line.unitAmount !== null}\n <span class=\"text-muted-foreground text-sm\">\n {line.quantity} × {formatAmount(line.unitAmount, line.currency)}\n </span>\n {/if}\n </div>\n <span>{formatAmount(line.amountTotal, line.currency)}</span>\n </li>\n {/each}\n </ul>\n <Separator />\n <div class=\"flex justify-between font-medium\">\n <span>Total</span>\n <span>{formatAmount(data.order.amountTotal, data.order.currency)}</span>\n </div>\n </Card.Content>\n </Card.Root>\n</div>\n", d = "import type Stripe from 'stripe';\nimport type { RecordModel } from 'pocketbase';\nimport stripe from '#lib/stripe.js';\n\n/**\n * What a Checkout Session becomes in `orders`: keyed by the session id, so a\n * redelivered or replayed event updates the row it already made. `status` is\n * Stripe's `payment_status` (`paid`, `unpaid`, `no_payment_required`); an\n * order whose payment clears later (a bank debit) is created `unpaid` and\n * updated by the async payment event.\n *\n * A signed-in buyer checked out as their Stripe customer, which\n * `stripe_customers` maps back to the user; a guest has only an email.\n */\nexport async function orderRecordFields(session: Stripe.Checkout.Session, locals: App.Locals) {\n const paymentIntent =\n typeof session.payment_intent === 'string'\n ? session.payment_intent\n : (session.payment_intent?.id ?? null);\n const customerId =\n typeof session.customer === 'string' ? session.customer : (session.customer?.id ?? null);\n const customer = customerId\n ? await locals.admin\n .collection('stripe_customers')\n .getOne<{ id: string; user: string }>(customerId)\n .catch(() => null)\n : null;\n return {\n status: session.payment_status,\n amount_total: session.amount_total ?? 0,\n currency: (session.currency ?? '').toUpperCase(),\n email: session.customer_details?.email ?? null,\n payment_intent: paymentIntent,\n customer: customer?.id ?? null,\n user: customer?.user ?? null\n };\n}\n\n/**\n * Records the session as an order with its lines, from Stripe's own line\n * items (the webhook payload carries none). Returns the stored order.\n */\nexport async function syncOrder(\n session: Stripe.Checkout.Session,\n locals: App.Locals\n): Promise<RecordModel> {\n const orders = locals.admin.collection('orders');\n const fields = await orderRecordFields(session, locals);\n let order: RecordModel;\n try {\n order = await orders.update(session.id, fields);\n } catch {\n order = await orders.create({ id: session.id, ...fields });\n }\n\n const lines = locals.admin.collection('order_lines');\n for await (const line of stripe.checkout.sessions.listLineItems(session.id, {\n limit: 100,\n expand: ['data.price.product']\n })) {\n const product = line.price?.product;\n const lineFields = {\n order: session.id,\n price: line.price?.id ?? null,\n product: typeof product === 'string' ? product : (product?.id ?? null),\n name: line.description,\n unit_amount: line.price?.unit_amount ?? null,\n quantity: line.quantity ?? 1,\n amount_total: line.amount_total,\n currency: line.currency.toUpperCase()\n };\n try {\n await lines.update(line.id, lineFields);\n } catch {\n await lines.create({ id: line.id, ...lineFields });\n }\n }\n return order;\n}\n", f = "import type Stripe from 'stripe';\nimport { notify } from '#lib/server/notifications.js';\nimport { formatAmount } from '#lib/cart.svelte.js';\nimport { syncOrder } from './shared';\n\n/**\n * `checkout.session.completed`: the buyer finished Checkout; the payment may\n * still be settling. A signed-in buyer gets a notification once it is paid.\n */\nexport async function handleCheckoutSessionCompleted(\n session: Stripe.Checkout.Session,\n locals: App.Locals\n) {\n const order = await syncOrder(session, locals);\n if (order.user && order.status === 'paid') {\n await notify(locals.admin, order.user, {\n title: 'Order received',\n body: `Your order of ${formatAmount(order.amount_total, order.currency)} is confirmed.`\n });\n }\n}\n", p = /* #__PURE__ */ Object.assign({
|
|
4
|
+
"./creates/src/routes/webhooks/stripe/handlers/checkout/async-payment.ts": r,
|
|
5
|
+
"./creates/src/routes/webhooks/stripe/handlers/checkout/completed.ts": i,
|
|
6
|
+
"./creates/src/routes/webhooks/stripe/handlers/checkout/server.test.ts": a,
|
|
7
|
+
"./creates/src/routes/webhooks/stripe/handlers/checkout/shared.ts": o
|
|
8
|
+
}), m = /* #__PURE__ */ Object.assign({
|
|
9
|
+
"./creates-app-mode/src/routes/(app)/orders/+page.server.ts": s,
|
|
10
|
+
"./creates-app-mode/src/routes/(app)/orders/+page.svelte": c,
|
|
11
|
+
"./creates-app-mode/src/routes/(app)/orders/[id]/+page.server.ts": l,
|
|
12
|
+
"./creates-app-mode/src/routes/(app)/orders/[id]/+page.svelte": u,
|
|
13
|
+
"./creates-app-mode/src/routes/webhooks/stripe/handlers/checkout/shared.ts": d
|
|
14
|
+
}), h = /* #__PURE__ */ Object.assign({ "./creates-notifications/src/routes/webhooks/stripe/handlers/checkout/completed.ts": f }), g = ["orders", "order_lines"];
|
|
15
|
+
function _(e) {
|
|
16
|
+
return {
|
|
17
|
+
name: "orders",
|
|
18
|
+
type: "base",
|
|
19
|
+
fields: [
|
|
20
|
+
{
|
|
21
|
+
name: "id",
|
|
22
|
+
pattern: "^[a-zA-Z0-9_]+$",
|
|
23
|
+
primaryKey: !0,
|
|
24
|
+
required: !0,
|
|
25
|
+
system: !0,
|
|
26
|
+
type: "text"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "status",
|
|
30
|
+
required: !0,
|
|
31
|
+
type: "text"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "amount_total",
|
|
35
|
+
required: !1,
|
|
36
|
+
type: "number"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "currency",
|
|
40
|
+
required: !1,
|
|
41
|
+
type: "text"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "email",
|
|
45
|
+
required: !1,
|
|
46
|
+
type: "text"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "payment_intent",
|
|
50
|
+
required: !1,
|
|
51
|
+
type: "text"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "customer",
|
|
55
|
+
required: !1,
|
|
56
|
+
type: "text"
|
|
57
|
+
},
|
|
58
|
+
...e ? [{
|
|
59
|
+
collectionId: "_pb_users_auth_",
|
|
60
|
+
maxSelect: 1,
|
|
61
|
+
minSelect: 0,
|
|
62
|
+
name: "user",
|
|
63
|
+
required: !1,
|
|
64
|
+
type: "relation"
|
|
65
|
+
}] : [],
|
|
66
|
+
{
|
|
67
|
+
name: "created",
|
|
68
|
+
onCreate: !0,
|
|
69
|
+
onUpdate: !1,
|
|
70
|
+
type: "autodate"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "updated",
|
|
74
|
+
onCreate: !0,
|
|
75
|
+
onUpdate: !0,
|
|
76
|
+
type: "autodate"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
var v = {
|
|
82
|
+
name: "order_lines",
|
|
83
|
+
type: "base",
|
|
84
|
+
fields: [
|
|
85
|
+
{
|
|
86
|
+
name: "id",
|
|
87
|
+
pattern: "^[a-zA-Z0-9_]+$",
|
|
88
|
+
primaryKey: !0,
|
|
89
|
+
required: !0,
|
|
90
|
+
system: !0,
|
|
91
|
+
type: "text"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
collectionId: "orders",
|
|
95
|
+
maxSelect: 1,
|
|
96
|
+
minSelect: 0,
|
|
97
|
+
name: "order",
|
|
98
|
+
required: !0,
|
|
99
|
+
type: "relation",
|
|
100
|
+
cascadeDelete: !0
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "price",
|
|
104
|
+
required: !1,
|
|
105
|
+
type: "text"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "product",
|
|
109
|
+
required: !1,
|
|
110
|
+
type: "text"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "name",
|
|
114
|
+
required: !1,
|
|
115
|
+
type: "text"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "unit_amount",
|
|
119
|
+
required: !1,
|
|
120
|
+
type: "number"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "quantity",
|
|
124
|
+
required: !1,
|
|
125
|
+
type: "number"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "amount_total",
|
|
129
|
+
required: !1,
|
|
130
|
+
type: "number"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "currency",
|
|
134
|
+
required: !1,
|
|
135
|
+
type: "text"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "created",
|
|
139
|
+
onCreate: !0,
|
|
140
|
+
onUpdate: !1,
|
|
141
|
+
type: "autodate"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "updated",
|
|
145
|
+
onCreate: !0,
|
|
146
|
+
onUpdate: !0,
|
|
147
|
+
type: "autodate"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
};
|
|
151
|
+
async function y(t) {
|
|
152
|
+
let n = t.features.auth, r = new Map(Object.values(e(p, "./creates/")).map((e) => [e.path, e]));
|
|
153
|
+
if (n) {
|
|
154
|
+
for (let t of Object.values(e(m, "./creates-app-mode/"))) r.set(t.path, t);
|
|
155
|
+
if (t.features.notifications) for (let t of Object.values(e(h, "./creates-notifications/"))) r.set(t.path, t);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
creates: [...r.values()].sort((e, t) => e.path.localeCompare(t.path)),
|
|
159
|
+
modifies: [],
|
|
160
|
+
deletes: [],
|
|
161
|
+
components: n ? [
|
|
162
|
+
"card",
|
|
163
|
+
"badge",
|
|
164
|
+
"separator"
|
|
165
|
+
] : [],
|
|
166
|
+
packages: [],
|
|
167
|
+
collections: [_(n), v],
|
|
168
|
+
collectionPatches: [],
|
|
169
|
+
collectionDrops: []
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { u as a, s as c, i as d, r as f, d as i, o as l, t as m, y as n, l as o, n as p, f as r, c as s, g as t, a as u };
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=generate-BrOPb9tW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-BrOPb9tW.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__1_2_","__import_glob__1_3_","__import_glob__1_4_","__import_glob__2_0_","filesFromGlob","_page_server_default$2","_page_default$2","async_payment_default","completed_default$1","server_test_default","shared_default$1","_page_server_default$1","_page_default$1","_page_server_default","_page_default","shared_default","completed_default","createsRaw","createsAppModeRaw","createsNotificationsRaw","ORDER_COLLECTIONS","orders","appMode","orderLines","generate","options","creates","file","a","b"],"sources":["../../src/patterns/enable/orders/generate.ts"],"sourcesContent":["import type { CollectionSpec, Options, Result } from \"../../../core/types\";\nimport { filesFromGlob } from \"../../../core/util\";\n\nconst createsRaw = import.meta.glob<string>(\"./creates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n// A signed-in buyer's orders: the user link on the record, and the pages\n// that list them.\nconst createsAppModeRaw = import.meta.glob<string>(\"./creates-app-mode/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n// With enable-notifications: a paid order drops a notification on its user.\nconst createsNotificationsRaw = import.meta.glob<string>(\n \"./creates-notifications/**\",\n { query: \"?raw\", import: \"default\", eager: true },\n);\n\n/** The collections in the order they are created, and dropped in reverse. */\nexport const ORDER_COLLECTIONS = [\"orders\", \"order_lines\"];\n\n/**\n * One row per Checkout Session, keyed by its id so Stripe's redeliveries and\n * replays update rather than duplicate. With auth, the buyer's user.\n */\nfunction orders(appMode: boolean): CollectionSpec {\n return {\n name: \"orders\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n // Stripe's payment_status: paid, unpaid, no_payment_required.\n { name: \"status\", required: true, type: \"text\" },\n { name: \"amount_total\", required: false, type: \"number\" },\n { name: \"currency\", required: false, type: \"text\" },\n { name: \"email\", required: false, type: \"text\" },\n { name: \"payment_intent\", required: false, type: \"text\" },\n // The Stripe customer id as text, not a relation: `stripe_customers`\n // exists only when payments came after auth, and a guest has none.\n { name: \"customer\", required: false, type: \"text\" },\n ...(appMode\n ? [\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: false,\n type: \"relation\",\n },\n ]\n : []),\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n };\n}\n\n/** A snapshot of each line as Stripe priced it, keyed by Stripe's line item id. */\nconst orderLines: CollectionSpec = {\n name: \"order_lines\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"orders\",\n maxSelect: 1,\n minSelect: 0,\n name: \"order\",\n required: true,\n type: \"relation\",\n cascadeDelete: true,\n },\n { name: \"price\", required: false, type: \"text\" },\n { name: \"product\", required: false, type: \"text\" },\n { name: \"name\", required: false, type: \"text\" },\n { name: \"unit_amount\", required: false, type: \"number\" },\n { name: \"quantity\", required: false, type: \"number\" },\n { name: \"amount_total\", required: false, type: \"number\" },\n { name: \"currency\", required: false, type: \"text\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n};\n\nexport async function generate(options: Options) {\n const appMode = options.features.auth;\n const creates = new Map(\n Object.values(filesFromGlob(createsRaw, \"./creates/\")).map((file) => [\n file.path,\n file,\n ]),\n );\n if (appMode) {\n for (const file of Object.values(\n filesFromGlob(createsAppModeRaw, \"./creates-app-mode/\"),\n )) {\n creates.set(file.path, file);\n }\n if (options.features.notifications) {\n for (const file of Object.values(\n filesFromGlob(createsNotificationsRaw, \"./creates-notifications/\"),\n )) {\n creates.set(file.path, file);\n }\n }\n }\n\n return {\n creates: [...creates.values()].sort((a, b) => a.path.localeCompare(b.path)),\n modifies: [],\n deletes: [],\n components: appMode ? [\"card\", \"badge\", \"separator\"] : [],\n packages: [],\n collections: [orders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