routesync 1.0.16 → 1.0.17

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.
Files changed (2) hide show
  1. package/dist/cli.js +13 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -8800,10 +8800,19 @@ var TypeGenerator = class {
8800
8800
  }
8801
8801
  }
8802
8802
  if (hasSchemas) {
8803
+ const generatedSchemas = /* @__PURE__ */ new Map();
8803
8804
  for (const route of manifest.routes) {
8804
8805
  if (route.schema && route.schema.rules && Object.keys(route.schema.rules).length > 0) {
8805
- const actionName = toMethodName(route);
8806
- const schemaName = actionName + "Schema";
8806
+ let actionName = toMethodName(route);
8807
+ let schemaName = actionName + "Schema";
8808
+ if (generatedSchemas.has(schemaName)) {
8809
+ const count = generatedSchemas.get(schemaName) + 1;
8810
+ generatedSchemas.set(schemaName, count);
8811
+ actionName = actionName + String(count);
8812
+ schemaName = actionName + "Schema";
8813
+ } else {
8814
+ generatedSchemas.set(schemaName, 1);
8815
+ }
8807
8816
  lines.push(`export const ${schemaName} = z.object({`);
8808
8817
  for (const [field, rules] of Object.entries(route.schema.rules)) {
8809
8818
  const ruleStr = Array.isArray(rules) ? rules.join("|") : String(rules);
@@ -8827,7 +8836,8 @@ var TypeGenerator = class {
8827
8836
  if (ruleStr.includes("nullable")) {
8828
8837
  zodRule += ".nullable()";
8829
8838
  }
8830
- lines.push(` ${field}: ${zodRule},`);
8839
+ const safeField = field.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/) ? field : `"${field}"`;
8840
+ lines.push(` ${safeField}: ${zodRule},`);
8831
8841
  }
8832
8842
  lines.push(`})`);
8833
8843
  lines.push(`export type ${toTypeName(actionName + "Payload")} = z.infer<typeof ${schemaName}>`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routesync",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Laravel routes to typed frontend SDKs.",
5
5
  "main": "./dist/sdk.js",
6
6
  "module": "./dist/sdk.mjs",