@scalar/oas-utils 0.10.8 → 0.10.9
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 +6 -0
- package/dist/entities/cookie/cookie.js +11 -15
- package/dist/entities/cookie/index.js +1 -5
- package/dist/entities/environment/environment.js +7 -11
- package/dist/entities/environment/index.js +1 -5
- package/dist/entities/hotkeys/hotkeys.js +116 -111
- package/dist/entities/hotkeys/index.js +1 -6
- package/dist/entities/shared/index.js +1 -7
- package/dist/entities/shared/utility.js +9 -9
- package/dist/entities/spec/collection.js +91 -89
- package/dist/entities/spec/index.js +10 -59
- package/dist/entities/spec/operation.js +6 -6
- package/dist/entities/spec/parameters.js +38 -38
- package/dist/entities/spec/request-examples.js +421 -331
- package/dist/entities/spec/requests.js +102 -84
- package/dist/entities/spec/server.js +61 -46
- package/dist/entities/spec/spec-objects.js +121 -76
- package/dist/entities/spec/x-scalar-environments.js +18 -20
- package/dist/entities/spec/x-scalar-secrets.js +6 -8
- package/dist/entities/workspace/index.js +1 -7
- package/dist/entities/workspace/workspace.js +47 -46
- package/dist/helpers/client-plugins.js +13 -13
- package/dist/helpers/fetch-document.js +30 -25
- package/dist/helpers/fetch-with-proxy-fallback.js +26 -21
- package/dist/helpers/index.d.ts +1 -2
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +80 -119
- package/dist/helpers/normalize-mime-type-object.js +19 -18
- package/dist/helpers/normalize-mime-type.js +11 -9
- package/dist/helpers/operation-stability.js +25 -20
- package/dist/helpers/parse.d.ts +0 -4
- package/dist/helpers/parse.d.ts.map +1 -1
- package/dist/helpers/parse.js +77 -77
- package/dist/helpers/schema-model.js +13 -16
- package/dist/helpers/security/get-schemes.js +7 -8
- package/dist/helpers/security/has-token.js +18 -19
- package/dist/helpers/security/index.js +2 -7
- package/dist/helpers/servers.js +128 -79
- package/dist/helpers/should-ignore-entity.js +4 -5
- package/dist/migrations/data-version.js +15 -7
- package/dist/migrations/generate-types.js +34 -37
- package/dist/migrations/index.js +4 -18
- package/dist/migrations/local-storage.js +31 -29
- package/dist/migrations/migrate-to-indexdb.js +706 -529
- package/dist/migrations/migrator.js +58 -54
- package/dist/migrations/semver.js +24 -24
- package/dist/migrations/v-0.0.0/types.generated.js +1 -1
- package/dist/migrations/v-2.1.0/migration.js +272 -258
- package/dist/migrations/v-2.1.0/types.generated.js +1 -1
- package/dist/migrations/v-2.2.0/migration.js +99 -96
- package/dist/migrations/v-2.2.0/types.generated.js +1 -1
- package/dist/migrations/v-2.3.0/migration.js +45 -48
- package/dist/migrations/v-2.3.0/types.generated.js +1 -1
- package/dist/migrations/v-2.4.0/migration.js +25 -25
- package/dist/migrations/v-2.4.0/types.generated.js +1 -1
- package/dist/migrations/v-2.5.0/migration.js +122 -139
- package/dist/migrations/v-2.5.0/types.generated.js +1 -1
- package/dist/spec-getters/get-example-from-schema.js +489 -385
- package/dist/spec-getters/get-parameters-from-operation.js +39 -23
- package/dist/spec-getters/get-request-body-from-operation.d.ts.map +1 -1
- package/dist/spec-getters/get-request-body-from-operation.js +168 -126
- package/dist/spec-getters/get-server-variable-examples.js +10 -13
- package/dist/spec-getters/index.js +4 -11
- package/dist/transforms/import-spec.js +381 -291
- package/dist/transforms/index.js +1 -11
- package/package.json +15 -19
- package/dist/entities/cookie/cookie.js.map +0 -7
- package/dist/entities/cookie/index.js.map +0 -7
- package/dist/entities/environment/environment.js.map +0 -7
- package/dist/entities/environment/index.js.map +0 -7
- package/dist/entities/hotkeys/hotkeys.js.map +0 -7
- package/dist/entities/hotkeys/index.js.map +0 -7
- package/dist/entities/shared/index.js.map +0 -7
- package/dist/entities/shared/utility.js.map +0 -7
- package/dist/entities/spec/collection.js.map +0 -7
- package/dist/entities/spec/index.js.map +0 -7
- package/dist/entities/spec/operation.js.map +0 -7
- package/dist/entities/spec/parameters.js.map +0 -7
- package/dist/entities/spec/request-examples.js.map +0 -7
- package/dist/entities/spec/requests.js.map +0 -7
- package/dist/entities/spec/server.js.map +0 -7
- package/dist/entities/spec/spec-objects.js.map +0 -7
- package/dist/entities/spec/x-scalar-environments.js.map +0 -7
- package/dist/entities/spec/x-scalar-secrets.js.map +0 -7
- package/dist/entities/workspace/index.js.map +0 -7
- package/dist/entities/workspace/workspace.js.map +0 -7
- package/dist/helpers/client-plugins.js.map +0 -7
- package/dist/helpers/fetch-document.js.map +0 -7
- package/dist/helpers/fetch-with-proxy-fallback.js.map +0 -7
- package/dist/helpers/index.js.map +0 -7
- package/dist/helpers/normalize-mime-type-object.js.map +0 -7
- package/dist/helpers/normalize-mime-type.js.map +0 -7
- package/dist/helpers/operation-stability.js.map +0 -7
- package/dist/helpers/parse.js.map +0 -7
- package/dist/helpers/pretty-print-json.d.ts +0 -9
- package/dist/helpers/pretty-print-json.d.ts.map +0 -1
- package/dist/helpers/pretty-print-json.js +0 -38
- package/dist/helpers/pretty-print-json.js.map +0 -7
- package/dist/helpers/schema-model.js.map +0 -7
- package/dist/helpers/security/get-schemes.js.map +0 -7
- package/dist/helpers/security/has-token.js.map +0 -7
- package/dist/helpers/security/index.js.map +0 -7
- package/dist/helpers/servers.js.map +0 -7
- package/dist/helpers/should-ignore-entity.js.map +0 -7
- package/dist/migrations/data-version.js.map +0 -7
- package/dist/migrations/generate-types.js.map +0 -7
- package/dist/migrations/index.js.map +0 -7
- package/dist/migrations/local-storage.js.map +0 -7
- package/dist/migrations/migrate-to-indexdb.js.map +0 -7
- package/dist/migrations/migrator.js.map +0 -7
- package/dist/migrations/semver.js.map +0 -7
- package/dist/migrations/v-0.0.0/types.generated.js.map +0 -7
- package/dist/migrations/v-2.1.0/migration.js.map +0 -7
- package/dist/migrations/v-2.1.0/types.generated.js.map +0 -7
- package/dist/migrations/v-2.2.0/migration.js.map +0 -7
- package/dist/migrations/v-2.2.0/types.generated.js.map +0 -7
- package/dist/migrations/v-2.3.0/migration.js.map +0 -7
- package/dist/migrations/v-2.3.0/types.generated.js.map +0 -7
- package/dist/migrations/v-2.4.0/migration.js.map +0 -7
- package/dist/migrations/v-2.4.0/types.generated.js.map +0 -7
- package/dist/migrations/v-2.5.0/migration.js.map +0 -7
- package/dist/migrations/v-2.5.0/types.generated.js.map +0 -7
- package/dist/spec-getters/get-example-from-schema.js.map +0 -7
- package/dist/spec-getters/get-parameters-from-operation.js.map +0 -7
- package/dist/spec-getters/get-request-body-from-operation.js.map +0 -7
- package/dist/spec-getters/get-server-variable-examples.js.map +0 -7
- package/dist/spec-getters/index.js.map +0 -7
- package/dist/transforms/import-spec.js.map +0 -7
- package/dist/transforms/index.js.map +0 -7
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import { themeIds } from
|
|
2
|
-
import { nanoidSchema } from
|
|
3
|
-
import { z } from
|
|
4
|
-
import { HOTKEY_EVENT_NAMES, KEYDOWN_KEYS } from
|
|
5
|
-
const modifiers = z
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { themeIds } from '@scalar/themes';
|
|
2
|
+
import { nanoidSchema } from '@scalar/types/utils';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { HOTKEY_EVENT_NAMES, KEYDOWN_KEYS } from '../hotkeys/hotkeys.js';
|
|
5
|
+
const modifiers = z
|
|
6
|
+
.array(z.union([z.literal('Meta'), z.literal('Control'), z.literal('Shift'), z.literal('Alt'), z.literal('default')]))
|
|
7
|
+
.optional()
|
|
8
|
+
.default(['default']);
|
|
9
|
+
const hotKeys = z.partialRecord(z.enum(KEYDOWN_KEYS), z.object({
|
|
9
10
|
modifiers: modifiers.optional(),
|
|
10
|
-
event: z.enum(HOTKEY_EVENT_NAMES)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
11
|
+
event: z.enum(HOTKEY_EVENT_NAMES),
|
|
12
|
+
}));
|
|
13
|
+
const hotKeyConfigSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
modifiers,
|
|
16
|
+
hotKeys: hotKeys.optional(),
|
|
17
|
+
})
|
|
18
|
+
.optional();
|
|
19
|
+
export const workspaceSchema = z.object({
|
|
20
|
+
uid: nanoidSchema.brand(),
|
|
21
|
+
name: z.string().default('Default Workspace'),
|
|
22
|
+
/** Workspace description */
|
|
23
|
+
description: z.string().default('Basic Scalar Workspace'),
|
|
24
|
+
/** List of all collection uids in a given workspace */
|
|
25
|
+
collections: z.array(z.string().brand()).default([]),
|
|
26
|
+
/** List of all environment uids in a given workspace, TODO: why is this a record? */
|
|
27
|
+
environments: z.record(z.string(), z.string()).default({}),
|
|
28
|
+
/** Customize hotkeys */
|
|
29
|
+
hotKeyConfig: hotKeyConfigSchema,
|
|
30
|
+
/** Active Environment ID to use for requests */
|
|
31
|
+
activeEnvironmentId: z.string().optional().default('default'),
|
|
32
|
+
/** List of all cookie uids in a given workspace */
|
|
33
|
+
cookies: z.array(z.string().brand()).default([]),
|
|
34
|
+
/** Workspace level proxy for all requests to be sent through */
|
|
35
|
+
proxyUrl: z.string().optional(),
|
|
36
|
+
/** Workspace level theme, we might move this to user level later */
|
|
37
|
+
themeId: z.enum(themeIds).optional().default('default').catch('default'),
|
|
38
|
+
/** Currently selected snippet client */
|
|
39
|
+
selectedHttpClient: z
|
|
40
|
+
.object({
|
|
41
|
+
targetKey: z.string(),
|
|
42
|
+
clientKey: z.string(),
|
|
43
|
+
})
|
|
44
|
+
.optional()
|
|
45
|
+
.default({
|
|
46
|
+
targetKey: 'shell',
|
|
47
|
+
clientKey: 'curl',
|
|
48
|
+
}),
|
|
44
49
|
});
|
|
45
|
-
export {
|
|
46
|
-
workspaceSchema
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=workspace.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Execute any hook with type-safe payload handling.
|
|
3
|
+
* The payload type is inferred from the hook name to ensure correct usage.
|
|
4
|
+
*/
|
|
5
|
+
export const executeHook = async (payload, hookName, plugins) => {
|
|
6
|
+
let currentPayload = payload;
|
|
7
|
+
for (const plugin of plugins) {
|
|
8
|
+
const hook = plugin.hooks?.[hookName];
|
|
9
|
+
if (hook) {
|
|
10
|
+
const modifiedPayload = await hook(currentPayload);
|
|
11
|
+
currentPayload = (modifiedPayload ?? currentPayload);
|
|
12
|
+
}
|
|
8
13
|
}
|
|
9
|
-
|
|
10
|
-
return currentPayload;
|
|
14
|
+
return currentPayload;
|
|
11
15
|
};
|
|
12
|
-
export {
|
|
13
|
-
executeHook
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=client-plugins.js.map
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { redirectToProxy } from
|
|
2
|
-
import { formatJsonOrYamlString } from
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { redirectToProxy } from '@scalar/helpers/url/redirect-to-proxy';
|
|
2
|
+
import { formatJsonOrYamlString } from './parse.js';
|
|
3
|
+
// Doesn't work
|
|
4
|
+
const OLD_PROXY_URL = 'https://api.scalar.com/request-proxy';
|
|
5
|
+
// Does work
|
|
6
|
+
const NEW_PROXY_URL = 'https://proxy.scalar.com';
|
|
7
|
+
/**
|
|
8
|
+
* Fetches an OpenAPI/Swagger document from a given URL
|
|
9
|
+
*
|
|
10
|
+
* @throws an error if the fetch fails
|
|
11
|
+
*/
|
|
12
|
+
export async function fetchDocument(url, proxyUrl, fetcher, prettyPrint = true) {
|
|
13
|
+
// This replaces the OLD_PROXY_URL with the NEW_PROXY_URL on the fly.
|
|
14
|
+
if (proxyUrl === OLD_PROXY_URL) {
|
|
15
|
+
// biome-ignore lint/style/noParameterAssign: It's ok, let's make an exception here.
|
|
16
|
+
proxyUrl = NEW_PROXY_URL;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const response = await (fetcher ? fetcher(url, undefined) : fetch(redirectToProxy(proxyUrl, url)));
|
|
19
|
+
// Looks like the request failed
|
|
20
|
+
if (response.status !== 200) {
|
|
21
|
+
console.error(`[fetchDocument] Failed to fetch the OpenAPI document from ${url} (Status: ${response.status})`);
|
|
22
|
+
if (!proxyUrl) {
|
|
23
|
+
console.warn(`[fetchDocument] Tried to fetch the OpenAPI document from ${url} without a proxy. Are the CORS headers configured to allow cross-domain requests? https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS`);
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Failed to fetch the OpenAPI document from ${url} (Status: ${response.status})`);
|
|
26
|
+
}
|
|
27
|
+
// If it's JSON, make it pretty
|
|
28
|
+
if (prettyPrint) {
|
|
29
|
+
return formatJsonOrYamlString(await response.text());
|
|
30
|
+
}
|
|
31
|
+
return await response.text();
|
|
23
32
|
}
|
|
24
|
-
export {
|
|
25
|
-
fetchDocument
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=fetch-document.js.map
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import { redirectToProxy, shouldUseProxy } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { redirectToProxy, shouldUseProxy } from '@scalar/helpers/url/redirect-to-proxy';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches an OpenAPI document with a proxyUrl fallback mechanism.
|
|
4
|
+
*
|
|
5
|
+
* If a proxy is provided and the URL requires it, it will first attempt to fetch using the proxy.
|
|
6
|
+
* If the proxy fetch fails or is not used, it will fall back to a direct fetch.
|
|
7
|
+
*/
|
|
8
|
+
export async function fetchWithProxyFallback(url, { proxyUrl, cache }) {
|
|
9
|
+
const fetchOptions = {
|
|
10
|
+
cache: cache || 'default',
|
|
11
|
+
};
|
|
12
|
+
const shouldTryProxy = shouldUseProxy(proxyUrl, url);
|
|
13
|
+
const initialUrl = shouldTryProxy ? redirectToProxy(proxyUrl, url) : url;
|
|
14
|
+
try {
|
|
15
|
+
const result = await fetch(initialUrl, fetchOptions);
|
|
16
|
+
if (result.ok || !shouldTryProxy) {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
// Retry without proxyUrl if the initial request failed
|
|
20
|
+
return await fetch(url, fetchOptions);
|
|
12
21
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (shouldTryProxy) {
|
|
24
|
+
// If proxyUrl failed, try without it
|
|
25
|
+
return await fetch(url, fetchOptions);
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
17
28
|
}
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
29
|
}
|
|
21
|
-
export {
|
|
22
|
-
fetchWithProxyFallback
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=fetch-with-proxy-fallback.js.map
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -78,8 +78,7 @@ export { type FetchWithProxyFallbackOptions, fetchWithProxyFallback } from './fe
|
|
|
78
78
|
export { normalizeMimeType } from './normalize-mime-type.js';
|
|
79
79
|
export { normalizeMimeTypeObject } from './normalize-mime-type-object.js';
|
|
80
80
|
export { getOperationStability, getOperationStabilityColor, isOperationDeprecated } from './operation-stability.js';
|
|
81
|
-
export { formatJsonOrYamlString,
|
|
82
|
-
export { prettyPrintJson, replaceCircularDependencies } from './pretty-print-json.js';
|
|
81
|
+
export { formatJsonOrYamlString, json, parseJsonOrYaml, transformToJson, yaml } from './parse.js';
|
|
83
82
|
export { schemaModel } from './schema-model.js';
|
|
84
83
|
export { getServersFromDocument } from './servers.js';
|
|
85
84
|
export { shouldIgnoreEntity } from './should-ignore-entity.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACL,sFAAsF;AACtF,SAAS,GACV,MAAM,kCAAkC,CAAA;AACzC,OAAO;AACL,kFAAkF;AAClF,QAAQ,GACT,MAAM,+BAA+B,CAAA;AACtC,OAAO;AACL,uGAAuG;AACvG,iBAAiB,GAClB,MAAM,2CAA2C,CAAA;AAClD,OAAO;AACL,6FAA6F;AAC7F,eAAe;AACf,4FAA4F;AAC5F,iBAAiB,GAClB,MAAM,gCAAgC,CAAA;AACvC,OAAO;AACL,iGAAiG;AACjG,KAAK,cAAc;AACnB,kGAAkG;AAClG,KAAK,eAAe;AACpB,kGAAkG;AAClG,eAAe,GAChB,MAAM,wCAAwC,CAAA;AAC/C,OAAO;AACL,4FAA4F;AAC5F,YAAY,GACb,MAAM,qCAAqC,CAAA;AAC5C,OAAO;AACL,yFAAyF;AACzF,UAAU,IAAI,aAAa,GAC5B,MAAM,oCAAoC,CAAA;AAC3C,OAAO;AACL,8FAA8F;AAC9F,aAAa,GACd,MAAM,sCAAsC,CAAA;AAC7C,OAAO;AACL,qFAAqF;AACrF,KAAK,GACN,MAAM,qCAAqC,CAAA;AAC5C,OAAO;AACL,oGAAoG;AACpG,gBAAgB,GACjB,MAAM,yCAAyC,CAAA;AAChD,OAAO;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28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
} from
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
combineUrlAndPath,
|
|
82
|
-
createHash,
|
|
83
|
-
ensureProtocol,
|
|
84
|
-
executeHook,
|
|
85
|
-
fetchDocument,
|
|
86
|
-
fetchWithProxyFallback,
|
|
87
|
-
findVariables,
|
|
88
|
-
formatJsonOrYamlString,
|
|
89
|
-
getHttpMethodInfo,
|
|
90
|
-
objectKeys as getObjectKeys,
|
|
91
|
-
getOperationStability,
|
|
92
|
-
getOperationStabilityColor,
|
|
93
|
-
getServersFromDocument,
|
|
94
|
-
httpStatusCodes,
|
|
95
|
-
isDefined,
|
|
96
|
-
isHttpMethod,
|
|
97
|
-
isJsonString,
|
|
98
|
-
isLocalUrl,
|
|
99
|
-
isOperationDeprecated,
|
|
100
|
-
isRelativePath,
|
|
101
|
-
isValidUrl,
|
|
102
|
-
iterateTitle,
|
|
103
|
-
json,
|
|
104
|
-
json2xml,
|
|
105
|
-
makeUrlAbsolute,
|
|
106
|
-
mergeSearchParams,
|
|
107
|
-
mergeUrls,
|
|
108
|
-
normalizeMimeType,
|
|
109
|
-
normalizeMimeTypeObject,
|
|
110
|
-
parseJsonOrYaml,
|
|
111
|
-
prettyPrintJson,
|
|
112
|
-
replaceCircularDependencies,
|
|
113
|
-
replaceVariables,
|
|
114
|
-
schemaModel,
|
|
115
|
-
shouldIgnoreEntity,
|
|
116
|
-
transformToJson,
|
|
117
|
-
yaml
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export {
|
|
2
|
+
/** @deprecated Please use isDefined from \@scalar/helpers/array/is-defined instead */
|
|
3
|
+
isDefined, } from '@scalar/helpers/array/is-defined';
|
|
4
|
+
export {
|
|
5
|
+
/** @deprecated Please use json2xml from \@scalar/helpers/file/json2xml instead */
|
|
6
|
+
json2xml, } from '@scalar/helpers/file/json2xml';
|
|
7
|
+
export {
|
|
8
|
+
/** @deprecated Please use canMethodHaveBody from \@scalar/helpers/http/can-method-have-body instead */
|
|
9
|
+
canMethodHaveBody, } from '@scalar/helpers/http/can-method-have-body';
|
|
10
|
+
export {
|
|
11
|
+
/** @deprecated Please use REQUEST_METHODS from \@scalar/helpers/http/http-methods instead */
|
|
12
|
+
REQUEST_METHODS,
|
|
13
|
+
/** @deprecated Please use getHttpMethodInfo from \@scalar/helpers/http/http-info instead */
|
|
14
|
+
getHttpMethodInfo, } from '@scalar/helpers/http/http-info';
|
|
15
|
+
export {
|
|
16
|
+
/** @deprecated Please use httpStatusCodes from \@scalar/helpers/http/http-status-codes instead */
|
|
17
|
+
httpStatusCodes, } from '@scalar/helpers/http/http-status-codes';
|
|
18
|
+
export {
|
|
19
|
+
/** @deprecated Please use isHttpMethod from \@scalar/helpers/http/is-http-method instead */
|
|
20
|
+
isHttpMethod, } from '@scalar/helpers/http/is-http-method';
|
|
21
|
+
export {
|
|
22
|
+
/** @deprecated Please use objectKeys from \@scalar/helpers/object/object-keys instead */
|
|
23
|
+
objectKeys as getObjectKeys, } from '@scalar/helpers/object/object-keys';
|
|
24
|
+
export {
|
|
25
|
+
/** @deprecated Please use findVariables from \@scalar/helpers/regex/find-variables instead */
|
|
26
|
+
findVariables, } from '@scalar/helpers/regex/find-variables';
|
|
27
|
+
export {
|
|
28
|
+
/** @deprecated Please use REGEX from \@scalar/helpers/regex/regex-helpers instead */
|
|
29
|
+
REGEX, } from '@scalar/helpers/regex/regex-helpers';
|
|
30
|
+
export {
|
|
31
|
+
/** @deprecated Please use replaceVariables from \@scalar/helpers/regex/replace-variables instead */
|
|
32
|
+
replaceVariables, } from '@scalar/helpers/regex/replace-variables';
|
|
33
|
+
export {
|
|
34
|
+
/** @deprecated Please use camelToTitleWords from \@scalar/helpers/string/camel-to-title instead */
|
|
35
|
+
camelToTitleWords, } from '@scalar/helpers/string/camel-to-title';
|
|
36
|
+
export {
|
|
37
|
+
/** @deprecated Please use capitalize from \@scalar/helpers/string/capitalize instead */
|
|
38
|
+
capitalize, } from '@scalar/helpers/string/capitalize';
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated These helpers are being phased out. Please import directly from @scalar/helpers instead.
|
|
41
|
+
* For example: import { createHash } from '/@scalar/helpers/string/create-hash'
|
|
42
|
+
*/
|
|
43
|
+
export {
|
|
44
|
+
/** @deprecated Please use createHash from \@scalar/helpers/string/create-hash instead */
|
|
45
|
+
createHash, } from '@scalar/helpers/string/create-hash';
|
|
46
|
+
export {
|
|
47
|
+
/** @deprecated Please use iterateTitle from \@scalar/helpers/string/iterate-title instead */
|
|
48
|
+
iterateTitle, } from '@scalar/helpers/string/iterate-title';
|
|
49
|
+
export {
|
|
50
|
+
/** @deprecated Please use ensureProtocol from \@scalar/helpers/url/ensure-protocol instead */
|
|
51
|
+
ensureProtocol, } from '@scalar/helpers/url/ensure-protocol';
|
|
52
|
+
export {
|
|
53
|
+
/** @deprecated Please use isLocalUrl from \@scalar/helpers/url/is-local-url instead */
|
|
54
|
+
isLocalUrl, } from '@scalar/helpers/url/is-local-url';
|
|
55
|
+
export {
|
|
56
|
+
/** @deprecated Please use isRelativePath from \@scalar/helpers/url/is-relative-path instead */
|
|
57
|
+
isRelativePath, } from '@scalar/helpers/url/is-relative-path';
|
|
58
|
+
export {
|
|
59
|
+
/** @deprecated Please use isValidUrl from \@scalar/helpers/url/is-valid-url instead */
|
|
60
|
+
isValidUrl, } from '@scalar/helpers/url/is-valid-url';
|
|
61
|
+
export {
|
|
62
|
+
/** @deprecated Please use makeUrlAbsolute from \@scalar/helpers/url/make-url-absolute instead */
|
|
63
|
+
makeUrlAbsolute, } from '@scalar/helpers/url/make-url-absolute';
|
|
64
|
+
export {
|
|
65
|
+
/** @deprecated Please use combineUrlAndPath from \@scalar/helpers/url/merge-urls instead */
|
|
66
|
+
combineUrlAndPath,
|
|
67
|
+
/** @deprecated Please use mergeSearchParams from \@scalar/helpers/url/merge-urls instead */
|
|
68
|
+
mergeSearchParams,
|
|
69
|
+
/** @deprecated Please use mergeUrls from \@scalar/helpers/url/merge-urls instead */
|
|
70
|
+
mergeUrls, } from '@scalar/helpers/url/merge-urls';
|
|
71
|
+
export { executeHook } from './client-plugins.js';
|
|
72
|
+
export { fetchDocument } from './fetch-document.js';
|
|
73
|
+
export { fetchWithProxyFallback } from './fetch-with-proxy-fallback.js';
|
|
74
|
+
export { normalizeMimeType } from './normalize-mime-type.js';
|
|
75
|
+
export { normalizeMimeTypeObject } from './normalize-mime-type-object.js';
|
|
76
|
+
export { getOperationStability, getOperationStabilityColor, isOperationDeprecated } from './operation-stability.js';
|
|
77
|
+
export { formatJsonOrYamlString, json, parseJsonOrYaml, transformToJson, yaml } from './parse.js';
|
|
78
|
+
export { schemaModel } from './schema-model.js';
|
|
79
|
+
export { getServersFromDocument } from './servers.js';
|
|
80
|
+
export { shouldIgnoreEntity } from './should-ignore-entity.js';
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { normalizeMimeType } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const normalizedKey = normalizeMimeType(key);
|
|
11
|
-
if (normalizedKey) {
|
|
12
|
-
newContent[normalizedKey] = value;
|
|
1
|
+
import { normalizeMimeType } from './normalize-mime-type.js';
|
|
2
|
+
/**
|
|
3
|
+
* Remove charset from content types
|
|
4
|
+
*
|
|
5
|
+
* Example: `application/json; charset=utf-8` -> `application/json`
|
|
6
|
+
*/
|
|
7
|
+
export function normalizeMimeTypeObject(content) {
|
|
8
|
+
if (!content) {
|
|
9
|
+
return content;
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const newContent = {
|
|
12
|
+
...content,
|
|
13
|
+
};
|
|
14
|
+
Object.entries(newContent).forEach(([key, value]) => {
|
|
15
|
+
const normalizedKey = normalizeMimeType(key);
|
|
16
|
+
if (normalizedKey) {
|
|
17
|
+
newContent[normalizedKey] = value;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return newContent;
|
|
16
21
|
}
|
|
17
|
-
export {
|
|
18
|
-
normalizeMimeTypeObject
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=normalize-mime-type-object.js.map
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
function normalizeMimeType(contentType) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export function normalizeMimeType(contentType) {
|
|
2
|
+
if (typeof contentType !== 'string') {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
return contentType
|
|
6
|
+
// Remove '; charset=utf-8'
|
|
7
|
+
.replace(/;.*$/, '')
|
|
8
|
+
// Remove 'problem+' but keep vendor-specific vnd and fhir mime types
|
|
9
|
+
.replace(/\/(?!.*vnd\.|fhir\+).*\+/, '/')
|
|
10
|
+
// Remove whitespace
|
|
11
|
+
.trim();
|
|
6
12
|
}
|
|
7
|
-
export {
|
|
8
|
-
normalizeMimeType
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=normalize-mime-type.js.map
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { XScalarStabilityValues } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { XScalarStabilityValues } from '@scalar/openapi-types/schemas/extensions';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if an operation is considered deprecated.
|
|
4
|
+
*/
|
|
5
|
+
export const isOperationDeprecated = (operation) => operation.deprecated || operation['x-scalar-stability'] === XScalarStabilityValues.Deprecated;
|
|
6
|
+
/**
|
|
7
|
+
* Get operation stability from deprecated or x-scalar-stability
|
|
8
|
+
*/
|
|
9
|
+
export const getOperationStability = (operation) => operation.deprecated
|
|
10
|
+
? XScalarStabilityValues.Deprecated
|
|
11
|
+
: operation['x-scalar-stability'];
|
|
12
|
+
/**
|
|
13
|
+
* Get Operation stability tailwind color class
|
|
14
|
+
*/
|
|
15
|
+
export const getOperationStabilityColor = (operation) => {
|
|
16
|
+
switch (getOperationStability(operation)) {
|
|
17
|
+
case XScalarStabilityValues.Deprecated:
|
|
18
|
+
return 'text-red';
|
|
19
|
+
case XScalarStabilityValues.Experimental:
|
|
20
|
+
return 'text-orange';
|
|
21
|
+
case XScalarStabilityValues.Stable:
|
|
22
|
+
return 'text-green';
|
|
23
|
+
default:
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
15
26
|
};
|
|
16
|
-
export {
|
|
17
|
-
getOperationStability,
|
|
18
|
-
getOperationStabilityColor,
|
|
19
|
-
isOperationDeprecated
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=operation-stability.js.map
|
package/dist/helpers/parse.d.ts
CHANGED
|
@@ -17,10 +17,6 @@ export declare const json: {
|
|
|
17
17
|
parseSafe<T extends PrimitiveOrObject>(val: string, fallback: T | ((err: any) => T)): UnknownObject | T;
|
|
18
18
|
stringify: (val: object) => string;
|
|
19
19
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Check if value is a valid JSON string
|
|
22
|
-
*/
|
|
23
|
-
export declare const isJsonString: (value?: any) => boolean;
|
|
24
20
|
/**
|
|
25
21
|
* This helper is used to transform the content of the swagger file to JSON, even it was YAML.
|
|
26
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/helpers/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAS,SAAS,EAAE,MAAM,MAAM,CAAA;AAEvC,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;AAE9E,4CAA4C;AAC5C,eAAO,MAAM,IAAI;IACf,2DAA2D;iBAC9C,MAAM,KAKI,aAAa;IAEpC,6CAA6C;cACnC,CAAC,SAAS,iBAAiB,OAAO,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,aAAa,GAAG,CAAC;;CAQxG,CAAA;AAED,4CAA4C;AAC5C,eAAO,MAAM,IAAI;IACf,2DAA2D;iBAC9C,MAAM,KAAG,aAAa;IAOnC,6CAA6C;cACnC,CAAC,SAAS,iBAAiB,OAAO,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,aAAa,GAAG,CAAC;qBAOtF,MAAM;CACxB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/helpers/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAS,SAAS,EAAE,MAA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