@scalar/pre-post-request-scripts 0.3.18 → 0.4.1

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 (124) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/components/ScriptEditor.vue.d.ts.map +1 -0
  3. package/dist/components/ScriptEditor.vue.js +7 -0
  4. package/dist/components/ScriptEditor.vue.js.map +1 -0
  5. package/dist/{plugins/post-response-scripts/components/PostResponseScripts → components}/ScriptEditor.vue.script.js +1 -1
  6. package/dist/components/ScriptEditor.vue.script.js.map +1 -0
  7. package/dist/index.d.ts +1 -3
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -3
  10. package/dist/libs/execute-scripts/build-sandbox-context.d.ts +15 -0
  11. package/dist/libs/execute-scripts/build-sandbox-context.d.ts.map +1 -0
  12. package/dist/libs/execute-scripts/build-sandbox-context.js +29 -0
  13. package/dist/libs/execute-scripts/build-sandbox-context.js.map +1 -0
  14. package/dist/libs/execute-scripts/execute-post-response-script.d.ts +3 -0
  15. package/dist/libs/execute-scripts/execute-post-response-script.d.ts.map +1 -1
  16. package/dist/libs/execute-scripts/execute-post-response-script.js +9 -4
  17. package/dist/libs/execute-scripts/execute-post-response-script.js.map +1 -1
  18. package/dist/libs/execute-scripts/execute-pre-request-script.d.ts +14 -0
  19. package/dist/libs/execute-scripts/execute-pre-request-script.d.ts.map +1 -0
  20. package/dist/libs/execute-scripts/execute-pre-request-script.js +26 -0
  21. package/dist/libs/execute-scripts/execute-pre-request-script.js.map +1 -0
  22. package/dist/libs/execute-scripts/index.d.ts +1 -0
  23. package/dist/libs/execute-scripts/index.d.ts.map +1 -1
  24. package/dist/libs/execute-scripts/postman-adapter/request-factory-adapter.d.ts +16 -0
  25. package/dist/libs/execute-scripts/postman-adapter/request-factory-adapter.d.ts.map +1 -0
  26. package/dist/libs/execute-scripts/postman-adapter/request-factory-adapter.js +95 -0
  27. package/dist/libs/execute-scripts/postman-adapter/request-factory-adapter.js.map +1 -0
  28. package/dist/libs/execute-scripts/postman-adapter/sandbox-adapter.d.ts +16 -0
  29. package/dist/libs/execute-scripts/postman-adapter/sandbox-adapter.d.ts.map +1 -0
  30. package/dist/libs/execute-scripts/{postman-sandbox-adapter.js → postman-adapter/sandbox-adapter.js} +43 -8
  31. package/dist/libs/execute-scripts/postman-adapter/sandbox-adapter.js.map +1 -0
  32. package/dist/libs/execute-scripts/variables-store.d.ts +22 -0
  33. package/dist/libs/execute-scripts/variables-store.d.ts.map +1 -0
  34. package/dist/libs/execute-scripts/variables-store.js +36 -0
  35. package/dist/libs/execute-scripts/variables-store.js.map +1 -0
  36. package/dist/plugins/index.d.ts +2 -0
  37. package/dist/plugins/index.d.ts.map +1 -0
  38. package/dist/plugins/index.js +2 -0
  39. package/dist/plugins/request-scripts/components/ExampleScripts.vue.d.ts.map +1 -0
  40. package/dist/plugins/{post-response-scripts/components/PostResponseScripts → request-scripts/components}/ExampleScripts.vue.js +1 -1
  41. package/dist/plugins/request-scripts/components/ExampleScripts.vue.js.map +1 -0
  42. package/dist/plugins/{post-response-scripts/components/PostResponseScripts → request-scripts/components}/ExampleScripts.vue.script.js +2 -2
  43. package/dist/plugins/request-scripts/components/ExampleScripts.vue.script.js.map +1 -0
  44. package/dist/plugins/{post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.d.ts → request-scripts/components/ScriptsSection.vue.d.ts} +3 -3
  45. package/dist/plugins/request-scripts/components/ScriptsSection.vue.d.ts.map +1 -0
  46. package/dist/plugins/request-scripts/components/ScriptsSection.vue.js +7 -0
  47. package/dist/plugins/request-scripts/components/ScriptsSection.vue.js.map +1 -0
  48. package/dist/plugins/request-scripts/components/ScriptsSection.vue.script.js +59 -0
  49. package/dist/plugins/request-scripts/components/ScriptsSection.vue.script.js.map +1 -0
  50. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResultIndicator.vue.d.ts +1 -1
  51. package/dist/plugins/request-scripts/components/TestResults/TestResultIndicator.vue.d.ts.map +1 -0
  52. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResultIndicator.vue.js +1 -1
  53. package/dist/plugins/request-scripts/components/TestResults/TestResultIndicator.vue.js.map +1 -0
  54. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResultIndicator.vue.script.js +1 -1
  55. package/dist/plugins/request-scripts/components/TestResults/TestResultIndicator.vue.script.js.map +1 -0
  56. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResultItem.vue.d.ts +1 -1
  57. package/dist/plugins/request-scripts/components/TestResults/TestResultItem.vue.d.ts.map +1 -0
  58. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResultItem.vue.js +1 -1
  59. package/dist/plugins/request-scripts/components/TestResults/TestResultItem.vue.js.map +1 -0
  60. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResultItem.vue.script.js +1 -1
  61. package/dist/plugins/request-scripts/components/TestResults/TestResultItem.vue.script.js.map +1 -0
  62. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResults.vue.d.ts +1 -1
  63. package/dist/plugins/request-scripts/components/TestResults/TestResults.vue.d.ts.map +1 -0
  64. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResults.vue.js +1 -1
  65. package/dist/plugins/request-scripts/components/TestResults/TestResults.vue.js.map +1 -0
  66. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestResults.vue.script.js +1 -1
  67. package/dist/plugins/request-scripts/components/TestResults/TestResults.vue.script.js.map +1 -0
  68. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestSummary.vue.d.ts +1 -1
  69. package/dist/plugins/request-scripts/components/TestResults/TestSummary.vue.d.ts.map +1 -0
  70. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestSummary.vue.js +1 -1
  71. package/dist/plugins/request-scripts/components/TestResults/TestSummary.vue.js.map +1 -0
  72. package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/TestSummary.vue.script.js +1 -1
  73. package/dist/plugins/request-scripts/components/TestResults/TestSummary.vue.script.js.map +1 -0
  74. package/dist/plugins/request-scripts/components/TestResults/index.d.ts.map +1 -0
  75. package/dist/plugins/request-scripts/request-scripts-plugin.d.ts +13 -0
  76. package/dist/plugins/request-scripts/request-scripts-plugin.d.ts.map +1 -0
  77. package/dist/plugins/request-scripts/request-scripts-plugin.js +55 -0
  78. package/dist/plugins/request-scripts/request-scripts-plugin.js.map +1 -0
  79. package/package.json +12 -25
  80. package/dist/_virtual/_plugin-vue_export-helper.js +0 -8
  81. package/dist/libs/execute-scripts/index.js +0 -2
  82. package/dist/libs/execute-scripts/postman-sandbox-adapter.d.ts +0 -9
  83. package/dist/libs/execute-scripts/postman-sandbox-adapter.d.ts.map +0 -1
  84. package/dist/libs/execute-scripts/postman-sandbox-adapter.js.map +0 -1
  85. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.d.ts.map +0 -1
  86. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.js.map +0 -1
  87. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.script.js.map +0 -1
  88. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.d.ts.map +0 -1
  89. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js +0 -7
  90. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js.map +0 -1
  91. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.script.js +0 -49
  92. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.script.js.map +0 -1
  93. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.d.ts.map +0 -1
  94. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.js +0 -9
  95. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.js.map +0 -1
  96. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.script.js.map +0 -1
  97. package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts +0 -2
  98. package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts.map +0 -1
  99. package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.js +0 -2
  100. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.d.ts.map +0 -1
  101. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.js.map +0 -1
  102. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.script.js.map +0 -1
  103. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.d.ts.map +0 -1
  104. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.js.map +0 -1
  105. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.script.js.map +0 -1
  106. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.d.ts.map +0 -1
  107. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.js.map +0 -1
  108. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.script.js.map +0 -1
  109. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.d.ts.map +0 -1
  110. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.js.map +0 -1
  111. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.script.js.map +0 -1
  112. package/dist/plugins/post-response-scripts/components/TestResults/index.d.ts.map +0 -1
  113. package/dist/plugins/post-response-scripts/components/TestResults/index.js +0 -2
  114. package/dist/plugins/post-response-scripts/index.d.ts +0 -2
  115. package/dist/plugins/post-response-scripts/index.d.ts.map +0 -1
  116. package/dist/plugins/post-response-scripts/index.js +0 -2
  117. package/dist/plugins/post-response-scripts/post-response-scripts-plugin.d.ts +0 -6
  118. package/dist/plugins/post-response-scripts/post-response-scripts-plugin.d.ts.map +0 -1
  119. package/dist/plugins/post-response-scripts/post-response-scripts-plugin.js +0 -61
  120. package/dist/plugins/post-response-scripts/post-response-scripts-plugin.js.map +0 -1
  121. package/dist/style.css +0 -64
  122. /package/dist/{plugins/post-response-scripts/components/PostResponseScripts → components}/ScriptEditor.vue.d.ts +0 -0
  123. /package/dist/plugins/{post-response-scripts/components/PostResponseScripts → request-scripts/components}/ExampleScripts.vue.d.ts +0 -0
  124. /package/dist/plugins/{post-response-scripts → request-scripts}/components/TestResults/index.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExampleScripts.vue.js","names":[],"sources":["../../../../src/plugins/request-scripts/components/ExampleScripts.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { EXAMPLE_SCRIPTS } from '@/consts/example-scripts'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst addExample = (example: string) => {\n let addition = example\n // Look at current value. If it's not empty, add a new line.\n if (props.modelValue.trim() !== '') {\n addition = `\\n\\n${addition}`\n }\n\n emit('update:modelValue', props.modelValue.trim() + addition)\n}\n</script>\n\n<template>\n <ul class=\"flex flex-wrap gap-1\">\n <li\n v-for=\"example in EXAMPLE_SCRIPTS\"\n :key=\"example.title\"\n class=\"bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium\">\n <button\n class=\"w-full\"\n type=\"button\"\n @click=\"addExample(example.script)\">\n {{ example.title }}\n </button>\n </li>\n </ul>\n</template>\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
- import { EXAMPLE_SCRIPTS } from "../../../../consts/example-scripts.js";
1
+ import { EXAMPLE_SCRIPTS } from "../../../consts/example-scripts.js";
2
2
  import { Fragment, createElementBlock, createElementVNode, defineComponent, openBlock, renderList, toDisplayString, unref } from "vue";
3
- //#region src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue?vue&type=script&setup=true&lang.ts
3
+ //#region src/plugins/request-scripts/components/ExampleScripts.vue?vue&type=script&setup=true&lang.ts
4
4
  var _hoisted_1 = { class: "flex flex-wrap gap-1" };
5
5
  var _hoisted_2 = ["onClick"];
6
6
  var ExampleScripts_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExampleScripts.vue.script.js","names":[],"sources":["../../../../src/plugins/request-scripts/components/ExampleScripts.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { EXAMPLE_SCRIPTS } from '@/consts/example-scripts'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst addExample = (example: string) => {\n let addition = example\n // Look at current value. If it's not empty, add a new line.\n if (props.modelValue.trim() !== '') {\n addition = `\\n\\n${addition}`\n }\n\n emit('update:modelValue', props.modelValue.trim() + addition)\n}\n</script>\n\n<template>\n <ul class=\"flex flex-wrap gap-1\">\n <li\n v-for=\"example in EXAMPLE_SCRIPTS\"\n :key=\"example.title\"\n class=\"bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium\">\n <button\n class=\"w-full\"\n type=\"button\"\n @click=\"addExample(example.script)\">\n {{ example.title }}\n </button>\n </li>\n </ul>\n</template>\n"],"mappings":";;;;;;;;;;EAGA,MAAM,QAAQ;EAId,MAAM,OAAO;EAIb,MAAM,cAAc,YAAoB;GACtC,IAAI,WAAW;AAEf,OAAI,MAAM,WAAW,MAAM,KAAK,GAC9B,YAAW,OAAO;AAGpB,QAAK,qBAAqB,MAAM,WAAW,MAAM,GAAG,SAAQ;;;uBAK5D,mBAYK,MAZL,YAYK,EAAA,UAAA,KAAA,EAXH,mBAUK,UAAA,MAAA,WATe,MAAA,gBAAe,GAA1B,YAAO;wBADhB,mBAUK,MAAA;KARF,KAAK,QAAQ;KACd,OAAM;QACN,mBAKS,UAAA;KAJP,OAAM;KACN,MAAK;KACJ,UAAK,WAAE,WAAW,QAAQ,OAAM;uBAC9B,QAAQ,MAAK,EAAA,GAAA,WAAA,CAAA,CAAA"}
@@ -1,6 +1,6 @@
1
- import type { Operation } from '@scalar/oas-utils/entities/spec';
1
+ import type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
2
2
  type __VLS_Props = {
3
- operation: Pick<Operation, 'x-post-response'>;
3
+ operation?: Pick<OperationObject, 'x-pre-request' | 'x-post-response'>;
4
4
  };
5
5
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
6
  "operation:update:extension": (payload: any) => any;
@@ -9,4 +9,4 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
9
9
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
10
  declare const _default: typeof __VLS_export;
11
11
  export default _default;
12
- //# sourceMappingURL=PostResponseScripts.vue.d.ts.map
12
+ //# sourceMappingURL=ScriptsSection.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScriptsSection.vue.d.ts","sourceRoot":"","sources":["../../../../src/plugins/request-scripts/components/ScriptsSection.vue"],"names":[],"mappings":"AA+EA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAOnG,KAAK,WAAW,GAAG;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,iBAAiB,CAAC,CAAA;CACvE,CAAC;AA2KF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,7 @@
1
+ import ScriptsSection_vue_vue_type_script_setup_true_lang_default from "./ScriptsSection.vue.script.js";
2
+ //#region src/plugins/request-scripts/components/ScriptsSection.vue
3
+ var ScriptsSection_default = ScriptsSection_vue_vue_type_script_setup_true_lang_default;
4
+ //#endregion
5
+ export { ScriptsSection_default as default };
6
+
7
+ //# sourceMappingURL=ScriptsSection.vue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScriptsSection.vue.js","names":[],"sources":["../../../../src/plugins/request-scripts/components/ScriptsSection.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport ScriptEditor from '@/components/ScriptEditor.vue'\nimport { ViewLayoutCollapse } from '@/components/ViewLayout'\nimport ExampleScripts from '@/plugins/request-scripts/components/ExampleScripts.vue'\n\nconst { operation } = defineProps<{\n operation?: Pick<OperationObject, 'x-pre-request' | 'x-post-response'>\n}>()\n\nconst emit = defineEmits<{\n (e: 'operation:update:extension', payload: any): void\n}>()\n\nconst preRequestScript = computed(\n () => (operation?.['x-pre-request'] as string) ?? '',\n)\nconst postResponseScript = computed(\n () => (operation?.['x-post-response'] as string) ?? '',\n)\n\nconst hasAnyScript = computed(\n () =>\n preRequestScript.value.length > 0 || postResponseScript.value.length > 0,\n)\n\nconst updatePreRequestScript = (value: string) => {\n emit('operation:update:extension', { 'x-pre-request': value })\n}\nconst updatePostResponseScript = (value: string) => {\n emit('operation:update:extension', { 'x-post-response': value })\n}\n</script>\n\n<template>\n <div class=\"w-full\">\n <ViewLayoutCollapse\n class=\"w-full\"\n :defaultOpen=\"true\">\n <template #title>Scripts</template>\n <template #suffix>\n <!-- Show an indicator whether we have a script -->\n <div class=\"mr-2\">\n <div\n v-if=\"hasAnyScript\"\n class=\"bg-green h-2 w-2 rounded-full\" />\n </div>\n </template>\n\n <!-- Pre-request -->\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Pre-request — run before the request is sent (e.g. set variables,\n headers).\n </div>\n <ScriptEditor\n :modelValue=\"preRequestScript\"\n @update:modelValue=\"updatePreRequestScript\" />\n\n <!-- Post-response -->\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Post-response — run after the response is received (e.g. tests,\n assertions).\n </div>\n <ScriptEditor\n :modelValue=\"postResponseScript\"\n @update:modelValue=\"updatePostResponseScript\" />\n <div class=\"border-y p-3\">\n <ExampleScripts\n :modelValue=\"postResponseScript\"\n @update:modelValue=\"updatePostResponseScript\" />\n </div>\n </ViewLayoutCollapse>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import ViewLayoutCollapse_default from "../../../components/ViewLayout/ViewLayoutCollapse.vue.js";
2
+ import ScriptEditor_default from "../../../components/ScriptEditor.vue.js";
3
+ import ExampleScripts_default from "./ExampleScripts.vue.js";
4
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, unref, withCtx } from "vue";
5
+ //#region src/plugins/request-scripts/components/ScriptsSection.vue?vue&type=script&setup=true&lang.ts
6
+ var _hoisted_1 = { class: "w-full" };
7
+ var _hoisted_2 = { class: "mr-2" };
8
+ var _hoisted_3 = {
9
+ key: 0,
10
+ class: "bg-green h-2 w-2 rounded-full"
11
+ };
12
+ var _hoisted_4 = { class: "border-y p-3" };
13
+ var ScriptsSection_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
14
+ __name: "ScriptsSection",
15
+ props: { operation: {} },
16
+ emits: ["operation:update:extension"],
17
+ setup(__props, { emit: __emit }) {
18
+ const emit = __emit;
19
+ const preRequestScript = computed(() => __props.operation?.["x-pre-request"] ?? "");
20
+ const postResponseScript = computed(() => __props.operation?.["x-post-response"] ?? "");
21
+ const hasAnyScript = computed(() => preRequestScript.value.length > 0 || postResponseScript.value.length > 0);
22
+ const updatePreRequestScript = (value) => {
23
+ emit("operation:update:extension", { "x-pre-request": value });
24
+ };
25
+ const updatePostResponseScript = (value) => {
26
+ emit("operation:update:extension", { "x-post-response": value });
27
+ };
28
+ return (_ctx, _cache) => {
29
+ return openBlock(), createElementBlock("div", _hoisted_1, [createVNode(unref(ViewLayoutCollapse_default), {
30
+ class: "w-full",
31
+ defaultOpen: true
32
+ }, {
33
+ title: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Scripts", -1)])]),
34
+ suffix: withCtx(() => [createElementVNode("div", _hoisted_2, [hasAnyScript.value ? (openBlock(), createElementBlock("div", _hoisted_3)) : createCommentVNode("", true)])]),
35
+ default: withCtx(() => [
36
+ _cache[1] || (_cache[1] = createElementVNode("div", { class: "text-c-3 flex h-8 items-center border-y px-3 text-sm" }, " Pre-request — run before the request is sent (e.g. set variables, headers). ", -1)),
37
+ createVNode(ScriptEditor_default, {
38
+ modelValue: preRequestScript.value,
39
+ "onUpdate:modelValue": updatePreRequestScript
40
+ }, null, 8, ["modelValue"]),
41
+ _cache[2] || (_cache[2] = createElementVNode("div", { class: "text-c-3 flex h-8 items-center border-y px-3 text-sm" }, " Post-response — run after the response is received (e.g. tests, assertions). ", -1)),
42
+ createVNode(ScriptEditor_default, {
43
+ modelValue: postResponseScript.value,
44
+ "onUpdate:modelValue": updatePostResponseScript
45
+ }, null, 8, ["modelValue"]),
46
+ createElementVNode("div", _hoisted_4, [createVNode(ExampleScripts_default, {
47
+ modelValue: postResponseScript.value,
48
+ "onUpdate:modelValue": updatePostResponseScript
49
+ }, null, 8, ["modelValue"])])
50
+ ]),
51
+ _: 1
52
+ })]);
53
+ };
54
+ }
55
+ });
56
+ //#endregion
57
+ export { ScriptsSection_vue_vue_type_script_setup_true_lang_default as default };
58
+
59
+ //# sourceMappingURL=ScriptsSection.vue.script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScriptsSection.vue.script.js","names":[],"sources":["../../../../src/plugins/request-scripts/components/ScriptsSection.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed } from 'vue'\n\nimport ScriptEditor from '@/components/ScriptEditor.vue'\nimport { ViewLayoutCollapse } from '@/components/ViewLayout'\nimport ExampleScripts from '@/plugins/request-scripts/components/ExampleScripts.vue'\n\nconst { operation } = defineProps<{\n operation?: Pick<OperationObject, 'x-pre-request' | 'x-post-response'>\n}>()\n\nconst emit = defineEmits<{\n (e: 'operation:update:extension', payload: any): void\n}>()\n\nconst preRequestScript = computed(\n () => (operation?.['x-pre-request'] as string) ?? '',\n)\nconst postResponseScript = computed(\n () => (operation?.['x-post-response'] as string) ?? '',\n)\n\nconst hasAnyScript = computed(\n () =>\n preRequestScript.value.length > 0 || postResponseScript.value.length > 0,\n)\n\nconst updatePreRequestScript = (value: string) => {\n emit('operation:update:extension', { 'x-pre-request': value })\n}\nconst updatePostResponseScript = (value: string) => {\n emit('operation:update:extension', { 'x-post-response': value })\n}\n</script>\n\n<template>\n <div class=\"w-full\">\n <ViewLayoutCollapse\n class=\"w-full\"\n :defaultOpen=\"true\">\n <template #title>Scripts</template>\n <template #suffix>\n <!-- Show an indicator whether we have a script -->\n <div class=\"mr-2\">\n <div\n v-if=\"hasAnyScript\"\n class=\"bg-green h-2 w-2 rounded-full\" />\n </div>\n </template>\n\n <!-- Pre-request -->\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Pre-request — run before the request is sent (e.g. set variables,\n headers).\n </div>\n <ScriptEditor\n :modelValue=\"preRequestScript\"\n @update:modelValue=\"updatePreRequestScript\" />\n\n <!-- Post-response -->\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Post-response — run after the response is received (e.g. tests,\n assertions).\n </div>\n <ScriptEditor\n :modelValue=\"postResponseScript\"\n @update:modelValue=\"updatePostResponseScript\" />\n <div class=\"border-y p-3\">\n <ExampleScripts\n :modelValue=\"postResponseScript\"\n @update:modelValue=\"updatePostResponseScript\" />\n </div>\n </ViewLayoutCollapse>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAYA,MAAM,OAAO;EAIb,MAAM,mBAAmB,eAChB,QAAA,YAAY,oBAA+B,GACpD;EACA,MAAM,qBAAqB,eAClB,QAAA,YAAY,sBAAiC,GACtD;EAEA,MAAM,eAAe,eAEjB,iBAAiB,MAAM,SAAS,KAAK,mBAAmB,MAAM,SAAS,EAC3E;EAEA,MAAM,0BAA0B,UAAkB;AAChD,QAAK,8BAA8B,EAAE,iBAAiB,OAAO,CAAA;;EAE/D,MAAM,4BAA4B,UAAkB;AAClD,QAAK,8BAA8B,EAAE,mBAAmB,OAAO,CAAA;;;uBAK/D,mBAqCM,OArCN,YAqCM,CApCJ,YAmCqB,MAAA,2BAAA,EAAA;IAlCnB,OAAM;IACL,aAAa;;IACH,OAAK,cAAQ,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAP,WAAO,GAAA,CAAA,EAAA,CAAA;IACb,QAAM,cAMT,CAJN,mBAIM,OAJN,YAIM,CAFI,aAAA,SAAA,WAAA,EADR,mBAE0C,OAF1C,WAE0C,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA,CAAA,CAAA;2BAQxC;+BAHN,mBAGM,OAAA,EAHD,OAAM,wDAAsD,EAAC,iFAGlE,GAAA;KACA,YAEgD,sBAAA;MAD7C,YAAY,iBAAA;MACZ,uBAAmB;;+BAGtB,mBAGM,OAAA,EAHD,OAAM,wDAAsD,EAAC,kFAGlE,GAAA;KACA,YAEkD,sBAAA;MAD/C,YAAY,mBAAA;MACZ,uBAAmB;;KACtB,mBAIM,OAJN,YAIM,CAHJ,YAEkD,wBAAA;MAD/C,YAAY,mBAAA;MACZ,uBAAmB"}
@@ -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;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResultIndicator.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/request-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"}
@@ -1,5 +1,5 @@
1
1
  import TestResultIndicator_vue_vue_type_script_setup_true_lang_default from "./TestResultIndicator.vue.script.js";
