rlz-engine 1.0.31 → 1.0.32
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/dist/client/api/api.d.ts +14 -4
- package/dist/client/api/api.js +30 -9
- package/package.json +1 -1
package/dist/client/api/api.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import z, { ZodType } from 'zod';
|
|
2
|
-
export declare class
|
|
3
|
-
|
|
2
|
+
export declare class HttpError extends Error {
|
|
3
|
+
readonly method: string;
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly statusText: string;
|
|
7
|
+
constructor(method: string, url: string, status: number, statusText: string);
|
|
4
8
|
}
|
|
5
|
-
export declare class
|
|
6
|
-
constructor(url: string);
|
|
9
|
+
export declare class Unauthorized extends HttpError {
|
|
10
|
+
constructor(method: string, url: string, statusText: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class Forbidden extends HttpError {
|
|
13
|
+
constructor(method: string, url: string, statusText: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class NotFound extends HttpError {
|
|
16
|
+
constructor(method: string, url: string, statusText: string);
|
|
7
17
|
}
|
|
8
18
|
export interface AuthParam {
|
|
9
19
|
userId: string;
|
package/dist/client/api/api.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { getFrontConfig } from '../config';
|
|
2
|
-
export class
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export class HttpError extends Error {
|
|
3
|
+
method;
|
|
4
|
+
url;
|
|
5
|
+
status;
|
|
6
|
+
statusText;
|
|
7
|
+
constructor(method, url, status, statusText) {
|
|
8
|
+
super(`Not ok resp (${status} ${statusText}): ${method} ${url}`);
|
|
9
|
+
this.method = method;
|
|
10
|
+
this.url = url;
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.statusText = statusText;
|
|
5
13
|
}
|
|
6
14
|
}
|
|
7
|
-
export class
|
|
8
|
-
constructor(url) {
|
|
9
|
-
super(
|
|
15
|
+
export class Unauthorized extends HttpError {
|
|
16
|
+
constructor(method, url, statusText) {
|
|
17
|
+
super(method, url, 401, statusText);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class Forbidden extends HttpError {
|
|
21
|
+
constructor(method, url, statusText) {
|
|
22
|
+
super(method, url, 403, statusText);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class NotFound extends HttpError {
|
|
26
|
+
constructor(method, url, statusText) {
|
|
27
|
+
super(method, url, 404, statusText);
|
|
10
28
|
}
|
|
11
29
|
}
|
|
12
30
|
function url(version, path, queryString) {
|
|
@@ -50,12 +68,15 @@ export async function apiCall(method, version, path, auth, queryString, request,
|
|
|
50
68
|
});
|
|
51
69
|
if (!resp.ok) {
|
|
52
70
|
if (resp.status === 401) {
|
|
53
|
-
throw new Unauthorized(u);
|
|
71
|
+
throw new Unauthorized(method, u, resp.statusText);
|
|
54
72
|
}
|
|
55
73
|
if (resp.status === 403) {
|
|
56
|
-
throw new Forbidden(u);
|
|
74
|
+
throw new Forbidden(method, u, resp.statusText);
|
|
75
|
+
}
|
|
76
|
+
if (resp.status === 404) {
|
|
77
|
+
throw new NotFound(method, u, resp.statusText);
|
|
57
78
|
}
|
|
58
|
-
throw
|
|
79
|
+
throw new HttpError(method, u, resp.status, resp.statusText);
|
|
59
80
|
}
|
|
60
81
|
if (resp.status === 204) {
|
|
61
82
|
return validator.parse(undefined);
|