@stacksjs/commerce 0.70.88 → 0.70.90

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.
Files changed (134) hide show
  1. package/dist/coupons/destroy.d.ts +17 -0
  2. package/dist/coupons/fetch.d.ts +59 -0
  3. package/dist/coupons/index.d.ts +27 -0
  4. package/dist/coupons/store.d.ts +9 -0
  5. package/dist/coupons/update.d.ts +46 -0
  6. package/dist/customers/destroy.d.ts +14 -0
  7. package/dist/customers/fetch.d.ts +9 -0
  8. package/dist/customers/index.d.ts +14 -0
  9. package/dist/customers/store.d.ts +9 -0
  10. package/dist/customers/update.d.ts +10 -0
  11. package/dist/devices/destroy.d.ts +14 -0
  12. package/dist/devices/export.d.ts +35 -0
  13. package/dist/devices/fetch.d.ts +38 -0
  14. package/dist/devices/index.d.ts +27 -0
  15. package/dist/devices/store.d.ts +16 -0
  16. package/dist/devices/update.d.ts +26 -0
  17. package/dist/errors/destroy.d.ts +12 -0
  18. package/dist/errors/fetch.d.ts +54 -0
  19. package/dist/errors/index.d.ts +25 -0
  20. package/dist/errors/update.d.ts +24 -0
  21. package/dist/gift-cards/destroy.d.ts +23 -0
  22. package/dist/gift-cards/fetch.d.ts +88 -0
  23. package/dist/gift-cards/index.d.ts +23 -0
  24. package/dist/gift-cards/store.d.ts +9 -0
  25. package/dist/gift-cards/update.d.ts +30 -0
  26. package/dist/index.d.ts +58 -0
  27. package/dist/index.js +2 -0
  28. package/dist/orders/destroy.d.ts +28 -0
  29. package/dist/orders/events.d.ts +46 -0
  30. package/dist/orders/export.d.ts +32 -0
  31. package/dist/orders/fetch.d.ts +76 -0
  32. package/dist/orders/guards.d.ts +93 -0
  33. package/dist/orders/index.d.ts +82 -0
  34. package/dist/orders/place-order.d.ts +18 -0
  35. package/dist/orders/store.d.ts +9 -0
  36. package/dist/orders/totals.d.ts +24 -0
  37. package/dist/orders/update.d.ts +28 -0
  38. package/dist/orders/webhook.d.ts +31 -0
  39. package/dist/payments/destroy.d.ts +14 -0
  40. package/dist/payments/fetch.d.ts +55 -0
  41. package/dist/payments/index.d.ts +13 -0
  42. package/dist/payments/store.d.ts +9 -0
  43. package/dist/payments/update.d.ts +18 -0
  44. package/dist/products/categories/destroy.d.ts +30 -0
  45. package/dist/products/categories/fetch.d.ts +49 -0
  46. package/dist/products/categories/index.d.ts +33 -0
  47. package/dist/products/categories/store.d.ts +21 -0
  48. package/dist/products/categories/update.d.ts +33 -0
  49. package/dist/products/index.d.ts +24 -0
  50. package/dist/products/items/destroy.d.ts +14 -0
  51. package/dist/products/items/fetch.d.ts +66 -0
  52. package/dist/products/items/index.d.ts +23 -0
  53. package/dist/products/items/store.d.ts +16 -0
  54. package/dist/products/items/update.d.ts +82 -0
  55. package/dist/products/manufacturers/destroy.d.ts +14 -0
  56. package/dist/products/manufacturers/fetch.d.ts +23 -0
  57. package/dist/products/manufacturers/index.d.ts +21 -0
  58. package/dist/products/manufacturers/store.d.ts +16 -0
  59. package/dist/products/manufacturers/update.d.ts +26 -0
  60. package/dist/products/reviews/destroy.d.ts +14 -0
  61. package/dist/products/reviews/fetch.d.ts +22 -0
  62. package/dist/products/reviews/index.d.ts +22 -0
  63. package/dist/products/reviews/store.d.ts +16 -0
  64. package/dist/products/reviews/update.d.ts +19 -0
  65. package/dist/products/units/destroy.d.ts +14 -0
  66. package/dist/products/units/fetch.d.ts +9 -0
  67. package/dist/products/units/index.d.ts +9 -0
  68. package/dist/products/units/store.d.ts +31 -0
  69. package/dist/products/units/update.d.ts +25 -0
  70. package/dist/products/variants/destroy.d.ts +14 -0
  71. package/dist/products/variants/fetch.d.ts +9 -0
  72. package/dist/products/variants/index.d.ts +18 -0
  73. package/dist/products/variants/store.d.ts +43 -0
  74. package/dist/products/variants/update.d.ts +25 -0
  75. package/dist/receipts/destroy.d.ts +14 -0
  76. package/dist/receipts/fetch.d.ts +80 -0
  77. package/dist/receipts/index.d.ts +21 -0
  78. package/dist/receipts/store.d.ts +16 -0
  79. package/dist/receipts/update.d.ts +28 -0
  80. package/dist/shippings/delivery-routes/destroy.d.ts +14 -0
  81. package/dist/shippings/delivery-routes/fetch.d.ts +17 -0
  82. package/dist/shippings/delivery-routes/index.d.ts +23 -0
  83. package/dist/shippings/delivery-routes/store.d.ts +16 -0
  84. package/dist/shippings/delivery-routes/update.d.ts +27 -0
  85. package/dist/shippings/digital-deliveries/destroy.d.ts +28 -0
  86. package/dist/shippings/digital-deliveries/fetch.d.ts +9 -0
  87. package/dist/shippings/digital-deliveries/index.d.ts +23 -0
  88. package/dist/shippings/digital-deliveries/store.d.ts +16 -0
  89. package/dist/shippings/digital-deliveries/update.d.ts +29 -0
  90. package/dist/shippings/drivers/destroy.d.ts +16 -0
  91. package/dist/shippings/drivers/fetch.d.ts +9 -0
  92. package/dist/shippings/drivers/index.d.ts +21 -0
  93. package/dist/shippings/drivers/store.d.ts +16 -0
  94. package/dist/shippings/drivers/update.d.ts +26 -0
  95. package/dist/shippings/index.d.ts +27 -0
  96. package/dist/shippings/license-keys/destroy.d.ts +28 -0
  97. package/dist/shippings/license-keys/fetch.d.ts +9 -0
  98. package/dist/shippings/license-keys/index.d.ts +23 -0
  99. package/dist/shippings/license-keys/store.d.ts +17 -0
  100. package/dist/shippings/license-keys/update.d.ts +26 -0
  101. package/dist/shippings/shipping-methods/destroy.d.ts +28 -0
  102. package/dist/shippings/shipping-methods/fetch.d.ts +9 -0
  103. package/dist/shippings/shipping-methods/index.d.ts +25 -0
  104. package/dist/shippings/shipping-methods/store.d.ts +28 -0
  105. package/dist/shippings/shipping-methods/update.d.ts +27 -0
  106. package/dist/shippings/shipping-rates/destroy.d.ts +28 -0
  107. package/dist/shippings/shipping-rates/fetch.d.ts +98 -0
  108. package/dist/shippings/shipping-rates/index.d.ts +33 -0
  109. package/dist/shippings/shipping-rates/store.d.ts +17 -0
  110. package/dist/shippings/shipping-rates/update.d.ts +36 -0
  111. package/dist/shippings/shipping-zones/destroy.d.ts +28 -0
  112. package/dist/shippings/shipping-zones/fetch.d.ts +28 -0
  113. package/dist/shippings/shipping-zones/index.d.ts +23 -0
  114. package/dist/shippings/shipping-zones/store.d.ts +17 -0
  115. package/dist/shippings/shipping-zones/update.d.ts +35 -0
  116. package/dist/tax/destroy.d.ts +14 -0
  117. package/dist/tax/fetch.d.ts +9 -0
  118. package/dist/tax/index.d.ts +21 -0
  119. package/dist/tax/store.d.ts +16 -0
  120. package/dist/tax/update.d.ts +26 -0
  121. package/dist/types.d.ts +265 -0
  122. package/dist/utils/typed-stats.d.ts +23 -0
  123. package/dist/waitlists/index.d.ts +12 -0
  124. package/dist/waitlists/products/destroy.d.ts +15 -0
  125. package/dist/waitlists/products/fetch.d.ts +100 -0
  126. package/dist/waitlists/products/index.d.ts +30 -0
  127. package/dist/waitlists/products/store.d.ts +16 -0
  128. package/dist/waitlists/products/update.d.ts +26 -0
  129. package/dist/waitlists/restaurant/destroy.d.ts +15 -0
  130. package/dist/waitlists/restaurant/fetch.d.ts +149 -0
  131. package/dist/waitlists/restaurant/index.d.ts +40 -0
  132. package/dist/waitlists/restaurant/store.d.ts +16 -0
  133. package/dist/waitlists/restaurant/update.d.ts +43 -0
  134. package/package.json +1 -1
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Delete a coupon by ID
3
+ * @param id The ID of the coupon to delete
4
+ * @returns A boolean indicating success
5
+ */
6
+ export declare function deleteCoupon(id: number): Promise<boolean>;
7
+ /**
8
+ * Delete multiple coupons by IDs
9
+ * @param ids Array of coupon IDs to delete
10
+ * @returns Number of deleted coupons
11
+ */
12
+ export declare function deleteCoupons(ids: number[]): Promise<number>;
13
+ /**
14
+ * Delete expired coupons
15
+ * @returns The number of deleted coupons
16
+ */
17
+ export declare function deleteExpiredCoupons(): Promise<number>;
@@ -0,0 +1,59 @@
1
+ import type { CouponCountStats, CouponRedemptionStats, CouponStats, CouponTimeStats } from '../types';
2
+ /**
3
+ * Fetch all coupons from the database
4
+ */
5
+ export declare function fetchAll(): Promise<CouponJsonResponse[]>;
6
+ /**
7
+ * Fetch a coupon by ID
8
+ */
9
+ export declare function fetchById(id: number): Promise<CouponJsonResponse | undefined>;
10
+ /**
11
+ * Fetch a coupon by code
12
+ */
13
+ export declare function fetchByCode(code: string): Promise<CouponJsonResponse | undefined>;
14
+ /**
15
+ * Fetch active coupons (is_active = true and within date range)
16
+ */
17
+ export declare function fetchActive(): Promise<CouponJsonResponse[]>;
18
+ /**
19
+ * Get coupon statistics
20
+ */
21
+ export declare function fetchStats(): Promise<CouponStats>;
22
+ /**
23
+ * Get count of active and inactive coupons for different time periods
24
+ */
25
+ export declare function fetchCouponCounts(): Promise<CouponTimeStats>;
26
+ /**
27
+ * Get detailed breakdown of active/inactive coupons by discount type
28
+ */
29
+ export declare function fetchCouponCountsByType(): Promise<Record<string, CouponCountStats>>;
30
+ /**
31
+ * Fetch coupon redemption statistics based on usage_count
32
+ */
33
+ export declare function fetchRedemptionStats(): Promise<CouponRedemptionStats>;
34
+ /**
35
+ * Get top redeemed coupons
36
+ */
37
+ export declare function fetchTopRedeemedCoupons(limit?: number): Promise<any[]>;
38
+ /**
39
+ * Get redemption trend data in a simplified manner
40
+ */
41
+ export declare function fetchRedemptionTrend(days?: number): Promise<any[]>;
42
+ /**
43
+ * Get conversion rate (number of redemptions / number of active coupons)
44
+ */
45
+ export declare function fetchConversionRate(): Promise<{
46
+ rate: number
47
+ total_active: number
48
+ total_redeemed: number
49
+ }>;
50
+ /**
51
+ * Calculate the month-over-month change in active coupons
52
+ */
53
+ export declare function getActiveCouponsMoMChange(): Promise<{
54
+ current_month: number
55
+ previous_month: number
56
+ difference: number
57
+ percentage_change: number
58
+ }>;
59
+ declare type CouponJsonResponse = ModelRow<typeof Coupon>;
@@ -0,0 +1,27 @@
1
+ export type { CouponRedemptionResult } from './update';
2
+ export {
3
+ deleteCoupon,
4
+ deleteCoupons,
5
+ deleteExpiredCoupons,
6
+ } from './destroy';
7
+ export {
8
+ fetchActive,
9
+ fetchAll,
10
+ fetchByCode,
11
+ fetchById,
12
+ fetchConversionRate,
13
+ fetchCouponCounts,
14
+ fetchCouponCountsByType,
15
+ fetchRedemptionStats,
16
+ fetchRedemptionTrend,
17
+ fetchStats,
18
+ fetchTopRedeemedCoupons,
19
+ getActiveCouponsMoMChange,
20
+ } from './fetch';
21
+ export {
22
+ store,
23
+ } from './store';
24
+ export {
25
+ redeem,
26
+ update,
27
+ } from './update';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Create a new coupon
3
+ *
4
+ * @param data The coupon data to store
5
+ * @returns The newly created coupon record
6
+ */
7
+ export declare function store(data: NewCoupon): Promise<CouponJsonResponse | undefined>;
8
+ declare type CouponJsonResponse = ModelRow<typeof Coupon>;
9
+ declare type NewCoupon = NewModelData<typeof Coupon>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Update a coupon by ID
3
+ *
4
+ * @param id The ID of the coupon to update
5
+ * @param data The updated coupon data
6
+ * @returns The updated coupon record
7
+ */
8
+ export declare function update(id: number, data: Omit<CouponUpdate, 'id'>): Promise<CouponJsonResponse | undefined>;
9
+ /**
10
+ * Atomically redeem a coupon (stacksjs/stacks#1879 Co-5).
11
+ *
12
+ * Pre-fix: callers fetched the coupon, checked `usage_count <
13
+ * max_uses`, then bumped `usage_count` via `update()`. Two concurrent
14
+ * redemption requests against a coupon with `max_uses=1` both saw
15
+ * `usage_count=0`, both incremented, both succeeded. The coupon
16
+ * was redeemed twice — direct revenue loss equal to `discount_value`
17
+ * times the over-redemption count.
18
+ *
19
+ * Post-fix: single conditional UPDATE that bumps `usage_count` and
20
+ * enforces `max_uses` / `is_active` / expiry in the WHERE clause.
21
+ * The database guarantees only one writer wins the race. Returns a
22
+ * discriminated result so callers can surface a useful reason
23
+ * ("limit reached" vs "expired" vs "inactive") instead of a generic
24
+ * failure.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const result = await redeem(couponId)
29
+ * if (!result.ok) {
30
+ * throw new HttpError(400, `Coupon cannot be redeemed: ${result.reason}`)
31
+ * }
32
+ * // Use result.coupon — it reflects the post-redemption state.
33
+ * ```
34
+ */
35
+ export declare function redeem(id: number): Promise<CouponRedemptionResult>;
36
+ declare type CouponJsonResponse = ModelRow<typeof Coupon>;
37
+ declare type CouponUpdate = UpdateModelData<typeof Coupon>;
38
+ /**
39
+ * Discriminated result for `redeem` — `ok: true` on a successful
40
+ * atomic redemption (the row's `usage_count` was bumped and the
41
+ * limit wasn't already hit); `ok: false` with a `reason` when the
42
+ * redemption failed (out of uses, expired, inactive, missing).
43
+ * Callers branch on `reason` to surface a useful error to the user.
44
+ */
45
+ export type CouponRedemptionResult = | { ok: true, coupon: CouponJsonResponse }
46
+ | { ok: false, reason: 'not-found' | 'inactive' | 'expired' | 'limit-reached' }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Delete a customer by ID
3
+ *
4
+ * @param id The ID of the customer to delete
5
+ * @returns True if the deletion was successful, false otherwise
6
+ */
7
+ export declare function destroy(id: number): Promise<boolean>;
8
+ /**
9
+ * Bulk delete multiple customers
10
+ *
11
+ * @param ids Array of customer IDs to delete
12
+ * @returns Number of customers successfully deleted
13
+ */
14
+ export declare function bulkDestroy(ids: number[]): Promise<number>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Fetch a customer by ID
3
+ */
4
+ export declare function fetchById(id: number): Promise<CustomerJsonResponse | undefined>;
5
+ /**
6
+ * Fetch all customers
7
+ */
8
+ export declare function fetchAll(): Promise<CustomerJsonResponse[]>;
9
+ declare type CustomerJsonResponse = ModelRow<typeof Customer>;
@@ -0,0 +1,14 @@
1
+ export {
2
+ bulkDestroy,
3
+ destroy,
4
+ } from './destroy';
5
+ export {
6
+ fetchAll,
7
+ fetchById,
8
+ } from './fetch';
9
+ export {
10
+ store,
11
+ } from './store';
12
+ export {
13
+ update,
14
+ } from './update';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Create a new customer
3
+ *
4
+ * @param data The customer data to store
5
+ * @returns The newly created customer record
6
+ */
7
+ export declare function store(data: NewCustomer): Promise<CustomerJsonResponse>;
8
+ declare type CustomerJsonResponse = ModelRow<typeof Customer>;
9
+ declare type NewCustomer = NewModelData<typeof Customer>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Update a customer
3
+ *
4
+ * @param id The ID of the customer to update
5
+ * @param data The customer data to update
6
+ * @returns The updated customer record
7
+ */
8
+ export declare function update(id: number, data: Omit<CustomerUpdate, 'id'>): Promise<CustomerJsonResponse>;
9
+ declare type CustomerJsonResponse = ModelRow<typeof Customer>;
10
+ declare type CustomerUpdate = UpdateModelData<typeof Customer>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Delete a print device by ID
3
+ *
4
+ * @param id The ID of the print device to delete
5
+ * @returns True if the print device was deleted, false otherwise
6
+ */
7
+ export declare function destroy(id: number): Promise<boolean>;
8
+ /**
9
+ * Delete multiple print devices by ID
10
+ *
11
+ * @param ids Array of print device IDs to delete
12
+ * @returns Number of print devices deleted
13
+ */
14
+ export declare function bulkDestroy(ids: number[]): Promise<number>;
@@ -0,0 +1,35 @@
1
+ import type { SpreadsheetWrapper } from 'ts-spreadsheets';
2
+ /**
3
+ * Export print devices to a spreadsheet
4
+ * @param format The format of the spreadsheet (default is CSV)
5
+ * @returns Spreadsheet object ready for download or storage
6
+ */
7
+ export declare function exportPrintDevices(format?: 'csv' | 'excel'): Promise<SpreadsheetWrapper>;
8
+ /**
9
+ * Export print devices and automatically download
10
+ * @param format The format of the spreadsheet (default is CSV)
11
+ * @param filename Optional filename for the download
12
+ * @returns Download response
13
+ */
14
+ export declare function downloadPrintDevices(format?: 'csv' | 'excel', filename?: string): Promise<Response>;
15
+ /**
16
+ * Store print devices export to disk
17
+ * @param format The format of the spreadsheet (default is CSV)
18
+ * @param path Optional path to store the file
19
+ * @returns Path where the file is stored
20
+ */
21
+ export declare function storePrintDevicesExport(format?: 'csv' | 'excel', path?: string): Promise<void>;
22
+ /**
23
+ * Represents the structure of an exported print device
24
+ */
25
+ export declare interface ExportedPrintDevice {
26
+ 'Device ID': number
27
+ 'Name': string
28
+ 'MAC Address': string
29
+ 'Location': string
30
+ 'Terminal': string
31
+ 'Status': string
32
+ 'Last Ping': string
33
+ 'Print Count': number
34
+ }
35
+ declare type PrintDeviceJsonResponse = ModelRow<typeof PrintDevice>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Fetch a print device by ID
3
+ */
4
+ export declare function fetchById(id: number): Promise<PrintDeviceJsonResponse | undefined>;
5
+ /**
6
+ * Fetch all print devices
7
+ */
8
+ export declare function fetchAll(): Promise<PrintDeviceJsonResponse[]>;
9
+ /**
10
+ * Count all print devices
11
+ */
12
+ export declare function countAll(): Promise<number>;
13
+ /**
14
+ * Count total prints across all print devices from receipts
15
+ */
16
+ export declare function countTotalPrints(): Promise<number>;
17
+ /**
18
+ * Count total prints for a specific print device from receipts
19
+ */
20
+ export declare function countPrintsByDeviceId(printDeviceId: number): Promise<number>;
21
+ /**
22
+ * Calculate error rate percentage based on receipts
23
+ */
24
+ export declare function calculateErrorRate(): Promise<number>;
25
+ /**
26
+ * Fetch all errors from receipts for a specific print device
27
+ */
28
+ export declare function fetchErrorsByDeviceId(printDeviceId: number): Promise<ReceiptJsonResponse[]>;
29
+ /**
30
+ * Calculate printer health percentage based on online status
31
+ */
32
+ export declare function calculatePrinterHealth(): Promise<number>;
33
+ /**
34
+ * Get printer counts by status for visualization
35
+ */
36
+ export declare function getPrinterStatusCounts(): Promise<Record<string, number>>;
37
+ declare type PrintDeviceJsonResponse = ModelRow<typeof PrintDevice>;
38
+ declare type ReceiptJsonResponse = ModelRow<typeof Receipt>;
@@ -0,0 +1,27 @@
1
+ // Functions from destroy.ts
2
+ export {
3
+ bulkDestroy,
4
+ destroy,
5
+ } from './destroy';
6
+ // Functions from export.ts
7
+ export {
8
+ downloadPrintDevices,
9
+ exportPrintDevices,
10
+ storePrintDevicesExport,
11
+ } from './export';
12
+ // Functions from fetch.ts
13
+ export {
14
+ fetchAll,
15
+ fetchById,
16
+ } from './fetch';
17
+ // Functions from store.ts
18
+ export {
19
+ bulkStore,
20
+ store,
21
+ } from './store';
22
+ // Functions from update.ts
23
+ export {
24
+ update,
25
+ updatePrintCount,
26
+ updateStatus,
27
+ } from './update';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Create a new print device
3
+ *
4
+ * @param data Print device data to store
5
+ * @returns The newly created print device record
6
+ */
7
+ export declare function store(data: NewPrintDevice): Promise<PrintDeviceJsonResponse | undefined>;
8
+ /**
9
+ * Create multiple print devices at once
10
+ *
11
+ * @param data Array of print device data to store
12
+ * @returns Number of print devices created
13
+ */
14
+ export declare function bulkStore(data: NewPrintDevice[]): Promise<number>;
15
+ declare type PrintDeviceJsonResponse = ModelRow<typeof PrintDevice>;
16
+ declare type NewPrintDevice = NewModelData<typeof PrintDevice>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Update a print device by ID
3
+ *
4
+ * @param id The ID of the print device to update
5
+ * @param data The updated print device data
6
+ * @returns The updated print device record
7
+ */
8
+ export declare function update(id: number, data: Omit<PrintDeviceUpdate, 'id'>): Promise<PrintDeviceJsonResponse | undefined>;
9
+ /**
10
+ * Update a print device's status
11
+ *
12
+ * @param id The ID of the print device
13
+ * @param status The new status
14
+ * @returns The updated print device with the new status
15
+ */
16
+ export declare function updateStatus(id: number, status: 'online' | 'offline' | 'warning'): Promise<PrintDeviceJsonResponse | undefined>;
17
+ /**
18
+ * Update print count for a print device
19
+ *
20
+ * @param id The ID of the print device
21
+ * @param printCount The updated print count value
22
+ * @returns The updated print device
23
+ */
24
+ export declare function updatePrintCount(id: number, printCount?: number): Promise<PrintDeviceJsonResponse | undefined>;
25
+ declare type PrintDeviceJsonResponse = ModelRow<typeof PrintDevice>;
26
+ declare type PrintDeviceUpdate = UpdateModelData<typeof PrintDevice>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Delete a single error by ID
3
+ */
4
+ export declare function destroy(id: number): Promise<boolean>;
5
+ /**
6
+ * Delete multiple errors by IDs
7
+ */
8
+ export declare function bulkDestroy(ids: number[]): Promise<boolean>;
9
+ /**
10
+ * Delete all errors in a group (by type and message)
11
+ */
12
+ export declare function destroyGroup(type: string, message: string): Promise<boolean>;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Fetch a single error by ID
3
+ */
4
+ export declare function fetchById(id: number): Promise<ErrorRecord | undefined>;
5
+ /**
6
+ * Fetch all errors (raw, ungrouped)
7
+ */
8
+ export declare function fetchAll(): Promise<ErrorRecord[]>;
9
+ /**
10
+ * Fetch errors grouped by type and message (Sentry-like behavior)
11
+ * Same errors are aggregated instead of creating duplicate entries
12
+ */
13
+ export declare function fetchGrouped(): Promise<GroupedError[]>;
14
+ /**
15
+ * Fetch errors for a specific group (by type and message)
16
+ */
17
+ export declare function fetchByGroup(type: string, message: string): Promise<ErrorRecord[]>;
18
+ /**
19
+ * Fetch error statistics
20
+ */
21
+ export declare function fetchStats(): Promise<ErrorStats>;
22
+ /**
23
+ * Fetch error timeline (hourly counts for the last 24 hours)
24
+ */
25
+ export declare function fetchTimeline(): Promise<{ hour: string, count: number }[]>;
26
+ export declare interface ErrorRecord {
27
+ id: number
28
+ type: string
29
+ message: string
30
+ stack: string | null
31
+ status: number | null
32
+ additional_info: string | null
33
+ created_at: string
34
+ updated_at: string | null
35
+ }
36
+ export declare interface GroupedError {
37
+ id: number
38
+ type: string
39
+ message: string
40
+ stack: string | null
41
+ status: string
42
+ count: number
43
+ first_seen: string
44
+ last_seen: string
45
+ error_ids: number[]
46
+ }
47
+ export declare interface ErrorStats {
48
+ total: number
49
+ unresolved: number
50
+ resolved: number
51
+ ignored: number
52
+ last_24h: number
53
+ trend: number
54
+ }
@@ -0,0 +1,25 @@
1
+ export type {
2
+ ErrorRecord,
3
+ ErrorStats,
4
+ GroupedError,
5
+ } from './fetch';
6
+ export {
7
+ bulkDestroy,
8
+ destroy,
9
+ destroyGroup,
10
+ } from './destroy';
11
+ export {
12
+ fetchAll,
13
+ fetchByGroup,
14
+ fetchById,
15
+ fetchGrouped,
16
+ fetchStats,
17
+ fetchTimeline,
18
+ } from './fetch';
19
+ export {
20
+ bulkUpdateStatus,
21
+ ignoreGroup,
22
+ resolveGroup,
23
+ unresolveGroup,
24
+ update,
25
+ } from './update';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Update a single error by ID
3
+ */
4
+ export declare function update(id: number, data: UpdateErrorData): Promise<boolean>;
5
+ /**
6
+ * Update multiple errors by IDs (for bulk status updates on grouped errors)
7
+ */
8
+ export declare function bulkUpdateStatus(ids: number[], status: number): Promise<boolean>;
9
+ /**
10
+ * Resolve a grouped error (sets status = 1 for all errors in the group)
11
+ */
12
+ export declare function resolveGroup(type: string, message: string): Promise<boolean>;
13
+ /**
14
+ * Ignore a grouped error (sets status = 2 for all errors in the group)
15
+ */
16
+ export declare function ignoreGroup(type: string, message: string): Promise<boolean>;
17
+ /**
18
+ * Unresolve a grouped error (sets status = 0 for all errors in the group)
19
+ */
20
+ export declare function unresolveGroup(type: string, message: string): Promise<boolean>;
21
+ export declare interface UpdateErrorData {
22
+ status?: number
23
+ additional_info?: string
24
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Delete a gift card by ID
3
+ * @param id The ID of the gift card to delete
4
+ * @returns A boolean indicating whether the deletion was successful
5
+ */
6
+ export declare function destroy(id: number): Promise<boolean>;
7
+ /**
8
+ * Bulk delete multiple gift cards
9
+ * @param ids Array of gift card IDs to delete
10
+ * @returns Number of gift cards successfully deleted
11
+ */
12
+ export declare function bulkDestroy(ids: number[]): Promise<number>;
13
+ /**
14
+ * Delete expired gift cards
15
+ * @returns Number of gift cards deleted
16
+ */
17
+ export declare function destroyExpired(): Promise<number>;
18
+ /**
19
+ * Deactivate a gift card (set is_active to false)
20
+ * @param id The ID of the gift card to deactivate
21
+ * @returns A boolean indicating whether the deactivation was successful
22
+ */
23
+ export declare function deactivate(id: number): Promise<boolean>;
@@ -0,0 +1,88 @@
1
+ import type { GiftCardStats } from '../types';
2
+ /**
3
+ * Fetch all gift cards from the database
4
+ */
5
+ export declare function fetchAll(): Promise<GiftCardJsonResponse[]>;
6
+ /**
7
+ * Fetch a gift card by ID
8
+ */
9
+ export declare function fetchById(id: number): Promise<GiftCardJsonResponse | undefined>;
10
+ /**
11
+ * Fetch a gift card by code
12
+ */
13
+ export declare function fetchByCode(code: string): Promise<GiftCardJsonResponse | undefined>;
14
+ /**
15
+ * Fetch active gift cards (is_active = true and not expired)
16
+ */
17
+ export declare function fetchActive(): Promise<GiftCardJsonResponse[]>;
18
+ /**
19
+ * Get gift card statistics
20
+ */
21
+ export declare function fetchStats(): Promise<GiftCardStats>;
22
+ /**
23
+ * Check gift card balance by code
24
+ */
25
+ export declare function checkBalance(code: string): Promise<{ valid: boolean, balance?: number, currency?: string, message?: string }>;
26
+ /**
27
+ * Compare active gift cards between different time periods
28
+ * @param daysRange Number of days to look back (7, 30, 60, etc.)
29
+ */
30
+ export declare function compareActiveGiftCards(_daysRange?: number): Promise<{
31
+ current_period: number
32
+ previous_period: number
33
+ difference: number
34
+ percentage_change: number
35
+ days_range: number
36
+ }>;
37
+ /**
38
+ * Calculate gift card balances and initial values for different time periods
39
+ * with clear increase/decrease indicators
40
+ * @param daysRange Number of days to look back (7, 30, 60, etc.)
41
+ */
42
+ export declare function calculateGiftCardValues(_daysRange?: number): Promise<{
43
+ current_period: {
44
+ total_initial_value: number
45
+ total_remaining_balance: number
46
+ utilization_rate: number
47
+ card_count: number
48
+ average_initial_value: number
49
+ average_remaining_balance: number
50
+ }
51
+ previous_period: {
52
+ total_initial_value: number
53
+ total_remaining_balance: number
54
+ utilization_rate: number
55
+ card_count: number
56
+ }
57
+ comparison: {
58
+ initial_value: {
59
+ difference: number
60
+ percentage: number
61
+ is_increase: boolean
62
+ }
63
+ balance: {
64
+ difference: number
65
+ percentage: number
66
+ is_increase: boolean
67
+ }
68
+ card_count: {
69
+ difference: number
70
+ percentage: number
71
+ is_increase: boolean
72
+ }
73
+ }
74
+ days_range: number
75
+ }>;
76
+ /**
77
+ * Get total value of all gift cards
78
+ */
79
+ export declare function fetchTotalValue(): Promise<{
80
+ total_value: number
81
+ }>;
82
+ /**
83
+ * Get total current balance of all gift cards
84
+ */
85
+ export declare function fetchTotalCurrentBalance(): Promise<{
86
+ total_balance: number
87
+ }>;
88
+ declare type GiftCardJsonResponse = ModelRow<typeof GiftCard>;
@@ -0,0 +1,23 @@
1
+ export {
2
+ bulkDestroy,
3
+ destroy,
4
+ } from './destroy';
5
+ export {
6
+ calculateGiftCardValues,
7
+ checkBalance,
8
+ compareActiveGiftCards,
9
+ fetchActive,
10
+ fetchAll,
11
+ fetchByCode,
12
+ fetchById,
13
+ fetchStats,
14
+ fetchTotalCurrentBalance,
15
+ fetchTotalValue,
16
+ } from './fetch';
17
+ export {
18
+ store,
19
+ } from './store';
20
+ export {
21
+ update,
22
+ updateBalance,
23
+ } from './update';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Create a new gift card
3
+ *
4
+ * @param data The gift card data to store
5
+ * @returns The newly created gift card record
6
+ */
7
+ export declare function store(data: NewGiftCard): Promise<GiftCardJsonResponse | undefined>;
8
+ declare type GiftCardJsonResponse = ModelRow<typeof GiftCard>;
9
+ declare type NewGiftCard = NewModelData<typeof GiftCard>;