@sixtyninecommerce/admin 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4598 -128
- package/dist/catalog/assets.d.ts +120 -8
- package/dist/catalog/assets.js +98 -12
- package/dist/catalog/collections.d.ts +279 -14
- package/dist/catalog/collections.js +246 -15
- package/dist/catalog/index.d.ts +9 -2
- package/dist/catalog/index.js +4 -0
- package/dist/catalog/products.d.ts +318 -17
- package/dist/catalog/products.js +182 -14
- package/dist/catalog/properties.d.ts +102 -14
- package/dist/catalog/properties.js +13 -0
- package/dist/catalog/recommendations.d.ts +261 -0
- package/dist/catalog/recommendations.js +145 -0
- package/dist/catalog/reviews.d.ts +368 -0
- package/dist/catalog/reviews.js +318 -0
- package/dist/catalog/types.d.ts +17 -1
- package/dist/catalog/types.js +10 -0
- package/dist/catalog/variant-find.d.ts +136 -0
- package/dist/catalog/variant-find.js +239 -0
- package/dist/catalog/variants.d.ts +282 -25
- package/dist/catalog/variants.js +173 -25
- package/dist/catalog/visibility.d.ts +20 -5
- package/dist/catalog/visibility.js +19 -1
- package/dist/client.d.ts +116 -9
- package/dist/client.js +41 -7
- package/dist/content/assets.d.ts +286 -0
- package/dist/content/assets.js +181 -0
- package/dist/content/items.d.ts +269 -0
- package/dist/content/items.js +170 -0
- package/dist/content/types.d.ts +282 -0
- package/dist/content/types.js +100 -0
- package/dist/customers/age-verification.d.ts +66 -0
- package/dist/customers/age-verification.js +79 -0
- package/dist/customers/credit.d.ts +263 -0
- package/dist/customers/credit.js +244 -0
- package/dist/customers/delivery-preferences.d.ts +120 -0
- package/dist/customers/delivery-preferences.js +97 -0
- package/dist/customers/groups.d.ts +207 -0
- package/dist/customers/groups.js +438 -0
- package/dist/customers/index.d.ts +447 -37
- package/dist/customers/index.js +313 -40
- package/dist/customers/invitation-status.d.ts +57 -0
- package/dist/customers/invitation-status.js +21 -0
- package/dist/customers/notes.d.ts +67 -0
- package/dist/customers/notes.js +51 -0
- package/dist/customers/notification-recipients.d.ts +97 -0
- package/dist/customers/notification-recipients.js +84 -0
- package/dist/customers/saved-lists.d.ts +42 -0
- package/dist/customers/saved-lists.js +61 -0
- package/dist/customers/vat.d.ts +83 -0
- package/dist/customers/vat.js +46 -0
- package/dist/customers/wire.d.ts +20 -0
- package/dist/customers/wire.js +35 -0
- package/dist/documents/ar.d.ts +307 -0
- package/dist/documents/ar.js +254 -0
- package/dist/documents/index.d.ts +731 -21
- package/dist/documents/index.js +436 -24
- package/dist/documents/pdf.d.ts +2 -0
- package/dist/documents/pdf.js +11 -0
- package/dist/fulfillments/create.d.ts +167 -0
- package/dist/fulfillments/create.js +216 -0
- package/dist/fulfillments/index.d.ts +121 -10
- package/dist/fulfillments/index.js +120 -2
- package/dist/fulfillments/payment-policy.d.ts +64 -0
- package/dist/fulfillments/payment-policy.js +140 -0
- package/dist/fulfillments/warehouse.d.ts +724 -0
- package/dist/fulfillments/warehouse.js +914 -0
- package/dist/geo/index.d.ts +119 -0
- package/dist/geo/index.js +107 -0
- package/dist/index.d.ts +129 -30
- package/dist/index.js +47 -9
- package/dist/integrations/afas-actions.d.ts +234 -0
- package/dist/integrations/afas-actions.js +310 -0
- package/dist/integrations/afas-types.d.ts +483 -0
- package/dist/integrations/afas-types.js +5 -0
- package/dist/integrations/afas.d.ts +234 -0
- package/dist/integrations/afas.js +290 -0
- package/dist/integrations/connections.d.ts +103 -0
- package/dist/integrations/connections.js +55 -0
- package/dist/integrations/esp.d.ts +313 -0
- package/dist/integrations/esp.js +169 -0
- package/dist/integrations/exact-online-types.d.ts +423 -0
- package/dist/integrations/exact-online-types.js +6 -0
- package/dist/integrations/exact-online.d.ts +248 -0
- package/dist/integrations/exact-online.js +376 -0
- package/dist/integrations/index.d.ts +40 -0
- package/dist/integrations/index.js +24 -0
- package/dist/integrations/pipeline-keys.d.ts +13 -0
- package/dist/integrations/pipeline-keys.js +22 -0
- package/dist/integrations/pipelines.d.ts +114 -0
- package/dist/integrations/pipelines.js +46 -0
- package/dist/integrations/types.d.ts +322 -0
- package/dist/integrations/types.js +8 -0
- package/dist/jobs/bulk-action-run.d.ts +11 -2
- package/dist/jobs/bulk-action-run.js +4 -5
- package/dist/locations/index.d.ts +66 -0
- package/dist/locations/index.js +31 -0
- package/dist/meta/index.d.ts +162 -0
- package/dist/orders/bulk.d.ts +75 -0
- package/dist/orders/bulk.js +150 -0
- package/dist/orders/cancel-with-money.d.ts +227 -0
- package/dist/orders/cancel-with-money.js +153 -0
- package/dist/orders/commit-edit.d.ts +7 -1
- package/dist/orders/commit-edit.js +5 -1
- package/dist/orders/deposit-policy.d.ts +103 -0
- package/dist/orders/deposit-policy.js +202 -0
- package/dist/orders/drafts.d.ts +800 -0
- package/dist/orders/drafts.js +771 -0
- package/dist/orders/fields.d.ts +245 -0
- package/dist/orders/fields.js +188 -0
- package/dist/orders/get.d.ts +29 -19
- package/dist/orders/get.js +17 -8
- package/dist/orders/index.d.ts +125 -5
- package/dist/orders/index.js +35 -2
- package/dist/orders/lifecycle.d.ts +128 -0
- package/dist/orders/lifecycle.js +158 -0
- package/dist/orders/line-price-preview.d.ts +7 -2
- package/dist/orders/list.d.ts +222 -0
- package/dist/orders/list.js +377 -0
- package/dist/orders/manual-discounts.d.ts +11 -2
- package/dist/orders/manual-discounts.js +2 -0
- package/dist/orders/manual-pricing.d.ts +5 -0
- package/dist/orders/order-entry.d.ts +20 -7
- package/dist/orders/plan-edit.d.ts +1 -1
- package/dist/orders/plan-edit.js +4 -1
- package/dist/orders/settings.d.ts +201 -0
- package/dist/orders/settings.js +325 -0
- package/dist/orders/status.d.ts +159 -13
- package/dist/orders/status.js +21 -0
- package/dist/orders/surcharges.d.ts +8 -1
- package/dist/orders/surcharges.js +3 -2
- package/dist/payments/account-credit.d.ts +30 -0
- package/dist/payments/account-credit.js +19 -0
- package/dist/payments/ar.d.ts +292 -0
- package/dist/payments/ar.js +223 -0
- package/dist/payments/connected-account.d.ts +47 -0
- package/dist/payments/connected-account.js +61 -0
- package/dist/payments/credit-noted-fields.d.ts +12 -0
- package/dist/payments/credit-noted-fields.js +37 -0
- package/dist/payments/index.d.ts +263 -10
- package/dist/payments/index.js +133 -1
- package/dist/payments/methods.d.ts +332 -0
- package/dist/payments/methods.js +363 -0
- package/dist/payments/mollie-methods.d.ts +159 -0
- package/dist/payments/mollie-methods.js +141 -0
- package/dist/payments/payment-links.d.ts +180 -0
- package/dist/payments/payment-links.js +97 -0
- package/dist/payments/provider-keys.d.ts +150 -0
- package/dist/payments/provider-keys.js +118 -0
- package/dist/payments/providers.d.ts +86 -11
- package/dist/payments/providers.js +29 -0
- package/dist/payments/requests.d.ts +144 -0
- package/dist/payments/requests.js +92 -0
- package/dist/payments/store-credit-fields.d.ts +15 -0
- package/dist/payments/store-credit-fields.js +51 -0
- package/dist/pickups/index.d.ts +104 -0
- package/dist/pickups/index.js +105 -0
- package/dist/platform/channels.d.ts +132 -0
- package/dist/platform/channels.js +128 -0
- package/dist/platform/geo.d.ts +123 -0
- package/dist/platform/geo.js +144 -0
- package/dist/platform/tax.d.ts +154 -0
- package/dist/platform/tax.js +139 -0
- package/dist/pos/anomalies.d.ts +158 -0
- package/dist/pos/anomalies.js +64 -0
- package/dist/pos/assisted-selling.d.ts +79 -0
- package/dist/pos/assisted-selling.js +38 -0
- package/dist/pos/exchanges.d.ts +103 -0
- package/dist/pos/exchanges.js +22 -0
- package/dist/pos/gift-cards.d.ts +135 -0
- package/dist/pos/gift-cards.js +47 -0
- package/dist/pos/index.d.ts +2125 -32
- package/dist/pos/index.js +742 -4
- package/dist/pos/no-receipt.d.ts +94 -0
- package/dist/pos/no-receipt.js +25 -0
- package/dist/pos/offline-sales.d.ts +187 -0
- package/dist/pos/offline-sales.js +116 -0
- package/dist/pos/pay-by-link.d.ts +143 -0
- package/dist/pos/pay-by-link.js +57 -0
- package/dist/pos/quick-keys.d.ts +103 -0
- package/dist/pos/quick-keys.js +45 -0
- package/dist/pos/reports.d.ts +360 -0
- package/dist/pos/reports.js +62 -0
- package/dist/pos/returns.d.ts +217 -0
- package/dist/pos/returns.js +53 -0
- package/dist/pricing/bulk-coupons.d.ts +139 -0
- package/dist/pricing/bulk-coupons.js +112 -0
- package/dist/pricing/index.d.ts +177 -4
- package/dist/pricing/index.js +176 -1
- package/dist/pricing/price-lists.d.ts +604 -0
- package/dist/pricing/price-lists.js +600 -0
- package/dist/pricing/vouchers.d.ts +103 -0
- package/dist/pricing/vouchers.js +69 -0
- package/dist/purchasing/alerts.d.ts +89 -0
- package/dist/purchasing/alerts.js +62 -0
- package/dist/purchasing/cost.d.ts +110 -0
- package/dist/purchasing/cost.js +86 -0
- package/dist/purchasing/index.d.ts +36 -0
- package/dist/purchasing/index.js +16 -0
- package/dist/purchasing/purchase-orders.d.ts +548 -0
- package/dist/purchasing/purchase-orders.js +491 -0
- package/dist/purchasing/replenishment.d.ts +281 -0
- package/dist/purchasing/replenishment.js +240 -0
- package/dist/purchasing/settings.d.ts +152 -0
- package/dist/purchasing/settings.js +181 -0
- package/dist/purchasing/suppliers.d.ts +476 -0
- package/dist/purchasing/suppliers.js +438 -0
- package/dist/quotes/index.d.ts +501 -0
- package/dist/quotes/index.js +439 -0
- package/dist/reports/index.d.ts +71 -8
- package/dist/reports/index.js +74 -11
- package/dist/returns/index.d.ts +818 -0
- package/dist/returns/index.js +844 -0
- package/dist/search/index.d.ts +174 -0
- package/dist/search/index.js +125 -0
- package/dist/shipping/definitions.d.ts +29 -0
- package/dist/shipping/definitions.js +47 -0
- package/dist/shipping/fulfillment-profiles.d.ts +174 -0
- package/dist/shipping/fulfillment-profiles.js +104 -0
- package/dist/shipping/hendriks.d.ts +97 -0
- package/dist/shipping/hendriks.js +50 -0
- package/dist/shipping/index.d.ts +48 -0
- package/dist/shipping/index.js +25 -0
- package/dist/shipping/methods.d.ts +198 -0
- package/dist/shipping/methods.js +240 -0
- package/dist/shipping/myparcel.d.ts +254 -0
- package/dist/shipping/myparcel.js +178 -0
- package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
- package/dist/shipping/parcel-rule.d.ts +6 -5
- package/dist/shipping/parcel-rule.js +21 -23
- package/dist/shipping/rate-tables.d.ts +179 -0
- package/dist/shipping/rate-tables.js +184 -0
- package/dist/stock/index.d.ts +10 -3
- package/dist/stock/index.js +3 -0
- package/dist/stock/locations.d.ts +144 -0
- package/dist/stock/locations.js +168 -0
- package/dist/stock/transfers.d.ts +216 -43
- package/dist/stock/transfers.js +140 -13
- package/dist/stored-value/index.d.ts +214 -4
- package/dist/stored-value/index.js +152 -0
- package/dist/subscriptions/index.d.ts +682 -0
- package/dist/subscriptions/index.js +815 -0
- package/dist/tax/index.d.ts +76 -1
- package/dist/tax/index.js +50 -0
- package/dist/tenant/email-style.d.ts +102 -0
- package/dist/tenant/email-style.js +72 -0
- package/dist/tenant/email-templates.d.ts +66 -0
- package/dist/tenant/email-templates.js +54 -0
- package/dist/tenant/notifications.d.ts +23 -17
- package/dist/tenant/settings-sources.d.ts +1 -1
- package/dist/tenant/time-zone.d.ts +17 -0
- package/dist/tenant/time-zone.js +11 -0
- package/dist/types.d.ts +51 -4
- package/dist/users/index.d.ts +3 -0
- package/dist/users/index.js +2 -0
- package/dist/users/warehouses.d.ts +50 -0
- package/dist/users/warehouses.js +51 -0
- package/package.json +2 -2
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Till returns and voids (POS engine sprint 20): goods of a completed till sale back, refunded to
|
|
5
|
+
* the sale's own payments, or the whole sale voided. A headless till (a machine principal with
|
|
6
|
+
* `x-location`) is a supported caller: its CREDENTIAL is the manager gate, so no staff or approval
|
|
7
|
+
* token is sent. Money is integer minor units of the order's currency.
|
|
8
|
+
*
|
|
9
|
+
* `quote` is a read: what the units would refund, to which payments, and why it cannot be done now
|
|
10
|
+
* (`blockedBy`, never thrown). `create` and `void` re-compute under the order's money turn and
|
|
11
|
+
* refuse a total other than `expectedTotal` (`POS_RETURN_AMOUNT_CHANGED`, another return was made
|
|
12
|
+
* meanwhile). Refusals that mean NOTHING moved: `POS_RETURN_INVALID` (`extensions.reason`),
|
|
13
|
+
* `POS_RETURN_AMOUNT_CHANGED`, `POS_RETURN_WINDOW_ENDED` (send `overrideWindow`),
|
|
14
|
+
* `POS_RETURN_REFUND_UNKNOWN`, `POS_RETURN_SPLIT_CARD`, `POS_RETURN_EXCEEDS_REFUNDABLE`,
|
|
15
|
+
* `POS_RETURN_SALE_NOT_COMPLETED`, `POS_VOID_NOT_ALLOWED` (`extensions.reason`),
|
|
16
|
+
* `POS_RETURNS_UNAVAILABLE`, `POS_SESSION_REQUIRED` (a cash refund needs an open drawer),
|
|
17
|
+
* `REFUND_REFUSED`, `REFUND_METHOD_UNAVAILABLE`, `LIVE_CONNECTION_REFUSED`.
|
|
18
|
+
* `IDEMPOTENCY_OUTCOME_UNKNOWN` is neither: a card refund reached the provider and the outcome is
|
|
19
|
+
* unknown; never retry under a new key. A card refund the provider did not confirm answers
|
|
20
|
+
* `complete: false` with that refund's `outcome: 'unknown'`; a repeat under the SAME key answers
|
|
21
|
+
* `complete: true` once it was reconciled as made.
|
|
22
|
+
*
|
|
23
|
+
* `payout: 'STORED_VALUE'` (engine C6b) pays a return out to the sale's OWN customer's store credit
|
|
24
|
+
* instead of refunding it: no refund, no provider, no drawer; `quote(...).storedValuePayout` says
|
|
25
|
+
* whether it can (`reason` `no_customer`, `no_method`, `not_entitled` when not), and `create`
|
|
26
|
+
* refuses `POS_RETURN_STORE_CREDIT_UNAVAILABLE` (`extensions.reason`) when it cannot, nothing moved.
|
|
27
|
+
* `quote` and `create` need an engine with C6b (an older one refuses their documents); `void`
|
|
28
|
+
* keeps its sprint-20 selection and reads on any engine.
|
|
29
|
+
*/
|
|
30
|
+
export type PosReturnKind = 'RETURN' | 'VOID';
|
|
31
|
+
/** Where a return's value goes (C6b): REFUND (the default) or the customer's store credit. */
|
|
32
|
+
export type PosReturnPayout = 'REFUND' | 'STORED_VALUE';
|
|
33
|
+
export interface PosReturnQuoteInput {
|
|
34
|
+
orderId: string;
|
|
35
|
+
/** RETURN when omitted; VOID ignores lines. */
|
|
36
|
+
kind?: PosReturnKind;
|
|
37
|
+
lines?: Array<{
|
|
38
|
+
orderLineId: string;
|
|
39
|
+
quantity: number;
|
|
40
|
+
}>;
|
|
41
|
+
cashFirst?: boolean;
|
|
42
|
+
/** REFUND when omitted (C6b). */
|
|
43
|
+
payout?: PosReturnPayout;
|
|
44
|
+
}
|
|
45
|
+
/** Whether a sale's return can go to its customer's store credit (C6b). */
|
|
46
|
+
export interface PosReturnStoredValuePayout {
|
|
47
|
+
available: boolean;
|
|
48
|
+
/** no_customer, no_method or not_entitled when it cannot. More may come. */
|
|
49
|
+
reason: string | null;
|
|
50
|
+
}
|
|
51
|
+
/** The store credit a return was paid out to (C6b). */
|
|
52
|
+
export interface PosReturnStoredValueCredit {
|
|
53
|
+
accountId: string;
|
|
54
|
+
entryId: string;
|
|
55
|
+
amount: number;
|
|
56
|
+
}
|
|
57
|
+
export interface PosReturnQuoteLine {
|
|
58
|
+
orderLineId: string;
|
|
59
|
+
name: string;
|
|
60
|
+
sku: string | null;
|
|
61
|
+
customItem: boolean;
|
|
62
|
+
restockable: boolean;
|
|
63
|
+
soldQuantity: number;
|
|
64
|
+
returnedQuantity: number;
|
|
65
|
+
returnableQuantity: number;
|
|
66
|
+
quantity: number;
|
|
67
|
+
refundAmount: number;
|
|
68
|
+
}
|
|
69
|
+
export interface PosReturnLeg {
|
|
70
|
+
paymentId: string;
|
|
71
|
+
/** cash, card or other. More may come. */
|
|
72
|
+
kind: string;
|
|
73
|
+
method: string;
|
|
74
|
+
amount: number;
|
|
75
|
+
}
|
|
76
|
+
export interface PosReturnQuote {
|
|
77
|
+
orderId: string;
|
|
78
|
+
kind: PosReturnKind;
|
|
79
|
+
currencyCode: string;
|
|
80
|
+
receiptNumber: string | null;
|
|
81
|
+
lines: PosReturnQuoteLine[];
|
|
82
|
+
total: number;
|
|
83
|
+
legs: PosReturnLeg[];
|
|
84
|
+
cashPaidOut: number;
|
|
85
|
+
returnWindowEndsAt: string | null;
|
|
86
|
+
outsideWindow: boolean;
|
|
87
|
+
refundedOutsideReturns: number;
|
|
88
|
+
restockLocationName: string | null;
|
|
89
|
+
/** A POS_RETURN_* / POS_VOID_NOT_ALLOWED / REFUND_METHOD_UNAVAILABLE code, or null. More may come. */
|
|
90
|
+
blockedBy: string | null;
|
|
91
|
+
blockedReason: string | null;
|
|
92
|
+
/** Whether the return can go to the customer's store credit (C6b). */
|
|
93
|
+
storedValuePayout: PosReturnStoredValuePayout;
|
|
94
|
+
}
|
|
95
|
+
export interface PosReturnLineInput {
|
|
96
|
+
orderLineId: string;
|
|
97
|
+
quantity: number;
|
|
98
|
+
/** damaged, defective, wrong_item, not_as_described, arrived_late, no_longer_needed, order_error, other. */
|
|
99
|
+
reasonCode: string;
|
|
100
|
+
restock: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface PosReturnCreateInput {
|
|
103
|
+
orderId: string;
|
|
104
|
+
lines: PosReturnLineInput[];
|
|
105
|
+
/** `quote(...).total` as shown. */
|
|
106
|
+
expectedTotal: number;
|
|
107
|
+
overrideWindow?: boolean;
|
|
108
|
+
cashFirst?: boolean;
|
|
109
|
+
/** REFUND when omitted (C6b). STORED_VALUE: the whole return to the sale's customer's store credit. */
|
|
110
|
+
payout?: PosReturnPayout;
|
|
111
|
+
}
|
|
112
|
+
export interface PosVoidInput {
|
|
113
|
+
orderId: string;
|
|
114
|
+
/** `quote({ orderId, kind: 'VOID' }).total` as shown. */
|
|
115
|
+
expectedTotal: number;
|
|
116
|
+
}
|
|
117
|
+
export interface PosReturnRefund {
|
|
118
|
+
paymentId: string;
|
|
119
|
+
kind: string;
|
|
120
|
+
method: string;
|
|
121
|
+
amount: number;
|
|
122
|
+
refundId: string;
|
|
123
|
+
/** made, or unknown. More may come. */
|
|
124
|
+
outcome: string;
|
|
125
|
+
}
|
|
126
|
+
export interface PosReturnResult {
|
|
127
|
+
orderId: string;
|
|
128
|
+
returnId: string;
|
|
129
|
+
/** The return's RMA code. */
|
|
130
|
+
returnCode: string;
|
|
131
|
+
kind: PosReturnKind;
|
|
132
|
+
total: number;
|
|
133
|
+
refunds: PosReturnRefund[];
|
|
134
|
+
cashPaidOut: number;
|
|
135
|
+
complete: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* What a STORED_VALUE payout credited (C6b); null for a refund. Absent on `void`, which never
|
|
138
|
+
* pays out to store credit and keeps the sprint-20 selection (it reads on an engine before C6b).
|
|
139
|
+
*/
|
|
140
|
+
storedValueCredit?: PosReturnStoredValueCredit | null;
|
|
141
|
+
}
|
|
142
|
+
/** A webshop order by its code AND its customer's email (engine C3/34). */
|
|
143
|
+
export interface PosOnlineOrderRef {
|
|
144
|
+
orderCode: string;
|
|
145
|
+
emailAddress: string;
|
|
146
|
+
}
|
|
147
|
+
/** What a till may know of a webshop order before a return (engine C3/34). */
|
|
148
|
+
export interface PosOnlineOrder {
|
|
149
|
+
orderId: string;
|
|
150
|
+
orderCode: string;
|
|
151
|
+
placedAt: string | null;
|
|
152
|
+
state: string;
|
|
153
|
+
currencyCode: string;
|
|
154
|
+
totalWithTax: number;
|
|
155
|
+
customerName: string | null;
|
|
156
|
+
/** The payment a return goes back to (its method's name); null when none can. */
|
|
157
|
+
refundMethodName: string | null;
|
|
158
|
+
returnableUnits: number;
|
|
159
|
+
/** POS_ONLINE_RETURN_BACK_OFFICE / POS_ONLINE_RETURN_NOTHING_RETURNABLE, or null. More may come. */
|
|
160
|
+
blockedBy: string | null;
|
|
161
|
+
blockedReason: string | null;
|
|
162
|
+
}
|
|
163
|
+
/** An online return's quote: the till quote plus what it refunds of delivery (engine C3/34). */
|
|
164
|
+
export interface PosOnlineReturnQuote extends PosReturnQuote {
|
|
165
|
+
/** Delivery refunded: only when the return brings the whole order back inside the window. */
|
|
166
|
+
shippingRefund: number;
|
|
167
|
+
/** `online`. More may come. */
|
|
168
|
+
source: string;
|
|
169
|
+
}
|
|
170
|
+
export interface PosOnlineReturnInput {
|
|
171
|
+
order: PosOnlineOrderRef;
|
|
172
|
+
lines: PosReturnLineInput[];
|
|
173
|
+
/** `onlineQuote(...).total` as shown, delivery included. */
|
|
174
|
+
expectedTotal: number;
|
|
175
|
+
overrideWindow?: boolean;
|
|
176
|
+
}
|
|
177
|
+
export interface PosReturnsModule {
|
|
178
|
+
/** What a return (or a void) would do now. Writes nothing. */
|
|
179
|
+
quote(input: PosReturnQuoteInput, options?: Call): Promise<PosReturnQuote>;
|
|
180
|
+
/** Return items: the key is REQUIRED (`options.idempotencyKey`). */
|
|
181
|
+
create(input: PosReturnCreateInput, options: Call & {
|
|
182
|
+
idempotencyKey: string;
|
|
183
|
+
}): Promise<PosReturnResult>;
|
|
184
|
+
/** Void a sale: the key is REQUIRED (`options.idempotencyKey`). */
|
|
185
|
+
void(input: PosVoidInput, options: Call & {
|
|
186
|
+
idempotencyKey: string;
|
|
187
|
+
}): Promise<PosReturnResult>;
|
|
188
|
+
/**
|
|
189
|
+
* A webshop order of this store by its code AND its customer's email (engine C3/34), re-verified
|
|
190
|
+
* on every call. An unknown code, a wrong email or another store's order is ONE refusal,
|
|
191
|
+
* `POS_ONLINE_ORDER_NOT_FOUND`; a till sale `POS_ONLINE_ORDER_IS_TILL_SALE`.
|
|
192
|
+
*/
|
|
193
|
+
findOnlineOrder(ref: PosOnlineOrderRef, options?: Call): Promise<PosOnlineOrder>;
|
|
194
|
+
/** What returning these units of the webshop order would refund now (engine C3/34). */
|
|
195
|
+
onlineQuote(input: {
|
|
196
|
+
order: PosOnlineOrderRef;
|
|
197
|
+
lines?: Array<{
|
|
198
|
+
orderLineId: string;
|
|
199
|
+
quantity: number;
|
|
200
|
+
}>;
|
|
201
|
+
}, options?: Call): Promise<PosOnlineReturnQuote>;
|
|
202
|
+
/**
|
|
203
|
+
* Return a webshop order's items at the credential's location, refunded to ONE online payment
|
|
204
|
+
* (engine C3/34). The key is REQUIRED. A provider that answers later or never confirms answers
|
|
205
|
+
* `complete: false` with the refund's `outcome` `pending` / `unknown` (do not refund again).
|
|
206
|
+
*/
|
|
207
|
+
onlineReturn(input: PosOnlineReturnInput, options: Call & {
|
|
208
|
+
idempotencyKey: string;
|
|
209
|
+
}): Promise<PosReturnResult>;
|
|
210
|
+
}
|
|
211
|
+
export declare const POS_RETURN_QUOTE_QUERY = "query PosReturnQuote($input: PosReturnQuoteInput!) { posReturnQuote(input: $input) { orderId kind currencyCode receiptNumber lines { orderLineId name sku customItem restockable soldQuantity returnedQuantity returnableQuantity quantity refundAmount } total legs { paymentId kind method amount } cashPaidOut returnWindowEndsAt outsideWindow refundedOutsideReturns restockLocationName blockedBy blockedReason storedValuePayout { available reason } } }";
|
|
212
|
+
export declare const POS_RETURN_MUTATION = "mutation PosReturn($input: PosReturnInput!) { posReturn(input: $input) { orderId returnId returnCode kind total refunds { paymentId kind method amount refundId outcome } cashPaidOut complete storedValueCredit { accountId entryId amount } } }";
|
|
213
|
+
export declare const POS_VOID_SALE_MUTATION = "mutation PosVoidSale($input: PosVoidSaleInput!) { posVoidSale(input: $input) { orderId returnId returnCode kind total refunds { paymentId kind method amount refundId outcome } cashPaidOut complete } }";
|
|
214
|
+
export declare const POS_ONLINE_ORDER_QUERY = "query PosOnlineOrder($input: PosOnlineOrderRefInput!) { posOnlineOrder(input: $input) { orderId orderCode placedAt state currencyCode totalWithTax customerName refundMethodName returnableUnits blockedBy blockedReason } }";
|
|
215
|
+
export declare const POS_ONLINE_RETURN_QUOTE_QUERY = "query PosOnlineReturnQuote($input: PosOnlineReturnQuoteInput!) { posOnlineReturnQuote(input: $input) { orderId kind currencyCode receiptNumber lines { orderLineId name sku customItem restockable soldQuantity returnedQuantity returnableQuantity quantity refundAmount } total legs { paymentId kind method amount } cashPaidOut returnWindowEndsAt outsideWindow refundedOutsideReturns restockLocationName blockedBy blockedReason storedValuePayout { available reason } shippingRefund source } }";
|
|
216
|
+
export declare const POS_ONLINE_RETURN_MUTATION = "mutation PosOnlineReturn($input: PosOnlineReturnInput!) { posOnlineReturn(input: $input) { orderId returnId returnCode kind total refunds { paymentId kind method amount refundId outcome } cashPaidOut complete } }";
|
|
217
|
+
export declare function createPosReturnsModule(transport: Transport): PosReturnsModule;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const QUOTE_FIELDS = 'orderId kind currencyCode receiptNumber lines { orderLineId name sku customItem restockable soldQuantity returnedQuantity returnableQuantity quantity refundAmount } total legs { paymentId kind method amount } cashPaidOut returnWindowEndsAt outsideWindow refundedOutsideReturns restockLocationName blockedBy blockedReason storedValuePayout { available reason }';
|
|
2
|
+
/** The sprint-20 result: what a void answers (it never pays out to store credit). */
|
|
3
|
+
const VOID_RESULT_FIELDS = 'orderId returnId returnCode kind total refunds { paymentId kind method amount refundId outcome } cashPaidOut complete';
|
|
4
|
+
/** A return's result: the void's, and the store credit a STORED_VALUE payout made (C6b). */
|
|
5
|
+
const RESULT_FIELDS = `${VOID_RESULT_FIELDS} storedValueCredit { accountId entryId amount }`;
|
|
6
|
+
export const POS_RETURN_QUOTE_QUERY = `query PosReturnQuote($input: PosReturnQuoteInput!) { posReturnQuote(input: $input) { ${QUOTE_FIELDS} } }`;
|
|
7
|
+
export const POS_RETURN_MUTATION = `mutation PosReturn($input: PosReturnInput!) { posReturn(input: $input) { ${RESULT_FIELDS} } }`;
|
|
8
|
+
export const POS_VOID_SALE_MUTATION = `mutation PosVoidSale($input: PosVoidSaleInput!) { posVoidSale(input: $input) { ${VOID_RESULT_FIELDS} } }`;
|
|
9
|
+
// Engine C3/34: their own documents, so a call to an older engine fails alone.
|
|
10
|
+
const ONLINE_ORDER_FIELDS = 'orderId orderCode placedAt state currencyCode totalWithTax customerName refundMethodName returnableUnits blockedBy blockedReason';
|
|
11
|
+
export const POS_ONLINE_ORDER_QUERY = `query PosOnlineOrder($input: PosOnlineOrderRefInput!) { posOnlineOrder(input: $input) { ${ONLINE_ORDER_FIELDS} } }`;
|
|
12
|
+
export const POS_ONLINE_RETURN_QUOTE_QUERY = `query PosOnlineReturnQuote($input: PosOnlineReturnQuoteInput!) { posOnlineReturnQuote(input: $input) { ${QUOTE_FIELDS} shippingRefund source } }`;
|
|
13
|
+
// A webshop order's return never pays out to store credit (C3 D22): the void's result fields.
|
|
14
|
+
export const POS_ONLINE_RETURN_MUTATION = `mutation PosOnlineReturn($input: PosOnlineReturnInput!) { posOnlineReturn(input: $input) { ${VOID_RESULT_FIELDS} } }`;
|
|
15
|
+
function keyOf(options, call) {
|
|
16
|
+
const key = options?.idempotencyKey;
|
|
17
|
+
if (typeof key !== 'string' || key.trim() === '') {
|
|
18
|
+
throw new TypeError(`pos.returns.${call} needs options.idempotencyKey (a fresh UUIDv7 per return; reuse it only to retry the same one).`);
|
|
19
|
+
}
|
|
20
|
+
return key;
|
|
21
|
+
}
|
|
22
|
+
export function createPosReturnsModule(transport) {
|
|
23
|
+
const gql = async (query, variables, options) => transport.graphql({ api: 'admin', query, variables }, options);
|
|
24
|
+
return {
|
|
25
|
+
async quote(input, options) {
|
|
26
|
+
const data = await gql(POS_RETURN_QUOTE_QUERY, { input }, options);
|
|
27
|
+
return data.posReturnQuote;
|
|
28
|
+
},
|
|
29
|
+
async create(input, options) {
|
|
30
|
+
const idempotencyKey = keyOf(options, 'create');
|
|
31
|
+
const data = await gql(POS_RETURN_MUTATION, { input: { ...input, idempotencyKey } }, options);
|
|
32
|
+
return data.posReturn;
|
|
33
|
+
},
|
|
34
|
+
async void(input, options) {
|
|
35
|
+
const idempotencyKey = keyOf(options, 'void');
|
|
36
|
+
const data = await gql(POS_VOID_SALE_MUTATION, { input: { ...input, idempotencyKey } }, options);
|
|
37
|
+
return data.posVoidSale;
|
|
38
|
+
},
|
|
39
|
+
async findOnlineOrder(ref, options) {
|
|
40
|
+
const data = await gql(POS_ONLINE_ORDER_QUERY, { input: ref }, options);
|
|
41
|
+
return data.posOnlineOrder;
|
|
42
|
+
},
|
|
43
|
+
async onlineQuote(input, options) {
|
|
44
|
+
const data = await gql(POS_ONLINE_RETURN_QUOTE_QUERY, { input }, options);
|
|
45
|
+
return data.posOnlineReturnQuote;
|
|
46
|
+
},
|
|
47
|
+
async onlineReturn(input, options) {
|
|
48
|
+
const idempotencyKey = keyOf(options, 'onlineReturn');
|
|
49
|
+
const data = await gql(POS_ONLINE_RETURN_MUTATION, { input: { ...input, idempotencyKey } }, options);
|
|
50
|
+
return data.posOnlineReturn;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { type Page, type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call, ListOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* `admin.pricing.coupons.bulk`: unique codes generated in bulk for a promotion of the store
|
|
5
|
+
* (`vendure-plugin-bulk-coupons`). A code stands in for its promotion's own coupon code, so a
|
|
6
|
+
* promotion WITHOUT a coupon code takes none: its codes would never be accepted. Each code keeps
|
|
7
|
+
* its group's usage limits on top of the promotion's.
|
|
8
|
+
*
|
|
9
|
+
* Every id names a record of THIS store: another store's promotion, group or code is
|
|
10
|
+
* `ENTITY_NOT_FOUND` (`NotFoundError`, 404), the same answer as one that does not exist.
|
|
11
|
+
*/
|
|
12
|
+
export interface PricingBulkCouponsModule {
|
|
13
|
+
/**
|
|
14
|
+
* The promotion's code groups, newest first, each with how many of its codes are active and
|
|
15
|
+
* how many uses its codes have had (orders holding a code that are not cancelled). A voucher
|
|
16
|
+
* template (`kind: 'voucher'`, `pricing.vouchers`) is a group too.
|
|
17
|
+
*
|
|
18
|
+
* @effect read
|
|
19
|
+
* @permission ReadPromotion
|
|
20
|
+
*/
|
|
21
|
+
groups(promotionId: string, options?: Call): Promise<BulkCouponGroup[]>;
|
|
22
|
+
/**
|
|
23
|
+
* One page of a group's codes, oldest first and then by id, an order every page agrees on, so
|
|
24
|
+
* a walk with `for await` sees each code once (`limit` 1 to 1,000, default 25), each with its
|
|
25
|
+
* own use count. Refused before sending: `INVALID_PAGE_SIZE` (`ValidationError`, 400).
|
|
26
|
+
*
|
|
27
|
+
* @effect read
|
|
28
|
+
* @permission ReadPromotion
|
|
29
|
+
*/
|
|
30
|
+
codes(groupId: string, options?: ListOptions): Promise<Page<BulkCouponCode>>;
|
|
31
|
+
/**
|
|
32
|
+
* Generate a group of `quantity` new codes, `PREFIX-RANDOM`, for the promotion, and answer
|
|
33
|
+
* the group. The prefix is trimmed; the random part is `codeLength` characters (8 when
|
|
34
|
+
* omitted).
|
|
35
|
+
*
|
|
36
|
+
* Refusals (`ValidationError`, 400): `BULK_COUPON_PREFIX_INVALID` (1 to 50 capital letters,
|
|
37
|
+
* digits or "-", starting with a letter or digit), `BULK_COUPON_CODE_LENGTH_INVALID` (8 to
|
|
38
|
+
* 32), `BULK_COUPON_QUANTITY_INVALID` (1 to 100,000);
|
|
39
|
+
* `BULK_COUPON_CODE_SPACE_EXHAUSTED` (`BusinessRuleError`, 422) when the prefix and length
|
|
40
|
+
* have too few free codes left (choose a longer length or another prefix). Nothing is saved
|
|
41
|
+
* on a refusal. A repeat generates another group: no `idempotencyKey` is read.
|
|
42
|
+
*
|
|
43
|
+
* @effect write
|
|
44
|
+
* @permission CreatePromotion
|
|
45
|
+
*/
|
|
46
|
+
generate(input: GenerateBulkCouponsInput, options?: Call): Promise<BulkCouponGroup>;
|
|
47
|
+
/**
|
|
48
|
+
* Accept a switched-off code again, and answer it.
|
|
49
|
+
*
|
|
50
|
+
* @effect write
|
|
51
|
+
* @permission UpdatePromotion
|
|
52
|
+
*/
|
|
53
|
+
activate(codeId: string, options?: Call): Promise<BulkCouponCode>;
|
|
54
|
+
/**
|
|
55
|
+
* Stop accepting one code from now on, and answer it.
|
|
56
|
+
*
|
|
57
|
+
* @effect write
|
|
58
|
+
* @permission UpdatePromotion
|
|
59
|
+
*/
|
|
60
|
+
deactivate(codeId: string, options?: Call): Promise<BulkCouponCode>;
|
|
61
|
+
/**
|
|
62
|
+
* Stop accepting every code of a group (each can be switched on again with
|
|
63
|
+
* {@link activate}).
|
|
64
|
+
*
|
|
65
|
+
* @effect write
|
|
66
|
+
* @permission UpdatePromotion
|
|
67
|
+
*/
|
|
68
|
+
deactivateGroup(groupId: string, options?: Call): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Delete a group and every code in it: none is accepted again, and none can be switched back
|
|
71
|
+
* on.
|
|
72
|
+
*
|
|
73
|
+
* @effect destructive
|
|
74
|
+
* @permission DeletePromotion
|
|
75
|
+
*/
|
|
76
|
+
deleteGroup(groupId: string, options?: Call): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Every code of a group as CSV text, in the order of {@link codes}: a `code,active,created_at`
|
|
79
|
+
* header, then one line per code (`active` is `true`/`false`, `created_at` an ISO-8601 instant).
|
|
80
|
+
*
|
|
81
|
+
* @effect read
|
|
82
|
+
* @permission ReadPromotion
|
|
83
|
+
*/
|
|
84
|
+
export(groupId: string, options?: Call): Promise<string>;
|
|
85
|
+
}
|
|
86
|
+
export interface BulkCouponGroup {
|
|
87
|
+
id: string;
|
|
88
|
+
promotionId: string;
|
|
89
|
+
prefix: string;
|
|
90
|
+
codeLength: number;
|
|
91
|
+
/** Codes generated up front; 0 for a voucher template, whose codes are issued one by one. */
|
|
92
|
+
quantity: number;
|
|
93
|
+
/** Uses each code allows; null for no limit of its own. */
|
|
94
|
+
perCodeUsageLimit: number | null;
|
|
95
|
+
/** Uses each code allows one customer; null for no limit of its own. */
|
|
96
|
+
perCodeCustomerUsageLimit: number | null;
|
|
97
|
+
/** `batch` (generated up front) or `voucher` (personal codes issued one by one). */
|
|
98
|
+
kind: 'batch' | 'voucher' | (string & {});
|
|
99
|
+
/** A voucher template's validity in days when an issue names none. */
|
|
100
|
+
defaultValidityDays: number | null;
|
|
101
|
+
activeCount: number;
|
|
102
|
+
usedCount: number;
|
|
103
|
+
createdAt: string;
|
|
104
|
+
}
|
|
105
|
+
export interface BulkCouponCode {
|
|
106
|
+
id: string;
|
|
107
|
+
code: string;
|
|
108
|
+
isActive: boolean;
|
|
109
|
+
usageCount: number;
|
|
110
|
+
createdAt: string;
|
|
111
|
+
/** A voucher's customer; null for a batch code (or a voucher whose customer was erased). */
|
|
112
|
+
customerId: string | null;
|
|
113
|
+
/** A voucher's own expiry; its promotion's end still applies. */
|
|
114
|
+
expiresAt: string | null;
|
|
115
|
+
/** The system that issued a voucher, as it named itself. */
|
|
116
|
+
sourceSystem: string | null;
|
|
117
|
+
/** The issuing journey's own reference, opaque. */
|
|
118
|
+
sourceRef: string | null;
|
|
119
|
+
}
|
|
120
|
+
export interface GenerateBulkCouponsInput {
|
|
121
|
+
promotionId: string;
|
|
122
|
+
prefix: string;
|
|
123
|
+
/** The random part's length, 8 to 32; 8 when omitted. */
|
|
124
|
+
codeLength?: number;
|
|
125
|
+
/** 1 to 100,000. */
|
|
126
|
+
quantity: number;
|
|
127
|
+
perCodeUsageLimit?: number | null;
|
|
128
|
+
perCodeCustomerUsageLimit?: number | null;
|
|
129
|
+
}
|
|
130
|
+
export declare const BULK_COUPON_GROUPS_QUERY = "\n query BulkCouponGroups($promotionId: ID!) {\n bulkCouponGroups(promotionId: $promotionId) { \n id\n promotionId\n prefix\n codeLength\n quantity\n perCodeUsageLimit\n perCodeCustomerUsageLimit\n kind\n defaultValidityDays\n activeCount\n usedCount\n createdAt\n }\n }\n";
|
|
131
|
+
export declare const BULK_COUPON_CODES_QUERY = "\n query BulkCouponCodes($groupId: ID!, $options: BulkCouponCodeListOptions) {\n bulkCouponCodes(groupId: $groupId, options: $options) {\n items { \n id\n code\n isActive\n usageCount\n createdAt\n customerId\n expiresAt\n sourceSystem\n sourceRef\n }\n totalItems\n }\n }\n";
|
|
132
|
+
export declare const GENERATE_BULK_COUPONS_MUTATION = "\n mutation GenerateBulkCoupons($input: GenerateBulkCouponsInput!) {\n generateBulkCoupons(input: $input) { \n id\n promotionId\n prefix\n codeLength\n quantity\n perCodeUsageLimit\n perCodeCustomerUsageLimit\n kind\n defaultValidityDays\n activeCount\n usedCount\n createdAt\n }\n }\n";
|
|
133
|
+
export declare const ACTIVATE_BULK_COUPON_CODE_MUTATION = "\n mutation ActivateBulkCouponCode($id: ID!) {\n activateBulkCouponCode(id: $id) { \n id\n code\n isActive\n usageCount\n createdAt\n customerId\n expiresAt\n sourceSystem\n sourceRef\n }\n }\n";
|
|
134
|
+
export declare const DEACTIVATE_BULK_COUPON_CODE_MUTATION = "\n mutation DeactivateBulkCouponCode($id: ID!) {\n deactivateBulkCouponCode(id: $id) { \n id\n code\n isActive\n usageCount\n createdAt\n customerId\n expiresAt\n sourceSystem\n sourceRef\n }\n }\n";
|
|
135
|
+
export declare const DEACTIVATE_BULK_COUPON_GROUP_MUTATION = "\n mutation DeactivateBulkCouponGroup($groupId: ID!) {\n deactivateBulkCouponGroup(groupId: $groupId)\n }\n";
|
|
136
|
+
export declare const DELETE_BULK_COUPON_GROUP_MUTATION = "\n mutation DeleteBulkCouponGroup($groupId: ID!) {\n deleteBulkCouponGroup(groupId: $groupId)\n }\n";
|
|
137
|
+
/** A mutation, though it writes nothing: the plugin declares it so (`ReadPromotion`). */
|
|
138
|
+
export declare const EXPORT_BULK_COUPON_CODES_MUTATION = "\n mutation ExportBulkCouponCodes($groupId: ID!) {\n exportBulkCouponCodes(groupId: $groupId)\n }\n";
|
|
139
|
+
export declare function createPricingBulkCouponsModule(transport: Transport): PricingBulkCouponsModule;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { UpstreamError } from '@sixtyninecommerce/core';
|
|
2
|
+
import { fieldOf, vendureListPage } from '../catalog/types.js';
|
|
3
|
+
const GROUP_FIELDS = /* GraphQL */ `
|
|
4
|
+
id
|
|
5
|
+
promotionId
|
|
6
|
+
prefix
|
|
7
|
+
codeLength
|
|
8
|
+
quantity
|
|
9
|
+
perCodeUsageLimit
|
|
10
|
+
perCodeCustomerUsageLimit
|
|
11
|
+
kind
|
|
12
|
+
defaultValidityDays
|
|
13
|
+
activeCount
|
|
14
|
+
usedCount
|
|
15
|
+
createdAt
|
|
16
|
+
`;
|
|
17
|
+
const CODE_FIELDS = /* GraphQL */ `
|
|
18
|
+
id
|
|
19
|
+
code
|
|
20
|
+
isActive
|
|
21
|
+
usageCount
|
|
22
|
+
createdAt
|
|
23
|
+
customerId
|
|
24
|
+
expiresAt
|
|
25
|
+
sourceSystem
|
|
26
|
+
sourceRef
|
|
27
|
+
`;
|
|
28
|
+
export const BULK_COUPON_GROUPS_QUERY = /* GraphQL */ `
|
|
29
|
+
query BulkCouponGroups($promotionId: ID!) {
|
|
30
|
+
bulkCouponGroups(promotionId: $promotionId) { ${GROUP_FIELDS} }
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
export const BULK_COUPON_CODES_QUERY = /* GraphQL */ `
|
|
34
|
+
query BulkCouponCodes($groupId: ID!, $options: BulkCouponCodeListOptions) {
|
|
35
|
+
bulkCouponCodes(groupId: $groupId, options: $options) {
|
|
36
|
+
items { ${CODE_FIELDS} }
|
|
37
|
+
totalItems
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
export const GENERATE_BULK_COUPONS_MUTATION = /* GraphQL */ `
|
|
42
|
+
mutation GenerateBulkCoupons($input: GenerateBulkCouponsInput!) {
|
|
43
|
+
generateBulkCoupons(input: $input) { ${GROUP_FIELDS} }
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
export const ACTIVATE_BULK_COUPON_CODE_MUTATION = /* GraphQL */ `
|
|
47
|
+
mutation ActivateBulkCouponCode($id: ID!) {
|
|
48
|
+
activateBulkCouponCode(id: $id) { ${CODE_FIELDS} }
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
export const DEACTIVATE_BULK_COUPON_CODE_MUTATION = /* GraphQL */ `
|
|
52
|
+
mutation DeactivateBulkCouponCode($id: ID!) {
|
|
53
|
+
deactivateBulkCouponCode(id: $id) { ${CODE_FIELDS} }
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
export const DEACTIVATE_BULK_COUPON_GROUP_MUTATION = /* GraphQL */ `
|
|
57
|
+
mutation DeactivateBulkCouponGroup($groupId: ID!) {
|
|
58
|
+
deactivateBulkCouponGroup(groupId: $groupId)
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
export const DELETE_BULK_COUPON_GROUP_MUTATION = /* GraphQL */ `
|
|
62
|
+
mutation DeleteBulkCouponGroup($groupId: ID!) {
|
|
63
|
+
deleteBulkCouponGroup(groupId: $groupId)
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
/** A mutation, though it writes nothing: the plugin declares it so (`ReadPromotion`). */
|
|
67
|
+
export const EXPORT_BULK_COUPON_CODES_MUTATION = /* GraphQL */ `
|
|
68
|
+
mutation ExportBulkCouponCodes($groupId: ID!) {
|
|
69
|
+
exportBulkCouponCodes(groupId: $groupId)
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
/** A `Boolean!` door's answer: anything but `true` is refused, never taken as done. */
|
|
73
|
+
function assertDone(field, answer) {
|
|
74
|
+
if (answer === true)
|
|
75
|
+
return;
|
|
76
|
+
throw new UpstreamError({
|
|
77
|
+
code: 'UNEXPECTED_RESPONSE',
|
|
78
|
+
message: `The engine answered "${field}" with ${JSON.stringify(answer)}, not true.`,
|
|
79
|
+
status: 502,
|
|
80
|
+
service: 'vendure',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export function createPricingBulkCouponsModule(transport) {
|
|
84
|
+
return {
|
|
85
|
+
groups(promotionId, options) {
|
|
86
|
+
return fieldOf(transport, BULK_COUPON_GROUPS_QUERY, 'bulkCouponGroups', { promotionId }, options);
|
|
87
|
+
},
|
|
88
|
+
codes(groupId, options) {
|
|
89
|
+
return vendureListPage(transport, BULK_COUPON_CODES_QUERY, 'bulkCouponCodes', (skip, take) => ({ groupId, options: { skip, take } }), options);
|
|
90
|
+
},
|
|
91
|
+
generate(input, options) {
|
|
92
|
+
return fieldOf(transport, GENERATE_BULK_COUPONS_MUTATION, 'generateBulkCoupons', { input }, options);
|
|
93
|
+
},
|
|
94
|
+
activate(codeId, options) {
|
|
95
|
+
return fieldOf(transport, ACTIVATE_BULK_COUPON_CODE_MUTATION, 'activateBulkCouponCode', { id: codeId }, options);
|
|
96
|
+
},
|
|
97
|
+
deactivate(codeId, options) {
|
|
98
|
+
return fieldOf(transport, DEACTIVATE_BULK_COUPON_CODE_MUTATION, 'deactivateBulkCouponCode', { id: codeId }, options);
|
|
99
|
+
},
|
|
100
|
+
async deactivateGroup(groupId, options) {
|
|
101
|
+
const field = 'deactivateBulkCouponGroup';
|
|
102
|
+
assertDone(field, await fieldOf(transport, DEACTIVATE_BULK_COUPON_GROUP_MUTATION, field, { groupId }, options));
|
|
103
|
+
},
|
|
104
|
+
async deleteGroup(groupId, options) {
|
|
105
|
+
const field = 'deleteBulkCouponGroup';
|
|
106
|
+
assertDone(field, await fieldOf(transport, DELETE_BULK_COUPON_GROUP_MUTATION, field, { groupId }, options));
|
|
107
|
+
},
|
|
108
|
+
export(groupId, options) {
|
|
109
|
+
return fieldOf(transport, EXPORT_BULK_COUPON_CODES_MUTATION, 'exportBulkCouponCodes', { groupId }, options);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|