routesync 1.0.28 → 1.0.30

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/cli.js CHANGED
@@ -8751,7 +8751,7 @@ var SDKGenerator = class {
8751
8751
  lines.push(`// Auto-generated by routesync. Do not edit manually.`);
8752
8752
  lines.push(`// Generated at: ${manifest.generatedAt}`);
8753
8753
  lines.push(``);
8754
- lines.push(`import { defineApi${usesTypes ? ", endpoint" : ""} } from 'routesync'`);
8754
+ lines.push(`import { defineApi, endpoint } from 'routesync'`);
8755
8755
  if (usesZod) {
8756
8756
  lines.push(`import { z } from 'zod'`);
8757
8757
  lines.push(`import * as Schemas from './schemas'`);
@@ -9116,16 +9116,18 @@ var NextActionGenerator = class {
9116
9116
  const hasParams = pathParams.length > 0;
9117
9117
  const hasBody = ["POST", "PUT", "PATCH", "DELETE"].includes(route.method) && route.schema?.rules && Object.keys(route.schema.rules).length > 0;
9118
9118
  const hasQuery = route.method === "GET" || route.method === "DELETE";
9119
- usedContracts.add(ContractName);
9120
9119
  const sigParts = [];
9121
9120
  if (hasParams) sigParts.push(`params: ${ContractName}['request']['params']`);
9122
9121
  if (hasQuery) sigParts.push(`query?: ${ContractName}['request']['query']`);
9123
- if (hasBody) sigParts.push(`body?: ${ContractName}['request']['body']`);
9124
- const fnParam = sigParts.length > 0 ? `payload${hasParams ? "" : "?"}: { ${sigParts.join(", ")} }` : "";
9122
+ if (hasBody) sigParts.push(`body: ${ContractName}['request']['body']`);
9123
+ const needsContract = sigParts.length > 0;
9124
+ if (needsContract) usedContracts.add(ContractName);
9125
+ const payloadRequired = hasParams || hasBody;
9126
+ const fnParam = sigParts.length > 0 ? `payload${payloadRequired ? "" : "?"}: { ${sigParts.join(", ")} }` : "";
9125
9127
  const callArgs = [];
9126
9128
  if (hasParams) callArgs.push(`params: payload.params`);
9127
9129
  if (hasQuery) callArgs.push(`query: payload?.query`);
9128
- if (hasBody) callArgs.push(`body: payload?.body`);
9130
+ if (hasBody) callArgs.push(`body: payload.body`);
9129
9131
  if (route.auth) callArgs.push(`headers: await getAuthHeaders()`);
9130
9132
  const argsStr = callArgs.length > 0 ? `{ ${callArgs.join(", ")} }` : "";
9131
9133
  lines.push(`export async function ${actionFnName}(${fnParam}) {`);
package/dist/react.d.mts CHANGED
@@ -45,6 +45,12 @@ interface RouteDefinition<TResponse = unknown, TParams = unknown, TBody = unknow
45
45
  _typeBody?: TBody;
46
46
  }
47
47
 
48
+ type CallOptions<TParams = unknown, TBody = unknown> = {
49
+ params?: TParams;
50
+ query?: Record<string, any>;
51
+ body?: TBody;
52
+ headers?: Record<string, string>;
53
+ };
48
54
  type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {} : {
49
55
  params: TParams;
50
56
  }) & (unknown extends TBody ? {
@@ -55,7 +61,10 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {} : {
55
61
  query?: Record<string, any>;
56
62
  headers?: Record<string, string>;
57
63
  };
58
- type OptionalIfEmpty<T> = keyof Omit<T, 'query' | 'headers'> extends never ? [options?: T] : [options: T];
64
+ type RequiredKeys<T> = {
65
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
66
+ }[keyof T];
67
+ type OptionalIfEmpty<T> = RequiredKeys<Omit<T, 'query' | 'headers'>> extends never ? [options?: T] : [options: T];
59
68
  interface ApiError {
60
69
  message: string;
61
70
  status?: number;
@@ -63,36 +72,25 @@ interface ApiError {
63
72
  }
64
73
  interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unknown> {
65
74
  (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>): Promise<TResponse>;
75
+ (options: EndpointCallableOptions<TParams, TBody> | undefined): Promise<TResponse>;
76
+ (options: CallOptions<TParams, TBody>): Promise<TResponse>;
66
77
  /** Original RouteDefinition — used by useApiQuery / useApiMutation */
67
78
  $def: RouteDefinition<TResponse, TParams, TBody>;
68
79
  /** Stable TanStack query key: [group, action] */
69
80
  $key: string[];
70
81
  /** Consistent query key builder that incorporates params/query if provided */
71
- $queryKey: (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>) => unknown[];
82
+ $queryKey: (options?: EndpointCallableOptions<TParams, TBody>) => unknown[];
72
83
  }
73
84
 
74
- /**
75
- * useApiQuery — accepts an endpoint callable directly.
76
- *
77
- * Usage:
78
- * const { data, isLoading } = useApiQuery(api.produk.list)
79
- * const { data } = useApiQuery(api.produk.detail, { params: { id: 10 } })
80
- */
81
85
  type ApiQueryOptions<TResponse, TError = ApiError, TData = TResponse> = Omit<UseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>;
82
86
  declare function useApiQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, ...args: [
83
87
  ...OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>,
84
- queryOptions?: Omit<UseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>
88
+ queryOptions?: ApiQueryOptions<TResponse, TError, TData>
85
89
  ]): _tanstack_react_query.UseQueryResult<NoInfer<TData>, TError>;
86
- /**
87
- * useApiSuspenseQuery — generic wrapper for Suspense-enabled data fetching (TanStack v5).
88
- */
89
90
  declare function useApiSuspenseQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, ...args: [
90
91
  ...OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>,
91
92
  queryOptions?: Omit<UseSuspenseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>
92
93
  ]): _tanstack_react_query.UseSuspenseQueryResult<TData, TError>;
93
- /**
94
- * useApiInfiniteQuery — framework agnostic paginated fetching.
95
- */
96
94
  declare function useApiInfiniteQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = InfiniteData<TResponse>, TPageParam = unknown>(endpoint: EndpointCallable<TResponse, TParams, TBody>, ...args: [
97
95
  ...OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>,
98
96
  queryOptions: Omit<UseInfiniteQueryOptions<TResponse, TError, TData, any, TPageParam>, 'queryKey' | 'queryFn'>
@@ -117,32 +115,11 @@ interface ApiMutationOptions<TData, TError, TVariables, TContext = unknown> exte
117
115
  }
118
116
  declare function useApiMutation<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TContext = unknown>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: ApiMutationOptions<TResponse, TError, EndpointCallableOptions<TParams, TBody>, TContext>): _tanstack_react_query.UseMutationResult<TResponse, TError, EndpointCallableOptions<TParams, TBody>, TContext>;
119
117
 
120
- /**
121
- * useApiQueryClient — a typed wrapper over TanStack's QueryClient
122
- *
123
- * Provides ergonomic helpers like invalidateEndpoint and prefetchEndpoint
124
- * with strong typing based on the RouteSync SDK contracts.
125
- */
126
118
  declare function useApiQueryClient(): {
127
119
  queryClient: QueryClient;
128
- /**
129
- * Invalidate specific queries related to an endpoint.
130
- * Optionally pass parameters to invalidate a more specific cache entry.
131
- */
132
120
  invalidateEndpoint: <TResponse, TParams, TBody>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>) => Promise<void>;
133
- /**
134
- * Prefetch data for an endpoint into the cache.
135
- * Useful for SSR, RSC hydration, or proactive prefetching.
136
- */
137
121
  prefetchEndpoint: <TResponse, TParams, TBody>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>) => Promise<void>;
138
- /**
139
- * Manually update the cache for a specific endpoint.
140
- * Often used for optimistic updates in mutations.
141
- */
142
122
  setEndpointData: <TResponse, TParams, TBody>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options: EndpointCallableOptions<TParams, TBody> | undefined, updater: TResponse | ((oldData: TResponse | undefined) => TResponse)) => unknown;
