@endora-commerce/contracts 0.100.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 (327) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/dist/actor.d.ts +79 -0
  4. package/dist/actor.d.ts.map +1 -0
  5. package/dist/actor.js +41 -0
  6. package/dist/actor.js.map +1 -0
  7. package/dist/addresses.d.ts +134 -0
  8. package/dist/addresses.d.ts.map +1 -0
  9. package/dist/addresses.js +16 -0
  10. package/dist/addresses.js.map +1 -0
  11. package/dist/admin-actions.d.ts +367 -0
  12. package/dist/admin-actions.d.ts.map +1 -0
  13. package/dist/admin-actions.js +287 -0
  14. package/dist/admin-actions.js.map +1 -0
  15. package/dist/admin-contributions.d.ts +518 -0
  16. package/dist/admin-contributions.d.ts.map +1 -0
  17. package/dist/admin-contributions.js +495 -0
  18. package/dist/admin-contributions.js.map +1 -0
  19. package/dist/admin-i18n.d.ts +135 -0
  20. package/dist/admin-i18n.d.ts.map +1 -0
  21. package/dist/admin-i18n.js +72 -0
  22. package/dist/admin-i18n.js.map +1 -0
  23. package/dist/admin-notifications.d.ts +55 -0
  24. package/dist/admin-notifications.d.ts.map +1 -0
  25. package/dist/admin-notifications.js +16 -0
  26. package/dist/admin-notifications.js.map +1 -0
  27. package/dist/admin-roles.d.ts +125 -0
  28. package/dist/admin-roles.d.ts.map +1 -0
  29. package/dist/admin-roles.js +2 -0
  30. package/dist/admin-roles.js.map +1 -0
  31. package/dist/admin-users.d.ts +178 -0
  32. package/dist/admin-users.d.ts.map +1 -0
  33. package/dist/admin-users.js +14 -0
  34. package/dist/admin-users.js.map +1 -0
  35. package/dist/admin.d.ts +243 -0
  36. package/dist/admin.d.ts.map +1 -0
  37. package/dist/admin.js +246 -0
  38. package/dist/admin.js.map +1 -0
  39. package/dist/analytics.d.ts +123 -0
  40. package/dist/analytics.d.ts.map +1 -0
  41. package/dist/analytics.js +68 -0
  42. package/dist/analytics.js.map +1 -0
  43. package/dist/api-keys.d.ts +97 -0
  44. package/dist/api-keys.d.ts.map +1 -0
  45. package/dist/api-keys.js +64 -0
  46. package/dist/api-keys.js.map +1 -0
  47. package/dist/assets-library.d.ts +684 -0
  48. package/dist/assets-library.d.ts.map +1 -0
  49. package/dist/assets-library.js +181 -0
  50. package/dist/assets-library.js.map +1 -0
  51. package/dist/audit-logs.d.ts +141 -0
  52. package/dist/audit-logs.d.ts.map +1 -0
  53. package/dist/audit-logs.js +31 -0
  54. package/dist/audit-logs.js.map +1 -0
  55. package/dist/auth.d.ts +174 -0
  56. package/dist/auth.d.ts.map +1 -0
  57. package/dist/auth.js +27 -0
  58. package/dist/auth.js.map +1 -0
  59. package/dist/blog.d.ts +669 -0
  60. package/dist/blog.d.ts.map +1 -0
  61. package/dist/blog.js +360 -0
  62. package/dist/blog.js.map +1 -0
  63. package/dist/capabilities.d.ts +40 -0
  64. package/dist/capabilities.d.ts.map +1 -0
  65. package/dist/capabilities.js +38 -0
  66. package/dist/capabilities.js.map +1 -0
  67. package/dist/carts.d.ts +1367 -0
  68. package/dist/carts.d.ts.map +1 -0
  69. package/dist/carts.js +405 -0
  70. package/dist/carts.js.map +1 -0
  71. package/dist/catalog.d.ts +2855 -0
  72. package/dist/catalog.d.ts.map +1 -0
  73. package/dist/catalog.js +1543 -0
  74. package/dist/catalog.js.map +1 -0
  75. package/dist/cms.d.ts +872 -0
  76. package/dist/cms.d.ts.map +1 -0
  77. package/dist/cms.js +468 -0
  78. package/dist/cms.js.map +1 -0
  79. package/dist/common.d.ts +82 -0
  80. package/dist/common.d.ts.map +1 -0
  81. package/dist/common.js +72 -0
  82. package/dist/common.js.map +1 -0
  83. package/dist/comparisons.d.ts +487 -0
  84. package/dist/comparisons.d.ts.map +1 -0
  85. package/dist/comparisons.js +221 -0
  86. package/dist/comparisons.js.map +1 -0
  87. package/dist/credentials.d.ts +292 -0
  88. package/dist/credentials.d.ts.map +1 -0
  89. package/dist/credentials.js +142 -0
  90. package/dist/credentials.js.map +1 -0
  91. package/dist/credit-limits.d.ts +111 -0
  92. package/dist/credit-limits.d.ts.map +1 -0
  93. package/dist/credit-limits.js +35 -0
  94. package/dist/credit-limits.js.map +1 -0
  95. package/dist/currencies.d.ts +127 -0
  96. package/dist/currencies.d.ts.map +1 -0
  97. package/dist/currencies.js +20 -0
  98. package/dist/currencies.js.map +1 -0
  99. package/dist/custom-fields.d.ts +345 -0
  100. package/dist/custom-fields.d.ts.map +1 -0
  101. package/dist/custom-fields.js +185 -0
  102. package/dist/custom-fields.js.map +1 -0
  103. package/dist/customer-accounts.d.ts +690 -0
  104. package/dist/customer-accounts.d.ts.map +1 -0
  105. package/dist/customer-accounts.js +41 -0
  106. package/dist/customer-accounts.js.map +1 -0
  107. package/dist/customers.d.ts +305 -0
  108. package/dist/customers.d.ts.map +1 -0
  109. package/dist/customers.js +158 -0
  110. package/dist/customers.js.map +1 -0
  111. package/dist/dictionary.d.ts +580 -0
  112. package/dist/dictionary.d.ts.map +1 -0
  113. package/dist/dictionary.js +297 -0
  114. package/dist/dictionary.js.map +1 -0
  115. package/dist/email-address.d.ts +62 -0
  116. package/dist/email-address.d.ts.map +1 -0
  117. package/dist/email-address.js +64 -0
  118. package/dist/email-address.js.map +1 -0
  119. package/dist/email.d.ts +175 -0
  120. package/dist/email.d.ts.map +1 -0
  121. package/dist/email.js +45 -0
  122. package/dist/email.js.map +1 -0
  123. package/dist/envelopes.d.ts +15 -0
  124. package/dist/envelopes.d.ts.map +1 -0
  125. package/dist/envelopes.js +16 -0
  126. package/dist/envelopes.js.map +1 -0
  127. package/dist/environment-inputs.d.ts +306 -0
  128. package/dist/environment-inputs.d.ts.map +1 -0
  129. package/dist/environment-inputs.js +277 -0
  130. package/dist/environment-inputs.js.map +1 -0
  131. package/dist/erp-connector.d.ts +52 -0
  132. package/dist/erp-connector.d.ts.map +1 -0
  133. package/dist/erp-connector.js +34 -0
  134. package/dist/erp-connector.js.map +1 -0
  135. package/dist/errors.d.ts +455 -0
  136. package/dist/errors.d.ts.map +1 -0
  137. package/dist/errors.js +532 -0
  138. package/dist/errors.js.map +1 -0
  139. package/dist/google-analytics.d.ts +181 -0
  140. package/dist/google-analytics.d.ts.map +1 -0
  141. package/dist/google-analytics.js +176 -0
  142. package/dist/google-analytics.js.map +1 -0
  143. package/dist/google-tag-manager.d.ts +111 -0
  144. package/dist/google-tag-manager.d.ts.map +1 -0
  145. package/dist/google-tag-manager.js +129 -0
  146. package/dist/google-tag-manager.js.map +1 -0
  147. package/dist/i18n.d.ts +69 -0
  148. package/dist/i18n.d.ts.map +1 -0
  149. package/dist/i18n.js +59 -0
  150. package/dist/i18n.js.map +1 -0
  151. package/dist/import-export.d.ts +63 -0
  152. package/dist/import-export.d.ts.map +1 -0
  153. package/dist/import-export.js +37 -0
  154. package/dist/import-export.js.map +1 -0
  155. package/dist/index.d.ts +82 -0
  156. package/dist/index.d.ts.map +1 -0
  157. package/dist/index.js +126 -0
  158. package/dist/index.js.map +1 -0
  159. package/dist/inventory.d.ts +673 -0
  160. package/dist/inventory.d.ts.map +1 -0
  161. package/dist/inventory.js +412 -0
  162. package/dist/inventory.js.map +1 -0
  163. package/dist/invoice-ledger.d.ts +366 -0
  164. package/dist/invoice-ledger.d.ts.map +1 -0
  165. package/dist/invoice-ledger.js +114 -0
  166. package/dist/invoice-ledger.js.map +1 -0
  167. package/dist/invoices.d.ts +845 -0
  168. package/dist/invoices.d.ts.map +1 -0
  169. package/dist/invoices.js +314 -0
  170. package/dist/invoices.js.map +1 -0
  171. package/dist/kernel.d.ts +49 -0
  172. package/dist/kernel.d.ts.map +1 -0
  173. package/dist/kernel.js +19 -0
  174. package/dist/kernel.js.map +1 -0
  175. package/dist/languages.d.ts +122 -0
  176. package/dist/languages.d.ts.map +1 -0
  177. package/dist/languages.js +24 -0
  178. package/dist/languages.js.map +1 -0
  179. package/dist/linkedin-ads.d.ts +167 -0
  180. package/dist/linkedin-ads.d.ts.map +1 -0
  181. package/dist/linkedin-ads.js +156 -0
  182. package/dist/linkedin-ads.js.map +1 -0
  183. package/dist/megamenu.d.ts +556 -0
  184. package/dist/megamenu.d.ts.map +1 -0
  185. package/dist/megamenu.js +186 -0
  186. package/dist/megamenu.js.map +1 -0
  187. package/dist/meta-ads.d.ts +126 -0
  188. package/dist/meta-ads.d.ts.map +1 -0
  189. package/dist/meta-ads.js +112 -0
  190. package/dist/meta-ads.js.map +1 -0
  191. package/dist/mfa.d.ts +274 -0
  192. package/dist/mfa.d.ts.map +1 -0
  193. package/dist/mfa.js +187 -0
  194. package/dist/mfa.js.map +1 -0
  195. package/dist/modules.d.ts +1706 -0
  196. package/dist/modules.d.ts.map +1 -0
  197. package/dist/modules.js +1390 -0
  198. package/dist/modules.js.map +1 -0
  199. package/dist/newsletter.d.ts +611 -0
  200. package/dist/newsletter.d.ts.map +1 -0
  201. package/dist/newsletter.js +345 -0
  202. package/dist/newsletter.js.map +1 -0
  203. package/dist/orders.d.ts +1175 -0
  204. package/dist/orders.d.ts.map +1 -0
  205. package/dist/orders.js +630 -0
  206. package/dist/orders.js.map +1 -0
  207. package/dist/organizations.d.ts +938 -0
  208. package/dist/organizations.d.ts.map +1 -0
  209. package/dist/organizations.js +418 -0
  210. package/dist/organizations.js.map +1 -0
  211. package/dist/pagination.d.ts +21 -0
  212. package/dist/pagination.d.ts.map +1 -0
  213. package/dist/pagination.js +22 -0
  214. package/dist/pagination.js.map +1 -0
  215. package/dist/payment-methods.d.ts +472 -0
  216. package/dist/payment-methods.d.ts.map +1 -0
  217. package/dist/payment-methods.js +175 -0
  218. package/dist/payment-methods.js.map +1 -0
  219. package/dist/payment-return-url.d.ts +53 -0
  220. package/dist/payment-return-url.d.ts.map +1 -0
  221. package/dist/payment-return-url.js +35 -0
  222. package/dist/payment-return-url.js.map +1 -0
  223. package/dist/payments.d.ts +386 -0
  224. package/dist/payments.d.ts.map +1 -0
  225. package/dist/payments.js +84 -0
  226. package/dist/payments.js.map +1 -0
  227. package/dist/pim-connector.d.ts +60 -0
  228. package/dist/pim-connector.d.ts.map +1 -0
  229. package/dist/pim-connector.js +43 -0
  230. package/dist/pim-connector.js.map +1 -0
  231. package/dist/pim-field-path.d.ts +6 -0
  232. package/dist/pim-field-path.d.ts.map +1 -0
  233. package/dist/pim-field-path.js +101 -0
  234. package/dist/pim-field-path.js.map +1 -0
  235. package/dist/platform-language.d.ts +20 -0
  236. package/dist/platform-language.d.ts.map +1 -0
  237. package/dist/platform-language.js +22 -0
  238. package/dist/platform-language.js.map +1 -0
  239. package/dist/price-lists.d.ts +685 -0
  240. package/dist/price-lists.d.ts.map +1 -0
  241. package/dist/price-lists.js +330 -0
  242. package/dist/price-lists.js.map +1 -0
  243. package/dist/product-feeds.d.ts +2837 -0
  244. package/dist/product-feeds.d.ts.map +1 -0
  245. package/dist/product-feeds.js +1504 -0
  246. package/dist/product-feeds.js.map +1 -0
  247. package/dist/product-scope-overrides.d.ts +134 -0
  248. package/dist/product-scope-overrides.d.ts.map +1 -0
  249. package/dist/product-scope-overrides.js +82 -0
  250. package/dist/product-scope-overrides.js.map +1 -0
  251. package/dist/product-value-resolver.d.ts +88 -0
  252. package/dist/product-value-resolver.d.ts.map +1 -0
  253. package/dist/product-value-resolver.js +128 -0
  254. package/dist/product-value-resolver.js.map +1 -0
  255. package/dist/promotions.d.ts +678 -0
  256. package/dist/promotions.d.ts.map +1 -0
  257. package/dist/promotions.js +479 -0
  258. package/dist/promotions.js.map +1 -0
  259. package/dist/prompt-actions.d.ts +582 -0
  260. package/dist/prompt-actions.d.ts.map +1 -0
  261. package/dist/prompt-actions.js +221 -0
  262. package/dist/prompt-actions.js.map +1 -0
  263. package/dist/pwa.d.ts +293 -0
  264. package/dist/pwa.d.ts.map +1 -0
  265. package/dist/pwa.js +204 -0
  266. package/dist/pwa.js.map +1 -0
  267. package/dist/quick-order.d.ts +340 -0
  268. package/dist/quick-order.d.ts.map +1 -0
  269. package/dist/quick-order.js +177 -0
  270. package/dist/quick-order.js.map +1 -0
  271. package/dist/quote-requests.d.ts +538 -0
  272. package/dist/quote-requests.d.ts.map +1 -0
  273. package/dist/quote-requests.js +308 -0
  274. package/dist/quote-requests.js.map +1 -0
  275. package/dist/returns.d.ts +774 -0
  276. package/dist/returns.d.ts.map +1 -0
  277. package/dist/returns.js +389 -0
  278. package/dist/returns.js.map +1 -0
  279. package/dist/sales-channels.d.ts +392 -0
  280. package/dist/sales-channels.d.ts.map +1 -0
  281. package/dist/sales-channels.js +285 -0
  282. package/dist/sales-channels.js.map +1 -0
  283. package/dist/scope-notice.d.ts +60 -0
  284. package/dist/scope-notice.d.ts.map +1 -0
  285. package/dist/scope-notice.js +56 -0
  286. package/dist/scope-notice.js.map +1 -0
  287. package/dist/search.d.ts +321 -0
  288. package/dist/search.d.ts.map +1 -0
  289. package/dist/search.js +160 -0
  290. package/dist/search.js.map +1 -0
  291. package/dist/seo.d.ts +113 -0
  292. package/dist/seo.d.ts.map +1 -0
  293. package/dist/seo.js +63 -0
  294. package/dist/seo.js.map +1 -0
  295. package/dist/settings.d.ts +453 -0
  296. package/dist/settings.d.ts.map +1 -0
  297. package/dist/settings.js +337 -0
  298. package/dist/settings.js.map +1 -0
  299. package/dist/shipments.d.ts +140 -0
  300. package/dist/shipments.d.ts.map +1 -0
  301. package/dist/shipments.js +14 -0
  302. package/dist/shipments.js.map +1 -0
  303. package/dist/shipping-methods.d.ts +350 -0
  304. package/dist/shipping-methods.d.ts.map +1 -0
  305. package/dist/shipping-methods.js +99 -0
  306. package/dist/shipping-methods.js.map +1 -0
  307. package/dist/shopping-lists.d.ts +122 -0
  308. package/dist/shopping-lists.d.ts.map +1 -0
  309. package/dist/shopping-lists.js +92 -0
  310. package/dist/shopping-lists.js.map +1 -0
  311. package/dist/taxes.d.ts +106 -0
  312. package/dist/taxes.d.ts.map +1 -0
  313. package/dist/taxes.js +80 -0
  314. package/dist/taxes.js.map +1 -0
  315. package/dist/text-normalization.d.ts +199 -0
  316. package/dist/text-normalization.d.ts.map +1 -0
  317. package/dist/text-normalization.js +205 -0
  318. package/dist/text-normalization.js.map +1 -0
  319. package/dist/transactional-emails.d.ts +459 -0
  320. package/dist/transactional-emails.d.ts.map +1 -0
  321. package/dist/transactional-emails.js +212 -0
  322. package/dist/transactional-emails.js.map +1 -0
  323. package/dist/webhooks.d.ts +69 -0
  324. package/dist/webhooks.d.ts.map +1 -0
  325. package/dist/webhooks.js +53 -0
  326. package/dist/webhooks.js.map +1 -0
  327. package/package.json +46 -0
