@aglyn/plugins-commerce 1.34.2 → 1.35.1
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/console/woo-connections-card.component.d.ts +52 -0
- package/src/lib/components/console/woo-connections-card.component.js +189 -0
- package/src/lib/components/console/woo-connections-card.component.js.map +1 -0
- package/src/lib/plugin.js +13 -1
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/order-event-triggers.js +9 -0
- package/src/lib/server/order-event-triggers.js.map +1 -1
- package/src/lib/server/woo/woo-connections.d.ts +23 -0
- package/src/lib/server/woo/woo-connections.js +109 -0
- package/src/lib/server/woo/woo-connections.js.map +1 -0
- package/src/lib/server/woo/woo-context.d.ts +45 -0
- package/src/lib/server/woo/woo-context.js +36 -0
- package/src/lib/server/woo/woo-context.js.map +1 -0
- package/src/lib/server/woo/woo-ids.d.ts +45 -0
- package/src/lib/server/woo/woo-ids.js +141 -0
- package/src/lib/server/woo/woo-ids.js.map +1 -0
- package/src/lib/server/woo/woo-meta.d.ts +68 -0
- package/src/lib/server/woo/woo-meta.js +127 -0
- package/src/lib/server/woo/woo-meta.js.map +1 -0
- package/src/lib/server/woo/woo-orders.d.ts +136 -0
- package/src/lib/server/woo/woo-orders.js +378 -0
- package/src/lib/server/woo/woo-orders.js.map +1 -0
- package/src/lib/server/woo/woo-products.d.ts +19 -0
- package/src/lib/server/woo/woo-products.js +662 -0
- package/src/lib/server/woo/woo-products.js.map +1 -0
- package/src/lib/server/woo/woo-route.d.ts +49 -0
- package/src/lib/server/woo/woo-route.js +333 -0
- package/src/lib/server/woo/woo-route.js.map +1 -0
- package/src/lib/server/woo/woo-shapes.d.ts +421 -0
- package/src/lib/server/woo/woo-shapes.js +835 -0
- package/src/lib/server/woo/woo-shapes.js.map +1 -0
- package/src/lib/server/woo/woo-system.d.ts +35 -0
- package/src/lib/server/woo/woo-system.js +339 -0
- package/src/lib/server/woo/woo-system.js.map +1 -0
- package/src/lib/server/woo/woo-webhooks.d.ts +53 -0
- package/src/lib/server/woo/woo-webhooks.js +204 -0
- package/src/lib/server/woo/woo-webhooks.js.map +1 -0
- package/src/lib/server.js +17 -0
- package/src/lib/server.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.35.1",
|
|
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.35.1",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.35.1",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.35.1",
|
|
31
|
+
"@aglyn/shared-ui-next": "1.35.1",
|
|
32
|
+
"@aglyn/shared-ui-snackstack": "1.35.1",
|
|
33
|
+
"@aglyn/shared-util-email": "1.35.1",
|
|
34
|
+
"@aglyn/shared-util-http": "1.35.1",
|
|
35
|
+
"@aglyn/shared-util-timestamp": "1.35.1",
|
|
36
|
+
"@aglyn/shared-util-tools": "1.35.1",
|
|
37
|
+
"@aglyn/tenant-data-admin": "1.35.1",
|
|
38
|
+
"@aglyn/tenant-feature-instance": "1.35.1",
|
|
39
|
+
"@aglyn/tenant-runtime": "1.35.1",
|
|
40
40
|
"@stripe/react-stripe-js": "^7.0.1",
|
|
41
41
|
"@stripe/stripe-js": "^10.2.1",
|
|
42
42
|
"@swc/helpers": "0.5.24",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/** One app linked through the WooCommerce connector, as the route shows it. */
|
|
18
|
+
export interface WooConnectionRow {
|
|
19
|
+
grantId: string;
|
|
20
|
+
appName: string;
|
|
21
|
+
sentTo: string;
|
|
22
|
+
keyEnding: string | null;
|
|
23
|
+
connectedBy: string | null;
|
|
24
|
+
connectedAt: string | null;
|
|
25
|
+
lastUsedAt: string | null;
|
|
26
|
+
access: 'read' | 'read_write';
|
|
27
|
+
}
|
|
28
|
+
export interface WooConnectionsState {
|
|
29
|
+
canManage: boolean;
|
|
30
|
+
connections: WooConnectionRow[];
|
|
31
|
+
}
|
|
32
|
+
/** The card's way to its route; a spec hands its own. */
|
|
33
|
+
export interface WooConnectionsApi {
|
|
34
|
+
list(): Promise<WooConnectionsState>;
|
|
35
|
+
disconnect(grantId: string): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export declare function useWooConnectionsApi(hostId: string): WooConnectionsApi;
|
|
38
|
+
export interface WooConnectionsCardProps {
|
|
39
|
+
hostId: string;
|
|
40
|
+
/** Test seam: the API; the route by default. */
|
|
41
|
+
api?: WooConnectionsApi;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* CONNECTED APPS on the store's Integrations page: the apps that linked this
|
|
45
|
+
* store through their WooCommerce connector (print-on-demand services such
|
|
46
|
+
* as Tapstitch), what each may do and when it last called, and Disconnect.
|
|
47
|
+
* Draws nothing for a person who may not read the store's orders, and
|
|
48
|
+
* nothing while no app is linked, so a store that never used it sees no
|
|
49
|
+
* card about it.
|
|
50
|
+
*/
|
|
51
|
+
export declare function WooConnectionsCard(props: WooConnectionsCardProps): import("react").JSX.Element;
|
|
52
|
+
export default WooConnectionsCard;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2026 Aglyn LLC
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/ import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
19
|
+
import { CardDisplay, useConfirmationContext } from "@aglyn/shared-ui-jsx";
|
|
20
|
+
import EmptyStateComponent from "@aglyn/shared-ui-jsx/components/empty-state.component";
|
|
21
|
+
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
22
|
+
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
23
|
+
import { useUser } from "@aglyn/tenant-feature-instance";
|
|
24
|
+
import { Alert, Button, List, ListItem, ListItemText, Typography } from "@mui/material";
|
|
25
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
26
|
+
const ROUTE = '/api/commerce/woo-connections';
|
|
27
|
+
export function useWooConnectionsApi(hostId) {
|
|
28
|
+
const { data: user } = useUser();
|
|
29
|
+
return useMemo(()=>{
|
|
30
|
+
const read = async (response)=>{
|
|
31
|
+
var _ref;
|
|
32
|
+
const answer = await response.json().catch(()=>({}));
|
|
33
|
+
if (!response.ok) throw new Error((_ref = answer == null ? void 0 : answer.error) != null ? _ref : 'Something went wrong. Try again.');
|
|
34
|
+
return answer;
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
list: async ()=>read(await authorizedFetch(user, `${ROUTE}?${new URLSearchParams({
|
|
38
|
+
hostId
|
|
39
|
+
}).toString()}`, {
|
|
40
|
+
method: 'GET'
|
|
41
|
+
})),
|
|
42
|
+
disconnect: async (grantId)=>{
|
|
43
|
+
await read(await authorizedFetch(user, ROUTE, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json'
|
|
47
|
+
},
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
hostId,
|
|
50
|
+
grantId
|
|
51
|
+
})
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
hostId,
|
|
57
|
+
user
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
const when = (iso)=>iso ? new Date(iso).toLocaleString() : 'Not yet';
|
|
61
|
+
/**
|
|
62
|
+
* CONNECTED APPS on the store's Integrations page: the apps that linked this
|
|
63
|
+
* store through their WooCommerce connector (print-on-demand services such
|
|
64
|
+
* as Tapstitch), what each may do and when it last called, and Disconnect.
|
|
65
|
+
* Draws nothing for a person who may not read the store's orders, and
|
|
66
|
+
* nothing while no app is linked, so a store that never used it sees no
|
|
67
|
+
* card about it.
|
|
68
|
+
*/ export function WooConnectionsCard(props) {
|
|
69
|
+
var _props_api;
|
|
70
|
+
const routeApi = useWooConnectionsApi(props.hostId);
|
|
71
|
+
const api = (_props_api = props.api) != null ? _props_api : routeApi;
|
|
72
|
+
const { confirm } = useConfirmationContext();
|
|
73
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
74
|
+
const [state, setState] = useState(null);
|
|
75
|
+
const [error, setError] = useState(null);
|
|
76
|
+
const [busy, setBusy] = useState(null);
|
|
77
|
+
const refresh = useCallback(async ()=>{
|
|
78
|
+
try {
|
|
79
|
+
setState(await api.list());
|
|
80
|
+
} catch (unused) {
|
|
81
|
+
setState(null);
|
|
82
|
+
}
|
|
83
|
+
}, [
|
|
84
|
+
api
|
|
85
|
+
]);
|
|
86
|
+
useEffect(()=>{
|
|
87
|
+
void refresh();
|
|
88
|
+
}, [
|
|
89
|
+
refresh
|
|
90
|
+
]);
|
|
91
|
+
const disconnect = useCallback(async (row)=>{
|
|
92
|
+
const confirmed = await confirm({
|
|
93
|
+
title: `Disconnect ${row.appName}?`,
|
|
94
|
+
description: `${row.appName} can no longer read or change this store. Connect it again from ${row.appName} to undo this.`,
|
|
95
|
+
confirmationText: 'Disconnect',
|
|
96
|
+
confirmationButtonProps: {
|
|
97
|
+
color: 'error'
|
|
98
|
+
}
|
|
99
|
+
}).then(()=>true).catch(()=>false);
|
|
100
|
+
if (!confirmed) return;
|
|
101
|
+
setBusy(row.grantId);
|
|
102
|
+
setError(null);
|
|
103
|
+
try {
|
|
104
|
+
await api.disconnect(row.grantId);
|
|
105
|
+
setState((current)=>current ? _extends({}, current, {
|
|
106
|
+
connections: current.connections.filter((entry)=>entry.grantId !== row.grantId)
|
|
107
|
+
}) : current);
|
|
108
|
+
enqueueSnackbar(`${row.appName} is disconnected.`, {
|
|
109
|
+
variant: 'success',
|
|
110
|
+
persist: false
|
|
111
|
+
});
|
|
112
|
+
} catch (cause) {
|
|
113
|
+
setError(cause.message);
|
|
114
|
+
} finally{
|
|
115
|
+
setBusy(null);
|
|
116
|
+
}
|
|
117
|
+
}, [
|
|
118
|
+
api,
|
|
119
|
+
confirm,
|
|
120
|
+
enqueueSnackbar
|
|
121
|
+
]);
|
|
122
|
+
if (!state || state.connections.length === 0) return null;
|
|
123
|
+
return /*#__PURE__*/ _jsxs(CardDisplay, {
|
|
124
|
+
header: "Connected store apps",
|
|
125
|
+
help: pluginDocsHelp('wooConnectApps', {
|
|
126
|
+
anchor: '#disconnect'
|
|
127
|
+
}),
|
|
128
|
+
subheader: "Apps you linked to this store from their own website, such as print-on-demand services.",
|
|
129
|
+
contentGutterX: true,
|
|
130
|
+
contentGutterY: true,
|
|
131
|
+
children: [
|
|
132
|
+
error ? /*#__PURE__*/ _jsx(Alert, {
|
|
133
|
+
severity: "error",
|
|
134
|
+
onClose: ()=>setError(null),
|
|
135
|
+
sx: {
|
|
136
|
+
mb: 1.5
|
|
137
|
+
},
|
|
138
|
+
children: error
|
|
139
|
+
}) : null,
|
|
140
|
+
state.connections.length ? /*#__PURE__*/ _jsx(List, {
|
|
141
|
+
dense: true,
|
|
142
|
+
disablePadding: true,
|
|
143
|
+
"aria-label": "Connected store apps",
|
|
144
|
+
children: state.connections.map((row)=>/*#__PURE__*/ _jsx(ListItem, {
|
|
145
|
+
divider: true,
|
|
146
|
+
disableGutters: true,
|
|
147
|
+
secondaryAction: state.canManage ? /*#__PURE__*/ _jsx(Button, {
|
|
148
|
+
size: "small",
|
|
149
|
+
color: "error",
|
|
150
|
+
disabled: busy === row.grantId,
|
|
151
|
+
onClick: ()=>void disconnect(row),
|
|
152
|
+
children: "Disconnect"
|
|
153
|
+
}) : undefined,
|
|
154
|
+
children: /*#__PURE__*/ _jsx(ListItemText, {
|
|
155
|
+
primary: row.appName,
|
|
156
|
+
secondary: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
159
|
+
component: "span",
|
|
160
|
+
variant: "body2",
|
|
161
|
+
color: "text.secondary",
|
|
162
|
+
sx: {
|
|
163
|
+
display: 'block'
|
|
164
|
+
},
|
|
165
|
+
children: `${row.access === 'read' ? 'Can see products and orders' : 'Can add products and ship orders'} · sends to ${row.sentTo}`
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
168
|
+
component: "span",
|
|
169
|
+
variant: "body2",
|
|
170
|
+
color: "text.secondary",
|
|
171
|
+
sx: {
|
|
172
|
+
display: 'block'
|
|
173
|
+
},
|
|
174
|
+
children: `Connected ${when(row.connectedAt)}${row.connectedBy ? ` by ${row.connectedBy}` : ''} · Last used: ${when(row.lastUsedAt)}`
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
}, row.grantId))
|
|
180
|
+
}) : /*#__PURE__*/ _jsx(EmptyStateComponent, {
|
|
181
|
+
compact: true,
|
|
182
|
+
label: "No apps are connected to this store."
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
export default WooConnectionsCard;
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=woo-connections-card.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/woo-connections-card.component.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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay, useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport EmptyStateComponent from '@aglyn/shared-ui-jsx/components/empty-state.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport { Alert, Button, List, ListItem, ListItemText, Typography } from '@mui/material'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\n\n/** One app linked through the WooCommerce connector, as the route shows it. */\nexport interface WooConnectionRow {\n grantId: string\n appName: string\n sentTo: string\n keyEnding: string | null\n connectedBy: string | null\n connectedAt: string | null\n lastUsedAt: string | null\n access: 'read' | 'read_write'\n}\n\nexport interface WooConnectionsState {\n canManage: boolean\n connections: WooConnectionRow[]\n}\n\n/** The card's way to its route; a spec hands its own. */\nexport interface WooConnectionsApi {\n list(): Promise<WooConnectionsState>\n disconnect(grantId: string): Promise<void>\n}\n\nconst ROUTE = '/api/commerce/woo-connections'\n\nexport function useWooConnectionsApi(hostId: string): WooConnectionsApi {\n const { data: user } = useUser()\n return useMemo(() => {\n const read = async <T,>(response: Response): Promise<T> => {\n const answer = (await response.json().catch(() => ({}))) as T & { error?: string }\n if (!response.ok) throw new Error(answer?.error ?? 'Something went wrong. Try again.')\n return answer\n }\n return {\n list: async () =>\n read<WooConnectionsState>(\n await authorizedFetch(user as never, `${ROUTE}?${new URLSearchParams({ hostId }).toString()}`, { method: 'GET' }),\n ),\n disconnect: async (grantId) => {\n await read(\n await authorizedFetch(user as never, ROUTE, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, grantId }),\n }),\n )\n },\n }\n }, [hostId, user])\n}\n\nexport interface WooConnectionsCardProps {\n hostId: string\n /** Test seam: the API; the route by default. */\n api?: WooConnectionsApi\n}\n\nconst when = (iso: string | null): string => (iso ? new Date(iso).toLocaleString() : 'Not yet')\n\n/**\n * CONNECTED APPS on the store's Integrations page: the apps that linked this\n * store through their WooCommerce connector (print-on-demand services such\n * as Tapstitch), what each may do and when it last called, and Disconnect.\n * Draws nothing for a person who may not read the store's orders, and\n * nothing while no app is linked, so a store that never used it sees no\n * card about it.\n */\nexport function WooConnectionsCard(props: WooConnectionsCardProps) {\n const routeApi = useWooConnectionsApi(props.hostId)\n const api = props.api ?? routeApi\n const { confirm } = useConfirmationContext()\n const { enqueueSnackbar } = useSnackbar()\n const [state, setState] = useState<WooConnectionsState | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [busy, setBusy] = useState<string | null>(null)\n\n const refresh = useCallback(async () => {\n try {\n setState(await api.list())\n } catch {\n setState(null)\n }\n }, [api])\n\n useEffect(() => {\n void refresh()\n }, [refresh])\n\n const disconnect = useCallback(\n async (row: WooConnectionRow) => {\n const confirmed = await confirm({\n title: `Disconnect ${row.appName}?`,\n description: `${row.appName} can no longer read or change this store. Connect it again from ${row.appName} to undo this.`,\n confirmationText: 'Disconnect',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n setBusy(row.grantId)\n setError(null)\n try {\n await api.disconnect(row.grantId)\n setState((current) =>\n current ? { ...current, connections: current.connections.filter((entry) => entry.grantId !== row.grantId) } : current,\n )\n enqueueSnackbar(`${row.appName} is disconnected.`, { variant: 'success', persist: false })\n } catch (cause) {\n setError((cause as Error).message)\n } finally {\n setBusy(null)\n }\n },\n [api, confirm, enqueueSnackbar],\n )\n\n if (!state || state.connections.length === 0) return null\n\n return (\n <CardDisplay\n header=\"Connected store apps\"\n help={pluginDocsHelp('wooConnectApps', { anchor: '#disconnect' })}\n subheader=\"Apps you linked to this store from their own website, such as print-on-demand services.\"\n contentGutterX\n contentGutterY\n >\n {error ? (\n <Alert severity=\"error\" onClose={() => setError(null)} sx={{ mb: 1.5 }}>\n {error}\n </Alert>\n ) : null}\n {state.connections.length ? (\n <List dense disablePadding aria-label=\"Connected store apps\">\n {state.connections.map((row) => (\n <ListItem\n key={row.grantId}\n divider\n disableGutters\n secondaryAction={\n state.canManage ? (\n <Button size=\"small\" color=\"error\" disabled={busy === row.grantId} onClick={() => void disconnect(row)}>\n Disconnect\n </Button>\n ) : undefined\n }\n >\n <ListItemText\n primary={row.appName}\n secondary={\n <>\n <Typography component=\"span\" variant=\"body2\" color=\"text.secondary\" sx={{ display: 'block' }}>\n {`${row.access === 'read' ? 'Can see products and orders' : 'Can add products and ship orders'} · sends to ${row.sentTo}`}\n </Typography>\n <Typography component=\"span\" variant=\"body2\" color=\"text.secondary\" sx={{ display: 'block' }}>\n {`Connected ${when(row.connectedAt)}${row.connectedBy ? ` by ${row.connectedBy}` : ''} · Last used: ${when(row.lastUsedAt)}`}\n </Typography>\n </>\n }\n />\n </ListItem>\n ))}\n </List>\n ) : (\n <EmptyStateComponent compact label=\"No apps are connected to this store.\" />\n )}\n </CardDisplay>\n )\n}\n\nexport default WooConnectionsCard\n"],"names":["pluginDocsHelp","CardDisplay","useConfirmationContext","EmptyStateComponent","useSnackbar","authorizedFetch","useUser","Alert","Button","List","ListItem","ListItemText","Typography","useCallback","useEffect","useMemo","useState","ROUTE","useWooConnectionsApi","hostId","data","user","read","response","answer","json","catch","ok","Error","error","list","URLSearchParams","toString","method","disconnect","grantId","headers","body","JSON","stringify","when","iso","Date","toLocaleString","WooConnectionsCard","props","routeApi","api","confirm","enqueueSnackbar","state","setState","setError","busy","setBusy","refresh","row","confirmed","title","appName","description","confirmationText","confirmationButtonProps","color","then","current","connections","filter","entry","variant","persist","cause","message","length","header","help","anchor","subheader","contentGutterX","contentGutterY","severity","onClose","sx","mb","dense","disablePadding","aria-label","map","divider","disableGutters","secondaryAction","canManage","size","disabled","onClick","undefined","primary","secondary","component","display","access","sentTo","connectedAt","connectedBy","lastUsedAt","compact","label"],"mappings":";;AAA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AAC,UAAU,EAAE3D,KAAKgB,IAAI8C,WAAW,IAAI9C,IAAI+C,WAAW,GAAG,CAAC,IAAI,EAAE/C,IAAI+C,WAAW,EAAE,GAAG,GAAG,cAAc,EAAE/D,KAAKgB,IAAIgD,UAAU,GAAG;;;;;uBAnB/HhD,IAAIrB,OAAO;+BA4BtB,KAAChC;gBAAoBsG,OAAO;gBAACC,OAAM;;;;AAI3C;AAEA,eAAe9D,mBAAkB"}
|
package/src/lib/plugin.js
CHANGED
|
@@ -26,7 +26,10 @@ const PosHardwareTermsSignPage = lazy(()=>import("./components/console/pos-hardw
|
|
|
26
26
|
const CommerceGlanceCard = lazy(()=>import("./components/console/commerce-glance-card.component.js"));
|
|
27
27
|
const NewestSiteUsersCard = lazy(()=>import("./components/console/newest-site-users-card.component.js"));
|
|
28
28
|
const SiteMemberPurchases = lazy(()=>import("./components/console/site-member-purchases.component.js"));
|
|
29
|
-
/** "Do you charge sales tax?" in Create site (AGL-4061): loads only with that dialog. */
|
|
29
|
+
/** "Do you charge sales tax?" in Create site (AGL-4061): loads only with that dialog. */ // Apps linked through the WooCommerce connector, on the store's
|
|
30
|
+
// Integrations page (`server/woo/woo-connections.ts`).
|
|
31
|
+
const WooConnectionsCard = lazy(()=>import("./components/console/woo-connections-card.component.js"));
|
|
32
|
+
const NewStoreTaxQuestion = lazy(()=>import("./components/console/new-store-tax-question.component.js"));
|
|
30
33
|
import { COMMERCE_CONSOLE_SECTIONS, COMMERCE_RETIRED_SECTIONS } from "./components/commerce-console-sections.js";
|
|
31
34
|
import { BUNDLE_ID } from "./constants/bundle-common.js";
|
|
32
35
|
import { COMMERCE_PERMISSIONS } from "./model/plugin-permissions.js";
|
|
@@ -181,6 +184,15 @@ const QuoteStartFromContact = lazy(()=>import("./components/console/quote-start.
|
|
|
181
184
|
// first sale. It hands its answer to the dialog and writes nothing; the
|
|
182
185
|
// create applies it (`declarations.console-server.ts`). Creating a site
|
|
183
186
|
// is the create's permission, as the starter picker's.
|
|
187
|
+
// The apps linked to the store through their WooCommerce connector,
|
|
188
|
+
// with Disconnect, on the store's Integrations page. Draws nothing
|
|
189
|
+
// until an app is linked.
|
|
190
|
+
{
|
|
191
|
+
slot: 'hostSettings',
|
|
192
|
+
widgetId: 'commerce-woo-connections',
|
|
193
|
+
title: 'Connected store apps',
|
|
194
|
+
Component: WooConnectionsCard
|
|
195
|
+
},
|
|
184
196
|
{
|
|
185
197
|
slot: 'hostCreateQuestions',
|
|
186
198
|
widgetId: 'commerce-new-store-tax',
|
package/src/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/commerce/src/lib/plugin.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 * as Aglyn from '@aglyn/aglyn'\nimport { mdiStorefrontOutline } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nconst PosConsolePage = lazy(() => import('./components/console/pos-page.component'))\n/** The customer display (AGL-3608): loads only on the public page that shows it. */\nconst PosDisplayPage = lazy(() => import('./components/console/pos-display-page.component'))\nconst PosKioskPage = lazy(() => import('./components/console/pos-kiosk-page.component'))\nconst PosHardwareTermsPage = lazy(() => import('./components/console/pos-hardware-terms-page.component'))\nconst PosHardwareTermsSignPage = lazy(() => import('./components/console/pos-hardware-terms-sign-page.component'))\n/** Staff → Hardware orders (AGL-4038): loads only on its staff page. */\nconst PosHardwareOrdersStaffPage = lazy(\n () => import('./components/console/pos-hardware-orders-staff-page.component'),\n)\n/** Staff → Reader start-up screen (AGL-4048): loads only on its staff page. */\nconst PosReaderSplashStaffPage = lazy(\n () => import('./components/console/pos-reader-splash-staff-page.component'),\n)\nconst CommerceGlanceCard = lazy(\n () => import('./components/console/commerce-glance-card.component'),\n)\nconst NewestSiteUsersCard = lazy(\n () => import('./components/console/newest-site-users-card.component'),\n)\nconst SiteMemberPurchases = lazy(\n () => import('./components/console/site-member-purchases.component'),\n)\n/** \"Do you charge sales tax?\" in Create site (AGL-4061): loads only with that dialog. */\nconst NewStoreTaxQuestion = lazy(\n () => import('./components/console/new-store-tax-question.component'),\n)\nimport {\n COMMERCE_CONSOLE_SECTIONS,\n COMMERCE_RETIRED_SECTIONS,\n} from './components/commerce-console-sections'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { COMMERCE_PERMISSIONS } from './model/plugin-permissions'\nimport { registerCommerceRecordLists } from './model/commerce-record-lists'\nimport { registerCommerceRecordRoutes } from './model/commerce-record-routes'\nimport { registerCommerceZones } from './components/console/product-zones'\nimport { registerCommerceOrderZones } from './components/console/order-zones'\nimport { registerCommerceReturnZones } from './components/console/return-zones'\nimport { registerCommerceStoreZones } from './components/console/store-zones'\nimport { registerCommercePosZones } from './components/console/pos-zones'\nimport { registerCommerceTransferUi } from './transfer/register-transfer-ui'\nimport { COMMERCE_SEARCH_SOURCES } from './model/commerce-search-sources'\nimport { COMMERCE_CONFIG_SCHEMA } from './plugin-config'\n\n/** Code-split: the Products console page only loads when opened. */\nconst CommerceConsolePage = lazy(() => import('./components/commerce-console-page'))\n/** \"Start a quote\" on a quote request in the Inbox and on a contact in the CRM (AGL-4098). */\nconst QuoteStartFromRequest = lazy(() => import('./components/console/quote-start.component'))\nconst QuoteStartFromContact = lazy(() =>\n import('./components/console/quote-start.component').then((module) => ({ default: module.QuoteStartFromContact })),\n)\n\n/**\n * Console half (AGL-395): registers the Products nav item in the\n * ConsoleExtension registry so the commerce console surface is owned by the\n * plugin, like events and email. The page body still lives in the console\n * app (`/[hostId]/products`): its product editor depends on the app's media\n * browser, which transitively pulls in the org/session context, so a full\n * body relocation needs a plugin-consumable media-picker context first —\n * tracked as follow-up. The nav item omits a `Component`, so the shell's\n * nav renders the link and the existing named route serves the page.\n */\nexport function registerCommerceConsole(): void {\n // Where a product is read, for surfaces outside this plugin (AGL-3080).\n registerCommerceRecordRoutes()\n registerCommerceRecordLists()\n // The zones its product editor, products hub and CSV import dialog host,\n // with the props each hands a widget (AGL-2916, AGL-3080).\n registerCommerceZones()\n // …and the order dialog's two (AGL-3611), where a shipping plugin's widget\n // buys a label and records the shipment through the dialog's own route.\n registerCommerceOrderZones()\n // …and the return dialog's (AGL-3611), where a shipping plugin's widget\n // buys the buyer a return label and attaches it through this plugin's route.\n registerCommerceReturnZones()\n // The orders list's bulk actions and the store's Settings (AGL-3612).\n registerCommerceStoreZones()\n // The register's orders from other channels — a delivery app's (AGL-3644).\n registerCommercePosZones()\n // Its import and export resources' names and the products wizard's own\n // step (AGL-3531); the server halves register from the console's server\n // declarations.\n registerCommerceTransferUi()\n // Plugin-declared permissions (AGL-435): tier defaults ride every\n // resolved role set; custom roles override key-by-key.\n Aglyn.registerPluginPermissions(COMMERCE_PERMISSIONS)\n // Register discount ceiling (AGL-2161) — the generic settings card renders\n // it from this schema, so there is no bespoke UI to keep in sync.\n Aglyn.registerPluginConfigSchema(COMMERCE_CONFIG_SCHEMA)\n Aglyn.registerConsoleExtension({\n pluginId: BUNDLE_ID,\n displayName: 'Commerce',\n searchSources: COMMERCE_SEARCH_SOURCES,\n // The screen a register turns toward its customer (AGL-3608), at\n // `/kiosk/commerce/pos-display`. No staff session: the device proves\n // itself with the display token it got by pairing, and\n // `server/pos-display.ts` refuses every read without one.\n // Every workspace's orders from the POS hardware shop (AGL-4038), where\n // staff record Stripe's order id and the tracking, move each order on,\n // and cancel or refund one that has not shipped. The staff area loads\n // this registrar through commerce's `staff` surface.\n staffPages: [\n {\n id: 'hardware-orders',\n label: 'Hardware orders',\n header: { title: 'Hardware Orders', docsTopic: 'posHardware' },\n Component: PosHardwareOrdersStaffPage,\n },\n // The platform's default card reader start-up screen (AGL-4048), which\n // every store that has not picked its own logo or image shows.\n {\n id: 'reader-start-up-screen',\n label: 'Reader start-up screen',\n header: { title: 'Reader Start-up Screen', docsTopic: 'posHardware' },\n Component: PosReaderSplashStaffPage,\n },\n ],\n publicPages: [\n { path: '/pos-display', title: 'Customer display', Component: PosDisplayPage },\n // The self-service kiosk (AGL-3623), paired the same way with a kiosk\n // code; `server/pos-kiosk.ts` refuses every call without its token.\n { path: '/pos-kiosk', title: 'Self-service kiosk', Component: PosKioskPage },\n // The terms of sale for a card reader sold at the platform's register\n // (AGL-4038): on its customer display, by the display's own token\n // (`server/pos-display.ts`), and the printable booth sign, which holds\n // only the published terms' address and summary.\n { path: '/hardware-terms', title: 'Terms of sale', Component: PosHardwareTermsPage },\n { path: '/hardware-terms-sign', title: 'Terms of sale sign', Component: PosHardwareTermsSignPage },\n ],\n // Dashboard/analytics glance card (AGL-419): rendered through the\n // shell's 'commerceGlance' widget slot.\n widgets: [\n {\n slot: 'commerceGlance',\n widgetId: 'commerce-glance',\n title: 'Commerce',\n Component: CommerceGlanceCard,\n },\n // What a site user bought — lifetime total, orders and subscriptions —\n // in their drawer on the site's Users page: the orders and\n // subscriptions are this plugin's.\n {\n slot: Aglyn.CONSOLE_WIDGET_SLOTS.siteMember,\n widgetId: 'commerce-site-member-purchases',\n title: 'Purchases',\n Component: SiteMemberPurchases,\n },\n // Start a quote from a quote request, among an open submission's\n // actions in the Inbox, and from a contact, in its header in the CRM\n // (AGL-4098). Each zone is its host's; neither host imports this plugin.\n {\n slot: 'inboxSubmissionActions',\n widgetId: 'commerce-quote-from-request',\n title: 'Start a quote',\n Component: QuoteStartFromRequest,\n },\n {\n slot: 'crmRecordActions',\n widgetId: 'commerce-quote-from-contact',\n title: 'Start a quote',\n Component: QuoteStartFromContact,\n },\n // \"Do you charge sales tax?\" among Create site's fields (AGL-4061),\n // asked before the site exists, so the store is decided before its\n // first sale. It hands its answer to the dialog and writes nothing; the\n // create applies it (`declarations.console-server.ts`). Creating a site\n // is the create's permission, as the starter picker's.\n {\n slot: 'hostCreateQuestions',\n widgetId: 'commerce-new-store-tax',\n permission: 'hosts.create',\n Component: NewStoreTaxQuestion,\n },\n ],\n navItems: [\n {\n label: 'Products',\n href: '/products',\n icon: { path: mdiStorefrontOutline.path },\n // Sections as ROUTES (AGL-2501): `/products/orders` and friends are\n // real URLs the shell resolves and gates, so the page mounts the one\n // being read instead of subscribing all six.\n sections: COMMERCE_CONSOLE_SECTIONS,\n // `/products/settings` was split into a page per setting (AGL-3713);\n // links to it open the first of them.\n retiredSections: COMMERCE_RETIRED_SECTIONS,\n header: {\n title: 'Products',\n icon: { path: mdiStorefrontOutline.path },\n // The overview, not `catalog`: this surface is the whole commerce\n // console — Catalog, Orders, Promotions and Reservations.\n docsTopic: 'commerce',\n },\n Component: CommerceConsolePage,\n },\n {\n // POS register (AGL-312/419): relocated from the app's /pos route —\n // the generic [pluginSlug] shell now serves it at the same URL.\n label: 'POS',\n href: '/pos',\n /*\n * WHO may open the register, declared on THIS nav item rather than on\n * the extension.\n *\n * A key here narrows one surface; a key on the extension would gate\n * every surface it registers, and Products is the sibling — a catalog\n * anyone who works on the site may open. The register is the one that\n * takes money and lists checked-in guests by name, so the two\n * genuinely have different answers and only this one is narrowed.\n *\n * `managePos` rather than a dotted catalog key because it is the key\n * the sale itself is refused by: `server/pos-order.ts` resolves the\n * member's permission map and returns 403 unless `managePos` holds.\n * The shell answers this declaration out of that same resolved map, so\n * the console offers a register exactly to the people the route will\n * accept a sale from — the gate and its server twin cannot disagree,\n * because they are reading one value.\n *\n * `pos-order.ts` stays the enforcement point regardless. This decides\n * whether the surface is built at all, which is the part a check\n * inside the page cannot do: by the time the page can refuse itself it\n * has mounted and its product, register, location and reservation\n * listeners are already open.\n */\n permission: 'managePos',\n icon: { path: mdiStorefrontOutline.path },\n header: { title: 'Point of Sale', docsTopic: 'pos' },\n Component: PosConsolePage,\n },\n ],\n })\n /*\n * The USER ACCOUNTS half, registered under its own id.\n *\n * `accounts` is a switch rather than a bundle: the member blocks and every\n * `membership/*` handler ship inside this package, which is why the id\n * carries no loader manifest entry of its own. A second extension is how a\n * card about visitor accounts is gated on the switch that decides whether\n * the site serves them — `listConsoleWidgets` filters by the workspace's\n * effective plugin ids, and `accounts` is default-OFF per site.\n *\n * A separate call rather than more widgets on the commerce extension: the\n * registry is keyed by `pluginId` and that key IS the gate, so folding this\n * card in above would have kept the dashboard defect it fixes — `Newest\n * site users` on a site whose /signin returns 404.\n */\n Aglyn.registerConsoleExtension({\n pluginId: Aglyn.ACCOUNTS_PLUGIN_ID,\n displayName: 'User Accounts',\n widgets: [\n {\n slot: Aglyn.CONSOLE_WIDGET_SLOTS.hostDashboard,\n widgetId: 'accounts-newest-site-users',\n title: 'Newest site users',\n Component: NewestSiteUsersCard,\n },\n ],\n })\n}\n\nexport * from './site'\n"],"names":["Aglyn","mdiStorefrontOutline","lazy","PosConsolePage","PosDisplayPage","PosKioskPage","PosHardwareTermsPage","PosHardwareTermsSignPage","PosHardwareOrdersStaffPage","PosReaderSplashStaffPage","CommerceGlanceCard","NewestSiteUsersCard","SiteMemberPurchases","NewStoreTaxQuestion","COMMERCE_CONSOLE_SECTIONS","COMMERCE_RETIRED_SECTIONS","BUNDLE_ID","COMMERCE_PERMISSIONS","registerCommerceRecordLists","registerCommerceRecordRoutes","registerCommerceZones","registerCommerceOrderZones","registerCommerceReturnZones","registerCommerceStoreZones","registerCommercePosZones","registerCommerceTransferUi","COMMERCE_SEARCH_SOURCES","COMMERCE_CONFIG_SCHEMA","CommerceConsolePage","QuoteStartFromRequest","QuoteStartFromContact","then","module","default","registerCommerceConsole","registerPluginPermissions","registerPluginConfigSchema","registerConsoleExtension","pluginId","displayName","searchSources","staffPages","id","label","header","title","docsTopic","Component","publicPages","path","widgets","slot","widgetId","CONSOLE_WIDGET_SLOTS","siteMember","permission","navItems","href","icon","sections","retiredSections","ACCOUNTS_PLUGIN_ID","hostDash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BC,GACDF,YAAY;gBACZG,MAAM;oBAAET,MAAMhD,qBAAqBgD,IAAI;gBAAC;gBACxCL,QAAQ;oBAAEC,OAAO;oBAAiBC,WAAW;gBAAM;gBACnDC,WAAW5C;YACb;SACD;IACH;IACA;;;;;;;;;;;;;;GAcC,GACDH,MAAMqC,wBAAwB,CAAC;QAC7BC,UAAUtC,MAAM6D,kBAAkB;QAClCtB,aAAa;QACbW,SAAS;YACP;gBACEC,MAAMnD,MAAMqD,oBAAoB,CAACS,aAAa;gBAC9CV,UAAU;gBACVP,OAAO;gBACPE,WAAWpC;YACb;SACD;IACH;AACF;AAEA,cAAc,YAAQ"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/commerce/src/lib/plugin.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 * as Aglyn from '@aglyn/aglyn'\nimport { mdiStorefrontOutline } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nconst PosConsolePage = lazy(() => import('./components/console/pos-page.component'))\n/** The customer display (AGL-3608): loads only on the public page that shows it. */\nconst PosDisplayPage = lazy(() => import('./components/console/pos-display-page.component'))\nconst PosKioskPage = lazy(() => import('./components/console/pos-kiosk-page.component'))\nconst PosHardwareTermsPage = lazy(() => import('./components/console/pos-hardware-terms-page.component'))\nconst PosHardwareTermsSignPage = lazy(() => import('./components/console/pos-hardware-terms-sign-page.component'))\n/** Staff → Hardware orders (AGL-4038): loads only on its staff page. */\nconst PosHardwareOrdersStaffPage = lazy(\n () => import('./components/console/pos-hardware-orders-staff-page.component'),\n)\n/** Staff → Reader start-up screen (AGL-4048): loads only on its staff page. */\nconst PosReaderSplashStaffPage = lazy(\n () => import('./components/console/pos-reader-splash-staff-page.component'),\n)\nconst CommerceGlanceCard = lazy(\n () => import('./components/console/commerce-glance-card.component'),\n)\nconst NewestSiteUsersCard = lazy(\n () => import('./components/console/newest-site-users-card.component'),\n)\nconst SiteMemberPurchases = lazy(\n () => import('./components/console/site-member-purchases.component'),\n)\n/** \"Do you charge sales tax?\" in Create site (AGL-4061): loads only with that dialog. */\n// Apps linked through the WooCommerce connector, on the store's\n// Integrations page (`server/woo/woo-connections.ts`).\nconst WooConnectionsCard = lazy(() => import('./components/console/woo-connections-card.component'))\nconst NewStoreTaxQuestion = lazy(\n () => import('./components/console/new-store-tax-question.component'),\n)\nimport {\n COMMERCE_CONSOLE_SECTIONS,\n COMMERCE_RETIRED_SECTIONS,\n} from './components/commerce-console-sections'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { COMMERCE_PERMISSIONS } from './model/plugin-permissions'\nimport { registerCommerceRecordLists } from './model/commerce-record-lists'\nimport { registerCommerceRecordRoutes } from './model/commerce-record-routes'\nimport { registerCommerceZones } from './components/console/product-zones'\nimport { registerCommerceOrderZones } from './components/console/order-zones'\nimport { registerCommerceReturnZones } from './components/console/return-zones'\nimport { registerCommerceStoreZones } from './components/console/store-zones'\nimport { registerCommercePosZones } from './components/console/pos-zones'\nimport { registerCommerceTransferUi } from './transfer/register-transfer-ui'\nimport { COMMERCE_SEARCH_SOURCES } from './model/commerce-search-sources'\nimport { COMMERCE_CONFIG_SCHEMA } from './plugin-config'\n\n/** Code-split: the Products console page only loads when opened. */\nconst CommerceConsolePage = lazy(() => import('./components/commerce-console-page'))\n/** \"Start a quote\" on a quote request in the Inbox and on a contact in the CRM (AGL-4098). */\nconst QuoteStartFromRequest = lazy(() => import('./components/console/quote-start.component'))\nconst QuoteStartFromContact = lazy(() =>\n import('./components/console/quote-start.component').then((module) => ({ default: module.QuoteStartFromContact })),\n)\n\n/**\n * Console half (AGL-395): registers the Products nav item in the\n * ConsoleExtension registry so the commerce console surface is owned by the\n * plugin, like events and email. The page body still lives in the console\n * app (`/[hostId]/products`): its product editor depends on the app's media\n * browser, which transitively pulls in the org/session context, so a full\n * body relocation needs a plugin-consumable media-picker context first —\n * tracked as follow-up. The nav item omits a `Component`, so the shell's\n * nav renders the link and the existing named route serves the page.\n */\nexport function registerCommerceConsole(): void {\n // Where a product is read, for surfaces outside this plugin (AGL-3080).\n registerCommerceRecordRoutes()\n registerCommerceRecordLists()\n // The zones its product editor, products hub and CSV import dialog host,\n // with the props each hands a widget (AGL-2916, AGL-3080).\n registerCommerceZones()\n // …and the order dialog's two (AGL-3611), where a shipping plugin's widget\n // buys a label and records the shipment through the dialog's own route.\n registerCommerceOrderZones()\n // …and the return dialog's (AGL-3611), where a shipping plugin's widget\n // buys the buyer a return label and attaches it through this plugin's route.\n registerCommerceReturnZones()\n // The orders list's bulk actions and the store's Settings (AGL-3612).\n registerCommerceStoreZones()\n // The register's orders from other channels — a delivery app's (AGL-3644).\n registerCommercePosZones()\n // Its import and export resources' names and the products wizard's own\n // step (AGL-3531); the server halves register from the console's server\n // declarations.\n registerCommerceTransferUi()\n // Plugin-declared permissions (AGL-435): tier defaults ride every\n // resolved role set; custom roles override key-by-key.\n Aglyn.registerPluginPermissions(COMMERCE_PERMISSIONS)\n // Register discount ceiling (AGL-2161) — the generic settings card renders\n // it from this schema, so there is no bespoke UI to keep in sync.\n Aglyn.registerPluginConfigSchema(COMMERCE_CONFIG_SCHEMA)\n Aglyn.registerConsoleExtension({\n pluginId: BUNDLE_ID,\n displayName: 'Commerce',\n searchSources: COMMERCE_SEARCH_SOURCES,\n // The screen a register turns toward its customer (AGL-3608), at\n // `/kiosk/commerce/pos-display`. No staff session: the device proves\n // itself with the display token it got by pairing, and\n // `server/pos-display.ts` refuses every read without one.\n // Every workspace's orders from the POS hardware shop (AGL-4038), where\n // staff record Stripe's order id and the tracking, move each order on,\n // and cancel or refund one that has not shipped. The staff area loads\n // this registrar through commerce's `staff` surface.\n staffPages: [\n {\n id: 'hardware-orders',\n label: 'Hardware orders',\n header: { title: 'Hardware Orders', docsTopic: 'posHardware' },\n Component: PosHardwareOrdersStaffPage,\n },\n // The platform's default card reader start-up screen (AGL-4048), which\n // every store that has not picked its own logo or image shows.\n {\n id: 'reader-start-up-screen',\n label: 'Reader start-up screen',\n header: { title: 'Reader Start-up Screen', docsTopic: 'posHardware' },\n Component: PosReaderSplashStaffPage,\n },\n ],\n publicPages: [\n { path: '/pos-display', title: 'Customer display', Component: PosDisplayPage },\n // The self-service kiosk (AGL-3623), paired the same way with a kiosk\n // code; `server/pos-kiosk.ts` refuses every call without its token.\n { path: '/pos-kiosk', title: 'Self-service kiosk', Component: PosKioskPage },\n // The terms of sale for a card reader sold at the platform's register\n // (AGL-4038): on its customer display, by the display's own token\n // (`server/pos-display.ts`), and the printable booth sign, which holds\n // only the published terms' address and summary.\n { path: '/hardware-terms', title: 'Terms of sale', Component: PosHardwareTermsPage },\n { path: '/hardware-terms-sign', title: 'Terms of sale sign', Component: PosHardwareTermsSignPage },\n ],\n // Dashboard/analytics glance card (AGL-419): rendered through the\n // shell's 'commerceGlance' widget slot.\n widgets: [\n {\n slot: 'commerceGlance',\n widgetId: 'commerce-glance',\n title: 'Commerce',\n Component: CommerceGlanceCard,\n },\n // What a site user bought — lifetime total, orders and subscriptions —\n // in their drawer on the site's Users page: the orders and\n // subscriptions are this plugin's.\n {\n slot: Aglyn.CONSOLE_WIDGET_SLOTS.siteMember,\n widgetId: 'commerce-site-member-purchases',\n title: 'Purchases',\n Component: SiteMemberPurchases,\n },\n // Start a quote from a quote request, among an open submission's\n // actions in the Inbox, and from a contact, in its header in the CRM\n // (AGL-4098). Each zone is its host's; neither host imports this plugin.\n {\n slot: 'inboxSubmissionActions',\n widgetId: 'commerce-quote-from-request',\n title: 'Start a quote',\n Component: QuoteStartFromRequest,\n },\n {\n slot: 'crmRecordActions',\n widgetId: 'commerce-quote-from-contact',\n title: 'Start a quote',\n Component: QuoteStartFromContact,\n },\n // \"Do you charge sales tax?\" among Create site's fields (AGL-4061),\n // asked before the site exists, so the store is decided before its\n // first sale. It hands its answer to the dialog and writes nothing; the\n // create applies it (`declarations.console-server.ts`). Creating a site\n // is the create's permission, as the starter picker's.\n // The apps linked to the store through their WooCommerce connector,\n // with Disconnect, on the store's Integrations page. Draws nothing\n // until an app is linked.\n {\n slot: 'hostSettings',\n widgetId: 'commerce-woo-connections',\n title: 'Connected store apps',\n Component: WooConnectionsCard,\n },\n {\n slot: 'hostCreateQuestions',\n widgetId: 'commerce-new-store-tax',\n permission: 'hosts.create',\n Component: NewStoreTaxQuestion,\n },\n ],\n navItems: [\n {\n label: 'Products',\n href: '/products',\n icon: { path: mdiStorefrontOutline.path },\n // Sections as ROUTES (AGL-2501): `/products/orders` and friends are\n // real URLs the shell resolves and gates, so the page mounts the one\n // being read instead of subscribing all six.\n sections: COMMERCE_CONSOLE_SECTIONS,\n // `/products/settings` was split into a page per setting (AGL-3713);\n // links to it open the first of them.\n retiredSections: COMMERCE_RETIRED_SECTIONS,\n header: {\n title: 'Products',\n icon: { path: mdiStorefrontOutline.path },\n // The overview, not `catalog`: this surface is the whole commerce\n // console — Catalog, Orders, Promotions and Reservations.\n docsTopic: 'commerce',\n },\n Component: CommerceConsolePage,\n },\n {\n // POS register (AGL-312/419): relocated from the app's /pos route —\n // the generic [pluginSlug] shell now serves it at the same URL.\n label: 'POS',\n href: '/pos',\n /*\n * WHO may open the register, declared on THIS nav item rather than on\n * the extension.\n *\n * A key here narrows one surface; a key on the extension would gate\n * every surface it registers, and Products is the sibling — a catalog\n * anyone who works on the site may open. The register is the one that\n * takes money and lists checked-in guests by name, so the two\n * genuinely have different answers and only this one is narrowed.\n *\n * `managePos` rather than a dotted catalog key because it is the key\n * the sale itself is refused by: `server/pos-order.ts` resolves the\n * member's permission map and returns 403 unless `managePos` holds.\n * The shell answers this declaration out of that same resolved map, so\n * the console offers a register exactly to the people the route will\n * accept a sale from — the gate and its server twin cannot disagree,\n * because they are reading one value.\n *\n * `pos-order.ts` stays the enforcement point regardless. This decides\n * whether the surface is built at all, which is the part a check\n * inside the page cannot do: by the time the page can refuse itself it\n * has mounted and its product, register, location and reservation\n * listeners are already open.\n */\n permission: 'managePos',\n icon: { path: mdiStorefrontOutline.path },\n header: { title: 'Point of Sale', docsTopic: 'pos' },\n Component: PosConsolePage,\n },\n ],\n })\n /*\n * The USER ACCOUNTS half, registered under its own id.\n *\n * `accounts` is a switch rather than a bundle: the member blocks and every\n * `membership/*` handler ship inside this package, which is why the id\n * carries no loader manifest entry of its own. A second extension is how a\n * card about visitor accounts is gated on the switch that decides whether\n * the site serves them — `listConsoleWidgets` filters by the workspace's\n * effective plugin ids, and `accounts` is default-OFF per site.\n *\n * A separate call rather than more widgets on the commerce extension: the\n * registry is keyed by `pluginId` and that key IS the gate, so folding this\n * card in above would have kept the dashboard defect it fixes — `Newest\n * site users` on a site whose /signin returns 404.\n */\n Aglyn.registerConsoleExtension({\n pluginId: Aglyn.ACCOUNTS_PLUGIN_ID,\n displayName: 'User Accounts',\n widgets: [\n {\n slot: Aglyn.CONSOLE_WIDGET_SLOTS.hostDashboard,\n widgetId: 'accounts-newest-site-users',\n title: 'Newest site users',\n Component: NewestSiteUsersCard,\n },\n ],\n })\n}\n\nexport * from './site'\n"],"names":["Aglyn","mdiStorefrontOutline","lazy","PosConsolePage","PosDisplayPage","PosKioskPage","PosHardwareTermsPage","PosHardwareTermsSignPage","PosHardwareOrdersStaffPage","PosReaderSplashStaffPage","CommerceGlanceCard","NewestSiteUsersCard","SiteMemberPurchases","WooConnectionsCard","NewStoreTaxQuestion","COMMERCE_CONSOLE_SECTIONS","COMMERCE_RETIRED_SECTIONS","BUNDLE_ID","COMMERCE_PERMISSIONS","registerCommerceRecordLists","registerCommerceRecordRoutes","registerCommerceZones","registerCommerceOrderZones","registerCommerceReturnZones","registerCommerceStoreZones","registerCommercePosZones","registerCommerceTransferUi","COMMERCE_SEARCH_SOURCES","COMMERCE_CONFIG_SCHEMA","CommerceConsolePage","QuoteStartFromRequest","QuoteStartFromContact","then","module","default","registerCommerceConsole","registerPluginPermissions","registerPluginConfigSchema","registerConsoleExtension","pluginId","displayName","searchSources","staffPages","id","label","header","title","docsTopic","Component","publicPages","path","widgets","slot","widgetId","CONSOLE_WIDGET_SLOTS","siteMember","permission","navItems","href","icon","sections","retiredSections","ACCOUNTS_PLUGIN_ID","hostDashboard"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,IAAI,QAAQ,QAAO;AAC5B,MAAMC,iBAAiBD,KAAK,IAAM,MAAM,CAAC;AACzC,kFAAkF,GAClF,MAAME,iBAAiBF,KAAK,IAAM,MAAM,CAAC;AACzC,MAAMG,eAAeH,KAAK,IAAM,MAAM,CAAC;AACvC,MAAMI,uBAAuBJ,KAAK,IAAM,MAAM,CAAC;AAC/C,MAAMK,2BAA2BL,KAAK,IAAM,MAAM,CAAC;AACnD,sEAAsE,GACtE,MAAMM,6BAA6BN,KACjC,IAAM,MAAM,CAAC;AAEf,6EAA6E,GAC7E,MAAMO,2BAA2BP,KAC/B,IAAM,MAAM,CAAC;AAEf,MAAMQ,qBAAqBR,KACzB,IAAM,MAAM,CAAC;AAEf,MAAMS,sBAAsBT,KAC1B,IAAM,MAAM,CAAC;AAEf,MAAMU,sBAAsBV,KAC1B,IAAM,MAAM,CAAC;AAEf,uFAAuF,GACvF,gEAAgE;AAChE,uDAAuD;AACvD,MAAMW,qBAAqBX,KAAK,IAAM,MAAM,CAAC;AAC7C,MAAMY,sBAAsBZ,KAC1B,IAAM,MAAM,CAAC;AAEf,SACEa,yBAAyB,EACzBC,yBAAyB,QACpB,4CAAwC;AAC/C,SAASC,SAAS,QAAQ,+BAA2B;AACrD,SAASC,oBAAoB,QAAQ,gCAA4B;AACjE,SAASC,2BA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ZR,WAAWlC;YACb;SACD;QACD2C,UAAU;YACR;gBACEb,OAAO;gBACPc,MAAM;gBACNC,MAAM;oBAAET,MAAMjD,qBAAqBiD,IAAI;gBAAC;gBACxC,oEAAoE;gBACpE,qEAAqE;gBACrE,6CAA6C;gBAC7CU,UAAU7C;gBACV,qEAAqE;gBACrE,sCAAsC;gBACtC8C,iBAAiB7C;gBACjB6B,QAAQ;oBACNC,OAAO;oBACPa,MAAM;wBAAET,MAAMjD,qBAAqBiD,IAAI;oBAAC;oBACxC,kEAAkE;oBAClE,0DAA0D;oBAC1DH,WAAW;gBACb;gBACAC,WAAWnB;YACb;YACA;gBACE,oEAAoE;gBACpE,gEAAgE;gBAChEe,OAAO;gBACPc,MAAM;gBACN;;;;;;;;;;;;;;;;;;;;;;;SAuBC,GACDF,YAAY;gBACZG,MAAM;oBAAET,MAAMjD,qBAAqBiD,IAAI;gBAAC;gBACxCL,QAAQ;oBAAEC,OAAO;oBAAiBC,WAAW;gBAAM;gBACnDC,WAAW7C;YACb;SACD;IACH;IACA;;;;;;;;;;;;;;GAcC,GACDH,MAAMsC,wBAAwB,CAAC;QAC7BC,UAAUvC,MAAM8D,kBAAkB;QAClCtB,aAAa;QACbW,SAAS;YACP;gBACEC,MAAMpD,MAAMsD,oBAAoB,CAACS,aAAa;gBAC9CV,UAAU;gBACVP,OAAO;gBACPE,WAAWrC;YACb;SACD;IACH;AACF;AAEA,cAAc,YAAQ"}
|
|
@@ -94,6 +94,15 @@ import { CHECKOUT_STARTED_EVENT_DECLARATION, COMMERCE_EVENT_DECLARATIONS, ORDER_
|
|
|
94
94
|
pluginId: BUNDLE_ID,
|
|
95
95
|
name: 'webhooks'
|
|
96
96
|
});
|
|
97
|
+
// Webhooks an app registered through the store's WooCommerce connector
|
|
98
|
+
// (`server/woo/woo-webhooks.ts`). Its own name, so each is retried apart.
|
|
99
|
+
subscribePluginDomainEvent(declaration.event, async (envelope)=>{
|
|
100
|
+
const { deliverWooWebhooks } = await import("./woo/woo-webhooks.js");
|
|
101
|
+
await deliverWooWebhooks(envelope);
|
|
102
|
+
}, {
|
|
103
|
+
pluginId: BUNDLE_ID,
|
|
104
|
+
name: 'woo-webhooks'
|
|
105
|
+
});
|
|
97
106
|
}
|
|
98
107
|
// The review-request email (AGL-3736): a fulfilled or delivered order —
|
|
99
108
|
// or a paid one with nothing to ship — is scheduled for its request. Its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/order-event-triggers.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 declarePluginDomainEvents,\n subscribePluginDomainEvent,\n type PluginDomainEventEnvelope,\n} from '@aglyn/aglyn/plugin-manager/plugin-domain-events'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport {\n CHECKOUT_STARTED_EVENT_DECLARATION,\n COMMERCE_EVENT_DECLARATIONS,\n ORDER_CANCELLED_EVENT,\n ORDER_DELIVERED_EVENT,\n ORDER_FULFILLED_EVENT,\n ORDER_PAID_EVENT,\n ORDER_REFUNDED_EVENT,\n} from '../model/order-events'\n\n/**\n * Commerce's events as workflow triggers (AGL-3611).\n *\n * The workflows plugin listens to host events, flat key/value payloads it\n * puts in an automation's scope. Commerce subscribes to its own order and\n * return events and raises each as the host event its declaration names\n * (`orderPaid`, `orderFulfilled`, …), declared in `plugins.config.json` so\n * every trigger picker lists them. The automation engine is never imported:\n * the host event bus is the seam.\n */\n\n/** The flat scope an automation reads: the order's facts, then the event's own. */\nexport function hostEventPayloadFor(\n envelope: Pick<PluginDomainEventEnvelope, 'event' | 'payload'>,\n): Record<string, string | number | boolean> {\n const payload = (envelope.payload ?? {}) as Record<string, any>\n const order = (payload.order ?? {}) as Record<string, any>\n const flat: Record<string, string | number | boolean> = {}\n const put = (key: string, value: unknown) => {\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n flat[key] = value\n }\n }\n put('orderId', order.id)\n put('orderNumber', typeof order.number === 'number' ? `#${order.number}` : order.id)\n put('status', order.status)\n put('channel', order.channel)\n put('email', order.customerEmail)\n put('name', order.customerName)\n put('totalCents', order.totals?.totalCents)\n put('currency', order.currency)\n const fulfillment = payload.fulfillment as Record<string, any> | undefined\n if (fulfillment) {\n put('fulfillmentId', fulfillment.id)\n put('carrier', fulfillment.carrier)\n put('trackingNumber', fulfillment.trackingNumber)\n put('trackingUrl', fulfillment.trackingUrl)\n }\n const refund = payload.refund as Record<string, any> | undefined\n if (refund) {\n put('refundCents', refund.amountCents)\n put('fullRefund', refund.full)\n }\n const returned = payload.return as Record<string, any> | undefined\n if (returned) {\n put('returnId', returned.id)\n put('returnStatus', returned.status)\n put('returnRefundCents', returned.refundCents)\n }\n return flat\n}\n\n/**\n * Declares commerce's events and subscribes the trigger bridge, from the\n * server declarations. `emitHostEvent` arrives with the first event, not\n * with the boot.\n */\nexport function registerCommerceEventTriggers(): void {\n declarePluginDomainEvents([...COMMERCE_EVENT_DECLARATIONS, CHECKOUT_STARTED_EVENT_DECLARATION], { pluginId: BUNDLE_ID })\n for (const declaration of COMMERCE_EVENT_DECLARATIONS) {\n subscribePluginDomainEvent(\n declaration.event,\n async (envelope) => {\n const { emitCommerceHostEvent } = await import('./order-event-host-emit')\n await emitCommerceHostEvent(envelope.hostId, declaration.hostEvent, hostEventPayloadFor(envelope))\n },\n // Named, so the outbox records it apart from the webhook subscriber\n // this plugin also registers.\n { pluginId: BUNDLE_ID, name: 'workflow-triggers' },\n )\n // The merchant's own webhooks (AGL-3611). Its own subscriber name, so a\n // failing endpoint is retried without raising the workflow trigger again.\n subscribePluginDomainEvent(\n declaration.event,\n async (envelope) => {\n const { deliverOrderEventToWebhooks } = await import('./order-webhooks')\n await deliverOrderEventToWebhooks(envelope)\n },\n { pluginId: BUNDLE_ID, name: 'webhooks' },\n )\n }\n // The review-request email (AGL-3736): a fulfilled or delivered order —\n // or a paid one with nothing to ship — is scheduled for its request. Its\n // own subscriber name; scheduling is idempotent on the order.\n for (const event of REVIEW_REQUEST_EVENTS) {\n subscribePluginDomainEvent(\n event,\n async (envelope) => {\n const { scheduleReviewRequestFromEvent } = await import('./review-requests')\n await scheduleReviewRequestFromEvent(envelope)\n },\n { pluginId: BUNDLE_ID, name: 'review-requests' },\n )\n }\n // ShippingEasy (AGL-3633): a paid order is sent to the merchant's\n // ShippingEasy account, and a canceled or refunded one is canceled there.\n // Its own subscriber name, so a ShippingEasy outage is retried without\n // re-posting the merchant's webhooks. A site with no connection costs one\n // document read.\n for (const event of SHIPPINGEASY_EVENTS) {\n subscribePluginDomainEvent(\n event,\n async (envelope) => {\n const { deliverOrderEventToShippingEasy } = await import('./shippingeasy')\n await deliverOrderEventToShippingEasy(envelope)\n },\n { pluginId: BUNDLE_ID, name: 'shippingeasy' },\n )\n }\n}\n\n/** The order events that schedule a review request (AGL-3736). */\nexport const REVIEW_REQUEST_EVENTS = [ORDER_FULFILLED_EVENT, ORDER_DELIVERED_EVENT, ORDER_PAID_EVENT] as const\n\n/** The order events that change what ShippingEasy should hold. */\nexport const SHIPPINGEASY_EVENTS = [ORDER_PAID_EVENT, ORDER_CANCELLED_EVENT, ORDER_REFUNDED_EVENT] as const\n"],"names":["declarePluginDomainEvents","subscribePluginDomainEvent","BUNDLE_ID","CHECKOUT_STARTED_EVENT_DECLARATION","COMMERCE_EVENT_DECLARATIONS","ORDER_CANCELLED_EVENT","ORDER_DELIVERED_EVENT","ORDER_FULFILLED_EVENT","ORDER_PAID_EVENT","ORDER_REFUNDED_EVENT","hostEventPayloadFor","envelope","payload","order","flat","put","key","value","id","number","status","channel","customerEmail","customerName","totals","totalCents","currency","fulfillment","carrier","trackingNumber","trackingUrl","refund","amountCents","full","returned","return","refundCents","registerCommerceEventTriggers","pluginId","declaration","event","emitCommerceHostEvent","hostId","hostEvent","name","deliverOrderEventToWebhooks","REVIEW_REQUEST_EVENTS","scheduleReviewRequestFromEvent","SHIPPINGEASY_EVENTS","deliverOrderEventToShippingEasy"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,yBAAyB,EACzBC,0BAA0B,QAErB,mDAAkD;AACzD,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SACEC,kCAAkC,EAClCC,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,EACrBC,qBAAqB,EACrBC,gBAAgB,EAChBC,oBAAoB,QACf,2BAAuB;AAE9B;;;;;;;;;CASC,GAED,iFAAiF,GACjF,OAAO,SAASC,oBACdC,QAA8D;QAE7CA,mBACFC;QAaGC;IAdlB,MAAMD,WAAWD,oBAAAA,SAASC,OAAO,YAAhBD,oBAAoB,CAAC;IACtC,MAAME,SAASD,iBAAAA,QAAQC,KAAK,YAAbD,iBAAiB,CAAC;IACjC,MAAME,OAAkD,CAAC;IACzD,MAAMC,MAAM,CAACC,KAAaC;QACxB,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,YAAY,OAAOA,UAAU,WAAW;YACxFH,IAAI,CAACE,IAAI,GAAGC;QACd;IACF;IACAF,IAAI,WAAWF,MAAMK,EAAE;IACvBH,IAAI,eAAe,OAAOF,MAAMM,MAAM,KAAK,WAAW,CAAC,CAAC,EAAEN,MAAMM,MAAM,EAAE,GAAGN,MAAMK,EAAE;IACnFH,IAAI,UAAUF,MAAMO,MAAM;IAC1BL,IAAI,WAAWF,MAAMQ,OAAO;IAC5BN,IAAI,SAASF,MAAMS,aAAa;IAChCP,IAAI,QAAQF,MAAMU,YAAY;IAC9BR,IAAI,eAAcF,gBAAAA,MAAMW,MAAM,qBAAZX,cAAcY,UAAU;IAC1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BAAuB;QACzC7C,2BACEuC,OACA,OAAO7B;YACL,MAAM,EAAEoC,8BAA8B,EAAE,GAAG,MAAM,MAAM,CAAC;YACxD,MAAMA,+BAA+BpC;QACvC,GACA;YAAE2B,UAAUpC;YAAW0C,MAAM;QAAkB;IAEnD;IACA,kEAAkE;IAClE,0EAA0E;IAC1E,uEAAuE;IACvE,0EAA0E;IAC1E,iBAAiB;IACjB,KAAK,MAAMJ,SAASQ,oBAAqB;QACvC/C,2BACEuC,OACA,OAAO7B;YACL,MAAM,EAAEsC,+BAA+B,EAAE,GAAG,MAAM,MAAM,CAAC;YACzD,MAAMA,gCAAgCtC;QACxC,GACA;YAAE2B,UAAUpC;YAAW0C,MAAM;QAAe;IAEhD;AACF;AAEA,gEAAgE,GAChE,OAAO,MAAME,wBAAwB;IAACvC;IAAuBD;IAAuBE;CAAiB,CAAS;AAE9G,gEAAgE,GAChE,OAAO,MAAMwC,sBAAsB;IAACxC;IAAkBH;IAAuBI;CAAqB,CAAS"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/order-event-triggers.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 declarePluginDomainEvents,\n subscribePluginDomainEvent,\n type PluginDomainEventEnvelope,\n} from '@aglyn/aglyn/plugin-manager/plugin-domain-events'\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport {\n CHECKOUT_STARTED_EVENT_DECLARATION,\n COMMERCE_EVENT_DECLARATIONS,\n ORDER_CANCELLED_EVENT,\n ORDER_DELIVERED_EVENT,\n ORDER_FULFILLED_EVENT,\n ORDER_PAID_EVENT,\n ORDER_REFUNDED_EVENT,\n} from '../model/order-events'\n\n/**\n * Commerce's events as workflow triggers (AGL-3611).\n *\n * The workflows plugin listens to host events, flat key/value payloads it\n * puts in an automation's scope. Commerce subscribes to its own order and\n * return events and raises each as the host event its declaration names\n * (`orderPaid`, `orderFulfilled`, …), declared in `plugins.config.json` so\n * every trigger picker lists them. The automation engine is never imported:\n * the host event bus is the seam.\n */\n\n/** The flat scope an automation reads: the order's facts, then the event's own. */\nexport function hostEventPayloadFor(\n envelope: Pick<PluginDomainEventEnvelope, 'event' | 'payload'>,\n): Record<string, string | number | boolean> {\n const payload = (envelope.payload ?? {}) as Record<string, any>\n const order = (payload.order ?? {}) as Record<string, any>\n const flat: Record<string, string | number | boolean> = {}\n const put = (key: string, value: unknown) => {\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n flat[key] = value\n }\n }\n put('orderId', order.id)\n put('orderNumber', typeof order.number === 'number' ? `#${order.number}` : order.id)\n put('status', order.status)\n put('channel', order.channel)\n put('email', order.customerEmail)\n put('name', order.customerName)\n put('totalCents', order.totals?.totalCents)\n put('currency', order.currency)\n const fulfillment = payload.fulfillment as Record<string, any> | undefined\n if (fulfillment) {\n put('fulfillmentId', fulfillment.id)\n put('carrier', fulfillment.carrier)\n put('trackingNumber', fulfillment.trackingNumber)\n put('trackingUrl', fulfillment.trackingUrl)\n }\n const refund = payload.refund as Record<string, any> | undefined\n if (refund) {\n put('refundCents', refund.amountCents)\n put('fullRefund', refund.full)\n }\n const returned = payload.return as Record<string, any> | undefined\n if (returned) {\n put('returnId', returned.id)\n put('returnStatus', returned.status)\n put('returnRefundCents', returned.refundCents)\n }\n return flat\n}\n\n/**\n * Declares commerce's events and subscribes the trigger bridge, from the\n * server declarations. `emitHostEvent` arrives with the first event, not\n * with the boot.\n */\nexport function registerCommerceEventTriggers(): void {\n declarePluginDomainEvents([...COMMERCE_EVENT_DECLARATIONS, CHECKOUT_STARTED_EVENT_DECLARATION], { pluginId: BUNDLE_ID })\n for (const declaration of COMMERCE_EVENT_DECLARATIONS) {\n subscribePluginDomainEvent(\n declaration.event,\n async (envelope) => {\n const { emitCommerceHostEvent } = await import('./order-event-host-emit')\n await emitCommerceHostEvent(envelope.hostId, declaration.hostEvent, hostEventPayloadFor(envelope))\n },\n // Named, so the outbox records it apart from the webhook subscriber\n // this plugin also registers.\n { pluginId: BUNDLE_ID, name: 'workflow-triggers' },\n )\n // The merchant's own webhooks (AGL-3611). Its own subscriber name, so a\n // failing endpoint is retried without raising the workflow trigger again.\n subscribePluginDomainEvent(\n declaration.event,\n async (envelope) => {\n const { deliverOrderEventToWebhooks } = await import('./order-webhooks')\n await deliverOrderEventToWebhooks(envelope)\n },\n { pluginId: BUNDLE_ID, name: 'webhooks' },\n )\n // Webhooks an app registered through the store's WooCommerce connector\n // (`server/woo/woo-webhooks.ts`). Its own name, so each is retried apart.\n subscribePluginDomainEvent(\n declaration.event,\n async (envelope) => {\n const { deliverWooWebhooks } = await import('./woo/woo-webhooks')\n await deliverWooWebhooks(envelope)\n },\n { pluginId: BUNDLE_ID, name: 'woo-webhooks' },\n )\n }\n // The review-request email (AGL-3736): a fulfilled or delivered order —\n // or a paid one with nothing to ship — is scheduled for its request. Its\n // own subscriber name; scheduling is idempotent on the order.\n for (const event of REVIEW_REQUEST_EVENTS) {\n subscribePluginDomainEvent(\n event,\n async (envelope) => {\n const { scheduleReviewRequestFromEvent } = await import('./review-requests')\n await scheduleReviewRequestFromEvent(envelope)\n },\n { pluginId: BUNDLE_ID, name: 'review-requests' },\n )\n }\n // ShippingEasy (AGL-3633): a paid order is sent to the merchant's\n // ShippingEasy account, and a canceled or refunded one is canceled there.\n // Its own subscriber name, so a ShippingEasy outage is retried without\n // re-posting the merchant's webhooks. A site with no connection costs one\n // document read.\n for (const event of SHIPPINGEASY_EVENTS) {\n subscribePluginDomainEvent(\n event,\n async (envelope) => {\n const { deliverOrderEventToShippingEasy } = await import('./shippingeasy')\n await deliverOrderEventToShippingEasy(envelope)\n },\n { pluginId: BUNDLE_ID, name: 'shippingeasy' },\n )\n }\n}\n\n/** The order events that schedule a review request (AGL-3736). */\nexport const REVIEW_REQUEST_EVENTS = [ORDER_FULFILLED_EVENT, ORDER_DELIVERED_EVENT, ORDER_PAID_EVENT] as const\n\n/** The order events that change what ShippingEasy should hold. */\nexport const SHIPPINGEASY_EVENTS = [ORDER_PAID_EVENT, ORDER_CANCELLED_EVENT, ORDER_REFUNDED_EVENT] as const\n"],"names":["declarePluginDomainEvents","subscribePluginDomainEvent","BUNDLE_ID","CHECKOUT_STARTED_EVENT_DECLARATION","COMMERCE_EVENT_DECLARATIONS","ORDER_CANCELLED_EVENT","ORDER_DELIVERED_EVENT","ORDER_FULFILLED_EVENT","ORDER_PAID_EVENT","ORDER_REFUNDED_EVENT","hostEventPayloadFor","envelope","payload","order","flat","put","key","value","id","number","status","channel","customerEmail","customerName","totals","totalCents","currency","fulfillment","carrier","trackingNumber","trackingUrl","refund","amountCents","full","returned","return","refundCents","registerCommerceEventTriggers","pluginId","declaration","event","emitCommerceHostEvent","hostId","hostEvent","name","deliverOrderEventToWebhooks","deliverWooWebhooks","REVIEW_REQUEST_EVENTS","scheduleReviewRequestFromEvent","SHIPPINGEASY_EVENTS","deliverOrderEventToShippingEasy"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,yBAAyB,EACzBC,0BAA0B,QAErB,mDAAkD;AACzD,SAASC,SAAS,QAAQ,gCAA4B;AACtD,SACEC,kCAAkC,EAClCC,2BAA2B,EAC3BC,qBAAqB,EACrBC,qBAAqB,EACrBC,qBAAqB,EACrBC,gBAAgB,EAChBC,oBAAoB,QACf,2BAAuB;AAE9B;;;;;;;;;CASC,GAED,iFAAiF,GACjF,OAAO,SAASC,oBACdC,QAA8D;QAE7CA,mBACFC;QAaGC;IAdlB,MAAMD,WAAWD,oBAAAA,SAASC,OAAO,YAAhBD,oBAAoB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;QAAe;IAEhD;AACF;AAEA,gEAAgE,GAChE,OAAO,MAAMG,wBAAwB;IAACxC;IAAuBD;IAAuBE;CAAiB,CAAS;AAE9G,gEAAgE,GAChE,OAAO,MAAMyC,sBAAsB;IAACzC;IAAkBH;IAAuBI;CAAqB,CAAS"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import * as Aglyn from '@aglyn/aglyn/server';
|
|
18
|
+
import { type PublicWooConnection } from '@aglyn/tenant-data-admin';
|
|
19
|
+
export interface WooConnectionsAnswer {
|
|
20
|
+
canManage: boolean;
|
|
21
|
+
connections: PublicWooConnection[];
|
|
22
|
+
}
|
|
23
|
+
export declare const wooConnectionsHandler: Aglyn.PluginApiHandler;
|