@scalar/oas-utils 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/entities/spec/collection.d.ts +6 -12
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +1 -1
- package/dist/entities/spec/collection.js.map +2 -2
- package/dist/entities/spec/operation.d.ts +3 -0
- package/dist/entities/spec/operation.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +1 -1
- package/dist/entities/spec/request-examples.js.map +2 -2
- package/dist/entities/spec/requests.d.ts +8 -0
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/requests.js +2 -0
- package/dist/entities/spec/requests.js.map +2 -2
- package/dist/helpers/http-methods.js +9 -9
- package/dist/helpers/http-methods.js.map +1 -1
- package/dist/helpers/pretty-print-json.d.ts.map +1 -1
- package/dist/helpers/pretty-print-json.js.map +2 -2
- package/dist/transforms/import-spec.d.ts +8 -3
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +30 -9
- package/dist/transforms/import-spec.js.map +2 -2
- package/package.json +4 -4
- package/dist/entities/spec/operation.test.js +0 -43
- package/dist/entities/spec/operation.test.js.map +0 -7
- package/dist/entities/spec/parameters.test.js +0 -80
- package/dist/entities/spec/parameters.test.js.map +0 -7
- package/dist/entities/spec/request-example.test.js +0 -636
- package/dist/entities/spec/request-example.test.js.map +0 -7
- package/dist/entities/spec/server.test.js +0 -120
- package/dist/entities/spec/server.test.js.map +0 -7
- package/dist/entities/spec/spec-objects.test.js +0 -205
- package/dist/entities/spec/spec-objects.test.js.map +0 -7
- package/dist/entities/spec/x-scalar-environments.test.js +0 -11
- package/dist/entities/spec/x-scalar-environments.test.js.map +0 -7
- package/dist/entities/spec/x-scalar-secrets.test.js +0 -11
- package/dist/entities/spec/x-scalar-secrets.test.js.map +0 -7
- package/dist/helpers/ensure-protocol.test.js +0 -70
- package/dist/helpers/ensure-protocol.test.js.map +0 -7
- package/dist/helpers/fetch-document.test.js +0 -63
- package/dist/helpers/fetch-document.test.js.map +0 -7
- package/dist/helpers/find-variables.test.js +0 -20
- package/dist/helpers/find-variables.test.js.map +0 -7
- package/dist/helpers/is-defined.test.js +0 -37
- package/dist/helpers/is-defined.test.js.map +0 -7
- package/dist/helpers/is-local-url.test.js +0 -40
- package/dist/helpers/is-local-url.test.js.map +0 -7
- package/dist/helpers/is-valid-url.test.js +0 -17
- package/dist/helpers/is-valid-url.test.js.map +0 -7
- package/dist/helpers/json2xml.test.js +0 -19
- package/dist/helpers/json2xml.test.js.map +0 -7
- package/dist/helpers/make-url-absolute.test.js +0 -61
- package/dist/helpers/make-url-absolute.test.js.map +0 -7
- package/dist/helpers/merge-urls.test.js +0 -339
- package/dist/helpers/merge-urls.test.js.map +0 -7
- package/dist/helpers/normalize-mime-type-object.test.js +0 -53
- package/dist/helpers/normalize-mime-type-object.test.js.map +0 -7
- package/dist/helpers/normalize-mime-type.test.js +0 -33
- package/dist/helpers/normalize-mime-type.test.js.map +0 -7
- package/dist/helpers/omit-undefined-values.test.js +0 -89
- package/dist/helpers/omit-undefined-values.test.js.map +0 -7
- package/dist/helpers/parse.test.js +0 -45
- package/dist/helpers/parse.test.js.map +0 -7
- package/dist/helpers/pretty-print-json.test.js +0 -28
- package/dist/helpers/pretty-print-json.test.js.map +0 -7
- package/dist/helpers/redirect-to-proxy.test.js +0 -54
- package/dist/helpers/redirect-to-proxy.test.js.map +0 -7
- package/dist/helpers/regex-helpers.test.js +0 -154
- package/dist/helpers/regex-helpers.test.js.map +0 -7
- package/dist/helpers/replace-variables.test.js +0 -30
- package/dist/helpers/replace-variables.test.js.map +0 -7
- package/dist/helpers/security/get-schemes.test.js +0 -71
- package/dist/helpers/security/get-schemes.test.js.map +0 -7
- package/dist/helpers/security/has-token.test.js +0 -157
- package/dist/helpers/security/has-token.test.js.map +0 -7
- package/dist/migrations/semver.test.js +0 -21
- package/dist/migrations/semver.test.js.map +0 -7
- package/dist/migrations/v-2.4.0/migration.test.js +0 -90
- package/dist/migrations/v-2.4.0/migration.test.js.map +0 -7
- package/dist/migrations/v-2.5.0/migration.test.js +0 -108
- package/dist/migrations/v-2.5.0/migration.test.js.map +0 -7
- package/dist/spec-getters/get-example-from-schema.test.js +0 -1092
- package/dist/spec-getters/get-example-from-schema.test.js.map +0 -7
- package/dist/spec-getters/get-parameters-from-operation.test.js +0 -178
- package/dist/spec-getters/get-parameters-from-operation.test.js.map +0 -7
- package/dist/spec-getters/get-request-body-from-operation.test.js +0 -289
- package/dist/spec-getters/get-request-body-from-operation.test.js.map +0 -7
- package/dist/transforms/import-spec.test.js +0 -1124
- package/dist/transforms/import-spec.test.js.map +0 -7
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/regex-helpers.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { REGEX } from './regex-helpers'\n\ndescribe('protocolRegex', () => {\n it('allows http://', () => {\n const text = 'http://example.com'\n expect(text.match(REGEX.PROTOCOL)).toBeTruthy()\n })\n\n it('allows https://', () => {\n const text = 'https://example.com'\n expect(text.match(REGEX.PROTOCOL)).toBeTruthy()\n })\n\n it('allows file://', () => {\n const text = 'file://example.com'\n expect(text.match(REGEX.PROTOCOL)).toBeTruthy()\n })\n\n it('allows ftp://', () => {\n const text = 'ftp://example.com'\n expect(text.match(REGEX.PROTOCOL)).toBeTruthy()\n })\n\n it('allows mailto://', () => {\n const text = 'mailto://example.com'\n expect(text.match(REGEX.PROTOCOL)).toBeTruthy()\n })\n\n it('does not allow variables before ://', () => {\n const text = '{protocol}://example.com'\n expect(text.match(REGEX.PROTOCOL)).toBeNull()\n })\n\n it('does not allow no protocol with a variable', () => {\n const text = '{base}/api'\n expect(text.match(REGEX.PROTOCOL)).toBeNull()\n })\n\n it('does not allow no protocol with no variables', () => {\n const text = 'example.com'\n expect(text.match(REGEX.PROTOCOL)).toBeNull()\n })\n})\n\ndescribe('multipleSlashesRegex', () => {\n it('matches multiple slashes', () => {\n const text = 'http://example.com//api'.replace(REGEX.MULTIPLE_SLASHES, '/')\n expect(text).toBe('http://example.com/api')\n })\n\n it('matches multiple slashes in the path', () => {\n const text = 'http://example.com/api//users////{id}'.replace(REGEX.MULTIPLE_SLASHES, '/')\n expect(text).toBe('http://example.com/api/users/{id}')\n })\n\n it('does not match single slash or the scheme', () => {\n const text = 'http://example.com/api/users/{id}'\n expect(text.match(REGEX.MULTIPLE_SLASHES)).toBeNull()\n })\n\n it('does not do anything to the query params', () => {\n const text = 'http://example.com/api/users/{id}?query=param'\n expect(text.replace(REGEX.MULTIPLE_SLASHES, '/')).toBe('http://example.com/api/users/{id}?query=param')\n })\n})\n\ndescribe('variableRegex', () => {\n it('matches variables with double curly braces', () => {\n const text = '{{example.com}}'\n const matches = [...text.matchAll(REGEX.VARIABLES)]\n expect(matches.length).toBe(1)\n expect(matches[0]![1]).toBe('example.com')\n })\n\n it('matches variables with nested curly braces', () => {\n const text = '{{example.com:{port}}}'\n const matches = [...text.matchAll(REGEX.VARIABLES)]\n expect(matches.length).toBe(1)\n expect(matches[0]![1]).toBe('example.com:{port}')\n })\n\n it('matches multiple variables', () => {\n const text = '{{{host}.example.com:{port}}}'\n const matches = [...text.matchAll(REGEX.VARIABLES)]\n expect(matches.length).toBe(1)\n expect(matches[0]![1]).toBe('{host}.example.com:{port}')\n })\n\n it('does not match single curly braces', () => {\n const text = '{example.com}'\n const matches = [...text.matchAll(REGEX.VARIABLES)]\n expect(matches.length).toBe(0)\n })\n\n it('does not match unbalanced curly braces', () => {\n const text = '{{example.com}'\n const matches = [...text.matchAll(REGEX.VARIABLES)]\n expect(matches.length).toBe(0)\n })\n\n it('matches variables with whitespace', () => {\n const text = '{{ example.com }}'\n const matches = [...text.matchAll(REGEX.VARIABLES)]\n expect(matches.length).toBe(1)\n expect(matches[0]![1]).toBe(' example.com ')\n })\n\n it('matches variables in longer text', () => {\n const text = 'prefix {{variable}} suffix'\n const matches = [...text.matchAll(REGEX.VARIABLES)]\n expect(matches.length).toBe(1)\n expect(matches[0]![1]).toBe('variable')\n })\n\n it('matches multiple separate variables', () => {\n const text = '{{first}} middle {{second}}'\n const matches = [...text.matchAll(REGEX.VARIABLES)]\n expect(matches.length).toBe(2)\n expect(matches[0]![1]).toBe('first')\n expect(matches[1]![1]).toBe('second')\n })\n})\n\ndescribe('pathRegex', () => {\n it('matches path parameters', () => {\n const text = '/users/{id}'\n const matches = [...text.matchAll(REGEX.PATH)]\n expect(matches.length).toBe(1)\n expect(matches[0]![1]).toBe('id')\n })\n\n it('matches multiple path parameters', () => {\n const text = '/users/{userId}/posts/{postId}'\n const matches = [...text.matchAll(REGEX.PATH)]\n expect(matches.length).toBe(2)\n expect(matches[0]![1]).toBe('userId')\n expect(matches[1]![1]).toBe('postId')\n })\n\n it('does not match double curly braces', () => {\n const text = '/users/{{id}}'\n const matches = [...text.matchAll(REGEX.PATH)]\n expect(matches.length).toBe(0)\n })\n\n it('matches path parameters with dots', () => {\n const text = '/api/{version}/users'\n const matches = [...text.matchAll(REGEX.PATH)]\n expect(matches.length).toBe(1)\n expect(matches[0]![1]).toBe('version')\n })\n\n it('matches path parameters with hyphens and underscores', () => {\n const text = '/users/{user-id}/posts/{post_id}'\n const matches = [...text.matchAll(REGEX.PATH)]\n expect(matches.length).toBe(2)\n expect(matches[0]![1]).toBe('user-id')\n expect(matches[1]![1]).toBe('post_id')\n })\n\n it('does not match nested curly braces', () => {\n const text = '/users/{outer{inner}}'\n const matches = [...text.matchAll(REGEX.PATH)]\n expect(matches.length).toBe(0)\n })\n\n it('matches path parameters at start of string', () => {\n const text = '{version}/api'\n const matches = [...text.matchAll(REGEX.PATH)]\n expect(matches.length).toBe(1)\n expect(matches[0]![1]).toBe('version')\n })\n\n it('matches path parameters at end of string', () => {\n const text = '/api/{version}'\n const matches = [...text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M,UAAU,CAAC,GAAG,KAAK,SAAS,MAAM,IAAI,CAAC;AAC7C,WAAO,QAAQ,MAAM,EAAE,KAAK,CAAC;AAC7B,WAAO,QAAQ,CAAC,EAAG,CAAC,CAAC,EAAE,KAAK,SAAS;AAAA,EACvC,CAAC;AAED,KAAG,4CAA4C,MAAM;AACnD,UAAM,OAAO;AACb,UAAM,UAAU,CAAC,GAAG,KAAK,SAAS,MAAM,IAAI,CAAC;AAC7C,WAAO,QAAQ,MAAM,EAAE,KAAK,CAAC;AAC7B,WAAO,QAAQ,CAAC,EAAG,CAAC,CAAC,EAAE,KAAK,SAAS;AAAA,EACvC,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { replaceVariables } from "./replace-variables.js";
|
|
3
|
-
describe("replaceVariables", () => {
|
|
4
|
-
it("replaces variables with a single bracket", () => {
|
|
5
|
-
expect(
|
|
6
|
-
replaceVariables("foo{bar}foo", {
|
|
7
|
-
bar: "foo"
|
|
8
|
-
})
|
|
9
|
-
).toMatchObject("foofoofoo");
|
|
10
|
-
});
|
|
11
|
-
it("replaces variables with a double bracket", () => {
|
|
12
|
-
expect(
|
|
13
|
-
replaceVariables("foo{{bar}}foo", {
|
|
14
|
-
bar: "foo"
|
|
15
|
-
})
|
|
16
|
-
).toMatchObject("foofoofoo");
|
|
17
|
-
});
|
|
18
|
-
it("replaces variables with a custom callback", () => {
|
|
19
|
-
expect(replaceVariables("foo{{bar}}foo", (match) => match === "bar" ? "<span>foo</span>" : "")).toMatchObject(
|
|
20
|
-
"foo<span>foo</span>foo"
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
it("returns variable in curly braces when value is empty", () => {
|
|
24
|
-
const template = "http://{host}:{port}/api";
|
|
25
|
-
const variables = { host: "localhost", port: "" };
|
|
26
|
-
const result = replaceVariables(template, variables);
|
|
27
|
-
expect(result).toBe("http://localhost:{port}/api");
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=replace-variables.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/helpers/replace-variables.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { replaceVariables } from './replace-variables'\n\ndescribe('replaceVariables', () => {\n it('replaces variables with a single bracket', () => {\n expect(\n replaceVariables('foo{bar}foo', {\n bar: 'foo',\n }),\n ).toMatchObject('foofoofoo')\n })\n\n it('replaces variables with a double bracket', () => {\n expect(\n replaceVariables('foo{{bar}}foo', {\n bar: 'foo',\n }),\n ).toMatchObject('foofoofoo')\n })\n\n it('replaces variables with a custom callback', () => {\n expect(replaceVariables('foo{{bar}}foo', (match) => (match === 'bar' ? '<span>foo</span>' : ''))).toMatchObject(\n 'foo<span>foo</span>foo',\n )\n })\n\n it('returns variable in curly braces when value is empty', () => {\n const template = 'http://{host}:{port}/api'\n const variables = { host: 'localhost', port: '' }\n\n const result = replaceVariables(template, variables)\n\n expect(result).toBe('http://localhost:{port}/api')\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,wBAAwB;AAEjC,SAAS,oBAAoB,MAAM;AACjC,KAAG,4CAA4C,MAAM;AACnD;AAAA,MACE,iBAAiB,eAAe;AAAA,QAC9B,KAAK;AAAA,MACP,CAAC;AAAA,IACH,EAAE,cAAc,WAAW;AAAA,EAC7B,CAAC;AAED,KAAG,4CAA4C,MAAM;AACnD;AAAA,MACE,iBAAiB,iBAAiB;AAAA,QAChC,KAAK;AAAA,MACP,CAAC;AAAA,IACH,EAAE,cAAc,WAAW;AAAA,EAC7B,CAAC;AAED,KAAG,6CAA6C,MAAM;AACpD,WAAO,iBAAiB,iBAAiB,CAAC,UAAW,UAAU,QAAQ,qBAAqB,EAAG,CAAC,EAAE;AAAA,MAChG;AAAA,IACF;AAAA,EACF,CAAC;AAED,KAAG,wDAAwD,MAAM;AAC/D,UAAM,WAAW;AACjB,UAAM,YAAY,EAAE,MAAM,aAAa,MAAM,GAAG;AAEhD,UAAM,SAAS,iBAAiB,UAAU,SAAS;AAEnD,WAAO,MAAM,EAAE,KAAK,6BAA6B;AAAA,EACnD,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { securitySchemeSchema } from "@scalar/types/entities";
|
|
2
|
-
import { describe, it, expect } from "vitest";
|
|
3
|
-
import { getSchemes } from "./get-schemes.js";
|
|
4
|
-
describe("getSchemes", () => {
|
|
5
|
-
const mockSecuritySchemes = {
|
|
6
|
-
"auth1-uid": securitySchemeSchema.parse({
|
|
7
|
-
uid: "auth1-uid",
|
|
8
|
-
type: "http",
|
|
9
|
-
scheme: "bearer"
|
|
10
|
-
}),
|
|
11
|
-
"auth2-uid": securitySchemeSchema.parse({
|
|
12
|
-
uid: "auth2-uid",
|
|
13
|
-
type: "apiKey",
|
|
14
|
-
in: "header"
|
|
15
|
-
}),
|
|
16
|
-
"auth3-uid": securitySchemeSchema.parse({
|
|
17
|
-
uid: "auth3-uid",
|
|
18
|
-
type: "oauth2",
|
|
19
|
-
flows: {}
|
|
20
|
-
})
|
|
21
|
-
};
|
|
22
|
-
it("should return empty array for empty input", () => {
|
|
23
|
-
const result = getSchemes([], mockSecuritySchemes);
|
|
24
|
-
expect(result).toEqual([]);
|
|
25
|
-
});
|
|
26
|
-
it("should handle single-level array of UIDs", () => {
|
|
27
|
-
const result = getSchemes(
|
|
28
|
-
["auth1-uid", "auth2-uid"],
|
|
29
|
-
mockSecuritySchemes
|
|
30
|
-
);
|
|
31
|
-
expect(result).toHaveLength(2);
|
|
32
|
-
expect(result).toEqual([mockSecuritySchemes["auth1-uid"], mockSecuritySchemes["auth2-uid"]]);
|
|
33
|
-
});
|
|
34
|
-
it("should handle nested arrays of UIDs", () => {
|
|
35
|
-
const result = getSchemes(
|
|
36
|
-
[["auth1-uid"], ["auth2-uid", "auth3-uid"]],
|
|
37
|
-
mockSecuritySchemes
|
|
38
|
-
);
|
|
39
|
-
expect(result).toHaveLength(3);
|
|
40
|
-
expect(result).toEqual([
|
|
41
|
-
mockSecuritySchemes["auth1-uid"],
|
|
42
|
-
mockSecuritySchemes["auth2-uid"],
|
|
43
|
-
mockSecuritySchemes["auth3-uid"]
|
|
44
|
-
]);
|
|
45
|
-
});
|
|
46
|
-
it("should deduplicate UIDs", () => {
|
|
47
|
-
const result = getSchemes(
|
|
48
|
-
[
|
|
49
|
-
["auth1-uid", "auth1-uid"],
|
|
50
|
-
["auth1-uid", "auth2-uid"]
|
|
51
|
-
],
|
|
52
|
-
mockSecuritySchemes
|
|
53
|
-
);
|
|
54
|
-
expect(result).toHaveLength(2);
|
|
55
|
-
expect(result).toEqual([mockSecuritySchemes["auth1-uid"], mockSecuritySchemes["auth2-uid"]]);
|
|
56
|
-
});
|
|
57
|
-
it("should filter out undefined schemes", () => {
|
|
58
|
-
const result = getSchemes(
|
|
59
|
-
["auth1-uid", "nonexistent-uid", "auth2-uid"],
|
|
60
|
-
mockSecuritySchemes
|
|
61
|
-
);
|
|
62
|
-
expect(result).toHaveLength(2);
|
|
63
|
-
expect(result).toEqual([mockSecuritySchemes["auth1-uid"], mockSecuritySchemes["auth2-uid"]]);
|
|
64
|
-
});
|
|
65
|
-
it("should handle empty nested arrays", () => {
|
|
66
|
-
const result = getSchemes([[], ["auth1-uid"], []], mockSecuritySchemes);
|
|
67
|
-
expect(result).toHaveLength(1);
|
|
68
|
-
expect(result).toEqual([mockSecuritySchemes["auth1-uid"]]);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
//# sourceMappingURL=get-schemes.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/security/get-schemes.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { securitySchemeSchema, type SecurityScheme } from '@scalar/types/entities'\nimport { describe, it, expect } from 'vitest'\n\nimport { getSchemes } from './get-schemes'\nimport type { Operation } from '@/entities/spec/operation'\n\ndescribe('getSchemes', () => {\n // Setup some mock security schemes for testing\n const mockSecuritySchemes: Record<string, SecurityScheme> = {\n 'auth1-uid': securitySchemeSchema.parse({\n uid: 'auth1-uid',\n type: 'http',\n scheme: 'bearer',\n }),\n 'auth2-uid': securitySchemeSchema.parse({\n uid: 'auth2-uid',\n type: 'apiKey',\n in: 'header',\n }),\n 'auth3-uid': securitySchemeSchema.parse({\n uid: 'auth3-uid',\n type: 'oauth2',\n flows: {},\n }),\n }\n\n it('should return empty array for empty input', () => {\n const result = getSchemes([], mockSecuritySchemes)\n expect(result).toEqual([])\n })\n\n it('should handle single-level array of UIDs', () => {\n const result = getSchemes(\n ['auth1-uid', 'auth2-uid'] as Operation['selectedSecuritySchemeUids'],\n mockSecuritySchemes,\n )\n expect(result).toHaveLength(2)\n expect(result).toEqual([mockSecuritySchemes['auth1-uid'], mockSecuritySchemes['auth2-uid']])\n })\n\n it('should handle nested arrays of UIDs', () => {\n const result = getSchemes(\n [['auth1-uid'], ['auth2-uid', 'auth3-uid']] as Operation['selectedSecuritySchemeUids'],\n mockSecuritySchemes,\n )\n expect(result).toHaveLength(3)\n expect(result).toEqual([\n mockSecuritySchemes['auth1-uid'],\n mockSecuritySchemes['auth2-uid'],\n mockSecuritySchemes['auth3-uid'],\n ])\n })\n\n it('should deduplicate UIDs', () => {\n const result = getSchemes(\n [\n ['auth1-uid', 'auth1-uid'],\n ['auth1-uid', 'auth2-uid'],\n ] as Operation['selectedSecuritySchemeUids'],\n mockSecuritySchemes,\n )\n expect(result).toHaveLength(2)\n expect(result).toEqual([mockSecuritySchemes['auth1-uid'], mockSecuritySchemes['auth2-uid']])\n })\n\n it('should filter out undefined schemes', () => {\n const result = getSchemes(\n ['auth1-uid', 'nonexistent-uid', 'auth2-uid'] as Operation['selectedSecuritySchemeUids'],\n mockSecuritySchemes,\n )\n expect(result).toHaveLength(2)\n expect(result).toEqual([mockSecuritySchemes['auth1-uid'], mockSecuritySchemes['auth2-uid']])\n })\n\n it('should handle empty nested arrays', () => {\n const result = getSchemes([[], ['auth1-uid'], []] as Operation['selectedSecuritySchemeUids'], mockSecuritySchemes)\n expect(result).toHaveLength(1)\n expect(result).toEqual([mockSecuritySchemes['auth1-uid']])\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,4BAAiD;AAC1D,SAAS,UAAU,IAAI,cAAc;AAErC,SAAS,kBAAkB;AAG3B,SAAS,cAAc,MAAM;AAE3B,QAAM,sBAAsD;AAAA,IAC1D,aAAa,qBAAqB,MAAM;AAAA,MACtC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,IACV,CAAC;AAAA,IACD,aAAa,qBAAqB,MAAM;AAAA,MACtC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,IAAI;AAAA,IACN,CAAC;AAAA,IACD,aAAa,qBAAqB,MAAM;AAAA,MACtC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO,CAAC;AAAA,IACV,CAAC;AAAA,EACH;AAEA,KAAG,6CAA6C,MAAM;AACpD,UAAM,SAAS,WAAW,CAAC,GAAG,mBAAmB;AACjD,WAAO,MAAM,EAAE,QAAQ,CAAC,CAAC;AAAA,EAC3B,CAAC;AAED,KAAG,4CAA4C,MAAM;AACnD,UAAM,SAAS;AAAA,MACb,CAAC,aAAa,WAAW;AAAA,MACzB;AAAA,IACF;AACA,WAAO,MAAM,EAAE,aAAa,CAAC;AAC7B,WAAO,MAAM,EAAE,QAAQ,CAAC,oBAAoB,WAAW,GAAG,oBAAoB,WAAW,CAAC,CAAC;AAAA,EAC7F,CAAC;AAED,KAAG,uCAAuC,MAAM;AAC9C,UAAM,SAAS;AAAA,MACb,CAAC,CAAC,WAAW,GAAG,CAAC,aAAa,WAAW,CAAC;AAAA,MAC1C;AAAA,IACF;AACA,WAAO,MAAM,EAAE,aAAa,CAAC;AAC7B,WAAO,MAAM,EAAE,QAAQ;AAAA,MACrB,oBAAoB,WAAW;AAAA,MAC/B,oBAAoB,WAAW;AAAA,MAC/B,oBAAoB,WAAW;AAAA,IACjC,CAAC;AAAA,EACH,CAAC;AAED,KAAG,2BAA2B,MAAM;AAClC,UAAM,SAAS;AAAA,MACb;AAAA,QACE,CAAC,aAAa,WAAW;AAAA,QACzB,CAAC,aAAa,WAAW;AAAA,MAC3B;AAAA,MACA;AAAA,IACF;AACA,WAAO,MAAM,EAAE,aAAa,CAAC;AAC7B,WAAO,MAAM,EAAE,QAAQ,CAAC,oBAAoB,WAAW,GAAG,oBAAoB,WAAW,CAAC,CAAC;AAAA,EAC7F,CAAC;AAED,KAAG,uCAAuC,MAAM;AAC9C,UAAM,SAAS;AAAA,MACb,CAAC,aAAa,mBAAmB,WAAW;AAAA,MAC5C;AAAA,IACF;AACA,WAAO,MAAM,EAAE,aAAa,CAAC;AAC7B,WAAO,MAAM,EAAE,QAAQ,CAAC,oBAAoB,WAAW,GAAG,oBAAoB,WAAW,CAAC,CAAC;AAAA,EAC7F,CAAC;AAED,KAAG,qCAAqC,MAAM;AAC5C,UAAM,SAAS,WAAW,CAAC,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,GAA8C,mBAAmB;AACjH,WAAO,MAAM,EAAE,aAAa,CAAC;AAC7B,WAAO,MAAM,EAAE,QAAQ,CAAC,oBAAoB,WAAW,CAAC,CAAC;AAAA,EAC3D,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { securitySchemeSchema } from "@scalar/types/entities";
|
|
2
|
-
import { describe, it, expect } from "vitest";
|
|
3
|
-
import { hasToken } from "./has-token.js";
|
|
4
|
-
describe("hasToken", () => {
|
|
5
|
-
describe("apiKey scheme", () => {
|
|
6
|
-
it("returns true when value is present", () => {
|
|
7
|
-
const scheme = securitySchemeSchema.parse({
|
|
8
|
-
type: "apiKey",
|
|
9
|
-
value: "my-api-key",
|
|
10
|
-
in: "header",
|
|
11
|
-
name: "x-api-key"
|
|
12
|
-
});
|
|
13
|
-
expect(hasToken(scheme)).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
it("returns false when value is empty", () => {
|
|
16
|
-
const scheme = securitySchemeSchema.parse({
|
|
17
|
-
type: "apiKey",
|
|
18
|
-
value: "",
|
|
19
|
-
in: "header",
|
|
20
|
-
name: "x-api-key"
|
|
21
|
-
});
|
|
22
|
-
expect(hasToken(scheme)).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
describe("http scheme", () => {
|
|
26
|
-
describe("bearer", () => {
|
|
27
|
-
it("returns true when token is present", () => {
|
|
28
|
-
const scheme = securitySchemeSchema.parse({
|
|
29
|
-
type: "http",
|
|
30
|
-
scheme: "bearer",
|
|
31
|
-
token: "my-bearer-token"
|
|
32
|
-
});
|
|
33
|
-
expect(hasToken(scheme)).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
it("returns false when token is empty", () => {
|
|
36
|
-
const scheme = securitySchemeSchema.parse({
|
|
37
|
-
type: "http",
|
|
38
|
-
scheme: "bearer",
|
|
39
|
-
token: ""
|
|
40
|
-
});
|
|
41
|
-
expect(hasToken(scheme)).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe("basic", () => {
|
|
45
|
-
it("returns true when both username and password are present", () => {
|
|
46
|
-
const scheme = securitySchemeSchema.parse({
|
|
47
|
-
type: "http",
|
|
48
|
-
scheme: "basic",
|
|
49
|
-
username: "user",
|
|
50
|
-
password: "pass"
|
|
51
|
-
});
|
|
52
|
-
expect(hasToken(scheme)).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
it("returns false when username is missing", () => {
|
|
55
|
-
const scheme = securitySchemeSchema.parse({
|
|
56
|
-
type: "http",
|
|
57
|
-
scheme: "basic",
|
|
58
|
-
username: "",
|
|
59
|
-
password: "pass"
|
|
60
|
-
});
|
|
61
|
-
expect(hasToken(scheme)).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
it("returns false when password is missing", () => {
|
|
64
|
-
const scheme = securitySchemeSchema.parse({
|
|
65
|
-
type: "http",
|
|
66
|
-
scheme: "basic",
|
|
67
|
-
username: "user",
|
|
68
|
-
password: ""
|
|
69
|
-
});
|
|
70
|
-
expect(hasToken(scheme)).toBe(false);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe("oauth2 scheme", () => {
|
|
75
|
-
it("returns true when authorization code flow has token", () => {
|
|
76
|
-
const scheme = securitySchemeSchema.parse({
|
|
77
|
-
type: "oauth2",
|
|
78
|
-
flows: {
|
|
79
|
-
authorizationCode: {
|
|
80
|
-
token: "auth-code-token",
|
|
81
|
-
authorizationUrl: "https://auth.example.com",
|
|
82
|
-
tokenUrl: "https://token.example.com",
|
|
83
|
-
scopes: {}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
expect(hasToken(scheme)).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
it("returns true when client credentials flow has token", () => {
|
|
90
|
-
const scheme = securitySchemeSchema.parse({
|
|
91
|
-
type: "oauth2",
|
|
92
|
-
flows: {
|
|
93
|
-
clientCredentials: {
|
|
94
|
-
token: "client-creds-token",
|
|
95
|
-
tokenUrl: "https://token.example.com",
|
|
96
|
-
scopes: {}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
expect(hasToken(scheme)).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
it("returns true when password flow has token", () => {
|
|
103
|
-
const scheme = securitySchemeSchema.parse({
|
|
104
|
-
type: "oauth2",
|
|
105
|
-
flows: {
|
|
106
|
-
password: {
|
|
107
|
-
token: "password-token",
|
|
108
|
-
tokenUrl: "https://token.example.com",
|
|
109
|
-
scopes: {}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
expect(hasToken(scheme)).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
it("returns true when implicit flow has token", () => {
|
|
116
|
-
const scheme = securitySchemeSchema.parse({
|
|
117
|
-
type: "oauth2",
|
|
118
|
-
flows: {
|
|
119
|
-
implicit: {
|
|
120
|
-
token: "implicit-token",
|
|
121
|
-
authorizationUrl: "https://auth.example.com",
|
|
122
|
-
scopes: {}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
expect(hasToken(scheme)).toBe(true);
|
|
127
|
-
});
|
|
128
|
-
it("returns false when no flows have tokens", () => {
|
|
129
|
-
const scheme = securitySchemeSchema.parse({
|
|
130
|
-
type: "oauth2",
|
|
131
|
-
flows: {
|
|
132
|
-
authorizationCode: {
|
|
133
|
-
token: "",
|
|
134
|
-
authorizationUrl: "https://auth.example.com",
|
|
135
|
-
tokenUrl: "https://token.example.com",
|
|
136
|
-
scopes: {}
|
|
137
|
-
},
|
|
138
|
-
clientCredentials: {
|
|
139
|
-
token: "",
|
|
140
|
-
tokenUrl: "https://token.example.com",
|
|
141
|
-
scopes: {}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
expect(hasToken(scheme)).toBe(false);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
describe("unknown scheme type", () => {
|
|
149
|
-
it("returns false for unknown scheme types", () => {
|
|
150
|
-
const scheme = {
|
|
151
|
-
type: "unknown"
|
|
152
|
-
};
|
|
153
|
-
expect(hasToken(scheme)).toBe(false);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
//# sourceMappingURL=has-token.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/security/has-token.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { securitySchemeSchema } from '@scalar/types/entities'\nimport { describe, it, expect } from 'vitest'\n\nimport { hasToken } from './has-token'\n\ndescribe('hasToken', () => {\n describe('apiKey scheme', () => {\n it('returns true when value is present', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'apiKey',\n value: 'my-api-key',\n in: 'header',\n name: 'x-api-key',\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns false when value is empty', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'apiKey',\n value: '',\n in: 'header',\n name: 'x-api-key',\n })\n expect(hasToken(scheme)).toBe(false)\n })\n })\n\n describe('http scheme', () => {\n describe('bearer', () => {\n it('returns true when token is present', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'bearer',\n token: 'my-bearer-token',\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns false when token is empty', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'bearer',\n token: '',\n })\n expect(hasToken(scheme)).toBe(false)\n })\n })\n\n describe('basic', () => {\n it('returns true when both username and password are present', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'basic',\n username: 'user',\n password: 'pass',\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns false when username is missing', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'basic',\n username: '',\n password: 'pass',\n })\n expect(hasToken(scheme)).toBe(false)\n })\n\n it('returns false when password is missing', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'http',\n scheme: 'basic',\n username: 'user',\n password: '',\n })\n expect(hasToken(scheme)).toBe(false)\n })\n })\n })\n\n describe('oauth2 scheme', () => {\n it('returns true when authorization code flow has token', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n authorizationCode: {\n token: 'auth-code-token',\n authorizationUrl: 'https://auth.example.com',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns true when client credentials flow has token', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n clientCredentials: {\n token: 'client-creds-token',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns true when password flow has token', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n password: {\n token: 'password-token',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns true when implicit flow has token', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n implicit: {\n token: 'implicit-token',\n authorizationUrl: 'https://auth.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(true)\n })\n\n it('returns false when no flows have tokens', () => {\n const scheme = securitySchemeSchema.parse({\n type: 'oauth2',\n flows: {\n authorizationCode: {\n token: '',\n authorizationUrl: 'https://auth.example.com',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n clientCredentials: {\n token: '',\n tokenUrl: 'https://token.example.com',\n scopes: {},\n },\n },\n })\n expect(hasToken(scheme)).toBe(false)\n })\n })\n\n describe('unknown scheme type', () => {\n it('returns false for unknown scheme types', () => {\n // Note: For unknown types, we can't use parse as it would fail validation\n // This is testing the edge case of an invalid type\n const scheme = {\n type: 'unknown',\n } as any\n expect(hasToken(scheme)).toBe(false)\n })\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,4BAA4B;AACrC,SAAS,UAAU,IAAI,cAAc;AAErC,SAAS,gBAAgB;AAEzB,SAAS,YAAY,MAAM;AACzB,WAAS,iBAAiB,MAAM;AAC9B,OAAG,sCAAsC,MAAM;AAC7C,YAAM,SAAS,qBAAqB,MAAM;AAAA,QACxC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,IAAI;AAAA,QACJ,MAAM;AAAA,MACR,CAAC;AACD,aAAO,SAAS,MAAM,CAAC,EAAE,KAAK,IAAI;AAAA,IACpC,CAAC;AAED,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AM,CAAC,EAAE,KAAK,IAAI;AAAA,IACpC,CAAC;AAED,OAAG,2CAA2C,MAAM;AAClD,YAAM,SAAS,qBAAqB,MAAM;AAAA,QACxC,MAAM;AAAA,QACN,OAAO;AAAA,UACL,mBAAmB;AAAA,YACjB,OAAO;AAAA,YACP,kBAAkB;AAAA,YAClB,UAAU;AAAA,YACV,QAAQ,CAAC;AAAA,UACX;AAAA,UACA,mBAAmB;AAAA,YACjB,OAAO;AAAA,YACP,UAAU;AAAA,YACV,QAAQ,CAAC;AAAA,UACX;AAAA,QACF;AAAA,MACF,CAAC;AACD,aAAO,SAAS,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,IACrC,CAAC;AAAA,EACH,CAAC;AAED,WAAS,uBAAuB,MAAM;AACpC,OAAG,0CAA0C,MAAM;AAGjD,YAAM,SAAS;AAAA,QACb,MAAM;AAAA,MACR;AACA,aAAO,SAAS,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,IACrC,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { semverLessThan } from "./semver.js";
|
|
3
|
-
describe("compareSemVer", () => {
|
|
4
|
-
it("should return true if version1 is less than version2", () => {
|
|
5
|
-
expect(semverLessThan("1.2.3", "1.2.4")).toBe(true);
|
|
6
|
-
expect(semverLessThan("1.2.3", "1.3.0")).toBe(true);
|
|
7
|
-
expect(semverLessThan("1.2.3", "2.0.0")).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
it("should return false if version1 is not less than version2", () => {
|
|
10
|
-
expect(semverLessThan("1.2.4", "1.2.3")).toBe(false);
|
|
11
|
-
expect(semverLessThan("1.3.0", "1.2.3")).toBe(false);
|
|
12
|
-
expect(semverLessThan("2.0.0", "1.2.3")).toBe(false);
|
|
13
|
-
expect(semverLessThan("1.2.3", "1.2.3")).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
it("should handle missing minor and patch versions correctly", () => {
|
|
16
|
-
expect(semverLessThan("1", "1.0.0")).toBe(false);
|
|
17
|
-
expect(semverLessThan("1.2", "1.2.0")).toBe(false);
|
|
18
|
-
expect(semverLessThan("1.0", "1.1.0")).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=semver.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/migrations/semver.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { semverLessThan } from './semver'\n\ndescribe('compareSemVer', () => {\n it('should return true if version1 is less than version2', () => {\n expect(semverLessThan('1.2.3', '1.2.4')).toBe(true)\n expect(semverLessThan('1.2.3', '1.3.0')).toBe(true)\n expect(semverLessThan('1.2.3', '2.0.0')).toBe(true)\n })\n\n it('should return false if version1 is not less than version2', () => {\n expect(semverLessThan('1.2.4', '1.2.3')).toBe(false)\n expect(semverLessThan('1.3.0', '1.2.3')).toBe(false)\n expect(semverLessThan('2.0.0', '1.2.3')).toBe(false)\n expect(semverLessThan('1.2.3', '1.2.3')).toBe(false)\n })\n\n it('should handle missing minor and patch versions correctly', () => {\n expect(semverLessThan('1', '1.0.0')).toBe(false)\n expect(semverLessThan('1.2', '1.2.0')).toBe(false)\n expect(semverLessThan('1.0', '1.1.0')).toBe(true)\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,sBAAsB;AAE/B,SAAS,iBAAiB,MAAM;AAC9B,KAAG,wDAAwD,MAAM;AAC/D,WAAO,eAAe,SAAS,OAAO,CAAC,EAAE,KAAK,IAAI;AAClD,WAAO,eAAe,SAAS,OAAO,CAAC,EAAE,KAAK,IAAI;AAClD,WAAO,eAAe,SAAS,OAAO,CAAC,EAAE,KAAK,IAAI;AAAA,EACpD,CAAC;AAED,KAAG,6DAA6D,MAAM;AACpE,WAAO,eAAe,SAAS,OAAO,CAAC,EAAE,KAAK,KAAK;AACnD,WAAO,eAAe,SAAS,OAAO,CAAC,EAAE,KAAK,KAAK;AACnD,WAAO,eAAe,SAAS,OAAO,CAAC,EAAE,KAAK,KAAK;AACnD,WAAO,eAAe,SAAS,OAAO,CAAC,EAAE,KAAK,KAAK;AAAA,EACrD,CAAC;AAED,KAAG,4DAA4D,MAAM;AACnE,WAAO,eAAe,KAAK,OAAO,CAAC,EAAE,KAAK,KAAK;AAC/C,WAAO,eAAe,OAAO,OAAO,CAAC,EAAE,KAAK,KAAK;AACjD,WAAO,eAAe,OAAO,OAAO,CAAC,EAAE,KAAK,IAAI;AAAA,EAClD,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { describe, expect, expectTypeOf, it } from "vitest";
|
|
2
|
-
import { migrate_v_2_4_0 } from "./migration.js";
|
|
3
|
-
describe("migrate_v_2_4_0", () => {
|
|
4
|
-
it("should migrate draft collection by removing servers and updating request paths", () => {
|
|
5
|
-
const mockServer = {
|
|
6
|
-
uid: "server1",
|
|
7
|
-
url: "https://api.example.com",
|
|
8
|
-
description: "Test server"
|
|
9
|
-
};
|
|
10
|
-
const mockRequest = {
|
|
11
|
-
uid: "request1",
|
|
12
|
-
type: "request",
|
|
13
|
-
path: "/users",
|
|
14
|
-
method: "get",
|
|
15
|
-
servers: ["server1"],
|
|
16
|
-
selectedServerUid: "server1",
|
|
17
|
-
examples: [],
|
|
18
|
-
selectedSecuritySchemeUids: []
|
|
19
|
-
};
|
|
20
|
-
const mockDraftCollection = {
|
|
21
|
-
"uid": "draft1",
|
|
22
|
-
"type": "collection",
|
|
23
|
-
"info": {
|
|
24
|
-
title: "Drafts",
|
|
25
|
-
version: "1.0.0"
|
|
26
|
-
},
|
|
27
|
-
"openapi": "3.0.0",
|
|
28
|
-
"security": [],
|
|
29
|
-
"servers": ["server1"],
|
|
30
|
-
"selectedServerUid": "",
|
|
31
|
-
"securitySchemes": [],
|
|
32
|
-
"selectedSecuritySchemeUids": [],
|
|
33
|
-
"requests": ["request1"],
|
|
34
|
-
"tags": [],
|
|
35
|
-
"children": [],
|
|
36
|
-
"watchMode": false,
|
|
37
|
-
"watchModeStatus": "IDLE",
|
|
38
|
-
"x-scalar-icon": "draft"
|
|
39
|
-
};
|
|
40
|
-
const mockData = {
|
|
41
|
-
collections: {
|
|
42
|
-
draft1: mockDraftCollection
|
|
43
|
-
},
|
|
44
|
-
servers: {
|
|
45
|
-
server1: mockServer
|
|
46
|
-
},
|
|
47
|
-
requests: {
|
|
48
|
-
request1: mockRequest
|
|
49
|
-
},
|
|
50
|
-
cookies: {},
|
|
51
|
-
environments: {},
|
|
52
|
-
requestExamples: {},
|
|
53
|
-
securitySchemes: {},
|
|
54
|
-
tags: {},
|
|
55
|
-
workspaces: {}
|
|
56
|
-
};
|
|
57
|
-
const result = migrate_v_2_4_0(mockData);
|
|
58
|
-
expectTypeOf(result).toMatchTypeOf();
|
|
59
|
-
expect(result.collections.draft1?.servers).toEqual([]);
|
|
60
|
-
expect(result.requests.request1?.path).toBe("https://api.example.com/users");
|
|
61
|
-
expect(result.requests.request1?.selectedServerUid).toBe("");
|
|
62
|
-
});
|
|
63
|
-
it("should preserve all other data properties", () => {
|
|
64
|
-
const mockData = {
|
|
65
|
-
collections: {},
|
|
66
|
-
cookies: {
|
|
67
|
-
cookie1: {
|
|
68
|
-
uid: "cookie1",
|
|
69
|
-
name: "test",
|
|
70
|
-
value: "value",
|
|
71
|
-
sameSite: "Lax"
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
environments: {
|
|
75
|
-
env1: { uid: "env1", name: "test", color: "blue", value: "value" }
|
|
76
|
-
},
|
|
77
|
-
requestExamples: {},
|
|
78
|
-
requests: {},
|
|
79
|
-
securitySchemes: {},
|
|
80
|
-
servers: {},
|
|
81
|
-
tags: {},
|
|
82
|
-
workspaces: {}
|
|
83
|
-
};
|
|
84
|
-
const result = migrate_v_2_4_0(mockData);
|
|
85
|
-
expect(result.cookies).toEqual(mockData.cookies);
|
|
86
|
-
expect(result.environments).toEqual(mockData.environments);
|
|
87
|
-
expect(result.collections).toEqual(mockData.collections);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
//# sourceMappingURL=migration.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/migrations/v-2.4.0/migration.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, expectTypeOf, it } from 'vitest'\n\nimport type { v_2_3_0 } from '../v-2.3.0/types.generated'\nimport { migrate_v_2_4_0 } from './migration'\nimport type { v_2_4_0 } from './types.generated'\n\ndescribe('migrate_v_2_4_0', () => {\n it('should migrate draft collection by removing servers and updating request paths', () => {\n // Setup test data\n const mockServer: v_2_3_0.Server = {\n uid: 'server1',\n url: 'https://api.example.com',\n description: 'Test server',\n }\n\n const mockRequest: v_2_3_0.Request = {\n uid: 'request1',\n type: 'request',\n path: '/users',\n method: 'get',\n servers: ['server1'],\n selectedServerUid: 'server1',\n examples: [],\n selectedSecuritySchemeUids: [],\n }\n\n const mockDraftCollection: v_2_3_0.Collection = {\n 'uid': 'draft1',\n 'type': 'collection',\n 'info': {\n title: 'Drafts',\n version: '1.0.0',\n },\n 'openapi': '3.0.0',\n 'security': [],\n 'servers': ['server1'],\n 'selectedServerUid': '',\n 'securitySchemes': [],\n 'selectedSecuritySchemeUids': [],\n 'requests': ['request1'],\n 'tags': [],\n 'children': [],\n 'watchMode': false,\n 'watchModeStatus': 'IDLE',\n 'x-scalar-icon': 'draft',\n }\n\n const mockData: v_2_3_0.DataRecord = {\n collections: {\n draft1: mockDraftCollection,\n },\n servers: {\n server1: mockServer,\n },\n requests: {\n request1: mockRequest,\n },\n cookies: {},\n environments: {},\n requestExamples: {},\n securitySchemes: {},\n tags: {},\n workspaces: {},\n }\n\n // Perform migration\n const result = migrate_v_2_4_0(mockData)\n\n // Assertions\n expectTypeOf(result).toMatchTypeOf<v_2_4_0.DataRecord>()\n expect(result.collections.draft1?.servers).toEqual([])\n expect(result.requests.request1?.path).toBe('https://api.example.com/users')\n expect(result.requests.request1?.selectedServerUid).toBe('')\n })\n\n it('should preserve all other data properties', () => {\n // Setup test data with all properties\n const mockData: v_2_3_0.DataRecord = {\n collections: {},\n cookies: {\n cookie1: {\n uid: 'cookie1',\n name: 'test',\n value: 'value',\n sameSite: 'Lax',\n },\n },\n environments: {\n env1: { uid: 'env1', name: 'test', color: 'blue', value: 'value' },\n },\n requestExamples: {},\n requests: {},\n securitySchemes: {},\n servers: {},\n tags: {},\n workspaces: {},\n }\n\n // Perform migration\n const result = migrate_v_2_4_0(mockData)\n\n // Assertions\n expect(result.cookies).toEqual(mockData.cookies)\n expect(result.environments).toEqual(mockData.environments)\n expect(result.collections).toEqual(mockData.collections)\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,cAAc,UAAU;AAGnD,SAAS,uBAAuB;AAGhC,SAAS,mBAAmB,MAAM;AAChC,KAAG,kFAAkF,MAAM;AAEzF,UAAM,aAA6B;AAAA,MACjC,KAAK;AAAA,MACL,KAAK;AAAA,MACL,aAAa;AAAA,IACf;AAEA,UAAM,cAA+B;AAAA,MACnC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS,CAAC,SAAS;AAAA,MACnB,mBAAmB;AAAA,MACnB,UAAU,CAAC;AAAA,MACX,4BAA4B,CAAC;AAAA,IAC/B;AAEA,UAAM,sBAA0C;AAAA,MAC9C,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,QACN,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,MACX,YAAY,CAAC;AAAA,MACb,WAAW,CAAC,SAAS;AAAA,MACrB,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A,IACf;AAGA,UAAM,SAAS,gBAAgB,QAAQ;AAGvC,WAAO,OAAO,OAAO,EAAE,QAAQ,SAAS,OAAO;AAC/C,WAAO,OAAO,YAAY,EAAE,QAAQ,SAAS,YAAY;AACzD,WAAO,OAAO,WAAW,EAAE,QAAQ,SAAS,WAAW;AAAA,EACzD,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { describe, expect, expectTypeOf, it } from "vitest";
|
|
2
|
-
import { migrate_v_2_5_0 } from "./migration.js";
|
|
3
|
-
describe("migrate_v_2_5_0", () => {
|
|
4
|
-
it('should add default "Accept" header if it does not exist', () => {
|
|
5
|
-
const mockRequestExample = {
|
|
6
|
-
type: "requestExample",
|
|
7
|
-
uid: "example1",
|
|
8
|
-
requestUid: "request1",
|
|
9
|
-
name: "Example with no Accept header",
|
|
10
|
-
body: {
|
|
11
|
-
activeBody: "raw"
|
|
12
|
-
},
|
|
13
|
-
parameters: {
|
|
14
|
-
headers: [{ key: "Content-Type", value: "application/json", enabled: true }],
|
|
15
|
-
path: [],
|
|
16
|
-
query: [],
|
|
17
|
-
cookies: []
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const mockData = {
|
|
21
|
-
requestExamples: { example1: mockRequestExample },
|
|
22
|
-
collections: {},
|
|
23
|
-
cookies: {},
|
|
24
|
-
environments: {},
|
|
25
|
-
requests: {},
|
|
26
|
-
securitySchemes: {},
|
|
27
|
-
servers: {},
|
|
28
|
-
tags: {},
|
|
29
|
-
workspaces: {}
|
|
30
|
-
};
|
|
31
|
-
const result = migrate_v_2_5_0(mockData);
|
|
32
|
-
expectTypeOf(result).toMatchTypeOf();
|
|
33
|
-
expect(result.requestExamples.example1.parameters.headers[0].key).toBe("Accept");
|
|
34
|
-
expect(result.requestExamples.example1.parameters.headers[0].value).toBe("*/*");
|
|
35
|
-
});
|
|
36
|
-
it('should not add "Accept" header if it already exists', () => {
|
|
37
|
-
const mockRequestExample = {
|
|
38
|
-
type: "requestExample",
|
|
39
|
-
uid: "example2",
|
|
40
|
-
requestUid: "request2",
|
|
41
|
-
name: "Example with Accept header",
|
|
42
|
-
body: {
|
|
43
|
-
activeBody: "raw"
|
|
44
|
-
},
|
|
45
|
-
parameters: {
|
|
46
|
-
headers: [
|
|
47
|
-
{ key: "Accept", value: "application/json", enabled: true },
|
|
48
|
-
{ key: "Content-Type", value: "application/json", enabled: true }
|
|
49
|
-
],
|
|
50
|
-
path: [],
|
|
51
|
-
query: [],
|
|
52
|
-
cookies: []
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const mockData = {
|
|
56
|
-
requestExamples: { example2: mockRequestExample },
|
|
57
|
-
collections: {},
|
|
58
|
-
cookies: {},
|
|
59
|
-
environments: {},
|
|
60
|
-
requests: {},
|
|
61
|
-
securitySchemes: {},
|
|
62
|
-
servers: {},
|
|
63
|
-
tags: {},
|
|
64
|
-
workspaces: {}
|
|
65
|
-
};
|
|
66
|
-
const result = migrate_v_2_5_0(mockData);
|
|
67
|
-
expectTypeOf(result).toMatchTypeOf();
|
|
68
|
-
expect(result.requestExamples.example2.parameters.headers.length).toBe(2);
|
|
69
|
-
expect(result.requestExamples.example2.parameters.headers[0].key).toBe("Accept");
|
|
70
|
-
expect(result.requestExamples.example2.parameters.headers[0].value).toBe("application/json");
|
|
71
|
-
});
|
|
72
|
-
it("should add default selectedHttpClient to workspaces", () => {
|
|
73
|
-
const mockData = {
|
|
74
|
-
requestExamples: {},
|
|
75
|
-
collections: {},
|
|
76
|
-
cookies: {},
|
|
77
|
-
environments: {},
|
|
78
|
-
requests: {},
|
|
79
|
-
securitySchemes: {},
|
|
80
|
-
servers: {},
|
|
81
|
-
tags: {},
|
|
82
|
-
workspaces: {
|
|
83
|
-
default: {
|
|
84
|
-
uid: "default",
|
|
85
|
-
name: "Default Workspace",
|
|
86
|
-
description: "Default Workspace",
|
|
87
|
-
collections: [],
|
|
88
|
-
environments: {},
|
|
89
|
-
hotKeyConfig: {
|
|
90
|
-
modifiers: [],
|
|
91
|
-
hotKeys: {}
|
|
92
|
-
},
|
|
93
|
-
activeEnvironmentId: "default",
|
|
94
|
-
cookies: [],
|
|
95
|
-
proxyUrl: "",
|
|
96
|
-
themeId: "default"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
const result = migrate_v_2_5_0(mockData);
|
|
101
|
-
expectTypeOf(result).toMatchTypeOf();
|
|
102
|
-
expect(result.workspaces.default.selectedHttpClient).toEqual({
|
|
103
|
-
targetKey: "shell",
|
|
104
|
-
clientKey: "curl"
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
//# sourceMappingURL=migration.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/migrations/v-2.5.0/migration.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, expectTypeOf, it } from 'vitest'\n\nimport type { v_2_4_0 } from '../v-2.4.0/types.generated'\nimport { migrate_v_2_5_0 } from './migration'\nimport type { v_2_5_0 } from './types.generated'\n\ndescribe('migrate_v_2_5_0', () => {\n it('should add default \"Accept\" header if it does not exist', () => {\n // Setup test data\n const mockRequestExample: v_2_4_0.RequestExample = {\n type: 'requestExample',\n uid: 'example1',\n requestUid: 'request1',\n name: 'Example with no Accept header',\n body: {\n activeBody: 'raw',\n },\n parameters: {\n headers: [{ key: 'Content-Type', value: 'application/json', enabled: true }],\n path: [],\n query: [],\n cookies: [],\n },\n }\n\n // Perform migration\n const mockData: v_2_4_0.DataRecord = {\n requestExamples: { example1: mockRequestExample },\n collections: {},\n cookies: {},\n environments: {},\n requests: {},\n securitySchemes: {},\n servers: {},\n tags: {},\n workspaces: {},\n }\n\n // Perform migration\n const result = migrate_v_2_5_0(mockData)\n\n // Assertions\n expectTypeOf(result).toMatchTypeOf<v_2_5_0['DataRecord']>()\n expect(result.requestExamples.example1!.parameters.headers[0]!.key).toBe('Accept')\n expect(result.requestExamples.example1!.parameters.headers[0]!.value).toBe('*/*')\n })\n\n it('should not add \"Accept\" header if it already exists', () => {\n // Setup test data\n const mockRequestExample: v_2_4_0.RequestExample = {\n type: 'requestExample',\n uid: 'example2',\n requestUid: 'request2',\n name: 'Example with Accept header',\n body: {\n activeBody: 'raw',\n },\n parameters: {\n headers: [\n { key: 'Accept', value: 'application/json', enabled: true },\n { key: 'Content-Type', value: 'application/json', enabled: true },\n ],\n path: [],\n query: [],\n cookies: [],\n },\n }\n\n const mockData: v_2_4_0.DataRecord = {\n requestExamples: { example2: mockRequestExample },\n collections: {},\n cookies: {},\n environments: {},\n requests: {},\n securitySchemes: {},\n servers: {},\n tags: {},\n workspaces: {},\n }\n\n // Perform migration\n const result = migrate_v_2_5_0(mockData)\n\n // Assertions\n expectTypeOf(result).toMatchTypeOf<v_2_5_0['DataRecord']>()\n expect(result.requestExamples.example2!.parameters.headers.length).toBe(2)\n expect(result.requestExamples.example2!.parameters.headers[0]!.key).toBe('Accept')\n expect(result.requestExamples.example2!.parameters.headers[0]!.value).toBe('application/json')\n })\n\n it('should add default selectedHttpClient to workspaces', () => {\n const mockData: v_2_4_0.DataRecord = {\n requestExamples: {},\n collections: {},\n cookies: {},\n environments: {},\n requests: {},\n securitySchemes: {},\n servers: {},\n tags: {},\n workspaces: {\n default: {\n uid: 'default',\n name: 'Default Workspace',\n description: 'Default Workspace',\n collections: [],\n environments: {},\n hotKeyConfig: {\n modifiers: [],\n hotKeys: {},\n },\n activeEnvironmentId: 'default',\n cookies: [],\n proxyUrl: '',\n themeId: 'default',\n },\n },\n }\n\n // Perform migration\n const result = migrate_v_2_5_0(mockData)\n\n // Assertions\n expectTypeOf(result).toMatchTypeOf<v_2_5_0['DataRecord']>()\n expect(result.workspaces.default!.selectedHttpClient).toEqual({\n targetKey: 'shell',\n clientKey: 'curl',\n })\n })\n})\n"],
|
|
5
|
-
"mappings": "AAA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