@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
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  * `@sixtyninecommerce/admin` — the back-office SDK.
3
3
  *
4
4
  * Every capability of the platform is a method here (the parity rule, spec §5).
5
- * Shipped so far: auth, personal API tokens, channel resolution, CMS forms, SEO
6
- * redirects, the meta catalog, the tenant's own audit trail, its retention
5
+ * Shipped so far: auth, personal API tokens, channel resolution, CMS forms, content types and
6
+ * items, SEO redirects, the meta catalog, the tenant's own audit trail, its retention
7
7
  * policy and its stock location profiles — plus the `platform` guard every
8
8
  * cross-tenant method added later runs through.
9
9
  *
@@ -28,27 +28,65 @@
28
28
  * being transitive, pnpm would not resolve for them anyway.
29
29
  */
30
30
  /** Platform events: the webhook handler, the verifier and the payload types, from core. */
31
- export { APP_MANIFEST_SCHEMA, APP_MANIFEST_SCHEMA_SOURCE, AuthenticationError, BusinessRuleError, ConflictError, createEventHandler, EventStreamClosedError, HookRejectedError, HookUnavailableError, isEventType, NotFoundError, PermissionDeniedError, PlatformError, RateLimitedError, TransportError, UpstreamError, ValidationError, verifyEventDelivery, } from '@sixtyninecommerce/core';
32
- export { MAX_AVAILABILITY_PRODUCTS, MAX_AVAILABILITY_STORES, MAX_PRODUCT_COLLECTION_IDS, MAX_STORE_EXCLUSION_PRODUCTS, } from './catalog/products.js';
31
+ export { APP_MANIFEST_SCHEMA, APP_MANIFEST_SCHEMA_SOURCE, AuthenticationError, BusinessRuleError, ConflictError, createEventHandler, EventStreamClosedError, HookRejectedError, HookUnavailableError, isEventType, NotFoundError,
32
+ /**
33
+ * The cursor of the page that starts at an offset, for a table that jumps to page N of an
34
+ * offset-paged list (`Page.nextCursor` is the next page's): `after: offsetCursor((n - 1) * size)`.
35
+ */
36
+ offsetCursor, PermissionDeniedError, PlatformError, RateLimitedError, TransportError, UpstreamError, ValidationError, verifyEventDelivery, } from '@sixtyninecommerce/core';
37
+ export { ASSET_SORT_FIELDS } from './catalog/assets.js';
38
+ export { MAX_COLLECTION_SEARCH_TAKE } from './catalog/collections.js';
39
+ export { MAX_AVAILABILITY_PRODUCTS, MAX_AVAILABILITY_STORES, MAX_PRODUCT_COLLECTION_IDS, MAX_STORE_EXCLUSION_PRODUCTS, MAX_STORE_PRICE_RANGE_PRODUCTS, } from './catalog/products.js';
33
40
  export { MAX_BULK_PRODUCTS, PRODUCT_BULK_ACTIONS } from './catalog/products-bulk.js';
34
- export { MAX_REVERT_PRICE_VARIANTS } from './catalog/variants.js';
41
+ export { RECOMMENDATION_SOURCE_TYPES_WITH_ID } from './catalog/recommendations.js';
42
+ export { MAX_BULK_REVIEWS, MAX_REVIEW_PAGE_SIZE, REVIEW_STATUSES, } from './catalog/reviews.js';
43
+ export { MAX_VARIANT_FIND_PRODUCTS, MAX_VARIANT_FIND_TAKE } from './catalog/variant-find.js';
44
+ export { DEFAULT_OPTION_SET_LIMIT, MAX_OPTION_SET_LIMIT, MAX_REVERT_PRICE_VARIANTS, } from './catalog/variants.js';
35
45
  export { createAdminClient, } from './client.js';
36
- export { MAX_REPLACE_GROUP_MEMBERS } from './customers/index.js';
37
- export { MAX_DOCUMENT_EXTENSIONS } from './documents/index.js';
46
+ export { CUSTOMER_GROUP_LIST_INCLUDES, CUSTOMER_GROUP_LIST_SORT_FIELDS, CUSTOMER_HISTORY_TAKE, CUSTOMER_INCLUDES, CUSTOMER_LIST_INCLUDES, CUSTOMER_LIST_SORT_FIELDS, MAX_CUSTOMER_GROUP_LIST_TAKE, MAX_CUSTOMER_LIST_TAKE, MAX_REPLACE_GROUP_MEMBERS, } from './customers/index.js';
47
+ export { VAT_VALIDATION_TIMEOUT_MS } from './customers/vat.js';
48
+ export { DOCUMENT_EMAIL_EVENTS, MAX_DOCUMENT_EXTENSIONS } from './documents/index.js';
49
+ export { decodePdf } from './documents/pdf.js';
38
50
  export { AdminProjectionError } from './errors.js';
39
51
  export { MAX_REDRIVE_EVENT_IDS } from './events/index.js';
40
52
  export { AI_UNAVAILABLE_CODE, DEFAULT_FEED_PAGE_LIMIT, DEFAULT_PREVIEW_SAMPLE_SIZE, DEFAULT_REFRESH_INTERVAL_MINUTES, FEED_CATEGORY_MAPPING_SOURCES, FEED_CATEGORY_MAPPING_STATUSES, FEED_CATEGORY_MATCH_TYPES, FEED_CONDITION_OPERATORS, FEED_DESTINATIONS, FEED_IDENTIFIER_PATTERN, FEED_ITEM_ISSUE_SEVERITIES, FEED_PREVIEW_TIMEOUT_MS, FEED_REGENERATE_THROTTLED, FEED_RUN_STATUSES, FEED_RUN_TRIGGERS, FEED_TRANSFORM_KINDS, FEED_VALUE_SOURCE_KINDS, isAiUnavailable, isFeedConditionGroup, isFeedValueSourceKind, MAX_BULK_STATUS_IDS, MAX_FEED_PAGE_LIMIT, MAX_LOOKUP_ENTRIES, MAX_PREVIEW_SAMPLE_SIZE, MAX_REFRESH_INTERVAL_MINUTES, MIN_REFRESH_INTERVAL_MINUTES, readFeedRegenerateThrottle, TAXONOMY_DEFAULT_LIMIT, TAXONOMY_MAX_LIMIT, TITLE_PRESET_TIMEOUT_MS, VALUELESS_FEED_CONDITION_OPERATORS, } from './feeds/index.js';
