@aglyn/plugins-commerce 1.24.0 → 1.25.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/package.json +13 -13
- package/src/lib/components/account.js +11 -2
- package/src/lib/components/account.js.map +1 -1
- package/src/lib/server/api-v1/openapi.js +6 -21
- package/src/lib/server/api-v1/openapi.js.map +1 -1
- package/src/lib/server/billing-webhook.js +18 -12
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/gift-card-issue.js +3 -1
- package/src/lib/server/gift-card-issue.js.map +1 -1
- package/src/lib/server/membership-recover.js +3 -2
- package/src/lib/server/membership-recover.js.map +1 -1
- package/src/lib/server/membership.js +12 -1
- package/src/lib/server/membership.js.map +1 -1
- package/src/lib/server/order-notifications.js +15 -0
- package/src/lib/server/order-notifications.js.map +1 -1
- package/src/lib/server/returns.js +3 -2
- package/src/lib/server/returns.js.map +1 -1
- package/src/lib/server/supplier-routing.js +7 -3
- package/src/lib/server/supplier-routing.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-commerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
31
|
-
"@aglyn/shared-ui-next": "1.
|
|
32
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
33
|
-
"@aglyn/shared-util-email": "1.
|
|
34
|
-
"@aglyn/shared-util-http": "1.
|
|
35
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
36
|
-
"@aglyn/shared-util-tools": "1.
|
|
37
|
-
"@aglyn/tenant-data-admin": "1.
|
|
38
|
-
"@aglyn/tenant-feature-instance": "1.
|
|
39
|
-
"@aglyn/tenant-runtime": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.25.0",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.25.0",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.25.0",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.25.0",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.25.0",
|
|
33
|
+
"@aglyn/shared-util-email": "1.25.0",
|
|
34
|
+
"@aglyn/shared-util-http": "1.25.0",
|
|
35
|
+
"@aglyn/shared-util-timestamp": "1.25.0",
|
|
36
|
+
"@aglyn/shared-util-tools": "1.25.0",
|
|
37
|
+
"@aglyn/tenant-data-admin": "1.25.0",
|
|
38
|
+
"@aglyn/tenant-feature-instance": "1.25.0",
|
|
39
|
+
"@aglyn/tenant-runtime": "1.25.0",
|
|
40
40
|
"@stripe/react-stripe-js": "^7.0.1",
|
|
41
41
|
"@stripe/stripe-js": "^10.2.1",
|
|
42
42
|
"@swc/helpers": "0.5.24",
|
|
@@ -18,6 +18,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
18
18
|
* limitations under the License.
|
|
19
19
|
*/ import * as Aglyn from "@aglyn/aglyn";
|
|
20
20
|
import { trackEvent } from "@aglyn/aglyn/app-utils/analytics-events";
|
|
21
|
+
import { markSignedIn } from "@aglyn/aglyn/app-utils/sign-in-visibility";
|
|
21
22
|
import * as CommerceModel from "../model/index.js";
|
|
22
23
|
import { mdiAccountCircleOutline } from "@aglyn/shared-data-mdi";
|
|
23
24
|
import Alert from "@mui/material/Alert";
|
|
@@ -70,8 +71,15 @@ const usd = (cents)=>`$${(cents / 100).toFixed(2)}`;
|
|
|
70
71
|
if (!hostId) return;
|
|
71
72
|
try {
|
|
72
73
|
const response = await fetch(`/api/membership/account?hostId=${encodeURIComponent(hostId)}`);
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
// What the session says is what the page shows (AGL-4231): elements
|
|
75
|
+
// shown to signed-in or signed-out visitors follow it here, without a
|
|
76
|
+
// reload, including a hint left behind by a session that has expired.
|
|
77
|
+
if (response.ok) {
|
|
78
|
+
const signedIn = await response.json();
|
|
79
|
+
markSignedIn(true);
|
|
80
|
+
return setAccount(signedIn);
|
|
81
|
+
}
|
|
82
|
+
if (response.status === 401) markSignedIn(false);
|
|
75
83
|
setAccount('anonymous');
|
|
76
84
|
} catch (unused) {
|
|
77
85
|
setAccount('anonymous');
|
|
@@ -168,6 +176,7 @@ const usd = (cents)=>`$${(cents / 100).toFixed(2)}`;
|
|
|
168
176
|
hostId
|
|
169
177
|
})
|
|
170
178
|
}).catch(()=>undefined);
|
|
179
|
+
markSignedIn(false);
|
|
171
180
|
setAccount('anonymous');
|
|
172
181
|
}, [
|
|
173
182
|
hostId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/account.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport * as CommerceModel from '../model'\nimport { mdiAccountCircleOutline } from '@aglyn/shared-data-mdi'\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Checkbox from '@mui/material/Checkbox'\nimport Chip from '@mui/material/Chip'\nimport Divider from '@mui/material/Divider'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport MuiLink from '@mui/material/Link'\nimport Tab from '@mui/material/Tab'\nimport Tabs from '@mui/material/Tabs'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport { forwardRef, lazy, Suspense, useCallback, useEffect, useState } from 'react'\nimport type { AccountSubscription } from './account-subscriptions'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { returnRequestHref } from '../constants/return-request'\nimport { generatePresetId } from '../utils/generate-preset-id'\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'customer-account'\n\nexport interface CustomerAccountProps {\n signedOutHeading?: string\n}\n\ninterface AccountData {\n member: {\n email: string\n displayName: string\n addresses: CommerceModel.OrderAddress[]\n }\n downloads?: Array<{\n orderId: string\n productId: string\n productName: string\n url: string\n licenseKeys?: string[]\n }>\n subscriptions?: AccountSubscription[]\n orders: Array<{\n id: string\n number: string\n status: string\n totalCents: number\n createdAtMs: number\n itemsSummary: string\n tracking?: { carrier?: string; trackingNumber?: string }\n }>\n}\n\nconst AccountSubscriptions = lazy(() => import('./account-subscriptions'))\n\nconst usd = (cents: number) => `$${(cents / 100).toFixed(2)}`\n\n/**\n * Customer account block (AGL-294): signed-out visitors get sign-in /\n * create-account forms on the AGL-109 membership APIs; signed-in\n * members see their profile, address book, and order history (status +\n * tracking) with sign-out. Session lives in the httpOnly member cookie.\n */\nconst CustomerAccount = forwardRef<HTMLDivElement, CustomerAccountProps>(\n (props, ref) => {\n const { signedOutHeading, ...rest } = props\n // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const { hostId } = Aglyn.useSite()\n const siteFetch = Aglyn.useSiteFetch()\n const [account, setAccount] = useState<AccountData | null | 'anonymous'>(\n null,\n )\n const [tab, setTab] = useState(0)\n const [email, setEmail] = useState('')\n const [password, setPassword] = useState('')\n const [displayName, setDisplayName] = useState('')\n const [marketingConsent, setMarketingConsent] = useState(false)\n const [error, setError] = useState('')\n const [busy, setBusy] = useState(false)\n const [addressDraft, setAddressDraft] = useState<CommerceModel.OrderAddress | null>(\n null,\n )\n\n const refresh = useCallback(async () => {\n if (!hostId) return\n try {\n const response = await fetch(\n `/api/membership/account?hostId=${encodeURIComponent(hostId)}`,\n )\n if (response.status === 401) return setAccount('anonymous')\n if (response.ok) return setAccount(await response.json())\n setAccount('anonymous')\n } catch {\n setAccount('anonymous')\n }\n }, [hostId])\n\n useEffect(() => {\n void refresh()\n }, [refresh])\n\n const handleAuth = useCallback(async () => {\n if (!hostId || busy) return\n setBusy(true)\n setError('')\n try {\n const endpoint =\n tab === 0 ? '/api/membership/login' : '/api/membership/register'\n const response = await siteFetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n email,\n password,\n ...(tab === 1 && displayName ? { displayName } : {}),\n ...(tab === 1 && marketingConsent\n ? { marketingConsent: true }\n : {}),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n setError(String(payload?.error ?? 'Something went wrong'))\n return\n }\n if (tab === 1) {\n // Register does not set the cookie on every deployment; sign in\n // right after to be safe.\n await siteFetch('/api/membership/login', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, email, password }),\n }).catch(() => undefined)\n }\n /*\n * The host's own GA4 property, not Aglyn's (AGL-1591). Reported after\n * the response was accepted and never on a validation failure, which\n * is what makes the count mean \"an account door was completed\".\n *\n * The follow-up login above is deliberately NOT a second event: it is\n * a cookie repair for the registration that just happened, and\n * reporting it would give every new member both a `sign_up` and a\n * `login` in the same second — turning a returning-visitor metric into\n * a copy of the signup one.\n *\n * Not awaited: this branch re-renders in place rather than navigating,\n * so there is no teardown to lose the hit to.\n */\n trackEvent(tab === 1 ? 'sign_up' : 'login', { method: 'password' })\n await refresh()\n } finally {\n setBusy(false)\n }\n }, [\n hostId,\n busy,\n tab,\n email,\n password,\n displayName,\n marketingConsent,\n refresh,\n siteFetch,\n ])\n\n const handleSignOut = useCallback(async () => {\n if (!hostId) return\n await siteFetch('/api/membership/logout', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId }),\n }).catch(() => undefined)\n setAccount('anonymous')\n }, [hostId, siteFetch])\n\n const handleAddressSave = useCallback(async () => {\n if (!hostId || account === 'anonymous' || !account || !addressDraft) {\n return\n }\n const addresses = [...account.member.addresses, addressDraft].slice(-5)\n await siteFetch('/api/membership/account', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, addresses }),\n }).catch(() => undefined)\n setAddressDraft(null)\n await refresh()\n }, [hostId, account, addressDraft, refresh, siteFetch])\n\n if (!hostId) {\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n p: 3,\n border: '1px dashed',\n borderColor: 'divider',\n borderRadius: 1,\n color: 'text.secondary',\n fontSize: 13,\n fontFamily: 'system-ui, sans-serif',\n },\n ...nodeSx,\n ]}\n >\n {'Customer account — sign-in and order history render here'}\n </Box>\n )\n }\n if (account === null) return <Box ref={ref} {...rest} />\n\n if (account === 'anonymous') {\n return (\n <Box ref={ref} {...rest} sx={[{ maxWidth: 420 }, ...nodeSx]}>\n {signedOutHeading ? (\n <Typography variant=\"h5\" gutterBottom>\n {signedOutHeading}\n </Typography>\n ) : null}\n <Tabs value={tab} onChange={(_event, value) => setTab(value)}>\n <Tab label=\"Sign in\" />\n <Tab label=\"Create account\" />\n </Tabs>\n <Box\n sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, mt: 2 }}\n >\n {tab === 1 ? (\n <TextField\n label=\"Name\"\n value={displayName}\n onChange={(event) => setDisplayName(event.target.value)}\n size=\"small\"\n />\n ) : null}\n <TextField\n label=\"Email\"\n type=\"email\"\n value={email}\n onChange={(event) => setEmail(event.target.value)}\n size=\"small\"\n />\n <TextField\n label=\"Password\"\n type=\"password\"\n value={password}\n onChange={(event) => setPassword(event.target.value)}\n size=\"small\"\n helperText={tab === 1 ? 'At least 8 characters' : undefined}\n />\n {tab === 1 ? (\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={marketingConsent}\n onChange={(event) =>\n setMarketingConsent(event.target.checked)\n }\n />\n }\n label=\"Email me about offers and updates\"\n />\n ) : null}\n {error ? <Alert severity=\"error\">{error}</Alert> : null}\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={busy || !email || !password}\n onClick={handleAuth}\n >\n {busy ? 'Working…' : tab === 0 ? 'Sign in' : 'Create account'}\n </Button>\n {tab === 0 ? (\n // Recovery flow (AGL-552): the built-in /recover route (or\n // the host's designated recovery screen) handles the rest.\n <Typography variant=\"body2\">\n <MuiLink href=\"/recover\" underline=\"hover\">\n {'Forgot password?'}\n </MuiLink>\n </Typography>\n ) : null}\n </Box>\n </Box>\n )\n }\n\n return (\n <Box ref={ref} {...rest} sx={[{ display: 'flex', flexDirection: 'column', gap: 2 }, ...nodeSx]}>\n <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>\n <Typography variant=\"h5\" sx={{ flex: 1 }}>\n {account.member.displayName || account.member.email}\n </Typography>\n <Button size=\"small\" onClick={handleSignOut}>\n {'Sign out'}\n </Button>\n </Box>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {account.member.email}\n </Typography>\n\n <Divider textAlign=\"left\">{'Orders'}</Divider>\n {account.orders.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No orders yet.'}\n </Typography>\n ) : (\n account.orders.map((order) => (\n <Box key={order.id} sx={{ display: 'flex', gap: 1, alignItems: 'center' }}>\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {`${order.number} · ${order.itemsSummary || 'Order'}`}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {new Date(order.createdAtMs).toLocaleDateString()}\n {order.tracking?.trackingNumber\n ? ` · ${order.tracking.carrier ?? ''} ${order.tracking.trackingNumber}`\n : ''}\n </Typography>\n </Box>\n <Chip\n label={order.status.replace('_', ' ')}\n size=\"small\"\n variant=\"outlined\"\n />\n <Typography variant=\"body2\">{usd(order.totalCents)}</Typography>\n {CommerceModel.RETURNABLE_ORDER_STATUSES.includes(order.status) ? (\n // The member's session authorizes the return page, so the\n // link carries no token (AGL-3611).\n <Button size=\"small\" href={returnRequestHref(order.id)}>\n {'Request a return'}\n </Button>\n ) : null}\n </Box>\n ))\n )}\n\n {(account.subscriptions?.length ?? 0) > 0 ? (\n // Loaded on demand (AGL-4191): it only ever appears after the\n // signed-in account has loaded in the browser, so it need not be in\n // the storefront's first download.\n <Suspense fallback={null}>\n <AccountSubscriptions\n hostId={hostId}\n subscriptions={account.subscriptions!}\n siteFetch={siteFetch}\n />\n </Suspense>\n ) : null}\n {(account.downloads?.length ?? 0) > 0 ? (\n <>\n <Divider textAlign=\"left\">{'Downloads'}</Divider>\n {account.downloads!.map((download) => (\n <Box\n key={`${download.orderId}:${download.productId}`}\n sx={{ display: 'flex', gap: 1, alignItems: 'center' }}\n >\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {download.productName}\n </Typography>\n {download.licenseKeys?.map((key) => (\n <Typography\n key={key}\n variant=\"caption\"\n sx={{ fontFamily: 'monospace', display: 'block' }}\n >\n {key}\n </Typography>\n ))}\n </Box>\n <Button size=\"small\" href={download.url}>\n {'Download'}\n </Button>\n </Box>\n ))}\n </>\n ) : null}\n\n <Divider textAlign=\"left\">{'Addresses'}</Divider>\n {account.member.addresses.map((address, index) => (\n <Typography key={index} variant=\"body2\" color=\"text.secondary\">\n {[\n address.name,\n address.line1,\n address.line2,\n `${address.city ?? ''} ${address.state ?? ''} ${address.postalCode ?? ''}`.trim(),\n address.country,\n ]\n .filter(Boolean)\n .join(', ')}\n </Typography>\n ))}\n {addressDraft ? (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>\n {(\n [\n ['name', 'Full name'],\n ['line1', 'Address'],\n ['line2', 'Apt / suite'],\n ['city', 'City'],\n ['state', 'State'],\n ['postalCode', 'Postal code'],\n ['country', 'Country (US)'],\n ] as const\n ).map(([field, label]) => (\n <TextField\n key={field}\n label={label}\n value={(addressDraft as any)[field] ?? ''}\n onChange={(event) =>\n setAddressDraft((prev) =>\n prev ? { ...prev, [field]: event.target.value } : prev,\n )\n }\n size=\"small\"\n />\n ))}\n <Box sx={{ display: 'flex', gap: 1 }}>\n <Button size=\"small\" onClick={() => setAddressDraft(null)}>\n {'Cancel'}\n </Button>\n <Button\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n disabled={!addressDraft.line1 || !addressDraft.city}\n onClick={handleAddressSave}\n >\n {'Save address'}\n </Button>\n </Box>\n </Box>\n ) : (\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() => setAddressDraft({})}\n >\n {'Add address'}\n </Button>\n )}\n </Box>\n )\n },\n)\nCustomerAccount.displayName = 'AglynCustomerAccount'\n\nexport const schema: Aglyn.ComponentSchema<CustomerAccountProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Customer account',\n description:\n 'Sign-in and account area — profile, addresses and order history.',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiAccountCircleOutline.path, sx: { color: '#2e7d32' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'signedOutHeading',\n label: 'Signed-out heading',\n description: 'Shown above the sign-in form.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Customer account',\n pluginId: BUNDLE_ID,\n description: 'Sign-in/up, profile, addresses, and order history',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiAccountCircleOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { signedOutHeading: 'Your account' },\n },\n },\n]\n\nexport default CustomerAccount\n"],"names":["Aglyn","trackEvent","CommerceModel","mdiAccountCircleOutline","Alert","Box","Button","Checkbox","Chip","Divider","FormControlLabel","MuiLink","Tab","Tabs","TextField","Typography","forwardRef","lazy","Suspense","useCallback","useEffect","useState","BUNDLE_ID","returnRequestHref","generatePresetId","ID","AccountSubscriptions","usd","cents","toFixed","CustomerAccount","props","ref","account","signedOutHeading","rest","nodeSx","Array","isArray","hostId","useSite","siteFetch","useSiteFetch","setAccount","tab","setTab","email","setEmail","password","setPassword","displayName","setDisplayName","marketingConsent","setMarketingConsent","error","setError","busy","setBusy","addressDraft","setAddressDraft","refresh","response","fetch","encodeURIComponent","status","ok","json","handleAuth","endpoint","method","headers","body","JSON","stringify","payload","catch","String","undefined","handleSignOut","handleAddressSave","addresses","member","slice","sx","p","border","borderColor","borderRadius","color","fontSize","fontFamily","maxWidth","variant","gutterBottom","value","onChange","_event","label","display","flexDirection","gap","mt","event","target","size","type","helperText","control","checked","severity","disabled","onClick","href","underline","alignItems","flex","textAlign","orders","length","map","order","minWidth","noWrap","number","itemsSummary","Date","createdAtMs","toLocaleDateString","tracking","trackingNumber","carrier","replace","totalCents","RETURNABLE_ORDER_STATUSES","includes","id","subscriptions","fallback","downloads","download","productName","licenseKeys","key","url","orderId","productId","address","index","name","line1","line2","city","state","postalCode","trim","country","filter","Boolean","join","field","prev","alignSelf","schema","$id","pluginId","description","category","ComponentCategory","COMMERCE","icon","path","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","component","FieldComponentType","TEXT_FIELD","presets","NodeType","PRESET","data","componentId"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,UAAU,QAAQ,0CAAyC;AACpE,YAAYC,mBAAmB,oBAAU;AACzC,SAASC,uBAAuB,QAAQ,yBAAwB;AAChE,OA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O;QAAEC,aAAa5K,MAAM6K,YAAY,CAACC,OAAO;IAAC;IACjDC,YAAY;QACV;YACE3B,MAAM;YACNnD,OAAO;YACPoE,aAAa;YACbW,WAAWhL,MAAMiL,kBAAkB,CAACC,UAAU;QAChD;KACD;AACH,EAAC;AAED,OAAO,MAAMC,UAAgC;IAC3C;QACEhB,KAAK3I,iBAAiBC;QACtBgF,MAAMzG,MAAMoL,QAAQ,CAACC,MAAM;QAC3BnI,aAAa;QACbkH,UAAU9I;QACV+I,aAAa;QACbC,UAAUtK,MAAMuK,iBAAiB,CAACC,QAAQ;QAC1CC,MAAM;YAAEC,MAAMvK,wBAAwBuK,IAAI;YAAEvF,IAAI;gBAAEK,OAAO;YAAU;QAAE;QACrE8F,MAAM;YACJnB,KAAK;YACLoB,aAAa9J;YACb2I,UAAU9I;YACVS,OAAO;gBAAEG,kBAAkB;YAAe;QAC5C;IACF;CACD,CAAA;AAED,eAAeJ,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/account.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport { markSignedIn } from '@aglyn/aglyn/app-utils/sign-in-visibility'\nimport * as CommerceModel from '../model'\nimport { mdiAccountCircleOutline } from '@aglyn/shared-data-mdi'\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Checkbox from '@mui/material/Checkbox'\nimport Chip from '@mui/material/Chip'\nimport Divider from '@mui/material/Divider'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport MuiLink from '@mui/material/Link'\nimport Tab from '@mui/material/Tab'\nimport Tabs from '@mui/material/Tabs'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport { forwardRef, lazy, Suspense, useCallback, useEffect, useState } from 'react'\nimport type { AccountSubscription } from './account-subscriptions'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { returnRequestHref } from '../constants/return-request'\nimport { generatePresetId } from '../utils/generate-preset-id'\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'customer-account'\n\nexport interface CustomerAccountProps {\n signedOutHeading?: string\n}\n\ninterface AccountData {\n member: {\n email: string\n displayName: string\n addresses: CommerceModel.OrderAddress[]\n }\n downloads?: Array<{\n orderId: string\n productId: string\n productName: string\n url: string\n licenseKeys?: string[]\n }>\n subscriptions?: AccountSubscription[]\n orders: Array<{\n id: string\n number: string\n status: string\n totalCents: number\n createdAtMs: number\n itemsSummary: string\n tracking?: { carrier?: string; trackingNumber?: string }\n }>\n}\n\nconst AccountSubscriptions = lazy(() => import('./account-subscriptions'))\n\nconst usd = (cents: number) => `$${(cents / 100).toFixed(2)}`\n\n/**\n * Customer account block (AGL-294): signed-out visitors get sign-in /\n * create-account forms on the AGL-109 membership APIs; signed-in\n * members see their profile, address book, and order history (status +\n * tracking) with sign-out. Session lives in the httpOnly member cookie.\n */\nconst CustomerAccount = forwardRef<HTMLDivElement, CustomerAccountProps>(\n (props, ref) => {\n const { signedOutHeading, ...rest } = props\n // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const { hostId } = Aglyn.useSite()\n const siteFetch = Aglyn.useSiteFetch()\n const [account, setAccount] = useState<AccountData | null | 'anonymous'>(\n null,\n )\n const [tab, setTab] = useState(0)\n const [email, setEmail] = useState('')\n const [password, setPassword] = useState('')\n const [displayName, setDisplayName] = useState('')\n const [marketingConsent, setMarketingConsent] = useState(false)\n const [error, setError] = useState('')\n const [busy, setBusy] = useState(false)\n const [addressDraft, setAddressDraft] = useState<CommerceModel.OrderAddress | null>(\n null,\n )\n\n const refresh = useCallback(async () => {\n if (!hostId) return\n try {\n const response = await fetch(\n `/api/membership/account?hostId=${encodeURIComponent(hostId)}`,\n )\n // What the session says is what the page shows (AGL-4231): elements\n // shown to signed-in or signed-out visitors follow it here, without a\n // reload, including a hint left behind by a session that has expired.\n if (response.ok) {\n const signedIn = await response.json()\n markSignedIn(true)\n return setAccount(signedIn)\n }\n if (response.status === 401) markSignedIn(false)\n setAccount('anonymous')\n } catch {\n setAccount('anonymous')\n }\n }, [hostId])\n\n useEffect(() => {\n void refresh()\n }, [refresh])\n\n const handleAuth = useCallback(async () => {\n if (!hostId || busy) return\n setBusy(true)\n setError('')\n try {\n const endpoint =\n tab === 0 ? '/api/membership/login' : '/api/membership/register'\n const response = await siteFetch(endpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n email,\n password,\n ...(tab === 1 && displayName ? { displayName } : {}),\n ...(tab === 1 && marketingConsent\n ? { marketingConsent: true }\n : {}),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n setError(String(payload?.error ?? 'Something went wrong'))\n return\n }\n if (tab === 1) {\n // Register does not set the cookie on every deployment; sign in\n // right after to be safe.\n await siteFetch('/api/membership/login', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, email, password }),\n }).catch(() => undefined)\n }\n /*\n * The host's own GA4 property, not Aglyn's (AGL-1591). Reported after\n * the response was accepted and never on a validation failure, which\n * is what makes the count mean \"an account door was completed\".\n *\n * The follow-up login above is deliberately NOT a second event: it is\n * a cookie repair for the registration that just happened, and\n * reporting it would give every new member both a `sign_up` and a\n * `login` in the same second — turning a returning-visitor metric into\n * a copy of the signup one.\n *\n * Not awaited: this branch re-renders in place rather than navigating,\n * so there is no teardown to lose the hit to.\n */\n trackEvent(tab === 1 ? 'sign_up' : 'login', { method: 'password' })\n await refresh()\n } finally {\n setBusy(false)\n }\n }, [\n hostId,\n busy,\n tab,\n email,\n password,\n displayName,\n marketingConsent,\n refresh,\n siteFetch,\n ])\n\n const handleSignOut = useCallback(async () => {\n if (!hostId) return\n await siteFetch('/api/membership/logout', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId }),\n }).catch(() => undefined)\n markSignedIn(false)\n setAccount('anonymous')\n }, [hostId, siteFetch])\n\n const handleAddressSave = useCallback(async () => {\n if (!hostId || account === 'anonymous' || !account || !addressDraft) {\n return\n }\n const addresses = [...account.member.addresses, addressDraft].slice(-5)\n await siteFetch('/api/membership/account', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, addresses }),\n }).catch(() => undefined)\n setAddressDraft(null)\n await refresh()\n }, [hostId, account, addressDraft, refresh, siteFetch])\n\n if (!hostId) {\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n p: 3,\n border: '1px dashed',\n borderColor: 'divider',\n borderRadius: 1,\n color: 'text.secondary',\n fontSize: 13,\n fontFamily: 'system-ui, sans-serif',\n },\n ...nodeSx,\n ]}\n >\n {'Customer account — sign-in and order history render here'}\n </Box>\n )\n }\n if (account === null) return <Box ref={ref} {...rest} />\n\n if (account === 'anonymous') {\n return (\n <Box ref={ref} {...rest} sx={[{ maxWidth: 420 }, ...nodeSx]}>\n {signedOutHeading ? (\n <Typography variant=\"h5\" gutterBottom>\n {signedOutHeading}\n </Typography>\n ) : null}\n <Tabs value={tab} onChange={(_event, value) => setTab(value)}>\n <Tab label=\"Sign in\" />\n <Tab label=\"Create account\" />\n </Tabs>\n <Box\n sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, mt: 2 }}\n >\n {tab === 1 ? (\n <TextField\n label=\"Name\"\n value={displayName}\n onChange={(event) => setDisplayName(event.target.value)}\n size=\"small\"\n />\n ) : null}\n <TextField\n label=\"Email\"\n type=\"email\"\n value={email}\n onChange={(event) => setEmail(event.target.value)}\n size=\"small\"\n />\n <TextField\n label=\"Password\"\n type=\"password\"\n value={password}\n onChange={(event) => setPassword(event.target.value)}\n size=\"small\"\n helperText={tab === 1 ? 'At least 8 characters' : undefined}\n />\n {tab === 1 ? (\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={marketingConsent}\n onChange={(event) =>\n setMarketingConsent(event.target.checked)\n }\n />\n }\n label=\"Email me about offers and updates\"\n />\n ) : null}\n {error ? <Alert severity=\"error\">{error}</Alert> : null}\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={busy || !email || !password}\n onClick={handleAuth}\n >\n {busy ? 'Working…' : tab === 0 ? 'Sign in' : 'Create account'}\n </Button>\n {tab === 0 ? (\n // Recovery flow (AGL-552): the built-in /recover route (or\n // the host's designated recovery screen) handles the rest.\n <Typography variant=\"body2\">\n <MuiLink href=\"/recover\" underline=\"hover\">\n {'Forgot password?'}\n </MuiLink>\n </Typography>\n ) : null}\n </Box>\n </Box>\n )\n }\n\n return (\n <Box ref={ref} {...rest} sx={[{ display: 'flex', flexDirection: 'column', gap: 2 }, ...nodeSx]}>\n <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>\n <Typography variant=\"h5\" sx={{ flex: 1 }}>\n {account.member.displayName || account.member.email}\n </Typography>\n <Button size=\"small\" onClick={handleSignOut}>\n {'Sign out'}\n </Button>\n </Box>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {account.member.email}\n </Typography>\n\n <Divider textAlign=\"left\">{'Orders'}</Divider>\n {account.orders.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No orders yet.'}\n </Typography>\n ) : (\n account.orders.map((order) => (\n <Box key={order.id} sx={{ display: 'flex', gap: 1, alignItems: 'center' }}>\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {`${order.number} · ${order.itemsSummary || 'Order'}`}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {new Date(order.createdAtMs).toLocaleDateString()}\n {order.tracking?.trackingNumber\n ? ` · ${order.tracking.carrier ?? ''} ${order.tracking.trackingNumber}`\n : ''}\n </Typography>\n </Box>\n <Chip\n label={order.status.replace('_', ' ')}\n size=\"small\"\n variant=\"outlined\"\n />\n <Typography variant=\"body2\">{usd(order.totalCents)}</Typography>\n {CommerceModel.RETURNABLE_ORDER_STATUSES.includes(order.status) ? (\n // The member's session authorizes the return page, so the\n // link carries no token (AGL-3611).\n <Button size=\"small\" href={returnRequestHref(order.id)}>\n {'Request a return'}\n </Button>\n ) : null}\n </Box>\n ))\n )}\n\n {(account.subscriptions?.length ?? 0) > 0 ? (\n // Loaded on demand (AGL-4191): it only ever appears after the\n // signed-in account has loaded in the browser, so it need not be in\n // the storefront's first download.\n <Suspense fallback={null}>\n <AccountSubscriptions\n hostId={hostId}\n subscriptions={account.subscriptions!}\n siteFetch={siteFetch}\n />\n </Suspense>\n ) : null}\n {(account.downloads?.length ?? 0) > 0 ? (\n <>\n <Divider textAlign=\"left\">{'Downloads'}</Divider>\n {account.downloads!.map((download) => (\n <Box\n key={`${download.orderId}:${download.productId}`}\n sx={{ display: 'flex', gap: 1, alignItems: 'center' }}\n >\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {download.productName}\n </Typography>\n {download.licenseKeys?.map((key) => (\n <Typography\n key={key}\n variant=\"caption\"\n sx={{ fontFamily: 'monospace', display: 'block' }}\n >\n {key}\n </Typography>\n ))}\n </Box>\n <Button size=\"small\" href={download.url}>\n {'Download'}\n </Button>\n </Box>\n ))}\n </>\n ) : null}\n\n <Divider textAlign=\"left\">{'Addresses'}</Divider>\n {account.member.addresses.map((address, index) => (\n <Typography key={index} variant=\"body2\" color=\"text.secondary\">\n {[\n address.name,\n address.line1,\n address.line2,\n `${address.city ?? ''} ${address.state ?? ''} ${address.postalCode ?? ''}`.trim(),\n address.country,\n ]\n .filter(Boolean)\n .join(', ')}\n </Typography>\n ))}\n {addressDraft ? (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>\n {(\n [\n ['name', 'Full name'],\n ['line1', 'Address'],\n ['line2', 'Apt / suite'],\n ['city', 'City'],\n ['state', 'State'],\n ['postalCode', 'Postal code'],\n ['country', 'Country (US)'],\n ] as const\n ).map(([field, label]) => (\n <TextField\n key={field}\n label={label}\n value={(addressDraft as any)[field] ?? ''}\n onChange={(event) =>\n setAddressDraft((prev) =>\n prev ? { ...prev, [field]: event.target.value } : prev,\n )\n }\n size=\"small\"\n />\n ))}\n <Box sx={{ display: 'flex', gap: 1 }}>\n <Button size=\"small\" onClick={() => setAddressDraft(null)}>\n {'Cancel'}\n </Button>\n <Button\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n disabled={!addressDraft.line1 || !addressDraft.city}\n onClick={handleAddressSave}\n >\n {'Save address'}\n </Button>\n </Box>\n </Box>\n ) : (\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() => setAddressDraft({})}\n >\n {'Add address'}\n </Button>\n )}\n </Box>\n )\n },\n)\nCustomerAccount.displayName = 'AglynCustomerAccount'\n\nexport const schema: Aglyn.ComponentSchema<CustomerAccountProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Customer account',\n description:\n 'Sign-in and account area — profile, addresses and order history.',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiAccountCircleOutline.path, sx: { color: '#2e7d32' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'signedOutHeading',\n label: 'Signed-out heading',\n description: 'Shown above the sign-in form.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Customer account',\n pluginId: BUNDLE_ID,\n description: 'Sign-in/up, profile, addresses, and order history',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiAccountCircleOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { signedOutHeading: 'Your account' },\n },\n },\n]\n\nexport default CustomerAccount\n"],"names":["Aglyn","trackEvent","markSignedIn","CommerceModel","mdiAccountCircleOutline","Alert","Box","Button","Checkbox","Chip","Divider","FormControlLabel","MuiLink","Tab","Tabs","TextField","Typography","forwardRef","lazy","Suspense","useCallback","useEffect","useState","BUNDLE_ID","returnRequestHref","generatePresetId","ID","AccountSubscriptions","usd","cents","toFixed","CustomerAccount","props","ref","account","signedOutHeading","rest","nodeSx","Array","isArray","hostId","useSite","siteFetch","useSiteFetch","setAccount","tab","setTab","email","setEmail","password","setPassword","displayName","setDisplayName","marketingConsent","setMarketingConsent","error","setError","busy","setBusy","addressDraft","setAddressDraft","refresh","response","fetch","encodeURIComponent","ok","signedIn","json","status","handleAuth","endpoint","method","headers","body","JSON","stringify","payload","catch","String","undefined","handleSignOut","handleAddressSave","addresses","member","slice","sx","p","border","borderColor","borderRadius","color","fontSize","fontFamily","maxWidth","variant","gutterBottom","value","onChange","_event","label","display","flexDirection","gap","mt","event","target","size","type","helperText","control","checked","severity","disabled","onClick","href","underline","alignItems","flex","textAlign","orders","length","map","order","minWidth","noWrap","number","itemsSummary","Date","createdAtMs","toLocaleDateString","tracking","trackingNumber","carrier","replace","totalCents","RETURNABLE_ORDER_STATUSES","includes","id","subscriptions","fallback","downloads","download","productName","licenseKeys","key","url","orderId","productId","address","index","name","line1","line2","city","state","postalCode","trim","country","filter","Boolean","join","field","prev","alignSelf","schema","$id","pluginId","description","category","ComponentCategory","COMMERCE","icon","path","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","component","FieldComponentType","TEXT_FIELD","presets","NodeType","PRESET","data","componentId"],"mappings":";;;A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,IAAMrD,gBAAgB,CAAC;0BAE/B;;;;AAKX;AAEF7B,gBAAgBoB,WAAW,GAAG;AAE9B,OAAO,MAAMiH,SAAsD;IACjEC,KAAK3I;IACL4I,UAAU/I;IACV4B,aAAa;IACboH,aACE;IACFC,UAAUxK,MAAMyK,iBAAiB,CAACC,QAAQ;IAC1CC,MAAM;QAAEC,MAAMxK,wBAAwBwK,IAAI;QAAEvF,IAAI;YAAEK,OAAO;QAAU;IAAE;IACrEmF,OAAO;QAAEC,aAAa9K,MAAM+K,YAAY,CAACC,OAAO;IAAC;IACjDC,YAAY;QACV;YACE3B,MAAM;YACNnD,OAAO;YACPoE,aAAa;YACbW,WAAWlL,MAAMmL,kBAAkB,CAACC,UAAU;QAChD;KACD;AACH,EAAC;AAED,OAAO,MAAMC,UAAgC;IAC3C;QACEhB,KAAK5I,iBAAiBC;QACtBiF,MAAM3G,MAAMsL,QAAQ,CAACC,MAAM;QAC3BpI,aAAa;QACbmH,UAAU/I;QACVgJ,aAAa;QACbC,UAAUxK,MAAMyK,iBAAiB,CAACC,QAAQ;QAC1CC,MAAM;YAAEC,MAAMxK,wBAAwBwK,IAAI;YAAEvF,IAAI;gBAAEK,OAAO;YAAU;QAAE;QACrE8F,MAAM;YACJnB,KAAK;YACLoB,aAAa/J;YACb4I,UAAU/I;YACVS,OAAO;gBAAEG,kBAAkB;YAAe;QAC5C;IACF;CACD,CAAA;AAED,eAAeJ,gBAAe"}
|
|
@@ -14,7 +14,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/ import { booleanField as bool, integerField as int, nullableField as nullable, objectKindField as OBJECT_FIELD, openObjectField as objectOf, postalAddressField as ADDRESS, queryParam as q, RECORD_STAMPS as STAMPS, stringField as str, stringListField as strList } from "@aglyn/tenant-data-admin/server/api-v1-description";
|
|
17
|
+
*/ import { booleanField as bool, integerField as int, nullableField as nullable, objectKindField as OBJECT_FIELD, openObjectField as objectOf, postalAddressField as ADDRESS, queryParam as q, RECORD_STAMPS as STAMPS, stringField as str, stringListField as strList, SITE_ID_PATH_PARAM } from "@aglyn/tenant-data-admin/server/api-v1-description";
|
|
18
18
|
/**
|
|
19
19
|
* A site's products and orders as the customer API's OpenAPI document
|
|
20
20
|
* describes them — what the console's builder turns into paths, tags and
|
|
@@ -71,10 +71,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
71
71
|
returns: 'Product',
|
|
72
72
|
description: 'Rows deleted since they were written are dropped after the read, so pages can come back short.',
|
|
73
73
|
pathParams: [
|
|
74
|
-
|
|
75
|
-
name: 'siteId',
|
|
76
|
-
description: 'Site id.'
|
|
77
|
-
}
|
|
74
|
+
SITE_ID_PATH_PARAM
|
|
78
75
|
]
|
|
79
76
|
},
|
|
80
77
|
{
|
|
@@ -84,10 +81,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
84
81
|
summary: 'Retrieve a product',
|
|
85
82
|
returns: 'Product',
|
|
86
83
|
pathParams: [
|
|
87
|
-
|
|
88
|
-
name: 'siteId',
|
|
89
|
-
description: 'Site id.'
|
|
90
|
-
},
|
|
84
|
+
SITE_ID_PATH_PARAM,
|
|
91
85
|
{
|
|
92
86
|
name: 'productId',
|
|
93
87
|
description: 'Product id.'
|
|
@@ -203,10 +197,7 @@ export const ORDERS_API_V1_DESCRIPTION = {
|
|
|
203
197
|
q('status', 'Order status.')
|
|
204
198
|
],
|
|
205
199
|
pathParams: [
|
|
206
|
-
|
|
207
|
-
name: 'siteId',
|
|
208
|
-
description: 'Site id.'
|
|
209
|
-
}
|
|
200
|
+
SITE_ID_PATH_PARAM
|
|
210
201
|
]
|
|
211
202
|
},
|
|
212
203
|
{
|
|
@@ -216,10 +207,7 @@ export const ORDERS_API_V1_DESCRIPTION = {
|
|
|
216
207
|
summary: 'Retrieve an order',
|
|
217
208
|
returns: 'Order',
|
|
218
209
|
pathParams: [
|
|
219
|
-
|
|
220
|
-
name: 'siteId',
|
|
221
|
-
description: 'Site id.'
|
|
222
|
-
},
|
|
210
|
+
SITE_ID_PATH_PARAM,
|
|
223
211
|
{
|
|
224
212
|
name: 'orderId',
|
|
225
213
|
description: 'Order id.'
|
|
@@ -235,10 +223,7 @@ export const ORDERS_API_V1_DESCRIPTION = {
|
|
|
235
223
|
returns: 'Order',
|
|
236
224
|
description: 'An illegal transition is `409 conflict` (`code: "order_transition"`), and the message names the status it is in.',
|
|
237
225
|
pathParams: [
|
|
238
|
-
|
|
239
|
-
name: 'siteId',
|
|
240
|
-
description: 'Site id.'
|
|
241
|
-
},
|
|
226
|
+
SITE_ID_PATH_PARAM,
|
|
242
227
|
{
|
|
243
228
|
name: 'orderId',
|
|
244
229
|
description: 'Order id.'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/server/api-v1/openapi.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type ApiV1ResourceDescription,\n booleanField as bool,\n integerField as int,\n nullableField as nullable,\n objectKindField as OBJECT_FIELD,\n openObjectField as objectOf,\n postalAddressField as ADDRESS,\n queryParam as q,\n RECORD_STAMPS as STAMPS,\n stringField as str,\n stringListField as strList,\n} from '@aglyn/tenant-data-admin/server/api-v1-description'\n\n/**\n * A site's products and orders as the customer API's OpenAPI document\n * describes them — what the console's builder turns into paths, tags and\n * schemas, and the MCP tools derive from. Transcribed unchanged from the\n * builder's own list when the resources moved here (AGL-3080);\n * `api-v1-openapi.spec.ts` holds the document to every endpoint the\n * documentation promises.\n */\nexport const PRODUCTS_API_V1_DESCRIPTION: ApiV1ResourceDescription = {\n tag: 'Products',\n description: 'A site’s catalog. Read-only over the API.',\n schemaName: 'Product',\n required: ['id', 'object', 'name'],\n fields: {\n id: str('Product id.'),\n object: OBJECT_FIELD('product'),\n name: str('Product name.'),\n slug: str('URL slug.'),\n description: nullable(str('Description.')),\n type: str('Product type.'),\n status: str('Publication status.'),\n tags: strList('Free-form tags.'),\n categoryIds: strList('Categories this product belongs to.'),\n mediaUrls: strList('Image URLs.'),\n options: { type: 'array', description: 'Option definitions, e.g. size.', items: { type: 'object', additionalProperties: true } },\n variants: { type: 'array', description: 'Purchasable variants.', items: { type: 'object', additionalProperties: true } },\n inventory: nullable(int('Stock on hand, when tracked.')),\n subscription: nullable(objectOf('Subscription terms, when the product is one.')),\n ...STAMPS,\n },\n ops: [\n { path: '/v1/sites/{siteId}/products', method: 'get', operationId: 'listProducts', summary: 'List products', list: true, returns: 'Product', description: 'Rows deleted since they were written are dropped after the read, so pages can come back short.', pathParams: [{ name: 'siteId', description: 'Site id.' }] },\n { path: '/v1/sites/{siteId}/products/{productId}', method: 'get', operationId: 'getProduct', summary: 'Retrieve a product', returns: 'Product', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'productId', description: 'Product id.' }] },\n ],\n}\n\nexport const ORDERS_API_V1_DESCRIPTION: ApiV1ResourceDescription = {\n tag: 'Orders',\n description: 'A site’s orders. Status moves are constrained.',\n schemaName: 'Order',\n required: ['id', 'object', 'number', 'status'],\n writable: ['status', 'carrier', 'trackingNumber', 'trackingUrl', 'lineItems', 'notify'],\n writeOnly: {\n status: { type: 'string', enum: ['fulfilled', 'delivered'], description: 'The status to move the order to.' },\n carrier: str('Free text, e.g. `UPS`. Trimmed to 40 characters. USPS, UPS, FedEx, DHL, Canada Post, Royal Mail and Australia Post get a tracking link.'),\n trackingNumber: str('Free text. Trimmed to 60 characters.'),\n trackingUrl: str('An https tracking link, for a carrier the link is not derived for.'),\n lineItems: {\n type: 'array',\n description:\n 'With `status: fulfilled`, the units this shipment covers: `[{ lineItemId, quantity }]`, where `lineItemId` is the line’s index. Omitted, the shipment covers everything still to ship. More than is left is `409 conflict` (`code: \"over_fulfilled\"`). Send an `Idempotency-Key` header so a retried partial shipment is recorded once.',\n items: { type: 'object', additionalProperties: true },\n },\n notify: bool('Whether the buyer is told about this shipment. Defaults to true.'),\n },\n writeRequired: ['status'],\n fields: {\n id: str('Order id.'),\n object: OBJECT_FIELD('order'),\n number: int('Human-facing order number.'),\n status: str('Order status.'),\n channel: str('`online` by default. Older orders carry no stored value, so `?channel=online` drops them after the read.'),\n currency: str('ISO 4217 code.'),\n customerEmail: nullable(str('Customer email.')),\n customerName: nullable(str('Customer name.')),\n lineItems: { type: 'array', description: 'What was bought.', items: { type: 'object', additionalProperties: true } },\n totals: objectOf('Money totals, in the smallest unit of `currency`. `extrasCents` is the optional lines the buyer added at checkout, inside `totalCents` and outside `itemsCents`.'),\n extras: { type: 'array', description: 'Optional lines the buyer added at checkout, such as package protection: `[{ id, pluginId, key, label, amountCents, quoteRef }]`. Empty when there were none.', items: { type: 'object', additionalProperties: true } },\n credits: { type: 'array', description: 'Store credit another plugin kept that paid part of the sale, such as rewards: `[{ providerId, pluginId, reference, label, last4, amountCents, appliedAs }]`. `appliedAs` is `discount` for a checkout redemption and `tender` for a register payment. Empty when there were none.', items: { type: 'object', additionalProperties: true } },\n refundedCents: int('Amount refunded so far.'),\n livemode: bool('Whether real money moved: `false` for an order paid in Stripe test mode, such as a store rehearsal.'),\n disputed: bool('Whether a chargeback is open.'),\n taxMode: nullable(str('The tax regime: `stripe-automatic` (Stripe Tax, collected and remitted by the platform as marketplace facilitator), `manual` (your own rate) or `none`. `null` on an order from before it was recorded.')),\n taxEngine: nullable(objectOf('The tax service you connected, when one was asked for this sale’s tax: `provider` (`avalara` or `taxjar`), `providerLabel`, `status` (`quoted` when its tax was charged, `fallback` when it did not answer and your own rate was charged), `reason` (`timeout` or `error` on a fallback) and `sandbox`. `null` when no service was asked.')),\n shippingAddress: ADDRESS(),\n couponCode: nullable(str('Coupon applied.')),\n fulfillments: { type: 'array', description: 'Shipments and deliveries.', items: { type: 'object', additionalProperties: true } },\n created: STAMPS.created,\n },\n ops: [\n { path: '/v1/sites/{siteId}/orders', method: 'get', operationId: 'listOrders', summary: 'List orders', list: true, returns: 'Order', filters: [q('channel', '`online` is a default rather than a stored value, so filtering on it drops older orders after the read.'), q('status', 'Order status.')], pathParams: [{ name: 'siteId', description: 'Site id.' }] },\n { path: '/v1/sites/{siteId}/orders/{orderId}', method: 'get', operationId: 'getOrder', summary: 'Retrieve an order', returns: 'Order', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'orderId', description: 'Order id.' }] },\n { path: '/v1/sites/{siteId}/orders/{orderId}', method: 'patch', operationId: 'updateOrder', summary: 'Move an order’s status', accepts: 'OrderWrite', returns: 'Order', description: 'An illegal transition is `409 conflict` (`code: \"order_transition\"`), and the message names the status it is in.', pathParams: [{ name: 'siteId', description: 'Site id.' }, { name: 'orderId', description: 'Order id.' }] },\n ],\n}\n"],"names":["booleanField","bool","integerField","int","nullableField","nullable","objectKindField","OBJECT_FIELD","openObjectField","objectOf","postalAddressField","ADDRESS","queryParam","q","RECORD_STAMPS","STAMPS","stringField","str","stringListField","strList","PRODUCTS_API_V1_DESCRIPTION","tag","description","schemaName","required","fields","id","object","name","slug","type","status","tags","categoryIds","mediaUrls","options","items","additionalProperties","variants","inventory","subscription","ops","path","method","operationId","summary","list","returns","pathParams","ORDERS_API_V1_DESCRIPTION","writable","writeOnly","enum","carrier","trackingNumber","trackingUrl","lineItems","notify","writeRequired","number","channel","currency","customerEmail","customerName","totals","extras","credits","refundedCents","livemode","disputed","taxMode","taxEngine","shippingAddress","couponCode","fulfillments","created","filters","accepts"],"mappings":";AAAA;;;;;;;;;;;;;;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AAa;YAA6Bc,OAAO;gBAAEN,MAAM;gBAAUO,sBAAsB;YAAK;QAAE;QAC/HsC,SAAS5D,OAAO4D,OAAO;IACzB;IACAlC,KAAK;QACH;YAAEC,MAAM;YAA6BC,QAAQ;YAAOC,aAAa;YAAcC,SAAS;YAAeC,MAAM;YAAMC,SAAS;YAAS6B,SAAS;gBAAC/D,EAAE,WAAW;gBAA4GA,EAAE,UAAU;aAAiB;YAAEmC,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;aAAE;QAAC;QACjW;YAAEoB,MAAM;YAAuCC,QAAQ;YAAOC,aAAa;YAAYC,SAAS;YAAqBE,SAAS;YAASC,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;gBAAG;oBAAEM,MAAM;oBAAWN,aAAa;gBAAY;aAAE;QAAC;QAChP;YAAEoB,MAAM;YAAuCC,QAAQ;YAASC,aAAa;YAAeC,SAAS;YAA0BgC,SAAS;YAAc9B,SAAS;YAASzB,aAAa;YAAoH0B,YAAY;gBAAC;oBAAEpB,MAAM;oBAAUN,aAAa;gBAAW;gBAAG;oBAAEM,MAAM;oBAAWN,aAAa;gBAAY;aAAE;QAAC;KACnZ;AACH,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/server/api-v1/openapi.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type ApiV1ResourceDescription,\n booleanField as bool,\n integerField as int,\n nullableField as nullable,\n objectKindField as OBJECT_FIELD,\n openObjectField as objectOf,\n postalAddressField as ADDRESS,\n queryParam as q,\n RECORD_STAMPS as STAMPS,\n stringField as str,\n stringListField as strList,\n SITE_ID_PATH_PARAM,\n} from '@aglyn/tenant-data-admin/server/api-v1-description'\n\n/**\n * A site's products and orders as the customer API's OpenAPI document\n * describes them — what the console's builder turns into paths, tags and\n * schemas, and the MCP tools derive from. Transcribed unchanged from the\n * builder's own list when the resources moved here (AGL-3080);\n * `api-v1-openapi.spec.ts` holds the document to every endpoint the\n * documentation promises.\n */\nexport const PRODUCTS_API_V1_DESCRIPTION: ApiV1ResourceDescription = {\n tag: 'Products',\n description: 'A site’s catalog. Read-only over the API.',\n schemaName: 'Product',\n required: ['id', 'object', 'name'],\n fields: {\n id: str('Product id.'),\n object: OBJECT_FIELD('product'),\n name: str('Product name.'),\n slug: str('URL slug.'),\n description: nullable(str('Description.')),\n type: str('Product type.'),\n status: str('Publication status.'),\n tags: strList('Free-form tags.'),\n categoryIds: strList('Categories this product belongs to.'),\n mediaUrls: strList('Image URLs.'),\n options: { type: 'array', description: 'Option definitions, e.g. size.', items: { type: 'object', additionalProperties: true } },\n variants: { type: 'array', description: 'Purchasable variants.', items: { type: 'object', additionalProperties: true } },\n inventory: nullable(int('Stock on hand, when tracked.')),\n subscription: nullable(objectOf('Subscription terms, when the product is one.')),\n ...STAMPS,\n },\n ops: [\n { path: '/v1/sites/{siteId}/products', method: 'get', operationId: 'listProducts', summary: 'List products', list: true, returns: 'Product', description: 'Rows deleted since they were written are dropped after the read, so pages can come back short.', pathParams: [SITE_ID_PATH_PARAM] },\n { path: '/v1/sites/{siteId}/products/{productId}', method: 'get', operationId: 'getProduct', summary: 'Retrieve a product', returns: 'Product', pathParams: [SITE_ID_PATH_PARAM, { name: 'productId', description: 'Product id.' }] },\n ],\n}\n\nexport const ORDERS_API_V1_DESCRIPTION: ApiV1ResourceDescription = {\n tag: 'Orders',\n description: 'A site’s orders. Status moves are constrained.',\n schemaName: 'Order',\n required: ['id', 'object', 'number', 'status'],\n writable: ['status', 'carrier', 'trackingNumber', 'trackingUrl', 'lineItems', 'notify'],\n writeOnly: {\n status: { type: 'string', enum: ['fulfilled', 'delivered'], description: 'The status to move the order to.' },\n carrier: str('Free text, e.g. `UPS`. Trimmed to 40 characters. USPS, UPS, FedEx, DHL, Canada Post, Royal Mail and Australia Post get a tracking link.'),\n trackingNumber: str('Free text. Trimmed to 60 characters.'),\n trackingUrl: str('An https tracking link, for a carrier the link is not derived for.'),\n lineItems: {\n type: 'array',\n description:\n 'With `status: fulfilled`, the units this shipment covers: `[{ lineItemId, quantity }]`, where `lineItemId` is the line’s index. Omitted, the shipment covers everything still to ship. More than is left is `409 conflict` (`code: \"over_fulfilled\"`). Send an `Idempotency-Key` header so a retried partial shipment is recorded once.',\n items: { type: 'object', additionalProperties: true },\n },\n notify: bool('Whether the buyer is told about this shipment. Defaults to true.'),\n },\n writeRequired: ['status'],\n fields: {\n id: str('Order id.'),\n object: OBJECT_FIELD('order'),\n number: int('Human-facing order number.'),\n status: str('Order status.'),\n channel: str('`online` by default. Older orders carry no stored value, so `?channel=online` drops them after the read.'),\n currency: str('ISO 4217 code.'),\n customerEmail: nullable(str('Customer email.')),\n customerName: nullable(str('Customer name.')),\n lineItems: { type: 'array', description: 'What was bought.', items: { type: 'object', additionalProperties: true } },\n totals: objectOf('Money totals, in the smallest unit of `currency`. `extrasCents` is the optional lines the buyer added at checkout, inside `totalCents` and outside `itemsCents`.'),\n extras: { type: 'array', description: 'Optional lines the buyer added at checkout, such as package protection: `[{ id, pluginId, key, label, amountCents, quoteRef }]`. Empty when there were none.', items: { type: 'object', additionalProperties: true } },\n credits: { type: 'array', description: 'Store credit another plugin kept that paid part of the sale, such as rewards: `[{ providerId, pluginId, reference, label, last4, amountCents, appliedAs }]`. `appliedAs` is `discount` for a checkout redemption and `tender` for a register payment. Empty when there were none.', items: { type: 'object', additionalProperties: true } },\n refundedCents: int('Amount refunded so far.'),\n livemode: bool('Whether real money moved: `false` for an order paid in Stripe test mode, such as a store rehearsal.'),\n disputed: bool('Whether a chargeback is open.'),\n taxMode: nullable(str('The tax regime: `stripe-automatic` (Stripe Tax, collected and remitted by the platform as marketplace facilitator), `manual` (your own rate) or `none`. `null` on an order from before it was recorded.')),\n taxEngine: nullable(objectOf('The tax service you connected, when one was asked for this sale’s tax: `provider` (`avalara` or `taxjar`), `providerLabel`, `status` (`quoted` when its tax was charged, `fallback` when it did not answer and your own rate was charged), `reason` (`timeout` or `error` on a fallback) and `sandbox`. `null` when no service was asked.')),\n shippingAddress: ADDRESS(),\n couponCode: nullable(str('Coupon applied.')),\n fulfillments: { type: 'array', description: 'Shipments and deliveries.', items: { type: 'object', additionalProperties: true } },\n created: STAMPS.created,\n },\n ops: [\n { path: '/v1/sites/{siteId}/orders', method: 'get', operationId: 'listOrders', summary: 'List orders', list: true, returns: 'Order', filters: [q('channel', '`online` is a default rather than a stored value, so filtering on it drops older orders after the read.'), q('status', 'Order status.')], pathParams: [SITE_ID_PATH_PARAM] },\n { path: '/v1/sites/{siteId}/orders/{orderId}', method: 'get', operationId: 'getOrder', summary: 'Retrieve an order', returns: 'Order', pathParams: [SITE_ID_PATH_PARAM, { name: 'orderId', description: 'Order id.' }] },\n { path: '/v1/sites/{siteId}/orders/{orderId}', method: 'patch', operationId: 'updateOrder', summary: 'Move an order’s status', accepts: 'OrderWrite', returns: 'Order', description: 'An illegal transition is `409 conflict` (`code: \"order_transition\"`), and the message names the status it is in.', pathParams: [SITE_ID_PATH_PARAM, { name: 'orderId', description: 'Order id.' }] },\n ],\n}\n"],"names":["booleanField","bool","integerField","int","nullableField","nullable","objectKindField","OBJECT_FIELD","openObjectField","objectOf","postalAddressField","ADDRESS","queryParam","q","RECORD_STAMPS","STAMPS","stringField","str","stringListField","strList","SITE_ID_PATH_PARAM","PRODUCTS_API_V1_DESCRIPTION","tag","description","schemaName","required","fields","id","object","name","slug","type","status","tags","categoryIds","mediaUrls","options","items","additionalProperties","variants","inventory","subscription","ops","path","method","operationId","summary","list","returns","pathParams","ORDERS_API_V1_DESCRIPTION","writable","writeOnly","enum","carrier","trackingNumber","trackingUrl","lineItems","notify","writeRequired","number","channel","currency","customerEmail","customerName","totals","extras","credits","refundedCents","livemode","disputed","taxMode","taxEngine","shippingAddress","couponCode","fulfillments","created","filters","accepts"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAEEA,gBAAgBC,IAAI,EACpBC,gBAAgBC,GAAG,EACnBC,iBAAiBC,QAAQ,EACzBC,mBAAmBC,YAAY,EAC/BC,mBAAmBC,QAAQ,EAC3BC,sBAAsBC,OAAO,EAC7BC,cAAcC,CAAC,EACfC,iBAAiBC,MAAM,EACvBC,eAAeC,GAAG,EAClBC,mBAAmBC,OAAO,EAC1BC,kBAAkB,QACb,qDAAoD;AAE3D;;;;;;;CAOC,GACD,OAAO,MAAMC,8BAAwD;IACnEC,KAAK;IACLC,aAAa;IACbC,YAAY;IACZC,UAAU;QAAC;QAAM;QAAU;KAAO;IAClCC,QAAQ;QACNC,IAAIV,IAAI;QACRW,QAAQrB,aAAa;QACrBsB,MAAMZ,IAAI;QACVa,MAAMb,IAAI;QACVM,aAAalB,SAASY,IAAI;QAC1Bc,MAAMd,IAAI;QACVe,QAAQf,IAAI;QACZgB,MAAMd,QAAQ;QACde,aAAaf,QAAQ;QACrBgB,WAAWhB,QAAQ;QACnBiB,SAAS;YAAEL,MAAM;YAASR,aAAa;YAAkCc,OAAO;gBAAEN,MAAM;gBAAUO,sBAAsB;YAAK;QAAE;QAC/HC,UAAU;YAAER,MAAM;YAASR,aAAa;YAAyBc,OAAO;gBAAEN,MAAM;gBAAUO,sBAAsB;YAAK;QAAE;QACvHE,WAAWnC,SAASF,IAAI;QACxBsC,cAAcpC,SAASI,SAAS;OAC7BM;IAEL2B,KAAK;QACH;YAAEC,MAAM;YAA+BC,QAAQ;YAAOC,aAAa;YAAgBC,SAAS;YAAiBC,MAAM;YAAMC,SAAS;YAAWzB,aAAa;YAAkG0B,YAAY;gBAAC7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K;QACfqE,UAAUrE,KAAK;QACfsE,SAASlE,SAASY,IAAI;QACtBuD,WAAWnE,SAASI,SAAS;QAC7BgE,iBAAiB9D;QACjB+D,YAAYrE,SAASY,IAAI;QACzB0D,cAAc;YAAE5C,MAAM;YAASR,aAAa;YAA6Bc,OAAO;gBAAEN,MAAM;gBAAUO,sBAAsB;YAAK;QAAE;QAC/HsC,SAAS7D,OAAO6D,OAAO;IACzB;IACAlC,KAAK;QACH;YAAEC,MAAM;YAA6BC,QAAQ;YAAOC,aAAa;YAAcC,SAAS;YAAeC,MAAM;YAAMC,SAAS;YAAS6B,SAAS;gBAAChE,EAAE,WAAW;gBAA4GA,EAAE,UAAU;aAAiB;YAAEoC,YAAY;gBAAC7B;aAAmB;QAAC;QACxU;YAAEuB,MAAM;YAAuCC,QAAQ;YAAOC,aAAa;YAAYC,SAAS;YAAqBE,SAAS;YAASC,YAAY;gBAAC7B;gBAAoB;oBAAES,MAAM;oBAAWN,aAAa;gBAAY;aAAE;QAAC;QACvN;YAAEoB,MAAM;YAAuCC,QAAQ;YAASC,aAAa;YAAeC,SAAS;YAA0BgC,SAAS;YAAc9B,SAAS;YAASzB,aAAa;YAAoH0B,YAAY;gBAAC7B;gBAAoB;oBAAES,MAAM;oBAAWN,aAAa;gBAAY;aAAE;QAAC;KAC1X;AACH,EAAC"}
|
|
@@ -2978,7 +2978,7 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
2978
2978
|
'reservation.balance': balanceNote,
|
|
2979
2979
|
'reservation.ref': String(reservationId)
|
|
2980
2980
|
});
|
|
2981
|
-
await sendEmail(_extends({
|
|
2981
|
+
const emailOutcome = await sendEmail(_extends({
|
|
2982
2982
|
to: guestEmail,
|
|
2983
2983
|
subject: (_ref39 = designed == null ? void 0 : designed.subject) != null ? _ref39 : 'Reservation confirmed',
|
|
2984
2984
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
@@ -2995,7 +2995,8 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
2995
2995
|
}));
|
|
2996
2996
|
// Cost meter (AGL-1438). Transactional: the guest has paid, and a
|
|
2997
2997
|
// confirmation a quota refused reads as a failed reservation.
|
|
2998
|
-
|
|
2998
|
+
// Only a sent email is metered (AGL-4227).
|
|
2999
|
+
if (emailOutcome == null ? void 0 : emailOutcome.sent) await meterHostEmail(String(hostId));
|
|
2999
3000
|
}
|
|
3000
3001
|
}
|
|
3001
3002
|
}
|
|
@@ -3414,7 +3415,7 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
3414
3415
|
// only in the fallback text above never reaches a buyer.
|
|
3415
3416
|
'store.receiptFooter': receiptFooter
|
|
3416
3417
|
}, receiptExtras.tokens));
|
|
3417
|
-
await sendEmail(_extends({
|
|
3418
|
+
const emailOutcome2 = await sendEmail(_extends({
|
|
3418
3419
|
to: buyerEmailForReceipt,
|
|
3419
3420
|
subject: (_ref51 = designed == null ? void 0 : designed.subject) != null ? _ref51 : `Receipt for your order`,
|
|
3420
3421
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
@@ -3431,7 +3432,8 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
3431
3432
|
}));
|
|
3432
3433
|
// Cost meter (AGL-1438). Transactional: a dropped receipt looks to
|
|
3433
3434
|
// the buyer like an order that did not go through.
|
|
3434
|
-
|
|
3435
|
+
// Only a sent email is metered (AGL-4227).
|
|
3436
|
+
if (emailOutcome2 == null ? void 0 : emailOutcome2.sent) await meterHostEmail(String(hostId));
|
|
3435
3437
|
}
|
|
3436
3438
|
// Inventory per line (AGL-281 semantics).
|
|
3437
3439
|
for (const line of cart.lines){
|
|
@@ -3698,7 +3700,7 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
3698
3700
|
'giftcard.value': giftValue,
|
|
3699
3701
|
'giftcard.note': ''
|
|
3700
3702
|
});
|
|
3701
|
-
await sendEmail(_extends({
|
|
3703
|
+
const emailOutcome3 = await sendEmail(_extends({
|
|
3702
3704
|
to: giftTo,
|
|
3703
3705
|
subject: (_ref57 = designed == null ? void 0 : designed.subject) != null ? _ref57 : 'Your gift card',
|
|
3704
3706
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
@@ -3715,7 +3717,8 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
3715
3717
|
}));
|
|
3716
3718
|
// Cost meter (AGL-1438). Transactional: this email IS the
|
|
3717
3719
|
// purchased goods.
|
|
3718
|
-
|
|
3720
|
+
// Only a sent email is metered (AGL-4227).
|
|
3721
|
+
if (emailOutcome3 == null ? void 0 : emailOutcome3.sent) await meterHostEmail(String(hostId));
|
|
3719
3722
|
}
|
|
3720
3723
|
}
|
|
3721
3724
|
}
|
|
@@ -4534,7 +4537,7 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
4534
4537
|
].filter(Boolean).join(', '),
|
|
4535
4538
|
payload.shippingAddress.country
|
|
4536
4539
|
].filter(Boolean).join(', ') : '';
|
|
4537
|
-
await sendEmail({
|
|
4540
|
+
const emailOutcome4 = await sendEmail({
|
|
4538
4541
|
to: supplier.email,
|
|
4539
4542
|
subject: `New order to fulfill for ${storeName}: ${payload.productName}`,
|
|
4540
4543
|
// The tracking link opens a form for the carrier and the
|
|
@@ -4552,7 +4555,8 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
4552
4555
|
});
|
|
4553
4556
|
// Cost meter (AGL-1438). Transactional: without it the order is
|
|
4554
4557
|
// never fulfilled.
|
|
4555
|
-
|
|
4558
|
+
// Only a sent email is metered (AGL-4227).
|
|
4559
|
+
if (emailOutcome4 == null ? void 0 : emailOutcome4.sent) await meterHostEmail(String(hostId));
|
|
4556
4560
|
}
|
|
4557
4561
|
} catch (routingError) {
|
|
4558
4562
|
console.error('Dropship routing failed', routingError);
|
|
@@ -4675,7 +4679,7 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
4675
4679
|
'order.ref': String(object.id),
|
|
4676
4680
|
'store.receiptFooter': receiptFooter
|
|
4677
4681
|
}, receiptExtras.tokens));
|
|
4678
|
-
await sendEmail(_extends({
|
|
4682
|
+
const emailOutcome5 = await sendEmail(_extends({
|
|
4679
4683
|
to: String(buyerEmail),
|
|
4680
4684
|
subject: (_ref90 = designed == null ? void 0 : designed.subject) != null ? _ref90 : `Receipt: ${productName}`,
|
|
4681
4685
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
@@ -4691,7 +4695,8 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
4691
4695
|
owedFor: 'order'
|
|
4692
4696
|
}));
|
|
4693
4697
|
// Cost meter (AGL-1438). Transactional, as the cart receipt above.
|
|
4694
|
-
|
|
4698
|
+
// Only a sent email is metered (AGL-4227).
|
|
4699
|
+
if (emailOutcome5 == null ? void 0 : emailOutcome5.sent) await meterHostEmail(String(hostId));
|
|
4695
4700
|
}
|
|
4696
4701
|
const hostSnapshot = await hostRef.get();
|
|
4697
4702
|
const sellerUid = (_this3 = await getOrgForHost(String(hostId))) == null ? void 0 : (_org = _this3.org) == null ? void 0 : _org.ownerUid;
|
|
@@ -4723,7 +4728,7 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
4723
4728
|
'order.ref': String(object.id),
|
|
4724
4729
|
'orders.url': await hostConsoleUrl(String(hostId), `/${hostId}/products/orders`)
|
|
4725
4730
|
});
|
|
4726
|
-
await sendEmail(_extends({
|
|
4731
|
+
const emailOutcome6 = await sendEmail(_extends({
|
|
4727
4732
|
to: seller.email,
|
|
4728
4733
|
subject: (_ref91 = designed == null ? void 0 : designed.subject) != null ? _ref91 : `New order: ${productName}`,
|
|
4729
4734
|
text: (designed == null ? void 0 : designed.text) || fallbackText
|
|
@@ -4740,7 +4745,8 @@ export const commerceBillingWebhookHandler = async ({ type, object, event, reque
|
|
|
4740
4745
|
}));
|
|
4741
4746
|
// Cost meter (AGL-1438). Transactional: the seller learns about
|
|
4742
4747
|
// the order here.
|
|
4743
|
-
|
|
4748
|
+
// Only a sent email is metered (AGL-4227).
|
|
4749
|
+
if (emailOutcome6 == null ? void 0 : emailOutcome6.sent) await meterHostEmail(String(hostId));
|
|
4744
4750
|
}
|
|
4745
4751
|
}
|
|
4746
4752
|
}
|