@scalar/pre-post-request-scripts 0.3.9
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 +1132 -0
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +9 -0
- package/dist/components/ViewLayout/ValueEmitter.vue.d.ts +32 -0
- package/dist/components/ViewLayout/ValueEmitter.vue.d.ts.map +1 -0
- package/dist/components/ViewLayout/ValueEmitter.vue.js +21 -0
- package/dist/components/ViewLayout/ValueEmitter.vue2.js +4 -0
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.d.ts +44 -0
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.d.ts.map +1 -0
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js +89 -0
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue2.js +4 -0
- package/dist/components/ViewLayout/index.d.ts +2 -0
- package/dist/components/ViewLayout/index.d.ts.map +1 -0
- package/dist/consts/example-scripts.d.ts +13 -0
- package/dist/consts/example-scripts.d.ts.map +1 -0
- package/dist/consts/example-scripts.js +88 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/libs/execute-scripts/context/console.d.ts +11 -0
- package/dist/libs/execute-scripts/context/console.d.ts.map +1 -0
- package/dist/libs/execute-scripts/context/console.js +12 -0
- package/dist/libs/execute-scripts/execute-post-response-script.d.ts +12 -0
- package/dist/libs/execute-scripts/execute-post-response-script.d.ts.map +1 -0
- package/dist/libs/execute-scripts/execute-post-response-script.js +13 -0
- package/dist/libs/execute-scripts/index.d.ts +2 -0
- package/dist/libs/execute-scripts/index.d.ts.map +1 -0
- package/dist/libs/execute-scripts/index.js +4 -0
- package/dist/libs/execute-scripts/postman-sandbox-adapter.d.ts +9 -0
- package/dist/libs/execute-scripts/postman-sandbox-adapter.d.ts.map +1 -0
- package/dist/libs/execute-scripts/postman-sandbox-adapter.js +88 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.d.ts +11 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.js +32 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue2.js +4 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.d.ts +12 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js +53 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue2.js +4 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.d.ts +11 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.js +7 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue2.js +33 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts +2 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.js +4 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.d.ts +12 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.js +48 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue2.js +4 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.d.ts +9 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.js +34 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue2.js +4 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.d.ts +9 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.js +68 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue2.js +4 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.d.ts +13 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.js +32 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue2.js +4 -0
- package/dist/plugins/post-response-scripts/components/TestResults/index.d.ts +2 -0
- package/dist/plugins/post-response-scripts/components/TestResults/index.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/index.js +4 -0
- package/dist/plugins/post-response-scripts/index.d.ts +2 -0
- package/dist/plugins/post-response-scripts/index.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/index.js +4 -0
- package/dist/plugins/post-response-scripts/post-response-scripts-plugin.d.ts +6 -0
- package/dist/plugins/post-response-scripts/post-response-scripts-plugin.d.ts.map +1 -0
- package/dist/plugins/post-response-scripts/post-response-scripts-plugin.js +65 -0
- package/dist/style.css +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Operation } from '@scalar/oas-utils/entities/spec';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
operation: Pick<Operation, 'x-post-response'>;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
6
|
+
"operation:update:extension": (payload: any) => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
+
"onOperation:update:extension"?: ((payload: any) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=PostResponseScripts.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostResponseScripts.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue"],"names":[],"mappings":"AA4DA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAQhE,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAA;CAC9C,CAAC;AAmIF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineComponent as u, computed as c, createElementBlock as i, openBlock as p, createVNode as o, unref as f, withCtx as s, createElementVNode as n, createCommentVNode as _, createTextVNode as x } from "vue";
|
|
2
|
+
import V from "./ExampleScripts.vue.js";
|
|
3
|
+
import v from "./ScriptEditor.vue.js";
|
|
4
|
+
import h from "../../../../components/ViewLayout/ViewLayoutCollapse.vue.js";
|
|
5
|
+
const w = { class: "w-full" }, N = { class: "mr-2" }, S = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "bg-green h-2 w-2 rounded-full"
|
|
8
|
+
}, b = { class: "border-y p-3" }, E = /* @__PURE__ */ u({
|
|
9
|
+
__name: "PostResponseScripts",
|
|
10
|
+
props: {
|
|
11
|
+
operation: {}
|
|
12
|
+
},
|
|
13
|
+
emits: ["operation:update:extension"],
|
|
14
|
+
setup(a, { emit: d }) {
|
|
15
|
+
const m = d, t = c(() => a.operation["x-post-response"] || ""), r = (l) => {
|
|
16
|
+
m("operation:update:extension", {
|
|
17
|
+
"x-post-response": l
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
return (l, e) => (p(), i("div", w, [
|
|
21
|
+
o(f(h), {
|
|
22
|
+
class: "w-full",
|
|
23
|
+
defaultOpen: !0
|
|
24
|
+
}, {
|
|
25
|
+
title: s(() => [...e[0] || (e[0] = [
|
|
26
|
+
x("Scripts", -1)
|
|
27
|
+
])]),
|
|
28
|
+
suffix: s(() => [
|
|
29
|
+
n("div", N, [
|
|
30
|
+
t.value.length > 0 ? (p(), i("div", S)) : _("", !0)
|
|
31
|
+
])
|
|
32
|
+
]),
|
|
33
|
+
default: s(() => [
|
|
34
|
+
e[1] || (e[1] = n("div", { class: "text-c-3 flex h-8 items-center border-y px-3 text-sm" }, " Post-Response ", -1)),
|
|
35
|
+
o(v, {
|
|
36
|
+
modelValue: t.value,
|
|
37
|
+
"onUpdate:modelValue": r
|
|
38
|
+
}, null, 8, ["modelValue"]),
|
|
39
|
+
n("div", b, [
|
|
40
|
+
o(V, {
|
|
41
|
+
modelValue: t.value,
|
|
42
|
+
"onUpdate:modelValue": r
|
|
43
|
+
}, null, 8, ["modelValue"])
|
|
44
|
+
])
|
|
45
|
+
]),
|
|
46
|
+
_: 1
|
|
47
|
+
})
|
|
48
|
+
]));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export {
|
|
52
|
+
E as default
|
|
53
|
+
};
|
package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
modelValue: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
5
|
+
"update:modelValue": (value: string) => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
7
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
//# sourceMappingURL=ScriptEditor.vue.d.ts.map
|
package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptEditor.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue"],"names":[],"mappings":"AAuHA,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAC;AAiEF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue2.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineComponent as s, ref as c, toRef as a, createElementBlock as l, openBlock as m, createElementVNode as d } from "vue";
|
|
2
|
+
import { javascript as p } from "@codemirror/lang-javascript";
|
|
3
|
+
import { useCodeMirror as u } from "@scalar/use-codemirror";
|
|
4
|
+
const f = { class: "script-editor text-sm" }, g = /* @__PURE__ */ s({
|
|
5
|
+
__name: "ScriptEditor",
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: {}
|
|
8
|
+
},
|
|
9
|
+
emits: ["update:modelValue"],
|
|
10
|
+
setup(t, { emit: r }) {
|
|
11
|
+
const n = t, i = r, e = c(null);
|
|
12
|
+
return u({
|
|
13
|
+
codeMirrorRef: e,
|
|
14
|
+
content: a(() => n.modelValue),
|
|
15
|
+
language: void 0,
|
|
16
|
+
// We want to use some custom configuration for the syntax highlighting.
|
|
17
|
+
extensions: [p()],
|
|
18
|
+
lineNumbers: !0,
|
|
19
|
+
onChange: (o) => {
|
|
20
|
+
i("update:modelValue", o);
|
|
21
|
+
}
|
|
22
|
+
}), (o, _) => (m(), l("div", f, [
|
|
23
|
+
d("div", {
|
|
24
|
+
ref_key: "codeMirrorRef",
|
|
25
|
+
ref: e,
|
|
26
|
+
class: "editor-container"
|
|
27
|
+
}, null, 512)
|
|
28
|
+
]));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
g as default
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/PostResponseScripts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,2BAA2B,CAAA"}
|
package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TestResult } from '../../../../libs/execute-scripts/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
state?: TestResult['status'];
|
|
4
|
+
failedTestsCount: number | undefined;
|
|
5
|
+
pendingTestsCount: number | undefined;
|
|
6
|
+
totalTestsCount: number | undefined;
|
|
7
|
+
inline?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=TestResultIndicator.vue.d.ts.map
|
package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestResultIndicator.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue"],"names":[],"mappings":"AA8FA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,KAAK,WAAW,GAAG;IACf,KAAK,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC;AAqHJ,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineComponent as x, computed as i, createElementBlock as s, openBlock as n, normalizeProps as r, guardReactiveProps as T, unref as e, createBlock as g, createCommentVNode as a, normalizeClass as v, toDisplayString as c, mergeProps as k } from "vue";
|
|
2
|
+
import { useBindCx as y, cva as u, ScalarIcon as B } from "@scalar/components";
|
|
3
|
+
const z = {
|
|
4
|
+
key: 1,
|
|
5
|
+
class: "ml-1.25 capitalize"
|
|
6
|
+
}, P = /* @__PURE__ */ x({
|
|
7
|
+
__name: "TestResultIndicator",
|
|
8
|
+
props: {
|
|
9
|
+
state: {},
|
|
10
|
+
failedTestsCount: {},
|
|
11
|
+
pendingTestsCount: {},
|
|
12
|
+
totalTestsCount: {},
|
|
13
|
+
inline: { type: Boolean }
|
|
14
|
+
},
|
|
15
|
+
setup(t) {
|
|
16
|
+
const { cx: o } = y(), l = i(() => t.state === "passed" ? { name: "Checkmark", color: "text-green p-0.25" } : t.state === "failed" ? { name: "Close", color: "text-red" } : { name: "Ellipses", color: "text-c-1" }), d = u({
|
|
17
|
+
base: "flex items-center gap-1.5 rounded-full border pr-2 pl-1.25",
|
|
18
|
+
variants: {
|
|
19
|
+
status: {
|
|
20
|
+
passed: "text-green",
|
|
21
|
+
failed: "text-red",
|
|
22
|
+
pending: "text-orange"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}), m = u({
|
|
26
|
+
base: "text-c-2",
|
|
27
|
+
variants: {
|
|
28
|
+
inline: {
|
|
29
|
+
true: "text-xs",
|
|
30
|
+
false: "text-sm"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}), f = i(() => t.totalTestsCount === void 0 ? "" : t.failedTestsCount ? `${t.failedTestsCount}/${t.totalTestsCount}` : `${t.totalTestsCount - (t.pendingTestsCount || 0) - (t.failedTestsCount || 0)}/${t.totalTestsCount}`);
|
|
34
|
+
return (C, $) => (n(), s("div", r(T(e(o)(e(d)({ status: t.state })))), [
|
|
35
|
+
t.state ? (n(), g(e(B), {
|
|
36
|
+
key: 0,
|
|
37
|
+
class: v(l.value.color),
|
|
38
|
+
icon: l.value.name,
|
|
39
|
+
size: "sm"
|
|
40
|
+
}, null, 8, ["class", "icon"])) : a("", !0),
|
|
41
|
+
t.inline ? a("", !0) : (n(), s("span", z, c(t.state), 1)),
|
|
42
|
+
t.totalTestsCount !== void 0 ? (n(), s("span", r(k({ key: 2 }, e(o)(e(m)({ inline: t.inline })))), c(f.value), 17)) : a("", !0)
|
|
43
|
+
], 16));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export {
|
|
47
|
+
P as default
|
|
48
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TestResult } from '../../../../libs/execute-scripts/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
result: TestResult;
|
|
4
|
+
currentState: TestResult['status'];
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=TestResultItem.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestResultItem.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue"],"names":[],"mappings":"AA2DA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,UAAU,CAAA;IAClB,YAAY,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;CACnC,CAAC;AAsGF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineComponent as n, computed as a, createElementBlock as c, openBlock as l, createElementVNode as t, createCommentVNode as i, normalizeClass as o, createVNode as u, unref as d, toDisplayString as s } from "vue";
|
|
2
|
+
import { ScalarIcon as m } from "@scalar/components";
|
|
3
|
+
const p = { class: "flex flex-col" }, f = { class: "flex items-center gap-3 p-2" }, x = { class: "text-c-2 overflow-hidden text-ellipsis whitespace-nowrap" }, h = { class: "text-c-3 ml-auto whitespace-nowrap" }, g = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9"
|
|
6
|
+
}, C = /* @__PURE__ */ n({
|
|
7
|
+
__name: "TestResultItem",
|
|
8
|
+
props: {
|
|
9
|
+
result: {},
|
|
10
|
+
currentState: {}
|
|
11
|
+
},
|
|
12
|
+
setup(e) {
|
|
13
|
+
const r = a(() => e.result.passed ? { icon: "Checkmark", color: "text-green p-0.25" } : !e.result.passed && e.currentState !== "pending" ? { icon: "Close", color: "text-red" } : { icon: "Ellipses", color: "text-c-1" });
|
|
14
|
+
return (v, b) => (l(), c("div", p, [
|
|
15
|
+
t("div", {
|
|
16
|
+
class: o(["flex h-8 items-center gap-2 pr-3 pl-2.25", e.result.error && "bg-b-danger"])
|
|
17
|
+
}, [
|
|
18
|
+
t("div", f, [
|
|
19
|
+
u(d(m), {
|
|
20
|
+
class: o(r.value.color),
|
|
21
|
+
icon: r.value.icon,
|
|
22
|
+
size: "sm"
|
|
23
|
+
}, null, 8, ["class", "icon"]),
|
|
24
|
+
t("span", x, s(e.result.title), 1)
|
|
25
|
+
]),
|
|
26
|
+
t("span", h, s(e.result.duration) + " ms ", 1)
|
|
27
|
+
], 2),
|
|
28
|
+
e.result.error ? (l(), c("div", g, s(e.result.error), 1)) : i("", !0)
|
|
29
|
+
]));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
export {
|
|
33
|
+
C as default
|
|
34
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { TestResult } from '../../../../libs/execute-scripts/index.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
results?: Ref<TestResult[]> | undefined;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=TestResults.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestResults.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/TestResults/TestResults.vue"],"names":[],"mappings":"AAyFA,OAAO,EAAY,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAOxD,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,SAAS,CAAA;CACxC,CAAC;AA6JF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineComponent as T, computed as s, createBlock as o, createCommentVNode as c, openBlock as a, unref as g, withCtx as i, createElementVNode as C, createElementBlock as h, Fragment as p, renderList as x, createVNode as k, createTextVNode as y } from "vue";
|
|
2
|
+
import N from "./TestResultIndicator.vue.js";
|
|
3
|
+
import V from "./TestResultItem.vue.js";
|
|
4
|
+
import $ from "./TestSummary.vue.js";
|
|
5
|
+
import w from "../../../../components/ViewLayout/ViewLayoutCollapse.vue.js";
|
|
6
|
+
const B = { class: "max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t" }, F = /* @__PURE__ */ T({
|
|
7
|
+
__name: "TestResults",
|
|
8
|
+
props: {
|
|
9
|
+
results: {}
|
|
10
|
+
},
|
|
11
|
+
setup(e) {
|
|
12
|
+
const u = s(
|
|
13
|
+
() => e.results?.value?.filter((t) => t.status === "passed")
|
|
14
|
+
), n = s(
|
|
15
|
+
() => e.results?.value?.filter((t) => t.status === "pending")
|
|
16
|
+
), d = s(
|
|
17
|
+
() => e.results?.value?.filter((t) => t.status === "failed")
|
|
18
|
+
), f = s(
|
|
19
|
+
() => u.value?.length === e.results?.value?.length
|
|
20
|
+
), m = s(() => f.value ? "passed" : n.value?.length ? "pending" : "failed"), v = s(
|
|
21
|
+
() => e.results?.value?.reduce(
|
|
22
|
+
(t, l) => t + l.duration,
|
|
23
|
+
0
|
|
24
|
+
) ?? 0
|
|
25
|
+
);
|
|
26
|
+
return (t, l) => e.results?.value?.length ? (a(), o(g(w), {
|
|
27
|
+
key: 0,
|
|
28
|
+
class: "overflow-auto text-sm",
|
|
29
|
+
defaultOpen: !0
|
|
30
|
+
}, {
|
|
31
|
+
title: i(() => [...l[0] || (l[0] = [
|
|
32
|
+
y(" Tests ", -1)
|
|
33
|
+
])]),
|
|
34
|
+
suffix: i(() => [
|
|
35
|
+
k(N, {
|
|
36
|
+
failedTestsCount: d.value?.length,
|
|
37
|
+
inline: "",
|
|
38
|
+
passedTestsCount: u.value?.length,
|
|
39
|
+
pendingTestsCount: n.value?.length,
|
|
40
|
+
state: m.value,
|
|
41
|
+
totalTestsCount: e.results?.value?.length
|
|
42
|
+
}, null, 8, ["failedTestsCount", "passedTestsCount", "pendingTestsCount", "state", "totalTestsCount"])
|
|
43
|
+
]),
|
|
44
|
+
default: i(() => [
|
|
45
|
+
C("div", B, [
|
|
46
|
+
(a(!0), h(p, null, x(e.results?.value, (r) => (a(), o(V, {
|
|
47
|
+
key: r.title,
|
|
48
|
+
currentState: r.status,
|
|
49
|
+
result: r
|
|
50
|
+
}, null, 8, ["currentState", "result"]))), 128)),
|
|
51
|
+
e.results ? (a(), o($, {
|
|
52
|
+
key: 0,
|
|
53
|
+
allTestsPassed: f.value,
|
|
54
|
+
failedTests: d.value ?? [],
|
|
55
|
+
passedTests: u.value ?? [],
|
|
56
|
+
pendingTests: n.value ?? [],
|
|
57
|
+
results: e.results?.value,
|
|
58
|
+
totalDuration: v.value
|
|
59
|
+
}, null, 8, ["allTestsPassed", "failedTests", "passedTests", "pendingTests", "results", "totalDuration"])) : c("", !0)
|
|
60
|
+
])
|
|
61
|
+
]),
|
|
62
|
+
_: 1
|
|
63
|
+
})) : c("", !0);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
export {
|
|
67
|
+
F as default
|
|
68
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TestResult } from '../../../../libs/execute-scripts/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
results: TestResult[];
|
|
4
|
+
passedTests: TestResult[];
|
|
5
|
+
failedTests: TestResult[];
|
|
6
|
+
pendingTests: TestResult[];
|
|
7
|
+
allTestsPassed: boolean;
|
|
8
|
+
totalDuration: number;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=TestSummary.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestSummary.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/TestResults/TestSummary.vue"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,YAAY,EAAE,UAAU,EAAE,CAAA;IAC1B,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAC;AA0DF,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineComponent as a, createElementBlock as t, openBlock as s, createVNode as l, createCommentVNode as o, createElementVNode as d, toDisplayString as n } from "vue";
|
|
2
|
+
import i from "./TestResultIndicator.vue.js";
|
|
3
|
+
const c = { class: "flex h-8 items-center gap-1.5 pr-3 pl-1" }, u = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "text-orange"
|
|
6
|
+
}, T = { class: "text-c-3 ml-auto" }, p = /* @__PURE__ */ a({
|
|
7
|
+
__name: "TestSummary",
|
|
8
|
+
props: {
|
|
9
|
+
results: {},
|
|
10
|
+
passedTests: {},
|
|
11
|
+
failedTests: {},
|
|
12
|
+
pendingTests: {},
|
|
13
|
+
allTestsPassed: { type: Boolean },
|
|
14
|
+
totalDuration: {}
|
|
15
|
+
},
|
|
16
|
+
setup(e) {
|
|
17
|
+
return (m, r) => (s(), t("div", c, [
|
|
18
|
+
l(i, {
|
|
19
|
+
failedTestsCount: e.failedTests?.length,
|
|
20
|
+
passedTestsCount: e.passedTests?.length,
|
|
21
|
+
pendingTestsCount: e.pendingTests?.length,
|
|
22
|
+
state: e.allTestsPassed ? "passed" : "failed",
|
|
23
|
+
totalTestsCount: e.results?.length
|
|
24
|
+
}, null, 8, ["failedTestsCount", "passedTestsCount", "pendingTestsCount", "state", "totalTestsCount"]),
|
|
25
|
+
e.pendingTests?.length ? (s(), t("span", u, n(e.pendingTests?.length) + " Pending ", 1)) : o("", !0),
|
|
26
|
+
d("span", T, n(e.totalDuration.toFixed(1)) + " ms ", 1)
|
|
27
|
+
]));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export {
|
|
31
|
+
p as default
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/TestResults/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/post-response-scripts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ClientPlugin } from '@scalar/oas-utils/helpers';
|
|
2
|
+
import type { ApiClientPlugin } from '@scalar/types/api-reference';
|
|
3
|
+
export declare const postResponseScriptsPlugin: () => ApiClientPlugin;
|
|
4
|
+
/** Post Response Scripts Plugin for client V2 */
|
|
5
|
+
export declare const postResponseScriptsPluginV2: () => ClientPlugin;
|
|
6
|
+
//# sourceMappingURL=post-response-scripts-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-response-scripts-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/post-response-scripts/post-response-scripts-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAQlE,eAAO,MAAM,yBAAyB,QAAO,eAoC5C,CAAA;AAED,iDAAiD;AACjD,eAAO,MAAM,2BAA2B,QAAO,YAuB9C,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ref as n } from "vue";
|
|
2
|
+
import p from "./components/TestResults/TestResults.vue.js";
|
|
3
|
+
import r from "./components/PostResponseScripts/PostResponseScripts.vue.js";
|
|
4
|
+
import { executePostResponseScript as i } from "../../libs/execute-scripts/execute-post-response-script.js";
|
|
5
|
+
const l = () => {
|
|
6
|
+
const e = n([]);
|
|
7
|
+
return () => ({
|
|
8
|
+
name: "post-response-scripts",
|
|
9
|
+
views: {
|
|
10
|
+
"request.section": [
|
|
11
|
+
{
|
|
12
|
+
title: "Scripts",
|
|
13
|
+
component: r
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"response.section": [
|
|
17
|
+
{
|
|
18
|
+
title: "Tests",
|
|
19
|
+
component: p,
|
|
20
|
+
props: {
|
|
21
|
+
results: e
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
hooks: {
|
|
27
|
+
// Reset test results when a new request is sent
|
|
28
|
+
onBeforeRequest() {
|
|
29
|
+
e.value = [];
|
|
30
|
+
},
|
|
31
|
+
// Execute post-response scripts when a response is received
|
|
32
|
+
async onResponseReceived({ response: s, operation: o }) {
|
|
33
|
+
await i(o["x-post-response"], {
|
|
34
|
+
response: s,
|
|
35
|
+
onTestResultsUpdate: (t) => e.value = [...t]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}, R = () => {
|
|
41
|
+
const e = n([]);
|
|
42
|
+
return {
|
|
43
|
+
components: {
|
|
44
|
+
request: { component: r },
|
|
45
|
+
response: { component: p, additionalProps: { results: e } }
|
|
46
|
+
},
|
|
47
|
+
hooks: {
|
|
48
|
+
// Reset test results when a new request is sent
|
|
49
|
+
beforeRequest: () => {
|
|
50
|
+
e.value = [];
|
|
51
|
+
},
|
|
52
|
+
// Execute post-response scripts when a response is received
|
|
53
|
+
responseReceived: async ({ response: s, operation: o }) => {
|
|
54
|
+
await i(o["x-post-response"], {
|
|
55
|
+
response: s,
|
|
56
|
+
onTestResultsUpdate: (t) => e.value = [...t]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
l as postResponseScriptsPlugin,
|
|
64
|
+
R as postResponseScriptsPluginV2
|
|
65
|
+
};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.script-editor[data-v-a9df3276]{width:100%;height:100%;position:relative}.editor-container[data-v-a9df3276]{width:100%;height:100%;background:var(--scalar-background-1);border-radius:var(--scalar-radius);overflow:hidden;padding-left:3px}[data-v-a9df3276] .cm-editor{height:100%;outline:none;background:var(--scalar-background-1)}[data-v-a9df3276] .cm-content{font-family:var(--scalar-font-code);font-size:var(--scalar-small);padding:8px 2px}[data-v-a9df3276] .cm-gutters{border-right:none;color:var(--scalar-color-3);background:var(--scalar-background-1);font-size:var(--scalar-mini);line-height:1.44}[data-v-a9df3276] .cm-gutters:before{content:"";position:absolute;top:2px;left:2px;width:calc(100% - 2px);height:calc(100% - 4px);border-radius:var(--scalar-radius) 0 0 var(--scalar-radius)}[data-v-a9df3276] .cm-gutterElement{font-family:var(--scalar-font-code)!important;display:flex;align-items:center;justify-content:flex-end;position:relative}[data-v-a9df3276] .cm-scroller{overflow:auto}[data-v-a9df3276] .cm-activeLine,[data-v-a9df3276] .cm-activeLineGutter{background-color:var(--scalar-background-2)}[data-v-a9df3276] .cm-selectionMatch,[data-v-a9df3276] .cm-matchingBracket{border-radius:var(--scalar-radius);background:var(--scalar-background-4)!important}[data-v-a9df3276] .cm-tooltip{background:var(--scalar-background-1)!important;border:1px solid var(--scalar-border-color)!important;border-radius:var(--scalar-radius);box-shadow:var(--scalar-shadow-2)}
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scalar/pre-post-request-scripts",
|
|
3
|
+
"description": "Execute pre-request and post-response scripts in the Scalar API Client",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Scalar (https://github.com/scalar)",
|
|
6
|
+
"homepage": "https://github.com/scalar/scalar",
|
|
7
|
+
"bugs": "https://github.com/scalar/scalar/issues/new/choose",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
|
+
"directory": "packages/pre-post-request-scripts"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"scalar",
|
|
15
|
+
"openapi",
|
|
16
|
+
"swagger",
|
|
17
|
+
"scripts",
|
|
18
|
+
"pre-request scripts",
|
|
19
|
+
"post-response scripts",
|
|
20
|
+
"api client"
|
|
21
|
+
],
|
|
22
|
+
"version": "0.3.9",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"module": "dist/index.js",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./*.css": {
|
|
36
|
+
"import": "./dist/*.css",
|
|
37
|
+
"require": "./dist/*.css",
|
|
38
|
+
"default": "./dist/*.css"
|
|
39
|
+
},
|
|
40
|
+
"./libs/execute-scripts": {
|
|
41
|
+
"import": "./dist/libs/execute-scripts/index.js",
|
|
42
|
+
"types": "./dist/libs/execute-scripts/index.d.ts",
|
|
43
|
+
"default": "./dist/libs/execute-scripts/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./plugins/post-response-scripts": {
|
|
46
|
+
"import": "./dist/plugins/post-response-scripts/index.js",
|
|
47
|
+
"types": "./dist/plugins/post-response-scripts/index.d.ts",
|
|
48
|
+
"default": "./dist/plugins/post-response-scripts/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./plugins/post-response-scripts/components/PostResponseScripts": {
|
|
51
|
+
"import": "./dist/plugins/post-response-scripts/components/PostResponseScripts/index.js",
|
|
52
|
+
"types": "./dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts",
|
|
53
|
+
"default": "./dist/plugins/post-response-scripts/components/PostResponseScripts/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./plugins/post-response-scripts/components/TestResults": {
|
|
56
|
+
"import": "./dist/plugins/post-response-scripts/components/TestResults/index.js",
|
|
57
|
+
"types": "./dist/plugins/post-response-scripts/components/TestResults/index.d.ts",
|
|
58
|
+
"default": "./dist/plugins/post-response-scripts/components/TestResults/index.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist",
|
|
63
|
+
"CHANGELOG.md"
|
|
64
|
+
],
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@codemirror/lang-javascript": "^6.2.4",
|
|
67
|
+
"@headlessui/vue": "1.7.23",
|
|
68
|
+
"postman-sandbox": "^6.5.0",
|
|
69
|
+
"vue": "^3.5.26",
|
|
70
|
+
"@scalar/oas-utils": "0.10.8",
|
|
71
|
+
"@scalar/components": "0.20.9"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@vitejs/plugin-vue": "^6.0.3",
|
|
75
|
+
"@vue/test-utils": "2.4.6",
|
|
76
|
+
"vite": "^7.3.1",
|
|
77
|
+
"@scalar/build-tooling": "0.5.0",
|
|
78
|
+
"@scalar/types": "0.7.3",
|
|
79
|
+
"@scalar/use-codemirror": "0.14.9"
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "scalar-build-vite",
|
|
83
|
+
"dev": "vite",
|
|
84
|
+
"lint:check": "scalar-lint-check",
|
|
85
|
+
"lint:fix": "scalar-lint-fix",
|
|
86
|
+
"preview": "vite preview",
|
|
87
|
+
"test": "vitest",
|
|
88
|
+
"types:build": "scalar-types-build-vue",
|
|
89
|
+
"types:check": "scalar-types-check-vue"
|
|
90
|
+
}
|
|
91
|
+
}
|