atmx-cli 0.34.0 → 0.36.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.
|
@@ -29,13 +29,23 @@ function generateSdk(multiIr) {
|
|
|
29
29
|
}
|
|
30
30
|
function generateEndpointMethod(ep, ns, pascalNs) {
|
|
31
31
|
const params = ep.parameters || [];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// ✨ FIX: If there are no parameters, don't even add the `args` variable!
|
|
33
|
+
if (params.length === 0) {
|
|
34
|
+
return `
|
|
35
|
+
/** RPC String Generator for <AxQuery> or <AxMutate> */
|
|
36
|
+
${(0, utils_1.camelCase)(ep.name)}(): string {
|
|
37
|
+
return \`${ns}.${ep.name}()\`;
|
|
38
|
+
}\n`;
|
|
39
|
+
}
|
|
40
|
+
// ✨ FIX: For endpoints with parameters, safely type them as optional objects
|
|
41
|
+
const argType = `{ ${params
|
|
42
|
+
.map((p) => {
|
|
43
|
+
return `${(0, utils_1.camelCase)(p.name)}?: ${prefixModels((0, utils_1.mapTypeToTs)(p.typeRef, pascalNs))}`;
|
|
44
|
+
})
|
|
45
|
+
.join(", ")} }`;
|
|
36
46
|
return `
|
|
37
47
|
/** RPC String Generator for <AxQuery> or <AxMutate> */
|
|
38
|
-
${(0, utils_1.camelCase)(ep.name)}(args
|
|
48
|
+
${(0, utils_1.camelCase)(ep.name)}(args?: ${argType}): string {
|
|
39
49
|
const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
|
|
40
50
|
return \`${ns}.${ep.name}(\${argsStr})\`;
|
|
41
51
|
}\n`;
|
package/package.json
CHANGED
|
@@ -42,15 +42,25 @@ function generateEndpointMethod(
|
|
|
42
42
|
): string {
|
|
43
43
|
const params = ep.parameters || [];
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// ✨ FIX: If there are no parameters, don't even add the `args` variable!
|
|
46
|
+
if (params.length === 0) {
|
|
47
|
+
return `
|
|
48
|
+
/** RPC String Generator for <AxQuery> or <AxMutate> */
|
|
49
|
+
${camelCase(ep.name)}(): string {
|
|
50
|
+
return \`${ns}.${ep.name}()\`;
|
|
51
|
+
}\n`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ✨ FIX: For endpoints with parameters, safely type them as optional objects
|
|
55
|
+
const argType = `{ ${params
|
|
56
|
+
.map((p) => {
|
|
57
|
+
return `${camelCase(p.name)}?: ${prefixModels(mapTypeToTs(p.typeRef, pascalNs))}`;
|
|
58
|
+
})
|
|
59
|
+
.join(", ")} }`;
|
|
49
60
|
|
|
50
|
-
// We generate a method that takes the typed arguments and returns the exact string ATMX expects
|
|
51
61
|
return `
|
|
52
62
|
/** RPC String Generator for <AxQuery> or <AxMutate> */
|
|
53
|
-
${camelCase(ep.name)}(args
|
|
63
|
+
${camelCase(ep.name)}(args?: ${argType}): string {
|
|
54
64
|
const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
|
|
55
65
|
return \`${ns}.${ep.name}(\${argsStr})\`;
|
|
56
66
|
}\n`;
|