143
- /**
144
- * Retrieve the current cached data for a specific endpoint.
145
- */
146
123
  getEndpointData: <TResponse, TParams, TBody>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>) => TResponse | undefined;
147
124
  };
148
125
 
package/dist/react.d.ts CHANGED
@@ -45,6 +45,12 @@ interface RouteDefinition<TResponse = unknown, TParams = unknown, TBody = unknow
45
45
  _typeBody?: TBody;
46
46
  }
47
47
 
48
+ type CallOptions<TParams = unknown, TBody = unknown> = {
49
+ params?: TParams;
50
+ query?: Record<string, any>;
51
+ body?: TBody;
52
+ headers?: Record<string, string>;
53
+ };
48
54
  type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {} : {
49
55
  params: TParams;
50
56
  }) & (unknown extends TBody ? {
@@ -55,7 +61,10 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {} : {
55
61
  query?: Record<string, any>;
56
62
  headers?: Record<string, string>;
57
63
  };
58
- type OptionalIfEmpty<T> = keyof Omit<T, 'query' | 'headers'> extends never ? [options?: T] : [options: T];
64
+ type RequiredKeys<T> = {
65
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
66
+ }[keyof T];
67
+ type OptionalIfEmpty<T> = RequiredKeys<Omit<T, 'query' | 'headers'>> extends never ? [options?: T] : [options: T];
59
68
  interface ApiError {
60
69
  message: string;
61
70
  status?: number;
@@ -63,36 +72,25 @@ interface ApiError {
63
72
  }
64
73
  interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unknown> {
65
74
  (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>): Promise<TResponse>;
75
+ (options: EndpointCallableOptions<TParams, TBody> | undefined): Promise<TResponse>;
76
+ (options: CallOptions<TParams, TBody>): Promise<TResponse>;
66
77
  /** Original RouteDefinition — used by useApiQuery / useApiMutation */
67
78
  $def: RouteDefinition<TResponse, TParams, TBody>;
68
79
  /** Stable TanStack query key: [group, action] */
69
80
  $key: string[];
70
81
  /** Consistent query key builder that incorporates params/query if provided */
71
- $queryKey: (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>) => unknown[];
82
+ $queryKey: (options?: EndpointCallableOptions<TParams, TBody>) => unknown[];
72
83
  }
73
84
 
74
- /**
75
- * useApiQuery — accepts an endpoint callable directly.
76
- *
77
- * Usage:
78
- * const { data, isLoading } = useApiQuery(api.produk.list)
79
- * const { data } = useApiQuery(api.produk.detail, { params: { id: 10 } })
80
- */
81
85
  type ApiQueryOptions<TResponse, TError = ApiError, TData = TResponse> = Omit<UseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>;
82
86
  declare function useApiQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, ...args: [
83
87
  ...OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>,
84
- queryOptions?: Omit<UseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>
88
+ queryOptions?: ApiQueryOptions<TResponse, TError, TData>
85
89
  ]): _tanstack_react_query.UseQueryResult<NoInfer<TData>, TError>;
86
- /**
87
- * useApiSuspenseQuery — generic wrapper for Suspense-enabled data fetching (TanStack v5).
88
- */
89
90
  declare function useApiSuspenseQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = TResponse>(endpoint: EndpointCallable<TResponse, TParams, TBody>, ...args: [
90
91
  ...OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>,
91
92
  queryOptions?: Omit<UseSuspenseQueryOptions<TResponse, TError, TData>, 'queryKey' | 'queryFn'>
92
93
  ]): _tanstack_react_query.UseSuspenseQueryResult<TData, TError>;
93
- /**
94
- * useApiInfiniteQuery — framework agnostic paginated fetching.
95
- */
96
94
  declare function useApiInfiniteQuery<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TData = InfiniteData<TResponse>, TPageParam = unknown>(endpoint: EndpointCallable<TResponse, TParams, TBody>, ...args: [
97
95
  ...OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>,
98
96
  queryOptions: Omit<UseInfiniteQueryOptions<TResponse, TError, TData, any, TPageParam>, 'queryKey' | 'queryFn'>
@@ -117,32 +115,11 @@ interface ApiMutationOptions<TData, TError, TVariables, TContext = unknown> exte
117
115
  }
118
116
  declare function useApiMutation<TResponse = unknown, TParams = unknown, TBody = unknown, TError = ApiError, TContext = unknown>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: ApiMutationOptions<TResponse, TError, EndpointCallableOptions<TParams, TBody>, TContext>): _tanstack_react_query.UseMutationResult<TResponse, TError, EndpointCallableOptions<TParams, TBody>, TContext>;
119
117
 
120
- /**
121
- * useApiQueryClient — a typed wrapper over TanStack's QueryClient
122
- *
123
- * Provides ergonomic helpers like invalidateEndpoint and prefetchEndpoint
124
- * with strong typing based on the RouteSync SDK contracts.
125
- */
126
118
  declare function useApiQueryClient(): {
127
119
  queryClient: QueryClient;
128
- /**
129
- * Invalidate specific queries related to an endpoint.
130
- * Optionally pass parameters to invalidate a more specific cache entry.
131
- */
132
120
  invalidateEndpoint: <TResponse, TParams, TBody>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>) => Promise<void>;
133
- /**
134
- * Prefetch data for an endpoint into the cache.
135
- * Useful for SSR, RSC hydration, or proactive prefetching.
136
- */
137
121
  prefetchEndpoint: <TResponse, TParams, TBody>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>) => Promise<void>;
138
- /**
139
- * Manually update the cache for a specific endpoint.
140
- * Often used for optimistic updates in mutations.
141
- */
142
122
  setEndpointData: <TResponse, TParams, TBody>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options: EndpointCallableOptions<TParams, TBody> | undefined, updater: TResponse | ((oldData: TResponse | undefined) => TResponse)) => unknown;