2
- //#region src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue
2
+ //#region src/plugins/request-scripts/components/TestResults/TestResultIndicator.vue
3
3
  var TestResultIndicator_default = TestResultIndicator_vue_vue_type_script_setup_true_lang_default;
4
4
  //#endregion
5
5
  export { TestResultIndicator_default as default };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResultIndicator.vue.js","names":[],"sources":["../../../../../src/plugins/request-scripts/components/TestResults/TestResultIndicator.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { cva, ScalarIcon, useBindCx, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { state, totalTestsCount, pendingTestsCount, failedTestsCount } =\n defineProps<{\n state?: TestResult['status']\n failedTestsCount: number | undefined\n pendingTestsCount: number | undefined\n totalTestsCount: number | undefined\n inline?: boolean\n }>()\n\nconst { cx } = useBindCx()\n\nconst icon = computed(() => {\n if (state === 'passed') {\n return { name: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (state === 'failed') {\n return { name: 'Close', color: 'text-red' }\n }\n\n return { name: 'Ellipses', color: 'text-c-1' }\n})\n\nconst statusVariants = cva({\n base: 'flex items-center gap-1.5 rounded-full border pr-2 pl-1.25',\n variants: {\n status: {\n passed: 'text-green',\n failed: 'text-red',\n pending: 'text-orange',\n },\n },\n})\n\nconst textVariants = cva({\n base: 'text-c-2',\n variants: {\n inline: {\n true: 'text-xs',\n false: 'text-sm',\n },\n },\n})\n\n// Display the number of tests that passed e.g 1/3\nconst getTestCountDisplay = computed(() => {\n // When there are no tests, show nothing\n if (totalTestsCount === undefined) {\n return ''\n }\n\n // When they failed, show failed/total\n if (failedTestsCount) {\n return `${failedTestsCount}/${totalTestsCount}`\n }\n\n // When they passed, show passed/total\n const completedTests =\n totalTestsCount - (pendingTestsCount || 0) - (failedTestsCount || 0)\n return `${completedTests}/${totalTestsCount}`\n})\n</script>\n\n<template>\n <div v-bind=\"cx(statusVariants({ status: state }))\">\n <ScalarIcon\n v-if=\"state\"\n :class=\"icon.color\"\n :icon=\"icon.name as Icon\"\n size=\"sm\" />\n <span\n v-if=\"!inline\"\n class=\"ml-1.25 capitalize\">\n {{ state }}\n </span>\n <span\n v-if=\"totalTestsCount !== undefined\"\n v-bind=\"cx(textVariants({ inline }))\">\n {{ getTestCountDisplay }}\n </span>\n </div>\n</template>\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { computed, createBlock, createCommentVNode, createElementBlock, defineComponent, guardReactiveProps, mergeProps, normalizeClass, normalizeProps, openBlock, toDisplayString, unref } from "vue";
2
2
  import { ScalarIcon, cva, useBindCx } from "@scalar/components";
3
- //#region src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue?vue&type=script&setup=true&lang.ts
3
+ //#region src/plugins/request-scripts/components/TestResults/TestResultIndicator.vue?vue&type=script&setup=true&lang.ts
4
4
  var _hoisted_1 = {
5
5
  key: 1,
6
6
  class: "ml-1.25 capitalize"
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResultIndicator.vue.script.js","names":[],"sources":["../../../../../src/plugins/request-scripts/components/TestResults/TestResultIndicator.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { cva, ScalarIcon, useBindCx, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { state, totalTestsCount, pendingTestsCount, failedTestsCount } =\n defineProps<{\n state?: TestResult['status']\n failedTestsCount: number | undefined\n pendingTestsCount: number | undefined\n totalTestsCount: number | undefined\n inline?: boolean\n }>()\n\nconst { cx } = useBindCx()\n\nconst icon = computed(() => {\n if (state === 'passed') {\n return { name: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (state === 'failed') {\n return { name: 'Close', color: 'text-red' }\n }\n\n return { name: 'Ellipses', color: 'text-c-1' }\n})\n\nconst statusVariants = cva({\n base: 'flex items-center gap-1.5 rounded-full border pr-2 pl-1.25',\n variants: {\n status: {\n passed: 'text-green',\n failed: 'text-red',\n pending: 'text-orange',\n },\n },\n})\n\nconst textVariants = cva({\n base: 'text-c-2',\n variants: {\n inline: {\n true: 'text-xs',\n false: 'text-sm',\n },\n },\n})\n\n// Display the number of tests that passed e.g 1/3\nconst getTestCountDisplay = computed(() => {\n // When there are no tests, show nothing\n if (totalTestsCount === undefined) {\n return ''\n }\n\n // When they failed, show failed/total\n if (failedTestsCount) {\n return `${failedTestsCount}/${totalTestsCount}`\n }\n\n // When they passed, show passed/total\n const completedTests =\n totalTestsCount - (pendingTestsCount || 0) - (failedTestsCount || 0)\n return `${completedTests}/${totalTestsCount}`\n})\n</script>\n\n<template>\n <div v-bind=\"cx(statusVariants({ status: state }))\">\n <ScalarIcon\n v-if=\"state\"\n :class=\"icon.color\"\n :icon=\"icon.name as Icon\"\n size=\"sm\" />\n <span\n v-if=\"!inline\"\n class=\"ml-1.25 capitalize\">\n {{ state }}\n </span>\n <span\n v-if=\"totalTestsCount !== undefined\"\n v-bind=\"cx(textVariants({ inline }))\">\n {{ getTestCountDisplay }}\n </span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAeA,MAAM,EAAE,OAAO,WAAU;EAEzB,MAAM,OAAO,eAAe;AAC1B,OAAI,QAAA,UAAU,SACZ,QAAO;IAAE,MAAM;IAAa,OAAO;IAAoB;AAGzD,OAAI,QAAA,UAAU,SACZ,QAAO;IAAE,MAAM;IAAS,OAAO;IAAW;AAG5C,UAAO;IAAE,MAAM;IAAY,OAAO;IAAW;IAC9C;EAED,MAAM,iBAAiB,IAAI;GACzB,MAAM;GACN,UAAU,EACR,QAAQ;IACN,QAAQ;IACR,QAAQ;IACR,SAAS;IACV,EACF;GACF,CAAA;EAED,MAAM,eAAe,IAAI;GACvB,MAAM;GACN,UAAU,EACR,QAAQ;IACN,MAAM;IACN,OAAO;IACR,EACF;GACF,CAAA;EAGD,MAAM,sBAAsB,eAAe;AAEzC,OAAI,QAAA,oBAAoB,KAAA,EACtB,QAAO;AAIT,OAAI,QAAA,iBACF,QAAO,GAAG,QAAA,iBAAiB,GAAG,QAAA;AAMhC,UAAO,GADL,QAAA,mBAAmB,QAAA,qBAAqB,MAAM,QAAA,oBAAoB,GAC3C,GAAG,QAAA;IAC7B;;uBAIC,mBAgBM,OAAA,eAAA,mBAhBO,MAAA,GAAE,CAAC,MAAA,eAAc,CAAA,EAAA,QAAW,QAAA,OAAK,CAAA,CAAA,CAAA,CAAA,EAAA;IAEpC,QAAA,SAAA,WAAA,EADR,YAIc,MAAA,WAAA,EAAA;;KAFX,OAAK,eAAE,KAAA,MAAK,MAAK;KACjB,MAAM,KAAA,MAAK;KACZ,MAAK;;KAEE,QAAA,UAAA,WAAA,EADT,mBAIO,QAJP,YAIO,gBADF,QAAA,MAAK,EAAA,EAAA,IAAA,mBAAA,IAAA,KAAA;IAGF,QAAA,oBAAoB,KAAA,KAAA,WAAA,EAD5B,mBAIO,QAAA,eAAA,WAAA,EAAA,KAAA,GAAA,EAFG,MAAA,GAAE,CAAC,MAAA,aAAY,CAAA,EAAA,QAAG,QAAA,QAAM,CAAA,CAAA,CAAA,CAAA,EAAA,gBAC7B,oBAAA,MAAmB,EAAA,GAAA,IAAA,mBAAA,IAAA,KAAA"}
@@ -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'];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResultItem.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/request-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"}
@@ -1,5 +1,5 @@
1
1
  import TestResultItem_vue_vue_type_script_setup_true_lang_default from "./TestResultItem.vue.script.js";
2
- //#region src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue
2
+ //#region src/plugins/request-scripts/components/TestResults/TestResultItem.vue
3
3
  var TestResultItem_default = TestResultItem_vue_vue_type_script_setup_true_lang_default;
4
4
  //#endregion
5
5
  export { TestResultItem_default as default };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResultItem.vue.js","names":[],"sources":["../../../../../src/plugins/request-scripts/components/TestResults/TestResultItem.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIcon, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { currentState, result } = defineProps<{\n result: TestResult\n currentState: TestResult['status']\n}>()\n\nconst resultStatus = computed(() => {\n if (result.passed) {\n return { icon: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (!result.passed && currentState !== 'pending') {\n return { icon: 'Close', color: 'text-red' }\n }\n\n return { icon: 'Ellipses', color: 'text-c-1' }\n})\n</script>\n\n<template>\n <div class=\"flex flex-col\">\n <div\n class=\"flex h-8 items-center gap-2 pr-3 pl-2.25\"\n :class=\"result.error && 'bg-b-danger'\">\n <!-- Title -->\n <div class=\"flex items-center gap-3 p-2\">\n <ScalarIcon\n :class=\"resultStatus.color\"\n :icon=\"resultStatus.icon as Icon\"\n size=\"sm\" />\n\n <span class=\"text-c-2 overflow-hidden text-ellipsis whitespace-nowrap\">\n {{ result.title }}\n </span>\n </div>\n <!-- Duration -->\n <span class=\"text-c-3 ml-auto whitespace-nowrap\">\n {{ result.duration }} ms\n </span>\n </div>\n <!-- Error -->\n <div\n v-if=\"result.error\"\n class=\"bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9\">\n {{ result.error }}\n </div>\n </div>\n</template>\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, toDisplayString, unref } from "vue";
2
2
  import { ScalarIcon } from "@scalar/components";
3
- //#region src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue?vue&type=script&setup=true&lang.ts
3
+ //#region src/plugins/request-scripts/components/TestResults/TestResultItem.vue?vue&type=script&setup=true&lang.ts
4
4
  var _hoisted_1 = { class: "flex flex-col" };
5
5
  var _hoisted_2 = { class: "flex items-center gap-3 p-2" };
6
6
  var _hoisted_3 = { class: "text-c-2 overflow-hidden text-ellipsis whitespace-nowrap" };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResultItem.vue.script.js","names":[],"sources":["../../../../../src/plugins/request-scripts/components/TestResults/TestResultItem.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIcon, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { currentState, result } = defineProps<{\n result: TestResult\n currentState: TestResult['status']\n}>()\n\nconst resultStatus = computed(() => {\n if (result.passed) {\n return { icon: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (!result.passed && currentState !== 'pending') {\n return { icon: 'Close', color: 'text-red' }\n }\n\n return { icon: 'Ellipses', color: 'text-c-1' }\n})\n</script>\n\n<template>\n <div class=\"flex flex-col\">\n <div\n class=\"flex h-8 items-center gap-2 pr-3 pl-2.25\"\n :class=\"result.error && 'bg-b-danger'\">\n <!-- Title -->\n <div class=\"flex items-center gap-3 p-2\">\n <ScalarIcon\n :class=\"resultStatus.color\"\n :icon=\"resultStatus.icon as Icon\"\n size=\"sm\" />\n\n <span class=\"text-c-2 overflow-hidden text-ellipsis whitespace-nowrap\">\n {{ result.title }}\n </span>\n </div>\n <!-- Duration -->\n <span class=\"text-c-3 ml-auto whitespace-nowrap\">\n {{ result.duration }} ms\n </span>\n </div>\n <!-- Error -->\n <div\n v-if=\"result.error\"\n class=\"bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9\">\n {{ result.error }}\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;EAWA,MAAM,eAAe,eAAe;AAClC,OAAI,QAAA,OAAO,OACT,QAAO;IAAE,MAAM;IAAa,OAAO;IAAoB;AAGzD,OAAI,CAAC,QAAA,OAAO,UAAU,QAAA,iBAAiB,UACrC,QAAO;IAAE,MAAM;IAAS,OAAO;IAAW;AAG5C,UAAO;IAAE,MAAM;IAAY,OAAO;IAAW;IAC9C;;uBAIC,mBA0BM,OA1BN,YA0BM,CAzBJ,mBAkBM,OAAA,EAjBJ,OAAK,eAAA,CAAC,4CACE,QAAA,OAAO,SAAK,cAAA,CAAA,EAAA,EAAA,CAEpB,mBASM,OATN,YASM,CARJ,YAGc,MAAA,WAAA,EAAA;IAFX,OAAK,eAAE,aAAA,MAAa,MAAK;IACzB,MAAM,aAAA,MAAa;IACpB,MAAK;mCAEP,mBAEO,QAFP,YAEO,gBADF,QAAA,OAAO,MAAK,EAAA,EAAA,CAAA,CAAA,EAInB,mBAEO,QAFP,YAEO,gBADF,QAAA,OAAO,SAAQ,GAAG,QACvB,EAAA,CAAA,EAAA,EAAA,EAIM,QAAA,OAAO,SAAA,WAAA,EADf,mBAIM,OAJN,YAIM,gBADD,QAAA,OAAO,MAAK,EAAA,EAAA,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA"}
@@ -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
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResults.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/request-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"}
@@ -1,5 +1,5 @@
1
1
  import TestResults_vue_vue_type_script_setup_true_lang_default from "./TestResults.vue.script.js";
2
- //#region src/plugins/post-response-scripts/components/TestResults/TestResults.vue
2
+ //#region src/plugins/request-scripts/components/TestResults/TestResults.vue
3
3
  var TestResults_default = TestResults_vue_vue_type_script_setup_true_lang_default;
4
4
  //#endregion
5
5
  export { TestResults_default as default };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResults.vue.js","names":[],"sources":["../../../../../src/plugins/request-scripts/components/TestResults/TestResults.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, type Ref } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport { ViewLayoutCollapse } from '../../../../components/ViewLayout'\nimport TestResultIndicator from './TestResultIndicator.vue'\nimport TestResultItem from './TestResultItem.vue'\nimport TestSummary from './TestSummary.vue'\n\nconst { results } = defineProps<{\n results?: Ref<TestResult[]> | undefined\n}>()\n\nconst passedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'passed'),\n)\n\nconst pendingTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'pending'),\n)\n\nconst failedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'failed'),\n)\n\nconst allTestsPassed = computed(\n () => passedTests.value?.length === results?.value?.length,\n)\n\nconst currentState = computed(() => {\n if (allTestsPassed.value) {\n return 'passed'\n }\n\n if (pendingTests.value?.length) {\n return 'pending'\n }\n\n return 'failed'\n})\n\nconst totalDuration = computed(\n () =>\n results?.value?.reduce(\n (acc: number, curr: TestResult) => acc + curr.duration,\n 0,\n ) ?? 0,\n)\n</script>\n\n<template>\n <ViewLayoutCollapse\n v-if=\"results?.value?.length\"\n class=\"overflow-auto text-sm\"\n :defaultOpen=\"true\">\n <template #title> Tests </template>\n <template #suffix>\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n inline\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"currentState\"\n :totalTestsCount=\"results?.value?.length\" />\n </template>\n\n <div class=\"max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t\">\n <!-- Results -->\n <TestResultItem\n v-for=\"result in results?.value\"\n :key=\"result.title\"\n :currentState=\"result.status\"\n :result=\"result\" />\n\n <TestSummary\n v-if=\"results\"\n :allTestsPassed=\"allTestsPassed\"\n :failedTests=\"failedTests ?? []\"\n :passedTests=\"passedTests ?? []\"\n :pendingTests=\"pendingTests ?? []\"\n :results=\"results?.value\"\n :totalDuration=\"totalDuration\" />\n </div>\n </ViewLayoutCollapse>\n</template>\n"],"mappings":""}
@@ -3,7 +3,7 @@ import TestResultIndicator_default from "./TestResultIndicator.vue.js";
3
3
  import TestResultItem_default from "./TestResultItem.vue.js";
4
4
  import TestSummary_default from "./TestSummary.vue.js";
5
5
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, renderList, unref, withCtx } from "vue";
6
- //#region src/plugins/post-response-scripts/components/TestResults/TestResults.vue?vue&type=script&setup=true&lang.ts
6
+ //#region src/plugins/request-scripts/components/TestResults/TestResults.vue?vue&type=script&setup=true&lang.ts
7
7
  var _hoisted_1 = { class: "max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t" };
