dart-tools 0.3.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.
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/core/ApiError.d.ts +10 -0
- package/dist/core/ApiError.js +16 -0
- package/dist/core/ApiError.js.map +1 -0
- package/dist/core/ApiRequestOptions.d.ts +13 -0
- package/dist/core/ApiRequestOptions.js +3 -0
- package/dist/core/ApiRequestOptions.js.map +1 -0
- package/dist/core/ApiResult.d.ts +7 -0
- package/dist/core/ApiResult.js +3 -0
- package/dist/core/ApiResult.js.map +1 -0
- package/dist/core/CancelablePromise.d.ts +20 -0
- package/dist/core/CancelablePromise.js +117 -0
- package/dist/core/CancelablePromise.js.map +1 -0
- package/dist/core/OpenAPI.d.ts +16 -0
- package/dist/core/OpenAPI.js +16 -0
- package/dist/core/OpenAPI.js.map +1 -0
- package/dist/core/request.d.ts +34 -0
- package/dist/core/request.js +295 -0
- package/dist/core/request.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +685 -0
- package/dist/index.umd.js +697 -0
- package/dist/models/Assignee.d.ts +4 -0
- package/dist/models/Assignee.js +3 -0
- package/dist/models/Assignee.js.map +1 -0
- package/dist/models/Comment.d.ts +22 -0
- package/dist/models/Comment.js +3 -0
- package/dist/models/Comment.js.map +1 -0
- package/dist/models/CommentCreate.d.ts +10 -0
- package/dist/models/CommentCreate.js +3 -0
- package/dist/models/CommentCreate.js.map +1 -0
- package/dist/models/ConciseDoc.d.ts +21 -0
- package/dist/models/ConciseDoc.js +3 -0
- package/dist/models/ConciseDoc.js.map +1 -0
- package/dist/models/ConciseTask.d.ts +65 -0
- package/dist/models/ConciseTask.js +3 -0
- package/dist/models/ConciseTask.js.map +1 -0
- package/dist/models/Doc.d.ts +22 -0
- package/dist/models/Doc.js +3 -0
- package/dist/models/Doc.js.map +1 -0
- package/dist/models/DocCreate.d.ts +14 -0
- package/dist/models/DocCreate.js +3 -0
- package/dist/models/DocCreate.js.map +1 -0
- package/dist/models/DocUpdate.d.ts +18 -0
- package/dist/models/DocUpdate.js +3 -0
- package/dist/models/DocUpdate.js.map +1 -0
- package/dist/models/PaginatedConciseDocList.d.ts +7 -0
- package/dist/models/PaginatedConciseDocList.js +3 -0
- package/dist/models/PaginatedConciseDocList.js.map +1 -0
- package/dist/models/PaginatedConciseTaskList.d.ts +7 -0
- package/dist/models/PaginatedConciseTaskList.js +3 -0
- package/dist/models/PaginatedConciseTaskList.js.map +1 -0
- package/dist/models/Task.d.ts +66 -0
- package/dist/models/Task.js +3 -0
- package/dist/models/Task.js.map +1 -0
- package/dist/models/TaskCreate.d.ts +58 -0
- package/dist/models/TaskCreate.js +3 -0
- package/dist/models/TaskCreate.js.map +1 -0
- package/dist/models/TaskUpdate.d.ts +62 -0
- package/dist/models/TaskUpdate.js +3 -0
- package/dist/models/TaskUpdate.js.map +1 -0
- package/dist/models/UserSpaceConfiguration.d.ts +12 -0
- package/dist/models/UserSpaceConfiguration.js +3 -0
- package/dist/models/UserSpaceConfiguration.js.map +1 -0
- package/dist/models/WrappedComment.d.ts +4 -0
- package/dist/models/WrappedComment.js +3 -0
- package/dist/models/WrappedComment.js.map +1 -0
- package/dist/models/WrappedCommentCreate.d.ts +4 -0
- package/dist/models/WrappedCommentCreate.js +3 -0
- package/dist/models/WrappedCommentCreate.js.map +1 -0
- package/dist/models/WrappedDoc.d.ts +4 -0
- package/dist/models/WrappedDoc.js +3 -0
- package/dist/models/WrappedDoc.js.map +1 -0
- package/dist/models/WrappedDocCreate.d.ts +4 -0
- package/dist/models/WrappedDocCreate.js +3 -0
- package/dist/models/WrappedDocCreate.js.map +1 -0
- package/dist/models/WrappedDocUpdate.d.ts +4 -0
- package/dist/models/WrappedDocUpdate.js +3 -0
- package/dist/models/WrappedDocUpdate.js.map +1 -0
- package/dist/models/WrappedTask.d.ts +4 -0
- package/dist/models/WrappedTask.js +3 -0
- package/dist/models/WrappedTask.js.map +1 -0
- package/dist/models/WrappedTaskCreate.d.ts +4 -0
- package/dist/models/WrappedTaskCreate.js +3 -0
- package/dist/models/WrappedTaskCreate.js.map +1 -0
- package/dist/models/WrappedTaskUpdate.d.ts +4 -0
- package/dist/models/WrappedTaskUpdate.js +3 -0
- package/dist/models/WrappedTaskUpdate.js.map +1 -0
- package/dist/services/CommentService.d.ts +13 -0
- package/dist/services/CommentService.js +27 -0
- package/dist/services/CommentService.js.map +1 -0
- package/dist/services/ConfigService.d.ts +11 -0
- package/dist/services/ConfigService.js +24 -0
- package/dist/services/ConfigService.js.map +1 -0
- package/dist/services/DocService.d.ts +79 -0
- package/dist/services/DocService.js +108 -0
- package/dist/services/DocService.js.map +1 -0
- package/dist/services/TaskService.d.ts +76 -0
- package/dist/services/TaskService.js +117 -0
- package/dist/services/TaskService.js.map +1 -0
- package/index.d.ts +2 -0
- package/package.json +72 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
|
|
4
|
+
class ApiError extends Error {
|
|
5
|
+
constructor(request, response, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "ApiError";
|
|
8
|
+
this.url = response.url;
|
|
9
|
+
this.status = response.status;
|
|
10
|
+
this.statusText = response.statusText;
|
|
11
|
+
this.body = response.body;
|
|
12
|
+
this.request = request;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/******************************************************************************
|
|
17
|
+
Copyright (c) Microsoft Corporation.
|
|
18
|
+
|
|
19
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
20
|
+
purpose with or without fee is hereby granted.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
23
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
24
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
27
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
29
|
+
***************************************************************************** */
|
|
30
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
34
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
35
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
36
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
40
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
41
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
42
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
43
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
47
|
+
var e = new Error(message);
|
|
48
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var _CancelablePromise_isResolved, _CancelablePromise_isRejected, _CancelablePromise_isCancelled, _CancelablePromise_cancelHandlers, _CancelablePromise_promise, _CancelablePromise_resolve, _CancelablePromise_reject;
|
|
52
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
53
|
+
/* istanbul ignore file */
|
|
54
|
+
/* tslint:disable */
|
|
55
|
+
/* eslint-disable */
|
|
56
|
+
class CancelError extends Error {
|
|
57
|
+
constructor(message) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.name = "CancelError";
|
|
60
|
+
}
|
|
61
|
+
get isCancelled() {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
class CancelablePromise {
|
|
66
|
+
constructor(executor) {
|
|
67
|
+
_CancelablePromise_isResolved.set(this, void 0);
|
|
68
|
+
_CancelablePromise_isRejected.set(this, void 0);
|
|
69
|
+
_CancelablePromise_isCancelled.set(this, void 0);
|
|
70
|
+
_CancelablePromise_cancelHandlers.set(this, void 0);
|
|
71
|
+
_CancelablePromise_promise.set(this, void 0);
|
|
72
|
+
_CancelablePromise_resolve.set(this, void 0);
|
|
73
|
+
_CancelablePromise_reject.set(this, void 0);
|
|
74
|
+
__classPrivateFieldSet(this, _CancelablePromise_isResolved, false, "f");
|
|
75
|
+
__classPrivateFieldSet(this, _CancelablePromise_isRejected, false, "f");
|
|
76
|
+
__classPrivateFieldSet(this, _CancelablePromise_isCancelled, false, "f");
|
|
77
|
+
__classPrivateFieldSet(this, _CancelablePromise_cancelHandlers, [], "f");
|
|
78
|
+
__classPrivateFieldSet(this, _CancelablePromise_promise, new Promise((resolve, reject) => {
|
|
79
|
+
__classPrivateFieldSet(this, _CancelablePromise_resolve, resolve, "f");
|
|
80
|
+
__classPrivateFieldSet(this, _CancelablePromise_reject, reject, "f");
|
|
81
|
+
const onResolve = (value) => {
|
|
82
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
__classPrivateFieldSet(this, _CancelablePromise_isResolved, true, "f");
|
|
86
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_resolve, "f"))
|
|
87
|
+
__classPrivateFieldGet(this, _CancelablePromise_resolve, "f").call(this, value);
|
|
88
|
+
};
|
|
89
|
+
const onReject = (reason) => {
|
|
90
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
__classPrivateFieldSet(this, _CancelablePromise_isRejected, true, "f");
|
|
94
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_reject, "f"))
|
|
95
|
+
__classPrivateFieldGet(this, _CancelablePromise_reject, "f").call(this, reason);
|
|
96
|
+
};
|
|
97
|
+
const onCancel = (cancelHandler) => {
|
|
98
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").push(cancelHandler);
|
|
102
|
+
};
|
|
103
|
+
Object.defineProperty(onCancel, "isResolved", {
|
|
104
|
+
get: () => __classPrivateFieldGet(this, _CancelablePromise_isResolved, "f"),
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(onCancel, "isRejected", {
|
|
107
|
+
get: () => __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f"),
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(onCancel, "isCancelled", {
|
|
110
|
+
get: () => __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f"),
|
|
111
|
+
});
|
|
112
|
+
return executor(onResolve, onReject, onCancel);
|
|
113
|
+
}), "f");
|
|
114
|
+
}
|
|
115
|
+
get [(_CancelablePromise_isResolved = new WeakMap(), _CancelablePromise_isRejected = new WeakMap(), _CancelablePromise_isCancelled = new WeakMap(), _CancelablePromise_cancelHandlers = new WeakMap(), _CancelablePromise_promise = new WeakMap(), _CancelablePromise_resolve = new WeakMap(), _CancelablePromise_reject = new WeakMap(), Symbol.toStringTag)]() {
|
|
116
|
+
return "Cancellable Promise";
|
|
117
|
+
}
|
|
118
|
+
then(onFulfilled, onRejected) {
|
|
119
|
+
return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").then(onFulfilled, onRejected);
|
|
120
|
+
}
|
|
121
|
+
catch(onRejected) {
|
|
122
|
+
return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").catch(onRejected);
|
|
123
|
+
}
|
|
124
|
+
finally(onFinally) {
|
|
125
|
+
return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").finally(onFinally);
|
|
126
|
+
}
|
|
127
|
+
cancel() {
|
|
128
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
__classPrivateFieldSet(this, _CancelablePromise_isCancelled, true, "f");
|
|
132
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length) {
|
|
133
|
+
try {
|
|
134
|
+
for (const cancelHandler of __classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f")) {
|
|
135
|
+
cancelHandler();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
console.warn("Cancellation threw an error", error);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length = 0;
|
|
144
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_reject, "f"))
|
|
145
|
+
__classPrivateFieldGet(this, _CancelablePromise_reject, "f").call(this, new CancelError("Request aborted"));
|
|
146
|
+
}
|
|
147
|
+
get isCancelled() {
|
|
148
|
+
return __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var _a;
|
|
153
|
+
const OpenAPI = {
|
|
154
|
+
BASE: `${(_a = process.env.DART_HOST) !== null && _a !== void 0 ? _a : "https://app.itsdart.com"}/api/v0/public`,
|
|
155
|
+
VERSION: "1.0.0",
|
|
156
|
+
WITH_CREDENTIALS: false,
|
|
157
|
+
CREDENTIALS: "include",
|
|
158
|
+
TOKEN: undefined,
|
|
159
|
+
USERNAME: undefined,
|
|
160
|
+
PASSWORD: undefined,
|
|
161
|
+
HEADERS: { Authorization: `Bearer ${process.env.DART_TOKEN}` },
|
|
162
|
+
ENCODE_PATH: undefined,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
166
|
+
/* istanbul ignore file */
|
|
167
|
+
/* tslint:disable */
|
|
168
|
+
/* eslint-disable */
|
|
169
|
+
const isDefined = (value) => {
|
|
170
|
+
return value !== undefined && value !== null;
|
|
171
|
+
};
|
|
172
|
+
const isString = (value) => {
|
|
173
|
+
return typeof value === "string";
|
|
174
|
+
};
|
|
175
|
+
const isStringWithValue = (value) => {
|
|
176
|
+
return isString(value) && value !== "";
|
|
177
|
+
};
|
|
178
|
+
const isBlob = (value) => {
|
|
179
|
+
return (typeof value === "object" &&
|
|
180
|
+
typeof value.type === "string" &&
|
|
181
|
+
typeof value.stream === "function" &&
|
|
182
|
+
typeof value.arrayBuffer === "function" &&
|
|
183
|
+
typeof value.constructor === "function" &&
|
|
184
|
+
typeof value.constructor.name === "string" &&
|
|
185
|
+
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
186
|
+
/^(Blob|File)$/.test(value[Symbol.toStringTag]));
|
|
187
|
+
};
|
|
188
|
+
const isFormData = (value) => {
|
|
189
|
+
return value instanceof FormData;
|
|
190
|
+
};
|
|
191
|
+
const isSuccess = (status) => {
|
|
192
|
+
return status >= 200 && status < 300;
|
|
193
|
+
};
|
|
194
|
+
const base64 = (str) => {
|
|
195
|
+
try {
|
|
196
|
+
return btoa(str);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
return Buffer.from(str).toString("base64");
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const getQueryString = (params) => {
|
|
204
|
+
const qs = [];
|
|
205
|
+
const append = (key, value) => {
|
|
206
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
207
|
+
};
|
|
208
|
+
const process = (key, value) => {
|
|
209
|
+
if (isDefined(value)) {
|
|
210
|
+
if (Array.isArray(value)) {
|
|
211
|
+
value.forEach((v) => {
|
|
212
|
+
process(key, v);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
else if (typeof value === "object") {
|
|
216
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
217
|
+
process(`${key}[${k}]`, v);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
append(key, value);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
226
|
+
process(key, value);
|
|
227
|
+
});
|
|
228
|
+
if (qs.length > 0) {
|
|
229
|
+
return `?${qs.join("&")}`;
|
|
230
|
+
}
|
|
231
|
+
return "";
|
|
232
|
+
};
|
|
233
|
+
const getUrl = (config, options) => {
|
|
234
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
235
|
+
const path = options.url
|
|
236
|
+
.replace("{api-version}", config.VERSION)
|
|
237
|
+
.replace(/{(.*?)}/g, (substring, group) => {
|
|
238
|
+
var _a;
|
|
239
|
+
if ((_a = options.path) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(group)) {
|
|
240
|
+
return encoder(String(options.path[group]));
|
|
241
|
+
}
|
|
242
|
+
return substring;
|
|
243
|
+
});
|
|
244
|
+
const url = `${config.BASE}${path}`;
|
|
245
|
+
if (options.query) {
|
|
246
|
+
return `${url}${getQueryString(options.query)}`;
|
|
247
|
+
}
|
|
248
|
+
return url;
|
|
249
|
+
};
|
|
250
|
+
const getFormData = (options) => {
|
|
251
|
+
if (options.formData) {
|
|
252
|
+
const formData = new FormData();
|
|
253
|
+
const process = (key, value) => {
|
|
254
|
+
if (isString(value) || isBlob(value)) {
|
|
255
|
+
formData.append(key, value);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
formData.append(key, JSON.stringify(value));
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
Object.entries(options.formData)
|
|
262
|
+
.filter(([_, value]) => isDefined(value))
|
|
263
|
+
.forEach(([key, value]) => {
|
|
264
|
+
if (Array.isArray(value)) {
|
|
265
|
+
value.forEach((v) => process(key, v));
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
process(key, value);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
return formData;
|
|
272
|
+
}
|
|
273
|
+
return undefined;
|
|
274
|
+
};
|
|
275
|
+
const resolve = async (options, resolver) => {
|
|
276
|
+
if (typeof resolver === "function") {
|
|
277
|
+
return resolver(options);
|
|
278
|
+
}
|
|
279
|
+
return resolver;
|
|
280
|
+
};
|
|
281
|
+
const getHeaders = async (config, options, formData) => {
|
|
282
|
+
const [token, username, password, additionalHeaders] = await Promise.all([
|
|
283
|
+
resolve(options, config.TOKEN),
|
|
284
|
+
resolve(options, config.USERNAME),
|
|
285
|
+
resolve(options, config.PASSWORD),
|
|
286
|
+
resolve(options, config.HEADERS),
|
|
287
|
+
]);
|
|
288
|
+
const formHeaders = (typeof (formData === null || formData === void 0 ? void 0 : formData.getHeaders) === "function" && (formData === null || formData === void 0 ? void 0 : formData.getHeaders())) || {};
|
|
289
|
+
const headers = Object.entries({
|
|
290
|
+
Accept: "application/json",
|
|
291
|
+
...additionalHeaders,
|
|
292
|
+
...options.headers,
|
|
293
|
+
...formHeaders,
|
|
294
|
+
})
|
|
295
|
+
.filter(([_, value]) => isDefined(value))
|
|
296
|
+
.reduce((headers, [key, value]) => ({
|
|
297
|
+
...headers,
|
|
298
|
+
[key]: String(value),
|
|
299
|
+
}), {});
|
|
300
|
+
if (isStringWithValue(token)) {
|
|
301
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
302
|
+
}
|
|
303
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
304
|
+
const credentials = base64(`${username}:${password}`);
|
|
305
|
+
headers["Authorization"] = `Basic ${credentials}`;
|
|
306
|
+
}
|
|
307
|
+
if (options.body !== undefined) {
|
|
308
|
+
if (options.mediaType) {
|
|
309
|
+
headers["Content-Type"] = options.mediaType;
|
|
310
|
+
}
|
|
311
|
+
else if (isBlob(options.body)) {
|
|
312
|
+
headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
313
|
+
}
|
|
314
|
+
else if (isString(options.body)) {
|
|
315
|
+
headers["Content-Type"] = "text/plain";
|
|
316
|
+
}
|
|
317
|
+
else if (!isFormData(options.body)) {
|
|
318
|
+
headers["Content-Type"] = "application/json";
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return headers;
|
|
322
|
+
};
|
|
323
|
+
const getRequestBody = (options) => {
|
|
324
|
+
if (options.body) {
|
|
325
|
+
return options.body;
|
|
326
|
+
}
|
|
327
|
+
return undefined;
|
|
328
|
+
};
|
|
329
|
+
const sendRequest = async (config, options, url, body, formData, headers, onCancel, axiosClient) => {
|
|
330
|
+
const source = axios.CancelToken.source();
|
|
331
|
+
const requestConfig = {
|
|
332
|
+
url,
|
|
333
|
+
headers,
|
|
334
|
+
data: body !== null && body !== void 0 ? body : formData,
|
|
335
|
+
method: options.method,
|
|
336
|
+
withCredentials: config.WITH_CREDENTIALS,
|
|
337
|
+
withXSRFToken: config.CREDENTIALS === "include" ? config.WITH_CREDENTIALS : false,
|
|
338
|
+
cancelToken: source.token,
|
|
339
|
+
};
|
|
340
|
+
onCancel(() => source.cancel("The user aborted a request."));
|
|
341
|
+
try {
|
|
342
|
+
return await axiosClient.request(requestConfig);
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
const axiosError = error;
|
|
346
|
+
if (axiosError.response) {
|
|
347
|
+
return axiosError.response;
|
|
348
|
+
}
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
const getResponseHeader = (response, responseHeader) => {
|
|
353
|
+
if (responseHeader) {
|
|
354
|
+
const content = response.headers[responseHeader];
|
|
355
|
+
if (isString(content)) {
|
|
356
|
+
return content;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return undefined;
|
|
360
|
+
};
|
|
361
|
+
const getResponseBody = (response) => {
|
|
362
|
+
if (response.status !== 204) {
|
|
363
|
+
return response.data;
|
|
364
|
+
}
|
|
365
|
+
return undefined;
|
|
366
|
+
};
|
|
367
|
+
const catchErrorCodes = (options, result) => {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
const errors = {
|
|
370
|
+
400: "Bad Request",
|
|
371
|
+
401: "Unauthorized",
|
|
372
|
+
403: "Forbidden",
|
|
373
|
+
404: "Not Found",
|
|
374
|
+
500: "Internal Server Error",
|
|
375
|
+
502: "Bad Gateway",
|
|
376
|
+
503: "Service Unavailable",
|
|
377
|
+
...options.errors,
|
|
378
|
+
};
|
|
379
|
+
const error = errors[result.status];
|
|
380
|
+
if (error) {
|
|
381
|
+
throw new ApiError(options, result, error);
|
|
382
|
+
}
|
|
383
|
+
if (!result.ok) {
|
|
384
|
+
const errorStatus = (_a = result.status) !== null && _a !== void 0 ? _a : "unknown";
|
|
385
|
+
const errorStatusText = (_b = result.statusText) !== null && _b !== void 0 ? _b : "unknown";
|
|
386
|
+
const errorBody = (() => {
|
|
387
|
+
try {
|
|
388
|
+
return JSON.stringify(result.body, null, 2);
|
|
389
|
+
}
|
|
390
|
+
catch (e) {
|
|
391
|
+
return undefined;
|
|
392
|
+
}
|
|
393
|
+
})();
|
|
394
|
+
throw new ApiError(options, result, `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* Request method
|
|
399
|
+
* @param config The OpenAPI configuration object
|
|
400
|
+
* @param options The request options from the service
|
|
401
|
+
* @param axiosClient The axios client instance to use
|
|
402
|
+
* @returns CancelablePromise<T>
|
|
403
|
+
* @throws ApiError
|
|
404
|
+
*/
|
|
405
|
+
const request = (config, options, axiosClient = axios) => {
|
|
406
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
407
|
+
try {
|
|
408
|
+
const url = getUrl(config, options);
|
|
409
|
+
const formData = getFormData(options);
|
|
410
|
+
const body = getRequestBody(options);
|
|
411
|
+
const headers = await getHeaders(config, options, formData);
|
|
412
|
+
if (!onCancel.isCancelled) {
|
|
413
|
+
const response = await sendRequest(config, options, url, body, formData, headers, onCancel, axiosClient);
|
|
414
|
+
const responseBody = getResponseBody(response);
|
|
415
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
416
|
+
const result = {
|
|
417
|
+
url,
|
|
418
|
+
ok: isSuccess(response.status),
|
|
419
|
+
status: response.status,
|
|
420
|
+
statusText: response.statusText,
|
|
421
|
+
body: responseHeader !== null && responseHeader !== void 0 ? responseHeader : responseBody,
|
|
422
|
+
};
|
|
423
|
+
catchErrorCodes(options, result);
|
|
424
|
+
resolve(result.body);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
catch (error) {
|
|
428
|
+
reject(error);
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
class CommentService {
|
|
434
|
+
/**
|
|
435
|
+
* Create a new comment
|
|
436
|
+
* Record a new comment that the user intends to add to a given task. This will save the comment in Dart for later access, search, etc.
|
|
437
|
+
* @param requestBody
|
|
438
|
+
* @returns WrappedComment Success, including the created comment
|
|
439
|
+
* @throws ApiError
|
|
440
|
+
*/
|
|
441
|
+
static createComment(requestBody) {
|
|
442
|
+
return request(OpenAPI, {
|
|
443
|
+
method: "POST",
|
|
444
|
+
url: "/comments",
|
|
445
|
+
body: requestBody,
|
|
446
|
+
mediaType: "application/json",
|
|
447
|
+
errors: {
|
|
448
|
+
400: `Invalid request, including the errors`,
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
class ConfigService {
|
|
455
|
+
/**
|
|
456
|
+
* Get user space configuration
|
|
457
|
+
* Get information about the user's space, including all of the possible values that can be provided to other endpoints.
|
|
458
|
+
* @returns UserSpaceConfiguration Success, including all of the options for the user space
|
|
459
|
+
* @throws ApiError
|
|
460
|
+
*/
|
|
461
|
+
static getConfig() {
|
|
462
|
+
return request(OpenAPI, {
|
|
463
|
+
method: "GET",
|
|
464
|
+
url: "/config",
|
|
465
|
+
errors: {
|
|
466
|
+
400: `Invalid request, including the errors`,
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
class DocService {
|
|
473
|
+
/**
|
|
474
|
+
* Create a new doc
|
|
475
|
+
* Record a new doc that the user intends to write down. This will save the doc in Dart for later access, search, etc. By default the created doc will be in the Docs folder. More information can be included in the text.
|
|
476
|
+
* @param requestBody
|
|
477
|
+
* @returns WrappedDoc Success, including the created doc
|
|
478
|
+
* @throws ApiError
|
|
479
|
+
*/
|
|
480
|
+
static createDoc(requestBody) {
|
|
481
|
+
return request(OpenAPI, {
|
|
482
|
+
method: "POST",
|
|
483
|
+
url: "/docs",
|
|
484
|
+
body: requestBody,
|
|
485
|
+
mediaType: "application/json",
|
|
486
|
+
errors: {
|
|
487
|
+
400: `Invalid request, including the errors`,
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Retrieve an existing doc
|
|
493
|
+
* Retrieve an existing doc. This will return the doc's information, including the title, folder, text and others.
|
|
494
|
+
* @param id
|
|
495
|
+
* @returns WrappedDoc Success, including the retrieved doc
|
|
496
|
+
* @throws ApiError
|
|
497
|
+
*/
|
|
498
|
+
static retrieveDoc(id) {
|
|
499
|
+
return request(OpenAPI, {
|
|
500
|
+
method: "GET",
|
|
501
|
+
url: "/docs/{id}",
|
|
502
|
+
path: {
|
|
503
|
+
id: id,
|
|
504
|
+
},
|
|
505
|
+
errors: {
|
|
506
|
+
400: `Invalid request, including the errors`,
|
|
507
|
+
},
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Update an existing doc
|
|
512
|
+
* Update certain properties of an existing doc. This will save the doc in Dart for later access, search, etc. Any properties that are not specified will not be changed.
|
|
513
|
+
* @param id
|
|
514
|
+
* @param requestBody
|
|
515
|
+
* @returns WrappedDoc Success, including the updated doc
|
|
516
|
+
* @throws ApiError
|
|
517
|
+
*/
|
|
518
|
+
static updateDoc(id, requestBody) {
|
|
519
|
+
return request(OpenAPI, {
|
|
520
|
+
method: "PUT",
|
|
521
|
+
url: "/docs/{id}",
|
|
522
|
+
path: {
|
|
523
|
+
id: id,
|
|
524
|
+
},
|
|
525
|
+
body: requestBody,
|
|
526
|
+
mediaType: "application/json",
|
|
527
|
+
errors: {
|
|
528
|
+
400: `Invalid request, including the errors`,
|
|
529
|
+
},
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Delete an existing doc
|
|
534
|
+
* Move an existing doc to the trash, where it can be recovered if needed. Nothing else about the doc will be changed.
|
|
535
|
+
* @param id
|
|
536
|
+
* @returns WrappedDoc Success, including the deleted doc
|
|
537
|
+
* @throws ApiError
|
|
538
|
+
*/
|
|
539
|
+
static deleteDoc(id) {
|
|
540
|
+
return request(OpenAPI, {
|
|
541
|
+
method: "DELETE",
|
|
542
|
+
url: "/docs/{id}",
|
|
543
|
+
path: {
|
|
544
|
+
id: id,
|
|
545
|
+
},
|
|
546
|
+
errors: {
|
|
547
|
+
400: `Invalid request, including the errors`,
|
|
548
|
+
},
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* @returns PaginatedConciseDocList
|
|
553
|
+
* @throws ApiError
|
|
554
|
+
*/
|
|
555
|
+
static listDocs({ folder, folderId, ids, limit, o, offset, s, text, title, }) {
|
|
556
|
+
return request(OpenAPI, {
|
|
557
|
+
method: "GET",
|
|
558
|
+
url: "/docs/list",
|
|
559
|
+
query: {
|
|
560
|
+
folder: folder,
|
|
561
|
+
folder_id: folderId,
|
|
562
|
+
ids: ids,
|
|
563
|
+
limit: limit,
|
|
564
|
+
o: o,
|
|
565
|
+
offset: offset,
|
|
566
|
+
s: s,
|
|
567
|
+
text: text,
|
|
568
|
+
title: title,
|
|
569
|
+
},
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
class TaskService {
|
|
575
|
+
/**
|
|
576
|
+
* Create a new task
|
|
577
|
+
* Record a new task that the user intends to do. This will save the task in Dart for later access, search, etc. By default the created task will be assigned to the user, with a status of to-do, with no parent, in the Active dartboard. More information can be included in the description.
|
|
578
|
+
* @param requestBody
|
|
579
|
+
* @returns WrappedTask
|
|
580
|
+
* @throws ApiError
|
|
581
|
+
*/
|
|
582
|
+
static createTask(requestBody) {
|
|
583
|
+
return request(OpenAPI, {
|
|
584
|
+
method: "POST",
|
|
585
|
+
url: "/tasks",
|
|
586
|
+
body: requestBody,
|
|
587
|
+
mediaType: "application/json",
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Retrieve an existing task
|
|
592
|
+
* Retrieve an existing task. This will return the task's information, including the title, dartboard, status, description and others.
|
|
593
|
+
* @param id
|
|
594
|
+
* @returns WrappedTask Success, including the retrieved task
|
|
595
|
+
* @throws ApiError
|
|
596
|
+
*/
|
|
597
|
+
static retrieveTask(id) {
|
|
598
|
+
return request(OpenAPI, {
|
|
599
|
+
method: "GET",
|
|
600
|
+
url: "/tasks/{id}",
|
|
601
|
+
path: {
|
|
602
|
+
id: id,
|
|
603
|
+
},
|
|
604
|
+
errors: {
|
|
605
|
+
400: `Invalid request, including the errors`,
|
|
606
|
+
},
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Update an existing task
|
|
611
|
+
* Update certain properties of an existing task. This will save the task in Dart for later access, search, etc. Any properties that are not specified will not be changed.
|
|
612
|
+
* @param id
|
|
613
|
+
* @param requestBody
|
|
614
|
+
* @returns WrappedTask Success, including the updated task
|
|
615
|
+
* @throws ApiError
|
|
616
|
+
*/
|
|
617
|
+
static updateTask(id, requestBody) {
|
|
618
|
+
return request(OpenAPI, {
|
|
619
|
+
method: "PUT",
|
|
620
|
+
url: "/tasks/{id}",
|
|
621
|
+
path: {
|
|
622
|
+
id: id,
|
|
623
|
+
},
|
|
624
|
+
body: requestBody,
|
|
625
|
+
mediaType: "application/json",
|
|
626
|
+
errors: {
|
|
627
|
+
400: `Invalid request, including the errors`,
|
|
628
|
+
},
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Delete an existing task
|
|
633
|
+
* Move an existing task to the trash, where it can be recovered if needed. Nothing else about the task will be changed.
|
|
634
|
+
* @param id
|
|
635
|
+
* @returns WrappedTask Success, including the deleted task
|
|
636
|
+
* @throws ApiError
|
|
637
|
+
*/
|
|
638
|
+
static deleteTask(id) {
|
|
639
|
+
return request(OpenAPI, {
|
|
640
|
+
method: "DELETE",
|
|
641
|
+
url: "/tasks/{id}",
|
|
642
|
+
path: {
|
|
643
|
+
id: id,
|
|
644
|
+
},
|
|
645
|
+
errors: {
|
|
646
|
+
400: `Invalid request, including the errors`,
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* @returns PaginatedConciseTaskList
|
|
652
|
+
* @throws ApiError
|
|
653
|
+
*/
|
|
654
|
+
static listTasks({ assignee, assigneeId, dartboard, dartboardId, description, dueAtAfter, dueAtBefore, ids, limit, offset, priority, size, startAtAfter, startAtBefore, status, statusId, tag, tagId, title, type, typeId, }) {
|
|
655
|
+
return request(OpenAPI, {
|
|
656
|
+
method: "GET",
|
|
657
|
+
url: "/tasks/list",
|
|
658
|
+
query: {
|
|
659
|
+
assignee: assignee,
|
|
660
|
+
assignee_id: assigneeId,
|
|
661
|
+
dartboard: dartboard,
|
|
662
|
+
dartboard_id: dartboardId,
|
|
663
|
+
description: description,
|
|
664
|
+
due_at_after: dueAtAfter,
|
|
665
|
+
due_at_before: dueAtBefore,
|
|
666
|
+
ids: ids,
|
|
667
|
+
limit: limit,
|
|
668
|
+
offset: offset,
|
|
669
|
+
priority: priority,
|
|
670
|
+
size: size,
|
|
671
|
+
start_at_after: startAtAfter,
|
|
672
|
+
start_at_before: startAtBefore,
|
|
673
|
+
status: status,
|
|
674
|
+
status_id: statusId,
|
|
675
|
+
tag: tag,
|
|
676
|
+
tag_id: tagId,
|
|
677
|
+
title: title,
|
|
678
|
+
type: type,
|
|
679
|
+
type_id: typeId,
|
|
680
|
+
},
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export { ApiError, CancelError, CancelablePromise, CommentService, ConfigService, DocService, OpenAPI, TaskService };
|