@viu/emporix-sdk 1.0.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 (132) hide show
  1. package/CHANGELOG.md +407 -0
  2. package/LICENSE +21 -0
  3. package/README.md +115 -0
  4. package/dist/cart.cjs +214 -0
  5. package/dist/cart.cjs.map +1 -0
  6. package/dist/cart.d.cts +1807 -0
  7. package/dist/cart.d.ts +1807 -0
  8. package/dist/cart.js +4 -0
  9. package/dist/cart.js.map +1 -0
  10. package/dist/category.cjs +97 -0
  11. package/dist/category.cjs.map +1 -0
  12. package/dist/category.d.cts +313 -0
  13. package/dist/category.d.ts +313 -0
  14. package/dist/category.js +4 -0
  15. package/dist/category.js.map +1 -0
  16. package/dist/checkout.cjs +98 -0
  17. package/dist/checkout.cjs.map +1 -0
  18. package/dist/checkout.d.cts +252 -0
  19. package/dist/checkout.d.ts +252 -0
  20. package/dist/checkout.js +4 -0
  21. package/dist/checkout.js.map +1 -0
  22. package/dist/chunk-4BJUCCKJ.js +86 -0
  23. package/dist/chunk-4BJUCCKJ.js.map +1 -0
  24. package/dist/chunk-6UNFMCHZ.js +95 -0
  25. package/dist/chunk-6UNFMCHZ.js.map +1 -0
  26. package/dist/chunk-B56JZNI7.js +49 -0
  27. package/dist/chunk-B56JZNI7.js.map +1 -0
  28. package/dist/chunk-BFQ732VZ.js +11 -0
  29. package/dist/chunk-BFQ732VZ.js.map +1 -0
  30. package/dist/chunk-F3WAQH2E.js +120 -0
  31. package/dist/chunk-F3WAQH2E.js.map +1 -0
  32. package/dist/chunk-GWJ2U2CP.js +14 -0
  33. package/dist/chunk-GWJ2U2CP.js.map +1 -0
  34. package/dist/chunk-HEO34WLO.js +47 -0
  35. package/dist/chunk-HEO34WLO.js.map +1 -0
  36. package/dist/chunk-HKPZI7Y5.js +30 -0
  37. package/dist/chunk-HKPZI7Y5.js.map +1 -0
  38. package/dist/chunk-IEZHGU7F.js +171 -0
  39. package/dist/chunk-IEZHGU7F.js.map +1 -0
  40. package/dist/chunk-KTODT6DV.js +86 -0
  41. package/dist/chunk-KTODT6DV.js.map +1 -0
  42. package/dist/chunk-NM7VDXBR.js +57 -0
  43. package/dist/chunk-NM7VDXBR.js.map +1 -0
  44. package/dist/chunk-OMYVOOSX.js +57 -0
  45. package/dist/chunk-OMYVOOSX.js.map +1 -0
  46. package/dist/chunk-QDABAMVN.js +89 -0
  47. package/dist/chunk-QDABAMVN.js.map +1 -0
  48. package/dist/chunk-RXVVFNYN.js +56 -0
  49. package/dist/chunk-RXVVFNYN.js.map +1 -0
  50. package/dist/chunk-SKX7KCMH.js +23 -0
  51. package/dist/chunk-SKX7KCMH.js.map +1 -0
  52. package/dist/chunk-TLH6SLAF.js +215 -0
  53. package/dist/chunk-TLH6SLAF.js.map +1 -0
  54. package/dist/chunk-Z6PNI5VT.js +142 -0
  55. package/dist/chunk-Z6PNI5VT.js.map +1 -0
  56. package/dist/companies.cjs +58 -0
  57. package/dist/companies.cjs.map +1 -0
  58. package/dist/companies.d.cts +31 -0
  59. package/dist/companies.d.ts +31 -0
  60. package/dist/companies.js +3 -0
  61. package/dist/companies.js.map +1 -0
  62. package/dist/contacts.cjs +51 -0
  63. package/dist/contacts.cjs.map +1 -0
  64. package/dist/contacts.d.cts +28 -0
  65. package/dist/contacts.d.ts +28 -0
  66. package/dist/contacts.js +3 -0
  67. package/dist/contacts.js.map +1 -0
  68. package/dist/context-vKgzZ-5f.d.cts +329 -0
  69. package/dist/context-vKgzZ-5f.d.ts +329 -0
  70. package/dist/customer-groups.cjs +25 -0
  71. package/dist/customer-groups.cjs.map +1 -0
  72. package/dist/customer-groups.d.cts +36 -0
  73. package/dist/customer-groups.d.ts +36 -0
  74. package/dist/customer-groups.js +3 -0
  75. package/dist/customer-groups.js.map +1 -0
  76. package/dist/customer.cjs +262 -0
  77. package/dist/customer.cjs.map +1 -0
  78. package/dist/customer.d.cts +386 -0
  79. package/dist/customer.d.ts +386 -0
  80. package/dist/customer.js +5 -0
  81. package/dist/customer.js.map +1 -0
  82. package/dist/index.cjs +2075 -0
  83. package/dist/index.cjs.map +1 -0
  84. package/dist/index.d.cts +218 -0
  85. package/dist/index.d.ts +218 -0
  86. package/dist/index.js +791 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/locations.cjs +59 -0
  89. package/dist/locations.cjs.map +1 -0
  90. package/dist/locations.d.cts +30 -0
  91. package/dist/locations.d.ts +30 -0
  92. package/dist/locations.js +3 -0
  93. package/dist/locations.js.map +1 -0
  94. package/dist/media.cjs +123 -0
  95. package/dist/media.cjs.map +1 -0
  96. package/dist/media.d.cts +219 -0
  97. package/dist/media.d.ts +219 -0
  98. package/dist/media.js +3 -0
  99. package/dist/media.js.map +1 -0
  100. package/dist/orders.cjs +98 -0
  101. package/dist/orders.cjs.map +1 -0
  102. package/dist/orders.d.cts +167 -0
  103. package/dist/orders.d.ts +167 -0
  104. package/dist/orders.js +3 -0
  105. package/dist/orders.js.map +1 -0
  106. package/dist/payment.cjs +77 -0
  107. package/dist/payment.cjs.map +1 -0
  108. package/dist/payment.d.cts +110 -0
  109. package/dist/payment.d.ts +110 -0
  110. package/dist/payment.js +5 -0
  111. package/dist/payment.js.map +1 -0
  112. package/dist/price.cjs +88 -0
  113. package/dist/price.cjs.map +1 -0
  114. package/dist/price.d.cts +445 -0
  115. package/dist/price.d.ts +445 -0
  116. package/dist/price.js +4 -0
  117. package/dist/price.js.map +1 -0
  118. package/dist/product.cjs +100 -0
  119. package/dist/product.cjs.map +1 -0
  120. package/dist/product.d.cts +400 -0
  121. package/dist/product.d.ts +400 -0
  122. package/dist/product.js +4 -0
  123. package/dist/product.js.map +1 -0
  124. package/dist/segment.cjs +189 -0
  125. package/dist/segment.cjs.map +1 -0
  126. package/dist/segment.d.cts +241 -0
  127. package/dist/segment.d.ts +241 -0
  128. package/dist/segment.js +5 -0
  129. package/dist/segment.js.map +1 -0
  130. package/dist/types.gen-D1QuqPLs.d.cts +166 -0
  131. package/dist/types.gen-D1QuqPLs.d.ts +166 -0
  132. package/package.json +141 -0