8
8
  var TestResults_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
9
9
  __name: "TestResults",
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestResults.vue.script.js","names":[],"sources":["../../../../../src/plugins/request-scripts/components/TestResults/TestResults.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, type Ref } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport { ViewLayoutCollapse } from '../../../../components/ViewLayout'\nimport TestResultIndicator from './TestResultIndicator.vue'\nimport TestResultItem from './TestResultItem.vue'\nimport TestSummary from './TestSummary.vue'\n\nconst { results } = defineProps<{\n results?: Ref<TestResult[]> | undefined\n}>()\n\nconst passedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'passed'),\n)\n\nconst pendingTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'pending'),\n)\n\nconst failedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'failed'),\n)\n\nconst allTestsPassed = computed(\n () => passedTests.value?.length === results?.value?.length,\n)\n\nconst currentState = computed(() => {\n if (allTestsPassed.value) {\n return 'passed'\n }\n\n if (pendingTests.value?.length) {\n return 'pending'\n }\n\n return 'failed'\n})\n\nconst totalDuration = computed(\n () =>\n results?.value?.reduce(\n (acc: number, curr: TestResult) => acc + curr.duration,\n 0,\n ) ?? 0,\n)\n</script>\n\n<template>\n <ViewLayoutCollapse\n v-if=\"results?.value?.length\"\n class=\"overflow-auto text-sm\"\n :defaultOpen=\"true\">\n <template #title> Tests </template>\n <template #suffix>\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n inline\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"currentState\"\n :totalTestsCount=\"results?.value?.length\" />\n </template>\n\n <div class=\"max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t\">\n <!-- Results -->\n <TestResultItem\n v-for=\"result in results?.value\"\n :key=\"result.title\"\n :currentState=\"result.status\"\n :result=\"result\" />\n\n <TestSummary\n v-if=\"results\"\n :allTestsPassed=\"allTestsPassed\"\n :failedTests=\"failedTests ?? []\"\n :passedTests=\"passedTests ?? []\"\n :pendingTests=\"pendingTests ?? []\"\n :results=\"results?.value\"\n :totalDuration=\"totalDuration\" />\n </div>\n </ViewLayoutCollapse>\n</template>\n"],"mappings":";;;;;;;;;;;EAcA,MAAM,cAAc,eAClB,QAAA,SAAS,OAAO,QAAQ,WAAuB,OAAO,WAAW,SAAS,CAC5E;EAEA,MAAM,eAAe,eACnB,QAAA,SAAS,OAAO,QAAQ,WAAuB,OAAO,WAAW,UAAU,CAC7E;EAEA,MAAM,cAAc,eAClB,QAAA,SAAS,OAAO,QAAQ,WAAuB,OAAO,WAAW,SAAS,CAC5E;EAEA,MAAM,iBAAiB,eACf,YAAY,OAAO,WAAW,QAAA,SAAS,OAAO,OACtD;EAEA,MAAM,eAAe,eAAe;AAClC,OAAI,eAAe,MACjB,QAAO;AAGT,OAAI,aAAa,OAAO,OACtB,QAAO;AAGT,UAAO;IACR;EAED,MAAM,gBAAgB,eAElB,QAAA,SAAS,OAAO,QACb,KAAa,SAAqB,MAAM,KAAK,UAC9C,EACD,IAAI,EACT;;UAKU,QAAA,SAAS,OAAO,UAAA,WAAA,EADxB,YAgCqB,MAAA,2BAAA,EAAA;;IA9BnB,OAAM;IACL,aAAa;;IACH,OAAK,cAAQ,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAP,WAAO,GAAA,CAAA,EAAA,CAAA;IACb,QAAM,cAO+B,CAN9C,YAM8C,6BAAA;KAL3C,kBAAkB,YAAA,OAAa;KAChC,QAAA;KACC,kBAAkB,YAAA,OAAa;KAC/B,mBAAmB,aAAA,OAAc;KACjC,OAAO,aAAA;KACP,iBAAiB,QAAA,SAAS,OAAO;;;;;;;;2BAmBhC,CAhBN,mBAgBM,OAhBN,YAgBM,EAAA,UAAA,KAAA,EAdJ,mBAIqB,UAAA,MAAA,WAHF,QAAA,SAAS,QAAnB,WAAM;yBADf,YAIqB,wBAAA;MAFlB,KAAK,OAAO;MACZ,cAAc,OAAO;MACb;;eAGH,QAAA,WAAA,WAAA,EADR,YAOmC,qBAAA;;KALhC,gBAAgB,eAAA;KAChB,aAAa,YAAA,SAAW,EAAA;KACxB,aAAa,YAAA,SAAW,EAAA;KACxB,cAAc,aAAA,SAAY,EAAA;KAC1B,SAAS,QAAA,SAAS;KAClB,eAAe,cAAA"}
@@ -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[];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestSummary.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/request-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"}
@@ -1,5 +1,5 @@
1
1
  import TestSummary_vue_vue_type_script_setup_true_lang_default from "./TestSummary.vue.script.js";
