@scalar/api-client 0.2.0 → 0.2.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 (59) hide show
  1. package/dist/components/SimpleTable/SimpleCell.vue.d.ts.map +1 -1
  2. package/dist/components/SimpleTable/SimpleHeader.vue.d.ts.map +1 -1
  3. package/dist/components/SimpleTable/SimpleRow.vue.d.ts.map +1 -1
  4. package/dist/components/SimpleTable/SimpleTable.vue.d.ts.map +1 -1
  5. package/dist/fixtures/index.d.ts +1 -1
  6. package/dist/fixtures/index.d.ts.map +1 -1
  7. package/dist/index.js +37 -26
  8. package/package.json +6 -6
  9. package/src/components/ApiClient/AddressBar.vue +462 -0
  10. package/src/components/ApiClient/ApiClient.vue +266 -0
  11. package/src/components/ApiClient/Request/Request.vue +271 -0
  12. package/src/components/ApiClient/Request/RequestAuth.vue +221 -0
  13. package/src/components/ApiClient/Request/RequestBody.vue +39 -0
  14. package/src/components/ApiClient/Request/RequestHeaders.vue +24 -0
  15. package/src/components/ApiClient/Request/RequestQuery.vue +25 -0
  16. package/src/components/ApiClient/Request/RequestVariables.vue +25 -0
  17. package/src/components/ApiClient/Request/index.ts +1 -0
  18. package/src/components/ApiClient/RequestHistory.vue +114 -0
  19. package/src/components/ApiClient/RequestHistoryItem.vue +59 -0
  20. package/src/components/ApiClient/Response/Copilot.vue.bak +385 -0
  21. package/src/components/ApiClient/Response/Response.vue +120 -0
  22. package/src/components/ApiClient/Response/ResponseBody.vue +23 -0
  23. package/src/components/ApiClient/Response/ResponseHeaders.vue +52 -0
  24. package/src/components/ApiClient/Response/ResponseMetaInformation.vue +58 -0
  25. package/src/components/ApiClient/Response/index.ts +1 -0
  26. package/src/components/ApiClient/index.ts +1 -0
  27. package/src/components/CodeMirror/CodeMirror.vue +232 -0
  28. package/src/components/CodeMirror/extensions/variables.ts +41 -0
  29. package/src/components/CodeMirror/index.ts +1 -0
  30. package/src/components/CollapsibleSection/CollapsibleSection.vue +149 -0
  31. package/src/components/CollapsibleSection/index.ts +1 -0
  32. package/src/components/FlowModal.vue +133 -0
  33. package/src/components/Grid/Grid.vue +511 -0
  34. package/src/components/Grid/SimpleGrid.vue +33 -0
  35. package/src/components/Grid/index.ts +2 -0
  36. package/src/components/HelpfulLink.vue +19 -0
  37. package/src/components/SimpleTable/SimpleCell.vue +47 -0
  38. package/src/components/SimpleTable/SimpleHeader.vue +17 -0
  39. package/src/components/SimpleTable/SimpleRow.vue +14 -0
  40. package/src/components/SimpleTable/SimpleTable.vue +13 -0
  41. package/src/components/SimpleTable/index.ts +4 -0
  42. package/src/fixtures/httpHeaders.ts +530 -0
  43. package/src/fixtures/httpStatusCodes.ts +259 -0
  44. package/src/fixtures/index.ts +6 -0
  45. package/src/helpers/createPlaceholderRequest.ts +16 -0
  46. package/src/helpers/generateParameters.ts +19 -0
  47. package/src/helpers/generateRequest.ts +26 -0
  48. package/src/helpers/index.ts +5 -0
  49. package/src/helpers/mapFromArray.ts +16 -0
  50. package/src/helpers/sendRequest.ts +94 -0
  51. package/src/hooks/index.ts +2 -0
  52. package/src/hooks/useCopilot.ts +64 -0
  53. package/src/hooks/useOperation.test.ts +7 -0
  54. package/src/hooks/useOperation.ts +43 -0
  55. package/src/index.ts +9 -0
  56. package/src/stores/apiClientRequestStore.ts +103 -0
  57. package/src/stores/apiClientStore.ts +57 -0
  58. package/src/stores/index.ts +5 -0
  59. package/src/types.ts +181 -0
