@sixtyninecommerce/admin 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +4598 -128
  2. package/dist/catalog/assets.d.ts +120 -8
  3. package/dist/catalog/assets.js +98 -12
  4. package/dist/catalog/collections.d.ts +279 -14
  5. package/dist/catalog/collections.js +246 -15
  6. package/dist/catalog/index.d.ts +9 -2
  7. package/dist/catalog/index.js +4 -0
  8. package/dist/catalog/products.d.ts +318 -17
  9. package/dist/catalog/products.js +182 -14
  10. package/dist/catalog/properties.d.ts +102 -14
  11. package/dist/catalog/properties.js +13 -0
  12. package/dist/catalog/recommendations.d.ts +261 -0
  13. package/dist/catalog/recommendations.js +145 -0
  14. package/dist/catalog/reviews.d.ts +368 -0
  15. package/dist/catalog/reviews.js +318 -0
  16. package/dist/catalog/types.d.ts +17 -1
  17. package/dist/catalog/types.js +10 -0
  18. package/dist/catalog/variant-find.d.ts +136 -0
  19. package/dist/catalog/variant-find.js +239 -0
  20. package/dist/catalog/variants.d.ts +282 -25
  21. package/dist/catalog/variants.js +173 -25
  22. package/dist/catalog/visibility.d.ts +20 -5
  23. package/dist/catalog/visibility.js +19 -1
  24. package/dist/client.d.ts +116 -9
  25. package/dist/client.js +41 -7
  26. package/dist/content/assets.d.ts +286 -0
  27. package/dist/content/assets.js +181 -0
  28. package/dist/content/items.d.ts +269 -0
  29. package/dist/content/items.js +170 -0
  30. package/dist/content/types.d.ts +282 -0
  31. package/dist/content/types.js +100 -0
  32. package/dist/customers/age-verification.d.ts +66 -0
  33. package/dist/customers/age-verification.js +79 -0
  34. package/dist/customers/credit.d.ts +263 -0
  35. package/dist/customers/credit.js +244 -0
  36. package/dist/customers/delivery-preferences.d.ts +120 -0
  37. package/dist/customers/delivery-preferences.js +97 -0
  38. package/dist/customers/groups.d.ts +207 -0
  39. package/dist/customers/groups.js +438 -0
  40. package/dist/customers/index.d.ts +447 -37
  41. package/dist/customers/index.js +313 -40
  42. package/dist/customers/invitation-status.d.ts +57 -0
  43. package/dist/customers/invitation-status.js +21 -0
  44. package/dist/customers/notes.d.ts +67 -0
  45. package/dist/customers/notes.js +51 -0
  46. package/dist/customers/notification-recipients.d.ts +97 -0
  47. package/dist/customers/notification-recipients.js +84 -0
  48. package/dist/customers/saved-lists.d.ts +42 -0
  49. package/dist/customers/saved-lists.js +61 -0
  50. package/dist/customers/vat.d.ts +83 -0
  51. package/dist/customers/vat.js +46 -0
  52. package/dist/customers/wire.d.ts +20 -0
  53. package/dist/customers/wire.js +35 -0
  54. package/dist/documents/ar.d.ts +307 -0
  55. package/dist/documents/ar.js +254 -0
  56. package/dist/documents/index.d.ts +731 -21
  57. package/dist/documents/index.js +436 -24
  58. package/dist/documents/pdf.d.ts +2 -0
  59. package/dist/documents/pdf.js +11 -0
  60. package/dist/fulfillments/create.d.ts +167 -0
  61. package/dist/fulfillments/create.js +216 -0
  62. package/dist/fulfillments/index.d.ts +121 -10
  63. package/dist/fulfillments/index.js +120 -2
  64. package/dist/fulfillments/payment-policy.d.ts +64 -0
  65. package/dist/fulfillments/payment-policy.js +140 -0
  66. package/dist/fulfillments/warehouse.d.ts +724 -0
  67. package/dist/fulfillments/warehouse.js +914 -0
  68. package/dist/geo/index.d.ts +119 -0
  69. package/dist/geo/index.js +107 -0
  70. package/dist/index.d.ts +129 -30
  71. package/dist/index.js +47 -9
  72. package/dist/integrations/afas-actions.d.ts +234 -0
  73. package/dist/integrations/afas-actions.js +310 -0
  74. package/dist/integrations/afas-types.d.ts +483 -0
  75. package/dist/integrations/afas-types.js +5 -0
  76. package/dist/integrations/afas.d.ts +234 -0
  77. package/dist/integrations/afas.js +290 -0
  78. package/dist/integrations/connections.d.ts +103 -0
  79. package/dist/integrations/connections.js +55 -0
  80. package/dist/integrations/esp.d.ts +313 -0
  81. package/dist/integrations/esp.js +169 -0
  82. package/dist/integrations/exact-online-types.d.ts +423 -0
  83. package/dist/integrations/exact-online-types.js +6 -0
  84. package/dist/integrations/exact-online.d.ts +248 -0
  85. package/dist/integrations/exact-online.js +376 -0
  86. package/dist/integrations/index.d.ts +40 -0
  87. package/dist/integrations/index.js +24 -0
  88. package/dist/integrations/pipeline-keys.d.ts +13 -0
  89. package/dist/integrations/pipeline-keys.js +22 -0
  90. package/dist/integrations/pipelines.d.ts +114 -0
  91. package/dist/integrations/pipelines.js +46 -0
  92. package/dist/integrations/types.d.ts +322 -0
  93. package/dist/integrations/types.js +8 -0
  94. package/dist/jobs/bulk-action-run.d.ts +11 -2
  95. package/dist/jobs/bulk-action-run.js +4 -5
  96. package/dist/locations/index.d.ts +66 -0
  97. package/dist/locations/index.js +31 -0
  98. package/dist/meta/index.d.ts +162 -0
  99. package/dist/orders/bulk.d.ts +75 -0
  100. package/dist/orders/bulk.js +150 -0
  101. package/dist/orders/cancel-with-money.d.ts +227 -0
  102. package/dist/orders/cancel-with-money.js +153 -0
  103. package/dist/orders/commit-edit.d.ts +7 -1
  104. package/dist/orders/commit-edit.js +5 -1
  105. package/dist/orders/deposit-policy.d.ts +103 -0
  106. package/dist/orders/deposit-policy.js +202 -0
  107. package/dist/orders/drafts.d.ts +800 -0
  108. package/dist/orders/drafts.js +771 -0
  109. package/dist/orders/fields.d.ts +245 -0
  110. package/dist/orders/fields.js +188 -0
  111. package/dist/orders/get.d.ts +29 -19
  112. package/dist/orders/get.js +17 -8
  113. package/dist/orders/index.d.ts +125 -5
  114. package/dist/orders/index.js +35 -2
  115. package/dist/orders/lifecycle.d.ts +128 -0
  116. package/dist/orders/lifecycle.js +158 -0
  117. package/dist/orders/line-price-preview.d.ts +7 -2
  118. package/dist/orders/list.d.ts +222 -0
  119. package/dist/orders/list.js +377 -0
  120. package/dist/orders/manual-discounts.d.ts +11 -2
  121. package/dist/orders/manual-discounts.js +2 -0
  122. package/dist/orders/manual-pricing.d.ts +5 -0
  123. package/dist/orders/order-entry.d.ts +20 -7
  124. package/dist/orders/plan-edit.d.ts +1 -1
  125. package/dist/orders/plan-edit.js +4 -1
  126. package/dist/orders/settings.d.ts +201 -0
  127. package/dist/orders/settings.js +325 -0
  128. package/dist/orders/status.d.ts +159 -13
  129. package/dist/orders/status.js +21 -0
  130. package/dist/orders/surcharges.d.ts +8 -1
  131. package/dist/orders/surcharges.js +3 -2
  132. package/dist/payments/account-credit.d.ts +30 -0
  133. package/dist/payments/account-credit.js +19 -0
  134. package/dist/payments/ar.d.ts +292 -0
  135. package/dist/payments/ar.js +223 -0
  136. package/dist/payments/connected-account.d.ts +47 -0
  137. package/dist/payments/connected-account.js +61 -0
  138. package/dist/payments/credit-noted-fields.d.ts +12 -0
  139. package/dist/payments/credit-noted-fields.js +37 -0
  140. package/dist/payments/index.d.ts +263 -10
  141. package/dist/payments/index.js +133 -1
  142. package/dist/payments/methods.d.ts +332 -0
  143. package/dist/payments/methods.js +363 -0
  144. package/dist/payments/mollie-methods.d.ts +159 -0
  145. package/dist/payments/mollie-methods.js +141 -0
  146. package/dist/payments/payment-links.d.ts +180 -0
  147. package/dist/payments/payment-links.js +97 -0
  148. package/dist/payments/provider-keys.d.ts +150 -0
  149. package/dist/payments/provider-keys.js +118 -0
  150. package/dist/payments/providers.d.ts +86 -11
  151. package/dist/payments/providers.js +29 -0
  152. package/dist/payments/requests.d.ts +144 -0
  153. package/dist/payments/requests.js +92 -0
  154. package/dist/payments/store-credit-fields.d.ts +15 -0
  155. package/dist/payments/store-credit-fields.js +51 -0
  156. package/dist/pickups/index.d.ts +104 -0
  157. package/dist/pickups/index.js +105 -0
  158. package/dist/platform/channels.d.ts +132 -0
  159. package/dist/platform/channels.js +128 -0
  160. package/dist/platform/geo.d.ts +123 -0
  161. package/dist/platform/geo.js +144 -0
  162. package/dist/platform/tax.d.ts +154 -0
  163. package/dist/platform/tax.js +139 -0
  164. package/dist/pos/anomalies.d.ts +158 -0
  165. package/dist/pos/anomalies.js +64 -0
  166. package/dist/pos/assisted-selling.d.ts +79 -0
  167. package/dist/pos/assisted-selling.js +38 -0
  168. package/dist/pos/exchanges.d.ts +103 -0
  169. package/dist/pos/exchanges.js +22 -0
  170. package/dist/pos/gift-cards.d.ts +135 -0
  171. package/dist/pos/gift-cards.js +47 -0
  172. package/dist/pos/index.d.ts +2125 -32
  173. package/dist/pos/index.js +742 -4
  174. package/dist/pos/no-receipt.d.ts +94 -0
  175. package/dist/pos/no-receipt.js +25 -0
  176. package/dist/pos/offline-sales.d.ts +187 -0
  177. package/dist/pos/offline-sales.js +116 -0
  178. package/dist/pos/pay-by-link.d.ts +143 -0
  179. package/dist/pos/pay-by-link.js +57 -0
  180. package/dist/pos/quick-keys.d.ts +103 -0
  181. package/dist/pos/quick-keys.js +45 -0
  182. package/dist/pos/reports.d.ts +360 -0
  183. package/dist/pos/reports.js +62 -0
  184. package/dist/pos/returns.d.ts +217 -0
  185. package/dist/pos/returns.js +53 -0
  186. package/dist/pricing/bulk-coupons.d.ts +139 -0
  187. package/dist/pricing/bulk-coupons.js +112 -0
  188. package/dist/pricing/index.d.ts +177 -4
  189. package/dist/pricing/index.js +176 -1
  190. package/dist/pricing/price-lists.d.ts +604 -0
  191. package/dist/pricing/price-lists.js +600 -0
  192. package/dist/pricing/vouchers.d.ts +103 -0
  193. package/dist/pricing/vouchers.js +69 -0
  194. package/dist/purchasing/alerts.d.ts +89 -0
  195. package/dist/purchasing/alerts.js +62 -0
  196. package/dist/purchasing/cost.d.ts +110 -0
  197. package/dist/purchasing/cost.js +86 -0
  198. package/dist/purchasing/index.d.ts +36 -0
  199. package/dist/purchasing/index.js +16 -0
  200. package/dist/purchasing/purchase-orders.d.ts +548 -0
  201. package/dist/purchasing/purchase-orders.js +491 -0
  202. package/dist/purchasing/replenishment.d.ts +281 -0
  203. package/dist/purchasing/replenishment.js +240 -0
  204. package/dist/purchasing/settings.d.ts +152 -0
  205. package/dist/purchasing/settings.js +181 -0
  206. package/dist/purchasing/suppliers.d.ts +476 -0
  207. package/dist/purchasing/suppliers.js +438 -0
  208. package/dist/quotes/index.d.ts +501 -0
  209. package/dist/quotes/index.js +439 -0
  210. package/dist/reports/index.d.ts +71 -8
  211. package/dist/reports/index.js +74 -11
  212. package/dist/returns/index.d.ts +818 -0
  213. package/dist/returns/index.js +844 -0
  214. package/dist/search/index.d.ts +174 -0
  215. package/dist/search/index.js +125 -0
  216. package/dist/shipping/definitions.d.ts +29 -0
  217. package/dist/shipping/definitions.js +47 -0
  218. package/dist/shipping/fulfillment-profiles.d.ts +174 -0
  219. package/dist/shipping/fulfillment-profiles.js +104 -0
  220. package/dist/shipping/hendriks.d.ts +97 -0
  221. package/dist/shipping/hendriks.js +50 -0
  222. package/dist/shipping/index.d.ts +48 -0
  223. package/dist/shipping/index.js +25 -0
  224. package/dist/shipping/methods.d.ts +198 -0
  225. package/dist/shipping/methods.js +240 -0
  226. package/dist/shipping/myparcel.d.ts +254 -0
  227. package/dist/shipping/myparcel.js +178 -0
  228. package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
  229. package/dist/shipping/parcel-rule.d.ts +6 -5
  230. package/dist/shipping/parcel-rule.js +21 -23
  231. package/dist/shipping/rate-tables.d.ts +179 -0
  232. package/dist/shipping/rate-tables.js +184 -0
  233. package/dist/stock/index.d.ts +10 -3
  234. package/dist/stock/index.js +3 -0
  235. package/dist/stock/locations.d.ts +144 -0
  236. package/dist/stock/locations.js +168 -0
  237. package/dist/stock/transfers.d.ts +216 -43
  238. package/dist/stock/transfers.js +140 -13
  239. package/dist/stored-value/index.d.ts +214 -4
  240. package/dist/stored-value/index.js +152 -0
  241. package/dist/subscriptions/index.d.ts +682 -0
  242. package/dist/subscriptions/index.js +815 -0
  243. package/dist/tax/index.d.ts +76 -1
  244. package/dist/tax/index.js +50 -0
  245. package/dist/tenant/email-style.d.ts +102 -0
  246. package/dist/tenant/email-style.js +72 -0
  247. package/dist/tenant/email-templates.d.ts +66 -0
  248. package/dist/tenant/email-templates.js +54 -0
  249. package/dist/tenant/notifications.d.ts +23 -17
  250. package/dist/tenant/settings-sources.d.ts +1 -1
  251. package/dist/tenant/time-zone.d.ts +17 -0
  252. package/dist/tenant/time-zone.js +11 -0
  253. package/dist/types.d.ts +51 -4
  254. package/dist/users/index.d.ts +3 -0
  255. package/dist/users/index.js +2 -0
  256. package/dist/users/warehouses.d.ts +50 -0
  257. package/dist/users/warehouses.js +51 -0
  258. 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
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Integrations (headless spec §9.2): the store's connections to other systems. The data
3
+ * pipelines' source connections, connectors and import and export set-ups, the e-mail marketing
4
+ * connection (`esp`), the AFAS Profit connection with what is sent to it (`afas`) and the Exact
5
+ * Online connection with its settings (`exactOnline`); the pipelines themselves, their runs and
6
+ * their progress streams follow in phase 7.
7
+ */
8
+ import type { Transport } from '@sixtyninecommerce/core';
9
+ import { type AfasModule } from './afas.js';
10
+ import { type EspModule } from './esp.js';
11
+ import { type ExactOnlineModule } from './exact-online.js';
12
+ import { type IntegrationPipelinesModule } from './pipelines.js';
13
+ export type { AfasConfigModule, AfasModule, AfasPaymentTermsModule, AfasWarehouseMappingsModule, } from './afas.js';
14
+ export { AFAS_SYNC_LOG_PAGE_LIMIT } from './afas.js';
15
+ export type { AfasCustomersModule, AfasOrdersModule, AfasStockTransfersModule, } from './afas-actions.js';
16
+ export { AFAS_CUSTOMER_SEARCH_LIMIT } from './afas-actions.js';
17
+ export type * from './afas-types.js';
18
+ export type { PipelineConnectionsModule } from './connections.js';
19
+ export { PIPELINE_CONNECTION_PRESERVE_KEYS } from './connections.js';
20
+ export type { ConnectEspWithTokenInput, EspBackfillResource, EspConnection, EspConnectionTestResult, EspConnectMetadata, EspCredentialsPushState, EspInboundWebhookState, EspModule, EspSyncLog, EspSyncLogFilter, UpdateEspConnectionInput, } from './esp.js';
21
+ export { ESP_BACKFILL_RESOURCES, ESP_SYNC_LOG_PAGE_LIMIT } from './esp.js';
22
+ export type { ExactOnlineConfigModule, ExactOnlineCredentialsModule, ExactOnlineModule, ExactOnlineSamplesModule, ExactOnlineStructureModule, ExactOnlineWebhooksModule, } from './exact-online.js';
23
+ export type * from './exact-online-types.js';
24
+ export type { IntegrationPipelinesModule, PipelineDraftsModule } from './pipelines.js';
25
+ export { PIPELINE_DRAFT_PRESERVE_KEYS, PIPELINE_DRAFT_SLOW_TIMEOUT_MS } from './pipelines.js';
26
+ export type * from './types.js';
27
+ export interface IntegrationsModule {
28
+ /**
29
+ * Data pipelines: the source connections (`connections`), the connectors, and the import and
30
+ * export set-ups kept on the server (`drafts`).
31
+ */
32
+ pipelines: IntegrationPipelinesModule;
33
+ /** The store's e-mail marketing connection (sixtynine.email). See {@link EspModule}. */
34
+ esp: EspModule;
35
+ /** The store's AFAS Profit connection and its settings. See {@link AfasModule}. */
36
+ afas: AfasModule;
37
+ /** The store's Exact Online connection and its settings. See {@link ExactOnlineModule}. */
38
+ exactOnline: ExactOnlineModule;
39
+ }
40
+ export declare function createIntegrationsModule(transport: Transport): IntegrationsModule;