2
- //#region src/plugins/post-response-scripts/components/TestResults/TestSummary.vue
2
+ //#region src/plugins/request-scripts/components/TestResults/TestSummary.vue
3
3
  var TestSummary_default = TestSummary_vue_vue_type_script_setup_true_lang_default;
4
4
  //#endregion
5
5
  export { TestSummary_default as default };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestSummary.vue.js","names":[],"sources":["../../../../../src/plugins/request-scripts/components/TestResults/TestSummary.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport TestResultIndicator from './TestResultIndicator.vue'\n\ndefineProps<{\n results: TestResult[]\n passedTests: TestResult[]\n failedTests: TestResult[]\n pendingTests: TestResult[]\n allTestsPassed: boolean\n totalDuration: number\n}>()\n</script>\n\n<template>\n <div class=\"flex h-8 items-center gap-1.5 pr-3 pl-1\">\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"allTestsPassed ? 'passed' : 'failed'\"\n :totalTestsCount=\"results?.length\" />\n <span\n v-if=\"pendingTests?.length\"\n class=\"text-orange\">\n {{ pendingTests?.length }}\n Pending\n </span>\n <span class=\"text-c-3 ml-auto\"> {{ totalDuration.toFixed(1) }} ms </span>\n </div>\n</template>\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import TestResultIndicator_default from "./TestResultIndicator.vue.js";