@@ -0,0 +1,386 @@
1
+ import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-vKgzZ-5f.cjs';
2
+
3
+ type AccountId = {
4
+ /**
5
+ * Customer email address.
6
+ */
7
+ id?: string;
8
+ /**
9
+ * Customer account unique identifier generated by an external identity provider.
10
+ *
11
+ * **Note**: This field is only applicable if the user has been registered through social login.
12
+ */
13
+ providerId?: string;
14
+ };
15
+ /**
16
+ * Customer address information.
17
+ */
18
+ type Address$1 = {
19
+ /**
20
+ * Customer address' unique identifier generated when the address is added to the customer account.
21
+ */
22
+ id?: string;
23
+ contactName: string;
24
+ companyName?: string;
25
+ street?: string;
26
+ streetNumber?: string;
27
+ streetAppendix?: string;
28
+ extraLine1?: string;
29
+ extraLine2?: string;
30
+ extraLine3?: string;
31
+ extraLine4?: string;
32
+ zipCode?: string;
33
+ city?: string;
34
+ country?: string;
35
+ state?: string;
36
+ contactPhone?: string;
37
+ /**
38
+ * Flag indicating whether the address is the customer default address.
39
+ */
40
+ isDefault?: boolean;
41
+ tags?: Array<string>;
42
+ metadata?: DefaultDtoMetadata;
43
+ /**
44
+ * Customer address' additional properties.
45
+ */
46
+ mixins?: {
47
+ [key: string]: unknown;
48
+ };
49
+ };
50
+ type AddressCommonDto = AddressCreateDto & {
51
+ metadata?: DefaultDtoMetadata;
52
+ };
53
+ type AddressCreateDto = {
54
+ contactName?: string;
55
+ companyName?: string;
56
+ street?: string;
57
+ streetNumber?: string;
58
+ streetAppendix?: string;
59
+ extraLine1?: string;
60
+ extraLine2?: string;
61
+ extraLine3?: string;
62
+ extraLine4?: string;
63
+ zipCode?: string;
64
+ city?: string;
65
+ country?: string;
66
+ state?: string;
67
+ contactPhone?: string;
68
+ tags?: Array<string>;
69
+ metadata?: BasicMetadataDto;
70
+ /**
71
+ * Customer address' additional properties.
72
+ */
73
+ mixins?: {
74
+ [key: string]: unknown;
75
+ };
76
+ };
77
+ type AddressUpdateDto = AddressCommonDto & {
78
+ /**
79
+ * Flag indicating whether the address is the customer default address.
80
+ */
81
+ isDefault?: boolean;
82
+ };
83
+ /**
84
+ * Customer profile.
85
+ */
86
+ type Customer$1 = {
87
+ /**
88
+ * Customer unique identifier generated when the customer profile is created.
89
+ */
90
+ id?: string;
91
+ /**
92
+ * Customer unique number generated when the customer profile is created.
93
+ */
94
+ customerNumber?: string;
95
+ title?: string;
96
+ firstName?: string;
97
+ middleName?: string;
98
+ lastName?: string;
99
+ contactEmail?: string;
100
+ contactPhone?: string;
101
+ company?: string;
102
+ /**
103
+ * Customer preferred language.
104
+ */
105
+ preferredLanguage?: string;
106
+ /**
107
+ * Customer's preferred currency, compliant with the ISO 4217 standard.
108
+ */
109
+ preferredCurrency?: string;
110
+ /**
111
+ * Customer preferred site.
112
+ */
113
+ preferredSite?: string;
114
+ /**
115
+ * List of accounts associated with the customer profile.
116
+ */
117
+ accounts?: Array<AccountId>;
118
+ /**
119
+ * List of customer addresses.
120
+ */
121
+ addresses?: Array<Address$1>;
122
+ defaultAddress?: Address$1;
123
+ /**
124
+ * Property indicating business model of customer. When customer is assigned to any company then it is `B2B`. Otherwise it is `B2C`.
125
+ */
126
+ businessModel?: 'B2B' | 'B2C';
127
+ b2b?: B2bGet;
128
+ /**
129
+ * Customer account additional properties.
130
+ */
131
+ mixins?: {
132
+ [key: string]: unknown;
133
+ };
134
+ metadata?: DefaultDtoMetadata;
135
+ /**
136
+ * Customer last login date.
137
+ */
138
+ lastLogin?: string;
139
+ };
140
+ type CustomerCommonDto = {
141
+ title?: string;
142
+ firstName?: string;
143
+ middleName?: string;
144
+ lastName?: string;
145
+ contactPhone?: string;
146
+ company?: string;
147
+ /**
148
+ * Customer preferred language.
149
+ */
150
+ preferredLanguage?: string;
151
+ /**
152
+ * Customer's preferred currency, compliant with the ISO 4217 standard.
153
+ */
154
+ preferredCurrency?: string;
155
+ /**
156
+ * Customer preferred site.
157
+ */
158
+ preferredSite?: string;
159
+ b2b?: B2bCreate;
160
+ metadata?: DefaultDtoMetadata;
161
+ /**
162
+ * Customer account additional properties.
163
+ */
164
+ mixins?: {
165
+ [key: string]: unknown;
166
+ };
167
+ };
168
+ /**
169
+ * Additional properties for B2B customer. If the `companyRegistrationId` property is provided, an additional validation for customer details executes - `firstName`, `lastName` and `company` values have to be provided.
170
+ */
171
+ type B2bCreate = {
172
+ /**
173
+ * Registration number of the company.
174
+ */
175
+ companyRegistrationId?: string;
176
+ };
177
+ /**
178
+ * Additional properties for B2B customer. If the `companyRegistrationId` property is provided, an additional validation for customer details executes - `firstName`, `lastName` and `company` values have to be provided.
179
+ */
180
+ type B2bGet = {
181
+ /**
182
+ * Registration number of the company.
183
+ */
184
+ companyRegistrationId?: string;
185
+ legalEntities?: Array<{
186
+ /**
187
+ * ID of legal entity.
188
+ */
189
+ id?: string;
190
+ /**
191
+ * Name of legal entity.
192
+ */
193
+ name?: string;
194
+ /**
195
+ * ID of contact assignment.
196
+ */
197
+ contactAssignmentId?: string;
198
+ }>;
199
+ };
200
+ type CustomerSignup = {
201
+ /**
202
+ * Customer email address.
203
+ */
204
+ email: string;
205
+ /**
206
+ * Customer account password.
207
+ */
208
+ password: string;
209
+ customerDetails?: CustomerUpdateDto;
210
+ customerAddress?: Address$1;
211
+ signup?: PasswordAuthentication;
212
+ };
213
+ type CustomerUpdateDto = CustomerCommonDto & {
214
+ contactEmail?: string;
215
+ };
216
+ /**
217
+ * Links to mixin schemas.
218
+ */
219
+ type BasicMetadataDto = {
220
+ mixins?: {
221
+ [key: string]: unknown;
222
+ };
223
+ };
224
+ type DefaultDtoMetadata = BasicMetadataDto & {
225
+ version?: number;
226
+ };
227
+ type PasswordAuthentication = {
228
+ /**
229
+ * Customer email address.
230
+ */
231
+ email: string;
232
+ /**
233
+ * Customer account password.
234
+ */
235
+ password: string;
236
+ };
237
+ type PasswordChangeDto = {
238
+ /**
239
+ * Customer current account password.
240
+ */
241
+ currentPassword: string;
242
+ /**
243
+ * Customer new account password.
244
+ */
245
+ newPassword: string;
246
+ };
247
+ type PasswordResetRequestDto = {
248
+ /**
249
+ * Customer email address.
250
+ */
251
+ email: string;
252
+ /**
253
+ * Site from which password reset request was sent
254
+ */
255
+ site?: string;
256
+ };
257
+ type PasswordUpdate = {
258
+ /**
259
+ * Token received by the customer through email.
260
+ */
261
+ token: string;
262
+ /**
263
+ * Customer new account password.
264
+ */
265
+ password: string;
266
+ };
267
+
268
+ /**
269
+ * Caller-owned customer session. Maps the Emporix `CustomerToken` wire shape to
270
+ * idiomatic names: `access_token` → `customerToken`, `saas_token` →
271
+ * `saasToken`. `saasToken` is a JWT required for the checkout (`saas-token`
272
+ * header). The wire's `*_token` (snake_case) fields are canonical; the
273
+ * camelCase variants are deprecated in the Emporix spec.
274
+ */
275
+ interface CustomerSession {
276
+ customerToken: string;
277
+ /** JWT required for completing checkout (sent as the `saas-token` header). */
278
+ saasToken: string;
279
+ refreshToken: string;
280
+ /** Same session as the anonymous token — preserves the cart across login. */
281
+ sessionId: string | undefined;
282
+ /** Customer access-token lifetime in seconds. */
283
+ expiresIn: number | undefined;
284
+ /** Only set by `socialLogin`: the IdP access token echoed by Emporix. */
285
+ socialAccessToken?: string;
286
+ /** Only set by `socialLogin`: the IdP ID token echoed by Emporix. */
287
+ socialIdToken?: string;
288
+ }
289
+ /** Customer profile as returned by the Customer service (all generated fields). */
290
+ type Customer = Customer$1;
291
+ /** A customer address as returned by the Customer service (all generated fields). */
292
+ type Address = Address$1;
293
+ /** Generated request bodies (caller sends the exact wire shape). */
294
+ type CustomerSignupInput = CustomerSignup;
295
+ type CustomerUpdateInput = CustomerUpdateDto;
296
+ type PasswordChangeInput = PasswordChangeDto;
297
+ type PasswordResetRequestInput = PasswordResetRequestDto;
298
+ type PasswordResetConfirmInput = PasswordUpdate;
299
+ type AddressCreateInput = AddressCreateDto;
300
+ type AddressUpdateInput = AddressUpdateDto;
301
+ /** Customer signup, session, profile and addresses. */
302
+ declare class CustomerService {
303
+ private readonly ctx;
304
+ constructor(ctx: ClientContext);
305
+ /** Obtains an anonymous storefront session (accessToken + sessionId + refreshToken). */
306
+ anonymous(): Promise<AnonymousSession>;
307
+ /** Registers a customer. Default auth: anonymous. */
308
+ signup(input: CustomerSignupInput, auth?: AuthContext): Promise<Customer>;
309
+ /**
310
+ * Logs a customer in. Threads the anonymous token so the session (and its
311
+ * cart) survives — losing it silently creates a new session per Emporix docs.
312
+ * Wire `accessToken` is mapped to `customerToken`.
313
+ */
314
+ login(creds: {
315
+ email: string;
316
+ password: string;
317
+ }, opts?: {
318
+ anonymousToken?: string;
319
+ }, auth?: AuthContext): Promise<CustomerSession>;
320
+ /**
321
+ * Refreshes an authenticated customer session via its refresh token,
322
+ * preserving the same `sessionId`. Calls
323
+ * `GET /customer/{tenant}/refreshauthtoken?refreshToken=…`, which **must be
324
+ * authorized with an anonymous token** (default auth: anonymous) — not the
325
+ * expired customer token. The refresh response does **not** include a
326
+ * `saas_token`; pass the original `saasToken` to carry it forward (it has
327
+ * its own, independent lifetime).
328
+ */
329
+ refresh(input: {
330
+ refreshToken: string;
331
+ saasToken?: string;
332
+ legalEntityId?: string;
333
+ }, auth?: AuthContext): Promise<CustomerSession>;
334
+ /**
335
+ * Logs the customer out server-side: `GET /customer/{tenant}/logout?
336
+ * accessToken=…` authorized with the customer token. Invalidates the
337
+ * access token (204 No Content). Requires customer/raw auth — the token is
338
+ * sent both as the bearer and the `accessToken` query param (per Emporix).
339
+ */
340
+ logout(auth?: AuthContext): Promise<void>;
341
+ /**
342
+ * Authorization-Code SSO: exchanges the IdP `code` for an Emporix customer
343
+ * session via `POST /customer/{tenant}/socialLogin`. The browser performs
344
+ * the IdP redirect itself; the SDK only does this Emporix exchange.
345
+ * Default auth: anonymous (Emporix requires an anonymous Bearer). The
346
+ * response has no `session_id` and returns `expires_in` as a string —
347
+ * normalized to a number here.
348
+ */
349
+ socialLogin(input: {
350
+ code: string;
351
+ redirectUri: string;
352
+ codeVerifier?: string;
353
+ sessionId?: string;
354
+ }, auth?: AuthContext): Promise<CustomerSession>;
355
+ /**
356
+ * RFC 8693 token exchange: exchanges an external IdP JWT for an Emporix
357
+ * customer session via `POST /customer/{tenant}/exchangeauthtoken`.
358
+ * Emporix uses a proprietary query-param wire (not the RFC form body).
359
+ * Default auth: anonymous. `config` selects a site-specific IdP config
360
+ * (multi-site); omit for the tenant default. Returns `session_id` and a
361
+ * fresh `saas_token`; `expires_in` is an integer (normalized anyway).
362
+ */
363
+ exchangeToken(input: {
364
+ subjectToken: string;
365
+ config?: string;
366
+ }, auth?: AuthContext): Promise<CustomerSession>;
367
+ /** Returns the authenticated customer. Requires customer/raw auth. */
368
+ me(auth?: AuthContext): Promise<Customer>;
369
+ /** Updates the authenticated customer. Requires customer/raw auth. */
370
+ update(patch: CustomerUpdateInput, auth?: AuthContext): Promise<Customer>;
371
+ /** Changes the password. Requires customer/raw auth. */
372
+ changePassword(input: PasswordChangeInput, auth?: AuthContext): Promise<void>;
373
+ /** Requests a password reset email. Default auth: anonymous. */
374
+ requestPasswordReset(input: PasswordResetRequestInput, auth?: AuthContext): Promise<void>;
375
+ /** Confirms a password reset. Default auth: anonymous. */
376
+ confirmPasswordReset(input: PasswordResetConfirmInput, auth?: AuthContext): Promise<void>;
377
+ /** Address sub-resource. All operations require customer/raw auth. */
378
+ readonly addresses: {
379
+ list: (auth?: AuthContext) => Promise<Address[]>;
380
+ add: (address: AddressCreateInput, auth?: AuthContext) => Promise<Address>;
381
+ update: (id: string, patch: AddressUpdateInput, auth?: AuthContext) => Promise<Address>;
382
+ remove: (id: string, auth?: AuthContext) => Promise<void>;
383
+ };
384
+ }
385
+
386
+ export { type Address, type AddressCreateInput, type AddressUpdateInput, type Customer, CustomerService, type CustomerSession, type CustomerSignupInput, type CustomerUpdateInput, type PasswordChangeInput, type PasswordResetConfirmInput, type PasswordResetRequestInput };