@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
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/patterns/enable/orders/preview-modifies/src/routes/(public)/checkout/success/+page.server.ts?raw
|
|
2
|
+
var e = "import { error } from '@sveltejs/kit';\nimport stripe from '#lib/stripe.js';\n\ninterface OrderRecord {\n status: string;\n amount_total: number;\n currency: string;\n}\n\ninterface OrderLineRecord {\n id: string;\n name: string;\n quantity: number;\n amount_total: number;\n currency: string;\n}\n\n/**\n * The order as the webhook recorded it, with its lines; until that event has\n * arrived (it usually has), Stripe's own summary of the session.\n */\nexport const load = async ({ url, locals }) => {\n const id = url.searchParams.get('session_id');\n if (!id) error(404, 'Not found');\n\n const order = await locals.admin\n .collection('orders')\n .getOne<OrderRecord>(id)\n .catch(() => null);\n if (order) {\n const lines = await locals.admin.collection('order_lines').getFullList<OrderLineRecord>({\n filter: locals.admin.filter('order = {:order}', { order: id }),\n sort: 'created'\n });\n return {\n amountTotal: order.amount_total,\n currency: order.currency,\n paid: order.status === 'paid',\n lines: lines.map((line) => ({\n id: line.id,\n name: line.name,\n quantity: line.quantity,\n amountTotal: line.amount_total,\n currency: line.currency\n }))\n };\n }\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 lines: []\n };\n } catch {\n error(404, 'Not found');\n }\n};\n", t = "<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\n {#if data.lines.length > 0}\n <ul class=\"mt-6 divide-y border-y\">\n {#each data.lines as line (line.id)}\n <li class=\"flex items-center justify-between gap-4 py-3 text-sm\">\n <span>{line.quantity} × {line.name}</span>\n <span>{formatAmount(line.amountTotal, line.currency)}</span>\n </li>\n {/each}\n </ul>\n {/if}\n</section>\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { e as n, t };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=_page-B6yd6_Vl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_page-B6yd6_Vl.js","names":["_page_server_default","_page_default"],"sources":[],"mappings":""}
|
|
@@ -124,6 +124,11 @@ var i = "users", a = "stripe_customers", o = "stripe_payment_methods", s = {
|
|
|
124
124
|
required: !1,
|
|
125
125
|
type: "text"
|
|
126
126
|
},
|
|
127
|
+
{
|
|
128
|
+
name: "currency_options",
|
|
129
|
+
required: !1,
|
|
130
|
+
type: "json"
|
|
131
|
+
},
|
|
127
132
|
{
|
|
128
133
|
name: "created",
|
|
129
134
|
onCreate: !0,
|
|
@@ -306,4 +311,4 @@ var i = "users", a = "stripe_customers", o = "stripe_payment_methods", s = {
|
|
|
306
311
|
//#endregion
|
|
307
312
|
export { r as a, s as i, f as n, c as r, p as t };
|
|
308
313
|
|
|
309
|
-
//# sourceMappingURL=collections-
|
|
314
|
+
//# sourceMappingURL=collections-DZOuRpvS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections-DZOuRpvS.js","names":["dedent","_templateObject","buyPageSnippet","_taggedTemplateLiteral","variantId","users","stripeCustomers","stripePaymentMethods","STRIPE_PRODUCTS","STRIPE_PRICES","stripeCustomersCollection","stripePaymentMethodsCollection","transactions","PAYMENTS_BASE_COLLECTIONS","PAYMENTS_APP_MODE_COLLECTIONS"],"sources":["../../src/patterns/enable/payments/shopify-page.ts","../../src/patterns/enable/payments/runtime/collections.ts"],"sourcesContent":["import dedent from \"dedent\";\n\n/** The demo page: one Buy button for the variant named on the command line. */\nexport function buyPageSnippet(variantId: string): string {\n return dedent`\n <script lang=\"ts\">\n import BuyButton from '#lib/components/payments/buy-button.svelte';\n </script>\n\n <section data-role=\"content\">\n <BuyButton variantId=\"${variantId}\" />\n </section>\n `;\n}\n","import type { CollectionSpec } from \"../../../../core/types\";\n\nconst users = \"users\";\nconst stripeCustomers = \"stripe_customers\";\nconst stripePaymentMethods = \"stripe_payment_methods\";\n\n/**\n * The Stripe catalog as `sync-stripe-catalog.ts` copies it: the fields the\n * payment and billing pages read, plus what a store page shows (description,\n * images, metadata, the product URL, a price's nickname and lookup key).\n * `setupStripe` creates these and adds any field an older project's\n * collection lacks.\n */\nexport const STRIPE_PRODUCTS: CollectionSpec = {\n name: \"stripe_products\",\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 { name: \"name\", required: false, type: \"text\" },\n { name: \"active\", required: false, type: \"text\" },\n { name: \"default_price\", required: false, type: \"text\" },\n { name: \"description\", required: false, type: \"text\" },\n // Stripe's list of image URLs, and its free-form key/value metadata.\n { name: \"images\", required: false, type: \"json\" },\n { name: \"metadata\", required: false, type: \"json\" },\n { name: \"url\", 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 const STRIPE_PRICES: CollectionSpec = {\n name: \"stripe_prices\",\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 { name: \"billing_scheme\", required: false, type: \"text\" },\n { name: \"currency\", required: false, type: \"text\" },\n { name: \"product\", required: false, type: \"text\" },\n { name: \"recurring\", required: false, type: \"json\" },\n { name: \"type\", required: false, type: \"text\" },\n { name: \"unit_amount\", required: false, type: \"number\" },\n { name: \"active\", required: false, type: \"bool\" },\n { name: \"nickname\", required: false, type: \"text\" },\n { name: \"lookup_key\", required: false, type: \"text\" },\n // Fixed amounts in other currencies, set in the dashboard: `{ eur: { unit_amount: 1800 } }`.\n { name: \"currency_options\", required: false, type: \"json\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n};\n\nconst stripeCustomersCollection: CollectionSpec = {\n name: stripeCustomers,\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n collectionId: users,\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n collectionId: stripePaymentMethods,\n maxSelect: 1,\n minSelect: 0,\n name: \"default_payment_method\",\n required: false,\n type: \"relation\",\n },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n};\n\nconst stripePaymentMethodsCollection: CollectionSpec = {\n name: stripePaymentMethods,\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"exp_month\", required: true, type: \"number\" },\n { name: \"exp_year\", required: true, type: \"number\" },\n {\n collectionId: stripeCustomers,\n maxSelect: 1,\n minSelect: 0,\n name: \"customer\",\n required: true,\n type: \"relation\",\n cascadeDelete: true,\n },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n};\n\nconst transactions: CollectionSpec = {\n name: \"transactions\",\n type: \"base\",\n fields: [\n {\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n { name: \"stripe_payment_intent\", required: true, type: \"text\" },\n { name: \"amount\", required: true, type: \"number\" },\n { name: \"currency\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"created\", required: true, type: \"date\" },\n { name: \"stripe_charge\", required: true, type: \"text\" },\n { name: \"stripe_customer\", required: true, type: \"text\" },\n {\n collectionId: users,\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n { name: \"receipt_url\", required: true, type: \"url\" },\n ],\n};\n\nexport const PAYMENTS_BASE_COLLECTIONS: CollectionSpec[] = [\n STRIPE_PRODUCTS,\n STRIPE_PRICES,\n];\n\nexport const PAYMENTS_APP_MODE_COLLECTIONS: CollectionSpec[] = [\n stripeCustomersCollection,\n stripePaymentMethodsCollection,\n transactions,\n];\n"],"mappings":";;;;AAGA,SAAgBE,EAAe,GAA2B;CACxD,OAAOF,EAAA,AAAAC,MAAAE,EAAA,CAAA,+LAAA,2BAAA,CAAA,GAMqBC,CAE5B;AACF;;;ACXA,IAAMC,IAAQ,SACRC,I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