atmx-cli 0.35.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,17 +29,23 @@ function generateSdk(multiIr) {
29
29
  }
30
30
  function generateEndpointMethod(ep, ns, pascalNs) {
31
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";
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(", ")} }`;
40
46
  return `
41
47
  /** RPC String Generator for <AxQuery> or <AxMutate> */
42
- ${(0, utils_1.camelCase)(ep.name)}(args${params.length > 0 ? "?" : ""}: ${argType} | void): string {
48
+ ${(0, utils_1.camelCase)(ep.name)}(args?: ${argType}): string {
43
49
  const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
44
50
  return \`${ns}.${ep.name}(\${argsStr})\`;
45
51
  }\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atmx-cli",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -42,19 +42,25 @@ function generateEndpointMethod(
42
42
  ): string {
43
43
  const params = ep.parameters || [];
44
44
 
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";
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(", ")} }`;
54
60
 
55
61
  return `
56
62
  /** RPC String Generator for <AxQuery> or <AxMutate> */
57
- ${camelCase(ep.name)}(args${params.length > 0 ? "?" : ""}: ${argType} | void): string {
63
+ ${camelCase(ep.name)}(args?: ${argType}): string {
58
64
  const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';
59
65
  return \`${ns}.${ep.name}(\${argsStr})\`;
60
66
  }\n`;