@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.
Files changed (103) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/CommandPalette/CommandActionForm.vue.d.ts +2 -0
  3. package/dist/components/CommandPalette/CommandActionForm.vue.d.ts.map +1 -1
  4. package/dist/components/CommandPalette/CommandActionForm.vue.js +1 -1
  5. package/dist/components/CommandPalette/CommandActionInput.vue.d.ts +2 -0
  6. package/dist/components/CommandPalette/CommandActionInput.vue.d.ts.map +1 -1
  7. package/dist/components/CommandPalette/CommandActionInput.vue.js +27 -23
  8. package/dist/components/CommandPalette/CommandPaletteCollection.vue.d.ts +2 -0
  9. package/dist/components/CommandPalette/CommandPaletteCollection.vue.d.ts.map +1 -1
  10. package/dist/components/CommandPalette/CommandPaletteCollection.vue.js +32 -31
  11. package/dist/components/CommandPalette/CommandPaletteExample.vue.d.ts +2 -0
  12. package/dist/components/CommandPalette/CommandPaletteExample.vue.d.ts.map +1 -1
  13. package/dist/components/CommandPalette/CommandPaletteExample.vue.js +43 -42
  14. package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts +2 -0
  15. package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
  16. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +26 -25
  17. package/dist/components/CommandPalette/CommandPaletteRequest.vue.d.ts +2 -0
  18. package/dist/components/CommandPalette/CommandPaletteRequest.vue.d.ts.map +1 -1
  19. package/dist/components/CommandPalette/CommandPaletteRequest.vue.js +31 -30
  20. package/dist/components/CommandPalette/CommandPaletteServer.vue.d.ts +2 -0
  21. package/dist/components/CommandPalette/CommandPaletteServer.vue.d.ts.map +1 -1
  22. package/dist/components/CommandPalette/CommandPaletteServer.vue.js +35 -34
  23. package/dist/components/CommandPalette/CommandPaletteTag.vue.d.ts +2 -0
  24. package/dist/components/CommandPalette/CommandPaletteTag.vue.d.ts.map +1 -1
  25. package/dist/components/CommandPalette/CommandPaletteTag.vue.js +28 -27
  26. package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.d.ts +2 -0
  27. package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.d.ts.map +1 -1
  28. package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.js +18 -17
  29. package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts +14 -0
  30. package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts.map +1 -1
  31. package/dist/components/CommandPalette/TheCommandPalette.vue.js +4 -4
  32. package/dist/components/CommandPalette/TheCommandPalette.vue2.js +112 -103
  33. package/dist/components/DataTable/DataTableInput.vue.js +2 -2
  34. package/dist/components/ImportCollection/DropEventListener.vue.d.ts +7 -0
  35. package/dist/components/ImportCollection/DropEventListener.vue.d.ts.map +1 -0
  36. package/dist/components/ImportCollection/DropEventListener.vue.js +75 -0
  37. package/dist/components/ImportCollection/DropEventListener.vue2.js +4 -0
  38. package/dist/components/ImportCollection/ImportCollectionListener.vue.d.ts +12 -0
  39. package/dist/components/ImportCollection/ImportCollectionListener.vue.d.ts.map +1 -0
  40. package/dist/components/ImportCollection/ImportCollectionListener.vue.js +30 -0
  41. package/dist/components/ImportCollection/ImportCollectionListener.vue2.js +4 -0
  42. package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts +20 -0
  43. package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts.map +1 -0
  44. package/dist/components/ImportCollection/ImportCollectionModal.vue.js +101 -0
  45. package/dist/components/ImportCollection/ImportCollectionModal.vue2.js +4 -0
  46. package/dist/components/ImportCollection/ImportNowButton.vue.d.ts +22 -0
  47. package/dist/components/ImportCollection/ImportNowButton.vue.d.ts.map +1 -0
  48. package/dist/components/ImportCollection/ImportNowButton.vue.js +85 -0
  49. package/dist/components/ImportCollection/ImportNowButton.vue2.js +4 -0
  50. package/dist/components/ImportCollection/OpenAppButton.vue.d.ts +16 -0
  51. package/dist/components/ImportCollection/OpenAppButton.vue.d.ts.map +1 -0
  52. package/dist/components/ImportCollection/OperationBadge.vue.d.ts +19 -0
  53. package/dist/components/ImportCollection/OperationBadge.vue.d.ts.map +1 -0
  54. package/dist/components/ImportCollection/PasteEventListener.vue.d.ts +7 -0
  55. package/dist/components/ImportCollection/PasteEventListener.vue.d.ts.map +1 -0
  56. package/dist/components/ImportCollection/PasteEventListener.vue.js +24 -0
  57. package/dist/components/ImportCollection/PasteEventListener.vue2.js +4 -0
  58. package/dist/components/ImportCollection/UrlQueryParameterChecker.vue.d.ts +7 -0
  59. package/dist/components/ImportCollection/UrlQueryParameterChecker.vue.d.ts.map +1 -0
  60. package/dist/components/ImportCollection/UrlQueryParameterChecker.vue.js +15 -0
  61. package/dist/components/ImportCollection/UrlQueryParameterChecker.vue2.js +4 -0
  62. package/dist/components/ImportCollection/hooks/useUrlPrefetcher.d.ts +28 -0
  63. package/dist/components/ImportCollection/hooks/useUrlPrefetcher.d.ts.map +1 -0
  64. package/dist/components/ImportCollection/hooks/useUrlPrefetcher.js +55 -0
  65. package/dist/components/ImportCollection/index.d.ts +2 -0
  66. package/dist/components/ImportCollection/index.d.ts.map +1 -0
  67. package/dist/components/ImportCollection/index.js +4 -0
  68. package/dist/components/ImportCollection/utils/getOpenApiDocumentVersion.d.ts +5 -0
  69. package/dist/components/ImportCollection/utils/getOpenApiDocumentVersion.d.ts.map +1 -0
  70. package/dist/components/ImportCollection/utils/getOpenApiDocumentVersion.js +20 -0
  71. package/dist/components/ImportCollection/utils/isDocument.d.ts +3 -0
  72. package/dist/components/ImportCollection/utils/isDocument.d.ts.map +1 -0
  73. package/dist/components/ImportCollection/utils/isDocument.js +7 -0
  74. package/dist/components/ImportCollection/utils/isUrl.d.ts +3 -0
  75. package/dist/components/ImportCollection/utils/isUrl.d.ts.map +1 -0
  76. package/dist/components/ImportCollection/utils/isUrl.js +6 -0
  77. package/dist/components/Sidebar/Actions/DeleteSidebarListElement.vue.d.ts +1 -1
  78. package/dist/layouts/App/ApiClientApp.vue.d.ts.map +1 -1
  79. package/dist/layouts/App/create-api-client-app.d.ts +129 -2
  80. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  81. package/dist/layouts/Modal/create-api-client-modal.d.ts +258 -4
  82. package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
  83. package/dist/libs/create-client.d.ts +130 -2
  84. package/dist/libs/create-client.d.ts.map +1 -1
  85. package/dist/libs/create-client.js +54 -41
  86. package/dist/libs/send-request.d.ts +37 -1
  87. package/dist/libs/send-request.d.ts.map +1 -1
  88. package/dist/libs/send-request.js +24 -19
  89. package/dist/store/import-spec.d.ts +128 -2
  90. package/dist/store/import-spec.d.ts.map +1 -1
  91. package/dist/store/import-spec.js +24 -23
  92. package/dist/store/store.d.ts +256 -4
  93. package/dist/store/store.d.ts.map +1 -1
  94. package/dist/style.css +1 -1
  95. package/dist/views/Request/Request.vue.d.ts.map +1 -1
  96. package/dist/views/Request/Request.vue.js +1 -1
  97. package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
  98. package/dist/views/Request/RequestSidebar.vue.js +1 -1
  99. package/dist/views/Request/RequestSidebar.vue2.js +14 -14
  100. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  101. package/dist/views/Request/components/WorkspaceDropdown.vue.d.ts.map +1 -1
  102. package/dist/views/Request/components/WorkspaceDropdown.vue.js +39 -39
  103. 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 R } from "../store/store.js";