53
+ export { FULFILLMENT_COVERAGE_REASON_MAX_LENGTH } from './fulfillments/index.js';
54
+ export { DEFAULT_FULFILLMENT_PAYMENT_POLICY, FULFILLMENT_PAYMENT_POLICY_EXEMPT_METHODS_MAX, FULFILLMENT_PAYMENT_POLICY_METHOD_CODE_MAX_LENGTH, normalizeFulfillmentPolicyMethodCode, } from './fulfillments/payment-policy.js';
55
+ export { MAX_WAREHOUSE_BULK_IDS } from './fulfillments/warehouse.js';
56
+ export { mostSpecificZone } from './geo/index.js';
57
+ export { AFAS_CUSTOMER_SEARCH_LIMIT, AFAS_SYNC_LOG_PAGE_LIMIT, ESP_BACKFILL_RESOURCES, ESP_SYNC_LOG_PAGE_LIMIT, PIPELINE_CONNECTION_PRESERVE_KEYS, PIPELINE_DRAFT_PRESERVE_KEYS, PIPELINE_DRAFT_SLOW_TIMEOUT_MS, } from './integrations/index.js';
41
58
  export { TERMINAL_BULK_ACTION_STATUSES } from './jobs/bulk-action-run.js';
42
59
  export { TERMINAL_JOB_STATUSES } from './jobs/index.js';
43
- export { OPENING_HOURS_DAYS } from './locations/index.js';
60
+ export { OPENING_HOURS_DAYS, STORE_PICKUP_HOLD_DAYS, STORE_PICKUP_INSTRUCTIONS_MAX_LENGTH, } from './locations/index.js';
44
61
  export { METAFIELD_OWNER_TYPES, METAFIELD_SCALAR_TYPES } from './metafields/index.js';
62
+ export { MAX_BULK_ORDERS, ORDER_BULK_ACTIONS, ORDER_BULK_TRANSITION_REFUSED, } from './orders/bulk.js';
63
+ export { DEFAULT_ORDER_DEPOSIT_POLICY, DEPOSIT_POLICY_AUTO_CANCEL_DAYS_MIN, DEPOSIT_POLICY_MINIMUM_PERCENT_MAX, DEPOSIT_POLICY_STOREFRONT_METHODS_MAX, } from './orders/deposit-policy.js';
45
64
  export { ORDER_INCLUDES } from './orders/get.js';
65
+ export { DraftInsufficientStockError, MAX_ORDER_LIST_TAKE, MAX_RECENT_ORDERS, ORDER_LIST_SORT_FIELDS, } from './orders/index.js';
66
+ export { MINIMUM_AGE_MAX, MINIMUM_AGE_MIN, ORDER_CODE_DIGITS_MAX, ORDER_CODE_DIGITS_MIN, ORDER_CODE_PREFIX_MAX_LENGTH, ORDER_SETTINGS_AMOUNT_MAX, ORDER_STATUS_RULE_CONDITION_TYPES, ORDER_STATUS_RULE_TARGET_STATES, } from './orders/settings.js';
46
67
  export { ORDER_ALLOCATION_BADGES, ORDER_EDIT_BLOCK_CODES, ORDER_LOCK_REASONS, ORDER_STATUS_ACTIONS, ORDER_STATUS_REASON_CODES, } from './orders/status.js';
68
+ export { PAYMENT_REQUEST_CLOSE_REASONS, PAYMENT_REQUEST_DEFAULT_EXPIRY_DAYS, PAYMENT_REQUEST_MAX_EXPIRY_DAYS, PAYMENT_REQUEST_STATUSES, } from './payments/index.js';
69
+ export { PAYMENT_LINK_REQUEST_STATUSES } from './payments/payment-links.js';
70
+ export { STORE_PICKUP_RELEASE_BLOCKED, STORE_PICKUP_STATUSES } from './pickups/index.js';
71
+ export { releaseStateOf } from './platform/channels.js';
47
72
  export { requireHumanSession } from './platform/guard.js';
48
73
  export { PROVISION_PROFILES } from './platform/provision-store.js';
49
- export { promotionActions, promotionConditions } from './pricing/index.js';
74
+ export { POS_ANOMALY_FLAGS_DEFAULT_PAGE, POS_ANOMALY_FLAGS_MAX_PAGE, } from './pos/anomalies.js';
75
+ export { POS_ASSISTED_SELLING_LIMITS } from './pos/assisted-selling.js';
76
+ export { POS_DEVICE_KINDS, POS_STAFF_GRANTS, POS_STAFF_LOCALES } from './pos/index.js';
77
+ export { POS_OFFLINE_CASH_SALES_LIMITS, POS_OFFLINE_NOT_READY_REASONS, POS_OFFLINE_SALE_NOTE_MAX_LENGTH, POS_OFFLINE_SALE_REASONS, } from './pos/offline-sales.js';
78
+ export { POS_PAY_BY_LINK_EXPIRY_MINUTES } from './pos/pay-by-link.js';
79
+ export { POS_QUICK_KEY_COLORS, POS_QUICK_KEY_LIMITS } from './pos/quick-keys.js';
80
+ export { POS_REPORT_PRODUCTS_DEFAULT_PAGE, POS_REPORT_PRODUCTS_MAX_PAGE, } from './pos/reports.js';
81
+ export { PROMOTION_SORT_FIELDS, promotionActions, promotionConditions, } from './pricing/index.js';
82
+ export { MAX_BULK_PRICE_LISTS, MAX_CUSTOMER_PRICE_LIST_ENTRIES, MAX_PRICE_LIST_ENTRY_EXPORT, MAX_PRICE_LIST_ENTRY_TAKE, MAX_PRICE_LIST_LIST_TAKE, PRICE_LIST_BULK_ACTIONS, PRICE_LIST_ENTRY_SEARCH_MODES, PRICE_LIST_SEARCH_MIN_TERM_LENGTH, PRICE_LIST_SEARCH_MODES, } from './pricing/price-lists.js';
50
83
  export { PROVENANCE_MAX_IDS } from './provenance/index.js';
