atmx-cli 0.55.0 → 0.56.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.
@@ -64,39 +64,38 @@ function generateEndpointMethod(ep, ns, camelNs, isReact) {
64
64
  const params = Array.isArray(rawParams)
65
65
  ? rawParams
66
66
  : Object.values(rawParams);
67
+ const isQuery = ep.method ? ep.method.toUpperCase() === "GET" : true;
68
+ const rawReturnType = (0, utils_1.mapTypeToTs)(ep.returnType, camelNs);
69
+ const returnType = rawReturnType === "void" || rawReturnType === "any"
70
+ ? rawReturnType
71
+ : 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)
67
74
  if (params.length === 0) {
68
75
  if (isReact) {
69
- const isQuery = ep.method ? ep.method.toUpperCase() === "GET" : true;
70
- const rawReturnType = (0, utils_1.mapTypeToTs)(ep.returnType, camelNs);
71
- const returnType = rawReturnType === "void" || rawReturnType === "any"
72
- ? rawReturnType
73
- : prefixModels(rawReturnType);
74
76
  const decLogic = generateLambda(ep.returnType, "fromJson", camelNs);
75
77
  return `
76
- get${(0, utils_1.pascalCase)(ep.name)}Def(): AxiomQueryDef<${returnType}> {
78
+ get${(0, utils_1.pascalCase)(ep.name)}Def(args?: Record<string, any>): AxiomQueryDef<${returnType}> {
77
79
  return {
78
80
  namespace: "${ns}", name: "${ep.name}", endpointId: ${ep.id},
79
81
  method: "${ep.method ? ep.method.toUpperCase() : "GET"}", path: "${ep.path}",
80
- args: {}, decoder: ${decLogic}, serializer: (p: any) => p, isStream: ${ep.isStream === true}
82
+ args: args || {}, decoder: ${decLogic}, serializer: (p: any) => p, isStream: ${ep.isStream === true}
81
83
  };
82
84
  },
83
85
  use${(0, utils_1.pascalCase)(ep.name)}${!isQuery ? "Mutation" : ""}(options?: { enabled?: boolean }) {
84
- ${isQuery ? `return useAxiomQuery<${returnType}>(this.get${(0, utils_1.pascalCase)(ep.name)}Def(), options);` : `return useAxiomMutation<${returnType}, void | Record<string,any>>(() => this.get${(0, utils_1.pascalCase)(ep.name)}Def());`}
86
+ ${isQuery ? `return useAxiomQuery<${returnType}>(this.get${(0, utils_1.pascalCase)(ep.name)}Def(), options);` : `return useAxiomMutation<${returnType}, void | Record<string,any>>((a) => this.get${(0, utils_1.pascalCase)(ep.name)}Def(a));`}
85
87
  },`;
86
88
  }
87
89
  else {
88
90
  return `
89
- ${(0, utils_1.camelCase)(ep.name)}(): string {
90
- return \`${ns}.${ep.name}()\`;
91
+ ${(0, utils_1.camelCase)(ep.name)}(args?: Record<string, any>): string {
92
+ const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
93
+ return \`${ns}.${ep.name}(\${argsStr})\`;
91
94
  },`;
92
95
  }
93
96
  }