2
2
  import { createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, toDisplayString } from "vue";
3
- //#region src/plugins/post-response-scripts/components/TestResults/TestSummary.vue?vue&type=script&setup=true&lang.ts
3
+ //#region src/plugins/request-scripts/components/TestResults/TestSummary.vue?vue&type=script&setup=true&lang.ts
4
4
  var _hoisted_1 = { class: "flex h-8 items-center gap-1.5 pr-3 pl-1" };
5
5
  var _hoisted_2 = {
6
6
  key: 0,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestSummary.vue.script.js","names":[],"sources":["../../../../../src/plugins/request-scripts/components/TestResults/TestSummary.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport TestResultIndicator from './TestResultIndicator.vue'\n\ndefineProps<{\n results: TestResult[]\n passedTests: TestResult[]\n failedTests: TestResult[]\n pendingTests: TestResult[]\n allTestsPassed: boolean\n totalDuration: number\n}>()\n</script>\n\n<template>\n <div class=\"flex h-8 items-center gap-1.5 pr-3 pl-1\">\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"allTestsPassed ? 'passed' : 'failed'\"\n :totalTestsCount=\"results?.length\" />\n <span\n v-if=\"pendingTests?.length\"\n class=\"text-orange\">\n {{ pendingTests?.length }}\n Pending\n </span>\n <span class=\"text-c-3 ml-auto\"> {{ totalDuration.toFixed(1) }} ms </span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;uBAgBE,mBAcM,OAdN,YAcM;IAbJ,YAKuC,6BAAA;KAJpC,kBAAkB,QAAA,aAAa;KAC/B,kBAAkB,QAAA,aAAa;KAC/B,mBAAmB,QAAA,cAAc;KACjC,OAAO,QAAA,iBAAc,WAAA;KACrB,iBAAiB,QAAA,SAAS;;;;;;;;IAErB,QAAA,cAAc,UAAA,WAAA,EADtB,mBAKO,QALP,YAKO,gBAFF,QAAA,cAAc,OAAM,GAAG,aAE5B,EAAA,IAAA,mBAAA,IAAA,KAAA;IACA,mBAAyE,QAAzE,YAAyE,gBAAtC,QAAA,cAAc,QAAO,EAAA,CAAA,GAAM,QAAI,EAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/request-scripts/components/TestResults/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import type { ClientPlugin } from '@scalar/oas-utils/helpers';
2
+ /**
3
+ * Unified request scripts plugin for client V2. Provides a single "Scripts"
4
+ * section with:
5
+ * - Pre-request script editor (x-pre-request) — runs before each request
6
+ * - Post-response script editor (x-post-response) — runs after each response
7
+ * - Test results from post-response assertions, shown in the response section
8
+ *
9
+ * Hooks: beforeRequest runs pre-request scripts and resets results;
10
+ * responseReceived runs post-response scripts and updates test results.
11
+ */
12
+ export declare const requestScriptsPlugin: () => ClientPlugin;
13
+ //# sourceMappingURL=request-scripts-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-scripts-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/request-scripts/request-scripts-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAe7D;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,QAAO,YAwCvC,CAAA"}
@@ -0,0 +1,55 @@
1
+ import { executePostResponseScript } from "../../libs/execute-scripts/execute-post-response-script.js";
2
+ import { executePreRequestScript } from "../../libs/execute-scripts/execute-pre-request-script.js";
3
+ import TestResults_default from "./components/TestResults/TestResults.vue.js";
4
+ import ScriptsSection_default from "./components/ScriptsSection.vue.js";
5
+ import { ref } from "vue";
6
+ //#region src/plugins/request-scripts/request-scripts-plugin.ts
7
+ var getScript = (...args) => {
8
+ return args.map((script) => script?.trim()).filter((script) => typeof script === "string" && script.length > 0).join("\n");
9
+ };
10
+ /**
11
+ * Unified request scripts plugin for client V2. Provides a single "Scripts"
12
+ * section with:
13
+ * - Pre-request script editor (x-pre-request) — runs before each request
14
+ * - Post-response script editor (x-post-response) — runs after each response
15
+ * - Test results from post-response assertions, shown in the response section
16
+ *
17
+ * Hooks: beforeRequest runs pre-request scripts and resets results;
18
+ * responseReceived runs post-response scripts and updates test results.
19
+ */
20
+ var requestScriptsPlugin = () => {
21
+ const results = ref([]);
22
+ return {
23
+ components: {
24
+ request: { component: ScriptsSection_default },
25
+ response: {
26
+ component: TestResults_default,
27
+ additionalProps: { results }
28
+ }
29
+ },
30
+ hooks: {
31
+ beforeRequest: async ({ requestBuilder, document, operation, variablesStore }) => {
32
+ results.value = [];
33
+ await executePreRequestScript(getScript(document["x-pre-request"], operation["x-pre-request"]), {
34
+ requestBuilder,
35
+ variablesStore,
36
+ onTestResultsUpdate: (newResults) => results.value = [...newResults]
37
+ });
38
+ },
39
+ responseReceived: async ({ requestBuilder, response, operation, document, variablesStore }) => {
40
+ const script = getScript(document["x-post-response"], operation["x-post-response"]);
41
+ const preRequestResults = [...results.value];
42
+ await executePostResponseScript(script, {
43
+ requestBuilder,
44
+ response,
45
+ onTestResultsUpdate: (postResponseResults) => results.value = [...preRequestResults, ...postResponseResults],
46
+ variablesStore
47
+ });
48
+ }
49
+ }
50
+ };
51
+ };
52
+ //#endregion
53
+ export { requestScriptsPlugin };
54
+
55
+ //# sourceMappingURL=request-scripts-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-scripts-plugin.js","names":[],"sources":["../../../src/plugins/request-scripts/request-scripts-plugin.ts"],"sourcesContent":["import type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport { ref } from 'vue'\n\nimport { type TestResult, executePostResponseScript, executePreRequestScript } from '@/libs/execute-scripts'\nimport { TestResults } from '@/plugins/request-scripts/components/TestResults'\n\nimport ScriptsSection from './components/ScriptsSection.vue'\n\nconst getScript = (...args: (string | undefined | null)[]): string => {\n return args\n .map((script) => script?.trim())\n .filter((script) => typeof script === 'string' && script.length > 0)\n .join('\\n')\n}\n\n/**\n * Unified request scripts plugin for client V2. Provides a single \"Scripts\"\n * section with:\n * - Pre-request script editor (x-pre-request) — runs before each request\n * - Post-response script editor (x-post-response) — runs after each response\n * - Test results from post-response assertions, shown in the response section\n *\n * Hooks: beforeRequest runs pre-request scripts and resets results;\n * responseReceived runs post-response scripts and updates test results.\n */\nexport const requestScriptsPlugin = (): ClientPlugin => {\n const results = ref<TestResult[]>([])\n\n return {\n components: {\n request: {\n component: ScriptsSection,\n },\n response: {\n component: TestResults,\n additionalProps: { results },\n },\n },\n\n hooks: {\n beforeRequest: async ({ requestBuilder, document, operation, variablesStore }) => {\n // Reset test results when a new request is sent\n results.value = []\n const script = getScript(document['x-pre-request'], operation['x-pre-request'])\n await executePreRequestScript(script, {\n requestBuilder,\n variablesStore,\n onTestResultsUpdate: (newResults) => (results.value = [...newResults]),\n })\n },\n\n responseReceived: async ({ requestBuilder, response, operation, document, variablesStore }) => {\n const script = getScript(document['x-post-response'], operation['x-post-response'])\n // Snapshot pre-request results before running post-response script\n const preRequestResults = [...results.value]\n await executePostResponseScript(script, {\n requestBuilder,\n response,\n onTestResultsUpdate: (postResponseResults) =>\n (results.value = [...preRequestResults, ...postResponseResults]),\n variablesStore,\n })\n },\n },\n }\n}\n"],"mappings":";;;;;;AAQA,IAAM,aAAa,GAAG,SAAgD;AACpE,QAAO,KACJ,KAAK,WAAW,QAAQ,MAAM,CAAC,CAC/B,QAAQ,WAAW,OAAO,WAAW,YAAY,OAAO,SAAS,EAAE,CACnE,KAAK,KAAK;;;;;;;;;;;;AAaf,IAAa,6BAA2C;CACtD,MAAM,UAAU,IAAkB,EAAE,CAAC;AAErC,QAAO;EACL,YAAY;GACV,SAAS,EACP,WAAW,wBACZ;GACD,UAAU;IACR,WAAW;IACX,iBAAiB,EAAE,SAAS;IAC7B;GACF;EAED,OAAO;GACL,eAAe,OAAO,EAAE,gBAAgB,UAAU,WAAW,qBAAqB;AAEhF,YAAQ,QAAQ,EAAE;AAElB,UAAM,wBADS,UAAU,SAAS,kBAAkB,UAAU,iBAAiB,EACzC;KACpC;KACA;KACA,sBAAsB,eAAgB,QAAQ,QAAQ,CAAC,GAAG,WAAW;KACtE,CAAC;;GAGJ,kBAAkB,OAAO,EAAE,gBAAgB,UAAU,WAAW,UAAU,qBAAqB;IAC7F,MAAM,SAAS,UAAU,SAAS,oBAAoB,UAAU,mBAAmB;IAEnF,MAAM,oBAAoB,CAAC,GAAG,QAAQ,MAAM;AAC5C,UAAM,0BAA0B,QAAQ;KACtC;KACA;KACA,sBAAsB,wBACnB,QAAQ,QAAQ,CAAC,GAAG,mBAAmB,GAAG,oBAAoB;KACjE;KACD,CAAC;;GAEL;EACF"}
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "post-response scripts",
20
20
  "api client"
21
21
  ],
