routesync 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.d.mts ADDED
@@ -0,0 +1,269 @@
1
+ import { AxiosRequestConfig, AxiosInstance } from 'axios';
2
+
3
+ interface ServiceConfig {
4
+ baseURL: string;
5
+ token?: string;
6
+ headers?: Record<string, string>;
7
+ timeout?: number;
8
+ retry?: RetryConfig;
9
+ cache?: boolean;
10
+ }
11
+ interface RetryConfig {
12
+ attempts: number;
13
+ delay?: number;
14
+ statusCodes?: number[];
15
+ }
16
+
17
+ declare class HttpClient {
18
+ private client;
19
+ constructor(config: ServiceConfig);
20
+ private setupInterceptors;
21
+ setToken(token: string): void;
22
+ removeToken(): void;
23
+ get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
24
+ post<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
25
+ put<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
26
+ patch<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
27
+ delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
28
+ upload<T>(url: string, formData: FormData): Promise<T>;
29
+ getInstance(): AxiosInstance;
30
+ }
31
+
32
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
33
+ type RouteTransform = (value: unknown) => unknown;
34
+ interface RouteTransformMap {
35
+ params?: RouteTransform;
36
+ query?: RouteTransform;
37
+ body?: RouteTransform;
38
+ request?: RouteTransform;
39
+ response?: RouteTransform;
40
+ }
41
+ type RouteMapper = RouteTransform | RouteTransformMap;
42
+ interface RouteParserSchema {
43
+ parse?: RouteTransform;
44
+ safeParse?: RouteTransform;
45
+ }
46
+ interface RouteSchemaMap {
47
+ params?: RouteSchemaValue;
48
+ query?: RouteSchemaValue;
49
+ body?: RouteSchemaValue;
50
+ request?: RouteSchemaValue;
51
+ response?: RouteSchemaValue;
52
+ }
53
+ type RouteSchemaValue = RouteTransform | RouteParserSchema;
54
+ type RouteSchema = RouteSchemaValue | RouteSchemaMap;
55
+ interface RouteDefinition {
56
+ method: HttpMethod;
57
+ path: string;
58
+ auth?: boolean;
59
+ schema?: RouteSchema;
60
+ mapper?: RouteMapper;
61
+ headers?: Record<string, string>;
62
+ cache?: unknown;
63
+ retry?: unknown;
64
+ body?: Record<string, any>;
65
+ params?: Record<string, any>;
66
+ query?: Record<string, any>;
67
+ }
68
+ interface ApiDefinition {
69
+ [group: string]: {
70
+ [action: string]: RouteDefinition;
71
+ };
72
+ }
73
+
74
+ interface ApiResponse<T = any> {
75
+ success: boolean;
76
+ message?: string;
77
+ data: T;
78
+ meta?: PaginationMeta;
79
+ }
80
+ interface PaginationMeta {
81
+ current_page: number;
82
+ last_page: number;
83
+ per_page: number;
84
+ total: number;
85
+ from?: number;
86
+ to?: number;
87
+ }
88
+
89
+ declare class TokenManager {
90
+ private static TOKEN_KEY;
91
+ private token;
92
+ set(token: string): void;
93
+ get(): string | null;
94
+ clear(): void;
95
+ exists(): boolean;
96
+ }
97
+
98
+ type CallOptions = {
99
+ params?: Record<string, any>;
100
+ query?: Record<string, any>;
101
+ body?: Record<string, any>;
102
+ };
103
+ interface EndpointCallable {
104
+ (options?: CallOptions): Promise<any>;
105
+ /** Original RouteDefinition — used by useApiQuery / useApiMutation */
106
+ $def: RouteDefinition;
107
+ /** Stable TanStack query key: [group, action] */
108
+ $key: string[];
109
+ }
110
+ type ApiGroupProxy<G extends Record<string, RouteDefinition>> = {
111
+ [K in keyof G]: EndpointCallable;
112
+ };
113
+ type ApiProxy<T extends ApiDefinition> = {
114
+ [G in keyof T]: ApiGroupProxy<T[G]>;
115
+ };
116
+ declare function createClient$1(config: ServiceConfig): HttpClient;
117
+ declare function defineApi<T extends ApiDefinition>(definition: T, config?: ServiceConfig): ApiProxy<T>;
118
+
119
+ type EndpointDefinition$1 = RouteDefinition;
120
+ /**
121
+ * endpoint() — declare a typed endpoint definition.
122
+ *
123
+ * Each endpoint fully owns its path. Use inside defineApi() or resource().
124
+ *
125
+ * Usage:
126
+ * const api = defineApi({
127
+ * cart: {
128
+ * list: endpoint({ method: 'GET', path: '/cart/items' }),
129
+ * create: endpoint({ method: 'POST', path: '/cart/items' }),
130
+ * }
131
+ * })
132
+ *
133
+ * // TanStack-friendly:
134
+ * const { data } = useApiQuery(api.cart.list)
135
+ * const mutation = useApiMutation(api.cart.create)
136
+ */
137
+ declare function endpoint(def: RouteDefinition): RouteDefinition;
138
+
139
+ type EndpointDefinition = RouteDefinition;
140
+ interface ResourceConfig<TEndpoints extends Record<string, EndpointDefinition>> {
141
+ /**
142
+ * Optional base path for grouping / documentation purposes only.
143
+ * NOT merged into endpoint paths — each endpoint fully owns its own path.
144
+ * @deprecated Use endpoint.path directly. This field is ignored at runtime.
145
+ */
146
+ basePath?: string;
147
+ endpoints: TEndpoints;
148
+ /** Default auth flag applied to all endpoints that don't override it. */
149
+ auth?: boolean;
150
+ /** Default headers merged with per-endpoint headers (endpoint takes priority). */
151
+ headers?: Record<string, string>;
152
+ /** Default cache config applied to endpoints that don't override it. */
153
+ cache?: unknown;
154
+ /** Default retry config applied to endpoints that don't override it. */
155
+ retry?: unknown;
156
+ }
157
+ type ResourceDefinition<TEndpoints extends Record<string, EndpointDefinition>> = {
158
+ [K in keyof TEndpoints]: RouteDefinition;
159
+ };
160
+ /**
161
+ * resource() — group related endpoints together.
162
+ *
163
+ * Each endpoint fully owns its path. No path merging happens.
164
+ * Defaults (auth, headers, cache, retry) cascade down but endpoints can override.
165
+ *
166
+ * Usage:
167
+ * const cartResource = resource({
168
+ * auth: true,
169
+ * endpoints: {
170
+ * list: { method: 'GET', path: '/cart/items' },
171
+ * show: { method: 'GET', path: '/cart/items/:id' },
172
+ * create: { method: 'POST', path: '/cart/items' },
173
+ * update: { method: 'PATCH', path: '/cart/items/:id' },
174
+ * delete: { method: 'DELETE', path: '/cart/items/:id' },
175
+ * },
176
+ * })
177
+ */
178
+ declare function resource<TEndpoints extends Record<string, EndpointDefinition>>(config: ResourceConfig<TEndpoints>): ResourceDefinition<TEndpoints>;
179
+
180
+ type ParseResult<T> = {
181
+ success: true;
182
+ data: T;
183
+ } | {
184
+ success: false;
185
+ error: unknown;
186
+ };
187
+ interface ParserSchema<T> {
188
+ parse?: (value: unknown) => T;
189
+ safeParse?: (value: unknown) => ParseResult<T>;
190
+ }
191
+ type SchemaLike<T> = ParserSchema<T> | ((value: unknown) => T);
192
+ declare function parseWithSchema<T>(schema: SchemaLike<T> | undefined, value: unknown): T;
193
+
194
+ type Id = string | number;
195
+ type QueryParams = Record<string, any>;
196
+ interface GenericServiceOptions<TEntity, TCreateInput = Partial<TEntity>, TUpdateInput = Partial<TCreateInput>, TBackendEntity = unknown> {
197
+ /** Validate one backend entity before it is mapped to frontend shape. Works with Zod schemas. */
198
+ entitySchema?: SchemaLike<TBackendEntity>;
199
+ /** Validate backend list responses before each item is mapped to frontend shape. Works with Zod arrays. */
200
+ listSchema?: SchemaLike<TBackendEntity[]>;
201
+ /** Validate frontend create payloads before they are mapped to backend snake_case. Works with Zod schemas. */
202
+ createSchema?: SchemaLike<TCreateInput>;
203
+ /** Validate frontend update/patch payloads before they are mapped to backend snake_case. Works with Zod schemas. */
204
+ updateSchema?: SchemaLike<TUpdateInput>;
205
+ /** Override backend -> frontend mapping. Defaults to deep snake_case -> camelCase. */
206
+ fromBackend?: (value: TBackendEntity) => TEntity;
207
+ /** Override frontend -> backend mapping. Defaults to deep camelCase -> snake_case. */
208
+ toBackend?: (value: TCreateInput | TUpdateInput | QueryParams) => unknown;
209
+ /** Disable if your backend already returns camelCase. Defaults to true. */
210
+ mapResponseKeys?: boolean;
211
+ /** Disable if your backend accepts camelCase. Defaults to true. */
212
+ mapRequestKeys?: boolean;
213
+ }
214
+ declare class GenericService<TEntity = any, TCreateInput = Partial<TEntity>, TUpdateInput = Partial<TCreateInput>, TBackendEntity = unknown> {
215
+ private client;
216
+ private endpoint;
217
+ private options;
218
+ constructor(client: HttpClient, endpoint: string, options?: GenericServiceOptions<TEntity, TCreateInput, TUpdateInput, TBackendEntity>);
219
+ findAll(params?: QueryParams): Promise<TEntity[]>;
220
+ findById(id: Id, params?: QueryParams): Promise<TEntity>;
221
+ create(payload: TCreateInput): Promise<TEntity>;
222
+ update(id: Id, payload: TUpdateInput): Promise<TEntity>;
223
+ patch(id: Id, payload: TUpdateInput): Promise<TEntity>;
224
+ delete<TDeleteResponse = unknown>(id: Id): Promise<TDeleteResponse>;
225
+ upload(file: FormData): Promise<TEntity>;
226
+ private extractData;
227
+ private parseEntity;
228
+ private mapEntity;
229
+ private mapRequest;
230
+ }
231
+ declare function createService<TEntity = any, TCreateInput = Partial<TEntity>, TUpdateInput = Partial<TCreateInput>, TBackendEntity = unknown>(client: HttpClient, endpoint: string, options?: GenericServiceOptions<TEntity, TCreateInput, TUpdateInput, TBackendEntity>): GenericService<TEntity, TCreateInput, TUpdateInput, TBackendEntity>;
232
+
233
+ declare function createClient(config: ServiceConfig): {
234
+ client: HttpClient;
235
+ tokenManager: TokenManager;
236
+ setToken(token: string): void;
237
+ clearToken(): void;
238
+ };
239
+
240
+ type HookMap = Record<string, (...args: any[]) => any>;
241
+ /**
242
+ * generateHooks — auto-generate TanStack hooks from a full defineApi result.
243
+ *
244
+ * Reads method from endpoint.$def.method — no heuristics, no string matching.
245
+ *
246
+ * Usage:
247
+ * const api = defineApi({ cart: { list: endpoint({...}), create: endpoint({...}) } })
248
+ * const hooks = generateHooks(api)
249
+ * const { useCartList, useCartCreate } = hooks
250
+ */
251
+ declare function generateHooks(api: Record<string, Record<string, EndpointCallable>>): HookMap;
252
+
253
+ type KeyCase = 'camel' | 'snake';
254
+ type SnakeToCamel<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${Capitalize<SnakeToCamel<Tail>>}` : S;
255
+ type CamelToSnake<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${CamelToSnake<Tail>}` : `${Lowercase<Head>}_${CamelToSnake<Tail>}` : S;
256
+ type CamelCasedPropertiesDeep<T> = T extends readonly (infer Item)[] ? CamelCasedPropertiesDeep<Item>[] : T extends object ? {
257
+ [K in keyof T as K extends string ? SnakeToCamel<K> : K]: CamelCasedPropertiesDeep<T[K]>;
258
+ } : T;
259
+ type SnakeCasedPropertiesDeep<T> = T extends readonly (infer Item)[] ? SnakeCasedPropertiesDeep<Item>[] : T extends object ? {
260
+ [K in keyof T as K extends string ? CamelToSnake<K> : K]: SnakeCasedPropertiesDeep<T[K]>;
261
+ } : T;
262
+ type UnknownRecord = Record<string, unknown>;
263
+ declare function snakeToCamelKey(key: string): string;
264
+ declare function camelToSnakeKey(key: string): string;
265
+ declare function mapKeysDeep<T>(value: T, keyCase: KeyCase): T;
266
+ declare function toCamelCase<T>(value: T): T;
267
+ declare function toSnakeCase<T>(value: T): T;
268
+
269
+ export { type ApiDefinition, type ApiResponse, type CallOptions, type CamelCasedPropertiesDeep, type CamelToSnake, type EndpointCallable, type EndpointDefinition$1 as EndpointDefinition, GenericService, type GenericServiceOptions, type HttpMethod, type Id, type KeyCase, type ParseResult, type ParserSchema, type QueryParams, type ResourceConfig, type ResourceDefinition, type RouteDefinition, type RouteMapper, type RouteParserSchema, type RouteSchema, type RouteSchemaMap, type RouteSchemaValue, type RouteTransform, type RouteTransformMap, type SchemaLike, type ServiceConfig, type SnakeCasedPropertiesDeep, type SnakeToCamel, type UnknownRecord, camelToSnakeKey, createClient$1 as createClient, createClient as createHttpClient, createService, defineApi, endpoint, generateHooks, mapKeysDeep, parseWithSchema, resource, snakeToCamelKey, toCamelCase, toSnakeCase };
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,269 @@
1
+ import { AxiosRequestConfig, AxiosInstance } from 'axios';
2
+
3
+ interface ServiceConfig {
4
+ baseURL: string;
5
+ token?: string;
6
+ headers?: Record<string, string>;
7
+ timeout?: number;
8
+ retry?: RetryConfig;
9
+ cache?: boolean;
10
+ }
11
+ interface RetryConfig {
12
+ attempts: number;
13
+ delay?: number;
14
+ statusCodes?: number[];
15
+ }
16
+
17
+ declare class HttpClient {
18
+ private client;
19
+ constructor(config: ServiceConfig);
20
+ private setupInterceptors;
21
+ setToken(token: string): void;
22
+ removeToken(): void;
23
+ get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
24
+ post<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
25
+ put<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
26
+ patch<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
27
+ delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
28
+ upload<T>(url: string, formData: FormData): Promise<T>;
29
+ getInstance(): AxiosInstance;
30
+ }
31
+
32
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
33
+ type RouteTransform = (value: unknown) => unknown;
34
+ interface RouteTransformMap {
35
+ params?: RouteTransform;
36
+ query?: RouteTransform;
37
+ body?: RouteTransform;
38
+ request?: RouteTransform;
39
+ response?: RouteTransform;
40
+ }
41
+ type RouteMapper = RouteTransform | RouteTransformMap;
42
+ interface RouteParserSchema {
43
+ parse?: RouteTransform;
44
+ safeParse?: RouteTransform;
45
+ }
46
+ interface RouteSchemaMap {
47
+ params?: RouteSchemaValue;
48
+ query?: RouteSchemaValue;
49
+ body?: RouteSchemaValue;
50
+ request?: RouteSchemaValue;
51
+ response?: RouteSchemaValue;
52
+ }
53
+ type RouteSchemaValue = RouteTransform | RouteParserSchema;
54
+ type RouteSchema = RouteSchemaValue | RouteSchemaMap;
55
+ interface RouteDefinition {
56
+ method: HttpMethod;
57
+ path: string;
58
+ auth?: boolean;
59
+ schema?: RouteSchema;
60
+ mapper?: RouteMapper;
61
+ headers?: Record<string, string>;
62
+ cache?: unknown;
63
+ retry?: unknown;
64
+ body?: Record<string, any>;
65
+ params?: Record<string, any>;
66
+ query?: Record<string, any>;
67
+ }
68
+ interface ApiDefinition {
69
+ [group: string]: {
70
+ [action: string]: RouteDefinition;
71
+ };
72
+ }
73
+
74
+ interface ApiResponse<T = any> {
75
+ success: boolean;
76
+ message?: string;
77
+ data: T;
78
+ meta?: PaginationMeta;
79
+ }
80
+ interface PaginationMeta {
81
+ current_page: number;
82
+ last_page: number;
83
+ per_page: number;
84
+ total: number;
85
+ from?: number;
86
+ to?: number;
87
+ }
88
+
89
+ declare class TokenManager {
90
+ private static TOKEN_KEY;
91
+ private token;
92
+ set(token: string): void;
93
+ get(): string | null;
94
+ clear(): void;
95
+ exists(): boolean;
96
+ }
97
+
98
+ type CallOptions = {
99
+ params?: Record<string, any>;
100
+ query?: Record<string, any>;
101
+ body?: Record<string, any>;
102
+ };
103
+ interface EndpointCallable {
104
+ (options?: CallOptions): Promise<any>;
105
+ /** Original RouteDefinition — used by useApiQuery / useApiMutation */
106
+ $def: RouteDefinition;
107
+ /** Stable TanStack query key: [group, action] */
108
+ $key: string[];
109
+ }
110
+ type ApiGroupProxy<G extends Record<string, RouteDefinition>> = {
111
+ [K in keyof G]: EndpointCallable;
112
+ };
113
+ type ApiProxy<T extends ApiDefinition> = {
114
+ [G in keyof T]: ApiGroupProxy<T[G]>;
115
+ };
116
+ declare function createClient$1(config: ServiceConfig): HttpClient;
117
+ declare function defineApi<T extends ApiDefinition>(definition: T, config?: ServiceConfig): ApiProxy<T>;
118
+
119
+ type EndpointDefinition$1 = RouteDefinition;
120
+ /**
121
+ * endpoint() — declare a typed endpoint definition.
122
+ *
123
+ * Each endpoint fully owns its path. Use inside defineApi() or resource().
124
+ *
125
+ * Usage:
126
+ * const api = defineApi({
127
+ * cart: {
128
+ * list: endpoint({ method: 'GET', path: '/cart/items' }),
129
+ * create: endpoint({ method: 'POST', path: '/cart/items' }),
130
+ * }
131
+ * })
132
+ *
133
+ * // TanStack-friendly:
134
+ * const { data } = useApiQuery(api.cart.list)
135
+ * const mutation = useApiMutation(api.cart.create)
136
+ */
137
+ declare function endpoint(def: RouteDefinition): RouteDefinition;
138
+
139
+ type EndpointDefinition = RouteDefinition;
140
+ interface ResourceConfig<TEndpoints extends Record<string, EndpointDefinition>> {
141
+ /**
142
+ * Optional base path for grouping / documentation purposes only.
143
+ * NOT merged into endpoint paths — each endpoint fully owns its own path.
144
+ * @deprecated Use endpoint.path directly. This field is ignored at runtime.
145
+ */
146
+ basePath?: string;
147
+ endpoints: TEndpoints;
148
+ /** Default auth flag applied to all endpoints that don't override it. */
149
+ auth?: boolean;
150
+ /** Default headers merged with per-endpoint headers (endpoint takes priority). */
151
+ headers?: Record<string, string>;
152
+ /** Default cache config applied to endpoints that don't override it. */
153
+ cache?: unknown;
154
+ /** Default retry config applied to endpoints that don't override it. */
155
+ retry?: unknown;
156
+ }
157
+ type ResourceDefinition<TEndpoints extends Record<string, EndpointDefinition>> = {
158
+ [K in keyof TEndpoints]: RouteDefinition;
159
+ };
160
+ /**
161
+ * resource() — group related endpoints together.
162
+ *
163
+ * Each endpoint fully owns its path. No path merging happens.
164
+ * Defaults (auth, headers, cache, retry) cascade down but endpoints can override.
165
+ *
166
+ * Usage:
167
+ * const cartResource = resource({
168
+ * auth: true,
169
+ * endpoints: {
170
+ * list: { method: 'GET', path: '/cart/items' },
171
+ * show: { method: 'GET', path: '/cart/items/:id' },
172
+ * create: { method: 'POST', path: '/cart/items' },
173
+ * update: { method: 'PATCH', path: '/cart/items/:id' },
174
+ * delete: { method: 'DELETE', path: '/cart/items/:id' },
175
+ * },
176
+ * })
177
+ */
178
+ declare function resource<TEndpoints extends Record<string, EndpointDefinition>>(config: ResourceConfig<TEndpoints>): ResourceDefinition<TEndpoints>;
179
+
180
+ type ParseResult<T> = {
181
+ success: true;
182
+ data: T;
183
+ } | {
184
+ success: false;
185
+ error: unknown;
186
+ };
187
+ interface ParserSchema<T> {
188
+ parse?: (value: unknown) => T;
189
+ safeParse?: (value: unknown) => ParseResult<T>;
190
+ }
191
+ type SchemaLike<T> = ParserSchema<T> | ((value: unknown) => T);
192
+ declare function parseWithSchema<T>(schema: SchemaLike<T> | undefined, value: unknown): T;
193
+
194
+ type Id = string | number;
195
+ type QueryParams = Record<string, any>;
196
+ interface GenericServiceOptions<TEntity, TCreateInput = Partial<TEntity>, TUpdateInput = Partial<TCreateInput>, TBackendEntity = unknown> {
197
+ /** Validate one backend entity before it is mapped to frontend shape. Works with Zod schemas. */
198
+ entitySchema?: SchemaLike<TBackendEntity>;
199
+ /** Validate backend list responses before each item is mapped to frontend shape. Works with Zod arrays. */
200
+ listSchema?: SchemaLike<TBackendEntity[]>;
201
+ /** Validate frontend create payloads before they are mapped to backend snake_case. Works with Zod schemas. */
202
+ createSchema?: SchemaLike<TCreateInput>;
203
+ /** Validate frontend update/patch payloads before they are mapped to backend snake_case. Works with Zod schemas. */
204
+ updateSchema?: SchemaLike<TUpdateInput>;
205
+ /** Override backend -> frontend mapping. Defaults to deep snake_case -> camelCase. */
206
+ fromBackend?: (value: TBackendEntity) => TEntity;
207
+ /** Override frontend -> backend mapping. Defaults to deep camelCase -> snake_case. */
208
+ toBackend?: (value: TCreateInput | TUpdateInput | QueryParams) => unknown;
209
+ /** Disable if your backend already returns camelCase. Defaults to true. */
210
+ mapResponseKeys?: boolean;
211
+ /** Disable if your backend accepts camelCase. Defaults to true. */
212
+ mapRequestKeys?: boolean;
213
+ }
214
+ declare class GenericService<TEntity = any, TCreateInput = Partial<TEntity>, TUpdateInput = Partial<TCreateInput>, TBackendEntity = unknown> {
215
+ private client;
216
+ private endpoint;
217
+ private options;
218
+ constructor(client: HttpClient, endpoint: string, options?: GenericServiceOptions<TEntity, TCreateInput, TUpdateInput, TBackendEntity>);
219
+ findAll(params?: QueryParams): Promise<TEntity[]>;
220
+ findById(id: Id, params?: QueryParams): Promise<TEntity>;
221
+ create(payload: TCreateInput): Promise<TEntity>;
222
+ update(id: Id, payload: TUpdateInput): Promise<TEntity>;
223
+ patch(id: Id, payload: TUpdateInput): Promise<TEntity>;
224
+ delete<TDeleteResponse = unknown>(id: Id): Promise<TDeleteResponse>;
225
+ upload(file: FormData): Promise<TEntity>;
226
+ private extractData;
227
+ private parseEntity;
228
+ private mapEntity;
229
+ private mapRequest;
230
+ }
231
+ declare function createService<TEntity = any, TCreateInput = Partial<TEntity>, TUpdateInput = Partial<TCreateInput>, TBackendEntity = unknown>(client: HttpClient, endpoint: string, options?: GenericServiceOptions<TEntity, TCreateInput, TUpdateInput, TBackendEntity>): GenericService<TEntity, TCreateInput, TUpdateInput, TBackendEntity>;
232
+
233
+ declare function createClient(config: ServiceConfig): {
234
+ client: HttpClient;
235
+ tokenManager: TokenManager;
236
+ setToken(token: string): void;
237
+ clearToken(): void;
238
+ };
239
+
240
+ type HookMap = Record<string, (...args: any[]) => any>;
241
+ /**
242
+ * generateHooks — auto-generate TanStack hooks from a full defineApi result.
243
+ *
244
+ * Reads method from endpoint.$def.method — no heuristics, no string matching.
245
+ *
246
+ * Usage:
247
+ * const api = defineApi({ cart: { list: endpoint({...}), create: endpoint({...}) } })
248
+ * const hooks = generateHooks(api)
249
+ * const { useCartList, useCartCreate } = hooks
250
+ */
251
+ declare function generateHooks(api: Record<string, Record<string, EndpointCallable>>): HookMap;
252
+
253
+ type KeyCase = 'camel' | 'snake';
254
+ type SnakeToCamel<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${Capitalize<SnakeToCamel<Tail>>}` : S;
255
+ type CamelToSnake<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${CamelToSnake<Tail>}` : `${Lowercase<Head>}_${CamelToSnake<Tail>}` : S;
256
+ type CamelCasedPropertiesDeep<T> = T extends readonly (infer Item)[] ? CamelCasedPropertiesDeep<Item>[] : T extends object ? {
257
+ [K in keyof T as K extends string ? SnakeToCamel<K> : K]: CamelCasedPropertiesDeep<T[K]>;
258
+ } : T;
259
+ type SnakeCasedPropertiesDeep<T> = T extends readonly (infer Item)[] ? SnakeCasedPropertiesDeep<Item>[] : T extends object ? {
260
+ [K in keyof T as K extends string ? CamelToSnake<K> : K]: SnakeCasedPropertiesDeep<T[K]>;
261
+ } : T;
262
+ type UnknownRecord = Record<string, unknown>;
263
+ declare function snakeToCamelKey(key: string): string;
264
+ declare function camelToSnakeKey(key: string): string;
265
+ declare function mapKeysDeep<T>(value: T, keyCase: KeyCase): T;
266
+ declare function toCamelCase<T>(value: T): T;
267
+ declare function toSnakeCase<T>(value: T): T;
268
+
269
+ export { type ApiDefinition, type ApiResponse, type CallOptions, type CamelCasedPropertiesDeep, type CamelToSnake, type EndpointCallable, type EndpointDefinition$1 as EndpointDefinition, GenericService, type GenericServiceOptions, type HttpMethod, type Id, type KeyCase, type ParseResult, type ParserSchema, type QueryParams, type ResourceConfig, type ResourceDefinition, type RouteDefinition, type RouteMapper, type RouteParserSchema, type RouteSchema, type RouteSchemaMap, type RouteSchemaValue, type RouteTransform, type RouteTransformMap, type SchemaLike, type ServiceConfig, type SnakeCasedPropertiesDeep, type SnakeToCamel, type UnknownRecord, camelToSnakeKey, createClient$1 as createClient, createClient as createHttpClient, createService, defineApi, endpoint, generateHooks, mapKeysDeep, parseWithSchema, resource, snakeToCamelKey, toCamelCase, toSnakeCase };