@@ -0,0 +1,57 @@
1
+ import { reactive, readonly } from 'vue'
2
+
3
+ type State = {
4
+ showApiClient: boolean
5
+ activeApiClientEndpointId: string
6
+ activeItem: any
7
+ snippetType: string
8
+ activeSidebar: string
9
+ }
10
+
11
+ function defaultState(): State {
12
+ return {
13
+ showApiClient: false,
14
+ activeApiClientEndpointId: '',
15
+ activeItem: {},
16
+ snippetType: 'javascript',
17
+ activeSidebar: '',
18
+ }
19
+ }
20
+
21
+ const state = reactive<State>(defaultState())
22
+
23
+ function toggleApiClient(item?: any, forceShow = false) {
24
+ if (forceShow) {
25
+ state.showApiClient = true
26
+ } else {
27
+ state.showApiClient = !state.showApiClient
28
+ }
29
+ if (item) {
30
+ state.activeItem = item
31
+ }
32
+ }
33
+
34
+ function hideApiClient() {
35
+ state.showApiClient = false
36
+ }
37
+
38
+ function setActiveApiClientEndpointId(id: string) {
39
+ state.activeApiClientEndpointId = id
40
+ }
41
+
42
+ function setSnippetType(type: string) {
43
+ state.snippetType = type
44
+ }
45
+
46
+ function setActiveSidebar(item: string) {
47
+ state.activeSidebar = item
48
+ }
49
+
50
+ export const useApiClientStore = () => ({
51
+ state: readonly(state),
52
+ toggleApiClient,
53
+ setActiveApiClientEndpointId,
54
+ setSnippetType,
55
+ setActiveSidebar,
56
+ hideApiClient,
57
+ })
@@ -0,0 +1,5 @@
1
+ export { useApiClientStore } from './apiClientStore'
2
+ export {
3
+ useApiClientRequestStore,
4
+ createEmptyAuthState,
5
+ } from './apiClientRequestStore'
package/src/types.ts ADDED
@@ -0,0 +1,181 @@
1
+ export type BasicAuth = {
2
+ userName: string
3
+ password: string
4
+ active: boolean
5
+ }
6
+
7
+ export type OAuthTwo = {
8
+ generatedToken: string
9
+ discoveryURL: string
10
+ authURL: string
11
+ accessTokenURL: string
12
+ clientID: string
13
+ clientSecret: string
14
+ scope: string
15
+ active: boolean
16
+ }
17
+
18
+ export type Bearer = {
19
+ token: string
20
+ active: boolean
21
+ }
22
+
23
+ export type Digest = {
24
+ userName: string
25
+ password: string
26
+ active: boolean
27
+ }
28
+
29
+ export type AuthType = 'basic' | 'oauthTwo' | 'bearer' | 'digest' | 'none'
30
+
31
+ export type AuthState = {
32
+ type: AuthType
33
+ basic: BasicAuth
34
+ oauthTwo: OAuthTwo
35
+ bearer: Bearer
36
+ digest: Digest
37
+ }
38
+
39
+ export type BaseParameter = {
40
+ name: string
41
+ value: string | number
42
+ customClass?: string
43
+ }
44
+
45
+ export type Header = BaseParameter
46
+
47
+ export type Query = BaseParameter
48
+
49
+ export type FormDataItem = BaseParameter
50
+
51
+ /** Complete request state for a client request */
52
+ export type ClientRequestConfig = {
53
+ id?: string
54
+ name: string
55
+ url: string
56
+ /** HTTP Request Method */
57
+ type: string
58
+ /** Request path */
59
+ path: string
60
+ /** Path parameters */
61
+ parameters: BaseParameter[]
62
+ /** Query parameters */
63
+ query: Query[]
64
+ /** Request headers */
65
+ headers: Header[]
66
+ /** Content type matched body */
67
+ body: string
68
+ /** Optional form data body */
69
+ formData?: FormDataItem[]
70
+ }
71
+
72
+ /** Formatted request for the proxy server */
73
+ export type ProxyPayload = {
74
+ method: string
75
+ url: string
76
+ body: string
77
+ headers: Header[]
78
+ auth: Record<string, string>
79
+ grpc: boolean
80
+ }
81
+
82
+ /** Client response from the proxy */
83
+ export type ClientResponse = {
84
+ cookies: Record<string, string>
85
+ headers: Record<string, string>
86
+ statusCode: number
87
+ statusText: string
88
+ data: string
89
+ duration: number
90
+ }
91
+
92
+ export type RequestResult = {
93
+ request: ClientRequestConfig
94
+ response: ClientResponse
95
+ responseId: string
96
+ sentTime: number
97
+ }
98
+
99
+ export type Schema = {
100
+ format: string
101
+ type: string
102
+ }
103
+
104
+ export type Parameters = {
105
+ description?: string
106
+ in?: string
107
+ name: string
108
+ required?: boolean
109
+ schema?: Schema
110
+ }
111
+
112
+ export type Security = {
113
+ api_key?: any[]
114
+ petstore_auth?: string[]
115
+ }
116
+
117
+ export type ContentProperties = {
118
+ [key: string]: {
119
+ type: string
120
+ format: string
121
+ example: string
122
+ required: string[]
123
+ description?: string
124
+ properties?: ContentProperties
125
+ }
126
+ }
127
+
128
+ export type ContentSchema = {
129
+ schema: {
130
+ type: string
131
+ required: string[]
132
+ properties: ContentProperties
133
+ }
134
+ }
135
+
136
+ export type ContentType =
137
+ | 'application/json'
138
+ | 'application/xml'
139
+ | 'text/plain'
140
+ | 'text/html'
141
+ | 'application/x-www-form-urlencoded'
142
+ | 'multipart/form-data'
143
+
144
+ export type Content = {
145
+ [key in ContentType]: ContentSchema
146
+ }
147
+
148
+ export type RequestBody = {
149
+ description: string
150
+ content: Content
151
+ required: boolean
152
+ }
153
+
154
+ export type Response = {
155
+ description: string
156
+ content: any
157
+ }
158
+
159
+ export type Information = {
160
+ description: string
161
+ operationId: string
162
+ parameters: Parameters[]
163
+ responses: Record<string, Response>
164
+ security: Security[]
165
+ requestBody: RequestBody
166
+ summary: string
167
+ tags: string[]
168
+ }
169
+
170
+ export type Operation = {
171
+ httpVerb: string
172
+ path: string
173
+ operationId: string
174
+ name: string
175
+ description: string
176
+ information: Information
177
+ }
178
+
179
+ export type Server = {
180
+ url: string
181
+ }