@stacksjs/defaults 0.75.489 → 0.75.490
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/ai/skills/stacks-actions/SKILL.md +1 -1
- package/ai/skills/stacks-dashboard/SKILL.md +20 -2
- package/ai/skills/stacks-native/CATALOG.md +9 -9
- package/ai/skills/stacks-search-engine/SKILL.md +14 -0
- package/app/Actions/Dashboard/Commerce/CommerceCategoriesAction.ts +7 -13
- package/app/Actions/Dashboard/Commerce/CommerceCustomerChoicesAction.ts +34 -0
- package/app/Actions/Dashboard/Commerce/CommerceDeliveryAction.ts +7 -16
- package/app/Actions/Dashboard/Commerce/CommerceGiftCardsAction.ts +21 -15
- package/app/Actions/Dashboard/Commerce/CommerceGiftCardsExportAction.ts +41 -0
- package/app/Actions/Dashboard/Commerce/CommerceOrderCustomersAction.ts +37 -0
- package/app/Actions/Dashboard/Commerce/CommerceOrdersAction.ts +26 -41
- package/app/Actions/Dashboard/Commerce/CommerceOrdersExportAction.ts +43 -0
- package/app/Actions/Dashboard/Commerce/CommercePaymentsAction.ts +24 -21
- package/app/Actions/Dashboard/Commerce/CommercePaymentsExportAction.ts +41 -0
- package/app/Actions/Dashboard/Commerce/CommercePosAction.ts +18 -48
- package/app/Actions/Dashboard/Commerce/CommercePosProductsAction.ts +39 -0
- package/app/Actions/Dashboard/Commerce/CommercePrintLogsAction.ts +14 -104
- package/app/Actions/Dashboard/Commerce/CommercePrintLogsExportAction.ts +41 -0
- package/app/Actions/Dashboard/Commerce/CommerceProductChoicesAction.ts +32 -0
- package/app/Actions/Dashboard/Commerce/CommerceProductsAction.ts +24 -43
- package/app/Actions/Dashboard/Commerce/CommerceProductsExportAction.ts +44 -0
- package/app/Actions/Dashboard/Commerce/CourierIndexAction.ts +3 -1
- package/app/Actions/Dashboard/Commerce/DeliveryRouteIndexAction.ts +23 -12
- package/app/Actions/Dashboard/Commerce/DigitalDeliveryIndexAction.ts +3 -1
- package/app/Actions/Dashboard/Commerce/LicenseKeyIndexAction.ts +24 -23
- package/app/Actions/Dashboard/Commerce/LicenseKeyOptionsAction.ts +35 -16
- package/app/Actions/Dashboard/Commerce/ProductWaitlistIndexAction.ts +22 -22
- package/app/Actions/Dashboard/Commerce/RestaurantWaitlistIndexAction.ts +22 -17
- package/app/Actions/Dashboard/Commerce/ReviewIndexAction.ts +22 -31
- package/app/Actions/Dashboard/Commerce/ShippingMethodIndexAction.ts +3 -1
- package/app/Actions/Dashboard/Commerce/ShippingRateIndexAction.ts +3 -1
- package/app/Actions/Dashboard/Commerce/ShippingZoneIndexAction.ts +3 -1
- package/app/Actions/Dashboard/Commerce/commerce-category-list.test.ts +100 -0
- package/app/Actions/Dashboard/Commerce/commerce-category-list.ts +26 -0
- package/app/Actions/Dashboard/Commerce/commerce-choice-records.ts +56 -0
- package/app/Actions/Dashboard/Commerce/commerce-choices.test.ts +88 -0
- package/app/Actions/Dashboard/Commerce/commerce-choices.ts +70 -0
- package/app/Actions/Dashboard/Commerce/commerce-delivery-overview.test.ts +151 -0
- package/app/Actions/Dashboard/Commerce/commerce-delivery-overview.ts +85 -0
- package/app/Actions/Dashboard/Commerce/commerce-delivery-route-list.test.ts +153 -0
- package/app/Actions/Dashboard/Commerce/commerce-delivery-route-list.ts +180 -0
- package/app/Actions/Dashboard/Commerce/commerce-delivery.ts +24 -9
- package/app/Actions/Dashboard/Commerce/commerce-gift-card-list.test.ts +221 -0
- package/app/Actions/Dashboard/Commerce/commerce-gift-card-list.ts +259 -0
- package/app/Actions/Dashboard/Commerce/commerce-license-key-list.test.ts +184 -0
- package/app/Actions/Dashboard/Commerce/commerce-license-key-list.ts +217 -0
- package/app/Actions/Dashboard/Commerce/commerce-order-list.test.ts +183 -0
- package/app/Actions/Dashboard/Commerce/commerce-order-list.ts +278 -0
- package/app/Actions/Dashboard/Commerce/commerce-order-records.test.ts +29 -0
- package/app/Actions/Dashboard/Commerce/commerce-payment-list.test.ts +180 -0
- package/app/Actions/Dashboard/Commerce/commerce-payment-list.ts +272 -0
- package/app/Actions/Dashboard/Commerce/commerce-pos-catalog.test.ts +171 -0
- package/app/Actions/Dashboard/Commerce/commerce-pos-catalog.ts +152 -0
- package/app/Actions/Dashboard/Commerce/commerce-pos.test.ts +1 -12
- package/app/Actions/Dashboard/Commerce/commerce-pos.ts +0 -26
- package/app/Actions/Dashboard/Commerce/commerce-print-log-list.test.ts +202 -0
- package/app/Actions/Dashboard/Commerce/commerce-print-log-list.ts +286 -0
- package/app/Actions/Dashboard/Commerce/commerce-product-list.test.ts +174 -0
- package/app/Actions/Dashboard/Commerce/commerce-product-list.ts +276 -0
- package/app/Actions/Dashboard/Commerce/commerce-product-waitlist-list.test.ts +183 -0
- package/app/Actions/Dashboard/Commerce/commerce-product-waitlist-list.ts +170 -0
- package/app/Actions/Dashboard/Commerce/commerce-record.ts +21 -0
- package/app/Actions/Dashboard/Commerce/commerce-restaurant-waitlist-list.test.ts +189 -0
- package/app/Actions/Dashboard/Commerce/commerce-restaurant-waitlist-list.ts +177 -0
- package/app/Actions/Dashboard/Commerce/commerce-review-list.test.ts +193 -0
- package/app/Actions/Dashboard/Commerce/commerce-review-list.ts +220 -0
- package/app/Actions/Dashboard/Commerce/commerce-sql.ts +57 -0
- package/app/Actions/Dashboard/Commerce/payment-records.test.ts +16 -0
- package/app/Actions/Dashboard/Commerce/product-waitlist-records.test.ts +6 -5
- package/app/Actions/Dashboard/Commerce/product-waitlist-records.ts +16 -45
- package/app/Actions/Dashboard/Commerce/restaurant-waitlist-records.ts +4 -24
- package/app/Actions/Dashboard/Content/content-list.ts +10 -0
- package/app/Actions/Dashboard/Content/file-listing-metadata.test.ts +46 -0
- package/app/Actions/Dashboard/Content/file-manager.ts +51 -10
- package/app/Actions/Dashboard/DashboardHomeAction.test.ts +13 -9
- package/app/Actions/Dashboard/DashboardHomeAction.ts +42 -21
- package/app/Actions/Dashboard/Jobs/JobStatsAction.ts +5 -2
- package/app/Actions/Dashboard/Kanban/UsersListAction.ts +13 -9
- package/app/Actions/Dashboard/Kanban/kanban-response.test.ts +40 -0
- package/app/Actions/Dashboard/Kanban/kanban-response.ts +53 -1
- package/app/Actions/Dashboard/Kanban/kanban-users.test.ts +114 -0
- package/app/Actions/Dashboard/Kanban/kanban-users.ts +32 -0
- package/app/Actions/Dashboard/Models/ModelShowAction.ts +8 -0
- package/app/Actions/Dashboard/Models/ModelsIndexAction.ts +16 -2
- package/app/Actions/Dashboard/Models/model-migration.test.ts +27 -0
- package/app/Actions/Dashboard/Models/model-migration.ts +23 -0
- package/app/Actions/Dashboard/Queue/QueueStatsAction.ts +5 -3
- package/app/Actions/Dashboard/Queue/QueueWorkersAction.ts +3 -2
- package/app/Actions/Dashboard/Queue/worker-snapshots.test.ts +31 -0
- package/app/Actions/Dashboard/Queue/worker-snapshots.ts +33 -0
- package/app/Actions/Dashboard/named-search.test.ts +36 -0
- package/app/Actions/Dashboard/named-search.ts +80 -0
- package/app/Models/Request.ts +4 -2
- package/functions/commerce/shippings/dashboard-resource.ts +12 -1
- package/functions/commerce/shippings/delivery-routes.ts +1 -0
- package/functions/commerce/shippings/license-keys.ts +1 -0
- package/functions/dashboard-list.test.ts +132 -1
- package/functions/dashboard-list.ts +198 -1
- package/functions/queue.ts +2 -0
- package/ide/vscode/package.json +1 -1
- package/package.json +2 -2
- package/resources/components/Dashboard/Commerce/CommerceGiftCardBreakdown.stx +38 -12
- package/resources/components/Dashboard/Commerce/CommerceGiftCardsDashboard.stx +122 -68
- package/resources/components/Dashboard/Commerce/CommerceGiftCardsTable.stx +29 -6
- package/resources/components/Dashboard/Commerce/CommerceOrderDialog.stx +59 -2
- package/resources/components/Dashboard/Commerce/CommerceOrdersDashboard.stx +126 -80
- package/resources/components/Dashboard/Commerce/CommerceOrdersTable.stx +28 -3
- package/resources/components/Dashboard/Commerce/CommercePaymentsBreakdown.stx +12 -29
- package/resources/components/Dashboard/Commerce/CommercePaymentsDashboard.stx +139 -60
- package/resources/components/Dashboard/Commerce/CommercePaymentsTable.stx +27 -2
- package/resources/components/Dashboard/Commerce/CommercePosCatalog.stx +17 -1
- package/resources/components/Dashboard/Commerce/CommercePosCheckoutDialog.stx +47 -3
- package/resources/components/Dashboard/Commerce/CommercePosDashboard.stx +59 -49
- package/resources/components/Dashboard/Commerce/CommerceProductsDashboard.stx +116 -82
- package/resources/components/Dashboard/Commerce/CommerceProductsTable.stx +28 -4
- package/resources/components/Dashboard/Commerce/CommerceReviewsDashboard.stx +120 -69
- package/resources/components/Dashboard/Commerce/CommerceReviewsTable.stx +29 -6
- package/resources/components/Dashboard/Commerce/Delivery/DeliveryRoutesDashboard.stx +79 -52
- package/resources/components/Dashboard/Commerce/Delivery/DeliveryRoutesTable.stx +31 -8
- package/resources/components/Dashboard/Commerce/Delivery/LicenseKeyDialog.stx +71 -13
- package/resources/components/Dashboard/Commerce/Delivery/LicenseKeysDashboard.stx +69 -81
- package/resources/components/Dashboard/Commerce/Delivery/LicenseKeysTable.stx +31 -8
- package/resources/components/Dashboard/Commerce/PrintLogBreakdown.stx +21 -17
- package/resources/components/Dashboard/Commerce/PrintLogsDashboard.stx +23 -22
- package/resources/components/Dashboard/Commerce/ProductWaitlistDashboard.stx +116 -20
- package/resources/components/Dashboard/Commerce/ProductWaitlistEntryDialog.stx +100 -12
- package/resources/components/Dashboard/Commerce/ProductWaitlistTable.stx +34 -16
- package/resources/components/Dashboard/Commerce/RestaurantWaitlistDashboard.stx +107 -19
- package/resources/components/Dashboard/Commerce/RestaurantWaitlistEntryDialog.stx +65 -6
- package/resources/components/Dashboard/Commerce/RestaurantWaitlistTable.stx +29 -3
- package/resources/components/Dashboard/Kanban/KanbanBoardsDashboard.stx +10 -1
- package/resources/components/Dashboard/Kanban/KanbanCardDialog.stx +21 -1
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +24 -4
- package/resources/components/Dashboard/Models/ModelsOverview.stx +13 -2
- package/resources/components/Dashboard/Queue/QueueDashboard.stx +7 -1
- package/routes/dashboard-api.ts +11 -0
- package/views/dashboard/stores/kanban.ts +38 -6
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import type { QueryBuilderDialect } from '@stacksjs/database/runtime'
|
|
2
|
+
import { db, getDatabaseDialect } from '@stacksjs/database/runtime'
|
|
3
|
+
import type { QueryReader } from '../Content/content-list'
|
|
4
|
+
import { containsPattern, countOf, LIST_PAGE_SIZES, pageWithin, queryText } from '../Content/content-list'
|
|
5
|
+
import type { CommerceOrderRecord, CommerceOrderSummary } from './commerce-order-records'
|
|
6
|
+
import {
|
|
7
|
+
addOrderItemQuantity,
|
|
8
|
+
normalizeCommerceOrderRecord,
|
|
9
|
+
normalizeOrderCouponId,
|
|
10
|
+
normalizeOrderCustomerContext,
|
|
11
|
+
} from './commerce-order-records'
|
|
12
|
+
import { commerceCurrency, commerceIdentifier, commerceValue, referencedIds } from './commerce-record'
|
|
13
|
+
import type { CommerceSqlRunner } from './commerce-sql'
|
|
14
|
+
import { asText, binder, idPlaceholders, sqlRows as rows } from './commerce-sql'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One page of orders, searched, filtered, sorted, counted and summarised by the
|
|
18
|
+
* database (stacksjs/stacks#3218).
|
|
19
|
+
*
|
|
20
|
+
* The Orders page used to read the newest 500 orders and do all of that in the
|
|
21
|
+
* browser, so an order past the 500th could not be found, and the summary
|
|
22
|
+
* cards and currency totals described those 500, not the store.
|
|
23
|
+
*/
|
|
24
|
+
export const ORDER_SORTS = ['created', 'id', 'customer', 'total', 'type', 'status'] as const
|
|
25
|
+
export type OrderSort = typeof ORDER_SORTS[number]
|
|
26
|
+
|
|
27
|
+
export interface OrderListQuery {
|
|
28
|
+
search: string
|
|
29
|
+
status: string
|
|
30
|
+
type: string
|
|
31
|
+
sort: OrderSort
|
|
32
|
+
direction: 'asc' | 'desc'
|
|
33
|
+
page: number
|
|
34
|
+
perPage: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type OrderListRunner = CommerceSqlRunner
|
|
38
|
+
|
|
39
|
+
/** The status groups the summary cards count, matched without regard to case. */
|
|
40
|
+
const STATUS_GROUPS = {
|
|
41
|
+
pending: ['PENDING', 'NEW'],
|
|
42
|
+
inProgress: ['PREPARING', 'PROCESSING', 'READY', 'SHIPPED'],
|
|
43
|
+
completed: ['DELIVERED', 'COMPLETED', 'PAID'],
|
|
44
|
+
cancelled: ['CANCELED', 'CANCELLED', 'REFUNDED'],
|
|
45
|
+
} as const
|
|
46
|
+
|
|
47
|
+
export const DEFAULT_ORDER_STATUSES = ['PENDING', 'PREPARING', 'READY', 'DELIVERED', 'CANCELED']
|
|
48
|
+
export const DEFAULT_ORDER_TYPES = ['DINE_IN', 'TAKEOUT', 'DELIVERY']
|
|
49
|
+
|
|
50
|
+
export function parseOrderListQuery(read: QueryReader): OrderListQuery | { error: string } {
|
|
51
|
+
const pageText = queryText(read, 'page')
|
|
52
|
+
const page = pageText === '' ? 1 : Number(pageText)
|
|
53
|
+
if (!Number.isInteger(page) || page < 1)
|
|
54
|
+
return { error: 'page must be a whole number of 1 or more.' }
|
|
55
|
+
|
|
56
|
+
const sizeText = queryText(read, 'per_page')
|
|
57
|
+
const perPage = sizeText === '' ? 25 : Number(sizeText)
|
|
58
|
+
if (!(LIST_PAGE_SIZES as readonly number[]).includes(perPage))
|
|
59
|
+
return { error: `per_page must be one of ${LIST_PAGE_SIZES.join(', ')}.` }
|
|
60
|
+
|
|
61
|
+
const sort = queryText(read, 'sort') || 'created'
|
|
62
|
+
if (!(ORDER_SORTS as readonly string[]).includes(sort))
|
|
63
|
+
return { error: `sort must be one of ${ORDER_SORTS.join(', ')}.` }
|
|
64
|
+
|
|
65
|
+
const directionText = queryText(read, 'direction').toLowerCase()
|
|
66
|
+
const direction = directionText === '' ? (sort === 'created' || sort === 'total' ? 'desc' : 'asc') : directionText
|
|
67
|
+
if (direction !== 'asc' && direction !== 'desc')
|
|
68
|
+
return { error: 'direction must be asc or desc.' }
|
|
69
|
+
|
|
70
|
+
const search = queryText(read, 'q')
|
|
71
|
+
if (search.length > 200)
|
|
72
|
+
return { error: 'q must be 200 characters or fewer.' }
|
|
73
|
+
|
|
74
|
+
const status = queryText(read, 'status')
|
|
75
|
+
const type = queryText(read, 'type')
|
|
76
|
+
if (status.length > 100 || type.length > 100)
|
|
77
|
+
return { error: 'status and type must be 100 characters or fewer.' }
|
|
78
|
+
|
|
79
|
+
return { search, status, type, sort: sort as OrderSort, direction, page, perPage }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function sortExpression(sort: OrderSort): string {
|
|
83
|
+
switch (sort) {
|
|
84
|
+
case 'id': return 'o.id'
|
|
85
|
+
// Case-insensitive, with unassigned orders first ascending, the same on
|
|
86
|
+
// every dialect (each sorts NULL differently).
|
|
87
|
+
case 'customer': return `LOWER(COALESCE(c.name, ''))`
|
|
88
|
+
case 'total': return 'o.total_amount'
|
|
89
|
+
case 'type': return 'o.order_type'
|
|
90
|
+
case 'status': return 'o.status'
|
|
91
|
+
default: return 'o.created_at'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The WHERE clause and its values for a query's search and filters. */
|
|
96
|
+
export function orderFilter(query: Pick<OrderListQuery, 'search' | 'status' | 'type'>, dialect: QueryBuilderDialect): { where: string, values: unknown[] } {
|
|
97
|
+
const { bind, values } = binder(dialect)
|
|
98
|
+
const clauses: string[] = []
|
|
99
|
+
if (query.status)
|
|
100
|
+
clauses.push(`o.status = ${bind(query.status)}`)
|
|
101
|
+
if (query.type)
|
|
102
|
+
clauses.push(`o.order_type = ${bind(query.type)}`)
|
|
103
|
+
if (query.search) {
|
|
104
|
+
const pattern = containsPattern(query.search)
|
|
105
|
+
const columns = [
|
|
106
|
+
asText('o.id', dialect),
|
|
107
|
+
`COALESCE(c.name, '')`,
|
|
108
|
+
`COALESCE(c.email, '')`,
|
|
109
|
+
`COALESCE(o.status, '')`,
|
|
110
|
+
`COALESCE(o.order_type, '')`,
|
|
111
|
+
`COALESCE(o.delivery_address, '')`,
|
|
112
|
+
]
|
|
113
|
+
clauses.push(`(${columns.map(column => `LOWER(${column}) LIKE ${bind(pattern)} ESCAPE '!'`).join(' OR ')})`)
|
|
114
|
+
}
|
|
115
|
+
return { where: clauses.length > 0 ? ` WHERE ${clauses.join(' AND ')}` : '', values }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const FROM = ' FROM orders o LEFT JOIN customers c ON c.id = o.customer_id'
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Orders turned into records: their referenced customers and coupons read by
|
|
122
|
+
* id, and their item counts. Shared by the page and the export.
|
|
123
|
+
*/
|
|
124
|
+
async function recordsFor(orders: Array<Record<string, unknown>>, run: OrderListRunner, dialect: QueryBuilderDialect): Promise<CommerceOrderRecord[]> {
|
|
125
|
+
if (orders.length === 0)
|
|
126
|
+
return []
|
|
127
|
+
|
|
128
|
+
const customerIds = referencedIds(orders, 'customer_id')
|
|
129
|
+
const couponIds = referencedIds(orders, 'coupon_id')
|
|
130
|
+
const orderIds = referencedIds(orders, 'id')
|
|
131
|
+
const [customers, coupons, items] = await Promise.all([
|
|
132
|
+
customerIds.length > 0 ? run.unsafe(`SELECT id, name, email FROM customers WHERE id IN (${idPlaceholders(customerIds, dialect)})`, customerIds).execute() : [],
|
|
133
|
+
couponIds.length > 0 ? run.unsafe(`SELECT id FROM coupons WHERE id IN (${idPlaceholders(couponIds, dialect)})`, couponIds).execute() : [],
|
|
134
|
+
orderIds.length > 0 ? run.unsafe(`SELECT id, order_id, quantity FROM order_items WHERE order_id IN (${idPlaceholders(orderIds, dialect)})`, orderIds).execute() : [],
|
|
135
|
+
])
|
|
136
|
+
|
|
137
|
+
const customerMap = new Map(rows(customers).map(normalizeOrderCustomerContext).map(customer => [customer.id, customer.context]))
|
|
138
|
+
const couponSet = new Set(rows(coupons).map(normalizeOrderCouponId))
|
|
139
|
+
const orderKeys = new Set(orders.map(order => commerceIdentifier(commerceValue(order, 'id', 'uuid'), 'Order')))
|
|
140
|
+
const itemCounts = new Map<string, number>()
|
|
141
|
+
for (const item of rows(items))
|
|
142
|
+
addOrderItemQuantity(item, orderKeys, itemCounts)
|
|
143
|
+
|
|
144
|
+
return orders.map(order => normalizeCommerceOrderRecord(order, customerMap, itemCounts, couponSet))
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The summary cards and currency totals, over every order. */
|
|
148
|
+
async function summarize(run: OrderListRunner): Promise<CommerceOrderSummary> {
|
|
149
|
+
const group = (statuses: readonly string[]) =>
|
|
150
|
+
`SUM(CASE WHEN UPPER(TRIM(status)) IN (${statuses.map(status => `'${status}'`).join(', ')}) THEN 1 ELSE 0 END)`
|
|
151
|
+
const [counts, totals] = await Promise.all([
|
|
152
|
+
run.unsafe(`SELECT COUNT(*) AS total_count, ${group(STATUS_GROUPS.pending)} AS pending_count, ${group(STATUS_GROUPS.inProgress)} AS progress_count, ${group(STATUS_GROUPS.completed)} AS completed_count, ${group(STATUS_GROUPS.cancelled)} AS cancelled_count FROM orders`).execute(),
|
|
153
|
+
run.unsafe('SELECT currency, SUM(total_amount) AS amount_total FROM orders GROUP BY currency').execute(),
|
|
154
|
+
])
|
|
155
|
+
const count = rows(counts)[0] ?? {}
|
|
156
|
+
|
|
157
|
+
// Currencies are normalized as the records are, so "eur" and "EUR" are one total.
|
|
158
|
+
const currencyTotals = new Map<string, number>()
|
|
159
|
+
for (const row of rows(totals)) {
|
|
160
|
+
const currency = commerceCurrency(row.currency, 'Order summary')
|
|
161
|
+
currencyTotals.set(currency, (currencyTotals.get(currency) ?? 0) + countOf(row.amount_total))
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
total: countOf(count.total_count),
|
|
166
|
+
pending: countOf(count.pending_count),
|
|
167
|
+
inProgress: countOf(count.progress_count),
|
|
168
|
+
completed: countOf(count.completed_count),
|
|
169
|
+
cancelled: countOf(count.cancelled_count),
|
|
170
|
+
currencyTotals: [...currencyTotals.entries()]
|
|
171
|
+
.map(([currency, amount]) => ({ currency, amount }))
|
|
172
|
+
.sort((left, right) => left.currency.localeCompare(right.currency)),
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** The filter choices: the usual ones plus every value an order actually has. */
|
|
177
|
+
async function choices(run: OrderListRunner): Promise<{ statuses: string[], orderTypes: string[] }> {
|
|
178
|
+
const [statuses, types] = await Promise.all([
|
|
179
|
+
run.unsafe('SELECT DISTINCT status FROM orders WHERE status IS NOT NULL').execute(),
|
|
180
|
+
run.unsafe('SELECT DISTINCT order_type FROM orders WHERE order_type IS NOT NULL').execute(),
|
|
181
|
+
])
|
|
182
|
+
const values = (result: unknown, key: string) => rows(result).map(row => String(row[key] ?? '').trim()).filter(Boolean).sort()
|
|
183
|
+
return {
|
|
184
|
+
statuses: [...new Set([...DEFAULT_ORDER_STATUSES, ...values(statuses, 'status')])],
|
|
185
|
+
orderTypes: [...new Set([...DEFAULT_ORDER_TYPES, ...values(types, 'order_type')])],
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface OrderPage {
|
|
190
|
+
records: CommerceOrderRecord[]
|
|
191
|
+
total: number
|
|
192
|
+
page: number
|
|
193
|
+
summary: CommerceOrderSummary
|
|
194
|
+
statuses: string[]
|
|
195
|
+
orderTypes: string[]
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function orderBy(query: Pick<OrderListQuery, 'sort' | 'direction'>): string {
|
|
199
|
+
const direction = query.direction === 'asc' ? 'ASC' : 'DESC'
|
|
200
|
+
// The id breaks ties, so a page boundary never repeats or skips an order.
|
|
201
|
+
return ` ORDER BY ${sortExpression(query.sort)} ${direction}, o.id ${direction}`
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export async function readOrderPage(
|
|
205
|
+
query: OrderListQuery,
|
|
206
|
+
run: OrderListRunner = db,
|
|
207
|
+
dialect: QueryBuilderDialect = getDatabaseDialect(),
|
|
208
|
+
): Promise<OrderPage> {
|
|
209
|
+
const { where, values } = orderFilter(query, dialect)
|
|
210
|
+
const [counted, summary, options] = await Promise.all([
|
|
211
|
+
run.unsafe(`SELECT COUNT(*) AS total_count${FROM}${where}`, values).execute(),
|
|
212
|
+
summarize(run),
|
|
213
|
+
choices(run),
|
|
214
|
+
])
|
|
215
|
+
const total = countOf(rows(counted)[0]?.total_count)
|
|
216
|
+
const page = pageWithin(query.page, total, query.perPage)
|
|
217
|
+
const orders = await run.unsafe(
|
|
218
|
+
`SELECT o.*${FROM}${where}${orderBy(query)} LIMIT ${query.perPage} OFFSET ${(page - 1) * query.perPage}`,
|
|
219
|
+
values,
|
|
220
|
+
).execute()
|
|
221
|
+
|
|
222
|
+
return { records: await recordsFor(rows(orders), run, dialect), total, page, summary, ...options }
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** How many orders the export reads per query. */
|
|
226
|
+
const EXPORT_BATCH = 500
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Every order matching the query, in its order, for the CSV export. Read a
|
|
230
|
+
* batch at a time, so a large export never needs one enormous result set.
|
|
231
|
+
*/
|
|
232
|
+
export async function readOrdersForExport(
|
|
233
|
+
query: Omit<OrderListQuery, 'page' | 'perPage'>,
|
|
234
|
+
run: OrderListRunner = db,
|
|
235
|
+
dialect: QueryBuilderDialect = getDatabaseDialect(),
|
|
236
|
+
batchSize: number = EXPORT_BATCH,
|
|
237
|
+
): Promise<CommerceOrderRecord[]> {
|
|
238
|
+
const { where, values } = orderFilter(query, dialect)
|
|
239
|
+
const records: CommerceOrderRecord[] = []
|
|
240
|
+
for (let offset = 0; ; offset += batchSize) {
|
|
241
|
+
const batch = rows(await run.unsafe(
|
|
242
|
+
`SELECT o.*${FROM}${where}${orderBy(query)} LIMIT ${batchSize} OFFSET ${offset}`,
|
|
243
|
+
values,
|
|
244
|
+
).execute())
|
|
245
|
+
records.push(...await recordsFor(batch, run, dialect))
|
|
246
|
+
if (batch.length < batchSize)
|
|
247
|
+
return records
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const CSV_HEADER = ['Order ID', 'Customer', 'Customer email', 'Status', 'Order type', 'Items', 'Total', 'Currency', 'Tax', 'Discount', 'Delivery fee', 'Tip', 'Delivery address', 'Created at']
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The CSV the "Export filtered" button downloads: the same columns the page
|
|
255
|
+
* built from what it had loaded, now from every matching order. Amounts are
|
|
256
|
+
* the major-unit strings a person types (`minor` converts them), and a leading
|
|
257
|
+
* byte-order mark tells spreadsheet apps it is UTF-8.
|
|
258
|
+
*/
|
|
259
|
+
export function ordersCsv(records: CommerceOrderRecord[], minor: (amount: number, currency: string) => string): string {
|
|
260
|
+
const escape = (value: string): string => `"${value.replaceAll('"', '""')}"`
|
|
261
|
+
const lines = records.map(record => [
|
|
262
|
+
record.id,
|
|
263
|
+
record.customerName,
|
|
264
|
+
record.customerEmail,
|
|
265
|
+
record.status,
|
|
266
|
+
record.orderType,
|
|
267
|
+
String(record.itemCount),
|
|
268
|
+
minor(record.totalAmount, record.currency),
|
|
269
|
+
record.currency,
|
|
270
|
+
minor(record.taxAmount, record.currency),
|
|
271
|
+
minor(record.discountAmount, record.currency),
|
|
272
|
+
minor(record.deliveryFee, record.currency),
|
|
273
|
+
minor(record.tipAmount, record.currency),
|
|
274
|
+
record.deliveryAddress,
|
|
275
|
+
record.createdAt,
|
|
276
|
+
])
|
|
277
|
+
return `${[CSV_HEADER, ...lines].map(row => row.map(escape).join(',')).join('\n')}`
|
|
278
|
+
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
normalizeOrderCustomerOption,
|
|
7
7
|
summarizeCommerceOrders,
|
|
8
8
|
} from './commerce-order-records'
|
|
9
|
+
import { referencedIds } from './commerce-record'
|
|
9
10
|
|
|
10
11
|
function order(overrides: Record<string, unknown> = {}): Record<string, unknown> {
|
|
11
12
|
return {
|
|
@@ -134,3 +135,31 @@ describe('dashboard commerce order records', () => {
|
|
|
134
135
|
})
|
|
135
136
|
})
|
|
136
137
|
})
|
|
138
|
+
|
|
139
|
+
describe('the customers and coupons an order page reads', () => {
|
|
140
|
+
test('are exactly the ids the orders reference, once each, in order', () => {
|
|
141
|
+
const orders = [
|
|
142
|
+
order({ id: 1, customer_id: 704, coupon_id: null }),
|
|
143
|
+
order({ id: 2, customer_id: 12, coupon_id: 9 }),
|
|
144
|
+
order({ id: 3, customer_id: 704, coupon_id: '9' }),
|
|
145
|
+
order({ id: 4, customer_id: null, coupon_id: 3 }),
|
|
146
|
+
]
|
|
147
|
+
expect(referencedIds(orders, 'customer_id', 'customerId')).toEqual([12, 704])
|
|
148
|
+
expect(referencedIds(orders, 'coupon_id', 'couponId')).toEqual([3, 9])
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
test('cover every order, so none is refused for a customer that was not read', () => {
|
|
152
|
+
// The 704th customer by name is past any fixed first-500 read. The map
|
|
153
|
+
// built from the referenced ids still holds it, so the order normalizes.
|
|
154
|
+
const orders = [order({ id: 1, customer_id: 704 })]
|
|
155
|
+
const ids = referencedIds(orders, 'customer_id')
|
|
156
|
+
const customers = new Map(ids.map(id => [String(id), { name: `Customer ${id}`, email: `c${id}@example.com` }]))
|
|
157
|
+
expect(normalizeCommerceOrderRecord(orders[0], customers, new Map()).customerName).toBe('Customer 704')
|
|
158
|
+
// And the refusal it prevents is real: without that customer the order is rejected.
|
|
159
|
+
expect(() => normalizeCommerceOrderRecord(orders[0], new Map(), new Map())).toThrow('references missing Customer 704')
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('ignore empty, zero and non-numeric references', () => {
|
|
163
|
+
expect(referencedIds([order({ customer_id: '' }), order({ customer_id: 0 }), order({ customer_id: 'abc' }), order({ customer_id: -4 })], 'customer_id')).toEqual([])
|
|
164
|
+
})
|
|
165
|
+
})
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { Database } from 'bun:sqlite'
|
|
2
|
+
import { SQL } from 'bun'
|
|
3
|
+
import { describe, expect, test } from 'bun:test'
|
|
4
|
+
import type { CommerceSqlRunner } from './commerce-sql'
|
|
5
|
+
import type { PaymentListQuery } from './commerce-payment-list'
|
|
6
|
+
import { parsePaymentListQuery, readPaymentPage, readPaymentsForExport } from './commerce-payment-list'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The Payments list against each dialect's real engine (stacksjs/stacks#3218),
|
|
10
|
+
* with status and method as real enum columns where the dialect has them.
|
|
11
|
+
*/
|
|
12
|
+
type Dialect = 'sqlite' | 'postgres' | 'mysql'
|
|
13
|
+
|
|
14
|
+
const NOW = new Date('2026-11-06T12:00:00.000Z')
|
|
15
|
+
const STATUSES = ['completed', 'failed', 'pending', 'refunded', 'partiallyRefunded'] as const
|
|
16
|
+
const METHODS = ['creditCard', 'paypal', 'cash'] as const
|
|
17
|
+
|
|
18
|
+
/** 24 payments, one every 20 hours back from NOW, each for an order. */
|
|
19
|
+
const PAYMENTS = Array.from({ length: 24 }, (_, index) => {
|
|
20
|
+
const id = index + 1
|
|
21
|
+
const status = STATUSES[id % STATUSES.length]!
|
|
22
|
+
const amount = 1000 + id * 50
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
amount,
|
|
26
|
+
refund_amount: status === 'refunded' ? amount : status === 'partiallyRefunded' ? 200 : null,
|
|
27
|
+
method: METHODS[id % METHODS.length]!,
|
|
28
|
+
status,
|
|
29
|
+
currency: id % 6 === 0 ? 'usd' : (id % 2 === 0 ? 'USD' : 'EUR'),
|
|
30
|
+
billing_email: id === 7 ? 'pay_100%@shop.test' : `buyer${id}@example.com`,
|
|
31
|
+
order_id: id + 700,
|
|
32
|
+
hoursAgo: index * 20,
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const SUCCESSFUL = new Set(['completed', 'succeeded', 'partiallyRefunded', 'refunded'])
|
|
37
|
+
|
|
38
|
+
function within(days: number) {
|
|
39
|
+
return PAYMENTS.filter(payment => days === 0 || payment.hoursAgo * 3_600_000 <= days * 86_400_000)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function query(overrides: Partial<PaymentListQuery> = {}): PaymentListQuery {
|
|
43
|
+
return { search: '', status: '', method: '', days: 0, sort: 'created', direction: 'desc', page: 1, perPage: 10, ...overrides }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function setUp(run: (sql: string, values?: unknown[]) => Promise<unknown>, dialect: Dialect) {
|
|
47
|
+
const pk = dialect === 'postgres' ? 'BIGINT PRIMARY KEY' : 'INTEGER PRIMARY KEY'
|
|
48
|
+
const text = dialect === 'mysql' ? 'VARCHAR(255)' : 'TEXT'
|
|
49
|
+
let statusType = text
|
|
50
|
+
let methodType = text
|
|
51
|
+
if (dialect === 'postgres') {
|
|
52
|
+
await run(`CREATE TYPE payment_status AS ENUM (${[...STATUSES, 'succeeded', 'processing'].map(s => `'${s}'`).join(', ')})`)
|
|
53
|
+
await run(`CREATE TYPE payment_method AS ENUM (${METHODS.map(m => `'${m}'`).join(', ')})`)
|
|
54
|
+
statusType = 'payment_status'
|
|
55
|
+
methodType = 'payment_method'
|
|
56
|
+
}
|
|
57
|
+
if (dialect === 'mysql') {
|
|
58
|
+
statusType = `ENUM(${[...STATUSES, 'succeeded', 'processing'].map(s => `'${s}'`).join(', ')})`
|
|
59
|
+
methodType = `ENUM(${METHODS.map(m => `'${m}'`).join(', ')})`
|
|
60
|
+
}
|
|
61
|
+
const time = dialect === 'sqlite' ? 'TEXT' : dialect === 'mysql' ? 'DATETIME(3)' : 'TIMESTAMP'
|
|
62
|
+
await run(`CREATE TABLE orders (id ${pk})`)
|
|
63
|
+
await run(`CREATE TABLE customers (id ${pk})`)
|
|
64
|
+
await run(`CREATE TABLE payments (id ${pk}, amount INTEGER, refund_amount INTEGER NULL, method ${methodType}, status ${statusType}, currency ${text}, reference_number ${text} NULL, card_last_four ${text} NULL, card_brand ${text} NULL, billing_email ${text} NULL, transaction_id ${text} NULL, payment_provider ${text} NULL, notes ${text} NULL, order_id INTEGER NULL, customer_id INTEGER NULL, created_at ${time})`)
|
|
65
|
+
const p = (count: number) => Array.from({ length: count }, (_, i) => dialect === 'postgres' ? `$${i + 1}` : '?').join(', ')
|
|
66
|
+
for (const payment of PAYMENTS)
|
|
67
|
+
await run(`INSERT INTO orders (id) VALUES (${p(1)})`, [payment.order_id])
|
|
68
|
+
for (const payment of PAYMENTS) {
|
|
69
|
+
const at = new Date(NOW.getTime() - payment.hoursAgo * 3_600_000).toISOString().slice(0, 19)
|
|
70
|
+
// SQLite gets both text forms, which compare wrongly as plain text.
|
|
71
|
+
const created = dialect === 'sqlite' && payment.id % 2 === 0 ? at.replace('T', ' ') : at.replace('T', dialect === 'sqlite' ? 'T' : ' ')
|
|
72
|
+
await run(
|
|
73
|
+
`INSERT INTO payments (id, amount, refund_amount, method, status, currency, billing_email, order_id, created_at) VALUES (${p(9)})`,
|
|
74
|
+
[payment.id, payment.amount, payment.refund_amount, payment.method, payment.status, payment.currency, payment.billing_email, payment.order_id, created],
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function exercise(runner: CommerceSqlRunner, dialect: Dialect) {
|
|
80
|
+
const read = (overrides: Partial<PaymentListQuery> = {}) => readPaymentPage(query(overrides), runner, dialect, NOW)
|
|
81
|
+
|
|
82
|
+
// Every time range counts exactly the payments inside it.
|
|
83
|
+
for (const days of [1, 7, 30, 0] as const)
|
|
84
|
+
expect((await read({ days })).total).toBe(within(days).length)
|
|
85
|
+
|
|
86
|
+
// The summary and breakdown describe the matching set, not the page.
|
|
87
|
+
const week = await read({ days: 7, perPage: 10 })
|
|
88
|
+
const inWeek = within(7)
|
|
89
|
+
expect(week.records.length).toBeLessThanOrEqual(10)
|
|
90
|
+
expect(week.summary.total).toBe(inWeek.length)
|
|
91
|
+
const successful = inWeek.filter(payment => SUCCESSFUL.has(payment.status))
|
|
92
|
+
const failed = inWeek.filter(payment => payment.status === 'failed')
|
|
93
|
+
expect(week.summary.successful).toBe(successful.length)
|
|
94
|
+
expect(week.summary.successRate).toBe(Math.round((successful.length / (successful.length + failed.length)) * 1000) / 10)
|
|
95
|
+
const captured = (currency: string) => successful.filter(payment => payment.currency.toUpperCase() === currency).reduce((sum, payment) => sum + payment.amount, 0)
|
|
96
|
+
expect(week.summary.capturedByCurrency.USD).toBe(captured('USD'))
|
|
97
|
+
expect(week.summary.capturedByCurrency.EUR).toBe(captured('EUR'))
|
|
98
|
+
expect(week.summary.currencies).toEqual(['EUR', 'USD'])
|
|
99
|
+
const statusCounts = Object.fromEntries(week.breakdown.statuses.map(row => [row.key, row.count]))
|
|
100
|
+
for (const status of new Set(inWeek.map(payment => payment.status)))
|
|
101
|
+
expect(statusCounts[status]).toBe(inWeek.filter(payment => payment.status === status).length)
|
|
102
|
+
|
|
103
|
+
// Newest first with id breaking ties, stable across pages.
|
|
104
|
+
const all = [...PAYMENTS].sort((a, b) => a.hoursAgo - b.hoursAgo || b.id - a.id).map(payment => String(payment.id))
|
|
105
|
+
const pages = [await read({ page: 1 }), await read({ page: 2 }), await read({ page: 3 })]
|
|
106
|
+
expect(pages.flatMap(result => result.records.map(record => record.id))).toEqual(all)
|
|
107
|
+
expect((await read({ page: 9 })).page).toBe(3)
|
|
108
|
+
|
|
109
|
+
// Filters on the enum columns, and a value no payment has, which is no match rather than an error.
|
|
110
|
+
expect((await read({ status: 'failed', perPage: 100 })).total).toBe(PAYMENTS.filter(payment => payment.status === 'failed').length)
|
|
111
|
+
expect((await read({ method: 'paypal', perPage: 100 })).total).toBe(PAYMENTS.filter(payment => payment.method === 'paypal').length)
|
|
112
|
+
expect((await read({ status: 'not-a-status' })).total).toBe(0)
|
|
113
|
+
|
|
114
|
+
// Search: enum text in any case, email with a literal %, and the order id.
|
|
115
|
+
expect((await read({ search: 'PAYPAL', perPage: 100 })).total).toBe(PAYMENTS.filter(payment => payment.method === 'paypal').length)
|
|
116
|
+
expect((await read({ search: '100%' })).records.map(record => record.id)).toEqual(['7'])
|
|
117
|
+
expect((await read({ search: '712' })).records.map(record => record.id)).toEqual(['12'])
|
|
118
|
+
|
|
119
|
+
// Amount sorts high first; status sorts by name, newest first within one.
|
|
120
|
+
const amounts = (await read({ sort: 'amount', direction: 'desc', perPage: 100 })).records.map(record => record.amount)
|
|
121
|
+
expect(amounts).toEqual([...amounts].sort((a, b) => b - a))
|
|
122
|
+
const byStatus = (await read({ sort: 'status', direction: 'asc', perPage: 100 })).records.map(record => record.status)
|
|
123
|
+
expect(byStatus).toEqual([...byStatus].sort())
|
|
124
|
+
|
|
125
|
+
// The export holds every match across batches, in order.
|
|
126
|
+
const exported = await readPaymentsForExport({ search: '', status: '', method: '', days: 0, sort: 'created', direction: 'desc' }, runner, dialect, NOW, 5)
|
|
127
|
+
expect(exported.map(record => record.id)).toEqual(all)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
describe('readPaymentPage on SQLite', () => {
|
|
131
|
+
test('ranges, summary, breakdown, filters, search, sorts, pages and export', async () => {
|
|
132
|
+
const database = new Database(':memory:')
|
|
133
|
+
await setUp(async (sql, values = []) => database.query(sql).run(...(values as never[])), 'sqlite')
|
|
134
|
+
await exercise({ unsafe: (sql, values = []) => ({ execute: async () => database.query(sql).all(...(values as never[])) }) }, 'sqlite')
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
for (const dialect of ['postgres', 'mysql'] as const) {
|
|
139
|
+
const connection = dialect === 'postgres' ? process.env.STACKS_TEST_POSTGRES_URL : process.env.STACKS_TEST_MYSQL_URL
|
|
140
|
+
|
|
141
|
+
test.skipIf(!connection)(`readPaymentPage on ${dialect}: ranges, summary, breakdown, filters, search, sorts, pages and export`, async () => {
|
|
142
|
+
const url = new URL(connection!)
|
|
143
|
+
if (!['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname))
|
|
144
|
+
throw new Error('Payment list tests require a local disposable database server')
|
|
145
|
+
|
|
146
|
+
const name = `stacks_payment_list_${crypto.randomUUID().replaceAll('-', '')}`
|
|
147
|
+
const quoted = dialect === 'mysql' ? `\`${name}\`` : `"${name}"`
|
|
148
|
+
const admin = new SQL({ url: url.href, database: decodeURIComponent(url.pathname.slice(1)) || undefined })
|
|
149
|
+
await admin.unsafe(`CREATE DATABASE ${quoted}`)
|
|
150
|
+
const scoped = new URL(url.href)
|
|
151
|
+
scoped.pathname = `/${name}`
|
|
152
|
+
// Explicit database wins over inherited PGDATABASE / MYSQL_DATABASE in CI.
|
|
153
|
+
const database = new SQL({ url: scoped.href, database: name })
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
await setUp(async (sql, values = []) => await database.unsafe(sql, values), dialect)
|
|
157
|
+
await exercise({ unsafe: (sql, values = []) => ({ execute: async () => await database.unsafe(sql, values) }) }, dialect)
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
await database.close()
|
|
161
|
+
try { await admin.unsafe(`DROP DATABASE ${quoted}${dialect === 'postgres' ? ' WITH (FORCE)' : ''}`) }
|
|
162
|
+
finally { await admin.close() }
|
|
163
|
+
}
|
|
164
|
+
}, 60_000)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
describe('parsePaymentListQuery', () => {
|
|
168
|
+
const reader = (values: Record<string, unknown>) => (key: string) => values[key] ?? ''
|
|
169
|
+
|
|
170
|
+
test('defaults to every payment, newest first, 25 a page', () => {
|
|
171
|
+
expect(parsePaymentListQuery(reader({}))).toEqual({ search: '', status: '', method: '', days: 0, sort: 'created', direction: 'desc', page: 1, perPage: 25 })
|
|
172
|
+
expect(parsePaymentListQuery(reader({ days: 'all' }))).toHaveProperty('days', 0)
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
test('accepts only the ranges the page offers', () => {
|
|
176
|
+
expect(parsePaymentListQuery(reader({ days: '30' }))).toHaveProperty('days', 30)
|
|
177
|
+
expect(parsePaymentListQuery(reader({ days: '45' }))).toHaveProperty('error')
|
|
178
|
+
expect(parsePaymentListQuery(reader({ sort: 'card_last_four' }))).toHaveProperty('error')
|
|
179
|
+
})
|
|
180
|
+
})
|