@sixtyninecommerce/admin 0.8.0 → 0.10.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 +2739 -17
- package/dist/api-tokens/index.d.ts +15 -5
- package/dist/api-tokens/index.js +1 -0
- package/dist/apps/event-subscription.d.ts +59 -0
- package/dist/apps/event-subscription.js +32 -0
- package/dist/apps/hook-secret.d.ts +22 -0
- package/dist/apps/hook-secret.js +36 -0
- package/dist/apps/index.d.ts +54 -3
- package/dist/apps/index.js +17 -0
- package/dist/audit/index.d.ts +7 -0
- package/dist/auth/queries.d.ts +5 -1
- package/dist/auth/queries.js +6 -0
- package/dist/bulk/index.d.ts +323 -0
- package/dist/bulk/index.js +162 -0
- package/dist/catalog/assets.d.ts +147 -0
- package/dist/catalog/assets.js +164 -0
- package/dist/catalog/collections.d.ts +109 -0
- package/dist/catalog/collections.js +91 -0
- package/dist/catalog/facets.d.ts +103 -0
- package/dist/catalog/facets.js +100 -0
- package/dist/catalog/index.d.ts +115 -0
- package/dist/catalog/index.js +21 -0
- package/dist/catalog/options.d.ts +89 -0
- package/dist/catalog/options.js +88 -0
- package/dist/catalog/products-bulk.d.ts +21 -0
- package/dist/catalog/products-bulk.js +58 -0
- package/dist/catalog/products.d.ts +650 -0
- package/dist/catalog/products.js +458 -0
- package/dist/catalog/properties.d.ts +234 -0
- package/dist/catalog/properties.js +158 -0
- package/dist/catalog/types.d.ts +174 -0
- package/dist/catalog/types.js +141 -0
- package/dist/catalog/variants.d.ts +324 -0
- package/dist/catalog/variants.js +288 -0
- package/dist/catalog/visibility.d.ts +57 -0
- package/dist/catalog/visibility.js +59 -0
- package/dist/client.d.ts +192 -3
- package/dist/client.js +87 -12
- package/dist/compliance/index.d.ts +88 -0
- package/dist/compliance/index.js +88 -0
- package/dist/customer-data-redaction.d.ts +14 -0
- package/dist/customer-data-redaction.js +22 -0
- package/dist/customers/index.d.ts +428 -17
- package/dist/customers/index.js +322 -15
- package/dist/documents/index.d.ts +513 -16
- package/dist/documents/index.js +229 -3
- package/dist/events/index.d.ts +259 -0
- package/dist/events/index.js +147 -0
- package/dist/feeds/ai.d.ts +46 -0
- package/dist/feeds/ai.js +43 -0
- package/dist/feeds/categories.d.ts +50 -0
- package/dist/feeds/categories.js +56 -0
- package/dist/feeds/configs.d.ts +54 -0
- package/dist/feeds/configs.js +85 -0
- package/dist/feeds/identifier-fields.d.ts +25 -0
- package/dist/feeds/identifier-fields.js +29 -0
- package/dist/feeds/index.d.ts +54 -0
- package/dist/feeds/index.js +46 -0
- package/dist/feeds/preserve.d.ts +38 -0
- package/dist/feeds/preserve.js +74 -0
- package/dist/feeds/rules.d.ts +42 -0
- package/dist/feeds/rules.js +56 -0
- package/dist/feeds/types.d.ts +654 -0
- package/dist/feeds/types.js +135 -0
- package/dist/fulfillments/index.d.ts +437 -0
- package/dist/fulfillments/index.js +534 -0
- package/dist/heads/index.d.ts +60 -0
- package/dist/heads/index.js +45 -0
- package/dist/hooks/assignments.d.ts +90 -0
- package/dist/hooks/assignments.js +53 -0
- package/dist/hooks/index.d.ts +97 -0
- package/dist/hooks/index.js +76 -0
- package/dist/index.d.ts +95 -9
- package/dist/index.js +21 -1
- package/dist/integrations/index.d.ts +14 -0
- package/dist/integrations/index.js +9 -0
- package/dist/integrations/pipelines.d.ts +113 -0
- package/dist/integrations/pipelines.js +62 -0
- package/dist/integrations/types.d.ts +176 -0
- package/dist/integrations/types.js +8 -0
- package/dist/jobs/bulk-action-run.d.ts +74 -0
- package/dist/jobs/bulk-action-run.js +69 -0
- package/dist/locations/index.d.ts +6 -2
- package/dist/meta/index.d.ts +32 -0
- package/dist/orders/bulk.d.ts +75 -0
- package/dist/orders/bulk.js +150 -0
- package/dist/orders/commit-edit.d.ts +123 -0
- package/dist/orders/commit-edit.js +142 -0
- package/dist/orders/deposit-policy.d.ts +103 -0
- package/dist/orders/deposit-policy.js +202 -0
- package/dist/orders/get.d.ts +722 -0
- package/dist/orders/get.js +530 -0
- package/dist/orders/index.d.ts +186 -21
- package/dist/orders/index.js +57 -0
- package/dist/orders/line-price-preview.d.ts +297 -0
- package/dist/orders/line-price-preview.js +50 -0
- package/dist/orders/manual-discounts.d.ts +141 -0
- package/dist/orders/manual-discounts.js +97 -0
- package/dist/orders/manual-pricing.d.ts +192 -0
- package/dist/orders/manual-pricing.js +72 -0
- package/dist/orders/order-entry.d.ts +566 -0
- package/dist/orders/order-entry.js +129 -0
- package/dist/orders/parcel-charge.d.ts +45 -0
- package/dist/orders/parcel-charge.js +55 -0
- package/dist/orders/plan-edit.d.ts +489 -0
- package/dist/orders/plan-edit.js +93 -0
- package/dist/orders/status.d.ts +235 -0
- package/dist/orders/status.js +96 -0
- package/dist/orders/surcharges.d.ts +75 -2
- package/dist/orders/surcharges.js +110 -4
- package/dist/payments/account-credit.d.ts +171 -0
- package/dist/payments/account-credit.js +107 -0
- package/dist/payments/index.d.ts +241 -9
- package/dist/payments/index.js +92 -0
- package/dist/payments/methods.d.ts +37 -0
- package/dist/payments/methods.js +33 -0
- package/dist/platform/catalog.d.ts +148 -0
- package/dist/platform/catalog.js +74 -0
- package/dist/platform/entitlements.d.ts +111 -0
- package/dist/platform/entitlements.js +86 -0
- package/dist/platform/legal-entities.d.ts +139 -0
- package/dist/platform/legal-entities.js +126 -0
- package/dist/platform/legal-entity-numbering.d.ts +103 -0
- package/dist/platform/legal-entity-numbering.js +101 -0
- package/dist/platform/organization-membership.d.ts +80 -0
- package/dist/platform/organization-membership.js +71 -0
- package/dist/platform/organization-settings.d.ts +33 -0
- package/dist/platform/organization-settings.js +42 -0
- package/dist/platform/organization-sharing.d.ts +172 -0
- package/dist/platform/organization-sharing.js +120 -0
- package/dist/platform/organizations.d.ts +205 -0
- package/dist/platform/organizations.js +180 -0
- package/dist/platform/provision-store.d.ts +88 -8
- package/dist/platform/provision-store.js +12 -0
- package/dist/platform/reports.d.ts +46 -0
- package/dist/platform/reports.js +31 -0
- package/dist/platform/server-metrics.d.ts +58 -0
- package/dist/platform/server-metrics.js +11 -0
- package/dist/pos/index.d.ts +567 -0
- package/dist/pos/index.js +205 -0
- package/dist/pricing/index.d.ts +408 -0
- package/dist/pricing/index.js +353 -0
- package/dist/pricing/vouchers.d.ts +103 -0
- package/dist/pricing/vouchers.js +69 -0
- package/dist/provenance/index.d.ts +93 -0
- package/dist/provenance/index.js +53 -0
- package/dist/reports/index.d.ts +199 -0
- package/dist/reports/index.js +154 -0
- package/dist/returns/index.d.ts +225 -0
- package/dist/returns/index.js +160 -0
- package/dist/search/index.d.ts +99 -0
- package/dist/search/index.js +62 -0
- package/dist/shipping/parcel-count-suggestion.d.ts +52 -0
- package/dist/shipping/parcel-count-suggestion.js +73 -0
- package/dist/shipping/parcel-rule.d.ts +48 -0
- package/dist/shipping/parcel-rule.js +91 -0
- package/dist/stock/index.d.ts +166 -0
- package/dist/stock/index.js +115 -0
- package/dist/stock/transfers.d.ts +520 -0
- package/dist/stock/transfers.js +437 -0
- package/dist/stored-value/index.d.ts +154 -0
- package/dist/stored-value/index.js +130 -0
- package/dist/tenant/capabilities.d.ts +10 -0
- package/dist/tenant/entitlements.d.ts +35 -0
- package/dist/tenant/entitlements.js +15 -0
- package/dist/tenant/field-groups.d.ts +64 -0
- package/dist/tenant/field-groups.js +34 -0
- package/dist/tenant/legal-entity.d.ts +32 -0
- package/dist/tenant/legal-entity.js +41 -0
- package/dist/tenant/notifications.d.ts +148 -0
- package/dist/tenant/notifications.js +79 -0
- package/dist/tenant/retention.d.ts +10 -4
- package/dist/tenant/settings-sources.d.ts +103 -0
- package/dist/tenant/settings-sources.js +92 -0
- package/dist/types.d.ts +86 -11
- package/dist/uploads/index.d.ts +11 -7
- package/dist/users/index.d.ts +104 -0
- package/dist/users/index.js +80 -0
- package/package.json +3 -2
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { createPage } from '@sixtyninecommerce/core';
|
|
2
|
+
const REGISTER_FIELDS = 'id stockLocationId name status createdAt updatedAt';
|
|
3
|
+
const TOTALS = 'cash card other refunds net saleCount';
|
|
4
|
+
const SESSION_FIELDS = `id registerId deviceId openedByStaffId openingFloat status expectedCash countedCash cashOverShort totals openedAt closedAt`;
|
|
5
|
+
const CART_FIELDS = `id code state currencyCode total totalWithTax couponCodes
|
|
6
|
+
lines { id quantity productVariant { id } linePriceWithTax }
|
|
7
|
+
surcharges { description sku price priceWithTax taxRate }`;
|
|
8
|
+
const TENDER_FIELDS = 'orderId paymentId covered outstanding change';
|
|
9
|
+
const DEVICE_FIELDS = 'id stockLocationId registerId label status paired lastSeenAt';
|
|
10
|
+
export const POS_REGISTERS_QUERY = `query PosRegisters { posRegisters { ${REGISTER_FIELDS} } }`;
|
|
11
|
+
export const POS_REGISTER_QUERY = `query PosRegister($id: ID!) { posRegister(id: $id) { ${REGISTER_FIELDS} } }`;
|
|
12
|
+
export const CREATE_POS_REGISTER_MUTATION = `mutation CreatePosRegister($input: CreatePosRegisterInput!) { createPosRegister(input: $input) { ${REGISTER_FIELDS} } }`;
|
|
13
|
+
export const UPDATE_POS_REGISTER_MUTATION = `mutation UpdatePosRegister($id: ID!, $input: UpdatePosRegisterInput!) { updatePosRegister(id: $id, input: $input) { ${REGISTER_FIELDS} } }`;
|
|
14
|
+
export const OPEN_POS_SESSION_MUTATION = `mutation OpenPosRegisterSession($input: OpenPosRegisterSessionInput!, $staffToken: String) { openPosRegisterSession(input: $input, staffToken: $staffToken) { ${SESSION_FIELDS} } }`;
|
|
15
|
+
export const CLOSE_POS_SESSION_MUTATION = `mutation ClosePosRegisterSession($input: ClosePosRegisterSessionInput!, $staffToken: String) { closePosRegisterSession(input: $input, staffToken: $staffToken) { ${SESSION_FIELDS} } }`;
|
|
16
|
+
export const POS_X_REPORT_QUERY = `query PosXReport($sessionId: ID!) { posXReport(sessionId: $sessionId) { sessionId openingFloat expectedCash movementCount totals { ${TOTALS} } } }`;
|
|
17
|
+
export const POS_SESSION_QUERY = `query PosRegisterSession($id: ID!) { posRegisterSession(id: $id) { ${SESSION_FIELDS} } }`;
|
|
18
|
+
export const RECORD_POS_CASH_MOVEMENT_MUTATION = `mutation RecordPosCashMovement($input: RecordPosCashMovementInput!, $staffToken: String) { recordPosCashMovement(input: $input, staffToken: $staffToken) { id sessionId type amount reason orderId createdAt } }`;
|
|
19
|
+
export const POS_CREATE_CART_MUTATION = `mutation PosCreateCart($registerId: ID) { posCreateCart(registerId: $registerId) { ${CART_FIELDS} } }`;
|
|
20
|
+
export const POS_ADD_ITEM_MUTATION = `mutation PosAddItem($input: PosAddItemInput!) { posAddItem(input: $input) { ${CART_FIELDS} } }`;
|
|
21
|
+
export const POS_APPLY_DISCOUNT_MUTATION = `mutation PosApplyDiscount($input: PosApplyDiscountInput!, $staffToken: String) { posApplyDiscount(input: $input, staffToken: $staffToken) { ${CART_FIELDS} } }`;
|
|
22
|
+
export const POS_APPLY_COUPON_CODE_MUTATION = `mutation PosApplyCouponCode($input: PosCouponCodeInput!) { posApplyCouponCode(input: $input) { ${CART_FIELDS} } }`;
|
|
23
|
+
export const POS_REMOVE_COUPON_CODE_MUTATION = `mutation PosRemoveCouponCode($input: PosCouponCodeInput!) { posRemoveCouponCode(input: $input) { ${CART_FIELDS} } }`;
|
|
24
|
+
export const POS_COMPLETE_SALE_MUTATION = `mutation PosCompleteSale($input: PosCompleteSaleInput!, $staffToken: String) { posCompleteSale(input: $input, staffToken: $staffToken) { orderId orderCode receiptNumber state } }`;
|
|
25
|
+
export const POS_TENDER_CASH_MUTATION = `mutation PosTenderCash($input: PosTenderCashInput!, $staffToken: String) { posTenderCash(input: $input, staffToken: $staffToken) { ${TENDER_FIELDS} } }`;
|
|
26
|
+
export const POS_TENDER_CARD_MUTATION = `mutation PosTenderCard($input: PosTenderCardInput!, $staffToken: String) { posTenderCard(input: $input, staffToken: $staffToken) { ${TENDER_FIELDS} } }`;
|
|
27
|
+
export const POS_TENDER_STORED_VALUE_MUTATION = `mutation PosTenderStoredValue($input: PosTenderStoredValueInput!, $staffToken: String) { posTenderStoredValue(input: $input, staffToken: $staffToken) { ${TENDER_FIELDS} } }`;
|
|
28
|
+
export const POS_TENDER_MANUAL_MUTATION = `mutation PosTenderManual($input: PosTenderManualInput!, $staffToken: String) { posTenderManual(input: $input, staffToken: $staffToken) { ${TENDER_FIELDS} } }`;
|
|
29
|
+
export const POS_REFUND_MUTATION = `mutation PosRefund($input: PosRefundInput!, $staffToken: String) { posRefund(input: $input, staffToken: $staffToken) { orderId refundId state } }`;
|
|
30
|
+
export const POS_DEVICES_QUERY = `query PosDevices { posDevices { ${DEVICE_FIELDS} } }`;
|
|
31
|
+
export const POS_DEVICE_QUERY = `query PosDevice($id: ID!) { posDevice(id: $id) { lastSeenAt } }`;
|
|
32
|
+
export const POS_PAIRING_CODE_MUTATION = `mutation GeneratePosPairingCode($deviceId: ID!) { generatePosPairingCode(deviceId: $deviceId) { code expiresAt } }`;
|
|
33
|
+
export const REVOKE_POS_DEVICE_MUTATION = `mutation RevokePosDevice($deviceId: ID!) { revokePosDevice(deviceId: $deviceId) { ${DEVICE_FIELDS} } }`;
|
|
34
|
+
export const POS_RECEIPT_NUMBERING_QUERY = `query PosReceiptNumberingConfig { posReceiptNumberingConfig { prefix suffix digits } }`;
|
|
35
|
+
export const UPDATE_POS_RECEIPT_NUMBERING_MUTATION = `mutation UpdatePosReceiptNumberingConfig($input: UpdatePosReceiptNumberingConfigInput!) { updatePosReceiptNumberingConfig(input: $input) { prefix suffix digits } }`;
|
|
36
|
+
function toCart(raw) {
|
|
37
|
+
return {
|
|
38
|
+
...raw,
|
|
39
|
+
lines: raw.lines.map((line) => ({
|
|
40
|
+
id: line.id,
|
|
41
|
+
quantity: line.quantity,
|
|
42
|
+
productVariantId: line.productVariant.id,
|
|
43
|
+
linePriceWithTax: line.linePriceWithTax,
|
|
44
|
+
})),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The wire answers `""` rather than null for a session a machine principal
|
|
49
|
+
* opened (the fields shipped `ID!`, and relaxing an output field breaks older
|
|
50
|
+
* consumers); this module's type says what that means.
|
|
51
|
+
*/
|
|
52
|
+
function toSession(raw) {
|
|
53
|
+
return { ...raw, deviceId: raw.deviceId || null, openedByStaffId: raw.openedByStaffId || null };
|
|
54
|
+
}
|
|
55
|
+
function wholeList(items) {
|
|
56
|
+
return createPage(items, { nextCursor: null, hasNext: false, total: items.length }, () => {
|
|
57
|
+
throw new Error('this list is returned whole; there is no next page');
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The key is a REQUIRED `String!` on the server; an empty one would be a
|
|
62
|
+
* GraphQL validation error that names no field a caller recognises, so it is
|
|
63
|
+
* refused here with the name of the option that was missing.
|
|
64
|
+
*/
|
|
65
|
+
function requireKey(options) {
|
|
66
|
+
const key = options?.idempotencyKey;
|
|
67
|
+
if (typeof key !== 'string' || key.trim() === '') {
|
|
68
|
+
throw new TypeError('A POS money call needs options.idempotencyKey (a fresh UUIDv7 per operation).');
|
|
69
|
+
}
|
|
70
|
+
return key;
|
|
71
|
+
}
|
|
72
|
+
export function createPosModule(transport) {
|
|
73
|
+
const gql = async (query, variables, options) => transport.graphql({ api: 'admin', query, variables }, options);
|
|
74
|
+
return {
|
|
75
|
+
registers: {
|
|
76
|
+
async list(options) {
|
|
77
|
+
const data = await gql(POS_REGISTERS_QUERY, {}, options);
|
|
78
|
+
return wholeList(data.posRegisters);
|
|
79
|
+
},
|
|
80
|
+
async get(id, options) {
|
|
81
|
+
const data = await gql(POS_REGISTER_QUERY, { id }, options);
|
|
82
|
+
return data.posRegister;
|
|
83
|
+
},
|
|
84
|
+
async create(input, options) {
|
|
85
|
+
const data = await gql(CREATE_POS_REGISTER_MUTATION, { input }, options);
|
|
86
|
+
return data.createPosRegister;
|
|
87
|
+
},
|
|
88
|
+
async update(id, input, options) {
|
|
89
|
+
const data = await gql(UPDATE_POS_REGISTER_MUTATION, { id, input }, options);
|
|
90
|
+
return data.updatePosRegister;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
sessions: {
|
|
94
|
+
async open(input, options) {
|
|
95
|
+
const data = await gql(OPEN_POS_SESSION_MUTATION, { input, staffToken: options?.staffToken }, options);
|
|
96
|
+
return toSession(data.openPosRegisterSession);
|
|
97
|
+
},
|
|
98
|
+
async close(input, options) {
|
|
99
|
+
const data = await gql(CLOSE_POS_SESSION_MUTATION, { input, staffToken: options?.staffToken }, options);
|
|
100
|
+
return toSession(data.closePosRegisterSession);
|
|
101
|
+
},
|
|
102
|
+
async xReport(sessionId, options) {
|
|
103
|
+
const data = await gql(POS_X_REPORT_QUERY, { sessionId }, options);
|
|
104
|
+
return data.posXReport;
|
|
105
|
+
},
|
|
106
|
+
async zReport(sessionId, options) {
|
|
107
|
+
const data = await gql(POS_SESSION_QUERY, { id: sessionId }, options);
|
|
108
|
+
return data.posRegisterSession && toSession(data.posRegisterSession);
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
cash: {
|
|
112
|
+
async record(input, options) {
|
|
113
|
+
const data = await gql(RECORD_POS_CASH_MOVEMENT_MUTATION, { input, staffToken: options?.staffToken }, options);
|
|
114
|
+
return data.recordPosCashMovement;
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
sale: {
|
|
118
|
+
async createCart(input, options) {
|
|
119
|
+
const data = await gql(POS_CREATE_CART_MUTATION, { registerId: input?.registerId }, options);
|
|
120
|
+
return toCart(data.posCreateCart);
|
|
121
|
+
},
|
|
122
|
+
async addItem(input, options) {
|
|
123
|
+
const data = await gql(POS_ADD_ITEM_MUTATION, { input }, options);
|
|
124
|
+
return toCart(data.posAddItem);
|
|
125
|
+
},
|
|
126
|
+
async applyDiscount(input, options) {
|
|
127
|
+
const data = await gql(POS_APPLY_DISCOUNT_MUTATION, {
|
|
128
|
+
input: { ...input, idempotencyKey: options?.idempotencyKey },
|
|
129
|
+
staffToken: options?.staffToken,
|
|
130
|
+
}, options);
|
|
131
|
+
return toCart(data.posApplyDiscount);
|
|
132
|
+
},
|
|
133
|
+
async applyCouponCode(input, options) {
|
|
134
|
+
const data = await gql(POS_APPLY_COUPON_CODE_MUTATION, { input: { ...input, idempotencyKey: options?.idempotencyKey } }, options);
|
|
135
|
+
return toCart(data.posApplyCouponCode);
|
|
136
|
+
},
|
|
137
|
+
async removeCouponCode(input, options) {
|
|
138
|
+
const data = await gql(POS_REMOVE_COUPON_CODE_MUTATION, { input: { ...input, idempotencyKey: options?.idempotencyKey } }, options);
|
|
139
|
+
return toCart(data.posRemoveCouponCode);
|
|
140
|
+
},
|
|
141
|
+
async complete(orderId, options) {
|
|
142
|
+
const idempotencyKey = requireKey(options);
|
|
143
|
+
const data = await gql(POS_COMPLETE_SALE_MUTATION, { input: { orderId, idempotencyKey }, staffToken: options.staffToken }, options);
|
|
144
|
+
return data.posCompleteSale;
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
tenders: {
|
|
148
|
+
async cash(input, options) {
|
|
149
|
+
const idempotencyKey = requireKey(options);
|
|
150
|
+
const data = await gql(POS_TENDER_CASH_MUTATION, { input: { ...input, idempotencyKey }, staffToken: options.staffToken }, options);
|
|
151
|
+
return data.posTenderCash;
|
|
152
|
+
},
|
|
153
|
+
async card(input, options) {
|
|
154
|
+
const idempotencyKey = requireKey(options);
|
|
155
|
+
const data = await gql(POS_TENDER_CARD_MUTATION, { input: { ...input, idempotencyKey }, staffToken: options.staffToken }, options);
|
|
156
|
+
return data.posTenderCard;
|
|
157
|
+
},
|
|
158
|
+
async manual(input, options) {
|
|
159
|
+
const idempotencyKey = requireKey(options);
|
|
160
|
+
const data = await gql(POS_TENDER_MANUAL_MUTATION, { input: { ...input, idempotencyKey }, staffToken: options.staffToken }, options);
|
|
161
|
+
return data.posTenderManual;
|
|
162
|
+
},
|
|
163
|
+
async storedValue(input, options) {
|
|
164
|
+
const idempotencyKey = requireKey(options);
|
|
165
|
+
const data = await gql(POS_TENDER_STORED_VALUE_MUTATION, { input: { ...input, idempotencyKey }, staffToken: options.staffToken }, options);
|
|
166
|
+
return data.posTenderStoredValue;
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
refunds: {
|
|
170
|
+
async create(input, options) {
|
|
171
|
+
const idempotencyKey = requireKey(options);
|
|
172
|
+
const data = await gql(POS_REFUND_MUTATION, { input: { ...input, idempotencyKey }, staffToken: options.staffToken }, options);
|
|
173
|
+
return data.posRefund;
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
devices: {
|
|
177
|
+
async list(options) {
|
|
178
|
+
const data = await gql(POS_DEVICES_QUERY, {}, options);
|
|
179
|
+
return wholeList(data.posDevices);
|
|
180
|
+
},
|
|
181
|
+
async pair(deviceId, options) {
|
|
182
|
+
const data = await gql(POS_PAIRING_CODE_MUTATION, { deviceId }, options);
|
|
183
|
+
return data.generatePosPairingCode;
|
|
184
|
+
},
|
|
185
|
+
async revoke(deviceId, options) {
|
|
186
|
+
const data = await gql(REVOKE_POS_DEVICE_MUTATION, { deviceId }, options);
|
|
187
|
+
return data.revokePosDevice;
|
|
188
|
+
},
|
|
189
|
+
async heartbeat(deviceId, options) {
|
|
190
|
+
const data = await gql(POS_DEVICE_QUERY, { id: deviceId }, options);
|
|
191
|
+
return data.posDevice;
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
receiptNumbering: {
|
|
195
|
+
async get(options) {
|
|
196
|
+
const data = await gql(POS_RECEIPT_NUMBERING_QUERY, {}, options);
|
|
197
|
+
return data.posReceiptNumberingConfig;
|
|
198
|
+
},
|
|
199
|
+
async set(input, options) {
|
|
200
|
+
const data = await gql(UPDATE_POS_RECEIPT_NUMBERING_MUTATION, { input }, options);
|
|
201
|
+
return data.updatePosReceiptNumberingConfig;
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { type Page, type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { ConfigurableOperation, ConfigurableOperationInput, LanguageCode } from '../catalog/types.js';
|
|
3
|
+
import type { Call } from '../types.js';
|
|
4
|
+
import { type PricingVouchersModule } from './vouchers.js';
|
|
5
|
+
/**
|
|
6
|
+
* Promotions at the register (headless spec §9.2 `pricing`; incentives spec §5,
|
|
7
|
+
* sprint 1): which promotions a register can offer, coupons on the order it is
|
|
8
|
+
* entering, and what each discount did to each line.
|
|
9
|
+
*
|
|
10
|
+
* Money is integer MINOR UNITS of the order's currency; times are ISO-8601 UTC.
|
|
11
|
+
*
|
|
12
|
+
* **Coded refusals** of the coupon methods, delivered as GraphQL errors with
|
|
13
|
+
* `extensions.code` (`BusinessRuleError`, 422, unless noted). Branch on the
|
|
14
|
+
* code, never on the class:
|
|
15
|
+
* - `COUPON_INVALID` (`ValidationError`, 400, by its `_INVALID` suffix) — no
|
|
16
|
+
* coupon of this store carries the code: unknown, mistyped, deactivated, its
|
|
17
|
+
* promotion disabled, or another store's code (the same answer, so no store
|
|
18
|
+
* learns of another's codes);
|
|
19
|
+
* - `COUPON_EXPIRED` — its promotion has ended;
|
|
20
|
+
* - `COUPON_NOT_YET_VALID` — its promotion has not started;
|
|
21
|
+
* - `COUPON_USAGE_EXHAUSTED` — used up: the promotion's limit, its per-customer
|
|
22
|
+
* limit for the order's customer, or a unique code's own limits
|
|
23
|
+
* (`extensions.details.limit`);
|
|
24
|
+
* - `COUPON_NOT_APPLICABLE` — valid, but its promotion does not apply to the
|
|
25
|
+
* order as it stands (a condition is not met, or the promotion is already on
|
|
26
|
+
* the order through another of its unique codes);
|
|
27
|
+
* - `EXTERNAL_LINE_PROMOTION_UNSUPPORTED` — it would discount a line whose price
|
|
28
|
+
* the caller stated (`orders.createOrRecover` external lines);
|
|
29
|
+
* - `ORDER_NOT_DRAFT` — the order is not a Draft; change a placed order through
|
|
30
|
+
* an order modification.
|
|
31
|
+
* A refused call leaves the order unchanged. Another store's order is
|
|
32
|
+
* `ENTITY_NOT_FOUND` (`NotFoundError`), as one that does not exist.
|
|
33
|
+
*/
|
|
34
|
+
export interface PricingModule {
|
|
35
|
+
promotions: PricingPromotionsModule;
|
|
36
|
+
coupons: PricingCouponsModule;
|
|
37
|
+
/** Personal vouchers: templates, issuing, a customer's vouchers (`./vouchers.ts`). */
|
|
38
|
+
vouchers: PricingVouchersModule;
|
|
39
|
+
/**
|
|
40
|
+
* The order's discounts as they stand: its coupon codes, the order-level
|
|
41
|
+
* discounts, and each line's discounts, every one naming the promotion it came
|
|
42
|
+
* from. Needs `ReadOrder`. `NotFoundError` (`ORDER_NOT_FOUND`) when this store
|
|
43
|
+
* has no such order.
|
|
44
|
+
*/
|
|
45
|
+
discounts(orderId: string, options?: Call): Promise<OrderDiscounts>;
|
|
46
|
+
}
|
|
47
|
+
export interface PricingPromotionsModule {
|
|
48
|
+
/**
|
|
49
|
+
* The store's promotions that can apply right now: enabled, inside their date
|
|
50
|
+
* window, not used up, and — with `customerId` — open to that customer (a
|
|
51
|
+
* customer-group condition naming a group they are in). With no customer a
|
|
52
|
+
* customer-group promotion is left out: an anonymous sale is in no group.
|
|
53
|
+
* Conditions on the basket (amounts, products, the payment method) are not
|
|
54
|
+
* judged here, they are summarised. Ordered as the engine applies them.
|
|
55
|
+
*
|
|
56
|
+
* The targeting conditions are judged for a sale here and now:
|
|
57
|
+
* `selling_location` against `locationId`, else the request's `x-location`
|
|
58
|
+
* (with neither, such a promotion is left out); `time_window` on that
|
|
59
|
+
* location's clock, else the store's; `first_order` for `customerId` (left out
|
|
60
|
+
* without one, and for the till's walk-in). `locationId` must be a stock
|
|
61
|
+
* location of this store that the credential may act at
|
|
62
|
+
* (`LOCATION_NOT_IN_CHANNEL` / `LOCATION_NOT_ALLOWED`).
|
|
63
|
+
*
|
|
64
|
+
* Needs `ReadPromotion`, `CreateOrder` or `OperatePos`. A `Page` because every
|
|
65
|
+
* list in this SDK is one; the engine answers the whole list, so it is always
|
|
66
|
+
* the last page.
|
|
67
|
+
*/
|
|
68
|
+
active(filter?: ActivePromotionsFilter, options?: Call): Promise<Page<ActivePromotion>>;
|
|
69
|
+
/**
|
|
70
|
+
* Create a promotion of this store. Build targeting conditions with
|
|
71
|
+
* {@link promotionConditions}; core's conditions and actions take their
|
|
72
|
+
* `ConfigurableOperationInput` as stored. The stacking guard the dashboard
|
|
73
|
+
* puts on every promotion it saves (`promotion_stacking_guard`) is added when
|
|
74
|
+
* the input does not carry it, so a promotion made here stacks like one made
|
|
75
|
+
* there. Needs `CreatePromotion`.
|
|
76
|
+
*
|
|
77
|
+
* **An empty `conditions` list creates a promotion that applies to every
|
|
78
|
+
* order** (with no coupon code: automatically), exactly as the dashboard's "No
|
|
79
|
+
* conditions means the promotion applies to all orders". The guard counts as
|
|
80
|
+
* a condition, so core's "no condition and no coupon code" refusal never
|
|
81
|
+
* fires for a promotion saved here: build at least one condition, or set
|
|
82
|
+
* `couponCode` or `enabled: false`, unless a store-wide promotion is meant.
|
|
83
|
+
*
|
|
84
|
+
* Refusals: `PROMOTION_CONDITION_INVALID` (`ValidationError`, 400: a
|
|
85
|
+
* targeting or set argument the engine cannot read, a second set condition or
|
|
86
|
+
* a set action without its condition (`argument: "conditions"`), or a set
|
|
87
|
+
* condition without its action or a second copy of a set action
|
|
88
|
+
* (`argument: "actions"`), judged on `update` for the pair the update leaves; `extensions.details` names the condition and
|
|
89
|
+
* argument), `LOCATION_NOT_IN_CHANNEL` (a location of another store, or not
|
|
90
|
+
* an id), `LOCATION_NOT_ALLOWED` (outside the credential's location
|
|
91
|
+
* restriction), `FACET_VALUE_NOT_FOUND` / `COLLECTION_NOT_FOUND`
|
|
92
|
+
* (`NotFoundError`, 404: a set component names a facet value or collection
|
|
93
|
+
* this store does not have; another store's answers the same).
|
|
94
|
+
*/
|
|
95
|
+
create(input: CreatePromotionInput, options?: Call): Promise<PricingPromotion>;
|
|
96
|
+
/**
|
|
97
|
+
* Update a promotion of this store. `conditions` and `actions`, when sent,
|
|
98
|
+
* replace the whole list (the guard is kept as on create). Needs
|
|
99
|
+
* `UpdatePromotion`.
|
|
100
|
+
*
|
|
101
|
+
* Refusals: those of {@link PricingPromotionsModule.create}, and
|
|
102
|
+
* `MISSING_CONDITIONS_ERROR` (`BusinessRuleError`, 422) for one case: the input
|
|
103
|
+
* does not name `conditions`, the STORED promotion has none (an imported
|
|
104
|
+
* coupon, a seed: no guard was ever added), and the result would have no coupon
|
|
105
|
+
* code (`couponCode: ''` clears it, or none is stored). Core judges omitted
|
|
106
|
+
* conditions from the stored ones, and the guard is added only to conditions
|
|
107
|
+
* the input sends: send `conditions` (even `[]`) to keep such a promotion
|
|
108
|
+
* without a code.
|
|
109
|
+
*/
|
|
110
|
+
update(input: UpdatePromotionInput, options?: Call): Promise<PricingPromotion>;
|
|
111
|
+
}
|
|
112
|
+
/** A day of the week as the `time_window` condition stores it (Monday first). */
|
|
113
|
+
export type Weekday = 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun';
|
|
114
|
+
/** `HH:mm`, 24-hour, local time. */
|
|
115
|
+
export type LocalTime = `${number}${number}:${number}${number}`;
|
|
116
|
+
/**
|
|
117
|
+
* The targeting conditions (incentives sprint 2), encoded as the engine stores
|
|
118
|
+
* them — every argument a string, lists JSON-encoded. Their argument names and
|
|
119
|
+
* shapes are a stored contract.
|
|
120
|
+
*/
|
|
121
|
+
export declare const promotionConditions: {
|
|
122
|
+
/**
|
|
123
|
+
* `selling_location`: the order is sold from one of these stock locations of
|
|
124
|
+
* the store — a till there, an order `orders.createOrRecover` recorded for it
|
|
125
|
+
* (`location`), or a register sending it as `x-location` on the Admin API. A
|
|
126
|
+
* web order has no location and never matches.
|
|
127
|
+
*/
|
|
128
|
+
readonly sellingLocation: (locationIds: readonly string[]) => ConfigurableOperationInput;
|
|
129
|
+
/**
|
|
130
|
+
* `time_window`: on one of `days`, from `from` (included) to `until`
|
|
131
|
+
* (excluded), local time — the selling location's profile zone, else the
|
|
132
|
+
* store's. An `until` not after `from` runs into the next day and belongs to
|
|
133
|
+
* the day it opened (`fri 22:00–02:00`); equal times are 24 hours
|
|
134
|
+
* (`00:00`–`00:00`: all day). Judged on the wall clock, so a window in the
|
|
135
|
+
* hour clocks repeat in autumn is open twice, one in the hour they skip in
|
|
136
|
+
* spring never opens. A placed order keeps a window it was placed with.
|
|
137
|
+
*/
|
|
138
|
+
readonly timeWindow: (window: {
|
|
139
|
+
days: readonly Weekday[];
|
|
140
|
+
from: LocalTime | string;
|
|
141
|
+
until: LocalTime | string;
|
|
142
|
+
}) => ConfigurableOperationInput;
|
|
143
|
+
/**
|
|
144
|
+
* `first_order`: the customer has no earlier placed order in this store. An
|
|
145
|
+
* order with no customer, or the till's walk-in, never matches.
|
|
146
|
+
*/
|
|
147
|
+
readonly firstOrder: () => ConfigurableOperationInput;
|
|
148
|
+
/**
|
|
149
|
+
* `bundle_fixed_price` (incentives sprint 4): each complete set of
|
|
150
|
+
* `components` costs `price` — minor units of the store's DEFAULT currency, in
|
|
151
|
+
* the store's tax basis (as its catalogue prices are entered), converted into
|
|
152
|
+
* an order's currency at the checkout's rate. The discount is spread over the
|
|
153
|
+
* set's lines by value; a set worth `price` or less stays at list price. Pair
|
|
154
|
+
* it with {@link promotionActions}`.bundleFixedPrice()`.
|
|
155
|
+
*
|
|
156
|
+
* `price` is required and must be a whole amount above 0: anything else throws
|
|
157
|
+
* `ValidationError` (`PROMOTION_CONDITION_INVALID`) before a request is sent,
|
|
158
|
+
* as the engine would refuse it. To give sets away use
|
|
159
|
+
* {@link promotionConditions}`.nthSetPercentage` with `discount: 100`.
|
|
160
|
+
*/
|
|
161
|
+
readonly bundleFixedPrice: (set: {
|
|
162
|
+
components: readonly SetComponent[];
|
|
163
|
+
price: number;
|
|
164
|
+
}) => ConfigurableOperationInput;
|
|
165
|
+
/**
|
|
166
|
+
* `nth_set_percentage`: of every `nth` complete sets, the cheapest is
|
|
167
|
+
* `discount`% off ("second pair at 50%" is `nth: 2, discount: 50`; `nth: 1`
|
|
168
|
+
* discounts every set). Pair it with {@link promotionActions}`.nthSetPercentage()`.
|
|
169
|
+
*/
|
|
170
|
+
readonly nthSetPercentage: (set: {
|
|
171
|
+
components: readonly SetComponent[];
|
|
172
|
+
nth: number;
|
|
173
|
+
discount: number;
|
|
174
|
+
}) => ConfigurableOperationInput;
|
|
175
|
+
/**
|
|
176
|
+
* `mix_and_match`: any `quantity` units matching the selector (all of
|
|
177
|
+
* `facetValueIds`, any of `collectionIds`) for `price`, per complete group;
|
|
178
|
+
* leftover units stay at list price. `price` as in `bundleFixedPrice`
|
|
179
|
+
* (required, above 0, refused before sending otherwise). Pair it with
|
|
180
|
+
* {@link promotionActions}`.mixAndMatch()`.
|
|
181
|
+
*/
|
|
182
|
+
readonly mixAndMatch: (group: {
|
|
183
|
+
facetValueIds?: readonly string[];
|
|
184
|
+
collectionIds?: readonly string[];
|
|
185
|
+
quantity: number;
|
|
186
|
+
price: number;
|
|
187
|
+
}) => ConfigurableOperationInput;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* One component of a set: `quantity` units, each carrying ALL of
|
|
191
|
+
* `facetValueIds` and sitting in ANY of `collectionIds` (at least one of the
|
|
192
|
+
* two lists). A unit that a caller priced (an external, imported, quoted or
|
|
193
|
+
* till-priced line) or that staff priced by hand never joins a set.
|
|
194
|
+
*/
|
|
195
|
+
export interface SetComponent {
|
|
196
|
+
facetValueIds?: readonly string[];
|
|
197
|
+
collectionIds?: readonly string[];
|
|
198
|
+
quantity: number;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The set actions (incentives sprint 4). Each takes no arguments and applies
|
|
202
|
+
* what its same-code condition computed, so it goes on the promotion together
|
|
203
|
+
* with that condition: the engine refuses one without the other.
|
|
204
|
+
*/
|
|
205
|
+
export declare const promotionActions: {
|
|
206
|
+
readonly bundleFixedPrice: () => ConfigurableOperationInput;
|
|
207
|
+
readonly nthSetPercentage: () => ConfigurableOperationInput;
|
|
208
|
+
readonly mixAndMatch: () => ConfigurableOperationInput;
|
|
209
|
+
};
|
|
210
|
+
export interface PromotionTranslationInput {
|
|
211
|
+
languageCode: LanguageCode;
|
|
212
|
+
name: string;
|
|
213
|
+
description?: string;
|
|
214
|
+
}
|
|
215
|
+
export interface CreatePromotionInput {
|
|
216
|
+
translations: PromotionTranslationInput[];
|
|
217
|
+
enabled: boolean;
|
|
218
|
+
/** ISO-8601; null or absent for an open end. */
|
|
219
|
+
startsAt?: string | null;
|
|
220
|
+
endsAt?: string | null;
|
|
221
|
+
couponCode?: string | null;
|
|
222
|
+
perCustomerUsageLimit?: number | null;
|
|
223
|
+
usageLimit?: number | null;
|
|
224
|
+
conditions: ConfigurableOperationInput[];
|
|
225
|
+
actions: ConfigurableOperationInput[];
|
|
226
|
+
/** Applies to customers on a price list too (the stacking guard's B2B rule). */
|
|
227
|
+
combineWithB2b?: boolean;
|
|
228
|
+
/** Stacks with other promotions instead of taking the exclusive slot. */
|
|
229
|
+
combineWithOtherPromotions?: boolean;
|
|
230
|
+
/** Higher is tested first and wins the exclusive slot. */
|
|
231
|
+
priority?: number;
|
|
232
|
+
}
|
|
233
|
+
export interface UpdatePromotionInput extends Partial<Omit<CreatePromotionInput, 'translations'>> {
|
|
234
|
+
id: string;
|
|
235
|
+
translations?: Array<PromotionTranslationInput & {
|
|
236
|
+
id?: string;
|
|
237
|
+
}>;
|
|
238
|
+
}
|
|
239
|
+
/** A promotion as `create` / `update` answer it. The coupon code is the caller's own input. */
|
|
240
|
+
export interface PricingPromotion {
|
|
241
|
+
id: string;
|
|
242
|
+
name: string;
|
|
243
|
+
description: string;
|
|
244
|
+
enabled: boolean;
|
|
245
|
+
couponCode: string | null;
|
|
246
|
+
startsAt: string | null;
|
|
247
|
+
endsAt: string | null;
|
|
248
|
+
usageLimit: number | null;
|
|
249
|
+
perCustomerUsageLimit: number | null;
|
|
250
|
+
conditions: ConfigurableOperation[];
|
|
251
|
+
actions: ConfigurableOperation[];
|
|
252
|
+
customFields: {
|
|
253
|
+
combineWithB2b: boolean | null;
|
|
254
|
+
combineWithOtherPromotions: boolean | null;
|
|
255
|
+
priority: number | null;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
export interface PricingCouponsModule {
|
|
259
|
+
/**
|
|
260
|
+
* Apply a coupon code — a promotion's own code or a unique code generated for
|
|
261
|
+
* it — to a DRAFT order of this store: a back-office draft, or an order
|
|
262
|
+
* `orders.createOrRecover` composed and left as a Draft. Answers the re-priced
|
|
263
|
+
* order. Surcharges are left as they are. A code already on the order answers
|
|
264
|
+
* the order unchanged. Needs `CreateOrder`.
|
|
265
|
+
*
|
|
266
|
+
* Takes `options.idempotencyKey`: the same key with the same arguments replays
|
|
267
|
+
* the first answer, a refusal included; a different request under the same key
|
|
268
|
+
* is `IDEMPOTENCY_CONFLICT`. A till cart takes its coupons through
|
|
269
|
+
* `pos.sale.applyCouponCode`.
|
|
270
|
+
*/
|
|
271
|
+
apply(orderId: string, couponCode: string, options?: Call): Promise<OrderDiscounts>;
|
|
272
|
+
/**
|
|
273
|
+
* Take a coupon code off a DRAFT order of this store — the code as applied (a
|
|
274
|
+
* unique code frees its use) or as `couponCodes` shows it. A code that is not
|
|
275
|
+
* on the order answers the order unchanged. Needs `CreateOrder`; takes
|
|
276
|
+
* `options.idempotencyKey` as {@link PricingCouponsModule.apply} does.
|
|
277
|
+
*/
|
|
278
|
+
remove(orderId: string, couponCode: string, options?: Call): Promise<OrderDiscounts>;
|
|
279
|
+
}
|
|
280
|
+
export interface ActivePromotionsFilter {
|
|
281
|
+
locationId?: string;
|
|
282
|
+
customerId?: string;
|
|
283
|
+
}
|
|
284
|
+
/** A promotion's stored condition or action, and the sentence its definition makes of it. */
|
|
285
|
+
export interface PromotionOperationSummary {
|
|
286
|
+
code: string;
|
|
287
|
+
args: Array<{
|
|
288
|
+
name: string;
|
|
289
|
+
value: string;
|
|
290
|
+
}>;
|
|
291
|
+
/**
|
|
292
|
+
* The registered definition's description with the stored values filled in,
|
|
293
|
+
* in the request's language — `"If order total is greater than 50.00 EUR"`.
|
|
294
|
+
* Money reads in the store's default currency; a list argument as a count.
|
|
295
|
+
*/
|
|
296
|
+
summary: string;
|
|
297
|
+
}
|
|
298
|
+
export interface ActivePromotion {
|
|
299
|
+
id: string;
|
|
300
|
+
name: string;
|
|
301
|
+
description: string;
|
|
302
|
+
startsAt: string | null;
|
|
303
|
+
endsAt: string | null;
|
|
304
|
+
/** Whether a coupon code must be applied for it to count. The code itself is never answered. */
|
|
305
|
+
requiresCouponCode: boolean;
|
|
306
|
+
usageLimit: number | null;
|
|
307
|
+
perCustomerUsageLimit: number | null;
|
|
308
|
+
conditions: PromotionOperationSummary[];
|
|
309
|
+
actions: PromotionOperationSummary[];
|
|
310
|
+
/** Conditions joined with "and", then what it gives. */
|
|
311
|
+
summary: string;
|
|
312
|
+
}
|
|
313
|
+
/** One discount, on the order or on a line. Amounts are negative minor units. */
|
|
314
|
+
export interface OrderDiscount {
|
|
315
|
+
/** The promotion it came from; null for a discount from anything else. */
|
|
316
|
+
promotionId: string | null;
|
|
317
|
+
/** `PROMOTION:<id>` for a promotion. */
|
|
318
|
+
adjustmentSource: string;
|
|
319
|
+
/** `PROMOTION` or `DISTRIBUTED_ORDER_PROMOTION` (an order-level discount's share of a line). */
|
|
320
|
+
type: string;
|
|
321
|
+
description: string;
|
|
322
|
+
amount: number;
|
|
323
|
+
amountWithTax: number;
|
|
324
|
+
}
|
|
325
|
+
export interface DiscountedOrderLine {
|
|
326
|
+
id: string;
|
|
327
|
+
quantity: number;
|
|
328
|
+
productVariant: {
|
|
329
|
+
id: string;
|
|
330
|
+
sku: string;
|
|
331
|
+
name: string;
|
|
332
|
+
};
|
|
333
|
+
unitPrice: number;
|
|
334
|
+
unitPriceWithTax: number;
|
|
335
|
+
/** Before any discount. */
|
|
336
|
+
linePrice: number;
|
|
337
|
+
linePriceWithTax: number;
|
|
338
|
+
/** After the line's own promotions. */
|
|
339
|
+
discountedLinePrice: number;
|
|
340
|
+
discountedLinePriceWithTax: number;
|
|
341
|
+
/** After the line's own promotions AND its share of the order-level ones: what it costs. */
|
|
342
|
+
proratedLinePrice: number;
|
|
343
|
+
proratedLinePriceWithTax: number;
|
|
344
|
+
discounts: OrderDiscount[];
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Lines a set promotion priced together (`bundle_fixed_price`,
|
|
348
|
+
* `nth_set_percentage`, `mix_and_match`), read from the order's own lines and
|
|
349
|
+
* discounts: a placed order keeps the packages it was priced with.
|
|
350
|
+
*/
|
|
351
|
+
export interface OrderPackage {
|
|
352
|
+
promotionId: string;
|
|
353
|
+
/** The promotion's name, as the order recorded it when it was priced. */
|
|
354
|
+
label: string;
|
|
355
|
+
/** What the package's units cost after its discount, excluding tax. */
|
|
356
|
+
price: number;
|
|
357
|
+
priceWithTax: number;
|
|
358
|
+
/** In the order's line order; a line belongs to one package at most. */
|
|
359
|
+
lineIds: string[];
|
|
360
|
+
/** Complete sets (groups) in the package. */
|
|
361
|
+
quantity: number;
|
|
362
|
+
}
|
|
363
|
+
export interface OrderDiscounts {
|
|
364
|
+
id: string;
|
|
365
|
+
code: string;
|
|
366
|
+
state: string;
|
|
367
|
+
currencyCode: string;
|
|
368
|
+
/**
|
|
369
|
+
* The codes on the order. A unique code is redeemed by standing in for its
|
|
370
|
+
* promotion's own code, so it shows here as THAT code.
|
|
371
|
+
*/
|
|
372
|
+
couponCodes: string[];
|
|
373
|
+
subTotal: number;
|
|
374
|
+
subTotalWithTax: number;
|
|
375
|
+
shipping: number;
|
|
376
|
+
shippingWithTax: number;
|
|
377
|
+
total: number;
|
|
378
|
+
totalWithTax: number;
|
|
379
|
+
/** The order's discounts, one per promotion (a line's share is on the line). */
|
|
380
|
+
discounts: OrderDiscount[];
|
|
381
|
+
/** The promotions that apply to the order now. */
|
|
382
|
+
promotions: Array<{
|
|
383
|
+
id: string;
|
|
384
|
+
name: string;
|
|
385
|
+
}>;
|
|
386
|
+
lines: DiscountedOrderLine[];
|
|
387
|
+
/** The sets its set promotions priced together; empty when none applies. */
|
|
388
|
+
packages: OrderPackage[];
|
|
389
|
+
/** Untouched by coupons; listed so a register can show the whole bill. */
|
|
390
|
+
surcharges: Array<{
|
|
391
|
+
id: string;
|
|
392
|
+
description: string;
|
|
393
|
+
sku: string | null;
|
|
394
|
+
price: number;
|
|
395
|
+
priceWithTax: number;
|
|
396
|
+
}>;
|
|
397
|
+
}
|
|
398
|
+
/** An order's pricing readout; the manual pricing doors (`orders.setLinePrices`, …) answer it too. */
|
|
399
|
+
export declare const ORDER_DISCOUNTS_FIELDS = "\n id\n code\n state\n currencyCode\n couponCodes\n subTotal\n subTotalWithTax\n shipping\n shippingWithTax\n total\n totalWithTax\n discounts { promotionId adjustmentSource type description amount amountWithTax }\n promotions { id name }\n lines {\n id\n quantity\n productVariant { id sku name }\n unitPrice\n unitPriceWithTax\n linePrice\n linePriceWithTax\n discountedLinePrice\n discountedLinePriceWithTax\n proratedLinePrice\n proratedLinePriceWithTax\n discounts { promotionId adjustmentSource type description amount amountWithTax }\n }\n surcharges { id description sku price priceWithTax }\n packages { promotionId label price priceWithTax lineIds quantity }\n";
|
|
400
|
+
export declare const ACTIVE_PROMOTIONS_QUERY = "\n query ActivePromotions($locationId: ID, $customerId: ID) {\n activePromotions(locationId: $locationId, customerId: $customerId) {\n id\n name\n description\n startsAt\n endsAt\n requiresCouponCode\n usageLimit\n perCustomerUsageLimit\n conditions { code args { name value } summary }\n actions { code args { name value } summary }\n summary\n }\n }\n";
|
|
401
|
+
export declare const CREATE_PROMOTION_MUTATION = "\n mutation CreatePromotion($input: CreatePromotionInput!) {\n createPromotion(input: $input) {\n ... on Promotion { \n id\n name\n description\n enabled\n couponCode\n startsAt\n endsAt\n usageLimit\n perCustomerUsageLimit\n conditions { code args { name value } }\n actions { code args { name value } }\n customFields { combineWithB2b combineWithOtherPromotions priority }\n }\n ... on ErrorResult { errorCode message }\n }\n }\n";
|
|
402
|
+
export declare const UPDATE_PROMOTION_MUTATION = "\n mutation UpdatePromotion($input: UpdatePromotionInput!) {\n updatePromotion(input: $input) {\n ... on Promotion { \n id\n name\n description\n enabled\n couponCode\n startsAt\n endsAt\n usageLimit\n perCustomerUsageLimit\n conditions { code args { name value } }\n actions { code args { name value } }\n customFields { combineWithB2b combineWithOtherPromotions priority }\n }\n ... on ErrorResult { errorCode message }\n }\n }\n";
|
|
403
|
+
/** The condition the dashboard and the admin app put on every promotion they save. */
|
|
404
|
+
export declare const STACKING_GUARD_CONDITION = "promotion_stacking_guard";
|
|
405
|
+
export declare const APPLY_COUPON_CODE_TO_ORDER_MUTATION = "\n mutation ApplyCouponCodeToOrder($orderId: ID!, $couponCode: String!, $idempotencyKey: String) {\n applyCouponCodeToOrder(\n orderId: $orderId\n couponCode: $couponCode\n idempotencyKey: $idempotencyKey\n ) {\n \n id\n code\n state\n currencyCode\n couponCodes\n subTotal\n subTotalWithTax\n shipping\n shippingWithTax\n total\n totalWithTax\n discounts { promotionId adjustmentSource type description amount amountWithTax }\n promotions { id name }\n lines {\n id\n quantity\n productVariant { id sku name }\n unitPrice\n unitPriceWithTax\n linePrice\n linePriceWithTax\n discountedLinePrice\n discountedLinePriceWithTax\n proratedLinePrice\n proratedLinePriceWithTax\n discounts { promotionId adjustmentSource type description amount amountWithTax }\n }\n surcharges { id description sku price priceWithTax }\n packages { promotionId label price priceWithTax lineIds quantity }\n\n }\n }\n";
|
|
406
|
+
export declare const REMOVE_COUPON_CODE_FROM_ORDER_MUTATION = "\n mutation RemoveCouponCodeFromOrder($orderId: ID!, $couponCode: String!, $idempotencyKey: String) {\n removeCouponCodeFromOrder(\n orderId: $orderId\n couponCode: $couponCode\n idempotencyKey: $idempotencyKey\n ) {\n \n id\n code\n state\n currencyCode\n couponCodes\n subTotal\n subTotalWithTax\n shipping\n shippingWithTax\n total\n totalWithTax\n discounts { promotionId adjustmentSource type description amount amountWithTax }\n promotions { id name }\n lines {\n id\n quantity\n productVariant { id sku name }\n unitPrice\n unitPriceWithTax\n linePrice\n linePriceWithTax\n discountedLinePrice\n discountedLinePriceWithTax\n proratedLinePrice\n proratedLinePriceWithTax\n discounts { promotionId adjustmentSource type description amount amountWithTax }\n }\n surcharges { id description sku price priceWithTax }\n packages { promotionId label price priceWithTax lineIds quantity }\n\n }\n }\n";
|
|
407
|
+
export declare const ORDER_DISCOUNTS_QUERY = "\n query OrderDiscounts($id: ID!) {\n order(id: $id) {\n \n id\n code\n state\n currencyCode\n couponCodes\n subTotal\n subTotalWithTax\n shipping\n shippingWithTax\n total\n totalWithTax\n discounts { promotionId adjustmentSource type description amount amountWithTax }\n promotions { id name }\n lines {\n id\n quantity\n productVariant { id sku name }\n unitPrice\n unitPriceWithTax\n linePrice\n linePriceWithTax\n discountedLinePrice\n discountedLinePriceWithTax\n proratedLinePrice\n proratedLinePriceWithTax\n discounts { promotionId adjustmentSource type description amount amountWithTax }\n }\n surcharges { id description sku price priceWithTax }\n packages { promotionId label price priceWithTax lineIds quantity }\n\n }\n }\n";
|
|
408
|
+
export declare function createPricingModule(transport: Transport): PricingModule;
|