@scalar/oas-utils 0.2.102 → 0.2.104

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/entities/spec/index.d.ts +1 -0
  3. package/dist/entities/spec/index.d.ts.map +1 -1
  4. package/dist/entities/spec/index.js +2 -1
  5. package/dist/entities/spec/operation.d.ts +243 -0
  6. package/dist/entities/spec/operation.d.ts.map +1 -0
  7. package/dist/entities/spec/operation.js +9 -0
  8. package/dist/entities/spec/request-examples.d.ts +267 -55
  9. package/dist/entities/spec/request-examples.d.ts.map +1 -1
  10. package/dist/entities/spec/request-examples.js +43 -12
  11. package/dist/entities/spec/requests.d.ts +0 -2
  12. package/dist/entities/spec/requests.d.ts.map +1 -1
  13. package/dist/entities/workspace/workspace.d.ts +19 -0
  14. package/dist/entities/workspace/workspace.d.ts.map +1 -1
  15. package/dist/entities/workspace/workspace.js +11 -0
  16. package/dist/helpers/ensure-protocol.d.ts +3 -0
  17. package/dist/helpers/ensure-protocol.d.ts.map +1 -0
  18. package/dist/helpers/ensure-protocol.js +11 -0
  19. package/dist/helpers/fetchWithProxyFallback.d.ts +1 -1
  20. package/dist/helpers/fetchWithProxyFallback.d.ts.map +1 -1
  21. package/dist/helpers/index.d.ts +2 -1
  22. package/dist/helpers/index.d.ts.map +1 -1
  23. package/dist/helpers/index.js +2 -1
  24. package/dist/helpers/merge-urls.d.ts +15 -0
  25. package/dist/helpers/merge-urls.d.ts.map +1 -0
  26. package/dist/helpers/merge-urls.js +79 -0
  27. package/dist/helpers/redirectToProxy.d.ts.map +1 -1
  28. package/dist/helpers/redirectToProxy.js +3 -2
  29. package/dist/helpers/regexHelpers.d.ts +4 -0
  30. package/dist/helpers/regexHelpers.d.ts.map +1 -1
  31. package/dist/helpers/regexHelpers.js +4 -0
  32. package/dist/migrations/v-2.5.0/migration.d.ts.map +1 -1
  33. package/dist/migrations/v-2.5.0/migration.js +11 -0
  34. package/dist/spec-getters/getRequestBodyFromOperation.d.ts +4 -10
  35. package/dist/spec-getters/getRequestBodyFromOperation.d.ts.map +1 -1
  36. package/dist/spec-getters/getRequestBodyFromOperation.js +29 -57
  37. package/dist/transforms/import-spec.d.ts +1 -3
  38. package/dist/transforms/import-spec.d.ts.map +1 -1
  39. package/dist/transforms/import-spec.js +49 -11
  40. package/package.json +5 -7
  41. package/dist/helpers/concatenateUrlAndPath.d.ts +0 -5
  42. package/dist/helpers/concatenateUrlAndPath.d.ts.map +0 -1
  43. package/dist/helpers/concatenateUrlAndPath.js +0 -17
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.104
4
+
5
+ ### Patch Changes
6
+
7
+ - f500435: chore: stricter TypeScript configuration
8
+ - da5cf08: fix: add security requirements for operations
9
+ - b5727ef: feat: allow pre-selecting multiple and complex auth
10
+ - 4de3124: feat: improve parameter zod schema
11
+ - 34e6f52: feat: upgrade to stricter tsconfig
12
+ - Updated dependencies [f500435]
13
+ - Updated dependencies [b5727ef]
14
+ - Updated dependencies [34e6f52]
15
+ - Updated dependencies [f2b082a]
16
+ - @scalar/types@0.0.32
17
+ - @scalar/themes@0.9.66
18
+
19
+ ## 0.2.103
20
+
21
+ ### Patch Changes
22
+
23
+ - 0f5df68: chore: refactored send request with extensive test suite
24
+ - 937f791: chore: alias request to operation
25
+ - Updated dependencies [a30e7cc]
26
+ - @scalar/types@0.0.31
27
+ - @scalar/themes@0.9.65
28
+
3
29
  ## 0.2.102
4
30
 
5
31
  ### Patch Changes
@@ -8,4 +8,5 @@ export * from './security.js';
8
8
  export * from './x-scalar-environments.js';
