@scalar/pre-post-request-scripts 0.3.9 → 0.3.11

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 (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/PostResponseScripts-CrM65oAM.js +202 -0
  3. package/dist/PostResponseScripts-CrM65oAM.js.map +1 -0
  4. package/dist/TestResults-DIM8u91u.js +224 -0
  5. package/dist/TestResults-DIM8u91u.js.map +1 -0
  6. package/dist/ViewLayoutCollapse-BMrPz_sj.js +96 -0
  7. package/dist/ViewLayoutCollapse-BMrPz_sj.js.map +1 -0
  8. package/dist/components/ViewLayout/index.d.ts +1 -1
  9. package/dist/execute-scripts-BV13zq7B.js +125 -0
  10. package/dist/execute-scripts-BV13zq7B.js.map +1 -0
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +4 -7
  13. package/dist/libs/execute-scripts/index.d.ts +1 -1
  14. package/dist/libs/execute-scripts/index.js +2 -4
  15. package/dist/libs/execute-scripts/postman-sandbox-adapter.d.ts +2 -2
  16. package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts +1 -1
  17. package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.js +2 -4
  18. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.d.ts +1 -1
  19. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.d.ts +1 -1
  20. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.d.ts +1 -1
  21. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.d.ts +1 -1
  22. package/dist/plugins/post-response-scripts/components/TestResults/index.d.ts +1 -1
  23. package/dist/plugins/post-response-scripts/components/TestResults/index.js +2 -4
  24. package/dist/plugins/post-response-scripts/index.d.ts +1 -1
  25. package/dist/plugins/post-response-scripts/index.js +3 -4
  26. package/dist/post-response-scripts-ikk1wrl9.js +61 -0
  27. package/dist/post-response-scripts-ikk1wrl9.js.map +1 -0
  28. package/dist/style.css +64 -1
  29. package/package.json +8 -12
  30. package/dist/_virtual/_plugin-vue_export-helper.js +0 -9
  31. package/dist/components/ViewLayout/ValueEmitter.vue.js +0 -21
  32. package/dist/components/ViewLayout/ValueEmitter.vue2.js +0 -4
  33. package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js +0 -89
  34. package/dist/components/ViewLayout/ViewLayoutCollapse.vue2.js +0 -4
  35. package/dist/consts/example-scripts.js +0 -88
  36. package/dist/libs/execute-scripts/context/console.js +0 -12
  37. package/dist/libs/execute-scripts/execute-post-response-script.js +0 -13
  38. package/dist/libs/execute-scripts/postman-sandbox-adapter.js +0 -88
  39. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.js +0 -32
  40. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue2.js +0 -4
  41. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js +0 -53
  42. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue2.js +0 -4
  43. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.js +0 -7
  44. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue2.js +0 -33
  45. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.js +0 -48
  46. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue2.js +0 -4
  47. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.js +0 -34
  48. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue2.js +0 -4
  49. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.js +0 -68
  50. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue2.js +0 -4
  51. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.js +0 -32
  52. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue2.js +0 -4
  53. package/dist/plugins/post-response-scripts/post-response-scripts-plugin.js +0 -65
@@ -1,2 +1,2 @@
1
- export { default as ViewLayoutCollapse } from './ViewLayoutCollapse.vue.js';
1
+ export { default as ViewLayoutCollapse } from './ViewLayoutCollapse.vue';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,125 @@
1
+ import Sandbox from "postman-sandbox";
2
+ //#region src/libs/execute-scripts/context/console.ts
3
+ var createConsoleContext = () => ({
4
+ log: (...args) => console.log("[Script]", ...args),
5
+ error: (...args) => console.error("[Script Error]", ...args),
6
+ warn: (...args) => console.warn("[Script Warning]", ...args),
7
+ info: (...args) => console.info("[Script Info]", ...args),
8
+ debug: (...args) => console.debug("[Script Debug]", ...args),
9
+ trace: (...args) => console.trace("[Script Trace]", ...args),
10
+ table: (tabularData, properties) => console.table(tabularData, properties)
11
+ });
12
+ //#endregion
13
+ //#region src/libs/execute-scripts/postman-sandbox-adapter.ts
14
+ var toPostmanResponse = async (response) => {
15
+ const responseText = await response.text();
16
+ const responseBytes = Array.from(new TextEncoder().encode(responseText));
17
+ return {
18
+ code: response.status,
19
+ status: response.statusText || String(response.status),
20
+ header: Array.from(response.headers.entries()).map(([key, value]) => ({
21
+ key,
22
+ value
23
+ })),
24
+ stream: {
25
+ type: "Buffer",
26
+ data: responseBytes
27
+ }
28
+ };
29
+ };
30
+ var createContext = () => new Promise((resolve, reject) => {
31
+ Sandbox.createContext((error, context) => {
32
+ if (error) {
33
+ reject(error);
34
+ return;
35
+ }
36
+ resolve(context);
37
+ });
38
+ });
39
+ var toErrorMessage = (error) => {
40
+ if (error && typeof error === "object" && "message" in error && typeof error.message === "string") return error.message;
41
+ return String(error);
42
+ };
43
+ var upsertTestResult = (testResults, assertion, duration) => {
44
+ const title = assertion.name || `Assertion ${assertion.index + 1}`;
45
+ const nextResult = {
46
+ title,
47
+ passed: assertion.passed,
48
+ duration,
49
+ error: assertion.error?.message,
50
+ status: assertion.passed ? "passed" : "failed"
51
+ };
52
+ const existingResultIndex = testResults.findIndex((result) => result.title === title);
53
+ if (existingResultIndex === -1) {
54
+ testResults.push(nextResult);
55
+ return;
56
+ }
57
+ testResults[existingResultIndex] = nextResult;
58
+ };
59
+ var executeInPostmanSandbox = async ({ script, response, onTestResultsUpdate, scriptConsole }) => {
60
+ const testResults = [];
61
+ let lastAssertionTime = 0;
62
+ let scriptExecutionStartedAt = 0;
63
+ const sandboxContext = await createContext();
64
+ const handleAssertion = (_cursor, assertions) => {
65
+ assertions.forEach((assertion) => {
66
+ const duration = Number((performance.now() - lastAssertionTime).toFixed(2));
67
+ lastAssertionTime = performance.now();
68
+ upsertTestResult(testResults, assertion, duration);
69
+ });
70
+ onTestResultsUpdate?.([...testResults]);
71
+ };
72
+ const handleConsole = (_cursor, level, ...args) => {
73
+ (scriptConsole[level] ?? scriptConsole.log)(...args);
74
+ };
75
+ try {
76
+ sandboxContext.on("execution.assertion", handleAssertion);
77
+ sandboxContext.on("console", handleConsole);
78
+ const postmanResponse = await toPostmanResponse(response);
79
+ scriptExecutionStartedAt = performance.now();
80
+ lastAssertionTime = scriptExecutionStartedAt;
81
+ await new Promise((resolve) => {
82
+ sandboxContext.execute({
83
+ listen: "test",
84
+ script: { exec: [script] }
85
+ }, {
86
+ disableLegacyAPIs: true,
87
+ context: { response: postmanResponse }
88
+ }, (error) => {
89
+ if (error) {
90
+ const duration = Number((performance.now() - scriptExecutionStartedAt).toFixed(2));
91
+ const errorMessage = toErrorMessage(error);
92
+ scriptConsole.error(`[Post-Response Script] Error (${duration}ms):`, errorMessage);
93
+ testResults.push({
94
+ title: "Script Execution",
95
+ passed: false,
96
+ duration,
97
+ error: errorMessage,
98
+ status: "failed"
99
+ });
100
+ onTestResultsUpdate?.([...testResults]);
101
+ }
102
+ resolve();
103
+ });
104
+ });
105
+ } finally {
106
+ sandboxContext.off("execution.assertion", handleAssertion);
107
+ sandboxContext.off("console", handleConsole);
108
+ sandboxContext.dispose();
109
+ }
110
+ };
111
+ //#endregion
112
+ //#region src/libs/execute-scripts/execute-post-response-script.ts
113
+ var executePostResponseScript = async (script, data) => {
114
+ if (!script) return;
115
+ await executeInPostmanSandbox({
116
+ script,
117
+ response: data.response,
118
+ onTestResultsUpdate: data.onTestResultsUpdate,
119
+ scriptConsole: createConsoleContext()
120
+ });
121
+ };
122
+ //#endregion
123
+ export { executePostResponseScript as t };
124
+
125
+ //# sourceMappingURL=execute-scripts-BV13zq7B.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-scripts-BV13zq7B.js","names":[],"sources":["../src/libs/execute-scripts/context/console.ts","../src/libs/execute-scripts/postman-sandbox-adapter.ts","../src/libs/execute-scripts/execute-post-response-script.ts"],"sourcesContent":["export interface ConsoleContext {\n log: (...args: any[]) => void\n error: (...args: any[]) => void\n warn: (...args: any[]) => void\n info: (...args: any[]) => void\n debug: (...args: any[]) => void\n trace: (...args: any[]) => void\n table: (tabularData: any, properties?: readonly string[]) => void\n}\n\nexport const createConsoleContext = (): ConsoleContext => ({\n log: (...args: any[]) => console.log('[Script]', ...args),\n error: (...args: any[]) => console.error('[Script Error]', ...args),\n warn: (...args: any[]) => console.warn('[Script Warning]', ...args),\n info: (...args: any[]) => console.info('[Script Info]', ...args),\n debug: (...args: any[]) => console.debug('[Script Debug]', ...args),\n trace: (...args: any[]) => console.trace('[Script Trace]', ...args),\n table: (tabularData: any, properties?: readonly string[]) => console.table(tabularData, properties),\n})\n","import type { SandboxContext } from 'postman-sandbox'\nimport Sandbox from 'postman-sandbox'\n\nimport type { ConsoleContext } from './context/console'\nimport type { TestResult } from './execute-post-response-script'\n\ntype AssertionEvent = {\n name: string\n index: number\n passed: boolean\n skipped: boolean\n error: { message?: string } | null\n}\n\nconst toPostmanResponse = async (response: Response) => {\n const responseText = await response.text()\n const responseBytes = Array.from(new TextEncoder().encode(responseText))\n\n return {\n code: response.status,\n status: response.statusText || String(response.status),\n header: Array.from(response.headers.entries()).map(([key, value]) => ({ key, value })),\n stream: {\n type: 'Buffer',\n data: responseBytes,\n },\n }\n}\n\nconst createContext = (): Promise<SandboxContext> =>\n new Promise((resolve, reject) => {\n Sandbox.createContext((error: unknown, context: SandboxContext) => {\n if (error) {\n reject(error)\n return\n }\n\n resolve(context)\n })\n })\n\nconst toErrorMessage = (error: unknown): string => {\n if (error && typeof error === 'object' && 'message' in error && typeof error.message === 'string') {\n return error.message\n }\n\n return String(error)\n}\n\nconst upsertTestResult = (testResults: TestResult[], assertion: AssertionEvent, duration: number): void => {\n const title = assertion.name || `Assertion ${assertion.index + 1}`\n\n const nextResult: TestResult = {\n title,\n passed: assertion.passed,\n duration,\n error: assertion.error?.message,\n status: assertion.passed ? 'passed' : 'failed',\n }\n\n const existingResultIndex = testResults.findIndex((result) => result.title === title)\n if (existingResultIndex === -1) {\n testResults.push(nextResult)\n return\n }\n\n testResults[existingResultIndex] = nextResult\n}\n\nexport const executeInPostmanSandbox = async ({\n script,\n response,\n onTestResultsUpdate,\n scriptConsole,\n}: {\n script: string\n response: Response\n onTestResultsUpdate?: ((results: TestResult[]) => void) | undefined\n scriptConsole: ConsoleContext\n}): Promise<void> => {\n const testResults: TestResult[] = []\n let lastAssertionTime = 0\n let scriptExecutionStartedAt = 0\n const sandboxContext = await createContext()\n\n const handleAssertion = (_cursor: unknown, assertions: AssertionEvent[]) => {\n assertions.forEach((assertion) => {\n const duration = Number((performance.now() - lastAssertionTime).toFixed(2))\n lastAssertionTime = performance.now()\n upsertTestResult(testResults, assertion, duration)\n })\n onTestResultsUpdate?.([...testResults])\n }\n\n const handleConsole = (_cursor: unknown, level: keyof ConsoleContext, ...args: unknown[]) => {\n const consoleMethod = scriptConsole[level] ?? scriptConsole.log\n ;(consoleMethod as (...params: unknown[]) => void)(...args)\n }\n\n try {\n sandboxContext.on('execution.assertion', handleAssertion)\n sandboxContext.on('console', handleConsole)\n\n const postmanResponse = await toPostmanResponse(response)\n\n scriptExecutionStartedAt = performance.now()\n lastAssertionTime = scriptExecutionStartedAt\n\n await new Promise<void>((resolve) => {\n sandboxContext.execute(\n {\n listen: 'test',\n script: {\n exec: [script],\n },\n },\n {\n disableLegacyAPIs: true,\n context: {\n response: postmanResponse,\n },\n },\n (error: unknown) => {\n if (error) {\n const duration = Number((performance.now() - scriptExecutionStartedAt).toFixed(2))\n const errorMessage = toErrorMessage(error)\n\n scriptConsole.error(`[Post-Response Script] Error (${duration}ms):`, errorMessage)\n\n testResults.push({\n title: 'Script Execution',\n passed: false,\n duration,\n error: errorMessage,\n status: 'failed',\n })\n onTestResultsUpdate?.([...testResults])\n }\n\n resolve()\n },\n )\n })\n } finally {\n sandboxContext.off('execution.assertion', handleAssertion)\n sandboxContext.off('console', handleConsole)\n sandboxContext.dispose()\n }\n}\n","import { createConsoleContext } from './context/console'\nimport { executeInPostmanSandbox } from './postman-sandbox-adapter'\n\nexport type TestResult = {\n title: string\n passed: boolean\n duration: number\n error?: string\n status: 'pending' | 'passed' | 'failed'\n}\n\nexport const executePostResponseScript = async (\n script: string | undefined,\n data: {\n response: Response\n onTestResultsUpdate?: ((results: TestResult[]) => void) | undefined\n },\n): Promise<void> => {\n if (!script) {\n return\n }\n await executeInPostmanSandbox({\n script,\n response: data.response,\n onTestResultsUpdate: data.onTestResultsUpdate,\n scriptConsole: createConsoleContext(),\n })\n}\n"],"mappings":"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"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { ViewLayoutCollapse } from './components/ViewLayout';
2
- export { postResponseScriptsPlugin } from './plugins/post-response-scripts/index.js';
3
- export { postResponseScriptsPluginV2 } from './plugins/post-response-scripts/post-response-scripts-plugin.js';
2
+ export { postResponseScriptsPlugin } from './plugins/post-response-scripts';
3
+ export { postResponseScriptsPluginV2 } from './plugins/post-response-scripts/post-response-scripts-plugin';
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,4 @@
1
- import { postResponseScriptsPlugin as e, postResponseScriptsPluginV2 as p } from "./plugins/post-response-scripts/post-response-scripts-plugin.js";
2
- import { default as r } from "./components/ViewLayout/ViewLayoutCollapse.vue.js";
3
- export {
4
- r as ViewLayoutCollapse,
5
- e as postResponseScriptsPlugin,
6
- p as postResponseScriptsPluginV2
7
- };
1
+ import { t as ViewLayoutCollapse_default } from "./ViewLayoutCollapse-BMrPz_sj.js";
2
+ import "./PostResponseScripts-CrM65oAM.js";
3
+ import { n as postResponseScriptsPluginV2, t as postResponseScriptsPlugin } from "./post-response-scripts-ikk1wrl9.js";
4
+ export { ViewLayoutCollapse_default as ViewLayoutCollapse, postResponseScriptsPlugin, postResponseScriptsPluginV2 };
@@ -1,2 +1,2 @@
1
- export { type TestResult, executePostResponseScript } from './execute-post-response-script.js';
1
+ export { type TestResult, executePostResponseScript } from './execute-post-response-script';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,2 @@
1
- import { executePostResponseScript as t } from "./execute-post-response-script.js";
2
- export {
3
- t as executePostResponseScript
4
- };
1
+ import { t as executePostResponseScript } from "../../execute-scripts-BV13zq7B.js";
2
+ export { executePostResponseScript };
@@ -1,5 +1,5 @@
1
- import type { ConsoleContext } from './context/console.js';
2
- import type { TestResult } from './execute-post-response-script.js';
1
+ import type { ConsoleContext } from './context/console';
2
+ import type { TestResult } from './execute-post-response-script';
3
3
  export declare const executeInPostmanSandbox: ({ script, response, onTestResultsUpdate, scriptConsole, }: {
4
4
  script: string;
5
5
  response: Response;
@@ -1,2 +1,2 @@
1
- export { default as PostResponseScripts } from './PostResponseScripts.vue.js';
1
+ export { default as PostResponseScripts } from './PostResponseScripts.vue';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,2 @@
1
- import { default as o } from "./PostResponseScripts.vue.js";
2
- export {
3
- o as PostResponseScripts
4
- };
1
+ import { t as PostResponseScripts_default } from "../../../../PostResponseScripts-CrM65oAM.js";
2
+ export { PostResponseScripts_default as PostResponseScripts };
@@ -1,4 +1,4 @@
1
- import type { TestResult } from '../../../../libs/execute-scripts/index.js';
1
+ import type { TestResult } from '@/libs/execute-scripts';
2
2
  type __VLS_Props = {
3
3
  state?: TestResult['status'];
4
4
  failedTestsCount: number | undefined;
@@ -1,4 +1,4 @@
1
- import type { TestResult } from '../../../../libs/execute-scripts/index.js';
1
+ import type { TestResult } from '@/libs/execute-scripts';
2
2
  type __VLS_Props = {
3
3
  result: TestResult;
4
4
  currentState: TestResult['status'];
@@ -1,5 +1,5 @@
1
1
  import { type Ref } from 'vue';
2
- import type { TestResult } from '../../../../libs/execute-scripts/index.js';
2
+ import type { TestResult } from '@/libs/execute-scripts';
3
3
  type __VLS_Props = {
4
4
  results?: Ref<TestResult[]> | undefined;
5
5
  };
@@ -1,4 +1,4 @@
1
- import type { TestResult } from '../../../../libs/execute-scripts/index.js';
1
+ import type { TestResult } from '@/libs/execute-scripts';
2
2
  type __VLS_Props = {
3
3
  results: TestResult[];
4
4
  passedTests: TestResult[];
@@ -1,2 +1,2 @@
1
- export { default as TestResults } from './TestResults.vue.js';
1
+ export { default as TestResults } from './TestResults.vue';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,2 @@
1
- import { default as t } from "./TestResults.vue.js";
2
- export {
3
- t as TestResults
4
- };
1
+ import { t as TestResults_default } from "../../../../TestResults-DIM8u91u.js";
2
+ export { TestResults_default as TestResults };
@@ -1,2 +1,2 @@
1
- export { postResponseScriptsPlugin } from './post-response-scripts-plugin.js';
1
+ export { postResponseScriptsPlugin } from './post-response-scripts-plugin';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
- import { postResponseScriptsPlugin as s } from "./post-response-scripts-plugin.js";
2
- export {
3
- s as postResponseScriptsPlugin
4
- };
1
+ import "../../PostResponseScripts-CrM65oAM.js";
2
+ import { t as postResponseScriptsPlugin } from "../../post-response-scripts-ikk1wrl9.js";
3
+ export { postResponseScriptsPlugin };
@@ -0,0 +1,61 @@
1
+ import { t as executePostResponseScript } from "./execute-scripts-BV13zq7B.js";
2
+ import { t as PostResponseScripts_default } from "./PostResponseScripts-CrM65oAM.js";
3
+ import { t as TestResults_default } from "./TestResults-DIM8u91u.js";
4
+ import { ref } from "vue";
5
+ //#region src/plugins/post-response-scripts/post-response-scripts-plugin.ts
6
+ var postResponseScriptsPlugin = () => {
7
+ const results = ref([]);
8
+ return () => ({
9
+ name: "post-response-scripts",
10
+ views: {
11
+ "request.section": [{
12
+ title: "Scripts",
13
+ component: PostResponseScripts_default
14
+ }],
15
+ "response.section": [{
16
+ title: "Tests",
17
+ component: TestResults_default,
18
+ props: { results }
19
+ }]
20
+ },
21
+ hooks: {
22
+ onBeforeRequest() {
23
+ results.value = [];
24
+ },
25
+ async onResponseReceived({ response, operation }) {
26
+ await executePostResponseScript(operation["x-post-response"], {
27
+ response,
28
+ onTestResultsUpdate: (newResults) => results.value = [...newResults]
29
+ });
30
+ }
31
+ }
32
+ });
33
+ };
34
+ /** Post Response Scripts Plugin for client V2 */
35
+ var postResponseScriptsPluginV2 = () => {
36
+ const results = ref([]);
37
+ return {
38
+ components: {
39
+ request: { component: PostResponseScripts_default },
40
+ response: {
41
+ component: TestResults_default,
42
+ additionalProps: { results }
43
+ }
44
+ },
45
+ hooks: {
46
+ beforeRequest: () => {
47
+ results.value = [];
48
+ },
49
+ responseReceived: async ({ response, operation }) => {
50
+ await executePostResponseScript(operation["x-post-response"], {
51
+ response,
52
+ onTestResultsUpdate: (newResults) => results.value = [...newResults]
53
+ });
54
+ }
55
+ }
56
+ };
57
+ };
58
+ //#endregion
59
+ export { postResponseScriptsPluginV2 as n, postResponseScriptsPlugin as t };
60
+
61
+ //# sourceMappingURL=post-response-scripts-ikk1wrl9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-response-scripts-ikk1wrl9.js","names":[],"sources":["../src/plugins/post-response-scripts/post-response-scripts-plugin.ts"],"sourcesContent":["import type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { ApiClientPlugin } from '@scalar/types/api-reference'\nimport { ref } from 'vue'\n\nimport { type TestResult, executePostResponseScript } from '@/libs/execute-scripts'\n\nimport { PostResponseScripts } from './components/PostResponseScripts'\nimport { TestResults } from './components/TestResults'\n\nexport const postResponseScriptsPlugin = (): ApiClientPlugin => {\n const results = ref<TestResult[]>([])\n\n return () => ({\n name: 'post-response-scripts',\n views: {\n 'request.section': [\n {\n title: 'Scripts',\n component: PostResponseScripts,\n },\n ],\n 'response.section': [\n {\n title: 'Tests',\n component: TestResults,\n props: {\n results,\n },\n },\n ],\n },\n hooks: {\n // Reset test results when a new request is sent\n onBeforeRequest() {\n results.value = []\n },\n // Execute post-response scripts when a response is received\n async onResponseReceived({ response, operation }) {\n await executePostResponseScript(operation['x-post-response'], {\n response,\n onTestResultsUpdate: (newResults) => (results.value = [...newResults]),\n })\n },\n },\n })\n}\n\n/** Post Response Scripts Plugin for client V2 */\nexport const postResponseScriptsPluginV2 = (): ClientPlugin => {\n const results = ref<TestResult[]>([])\n\n return {\n components: {\n request: { component: PostResponseScripts },\n response: { component: TestResults, additionalProps: { results } },\n },\n\n hooks: {\n // Reset test results when a new request is sent\n beforeRequest: () => {\n results.value = []\n },\n // Execute post-response scripts when a response is received\n responseReceived: async ({ response, operation }) => {\n await executePostResponseScript(operation['x-post-response'], {\n response,\n onTestResultsUpdate: (newResults) => (results.value = [...newResults]),\n })\n },\n },\n }\n}\n"],"mappings":";;;;;AASA,IAAa,kCAAmD;CAC9D,MAAM,UAAU,IAAkB,EAAE,CAAC;AAErC,eAAc;EACZ,MAAM;EACN,OAAO;GACL,mBAAmB,CACjB;IACE,OAAO;IACP,WAAW;IACZ,CACF;GACD,oBAAoB,CAClB;IACE,OAAO;IACP,WAAW;IACX,OAAO,EACL,SACD;IACF,CACF;GACF;EACD,OAAO;GAEL,kBAAkB;AAChB,YAAQ,QAAQ,EAAE;;GAGpB,MAAM,mBAAmB,EAAE,UAAU,aAAa;AAChD,UAAM,0BAA0B,UAAU,oBAAoB;KAC5D;KACA,sBAAsB,eAAgB,QAAQ,QAAQ,CAAC,GAAG,WAAW;KACtE,CAAC;;GAEL;EACF;;;AAIH,IAAa,oCAAkD;CAC7D,MAAM,UAAU,IAAkB,EAAE,CAAC;AAErC,QAAO;EACL,YAAY;GACV,SAAS,EAAE,WAAW,6BAAqB;GAC3C,UAAU;IAAE,WAAW;IAAa,iBAAiB,EAAE,SAAS;IAAE;GACnE;EAED,OAAO;GAEL,qBAAqB;AACnB,YAAQ,QAAQ,EAAE;;GAGpB,kBAAkB,OAAO,EAAE,UAAU,gBAAgB;AACnD,UAAM,0BAA0B,UAAU,oBAAoB;KAC5D;KACA,sBAAsB,eAAgB,QAAQ,QAAQ,CAAC,GAAG,WAAW;KACtE,CAAC;;GAEL;EACF"}
package/dist/style.css CHANGED
@@ -1 +1,64 @@
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)}
1
+
2
+ .script-editor[data-v-a9df3276] {
3
+ width: 100%;
4
+ height: 100%;
5
+ position: relative;
6
+ }
7
+ .editor-container[data-v-a9df3276] {
8
+ width: 100%;
9
+ height: 100%;
10
+ background: var(--scalar-background-1);
11
+ border-radius: var(--scalar-radius);
12
+ overflow: hidden;
13
+ padding-left: 3px;
14
+ }
15
+ [data-v-a9df3276] .cm-editor {
16
+ height: 100%;
17
+ outline: none;
18
+ background: var(--scalar-background-1);
19
+ }
20
+ [data-v-a9df3276] .cm-content {
21
+ font-family: var(--scalar-font-code);
22
+ font-size: var(--scalar-small);
23
+ padding: 8px 2px;
24
+ }
25
+ [data-v-a9df3276] .cm-gutters {
26
+ border-right: none;
27
+ color: var(--scalar-color-3);
28
+ background: var(--scalar-background-1);
29
+ font-size: var(--scalar-mini);
30
+ line-height: 1.44;
31
+ }
32
+ [data-v-a9df3276] .cm-gutters:before {
33
+ content: '';
34
+ position: absolute;
35
+ top: 2px;
36
+ left: 2px;
37
+ width: calc(100% - 2px);
38
+ height: calc(100% - 4px);
39
+ border-radius: var(--scalar-radius) 0 0 var(--scalar-radius);
40
+ }
41
+ [data-v-a9df3276] .cm-gutterElement {
42
+ font-family: var(--scalar-font-code) !important;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: flex-end;
46
+ position: relative;
47
+ }
48
+ [data-v-a9df3276] .cm-scroller {
49
+ overflow: auto;
50
+ }
51
+ [data-v-a9df3276] .cm-activeLine,[data-v-a9df3276] .cm-activeLineGutter {
52
+ background-color: var(--scalar-background-2);
53
+ }
54
+ [data-v-a9df3276] .cm-selectionMatch,[data-v-a9df3276] .cm-matchingBracket {
55
+ border-radius: var(--scalar-radius);
56
+ background: var(--scalar-background-4) !important;
57
+ }
58
+ [data-v-a9df3276] .cm-tooltip {
59
+ background: var(--scalar-background-1) !important;
60
+ border: 1px solid var(--scalar-border-color) !important;
61
+ border-radius: var(--scalar-radius);
62
+ box-shadow: var(--scalar-shadow-2);
63
+ }
64
+ /*$vite$:1*/
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "post-response scripts",
20
20
  "api client"
21
21
  ],
22
- "version": "0.3.9",
22
+ "version": "0.3.11",
23
23
  "engines": {
24
24
  "node": ">=22"
25
25
  },
@@ -67,25 +67,21 @@
67
67
  "@headlessui/vue": "1.7.23",
68
68
  "postman-sandbox": "^6.5.0",
69
69
  "vue": "^3.5.26",
70
- "@scalar/oas-utils": "0.10.8",
71
- "@scalar/components": "0.20.9"
70
+ "@scalar/components": "0.20.11",
71
+ "@scalar/oas-utils": "0.10.10"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@vitejs/plugin-vue": "^6.0.3",
75
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"
76
+ "vite": "8.0.0",
77
+ "@scalar/types": "0.7.4",
78
+ "@scalar/use-codemirror": "0.14.10"
80
79
  },
81
80
  "scripts": {
82
- "build": "scalar-build-vite",
81
+ "build": "vite build && vue-tsc -p tsconfig.build.json",
83
82
  "dev": "vite",
84
- "lint:check": "scalar-lint-check",
85
- "lint:fix": "scalar-lint-fix",
86
83
  "preview": "vite preview",
87
84
  "test": "vitest",
88
- "types:build": "scalar-types-build-vue",
89
- "types:check": "scalar-types-check-vue"
85
+ "types:check": "vue-tsc --noEmit"
90
86
  }
91
87
  }
@@ -1,9 +0,0 @@
1
- const s = (t, e) => {
2
- const o = t.__vccOpts || t;
3
- for (const [r, c] of e)
4
- o[r] = c;
5
- return o;
6
- };
7
- export {
8
- s as default
9
- };
@@ -1,21 +0,0 @@
1
- import { defineComponent as m, watch as o, onBeforeUnmount as a } from "vue";
2
- const r = {
3
- name: "ValueEmitter"
4
- }, s = /* @__PURE__ */ m({
5
- ...r,
6
- props: {
7
- value: {}
8
- },
9
- emits: ["change", "unmount"],
10
- setup(n, { emit: u }) {
11
- const e = u;
12
- return o(
13
- () => n.value,
14
- (t) => e("change", t),
15
- { immediate: !0 }
16
- ), a(() => e("unmount")), (t, c) => null;
17
- }
18
- });
19
- export {
20
- s as default
21
- };
@@ -1,4 +0,0 @@
1
- import f from "./ValueEmitter.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,89 +0,0 @@
1
- import { defineComponent as y, useId as C, createBlock as p, openBlock as l, unref as s, normalizeClass as n, withCtx as c, createVNode as d, createElementVNode as a, createElementBlock as r, createCommentVNode as i, renderSlot as u, createTextVNode as S, toDisplayString as b, mergeProps as v } from "vue";
2
- import { Disclosure as k, DisclosureButton as B, DisclosurePanel as V } from "@headlessui/vue";
3
- import { ScalarIcon as $ } from "@scalar/components";
4
- import w from "./ValueEmitter.vue.js";
5
- const D = ["aria-labelledby"], I = { class: "text-c-1 m-0 flex flex-1 items-center gap-1.5 leading-[20px]" }, N = ["id"], O = {
6
- key: 0,
7
- class: "sr-only"
8
- }, z = {
9
- key: 0,
10
- class: "bg-b-2 text-c-2 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold"
11
- }, E = { class: "sr-only" }, P = {
12
- key: 0,
13
- class: "ui-not-open:hidden flex items-center gap-2 pr-0.75"
14
- }, _ = {
15
- name: "CollapsibleSection"
16
- }, A = /* @__PURE__ */ y({
17
- ..._,
18
- props: {
19
- defaultOpen: { type: Boolean, default: !0 },
20
- itemCount: { default: 0 },
21
- isStatic: { type: Boolean }
22
- },
23
- emits: ["update:modelValue"],
24
- setup(e, { emit: x }) {
25
- const h = x, f = C();
26
- return (o, m) => (l(), p(s(k), {
27
- as: "div",
28
- class: n(["group/collapse text-c-2 focus-within:text-c-1 last:ui-open:border-b-0 border-b", e.isStatic && "last-of-type:first-of-type:border-b-0"]),
29
- defaultOpen: e.defaultOpen,
30
- static: e.isStatic
31
- }, {
32
- default: c(({ open: t }) => [
33
- d(w, {
34
- value: t,
35
- onChange: m[0] || (m[0] = (g) => h("update:modelValue", g))
36
- }, null, 8, ["value"]),
37
- a("section", {
38
- "aria-labelledby": s(f),
39
- class: "contents"
40
- }, [
41
- a("div", {
42
- class: n(["bg-b-2 flex items-center", e.isStatic && "rounded-t-lg border border-b-0"])
43
- }, [
44
- d(s(B), {
45
- class: n(["hover:text-c-1 group box-content flex max-h-8 flex-1 items-center gap-2.5 overflow-hidden px-1 py-1.5 text-base font-medium outline-none md:px-1.5 xl:pr-0.5 xl:pl-2", e.isStatic && "!pl-3"]),
46
- disabled: e.isStatic
47
- }, {
48
- default: c(() => [
49
- e.isStatic ? i("", !0) : (l(), p(s($), {
50
- key: 0,
51
- class: "text-c-3 group-hover:text-c-1 rounded-px ui-open:rotate-90 ui-not-open:rotate-0 outline-offset-2 group-focus-visible:outline",
52
- icon: "ChevronRight",
53
- size: "md"
54
- })),
55
- a("h2", I, [
56
- a("span", {
57
- id: s(f),
58
- class: "contents"
59
- }, [
60
- u(o.$slots, "title", { open: t }),
61
- t ? i("", !0) : (l(), r("span", O, " (Collapsed) "))
62
- ], 8, N),
63
- !t && e.itemCount ? (l(), r("span", z, [
64
- S(b(e.itemCount) + " ", 1),
65
- a("span", E, "Item" + b(e.itemCount === 1 ? "" : "s"), 1)
66
- ])) : i("", !0)
67
- ])
68
- ]),
69
- _: 2
70
- }, 1032, ["class", "disabled"]),
71
- o.$slots.actions ? (l(), r("div", P, [
72
- u(o.$slots, "actions", { open: t })
73
- ])) : i("", !0)
74
- ], 2),
75
- d(s(V), v(o.$attrs, { class: "diclosure-panel h-full max-h-fit rounded-b" }), {
76
- default: c(() => [
77
- u(o.$slots, "default", { open: t })
78
- ]),
79
- _: 2
80
- }, 1040)
81
- ], 8, D)
82
- ]),
83
- _: 3
84
- }, 8, ["class", "defaultOpen", "static"]));
85
- }
86
- });
87
- export {
88
- A as default
89
- };
@@ -1,4 +0,0 @@
1
- import f from "./ViewLayoutCollapse.vue.js";
2
- export {
3
- f as default
4
- };