84
+ export { QUOTE_STATUSES } from './quotes/index.js';
85
+ export { RETURN_ACTIONS, RETURN_SETTLEMENT_BLOCKERS, RETURN_SETTLEMENT_METHODS, RETURN_STATES, } from './returns/index.js';
86
+ export { escapeSearchFilterValue, SEARCH_ENTITIES_MAX_TAKE, SEARCH_ENTITIES_MIN_TERM_LENGTH, SEARCH_INDEX_MAX_FILTERS, SEARCH_INDEXES, } from './search/index.js';
51
87
  export { PARCEL_SUGGESTION_MAX_ITEMS, PARCEL_SUGGESTION_MAX_QUANTITY, } from './shipping/parcel-count-suggestion.js';
52
88
  export { PARCEL_CAPACITY_MAX, PARCEL_WEIGHT_GRAMS_MAX } from './shipping/parcel-rule.js';
89
+ export { STOCK_LOCATION_SORT_FIELDS } from './stock/locations.js';
90
+ export { SUBSCRIPTION_STATUSES } from './subscriptions/index.js';
53
91
  export { TAX_CLASS_FALLBACK_COUNTRY } from './tax/index.js';
54
92
  export { SETTINGS_GROUPS } from './tenant/settings-sources.js';
@@ -0,0 +1,234 @@
1
+ import { type Page, type Transport } from '@sixtyninecommerce/core';
2
+ import type { Call } from '../types.js';
3
+ import type { AfasAddressPreview, AfasCustomerBalance, AfasCustomerPreview, AfasCustomerSearchFilter, AfasDebtorLink, AfasDirectInvoiceResult, AfasOrderPreview, AfasOrderState, AfasPushResult, AfasSettleResult, AfasStockTransferInvoiceResult, AfasStockTransferState, CreateAfasDirectInvoiceInput, CreateAfasStockTransferInvoiceInput, SyncAfasCustomerInput, SyncAfasOrderInput } from './afas-types.js';
4
+ /** The most debtors `customers.search` asks AFAS for; the default is 10. */
5
+ export declare const AFAS_CUSTOMER_SEARCH_LIMIT = 50;
6
+ /**
7
+ * An order's AFAS documents (`admin.integrations.afas.orders`). AFAS keeps every document the
8
+ * platform writes into the store's administration: nothing here can be undone from the
9
+ * platform, only in AFAS by the store's accountant.
10
+ *
11
+ * Every method refuses an order the store does not hold with `ENTITY_NOT_FOUND`
12
+ * (`NotFoundError`, 404), and a store whose AFAS is not saved and switched on with
13
+ * `AFAS_NOT_CONFIGURED` (`BusinessRuleError`, 422).
14
+ */
15
+ export interface AfasOrdersModule {
16
+ /**
17
+ * The AFAS sales order the order was pushed as, read live from AFAS; `null` when it was not
18
+ * pushed as one, or AFAS answered nothing.
19
+ *
20
+ * @effect read
21
+ * @permission UpdateOrder
22
+ */
23
+ preview(orderId: string, options?: Call): Promise<AfasOrderPreview | null>;
24
+ /**
25
+ * The order's AFAS state, read from the platform (no AFAS call): which path it is on, what
26
+ * AFAS answered, and whether its state lets it be pushed (`stateAllowsPush`,
27
+ * `stateAllowsPrepaidSettlement`), so a screen offers only what the engine accepts.
28
+ *
29
+ * @effect read
30
+ * @permission ReadOrder
31
+ */
32
+ state(orderId: string, options?: Call): Promise<AfasOrderState>;
33
+ /**
34
+ * Push the order to AFAS as a sales order (`FbSales`), with its customer: an unlinked
35
+ * customer is linked to `customerAfasVrId`, or created as a new AFAS debtor when it is `null`.
36
+ * This writes into the store's AFAS administration and cannot be undone from the platform.
37
+ *
38
+ * Refused, with nothing sent to AFAS:
39
+ * - `AFAS_ORDER_STATE_BLOCKS_PUSH` (`BusinessRuleError`, 422): the order is in `Draft`,
40
+ * `AddingItems`, `ArrangingPayment` (its payment is still being arranged) or `Cancelled`;
41
+ * - `AFAS_ADMINISTRATION_NOT_CONFIGURED` (422): the store's connection names no administration;
42
+ * - `SANDBOX_PUSH_REFUSED` (422): a sandbox store never writes to AFAS.
43
+ *
44
+ * What AFAS itself refuses, and the path rules (an order already a direct invoice, or locked
45
+ * as invoiced), answer `success: false` with the reason in `error` (and `errorCode` when it
46
+ * has one), not a throw.
47
+ *
48
+ * `options.idempotencyKey` is accepted and sent, but the engine does not store it yet: a
49
+ * repeat runs again (an order already pushed answers `alreadySynced`).
50
+ *
51
+ * @effect irreversible
52
+ * @permission UpdateOrder
53
+ */
54
+ sync(orderId: string, input?: SyncAfasOrderInput, options?: Call): Promise<AfasPushResult>;
55
+ /**
56
+ * Settle the order's AFAS sales order (`FbSettleOrder`): AFAS marks it "Afgehandeld" for the
57
+ * accountant to invoice; it creates no invoice. This writes into the store's AFAS
58
+ * administration and cannot be undone from the platform.
59
+ *
60
+ * Refused with `AFAS_ADMINISTRATION_NOT_CONFIGURED` or `SANDBOX_PUSH_REFUSED` (422). An
61
+ * order with no sales order, already settled, or a direct invoice answers `success: false`
62
+ * with the reason in `error`, as does a refusal from AFAS.
63
+ *
64
+ * `options.idempotencyKey` is accepted and sent, but the engine does not store it yet.
65
+ *
66
+ * @effect irreversible
67
+ * @permission UpdateOrder
68
+ */
69
+ settle(orderId: string, options?: Call): Promise<AfasSettleResult>;
70
+ /**
71
+ * Create a direct invoice for the order in AFAS (`FbDirectInvoice`): AFAS numbers a packing
72
+ * slip and an invoice in one go. The customer is resolved as in {@link sync}. With
73
+ * `settleAsZeroValue` it is a settlement from prepaid credit instead: a €0 document that books
74
+ * no receivable and keeps the lines, so AFAS deducts the stock. This writes into the store's
75
+ * AFAS administration and cannot be undone from the platform. The engine refuses a second
76
+ * direct invoice for the order, so a repeat writes nothing twice.
77
+ *
78
+ * Refused, with nothing sent to AFAS:
79
+ * - `AFAS_ORDER_STATE_BLOCKS_PUSH` (422): the order is in `Draft`, `AddingItems`,
80
+ * `ArrangingPayment` or `Cancelled`; a settlement from prepaid is allowed in
81
+ * `ArrangingPayment`, since it is one way such an order gets paid;
82
+ * - `AFAS_ADMINISTRATION_NOT_CONFIGURED`, `SANDBOX_PUSH_REFUSED` (422).
83
+ *
84
+ * An order already on an AFAS path, a store whose invoices AFAS numbers (use the invoice
85
+ * door), and a refusal from AFAS answer `success: false` with the reason in `error`.
86
+ *
87
+ * `options.idempotencyKey` is accepted and sent, but the engine does not store it yet.
88
+ *
89
+ * @effect irreversible
90
+ * @permission UpdateOrder
91
+ */
92
+ createDirectInvoice(orderId: string, input?: CreateAfasDirectInvoiceInput, options?: Call): Promise<AfasDirectInvoiceResult>;
93
+ /**
94
+ * The order's AFAS invoice as PDF bytes, read live from AFAS; `null` when the order has no
95
+ * AFAS invoice number, the store has no invoice report connector, or AFAS answered nothing.
96
+ *
97
+ * @effect read
98
+ * @permission ReadOrder
99
+ */
100
+ invoicePdf(orderId: string, options?: Call): Promise<Uint8Array | null>;
101
+ }
102
+ /**
103
+ * A customer's AFAS debtor (`admin.integrations.afas.customers`). Every method but `balance`
104
+ * refuses a store whose AFAS is not saved and switched on with `AFAS_NOT_CONFIGURED`
105
+ * (`BusinessRuleError`, 422), and a customer the store does not hold with `ENTITY_NOT_FOUND`
106
+ * (`NotFoundError`, 404).
107
+ */
108
+ export interface AfasCustomersModule {
109
+ /**
110
+ * The AFAS debtor the customer is linked to, read live; `null` when it is not linked, or AFAS
111
+ * answered nothing.
112
+ *
113
+ * @effect read
114
+ * @permission UpdateCustomer
115
+ */
116
+ preview(customerId: string, options?: Call): Promise<AfasCustomerPreview | null>;
117
+ /**
118
+ * The AFAS delivery address one of the customer's addresses is linked to, read live; `null`
119
+ * when it is not linked.
120
+ *
121
+ * @effect read
122
+ * @permission UpdateCustomer
123
+ */
124
+ previewAddress(addressId: string, options?: Call): Promise<AfasAddressPreview | null>;
125
+ /**
126
+ * AFAS debtors matching an email, a phone number or a name, read live; most specific first.
127
+ * One page: AFAS answers at most `limit` (default 10, at most
128
+ * {@link AFAS_CUSTOMER_SEARCH_LIMIT}). A filter with nothing to look for answers an empty page.
129
+ * `AFAS_READ_FAILED` (`BusinessRuleError`, 422) when AFAS could not be read at all; the message
130
+ * says what to fix.
131
+ *
132
+ * @effect read
133
+ * @permission UpdateCustomer
134
+ */
135
+ search(filter: AfasCustomerSearchFilter, options?: Call): Promise<Page<AfasCustomerPreview>>;
136
+ /**
137
+ * Push the customer to AFAS: link it to `afasVrId` and update that debtor from the customer,
138
+ * or create a new debtor when `afasVrId` is `null` or absent. This writes into the store's AFAS
139
+ * administration and cannot be undone from the platform. To attach a customer to an existing
140
+ * debtor WITHOUT changing the debtor, use {@link link}.
141
+ *
142
+ * Refused with `AFAS_ADMINISTRATION_NOT_CONFIGURED` or `SANDBOX_PUSH_REFUSED` (422),
143
+ * nothing sent. A refusal from AFAS answers `success: false` with the reason in `error`.
144
+ *
145
+ * The engine takes no idempotency key for it yet, so `options.idempotencyKey` is not sent: a
146
+ * repeat runs again.
147
+ *
148
+ * @effect irreversible
149
+ * @permission UpdateCustomer
150
+ */
151
+ sync(customerId: string, input?: SyncAfasCustomerInput, options?: Call): Promise<AfasPushResult>;
152
+ /**
153
+ * Link the customer to an existing AFAS debtor without writing anything to AFAS (the debtor's
154
+ * own data stays as it is), and read its payment condition. `true` when the link changed,
155
+ * `false` when it was already in place. Refused `AFAS_LINK_INVALID` (400) for a blank
156
+ * `afasVrId`; `INVALID_AFAS_INPUT` (`ValidationError`, 400) before sending when it is not a
157
+ * string; `AFAS_ADMINISTRATION_NOT_CONFIGURED` (422).
158
+ *
159
+ * @effect write
160
+ * @permission UpdateCustomer
161
+ */
162
+ link(customerId: string, debtor: AfasDebtorLink, options?: Call): Promise<boolean>;
163
+ /**
164
+ * Clear the customer's link to its AFAS debtor without writing anything to AFAS. `true` when
165
+ * a link was cleared, `false` when there was none. Refused
166
+ * `AFAS_ADMINISTRATION_NOT_CONFIGURED` (422).
167
+ *
168
+ * @effect write
169
+ * @permission UpdateCustomer
170
+ */
171
+ unlink(customerId: string, options?: Call): Promise<boolean>;
172
+ /**
173
+ * The customer's outstanding AFAS balance, read live. Never refuses for AFAS: an unreachable
174
+ * AFAS answers `available: false`, AFAS off or an unlinked customer `linked: false`.
175
+ *
176
+ * @effect read
177
+ * @permission ReadCustomer
178
+ */
179
+ balance(customerId: string, options?: Call): Promise<AfasCustomerBalance>;
180
+ }
181
+ /** A stock transfer's AFAS document (`admin.integrations.afas.stockTransfers`). */
182
+ export interface AfasStockTransfersModule {
183
+ /**
184
+ * The transfer's AFAS state, read from the platform (no AFAS call): whether it was sent, which
185
+ * way its stock moves and on which warehouse, and why it cannot be sent (`blockReason`).
186
+ *
187
+ * @effect read
188
+ * @permission ReadStockLocation
189
+ */
190
+ state(stockTransferId: string, options?: Call): Promise<AfasStockTransferState>;
191
+ /**
192
+ * Send the transfer to AFAS as a €0 direct invoice booked against `afasDebtorId`, so AFAS
193
+ * moves the stock and books no receivable. This writes into the store's AFAS administration
194
+ * and cannot be undone from the platform. Idempotent per transfer: sending one again answers
195
+ * `alreadyPushed` and writes nothing.
196
+ *
197
+ * What blocks it (`state().blockReason`) and a refusal from AFAS answer `success: false` with
198
+ * the reason in `error`. `INVALID_AFAS_INPUT` (`ValidationError`, 400) before sending when
199
+ * `afasDebtorId` is not a non-empty string.
200
+ *
201
+ * `options.idempotencyKey` is accepted and sent, but the engine does not store it yet; the
202
+ * per-transfer rule above is what makes a repeat safe.
203
+ *
204
+ * @effect irreversible
205
+ * @permission UpdateStockLocation
206
+ */
207
+ createInvoice(stockTransferId: string, input: CreateAfasStockTransferInvoiceInput, options?: Call): Promise<AfasStockTransferInvoiceResult>;
208
+ }
209
+ export declare const PREVIEW_AFAS_ORDER_QUERY = "\n query PreviewAfasOrder($orderId: ID!) {\n previewAfasOrder(orderId: $orderId) {\n orNu\n debtorBcCo\n reference\n orderDate\n totalAmount\n currency\n status\n settled\n }\n }\n";
210
+ export declare const AFAS_ORDER_STATE_QUERY = "\n query AfasOrderState($orderId: ID!) {\n afasOrderState(orderId: $orderId) {\n path\n afasSalesOrderId\n afasSettled\n afasDirectInvoiceOrNu\n afasInvoiceNumber\n afasInvoiceDate\n hasPdfReport\n stateAllowsPush\n stateAllowsPrepaidSettlement\n }\n }\n";
211
+ export declare const SYNC_ORDER_TO_AFAS_MUTATION = "\n mutation SyncOrderToAfas($input: SyncOrderToAfasInput!, $idempotencyKey: String) {\n syncOrderToAfas(input: $input, idempotencyKey: $idempotencyKey) { \n success\n locked\n alreadySynced\n externalRef\n message\n error\n errorCode\n }\n }\n";
212
+ export declare const SETTLE_AFAS_ORDER_MUTATION = "\n mutation SettleAfasOrder($orderId: ID!, $idempotencyKey: String) {\n settleAfasOrder(orderId: $orderId, idempotencyKey: $idempotencyKey) {\n success\n locked\n afasSettled\n error\n }\n }\n";
213
+ export declare const CREATE_AFAS_DIRECT_INVOICE_MUTATION = "\n mutation CreateAfasDirectInvoice($input: CreateAfasDirectInvoiceInput!, $idempotencyKey: String) {\n createAfasDirectInvoice(input: $input, idempotencyKey: $idempotencyKey) {\n success\n afasDirectInvoiceOrNu\n afasInvoiceNumber\n afasInvoiceDate\n error\n errorCode\n }\n }\n";
214
+ export declare const AFAS_INVOICE_PDF_QUERY = "\n query AfasInvoicePdf($orderId: ID!) {\n afasInvoicePdf(orderId: $orderId)\n }\n";
215
+ export declare const PREVIEW_AFAS_CUSTOMER_QUERY = "\n query PreviewAfasCustomer($customerId: ID!) {\n previewAfasCustomer(customerId: $customerId) { \n bcCo\n debtorId\n name\n kind\n email\n phone\n vatNumber\n kvkNumber\n addressLine1\n addressLine3\n addressLine4\n currency\n paymentCondition\n blocked\n }\n }\n";
216
+ export declare const PREVIEW_AFAS_ADDRESS_QUERY = "\n query PreviewAfasAddress($addressId: ID!) {\n previewAfasAddress(addressId: $addressId) {\n adId\n bcCo\n street\n houseNumber\n postalCode\n city\n countryCode\n }\n }\n";
217
+ export declare const SEARCH_AFAS_CUSTOMERS_QUERY = "\n query SearchAfasCustomers($email: String, $phone: String, $name: String, $limit: Int) {\n searchAfasCustomers(email: $email, phone: $phone, name: $name, limit: $limit) {\n \n bcCo\n debtorId\n name\n kind\n email\n phone\n vatNumber\n kvkNumber\n addressLine1\n addressLine3\n addressLine4\n currency\n paymentCondition\n blocked\n\n }\n }\n";
218
+ export declare const SYNC_CUSTOMER_TO_AFAS_MUTATION = "\n mutation SyncCustomerToAfas($input: SyncCustomerToAfasInput!) {\n syncCustomerToAfas(input: $input) { \n success\n locked\n alreadySynced\n externalRef\n message\n error\n errorCode\n }\n }\n";
219
+ export declare const LINK_CUSTOMER_TO_AFAS_MUTATION = "\n mutation LinkCustomerToAfas(\n $customerId: ID!\n $afasVrId: String!\n $afasBcCo: String\n $afasKind: AfasDebtorKind\n ) {\n linkCustomerToAfas(\n customerId: $customerId\n afasVrId: $afasVrId\n afasBcCo: $afasBcCo\n afasKind: $afasKind\n )\n }\n";
220
+ export declare const UNLINK_CUSTOMER_FROM_AFAS_MUTATION = "\n mutation UnlinkCustomerFromAfas($customerId: ID!) {\n unlinkCustomerFromAfas(customerId: $customerId)\n }\n";
221
+ export declare const AFAS_CUSTOMER_BALANCE_QUERY = "\n query AfasCustomerBalance($customerId: ID!) {\n afasCustomerBalance(customerId: $customerId) {\n linked\n available\n balance\n currencyCode\n debtorId\n }\n }\n";
222
+ /**
223
+ * Only the current document: every engine in production answers the return fields (a read-only
224
+ * probe of production's Admin schema, 2026-10-13, headless W10-54), so the older-engine document
225
+ * without them is gone.
226
+ */
227
+ export declare const AFAS_STOCK_TRANSFER_STATE_QUERY = "\n query AfasStockTransferState($stockTransferId: ID!) {\n afasStockTransferState(stockTransferId: $stockTransferId) {\n enabled\n pushed\n afasDirectInvoiceOrNu\n afasInvoiceNumber\n afasDebtorId\n pushedAt\n sourceAfasWarehouse\n destinationAfasWarehouse\n isReturn\n stockDirection\n pushable\n blockReason\n }\n }\n";
228
+ export declare const CREATE_AFAS_STOCK_TRANSFER_INVOICE_MUTATION = "\n mutation CreateAfasStockTransferInvoice(\n $input: CreateAfasStockTransferInvoiceInput!\n $idempotencyKey: String\n ) {\n createAfasStockTransferInvoice(input: $input, idempotencyKey: $idempotencyKey) {\n success\n alreadyPushed\n afasDirectInvoiceOrNu\n afasInvoiceNumber\n error\n }\n }\n";
229
+ export interface AfasActionsModules {
230
+ orders: AfasOrdersModule;
231
+ customers: AfasCustomersModule;
232
+ stockTransfers: AfasStockTransfersModule;
233
+ }
234
+ export declare function createAfasActionsModules(transport: Transport): AfasActionsModules;
@@ -0,0 +1,310 @@
1
+ import { createPage, ValidationError } from '@sixtyninecommerce/core';
2
+ import { fieldOf } from '../catalog/types.js';
3
+ import { decodePdf } from '../documents/pdf.js';
4
+ /** The most debtors `customers.search` asks AFAS for; the default is 10. */
5
+ export const AFAS_CUSTOMER_SEARCH_LIMIT = 50;
6
+ const AFAS_CUSTOMER_SEARCH_DEFAULT = 10;
7
+ const PUSH_RESULT_FIELDS = /* GraphQL */ `
8
+ success
9
+ locked
10
+ alreadySynced
11
+ externalRef
12
+ message
13
+ error
14
+ errorCode
15
+ `;
16
+ const CUSTOMER_PREVIEW_FIELDS = /* GraphQL */ `
17
+ bcCo
18
+ debtorId
19
+ name
20
+ kind
21
+ email
22
+ phone
23
+ vatNumber
24
+ kvkNumber
25
+ addressLine1
26
+ addressLine3
27
+ addressLine4
28
+ currency
29
+ paymentCondition
30
+ blocked
31
+ `;
32
+ export const PREVIEW_AFAS_ORDER_QUERY = /* GraphQL */ `
33
+ query PreviewAfasOrder($orderId: ID!) {
34
+ previewAfasOrder(orderId: $orderId) {
35
+ orNu
36
+ debtorBcCo
37
+ reference
38
+ orderDate
39
+ totalAmount
40
+ currency
41
+ status
42
+ settled
43
+ }
44
+ }
45
+ `;
46
+ export const AFAS_ORDER_STATE_QUERY = /* GraphQL */ `
47
+ query AfasOrderState($orderId: ID!) {
48
+ afasOrderState(orderId: $orderId) {
49
+ path
50
+ afasSalesOrderId
51
+ afasSettled
52
+ afasDirectInvoiceOrNu
53
+ afasInvoiceNumber
54
+ afasInvoiceDate
55
+ hasPdfReport
56
+ stateAllowsPush
57
+ stateAllowsPrepaidSettlement
58
+ }
59
+ }
60
+ `;
61
+ export const SYNC_ORDER_TO_AFAS_MUTATION = /* GraphQL */ `
62
+ mutation SyncOrderToAfas($input: SyncOrderToAfasInput!, $idempotencyKey: String) {
63
+ syncOrderToAfas(input: $input, idempotencyKey: $idempotencyKey) { ${PUSH_RESULT_FIELDS} }
64
+ }
65
+ `;
66
+ export const SETTLE_AFAS_ORDER_MUTATION = /* GraphQL */ `
67
+ mutation SettleAfasOrder($orderId: ID!, $idempotencyKey: String) {
68
+ settleAfasOrder(orderId: $orderId, idempotencyKey: $idempotencyKey) {
69
+ success
70
+ locked
71
+ afasSettled
72
+ error
73
+ }
74
+ }
75
+ `;
76
+ export const CREATE_AFAS_DIRECT_INVOICE_MUTATION = /* GraphQL */ `
77
+ mutation CreateAfasDirectInvoice($input: CreateAfasDirectInvoiceInput!, $idempotencyKey: String) {
78
+ createAfasDirectInvoice(input: $input, idempotencyKey: $idempotencyKey) {
79
+ success
80
+ afasDirectInvoiceOrNu
81
+ afasInvoiceNumber
82
+ afasInvoiceDate
83
+ error
84
+ errorCode
85
+ }
86
+ }
87
+ `;
88
+ export const AFAS_INVOICE_PDF_QUERY = /* GraphQL */ `
89
+ query AfasInvoicePdf($orderId: ID!) {
90
+ afasInvoicePdf(orderId: $orderId)
91
+ }
92
+ `;
93
+ export const PREVIEW_AFAS_CUSTOMER_QUERY = /* GraphQL */ `
94
+ query PreviewAfasCustomer($customerId: ID!) {
95
+ previewAfasCustomer(customerId: $customerId) { ${CUSTOMER_PREVIEW_FIELDS} }
96
+ }
97
+ `;
98
+ export const PREVIEW_AFAS_ADDRESS_QUERY = /* GraphQL */ `
99
+ query PreviewAfasAddress($addressId: ID!) {
100
+ previewAfasAddress(addressId: $addressId) {
101
+ adId
102
+ bcCo
103
+ street
104
+ houseNumber
105
+ postalCode
106
+ city
107
+ countryCode
108
+ }
109
+ }
110
+ `;
111
+ export const SEARCH_AFAS_CUSTOMERS_QUERY = /* GraphQL */ `
112
+ query SearchAfasCustomers($email: String, $phone: String, $name: String, $limit: Int) {
113
+ searchAfasCustomers(email: $email, phone: $phone, name: $name, limit: $limit) {
114
+ ${CUSTOMER_PREVIEW_FIELDS}
115
+ }
116
+ }
117
+ `;
118
+ export const SYNC_CUSTOMER_TO_AFAS_MUTATION = /* GraphQL */ `
119
+ mutation SyncCustomerToAfas($input: SyncCustomerToAfasInput!) {
120
+ syncCustomerToAfas(input: $input) { ${PUSH_RESULT_FIELDS} }
121
+ }
122
+ `;
123
+ export const LINK_CUSTOMER_TO_AFAS_MUTATION = /* GraphQL */ `
124
+ mutation LinkCustomerToAfas(
125
+ $customerId: ID!
126
+ $afasVrId: String!
127
+ $afasBcCo: String
128
+ $afasKind: AfasDebtorKind
129
+ ) {
130
+ linkCustomerToAfas(
131
+ customerId: $customerId
132
+ afasVrId: $afasVrId
133
+ afasBcCo: $afasBcCo
134
+ afasKind: $afasKind
135
+ )
136
+ }
137
+ `;
138
+ export const UNLINK_CUSTOMER_FROM_AFAS_MUTATION = /* GraphQL */ `
139
+ mutation UnlinkCustomerFromAfas($customerId: ID!) {
140
+ unlinkCustomerFromAfas(customerId: $customerId)
141
+ }
142
+ `;
143
+ export const AFAS_CUSTOMER_BALANCE_QUERY = /* GraphQL */ `
144
+ query AfasCustomerBalance($customerId: ID!) {
145
+ afasCustomerBalance(customerId: $customerId) {
146
+ linked
147
+ available
148
+ balance
149
+ currencyCode
150
+ debtorId
151
+ }
152
+ }
153
+ `;
154
+ /**
155
+ * Only the current document: every engine in production answers the return fields (a read-only
156
+ * probe of production's Admin schema, 2026-10-13, headless W10-54), so the older-engine document
157
+ * without them is gone.
158
+ */
159
+ export const AFAS_STOCK_TRANSFER_STATE_QUERY = /* GraphQL */ `
160
+ query AfasStockTransferState($stockTransferId: ID!) {
161
+ afasStockTransferState(stockTransferId: $stockTransferId) {
162
+ enabled
163
+ pushed
164
+ afasDirectInvoiceOrNu
165
+ afasInvoiceNumber
166
+ afasDebtorId
167
+ pushedAt
168
+ sourceAfasWarehouse
169
+ destinationAfasWarehouse
170
+ isReturn
171
+ stockDirection
172
+ pushable
173
+ blockReason
174
+ }
175
+ }
176
+ `;
177
+ export const CREATE_AFAS_STOCK_TRANSFER_INVOICE_MUTATION = /* GraphQL */ `
178
+ mutation CreateAfasStockTransferInvoice(
179
+ $input: CreateAfasStockTransferInvoiceInput!
180
+ $idempotencyKey: String
181
+ ) {
182
+ createAfasStockTransferInvoice(input: $input, idempotencyKey: $idempotencyKey) {
183
+ success
184
+ alreadyPushed
185
+ afasDirectInvoiceOrNu
186
+ afasInvoiceNumber
187
+ error
188
+ }
189
+ }
190
+ `;
191
+ const invalidInput = (message) => new ValidationError({ code: 'INVALID_AFAS_INPUT', message, status: 400, service: 'vendure' });
192
+ const requireId = (value, name) => {
193
+ if (typeof value !== 'string' || value === '') {
194
+ throw invalidInput(`${name} must be a non-empty id.`);
195
+ }
196
+ return value;
197
+ };
198
+ const optionalObject = (value, method) => {
199
+ if (value === undefined)
200
+ return undefined;
201
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
202
+ throw invalidInput(`${method} takes an input object.`);
203
+ }
204
+ return value;
205
+ };
206
+ const trimmedOrNull = (value) => value?.trim() || null;
207
+ export function createAfasActionsModules(transport) {
208
+ const read = (document, field, options, variables = {}) => fieldOf(transport, document, field, variables, options);
209
+ return {
210
+ orders: {
211
+ async preview(orderId, options) {
212
+ return ((await read(PREVIEW_AFAS_ORDER_QUERY, 'previewAfasOrder', options, { orderId: requireId(orderId, 'orderId') })) ?? null);
213
+ },
214
+ async state(orderId, options) {
215
+ return read(AFAS_ORDER_STATE_QUERY, 'afasOrderState', options, {
216
+ orderId: requireId(orderId, 'orderId'),
217
+ });
218
+ },
219
+ async sync(orderId, input, options) {
220
+ const given = optionalObject(input, 'orders.sync') ?? {};
221
+ return read(SYNC_ORDER_TO_AFAS_MUTATION, 'syncOrderToAfas', options, {
222
+ input: { ...given, orderId: requireId(orderId, 'orderId') },
223
+ idempotencyKey: options?.idempotencyKey ?? null,
224
+ });
225
+ },
226
+ async settle(orderId, options) {
227
+ return read(SETTLE_AFAS_ORDER_MUTATION, 'settleAfasOrder', options, {
228
+ orderId: requireId(orderId, 'orderId'),
229
+ idempotencyKey: options?.idempotencyKey ?? null,
230
+ });
231
+ },
232
+ async createDirectInvoice(orderId, input, options) {
233
+ const given = optionalObject(input, 'orders.createDirectInvoice') ?? {};
234
+ return read(CREATE_AFAS_DIRECT_INVOICE_MUTATION, 'createAfasDirectInvoice', options, {
235
+ input: { ...given, orderId: requireId(orderId, 'orderId') },
236
+ idempotencyKey: options?.idempotencyKey ?? null,
237
+ });
238
+ },
239
+ async invoicePdf(orderId, options) {
240
+ const base64 = await read(AFAS_INVOICE_PDF_QUERY, 'afasInvoicePdf', options, { orderId: requireId(orderId, 'orderId') });
241
+ return base64 ? decodePdf(base64) : null;
242
+ },
243
+ },
244
+ customers: {
245
+ async preview(customerId, options) {
246
+ return ((await read(PREVIEW_AFAS_CUSTOMER_QUERY, 'previewAfasCustomer', options, { customerId: requireId(customerId, 'customerId') })) ?? null);
247
+ },
248
+ async previewAddress(addressId, options) {
249
+ return ((await read(PREVIEW_AFAS_ADDRESS_QUERY, 'previewAfasAddress', options, { addressId: requireId(addressId, 'addressId') })) ?? null);
250
+ },
251
+ async search(filter, options) {
252
+ const given = optionalObject(filter, 'customers.search') ?? {};
253
+ const email = trimmedOrNull(given.email);
254
+ const phone = trimmedOrNull(given.phone);
255
+ const name = trimmedOrNull(given.name);
256
+ const limit = Math.min(Math.max(Math.trunc(given.limit ?? AFAS_CUSTOMER_SEARCH_DEFAULT), 1), AFAS_CUSTOMER_SEARCH_LIMIT);
257
+ const single = (items) => createPage(items, { nextCursor: null, hasNext: false }, () => {
258
+ throw invalidInput('customers.search answers a single page.');
259
+ });
260
+ // Nothing to look for: the engine would answer [] after an AFAS round trip.
261
+ if (!email && !phone && !name)
262
+ return single([]);
263
+ const items = await read(SEARCH_AFAS_CUSTOMERS_QUERY, 'searchAfasCustomers', options, { email, phone, name, limit });
264
+ return single(items);
265
+ },
266
+ async sync(customerId, input, options) {
267
+ const given = optionalObject(input, 'customers.sync') ?? {};
268
+ return read(SYNC_CUSTOMER_TO_AFAS_MUTATION, 'syncCustomerToAfas', options, {
269
+ input: { ...given, customerId: requireId(customerId, 'customerId') },
270
+ });
271
+ },
272
+ async link(customerId, debtor, options) {
273
+ const given = optionalObject(debtor, 'customers.link');
274
+ if (typeof given?.afasVrId !== 'string') {
275
+ throw invalidInput('customers.link needs the AFAS debtor code (afasVrId).');
276
+ }
277
+ return ((await read(LINK_CUSTOMER_TO_AFAS_MUTATION, 'linkCustomerToAfas', options, {
278
+ customerId: requireId(customerId, 'customerId'),
279
+ afasVrId: given.afasVrId,
280
+ afasBcCo: given.afasBcCo ?? null,
281
+ afasKind: given.afasKind ?? null,
282
+ })) === true);
283
+ },
284
+ async unlink(customerId, options) {
285
+ return ((await read(UNLINK_CUSTOMER_FROM_AFAS_MUTATION, 'unlinkCustomerFromAfas', options, { customerId: requireId(customerId, 'customerId') })) === true);
286
+ },
287
+ async balance(customerId, options) {
288
+ return read(AFAS_CUSTOMER_BALANCE_QUERY, 'afasCustomerBalance', options, { customerId: requireId(customerId, 'customerId') });
289
+ },
290
+ },
291
+ stockTransfers: {
292
+ async state(stockTransferId, options) {
293
+ return read(AFAS_STOCK_TRANSFER_STATE_QUERY, 'afasStockTransferState', options, { stockTransferId: requireId(stockTransferId, 'stockTransferId') });
294
+ },
295
+ async createInvoice(stockTransferId, input, options) {
296
+ const given = optionalObject(input, 'stockTransfers.createInvoice');
297
+ if (typeof given?.afasDebtorId !== 'string' || given.afasDebtorId.trim() === '') {
298
+ throw invalidInput('stockTransfers.createInvoice needs the AFAS relation (afasDebtorId).');
299
+ }
300
+ return read(CREATE_AFAS_STOCK_TRANSFER_INVOICE_MUTATION, 'createAfasStockTransferInvoice', options, {
301
+ input: {
302
+ stockTransferId: requireId(stockTransferId, 'stockTransferId'),
303
+ afasDebtorId: given.afasDebtorId,
304
+ },
305
+ idempotencyKey: options?.idempotencyKey ?? null,
306
+ });
307
+ },
308
+ },
309
+ };
310
+ }