22
- "version": "0.3.18",
22
+ "version": "0.4.1",
23
23
  "engines": {
24
24
  "node": ">=22"
25
25
  },
@@ -37,25 +37,10 @@
37
37
  "require": "./dist/*.css",
38
38
  "default": "./dist/*.css"
39
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"
40
+ "./plugins": {
41
+ "import": "./dist/plugins/index.js",
42
+ "types": "./dist/plugins/index.d.ts",
43
+ "default": "./dist/plugins/index.js"
59
44
  }
60
45
  },
61
46
  "files": [
@@ -67,15 +52,17 @@
67
52
  "@headlessui/vue": "1.7.23",
68
53
  "postman-sandbox": "^6.6.1",
69
54
  "vue": "^3.5.30",
70
- "@scalar/components": "0.21.3",
71
- "@scalar/oas-utils": "0.10.16"
55
+ "@types/postman-collection": "^3.5.11",
56
+ "postman-collection": "^5.2.0",
57
+ "@scalar/components": "0.21.4",
58
+ "@scalar/oas-utils": "0.11.1",
59
+ "@scalar/workspace-store": "0.45.0",
60
+ "@scalar/use-codemirror": "0.14.11"
72
61
  },
73
62
  "devDependencies": {
74
63
  "@vitejs/plugin-vue": "^6.0.3",
75
64
  "@vue/test-utils": "2.4.6",
76
- "vite": "8.0.0",
77
- "@scalar/types": "0.7.6",
78
- "@scalar/use-codemirror": "0.14.11"
65
+ "vite": "8.0.0"
79
66
  },
