@scalar/api-client 2.22.3 → 2.23.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/style.css +1 -1
  3. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
  4. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  5. package/dist/v2/features/app/App.vue.js +111 -85
  6. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  7. package/dist/v2/features/app/app-state.js +115 -114
  8. package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
  9. package/dist/v2/features/app/helpers/routes.js +31 -25
  10. package/dist/v2/features/import-listener/ImportListener.vue.d.ts +52 -0
  11. package/dist/v2/features/import-listener/ImportListener.vue.d.ts.map +1 -0
  12. package/dist/v2/features/import-listener/ImportListener.vue.js +91 -0
  13. package/dist/v2/features/import-listener/ImportListener.vue2.js +4 -0
  14. package/dist/v2/features/import-listener/components/DropEventListener.vue.d.ts +7 -0
  15. package/dist/v2/features/import-listener/components/DropEventListener.vue.d.ts.map +1 -0
  16. package/dist/v2/features/import-listener/components/DropEventListener.vue.js +81 -0
  17. package/dist/v2/features/import-listener/components/DropEventListener.vue2.js +4 -0
  18. package/dist/v2/features/import-listener/components/ImportModal.vue.d.ts +40 -0
  19. package/dist/v2/features/import-listener/components/ImportModal.vue.d.ts.map +1 -0
  20. package/dist/v2/features/import-listener/components/ImportModal.vue.js +170 -0
  21. package/dist/v2/features/import-listener/components/ImportModal.vue3.js +5 -0
  22. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.d.ts +29 -0
  23. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.d.ts.map +1 -0
  24. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue.js +83 -0
  25. package/dist/v2/features/import-listener/components/WorkspaceSelector.vue2.js +4 -0
  26. package/dist/v2/features/import-listener/helpers/generate-unique-slug.d.ts +16 -0
  27. package/dist/v2/features/import-listener/helpers/generate-unique-slug.d.ts.map +1 -0
  28. package/dist/v2/features/import-listener/helpers/generate-unique-slug.js +11 -0
  29. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.d.ts +8 -0
  30. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.d.ts.map +1 -0
  31. package/dist/v2/features/import-listener/helpers/get-url-query-parameter.js +4 -0
  32. package/dist/v2/features/import-listener/helpers/import-document-to-workspace.d.ts +30 -0
  33. package/dist/v2/features/import-listener/helpers/import-document-to-workspace.d.ts.map +1 -0
  34. package/dist/v2/features/import-listener/helpers/import-document-to-workspace.js +31 -0
  35. package/dist/v2/features/import-listener/helpers/load-document-from-source.d.ts +15 -0
  36. package/dist/v2/features/import-listener/helpers/load-document-from-source.d.ts.map +1 -0
  37. package/dist/v2/features/import-listener/helpers/load-document-from-source.js +28 -0
  38. package/dist/v2/features/import-listener/helpers/wait-for-condition.d.ts +15 -0
  39. package/dist/v2/features/import-listener/helpers/wait-for-condition.d.ts.map +1 -0
  40. package/dist/v2/features/import-listener/helpers/wait-for-condition.js +16 -0
  41. package/dist/v2/features/import-listener/index.d.ts +2 -0
  42. package/dist/v2/features/import-listener/index.d.ts.map +1 -0
  43. package/dist/v2/features/import-listener/index.js +4 -0
  44. package/dist/v2/features/operation/Operation.vue.js +1 -1
  45. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  46. package/package.json +13 -8
