routesync 1.0.34 → 1.0.35

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/react.d.mts CHANGED
@@ -63,6 +63,12 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {
63
63
  query?: Record<string, any>;
64
64
  headers?: Record<string, string>;
65
65
  };
66
+ type LooseEndpointOptions = {
67
+ params?: unknown;
68
+ query?: Record<string, unknown>;
69
+ body?: unknown;
70
+ headers?: Record<string, string>;
71
+ };
66
72
  type RequiredKeys<T> = {
67
73
  [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
68
74
  }[keyof T];
@@ -74,7 +80,7 @@ interface ApiError {
74
80
  }
75
81
  interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unknown> {
76
82
  (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>): Promise<TResponse>;
77
- (options: EndpointCallableOptions<TParams, TBody> | undefined): Promise<TResponse>;
83
+ (options: LooseEndpointOptions | undefined): Promise<TResponse>;
78
84
  (options: CallOptions<TParams, TBody>): Promise<TResponse>;
79
85
  /** Original RouteDefinition — used by useApiQuery / useApiMutation */
80
86
  $def: RouteDefinition<TResponse, TParams, TBody>;
@@ -86,9 +92,9 @@ interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unkno
86
92
 
87
93
  type ApiQueryOptions<TResponse, TError = ApiError, TData = TResponse> = Omit<UseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>;
88
94
  declare function useApiQuery<TResponse, TParams, TBody, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options: EndpointCallableOptions<TParams, TBody>, queryOptions?: ApiQueryOptions<TResponse, TError, TData>): ReturnType<typeof useQuery<TResponse, TError, TData>>;
89
- declare function useApiQuery<TResponse, TParams, TBody, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>, queryOptions?: ApiQueryOptions<TResponse, TError, TData>): ReturnType<typeof useQuery<TResponse, TError, TData>>;
90
- declare function useApiSuspenseQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>, queryOptions?: Omit<UseSuspenseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseSuspenseQueryResult<TData, TError>;
91
- declare function useApiInfiniteQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = InfiniteData<TResponse>, TPageParam = unknown>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options: EndpointCallableOptions<TParams, TBody> | undefined, queryOptions: Omit<UseInfiniteQueryOptions<TResponse, TError, TData, any, TPageParam>, 'queryKey' | 'queryFn'> & {
95
+ declare function useApiQuery<TResponse, TParams, TBody, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: LooseEndpointOptions, queryOptions?: ApiQueryOptions<TResponse, TError, TData>): ReturnType<typeof useQuery<TResponse, TError, TData>>;
96
+ declare function useApiSuspenseQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: LooseEndpointOptions, queryOptions?: Omit<UseSuspenseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseSuspenseQueryResult<TData, TError>;
97
+ declare function useApiInfiniteQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = InfiniteData<TResponse>, TPageParam = unknown>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options: LooseEndpointOptions | undefined, queryOptions: Omit<UseInfiniteQueryOptions<TResponse, TError, TData, any, TPageParam>, 'queryKey' | 'queryFn'> & {
92
98
  getNextPageParam: UseInfiniteQueryOptions<TResponse, TError, TData, any, TPageParam>['getNextPageParam'];
93
99
  }): _tanstack_react_query.UseInfiniteQueryResult<TData, TError>;
94
100
 
package/dist/react.d.ts CHANGED
@@ -63,6 +63,12 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {
63
63
  query?: Record<string, any>;
64
64
  headers?: Record<string, string>;
65
65
  };
