@scalar/oas-utils 0.3.1 → 0.4.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/CHANGELOG.md +22 -0
- package/dist/entities/spec/collection.d.ts +6 -12
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +1 -1
- package/dist/entities/spec/collection.js.map +2 -2
- package/dist/entities/spec/operation.d.ts +3 -0
- package/dist/entities/spec/operation.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +1 -1
- package/dist/entities/spec/request-examples.js.map +2 -2
- package/dist/entities/spec/requests.d.ts +8 -0
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/requests.js +2 -0
- package/dist/entities/spec/requests.js.map +2 -2
- package/dist/helpers/http-methods.js +9 -9
- package/dist/helpers/http-methods.js.map +1 -1
- package/dist/helpers/pretty-print-json.d.ts.map +1 -1
- package/dist/helpers/pretty-print-json.js.map +2 -2
- 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 +30 -9
- package/dist/transforms/import-spec.js.map +2 -2
- package/package.json +4 -4
- package/dist/entities/spec/operation.test.js +0 -43
- package/dist/entities/spec/operation.test.js.map +0 -7
- package/dist/entities/spec/parameters.test.js +0 -80
- package/dist/entities/spec/parameters.test.js.map +0 -7
- package/dist/entities/spec/request-example.test.js +0 -636
- package/dist/entities/spec/request-example.test.js.map +0 -7
- package/dist/entities/spec/server.test.js +0 -120
- package/dist/entities/spec/server.test.js.map +0 -7
- package/dist/entities/spec/spec-objects.test.js +0 -205
- package/dist/entities/spec/spec-objects.test.js.map +0 -7
- package/dist/entities/spec/x-scalar-environments.test.js +0 -11
- package/dist/entities/spec/x-scalar-environments.test.js.map +0 -7
- package/dist/entities/spec/x-scalar-secrets.test.js +0 -11
- package/dist/entities/spec/x-scalar-secrets.test.js.map +0 -7
- package/dist/helpers/ensure-protocol.test.js +0 -70
- package/dist/helpers/ensure-protocol.test.js.map +0 -7
- package/dist/helpers/fetch-document.test.js +0 -63
- package/dist/helpers/fetch-document.test.js.map +0 -7
- package/dist/helpers/find-variables.test.js +0 -20
- package/dist/helpers/find-variables.test.js.map +0 -7
- package/dist/helpers/is-defined.test.js +0 -37
- package/dist/helpers/is-defined.test.js.map +0 -7
- package/dist/helpers/is-local-url.test.js +0 -40
- package/dist/helpers/is-local-url.test.js.map +0 -7
- package/dist/helpers/is-valid-url.test.js +0 -17
- package/dist/helpers/is-valid-url.test.js.map +0 -7
- package/dist/helpers/json2xml.test.js +0 -19
- package/dist/helpers/json2xml.test.js.map +0 -7
- package/dist/helpers/make-url-absolute.test.js +0 -61
- package/dist/helpers/make-url-absolute.test.js.map +0 -7
- package/dist/helpers/merge-urls.test.js +0 -339
- package/dist/helpers/merge-urls.test.js.map +0 -7
- package/dist/helpers/normalize-mime-type-object.test.js +0 -53
- package/dist/helpers/normalize-mime-type-object.test.js.map +0 -7
- package/dist/helpers/normalize-mime-type.test.js +0 -33
- package/dist/helpers/normalize-mime-type.test.js.map +0 -7
- package/dist/helpers/omit-undefined-values.test.js +0 -89
- package/dist/helpers/omit-undefined-values.test.js.map +0 -7
- package/dist/helpers/parse.test.js +0 -45
- package/dist/helpers/parse.test.js.map +0 -7
- package/dist/helpers/pretty-print-json.test.js +0 -28
- package/dist/helpers/pretty-print-json.test.js.map +0 -7
- package/dist/helpers/redirect-to-proxy.test.js +0 -54
- package/dist/helpers/redirect-to-proxy.test.js.map +0 -7
- package/dist/helpers/regex-helpers.test.js +0 -154
- package/dist/helpers/regex-helpers.test.js.map +0 -7
- package/dist/helpers/replace-variables.test.js +0 -30
- package/dist/helpers/replace-variables.test.js.map +0 -7
- package/dist/helpers/security/get-schemes.test.js +0 -71
- package/dist/helpers/security/get-schemes.test.js.map +0 -7
- package/dist/helpers/security/has-token.test.js +0 -157
- package/dist/helpers/security/has-token.test.js.map +0 -7
- package/dist/migrations/semver.test.js +0 -21
- package/dist/migrations/semver.test.js.map +0 -7
- package/dist/migrations/v-2.4.0/migration.test.js +0 -90
- package/dist/migrations/v-2.4.0/migration.test.js.map +0 -7
- package/dist/migrations/v-2.5.0/migration.test.js +0 -108
- package/dist/migrations/v-2.5.0/migration.test.js.map +0 -7
- package/dist/spec-getters/get-example-from-schema.test.js +0 -1092
- package/dist/spec-getters/get-example-from-schema.test.js.map +0 -7
- package/dist/spec-getters/get-parameters-from-operation.test.js +0 -178
- package/dist/spec-getters/get-parameters-from-operation.test.js.map +0 -7
- package/dist/spec-getters/get-request-body-from-operation.test.js +0 -289
- package/dist/spec-getters/get-request-body-from-operation.test.js.map +0 -7
- package/dist/transforms/import-spec.test.js +0 -1124
- package/dist/transforms/import-spec.test.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @scalar/oas-utils
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1e87feb: refactor!: use dereferenced documents as a content source
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- cad6277: feat(themes)!: migrate to tailwind v4
|
|
12
|
+
- Updated dependencies [cad6277]
|
|
13
|
+
- @scalar/themes@0.13.0
|
|
14
|
+
- @scalar/object-utils@1.2.1
|
|
15
|
+
- @scalar/openapi-types@0.3.1
|
|
16
|
+
- @scalar/types@0.2.1
|
|
17
|
+
|
|
18
|
+
## 0.3.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 151ef09: fix(oas-utils): do not add content-type for multipart requests
|
|
23
|
+
- 442c0a3: feat: added support for callbacks
|
|
24
|
+
|
|
3
25
|
## 0.3.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -139,7 +139,7 @@ export declare const oasCollectionSchema: z.ZodObject<{
|
|
|
139
139
|
* security requirement ({}) can be included in the array.
|
|
140
140
|
*/
|
|
141
141
|
security: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>>, "many">>>;
|
|
142
|
-
externalDocs: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
142
|
+
externalDocs: z.ZodCatch<z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
143
143
|
description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
144
144
|
url: z.ZodString;
|
|
145
145
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -154,7 +154,7 @@ export declare const oasCollectionSchema: z.ZodObject<{
|
|
|
154
154
|
}, {
|
|
155
155
|
url: string;
|
|
156
156
|
description?: unknown;
|
|
157
|
-
}
|
|
157
|
+
}>>>;
|
|
158
158
|
/** TODO: Type these */
|
|
159
159
|
components: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
160
160
|
/** TODO: Type these */
|
|
@@ -249,10 +249,7 @@ export declare const oasCollectionSchema: z.ZodObject<{
|
|
|
249
249
|
}> | undefined;
|
|
250
250
|
}, {
|
|
251
251
|
type?: "collection" | undefined;
|
|
252
|
-
externalDocs?:
|
|
253
|
-
url: string;
|
|
254
|
-
description?: unknown;
|
|
255
|
-
} | undefined;
|
|
252
|
+
externalDocs?: unknown;
|
|
256
253
|
openapi?: string | undefined;
|
|
257
254
|
jsonSchemaDialect?: string | undefined;
|
|
258
255
|
info?: unknown;
|
|
@@ -486,7 +483,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
486
483
|
* security requirement ({}) can be included in the array.
|
|
487
484
|
*/
|
|
488
485
|
security: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>>, "many">>>;
|
|
489
|
-
externalDocs: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
486
|
+
externalDocs: z.ZodCatch<z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
490
487
|
description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
491
488
|
url: z.ZodString;
|
|
492
489
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -501,7 +498,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
501
498
|
}, {
|
|
502
499
|
url: string;
|
|
503
500
|
description?: unknown;
|
|
504
|
-
}
|
|
501
|
+
}>>>;
|
|
505
502
|
/** TODO: Type these */
|
|
506
503
|
components: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
507
504
|
/** TODO: Type these */
|
|
@@ -653,10 +650,7 @@ export declare const collectionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
653
650
|
}, {
|
|
654
651
|
uid?: string | undefined;
|
|
655
652
|
type?: "collection" | undefined;
|
|
656
|
-
externalDocs?:
|
|
657
|
-
url: string;
|
|
658
|
-
description?: unknown;
|
|
659
|
-
} | undefined;
|
|
653
|
+
externalDocs?: unknown;
|
|
660
654
|
children?: string[] | undefined;
|
|
661
655
|
openapi?: string | undefined;
|
|
662
656
|
jsonSchemaDialect?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/collection.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,mBAAmB;IAC9B;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAbyC,EAAG,QAAQ,CAAC,EAAE,WAAW,CAAC,EAAE,QAC1E,CAAC,EAAE,SAAS;kBAAgB,EAAI,SAAQ;oBAAiB,EAAG,QAAQ,CAAC,EACrE,WAAU,CAAC,EAAE,SAAS;yBAAwB,EAAG,QAAQ,CAAC,EAAE,WAC3D,CAAC,EA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be included in the array.
|
|
27
27
|
*/
|
|
28
28
|
"security": z.array(oasSecurityRequirementSchema).optional().default([]),
|
|
29
|
-
"externalDocs": oasExternalDocumentationSchema.optional(),
|
|
29
|
+
"externalDocs": oasExternalDocumentationSchema.optional().catch(void 0),
|
|
30
30
|
/** TODO: Type these */
|
|
31
31
|
"components": z.record(z.string(), z.unknown()).optional(),
|
|
32
32
|
/** TODO: Type these */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/collection.ts"],
|
|
4
|
-
"sourcesContent": ["import { selectedSecuritySchemeUidSchema } from '@/entities/shared/utility'\nimport { xScalarEnvironmentsSchema } from '@/entities/spec/x-scalar-environments'\nimport { xScalarSecretsSchema } from '@/entities/spec/x-scalar-secrets'\nimport { oasSecurityRequirementSchema } from '@scalar/types/entities'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { oasExternalDocumentationSchema, oasInfoSchema } from './spec-objects'\n\nexport const oasCollectionSchema = z.object({\n /**\n * @deprecated\n *\n * Needs to be remove as it is not a spec property\n */\n 'type': z.literal('collection').optional().default('collection'),\n 'openapi': z\n .union([z.string(), z.literal('3.0.0'), z.literal('3.1.0'), z.literal('4.0.0')])\n .optional()\n .default('3.1.0'),\n 'jsonSchemaDialect': z.string().optional(),\n 'info': oasInfoSchema.catch({\n title: 'API',\n version: '1.0',\n }),\n /**\n * A declaration of which security mechanisms can be used across the API. The list of\n * values includes alternative security requirement objects that can be used. Only\n * one of the security requirement objects need to be satisfied to authorize a request.\n * Individual operations can override this definition. To make security optional, an empty\n * security requirement ({}) can be included in the array.\n */\n 'security': z.array(oasSecurityRequirementSchema).optional().default([]),\n 'externalDocs': oasExternalDocumentationSchema.optional(),\n /** TODO: Type these */\n 'components': z.record(z.string(), z.unknown()).optional(),\n /** TODO: Type these */\n 'webhooks': z.record(z.string(), z.unknown()).optional(),\n /** A custom icon representing the collection */\n 'x-scalar-icon': z.string().optional().default('interface-content-folder'),\n 'x-scalar-active-environment': z.string().optional(),\n 'x-scalar-environments': xScalarEnvironmentsSchema.optional(),\n 'x-scalar-secrets': xScalarSecretsSchema.optional(),\n // These properties will be stripped out and mapped back as id lists\n // servers\n // paths/**\n // servers\n // tags\n // security\n})\n\nexport const extendedCollectionSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['COLLECTION']>(),\n /** A list of security schemes UIDs associated with the collection */\n securitySchemes: z.string().array().default([]),\n /** List of currently selected security scheme UIDs, these can be overridden per request */\n selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,\n /** The currently selected server */\n selectedServerUid: z.string().brand<ENTITY_BRANDS['SERVER']>().optional(),\n /** UIDs which refer to servers on the workspace base */\n servers: z.string().brand<ENTITY_BRANDS['SERVER']>().array().default([]),\n /** Request UIDs associated with a collection */\n requests: z.string().brand<ENTITY_BRANDS['OPERATION']>().array().default([]),\n /** Tag UIDs associated with the collection */\n tags: z.string().brand<ENTITY_BRANDS['TAG']>().array().default([]),\n /** List of requests without tags and top level tag \"folders\" */\n children: z\n .union([z.string().brand<ENTITY_BRANDS['OPERATION']>(), z.string().brand<ENTITY_BRANDS['TAG']>()])\n .array()\n .default([]),\n /**\n * A link to where this document is stored\n *\n * - Used for watch mode\n * - Possibly useful for Git sync down the line\n */\n documentUrl: z.string().optional(),\n /**\n * Enables polling of OpenAPI document urls\n *\n * @remarks Only effective when `documentUrl` is set\n */\n watchMode: z.boolean().optional().default(false),\n /** Keeps track of which integration is associated with the specific collection */\n integration: z.string().nullable().optional(),\n /**\n * Selected authentication will be set at the collection level instead of the request level\n *\n * @default false\n */\n useCollectionSecurity: z.boolean().optional().default(false),\n /**\n * Status of the watcher from above\n *\n * @defaults to idle for all collections, doesn't mean that it can watch for changes\n */\n watchModeStatus: z.enum(['IDLE', 'WATCHING', 'ERROR']).optional().default('IDLE'),\n})\n\nexport const collectionSchema = oasCollectionSchema.merge(extendedCollectionSchema)\nexport type Collection = z.infer<typeof collectionSchema>\nexport type CollectionPayload = z.input<typeof collectionSchema>\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,uCAAuC;AAChD,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AACrC,SAAS,oCAAoC;AAC7C,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,gCAAgC,qBAAqB;AAEvD,MAAM,sBAAsB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,QAAQ,EAAE,QAAQ,YAAY,EAAE,SAAS,EAAE,QAAQ,YAAY;AAAA,EAC/D,WAAW,EACR,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,CAAC,CAAC,EAC9E,SAAS,EACT,QAAQ,OAAO;AAAA,EAClB,qBAAqB,EAAE,OAAO,EAAE,SAAS;AAAA,EACzC,QAAQ,cAAc,MAAM;AAAA,IAC1B,OAAO;AAAA,IACP,SAAS;AAAA,EACX,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQD,YAAY,EAAE,MAAM,4BAA4B,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA,EACvE,gBAAgB,+BAA+B,SAAS;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { selectedSecuritySchemeUidSchema } from '@/entities/shared/utility'\nimport { xScalarEnvironmentsSchema } from '@/entities/spec/x-scalar-environments'\nimport { xScalarSecretsSchema } from '@/entities/spec/x-scalar-secrets'\nimport { oasSecurityRequirementSchema } from '@scalar/types/entities'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { oasExternalDocumentationSchema, oasInfoSchema } from './spec-objects'\n\nexport const oasCollectionSchema = z.object({\n /**\n * @deprecated\n *\n * Needs to be remove as it is not a spec property\n */\n 'type': z.literal('collection').optional().default('collection'),\n 'openapi': z\n .union([z.string(), z.literal('3.0.0'), z.literal('3.1.0'), z.literal('4.0.0')])\n .optional()\n .default('3.1.0'),\n 'jsonSchemaDialect': z.string().optional(),\n 'info': oasInfoSchema.catch({\n title: 'API',\n version: '1.0',\n }),\n /**\n * A declaration of which security mechanisms can be used across the API. The list of\n * values includes alternative security requirement objects that can be used. Only\n * one of the security requirement objects need to be satisfied to authorize a request.\n * Individual operations can override this definition. To make security optional, an empty\n * security requirement ({}) can be included in the array.\n */\n 'security': z.array(oasSecurityRequirementSchema).optional().default([]),\n 'externalDocs': oasExternalDocumentationSchema.optional().catch(undefined),\n /** TODO: Type these */\n 'components': z.record(z.string(), z.unknown()).optional(),\n /** TODO: Type these */\n 'webhooks': z.record(z.string(), z.unknown()).optional(),\n /** A custom icon representing the collection */\n 'x-scalar-icon': z.string().optional().default('interface-content-folder'),\n 'x-scalar-active-environment': z.string().optional(),\n 'x-scalar-environments': xScalarEnvironmentsSchema.optional(),\n 'x-scalar-secrets': xScalarSecretsSchema.optional(),\n // These properties will be stripped out and mapped back as id lists\n // servers\n // paths/**\n // servers\n // tags\n // security\n})\n\nexport const extendedCollectionSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['COLLECTION']>(),\n /** A list of security schemes UIDs associated with the collection */\n securitySchemes: z.string().array().default([]),\n /** List of currently selected security scheme UIDs, these can be overridden per request */\n selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,\n /** The currently selected server */\n selectedServerUid: z.string().brand<ENTITY_BRANDS['SERVER']>().optional(),\n /** UIDs which refer to servers on the workspace base */\n servers: z.string().brand<ENTITY_BRANDS['SERVER']>().array().default([]),\n /** Request UIDs associated with a collection */\n requests: z.string().brand<ENTITY_BRANDS['OPERATION']>().array().default([]),\n /** Tag UIDs associated with the collection */\n tags: z.string().brand<ENTITY_BRANDS['TAG']>().array().default([]),\n /** List of requests without tags and top level tag \"folders\" */\n children: z\n .union([z.string().brand<ENTITY_BRANDS['OPERATION']>(), z.string().brand<ENTITY_BRANDS['TAG']>()])\n .array()\n .default([]),\n /**\n * A link to where this document is stored\n *\n * - Used for watch mode\n * - Possibly useful for Git sync down the line\n */\n documentUrl: z.string().optional(),\n /**\n * Enables polling of OpenAPI document urls\n *\n * @remarks Only effective when `documentUrl` is set\n */\n watchMode: z.boolean().optional().default(false),\n /** Keeps track of which integration is associated with the specific collection */\n integration: z.string().nullable().optional(),\n /**\n * Selected authentication will be set at the collection level instead of the request level\n *\n * @default false\n */\n useCollectionSecurity: z.boolean().optional().default(false),\n /**\n * Status of the watcher from above\n *\n * @defaults to idle for all collections, doesn't mean that it can watch for changes\n */\n watchModeStatus: z.enum(['IDLE', 'WATCHING', 'ERROR']).optional().default('IDLE'),\n})\n\nexport const collectionSchema = oasCollectionSchema.merge(extendedCollectionSchema)\nexport type Collection = z.infer<typeof collectionSchema>\nexport type CollectionPayload = z.input<typeof collectionSchema>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,uCAAuC;AAChD,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AACrC,SAAS,oCAAoC;AAC7C,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,gCAAgC,qBAAqB;AAEvD,MAAM,sBAAsB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,QAAQ,EAAE,QAAQ,YAAY,EAAE,SAAS,EAAE,QAAQ,YAAY;AAAA,EAC/D,WAAW,EACR,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,CAAC,CAAC,EAC9E,SAAS,EACT,QAAQ,OAAO;AAAA,EAClB,qBAAqB,EAAE,OAAO,EAAE,SAAS;AAAA,EACzC,QAAQ,cAAc,MAAM;AAAA,IAC1B,OAAO;AAAA,IACP,SAAS;AAAA,EACX,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA,EAE/C,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5C,uBAAuB,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3D,iBAAiB,EAAE,KAAK,CAAC,QAAQ,YAAY,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,MAAM;AAClF,CAAC;AAEM,MAAM,mBAAmB,oBAAoB,MAAM,wBAAwB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -87,6 +87,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
87
87
|
}>>;
|
|
88
88
|
deprecated: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
89
89
|
responses: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
90
|
+
callbacks: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>>>;
|
|
90
91
|
'x-scalar-examples': import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
91
92
|
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
92
93
|
body: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
@@ -261,6 +262,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
261
262
|
}[] | undefined;
|
|
262
263
|
requestBody?: any;
|
|
263
264
|
responses?: Record<string, any> | undefined;
|
|
265
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
264
266
|
'x-scalar-stability'?: import("@scalar/types").XScalarStability | undefined;
|
|
265
267
|
'x-post-response'?: string | undefined;
|
|
266
268
|
'x-codeSamples'?: {
|
|
@@ -317,6 +319,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
317
319
|
}[] | undefined;
|
|
318
320
|
requestBody?: any;
|
|
319
321
|
responses?: Record<string, any> | undefined;
|
|
322
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
320
323
|
'x-scalar-stability'?: unknown;
|
|
321
324
|
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
322
325
|
'x-post-response'?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,YAAY,CAAA;AAE5F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,YAAY,CAAA;AAE5F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aACwV,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAqT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAwT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADxzC,CAAA"}
|
|
@@ -314,7 +314,7 @@ function createExampleFromRequest(request, name, server) {
|
|
|
314
314
|
})
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
-
if (requestBody?.mimeType && !contentTypeHeader) {
|
|
317
|
+
if (requestBody?.mimeType && !contentTypeHeader && !requestBody.mimeType.startsWith("multipart/")) {
|
|
318
318
|
parameters.headers.push({
|
|
319
319
|
key: "Content-Type",
|
|
320
320
|
value: requestBody.mimeType,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/request-examples.ts"],
|
|
4
|
-
"sourcesContent": ["import { schemaModel } from '@/helpers/schema-model'\nimport { getServerVariableExamples } from '@/spec-getters/get-server-variable-examples'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { isDefined } from '@/helpers/is-defined'\nimport { getObjectKeys } from '@/helpers/object'\n\nimport { getRequestBodyFromOperation } from '@/spec-getters/get-request-body-from-operation'\nimport type { RequestParameter, ParameterContent } from './parameters'\nimport type { Request } from './requests'\nimport type { Server } from './server'\n\n// ---------------------------------------------------------------------------\n// Example Parameters\n\n/**\n * TODO: Deprecate this.\n *\n * The request schema should be stored in the request and any\n * parameters should be validated against that\n */\nexport const requestExampleParametersSchema = z\n .object({\n key: z.string().default(''),\n value: z.coerce.string().default(''),\n enabled: z.boolean().default(true),\n file: z.any().optional(),\n description: z.string().optional(),\n required: z.boolean().optional(),\n enum: z.array(z.string()).optional(),\n examples: z.array(z.any()).optional(),\n type: z\n .union([\n // 'string'\n z.string(),\n // ['string', 'null']\n z.array(z.string()),\n ])\n .optional(),\n format: z.string().optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n default: z.any().optional(),\n nullable: z.boolean().optional(),\n })\n // set nullable: to true if type is ['string', 'null']\n .transform((_data) => {\n const data = { ..._data }\n\n // type: ['string', 'null'] -> nullable: true\n if (Array.isArray(data.type) && data.type.includes('null')) {\n data.nullable = true\n }\n\n // Hey, if it's just one value and 'null', we can make it a string and ditch the 'null'.\n if (Array.isArray(data.type) && data.type.length === 2 && data.type.includes('null')) {\n data.type = data.type.find((item) => item !== 'null')\n }\n\n return data\n })\n\n/** Convert the array of parameters to an object keyed by the parameter name */\nexport const parameterArrayToObject = (params: RequestExampleParameter[]) =>\n params.reduce<Record<string, string>>((map, param) => {\n map[param.key] = param.value\n return map\n }, {})\n\n/** Request examples - formerly known as instances - are \"children\" of requests */\nexport type RequestExampleParameter = z.infer<typeof requestExampleParametersSchema>\n\nexport const xScalarFileValueSchema = z\n .object({\n url: z.string(),\n base64: z.string().optional(),\n })\n .nullable()\n\n/**\n * When files are required for an example we provide the options\n * to provide a public URL or a base64 encoded string\n */\nexport type XScalarFileValue = z.infer<typeof xScalarFileValueSchema>\n\n/**\n * Schema for the OAS serialization of request example parameters\n *\n * File values can be optionally fetched on import OR inserted as a base64 encoded string\n */\nexport const xScalarFormDataValue = z.union([\n z.object({\n type: z.literal('string'),\n value: z.string(),\n }),\n z.object({\n type: z.literal('file'),\n file: xScalarFileValueSchema,\n }),\n])\n\nexport type XScalarFormDataValue = z.infer<typeof xScalarFormDataValue>\n\n// ---------------------------------------------------------------------------\n// Example Body\n\n/**\n * Possible encodings for example request bodies when using text formats\n *\n * TODO: This list may not be comprehensive enough\n */\nexport const exampleRequestBodyEncoding = ['json', 'text', 'html', 'javascript', 'xml', 'yaml', 'edn'] as const\n\nexport type BodyEncoding = (typeof exampleRequestBodyEncoding)[number]\n\nexport const exampleBodyMime = [\n 'application/json',\n 'text/plain',\n 'text/html',\n 'application/javascript',\n 'application/xml',\n 'application/yaml',\n 'application/edn',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'multipart/form-data',\n /** Used for direct files */\n 'binary',\n] as const\n\nexport type BodyMime = (typeof exampleBodyMime)[number]\n\nconst contentMapping: Record<BodyEncoding, BodyMime> = {\n json: 'application/json',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n} as const\n\n/**\n * TODO: Migrate away from this layout to the format used in the extension\n *\n * If a user changes the encoding of the body we expect the content to change as well\n */\nexport const exampleRequestBodySchema = z.object({\n raw: z\n .object({\n encoding: z.enum(exampleRequestBodyEncoding),\n value: z.string().default(''),\n mimeType: z.string().optional(),\n })\n .optional(),\n formData: z\n .object({\n encoding: z.union([z.literal('form-data'), z.literal('urlencoded')]).default('form-data'),\n value: requestExampleParametersSchema.array().default([]),\n })\n .optional(),\n binary: z.instanceof(Blob).optional(),\n activeBody: z.union([z.literal('raw'), z.literal('formData'), z.literal('binary')]).default('raw'),\n})\n\nexport type ExampleRequestBody = z.infer<typeof exampleRequestBodySchema>\n\n/** Schema for the OAS serialization of request example bodies */\nexport const xScalarExampleBodySchema = z.object({\n encoding: z.enum(exampleBodyMime),\n /**\n * Body content as an object with a separately specified encoding or a simple pre-encoded string value\n *\n * Ideally we would convert any objects into the proper encoding on import\n */\n content: z.union([z.record(z.string(), z.any()), z.string()]),\n /** When the encoding is `binary` this will be used to link to the file */\n file: xScalarFileValueSchema.optional(),\n})\n\nexport type XScalarExampleBody = z.infer<typeof xScalarExampleBodySchema>\n\n// ---------------------------------------------------------------------------\n// Example Schema\n\nexport const requestExampleSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['EXAMPLE']>(),\n type: z.literal('requestExample').optional().default('requestExample'),\n requestUid: z.string().brand<ENTITY_BRANDS['OPERATION']>().optional(),\n name: z.string().optional().default('Name'),\n body: exampleRequestBodySchema.optional().default({}),\n parameters: z\n .object({\n path: requestExampleParametersSchema.array().default([]),\n query: requestExampleParametersSchema.array().default([]),\n headers: requestExampleParametersSchema.array().default([{ key: 'Accept', value: '*/*', enabled: true }]),\n cookies: requestExampleParametersSchema.array().default([]),\n })\n .optional()\n .default({}),\n /** TODO: Should this be deprecated? */\n serverVariables: z.record(z.string(), z.array(z.string())).optional(),\n})\n\nexport type RequestExample = z.infer<typeof requestExampleSchema>\n\n/** For OAS serialization we just store the simple key/value pairs */\nconst xScalarExampleParameterSchema = z.record(z.string(), z.string()).optional()\n\n/** Schema for the OAS serialization of request examples */\nexport const xScalarExampleSchema = z.object({\n /** TODO: Should this be required? */\n name: z.string().optional(),\n body: xScalarExampleBodySchema.optional(),\n parameters: z.object({\n path: xScalarExampleParameterSchema,\n query: xScalarExampleParameterSchema,\n headers: xScalarExampleParameterSchema,\n cookies: xScalarExampleParameterSchema,\n }),\n})\n\nexport type XScalarExample = z.infer<typeof xScalarExampleSchema>\n\n/**\n * Convert a request example to the xScalar serialized format\n *\n * TODO: The base format should be migrated to align MUCH closer to the serialized format\n */\nexport function convertExampleToXScalar(example: RequestExample) {\n const active = example.body?.activeBody\n\n const xScalarBody: XScalarExampleBody = {\n encoding: 'text/plain',\n content: '',\n }\n\n if (example.body?.activeBody === 'binary') {\n xScalarBody.encoding = 'binary'\n // TODO: Need to allow users to set these properties\n xScalarBody.file = null\n }\n\n if (active === 'formData' && example.body?.[active]) {\n const body = example.body[active]\n xScalarBody.encoding = body.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded'\n\n // TODO: Need to allow users to set these properties\n xScalarBody.content = body.value.reduce<Record<string, XScalarFormDataValue>>((map, param) => {\n /** TODO: We need to ensure only file or value is set */\n map[param.key] = param.file\n ? {\n type: 'file',\n file: null,\n }\n : {\n type: 'string',\n value: param.value,\n }\n return map\n }, {})\n }\n\n if (example.body?.activeBody === 'raw') {\n xScalarBody.encoding = contentMapping[example.body.raw?.encoding ?? 'text'] ?? 'text/plain'\n\n xScalarBody.content = example.body.raw?.value ?? ''\n }\n\n const parameters: XScalarExample['parameters'] = {}\n\n keysOf(example.parameters ?? {}).forEach((key) => {\n if (example.parameters?.[key].length) {\n parameters[key] = parameterArrayToObject(example.parameters[key])\n }\n })\n\n return xScalarExampleSchema.parse({\n /** Only add the body if we have content or the body should be a file */\n body: xScalarBody.content || xScalarBody.encoding === 'binary' ? xScalarBody : undefined,\n parameters,\n })\n}\n\n// ---------------------------------------------------------------------------\n// Example Helpers\n\n/** Create new instance parameter from a request parameter */\nexport function createParamInstance(param: RequestParameter) {\n const schema = param.schema as any\n\n const firstExample = (() => {\n if (param.examples && !Array.isArray(param.examples) && getObjectKeys(param.examples).length > 0) {\n const exampleValues = Object.entries(param.examples).map(([_, example]) => {\n // returns the external value if it exists\n if (example.externalValue) {\n return example.externalValue\n }\n\n // returns the value if it exists and is defined\n // e.g. { examples: { foo: { value: 'bar' } } } would return ['bar']\n return example.value\n })\n\n // returns the first example as selected value along other examples\n return { value: exampleValues[0], examples: exampleValues }\n }\n\n // param example e.g. { example: 'foo' }\n if (isDefined(param.example)) {\n return { value: param.example }\n }\n\n // param examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(param.examples) && param.examples.length > 0) {\n return { value: param.examples[0] }\n }\n\n // schema example e.g. { example: 'foo' } while being discouraged\n // see https://spec.openapis.org/oas/v3.1.1.html#fixed-fields-20\n if (isDefined(schema?.example)) {\n return { value: schema.example }\n }\n\n // schema examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(schema?.examples) && schema.examples.length > 0) {\n // For boolean type, default to false when using schema examples\n if (schema?.type === 'boolean') {\n return { value: schema.default ?? false }\n }\n return { value: schema.examples[0] }\n }\n\n // content examples e.g. { content: { 'application/json': { examples: { foo: { value: 'bar' } } } } }\n if (param.content) {\n const firstContentType = getObjectKeys(param.content)[0]\n if (firstContentType) {\n const content = (param.content as ParameterContent)[firstContentType]\n if (content?.examples) {\n const firstExampleKey = Object.keys(content.examples)[0]\n if (firstExampleKey) {\n const example = content.examples[firstExampleKey]\n if (isDefined(example?.value)) {\n return { value: example.value }\n }\n }\n }\n // content example e.g. { example: 'foo' }\n if (isDefined(content?.example)) {\n return { value: content.example }\n }\n }\n }\n\n return null\n })() as null | { value: any; examples?: string[] }\n\n /**\n * TODO:\n * - Need better value defaulting here\n * - Need to handle non-string parameters much better\n * - Need to handle unions/array values for schema\n */\n const value = String(firstExample?.value ?? schema?.default ?? '')\n\n // Handle non-string enums and enums within items for array types\n const parseEnum = (() => {\n if (schema?.enum && schema?.type !== 'string') {\n return schema.enum?.map(String)\n }\n\n if (schema?.items?.enum && schema?.type === 'array') {\n return schema.items.enum.map(String)\n }\n\n return schema?.enum\n })()\n\n // Handle parameter examples\n const examples =\n firstExample?.examples ||\n (schema?.examples && schema?.type !== 'string' ? schema.examples?.map(String) : schema?.examples)\n\n // safe parse the example\n const example = schemaModel(\n {\n ...schema,\n key: param.name,\n value,\n description: param.description,\n required: param.required,\n /** Initialized all required properties to enabled */\n enabled: !!param.required,\n enum: parseEnum,\n examples,\n },\n requestExampleParametersSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${param.name} is invalid.`)\n return requestExampleParametersSchema.parse({})\n }\n\n return example\n}\n\n/**\n * Create new request example from a request\n * Iterates the name of the example if provided\n */\nexport function createExampleFromRequest(request: Request, name: string, server?: Server): RequestExample {\n // ---------------------------------------------------------------------------\n // Populate all parameters with an example value\n const parameters: Record<'path' | 'cookie' | 'header' | 'query' | 'headers', RequestExampleParameter[]> = {\n path: [],\n query: [],\n cookie: [],\n // deprecated TODO: add zod transform to remove\n header: [],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n }\n\n // Populated the separated params\n request.parameters?.forEach((p) => parameters[p.in].push(createParamInstance(p)))\n\n // TODO: add zod transform to remove header and only support headers\n if (parameters.header.length > 0) {\n parameters.headers = parameters.header\n parameters.header = []\n }\n\n // Get content type header\n const contentTypeHeader = parameters.headers.find((h) => h.key.toLowerCase() === 'content-type')\n\n // ---------------------------------------------------------------------------\n // Handle request body defaulting for various content type encodings\n const body: ExampleRequestBody = {\n activeBody: 'raw',\n }\n\n // If we have a request body or a content type header\n if (request.requestBody || contentTypeHeader?.value) {\n const requestBody = getRequestBodyFromOperation({\n path: request.path,\n information: {\n requestBody: request.requestBody,\n },\n })\n\n const contentType = request.requestBody ? requestBody?.mimeType : contentTypeHeader?.value\n\n // Handle JSON and JSON-like mimetypes\n if (contentType?.includes('/json') || contentType?.endsWith('+json')) {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'json',\n mimeType: contentType,\n value: requestBody?.text ?? JSON.stringify({}),\n }\n }\n\n if (contentType === 'application/xml') {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'xml',\n value: requestBody?.text ?? '',\n }\n }\n\n /**\n * TODO: Are we loading example files from somewhere based on the spec?\n * How are we handling the body values\n */\n if (contentType === 'application/octet-stream') {\n body.activeBody = 'binary'\n body.binary = undefined\n }\n\n if (contentType === 'application/x-www-form-urlencoded' || contentType === 'multipart/form-data') {\n body.activeBody = 'formData'\n body.formData = {\n encoding: contentType === 'application/x-www-form-urlencoded' ? 'urlencoded' : 'form-data',\n value: (requestBody?.params || []).map((param) => {\n if (param.value instanceof File) {\n return {\n key: param.name,\n value: 'BINARY',\n file: param.value,\n enabled: true,\n }\n }\n return {\n key: param.name,\n value: param.value || '',\n enabled: true,\n }\n }),\n }\n }\n\n // Add the content-type header if it doesn't exist\n if (requestBody?.mimeType && !contentTypeHeader) {\n parameters.headers.push({\n key: 'Content-Type',\n value: requestBody.mimeType,\n enabled: true,\n })\n }\n }\n\n const serverVariables = server ? getServerVariableExamples(server) : {}\n\n // safe parse the example\n const example = schemaModel(\n {\n requestUid: request.uid,\n parameters,\n name,\n body,\n serverVariables,\n },\n requestExampleSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${request.uid} is invalid.`)\n return requestExampleSchema.parse({})\n }\n return example\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,iCAAiC;AAC1C,SAAS,cAAc;AACvB,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,mCAAmC;AAcrC,MAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC1B,OAAO,EAAE,OAAO,OAAO,EAAE,QAAQ,EAAE;AAAA,EACnC,SAAS,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EACjC,MAAM,EAAE,IAAI,EAAE,SAAS;AAAA,EACvB,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACnC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACpC,MAAM,EACH,MAAM;AAAA;AAAA,IAEL,EAAE,OAAO;AAAA;AAAA,IAET,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EACpB,CAAC,EACA,SAAS;AAAA,EACZ,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,IAAI,EAAE,SAAS;AAAA,EAC1B,UAAU,EAAE,QAAQ,EAAE,SAAS;AACjC,CAAC,EAEA,UAAU,CAAC,UAAU;AACpB,QAAM,OAAO,EAAE,GAAG,MAAM;AAGxB,MAAI,MAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,KAAK,SAAS,MAAM,GAAG;AAC1D,SAAK,W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AM;AAAA,QACT,UAAU;AAAA,QACV,UAAU;AAAA,QACV,OAAO,aAAa,QAAQ,KAAK,UAAU,CAAC,CAAC;AAAA,MAC/C;AAAA,IACF;AAEA,QAAI,gBAAgB,mBAAmB;AACrC,WAAK,aAAa;AAClB,WAAK,MAAM;AAAA,QACT,UAAU;AAAA,QACV,OAAO,aAAa,QAAQ;AAAA,MAC9B;AAAA,IACF;AAMA,QAAI,gBAAgB,4BAA4B;AAC9C,WAAK,aAAa;AAClB,WAAK,SAAS;AAAA,IAChB;AAEA,QAAI,gBAAgB,uCAAuC,gBAAgB,uBAAuB;AAChG,WAAK,aAAa;AAClB,WAAK,WAAW;AAAA,QACd,UAAU,gBAAgB,sCAAsC,eAAe;AAAA,QAC/E,QAAQ,aAAa,UAAU,CAAC,GAAG,IAAI,CAAC,UAAU;AAChD,cAAI,MAAM,iBAAiB,MAAM;AAC/B,mBAAO;AAAA,cACL,KAAK,MAAM;AAAA,cACX,OAAO;AAAA,cACP,MAAM,MAAM;AAAA,cACZ,SAAS;AAAA,YACX;AAAA,UACF;AACA,iBAAO;AAAA,YACL,KAAK,MAAM;AAAA,YACX,OAAO,MAAM,SAAS;AAAA,YACtB,SAAS;AAAA,UACX;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAGA,QAAI,aAAa,YAAY,CAAC,
|
|
4
|
+
"sourcesContent": ["import { schemaModel } from '@/helpers/schema-model'\nimport { getServerVariableExamples } from '@/spec-getters/get-server-variable-examples'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { isDefined } from '@/helpers/is-defined'\nimport { getObjectKeys } from '@/helpers/object'\n\nimport { getRequestBodyFromOperation } from '@/spec-getters/get-request-body-from-operation'\nimport type { RequestParameter, ParameterContent } from './parameters'\nimport type { Request } from './requests'\nimport type { Server } from './server'\n\n// ---------------------------------------------------------------------------\n// Example Parameters\n\n/**\n * TODO: Deprecate this.\n *\n * The request schema should be stored in the request and any\n * parameters should be validated against that\n */\nexport const requestExampleParametersSchema = z\n .object({\n key: z.string().default(''),\n value: z.coerce.string().default(''),\n enabled: z.boolean().default(true),\n file: z.any().optional(),\n description: z.string().optional(),\n required: z.boolean().optional(),\n enum: z.array(z.string()).optional(),\n examples: z.array(z.any()).optional(),\n type: z\n .union([\n // 'string'\n z.string(),\n // ['string', 'null']\n z.array(z.string()),\n ])\n .optional(),\n format: z.string().optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n default: z.any().optional(),\n nullable: z.boolean().optional(),\n })\n // set nullable: to true if type is ['string', 'null']\n .transform((_data) => {\n const data = { ..._data }\n\n // type: ['string', 'null'] -> nullable: true\n if (Array.isArray(data.type) && data.type.includes('null')) {\n data.nullable = true\n }\n\n // Hey, if it's just one value and 'null', we can make it a string and ditch the 'null'.\n if (Array.isArray(data.type) && data.type.length === 2 && data.type.includes('null')) {\n data.type = data.type.find((item) => item !== 'null')\n }\n\n return data\n })\n\n/** Convert the array of parameters to an object keyed by the parameter name */\nexport const parameterArrayToObject = (params: RequestExampleParameter[]) =>\n params.reduce<Record<string, string>>((map, param) => {\n map[param.key] = param.value\n return map\n }, {})\n\n/** Request examples - formerly known as instances - are \"children\" of requests */\nexport type RequestExampleParameter = z.infer<typeof requestExampleParametersSchema>\n\nexport const xScalarFileValueSchema = z\n .object({\n url: z.string(),\n base64: z.string().optional(),\n })\n .nullable()\n\n/**\n * When files are required for an example we provide the options\n * to provide a public URL or a base64 encoded string\n */\nexport type XScalarFileValue = z.infer<typeof xScalarFileValueSchema>\n\n/**\n * Schema for the OAS serialization of request example parameters\n *\n * File values can be optionally fetched on import OR inserted as a base64 encoded string\n */\nexport const xScalarFormDataValue = z.union([\n z.object({\n type: z.literal('string'),\n value: z.string(),\n }),\n z.object({\n type: z.literal('file'),\n file: xScalarFileValueSchema,\n }),\n])\n\nexport type XScalarFormDataValue = z.infer<typeof xScalarFormDataValue>\n\n// ---------------------------------------------------------------------------\n// Example Body\n\n/**\n * Possible encodings for example request bodies when using text formats\n *\n * TODO: This list may not be comprehensive enough\n */\nexport const exampleRequestBodyEncoding = ['json', 'text', 'html', 'javascript', 'xml', 'yaml', 'edn'] as const\n\nexport type BodyEncoding = (typeof exampleRequestBodyEncoding)[number]\n\nexport const exampleBodyMime = [\n 'application/json',\n 'text/plain',\n 'text/html',\n 'application/javascript',\n 'application/xml',\n 'application/yaml',\n 'application/edn',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'multipart/form-data',\n /** Used for direct files */\n 'binary',\n] as const\n\nexport type BodyMime = (typeof exampleBodyMime)[number]\n\nconst contentMapping: Record<BodyEncoding, BodyMime> = {\n json: 'application/json',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n} as const\n\n/**\n * TODO: Migrate away from this layout to the format used in the extension\n *\n * If a user changes the encoding of the body we expect the content to change as well\n */\nexport const exampleRequestBodySchema = z.object({\n raw: z\n .object({\n encoding: z.enum(exampleRequestBodyEncoding),\n value: z.string().default(''),\n mimeType: z.string().optional(),\n })\n .optional(),\n formData: z\n .object({\n encoding: z.union([z.literal('form-data'), z.literal('urlencoded')]).default('form-data'),\n value: requestExampleParametersSchema.array().default([]),\n })\n .optional(),\n binary: z.instanceof(Blob).optional(),\n activeBody: z.union([z.literal('raw'), z.literal('formData'), z.literal('binary')]).default('raw'),\n})\n\nexport type ExampleRequestBody = z.infer<typeof exampleRequestBodySchema>\n\n/** Schema for the OAS serialization of request example bodies */\nexport const xScalarExampleBodySchema = z.object({\n encoding: z.enum(exampleBodyMime),\n /**\n * Body content as an object with a separately specified encoding or a simple pre-encoded string value\n *\n * Ideally we would convert any objects into the proper encoding on import\n */\n content: z.union([z.record(z.string(), z.any()), z.string()]),\n /** When the encoding is `binary` this will be used to link to the file */\n file: xScalarFileValueSchema.optional(),\n})\n\nexport type XScalarExampleBody = z.infer<typeof xScalarExampleBodySchema>\n\n// ---------------------------------------------------------------------------\n// Example Schema\n\nexport const requestExampleSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['EXAMPLE']>(),\n type: z.literal('requestExample').optional().default('requestExample'),\n requestUid: z.string().brand<ENTITY_BRANDS['OPERATION']>().optional(),\n name: z.string().optional().default('Name'),\n body: exampleRequestBodySchema.optional().default({}),\n parameters: z\n .object({\n path: requestExampleParametersSchema.array().default([]),\n query: requestExampleParametersSchema.array().default([]),\n headers: requestExampleParametersSchema.array().default([{ key: 'Accept', value: '*/*', enabled: true }]),\n cookies: requestExampleParametersSchema.array().default([]),\n })\n .optional()\n .default({}),\n /** TODO: Should this be deprecated? */\n serverVariables: z.record(z.string(), z.array(z.string())).optional(),\n})\n\nexport type RequestExample = z.infer<typeof requestExampleSchema>\n\n/** For OAS serialization we just store the simple key/value pairs */\nconst xScalarExampleParameterSchema = z.record(z.string(), z.string()).optional()\n\n/** Schema for the OAS serialization of request examples */\nexport const xScalarExampleSchema = z.object({\n /** TODO: Should this be required? */\n name: z.string().optional(),\n body: xScalarExampleBodySchema.optional(),\n parameters: z.object({\n path: xScalarExampleParameterSchema,\n query: xScalarExampleParameterSchema,\n headers: xScalarExampleParameterSchema,\n cookies: xScalarExampleParameterSchema,\n }),\n})\n\nexport type XScalarExample = z.infer<typeof xScalarExampleSchema>\n\n/**\n * Convert a request example to the xScalar serialized format\n *\n * TODO: The base format should be migrated to align MUCH closer to the serialized format\n */\nexport function convertExampleToXScalar(example: RequestExample) {\n const active = example.body?.activeBody\n\n const xScalarBody: XScalarExampleBody = {\n encoding: 'text/plain',\n content: '',\n }\n\n if (example.body?.activeBody === 'binary') {\n xScalarBody.encoding = 'binary'\n // TODO: Need to allow users to set these properties\n xScalarBody.file = null\n }\n\n if (active === 'formData' && example.body?.[active]) {\n const body = example.body[active]\n xScalarBody.encoding = body.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded'\n\n // TODO: Need to allow users to set these properties\n xScalarBody.content = body.value.reduce<Record<string, XScalarFormDataValue>>((map, param) => {\n /** TODO: We need to ensure only file or value is set */\n map[param.key] = param.file\n ? {\n type: 'file',\n file: null,\n }\n : {\n type: 'string',\n value: param.value,\n }\n return map\n }, {})\n }\n\n if (example.body?.activeBody === 'raw') {\n xScalarBody.encoding = contentMapping[example.body.raw?.encoding ?? 'text'] ?? 'text/plain'\n\n xScalarBody.content = example.body.raw?.value ?? ''\n }\n\n const parameters: XScalarExample['parameters'] = {}\n\n keysOf(example.parameters ?? {}).forEach((key) => {\n if (example.parameters?.[key].length) {\n parameters[key] = parameterArrayToObject(example.parameters[key])\n }\n })\n\n return xScalarExampleSchema.parse({\n /** Only add the body if we have content or the body should be a file */\n body: xScalarBody.content || xScalarBody.encoding === 'binary' ? xScalarBody : undefined,\n parameters,\n })\n}\n\n// ---------------------------------------------------------------------------\n// Example Helpers\n\n/** Create new instance parameter from a request parameter */\nexport function createParamInstance(param: RequestParameter) {\n const schema = param.schema as any\n\n const firstExample = (() => {\n if (param.examples && !Array.isArray(param.examples) && getObjectKeys(param.examples).length > 0) {\n const exampleValues = Object.entries(param.examples).map(([_, example]) => {\n // returns the external value if it exists\n if (example.externalValue) {\n return example.externalValue\n }\n\n // returns the value if it exists and is defined\n // e.g. { examples: { foo: { value: 'bar' } } } would return ['bar']\n return example.value\n })\n\n // returns the first example as selected value along other examples\n return { value: exampleValues[0], examples: exampleValues }\n }\n\n // param example e.g. { example: 'foo' }\n if (isDefined(param.example)) {\n return { value: param.example }\n }\n\n // param examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(param.examples) && param.examples.length > 0) {\n return { value: param.examples[0] }\n }\n\n // schema example e.g. { example: 'foo' } while being discouraged\n // see https://spec.openapis.org/oas/v3.1.1.html#fixed-fields-20\n if (isDefined(schema?.example)) {\n return { value: schema.example }\n }\n\n // schema examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(schema?.examples) && schema.examples.length > 0) {\n // For boolean type, default to false when using schema examples\n if (schema?.type === 'boolean') {\n return { value: schema.default ?? false }\n }\n return { value: schema.examples[0] }\n }\n\n // content examples e.g. { content: { 'application/json': { examples: { foo: { value: 'bar' } } } } }\n if (param.content) {\n const firstContentType = getObjectKeys(param.content)[0]\n if (firstContentType) {\n const content = (param.content as ParameterContent)[firstContentType]\n if (content?.examples) {\n const firstExampleKey = Object.keys(content.examples)[0]\n if (firstExampleKey) {\n const example = content.examples[firstExampleKey]\n if (isDefined(example?.value)) {\n return { value: example.value }\n }\n }\n }\n // content example e.g. { example: 'foo' }\n if (isDefined(content?.example)) {\n return { value: content.example }\n }\n }\n }\n\n return null\n })() as null | { value: any; examples?: string[] }\n\n /**\n * TODO:\n * - Need better value defaulting here\n * - Need to handle non-string parameters much better\n * - Need to handle unions/array values for schema\n */\n const value = String(firstExample?.value ?? schema?.default ?? '')\n\n // Handle non-string enums and enums within items for array types\n const parseEnum = (() => {\n if (schema?.enum && schema?.type !== 'string') {\n return schema.enum?.map(String)\n }\n\n if (schema?.items?.enum && schema?.type === 'array') {\n return schema.items.enum.map(String)\n }\n\n return schema?.enum\n })()\n\n // Handle parameter examples\n const examples =\n firstExample?.examples ||\n (schema?.examples && schema?.type !== 'string' ? schema.examples?.map(String) : schema?.examples)\n\n // safe parse the example\n const example = schemaModel(\n {\n ...schema,\n key: param.name,\n value,\n description: param.description,\n required: param.required,\n /** Initialized all required properties to enabled */\n enabled: !!param.required,\n enum: parseEnum,\n examples,\n },\n requestExampleParametersSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${param.name} is invalid.`)\n return requestExampleParametersSchema.parse({})\n }\n\n return example\n}\n\n/**\n * Create new request example from a request\n * Iterates the name of the example if provided\n */\nexport function createExampleFromRequest(request: Request, name: string, server?: Server): RequestExample {\n // ---------------------------------------------------------------------------\n // Populate all parameters with an example value\n const parameters: Record<'path' | 'cookie' | 'header' | 'query' | 'headers', RequestExampleParameter[]> = {\n path: [],\n query: [],\n cookie: [],\n // deprecated TODO: add zod transform to remove\n header: [],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n }\n\n // Populated the separated params\n request.parameters?.forEach((p) => parameters[p.in].push(createParamInstance(p)))\n\n // TODO: add zod transform to remove header and only support headers\n if (parameters.header.length > 0) {\n parameters.headers = parameters.header\n parameters.header = []\n }\n\n // Get content type header\n const contentTypeHeader = parameters.headers.find((h) => h.key.toLowerCase() === 'content-type')\n\n // ---------------------------------------------------------------------------\n // Handle request body defaulting for various content type encodings\n const body: ExampleRequestBody = {\n activeBody: 'raw',\n }\n\n // If we have a request body or a content type header\n if (request.requestBody || contentTypeHeader?.value) {\n const requestBody = getRequestBodyFromOperation({\n path: request.path,\n information: {\n requestBody: request.requestBody,\n },\n })\n\n const contentType = request.requestBody ? requestBody?.mimeType : contentTypeHeader?.value\n\n // Handle JSON and JSON-like mimetypes\n if (contentType?.includes('/json') || contentType?.endsWith('+json')) {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'json',\n mimeType: contentType,\n value: requestBody?.text ?? JSON.stringify({}),\n }\n }\n\n if (contentType === 'application/xml') {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'xml',\n value: requestBody?.text ?? '',\n }\n }\n\n /**\n * TODO: Are we loading example files from somewhere based on the spec?\n * How are we handling the body values\n */\n if (contentType === 'application/octet-stream') {\n body.activeBody = 'binary'\n body.binary = undefined\n }\n\n if (contentType === 'application/x-www-form-urlencoded' || contentType === 'multipart/form-data') {\n body.activeBody = 'formData'\n body.formData = {\n encoding: contentType === 'application/x-www-form-urlencoded' ? 'urlencoded' : 'form-data',\n value: (requestBody?.params || []).map((param) => {\n if (param.value instanceof File) {\n return {\n key: param.name,\n value: 'BINARY',\n file: param.value,\n enabled: true,\n }\n }\n return {\n key: param.name,\n value: param.value || '',\n enabled: true,\n }\n }),\n }\n }\n\n // Add the content-type header if it doesn't exist and if it's not multipart request\n if (requestBody?.mimeType && !contentTypeHeader && !requestBody.mimeType.startsWith('multipart/')) {\n parameters.headers.push({\n key: 'Content-Type',\n value: requestBody.mimeType,\n enabled: true,\n })\n }\n }\n\n const serverVariables = server ? getServerVariableExamples(server) : {}\n\n // safe parse the example\n const example = schemaModel(\n {\n requestUid: request.uid,\n parameters,\n name,\n body,\n serverVariables,\n },\n requestExampleSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${request.uid} is invalid.`)\n return requestExampleSchema.parse({})\n }\n return example\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,iCAAiC;AAC1C,SAAS,cAAc;AACvB,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,mCAAmC;AAcrC,MAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC1B,OAAO,EAAE,OAAO,OAAO,EAAE,QAAQ,EAAE;AAAA,EACnC,SAAS,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EACjC,MAAM,EAAE,IAAI,EAAE,SAAS;AAAA,EACvB,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACnC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACpC,MAAM,EACH,MAAM;AAAA;AAAA,IAEL,EAAE,OAAO;AAAA;AAAA,IAET,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EACpB,CAAC,EACA,SAAS;AAAA,EACZ,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,IAAI,EAAE,SAAS;AAAA,EAC1B,UAAU,EAAE,QAAQ,EAAE,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AAAA,IACd;AAAA,MACE,YAAY,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,CAAC,SAAS;AACZ,YAAQ,KAAK,cAAc,QAAQ,GAAG,cAAc;AACpD,WAAO,qBAAqB,MAAM,CAAC,CAAC;AAAA,EACtC;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["example"]
|
|
7
7
|
}
|
|
@@ -151,6 +151,8 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
151
151
|
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
152
152
|
/** Response formats */
|
|
153
153
|
responses: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
154
|
+
/** Callbacks */
|
|
155
|
+
callbacks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>;
|
|
154
156
|
/** xScalar examples */
|
|
155
157
|
'x-scalar-examples': z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
156
158
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -267,6 +269,7 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
267
269
|
}[] | undefined;
|
|
268
270
|
requestBody?: any;
|
|
269
271
|
responses?: Record<string, any> | undefined;
|
|
272
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
270
273
|
'x-scalar-examples'?: Record<string, {
|
|
271
274
|
parameters: {
|
|
272
275
|
path?: Record<string, string> | undefined;
|
|
@@ -316,6 +319,7 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
316
319
|
}[] | undefined;
|
|
317
320
|
requestBody?: any;
|
|
318
321
|
responses?: Record<string, any> | undefined;
|
|
322
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
319
323
|
'x-scalar-examples'?: Record<string, {
|
|
320
324
|
parameters: {
|
|
321
325
|
path?: Record<string, string> | undefined;
|
|
@@ -452,6 +456,8 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
452
456
|
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
453
457
|
/** Response formats */
|
|
454
458
|
responses: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
459
|
+
/** Callbacks */
|
|
460
|
+
callbacks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>;
|
|
455
461
|
/** xScalar examples */
|
|
456
462
|
'x-scalar-examples': z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
457
463
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -635,6 +641,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
635
641
|
}[] | undefined;
|
|
636
642
|
requestBody?: any;
|
|
637
643
|
responses?: Record<string, any> | undefined;
|
|
644
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
638
645
|
'x-scalar-stability'?: XScalarStability | undefined;
|
|
639
646
|
'x-post-response'?: string | undefined;
|
|
640
647
|
'x-codeSamples'?: {
|
|
@@ -691,6 +698,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
691
698
|
}[] | undefined;
|
|
692
699
|
requestBody?: any;
|
|
693
700
|
responses?: Record<string, any> | undefined;
|
|
701
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
694
702
|
'x-scalar-stability'?: unknown;
|
|
695
703
|
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
696
704
|
'x-post-response'?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/requests.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,CAAC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IAErB,kDAAkD;;IAElD,oCAAoC;;IAEpC,uDAAuD;;IAEvD,+DAA+D;;;uBAzInC,EAAG,WAAW,CAAC,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsJ3B,CAAA;AAE7B,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
|
@@ -56,6 +56,8 @@ const oasRequestSchema = z.object({
|
|
|
56
56
|
"deprecated": z.boolean().optional(),
|
|
57
57
|
/** Response formats */
|
|
58
58
|
"responses": z.record(z.string(), z.any()).optional(),
|
|
59
|
+
/** Callbacks */
|
|
60
|
+
"callbacks": z.record(z.string(), z.record(z.string(), z.record(z.string(), z.any()))).optional(),
|
|
59
61
|
/** xScalar examples */
|
|
60
62
|
"x-scalar-examples": z.record(z.string(), xScalarExampleSchema).optional(),
|
|
61
63
|
/** Hide operations */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/requests.ts"],
|
|
4
|
-
"sourcesContent": ["import { selectedSecuritySchemeUidSchema } from '@/entities/shared/utility'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { type ZodSchema, z } from 'zod'\n\nimport {\n type PostResponseSchema,\n XCodeSamplesSchema,\n XPostResponseSchema,\n} from '@scalar/openapi-types/schemas/extensions'\nimport { XScalarStability } from '@scalar/types'\nimport { oasSecurityRequirementSchema } from '@scalar/types/entities'\nimport { oasParameterSchema } from './parameters'\nimport { type RequestExample, xScalarExampleSchema } from './request-examples'\nimport { oasExternalDocumentationSchema } from './spec-objects'\n\nexport const requestMethods = ['connect', 'delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace'] as const\n\nexport type RequestMethod = (typeof requestMethods)[number]\n\n/** A single set of populated values for a sent request */\nexport type ResponseInstance = Omit<Response, 'headers'> & {\n /** Store headers as an object to match what we had with axios */\n headers: Record<string, string>\n /** Keys of headers which set cookies */\n cookieHeaderKeys: string[]\n /** Time in ms the request took */\n duration: number\n /** The response status */\n status: number\n /** The response status text */\n statusText: string\n /** The response method */\n method: RequestMethod\n /** The request path */\n path: string\n} & (\n | {\n /** The response data */\n data: string | Blob\n /** The response size in bytes */\n size: number\n }\n | {\n /** A stream reader for a streamable response body */\n reader: ReadableStreamDefaultReader<Uint8Array>\n }\n )\n\n/** A single request/response set to save to the history stack */\nexport type RequestEvent = {\n request: RequestExample\n response: ResponseInstance\n timestamp: number\n}\n\n// TODO: Type body definitions\ntype RequestBody = object\nconst requestBodySchema = z.any() satisfies ZodSchema<RequestBody>\n\n/** Open API Compliant Request Validator */\nexport const oasRequestSchema = z.object({\n /**\n * A list of tags for API documentation control. Tags can be used for logical\n * grouping of operations by resources or any other qualifier.\n *\n * These tags are the openapi spec tag names, not uids\n */\n 'tags': z.string().array().optional(),\n /** A short summary of what the operation does. */\n 'summary': z.string().optional(),\n /** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */\n 'description': z.string().optional(),\n /**\n * Unique string used to identify the operation. The id MUST be unique among all operations described in the API.\n * The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an\n * operation, therefore, it is RECOMMENDED to follow bin common programming naming conventions./\n */\n 'operationId': z.string().optional(),\n /**\n * A declaration of which security mechanisms can be used across the API. The list of\n * values includes alternative security requirement objects that can be used. Only\n * one of the security requirement objects need to be satisfied to authorize a request.\n * Individual operations can override this definition. To make security optional, an empty\n * security requirement ({}) can be included in the array.\n */\n 'security': z.array(oasSecurityRequirementSchema).optional(),\n /**\n * The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the\n * HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the\n * HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined\n * semantics and SHOULD be avoided if possible.\n */\n 'requestBody': requestBodySchema.optional(),\n /**\n * Request parameters\n */\n 'parameters': oasParameterSchema.array().optional(),\n /**\n * External documentation object\n */\n 'externalDocs': oasExternalDocumentationSchema.optional(),\n 'deprecated': z.boolean().optional(),\n /** Response formats */\n 'responses': z.record(z.string(), z.any()).optional(),\n /** xScalar examples */\n 'x-scalar-examples': z.record(z.string(), xScalarExampleSchema).optional(),\n /** Hide operations */\n 'x-internal': z.boolean().optional(),\n /** Ignore operations */\n 'x-scalar-ignore': z.boolean().optional(),\n})\n\n/**\n * An OpenAPI extension to indicate the stability of the operation\n *\n * @example\n * ```yaml\n * x-scalar-stability: deprecated\n * ```\n */\nconst ScalarStabilitySchema = z.object({\n 'x-scalar-stability': z\n .enum([XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable])\n .optional()\n .catch(undefined),\n})\n\n/**\n * Extended properties added to the spec definition for client usage\n *\n * WARNING: DO NOT ADD PROPERTIES THAT SHARE A NAME WITH OAS OPERATION ENTITIES\n *\n * This object is directly converted to a spec operation during saving\n */\nconst extendedRequestSchema = z.object({\n type: z.literal('request').optional().default('request'),\n uid: nanoidSchema.brand<ENTITY_BRANDS['OPERATION']>(),\n /** Path Key */\n path: z.string().optional().default(''),\n /** Request Method */\n method: z.enum(requestMethods).default('get'),\n /** List of server UIDs specific to the request */\n servers: z.string().brand<ENTITY_BRANDS['SERVER']>().array().default([]),\n /** The currently selected server */\n selectedServerUid: z.string().brand<ENTITY_BRANDS['SERVER']>().optional().nullable().default(null),\n /** List of example UIDs associated with the request */\n examples: z.string().brand<ENTITY_BRANDS['EXAMPLE']>().array().default([]),\n /** List of security scheme UIDs associated with the request */\n selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,\n})\n\nexport type PostResponseScript = z.infer<typeof PostResponseSchema>\nexport type PostResponseScripts = z.infer<typeof XPostResponseSchema>['x-post-response']\n\n/** Unified request schema for client usage */\nexport const requestSchema = oasRequestSchema\n .omit({ 'x-scalar-examples': true })\n .merge(XCodeSamplesSchema)\n .merge(ScalarStabilitySchema)\n .merge(extendedRequestSchema)\n .merge(XPostResponseSchema)\n\nexport type Request = z.infer<typeof requestSchema>\nexport type RequestPayload = z.input<typeof requestSchema>\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,uCAAuC;AAChD,SAA6B,oBAAoB;AACjD,SAAyB,SAAS;AAElC;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,oCAAoC;AAC7C,SAAS,0BAA0B;AACnC,SAA8B,4BAA4B;AAC1D,SAAS,sCAAsC;AAExC,MAAM,iBAAiB,CAAC,WAAW,UAAU,OAAO,QAAQ,WAAW,SAAS,QAAQ,OAAO,OAAO;AA0C7G,MAAM,oBAAoB,EAAE,IAAI;AAGzB,MAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOvC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS;AAAA;AAAA,EAEpC,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE/B,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAY,EAAE,MAAM,4BAA4B,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3D,eAAe,kBAAkB,SAAS;AAAA;AAAA;AAAA;AAAA,EAI1C,cAAc,mBAAmB,MAAM,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAIlD,gBAAgB,+BAA+B,SAAS;AAAA,EACxD,cAAc,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAEnC,aA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oidSchema } from '@scalar/types/utils'\nimport { type ZodSchema, z } from 'zod'\n\nimport {\n type PostResponseSchema,\n XCodeSamplesSchema,\n XPostResponseSchema,\n} from '@scalar/openapi-types/schemas/extensions'\nimport { XScalarStability } from '@scalar/types'\nimport { oasSecurityRequirementSchema } from '@scalar/types/entities'\nimport { oasParameterSchema } from './parameters'\nimport { type RequestExample, xScalarExampleSchema } from './request-examples'\nimport { oasExternalDocumentationSchema } from './spec-objects'\n\nexport const requestMethods = ['connect', 'delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace'] as const\n\nexport type RequestMethod = (typeof requestMethods)[number]\n\n/** A single set of populated values for a sent request */\nexport type ResponseInstance = Omit<Response, 'headers'> & {\n /** Store headers as an object to match what we had with axios */\n headers: Record<string, string>\n /** Keys of headers which set cookies */\n cookieHeaderKeys: string[]\n /** Time in ms the request took */\n duration: number\n /** The response status */\n status: number\n /** The response status text */\n statusText: string\n /** The response method */\n method: RequestMethod\n /** The request path */\n path: string\n} & (\n | {\n /** The response data */\n data: string | Blob\n /** The response size in bytes */\n size: number\n }\n | {\n /** A stream reader for a streamable response body */\n reader: ReadableStreamDefaultReader<Uint8Array>\n }\n )\n\n/** A single request/response set to save to the history stack */\nexport type RequestEvent = {\n request: RequestExample\n response: ResponseInstance\n timestamp: number\n}\n\n// TODO: Type body definitions\ntype RequestBody = object\nconst requestBodySchema = z.any() satisfies ZodSchema<RequestBody>\n\n/** Open API Compliant Request Validator */\nexport const oasRequestSchema = z.object({\n /**\n * A list of tags for API documentation control. Tags can be used for logical\n * grouping of operations by resources or any other qualifier.\n *\n * These tags are the openapi spec tag names, not uids\n */\n 'tags': z.string().array().optional(),\n /** A short summary of what the operation does. */\n 'summary': z.string().optional(),\n /** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */\n 'description': z.string().optional(),\n /**\n * Unique string used to identify the operation. The id MUST be unique among all operations described in the API.\n * The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an\n * operation, therefore, it is RECOMMENDED to follow bin common programming naming conventions./\n */\n 'operationId': z.string().optional(),\n /**\n * A declaration of which security mechanisms can be used across the API. The list of\n * values includes alternative security requirement objects that can be used. Only\n * one of the security requirement objects need to be satisfied to authorize a request.\n * Individual operations can override this definition. To make security optional, an empty\n * security requirement ({}) can be included in the array.\n */\n 'security': z.array(oasSecurityRequirementSchema).optional(),\n /**\n * The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the\n * HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the\n * HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined\n * semantics and SHOULD be avoided if possible.\n */\n 'requestBody': requestBodySchema.optional(),\n /**\n * Request parameters\n */\n 'parameters': oasParameterSchema.array().optional(),\n /**\n * External documentation object\n */\n 'externalDocs': oasExternalDocumentationSchema.optional(),\n 'deprecated': z.boolean().optional(),\n /** Response formats */\n 'responses': z.record(z.string(), z.any()).optional(),\n /** Callbacks */\n 'callbacks': z.record(z.string(), z.record(z.string(), z.record(z.string(), z.any()))).optional(),\n /** xScalar examples */\n 'x-scalar-examples': z.record(z.string(), xScalarExampleSchema).optional(),\n /** Hide operations */\n 'x-internal': z.boolean().optional(),\n /** Ignore operations */\n 'x-scalar-ignore': z.boolean().optional(),\n})\n\n/**\n * An OpenAPI extension to indicate the stability of the operation\n *\n * @example\n * ```yaml\n * x-scalar-stability: deprecated\n * ```\n */\nconst ScalarStabilitySchema = z.object({\n 'x-scalar-stability': z\n .enum([XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable])\n .optional()\n .catch(undefined),\n})\n\n/**\n * Extended properties added to the spec definition for client usage\n *\n * WARNING: DO NOT ADD PROPERTIES THAT SHARE A NAME WITH OAS OPERATION ENTITIES\n *\n * This object is directly converted to a spec operation during saving\n */\nconst extendedRequestSchema = z.object({\n type: z.literal('request').optional().default('request'),\n uid: nanoidSchema.brand<ENTITY_BRANDS['OPERATION']>(),\n /** Path Key */\n path: z.string().optional().default(''),\n /** Request Method */\n method: z.enum(requestMethods).default('get'),\n /** List of server UIDs specific to the request */\n servers: z.string().brand<ENTITY_BRANDS['SERVER']>().array().default([]),\n /** The currently selected server */\n selectedServerUid: z.string().brand<ENTITY_BRANDS['SERVER']>().optional().nullable().default(null),\n /** List of example UIDs associated with the request */\n examples: z.string().brand<ENTITY_BRANDS['EXAMPLE']>().array().default([]),\n /** List of security scheme UIDs associated with the request */\n selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,\n})\n\nexport type PostResponseScript = z.infer<typeof PostResponseSchema>\nexport type PostResponseScripts = z.infer<typeof XPostResponseSchema>['x-post-response']\n\n/** Unified request schema for client usage */\nexport const requestSchema = oasRequestSchema\n .omit({ 'x-scalar-examples': true })\n .merge(XCodeSamplesSchema)\n .merge(ScalarStabilitySchema)\n .merge(extendedRequestSchema)\n .merge(XPostResponseSchema)\n\nexport type Request = z.infer<typeof requestSchema>\nexport type RequestPayload = z.input<typeof requestSchema>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,uCAAuC;AAChD,SAA6B,oBAAoB;AACjD,SAAyB,SAAS;AAElC;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,oCAAoC;AAC7C,SAAS,0BAA0B;AACnC,SAA8B,4BAA4B;AAC1D,SAAS,sCAAsC;AAExC,MAAM,iBAAiB,CAAC,WAAW,UAAU,OAAO,QAAQ,WAAW,SAAS,QAAQ,OAAO,OAAO;AA0C7G,MAAM,oBAAoB,EAAE,IAAI;AAGzB,MAAM,mBAAmB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOvC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS;AAAA;AAAA,EAEpC,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE/B,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,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AE5C,SAAS,EAAE,OAAO,EAAE,MAA+B,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEvE,mBAAmB,EAAE,OAAO,EAAE,MAA+B,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,IAAI;AAAA;AAAA,EAEjG,UAAU,EAAE,OAAO,EAAE,MAAgC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAEzE,4BAA4B;AAC9B,CAAC;AAMM,MAAM,gBAAgB,iBAC1B,KAAK,EAAE,qBAAqB,KAAK,CAAC,EAClC,MAAM,kBAAkB,EACxB,MAAM,qBAAqB,EAC3B,MAAM,qBAAqB,EAC3B,MAAM,mBAAmB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,47 +3,47 @@ const REQUEST_METHODS = {
|
|
|
3
3
|
get: {
|
|
4
4
|
short: "GET",
|
|
5
5
|
color: "text-blue",
|
|
6
|
-
backgroundColor: "bg-blue"
|
|
6
|
+
backgroundColor: "bg-blue/10"
|
|
7
7
|
},
|
|
8
8
|
post: {
|
|
9
9
|
short: "POST",
|
|
10
10
|
color: "text-green",
|
|
11
|
-
backgroundColor: "bg-green"
|
|
11
|
+
backgroundColor: "bg-green/10"
|
|
12
12
|
},
|
|
13
13
|
put: {
|
|
14
14
|
short: "PUT",
|
|
15
15
|
color: "text-orange",
|
|
16
|
-
backgroundColor: "bg-orange"
|
|
16
|
+
backgroundColor: "bg-orange/10"
|
|
17
17
|
},
|
|
18
18
|
patch: {
|
|
19
19
|
short: "PATCH",
|
|
20
20
|
color: "text-yellow",
|
|
21
|
-
backgroundColor: "bg-yellow"
|
|
21
|
+
backgroundColor: "bg-yellow/10"
|
|
22
22
|
},
|
|
23
23
|
delete: {
|
|
24
24
|
short: "DEL",
|
|
25
25
|
color: "text-red",
|
|
26
|
-
backgroundColor: "bg-red"
|
|
26
|
+
backgroundColor: "bg-red/10"
|
|
27
27
|
},
|
|
28
28
|
options: {
|
|
29
29
|
short: "OPTS",
|
|
30
30
|
color: "text-purple",
|
|
31
|
-
backgroundColor: "bg-purple"
|
|
31
|
+
backgroundColor: "bg-purple/10"
|
|
32
32
|
},
|
|
33
33
|
head: {
|
|
34
34
|
short: "HEAD",
|
|
35
35
|
color: "text-scalar-c-2",
|
|
36
|
-
backgroundColor: "bg-c-2"
|
|
36
|
+
backgroundColor: "bg-c-2/10"
|
|
37
37
|
},
|
|
38
38
|
connect: {
|
|
39
39
|
short: "CONN",
|
|
40
40
|
color: "text-c-2",
|
|
41
|
-
backgroundColor: "bg-c-2"
|
|
41
|
+
backgroundColor: "bg-c-2/10"
|
|
42
42
|
},
|
|
43
43
|
trace: {
|
|
44
44
|
short: "TRACE",
|
|
45
45
|
color: "text-c-2",
|
|
46
|
-
backgroundColor: "bg-c-2"
|
|
46
|
+
backgroundColor: "bg-c-2/10"
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const BODY_METHODS = ["post", "put", "patch", "delete"];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/http-methods.ts"],
|
|
4
|
-
"sourcesContent": ["import { type RequestMethod, requestMethods } from '@/entities/spec/requests'\n\n/**\n * HTTP methods in a specific order\n * Do not change the order\n */\nexport const REQUEST_METHODS: {\n [x in RequestMethod]: {\n short: string\n color: string\n backgroundColor: string\n }\n} = {\n get: {\n short: 'GET',\n color: 'text-blue',\n backgroundColor: 'bg-blue',\n },\n post: {\n short: 'POST',\n color: 'text-green',\n backgroundColor: 'bg-green',\n },\n put: {\n short: 'PUT',\n color: 'text-orange',\n backgroundColor: 'bg-orange',\n },\n patch: {\n short: 'PATCH',\n color: 'text-yellow',\n backgroundColor: 'bg-yellow',\n },\n delete: {\n short: 'DEL',\n color: 'text-red',\n backgroundColor: 'bg-red',\n },\n options: {\n short: 'OPTS',\n color: 'text-purple',\n backgroundColor: 'bg-purple',\n },\n head: {\n short: 'HEAD',\n color: 'text-scalar-c-2',\n backgroundColor: 'bg-c-2',\n },\n connect: {\n short: 'CONN',\n color: 'text-c-2',\n backgroundColor: 'bg-c-2',\n },\n trace: {\n short: 'TRACE',\n color: 'text-c-2',\n backgroundColor: 'bg-c-2',\n },\n} as const\n\n/** HTTP Methods which can have a body */\nconst BODY_METHODS = ['post', 'put', 'patch', 'delete'] as const\ntype BodyMethod = (typeof BODY_METHODS)[number]\n\n/** Makes a check to see if this method CAN have a body */\nexport const canMethodHaveBody = (method: RequestMethod): method is BodyMethod =>\n BODY_METHODS.includes(method as BodyMethod)\n\n/**\n * Accepts an HTTP Method name and returns some properties for the tag\n */\nexport const getHttpMethodInfo = (methodName: string) => {\n const normalizedMethod = methodName.trim().toLowerCase()\n return (\n REQUEST_METHODS[normalizedMethod as RequestMethod] ?? {\n short: normalizedMethod,\n color: 'text-c-2',\n backgroundColor: 'bg-c-2',\n }\n )\n}\n\n/** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */\nexport const isHttpMethod = (method?: string | undefined): method is RequestMethod =>\n method ? requestMethods.includes(method as RequestMethod) : false\n"],
|
|
4
|
+
"sourcesContent": ["import { type RequestMethod, requestMethods } from '@/entities/spec/requests'\n\n/**\n * HTTP methods in a specific order\n * Do not change the order\n */\nexport const REQUEST_METHODS: {\n [x in RequestMethod]: {\n short: string\n color: string\n backgroundColor: string\n }\n} = {\n get: {\n short: 'GET',\n color: 'text-blue',\n backgroundColor: 'bg-blue/10',\n },\n post: {\n short: 'POST',\n color: 'text-green',\n backgroundColor: 'bg-green/10',\n },\n put: {\n short: 'PUT',\n color: 'text-orange',\n backgroundColor: 'bg-orange/10',\n },\n patch: {\n short: 'PATCH',\n color: 'text-yellow',\n backgroundColor: 'bg-yellow/10',\n },\n delete: {\n short: 'DEL',\n color: 'text-red',\n backgroundColor: 'bg-red/10',\n },\n options: {\n short: 'OPTS',\n color: 'text-purple',\n backgroundColor: 'bg-purple/10',\n },\n head: {\n short: 'HEAD',\n color: 'text-scalar-c-2',\n backgroundColor: 'bg-c-2/10',\n },\n connect: {\n short: 'CONN',\n color: 'text-c-2',\n backgroundColor: 'bg-c-2/10',\n },\n trace: {\n short: 'TRACE',\n color: 'text-c-2',\n backgroundColor: 'bg-c-2/10',\n },\n} as const\n\n/** HTTP Methods which can have a body */\nconst BODY_METHODS = ['post', 'put', 'patch', 'delete'] as const\ntype BodyMethod = (typeof BODY_METHODS)[number]\n\n/** Makes a check to see if this method CAN have a body */\nexport const canMethodHaveBody = (method: RequestMethod): method is BodyMethod =>\n BODY_METHODS.includes(method as BodyMethod)\n\n/**\n * Accepts an HTTP Method name and returns some properties for the tag\n */\nexport const getHttpMethodInfo = (methodName: string) => {\n const normalizedMethod = methodName.trim().toLowerCase()\n return (\n REQUEST_METHODS[normalizedMethod as RequestMethod] ?? {\n short: normalizedMethod,\n color: 'text-c-2',\n backgroundColor: 'bg-c-2',\n }\n )\n}\n\n/** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */\nexport const isHttpMethod = (method?: string | undefined): method is RequestMethod =>\n method ? requestMethods.includes(method as RequestMethod) : false\n"],
|
|
5
5
|
"mappings": "AAAA,SAA6B,sBAAsB;AAM5C,MAAM,kBAMT;AAAA,EACF,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,KAAK;AAAA,IACH,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,SAAS;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AACF;AAGA,MAAM,eAAe,CAAC,QAAQ,OAAO,SAAS,QAAQ;AAI/C,MAAM,oBAAoB,CAAC,WAChC,aAAa,SAAS,MAAoB;AAKrC,MAAM,oBAAoB,CAAC,eAAuB;AACvD,QAAM,mBAAmB,WAAW,KAAK,EAAE,YAAY;AACvD,SACE,gBAAgB,gBAAiC,KAAK;AAAA,IACpD,OAAO;AAAA,IACP,OAAO;AAAA,IACP,iBAAiB;AAAA,EACnB;AAEJ;AAGO,MAAM,eAAe,CAAC,WAC3B,SAAS,eAAe,SAAS,MAAuB,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pretty-print-json.d.ts","sourceRoot":"","sources":["../../src/helpers/pretty-print-json.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,GAAG,MAAM,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"pretty-print-json.d.ts","sourceRoot":"","sources":["../../src/helpers/pretty-print-json.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,GAAG,MAAM,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,KAAG,MAqBnF,CAAA;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,GAAG,UAiBvD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/pretty-print-json.ts"],
|
|
4
|
-
"sourcesContent": ["import { isJsonString } from './parse'\n\n/**\n * Takes JSON and formats it.\n */\nexport const prettyPrintJson = (value: string | number | any[] | Record<any, any>) => {\n if (typeof value === 'string') {\n // JSON string\n if (isJsonString(value)) {\n return JSON.stringify(JSON.parse(value), null, 2)\n }\n\n // Regular string\n return value\n }\n\n // Object\n if (typeof value === 'object') {\n try {\n return JSON.stringify(value, null, 2)\n } catch {\n return replaceCircularDependencies(value)\n }\n }\n\n return value?.toString() ?? ''\n}\n\n/**\n * JSON.stringify, but with circular dependencies replaced with '[Circular]'\n */\nexport function replaceCircularDependencies(content: any) {\n const cache = new Set()\n\n return JSON.stringify(\n content,\n (_key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n return '[Circular]'\n }\n\n cache.add(value)\n }\n return value\n },\n 2,\n )\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAKtB,MAAM,kBAAkB,CAAC,
|
|
4
|
+
"sourcesContent": ["import { isJsonString } from './parse'\n\n/**\n * Takes JSON and formats it.\n */\nexport const prettyPrintJson = (value: string | number | any[] | Record<any, any>): string => {\n if (typeof value === 'string') {\n // JSON string\n if (isJsonString(value)) {\n return JSON.stringify(JSON.parse(value), null, 2)\n }\n\n // Regular string\n return value\n }\n\n // Object\n if (typeof value === 'object') {\n try {\n return JSON.stringify(value, null, 2)\n } catch {\n return replaceCircularDependencies(value)\n }\n }\n\n return value?.toString() ?? ''\n}\n\n/**\n * JSON.stringify, but with circular dependencies replaced with '[Circular]'\n */\nexport function replaceCircularDependencies(content: any) {\n const cache = new Set()\n\n return JSON.stringify(\n content,\n (_key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n return '[Circular]'\n }\n\n cache.add(value)\n }\n return value\n },\n 2,\n )\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAKtB,MAAM,kBAAkB,CAAC,UAA8D;AAC5F,MAAI,OAAO,UAAU,UAAU;AAE7B,QAAI,aAAa,KAAK,GAAG;AACvB,aAAO,KAAK,UAAU,KAAK,MAAM,KAAK,GAAG,MAAM,CAAC;AAAA,IAClD;AAGA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI;AACF,aAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,IACtC,QAAQ;AACN,aAAO,4BAA4B,KAAK;AAAA,IAC1C;AAAA,EACF;AAEA,SAAO,OAAO,SAAS,KAAK;AAC9B;AAKO,SAAS,4BAA4B,SAAc;AACxD,QAAM,QAAQ,oBAAI,IAAI;AAEtB,SAAO,KAAK;AAAA,IACV;AAAA,IACA,CAAC,MAAM,UAAU;AACf,UAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,YAAI,MAAM,IAAI,KAAK,GAAG;AACpB,iBAAO;AAAA,QACT;AAEA,cAAM,IAAI,KAAK;AAAA,MACjB;AACA,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,8 +9,9 @@ import { type Server } from '../entities/spec/server.js';
|
|
|
9
9
|
import { type Tag } from '../entities/spec/spec-objects.js';
|
|
10
10
|
import { type SecurityScheme } from '@scalar/types/entities';
|
|
11
11
|
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
12
|
-
export declare const parseSchema: (
|
|
13
|
-
shouldLoad?: boolean
|
|
12
|
+
export declare const parseSchema: (originalDocument: string | UnknownObject | undefined, { shouldLoad, dereferencedDocument, }?: {
|
|
13
|
+
shouldLoad?: boolean;
|
|
14
|
+
dereferencedDocument?: OpenAPIV3_1.Document;
|
|
14
15
|
}) => Promise<{
|
|
15
16
|
/**
|
|
16
17
|
* Temporary fix for the parser returning an empty array
|
|
@@ -24,6 +25,8 @@ export declare const getSelectedSecuritySchemeUids: (securityRequirements: (stri
|
|
|
24
25
|
/** Create a "uid" from a slug */
|
|
25
26
|
export declare const getSlugUid: (slug: string) => Collection["uid"];
|
|
26
27
|
export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> & Pick<ApiReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers' | 'slug'> & {
|
|
28
|
+
/** The dereferenced document */
|
|
29
|
+
dereferencedDocument?: OpenAPIV3_1.Document;
|
|
27
30
|
/** Sets the preferred security scheme on the collection instead of the requests */
|
|
28
31
|
useCollectionSecurity?: boolean;
|
|
29
32
|
/** Call the load step from the parser */
|
|
@@ -42,7 +45,9 @@ export type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' |
|
|
|
42
45
|
* - Proper linking between related components
|
|
43
46
|
* - Easy lookup and reference of dependent entities
|
|
44
47
|
*/
|
|
45
|
-
export declare function importSpecToWorkspace(
|
|
48
|
+
export declare function importSpecToWorkspace(content: string | UnknownObject | undefined, {
|
|
49
|
+
/** If a dereferenced document is provided, we will skip the dereferencing step. */
|
|
50
|
+
dereferencedDocument, authentication, baseServerURL, documentUrl, servers: configuredServers, useCollectionSecurity, slug, shouldLoad, watchMode, }?: ImportSpecToWorkspaceArgs): Promise<{
|
|
46
51
|
error: false;
|
|
47
52
|
collection: Collection;
|
|
48
53
|
requests: Request[];
|