-
Notifications
You must be signed in to change notification settings - Fork 534
/
Copy pathconsts.dart
484 lines (448 loc) · 18 KB
/
consts.dart
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
import 'dart:io';
import 'package:apidash_design_system/apidash_design_system.dart';
import 'package:apidash_core/apidash_core.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
const kDiscordUrl = "https://bit.ly/heyfoss";
const kGitUrl = "https://github.com/foss42/apidash";
const kIssueUrl = "$kGitUrl/issues";
const kDefaultUri = "api.apidash.dev";
const kAssetIntroMd = "assets/intro.md";
const kAssetSendingLottie = "assets/sending.json";
const kAssetSavingLottie = "assets/saving.json";
const kAssetSavedLottie = "assets/completed.json";
final kIsMacOS = !kIsWeb && Platform.isMacOS;
final kIsWindows = !kIsWeb && Platform.isWindows;
final kIsLinux = !kIsWeb && Platform.isLinux;
final kIsApple = !kIsWeb && (Platform.isIOS || Platform.isMacOS);
final kIsDesktop =
!kIsWeb && (Platform.isMacOS || Platform.isWindows || Platform.isLinux);
final kIsRunningTests = Platform.environment.containsKey('FLUTTER_TEST');
final kIsIOS = !kIsWeb && Platform.isIOS;
final kIsAndroid = !kIsWeb && Platform.isAndroid;
final kIsMobile = !kIsWeb && (Platform.isIOS || Platform.isAndroid);
const kWindowTitle = "API Dash";
const kMinWindowSize = Size(320, 640);
const kMinInitialWindowWidth = 1200.0;
const kMinInitialWindowHeight = 800.0;
const kMinRequestEditorDetailsCardPaneSize = 300.0;
final kHomeScaffoldKey = GlobalKey<ScaffoldState>();
final kEnvScaffoldKey = GlobalKey<ScaffoldState>();
final kHisScaffoldKey = GlobalKey<ScaffoldState>();
const kTabAnimationDuration = Duration(milliseconds: 200);
const kTabHeight = 40.0;
const kHeaderHeight = 32.0;
const kSegmentHeight = 24.0;
const kTextButtonMinWidth = 44.0;
const kRandMax = 100000;
const kSuggestionsMenuWidth = 300.0;
const kSuggestionsMenuMaxHeight = 200.0;
const kSegmentedTabWidth = 140.0;
const kSegmentedTabHeight = 32.0;
const kDataTableScrollbarTheme = ScrollbarThemeData(
crossAxisMargin: -4,
);
const kDataTableBottomPadding = 12.0;
const kDataTableRowHeight = 36.0;
const kIconRemoveDark = Icon(
Icons.remove_circle,
size: 16,
color: kColorDarkDanger,
);
final kIconRemoveLight = Icon(
Icons.remove_circle,
size: 16,
color: kColorLightDanger,
);
const kCodePreviewLinesLimit = 500;
enum HistoryRetentionPeriod {
oneWeek("1 Week", Icons.calendar_view_week_rounded),
oneMonth("1 Month", Icons.calendar_view_month_rounded),
threeMonths("3 Months", Icons.calendar_month_rounded),
forever("Forever", Icons.all_inclusive_rounded);
const HistoryRetentionPeriod(this.label, this.icon);
final String label;
final IconData icon;
}
enum ItemMenuOption {
edit("Rename"),
delete("Delete"),
duplicate("Duplicate");
const ItemMenuOption(this.label);
final String label;
}
enum SidebarMenuOption {
import("Import");
const SidebarMenuOption(this.label);
final String label;
}
final kEnvVarRegEx = RegExp(r'{{([^{}]*)}}');
enum CodegenLanguage {
curl("cURL", "bash", "curl"),
har("HAR", "json", "har"),
cCurlCodeGen("C (Curl)", "cpp", "c"),
cSharpHttpClient("C# (Http Client)", "cs", "cs"),
cSharpRestSharp("C# (Rest Sharp)", "cs", "cs"),
dartHttp("Dart (http)", "dart", "dart"),
dartDio("Dart (dio)", "dart", "dart"),
goHttp("Go (http)", "go", "go"),
jsAxios("JavaScript (axios)", "javascript", "js"),
jsFetch("JavaScript (fetch)", "javascript", "js"),
nodejsAxios("node.js (axios)", "javascript", "js"),
nodejsFetch("node.js (fetch)", "javascript", "js"),
javaAsyncHttpClient("Java (asynchttpclient)", "java", "java"),
javaHttpClient("Java (HttpClient)", "java", "java"),
javaOkHttp("Java (okhttp3)", "java", 'java'),
javaUnirest("Java (Unirest)", "java", "java"),
juliaHttp("Julia (HTTP)", "julia", "jl"),
kotlinOkHttp("Kotlin (okhttp3)", "kotlin", "kt"),
phpCurl("PHP (cURL)", "php", "php"),
phpGuzzle("PHP (guzzle)", "php", "php"),
phpHttpPlug("PHP (httpPlug)", "php", "php"),
pythonRequests("Python (requests)", "python", "py"),
pythonHttpClient("Python (http.client)", "python", "py"),
rubyFaraday("Ruby (Faraday)", "ruby", "rb"),
rubyNetHttp("Ruby (Net::Http)", "ruby", "rb"),
rustActix("Rust (Actix Client)", "rust", "rs"),
rustHyper("Rust (Hyper)", "rust", "rs"),
rustReqwest("Rust (reqwest)", "rust", "rs"),
rustCurl("Rust (curl-rust)", "rust", "rs"),
rustUreq("Rust (ureq)", "rust", "rs"),
swiftUrlSession("Swift (URLSession)", "swift", "swift");
const CodegenLanguage(this.label, this.codeHighlightLang, this.ext);
final String label;
final String codeHighlightLang;
final String ext;
}
enum ImportFormat {
curl("cURL"),
postman("Postman Collection v2.1"),
insomnia("Insomnia v4"),
har("Har v1.2");
const ImportFormat(this.label);
final String label;
}
const String kGlobalEnvironmentId = "global";
enum ResponseBodyView {
preview("Preview", Icons.visibility_rounded),
code("Preview", Icons.code_rounded),
raw("Raw", Icons.text_snippet_rounded),
none("Preview", Icons.warning);
const ResponseBodyView(this.label, this.icon);
final String label;
final IconData icon;
}
const kNoBodyViewOptions = [ResponseBodyView.none];
const kNoRawBodyViewOptions = [ResponseBodyView.none, ResponseBodyView.raw];
const kRawBodyViewOptions = [ResponseBodyView.raw];
const kCodeRawBodyViewOptions = [ResponseBodyView.code, ResponseBodyView.raw];
const kPreviewBodyViewOptions = [
ResponseBodyView.preview,
];
const kPreviewRawBodyViewOptions = [
ResponseBodyView.preview,
ResponseBodyView.raw
];
const kPreviewCodeRawBodyViewOptions = [
ResponseBodyView.preview,
ResponseBodyView.code,
ResponseBodyView.raw
];
const Map<String, Map<String, List<ResponseBodyView>>>
kResponseBodyViewOptions = {
kTypeApplication: {
kSubTypeDefaultViewOptions: kNoRawBodyViewOptions,
kSubTypeJson: kPreviewRawBodyViewOptions,
kSubTypeOctetStream: kNoBodyViewOptions,
kSubTypePdf: kPreviewBodyViewOptions,
kSubTypeSql: kCodeRawBodyViewOptions,
kSubTypeXml: kCodeRawBodyViewOptions,
kSubTypeYaml: kCodeRawBodyViewOptions,
kSubTypeXYaml: kCodeRawBodyViewOptions,
kSubTypeYml: kCodeRawBodyViewOptions,
},
kTypeImage: {
kSubTypeDefaultViewOptions: kPreviewBodyViewOptions,
kSubTypeSvg: kPreviewRawBodyViewOptions,
},
kTypeAudio: {
kSubTypeDefaultViewOptions: kPreviewBodyViewOptions,
},
kTypeVideo: {
kSubTypeDefaultViewOptions: kPreviewBodyViewOptions,
},
kTypeText: {
kSubTypeDefaultViewOptions: kRawBodyViewOptions,
kSubTypeCss: kCodeRawBodyViewOptions,
kSubTypeHtml: kCodeRawBodyViewOptions,
kSubTypeCsv: kPreviewRawBodyViewOptions,
kSubTypeJavascript: kCodeRawBodyViewOptions,
kSubTypeMarkdown: kCodeRawBodyViewOptions,
kSubTypeTextXml: kCodeRawBodyViewOptions,
kSubTypeTextYaml: kCodeRawBodyViewOptions,
kSubTypeTextYml: kCodeRawBodyViewOptions,
},
};
const Map<String, String> kCodeHighlighterMap = {
kSubTypeHtml: "xml",
kSubTypeSvg: "xml",
kSubTypeYaml: "yaml",
kSubTypeXYaml: "yaml",
kSubTypeYml: "yaml",
//kSubTypeTextYaml: "yaml",
kSubTypeTextYml: "yaml",
};
// HTTP response status codes
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
const kResponseCodeReasons = {
// 100s - Informational responses
100: 'Continue',
101: 'Switching Protocols',
102: 'Processing',
103: 'Early Hints',
// 200s - Successful responses
200: 'OK',
201: 'Created',
202: 'Accepted',
203: 'Non-Authoritative Information',
204: 'No Content',
205: 'Reset Content',
206: 'Partial Content',
207: 'Multi-Status',
208: 'Already Reported',
226: 'IM Used',
// 300s - Redirection messages
300: 'Multiple Choices',
301: 'Moved Permanently',
302: 'Found',
303: 'See Other',
304: 'Not Modified',
305: 'Use Proxy',
306: 'Switch Proxy',
307: 'Temporary Redirect',
308: 'Permanent Redirect',
// 400s - Client error responses
400: 'Bad Request',
401: 'Unauthorized',
402: 'Payment Required',
403: 'Forbidden',
404: 'Not Found',
405: 'Method Not Allowed',
406: 'Not Acceptable',
407: 'Proxy Authentication Required',
408: 'Request Timeout',
409: 'Conflict',
410: 'Gone',
411: 'Length Required',
412: 'Precondition Failed',
413: 'Payload Too Large',
414: 'URI Too Long',
415: 'Unsupported Media Type',
416: 'Range Not Satisfiable',
417: 'Expectation Failed',
418: "I'm a Teapot",
421: 'Misdirected Request',
422: 'Unprocessable Entity',
423: 'Locked',
424: 'Failed Dependency',
425: 'Too Early',
426: 'Upgrade Required',
428: 'Precondition Required',
429: 'Too Many Requests',
431: 'Request Header Fields Too Large',
451: 'Unavailable For Legal Reasons',
// 500s - Server error responses
500: 'Internal Server Error',
501: 'Not Implemented',
502: 'Bad Gateway',
503: 'Service Unavailable',
504: 'Gateway Timeout',
505: 'HTTP Version Not Supported',
506: 'Variant Also Negotiates',
507: 'Insufficient Storage',
508: 'Loop Detected',
510: 'Not Extended',
511: 'Network Authentication Required',
};
Map<String, String> kHttpHeadersMap = {
"Accept": "Specifies the media types that are acceptable for the response.",
"Accept-Encoding":
"Indicates the encoding methods the client can understand.",
"Accept-Charset": "Specifies the character sets that are acceptable.",
"Access-Control-Allow-Headers":
"Specifies a list of HTTP headers that can be used in an actual request after a preflight request including the Access-Control-Request-Headers header is made.",
"Access-Control-Allow-Methods":
"Specifies a list of HTTP request methods allowed during CORS. ",
"Access-Control-Allow-Origin":
"Indicates whether the response can be shared with the requesting code from the given origin.",
"Access-Control-Max-Age":
"Indicates the maximum amount of time the results of a preflight request can be cached.",
"Access-Control-Request-Headers":
"Used in preflight requests during CORS to specify the headers that will be included in the actual request.",
"Access-Control-Request-Method":
"Used in preflight requests during CORS to indicate the HTTP method that will be used in the actual request.",
"Accept-Language":
"Specifies the preferred natural language and locale for the response.",
"Authorization":
"Contains credentials for authenticating the client with the server.",
"Authorization Bearer Token": "Often used for token-based authentication.",
"Cache-Control":
"Provides directives for caching mechanisms in both requests and responses.",
"Connection":
"Informs whether the connection stays open or close after the current transaction finishes.",
"Content-Disposition":
"Specifies the presentation style (inline or attachment) of the response.",
"Content-Encoding":
"Indicates the encoding transformations that have been applied to the entity body of the response.",
"Content-Length":
"Indicates the size of the message body sent to the recipient in bytes.",
"Content-Security-Policy":
"Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.",
"Content-Type":
"Indicates the original media type of the resource (prior to any content encoding applied for sending)",
"Cookie": "Used to send previously stored cookies back to the server.",
"Cross-Origin-Embedder-Policy":
"Controls whether a document is allowed to be embedded in another document.",
"Cross-Origin-Opener-Policy":
"Controls which documents are allowed to open a new window or access the current window.",
"Cross-Origin-Resource-Policy":
"Controls how cross-origin requests for resources are handled.",
"Date": "Indicates the date and time at which the message was sent.",
"Device-Memory":
"Indicates the approximate amount of device memory in gigabytes.",
"DNT":
"Informs websites whether the user's preference is to opt out of online tracking.",
"Expect": "Indicates certain expectations that need to be met by the server.",
"Expires":
"Contains the date/time after which the response is considered expired",
"Forwarded":
"Contains information from the client-facing side of proxy servers that is altered or lost when a proxy is involved in the path of the request.",
"From":
"Contains an Internet email address for a human user who controls the requesting user agent.",
"Host": "Specifies the domain name of the server and the port number.",
"If-Match":
"Used for conditional requests, allows the server to respond based on certain conditions.",
"If-Modified-Since":
"Used for conditional requests, allows the server to respond based on certain conditions.",
"If-None-Match":
"Used for conditional requests, allows the server to respond based on certain conditions.",
"If-Range":
"Used in conjunction with the Range header to conditionally request a partial resource.",
"If-Unmodified-Since":
"Used for conditional requests, allows the server to respond based on certain conditions.",
"Keep-Alive":
"Used to allow the connection to be reused for further requests.",
"Location":
"Indicates the URL a client should redirect to for further interaction.",
"Max-Forwards":
"Indicates the remaining number of times a request can be forwarded by proxies.",
"Origin": "Specifies the origin of a cross-origin request.",
"Proxy-Authorization":
"Contains credentials for authenticating a client with a proxy server.",
"Range":
"Used to request only part of a resource, typically in the context of downloading large files.",
"Referer":
"Indicates the URL of the page that referred the client to the current URL.",
"Referrer-Policy":
"Specifies how much information the browser should include in the Referer header when navigating to other pages.",
"Retry-After":
"Informs the client how long it should wait before making another request after a server has responded with a rate-limiting status code.",
"Save-Data": "Indicates the client's preference for reduced data usage.",
"Server": "Indicates the software used by the origin server.",
"Strict-Transport-Security":
"Instructs the browser to always use HTTPS for the given domain.",
"TE": "Specifies the transfer encodings that are acceptable to the client.",
"Upgrade-Insecure-Requests":
"Instructs the browser to prefer secure connections when available.",
"User-Agent":
"Identifies the client software and version making the request.",
"Via":
"Indicates intermediate proxies or gateways through which the request or response has passed.",
"X-Api-Key": "Used to authenticate requests to an API with an API key.",
"X-Content-Type-Options":
"Used to prevent browsers from MIME-sniffing a response.",
"X-CSRF-Token":
"Used for protection against Cross-Site Request Forgery (CSRF) attacks.",
"X-Forwarded-For":
"Identifies the client's original IP address when behind a proxy or load balancer.",
"X-Frame-Options":
"Controls whether a webpage can be displayed within an iframe or other embedded frame elements.",
"X-Requested-With":
"Indicates whether the request was made with JavaScript using XMLHttpRequest.",
"X-XSS-Protection":
"Enables or disables the browser's built-in cross-site scripting (XSS) filter.",
};
const kMimeTypeRaiseIssue =
"{% if showRaw %}Please click on 'Raw' to view the unformatted raw results as we{% else %}We{% endif %} encountered an error rendering this {% if showContentType %}Content-Type {% endif %}{{type}}.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue.";
const kUnexpectedRaiseIssue =
"\nIf the behaviour is unexpected, please raise an issue in API Dash GitHub repo so that we can resolve it.";
const kRaiseIssue =
"\nPlease raise an issue in API Dash GitHub repo so that we can resolve it.";
const kHintTextUrlCard = "Enter API endpoint like https://$kDefaultUri/";
const kLabelPlusNew = "+ New";
const kLabelMoreOptions = "More Options";
const kLabelSend = "Send";
const kLabelSending = "Sending..";
const kLabelBusy = "Busy";
const kLabelCopy = "Copy";
const kLabelShare = "Share";
const kLabelSave = "Save";
const kLabelDownload = "Download";
const kLabelSaving = "Saving";
const kLabelSaved = "Saved";
const kLabelCode = "Code";
const kLabelDuplicate = "Duplicate";
const kLabelSelect = "Select";
const kLabelContinue = "Continue";
const kLabelCancel = "Cancel";
const kLabelOk = "Ok";
const kLabelImport = "Import";
const kUntitled = "untitled";
// Request Pane
const kLabelRequest = "Request";
const kLabelHideCode = "Hide Code";
const kLabelViewCode = "View Code";
const kLabelURLParams = "URL Params";
const kLabelHeaders = "Headers";
const kLabelBody = "Body";
const kLabelQuery = "Query";
const kNameCheckbox = "Checkbox";
const kNameURLParam = "URL Parameter";
const kNameHeader = "Header Name";
const kNameValue = "Value";
const kNameField = "Field";
const kHintAddURLParam = "Add URL Parameter";
const kHintAddValue = "Add Value";
const kHintAddName = "Add Name";
const kHintAddFieldName = "Add Field Name";
const kLabelAddParam = "Add Param";
const kLabelAddHeader = "Add Header";
const kLabelAddVariable = "Add Variable";
const kLabelSelectFile = "Select File";
const kLabelAddFormField = "Add Form Field";
const kHintContent = "Enter content";
const kHintText = "Enter text";
const kHintJson = "Enter JSON";
const kHintQuery = "Enter Query";
// Response Pane
const kLabelNotSent = "Not Sent";
const kLabelResponse = "Response";
const kLabelResponseBody = "Response Body";
const kTooltipClearResponse = "Clear Response";
const kHeaderRow = ["Header Name", "Header Value"];
const kLabelRequestHeaders = "Request Headers";
const kLabelResponseHeaders = "Response Headers";
const kLabelItems = "items";
const kNullResponseModelError = "Error: Response data does not exist.";
const kMsgNullBody = "Response body is missing (null).";
const kMsgNoContent = "No content";
const kMsgUnknowContentType = "Unknown Response Content-Type";
// Workspace Selector
const kMsgSelectWorkspace = "Create your workspace";
// History Page
const kTitleClearHistory = 'Clear History';
const kMsgClearHistory =
'Clearing History is permanent. Do you want to continue?';
const kMsgClearHistorySuccess = 'History cleared successfully';
const kMsgClearHistoryError = 'Error clearing history';
const kMsgShareError = "Unable to share";