66
+ type LooseEndpointOptions = {
67
+ params?: unknown;
68
+ query?: Record<string, unknown>;
69
+ body?: unknown;
70
+ headers?: Record<string, string>;
71
+ };
66
72
  type RequiredKeys<T> = {
67
73
  [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
68
74
  }[keyof T];
@@ -74,7 +80,7 @@ interface ApiError {
74
80
  }
75
81
  interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unknown> {
76
82
  (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>): Promise<TResponse>;
77
- (options: EndpointCallableOptions<TParams, TBody> | undefined): Promise<TResponse>;
83
+ (options: LooseEndpointOptions | undefined): Promise<TResponse>;
78
84
  (options: CallOptions<TParams, TBody>): Promise<TResponse>;
79
85
  /** Original RouteDefinition — used by useApiQuery / useApiMutation */
80
86
  $def: RouteDefinition<TResponse, TParams, TBody>;
@@ -86,9 +92,9 @@ interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unkno
86
92
 
87
93
  type ApiQueryOptions<TResponse, TError = ApiError, TData = TResponse> = Omit<UseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>;
88
94
  declare function useApiQuery<TResponse, TParams, TBody, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options: EndpointCallableOptions<TParams, TBody>, queryOptions?: ApiQueryOptions<TResponse, TError, TData>): ReturnType<typeof useQuery<TResponse, TError, TData>>;
89
- declare function useApiQuery<TResponse, TParams, TBody, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>, queryOptions?: ApiQueryOptions<TResponse, TError, TData>): ReturnType<typeof useQuery<TResponse, TError, TData>>;
90
- declare function useApiSuspenseQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>, queryOptions?: Omit<UseSuspenseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseSuspenseQueryResult<TData, TError>;
91
- declare function useApiInfiniteQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = InfiniteData<TResponse>, TPageParam = unknown>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options: EndpointCallableOptions<TParams, TBody> | undefined, queryOptions: Omit<UseInfiniteQueryOptions<TResponse, TError, TData, any, TPageParam>, 'queryKey' | 'queryFn'> & {
95
+ declare function useApiQuery<TResponse, TParams, TBody, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: LooseEndpointOptions, queryOptions?: ApiQueryOptions<TResponse, TError, TData>): ReturnType<typeof useQuery<TResponse, TError, TData>>;
96
+ declare function useApiSuspenseQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: LooseEndpointOptions, queryOptions?: Omit<UseSuspenseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseSuspenseQueryResult<TData, TError>;
97
+ declare function useApiInfiniteQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = InfiniteData<TResponse>, TPageParam = unknown>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options: LooseEndpointOptions | undefined, queryOptions: Omit<UseInfiniteQueryOptions<TResponse, TError, TData, any, TPageParam>, 'queryKey' | 'queryFn'> & {
92
98
  getNextPageParam: UseInfiniteQueryOptions<TResponse, TError, TData, any, TPageParam>['getNextPageParam'];
93
99
  }): _tanstack_react_query.UseInfiniteQueryResult<TData, TError>;
94
100
 
package/dist/react.js CHANGED
@@ -33,30 +33,30 @@ module.exports = __toCommonJS(src_exports);
33
33
  // packages/react/src/hooks/useQuery.ts
34
34
  var import_react_query = require("@tanstack/react-query");
35
35
  function useApiQuery(endpoint, options, queryOptions) {
36
- const queryKey = endpoint.$queryKey(options);
37
- const callEndpoint = endpoint;
36
+ const queryKey = options ? [...endpoint.$key, options] : endpoint.$key;
38
37
  return (0, import_react_query.useQuery)({
39
38
  queryKey,
40
- queryFn: () => callEndpoint(options),
39
+ queryFn: () => endpoint(options),
41
40
  ...queryOptions
42
41
  });
43
42
  }
44
43
  function useApiSuspenseQuery(endpoint, options, queryOptions) {
45
- const queryKey = endpoint.$queryKey(options);
46
- const callEndpoint = endpoint;
44
+ const queryKey = options ? [...endpoint.$key, options] : endpoint.$key;
47
45
  return (0, import_react_query.useSuspenseQuery)({
48
46
  queryKey,
49
- queryFn: () => callEndpoint(options),
47
+ queryFn: () => endpoint(options),
50
48
  ...queryOptions
51
49
  });
52
50
  }
