@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.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/dist/actor.d.ts +79 -0
- package/dist/actor.d.ts.map +1 -0
- package/dist/actor.js +41 -0
- package/dist/actor.js.map +1 -0
- package/dist/addresses.d.ts +134 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +16 -0
- package/dist/addresses.js.map +1 -0
- package/dist/admin-actions.d.ts +367 -0
- package/dist/admin-actions.d.ts.map +1 -0
- package/dist/admin-actions.js +287 -0
- package/dist/admin-actions.js.map +1 -0
- package/dist/admin-contributions.d.ts +518 -0
- package/dist/admin-contributions.d.ts.map +1 -0
- package/dist/admin-contributions.js +495 -0
- package/dist/admin-contributions.js.map +1 -0
- package/dist/admin-i18n.d.ts +135 -0
- package/dist/admin-i18n.d.ts.map +1 -0
- package/dist/admin-i18n.js +72 -0
- package/dist/admin-i18n.js.map +1 -0
- package/dist/admin-notifications.d.ts +55 -0
- package/dist/admin-notifications.d.ts.map +1 -0
- package/dist/admin-notifications.js +16 -0
- package/dist/admin-notifications.js.map +1 -0
- package/dist/admin-roles.d.ts +125 -0
- package/dist/admin-roles.d.ts.map +1 -0
- package/dist/admin-roles.js +2 -0
- package/dist/admin-roles.js.map +1 -0
- package/dist/admin-users.d.ts +178 -0
- package/dist/admin-users.d.ts.map +1 -0
- package/dist/admin-users.js +14 -0
- package/dist/admin-users.js.map +1 -0
- package/dist/admin.d.ts +243 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +246 -0
- package/dist/admin.js.map +1 -0
- package/dist/analytics.d.ts +123 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +68 -0
- package/dist/analytics.js.map +1 -0
- package/dist/api-keys.d.ts +97 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +64 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/assets-library.d.ts +684 -0
- package/dist/assets-library.d.ts.map +1 -0
- package/dist/assets-library.js +181 -0
- package/dist/assets-library.js.map +1 -0
- package/dist/audit-logs.d.ts +141 -0
- package/dist/audit-logs.d.ts.map +1 -0
- package/dist/audit-logs.js +31 -0
- package/dist/audit-logs.js.map +1 -0
- package/dist/auth.d.ts +174 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +27 -0
- package/dist/auth.js.map +1 -0
- package/dist/blog.d.ts +669 -0
- package/dist/blog.d.ts.map +1 -0
- package/dist/blog.js +360 -0
- package/dist/blog.js.map +1 -0
- package/dist/capabilities.d.ts +40 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +38 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/carts.d.ts +1367 -0
- package/dist/carts.d.ts.map +1 -0
- package/dist/carts.js +405 -0
- package/dist/carts.js.map +1 -0
- package/dist/catalog.d.ts +2855 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +1543 -0
- package/dist/catalog.js.map +1 -0
- package/dist/cms.d.ts +872 -0
- package/dist/cms.d.ts.map +1 -0
- package/dist/cms.js +468 -0
- package/dist/cms.js.map +1 -0
- package/dist/common.d.ts +82 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +72 -0
- package/dist/common.js.map +1 -0
- package/dist/comparisons.d.ts +487 -0
- package/dist/comparisons.d.ts.map +1 -0
- package/dist/comparisons.js +221 -0
- package/dist/comparisons.js.map +1 -0
- package/dist/credentials.d.ts +292 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +142 -0
- package/dist/credentials.js.map +1 -0
- package/dist/credit-limits.d.ts +111 -0
- package/dist/credit-limits.d.ts.map +1 -0
- package/dist/credit-limits.js +35 -0
- package/dist/credit-limits.js.map +1 -0
- package/dist/currencies.d.ts +127 -0
- package/dist/currencies.d.ts.map +1 -0
- package/dist/currencies.js +20 -0
- package/dist/currencies.js.map +1 -0
- package/dist/custom-fields.d.ts +345 -0
- package/dist/custom-fields.d.ts.map +1 -0
- package/dist/custom-fields.js +185 -0
- package/dist/custom-fields.js.map +1 -0
- package/dist/customer-accounts.d.ts +690 -0
- package/dist/customer-accounts.d.ts.map +1 -0
- package/dist/customer-accounts.js +41 -0
- package/dist/customer-accounts.js.map +1 -0
- package/dist/customers.d.ts +305 -0
- package/dist/customers.d.ts.map +1 -0
- package/dist/customers.js +158 -0
- package/dist/customers.js.map +1 -0
- package/dist/dictionary.d.ts +580 -0
- package/dist/dictionary.d.ts.map +1 -0
- package/dist/dictionary.js +297 -0
- package/dist/dictionary.js.map +1 -0
- package/dist/email-address.d.ts +62 -0
- package/dist/email-address.d.ts.map +1 -0
- package/dist/email-address.js +64 -0
- package/dist/email-address.js.map +1 -0
- package/dist/email.d.ts +175 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +45 -0
- package/dist/email.js.map +1 -0
- package/dist/envelopes.d.ts +15 -0
- package/dist/envelopes.d.ts.map +1 -0
- package/dist/envelopes.js +16 -0
- package/dist/envelopes.js.map +1 -0
- package/dist/environment-inputs.d.ts +306 -0
- package/dist/environment-inputs.d.ts.map +1 -0
- package/dist/environment-inputs.js +277 -0
- package/dist/environment-inputs.js.map +1 -0
- package/dist/erp-connector.d.ts +52 -0
- package/dist/erp-connector.d.ts.map +1 -0
- package/dist/erp-connector.js +34 -0
- package/dist/erp-connector.js.map +1 -0
- package/dist/errors.d.ts +455 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +532 -0
- package/dist/errors.js.map +1 -0
- package/dist/google-analytics.d.ts +181 -0
- package/dist/google-analytics.d.ts.map +1 -0
- package/dist/google-analytics.js +176 -0
- package/dist/google-analytics.js.map +1 -0
- package/dist/google-tag-manager.d.ts +111 -0
- package/dist/google-tag-manager.d.ts.map +1 -0
- package/dist/google-tag-manager.js +129 -0
- package/dist/google-tag-manager.js.map +1 -0
- package/dist/i18n.d.ts +69 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +59 -0
- package/dist/i18n.js.map +1 -0
- package/dist/import-export.d.ts +63 -0
- package/dist/import-export.d.ts.map +1 -0
- package/dist/import-export.js +37 -0
- package/dist/import-export.js.map +1 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory.d.ts +673 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +412 -0
- package/dist/inventory.js.map +1 -0
- package/dist/invoice-ledger.d.ts +366 -0
- package/dist/invoice-ledger.d.ts.map +1 -0
- package/dist/invoice-ledger.js +114 -0
- package/dist/invoice-ledger.js.map +1 -0
- package/dist/invoices.d.ts +845 -0
- package/dist/invoices.d.ts.map +1 -0
- package/dist/invoices.js +314 -0
- package/dist/invoices.js.map +1 -0
- package/dist/kernel.d.ts +49 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +19 -0
- package/dist/kernel.js.map +1 -0
- package/dist/languages.d.ts +122 -0
- package/dist/languages.d.ts.map +1 -0
- package/dist/languages.js +24 -0
- package/dist/languages.js.map +1 -0
- package/dist/linkedin-ads.d.ts +167 -0
- package/dist/linkedin-ads.d.ts.map +1 -0
- package/dist/linkedin-ads.js +156 -0
- package/dist/linkedin-ads.js.map +1 -0
- package/dist/megamenu.d.ts +556 -0
- package/dist/megamenu.d.ts.map +1 -0
- package/dist/megamenu.js +186 -0
- package/dist/megamenu.js.map +1 -0
- package/dist/meta-ads.d.ts +126 -0
- package/dist/meta-ads.d.ts.map +1 -0
- package/dist/meta-ads.js +112 -0
- package/dist/meta-ads.js.map +1 -0
- package/dist/mfa.d.ts +274 -0
- package/dist/mfa.d.ts.map +1 -0
- package/dist/mfa.js +187 -0
- package/dist/mfa.js.map +1 -0
- package/dist/modules.d.ts +1706 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +1390 -0
- package/dist/modules.js.map +1 -0
- package/dist/newsletter.d.ts +611 -0
- package/dist/newsletter.d.ts.map +1 -0
- package/dist/newsletter.js +345 -0
- package/dist/newsletter.js.map +1 -0
- package/dist/orders.d.ts +1175 -0
- package/dist/orders.d.ts.map +1 -0
- package/dist/orders.js +630 -0
- package/dist/orders.js.map +1 -0
- package/dist/organizations.d.ts +938 -0
- package/dist/organizations.d.ts.map +1 -0
- package/dist/organizations.js +418 -0
- package/dist/organizations.js.map +1 -0
- package/dist/pagination.d.ts +21 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +22 -0
- package/dist/pagination.js.map +1 -0
- package/dist/payment-methods.d.ts +472 -0
- package/dist/payment-methods.d.ts.map +1 -0
- package/dist/payment-methods.js +175 -0
- package/dist/payment-methods.js.map +1 -0
- package/dist/payment-return-url.d.ts +53 -0
- package/dist/payment-return-url.d.ts.map +1 -0
- package/dist/payment-return-url.js +35 -0
- package/dist/payment-return-url.js.map +1 -0
- package/dist/payments.d.ts +386 -0
- package/dist/payments.d.ts.map +1 -0
- package/dist/payments.js +84 -0
- package/dist/payments.js.map +1 -0
- package/dist/pim-connector.d.ts +60 -0
- package/dist/pim-connector.d.ts.map +1 -0
- package/dist/pim-connector.js +43 -0
- package/dist/pim-connector.js.map +1 -0
- package/dist/pim-field-path.d.ts +6 -0
- package/dist/pim-field-path.d.ts.map +1 -0
- package/dist/pim-field-path.js +101 -0
- package/dist/pim-field-path.js.map +1 -0
- package/dist/platform-language.d.ts +20 -0
- package/dist/platform-language.d.ts.map +1 -0
- package/dist/platform-language.js +22 -0
- package/dist/platform-language.js.map +1 -0
- package/dist/price-lists.d.ts +685 -0
- package/dist/price-lists.d.ts.map +1 -0
- package/dist/price-lists.js +330 -0
- package/dist/price-lists.js.map +1 -0
- package/dist/product-feeds.d.ts +2837 -0
- package/dist/product-feeds.d.ts.map +1 -0
- package/dist/product-feeds.js +1504 -0
- package/dist/product-feeds.js.map +1 -0
- package/dist/product-scope-overrides.d.ts +134 -0
- package/dist/product-scope-overrides.d.ts.map +1 -0
- package/dist/product-scope-overrides.js +82 -0
- package/dist/product-scope-overrides.js.map +1 -0
- package/dist/product-value-resolver.d.ts +88 -0
- package/dist/product-value-resolver.d.ts.map +1 -0
- package/dist/product-value-resolver.js +128 -0
- package/dist/product-value-resolver.js.map +1 -0
- package/dist/promotions.d.ts +678 -0
- package/dist/promotions.d.ts.map +1 -0
- package/dist/promotions.js +479 -0
- package/dist/promotions.js.map +1 -0
- package/dist/prompt-actions.d.ts +582 -0
- package/dist/prompt-actions.d.ts.map +1 -0
- package/dist/prompt-actions.js +221 -0
- package/dist/prompt-actions.js.map +1 -0
- package/dist/pwa.d.ts +293 -0
- package/dist/pwa.d.ts.map +1 -0
- package/dist/pwa.js +204 -0
- package/dist/pwa.js.map +1 -0
- package/dist/quick-order.d.ts +340 -0
- package/dist/quick-order.d.ts.map +1 -0
- package/dist/quick-order.js +177 -0
- package/dist/quick-order.js.map +1 -0
- package/dist/quote-requests.d.ts +538 -0
- package/dist/quote-requests.d.ts.map +1 -0
- package/dist/quote-requests.js +308 -0
- package/dist/quote-requests.js.map +1 -0
- package/dist/returns.d.ts +774 -0
- package/dist/returns.d.ts.map +1 -0
- package/dist/returns.js +389 -0
- package/dist/returns.js.map +1 -0
- package/dist/sales-channels.d.ts +392 -0
- package/dist/sales-channels.d.ts.map +1 -0
- package/dist/sales-channels.js +285 -0
- package/dist/sales-channels.js.map +1 -0
- package/dist/scope-notice.d.ts +60 -0
- package/dist/scope-notice.d.ts.map +1 -0
- package/dist/scope-notice.js +56 -0
- package/dist/scope-notice.js.map +1 -0
- package/dist/search.d.ts +321 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +160 -0
- package/dist/search.js.map +1 -0
- package/dist/seo.d.ts +113 -0
- package/dist/seo.d.ts.map +1 -0
- package/dist/seo.js +63 -0
- package/dist/seo.js.map +1 -0
- package/dist/settings.d.ts +453 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +337 -0
- package/dist/settings.js.map +1 -0
- package/dist/shipments.d.ts +140 -0
- package/dist/shipments.d.ts.map +1 -0
- package/dist/shipments.js +14 -0
- package/dist/shipments.js.map +1 -0
- package/dist/shipping-methods.d.ts +350 -0
- package/dist/shipping-methods.d.ts.map +1 -0
- package/dist/shipping-methods.js +99 -0
- package/dist/shipping-methods.js.map +1 -0
- package/dist/shopping-lists.d.ts +122 -0
- package/dist/shopping-lists.d.ts.map +1 -0
- package/dist/shopping-lists.js +92 -0
- package/dist/shopping-lists.js.map +1 -0
- package/dist/taxes.d.ts +106 -0
- package/dist/taxes.d.ts.map +1 -0
- package/dist/taxes.js +80 -0
- package/dist/taxes.js.map +1 -0
- package/dist/text-normalization.d.ts +199 -0
- package/dist/text-normalization.d.ts.map +1 -0
- package/dist/text-normalization.js +205 -0
- package/dist/text-normalization.js.map +1 -0
- package/dist/transactional-emails.d.ts +459 -0
- package/dist/transactional-emails.d.ts.map +1 -0
- package/dist/transactional-emails.js +212 -0
- package/dist/transactional-emails.js.map +1 -0
- package/dist/webhooks.d.ts +69 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +53 -0
- package/dist/webhooks.js.map +1 -0
- 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.
|
package/dist/actor.d.ts
ADDED
|
@@ -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"}
|