routesync 1.0.27 → 1.0.29

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
@@ -55,7 +55,10 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {} : {
55
55
  query?: Record<string, any>;
56
56
  headers?: Record<string, string>;
57
57
  };
58
- type OptionalIfEmpty<T> = keyof Omit<T, 'query' | 'headers'> extends never ? [options?: T] : [options: T];
58
+ type RequiredKeys<T> = {
59
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
60
+ }[keyof T];
61
+ type OptionalIfEmpty<T> = RequiredKeys<Omit<T, 'query' | 'headers'>> extends never ? [options?: T] : [options: T];
59
62
  interface ApiError {
60
63
  message: string;
61
64
  status?: number;
package/dist/react.d.ts CHANGED
@@ -55,7 +55,10 @@ type EndpointCallableOptions<TParams, TBody> = (unknown extends TParams ? {} : {
55
55
  query?: Record<string, any>;
56
56
  headers?: Record<string, string>;
57
57
  };
58
- type OptionalIfEmpty<T> = keyof Omit<T, 'query' | 'headers'> extends never ? [options?: T] : [options: T];
58
+ type RequiredKeys<T> = {
59
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
60
+ }[keyof T];
61
+ type OptionalIfEmpty<T> = RequiredKeys<Omit<T, 'query' | 'headers'>> extends never ? [options?: T] : [options: T];
59
62
  interface ApiError {
60
63
  message: string;
61
64
  status?: number;
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;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routesync",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Laravel routes to typed frontend SDKs.",
5
5
  "main": "./dist/sdk.js",
6
6
  "module": "./dist/sdk.mjs",