80
67
  "scripts": {
81
68
  "build": "vite build && vue-tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
@@ -1,8 +0,0 @@
1
- //#region \0plugin-vue:export-helper
2
- var _plugin_vue_export_helper_default = (sfc, props) => {
3
- const target = sfc.__vccOpts || sfc;
4
- for (const [key, val] of props) target[key] = val;
5
- return target;
6
- };
7
- //#endregion
8
- export { _plugin_vue_export_helper_default as default };
@@ -1,2 +0,0 @@
1
- import { executePostResponseScript } from "./execute-post-response-script.js";
2
- export { executePostResponseScript };
@@ -1,9 +0,0 @@
1
- import type { ConsoleContext } from './context/console.js';
2
- import type { TestResult } from './execute-post-response-script.js';
3
- export declare const executeInPostmanSandbox: ({ script, response, onTestResultsUpdate, scriptConsole, }: {
4
- script: string;
5
- response: Response;
6
- onTestResultsUpdate?: ((results: TestResult[]) => void) | undefined;
7
- scriptConsole: ConsoleContext;
8
- }) => Promise<void>;
9
- //# sourceMappingURL=postman-sandbox-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postman-sandbox-adapter.d.ts","sourceRoot":"","sources":["../../../src/libs/execute-scripts/postman-sandbox-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAiEhE,eAAO,MAAM,uBAAuB,GAAU,2DAK3C;IACD,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,QAAQ,CAAA;IAClB,mBAAmB,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;IACnE,aAAa,EAAE,cAAc,CAAA;CAC9B,KAAG,OAAO,CAAC,IAAI,CAqEf,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"postman-sandbox-adapter.js","names":[],"sources":["../../../src/libs/execute-scripts/postman-sandbox-adapter.ts"],"sourcesContent":["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"],"mappings":";;AAcA,IAAM,oBAAoB,OAAO,aAAuB;CACtD,MAAM,eAAe,MAAM,SAAS,MAAM;CAC1C,MAAM,gBAAgB,MAAM,KAAK,IAAI,aAAa,CAAC,OAAO,aAAa,CAAC;AAExE,QAAO;EACL,MAAM,SAAS;EACf,QAAQ,SAAS,cAAc,OAAO,SAAS,OAAO;EACtD,QAAQ,MAAM,KAAK,SAAS,QAAQ,SAAS,CAAC,CAAC,KAAK,CAAC,KAAK,YAAY;GAAE;GAAK;GAAO,EAAE;EACtF,QAAQ;GACN,MAAM;GACN,MAAM;GACP;EACF;;AAGH,IAAM,sBACJ,IAAI,SAAS,SAAS,WAAW;AAC/B,SAAQ,eAAe,OAAgB,YAA4B;AACjE,MAAI,OAAO;AACT,UAAO,MAAM;AACb;;AAGF,UAAQ,QAAQ;GAChB;EACF;AAEJ,IAAM,kBAAkB,UAA2B;AACjD,KAAI,SAAS,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY,SACvF,QAAO,MAAM;AAGf,QAAO,OAAO,MAAM;;AAGtB,IAAM,oBAAoB,aAA2B,WAA2B,aAA2B;CACzG,MAAM,QAAQ,UAAU,QAAQ,aAAa,UAAU,QAAQ;CAE/D,MAAM,aAAyB;EAC7B;EACA,QAAQ,UAAU;EAClB;EACA,OAAO,UAAU,OAAO;EACxB,QAAQ,UAAU,SAAS,WAAW;EACvC;CAED,MAAM,sBAAsB,YAAY,WAAW,WAAW,OAAO,UAAU,MAAM;AACrF,KAAI,wBAAwB,IAAI;AAC9B,cAAY,KAAK,WAAW;AAC5B;;AAGF,aAAY,uBAAuB;;AAGrC,IAAa,0BAA0B,OAAO,EAC5C,QACA,UACA,qBACA,oBAMmB;CACnB,MAAM,cAA4B,EAAE;CACpC,IAAI,oBAAoB;CACxB,IAAI,2BAA2B;CAC/B,MAAM,iBAAiB,MAAM,eAAe;CAE5C,MAAM,mBAAmB,SAAkB,eAAiC;AAC1E,aAAW,SAAS,cAAc;GAChC,MAAM,WAAW,QAAQ,YAAY,KAAK,GAAG,mBAAmB,QAAQ,EAAE,CAAC;AAC3E,uBAAoB,YAAY,KAAK;AACrC,oBAAiB,aAAa,WAAW,SAAS;IAClD;AACF,wBAAsB,CAAC,GAAG,YAAY,CAAC;;CAGzC,MAAM,iBAAiB,SAAkB,OAA6B,GAAG,SAAoB;AAEzF,GADoB,cAAc,UAAU,cAAc,KACT,GAAG,KAAK;;AAG7D,KAAI;AACF,iBAAe,GAAG,uBAAuB,gBAAgB;AACzD,iBAAe,GAAG,WAAW,cAAc;EAE3C,MAAM,kBAAkB,MAAM,kBAAkB,SAAS;AAEzD,6BAA2B,YAAY,KAAK;AAC5C,sBAAoB;AAEpB,QAAM,IAAI,SAAe,YAAY;AACnC,kBAAe,QACb;IACE,QAAQ;IACR,QAAQ,EACN,MAAM,CAAC,OAAO,EACf;IACF,EACD;IACE,mBAAmB;IACnB,SAAS,EACP,UAAU,iBACX;IACF,GACA,UAAmB;AAClB,QAAI,OAAO;KACT,MAAM,WAAW,QAAQ,YAAY,KAAK,GAAG,0BAA0B,QAAQ,EAAE,CAAC;KAClF,MAAM,eAAe,eAAe,MAAM;AAE1C,mBAAc,MAAM,iCAAiC,SAAS,OAAO,aAAa;AAElF,iBAAY,KAAK;MACf,OAAO;MACP,QAAQ;MACR;MACA,OAAO;MACP,QAAQ;MACT,CAAC;AACF,2BAAsB,CAAC,GAAG,YAAY,CAAC;;AAGzC,aAAS;KAEZ;IACD;WACM;AACR,iBAAe,IAAI,uBAAuB,gBAAgB;AAC1D,iBAAe,IAAI,WAAW,cAAc;AAC5C,iBAAe,SAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExampleScripts.vue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue"],"names":[],"mappings":"AA0CA,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAC;AA6EF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExampleScripts.vue.js","names":[],"sources":["../../../../../src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { EXAMPLE_SCRIPTS } from '@/consts/example-scripts'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst addExample = (example: string) => {\n let addition = example\n // Look at current value. If it's not empty, add a new line.\n if (props.modelValue.trim() !== '') {\n addition = `\\n\\n${addition}`\n }\n\n emit('update:modelValue', props.modelValue.trim() + addition)\n}\n</script>\n\n<template>\n <ul class=\"flex flex-wrap gap-1\">\n <li\n v-for=\"example in EXAMPLE_SCRIPTS\"\n :key=\"example.title\"\n class=\"bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium\">\n <button\n class=\"w-full\"\n type=\"button\"\n @click=\"addExample(example.script)\">\n {{ example.title }}\n </button>\n </li>\n </ul>\n</template>\n"],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExampleScripts.vue.script.js","names":[],"sources":["../../../../../src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { EXAMPLE_SCRIPTS } from '@/consts/example-scripts'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst addExample = (example: string) => {\n let addition = example\n // Look at current value. If it's not empty, add a new line.\n if (props.modelValue.trim() !== '') {\n addition = `\\n\\n${addition}`\n }\n\n emit('update:modelValue', props.modelValue.trim() + addition)\n}\n</script>\n\n<template>\n <ul class=\"flex flex-wrap gap-1\">\n <li\n v-for=\"example in EXAMPLE_SCRIPTS\"\n :key=\"example.title\"\n class=\"bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium\">\n <button\n class=\"w-full\"\n type=\"button\"\n @click=\"addExample(example.script)\">\n {{ example.title }}\n </button>\n </li>\n </ul>\n</template>\n"],"mappings":";;;;;;;;;;EAGA,MAAM,QAAQ;EAId,MAAM,OAAO;EAIb,MAAM,cAAc,YAAoB;GACtC,IAAI,WAAW;AAEf,OAAI,MAAM,WAAW,MAAM,KAAK,GAC9B,YAAW,OAAO;AAGpB,QAAK,qBAAqB,MAAM,WAAW,MAAM,GAAG,SAAQ;;;uBAK5D,mBAYK,MAZL,YAYK,EAAA,UAAA,KAAA,EAXH,mBAUK,UAAA,MAAA,WATe,MAAA,gBAAe,GAA1B,YAAO;wBADhB,mBAUK,MAAA;KARF,KAAK,QAAQ;KACd,OAAM;QACN,mBAKS,UAAA;KAJP,OAAM;KACN,MAAK;KACJ,UAAK,WAAE,WAAW,QAAQ,OAAM;uBAC9B,QAAQ,MAAK,EAAA,GAAA,WAAA,CAAA,CAAA"}
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
1
- import PostResponseScripts_vue_vue_type_script_setup_true_lang_default from "./PostResponseScripts.vue.script.js";
2
- //#region src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue
3
- var PostResponseScripts_default = PostResponseScripts_vue_vue_type_script_setup_true_lang_default;
4
- //#endregion
5
- export { PostResponseScripts_default as default };
6
-
7
- //# sourceMappingURL=PostResponseScripts.vue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostResponseScripts.vue.js","names":[],"sources":["../../../../../src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Operation } from '@scalar/oas-utils/entities/spec'\nimport { computed } from 'vue'\n\nimport { ViewLayoutCollapse } from '@/components/ViewLayout'\n\nimport ExampleScripts from './ExampleScripts.vue'\nimport ScriptEditor from './ScriptEditor.vue'\n\nconst { operation } = defineProps<{\n operation: Pick<Operation, 'x-post-response'>\n}>()\n\nconst emit = defineEmits<{\n (e: 'operation:update:extension', payload: any): void\n}>()\n\nconst script = computed(() => (operation['x-post-response'] as string) || '')\n\nconst updatePostResponseScript = (value: string) => {\n emit('operation:update:extension', {\n 'x-post-response': value,\n })\n}\n</script>\n\n<template>\n <div class=\"w-full\">\n <ViewLayoutCollapse\n class=\"w-full\"\n :defaultOpen=\"true\">\n <template #title>Scripts</template>\n <template #suffix>\n <!-- Show an indicator whether we have a script -->\n <div class=\"mr-2\">\n <div\n v-if=\"script.length > 0\"\n class=\"bg-green h-2 w-2 rounded-full\" />\n </div>\n </template>\n\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Post-Response\n </div>\n\n <ScriptEditor\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n\n <div class=\"border-y p-3\">\n <ExampleScripts\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n </div>\n </ViewLayoutCollapse>\n </div>\n</template>\n"],"mappings":""}