@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
|
@@ -94,6 +94,46 @@ export interface UpsertLocationProfileInput {
|
|
|
94
94
|
openingHours?: OpeningHours | null;
|
|
95
95
|
address?: StockLocationAddressInput | null;
|
|
96
96
|
}
|
|
97
|
+
/** Hold days a ready store pickup may be set to: 1 to 60, 7 when a location never set them (D15). */
|
|
98
|
+
export declare const STORE_PICKUP_HOLD_DAYS: {
|
|
99
|
+
readonly min: 1;
|
|
100
|
+
readonly max: 60;
|
|
101
|
+
readonly default: 7;
|
|
102
|
+
};
|
|
103
|
+
/** The longest store pickup instructions a location may carry, in characters (D15). */
|
|
104
|
+
export declare const STORE_PICKUP_INSTRUCTIONS_MAX_LENGTH = 500;
|
|
105
|
+
/**
|
|
106
|
+
* A stock location's store pickup settings (C1/33). A location that never set them reads as not
|
|
107
|
+
* enabled, {@link STORE_PICKUP_HOLD_DAYS} `default` hold days and no instructions.
|
|
108
|
+
*/
|
|
109
|
+
export interface StockLocationPickup {
|
|
110
|
+
stockLocationId: string;
|
|
111
|
+
/** Shoppers may choose this location at checkout, and its till hands the order over. */
|
|
112
|
+
enabled: boolean;
|
|
113
|
+
/** Days a ready pickup is held before its stock goes back on sale (1 to 60). */
|
|
114
|
+
holdDays: number;
|
|
115
|
+
/** Shown to shoppers at checkout and in the ready email; null when none. */
|
|
116
|
+
instructions: string | null;
|
|
117
|
+
/**
|
|
118
|
+
* What ENABLING needs, answered now: the location's address (its location profile) and an
|
|
119
|
+
* active POS register at the location, because the hand-over happens at a till. Turning on a
|
|
120
|
+
* location that lacks one is refused; a location already on keeps working.
|
|
121
|
+
*/
|
|
122
|
+
hasAddress: boolean;
|
|
123
|
+
hasTill: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The WHOLE settings, not a patch: an omitted `instructions` clears them. Instructions are
|
|
127
|
+
* trimmed, and blank is none.
|
|
128
|
+
*/
|
|
129
|
+
export interface SetStockLocationPickupInput {
|
|
130
|
+
stockLocationId: string;
|
|
131
|
+
enabled: boolean;
|
|
132
|
+
/** A whole number from 1 to 60. */
|
|
133
|
+
holdDays: number;
|
|
134
|
+
/** At most 500 characters, no control characters (a line break is fine). */
|
|
135
|
+
instructions?: string | null;
|
|
136
|
+
}
|
|
97
137
|
/**
|
|
98
138
|
* Location profiles for the active channel (spec §8.7).
|
|
99
139
|
*
|
|
@@ -134,9 +174,35 @@ export interface LocationsModule {
|
|
|
134
174
|
upsert(input: UpsertLocationProfileInput, options?: Call): Promise<LocationProfile>;
|
|
135
175
|
/** True when a profile was removed, false when there was none. The stock location survives. */
|
|
136
176
|
delete(stockLocationId: string, options?: Call): Promise<boolean>;
|
|
177
|
+
/**
|
|
178
|
+
* The location's store pickup settings, with what enabling needs (`hasAddress`, `hasTill`).
|
|
179
|
+
* Needs `ReadStockLocation`. Refused `LOCATION_NOT_FOUND` (`NotFoundError`) for a location that
|
|
180
|
+
* is not this store's.
|
|
181
|
+
*
|
|
182
|
+
* @effect read
|
|
183
|
+
*/
|
|
184
|
+
pickup(stockLocationId: string, options?: Call): Promise<StockLocationPickup>;
|
|
185
|
+
/**
|
|
186
|
+
* Set the location's store pickup settings (C1/33). Needs `UpdateStockLocation`. The store's
|
|
187
|
+
* first enabled location creates its `store-pickup` shipping method, which then appears among
|
|
188
|
+
* the store's shipping methods (rename or disable it there). Sending the stored settings back
|
|
189
|
+
* writes nothing.
|
|
190
|
+
*
|
|
191
|
+
* Refused: `STORE_PICKUP_SETTINGS_INVALID` (`ValidationError`) for hold days outside 1-60 or
|
|
192
|
+
* instructions over 500 characters or with a control character; turning pickup ON at a
|
|
193
|
+
* location without an address, `STORE_PICKUP_ADDRESS_REQUIRED`, or without an active POS
|
|
194
|
+
* register, `STORE_PICKUP_TILL_REQUIRED` (both `BusinessRuleError`); `LOCATION_NOT_FOUND`
|
|
195
|
+
* (`NotFoundError`); and `LOCATION_NOT_ALLOWED` (`PermissionDeniedError`) for a credential
|
|
196
|
+
* restricted with `locationIds` that does not hold the location.
|
|
197
|
+
*
|
|
198
|
+
* @effect write
|
|
199
|
+
*/
|
|
200
|
+
setPickup(input: SetStockLocationPickupInput, options?: Call): Promise<StockLocationPickup>;
|
|
137
201
|
}
|
|
138
202
|
export declare const LOCATION_PROFILES_QUERY = "\n query LocationProfiles {\n locationProfiles { \n stockLocationId\n code\n name\n timezone\n phone\n openingHours\n address {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n stockLocation {\n id\n name\n description\n }\n }\n }\n";
|
|
139
203
|
export declare const LOCATION_PROFILE_QUERY = "\n query LocationProfile($stockLocationId: ID!) {\n locationProfile(stockLocationId: $stockLocationId) { \n stockLocationId\n code\n name\n timezone\n phone\n openingHours\n address {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n stockLocation {\n id\n name\n description\n }\n }\n }\n";
|
|
140
204
|
export declare const UPSERT_LOCATION_PROFILE_MUTATION = "\n mutation UpsertLocationProfile($input: UpsertLocationProfileInput!) {\n upsertLocationProfile(input: $input) { \n stockLocationId\n code\n name\n timezone\n phone\n openingHours\n address {\n contactName\n company\n streetLine1\n streetLine2\n city\n province\n postalCode\n countryCode\n phoneNumber\n }\n stockLocation {\n id\n name\n description\n }\n }\n }\n";
|
|
141
205
|
export declare const DELETE_LOCATION_PROFILE_MUTATION = "\n mutation DeleteLocationProfile($stockLocationId: ID!) {\n deleteLocationProfile(stockLocationId: $stockLocationId)\n }\n";
|
|
206
|
+
export declare const STOCK_LOCATION_PICKUP_QUERY = "\n query StockLocationPickup($stockLocationId: ID!) {\n stockLocationPickup(stockLocationId: $stockLocationId) { \n stockLocationId\n enabled\n holdDays\n instructions\n hasAddress\n hasTill\n }\n }\n";
|
|
207
|
+
export declare const SET_STOCK_LOCATION_PICKUP_MUTATION = "\n mutation SetStockLocationPickup($input: SetStockLocationPickupInput!) {\n setStockLocationPickup(input: $input) { \n stockLocationId\n enabled\n holdDays\n instructions\n hasAddress\n hasTill\n }\n }\n";
|
|
142
208
|
export declare function createLocationsModule(transport: Transport): LocationsModule;
|
package/dist/locations/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { createPage } from '@sixtyninecommerce/core';
|
|
2
2
|
/** `openingHours` keys: lowercase, three letters, Monday first. */
|
|
3
3
|
export const OPENING_HOURS_DAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
|
4
|
+
// ── Store pickup (POS C1/33) ──
|
|
5
|
+
/** Hold days a ready store pickup may be set to: 1 to 60, 7 when a location never set them (D15). */
|
|
6
|
+
export const STORE_PICKUP_HOLD_DAYS = { min: 1, max: 60, default: 7 };
|
|
7
|
+
/** The longest store pickup instructions a location may carry, in characters (D15). */
|
|
8
|
+
export const STORE_PICKUP_INSTRUCTIONS_MAX_LENGTH = 500;
|
|
4
9
|
const LOCATION_PROFILE_FIELDS = /* GraphQL */ `
|
|
5
10
|
stockLocationId
|
|
6
11
|
code
|
|
@@ -45,6 +50,24 @@ export const DELETE_LOCATION_PROFILE_MUTATION = /* GraphQL */ `
|
|
|
45
50
|
deleteLocationProfile(stockLocationId: $stockLocationId)
|
|
46
51
|
}
|
|
47
52
|
`;
|
|
53
|
+
const STOCK_LOCATION_PICKUP_FIELDS = /* GraphQL */ `
|
|
54
|
+
stockLocationId
|
|
55
|
+
enabled
|
|
56
|
+
holdDays
|
|
57
|
+
instructions
|
|
58
|
+
hasAddress
|
|
59
|
+
hasTill
|
|
60
|
+
`;
|
|
61
|
+
export const STOCK_LOCATION_PICKUP_QUERY = /* GraphQL */ `
|
|
62
|
+
query StockLocationPickup($stockLocationId: ID!) {
|
|
63
|
+
stockLocationPickup(stockLocationId: $stockLocationId) { ${STOCK_LOCATION_PICKUP_FIELDS} }
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
export const SET_STOCK_LOCATION_PICKUP_MUTATION = /* GraphQL */ `
|
|
67
|
+
mutation SetStockLocationPickup($input: SetStockLocationPickupInput!) {
|
|
68
|
+
setStockLocationPickup(input: $input) { ${STOCK_LOCATION_PICKUP_FIELDS} }
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
48
71
|
export function createLocationsModule(transport) {
|
|
49
72
|
return {
|
|
50
73
|
async list(options) {
|
|
@@ -68,5 +91,13 @@ export function createLocationsModule(transport) {
|
|
|
68
91
|
const data = await transport.graphql({ api: 'admin', query: DELETE_LOCATION_PROFILE_MUTATION, variables: { stockLocationId } }, options);
|
|
69
92
|
return data.deleteLocationProfile;
|
|
70
93
|
},
|
|
94
|
+
async pickup(stockLocationId, options) {
|
|
95
|
+
const data = await transport.graphql({ api: 'admin', query: STOCK_LOCATION_PICKUP_QUERY, variables: { stockLocationId } }, options);
|
|
96
|
+
return data.stockLocationPickup;
|
|
97
|
+
},
|
|
98
|
+
async setPickup(input, options) {
|
|
99
|
+
const data = await transport.graphql({ api: 'admin', query: SET_STOCK_LOCATION_PICKUP_MUTATION, variables: { input } }, options);
|
|
100
|
+
return data.setStockLocationPickup;
|
|
101
|
+
},
|
|
71
102
|
};
|
|
72
103
|
}
|
package/dist/meta/index.d.ts
CHANGED
|
@@ -39,6 +39,11 @@ export interface MetaCatalogLabels {
|
|
|
39
39
|
auditCallOutcome: LabelMap;
|
|
40
40
|
/** Who sends a notification event's email: `platform` or `none` (`admin.tenant.notifications`). */
|
|
41
41
|
notificationSender: LabelMap;
|
|
42
|
+
/**
|
|
43
|
+
* A supplier purchase order's status (`admin.purchasing.purchaseOrders`). Served by a platform
|
|
44
|
+
* with purchase orders; absent before.
|
|
45
|
+
*/
|
|
46
|
+
purchaseOrderStatus?: LabelMap;
|
|
42
47
|
/**
|
|
43
48
|
* A vocabulary added after this SDK release arrives camelised, with its map
|
|
44
49
|
* untouched.
|
|
@@ -54,6 +59,12 @@ export interface MetaCatalogTransitions {
|
|
|
54
59
|
* UNRANKED, so it is absent — treat "no rank" as "no forward move", never 0.
|
|
55
60
|
*/
|
|
56
61
|
fulfillmentRank: Record<string, number>;
|
|
62
|
+
/**
|
|
63
|
+
* A supplier purchase order's lifecycle (`admin.purchasing.purchaseOrders`): `cancelled` is
|
|
64
|
+
* terminal, `closed` moves only back to `sent`. Served by a platform with purchase orders;
|
|
65
|
+
* absent before.
|
|
66
|
+
*/
|
|
67
|
+
purchaseOrder?: TransitionMap;
|
|
57
68
|
[extra: string]: unknown;
|
|
58
69
|
}
|
|
59
70
|
export interface PermissionGroup {
|
|
@@ -108,6 +119,12 @@ export interface MetaCatalogPermissions {
|
|
|
108
119
|
export interface PluginCatalogEntry {
|
|
109
120
|
key: string;
|
|
110
121
|
name: string;
|
|
122
|
+
/**
|
|
123
|
+
* One sentence on what the plugin does, in merchant English: the words the
|
|
124
|
+
* platform's own dashboard shows beside the name. Served by a platform from
|
|
125
|
+
* this release on.
|
|
126
|
+
*/
|
|
127
|
+
description: string;
|
|
111
128
|
group: string;
|
|
112
129
|
/** `system` plugins are always on; `external` ones need an entitlement. */
|
|
113
130
|
kind: string;
|
|
@@ -117,6 +134,142 @@ export interface MetaCatalogPlugins {
|
|
|
117
134
|
groupLabels: Record<string, string>;
|
|
118
135
|
[extra: string]: unknown;
|
|
119
136
|
}
|
|
137
|
+
/** Which API a plugin settings input is written through. */
|
|
138
|
+
export type PluginConfigWriteApi = 'admin-graphql' | 'plugins-rest';
|
|
139
|
+
/**
|
|
140
|
+
* How a secret property of a plugin settings schema behaves on READ, carried
|
|
141
|
+
* as the schema property's `x-secret` keyword beside `writeOnly: true`:
|
|
142
|
+
*
|
|
143
|
+
* - `masked-roundtrip`: the config read returns a masked preview (named in
|
|
144
|
+
* {@link PluginConfigRead.fields}); sending that preview back unchanged, or
|
|
145
|
+
* leaving the property out, keeps the stored secret. A BLANK is not the same
|
|
146
|
+
* everywhere: it keeps the Tikkie credentials but REMOVES the till's Mollie
|
|
147
|
+
* key, so read the property's `description` before sending one;
|
|
148
|
+
* - `write-only`: no value the read returns may be sent back. A masked preview
|
|
149
|
+
* may exist for display, but the platform would store it AS the secret, so
|
|
150
|
+
* never pre-fill the field;
|
|
151
|
+
* - `server-generated`: the platform mints it; a head shows it, never asks for it.
|
|
152
|
+
*/
|
|
153
|
+
export type PluginConfigSecret = 'masked-roundtrip' | 'write-only' | 'server-generated';
|
|
154
|
+
/** The operation that writes a settings input. */
|
|
155
|
+
export interface PluginConfigWrite {
|
|
156
|
+
api: PluginConfigWriteApi;
|
|
157
|
+
/** The Admin API mutation (`admin-graphql`), or `METHOD /path` on the plugins service. */
|
|
158
|
+
operation: string;
|
|
159
|
+
/**
|
|
160
|
+
* The mutation argument that takes the input type named by
|
|
161
|
+
* {@link PluginConfigInput.name}, e.g. `input`. Absent when the mutation takes
|
|
162
|
+
* its settings as INLINE arguments (then `name` is the operation itself and the
|
|
163
|
+
* schema's properties are the argument names), and absent for a REST body.
|
|
164
|
+
*/
|
|
165
|
+
argument?: string;
|
|
166
|
+
/**
|
|
167
|
+
* The field of the argument's input object that takes the schema's
|
|
168
|
+
* properties, when they are only PART of a wider input: the SEO plugin's
|
|
169
|
+
* Channel defaults go in `updateChannel(input: { id, customFields: { … } })`
|
|
170
|
+
* under `customFields`. That schema lists only its own fields and stays open
|
|
171
|
+
* to the rest (other forms' fields), and {@link key} is then a field of the
|
|
172
|
+
* argument object (`input.id`). Absent: the argument IS the input. Served by a
|
|
173
|
+
* platform from this release on.
|
|
174
|
+
*/
|
|
175
|
+
field?: string;
|
|
176
|
+
/**
|
|
177
|
+
* For a plugin whose settings are a COLLECTION of records (email gateways,
|
|
178
|
+
* product feeds): what names the record this input changes. The mutation
|
|
179
|
+
* argument sent beside {@link argument} (`updateEmailGateway(id:, input:)`);
|
|
180
|
+
* with {@link field}, a field of the argument object; for a REST write, the
|
|
181
|
+
* path parameter of `operation` (`PATCH /feeds/configs/:id` → `id`). Absent
|
|
182
|
+
* for a create and for settings that are one record per store, and for an
|
|
183
|
+
* input that names its record by a property of its own (`paymentMethodCode`,
|
|
184
|
+
* which {@link PluginConfigRead.fields} pre-fills). Served by a platform from
|
|
185
|
+
* this release on.
|
|
186
|
+
*/
|
|
187
|
+
key?: string;
|
|
188
|
+
}
|
|
189
|
+
/** The read that pre-fills a form for this input. */
|
|
190
|
+
export interface PluginConfigRead {
|
|
191
|
+
/** The Admin API query (or `GET /path`) that returns the stored config. */
|
|
192
|
+
operation: string;
|
|
193
|
+
/**
|
|
194
|
+
* The field of the read's answer that holds {@link fields}, when they are
|
|
195
|
+
* nested: `activeChannel { customFields { … } }` → `customFields`. Absent: the
|
|
196
|
+
* answer itself holds them. Served by a platform from this release on.
|
|
197
|
+
*/
|
|
198
|
+
field?: string;
|
|
199
|
+
/** The permission the read needs; not always the write's. */
|
|
200
|
+
permission: string;
|
|
201
|
+
/**
|
|
202
|
+
* EVERY permission that allows the read, {@link permission} first, when there
|
|
203
|
+
* is more than one: holding any one of them is enough. Absent when
|
|
204
|
+
* `permission` is the only one, so read `permissions ?? [permission]`. Served
|
|
205
|
+
* by a platform from this release on.
|
|
206
|
+
*/
|
|
207
|
+
permissions?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* For a collection: the query argument (for a REST read, the path parameter
|
|
210
|
+
* of {@link operation}) that names the record to read, e.g. `id`. Served by a
|
|
211
|
+
* platform from this release on.
|
|
212
|
+
*/
|
|
213
|
+
key?: string;
|
|
214
|
+
/**
|
|
215
|
+
* For a collection: the query that lists every record. Each item reads like
|
|
216
|
+
* {@link operation}'s answer, and its field named like {@link key} is the
|
|
217
|
+
* value {@link key} takes (`id`; `paymentMethodCode` for a payment provider).
|
|
218
|
+
* A REST list is `GET /path` answering a cursor page: the items in `data`, the
|
|
219
|
+
* next page through `pagination.next_cursor`. Served by a platform from this
|
|
220
|
+
* release on.
|
|
221
|
+
*/
|
|
222
|
+
list?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Schema property → the field of the read that pre-fills it, keyed by DATA
|
|
225
|
+
* (the schema's own property names). A property absent here has nothing to
|
|
226
|
+
* pre-fill: a write-only secret, or a value the read does not return. A read
|
|
227
|
+
* field that is null pre-fills nothing either: leave the property out, which
|
|
228
|
+
* keeps the stored value. Projected that way, a read validates against the
|
|
229
|
+
* schema once any required write-only secret is typed in. For a
|
|
230
|
+
* `plugins-rest` input both sides are the route's WIRE names
|
|
231
|
+
* (`language_code`); this SDK's typed modules over those routes
|
|
232
|
+
* (`admin.feeds.get`) camelise top-level keys, so map them back, or call the
|
|
233
|
+
* route in wire form.
|
|
234
|
+
*/
|
|
235
|
+
fields: Record<string, string>;
|
|
236
|
+
}
|
|
237
|
+
/** One settings input of a plugin: what to send, where, and who may send it. */
|
|
238
|
+
export interface PluginConfigInput {
|
|
239
|
+
/**
|
|
240
|
+
* The GraphQL input type (or REST DTO) the schema describes, e.g.
|
|
241
|
+
* `UpdateHendriksConfigInput`; for a mutation that takes inline arguments
|
|
242
|
+
* (`write.argument` absent), the operation itself, e.g. `setMyparcelEnabled`.
|
|
243
|
+
*/
|
|
244
|
+
name: string;
|
|
245
|
+
write: PluginConfigWrite;
|
|
246
|
+
/** `null` when no read returns this input's values. */
|
|
247
|
+
read: PluginConfigRead | null;
|
|
248
|
+
/** The permission the write needs on the active store. */
|
|
249
|
+
permission: string;
|
|
250
|
+
/**
|
|
251
|
+
* EVERY permission that allows the write, {@link permission} first, when there
|
|
252
|
+
* is more than one: holding any one of them is enough (POS receipt numbering
|
|
253
|
+
* takes `UpdateSettings` or `ManagePosDevices`). Absent when `permission` is
|
|
254
|
+
* the only one, so read `permissions ?? [permission]`. Served by a platform
|
|
255
|
+
* from this release on.
|
|
256
|
+
*/
|
|
257
|
+
permissions?: string[];
|
|
258
|
+
/**
|
|
259
|
+
* Draft 2020-12 JSON Schema of the input. It states only what the platform
|
|
260
|
+
* enforces on write: schema-valid means "worth sending", not "certain to be
|
|
261
|
+
* accepted" (a refusal can depend on stored state, e.g. enabling before a
|
|
262
|
+
* credential exists). Property names are the API's own and are never
|
|
263
|
+
* camelised. A secret carries `writeOnly: true` and `x-secret`. A write the
|
|
264
|
+
* platform deprecates (the legacy Mollie/Stripe key door) carries the
|
|
265
|
+
* standard `deprecated: true`.
|
|
266
|
+
*/
|
|
267
|
+
schema: JsonSchema;
|
|
268
|
+
}
|
|
269
|
+
/** Every settings input one plugin takes. */
|
|
270
|
+
export interface PluginConfigSchemas {
|
|
271
|
+
inputs: PluginConfigInput[];
|
|
272
|
+
}
|
|
120
273
|
export interface MetaCatalog {
|
|
121
274
|
/**
|
|
122
275
|
* A short hash of everything else. It changes only when the catalog's content
|
|
@@ -138,6 +291,15 @@ export interface MetaCatalog {
|
|
|
138
291
|
* shape.
|
|
139
292
|
*/
|
|
140
293
|
settingsSchemas: Record<string, JsonSchema>;
|
|
294
|
+
/**
|
|
295
|
+
* JSON Schema of each plugin's settings inputs, keyed by PLUGIN KEY
|
|
296
|
+
* (`payment-links`, `external-tracking`, …, as in `plugins.catalog`), so a
|
|
297
|
+
* head can render a plugin's settings form from data. Everything below the
|
|
298
|
+
* plugin key, the schemas included, arrives exactly as the platform spells
|
|
299
|
+
* it. A plugin with no entry has no per-store settings at all (search,
|
|
300
|
+
* warehouse, stored value). Served by a platform from this release on.
|
|
301
|
+
*/
|
|
302
|
+
pluginConfigSchemas: Record<string, PluginConfigSchemas>;
|
|
141
303
|
/**
|
|
142
304
|
* A member added after this SDK release arrives with its NAME camelised and
|
|
143
305
|
* its contents untouched — the half that matters, since a member this build
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `admin.orders.bulk`, `admin.orders.bulkRun` and `admin.orders.delete` (headless spec §7
|
|
3
|
+
* `orders.bulk`, plan W9-43; rulings G19, G28, G29).
|
|
4
|
+
*/
|
|
5
|
+
import { type Transport } from '@sixtyninecommerce/core';
|
|
6
|
+
import { type BulkActionItem, type BulkActionRun } from '../jobs/bulk-action-run.js';
|
|
7
|
+
import type { JobHandle } from '../jobs/index.js';
|
|
8
|
+
import type { Call } from '../types.js';
|
|
9
|
+
/** What each order of one bulk run gets. */
|
|
10
|
+
export type OrderBulkAction = 'TRANSITION' | 'CANCEL' | 'DELETE' | 'MARK_PAID';
|
|
11
|
+
export declare const ORDER_BULK_ACTIONS: readonly OrderBulkAction[];
|
|
12
|
+
/** The engine's bound on one bulk run (`MAX_BULK_ACTION_ITEMS`). Split a larger selection. */
|
|
13
|
+
export declare const MAX_BULK_ORDERS = 50;
|
|
14
|
+
/**
|
|
15
|
+
* The states a TRANSITION never names, each with its own action or door: `Cancelled` (CANCEL),
|
|
16
|
+
* `PaymentSettled` (MARK_PAID), `Modifying` (the order edit) and `AddingItems`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ORDER_BULK_TRANSITION_REFUSED: readonly string[];
|
|
19
|
+
export interface OrderBulkInput {
|
|
20
|
+
action: OrderBulkAction;
|
|
21
|
+
/** 1 to {@link MAX_BULK_ORDERS} orders of the store, each named once. */
|
|
22
|
+
orderIds: readonly string[];
|
|
23
|
+
/** TRANSITION only, and required there: the state each order moves to. */
|
|
24
|
+
toState?: string;
|
|
25
|
+
/** CANCEL only: the reason recorded on each cancelled order. */
|
|
26
|
+
reason?: string;
|
|
27
|
+
}
|
|
28
|
+
/** One payment a MARK_PAID item acted on. */
|
|
29
|
+
export interface OrderBulkCapture {
|
|
30
|
+
paymentId: string;
|
|
31
|
+
/** The payment's state after the capture: `Settled`, or what a decline left. */
|
|
32
|
+
state: string;
|
|
33
|
+
/**
|
|
34
|
+
* Why it was not captured, null when it was: `SETTLE_PAYMENT_ERROR` (declined; `message`
|
|
35
|
+
* quotes the provider), `PAYMENT_NOT_AUTHORIZED` (captured by someone else meanwhile),
|
|
36
|
+
* `PAYMENT_METHOD_UNAVAILABLE` (its method is switched off, not on this store, or no longer installed; nothing asked),
|
|
37
|
+
* `IDEMPOTENCY_IN_PROGRESS` (a capture under the same request may still run: check the order
|
|
38
|
+
* before trying again), `IDEMPOTENCY_OUTCOME_UNKNOWN` (the provider was asked and its answer
|
|
39
|
+
* was lost: reconcile with the provider, never retry blind), or a fault's code.
|
|
40
|
+
*/
|
|
41
|
+
code: string | null;
|
|
42
|
+
message: string | null;
|
|
43
|
+
}
|
|
44
|
+
/** One order's outcome. */
|
|
45
|
+
export interface OrderBulkItem extends BulkActionItem {
|
|
46
|
+
/**
|
|
47
|
+
* When `code` is `ORDER_ACTION_UNAVAILABLE`: why the order's own status (`orders.status`) did
|
|
48
|
+
* not offer the action, in that read's vocabulary (`STATE`, `INVOICE_LOCKED`, `SHOPPER_CART`,
|
|
49
|
+
* `HAS_RECORDS`, `UNITS_SHIPPED`, `ACTIVE_FULFILLMENT`, `NOTHING_TO_CANCEL`, …). Null otherwise.
|
|
50
|
+
*/
|
|
51
|
+
reasonCode: string | null;
|
|
52
|
+
/** MARK_PAID: each payment the order's item acted on, in order. Null for other actions. */
|
|
53
|
+
captured: OrderBulkCapture[] | null;
|
|
54
|
+
}
|
|
55
|
+
/** A bulk order run, as `wait()` and `bulkRun()` answer it. */
|
|
56
|
+
export type OrderBulkRun = Omit<BulkActionRun<OrderBulkAction>, 'items'> & {
|
|
57
|
+
items: OrderBulkItem[];
|
|
58
|
+
};
|
|
59
|
+
export declare const BULK_ORDER_ACTION_MUTATION = "\n mutation BulkOrderAction($input: BulkOrderActionInput!, $idempotencyKey: String) {\n bulkOrderAction(input: $input, idempotencyKey: $idempotencyKey) {\n runId\n }\n }\n";
|
|
60
|
+
/**
|
|
61
|
+
* The run read with the order fields. Its own document, so `catalog.products.bulkRun` keeps
|
|
62
|
+
* selecting only what an engine without the orders kind has.
|
|
63
|
+
*/
|
|
64
|
+
export declare const ORDER_BULK_RUN_QUERY = "\n query OrderBulkRun($runId: ID!) {\n bulkActionRun(runId: $runId) {\n id\n kind\n action\n status\n total\n done\n items {\n id\n status\n code\n message\n newId\n reasonCode\n captured {\n paymentId\n state\n code\n message\n }\n }\n failure {\n code\n message\n }\n }\n }\n";
|
|
65
|
+
export declare const DELETE_ORDER_MUTATION = "\n mutation DeleteOrder($orderId: ID!) {\n deleteOrder(orderId: $orderId) {\n result\n message\n }\n }\n";
|
|
66
|
+
/** One read of a bulk order run. A run of another store, or a missing one, is `NotFoundError`. */
|
|
67
|
+
export declare function readOrderBulkRun(transport: Transport, runId: string, options?: Call): Promise<OrderBulkRun>;
|
|
68
|
+
/** `orders.bulk`; see `OrdersModule.bulk`. */
|
|
69
|
+
export declare function bulkOrders(transport: Transport, input: OrderBulkInput, options?: Call): Promise<JobHandle<OrderBulkRun>>;
|
|
70
|
+
/**
|
|
71
|
+
* `orders.delete`; see `OrdersModule.delete`. The engine's `NOT_DELETED` is raised as every other
|
|
72
|
+
* `*_NOT_DELETED` refusal of this SDK is (`assertDeleted`): a `ConflictError` with the engine's own
|
|
73
|
+
* reason.
|
|
74
|
+
*/
|
|
75
|
+
export declare function deleteOrder(transport: Transport, orderId: string, options?: Call): Promise<void>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `admin.orders.bulk`, `admin.orders.bulkRun` and `admin.orders.delete` (headless spec §7
|
|
3
|
+
* `orders.bulk`, plan W9-43; rulings G19, G28, G29).
|
|
4
|
+
*/
|
|
5
|
+
import { idempotencyKey, ValidationError } from '@sixtyninecommerce/core';
|
|
6
|
+
import { assertDeleted, fieldOf } from '../catalog/types.js';
|
|
7
|
+
import { bulkActionHandle, } from '../jobs/bulk-action-run.js';
|
|
8
|
+
export const ORDER_BULK_ACTIONS = [
|
|
9
|
+
'TRANSITION',
|
|
10
|
+
'CANCEL',
|
|
11
|
+
'DELETE',
|
|
12
|
+
'MARK_PAID',
|
|
13
|
+
];
|
|
14
|
+
/** The engine's bound on one bulk run (`MAX_BULK_ACTION_ITEMS`). Split a larger selection. */
|
|
15
|
+
export const MAX_BULK_ORDERS = 50;
|
|
16
|
+
/**
|
|
17
|
+
* The states a TRANSITION never names, each with its own action or door: `Cancelled` (CANCEL),
|
|
18
|
+
* `PaymentSettled` (MARK_PAID), `Modifying` (the order edit) and `AddingItems`.
|
|
19
|
+
*/
|
|
20
|
+
export const ORDER_BULK_TRANSITION_REFUSED = [
|
|
21
|
+
'Cancelled',
|
|
22
|
+
'PaymentSettled',
|
|
23
|
+
'Modifying',
|
|
24
|
+
'AddingItems',
|
|
25
|
+
];
|
|
26
|
+
export const BULK_ORDER_ACTION_MUTATION = /* GraphQL */ `
|
|
27
|
+
mutation BulkOrderAction($input: BulkOrderActionInput!, $idempotencyKey: String) {
|
|
28
|
+
bulkOrderAction(input: $input, idempotencyKey: $idempotencyKey) {
|
|
29
|
+
runId
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
/**
|
|
34
|
+
* The run read with the order fields. Its own document, so `catalog.products.bulkRun` keeps
|
|
35
|
+
* selecting only what an engine without the orders kind has.
|
|
36
|
+
*/
|
|
37
|
+
export const ORDER_BULK_RUN_QUERY = /* GraphQL */ `
|
|
38
|
+
query OrderBulkRun($runId: ID!) {
|
|
39
|
+
bulkActionRun(runId: $runId) {
|
|
40
|
+
id
|
|
41
|
+
kind
|
|
42
|
+
action
|
|
43
|
+
status
|
|
44
|
+
total
|
|
45
|
+
done
|
|
46
|
+
items {
|
|
47
|
+
id
|
|
48
|
+
status
|
|
49
|
+
code
|
|
50
|
+
message
|
|
51
|
+
newId
|
|
52
|
+
reasonCode
|
|
53
|
+
captured {
|
|
54
|
+
paymentId
|
|
55
|
+
state
|
|
56
|
+
code
|
|
57
|
+
message
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
failure {
|
|
61
|
+
code
|
|
62
|
+
message
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
export const DELETE_ORDER_MUTATION = /* GraphQL */ `
|
|
68
|
+
mutation DeleteOrder($orderId: ID!) {
|
|
69
|
+
deleteOrder(orderId: $orderId) {
|
|
70
|
+
result
|
|
71
|
+
message
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
function refuse(message) {
|
|
76
|
+
return new ValidationError({
|
|
77
|
+
code: 'BULK_ACTION_INPUT_INVALID',
|
|
78
|
+
message,
|
|
79
|
+
status: 400,
|
|
80
|
+
service: 'vendure',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/** The engine's own checks of a submit (`BULK_ACTION_INPUT_INVALID`), before sending. */
|
|
84
|
+
function assertBulkInput(input) {
|
|
85
|
+
if (!ORDER_BULK_ACTIONS.includes(input?.action)) {
|
|
86
|
+
throw refuse(`"${String(input?.action)}" is not a bulk order action: ${ORDER_BULK_ACTIONS.join(', ')}. Nothing was sent.`);
|
|
87
|
+
}
|
|
88
|
+
const ids = input.orderIds;
|
|
89
|
+
if (!Array.isArray(ids) || ids.length === 0) {
|
|
90
|
+
throw refuse('Name at least one order. Nothing was sent.');
|
|
91
|
+
}
|
|
92
|
+
if (ids.length > MAX_BULK_ORDERS) {
|
|
93
|
+
throw refuse(`Name at most ${String(MAX_BULK_ORDERS)} orders in one bulk action; this one named ${String(ids.length)}. Split the selection into several actions. Nothing was sent.`);
|
|
94
|
+
}
|
|
95
|
+
if (new Set(ids.map((id) => String(id).toLowerCase())).size !== ids.length) {
|
|
96
|
+
throw refuse('The selection names an order more than once. Name each order once. Nothing was sent.');
|
|
97
|
+
}
|
|
98
|
+
const toState = input.toState?.trim() ?? '';
|
|
99
|
+
if (input.action === 'TRANSITION') {
|
|
100
|
+
if (toState === '')
|
|
101
|
+
throw refuse('Name the status to move the orders to. Nothing was sent.');
|
|
102
|
+
if (ORDER_BULK_TRANSITION_REFUSED.includes(toState)) {
|
|
103
|
+
throw refuse(`Orders are not moved to "${toState}" by a status change${toState === 'Cancelled'
|
|
104
|
+
? ': use CANCEL'
|
|
105
|
+
: toState === 'PaymentSettled'
|
|
106
|
+
? ': use MARK_PAID'
|
|
107
|
+
: ''}. Nothing was sent.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (toState !== '') {
|
|
111
|
+
throw refuse(`toState is only for TRANSITION, not ${input.action}. Nothing was sent.`);
|
|
112
|
+
}
|
|
113
|
+
if ((input.reason?.trim() ?? '') !== '' && input.action !== 'CANCEL') {
|
|
114
|
+
throw refuse(`reason is only for CANCEL, not ${input.action}. Nothing was sent.`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** One read of a bulk order run. A run of another store, or a missing one, is `NotFoundError`. */
|
|
118
|
+
export function readOrderBulkRun(transport, runId, options) {
|
|
119
|
+
return fieldOf(transport, ORDER_BULK_RUN_QUERY, 'bulkActionRun', { runId }, options);
|
|
120
|
+
}
|
|
121
|
+
/** `orders.bulk`; see `OrdersModule.bulk`. */
|
|
122
|
+
export async function bulkOrders(transport, input, options) {
|
|
123
|
+
assertBulkInput(input);
|
|
124
|
+
// Minted when the caller gave none, so a retry of THIS call answers the same run instead of
|
|
125
|
+
// starting a second one (and capturing nothing twice).
|
|
126
|
+
const key = options?.idempotencyKey ?? idempotencyKey();
|
|
127
|
+
const toState = input.toState?.trim();
|
|
128
|
+
const reason = input.reason?.trim();
|
|
129
|
+
const { runId } = await fieldOf(transport, BULK_ORDER_ACTION_MUTATION, 'bulkOrderAction', {
|
|
130
|
+
input: {
|
|
131
|
+
action: input.action,
|
|
132
|
+
orderIds: [...input.orderIds],
|
|
133
|
+
// Omitted, never null, when not given: an absent option stays off the wire.
|
|
134
|
+
...(toState ? { toState } : {}),
|
|
135
|
+
...(reason ? { reason } : {}),
|
|
136
|
+
},
|
|
137
|
+
idempotencyKey: key,
|
|
138
|
+
}, { ...options, idempotencyKey: key });
|
|
139
|
+
return bulkActionHandle(transport, runId, options, (id, call) => readOrderBulkRun(transport, id, call));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* `orders.delete`; see `OrdersModule.delete`. The engine's `NOT_DELETED` is raised as every other
|
|
143
|
+
* `*_NOT_DELETED` refusal of this SDK is (`assertDeleted`): a `ConflictError` with the engine's own
|
|
144
|
+
* reason.
|
|
145
|
+
*/
|
|
146
|
+
export async function deleteOrder(transport, orderId, options) {
|
|
147
|
+
assertDeleted('ORDER_NOT_DELETED', [
|
|
148
|
+
await fieldOf(transport, DELETE_ORDER_MUTATION, 'deleteOrder', { orderId }, options),
|
|
149
|
+
]);
|
|
150
|
+
}
|