@scalar/api-client 2.1.11 → 2.1.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 +24 -0
- package/dist/components/CommandPalette/CommandActionForm.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandActionForm.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandActionForm.vue.js +1 -1
- package/dist/components/CommandPalette/CommandActionInput.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandActionInput.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandActionInput.vue.js +27 -23
- package/dist/components/CommandPalette/CommandPaletteCollection.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPaletteCollection.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteCollection.vue.js +32 -31
- package/dist/components/CommandPalette/CommandPaletteExample.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPaletteExample.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteExample.vue.js +43 -42
- package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteImport.vue.js +26 -25
- package/dist/components/CommandPalette/CommandPaletteRequest.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPaletteRequest.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteRequest.vue.js +31 -30
- package/dist/components/CommandPalette/CommandPaletteServer.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPaletteServer.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteServer.vue.js +35 -34
- package/dist/components/CommandPalette/CommandPaletteTag.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPaletteTag.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteTag.vue.js +28 -27
- package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.js +18 -17
- package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts +14 -0
- package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/TheCommandPalette.vue.js +4 -4
- package/dist/components/CommandPalette/TheCommandPalette.vue2.js +112 -103
- package/dist/components/DataTable/DataTableInput.vue.js +2 -2
- package/dist/components/ImportCollection/DropEventListener.vue.d.ts +7 -0
- package/dist/components/ImportCollection/DropEventListener.vue.d.ts.map +1 -0
- package/dist/components/ImportCollection/DropEventListener.vue.js +75 -0
- package/dist/components/ImportCollection/DropEventListener.vue2.js +4 -0
- package/dist/components/ImportCollection/ImportCollectionListener.vue.d.ts +12 -0
- package/dist/components/ImportCollection/ImportCollectionListener.vue.d.ts.map +1 -0
- package/dist/components/ImportCollection/ImportCollectionListener.vue.js +30 -0
- package/dist/components/ImportCollection/ImportCollectionListener.vue2.js +4 -0
- package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts +20 -0
- package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts.map +1 -0
- package/dist/components/ImportCollection/ImportCollectionModal.vue.js +101 -0
- package/dist/components/ImportCollection/ImportCollectionModal.vue2.js +4 -0
- package/dist/components/ImportCollection/ImportNowButton.vue.d.ts +22 -0
- package/dist/components/ImportCollection/ImportNowButton.vue.d.ts.map +1 -0
- package/dist/components/ImportCollection/ImportNowButton.vue.js +85 -0
- package/dist/components/ImportCollection/ImportNowButton.vue2.js +4 -0
- package/dist/components/ImportCollection/OpenAppButton.vue.d.ts +16 -0
- package/dist/components/ImportCollection/OpenAppButton.vue.d.ts.map +1 -0
- package/dist/components/ImportCollection/OperationBadge.vue.d.ts +19 -0
- package/dist/components/ImportCollection/OperationBadge.vue.d.ts.map +1 -0
- package/dist/components/ImportCollection/PasteEventListener.vue.d.ts +7 -0
- package/dist/components/ImportCollection/PasteEventListener.vue.d.ts.map +1 -0
- package/dist/components/ImportCollection/PasteEventListener.vue.js +24 -0
- package/dist/components/ImportCollection/PasteEventListener.vue2.js +4 -0
- package/dist/components/ImportCollection/UrlQueryParameterChecker.vue.d.ts +7 -0
- package/dist/components/ImportCollection/UrlQueryParameterChecker.vue.d.ts.map +1 -0
- package/dist/components/ImportCollection/UrlQueryParameterChecker.vue.js +15 -0
- package/dist/components/ImportCollection/UrlQueryParameterChecker.vue2.js +4 -0
- package/dist/components/ImportCollection/hooks/useUrlPrefetcher.d.ts +28 -0
- package/dist/components/ImportCollection/hooks/useUrlPrefetcher.d.ts.map +1 -0
- package/dist/components/ImportCollection/hooks/useUrlPrefetcher.js +55 -0
- package/dist/components/ImportCollection/index.d.ts +2 -0
- package/dist/components/ImportCollection/index.d.ts.map +1 -0
- package/dist/components/ImportCollection/index.js +4 -0
- package/dist/components/ImportCollection/utils/getOpenApiDocumentVersion.d.ts +5 -0
- package/dist/components/ImportCollection/utils/getOpenApiDocumentVersion.d.ts.map +1 -0
- package/dist/components/ImportCollection/utils/getOpenApiDocumentVersion.js +20 -0
- package/dist/components/ImportCollection/utils/isDocument.d.ts +3 -0
- package/dist/components/ImportCollection/utils/isDocument.d.ts.map +1 -0
- package/dist/components/ImportCollection/utils/isDocument.js +7 -0
- package/dist/components/ImportCollection/utils/isUrl.d.ts +3 -0
- package/dist/components/ImportCollection/utils/isUrl.d.ts.map +1 -0
- package/dist/components/ImportCollection/utils/isUrl.js +6 -0
- package/dist/components/Sidebar/Actions/DeleteSidebarListElement.vue.d.ts +1 -1
- package/dist/layouts/App/ApiClientApp.vue.d.ts.map +1 -1
- package/dist/layouts/App/create-api-client-app.d.ts +129 -2
- package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
- package/dist/layouts/Modal/create-api-client-modal.d.ts +258 -4
- package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
- package/dist/libs/create-client.d.ts +130 -2
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/create-client.js +54 -41
- package/dist/libs/send-request.d.ts +37 -1
- package/dist/libs/send-request.d.ts.map +1 -1
- package/dist/libs/send-request.js +24 -19
- package/dist/store/import-spec.d.ts +128 -2
- package/dist/store/import-spec.d.ts.map +1 -1
- package/dist/store/import-spec.js +24 -23
- package/dist/store/store.d.ts +256 -4
- package/dist/store/store.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/views/Request/Request.vue.d.ts.map +1 -1
- package/dist/views/Request/Request.vue.js +1 -1
- package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebar.vue.js +1 -1
- package/dist/views/Request/RequestSidebar.vue2.js +14 -14
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/views/Request/components/WorkspaceDropdown.vue.d.ts.map +1 -1
- package/dist/views/Request/components/WorkspaceDropdown.vue.js +39 -39
- package/package.json +14 -9
|
@@ -2,26 +2,26 @@ import { loadAllResources as j } from "./local-storage.js";
|
|
|
2
2
|
import { workspaceSchema as C } from "@scalar/oas-utils/entities/workspace";
|
|
3
3
|
import { LS_KEYS as M, objectMerge as P } from "@scalar/oas-utils/helpers";
|
|
4
4
|
import { DATA_VERSION_LS_LEY as q, DATA_VERSION as K } from "@scalar/oas-utils/migrations";
|
|
5
|
-
import { createApp as L } from "vue";
|
|
6
|
-
import { createWorkspaceStore as
|
|
7
|
-
const
|
|
8
|
-
el:
|
|
9
|
-
appComponent:
|
|
5
|
+
import { createApp as L, watch as R } from "vue";
|
|
6
|
+
import { createWorkspaceStore as T } from "../store/store.js";
|
|
7
|
+
const D = ({
|
|
8
|
+
el: x,
|
|
9
|
+
appComponent: b,
|
|
10
10
|
configuration: t = {},
|
|
11
11
|
isReadOnly: c = !1,
|
|
12
12
|
persistData: I = !0,
|
|
13
|
-
mountOnInitialize:
|
|
14
|
-
router:
|
|
13
|
+
mountOnInitialize: O = !0,
|
|
14
|
+
router: d
|
|
15
15
|
}) => {
|
|
16
|
-
const
|
|
16
|
+
const s = T(d, I);
|
|
17
17
|
if (localStorage.getItem(M.WORKSPACE) && !c) {
|
|
18
18
|
const e = {};
|
|
19
|
-
let r = 0, l = 0,
|
|
20
|
-
for (
|
|
21
|
-
Object.prototype.hasOwnProperty.call(localStorage,
|
|
22
|
-
e.Total = (r / 1024).toFixed(2) + " KB", console.table(e), j(
|
|
19
|
+
let r = 0, l = 0, a = "";
|
|
20
|
+
for (a in localStorage)
|
|
21
|
+
Object.prototype.hasOwnProperty.call(localStorage, a) && (l = (localStorage[a].length + a.length) * 2, r += l, e[a] = (l / 1024).toFixed(2) + " KB");
|
|
22
|
+
e.Total = (r / 1024).toFixed(2) + " KB", console.table(e), j(s);
|
|
23
23
|
} else if (!c || !t.spec)
|
|
24
|
-
|
|
24
|
+
s.workspaceMutators.add({
|
|
25
25
|
uid: "default",
|
|
26
26
|
name: "Workspace",
|
|
27
27
|
isReadOnly: c,
|
|
@@ -34,22 +34,22 @@ const B = ({
|
|
|
34
34
|
isReadOnly: !0,
|
|
35
35
|
proxyUrl: t.proxyUrl
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
s.workspaceMutators.rawAdd(e);
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
const o = L(b);
|
|
40
|
+
o.use(d), o.provide("workspace", s);
|
|
41
41
|
const {
|
|
42
|
-
activeCollection:
|
|
42
|
+
activeCollection: p,
|
|
43
43
|
activeWorkspace: m,
|
|
44
44
|
collectionMutators: u,
|
|
45
45
|
importSpecFile: h,
|
|
46
|
-
importSpecFromUrl:
|
|
46
|
+
importSpecFromUrl: w,
|
|
47
47
|
modalState: v,
|
|
48
48
|
requests: S,
|
|
49
|
-
securitySchemes:
|
|
50
|
-
servers:
|
|
51
|
-
workspaceMutators:
|
|
52
|
-
} =
|
|
49
|
+
securitySchemes: y,
|
|
50
|
+
servers: i,
|
|
51
|
+
workspaceMutators: U
|
|
52
|
+
} = s, k = (e = x) => {
|
|
53
53
|
if (!e) {
|
|
54
54
|
console.error(
|
|
55
55
|
"[@scalar/api-client-modal] Could not create the API client.",
|
|
@@ -58,19 +58,19 @@ const B = ({
|
|
|
58
58
|
);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
o.mount(e);
|
|
62
62
|
};
|
|
63
|
-
return m.value && (
|
|
63
|
+
return m.value && (O && k(), t != null && t.proxyUrl && U.edit(
|
|
64
64
|
m.value.uid,
|
|
65
65
|
"proxyUrl",
|
|
66
66
|
t == null ? void 0 : t.proxyUrl
|
|
67
|
-
), t != null && t.themeId &&
|
|
67
|
+
), t != null && t.themeId && U.edit(
|
|
68
68
|
m.value.uid,
|
|
69
69
|
"themeId",
|
|
70
70
|
t == null ? void 0 : t.themeId
|
|
71
71
|
)), {
|
|
72
72
|
/** The vue app instance for the modal, be careful with this */
|
|
73
|
-
app:
|
|
73
|
+
app: o,
|
|
74
74
|
/** Update the API client config */
|
|
75
75
|
updateConfig(e, r = !0) {
|
|
76
76
|
r ? Object.assign(t ?? {}, e) : P(t ?? {}, e), e.spec && h(e.spec);
|
|
@@ -78,13 +78,26 @@ const B = ({
|
|
|
78
78
|
/** Update the currently selected server via URL */
|
|
79
79
|
updateServer: (e) => {
|
|
80
80
|
var l;
|
|
81
|
-
const r = Object.values(
|
|
82
|
-
r &&
|
|
83
|
-
(l =
|
|
81
|
+
const r = Object.values(i).find((a) => a.url === e);
|
|
82
|
+
r && p.value && u.edit(
|
|
83
|
+
(l = p.value) == null ? void 0 : l.uid,
|
|
84
84
|
"selectedServerUid",
|
|
85
85
|
r.uid
|
|
86
86
|
);
|
|
87
87
|
},
|
|
88
|
+
/** Update the currently selected server via URL */
|
|
89
|
+
onUpdateServer: (e) => {
|
|
90
|
+
R(
|
|
91
|
+
() => {
|
|
92
|
+
var r;
|
|
93
|
+
return (r = p.value) == null ? void 0 : r.selectedServerUid;
|
|
94
|
+
},
|
|
95
|
+
(r) => {
|
|
96
|
+
const l = Object.values(i).find((a) => a.uid === r);
|
|
97
|
+
l != null && l.url && e(l.url);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
},
|
|
88
101
|
/**
|
|
89
102
|
* Update the auth values, we currently don't change the auth selection
|
|
90
103
|
*/
|
|
@@ -93,17 +106,17 @@ const B = ({
|
|
|
93
106
|
propertyKey: r,
|
|
94
107
|
value: l
|
|
95
108
|
}) => {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
`auth.${
|
|
109
|
+
const A = Object.values(y).find((_) => _.nameKey === e);
|
|
110
|
+
A && p.value && u.edit(
|
|
111
|
+
p.value.uid,
|
|
112
|
+
`auth.${A.uid}.${r}`,
|
|
100
113
|
// @ts-expect-error why typescript why
|
|
101
114
|
l
|
|
102
115
|
);
|
|
103
116
|
},
|
|
104
117
|
/** Update the spec file, this will re-parse it and clear your store */
|
|
105
118
|
updateSpec: async (e) => {
|
|
106
|
-
e != null && e.url ? await
|
|
119
|
+
e != null && e.url ? await w(e.url, t == null ? void 0 : t.proxyUrl) : e != null && e.content ? await h(e == null ? void 0 : e.content) : console.error(
|
|
107
120
|
"[@scalar/api-client-modal] Could not create the API client.",
|
|
108
121
|
"Please provide an OpenAPI document: { spec: { url: '…' } }",
|
|
109
122
|
"Read more: https://github.com/scalar/scalar/tree/main/packages/api-client"
|
|
@@ -112,23 +125,23 @@ const B = ({
|
|
|
112
125
|
/** Route to a method + path */
|
|
113
126
|
route: (e) => {
|
|
114
127
|
const r = Object.values(S).find(
|
|
115
|
-
({ path: l, method:
|
|
128
|
+
({ path: l, method: a }) => l === e.path && a.toUpperCase() === e.method.toUpperCase()
|
|
116
129
|
);
|
|
117
|
-
r &&
|
|
130
|
+
r && d.push(`/workspace/default/request/${r.uid}`);
|
|
118
131
|
},
|
|
119
132
|
/** Open the API client modal and optionally route to a request */
|
|
120
133
|
open: (e) => {
|
|
121
134
|
if (e) {
|
|
122
135
|
const r = Object.values(S).find(
|
|
123
|
-
({ path: l, method:
|
|
136
|
+
({ path: l, method: a }) => e ? (
|
|
124
137
|
// The given operation
|
|
125
|
-
l === e.path &&
|
|
138
|
+
l === e.path && a.toUpperCase() === e.method.toUpperCase()
|
|
126
139
|
) : (
|
|
127
140
|
// Or the first request
|
|
128
141
|
!0
|
|
129
142
|
)
|
|
130
143
|
);
|
|
131
|
-
r &&
|
|
144
|
+
r && d.push(`/workspace/default/request/${r.uid}`);
|
|
132
145
|
}
|
|
133
146
|
v.open = !0;
|
|
134
147
|
},
|
|
@@ -137,9 +150,9 @@ const B = ({
|
|
|
137
150
|
/** State for controlling the modal */
|
|
138
151
|
modalState: v,
|
|
139
152
|
/* The workspace store */
|
|
140
|
-
store:
|
|
153
|
+
store: s
|
|
141
154
|
};
|
|
142
155
|
};
|
|
143
156
|
export {
|
|
144
|
-
|
|
157
|
+
D as createApiClient
|
|
145
158
|
};
|
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
import { type ErrorResponse } from '../libs/errors.js';
|
|
2
2
|
import type { Cookie } from '@scalar/oas-utils/entities/cookie';
|
|
3
|
-
import type { Collection, Request, RequestExample, ResponseInstance, SecurityScheme, Server } from '@scalar/oas-utils/entities/spec';
|
|
3
|
+
import type { Collection, Request, RequestExample, RequestMethod, ResponseInstance, SecurityScheme, Server } from '@scalar/oas-utils/entities/spec';
|
|
4
|
+
/** Decode the buffer according to its content-type */
|
|
5
|
+
export declare function decodeBuffer(buffer: ArrayBuffer, contentType: string): any;
|
|
6
|
+
/** Populate the headers from enabled parameters */
|
|
7
|
+
export declare function createFetchHeaders(example: Pick<RequestExample, 'parameters'>, env: object): Record<string, string>;
|
|
8
|
+
/** Populate the query parameters from the example */
|
|
9
|
+
export declare function createFetchQueryParams(example: Pick<RequestExample, 'parameters'>, env: object): URLSearchParams;
|
|
10
|
+
/** Set all cookie params and workspace level cookies that are applicable */
|
|
11
|
+
export declare function setRequestCookies({ example, env, globalCookies, domain, proxy, }: {
|
|
12
|
+
example: RequestExample;
|
|
13
|
+
env: object;
|
|
14
|
+
globalCookies: Cookie[];
|
|
15
|
+
domain: string;
|
|
16
|
+
proxy?: string;
|
|
17
|
+
}): {
|
|
18
|
+
cookieParams: {
|
|
19
|
+
readonly domain: string | undefined;
|
|
20
|
+
readonly sameSite: "None";
|
|
21
|
+
readonly secure: true;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Create the fetch request body from an example
|
|
26
|
+
*
|
|
27
|
+
* TODO: Should we be setting the content type headers here?
|
|
28
|
+
* If so we must allow the user to override the content type header
|
|
29
|
+
*/
|
|
30
|
+
export declare function createFetchBody(method: RequestMethod, example: RequestExample, env: object): {
|
|
31
|
+
body: URLSearchParams | FormData;
|
|
32
|
+
contentType: string;
|
|
33
|
+
} | {
|
|
34
|
+
body: string;
|
|
35
|
+
contentType: "html" | "text" | "json" | "yaml" | "xml" | "javascript" | "edn" | undefined;
|
|
36
|
+
} | {
|
|
37
|
+
body: Blob | undefined;
|
|
38
|
+
contentType: string | undefined;
|
|
39
|
+
};
|
|
4
40
|
/** Response from sendRequest hoisted so we can use it as the return type for createRequestOperation */
|
|
5
41
|
type SendRequestResponse<ResponseDataType = unknown> = Promise<ErrorResponse<{
|
|
6
42
|
response: ResponseInstance<ResponseDataType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-request.d.ts","sourceRoot":"","sources":["../../src/libs/send-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAA;AAK1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,
|
|
1
|
+
{"version":3,"file":"send-request.d.ts","sourceRoot":"","sources":["../../src/libs/send-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAA;AAK1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,MAAM,EACP,MAAM,iCAAiC,CAAA;AAUxC,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,OAkBpE;AAED,mDAAmD;AACnD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,EAC3C,GAAG,EAAE,MAAM,0BAgBZ;AAED,sDAAsD;AACtD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,EAC3C,GAAG,EAAE,MAAM,mBASZ;AAED,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,GAAG,EACH,aAAa,EACb,MAAM,EACN,KAAK,GACN,EAAE;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;;;;;;EA+DA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,MAAM;;;;;;;;;EAgDZ;AAED,uGAAuG;AACvG,KAAK,mBAAmB,CAAC,gBAAgB,GAAG,OAAO,IAAI,OAAO,CAC5D,aAAa,CAAC;IACZ,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAC,CACH,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,gBAAgB,qGASpD;IACD,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,cAAc,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC/C,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB,KAAG,aAAa,CAAC;IAChB,UAAU,EAAE,eAAe,CAAA;IAC3B,WAAW,EAAE,MAAM,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;CACzD,CA2LA,CAAA"}
|
|
@@ -17,7 +17,7 @@ function K(s, n) {
|
|
|
17
17
|
function _(s, n) {
|
|
18
18
|
const o = {};
|
|
19
19
|
return s.parameters.headers.forEach((t) => {
|
|
20
|
-
const c = t.key.toLowerCase();
|
|
20
|
+
const c = t.key.trim().toLowerCase();
|
|
21
21
|
t.enabled && (c !== "content-type" || t.value !== "multipart/form-data") && (o[c] = u(t.value, n));
|
|
22
22
|
}), o;
|
|
23
23
|
}
|
|
@@ -52,15 +52,15 @@ function N({
|
|
|
52
52
|
e.enabled && k.set(e.key, u(e.value, n));
|
|
53
53
|
}), o.forEach((e) => {
|
|
54
54
|
var i;
|
|
55
|
-
const { name: R, value: U, ...
|
|
56
|
-
(
|
|
55
|
+
const { name: R, value: U, ...m } = e;
|
|
56
|
+
(m.domain === t || ((i = m.domain) == null ? void 0 : i.startsWith(".")) && t.endsWith(m.domain ?? "")) && k.set(R, U, {
|
|
57
57
|
/** Override the domain with the proxy value */
|
|
58
58
|
domain: d,
|
|
59
59
|
// TODO: path cookies probably don't worth with the proxy
|
|
60
|
-
path:
|
|
61
|
-
expires:
|
|
62
|
-
httpOnly:
|
|
63
|
-
secure:
|
|
60
|
+
path: m.path,
|
|
61
|
+
expires: m.expires ? new Date(m.expires) : void 0,
|
|
62
|
+
httpOnly: m.httpOnly,
|
|
63
|
+
secure: m.secure
|
|
64
64
|
});
|
|
65
65
|
}), {
|
|
66
66
|
cookieParams: l
|
|
@@ -98,8 +98,8 @@ const te = ({
|
|
|
98
98
|
globalCookies: f
|
|
99
99
|
}) => {
|
|
100
100
|
try {
|
|
101
|
-
const e = l ?? {}, R = new AbortController(), U = o.parameters.path.reduce((p, a) => (a.enabled && (p[a.key] = u(a.value, e)), p), {}),
|
|
102
|
-
let i =
|
|
101
|
+
const e = l ?? {}, R = new AbortController(), U = o.parameters.path.reduce((p, a) => (a.enabled && (p[a.key] = u(a.value, e)), p), {}), m = u((t == null ? void 0 : t.url) ?? "", e), y = u(s.path, U);
|
|
102
|
+
let i = m || y;
|
|
103
103
|
if (!i) throw T.URL_EMPTY;
|
|
104
104
|
const P = j(o, e), w = _(o, e), { body: C } = Q(s.method, o, e), { cookieParams: V } = N({
|
|
105
105
|
example: o,
|
|
@@ -109,21 +109,21 @@ const te = ({
|
|
|
109
109
|
proxy: d
|
|
110
110
|
});
|
|
111
111
|
return s.selectedSecuritySchemeUids.forEach((p) => {
|
|
112
|
-
const a = n[p],
|
|
113
|
-
if (!(!a || !
|
|
114
|
-
if (
|
|
112
|
+
const a = n[p], h = c[p];
|
|
113
|
+
if (!(!a || !h)) {
|
|
114
|
+
if (h.type === "apiKey" && a.type === "apiKey") {
|
|
115
115
|
const r = u(a.value, e);
|
|
116
|
-
|
|
116
|
+
h.in === "header" && (w[a.name] = r), h.in === "query" && P.append(a.name, r), h.in === "cookie" && k.set(a.name, r);
|
|
117
117
|
}
|
|
118
|
-
if (
|
|
119
|
-
if (
|
|
118
|
+
if (h.type === "http" && a.type === "http")
|
|
119
|
+
if (h.scheme === "basic") {
|
|
120
120
|
const r = u(a.username, e), g = u(a.password, e), D = g ? `${r}:${g}` : r;
|
|
121
121
|
w.Authorization = `Basic ${btoa(D)}`;
|
|
122
122
|
} else {
|
|
123
123
|
const r = u(a.token, e);
|
|
124
124
|
w.Authorization = `Bearer ${r}`;
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
h.type === "oauth2" && a.type.includes("oauth") && "token" in a && (a.token || console.error("OAuth token was not created"), w.Authorization = `Bearer ${a.token}`);
|
|
127
127
|
}
|
|
128
128
|
}), [
|
|
129
129
|
null,
|
|
@@ -140,9 +140,9 @@ const te = ({
|
|
|
140
140
|
...P
|
|
141
141
|
]).toString(), i = S.toString();
|
|
142
142
|
}
|
|
143
|
-
const a = new URLSearchParams([["scalar_url", i.toString()]]),
|
|
143
|
+
const a = new URLSearchParams([["scalar_url", i.toString()]]), h = B(d, i) ? `${d}?${a.toString()}` : i, r = await fetch(h, {
|
|
144
144
|
signal: R.signal,
|
|
145
|
-
method: s.method,
|
|
145
|
+
method: s.method.toUpperCase(),
|
|
146
146
|
body: C,
|
|
147
147
|
headers: w
|
|
148
148
|
});
|
|
@@ -183,5 +183,10 @@ const te = ({
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
export {
|
|
186
|
-
|
|
186
|
+
Q as createFetchBody,
|
|
187
|
+
_ as createFetchHeaders,
|
|
188
|
+
j as createFetchQueryParams,
|
|
189
|
+
te as createRequestOperation,
|
|
190
|
+
K as decodeBuffer,
|
|
191
|
+
N as setRequestCookies
|
|
187
192
|
};
|
|
@@ -3,7 +3,133 @@ import type { StoreContext } from '../store/store-context';
|
|
|
3
3
|
import type { Spec } from '@scalar/types/legacy';
|
|
4
4
|
/** Generate the import functions from a store context */
|
|
5
5
|
export declare function importSpecFileFactory({ requestMutators, collectionMutators, serverMutators, tagMutators, securitySchemeMutators, requestExampleMutators, workspaceMutators, workspaces, }: StoreContext): {
|
|
6
|
-
importSpecFile: (_spec: string | Record<string, any>, workspaceUid?: string, overloadServers?: Spec["servers"], preferredSecurityScheme?: ClientConfiguration["preferredSecurityScheme"]) => Promise<
|
|
7
|
-
|
|
6
|
+
importSpecFile: (_spec: string | Record<string, any>, workspaceUid?: string, overloadServers?: Spec["servers"], preferredSecurityScheme?: ClientConfiguration["preferredSecurityScheme"]) => Promise<{
|
|
7
|
+
type: "collection";
|
|
8
|
+
uid: string;
|
|
9
|
+
children: string[];
|
|
10
|
+
openapi: string;
|
|
11
|
+
security: Record<string, string[]>[];
|
|
12
|
+
'x-scalar-icon': string;
|
|
13
|
+
securitySchemes: string[];
|
|
14
|
+
selectedServerUid: string;
|
|
15
|
+
servers: string[];
|
|
16
|
+
requests: string[];
|
|
17
|
+
tags: string[];
|
|
18
|
+
auth: Record<string, {
|
|
19
|
+
type: "apiKey";
|
|
20
|
+
value: string;
|
|
21
|
+
name: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: "http";
|
|
24
|
+
username: string;
|
|
25
|
+
password: string;
|
|
26
|
+
token: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: "oauth-implicit";
|
|
29
|
+
token: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "oauth-password";
|
|
32
|
+
username: string;
|
|
33
|
+
password: string;
|
|
34
|
+
token: string;
|
|
35
|
+
clientSecret: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "oauth-clientCredentials";
|
|
38
|
+
token: string;
|
|
39
|
+
clientSecret: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: "oauth-authorizationCode";
|
|
42
|
+
token: string;
|
|
43
|
+
clientSecret: string;
|
|
44
|
+
}>;
|
|
45
|
+
externalDocs?: {
|
|
46
|
+
url: string;
|
|
47
|
+
description?: string | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
jsonSchemaDialect?: string | undefined;
|
|
50
|
+
info?: {
|
|
51
|
+
title: string;
|
|
52
|
+
version: string;
|
|
53
|
+
description?: string | undefined;
|
|
54
|
+
summary?: string | undefined;
|
|
55
|
+
termsOfService?: string | undefined;
|
|
56
|
+
contact?: {
|
|
57
|
+
name?: string | undefined;
|
|
58
|
+
url?: string | undefined;
|
|
59
|
+
email?: string | undefined;
|
|
60
|
+
} | undefined;
|
|
61
|
+
license?: {
|
|
62
|
+
name: string;
|
|
63
|
+
identifier?: string | undefined;
|
|
64
|
+
url?: string | undefined;
|
|
65
|
+
} | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
components?: Record<string, unknown> | undefined;
|
|
68
|
+
webhooks?: Record<string, unknown> | undefined;
|
|
69
|
+
} | undefined>;
|
|
70
|
+
importSpecFromUrl: (url: string, proxy?: string, overloadServers?: Spec["servers"], preferredSecurityScheme?: ClientConfiguration["preferredSecurityScheme"], workspaceUid?: string) => Promise<{
|
|
71
|
+
type: "collection";
|
|
72
|
+
uid: string;
|
|
73
|
+
children: string[];
|
|
74
|
+
openapi: string;
|
|
75
|
+
security: Record<string, string[]>[];
|
|
76
|
+
'x-scalar-icon': string;
|
|
77
|
+
securitySchemes: string[];
|
|
78
|
+
selectedServerUid: string;
|
|
79
|
+
servers: string[];
|
|
80
|
+
requests: string[];
|
|
81
|
+
tags: string[];
|
|
82
|
+
auth: Record<string, {
|
|
83
|
+
type: "apiKey";
|
|
84
|
+
value: string;
|
|
85
|
+
name: string;
|
|
86
|
+
} | {
|
|
87
|
+
type: "http";
|
|
88
|
+
username: string;
|
|
89
|
+
password: string;
|
|
90
|
+
token: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: "oauth-implicit";
|
|
93
|
+
token: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: "oauth-password";
|
|
96
|
+
username: string;
|
|
97
|
+
password: string;
|
|
98
|
+
token: string;
|
|
99
|
+
clientSecret: string;
|
|
100
|
+
} | {
|
|
101
|
+
type: "oauth-clientCredentials";
|
|
102
|
+
token: string;
|
|
103
|
+
clientSecret: string;
|
|
104
|
+
} | {
|
|
105
|
+
type: "oauth-authorizationCode";
|
|
106
|
+
token: string;
|
|
107
|
+
clientSecret: string;
|
|
108
|
+
}>;
|
|
109
|
+
externalDocs?: {
|
|
110
|
+
url: string;
|
|
111
|
+
description?: string | undefined;
|
|
112
|
+
} | undefined;
|
|
113
|
+
jsonSchemaDialect?: string | undefined;
|
|
114
|
+
info?: {
|
|
115
|
+
title: string;
|
|
116
|
+
version: string;
|
|
117
|
+
description?: string | undefined;
|
|
118
|
+
summary?: string | undefined;
|
|
119
|
+
termsOfService?: string | undefined;
|
|
120
|
+
contact?: {
|
|
121
|
+
name?: string | undefined;
|
|
122
|
+
url?: string | undefined;
|
|
123
|
+
email?: string | undefined;
|
|
124
|
+
} | undefined;
|
|
125
|
+
license?: {
|
|
126
|
+
name: string;
|
|
127
|
+
identifier?: string | undefined;
|
|
128
|
+
url?: string | undefined;
|
|
129
|
+
} | undefined;
|
|
130
|
+
} | undefined;
|
|
131
|
+
components?: Record<string, unknown> | undefined;
|
|
132
|
+
webhooks?: Record<string, unknown> | undefined;
|
|
133
|
+
} | undefined>;
|
|
8
134
|
};
|
|
9
135
|
//# sourceMappingURL=import-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/store/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAGhD,yDAAyD;AACzD,wBAAgB,qBAAqB,CAAC,EACpC,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,GACX,EAAE,YAAY;4BAEJ,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/store/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAGhD,yDAAyD;AACzD,wBAAgB,qBAAqB,CAAC,EACpC,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,GACX,EAAE,YAAY;4BAEJ,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,2CAQjB,IAAI,CAAC,SAAS,CAAC,4BACP,mBAAmB,CAAC,yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAsE81W,CAAC;;;;;;uBAAqK,CAAC;mBAAqC,CAAC;0BAA4C,CAAC;mBAAqC,CAAC;oBAAoB,CAAC;mBAAqC,CAAC;qBAAuC,CAAC;;mBAA4D,CAAC;;0BAAoD,CAAC;mBAAqC,CAAC;;;;;;6BA3B57X,MAAM,UACH,MAAM,oBACI,IAAI,CAAC,SAAS,CAAC,4BACP,mBAAmB,CAAC,yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAwB81W,CAAC;;;;;;uBAAqK,CAAC;mBAAqC,CAAC;0BAA4C,CAAC;mBAAqC,CAAC;oBAAoB,CAAC;mBAAqC,CAAC;qBAAuC,CAAC;;mBAA4D,CAAC;;0BAAoD,CAAC;mBAAqC,CAAC;;;;;;EADp8X"}
|
|
@@ -4,43 +4,44 @@ import { toRaw as g } from "vue";
|
|
|
4
4
|
function S({
|
|
5
5
|
requestMutators: p,
|
|
6
6
|
collectionMutators: f,
|
|
7
|
-
serverMutators:
|
|
8
|
-
tagMutators:
|
|
7
|
+
serverMutators: l,
|
|
8
|
+
tagMutators: m,
|
|
9
9
|
securitySchemeMutators: d,
|
|
10
|
-
requestExampleMutators:
|
|
11
|
-
workspaceMutators:
|
|
10
|
+
requestExampleMutators: u,
|
|
11
|
+
workspaceMutators: h,
|
|
12
12
|
workspaces: E
|
|
13
13
|
}) {
|
|
14
|
-
const a = async (i, e = "default",
|
|
14
|
+
const a = async (i, e = "default", c, n) => {
|
|
15
15
|
var s;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
16
|
+
const r = g(i);
|
|
17
|
+
c != null && c.length && typeof r == "object" && (r.servers = c);
|
|
18
|
+
const o = await R(
|
|
19
|
+
r,
|
|
20
20
|
n
|
|
21
21
|
);
|
|
22
|
-
if (
|
|
23
|
-
console.group("IMPORT ERRORS"),
|
|
22
|
+
if (o.error) {
|
|
23
|
+
console.group("IMPORT ERRORS"), o.importWarnings.forEach((t) => console.warn(t)), console.groupEnd();
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
), f.add(
|
|
26
|
+
return o.examples.forEach((t) => u.add(t)), o.requests.forEach((t) => p.add(t)), o.tags.forEach((t) => m.add(t)), o.servers.forEach((t) => l.add(t)), o.securitySchemes.forEach(
|
|
27
|
+
(t) => d.add(t)
|
|
28
|
+
), f.add(o.collection), h.edit(e, "collections", [
|
|
29
29
|
...((s = E[e]) == null ? void 0 : s.collections) ?? [],
|
|
30
|
-
|
|
31
|
-
]);
|
|
30
|
+
o.collection.uid
|
|
31
|
+
]), o.collection;
|
|
32
32
|
};
|
|
33
|
-
async function y(i, e,
|
|
33
|
+
async function y(i, e, c, n, r = "default") {
|
|
34
34
|
try {
|
|
35
|
-
const
|
|
36
|
-
await a(
|
|
37
|
-
|
|
38
|
-
void 0,
|
|
35
|
+
const o = await F(i, e);
|
|
36
|
+
return await a(
|
|
37
|
+
o,
|
|
39
38
|
r,
|
|
39
|
+
c,
|
|
40
40
|
n
|
|
41
41
|
);
|
|
42
|
-
} catch (
|
|
43
|
-
console.error("Failed to fetch spec from URL:",
|
|
42
|
+
} catch (o) {
|
|
43
|
+
console.error("Failed to fetch spec from URL:", o);
|
|
44
|
+
return;
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
return {
|