@scryme/sdk 9.65.0 → 9.67.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-DZWqHn_L.d.mts → base-1B2-e5i_.d.mts} +78 -20
- package/dist/{base-DZWqHn_L.d.ts → base-1B2-e5i_.d.ts} +78 -20
- package/dist/{chunk-PPNV4D3M.mjs → chunk-QS5K7GIL.mjs} +284 -445
- package/dist/client.d.mts +149 -87
- package/dist/client.d.ts +149 -87
- package/dist/client.js +160 -394
- package/dist/client.mjs +3 -7
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +285 -448
- package/dist/index.mjs +3 -7
- package/dist/server.d.mts +199 -29
- package/dist/server.d.ts +199 -29
- package/dist/server.js +145 -67
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
package/dist/client.d.mts
CHANGED
|
@@ -1,149 +1,211 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
3
|
-
import {
|
|
2
|
+
import { ae as CustomerResponseDto, G as ProductResponseDto, K as ServiceCatalogResponseDto, cM as CartItemDto, b7 as CartResponseDto, dK as CustomerSessionDto, fT as RawAPI, cT as CatalogModule, ep as InventoryModule, fh as OrdersModule, cH as CRMModule, fp as POSModule, bN as AccountingModule, eR as LoyaltyModule, fa as MembersModule, cf as AdminModule, b6 as CartControllerGetCartParams, b9 as AddToCartDto, ba as RemoveFromCartDto, b8 as CartControllerClearCartParams, az as OrderResponseDto, ai as UpdateCustomerDto, aj as AddressDto, af as RegisterCustomerDto, dJ as CustomerAuthResponseDto, a0 as CreateBookingDto, gf as ServiceBookingItemDto, cs as AuthModule, s as AuthExchangeToken201 } from './base-1B2-e5i_.mjs';
|
|
4
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
|
+
*/
|
|
5
8
|
interface StorageProvider {
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves an item from storage.
|
|
11
|
+
* @param key Unique storage key.
|
|
12
|
+
*/
|
|
6
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
|
+
*/
|
|
7
19
|
setItem(key: string, value: string): void | Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes an item from storage.
|
|
22
|
+
* @param key Unique storage key.
|
|
23
|
+
*/
|
|
8
24
|
removeItem(key: string): void | Promise<void>;
|
|
9
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for the stateful ScrymeClientSDK.
|
|
28
|
+
*/
|
|
10
29
|
interface ClientSDKConfig {
|
|
30
|
+
/**
|
|
31
|
+
* The client ID of your Storefront application.
|
|
32
|
+
*/
|
|
11
33
|
clientId: string;
|
|
34
|
+
/**
|
|
35
|
+
* The optional client secret. It is omitted on the client side for maximum security.
|
|
36
|
+
*/
|
|
12
37
|
clientSecret?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The unique slug of the organization to target.
|
|
40
|
+
*/
|
|
13
41
|
orgSlug: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional base API URL. Defaults to "https://api.scryme.tech".
|
|
44
|
+
*/
|
|
14
45
|
baseURL?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Custom storage provider to persist session tokens. Defaults to localStorage where available.
|
|
48
|
+
*/
|
|
15
49
|
storage?: StorageProvider;
|
|
16
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Represents the authentication change events emitted by the SDK.
|
|
53
|
+
*/
|
|
17
54
|
type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "INITIAL_SESSION";
|
|
18
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Represents the active customer session status.
|
|
57
|
+
* @template TUser Custom User profile type.
|
|
58
|
+
*/
|
|
59
|
+
interface SessionState<TUser = CustomerResponseDto> {
|
|
60
|
+
/**
|
|
61
|
+
* The current customer authentication JWT token.
|
|
62
|
+
*/
|
|
19
63
|
token: string | null;
|
|
20
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The deserialized customer profile details.
|
|
66
|
+
*/
|
|
67
|
+
user: TUser | null;
|
|
68
|
+
/**
|
|
69
|
+
* Epoch millisecond expiration timestamp of the token.
|
|
70
|
+
*/
|
|
21
71
|
expiresAt?: number | null;
|
|
22
72
|
}
|
|
23
|
-
|
|
24
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Callback signature triggered whenever the customer authentication status changes.
|
|
75
|
+
*/
|
|
76
|
+
type AuthStateCallback<TUser = CustomerResponseDto> = (event: AuthChangeEvent, session: SessionState<TUser>) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Stateful, reactive Client-Side SDK for Scryme V3.
|
|
79
|
+
*
|
|
80
|
+
* Automatically handles JWT token exchanges, reactive customer session refreshes,
|
|
81
|
+
* stateful shopping cart synchronization, and real-time authentication state updates.
|
|
82
|
+
*
|
|
83
|
+
* @template TProduct Custom Product DTO type override. Defaults to ProductResponseDto.
|
|
84
|
+
* @template TService Custom Service DTO type override. Defaults to ServiceCatalogResponseDto.
|
|
85
|
+
* @template TCartItem Custom Cart Item DTO type override. Defaults to CartItemDto.
|
|
86
|
+
* @template TCartResponse Custom Cart Response DTO type override. Defaults to CartResponseDto.
|
|
87
|
+
* @template TUser Custom User Profile DTO type override. Defaults to CustomerResponseDto.
|
|
88
|
+
* @template TSession Custom Customer Session DTO type override. Defaults to CustomerSessionDto.
|
|
89
|
+
*/
|
|
90
|
+
declare class ScrymeClientSDK<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto> {
|
|
91
|
+
/**
|
|
92
|
+
* Underlying Axios instance initialized with the customized baseUrl and automatic interceptors.
|
|
93
|
+
*/
|
|
25
94
|
axiosInstance: AxiosInstance;
|
|
95
|
+
/**
|
|
96
|
+
* Raw proxy API client exposing all standard endpoints auto-bound with the configured orgSlug.
|
|
97
|
+
*/
|
|
26
98
|
api: RawAPI;
|
|
27
|
-
|
|
99
|
+
/** Catalog operations submodule (products, services, categories, bookings, staff schedules). */
|
|
100
|
+
catalog: CatalogModule<TProduct, TService>;
|
|
101
|
+
/** Traceability, split/merge, physical reconciliation, and partner wallet operations submodule. */
|
|
28
102
|
inventory: InventoryModule;
|
|
103
|
+
/** Cart management, sales order orchestration, checkout processing, and payments submodule. */
|
|
29
104
|
orders: OrdersModule;
|
|
105
|
+
/** Custom fields, relationships, note logging, associations, and CRM timeline submodule. */
|
|
30
106
|
crm: CRMModule;
|
|
107
|
+
/** Cash flow register, sale processing, terminal synchronization, and device provision submodule. */
|
|
31
108
|
pos: POSModule;
|
|
109
|
+
/** Balance sheets, Profit & Loss reports, expenses, invoices, and utility account submodule. */
|
|
32
110
|
accounting: AccountingModule;
|
|
111
|
+
/** Rewards, voucher validation, point balances, and customer favorite records submodule. */
|
|
33
112
|
loyalty: LoyaltyModule;
|
|
113
|
+
/** Staff members, department directories, check-in logs, and broadcast announcements submodule. */
|
|
34
114
|
members: MembersModule;
|
|
115
|
+
/** Global setup parameters, organization definitions, audit trails, and tier limit submodule. */
|
|
35
116
|
admin: AdminModule;
|
|
117
|
+
/**
|
|
118
|
+
* Stateful Shopping Cart Submodule.
|
|
119
|
+
* Leverages internal tracking and smart delta calculations for optimized storefront shopping.
|
|
120
|
+
*/
|
|
36
121
|
cart: {
|
|
37
|
-
get(params?: CartControllerGetCartParams): Promise<AxiosResponse<
|
|
122
|
+
get<T = TCartResponse>(params?: CartControllerGetCartParams): Promise<AxiosResponse<T & Record<string, any>>>;
|
|
38
123
|
add(dto: AddToCartDto): Promise<AxiosResponse<void>>;
|
|
39
124
|
remove(dto: RemoveFromCartDto): Promise<AxiosResponse<void>>;
|
|
40
125
|
clear(params?: CartControllerClearCartParams): Promise<AxiosResponse<void>>;
|
|
41
|
-
update(dto: AddToCartDto & {
|
|
126
|
+
update<T = TCartResponse>(dto: AddToCartDto & {
|
|
42
127
|
quantity: number;
|
|
43
|
-
}): Promise<AxiosResponse<void> | AxiosResponse<
|
|
44
|
-
getItems(params?: CartControllerGetCartParams): Promise<
|
|
45
|
-
getTotals(params?: CartControllerGetCartParams): Promise<{
|
|
128
|
+
}): Promise<AxiosResponse<void> | AxiosResponse<T> | undefined>;
|
|
129
|
+
getItems<T = TCartItem>(params?: CartControllerGetCartParams): Promise<T[]>;
|
|
130
|
+
getTotals<TItem = TCartItem, TRaw = TCartResponse>(params?: CartControllerGetCartParams): Promise<{
|
|
46
131
|
itemsCount: number;
|
|
47
|
-
items:
|
|
48
|
-
raw:
|
|
132
|
+
items: TItem[];
|
|
133
|
+
raw: TRaw;
|
|
49
134
|
}>;
|
|
50
|
-
mergeGuestCart(guestSessionId: string, customerId: string): Promise<AxiosResponse<
|
|
135
|
+
mergeGuestCart<T = TCartResponse>(guestSessionId: string, customerId: string): Promise<AxiosResponse<T & Record<string, any>>>;
|
|
51
136
|
checkout(params: {
|
|
52
137
|
locationId: string;
|
|
53
138
|
notes?: string;
|
|
54
139
|
channel?: string;
|
|
55
140
|
}): Promise<OrderResponseDto>;
|
|
56
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Storefront Customer Profile Submodule.
|
|
144
|
+
* Manages the authenticated user's self-serve account, update workflows, and shipping/billing directories.
|
|
145
|
+
*/
|
|
57
146
|
customer: {
|
|
58
|
-
getProfile(): Promise<
|
|
59
|
-
updateProfile(dto: UpdateCustomerDto): Promise<AxiosResponse<
|
|
147
|
+
getProfile<T = TUser>(): Promise<T>;
|
|
148
|
+
updateProfile<T = TUser>(dto: UpdateCustomerDto): Promise<AxiosResponse<T>>;
|
|
60
149
|
getAddresses(): Promise<AxiosResponse<AddressDto[]>>;
|
|
61
150
|
addAddress(dto: AddressDto): Promise<AxiosResponse<void>>;
|
|
151
|
+
auth: {
|
|
152
|
+
signUp<T = TUser>(dto: RegisterCustomerDto): Promise<AxiosResponse<T>>;
|
|
153
|
+
signIn<TSess = TSession, TU = TUser>(credentials: {
|
|
154
|
+
email: string;
|
|
155
|
+
password?: string;
|
|
156
|
+
}): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
157
|
+
signOut(): Promise<void>;
|
|
158
|
+
getSession<TU = TUser>(): Promise<SessionState<TU>>;
|
|
159
|
+
onAuthStateChange<TU = TUser>(callback: AuthStateCallback<TU>): {
|
|
160
|
+
unsubscribe(): void;
|
|
161
|
+
};
|
|
162
|
+
getSessions<TSess = TSession>(): Promise<TSess[]>;
|
|
163
|
+
revokeSession(id: string): Promise<AxiosResponse<void>>;
|
|
164
|
+
revokeAllSessions(mode?: string): Promise<AxiosResponse<void>>;
|
|
165
|
+
getCurrentSession<TU = TUser>(): Promise<TU>;
|
|
166
|
+
refreshSession<TSess = TSession, TU = TUser>(): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
167
|
+
};
|
|
62
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* Service Bookings & Appointments Submodule.
|
|
171
|
+
*/
|
|
63
172
|
bookings: {
|
|
64
173
|
create(dto: CreateBookingDto): Promise<AxiosResponse<void>>;
|
|
65
174
|
get(id: string): Promise<AxiosResponse<ServiceBookingItemDto>>;
|
|
66
175
|
list(): Promise<AxiosResponse<ServiceBookingItemDto[]>>;
|
|
67
176
|
cancel(id: string): Promise<AxiosResponse<void>>;
|
|
68
177
|
};
|
|
178
|
+
/**
|
|
179
|
+
* Authentication & Customer Session Submodule.
|
|
180
|
+
*/
|
|
69
181
|
auth: AuthModule & {
|
|
70
|
-
signUp(dto: RegisterCustomerDto): Promise<AxiosResponse<
|
|
182
|
+
signUp<T = TUser>(dto: RegisterCustomerDto): Promise<AxiosResponse<T>>;
|
|
71
183
|
authenticate(): Promise<AuthExchangeToken201>;
|
|
72
|
-
signIn(credentials: {
|
|
184
|
+
signIn<TSess = TSession, TU = TUser>(credentials: {
|
|
73
185
|
email: string;
|
|
74
186
|
password?: string;
|
|
75
|
-
}): Promise<
|
|
76
|
-
token: string;
|
|
77
|
-
session?: any;
|
|
78
|
-
user?: any;
|
|
79
|
-
}>;
|
|
187
|
+
}): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
80
188
|
signOut(): Promise<void>;
|
|
81
|
-
getSession(): Promise<SessionState
|
|
82
|
-
onAuthStateChange(callback: AuthStateCallback): {
|
|
189
|
+
getSession<TU = TUser>(): Promise<SessionState<TU>>;
|
|
190
|
+
onAuthStateChange<TU = TUser>(callback: AuthStateCallback<TU>): {
|
|
83
191
|
unsubscribe(): void;
|
|
84
192
|
};
|
|
85
|
-
getSessions(): Promise<
|
|
86
|
-
revokeSession(id: string): Promise<
|
|
87
|
-
revokeAllSessions(mode?: string): Promise<
|
|
88
|
-
getCurrentSession(): Promise<
|
|
89
|
-
refreshSession(): Promise<
|
|
90
|
-
token: string;
|
|
91
|
-
session?: any;
|
|
92
|
-
}>;
|
|
93
|
-
swapZitadel(zitadelToken: string): Promise<{
|
|
94
|
-
token: string;
|
|
95
|
-
session?: any;
|
|
96
|
-
}>;
|
|
193
|
+
getSessions<TSess = TSession>(): Promise<TSess[]>;
|
|
194
|
+
revokeSession(id: string): Promise<AxiosResponse<void>>;
|
|
195
|
+
revokeAllSessions(mode?: string): Promise<AxiosResponse<void>>;
|
|
196
|
+
getCurrentSession<TU = TUser>(): Promise<TU>;
|
|
197
|
+
refreshSession<TSess = TSession, TU = TUser>(): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
97
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* Initializes the ScrymeClientSDK.
|
|
201
|
+
* @param config Application and organization configuration parameters.
|
|
202
|
+
*/
|
|
98
203
|
constructor(config: ClientSDKConfig);
|
|
99
204
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
token: string | null;
|
|
106
|
-
isLoading: boolean;
|
|
107
|
-
signIn: (credentials: {
|
|
108
|
-
email: string;
|
|
109
|
-
password?: string;
|
|
110
|
-
}) => Promise<{
|
|
111
|
-
token: string;
|
|
112
|
-
session?: any;
|
|
113
|
-
user?: any;
|
|
114
|
-
}>;
|
|
115
|
-
signUp: (dto: RegisterCustomerDto) => Promise<AxiosResponse<CustomerResponseDto>>;
|
|
116
|
-
signOut: () => Promise<void>;
|
|
117
|
-
cart: CartResponseDto | null;
|
|
118
|
-
cartLoading: boolean;
|
|
119
|
-
addToCart: (dto: AddToCartDto) => Promise<void>;
|
|
120
|
-
removeFromCart: (dto: RemoveFromCartDto) => Promise<void>;
|
|
121
|
-
updateCartItem: (dto: AddToCartDto & {
|
|
122
|
-
quantity: number;
|
|
123
|
-
}) => Promise<void>;
|
|
124
|
-
clearCart: (params?: CartControllerClearCartParams) => Promise<void>;
|
|
125
|
-
refreshCart: () => Promise<void>;
|
|
126
|
-
customerProfile: CustomerResponseDto | null;
|
|
127
|
-
customerAddresses: AddressDto[];
|
|
128
|
-
bookings: ServiceBookingItemDto[];
|
|
129
|
-
bookingsLoading: boolean;
|
|
130
|
-
addAddress: (dto: AddressDto) => Promise<AxiosResponse<void>>;
|
|
131
|
-
updateProfile: (dto: UpdateCustomerDto) => Promise<AxiosResponse<CustomerResponseDto>>;
|
|
132
|
-
createBooking: (dto: CreateBookingDto) => Promise<AxiosResponse<void>>;
|
|
133
|
-
cancelBooking: (id: string) => Promise<AxiosResponse<void>>;
|
|
134
|
-
checkoutCart: (params: {
|
|
135
|
-
locationId: string;
|
|
136
|
-
notes?: string;
|
|
137
|
-
channel?: string;
|
|
138
|
-
}) => Promise<OrderResponseDto>;
|
|
139
|
-
refreshProfile: () => Promise<void>;
|
|
140
|
-
refreshBookings: () => Promise<void>;
|
|
141
|
-
}
|
|
142
|
-
interface ScrymeAuthProviderProps {
|
|
143
|
-
sdk: ScrymeClientSDK;
|
|
144
|
-
children: React.ReactNode;
|
|
145
|
-
}
|
|
146
|
-
declare const ScrymeAuthProvider: React.FC<ScrymeAuthProviderProps>;
|
|
147
|
-
declare const useScrymeAuth: () => AuthContextType;
|
|
205
|
+
/**
|
|
206
|
+
* Factory helper function to instantiate a ScrymeClientSDK.
|
|
207
|
+
* Retains backward compatibility while enforcing strict ClientSDKConfig types.
|
|
208
|
+
*/
|
|
209
|
+
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>;
|
|
148
210
|
|
|
149
|
-
export { type AuthChangeEvent, type
|
|
211
|
+
export { type AuthChangeEvent, type AuthStateCallback, type ClientSDKConfig, ScrymeClientSDK, type SessionState, type StorageProvider, createClientSDK };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,149 +1,211 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
3
|
-
import {
|
|
2
|
+
import { ae as CustomerResponseDto, G as ProductResponseDto, K as ServiceCatalogResponseDto, cM as CartItemDto, b7 as CartResponseDto, dK as CustomerSessionDto, fT as RawAPI, cT as CatalogModule, ep as InventoryModule, fh as OrdersModule, cH as CRMModule, fp as POSModule, bN as AccountingModule, eR as LoyaltyModule, fa as MembersModule, cf as AdminModule, b6 as CartControllerGetCartParams, b9 as AddToCartDto, ba as RemoveFromCartDto, b8 as CartControllerClearCartParams, az as OrderResponseDto, ai as UpdateCustomerDto, aj as AddressDto, af as RegisterCustomerDto, dJ as CustomerAuthResponseDto, a0 as CreateBookingDto, gf as ServiceBookingItemDto, cs as AuthModule, s as AuthExchangeToken201 } from './base-1B2-e5i_.js';
|
|
4
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
|
+
*/
|
|
5
8
|
interface StorageProvider {
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves an item from storage.
|
|
11
|
+
* @param key Unique storage key.
|
|
12
|
+
*/
|
|
6
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
|
+
*/
|
|
7
19
|
setItem(key: string, value: string): void | Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes an item from storage.
|
|
22
|
+
* @param key Unique storage key.
|
|
23
|
+
*/
|
|
8
24
|
removeItem(key: string): void | Promise<void>;
|
|
9
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for the stateful ScrymeClientSDK.
|
|
28
|
+
*/
|
|
10
29
|
interface ClientSDKConfig {
|
|
30
|
+
/**
|
|
31
|
+
* The client ID of your Storefront application.
|
|
32
|
+
*/
|
|
11
33
|
clientId: string;
|
|
34
|
+
/**
|
|
35
|
+
* The optional client secret. It is omitted on the client side for maximum security.
|
|
36
|
+
*/
|
|
12
37
|
clientSecret?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The unique slug of the organization to target.
|
|
40
|
+
*/
|
|
13
41
|
orgSlug: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional base API URL. Defaults to "https://api.scryme.tech".
|
|
44
|
+
*/
|
|
14
45
|
baseURL?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Custom storage provider to persist session tokens. Defaults to localStorage where available.
|
|
48
|
+
*/
|
|
15
49
|
storage?: StorageProvider;
|
|
16
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Represents the authentication change events emitted by the SDK.
|
|
53
|
+
*/
|
|
17
54
|
type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "INITIAL_SESSION";
|
|
18
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Represents the active customer session status.
|
|
57
|
+
* @template TUser Custom User profile type.
|
|
58
|
+
*/
|
|
59
|
+
interface SessionState<TUser = CustomerResponseDto> {
|
|
60
|
+
/**
|
|
61
|
+
* The current customer authentication JWT token.
|
|
62
|
+
*/
|
|
19
63
|
token: string | null;
|
|
20
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The deserialized customer profile details.
|
|
66
|
+
*/
|
|
67
|
+
user: TUser | null;
|
|
68
|
+
/**
|
|
69
|
+
* Epoch millisecond expiration timestamp of the token.
|
|
70
|
+
*/
|
|
21
71
|
expiresAt?: number | null;
|
|
22
72
|
}
|
|
23
|
-
|
|
24
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Callback signature triggered whenever the customer authentication status changes.
|
|
75
|
+
*/
|
|
76
|
+
type AuthStateCallback<TUser = CustomerResponseDto> = (event: AuthChangeEvent, session: SessionState<TUser>) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Stateful, reactive Client-Side SDK for Scryme V3.
|
|
79
|
+
*
|
|
80
|
+
* Automatically handles JWT token exchanges, reactive customer session refreshes,
|
|
81
|
+
* stateful shopping cart synchronization, and real-time authentication state updates.
|
|
82
|
+
*
|
|
83
|
+
* @template TProduct Custom Product DTO type override. Defaults to ProductResponseDto.
|
|
84
|
+
* @template TService Custom Service DTO type override. Defaults to ServiceCatalogResponseDto.
|
|
85
|
+
* @template TCartItem Custom Cart Item DTO type override. Defaults to CartItemDto.
|
|
86
|
+
* @template TCartResponse Custom Cart Response DTO type override. Defaults to CartResponseDto.
|
|
87
|
+
* @template TUser Custom User Profile DTO type override. Defaults to CustomerResponseDto.
|
|
88
|
+
* @template TSession Custom Customer Session DTO type override. Defaults to CustomerSessionDto.
|
|
89
|
+
*/
|
|
90
|
+
declare class ScrymeClientSDK<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto> {
|
|
91
|
+
/**
|
|
92
|
+
* Underlying Axios instance initialized with the customized baseUrl and automatic interceptors.
|
|
93
|
+
*/
|
|
25
94
|
axiosInstance: AxiosInstance;
|
|
95
|
+
/**
|
|
96
|
+
* Raw proxy API client exposing all standard endpoints auto-bound with the configured orgSlug.
|
|
97
|
+
*/
|
|
26
98
|
api: RawAPI;
|
|
27
|
-
|
|
99
|
+
/** Catalog operations submodule (products, services, categories, bookings, staff schedules). */
|
|
100
|
+
catalog: CatalogModule<TProduct, TService>;
|
|
101
|
+
/** Traceability, split/merge, physical reconciliation, and partner wallet operations submodule. */
|
|
28
102
|
inventory: InventoryModule;
|
|
103
|
+
/** Cart management, sales order orchestration, checkout processing, and payments submodule. */
|
|
29
104
|
orders: OrdersModule;
|
|
105
|
+
/** Custom fields, relationships, note logging, associations, and CRM timeline submodule. */
|
|
30
106
|
crm: CRMModule;
|
|
107
|
+
/** Cash flow register, sale processing, terminal synchronization, and device provision submodule. */
|
|
31
108
|
pos: POSModule;
|
|
109
|
+
/** Balance sheets, Profit & Loss reports, expenses, invoices, and utility account submodule. */
|
|
32
110
|
accounting: AccountingModule;
|
|
111
|
+
/** Rewards, voucher validation, point balances, and customer favorite records submodule. */
|
|
33
112
|
loyalty: LoyaltyModule;
|
|
113
|
+
/** Staff members, department directories, check-in logs, and broadcast announcements submodule. */
|
|
34
114
|
members: MembersModule;
|
|
115
|
+
/** Global setup parameters, organization definitions, audit trails, and tier limit submodule. */
|
|
35
116
|
admin: AdminModule;
|
|
117
|
+
/**
|
|
118
|
+
* Stateful Shopping Cart Submodule.
|
|
119
|
+
* Leverages internal tracking and smart delta calculations for optimized storefront shopping.
|
|
120
|
+
*/
|
|
36
121
|
cart: {
|
|
37
|
-
get(params?: CartControllerGetCartParams): Promise<AxiosResponse<
|
|
122
|
+
get<T = TCartResponse>(params?: CartControllerGetCartParams): Promise<AxiosResponse<T & Record<string, any>>>;
|
|
38
123
|
add(dto: AddToCartDto): Promise<AxiosResponse<void>>;
|
|
39
124
|
remove(dto: RemoveFromCartDto): Promise<AxiosResponse<void>>;
|
|
40
125
|
clear(params?: CartControllerClearCartParams): Promise<AxiosResponse<void>>;
|
|
41
|
-
update(dto: AddToCartDto & {
|
|
126
|
+
update<T = TCartResponse>(dto: AddToCartDto & {
|
|
42
127
|
quantity: number;
|
|
43
|
-
}): Promise<AxiosResponse<void> | AxiosResponse<
|
|
44
|
-
getItems(params?: CartControllerGetCartParams): Promise<
|
|
45
|
-
getTotals(params?: CartControllerGetCartParams): Promise<{
|
|
128
|
+
}): Promise<AxiosResponse<void> | AxiosResponse<T> | undefined>;
|
|
129
|
+
getItems<T = TCartItem>(params?: CartControllerGetCartParams): Promise<T[]>;
|
|
130
|
+
getTotals<TItem = TCartItem, TRaw = TCartResponse>(params?: CartControllerGetCartParams): Promise<{
|
|
46
131
|
itemsCount: number;
|
|
47
|
-
items:
|
|
48
|
-
raw:
|
|
132
|
+
items: TItem[];
|
|
133
|
+
raw: TRaw;
|
|
49
134
|
}>;
|
|
50
|
-
mergeGuestCart(guestSessionId: string, customerId: string): Promise<AxiosResponse<
|
|
135
|
+
mergeGuestCart<T = TCartResponse>(guestSessionId: string, customerId: string): Promise<AxiosResponse<T & Record<string, any>>>;
|
|
51
136
|
checkout(params: {
|
|
52
137
|
locationId: string;
|
|
53
138
|
notes?: string;
|
|
54
139
|
channel?: string;
|
|
55
140
|
}): Promise<OrderResponseDto>;
|
|
56
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Storefront Customer Profile Submodule.
|
|
144
|
+
* Manages the authenticated user's self-serve account, update workflows, and shipping/billing directories.
|
|
145
|
+
*/
|
|
57
146
|
customer: {
|
|
58
|
-
getProfile(): Promise<
|
|
59
|
-
updateProfile(dto: UpdateCustomerDto): Promise<AxiosResponse<
|
|
147
|
+
getProfile<T = TUser>(): Promise<T>;
|
|
148
|
+
updateProfile<T = TUser>(dto: UpdateCustomerDto): Promise<AxiosResponse<T>>;
|
|
60
149
|
getAddresses(): Promise<AxiosResponse<AddressDto[]>>;
|
|
61
150
|
addAddress(dto: AddressDto): Promise<AxiosResponse<void>>;
|
|
151
|
+
auth: {
|
|
152
|
+
signUp<T = TUser>(dto: RegisterCustomerDto): Promise<AxiosResponse<T>>;
|
|
153
|
+
signIn<TSess = TSession, TU = TUser>(credentials: {
|
|
154
|
+
email: string;
|
|
155
|
+
password?: string;
|
|
156
|
+
}): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
157
|
+
signOut(): Promise<void>;
|
|
158
|
+
getSession<TU = TUser>(): Promise<SessionState<TU>>;
|
|
159
|
+
onAuthStateChange<TU = TUser>(callback: AuthStateCallback<TU>): {
|
|
160
|
+
unsubscribe(): void;
|
|
161
|
+
};
|
|
162
|
+
getSessions<TSess = TSession>(): Promise<TSess[]>;
|
|
163
|
+
revokeSession(id: string): Promise<AxiosResponse<void>>;
|
|
164
|
+
revokeAllSessions(mode?: string): Promise<AxiosResponse<void>>;
|
|
165
|
+
getCurrentSession<TU = TUser>(): Promise<TU>;
|
|
166
|
+
refreshSession<TSess = TSession, TU = TUser>(): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
167
|
+
};
|
|
62
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* Service Bookings & Appointments Submodule.
|
|
171
|
+
*/
|
|
63
172
|
bookings: {
|
|
64
173
|
create(dto: CreateBookingDto): Promise<AxiosResponse<void>>;
|
|
65
174
|
get(id: string): Promise<AxiosResponse<ServiceBookingItemDto>>;
|
|
66
175
|
list(): Promise<AxiosResponse<ServiceBookingItemDto[]>>;
|
|
67
176
|
cancel(id: string): Promise<AxiosResponse<void>>;
|
|
68
177
|
};
|
|
178
|
+
/**
|
|
179
|
+
* Authentication & Customer Session Submodule.
|
|
180
|
+
*/
|
|
69
181
|
auth: AuthModule & {
|
|
70
|
-
signUp(dto: RegisterCustomerDto): Promise<AxiosResponse<
|
|
182
|
+
signUp<T = TUser>(dto: RegisterCustomerDto): Promise<AxiosResponse<T>>;
|
|
71
183
|
authenticate(): Promise<AuthExchangeToken201>;
|
|
72
|
-
signIn(credentials: {
|
|
184
|
+
signIn<TSess = TSession, TU = TUser>(credentials: {
|
|
73
185
|
email: string;
|
|
74
186
|
password?: string;
|
|
75
|
-
}): Promise<
|
|
76
|
-
token: string;
|
|
77
|
-
session?: any;
|
|
78
|
-
user?: any;
|
|
79
|
-
}>;
|
|
187
|
+
}): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
80
188
|
signOut(): Promise<void>;
|
|
81
|
-
getSession(): Promise<SessionState
|
|
82
|
-
onAuthStateChange(callback: AuthStateCallback): {
|
|
189
|
+
getSession<TU = TUser>(): Promise<SessionState<TU>>;
|
|
190
|
+
onAuthStateChange<TU = TUser>(callback: AuthStateCallback<TU>): {
|
|
83
191
|
unsubscribe(): void;
|
|
84
192
|
};
|
|
85
|
-
getSessions(): Promise<
|
|
86
|
-
revokeSession(id: string): Promise<
|
|
87
|
-
revokeAllSessions(mode?: string): Promise<
|
|
88
|
-
getCurrentSession(): Promise<
|
|
89
|
-
refreshSession(): Promise<
|
|
90
|
-
token: string;
|
|
91
|
-
session?: any;
|
|
92
|
-
}>;
|
|
93
|
-
swapZitadel(zitadelToken: string): Promise<{
|
|
94
|
-
token: string;
|
|
95
|
-
session?: any;
|
|
96
|
-
}>;
|
|
193
|
+
getSessions<TSess = TSession>(): Promise<TSess[]>;
|
|
194
|
+
revokeSession(id: string): Promise<AxiosResponse<void>>;
|
|
195
|
+
revokeAllSessions(mode?: string): Promise<AxiosResponse<void>>;
|
|
196
|
+
getCurrentSession<TU = TUser>(): Promise<TU>;
|
|
197
|
+
refreshSession<TSess = TSession, TU = TUser>(): Promise<CustomerAuthResponseDto<TU, TSess>>;
|
|
97
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* Initializes the ScrymeClientSDK.
|
|
201
|
+
* @param config Application and organization configuration parameters.
|
|
202
|
+
*/
|
|
98
203
|
constructor(config: ClientSDKConfig);
|
|
99
204
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
token: string | null;
|
|
106
|
-
isLoading: boolean;
|
|
107
|
-
signIn: (credentials: {
|
|
108
|
-
email: string;
|
|
109
|
-
password?: string;
|
|
110
|
-
}) => Promise<{
|
|
111
|
-
token: string;
|
|
112
|
-
session?: any;
|
|
113
|
-
user?: any;
|
|
114
|
-
}>;
|
|
115
|
-
signUp: (dto: RegisterCustomerDto) => Promise<AxiosResponse<CustomerResponseDto>>;
|
|
116
|
-
signOut: () => Promise<void>;
|
|
117
|
-
cart: CartResponseDto | null;
|
|
118
|
-
cartLoading: boolean;
|
|
119
|
-
addToCart: (dto: AddToCartDto) => Promise<void>;
|
|
120
|
-
removeFromCart: (dto: RemoveFromCartDto) => Promise<void>;
|
|
121
|
-
updateCartItem: (dto: AddToCartDto & {
|
|
122
|
-
quantity: number;
|
|
123
|
-
}) => Promise<void>;
|
|
124
|
-
clearCart: (params?: CartControllerClearCartParams) => Promise<void>;
|
|
125
|
-
refreshCart: () => Promise<void>;
|
|
126
|
-
customerProfile: CustomerResponseDto | null;
|
|
127
|
-
customerAddresses: AddressDto[];
|
|
128
|
-
bookings: ServiceBookingItemDto[];
|
|
129
|
-
bookingsLoading: boolean;
|
|
130
|
-
addAddress: (dto: AddressDto) => Promise<AxiosResponse<void>>;
|
|
131
|
-
updateProfile: (dto: UpdateCustomerDto) => Promise<AxiosResponse<CustomerResponseDto>>;
|
|
132
|
-
createBooking: (dto: CreateBookingDto) => Promise<AxiosResponse<void>>;
|
|
133
|
-
cancelBooking: (id: string) => Promise<AxiosResponse<void>>;
|
|
134
|
-
checkoutCart: (params: {
|
|
135
|
-
locationId: string;
|
|
136
|
-
notes?: string;
|
|
137
|
-
channel?: string;
|
|
138
|
-
}) => Promise<OrderResponseDto>;
|
|
139
|
-
refreshProfile: () => Promise<void>;
|
|
140
|
-
refreshBookings: () => Promise<void>;
|
|
141
|
-
}
|
|
142
|
-
interface ScrymeAuthProviderProps {
|
|
143
|
-
sdk: ScrymeClientSDK;
|
|
144
|
-
children: React.ReactNode;
|
|
145
|
-
}
|
|
146
|
-
declare const ScrymeAuthProvider: React.FC<ScrymeAuthProviderProps>;
|
|
147
|
-
declare const useScrymeAuth: () => AuthContextType;
|
|
205
|
+
/**
|
|
206
|
+
* Factory helper function to instantiate a ScrymeClientSDK.
|
|
207
|
+
* Retains backward compatibility while enforcing strict ClientSDKConfig types.
|
|
208
|
+
*/
|
|
209
|
+
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>;
|
|
148
210
|
|
|
149
|
-
export { type AuthChangeEvent, type
|
|
211
|
+
export { type AuthChangeEvent, type AuthStateCallback, type ClientSDKConfig, ScrymeClientSDK, type SessionState, type StorageProvider, createClientSDK };
|