@sixtyninecommerce/admin 0.10.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 +4347 -171
- 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 +159 -19
- package/dist/catalog/products.js +88 -13
- 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 +233 -26
- package/dist/catalog/variants.js +125 -7
- package/dist/catalog/visibility.d.ts +20 -5
- package/dist/catalog/visibility.js +19 -1
- package/dist/client.d.ts +95 -9
- package/dist/client.js +35 -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 +44 -10
- package/dist/fulfillments/index.js +11 -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 +123 -35
- package/dist/index.js +45 -12
- 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 +29 -3
- package/dist/integrations/index.js +18 -3
- package/dist/integrations/pipeline-keys.d.ts +13 -0
- package/dist/integrations/pipeline-keys.js +22 -0
- package/dist/integrations/pipelines.d.ts +15 -14
- package/dist/integrations/pipelines.js +6 -22
- package/dist/integrations/types.d.ts +146 -0
- 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/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/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 +49 -9
- package/dist/orders/index.js +22 -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-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 +257 -11
- package/dist/payments/index.js +131 -1
- package/dist/payments/methods.d.ts +303 -8
- package/dist/payments/methods.js +337 -7
- 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 +174 -4
- package/dist/pricing/index.js +174 -1
- package/dist/pricing/price-lists.d.ts +604 -0
- package/dist/pricing/price-lists.js +600 -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 +614 -21
- package/dist/returns/index.js +695 -11
- package/dist/search/index.d.ts +76 -1
- package/dist/search/index.js +63 -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 +50 -3
- package/dist/users/index.d.ts +3 -0
- package/dist/users/index.js +2 -0
- package/dist/users/warehouses.d.ts +50 -0
- package/dist/users/warehouses.js +51 -0
- package/package.json +2 -2
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call } from '../types.js';
|
|
3
|
+
import type { ExactAccountStructure, ExactCatalogueStructure, ExactOnlineAccountPreview, ExactOnlineConfig, ExactOnlineItemPreview, ExactPricingStructure, ExactSyncEstimate, ExactSyncScheduleInput, ExactWebhookStatus, SetExactOnlineCredentialsInput, UpdateExactOnlineConfigInput } from './exact-online-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The store's Exact Online connection itself (`admin.integrations.exactOnline.config`).
|
|
6
|
+
*/
|
|
7
|
+
export interface ExactOnlineConfigModule {
|
|
8
|
+
/**
|
|
9
|
+
* The store's connection and settings, or `null` when it never had one. Every section reads
|
|
10
|
+
* resolved: a section the store never saved reads the engine's defaults. The client secret,
|
|
11
|
+
* the webhook secret and the OAuth tokens are never read back.
|
|
12
|
+
*
|
|
13
|
+
* @effect read
|
|
14
|
+
* @permission ReadSettings
|
|
15
|
+
*/
|
|
16
|
+
get(options?: Call): Promise<ExactOnlineConfig | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Change the settings; the first call creates the store's row (switched off). Answers the saved
|
|
19
|
+
* connection. Every key is optional and one left out keeps the stored value; the sections are
|
|
20
|
+
* judged again when sent (the payment-method mappings, the delivery defaults and readiness), so
|
|
21
|
+
* send only what changed. Sent as the engine's inline arguments, one per key.
|
|
22
|
+
*
|
|
23
|
+
* Refused, with nothing saved:
|
|
24
|
+
* - `INVALID_EXACT_ONLINE_INPUT` (`ValidationError`, 400), before sending: not an input object,
|
|
25
|
+
* a key that is no setting (GraphQL would drop it unread), or an explicit `null` for `region`,
|
|
26
|
+
* `enabled`, `shippingItemCode`, `discountItemCode`, `paymentTerms` or `deliveryTerms` (the
|
|
27
|
+
* engine cannot store one: a database or type error); the key in `error.details[]`;
|
|
28
|
+
* - `PLUGIN_ACCESS_DENIED` (`PermissionDeniedError`, 403): the store has no Exact Online plugin
|
|
29
|
+
* (never for a SuperAdmin);
|
|
30
|
+
* - `FIELD_GROUP_LOCKED` (`BusinessRuleError`, 422): the save switches Exact, or its customer
|
|
31
|
+
* sync, on while an app or API token owns a field group of the store (prices, stock, product
|
|
32
|
+
* or customer details), which Exact would write; `error.details[]` names each owner. The owner
|
|
33
|
+
* releases the group in Settings → Apps first;
|
|
34
|
+
* - `ORGANIZATION_WORKSPACE_NOT_A_STORE` (422): switching Exact on in an organization's
|
|
35
|
+
* workspace;
|
|
36
|
+
* - `USER_INPUT_ERROR` (`ValidationError`, 400): an external-line or surcharge item code over
|
|
37
|
+
* 60 characters once trimmed.
|
|
38
|
+
*
|
|
39
|
+
* The engine's other refusals are not coded yet and arrive as an uncoded error
|
|
40
|
+
* (`GRAPHQL_ERROR`, 500): an unknown `region`, a shipping or discount item code over 60
|
|
41
|
+
* characters, a new-account payment condition missing from the synchronised catalog, a payment
|
|
42
|
+
* method that is not the store's or is mapped twice, the delivery defaults (an Incoterm without
|
|
43
|
+
* a version, a lead time or advice out of range) and operational delivery terms the schedule or
|
|
44
|
+
* the switch cannot serve.
|
|
45
|
+
*
|
|
46
|
+
* @effect write
|
|
47
|
+
* @permission UpdateSettings
|
|
48
|
+
*/
|
|
49
|
+
update(input: UpdateExactOnlineConfigInput, options?: Call): Promise<ExactOnlineConfig>;
|
|
50
|
+
}
|
|
51
|
+
/** The store's own Exact app (`admin.integrations.exactOnline.credentials`). */
|
|
52
|
+
export interface ExactOnlineCredentialsModule {
|
|
53
|
+
/**
|
|
54
|
+
* Store the store's own Exact app: its client id and, write-only, its client secret and webhook
|
|
55
|
+
* secret (a secret left out, or blank, keeps the stored one). Needed before connecting; kept
|
|
56
|
+
* across a disconnect. Answers the connection (`hasCustomCredentials` once both id and secret
|
|
57
|
+
* are stored); the first call creates the store's row.
|
|
58
|
+
*
|
|
59
|
+
* Refused: `PLUGIN_ACCESS_DENIED` (403); `ORGANIZATION_WORKSPACE_NOT_A_STORE` (422) in an
|
|
60
|
+
* organization's workspace; `INVALID_EXACT_ONLINE_INPUT` (400), before sending, when `clientId`
|
|
61
|
+
* is not a string.
|
|
62
|
+
*
|
|
63
|
+
* @effect write
|
|
64
|
+
* @permission UpdateSettings
|
|
65
|
+
*/
|
|
66
|
+
set(input: SetExactOnlineCredentialsInput, options?: Call): Promise<ExactOnlineConfig>;
|
|
67
|
+
}
|
|
68
|
+
/** Live samples of the connected division (`admin.integrations.exactOnline.samples`). */
|
|
69
|
+
export interface ExactOnlineSamplesModule {
|
|
70
|
+
/**
|
|
71
|
+
* A few CRM Accounts of the connected division, read live from Exact (5 unless `limit` says).
|
|
72
|
+
* Refused `PLUGIN_ACCESS_DENIED` (403); a store that is not connected, or an Exact read that
|
|
73
|
+
* fails, answers an uncoded error (`GRAPHQL_ERROR`, 500; not coded yet).
|
|
74
|
+
*
|
|
75
|
+
* @effect read
|
|
76
|
+
* @permission ReadSettings
|
|
77
|
+
*/
|
|
78
|
+
accounts(options?: {
|
|
79
|
+
limit?: number;
|
|
80
|
+
} & Call): Promise<ExactOnlineAccountPreview[]>;
|
|
81
|
+
/**
|
|
82
|
+
* A few logistics Items of the connected division, read live from Exact (5 unless `limit`
|
|
83
|
+
* says). Refusals as {@link accounts}.
|
|
84
|
+
*
|
|
85
|
+
* @effect read
|
|
86
|
+
* @permission ReadSettings
|
|
87
|
+
*/
|
|
88
|
+
items(options?: {
|
|
89
|
+
limit?: number;
|
|
90
|
+
} & Call): Promise<ExactOnlineItemPreview[]>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Read-only probes of how the connected division is organised, for designing the import rules
|
|
94
|
+
* (`admin.integrations.exactOnline.structure`). Each reads Exact live, page by page: slow on a
|
|
95
|
+
* large division. Refused `PLUGIN_ACCESS_DENIED` (403); a store that is not connected, or an
|
|
96
|
+
* Exact read that fails, answers an uncoded error (`GRAPHQL_ERROR`, 500; not coded yet).
|
|
97
|
+
*/
|
|
98
|
+
export interface ExactOnlineStructureModule {
|
|
99
|
+
/**
|
|
100
|
+
* How the items group (item groups, classification fields), over the first `sample` items
|
|
101
|
+
* (200 unless said).
|
|
102
|
+
*
|
|
103
|
+
* @effect read
|
|
104
|
+
* @permission ReadSettings
|
|
105
|
+
*/
|
|
106
|
+
catalogue(options?: {
|
|
107
|
+
sample?: number;
|
|
108
|
+
} & Call): Promise<ExactCatalogueStructure>;
|
|
109
|
+
/**
|
|
110
|
+
* How the Accounts group (classification dimensions, price lists, resellers), over the first
|
|
111
|
+
* `sample` Accounts (1,000 unless said).
|
|
112
|
+
*
|
|
113
|
+
* @effect read
|
|
114
|
+
* @permission ReadSettings
|
|
115
|
+
*/
|
|
116
|
+
customers(options?: {
|
|
117
|
+
sample?: number;
|
|
118
|
+
} & Call): Promise<ExactAccountStructure>;
|
|
119
|
+
/**
|
|
120
|
+
* Named price lists against per-customer item prices in the division.
|
|
121
|
+
*
|
|
122
|
+
* @effect read
|
|
123
|
+
* @permission ReadSettings
|
|
124
|
+
*/
|
|
125
|
+
pricing(options?: Call): Promise<ExactPricingStructure>;
|
|
126
|
+
}
|
|
127
|
+
/** The store's Exact webhook subscriptions (`admin.integrations.exactOnline.webhooks`). */
|
|
128
|
+
export interface ExactOnlineWebhooksModule {
|
|
129
|
+
/**
|
|
130
|
+
* The subscriptions live in Exact for the store, read live. A failed Exact read answers
|
|
131
|
+
* `error` with a best-effort rest, never a throw. Refused `PLUGIN_ACCESS_DENIED` (403).
|
|
132
|
+
*
|
|
133
|
+
* @effect read
|
|
134
|
+
* @permission ReadSettings
|
|
135
|
+
*/
|
|
136
|
+
status(options?: Call): Promise<ExactWebhookStatus>;
|
|
137
|
+
/**
|
|
138
|
+
* Register (or refresh) the store's subscriptions in Exact. Safe to repeat. Refused
|
|
139
|
+
* `PLUGIN_ACCESS_DENIED` (403) and `FIELD_GROUP_LOCKED` (422) while an app or API token owns a
|
|
140
|
+
* field group of the store; a store that is not connected, or an Exact write that fails,
|
|
141
|
+
* answers an uncoded error (`GRAPHQL_ERROR`, 500; not coded yet).
|
|
142
|
+
*
|
|
143
|
+
* @effect write
|
|
144
|
+
* @permission UpdateSettings
|
|
145
|
+
*/
|
|
146
|
+
sync(options?: Call): Promise<boolean>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The store's Exact Online connection, its settings and its import structure
|
|
150
|
+
* (`admin.integrations.exactOnline`). Always the store the client is scoped to; a SuperAdmin acts
|
|
151
|
+
* on ANOTHER store with `admin.withTenant({ scope: { kind: 'channel', code } })`, or a per-call
|
|
152
|
+
* `tenant`.
|
|
153
|
+
*
|
|
154
|
+
* The connection is OAuth: `authorizationUrl` gives the consent page of the region's Exact host,
|
|
155
|
+
* and Exact's callback stores the division. A store without the Exact Online plugin is refused
|
|
156
|
+
* every method but `config.get` and `disconnect` (`PLUGIN_ACCESS_DENIED`, 403; never for a
|
|
157
|
+
* SuperAdmin). The sync runs, the logs and the shipping-method mapping follow in their own
|
|
158
|
+
* modules.
|
|
159
|
+
*/
|
|
160
|
+
export interface ExactOnlineModule {
|
|
161
|
+
/** The connection's settings. See {@link ExactOnlineConfigModule}. */
|
|
162
|
+
config: ExactOnlineConfigModule;
|
|
163
|
+
/** The store's own Exact app. See {@link ExactOnlineCredentialsModule}. */
|
|
164
|
+
credentials: ExactOnlineCredentialsModule;
|
|
165
|
+
/**
|
|
166
|
+
* The Exact consent page to send the merchant to (open it in a popup): the region's Exact host
|
|
167
|
+
* with the store's own app and an encrypted state. Nothing is stored; the connection is made
|
|
168
|
+
* when Exact calls back. `region` defaults to the engine's (`nl`).
|
|
169
|
+
*
|
|
170
|
+
* Refused: `PLUGIN_ACCESS_DENIED` (403); `ORGANIZATION_WORKSPACE_NOT_A_STORE` (422);
|
|
171
|
+
* `FIELD_GROUP_LOCKED` (422) while an app or API token owns a field group of the store (the URL
|
|
172
|
+
* is withheld). The store has no app credentials yet, or the region is unknown: an uncoded
|
|
173
|
+
* error (`GRAPHQL_ERROR`, 500; not coded yet).
|
|
174
|
+
*
|
|
175
|
+
* @effect read
|
|
176
|
+
* @permission UpdateSettings
|
|
177
|
+
*/
|
|
178
|
+
authorizationUrl(region?: string, options?: Call): Promise<string>;
|
|
179
|
+
/**
|
|
180
|
+
* [deletes] Disconnect the store from Exact: the OAuth tokens, the division and the connection
|
|
181
|
+
* are cleared and Exact is switched off. The app credentials and every setting stay, so a
|
|
182
|
+
* reconnect needs only the consent. Answers `true`, or `false` when the store never had a row.
|
|
183
|
+
* Allowed without the plugin (it only removes access).
|
|
184
|
+
*
|
|
185
|
+
* Before clearing, it removes the store's Exact webhook subscriptions while the token still
|
|
186
|
+
* works and marks the store's synced delivery terms stale; either one failing is NOT reported
|
|
187
|
+
* (the engine ignores it), so a subscription can outlive the disconnect in Exact.
|
|
188
|
+
*
|
|
189
|
+
* @effect destructive
|
|
190
|
+
* @permission UpdateSettings
|
|
191
|
+
*/
|
|
192
|
+
disconnect(options?: Call): Promise<boolean>;
|
|
193
|
+
/** Live samples of the connected division. See {@link ExactOnlineSamplesModule}. */
|
|
194
|
+
samples: ExactOnlineSamplesModule;
|
|
195
|
+
/** How the connected division is organised. See {@link ExactOnlineStructureModule}. */
|
|
196
|
+
structure: ExactOnlineStructureModule;
|
|
197
|
+
/** The store's webhook subscriptions. See {@link ExactOnlineWebhooksModule}. */
|
|
198
|
+
webhooks: ExactOnlineWebhooksModule;
|
|
199
|
+
/**
|
|
200
|
+
* The Exact API calls a day `schedule` would make, sweep by sweep, and whether that passes the
|
|
201
|
+
* advisory budget. Advice only: nothing is capped by it. The schedule is read as a save would
|
|
202
|
+
* store it: merged over the store's stored schedule (a window left out keeps the stored one)
|
|
203
|
+
* and every interval rounded and clamped to its bounds, which the answer names
|
|
204
|
+
* (`minIntervalMinutes`, `maxIntervalMinutes`). It is never refused for an interval out of
|
|
205
|
+
* bounds. Makes no Exact call.
|
|
206
|
+
*
|
|
207
|
+
* Intervals and the budget are whole numbers (the engine refuses a fraction `BAD_USER_INPUT`,
|
|
208
|
+
* 400). Refused `PLUGIN_ACCESS_DENIED` (403).
|
|
209
|
+
*
|
|
210
|
+
* @effect read
|
|
211
|
+
* @permission ReadSettings
|
|
212
|
+
*/
|
|
213
|
+
syncEstimate(schedule: ExactSyncScheduleInput, options?: Call): Promise<ExactSyncEstimate>;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* `updateExactOnlineConfig`'s inline arguments, each with its GraphQL type: the SDK takes one
|
|
217
|
+
* object, the wire keeps the arguments (adding an input type would be a second door to keep).
|
|
218
|
+
*/
|
|
219
|
+
export declare const EXACT_ONLINE_CONFIG_ARGUMENTS: {
|
|
220
|
+
readonly region: "String";
|
|
221
|
+
readonly enabled: "Boolean";
|
|
222
|
+
readonly shippingItemCode: "String";
|
|
223
|
+
readonly discountItemCode: "String";
|
|
224
|
+
readonly externalLineItemCode: "String";
|
|
225
|
+
readonly pushSurcharges: "Boolean";
|
|
226
|
+
readonly surchargeItemCode: "String";
|
|
227
|
+
readonly negativeSurchargeItemCode: "String";
|
|
228
|
+
readonly autoPush: "ExactAutoPushConfigInput";
|
|
229
|
+
readonly customerSync: "ExactCustomerSyncConfigInput";
|
|
230
|
+
readonly paymentTerms: "ExactPaymentTermsConfigInput";
|
|
231
|
+
readonly deliveryTerms: "ExactDeliveryTermsConfigInput";
|
|
232
|
+
readonly syncSchedule: "ExactSyncScheduleInput";
|
|
233
|
+
readonly catalogueImportPolicy: "ExactCatalogueImportPolicyInput";
|
|
234
|
+
};
|
|
235
|
+
export declare const EXACT_ONLINE_CONFIG_QUERY = "\n query ExactOnlineConfig {\n exactOnlineConfig { \n id\n enabled\n connected\n region\n division\n companyName\n clientId\n hasCustomCredentials\n hasWebhookSecret\n lastConnectedAt\n lastRefreshedAt\n accessTokenExpiresAt\n shippingItemCode\n discountItemCode\n externalLineItemCode\n pushSurcharges\n surchargeItemCode\n negativeSurchargeItemCode\n pushSurchargesWarning\n autoPush { enabled defaultTrigger rules { customerGroupId trigger } }\n customerSync {\n enabled\n webhookEnabled\n pushEnabled\n accountFilter\n overwritePolicy\n fields { name email address }\n }\n paymentTerms {\n enabled\n synchronizationEnabled\n newAccountPaymentConditionCode\n paymentMethodConditions { paymentMethodId conditionCode }\n }\n deliveryTerms {\n enabled\n synchronizationEnabled\n forwardRequestedDeliveryDate\n sendDeliveryAddress\n newAccountShippingMethodId\n newAccountIncotermCode\n newAccountIncotermVersion\n newAccountIncotermAddress\n newAccountShippingLeadDays\n newAccountDeliveryAdvice\n }\n syncSchedule {\n delta { enabled intervalMinutes }\n full { enabled intervalMinutes }\n order { enabled intervalMinutes }\n purchaseOrders { enabled intervalMinutes }\n purchaseOrdersReconcile { enabled intervalMinutes }\n customers { enabled intervalMinutes }\n priceLists { enabled intervalMinutes }\n dailyCallBudget\n }\n catalogueImportPolicy {\n requireWebshopFlag\n nonStockItems\n unpricedItems\n priceBasis\n pictures\n stockBasis\n }\n deltaLastEnqueuedAt\n fullLastEnqueuedAt\n orderLastEnqueuedAt\n purchaseOrderLastEnqueuedAt\n purchaseOrderReconcileLastEnqueuedAt\n customerLastEnqueuedAt\n priceListLastEnqueuedAt\n }\n }\n";
|
|
236
|
+
export declare const UPDATE_EXACT_ONLINE_CONFIG_MUTATION = "\n mutation UpdateExactOnlineConfig(\n $region: String\n $enabled: Boolean\n $shippingItemCode: String\n $discountItemCode: String\n $externalLineItemCode: String\n $pushSurcharges: Boolean\n $surchargeItemCode: String\n $negativeSurchargeItemCode: String\n $autoPush: ExactAutoPushConfigInput\n $customerSync: ExactCustomerSyncConfigInput\n $paymentTerms: ExactPaymentTermsConfigInput\n $deliveryTerms: ExactDeliveryTermsConfigInput\n $syncSchedule: ExactSyncScheduleInput\n $catalogueImportPolicy: ExactCatalogueImportPolicyInput\n ) {\n updateExactOnlineConfig(\n region: $region\n enabled: $enabled\n shippingItemCode: $shippingItemCode\n discountItemCode: $discountItemCode\n externalLineItemCode: $externalLineItemCode\n pushSurcharges: $pushSurcharges\n surchargeItemCode: $surchargeItemCode\n negativeSurchargeItemCode: $negativeSurchargeItemCode\n autoPush: $autoPush\n customerSync: $customerSync\n paymentTerms: $paymentTerms\n deliveryTerms: $deliveryTerms\n syncSchedule: $syncSchedule\n catalogueImportPolicy: $catalogueImportPolicy\n ) {\n \n id\n enabled\n connected\n region\n division\n companyName\n clientId\n hasCustomCredentials\n hasWebhookSecret\n lastConnectedAt\n lastRefreshedAt\n accessTokenExpiresAt\n shippingItemCode\n discountItemCode\n externalLineItemCode\n pushSurcharges\n surchargeItemCode\n negativeSurchargeItemCode\n pushSurchargesWarning\n autoPush { enabled defaultTrigger rules { customerGroupId trigger } }\n customerSync {\n enabled\n webhookEnabled\n pushEnabled\n accountFilter\n overwritePolicy\n fields { name email address }\n }\n paymentTerms {\n enabled\n synchronizationEnabled\n newAccountPaymentConditionCode\n paymentMethodConditions { paymentMethodId conditionCode }\n }\n deliveryTerms {\n enabled\n synchronizationEnabled\n forwardRequestedDeliveryDate\n sendDeliveryAddress\n newAccountShippingMethodId\n newAccountIncotermCode\n newAccountIncotermVersion\n newAccountIncotermAddress\n newAccountShippingLeadDays\n newAccountDeliveryAdvice\n }\n syncSchedule {\n delta { enabled intervalMinutes }\n full { enabled intervalMinutes }\n order { enabled intervalMinutes }\n purchaseOrders { enabled intervalMinutes }\n purchaseOrdersReconcile { enabled intervalMinutes }\n customers { enabled intervalMinutes }\n priceLists { enabled intervalMinutes }\n dailyCallBudget\n }\n catalogueImportPolicy {\n requireWebshopFlag\n nonStockItems\n unpricedItems\n priceBasis\n pictures\n stockBasis\n }\n deltaLastEnqueuedAt\n fullLastEnqueuedAt\n orderLastEnqueuedAt\n purchaseOrderLastEnqueuedAt\n purchaseOrderReconcileLastEnqueuedAt\n customerLastEnqueuedAt\n priceListLastEnqueuedAt\n\n }\n }\n";
|
|
237
|
+
export declare const SET_EXACT_ONLINE_CREDENTIALS_MUTATION = "\n mutation SetExactOnlineCredentials(\n $clientId: String!\n $clientSecret: String\n $webhookSecret: String\n ) {\n setExactOnlineCredentials(\n clientId: $clientId\n clientSecret: $clientSecret\n webhookSecret: $webhookSecret\n ) {\n \n id\n enabled\n connected\n region\n division\n companyName\n clientId\n hasCustomCredentials\n hasWebhookSecret\n lastConnectedAt\n lastRefreshedAt\n accessTokenExpiresAt\n shippingItemCode\n discountItemCode\n externalLineItemCode\n pushSurcharges\n surchargeItemCode\n negativeSurchargeItemCode\n pushSurchargesWarning\n autoPush { enabled defaultTrigger rules { customerGroupId trigger } }\n customerSync {\n enabled\n webhookEnabled\n pushEnabled\n accountFilter\n overwritePolicy\n fields { name email address }\n }\n paymentTerms {\n enabled\n synchronizationEnabled\n newAccountPaymentConditionCode\n paymentMethodConditions { paymentMethodId conditionCode }\n }\n deliveryTerms {\n enabled\n synchronizationEnabled\n forwardRequestedDeliveryDate\n sendDeliveryAddress\n newAccountShippingMethodId\n newAccountIncotermCode\n newAccountIncotermVersion\n newAccountIncotermAddress\n newAccountShippingLeadDays\n newAccountDeliveryAdvice\n }\n syncSchedule {\n delta { enabled intervalMinutes }\n full { enabled intervalMinutes }\n order { enabled intervalMinutes }\n purchaseOrders { enabled intervalMinutes }\n purchaseOrdersReconcile { enabled intervalMinutes }\n customers { enabled intervalMinutes }\n priceLists { enabled intervalMinutes }\n dailyCallBudget\n }\n catalogueImportPolicy {\n requireWebshopFlag\n nonStockItems\n unpricedItems\n priceBasis\n pictures\n stockBasis\n }\n deltaLastEnqueuedAt\n fullLastEnqueuedAt\n orderLastEnqueuedAt\n purchaseOrderLastEnqueuedAt\n purchaseOrderReconcileLastEnqueuedAt\n customerLastEnqueuedAt\n priceListLastEnqueuedAt\n\n }\n }\n";
|
|
238
|
+
export declare const EXACT_ONLINE_AUTHORIZATION_URL_MUTATION = "\n mutation ExactOnlineAuthorizationUrl($region: String) {\n exactOnlineAuthorizationUrl(region: $region)\n }\n";
|
|
239
|
+
export declare const DISCONNECT_EXACT_ONLINE_MUTATION = "\n mutation DisconnectExactOnline {\n disconnectExactOnline\n }\n";
|
|
240
|
+
export declare const EXACT_ONLINE_SAMPLE_ACCOUNTS_QUERY = "\n query ExactOnlineSampleAccounts($limit: Int) {\n exactOnlineSampleAccounts(limit: $limit) { id code name city country email status }\n }\n";
|
|
241
|
+
export declare const EXACT_ONLINE_SAMPLE_ITEMS_QUERY = "\n query ExactOnlineSampleItems($limit: Int) {\n exactOnlineSampleItems(limit: $limit) { id code description isSalesItem isStockItem }\n }\n";
|
|
242
|
+
export declare const EXACT_ONLINE_CATALOGUE_STRUCTURE_QUERY = "\n query ExactOnlineCatalogueStructure($sample: Int) {\n exactOnlineCatalogueStructure(sample: $sample) {\n sampledCount\n distinctItemGroupCount\n topItemGroups { code description itemCount }\n classFields { field nonEmptyCount distinctCount }\n rows { code description itemGroup }\n }\n }\n";
|
|
243
|
+
export declare const EXACT_ONLINE_CUSTOMER_STRUCTURE_QUERY = "\n query ExactOnlineCustomerStructure($sample: Int) {\n exactOnlineCustomerStructure(sample: $sample) {\n sampledCount\n withEmail\n withoutEmail\n withAddress\n resellerCount\n dimensions {\n sequence\n name\n slotField\n populatedCount\n distinctCount\n values { id code description accountCount }\n }\n priceLists { id code description accountCount }\n rows { code name email city country isReseller classifications priceList }\n }\n }\n";
|
|
244
|
+
export declare const EXACT_ONLINE_PRICING_STRUCTURE_QUERY = "\n query ExactOnlinePricingStructure {\n exactOnlinePricingStructure {\n priceLists { id code description currency }\n priceListItemPriceCount\n priceListItemSamples {\n itemCode\n itemDescription\n quantity\n newPrice\n discount\n entryMethod\n basePrice\n }\n accountsWithDefaultPriceList\n customerPriceCount\n customerPriceDistinctAccounts\n customerPriceDistinctItems\n customerPriceSamples { itemCode accountName price quantity currency }\n sampled\n }\n }\n";
|
|
245
|
+
export declare const EXACT_ONLINE_WEBHOOK_STATUS_QUERY = "\n query ExactOnlineWebhookStatus {\n exactOnlineWebhookStatus {\n supported\n registered\n subscriptions { topic subscriptionId callbackUrl }\n checkedAt\n error\n }\n }\n";
|
|
246
|
+
export declare const SYNC_EXACT_ONLINE_WEBHOOKS_MUTATION = "\n mutation SyncExactOnlineWebhooks {\n syncExactOnlineWebhooks\n }\n";
|
|
247
|
+
export declare const EXACT_ONLINE_SYNC_ESTIMATE_QUERY = "\n query ExactOnlineSyncEstimate($schedule: ExactSyncScheduleInput!) {\n exactOnlineSyncEstimate(schedule: $schedule) {\n delta { \n enabled\n intervalMinutes\n minIntervalMinutes\n maxIntervalMinutes\n callsPerRun\n runsPerDay\n callsPerDay\n }\n full { \n enabled\n intervalMinutes\n minIntervalMinutes\n maxIntervalMinutes\n callsPerRun\n runsPerDay\n callsPerDay\n }\n order { \n enabled\n intervalMinutes\n minIntervalMinutes\n maxIntervalMinutes\n callsPerRun\n runsPerDay\n callsPerDay\n }\n purchaseOrders { \n enabled\n intervalMinutes\n minIntervalMinutes\n maxIntervalMinutes\n callsPerRun\n runsPerDay\n callsPerDay\n }\n purchaseOrdersReconcile { \n enabled\n intervalMinutes\n minIntervalMinutes\n maxIntervalMinutes\n callsPerRun\n runsPerDay\n callsPerDay\n }\n customers { \n enabled\n intervalMinutes\n minIntervalMinutes\n maxIntervalMinutes\n callsPerRun\n runsPerDay\n callsPerDay\n }\n priceLists { \n enabled\n intervalMinutes\n minIntervalMinutes\n maxIntervalMinutes\n callsPerRun\n runsPerDay\n callsPerDay\n }\n total\n dailyCallBudget\n overBudget\n }\n }\n";
|
|
248
|
+
export declare function createExactOnlineModule(transport: Transport): ExactOnlineModule;
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { ValidationError } from '@sixtyninecommerce/core';
|
|
2
|
+
import { fieldOf } from '../catalog/types.js';
|
|
3
|
+
const SYNC_WINDOW_FIELDS = /* GraphQL */ `enabled intervalMinutes`;
|
|
4
|
+
const CONFIG_FIELDS = /* GraphQL */ `
|
|
5
|
+
id
|
|
6
|
+
enabled
|
|
7
|
+
connected
|
|
8
|
+
region
|
|
9
|
+
division
|
|
10
|
+
companyName
|
|
11
|
+
clientId
|
|
12
|
+
hasCustomCredentials
|
|
13
|
+
hasWebhookSecret
|
|
14
|
+
lastConnectedAt
|
|
15
|
+
lastRefreshedAt
|
|
16
|
+
accessTokenExpiresAt
|
|
17
|
+
shippingItemCode
|
|
18
|
+
discountItemCode
|
|
19
|
+
externalLineItemCode
|
|
20
|
+
pushSurcharges
|
|
21
|
+
surchargeItemCode
|
|
22
|
+
negativeSurchargeItemCode
|
|
23
|
+
pushSurchargesWarning
|
|
24
|
+
autoPush { enabled defaultTrigger rules { customerGroupId trigger } }
|
|
25
|
+
customerSync {
|
|
26
|
+
enabled
|
|
27
|
+
webhookEnabled
|
|
28
|
+
pushEnabled
|
|
29
|
+
accountFilter
|
|
30
|
+
overwritePolicy
|
|
31
|
+
fields { name email address }
|
|
32
|
+
}
|
|
33
|
+
paymentTerms {
|
|
34
|
+
enabled
|
|
35
|
+
synchronizationEnabled
|
|
36
|
+
newAccountPaymentConditionCode
|
|
37
|
+
paymentMethodConditions { paymentMethodId conditionCode }
|
|
38
|
+
}
|
|
39
|
+
deliveryTerms {
|
|
40
|
+
enabled
|
|
41
|
+
synchronizationEnabled
|
|
42
|
+
forwardRequestedDeliveryDate
|
|
43
|
+
sendDeliveryAddress
|
|
44
|
+
newAccountShippingMethodId
|
|
45
|
+
newAccountIncotermCode
|
|
46
|
+
newAccountIncotermVersion
|
|
47
|
+
newAccountIncotermAddress
|
|
48
|
+
newAccountShippingLeadDays
|
|
49
|
+
newAccountDeliveryAdvice
|
|
50
|
+
}
|
|
51
|
+
syncSchedule {
|
|
52
|
+
delta { ${SYNC_WINDOW_FIELDS} }
|
|
53
|
+
full { ${SYNC_WINDOW_FIELDS} }
|
|
54
|
+
order { ${SYNC_WINDOW_FIELDS} }
|
|
55
|
+
purchaseOrders { ${SYNC_WINDOW_FIELDS} }
|
|
56
|
+
purchaseOrdersReconcile { ${SYNC_WINDOW_FIELDS} }
|
|
57
|
+
customers { ${SYNC_WINDOW_FIELDS} }
|
|
58
|
+
priceLists { ${SYNC_WINDOW_FIELDS} }
|
|
59
|
+
dailyCallBudget
|
|
60
|
+
}
|
|
61
|
+
catalogueImportPolicy {
|
|
62
|
+
requireWebshopFlag
|
|
63
|
+
nonStockItems
|
|
64
|
+
unpricedItems
|
|
65
|
+
priceBasis
|
|
66
|
+
pictures
|
|
67
|
+
stockBasis
|
|
68
|
+
}
|
|
69
|
+
deltaLastEnqueuedAt
|
|
70
|
+
fullLastEnqueuedAt
|
|
71
|
+
orderLastEnqueuedAt
|
|
72
|
+
purchaseOrderLastEnqueuedAt
|
|
73
|
+
purchaseOrderReconcileLastEnqueuedAt
|
|
74
|
+
customerLastEnqueuedAt
|
|
75
|
+
priceListLastEnqueuedAt
|
|
76
|
+
`;
|
|
77
|
+
/**
|
|
78
|
+
* `updateExactOnlineConfig`'s inline arguments, each with its GraphQL type: the SDK takes one
|
|
79
|
+
* object, the wire keeps the arguments (adding an input type would be a second door to keep).
|
|
80
|
+
*/
|
|
81
|
+
export const EXACT_ONLINE_CONFIG_ARGUMENTS = {
|
|
82
|
+
region: 'String',
|
|
83
|
+
enabled: 'Boolean',
|
|
84
|
+
shippingItemCode: 'String',
|
|
85
|
+
discountItemCode: 'String',
|
|
86
|
+
externalLineItemCode: 'String',
|
|
87
|
+
pushSurcharges: 'Boolean',
|
|
88
|
+
surchargeItemCode: 'String',
|
|
89
|
+
negativeSurchargeItemCode: 'String',
|
|
90
|
+
autoPush: 'ExactAutoPushConfigInput',
|
|
91
|
+
customerSync: 'ExactCustomerSyncConfigInput',
|
|
92
|
+
paymentTerms: 'ExactPaymentTermsConfigInput',
|
|
93
|
+
deliveryTerms: 'ExactDeliveryTermsConfigInput',
|
|
94
|
+
syncSchedule: 'ExactSyncScheduleInput',
|
|
95
|
+
catalogueImportPolicy: 'ExactCatalogueImportPolicyInput',
|
|
96
|
+
};
|
|
97
|
+
/** The keys the engine cannot store as `null` (a not-null column, a `.trim()`, a section read). */
|
|
98
|
+
const NEVER_NULL_CONFIG_KEYS = [
|
|
99
|
+
'region',
|
|
100
|
+
'enabled',
|
|
101
|
+
'shippingItemCode',
|
|
102
|
+
'discountItemCode',
|
|
103
|
+
'paymentTerms',
|
|
104
|
+
'deliveryTerms',
|
|
105
|
+
];
|
|
106
|
+
export const EXACT_ONLINE_CONFIG_QUERY = /* GraphQL */ `
|
|
107
|
+
query ExactOnlineConfig {
|
|
108
|
+
exactOnlineConfig { ${CONFIG_FIELDS} }
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
// The variable list and the arguments are written out, never spliced in from
|
|
112
|
+
// EXACT_ONLINE_CONFIG_ARGUMENTS: the package's coverage specs parse every document literal with
|
|
113
|
+
// each `${…}` read as a field name, so an interpolated variable list fails them. The SDK spec
|
|
114
|
+
// pins the variables against the map and the engine's arguments.
|
|
115
|
+
export const UPDATE_EXACT_ONLINE_CONFIG_MUTATION = /* GraphQL */ `
|
|
116
|
+
mutation UpdateExactOnlineConfig(
|
|
117
|
+
$region: String
|
|
118
|
+
$enabled: Boolean
|
|
119
|
+
$shippingItemCode: String
|
|
120
|
+
$discountItemCode: String
|
|
121
|
+
$externalLineItemCode: String
|
|
122
|
+
$pushSurcharges: Boolean
|
|
123
|
+
$surchargeItemCode: String
|
|
124
|
+
$negativeSurchargeItemCode: String
|
|
125
|
+
$autoPush: ExactAutoPushConfigInput
|
|
126
|
+
$customerSync: ExactCustomerSyncConfigInput
|
|
127
|
+
$paymentTerms: ExactPaymentTermsConfigInput
|
|
128
|
+
$deliveryTerms: ExactDeliveryTermsConfigInput
|
|
129
|
+
$syncSchedule: ExactSyncScheduleInput
|
|
130
|
+
$catalogueImportPolicy: ExactCatalogueImportPolicyInput
|
|
131
|
+
) {
|
|
132
|
+
updateExactOnlineConfig(
|
|
133
|
+
region: $region
|
|
134
|
+
enabled: $enabled
|
|
135
|
+
shippingItemCode: $shippingItemCode
|
|
136
|
+
discountItemCode: $discountItemCode
|
|
137
|
+
externalLineItemCode: $externalLineItemCode
|
|
138
|
+
pushSurcharges: $pushSurcharges
|
|
139
|
+
surchargeItemCode: $surchargeItemCode
|
|
140
|
+
negativeSurchargeItemCode: $negativeSurchargeItemCode
|
|
141
|
+
autoPush: $autoPush
|
|
142
|
+
customerSync: $customerSync
|
|
143
|
+
paymentTerms: $paymentTerms
|
|
144
|
+
deliveryTerms: $deliveryTerms
|
|
145
|
+
syncSchedule: $syncSchedule
|
|
146
|
+
catalogueImportPolicy: $catalogueImportPolicy
|
|
147
|
+
) {
|
|
148
|
+
${CONFIG_FIELDS}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
export const SET_EXACT_ONLINE_CREDENTIALS_MUTATION = /* GraphQL */ `
|
|
153
|
+
mutation SetExactOnlineCredentials(
|
|
154
|
+
$clientId: String!
|
|
155
|
+
$clientSecret: String
|
|
156
|
+
$webhookSecret: String
|
|
157
|
+
) {
|
|
158
|
+
setExactOnlineCredentials(
|
|
159
|
+
clientId: $clientId
|
|
160
|
+
clientSecret: $clientSecret
|
|
161
|
+
webhookSecret: $webhookSecret
|
|
162
|
+
) {
|
|
163
|
+
${CONFIG_FIELDS}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
`;
|
|
167
|
+
export const EXACT_ONLINE_AUTHORIZATION_URL_MUTATION = /* GraphQL */ `
|
|
168
|
+
mutation ExactOnlineAuthorizationUrl($region: String) {
|
|
169
|
+
exactOnlineAuthorizationUrl(region: $region)
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
export const DISCONNECT_EXACT_ONLINE_MUTATION = /* GraphQL */ `
|
|
173
|
+
mutation DisconnectExactOnline {
|
|
174
|
+
disconnectExactOnline
|
|
175
|
+
}
|
|
176
|
+
`;
|
|
177
|
+
export const EXACT_ONLINE_SAMPLE_ACCOUNTS_QUERY = /* GraphQL */ `
|
|
178
|
+
query ExactOnlineSampleAccounts($limit: Int) {
|
|
179
|
+
exactOnlineSampleAccounts(limit: $limit) { id code name city country email status }
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
182
|
+
export const EXACT_ONLINE_SAMPLE_ITEMS_QUERY = /* GraphQL */ `
|
|
183
|
+
query ExactOnlineSampleItems($limit: Int) {
|
|
184
|
+
exactOnlineSampleItems(limit: $limit) { id code description isSalesItem isStockItem }
|
|
185
|
+
}
|
|
186
|
+
`;
|
|
187
|
+
export const EXACT_ONLINE_CATALOGUE_STRUCTURE_QUERY = /* GraphQL */ `
|
|
188
|
+
query ExactOnlineCatalogueStructure($sample: Int) {
|
|
189
|
+
exactOnlineCatalogueStructure(sample: $sample) {
|
|
190
|
+
sampledCount
|
|
191
|
+
distinctItemGroupCount
|
|
192
|
+
topItemGroups { code description itemCount }
|
|
193
|
+
classFields { field nonEmptyCount distinctCount }
|
|
194
|
+
rows { code description itemGroup }
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
export const EXACT_ONLINE_CUSTOMER_STRUCTURE_QUERY = /* GraphQL */ `
|
|
199
|
+
query ExactOnlineCustomerStructure($sample: Int) {
|
|
200
|
+
exactOnlineCustomerStructure(sample: $sample) {
|
|
201
|
+
sampledCount
|
|
202
|
+
withEmail
|
|
203
|
+
withoutEmail
|
|
204
|
+
withAddress
|
|
205
|
+
resellerCount
|
|
206
|
+
dimensions {
|
|
207
|
+
sequence
|
|
208
|
+
name
|
|
209
|
+
slotField
|
|
210
|
+
populatedCount
|
|
211
|
+
distinctCount
|
|
212
|
+
values { id code description accountCount }
|
|
213
|
+
}
|
|
214
|
+
priceLists { id code description accountCount }
|
|
215
|
+
rows { code name email city country isReseller classifications priceList }
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
`;
|
|
219
|
+
export const EXACT_ONLINE_PRICING_STRUCTURE_QUERY = /* GraphQL */ `
|
|
220
|
+
query ExactOnlinePricingStructure {
|
|
221
|
+
exactOnlinePricingStructure {
|
|
222
|
+
priceLists { id code description currency }
|
|
223
|
+
priceListItemPriceCount
|
|
224
|
+
priceListItemSamples {
|
|
225
|
+
itemCode
|
|
226
|
+
itemDescription
|
|
227
|
+
quantity
|
|
228
|
+
newPrice
|
|
229
|
+
discount
|
|
230
|
+
entryMethod
|
|
231
|
+
basePrice
|
|
232
|
+
}
|
|
233
|
+
accountsWithDefaultPriceList
|
|
234
|
+
customerPriceCount
|
|
235
|
+
customerPriceDistinctAccounts
|
|
236
|
+
customerPriceDistinctItems
|
|
237
|
+
customerPriceSamples { itemCode accountName price quantity currency }
|
|
238
|
+
sampled
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
`;
|
|
242
|
+
export const EXACT_ONLINE_WEBHOOK_STATUS_QUERY = /* GraphQL */ `
|
|
243
|
+
query ExactOnlineWebhookStatus {
|
|
244
|
+
exactOnlineWebhookStatus {
|
|
245
|
+
supported
|
|
246
|
+
registered
|
|
247
|
+
subscriptions { topic subscriptionId callbackUrl }
|
|
248
|
+
checkedAt
|
|
249
|
+
error
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
`;
|
|
253
|
+
export const SYNC_EXACT_ONLINE_WEBHOOKS_MUTATION = /* GraphQL */ `
|
|
254
|
+
mutation SyncExactOnlineWebhooks {
|
|
255
|
+
syncExactOnlineWebhooks
|
|
256
|
+
}
|
|
257
|
+
`;
|
|
258
|
+
const SWEEP_ESTIMATE_FIELDS = /* GraphQL */ `
|
|
259
|
+
enabled
|
|
260
|
+
intervalMinutes
|
|
261
|
+
minIntervalMinutes
|
|
262
|
+
maxIntervalMinutes
|
|
263
|
+
callsPerRun
|
|
264
|
+
runsPerDay
|
|
265
|
+
callsPerDay
|
|
266
|
+
`;
|
|
267
|
+
export const EXACT_ONLINE_SYNC_ESTIMATE_QUERY = /* GraphQL */ `
|
|
268
|
+
query ExactOnlineSyncEstimate($schedule: ExactSyncScheduleInput!) {
|
|
269
|
+
exactOnlineSyncEstimate(schedule: $schedule) {
|
|
270
|
+
delta { ${SWEEP_ESTIMATE_FIELDS} }
|
|
271
|
+
full { ${SWEEP_ESTIMATE_FIELDS} }
|
|
272
|
+
order { ${SWEEP_ESTIMATE_FIELDS} }
|
|
273
|
+
purchaseOrders { ${SWEEP_ESTIMATE_FIELDS} }
|
|
274
|
+
purchaseOrdersReconcile { ${SWEEP_ESTIMATE_FIELDS} }
|
|
275
|
+
customers { ${SWEEP_ESTIMATE_FIELDS} }
|
|
276
|
+
priceLists { ${SWEEP_ESTIMATE_FIELDS} }
|
|
277
|
+
total
|
|
278
|
+
dailyCallBudget
|
|
279
|
+
overBudget
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
`;
|
|
283
|
+
const invalidInput = (message, field) => new ValidationError({
|
|
284
|
+
code: 'INVALID_EXACT_ONLINE_INPUT',
|
|
285
|
+
message,
|
|
286
|
+
status: 400,
|
|
287
|
+
service: 'vendure',
|
|
288
|
+
...(field ? { details: [{ field, code: 'INVALID_EXACT_ONLINE_INPUT', message }] } : {}),
|
|
289
|
+
});
|
|
290
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
291
|
+
function requireObject(value, method) {
|
|
292
|
+
if (!isObject(value))
|
|
293
|
+
throw invalidInput(`${method} takes an input object.`);
|
|
294
|
+
return value;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The input as the mutation's variables, as given: a key left out stays out, so the engine keeps
|
|
298
|
+
* the stored value. A key the engine has no argument for is refused here: GraphQL ignores a
|
|
299
|
+
* variable the operation does not declare, so it would otherwise be dropped silently.
|
|
300
|
+
*/
|
|
301
|
+
function configVariables(input) {
|
|
302
|
+
const variables = requireObject(input, 'config.update');
|
|
303
|
+
for (const key of Object.keys(variables)) {
|
|
304
|
+
if (!Object.hasOwn(EXACT_ONLINE_CONFIG_ARGUMENTS, key)) {
|
|
305
|
+
throw invalidInput(`${key} is not an Exact Online setting.`, key);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
for (const key of NEVER_NULL_CONFIG_KEYS) {
|
|
309
|
+
if (Object.hasOwn(variables, key) && variables[key] === null) {
|
|
310
|
+
throw invalidInput(`${key} cannot be null: leave it out to keep the stored value.`, key);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return variables;
|
|
314
|
+
}
|
|
315
|
+
export function createExactOnlineModule(transport) {
|
|
316
|
+
const read = (document, field, options, variables = {}) => fieldOf(transport, document, field, variables, options);
|
|
317
|
+
return {
|
|
318
|
+
config: {
|
|
319
|
+
async get(options) {
|
|
320
|
+
return ((await read(EXACT_ONLINE_CONFIG_QUERY, 'exactOnlineConfig', options)) ?? null);
|
|
321
|
+
},
|
|
322
|
+
async update(input, options) {
|
|
323
|
+
return read(UPDATE_EXACT_ONLINE_CONFIG_MUTATION, 'updateExactOnlineConfig', options, configVariables(input));
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
credentials: {
|
|
327
|
+
async set(input, options) {
|
|
328
|
+
const { clientId, clientSecret, webhookSecret } = requireObject(input, 'credentials.set');
|
|
329
|
+
if (typeof clientId !== 'string') {
|
|
330
|
+
throw invalidInput('credentials.set needs the Exact app client id.', 'clientId');
|
|
331
|
+
}
|
|
332
|
+
return read(SET_EXACT_ONLINE_CREDENTIALS_MUTATION, 'setExactOnlineCredentials', options, { clientId, clientSecret, webhookSecret });
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
authorizationUrl(region, options) {
|
|
336
|
+
return read(EXACT_ONLINE_AUTHORIZATION_URL_MUTATION, 'exactOnlineAuthorizationUrl', options, region === undefined ? {} : { region });
|
|
337
|
+
},
|
|
338
|
+
async disconnect(options) {
|
|
339
|
+
return ((await read(DISCONNECT_EXACT_ONLINE_MUTATION, 'disconnectExactOnline', options)) === true);
|
|
340
|
+
},
|
|
341
|
+
samples: {
|
|
342
|
+
accounts(options) {
|
|
343
|
+
const { limit, ...call } = options ?? {};
|
|
344
|
+
return read(EXACT_ONLINE_SAMPLE_ACCOUNTS_QUERY, 'exactOnlineSampleAccounts', call, limit === undefined ? {} : { limit });
|
|
345
|
+
},
|
|
346
|
+
items(options) {
|
|
347
|
+
const { limit, ...call } = options ?? {};
|
|
348
|
+
return read(EXACT_ONLINE_SAMPLE_ITEMS_QUERY, 'exactOnlineSampleItems', call, limit === undefined ? {} : { limit });
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
structure: {
|
|
352
|
+
catalogue(options) {
|
|
353
|
+
const { sample, ...call } = options ?? {};
|
|
354
|
+
return read(EXACT_ONLINE_CATALOGUE_STRUCTURE_QUERY, 'exactOnlineCatalogueStructure', call, sample === undefined ? {} : { sample });
|
|
355
|
+
},
|
|
356
|
+
customers(options) {
|
|
357
|
+
const { sample, ...call } = options ?? {};
|
|
358
|
+
return read(EXACT_ONLINE_CUSTOMER_STRUCTURE_QUERY, 'exactOnlineCustomerStructure', call, sample === undefined ? {} : { sample });
|
|
359
|
+
},
|
|
360
|
+
pricing(options) {
|
|
361
|
+
return read(EXACT_ONLINE_PRICING_STRUCTURE_QUERY, 'exactOnlinePricingStructure', options);
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
webhooks: {
|
|
365
|
+
status(options) {
|
|
366
|
+
return read(EXACT_ONLINE_WEBHOOK_STATUS_QUERY, 'exactOnlineWebhookStatus', options);
|
|
367
|
+
},
|
|
368
|
+
async sync(options) {
|
|
369
|
+
return ((await read(SYNC_EXACT_ONLINE_WEBHOOKS_MUTATION, 'syncExactOnlineWebhooks', options)) === true);
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
async syncEstimate(schedule, options) {
|
|
373
|
+
return read(EXACT_ONLINE_SYNC_ESTIMATE_QUERY, 'exactOnlineSyncEstimate', options, { schedule: requireObject(schedule, 'syncEstimate') });
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
}
|