143
- /**
144
- * Retrieve the current cached data for a specific endpoint.
145
- */
146
123
  getEndpointData: <TResponse, TParams, TBody>(endpoint: EndpointCallable<TResponse, TParams, TBody>, options?: EndpointCallableOptions<TParams, TBody>) => TResponse | undefined;
147
124
  };
148
125
 
package/dist/react.js CHANGED
@@ -59,11 +59,11 @@ function useApiInfiniteQuery(endpoint, ...args) {
59
59
  return (0, import_react_query.useInfiniteQuery)({
60
60
  queryKey,
61
61
  queryFn: ({ pageParam }) => {
62
- const fetchOptions = { ...options };
63
- if (pageParam !== void 0) {
64
- fetchOptions.query = { ...fetchOptions.query || {}, page: pageParam };
65
- }
66
- return endpoint(fetchOptions);
62
+ const callOptions = {
63
+ ...options,
64
+ query: { ...options?.query, page: pageParam }
65
+ };
66
+ return endpoint(callOptions);
67
67
  },
68
68
  ...queryOptions
69
69
  });
@@ -93,35 +93,20 @@ function useApiQueryClient() {
93
93
  const queryClient = (0, import_react_query3.useQueryClient)();
94
94
  return {
95
95
  queryClient,
96
- /**
97
- * Invalidate specific queries related to an endpoint.
98
- * Optionally pass parameters to invalidate a more specific cache entry.
99
- */
100
96
  invalidateEndpoint: (endpoint, options) => {
101
97
  return queryClient.invalidateQueries({
102
98
  queryKey: endpoint.$queryKey(options)
103
99
  });
104
100
  },
105
- /**
106
- * Prefetch data for an endpoint into the cache.
107
- * Useful for SSR, RSC hydration, or proactive prefetching.
108
- */
109
101
  prefetchEndpoint: (endpoint, options) => {
110
102
  return queryClient.prefetchQuery({
111
103
  queryKey: endpoint.$queryKey(options),
112
104
  queryFn: () => endpoint(options)
113
105
  });
114
106
  },
115
- /**
116
- * Manually update the cache for a specific endpoint.
117
- * Often used for optimistic updates in mutations.
118
- */
119
107
  setEndpointData: (endpoint, options, updater) => {
120
108
  return queryClient.setQueryData(endpoint.$queryKey(options), updater);
121
109
  },
122
- /**
123
- * Retrieve the current cached data for a specific endpoint.
124
- */
125
110
  getEndpointData: (endpoint, options) => {
126
111
  return queryClient.getQueryData(endpoint.$queryKey(options));
127
112
  }
package/dist/react.mjs CHANGED
@@ -27,11 +27,11 @@ function useApiInfiniteQuery(endpoint, ...args) {
27
27
  return useInfiniteQuery({
28
28
  queryKey,
29
29
  queryFn: ({ pageParam }) => {
30
- const fetchOptions = { ...options };
31
- if (pageParam !== void 0) {
32
- fetchOptions.query = { ...fetchOptions.query || {}, page: pageParam };
33
- }
34
- return endpoint(fetchOptions);
30
+ const callOptions = {
31
+ ...options,
32
+ query: { ...options?.query, page: pageParam }
33
+ };
34
+ return endpoint(callOptions);
35
35
  },
36
36
  ...queryOptions
37
37
  });
@@ -61,35 +61,20 @@ function useApiQueryClient() {
61
61
  const queryClient = useQueryClient2();
62
62
  return {
63
63
  queryClient,
64
- /**
65
- * Invalidate specific queries related to an endpoint.
66
- * Optionally pass parameters to invalidate a more specific cache entry.
67
- */
68
64
  invalidateEndpoint: (endpoint, options) => {
69
65
  return queryClient.invalidateQueries({
70
66
  queryKey: endpoint.$queryKey(options)
71
67
  });
72
68
  },
73
- /**
74
- * Prefetch data for an endpoint into the cache.
75
- * Useful for SSR, RSC hydration, or proactive prefetching.
76
- */
77
69
  prefetchEndpoint: (endpoint, options) => {
78
70
  return queryClient.prefetchQuery({
79
71
  queryKey: endpoint.$queryKey(options),
80
72
  queryFn: () => endpoint(options)
81
73
  });
82
74
  },
83
- /**
84
- * Manually update the cache for a specific endpoint.
85
- * Often used for optimistic updates in mutations.
86
- */
87
75
  setEndpointData: (endpoint, options, updater) => {
88
76
  return queryClient.setQueryData(endpoint.$queryKey(options), updater);
89
77
  },
90
- /**
91
- * Retrieve the current cached data for a specific endpoint.
92
- */
93
78
  getEndpointData: (endpoint, options) => {
94
79
  return queryClient.getQueryData(endpoint.$queryKey(options));
95
80
  }
package/dist/sdk.d.mts CHANGED
@@ -131,7 +131,10 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {} : {
131
131
  query?: Record<string, any>;
132
132
  headers?: Record<string, string>;
133
133
  };
134
- type OptionalIfEmpty<T> = keyof Omit<T, 'query' | 'headers'> extends never ? [options?: T] : [options: T];
134
+ type RequiredKeys<T> = {
135
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
136
+ }[keyof T];
137
+ type OptionalIfEmpty<T> = RequiredKeys<Omit<T, 'query' | 'headers'>> extends never ? [options?: T] : [options: T];
135
138
  interface ApiError {
136
139
  message: string;
137
140
  status?: number;
@@ -139,12 +142,14 @@ interface ApiError {
139
142
  }
140
143
  interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unknown> {
141
144
  (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>): Promise<TResponse>;
145
+ (options: EndpointCallableOptions<TParams, TBody> | undefined): Promise<TResponse>;
146
+ (options: CallOptions<TParams, TBody>): Promise<TResponse>;
142
147
  /** Original RouteDefinition — used by useApiQuery / useApiMutation */
143
148
  $def: RouteDefinition<TResponse, TParams, TBody>;
144
149
  /** Stable TanStack query key: [group, action] */
145
150
  $key: string[];
146
151
  /** Consistent query key builder that incorporates params/query if provided */
147
- $queryKey: (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>) => unknown[];
152
+ $queryKey: (options?: EndpointCallableOptions<TParams, TBody>) => unknown[];
148
153
  }
149
154
  type ApiGroupProxy<G extends Record<string, RouteDefinition<any, any, any>>> = {
150
155
  [K in keyof G]: EndpointCallable<G[K] extends RouteDefinition<infer R, any, any> ? R : unknown, G[K] extends RouteDefinition<any, infer P, any> ? P : unknown, G[K] extends RouteDefinition<any, any, infer B> ? B : unknown>;
package/dist/sdk.d.ts CHANGED
@@ -131,7 +131,10 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {} : {
131
131
  query?: Record<string, any>;
132
132
  headers?: Record<string, string>;
133
133
  };
134
- type OptionalIfEmpty<T> = keyof Omit<T, 'query' | 'headers'> extends never ? [options?: T] : [options: T];
134
+ type RequiredKeys<T> = {
135
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
136
+ }[keyof T];
137
+ type OptionalIfEmpty<T> = RequiredKeys<Omit<T, 'query' | 'headers'>> extends never ? [options?: T] : [options: T];
135
138
  interface ApiError {
136
139
  message: string;
137
140
  status?: number;
@@ -139,12 +142,14 @@ interface ApiError {
139
142
  }
140
143
  interface EndpointCallable<TResponse = unknown, TParams = unknown, TBody = unknown> {
141
144
  (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>): Promise<TResponse>;
145
+ (options: EndpointCallableOptions<TParams, TBody> | undefined): Promise<TResponse>;
146
+ (options: CallOptions<TParams, TBody>): Promise<TResponse>;
142
147
  /** Original RouteDefinition — used by useApiQuery / useApiMutation */
143
148
  $def: RouteDefinition<TResponse, TParams, TBody>;
144
149
  /** Stable TanStack query key: [group, action] */
145
150
  $key: string[];
146
151
  /** Consistent query key builder that incorporates params/query if provided */
147
- $queryKey: (...args: OptionalIfEmpty<EndpointCallableOptions<TParams, TBody>>) => unknown[];
152
+ $queryKey: (options?: EndpointCallableOptions<TParams, TBody>) => unknown[];
148
153
  }
149
154
  type ApiGroupProxy<G extends Record<string, RouteDefinition<any, any, any>>> = {
150
155
  [K in keyof G]: EndpointCallable<G[K] extends RouteDefinition<infer R, any, any> ? R : unknown, G[K] extends RouteDefinition<any, infer P, any> ? P : unknown, G[K] extends RouteDefinition<any, any, infer B> ? B : unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routesync",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "Laravel routes to typed frontend SDKs.",
5
5
  "main": "./dist/sdk.js",
6
6
  "module": "./dist/sdk.mjs",