atmx-cli 0.56.0 → 0.57.0

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.
@@ -59,6 +59,7 @@ function generateSdk(multiIr, isReact = false) {
59
59
  lines.push(`};\n`);
60
60
  return lines.join("\n");
61
61
  }
62
+ // FILE: atmx-cli/src/generators/sdk-generator.ts (Partial replacement)
62
63
  function generateEndpointMethod(ep, ns, camelNs, isReact) {
63
64
  const rawParams = ep.parameters || [];
64
65
  const params = Array.isArray(rawParams)
@@ -69,8 +70,10 @@ function generateEndpointMethod(ep, ns, camelNs, isReact) {
69
70
  const returnType = rawReturnType === "void" || rawReturnType === "any"
70
71
  ? rawReturnType
71
72
  : prefixModels(rawReturnType);
72
- // FIX: If no parameters are defined, default to accepting an optional Record<string, any>
73
- // This allows developers to pass undocumented fields (like FastAPI Form data)
73
+ // Map camelCase TS args back to original IR snake_case names!
74
+ const argsMapping = params
75
+ .map((p) => `if (args && '${(0, utils_1.camelCase)(p.name)}' in args) { mappedArgs["${p.name}"] = (args as any)["${(0, utils_1.camelCase)(p.name)}"]; delete mappedArgs["${(0, utils_1.camelCase)(p.name)}"]; }`)
76
+ .join("\n ");
74
77
  if (params.length === 0) {
75
78
  if (isReact) {
76
79
  const decLogic = generateLambda(ep.returnType, "fromJson", camelNs);
@@ -94,7 +97,6 @@ function generateEndpointMethod(ep, ns, camelNs, isReact) {
94
97
  },`;
95
98
  }
96
99
  }
97
- // Endpoints with explicitly defined parameters
98
100
  const argType = `{ ${params.map((p) => `${(0, utils_1.camelCase)(p.name)}${p.isOptional ? "?" : ""}: ${prefixModels((0, utils_1.mapTypeToTs)(p.typeRef, camelNs))}`).join(", ")} }`;
99
101
  if (isReact) {
100
102
  const bodyParam = params.find((p) => p.source === "body");
@@ -108,10 +110,13 @@ function generateEndpointMethod(ep, ns, camelNs, isReact) {
108
110
  return `
109
111
  get${(0, utils_1.pascalCase)(ep.name)}Def(args?: ${argType}): AxiomQueryDef<${returnType}> {
110
112
  ${payloadLogic}
113
+ const mappedArgs: any = { ...(args || {}) };
114
+ ${argsMapping}
115
+
111
116
  return {
112
117
  namespace: "${ns}", name: "${ep.name}", endpointId: ${ep.id},
113
118
  method: "${ep.method ? ep.method.toUpperCase() : "GET"}", path: "${ep.path}",
114
- payload: payload, args: args || {}, decoder: ${decLogic}, serializer: ${serLogic}, isStream: ${ep.isStream === true}
119
+ payload: payload, args: mappedArgs, decoder: ${decLogic}, serializer: ${serLogic}, isStream: ${ep.isStream === true}
115
120
  };
116
121
  },
117
122
  use${(0, utils_1.pascalCase)(ep.name)}${!isQuery ? "Mutation" : ""}(args?: ${argType}, options?: { enabled?: boolean }) {
@@ -121,7 +126,9 @@ function generateEndpointMethod(ep, ns, camelNs, isReact) {
121
126
  else {
122
127
  return `
123
128
  ${(0, utils_1.camelCase)(ep.name)}(args?: ${argType}): string {
124
- const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
129
+ const mappedArgs: any = { ...(args || {}) };
130
+ ${argsMapping}
131
+ const argsStr = Object.keys(mappedArgs).length > 0 ? JSON.stringify(mappedArgs) : '';
125
132
  return \`${ns}.${ep.name}(\${argsStr})\`;
126
133
  },`;
127
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atmx-cli",
3
- "version": "0.56.0",
3
+ "version": "0.57.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -76,6 +76,8 @@ export function generateSdk(
76
76
  return lines.join("\n");
77
77
  }
78
78
 
79
+ // FILE: atmx-cli/src/generators/sdk-generator.ts (Partial replacement)
80
+
79
81
  function generateEndpointMethod(
80
82
  ep: AxiomEndpoint,
81
83
  ns: string,
@@ -94,8 +96,14 @@ function generateEndpointMethod(
94
96
  ? rawReturnType
95
97
  : prefixModels(rawReturnType);
96
98
 
97
- // FIX: If no parameters are defined, default to accepting an optional Record<string, any>
98
- // This allows developers to pass undocumented fields (like FastAPI Form data)
99
+ // Map camelCase TS args back to original IR snake_case names!
100
+ const argsMapping = params
101
+ .map(
102
+ (p: any) =>
103
+ `if (args && '${camelCase(p.name)}' in args) { mappedArgs["${p.name}"] = (args as any)["${camelCase(p.name)}"]; delete mappedArgs["${camelCase(p.name)}"]; }`,
104
+ )
105
+ .join("\n ");
106
+
99
107
  if (params.length === 0) {
100
108
  if (isReact) {
101
109
  const decLogic = generateLambda(ep.returnType, "fromJson", camelNs);
@@ -119,7 +127,6 @@ function generateEndpointMethod(
119
127
  }
120
128
  }
121
129
 
122
- // Endpoints with explicitly defined parameters
123
130
  const argType = `{ ${params.map((p: any) => `${camelCase(p.name)}${p.isOptional ? "?" : ""}: ${prefixModels(mapTypeToTs(p.typeRef, camelNs))}`).join(", ")} }`;
124
131
 
125
132
  if (isReact) {
@@ -137,10 +144,13 @@ function generateEndpointMethod(
137
144
  return `
138
145
  get${pascalCase(ep.name)}Def(args?: ${argType}): AxiomQueryDef<${returnType}> {
139
146
  ${payloadLogic}
147
+ const mappedArgs: any = { ...(args || {}) };
148
+ ${argsMapping}
149
+
140
150
  return {
141
151
  namespace: "${ns}", name: "${ep.name}", endpointId: ${ep.id},
142
152
  method: "${ep.method ? ep.method.toUpperCase() : "GET"}", path: "${ep.path}",
143
- payload: payload, args: args || {}, decoder: ${decLogic}, serializer: ${serLogic}, isStream: ${ep.isStream === true}
153
+ payload: payload, args: mappedArgs, decoder: ${decLogic}, serializer: ${serLogic}, isStream: ${ep.isStream === true}
144
154
  };
145
155
  },
146
156
  use${pascalCase(ep.name)}${!isQuery ? "Mutation" : ""}(args?: ${argType}, options?: { enabled?: boolean }) {
@@ -149,7 +159,9 @@ function generateEndpointMethod(
149
159
  } else {
150
160
  return `
151
161
  ${camelCase(ep.name)}(args?: ${argType}): string {
152
- const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
162
+ const mappedArgs: any = { ...(args || {}) };
163
+ ${argsMapping}
164
+ const argsStr = Object.keys(mappedArgs).length > 0 ? JSON.stringify(mappedArgs) : '';
153
165
  return \`${ns}.${ep.name}(\${argsStr})\`;
154
166
  },`;
155
167
  }