@smess/networking 2.0.0 → 2.2.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 (31) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +43 -2
  3. package/dist/core/hosts.d.ts +4 -0
  4. package/dist/core/hosts.d.ts.map +1 -1
  5. package/dist/core/hosts.js +4 -0
  6. package/dist/core/hosts.js.map +1 -1
  7. package/dist/modules/authentication/index.d.ts +19 -0
  8. package/dist/modules/authentication/index.d.ts.map +1 -1
  9. package/dist/modules/authentication/index.js +15 -0
  10. package/dist/modules/authentication/index.js.map +1 -1
  11. package/dist/modules/messenger/index.d.ts +92 -0
  12. package/dist/modules/messenger/index.d.ts.map +1 -0
  13. package/dist/modules/messenger/index.js +44 -0
  14. package/dist/modules/messenger/index.js.map +1 -0
  15. package/dist/modules/storefront/index.d.ts +160 -0
  16. package/dist/modules/storefront/index.d.ts.map +1 -0
  17. package/dist/modules/storefront/index.js +176 -0
  18. package/dist/modules/storefront/index.js.map +1 -0
  19. package/dist/modules/storefront/types.d.ts +499 -0
  20. package/dist/modules/storefront/types.d.ts.map +1 -0
  21. package/dist/modules/storefront/types.js +8 -0
  22. package/dist/modules/storefront/types.js.map +1 -0
  23. package/dist/modules/storefront-admin/index.d.ts +85 -0
  24. package/dist/modules/storefront-admin/index.d.ts.map +1 -0
  25. package/dist/modules/storefront-admin/index.js +80 -0
  26. package/dist/modules/storefront-admin/index.js.map +1 -0
  27. package/dist/modules/storefront-admin/types.d.ts +295 -0
  28. package/dist/modules/storefront-admin/types.d.ts.map +1 -0
  29. package/dist/modules/storefront-admin/types.js +2 -0
  30. package/dist/modules/storefront-admin/types.js.map +1 -0
  31. package/package.json +14 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to `@smess/networking`. Versions follow [semver](https://semver.org).
4
4
 
5
+ ## 2.2.0 (2026-11-07)
6
+
7
+ ### Added
8
+
9
+ - `@smess/networking/storefront`: the shop customer side of core's Storefront module (`/v1/storefront/*`):
10
+ catalog, stores, promos, cart, checkout, orders, profile and addresses, store metadata, favorites and
11
+ the contact message. `storeId` option → `X-Store-Id`; the guest cart token is kept in a
12
+ `CartTokenStore` (`memoryCartToken()` by default) and sent as `X-Nonce-Token` while signed out.
13
+ - `@smess/networking/storefront-admin`: the shop back office (`/v1/storefront/admin/*`): products,
14
+ orders (update, confirm, reject, status, resend confirmation), promos, customers, search, stores.
15
+ - `authentication(client).registerCustomer()`: shop sign-up (`POST /v1/authentication/customer/register`),
16
+ saves the session.
17
+ - `storefront` host key in `PRODUCTION_HOSTS` (`api.smess.vn`).
18
+ - `scripts/smoke-storefront.mjs`: read-only checks against a live storefront (`make smoke-storefront`).
19
+
20
+ ## 2.1.0 (2026-11-07)
21
+
22
+ ### Added
23
+
24
+ - `@smess/networking/messenger`: `send` (website contact forms and leads, `POST /v1/messenger/send`), `get`
25
+ and `trackWebsiteEvent` (`POST /v1/messenger/website_events`). Anonymous; the tenant goes in the body's
26
+ `client_id` (defaults to the client's `clientId`), so one build can serve domains whose CORS origins are
27
+ bound to different tenants.
28
+ - `messenger` host key in `PRODUCTION_HOSTS` (`api.smess.vn`).
29
+
5
30
  ## 2.0.0 (2026-11-07)
6
31
 
7
32
  A rewrite: one typed client for core-services, built on `fetch`. Not compatible with 1.x.
package/README.md CHANGED
@@ -6,7 +6,8 @@ React Native.
6
6
 
7
7
  - Built on `fetch`, no runtime dependencies, ESM, typed.
8
8
  - One client per app: it knows core's hosts, the tenant header, the session and its refresh.
9
- - One module per core-services Microservice: `authentication`, `sso`, `campaign`, `smeup-file`, `danara`.
9
+ - One module per core-services Microservice: `authentication`, `sso`, `campaign`, `smeup-file`, `danara`,
10
+ `messenger`, `storefront`, `storefront-admin`.
10
11
  - One error type, `SmessApiError`, for every error format core emits.
11
12
 
12
13
  Layers and the backend facts behind them: [docs/architecture.md](docs/architecture.md).
@@ -38,6 +39,42 @@ await auth.otp.verify({ identifier: email, code }); // saves the session
38
39
  const templates = await campaign(smess).email.templates.list(); // ApiList<Template>
39
40
  ```
40
41
 
42
+ ### Public website form (smess.vn)
43
+
44
+ ```ts
45
+ import { createSmessClient, PRODUCTION_HOSTS } from '@smess/networking';
46
+ import { messenger } from '@smess/networking/messenger';
47
+
48
+ const forms = messenger(createSmessClient({ hosts: PRODUCTION_HOSTS }));
49
+ await forms.send({
50
+ client_id: TENANT_ID, // the tenant that owns the site's leads
51
+ type: 'contact_form', // never lead_capture on a contact form: that starts a Rebuild job
52
+ from_name, from_email, subject, message,
53
+ });
54
+ ```
55
+
56
+ ### Online shop (Grand Paris Marché)
57
+
58
+ ```ts
59
+ import { createSmessClient, PRODUCTION_HOSTS, webStorageSession } from '@smess/networking';
60
+ import { authenticationRefresh } from '@smess/networking/authentication';
61
+ import { storefront } from '@smess/networking/storefront';
62
+
63
+ const smess = createSmessClient({
64
+ hosts: PRODUCTION_HOSTS,
65
+ clientId: SHOP_TENANT_ID, // scopes the catalog, stores and promos
66
+ session: webStorageSession(),
67
+ refresh: authenticationRefresh(),
68
+ });
69
+ const shop = storefront(smess, { storeId: () => selectedStoreId, cartToken: myCartTokenStore });
70
+
71
+ const page = await shop.products.list({ category: 'epice', per_page: 24 }); // Paginated<Product>
72
+ await shop.cart.addItem({ product_id: page.items[0].id, quantity: 1 }); // guest token kept for you
73
+ ```
74
+
75
+ The back office uses `storefrontAdmin(smess, { storeId })` from `@smess/networking/storefront-admin`
76
+ with a store employee's session.
77
+
41
78
  ### Tenant-scoped app, Next.js server component (Danara)
42
79
 
43
80
  ```ts
@@ -115,11 +152,14 @@ never sends one. smeup.email sends none (the tenant comes from the JWT); Danara
115
152
 
116
153
  | Import | Backend module | Host key | Notes |
117
154
  |---|---|---|---|
118
- | `@smess/networking/authentication` | Authentication | `authentication` | password, OTP, refresh, reset, change password, logout |
155
+ | `@smess/networking/authentication` | Authentication | `authentication` | password, OTP, refresh, reset, change password, logout, shop customer sign-up |
119
156
  | `@smess/networking/sso` | Sso | `sso` | `start`, `completeLogin(location.hash)`, `parseSsoCallback`, `readSsoError` |
120
157
  | `@smess/networking/campaign` | Campaign (email) | `campaignApi` | the whole smeup.email API: sender, templates, campaigns, audiences, domains, addresses, short links, segments, automations, A/B tests, developers, SSO settings |
121
158
  | `@smess/networking/smeup-file` | SMEUpFile | `smeupFile` | base64 upload |
122
159
  | `@smess/networking/danara` | Danara | `danara` | identity, listings, sales, fit-out, leasing, owner portal, transit |
160
+ | `@smess/networking/messenger` | Messenger | `messenger` | website contact forms and leads (`send`), visitor events (`trackWebsiteEvent`) |
161
+ | `@smess/networking/storefront` | Storefront | `storefront` | shop customer side: catalog, stores, promos, cart (guest token as `X-Nonce-Token`), checkout, orders, profile and addresses, favorites, contact |
162
+ | `@smess/networking/storefront-admin` | Storefront (admin) | `storefront` | shop back office: products, orders (confirm, reject, status), promos, customers, search, stores |
123
163
  | `@smess/networking/rx` | – | – | `fromSmess(signal => call)` → cancellable Observable (peer dep `rxjs`) |
124
164
 
125
165
  Each module also exports its endpoint table (`campaignEmailEndpoints`, `danaraEndpoints`, …) and its
@@ -175,6 +215,7 @@ transformer or DTO, and a line in the route table snapshot (`test/__snapshots__`
175
215
  make install # npm ci
176
216
  make check # lint, typecheck, tests, build, publint
177
217
  make smoke # read-only checks of the built package against PROD Danara (DANARA_CLIENT_ID=… make smoke)
218
+ make smoke-storefront # same against a PROD shop (STOREFRONT_CLIENT_ID=… make smoke-storefront)
178
219
  ```
179
220
 
180
221
  Try a local build in an app without publishing: `npm pack`, then in the app
@@ -10,6 +10,10 @@ export declare const PRODUCTION_HOSTS: {
10
10
  readonly campaignApi: "https://api.smess.vn";
11
11
  /** `app.smeup_file_host`: file uploads (`/v1/smeup-files/*`). */
12
12
  readonly smeupFile: "https://api.smess.vn";
13
+ /** `app.messenger_host`: public website forms and visitor events (`/v1/messenger/*`). */
14
+ readonly messenger: "https://api.smess.vn";
15
+ /** `app.storefront_host`: online shops, customer and back office (`/v1/storefront/*`). */
16
+ readonly storefront: "https://api.smess.vn";
13
17
  /** `app.sso_host`: company single sign-on (`/v1/sso/*`). */
14
18
  readonly sso: "https://sso.smess.vn";
15
19
  /** `app.danara_host`: the Danara rentals API. */
@@ -1 +1 @@
1
- {"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../../src/core/hosts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IAC3B,sEAAsE;;IAEtE,iFAAiF;;IAEjF,iEAAiE;;IAEjE,4DAA4D;;IAE5D,iDAAiD;;IAEjD,+CAA+C;;IAE/C,sEAAsE;;CAE9D,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAEvD,qHAAqH;AACrH,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../../src/core/hosts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IAC3B,sEAAsE;;IAEtE,iFAAiF;;IAEjF,iEAAiE;;IAEjE,yFAAyF;;IAEzF,0FAA0F;;IAE1F,4DAA4D;;IAE5D,iDAAiD;;IAEjD,+CAA+C;;IAE/C,sEAAsE;;CAE9D,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAEvD,qHAAqH;AACrH,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC"}
@@ -10,6 +10,10 @@ export const PRODUCTION_HOSTS = {
10
10
  campaignApi: 'https://api.smess.vn',
11
11
  /** `app.smeup_file_host`: file uploads (`/v1/smeup-files/*`). */
12
12
  smeupFile: 'https://api.smess.vn',
13
+ /** `app.messenger_host`: public website forms and visitor events (`/v1/messenger/*`). */
14
+ messenger: 'https://api.smess.vn',
15
+ /** `app.storefront_host`: online shops, customer and back office (`/v1/storefront/*`). */
16
+ storefront: 'https://api.smess.vn',
13
17
  /** `app.sso_host`: company single sign-on (`/v1/sso/*`). */
14
18
  sso: 'https://sso.smess.vn',
15
19
  /** `app.danara_host`: the Danara rentals API. */
@@ -1 +1 @@
1
- {"version":3,"file":"hosts.js","sourceRoot":"","sources":["../../src/core/hosts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,sEAAsE;IACtE,cAAc,EAAE,uBAAuB;IACvC,iFAAiF;IACjF,WAAW,EAAE,sBAAsB;IACnC,iEAAiE;IACjE,SAAS,EAAE,sBAAsB;IACjC,4DAA4D;IAC5D,GAAG,EAAE,sBAAsB;IAC3B,iDAAiD;IACjD,MAAM,EAAE,uBAAuB;IAC/B,+CAA+C;IAC/C,MAAM,EAAE,yBAAyB;IACjC,sEAAsE;IACtE,SAAS,EAAE,uBAAuB;CAC1B,CAAC"}
1
+ {"version":3,"file":"hosts.js","sourceRoot":"","sources":["../../src/core/hosts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,sEAAsE;IACtE,cAAc,EAAE,uBAAuB;IACvC,iFAAiF;IACjF,WAAW,EAAE,sBAAsB;IACnC,iEAAiE;IACjE,SAAS,EAAE,sBAAsB;IACjC,yFAAyF;IACzF,SAAS,EAAE,sBAAsB;IACjC,0FAA0F;IAC1F,UAAU,EAAE,sBAAsB;IAClC,4DAA4D;IAC5D,GAAG,EAAE,sBAAsB;IAC3B,iDAAiD;IACjD,MAAM,EAAE,uBAAuB;IAC/B,+CAA+C;IAC/C,MAAM,EAAE,yBAAyB;IACjC,sEAAsE;IACtE,SAAS,EAAE,uBAAuB;CAC1B,CAAC"}
@@ -38,6 +38,17 @@ export interface ResetPasswordInput {
38
38
  token: string;
39
39
  new_password: string;
40
40
  }
41
+ /** `RegisterRequestDto`: a shop customer account for one tenant (an existing user gets a customer for it). */
42
+ export interface CustomerRegisterInput {
43
+ /** The tenant; defaults to the client's `clientId`. */
44
+ client_id?: string;
45
+ email: string;
46
+ password: string;
47
+ phone_number?: string | null;
48
+ name?: string | null;
49
+ address?: string | null;
50
+ tax_identification_number?: string | null;
51
+ }
41
52
  export interface ChangePasswordInput {
42
53
  old_password: string;
43
54
  password: string;
@@ -53,6 +64,9 @@ export declare const authenticationEndpoints: {
53
64
  readonly otpVerify: import("../../core/endpoint.js").Endpoint<"/v1/authentication/otp/verify", OtpVerifyInput, never, {
54
65
  data: AuthenticationSucceeded | null;
55
66
  }>;
67
+ readonly customerRegister: import("../../core/endpoint.js").Endpoint<"/v1/authentication/customer/register", CustomerRegisterInput, never, {
68
+ data: AuthenticationSucceeded | null;
69
+ }>;
56
70
  readonly forgotPassword: import("../../core/endpoint.js").Endpoint<"/v1/authentication/forgot-password", IdentifierInput, never, undefined>;
57
71
  readonly resetPassword: import("../../core/endpoint.js").Endpoint<"/v1/authentication/verify-reset-password-token", ResetPasswordInput, never, {
58
72
  data: AuthenticationSucceeded | null;
@@ -74,6 +88,11 @@ export declare function authentication(client: SmessClient): {
74
88
  /** Exchanges the code for a session. A wrong or expired code fails with `validation` / `invalid_code`. */
75
89
  verify: (input: OtpVerifyInput) => Promise<Session>;
76
90
  };
91
+ /**
92
+ * Creates a shop customer account for the tenant and signs in (`{data: {token, refreshToken}}`).
93
+ * Validation errors (blank email or password, bad `client_id`) are 400 `validation`.
94
+ */
95
+ registerCustomer: (input: CustomerRegisterInput) => Promise<Session>;
77
96
  /** Sends a reset link. Always succeeds. */
78
97
  forgotPassword: (input: IdentifierInput) => Promise<undefined>;
79
98
  /** Sets a new password from a reset-link token and signs in. A bad token fails with `invalid_reset_token`. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/authentication/index.ts"],"names":[],"mappings":"AAAA;;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0GAA0G;wBACpF,cAAc;;IAItC,2CAA2C;4BACnB,eAAe;IAEvC,8GAA8G;2BACjF,kBAAkB;4BAGvB,mBAAmB;IAE3C;;;OAGG;;EASN;AAED,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/authentication/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAItD,uEAAuE;AACvE,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,mEAAmE;AACnE,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,2FAA2F;IAC3F,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,8GAA8G;AAC9G,MAAM,WAAW,qBAAqB;IACpC,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yBAAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAMD,eAAO,MAAM,uBAAuB;;;uBAOkB,MAAM;;;;cAaxB,uBAAuB,GAAG,IAAI;;;cAMvB,uBAAuB,GAAG,IAAI;;;;cAajC,uBAAuB,GAAG,IAAI;;;;CAoB5D,CAAC;AAoBX,iHAAiH;AACjH,wBAAgB,qBAAqB,IAAI,eAAe,CAQvD;AAID,6GAA6G;AAC7G,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW;IAQ9C,sBAAsB;mBACD,UAAU;IAE/B,sGAAsG;6BACvE,MAAM;;QAOnC,qGAAqG;yBACpF,eAAe;QAChC,0GAA0G;wBACpF,cAAc;;IAItC;;;OAGG;8BAC6B,qBAAqB;IAMrD,2CAA2C;4BACnB,eAAe;IAEvC,8GAA8G;2BACjF,kBAAkB;4BAGvB,mBAAmB;IAE3C;;;OAGG;;EASN;AAED,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -29,6 +29,12 @@ export const authenticationEndpoints = {
29
29
  path: '/v1/authentication/otp/verify',
30
30
  auth: 'none',
31
31
  }),
32
+ customerRegister: defineEndpoint()({
33
+ service: AUTH,
34
+ method: 'POST',
35
+ path: '/v1/authentication/customer/register',
36
+ auth: 'none',
37
+ }),
32
38
  forgotPassword: defineEndpoint()({
33
39
  service: AUTH,
34
40
  method: 'POST',
@@ -106,6 +112,15 @@ export function authentication(client) {
106
112
  /** Exchanges the code for a session. A wrong or expired code fails with `validation` / `invalid_code`. */
107
113
  verify: async (input) => save(fromSucceeded(await client.call(e.otpVerify, { body: input }), 'invalid_code', 'The code is invalid or has expired.')),
108
114
  },
115
+ /**
116
+ * Creates a shop customer account for the tenant and signs in (`{data: {token, refreshToken}}`).
117
+ * Validation errors (blank email or password, bad `client_id`) are 400 `validation`.
118
+ */
119
+ registerCustomer: async (input) => {
120
+ const clientId = input.client_id ?? client.config.clientId;
121
+ const body = clientId ? { ...input, client_id: clientId } : input;
122
+ return save(fromSucceeded(await client.call(e.customerRegister, { body }), 'registration_failed', 'The account could not be created.'));
123
+ },
109
124
  /** Sends a reset link. Always succeeds. */
110
125
  forgotPassword: (input) => client.call(e.forgotPassword, { body: input }),
111
126
  /** Sets a new password from a reset-link token and signs in. A bad token fails with `invalid_reset_token`. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/authentication/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AA8ChE,yEAAyE;AAEzE,MAAM,IAAI,GAAG,gBAAyB,CAAC;AAEvC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,KAAK,EAAE,cAAc,EAAyB,CAAC;QAC7C,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,gCAAgC;QACtC,IAAI,EAAE,MAAM;KACb,CAAC;IACF,OAAO,EAAE,cAAc,EAAwC,CAAC;QAC9D,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,kCAAkC;QACxC,IAAI,EAAE,MAAM;KACb,CAAC;IACF,UAAU,EAAE,cAAc,EAA8B,CAAC;QACvD,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,gCAAgC;QACtC,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,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,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAE9F;;;WAGG;QACH,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAC9B,CAAC;oBAAS,CAAC;gBACT,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC/B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Messenger module (`src/Microservice/Messenger`, host `app.messenger_host` → api.smess.vn): public
3
+ * website forms and visitor events.
4
+ *
5
+ * - Every route is anonymous (`auth: 'none'`). There is no `security: false` firewall on these paths, so
6
+ * a stale Bearer would 401 them: the module never sends one.
7
+ * - The owning tenant is the body's `client_id`; `X-Client-Id` is optional. Leave `clientId` off the
8
+ * client when one build serves several domains whose CORS origins are bound to different tenants
9
+ * (core answers 403 when the header disagrees with the origin's tenant). The module fills `client_id`
10
+ * from the client's `clientId` when the input has none.
11
+ * - `send` does not validate the body (the DTO constraints are not run): keep fields short;
12
+ * `from_phone_number` is a 20-character column.
13
+ * - Saved messages are forwarded to the tenant's Livechat inbox when contact-form forwarding is on for that
14
+ * client (Admin → client → Livechat).
15
+ */
16
+ import type { SmessClient } from '../../core/client.js';
17
+ import type { CallOptions } from '../../core/endpoint.js';
18
+ /**
19
+ * `contact_form` for website contact forms. `lead_capture` also creates a CRM prospect and starts a Rebuild
20
+ * pipeline job (rebuild.vn only). `demo_*` are the Rebuild demo-site CTAs and need `site_id`.
21
+ */
22
+ export type MessengerType = 'contact_form' | 'lead_capture' | 'order' | 'default' | 'monitoring' | 'demo_contract_request' | 'demo_cooperation_request' | (string & Record<never, never>);
23
+ export interface MessengerSendInput {
24
+ /** The owning tenant (Authentication Client UUID). Defaults to the client's `clientId`. */
25
+ client_id?: string;
26
+ /** Default `default`. */
27
+ type?: MessengerType;
28
+ from_name?: string;
29
+ from_email?: string;
30
+ /** ≤ 20 characters (database column). */
31
+ from_phone_number?: string;
32
+ subject?: string;
33
+ message?: string;
34
+ /** `[a-z0-9][a-z0-9-]{0,63}`; required for `demo_*` types. */
35
+ site_id?: string;
36
+ /** Your own reference for the message. */
37
+ external_id?: string;
38
+ }
39
+ /** `MessengerGetDto`, plain `json_encode` (camelCase, nulls kept). */
40
+ export interface MessengerMessage {
41
+ id: string;
42
+ type: MessengerType;
43
+ fromIpAddress: string | null;
44
+ fromName: string | null;
45
+ fromEmail: string | null;
46
+ fromPhoneNumber: string | null;
47
+ subject: string | null;
48
+ message: string | null;
49
+ siteId: string | null;
50
+ }
51
+ export type WebsiteEventName = 'website_viewed' | 'contact_form_opened' | 'contact_form_submitted' | 'contact_form_failed' | 'livechat_opened' | 'livechat_started' | 'livechat_message_sent' | 'lead_created' | 'demo_cta_clicked' | 'contract_booking_started' | 'cooperation_requested';
52
+ export interface WebsiteEventInput {
53
+ /** Defaults to the client's `clientId`; the client must exist. */
54
+ client_id?: string;
55
+ /** `[a-z0-9][a-z0-9-]{0,63}`. */
56
+ site_id: string;
57
+ event: WebsiteEventName;
58
+ /** Per-tab visitor session, ≤ 64. */
59
+ session_id?: string;
60
+ page_url?: string;
61
+ referrer?: string;
62
+ /** ATOM date-time, e.g. `2026-11-07T10:00:00+07:00`. */
63
+ occurred_at?: string;
64
+ /** A Rebuild demo site. */
65
+ demo?: boolean;
66
+ /** ≤ 20 snake_case keys with scalar values (strings ≤ 500). */
67
+ properties?: Record<string, string | number | boolean | null>;
68
+ }
69
+ export interface WebsiteEventAccepted {
70
+ object: 'website_event';
71
+ event: WebsiteEventName;
72
+ accepted: true;
73
+ }
74
+ export declare const messengerEndpoints: {
75
+ readonly send: import("../../core/endpoint.js").Endpoint<"/v1/messenger/send", MessengerSendInput & {
76
+ client_id: string;
77
+ }, never, MessengerMessage>;
78
+ readonly get: import("../../core/endpoint.js").Endpoint<"/v1/messenger/{id}/information", never, never, MessengerMessage>;
79
+ readonly websiteEvent: import("../../core/endpoint.js").Endpoint<"/v1/messenger/website_events", WebsiteEventInput & {
80
+ client_id: string;
81
+ }, never, WebsiteEventAccepted>;
82
+ };
83
+ export declare function messenger(client: SmessClient): {
84
+ /** Saves a website message (contact form, lead, ...) for the tenant. */
85
+ send: (input: MessengerSendInput, o?: CallOptions) => Promise<MessengerMessage>;
86
+ /** A saved message by id. */
87
+ get: (id: string, o?: CallOptions) => Promise<MessengerMessage>;
88
+ /** Records a visitor event (202); 60 per minute per IP and site. */
89
+ trackWebsiteEvent: (input: WebsiteEventInput, o?: CallOptions) => Promise<WebsiteEventAccepted>;
90
+ };
91
+ export type MessengerModule = ReturnType<typeof messenger>;
92
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/messenger/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,cAAc,GACd,OAAO,GACP,SAAS,GACT,YAAY,GACZ,uBAAuB,GACvB,0BAA0B,GAC1B,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAEpC,MAAM,WAAW,kBAAkB;IACjC,2FAA2F;IAC3F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC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CAAC;CAC/D;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC;CAChB;AAED,eAAO,MAAM,kBAAkB;;mBAC4C,MAAM;;;;mBAcK,MAAM;;CAMlF,CAAC;AAEX,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW;IAWzC,wEAAwE;kBACpD,kBAAkB,MAAM,WAAW;IAEvD,6BAA6B;cACnB,MAAM,MAAM,WAAW;IACjC,oEAAoE;+BACnC,iBAAiB,MAAM,WAAW;EAGtE;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { unwrapData } from '../../core/decoders.js';
2
+ import { defineEndpoint } from '../../core/endpoint.js';
3
+ import { SmessApiError } from '../../errors/smess-api-error.js';
4
+ export const messengerEndpoints = {
5
+ send: defineEndpoint()({
6
+ service: 'messenger',
7
+ method: 'POST',
8
+ path: '/v1/messenger/send',
9
+ auth: 'none',
10
+ decode: unwrapData,
11
+ }),
12
+ get: defineEndpoint()({
13
+ service: 'messenger',
14
+ method: 'GET',
15
+ path: '/v1/messenger/{id}/information',
16
+ auth: 'none',
17
+ decode: unwrapData,
18
+ }),
19
+ websiteEvent: defineEndpoint()({
20
+ service: 'messenger',
21
+ method: 'POST',
22
+ path: '/v1/messenger/website_events',
23
+ auth: 'none',
24
+ }),
25
+ };
26
+ export function messenger(client) {
27
+ const e = messengerEndpoints;
28
+ const tenantOf = (clientId) => {
29
+ const value = clientId ?? client.config.clientId;
30
+ if (!value) {
31
+ throw new SmessApiError({ kind: 'config', code: 'missing_client_id', message: 'Messenger needs a client_id (input or client clientId).' });
32
+ }
33
+ return value;
34
+ };
35
+ return {
36
+ /** Saves a website message (contact form, lead, ...) for the tenant. */
37
+ send: async (input, o) => client.call(e.send, { ...o, body: { ...input, client_id: tenantOf(input.client_id) } }),
38
+ /** A saved message by id. */
39
+ get: (id, o) => client.call(e.get, { ...o, path: { id } }),
40
+ /** Records a visitor event (202); 60 per minute per IP and site. */
41
+ trackWebsiteEvent: async (input, o) => client.call(e.websiteEvent, { ...o, body: { ...input, client_id: tenantOf(input.client_id) } }),
42
+ };
43
+ }
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/messenger/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAmFhE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,cAAc,EAAgE,CAAC;QACnF,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,UAAU;KACnB,CAAC;IACF,GAAG,EAAE,cAAc,EAAoB,CAAC;QACtC,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,gCAAgC;QACtC,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,UAAU;KACnB,CAAC;IACF,YAAY,EAAE,cAAc,EAAmE,CAAC;QAC9F,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,8BAA8B;QACpC,IAAI,EAAE,MAAM;KACb,CAAC;CACM,CAAC;AAEX,MAAM,UAAU,SAAS,CAAC,MAAmB;IAC3C,MAAM,CAAC,GAAG,kBAAkB,CAAC;IAC7B,MAAM,QAAQ,GAAG,CAAC,QAA4B,EAAU,EAAE;QACxD,MAAM,KAAK,GAAG,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,yDAAyD,EAAE,CAAC,CAAC;QAC7I,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,OAAO;QACL,wEAAwE;QACxE,IAAI,EAAE,KAAK,EAAE,KAAyB,EAAE,CAAe,EAAE,EAAE,CACzD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;QACzF,6BAA6B;QAC7B,GAAG,EAAE,CAAC,EAAU,EAAE,CAAe,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;QAChF,oEAAoE;QACpE,iBAAiB,EAAE,KAAK,EAAE,KAAwB,EAAE,CAAe,EAAE,EAAE,CACrE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;KAClG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Storefront module, customer side (`src/Microservice/Storefront`, host `app.storefront_host` →
3
+ * api.smess.vn, prefix `/v1/storefront`).
4
+ *
5
+ * - The tenant is `X-Client-Id` (set `clientId` on the client): it scopes the catalog, the store list and
6
+ * promos, and picks the default store.
7
+ * - The store is `X-Store-Id` (numeric id or uuid). Without it the server uses the tenant's first store.
8
+ * Pass `storeId` to the module to pin one; it is sent on every call.
9
+ * - Guest carts are identified by a token the server returns as `cart.sessionToken`. While signed out the
10
+ * module sends it as `X-Nonce-Token` (the CORS allow-list has no `X-Session-Token`) and stores each new
11
+ * one in the `cartToken` store. Signed in, the cart belongs to the customer and no token is sent.
12
+ * - Catalog routes are anonymous (`auth: 'none'`): a stale Bearer would 401 them. Cart and checkout send
13
+ * the token when there is one (`optional`); customer and order routes need it (`required`).
14
+ * - Every response is `{data: …}` and is unwrapped; the page-number lists keep their `Paginated` envelope.
15
+ */
16
+ import type { SmessClient } from '../../core/client.js';
17
+ import type { CallOptions } from '../../core/endpoint.js';
18
+ import type { MaybePromise } from '../../core/types.js';
19
+ import type { Acknowledged, AddFavoriteInput, AddToCartInput, AddressInput, CalculateShippingInput, Cart, CartBatchInput, Category, CheckoutInput, CheckoutValidation, CustomerProfile, FavoriteBatchInput, FavoriteBatchResult, FavoriteCategory, FavoriteCategoryRenamed, FavoriteProduct, FavoriteQuery, Order, OrderQuery, Paginated, Product, ProductQuery, Promo, PromoQuery, RecentSearch, RecentlyViewed, RenameFavoriteCategoryInput, Reorder, ShippingQuote, Store, StoreCustomerMetadata, StorefrontMessage, StorefrontMessageInput, TrackOrderInput, UpdateCartInput, UpdateCartItemInput, UpdateProfileInput } from './types.js';
20
+ export type * from './types.js';
21
+ export declare const storefrontEndpoints: {
22
+ readonly products: import("../../core/endpoint.js").Endpoint<"/v1/storefront/products/collection", never, ProductQuery, Paginated<Product>>;
23
+ /** Numeric id or slug. */
24
+ readonly product: import("../../core/endpoint.js").Endpoint<"/v1/storefront/products/{identifier}", never, never, Product>;
25
+ readonly categories: import("../../core/endpoint.js").Endpoint<"/v1/storefront/products/categories", never, never, Category[]>;
26
+ readonly stores: import("../../core/endpoint.js").Endpoint<"/v1/storefront/stores/list", never, never, Store[]>;
27
+ readonly store: import("../../core/endpoint.js").Endpoint<"/v1/storefront/stores/{uuid}/information", never, never, Store>;
28
+ readonly promos: import("../../core/endpoint.js").Endpoint<"/v1/storefront/promo/list", never, PromoQuery, Promo[]>;
29
+ readonly cart: import("../../core/endpoint.js").Endpoint<"/v1/storefront/cart", never, never, Cart>;
30
+ readonly updateCart: import("../../core/endpoint.js").Endpoint<"/v1/storefront/cart", UpdateCartInput, never, Cart>;
31
+ readonly addToCart: import("../../core/endpoint.js").Endpoint<"/v1/storefront/cart/items", AddToCartInput, never, Cart>;
32
+ readonly batchCartItems: import("../../core/endpoint.js").Endpoint<"/v1/storefront/cart/items/batch", CartBatchInput, never, Cart>;
33
+ readonly updateCartItem: import("../../core/endpoint.js").Endpoint<"/v1/storefront/cart/items/{cartItemId}", UpdateCartItemInput, never, Cart>;
34
+ readonly removeCartItem: import("../../core/endpoint.js").Endpoint<"/v1/storefront/cart/items/{cartItemId}", never, never, Cart | null>;
35
+ readonly clearCart: import("../../core/endpoint.js").Endpoint<"/v1/storefront/cart/items", never, never, Cart>;
36
+ readonly calculateShipping: import("../../core/endpoint.js").Endpoint<"/v1/storefront/cart/calculate-shipping", CalculateShippingInput, never, ShippingQuote>;
37
+ readonly validateCheckout: import("../../core/endpoint.js").Endpoint<"/v1/storefront/checkout/validate", never, never, CheckoutValidation>;
38
+ readonly checkout: import("../../core/endpoint.js").Endpoint<"/v1/storefront/checkout/process", CheckoutInput, never, Order>;
39
+ readonly orders: import("../../core/endpoint.js").Endpoint<"/v1/storefront/orders/collection", never, OrderQuery, Paginated<Order>>;
40
+ readonly order: import("../../core/endpoint.js").Endpoint<"/v1/storefront/orders/{id}", never, never, Order>;
41
+ readonly trackOrder: import("../../core/endpoint.js").Endpoint<"/v1/storefront/orders/track", TrackOrderInput, never, Order>;
42
+ readonly reorder: import("../../core/endpoint.js").Endpoint<"/v1/storefront/orders/{id}/reorder", never, never, Reorder>;
43
+ readonly cancelOrder: import("../../core/endpoint.js").Endpoint<"/v1/storefront/orders/{id}/cancel", never, never, Order>;
44
+ readonly profile: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/profile", never, never, CustomerProfile>;
45
+ readonly updateProfile: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/profile", UpdateProfileInput, never, CustomerProfile>;
46
+ readonly saveShippingAddress: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/shipping-addresses", AddressInput, never, CustomerProfile>;
47
+ readonly deleteShippingAddress: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/shipping-addresses/{id}", never, never, CustomerProfile>;
48
+ readonly saveBillingAddress: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/billing-addresses", AddressInput, never, CustomerProfile>;
49
+ readonly deleteBillingAddress: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/billing-addresses/{id}", never, never, CustomerProfile>;
50
+ readonly metadata: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/metadata", never, never, StoreCustomerMetadata>;
51
+ readonly updatePreferences: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/preferences", {
52
+ preferences: Record<string, unknown>;
53
+ }, never, StoreCustomerMetadata>;
54
+ readonly recordProductView: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/product-view", {
55
+ product_id: number;
56
+ }, never, Acknowledged>;
57
+ readonly recentSearches: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/recent-searches", never, never, RecentSearch[]>;
58
+ readonly recentlyViewed: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/recently-viewed", never, {
59
+ limit?: number;
60
+ }, RecentlyViewed[]>;
61
+ readonly favorites: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/favorites/collection", never, FavoriteQuery, Paginated<FavoriteProduct>>;
62
+ readonly addFavorite: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/favorites", AddFavoriteInput, never, FavoriteProduct>;
63
+ readonly renameFavoriteCategory: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/favorites/category", RenameFavoriteCategoryInput, never, FavoriteCategoryRenamed>;
64
+ readonly removeFavorite: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/favorites/{productId}", never, never, Acknowledged>;
65
+ readonly favoriteCategories: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/favorites/categories", never, never, FavoriteCategory[]>;
66
+ readonly batchFavorites: import("../../core/endpoint.js").Endpoint<"/v1/storefront/customer/favorites-batch", FavoriteBatchInput, never, FavoriteBatchResult>;
67
+ readonly sendMessage: import("../../core/endpoint.js").Endpoint<"/v1/storefront/messenger/send", StorefrontMessageInput, never, StorefrontMessage>;
68
+ };
69
+ /** Where the guest cart token lives between calls. */
70
+ export interface CartTokenStore {
71
+ get(): MaybePromise<string | null | undefined>;
72
+ set(token: string | null): MaybePromise<void>;
73
+ }
74
+ /** A cart token kept in memory (lost on reload). */
75
+ export declare function memoryCartToken(initial?: string | null): CartTokenStore;
76
+ export interface StorefrontOptions {
77
+ /** `X-Store-Id` on every call: a numeric store id or uuid, or a function read per call. */
78
+ storeId?: string | number | (() => string | number | null | undefined) | null | undefined;
79
+ /** The guest cart token store. Default: in memory. */
80
+ cartToken?: CartTokenStore | undefined;
81
+ }
82
+ export declare function storefront(client: SmessClient, options?: StorefrontOptions): {
83
+ products: {
84
+ list: (query?: ProductQuery, o?: CallOptions) => Promise<Paginated<Product>>;
85
+ /** By numeric id or slug. */
86
+ get: (identifier: string | number, o?: CallOptions) => Promise<Product>;
87
+ /** Category counts of the whole catalog. */
88
+ categories: (o?: CallOptions) => Promise<Category[]>;
89
+ };
90
+ stores: {
91
+ /** The tenant's stores (every active store without a tenant). */
92
+ list: (o?: CallOptions) => Promise<Store[]>;
93
+ /** One store with its shipping rules. */
94
+ get: (uuid: string, o?: CallOptions) => Promise<Store>;
95
+ };
96
+ promos: {
97
+ list: (query?: PromoQuery, o?: CallOptions) => Promise<Promo[]>;
98
+ };
99
+ cart: {
100
+ /** The current cart; a guest call without a token starts a new draft cart. */
101
+ get: (o?: CallOptions) => Promise<Cart>;
102
+ /** Notes, delivery fee and contact blocks. */
103
+ update: (input: UpdateCartInput, o?: CallOptions) => Promise<Cart>;
104
+ /** Adds a product (201). The guest token goes in the body, as the route reads it there. */
105
+ addItem: (input: AddToCartInput, o?: CallOptions) => Promise<Cart>;
106
+ /** Adds and updates by product id in one call; updates win over adds for the same product. */
107
+ batch: (input: CartBatchInput, o?: CallOptions) => Promise<Cart>;
108
+ updateItem: (cartItemId: string | number, input: UpdateCartItemInput, o?: CallOptions) => Promise<Cart>;
109
+ removeItem: (cartItemId: string | number, o?: CallOptions) => Promise<Cart | null>;
110
+ /** Removes every item. */
111
+ clear: (o?: CallOptions) => Promise<Cart>;
112
+ /** Needs a cart (token or session) and a store, otherwise 400. */
113
+ calculateShipping: (input: CalculateShippingInput, o?: CallOptions) => Promise<ShippingQuote>;
114
+ /** The guest cart token store, e.g. to forget the cart after an order. */
115
+ token: CartTokenStore;
116
+ };
117
+ checkout: {
118
+ validate: (o?: CallOptions) => Promise<CheckoutValidation>;
119
+ /** Places the order from `items` (201). `clientSecret` is set when the payment needs a confirmation. */
120
+ process: (input: CheckoutInput, o?: CallOptions) => Promise<Order>;
121
+ };
122
+ orders: {
123
+ list: (query?: OrderQuery, o?: CallOptions) => Promise<Paginated<Order>>;
124
+ get: (id: string | number, o?: CallOptions) => Promise<Order>;
125
+ track: (input: TrackOrderInput, o?: CallOptions) => Promise<Order>;
126
+ /** The order's products as they are now, ready to add to the cart. */
127
+ reorder: (id: string | number, o?: CallOptions) => Promise<Reorder>;
128
+ cancel: (id: string | number, o?: CallOptions) => Promise<Order>;
129
+ };
130
+ customer: {
131
+ /** Also counts a visit to the store when one is set. */
132
+ profile: (o?: CallOptions) => Promise<CustomerProfile>;
133
+ updateProfile: (input: UpdateProfileInput, o?: CallOptions) => Promise<CustomerProfile>;
134
+ /** Creates the address, or updates it when `id` is set. Returns the whole profile. */
135
+ saveShippingAddress: (input: AddressInput, o?: CallOptions) => Promise<CustomerProfile>;
136
+ deleteShippingAddress: (id: string | number, o?: CallOptions) => Promise<CustomerProfile>;
137
+ saveBillingAddress: (input: AddressInput, o?: CallOptions) => Promise<CustomerProfile>;
138
+ deleteBillingAddress: (id: string | number, o?: CallOptions) => Promise<CustomerProfile>;
139
+ /** The customer's stats in the current store (needs a store). */
140
+ metadata: (o?: CallOptions) => Promise<StoreCustomerMetadata>;
141
+ updatePreferences: (preferences: Record<string, unknown>, o?: CallOptions) => Promise<StoreCustomerMetadata>;
142
+ recordProductView: (productId: number, o?: CallOptions) => Promise<Acknowledged>;
143
+ recentSearches: (o?: CallOptions) => Promise<RecentSearch[]>;
144
+ /** Default limit 100. */
145
+ recentlyViewed: (limit?: number, o?: CallOptions) => Promise<RecentlyViewed[]>;
146
+ };
147
+ favorites: {
148
+ list: (query?: FavoriteQuery, o?: CallOptions) => Promise<Paginated<FavoriteProduct>>;
149
+ /** 201. */
150
+ add: (input: AddFavoriteInput, o?: CallOptions) => Promise<FavoriteProduct>;
151
+ renameCategory: (input: RenameFavoriteCategoryInput, o?: CallOptions) => Promise<FavoriteCategoryRenamed>;
152
+ remove: (productId: string | number, o?: CallOptions) => Promise<Acknowledged>;
153
+ categories: (o?: CallOptions) => Promise<FavoriteCategory[]>;
154
+ batch: (input: FavoriteBatchInput, o?: CallOptions) => Promise<FavoriteBatchResult>;
155
+ };
156
+ /** A contact message for the tenant (needs `clientId`). */
157
+ sendMessage: (input: StorefrontMessageInput, o?: CallOptions) => Promise<StorefrontMessage>;
158
+ };
159
+ export type StorefrontModule = ReturnType<typeof storefront>;
160
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/storefront/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAQ,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,sBA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