9
9
  type FetchRequest = Request;
10
10
  export type { FetchRequest };
11
+ export { type Operation, type OperationPayload, operationSchema, } from './operation.js';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AAEvC,KAAK,YAAY,GAAG,OAAO,CAAA;AAC3B,YAAY,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AAEvC,KAAK,YAAY,GAAG,OAAO,CAAA;AAC3B,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,OAAO,EACL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,eAAe,GAChB,MAAM,aAAa,CAAA"}
@@ -1,8 +1,9 @@
1
1
  export { collectionSchema, extendedCollectionSchema, oasCollectionSchema } from './collection.js';
2
2
  export { oasServerSchema, oasServerVariableSchema, serverSchema } from './server.js';
3
3
  export { oasRequestSchema, requestMethods, requestSchema } from './requests.js';
4
- export { convertExampleToXScalar, createExampleFromRequest, createParamInstance, exampleBodyMime, exampleRequestBodyEncoding, exampleRequestBodySchema, requestExampleParametersSchema, requestExampleSchema, xScalarExampleBodySchema, xScalarExampleSchema, xScalarFileValueSchema, xScalarFormDataValue } from './request-examples.js';
4
+ export { convertExampleToXScalar, createExampleFromRequest, createParamInstance, exampleBodyMime, exampleRequestBodyEncoding, exampleRequestBodySchema, parameterArrayToObject, requestExampleParametersSchema, requestExampleSchema, xScalarExampleBodySchema, xScalarExampleSchema, xScalarFileValueSchema, xScalarFormDataValue } from './request-examples.js';
5
5
  export { oasContactSchema, oasExternalDocumentationSchema, oasInfoSchema, oasLicenseSchema, oasTagSchema, tagSchema, xScalarNestedSchema } from './spec-objects.js';
6
6
  export { oasParameterSchema, parameterStyleSchema, parameterTypeSchema } from './parameters.js';
7
7
  export { oasSecurityRequirementSchema, oasSecuritySchemeSchema, pkceOptions, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeApiKeyIn, securitySchemeSchema } from './security.js';
8
8
  export { xScalarEnvVarSchema, xScalarEnvironmentSchema, xScalarEnvironmentsSchema } from './x-scalar-environments.js';
