@faable/auth-sdk 2.6.23 → 2.7.1
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/FaableAuthApi.js +1 -1
- package/dist/api/api-types.d.ts +2 -0
- package/dist/api/generated-client.d.ts +1155 -1
- package/dist/api/generated-client.js +1154 -0
- package/dist/api/types.d.ts +13063 -819
- package/dist/helpers.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/version.js +2 -2
- package/package.json +2 -2
- package/scripts/gen-client.mjs +48 -2
- package/spec/openapi.json +23657 -991
- package/dist/error_handler.d.ts +0 -27
- package/dist/error_handler.js +0 -36
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FaableApiError } from "
|
|
1
|
+
import { FaableApiError } from "@faable/sdk-base";
|
|
2
2
|
// Normaliza el `domain` para que dé igual cómo lo pase el usuario: con o sin
|
|
3
3
|
// protocolo, con trailing slash, o incluso con protocolo duplicado (el valor
|
|
4
4
|
// que el dashboard copia ya trae `https://`). Siempre devuelve
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { SDK_CLIENT, commit, version } from "./version.js";
|
|
|
3
3
|
export * from "./api/generated-client.js";
|
|
4
4
|
export * from "./api/api-types.js";
|
|
5
5
|
export * from "./api/types.js";
|
|
6
|
-
export { authClientCredentials, authApikey, authBearer, authCookie, } from "@faable/sdk-base";
|
|
6
|
+
export { authClientCredentials, authApikey, authBearer, authCookie, FaableApiError, } from "@faable/sdk-base";
|
|
7
7
|
export type { ApiParams, ClientCredentialsConfig, ApikeyConfig, BearerConfig, RetryConfig, Fetcher, FetcherConfig, FetcherRequestParams, AuthStrategy, AuthStrategyBuilder, AuthStrategyContext, } from "@faable/sdk-base";
|
package/dist/index.js
CHANGED
|
@@ -6,4 +6,8 @@ export * from "./api/types.js";
|
|
|
6
6
|
// Re-export the auth strategies (and their config/types) from
|
|
7
7
|
// @faable/sdk-base so consumers depend on @faable/auth-sdk ONLY — sdk-base
|
|
8
8
|
// stays a transitive dependency and no app needs to import it directly.
|
|
9
|
-
export { authClientCredentials, authApikey, authBearer, authCookie,
|
|
9
|
+
export { authClientCredentials, authApikey, authBearer, authCookie,
|
|
10
|
+
// The error every method throws on a non-2xx. Branch on `err.error_code`
|
|
11
|
+
// (or `err.isErrorCode('sms_unavailable')`), never on `err.message`: the
|
|
12
|
+
// generated client lists the codes of each method as `@throws`.
|
|
13
|
+
FaableApiError, } from "@faable/sdk-base";
|
package/dist/version.js
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
// login pages could not import the SDK at all. Same pattern as auth-js.
|
|
10
10
|
//
|
|
11
11
|
// The sentinels MUST stay byte-identical to the `from` values in `.releaserc`.
|
|
12
|
-
export const version = "2.
|
|
12
|
+
export const version = "2.7.1";
|
|
13
13
|
// Short git SHA of the released commit. The version dates a build; this names
|
|
14
14
|
// the exact tree, so a canonical log line or an audit entry leads straight to
|
|
15
15
|
// `git show <sha>`. Deliberately NOT hex: an unreleased build (dev, a local
|
|
16
16
|
// link) cannot be mistaken for a real commit — auth only records values that
|
|
17
17
|
// look like a SHA, and this one never will.
|
|
18
|
-
export const commit = "
|
|
18
|
+
export const commit = "2271aa1";
|
|
19
19
|
// What this SDK writes in `x-faable-client`. Exported for a consumer that
|
|
20
20
|
// builds a strategy on its own (outside `FaableAuthApi`) and still wants the
|
|
21
21
|
// token request attributed — a bare `authClientCredentials` stamps only what
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faable/auth-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"author": "Marc Pomar <marc@faable.com>",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@faable/sdk-base": "^1.
|
|
13
|
+
"@faable/sdk-base": "^1.7.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@ava/typescript": "^5.0.0",
|
package/scripts/gen-client.mjs
CHANGED
|
@@ -80,6 +80,40 @@ for (const [path, methods] of Object.entries(spec.paths || {})) {
|
|
|
80
80
|
}
|
|
81
81
|
operations.sort((a, b) => a.op.operationId.localeCompare(b.op.operationId));
|
|
82
82
|
|
|
83
|
+
// Multi-line descriptions become one JSDoc line each.
|
|
84
|
+
const escapeBlock = (text) =>
|
|
85
|
+
String(text)
|
|
86
|
+
.split("\n")
|
|
87
|
+
.map((l) => ` * ${escape(l)}`);
|
|
88
|
+
|
|
89
|
+
// The server documents each 4xx/5xx as an ErrorResponse whose `error_code`
|
|
90
|
+
// is restricted to an enum, and describes every code in the response
|
|
91
|
+
// description as "`code` — text" lines. Read both back so the docstring can
|
|
92
|
+
// list what a caller may branch on.
|
|
93
|
+
const errorCodesOf = (op) => {
|
|
94
|
+
const out = [];
|
|
95
|
+
const seen = new Set();
|
|
96
|
+
for (const [status, res] of Object.entries(op.responses || {})) {
|
|
97
|
+
if (!/^[45]\d\d$/.test(status)) continue;
|
|
98
|
+
const schema = res?.content?.["application/json"]?.schema;
|
|
99
|
+
const parts = schema?.allOf || (schema ? [schema] : []);
|
|
100
|
+
const codes = parts.flatMap((p) => p?.properties?.error_code?.enum || []);
|
|
101
|
+
const descriptions = new Map(
|
|
102
|
+
String(res?.description || "")
|
|
103
|
+
.split("\n")
|
|
104
|
+
.map((l) => l.match(/^`([a-z_]+)` — (.*)$/))
|
|
105
|
+
.filter(Boolean)
|
|
106
|
+
.map((m) => [m[1], m[2]]),
|
|
107
|
+
);
|
|
108
|
+
for (const code of codes) {
|
|
109
|
+
if (seen.has(code)) continue;
|
|
110
|
+
seen.add(code);
|
|
111
|
+
out.push({ code, status, description: descriptions.get(code) });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
};
|
|
116
|
+
|
|
83
117
|
const emitMethod = ({ path, httpMethod, op }) => {
|
|
84
118
|
const id = op.operationId;
|
|
85
119
|
const name = toMethodName(id);
|
|
@@ -128,11 +162,23 @@ const emitMethod = ({ path, httpMethod, op }) => {
|
|
|
128
162
|
}
|
|
129
163
|
|
|
130
164
|
const guards = pathParams.map((p) => ` requireId("${p}", ${p});`);
|
|
131
|
-
|
|
165
|
+
// Summary AND description: the CRUD summaries are generic ("Get User") and
|
|
166
|
+
// used to hide the prose that actually explains the endpoint.
|
|
167
|
+
const docLines = [op.summary, op.description]
|
|
168
|
+
.filter((x, i, all) => x && all.indexOf(x) === i)
|
|
169
|
+
.flatMap((text, i) => [...(i ? [" *"] : []), ...escapeBlock(text)]);
|
|
170
|
+
// One `@throws` per documented error code, read from the 4xx/5xx responses
|
|
171
|
+
// the server injects (see auth's server/openapi_errors.ts). The code is
|
|
172
|
+
// `err.error_code` on the FaableApiError the fetcher throws.
|
|
173
|
+
const throwsLines = errorCodesOf(op).map(
|
|
174
|
+
({ code, status, description }) =>
|
|
175
|
+
` * @throws {FaableApiError} \`${code}\` (${status})${description ? ` — ${escape(description)}` : ""}`,
|
|
176
|
+
);
|
|
132
177
|
const jsdoc = [
|
|
133
178
|
" /**",
|
|
134
179
|
` * \`${httpMethod.toUpperCase()} ${path}\` — operationId: \`${id}\``,
|
|
135
|
-
...(
|
|
180
|
+
...(docLines.length ? [" *", ...docLines] : []),
|
|
181
|
+
...(throwsLines.length ? [" *", ...throwsLines] : []),
|
|
136
182
|
" */",
|
|
137
183
|
].join("\n");
|
|
138
184
|
|