atmx-cli 0.63.0 → 0.65.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.
|
@@ -15,24 +15,40 @@ function generateSdk(multiIr, isReact = false) {
|
|
|
15
15
|
}
|
|
16
16
|
for (const [ns, ir] of Object.entries(multiIr)) {
|
|
17
17
|
const camelNs = (0, utils_1.camelCase)(ns);
|
|
18
|
+
// 👉 THIS LINE WAS MISSING IN THE PREVIOUS STEP!
|
|
18
19
|
lines.push(`export const ${camelNs}Module = {`);
|
|
19
|
-
|
|
20
|
+
lines.push(` axiom: {`);
|
|
20
21
|
if (isReact) {
|
|
21
|
-
lines.push(`
|
|
22
|
-
lines.push(`
|
|
23
|
-
lines.push(`
|
|
24
|
-
lines.push(`
|
|
25
|
-
lines.push(`
|
|
26
|
-
lines.push(`
|
|
22
|
+
lines.push(` setAuthToken(methodName: string, token: string) {`);
|
|
23
|
+
lines.push(` setAuthToken("${ns}", methodName, token);`);
|
|
24
|
+
lines.push(` },`);
|
|
25
|
+
lines.push(` clearAuthToken(methodName: string) {`);
|
|
26
|
+
lines.push(` clearAuthToken("${ns}", methodName);`);
|
|
27
|
+
lines.push(` },`);
|
|
28
|
+
lines.push(` connect(methodName: string, args?: Record<string, any>) {`);
|
|
29
|
+
lines.push(` console.warn("Manual connect not implemented for React. Use useAxiomQuery.");`);
|
|
30
|
+
lines.push(` },`);
|
|
31
|
+
lines.push(` disconnect(methodName: string, args?: Record<string, any>) {`);
|
|
32
|
+
lines.push(` console.warn("Manual disconnect not implemented for React. Unmount the component.");`);
|
|
33
|
+
lines.push(` }`);
|
|
27
34
|
}
|
|
28
35
|
else {
|
|
29
|
-
lines.push(`
|
|
30
|
-
lines.push(`
|
|
31
|
-
lines.push(`
|
|
32
|
-
lines.push(`
|
|
33
|
-
lines.push(`
|
|
34
|
-
lines.push(`
|
|
36
|
+
lines.push(` setAuthToken(methodName: string, token: string) {`);
|
|
37
|
+
lines.push(` (window as any).atmx?.setAuthToken("${ns}", methodName, token);`);
|
|
38
|
+
lines.push(` },`);
|
|
39
|
+
lines.push(` clearAuthToken(methodName: string) {`);
|
|
40
|
+
lines.push(` (window as any).atmx?.clearAuthToken("${ns}", methodName);`);
|
|
41
|
+
lines.push(` },`);
|
|
42
|
+
lines.push(` connect(methodName: string, args?: Record<string, any>) {`);
|
|
43
|
+
lines.push(` const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';`);
|
|
44
|
+
lines.push(` (window as any).atmx?.connect(\`${ns}.\${methodName}(\${argsStr})\`);`);
|
|
45
|
+
lines.push(` },`);
|
|
46
|
+
lines.push(` disconnect(methodName: string, args?: Record<string, any>) {`);
|
|
47
|
+
lines.push(` const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';`);
|
|
48
|
+
lines.push(` (window as any).atmx?.disconnect(\`${ns}.\${methodName}(\${argsStr})\`);`);
|
|
49
|
+
lines.push(` }`);
|
|
35
50
|
}
|
|
51
|
+
lines.push(` },`);
|
|
36
52
|
const endpointsMap = ir.endpoints || {};
|
|
37
53
|
const endpoints = Array.isArray(endpointsMap)
|
|
38
54
|
? endpointsMap
|
package/package.json
CHANGED
|
@@ -22,28 +22,65 @@ export function generateSdk(
|
|
|
22
22
|
|
|
23
23
|
for (const [ns, ir] of Object.entries(multiIr)) {
|
|
24
24
|
const camelNs = camelCase(ns);
|
|
25
|
+
|
|
26
|
+
// 👉 THIS LINE WAS MISSING IN THE PREVIOUS STEP!
|
|
25
27
|
lines.push(`export const ${camelNs}Module = {`);
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
lines.push(` axiom: {`);
|
|
28
30
|
if (isReact) {
|
|
29
|
-
lines.push(`
|
|
30
|
-
lines.push(`
|
|
31
|
-
lines.push(`
|
|
32
|
-
lines.push(`
|
|
33
|
-
lines.push(`
|
|
34
|
-
lines.push(`
|
|
31
|
+
lines.push(` setAuthToken(methodName: string, token: string) {`);
|
|
32
|
+
lines.push(` setAuthToken("${ns}", methodName, token);`);
|
|
33
|
+
lines.push(` },`);
|
|
34
|
+
lines.push(` clearAuthToken(methodName: string) {`);
|
|
35
|
+
lines.push(` clearAuthToken("${ns}", methodName);`);
|
|
36
|
+
lines.push(` },`);
|
|
37
|
+
lines.push(
|
|
38
|
+
` connect(methodName: string, args?: Record<string, any>) {`,
|
|
39
|
+
);
|
|
40
|
+
lines.push(
|
|
41
|
+
` console.warn("Manual connect not implemented for React. Use useAxiomQuery.");`,
|
|
42
|
+
);
|
|
43
|
+
lines.push(` },`);
|
|
44
|
+
lines.push(
|
|
45
|
+
` disconnect(methodName: string, args?: Record<string, any>) {`,
|
|
46
|
+
);
|
|
47
|
+
lines.push(
|
|
48
|
+
` console.warn("Manual disconnect not implemented for React. Unmount the component.");`,
|
|
49
|
+
);
|
|
50
|
+
lines.push(` }`);
|
|
35
51
|
} else {
|
|
36
|
-
lines.push(`
|
|
52
|
+
lines.push(` setAuthToken(methodName: string, token: string) {`);
|
|
53
|
+
lines.push(
|
|
54
|
+
` (window as any).atmx?.setAuthToken("${ns}", methodName, token);`,
|
|
55
|
+
);
|
|
56
|
+
lines.push(` },`);
|
|
57
|
+
lines.push(` clearAuthToken(methodName: string) {`);
|
|
58
|
+
lines.push(
|
|
59
|
+
` (window as any).atmx?.clearAuthToken("${ns}", methodName);`,
|
|
60
|
+
);
|
|
61
|
+
lines.push(` },`);
|
|
62
|
+
lines.push(
|
|
63
|
+
` connect(methodName: string, args?: Record<string, any>) {`,
|
|
64
|
+
);
|
|
65
|
+
lines.push(
|
|
66
|
+
` const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';`,
|
|
67
|
+
);
|
|
68
|
+
lines.push(
|
|
69
|
+
` (window as any).atmx?.connect(\`${ns}.\${methodName}(\${argsStr})\`);`,
|
|
70
|
+
);
|
|
71
|
+
lines.push(` },`);
|
|
72
|
+
lines.push(
|
|
73
|
+
` disconnect(methodName: string, args?: Record<string, any>) {`,
|
|
74
|
+
);
|
|
37
75
|
lines.push(
|
|
38
|
-
`
|
|
76
|
+
` const argsStr = args && Object.keys(args).length > 0 ? JSON.stringify(args) : '';`,
|
|
39
77
|
);
|
|
40
|
-
lines.push(` },`);
|
|
41
|
-
lines.push(` clearAuthToken(methodName: string) {`);
|
|
42
78
|
lines.push(
|
|
43
|
-
`
|
|
79
|
+
` (window as any).atmx?.disconnect(\`${ns}.\${methodName}(\${argsStr})\`);`,
|
|
44
80
|
);
|
|
45
|
-
lines.push(`
|
|
81
|
+
lines.push(` }`);
|
|
46
82
|
}
|
|
83
|
+
lines.push(` },`);
|
|
47
84
|
|
|
48
85
|
const endpointsMap = ir.endpoints || {};
|
|
49
86
|
const endpoints = Array.isArray(endpointsMap)
|