@@ -0,0 +1,350 @@
1
+ import { z } from 'zod';
2
+ import type { OrderStatusOption } from './payment-methods.js';
3
+ /**
4
+ * Shipping Method adapter framework (feature 035 — Metoda Dostawy).
5
+ *
6
+ * Source-of-truth schemas for the admin-managed delivery-method entry, the
7
+ * Shipment record, and the adapter ingress, plus the behavioural
8
+ * `ShippingAdapter` contract a module implements to act as a shipping method.
9
+ * The delivery-side twin of `payment-methods.ts` (feature 034), minus the
10
+ * `kind`/`type` discriminator and `statusOnPending`: a shipping method is
11
+ * identified by its `adapter` alone, and only success/failure order statuses
12
+ * are mapped. The `price` surcharge is the existing `DeliveryMethod.cost`.
13
+ *
14
+ * The selectable Order statuses are surfaced through the same
15
+ * `OrderStatusOption` shape already exported by `payment-methods.ts`.
16
+ */
17
+ export type ShippingOrderStatusOption = OrderStatusOption;
18
+ /**
19
+ * Localised name: a non-empty record of `lang → label`. A surface in language
20
+ * `xx` uses `name[xx]` when present; otherwise the `default` key, otherwise the
21
+ * first available value (the backend name-resolver). Open record for
22
+ * compatibility with the existing locale-keyed payloads.
23
+ */
24
+ export declare const deliveryMethodNameSchema: z.ZodRecord<z.ZodString, z.ZodString>;
25
+ export type DeliveryMethodName = z.infer<typeof deliveryMethodNameSchema>;
26
+ /**
27
+ * Admin upsert body for a delivery-method entry. `cost` is the `price`
28
+ * surcharge; `adapter` defaults to `code` and `statusOn*` to the seed order
29
+ * statuses (shipped / in_fulfilment) when omitted — keeping the pre-feature-035
30
+ * payload (`{ code, name, cost, currency }`) valid while letting the richer
31
+ * admin form send the full configuration.
32
+ */
33
+ export declare const deliveryMethodUpsertSchema: z.ZodObject<{
34
+ code: z.ZodOptional<z.ZodString>;
35
+ name: z.ZodRecord<z.ZodString, z.ZodString>;
36
+ cost: z.ZodNumber;
37
+ currency: z.ZodString;
38
+ adapter: z.ZodOptional<z.ZodString>;
39
+ status: z.ZodOptional<z.ZodEnum<{
40
+ active: "active";
41
+ inactive: "inactive";
42
+ }>>;
43
+ statusOnSuccess: z.ZodOptional<z.ZodString>;
44
+ statusOnFailure: z.ZodOptional<z.ZodString>;
45
+ salesChannelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
46
+ }, z.core.$strip>;
47
+ export type DeliveryMethodUpsert = z.infer<typeof deliveryMethodUpsertSchema>;
48
+ /** Admin detail (full config) response. */
49
+ export declare const deliveryMethodAdminSchema: z.ZodObject<{
50
+ id: z.ZodString;
51
+ code: z.ZodString;
52
+ adapter: z.ZodString;
53
+ name: z.ZodRecord<z.ZodString, z.ZodString>;
54
+ cost: z.ZodObject<{
55
+ amount: z.ZodNumber;
56
+ currency: z.ZodString;
57
+ }, z.core.$strip>;
58
+ status: z.ZodEnum<{
59
+ active: "active";
60
+ inactive: "inactive";
61
+ }>;
62
+ statusOnSuccess: z.ZodString;
63
+ statusOnFailure: z.ZodString;
64
+ salesChannelIds: z.ZodArray<z.ZodString>;
65
+ rendererKey: z.ZodNullable<z.ZodString>;
66
+ }, z.core.$strip>;
67
+ export type DeliveryMethodAdmin = z.infer<typeof deliveryMethodAdminSchema>;
68
+ /** Storefront list item — what checkout needs to render an eligible method. */
69
+ export declare const deliveryMethodListItemSchema: z.ZodObject<{
70
+ id: z.ZodString;
71
+ code: z.ZodString;
72
+ adapter: z.ZodString;
73
+ name: z.ZodRecord<z.ZodString, z.ZodString>;
74
+ cost: z.ZodObject<{
75
+ amount: z.ZodNumber;
76
+ currency: z.ZodString;
77
+ }, z.core.$strip>;
78
+ status: z.ZodEnum<{
79
+ active: "active";
80
+ inactive: "inactive";
81
+ }>;
82
+ rendererKey: z.ZodNullable<z.ZodString>;
83
+ }, z.core.$strip>;
84
+ export type DeliveryMethodListItem = z.infer<typeof deliveryMethodListItemSchema>;
85
+ /**
86
+ * Shipment-process status — distinct from the mapped Order status.
87
+ *
88
+ * `pending_manual` is the state a shipment opens in when the carrier was never
89
+ * asked for it: the adapter that would have requested the label, the tracking
90
+ * number or the pickup is contributed by a module that is not present, so the
91
+ * row exists and a human has to finish it. It carries the same meaning as the
92
+ * refund settlement state of the same name (feature 046, FR-035) — deliberately
93
+ * the same word, because it is the same instruction to the same operator.
94
+ *
95
+ * It is **not** `failure`: nothing was rejected, because nothing was sent. It is
96
+ * not plain `pending` either — a `pending` shipment is waiting for a carrier
97
+ * that knows about it, and this one is waiting for a person.
98
+ */
99
+ export declare const shipmentStatusSchema: z.ZodEnum<{
100
+ success: "success";
101
+ pending: "pending";
102
+ pending_manual: "pending_manual";
103
+ failure: "failure";
104
+ }>;
105
+ export type ShipmentStatus = z.infer<typeof shipmentStatusSchema>;
106
+ /** Serialized Shipment (admin order view). */
107
+ export declare const shipmentSchema: z.ZodObject<{
108
+ id: z.ZodString;
109
+ orderId: z.ZodString;
110
+ deliveryMethodId: z.ZodString;
111
+ status: z.ZodEnum<{
112
+ success: "success";
113
+ pending: "pending";
114
+ pending_manual: "pending_manual";
115
+ failure: "failure";
116
+ }>;
117
+ externalReference: z.ZodNullable<z.ZodString>;
118
+ providerDetails: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
119
+ failureReason: z.ZodNullable<z.ZodString>;
120
+ attemptNo: z.ZodNumber;
121
+ createdAt: z.ZodString;
122
+ updatedAt: z.ZodString;
123
+ }, z.core.$strip>;
124
+ export type ShipmentDto = z.infer<typeof shipmentSchema>;
125
+ /** `receive_shipment` ingress payload (FR-022). */
126
+ export declare const receiveShipmentSchema: z.ZodObject<{
127
+ shipmentId: z.ZodOptional<z.ZodString>;
128
+ orderId: z.ZodOptional<z.ZodString>;
129
+ externalReference: z.ZodOptional<z.ZodNullable<z.ZodString>>;
130
+ outcome: z.ZodEnum<{
131
+ success: "success";
132
+ failure: "failure";
133
+ }>;
134
+ failureReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
135
+ providerDetails: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
136
+ }, z.core.$strip>;
137
+ export type ReceiveShipment = z.infer<typeof receiveShipmentSchema>;
138
+ /**
139
+ * Container name: `receiveShipmentHandler`. Owner: `shipments`.
140
+ *
141
+ * Carrier callback / tracking-poll ingress: apply a success or failure outcome
142
+ * to a shipment attempt and ask the order lifecycle for the configured move.
143
+ *
144
+ * **Owner off:** fails closed — a caller gets the 503 `MODULE_DISABLED`
145
+ * envelope. Tracking workers must rethrow `ModuleDisabledError` from any
146
+ * per-item `catch` that records transport failures.
147
+ */
148
+ export interface ReceiveShipmentPort {
149
+ receive(input: ReceiveShipment): Promise<{
150
+ shipmentId: string;
151
+ status: string;
152
+ orderStatus: string | null;
153
+ idempotent: boolean;
154
+ }>;
155
+ }
156
+ export type ShippingSurface = 'storefront' | 'admin' | 'api';
157
+ export interface ShippingEligibilityContext {
158
+ deliveryMethod: DeliveryMethodAdmin;
159
+ /**
160
+ * The channel the buyer is on, or `null` when none is resolved. Widened from
161
+ * `string` (issue #103) for the reason spelled out on
162
+ * `PaymentEligibilityContext.salesChannelId`: the empty-string stand-in it
163
+ * forced is rejected by the settings seam guard, so an adapter reading its own
164
+ * configuration answered "not eligible". `null` is the platform-wide tier.
165
+ */
166
+ salesChannelId: string | null;
167
+ organizationId: string | null;
168
+ customerAccountId: string | null;
169
+ surface: ShippingSurface;
170
+ /** Present at storefront checkout; opaque to the contract. */
171
+ cartSnapshot?: unknown;
172
+ }
173
+ /** `order_created` — fired in placeOrder after the Order exists. */
174
+ export interface OrderCreatedContext {
175
+ orderId: string;
176
+ deliveryMethodId: string;
177
+ salesChannelId: string;
178
+ organizationId: string | null;
179
+ /**
180
+ * Adapter-specific shipping envelope from place-order (feature 068).
181
+ * Passed from the in-transaction Order entity — adapters must NOT re-fetch
182
+ * the order on a separate EntityManager (uncommitted row is invisible).
183
+ */
184
+ shippingAdapterData?: Record<string, unknown> | null;
185
+ /** Delivery (or billing fallback) phone from the in-transaction order snapshot. */
186
+ deliveryPhone?: string | null;
187
+ /** Placing customer's email when available (locker ShipX requires it). */
188
+ customerEmail?: string | null;
189
+ }
190
+ /** `shipment_created` — fired after a pending Shipment row is opened. */
191
+ export interface ShipmentCreatedContext {
192
+ orderId: string;
193
+ shipmentId: string;
194
+ deliveryMethodId: string;
195
+ attemptNo: number;
196
+ }
197
+ export type StartShipmentResult = {
198
+ kind: 'pending';
199
+ /** Carrier reference written onto the Shipment in the same create transaction. */
200
+ externalReference?: string | null;
201
+ providerDetails?: Record<string, unknown>;
202
+ } | {
203
+ kind: 'generated';
204
+ trackingNumber?: string;
205
+ externalReference?: string | null;
206
+ providerDetails?: Record<string, unknown>;
207
+ } | {
208
+ kind: 'none';
209
+ };
210
+ export interface ReceiveShipmentContext {
211
+ orderId: string;
212
+ shipmentId: string;
213
+ externalReference?: string | null;
214
+ providerDetails?: Record<string, unknown>;
215
+ }
216
+ export type ShipmentOutcome = {
217
+ result: 'success';
218
+ externalReference?: string | null;
219
+ providerDetails?: Record<string, unknown>;
220
+ } | {
221
+ result: 'failure';
222
+ failureReason: string;
223
+ providerDetails?: Record<string, unknown>;
224
+ };
225
+ export interface ShippingAdapter {
226
+ readonly adapterKey: string;
227
+ validateUseOnStorefront(ctx: ShippingEligibilityContext): Promise<boolean>;
228
+ validateUseOnAdmin(ctx: ShippingEligibilityContext): Promise<boolean>;
229
+ validateUseInApi(ctx: ShippingEligibilityContext): Promise<boolean>;
230
+ /** `order_created`; default no-op (MUST NOT open a Shipment). */
231
+ onOrderCreated(ctx: OrderCreatedContext): Promise<void>;
232
+ /** `shipment_created`; begin generation, return the next action. */
233
+ onShipmentCreated(ctx: ShipmentCreatedContext): Promise<StartShipmentResult>;
234
+ /** `receive_shipment`; map the ingress to an outcome. */
235
+ onReceiveShipment(ctx: ReceiveShipmentContext): Promise<ShipmentOutcome>;
236
+ /**
237
+ * When true, the platform may call `createShipment` after `payment.received.v1`.
238
+ * Optional — absent / false for built-in offline adapters. Carrier modules
239
+ * (InPost, future DHL, …) opt in via their own Settings flag.
240
+ */
241
+ shouldAutoCreateOnPaid?(): Promise<boolean>;
242
+ /** Optional renderer keys; absent ⇒ the default fallback renderer is used. */
243
+ readonly renderers?: {
244
+ storefront?: string;
245
+ admin?: string;
246
+ email?: string;
247
+ };
248
+ }
249
+ /**
250
+ * A delivery method as it crosses a module boundary — a plain shape, never the
251
+ * ORM entity (FR-011).
252
+ *
253
+ * `cost` stays a decimal string: it lands verbatim in an order's
254
+ * `deliveryMethodSnapshot`, and a `number` cannot round-trip it. The two
255
+ * `statusOn…` fields name **order statuses**, which are admin-configurable, so
256
+ * they are `string` rather than a union.
257
+ */
258
+ export interface DeliveryMethodRecord {
259
+ id: string;
260
+ code: string;
261
+ name: Record<string, string>;
262
+ cost: string;
263
+ currency: string;
264
+ status: 'active' | 'inactive';
265
+ /** The adapter registry key this method ships through; `''` for none. */
266
+ adapter: string;
267
+ statusOnSuccess: string;
268
+ statusOnFailure: string;
269
+ createdAt: Date;
270
+ updatedAt: Date;
271
+ }
272
+ /**
273
+ * Container name: `deliveryMethodReadPort`. Owner: `delivery_methods`.
274
+ *
275
+ * Five inbound sites read the entity: `orders` resolving the method at
276
+ * placement, `shipments` resolving it at dispatch, `quick_order` resolving a
277
+ * buyer's default, and the dev seed.
278
+ *
279
+ * `listActive` is separate from `listAll` for the reason its payment twin
280
+ * gives: a catalogue read wants active methods, a settlement of an order
281
+ * placed earlier wants any, or the order stops being explicable the day an
282
+ * operator retires a method.
283
+ *
284
+ * **Owner off:** the seam fails closed — resolving this port throws
285
+ * `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`, so nothing
286
+ * half-executes. Whether `delivery_methods` has an off state at all is its manifest's
287
+ * `activation` to say, not this line's: a module declaring
288
+ * `nonDeactivatable` never enters one.
289
+ */
290
+ export interface DeliveryMethodReadPort {
291
+ findById(id: string): Promise<DeliveryMethodRecord | null>;
292
+ findByIds(ids: readonly string[]): Promise<DeliveryMethodRecord[]>;
293
+ findByCode(code: string): Promise<DeliveryMethodRecord | null>;
294
+ /** Every method, ordered by code. */
295
+ listAll(): Promise<DeliveryMethodRecord[]>;
296
+ /** Only `status === 'active'`, ordered by code. */
297
+ listActive(): Promise<DeliveryMethodRecord[]>;
298
+ }
299
+ /**
300
+ * Container name: `shippingAdapterRegistry`. Owner: `delivery_methods`.
301
+ *
302
+ * A **contribution seam**, the delivery-side twin of
303
+ * `PaymentAdapterRegistryPort`: a module that ships parcels registers its
304
+ * adapter from its boot hook, and this module's catalogue reads the table.
305
+ * Every edge into it classifies as `contributes`, and publishing the shape
306
+ * must not change that.
307
+ *
308
+ * `register` names its contributor, and `isAvailable` / `get` / `resolve` /
309
+ * `list` filter on that name's effective state, while `entry`, `ownerOf` and
310
+ * `listAll` deliberately do not — an admin screen has to keep showing a method
311
+ * *and* the reason it is unavailable.
312
+ *
313
+ * **Owner off:** nothing throws here. This is a **contribution seam**, a plain
314
+ * `di.register` rather than a `providePort`, so a push still lands and
315
+ * `delivery_methods` filters by contributor when it enumerates. Converting it to
316
+ * `providePort` would move every edge into it from `contributes` to
317
+ * `fails-closed` in the deactivation-consequence ledger, and change the
318
+ * sentence the operator's confirmation dialog renders.
319
+ */
320
+ export interface ShippingAdapterRegistryPort {
321
+ register(adapter: ShippingAdapter, module: string): void;
322
+ unregister(adapterKey: string): void;
323
+ /** Registered at all, presence-blind. */
324
+ isRegistered(adapterKey: string): boolean;
325
+ /** Registered **and** its owning module effectively present. */
326
+ isAvailable(adapterKey: string): boolean;
327
+ /** The adapter, or `undefined` when unregistered or its owner is absent. */
328
+ get(adapterKey: string): ShippingAdapter | undefined;
329
+ /** Like {@link get}, but throws rather than answering `undefined`. */
330
+ resolve(adapterKey: string): ShippingAdapter;
331
+ /** Adapter keys whose owner is present, in registration order. */
332
+ list(): string[];
333
+ /** Every registered adapter key, presence-blind. */
334
+ listAll(): string[];
335
+ /** Which module contributed the key, or `null` when nobody did. */
336
+ ownerOf(adapterKey: string): string | null;
337
+ /**
338
+ * The module that would have handled this shipment but is not present, or
339
+ * `null` when the adapter is available or was never contributed.
340
+ *
341
+ * The one reader that answers the *question* rather than exposing the table,
342
+ * and the reason it exists: `get()` collapses "nobody ever contributed this
343
+ * key" and "its contributor is switched off" into one `undefined`, and those
344
+ * are two different situations for the operator — the second one names a
345
+ * module they can switch back on. The payment twin's `absentOwnerFor`
346
+ * (D-71) is the same reader for the same reason.
347
+ */
348
+ absentOwnerFor(adapterKey: string): string | null;
349
+ }
350
+ //# sourceMappingURL=shipping-methods.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-methods.d.ts","sourceRoot":"","sources":["../src/shipping-methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,uCAEuD,CAAC;AAC7F,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;iBAUrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,2CAA2C;AAC3C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;iBAWpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;A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,CAAC;IACrD,sEAAsE;IACtE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CAAC;IAC7C,kEAAkE;IAClE,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,oDAAoD;IACpD,OAAO,IAAI,MAAM,EAAE,CAAC;IACpB,mEAAmE;IACnE,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3C;;;;;;;;;;OAUG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACnD"}
@@ -0,0 +1,99 @@
1
+ import { z } from 'zod';
2
+ import { uuidSchema } from './common.js';
3
+ /**
4
+ * Localised name: a non-empty record of `lang → label`. A surface in language
5
+ * `xx` uses `name[xx]` when present; otherwise the `default` key, otherwise the
6
+ * first available value (the backend name-resolver). Open record for
7
+ * compatibility with the existing locale-keyed payloads.
8
+ */
9
+ export const deliveryMethodNameSchema = z
10
+ .record(z.string(), z.string().min(1))
11
+ .refine((r) => Object.keys(r).length > 0, { message: 'name requires at least one entry' });
12
+ /**
13
+ * Admin upsert body for a delivery-method entry. `cost` is the `price`
14
+ * surcharge; `adapter` defaults to `code` and `statusOn*` to the seed order
15
+ * statuses (shipped / in_fulfilment) when omitted — keeping the pre-feature-035
16
+ * payload (`{ code, name, cost, currency }`) valid while letting the richer
17
+ * admin form send the full configuration.
18
+ */
19
+ export const deliveryMethodUpsertSchema = z.object({
20
+ code: z.string().min(1).max(64).optional(),
21
+ name: deliveryMethodNameSchema,
22
+ cost: z.number().finite().nonnegative(),
23
+ currency: z.string().length(3),
24
+ adapter: z.string().min(1).max(64).optional(),
25
+ status: z.enum(['active', 'inactive']).optional(),
26
+ statusOnSuccess: z.string().min(1).max(64).optional(),
27
+ statusOnFailure: z.string().min(1).max(64).optional(),
28
+ salesChannelIds: z.array(uuidSchema).optional(),
29
+ });
30
+ /** Admin detail (full config) response. */
31
+ export const deliveryMethodAdminSchema = z.object({
32
+ id: uuidSchema,
33
+ code: z.string(),
34
+ adapter: z.string(),
35
+ name: deliveryMethodNameSchema,
36
+ cost: z.object({ amount: z.number(), currency: z.string() }),
37
+ status: z.enum(['active', 'inactive']),
38
+ statusOnSuccess: z.string(),
39
+ statusOnFailure: z.string(),
40
+ salesChannelIds: z.array(uuidSchema),
41
+ rendererKey: z.string().nullable(),
42
+ });
43
+ /** Storefront list item — what checkout needs to render an eligible method. */
44
+ export const deliveryMethodListItemSchema = z.object({
45
+ id: uuidSchema,
46
+ code: z.string(),
47
+ adapter: z.string(),
48
+ name: deliveryMethodNameSchema,
49
+ cost: z.object({ amount: z.number(), currency: z.string() }),
50
+ status: z.enum(['active', 'inactive']),
51
+ rendererKey: z.string().nullable(),
52
+ });
53
+ /**
54
+ * Shipment-process status — distinct from the mapped Order status.
55
+ *
56
+ * `pending_manual` is the state a shipment opens in when the carrier was never
57
+ * asked for it: the adapter that would have requested the label, the tracking
58
+ * number or the pickup is contributed by a module that is not present, so the
59
+ * row exists and a human has to finish it. It carries the same meaning as the
60
+ * refund settlement state of the same name (feature 046, FR-035) — deliberately
61
+ * the same word, because it is the same instruction to the same operator.
62
+ *
63
+ * It is **not** `failure`: nothing was rejected, because nothing was sent. It is
64
+ * not plain `pending` either — a `pending` shipment is waiting for a carrier
65
+ * that knows about it, and this one is waiting for a person.
66
+ */
67
+ export const shipmentStatusSchema = z.enum([
68
+ 'pending',
69
+ 'pending_manual',
70
+ 'success',
71
+ 'failure',
72
+ ]);
73
+ /** Serialized Shipment (admin order view). */
74
+ export const shipmentSchema = z.object({
75
+ id: uuidSchema,
76
+ orderId: uuidSchema,
77
+ deliveryMethodId: uuidSchema,
78
+ status: shipmentStatusSchema,
79
+ externalReference: z.string().nullable(),
80
+ providerDetails: z.record(z.string(), z.unknown()).nullable(),
81
+ failureReason: z.string().nullable(),
82
+ attemptNo: z.number().int(),
83
+ createdAt: z.string(),
84
+ updatedAt: z.string(),
85
+ });
86
+ /** `receive_shipment` ingress payload (FR-022). */
87
+ export const receiveShipmentSchema = z
88
+ .object({
89
+ shipmentId: uuidSchema.optional(),
90
+ orderId: uuidSchema.optional(),
91
+ externalReference: z.string().max(255).nullish(),
92
+ outcome: z.enum(['success', 'failure']),
93
+ failureReason: z.string().max(2000).nullish(),
94
+ providerDetails: z.record(z.string(), z.unknown()).optional(),
95
+ })
96
+ .refine((d) => Boolean(d.shipmentId) || Boolean(d.orderId && d.externalReference), {
97
+ message: 'shipmentId or (orderId + externalReference) is required',
98
+ });
99
+ //# sourceMappingURL=shipping-methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-methods.js","sourceRoot":"","sources":["../src/shipping-methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoBzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACrC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC,CAAC;AAG7F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;IACvC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAA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AC,CAAC;AAGH,mDAAmD;AACnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;IACjC,OAAO,EAAE,UAAU,CAAC,QAAQ,EAAE;IAC9B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE;IAChD,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE;IAC7C,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC9D,CAAC;KACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,iBAAiB,CAAC,EAAE;IACjF,OAAO,EAAE,yDAAyD;CACnE,CAAC,CAAC"}
@@ -0,0 +1,122 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Shopping list contracts (T202 / FR-031..FR-033).
4
+ *
5
+ * A shopping list is a per-customer, named collection of (product, variant?, quantity)
6
+ * rows with optional notes. Two terminal actions:
7
+ * - convertToCart — adds the (selected or all) items to the customer's active cart;
8
+ * archived products are skipped and reported.
9
+ * - convertToRfq — adds the (selected or all) items to the customer's draft RFQ;
10
+ * same skip-and-report behaviour.
11
+ *
12
+ * Lists are private to the (customer, organization) pair today; sharing within an
13
+ * organization is intentionally out of scope for the MVP — the entity has no
14
+ * `isShared` column yet to keep the surface narrow.
15
+ */
16
+ export declare const shoppingListItemSchema: z.ZodObject<{
17
+ id: z.ZodString;
18
+ shoppingListId: z.ZodString;
19
+ productId: z.ZodString;
20
+ variantId: z.ZodNullable<z.ZodString>;
21
+ quantity: z.ZodNumber;
22
+ note: z.ZodNullable<z.ZodString>;
23
+ createdAt: z.ZodString;
24
+ updatedAt: z.ZodString;
25
+ }, z.core.$strip>;
26
+ export type ShoppingListItem = z.infer<typeof shoppingListItemSchema>;
27
+ export declare const shoppingListSchema: z.ZodObject<{
28
+ id: z.ZodString;
29
+ organizationId: z.ZodString;
30
+ customerAccountId: z.ZodString;
31
+ name: z.ZodString;
32
+ isDefault: z.ZodBoolean;
33
+ items: z.ZodArray<z.ZodObject<{
34
+ id: z.ZodString;
35
+ shoppingListId: z.ZodString;
36
+ productId: z.ZodString;
37
+ variantId: z.ZodNullable<z.ZodString>;
38
+ quantity: z.ZodNumber;
39
+ note: z.ZodNullable<z.ZodString>;
40
+ createdAt: z.ZodString;
41
+ updatedAt: z.ZodString;
42
+ }, z.core.$strip>>;
43
+ createdAt: z.ZodString;
44
+ updatedAt: z.ZodString;
45
+ }, z.core.$strip>;
46
+ export type ShoppingList = z.infer<typeof shoppingListSchema>;
47
+ /** Lightweight default-list view for the storefront header heart badge. */
48
+ export declare const defaultShoppingListSummarySchema: z.ZodObject<{
49
+ id: z.ZodString;
50
+ name: z.ZodString;
51
+ itemCount: z.ZodNumber;
52
+ }, z.core.$strip>;
53
+ export type DefaultShoppingListSummary = z.infer<typeof defaultShoppingListSummarySchema>;
54
+ export declare const createShoppingListRequestSchema: z.ZodObject<{
55
+ name: z.ZodString;
56
+ }, z.core.$strip>;
57
+ export type CreateShoppingListRequest = z.infer<typeof createShoppingListRequestSchema>;
58
+ export declare const renameShoppingListRequestSchema: z.ZodObject<{
59
+ name: z.ZodString;
60
+ }, z.core.$strict>;
61
+ export type RenameShoppingListRequest = z.infer<typeof renameShoppingListRequestSchema>;
62
+ export declare const addShoppingListItemRequestSchema: z.ZodObject<{
63
+ productId: z.ZodString;
64
+ variantId: z.ZodOptional<z.ZodString>;
65
+ quantity: z.ZodNumber;
66
+ note: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strip>;
68
+ export type AddShoppingListItemRequest = z.infer<typeof addShoppingListItemRequestSchema>;
69
+ export declare const updateShoppingListItemRequestSchema: z.ZodObject<{
70
+ quantity: z.ZodOptional<z.ZodNumber>;
71
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ }, z.core.$strict>;
73
+ export type UpdateShoppingListItemRequest = z.infer<typeof updateShoppingListItemRequestSchema>;
74
+ /**
75
+ * The convert request optionally narrows by item id; an empty (or missing)
76
+ * `itemIds` array means "convert every item on the list".
77
+ */
78
+ export declare const convertShoppingListRequestSchema: z.ZodObject<{
79
+ itemIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
80
+ }, z.core.$strict>;
81
+ export type ConvertShoppingListRequest = z.infer<typeof convertShoppingListRequestSchema>;
82
+ /** Per-item skip note returned when conversion encounters an archived product. */
83
+ export declare const conversionSkipSchema: z.ZodObject<{
84
+ itemId: z.ZodString;
85
+ productId: z.ZodString;
86
+ reason: z.ZodEnum<{
87
+ product_not_found: "product_not_found";
88
+ product_archived: "product_archived";
89
+ variant_unavailable: "variant_unavailable";
90
+ }>;
91
+ }, z.core.$strip>;
92
+ export type ConversionSkip = z.infer<typeof conversionSkipSchema>;
93
+ export declare const convertToCartResponseSchema: z.ZodObject<{
94
+ shoppingListId: z.ZodString;
95
+ added: z.ZodNumber;
96
+ skipped: z.ZodArray<z.ZodObject<{
97
+ itemId: z.ZodString;
98
+ productId: z.ZodString;
99
+ reason: z.ZodEnum<{
100
+ product_not_found: "product_not_found";
101
+ product_archived: "product_archived";
102
+ variant_unavailable: "variant_unavailable";
103
+ }>;
104
+ }, z.core.$strip>>;
105
+ }, z.core.$strip>;
106
+ export type ConvertToCartResponse = z.infer<typeof convertToCartResponseSchema>;
107
+ export declare const convertToRfqResponseSchema: z.ZodObject<{
108
+ shoppingListId: z.ZodString;
109
+ rfqId: z.ZodString;
110
+ added: z.ZodNumber;
111
+ skipped: z.ZodArray<z.ZodObject<{
112
+ itemId: z.ZodString;
113
+ productId: z.ZodString;
114
+ reason: z.ZodEnum<{
115
+ product_not_found: "product_not_found";
116
+ product_archived: "product_archived";
117
+ variant_unavailable: "variant_unavailable";
118
+ }>;
119
+ }, z.core.$strip>>;
120
+ }, z.core.$strip>;
121
+ export type ConvertToRfqResponse = z.infer<typeof convertToRfqResponseSchema>;
122
+ //# sourceMappingURL=shopping-lists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopping-lists.d.ts","sourceRoot":"","sources":["../src/shopping-lists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;iBASjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;iBAU7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,2EAA2E;AAC3E,eAAO,MAAM,gCAAgC;;;;iBAI3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAI1F,eAAO,MAAM,+BAA+B;;iBAE1C,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,+BAA+B;;kBAIjC,CAAC;AACZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,gCAAgC;;;;;iBAK3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAg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