@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.
- package/README.md +4598 -128
- package/dist/catalog/assets.d.ts +120 -8
- package/dist/catalog/assets.js +98 -12
- package/dist/catalog/collections.d.ts +279 -14
- package/dist/catalog/collections.js +246 -15
- package/dist/catalog/index.d.ts +9 -2
- package/dist/catalog/index.js +4 -0
- package/dist/catalog/products.d.ts +318 -17
- package/dist/catalog/products.js +182 -14
- package/dist/catalog/properties.d.ts +102 -14
- package/dist/catalog/properties.js +13 -0
- package/dist/catalog/recommendations.d.ts +261 -0
- package/dist/catalog/recommendations.js +145 -0
- package/dist/catalog/reviews.d.ts +368 -0
- package/dist/catalog/reviews.js +318 -0
- package/dist/catalog/types.d.ts +17 -1
- package/dist/catalog/types.js +10 -0
- package/dist/catalog/variant-find.d.ts +136 -0
- package/dist/catalog/variant-find.js +239 -0
- package/dist/catalog/variants.d.ts +282 -25
- package/dist/catalog/variants.js +173 -25
- package/dist/catalog/visibility.d.ts +20 -5
- package/dist/catalog/visibility.js +19 -1
- package/dist/client.d.ts +116 -9
- package/dist/client.js +41 -7
- package/dist/content/assets.d.ts +286 -0
- package/dist/content/assets.js +181 -0
- package/dist/content/items.d.ts +269 -0
- package/dist/content/items.js +170 -0
- package/dist/content/types.d.ts +282 -0
- package/dist/content/types.js +100 -0
- package/dist/customers/age-verification.d.ts +66 -0
- package/dist/customers/age-verification.js +79 -0
- package/dist/customers/credit.d.ts +263 -0
- package/dist/customers/credit.js +244 -0
- package/dist/customers/delivery-preferences.d.ts +120 -0
- package/dist/customers/delivery-preferences.js +97 -0
- package/dist/customers/groups.d.ts +207 -0
- package/dist/customers/groups.js +438 -0
- package/dist/customers/index.d.ts +447 -37
- package/dist/customers/index.js +313 -40
- package/dist/customers/invitation-status.d.ts +57 -0
- package/dist/customers/invitation-status.js +21 -0
- package/dist/customers/notes.d.ts +67 -0
- package/dist/customers/notes.js +51 -0
- package/dist/customers/notification-recipients.d.ts +97 -0
- package/dist/customers/notification-recipients.js +84 -0
- package/dist/customers/saved-lists.d.ts +42 -0
- package/dist/customers/saved-lists.js +61 -0
- package/dist/customers/vat.d.ts +83 -0
- package/dist/customers/vat.js +46 -0
- package/dist/customers/wire.d.ts +20 -0
- package/dist/customers/wire.js +35 -0
- package/dist/documents/ar.d.ts +307 -0
- package/dist/documents/ar.js +254 -0
- package/dist/documents/index.d.ts +731 -21
- package/dist/documents/index.js +436 -24
- package/dist/documents/pdf.d.ts +2 -0
- package/dist/documents/pdf.js +11 -0
- package/dist/fulfillments/create.d.ts +167 -0
- package/dist/fulfillments/create.js +216 -0
- package/dist/fulfillments/index.d.ts +121 -10
- package/dist/fulfillments/index.js +120 -2
- package/dist/fulfillments/payment-policy.d.ts +64 -0
- package/dist/fulfillments/payment-policy.js +140 -0
- package/dist/fulfillments/warehouse.d.ts +724 -0
- package/dist/fulfillments/warehouse.js +914 -0
- package/dist/geo/index.d.ts +119 -0
- package/dist/geo/index.js +107 -0
- package/dist/index.d.ts +129 -30
- package/dist/index.js +47 -9
- package/dist/integrations/afas-actions.d.ts +234 -0
- package/dist/integrations/afas-actions.js +310 -0
- package/dist/integrations/afas-types.d.ts +483 -0
- package/dist/integrations/afas-types.js +5 -0
- package/dist/integrations/afas.d.ts +234 -0
- package/dist/integrations/afas.js +290 -0
- package/dist/integrations/connections.d.ts +103 -0
- package/dist/integrations/connections.js +55 -0
- package/dist/integrations/esp.d.ts +313 -0
- package/dist/integrations/esp.js +169 -0
- package/dist/integrations/exact-online-types.d.ts +423 -0
- package/dist/integrations/exact-online-types.js +6 -0
- package/dist/integrations/exact-online.d.ts +248 -0
- package/dist/integrations/exact-online.js +376 -0
- package/dist/integrations/index.d.ts +40 -0
- package/dist/integrations/index.js +24 -0
- package/dist/integrations/pipeline-keys.d.ts +13 -0
- package/dist/integrations/pipeline-keys.js +22 -0
- package/dist/integrations/pipelines.d.ts +114 -0
- package/dist/integrations/pipelines.js +46 -0
- package/dist/integrations/types.d.ts +322 -0
- package/dist/integrations/types.js +8 -0
- package/dist/jobs/bulk-action-run.d.ts +11 -2
- package/dist/jobs/bulk-action-run.js +4 -5
- package/dist/locations/index.d.ts +66 -0
- package/dist/locations/index.js +31 -0
- package/dist/meta/index.d.ts +162 -0
- package/dist/orders/bulk.d.ts +75 -0
- package/dist/orders/bulk.js +150 -0
- package/dist/orders/cancel-with-money.d.ts +227 -0
- package/dist/orders/cancel-with-money.js +153 -0
- package/dist/orders/commit-edit.d.ts +7 -1
- package/dist/orders/commit-edit.js +5 -1
- package/dist/orders/deposit-policy.d.ts +103 -0
- package/dist/orders/deposit-policy.js +202 -0
- package/dist/orders/drafts.d.ts +800 -0
- package/dist/orders/drafts.js +771 -0
- package/dist/orders/fields.d.ts +245 -0
- package/dist/orders/fields.js +188 -0
- package/dist/orders/get.d.ts +29 -19
- package/dist/orders/get.js +17 -8
- package/dist/orders/index.d.ts +125 -5
- package/dist/orders/index.js +35 -2
- package/dist/orders/lifecycle.d.ts +128 -0
- package/dist/orders/lifecycle.js +158 -0
- package/dist/orders/line-price-preview.d.ts +7 -2
- package/dist/orders/list.d.ts +222 -0
- package/dist/orders/list.js +377 -0
- package/dist/orders/manual-discounts.d.ts +11 -2
- package/dist/orders/manual-discounts.js +2 -0
- package/dist/orders/manual-pricing.d.ts +5 -0
- package/dist/orders/order-entry.d.ts +20 -7
- package/dist/orders/plan-edit.d.ts +1 -1
- package/dist/orders/plan-edit.js +4 -1
- package/dist/orders/settings.d.ts +201 -0
- package/dist/orders/settings.js +325 -0
- package/dist/orders/status.d.ts +159 -13
- package/dist/orders/status.js +21 -0
- package/dist/orders/surcharges.d.ts +8 -1
- package/dist/orders/surcharges.js +3 -2
- package/dist/payments/account-credit.d.ts +30 -0
- package/dist/payments/account-credit.js +19 -0
- package/dist/payments/ar.d.ts +292 -0
- package/dist/payments/ar.js +223 -0
- package/dist/payments/connected-account.d.ts +47 -0
- package/dist/payments/connected-account.js +61 -0
- package/dist/payments/credit-noted-fields.d.ts +12 -0
- package/dist/payments/credit-noted-fields.js +37 -0
- package/dist/payments/index.d.ts +263 -10
- package/dist/payments/index.js +133 -1
- package/dist/payments/methods.d.ts +332 -0
- package/dist/payments/methods.js +363 -0
- package/dist/payments/mollie-methods.d.ts +159 -0
- package/dist/payments/mollie-methods.js +141 -0
- package/dist/payments/payment-links.d.ts +180 -0
- package/dist/payments/payment-links.js +97 -0
- package/dist/payments/provider-keys.d.ts +150 -0
- package/dist/payments/provider-keys.js +118 -0
- package/dist/payments/providers.d.ts +86 -11
- package/dist/payments/providers.js +29 -0
- package/dist/payments/requests.d.ts +144 -0
- package/dist/payments/requests.js +92 -0
- package/dist/payments/store-credit-fields.d.ts +15 -0
- package/dist/payments/store-credit-fields.js +51 -0
- package/dist/pickups/index.d.ts +104 -0
- package/dist/pickups/index.js +105 -0
- package/dist/platform/channels.d.ts +132 -0
- package/dist/platform/channels.js +128 -0
- package/dist/platform/geo.d.ts +123 -0
- package/dist/platform/geo.js +144 -0
- package/dist/platform/tax.d.ts +154 -0
- package/dist/platform/tax.js +139 -0
- package/dist/pos/anomalies.d.ts +158 -0
- package/dist/pos/anomalies.js +64 -0
- package/dist/pos/assisted-selling.d.ts +79 -0
- package/dist/pos/assisted-selling.js +38 -0
- package/dist/pos/exchanges.d.ts +103 -0
- package/dist/pos/exchanges.js +22 -0
- package/dist/pos/gift-cards.d.ts +135 -0
- package/dist/pos/gift-cards.js +47 -0
- package/dist/pos/index.d.ts +2125 -32
- package/dist/pos/index.js +742 -4
- package/dist/pos/no-receipt.d.ts +94 -0
- package/dist/pos/no-receipt.js +25 -0
- package/dist/pos/offline-sales.d.ts +187 -0
- package/dist/pos/offline-sales.js +116 -0
- package/dist/pos/pay-by-link.d.ts +143 -0
- package/dist/pos/pay-by-link.js +57 -0
- package/dist/pos/quick-keys.d.ts +103 -0
- package/dist/pos/quick-keys.js +45 -0
- package/dist/pos/reports.d.ts +360 -0
- package/dist/pos/reports.js +62 -0
- package/dist/pos/returns.d.ts +217 -0
- package/dist/pos/returns.js +53 -0
- package/dist/pricing/bulk-coupons.d.ts +139 -0
- package/dist/pricing/bulk-coupons.js +112 -0
- package/dist/pricing/index.d.ts +177 -4
- package/dist/pricing/index.js +176 -1
- package/dist/pricing/price-lists.d.ts +604 -0
- package/dist/pricing/price-lists.js +600 -0
- package/dist/pricing/vouchers.d.ts +103 -0
- package/dist/pricing/vouchers.js +69 -0
- package/dist/purchasing/alerts.d.ts +89 -0
- package/dist/purchasing/alerts.js +62 -0
- package/dist/purchasing/cost.d.ts +110 -0
- package/dist/purchasing/cost.js +86 -0
- package/dist/purchasing/index.d.ts +36 -0
- package/dist/purchasing/index.js +16 -0
- package/dist/purchasing/purchase-orders.d.ts +548 -0
- package/dist/purchasing/purchase-orders.js +491 -0
- package/dist/purchasing/replenishment.d.ts +281 -0
- package/dist/purchasing/replenishment.js +240 -0
- package/dist/purchasing/settings.d.ts +152 -0
- package/dist/purchasing/settings.js +181 -0
- package/dist/purchasing/suppliers.d.ts +476 -0
- package/dist/purchasing/suppliers.js +438 -0
- package/dist/quotes/index.d.ts +501 -0
- package/dist/quotes/index.js +439 -0
- package/dist/reports/index.d.ts +71 -8
- package/dist/reports/index.js +74 -11
- package/dist/returns/index.d.ts +818 -0
- package/dist/returns/index.js +844 -0
- package/dist/search/index.d.ts +174 -0
- package/dist/search/index.js +125 -0
- package/dist/shipping/definitions.d.ts +29 -0
- package/dist/shipping/definitions.js +47 -0
- package/dist/shipping/fulfillment-profiles.d.ts +174 -0
- package/dist/shipping/fulfillment-profiles.js +104 -0
- package/dist/shipping/hendriks.d.ts +97 -0
- package/dist/shipping/hendriks.js +50 -0
- package/dist/shipping/index.d.ts +48 -0
- package/dist/shipping/index.js +25 -0
- package/dist/shipping/methods.d.ts +198 -0
- package/dist/shipping/methods.js +240 -0
- package/dist/shipping/myparcel.d.ts +254 -0
- package/dist/shipping/myparcel.js +178 -0
- package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
- package/dist/shipping/parcel-rule.d.ts +6 -5
- package/dist/shipping/parcel-rule.js +21 -23
- package/dist/shipping/rate-tables.d.ts +179 -0
- package/dist/shipping/rate-tables.js +184 -0
- package/dist/stock/index.d.ts +10 -3
- package/dist/stock/index.js +3 -0
- package/dist/stock/locations.d.ts +144 -0
- package/dist/stock/locations.js +168 -0
- package/dist/stock/transfers.d.ts +216 -43
- package/dist/stock/transfers.js +140 -13
- package/dist/stored-value/index.d.ts +214 -4
- package/dist/stored-value/index.js +152 -0
- package/dist/subscriptions/index.d.ts +682 -0
- package/dist/subscriptions/index.js +815 -0
- package/dist/tax/index.d.ts +76 -1
- package/dist/tax/index.js +50 -0
- package/dist/tenant/email-style.d.ts +102 -0
- package/dist/tenant/email-style.js +72 -0
- package/dist/tenant/email-templates.d.ts +66 -0
- package/dist/tenant/email-templates.js +54 -0
- package/dist/tenant/notifications.d.ts +23 -17
- package/dist/tenant/settings-sources.d.ts +1 -1
- package/dist/tenant/time-zone.d.ts +17 -0
- package/dist/tenant/time-zone.js +11 -0
- package/dist/types.d.ts +51 -4
- package/dist/users/index.d.ts +3 -0
- package/dist/users/index.js +2 -0
- package/dist/users/warehouses.d.ts +50 -0
- package/dist/users/warehouses.js +51 -0
- package/package.json +2 -2
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { type Page, type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call, ListOptions } from '../types.js';
|
|
3
|
+
import { type AfasCustomersModule, type AfasOrdersModule, type AfasStockTransfersModule } from './afas-actions.js';
|
|
4
|
+
import type { AfasAdministration, AfasConfig, AfasConfigSaveResult, AfasConnectionVerification, AfasCorrectionArticleFill, AfasDiscoveredDefaults, AfasPaymentCondition, AfasPaymentTermsStatus, AfasPaymentTermsSyncResult, AfasSyncLog, AfasSyncLogFilter, AfasWarehouse, AfasWarehouseMapping, UpdateAfasConfigInput, UpdateAfasPaymentConditionInput } from './afas-types.js';
|
|
5
|
+
/** The largest page `syncLogs` asks for; the default is 25. */
|
|
6
|
+
export declare const AFAS_SYNC_LOG_PAGE_LIMIT = 100;
|
|
7
|
+
/**
|
|
8
|
+
* The store's AFAS Profit connection itself (`admin.integrations.afas.config`). Writing it is
|
|
9
|
+
* the platform SuperAdmin's alone: a store administrator is refused `FORBIDDEN`
|
|
10
|
+
* (`PermissionDeniedError`, 403).
|
|
11
|
+
*/
|
|
12
|
+
export interface AfasConfigModule {
|
|
13
|
+
/**
|
|
14
|
+
* The store's connection, or `null` when it has none. The App Connector token is write-only:
|
|
15
|
+
* never read back, in any form.
|
|
16
|
+
*
|
|
17
|
+
* @effect read
|
|
18
|
+
* @permission UpdateSettings
|
|
19
|
+
*/
|
|
20
|
+
get(options?: Call): Promise<AfasConfig | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Configure the connection; the first call creates it. A patch: a key left out keeps the
|
|
23
|
+
* stored value. Answers the saved connection with `correctionArticleFill`: a save that leaves
|
|
24
|
+
* AFAS on with a token also fills the correction article of each VAT rate of the store that has
|
|
25
|
+
* none, from AFAS (a detection failure never fails the save; it is reported there). The first
|
|
26
|
+
* save that turns payment terms on also starts a payment-terms sync in the background.
|
|
27
|
+
*
|
|
28
|
+
* A store administrator is refused `FORBIDDEN` (`PermissionDeniedError`, 403). Refused, with
|
|
29
|
+
* nothing saved:
|
|
30
|
+
* - `AFAS_CONFIG_INVALID` (`ValidationError`, 400): every problem of the save at once, each in
|
|
31
|
+
* `error.details[]` with its `field`: `environmentId` (missing on the first save, blank or
|
|
32
|
+
* null on any, or not an AFAS environment id: the number such as `89990`, or the code such as
|
|
33
|
+
* `T89990AA`), `token` (missing on the first save, or neither the token envelope nor a bare
|
|
34
|
+
* hex blob of 32+ characters), `correctionArticleCodes[n].taxRate` (outside 0-100, or a rate
|
|
35
|
+
* listed twice) and `correctionArticleCodes[n].itemCode` (blank, or over 50 characters), n
|
|
36
|
+
* being the row's index in the list as sent;
|
|
37
|
+
* - `ORGANIZATION_WORKSPACE_NOT_A_STORE` (422): switching AFAS on, or storing a token, in an
|
|
38
|
+
* organization's workspace.
|
|
39
|
+
*
|
|
40
|
+
* The connector and field ids are free text the engine does not check.
|
|
41
|
+
*
|
|
42
|
+
* @effect write
|
|
43
|
+
* @permission SuperAdmin
|
|
44
|
+
*/
|
|
45
|
+
update(input: UpdateAfasConfigInput, options?: Call): Promise<AfasConfigSaveResult>;
|
|
46
|
+
/**
|
|
47
|
+
* [deletes] Remove the store's connection and the token it holds. `true` when one was
|
|
48
|
+
* removed, `false` when there was none. A store administrator is refused `FORBIDDEN`
|
|
49
|
+
* (`PermissionDeniedError`, 403).
|
|
50
|
+
*
|
|
51
|
+
* @effect destructive
|
|
52
|
+
* @permission SuperAdmin
|
|
53
|
+
*/
|
|
54
|
+
delete(options?: Call): Promise<boolean>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The store's stock locations paired with AFAS warehouses (`admin.integrations.afas
|
|
58
|
+
* .warehouseMappings`): the warehouse a location's stock moves are booked on in AFAS.
|
|
59
|
+
*/
|
|
60
|
+
export interface AfasWarehouseMappingsModule {
|
|
61
|
+
/**
|
|
62
|
+
* Every mapping of the store.
|
|
63
|
+
*
|
|
64
|
+
* @effect read
|
|
65
|
+
* @permission UpdateSettings
|
|
66
|
+
*/
|
|
67
|
+
list(options?: Call): Promise<AfasWarehouseMapping[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Map a stock location of the store to an AFAS warehouse code, replacing its mapping if it has
|
|
70
|
+
* one. Answers the saved mapping. Refused, with nothing saved: `AFAS_WAREHOUSE_MAPPING_INVALID`
|
|
71
|
+
* (`ValidationError`, 400, `details[]` field `afasWarehouse`) for a blank code or one over 15
|
|
72
|
+
* characters; `ENTITY_NOT_FOUND` (`NotFoundError`, 404) for a location the store does not have.
|
|
73
|
+
* `INVALID_AFAS_INPUT` (`ValidationError`, 400), before sending: the location id is not a
|
|
74
|
+
* non-empty string, or the code not a string.
|
|
75
|
+
*
|
|
76
|
+
* @effect write
|
|
77
|
+
* @permission UpdateSettings
|
|
78
|
+
*/
|
|
79
|
+
upsert(stockLocationId: string, afasWarehouse: string, options?: Call): Promise<AfasWarehouseMapping>;
|
|
80
|
+
/**
|
|
81
|
+
* [deletes] Remove a stock location's mapping. `true` when one was removed, `false` when it
|
|
82
|
+
* had none. `INVALID_AFAS_INPUT` (400), before sending, for a location id that is not a
|
|
83
|
+
* non-empty string.
|
|
84
|
+
*
|
|
85
|
+
* @effect destructive
|
|
86
|
+
* @permission UpdateSettings
|
|
87
|
+
*/
|
|
88
|
+
delete(stockLocationId: string, options?: Call): Promise<boolean>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The store's AFAS customer payment terms (`admin.integrations.afas.paymentTerms`): the condition
|
|
92
|
+
* catalog (AFAS code → days), the health of the debtor mirror, the sync, and merchant edits.
|
|
93
|
+
*/
|
|
94
|
+
export interface AfasPaymentTermsModule {
|
|
95
|
+
/**
|
|
96
|
+
* The condition catalog, by code.
|
|
97
|
+
*
|
|
98
|
+
* @effect read
|
|
99
|
+
* @permission ReadSettings
|
|
100
|
+
*/
|
|
101
|
+
conditions(options?: Call): Promise<AfasPaymentCondition[]>;
|
|
102
|
+
/**
|
|
103
|
+
* The health of the mirror and the catalog.
|
|
104
|
+
*
|
|
105
|
+
* @effect read
|
|
106
|
+
* @permission ReadSettings
|
|
107
|
+
*/
|
|
108
|
+
status(options?: Call): Promise<AfasPaymentTermsStatus>;
|
|
109
|
+
/**
|
|
110
|
+
* Refresh the condition catalog from AFAS and mirror every linked customer's AFAS condition.
|
|
111
|
+
* A catalog AFAS will not give is reported in `catalogError`, not thrown. A failed debtor read
|
|
112
|
+
* marks the mirror stale and throws. A store administrator is refused `FORBIDDEN`
|
|
113
|
+
* (`PermissionDeniedError`, 403). AFAS off is refused `AFAS_NOT_CONFIGURED` (422), payment
|
|
114
|
+
* terms off `AFAS_PAYMENT_TERMS_DISABLED` (`BusinessRuleError`, 422).
|
|
115
|
+
*
|
|
116
|
+
* @effect write
|
|
117
|
+
* @permission SuperAdmin
|
|
118
|
+
*/
|
|
119
|
+
sync(options?: Call): Promise<AfasPaymentTermsSyncResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Create or change one condition of the catalog (the merchant's own edit, never overwritten by
|
|
122
|
+
* a sync). Answers the saved row. A store administrator is refused `FORBIDDEN`
|
|
123
|
+
* (`PermissionDeniedError`, 403); a code that is not 1-20 characters, or days that are not a
|
|
124
|
+
* whole number in range, are refused `AFAS_PAYMENT_CONDITION_INVALID` (`ValidationError`, 400,
|
|
125
|
+
* `details[]` field `code` or `days`). `INVALID_AFAS_INPUT` (400), before
|
|
126
|
+
* sending, when the input has no string `code`.
|
|
127
|
+
*
|
|
128
|
+
* @effect write
|
|
129
|
+
* @permission SuperAdmin
|
|
130
|
+
*/
|
|
131
|
+
updateCondition(input: UpdateAfasPaymentConditionInput, options?: Call): Promise<AfasPaymentCondition>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The store's AFAS Profit connection and its settings (`admin.integrations.afas`): the
|
|
135
|
+
* connection, its test, the AFAS lists the settings pick from, the warehouse mapping, the payment
|
|
136
|
+
* terms, and the log of what was sent. Always the store the client is scoped to; a SuperAdmin
|
|
137
|
+
* acts on ANOTHER store with `admin.withTenant({ scope: { kind: 'channel', code } })`, or a
|
|
138
|
+
* per-call `tenant`.
|
|
139
|
+
*
|
|
140
|
+
* A store without the AFAS plugin is refused every method but `config.get`, `config.delete` and
|
|
141
|
+
* `syncLogs` (`PLUGIN_ACCESS_DENIED`, `PermissionDeniedError`, 403; never for a SuperAdmin). A door
|
|
142
|
+
* that needs a connection the store does not have answers `AFAS_NOT_CONFIGURED` (422). What is
|
|
143
|
+
* sent to AFAS for an order, a customer or a stock transfer is under `orders`, `customers` and
|
|
144
|
+
* `stockTransfers`.
|
|
145
|
+
*/
|
|
146
|
+
export interface AfasModule {
|
|
147
|
+
/** The connection itself. See {@link AfasConfigModule}. */
|
|
148
|
+
config: AfasConfigModule;
|
|
149
|
+
/**
|
|
150
|
+
* Ask AFAS whether the saved connection works. Never refuses for what it finds: a connection
|
|
151
|
+
* AFAS refuses answers `connected: false`. A connection that works also fills the correction
|
|
152
|
+
* article of each VAT rate that has none (`correctionArticles`, saved).
|
|
153
|
+
*
|
|
154
|
+
* A store administrator is refused `FORBIDDEN` (`PermissionDeniedError`, 403).
|
|
155
|
+
* `AFAS_NOT_CONFIGURED` (422): the store has no saved connection.
|
|
156
|
+
*
|
|
157
|
+
* @effect write
|
|
158
|
+
* @permission SuperAdmin
|
|
159
|
+
*/
|
|
160
|
+
verifyConnection(options?: Call): Promise<AfasConnectionVerification>;
|
|
161
|
+
/**
|
|
162
|
+
* "Detect from AFAS": fill the correction article of each VAT rate of the store that has none,
|
|
163
|
+
* from the AFAS articles without stock, and save. Never replaces an entry.
|
|
164
|
+
*
|
|
165
|
+
* A store administrator is refused `FORBIDDEN` (`PermissionDeniedError`, 403). Refused, with
|
|
166
|
+
* nothing changed: `AFAS_NOT_CONFIGURED` (422, no connection or no token);
|
|
167
|
+
* `AFAS_READ_FAILED` (AFAS could not be read; the sentence names what to authorise).
|
|
168
|
+
*
|
|
169
|
+
* @effect write
|
|
170
|
+
* @permission SuperAdmin
|
|
171
|
+
*/
|
|
172
|
+
fillCorrectionArticles(options?: Call): Promise<AfasCorrectionArticleFill>;
|
|
173
|
+
/**
|
|
174
|
+
* Values the saved AFAS environment suggests for the settings. Reads only. Never throws for
|
|
175
|
+
* what AFAS answers: a field AFAS cannot give is null, and every field is null when the store
|
|
176
|
+
* has no saved connection. A store administrator is refused `FORBIDDEN`
|
|
177
|
+
* (`PermissionDeniedError`, 403).
|
|
178
|
+
*
|
|
179
|
+
* @effect read
|
|
180
|
+
* @permission SuperAdmin
|
|
181
|
+
*/
|
|
182
|
+
discoverDefaults(options?: Call): Promise<AfasDiscoveredDefaults>;
|
|
183
|
+
/**
|
|
184
|
+
* The attempts to send this store's records to AFAS, newest first, 25 to a page (at most
|
|
185
|
+
* {@link AFAS_SYNC_LOG_PAGE_LIMIT}).
|
|
186
|
+
*
|
|
187
|
+
* @effect read
|
|
188
|
+
* @permission UpdateSettings
|
|
189
|
+
*/
|
|
190
|
+
syncLogs(filter?: AfasSyncLogFilter & ListOptions): Promise<Page<AfasSyncLog>>;
|
|
191
|
+
/**
|
|
192
|
+
* The administrations of the connected AFAS environment, read live. An AFAS read that fails
|
|
193
|
+
* answers an empty list. `AFAS_NOT_CONFIGURED` (422): no connection, or AFAS switched off.
|
|
194
|
+
*
|
|
195
|
+
* @effect read
|
|
196
|
+
* @permission UpdateSettings
|
|
197
|
+
*/
|
|
198
|
+
administrations(options?: Call): Promise<AfasAdministration[]>;
|
|
199
|
+
/**
|
|
200
|
+
* The warehouses of the connected AFAS environment, read live. An AFAS read that fails answers
|
|
201
|
+
* an empty list. `AFAS_NOT_CONFIGURED` (422): no connection, or AFAS switched off.
|
|
202
|
+
*
|
|
203
|
+
* @effect read
|
|
204
|
+
* @permission UpdateSettings
|
|
205
|
+
*/
|
|
206
|
+
warehouses(options?: Call): Promise<AfasWarehouse[]>;
|
|
207
|
+
/** Stock locations paired with AFAS warehouses. See {@link AfasWarehouseMappingsModule}. */
|
|
208
|
+
warehouseMappings: AfasWarehouseMappingsModule;
|
|
209
|
+
/** The customer payment terms. See {@link AfasPaymentTermsModule}. */
|
|
210
|
+
paymentTerms: AfasPaymentTermsModule;
|
|
211
|
+
/** An order's AFAS documents. See {@link AfasOrdersModule}. */
|
|
212
|
+
orders: AfasOrdersModule;
|
|
213
|
+
/** A customer's AFAS debtor. See {@link AfasCustomersModule}. */
|
|
214
|
+
customers: AfasCustomersModule;
|
|
215
|
+
/** A stock transfer's AFAS document. See {@link AfasStockTransfersModule}. */
|
|
216
|
+
stockTransfers: AfasStockTransfersModule;
|
|
217
|
+
}
|
|
218
|
+
export declare const AFAS_CONFIG_QUERY = "\n query AfasConfig {\n afasConfig { \n id\n channelId\n enabled\n environmentId\n environmentType\n orderConnectorId\n orgCustomerConnectorId\n perCustomerConnectorId\n defaultCurrency\n defaultPaymentCondition\n defaultWarehouse\n defaultAdministration\n paymentTermsEnabled\n paymentConditionConnectorId\n balanceConnectorId\n balanceDebtorFieldId\n balanceAmountFieldId\n invoiceReportConnectorId\n invoiceReportFilterFieldId\n debtorVatDuty\n debtorCollectionAccount\n shippingItemCode\n discountItemCode\n correctionArticleCodes { taxRate itemCode }\n directInvoiceUnitCode\n directInvoiceJournalId\n createdAt\n updatedAt\n }\n }\n";
|
|
219
|
+
export declare const UPDATE_AFAS_CONFIG_MUTATION = "\n mutation UpdateAfasConfig($input: UpdateAfasConfigInput!) {\n updateAfasConfig(input: $input) {\n \n id\n channelId\n enabled\n environmentId\n environmentType\n orderConnectorId\n orgCustomerConnectorId\n perCustomerConnectorId\n defaultCurrency\n defaultPaymentCondition\n defaultWarehouse\n defaultAdministration\n paymentTermsEnabled\n paymentConditionConnectorId\n balanceConnectorId\n balanceDebtorFieldId\n balanceAmountFieldId\n invoiceReportConnectorId\n invoiceReportFilterFieldId\n debtorVatDuty\n debtorCollectionAccount\n shippingItemCode\n discountItemCode\n correctionArticleCodes { taxRate itemCode }\n directInvoiceUnitCode\n directInvoiceJournalId\n createdAt\n updatedAt\n\n correctionArticleFill { \n storeRates\n filled { taxRate itemCode description reason }\n kept\n unmatchedRates\n errorCode\n error\n }\n }\n }\n";
|
|
220
|
+
export declare const DELETE_AFAS_CONFIG_MUTATION = "\n mutation DeleteAfasConfig {\n deleteAfasConfig\n }\n";
|
|
221
|
+
export declare const VERIFY_AFAS_CONNECTION_MUTATION = "\n mutation VerifyAfasConnection {\n verifyAfasConnection {\n connected\n correctionArticles { \n storeRates\n filled { taxRate itemCode description reason }\n kept\n unmatchedRates\n errorCode\n error\n }\n }\n }\n";
|
|
222
|
+
export declare const FILL_AFAS_CORRECTION_ARTICLES_MUTATION = "\n mutation FillAfasCorrectionArticles {\n fillAfasCorrectionArticles { \n storeRates\n filled { taxRate itemCode description reason }\n kept\n unmatchedRates\n errorCode\n error\n }\n }\n";
|
|
223
|
+
export declare const DISCOVER_AFAS_DEFAULTS_MUTATION = "\n mutation DiscoverAfasDefaults {\n discoverAfasDefaults {\n administration\n warehouse\n currency\n paymentCondition\n vatDuty\n collectionAccount\n }\n }\n";
|
|
224
|
+
export declare const AFAS_SYNC_LOGS_QUERY = "\n query AfasSyncLogs($options: AfasSyncLogListOptions) {\n afasSyncLogs(options: $options) {\n items { \n id\n channelId\n entityType\n entityId\n externalRef\n eventType\n status\n responseStatus\n error\n attempt\n durationMs\n createdAt\n }\n totalItems\n }\n }\n";
|
|
225
|
+
export declare const AFAS_ADMINISTRATIONS_QUERY = "\n query AfasAdministrations {\n afasAdministrations { adminCd adminNm adminId }\n }\n";
|
|
226
|
+
export declare const AFAS_WAREHOUSES_QUERY = "\n query AfasWarehouses {\n afasWarehouses { code name blocked }\n }\n";
|
|
227
|
+
export declare const AFAS_WAREHOUSE_MAPPINGS_QUERY = "\n query AfasWarehouseMappings {\n afasWarehouseMappings { \n id\n channelId\n stockLocationId\n stockLocationName\n afasWarehouse\n createdAt\n updatedAt\n }\n }\n";
|
|
228
|
+
export declare const UPSERT_AFAS_WAREHOUSE_MAPPING_MUTATION = "\n mutation UpsertAfasWarehouseMapping($stockLocationId: ID!, $afasWarehouse: String!) {\n upsertAfasWarehouseMapping(stockLocationId: $stockLocationId, afasWarehouse: $afasWarehouse) {\n \n id\n channelId\n stockLocationId\n stockLocationName\n afasWarehouse\n createdAt\n updatedAt\n\n }\n }\n";
|
|
229
|
+
export declare const DELETE_AFAS_WAREHOUSE_MAPPING_MUTATION = "\n mutation DeleteAfasWarehouseMapping($stockLocationId: ID!) {\n deleteAfasWarehouseMapping(stockLocationId: $stockLocationId)\n }\n";
|
|
230
|
+
export declare const AFAS_PAYMENT_CONDITIONS_QUERY = "\n query AfasPaymentConditions {\n afasPaymentConditions { \n id\n code\n description\n days\n dueImmediately\n source\n active\n lastSyncedAt\n createdAt\n updatedAt\n }\n }\n";
|
|
231
|
+
export declare const AFAS_PAYMENT_TERMS_STATUS_QUERY = "\n query AfasPaymentTermsStatus {\n afasPaymentTermsStatus {\n enabled\n connectorId\n conditionCount\n unmappedConditionCount\n linkedCustomers\n assigned\n unassigned\n unresolved\n stale\n lastSyncedAt\n }\n }\n";
|
|
232
|
+
export declare const SYNC_AFAS_PAYMENT_TERMS_MUTATION = "\n mutation SyncAfasPaymentTerms {\n syncAfasPaymentTerms {\n catalogConnectorId\n catalogRows\n catalogCreated\n catalogUpdated\n catalogError\n customersLinked\n customersMatched\n customersUnassigned\n customersUnresolved\n }\n }\n";
|
|
233
|
+
export declare const UPDATE_AFAS_PAYMENT_CONDITION_MUTATION = "\n mutation UpdateAfasPaymentCondition($input: UpdateAfasPaymentConditionInput!) {\n updateAfasPaymentCondition(input: $input) { \n id\n code\n description\n days\n dueImmediately\n source\n active\n lastSyncedAt\n createdAt\n updatedAt\n }\n }\n";
|
|
234
|
+
export declare function createAfasModule(transport: Transport): AfasModule;
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { pageFromVendureList, readOffsetCursor, ValidationError, } from '@sixtyninecommerce/core';
|
|
2
|
+
import { fieldOf } from '../catalog/types.js';
|
|
3
|
+
import { createAfasActionsModules, } from './afas-actions.js';
|
|
4
|
+
/** The largest page `syncLogs` asks for; the default is 25. */
|
|
5
|
+
export const AFAS_SYNC_LOG_PAGE_LIMIT = 100;
|
|
6
|
+
const AFAS_SYNC_LOG_PAGE_SIZE = 25;
|
|
7
|
+
const CORRECTION_ARTICLE_FILL_FIELDS = /* GraphQL */ `
|
|
8
|
+
storeRates
|
|
9
|
+
filled { taxRate itemCode description reason }
|
|
10
|
+
kept
|
|
11
|
+
unmatchedRates
|
|
12
|
+
errorCode
|
|
13
|
+
error
|
|
14
|
+
`;
|
|
15
|
+
const CONFIG_FIELDS = /* GraphQL */ `
|
|
16
|
+
id
|
|
17
|
+
channelId
|
|
18
|
+
enabled
|
|
19
|
+
environmentId
|
|
20
|
+
environmentType
|
|
21
|
+
orderConnectorId
|
|
22
|
+
orgCustomerConnectorId
|
|
23
|
+
perCustomerConnectorId
|
|
24
|
+
defaultCurrency
|
|
25
|
+
defaultPaymentCondition
|
|
26
|
+
defaultWarehouse
|
|
27
|
+
defaultAdministration
|
|
28
|
+
paymentTermsEnabled
|
|
29
|
+
paymentConditionConnectorId
|
|
30
|
+
balanceConnectorId
|
|
31
|
+
balanceDebtorFieldId
|
|
32
|
+
balanceAmountFieldId
|
|
33
|
+
invoiceReportConnectorId
|
|
34
|
+
invoiceReportFilterFieldId
|
|
35
|
+
debtorVatDuty
|
|
36
|
+
debtorCollectionAccount
|
|
37
|
+
shippingItemCode
|
|
38
|
+
discountItemCode
|
|
39
|
+
correctionArticleCodes { taxRate itemCode }
|
|
40
|
+
directInvoiceUnitCode
|
|
41
|
+
directInvoiceJournalId
|
|
42
|
+
createdAt
|
|
43
|
+
updatedAt
|
|
44
|
+
`;
|
|
45
|
+
const SYNC_LOG_FIELDS = /* GraphQL */ `
|
|
46
|
+
id
|
|
47
|
+
channelId
|
|
48
|
+
entityType
|
|
49
|
+
entityId
|
|
50
|
+
externalRef
|
|
51
|
+
eventType
|
|
52
|
+
status
|
|
53
|
+
responseStatus
|
|
54
|
+
error
|
|
55
|
+
attempt
|
|
56
|
+
durationMs
|
|
57
|
+
createdAt
|
|
58
|
+
`;
|
|
59
|
+
const WAREHOUSE_MAPPING_FIELDS = /* GraphQL */ `
|
|
60
|
+
id
|
|
61
|
+
channelId
|
|
62
|
+
stockLocationId
|
|
63
|
+
stockLocationName
|
|
64
|
+
afasWarehouse
|
|
65
|
+
createdAt
|
|
66
|
+
updatedAt
|
|
67
|
+
`;
|
|
68
|
+
const PAYMENT_CONDITION_FIELDS = /* GraphQL */ `
|
|
69
|
+
id
|
|
70
|
+
code
|
|
71
|
+
description
|
|
72
|
+
days
|
|
73
|
+
dueImmediately
|
|
74
|
+
source
|
|
75
|
+
active
|
|
76
|
+
lastSyncedAt
|
|
77
|
+
createdAt
|
|
78
|
+
updatedAt
|
|
79
|
+
`;
|
|
80
|
+
export const AFAS_CONFIG_QUERY = /* GraphQL */ `
|
|
81
|
+
query AfasConfig {
|
|
82
|
+
afasConfig { ${CONFIG_FIELDS} }
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
export const UPDATE_AFAS_CONFIG_MUTATION = /* GraphQL */ `
|
|
86
|
+
mutation UpdateAfasConfig($input: UpdateAfasConfigInput!) {
|
|
87
|
+
updateAfasConfig(input: $input) {
|
|
88
|
+
${CONFIG_FIELDS}
|
|
89
|
+
correctionArticleFill { ${CORRECTION_ARTICLE_FILL_FIELDS} }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
export const DELETE_AFAS_CONFIG_MUTATION = /* GraphQL */ `
|
|
94
|
+
mutation DeleteAfasConfig {
|
|
95
|
+
deleteAfasConfig
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
export const VERIFY_AFAS_CONNECTION_MUTATION = /* GraphQL */ `
|
|
99
|
+
mutation VerifyAfasConnection {
|
|
100
|
+
verifyAfasConnection {
|
|
101
|
+
connected
|
|
102
|
+
correctionArticles { ${CORRECTION_ARTICLE_FILL_FIELDS} }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
export const FILL_AFAS_CORRECTION_ARTICLES_MUTATION = /* GraphQL */ `
|
|
107
|
+
mutation FillAfasCorrectionArticles {
|
|
108
|
+
fillAfasCorrectionArticles { ${CORRECTION_ARTICLE_FILL_FIELDS} }
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
export const DISCOVER_AFAS_DEFAULTS_MUTATION = /* GraphQL */ `
|
|
112
|
+
mutation DiscoverAfasDefaults {
|
|
113
|
+
discoverAfasDefaults {
|
|
114
|
+
administration
|
|
115
|
+
warehouse
|
|
116
|
+
currency
|
|
117
|
+
paymentCondition
|
|
118
|
+
vatDuty
|
|
119
|
+
collectionAccount
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
export const AFAS_SYNC_LOGS_QUERY = /* GraphQL */ `
|
|
124
|
+
query AfasSyncLogs($options: AfasSyncLogListOptions) {
|
|
125
|
+
afasSyncLogs(options: $options) {
|
|
126
|
+
items { ${SYNC_LOG_FIELDS} }
|
|
127
|
+
totalItems
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
export const AFAS_ADMINISTRATIONS_QUERY = /* GraphQL */ `
|
|
132
|
+
query AfasAdministrations {
|
|
133
|
+
afasAdministrations { adminCd adminNm adminId }
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
export const AFAS_WAREHOUSES_QUERY = /* GraphQL */ `
|
|
137
|
+
query AfasWarehouses {
|
|
138
|
+
afasWarehouses { code name blocked }
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
export const AFAS_WAREHOUSE_MAPPINGS_QUERY = /* GraphQL */ `
|
|
142
|
+
query AfasWarehouseMappings {
|
|
143
|
+
afasWarehouseMappings { ${WAREHOUSE_MAPPING_FIELDS} }
|
|
144
|
+
}
|
|
145
|
+
`;
|
|
146
|
+
export const UPSERT_AFAS_WAREHOUSE_MAPPING_MUTATION = /* GraphQL */ `
|
|
147
|
+
mutation UpsertAfasWarehouseMapping($stockLocationId: ID!, $afasWarehouse: String!) {
|
|
148
|
+
upsertAfasWarehouseMapping(stockLocationId: $stockLocationId, afasWarehouse: $afasWarehouse) {
|
|
149
|
+
${WAREHOUSE_MAPPING_FIELDS}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
153
|
+
export const DELETE_AFAS_WAREHOUSE_MAPPING_MUTATION = /* GraphQL */ `
|
|
154
|
+
mutation DeleteAfasWarehouseMapping($stockLocationId: ID!) {
|
|
155
|
+
deleteAfasWarehouseMapping(stockLocationId: $stockLocationId)
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
158
|
+
export const AFAS_PAYMENT_CONDITIONS_QUERY = /* GraphQL */ `
|
|
159
|
+
query AfasPaymentConditions {
|
|
160
|
+
afasPaymentConditions { ${PAYMENT_CONDITION_FIELDS} }
|
|
161
|
+
}
|
|
162
|
+
`;
|
|
163
|
+
export const AFAS_PAYMENT_TERMS_STATUS_QUERY = /* GraphQL */ `
|
|
164
|
+
query AfasPaymentTermsStatus {
|
|
165
|
+
afasPaymentTermsStatus {
|
|
166
|
+
enabled
|
|
167
|
+
connectorId
|
|
168
|
+
conditionCount
|
|
169
|
+
unmappedConditionCount
|
|
170
|
+
linkedCustomers
|
|
171
|
+
assigned
|
|
172
|
+
unassigned
|
|
173
|
+
unresolved
|
|
174
|
+
stale
|
|
175
|
+
lastSyncedAt
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
export const SYNC_AFAS_PAYMENT_TERMS_MUTATION = /* GraphQL */ `
|
|
180
|
+
mutation SyncAfasPaymentTerms {
|
|
181
|
+
syncAfasPaymentTerms {
|
|
182
|
+
catalogConnectorId
|
|
183
|
+
catalogRows
|
|
184
|
+
catalogCreated
|
|
185
|
+
catalogUpdated
|
|
186
|
+
catalogError
|
|
187
|
+
customersLinked
|
|
188
|
+
customersMatched
|
|
189
|
+
customersUnassigned
|
|
190
|
+
customersUnresolved
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
`;
|
|
194
|
+
export const UPDATE_AFAS_PAYMENT_CONDITION_MUTATION = /* GraphQL */ `
|
|
195
|
+
mutation UpdateAfasPaymentCondition($input: UpdateAfasPaymentConditionInput!) {
|
|
196
|
+
updateAfasPaymentCondition(input: $input) { ${PAYMENT_CONDITION_FIELDS} }
|
|
197
|
+
}
|
|
198
|
+
`;
|
|
199
|
+
const invalidInput = (message) => new ValidationError({ code: 'INVALID_AFAS_INPUT', message, status: 400, service: 'vendure' });
|
|
200
|
+
const requireLocationId = (value) => {
|
|
201
|
+
if (typeof value !== 'string' || value === '') {
|
|
202
|
+
throw invalidInput('stockLocationId must be the id of a stock location of the store.');
|
|
203
|
+
}
|
|
204
|
+
return value;
|
|
205
|
+
};
|
|
206
|
+
const requireObject = (value, method) => {
|
|
207
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
208
|
+
throw invalidInput(`${method} takes an input object.`);
|
|
209
|
+
}
|
|
210
|
+
return value;
|
|
211
|
+
};
|
|
212
|
+
export function createAfasModule(transport) {
|
|
213
|
+
const read = (document, field, options, variables = {}) => fieldOf(transport, document, field, variables, options);
|
|
214
|
+
const syncLogPage = async (filter, skip, take, options) => {
|
|
215
|
+
const list = await read(AFAS_SYNC_LOGS_QUERY, 'afasSyncLogs', options, { options: { ...filter, skip, take } });
|
|
216
|
+
return pageFromVendureList(list, skip, take, (cursor) => syncLogPage(filter, readOffsetCursor(cursor), take, options));
|
|
217
|
+
};
|
|
218
|
+
return {
|
|
219
|
+
...createAfasActionsModules(transport),
|
|
220
|
+
config: {
|
|
221
|
+
async get(options) {
|
|
222
|
+
return (await read(AFAS_CONFIG_QUERY, 'afasConfig', options)) ?? null;
|
|
223
|
+
},
|
|
224
|
+
async update(input, options) {
|
|
225
|
+
// Sent as given: an absent key keeps the stored value, and the engine names every field
|
|
226
|
+
// it refuses (AFAS_CONFIG_INVALID).
|
|
227
|
+
return read(UPDATE_AFAS_CONFIG_MUTATION, 'updateAfasConfig', options, {
|
|
228
|
+
input: requireObject(input, 'config.update'),
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
async delete(options) {
|
|
232
|
+
return ((await read(DELETE_AFAS_CONFIG_MUTATION, 'deleteAfasConfig', options)) === true);
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
verifyConnection(options) {
|
|
236
|
+
return read(VERIFY_AFAS_CONNECTION_MUTATION, 'verifyAfasConnection', options);
|
|
237
|
+
},
|
|
238
|
+
fillCorrectionArticles(options) {
|
|
239
|
+
return read(FILL_AFAS_CORRECTION_ARTICLES_MUTATION, 'fillAfasCorrectionArticles', options);
|
|
240
|
+
},
|
|
241
|
+
discoverDefaults(options) {
|
|
242
|
+
return read(DISCOVER_AFAS_DEFAULTS_MUTATION, 'discoverAfasDefaults', options);
|
|
243
|
+
},
|
|
244
|
+
syncLogs(filter) {
|
|
245
|
+
const { after, limit, entityType, entityId, status, ...options } = filter ?? {};
|
|
246
|
+
const take = Math.min(Math.max(limit ?? AFAS_SYNC_LOG_PAGE_SIZE, 1), AFAS_SYNC_LOG_PAGE_LIMIT);
|
|
247
|
+
const skip = after === undefined ? 0 : readOffsetCursor(after);
|
|
248
|
+
return syncLogPage({ entityType, entityId, status }, skip, take, options);
|
|
249
|
+
},
|
|
250
|
+
administrations(options) {
|
|
251
|
+
return read(AFAS_ADMINISTRATIONS_QUERY, 'afasAdministrations', options);
|
|
252
|
+
},
|
|
253
|
+
warehouses(options) {
|
|
254
|
+
return read(AFAS_WAREHOUSES_QUERY, 'afasWarehouses', options);
|
|
255
|
+
},
|
|
256
|
+
warehouseMappings: {
|
|
257
|
+
list(options) {
|
|
258
|
+
return read(AFAS_WAREHOUSE_MAPPINGS_QUERY, 'afasWarehouseMappings', options);
|
|
259
|
+
},
|
|
260
|
+
async upsert(stockLocationId, afasWarehouse, options) {
|
|
261
|
+
const location = requireLocationId(stockLocationId);
|
|
262
|
+
if (typeof afasWarehouse !== 'string') {
|
|
263
|
+
throw invalidInput('afasWarehouse must be an AFAS warehouse code.');
|
|
264
|
+
}
|
|
265
|
+
// The code goes as typed: the engine trims it and judges its length.
|
|
266
|
+
return read(UPSERT_AFAS_WAREHOUSE_MAPPING_MUTATION, 'upsertAfasWarehouseMapping', options, { stockLocationId: location, afasWarehouse });
|
|
267
|
+
},
|
|
268
|
+
async delete(stockLocationId, options) {
|
|
269
|
+
return ((await read(DELETE_AFAS_WAREHOUSE_MAPPING_MUTATION, 'deleteAfasWarehouseMapping', options, { stockLocationId: requireLocationId(stockLocationId) })) === true);
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
paymentTerms: {
|
|
273
|
+
conditions(options) {
|
|
274
|
+
return read(AFAS_PAYMENT_CONDITIONS_QUERY, 'afasPaymentConditions', options);
|
|
275
|
+
},
|
|
276
|
+
status(options) {
|
|
277
|
+
return read(AFAS_PAYMENT_TERMS_STATUS_QUERY, 'afasPaymentTermsStatus', options);
|
|
278
|
+
},
|
|
279
|
+
sync(options) {
|
|
280
|
+
return read(SYNC_AFAS_PAYMENT_TERMS_MUTATION, 'syncAfasPaymentTerms', options);
|
|
281
|
+
},
|
|
282
|
+
async updateCondition(input, options) {
|
|
283
|
+
if (typeof requireObject(input, 'paymentTerms.updateCondition').code !== 'string') {
|
|
284
|
+
throw invalidInput('paymentTerms.updateCondition needs the condition code.');
|
|
285
|
+
}
|
|
286
|
+
return read(UPDATE_AFAS_PAYMENT_CONDITION_MUTATION, 'updateAfasPaymentCondition', options, { input });
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type Page, type Transport } from '@sixtyninecommerce/core';
|
|
2
|
+
import type { Call, ListOptions } from '../types.js';
|
|
3
|
+
import type { CreatePipelineConnectionInput, DetectPipelineConnectionConfigInput, PipelineConnection, PipelineConnector, PipelineSiteAnalysis, TestPipelineConnectionInput, UpdatePipelineConnectionInput } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The draft set plus a probe's `entityCounts`, keyed by the source's own entity names (a WordPress
|
|
6
|
+
* post type such as `product_brand`). `test` and `retest` answer the analysis at the top level,
|
|
7
|
+
* where no passthrough key covers it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PIPELINE_CONNECTION_PRESERVE_KEYS: ReadonlySet<string>;
|
|
10
|
+
/**
|
|
11
|
+
* The store's source connections: the login to another system (a WooCommerce shop, a BluJay WMS
|
|
12
|
+
* SFTP server) that its import and export pipelines run over (headless spec §9.2).
|
|
13
|
+
*
|
|
14
|
+
* - **Credentials are write-only.** `create`, `update`, `test` and `detectConfig` take them; no
|
|
15
|
+
* answer carries a secret. `publicCredentials` holds the fields the connector does not mark
|
|
16
|
+
* `password` ({@link PipelineConnector.credentialFields}).
|
|
17
|
+
* - **Every write that sends credentials or changes where they go probes the source first**, and a
|
|
18
|
+
* failed probe saves nothing: `ValidationError` (400) coded `PIPELINE_CONNECTION_TEST_FAILED`
|
|
19
|
+
* with a readable reason (unreachable, refused, timed out), or `CONNECTION_CONFIG_INVALID` when
|
|
20
|
+
* the connector itself refuses a setting (`details[].field` names it). A connector type the
|
|
21
|
+
* deployment does not offer is `CONNECTOR_TYPE_UNKNOWN`.
|
|
22
|
+
* - **A stored secret stays with its recipient** (`PipelineConnector.credentialBinding`): an
|
|
23
|
+
* `update` that moves the source URL or the SFTP login must carry every required secret again,
|
|
24
|
+
* or it is refused `PIPELINE_HOST_CHANGE_REQUIRES_CREDENTIALS` (422) before anything is sent.
|
|
25
|
+
* - **Organization workspaces are not stores**: every door that tests, creates or changes a
|
|
26
|
+
* connection answers `ORGANIZATION_WORKSPACE_NOT_A_STORE` (422) there.
|
|
27
|
+
* - **Apps:** an app installation is refused every door that sends, tests or writes credentials
|
|
28
|
+
* (`APP_CREDENTIAL_NOT_ALLOWED`, 403), and an app below `customerData: full` every door
|
|
29
|
+
* (`CUSTOMER_DATA_NOT_GRANTED`).
|
|
30
|
+
* - Reads need `ReadCatalog`; writes, probes and `delete` need `UpdateCatalog`. Another store's
|
|
31
|
+
* connection is not found (`get` answers `null`, a write a `NotFoundError`).
|
|
32
|
+
*/
|
|
33
|
+
export interface PipelineConnectionsModule {
|
|
34
|
+
/**
|
|
35
|
+
* The store's connections, newest first, each with the pipelines that run over it. Includes the
|
|
36
|
+
* ones whose last probe failed (`status: 'error'`): fix or delete them here.
|
|
37
|
+
*
|
|
38
|
+
* @effect read
|
|
39
|
+
*/
|
|
40
|
+
list(options?: ListOptions): Promise<Page<PipelineConnection>>;
|
|
41
|
+
/**
|
|
42
|
+
* One connection, or `null` when the store has none with that id (deleted, or another store's).
|
|
43
|
+
*
|
|
44
|
+
* @effect read
|
|
45
|
+
*/
|
|
46
|
+
get(id: string, options?: Call): Promise<PipelineConnection | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Probe the source with `credentials`, then store the connection with them encrypted. A failed
|
|
49
|
+
* probe stores nothing. Up to a minute on a slow source.
|
|
50
|
+
*
|
|
51
|
+
* @effect write
|
|
52
|
+
*/
|
|
53
|
+
create(input: CreatePipelineConnectionInput, options?: Call): Promise<PipelineConnection>;
|
|
54
|
+
/**
|
|
55
|
+
* Change a connection. A field left out stays as stored. A rename, a throttle or the legacy
|
|
56
|
+
* hosts save without a probe, so they work while the source is down; new credentials or a new
|
|
57
|
+
* source URL are probed first and saved only if the probe succeeds. Two overlapping saves that
|
|
58
|
+
* both change the source are answered `PIPELINE_CONNECTION_CHANGED` (409) for the later one:
|
|
59
|
+
* read it again and save again. The new settings apply to every pipeline over it from its next
|
|
60
|
+
* run on, scheduled ones included.
|
|
61
|
+
*
|
|
62
|
+
* @effect write
|
|
63
|
+
*/
|
|
64
|
+
update(id: string, input: UpdatePipelineConnectionInput, options?: Call): Promise<PipelineConnection>;
|
|
65
|
+
/**
|
|
66
|
+
* Delete a connection and the credentials stored with it. Refused with a `ConflictError` coded
|
|
67
|
+
* `PIPELINE_CONNECTION_IN_USE` (409), deleting nothing, while a pipeline or an unfinished set-up
|
|
68
|
+
* (`pipelines.drafts`) still uses it: the message names them, and `details[]` lists each one's
|
|
69
|
+
* id (`field` `pipeline_id` or `draft_id`). Delete those pipelines, and finish or discard those
|
|
70
|
+
* set-ups, first. The credentials cannot be recovered: a connection made again needs them
|
|
71
|
+
* typed again.
|
|
72
|
+
*
|
|
73
|
+
* @effect destructive
|
|
74
|
+
*/
|
|
75
|
+
delete(id: string, options?: Call): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Probe a source with credentials that are not saved anywhere, and answer what it reported.
|
|
78
|
+
* Nothing is stored. Up to a minute on a slow source.
|
|
79
|
+
*
|
|
80
|
+
* @effect read
|
|
81
|
+
*/
|
|
82
|
+
test(input: TestPipelineConnectionInput, options?: Call): Promise<PipelineSiteAnalysis>;
|
|
83
|
+
/**
|
|
84
|
+
* Probe a saved connection with its stored credentials. The outcome is recorded either way: a
|
|
85
|
+
* success sets `status: 'connected'` and the new `siteAnalysis`, a failure `status: 'error'`
|
|
86
|
+
* (and is then refused `PIPELINE_CONNECTION_TEST_FAILED`). Both stamp `lastTestedAt`.
|
|
87
|
+
*
|
|
88
|
+
* @effect write
|
|
89
|
+
*/
|
|
90
|
+
retest(id: string, options?: Call): Promise<PipelineSiteAnalysis>;
|
|
91
|
+
/**
|
|
92
|
+
* Ask the source for the settings a connector can find itself (BluJay WMS: the upload and stock
|
|
93
|
+
* file paths and the transmitter code), from the login in `credentials`. Answers the credential
|
|
94
|
+
* fields it found, by `key`, to put in the form; nothing is stored. A connector that cannot
|
|
95
|
+
* detect anything answers a `ValidationError` (400).
|
|
96
|
+
*
|
|
97
|
+
* @effect read
|
|
98
|
+
*/
|
|
99
|
+
detectConfig(input: DetectPipelineConnectionConfigInput, options?: Call): Promise<Record<string, string>>;
|
|
100
|
+
}
|
|
101
|
+
export declare function createPipelineConnectionsModule(transport: Transport): PipelineConnectionsModule;
|
|
102
|
+
/** The connectors this deployment offers, `coming_soon` ones included. */
|
|
103
|
+
export declare function listPipelineConnectors(transport: Transport, options?: Call): Promise<PipelineConnector[]>;
|