@scalar/api-client 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -7
- package/src/components/ApiClient/AddressBar.vue +0 -462
- package/src/components/ApiClient/ApiClient.vue +0 -266
- package/src/components/ApiClient/Request/Request.vue +0 -271
- package/src/components/ApiClient/Request/RequestAuth.vue +0 -221
- package/src/components/ApiClient/Request/RequestBody.vue +0 -40
- package/src/components/ApiClient/Request/RequestHeaders.vue +0 -24
- package/src/components/ApiClient/Request/RequestQuery.vue +0 -25
- package/src/components/ApiClient/Request/RequestVariables.vue +0 -25
- package/src/components/ApiClient/Request/index.ts +0 -1
- package/src/components/ApiClient/RequestHistory.vue +0 -114
- package/src/components/ApiClient/RequestHistoryItem.vue +0 -59
- package/src/components/ApiClient/Response/Copilot.vue.bak +0 -385
- package/src/components/ApiClient/Response/Response.vue +0 -120
- package/src/components/ApiClient/Response/ResponseBody.vue +0 -24
- package/src/components/ApiClient/Response/ResponseHeaders.vue +0 -52
- package/src/components/ApiClient/Response/ResponseMetaInformation.vue +0 -58
- package/src/components/ApiClient/Response/index.ts +0 -1
- package/src/components/ApiClient/index.ts +0 -1
- package/src/components/CollapsibleSection/CollapsibleSection.vue +0 -149
- package/src/components/CollapsibleSection/index.ts +0 -1
- package/src/components/FlowModal.vue +0 -133
- package/src/components/Grid/Grid.vue +0 -511
- package/src/components/Grid/SimpleGrid.vue +0 -33
- package/src/components/Grid/index.ts +0 -2
- package/src/components/HelpfulLink.vue +0 -19
- package/src/components/SimpleTable/SimpleCell.vue +0 -47
- package/src/components/SimpleTable/SimpleHeader.vue +0 -17
- package/src/components/SimpleTable/SimpleRow.vue +0 -14
- package/src/components/SimpleTable/SimpleTable.vue +0 -13
- package/src/components/SimpleTable/index.ts +0 -4
- package/src/fixtures/httpHeaders.ts +0 -530
- package/src/fixtures/httpStatusCodes.ts +0 -259
- package/src/fixtures/index.ts +0 -6
- package/src/helpers/concatenateUrlAndPath.test.ts +0 -27
- package/src/helpers/concatenateUrlAndPath.ts +0 -13
- package/src/helpers/createPlaceholderRequest.ts +0 -16
- package/src/helpers/generateParameters.ts +0 -19
- package/src/helpers/generateRequest.ts +0 -26
- package/src/helpers/index.ts +0 -10
- package/src/helpers/mapFromArray.ts +0 -16
- package/src/helpers/normalizePath.test.ts +0 -17
- package/src/helpers/normalizePath.ts +0 -16
- package/src/helpers/normalizeRequestMethod.test.ts +0 -29
- package/src/helpers/normalizeRequestMethod.ts +0 -43
- package/src/helpers/normalizeUrl.test.ts +0 -25
- package/src/helpers/normalizeUrl.ts +0 -24
- package/src/helpers/replaceVariables.test.ts +0 -13
- package/src/helpers/replaceVariables.ts +0 -11
- package/src/helpers/sendRequest.test.ts +0 -50
- package/src/helpers/sendRequest.ts +0 -105
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useCopilot.ts +0 -64
- package/src/hooks/useOperation.ts +0 -43
- package/src/index.ts +0 -8
- package/src/stores/apiClientRequestStore.ts +0 -103
- package/src/stores/apiClientStore.ts +0 -57
- package/src/stores/index.ts +0 -5
- package/src/types.ts +0 -185
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useMarkdown } from '@anc/library'
|
|
3
|
-
import { StarterKit } from '@tiptap/starter-kit'
|
|
4
|
-
import { Editor, EditorContent } from '@tiptap/vue-3'
|
|
5
|
-
import { Markdown } from 'tiptap-markdown'
|
|
6
|
-
import { computed, ref, watch } from 'vue'
|
|
7
|
-
|
|
8
|
-
import { CopilotLoadingStates, useCopilot } from '../../../hooks'
|
|
9
|
-
|
|
10
|
-
const content = ref('')
|
|
11
|
-
const editor = ref<any>()
|
|
12
|
-
const itemSuggestionOpen = ref(false)
|
|
13
|
-
const contentFilled = ref(false)
|
|
14
|
-
|
|
15
|
-
editor.value = new Editor({
|
|
16
|
-
editable: false,
|
|
17
|
-
extensions: [StarterKit],
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const { html, setMarkdown } = useMarkdown(content, [StarterKit, Markdown])
|
|
21
|
-
|
|
22
|
-
const { state, onRecommendation, setLoadingState } = useCopilot()
|
|
23
|
-
|
|
24
|
-
onRecommendation((recommendation: string) => {
|
|
25
|
-
contentFilled.value = true
|
|
26
|
-
content.value += recommendation
|
|
27
|
-
setMarkdown(content.value)
|
|
28
|
-
setLoadingState(CopilotLoadingStates.Fix)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
watch(html, () => {
|
|
32
|
-
editor.value.commands.setContent(html)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const classLookUp: Partial<Record<CopilotLoadingStates, string>> = {
|
|
36
|
-
[CopilotLoadingStates.Loading]: 'scalar-copilot__header-button--loading',
|
|
37
|
-
[CopilotLoadingStates.Working]: 'scalar-copilot__header-button--working',
|
|
38
|
-
[CopilotLoadingStates.Success]: 'scalar-copilot__header-button--success',
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const loadingStateClass = computed(() => classLookUp[state.loadingState])
|
|
42
|
-
|
|
43
|
-
const toggleItemSuggestion = () => {
|
|
44
|
-
itemSuggestionOpen.value = !itemSuggestionOpen.value
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const itemSuggestionState = computed(() => ({
|
|
48
|
-
'scalar-copilot__suggestion--open': itemSuggestionOpen.value,
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
const contentFilledState = computed(() => ({
|
|
52
|
-
'scalar-copilot--inactive': !contentFilled.value,
|
|
53
|
-
}))
|
|
54
|
-
|
|
55
|
-
function sleep(ms: number) {
|
|
56
|
-
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const fixErrors = async () => {
|
|
60
|
-
setLoadingState(CopilotLoadingStates.Working)
|
|
61
|
-
await sleep(3000) // Sleep for 3 seconds
|
|
62
|
-
content.value = ''
|
|
63
|
-
setMarkdown(content.value)
|
|
64
|
-
setLoadingState(CopilotLoadingStates.Success)
|
|
65
|
-
contentFilled.value = false
|
|
66
|
-
}
|
|
67
|
-
</script>
|
|
68
|
-
<template>
|
|
69
|
-
<!-- remove class scalar-copilot--inactive once we start loading suggestions-->
|
|
70
|
-
<!-- add the class "scalar-copilot__response" when copilot is within response -->
|
|
71
|
-
<div
|
|
72
|
-
class="scalar-copilot"
|
|
73
|
-
:class="contentFilledState">
|
|
74
|
-
<div class="scalar-copilot__header">
|
|
75
|
-
<span>
|
|
76
|
-
<svg
|
|
77
|
-
fill="none"
|
|
78
|
-
height="48"
|
|
79
|
-
stroke-width="2"
|
|
80
|
-
viewBox="0 0 24 24"
|
|
81
|
-
width="48"
|
|
82
|
-
xmlns="http://www.w3.org/2000/svg">
|
|
83
|
-
<path
|
|
84
|
-
d="M16.625 13.724c-4.988 1.68-6.632 3.552-7.848 8.213-1.216-4.66-2.86-6.532-7.848-8.213 4.988-1.68 6.632-3.552 7.848-8.214 1.216 4.662 2.86 6.533 7.848 8.214ZM22.813 5.948c-2.814.944-3.741 1.996-4.427 4.615-.686-2.619-1.614-3.67-4.427-4.615 2.813-.944 3.74-1.996 4.427-4.615.686 2.62 1.613 3.67 4.427 4.615ZM23.178 19.562c-2.082.684-2.769 1.446-3.276 3.344-.508-1.898-1.195-2.66-3.277-3.344 2.082-.684 2.769-1.446 3.277-3.344.507 1.898 1.194 2.66 3.276 3.344Z"
|
|
85
|
-
stroke="currentColor"
|
|
86
|
-
stroke-linecap="round"
|
|
87
|
-
stroke-linejoin="round" />
|
|
88
|
-
</svg>
|
|
89
|
-
AI Suggestions
|
|
90
|
-
</span>
|
|
91
|
-
<!-- Add this class: "scalar-copilot__header-button--loading" when you blur an input and are loading to check for errors -->
|
|
92
|
-
<div
|
|
93
|
-
v-if="state.loadingState !== CopilotLoadingStates.Inactive"
|
|
94
|
-
class="scalar-copilot__header-button"
|
|
95
|
-
:class="loadingStateClass"
|
|
96
|
-
@click="fixErrors">
|
|
97
|
-
<!--should be applied to the tag above-->
|
|
98
|
-
Fix (1) Error
|
|
99
|
-
</div>
|
|
100
|
-
<!-- Add this class: "scalar-copilot__header-button--working" after you click button -->
|
|
101
|
-
<!-- Add this class: "scalar-copilot__header-button--success" after button is done working add the success -->
|
|
102
|
-
<!-- class IF there is no more errors to fix IF there is still errors to fix don't add -->
|
|
103
|
-
</div>
|
|
104
|
-
<div
|
|
105
|
-
v-if="contentFilled"
|
|
106
|
-
class="scalar-copilot__item">
|
|
107
|
-
<div
|
|
108
|
-
class="scalar-copilot__suggestion"
|
|
109
|
-
:class="itemSuggestionState">
|
|
110
|
-
<!-- when you click toggle you need to add and remove the class "scalar-copilot__suggestion--open" to the div above it-->
|
|
111
|
-
<div
|
|
112
|
-
class="scalar-copilot__item__toggle"
|
|
113
|
-
@click="toggleItemSuggestion">
|
|
114
|
-
<div class="scalar-copilot__item__toggle-button" />
|
|
115
|
-
</div>
|
|
116
|
-
<EditorContent
|
|
117
|
-
class="scalar-copilot__suggestion__content"
|
|
118
|
-
:editor="editor" />
|
|
119
|
-
</div>
|
|
120
|
-
<div class="scalar-copilot__item-check">
|
|
121
|
-
<label class="meta-check">
|
|
122
|
-
<input
|
|
123
|
-
checked
|
|
124
|
-
type="checkbox" />
|
|
125
|
-
<span class="meta-checkmark" />
|
|
126
|
-
</label>
|
|
127
|
-
</div>
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
</template>
|
|
131
|
-
|
|
132
|
-
<style scoped>
|
|
133
|
-
.scalar-copilot__response .scalar-copilot__header {
|
|
134
|
-
height: 0px;
|
|
135
|
-
min-height: 0px;
|
|
136
|
-
padding: 0;
|
|
137
|
-
border-bottom: 0;
|
|
138
|
-
}
|
|
139
|
-
.scalar-copilot__response .scalar-copilot__header span {
|
|
140
|
-
display: none;
|
|
141
|
-
}
|
|
142
|
-
.scalar-copilot__response .scalar-copilot__header-button {
|
|
143
|
-
position: absolute;
|
|
144
|
-
top: 8px;
|
|
145
|
-
right: 12px;
|
|
146
|
-
}
|
|
147
|
-
.scalar-copilot {
|
|
148
|
-
color: var(--theme-color-1);
|
|
149
|
-
width: 100%;
|
|
150
|
-
border-radius: var(--theme-radius-lg);
|
|
151
|
-
border: 1px solid var(--theme-border-color);
|
|
152
|
-
}
|
|
153
|
-
.scalar-copilot--inactive {
|
|
154
|
-
border: 1px solid transparent;
|
|
155
|
-
background: var(--theme-background-3);
|
|
156
|
-
}
|
|
157
|
-
.scalar-copilot__header {
|
|
158
|
-
padding: 7px 7px 7px 9px;
|
|
159
|
-
min-height: 32.5px;
|
|
160
|
-
display: flex;
|
|
161
|
-
color: var(--theme-color-disabled);
|
|
162
|
-
font-weight: var(--theme-bold);
|
|
163
|
-
align-items: center;
|
|
164
|
-
justify-content: space-between;
|
|
165
|
-
border-bottom: 1px solid var(--theme-border-color);
|
|
166
|
-
}
|
|
167
|
-
.scalar-copilot__header span {
|
|
168
|
-
display: flex;
|
|
169
|
-
align-items: center;
|
|
170
|
-
}
|
|
171
|
-
.scalar-copilot__header svg {
|
|
172
|
-
width: 12px;
|
|
173
|
-
height: 12px;
|
|
174
|
-
margin-right: 6px;
|
|
175
|
-
}
|
|
176
|
-
.scalar-copilot__item {
|
|
177
|
-
line-height: 1.45;
|
|
178
|
-
display: flex;
|
|
179
|
-
}
|
|
180
|
-
.scalar-copilot__item:not(:last-of-type) {
|
|
181
|
-
border-bottom: 1px solid var(--theme-border-color);
|
|
182
|
-
}
|
|
183
|
-
.scalar-copilot__suggestion {
|
|
184
|
-
position: relative;
|
|
185
|
-
cursor: pointer;
|
|
186
|
-
display: flex;
|
|
187
|
-
}
|
|
188
|
-
.scalar-copilot__suggestion__content {
|
|
189
|
-
-webkit-line-clamp: 2;
|
|
190
|
-
-webkit-box-orient: vertical;
|
|
191
|
-
overflow: hidden;
|
|
192
|
-
max-height: 52.8px;
|
|
193
|
-
display: -webkit-box;
|
|
194
|
-
padding: 9px 9px 9px 27px;
|
|
195
|
-
}
|
|
196
|
-
.scalar-copilot__suggestion__content:after {
|
|
197
|
-
content: '';
|
|
198
|
-
position: absolute;
|
|
199
|
-
bottom: 0;
|
|
200
|
-
left: 0;
|
|
201
|
-
width: 100%;
|
|
202
|
-
height: 9px;
|
|
203
|
-
background: var(--theme-background-2);
|
|
204
|
-
}
|
|
205
|
-
.scalar-copilot__suggestion--open .scalar-copilot__suggestion__content {
|
|
206
|
-
max-height: initial;
|
|
207
|
-
cursor: initial;
|
|
208
|
-
display: block;
|
|
209
|
-
}
|
|
210
|
-
.scalar-copilot__item-check {
|
|
211
|
-
border-left: 1px solid var(--theme-border-color);
|
|
212
|
-
width: 32.5px;
|
|
213
|
-
flex-shrink: 0;
|
|
214
|
-
display: flex;
|
|
215
|
-
align-items: center;
|
|
216
|
-
justify-content: center;
|
|
217
|
-
}
|
|
218
|
-
.scalar-copilot__header-button {
|
|
219
|
-
background: var(--scalar-api-client-color);
|
|
220
|
-
border-radius: var(--theme-radius-lg);
|
|
221
|
-
cursor: pointer;
|
|
222
|
-
flex-shrink: 0;
|
|
223
|
-
display: flex;
|
|
224
|
-
color: white;
|
|
225
|
-
padding: 2px 6px;
|
|
226
|
-
}
|
|
227
|
-
.dark-mode .scalar-copilot__header-button {
|
|
228
|
-
color: black;
|
|
229
|
-
}
|
|
230
|
-
.scalar-copilot__header-button--loading {
|
|
231
|
-
background: transparent;
|
|
232
|
-
font-size: 0px;
|
|
233
|
-
color: var(--theme-color-disabled);
|
|
234
|
-
}
|
|
235
|
-
.scalar-copilot__header-button--working {
|
|
236
|
-
font-size: 0px;
|
|
237
|
-
}
|
|
238
|
-
.scalar-copilot__header-button--working:before,
|
|
239
|
-
.scalar-copilot__header-button--loading:before {
|
|
240
|
-
content: '';
|
|
241
|
-
border: 1px solid var(--theme-color-disabled);
|
|
242
|
-
border-top: 1px solid var(--theme-color-1);
|
|
243
|
-
animation: urlloader 0.45s linear infinite;
|
|
244
|
-
background: transparent;
|
|
245
|
-
width: 14px;
|
|
246
|
-
height: 14px;
|
|
247
|
-
margin-left: 0;
|
|
248
|
-
margin-right: 9px;
|
|
249
|
-
border-radius: 50%;
|
|
250
|
-
display: block;
|
|
251
|
-
}
|
|
252
|
-
.scalar-copilot__header-button--working:before {
|
|
253
|
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
254
|
-
border-top: 1px solid white;
|
|
255
|
-
}
|
|
256
|
-
.dark-mode .scalar-copilot__header-button--working:before {
|
|
257
|
-
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
258
|
-
border-top: 1px solid black;
|
|
259
|
-
}
|
|
260
|
-
.scalar-copilot__header-button--working:after {
|
|
261
|
-
content: 'Working';
|
|
262
|
-
font-size: 12px;
|
|
263
|
-
}
|
|
264
|
-
.scalar-copilot__header-button--loading:after {
|
|
265
|
-
content: 'Loading';
|
|
266
|
-
font-size: 12px;
|
|
267
|
-
}
|
|
268
|
-
.scalar-copilot__header-button--success {
|
|
269
|
-
font-size: 0;
|
|
270
|
-
background: transparent;
|
|
271
|
-
cursor: default;
|
|
272
|
-
}
|
|
273
|
-
.scalar-copilot__header-button--success:after {
|
|
274
|
-
content: 'Success';
|
|
275
|
-
font-size: 12px;
|
|
276
|
-
color: var(--theme-color-2);
|
|
277
|
-
}
|
|
278
|
-
.scalar-copilot__header-button--success:before {
|
|
279
|
-
content: '';
|
|
280
|
-
display: block;
|
|
281
|
-
width: 5px;
|
|
282
|
-
height: 8px;
|
|
283
|
-
border: solid var(--theme-color-2);
|
|
284
|
-
margin-right: 9px;
|
|
285
|
-
top: 3px;
|
|
286
|
-
position: relative;
|
|
287
|
-
border-width: 0 1.5px 1.5px 0;
|
|
288
|
-
transform: rotate(45deg) translate3d(0, -1px, 0);
|
|
289
|
-
}
|
|
290
|
-
@keyframes urlloader {
|
|
291
|
-
0% {
|
|
292
|
-
transform: rotate(0deg);
|
|
293
|
-
}
|
|
294
|
-
to {
|
|
295
|
-
transform: rotate(1turn);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
.scalar-copilot__item__toggle {
|
|
299
|
-
position: absolute;
|
|
300
|
-
width: 100%;
|
|
301
|
-
height: 100%;
|
|
302
|
-
padding: 9px;
|
|
303
|
-
z-index: 10;
|
|
304
|
-
cursor: pointer;
|
|
305
|
-
}
|
|
306
|
-
.scalar-copilot__item__toggle-button {
|
|
307
|
-
width: 6px;
|
|
308
|
-
height: 6px;
|
|
309
|
-
margin-right: 12px;
|
|
310
|
-
flex-shrink: 0;
|
|
311
|
-
position: relative;
|
|
312
|
-
top: 5px;
|
|
313
|
-
left: -2px;
|
|
314
|
-
transform: rotate(315deg);
|
|
315
|
-
box-shadow: 1px 1px 0 var(--theme-color-disabled);
|
|
316
|
-
z-index: 10;
|
|
317
|
-
}
|
|
318
|
-
.scalar-copilot__item__toggle-button:after {
|
|
319
|
-
content: '';
|
|
320
|
-
width: 20px;
|
|
321
|
-
height: 20px;
|
|
322
|
-
border-radius: 50%;
|
|
323
|
-
position: absolute;
|
|
324
|
-
display: block;
|
|
325
|
-
left: -5px;
|
|
326
|
-
top: -4px;
|
|
327
|
-
}
|
|
328
|
-
.scalar-copilot__item__toggle-button:hover {
|
|
329
|
-
box-shadow: 1px 1px 0 var(--theme-color-1);
|
|
330
|
-
}
|
|
331
|
-
.scalar-copilot__suggestion--open .scalar-copilot__item__toggle-button {
|
|
332
|
-
transform: rotate(45deg);
|
|
333
|
-
left: 2px;
|
|
334
|
-
top: 1px;
|
|
335
|
-
}
|
|
336
|
-
.scalar-copilot__suggestion--open .scalar-copilot__item__toggle {
|
|
337
|
-
height: 24px;
|
|
338
|
-
position: absolute;
|
|
339
|
-
width: 24px;
|
|
340
|
-
}
|
|
341
|
-
.scalar-copilot__item__toggle:hover:after {
|
|
342
|
-
content: '';
|
|
343
|
-
background: var(--theme-background-3);
|
|
344
|
-
width: 20px;
|
|
345
|
-
height: 20px;
|
|
346
|
-
border-radius: 50%;
|
|
347
|
-
position: absolute;
|
|
348
|
-
left: 3px;
|
|
349
|
-
top: 7px;
|
|
350
|
-
z-index: 0;
|
|
351
|
-
}
|
|
352
|
-
.scalar-copilot__suggestion--open .scalar-copilot__item__toggle:hover:after {
|
|
353
|
-
top: 6px;
|
|
354
|
-
left: 4px;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
.scalar-api-client__item:hover .scalar-copilot__item__toggle-button,
|
|
358
|
-
.scalar-api-client__item:focus-within .scalar-copilot__item__toggle-button {
|
|
359
|
-
opacity: 1;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
.scalar-copilot__toggle-button {
|
|
363
|
-
appearance: none;
|
|
364
|
-
color: var(--scalar-api-client-color2);
|
|
365
|
-
font-size: var(--theme-small);
|
|
366
|
-
background: var(--scalar-api-client-gradient);
|
|
367
|
-
border-radius: var(--theme-radius-lg);
|
|
368
|
-
border: 1px solid var(--theme-border-color);
|
|
369
|
-
font-weight: var(--theme-bold);
|
|
370
|
-
max-height: 25px;
|
|
371
|
-
padding: 4px 8px;
|
|
372
|
-
outline: none;
|
|
373
|
-
cursor: pointer;
|
|
374
|
-
transition: opacity 0.15s ease-in-out;
|
|
375
|
-
white-space: nowrap;
|
|
376
|
-
&:hover {
|
|
377
|
-
color: var(--theme-color-1);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
.scalar-copilot__toggle-button svg {
|
|
382
|
-
margin-left: 6px;
|
|
383
|
-
width: 8px;
|
|
384
|
-
}
|
|
385
|
-
</style>
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue'
|
|
3
|
-
|
|
4
|
-
import { useApiClientRequestStore } from '../../../stores/apiClientRequestStore'
|
|
5
|
-
import { CollapsibleSection } from '../../CollapsibleSection'
|
|
6
|
-
// import Copilot from './Copilot.vue'
|
|
7
|
-
import { SimpleGrid } from '../../Grid'
|
|
8
|
-
import ResponseBody from './ResponseBody.vue'
|
|
9
|
-
import ResponseHeaders from './ResponseHeaders.vue'
|
|
10
|
-
import ResponseMetaInformation from './ResponseMetaInformation.vue'
|
|
11
|
-
|
|
12
|
-
const { activeResponse, activeRequestId } = useApiClientRequestStore()
|
|
13
|
-
|
|
14
|
-
// Headers
|
|
15
|
-
const responseHeaders = computed(() => {
|
|
16
|
-
const headers = activeResponse.value?.headers
|
|
17
|
-
|
|
18
|
-
return headers
|
|
19
|
-
? Object.keys(headers)
|
|
20
|
-
.map((key) => ({ name: key, value: headers[key] }))
|
|
21
|
-
.filter(
|
|
22
|
-
(item) =>
|
|
23
|
-
![
|
|
24
|
-
'rest-api-client-content-length',
|
|
25
|
-
'X-API-Client-Content-Length',
|
|
26
|
-
].includes(item.name),
|
|
27
|
-
)
|
|
28
|
-
: []
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// Cookies
|
|
32
|
-
const responseCookies = computed(() => {
|
|
33
|
-
const cookies = activeResponse.value?.cookies
|
|
34
|
-
|
|
35
|
-
return cookies
|
|
36
|
-
? Object.keys(cookies).map((key) => ({ name: key, value: cookies[key] }))
|
|
37
|
-
: []
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
// Check if string is JSON
|
|
41
|
-
const isJsonString = (value?: string) => {
|
|
42
|
-
if (typeof value !== 'string') {
|
|
43
|
-
return false
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
JSON.parse(value)
|
|
48
|
-
} catch {
|
|
49
|
-
return false
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return true
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Pretty print JSON
|
|
56
|
-
const responseData = computed(() => {
|
|
57
|
-
const value = activeResponse.value?.data
|
|
58
|
-
|
|
59
|
-
if (value && isJsonString(value)) {
|
|
60
|
-
return JSON.stringify(JSON.parse(value), null, 2)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return value
|
|
64
|
-
})
|
|
65
|
-
</script>
|
|
66
|
-
<template>
|
|
67
|
-
<div class="scalar-api-client__main__right custom-scroll">
|
|
68
|
-
<div class="scalar-api-client__main__content">
|
|
69
|
-
<label>Response</label>
|
|
70
|
-
<div class="meta">
|
|
71
|
-
<template v-if="activeRequestId && activeResponse">
|
|
72
|
-
<ResponseMetaInformation :response="activeResponse" />
|
|
73
|
-
</template>
|
|
74
|
-
<template v-else>
|
|
75
|
-
<div class="meta-item">
|
|
76
|
-
<span>Send your first request to start</span>
|
|
77
|
-
</div>
|
|
78
|
-
</template>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
<div>
|
|
82
|
-
<ResponseBody
|
|
83
|
-
:active="!!activeResponse"
|
|
84
|
-
:data="responseData" />
|
|
85
|
-
<!-- <CollapsibleSection title="Co Pilot">
|
|
86
|
-
<Copilot />
|
|
87
|
-
<template v-if="responseHeaders.length === 0">
|
|
88
|
-
<pre>No headers</pre>
|
|
89
|
-
</template>
|
|
90
|
-
</CollapsibleSection> -->
|
|
91
|
-
<ResponseHeaders :headers="responseHeaders" />
|
|
92
|
-
<CollapsibleSection title="Cookies">
|
|
93
|
-
<SimpleGrid
|
|
94
|
-
v-show="responseCookies.length > 0"
|
|
95
|
-
:items="responseCookies" />
|
|
96
|
-
<template v-if="responseCookies.length === 0">
|
|
97
|
-
<div class="scalar-api-client__empty-state">No Cookies</div>
|
|
98
|
-
</template>
|
|
99
|
-
</CollapsibleSection>
|
|
100
|
-
<div class="scalar-api-client__main__scroll-container" />
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</template>
|
|
104
|
-
<style>
|
|
105
|
-
.scalar-api-client__main__right {
|
|
106
|
-
width: 50%;
|
|
107
|
-
padding: 0 0 12px 12px;
|
|
108
|
-
}
|
|
109
|
-
@media screen and (max-width: 820px) {
|
|
110
|
-
.scalar-api-client__main__right {
|
|
111
|
-
width: 100%;
|
|
112
|
-
border-right: none;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
.scalar-api-client__main__right :deep(.scalar-copilot__header-button) {
|
|
116
|
-
position: absolute;
|
|
117
|
-
top: 6px;
|
|
118
|
-
right: 12px;
|
|
119
|
-
}
|
|
120
|
-
</style>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { CodeMirror } from '@scalar/use-codemirror'
|
|
3
|
-
|
|
4
|
-
import { CollapsibleSection } from '../../CollapsibleSection'
|
|
5
|
-
|
|
6
|
-
withDefaults(defineProps<{ active: boolean; data: any }>(), {
|
|
7
|
-
active: false,
|
|
8
|
-
data: null,
|
|
9
|
-
})
|
|
10
|
-
</script>
|
|
11
|
-
<template>
|
|
12
|
-
<CollapsibleSection title="Body">
|
|
13
|
-
<CodeMirror
|
|
14
|
-
v-if="active"
|
|
15
|
-
:content="data"
|
|
16
|
-
:languages="['json']"
|
|
17
|
-
readOnly />
|
|
18
|
-
<div
|
|
19
|
-
v-else
|
|
20
|
-
class="scalar-api-client__empty-state">
|
|
21
|
-
No Response
|
|
22
|
-
</div>
|
|
23
|
-
</CollapsibleSection>
|
|
24
|
-
</template>
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { httpHeaders } from '../../../fixtures'
|
|
3
|
-
import { CollapsibleSection } from '../../CollapsibleSection'
|
|
4
|
-
import {
|
|
5
|
-
SimpleCell,
|
|
6
|
-
SimpleHeader,
|
|
7
|
-
SimpleRow,
|
|
8
|
-
SimpleTable,
|
|
9
|
-
} from '../../SimpleTable'
|
|
10
|
-
|
|
11
|
-
defineProps<{ headers: Record<string, string>[] }>()
|
|
12
|
-
|
|
13
|
-
const getDocumentationUrlForHttpHeader = (headerName: string) => {
|
|
14
|
-
return httpHeaders.find((header) => {
|
|
15
|
-
return header.name.toLowerCase() === headerName.toLowerCase()
|
|
16
|
-
})?.url
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Make the first letter and all letters after a - uppercase
|
|
20
|
-
const formatHeaderName = (headerName: string) => {
|
|
21
|
-
return headerName
|
|
22
|
-
.split('-')
|
|
23
|
-
.map((word) => {
|
|
24
|
-
return word.charAt(0).toUpperCase() + word.slice(1)
|
|
25
|
-
})
|
|
26
|
-
.join('-')
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
29
|
-
<template>
|
|
30
|
-
<CollapsibleSection title="Headers">
|
|
31
|
-
<SimpleTable v-if="headers.length > 0">
|
|
32
|
-
<SimpleRow>
|
|
33
|
-
<SimpleHeader>Key</SimpleHeader>
|
|
34
|
-
<SimpleHeader>Value</SimpleHeader>
|
|
35
|
-
</SimpleRow>
|
|
36
|
-
<SimpleRow
|
|
37
|
-
v-for="header in headers"
|
|
38
|
-
:key="header.name">
|
|
39
|
-
<SimpleCell
|
|
40
|
-
:href="getDocumentationUrlForHttpHeader(header.name)"
|
|
41
|
-
:strong="true"
|
|
42
|
-
:wrap="false">
|
|
43
|
-
{{ formatHeaderName(header.name) }}
|
|
44
|
-
</SimpleCell>
|
|
45
|
-
<SimpleCell>{{ header.value }}</SimpleCell>
|
|
46
|
-
</SimpleRow>
|
|
47
|
-
</SimpleTable>
|
|
48
|
-
<template v-else>
|
|
49
|
-
<div class="scalar-api-client__empty-state">No Headers</div>
|
|
50
|
-
</template>
|
|
51
|
-
</CollapsibleSection>
|
|
52
|
-
</template>
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import prettyBytes from 'pretty-bytes'
|
|
3
|
-
import prettyMilliseconds from 'pretty-ms'
|
|
4
|
-
import { computed } from 'vue'
|
|
5
|
-
|
|
6
|
-
import { type HttpStatusCode, httpStatusCodes } from '../../../fixtures'
|
|
7
|
-
import { type ClientResponse } from '../../../types'
|
|
8
|
-
import HelpfulLink from '../../HelpfulLink.vue'
|
|
9
|
-
|
|
10
|
-
const props = defineProps<{ response: any }>()
|
|
11
|
-
|
|
12
|
-
/** Size of the response */
|
|
13
|
-
const getContentLength = (response: ClientResponse) => {
|
|
14
|
-
if (response?.headers?.['X-API-Client-Content-Length']) {
|
|
15
|
-
return prettyBytes(
|
|
16
|
-
parseFloat(response.headers['X-API-Client-Content-Length']),
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
return prettyBytes(0)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Status text for the response */
|
|
23
|
-
const statusCodeInformation = computed((): HttpStatusCode | undefined => {
|
|
24
|
-
const responseStatusCode = props.response.statusCode
|
|
25
|
-
|
|
26
|
-
if (!responseStatusCode) {
|
|
27
|
-
return undefined
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return httpStatusCodes[responseStatusCode] ?? undefined
|
|
31
|
-
})
|
|
32
|
-
</script>
|
|
33
|
-
<template>
|
|
34
|
-
<div class="meta-item">
|
|
35
|
-
<!-- <span>182 ms</span> -->
|
|
36
|
-
<span>{{ prettyMilliseconds(response.duration) }}</span>
|
|
37
|
-
</div>
|
|
38
|
-
<div class="meta-item">
|
|
39
|
-
<!-- <span>20 Bytes</span> -->
|
|
40
|
-
<span>{{ getContentLength(response) }}</span>
|
|
41
|
-
</div>
|
|
42
|
-
<div class="meta-item">
|
|
43
|
-
<!-- <span>200</span> -->
|
|
44
|
-
<span
|
|
45
|
-
:class="`scalar-api-client__status scalar-api-client__status--${String(
|
|
46
|
-
response.statusCode,
|
|
47
|
-
).charAt(0)}xx`">
|
|
48
|
-
<template v-if="statusCodeInformation?.url">
|
|
49
|
-
<HelpfulLink :href="statusCodeInformation.url">
|
|
50
|
-
{{ response.statusCode }} {{ statusCodeInformation.name }}
|
|
51
|
-
</HelpfulLink>
|
|
52
|
-
</template>
|
|
53
|
-
<template v-else>
|
|
54
|
-
{{ response.statusCode }} {{ statusCodeInformation?.name }}
|
|
55
|
-
</template>
|
|
56
|
-
</span>
|
|
57
|
-
</div>
|
|
58
|
-
</template>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Response } from './Response.vue'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as ApiClient } from './ApiClient.vue'
|