@@ -0,0 +1,31 @@
1
+ import { generateUniqueSlug as u } from "./generate-unique-slug.js";
2
+ const m = async ({
3
+ workspaceStore: t,
4
+ workspaceState: o,
5
+ name: n
6
+ }) => {
7
+ if (!t)
8
+ return { ok: !1, error: "Workspace store is not available" };
9
+ const r = o.documents[n];
10
+ if (!r)
11
+ return { ok: !1, error: "Importing document not found in workspace state" };
12
+ const i = new Set(Object.keys(t.workspace.documents)), e = await u(r.info.title || "default", i);
13
+ return e ? (t.loadWorkspace({
14
+ meta: {},
15
+ documents: {
16
+ [e]: r
17
+ },
18
+ intermediateDocuments: {
19
+ [e]: o.intermediateDocuments[n] ?? {}
20
+ },
21
+ originalDocuments: {
22
+ [e]: o.originalDocuments[n] ?? {}
23
+ },
24
+ overrides: {
25
+ [e]: o.overrides[n] ?? {}
26
+ }
27
+ }), t.buildSidebar(e), await t.saveDocument(e), { ok: !0, slug: e }) : { ok: !1, error: "Failed to generate a unique slug for the importing document" };
28
+ };
29
+ export {
30
+ m as importDocumentToWorkspace
31
+ };
@@ -0,0 +1,15 @@
1
+ import type { WorkspaceStore } from '@scalar/workspace-store/client';
2
+ /**
3
+ * Loads a document from a given source (URL or raw content) and adds it to the workspace.
4
+ *
5
+ * - If the source is a URL, adds the document from the URL and enables/disables watch mode as requested.
6
+ * - If the source is raw content (like pasted JSON/YAML), normalizes and adds it as a document.
7
+ *
8
+ * @param workspaceStore The workspace store to add the document to
9
+ * @param source The source to load the document from (URL or raw content)
10
+ * @param name The name of the document
11
+ * @param watchMode Whether to enable watch mode for URL sources
12
+ * @returns Promise resolving to true if the document is added successfully, false otherwise
13
+ */
14
+ export declare const loadDocumentFromSource: (workspaceStore: WorkspaceStore, source: string | null, name: string, watchMode: boolean) => Promise<boolean>;
15
+ //# sourceMappingURL=load-document-from-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-document-from-source.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/import-listener/helpers/load-document-from-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAIpE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GACjC,gBAAgB,cAAc,EAC9B,QAAQ,MAAM,GAAG,IAAI,EACrB,MAAM,MAAM,EACZ,WAAW,OAAO,KACjB,OAAO,CAAC,OAAO,CAqCjB,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { normalize as m } from "@scalar/openapi-parser";
2
+ import { isUrl as i } from "../../../helpers/is-url.js";
3
+ const f = async (r, t, n, o) => {
4
+ if (!t)
5
+ return !1;
6
+ if (i(t))
7
+ return await r.addDocument({
8
+ name: n,
9
+ url: t,
10
+ meta: {
11
+ "x-scalar-watch-mode": o
12
+ }
13
+ });
14
+ const e = ((a) => {
15
+ try {
16
+ return m(a);
17
+ } catch (l) {
18
+ return console.error(l), null;
19
+ }
20
+ })(t);
21
+ return e === null ? !1 : await r.addDocument({
22
+ name: n,
23
+ document: e
24
+ });
25
+ };
26
+ export {
27
+ f as loadDocumentFromSource
28
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Waits for a condition to be true with a timeout.
3
+ * Checks the condition at a specified interval up to a maximum wait time.
4
+ *
5
+ * @param checkCondition - Function that returns true when the condition is met
6
+ * @param options - Configuration options
7
+ * @param options.checkInterval - Time in milliseconds between checks (default: 100)
8
+ * @param options.maxWaitTime - Maximum time in milliseconds to wait (default: 3000)
9
+ * @returns Promise that resolves to true if the condition is met, false if it timed out
10
+ */
11
+ export declare const waitForCondition: (checkCondition: () => boolean, options?: {
12
+ checkInterval?: number;
13
+ maxWaitTime?: number;
14
+ }) => Promise<boolean>;
15
+ //# sourceMappingURL=wait-for-condition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-for-condition.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/import-listener/helpers/wait-for-condition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAC3B,gBAAgB,MAAM,OAAO,EAC7B,UAAS;IACP,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;CAChB,KACL,OAAO,CAAC,OAAO,CAuBjB,CAAA"}
@@ -0,0 +1,16 @@
1
+ const s = (t, l = {}) => {
2
+ const { checkInterval: r = 100, maxWaitTime: i = 3e3 } = l;
3
+ return new Promise((e) => {
4
+ if (t()) {
5
+ e(!0);
6
+ return;
7
+ }
8
+ let a = 0;
9
+ const n = setInterval(() => {
10
+ a += r, t() ? (clearInterval(n), e(!0)) : a >= i && (clearInterval(n), e(!1));
11
+ }, r);
12
+ });
13
+ };
14
+ export {
15
+ s as waitForCondition
16
+ };
@@ -0,0 +1,2 @@
1
+ export { default as ImportListener } from './ImportListener.vue.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/import-listener/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { default as t } from "./ImportListener.vue.js";
2
+ export {
3
+ t as ImportListener
4
+ };
@@ -69,7 +69,7 @@ const b = {
69
69
  type: "document"
70
70
  }), h = n(
71
71
  () => C(o(e.options)?.hiddenClients)
72
- ), f = "2.22.3";
72
+ ), f = "2.23.0";
73
73
  return (t, a) => e.path && e.method && e.exampleName && l.value ? (c(), x(i(p), {
74
74
  key: 0,
75
75
  appVersion: i(f),
@@ -33,7 +33,7 @@ const W = { class: "flex-center relative flex flex-1 flex-col gap-6 p-2 capitali
33
33
  }));
34
34
  }, f = (u) => {
35
35
  u?.createNew && g.name === "request" && p();
36
- }, v = "2.22.3";
36
+ }, v = "2.23.0";
37
37
  return q(() => a.hotKeys.on(f)), R(() => a.hotKeys.off(f)), (u, e) => (l(), n("div", W, [
38
38
  s("div", {
39
39
  class: y(["flex h-[calc(100%_-_50px)] flex-col items-center justify-center", {
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.22.3",
21
+ "version": "2.23.0",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -231,6 +231,11 @@
231
231
  "types": "./dist/v2/features/global-cookies/index.d.ts",
232
232
  "default": "./dist/v2/features/global-cookies/index.js"
233
233
  },
234
+ "./v2/features/import-listener": {
235
+ "import": "./dist/v2/features/import-listener/index.js",
236
+ "types": "./dist/v2/features/import-listener/index.d.ts",
237
+ "default": "./dist/v2/features/import-listener/index.js"
238
+ },
234
239
  "./v2/features/modal": {
235
240
  "import": "./dist/v2/features/modal/index.js",
236
241
  "types": "./dist/v2/features/modal/index.d.ts",
@@ -321,26 +326,26 @@
321
326
  "whatwg-mimetype": "4.0.0",
322
327
  "yaml": "^2.8.0",
323
328
  "zod": "^4.3.5",
324
- "@scalar/components": "0.17.2",
325
329
  "@scalar/analytics-client": "1.0.1",
326
330
  "@scalar/draggable": "0.3.0",
327
- "@scalar/import": "0.4.47",
331
+ "@scalar/components": "0.17.2",
332
+ "@scalar/helpers": "0.2.10",
328
333
  "@scalar/icons": "0.5.2",
329
334
  "@scalar/json-magic": "0.9.5",
330
335
  "@scalar/oas-utils": "0.6.32",
331
- "@scalar/openapi-parser": "0.24.6",
332
336
  "@scalar/object-utils": "1.2.24",
337
+ "@scalar/import": "0.4.47",
338
+ "@scalar/openapi-parser": "0.24.6",
333
339
  "@scalar/openapi-types": "0.5.3",
334
- "@scalar/postman-to-openapi": "0.4.2",
335
340
  "@scalar/sidebar": "0.7.25",
336
341
  "@scalar/snippetz": "0.6.10",
337
342
  "@scalar/themes": "0.14.0",
338
- "@scalar/use-codemirror": "0.13.29",
339
343
  "@scalar/types": "0.6.1",
344
+ "@scalar/postman-to-openapi": "0.4.2",
345
+ "@scalar/use-codemirror": "0.13.29",
340
346
  "@scalar/use-hooks": "0.3.7",
341
347
  "@scalar/use-toasts": "0.9.1",
342
- "@scalar/workspace-store": "0.28.1",
343
- "@scalar/helpers": "0.2.10"
348
+ "@scalar/workspace-store": "0.28.1"
344
349
  },
345
350
  "devDependencies": {
346
351
  "@tailwindcss/vite": "^4.1.18",