atmx-cli 0.35.0 → 0.38.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.
@@ -28,18 +28,26 @@ function generateSdk(multiIr) {
28
28
  return lines.join("\n");
29
29
  }
30
30
  function generateEndpointMethod(ep, ns, pascalNs) {
31
- const params = ep.parameters || [];
32
- const argType = params.length > 0
33
- ? `{ ${params
34
- .map((p) => {
35
- // ✨ FIX: Make everything optional so DOM forms can fill in the blanks!
36
- return `${(0, utils_1.camelCase)(p.name)}?: ${prefixModels((0, utils_1.mapTypeToTs)(p.typeRef, pascalNs))}`;
37
- })
38
- .join(", ")} }`
39
- : "void";
31
+ // ✨ FIX: Ensure params is always an Array regardless of the IR structure
32
+ const rawParams = ep.parameters || [];
33
+ const params = Array.isArray(rawParams)
34
+ ? rawParams
35
+ : Object.values(rawParams);
36
+ if (params.length === 0) {
37
+ return `
38
+ /** RPC String Generator for <AxQuery> or <AxMutate> */
39
+ ${(0, utils_1.camelCase)(ep.name)}(): string {
40
+ return \`${ns}.${ep.name}()\`;
41
+ }\n`;
42
+ }
43
+ const argType = `{ ${params
44
+ .map((p) => {
45
+ return `${(0, utils_1.camelCase)(p.name)}?: ${prefixModels((0, utils_1.mapTypeToTs)(p.typeRef, pascalNs))}`;
46
+ })
47
+ .join(", ")} }`;
40
48
  return `
41
49
  /** RPC String Generator for <AxQuery> or <AxMutate> */
42
- ${(0, utils_1.camelCase)(ep.name)}(args${params.length > 0 ? "?" : ""}: ${argType} | void): string {
50
+ ${(0, utils_1.camelCase)(ep.name)}(args?: ${argType}): string {
43
51
  const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
44
52
  return \`${ns}.${ep.name}(\${argsStr})\`;
45
53
  }\n`;
@@ -18,14 +18,17 @@ function camelCase(str) {
18
18
  return pascal.charAt(0).toLowerCase() + pascal.slice(1);
19
19
  }
20
20
  function normalizeIr(obj) {
21
- // ✨ FIX: Recursively convert Axiom Core HashMaps back into Arrays for the generator
21
+ // ✨ FIX: Arrays in JavaScript are Objects! We must check Array.isArray FIRST.
22
+ if (Array.isArray(obj)) {
23
+ return obj.map(normalizeIr);
24
+ }
22
25
  if (obj !== null && typeof obj === "object") {
23
26
  const newObj = {};
24
27
  for (const key of Object.keys(obj)) {
25
28
  const camelKey = key.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
26
29
  newObj[camelKey] = normalizeIr(obj[key]);
27
30
  }
28
- // Convert common Maps to Arrays if they exist
31
+ // Convert common Maps to Arrays if they exist and are not already arrays
29
32
  if (newObj.endpoints &&
30
33
  typeof newObj.endpoints === "object" &&
31
34
  !Array.isArray(newObj.endpoints)) {
@@ -54,8 +57,6 @@ function normalizeIr(obj) {
54
57
  }
55
58
  return newObj;
56
59
  }
57
- if (Array.isArray(obj))
58
- return obj.map(normalizeIr);
59
60
  return obj;
60
61
  }
61
62
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atmx-cli",
3
- "version": "0.35.0",
3
+ "version": "0.38.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -40,21 +40,29 @@ function generateEndpointMethod(
40
40
  ns: string,
41
41
  pascalNs: string,
42
42
  ): string {
43
- const params = ep.parameters || [];
43
+ // ✨ FIX: Ensure params is always an Array regardless of the IR structure
44
+ const rawParams = ep.parameters || [];
45
+ const params = Array.isArray(rawParams)
46
+ ? rawParams
47
+ : Object.values(rawParams);
44
48
 
45
- const argType =
46
- params.length > 0
47
- ? `{ ${params
48
- .map((p) => {
49
- // ✨ FIX: Make everything optional so DOM forms can fill in the blanks!
50
- return `${camelCase(p.name)}?: ${prefixModels(mapTypeToTs(p.typeRef, pascalNs))}`;
51
- })
52
- .join(", ")} }`
53
- : "void";
49
+ if (params.length === 0) {
50
+ return `
51
+ /** RPC String Generator for <AxQuery> or <AxMutate> */
52
+ ${camelCase(ep.name)}(): string {
53
+ return \`${ns}.${ep.name}()\`;
54
+ }\n`;
55
+ }
56
+
57
+ const argType = `{ ${params
58
+ .map((p: any) => {
59
+ return `${camelCase(p.name)}?: ${prefixModels(mapTypeToTs(p.typeRef, pascalNs))}`;
60
+ })
61
+ .join(", ")} }`;
54
62
 
55
63
  return `
56
64
  /** RPC String Generator for <AxQuery> or <AxMutate> */
57
- ${camelCase(ep.name)}(args${params.length > 0 ? "?" : ""}: ${argType} | void): string {
65
+ ${camelCase(ep.name)}(args?: ${argType}): string {
58
66
  const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
59
67
  return \`${ns}.${ep.name}(\${argsStr})\`;
60
68
  }\n`;
@@ -14,7 +14,11 @@ export function camelCase(str: string): string {
14
14
  }
15
15
 
16
16
  export function normalizeIr(obj: any): any {
17
- // ✨ FIX: Recursively convert Axiom Core HashMaps back into Arrays for the generator
17
+ // ✨ FIX: Arrays in JavaScript are Objects! We must check Array.isArray FIRST.
18
+ if (Array.isArray(obj)) {
19
+ return obj.map(normalizeIr);
20
+ }
21
+
18
22
  if (obj !== null && typeof obj === "object") {
19
23
  const newObj: any = {};
20
24
  for (const key of Object.keys(obj)) {
@@ -22,7 +26,7 @@ export function normalizeIr(obj: any): any {
22
26
  newObj[camelKey] = normalizeIr(obj[key]);
23
27
  }
24
28
 
25
- // Convert common Maps to Arrays if they exist
29
+ // Convert common Maps to Arrays if they exist and are not already arrays
26
30
  if (
27
31
  newObj.endpoints &&
28
32
  typeof newObj.endpoints === "object" &&
@@ -62,7 +66,6 @@ export function normalizeIr(obj: any): any {
62
66
  return newObj;
63
67
  }
64
68
 
65
- if (Array.isArray(obj)) return obj.map(normalizeIr);
66
69
  return obj;
67
70
  }
68
71