@scalar/oas-utils 0.4.11 → 0.4.12
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 +14 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +4 -0
- package/dist/helpers/index.js.map +2 -2
- package/dist/helpers/operation-stability.d.ts +19 -0
- package/dist/helpers/operation-stability.d.ts.map +1 -0
- package/dist/helpers/operation-stability.js +21 -0
- package/dist/helpers/operation-stability.js.map +7 -0
- package/dist/helpers/security/get-schemes.d.ts +4 -0
- package/dist/helpers/security/get-schemes.d.ts.map +1 -1
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +9 -3
- package/dist/transforms/import-spec.js.map +2 -2
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @scalar/oas-utils
|
|
2
2
|
|
|
3
|
+
## 0.4.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c826b3e: fix: uses relative document URL as server URL
|
|
8
|
+
- 80acf84: feat: add code sample block wrapper with global state
|
|
9
|
+
- Updated dependencies [a0cadac]
|
|
10
|
+
- Updated dependencies [c10e191]
|
|
11
|
+
- Updated dependencies [661c7e9]
|
|
12
|
+
- Updated dependencies [80acf84]
|
|
13
|
+
- @scalar/workspace-store@0.9.0
|
|
14
|
+
- @scalar/types@0.2.8
|
|
15
|
+
- @scalar/themes@0.13.9
|
|
16
|
+
|
|
3
17
|
## 0.4.11
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { shouldUseProxy, redirectToProxy } from './redirect-to-proxy.js';
|
|
|
8
8
|
export { schemaModel } from './schema-model.js';
|
|
9
9
|
export { shouldIgnoreEntity } from './should-ignore-entity.js';
|
|
10
10
|
export { defaultStateFactory, ssrState } from './ssr-state.js';
|
|
11
|
+
export { isOperationDeprecated, getOperationStability, getOperationStabilityColor } from './operation-stability.js';
|
|
11
12
|
/**
|
|
12
13
|
* @deprecated These helpers are being phased out. Please import directly from @scalar/helpers instead.
|
|
13
14
|
* For example: import { createHash } from '/@scalar/helpers/string/create-hash'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,KAAK,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC5G,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AAClF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,KAAK,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,uBAAuB,E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C,CAAA;AAC5C,OAAO;AACL,8FAA8F;AAC9F,aAAa,GACd,MAAM,sCAAsC,CAAA;AAC7C,OAAO;AACL,uGAAuG;AACvG,iBAAiB,GAClB,MAAM,2CAA2C,CAAA;AAClD,OAAO;AACL,4FAA4F;AAC5F,iBAAiB,GAClB,MAAM,gCAAgC,CAAA;AACvC,OAAO;AACL,6FAA6F;AAC7F,eAAe,GAChB,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,uFAAuF;AACvF,UAAU,GACX,MAAM,kCAAkC,CAAA;AACzC,OAAO;AACL,6FAA6F;AAC7F,YAAY,GACb,MAAM,sCAAsC,CAAA;AAC7C,OAAO;AACL,iGAAiG;AACjG,eAAe,GAChB,MAAM,uCAAuC,CAAA;AAC9C,OAAO;AACL,4FAA4F;AAC5F,iBAAiB;AACjB,oFAAoF;AACpF,SAAS,GACV,MAAM,gCAAgC,CAAA;AACvC,OAAO;AACL,yFAAyF;AACzF,UAAU,IAAI,aAAa,GAC5B,MAAM,oCAAoC,CAAA;AAC3C,OAAO;AACL,oGAAoG;AACpG,gBAAgB,GACjB,MAAM,yCAAyC,CAAA"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { shouldUseProxy, redirectToProxy } from "./redirect-to-proxy.js";
|
|
|
8
8
|
import { schemaModel } from "./schema-model.js";
|
|
9
9
|
import { shouldIgnoreEntity } from "./should-ignore-entity.js";
|
|
10
10
|
import { defaultStateFactory, ssrState } from "./ssr-state.js";
|
|
11
|
+
import { isOperationDeprecated, getOperationStability, getOperationStabilityColor } from "./operation-stability.js";
|
|
11
12
|
import {
|
|
12
13
|
createHash
|
|
13
14
|
} from "@scalar/helpers/string/create-hash";
|
|
@@ -91,11 +92,14 @@ export {
|
|
|
91
92
|
formatJsonOrYamlString,
|
|
92
93
|
getHttpMethodInfo,
|
|
93
94
|
objectKeys as getObjectKeys,
|
|
95
|
+
getOperationStability,
|
|
96
|
+
getOperationStabilityColor,
|
|
94
97
|
httpStatusCodes,
|
|
95
98
|
isDefined,
|
|
96
99
|
isHttpMethod,
|
|
97
100
|
isJsonString,
|
|
98
101
|
isLocalUrl,
|
|
102
|
+
isOperationDeprecated,
|
|
99
103
|
isRelativePath,
|
|
100
104
|
isValidUrl,
|
|
101
105
|
iterateTitle,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { fetchDocument } from './fetch-document'\nexport { type FetchWithProxyFallbackOptions, fetchWithProxyFallback } from './fetch-with-proxy-fallback'\nexport { normalizeMimeType } from './normalize-mime-type'\nexport { normalizeMimeTypeObject } from './normalize-mime-type-object'\nexport { formatJsonOrYamlString, isJsonString, json, parseJsonOrYaml, transformToJson, yaml } from './parse'\nexport { prettyPrintJson, replaceCircularDependencies } from './pretty-print-json'\nexport { shouldUseProxy, redirectToProxy } from './redirect-to-proxy'\nexport { schemaModel } from './schema-model'\nexport { shouldIgnoreEntity } from './should-ignore-entity'\nexport { defaultStateFactory, ssrState } from './ssr-state'\n\n/**\n * @deprecated These helpers are being phased out. Please import directly from @scalar/helpers instead.\n * For example: import { createHash } from '\\@scalar/helpers/string/create-hash'\n */\nexport {\n /** @deprecated Please use createHash from \\@scalar/helpers/string/create-hash instead */\n createHash,\n} from '@scalar/helpers/string/create-hash'\nexport {\n /** @deprecated Please use isDefined from \\@scalar/helpers/array/is-defined instead */\n isDefined,\n} from '@scalar/helpers/array/is-defined'\nexport {\n /** @deprecated Please use isHttpMethod from \\@scalar/helpers/http/is-http-method instead */\n isHttpMethod,\n} from '@scalar/helpers/http/is-http-method'\nexport {\n /** @deprecated Please use combineUrlAndPath from \\@scalar/helpers/url/merge-urls instead */\n combineUrlAndPath,\n} from '@scalar/helpers/url/merge-urls'\nexport {\n /** @deprecated Please use json2xml from \\@scalar/helpers/file/json2xml instead */\n json2xml,\n} from '@scalar/helpers/file/json2xml'\nexport {\n /** @deprecated Please use capitalize from \\@scalar/helpers/string/capitalize instead */\n capitalize,\n} from '@scalar/helpers/string/capitalize'\nexport {\n /** @deprecated Please use camelToTitleWords from \\@scalar/helpers/string/camel-to-title instead */\n camelToTitleWords,\n} from '@scalar/helpers/string/camel-to-title'\nexport {\n /** @deprecated Please use REGEX from \\@scalar/helpers/regex/regex-helpers instead */\n REGEX,\n} from '@scalar/helpers/regex/regex-helpers'\nexport {\n /** @deprecated Please use isLocalUrl from \\@scalar/helpers/url/is-local-url instead */\n isLocalUrl,\n} from '@scalar/helpers/url/is-local-url'\nexport {\n /** @deprecated Please use isRelativePath from \\@scalar/helpers/url/is-relative-path instead */\n isRelativePath,\n} from '@scalar/helpers/url/is-relative-path'\nexport {\n /** @deprecated Please use ensureProtocol from \\@scalar/helpers/url/ensure-protocol instead */\n ensureProtocol,\n} from '@scalar/helpers/url/ensure-protocol'\nexport {\n /** @deprecated Please use findVariables from \\@scalar/helpers/regex/find-variables instead */\n findVariables,\n} from '@scalar/helpers/regex/find-variables'\nexport {\n /** @deprecated Please use canMethodHaveBody from \\@scalar/helpers/http/can-method-have-body instead */\n canMethodHaveBody,\n} from '@scalar/helpers/http/can-method-have-body'\nexport {\n /** @deprecated Please use getHttpMethodInfo from \\@scalar/helpers/http/http-info instead */\n getHttpMethodInfo,\n} from '@scalar/helpers/http/http-info'\nexport {\n /** @deprecated Please use REQUEST_METHODS from \\@scalar/helpers/http/http-methods instead */\n REQUEST_METHODS,\n} from '@scalar/helpers/http/http-info'\nexport {\n /** @deprecated Please use HttpStatusCode from \\@scalar/helpers/http/http-status-codes instead */\n type HttpStatusCode,\n /** @deprecated Please use HttpStatusCodes from \\@scalar/helpers/http/http-status-codes instead */\n type HttpStatusCodes,\n /** @deprecated Please use httpStatusCodes from \\@scalar/helpers/http/http-status-codes instead */\n httpStatusCodes,\n} from '@scalar/helpers/http/http-status-codes'\nexport {\n /** @deprecated Please use isValidUrl from \\@scalar/helpers/url/is-valid-url instead */\n isValidUrl,\n} from '@scalar/helpers/url/is-valid-url'\nexport {\n /** @deprecated Please use iterateTitle from \\@scalar/helpers/string/iterate-title instead */\n iterateTitle,\n} from '@scalar/helpers/string/iterate-title'\nexport {\n /** @deprecated Please use makeUrlAbsolute from \\@scalar/helpers/url/make-url-absolute instead */\n makeUrlAbsolute,\n} from '@scalar/helpers/url/make-url-absolute'\nexport {\n /** @deprecated Please use mergeSearchParams from \\@scalar/helpers/url/merge-urls instead */\n mergeSearchParams,\n /** @deprecated Please use mergeUrls from \\@scalar/helpers/url/merge-urls instead */\n mergeUrls,\n} from '@scalar/helpers/url/merge-urls'\nexport {\n /** @deprecated Please use objectKeys from \\@scalar/helpers/object/object-keys instead */\n objectKeys as getObjectKeys,\n} from '@scalar/helpers/object/object-keys'\nexport {\n /** @deprecated Please use replaceVariables from \\@scalar/helpers/regex/replace-variables instead */\n replaceVariables,\n} from '@scalar/helpers/regex/replace-variables'\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,qBAAqB;AAC9B,SAA6C,8BAA8B;AAC3E,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,wBAAwB,cAAc,MAAM,iBAAiB,iBAAiB,YAAY;AACnG,SAAS,iBAAiB,mCAAmC;AAC7D,SAAS,gBAAgB,uBAAuB;AAChD,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AACnC,SAAS,qBAAqB,gBAAgB;
|
|
4
|
+
"sourcesContent": ["export { fetchDocument } from './fetch-document'\nexport { type FetchWithProxyFallbackOptions, fetchWithProxyFallback } from './fetch-with-proxy-fallback'\nexport { normalizeMimeType } from './normalize-mime-type'\nexport { normalizeMimeTypeObject } from './normalize-mime-type-object'\nexport { formatJsonOrYamlString, isJsonString, json, parseJsonOrYaml, transformToJson, yaml } from './parse'\nexport { prettyPrintJson, replaceCircularDependencies } from './pretty-print-json'\nexport { shouldUseProxy, redirectToProxy } from './redirect-to-proxy'\nexport { schemaModel } from './schema-model'\nexport { shouldIgnoreEntity } from './should-ignore-entity'\nexport { defaultStateFactory, ssrState } from './ssr-state'\nexport { isOperationDeprecated, getOperationStability, getOperationStabilityColor } from './operation-stability'\n\n/**\n * @deprecated These helpers are being phased out. Please import directly from @scalar/helpers instead.\n * For example: import { createHash } from '\\@scalar/helpers/string/create-hash'\n */\nexport {\n /** @deprecated Please use createHash from \\@scalar/helpers/string/create-hash instead */\n createHash,\n} from '@scalar/helpers/string/create-hash'\nexport {\n /** @deprecated Please use isDefined from \\@scalar/helpers/array/is-defined instead */\n isDefined,\n} from '@scalar/helpers/array/is-defined'\nexport {\n /** @deprecated Please use isHttpMethod from \\@scalar/helpers/http/is-http-method instead */\n isHttpMethod,\n} from '@scalar/helpers/http/is-http-method'\nexport {\n /** @deprecated Please use combineUrlAndPath from \\@scalar/helpers/url/merge-urls instead */\n combineUrlAndPath,\n} from '@scalar/helpers/url/merge-urls'\nexport {\n /** @deprecated Please use json2xml from \\@scalar/helpers/file/json2xml instead */\n json2xml,\n} from '@scalar/helpers/file/json2xml'\nexport {\n /** @deprecated Please use capitalize from \\@scalar/helpers/string/capitalize instead */\n capitalize,\n} from '@scalar/helpers/string/capitalize'\nexport {\n /** @deprecated Please use camelToTitleWords from \\@scalar/helpers/string/camel-to-title instead */\n camelToTitleWords,\n} from '@scalar/helpers/string/camel-to-title'\nexport {\n /** @deprecated Please use REGEX from \\@scalar/helpers/regex/regex-helpers instead */\n REGEX,\n} from '@scalar/helpers/regex/regex-helpers'\nexport {\n /** @deprecated Please use isLocalUrl from \\@scalar/helpers/url/is-local-url instead */\n isLocalUrl,\n} from '@scalar/helpers/url/is-local-url'\nexport {\n /** @deprecated Please use isRelativePath from \\@scalar/helpers/url/is-relative-path instead */\n isRelativePath,\n} from '@scalar/helpers/url/is-relative-path'\nexport {\n /** @deprecated Please use ensureProtocol from \\@scalar/helpers/url/ensure-protocol instead */\n ensureProtocol,\n} from '@scalar/helpers/url/ensure-protocol'\nexport {\n /** @deprecated Please use findVariables from \\@scalar/helpers/regex/find-variables instead */\n findVariables,\n} from '@scalar/helpers/regex/find-variables'\nexport {\n /** @deprecated Please use canMethodHaveBody from \\@scalar/helpers/http/can-method-have-body instead */\n canMethodHaveBody,\n} from '@scalar/helpers/http/can-method-have-body'\nexport {\n /** @deprecated Please use getHttpMethodInfo from \\@scalar/helpers/http/http-info instead */\n getHttpMethodInfo,\n} from '@scalar/helpers/http/http-info'\nexport {\n /** @deprecated Please use REQUEST_METHODS from \\@scalar/helpers/http/http-methods instead */\n REQUEST_METHODS,\n} from '@scalar/helpers/http/http-info'\nexport {\n /** @deprecated Please use HttpStatusCode from \\@scalar/helpers/http/http-status-codes instead */\n type HttpStatusCode,\n /** @deprecated Please use HttpStatusCodes from \\@scalar/helpers/http/http-status-codes instead */\n type HttpStatusCodes,\n /** @deprecated Please use httpStatusCodes from \\@scalar/helpers/http/http-status-codes instead */\n httpStatusCodes,\n} from '@scalar/helpers/http/http-status-codes'\nexport {\n /** @deprecated Please use isValidUrl from \\@scalar/helpers/url/is-valid-url instead */\n isValidUrl,\n} from '@scalar/helpers/url/is-valid-url'\nexport {\n /** @deprecated Please use iterateTitle from \\@scalar/helpers/string/iterate-title instead */\n iterateTitle,\n} from '@scalar/helpers/string/iterate-title'\nexport {\n /** @deprecated Please use makeUrlAbsolute from \\@scalar/helpers/url/make-url-absolute instead */\n makeUrlAbsolute,\n} from '@scalar/helpers/url/make-url-absolute'\nexport {\n /** @deprecated Please use mergeSearchParams from \\@scalar/helpers/url/merge-urls instead */\n mergeSearchParams,\n /** @deprecated Please use mergeUrls from \\@scalar/helpers/url/merge-urls instead */\n mergeUrls,\n} from '@scalar/helpers/url/merge-urls'\nexport {\n /** @deprecated Please use objectKeys from \\@scalar/helpers/object/object-keys instead */\n objectKeys as getObjectKeys,\n} from '@scalar/helpers/object/object-keys'\nexport {\n /** @deprecated Please use replaceVariables from \\@scalar/helpers/regex/replace-variables instead */\n replaceVariables,\n} from '@scalar/helpers/regex/replace-variables'\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAC9B,SAA6C,8BAA8B;AAC3E,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,wBAAwB,cAAc,MAAM,iBAAiB,iBAAiB,YAAY;AACnG,SAAS,iBAAiB,mCAAmC;AAC7D,SAAS,gBAAgB,uBAAuB;AAChD,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AACnC,SAAS,qBAAqB,gBAAgB;AAC9C,SAAS,uBAAuB,uBAAuB,kCAAkC;AAMzF;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAME;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EAEgB;AAAA,OACT;AACP;AAAA,EAEE;AAAA,OACK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { XScalarStabilityValues } from '@scalar/openapi-types/schemas/extensions';
|
|
2
|
+
type OperationStability = {
|
|
3
|
+
deprecated?: boolean;
|
|
4
|
+
'x-scalar-stability'?: unknown;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if an operation is considered deprecated.
|
|
8
|
+
*/
|
|
9
|
+
export declare const isOperationDeprecated: (operation: OperationStability) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Get operation stability from deprecated or x-scalar-stability
|
|
12
|
+
*/
|
|
13
|
+
export declare const getOperationStability: (operation: OperationStability) => XScalarStabilityValues | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get Operation stability tailwind color class
|
|
16
|
+
*/
|
|
17
|
+
export declare const getOperationStabilityColor: (operation: OperationStability) => string;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=operation-stability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-stability.d.ts","sourceRoot":"","sources":["../../src/helpers/operation-stability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAA;AAEjF,KAAK,kBAAkB,GAAG;IACxB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,cAAe,kBAAkB,KAAG,OACyB,CAAA;AAE/F;;GAEG;AACH,eAAO,MAAM,qBAAqB,cAAe,kBAAkB,KAAG,sBAAsB,GAAG,SAGlB,CAAA;AAE7E;;GAEG;AACH,eAAO,MAAM,0BAA0B,cAAe,kBAAkB,KAAG,MAW1E,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { XScalarStabilityValues } from "@scalar/openapi-types/schemas/extensions";
|
|
2
|
+
const isOperationDeprecated = (operation) => operation.deprecated || operation["x-scalar-stability"] === XScalarStabilityValues.Deprecated;
|
|
3
|
+
const getOperationStability = (operation) => operation.deprecated ? XScalarStabilityValues.Deprecated : operation["x-scalar-stability"];
|
|
4
|
+
const getOperationStabilityColor = (operation) => {
|
|
5
|
+
switch (getOperationStability(operation)) {
|
|
6
|
+
case XScalarStabilityValues.Deprecated:
|
|
7
|
+
return "text-red";
|
|
8
|
+
case XScalarStabilityValues.Experimental:
|
|
9
|
+
return "text-orange";
|
|
10
|
+
case XScalarStabilityValues.Stable:
|
|
11
|
+
return "text-green";
|
|
12
|
+
default:
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
getOperationStability,
|
|
18
|
+
getOperationStabilityColor,
|
|
19
|
+
isOperationDeprecated
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=operation-stability.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/helpers/operation-stability.ts"],
|
|
4
|
+
"sourcesContent": ["import { XScalarStabilityValues } from '@scalar/openapi-types/schemas/extensions'\n\ntype OperationStability = {\n deprecated?: boolean\n 'x-scalar-stability'?: unknown\n}\n\n/**\n * Returns true if an operation is considered deprecated.\n */\nexport const isOperationDeprecated = (operation: OperationStability): boolean =>\n operation.deprecated || operation['x-scalar-stability'] === XScalarStabilityValues.Deprecated\n\n/**\n * Get operation stability from deprecated or x-scalar-stability\n */\nexport const getOperationStability = (operation: OperationStability): XScalarStabilityValues | undefined =>\n operation.deprecated\n ? XScalarStabilityValues.Deprecated\n : (operation['x-scalar-stability'] as XScalarStabilityValues | undefined)\n\n/**\n * Get Operation stability tailwind color class\n */\nexport const getOperationStabilityColor = (operation: OperationStability): string => {\n switch (getOperationStability(operation)) {\n case XScalarStabilityValues.Deprecated:\n return 'text-red'\n case XScalarStabilityValues.Experimental:\n return 'text-orange'\n case XScalarStabilityValues.Stable:\n return 'text-green'\n default:\n return ''\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,8BAA8B;AAUhC,MAAM,wBAAwB,CAAC,cACpC,UAAU,cAAc,UAAU,oBAAoB,MAAM,uBAAuB;AAK9E,MAAM,wBAAwB,CAAC,cACpC,UAAU,aACN,uBAAuB,aACtB,UAAU,oBAAoB;AAK9B,MAAM,6BAA6B,CAAC,cAA0C;AACnF,UAAQ,sBAAsB,SAAS,GAAG;AAAA,IACxC,KAAK,uBAAuB;AAC1B,aAAO;AAAA,IACT,KAAK,uBAAuB;AAC1B,aAAO;AAAA,IACT,KAAK,uBAAuB;AAC1B,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -42,6 +42,7 @@ export declare const getSchemes: (selectedSecuritySchemes: Operation["selectedSe
|
|
|
42
42
|
tokenUrl: string;
|
|
43
43
|
clientSecret: string;
|
|
44
44
|
"x-scalar-security-query"?: Record<string, string> | undefined;
|
|
45
|
+
"x-tokenName"?: string | undefined;
|
|
45
46
|
} | undefined;
|
|
46
47
|
implicit?: {
|
|
47
48
|
type: "implicit";
|
|
@@ -53,6 +54,7 @@ export declare const getSchemes: (selectedSecuritySchemes: Operation["selectedSe
|
|
|
53
54
|
authorizationUrl: string;
|
|
54
55
|
"x-scalar-redirect-uri": string;
|
|
55
56
|
"x-scalar-security-query"?: Record<string, string> | undefined;
|
|
57
|
+
"x-tokenName"?: string | undefined;
|
|
56
58
|
} | undefined;
|
|
57
59
|
clientCredentials?: {
|
|
58
60
|
type: "clientCredentials";
|
|
@@ -64,6 +66,7 @@ export declare const getSchemes: (selectedSecuritySchemes: Operation["selectedSe
|
|
|
64
66
|
tokenUrl: string;
|
|
65
67
|
clientSecret: string;
|
|
66
68
|
"x-scalar-security-query"?: Record<string, string> | undefined;
|
|
69
|
+
"x-tokenName"?: string | undefined;
|
|
67
70
|
} | undefined;
|
|
68
71
|
authorizationCode?: {
|
|
69
72
|
type: "authorizationCode";
|
|
@@ -78,6 +81,7 @@ export declare const getSchemes: (selectedSecuritySchemes: Operation["selectedSe
|
|
|
78
81
|
clientSecret: string;
|
|
79
82
|
"x-usePkce": "SHA-256" | "plain" | "no";
|
|
80
83
|
"x-scalar-security-query"?: Record<string, string> | undefined;
|
|
84
|
+
"x-tokenName"?: string | undefined;
|
|
81
85
|
} | undefined;
|
|
82
86
|
};
|
|
83
87
|
description?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-schemes.d.ts","sourceRoot":"","sources":["../../../src/helpers/security/get-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAG5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAE1D,2IAA2I;AAC3I,eAAO,MAAM,UAAU,4BACI,SAAS,CAAC,4BAA4B,CAAC,mBAC/C,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"get-schemes.d.ts","sourceRoot":"","sources":["../../../src/helpers/security/get-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAG5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAE1D,2IAA2I;AAC3I,eAAO,MAAM,UAAU,4BACI,SAAS,CAAC,4BAA4B,CAAC,mBAC/C,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAOu7xE,CAAC;;;;;;;;;;;qCAA0X,CAAC;yBAA+D,CAAC;;gBAA6D,CAAC;;;;;;;;;qCAAiV,CAAC;yBAA+D,CAAC;;yBAAsE,CAAC;;;;;;;;;qCAAuU,CAAC;yBAA+D,CAAC;;yBAAsE,CAAC;;;;;;;;;;;;qCAA+c,CAAC;yBAA+D,CAAC;;;;;IADx61E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/trans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,CAAC,yBAAyB,EAAE,aAAa,CAAM,GACxG,MAAM,EAAE,CA8DV"}
|
|
@@ -309,7 +309,7 @@ function getBaseUrlFromDocumentUrl(documentUrl) {
|
|
|
309
309
|
const url = new URL(documentUrl);
|
|
310
310
|
return `${url.protocol}//${url.hostname}`;
|
|
311
311
|
} catch {
|
|
312
|
-
return
|
|
312
|
+
return void 0;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
function getServersFromOpenApiDocument(servers, {
|
|
@@ -317,7 +317,10 @@ function getServersFromOpenApiDocument(servers, {
|
|
|
317
317
|
documentUrl
|
|
318
318
|
} = {}) {
|
|
319
319
|
if (!servers?.length && documentUrl) {
|
|
320
|
-
|
|
320
|
+
const newServerUrl = getBaseUrlFromDocumentUrl(documentUrl);
|
|
321
|
+
if (newServerUrl) {
|
|
322
|
+
return [serverSchema.parse({ url: newServerUrl })];
|
|
323
|
+
}
|
|
321
324
|
}
|
|
322
325
|
if (!servers || !Array.isArray(servers)) {
|
|
323
326
|
return [];
|
|
@@ -331,7 +334,10 @@ function getServersFromOpenApiDocument(servers, {
|
|
|
331
334
|
return parsedSchema;
|
|
332
335
|
}
|
|
333
336
|
if (documentUrl) {
|
|
334
|
-
|
|
337
|
+
const baseUrl = getBaseUrlFromDocumentUrl(documentUrl);
|
|
338
|
+
if (baseUrl) {
|
|
339
|
+
parsedSchema.url = combineUrlAndPath(baseUrl, parsedSchema.url);
|
|
340
|
+
}
|
|
335
341
|
return parsedSchema;
|
|
336
342
|
}
|
|
337
343
|
const fallbackUrl = getFallbackUrl();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/transforms/import-spec.ts"],
|
|
4
|
-
"sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { combineUrlAndPath } from '@scalar/helpers/url/merge-urls'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type LoadResult, dereference, load, upgrade } from '@scalar/openapi-parser'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport type { SecuritySchemeOauth2 } from '@scalar/types/entities'\nimport {\n type Oauth2FlowPayload,\n type SecurityScheme,\n type SecuritySchemePayload,\n securitySchemeSchema,\n} from '@scalar/types/entities'\nimport type { UnknownObject } from '@scalar/types/utils'\nimport type { Entries } from 'type-fest'\n\nimport type { SelectedSecuritySchemeUids } from '@/entities/shared/utility'\nimport { type Collection, type CollectionPayload, collectionSchema } from '@/entities/spec/collection'\nimport type { RequestParameterPayload } from '@/entities/spec/parameters'\nimport { type RequestExample, createExampleFromRequest } from '@/entities/spec/request-examples'\nimport { type Request, type RequestPayload, requestSchema } from '@/entities/spec/requests'\nimport { type Server, serverSchema } from '@/entities/spec/server'\nimport { type Tag, tagSchema } from '@/entities/spec/spec-objects'\nimport { schemaModel } from '@/helpers/schema-model'\n\nconst dereferenceDocument = async (\n document: string | UnknownObject,\n { shouldLoad = true }: { shouldLoad?: boolean } = {},\n) => {\n if (document === null || (typeof document === 'string' && document.trim() === '')) {\n console.warn('[@scalar/oas-utils] Empty OpenAPI document provided.')\n\n return {\n schema: {} as OpenAPIV3_1.Document,\n errors: [],\n }\n }\n\n let filesystem: LoadResult['filesystem'] | string | UnknownObject = document\n let loadErrors: LoadResult['errors'] = []\n\n if (shouldLoad) {\n // TODO: Plugins for URLs and files with the proxy are missing here.\n // @see packages/api-reference/src/helpers/parse.ts\n const response = await load(document).catch((e) => ({\n errors: [\n {\n code: e.code,\n message: e.message,\n },\n ],\n filesystem: [],\n }))\n filesystem = response.filesystem\n loadErrors = response.errors ?? []\n }\n\n const { specification } = upgrade(filesystem)\n const { schema, errors: derefErrors = [] } = await dereference(specification)\n\n return {\n schema,\n errors: [...loadErrors, ...derefErrors],\n }\n}\n\n/** Takes a string or object and parses it into an openapi spec compliant schema */\nexport const parseSchema = async (\n originalDocument: string | UnknownObject | undefined,\n {\n shouldLoad = true,\n /** If a dereferenced document is provided, we will skip the dereferencing step. */\n dereferencedDocument = undefined,\n }: { shouldLoad?: boolean; dereferencedDocument?: OpenAPIV3_1.Document } = {},\n) => {\n // Skip, if a dereferenced document is provided\n const { schema, errors } = dereferencedDocument\n ? {\n schema: dereferencedDocument,\n errors: [],\n }\n : // Otherwise, dereference the original document\n await dereferenceDocument(originalDocument ?? '', {\n shouldLoad,\n })\n\n if (!schema) {\n console.warn('[@scalar/oas-utils] OpenAPI Parser Warning: Schema is undefined')\n }\n\n return {\n /**\n * Temporary fix for the parser returning an empty array\n * TODO: remove this once the parser is fixed\n */\n schema: (Array.isArray(schema) ? {} : schema) as OpenAPIV3_1.Document,\n errors,\n }\n}\n\n/** Converts selected security requirements to uids */\nexport const getSelectedSecuritySchemeUids = (\n securityRequirements: (string | string[])[],\n preferredSecurityNames: (string | string[])[] = [],\n securitySchemeMap: Record<string, SecurityScheme['uid']>,\n): SelectedSecuritySchemeUids => {\n // Set the first security requirement if no preferred security schemes are set\n const names =\n securityRequirements[0] && !preferredSecurityNames.length ? [securityRequirements[0]] : preferredSecurityNames\n\n // Map names to uids\n const uids = names\n .map((name) =>\n Array.isArray(name) ? name.map((k) => securitySchemeMap[k]).filter(isDefined) : securitySchemeMap[name],\n )\n .filter(isDefined)\n\n return uids\n}\n\n/** Create a \"uid\" from a slug */\nexport const getSlugUid = (slug: string) => `slug-uid-${slug}` as Collection['uid']\n\nexport type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> &\n Pick<ApiReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers' | 'slug'> & {\n /** The dereferenced document */\n dereferencedDocument?: OpenAPIV3_1.Document\n /** Sets the preferred security scheme on the collection instead of the requests */\n useCollectionSecurity?: boolean\n /** Call the load step from the parser */\n shouldLoad?: boolean\n }\n\n/**\n * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)\n *\n * The imported entities maintain a close mapping to the original OpenAPI specification to enable:\n * - Bi-directional translation between spec and workspace entities\n * - Preservation of specification details and structure\n * - Accurate representation of relationships between components\n *\n * Relationships between entities are maintained through unique identifiers (UIDs) which allow:\n * - Flexible organization at different levels (workspace, collection, request)\n * - Proper linking between related components\n * - Easy lookup and reference of dependent entities\n */\nexport async function importSpecToWorkspace(\n content: string | UnknownObject | undefined,\n {\n /** If a dereferenced document is provided, we will skip the dereferencing step. */\n dereferencedDocument,\n authentication,\n baseServerURL,\n documentUrl,\n servers: configuredServers,\n useCollectionSecurity = false,\n slug,\n shouldLoad,\n watchMode = false,\n }: ImportSpecToWorkspaceArgs = {},\n): Promise<\n | {\n error: false\n collection: Collection\n requests: Request[]\n schema: OpenAPIV3_1.Document\n examples: RequestExample[]\n servers: Server[]\n tags: Tag[]\n securitySchemes: SecurityScheme[]\n }\n | { error: true; importWarnings: string[]; collection: undefined }\n> {\n const { schema, errors } = await parseSchema(content, { shouldLoad, dereferencedDocument })\n const importWarnings: string[] = [...errors.map((e) => e.message)]\n\n if (!schema) {\n return { importWarnings, error: true, collection: undefined }\n }\n // ---------------------------------------------------------------------------\n // Some entities will be broken out as individual lists for modification in the workspace\n const start = performance.now()\n const requests: Request[] = []\n\n // Add the base server url to collection servers\n const collectionServers: Server[] = getServersFromOpenApiDocument(configuredServers || schema.servers, {\n baseServerURL,\n documentUrl,\n })\n\n // Store operation servers\n const operationServers: Server[] = []\n\n // Fallback to the current window.location.origin if no servers are provided\n if (!collectionServers.length) {\n const fallbackUrl = getFallbackUrl()\n\n if (fallbackUrl) {\n collectionServers.push(serverSchema.parse({ url: fallbackUrl }))\n }\n }\n\n /**\n * List of all tag strings. For non compliant specs we may need to\n * add top level tag objects for missing tag objects\n */\n const tagNames: Set<string> = new Set()\n\n // ---------------------------------------------------------------------------\n // SECURITY HANDLING\n\n const security = schema.components?.securitySchemes ?? schema?.securityDefinitions ?? {}\n\n // @ts-expect-error - Toss out a deprecated warning for the old authentication state\n if (authentication?.oAuth2 || authentication?.apiKey || authentication?.http) {\n console.warn(\n `DEPRECATION WARNING: It looks like you're using legacy authentication config. Please migrate to use the updated config. See https://github.com/scalar/scalar/blob/main/documentation/configuration.md#authentication-partial This will be removed in a future version.`,\n )\n }\n\n const securitySchemes = (Object.entries(security) as Entries<Record<string, OpenAPIV3_1.SecuritySchemeObject>>)\n .map?.(([nameKey, _scheme]) => {\n // Apply any transforms we need before parsing\n const payload = {\n ..._scheme,\n // Add the new auth config overrides, we keep the old code below for backwards compatibility\n ...(authentication?.securitySchemes?.[nameKey] ?? {}),\n nameKey,\n } as SecuritySchemePayload\n\n // For oauth2 we need to add the type to the flows + prefill from authentication\n if (payload.type === 'oauth2' && payload.flows) {\n const flowKeys = Object.keys(payload.flows) as Array<keyof typeof payload.flows>\n\n flowKeys.forEach((key) => {\n if (!payload.flows?.[key] || _scheme.type !== 'oauth2') {\n return\n }\n const authFlow = (authentication?.securitySchemes?.[nameKey] as SecuritySchemeOauth2)?.flows?.[key] ?? {}\n\n // This part handles setting of flows via the new auth config, the rest can be removed in a future version\n payload.flows[key] = {\n ...(_scheme.flows?.[key] ?? {}),\n ...authFlow,\n } satisfies Oauth2FlowPayload\n\n const flow = payload.flows[key] as Oauth2FlowPayload\n\n // Set the type\n flow.type = key\n\n // Prefill values from authorization config - old deprecated config\n // @ts-expect-error - deprecated\n if (authentication?.oAuth2) {\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.accessToken) {\n // @ts-expect-error - deprecated\n flow.token = authentication.oAuth2.accessToken\n }\n\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.clientId) {\n // @ts-expect-error - deprecated\n flow['x-scalar-client-id'] = authentication.oAuth2.clientId\n }\n\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.scopes) {\n // @ts-expect-error - deprecated\n flow.selectedScopes = authentication.oAuth2.scopes\n }\n\n if (flow.type === 'password') {\n // @ts-expect-error - deprecated\n flow.username = authentication.oAuth2.username\n // @ts-expect-error - deprecated\n flow.password = authentication.oAuth2.password\n }\n }\n\n // Convert scopes to an object\n if (Array.isArray(flow.scopes)) {\n flow.scopes = flow.scopes.reduce((prev, s) => ({ ...prev, [s]: '' }), {})\n }\n\n // Handle x-defaultClientId\n if (flow['x-defaultClientId']) {\n flow['x-scalar-client-id'] = flow['x-defaultClientId']\n }\n })\n }\n // Otherwise we just prefill - old deprecated config\n else if (authentication) {\n // ApiKey\n // @ts-expect-error - deprecated\n if (payload.type === 'apiKey' && authentication.apiKey?.token) {\n // @ts-expect-error - deprecated\n payload.value = authentication.apiKey.token\n }\n // HTTP\n else if (payload.type === 'http') {\n // @ts-expect-error - deprecated\n if (payload.scheme === 'basic' && authentication.http?.basic) {\n // @ts-expect-error - deprecated\n payload.username = authentication.http.basic.username ?? ''\n // @ts-expect-error - deprecated\n payload.password = authentication.http.basic.password ?? ''\n }\n // Bearer\n // @ts-expect-error - deprecated\n else if (payload.scheme === 'bearer' && authentication.http?.bearer?.token) {\n // @ts-expect-error - deprecated\n payload.token = authentication.http.bearer.token ?? ''\n }\n }\n }\n\n const scheme = schemaModel(payload, securitySchemeSchema, false)\n if (!scheme) {\n importWarnings.push(`Security scheme ${nameKey} is invalid.`)\n }\n\n return scheme\n })\n .filter((v) => !!v)\n\n // Map of security scheme names to UIDs\n const securitySchemeMap: Record<string, SecurityScheme['uid']> = {}\n securitySchemes.forEach((s) => {\n securitySchemeMap[s.nameKey] = s.uid\n })\n\n // ---------------------------------------------------------------------------\n // REQUEST HANDLING\n\n keysOf(schema.paths ?? {}).forEach((pathString) => {\n const path = schema?.paths?.[pathString]\n\n if (!path) {\n return\n }\n // Path level servers must be saved\n const pathServers = serverSchema.array().parse(path.servers ?? [])\n for (const server of pathServers) {\n collectionServers.push(server)\n }\n\n // Creates a sorted array of methods based on the path object.\n const methods = Object.keys(path).filter(isHttpMethod)\n\n methods.forEach((method) => {\n const operation = path[method]\n if (!operation) {\n return\n }\n\n const operationLevelServers = serverSchema.array().parse(operation.servers ?? [])\n\n for (const server of operationLevelServers) {\n operationServers.push(server)\n }\n\n // We will save a list of all tags to ensure they exists at the top level\n // TODO: make sure we add any loose requests with no tags to the collection children\n operation.tags?.forEach((t: string) => tagNames.add(t))\n\n // Remove security here and add it correctly below\n const { security: operationSecurity, ...operationWithoutSecurity } = operation\n\n const securityRequirements: (string | string[])[] = (operationSecurity ?? schema.security ?? [])\n .map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n return keys.length > 1 ? keys : keys[0]\n })\n .filter(isDefined)\n\n // Filter the preferred security schemes to only include the ones that are in the security requirements\n const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat().filter((name) => {\n // Match up complex security requirements, array to array\n if (Array.isArray(name)) {\n // We match every element in the array\n return securityRequirements.some(\n (r) => Array.isArray(r) && r.length === name.length && r.every((v, i) => v === name[i]),\n )\n }\n return securityRequirements.includes(name)\n })\n\n // Set the initially selected security scheme\n const selectedSecuritySchemeUids =\n securityRequirements.length && !useCollectionSecurity\n ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)\n : []\n\n const requestPayload: RequestPayload = {\n ...operationWithoutSecurity,\n method,\n path: pathString,\n security: operationSecurity,\n selectedServerUid: operationLevelServers?.[0]?.uid,\n selectedSecuritySchemeUids,\n // Merge path and operation level parameters\n parameters: [...(path?.parameters ?? []), ...(operation.parameters ?? [])] as RequestParameterPayload[],\n servers: [...pathServers, ...operationLevelServers].map((s) => s.uid),\n }\n\n // Remove any examples from the request payload as they conflict with our examples property and are not valid\n if (requestPayload.examples) {\n console.warn('[@scalar/api-client] operation.examples is not a valid openapi property')\n delete requestPayload.examples\n }\n\n // Save parse the request\n const request = schemaModel(requestPayload, requestSchema, false)\n\n if (!request) {\n importWarnings.push(`${method} Request at ${path} is invalid.`)\n } else {\n requests.push(request)\n }\n })\n })\n\n // ---------------------------------------------------------------------------\n // TAG HANDLING\n\n // TODO: We may need to handle de-duping tags\n const tags = schemaModel(schema?.tags ?? [], tagSchema.array(), false) ?? []\n\n // Delete any tag names that already have a definition\n tags.forEach((t) => tagNames.delete(t.name))\n\n // Add an entry for any tags that are used but do not have a definition\n tagNames.forEach((name) => name && tags.push(tagSchema.parse({ name })))\n\n // Tag name to UID map\n const tagMap: Record<string, Tag> = {}\n tags.forEach((t) => {\n tagMap[t.name] = t\n })\n\n // Add all tags by default. We will remove nested ones\n const collectionChildren = new Set<Collection['children'][number]>(tags.map((t) => t.uid))\n\n // Nested folders go before any requests\n tags.forEach((t) => {\n t['x-scalar-children']?.forEach((c) => {\n // Add the uid to the appropriate parent.children\n const nestedUid = tagMap[c.tagName]?.uid\n\n if (nestedUid) {\n t.children.push(nestedUid)\n\n // Remove the nested uid from the root folder\n collectionChildren.delete(nestedUid)\n }\n })\n })\n\n // Add the request UIDs to the tag children (or collection root)\n requests.forEach((r) => {\n if (r.tags?.length) {\n r.tags.forEach((t) => {\n tagMap[t]?.children.push(r.uid)\n })\n } else {\n collectionChildren.add(r.uid)\n }\n })\n\n // ---------------------------------------------------------------------------\n\n const examples: RequestExample[] = []\n\n // Ensure each request has at least 1 example\n requests.forEach((request) => {\n // TODO: Need to handle parsing examples\n // if (request['x-scalar-examples']) return\n\n // Create the initial example\n const example = createExampleFromRequest(request, 'Default Example')\n\n examples.push(example)\n request.examples.push(example.uid)\n })\n\n // ---------------------------------------------------------------------------\n // Generate Collection\n\n // Grab the security requirements for this operation\n const securityRequirements: SelectedSecuritySchemeUids = (schema.security ?? [])\n .map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n return keys.length > 1 ? keys : keys[0]\n })\n .filter(isDefined)\n\n // Here we do not filter these as we let the preferredSecurityScheme override the requirements\n const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat()\n\n // Set the initially selected security scheme\n const selectedSecuritySchemeUids =\n (securityRequirements.length || preferredSecurityNames?.length) && useCollectionSecurity\n ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)\n : []\n\n // Set the uid as a prefixed slug if we have one\n const slugObj = slug?.length ? { uid: getSlugUid(slug) } : {}\n\n const collection = collectionSchema.parse({\n ...slugObj,\n ...schema,\n watchMode,\n documentUrl,\n useCollectionSecurity,\n requests: requests.map((r) => r.uid),\n servers: collectionServers.map((s) => s.uid),\n tags: tags.map((t) => t.uid),\n children: [...collectionChildren],\n security: schema.security ?? [{}],\n selectedServerUid: collectionServers?.[0]?.uid,\n selectedSecuritySchemeUids,\n components: {\n ...schema.components,\n },\n securitySchemes: securitySchemes.map((s) => s.uid),\n })\n\n const end = performance.now()\n console.log(`workspace: ${Math.round(end - start)} ms`)\n\n /**\n * Servers and requests will be saved in top level maps and indexed via UID to\n * maintain specification relationships\n */\n return {\n error: false,\n servers: [...collectionServers, ...operationServers],\n schema,\n requests,\n examples,\n collection,\n tags,\n securitySchemes,\n }\n}\n\n/**\n * Extracts the base URL (protocol + hostname) from a document URL.\n * Falls back to the original URL if it's not a valid URL.\n */\nfunction getBaseUrlFromDocumentUrl(documentUrl: string): string {\n try {\n const url = new URL(documentUrl)\n return `${url.protocol}//${url.hostname}`\n } catch {\n // If the documentUrl is not a valid URL, fall back to using it as-is\n return documentUrl\n }\n}\n\n/**\n * Retrieves a list of servers from an OpenAPI document and converts them to a list of Server entities.\n */\nexport function getServersFromOpenApiDocument(\n servers: OpenAPIV3_1.ServerObject[] | undefined,\n {\n baseServerURL,\n documentUrl,\n }: Pick<ApiReferenceConfiguration, 'baseServerURL'> & Pick<ImportSpecToWorkspaceArgs, 'documentUrl'> = {},\n): Server[] {\n // If the document doesn't have any servers, try to use the documentUrl as the default server.\n if (!servers?.length && documentUrl) {\n return [serverSchema.parse({ url: getBaseUrlFromDocumentUrl(documentUrl) })]\n }\n\n // If the servers are not an array, return an empty array.\n if (!servers || !Array.isArray(servers)) {\n return []\n }\n\n return servers\n .map((server): Server | undefined => {\n try {\n // Validate the server against the schema\n const parsedSchema = serverSchema.parse(server)\n\n // Prepend with the base server URL (if the given URL is relative)\n if (parsedSchema?.url?.startsWith('/')) {\n // Use the base server URL (if provided)\n if (baseServerURL) {\n parsedSchema.url = combineUrlAndPath(baseServerURL, parsedSchema.url)\n\n return parsedSchema\n }\n\n if (documentUrl) {\n parsedSchema.url = combineUrlAndPath(getBaseUrlFromDocumentUrl(documentUrl), parsedSchema.url)\n\n return parsedSchema\n }\n\n // Fallback to the current window origin\n const fallbackUrl = getFallbackUrl()\n\n if (fallbackUrl) {\n parsedSchema.url = combineUrlAndPath(fallbackUrl, parsedSchema.url.replace(/^\\//, ''))\n\n return parsedSchema\n }\n }\n\n // Must be good, return it\n return parsedSchema\n } catch (error) {\n console.warn(\"Oops, that's an invalid server configuration.\")\n console.warn('Server:', server)\n console.warn('Error:', error)\n\n // Return undefined to remove the server\n return undefined\n }\n })\n .filter(isDefined)\n}\n\n/**\n * Fallback to the current window.location.origin, if available\n */\nfunction getFallbackUrl() {\n if (typeof window === 'undefined') {\n return undefined\n }\n\n if (typeof window?.location?.origin !== 'string') {\n return undefined\n }\n\n return window.location.origin\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,cAAc;AACvB,SAA0B,aAAa,MAAM,eAAe;AAI5D;AAAA,EAIE;AAAA,OACK;AAKP,SAAkD,wBAAwB;AAE1E,SAA8B,gCAAgC;AAC9D,SAA4C,qBAAqB;AACjE,SAAsB,oBAAoB;AAC1C,SAAmB,iBAAiB;AACpC,SAAS,mBAAmB;AAE5B,MAAM,sBAAsB,OAC1B,UACA,EAAE,aAAa,KAAK,IAA8B,CAAC,MAChD;AACH,MAAI,aAAa,QAAS,OAAO,aAAa,YAAY,SAAS,KAAK,MAAM,IAAK;AACjF,YAAQ,KAAK,sDAAsD;AAEnE,WAAO;AAAA,MACL,QAAQ,CAAC;AAAA,MACT,QAAQ,CAAC;AAAA,IACX;AAAA,EACF;AAEA,MAAI,aAAgE;AACp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A;AAAA,IACA;AAAA,EACF;AACF;AAMA,SAAS,0BAA0B,
|
|
4
|
+
"sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { combineUrlAndPath } from '@scalar/helpers/url/merge-urls'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type LoadResult, dereference, load, upgrade } from '@scalar/openapi-parser'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { ApiReferenceConfiguration } from '@scalar/types/api-reference'\nimport type { SecuritySchemeOauth2 } from '@scalar/types/entities'\nimport {\n type Oauth2FlowPayload,\n type SecurityScheme,\n type SecuritySchemePayload,\n securitySchemeSchema,\n} from '@scalar/types/entities'\nimport type { UnknownObject } from '@scalar/types/utils'\nimport type { Entries } from 'type-fest'\n\nimport type { SelectedSecuritySchemeUids } from '@/entities/shared/utility'\nimport { type Collection, type CollectionPayload, collectionSchema } from '@/entities/spec/collection'\nimport type { RequestParameterPayload } from '@/entities/spec/parameters'\nimport { type RequestExample, createExampleFromRequest } from '@/entities/spec/request-examples'\nimport { type Request, type RequestPayload, requestSchema } from '@/entities/spec/requests'\nimport { type Server, serverSchema } from '@/entities/spec/server'\nimport { type Tag, tagSchema } from '@/entities/spec/spec-objects'\nimport { schemaModel } from '@/helpers/schema-model'\n\nconst dereferenceDocument = async (\n document: string | UnknownObject,\n { shouldLoad = true }: { shouldLoad?: boolean } = {},\n) => {\n if (document === null || (typeof document === 'string' && document.trim() === '')) {\n console.warn('[@scalar/oas-utils] Empty OpenAPI document provided.')\n\n return {\n schema: {} as OpenAPIV3_1.Document,\n errors: [],\n }\n }\n\n let filesystem: LoadResult['filesystem'] | string | UnknownObject = document\n let loadErrors: LoadResult['errors'] = []\n\n if (shouldLoad) {\n // TODO: Plugins for URLs and files with the proxy are missing here.\n // @see packages/api-reference/src/helpers/parse.ts\n const response = await load(document).catch((e) => ({\n errors: [\n {\n code: e.code,\n message: e.message,\n },\n ],\n filesystem: [],\n }))\n filesystem = response.filesystem\n loadErrors = response.errors ?? []\n }\n\n const { specification } = upgrade(filesystem)\n const { schema, errors: derefErrors = [] } = await dereference(specification)\n\n return {\n schema,\n errors: [...loadErrors, ...derefErrors],\n }\n}\n\n/** Takes a string or object and parses it into an openapi spec compliant schema */\nexport const parseSchema = async (\n originalDocument: string | UnknownObject | undefined,\n {\n shouldLoad = true,\n /** If a dereferenced document is provided, we will skip the dereferencing step. */\n dereferencedDocument = undefined,\n }: { shouldLoad?: boolean; dereferencedDocument?: OpenAPIV3_1.Document } = {},\n) => {\n // Skip, if a dereferenced document is provided\n const { schema, errors } = dereferencedDocument\n ? {\n schema: dereferencedDocument,\n errors: [],\n }\n : // Otherwise, dereference the original document\n await dereferenceDocument(originalDocument ?? '', {\n shouldLoad,\n })\n\n if (!schema) {\n console.warn('[@scalar/oas-utils] OpenAPI Parser Warning: Schema is undefined')\n }\n\n return {\n /**\n * Temporary fix for the parser returning an empty array\n * TODO: remove this once the parser is fixed\n */\n schema: (Array.isArray(schema) ? {} : schema) as OpenAPIV3_1.Document,\n errors,\n }\n}\n\n/** Converts selected security requirements to uids */\nexport const getSelectedSecuritySchemeUids = (\n securityRequirements: (string | string[])[],\n preferredSecurityNames: (string | string[])[] = [],\n securitySchemeMap: Record<string, SecurityScheme['uid']>,\n): SelectedSecuritySchemeUids => {\n // Set the first security requirement if no preferred security schemes are set\n const names =\n securityRequirements[0] && !preferredSecurityNames.length ? [securityRequirements[0]] : preferredSecurityNames\n\n // Map names to uids\n const uids = names\n .map((name) =>\n Array.isArray(name) ? name.map((k) => securitySchemeMap[k]).filter(isDefined) : securitySchemeMap[name],\n )\n .filter(isDefined)\n\n return uids\n}\n\n/** Create a \"uid\" from a slug */\nexport const getSlugUid = (slug: string) => `slug-uid-${slug}` as Collection['uid']\n\nexport type ImportSpecToWorkspaceArgs = Pick<CollectionPayload, 'documentUrl' | 'watchMode'> &\n Pick<ApiReferenceConfiguration, 'authentication' | 'baseServerURL' | 'servers' | 'slug'> & {\n /** The dereferenced document */\n dereferencedDocument?: OpenAPIV3_1.Document\n /** Sets the preferred security scheme on the collection instead of the requests */\n useCollectionSecurity?: boolean\n /** Call the load step from the parser */\n shouldLoad?: boolean\n }\n\n/**\n * Imports an OpenAPI document and converts it to workspace entities (Collection, Request, Server, etc.)\n *\n * The imported entities maintain a close mapping to the original OpenAPI specification to enable:\n * - Bi-directional translation between spec and workspace entities\n * - Preservation of specification details and structure\n * - Accurate representation of relationships between components\n *\n * Relationships between entities are maintained through unique identifiers (UIDs) which allow:\n * - Flexible organization at different levels (workspace, collection, request)\n * - Proper linking between related components\n * - Easy lookup and reference of dependent entities\n */\nexport async function importSpecToWorkspace(\n content: string | UnknownObject | undefined,\n {\n /** If a dereferenced document is provided, we will skip the dereferencing step. */\n dereferencedDocument,\n authentication,\n baseServerURL,\n documentUrl,\n servers: configuredServers,\n useCollectionSecurity = false,\n slug,\n shouldLoad,\n watchMode = false,\n }: ImportSpecToWorkspaceArgs = {},\n): Promise<\n | {\n error: false\n collection: Collection\n requests: Request[]\n schema: OpenAPIV3_1.Document\n examples: RequestExample[]\n servers: Server[]\n tags: Tag[]\n securitySchemes: SecurityScheme[]\n }\n | { error: true; importWarnings: string[]; collection: undefined }\n> {\n const { schema, errors } = await parseSchema(content, { shouldLoad, dereferencedDocument })\n const importWarnings: string[] = [...errors.map((e) => e.message)]\n\n if (!schema) {\n return { importWarnings, error: true, collection: undefined }\n }\n // ---------------------------------------------------------------------------\n // Some entities will be broken out as individual lists for modification in the workspace\n const start = performance.now()\n const requests: Request[] = []\n\n // Add the base server url to collection servers\n const collectionServers: Server[] = getServersFromOpenApiDocument(configuredServers || schema.servers, {\n baseServerURL,\n documentUrl,\n })\n\n // Store operation servers\n const operationServers: Server[] = []\n\n // Fallback to the current window.location.origin if no servers are provided\n if (!collectionServers.length) {\n const fallbackUrl = getFallbackUrl()\n\n if (fallbackUrl) {\n collectionServers.push(serverSchema.parse({ url: fallbackUrl }))\n }\n }\n\n /**\n * List of all tag strings. For non compliant specs we may need to\n * add top level tag objects for missing tag objects\n */\n const tagNames: Set<string> = new Set()\n\n // ---------------------------------------------------------------------------\n // SECURITY HANDLING\n\n const security = schema.components?.securitySchemes ?? schema?.securityDefinitions ?? {}\n\n // @ts-expect-error - Toss out a deprecated warning for the old authentication state\n if (authentication?.oAuth2 || authentication?.apiKey || authentication?.http) {\n console.warn(\n `DEPRECATION WARNING: It looks like you're using legacy authentication config. Please migrate to use the updated config. See https://github.com/scalar/scalar/blob/main/documentation/configuration.md#authentication-partial This will be removed in a future version.`,\n )\n }\n\n const securitySchemes = (Object.entries(security) as Entries<Record<string, OpenAPIV3_1.SecuritySchemeObject>>)\n .map?.(([nameKey, _scheme]) => {\n // Apply any transforms we need before parsing\n const payload = {\n ..._scheme,\n // Add the new auth config overrides, we keep the old code below for backwards compatibility\n ...(authentication?.securitySchemes?.[nameKey] ?? {}),\n nameKey,\n } as SecuritySchemePayload\n\n // For oauth2 we need to add the type to the flows + prefill from authentication\n if (payload.type === 'oauth2' && payload.flows) {\n const flowKeys = Object.keys(payload.flows) as Array<keyof typeof payload.flows>\n\n flowKeys.forEach((key) => {\n if (!payload.flows?.[key] || _scheme.type !== 'oauth2') {\n return\n }\n const authFlow = (authentication?.securitySchemes?.[nameKey] as SecuritySchemeOauth2)?.flows?.[key] ?? {}\n\n // This part handles setting of flows via the new auth config, the rest can be removed in a future version\n payload.flows[key] = {\n ...(_scheme.flows?.[key] ?? {}),\n ...authFlow,\n } satisfies Oauth2FlowPayload\n\n const flow = payload.flows[key] as Oauth2FlowPayload\n\n // Set the type\n flow.type = key\n\n // Prefill values from authorization config - old deprecated config\n // @ts-expect-error - deprecated\n if (authentication?.oAuth2) {\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.accessToken) {\n // @ts-expect-error - deprecated\n flow.token = authentication.oAuth2.accessToken\n }\n\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.clientId) {\n // @ts-expect-error - deprecated\n flow['x-scalar-client-id'] = authentication.oAuth2.clientId\n }\n\n // @ts-expect-error - deprecated\n if (authentication.oAuth2.scopes) {\n // @ts-expect-error - deprecated\n flow.selectedScopes = authentication.oAuth2.scopes\n }\n\n if (flow.type === 'password') {\n // @ts-expect-error - deprecated\n flow.username = authentication.oAuth2.username\n // @ts-expect-error - deprecated\n flow.password = authentication.oAuth2.password\n }\n }\n\n // Convert scopes to an object\n if (Array.isArray(flow.scopes)) {\n flow.scopes = flow.scopes.reduce((prev, s) => ({ ...prev, [s]: '' }), {})\n }\n\n // Handle x-defaultClientId\n if (flow['x-defaultClientId']) {\n flow['x-scalar-client-id'] = flow['x-defaultClientId']\n }\n })\n }\n // Otherwise we just prefill - old deprecated config\n else if (authentication) {\n // ApiKey\n // @ts-expect-error - deprecated\n if (payload.type === 'apiKey' && authentication.apiKey?.token) {\n // @ts-expect-error - deprecated\n payload.value = authentication.apiKey.token\n }\n // HTTP\n else if (payload.type === 'http') {\n // @ts-expect-error - deprecated\n if (payload.scheme === 'basic' && authentication.http?.basic) {\n // @ts-expect-error - deprecated\n payload.username = authentication.http.basic.username ?? ''\n // @ts-expect-error - deprecated\n payload.password = authentication.http.basic.password ?? ''\n }\n // Bearer\n // @ts-expect-error - deprecated\n else if (payload.scheme === 'bearer' && authentication.http?.bearer?.token) {\n // @ts-expect-error - deprecated\n payload.token = authentication.http.bearer.token ?? ''\n }\n }\n }\n\n const scheme = schemaModel(payload, securitySchemeSchema, false)\n if (!scheme) {\n importWarnings.push(`Security scheme ${nameKey} is invalid.`)\n }\n\n return scheme\n })\n .filter((v) => !!v)\n\n // Map of security scheme names to UIDs\n const securitySchemeMap: Record<string, SecurityScheme['uid']> = {}\n securitySchemes.forEach((s) => {\n securitySchemeMap[s.nameKey] = s.uid\n })\n\n // ---------------------------------------------------------------------------\n // REQUEST HANDLING\n\n keysOf(schema.paths ?? {}).forEach((pathString) => {\n const path = schema?.paths?.[pathString]\n\n if (!path) {\n return\n }\n // Path level servers must be saved\n const pathServers = serverSchema.array().parse(path.servers ?? [])\n for (const server of pathServers) {\n collectionServers.push(server)\n }\n\n // Creates a sorted array of methods based on the path object.\n const methods = Object.keys(path).filter(isHttpMethod)\n\n methods.forEach((method) => {\n const operation = path[method]\n if (!operation) {\n return\n }\n\n const operationLevelServers = serverSchema.array().parse(operation.servers ?? [])\n\n for (const server of operationLevelServers) {\n operationServers.push(server)\n }\n\n // We will save a list of all tags to ensure they exists at the top level\n // TODO: make sure we add any loose requests with no tags to the collection children\n operation.tags?.forEach((t: string) => tagNames.add(t))\n\n // Remove security here and add it correctly below\n const { security: operationSecurity, ...operationWithoutSecurity } = operation\n\n const securityRequirements: (string | string[])[] = (operationSecurity ?? schema.security ?? [])\n .map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n return keys.length > 1 ? keys : keys[0]\n })\n .filter(isDefined)\n\n // Filter the preferred security schemes to only include the ones that are in the security requirements\n const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat().filter((name) => {\n // Match up complex security requirements, array to array\n if (Array.isArray(name)) {\n // We match every element in the array\n return securityRequirements.some(\n (r) => Array.isArray(r) && r.length === name.length && r.every((v, i) => v === name[i]),\n )\n }\n return securityRequirements.includes(name)\n })\n\n // Set the initially selected security scheme\n const selectedSecuritySchemeUids =\n securityRequirements.length && !useCollectionSecurity\n ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)\n : []\n\n const requestPayload: RequestPayload = {\n ...operationWithoutSecurity,\n method,\n path: pathString,\n security: operationSecurity,\n selectedServerUid: operationLevelServers?.[0]?.uid,\n selectedSecuritySchemeUids,\n // Merge path and operation level parameters\n parameters: [...(path?.parameters ?? []), ...(operation.parameters ?? [])] as RequestParameterPayload[],\n servers: [...pathServers, ...operationLevelServers].map((s) => s.uid),\n }\n\n // Remove any examples from the request payload as they conflict with our examples property and are not valid\n if (requestPayload.examples) {\n console.warn('[@scalar/api-client] operation.examples is not a valid openapi property')\n delete requestPayload.examples\n }\n\n // Save parse the request\n const request = schemaModel(requestPayload, requestSchema, false)\n\n if (!request) {\n importWarnings.push(`${method} Request at ${path} is invalid.`)\n } else {\n requests.push(request)\n }\n })\n })\n\n // ---------------------------------------------------------------------------\n // TAG HANDLING\n\n // TODO: We may need to handle de-duping tags\n const tags = schemaModel(schema?.tags ?? [], tagSchema.array(), false) ?? []\n\n // Delete any tag names that already have a definition\n tags.forEach((t) => tagNames.delete(t.name))\n\n // Add an entry for any tags that are used but do not have a definition\n tagNames.forEach((name) => name && tags.push(tagSchema.parse({ name })))\n\n // Tag name to UID map\n const tagMap: Record<string, Tag> = {}\n tags.forEach((t) => {\n tagMap[t.name] = t\n })\n\n // Add all tags by default. We will remove nested ones\n const collectionChildren = new Set<Collection['children'][number]>(tags.map((t) => t.uid))\n\n // Nested folders go before any requests\n tags.forEach((t) => {\n t['x-scalar-children']?.forEach((c) => {\n // Add the uid to the appropriate parent.children\n const nestedUid = tagMap[c.tagName]?.uid\n\n if (nestedUid) {\n t.children.push(nestedUid)\n\n // Remove the nested uid from the root folder\n collectionChildren.delete(nestedUid)\n }\n })\n })\n\n // Add the request UIDs to the tag children (or collection root)\n requests.forEach((r) => {\n if (r.tags?.length) {\n r.tags.forEach((t) => {\n tagMap[t]?.children.push(r.uid)\n })\n } else {\n collectionChildren.add(r.uid)\n }\n })\n\n // ---------------------------------------------------------------------------\n\n const examples: RequestExample[] = []\n\n // Ensure each request has at least 1 example\n requests.forEach((request) => {\n // TODO: Need to handle parsing examples\n // if (request['x-scalar-examples']) return\n\n // Create the initial example\n const example = createExampleFromRequest(request, 'Default Example')\n\n examples.push(example)\n request.examples.push(example.uid)\n })\n\n // ---------------------------------------------------------------------------\n // Generate Collection\n\n // Grab the security requirements for this operation\n const securityRequirements: SelectedSecuritySchemeUids = (schema.security ?? [])\n .map((s: OpenAPIV3_1.SecurityRequirementObject) => {\n const keys = Object.keys(s)\n return keys.length > 1 ? keys : keys[0]\n })\n .filter(isDefined)\n\n // Here we do not filter these as we let the preferredSecurityScheme override the requirements\n const preferredSecurityNames = [authentication?.preferredSecurityScheme ?? []].flat()\n\n // Set the initially selected security scheme\n const selectedSecuritySchemeUids =\n (securityRequirements.length || preferredSecurityNames?.length) && useCollectionSecurity\n ? getSelectedSecuritySchemeUids(securityRequirements, preferredSecurityNames, securitySchemeMap)\n : []\n\n // Set the uid as a prefixed slug if we have one\n const slugObj = slug?.length ? { uid: getSlugUid(slug) } : {}\n\n const collection = collectionSchema.parse({\n ...slugObj,\n ...schema,\n watchMode,\n documentUrl,\n useCollectionSecurity,\n requests: requests.map((r) => r.uid),\n servers: collectionServers.map((s) => s.uid),\n tags: tags.map((t) => t.uid),\n children: [...collectionChildren],\n security: schema.security ?? [{}],\n selectedServerUid: collectionServers?.[0]?.uid,\n selectedSecuritySchemeUids,\n components: {\n ...schema.components,\n },\n securitySchemes: securitySchemes.map((s) => s.uid),\n })\n\n const end = performance.now()\n console.log(`workspace: ${Math.round(end - start)} ms`)\n\n /**\n * Servers and requests will be saved in top level maps and indexed via UID to\n * maintain specification relationships\n */\n return {\n error: false,\n servers: [...collectionServers, ...operationServers],\n schema,\n requests,\n examples,\n collection,\n tags,\n securitySchemes,\n }\n}\n\n/**\n * Extracts the base URL (protocol + hostname) from a document URL.\n * Falls back to the original URL if it's not a valid URL.\n */\nfunction getBaseUrlFromDocumentUrl(documentUrl: string): string | undefined {\n try {\n const url = new URL(documentUrl)\n return `${url.protocol}//${url.hostname}`\n } catch {\n // If the documentUrl is not a valid URL, we can't use it\n return undefined\n }\n}\n\n/**\n * Retrieves a list of servers from an OpenAPI document and converts them to a list of Server entities.\n */\nexport function getServersFromOpenApiDocument(\n servers: OpenAPIV3_1.ServerObject[] | undefined,\n {\n baseServerURL,\n documentUrl,\n }: Pick<ApiReferenceConfiguration, 'baseServerURL'> & Pick<ImportSpecToWorkspaceArgs, 'documentUrl'> = {},\n): Server[] {\n // If the document doesn't have any servers, try to use the documentUrl as the default server.\n if (!servers?.length && documentUrl) {\n const newServerUrl = getBaseUrlFromDocumentUrl(documentUrl)\n\n if (newServerUrl) {\n return [serverSchema.parse({ url: newServerUrl })]\n }\n }\n\n // If the servers are not an array, return an empty array.\n if (!servers || !Array.isArray(servers)) {\n return []\n }\n\n return servers\n .map((server): Server | undefined => {\n try {\n // Validate the server against the schema\n const parsedSchema = serverSchema.parse(server)\n\n // Prepend with the base server URL (if the given URL is relative)\n if (parsedSchema?.url?.startsWith('/')) {\n // Use the base server URL (if provided)\n if (baseServerURL) {\n parsedSchema.url = combineUrlAndPath(baseServerURL, parsedSchema.url)\n\n return parsedSchema\n }\n\n if (documentUrl) {\n const baseUrl = getBaseUrlFromDocumentUrl(documentUrl)\n\n if (baseUrl) {\n parsedSchema.url = combineUrlAndPath(baseUrl, parsedSchema.url)\n }\n\n return parsedSchema\n }\n\n // Fallback to the current window origin\n const fallbackUrl = getFallbackUrl()\n\n if (fallbackUrl) {\n parsedSchema.url = combineUrlAndPath(fallbackUrl, parsedSchema.url.replace(/^\\//, ''))\n\n return parsedSchema\n }\n }\n\n // Must be good, return it\n return parsedSchema\n } catch (error) {\n console.warn(\"Oops, that's an invalid server configuration.\")\n console.warn('Server:', server)\n console.warn('Error:', error)\n\n // Return undefined to remove the server\n return undefined\n }\n })\n .filter(isDefined)\n}\n\n/**\n * Fallback to the current window.location.origin, if available\n */\nfunction getFallbackUrl() {\n if (typeof window === 'undefined') {\n return undefined\n }\n\n if (typeof window?.location?.origin !== 'string') {\n return undefined\n }\n\n return window.location.origin\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,cAAc;AACvB,SAA0B,aAAa,MAAM,eAAe;AAI5D;AAAA,EAIE;AAAA,OACK;AAKP,SAAkD,wBAAwB;AAE1E,SAA8B,gCAAgC;AAC9D,SAA4C,qBAAqB;AACjE,SAAsB,oBAAoB;AAC1C,SAAmB,iBAAiB;AACpC,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Aa,MAAM,kBAAkB,aAAa,aAAa,IAAI,QAAQ,OAAO,EAAE,CAAC;AAErF,iBAAO;AAAA,QACT;AAAA,MACF;AAGA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,cAAQ,KAAK,+CAA+C;AAC5D,cAAQ,KAAK,WAAW,MAAM;AAC9B,cAAQ,KAAK,UAAU,KAAK;AAG5B,aAAO;AAAA,IACT;AAAA,EACF,CAAC,EACA,OAAO,SAAS;AACrB;AAKA,SAAS,iBAAiB;AACxB,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,QAAQ,UAAU,WAAW,UAAU;AAChD,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,SAAS;AACzB;",
|
|
6
6
|
"names": ["securityRequirements", "preferredSecurityNames", "selectedSecuritySchemeUids"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.4.
|
|
19
|
+
"version": "0.4.12",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=20"
|
|
22
22
|
},
|
|
@@ -100,11 +100,11 @@
|
|
|
100
100
|
"yaml": "2.8.0",
|
|
101
101
|
"zod": "3.24.1",
|
|
102
102
|
"@scalar/helpers": "0.0.6",
|
|
103
|
-
"@scalar/openapi-types": "0.3.5",
|
|
104
|
-
"@scalar/types": "0.2.7",
|
|
105
|
-
"@scalar/themes": "0.13.8",
|
|
106
103
|
"@scalar/object-utils": "1.2.2",
|
|
107
|
-
"@scalar/
|
|
104
|
+
"@scalar/openapi-types": "0.3.5",
|
|
105
|
+
"@scalar/themes": "0.13.9",
|
|
106
|
+
"@scalar/types": "0.2.8",
|
|
107
|
+
"@scalar/workspace-store": "0.9.0"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
110
|
"@types/node": "^22.9.0",
|
|
@@ -112,9 +112,9 @@
|
|
|
112
112
|
"vite": "5.4.19",
|
|
113
113
|
"vitest": "^1.6.1",
|
|
114
114
|
"zod-to-ts": "github:amritk/zod-to-ts#build",
|
|
115
|
-
"@scalar/
|
|
115
|
+
"@scalar/build-tooling": "0.2.4",
|
|
116
116
|
"@scalar/openapi-parser": "0.18.1",
|
|
117
|
-
"@scalar/
|
|
117
|
+
"@scalar/openapi-types": "0.3.5"
|
|
118
118
|
},
|
|
119
119
|
"scripts": {
|
|
120
120
|
"build": "scalar-build-esbuild",
|