@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,53 @@
1
+ /**
2
+ * Where a payment gateway hands the buyer back (issues #274, #287).
3
+ *
4
+ * Issue #274 moved all four gateways off `/checkout/*` and onto the order's
5
+ * own page, on the ground that every `/checkout/*` route is a **placement**
6
+ * surface and returning a buyer whose order already exists to one is how a
7
+ * shop gets a second order for the same goods. The first half of that stands;
8
+ * the destination does not. The owner ruled that **a correct payment lands on
9
+ * the success page and a failed one on the failure page**, and that the pages
10
+ * are to be corrected rather than the routing.
11
+ *
12
+ * PayU's `continueUrl` and Autopay's `ReturnURL` are one URL for every
13
+ * outcome, so that ruling cannot be expressed in gateway configuration. So
14
+ * every gateway hook — the two that discriminate and the two that cannot —
15
+ * points here, at a landing that places nothing: it reads the order's own
16
+ * payment state and forwards to success, to failure, or to a wait while the
17
+ * gateway's confirmation is still in flight. One behaviour, not two.
18
+ *
19
+ * Kept here rather than four times over because the rule is the platform's,
20
+ * not any one gateway's, and `check:module-boundary` (rightly) forbids the
21
+ * gateway modules from sharing it between themselves.
22
+ */
23
+ /**
24
+ * What the gateway said as it handed the buyer back.
25
+ *
26
+ * - `returned` — the gateway sent the buyer back and did not say how it went
27
+ * (PayU `continueUrl`, Autopay `ReturnURL`), or it says the payment went
28
+ * through (Stripe `success_url`, TPay `successUrl`) — which is a claim the
29
+ * platform will not take from a URL, since the same URL fires a purchase
30
+ * conversion and a buyer can replay it. The settlement notification is the
31
+ * authority, and it may not have arrived yet.
32
+ * - `cancelled` — the buyer left the gateway without paying (Stripe
33
+ * `cancel_url` fires on *back*, not on a decline). Nothing was charged and
34
+ * the order is waiting to be paid.
35
+ * - `failed` — the gateway reported the attempt as unsuccessful (TPay
36
+ * `errorUrl`).
37
+ *
38
+ * The landing trusts this **downwards only**: `failed` and `cancelled` show
39
+ * the failure page before our own notification lands, which costs nothing
40
+ * because that page only offers to pay the same order again and re-reads the
41
+ * order every time. No value here can produce a success page.
42
+ */
43
+ export type PaymentReturnOutcome = 'returned' | 'cancelled' | 'failed';
44
+ /**
45
+ * Build the post-payment landing for `orderId`:
46
+ * `/checkout/return?id=<orderId>&outcome=<outcome>`.
47
+ *
48
+ * The outcome is a hint for the landing's decision, never the payment's
49
+ * status — a gateway's return URL is a browser redirect the buyer can replay,
50
+ * so the order's own `paymentStatus` stays the authority.
51
+ */
52
+ export declare function storefrontPaymentReturnUrl(storefrontBaseUrl: string, orderId: string, outcome: PaymentReturnOutcome): string;
53
+ //# sourceMappingURL=payment-return-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-return-url.d.ts","sourceRoot":"","sources":["../src/payment-return-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEvE;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CAGR"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Where a payment gateway hands the buyer back (issues #274, #287).
3
+ *
4
+ * Issue #274 moved all four gateways off `/checkout/*` and onto the order's
5
+ * own page, on the ground that every `/checkout/*` route is a **placement**
6
+ * surface and returning a buyer whose order already exists to one is how a
7
+ * shop gets a second order for the same goods. The first half of that stands;
8
+ * the destination does not. The owner ruled that **a correct payment lands on
9
+ * the success page and a failed one on the failure page**, and that the pages
10
+ * are to be corrected rather than the routing.
11
+ *
12
+ * PayU's `continueUrl` and Autopay's `ReturnURL` are one URL for every
13
+ * outcome, so that ruling cannot be expressed in gateway configuration. So
14
+ * every gateway hook — the two that discriminate and the two that cannot —
15
+ * points here, at a landing that places nothing: it reads the order's own
16
+ * payment state and forwards to success, to failure, or to a wait while the
17
+ * gateway's confirmation is still in flight. One behaviour, not two.
18
+ *
19
+ * Kept here rather than four times over because the rule is the platform's,
20
+ * not any one gateway's, and `check:module-boundary` (rightly) forbids the
21
+ * gateway modules from sharing it between themselves.
22
+ */
23
+ /**
24
+ * Build the post-payment landing for `orderId`:
25
+ * `/checkout/return?id=<orderId>&outcome=<outcome>`.
26
+ *
27
+ * The outcome is a hint for the landing's decision, never the payment's
28
+ * status — a gateway's return URL is a browser redirect the buyer can replay,
29
+ * so the order's own `paymentStatus` stays the authority.
30
+ */
31
+ export function storefrontPaymentReturnUrl(storefrontBaseUrl, orderId, outcome) {
32
+ const base = storefrontBaseUrl.replace(/\/+$/, '');
33
+ return `${base}/checkout/return?id=${encodeURIComponent(orderId)}&outcome=${outcome}`;
34
+ }
35
+ //# sourceMappingURL=payment-return-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-return-url.js","sourceRoot":"","sources":["../src/payment-return-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAwBH;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,iBAAyB,EACzB,OAAe,EACf,OAA6B;IAE7B,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACnD,OAAO,GAAG,IAAI,uBAAuB,kBAAkB,CAAC,OAAO,CAAC,YAAY,OAAO,EAAE,CAAC;AACxF,CAAC"}
@@ -0,0 +1,386 @@
1
+ import { z } from 'zod';
2
+ import type { ReceivePayment } from './payment-methods.js';
3
+ import type { PaymentRefundInput, PaymentRefundResult } from './returns.js';
4
+ /**
5
+ * Payments (FR-072). Drivers: bank_transfer, pickup, credit_limit, gateway.
6
+ * Driver-specific NextAction payloads live in orders.ts (the Place Order
7
+ * response body).
8
+ */
9
+ export declare const paymentMethodKindSchema: z.ZodEnum<{
10
+ bank_transfer: "bank_transfer";
11
+ pickup: "pickup";
12
+ credit_limit: "credit_limit";
13
+ gateway: "gateway";
14
+ }>;
15
+ export type PaymentMethodKind = z.infer<typeof paymentMethodKindSchema>;
16
+ export declare const paymentMethodSchema: z.ZodObject<{
17
+ id: z.ZodString;
18
+ code: z.ZodString;
19
+ name: z.ZodString;
20
+ kind: z.ZodEnum<{
21
+ bank_transfer: "bank_transfer";
22
+ pickup: "pickup";
23
+ credit_limit: "credit_limit";
24
+ gateway: "gateway";
25
+ }>;
26
+ status: z.ZodEnum<{
27
+ active: "active";
28
+ inactive: "inactive";
29
+ }>;
30
+ }, z.core.$strip>;
31
+ export type PaymentMethod = z.infer<typeof paymentMethodSchema>;
32
+ export declare const paymentSchema: z.ZodObject<{
33
+ id: z.ZodString;
34
+ orderId: z.ZodString;
35
+ paymentMethodId: z.ZodString;
36
+ status: z.ZodEnum<{
37
+ paid: "paid";
38
+ awaiting_payment: "awaiting_payment";
39
+ failed: "failed";
40
+ deferred: "deferred";
41
+ refunded: "refunded";
42
+ }>;
43
+ amount: z.ZodNumber;
44
+ currency: z.ZodString;
45
+ paidAt: z.ZodNullable<z.ZodString>;
46
+ externalReference: z.ZodNullable<z.ZodString>;
47
+ providerDetails: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
48
+ failureReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ attemptNo: z.ZodDefault<z.ZodNumber>;
50
+ }, z.core.$strip>;
51
+ export type Payment = z.infer<typeof paymentSchema>;
52
+ /**
53
+ * What a buyer is told to do next after asking to pay an unpaid order again
54
+ * (issue #264). The three kinds are the `StartPaymentResult` a payment adapter
55
+ * returns, carried out to the storefront: send the buyer to the gateway, show
56
+ * them the transfer details again, or tell them there is nothing to do here.
57
+ */
58
+ export declare const paymentRetryNextActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
59
+ kind: z.ZodLiteral<"none">;
60
+ }, z.core.$strip>, z.ZodObject<{
61
+ kind: z.ZodLiteral<"redirect">;
62
+ url: z.ZodString;
63
+ }, z.core.$strip>, z.ZodObject<{
64
+ kind: z.ZodLiteral<"awaiting_transfer">;
65
+ iban: z.ZodNullable<z.ZodString>;
66
+ reference: z.ZodString;
67
+ }, z.core.$strip>], "kind">;
68
+ export type PaymentRetryNextAction = z.infer<typeof paymentRetryNextActionSchema>;
69
+ /**
70
+ * The reply to `POST /api/v1/orders/:orderId/payments/retry` (issue #264).
71
+ *
72
+ * `opened` is the difference between the two things the buyer's click can
73
+ * mean, and the storefront routes on it:
74
+ *
75
+ * - `true` — the previous attempt had failed, so attempt `attemptNo` was
76
+ * opened and its provider session started. `nextAction` is that
77
+ * session.
78
+ * - `false` — an attempt was already open (a double-click, a reload, a buyer
79
+ * coming back to a payment they abandoned). Nothing was opened and
80
+ * no provider was contacted, so `nextAction` is `none` and the
81
+ * buyer belongs on the existing payment step for that attempt.
82
+ *
83
+ * That split is what makes the endpoint idempotent at the provider: one click
84
+ * is one provider object, whatever the buyer does to the button. It matters
85
+ * concretely rather than tidily — PayU keys its order on `extOrderId`, which is
86
+ * this platform's payment id, and a second create against a live attempt would
87
+ * be a duplicate `extOrderId` at the POS.
88
+ */
89
+ export declare const paymentRetryResultSchema: z.ZodObject<{
90
+ paymentId: z.ZodString;
91
+ attemptNo: z.ZodNumber;
92
+ opened: z.ZodBoolean;
93
+ nextAction: z.ZodDiscriminatedUnion<[z.ZodObject<{
94
+ kind: z.ZodLiteral<"none">;
95
+ }, z.core.$strip>, z.ZodObject<{
96
+ kind: z.ZodLiteral<"redirect">;
97
+ url: z.ZodString;
98
+ }, z.core.$strip>, z.ZodObject<{
99
+ kind: z.ZodLiteral<"awaiting_transfer">;
100
+ iban: z.ZodNullable<z.ZodString>;
101
+ reference: z.ZodString;
102
+ }, z.core.$strip>], "kind">;
103
+ }, z.core.$strip>;
104
+ export type PaymentRetryResult = z.infer<typeof paymentRetryResultSchema>;
105
+ export declare const deliveryMethodSchema: z.ZodObject<{
106
+ id: z.ZodString;
107
+ code: z.ZodString;
108
+ name: z.ZodString;
109
+ cost: z.ZodNumber;
110
+ currency: z.ZodString;
111
+ status: z.ZodEnum<{
112
+ active: "active";
113
+ inactive: "inactive";
114
+ }>;
115
+ }, z.core.$strip>;
116
+ export type DeliveryMethod = z.infer<typeof deliveryMethodSchema>;
117
+ export type PaymentAttemptStatus = 'awaiting_payment' | 'paid' | 'failed' | 'deferred' | 'refunded' | 'partially_refunded';
118
+ /**
119
+ * A payment attempt as it crosses a module boundary — a plain shape, never the
120
+ * ORM entity (FR-011).
121
+ *
122
+ * `amount` and `refundedAmount` stay strings. They are `decimal(14,2)`, and
123
+ * every consumer of this record is a gateway that forwards the figure to a
124
+ * payment provider; a `number` cannot round-trip it.
125
+ */
126
+ export interface PaymentRecord {
127
+ id: string;
128
+ orderId: string;
129
+ paymentMethodId: string;
130
+ status: PaymentAttemptStatus;
131
+ amount: string;
132
+ refundedAmount: string;
133
+ currency: string;
134
+ paidAt: Date | null;
135
+ externalReference: string | null;
136
+ providerDetails: Record<string, unknown> | null;
137
+ failureReason: string | null;
138
+ attemptNo: number;
139
+ createdAt: Date;
140
+ updatedAt: Date;
141
+ }
142
+ /**
143
+ * Container name: `paymentReadPort`. Owner: `payments`.
144
+ *
145
+ * The four gateways resolve a payment attempt by order, by id or by the
146
+ * provider's own reference — sixteen sites of `em.findOne(Payment, …)` written
147
+ * out four times over, once per gateway, with slightly different ordering
148
+ * rules for "the latest attempt".
149
+ *
150
+ * When `payments` is off every method fails closed. That is the answer a
151
+ * gateway webhook should get: a 503 makes the provider retry, where an
152
+ * invented `null` would make the gateway record a payment nothing accounted
153
+ * for.
154
+ */
155
+ export interface PaymentReadPort {
156
+ findById(id: string): Promise<PaymentRecord | null>;
157
+ /** Attempts for an order, newest attempt first. */
158
+ listByOrderId(orderId: string): Promise<PaymentRecord[]>;
159
+ /** The most recent attempt for an order, or `null` when there is none. */
160
+ findLatestForOrder(orderId: string): Promise<PaymentRecord | null>;
161
+ /** Resolve by the provider's own reference (a PaymentIntent id, an order id at the PSP). */
162
+ findByExternalReference(externalReference: string): Promise<PaymentRecord | null>;
163
+ /**
164
+ * How many attempts reference a payment method — the delete-guard
165
+ * `payment_methods` runs before removing one (feature 034 FR-003, feature
166
+ * 075).
167
+ *
168
+ * A count rather than the rows: the guard needs "is this method still spoken
169
+ * for", and the figure goes into the operator's 409 message. Handing back
170
+ * every attempt for a method a busy shop has used for a year would be a read
171
+ * of unbounded size for a yes/no question.
172
+ *
173
+ * It runs on this port's own `EntityManager`, so it does **not** join the
174
+ * caller's transaction. That costs nothing here and is worth saying: the
175
+ * deleting transaction writes no `payments` row, and under `read committed`
176
+ * an in-transaction count took a fresh snapshot per statement anyway — it
177
+ * never held a concurrent attempt off. What guarantees no orphan is the
178
+ * guard plus this module refusing to record an attempt against a method that
179
+ * is gone, not the instant the count was taken.
180
+ */
181
+ countByPaymentMethod(paymentMethodId: string): Promise<number>;
182
+ }
183
+ /**
184
+ * Container name: `paymentReferencePort`. Owner: `payments`.
185
+ *
186
+ * The one **write** the four gateways make into this module's table, and the
187
+ * only one they make anywhere outside the settlement ingress: when a gateway
188
+ * has created its own object for an attempt — a Stripe PaymentIntent or
189
+ * Checkout Session, a TPay transaction, a PayU order, an Autopay transaction —
190
+ * it records that object's identifier on the attempt, so a later provider
191
+ * event that carries only the provider's own reference resolves back to a
192
+ * payment. It is the write side of `PaymentReadPort.findByExternalReference`.
193
+ *
194
+ * Two methods rather than one, because the four gateways genuinely do two
195
+ * different things and neither is wrong: `stampExternalReference` replaces
196
+ * whatever was there (TPay, PayU — a new provider object supersedes the old
197
+ * one, and keeping the stale reference would strand the settlement event),
198
+ * while `stampExternalReferenceIfAbsent` keeps a reference already on the row
199
+ * (Stripe — a redirect Checkout Session and the PaymentIntent it later spawns
200
+ * are two identifiers for one attempt, and the first is the one its metadata
201
+ * was written against). Publishing the divergence is how it becomes a decision
202
+ * somebody can take; hiding it behind one method would have taken it silently.
203
+ *
204
+ * Each returns whether the row changed.
205
+ *
206
+ * When `payments` is off the write fails closed, and a gateway that has just
207
+ * created a provider object must hear that: swallowing it would leave a live
208
+ * PaymentIntent at the provider with nothing on this side able to resolve the
209
+ * event it will send.
210
+ *
211
+ * `mergeProviderDetails` is the same surface seen through the other column
212
+ * `payments` keeps for a provider: `providerDetails` is what the provider
213
+ * recorded about an attempt, and `PaymentReadPort.findById` is where a gateway
214
+ * reads it back. TPay is the one consumer — a BLIK payment that asked for
215
+ * one-click registration has to carry that request from the pay call to the
216
+ * settlement notification, which is a different process lifetime — and it is a
217
+ * merge rather than a set because the settlement path writes the same column.
218
+ */
219
+ export interface PaymentReferencePort {
220
+ stampExternalReference(paymentId: string, externalReference: string): Promise<boolean>;
221
+ /** Stamp only when the attempt carries no reference yet. */
222
+ stampExternalReferenceIfAbsent(paymentId: string, externalReference: string): Promise<boolean>;
223
+ /**
224
+ * Shallow-merge `patch` into the attempt's `providerDetails`. Returns whether
225
+ * a row was found; a `null` value in `patch` is stored as `null`, not
226
+ * treated as a deletion.
227
+ */
228
+ mergeProviderDetails(paymentId: string, patch: Record<string, unknown>): Promise<boolean>;
229
+ }
230
+ export interface ReceivePaymentResult {
231
+ paymentId: string;
232
+ status: PaymentAttemptStatus;
233
+ orderStatus: string | null;
234
+ idempotent: boolean;
235
+ }
236
+ /** What a gateway reports when a provider reflects a refund back to us. */
237
+ export interface ReflectRefundInput {
238
+ paymentId?: string;
239
+ orderId?: string;
240
+ /** The provider's own reference — resolves the payment when no `paymentId`. */
241
+ externalReference?: string;
242
+ /** Cumulative refunded amount in major units. */
243
+ refundedAmount: number;
244
+ currency: string;
245
+ fullyRefunded: boolean;
246
+ externalRefundId?: string | null;
247
+ providerDetails?: Record<string, unknown>;
248
+ }
249
+ /**
250
+ * Container name: `receivePaymentPort`. Owner: `payments`.
251
+ *
252
+ * The ingress every gateway funnels a provider event through (feature 034,
253
+ * FR-022/FR-023/FR-025). It resolves the payment, applies the outcome and maps
254
+ * the order status through the method's `statusOnSuccess` / `statusOnFailure`.
255
+ *
256
+ * Idempotent by contract: a success after a terminal `paid` is a no-op, a
257
+ * failure after `paid` is rejected — no downgrade. It resolves a late event
258
+ * even when the adapter has since been de-registered, because it keys on the
259
+ * persisted payment rather than on the live registry.
260
+ *
261
+ * **Owner off:** the seam fails closed — resolving this port throws
262
+ * `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`, so nothing
263
+ * half-executes. Whether `payments` has an off state at all is its manifest's
264
+ * `activation` to say, not this line's: a module declaring
265
+ * `nonDeactivatable` never enters one.
266
+ */
267
+ export interface ReceivePaymentPort {
268
+ receive(input: ReceivePayment): Promise<ReceivePaymentResult>;
269
+ reflectRefund(input: ReflectRefundInput): Promise<{
270
+ paymentId: string;
271
+ changed: boolean;
272
+ } | null>;
273
+ }
274
+ /**
275
+ * A gateway's refund handler, as the host registry holds it.
276
+ *
277
+ * The four gateway modules contribute one each from their boot hook. The
278
+ * registry's absent-owner policy is `payments`' and stays `payments`': a
279
+ * handler whose module is switched off is **skipped**, and the obligation
280
+ * lands on `pending_manual` rather than being dropped. Refunding through a PSP
281
+ * the operator switched off would charge that PSP's API with that operator's
282
+ * credentials — the opposite of "behaves as if never installed"
283
+ * (Principle XVII).
284
+ */
285
+ export interface GatewayRefundHandler {
286
+ /** The payment adapter key this handler serves (e.g. `stripe`). */
287
+ readonly adapterKey: string;
288
+ refund(input: PaymentRefundInput): Promise<PaymentRefundResult>;
289
+ }
290
+ /**
291
+ * Container name: `gatewayRefundRegistry`. Owner: `payments`.
292
+ *
293
+ * A **contribution seam**, not a call seam: the gateways push into it at boot
294
+ * and the host filters at enumeration, keyed on the module recorded with each
295
+ * entry. The deactivation-consequence classification of every edge into it is
296
+ * `contributes`, and publishing the shape must not change that — a cut that
297
+ * turned these into `fails-closed` would change the sentence the operator's
298
+ * confirmation dialog renders (contracts/port-publication.md §1.4).
299
+ *
300
+ * **The name above is the ungated one, and that is the whole instruction to an
301
+ * implementer** (D-99.7). `gatewayRefundRegistry` is a plain `di.register`: a
302
+ * gateway resolves it and calls `register` from its `ctx.onBoot` hook, exactly
303
+ * as `stripe`, `payu`, `tpay` and `autopay` do. It is ungated **because a gate
304
+ * on a push refuses the contribution rather than deferring it** — a gateway
305
+ * that booted while `payments` was off would stay silently unregistered until
306
+ * the next restart after an operator switched `payments` back on.
307
+ *
308
+ * A gated twin, `gatewayRefundRegistryPort`, used to be published over this
309
+ * same interface and was resolved by nobody. It is gone: an author following it
310
+ * would resolve a gated registration from a boot hook, and a `ModuleDisabledError`
311
+ * raised during composition is re-thrown as `ModuleCompositionError` and ends
312
+ * in `process.exit(1)`. The pull direction is real but intra-module —
313
+ * `payments`' own refund provider asks this registry which handler settles a
314
+ * refund — and it is not published.
315
+ *
316
+ * `register` therefore names its contributor. That argument is the whole
317
+ * mechanism: without it the registry records no owner, states no policy, and a
318
+ * switched-off gateway goes on refunding through its own PSP API — which is
319
+ * what D-44 §7 recorded as the one live instance of that gap.
320
+ *
321
+ * **What an implementer inherits while their own module is off:** the handler
322
+ * is *skipped* at enumeration, not dropped. The refund does not silently fail —
323
+ * `payments` records a `pending_manual` obligation naming the absent module, so
324
+ * a person settles it, which is what a deployment that never installed the
325
+ * gateway already gets (D-71).
326
+ *
327
+ * **Do not "complete" this interface.** `GatewayRefundRegistry` also has
328
+ * `entry`, `ownerOf`, `listAll` and `absentOwnerFor`, and the omission is the
329
+ * point rather than an oversight: `absentOwnerFor` is what turns a refund
330
+ * through an absent gateway into a `pending_manual` obligation instead of a
331
+ * refund that did not happen (D-71), and it is called from exactly one place —
332
+ * `payments/services/payment-refund.ts` — plus this module's own unit test.
333
+ * Verified for issue #192: no caller outside `payments`. Publishing it would
334
+ * offer another module a presence-blind read of the table, which is the one
335
+ * thing the contribution classification rests on not existing.
336
+ */
337
+ export interface GatewayRefundRegistryPort {
338
+ register(handler: GatewayRefundHandler, module: string): void;
339
+ /** The handler for an adapter key, or `undefined` when its owner is absent. */
340
+ get(adapterKey: string): GatewayRefundHandler | undefined;
341
+ /**
342
+ * The handler for an adapter key, falling back to the sole registered one
343
+ * when the order names no adapter. Absent owners are skipped here too:
344
+ * honouring one would route exactly the refunds with the least information
345
+ * behind them into a switched-off gateway.
346
+ */
347
+ resolve(adapterKey?: string | null): GatewayRefundHandler | undefined;
348
+ /** Adapter keys whose owner is present, in registration order. */
349
+ list(): string[];
350
+ }
351
+ /** What the order-confirmation e-mail knows about the payment method. */
352
+ export interface PaymentEmailContext {
353
+ /** Resolved display name of the payment method. */
354
+ name: string;
355
+ kind: string;
356
+ /** Flat surcharge applied for this method (order currency). */
357
+ additionalPrice: number;
358
+ currency: string;
359
+ }
360
+ /**
361
+ * Container name: `paymentEmailRendererPort`. Owner: `payments`.
362
+ *
363
+ * The payment line of the transactional order-confirmation e-mail (feature
364
+ * 034, FR-016/FR-017). An adapter may register a custom renderer under a key;
365
+ * when none is registered the platform default is used, so the payment section
366
+ * always renders.
367
+ *
368
+ * `orders` reaches the resolver today and then calls the function it gets
369
+ * back. The port collapses those two steps, which is what lets the fallback
370
+ * stay on this side: a consumer that resolved a renderer and got `undefined`
371
+ * would have to hold a copy of the default text, and two copies of a default
372
+ * are how a default stops being one.
373
+ *
374
+ * Bodies are plain text (see `EmailMailerSendInput.text`), so a renderer is a
375
+ * `(ctx) => string` builder rather than a component.
376
+ *
377
+ * **Owner off:** the seam fails closed — resolving this port throws
378
+ * `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`, so nothing
379
+ * half-executes. Whether `payments` has an off state at all is its manifest's
380
+ * `activation` to say, not this line's: a module declaring
381
+ * `nonDeactivatable` never enters one.
382
+ */
383
+ export interface PaymentEmailRendererPort {
384
+ render(rendererKey: string | null, ctx: PaymentEmailContext): string;
385
+ }
386
+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M,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACjE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9D,+EAA+E;IAC/E,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAAC;IAC1D;;;;;OAKG;IACH,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,oBAAoB,GAAG,SAAS,CAAC;IACtE,kEAAkE;IAClE,IAAI,IAAI,MAAM,EAAE,CAAC;CAClB;AAED,yEAAyE;AACzE,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,mBAAmB,GAAG,MAAM,CAAC;CACtE"}
@@ -0,0 +1,84 @@
1
+ import { z } from 'zod';
2
+ import { isoDateTimeSchema, paymentStatusSchema, uuidSchema } from './common.js';
3
+ /**
4
+ * Payments (FR-072). Drivers: bank_transfer, pickup, credit_limit, gateway.
5
+ * Driver-specific NextAction payloads live in orders.ts (the Place Order
6
+ * response body).
7
+ */
8
+ export const paymentMethodKindSchema = z.enum([
9
+ 'bank_transfer',
10
+ 'pickup',
11
+ 'credit_limit',
12
+ 'gateway',
13
+ ]);
14
+ export const paymentMethodSchema = z.object({
15
+ id: uuidSchema,
16
+ code: z.string(),
17
+ name: z.string(),
18
+ kind: paymentMethodKindSchema,
19
+ status: z.enum(['active', 'inactive']),
20
+ });
21
+ export const paymentSchema = z.object({
22
+ id: uuidSchema,
23
+ orderId: uuidSchema,
24
+ paymentMethodId: uuidSchema,
25
+ status: paymentStatusSchema,
26
+ amount: z.number().finite().nonnegative(),
27
+ currency: z.string().length(3),
28
+ paidAt: isoDateTimeSchema.nullable(),
29
+ externalReference: z.string().nullable(),
30
+ // Feature 034 — payment-process detail captured by the adapter on receive_payment.
31
+ providerDetails: z.record(z.string(), z.unknown()).nullable().optional(),
32
+ failureReason: z.string().nullable().optional(),
33
+ attemptNo: z.number().int().positive().default(1),
34
+ });
35
+ /**
36
+ * What a buyer is told to do next after asking to pay an unpaid order again
37
+ * (issue #264). The three kinds are the `StartPaymentResult` a payment adapter
38
+ * returns, carried out to the storefront: send the buyer to the gateway, show
39
+ * them the transfer details again, or tell them there is nothing to do here.
40
+ */
41
+ export const paymentRetryNextActionSchema = z.discriminatedUnion('kind', [
42
+ z.object({ kind: z.literal('none') }),
43
+ z.object({ kind: z.literal('redirect'), url: z.string().url() }),
44
+ z.object({
45
+ kind: z.literal('awaiting_transfer'),
46
+ iban: z.string().nullable(),
47
+ reference: z.string(),
48
+ }),
49
+ ]);
50
+ /**
51
+ * The reply to `POST /api/v1/orders/:orderId/payments/retry` (issue #264).
52
+ *
53
+ * `opened` is the difference between the two things the buyer's click can
54
+ * mean, and the storefront routes on it:
55
+ *
56
+ * - `true` — the previous attempt had failed, so attempt `attemptNo` was
57
+ * opened and its provider session started. `nextAction` is that
58
+ * session.
59
+ * - `false` — an attempt was already open (a double-click, a reload, a buyer
60
+ * coming back to a payment they abandoned). Nothing was opened and
61
+ * no provider was contacted, so `nextAction` is `none` and the
62
+ * buyer belongs on the existing payment step for that attempt.
63
+ *
64
+ * That split is what makes the endpoint idempotent at the provider: one click
65
+ * is one provider object, whatever the buyer does to the button. It matters
66
+ * concretely rather than tidily — PayU keys its order on `extOrderId`, which is
67
+ * this platform's payment id, and a second create against a live attempt would
68
+ * be a duplicate `extOrderId` at the POS.
69
+ */
70
+ export const paymentRetryResultSchema = z.object({
71
+ paymentId: uuidSchema,
72
+ attemptNo: z.number().int().positive(),
73
+ opened: z.boolean(),
74
+ nextAction: paymentRetryNextActionSchema,
75
+ });
76
+ export const deliveryMethodSchema = z.object({
77
+ id: uuidSchema,
78
+ code: z.string(),
79
+ name: z.string(),
80
+ cost: z.number().finite().nonnegative(),
81
+ currency: z.string().length(3),
82
+ status: z.enum(['active', 'inactive']),
83
+ });
84
+ //# sourceMappingURL=payments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payments.js","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIjF;;;;GAIG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC5C,eAAe;IACf,QAAQ;IACR,cAAc;IACd,SAAS;CACV,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,uBAAuB;IAC7B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CACvC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,UAAU;IACd,OAAO,EAAE,UAAU;IACnB,eAAe,EAAE,UAAU;IAC3B,MAAM,EAAE,mBAAmB;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MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,SAAS,EAAE,UAAU;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACtC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,UAAU,EAAE,4BAA4B;CACzC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE;IACvC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CACvC,CAAC,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { z } from 'zod';
2
+ export declare const pimImportRunStatusSchema: z.ZodEnum<{
3
+ completed: "completed";
4
+ failed: "failed";
5
+ skipped: "skipped";
6
+ queued: "queued";
7
+ running: "running";
8
+ completed_with_issues: "completed_with_issues";
9
+ }>;
10
+ export type PimImportRunStatus = z.infer<typeof pimImportRunStatusSchema>;
11
+ export declare const pimImportTriggerSchema: z.ZodEnum<{
12
+ push: "push";
13
+ scheduled: "scheduled";
14
+ manual: "manual";
15
+ }>;
16
+ export type PimImportTrigger = z.infer<typeof pimImportTriggerSchema>;
17
+ export declare const pimImportModeSchema: z.ZodEnum<{
18
+ delta: "delta";
19
+ full: "full";
20
+ }>;
21
+ export type PimImportMode = z.infer<typeof pimImportModeSchema>;
22
+ export declare const pimImportIssueSeveritySchema: z.ZodEnum<{
23
+ error: "error";
24
+ info: "info";
25
+ warning: "warning";
26
+ }>;
27
+ export type PimImportIssueSeverity = z.infer<typeof pimImportIssueSeveritySchema>;
28
+ export declare const pimImportCountsSchema: z.ZodObject<{
29
+ considered: z.ZodNumber;
30
+ created: z.ZodNumber;
31
+ updated: z.ZodNumber;
32
+ skipped: z.ZodNumber;
33
+ withdrawn: z.ZodNumber;
34
+ failed: z.ZodNumber;
35
+ protected: z.ZodOptional<z.ZodNumber>;
36
+ }, z.core.$strip>;
37
+ export type PimImportCounts = z.infer<typeof pimImportCountsSchema>;
38
+ /** Canonical field-protection path grammar (shared across PIM connectors). */
39
+ export declare const pimFieldPathSchema: z.ZodString;
40
+ export type PimFieldPath = z.infer<typeof pimFieldPathSchema>;
41
+ export declare const PIM_CONNECTOR_REGISTRY_PORT: "pimConnectorRegistryPort";
42
+ /**
43
+ * Container name: `pimConnectorRegistryPort`. Owner: `pim_connector`.
44
+ *
45
+ * Mutual-exclusion registry — see
46
+ * `specs/089-unopim-pim-sync/contracts/pim-connector-shared.md`. The name is
47
+ * the whole of the promise this port makes (D-98.2): `lazyPort<T>` asserts `T`
48
+ * and compares it to nothing that is registered, so a consumer copying the
49
+ * owner's class registration instead of this name would compile and receive the
50
+ * service ungated. `PIM_CONNECTOR_REGISTRY_PORT` above is the same literal, for
51
+ * the owner's `providePort` call.
52
+ */
53
+ export interface PimConnectorRegistryPort {
54
+ /** Refuses when another PIM connector's activation Setting is true. */
55
+ assertCanActivate(moduleId: string): Promise<void>;
56
+ recordActive(moduleId: string, adminId: string | null): Promise<void>;
57
+ clearActive(moduleId: string): Promise<void>;
58
+ getActiveModuleId(): Promise<string | null>;
59
+ }
60
+ //# sourceMappingURL=pim-connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pim-connector.d.ts","sourceRoot":"","sources":["../src/pim-connector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB;;;;;;;EAOnC,CAAC;AACH,MAAM,MAA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