-
Notifications
You must be signed in to change notification settings - Fork 2
/
paw.d.ts
executable file
·528 lines (476 loc) · 15.8 KB
/
paw.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
declare module 'promise'
declare global {
namespace NodeJS {
interface Global {
location: any
}
}
function registerImporter(importer: any): void
function registerCodeGenerator(generator: any): void
interface Logger {
log: (..._args: unknown[]) => void
info: (..._args: unknown[]) => void
}
type MapKeyedWithString<T> = { [key: string]: T }
type GroupedRequestType = { group: string; path: string }
type CreateRequestGroupType = {
group: string
paths: string[]
}
type TransformStringType = {
defaultValue: string
envManager: EnvironmentManager
stringInput: string
requestInput: Paw.Request
}
type DynamicStringComponent = string | DynamicValue
class DynamicString {
length: number
components: DynamicStringComponent[]
constructor(...components: DynamicStringComponent[])
getComponentAtIndex(index: number): DynamicStringComponent | null
getSimpleString(): string
getOnlyString(): string | null
getOnlyDynamicValue(): DynamicValue | null
getEvaluatedString(): string
copy(): DynamicString
appendString(string: string): void
appendDynamicValue(dynamicValue: DynamicValue): void
appendDynamicString(dynamicString: DynamicString): void
}
class DynamicValue {
public type: string
constructor(type: string, properties?: { [key: string]: any })
getEvaluatedString(): string
copy(): DynamicValue
variableUUID: string
// @todo: confirm whether bookmarkData field should be accessed publicly
bookmarkData?: string
}
class NetworkHTTPRequest {}
class BasicAuth {
username: string | DynamicString | null
password: string | DynamicString | null
}
class OAuth1 {
oauth_consumer_key: string | DynamicString | null
oauth_consumer_secret: string | DynamicString | null
oauth_token: string | DynamicString | null
oauth_token_secret: string | DynamicString | null
oauth_nonce: string | DynamicString | null | undefined
oauth_timestamp: string | DynamicString | null | undefined
oauth_callback: string | DynamicString | null | undefined
oauth_signature: string | DynamicString | null | undefined
oauth_signature_method: string | null | undefined
oauth_version: string | undefined
oauth_additional_parameters: string | DynamicString | null | undefined
}
class OAuth2 {
client_id: string | DynamicString | null
client_secret: string | DynamicString | null
authorization_uri: string | DynamicString | null
access_token_uri: string | DynamicString | null
redirect_uri: string | DynamicString | null
scope: string | DynamicString | null | undefined
state: string | DynamicString | null | undefined
token: string | DynamicString | null | undefined
token_prefix: string | DynamicString | null | undefined
grant_type: string | undefined
}
}
declare namespace Paw {
interface RuntimeInfo {
task: string
isMainThread: boolean
}
interface DocumentInfo {
name: string | null
uuid: string | null
isCloudProject: boolean
cloudProjectId: number | null
cloudProject: {
id: number | null
currentCommitSha: string | null
currentBranch: string | null
mainBranch: string
isSynced: boolean
} | null
cloudTeam: {
id: number | null
name: string | null
} | null
}
interface UserInfo {
username: string | null
email: string | null
avatar_url: string | null
}
class Context {
runtimeInfo: RuntimeInfo
allowsMutation: boolean
document: DocumentInfo
user: UserInfo | null
createRequest(
name?: string | null,
method?: string | DynamicString | null,
url?: string | DynamicString | null,
description?: string | null,
order?: number,
): Request
createRequestGroup(name: string | null): RequestGroup
createEnvironmentDomain(name: string | null): EnvironmentDomain
createSecureValue(name: string | null): DynamicValue
createJSONDynamicValue(name: string | null): DynamicValue
getCurrentRequest(isRequired?: boolean): Request | null
getRequestByName(name: string): Request | null
getRequestGroupByName(name: string): RequestGroup | null
getEnvironmentDomainByName(name: string): EnvironmentDomain | null
getEnvironmentVariableByName(name: string): EnvironmentVariable | null
getRequestById(id: string): Request | null
getRequestGroupById(id: string): RequestGroup | null
getEnvironmentDomainById(id: string): EnvironmentDomain | null
getEnvironmentVariableById(id: string): EnvironmentVariable | null
getEnvironmentById(id: string): Environment | null
getRootRequests(): Request[]
getRootGroups(): RequestGroup[]
getRootRequestTreeItems(): RequestTreeItem[]
getAllRequests(): Request[]
getAllGroups(): RequestGroup[]
getAllRequestTreeItems(): RequestTreeItem[]
getSelectedRequests(): Request[]
getSelectedGroups(): RequestGroup[]
getSelectedRequestTreeItems(): RequestTreeItem[]
stringifyJSONItems(...items: any[]): string | null
parseJSONItems(json: string): any[] | null
}
class RequestTreeItem {
readonly id: string
readonly parent: RequestTreeItem | null
readonly urlBase: string
readonly urlQuery: string
readonly urlParametersNames: string[]
readonly urlEncodedBodyKeys: string[] | null
readonly headersNames: string[]
readonly variables: RequestVariable[]
name: string
description: string
order: number
url: string | DynamicString
urlParameters: { [key: string]: string | DynamicString }
method: string | DynamicString
headers: { [key: string]: string | DynamicString }
body: string | DynamicString | null
urlEncodedBody: { [key: string]: string | DynamicString } | null
multipartBody: { [key: string]: string | DynamicString } | null
jsonBody: object | null
httpBasicAuth: BasicAuth | null
oauth1: OAuth1 | null
oauth2: OAuth2 | null
timeout: number
followRedirects: boolean
redirectAuthorization: boolean
redirectMethod: boolean
sendCookies: boolean
storeCookies: boolean
clientCertificate: DynamicString | null
getUrl(isDynamic?: boolean): string | DynamicString
getUrlBase(isDynamic?: boolean): string | DynamicString
getUrlParametersArray(): KeyValue[]
getUrlParametersNames(): string[]
getUrlParameters(
isDynamic?: boolean,
): { [key: string]: string | DynamicString }
getUrlParameterByName(
name: string,
isDynamic?: boolean,
): string | DynamicString | null
setUrlParameter(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue
setUrlParameterByName(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue // alias of setUrlParameter()
addUrlParameter(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue
addRawUrlQuery(query: string | DynamicString): KeyValue
getMethod(isDynamic?: boolean): string | DynamicString
getHeaders(isDynamic?: boolean): { [key: string]: string | DynamicString }
getHeadersNames(): string[]
getHeaderByName(
name: string,
isDynamic?: boolean,
): string | DynamicString | null
getHeadersArray(): KeyValue[]
setHeader(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue
addHeader(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue
getBody(isDynamic?: boolean): string | DynamicString | null
getUrlEncodedBody(
isDynamic?: boolean,
): { [key: string]: string | DynamicString } | null
getUrlEncodedBodyKeys(): string[] | null
getUrlEncodedBodyKey(key: string): string | null
getMultipartBody(
isDynamic?: boolean,
): { [key: string]: string | DynamicString } | null
getJsonBodyKeyPath(keyPath: string): object | null
getHttpBasicAuth(isDynamic?: boolean): BasicAuth | null
getOAuth1(isDynamic?: boolean): OAuth1 | null
getOAuth2(isDynamic?: boolean): OAuth2 | null
getVariablesNames(): string[]
getVariableByName(name: string): RequestVariable | null
getVariableById(id: string): RequestVariable | null
addVariable(
name: string,
value: string | DynamicString,
description: string,
): RequestVariable
getLastExchange(): HTTPExchange | null
getAllExchanges(): HTTPExchange[]
clone(newName: string): Request
deleteRequest(): boolean
}
enum KeyValueMode {
Normal = 0,
NormalAlwaysAddEqualSign = 1,
Raw = 2,
}
class KeyValue {
readonly id: string
readonly request: Request
readonly isHeader: boolean
readonly isUrlParameter: boolean
name: DynamicString
value: DynamicString
enabled: boolean
mode: KeyValueMode
}
class Request extends RequestTreeItem {
readonly id: string
readonly parent: RequestTreeItem | null
readonly urlBase: string
readonly urlQuery: string
readonly urlParametersNames: string[]
readonly headersNames: string[]
readonly urlEncodedBodyKeys: string[] | null
readonly variables: RequestVariable[]
name: string
description: string
order: number
url: string | DynamicString
timeout: number
followRedirects: boolean
redirectAuthorization: boolean
redirectMethod: boolean
sendCookies: boolean
storeCookies: boolean
clientCertificate: DynamicString | null
urlParameters: { [key: string]: string | DynamicString }
method: string | DynamicString
headers: { [key: string]: string | DynamicString }
body: string | DynamicString | null
urlEncodedBody: { [key: string]: string | DynamicString } | null
multipartBody: { [key: string]: string | DynamicString } | null
jsonBody: object | null
httpBasicAuth: BasicAuth | null
oauth1: OAuth1 | null
oauth2: OAuth2 | null
getUrl(isDynamic?: boolean): string | DynamicString
getUrlBase(isDynamic?: boolean): string | DynamicString
getUrlParameters(
isDynamic?: boolean,
): { [key: string]: string | DynamicString }
getUrlParametersArray(): KeyValue[]
getUrlParametersNames(): string[]
getUrlParameterByName(
name: string,
isDynamic?: boolean,
): string | DynamicString | null
setUrlParameter(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue
setUrlParameterByName(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue // alias of setUrlParameter()
addUrlParameter(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue
addRawUrlQuery(query: string | DynamicString): KeyValue
getMethod(isDynamic?: boolean): string | DynamicString
getHeaders(isDynamic?: boolean): { [key: string]: string | DynamicString }
getHeadersNames(): string[]
getHeadersArray(): KeyValue[]
getHeaderByName(
name: string,
isDynamic?: boolean,
): string | DynamicString | null
setHeader(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue
addHeader(
name: string | DynamicString,
value: string | DynamicString,
): KeyValue
getBody(isDynamic?: boolean): string | DynamicString | null
getUrlEncodedBodyKeys(): string[] | null
getUrlEncodedBodyKey(key: string): string | null
getUrlEncodedBody(
isDynamic?: boolean,
): { [key: string]: string | DynamicString } | null
getMultipartBody(
isDynamic?: boolean,
): { [key: string]: string | DynamicString } | null
getJsonBodyKeyPath(keyPath: string): object | null
getHttpBasicAuth(isDynamic?: boolean): BasicAuth | null
getOAuth1(isDynamic?: boolean): OAuth1 | null
getOAuth2(isDynamic?: boolean): OAuth2 | null
getVariablesNames(): string[]
getVariableByName(name: string): RequestVariable | null
getVariableById(id: string): RequestVariable | null
addVariable(
name: string,
value: string | DynamicString,
description: string,
): RequestVariable
getLastExchange(): HTTPExchange | null
getAllExchanges(): HTTPExchange[]
clone(newName: string): Request
deleteRequest(): boolean
}
class RequestGroup extends RequestTreeItem {
readonly id: string
readonly parent: RequestTreeItem | null
order: number
getChildren(): RequestTreeItem[]
getChildRequests(): Request[]
getChildGroups(): RequestGroup[]
appendChild(child: RequestTreeItem): void
insertChild(child: RequestTreeItem, index: number): void
deleteGroup(): boolean
}
class RequestVariable {
readonly id: string
readonly request: Request
name: string
value: string | DynamicString | null
description: string | null
required: boolean
schema: string | DynamicString | null
getCurrentValue(isDynamic?: boolean): string | DynamicString | null
getSchema(isDynamic?: boolean): string | DynamicString | null
createDynamicValue(): DynamicValue
createDynamicString(): DynamicString
}
class EnvironmentDomain {
readonly id: string
readonly variables: EnvironmentVariable[]
readonly environments: Environment[]
name: string | null
order: number
getVariableByName(name: string): EnvironmentVariable | null
createEnvironmentVariable(name: string): EnvironmentVariable
getEnvironmentByName(name: string): Environment | null
createEnvironment(name: string): Environment
}
class Environment {
readonly id: string
name: string | null
domain: EnvironmentDomain
order: number
getVariablesValues(
isDynamic?: boolean,
): { [key: string]: string | DynamicString }
setVariablesValues(values: { [key: string]: string | DynamicString }): void
}
class EnvironmentVariable {
readonly id: string
name: string | null
domain: EnvironmentDomain
order: number
getCurrentValue(isDynamic?: boolean): string | DynamicString | null
getValue(
environment: Environment,
isDynamic?: boolean,
): string | DynamicString | null
setCurrentValue(value: string | DynamicString): void
setValue(value: string | DynamicString, environment: Environment): void
createDynamicValue(): DynamicValue
createDynamicString(): DynamicString
}
class HTTPExchange {
readonly id: string
readonly requestMethod: string
readonly requestUrl: string
readonly requestBody: string
readonly requestHeaders: { [headerName: string]: string }
readonly requestHeaderString: string
readonly responseStatusCode: number
readonly responseStatusLine: string
readonly responseHeaders: { [headerName: string]: string }
readonly responseHeaderString: string
readonly responseBody: string
readonly responseTime: number
readonly downloadTime: number
readonly date: Date
getRequestHeaderByName(headerName: string): string | null
getResponseHeaderByName(headerName: string): string | null
}
interface ExtensionProperties {
identifier: string
title: string
fileExtension?: string[]
languageHighlighter?: string
inputs?: unknown
help?: string
}
class Importer {
public canImport(context: Context, items: ExtensionItem[]): number
public import(
context: Context,
items: ExtensionItem[],
options: ExtensionOption,
): boolean | Promise<boolean>
}
class Generator {
public generate(
context: Context,
requests: Request[],
options: ExtensionOption,
): string
}
class ExtensionImportFile {
name: string
path: string
}
class ExtensionOption {
inputs: { [key: string]: any } | null
file: ExtensionImportFile | null
hideCredentials: boolean
parent: RequestTreeItem | null
order: number | null
}
class ExtensionItem {
content: string
name: string
uri: string
url: string | null
file: ExtensionImportFile
mimeType: string | null
httpHeaders: object | null
httpStatus: number | null
}
}
export default Paw