routesync 1.0.4 → 1.0.6
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 +20 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8451,7 +8451,7 @@ if ($extractModels) {
|
|
|
8451
8451
|
foreach ($columns as $col) {
|
|
8452
8452
|
$parsedColumns[] = [
|
|
8453
8453
|
'name' => $col['name'],
|
|
8454
|
-
'type' => $col['
|
|
8454
|
+
'type' => $col['type'], // Use 'type' which contains the raw type like enum('a','b') instead of 'type_name'
|
|
8455
8455
|
'nullable' => $col['nullable']
|
|
8456
8456
|
];
|
|
8457
8457
|
}
|
|
@@ -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(``);
|
|
@@ -8831,7 +8831,7 @@ var MswGenerator = class {
|
|
|
8831
8831
|
const mswMethod = route.method.toLowerCase();
|
|
8832
8832
|
const mswPath = manifest.baseURL + route.path.replace(/\{([^}]+)\}/g, ":$1");
|
|
8833
8833
|
const actionName = toMethodName(route);
|
|
8834
|
-
lines.push(" http." + mswMethod + "('" + mswPath + "', async ({ request, params }) => {");
|
|
8834
|
+
lines.push(" http." + mswMethod + "('" + mswPath + "', async ({ request: _request, params: _params }) => {");
|
|
8835
8835
|
lines.push(` await delay(300) // Simulated network latency`);
|
|
8836
8836
|
lines.push(` return HttpResponse.json({`);
|
|
8837
8837
|
lines.push(` success: true,`);
|
|
@@ -8864,11 +8864,11 @@ var EchoGenerator = class {
|
|
|
8864
8864
|
const params = [...channel.name.matchAll(/\\{([^}]+)\\}/g)].map((m) => m[1]);
|
|
8865
8865
|
const paramArgs = params.length > 0 ? params.map((p) => p + ": string | number").join(", ") + ", " : "";
|
|
8866
8866
|
const runtimeChannelName = channel.name.replace(/\\{([^}]+)\\}/g, "${$1}");
|
|
8867
|
-
lines.push("export function " + hookName + "(" + paramArgs + "eventName: string, callback: (event:
|
|
8867
|
+
lines.push("export function " + hookName + "(" + paramArgs + "eventName: string, callback: (event: unknown) => void) {");
|
|
8868
8868
|
lines.push(` useEffect(() => {`);
|
|
8869
|
-
lines.push(` if (typeof window === 'undefined' || !(window as
|
|
8869
|
+
lines.push(` if (typeof window === 'undefined' || !(window as unknown as { Echo?: Echo }).Echo) return`);
|
|
8870
8870
|
lines.push(` `);
|
|
8871
|
-
lines.push(` const echo: Echo = (window as
|
|
8871
|
+
lines.push(` const echo: Echo = (window as unknown as { Echo: Echo }).Echo`);
|
|
8872
8872
|
const channelMethod = channel.isPrivate ? "private" : "channel";
|
|
8873
8873
|
lines.push(" const channelInstance = echo." + channelMethod + "(`" + runtimeChannelName + "`)");
|
|
8874
8874
|
lines.push(` channelInstance.listen(eventName, callback)`);
|
|
@@ -8934,7 +8934,7 @@ var ModelGenerator = class {
|
|
|
8934
8934
|
}
|
|
8935
8935
|
const appends = Array.isArray(model.appends) ? model.appends : [];
|
|
8936
8936
|
for (const append of appends) {
|
|
8937
|
-
lines.push(` ${append}:
|
|
8937
|
+
lines.push(` ${append}: unknown // appended attribute`);
|
|
8938
8938
|
}
|
|
8939
8939
|
lines.push(`}`);
|
|
8940
8940
|
lines.push(``);
|
|
@@ -8950,7 +8950,12 @@ var ModelGenerator = class {
|
|
|
8950
8950
|
return "boolean";
|
|
8951
8951
|
}
|
|
8952
8952
|
if (type.includes("json")) {
|
|
8953
|
-
return "
|
|
8953
|
+
return "Record<string, unknown>";
|
|
8954
|
+
}
|
|
8955
|
+
const enumMatch = type.match(/^enum\((.*)\)$/);
|
|
8956
|
+
if (enumMatch && enumMatch[1]) {
|
|
8957
|
+
const values = enumMatch[1].split(",").map((v) => v.trim().replace(/^'|'$/g, ""));
|
|
8958
|
+
return values.map((v) => `'${v}'`).join(" | ");
|
|
8954
8959
|
}
|
|
8955
8960
|
return "string";
|
|
8956
8961
|
}
|
|
@@ -8963,7 +8968,7 @@ var ModelGenerator = class {
|
|
|
8963
8968
|
return "boolean";
|
|
8964
8969
|
}
|
|
8965
8970
|
if (type.includes("array") || type.includes("json") || type.includes("collection") || type.includes("object")) {
|
|
8966
|
-
return "
|
|
8971
|
+
return "Record<string, unknown>";
|
|
8967
8972
|
}
|
|
8968
8973
|
if (type.includes("date") || type.includes("datetime") || type.includes("string")) {
|
|
8969
8974
|
return "string";
|