@endora-commerce/contracts 0.109.0 → 0.111.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 (385) hide show
  1. package/dist/accept-language.d.ts +31 -0
  2. package/dist/accept-language.js +64 -0
  3. package/dist/actor.d.ts +16 -0
  4. package/dist/addresses.d.ts +35 -0
  5. package/dist/addresses.js +8 -1
  6. package/dist/admin-actions.d.ts +2 -0
  7. package/dist/admin-actions.js +18 -0
  8. package/dist/admin-contributions.d.ts +99 -12
  9. package/dist/admin-contributions.js +36 -10
  10. package/dist/admin-roles.d.ts +17 -2
  11. package/dist/admin-users.d.ts +9 -0
  12. package/dist/admin.d.ts +114 -4
  13. package/dist/admin.js +98 -3
  14. package/dist/api-keys.d.ts +22 -0
  15. package/dist/api-keys.js +4 -0
  16. package/dist/assets-library.d.ts +45 -0
  17. package/dist/assets-library.js +20 -3
  18. package/dist/audit-logs.d.ts +12 -0
  19. package/dist/audit-logs.js +12 -0
  20. package/dist/auth.d.ts +9 -0
  21. package/dist/auth.js +9 -0
  22. package/dist/blog.d.ts +382 -22
  23. package/dist/blog.js +199 -17
  24. package/dist/carts.d.ts +423 -36
  25. package/dist/carts.js +150 -12
  26. package/dist/catalog.d.ts +379 -208
  27. package/dist/catalog.js +241 -163
  28. package/dist/cms-brand.d.ts +14 -14
  29. package/dist/cms.d.ts +71 -16
  30. package/dist/cms.js +15 -0
  31. package/dist/command-hooks.d.ts +301 -0
  32. package/dist/command-hooks.js +248 -0
  33. package/dist/common.d.ts +23 -6
  34. package/dist/common.js +25 -2
  35. package/dist/comparisons.d.ts +21 -14
  36. package/dist/comparisons.js +2 -1
  37. package/dist/credit-limits.d.ts +22 -0
  38. package/dist/credit-limits.js +35 -0
  39. package/dist/crm.d.ts +134 -78
  40. package/dist/crm.js +21 -5
  41. package/dist/custom-fields.d.ts +417 -49
  42. package/dist/custom-fields.js +142 -1
  43. package/dist/customer-accounts.d.ts +324 -22
  44. package/dist/customer-accounts.js +43 -0
  45. package/dist/customer-notifications.d.ts +143 -0
  46. package/dist/customer-notifications.js +41 -0
  47. package/dist/customers.d.ts +92 -73
  48. package/dist/customers.js +98 -10
  49. package/dist/dictionary.d.ts +53 -0
  50. package/dist/dictionary.js +25 -0
  51. package/dist/document-templates.d.ts +12 -12
  52. package/dist/email.d.ts +34 -0
  53. package/dist/email.js +6 -0
  54. package/dist/errors.d.ts +431 -3
  55. package/dist/errors.js +523 -3
  56. package/dist/forms-logic.d.ts +79 -0
  57. package/dist/forms-logic.fixtures.d.ts +52 -0
  58. package/dist/forms-logic.fixtures.js +610 -0
  59. package/dist/forms-logic.js +699 -0
  60. package/dist/forms.d.ts +9833 -0
  61. package/dist/forms.js +827 -0
  62. package/dist/i18n.d.ts +34 -0
  63. package/dist/i18n.js +15 -0
  64. package/dist/import-export.d.ts +180 -0
  65. package/dist/import-export.js +60 -0
  66. package/dist/index.d.ts +16 -1
  67. package/dist/index.js +30 -1
  68. package/dist/inventory.d.ts +9 -9
  69. package/dist/invoice-ledger.d.ts +13 -13
  70. package/dist/invoices.d.ts +126 -0
  71. package/dist/invoices.js +53 -0
  72. package/dist/line-bounds.d.ts +53 -0
  73. package/dist/line-bounds.js +65 -0
  74. package/dist/megamenu.d.ts +27 -27
  75. package/dist/mfa.d.ts +210 -4
  76. package/dist/mfa.js +136 -0
  77. package/dist/modules.d.ts +56 -8
  78. package/dist/modules.js +128 -3
  79. package/dist/money-decimal.d.ts +54 -0
  80. package/dist/money-decimal.js +95 -0
  81. package/dist/newsletter.d.ts +4 -4
  82. package/dist/orders.d.ts +246 -12
  83. package/dist/orders.js +140 -7
  84. package/dist/organization-hooks.d.ts +99 -0
  85. package/dist/organization-hooks.js +22 -0
  86. package/dist/organization-registry-lookup.d.ts +362 -0
  87. package/dist/organization-registry-lookup.js +196 -0
  88. package/dist/organization-roles.d.ts +341 -0
  89. package/dist/organization-roles.js +218 -0
  90. package/dist/organizations.d.ts +1074 -103
  91. package/dist/organizations.js +293 -28
  92. package/dist/page-builder-props.d.ts +56 -56
  93. package/dist/pim-connector.d.ts +7 -3
  94. package/dist/pim-connector.js +6 -2
  95. package/dist/pim-field-path.d.ts +5 -1
  96. package/dist/pim-field-path.js +37 -81
  97. package/dist/pim-locale-mapping.d.ts +131 -0
  98. package/dist/pim-locale-mapping.js +193 -0
  99. package/dist/price-books.d.ts +215 -63
  100. package/dist/price-books.js +47 -2
  101. package/dist/price-lists.d.ts +13 -10
  102. package/dist/product-feeds.d.ts +249 -100
  103. package/dist/product-feeds.js +46 -2
  104. package/dist/product-scope-model.d.ts +161 -0
  105. package/dist/product-scope-model.js +161 -0
  106. package/dist/product-scope-overrides.d.ts +0 -103
  107. package/dist/product-scope-overrides.js +0 -54
  108. package/dist/product-scoped-values.d.ts +2610 -0
  109. package/dist/product-scoped-values.js +425 -0
  110. package/dist/product-scopes.d.ts +199 -64
  111. package/dist/product-scopes.js +120 -23
  112. package/dist/product-tax-rates.d.ts +38 -0
  113. package/dist/product-tax-rates.js +45 -0
  114. package/dist/product-url-keys.d.ts +51 -45
  115. package/dist/product-url-keys.js +73 -39
  116. package/dist/product-value-resolver.d.ts +37 -60
  117. package/dist/product-value-resolver.js +36 -96
  118. package/dist/projects.d.ts +76 -28
  119. package/dist/projects.js +53 -9
  120. package/dist/promotions.d.ts +163 -11
  121. package/dist/promotions.js +23 -1
  122. package/dist/pwa.d.ts +41 -2
  123. package/dist/quick-order.d.ts +159 -9
  124. package/dist/quick-order.js +79 -4
  125. package/dist/quote-requests.d.ts +231 -17
  126. package/dist/quote-requests.js +111 -9
  127. package/dist/record-references.d.ts +15 -15
  128. package/dist/record-references.js +2 -3
  129. package/dist/record-rich-text.js +2 -1
  130. package/dist/returns.d.ts +214 -52
  131. package/dist/returns.js +143 -28
  132. package/dist/sales-channels.d.ts +34 -3
  133. package/dist/sales-channels.js +16 -1
  134. package/dist/saved-list-views.d.ts +28 -0
  135. package/dist/saved-list-views.js +14 -1
  136. package/dist/schema-extensions.d.ts +36 -0
  137. package/dist/schema-extensions.js +29 -0
  138. package/dist/scoped-write-encoding.d.ts +100 -0
  139. package/dist/scoped-write-encoding.js +135 -0
  140. package/dist/search.d.ts +18 -16
  141. package/dist/seo.d.ts +83 -30
  142. package/dist/seo.js +8 -1
  143. package/dist/settings.d.ts +173 -2
  144. package/dist/settings.js +53 -2
  145. package/dist/shopping-lists.d.ts +63 -4
  146. package/dist/shopping-lists.js +57 -3
  147. package/dist/storefront-cache-tags.d.ts +22 -0
  148. package/dist/storefront-cache-tags.js +12 -0
  149. package/dist/storefront-value-overrides.d.ts +18 -56
  150. package/dist/storefront-value-overrides.js +11 -86
  151. package/dist/tasks.d.ts +27 -27
  152. package/dist/taxes.d.ts +27 -0
  153. package/dist/taxes.js +4 -0
  154. package/dist/transactional-emails.d.ts +48 -22
  155. package/dist/webhooks.d.ts +75 -0
  156. package/dist/webhooks.js +24 -0
  157. package/package.json +5 -3
  158. package/dist/actor.d.ts.map +0 -1
  159. package/dist/actor.js.map +0 -1
  160. package/dist/addresses.d.ts.map +0 -1
  161. package/dist/addresses.js.map +0 -1
  162. package/dist/admin-actions.d.ts.map +0 -1
  163. package/dist/admin-actions.js.map +0 -1
  164. package/dist/admin-contributions.d.ts.map +0 -1
  165. package/dist/admin-contributions.js.map +0 -1
  166. package/dist/admin-feedback.d.ts.map +0 -1
  167. package/dist/admin-feedback.js.map +0 -1
  168. package/dist/admin-i18n.d.ts.map +0 -1
  169. package/dist/admin-i18n.js.map +0 -1
  170. package/dist/admin-name.d.ts.map +0 -1
  171. package/dist/admin-name.js.map +0 -1
  172. package/dist/admin-notifications.d.ts.map +0 -1
  173. package/dist/admin-notifications.js.map +0 -1
  174. package/dist/admin-preferences.d.ts.map +0 -1
  175. package/dist/admin-preferences.js.map +0 -1
  176. package/dist/admin-roles.d.ts.map +0 -1
  177. package/dist/admin-roles.js.map +0 -1
  178. package/dist/admin-search.d.ts.map +0 -1
  179. package/dist/admin-search.js.map +0 -1
  180. package/dist/admin-users.d.ts.map +0 -1
  181. package/dist/admin-users.js.map +0 -1
  182. package/dist/admin.d.ts.map +0 -1
  183. package/dist/admin.js.map +0 -1
  184. package/dist/analytics.d.ts.map +0 -1
  185. package/dist/analytics.js.map +0 -1
  186. package/dist/api-keys.d.ts.map +0 -1
  187. package/dist/api-keys.js.map +0 -1
  188. package/dist/assets-library.d.ts.map +0 -1
  189. package/dist/assets-library.js.map +0 -1
  190. package/dist/audit-logs.d.ts.map +0 -1
  191. package/dist/audit-logs.js.map +0 -1
  192. package/dist/auth.d.ts.map +0 -1
  193. package/dist/auth.js.map +0 -1
  194. package/dist/blog.d.ts.map +0 -1
  195. package/dist/blog.js.map +0 -1
  196. package/dist/capabilities.d.ts.map +0 -1
  197. package/dist/capabilities.js.map +0 -1
  198. package/dist/carts.d.ts.map +0 -1
  199. package/dist/carts.js.map +0 -1
  200. package/dist/catalog.d.ts.map +0 -1
  201. package/dist/catalog.js.map +0 -1
  202. package/dist/cms-brand.d.ts.map +0 -1
  203. package/dist/cms-brand.js.map +0 -1
  204. package/dist/cms-contact-form.d.ts.map +0 -1
  205. package/dist/cms-contact-form.js.map +0 -1
  206. package/dist/cms.d.ts.map +0 -1
  207. package/dist/cms.js.map +0 -1
  208. package/dist/common.d.ts.map +0 -1
  209. package/dist/common.js.map +0 -1
  210. package/dist/comparisons.d.ts.map +0 -1
  211. package/dist/comparisons.js.map +0 -1
  212. package/dist/credentials.d.ts.map +0 -1
  213. package/dist/credentials.js.map +0 -1
  214. package/dist/credit-limits.d.ts.map +0 -1
  215. package/dist/credit-limits.js.map +0 -1
  216. package/dist/crm-rich-text.d.ts.map +0 -1
  217. package/dist/crm-rich-text.js.map +0 -1
  218. package/dist/crm.d.ts.map +0 -1
  219. package/dist/crm.js.map +0 -1
  220. package/dist/currencies.d.ts.map +0 -1
  221. package/dist/currencies.js.map +0 -1
  222. package/dist/custom-fields.d.ts.map +0 -1
  223. package/dist/custom-fields.js.map +0 -1
  224. package/dist/customer-accounts.d.ts.map +0 -1
  225. package/dist/customer-accounts.js.map +0 -1
  226. package/dist/customers.d.ts.map +0 -1
  227. package/dist/customers.js.map +0 -1
  228. package/dist/dictionary.d.ts.map +0 -1
  229. package/dist/dictionary.js.map +0 -1
  230. package/dist/document-templates.d.ts.map +0 -1
  231. package/dist/document-templates.js.map +0 -1
  232. package/dist/document-values.d.ts.map +0 -1
  233. package/dist/document-values.js.map +0 -1
  234. package/dist/email-address.d.ts.map +0 -1
  235. package/dist/email-address.js.map +0 -1
  236. package/dist/email.d.ts.map +0 -1
  237. package/dist/email.js.map +0 -1
  238. package/dist/envelopes.d.ts.map +0 -1
  239. package/dist/envelopes.js.map +0 -1
  240. package/dist/environment-inputs.d.ts.map +0 -1
  241. package/dist/environment-inputs.js.map +0 -1
  242. package/dist/erp-connector.d.ts.map +0 -1
  243. package/dist/erp-connector.js.map +0 -1
  244. package/dist/errors.d.ts.map +0 -1
  245. package/dist/errors.js.map +0 -1
  246. package/dist/google-analytics.d.ts.map +0 -1
  247. package/dist/google-analytics.js.map +0 -1
  248. package/dist/google-tag-manager.d.ts.map +0 -1
  249. package/dist/google-tag-manager.js.map +0 -1
  250. package/dist/i18n.d.ts.map +0 -1
  251. package/dist/i18n.js.map +0 -1
  252. package/dist/import-export.d.ts.map +0 -1
  253. package/dist/import-export.js.map +0 -1
  254. package/dist/index.d.ts.map +0 -1
  255. package/dist/index.js.map +0 -1
  256. package/dist/inventory.d.ts.map +0 -1
  257. package/dist/inventory.js.map +0 -1
  258. package/dist/invoice-ledger.d.ts.map +0 -1
  259. package/dist/invoice-ledger.js.map +0 -1
  260. package/dist/invoices.d.ts.map +0 -1
  261. package/dist/invoices.js.map +0 -1
  262. package/dist/kernel.d.ts.map +0 -1
  263. package/dist/kernel.js.map +0 -1
  264. package/dist/languages.d.ts.map +0 -1
  265. package/dist/languages.js.map +0 -1
  266. package/dist/line-groups.d.ts.map +0 -1
  267. package/dist/line-groups.js.map +0 -1
  268. package/dist/linkedin-ads.d.ts.map +0 -1
  269. package/dist/linkedin-ads.js.map +0 -1
  270. package/dist/localized-name.d.ts.map +0 -1
  271. package/dist/localized-name.js.map +0 -1
  272. package/dist/megamenu.d.ts.map +0 -1
  273. package/dist/megamenu.js.map +0 -1
  274. package/dist/meta-ads.d.ts.map +0 -1
  275. package/dist/meta-ads.js.map +0 -1
  276. package/dist/mfa.d.ts.map +0 -1
  277. package/dist/mfa.js.map +0 -1
  278. package/dist/modules.d.ts.map +0 -1
  279. package/dist/modules.js.map +0 -1
  280. package/dist/money-decimal.d.ts.map +0 -1
  281. package/dist/money-decimal.js.map +0 -1
  282. package/dist/money-input.d.ts.map +0 -1
  283. package/dist/money-input.js.map +0 -1
  284. package/dist/newsletter.d.ts.map +0 -1
  285. package/dist/newsletter.js.map +0 -1
  286. package/dist/order-minimums.d.ts.map +0 -1
  287. package/dist/order-minimums.js.map +0 -1
  288. package/dist/orders.d.ts.map +0 -1
  289. package/dist/orders.js.map +0 -1
  290. package/dist/organizations.d.ts.map +0 -1
  291. package/dist/organizations.js.map +0 -1
  292. package/dist/page-builder-props.d.ts.map +0 -1
  293. package/dist/page-builder-props.js.map +0 -1
  294. package/dist/page-builder-values.d.ts.map +0 -1
  295. package/dist/page-builder-values.js.map +0 -1
  296. package/dist/pagination.d.ts.map +0 -1
  297. package/dist/pagination.js.map +0 -1
  298. package/dist/payment-methods.d.ts.map +0 -1
  299. package/dist/payment-methods.js.map +0 -1
  300. package/dist/payment-return-url.d.ts.map +0 -1
  301. package/dist/payment-return-url.js.map +0 -1
  302. package/dist/payments.d.ts.map +0 -1
  303. package/dist/payments.js.map +0 -1
  304. package/dist/pim-connector.d.ts.map +0 -1
  305. package/dist/pim-connector.js.map +0 -1
  306. package/dist/pim-field-path.d.ts.map +0 -1
  307. package/dist/pim-field-path.js.map +0 -1
  308. package/dist/platform-info.d.ts.map +0 -1
  309. package/dist/platform-info.js.map +0 -1
  310. package/dist/platform-language.d.ts.map +0 -1
  311. package/dist/platform-language.js.map +0 -1
  312. package/dist/price-book-decimal.d.ts.map +0 -1
  313. package/dist/price-book-decimal.js.map +0 -1
  314. package/dist/price-books.d.ts.map +0 -1
  315. package/dist/price-books.js.map +0 -1
  316. package/dist/price-lists.d.ts.map +0 -1
  317. package/dist/price-lists.js.map +0 -1
  318. package/dist/product-feeds.d.ts.map +0 -1
  319. package/dist/product-feeds.js.map +0 -1
  320. package/dist/product-scope-overrides.d.ts.map +0 -1
  321. package/dist/product-scope-overrides.js.map +0 -1
  322. package/dist/product-scopes.d.ts.map +0 -1
  323. package/dist/product-scopes.js.map +0 -1
  324. package/dist/product-summary-text.d.ts.map +0 -1
  325. package/dist/product-summary-text.js.map +0 -1
  326. package/dist/product-url-keys.d.ts.map +0 -1
  327. package/dist/product-url-keys.js.map +0 -1
  328. package/dist/product-value-resolver.d.ts.map +0 -1
  329. package/dist/product-value-resolver.js.map +0 -1
  330. package/dist/projects.d.ts.map +0 -1
  331. package/dist/projects.js.map +0 -1
  332. package/dist/promotions.d.ts.map +0 -1
  333. package/dist/promotions.js.map +0 -1
  334. package/dist/prompt-actions.d.ts.map +0 -1
  335. package/dist/prompt-actions.js.map +0 -1
  336. package/dist/pwa.d.ts.map +0 -1
  337. package/dist/pwa.js.map +0 -1
  338. package/dist/quick-order.d.ts.map +0 -1
  339. package/dist/quick-order.js.map +0 -1
  340. package/dist/quote-requests.d.ts.map +0 -1
  341. package/dist/quote-requests.js.map +0 -1
  342. package/dist/record-references.d.ts.map +0 -1
  343. package/dist/record-references.js.map +0 -1
  344. package/dist/record-rich-text.d.ts.map +0 -1
  345. package/dist/record-rich-text.js.map +0 -1
  346. package/dist/returns.d.ts.map +0 -1
  347. package/dist/returns.js.map +0 -1
  348. package/dist/sales-channels.d.ts.map +0 -1
  349. package/dist/sales-channels.js.map +0 -1
  350. package/dist/saved-list-views.d.ts.map +0 -1
  351. package/dist/saved-list-views.js.map +0 -1
  352. package/dist/scope-notice.d.ts.map +0 -1
  353. package/dist/scope-notice.js.map +0 -1
  354. package/dist/scoped-translations.d.ts +0 -48
  355. package/dist/scoped-translations.d.ts.map +0 -1
  356. package/dist/scoped-translations.js +0 -78
  357. package/dist/scoped-translations.js.map +0 -1
  358. package/dist/search.d.ts.map +0 -1
  359. package/dist/search.js.map +0 -1
  360. package/dist/seo.d.ts.map +0 -1
  361. package/dist/seo.js.map +0 -1
  362. package/dist/settings.d.ts.map +0 -1
  363. package/dist/settings.js.map +0 -1
  364. package/dist/shipments.d.ts.map +0 -1
  365. package/dist/shipments.js.map +0 -1
  366. package/dist/shipping-methods.d.ts.map +0 -1
  367. package/dist/shipping-methods.js.map +0 -1
  368. package/dist/shopping-lists.d.ts.map +0 -1
  369. package/dist/shopping-lists.js.map +0 -1
  370. package/dist/storefront-cache-tags.d.ts.map +0 -1
  371. package/dist/storefront-cache-tags.js.map +0 -1
  372. package/dist/storefront-language-path.d.ts.map +0 -1
  373. package/dist/storefront-language-path.js.map +0 -1
  374. package/dist/storefront-value-overrides.d.ts.map +0 -1
  375. package/dist/storefront-value-overrides.js.map +0 -1
  376. package/dist/tasks.d.ts.map +0 -1
  377. package/dist/tasks.js.map +0 -1
  378. package/dist/taxes.d.ts.map +0 -1
  379. package/dist/taxes.js.map +0 -1
  380. package/dist/text-normalization.d.ts.map +0 -1
  381. package/dist/text-normalization.js.map +0 -1
  382. package/dist/transactional-emails.d.ts.map +0 -1
  383. package/dist/transactional-emails.js.map +0 -1
  384. package/dist/webhooks.d.ts.map +0 -1
  385. package/dist/webhooks.js.map +0 -1
