@scryme/sdk 9.64.2 → 9.66.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/dist/client.d.mts CHANGED
@@ -1,5 +1,7 @@
1
- import { AxiosInstance } from 'axios';
2
- import { fx as RawAPI, cM as CatalogModule, eb as InventoryModule, f3 as OrdersModule, cB as CRMModule, fb as POSModule, bH as AccountingModule, eD as LoyaltyModule, eY as MembersModule, c9 as AdminModule, cm as AuthModule, ab as RegisterCustomerDto } from './base-DZXCyXwH.mjs';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import { AxiosInstance, AxiosResponse } from 'axios';
4
+ import { af as CustomerResponseDto, G as ProductResponseDto, K as ServiceCatalogResponseDto, cN as CartItemDto, b8 as CartResponseDto, dK as CustomerSessionDto, fT as RawAPI, cT as CatalogModule, ep as InventoryModule, fh as OrdersModule, cI as CRMModule, fp as POSModule, bO as AccountingModule, eR as LoyaltyModule, fa as MembersModule, cg as AdminModule, b7 as CartControllerGetCartParams, ba as AddToCartDto, bb as RemoveFromCartDto, b9 as CartControllerClearCartParams, aA as OrderResponseDto, aj as UpdateCustomerDto, ak as AddressDto, a0 as CreateBookingDto, gf as ServiceBookingItemDto, ct as AuthModule, ag as RegisterCustomerDto, s as AuthExchangeToken201, dJ as CustomerAuthResponseDto } from './base-Cl7_QxqC.mjs';
3
5
 