53
51
  function useApiInfiniteQuery(endpoint, options, queryOptions) {
54
- const queryKey = endpoint.$queryKey(options);
52
+ const queryKey = options ? [...endpoint.$key, options] : endpoint.$key;
55
53
  return (0, import_react_query.useInfiniteQuery)({
56
54
  queryKey,
57
55
  queryFn: ({ pageParam }) => {
58
56
  const callOptions = {
59
- ...options,
57
+ params: options?.params,
58
+ body: options?.body,
59
+ headers: options?.headers,
60
60
  query: { ...options?.query, page: pageParam }
61
61
  };
62
62
  return endpoint(callOptions);
package/dist/react.mjs CHANGED
@@ -1,30 +1,30 @@
1
1
  // packages/react/src/hooks/useQuery.ts
2
2
  import { useQuery, useSuspenseQuery, useInfiniteQuery } from "@tanstack/react-query";
3
3
  function useApiQuery(endpoint, options, queryOptions) {
4
- const queryKey = endpoint.$queryKey(options);
5
- const callEndpoint = endpoint;
4
+ const queryKey = options ? [...endpoint.$key, options] : endpoint.$key;
6
5
  return useQuery({
7
6
  queryKey,
8
- queryFn: () => callEndpoint(options),
7
+ queryFn: () => endpoint(options),
9
8
  ...queryOptions
10
9
  });
11
10
  }
12
11
  function useApiSuspenseQuery(endpoint, options, queryOptions) {
13
- const queryKey = endpoint.$queryKey(options);
14
- const callEndpoint = endpoint;
12
+ const queryKey = options ? [...endpoint.$key, options] : endpoint.$key;
15
13
  return useSuspenseQuery({
16
14
  queryKey,
17
- queryFn: () => callEndpoint(options),
15
+ queryFn: () => endpoint(options),
18
16
  ...queryOptions
19
17
  });
20
18
  }
21
19
  function useApiInfiniteQuery(endpoint, options, queryOptions) {
22
- const queryKey = endpoint.$queryKey(options);
20
+ const queryKey = options ? [...endpoint.$key, options] : endpoint.$key;
23
21
  return useInfiniteQuery({
24
22
  queryKey,
25
23
  queryFn: ({ pageParam }) => {
26
24
  const callOptions = {
27
- ...options,
25
+ params: options?.params,
26
+ body: options?.body,
27
+ headers: options?.headers,
28
28
  query: { ...options?.query, page: pageParam }
29
29
  };
30
30
  return endpoint(callOptions);
package/dist/sdk.d.mts CHANGED
@@ -133,6 +133,12 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {
133
133
  query?: Record<string, any>;
134
134
  headers?: Record<string, string>;
135
135
  };
136
+ type LooseEndpointOptions = {
137
+ params?: unknown;
138
+ query?: Record<string, unknown>;
139
+ body?: unknown;
140
+ headers?: Record<string, string>;
141
+ };
136
142
  type RequiredKeys<T> = {
137
143
  [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
138
144
  }[keyof T];
@@ -144,7 +150,7 @@ interface ApiError {
144
150
  }
145
151
  interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unknown> {
146
152
  (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>): Promise<TResponse>;
147
- (options: EndpointCallableOptions<TParams, TBody> | undefined): Promise<TResponse>;
153
+ (options: LooseEndpointOptions | undefined): Promise<TResponse>;
148
154
  (options: CallOptions<TParams, TBody>): Promise<TResponse>;
149
155
  /** Original RouteDefinition — used by useApiQuery / useApiMutation */
150
156
  $def: RouteDefinition<TResponse, TParams, TBody>;
@@ -312,4 +318,4 @@ declare function mapKeysDeep<T>(value: T, keyCase: KeyCase): T;
312
318
  declare function toCamelCase<T>(value: T): T;
313
319
  declare function toSnakeCase<T>(value: T): T;
314
320
 
315
- export { type ApiDefinition, type ApiError, type ApiResponse, type CallOptions, type CamelCasedPropertiesDeep, type CamelToSnake, type EndpointCallable, type EndpointCallableOptions, type EndpointDefinition$1 as EndpointDefinition, GenericService, type GenericServiceOptions, type HttpMethod, type Id, type KeyCase, type OptionalIfEmpty, 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 };
321
+ export { type ApiDefinition, type ApiError, type ApiResponse, type CallOptions, type CamelCasedPropertiesDeep, type CamelToSnake, type EndpointCallable, type EndpointCallableOptions, type EndpointDefinition$1 as EndpointDefinition, GenericService, type GenericServiceOptions, type HttpMethod, type Id, type KeyCase, type LooseEndpointOptions, type OptionalIfEmpty, 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 CHANGED
@@ -133,6 +133,12 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {
133
133
  query?: Record<string, any>;
134
134
  headers?: Record<string, string>;
135
135
  };
136
+ type LooseEndpointOptions = {
137
+ params?: unknown;
138
+ query?: Record<string, unknown>;
139
+ body?: unknown;
140
+ headers?: Record<string, string>;
141
+ };
136
142
  type RequiredKeys<T> = {
137
143
  [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
138
144
  }[keyof T];
@@ -144,7 +150,7 @@ interface ApiError {
144
150
  }
145
151
  interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unknown> {
146
152
  (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>): Promise<TResponse>;
147
- (options: EndpointCallableOptions<TParams, TBody> | undefined): Promise<TResponse>;
153
+ (options: LooseEndpointOptions | undefined): Promise<TResponse>;
148
154
  (options: CallOptions<TParams, TBody>): Promise<TResponse>;
149
155
  /** Original RouteDefinition — used by useApiQuery / useApiMutation */
150
156
  $def: RouteDefinition<TResponse, TParams, TBody>;
@@ -312,4 +318,4 @@ declare function mapKeysDeep<T>(value: T, keyCase: KeyCase): T;
312
318
  declare function toCamelCase<T>(value: T): T;
313
319
  declare function toSnakeCase<T>(value: T): T;
314
320
 
315
- export { type ApiDefinition, type ApiError, type ApiResponse, type CallOptions, type CamelCasedPropertiesDeep, type CamelToSnake, type EndpointCallable, type EndpointCallableOptions, type EndpointDefinition$1 as EndpointDefinition, GenericService, type GenericServiceOptions, type HttpMethod, type Id, type KeyCase, type OptionalIfEmpty, 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 };
321
+ export { type ApiDefinition, type ApiError, type ApiResponse, type CallOptions, type CamelCasedPropertiesDeep, type CamelToSnake, type EndpointCallable, type EndpointCallableOptions, type EndpointDefinition$1 as EndpointDefinition, GenericService, type GenericServiceOptions, type HttpMethod, type Id, type KeyCase, type LooseEndpointOptions, type OptionalIfEmpty, 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routesync",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "Laravel routes to typed frontend SDKs.",
5
5
  "main": "./dist/sdk.js",
6
6
  "module": "./dist/sdk.mjs",