@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,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything the caller was promised about the composed order, in one
|
|
3
|
+
* projection: every line with its ids, both bases of its prices and its tax
|
|
4
|
+
* lines, the order's own totals, its surcharges, and the ref it was filed under.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately generous. The whole point of an atomic compose is that the caller
|
|
7
|
+
* never has to ask a second question to learn what it got, and a retry that had
|
|
8
|
+
* to re-read the order to find its line ids would defeat it.
|
|
9
|
+
*/
|
|
10
|
+
const EXTERNAL_ORDER_FIELDS = /* GraphQL */ `
|
|
11
|
+
id
|
|
12
|
+
code
|
|
13
|
+
state
|
|
14
|
+
currencyCode
|
|
15
|
+
subTotal
|
|
16
|
+
subTotalWithTax
|
|
17
|
+
total
|
|
18
|
+
totalWithTax
|
|
19
|
+
lines {
|
|
20
|
+
id
|
|
21
|
+
quantity
|
|
22
|
+
unitPrice
|
|
23
|
+
unitPriceWithTax
|
|
24
|
+
linePrice
|
|
25
|
+
linePriceWithTax
|
|
26
|
+
taxLines {
|
|
27
|
+
description
|
|
28
|
+
taxRate
|
|
29
|
+
}
|
|
30
|
+
productVariant {
|
|
31
|
+
id
|
|
32
|
+
sku
|
|
33
|
+
name
|
|
34
|
+
}
|
|
35
|
+
customFields {
|
|
36
|
+
externalEntryPosition
|
|
37
|
+
externalEntryKey
|
|
38
|
+
externalLineLabel
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
surcharges {
|
|
42
|
+
id
|
|
43
|
+
description
|
|
44
|
+
sku
|
|
45
|
+
price
|
|
46
|
+
priceWithTax
|
|
47
|
+
taxRate
|
|
48
|
+
}
|
|
49
|
+
customFields {
|
|
50
|
+
externalRef
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
export const CREATE_OR_RECOVER_ORDER_MUTATION = /* GraphQL */ `
|
|
54
|
+
mutation CreateOrRecoverOrder($input: ExternalOrderInput!, $idempotencyKey: String!) {
|
|
55
|
+
createOrRecoverOrder(input: $input, idempotencyKey: $idempotencyKey) {
|
|
56
|
+
${EXTERNAL_ORDER_FIELDS}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
export const ORDER_BY_EXTERNAL_REF_QUERY = /* GraphQL */ `
|
|
61
|
+
query OrderByExternalRef($externalRef: String!) {
|
|
62
|
+
orderByExternalRef(externalRef: $externalRef) {
|
|
63
|
+
${EXTERNAL_ORDER_FIELDS}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
export const ORDER_BY_IDEMPOTENCY_KEY_QUERY = /* GraphQL */ `
|
|
68
|
+
query OrderByIdempotencyKey($key: String!) {
|
|
69
|
+
orderByIdempotencyKey(key: $key) {
|
|
70
|
+
${EXTERNAL_ORDER_FIELDS}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
/**
|
|
75
|
+
* The SDK's discriminated line → the wrapper member the SDL declares.
|
|
76
|
+
*
|
|
77
|
+
* `kind` is stripped rather than sent: it is not a field of either input type,
|
|
78
|
+
* and the Admin API runs `forbidNonWhitelisted`-equivalent GraphQL input
|
|
79
|
+
* coercion, so leaving it on would 400 the whole document.
|
|
80
|
+
*
|
|
81
|
+
* Every other key is copied ACROSS, never rebuilt field by field: `configuration`
|
|
82
|
+
* is the caller's own JSON and must reach the engine byte-for-byte, and a
|
|
83
|
+
* hand-written field list would also silently drop a field added to the input
|
|
84
|
+
* type later. Nothing on this path converts case — see
|
|
85
|
+
* {@link ExternalOrderExternalLine.configuration}.
|
|
86
|
+
*
|
|
87
|
+
* An absent optional stays ABSENT rather than becoming an explicit null:
|
|
88
|
+
* `JSON.stringify` drops `undefined`, and the engine's request fingerprint is
|
|
89
|
+
* taken from the raw wire arguments, so coercing one to null here would make two
|
|
90
|
+
* identical requests look different to the idempotency store.
|
|
91
|
+
*/
|
|
92
|
+
export function toWireLine(line) {
|
|
93
|
+
const { kind, ...rest } = line;
|
|
94
|
+
return kind === 'catalog'
|
|
95
|
+
? { catalog: rest }
|
|
96
|
+
: { external: rest };
|
|
97
|
+
}
|
|
98
|
+
/** The input as the engine declares it, lines wrapped. */
|
|
99
|
+
function toWireInput(input) {
|
|
100
|
+
return { ...input, lines: (input.lines ?? []).map(toWireLine) };
|
|
101
|
+
}
|
|
102
|
+
export function createOrderEntryModule(transport) {
|
|
103
|
+
return {
|
|
104
|
+
async createOrRecover(input, options) {
|
|
105
|
+
const data = await transport.graphql({
|
|
106
|
+
api: 'admin',
|
|
107
|
+
query: CREATE_OR_RECOVER_ORDER_MUTATION,
|
|
108
|
+
// The key travels as an ARGUMENT, not as the `Idempotency-Key` header
|
|
109
|
+
// the transport would otherwise send: the Admin API has no header for
|
|
110
|
+
// it, and `options` is forwarded separately so the header goes out too
|
|
111
|
+
// for any middleware that records it.
|
|
112
|
+
variables: { input: toWireInput(input), idempotencyKey: options.idempotencyKey },
|
|
113
|
+
}, options);
|
|
114
|
+
return data.createOrRecoverOrder;
|
|
115
|
+
},
|
|
116
|
+
async byExternalRef(externalRef, options) {
|
|
117
|
+
const data = await transport.graphql({ api: 'admin', query: ORDER_BY_EXTERNAL_REF_QUERY, variables: { externalRef } }, options);
|
|
118
|
+
// `?? null`, not the raw value: a field the engine answers as absent
|
|
119
|
+
// rather than null would otherwise reach the caller as `undefined`, and
|
|
120
|
+
// `order === null` is how every consumer of this method asks "is there
|
|
121
|
+
// one?".
|
|
122
|
+
return data.orderByExternalRef ?? null;
|
|
123
|
+
},
|
|
124
|
+
async byIdempotencyKey(key, options) {
|
|
125
|
+
const data = await transport.graphql({ api: 'admin', query: ORDER_BY_IDEMPOTENCY_KEY_QUERY, variables: { key } }, options);
|
|
126
|
+
return data.orderByIdempotencyKey ?? null;
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call } from '../types.js';
|
|
3
|
+
/** One fulfilment of the order, as far as its parcels go. */
|
|
4
|
+
export interface OrderParcelChargeFulfillment {
|
|
5
|
+
id: string;
|
|
6
|
+
state: string;
|
|
7
|
+
/** Parcels the warehouse pack step recorded on it; 0 when none were. */
|
|
8
|
+
parcelCount: number;
|
|
9
|
+
/**
|
|
10
|
+
* Every order this fulfilment ships in the channel, this one included. A
|
|
11
|
+
* fulfilment can ship several orders of one customer, so its parcels are
|
|
12
|
+
* then shared with orders whose charge this read does not return.
|
|
13
|
+
*/
|
|
14
|
+
orderIds: string[];
|
|
15
|
+
/** The order lines it ships, which may include another order's lines. */
|
|
16
|
+
orderLineIds: string[];
|
|
17
|
+
}
|
|
18
|
+
/** What an order's shipping was charged for, next to what its fulfilments packed. */
|
|
19
|
+
export interface OrderParcelCharge {
|
|
20
|
+
orderId: string;
|
|
21
|
+
/**
|
|
22
|
+
* The parcel count the shipping price was charged for, frozen when the order
|
|
23
|
+
* left the cart. `null` when the order was not priced per parcel.
|
|
24
|
+
*/
|
|
25
|
+
chargedParcelCount: number | null;
|
|
26
|
+
/** This order's own line ids, to tell its lines from another order's in a fulfilment. */
|
|
27
|
+
lineIds: string[];
|
|
28
|
+
fulfillments: OrderParcelChargeFulfillment[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Its own document on purpose: `chargedParcelCount` exists only on an engine
|
|
32
|
+
* with the extra-parcel charge, so on an older one this call alone fails
|
|
33
|
+
* validation and no other order read does.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ORDER_PARCEL_CHARGE_QUERY = "\n query OrderParcelCharge($id: ID!) {\n order(id: $id) {\n id\n customFields {\n chargedParcelCount\n }\n lines {\n id\n }\n fulfillments {\n id\n state\n lines {\n orderLineId\n }\n linkedOrders {\n id\n }\n customFields {\n parcels {\n weightGrams\n }\n }\n }\n }\n }\n";
|
|
36
|
+
export interface OrderParcelChargeModule {
|
|
37
|
+
/**
|
|
38
|
+
* The parcel count an order was charged for and the parcels its fulfilments
|
|
39
|
+
* recorded. `null` when the order does not exist in this channel. Needs
|
|
40
|
+
* `ReadOrder`, and an engine that serves
|
|
41
|
+
* `Order.customFields.chargedParcelCount`.
|
|
42
|
+
*/
|
|
43
|
+
parcelCharge(orderId: string, options?: Call): Promise<OrderParcelCharge | null>;
|
|
44
|
+
}
|
|
45
|
+
export declare function createOrderParcelChargeModule(transport: Transport): OrderParcelChargeModule;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Its own document on purpose: `chargedParcelCount` exists only on an engine
|
|
3
|
+
* with the extra-parcel charge, so on an older one this call alone fails
|
|
4
|
+
* validation and no other order read does.
|
|
5
|
+
*/
|
|
6
|
+
export const ORDER_PARCEL_CHARGE_QUERY = /* GraphQL */ `
|
|
7
|
+
query OrderParcelCharge($id: ID!) {
|
|
8
|
+
order(id: $id) {
|
|
9
|
+
id
|
|
10
|
+
customFields {
|
|
11
|
+
chargedParcelCount
|
|
12
|
+
}
|
|
13
|
+
lines {
|
|
14
|
+
id
|
|
15
|
+
}
|
|
16
|
+
fulfillments {
|
|
17
|
+
id
|
|
18
|
+
state
|
|
19
|
+
lines {
|
|
20
|
+
orderLineId
|
|
21
|
+
}
|
|
22
|
+
linkedOrders {
|
|
23
|
+
id
|
|
24
|
+
}
|
|
25
|
+
customFields {
|
|
26
|
+
parcels {
|
|
27
|
+
weightGrams
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
function toParcelCharge(order) {
|
|
35
|
+
return {
|
|
36
|
+
orderId: order.id,
|
|
37
|
+
chargedParcelCount: order.customFields?.chargedParcelCount ?? null,
|
|
38
|
+
lineIds: order.lines.map((line) => line.id),
|
|
39
|
+
fulfillments: (order.fulfillments ?? []).map((fulfillment) => ({
|
|
40
|
+
id: fulfillment.id,
|
|
41
|
+
state: fulfillment.state,
|
|
42
|
+
parcelCount: fulfillment.customFields?.parcels?.length ?? 0,
|
|
43
|
+
orderIds: fulfillment.linkedOrders.map((linked) => linked.id),
|
|
44
|
+
orderLineIds: fulfillment.lines.map((line) => line.orderLineId),
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function createOrderParcelChargeModule(transport) {
|
|
49
|
+
return {
|
|
50
|
+
async parcelCharge(orderId, options) {
|
|
51
|
+
const data = await transport.graphql({ api: 'admin', query: ORDER_PARCEL_CHARGE_QUERY, variables: { id: orderId } }, options);
|
|
52
|
+
return data.order ? toParcelCharge(data.order) : null;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|