@stacksjs/commerce 0.70.55 → 0.70.56
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 +10 -7
- package/src/carts/destroy.ts +0 -54
- package/src/carts/fetch.ts +0 -20
- package/src/carts/index.ts +0 -13
- package/src/carts/store.ts +0 -75
- package/src/carts/update.ts +0 -78
- package/src/coupons/destroy.ts +0 -49
- package/src/coupons/fetch.ts +0 -510
- package/src/coupons/index.ts +0 -30
- package/src/coupons/store.ts +0 -46
- package/src/coupons/update.ts +0 -147
- package/src/customers/destroy.ts +0 -62
- package/src/customers/fetch.ts +0 -20
- package/src/customers/index.ts +0 -17
- package/src/customers/store.ts +0 -45
- package/src/customers/update.ts +0 -44
- package/src/devices/destroy.ts +0 -54
- package/src/devices/export.ts +0 -98
- package/src/devices/fetch.ts +0 -125
- package/src/devices/index.ts +0 -31
- package/src/devices/store.ts +0 -82
- package/src/devices/update.ts +0 -125
- package/src/errors/destroy.ts +0 -54
- package/src/errors/fetch.ts +0 -197
- package/src/errors/index.ts +0 -28
- package/src/errors/update.ts +0 -116
- package/src/gift-cards/destroy.ts +0 -87
- package/src/gift-cards/fetch.ts +0 -431
- package/src/gift-cards/index.ts +0 -26
- package/src/gift-cards/store.ts +0 -56
- package/src/gift-cards/update.ts +0 -102
- package/src/index.ts +0 -78
- package/src/orders/destroy.ts +0 -111
- package/src/orders/events.ts +0 -121
- package/src/orders/export.ts +0 -158
- package/src/orders/fetch.ts +0 -379
- package/src/orders/guards.ts +0 -261
- package/src/orders/index.ts +0 -91
- package/src/orders/place-order.ts +0 -274
- package/src/orders/store.ts +0 -51
- package/src/orders/totals.ts +0 -190
- package/src/orders/update.ts +0 -164
- package/src/orders/webhook.ts +0 -312
- package/src/payments/destroy.ts +0 -56
- package/src/payments/fetch.ts +0 -288
- package/src/payments/index.ts +0 -16
- package/src/payments/store.ts +0 -63
- package/src/payments/update.ts +0 -52
- package/src/product.ts +0 -0
- package/src/products/categories/destroy.ts +0 -103
- package/src/products/categories/fetch.ts +0 -285
- package/src/products/categories/index.ts +0 -36
- package/src/products/categories/store.ts +0 -87
- package/src/products/categories/update.ts +0 -251
- package/src/products/index.ts +0 -35
- package/src/products/items/destroy.ts +0 -54
- package/src/products/items/fetch.ts +0 -282
- package/src/products/items/index.ts +0 -26
- package/src/products/items/store.ts +0 -84
- package/src/products/items/update.ts +0 -324
- package/src/products/manufacturers/destroy.ts +0 -56
- package/src/products/manufacturers/fetch.ts +0 -117
- package/src/products/manufacturers/index.ts +0 -24
- package/src/products/manufacturers/store.ts +0 -82
- package/src/products/manufacturers/update.ts +0 -113
- package/src/products/reviews/destroy.ts +0 -56
- package/src/products/reviews/fetch.ts +0 -63
- package/src/products/reviews/index.ts +0 -25
- package/src/products/reviews/store.ts +0 -46
- package/src/products/reviews/update.ts +0 -82
- package/src/products/units/destroy.ts +0 -56
- package/src/products/units/fetch.ts +0 -20
- package/src/products/units/index.ts +0 -13
- package/src/products/units/store.ts +0 -162
- package/src/products/units/update.ts +0 -159
- package/src/products/variants/destroy.ts +0 -56
- package/src/products/variants/fetch.ts +0 -20
- package/src/products/variants/index.ts +0 -21
- package/src/products/variants/store.ts +0 -136
- package/src/products/variants/update.ts +0 -104
- package/src/receipts/destroy.ts +0 -54
- package/src/receipts/export.ts +0 -0
- package/src/receipts/fetch.ts +0 -222
- package/src/receipts/index.ts +0 -24
- package/src/receipts/printer.ts +0 -69
- package/src/receipts/store.ts +0 -69
- package/src/receipts/update.ts +0 -124
- package/src/shippings/delivery-routes/destroy.ts +0 -54
- package/src/shippings/delivery-routes/fetch.ts +0 -42
- package/src/shippings/delivery-routes/index.ts +0 -26
- package/src/shippings/delivery-routes/store.ts +0 -69
- package/src/shippings/delivery-routes/update.ts +0 -120
- package/src/shippings/digital-deliveries/destroy.ts +0 -111
- package/src/shippings/digital-deliveries/fetch.ts +0 -20
- package/src/shippings/digital-deliveries/index.ts +0 -26
- package/src/shippings/digital-deliveries/store.ts +0 -76
- package/src/shippings/digital-deliveries/update.ts +0 -129
- package/src/shippings/drivers/destroy.ts +0 -78
- package/src/shippings/drivers/fetch.ts +0 -20
- package/src/shippings/drivers/index.ts +0 -24
- package/src/shippings/drivers/store.ts +0 -69
- package/src/shippings/drivers/update.ts +0 -117
- package/src/shippings/index.ts +0 -39
- package/src/shippings/license-keys/destroy.ts +0 -111
- package/src/shippings/license-keys/fetch.ts +0 -20
- package/src/shippings/license-keys/index.ts +0 -26
- package/src/shippings/license-keys/store.ts +0 -77
- package/src/shippings/license-keys/update.ts +0 -117
- package/src/shippings/shipping-methods/destroy.ts +0 -111
- package/src/shippings/shipping-methods/fetch.ts +0 -62
- package/src/shippings/shipping-methods/index.ts +0 -28
- package/src/shippings/shipping-methods/store.ts +0 -123
- package/src/shippings/shipping-methods/update.ts +0 -120
- package/src/shippings/shipping-rates/destroy.ts +0 -102
- package/src/shippings/shipping-rates/fetch.ts +0 -320
- package/src/shippings/shipping-rates/index.ts +0 -36
- package/src/shippings/shipping-rates/store.ts +0 -102
- package/src/shippings/shipping-rates/update.ts +0 -139
- package/src/shippings/shipping-zones/destroy.ts +0 -111
- package/src/shippings/shipping-zones/fetch.ts +0 -96
- package/src/shippings/shipping-zones/index.ts +0 -26
- package/src/shippings/shipping-zones/store.ts +0 -74
- package/src/shippings/shipping-zones/update.ts +0 -156
- package/src/tax/destroy.ts +0 -54
- package/src/tax/fetch.ts +0 -20
- package/src/tax/index.ts +0 -24
- package/src/tax/store.ts +0 -69
- package/src/tax/update.ts +0 -119
- package/src/tests/coupons.test.ts +0 -90
- package/src/tests/customers.test.ts +0 -39
- package/src/tests/device.test.ts +0 -111
- package/src/tests/digitals.test.ts +0 -31
- package/src/tests/drivers.test.ts +0 -25
- package/src/tests/gift-cards.test.ts +0 -36
- package/src/tests/license.test.ts +0 -31
- package/src/tests/manufacturers.test.ts +0 -80
- package/src/tests/orders.test.ts +0 -25
- package/src/tests/payments.test.ts +0 -75
- package/src/tests/rates.test.ts +0 -367
- package/src/tests/receipts.test.ts +0 -287
- package/src/tests/restaurant.test.ts +0 -522
- package/src/tests/reviews.test.ts +0 -165
- package/src/tests/routes.test.ts +0 -51
- package/src/tests/setup.ts +0 -149
- package/src/tests/shipping.test.ts +0 -88
- package/src/tests/tax.test.ts +0 -25
- package/src/tests/units.test.ts +0 -110
- package/src/tests/variants.test.ts +0 -133
- package/src/tests/waitlist.test.ts +0 -303
- package/src/tests/zones.test.ts +0 -86
- package/src/types.ts +0 -312
- package/src/utils/typed-stats.ts +0 -67
- package/src/waitlists/index.ts +0 -19
- package/src/waitlists/products/destroy.ts +0 -65
- package/src/waitlists/products/export.ts +0 -113
- package/src/waitlists/products/fetch.ts +0 -362
- package/src/waitlists/products/index.ts +0 -33
- package/src/waitlists/products/store.ts +0 -112
- package/src/waitlists/products/update.ts +0 -125
- package/src/waitlists/restaurant/destroy.ts +0 -65
- package/src/waitlists/restaurant/export.ts +0 -107
- package/src/waitlists/restaurant/fetch.ts +0 -538
- package/src/waitlists/restaurant/index.ts +0 -43
- package/src/waitlists/restaurant/store.ts +0 -109
- package/src/waitlists/restaurant/update.ts +0 -198
- /package/dist/{src/coupons → coupons}/destroy.d.ts +0 -0
- /package/dist/{src/coupons → coupons}/fetch.d.ts +0 -0
- /package/dist/{src/coupons → coupons}/index.d.ts +0 -0
- /package/dist/{src/coupons → coupons}/store.d.ts +0 -0
- /package/dist/{src/coupons → coupons}/update.d.ts +0 -0
- /package/dist/{src/customers → customers}/destroy.d.ts +0 -0
- /package/dist/{src/customers → customers}/fetch.d.ts +0 -0
- /package/dist/{src/customers → customers}/index.d.ts +0 -0
- /package/dist/{src/customers → customers}/store.d.ts +0 -0
- /package/dist/{src/customers → customers}/update.d.ts +0 -0
- /package/dist/{src/devices → devices}/destroy.d.ts +0 -0
- /package/dist/{src/devices → devices}/export.d.ts +0 -0
- /package/dist/{src/devices → devices}/fetch.d.ts +0 -0
- /package/dist/{src/devices → devices}/index.d.ts +0 -0
- /package/dist/{src/devices → devices}/store.d.ts +0 -0
- /package/dist/{src/devices → devices}/update.d.ts +0 -0
- /package/dist/{src/errors → errors}/destroy.d.ts +0 -0
- /package/dist/{src/errors → errors}/fetch.d.ts +0 -0
- /package/dist/{src/errors → errors}/index.d.ts +0 -0
- /package/dist/{src/errors → errors}/update.d.ts +0 -0
- /package/dist/{src/gift-cards → gift-cards}/destroy.d.ts +0 -0
- /package/dist/{src/gift-cards → gift-cards}/fetch.d.ts +0 -0
- /package/dist/{src/gift-cards → gift-cards}/index.d.ts +0 -0
- /package/dist/{src/gift-cards → gift-cards}/store.d.ts +0 -0
- /package/dist/{src/gift-cards → gift-cards}/update.d.ts +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/orders → orders}/destroy.d.ts +0 -0
- /package/dist/{src/orders → orders}/events.d.ts +0 -0
- /package/dist/{src/orders → orders}/export.d.ts +0 -0
- /package/dist/{src/orders → orders}/fetch.d.ts +0 -0
- /package/dist/{src/orders → orders}/guards.d.ts +0 -0
- /package/dist/{src/orders → orders}/index.d.ts +0 -0
- /package/dist/{src/orders → orders}/place-order.d.ts +0 -0
- /package/dist/{src/orders → orders}/store.d.ts +0 -0
- /package/dist/{src/orders → orders}/totals.d.ts +0 -0
- /package/dist/{src/orders → orders}/update.d.ts +0 -0
- /package/dist/{src/orders → orders}/webhook.d.ts +0 -0
- /package/dist/{src/payments → payments}/destroy.d.ts +0 -0
- /package/dist/{src/payments → payments}/fetch.d.ts +0 -0
- /package/dist/{src/payments → payments}/index.d.ts +0 -0
- /package/dist/{src/payments → payments}/store.d.ts +0 -0
- /package/dist/{src/payments → payments}/update.d.ts +0 -0
- /package/dist/{src/products → products}/categories/destroy.d.ts +0 -0
- /package/dist/{src/products → products}/categories/fetch.d.ts +0 -0
- /package/dist/{src/products → products}/categories/index.d.ts +0 -0
- /package/dist/{src/products → products}/categories/store.d.ts +0 -0
- /package/dist/{src/products → products}/categories/update.d.ts +0 -0
- /package/dist/{src/products → products}/index.d.ts +0 -0
- /package/dist/{src/products → products}/items/destroy.d.ts +0 -0
- /package/dist/{src/products → products}/items/fetch.d.ts +0 -0
- /package/dist/{src/products → products}/items/index.d.ts +0 -0
- /package/dist/{src/products → products}/items/store.d.ts +0 -0
- /package/dist/{src/products → products}/items/update.d.ts +0 -0
- /package/dist/{src/products → products}/manufacturers/destroy.d.ts +0 -0
- /package/dist/{src/products → products}/manufacturers/fetch.d.ts +0 -0
- /package/dist/{src/products → products}/manufacturers/index.d.ts +0 -0
- /package/dist/{src/products → products}/manufacturers/store.d.ts +0 -0
- /package/dist/{src/products → products}/manufacturers/update.d.ts +0 -0
- /package/dist/{src/products → products}/reviews/destroy.d.ts +0 -0
- /package/dist/{src/products → products}/reviews/fetch.d.ts +0 -0
- /package/dist/{src/products → products}/reviews/index.d.ts +0 -0
- /package/dist/{src/products → products}/reviews/store.d.ts +0 -0
- /package/dist/{src/products → products}/reviews/update.d.ts +0 -0
- /package/dist/{src/products → products}/units/destroy.d.ts +0 -0
- /package/dist/{src/products → products}/units/fetch.d.ts +0 -0
- /package/dist/{src/products → products}/units/index.d.ts +0 -0
- /package/dist/{src/products → products}/units/store.d.ts +0 -0
- /package/dist/{src/products → products}/units/update.d.ts +0 -0
- /package/dist/{src/products → products}/variants/destroy.d.ts +0 -0
- /package/dist/{src/products → products}/variants/fetch.d.ts +0 -0
- /package/dist/{src/products → products}/variants/index.d.ts +0 -0
- /package/dist/{src/products → products}/variants/store.d.ts +0 -0
- /package/dist/{src/products → products}/variants/update.d.ts +0 -0
- /package/dist/{src/receipts → receipts}/destroy.d.ts +0 -0
- /package/dist/{src/receipts → receipts}/fetch.d.ts +0 -0
- /package/dist/{src/receipts → receipts}/index.d.ts +0 -0
- /package/dist/{src/receipts → receipts}/store.d.ts +0 -0
- /package/dist/{src/receipts → receipts}/update.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/delivery-routes/destroy.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/delivery-routes/fetch.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/delivery-routes/index.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/delivery-routes/store.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/delivery-routes/update.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/digital-deliveries/destroy.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/digital-deliveries/fetch.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/digital-deliveries/index.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/digital-deliveries/store.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/digital-deliveries/update.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/drivers/destroy.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/drivers/fetch.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/drivers/index.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/drivers/store.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/drivers/update.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/index.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/license-keys/destroy.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/license-keys/fetch.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/license-keys/index.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/license-keys/store.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/license-keys/update.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-methods/destroy.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-methods/fetch.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-methods/index.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-methods/store.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-methods/update.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-rates/destroy.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-rates/fetch.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-rates/index.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-rates/store.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-rates/update.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-zones/destroy.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-zones/fetch.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-zones/index.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-zones/store.d.ts +0 -0
- /package/dist/{src/shippings → shippings}/shipping-zones/update.d.ts +0 -0
- /package/dist/{src/tax → tax}/destroy.d.ts +0 -0
- /package/dist/{src/tax → tax}/fetch.d.ts +0 -0
- /package/dist/{src/tax → tax}/index.d.ts +0 -0
- /package/dist/{src/tax → tax}/store.d.ts +0 -0
- /package/dist/{src/tax → tax}/update.d.ts +0 -0
- /package/dist/{src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{src/utils → utils}/typed-stats.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/index.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/products/destroy.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/products/fetch.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/products/index.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/products/store.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/products/update.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/restaurant/destroy.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/restaurant/fetch.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/restaurant/index.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/restaurant/store.d.ts +0 -0
- /package/dist/{src/waitlists → waitlists}/restaurant/update.d.ts +0 -0
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { db } from '@stacksjs/database'
|
|
2
|
-
import { HttpError } from '@stacksjs/error-handling'
|
|
3
|
-
import { formatDate, isUniqueViolation } from '@stacksjs/orm'
|
|
4
|
-
type ManufacturerJsonResponse = ModelRow<typeof Manufacturer>
|
|
5
|
-
type ManufacturerUpdate = UpdateModelData<typeof Manufacturer>
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Update a manufacturer
|
|
9
|
-
*
|
|
10
|
-
* @param id The ID of the manufacturer to update
|
|
11
|
-
* @param data The manufacturer data to update
|
|
12
|
-
* @returns The updated manufacturer record
|
|
13
|
-
*/
|
|
14
|
-
export async function update(id: number, data: ManufacturerUpdate): Promise<ManufacturerJsonResponse> {
|
|
15
|
-
try {
|
|
16
|
-
if (!id)
|
|
17
|
-
throw new Error('Manufacturer ID is required for update')
|
|
18
|
-
|
|
19
|
-
const result = await db
|
|
20
|
-
.updateTable('manufacturers')
|
|
21
|
-
.set({
|
|
22
|
-
...data,
|
|
23
|
-
updated_at: formatDate(new Date()),
|
|
24
|
-
})
|
|
25
|
-
.where('id', '=', id)
|
|
26
|
-
.returningAll()
|
|
27
|
-
.executeTakeFirst()
|
|
28
|
-
|
|
29
|
-
if (!result)
|
|
30
|
-
throw new Error(`Manufacturer with ID ${id} not found`)
|
|
31
|
-
|
|
32
|
-
return result as ManufacturerJsonResponse
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
if (error instanceof HttpError)
|
|
36
|
-
throw error
|
|
37
|
-
// Cross-dialect duplicate detection (#1957).
|
|
38
|
-
if (isUniqueViolation(error))
|
|
39
|
-
throw new HttpError(409, 'A manufacturer with this name already exists')
|
|
40
|
-
if (error instanceof Error)
|
|
41
|
-
throw new Error(`Failed to update manufacturer: ${error.message}`)
|
|
42
|
-
throw error
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Toggle the featured status of a manufacturer
|
|
48
|
-
*
|
|
49
|
-
* @param id The ID of the manufacturer
|
|
50
|
-
* @param featured The new featured status (or toggle if not provided)
|
|
51
|
-
* @returns The updated manufacturer with the new featured status
|
|
52
|
-
*/
|
|
53
|
-
export async function updateFeaturedStatus(
|
|
54
|
-
id: number,
|
|
55
|
-
featured?: boolean,
|
|
56
|
-
): Promise<ManufacturerJsonResponse> {
|
|
57
|
-
try {
|
|
58
|
-
const result = await db
|
|
59
|
-
.updateTable('manufacturers')
|
|
60
|
-
.set({
|
|
61
|
-
featured,
|
|
62
|
-
updated_at: formatDate(new Date()),
|
|
63
|
-
})
|
|
64
|
-
.where('id', '=', id)
|
|
65
|
-
.returningAll()
|
|
66
|
-
.executeTakeFirst()
|
|
67
|
-
|
|
68
|
-
if (!result)
|
|
69
|
-
throw new Error('Failed to update manufacturer featured status')
|
|
70
|
-
|
|
71
|
-
return result as ManufacturerJsonResponse
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
if (error instanceof Error) {
|
|
75
|
-
throw new TypeError(`Failed to update manufacturer featured status: ${error.message}`)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
throw error
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Update a manufacturer by UUID
|
|
84
|
-
*
|
|
85
|
-
* @param uuid The UUID of the manufacturer to update
|
|
86
|
-
* @param data The updated manufacturer data
|
|
87
|
-
* @returns The updated manufacturer record
|
|
88
|
-
*/
|
|
89
|
-
export async function updateByUuid(uuid: string, data: Omit<ManufacturerUpdate, 'id'>): Promise<ManufacturerJsonResponse> {
|
|
90
|
-
try {
|
|
91
|
-
const result = await db
|
|
92
|
-
.updateTable('manufacturers')
|
|
93
|
-
.set({
|
|
94
|
-
...data,
|
|
95
|
-
updated_at: formatDate(new Date()),
|
|
96
|
-
})
|
|
97
|
-
.where('uuid', '=', uuid)
|
|
98
|
-
.returningAll()
|
|
99
|
-
.executeTakeFirst()
|
|
100
|
-
|
|
101
|
-
if (!result)
|
|
102
|
-
throw new Error('Failed to update manufacturer')
|
|
103
|
-
|
|
104
|
-
return result as ManufacturerJsonResponse
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
if (error instanceof Error) {
|
|
108
|
-
throw new TypeError(`Failed to update manufacturer: ${error.message}`)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
throw error
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { db } from '@stacksjs/database'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Delete an order by ID
|
|
5
|
-
*
|
|
6
|
-
* @param id The ID of the order to delete
|
|
7
|
-
* @returns True if the order was deleted, false otherwise
|
|
8
|
-
*/
|
|
9
|
-
export async function destroy(id: number): Promise<boolean> {
|
|
10
|
-
try {
|
|
11
|
-
// Perform the delete operation
|
|
12
|
-
const result = await db
|
|
13
|
-
.deleteFrom('reviews')
|
|
14
|
-
.where('id', '=', id)
|
|
15
|
-
.executeTakeFirst()
|
|
16
|
-
|
|
17
|
-
// Return true if any row was affected (deleted)
|
|
18
|
-
return Number(result.numDeletedRows) > 0
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
if (error instanceof Error) {
|
|
22
|
-
throw new TypeError(`Failed to delete order: ${error.message}`)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
throw error
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Delete multiple orders by ID
|
|
31
|
-
*
|
|
32
|
-
* @param ids Array of order IDs to delete
|
|
33
|
-
* @returns Number of orders deleted
|
|
34
|
-
*/
|
|
35
|
-
export async function bulkDestroy(ids: number[]): Promise<number> {
|
|
36
|
-
if (!ids.length)
|
|
37
|
-
return 0
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
// Perform the delete operation
|
|
41
|
-
const result = await db
|
|
42
|
-
.deleteFrom('reviews')
|
|
43
|
-
.where('id', 'in', ids)
|
|
44
|
-
.executeTakeFirst()
|
|
45
|
-
|
|
46
|
-
// Return the number of deleted rows
|
|
47
|
-
return Number(result.numDeletedRows)
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
if (error instanceof Error) {
|
|
51
|
-
throw new TypeError(`Failed to delete orders: ${error.message}`)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
throw error
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
type ReviewJsonResponse = ModelRow<typeof Review>
|
|
2
|
-
import { db } from '@stacksjs/database'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Fetch a product review by ID
|
|
6
|
-
*/
|
|
7
|
-
export async function fetchById(id: number): Promise<ReviewJsonResponse | undefined> {
|
|
8
|
-
return await db
|
|
9
|
-
.selectFrom('reviews')
|
|
10
|
-
.where('id', '=', id)
|
|
11
|
-
.selectAll()
|
|
12
|
-
.executeTakeFirst()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Fetch all product reviews
|
|
17
|
-
*/
|
|
18
|
-
export async function fetchAll(): Promise<ReviewJsonResponse[]> {
|
|
19
|
-
return await db.selectFrom('reviews').selectAll().execute()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Fetch reviews for a specific product
|
|
24
|
-
*/
|
|
25
|
-
export async function fetchByProductId(productId: number): Promise<ReviewJsonResponse[]> {
|
|
26
|
-
return await db
|
|
27
|
-
.selectFrom('reviews')
|
|
28
|
-
.where('product_id', '=', productId)
|
|
29
|
-
.selectAll()
|
|
30
|
-
.execute()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Fetch reviews by user ID
|
|
35
|
-
*/
|
|
36
|
-
export async function fetchByUserId(userId: number): Promise<ReviewJsonResponse[]> {
|
|
37
|
-
return await db
|
|
38
|
-
.selectFrom('reviews')
|
|
39
|
-
.where('customer_id', '=', userId)
|
|
40
|
-
.selectAll()
|
|
41
|
-
.execute()
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Fetch approved reviews for a product
|
|
46
|
-
*/
|
|
47
|
-
export async function fetchApprovedByProductId(productId: number): Promise<ReviewJsonResponse[]> {
|
|
48
|
-
return await db
|
|
49
|
-
.selectFrom('reviews')
|
|
50
|
-
.where('product_id', '=', productId)
|
|
51
|
-
.where('is_approved', '=', true)
|
|
52
|
-
.selectAll()
|
|
53
|
-
.execute()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export async function fetchMostHelpfulByProductId(productId: number): Promise<ReviewJsonResponse[]> {
|
|
57
|
-
return await db
|
|
58
|
-
.selectFrom('reviews')
|
|
59
|
-
.where('product_id', '=', productId)
|
|
60
|
-
.orderBy('helpful_votes', 'desc')
|
|
61
|
-
.selectAll()
|
|
62
|
-
.execute()
|
|
63
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
bulkDestroy,
|
|
3
|
-
destroy,
|
|
4
|
-
} from './destroy'
|
|
5
|
-
|
|
6
|
-
// Functions from fetch.ts
|
|
7
|
-
export {
|
|
8
|
-
fetchAll,
|
|
9
|
-
fetchApprovedByProductId,
|
|
10
|
-
fetchById,
|
|
11
|
-
fetchByProductId,
|
|
12
|
-
fetchByUserId,
|
|
13
|
-
fetchMostHelpfulByProductId,
|
|
14
|
-
} from './fetch'
|
|
15
|
-
|
|
16
|
-
// Functions from store.ts
|
|
17
|
-
export {
|
|
18
|
-
store,
|
|
19
|
-
} from './store'
|
|
20
|
-
|
|
21
|
-
// Functions from update.ts
|
|
22
|
-
export {
|
|
23
|
-
update,
|
|
24
|
-
updateVotes,
|
|
25
|
-
} from './update'
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
type ReviewJsonResponse = ModelRow<typeof Review>
|
|
2
|
-
type NewReview = NewModelData<typeof Review>
|
|
3
|
-
import { randomUUIDv7 } from 'bun'
|
|
4
|
-
import { db } from '@stacksjs/database'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create a new product review
|
|
8
|
-
*
|
|
9
|
-
* @param data The review data to store
|
|
10
|
-
* @returns The newly created review record
|
|
11
|
-
*/
|
|
12
|
-
export async function store(data: NewReview): Promise<ReviewJsonResponse> {
|
|
13
|
-
try {
|
|
14
|
-
const reviewData = {
|
|
15
|
-
...data,
|
|
16
|
-
uuid: randomUUIDv7(),
|
|
17
|
-
is_verified_purchase: data.is_verified_purchase ?? false,
|
|
18
|
-
is_approved: data.is_approved ?? false,
|
|
19
|
-
helpful_votes: data.helpful_votes ?? 0,
|
|
20
|
-
unhelpful_votes: data.unhelpful_votes ?? 0,
|
|
21
|
-
is_featured: data.is_featured ?? false,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const result = await db
|
|
25
|
-
.insertInto('reviews')
|
|
26
|
-
.values(reviewData)
|
|
27
|
-
.returningAll()
|
|
28
|
-
.executeTakeFirst()
|
|
29
|
-
|
|
30
|
-
if (!result)
|
|
31
|
-
throw new Error('Failed to create review')
|
|
32
|
-
|
|
33
|
-
return result
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
if (error instanceof Error) {
|
|
37
|
-
if (error.message.includes('Duplicate entry')) {
|
|
38
|
-
throw new Error('A review with this code already exists')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
throw new Error(`Failed to create review: ${error.message}`)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
throw error
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { db } from '@stacksjs/database'
|
|
2
|
-
import { formatDate } from '@stacksjs/orm'
|
|
3
|
-
type ReviewJsonResponse = ModelRow<typeof Review>
|
|
4
|
-
type ReviewUpdate = UpdateModelData<typeof Review>
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Update a review
|
|
8
|
-
*
|
|
9
|
-
* @param id The id of the review to update
|
|
10
|
-
* @param data The review data to update
|
|
11
|
-
* @returns The updated review record
|
|
12
|
-
*/
|
|
13
|
-
export async function update(id: number, data: ReviewUpdate): Promise<ReviewJsonResponse> {
|
|
14
|
-
try {
|
|
15
|
-
if (!id)
|
|
16
|
-
throw new Error('Review ID is required for update')
|
|
17
|
-
|
|
18
|
-
const result = await db
|
|
19
|
-
.updateTable('reviews')
|
|
20
|
-
.set({
|
|
21
|
-
...data,
|
|
22
|
-
updated_at: formatDate(new Date()),
|
|
23
|
-
})
|
|
24
|
-
.where('id', '=', id)
|
|
25
|
-
.returningAll()
|
|
26
|
-
.executeTakeFirst()
|
|
27
|
-
|
|
28
|
-
if (!result)
|
|
29
|
-
throw new Error('Failed to update review')
|
|
30
|
-
|
|
31
|
-
return result
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (error instanceof Error) {
|
|
35
|
-
throw new TypeError(`Failed to update review: ${error.message}`)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
throw error
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Update a review's vote counts
|
|
44
|
-
*
|
|
45
|
-
* @param id The ID of the review
|
|
46
|
-
* @param voteType The type of vote ('helpful' or 'unhelpful')
|
|
47
|
-
* @param increment Whether to increment (true) or decrement (false) the vote count
|
|
48
|
-
* @returns The updated review with new vote counts
|
|
49
|
-
*/
|
|
50
|
-
export async function updateVotes(
|
|
51
|
-
id: number,
|
|
52
|
-
voteType: 'helpful' | 'unhelpful',
|
|
53
|
-
increment: boolean = true,
|
|
54
|
-
): Promise<ReviewJsonResponse> {
|
|
55
|
-
try {
|
|
56
|
-
const column = voteType === 'helpful' ? 'helpful_votes' : 'unhelpful_votes'
|
|
57
|
-
const expr = increment
|
|
58
|
-
? `COALESCE("${column}", 0) + 1`
|
|
59
|
-
: `MAX(COALESCE("${column}", 0) - 1, 0)`
|
|
60
|
-
|
|
61
|
-
const result = await db
|
|
62
|
-
.unsafe(
|
|
63
|
-
`UPDATE "reviews" SET "${column}" = ${expr}, "updated_at" = ? WHERE "id" = ? RETURNING *`,
|
|
64
|
-
[formatDate(new Date()), id],
|
|
65
|
-
)
|
|
66
|
-
.execute()
|
|
67
|
-
|
|
68
|
-
const row = Array.isArray(result) ? result[0] : result
|
|
69
|
-
|
|
70
|
-
if (!row)
|
|
71
|
-
throw new Error('Failed to update review votes')
|
|
72
|
-
|
|
73
|
-
return row
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
if (error instanceof Error) {
|
|
77
|
-
throw new TypeError(`Failed to update review votes: ${error.message}`)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
throw error
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { db } from '@stacksjs/database'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Delete a product unit by ID
|
|
5
|
-
*
|
|
6
|
-
* @param id The ID of the product unit to delete
|
|
7
|
-
* @returns True if the product unit was deleted, false otherwise
|
|
8
|
-
*/
|
|
9
|
-
export async function destroy(id: number): Promise<boolean> {
|
|
10
|
-
try {
|
|
11
|
-
// Perform the delete operation
|
|
12
|
-
const result = await db
|
|
13
|
-
.deleteFrom('product_units')
|
|
14
|
-
.where('id', '=', id)
|
|
15
|
-
.executeTakeFirst()
|
|
16
|
-
|
|
17
|
-
// Return true if any row was affected (deleted)
|
|
18
|
-
return Number(result.numDeletedRows) > 0
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
if (error instanceof Error) {
|
|
22
|
-
throw new TypeError(`Failed to delete product unit: ${error.message}`)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
throw error
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Delete multiple product units by ID
|
|
31
|
-
*
|
|
32
|
-
* @param ids Array of product unit IDs to delete
|
|
33
|
-
* @returns Number of product units deleted
|
|
34
|
-
*/
|
|
35
|
-
export async function bulkDestroy(ids: number[]): Promise<number> {
|
|
36
|
-
if (!ids.length)
|
|
37
|
-
return 0
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
// Perform the delete operation
|
|
41
|
-
const result = await db
|
|
42
|
-
.deleteFrom('product_units')
|
|
43
|
-
.where('id', 'in', ids)
|
|
44
|
-
.executeTakeFirst()
|
|
45
|
-
|
|
46
|
-
// Return the number of deleted rows
|
|
47
|
-
return Number(result.numDeletedRows)
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
if (error instanceof Error) {
|
|
51
|
-
throw new TypeError(`Failed to delete product units: ${error.message}`)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
throw error
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type ProductUnitJsonResponse = ModelRow<typeof ProductUnit>
|
|
2
|
-
import { db } from '@stacksjs/database'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Fetch a product unit by ID
|
|
6
|
-
*/
|
|
7
|
-
export async function fetchById(id: number): Promise<ProductUnitJsonResponse | undefined> {
|
|
8
|
-
return await db
|
|
9
|
-
.selectFrom('product_units')
|
|
10
|
-
.where('id', '=', id)
|
|
11
|
-
.selectAll()
|
|
12
|
-
.executeTakeFirst() as ProductUnitJsonResponse | undefined
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Fetch all product units
|
|
17
|
-
*/
|
|
18
|
-
export async function fetchAll(): Promise<ProductUnitJsonResponse[]> {
|
|
19
|
-
return await db.selectFrom('product_units').selectAll().execute() as ProductUnitJsonResponse[]
|
|
20
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Export all functions from the unit modules
|
|
2
|
-
|
|
3
|
-
// Destroy functions
|
|
4
|
-
export { bulkDestroy, destroy } from './destroy'
|
|
5
|
-
|
|
6
|
-
// Fetch functions
|
|
7
|
-
export { fetchAll, fetchById } from './fetch'
|
|
8
|
-
|
|
9
|
-
// Store functions
|
|
10
|
-
export { bulkStore, formatUnitOptions, getDefaultUnit, store } from './store'
|
|
11
|
-
|
|
12
|
-
// Update functions
|
|
13
|
-
export { bulkUpdate, update, updateDefaultStatus } from './update'
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
// Import dependencies
|
|
2
|
-
type ProductUnitJsonResponse = ModelRow<typeof ProductUnit>
|
|
3
|
-
type NewProductUnit = NewModelData<typeof ProductUnit>
|
|
4
|
-
import { randomUUIDv7 } from 'bun'
|
|
5
|
-
import { db } from '@stacksjs/database'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Create a new product unit
|
|
9
|
-
*
|
|
10
|
-
* @param data The product unit data to store
|
|
11
|
-
* @returns The newly created product unit record
|
|
12
|
-
*/
|
|
13
|
-
export async function store(data: NewProductUnit): Promise<ProductUnitJsonResponse> {
|
|
14
|
-
try {
|
|
15
|
-
const unitData = {
|
|
16
|
-
...data,
|
|
17
|
-
uuid: randomUUIDv7(),
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const result = await db
|
|
21
|
-
.insertInto('product_units')
|
|
22
|
-
.values(unitData)
|
|
23
|
-
.returningAll()
|
|
24
|
-
.executeTakeFirst()
|
|
25
|
-
|
|
26
|
-
if (!result)
|
|
27
|
-
throw new Error('Failed to create product unit')
|
|
28
|
-
|
|
29
|
-
// If this unit is set as default, update all other units of the same type
|
|
30
|
-
if ((unitData as Record<string, unknown>).is_default) {
|
|
31
|
-
await db
|
|
32
|
-
.updateTable('product_units')
|
|
33
|
-
.set({ is_default: false })
|
|
34
|
-
.where('type', '=', unitData.type)
|
|
35
|
-
.where('id', '!=', result.id)
|
|
36
|
-
.execute()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return result as ProductUnitJsonResponse
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
if (error instanceof Error) {
|
|
43
|
-
throw new TypeError(`Failed to create product unit: ${error.message}`)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
throw error
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create multiple product units at once
|
|
52
|
-
*
|
|
53
|
-
* @param data Array of product unit data to store
|
|
54
|
-
* @returns Number of product units created
|
|
55
|
-
*/
|
|
56
|
-
export async function bulkStore(data: NewProductUnit[]): Promise<number> {
|
|
57
|
-
if (!data.length)
|
|
58
|
-
return 0
|
|
59
|
-
|
|
60
|
-
let createdCount = 0
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
for (const unit of data) {
|
|
64
|
-
const unitData = {
|
|
65
|
-
...unit,
|
|
66
|
-
uuid: randomUUIDv7(),
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const result = await db
|
|
70
|
-
.insertInto('product_units')
|
|
71
|
-
.values(unitData)
|
|
72
|
-
.returningAll()
|
|
73
|
-
.executeTakeFirst()
|
|
74
|
-
|
|
75
|
-
// If this unit is set as default, update all other units of the same type
|
|
76
|
-
if ((unitData as Record<string, unknown>).is_default && result) {
|
|
77
|
-
await db
|
|
78
|
-
.updateTable('product_units')
|
|
79
|
-
.set({ is_default: false })
|
|
80
|
-
.where('type', '=', unitData.type)
|
|
81
|
-
.where('id', '!=', result.id)
|
|
82
|
-
.execute()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
createdCount++
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return createdCount
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
if (error instanceof Error) {
|
|
92
|
-
throw new TypeError(`Failed to create product units in bulk: ${error.message}`)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
throw error
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Format product unit options for dropdown menus or selectors
|
|
101
|
-
*
|
|
102
|
-
* @param type Optional filter by unit type
|
|
103
|
-
* @returns Array of formatted unit options with id, name, and abbreviation
|
|
104
|
-
*/
|
|
105
|
-
export function formatUnitOptions(
|
|
106
|
-
type?: string,
|
|
107
|
-
): Promise<{ id: string, name: string, abbreviation: string, is_default: boolean | undefined }[] | []> {
|
|
108
|
-
try {
|
|
109
|
-
let query = db
|
|
110
|
-
.selectFrom('product_units')
|
|
111
|
-
.select(['id', 'name', 'abbreviation', 'is_default'] as any) as any
|
|
112
|
-
|
|
113
|
-
// Filter by type if provided
|
|
114
|
-
if (type)
|
|
115
|
-
query = query.where('type', '=', type)
|
|
116
|
-
|
|
117
|
-
query = query.orderBy('name')
|
|
118
|
-
|
|
119
|
-
// Convert db results to ensure id is string and handle potentially undefined is_default
|
|
120
|
-
return query.execute().then((results: any) =>
|
|
121
|
-
results.map((result: any) => ({
|
|
122
|
-
id: String(result.id), // Convert id to string
|
|
123
|
-
name: result.name,
|
|
124
|
-
abbreviation: result.abbreviation,
|
|
125
|
-
is_default: result.is_default,
|
|
126
|
-
})),
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
if (error instanceof Error) {
|
|
131
|
-
throw new TypeError(`Failed to format unit options: ${error.message}`)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
throw error
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Get the default unit for a specific type
|
|
140
|
-
*
|
|
141
|
-
* @param type The unit type to get the default for
|
|
142
|
-
* @returns The default unit or undefined if none found
|
|
143
|
-
*/
|
|
144
|
-
export async function getDefaultUnit(type: string): Promise<ProductUnitJsonResponse | undefined> {
|
|
145
|
-
try {
|
|
146
|
-
const defaultUnit = await db
|
|
147
|
-
.selectFrom('product_units')
|
|
148
|
-
.selectAll()
|
|
149
|
-
.where('type', '=', type)
|
|
150
|
-
.where('is_default', '=', true)
|
|
151
|
-
.executeTakeFirst()
|
|
152
|
-
|
|
153
|
-
return defaultUnit as ProductUnitJsonResponse | undefined
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
if (error instanceof Error) {
|
|
157
|
-
throw new TypeError(`Failed to get default unit: ${error.message}`)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
throw error
|
|
161
|
-
}
|
|
162
|
-
}
|