@scalar/oas-utils 0.2.2 → 0.2.4
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 +12 -0
- package/dist/entities/workspace/collection/collection.d.ts +51 -17
- package/dist/entities/workspace/collection/collection.d.ts.map +1 -1
- package/dist/entities/workspace/collection/collection.js +27 -0
- package/dist/entities/workspace/cookie/cookie.d.ts +2 -2
- package/dist/entities/workspace/environment/environment.d.ts +3 -3
- package/dist/entities/workspace/folder/folder.d.ts +4 -4
- package/dist/entities/workspace/security/index.d.ts +3 -0
- package/dist/entities/workspace/security/index.d.ts.map +1 -0
- package/dist/entities/workspace/security/index.js +2 -0
- package/dist/entities/workspace/security/security-requirement.d.ts +13 -0
- package/dist/entities/workspace/security/security-requirement.d.ts.map +1 -0
- package/dist/entities/workspace/security/security-requirement.js +15 -0
- package/dist/entities/workspace/security/security-schemes.d.ts +664 -0
- package/dist/entities/workspace/security/security-schemes.d.ts.map +1 -0
- package/dist/entities/workspace/security/security-schemes.js +146 -0
- package/dist/entities/workspace/server/server.d.ts +6 -6
- package/dist/entities/workspace/spec/request-examples.d.ts +18 -18
- package/dist/entities/workspace/spec/requests.d.ts +29 -12
- package/dist/entities/workspace/spec/requests.d.ts.map +1 -1
- package/dist/entities/workspace/spec/requests.js +9 -0
- package/dist/entities/workspace/workspace.d.ts +6 -6
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +3 -2
- package/dist/helpers/object.d.ts +10 -0
- package/dist/helpers/object.d.ts.map +1 -0
- package/dist/helpers/{objectMerge.js → object.js} +6 -1
- package/dist/helpers/prettyPrintJson.d.ts +5 -1
- package/dist/helpers/prettyPrintJson.d.ts.map +1 -1
- package/dist/helpers/prettyPrintJson.js +31 -8
- package/dist/helpers/string.d.ts +10 -0
- package/dist/helpers/string.d.ts.map +1 -0
- package/dist/helpers/string.js +14 -0
- package/dist/spec-getters/getRequestBodyFromOperation.d.ts +1 -1
- package/dist/transforms/import-spec.d.ts +8 -3
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +13 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/entities/workspace/security-schemes/index.d.ts +0 -2
- package/dist/entities/workspace/security-schemes/index.d.ts.map +0 -1
- package/dist/entities/workspace/security-schemes/index.js +0 -1
- package/dist/entities/workspace/security-schemes/security-schemes.d.ts +0 -19
- package/dist/entities/workspace/security-schemes/security-schemes.d.ts.map +0 -1
- package/dist/entities/workspace/security-schemes/security-schemes.js +0 -15
- package/dist/helpers/objectMerge.d.ts +0 -5
- package/dist/helpers/objectMerge.d.ts.map +0 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** The uid here is actually the name key, called uid to re-use our mutators */
|
|
4
|
+
const uid = z.string().optional().default('default');
|
|
5
|
+
/* A description for security scheme. CommonMark syntax MAY be used for rich text representation. */
|
|
6
|
+
const description = z.string().optional();
|
|
7
|
+
/** A generic string value used for filling in fields */
|
|
8
|
+
const value = z.string().optional().default('');
|
|
9
|
+
const securitySchemeApiKey = z.object({
|
|
10
|
+
type: z.literal('apiKey'),
|
|
11
|
+
uid,
|
|
12
|
+
description,
|
|
13
|
+
/** REQUIRED. The name of the header, query or cookie parameter to be used. */
|
|
14
|
+
name: z.string().optional().default('default'),
|
|
15
|
+
/** REQUIRED. The location of the API key. Valid values are "query", "header" or "cookie". */
|
|
16
|
+
in: z.enum(['query', 'header', 'cookie']).optional().default('header'),
|
|
17
|
+
value,
|
|
18
|
+
});
|
|
19
|
+
const securitySchemeHttp = z.object({
|
|
20
|
+
type: z.literal('http'),
|
|
21
|
+
uid,
|
|
22
|
+
description,
|
|
23
|
+
/**
|
|
24
|
+
* REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as defined in
|
|
25
|
+
* [RFC7235]. The values used SHOULD be registered in the IANA Authentication Scheme registry.
|
|
26
|
+
*/
|
|
27
|
+
scheme: z.enum(['basic', 'bearer']).optional().default('basic'),
|
|
28
|
+
/**
|
|
29
|
+
* A hint to the client to identify how the bearer token is formatted.
|
|
30
|
+
* Bearer tokens are usually generated by an authorization server, so
|
|
31
|
+
* this information is primarily for documentation purposes.
|
|
32
|
+
*/
|
|
33
|
+
bearerFormat: z
|
|
34
|
+
.union([z.literal('JWT'), z.string()])
|
|
35
|
+
.optional()
|
|
36
|
+
.default('JWT'),
|
|
37
|
+
value,
|
|
38
|
+
secondValue: value,
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* REQUIRED. The authorization URL to be used for this flow. This MUST be in
|
|
42
|
+
* the form of a URL. The OAuth2 standard requires the use of TLS.
|
|
43
|
+
*/
|
|
44
|
+
const authorizationUrl = z.string().optional().default('https://scalar.com');
|
|
45
|
+
/** REQUIRED. The token URL to be used for this flow. This MUST be in the
|
|
46
|
+
* form of a URL. The OAuth2 standard requires the use of TLS.
|
|
47
|
+
*/
|
|
48
|
+
const tokenUrl = z.string().optional().default('https://scalar.com');
|
|
49
|
+
/** The URL to be used for obtaining refresh tokens. This MUST be in the form of a
|
|
50
|
+
* URL. The OAuth2 standard requires the use of TLS.
|
|
51
|
+
*/
|
|
52
|
+
const refreshUrl = z.string().optional();
|
|
53
|
+
/**
|
|
54
|
+
* REQUIRED. The available scopes for the OAuth2 security scheme. A map
|
|
55
|
+
* between the scope name and a short description for it. The map MAY be empty.
|
|
56
|
+
*/
|
|
57
|
+
const scopes = z
|
|
58
|
+
.union([
|
|
59
|
+
z.map(z.string(), z.string().optional()),
|
|
60
|
+
z.record(z.string(), z.string().optional()),
|
|
61
|
+
z.object({}),
|
|
62
|
+
])
|
|
63
|
+
.optional();
|
|
64
|
+
/** User selected scopes per flow */
|
|
65
|
+
const selectedScopes = z.array(z.string()).optional().default([]);
|
|
66
|
+
const oauthFlowSchema = z
|
|
67
|
+
.object({
|
|
68
|
+
/** Configuration for the OAuth Implicit flow */
|
|
69
|
+
implicit: z
|
|
70
|
+
.object({
|
|
71
|
+
authorizationUrl,
|
|
72
|
+
refreshUrl,
|
|
73
|
+
scopes,
|
|
74
|
+
selectedScopes,
|
|
75
|
+
token: value,
|
|
76
|
+
})
|
|
77
|
+
.optional(),
|
|
78
|
+
/** Configuration for the OAuth Resource Owner Password flow */
|
|
79
|
+
password: z
|
|
80
|
+
.object({
|
|
81
|
+
tokenUrl,
|
|
82
|
+
refreshUrl,
|
|
83
|
+
scopes,
|
|
84
|
+
username: value,
|
|
85
|
+
password: value,
|
|
86
|
+
selectedScopes,
|
|
87
|
+
token: value,
|
|
88
|
+
})
|
|
89
|
+
.optional(),
|
|
90
|
+
/** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
|
|
91
|
+
clientCredentials: z
|
|
92
|
+
.object({
|
|
93
|
+
tokenUrl,
|
|
94
|
+
refreshUrl,
|
|
95
|
+
scopes,
|
|
96
|
+
clientSecret: value,
|
|
97
|
+
selectedScopes,
|
|
98
|
+
token: value,
|
|
99
|
+
})
|
|
100
|
+
.optional(),
|
|
101
|
+
/** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.*/
|
|
102
|
+
authorizationCode: z
|
|
103
|
+
.object({
|
|
104
|
+
authorizationUrl,
|
|
105
|
+
tokenUrl,
|
|
106
|
+
refreshUrl,
|
|
107
|
+
scopes,
|
|
108
|
+
clientSecret: value,
|
|
109
|
+
selectedScopes,
|
|
110
|
+
token: value,
|
|
111
|
+
})
|
|
112
|
+
.optional(),
|
|
113
|
+
})
|
|
114
|
+
.optional()
|
|
115
|
+
.default({
|
|
116
|
+
implicit: {},
|
|
117
|
+
});
|
|
118
|
+
const securitySchemeOauth2 = z.object({
|
|
119
|
+
type: z.literal('oauth2'),
|
|
120
|
+
uid,
|
|
121
|
+
description,
|
|
122
|
+
/** REQUIRED. An object containing configuration information for the flow types supported. */
|
|
123
|
+
flows: oauthFlowSchema,
|
|
124
|
+
clientId: value,
|
|
125
|
+
redirectUri: z.string().url().optional().default(''),
|
|
126
|
+
});
|
|
127
|
+
const securitySchemeOpenId = z.object({
|
|
128
|
+
type: z.literal('openIdConnect'),
|
|
129
|
+
uid,
|
|
130
|
+
description,
|
|
131
|
+
/**
|
|
132
|
+
* REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the
|
|
133
|
+
* form of a URL. The OpenID Connect standard requires the use of TLS.
|
|
134
|
+
*/
|
|
135
|
+
openIdConnectUrl: z.string().url().optional().default('https://scalar.com'),
|
|
136
|
+
});
|
|
137
|
+
const securityScheme = z.union([
|
|
138
|
+
securitySchemeApiKey,
|
|
139
|
+
securitySchemeHttp,
|
|
140
|
+
securitySchemeOauth2,
|
|
141
|
+
securitySchemeOpenId,
|
|
142
|
+
]);
|
|
143
|
+
/** Create Security Scheme with defaults */
|
|
144
|
+
const createSecurityScheme = (payload) => securityScheme.parse(payload);
|
|
145
|
+
|
|
146
|
+
export { createSecurityScheme };
|
|
@@ -35,13 +35,13 @@ declare const serverSchema: z.ZodObject<{
|
|
|
35
35
|
enum?: string[] | undefined;
|
|
36
36
|
}, {
|
|
37
37
|
default?: string | undefined;
|
|
38
|
-
description?: string | undefined;
|
|
39
38
|
uid?: string | undefined;
|
|
39
|
+
description?: string | undefined;
|
|
40
40
|
enum?: string[] | undefined;
|
|
41
41
|
}>>>>;
|
|
42
42
|
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
url: string;
|
|
44
43
|
uid: string;
|
|
44
|
+
url: string;
|
|
45
45
|
description?: string | undefined;
|
|
46
46
|
variables?: Record<string, {
|
|
47
47
|
default: string;
|
|
@@ -50,13 +50,13 @@ declare const serverSchema: z.ZodObject<{
|
|
|
50
50
|
enum?: string[] | undefined;
|
|
51
51
|
}> | null | undefined;
|
|
52
52
|
}, {
|
|
53
|
-
url?: string | undefined;
|
|
54
|
-
description?: string | undefined;
|
|
55
53
|
uid?: string | undefined;
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
url?: string | undefined;
|
|
56
56
|
variables?: Record<string, {
|
|
57
57
|
default?: string | undefined;
|
|
58
|
-
description?: string | undefined;
|
|
59
58
|
uid?: string | undefined;
|
|
59
|
+
description?: string | undefined;
|
|
60
60
|
enum?: string[] | undefined;
|
|
61
61
|
}> | null | undefined;
|
|
62
62
|
}>;
|
|
@@ -70,8 +70,8 @@ export type Server = z.infer<typeof serverSchema>;
|
|
|
70
70
|
export type ServerPayload = z.input<typeof serverSchema>;
|
|
71
71
|
/** Create server helper */
|
|
72
72
|
export declare const createServer: (payload: ServerPayload) => {
|
|
73
|
-
url: string;
|
|
74
73
|
uid: string;
|
|
74
|
+
url: string;
|
|
75
75
|
description?: string | undefined;
|
|
76
76
|
variables?: Record<string, {
|
|
77
77
|
default: string;
|
|
@@ -236,7 +236,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
236
236
|
file?: File | undefined;
|
|
237
237
|
refUid?: string | undefined;
|
|
238
238
|
}[];
|
|
239
|
-
|
|
239
|
+
query: {
|
|
240
240
|
value: string;
|
|
241
241
|
key: string;
|
|
242
242
|
enabled: boolean;
|
|
@@ -244,7 +244,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
244
244
|
file?: File | undefined;
|
|
245
245
|
refUid?: string | undefined;
|
|
246
246
|
}[];
|
|
247
|
-
|
|
247
|
+
cookies: {
|
|
248
248
|
value: string;
|
|
249
249
|
key: string;
|
|
250
250
|
enabled: boolean;
|
|
@@ -252,7 +252,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
252
252
|
file?: File | undefined;
|
|
253
253
|
refUid?: string | undefined;
|
|
254
254
|
}[];
|
|
255
|
-
|
|
255
|
+
headers: {
|
|
256
256
|
value: string;
|
|
257
257
|
key: string;
|
|
258
258
|
enabled: boolean;
|
|
@@ -269,7 +269,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
269
269
|
file?: File | undefined;
|
|
270
270
|
refUid?: string | undefined;
|
|
271
271
|
}[] | undefined;
|
|
272
|
-
|
|
272
|
+
query?: {
|
|
273
273
|
value?: string | number | undefined;
|
|
274
274
|
description?: string | undefined;
|
|
275
275
|
key?: string | undefined;
|
|
@@ -277,7 +277,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
277
277
|
file?: File | undefined;
|
|
278
278
|
refUid?: string | undefined;
|
|
279
279
|
}[] | undefined;
|
|
280
|
-
|
|
280
|
+
cookies?: {
|
|
281
281
|
value?: string | number | undefined;
|
|
282
282
|
description?: string | undefined;
|
|
283
283
|
key?: string | undefined;
|
|
@@ -285,7 +285,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
285
285
|
file?: File | undefined;
|
|
286
286
|
refUid?: string | undefined;
|
|
287
287
|
}[] | undefined;
|
|
288
|
-
|
|
288
|
+
headers?: {
|
|
289
289
|
value?: string | number | undefined;
|
|
290
290
|
description?: string | undefined;
|
|
291
291
|
key?: string | undefined;
|
|
@@ -296,8 +296,8 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
296
296
|
}>>>;
|
|
297
297
|
auth: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
298
298
|
}, "strip", z.ZodTypeAny, {
|
|
299
|
-
name: string;
|
|
300
299
|
uid: string;
|
|
300
|
+
name: string;
|
|
301
301
|
parameters: {
|
|
302
302
|
path: {
|
|
303
303
|
value: string;
|
|
@@ -307,7 +307,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
307
307
|
file?: File | undefined;
|
|
308
308
|
refUid?: string | undefined;
|
|
309
309
|
}[];
|
|
310
|
-
|
|
310
|
+
query: {
|
|
311
311
|
value: string;
|
|
312
312
|
key: string;
|
|
313
313
|
enabled: boolean;
|
|
@@ -315,7 +315,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
315
315
|
file?: File | undefined;
|
|
316
316
|
refUid?: string | undefined;
|
|
317
317
|
}[];
|
|
318
|
-
|
|
318
|
+
cookies: {
|
|
319
319
|
value: string;
|
|
320
320
|
key: string;
|
|
321
321
|
enabled: boolean;
|
|
@@ -323,7 +323,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
323
323
|
file?: File | undefined;
|
|
324
324
|
refUid?: string | undefined;
|
|
325
325
|
}[];
|
|
326
|
-
|
|
326
|
+
headers: {
|
|
327
327
|
value: string;
|
|
328
328
|
key: string;
|
|
329
329
|
enabled: boolean;
|
|
@@ -355,8 +355,8 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
355
355
|
auth: Record<string, any>;
|
|
356
356
|
}, {
|
|
357
357
|
requestUid: string;
|
|
358
|
-
name?: string | undefined;
|
|
359
358
|
uid?: string | undefined;
|
|
359
|
+
name?: string | undefined;
|
|
360
360
|
parameters?: {
|
|
361
361
|
path?: {
|
|
362
362
|
value?: string | number | undefined;
|
|
@@ -366,7 +366,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
366
366
|
file?: File | undefined;
|
|
367
367
|
refUid?: string | undefined;
|
|
368
368
|
}[] | undefined;
|
|
369
|
-
|
|
369
|
+
query?: {
|
|
370
370
|
value?: string | number | undefined;
|
|
371
371
|
description?: string | undefined;
|
|
372
372
|
key?: string | undefined;
|
|
@@ -374,7 +374,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
374
374
|
file?: File | undefined;
|
|
375
375
|
refUid?: string | undefined;
|
|
376
376
|
}[] | undefined;
|
|
377
|
-
|
|
377
|
+
cookies?: {
|
|
378
378
|
value?: string | number | undefined;
|
|
379
379
|
description?: string | undefined;
|
|
380
380
|
key?: string | undefined;
|
|
@@ -382,7 +382,7 @@ declare const requestExampleSchema: z.ZodObject<{
|
|
|
382
382
|
file?: File | undefined;
|
|
383
383
|
refUid?: string | undefined;
|
|
384
384
|
}[] | undefined;
|
|
385
|
-
|
|
385
|
+
headers?: {
|
|
386
386
|
value?: string | number | undefined;
|
|
387
387
|
description?: string | undefined;
|
|
388
388
|
key?: string | undefined;
|
|
@@ -417,8 +417,8 @@ export type RequestExample = z.infer<typeof requestExampleSchema>;
|
|
|
417
417
|
export type RequestExamplePayload = z.input<typeof requestExampleSchema>;
|
|
418
418
|
/** Create request example helper */
|
|
419
419
|
export declare const createRequestExample: (payload: RequestExamplePayload) => {
|
|
420
|
-
name: string;
|
|
421
420
|
uid: string;
|
|
421
|
+
name: string;
|
|
422
422
|
parameters: {
|
|
423
423
|
path: {
|
|
424
424
|
value: string;
|
|
@@ -428,7 +428,7 @@ export declare const createRequestExample: (payload: RequestExamplePayload) => {
|
|
|
428
428
|
file?: File | undefined;
|
|
429
429
|
refUid?: string | undefined;
|
|
430
430
|
}[];
|
|
431
|
-
|
|
431
|
+
query: {
|
|
432
432
|
value: string;
|
|
433
433
|
key: string;
|
|
434
434
|
enabled: boolean;
|
|
@@ -436,7 +436,7 @@ export declare const createRequestExample: (payload: RequestExamplePayload) => {
|
|
|
436
436
|
file?: File | undefined;
|
|
437
437
|
refUid?: string | undefined;
|
|
438
438
|
}[];
|
|
439
|
-
|
|
439
|
+
cookies: {
|
|
440
440
|
value: string;
|
|
441
441
|
key: string;
|
|
442
442
|
enabled: boolean;
|
|
@@ -444,7 +444,7 @@ export declare const createRequestExample: (payload: RequestExamplePayload) => {
|
|
|
444
444
|
file?: File | undefined;
|
|
445
445
|
refUid?: string | undefined;
|
|
446
446
|
}[];
|
|
447
|
-
|
|
447
|
+
headers: {
|
|
448
448
|
value: string;
|
|
449
449
|
key: string;
|
|
450
450
|
enabled: boolean;
|
|
@@ -3,7 +3,12 @@ import type { OpenAPIV3_1 } from 'openapi-types';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import type { RequestExample } from './request-examples.js';
|
|
5
5
|
/** A single set of populated values for a sent request */
|
|
6
|
-
export type ResponseInstance = AxiosResponse
|
|
6
|
+
export type ResponseInstance = AxiosResponse & {
|
|
7
|
+
/**
|
|
8
|
+
* Time in ms the request took
|
|
9
|
+
**/
|
|
10
|
+
duration: number;
|
|
11
|
+
};
|
|
7
12
|
/** A single request/response set to save to the history stack */
|
|
8
13
|
export type RequestEvent = {
|
|
9
14
|
request: RequestExample;
|
|
@@ -16,6 +21,7 @@ declare const requestSchema: z.ZodObject<{
|
|
|
16
21
|
ref: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
17
22
|
path: z.ZodString;
|
|
18
23
|
collectionRef: z.ZodOptional<z.ZodString>;
|
|
24
|
+
/** A single request/response set to save to the history stack */
|
|
19
25
|
isExternal: z.ZodBoolean;
|
|
20
26
|
}, "strip", z.ZodTypeAny, {
|
|
21
27
|
path: string;
|
|
@@ -46,15 +52,23 @@ declare const requestSchema: z.ZodObject<{
|
|
|
46
52
|
cookies: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
47
53
|
}, "strip", z.ZodTypeAny, {
|
|
48
54
|
path: Record<string, any>;
|
|
55
|
+
query: Record<string, any>;
|
|
49
56
|
cookies: Record<string, any>;
|
|
50
57
|
headers: Record<string, any>;
|
|
51
|
-
query: Record<string, any>;
|
|
52
58
|
}, {
|
|
53
59
|
path: Record<string, any>;
|
|
60
|
+
query: Record<string, any>;
|
|
54
61
|
cookies: Record<string, any>;
|
|
55
62
|
headers: Record<string, any>;
|
|
56
|
-
query: Record<string, any>;
|
|
57
63
|
}>>;
|
|
64
|
+
/**
|
|
65
|
+
* A declaration of which security mechanisms can be used across the API. The list of
|
|
66
|
+
* values includes alternative security requirement objects that can be used. Only
|
|
67
|
+
* one of the security requirement objects need to be satisfied to authorize a request.
|
|
68
|
+
* Individual operations can override this definition. To make security optional, an empty
|
|
69
|
+
* security requirement ({}) can be included in the array.
|
|
70
|
+
*/
|
|
71
|
+
security: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>>, "many">>;
|
|
58
72
|
/**
|
|
59
73
|
* The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the
|
|
60
74
|
* HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the
|
|
@@ -67,15 +81,15 @@ declare const requestSchema: z.ZodObject<{
|
|
|
67
81
|
history: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
|
|
68
82
|
}, "strip", z.ZodTypeAny, {
|
|
69
83
|
path: string;
|
|
70
|
-
tags: string[];
|
|
71
84
|
uid: string;
|
|
85
|
+
tags: string[];
|
|
72
86
|
childUids: string[];
|
|
73
87
|
method: "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "TRACE" | "CONNECT" | "DELETE" | "OPTIONS";
|
|
74
88
|
parameters: {
|
|
75
89
|
path: Record<string, any>;
|
|
90
|
+
query: Record<string, any>;
|
|
76
91
|
cookies: Record<string, any>;
|
|
77
92
|
headers: Record<string, any>;
|
|
78
|
-
query: Record<string, any>;
|
|
79
93
|
};
|
|
80
94
|
ref: {
|
|
81
95
|
path: string;
|
|
@@ -83,23 +97,25 @@ declare const requestSchema: z.ZodObject<{
|
|
|
83
97
|
collectionRef?: string | undefined;
|
|
84
98
|
} | null;
|
|
85
99
|
history: any[];
|
|
86
|
-
summary?: string | undefined;
|
|
87
100
|
description?: string | undefined;
|
|
101
|
+
summary?: string | undefined;
|
|
102
|
+
security?: Record<string, string[]>[] | undefined;
|
|
88
103
|
operationId?: string | undefined;
|
|
89
104
|
requestBody?: any;
|
|
90
105
|
}, {
|
|
91
106
|
path?: string | undefined;
|
|
92
|
-
|
|
107
|
+
uid?: string | undefined;
|
|
93
108
|
description?: string | undefined;
|
|
109
|
+
summary?: string | undefined;
|
|
110
|
+
security?: Record<string, string[] | undefined>[] | undefined;
|
|
94
111
|
tags?: string[] | undefined;
|
|
95
|
-
uid?: string | undefined;
|
|
96
112
|
childUids?: (string | undefined)[] | undefined;
|
|
97
113
|
method?: "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "TRACE" | "CONNECT" | "DELETE" | "OPTIONS" | undefined;
|
|
98
114
|
parameters?: {
|
|
99
115
|
path: Record<string, any>;
|
|
116
|
+
query: Record<string, any>;
|
|
100
117
|
cookies: Record<string, any>;
|
|
101
118
|
headers: Record<string, any>;
|
|
102
|
-
query: Record<string, any>;
|
|
103
119
|
} | undefined;
|
|
104
120
|
ref?: {
|
|
105
121
|
path: string;
|
|
@@ -124,15 +140,15 @@ export type RequestPayload = z.input<typeof requestSchema> & {
|
|
|
124
140
|
/** Create request helper */
|
|
125
141
|
export declare const createRequest: (payload: RequestPayload) => {
|
|
126
142
|
path: string;
|
|
127
|
-
tags: string[];
|
|
128
143
|
uid: string;
|
|
144
|
+
tags: string[];
|
|
129
145
|
childUids: string[];
|
|
130
146
|
method: "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "TRACE" | "CONNECT" | "DELETE" | "OPTIONS";
|
|
131
147
|
parameters: {
|
|
132
148
|
path: Record<string, any>;
|
|
149
|
+
query: Record<string, any>;
|
|
133
150
|
cookies: Record<string, any>;
|
|
134
151
|
headers: Record<string, any>;
|
|
135
|
-
query: Record<string, any>;
|
|
136
152
|
};
|
|
137
153
|
ref: {
|
|
138
154
|
path: string;
|
|
@@ -140,8 +156,9 @@ export declare const createRequest: (payload: RequestPayload) => {
|
|
|
140
156
|
collectionRef?: string | undefined;
|
|
141
157
|
} | null;
|
|
142
158
|
history: any[];
|
|
143
|
-
summary?: string | undefined;
|
|
144
159
|
description?: string | undefined;
|
|
160
|
+
summary?: string | undefined;
|
|
161
|
+
security?: Record<string, string[]>[] | undefined;
|
|
145
162
|
operationId?: string | undefined;
|
|
146
163
|
requestBody?: any;
|
|
147
164
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../../src/entities/workspace/spec/requests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../../src/entities/workspace/spec/requests.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C;;QAEI;IACJ,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,iEAAiE;AACjE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,cAAc,CAAA;IACvB,QAAQ,EAAE,gBAAgB,CAAA;CAC3B,CAAA;AAQD,QAAA,MAAM,aAAa;;;;;;;QAZnB,iEAAiE;;;;;;;;;;;IAoB/D;;OAEG;;IAEH,kDAAkD;;IAElD,mHAAmH;;IAEnH;;;OAGG;;;;;;;;;;;;;;;;;;IAUH;;;;;;OAMG;;IAEH;;;;;OAKG;;IAEH,0CAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG1C,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG;IACpD,YAAY,CAAC,EAAE,WAAW,CAAC,2BAA2B,CAAA;CACvD,CAAA;AACD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG;IAC3D,YAAY,CAAC,EAAE,WAAW,CAAC,2BAA2B,CAAA;CACvD,CAAA;AAED,4BAA4B;AAC5B,eAAO,MAAM,aAAa,YAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;CACR,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { $refSchema } from './refs.js';
|
|
3
3
|
import { REQUEST_METHODS } from '../../../helpers/httpMethods.js';
|
|
4
4
|
import { nanoidSchema } from '../shared/utility.js';
|
|
5
|
+
import { securityRequirement } from '../security/security-requirement.js';
|
|
5
6
|
import { deepMerge } from '../../../helpers/deepMerge.js';
|
|
6
7
|
|
|
7
8
|
const requestBodySchema = z.any();
|
|
@@ -35,6 +36,14 @@ const requestSchema = z.object({
|
|
|
35
36
|
cookies: parametersSchema,
|
|
36
37
|
})
|
|
37
38
|
.default({ path: {}, query: {}, headers: {}, cookies: {} }),
|
|
39
|
+
/**
|
|
40
|
+
* A declaration of which security mechanisms can be used across the API. The list of
|
|
41
|
+
* values includes alternative security requirement objects that can be used. Only
|
|
42
|
+
* one of the security requirement objects need to be satisfied to authorize a request.
|
|
43
|
+
* Individual operations can override this definition. To make security optional, an empty
|
|
44
|
+
* security requirement ({}) can be included in the array.
|
|
45
|
+
*/
|
|
46
|
+
security: z.array(securityRequirement).optional(),
|
|
38
47
|
/**
|
|
39
48
|
* The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the
|
|
40
49
|
* HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the
|
|
@@ -13,17 +13,17 @@ declare const workspaceSchema: z.ZodObject<{
|
|
|
13
13
|
/** List of all cookie uids in a given workspace */
|
|
14
14
|
cookieUids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
16
|
uid: string;
|
|
17
|
+
description: string;
|
|
18
|
+
name: string;
|
|
19
19
|
isReadOnly: boolean;
|
|
20
20
|
collectionUids: string[];
|
|
21
21
|
environmentUids: string[];
|
|
22
22
|
cookieUids: string[];
|
|
23
23
|
}, {
|
|
24
|
-
name?: string | undefined;
|
|
25
|
-
description?: string | undefined;
|
|
26
24
|
uid?: string | undefined;
|
|
25
|
+
description?: string | undefined;
|
|
26
|
+
name?: string | undefined;
|
|
27
27
|
isReadOnly?: boolean | undefined;
|
|
28
28
|
collectionUids?: string[] | undefined;
|
|
29
29
|
environmentUids?: string[] | undefined;
|
|
@@ -33,9 +33,9 @@ declare const workspaceSchema: z.ZodObject<{
|
|
|
33
33
|
export type Workspace = z.infer<typeof workspaceSchema>;
|
|
34
34
|
export type WorkspacePayload = z.input<typeof workspaceSchema>;
|
|
35
35
|
export declare const createWorkspace: (payload: WorkspacePayload) => {
|
|
36
|
-
name: string;
|
|
37
|
-
description: string;
|
|
38
36
|
uid: string;
|
|
37
|
+
description: string;
|
|
38
|
+
name: string;
|
|
39
39
|
isReadOnly: boolean;
|
|
40
40
|
collectionUids: string[];
|
|
41
41
|
environmentUids: string[];
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ export * from './httpStatusCodes.js';
|
|
|
6
6
|
export * from './iterateTitle.js';
|
|
7
7
|
export * from './normalizeMimeType.js';
|
|
8
8
|
export * from './normalizeMimeTypeObject.js';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './object.js';
|
|
10
10
|
export * from './parse.js';
|
|
11
11
|
export * from './prettyPrintJson.js';
|
|
12
12
|
export * from './schema-model.js';
|
|
13
13
|
export * from './ssrState.js';
|
|
14
|
+
export * from './string.js';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA;AACzC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA;AACzC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -6,8 +6,9 @@ export { httpStatusCodes } from './httpStatusCodes.js';
|
|
|
6
6
|
export { iterateTitle } from './iterateTitle.js';
|
|
7
7
|
export { normalizeMimeType } from './normalizeMimeType.js';
|
|
8
8
|
export { normalizeMimeTypeObject } from './normalizeMimeTypeObject.js';
|
|
9
|
-
export { objectMerge } from './
|
|
9
|
+
export { getObjectKeys, objectMerge } from './object.js';
|
|
10
10
|
export { formatJsonOrYamlString, isJsonString, json, parseJsonOrYaml, transformToJson, yaml } from './parse.js';
|
|
11
|
-
export { prettyPrintJson } from './prettyPrintJson.js';
|
|
11
|
+
export { prettyPrintJson, replaceCircularDependencies } from './prettyPrintJson.js';
|
|
12
12
|
export { schemaModel } from './schema-model.js';
|
|
13
13
|
export { defaultStateFactory, ssrState } from './ssrState.js';
|
|
14
|
+
export { camelToTitleWords } from './string.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overwrite a target object a new replacement object handling removed keys
|
|
3
|
+
**/
|
|
4
|
+
export declare function objectMerge<A extends object, B extends object>(target: A, replacement: B): B;
|
|
5
|
+
/**
|
|
6
|
+
* Type safe version of Object.keys
|
|
7
|
+
* Can probably remove this whenever typescript adds it
|
|
8
|
+
*/
|
|
9
|
+
export declare const getObjectKeys: <T extends object>(obj: T) => (keyof T)[];
|
|
10
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/helpers/object.ts"],"names":[],"mappings":"AACA;;IAEI;AACJ,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC5D,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,CAAC,KAYf;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,0BAA2B,CAAC,KAAG,CAAC,MAAM,CAAC,CAAC,EACjC,CAAA"}
|
|
@@ -12,5 +12,10 @@ function objectMerge(target, replacement) {
|
|
|
12
12
|
Object.assign(target, replacement);
|
|
13
13
|
return target;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Type safe version of Object.keys
|
|
17
|
+
* Can probably remove this whenever typescript adds it
|
|
18
|
+
*/
|
|
19
|
+
const getObjectKeys = (obj) => Object.keys(obj);
|
|
15
20
|
|
|
16
|
-
export { objectMerge };
|
|
21
|
+
export { getObjectKeys, objectMerge };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Takes JSON and formats it.
|
|
3
3
|
**/
|
|
4
|
-
export declare const prettyPrintJson: (value: any) =>
|
|
4
|
+
export declare const prettyPrintJson: (value: string | number | any[] | Record<any, any>) => string;
|
|
5
|
+
/**
|
|
6
|
+
* JSON.stringify, but with circular dependencies replaced with '[Circular]'
|
|
7
|
+
*/
|
|
8
|
+
export declare function replaceCircularDependencies(content: any): string;
|
|
5
9
|
//# sourceMappingURL=prettyPrintJson.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettyPrintJson.d.ts","sourceRoot":"","sources":["../../src/helpers/prettyPrintJson.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prettyPrintJson.d.ts","sourceRoot":"","sources":["../../src/helpers/prettyPrintJson.ts"],"names":[],"mappings":"AAEA;;IAEI;AACJ,eAAO,MAAM,eAAe,UACnB,MAAM,GAAG,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,WAsBlD,CAAA;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,GAAG,UAiBvD"}
|
|
@@ -1,19 +1,42 @@
|
|
|
1
|
+
import { isJsonString } from './parse.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Takes JSON and formats it.
|
|
3
5
|
**/
|
|
4
6
|
const prettyPrintJson = (value) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
if (typeof value === 'string') {
|
|
8
|
+
// JSON string
|
|
9
|
+
if (isJsonString(value)) {
|
|
7
10
|
return JSON.stringify(JSON.parse(value), null, 2);
|
|
8
11
|
}
|
|
9
|
-
|
|
12
|
+
// Regular string
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
// Object
|
|
16
|
+
if (typeof value === 'object') {
|
|
17
|
+
try {
|
|
10
18
|
return JSON.stringify(value, null, 2);
|
|
11
19
|
}
|
|
20
|
+
catch {
|
|
21
|
+
return replaceCircularDependencies(value);
|
|
22
|
+
}
|
|
12
23
|
}
|
|
13
|
-
|
|
14
|
-
console.log('[prettyPrintJson] Error parsing JSON', value);
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
24
|
+
return value.toString();
|
|
17
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* JSON.stringify, but with circular dependencies replaced with '[Circular]'
|
|
28
|
+
*/
|
|
29
|
+
function replaceCircularDependencies(content) {
|
|
30
|
+
const cache = new Set();
|
|
31
|
+
return JSON.stringify(content, (key, value) => {
|
|
32
|
+
if (typeof value === 'object' && value !== null) {
|
|
33
|
+
if (cache.has(value)) {
|
|
34
|
+
return '[Circular]';
|
|
35
|
+
}
|
|
36
|
+
cache.add(value);
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}, 2);
|
|
40
|
+
}
|
|
18
41
|
|
|
19
|
-
export { prettyPrintJson };
|
|
42
|
+
export { prettyPrintJson, replaceCircularDependencies };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A collection of string manipulation helper methods
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Converts a camelCase string to Title Words with spaces
|
|
6
|
+
*
|
|
7
|
+
* @param camelStr - MUST be in camelCase or this might not work
|
|
8
|
+
*/
|
|
9
|
+
export declare const camelToTitleWords: (camelStr: string) => string;
|
|
10
|
+
//# sourceMappingURL=string.d.ts.map
|