9
+ export { operationSchema } from './operation.js';
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Aliases Request to Operation which is closer to the spec,
3
+ * also will not conflict with the builtin Request class
4
+ */
5
+ import { type RequestPayload, type Request as RequestType } from './requests.js';
6
+ export type Operation = RequestType;
7
+ export type OperationPayload = RequestPayload;
8
+ export declare const operationSchema: import("zod").ZodObject<import("zod").objectUtil.extendShape<Omit<{
9
+ tags: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
10
+ summary: import("zod").ZodOptional<import("zod").ZodString>;
11
+ description: import("zod").ZodOptional<import("zod").ZodString>;
12
+ operationId: import("zod").ZodOptional<import("zod").ZodString>;
13
+ security: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>>>, "many">>;
14
+ requestBody: import("zod").ZodOptional<import("zod").ZodAny>;
15
+ parameters: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
16
+ in: import("zod").ZodEnum<["path", "query", "header", "cookie"]>;
17
+ name: import("zod").ZodString;
18
+ description: import("zod").ZodOptional<import("zod").ZodString>;
19
+ required: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
20
+ deprecated: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
21
+ schema: import("zod").ZodOptional<import("zod").ZodUnknown>;
22
+ content: import("zod").ZodOptional<import("zod").ZodUnknown>;
23
+ style: import("zod").ZodOptional<import("zod").ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
24
+ example: import("zod").ZodOptional<import("zod").ZodUnknown>;
25
+ examples: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
26
+ value: import("zod").ZodUnknown;
27
+ summary: import("zod").ZodOptional<import("zod").ZodString>;
28
+ }, "strip", import("zod").ZodTypeAny, {
29
+ value?: unknown;
30
+ summary?: string | undefined;
31
+ }, {
32
+ value?: unknown;
33
+ summary?: string | undefined;
34
+ }>>>;
35
+ }, "strip", import("zod").ZodTypeAny, {
36
+ required: boolean;
37
+ name: string;
38
+ in: "path" | "query" | "header" | "cookie";
39
+ deprecated: boolean;
40
+ description?: string | undefined;
41
+ example?: unknown;
42
+ schema?: unknown;
43
+ content?: unknown;
44
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
45
+ examples?: Record<string, {
46
+ value?: unknown;
47
+ summary?: string | undefined;
48
+ }> | undefined;
49
+ }, {
50
+ name: string;
51
+ in: "path" | "query" | "header" | "cookie";
52
+ required?: boolean | undefined;
53
+ description?: string | undefined;
54
+ example?: unknown;
55
+ deprecated?: boolean | undefined;
56
+ schema?: unknown;
57
+ content?: unknown;
58
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
59
+ examples?: Record<string, {
60
+ value?: unknown;
61
+ summary?: string | undefined;
62
+ }> | undefined;
63
+ }>, "many">>;
64
+ externalDocs: import("zod").ZodOptional<import("zod").ZodObject<{
65
+ description: import("zod").ZodOptional<import("zod").ZodString>;
66
+ url: import("zod").ZodDefault<import("zod").ZodString>;
67
+ }, "strip", import("zod").ZodTypeAny, {
68
+ url: string;
69
+ description?: string | undefined;
70
+ }, {
71
+ description?: string | undefined;
72
+ url?: string | undefined;
73
+ }>>;
74
+ deprecated: import("zod").ZodOptional<import("zod").ZodBoolean>;
75
+ responses: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
76
+ 'x-scalar-examples': import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
77
+ name: import("zod").ZodOptional<import("zod").ZodString>;
78
+ body: import("zod").ZodOptional<import("zod").ZodObject<{
79
+ encoding: import("zod").ZodEnum<["application/json", "text/plain", "text/html", "application/javascript", "application/xml", "application/yaml", "application/edn", "application/octet-stream", "application/x-www-form-urlencoded", "multipart/form-data", "binary"]>;
80
+ content: import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>, import("zod").ZodString]>;
81
+ file: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodObject<{
82
+ url: import("zod").ZodString;
83
+ base64: import("zod").ZodOptional<import("zod").ZodString>;
84
+ }, "strip", import("zod").ZodTypeAny, {
85
+ url: string;
86
+ base64?: string | undefined;
87
+ }, {
88
+ url: string;
89
+ base64?: string | undefined;
90
+ }>>>;
91
+ }, "strip", import("zod").ZodTypeAny, {
92
+ content: string | Record<string, any>;
93
+ encoding: "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data" | "binary";
94
+ file?: {
95
+ url: string;
96
+ base64?: string | undefined;
97
+ } | null | undefined;
98
+ }, {
99
+ content: string | Record<string, any>;
100
+ encoding: "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data" | "binary";
101
+ file?: {
102
+ url: string;
103
+ base64?: string | undefined;
104
+ } | null | undefined;
105
+ }>>;
106
+ parameters: import("zod").ZodObject<{
107
+ path: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
108
+ query: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
109
+ headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
110
+ cookies: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
111
+ }, "strip", import("zod").ZodTypeAny, {
112
+ path?: Record<string, string> | undefined;
113
+ cookies?: Record<string, string> | undefined;
114
+ query?: Record<string, string> | undefined;
115
+ headers?: Record<string, string> | undefined;
116
+ }, {
117
+ path?: Record<string, string> | undefined;
118
+ cookies?: Record<string, string> | undefined;
119
+ query?: Record<string, string> | undefined;
120
+ headers?: Record<string, string> | undefined;
121
+ }>;
122
+ }, "strip", import("zod").ZodTypeAny, {
123
+ parameters: {
124
+ path?: Record<string, string> | undefined;
125
+ cookies?: Record<string, string> | undefined;
126
+ query?: Record<string, string> | undefined;
127
+ headers?: Record<string, string> | undefined;
128
+ };
129
+ name?: string | undefined;
130
+ body?: {
131
+ content: string | Record<string, any>;
132
+ encoding: "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data" | "binary";
133
+ file?: {
134
+ url: string;
135
+ base64?: string | undefined;
136
+ } | null | undefined;
137
+ } | undefined;
138
+ }, {
139
+ parameters: {
140
+ path?: Record<string, string> | undefined;
141
+ cookies?: Record<string, string> | undefined;
142
+ query?: Record<string, string> | undefined;
143
+ headers?: Record<string, string> | undefined;
144
+ };
145
+ name?: string | undefined;
146
+ body?: {
147
+ content: string | Record<string, any>;
148
+ encoding: "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data" | "binary";
149
+ file?: {
150
+ url: string;
151
+ base64?: string | undefined;
152
+ } | null | undefined;
153
+ } | undefined;
154
+ }>>>;
155
+ 'x-internal': import("zod").ZodOptional<import("zod").ZodBoolean>;
156
+ 'x-scalar-ignore': import("zod").ZodOptional<import("zod").ZodBoolean>;
157
+ }, "x-scalar-examples">, {
158
+ type: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodLiteral<"request">>>;
159
+ uid: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
160
+ path: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
161
+ method: import("zod").ZodDefault<import("zod").ZodEnum<["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"]>>;
162
+ servers: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, "many">>;
163
+ selectedServerUid: import("zod").ZodDefault<import("zod").ZodString>;
164
+ examples: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, "many">>;
165
+ selectedSecuritySchemeUids: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, import("zod").ZodArray<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, "many">]>, "many">>;
166
+ }>, "strip", import("zod").ZodTypeAny, {
167
+ path: string;
168
+ type: "request";
169
+ uid: string;
170
+ selectedSecuritySchemeUids: (string | string[])[];
171
+ selectedServerUid: string;
172
+ servers: string[];
173
+ examples: string[];
174
+ method: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace";
175
+ description?: string | undefined;
176
+ summary?: string | undefined;
177
+ externalDocs?: {
178
+ url: string;
179
+ description?: string | undefined;
180
+ } | undefined;
181
+ 'x-internal'?: boolean | undefined;
182
+ 'x-scalar-ignore'?: boolean | undefined;
183
+ security?: Record<string, string[]>[] | undefined;
184
+ tags?: string[] | undefined;
185
+ deprecated?: boolean | undefined;
186
+ operationId?: string | undefined;
187
+ parameters?: {
188
+ required: boolean;
189
+ name: string;
190
+ in: "path" | "query" | "header" | "cookie";
191
+ deprecated: boolean;
192
+ description?: string | undefined;
193
+ example?: unknown;
194
+ schema?: unknown;
195
+ content?: unknown;
196
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
197
+ examples?: Record<string, {
198
+ value?: unknown;
199
+ summary?: string | undefined;
200
+ }> | undefined;
201
+ }[] | undefined;
202
+ requestBody?: any;
203
+ responses?: Record<string, any> | undefined;
204
+ }, {
205
+ path?: string | undefined;
206
+ type?: "request" | undefined;
207
+ uid?: string | undefined;
208
+ description?: string | undefined;
209
+ summary?: string | undefined;
210
+ externalDocs?: {
211
+ description?: string | undefined;
212
+ url?: string | undefined;
213
+ } | undefined;
214
+ 'x-internal'?: boolean | undefined;
215
+ 'x-scalar-ignore'?: boolean | undefined;
216
+ security?: Record<string, string[] | undefined>[] | undefined;
217
+ selectedSecuritySchemeUids?: (string | (string | undefined)[] | undefined)[] | undefined;
218
+ selectedServerUid?: string | undefined;
219
+ servers?: (string | undefined)[] | undefined;
220
+ tags?: string[] | undefined;
221
+ deprecated?: boolean | undefined;
222
+ examples?: (string | undefined)[] | undefined;
223
+ operationId?: string | undefined;
224
+ parameters?: {
225
+ name: string;
226
+ in: "path" | "query" | "header" | "cookie";
227
+ required?: boolean | undefined;
228
+ description?: string | undefined;
229
+ example?: unknown;
230
+ deprecated?: boolean | undefined;
231
+ schema?: unknown;
232
+ content?: unknown;
233
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
234
+ examples?: Record<string, {
235
+ value?: unknown;
236
+ summary?: string | undefined;
237
+ }> | undefined;
238
+ }[] | undefined;
239
+ requestBody?: any;
240
+ responses?: Record<string, any> | undefined;
241
+ method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
242
+ }>;
243
+ //# sourceMappingURL=operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,OAAO,IAAI,WAAW,EAE5B,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAgB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { requestSchema } from './requests.js';
2
+
3
+ /**
4
+ * Aliases Request to Operation which is closer to the spec,
5
+ * also will not conflict with the builtin Request class
6
+ */
7
+ const operationSchema = requestSchema;
8
+
9
+ export { operationSchema };