@inweb/client 25.3.19 → 25.3.20

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/src/Api/Job.ts CHANGED
@@ -41,15 +41,15 @@ export class Job {
41
41
  this.data = data;
42
42
  }
43
43
 
44
- protected internalGet() {
44
+ protected internalGet(): Promise<Response> {
45
45
  return this.httpClient.get(`/jobs/${this.data.id}`);
46
46
  }
47
47
 
48
- protected internalPut(body?: BodyInit | object) {
48
+ protected internalPut(body?: BodyInit | object): Promise<Response> {
49
49
  return this.httpClient.put(`/jobs/${this.data.id}`, body);
50
50
  }
51
51
 
52
- protected internalDelete() {
52
+ protected internalDelete(): Promise<Response> {
53
53
  return this.httpClient.delete(`/jobs/${this.data.id}`);
54
54
  }
55
55
 
@@ -183,7 +183,7 @@ export class Job {
183
183
  *
184
184
  * @async
185
185
  */
186
- async checkout(): Promise<Job> {
186
+ async checkout(): Promise<this> {
187
187
  const response = await this.internalGet();
188
188
  this.data = await response.json();
189
189
  return this;
@@ -195,7 +195,7 @@ export class Job {
195
195
  * @async
196
196
  * @param data - Raw job data.
197
197
  */
198
- async update(data: any): Promise<Job> {
198
+ async update(data: any): Promise<this> {
199
199
  const response = await this.internalPut(data);
200
200
  this.data = await response.json();
201
201
  return this;
@@ -242,7 +242,7 @@ export class Job {
242
242
  interval?: number;
243
243
  signal?: AbortSignal;
244
244
  onCheckout?: (job: Job, ready: boolean) => boolean;
245
- }): Promise<Job> {
245
+ }): Promise<this> {
246
246
  const checkDone = () =>
247
247
  this.checkout().then((job) => {
248
248
  const ready = ["done", "failed"].includes(job.status);
package/src/Api/Member.ts CHANGED
@@ -44,15 +44,15 @@ export class Member {
44
44
  this.data = data;
45
45
  }
46
46
 
47
- private internalGet() {
47
+ private internalGet(): Promise<Response> {
48
48
  return this.httpClient.get(`/projects/${this.projectId}/members/${this.id}`);
49
49
  }
50
50
 
51
- private internalPut(body?: BodyInit | object) {
51
+ private internalPut(body?: BodyInit | object): Promise<Response> {
52
52
  return this.httpClient.put(`/projects/${this.projectId}/members/${this.id}`, body);
53
53
  }
54
54
 
55
- private internalDelete() {
55
+ private internalDelete(): Promise<Response> {
56
56
  return this.httpClient.delete(`/projects/${this.projectId}/members/${this.id}`);
57
57
  }
58
58
 
@@ -123,7 +123,7 @@ export class Member {
123
123
  *
124
124
  * @async
125
125
  */
126
- async checkout(): Promise<Member> {
126
+ async checkout(): Promise<this> {
127
127
  const response = await this.internalGet();
128
128
  this.data = await response.json();
129
129
  return this;
@@ -135,7 +135,7 @@ export class Member {
135
135
  * @async
136
136
  * @param data - Raw member data.
137
137
  */
138
- async update(data: any): Promise<Member> {
138
+ async update(data: any): Promise<this> {
139
139
  const response = await this.internalPut(data);
140
140
  this.data = await response.json();
141
141
  return this;
@@ -157,7 +157,7 @@ export class Member {
157
157
  *
158
158
  * @async
159
159
  */
160
- save(): Promise<Member> {
160
+ save(): Promise<this> {
161
161
  return this.update(this.data);
162
162
  }
163
163
  }
package/src/Api/Model.ts CHANGED
@@ -339,7 +339,7 @@ export class Model {
339
339
  * href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
340
340
  * signal object instance, which can be used to abort waiting as desired.
341
341
  */
342
- getReferences(signal?: AbortSignal) {
342
+ getReferences(signal?: AbortSignal): Promise<any> {
343
343
  return this._file.getReferences(signal);
344
344
  }
345
345
  }
@@ -43,15 +43,15 @@ export class Permission {
43
43
  this.data = data;
44
44
  }
45
45
 
46
- private internalGet() {
46
+ private internalGet(): Promise<Response> {
47
47
  return this.httpClient.get(`/files/${this.fileId}/permissions/${this.id}`);
48
48
  }
49
49
 
50
- private internalPut(body?: BodyInit | object) {
50
+ private internalPut(body?: BodyInit | object): Promise<Response> {
51
51
  return this.httpClient.put(`/files/${this.fileId}/permissions/${this.id}`, body);
52
52
  }
53
53
 
54
- private internalDelete() {
54
+ private internalDelete(): Promise<Response> {
55
55
  return this.httpClient.delete(`/files/${this.fileId}/permissions/${this.id}`);
56
56
  }
57
57
 
@@ -134,7 +134,7 @@ export class Permission {
134
134
  *
135
135
  * @async
136
136
  */
137
- async checkout(): Promise<Permission> {
137
+ async checkout(): Promise<this> {
138
138
  const response = await this.internalGet();
139
139
  this.data = await response.json();
140
140
  return this;
@@ -146,7 +146,7 @@ export class Permission {
146
146
  * @async
147
147
  * @param data - Raw permission data.
148
148
  */
149
- async update(data: any): Promise<Permission> {
149
+ async update(data: any): Promise<this> {
150
150
  const response = await this.internalPut(data);
151
151
  this.data = await response.json();
152
152
  return this;
@@ -168,7 +168,7 @@ export class Permission {
168
168
  *
169
169
  * @async
170
170
  */
171
- save(): Promise<Permission> {
171
+ save(): Promise<this> {
172
172
  return this.update(this.data);
173
173
  }
174
174
  }
@@ -43,19 +43,19 @@ export class Project {
43
43
  this.data = data;
44
44
  }
45
45
 
46
- protected internalGet(relativePath: string) {
46
+ protected internalGet(relativePath: string): Promise<Response> {
47
47
  return this.httpClient.get(`/projects/${this.id}${relativePath}`);
48
48
  }
49
49
 
50
- protected internalPost(relativePath: string, body?: BodyInit | object) {
50
+ protected internalPost(relativePath: string, body?: BodyInit | object): Promise<Response> {
51
51
  return this.httpClient.post(`/projects/${this.id}${relativePath}`, body);
52
52
  }
53
53
 
54
- protected internalPut(relativePath: string, body?: BodyInit | object) {
54
+ protected internalPut(relativePath: string, body?: BodyInit | object): Promise<Response> {
55
55
  return this.httpClient.put(`/projects/${this.id}${relativePath}`, body);
56
56
  }
57
57
 
58
- protected internalDelete(relativePath: string) {
58
+ protected internalDelete(relativePath: string): Promise<Response> {
59
59
  return this.httpClient.delete(`/projects/${this.id}${relativePath}`);
60
60
  }
61
61
 
@@ -242,7 +242,7 @@ export class Project {
242
242
  *
243
243
  * @async
244
244
  */
245
- async checkout(): Promise<Project> {
245
+ async checkout(): Promise<this> {
246
246
  const response = await this.internalGet("");
247
247
  this.data = await response.json();
248
248
  return this;
@@ -254,7 +254,7 @@ export class Project {
254
254
  * @async
255
255
  * @param data - Raw project data.
256
256
  */
257
- async update(data: any): Promise<Project> {
257
+ async update(data: any): Promise<this> {
258
258
  const response = await this.internalPut("", data);
259
259
  this.data = await response.json();
260
260
  return this;
@@ -285,7 +285,7 @@ export class Project {
285
285
  *
286
286
  * @async
287
287
  */
288
- save(): Promise<Project> {
288
+ save(): Promise<this> {
289
289
  return this.update(this.data);
290
290
  }
291
291
 
@@ -303,7 +303,7 @@ export class Project {
303
303
  * target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
304
304
  */
305
305
 
306
- async setPreview(image: BodyInit | null) {
306
+ async setPreview(image: BodyInit | null): Promise<any> {
307
307
  const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
308
308
  this.data = await response.json();
309
309
  return this;
package/src/Api/Role.ts CHANGED
@@ -42,15 +42,15 @@ export class Role {
42
42
  this.data = data;
43
43
  }
44
44
 
45
- private internalGet() {
45
+ private internalGet(): Promise<Response> {
46
46
  return this.httpClient.get(`/projects/${this.projectId}/roles/${this.name}`);
47
47
  }
48
48
 
49
- private internalPut(body?: BodyInit | object) {
49
+ private internalPut(body?: BodyInit | object): Promise<Response> {
50
50
  return this.httpClient.put(`/projects/${this.projectId}/roles/${this.name}`, body);
51
51
  }
52
52
 
53
- private internalDelete() {
53
+ private internalDelete(): Promise<Response> {
54
54
  return this.httpClient.delete(`/projects/${this.projectId}/roles/${this.name}`);
55
55
  }
56
56
 
@@ -119,7 +119,7 @@ export class Role {
119
119
  *
120
120
  * @async
121
121
  */
122
- async checkout(): Promise<Role> {
122
+ async checkout(): Promise<this> {
123
123
  const response = await this.internalGet();
124
124
  this.data = await response.json();
125
125
  return this;
@@ -131,7 +131,7 @@ export class Role {
131
131
  * @async
132
132
  * @param data - Raw role data.
133
133
  */
134
- async update(data: any): Promise<Role> {
134
+ async update(data: any): Promise<this> {
135
135
  const response = await this.internalPut(data);
136
136
  this.data = await response.json();
137
137
  return this;
@@ -153,7 +153,7 @@ export class Role {
153
153
  *
154
154
  * @async
155
155
  */
156
- save(): Promise<Role> {
156
+ save(): Promise<this> {
157
157
  return this.update(this.data);
158
158
  }
159
159
  }
package/src/Api/User.ts CHANGED
@@ -257,7 +257,7 @@ export class User {
257
257
  * does not have administrator rights, hi can only checkout himself, otherwise an exception
258
258
  * will be thrown.
259
259
  */
260
- async checkout(): Promise<User> {
260
+ async checkout(): Promise<this> {
261
261
  if (this.id === this.httpClient.signInUserId) {
262
262
  const response = await this.httpClient.get("/user");
263
263
  const data = await response.json();
@@ -278,7 +278,7 @@ export class User {
278
278
  * @async
279
279
  * @param data - Raw user data.
280
280
  */
281
- async update(data: any) {
281
+ async update(data: any): Promise<this> {
282
282
  if (this.id === this.httpClient.signInUserId) {
283
283
  const response = await this.httpClient.put("/user", data);
284
284
  const newData = await response.json();
@@ -322,7 +322,7 @@ export class User {
322
322
  *
323
323
  * @async
324
324
  */
325
- save(): Promise<User> {
325
+ save(): Promise<this> {
326
326
  return this.update(this.data);
327
327
  }
328
328
 
@@ -341,7 +341,7 @@ export class User {
341
341
  * Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
342
342
  * target="_blank">File</a> object. Setting the `image` to `null` will remove the avatar.
343
343
  */
344
- async setAvatar(image: BodyInit | null): Promise<User> {
344
+ async setAvatar(image: BodyInit | null): Promise<this> {
345
345
  if (image) {
346
346
  if (this.id === this.httpClient.signInUserId) {
347
347
  const response = await this.httpClient.post("/user/avatar", image);
package/src/Api/Utils.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- function delay(ms: number, signal: AbortSignal) {
24
+ function delay(ms: number, signal: AbortSignal): Promise<boolean> {
25
25
  return new Promise((resolve) => {
26
26
  let timeoutId = 0;
27
27
 
@@ -49,9 +49,9 @@ export async function waitFor(
49
49
  timeoutError?: DOMException;
50
50
  result?: any;
51
51
  } = {}
52
- ) {
53
- const timeout = params.timeout ?? 600000;
54
- const interval = params.interval ?? 3000;
52
+ ): Promise<any> {
53
+ const timeout = params.timeout || 600000;
54
+ const interval = params.interval || 3000;
55
55
  const signal = params.signal ?? new AbortController().signal;
56
56
  const abortError = params.abortError ?? new DOMException("Aborted", "AbortError");
57
57
  const timeoutError = params.timeoutError ?? new DOMException("Timeout", "TimeoutError");
@@ -67,7 +67,7 @@ export async function waitFor(
67
67
  return Promise.reject(timeoutError);
68
68
  }
69
69
 
70
- export function parseArgs(args: string | object): object {
70
+ export function parseArgs(args?: string | object): object {
71
71
  if (typeof args === "string") {
72
72
  const firstArg = args.indexOf("--");
73
73
  if (firstArg !== -1) args = args.slice(firstArg);
@@ -83,7 +83,7 @@ export function parseArgs(args: string | object): object {
83
83
  .map((x) => x.concat([""]));
84
84
  return Object.fromEntries(argArray);
85
85
  }
86
- return args ?? {};
86
+ return args || {};
87
87
  }
88
88
 
89
89
  export function userFullName(firstName: string | any, lastName = "", userName = ""): string {
@@ -61,7 +61,7 @@ export function $xmlhttp(
61
61
  for (const key in params.headers) {
62
62
  xhr.setRequestHeader(key, params.headers[key]);
63
63
  }
64
- function calcProgress(event: ProgressEvent) {
64
+ function calcProgress(event: ProgressEvent): number {
65
65
  return event.lengthComputable ? event.loaded / event.total : 1;
66
66
  }
67
67
  xhr.upload.onprogress = (event) => params.uploadProgress && params.uploadProgress(calcProgress(event));