@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Endora sp. z o.o. and the Endora Commerce contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ <!-- Generated by `pnpm --filter backend run manifests:generate`. Delete this line to take the file over; a README without it is never regenerated. -->
2
+
3
+ # @endora-commerce/contracts
4
+
5
+ Source-of-truth Zod schemas shared across backend, storefront, admin (Principle V). The backend regenerates its live OpenAPI document from these at startup.
6
+
7
+ ## What this is
8
+
9
+ A shared library package of **Endora Commerce**, the modular B2B/B2C commerce platform. It declares no module manifest, so the platform composes nothing from it: what is published here is what the platform and the modules built on it compile against.
10
+
11
+ ## Entry points
12
+
13
+ - `@endora-commerce/contracts`
14
+ - `@endora-commerce/contracts/*`
15
+
16
+ ## Depends on
17
+
18
+ **Bundled dependencies**
19
+
20
+ - `zod` ^4.2.0
21
+
22
+ ## What the tarball carries
23
+
24
+ - `dist/` — the compiled JavaScript and its type declarations
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ pnpm add @endora-commerce/contracts
30
+ ```
31
+
32
+ ## Licence
33
+
34
+ MIT — the text is in `LICENSE`, beside this file.
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The **actor** a request carries: who is asking, as four kinds and nothing
3
+ * else (`specs/110-instance-repository/` T118b).
4
+ *
5
+ * ## Why it is here rather than in `@endora-commerce/mod-auth`
6
+ *
7
+ * `auth` resolves the actor and writes it onto the request, so the shape lived
8
+ * beside that implementation — and the Fastify augmentation that puts it on
9
+ * `FastifyRequest` lived there with it. That made every reader of
10
+ * `request.actor` a consumer of a module: `backend/src/composition.ts` named
11
+ * `@endora-commerce/mod-auth/backend` for a type it erases at build time, the
12
+ * platform restated the shape structurally in four places because D-52/D-53
13
+ * forbids it the import, and a packaged module read it through a hand-written
14
+ * cast per module.
15
+ *
16
+ * The blocker on relocating it was believed to be `Session`: `auth`'s own
17
+ * barrel said moving the augmentation *"would take `Session` with it"*, because
18
+ * `ActorCustomer` and `ActorAdmin` each carried the ORM entity. Measured across
19
+ * `packages/`, `backend/`, `admin/` and `storefront/`, **no file outside
20
+ * `packages/modules/auth/` ever read `actor.session`** — `composition.ts` alone
21
+ * reads `kind`, `adminUserId`, `organizationId`, `customerAccountId`,
22
+ * `impersonatorAdminUserId` and `apiKeyId`, and `.session` not once. So the
23
+ * field was written by the auth plugin on every request and read by nobody, and
24
+ * dropping it is what lets the vocabulary sit in a package that imports neither
25
+ * Fastify nor the ORM.
26
+ *
27
+ * A consumer that needs the *session* asks `auth` for it — `AuthSessionPort`
28
+ * and `AuthSessionReadPort` in `./auth.js` are that surface, and they carry
29
+ * `AuthSessionRecord` rather than the entity.
30
+ *
31
+ * ## Where the Fastify augmentation lives
32
+ *
33
+ * Not here. `@endora-commerce/contracts` declares no dependency on Fastify, for
34
+ * the reason `RequireCustomerGuard` and `AdminActorPromotion` are in the
35
+ * platform's `kernel/ports/require-admin.ts` rather than in this package. The
36
+ * `declare module 'fastify'` block that adds `actor` and `adminActor` to
37
+ * `FastifyRequest` is `@endora-commerce/platform`'s
38
+ * (`src/http/request-actor.ts`), on the `./http` subpath.
39
+ */
40
+ /** No identified caller. The fail-closed end of every audience question. */
41
+ export interface ActorAnonymous {
42
+ kind: 'anonymous';
43
+ }
44
+ export interface ActorCustomer {
45
+ kind: 'customer';
46
+ customerAccountId: string;
47
+ /**
48
+ * The buyer's Organization (Principle XI). Nullable at this seam rather than
49
+ * by design: every transacting customer has one — `organization_id` is
50
+ * `NOT NULL` and an individual is backed by a personal organisation — but the
51
+ * auth plugin stamps `''` when no resolver is wired, and a guest-style
52
+ * account predating feature 026 can still present without one. A consumer
53
+ * that requires an Organization asserts it (`customerContextResolver`).
54
+ */
55
+ organizationId: string | null;
56
+ /** Non-null when a Supplier employee is acting on behalf of this Customer. */
57
+ impersonatorAdminUserId: string | null;
58
+ }
59
+ export interface ActorAdmin {
60
+ kind: 'admin';
61
+ adminUserId: string;
62
+ }
63
+ /**
64
+ * An integration authenticated by a bearer key (feature 062). All three binding
65
+ * fields are set for a **bound** distributor key and absent for a legacy
66
+ * unbound one: the tenant-context mapping derives single-org scope from them
67
+ * and the sales-channel resolver pins the channel, failing closed on a header
68
+ * that names a different one.
69
+ */
70
+ export interface ActorApiKey {
71
+ kind: 'api_key';
72
+ apiKeyId: string;
73
+ scopes: string[];
74
+ organizationId?: string | null;
75
+ salesChannelId?: string | null;
76
+ customerAccountId?: string | null;
77
+ }
78
+ export type Actor = ActorAnonymous | ActorCustomer | ActorAdmin | ActorApiKey;
79
+ //# sourceMappingURL=actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../src/actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,8EAA8E;IAC9E,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,KAAK,GAAG,cAAc,GAAG,aAAa,GAAG,UAAU,GAAG,WAAW,CAAC"}
package/dist/actor.js ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The **actor** a request carries: who is asking, as four kinds and nothing
3
+ * else (`specs/110-instance-repository/` T118b).
4
+ *
5
+ * ## Why it is here rather than in `@endora-commerce/mod-auth`
6
+ *
7
+ * `auth` resolves the actor and writes it onto the request, so the shape lived
8
+ * beside that implementation — and the Fastify augmentation that puts it on
9
+ * `FastifyRequest` lived there with it. That made every reader of
10
+ * `request.actor` a consumer of a module: `backend/src/composition.ts` named
11
+ * `@endora-commerce/mod-auth/backend` for a type it erases at build time, the
12
+ * platform restated the shape structurally in four places because D-52/D-53
13
+ * forbids it the import, and a packaged module read it through a hand-written
14
+ * cast per module.
15
+ *
16
+ * The blocker on relocating it was believed to be `Session`: `auth`'s own
17
+ * barrel said moving the augmentation *"would take `Session` with it"*, because
18
+ * `ActorCustomer` and `ActorAdmin` each carried the ORM entity. Measured across
19
+ * `packages/`, `backend/`, `admin/` and `storefront/`, **no file outside
20
+ * `packages/modules/auth/` ever read `actor.session`** — `composition.ts` alone
21
+ * reads `kind`, `adminUserId`, `organizationId`, `customerAccountId`,
22
+ * `impersonatorAdminUserId` and `apiKeyId`, and `.session` not once. So the
23
+ * field was written by the auth plugin on every request and read by nobody, and
24
+ * dropping it is what lets the vocabulary sit in a package that imports neither
25
+ * Fastify nor the ORM.
26
+ *
27
+ * A consumer that needs the *session* asks `auth` for it — `AuthSessionPort`
28
+ * and `AuthSessionReadPort` in `./auth.js` are that surface, and they carry
29
+ * `AuthSessionRecord` rather than the entity.
30
+ *
31
+ * ## Where the Fastify augmentation lives
32
+ *
33
+ * Not here. `@endora-commerce/contracts` declares no dependency on Fastify, for
34
+ * the reason `RequireCustomerGuard` and `AdminActorPromotion` are in the
35
+ * platform's `kernel/ports/require-admin.ts` rather than in this package. The
36
+ * `declare module 'fastify'` block that adds `actor` and `adminActor` to
37
+ * `FastifyRequest` is `@endora-commerce/platform`'s
38
+ * (`src/http/request-actor.ts`), on the `./http` subpath.
39
+ */
40
+ export {};
41
+ //# sourceMappingURL=actor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.js","sourceRoot":"","sources":["../src/actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * `addresses` module contracts — the in-process port surface (feature 075,
3
+ * Phase P).
4
+ *
5
+ * Ten inbound sites, split six-four: `orders` and `organizations` type
6
+ * themselves against `AddressService` to create, list and delete an
7
+ * organisation's addresses, and four read the `Address` entity directly —
8
+ * `orders` snapshotting one onto a placed order, `customers` serialising one,
9
+ * `quick_order` resolving a buyer's default.
10
+ *
11
+ * Plain TypeScript rather than Zod: these describe in-process calls. The HTTP
12
+ * shapes are `organizations.ts`' business, because that module serves the
13
+ * customer-facing address routes over this module's table.
14
+ */
15
+ export type AddressKindValue = 'delivery' | 'billing';
16
+ /**
17
+ * An address as it crosses a module boundary — a plain shape, never the ORM
18
+ * entity (FR-011).
19
+ *
20
+ * Every address belongs to an organisation, and there is no other kind: the
21
+ * Organization is the one tenant concept (Principle XI), and a B2C buyer's
22
+ * personal organisation holds theirs.
23
+ */
24
+ export interface AddressRecord {
25
+ id: string;
26
+ organizationId: string;
27
+ kind: AddressKindValue;
28
+ recipientName: string;
29
+ street: string;
30
+ city: string;
31
+ postalCode: string;
32
+ country: string;
33
+ phone: string | null;
34
+ isDefault: boolean;
35
+ createdAt: Date;
36
+ updatedAt: Date;
37
+ deletedAt: Date | null;
38
+ }
39
+ export interface CreateAddressInput {
40
+ kind: AddressKindValue;
41
+ recipientName: string;
42
+ street: string;
43
+ city: string;
44
+ postalCode: string;
45
+ country: string;
46
+ phone?: string;
47
+ isDefault?: boolean;
48
+ }
49
+ export type UpdateAddressInput = Partial<{
50
+ recipientName: string;
51
+ street: string;
52
+ city: string;
53
+ postalCode: string;
54
+ country: string;
55
+ phone: string;
56
+ isDefault: boolean;
57
+ }>;
58
+ /**
59
+ * Container name: `addressReadPort`. Owner: `addresses`.
60
+ *
61
+ * The four direct entity reads. `findById` is scoped by organisation on
62
+ * purpose: every caller already knows whose address it is asking for, and
63
+ * doing the check in one query is what stops it being forgotten.
64
+ *
65
+ * **`liveOnly` defaults to `false`: a by-id read returns a soft-deleted
66
+ * address.** The two lookups differ from the two lists on purpose — an address
67
+ * is soft-deleted, and `findById` / `findByIds` are how a caller resolves an id
68
+ * something else already stored, where "the row is gone" and "the row was
69
+ * deleted after it was referenced" are different answers and only the second is
70
+ * renderable. `listForOrganization` and `findDefault` are the opposite case —
71
+ * they are choosing an address to use *now* — so they filter `deletedAt: null`
72
+ * unconditionally and take no flag at all.
73
+ *
74
+ * The consequence, said plainly because it is one careless cut from a product
75
+ * change: a consumer replacing a hand-written `deletedAt: null` filter with
76
+ * `findById` and dropping the filter as "now redundant" reinstates deleted
77
+ * addresses. Pass `{ liveOnly: true }` whenever the answer feeds a choice
78
+ * rather than a rendering — all three call sites in the tree do
79
+ * (`orders/services/order-service.ts:989,1093,1096`). The record also carries
80
+ * `deletedAt`, so a caller that must tell the two apart can (Phase-P
81
+ * unreached-port audit, A8).
82
+ *
83
+ * **Owner off:** the seam fails closed — resolving this port throws
84
+ * `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`, so nothing
85
+ * half-executes. Whether `addresses` has an off state at all is its manifest's
86
+ * `activation` to say, not this line's: a module declaring
87
+ * `nonDeactivatable` never enters one.
88
+ */
89
+ export interface AddressReadPort {
90
+ findById(organizationId: string, addressId: string, options?: {
91
+ liveOnly?: boolean;
92
+ }): Promise<AddressRecord | null>;
93
+ findByIds(organizationId: string, addressIds: readonly string[], options?: {
94
+ liveOnly?: boolean;
95
+ }): Promise<AddressRecord[]>;
96
+ /** An organisation's addresses, optionally of one kind, default first. */
97
+ listForOrganization(organizationId: string, kind?: AddressKindValue): Promise<AddressRecord[]>;
98
+ /** The organisation's default address of that kind, or `null`. */
99
+ findDefault(organizationId: string, kind: AddressKindValue): Promise<AddressRecord | null>;
100
+ }
101
+ /**
102
+ * Container name: `addressServicePort`. Owner: `addresses`.
103
+ *
104
+ * (It said `addressService` until issue #192, and that name **is** registered:
105
+ * it is the `AddressService` **class**, whose methods return `Address`
106
+ * entities. `Address` is structurally assignable to `AddressRecord`, so a
107
+ * consumer copying the old name out of this comment gets entities across the
108
+ * boundary behind a record-shaped type and `tsc` says nothing — the mapping
109
+ * `createAddressServicePort` performs is exactly what it skips. Two consumers
110
+ * followed it, `orders/backend.ts` and `organizations/backend.ts`; issue #195
111
+ * re-pointed both at `addressServicePort` under D-98.1, which ruled the call
112
+ * site wrong rather than this shape — every one of their six call sites reads
113
+ * fields or `.id` off the result, so the snapshot record is all any of them
114
+ * ever needed. The class registration stays for the module's own use.)
115
+ *
116
+ * The write surface `orders` and `organizations` reach. The
117
+ * one-default-per-kind invariant and the country-code validation stay on this
118
+ * side of the port, where they already are — `createAddress` validates the
119
+ * country against `dictionaries` before it writes, and a caller cannot be
120
+ * trusted to remember that.
121
+ *
122
+ * **Owner off:** the seam fails closed — resolving this port throws
123
+ * `ModuleDisabledError` and the call answers 503 `MODULE_DISABLED`, so nothing
124
+ * half-executes. Whether `addresses` has an off state at all is its manifest's
125
+ * `activation` to say, not this line's: a module declaring
126
+ * `nonDeactivatable` never enters one.
127
+ */
128
+ export interface AddressServicePort {
129
+ list(organizationId: string, kind?: AddressKindValue): Promise<AddressRecord[]>;
130
+ createAddress(organizationId: string, input: CreateAddressInput): Promise<AddressRecord>;
131
+ updateAddress(organizationId: string, addressId: string, patch: UpdateAddressInput): Promise<AddressRecord>;
132
+ deleteAddress(organizationId: string, addressId: string): Promise<void>;
133
+ }
134
+ //# sourceMappingURL=addresses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../src/addresses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,gBAAgB,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CACN,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAC/B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACjC,SAAS,CACP,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAC/B,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5B,0EAA0E;IAC1E,mBAAmB,CACjB,cAAc,EAAE,MAAM,EACtB,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5B,kEAAkE;IAClE,WAAW,CACT,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAChF,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzF,aAAa,CACX,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1B,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `addresses` module contracts — the in-process port surface (feature 075,
3
+ * Phase P).
4
+ *
5
+ * Ten inbound sites, split six-four: `orders` and `organizations` type
6
+ * themselves against `AddressService` to create, list and delete an
7
+ * organisation's addresses, and four read the `Address` entity directly —
8
+ * `orders` snapshotting one onto a placed order, `customers` serialising one,
9
+ * `quick_order` resolving a buyer's default.
10
+ *
11
+ * Plain TypeScript rather than Zod: these describe in-process calls. The HTTP
12
+ * shapes are `organizations.ts`' business, because that module serves the
13
+ * customer-facing address routes over this module's table.
14
+ */
15
+ export {};
16
+ //# sourceMappingURL=addresses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addresses.js","sourceRoot":"","sources":["../src/addresses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}