@classytic/commerce-sdk 0.1.1
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/LICENSE +14 -0
- package/README.md +164 -0
- package/dist/adjustment-MNH3AT6S.js +5 -0
- package/dist/adjustment-MNH3AT6S.js.map +1 -0
- package/dist/analytics/index.d.ts +27 -0
- package/dist/analytics/index.js +6 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics-DMcD-o8w.d.ts +76 -0
- package/dist/api-factory-B_h4RKBm.d.ts +280 -0
- package/dist/auth/index.d.ts +39 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/catalog/index.d.ts +571 -0
- package/dist/catalog/index.js +9 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-24FDD6UR.js +75 -0
- package/dist/chunk-24FDD6UR.js.map +1 -0
- package/dist/chunk-2TF7QNYV.js +159 -0
- package/dist/chunk-2TF7QNYV.js.map +1 -0
- package/dist/chunk-2YAZ5WG6.js +479 -0
- package/dist/chunk-2YAZ5WG6.js.map +1 -0
- package/dist/chunk-36NLLAVH.js +177 -0
- package/dist/chunk-36NLLAVH.js.map +1 -0
- package/dist/chunk-3OYSJB3P.js +126 -0
- package/dist/chunk-3OYSJB3P.js.map +1 -0
- package/dist/chunk-5E57JODA.js +135 -0
- package/dist/chunk-5E57JODA.js.map +1 -0
- package/dist/chunk-7LZCW4VF.js +13 -0
- package/dist/chunk-7LZCW4VF.js.map +1 -0
- package/dist/chunk-ANYGZ6O5.js +830 -0
- package/dist/chunk-ANYGZ6O5.js.map +1 -0
- package/dist/chunk-AQAISI4F.js +183 -0
- package/dist/chunk-AQAISI4F.js.map +1 -0
- package/dist/chunk-B6MPVOV7.js +328 -0
- package/dist/chunk-B6MPVOV7.js.map +1 -0
- package/dist/chunk-CILP56G2.js +94 -0
- package/dist/chunk-CILP56G2.js.map +1 -0
- package/dist/chunk-ERQ52WHY.js +534 -0
- package/dist/chunk-ERQ52WHY.js.map +1 -0
- package/dist/chunk-FOTUJPM4.js +640 -0
- package/dist/chunk-FOTUJPM4.js.map +1 -0
- package/dist/chunk-IHCBBLLW.js +198 -0
- package/dist/chunk-IHCBBLLW.js.map +1 -0
- package/dist/chunk-J4JBQET2.js +76 -0
- package/dist/chunk-J4JBQET2.js.map +1 -0
- package/dist/chunk-L4OEI4VZ.js +123 -0
- package/dist/chunk-L4OEI4VZ.js.map +1 -0
- package/dist/chunk-LRV7MWWX.js +616 -0
- package/dist/chunk-LRV7MWWX.js.map +1 -0
- package/dist/chunk-N43VE355.js +126 -0
- package/dist/chunk-N43VE355.js.map +1 -0
- package/dist/chunk-PYYLHUV6.js +3 -0
- package/dist/chunk-PYYLHUV6.js.map +1 -0
- package/dist/chunk-QCTXAMLA.js +261 -0
- package/dist/chunk-QCTXAMLA.js.map +1 -0
- package/dist/chunk-RIKAPJNG.js +40 -0
- package/dist/chunk-RIKAPJNG.js.map +1 -0
- package/dist/chunk-U3XT35GZ.js +202 -0
- package/dist/chunk-U3XT35GZ.js.map +1 -0
- package/dist/chunk-W22WB3WZ.js +148 -0
- package/dist/chunk-W22WB3WZ.js.map +1 -0
- package/dist/chunk-WTIJMKML.js +27 -0
- package/dist/chunk-WTIJMKML.js.map +1 -0
- package/dist/chunk-X2CQFJPR.js +75 -0
- package/dist/chunk-X2CQFJPR.js.map +1 -0
- package/dist/chunk-YYFKLOKO.js +769 -0
- package/dist/chunk-YYFKLOKO.js.map +1 -0
- package/dist/client-Cs7E_usr.d.ts +113 -0
- package/dist/content/index.d.ts +309 -0
- package/dist/content/index.js +6 -0
- package/dist/content/index.js.map +1 -0
- package/dist/core/index.d.ts +166 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/react.d.ts +107 -0
- package/dist/core/react.js +5 -0
- package/dist/core/react.js.map +1 -0
- package/dist/coupon-BZSZ0y3n.d.ts +129 -0
- package/dist/coupon-CDzL4bJG.d.ts +655 -0
- package/dist/crud.factory-DyKaPHcU.d.ts +181 -0
- package/dist/finance/index.d.ts +81 -0
- package/dist/finance/index.js +5 -0
- package/dist/finance/index.js.map +1 -0
- package/dist/finance-BJdfKRw0.d.ts +135 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory/index.d.ts +512 -0
- package/dist/inventory/index.js +16 -0
- package/dist/inventory/index.js.map +1 -0
- package/dist/inventory-B5pssqRx.d.ts +748 -0
- package/dist/logistics/index.d.ts +248 -0
- package/dist/logistics/index.js +7 -0
- package/dist/logistics/index.js.map +1 -0
- package/dist/logistics-CrpKadKE.d.ts +410 -0
- package/dist/media-CNLJK93J.d.ts +721 -0
- package/dist/movement-R3CERFAM.js +5 -0
- package/dist/movement-R3CERFAM.js.map +1 -0
- package/dist/order-B3dCvHgK.d.ts +360 -0
- package/dist/payment-BRboLqvU.d.ts +127 -0
- package/dist/payments/index.d.ts +55 -0
- package/dist/payments/index.js +6 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/platform/index.d.ts +645 -0
- package/dist/platform/index.js +8 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/pos-BCqkx2-K.d.ts +527 -0
- package/dist/product-p09zXkXB.d.ts +260 -0
- package/dist/purchase-54PER2PY.js +5 -0
- package/dist/purchase-54PER2PY.js.map +1 -0
- package/dist/request-MP6NV5ZE.js +5 -0
- package/dist/request-MP6NV5ZE.js.map +1 -0
- package/dist/sales/index.d.ts +587 -0
- package/dist/sales/index.js +9 -0
- package/dist/sales/index.js.map +1 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +37 -0
- package/dist/server.js.map +1 -0
- package/dist/size-guide-DgjzjM5P.d.ts +554 -0
- package/dist/stock-2LP4HJSB.js +5 -0
- package/dist/stock-2LP4HJSB.js.map +1 -0
- package/dist/stock-CfrU5_Wr.d.ts +632 -0
- package/dist/supplier-BWJTRZ5Z.js +5 -0
- package/dist/supplier-BWJTRZ5Z.js.map +1 -0
- package/dist/transaction/index.d.ts +104 -0
- package/dist/transaction/index.js +8 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction-Bf6WjYCh.d.ts +84 -0
- package/dist/transaction-dL3WW-er.d.ts +442 -0
- package/dist/transfer-4XSS6HWT.js +5 -0
- package/dist/transfer-4XSS6HWT.js.map +1 -0
- package/dist/user-data-DdLjAGwO.d.ts +132 -0
- package/package.json +147 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export { d as AggregatePaginationResponse, A as ApiResponse, B as BaseApi, f as BaseApiConfig, D as DeleteResponse, E as ExtractDoc, F as FilterOperator, K as KeysetPaginationResponse, O as OffsetPaginationResponse, P as PaginatedResponse, Q as QueryParams, R as RequestOptions, S as SortDirection, e as SortSpec, c as createCrudApi, b as isAggregatePagination, a as isKeysetPagination, i as isOffsetPagination } from '../api-factory-B_h4RKBm.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @classytic/commerce-sdk - API Handler
|
|
5
|
+
*
|
|
6
|
+
* Universal API request handler for Next.js applications.
|
|
7
|
+
* Handles JSON, binary (PDF, images), CSV, and text responses.
|
|
8
|
+
*/
|
|
9
|
+
type HttpMethod = "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
|
|
10
|
+
interface ApiRequestOptions {
|
|
11
|
+
body?: unknown;
|
|
12
|
+
token?: string | null;
|
|
13
|
+
organizationId?: string | null;
|
|
14
|
+
revalidate?: number;
|
|
15
|
+
headerOptions?: Record<string, string>;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
cache?: RequestCache;
|
|
18
|
+
/**
|
|
19
|
+
* Credentials mode for this specific request.
|
|
20
|
+
* Overrides SDK-level credentials config.
|
|
21
|
+
* - "include": Always send cookies
|
|
22
|
+
* - "same-origin": Only send cookies for same-origin requests
|
|
23
|
+
* - "omit": Never send cookies (pure bearer-token auth)
|
|
24
|
+
*/
|
|
25
|
+
credentials?: RequestCredentials;
|
|
26
|
+
}
|
|
27
|
+
interface BlobResponse {
|
|
28
|
+
data: Blob;
|
|
29
|
+
response: Response;
|
|
30
|
+
}
|
|
31
|
+
interface TextResponse {
|
|
32
|
+
data: string;
|
|
33
|
+
response: Response;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* SDK Configuration
|
|
37
|
+
*/
|
|
38
|
+
interface SDKConfig {
|
|
39
|
+
/** Base URL for API requests (e.g., "https://api.example.com") */
|
|
40
|
+
baseUrl: string;
|
|
41
|
+
/** Default organization ID for multi-tenant support */
|
|
42
|
+
organizationId?: string;
|
|
43
|
+
/** Function to get current auth token */
|
|
44
|
+
getToken?: () => string | null | Promise<string | null>;
|
|
45
|
+
/** Default request cache mode */
|
|
46
|
+
cache?: RequestCache;
|
|
47
|
+
/** Default headers to include in all requests (e.g., API keys, custom headers) */
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* Default credentials mode for fetch requests.
|
|
51
|
+
* Can be overridden per-request via ApiRequestOptions.credentials
|
|
52
|
+
* - "include": Always send cookies (default for backward compatibility)
|
|
53
|
+
* - "same-origin": Only send cookies for same-origin requests
|
|
54
|
+
* - "omit": Never send cookies (use for pure bearer-token auth)
|
|
55
|
+
* @default "include"
|
|
56
|
+
*/
|
|
57
|
+
credentials?: RequestCredentials;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Custom API Error class that preserves HTTP status and response body.
|
|
61
|
+
* Provides better debugging context for API failures.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* try {
|
|
65
|
+
* await sdk.orders.create(data);
|
|
66
|
+
* } catch (error) {
|
|
67
|
+
* if (error instanceof ApiError) {
|
|
68
|
+
* console.log(error.status); // 422
|
|
69
|
+
* console.log(error.body); // { errors: [...] }
|
|
70
|
+
* console.log(error.endpoint); // "/api/v1/orders"
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
*/
|
|
74
|
+
declare class ApiError extends Error {
|
|
75
|
+
/** HTTP status code (e.g., 400, 401, 404, 500) */
|
|
76
|
+
readonly status: number;
|
|
77
|
+
/** HTTP status text (e.g., "Bad Request", "Unauthorized") */
|
|
78
|
+
readonly statusText: string;
|
|
79
|
+
/** Raw response body - JSON object, string, or null if unparseable */
|
|
80
|
+
readonly body: unknown;
|
|
81
|
+
/** The API endpoint that was called */
|
|
82
|
+
readonly endpoint: string;
|
|
83
|
+
/** The HTTP method used */
|
|
84
|
+
readonly method: HttpMethod;
|
|
85
|
+
constructor(options: {
|
|
86
|
+
message: string;
|
|
87
|
+
status: number;
|
|
88
|
+
statusText: string;
|
|
89
|
+
body: unknown;
|
|
90
|
+
endpoint: string;
|
|
91
|
+
method: HttpMethod;
|
|
92
|
+
});
|
|
93
|
+
/** Check if error is a client error (4xx) */
|
|
94
|
+
isClientError(): boolean;
|
|
95
|
+
/** Check if error is a server error (5xx) */
|
|
96
|
+
isServerError(): boolean;
|
|
97
|
+
/** Returns detailed string for logging */
|
|
98
|
+
toDetailedString(): string;
|
|
99
|
+
}
|
|
100
|
+
declare function setSDKConfigProvider(provider: (() => SDKConfig | null) | null): void;
|
|
101
|
+
/**
|
|
102
|
+
* Configure the SDK with base URL and other options
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Basic configuration
|
|
106
|
+
* configureSDK({
|
|
107
|
+
* baseUrl: process.env.NEXT_PUBLIC_API_URL!,
|
|
108
|
+
* getToken: () => localStorage.getItem('token'),
|
|
109
|
+
* organizationId: 'org_123',
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // With custom headers (API keys, etc.)
|
|
114
|
+
* configureSDK({
|
|
115
|
+
* baseUrl: process.env.NEXT_PUBLIC_API_URL!,
|
|
116
|
+
* headers: {
|
|
117
|
+
* 'x-api-key': process.env.API_KEY,
|
|
118
|
+
* 'x-custom-header': 'value',
|
|
119
|
+
* },
|
|
120
|
+
* });
|
|
121
|
+
*/
|
|
122
|
+
declare function configureSDK(config: SDKConfig): void;
|
|
123
|
+
/**
|
|
124
|
+
* Get current SDK configuration
|
|
125
|
+
*/
|
|
126
|
+
declare function getSDKConfig(): SDKConfig | null;
|
|
127
|
+
/**
|
|
128
|
+
* Get base URL from SDK config or throw if not configured
|
|
129
|
+
*/
|
|
130
|
+
declare function getBaseUrl(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Universal API request handler for Next.js applications
|
|
133
|
+
* Handles JSON, binary (PDF, images), CSV, and text responses
|
|
134
|
+
*
|
|
135
|
+
* @template T - Expected response type
|
|
136
|
+
* @param method - HTTP method
|
|
137
|
+
* @param endpoint - API endpoint (will be appended to BASE_URL)
|
|
138
|
+
* @param options - Request options
|
|
139
|
+
* @param debug - Enable debug logging
|
|
140
|
+
* @returns Promise resolving to the response data
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* // JSON response
|
|
144
|
+
* const { success, data } = await handleApiRequest<ApiResponse<User>>('GET', '/users/me', { token });
|
|
145
|
+
*
|
|
146
|
+
* // Paginated response
|
|
147
|
+
* const response = await handleApiRequest<PaginatedResponse<Product>>('GET', '/products?page=1');
|
|
148
|
+
*
|
|
149
|
+
* // Create with body
|
|
150
|
+
* const result = await handleApiRequest('POST', '/orders', { token, body: orderData });
|
|
151
|
+
*/
|
|
152
|
+
declare function handleApiRequest<T = unknown>(method: HttpMethod, endpoint: string, options?: ApiRequestOptions, debug?: boolean): Promise<T>;
|
|
153
|
+
/**
|
|
154
|
+
* Creates query string from parameters
|
|
155
|
+
* Supports: ?field=value and arrays as field[in]=value1,value2
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* createQueryString({ page: 1, limit: 10, status: 'active' })
|
|
159
|
+
* // => 'page=1&limit=10&status=active'
|
|
160
|
+
*
|
|
161
|
+
* createQueryString({ roles: ['admin', 'user'] })
|
|
162
|
+
* // => 'roles[in]=admin,user'
|
|
163
|
+
*/
|
|
164
|
+
declare function createQueryString<T extends Record<string, unknown>>(params?: T): string;
|
|
165
|
+
|
|
166
|
+
export { ApiError, type ApiRequestOptions, type BlobResponse, type HttpMethod, type SDKConfig, type TextResponse, configureSDK, createQueryString, getBaseUrl, getSDKConfig, handleApiRequest, setSDKConfigProvider };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import '../chunk-PYYLHUV6.js';
|
|
2
|
+
export { BaseApi, createCrudApi, isAggregatePagination, isKeysetPagination, isOffsetPagination } from '../chunk-QCTXAMLA.js';
|
|
3
|
+
export { ApiError, configureSDK, createQueryString, getBaseUrl, getSDKConfig, handleApiRequest, setSDKConfigProvider } from '../chunk-IHCBBLLW.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export { o as CreateDetailQueryOptions, n as CreateListQueryOptions, d as CrudActions, C as CrudApi, a as CrudHooksConfig, b as CrudHooksReturn, j as DEFAULT_QUERY_CONFIG, D as DetailOptions, m as DetailQueryResult, L as ListOptions, l as ListQueryResult, N as NavigateFn, e as NavigationOptions, P as PaginationData, Q as QueryConfig, k as QueryKeys, c as createCrudHooks, g as createDetailQuery, f as createListQuery, h as createQueryKeys, i as getItemId, u as updateListCache } from '../crud.factory-DyKaPHcU.js';
|
|
2
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
|
+
import { QueryKey, QueryClient } from '@tanstack/react-query';
|
|
4
|
+
|
|
5
|
+
interface ToastHandler {
|
|
6
|
+
success: (message: string) => void;
|
|
7
|
+
error: (message: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Configure the toast handler for mutations
|
|
11
|
+
* @example
|
|
12
|
+
* import { toast } from 'sonner';
|
|
13
|
+
* configureToast({ success: toast.success, error: toast.error });
|
|
14
|
+
*/
|
|
15
|
+
declare function configureToast(handler: ToastHandler): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get the current toast handler (for internal use)
|
|
18
|
+
*/
|
|
19
|
+
declare function getToastHandler(): ToastHandler;
|
|
20
|
+
interface MutationMessages {
|
|
21
|
+
success?: string | ((data: unknown, variables: unknown) => string);
|
|
22
|
+
error?: string | ((error: Error, variables: unknown) => string);
|
|
23
|
+
}
|
|
24
|
+
interface MutationWithTransitionConfig<TData, TVariables> {
|
|
25
|
+
mutationFn: (variables: TVariables) => Promise<TData>;
|
|
26
|
+
invalidateQueries?: QueryKey[];
|
|
27
|
+
onSuccess?: (data: TData, variables: TVariables, context: unknown) => void;
|
|
28
|
+
onError?: (error: Error, variables: TVariables, context: unknown) => void;
|
|
29
|
+
messages?: MutationMessages;
|
|
30
|
+
useTransition?: boolean;
|
|
31
|
+
showToast?: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare function useMutationWithTransition<TData, TVariables>(config: MutationWithTransitionConfig<TData, TVariables>): {
|
|
34
|
+
mutate: _tanstack_react_query.UseMutateFunction<TData, Error, TVariables, unknown>;
|
|
35
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<TData, Error, TVariables, unknown>;
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
isPending: boolean;
|
|
38
|
+
isSuccess: boolean;
|
|
39
|
+
error: Error | null;
|
|
40
|
+
data: TData | undefined;
|
|
41
|
+
reset: () => void;
|
|
42
|
+
};
|
|
43
|
+
interface MutationWithOptimisticConfig<TData, TVariables> {
|
|
44
|
+
mutationFn: (variables: TVariables) => Promise<TData>;
|
|
45
|
+
queryKeys?: QueryKey[];
|
|
46
|
+
optimisticUpdate?: (oldData: unknown, variables: TVariables) => unknown;
|
|
47
|
+
messages?: MutationMessages;
|
|
48
|
+
onSuccess?: (data: TData, variables: TVariables, context: unknown) => void;
|
|
49
|
+
onError?: (error: Error, variables: TVariables, context: unknown) => void;
|
|
50
|
+
showToast?: boolean;
|
|
51
|
+
}
|
|
52
|
+
declare function useMutationWithOptimistic<TData, TVariables>(config: MutationWithOptimisticConfig<TData, TVariables>): {
|
|
53
|
+
mutate: _tanstack_react_query.UseMutateFunction<TData, Error, TVariables, {
|
|
54
|
+
previousData: {
|
|
55
|
+
queryKey: readonly unknown[];
|
|
56
|
+
data: unknown;
|
|
57
|
+
}[];
|
|
58
|
+
}>;
|
|
59
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<TData, Error, TVariables, {
|
|
60
|
+
previousData: {
|
|
61
|
+
queryKey: readonly unknown[];
|
|
62
|
+
data: unknown;
|
|
63
|
+
}[];
|
|
64
|
+
}>;
|
|
65
|
+
isLoading: boolean;
|
|
66
|
+
isPending: boolean;
|
|
67
|
+
isSuccess: boolean;
|
|
68
|
+
error: Error | null;
|
|
69
|
+
data: TData | undefined;
|
|
70
|
+
reset: () => void;
|
|
71
|
+
};
|
|
72
|
+
interface CreateOptimisticMutationConfig<TData, TVariables> {
|
|
73
|
+
mutationFn: (variables: TVariables) => Promise<TData>;
|
|
74
|
+
queryClient: QueryClient;
|
|
75
|
+
queryKeys: QueryKey[];
|
|
76
|
+
optimisticUpdate?: (oldData: unknown, variables: TVariables) => unknown;
|
|
77
|
+
onSuccess?: (data: TData, variables: TVariables, context: unknown) => void;
|
|
78
|
+
onError?: (error: Error, variables: TVariables, context: unknown) => void;
|
|
79
|
+
messages?: MutationMessages;
|
|
80
|
+
}
|
|
81
|
+
declare function createOptimisticMutation<TData, TVariables>({ mutationFn, queryClient, queryKeys, optimisticUpdate, onSuccess, onError, messages, }: CreateOptimisticMutationConfig<TData, TVariables>): _tanstack_react_query.UseMutationResult<TData, Error, TVariables, {
|
|
82
|
+
previous: {
|
|
83
|
+
key: readonly unknown[];
|
|
84
|
+
data: [readonly unknown[], unknown][];
|
|
85
|
+
}[];
|
|
86
|
+
}>;
|
|
87
|
+
declare const QUERY_CONFIGS: {
|
|
88
|
+
readonly realtime: {
|
|
89
|
+
readonly staleTime: 20000;
|
|
90
|
+
readonly refetchInterval: 30000;
|
|
91
|
+
};
|
|
92
|
+
readonly frequent: {
|
|
93
|
+
readonly staleTime: 60000;
|
|
94
|
+
readonly refetchInterval: false;
|
|
95
|
+
};
|
|
96
|
+
readonly stable: {
|
|
97
|
+
readonly staleTime: 300000;
|
|
98
|
+
readonly refetchInterval: false;
|
|
99
|
+
};
|
|
100
|
+
readonly static: {
|
|
101
|
+
readonly staleTime: 600000;
|
|
102
|
+
readonly refetchInterval: false;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
declare const createMessage: <T>(fn: T) => T;
|
|
106
|
+
|
|
107
|
+
export { type CreateOptimisticMutationConfig, type MutationMessages, type MutationWithOptimisticConfig, type MutationWithTransitionConfig, QUERY_CONFIGS, type ToastHandler, configureToast, createMessage, createOptimisticMutation, getToastHandler, useMutationWithOptimistic, useMutationWithTransition };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export { DEFAULT_QUERY_CONFIG, createCrudHooks, createDetailQuery, createListQuery, createQueryKeys, getItemId, updateListCache } from '../chunk-B6MPVOV7.js';
|
|
3
|
+
export { QUERY_CONFIGS, configureToast, createMessage, createOptimisticMutation, getToastHandler, useMutationWithOptimistic, useMutationWithTransition } from '../chunk-U3XT35GZ.js';
|
|
4
|
+
//# sourceMappingURL=react.js.map
|
|
5
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.js"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { k as QueryKeys, b as CrudHooksReturn, L as ListOptions, l as ListQueryResult, D as DetailOptions, m as DetailQueryResult, d as CrudActions, N as NavigateFn } from './crud.factory-DyKaPHcU.js';
|
|
2
|
+
import { I as PlatformConfig, J as UpdatePlatformConfigPayload, X as PaymentMethodConfig, Q as CheckoutSettings, H as MembershipConfig, g as Branch, h as CreateBranchPayload, j as UpdateBranchPayload, Z as User, n as CreateUserPayload, o as UpdateUserPayload, r as Coupon, t as CreateCouponPayload } from './coupon-CDzL4bJG.js';
|
|
3
|
+
|
|
4
|
+
declare const PLATFORM_KEYS: QueryKeys;
|
|
5
|
+
interface UsePlatformConfigReturn {
|
|
6
|
+
config: PlatformConfig | undefined;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
isError: boolean;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
refetch: () => void;
|
|
11
|
+
}
|
|
12
|
+
interface UsePaymentMethodsReturn {
|
|
13
|
+
paymentMethods: PaymentMethodConfig[];
|
|
14
|
+
isLoading: boolean;
|
|
15
|
+
isError: boolean;
|
|
16
|
+
error: Error | null;
|
|
17
|
+
refetch: () => void;
|
|
18
|
+
}
|
|
19
|
+
interface UseDeliveryZonesReturn {
|
|
20
|
+
deliveryZones: CheckoutSettings["deliveryZones"];
|
|
21
|
+
freeDeliveryThreshold: number;
|
|
22
|
+
allowStorePickup: boolean;
|
|
23
|
+
pickupBranches: CheckoutSettings["pickupBranches"];
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
isError: boolean;
|
|
26
|
+
error: Error | null;
|
|
27
|
+
refetch: () => void;
|
|
28
|
+
}
|
|
29
|
+
interface UseMembershipConfigReturn {
|
|
30
|
+
membership: MembershipConfig | null | undefined;
|
|
31
|
+
isLoading: boolean;
|
|
32
|
+
isError: boolean;
|
|
33
|
+
error: Error | null;
|
|
34
|
+
refetch: () => void;
|
|
35
|
+
}
|
|
36
|
+
interface UseUpdatePlatformConfigReturn {
|
|
37
|
+
updateConfig: (data: UpdatePlatformConfigPayload) => Promise<PlatformConfig | undefined>;
|
|
38
|
+
isUpdating: boolean;
|
|
39
|
+
error: Error | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hook to fetch platform configuration
|
|
43
|
+
*
|
|
44
|
+
* @param token - Optional auth token (public access without, authenticated with)
|
|
45
|
+
* @param select - Optional field selection (e.g., "paymentMethods", "checkout,vat")
|
|
46
|
+
* @returns Platform config with loading/error states
|
|
47
|
+
*/
|
|
48
|
+
declare function usePlatformConfig(token?: string | null, select?: string | null): UsePlatformConfigReturn;
|
|
49
|
+
/**
|
|
50
|
+
* Hook to update platform configuration
|
|
51
|
+
*
|
|
52
|
+
* @param token - Admin auth token (required)
|
|
53
|
+
* @returns Mutation function with loading state
|
|
54
|
+
*/
|
|
55
|
+
declare function useUpdatePlatformConfig(token: string): UseUpdatePlatformConfigReturn;
|
|
56
|
+
/**
|
|
57
|
+
* Hook to fetch payment methods only
|
|
58
|
+
* Convenience hook for checkout/POS
|
|
59
|
+
*
|
|
60
|
+
* @param token - Optional auth token
|
|
61
|
+
* @returns Payment methods with loading state
|
|
62
|
+
*/
|
|
63
|
+
declare function usePaymentMethods(token?: string | null): UsePaymentMethodsReturn;
|
|
64
|
+
/**
|
|
65
|
+
* Hook to fetch delivery zones and checkout settings
|
|
66
|
+
* Convenience hook for checkout flow
|
|
67
|
+
*
|
|
68
|
+
* @param token - Optional auth token
|
|
69
|
+
* @returns Delivery zones and checkout settings
|
|
70
|
+
*/
|
|
71
|
+
declare function useDeliveryZones(token?: string | null): UseDeliveryZonesReturn;
|
|
72
|
+
/**
|
|
73
|
+
* Hook to fetch membership config only
|
|
74
|
+
* Convenience hook for loyalty programs
|
|
75
|
+
*
|
|
76
|
+
* @param token - Optional auth token
|
|
77
|
+
* @returns Membership configuration
|
|
78
|
+
*/
|
|
79
|
+
declare function useMembershipConfig(token?: string | null): UseMembershipConfigReturn;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Branch hooks using createCrudHooks factory
|
|
83
|
+
*
|
|
84
|
+
* Provides:
|
|
85
|
+
* - useBranches: List branches with filtering/pagination
|
|
86
|
+
* - useBranchDetail: Get single branch
|
|
87
|
+
* - useBranchActions: Create, update, delete mutations
|
|
88
|
+
* - useBranchNavigation: Navigation between branches
|
|
89
|
+
*/
|
|
90
|
+
declare const branchHooks: CrudHooksReturn<Branch, CreateBranchPayload, UpdateBranchPayload>;
|
|
91
|
+
declare const BRANCH_KEYS: QueryKeys;
|
|
92
|
+
declare const useBranches: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Branch>;
|
|
93
|
+
declare const useBranchDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Branch>;
|
|
94
|
+
declare const useBranchActions: () => CrudActions<CreateBranchPayload, UpdateBranchPayload>;
|
|
95
|
+
declare const useBranchNavigation: () => NavigateFn<Branch>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* User hooks using createCrudHooks factory
|
|
99
|
+
*
|
|
100
|
+
* Provides:
|
|
101
|
+
* - useUsers: List users with filtering/pagination
|
|
102
|
+
* - useUserDetail: Get single user
|
|
103
|
+
* - useUserActions: Create, update, delete mutations
|
|
104
|
+
* - useUserNavigation: Navigation between users
|
|
105
|
+
*/
|
|
106
|
+
declare const userHooks: CrudHooksReturn<User, CreateUserPayload, UpdateUserPayload>;
|
|
107
|
+
declare const USER_KEYS: QueryKeys;
|
|
108
|
+
declare const useUsers: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<User>;
|
|
109
|
+
declare const useUserDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<User>;
|
|
110
|
+
declare const useUserActions: () => CrudActions<CreateUserPayload, UpdateUserPayload>;
|
|
111
|
+
declare const useUserNavigation: () => NavigateFn<User>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Coupon hooks using createCrudHooks factory
|
|
115
|
+
*
|
|
116
|
+
* Provides:
|
|
117
|
+
* - useCoupons: List coupons with filtering/pagination
|
|
118
|
+
* - useCouponDetail: Get single coupon
|
|
119
|
+
* - useCouponActions: Create, update, delete mutations
|
|
120
|
+
* - useCouponNavigation: Navigation between coupons
|
|
121
|
+
*/
|
|
122
|
+
declare const couponHooks: CrudHooksReturn<Coupon, CreateCouponPayload, Partial<CreateCouponPayload>>;
|
|
123
|
+
declare const COUPON_KEYS: QueryKeys;
|
|
124
|
+
declare const useCoupons: (token: string | null, params?: Record<string, unknown>, options?: ListOptions) => ListQueryResult<Coupon>;
|
|
125
|
+
declare const useCouponDetail: (id: string | null, token: string | null, options?: DetailOptions) => DetailQueryResult<Coupon>;
|
|
126
|
+
declare const useCouponActions: () => CrudActions<CreateCouponPayload, Partial<CreateCouponPayload>>;
|
|
127
|
+
declare const useCouponNavigation: () => NavigateFn<Coupon>;
|
|
128
|
+
|
|
129
|
+
export { BRANCH_KEYS as B, COUPON_KEYS as C, PLATFORM_KEYS as P, USER_KEYS as U, useUpdatePlatformConfig as a, usePaymentMethods as b, useDeliveryZones as c, useMembershipConfig as d, branchHooks as e, useBranches as f, useBranchDetail as g, useBranchActions as h, useBranchNavigation as i, userHooks as j, useUsers as k, useUserDetail as l, useUserActions as m, useUserNavigation as n, couponHooks as o, useCoupons as p, useCouponDetail as q, useCouponActions as r, useCouponNavigation as s, type UsePlatformConfigReturn as t, usePlatformConfig as u, type UsePaymentMethodsReturn as v, type UseDeliveryZonesReturn as w, type UseMembershipConfigReturn as x, type UseUpdatePlatformConfigReturn as y };
|