7
- const B = ({
8
- el: A,
9
- appComponent: x,
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: b = !0,
14
- router: p
13
+ mountOnInitialize: O = !0,
14
+ router: d
15
15
  }) => {
16
- const a = R(p, I);
16
+ const s = T(d, I);
17
17
  if (localStorage.getItem(M.WORKSPACE) && !c) {
18
18
  const e = {};
19
- let r = 0, l = 0, s = "";
20
- for (s in localStorage)
21
- Object.prototype.hasOwnProperty.call(localStorage, s) && (l = (localStorage[s].length + s.length) * 2, r += l, e[s] = (l / 1024).toFixed(2) + " KB");
22
- e.Total = (r / 1024).toFixed(2) + " KB", console.table(e), j(a);
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
- a.workspaceMutators.add({
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
- a.workspaceMutators.rawAdd(e);
37
+ s.workspaceMutators.rawAdd(e);
38
38
  }
39
- const d = L(x);
40
- d.use(p), d.provide("workspace", a);
39
+ const o = L(b);
40
+ o.use(d), o.provide("workspace", s);
41
41
  const {
42
- activeCollection: o,
42
+ activeCollection: p,
43
43
  activeWorkspace: m,
44
44
  collectionMutators: u,
45
45
  importSpecFile: h,
46
- importSpecFromUrl: y,
46
+ importSpecFromUrl: w,
47
47
  modalState: v,
48
48
  requests: S,
49
- securitySchemes: O,
50
- servers: w,
51
- workspaceMutators: i
52
- } = a, k = (e = A) => {
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
- d.mount(e);
61
+ o.mount(e);
62
62
  };
63
- return m.value && (b && k(), t != null && t.proxyUrl && i.edit(
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 && i.edit(
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: d,
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(w).find((s) => s.url === e);
82
- r && o.value && u.edit(
83
- (l = o.value) == null ? void 0 : l.uid,
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 U = Object.values(O).find((_) => _.nameKey === e);
97
- U && o.value && u.edit(
98
- o.value.uid,
99
- `auth.${U.uid}.${r}`,
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 y(e.url, t == null ? void 0 : t.proxyUrl) : e != null && e.content ? await h(e == null ? void 0 : e.content) : console.error(
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: s }) => l === e.path && s.toUpperCase() === e.method.toUpperCase()
128
+ ({ path: l, method: a }) => l === e.path && a.toUpperCase() === e.method.toUpperCase()
116
129
  );
117
- r && p.push(`/workspace/default/request/${r.uid}`);
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: s }) => e ? (
136
+ ({ path: l, method: a }) => e ? (
124
137
  // The given operation
125
- l === e.path && s.toUpperCase() === e.method.toUpperCase()
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 && p.push(`/workspace/default/request/${r.uid}`);
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: a
153
+ store: s
141
154
  };
142
155
  };
143
156
  export {
144
- B as createApiClient
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,EAEd,gBAAgB,EAChB,cAAc,EACd,MAAM,EACP,MAAM,iCAAiC,CAAA;AAqMxC,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"}
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, ...h } = e;
56
- (h.domain === t || ((i = h.domain) == null ? void 0 : i.startsWith(".")) && t.endsWith(h.domain ?? "")) && k.set(R, U, {
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: h.path,
61
- expires: h.expires ? new Date(h.expires) : void 0,
62
- httpOnly: h.httpOnly,
63
- secure: h.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), {}), h = u((t == null ? void 0 : t.url) ?? "", e), y = u(s.path, U);
102
- let i = h || y;
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], m = c[p];
113
- if (!(!a || !m)) {
114
- if (m.type === "apiKey" && a.type === "apiKey") {
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
- m.in === "header" && (w[a.name] = r), m.in === "query" && P.append(a.name, r), m.in === "cookie" && k.set(a.name, r);
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 (m.type === "http" && a.type === "http")
119
- if (m.scheme === "basic") {
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
- m.type === "oauth2" && a.type.includes("oauth") && "token" in a && (a.token || console.error("OAuth token was not created"), w.Authorization = `Bearer ${a.token}`);
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()]]), m = B(d, i) ? `${d}?${a.toString()}` : i, r = await fetch(m, {
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
- te as createRequestOperation
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<void>;
7
- importSpecFromUrl: (url: string, proxy?: string, overloadServers?: Spec["servers"], preferredSecurityScheme?: ClientConfiguration["preferredSecurityScheme"]) => Promise<void>;
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,2CAOjB,IAAI,CAAC,SAAS,CAAC,4BACP,mBAAmB,CAAC,yBAAyB,CAAC;6BAyCnE,MAAM,UACH,MAAM,oBACI,IAAI,CAAC,SAAS,CAAC,4BACP,mBAAmB,CAAC,yBAAyB,CAAC;EAmB3E"}
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: m,
8
- tagMutators: l,
7
+ serverMutators: l,
8
+ tagMutators: m,
9
9
  securitySchemeMutators: d,
10
- requestExampleMutators: h,
11
- workspaceMutators: u,
10
+ requestExampleMutators: u,
11
+ workspaceMutators: h,
12
12
  workspaces: E
13
13
  }) {
14
- const a = async (i, e = "default", r, n) => {
14
+ const a = async (i, e = "default", c, n) => {
15
15
  var s;
16
- const t = g(i);
17
- r != null && r.length && typeof t == "object" && (t.servers = r);
18
- const c = await R(
19
- t,
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 (c.error) {
23
- console.group("IMPORT ERRORS"), c.importWarnings.forEach((o) => console.warn(o)), console.groupEnd();
22
+ if (o.error) {
23
+ console.group("IMPORT ERRORS"), o.importWarnings.forEach((t) => console.warn(t)), console.groupEnd();
24
24
  return;
25
25
  }
26
- c.examples.forEach((o) => h.add(o)), c.requests.forEach((o) => p.add(o)), c.tags.forEach((o) => l.add(o)), c.servers.forEach((o) => m.add(o)), c.securitySchemes.forEach(
27
- (o) => d.add(o)
28
- ), f.add(c.collection), u.edit(e, "collections", [
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
- c.collection.uid
31
- ]);
30
+ o.collection.uid
31
+ ]), o.collection;
32
32
  };
33
- async function y(i, e, r, n) {
33
+ async function y(i, e, c, n, r = "default") {
34
34
  try {
35
- const t = await F(i, e);
36
- await a(
37
- t,
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 (t) {
43
- console.error("Failed to fetch spec from URL:", t);
42
+ } catch (o) {
43
+ console.error("Failed to fetch spec from URL:", o);
44
+ return;
44
45
  }
45
46
  }
46
47
  return {