94
- const argType = `{ ${params.map((p) => `${(0, utils_1.camelCase)(p.name)}?: ${prefixModels((0, utils_1.mapTypeToTs)(p.typeRef, camelNs))}`).join(", ")} }`;
95
- const isQuery = ep.method ? ep.method.toUpperCase() === "GET" : true;
96
- const rawReturnType = (0, utils_1.mapTypeToTs)(ep.returnType, camelNs);
97
- const returnType = rawReturnType === "void" || rawReturnType === "any"
98
- ? rawReturnType
99
- : prefixModels(rawReturnType);
97
+ // Endpoints with explicitly defined parameters
98
+ const argType = `{ ${params.map((p) => `${(0, utils_1.camelCase)(p.name)}${p.isOptional ? "?" : ""}: ${prefixModels((0, utils_1.mapTypeToTs)(p.typeRef, camelNs))}`).join(", ")} }`;
100
99
  if (isReact) {
101
100
  const bodyParam = params.find((p) => p.source === "body");
102
101
  const payloadLogic = bodyParam
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atmx-cli",
3
- "version": "0.55.0",
3
+ "version": "0.56.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -87,41 +87,40 @@ function generateEndpointMethod(
87
87
  ? rawParams
88
88
  : Object.values(rawParams);
89
89
 
90
+ const isQuery = ep.method ? ep.method.toUpperCase() === "GET" : true;
91
+ const rawReturnType = mapTypeToTs(ep.returnType, camelNs);
92
+ const returnType =
93
+ rawReturnType === "void" || rawReturnType === "any"
94
+ ? rawReturnType
95
+ : prefixModels(rawReturnType);
96
+
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)
90
99
  if (params.length === 0) {
91
100
  if (isReact) {
92
- const isQuery = ep.method ? ep.method.toUpperCase() === "GET" : true;
93
- const rawReturnType = mapTypeToTs(ep.returnType, camelNs);
94
- const returnType =
95
- rawReturnType === "void" || rawReturnType === "any"
96
- ? rawReturnType
97
- : prefixModels(rawReturnType);
98
101
  const decLogic = generateLambda(ep.returnType, "fromJson", camelNs);
99
102
  return `
100
- get${pascalCase(ep.name)}Def(): AxiomQueryDef<${returnType}> {
103
+ get${pascalCase(ep.name)}Def(args?: Record<string, any>): AxiomQueryDef<${returnType}> {
101
104
  return {
102
105
  namespace: "${ns}", name: "${ep.name}", endpointId: ${ep.id},
103
106
  method: "${ep.method ? ep.method.toUpperCase() : "GET"}", path: "${ep.path}",
104
- args: {}, decoder: ${decLogic}, serializer: (p: any) => p, isStream: ${ep.isStream === true}
107
+ args: args || {}, decoder: ${decLogic}, serializer: (p: any) => p, isStream: ${ep.isStream === true}
105
108
  };
106
109
  },
107
110
  use${pascalCase(ep.name)}${!isQuery ? "Mutation" : ""}(options?: { enabled?: boolean }) {
108
- ${isQuery ? `return useAxiomQuery<${returnType}>(this.get${pascalCase(ep.name)}Def(), options);` : `return useAxiomMutation<${returnType}, void | Record<string,any>>(() => this.get${pascalCase(ep.name)}Def());`}
111
+ ${isQuery ? `return useAxiomQuery<${returnType}>(this.get${pascalCase(ep.name)}Def(), options);` : `return useAxiomMutation<${returnType}, void | Record<string,any>>((a) => this.get${pascalCase(ep.name)}Def(a));`}
109
112
  },`;
110
113
  } else {
111
114
  return `
112
- ${camelCase(ep.name)}(): string {
113
- return \`${ns}.${ep.name}()\`;
115
+ ${camelCase(ep.name)}(args?: Record<string, any>): string {
116
+ const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
117
+ return \`${ns}.${ep.name}(\${argsStr})\`;
114
118
  },`;
115
119
  }
116
120
  }
117
121
 
118
- const argType = `{ ${params.map((p: any) => `${camelCase(p.name)}?: ${prefixModels(mapTypeToTs(p.typeRef, camelNs))}`).join(", ")} }`;
119
- const isQuery = ep.method ? ep.method.toUpperCase() === "GET" : true;
120
- const rawReturnType = mapTypeToTs(ep.returnType, camelNs);
121
- const returnType =
122
- rawReturnType === "void" || rawReturnType === "any"
123
- ? rawReturnType
124
- : prefixModels(rawReturnType);
122
+ // Endpoints with explicitly defined parameters
123
+ const argType = `{ ${params.map((p: any) => `${camelCase(p.name)}${p.isOptional ? "?" : ""}: ${prefixModels(mapTypeToTs(p.typeRef, camelNs))}`).join(", ")} }`;
125
124
 
126
125
  if (isReact) {
127
126
  const bodyParam = params.find(