@scalar/api-client 2.2.7 → 2.2.8

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/api-client
2
2
 
3
+ ## 2.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - f2ec59d: feat: add postman import
8
+
3
9
  ## 2.2.7
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandPaletteImport.vue"],"names":[],"mappings":";;;;;;;AA+mBA,wBAOG"}
1
+ {"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPalette/CommandPaletteImport.vue"],"names":[],"mappings":";;;;;;;AA2pBA,wBAOG"}
@@ -1,42 +1,44 @@
1
- import { defineComponent as $, ref as U, computed as k, watch as _, openBlock as a, createBlock as h, unref as r, withCtx as u, createElementVNode as f, createVNode as g, createTextVNode as c, createElementBlock as s, Fragment as d, toDisplayString as A, createCommentVNode as z } from "vue";
2
- import { useActiveEntities as B } from "../../store/active-entities.js";
3
- import { useLoadingState as N, ScalarButton as O, ScalarIcon as j, ScalarTooltip as E, ScalarCodeBlock as W } from "@scalar/components";
4
- import { useToasts as J } from "@scalar/use-toasts";
5
- import Y from "./CommandActionForm.vue.js";
6
- import q from "./CommandActionInput.vue.js";
7
- import G from "./WatchModeToggle.vue.js";
8
- import { getOpenApiDocumentDetails as H } from "../../libs/getOpenApiDocumentDetails.js";
9
- import { isUrl as w } from "../../libs/isUrl.js";
10
- import { useFileDialog as K } from "../../hooks/useFileDialog.js";
11
- import { useWorkspace as Q } from "../../store/store.js";
12
- const X = { class: "flex justify-between" }, Z = { class: "flex flex-row items-center justify-between gap-3 w-full" }, ee = { class: "grid gap-1.5 pointer-events-none max-w-[320px] w-content shadow-lg rounded bg-b-1 z-100 p-2 text-xxs leading-5 z-10 text-c-1" }, te = { class: "flex items-center text-c-2" }, oe = {
1
+ import { defineComponent as B, ref as _, computed as k, watch as A, openBlock as a, createBlock as C, unref as s, withCtx as c, createElementVNode as g, createVNode as y, createTextVNode as m, createElementBlock as r, Fragment as p, toDisplayString as O, createCommentVNode as N } from "vue";
2
+ import { useActiveEntities as j } from "../../store/active-entities.js";
3
+ import { useLoadingState as E, ScalarButton as D, ScalarIcon as W, ScalarTooltip as J, ScalarCodeBlock as Y } from "@scalar/components";
4
+ import { useToasts as q } from "@scalar/use-toasts";
5
+ import G from "./CommandActionForm.vue.js";
6
+ import H from "./CommandActionInput.vue.js";
7
+ import K from "./WatchModeToggle.vue.js";
8
+ import { isPostmanCollection as S, getPostmanDocumentDetails as Q, convertPostmanToOpenApi as L } from "../../libs/postman.js";
9
+ import { getOpenApiDocumentDetails as X } from "../../libs/getOpenApiDocumentDetails.js";
10
+ import { isUrl as b } from "../../libs/isUrl.js";
11
+ import { useFileDialog as Z } from "../../hooks/useFileDialog.js";
12
+ import { useWorkspace as ee } from "../../store/store.js";
13
+ const te = { class: "flex justify-between" }, oe = { class: "flex flex-row items-center justify-between gap-3 w-full" }, ae = { class: "grid gap-1.5 pointer-events-none max-w-[320px] w-content shadow-lg rounded bg-b-1 z-100 p-2 text-xxs leading-5 z-10 text-c-1" }, le = { class: "flex items-center text-c-2" }, ne = {
13
14
  key: 0,
14
15
  class: "text-pretty"
15
- }, ae = {
16
+ }, se = {
16
17
  key: 1,
17
18
  class: "text-pretty"
18
- }, ge = /* @__PURE__ */ $({
19
+ }, ke = /* @__PURE__ */ B({
19
20
  __name: "CommandPaletteImport",
20
21
  emits: ["close", "back"],
21
- setup(le, { emit: L }) {
22
- const b = L, { activeWorkspace: y } = B(), { importSpecFile: I, importSpecFromUrl: V } = Q(), { toast: m } = J(), i = N(), o = U(""), p = U(!0), l = k(
23
- () => H(o.value)
24
- ), S = k(
22
+ setup(re, { emit: V }) {
23
+ const h = V, { activeWorkspace: d } = j(), { importSpecFile: x, importSpecFromUrl: R } = ee(), { toast: i } = q(), u = E(), t = _(""), v = _(!0), l = k(() => S(t.value) ? Q(t.value) : X(t.value)), U = k(
25
24
  () => l.value ? l.value.type : "json"
26
- ), v = k(() => w(o.value)), P = k(() => !!l.value), { open: R } = K({
27
- onChange: async (t) => {
28
- const e = t == null ? void 0 : t[0];
25
+ ), f = k(() => b(t.value)), F = k(() => !!l.value), { open: T } = Z({
26
+ onChange: async (o) => {
27
+ const e = o == null ? void 0 : o[0];
29
28
  if (e) {
30
29
  const n = new FileReader();
31
- n.onload = async (F) => {
32
- var C;
33
- const M = (C = F.target) == null ? void 0 : C.result;
30
+ n.onload = async ($) => {
31
+ var P;
32
+ const I = (P = $.target) == null ? void 0 : P.result;
34
33
  try {
35
- await I(M, y.value.uid), m("Import successful", "info"), b("close");
36
- } catch (x) {
37
- console.error(x);
38
- const T = (x == null ? void 0 : x.message) || "Unknown error";
39
- m(`Import failed: ${T}`, "error");
34
+ S(I) ? await x(
35
+ await L(I),
36
+ d.value.uid
37
+ ) : await x(I, d.value.uid), i("Import successful", "info"), h("close");
38
+ } catch (w) {
39
+ console.error(w);
40
+ const z = (w == null ? void 0 : w.message) || "Unknown error";
41
+ i(`Import failed: ${z}`, "error");
40
42
  }
41
43
  }, n.readAsText(e);
42
44
  }
@@ -44,64 +46,64 @@ const X = { class: "flex justify-between" }, Z = { class: "flex flex-row items-c
44
46
  multiple: !1,
45
47
  accept: ".json,.yaml,.yml"
46
48
  });
47
- _(v, (t) => {
48
- t || (p.value = !1);
49
- }), _(o, (t) => {
50
- w(t) || (p.value = !1);
49
+ A(f, (o) => {
50
+ o || (v.value = !1);
51
+ }), A(t, (o) => {
52
+ b(o) || (v.value = !1);
51
53
  });
52
- async function D() {
53
- if (!(!o.value || i.isLoading)) {
54
- i.startLoading();
54
+ async function M() {
55
+ if (!(!t.value || u.isLoading)) {
56
+ u.startLoading();
55
57
  try {
56
- if (v.value) {
57
- const [t] = await V(
58
- o.value,
59
- y.value.uid,
58
+ if (f.value) {
59
+ const [o] = await R(
60
+ t.value,
61
+ d.value.uid,
60
62
  {
61
- proxyUrl: y.value.proxyUrl,
62
- watchMode: p.value
63
+ proxyUrl: d.value.proxyUrl,
64
+ watchMode: v.value
63
65
  }
64
66
  );
65
- if (t) {
66
- m(
67
+ if (o) {
68
+ i(
67
69
  "There was a possible CORS error while importing your spec, please make sure this server is allowed in the CORS policy of your OpenAPI document.",
68
70
  "error",
69
71
  { timeout: 5e3 }
70
- ), i.invalidate(2e3, !0);
72
+ ), u.invalidate(2e3, !0);
71
73
  return;
72
74
  }
73
- } else if (P.value)
74
- await I(
75
- String(o.value),
76
- y.value.uid
77
- );
75
+ } else if (F.value)
76
+ S(t.value) ? (await x(
77
+ await L(t.value),
78
+ d.value.uid
79
+ ), i("Successfully converted Postman collection", "info")) : await x(t.value, d.value.uid);
78
80
  else {
79
- m("Import failed: Invalid URL or OpenAPI document", "error"), i.invalidate(2e3, !0);
81
+ i("Import failed: Invalid URL or OpenAPI document", "error"), u.invalidate(2e3, !0);
80
82
  return;
81
83
  }
82
- i.clear(), b("close"), m("Import successful", "info");
83
- } catch (t) {
84
- console.error("[importCollection]", t);
85
- const e = (t == null ? void 0 : t.message) || "Unknown error";
86
- i.invalidate(2e3, !0), m(`Import failed: ${e}`, "error");
84
+ u.clear(), h("close"), i("Import successful", "info");
85
+ } catch (o) {
86
+ console.error("[importCollection]", o);
87
+ const e = (o == null ? void 0 : o.message) || "Unknown error";
88
+ u.invalidate(2e3, !0), i(`Import failed: ${e}`, "error");
87
89
  }
88
90
  }
89
91
  }
90
- return (t, e) => (a(), h(Y, {
91
- disabled: !o.value.trim(),
92
- loading: r(i),
93
- onSubmit: D
92
+ return (o, e) => (a(), C(G, {
93
+ disabled: !t.value.trim(),
94
+ loading: s(u),
95
+ onSubmit: M
94
96
  }, {
95
- options: u(() => [
96
- f("div", Z, [
97
- g(r(O), {
97
+ options: c(() => [
98
+ g("div", oe, [
99
+ y(s(D), {
98
100
  class: "p-2 max-h-8 gap-1.5 text-xs hover:bg-b-2 relative",
99
101
  variant: "outlined",
100
- onClick: r(R)
102
+ onClick: s(T)
101
103
  }, {
102
- default: u(() => [
103
- e[6] || (e[6] = c(" JSON, or YAML File ")),
104
- g(r(j), {
104
+ default: c(() => [
105
+ e[6] || (e[6] = m(" JSON, or YAML File ")),
106
+ y(s(W), {
105
107
  class: "text-c-3",
106
108
  icon: "UploadSimple",
107
109
  size: "md"
@@ -109,23 +111,23 @@ const X = { class: "flex justify-between" }, Z = { class: "flex flex-row items-c
109
111
  ]),
110
112
  _: 1
111
113
  }, 8, ["onClick"]),
112
- g(r(E), {
114
+ y(s(J), {
113
115
  as: "div",
114
116
  class: "z-[10001]",
115
117
  side: "bottom",
116
118
  sideOffset: 5
117
119
  }, {
118
- trigger: u(() => [
119
- g(G, {
120
- modelValue: p.value,
121
- "onUpdate:modelValue": e[3] || (e[3] = (n) => p.value = n),
122
- disabled: !v.value
120
+ trigger: c(() => [
121
+ y(K, {
122
+ modelValue: v.value,
123
+ "onUpdate:modelValue": e[3] || (e[3] = (n) => v.value = n),
124
+ disabled: !f.value
123
125
  }, null, 8, ["modelValue", "disabled"])
124
126
  ]),
125
- content: u(() => [
126
- f("div", ee, [
127
- f("div", te, [
128
- v.value ? (a(), s("span", oe, " Automatically updates the API client when the OpenAPI URL content changes, ensuring your client remains up-to-date. ")) : (a(), s("span", ae, " Watch Mode is only available for URL imports. It automatically updates the API client when the OpenAPI URL content changes. "))
127
+ content: c(() => [
128
+ g("div", ae, [
129
+ g("div", le, [
130
+ f.value ? (a(), r("span", ne, " Automatically updates the API client when the OpenAPI URL content changes, ensuring your client remains up-to-date. ")) : (a(), r("span", se, " Watch Mode is only available for URL imports. It automatically updates the API client when the OpenAPI URL content changes. "))
129
131
  ])
130
132
  ])
131
133
  ]),
@@ -133,48 +135,48 @@ const X = { class: "flex justify-between" }, Z = { class: "flex flex-row items-c
133
135
  })
134
136
  ])
135
137
  ]),
136
- submit: u(() => [
137
- e[7] || (e[7] = c(" Import ")),
138
- v.value ? (a(), s(d, { key: 0 }, [
139
- c(" from URL ")
140
- ], 64)) : l.value && S.value ? (a(), s(d, { key: 1 }, [
141
- l.value.title ? (a(), s(d, { key: 0 }, [
142
- c(' "' + A(l.value.title) + '" ', 1)
143
- ], 64)) : (a(), s(d, { key: 1 }, [
144
- c(A(l.value.version) + " Spec", 1)
138
+ submit: c(() => [
139
+ e[7] || (e[7] = m(" Import ")),
140
+ f.value ? (a(), r(p, { key: 0 }, [
141
+ m(" from URL ")
142
+ ], 64)) : l.value && U.value ? (a(), r(p, { key: 1 }, [
143
+ l.value.title ? (a(), r(p, { key: 0 }, [
144
+ m(' "' + O(l.value.title) + '" ', 1)
145
+ ], 64)) : (a(), r(p, { key: 1 }, [
146
+ m(O(l.value.version) + " Spec", 1)
145
147
  ], 64))
146
- ], 64)) : (a(), s(d, { key: 2 }, [
147
- c("Collection")
148
+ ], 64)) : (a(), r(p, { key: 2 }, [
149
+ m("Collection")
148
150
  ], 64))
149
151
  ]),
150
- default: u(() => [
151
- !l.value || r(w)(o.value) ? (a(), h(q, {
152
+ default: c(() => [
153
+ !l.value || s(b)(t.value) ? (a(), C(H, {
152
154
  key: 0,
153
- modelValue: o.value,
154
- "onUpdate:modelValue": e[0] || (e[0] = (n) => o.value = n),
155
- placeholder: "OpenAPI/Swagger URL or document",
156
- onOnDelete: e[1] || (e[1] = (n) => b("back", n))
157
- }, null, 8, ["modelValue"])) : (a(), s(d, { key: 1 }, [
158
- f("div", X, [
159
- e[5] || (e[5] = f("div", { class: "pl-8 text-xs min-h-8 py-2 text-c-2" }, "Preview", -1)),
160
- g(r(O), {
155
+ modelValue: t.value,
156
+ "onUpdate:modelValue": e[0] || (e[0] = (n) => t.value = n),
157
+ placeholder: "OpenAPI/Swagger/Postman URL or document",
158
+ onOnDelete: e[1] || (e[1] = (n) => h("back", n))
159
+ }, null, 8, ["modelValue"])) : (a(), r(p, { key: 1 }, [
160
+ g("div", te, [
161
+ e[5] || (e[5] = g("div", { class: "pl-8 text-xs min-h-8 py-2 text-c-2" }, "Preview", -1)),
162
+ y(s(D), {
161
163
  class: "ml-auto p-2 max-h-8 gap-1.5 text-xs hover:bg-b-2 relative",
162
164
  variant: "ghost",
163
- onClick: e[2] || (e[2] = (n) => o.value = "")
165
+ onClick: e[2] || (e[2] = (n) => t.value = "")
164
166
  }, {
165
- default: u(() => e[4] || (e[4] = [
166
- c(" Clear ")
167
+ default: c(() => e[4] || (e[4] = [
168
+ m(" Clear ")
167
169
  ])),
168
170
  _: 1
169
171
  })
170
172
  ]),
171
- l.value && !r(w)(o.value) ? (a(), h(r(W), {
173
+ l.value && !s(b)(t.value) ? (a(), C(s(Y), {
172
174
  key: 0,
173
175
  class: "border max-h-[40dvh] mt-1 bg-b-2 rounded [--scalar-small:--scalar-font-size-4]",
174
- content: o.value,
176
+ content: t.value,
175
177
  copy: !1,
176
- lang: S.value
177
- }, null, 8, ["content", "lang"])) : z("", !0)
178
+ lang: U.value
179
+ }, null, 8, ["content", "lang"])) : N("", !0)
178
180
  ], 64))
179
181
  ]),
180
182
  _: 1
@@ -182,5 +184,5 @@ const X = { class: "flex justify-between" }, Z = { class: "flex flex-row items-c
182
184
  }
183
185
  });
184
186
  export {
185
- ge as default
187
+ ke as default
186
188
  };
@@ -6,7 +6,7 @@
6
6
  declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
7
7
  export default _default;
8
8
  export declare const PaletteComponents: {
9
- readonly 'Import from OpenAPI/Swagger': import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
9
+ readonly 'Import from OpenAPI/Swagger/Postman': import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
10
10
  close: () => any;
11
11
  back: (e: KeyboardEvent) => any;
12
12
  }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
@@ -2,8 +2,8 @@ import o from "./TheCommandPalette.vue2.js";
2
2
  import { PaletteComponents as s } from "./TheCommandPalette.vue2.js";
3
3
  /* empty css */
4
4
  import t from "../../_virtual/_plugin-vue_export-helper.js";
5
- const r = /* @__PURE__ */ t(o, [["__scopeId", "data-v-a44888ad"]]);
5
+ const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-c09436db"]]);
6
6
  export {
7
7
  s as PaletteComponents,
8
- r as default
8
+ a as default
9
9
  };
@@ -1,5 +1,5 @@
1
- import { defineComponent as q, ref as i, computed as T, watch as F, onMounted as G, onBeforeUnmount as Q, openBlock as a, createBlock as z, unref as r, withCtx as y, createElementVNode as u, createVNode as p, createTextVNode as K, createElementBlock as m, withDirectives as M, withKeys as w, withModifiers as g, vModelText as j, Fragment as A, renderList as B, toDisplayString as N, vShow as J, normalizeClass as X, createCommentVNode as Y, resolveDynamicComponent as Z, mergeProps as ee, nextTick as V } from "vue";
2
- import { useModal as oe, ScalarIcon as S } from "@scalar/components";
1
+ import { defineComponent as q, ref as i, computed as T, watch as F, onMounted as G, onBeforeUnmount as Q, openBlock as a, createBlock as z, unref as r, withCtx as y, createElementVNode as u, createVNode as p, createTextVNode as K, createElementBlock as m, withDirectives as M, withKeys as w, withModifiers as g, vModelText as j, Fragment as P, renderList as B, toDisplayString as N, vShow as J, normalizeClass as X, createCommentVNode as Y, resolveDynamicComponent as Z, mergeProps as ee, nextTick as V } from "vue";
2
+ import { useModal as oe, ScalarIcon as A } from "@scalar/components";
3
3
  import { Dialog as te, DialogPanel as ne, DialogTitle as ae } from "@headlessui/vue";
4
4
  import { useRouter as le } from "vue-router";
5
5
  import { ROUTES as se } from "../../constants.js";
@@ -24,7 +24,7 @@ const he = {
24
24
  }, we = {
25
25
  name: "TheCommandPalette"
26
26
  }, ge = {
27
- "Import from OpenAPI/Swagger": ie,
27
+ "Import from OpenAPI/Swagger/Postman": ie,
28
28
  "Create Request": ue,
29
29
  "Create Workspace": fe,
30
30
  "Add Tag": pe,
@@ -33,8 +33,8 @@ const he = {
33
33
  "Add Example": ce
34
34
  }, Ve = /* @__PURE__ */ q({
35
35
  ...we,
36
- setup(Ae) {
37
- const P = [
36
+ setup(Pe) {
37
+ const S = [
38
38
  {
39
39
  label: "",
40
40
  commands: [
@@ -43,7 +43,7 @@ const he = {
43
43
  icon: "ExternalLink"
44
44
  },
45
45
  {
46
- name: "Import from OpenAPI/Swagger",
46
+ name: "Import from OpenAPI/Swagger/Postman",
47
47
  icon: "Import"
48
48
  },
49
49
  {
@@ -92,7 +92,7 @@ const he = {
92
92
  }))
93
93
  }
94
94
  ], d = oe(), { push: W } = le(), { activeWorkspace: H } = re(), { events: f } = ve(), x = i(), l = i(""), s = i(null), c = i(-1), D = i([]), v = T(
95
- () => P.reduce((e, o) => {
95
+ () => S.reduce((e, o) => {
96
96
  const t = o.commands.filter(
97
97
  (n) => n.name.toLowerCase().includes(l.value.toLowerCase())
98
98
  );
@@ -164,7 +164,7 @@ const he = {
164
164
  type: "button",
165
165
  onClick: o[3] || (o[3] = (t) => s.value = null)
166
166
  }, [
167
- p(r(S), {
167
+ p(r(A), {
168
168
  icon: "ChevronLeft",
169
169
  size: "md",
170
170
  thickness: "1.5"
@@ -177,7 +177,7 @@ const he = {
177
177
  ])) : (a(), m("div", he, [
178
178
  u("div", Ce, [
179
179
  u("label", xe, [
180
- p(r(S), {
180
+ p(r(A), {
181
181
  class: "text-c-2 mr-2.5",
182
182
  icon: "Search",
183
183
  size: "md",
@@ -203,7 +203,7 @@ const he = {
203
203
  [j, l.value]
204
204
  ])
205
205
  ]),
206
- (a(), m(A, null, B(P, (t) => (a(), m(A, {
206
+ (a(), m(P, null, B(S, (t) => (a(), m(P, {
207
207
  key: t.label
208
208
  }, [
209
209
  M(u("div", { class: "text-c-3 font-medium text-xs px-2 mb-1 mt-2" }, N(t.label), 513), [
@@ -214,7 +214,7 @@ const he = {
214
214
  ).length > 0
215
215
  ]
216
216
  ]),
217
- (a(!0), m(A, null, B(t.commands.filter(
217
+ (a(!0), m(P, null, B(t.commands.filter(
218
218
  (n) => n.name.toLowerCase().includes(l.value.toLowerCase())
219
219
  ), (n, C) => {
220
220
  var L;
@@ -229,7 +229,7 @@ const he = {
229
229
  }]),
230
230
  onClick: (b) => $(n)
231
231
  }, [
232
- p(r(S), {
232
+ p(r(A), {
233
233
  class: "text-c-2 mr-2.5",
234
234
  icon: n.icon,
235
235
  size: "md",
@@ -11,4 +11,5 @@ export * from './environment-parser.js';
11
11
  export * from './isUrl.js';
12
12
  export * from './getOpenApiDocumentDetails.js';
13
13
  export * from './parse-curl.js';
14
+ export * from './postman.js';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/libs/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA;AACvB,cAAc,6BAA6B,CAAA;AAC3C,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/libs/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA;AACvB,cAAc,6BAA6B,CAAA;AAC3C,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA"}
@@ -1,37 +1,41 @@
1
1
  import { createApiClient as o } from "./create-client.js";
2
2
  import { formatBytes as a, formatMs as m } from "./formatters.js";
3
- import { ERRORS as p, normalizeError as f, prettyErrorMessage as c } from "./errors.js";
4
- import { DEFAULT_HOTKEYS as x, getModifiers as l, handleHotKeyDown as n } from "./hot-keys.js";
3
+ import { ERRORS as p, normalizeError as f, prettyErrorMessage as n } from "./errors.js";
4
+ import { DEFAULT_HOTKEYS as c, getModifiers as l, handleHotKeyDown as x } from "./hot-keys.js";
5
5
  import { createEventBus as u } from "./event-bus.js";
6
- import { formatHeaderKey as y, normalizeHeaders as R } from "./normalize-headers.js";
7
- import { loadAllResources as h } from "./local-storage.js";
8
- import { parseEnvVariables as B } from "./environment-parser.js";
9
- import { isUrl as D } from "./isUrl.js";
10
- import { getOpenApiDocumentDetails as O } from "./getOpenApiDocumentDetails.js";
11
- import { parseCurlCommand as K } from "./parse-curl.js";
12
- import { createFetchBody as q, createFetchHeaders as v, createFetchQueryParams as z, createRequestOperation as S, decodeBuffer as T, setRequestCookies as U } from "./send-request/send-request.js";
6
+ import { formatHeaderKey as y, normalizeHeaders as D } from "./normalize-headers.js";
7
+ import { loadAllResources as A } from "./local-storage.js";
8
+ import { parseEnvVariables as H } from "./environment-parser.js";
9
+ import { isUrl as g } from "./isUrl.js";
10
+ import { getOpenApiDocumentDetails as B } from "./getOpenApiDocumentDetails.js";
11
+ import { parseCurlCommand as P } from "./parse-curl.js";
12
+ import { convertPostmanToOpenApi as K, getPostmanDocumentDetails as M, isPostmanCollection as T } from "./postman.js";
13
+ import { createFetchBody as z, createFetchHeaders as S, createFetchQueryParams as U, createRequestOperation as b, decodeBuffer as k, setRequestCookies as w } from "./send-request/send-request.js";
13
14
  export {
14
- x as DEFAULT_HOTKEYS,
15
+ c as DEFAULT_HOTKEYS,
15
16
  p as ERRORS,
17
+ K as convertPostmanToOpenApi,
16
18
  o as createApiClient,
17
19
  u as createEventBus,
18
- q as createFetchBody,
19
- v as createFetchHeaders,
20
- z as createFetchQueryParams,
21
- S as createRequestOperation,
22
- T as decodeBuffer,
20
+ z as createFetchBody,
21
+ S as createFetchHeaders,
22
+ U as createFetchQueryParams,
23
+ b as createRequestOperation,
24
+ k as decodeBuffer,
23
25
  a as formatBytes,
24
26
  y as formatHeaderKey,
25
27
  m as formatMs,
26
28
  l as getModifiers,
27
- O as getOpenApiDocumentDetails,
28
- n as handleHotKeyDown,
29
- D as isUrl,
30
- h as loadAllResources,
29
+ B as getOpenApiDocumentDetails,
30
+ M as getPostmanDocumentDetails,
31
+ x as handleHotKeyDown,
32
+ T as isPostmanCollection,
33
+ g as isUrl,
34
+ A as loadAllResources,
31
35
  f as normalizeError,
32
- R as normalizeHeaders,
33
- K as parseCurlCommand,
34
- B as parseEnvVariables,
35
- c as prettyErrorMessage,
36
- U as setRequestCookies
36
+ D as normalizeHeaders,
37
+ P as parseCurlCommand,
38
+ H as parseEnvVariables,
39
+ n as prettyErrorMessage,
40
+ w as setRequestCookies
37
41
  };
@@ -0,0 +1,11 @@
1
+ /** Checks if the given content is a Postman collection */
2
+ export declare function isPostmanCollection(content: string): boolean;
3
+ /** Converts a Postman collection JSON string to an OpenAPI JSON string */
4
+ export declare function convertPostmanToOpenApi(postmanJson: string): Promise<string>;
5
+ /** Extracts details from a Postman collection JSON string */
6
+ export declare function getPostmanDocumentDetails(content: string): {
7
+ type: string;
8
+ title: string;
9
+ version: string;
10
+ } | null;
11
+ //# sourceMappingURL=postman.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postman.d.ts","sourceRoot":"","sources":["../../src/libs/postman.ts"],"names":[],"mappings":"AAEA,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAU5D;AAED,0EAA0E;AAC1E,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,6DAA6D;AAC7D,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,IAAI,CAcP"}
@@ -0,0 +1,39 @@
1
+ import { convert as e } from "@scalar/postman-to-openapi";
2
+ function s(t) {
3
+ var n, o;
4
+ try {
5
+ const r = JSON.parse(t);
6
+ return ((n = r.info) == null ? void 0 : n._postman_id) !== void 0 && new URL((o = r.info) == null ? void 0 : o.schema).host === "schema.getpostman.com";
7
+ } catch {
8
+ return !1;
9
+ }
10
+ }
11
+ async function a(t) {
12
+ try {
13
+ const n = JSON.parse(t), o = e(n);
14
+ return JSON.stringify(o, null, 2);
15
+ } catch {
16
+ throw new Error("Failed to convert Postman collection to OpenAPI");
17
+ }
18
+ }
19
+ function l(t) {
20
+ var n, o;
21
+ try {
22
+ if (s(t)) {
23
+ const r = JSON.parse(t);
24
+ return {
25
+ type: "json",
26
+ title: ((n = r.info) == null ? void 0 : n.name) || "Postman Collection",
27
+ version: ((o = r.info) == null ? void 0 : o.version) || "1.0"
28
+ };
29
+ }
30
+ return null;
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+ export {
36
+ a as convertPostmanToOpenApi,
37
+ l as getPostmanDocumentDetails,
38
+ s as isPostmanCollection
39
+ };