@naturali/cli 0.28.1 → 0.29.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.
- package/dist/index.mjs +101 -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.
|
|
17
|
+
var version = "0.29.0";
|
|
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) };
|
|
@@ -798,6 +798,38 @@ var Auth = class {
|
|
|
798
798
|
});
|
|
799
799
|
}
|
|
800
800
|
/**
|
|
801
|
+
* Email a sign-in code
|
|
802
|
+
*
|
|
803
|
+
* Emails a short numeric code to the address. Always responds 200 with the same body whether or not the address has an account, so it never leaks existence. A first-time address gets an account on its first successful verification, so this is both sign-up and log-in. Issuing a code invalidates any previous one for the same address.
|
|
804
|
+
*
|
|
805
|
+
*/
|
|
806
|
+
static requestSignInCode(options) {
|
|
807
|
+
return (options.client ?? client).post({
|
|
808
|
+
url: "/v1/auth/code",
|
|
809
|
+
...options,
|
|
810
|
+
headers: {
|
|
811
|
+
"Content-Type": "application/json",
|
|
812
|
+
...options.headers
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Redeem a sign-in code
|
|
818
|
+
*
|
|
819
|
+
* Exchanges an emailed code for a session, creating the account if the address is new. The code is single-use and short-lived. A code is destroyed after too many wrong guesses, since six digits is small enough to guess given unlimited attempts — the client must then request a new one rather than retry.
|
|
820
|
+
*
|
|
821
|
+
*/
|
|
822
|
+
static verifySignInCode(options) {
|
|
823
|
+
return (options.client ?? client).post({
|
|
824
|
+
url: "/v1/auth/code/verify",
|
|
825
|
+
...options,
|
|
826
|
+
headers: {
|
|
827
|
+
"Content-Type": "application/json",
|
|
828
|
+
...options.headers
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
801
833
|
* Refresh a session
|
|
802
834
|
*
|
|
803
835
|
* Exchanges a valid refresh token for a new access JWT and a rotated refresh token. Refresh tokens are single-use; presenting a previously-rotated token is treated as reuse and revokes the whole session family (createRefreshRotation reuse detection).
|
|
@@ -2107,6 +2139,32 @@ const formatError = (args) => {
|
|
|
2107
2139
|
}, null, 2);
|
|
2108
2140
|
};
|
|
2109
2141
|
/**
|
|
2142
|
+
* Resolves the generated SDK method for a route, exiting with an error
|
|
2143
|
+
* envelope if the service class or the method itself cannot be found.
|
|
2144
|
+
*/
|
|
2145
|
+
const resolveServiceMethod = (route) => {
|
|
2146
|
+
const serviceClass = resolveServiceClass(route.serviceClass);
|
|
2147
|
+
if (!serviceClass) {
|
|
2148
|
+
console.error(`SDK class "${route.serviceClass}" not found.`);
|
|
2149
|
+
process.exit(1);
|
|
2150
|
+
}
|
|
2151
|
+
const method = serviceClass[route.operationId];
|
|
2152
|
+
if (typeof method !== "function") {
|
|
2153
|
+
console.error(`Method "${route.operationId}" not found on ${route.serviceClass}.`);
|
|
2154
|
+
process.exit(1);
|
|
2155
|
+
}
|
|
2156
|
+
return method;
|
|
2157
|
+
};
|
|
2158
|
+
/** Builds the SDK call options from a resolved route call, omitting empty parts. */
|
|
2159
|
+
const buildCallOptions = (args) => {
|
|
2160
|
+
const { client, call } = args;
|
|
2161
|
+
const callOptions = { client };
|
|
2162
|
+
if (Object.keys(call.path).length) callOptions["path"] = call.path;
|
|
2163
|
+
if (Object.keys(call.query).length) callOptions["query"] = call.query;
|
|
2164
|
+
if (Object.keys(call.body).length) callOptions["body"] = call.body;
|
|
2165
|
+
return callOptions;
|
|
2166
|
+
};
|
|
2167
|
+
/**
|
|
2110
2168
|
* Runs one generated command: parses its flags, resolves credentials, calls the
|
|
2111
2169
|
* matching SDK method, and prints the result.
|
|
2112
2170
|
*
|
|
@@ -2135,21 +2193,10 @@ const dispatchCommand = async (args) => {
|
|
|
2135
2193
|
console.error(`Missing required path parameter(s): ${built.missingPathParams.join(", ")}.\nProvide with ${flagsHint}.`);
|
|
2136
2194
|
process.exit(1);
|
|
2137
2195
|
}
|
|
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) ?? {};
|
|
2196
|
+
const result = await resolveServiceMethod(route)(buildCallOptions({
|
|
2197
|
+
client: context.client,
|
|
2198
|
+
call: built.call
|
|
2199
|
+
})) ?? {};
|
|
2153
2200
|
if (result.error) {
|
|
2154
2201
|
console.error(formatError({
|
|
2155
2202
|
error: result.error,
|
|
@@ -2590,6 +2637,44 @@ const routes = {
|
|
|
2590
2637
|
"in": "body"
|
|
2591
2638
|
}]
|
|
2592
2639
|
},
|
|
2640
|
+
"request-sign-in-code": {
|
|
2641
|
+
serviceClass: "Auth",
|
|
2642
|
+
operationId: "requestSignInCode",
|
|
2643
|
+
description: "Emails a short numeric code to the address. Always responds 200 with the same body whether or not the address has an account, so it never leaks existence. A first-time address gets an account on its first successful verification, so this is both sign-up and log-in. Issuing a code invalidates any previous one for the same address.",
|
|
2644
|
+
moduleDocsUrl: "https://docs.naturali.ai/docs/modules/auth",
|
|
2645
|
+
httpMethod: "post",
|
|
2646
|
+
pathParams: [],
|
|
2647
|
+
queryParams: [],
|
|
2648
|
+
flags: [{
|
|
2649
|
+
"name": "email",
|
|
2650
|
+
"description": "",
|
|
2651
|
+
"required": true,
|
|
2652
|
+
"type": "string",
|
|
2653
|
+
"in": "body"
|
|
2654
|
+
}]
|
|
2655
|
+
},
|
|
2656
|
+
"verify-sign-in-code": {
|
|
2657
|
+
serviceClass: "Auth",
|
|
2658
|
+
operationId: "verifySignInCode",
|
|
2659
|
+
description: "Exchanges an emailed code for a session, creating the account if the address is new. The code is single-use and short-lived. A code is destroyed after too many wrong guesses, since six digits is small enough to guess given unlimited attempts — the client must then request a new one rather than retry.",
|
|
2660
|
+
moduleDocsUrl: "https://docs.naturali.ai/docs/modules/auth",
|
|
2661
|
+
httpMethod: "post",
|
|
2662
|
+
pathParams: [],
|
|
2663
|
+
queryParams: [],
|
|
2664
|
+
flags: [{
|
|
2665
|
+
"name": "email",
|
|
2666
|
+
"description": "",
|
|
2667
|
+
"required": true,
|
|
2668
|
+
"type": "string",
|
|
2669
|
+
"in": "body"
|
|
2670
|
+
}, {
|
|
2671
|
+
"name": "code",
|
|
2672
|
+
"description": "The code from the email, as sent — digits only.",
|
|
2673
|
+
"required": true,
|
|
2674
|
+
"type": "string",
|
|
2675
|
+
"in": "body"
|
|
2676
|
+
}]
|
|
2677
|
+
},
|
|
2593
2678
|
"refresh-session": {
|
|
2594
2679
|
serviceClass: "Auth",
|
|
2595
2680
|
operationId: "refreshSession",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturali/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
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.
|
|
33
|
+
"@naturali/sdk": "0.29.0"
|
|
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"
|