4
6
  interface StorageProvider {
5
7
  getItem(key: string): string | null | Promise<string | null>;
@@ -8,22 +10,22 @@ interface StorageProvider {
8
10
  }
9
11
  interface ClientSDKConfig {
10
12
  clientId: string;
11
- clientSecret: string;
13
+ clientSecret?: string;
12
14
  orgSlug: string;
13
15
  baseURL?: string;
14
16
  storage?: StorageProvider;
15
17
  }
16
18
  type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "INITIAL_SESSION";
17
- interface SessionState {
19
+ interface SessionState<TUser = CustomerResponseDto> {
18
20
  token: string | null;
19
- user: any | null;
21
+ user: TUser | null;
20
22
  expiresAt?: number | null;
21
23
  }
22
- type AuthStateCallback = (event: AuthChangeEvent, session: SessionState) => void;
23
- declare class ScrymeClientSDK {
24
+ type AuthStateCallback<TUser = CustomerResponseDto> = (event: AuthChangeEvent, session: SessionState<TUser>) => void;
25
+ declare class ScrymeClientSDK<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto> {
24
26
  axiosInstance: AxiosInstance;
25
27
  api: RawAPI;
26
- catalog: CatalogModule;
28
+ catalog: CatalogModule<TProduct, TService>;
27
29
  inventory: InventoryModule;
28
30
  orders: OrdersModule;
29
31
  crm: CRMModule;
@@ -32,21 +34,103 @@ declare class ScrymeClientSDK {
32
34
  loyalty: LoyaltyModule;
33
35
  members: MembersModule;
34
36
  admin: AdminModule;
37
+ cart: {
38
+ get<T = TCartResponse>(params?: CartControllerGetCartParams): Promise<AxiosResponse<T & Record<string, any>>>;
39
+ add(dto: AddToCartDto): Promise<AxiosResponse<void>>;
40
+ remove(dto: RemoveFromCartDto): Promise<AxiosResponse<void>>;
41
+ clear(params?: CartControllerClearCartParams): Promise<AxiosResponse<void>>;
42
+ update<T = TCartResponse>(dto: AddToCartDto & {
43
+ quantity: number;
44
+ }): Promise<AxiosResponse<void> | AxiosResponse<T> | undefined>;
45
+ getItems<T = TCartItem>(params?: CartControllerGetCartParams): Promise<T[]>;
46
+ getTotals<TItem = TCartItem, TRaw = TCartResponse>(params?: CartControllerGetCartParams): Promise<{
47
+ itemsCount: number;
48
+ items: TItem[];
49
+ raw: TRaw;
50
+ }>;
51
+ mergeGuestCart<T = TCartResponse>(guestSessionId: string, customerId: string): Promise<AxiosResponse<T & Record<string, any>>>;
52
+ checkout(params: {
53
+ locationId: string;
54
+ notes?: string;
55
+ channel?: string;
56
+ }): Promise<OrderResponseDto>;
57
+ };
58
+ customer: {
59
+ getProfile<T = TUser>(): Promise<T>;
60
+ updateProfile<T = TUser>(dto: UpdateCustomerDto): Promise<AxiosResponse<T>>;
61
+ getAddresses(): Promise<AxiosResponse<AddressDto[]>>;
62
+ addAddress(dto: AddressDto): Promise<AxiosResponse<void>>;
63
+ };
64
+ bookings: {
65
+ create(dto: CreateBookingDto): Promise<AxiosResponse<void>>;
66
+ get(id: string): Promise<AxiosResponse<ServiceBookingItemDto>>;
67
+ list(): Promise<AxiosResponse<ServiceBookingItemDto[]>>;
68
+ cancel(id: string): Promise<AxiosResponse<void>>;
69
+ };
35
70
  auth: AuthModule & {
36
- signUp(dto: RegisterCustomerDto): Promise<any>;
37
- authenticate(): Promise<any>;
38
- signIn(credentials: {
71
+ signUp<T = TUser>(dto: RegisterCustomerDto): Promise<AxiosResponse<T>>;
72
+ authenticate(): Promise<AuthExchangeToken201>;
73
+ signIn<TSess = TSession, TU = TUser>(credentials: {
39
74
  email: string;
40
75
  password?: string;
41
- }): Promise<any>;
76
+ }): Promise<CustomerAuthResponseDto<TU, TSess>>;
42
77
  signOut(): Promise<void>;
43
- getSession(): Promise<SessionState>;
44
- onAuthStateChange(callback: AuthStateCallback): {
78
+ getSession<TU = TUser>(): Promise<SessionState<TU>>;
79
+ onAuthStateChange<TU = TUser>(callback: AuthStateCallback<TU>): {
45
80
  unsubscribe(): void;
46
81
  };
82
+ getSessions<TSess = TSession>(): Promise<TSess[]>;
83
+ revokeSession(id: string): Promise<any>;
84
+ revokeAllSessions(mode?: string): Promise<any>;
85
+ getCurrentSession<TU = TUser>(): Promise<TU>;
86
+ refreshSession<TSess = TSession, TU = TUser>(): Promise<CustomerAuthResponseDto<TU, TSess>>;
87
+ swapZitadel<TSess = TSession, TU = TUser>(zitadelToken: string): Promise<CustomerAuthResponseDto<TU, TSess>>;
47
88
  };
48
89
  constructor(config: ClientSDKConfig);
49
90
  }
50
- declare function createClientSDK(config?: any): ScrymeClientSDK;
91
+ declare function createClientSDK<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto>(config?: any): ScrymeClientSDK<TProduct, TService, TCartItem, TCartResponse, TUser, TSession>;
92
+ interface AuthContextType<TUser = CustomerResponseDto, TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TSession = CustomerSessionDto> {
93
+ sdk: ScrymeClientSDK<TProduct, TService, TCartItem, TCartResponse, TUser, TSession>;
94
+ session: SessionState<TUser>;
95
+ user: TUser | null;
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>;
51
135
 
52
- export { type AuthChangeEvent, type AuthStateCallback, type ClientSDKConfig, ScrymeClientSDK, type SessionState, type StorageProvider, createClientSDK };
136
+ export { type AuthChangeEvent, type AuthContextType, type AuthStateCallback, type ClientSDKConfig, ScrymeAuthProvider, type ScrymeAuthProviderProps, ScrymeClientSDK, type SessionState, type StorageProvider, createClientSDK, useScrymeAuth };
package/dist/client.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { AxiosInstance } from 'axios';
2
- import { fx as RawAPI, cM as CatalogModule, eb as InventoryModule, f3 as OrdersModule, cB as CRMModule, fb as POSModule, bH as AccountingModule, eD as LoyaltyModule, eY as MembersModule, c9 as AdminModule, cm as AuthModule, ab as RegisterCustomerDto } from './base-DZXCyXwH.js';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import { AxiosInstance, AxiosResponse } from 'axios';
4
+ import { af as CustomerResponseDto, G as ProductResponseDto, K as ServiceCatalogResponseDto, cN as CartItemDto, b8 as CartResponseDto, dK as CustomerSessionDto, fT as RawAPI, cT as CatalogModule, ep as InventoryModule, fh as OrdersModule, cI as CRMModule, fp as POSModule, bO as AccountingModule, eR as LoyaltyModule, fa as MembersModule, cg as AdminModule, b7 as CartControllerGetCartParams, ba as AddToCartDto, bb as RemoveFromCartDto, b9 as CartControllerClearCartParams, aA as OrderResponseDto, aj as UpdateCustomerDto, ak as AddressDto, a0 as CreateBookingDto, gf as ServiceBookingItemDto, ct as AuthModule, ag as RegisterCustomerDto, s as AuthExchangeToken201, dJ as CustomerAuthResponseDto } from './base-Cl7_QxqC.js';
3
5
 
4
6
  interface StorageProvider {
5
7
  getItem(key: string): string | null | Promise<string | null>;
@@ -8,22 +10,22 @@ interface StorageProvider {
8
10
  }
9
11
  interface ClientSDKConfig {
10
12
  clientId: string;
11
- clientSecret: string;
13
+ clientSecret?: string;
12
14
  orgSlug: string;
13
15
  baseURL?: string;
14
16
  storage?: StorageProvider;
15
17
  }
16
18
  type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "INITIAL_SESSION";
17
- interface SessionState {
19
+ interface SessionState<TUser = CustomerResponseDto> {
18
20
  token: string | null;
19
- user: any | null;
21
+ user: TUser | null;
20
22
  expiresAt?: number | null;
21
23
  }
22
- type AuthStateCallback = (event: AuthChangeEvent, session: SessionState) => void;
23
- declare class ScrymeClientSDK {
24
+ type AuthStateCallback<TUser = CustomerResponseDto> = (event: AuthChangeEvent, session: SessionState<TUser>) => void;
25
+ declare class ScrymeClientSDK<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto> {
24
26
  axiosInstance: AxiosInstance;
25
27
  api: RawAPI;
26
- catalog: CatalogModule;
28
+ catalog: CatalogModule<TProduct, TService>;
27
29
  inventory: InventoryModule;
28
30
  orders: OrdersModule;
29
31
  crm: CRMModule;
@@ -32,21 +34,103 @@ declare class ScrymeClientSDK {
32
34
  loyalty: LoyaltyModule;
33
35
  members: MembersModule;
34
36
  admin: AdminModule;
37
+ cart: {
38
+ get<T = TCartResponse>(params?: CartControllerGetCartParams): Promise<AxiosResponse<T & Record<string, any>>>;
39
+ add(dto: AddToCartDto): Promise<AxiosResponse<void>>;
40
+ remove(dto: RemoveFromCartDto): Promise<AxiosResponse<void>>;
41
+ clear(params?: CartControllerClearCartParams): Promise<AxiosResponse<void>>;
42
+ update<T = TCartResponse>(dto: AddToCartDto & {
43
+ quantity: number;
44
+ }): Promise<AxiosResponse<void> | AxiosResponse<T> | undefined>;
45
+ getItems<T = TCartItem>(params?: CartControllerGetCartParams): Promise<T[]>;
46
+ getTotals<TItem = TCartItem, TRaw = TCartResponse>(params?: CartControllerGetCartParams): Promise<{
47
+ itemsCount: number;
48
+ items: TItem[];
49
+ raw: TRaw;
50
+ }>;
51
+ mergeGuestCart<T = TCartResponse>(guestSessionId: string, customerId: string): Promise<AxiosResponse<T & Record<string, any>>>;
52
+ checkout(params: {
53
+ locationId: string;
54
+ notes?: string;
55
+ channel?: string;
56
+ }): Promise<OrderResponseDto>;
57
+ };
58
+ customer: {
59
+ getProfile<T = TUser>(): Promise<T>;
60
+ updateProfile<T = TUser>(dto: UpdateCustomerDto): Promise<AxiosResponse<T>>;
61
+ getAddresses(): Promise<AxiosResponse<AddressDto[]>>;
62
+ addAddress(dto: AddressDto): Promise<AxiosResponse<void>>;
63
+ };
64
+ bookings: {
65
+ create(dto: CreateBookingDto): Promise<AxiosResponse<void>>;
66
+ get(id: string): Promise<AxiosResponse<ServiceBookingItemDto>>;
67
+ list(): Promise<AxiosResponse<ServiceBookingItemDto[]>>;
68
+ cancel(id: string): Promise<AxiosResponse<void>>;
69
+ };
35
70
  auth: AuthModule & {
36
- signUp(dto: RegisterCustomerDto): Promise<any>;
37
- authenticate(): Promise<any>;
38
- signIn(credentials: {
71
+ signUp<T = TUser>(dto: RegisterCustomerDto): Promise<AxiosResponse<T>>;
72
+ authenticate(): Promise<AuthExchangeToken201>;
73
+ signIn<TSess = TSession, TU = TUser>(credentials: {
39
74
  email: string;
40
75
  password?: string;
41
- }): Promise<any>;
76
+ }): Promise<CustomerAuthResponseDto<TU, TSess>>;
42
77
  signOut(): Promise<void>;
43
- getSession(): Promise<SessionState>;
44
- onAuthStateChange(callback: AuthStateCallback): {
78
+ getSession<TU = TUser>(): Promise<SessionState<TU>>;
79
+ onAuthStateChange<TU = TUser>(callback: AuthStateCallback<TU>): {
45
80
  unsubscribe(): void;
46
81
  };
82
+ getSessions<TSess = TSession>(): Promise<TSess[]>;
83
+ revokeSession(id: string): Promise<any>;
84
+ revokeAllSessions(mode?: string): Promise<any>;
85
+ getCurrentSession<TU = TUser>(): Promise<TU>;
86
+ refreshSession<TSess = TSession, TU = TUser>(): Promise<CustomerAuthResponseDto<TU, TSess>>;
87
+ swapZitadel<TSess = TSession, TU = TUser>(zitadelToken: string): Promise<CustomerAuthResponseDto<TU, TSess>>;
47
88
  };
48
89
  constructor(config: ClientSDKConfig);
49
90
  }
50
- declare function createClientSDK(config?: any): ScrymeClientSDK;
91
+ declare function createClientSDK<TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TUser = CustomerResponseDto, TSession = CustomerSessionDto>(config?: any): ScrymeClientSDK<TProduct, TService, TCartItem, TCartResponse, TUser, TSession>;
92
+ interface AuthContextType<TUser = CustomerResponseDto, TProduct = ProductResponseDto, TService = ServiceCatalogResponseDto, TCartItem = CartItemDto, TCartResponse = CartResponseDto, TSession = CustomerSessionDto> {
93
+ sdk: ScrymeClientSDK<TProduct, TService, TCartItem, TCartResponse, TUser, TSession>;
94
+ session: SessionState<TUser>;
95
+ user: TUser | null;
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>;
51
135
 
52
- export { type AuthChangeEvent, type AuthStateCallback, type ClientSDKConfig, ScrymeClientSDK, type SessionState, type StorageProvider, createClientSDK };
136
+ export { type AuthChangeEvent, type AuthContextType, type AuthStateCallback, type ClientSDKConfig, ScrymeAuthProvider, type ScrymeAuthProviderProps, ScrymeClientSDK, type SessionState, type StorageProvider, createClientSDK, useScrymeAuth };