@sixtyninecommerce/admin 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +4598 -128
  2. package/dist/catalog/assets.d.ts +120 -8
  3. package/dist/catalog/assets.js +98 -12
  4. package/dist/catalog/collections.d.ts +279 -14
  5. package/dist/catalog/collections.js +246 -15
  6. package/dist/catalog/index.d.ts +9 -2
  7. package/dist/catalog/index.js +4 -0
  8. package/dist/catalog/products.d.ts +318 -17
  9. package/dist/catalog/products.js +182 -14
  10. package/dist/catalog/properties.d.ts +102 -14
  11. package/dist/catalog/properties.js +13 -0
  12. package/dist/catalog/recommendations.d.ts +261 -0
  13. package/dist/catalog/recommendations.js +145 -0
  14. package/dist/catalog/reviews.d.ts +368 -0
  15. package/dist/catalog/reviews.js +318 -0
  16. package/dist/catalog/types.d.ts +17 -1
  17. package/dist/catalog/types.js +10 -0
  18. package/dist/catalog/variant-find.d.ts +136 -0
  19. package/dist/catalog/variant-find.js +239 -0
  20. package/dist/catalog/variants.d.ts +282 -25
  21. package/dist/catalog/variants.js +173 -25
  22. package/dist/catalog/visibility.d.ts +20 -5
  23. package/dist/catalog/visibility.js +19 -1
  24. package/dist/client.d.ts +116 -9
  25. package/dist/client.js +41 -7
  26. package/dist/content/assets.d.ts +286 -0
  27. package/dist/content/assets.js +181 -0
  28. package/dist/content/items.d.ts +269 -0
  29. package/dist/content/items.js +170 -0
  30. package/dist/content/types.d.ts +282 -0
  31. package/dist/content/types.js +100 -0
  32. package/dist/customers/age-verification.d.ts +66 -0
  33. package/dist/customers/age-verification.js +79 -0
  34. package/dist/customers/credit.d.ts +263 -0
  35. package/dist/customers/credit.js +244 -0
  36. package/dist/customers/delivery-preferences.d.ts +120 -0
  37. package/dist/customers/delivery-preferences.js +97 -0
  38. package/dist/customers/groups.d.ts +207 -0
  39. package/dist/customers/groups.js +438 -0
  40. package/dist/customers/index.d.ts +447 -37
  41. package/dist/customers/index.js +313 -40
  42. package/dist/customers/invitation-status.d.ts +57 -0
  43. package/dist/customers/invitation-status.js +21 -0
  44. package/dist/customers/notes.d.ts +67 -0
  45. package/dist/customers/notes.js +51 -0
  46. package/dist/customers/notification-recipients.d.ts +97 -0
  47. package/dist/customers/notification-recipients.js +84 -0
  48. package/dist/customers/saved-lists.d.ts +42 -0
  49. package/dist/customers/saved-lists.js +61 -0
  50. package/dist/customers/vat.d.ts +83 -0
  51. package/dist/customers/vat.js +46 -0
  52. package/dist/customers/wire.d.ts +20 -0
  53. package/dist/customers/wire.js +35 -0
  54. package/dist/documents/ar.d.ts +307 -0
  55. package/dist/documents/ar.js +254 -0
  56. package/dist/documents/index.d.ts +731 -21
  57. package/dist/documents/index.js +436 -24
  58. package/dist/documents/pdf.d.ts +2 -0
  59. package/dist/documents/pdf.js +11 -0
  60. package/dist/fulfillments/create.d.ts +167 -0
  61. package/dist/fulfillments/create.js +216 -0
  62. package/dist/fulfillments/index.d.ts +121 -10
  63. package/dist/fulfillments/index.js +120 -2
  64. package/dist/fulfillments/payment-policy.d.ts +64 -0
  65. package/dist/fulfillments/payment-policy.js +140 -0
  66. package/dist/fulfillments/warehouse.d.ts +724 -0
  67. package/dist/fulfillments/warehouse.js +914 -0
  68. package/dist/geo/index.d.ts +119 -0
  69. package/dist/geo/index.js +107 -0
  70. package/dist/index.d.ts +129 -30
  71. package/dist/index.js +47 -9
  72. package/dist/integrations/afas-actions.d.ts +234 -0
  73. package/dist/integrations/afas-actions.js +310 -0
  74. package/dist/integrations/afas-types.d.ts +483 -0
  75. package/dist/integrations/afas-types.js +5 -0
  76. package/dist/integrations/afas.d.ts +234 -0
  77. package/dist/integrations/afas.js +290 -0
  78. package/dist/integrations/connections.d.ts +103 -0
  79. package/dist/integrations/connections.js +55 -0
  80. package/dist/integrations/esp.d.ts +313 -0
  81. package/dist/integrations/esp.js +169 -0
  82. package/dist/integrations/exact-online-types.d.ts +423 -0
  83. package/dist/integrations/exact-online-types.js +6 -0
  84. package/dist/integrations/exact-online.d.ts +248 -0
  85. package/dist/integrations/exact-online.js +376 -0
  86. package/dist/integrations/index.d.ts +40 -0
  87. package/dist/integrations/index.js +24 -0
  88. package/dist/integrations/pipeline-keys.d.ts +13 -0
  89. package/dist/integrations/pipeline-keys.js +22 -0
  90. package/dist/integrations/pipelines.d.ts +114 -0
  91. package/dist/integrations/pipelines.js +46 -0
  92. package/dist/integrations/types.d.ts +322 -0
  93. package/dist/integrations/types.js +8 -0
  94. package/dist/jobs/bulk-action-run.d.ts +11 -2
  95. package/dist/jobs/bulk-action-run.js +4 -5
  96. package/dist/locations/index.d.ts +66 -0
  97. package/dist/locations/index.js +31 -0
  98. package/dist/meta/index.d.ts +162 -0
  99. package/dist/orders/bulk.d.ts +75 -0
  100. package/dist/orders/bulk.js +150 -0
  101. package/dist/orders/cancel-with-money.d.ts +227 -0
  102. package/dist/orders/cancel-with-money.js +153 -0
  103. package/dist/orders/commit-edit.d.ts +7 -1
  104. package/dist/orders/commit-edit.js +5 -1
  105. package/dist/orders/deposit-policy.d.ts +103 -0
  106. package/dist/orders/deposit-policy.js +202 -0
  107. package/dist/orders/drafts.d.ts +800 -0
  108. package/dist/orders/drafts.js +771 -0
  109. package/dist/orders/fields.d.ts +245 -0
  110. package/dist/orders/fields.js +188 -0
  111. package/dist/orders/get.d.ts +29 -19
  112. package/dist/orders/get.js +17 -8
  113. package/dist/orders/index.d.ts +125 -5
  114. package/dist/orders/index.js +35 -2
  115. package/dist/orders/lifecycle.d.ts +128 -0
  116. package/dist/orders/lifecycle.js +158 -0
  117. package/dist/orders/line-price-preview.d.ts +7 -2
  118. package/dist/orders/list.d.ts +222 -0
  119. package/dist/orders/list.js +377 -0
  120. package/dist/orders/manual-discounts.d.ts +11 -2
  121. package/dist/orders/manual-discounts.js +2 -0
  122. package/dist/orders/manual-pricing.d.ts +5 -0
  123. package/dist/orders/order-entry.d.ts +20 -7
  124. package/dist/orders/plan-edit.d.ts +1 -1
  125. package/dist/orders/plan-edit.js +4 -1
  126. package/dist/orders/settings.d.ts +201 -0
  127. package/dist/orders/settings.js +325 -0
  128. package/dist/orders/status.d.ts +159 -13
  129. package/dist/orders/status.js +21 -0
  130. package/dist/orders/surcharges.d.ts +8 -1
  131. package/dist/orders/surcharges.js +3 -2
  132. package/dist/payments/account-credit.d.ts +30 -0
  133. package/dist/payments/account-credit.js +19 -0
  134. package/dist/payments/ar.d.ts +292 -0
  135. package/dist/payments/ar.js +223 -0
  136. package/dist/payments/connected-account.d.ts +47 -0
  137. package/dist/payments/connected-account.js +61 -0
  138. package/dist/payments/credit-noted-fields.d.ts +12 -0
  139. package/dist/payments/credit-noted-fields.js +37 -0
  140. package/dist/payments/index.d.ts +263 -10
  141. package/dist/payments/index.js +133 -1
  142. package/dist/payments/methods.d.ts +332 -0
  143. package/dist/payments/methods.js +363 -0
  144. package/dist/payments/mollie-methods.d.ts +159 -0
  145. package/dist/payments/mollie-methods.js +141 -0
  146. package/dist/payments/payment-links.d.ts +180 -0
  147. package/dist/payments/payment-links.js +97 -0
  148. package/dist/payments/provider-keys.d.ts +150 -0
  149. package/dist/payments/provider-keys.js +118 -0
  150. package/dist/payments/providers.d.ts +86 -11
  151. package/dist/payments/providers.js +29 -0
  152. package/dist/payments/requests.d.ts +144 -0
  153. package/dist/payments/requests.js +92 -0
  154. package/dist/payments/store-credit-fields.d.ts +15 -0
  155. package/dist/payments/store-credit-fields.js +51 -0
  156. package/dist/pickups/index.d.ts +104 -0
  157. package/dist/pickups/index.js +105 -0
  158. package/dist/platform/channels.d.ts +132 -0
  159. package/dist/platform/channels.js +128 -0
  160. package/dist/platform/geo.d.ts +123 -0
  161. package/dist/platform/geo.js +144 -0
  162. package/dist/platform/tax.d.ts +154 -0
  163. package/dist/platform/tax.js +139 -0
  164. package/dist/pos/anomalies.d.ts +158 -0
  165. package/dist/pos/anomalies.js +64 -0
  166. package/dist/pos/assisted-selling.d.ts +79 -0
  167. package/dist/pos/assisted-selling.js +38 -0
  168. package/dist/pos/exchanges.d.ts +103 -0
  169. package/dist/pos/exchanges.js +22 -0
  170. package/dist/pos/gift-cards.d.ts +135 -0
  171. package/dist/pos/gift-cards.js +47 -0
  172. package/dist/pos/index.d.ts +2125 -32
  173. package/dist/pos/index.js +742 -4
  174. package/dist/pos/no-receipt.d.ts +94 -0
  175. package/dist/pos/no-receipt.js +25 -0
  176. package/dist/pos/offline-sales.d.ts +187 -0
  177. package/dist/pos/offline-sales.js +116 -0
  178. package/dist/pos/pay-by-link.d.ts +143 -0
  179. package/dist/pos/pay-by-link.js +57 -0
  180. package/dist/pos/quick-keys.d.ts +103 -0
  181. package/dist/pos/quick-keys.js +45 -0
  182. package/dist/pos/reports.d.ts +360 -0
  183. package/dist/pos/reports.js +62 -0
  184. package/dist/pos/returns.d.ts +217 -0
  185. package/dist/pos/returns.js +53 -0
  186. package/dist/pricing/bulk-coupons.d.ts +139 -0
  187. package/dist/pricing/bulk-coupons.js +112 -0
  188. package/dist/pricing/index.d.ts +177 -4
  189. package/dist/pricing/index.js +176 -1
  190. package/dist/pricing/price-lists.d.ts +604 -0
  191. package/dist/pricing/price-lists.js +600 -0
  192. package/dist/pricing/vouchers.d.ts +103 -0
  193. package/dist/pricing/vouchers.js +69 -0
  194. package/dist/purchasing/alerts.d.ts +89 -0
  195. package/dist/purchasing/alerts.js +62 -0
  196. package/dist/purchasing/cost.d.ts +110 -0
  197. package/dist/purchasing/cost.js +86 -0
  198. package/dist/purchasing/index.d.ts +36 -0
  199. package/dist/purchasing/index.js +16 -0
  200. package/dist/purchasing/purchase-orders.d.ts +548 -0
  201. package/dist/purchasing/purchase-orders.js +491 -0
  202. package/dist/purchasing/replenishment.d.ts +281 -0
  203. package/dist/purchasing/replenishment.js +240 -0
  204. package/dist/purchasing/settings.d.ts +152 -0
  205. package/dist/purchasing/settings.js +181 -0
  206. package/dist/purchasing/suppliers.d.ts +476 -0
  207. package/dist/purchasing/suppliers.js +438 -0
  208. package/dist/quotes/index.d.ts +501 -0
  209. package/dist/quotes/index.js +439 -0
  210. package/dist/reports/index.d.ts +71 -8
  211. package/dist/reports/index.js +74 -11
  212. package/dist/returns/index.d.ts +818 -0
  213. package/dist/returns/index.js +844 -0
  214. package/dist/search/index.d.ts +174 -0
  215. package/dist/search/index.js +125 -0
  216. package/dist/shipping/definitions.d.ts +29 -0
  217. package/dist/shipping/definitions.js +47 -0
  218. package/dist/shipping/fulfillment-profiles.d.ts +174 -0
  219. package/dist/shipping/fulfillment-profiles.js +104 -0
  220. package/dist/shipping/hendriks.d.ts +97 -0
  221. package/dist/shipping/hendriks.js +50 -0
  222. package/dist/shipping/index.d.ts +48 -0
  223. package/dist/shipping/index.js +25 -0
  224. package/dist/shipping/methods.d.ts +198 -0
  225. package/dist/shipping/methods.js +240 -0
  226. package/dist/shipping/myparcel.d.ts +254 -0
  227. package/dist/shipping/myparcel.js +178 -0
  228. package/dist/shipping/parcel-count-suggestion.d.ts +2 -0
  229. package/dist/shipping/parcel-rule.d.ts +6 -5
  230. package/dist/shipping/parcel-rule.js +21 -23
  231. package/dist/shipping/rate-tables.d.ts +179 -0
  232. package/dist/shipping/rate-tables.js +184 -0
  233. package/dist/stock/index.d.ts +10 -3
  234. package/dist/stock/index.js +3 -0
  235. package/dist/stock/locations.d.ts +144 -0
  236. package/dist/stock/locations.js +168 -0
  237. package/dist/stock/transfers.d.ts +216 -43
  238. package/dist/stock/transfers.js +140 -13
  239. package/dist/stored-value/index.d.ts +214 -4
  240. package/dist/stored-value/index.js +152 -0
  241. package/dist/subscriptions/index.d.ts +682 -0
  242. package/dist/subscriptions/index.js +815 -0
  243. package/dist/tax/index.d.ts +76 -1
  244. package/dist/tax/index.js +50 -0
  245. package/dist/tenant/email-style.d.ts +102 -0
  246. package/dist/tenant/email-style.js +72 -0
  247. package/dist/tenant/email-templates.d.ts +66 -0
  248. package/dist/tenant/email-templates.js +54 -0
  249. package/dist/tenant/notifications.d.ts +23 -17
  250. package/dist/tenant/settings-sources.d.ts +1 -1
  251. package/dist/tenant/time-zone.d.ts +17 -0
  252. package/dist/tenant/time-zone.js +11 -0
  253. package/dist/types.d.ts +51 -4
  254. package/dist/users/index.d.ts +3 -0
  255. package/dist/users/index.js +2 -0
  256. package/dist/users/warehouses.d.ts +50 -0
  257. package/dist/users/warehouses.js +51 -0
  258. package/package.json +2 -2
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Integrations (headless spec §9.2): the store's connections to other systems. The data
3
+ * pipelines' source connections, connectors and import and export set-ups, the e-mail marketing
4
+ * connection (`esp`), the AFAS Profit connection with what is sent to it (`afas`) and the Exact
5
+ * Online connection with its settings (`exactOnline`); the pipelines themselves, their runs and
6
+ * their progress streams follow in phase 7.
7
+ */
8
+ import { createAfasModule } from './afas.js';
9
+ import { createEspModule } from './esp.js';
10
+ import { createExactOnlineModule } from './exact-online.js';
11
+ import { createIntegrationPipelinesModule } from './pipelines.js';
12
+ export { AFAS_SYNC_LOG_PAGE_LIMIT } from './afas.js';
13
+ export { AFAS_CUSTOMER_SEARCH_LIMIT } from './afas-actions.js';
14
+ export { PIPELINE_CONNECTION_PRESERVE_KEYS } from './connections.js';
15
+ export { ESP_BACKFILL_RESOURCES, ESP_SYNC_LOG_PAGE_LIMIT } from './esp.js';
16
+ export { PIPELINE_DRAFT_PRESERVE_KEYS, PIPELINE_DRAFT_SLOW_TIMEOUT_MS } from './pipelines.js';
17
+ export function createIntegrationsModule(transport) {
18
+ return {
19
+ pipelines: createIntegrationPipelinesModule(transport),
20
+ esp: createEspModule(transport),
21
+ afas: createAfasModule(transport),
22
+ exactOnline: createExactOnlineModule(transport),
23
+ };
24
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Every key whose VALUE is stored data, not DTO shape: the platform's passthrough set
3
+ * (`credentials`, `public_credentials`, `site_analysis`, `trigger_filter`, …) plus a schema map's
4
+ * jsonb columns, which carry the source's own field names and sample records. Converting them
5
+ * would rename a sample's `date_created` to `dateCreated`, and a `triggerFilter`'s `toState` would
6
+ * reach the reader as `to_state`, which it ignores.
7
+ */
8
+ export declare const PIPELINE_DRAFT_PRESERVE_KEYS: ReadonlySet<string>;
9
+ /**
10
+ * A creation probes the source over the network, and a commit creates the pipeline and may start
11
+ * its run: both outlast the SDK's 15-second default on a slow source.
12
+ */
13
+ export declare const PIPELINE_DRAFT_SLOW_TIMEOUT_MS = 60000;
@@ -0,0 +1,22 @@
1
+ import { PLATFORM_PASSTHROUGH_KEYS } from '@sixtyninecommerce/core';
2
+ /**
3
+ * Every key whose VALUE is stored data, not DTO shape: the platform's passthrough set
4
+ * (`credentials`, `public_credentials`, `site_analysis`, `trigger_filter`, …) plus a schema map's
5
+ * jsonb columns, which carry the source's own field names and sample records. Converting them
6
+ * would rename a sample's `date_created` to `dateCreated`, and a `triggerFilter`'s `toState` would
7
+ * reach the reader as `to_state`, which it ignores.
8
+ */
9
+ export const PIPELINE_DRAFT_PRESERVE_KEYS = new Set([
10
+ ...PLATFORM_PASSTHROUGH_KEYS,
11
+ 'source_schema',
12
+ 'sourceSchema',
13
+ 'target_schema',
14
+ 'targetSchema',
15
+ 'sub_counts',
16
+ 'subCounts',
17
+ ]);
18
+ /**
19
+ * A creation probes the source over the network, and a commit creates the pipeline and may start
20
+ * its run: both outlast the SDK's 15-second default on a slow source.
21
+ */
22
+ export const PIPELINE_DRAFT_SLOW_TIMEOUT_MS = 60_000;
@@ -0,0 +1,114 @@
1
+ import { type Page, type Transport } from '@sixtyninecommerce/core';
2
+ import type { Call, ListOptions } from '../types.js';
3
+ import { type PipelineConnectionsModule } from './connections.js';
4
+ import type { CommittedPipelineDraft, ImportDependency, PipelineConnector, PipelineDirection, PipelineDraft, PipelineDraftSummary, UpdatePipelineDraftInput, UpdatePipelineDraftSchemaMapInput } from './types.js';
5
+ export { PIPELINE_DRAFT_PRESERVE_KEYS, PIPELINE_DRAFT_SLOW_TIMEOUT_MS } from './pipeline-keys.js';
6
+ /**
7
+ * Half-finished import and export set-ups, kept on the server for the store (headless spec §7).
8
+ *
9
+ * - **Any admin of the store with pipeline rights (`UpdateCatalog`) continues a draft, from any
10
+ * device.** Drafts belong to the store, not to the person who started one: the list shows every
11
+ * unfinished set-up of the active store, and another store's draft is `PIPELINE_DRAFT_NOT_FOUND`.
12
+ * - **Kept 7 days after its LAST change.** Every write moves `expiresAt`; reads do not. An expired
13
+ * draft answers `PIPELINE_DRAFT_NOT_FOUND` at once, and the platform then deletes it together
14
+ * with the connection (and its stored password) the draft created, unless a pipeline or another
15
+ * draft uses that connection. A connection that existed before any draft is never deleted; one
16
+ * another draft created is the picking draft's too (`connection.createdByDraft`), and goes when
17
+ * the last draft holding it lets go of it unused.
18
+ * - **A draft never holds a secret.** Credentials go to {@link PipelineDraftsModule.connect} only,
19
+ * which creates the connection and stores them there, encrypted. A set-up resumed before its
20
+ * connection exists asks for the credentials again; the source URL and the other settings are
21
+ * kept.
22
+ * - **Every change names the `version` it was made against** and answers the draft with the next
23
+ * one. A change made on an older version is refused with a `ConflictError` coded
24
+ * `PIPELINE_DRAFT_CONFLICT` (409) and changes nothing: another admin, or another tab, changed it
25
+ * first. Read it again and reapply.
26
+ * - What a step still needs is a `BusinessRuleError` coded `PIPELINE_DRAFT_INCOMPLETE` (422) whose
27
+ * `details[]` name each field; a change the set-up refuses (a step of the other direction, a
28
+ * connector that cannot work in it) is a `ValidationError` coded `PIPELINE_DRAFT_INVALID` (400).
29
+ * - An organization workspace is not a store and is refused every door; an app below
30
+ * `customerData: full` is too, and `connect` refuses every app (`APP_CREDENTIAL_NOT_ALLOWED`).
31
+ */
32
+ export interface PipelineDraftsModule {
33
+ /** The store's unexpired drafts, newest first. */
34
+ list(options?: ListOptions): Promise<Page<PipelineDraftSummary>>;
35
+ /**
36
+ * One draft with its connection, discovery status, schema maps, the served dependencies and their
37
+ * warnings, and the name the configure step would suggest in the store's zone. Poll it while
38
+ * `discovery.status` is `pending` or `running`.
39
+ */
40
+ get(id: string, options?: Call): Promise<PipelineDraft>;
41
+ /** Start a set-up. The schedule zone starts as the store's, and the step is `connector`. */
42
+ create(input: {
43
+ direction: PipelineDirection;
44
+ }, options?: Call): Promise<PipelineDraft>;
45
+ /**
46
+ * Change fields. `connectorType` starts the connection over (no source URL, connection,
47
+ * discovery or stock location), even for the same connector; `direction` alone moves to the
48
+ * connector step; entering `configure` with no name gives the default one. A credential is
49
+ * refused here (400): send it to {@link PipelineDraftsModule.connect}.
50
+ */
51
+ update(id: string, input: UpdatePipelineDraftInput, options?: Call): Promise<PipelineDraft>;
52
+ /**
53
+ * Create the draft's connection from its connector, source URL, throttle and legacy hosts, plus
54
+ * the `credentials` sent now: the source is probed first (a failed probe saves nothing), then
55
+ * the credentials are stored encrypted ON THE CONNECTION, never on the draft. The draft then
56
+ * owns the connection, so discarding or expiring it deletes the connection too. A previous
57
+ * connection the draft created, and its discovery, are let go.
58
+ */
59
+ connect(id: string, input: {
60
+ version: number;
61
+ credentials: Record<string, string>;
62
+ }, options?: Call): Promise<PipelineDraft>;
63
+ /**
64
+ * Use one of the store's existing connections. Discarding the draft never deletes a connection
65
+ * that existed before any draft; one another draft created and still holds is this draft's too
66
+ * (`connection.createdByDraft` says so), and the last draft to let go of it unused deletes it.
67
+ */
68
+ useConnection(id: string, input: {
69
+ version: number;
70
+ connectionId: string;
71
+ }, options?: Call): Promise<PipelineDraft>;
72
+ /** Start the discovery of an import draft's connection; poll {@link PipelineDraftsModule.get}. */
73
+ discover(id: string, input: {
74
+ version: number;
75
+ }, options?: Call): Promise<PipelineDraft>;
76
+ /** Change one schema map of the draft's discovery. */
77
+ updateSchemaMap(id: string, entityType: string, input: UpdatePipelineDraftSchemaMapInput, options?: Call): Promise<PipelineDraft>;
78
+ /**
79
+ * Save the draft as a pipeline and delete the draft; with `startRun` also start its first run.
80
+ * A run that does not start leaves the pipeline in place and answers `runError`. Takes an
81
+ * `idempotencyKey`: a commit retried after a lost answer replays the first one.
82
+ */
83
+ commit(id: string, input: {
84
+ version: number;
85
+ startRun?: boolean;
86
+ }, options?: Call): Promise<CommittedPipelineDraft>;
87
+ /**
88
+ * Delete the draft, and the connection it created with its stored password unless a pipeline
89
+ * or another draft uses it.
90
+ */
91
+ discard(id: string, options?: Call): Promise<void>;
92
+ }
93
+ /** Data pipelines (imports and exports between the store and another system). */
94
+ export interface IntegrationPipelinesModule {
95
+ drafts: PipelineDraftsModule;
96
+ /** The store's source connections. See {@link PipelineConnectionsModule}. */
97
+ connections: PipelineConnectionsModule;
98
+ /**
99
+ * The connectors this deployment offers, `coming_soon` ones included: each one's credential
100
+ * form (`credentialFields`), what its stored secrets are bound to (`credentialBinding`) and
101
+ * what it can import and export. Needs `ReadCatalog`.
102
+ *
103
+ * @effect read
104
+ */
105
+ connectors(options?: Call): Promise<PipelineConnector[]>;
106
+ /**
107
+ * What each importable entity type needs imported first, from the import writers themselves
108
+ * (the warnings' data; the words are yours).
109
+ *
110
+ * @effect read
111
+ */
112
+ importDependencies(options?: Call): Promise<ImportDependency[]>;
113
+ }
114
+ export declare function createIntegrationPipelinesModule(transport: Transport): IntegrationPipelinesModule;
@@ -0,0 +1,46 @@
1
+ import { createPage, readRestPage } from '@sixtyninecommerce/core';
2
+ import { createPipelineConnectionsModule, listPipelineConnectors, } from './connections.js';
3
+ import { PIPELINE_DRAFT_PRESERVE_KEYS, PIPELINE_DRAFT_SLOW_TIMEOUT_MS } from './pipeline-keys.js';
4
+ export { PIPELINE_DRAFT_PRESERVE_KEYS, PIPELINE_DRAFT_SLOW_TIMEOUT_MS } from './pipeline-keys.js';
5
+ const DRAFTS = '/pipelines/drafts';
6
+ const segment = (value) => encodeURIComponent(value);
7
+ export function createIntegrationPipelinesModule(transport) {
8
+ const read = (path, options) => transport.rest('plugins', { method: 'GET', path }, { ...options, preserveKeys: PIPELINE_DRAFT_PRESERVE_KEYS });
9
+ const write = (method, path, body, options, timeoutMs) => transport.rest('plugins', { method, path, body }, {
10
+ ...options,
11
+ preserveKeys: PIPELINE_DRAFT_PRESERVE_KEYS,
12
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
13
+ });
14
+ async function list(options) {
15
+ const body = await transport.rest('plugins', {
16
+ method: 'GET',
17
+ path: DRAFTS,
18
+ query: { after: options?.after, limit: options?.limit },
19
+ }, { ...options, preserveKeys: PIPELINE_DRAFT_PRESERVE_KEYS });
20
+ const { items, meta } = readRestPage(body);
21
+ return createPage(items, meta, (cursor) => list({ ...options, after: cursor }));
22
+ }
23
+ const drafts = {
24
+ list,
25
+ get: (id, options) => read(`${DRAFTS}/${segment(id)}`, options),
26
+ create: (input, options) => write('POST', DRAFTS, input, options),
27
+ update: (id, input, options) => write('PATCH', `${DRAFTS}/${segment(id)}`, input, options),
28
+ connect: (id, input, options) => write('POST', `${DRAFTS}/${segment(id)}/connection`, input, options, PIPELINE_DRAFT_SLOW_TIMEOUT_MS),
29
+ useConnection: (id, input, options) => write('POST', `${DRAFTS}/${segment(id)}/connection/existing`, input, options),
30
+ discover: (id, input, options) => write('POST', `${DRAFTS}/${segment(id)}/discover`, input, options),
31
+ updateSchemaMap: (id, entityType, input, options) => write('PATCH', `${DRAFTS}/${segment(id)}/schema-maps/${segment(entityType)}`, input, options),
32
+ commit: (id, input, options) => write('POST', `${DRAFTS}/${segment(id)}/commit`, input, options, PIPELINE_DRAFT_SLOW_TIMEOUT_MS),
33
+ async discard(id, options) {
34
+ await transport.rest('plugins', { method: 'DELETE', path: `${DRAFTS}/${segment(id)}`, expect: 'void' }, options);
35
+ },
36
+ };
37
+ return {
38
+ drafts,
39
+ connections: createPipelineConnectionsModule(transport),
40
+ connectors: (options) => listPipelineConnectors(transport, options),
41
+ async importDependencies(options) {
42
+ const body = await read('/pipelines/import-dependencies', options);
43
+ return body.data;
44
+ },
45
+ };
46
+ }
@@ -0,0 +1,322 @@
1
+ /**
2
+ * The shapes of `admin.integrations.pipelines` (headless spec §7 `pipelines.drafts`).
3
+ *
4
+ * Kept verbatim (stored data, never renamed): `triggerFilter`'s keys (reader field names such as
5
+ * `toState`), `siteAnalysis` and `publicCredentials` (the connector's own keys), and a schema
6
+ * map's `sourceSchema`, `targetSchema` and `subCounts`.
7
+ */
8
+ export type PipelineDirection = 'import' | 'export';
9
+ /** The wizard's steps before a commit; `import`/`done` come after one, when no draft exists. */
10
+ export type PipelineDraftStep = 'direction' | 'connector' | 'credentials' | 'discovery' | 'review' | 'entities' | 'trigger' | 'configure' | 'preview';
11
+ export type PipelineSyncPolicy = 'preserve_local' | 'always_source';
12
+ export type PipelineScheduleType = 'one_time' | 'daily' | 'weekly' | 'custom';
13
+ export type PipelineTriggerType = 'manual' | 'scheduled';
14
+ /** One draft in the store's list. */
15
+ export interface PipelineDraftSummary {
16
+ id: string;
17
+ direction: PipelineDirection;
18
+ step: PipelineDraftStep;
19
+ connectorType: string | null;
20
+ /** The pipeline's name, once the configure step gave it one. */
21
+ name: string | null;
22
+ connectionId: string | null;
23
+ discoveryId: string | null;
24
+ /** Send it back with the next change; a change made on an older one is refused 409. */
25
+ version: number;
26
+ /** Vendure User.id of whoever started it (an API token's own administrator for a token). */
27
+ createdByUserId: string;
28
+ updatedByUserId: string;
29
+ createdAt: string;
30
+ updatedAt: string;
31
+ /** 7 days after the last change; the draft answers 404 from then on. */
32
+ expiresAt: string;
33
+ }
34
+ /** The connection a draft holds. Never a credential: `publicCredentials` holds non-password fields only. */
35
+ export interface PipelineDraftConnection {
36
+ id: string;
37
+ name: string;
38
+ connectorType: string;
39
+ sourceUrl: string;
40
+ status: string;
41
+ /** Soft-deleted on the Connections page since the draft took it: connect again. */
42
+ removed: boolean;
43
+ /** The draft (or another draft holding it) created it, so discarding the draft deletes it. */
44
+ createdByDraft: boolean;
45
+ siteAnalysis: Record<string, unknown> | null;
46
+ publicCredentials: Record<string, string> | null;
47
+ lastTestedAt: string | null;
48
+ }
49
+ export interface PipelineDraftDiscovery {
50
+ id: string;
51
+ /** `pending` → `running` → `completed` | `failed`. Poll the draft to follow it. */
52
+ status: 'pending' | 'running' | 'completed' | 'failed';
53
+ source: string;
54
+ errorMessage: string | null;
55
+ warnings: string[];
56
+ detectedPlugins: string[];
57
+ startedAt: string | null;
58
+ completedAt: string | null;
59
+ }
60
+ export interface PipelineDraftFieldMapping {
61
+ sourceField: string;
62
+ sourcePath: string;
63
+ targetField: string;
64
+ targetPath: string;
65
+ transform: string | null;
66
+ confidence: number;
67
+ enabled: boolean;
68
+ }
69
+ export interface PipelineDraftSchemaMap {
70
+ id: string;
71
+ entityType: string;
72
+ enabled: boolean;
73
+ confidence: number;
74
+ entityCount: number;
75
+ subCounts: Record<string, number> | null;
76
+ /** As stored: `{ sourceEntityType, fields: [{ name, path, type, sampleValues, … }], notes }`. */
77
+ sourceSchema: Record<string, unknown>;
78
+ /** As stored: `{ targetEntityType, allowedTargetEntityTypes? }`. */
79
+ targetSchema: Record<string, unknown>;
80
+ fieldMappings: PipelineDraftFieldMapping[];
81
+ }
82
+ /** What an importable entity type needs imported first, from the import writers themselves. */
83
+ export interface ImportDependency {
84
+ entityType: string;
85
+ dependsOn: string[];
86
+ /** It also depends on every type in the run starting with one of these (`cms_`). */
87
+ dependsOnPrefixes: string[];
88
+ }
89
+ /** An enabled entity type whose dependencies were discovered but switched off. */
90
+ export interface ImportDependencyWarning {
91
+ entityType: string;
92
+ missing: string[];
93
+ }
94
+ /** A draft and everything the set-up screen shows, read now. */
95
+ export interface PipelineDraft extends PipelineDraftSummary {
96
+ sourceUrl: string;
97
+ requestDelayMs: number;
98
+ /** As typed: a comma-separated list, parsed when the connection is created. */
99
+ legacyAssetHosts: string;
100
+ syncPolicy: PipelineSyncPolicy;
101
+ scheduleType: PipelineScheduleType;
102
+ cronExpression: string;
103
+ /** The schedule's zone; a new draft starts with the store's. */
104
+ timezone: string;
105
+ /**
106
+ * Whether the source's prices include tax. Until the merchant sets it (`sourcePricesIncludeTaxChosen`)
107
+ * it follows what the source reports when a connection is made, and before that the store's own
108
+ * setting.
109
+ */
110
+ sourcePricesIncludeTax: boolean;
111
+ sourcePricesIncludeTaxChosen: boolean;
112
+ stockLocationId: string | null;
113
+ triggerType: PipelineTriggerType;
114
+ exportEntityTypes: string[];
115
+ triggerFilter: Record<string, string>;
116
+ connection: PipelineDraftConnection | null;
117
+ discovery: PipelineDraftDiscovery | null;
118
+ schemaMaps: PipelineDraftSchemaMap[];
119
+ dependencies: ImportDependency[];
120
+ dependencyWarnings: ImportDependencyWarning[];
121
+ /** The name the configure step would give it now, in the store's zone. */
122
+ suggestedName: string | null;
123
+ /** The store's business time zone; null when it could not be read just now. */
124
+ storeTimeZone: string | null;
125
+ }
126
+ /** A field change. `version` is the draft's current one. */
127
+ export interface UpdatePipelineDraftInput {
128
+ version: number;
129
+ direction?: PipelineDirection;
130
+ step?: PipelineDraftStep;
131
+ /** Starts the connection over, even for the same connector. */
132
+ connectorType?: string;
133
+ sourceUrl?: string;
134
+ requestDelayMs?: 50 | 100 | 200 | 300 | 500;
135
+ legacyAssetHosts?: string;
136
+ name?: string;
137
+ syncPolicy?: PipelineSyncPolicy;
138
+ scheduleType?: PipelineScheduleType;
139
+ /** A 5-part cron, or '' to clear it. */
140
+ cronExpression?: string;
141
+ timezone?: string;
142
+ sourcePricesIncludeTax?: boolean;
143
+ /** `null` clears it. */
144
+ stockLocationId?: string | null;
145
+ triggerType?: PipelineTriggerType;
146
+ exportEntityTypes?: string[];
147
+ triggerFilter?: Record<string, string>;
148
+ }
149
+ export interface UpdatePipelineDraftSchemaMapInput {
150
+ version: number;
151
+ enabled?: boolean;
152
+ fieldMappings?: PipelineDraftFieldMapping[];
153
+ /** Move a taxonomy to another target its schema map allows. */
154
+ targetEntityType?: string;
155
+ }
156
+ /** `commit`'s answer: the pipeline, and its first run when one was asked for. */
157
+ export interface CommittedPipelineDraft {
158
+ pipeline: {
159
+ id: string;
160
+ name: string;
161
+ direction: PipelineDirection;
162
+ connectionId: string;
163
+ discoveryId: string | null;
164
+ scheduleType: PipelineScheduleType;
165
+ isActive: boolean;
166
+ };
167
+ run: {
168
+ id: string;
169
+ status: string;
170
+ } | null;
171
+ /** The pipeline was saved but its first run did not start; start it from the pipeline. */
172
+ runError: {
173
+ code: string;
174
+ message: string;
175
+ } | null;
176
+ }
177
+ /** A field of a connector's credentials form, as the connector declares it. */
178
+ export interface PipelineConnectorCredentialField {
179
+ /** The key to send in `credentials`, in the connector's own spelling (`consumerKey`, `sftpHost`). */
180
+ key: string;
181
+ label: string;
182
+ /**
183
+ * `password` marks a secret: it is never read back (`publicCredentials` leaves it out), and on
184
+ * `connections.update` a blank one keeps the stored secret.
185
+ */
186
+ type: 'text' | 'password' | 'url';
187
+ placeholder: string;
188
+ required: boolean;
189
+ helpText?: string;
190
+ /** A heading the form groups the field under (`sftp`, `paths`, `edi`, `warehouse`, `sender`). */
191
+ group?: string;
192
+ }
193
+ /** One credential field that names where the connector sends its secrets. */
194
+ export interface PipelineCredentialBindingField {
195
+ key: string;
196
+ role: 'host' | 'port' | 'user';
197
+ /** The port a blank `port` field means. */
198
+ defaultPort?: number;
199
+ }
200
+ /**
201
+ * What a connection's stored secrets are bound to: its source URL (scheme, host, port and path),
202
+ * or the named credential fields (an SFTP login). A `connections.update` that moves it must carry
203
+ * every required secret afresh, or it is refused `PIPELINE_HOST_CHANGE_REQUIRES_CREDENTIALS`.
204
+ */
205
+ export type PipelineCredentialBinding = {
206
+ kind: 'source-url';
207
+ } | {
208
+ kind: 'credential-fields';
209
+ fields: PipelineCredentialBindingField[];
210
+ };
211
+ /** A connector this deployment offers (`integrations.pipelines.connectors()`). */
212
+ export interface PipelineConnector {
213
+ /** `woocommerce`, `blujay_wms`, … : a connection's `connectorType`. */
214
+ type: string;
215
+ name: string;
216
+ description: string;
217
+ logoUrl: string;
218
+ /** A `coming_soon` connector is listed but cannot be connected yet. */
219
+ status: 'active' | 'coming_soon';
220
+ credentialFields: PipelineConnectorCredentialField[];
221
+ /** Absent from a plugins service deployed before it existed; the server still refuses a move. */
222
+ credentialBinding?: PipelineCredentialBinding;
223
+ /** What an import over it can read; empty when it imports nothing. */
224
+ supportedEntityTypes: string[];
225
+ /** What an export over it can write; absent when it exports nothing. */
226
+ supportedExportEntityTypes?: string[];
227
+ /** It brings its own schema maps, so an import needs no discovery. */
228
+ fixedSchema?: boolean;
229
+ }
230
+ /** A credential the source checks apart from the main login (WooCommerce's companion plugin). */
231
+ export interface PipelineAuthCheck {
232
+ id: string;
233
+ label: string;
234
+ ok: boolean;
235
+ /** Why it failed; absent when `ok`. */
236
+ message?: string;
237
+ }
238
+ /** What a probe of the source reported (`test`, `retest`, and a connection's `siteAnalysis`). */
239
+ export interface PipelineSiteAnalysis {
240
+ platform: string;
241
+ version: string;
242
+ /**
243
+ * Records per entity type, keyed by the source's own names (a WordPress post type such as
244
+ * `product_brand` too): kept verbatim, never camelCased.
245
+ */
246
+ entityCounts: Record<string, number>;
247
+ languages: string[];
248
+ plugins: string[];
249
+ currency: string;
250
+ capabilities: string[];
251
+ authChecks?: PipelineAuthCheck[];
252
+ /** Whether the source's prices include tax; absent when the connector could not tell. */
253
+ sourcePricesIncludeTax?: boolean;
254
+ }
255
+ /** A pipeline that runs over a connection. Only the store's own are listed. */
256
+ export interface PipelineConnectionUsage {
257
+ id: string;
258
+ name: string;
259
+ direction: PipelineDirection;
260
+ isActive: boolean;
261
+ }
262
+ export type PipelineConnectionStatus = 'pending' | 'connected' | 'error';
263
+ /** The throttles a connection may wait between two requests to its source, in milliseconds. */
264
+ export type PipelineRequestDelayMs = 50 | 100 | 200 | 300 | 500;
265
+ /**
266
+ * A source connection of the store. Never a secret: `publicCredentials` holds the fields its
267
+ * connector does not mark `password`, and is absent when they cannot be read.
268
+ */
269
+ export interface PipelineConnection {
270
+ id: string;
271
+ connectorType: string;
272
+ name: string;
273
+ sourceUrl: string;
274
+ /** As of the last probe: a failed re-test sets `error`. */
275
+ status: PipelineConnectionStatus;
276
+ /** `null`: no throttle. */
277
+ requestDelayMs: number | null;
278
+ /** Old hostnames whose image URLs an import rewrites to `sourceUrl`'s host. */
279
+ legacyAssetHosts: string[] | null;
280
+ /** What the last successful probe reported; stored data, kept verbatim. */
281
+ siteAnalysis: PipelineSiteAnalysis | null;
282
+ lastTestedAt: string | null;
283
+ createdAt: string;
284
+ updatedAt: string;
285
+ publicCredentials?: Record<string, string>;
286
+ /** The pipelines that run over it; one in the list blocks `connections.delete`. */
287
+ pipelineUsage: PipelineConnectionUsage[];
288
+ }
289
+ export interface CreatePipelineConnectionInput {
290
+ /** A connector's `type` (`connectors()`). */
291
+ connectorType: string;
292
+ name: string;
293
+ /** The source's address: `https://…` for a shop, `sftp://host:port` for an SFTP connector. */
294
+ sourceUrl: string;
295
+ /** The connector's `credentialFields`, by `key`. Stored encrypted; never read back. */
296
+ credentials: Record<string, string>;
297
+ requestDelayMs?: PipelineRequestDelayMs;
298
+ legacyAssetHosts?: string[];
299
+ }
300
+ /** Every field optional: one left out stays as stored. */
301
+ export interface UpdatePipelineConnectionInput {
302
+ name?: string;
303
+ sourceUrl?: string;
304
+ /**
305
+ * MERGED over the stored set: a `password` field sent blank (or left out) keeps the stored
306
+ * secret while the connection keeps its recipient (`PipelineCredentialBinding`); a non-secret
307
+ * field sent blank is cleared.
308
+ */
309
+ credentials?: Record<string, string>;
310
+ /** `null` removes the throttle. */
311
+ requestDelayMs?: PipelineRequestDelayMs | null;
312
+ legacyAssetHosts?: string[];
313
+ }
314
+ export interface TestPipelineConnectionInput {
315
+ connectorType: string;
316
+ sourceUrl: string;
317
+ credentials: Record<string, string>;
318
+ }
319
+ export interface DetectPipelineConnectionConfigInput {
320
+ connectorType: string;
321
+ credentials: Record<string, string>;
322
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The shapes of `admin.integrations.pipelines` (headless spec §7 `pipelines.drafts`).
3
+ *
4
+ * Kept verbatim (stored data, never renamed): `triggerFilter`'s keys (reader field names such as
5
+ * `toState`), `siteAnalysis` and `publicCredentials` (the connector's own keys), and a schema
6
+ * map's `sourceSchema`, `targetSchema` and `subCounts`.
7
+ */
8
+ export {};
@@ -2,7 +2,7 @@ import { type Transport } from '@sixtyninecommerce/core';
2
2
  import type { Call } from '../types.js';
3
3
  import { type JobHandle } from './index.js';
4
4
  /**
5
- * A bulk action run (`catalog.products.bulk`, and the orders kind of a later release): one call
5
+ * A bulk action run (`catalog.products.bulk`, `orders.bulk`): one call
6
6
  * that acts on many records of the store as a job, each record through its single door and
7
7
  * reported on its own. Read back through the Admin API's `bulkActionRun`.
8
8
  */
@@ -62,4 +62,13 @@ export declare function readBulkActionRun<Action extends string>(transport: Tran
62
62
  * when waiting itself cannot go on: `JOB_WAIT_TIMEOUT`, an aborted signal, or a read refused for
63
63
  * a reason polling cannot fix.
64
64
  */
65
- export declare function bulkActionHandle<Action extends string>(transport: Transport, runId: string, options?: Call): JobHandle<BulkActionRun<Action>>;
65
+ export declare function bulkActionHandle<Action extends string, Run extends RunProgress = BulkActionRun<Action>>(transport: Transport, runId: string, options?: Call,
66
+ /** How one read is made, when the kind selects more than the shared fields (orders). */
67
+ read?: (runId: string, call: Call) => Promise<Run>): JobHandle<Run>;
68
+ /** What waiting on a run reads of it, whatever its kind. */
69
+ interface RunProgress {
70
+ status: string;
71
+ done: number;
72
+ total: number;
73
+ }
74
+ export {};
@@ -40,15 +40,14 @@ export function readBulkActionRun(transport, runId, options) {
40
40
  * when waiting itself cannot go on: `JOB_WAIT_TIMEOUT`, an aborted signal, or a read refused for
41
41
  * a reason polling cannot fix.
42
42
  */
43
- export function bulkActionHandle(transport, runId, options) {
43
+ export function bulkActionHandle(transport, runId, options,
44
+ /** How one read is made, when the kind selects more than the shared fields (orders). */
45
+ read = (id, call) => readBulkActionRun(transport, id, call)) {
44
46
  return {
45
47
  runId,
46
48
  wait(waitOptions) {
47
49
  return pollUntilTerminal({
48
- read: (signal) => readBulkActionRun(transport, runId, {
49
- ...options,
50
- ...(signal ? { signal } : {}),
51
- }),
50
+ read: (signal) => read(runId, { ...options, ...(signal ? { signal } : {}) }),
52
51
  isTerminal: (run) => TERMINAL_BULK_ACTION_STATUSES.includes(run.status),
53
52
  onTimeout: (seen) => bulkWaitTimeout(runId, seen),
54
53
  ...waitOptions,