@scryme/sdk 9.66.0 → 9.68.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/README.md +1 -1
- package/dist/{base-Cl7_QxqC.d.mts → base-CSVOv3Nr.d.mts} +242 -20
- package/dist/{base-Cl7_QxqC.d.ts → base-CSVOv3Nr.d.ts} +242 -20
- package/dist/{chunk-PPNV4D3M.mjs → chunk-SYGBIPUK.mjs} +492 -442
- package/dist/client.d.mts +379 -52
- package/dist/client.d.ts +379 -52
- package/dist/client.js +356 -390
- package/dist/client.mjs +3 -7
- package/dist/index.d.mts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +492 -444
- package/dist/index.mjs +3 -7
- package/dist/server.d.mts +184 -4
- package/dist/server.d.ts +184 -4
- package/dist/server.js +192 -66
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
package/dist/client.d.mts
CHANGED
|
@@ -1,136 +1,463 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
3
1
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
4
|
-
import {
|
|
2
|
+
import { ai as CustomerResponseDto, G as ProductResponseDto, K as ServiceCatalogResponseDto, cQ as CartItemDto, bb as CartResponseDto, dS as CustomerSessionDto, cZ as CatalogModule, ex as InventoryModule, fp as OrdersModule, cL as CRMModule, fx as POSModule, bR as AccountingModule, eZ as LoyaltyModule, fi as MembersModule, cj as AdminModule, ba as CartControllerGetCartParams, bd as AddToCartDto, be as RemoveFromCartDto, bc as CartControllerClearCartParams, aD as OrderResponseDto, am as UpdateCustomerDto, an as AddressDto, aj as RegisterCustomerDto, dQ as CustomerAuthResponseDto, a4 as CreateBookingDto, gu as ServiceBookingItemDto, cw as AuthModule, s as AuthExchangeToken201 } from './base-CSVOv3Nr.mjs';
|
|
5
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Defines a storage contract for persisting authentication tokens and session data.
|
|
6
|
+
* Ideal for client-side environments (localStorage, secure storage, custom cookies).
|
|
7
|
+
*/
|
|
6
8
|
interface StorageProvider {
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves an item from storage.
|
|
11
|
+
* @param key Unique storage key.
|
|
12
|
+
*/
|
|
7
13
|
getItem(key: string): string | null | Promise<string | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Stores an item in storage.
|
|
16
|
+
* @param key Unique storage key.
|
|
17
|
+
* @param value Stringified value to store.
|
|
18
|
+
*/
|
|
8
19
|
setItem(key: string, value: string): void | Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes an item from storage.
|
|
22
|
+
* @param key Unique storage key.
|
|
23
|
+
*/
|
|
9
24
|
removeItem(key: string): void | Promise<void>;
|
|
10
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for the stateful ScrymeClientSDK.
|
|
28
|
+
*/
|
|
11
29
|
interface ClientSDKConfig {
|
|
30
|
+
/**
|
|
31
|
+
* The client ID of your Storefront application.
|
|
32
|
+
*/
|
|
12
33
|
clientId: string;
|
|
34
|
+
/**
|
|
35
|
+
* The optional client secret. It is omitted on the client side for maximum security.
|
|
36
|
+
*/
|
|
13
37
|
clientSecret?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The unique slug of the organization to target.
|
|
40
|
+
*/
|
|
14
41
|
orgSlug: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional base API URL. Defaults to "https://api.scryme.tech".
|
|
44
|
+
*/
|
|
15
45
|
baseURL?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Custom storage provider to persist session tokens. Defaults to localStorage where available.
|
|
48
|
+
*/
|
|
16
49
|
storage?: StorageProvider;
|
|
17
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Represents the authentication change events emitted by the SDK.
|
|
53
|
+
*/
|
|
18
54
|
type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "INITIAL_SESSION";
|
|
55
|
+
/**
|
|
56
|
+
* Represents the active customer session status.
|
|
57
|
+
* @template TUser Custom User profile type.
|
|
58
|
+
*/
|
|
19
59
|
interface SessionState<TUser = CustomerResponseDto> {
|
|
60
|
+
/**
|
|
61
|
+
* The current customer authentication JWT token.
|
|
62
|
+
*/
|
|
20
63
|
token: string | null;
|
|
64
|
+
/**
|
|
65
|
+
* The deserialized customer profile details.
|
|
66
|
+
*/
|
|
21
67
|
user: TUser | null;
|
|
68
|
+
/**
|
|
69
|
+
* Epoch millisecond expiration timestamp of the token.
|
|
70
|
+
*/
|
|
22
71
|
expiresAt?: number | null;
|
|
23
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Standard client-side session structure matching better-auth.
|
|
75
|
+
*/
|
|
76
|
+
interface ClientSessionStructure<TUser = CustomerResponseDto> {
|
|
77
|
+
data: {
|
|
78
|
+
session: {
|
|
79
|
+
id: string;
|
|
80
|
+
userId: string;
|
|
81
|
+
expiresAt: Date | null;
|
|
82
|
+
token: string | null;
|
|
83
|
+
};
|
|
84
|
+
user: TUser;
|
|
85
|
+
} | null;
|
|
86
|
+
isPending: boolean;
|
|
87
|
+
error: any;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Callback signature triggered whenever the customer authentication status changes.
|
|
91
|
+
*/
|
|
24
92
|
type AuthStateCallback<TUser = CustomerResponseDto> = (event: AuthChangeEvent, session: SessionState<TUser>) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Stateful, reactive Client-Side SDK for Scryme V3.
|
|
95
|
+
*
|
|
96
|
+
* Automatically handles JWT token exchanges, reactive customer session refreshes,
|
|
97
|
+
* stateful shopping cart synchronization, and real-time authentication state updates.
|
|
98
|
+
*
|
|
99
|
+
* @template TProduct Custom Product DTO type override. Defaults to ProductResponseDto.
|
|
100
|
+
* @template TService Custom Service DTO type override. Defaults to ServiceCatalogResponseDto.
|
|
101
|
+
* @template TCartItem Custom Cart Item DTO type override. Defaults to CartItemDto.
|
|
102
|
+
* @template TCartResponse Custom Cart Response DTO type override. Defaults to CartResponseDto.
|
|
103
|
+
* @template TUser Custom User Profile DTO type override. Defaults to CustomerResponseDto.
|
|
104
|
+
* @template TSession Custom Customer Session DTO type override. Defaults to CustomerSessionDto.
|
|
105
|
+
*/
|
|
25
106
|
declare class ScrymeClientSDK<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto> {
|
|
107
|
+
/**
|
|
108
|
+
* Underlying Axios instance initialized with the customized baseUrl and automatic interceptors.
|
|
109
|
+
*/
|
|
26
110
|
axiosInstance: AxiosInstance;
|
|
27
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Raw proxy API client exposing all standard endpoints auto-bound with the configured orgSlug.
|
|
113
|
+
*/
|
|
114
|
+
private api;
|
|
115
|
+
/** Catalog operations submodule (products, services, categories, bookings, staff schedules). */
|
|
28
116
|
catalog: CatalogModule<TProduct, TService>;
|
|
117
|
+
/** Traceability, split/merge, physical reconciliation, and partner wallet operations submodule. */
|
|
29
118
|
inventory: InventoryModule;
|
|
119
|
+
/** Cart management, sales order orchestration, checkout processing, and payments submodule. */
|
|
30
120
|
orders: OrdersModule;
|
|
121
|
+
/** Custom fields, relationships, note logging, associations, and CRM timeline submodule. */
|
|
31
122
|
crm: CRMModule;
|
|
123
|
+
/** Cash flow register, sale processing, terminal synchronization, and device provision submodule. */
|
|
32
124
|
pos: POSModule;
|
|
125
|
+
/** Balance sheets, Profit & Loss reports, expenses, invoices, and utility account submodule. */
|
|
33
126
|
accounting: AccountingModule;
|
|
127
|
+
/** Rewards, voucher validation, point balances, and customer favorite records submodule. */
|
|
34
128
|
loyalty: LoyaltyModule;
|
|
129
|
+
/** Staff members, department directories, check-in logs, and broadcast announcements submodule. */
|
|
35
130
|
members: MembersModule;
|
|
131
|
+
/** Global setup parameters, organization definitions, audit trails, and tier limit submodule. */
|
|
36
132
|
admin: AdminModule;
|
|
133
|
+
/**
|
|
134
|
+
* Stateful Shopping Cart Submodule.
|
|
135
|
+
* Leverages internal tracking and smart delta calculations for optimized storefront shopping.
|
|
136
|
+
*/
|
|
37
137
|
cart: {
|
|
138
|
+
/**
|
|
139
|
+
* Retrieves the active shopping cart for the current session or customer.
|
|
140
|
+
* @param params Optional cart parameters including sessionId.
|
|
141
|
+
* @returns Promise containing the axios response with the cart details.
|
|
142
|
+
*/
|
|
38
143
|
get<T = TCartResponse>(params?: CartControllerGetCartParams): Promise<AxiosResponse<T & Record<string, any>>>;
|
|
144
|
+
/**
|
|
145
|
+
* Adds a product variant or service to the shopping cart.
|
|
146
|
+
* Automatically resolves and appends the customer ID from the active customer session if omitted.
|
|
147
|
+
* @param dto Data transfer object containing the item details and quantity.
|
|
148
|
+
* @returns Promise containing the axios response.
|
|
149
|
+
*/
|
|
39
150
|
add(dto: AddToCartDto): Promise<AxiosResponse<void>>;
|
|
151
|
+
/**
|
|
152
|
+
* Removes a product variant or service from the shopping cart.
|
|
153
|
+
* Automatically resolves and appends the customer ID from the active customer session if omitted.
|
|
154
|
+
* @param dto Data transfer object specifying the item to remove.
|
|
155
|
+
* @returns Promise containing the axios response.
|
|
156
|
+
*/
|
|
40
157
|
remove(dto: RemoveFromCartDto): Promise<AxiosResponse<void>>;
|
|
158
|
+
/**
|
|
159
|
+
* Clears all items from the active shopping cart.
|
|
160
|
+
* @param params Optional clear parameters containing sessionId.
|
|
161
|
+
* @returns Promise containing the axios response.
|
|
162
|
+
*/
|
|
41
163
|
clear(params?: CartControllerClearCartParams): Promise<AxiosResponse<void>>;
|
|
164
|
+
/**
|
|
165
|
+
* Updates the quantity of a product variant or service in the shopping cart.
|
|
166
|
+
* Computes the difference and invokes add or remove operations accordingly.
|
|
167
|
+
* Automatically resolves and appends the customer ID from the active customer session if omitted.
|
|
168
|
+
* @param dto Data transfer object containing item identifiers and the target absolute quantity.
|
|
169
|
+
* @returns Promise resolving to the updated cart state or undefined.
|
|
170
|
+
*/
|
|
42
171
|
update<T = TCartResponse>(dto: AddToCartDto & {
|
|
43
172
|
quantity: number;
|
|
44
173
|
}): Promise<AxiosResponse<void> | AxiosResponse<T> | undefined>;
|
|
174
|
+
/**
|
|
175
|
+
* Retrieves the flat list of cart items currently in the cart.
|
|
176
|
+
* @param params Optional parameters.
|
|
177
|
+
* @returns Promise resolving to an array of cart items.
|
|
178
|
+
*/
|
|
45
179
|
getItems<T = TCartItem>(params?: CartControllerGetCartParams): Promise<T[]>;
|
|
180
|
+
/**
|
|
181
|
+
* Calculates the totals, item counts, and summary metrics of the current shopping cart.
|
|
182
|
+
* @param params Optional parameters.
|
|
183
|
+
* @returns Promise resolving to the totals object containing the itemsCount, item array, and raw cart.
|
|
184
|
+
*/
|
|
46
185
|
getTotals<TItem = TCartItem, TRaw = TCartResponse>(params?: CartControllerGetCartParams): Promise<{
|
|
47
186
|
itemsCount: number;
|
|
48
187
|
items: TItem[];
|
|
49
188
|
raw: TRaw;
|
|
50
189
|
}>;
|
|
190
|
+
/**
|
|
191
|
+
* Merges a guest shopping cart session into an authenticated customer's shopping cart.
|
|
192
|
+
* @param guestSessionId The guest session token to migrate items from.
|
|
193
|
+
* @param customerId The destination customer ID.
|
|
194
|
+
* @returns Promise resolving to the merged cart state.
|
|
195
|
+
*/
|
|
51
196
|
mergeGuestCart<T = TCartResponse>(guestSessionId: string, customerId: string): Promise<AxiosResponse<T & Record<string, any>>>;
|
|
197
|
+
/**
|
|
198
|
+
* Finalizes the shopping cart, creating a physical Sales Order for checkout.
|
|
199
|
+
* Automatically resolves and appends the customer ID from the active customer session.
|
|
200
|
+
* Clears the shopping cart state upon successful transaction creation.
|
|
201
|
+
* @param params Checkout configurations including locationId, channel, and custom notes.
|
|
202
|
+
* @returns Promise resolving to the created order response.
|
|
203
|
+
*/
|
|
52
204
|
checkout(params: {
|
|
53
205
|
locationId: string;
|
|
54
206
|
notes?: string;
|
|
55
207
|
channel?: string;
|
|
56
208
|
}): Promise<OrderResponseDto>;
|
|
57
209
|
};
|
|
210
|
+
/**
|
|
211
|
+
* Storefront Customer Profile Submodule.
|
|
212
|
+
* Manages the authenticated user's self-serve account, update workflows, and shipping/billing directories.
|
|
213
|
+
*/
|
|
58
214
|
customer: {
|
|
215
|
+
/**
|
|
216
|
+
* Fetches the current customer profile details.
|
|
217
|
+
* @template T The expected type of the user profile.
|
|
218
|
+
* @returns Promise resolving to the user profile object.
|
|
219
|
+
*/
|
|
59
220
|
getProfile<T = TUser>(): Promise<T>;
|
|
221
|
+
/**
|
|
222
|
+
* Updates the profile information of the authenticated customer.
|
|
223
|
+
* @param dto Updated field attributes.
|
|
224
|
+
* @returns Promise containing the updated customer profile response.
|
|
225
|
+
*/
|
|
60
226
|
updateProfile<T = TUser>(dto: UpdateCustomerDto): Promise<AxiosResponse<T>>;
|
|
227
|
+
/**
|
|
228
|
+
* Retrieves all saved billing/shipping addresses for the active customer.
|
|
229
|
+
* @returns Promise resolving to the list of address records.
|
|
230
|
+
*/
|
|
61
231
|
getAddresses(): Promise<AxiosResponse<AddressDto[]>>;
|
|
232
|
+
/**
|
|
233
|
+
* Saves a new address record to the active customer's profile directory.
|
|
234
|
+
* @param dto The address details to persist.
|
|
235
|
+
* @returns Promise containing the response of the creation operation.
|
|
236
|
+
*/
|
|
62
237
|
addAddress(dto: AddressDto): Promise<AxiosResponse<void>>;
|
|
238
|
+
/**
|
|
239
|
+
* Reactive & Stateful Customer Authentication Submodule.
|
|
240
|
+
*/
|
|
241
|
+
auth: {
|
|
242
|
+
/**
|
|
243
|
+
* Gets the current customer session synchronously in standard format.
|
|
244
|
+
* Reflects the active customer state immediately without causing React re-renders.
|
|
245
|
+
*/
|
|
246
|
+
get session(): ClientSessionStructure<TUser>;
|
|
247
|
+
/**
|
|
248
|
+
* Registers a new customer storefront profile.
|
|
249
|
+
* Automatically performs sign-in and establishes a customer session if a password is provided.
|
|
250
|
+
* @param dto The customer registration attributes (email, name, password, etc.).
|
|
251
|
+
* @returns Promise containing the created customer details.
|
|
252
|
+
*/
|
|
253
|
+
signUp<T = TUser>(dto: RegisterCustomerDto): Promise<AxiosResponse<T>>;
|
|
254
|
+
/**
|
|
255
|
+
* Authenticates a customer using their credentials, starting an active session.
|
|
256
|
+
* Triggers a 'SIGNED_IN' authentication state change event.
|
|
257
|
+
* @param credentials Customer login email and optional password.
|
|
258
|
+
* @returns Promise containing the session token and user profile.
|
|
259
|
+
*/
|
|
260
|
+
signIn<TSess = TSession, TU = TUser>(credentials: {
|
|
261
|
+
email: string;
|
|
262
|
+
password?: string;
|
|
263
|
+
}): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
264
|
+
/**
|
|
265
|
+
* Terminate the active customer session, clearing persisted tokens and session memory.
|
|
266
|
+
* Triggers a 'SIGNED_OUT' authentication state change event.
|
|
267
|
+
* @returns Promise resolving once state cleanup is done.
|
|
268
|
+
*/
|
|
269
|
+
signOut(): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Retrieves the raw internal authentication state synchronously/asynchronously.
|
|
272
|
+
* @returns Promise containing token and user state.
|
|
273
|
+
*/
|
|
274
|
+
getSession<TU = TUser>(): Promise<SessionState<TU>>;
|
|
275
|
+
/**
|
|
276
|
+
* Registers a listener to reactively monitor authentication events.
|
|
277
|
+
* Triggers callback upon 'SIGNED_IN', 'SIGNED_OUT', or 'INITIAL_SESSION' events.
|
|
278
|
+
* @param callback Callback function.
|
|
279
|
+
* @returns Subscription reference containing unsubscribe cleanup method.
|
|
280
|
+
*/
|
|
281
|
+
onAuthStateChange<TU = TUser>(callback: AuthStateCallback<TU>): {
|
|
282
|
+
unsubscribe(): void;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Lists all active concurrent sessions associated with this customer profile.
|
|
286
|
+
* @returns Promise containing the list of active session tokens and metadata.
|
|
287
|
+
*/
|
|
288
|
+
getSessions<TSess = TSession>(): Promise<TSess[]>;
|
|
289
|
+
/**
|
|
290
|
+
* Revokes and terminates a specific active customer session by its identifier.
|
|
291
|
+
* @param id The session identifier to destroy.
|
|
292
|
+
* @returns Promise containing the revocation response.
|
|
293
|
+
*/
|
|
294
|
+
revokeSession(id: string): Promise<AxiosResponse<void>>;
|
|
295
|
+
/**
|
|
296
|
+
* Revokes and terminates all other concurrent sessions for this customer.
|
|
297
|
+
* @param mode Optional mode configurations.
|
|
298
|
+
* @returns Promise containing the response.
|
|
299
|
+
*/
|
|
300
|
+
revokeAllSessions(mode?: string): Promise<AxiosResponse<void>>;
|
|
301
|
+
/**
|
|
302
|
+
* Retrieves the current customer user record from the backend.
|
|
303
|
+
* @returns Promise containing the active customer user details.
|
|
304
|
+
*/
|
|
305
|
+
getCurrentSession<TU = TUser>(): Promise<TU>;
|
|
306
|
+
/**
|
|
307
|
+
* Refreshes the active customer session, extending the validity of the customer JWT token.
|
|
308
|
+
* Triggers automatic session token updates and reactive state updates.
|
|
309
|
+
* @returns Promise resolving to the fresh customer authentication response.
|
|
310
|
+
*/
|
|
311
|
+
refreshSession<TSess = TSession, TU = TUser>(): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
312
|
+
/**
|
|
313
|
+
* Stateful, reactive React Hook that fetches, manages, and updates the customer session.
|
|
314
|
+
* Subscribes to authentication state change listeners to ensure immediate UI synchronization.
|
|
315
|
+
* @returns Reactive session state containing session, user, error, pending flags, and refetch handler.
|
|
316
|
+
*/
|
|
317
|
+
useSession<TSess = TSession, TU = TUser>(): {
|
|
318
|
+
data: {
|
|
319
|
+
session: TSess;
|
|
320
|
+
user: TU;
|
|
321
|
+
} | null;
|
|
322
|
+
isPending: boolean;
|
|
323
|
+
error: any;
|
|
324
|
+
refetch: () => Promise<void>;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
63
327
|
};
|
|
328
|
+
/**
|
|
329
|
+
* Service Bookings & Appointments Submodule.
|
|
330
|
+
*/
|
|
64
331
|
bookings: {
|
|
332
|
+
/**
|
|
333
|
+
* Creates a new booking appointment.
|
|
334
|
+
* Automatically resolves and appends the customer ID from the active customer session if omitted.
|
|
335
|
+
* @param dto The service booking reservation parameters.
|
|
336
|
+
* @returns Promise containing the booking creation response.
|
|
337
|
+
*/
|
|
65
338
|
create(dto: CreateBookingDto): Promise<AxiosResponse<void>>;
|
|
339
|
+
/**
|
|
340
|
+
* Retrieves the full details of a specific service booking by its identifier.
|
|
341
|
+
* @param id Service booking ID.
|
|
342
|
+
* @returns Promise containing the booking details response.
|
|
343
|
+
*/
|
|
66
344
|
get(id: string): Promise<AxiosResponse<ServiceBookingItemDto>>;
|
|
345
|
+
/**
|
|
346
|
+
* Lists all service bookings and reservations associated with the authenticated customer.
|
|
347
|
+
* @returns Promise containing the list of service booking records.
|
|
348
|
+
*/
|
|
67
349
|
list(): Promise<AxiosResponse<ServiceBookingItemDto[]>>;
|
|
350
|
+
/**
|
|
351
|
+
* Cancels an existing service booking appointment.
|
|
352
|
+
* @param id Service booking ID to cancel.
|
|
353
|
+
* @returns Promise containing the cancellation response.
|
|
354
|
+
*/
|
|
68
355
|
cancel(id: string): Promise<AxiosResponse<void>>;
|
|
69
356
|
};
|
|
357
|
+
/**
|
|
358
|
+
* Authentication & Customer Session Submodule.
|
|
359
|
+
*/
|
|
70
360
|
auth: AuthModule & {
|
|
361
|
+
/**
|
|
362
|
+
* Gets the current customer session synchronously in standard format.
|
|
363
|
+
* Reflects the active customer state immediately without causing React re-renders.
|
|
364
|
+
*/
|
|
365
|
+
get session(): ClientSessionStructure<TUser>;
|
|
366
|
+
/**
|
|
367
|
+
* Registers a new customer storefront profile.
|
|
368
|
+
* Automatically performs sign-in and establishes a customer session if a password is provided.
|
|
369
|
+
* @param dto The customer registration attributes (email, name, password, etc.).
|
|
370
|
+
* @returns Promise containing the created customer details.
|
|
371
|
+
*/
|
|
71
372
|
signUp<T = TUser>(dto: RegisterCustomerDto): Promise<AxiosResponse<T>>;
|
|
373
|
+
/**
|
|
374
|
+
* Authenticates application or SDK client via client ID and client secret credentials.
|
|
375
|
+
* @returns Promise resolving to the token exchange response containing access token.
|
|
376
|
+
*/
|
|
72
377
|
authenticate(): Promise<AuthExchangeToken201>;
|
|
378
|
+
/**
|
|
379
|
+
* Authenticates a customer using their credentials, starting an active session.
|
|
380
|
+
* Triggers a 'SIGNED_IN' authentication state change event.
|
|
381
|
+
* @param credentials Customer login email and optional password.
|
|
382
|
+
* @returns Promise containing the session token and user profile.
|
|
383
|
+
*/
|
|
73
384
|
signIn<TSess = TSession, TU = TUser>(credentials: {
|
|
74
385
|
email: string;
|
|
75
386
|
password?: string;
|
|
76
387
|
}): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
388
|
+
/**
|
|
389
|
+
* Terminate the active customer session, clearing persisted tokens and session memory.
|
|
390
|
+
* Triggers a 'SIGNED_OUT' authentication state change event.
|
|
391
|
+
* @returns Promise resolving once state cleanup is done.
|
|
392
|
+
*/
|
|
77
393
|
signOut(): Promise<void>;
|
|
394
|
+
/**
|
|
395
|
+
* Retrieves the raw internal authentication state synchronously/asynchronously.
|
|
396
|
+
* @returns Promise containing token and user state.
|
|
397
|
+
*/
|
|
78
398
|
getSession<TU = TUser>(): Promise<SessionState<TU>>;
|
|
399
|
+
/**
|
|
400
|
+
* Registers a listener to reactively monitor authentication events.
|
|
401
|
+
* Triggers callback upon 'SIGNED_IN', 'SIGNED_OUT', or 'INITIAL_SESSION' events.
|
|
402
|
+
* @param callback Callback function.
|
|
403
|
+
* @returns Subscription reference containing unsubscribe cleanup method.
|
|
404
|
+
*/
|
|
79
405
|
onAuthStateChange<TU = TUser>(callback: AuthStateCallback<TU>): {
|
|
80
406
|
unsubscribe(): void;
|
|
81
407
|
};
|
|
408
|
+
/**
|
|
409
|
+
* Lists all active concurrent sessions associated with this customer profile.
|
|
410
|
+
* @returns Promise containing the list of active session tokens and metadata.
|
|
411
|
+
*/
|
|
82
412
|
getSessions<TSess = TSession>(): Promise<TSess[]>;
|
|
83
|
-
|
|
84
|
-
|
|
413
|
+
/**
|
|
414
|
+
* Revokes and terminates a specific active customer session by its identifier.
|
|
415
|
+
* @param id The session identifier to destroy.
|
|
416
|
+
* @returns Promise containing the revocation response.
|
|
417
|
+
*/
|
|
418
|
+
revokeSession(id: string): Promise<AxiosResponse<void>>;
|
|
419
|
+
/**
|
|
420
|
+
* Revokes and terminates all other concurrent sessions for this customer.
|
|
421
|
+
* @param mode Optional mode configurations.
|
|
422
|
+
* @returns Promise containing the response.
|
|
423
|
+
*/
|
|
424
|
+
revokeAllSessions(mode?: string): Promise<AxiosResponse<void>>;
|
|
425
|
+
/**
|
|
426
|
+
* Retrieves the current customer user record from the backend.
|
|
427
|
+
* @returns Promise containing the active customer user details.
|
|
428
|
+
*/
|
|
85
429
|
getCurrentSession<TU = TUser>(): Promise<TU>;
|
|
430
|
+
/**
|
|
431
|
+
* Refreshes the active customer session, extending the validity of the customer JWT token.
|
|
432
|
+
* Triggers automatic session token updates and reactive state updates.
|
|
433
|
+
* @returns Promise resolving to the fresh customer authentication response.
|
|
434
|
+
*/
|
|
86
435
|
refreshSession<TSess = TSession, TU = TUser>(): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
87
|
-
|
|
436
|
+
/**
|
|
437
|
+
* Stateful, reactive React Hook that fetches, manages, and updates the customer session.
|
|
438
|
+
* Subscribes to authentication state change listeners to ensure immediate UI synchronization.
|
|
439
|
+
* @returns Reactive session state containing session, user, error, pending flags, and refetch handler.
|
|
440
|
+
*/
|
|
441
|
+
useSession<TSess = TSession, TU = TUser>(): {
|
|
442
|
+
data: {
|
|
443
|
+
session: TSess;
|
|
444
|
+
user: TU;
|
|
445
|
+
} | null;
|
|
446
|
+
isPending: boolean;
|
|
447
|
+
error: any;
|
|
448
|
+
refetch: () => Promise<void>;
|
|
449
|
+
};
|
|
88
450
|
};
|
|
451
|
+
/**
|
|
452
|
+
* Initializes the ScrymeClientSDK.
|
|
453
|
+
* @param config Application and organization configuration parameters.
|
|
454
|
+
*/
|
|
89
455
|
constructor(config: ClientSDKConfig);
|
|
90
456
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
token: string | null;
|
|
97
|
-
isLoading: boolean;
|
|
98
|
-
signIn: (credentials: {
|
|
99
|
-
email: string;
|
|
100
|
-
password?: string;
|
|
101
|
-
}) => Promise<CustomerAuthResponseDto<TUser, TSession>>;
|
|
102
|
-
signUp: (dto: RegisterCustomerDto) => Promise<AxiosResponse<TUser>>;
|
|
103
|
-
signOut: () => Promise<void>;
|
|
104
|
-
cart: TCartResponse | null;
|
|
105
|
-
cartLoading: boolean;
|
|
106
|
-
addToCart: (dto: AddToCartDto) => Promise<void>;
|
|
107
|
-
removeFromCart: (dto: RemoveFromCartDto) => Promise<void>;
|
|
108
|
-
updateCartItem: (dto: AddToCartDto & {
|
|
109
|
-
quantity: number;
|
|
110
|
-
}) => Promise<void>;
|
|
111
|
-
clearCart: (params?: CartControllerClearCartParams) => Promise<void>;
|
|
112
|
-
refreshCart: () => Promise<void>;
|
|
113
|
-
customerProfile: TUser | null;
|
|
114
|
-
customerAddresses: AddressDto[];
|
|
115
|
-
bookings: ServiceBookingItemDto[];
|
|
116
|
-
bookingsLoading: boolean;
|
|
117
|
-
addAddress: (dto: AddressDto) => Promise<AxiosResponse<void>>;
|
|
118
|
-
updateProfile: (dto: UpdateCustomerDto) => Promise<AxiosResponse<TUser>>;
|
|
119
|
-
createBooking: (dto: CreateBookingDto) => Promise<AxiosResponse<void>>;
|
|
120
|
-
cancelBooking: (id: string) => Promise<AxiosResponse<void>>;
|
|
121
|
-
checkoutCart: (params: {
|
|
122
|
-
locationId: string;
|
|
123
|
-
notes?: string;
|
|
124
|
-
channel?: string;
|
|
125
|
-
}) => Promise<OrderResponseDto>;
|
|
126
|
-
refreshProfile: () => Promise<void>;
|
|
127
|
-
refreshBookings: () => Promise<void>;
|
|
128
|
-
}
|
|
129
|
-
interface ScrymeAuthProviderProps<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto> {
|
|
130
|
-
sdk: ScrymeClientSDK<TProduct, TService, TCartItem, TCartResponse, TUser, TSession>;
|
|
131
|
-
children: React.ReactNode;
|
|
132
|
-
}
|
|
133
|
-
declare const ScrymeAuthProvider: <TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto>({ sdk, children, }: ScrymeAuthProviderProps<TProduct, TService, TCartItem, TCartResponse, TUser, TSession>) => react_jsx_runtime.JSX.Element;
|
|
134
|
-
declare const useScrymeAuth: <TUser = CustomerResponseDto, TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TSession = CustomerSessionDto>() => AuthContextType<TUser, TProduct, TService, TCartItem, TCartResponse, TSession>;
|
|
457
|
+
/**
|
|
458
|
+
* Factory helper function to instantiate a ScrymeClientSDK.
|
|
459
|
+
* Retains backward compatibility while enforcing strict ClientSDKConfig types.
|
|
460
|
+
*/
|
|
461
|
+
declare function createClientSDK<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto>(config?: Partial<ClientSDKConfig>): ScrymeClientSDK<TProduct, TService, TCartItem, TCartResponse, TUser, TSession>;
|
|
135
462
|
|
|
136
|
-
export { type AuthChangeEvent, type
|
|
463
|
+
export { type AuthChangeEvent, type AuthStateCallback, type ClientSDKConfig, type ClientSessionStructure, ScrymeClientSDK, type SessionState, type StorageProvider, createClientSDK };
|