routesync 1.0.7 → 1.0.9
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 +26 -23
- package/dist/react.d.mts +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/sdk.d.mts +1 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +1 -1
- package/dist/sdk.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8722,7 +8722,7 @@ var TypeGenerator = class {
|
|
|
8722
8722
|
}
|
|
8723
8723
|
}
|
|
8724
8724
|
}
|
|
8725
|
-
await import_fs_extra4.default.writeFile(import_path3.default.join(outputDir, "types.ts"), lines.join("
|
|
8725
|
+
await import_fs_extra4.default.writeFile(import_path3.default.join(outputDir, "types.ts"), lines.join("\n"));
|
|
8726
8726
|
}
|
|
8727
8727
|
};
|
|
8728
8728
|
|
|
@@ -8755,7 +8755,7 @@ var HookGenerator = class _HookGenerator {
|
|
|
8755
8755
|
lines.push(`export function ${hookName}() {`);
|
|
8756
8756
|
lines.push(` const queryClient = useQueryClient()`);
|
|
8757
8757
|
lines.push(` return useMutation({`);
|
|
8758
|
-
lines.push(` mutationFn: (data: unknown) => api.${group}.${route.actionName}({ body: data }),`);
|
|
8758
|
+
lines.push(` mutationFn: (data: Record<string, unknown>) => api.${group}.${route.actionName}({ body: data }),`);
|
|
8759
8759
|
lines.push(` onSuccess: () => {`);
|
|
8760
8760
|
lines.push(` queryClient.invalidateQueries({ queryKey: ['${group}'] })`);
|
|
8761
8761
|
lines.push(` }`);
|
|
@@ -8791,27 +8791,30 @@ var NextActionGenerator = class {
|
|
|
8791
8791
|
lines.push(` return token ? { Authorization: \`Bearer \${token}\` } : {}`);
|
|
8792
8792
|
lines.push(`}`);
|
|
8793
8793
|
lines.push(``);
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
args
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8794
|
+
const grouped = buildGeneratedRoutes(manifest.routes);
|
|
8795
|
+
for (const [groupName, routes] of Object.entries(grouped)) {
|
|
8796
|
+
for (const route of routes) {
|
|
8797
|
+
const actionName = `${groupName}${toTypeName(route.actionName)}`;
|
|
8798
|
+
lines.push(`export async function ${actionName}Action(payload?: Record<string, unknown>) {`);
|
|
8799
|
+
const args = [];
|
|
8800
|
+
if (route.method === "GET") {
|
|
8801
|
+
args.push(`query: payload`);
|
|
8802
|
+
} else {
|
|
8803
|
+
args.push(`body: payload`);
|
|
8804
|
+
}
|
|
8805
|
+
if (route.auth) {
|
|
8806
|
+
args.push(`headers: await getAuthHeaders()`);
|
|
8807
|
+
}
|
|
8808
|
+
const apiCall = `await api.${groupName}.${route.actionName}({ ${args.join(", ")} })`;
|
|
8809
|
+
lines.push(` try {`);
|
|
8810
|
+
lines.push(` const response = ${apiCall}`);
|
|
8811
|
+
lines.push(` return { success: true, data: response.data }`);
|
|
8812
|
+
lines.push(` } catch (error: unknown) {`);
|
|
8813
|
+
lines.push(` return { success: false, error: error instanceof Error ? error.message : String(error) }`);
|
|
8814
|
+
lines.push(` }`);
|
|
8815
|
+
lines.push(`}`);
|
|
8816
|
+
lines.push(``);
|
|
8817
|
+
}
|
|
8815
8818
|
}
|
|
8816
8819
|
await import_fs_extra6.default.writeFile(import_path5.default.join(outputDir, "actions.ts"), lines.join("\n"));
|
|
8817
8820
|
}
|
package/dist/react.d.mts
CHANGED
package/dist/react.d.ts
CHANGED
package/dist/sdk.d.mts
CHANGED
package/dist/sdk.d.ts
CHANGED
package/dist/sdk.js
CHANGED
|
@@ -280,7 +280,7 @@ function defineApi(definition, config) {
|
|
|
280
280
|
);
|
|
281
281
|
const resolvedPath = PathResolver.resolve(route.path, params);
|
|
282
282
|
const method = route.method.toLowerCase();
|
|
283
|
-
const requestConfig = { params: query, headers: route.headers };
|
|
283
|
+
const requestConfig = { params: query, headers: { ...route.headers, ...options?.headers } };
|
|
284
284
|
let response;
|
|
285
285
|
if (method === "get" || method === "delete") {
|
|
286
286
|
response = await client[method](resolvedPath, requestConfig);
|
package/dist/sdk.mjs
CHANGED
|
@@ -238,7 +238,7 @@ function defineApi(definition, config) {
|
|
|
238
238
|
);
|
|
239
239
|
const resolvedPath = PathResolver.resolve(route.path, params);
|
|
240
240
|
const method = route.method.toLowerCase();
|
|
241
|
-
const requestConfig = { params: query, headers: route.headers };
|
|
241
|
+
const requestConfig = { params: query, headers: { ...route.headers, ...options?.headers } };
|
|
242
242
|
let response;
|
|
243
243
|
if (method === "get" || method === "delete") {
|
|
244
244
|
response = await client[method](resolvedPath, requestConfig);
|