@@ -0,0 +1,99 @@
1
+ import type { OrganizationRecord, OrganizationStatus, VatStatus } from './organizations.js';
2
+ /**
3
+ * `organization.create` — an operator creates an Organization. `organization`
4
+ * reflects the **uncommitted** row on the Command's transaction.
5
+ */
6
+ export interface OrganizationCreateHookData {
7
+ readonly organization: OrganizationRecord;
8
+ /** The channels the create bound, sorted and deduplicated. */
9
+ readonly salesChannelIds: readonly string[];
10
+ }
11
+ /** `organization.register` — a business registers on the storefront. */
12
+ export interface OrganizationRegisterHookData {
13
+ readonly organization: OrganizationRecord;
14
+ /** The first account, created by the child `customer_account.create`. */
15
+ readonly customerAccountId: string;
16
+ /** The request's resolved channel; `null` when the system default was bound. */
17
+ readonly salesChannelId: string | null;
18
+ /** The registry lookup's outcome code, when the registration carried a matched lookup. */
19
+ readonly registryLookupOutcome: string | null;
20
+ }
21
+ /**
22
+ * `organization.admin_patch` and `organization.set_custom_field_values` — an
23
+ * existing Organization changed. `organization` is the after-state.
24
+ */
25
+ export interface OrganizationUpdateHookData {
26
+ readonly organization: OrganizationRecord;
27
+ /** Sorted names of the columns whose value changed. */
28
+ readonly changedFields: readonly string[];
29
+ /** Sorted keys of the custom fields whose value changed. */
30
+ readonly changedCustomFields: readonly string[];
31
+ }
32
+ /**
33
+ * `organization.convert_to_company` (issue #1057) — an operator turned a
34
+ * personal Organization into a company. **Ids, codes and field names only**
35
+ * (`specs/conventions/audit-state.md` list 1): never the tax ID, the name or the
36
+ * address the conversion wrote.
37
+ */
38
+ export interface OrganizationConvertToCompanyHookData {
39
+ readonly organizationId: string;
40
+ /** The status the conversion kept. */
41
+ readonly status: OrganizationStatus;
42
+ /** The company's VAT classification, as converted. */
43
+ readonly vatStatus: VatStatus;
44
+ /** Sorted names of the columns whose value changed. */
45
+ readonly changedFields: readonly string[];
46
+ /** `true` when the Organization had never been approved and the conversion stamped it. */
47
+ readonly approvalStamped: boolean;
48
+ }
49
+ /**
50
+ * `organization.tax_id.change` (issue #1057) — an operator corrected a
51
+ * company's tax ID in place. **Never the old or the new tax ID**; a correction
52
+ * to the same value (after normalisation) is handed `changedFields: []` and
53
+ * `vatValidationReset: false`, and nothing was written.
54
+ */
55
+ export interface OrganizationTaxIdChangeHookData {
56
+ readonly organizationId: string;
57
+ /** `['taxId']`, or `[]` for the same value. */
58
+ readonly changedFields: readonly string[];
59
+ /** `true` when the VAT validation summary was reset to never-validated. */
60
+ readonly vatValidationReset: boolean;
61
+ }
62
+ /** `afterCommit` data: ids and codes only (audit-state list 1). Delivered in P3. */
63
+ export type OrganizationCreateOutbox = {
64
+ readonly organizationId: string;
65
+ readonly status: string;
66
+ };
67
+ export type OrganizationRegisterOutbox = {
68
+ readonly organizationId: string;
69
+ readonly customerAccountId: string;
70
+ readonly status: string;
71
+ };
72
+ export type OrganizationUpdateOutbox = {
73
+ readonly organizationId: string;
74
+ readonly changedFields: readonly string[];
75
+ readonly changedCustomFields: readonly string[];
76
+ };
77
+ export type OrganizationConvertToCompanyOutbox = {
78
+ readonly organizationId: string;
79
+ readonly status: string;
80
+ readonly changedFields: readonly string[];
81
+ };
82
+ export type OrganizationTaxIdChangeOutbox = {
83
+ readonly organizationId: string;
84
+ readonly changedFields: readonly string[];
85
+ };
86
+ /**
87
+ * The refs a hook author registers against (`ctx.commandHooks([{ on: ORG.create, … }])`)
88
+ * and the `organizations` manifest lists. All six offer both phases; the
89
+ * `afterCommit` delivery is the transactional outbox (P3).
90
+ */
91
+ export declare const ORGANIZATION_HOOKABLE_ACTIONS: {
92
+ readonly create: import("./command-hooks.js").HookableActionRef<OrganizationCreateHookData, OrganizationCreateOutbox>;
93
+ readonly register: import("./command-hooks.js").HookableActionRef<OrganizationRegisterHookData, OrganizationRegisterOutbox>;
94
+ readonly adminPatch: import("./command-hooks.js").HookableActionRef<OrganizationUpdateHookData, OrganizationUpdateOutbox>;
95
+ readonly setCustomFieldValues: import("./command-hooks.js").HookableActionRef<OrganizationUpdateHookData, OrganizationUpdateOutbox>;
96
+ readonly convertToCompany: import("./command-hooks.js").HookableActionRef<OrganizationConvertToCompanyHookData, OrganizationConvertToCompanyOutbox>;
97
+ readonly changeTaxId: import("./command-hooks.js").HookableActionRef<OrganizationTaxIdChangeHookData, OrganizationTaxIdChangeOutbox>;
98
+ };
99
+ //# sourceMappingURL=organization-hooks.d.ts.map
@@ -0,0 +1,22 @@
1
+ // `organizations`' hookable actions — `specs/176-command-hooks-outbox/` FR-024,
2
+ // `contracts/organization-hookable-actions.md`.
3
+ //
4
+ // The six Organization writes an instance may take part in through a command
5
+ // hook (`organization.convert_to_company` and `organization.tax_id.change`
6
+ // since issue #1057). The action strings, the phases and the data types are a public
7
+ // contract: changing one is a changeset on `@endora-commerce/contracts`.
8
+ import { hookableAction } from './command-hooks.js';
9
+ /**
10
+ * The refs a hook author registers against (`ctx.commandHooks([{ on: ORG.create, … }])`)
11
+ * and the `organizations` manifest lists. All six offer both phases; the
12
+ * `afterCommit` delivery is the transactional outbox (P3).
13
+ */
14
+ export const ORGANIZATION_HOOKABLE_ACTIONS = {
15
+ create: hookableAction('organization.create', 'organization', ['beforeCommit', 'afterCommit']),
16
+ register: hookableAction('organization.register', 'organization', ['beforeCommit', 'afterCommit']),
17
+ adminPatch: hookableAction('organization.admin_patch', 'organization', ['beforeCommit', 'afterCommit']),
18
+ setCustomFieldValues: hookableAction('organization.set_custom_field_values', 'organization', ['beforeCommit', 'afterCommit']),
19
+ convertToCompany: hookableAction('organization.convert_to_company', 'organization', ['beforeCommit', 'afterCommit']),
20
+ changeTaxId: hookableAction('organization.tax_id.change', 'organization', ['beforeCommit', 'afterCommit']),
21
+ };
22
+ //# sourceMappingURL=organization-hooks.js.map
@@ -0,0 +1,362 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Feature 173 — the company registry lookup at storefront registration
4
+ * (`specs/173-registration-registry-lookup/contracts/public-api.md`,
5
+ * `contracts/admin-surfaces.md` §6, data-model §6). Owner: `organizations`.
6
+ *
7
+ * A buyer registering a business types a Polish NIP or an EU VAT number; the
8
+ * platform answers what the public registry (GUS REGON, the Ministry of Finance
9
+ * VAT White List, VIES) knows about the company, and the registration later
10
+ * carries the `lookupId` back so the snapshot the buyer was shown is persisted
11
+ * from the platform's own store — never from anything the client sends.
12
+ *
13
+ * Every status, VAT status, activity status and source is a **machine token**:
14
+ * the storefront and the admin translate them (research R-18).
15
+ *
16
+ * This file imports nothing from `organizations.ts` at run time: that file
17
+ * imports {@link registryLookupIdSchema} from here for the register body.
18
+ */
19
+ /**
20
+ * The countries the lookup serves: Poland (GUS / White List) and the VIES
21
+ * member states. VIES spells Greece `EL` and Northern Ireland `XI`; the form's
22
+ * country picker sends ISO `GR`, which the backend normaliser maps to `EL`.
23
+ */
24
+ export declare const REGISTRY_LOOKUP_COUNTRIES: readonly ["PL", "AT", "BE", "BG", "CY", "CZ", "DE", "DK", "EE", "EL", "ES", "FI", "FR", "HR", "HU", "IE", "IT", "LT", "LU", "LV", "MT", "NL", "PT", "RO", "SE", "SI", "SK", "XI"];
25
+ export type RegistryLookupCountry = (typeof REGISTRY_LOOKUP_COUNTRIES)[number];
26
+ /**
27
+ * The picker form of a lookup country: `GR` for Greece, every other code as it
28
+ * is. What `registration-options` lists and what a lookup answer's `country`
29
+ * carries, so a client can select it in an ISO country picker.
30
+ */
31
+ export declare function registryLookupCountryForPicker(country: string): string;
32
+ /** The lookup reference: 32 random bytes, base64url, no padding. */
33
+ export declare const registryLookupIdSchema: z.ZodString;
34
+ export declare const registrationOptionsResponseSchema: z.ZodObject<{
35
+ data: z.ZodObject<{
36
+ registryLookup: z.ZodObject<{
37
+ enabled: z.ZodBoolean;
38
+ countries: z.ZodArray<z.ZodString>;
39
+ }, z.core.$strip>;
40
+ }, z.core.$strip>;
41
+ }, z.core.$strip>;
42
+ export type RegistrationOptionsResponse = z.infer<typeof registrationOptionsResponseSchema>;
43
+ export declare const registryLookupRequestSchema: z.ZodObject<{
44
+ taxId: z.ZodString;
45
+ country: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
46
+ }, z.core.$strip>;
47
+ export type RegistryLookupRequest = z.infer<typeof registryLookupRequestSchema>;
48
+ export declare const REGISTRY_LOOKUP_STATUSES: readonly ["found", "not_found", "unavailable", "invalid_tax_id", "unsupported_country"];
49
+ export declare const registryLookupStatusSchema: z.ZodEnum<{
50
+ not_found: "not_found";
51
+ unavailable: "unavailable";
52
+ found: "found";
53
+ invalid_tax_id: "invalid_tax_id";
54
+ unsupported_country: "unsupported_country";
55
+ }>;
56
+ export type RegistryLookupStatus = z.infer<typeof registryLookupStatusSchema>;
57
+ export declare const registryVatStatusSchema: z.ZodEnum<{
58
+ unknown: "unknown";
59
+ active: "active";
60
+ exempt: "exempt";
61
+ not_registered: "not_registered";
62
+ }>;
63
+ export type RegistryVatStatus = z.infer<typeof registryVatStatusSchema>;
64
+ export declare const registryActivityStatusSchema: z.ZodEnum<{
65
+ unknown: "unknown";
66
+ active: "active";
67
+ ceased: "ceased";
68
+ }>;
69
+ export type RegistryActivityStatus = z.infer<typeof registryActivityStatusSchema>;
70
+ /** The registry a found answer's data came from. */
71
+ export declare const registrySourceSchema: z.ZodEnum<{
72
+ gus: "gus";
73
+ mf: "mf";
74
+ vies: "vies";
75
+ }>;
76
+ export type RegistrySource = z.infer<typeof registrySourceSchema>;
77
+ export declare const registryLookupCompanySchema: z.ZodObject<{
78
+ legalName: z.ZodNullable<z.ZodString>;
79
+ registeredAddress: z.ZodObject<{
80
+ street: z.ZodNullable<z.ZodString>;
81
+ postalCode: z.ZodNullable<z.ZodString>;
82
+ city: z.ZodNullable<z.ZodString>;
83
+ country: z.ZodString;
84
+ }, z.core.$strip>;
85
+ regon: z.ZodNullable<z.ZodString>;
86
+ vatStatus: z.ZodEnum<{
87
+ unknown: "unknown";
88
+ active: "active";
89
+ exempt: "exempt";
90
+ not_registered: "not_registered";
91
+ }>;
92
+ activityStatus: z.ZodEnum<{
93
+ unknown: "unknown";
94
+ active: "active";
95
+ ceased: "ceased";
96
+ }>;
97
+ }, z.core.$strip>;
98
+ export type RegistryLookupCompany = z.infer<typeof registryLookupCompanySchema>;
99
+ export declare const registryLookupResponseSchema: z.ZodObject<{
100
+ data: z.ZodObject<{
101
+ status: z.ZodEnum<{
102
+ not_found: "not_found";
103
+ unavailable: "unavailable";
104
+ found: "found";
105
+ invalid_tax_id: "invalid_tax_id";
106
+ unsupported_country: "unsupported_country";
107
+ }>;
108
+ lookupId: z.ZodNullable<z.ZodString>;
109
+ normalizedTaxId: z.ZodNullable<z.ZodString>;
110
+ country: z.ZodString;
111
+ source: z.ZodNullable<z.ZodEnum<{
112
+ gus: "gus";
113
+ mf: "mf";
114
+ vies: "vies";
115
+ }>>;
116
+ company: z.ZodNullable<z.ZodObject<{
117
+ legalName: z.ZodNullable<z.ZodString>;
118
+ registeredAddress: z.ZodObject<{
119
+ street: z.ZodNullable<z.ZodString>;
120
+ postalCode: z.ZodNullable<z.ZodString>;
121
+ city: z.ZodNullable<z.ZodString>;
122
+ country: z.ZodString;
123
+ }, z.core.$strip>;
124
+ regon: z.ZodNullable<z.ZodString>;
125
+ vatStatus: z.ZodEnum<{
126
+ unknown: "unknown";
127
+ active: "active";
128
+ exempt: "exempt";
129
+ not_registered: "not_registered";
130
+ }>;
131
+ activityStatus: z.ZodEnum<{
132
+ unknown: "unknown";
133
+ active: "active";
134
+ ceased: "ceased";
135
+ }>;
136
+ }, z.core.$strip>>;
137
+ fetchedAt: z.ZodNullable<z.ZodString>;
138
+ }, z.core.$strip>;
139
+ }, z.core.$strip>;
140
+ export type RegistryLookupResponse = z.infer<typeof registryLookupResponseSchema>;
141
+ export type RegistryLookupResult = RegistryLookupResponse['data'];
142
+ /** The Polish-sources mode a lookup ran under (owner decision OD-5). */
143
+ export declare const REGISTRY_LOOKUP_PL_SOURCES: readonly ["gus_mf", "gus", "mf"];
144
+ export declare const registryPlSourcesSchema: z.ZodEnum<{
145
+ gus: "gus";
146
+ mf: "mf";
147
+ gus_mf: "gus_mf";
148
+ }>;
149
+ export type RegistryPlSources = z.infer<typeof registryPlSourcesSchema>;
150
+ export declare const registryProviderSchema: z.ZodEnum<{
151
+ vies: "vies";
152
+ gus_pl: "gus_pl";
153
+ mf_pl: "mf_pl";
154
+ }>;
155
+ export type RegistryProvider = z.infer<typeof registryProviderSchema>;
156
+ export declare const registryAttemptSchema: z.ZodObject<{
157
+ provider: z.ZodEnum<{
158
+ vies: "vies";
159
+ gus_pl: "gus_pl";
160
+ mf_pl: "mf_pl";
161
+ }>;
162
+ outcome: z.ZodEnum<{
163
+ skipped: "skipped";
164
+ not_found: "not_found";
165
+ unavailable: "unavailable";
166
+ found: "found";
167
+ }>;
168
+ errorKind: z.ZodNullable<z.ZodString>;
169
+ durationMs: z.ZodNullable<z.ZodNumber>;
170
+ }, z.core.$strip>;
171
+ export type RegistryAttempt = z.infer<typeof registryAttemptSchema>;
172
+ /** What the registry said at registration, beside the existing validation columns (data-model §1.1). */
173
+ export declare const registryDetailsSchema: z.ZodObject<{
174
+ plSources: z.ZodNullable<z.ZodEnum<{
175
+ gus: "gus";
176
+ mf: "mf";
177
+ gus_mf: "gus_mf";
178
+ }>>;
179
+ dataSource: z.ZodNullable<z.ZodEnum<{
180
+ vies: "vies";
181
+ gus_pl: "gus_pl";
182
+ mf_pl: "mf_pl";
183
+ }>>;
184
+ vatStatusSource: z.ZodNullable<z.ZodEnum<{
185
+ vies: "vies";
186
+ mf_pl: "mf_pl";
187
+ }>>;
188
+ regon: z.ZodNullable<z.ZodString>;
189
+ vatPayerStatus: z.ZodEnum<{
190
+ unknown: "unknown";
191
+ active: "active";
192
+ exempt: "exempt";
193
+ not_registered: "not_registered";
194
+ }>;
195
+ activityStatus: z.ZodEnum<{
196
+ unknown: "unknown";
197
+ active: "active";
198
+ ceased: "ceased";
199
+ }>;
200
+ fetchedAt: z.ZodString;
201
+ fromCache: z.ZodBoolean;
202
+ attempts: z.ZodArray<z.ZodObject<{
203
+ provider: z.ZodEnum<{
204
+ vies: "vies";
205
+ gus_pl: "gus_pl";
206
+ mf_pl: "mf_pl";
207
+ }>;
208
+ outcome: z.ZodEnum<{
209
+ skipped: "skipped";
210
+ not_found: "not_found";
211
+ unavailable: "unavailable";
212
+ found: "found";
213
+ }>;
214
+ errorKind: z.ZodNullable<z.ZodString>;
215
+ durationMs: z.ZodNullable<z.ZodNumber>;
216
+ }, z.core.$strip>>;
217
+ }, z.core.$strip>;
218
+ export type RegistryDetails = z.infer<typeof registryDetailsSchema>;
219
+ /** What the registrant submitted, captured at registration (data-model §1.2). No personal data. */
220
+ export declare const submittedCompanyValuesSchema: z.ZodObject<{
221
+ name: z.ZodString;
222
+ taxId: z.ZodString;
223
+ registeredAddress: z.ZodObject<{
224
+ street: z.ZodString;
225
+ postalCode: z.ZodString;
226
+ city: z.ZodString;
227
+ country: z.ZodString;
228
+ }, z.core.$strip>;
229
+ }, z.core.$strip>;
230
+ export type SubmittedCompanyValues = z.infer<typeof submittedCompanyValuesSchema>;
231
+ export declare const REGISTRY_DIVERGENCE_FIELDS: readonly ["name", "street", "postalCode", "city", "country"];
232
+ export declare const registryDivergenceSchema: z.ZodObject<{
233
+ field: z.ZodEnum<{
234
+ street: "street";
235
+ city: "city";
236
+ postalCode: "postalCode";
237
+ country: "country";
238
+ name: "name";
239
+ }>;
240
+ registry: z.ZodString;
241
+ submitted: z.ZodString;
242
+ }, z.core.$strip>;
243
+ export type RegistryDivergence = z.infer<typeof registryDivergenceSchema>;
244
+ export declare const vatValidationProviderSchema: z.ZodEnum<{
245
+ vies: "vies";
246
+ gus_pl: "gus_pl";
247
+ mf_pl: "mf_pl";
248
+ format_only: "format_only";
249
+ }>;
250
+ export declare const vatValidationOutcomeSchema: z.ZodEnum<{
251
+ failed: "failed";
252
+ deferred: "deferred";
253
+ validated: "validated";
254
+ unverified: "unverified";
255
+ }>;
256
+ export declare const vatReturnedAddressSchema: z.ZodObject<{
257
+ line1: z.ZodOptional<z.ZodNullable<z.ZodString>>;
258
+ line2: z.ZodOptional<z.ZodNullable<z.ZodString>>;
259
+ postalCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
260
+ city: z.ZodOptional<z.ZodNullable<z.ZodString>>;
261
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
262
+ }, z.core.$strip>;
263
+ /** One row of an Organization's VAT validation history, as the admin API answers it. */
264
+ export declare const organizationTaxIdValidationRecordSchema: z.ZodObject<{
265
+ id: z.ZodString;
266
+ provider: z.ZodEnum<{
267
+ vies: "vies";
268
+ gus_pl: "gus_pl";
269
+ mf_pl: "mf_pl";
270
+ format_only: "format_only";
271
+ }>;
272
+ outcome: z.ZodEnum<{
273
+ failed: "failed";
274
+ deferred: "deferred";
275
+ validated: "validated";
276
+ unverified: "unverified";
277
+ }>;
278
+ taxIdValue: z.ZodString;
279
+ legalNameReturned: z.ZodNullable<z.ZodString>;
280
+ addressReturned: z.ZodNullable<z.ZodObject<{
281
+ line1: z.ZodOptional<z.ZodNullable<z.ZodString>>;
282
+ line2: z.ZodOptional<z.ZodNullable<z.ZodString>>;
283
+ postalCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
284
+ city: z.ZodOptional<z.ZodNullable<z.ZodString>>;
285
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
286
+ }, z.core.$strip>>;
287
+ errorKind: z.ZodNullable<z.ZodString>;
288
+ requestedByAdminUserId: z.ZodNullable<z.ZodString>;
289
+ createdAt: z.ZodString;
290
+ origin: z.ZodEnum<{
291
+ admin: "admin";
292
+ registration: "registration";
293
+ }>;
294
+ registryDetails: z.ZodNullable<z.ZodObject<{
295
+ plSources: z.ZodNullable<z.ZodEnum<{
296
+ gus: "gus";
297
+ mf: "mf";
298
+ gus_mf: "gus_mf";
299
+ }>>;
300
+ dataSource: z.ZodNullable<z.ZodEnum<{
301
+ vies: "vies";
302
+ gus_pl: "gus_pl";
303
+ mf_pl: "mf_pl";
304
+ }>>;
305
+ vatStatusSource: z.ZodNullable<z.ZodEnum<{
306
+ vies: "vies";
307
+ mf_pl: "mf_pl";
308
+ }>>;
309
+ regon: z.ZodNullable<z.ZodString>;
310
+ vatPayerStatus: z.ZodEnum<{
311
+ unknown: "unknown";
312
+ active: "active";
313
+ exempt: "exempt";
314
+ not_registered: "not_registered";
315
+ }>;
316
+ activityStatus: z.ZodEnum<{
317
+ unknown: "unknown";
318
+ active: "active";
319
+ ceased: "ceased";
320
+ }>;
321
+ fetchedAt: z.ZodString;
322
+ fromCache: z.ZodBoolean;
323
+ attempts: z.ZodArray<z.ZodObject<{
324
+ provider: z.ZodEnum<{
325
+ vies: "vies";
326
+ gus_pl: "gus_pl";
327
+ mf_pl: "mf_pl";
328
+ }>;
329
+ outcome: z.ZodEnum<{
330
+ skipped: "skipped";
331
+ not_found: "not_found";
332
+ unavailable: "unavailable";
333
+ found: "found";
334
+ }>;
335
+ errorKind: z.ZodNullable<z.ZodString>;
336
+ durationMs: z.ZodNullable<z.ZodNumber>;
337
+ }, z.core.$strip>>;
338
+ }, z.core.$strip>>;
339
+ submittedValues: z.ZodNullable<z.ZodObject<{
340
+ name: z.ZodString;
341
+ taxId: z.ZodString;
342
+ registeredAddress: z.ZodObject<{
343
+ street: z.ZodString;
344
+ postalCode: z.ZodString;
345
+ city: z.ZodString;
346
+ country: z.ZodString;
347
+ }, z.core.$strip>;
348
+ }, z.core.$strip>>;
349
+ divergence: z.ZodNullable<z.ZodArray<z.ZodObject<{
350
+ field: z.ZodEnum<{
351
+ street: "street";
352
+ city: "city";
353
+ postalCode: "postalCode";
354
+ country: "country";
355
+ name: "name";
356
+ }>;
357
+ registry: z.ZodString;
358
+ submitted: z.ZodString;
359
+ }, z.core.$strip>>>;
360
+ }, z.core.$strip>;
361
+ export type OrganizationTaxIdValidationRecord = z.infer<typeof organizationTaxIdValidationRecordSchema>;
362
+ //# sourceMappingURL=organization-registry-lookup.d.ts.map
@@ -0,0 +1,196 @@
1
+ import { z } from 'zod';
2
+ import { isoDateTimeSchema } from './common.js';
3
+ /**
4
+ * Feature 173 — the company registry lookup at storefront registration
5
+ * (`specs/173-registration-registry-lookup/contracts/public-api.md`,
6
+ * `contracts/admin-surfaces.md` §6, data-model §6). Owner: `organizations`.
7
+ *
8
+ * A buyer registering a business types a Polish NIP or an EU VAT number; the
9
+ * platform answers what the public registry (GUS REGON, the Ministry of Finance
10
+ * VAT White List, VIES) knows about the company, and the registration later
11
+ * carries the `lookupId` back so the snapshot the buyer was shown is persisted
12
+ * from the platform's own store — never from anything the client sends.
13
+ *
14
+ * Every status, VAT status, activity status and source is a **machine token**:
15
+ * the storefront and the admin translate them (research R-18).
16
+ *
17
+ * This file imports nothing from `organizations.ts` at run time: that file
18
+ * imports {@link registryLookupIdSchema} from here for the register body.
19
+ */
20
+ /**
21
+ * The countries the lookup serves: Poland (GUS / White List) and the VIES
22
+ * member states. VIES spells Greece `EL` and Northern Ireland `XI`; the form's
23
+ * country picker sends ISO `GR`, which the backend normaliser maps to `EL`.
24
+ */
25
+ export const REGISTRY_LOOKUP_COUNTRIES = [
26
+ 'PL',
27
+ 'AT',
28
+ 'BE',
29
+ 'BG',
30
+ 'CY',
31
+ 'CZ',
32
+ 'DE',
33
+ 'DK',
34
+ 'EE',
35
+ 'EL',
36
+ 'ES',
37
+ 'FI',
38
+ 'FR',
39
+ 'HR',
40
+ 'HU',
41
+ 'IE',
42
+ 'IT',
43
+ 'LT',
44
+ 'LU',
45
+ 'LV',
46
+ 'MT',
47
+ 'NL',
48
+ 'PT',
49
+ 'RO',
50
+ 'SE',
51
+ 'SI',
52
+ 'SK',
53
+ 'XI',
54
+ ];
55
+ /**
56
+ * The picker form of a lookup country: `GR` for Greece, every other code as it
57
+ * is. What `registration-options` lists and what a lookup answer's `country`
58
+ * carries, so a client can select it in an ISO country picker.
59
+ */
60
+ export function registryLookupCountryForPicker(country) {
61
+ return country === 'EL' ? 'GR' : country;
62
+ }
63
+ /** The lookup reference: 32 random bytes, base64url, no padding. */
64
+ export const registryLookupIdSchema = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
65
+ // --- GET /api/v1/organizations/registration-options --------------------------
66
+ export const registrationOptionsResponseSchema = z.object({
67
+ data: z.object({
68
+ registryLookup: z.object({
69
+ enabled: z.boolean(),
70
+ /** Countries the lookup serves; `[]` when disabled. Picker form (GR, not EL). */
71
+ countries: z.array(z.string().length(2)),
72
+ }),
73
+ }),
74
+ });
75
+ // --- POST /api/v1/organizations/registry-lookup ------------------------------
76
+ export const registryLookupRequestSchema = z.object({
77
+ /** As typed: spaces, dashes, dots and an EU prefix are accepted. */
78
+ taxId: z.string().trim().min(1).max(32),
79
+ /** The country chosen in the form; an EU prefix in `taxId` overrides it. */
80
+ country: z
81
+ .string()
82
+ .length(2)
83
+ .transform((c) => c.toUpperCase()),
84
+ });
85
+ export const REGISTRY_LOOKUP_STATUSES = [
86
+ 'found',
87
+ 'not_found',
88
+ 'unavailable',
89
+ 'invalid_tax_id',
90
+ 'unsupported_country',
91
+ ];
92
+ export const registryLookupStatusSchema = z.enum(REGISTRY_LOOKUP_STATUSES);
93
+ export const registryVatStatusSchema = z.enum(['active', 'exempt', 'not_registered', 'unknown']);
94
+ export const registryActivityStatusSchema = z.enum(['active', 'ceased', 'unknown']);
95
+ /** The registry a found answer's data came from. */
96
+ export const registrySourceSchema = z.enum(['gus', 'mf', 'vies']);
97
+ export const registryLookupCompanySchema = z.object({
98
+ legalName: z.string().nullable(),
99
+ /** Field names match `registerOrganizationRequestSchema.organization.registeredAddress`. */
100
+ registeredAddress: z.object({
101
+ street: z.string().nullable(),
102
+ postalCode: z.string().nullable(),
103
+ city: z.string().nullable(),
104
+ country: z.string().length(2),
105
+ }),
106
+ regon: z.string().nullable(),
107
+ vatStatus: registryVatStatusSchema,
108
+ activityStatus: registryActivityStatusSchema,
109
+ });
110
+ export const registryLookupResponseSchema = z.object({
111
+ data: z.object({
112
+ status: registryLookupStatusSchema,
113
+ /** Present for found / not_found / unavailable; send it back on registration. */
114
+ lookupId: registryLookupIdSchema.nullable(),
115
+ /** The normalised identifier the lookup used, e.g. "5260250995"; null when invalid. */
116
+ normalizedTaxId: z.string().nullable(),
117
+ /** The country the lookup used (an EU prefix may have changed it). Picker form: GR, not EL. */
118
+ country: z.string().length(2),
119
+ /** The registry the company data came from; null unless found. */
120
+ source: registrySourceSchema.nullable(),
121
+ company: registryLookupCompanySchema.nullable(),
122
+ fetchedAt: isoDateTimeSchema.nullable(),
123
+ }),
124
+ });
125
+ // --- Admin: GET /api/v1/admin/organizations/:id/vat-validations item ---------
126
+ /** The Polish-sources mode a lookup ran under (owner decision OD-5). */
127
+ export const REGISTRY_LOOKUP_PL_SOURCES = ['gus_mf', 'gus', 'mf'];
128
+ export const registryPlSourcesSchema = z.enum(REGISTRY_LOOKUP_PL_SOURCES);
129
+ export const registryProviderSchema = z.enum(['gus_pl', 'mf_pl', 'vies']);
130
+ export const registryAttemptSchema = z.object({
131
+ provider: registryProviderSchema,
132
+ outcome: z.enum(['found', 'not_found', 'unavailable', 'skipped']),
133
+ /** 'not_configured', 'excluded_by_setting', 'budget_exhausted', 'network_timeout', … */
134
+ errorKind: z.string().nullable(),
135
+ durationMs: z.number().int().nonnegative().nullable(),
136
+ });
137
+ /** What the registry said at registration, beside the existing validation columns (data-model §1.1). */
138
+ export const registryDetailsSchema = z.object({
139
+ /** The Polish-sources mode the lookup ran under; null for a non-Polish lookup (always VIES). */
140
+ plSources: registryPlSourcesSchema.nullable(),
141
+ dataSource: registryProviderSchema.nullable(),
142
+ vatStatusSource: z.enum(['mf_pl', 'vies']).nullable(),
143
+ regon: z.string().nullable(),
144
+ vatPayerStatus: registryVatStatusSchema,
145
+ activityStatus: registryActivityStatusSchema,
146
+ /** When the registries answered — may precede the row's `createdAt` by up to the ticket TTL. */
147
+ fetchedAt: isoDateTimeSchema,
148
+ /** Whether the answer was served from the platform's cache. */
149
+ fromCache: z.boolean(),
150
+ attempts: z.array(registryAttemptSchema),
151
+ });
152
+ /** What the registrant submitted, captured at registration (data-model §1.2). No personal data. */
153
+ export const submittedCompanyValuesSchema = z.object({
154
+ name: z.string(),
155
+ taxId: z.string(),
156
+ registeredAddress: z.object({
157
+ street: z.string(),
158
+ postalCode: z.string(),
159
+ city: z.string(),
160
+ country: z.string(),
161
+ }),
162
+ });
163
+ export const REGISTRY_DIVERGENCE_FIELDS = ['name', 'street', 'postalCode', 'city', 'country'];
164
+ export const registryDivergenceSchema = z.object({
165
+ field: z.enum(REGISTRY_DIVERGENCE_FIELDS),
166
+ registry: z.string(),
167
+ submitted: z.string(),
168
+ });
169
+ export const vatValidationProviderSchema = z.enum(['vies', 'mf_pl', 'format_only', 'gus_pl']);
170
+ export const vatValidationOutcomeSchema = z.enum(['validated', 'failed', 'deferred', 'unverified']);
171
+ export const vatReturnedAddressSchema = z.object({
172
+ line1: z.string().nullable().optional(),
173
+ line2: z.string().nullable().optional(),
174
+ postalCode: z.string().nullable().optional(),
175
+ city: z.string().nullable().optional(),
176
+ countryCode: z.string().nullable().optional(),
177
+ });
178
+ /** One row of an Organization's VAT validation history, as the admin API answers it. */
179
+ export const organizationTaxIdValidationRecordSchema = z.object({
180
+ id: z.string().uuid(),
181
+ provider: vatValidationProviderSchema,
182
+ outcome: vatValidationOutcomeSchema,
183
+ taxIdValue: z.string(),
184
+ legalNameReturned: z.string().nullable(),
185
+ addressReturned: vatReturnedAddressSchema.nullable(),
186
+ errorKind: z.string().nullable(),
187
+ requestedByAdminUserId: z.string().nullable(),
188
+ createdAt: isoDateTimeSchema,
189
+ /** `admin` — an administrator's "Validate now"; `registration` — the lookup a self-registration carried. */
190
+ origin: z.enum(['admin', 'registration']),
191
+ registryDetails: registryDetailsSchema.nullable(),
192
+ submittedValues: submittedCompanyValuesSchema.nullable(),
193
+ /** Computed on read; `null` for an admin row, `[]` for a registration row that matches. */
194
+ divergence: z.array(registryDivergenceSchema).nullable(),
195
+ });
196
+ //# sourceMappingURL=organization-registry-lookup.js.map