routesync 1.0.5 → 1.0.7
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 +19 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8652,7 +8652,7 @@ var TypeGenerator = class {
|
|
|
8652
8652
|
lines.push(`import { z } from 'zod'`);
|
|
8653
8653
|
lines.push(``);
|
|
8654
8654
|
}
|
|
8655
|
-
lines.push(`export interface ApiResponse<T =
|
|
8655
|
+
lines.push(`export interface ApiResponse<T = unknown> {`);
|
|
8656
8656
|
lines.push(` success: boolean`);
|
|
8657
8657
|
lines.push(` message?: string`);
|
|
8658
8658
|
lines.push(` data: T`);
|
|
@@ -8700,7 +8700,7 @@ var TypeGenerator = class {
|
|
|
8700
8700
|
} else if (ruleStr.includes("boolean")) {
|
|
8701
8701
|
zodRule = "z.boolean()";
|
|
8702
8702
|
} else if (ruleStr.includes("array")) {
|
|
8703
|
-
zodRule = "z.array(z.
|
|
8703
|
+
zodRule = "z.array(z.unknown())";
|
|
8704
8704
|
}
|
|
8705
8705
|
if (ruleStr.includes("email")) zodRule += ".email()";
|
|
8706
8706
|
if (ruleStr.includes("url")) zodRule += ".url()";
|
|
@@ -8744,7 +8744,7 @@ var HookGenerator = class _HookGenerator {
|
|
|
8744
8744
|
const hookName = _HookGenerator.toHookName(group, route.actionName);
|
|
8745
8745
|
const queryKey = `['${group}', '${route.actionName}']`;
|
|
8746
8746
|
if (method === "GET") {
|
|
8747
|
-
lines.push(`export function ${hookName}(params?: Record<string,
|
|
8747
|
+
lines.push(`export function ${hookName}(params?: Record<string, unknown>) {`);
|
|
8748
8748
|
lines.push(` return useQuery({`);
|
|
8749
8749
|
lines.push(` queryKey: ${queryKey},`);
|
|
8750
8750
|
lines.push(` queryFn: () => api.${group}.${route.actionName}({ query: params })`);
|
|
@@ -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:
|
|
8758
|
+
lines.push(` mutationFn: (data: unknown) => api.${group}.${route.actionName}({ body: data }),`);
|
|
8759
8759
|
lines.push(` onSuccess: () => {`);
|
|
8760
8760
|
lines.push(` queryClient.invalidateQueries({ queryKey: ['${group}'] })`);
|
|
8761
8761
|
lines.push(` }`);
|
|
@@ -8793,7 +8793,7 @@ var NextActionGenerator = class {
|
|
|
8793
8793
|
lines.push(``);
|
|
8794
8794
|
for (const route of manifest.routes) {
|
|
8795
8795
|
const actionName = toMethodName(route);
|
|
8796
|
-
lines.push(`export async function ${actionName}Action(payload?:
|
|
8796
|
+
lines.push(`export async function ${actionName}Action(payload?: unknown) {`);
|
|
8797
8797
|
const args = [];
|
|
8798
8798
|
if (route.method === "GET") {
|
|
8799
8799
|
args.push(`query: payload`);
|
|
@@ -8807,8 +8807,8 @@ var NextActionGenerator = class {
|
|
|
8807
8807
|
lines.push(` try {`);
|
|
8808
8808
|
lines.push(` const response = ${apiCall}`);
|
|
8809
8809
|
lines.push(` return { success: true, data: response.data }`);
|
|
8810
|
-
lines.push(` } catch (error:
|
|
8811
|
-
lines.push(` return { success: false, error: error.message }`);
|
|
8810
|
+
lines.push(` } catch (error: unknown) {`);
|
|
8811
|
+
lines.push(` return { success: false, error: error instanceof Error ? error.message : String(error) }`);
|
|
8812
8812
|
lines.push(` }`);
|
|
8813
8813
|
lines.push(`}`);
|
|
8814
8814
|
lines.push(``);
|
|
@@ -8833,10 +8833,14 @@ var MswGenerator = class {
|
|
|
8833
8833
|
const actionName = toMethodName(route);
|
|
8834
8834
|
lines.push(" http." + mswMethod + "('" + mswPath + "', async ({ request, params }) => {");
|
|
8835
8835
|
lines.push(` await delay(300) // Simulated network latency`);
|
|
8836
|
+
lines.push(` const url = new URL(request.url)`);
|
|
8836
8837
|
lines.push(` return HttpResponse.json({`);
|
|
8837
8838
|
lines.push(` success: true,`);
|
|
8838
|
-
lines.push(` message: 'Mocked response for ${actionName}',`);
|
|
8839
|
-
lines.push(` data: {
|
|
8839
|
+
lines.push(` message: 'Mocked response for ${actionName} at ' + url.pathname,`);
|
|
8840
|
+
lines.push(` data: {`);
|
|
8841
|
+
lines.push(` params,`);
|
|
8842
|
+
lines.push(` // TODO: Add mock data based on your schema`);
|
|
8843
|
+
lines.push(` }`);
|
|
8840
8844
|
lines.push(` })`);
|
|
8841
8845
|
lines.push(` }),`);
|
|
8842
8846
|
}
|
|
@@ -8864,11 +8868,11 @@ var EchoGenerator = class {
|
|
|
8864
8868
|
const params = [...channel.name.matchAll(/\\{([^}]+)\\}/g)].map((m) => m[1]);
|
|
8865
8869
|
const paramArgs = params.length > 0 ? params.map((p) => p + ": string | number").join(", ") + ", " : "";
|
|
8866
8870
|
const runtimeChannelName = channel.name.replace(/\\{([^}]+)\\}/g, "${$1}");
|
|
8867
|
-
lines.push("export function " + hookName + "(" + paramArgs + "eventName: string, callback: (event:
|
|
8871
|
+
lines.push("export function " + hookName + "(" + paramArgs + "eventName: string, callback: (event: unknown) => void) {");
|
|
8868
8872
|
lines.push(` useEffect(() => {`);
|
|
8869
|
-
lines.push(` if (typeof window === 'undefined' || !(window as
|
|
8873
|
+
lines.push(` if (typeof window === 'undefined' || !(window as unknown as { Echo?: Echo }).Echo) return`);
|
|
8870
8874
|
lines.push(` `);
|
|
8871
|
-
lines.push(` const echo: Echo = (window as
|
|
8875
|
+
lines.push(` const echo: Echo = (window as unknown as { Echo: Echo }).Echo`);
|
|
8872
8876
|
const channelMethod = channel.isPrivate ? "private" : "channel";
|
|
8873
8877
|
lines.push(" const channelInstance = echo." + channelMethod + "(`" + runtimeChannelName + "`)");
|
|
8874
8878
|
lines.push(` channelInstance.listen(eventName, callback)`);
|
|
@@ -8934,7 +8938,7 @@ var ModelGenerator = class {
|
|
|
8934
8938
|
}
|
|
8935
8939
|
const appends = Array.isArray(model.appends) ? model.appends : [];
|
|
8936
8940
|
for (const append of appends) {
|
|
8937
|
-
lines.push(` ${append}:
|
|
8941
|
+
lines.push(` ${append}: unknown // appended attribute`);
|
|
8938
8942
|
}
|
|
8939
8943
|
lines.push(`}`);
|
|
8940
8944
|
lines.push(``);
|
|
@@ -8950,7 +8954,7 @@ var ModelGenerator = class {
|
|
|
8950
8954
|
return "boolean";
|
|
8951
8955
|
}
|
|
8952
8956
|
if (type.includes("json")) {
|
|
8953
|
-
return "
|
|
8957
|
+
return "Record<string, unknown>";
|
|
8954
8958
|
}
|
|
8955
8959
|
const enumMatch = type.match(/^enum\((.*)\)$/);
|
|
8956
8960
|
if (enumMatch && enumMatch[1]) {
|
|
@@ -8968,7 +8972,7 @@ var ModelGenerator = class {
|
|
|
8968
8972
|
return "boolean";
|
|
8969
8973
|
}
|
|
8970
8974
|
if (type.includes("array") || type.includes("json") || type.includes("collection") || type.includes("object")) {
|
|
8971
|
-
return "
|
|
8975
|
+
return "Record<string, unknown>";
|
|
8972
8976
|
}
|
|
8973
8977
|
if (type.includes("date") || type.includes("datetime") || type.includes("string")) {
|
|
8974
8978
|
return "string";
|