@naturali/cli 0.28.1 → 0.28.2
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.
- package/dist/index.mjs +31 -16
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
14
14
|
};
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region package.json
|
|
17
|
-
var version = "0.28.
|
|
17
|
+
var version = "0.28.2";
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region ../sdk/src/generated/core/bodySerializer.gen.ts
|
|
20
20
|
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
@@ -2107,6 +2107,32 @@ const formatError = (args) => {
|
|
|
2107
2107
|
}, null, 2);
|
|
2108
2108
|
};
|
|
2109
2109
|
/**
|
|
2110
|
+
* Resolves the generated SDK method for a route, exiting with an error
|
|
2111
|
+
* envelope if the service class or the method itself cannot be found.
|
|
2112
|
+
*/
|
|
2113
|
+
const resolveServiceMethod = (route) => {
|
|
2114
|
+
const serviceClass = resolveServiceClass(route.serviceClass);
|
|
2115
|
+
if (!serviceClass) {
|
|
2116
|
+
console.error(`SDK class "${route.serviceClass}" not found.`);
|
|
2117
|
+
process.exit(1);
|
|
2118
|
+
}
|
|
2119
|
+
const method = serviceClass[route.operationId];
|
|
2120
|
+
if (typeof method !== "function") {
|
|
2121
|
+
console.error(`Method "${route.operationId}" not found on ${route.serviceClass}.`);
|
|
2122
|
+
process.exit(1);
|
|
2123
|
+
}
|
|
2124
|
+
return method;
|
|
2125
|
+
};
|
|
2126
|
+
/** Builds the SDK call options from a resolved route call, omitting empty parts. */
|
|
2127
|
+
const buildCallOptions = (args) => {
|
|
2128
|
+
const { client, call } = args;
|
|
2129
|
+
const callOptions = { client };
|
|
2130
|
+
if (Object.keys(call.path).length) callOptions["path"] = call.path;
|
|
2131
|
+
if (Object.keys(call.query).length) callOptions["query"] = call.query;
|
|
2132
|
+
if (Object.keys(call.body).length) callOptions["body"] = call.body;
|
|
2133
|
+
return callOptions;
|
|
2134
|
+
};
|
|
2135
|
+
/**
|
|
2110
2136
|
* Runs one generated command: parses its flags, resolves credentials, calls the
|
|
2111
2137
|
* matching SDK method, and prints the result.
|
|
2112
2138
|
*
|
|
@@ -2135,21 +2161,10 @@ const dispatchCommand = async (args) => {
|
|
|
2135
2161
|
console.error(`Missing required path parameter(s): ${built.missingPathParams.join(", ")}.\nProvide with ${flagsHint}.`);
|
|
2136
2162
|
process.exit(1);
|
|
2137
2163
|
}
|
|
2138
|
-
const
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
}
|
|
2143
|
-
const method = serviceClass[route.operationId];
|
|
2144
|
-
if (typeof method !== "function") {
|
|
2145
|
-
console.error(`Method "${route.operationId}" not found on ${route.serviceClass}.`);
|
|
2146
|
-
process.exit(1);
|
|
2147
|
-
}
|
|
2148
|
-
const callOptions = { client: context.client };
|
|
2149
|
-
if (Object.keys(built.call.path).length) callOptions["path"] = built.call.path;
|
|
2150
|
-
if (Object.keys(built.call.query).length) callOptions["query"] = built.call.query;
|
|
2151
|
-
if (Object.keys(built.call.body).length) callOptions["body"] = built.call.body;
|
|
2152
|
-
const result = await method(callOptions) ?? {};
|
|
2164
|
+
const result = await resolveServiceMethod(route)(buildCallOptions({
|
|
2165
|
+
client: context.client,
|
|
2166
|
+
call: built.call
|
|
2167
|
+
})) ?? {};
|
|
2153
2168
|
if (result.error) {
|
|
2154
2169
|
console.error(formatError({
|
|
2155
2170
|
error: result.error,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturali/cli",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.2",
|
|
4
4
|
"description": "Command-line interface for the naturali.ai API, generated from its OpenAPI specs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -30,11 +30,12 @@
|
|
|
30
30
|
"tsx": "^4.23.1",
|
|
31
31
|
"typescript": "~6.0.3",
|
|
32
32
|
"vitest": "^4.1.10",
|
|
33
|
-
"@naturali/sdk": "0.28.
|
|
33
|
+
"@naturali/sdk": "0.28.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"generate": "tsx scripts/generate.ts",
|
|
37
37
|
"typecheck": "tsc --noEmit",
|
|
38
|
+
"lint": "eslint src tests",
|
|
38
39
|
"test": "vitest run",
|
|
39
40
|
"build": "tsdown",
|
|
40
41
|
"e2e": "tsx tests/e2e/smoke.ts"
|