@pikku/openapi-parser 0.12.22 → 0.12.23
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/CHANGELOG.md +16 -0
- package/dist/auth-config.d.ts +53 -16
- package/dist/auth-config.js +43 -9
- package/dist/codegen.d.ts +1 -1
- package/dist/codegen.js +415 -376
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parse-openapi.d.ts +31 -5
- package/dist/parse-openapi.js +198 -70
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @pikku/openapi-parser
|
|
2
2
|
|
|
3
|
+
## 0.12.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0210e96: Review fixes for the OpenAPI addon onboarding:
|
|
8
|
+
|
|
9
|
+
- A delegated sign-in whose email the upstream did not return, including a login typed as an email, never links to an existing user. An authenticator that omits `syntheticEmail` counts as synthetic.
|
|
10
|
+
- `pikkuActor` credentials take an optional `remove`, which drops a credential the environment no longer sets. The actor log line names the user id, not the email.
|
|
11
|
+
- Basic credentials are UTF-8 encoded, and a Swagger 2 `application` OAuth flow keeps its token URL.
|
|
12
|
+
- `pikku new addon` writes a `file:` path relative to each package when the app is not a workspace, and reports an auth.ts factory it cannot edit instead of half-wiring it.
|
|
13
|
+
- The inspector reads an addon from the package that declares it before the root.
|
|
14
|
+
- The dev credentials key file is created exclusively, so two `pikku dev` processes agree on one key.
|
|
15
|
+
|
|
16
|
+
- 38d4f65: OpenAPI codegen builds without hand-fixes: specs from a URL with headers, Swagger 2 / OAS 3.0 / 3.1, server variables, form and multipart bodies, tag/include/exclude filters, a coverage warning for thin specs, a url() base URL, z.unknown() for vague responses, basic auth, CredentialRejectedError on an upstream 401, and a generalized delegated-login config.
|
|
17
|
+
- a8cf3a1: A generated addon's errors now carry the upstream API's own message (`error.message`, `message`, `detail`, `title`), capped at 200 characters, instead of the raw response body with whatever debug data the API put in it.
|
|
18
|
+
|
|
3
19
|
## 0.12.22
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/auth-config.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const DelegatedClaimsSchema: z.ZodObject<{
|
|
3
|
-
source: z.ZodEnum<{
|
|
3
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
4
|
+
identity: "identity";
|
|
4
5
|
jwt: "jwt";
|
|
5
6
|
response: "response";
|
|
6
|
-
}
|
|
7
|
-
externalId: z.ZodString
|
|
8
|
-
email: z.ZodString
|
|
7
|
+
}>>;
|
|
8
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
email: z.ZodOptional<z.ZodString>;
|
|
9
10
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
10
11
|
role: z.ZodOptional<z.ZodString>;
|
|
11
12
|
tenantId: z.ZodOptional<z.ZodString>;
|
|
@@ -16,22 +17,40 @@ export declare const DelegatedLoginSchema: z.ZodObject<{
|
|
|
16
17
|
credentials: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
17
18
|
apiKey: "apiKey";
|
|
18
19
|
email: "email";
|
|
20
|
+
login: "login";
|
|
19
21
|
password: "password";
|
|
20
22
|
}>>>;
|
|
23
|
+
fields: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
24
|
+
email: "email";
|
|
25
|
+
login: "login";
|
|
26
|
+
password: "password";
|
|
27
|
+
}> & z.core.$partial, z.ZodString>>;
|
|
28
|
+
encoding: z.ZodDefault<z.ZodEnum<{
|
|
29
|
+
form: "form";
|
|
30
|
+
json: "json";
|
|
31
|
+
query: "query";
|
|
32
|
+
}>>;
|
|
21
33
|
apiKeyHeader: z.ZodDefault<z.ZodString>;
|
|
22
34
|
tokenPath: z.ZodString;
|
|
23
35
|
expiresAtPath: z.ZodOptional<z.ZodString>;
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
path: z.ZodString;
|
|
38
|
+
method: z.ZodDefault<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
claims: z.ZodDefault<z.ZodObject<{
|
|
41
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
identity: "identity";
|
|
26
43
|
jwt: "jwt";
|
|
27
44
|
response: "response";
|
|
28
|
-
}
|
|
29
|
-
externalId: z.ZodString
|
|
30
|
-
email: z.ZodString
|
|
45
|
+
}>>;
|
|
46
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
47
|
+
email: z.ZodOptional<z.ZodString>;
|
|
31
48
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
32
49
|
role: z.ZodOptional<z.ZodString>;
|
|
33
50
|
tenantId: z.ZodOptional<z.ZodString>;
|
|
34
|
-
}, z.core.$strip
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
emailTemplate: z.ZodDefault<z.ZodString>;
|
|
53
|
+
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
35
54
|
}, z.core.$strip>;
|
|
36
55
|
export declare const AuthConfigSchema: z.ZodObject<{
|
|
37
56
|
headerName: z.ZodOptional<z.ZodString>;
|
|
@@ -46,22 +65,40 @@ export declare const AuthConfigSchema: z.ZodObject<{
|
|
|
46
65
|
credentials: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
47
66
|
apiKey: "apiKey";
|
|
48
67
|
email: "email";
|
|
68
|
+
login: "login";
|
|
49
69
|
password: "password";
|
|
50
70
|
}>>>;
|
|
71
|
+
fields: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
72
|
+
email: "email";
|
|
73
|
+
login: "login";
|
|
74
|
+
password: "password";
|
|
75
|
+
}> & z.core.$partial, z.ZodString>>;
|
|
76
|
+
encoding: z.ZodDefault<z.ZodEnum<{
|
|
77
|
+
form: "form";
|
|
78
|
+
json: "json";
|
|
79
|
+
query: "query";
|
|
80
|
+
}>>;
|
|
51
81
|
apiKeyHeader: z.ZodDefault<z.ZodString>;
|
|
52
82
|
tokenPath: z.ZodString;
|
|
53
83
|
expiresAtPath: z.ZodOptional<z.ZodString>;
|
|
54
|
-
|
|
55
|
-
|
|
84
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
path: z.ZodString;
|
|
86
|
+
method: z.ZodDefault<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
claims: z.ZodDefault<z.ZodObject<{
|
|
89
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
90
|
+
identity: "identity";
|
|
56
91
|
jwt: "jwt";
|
|
57
92
|
response: "response";
|
|
58
|
-
}
|
|
59
|
-
externalId: z.ZodString
|
|
60
|
-
email: z.ZodString
|
|
93
|
+
}>>;
|
|
94
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
95
|
+
email: z.ZodOptional<z.ZodString>;
|
|
61
96
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
62
97
|
role: z.ZodOptional<z.ZodString>;
|
|
63
98
|
tenantId: z.ZodOptional<z.ZodString>;
|
|
64
|
-
}, z.core.$strip
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
emailTemplate: z.ZodDefault<z.ZodString>;
|
|
101
|
+
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
65
102
|
}, z.core.$strip>>;
|
|
66
103
|
}, z.core.$strip>;
|
|
67
104
|
export type DelegatedLoginConfig = z.infer<typeof DelegatedLoginSchema>;
|
package/dist/auth-config.js
CHANGED
|
@@ -7,12 +7,17 @@
|
|
|
7
7
|
import { readFile } from 'fs/promises';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
export const DelegatedClaimsSchema = z.object({
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Where identity claims live: the decoded login-JWT payload, the login
|
|
12
|
+
* response body, or the `identity` lookup's response. Defaults to
|
|
13
|
+
* `identity` when an identity lookup is configured, else `response`.
|
|
14
|
+
*/
|
|
15
|
+
source: z.enum(['jwt', 'response', 'identity']).optional(),
|
|
16
|
+
/** Dot-path to the stable upstream user id (e.g. 'user._id'). Defaults to the sign-in login. */
|
|
17
|
+
externalId: z.string().optional(),
|
|
18
|
+
/** Dot-path to the email; when missing or empty, `emailTemplate` builds one. */
|
|
19
|
+
email: z.string().optional(),
|
|
20
|
+
/** One dot-path, or several joined with a space (e.g. first + last name). Defaults to the login. */
|
|
16
21
|
name: z.union([z.string(), z.array(z.string())]).optional(),
|
|
17
22
|
role: z.string().optional(),
|
|
18
23
|
tenantId: z.string().optional(),
|
|
@@ -21,17 +26,46 @@ export const DelegatedLoginSchema = z.object({
|
|
|
21
26
|
/** Spec-relative path of the login operation (e.g. '/users/login'). */
|
|
22
27
|
loginPath: z.string(),
|
|
23
28
|
loginMethod: z.string().default('post'),
|
|
24
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Which credentials the sign-in form collects. `login` is a username or
|
|
31
|
+
* email, `email` an email address, `apiKey` a key sent in `apiKeyHeader`.
|
|
32
|
+
*/
|
|
25
33
|
credentials: z
|
|
26
|
-
.array(z.enum(['email', 'password', 'apiKey']))
|
|
34
|
+
.array(z.enum(['login', 'email', 'password', 'apiKey']))
|
|
27
35
|
.default(['email', 'password']),
|
|
36
|
+
/**
|
|
37
|
+
* Upstream field name for each credential, e.g. `{ "login": "username" }`.
|
|
38
|
+
* Unmapped credentials keep their own name.
|
|
39
|
+
*/
|
|
40
|
+
fields: z
|
|
41
|
+
.partialRecord(z.enum(['login', 'email', 'password']), z.string())
|
|
42
|
+
.optional(),
|
|
43
|
+
/** How the login fields travel: a JSON body, a form body, or the query string. */
|
|
44
|
+
encoding: z.enum(['json', 'form', 'query']).default('json'),
|
|
28
45
|
/** Header carrying the apiKey when 'apiKey' is a supported credential. */
|
|
29
46
|
apiKeyHeader: z.string().default('x-api-key'),
|
|
30
47
|
/** Dot-path to the token in the login response (e.g. 'token'). */
|
|
31
48
|
tokenPath: z.string(),
|
|
32
49
|
/** Dot-path to an epoch-seconds expiry in the response; defaults to the JWT `exp` claim when source is jwt. */
|
|
33
50
|
expiresAtPath: z.string().optional(),
|
|
34
|
-
|
|
51
|
+
/**
|
|
52
|
+
* An operation that returns the signed-in user, called with the new token
|
|
53
|
+
* in the auth header — for upstreams whose login returns only a token.
|
|
54
|
+
*/
|
|
55
|
+
identity: z
|
|
56
|
+
.object({
|
|
57
|
+
path: z.string(),
|
|
58
|
+
method: z.string().default('get'),
|
|
59
|
+
})
|
|
60
|
+
.optional(),
|
|
61
|
+
claims: DelegatedClaimsSchema.default({}),
|
|
62
|
+
/**
|
|
63
|
+
* Builds the user's email when the upstream has none. Placeholders:
|
|
64
|
+
* `{login}`, `{externalId}`, `{host}` (the upstream's host).
|
|
65
|
+
*/
|
|
66
|
+
emailTemplate: z.string().default('{login}@{host}'),
|
|
67
|
+
/** Maps the raw `claims.role` value onto an app role; unmapped values get no role. */
|
|
68
|
+
roles: z.record(z.string(), z.string()).optional(),
|
|
35
69
|
});
|
|
36
70
|
export const AuthConfigSchema = z.object({
|
|
37
71
|
/** Auth header the API expects on authenticated calls (e.g. 'authentication'). Overrides the spec. */
|
package/dist/codegen.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ interface AddonVars {
|
|
|
15
15
|
interface CodegenFlags {
|
|
16
16
|
oauth: boolean;
|
|
17
17
|
secret: boolean;
|
|
18
|
-
credential?: 'apikey' | 'bearer' | 'oauth2';
|
|
18
|
+
credential?: 'apikey' | 'bearer' | 'basic' | 'oauth2';
|
|
19
19
|
mcp?: boolean;
|
|
20
20
|
camelCase?: boolean;
|
|
21
21
|
/** Operator-supplied auth overrides (custom header, delegated login). */
|