@flexbe/sdk 0.2.28 → 0.2.29
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/browser/client/api-client.js +7 -6
- package/dist/browser/types/index.js +18 -6
- package/dist/cjs/client/api-client.js +7 -6
- package/dist/cjs/types/index.js +18 -6
- package/dist/esm/client/api-client.js +7 -6
- package/dist/esm/types/index.js +18 -6
- package/dist/types/types/index.d.ts +26 -6
- package/dist/types/types/pages.d.ts +2 -7
- package/package.json +1 -1
|
@@ -44,23 +44,24 @@ export class ApiClient {
|
|
|
44
44
|
const errorData = yield response.json().catch(() => defaultError);
|
|
45
45
|
switch (errorData.statusCode) {
|
|
46
46
|
case 400:
|
|
47
|
-
throw new BadRequestException(errorData.message);
|
|
47
|
+
throw new BadRequestException(errorData.message, errorData.error, errorData.errors);
|
|
48
48
|
case 401:
|
|
49
|
-
throw new UnauthorizedException(errorData.message);
|
|
49
|
+
throw new UnauthorizedException(errorData.message, errorData.error, errorData.errors);
|
|
50
50
|
case 403:
|
|
51
|
-
throw new ForbiddenException(errorData.message);
|
|
51
|
+
throw new ForbiddenException(errorData.message, errorData.error, errorData.errors);
|
|
52
52
|
case 404:
|
|
53
|
-
throw new NotFoundException(errorData.message);
|
|
53
|
+
throw new NotFoundException(errorData.message, errorData.error, errorData.errors);
|
|
54
54
|
case 500:
|
|
55
55
|
case 502:
|
|
56
56
|
case 503:
|
|
57
57
|
case 504:
|
|
58
|
-
throw new ServerException(errorData.message, errorData.statusCode);
|
|
58
|
+
throw new ServerException(errorData.message, errorData.error, errorData.statusCode, errorData.errors);
|
|
59
59
|
default:
|
|
60
60
|
throw {
|
|
61
61
|
message: errorData.message,
|
|
62
62
|
error: errorData.error,
|
|
63
|
-
statusCode: errorData.statusCode
|
|
63
|
+
statusCode: errorData.statusCode,
|
|
64
|
+
errors: errorData.errors
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
}
|
|
@@ -4,44 +4,56 @@ export var FlexbeAuthType;
|
|
|
4
4
|
FlexbeAuthType["BEARER"] = "bearer";
|
|
5
5
|
})(FlexbeAuthType || (FlexbeAuthType = {}));
|
|
6
6
|
export class NotFoundException extends Error {
|
|
7
|
-
constructor(message) {
|
|
7
|
+
constructor(message, error, errors) {
|
|
8
8
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
9
9
|
this.statusCode = 404;
|
|
10
10
|
this.name = 'NotFoundException';
|
|
11
|
+
this.error = error || 'not_found';
|
|
12
|
+
this.errors = errors;
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
export class ForbiddenException extends Error {
|
|
14
|
-
constructor(message) {
|
|
16
|
+
constructor(message, error, errors) {
|
|
15
17
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
16
18
|
this.statusCode = 403;
|
|
17
19
|
this.name = 'ForbiddenException';
|
|
20
|
+
this.error = error || 'forbidden';
|
|
21
|
+
this.errors = errors;
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
export class BadRequestException extends Error {
|
|
21
|
-
constructor(message) {
|
|
25
|
+
constructor(message, error, errors) {
|
|
22
26
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
23
27
|
this.statusCode = 400;
|
|
24
28
|
this.name = 'BadRequestException';
|
|
29
|
+
this.error = error || 'bad_request';
|
|
30
|
+
this.errors = errors;
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
export class UnauthorizedException extends Error {
|
|
28
|
-
constructor(message) {
|
|
34
|
+
constructor(message, error, errors) {
|
|
29
35
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
30
36
|
this.statusCode = 401;
|
|
31
37
|
this.name = 'UnauthorizedException';
|
|
38
|
+
this.error = error || 'unauthorized';
|
|
39
|
+
this.errors = errors;
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
export class ServerException extends Error {
|
|
35
|
-
constructor(message, statusCode = 500) {
|
|
43
|
+
constructor(message, error, statusCode = 500, errors) {
|
|
36
44
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
37
45
|
this.name = 'ServerException';
|
|
46
|
+
this.error = error || 'server_error';
|
|
38
47
|
this.statusCode = statusCode;
|
|
48
|
+
this.errors = errors;
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
51
|
export class TimeoutException extends Error {
|
|
42
|
-
constructor(message) {
|
|
52
|
+
constructor(message, error, errors) {
|
|
43
53
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
44
54
|
this.statusCode = 408;
|
|
45
55
|
this.name = 'TimeoutException';
|
|
56
|
+
this.error = error || 'timeout';
|
|
57
|
+
this.errors = errors;
|
|
46
58
|
}
|
|
47
59
|
}
|
|
@@ -44,23 +44,24 @@ class ApiClient {
|
|
|
44
44
|
const errorData = await response.json().catch(() => defaultError);
|
|
45
45
|
switch (errorData.statusCode) {
|
|
46
46
|
case 400:
|
|
47
|
-
throw new types_1.BadRequestException(errorData.message);
|
|
47
|
+
throw new types_1.BadRequestException(errorData.message, errorData.error, errorData.errors);
|
|
48
48
|
case 401:
|
|
49
|
-
throw new types_1.UnauthorizedException(errorData.message);
|
|
49
|
+
throw new types_1.UnauthorizedException(errorData.message, errorData.error, errorData.errors);
|
|
50
50
|
case 403:
|
|
51
|
-
throw new types_1.ForbiddenException(errorData.message);
|
|
51
|
+
throw new types_1.ForbiddenException(errorData.message, errorData.error, errorData.errors);
|
|
52
52
|
case 404:
|
|
53
|
-
throw new types_1.NotFoundException(errorData.message);
|
|
53
|
+
throw new types_1.NotFoundException(errorData.message, errorData.error, errorData.errors);
|
|
54
54
|
case 500:
|
|
55
55
|
case 502:
|
|
56
56
|
case 503:
|
|
57
57
|
case 504:
|
|
58
|
-
throw new types_1.ServerException(errorData.message, errorData.statusCode);
|
|
58
|
+
throw new types_1.ServerException(errorData.message, errorData.error, errorData.statusCode, errorData.errors);
|
|
59
59
|
default:
|
|
60
60
|
throw {
|
|
61
61
|
message: errorData.message,
|
|
62
62
|
error: errorData.error,
|
|
63
|
-
statusCode: errorData.statusCode
|
|
63
|
+
statusCode: errorData.statusCode,
|
|
64
|
+
errors: errorData.errors
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
}
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -7,50 +7,62 @@ var FlexbeAuthType;
|
|
|
7
7
|
FlexbeAuthType["BEARER"] = "bearer";
|
|
8
8
|
})(FlexbeAuthType || (exports.FlexbeAuthType = FlexbeAuthType = {}));
|
|
9
9
|
class NotFoundException extends Error {
|
|
10
|
-
constructor(message) {
|
|
10
|
+
constructor(message, error, errors) {
|
|
11
11
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
12
12
|
this.statusCode = 404;
|
|
13
13
|
this.name = 'NotFoundException';
|
|
14
|
+
this.error = error || 'not_found';
|
|
15
|
+
this.errors = errors;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
exports.NotFoundException = NotFoundException;
|
|
17
19
|
class ForbiddenException extends Error {
|
|
18
|
-
constructor(message) {
|
|
20
|
+
constructor(message, error, errors) {
|
|
19
21
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
20
22
|
this.statusCode = 403;
|
|
21
23
|
this.name = 'ForbiddenException';
|
|
24
|
+
this.error = error || 'forbidden';
|
|
25
|
+
this.errors = errors;
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
exports.ForbiddenException = ForbiddenException;
|
|
25
29
|
class BadRequestException extends Error {
|
|
26
|
-
constructor(message) {
|
|
30
|
+
constructor(message, error, errors) {
|
|
27
31
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
28
32
|
this.statusCode = 400;
|
|
29
33
|
this.name = 'BadRequestException';
|
|
34
|
+
this.error = error || 'bad_request';
|
|
35
|
+
this.errors = errors;
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
exports.BadRequestException = BadRequestException;
|
|
33
39
|
class UnauthorizedException extends Error {
|
|
34
|
-
constructor(message) {
|
|
40
|
+
constructor(message, error, errors) {
|
|
35
41
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
36
42
|
this.statusCode = 401;
|
|
37
43
|
this.name = 'UnauthorizedException';
|
|
44
|
+
this.error = error || 'unauthorized';
|
|
45
|
+
this.errors = errors;
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
exports.UnauthorizedException = UnauthorizedException;
|
|
41
49
|
class ServerException extends Error {
|
|
42
|
-
constructor(message, statusCode = 500) {
|
|
50
|
+
constructor(message, error, statusCode = 500, errors) {
|
|
43
51
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
44
52
|
this.name = 'ServerException';
|
|
53
|
+
this.error = error || 'server_error';
|
|
45
54
|
this.statusCode = statusCode;
|
|
55
|
+
this.errors = errors;
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
58
|
exports.ServerException = ServerException;
|
|
49
59
|
class TimeoutException extends Error {
|
|
50
|
-
constructor(message) {
|
|
60
|
+
constructor(message, error, errors) {
|
|
51
61
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
52
62
|
this.statusCode = 408;
|
|
53
63
|
this.name = 'TimeoutException';
|
|
64
|
+
this.error = error || 'timeout';
|
|
65
|
+
this.errors = errors;
|
|
54
66
|
}
|
|
55
67
|
}
|
|
56
68
|
exports.TimeoutException = TimeoutException;
|
|
@@ -41,23 +41,24 @@ export class ApiClient {
|
|
|
41
41
|
const errorData = await response.json().catch(() => defaultError);
|
|
42
42
|
switch (errorData.statusCode) {
|
|
43
43
|
case 400:
|
|
44
|
-
throw new BadRequestException(errorData.message);
|
|
44
|
+
throw new BadRequestException(errorData.message, errorData.error, errorData.errors);
|
|
45
45
|
case 401:
|
|
46
|
-
throw new UnauthorizedException(errorData.message);
|
|
46
|
+
throw new UnauthorizedException(errorData.message, errorData.error, errorData.errors);
|
|
47
47
|
case 403:
|
|
48
|
-
throw new ForbiddenException(errorData.message);
|
|
48
|
+
throw new ForbiddenException(errorData.message, errorData.error, errorData.errors);
|
|
49
49
|
case 404:
|
|
50
|
-
throw new NotFoundException(errorData.message);
|
|
50
|
+
throw new NotFoundException(errorData.message, errorData.error, errorData.errors);
|
|
51
51
|
case 500:
|
|
52
52
|
case 502:
|
|
53
53
|
case 503:
|
|
54
54
|
case 504:
|
|
55
|
-
throw new ServerException(errorData.message, errorData.statusCode);
|
|
55
|
+
throw new ServerException(errorData.message, errorData.error, errorData.statusCode, errorData.errors);
|
|
56
56
|
default:
|
|
57
57
|
throw {
|
|
58
58
|
message: errorData.message,
|
|
59
59
|
error: errorData.error,
|
|
60
|
-
statusCode: errorData.statusCode
|
|
60
|
+
statusCode: errorData.statusCode,
|
|
61
|
+
errors: errorData.errors
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
}
|
package/dist/esm/types/index.js
CHANGED
|
@@ -4,44 +4,56 @@ export var FlexbeAuthType;
|
|
|
4
4
|
FlexbeAuthType["BEARER"] = "bearer";
|
|
5
5
|
})(FlexbeAuthType || (FlexbeAuthType = {}));
|
|
6
6
|
export class NotFoundException extends Error {
|
|
7
|
-
constructor(message) {
|
|
7
|
+
constructor(message, error, errors) {
|
|
8
8
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
9
9
|
this.statusCode = 404;
|
|
10
10
|
this.name = 'NotFoundException';
|
|
11
|
+
this.error = error || 'not_found';
|
|
12
|
+
this.errors = errors;
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
export class ForbiddenException extends Error {
|
|
14
|
-
constructor(message) {
|
|
16
|
+
constructor(message, error, errors) {
|
|
15
17
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
16
18
|
this.statusCode = 403;
|
|
17
19
|
this.name = 'ForbiddenException';
|
|
20
|
+
this.error = error || 'forbidden';
|
|
21
|
+
this.errors = errors;
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
export class BadRequestException extends Error {
|
|
21
|
-
constructor(message) {
|
|
25
|
+
constructor(message, error, errors) {
|
|
22
26
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
23
27
|
this.statusCode = 400;
|
|
24
28
|
this.name = 'BadRequestException';
|
|
29
|
+
this.error = error || 'bad_request';
|
|
30
|
+
this.errors = errors;
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
export class UnauthorizedException extends Error {
|
|
28
|
-
constructor(message) {
|
|
34
|
+
constructor(message, error, errors) {
|
|
29
35
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
30
36
|
this.statusCode = 401;
|
|
31
37
|
this.name = 'UnauthorizedException';
|
|
38
|
+
this.error = error || 'unauthorized';
|
|
39
|
+
this.errors = errors;
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
export class ServerException extends Error {
|
|
35
|
-
constructor(message, statusCode = 500) {
|
|
43
|
+
constructor(message, error, statusCode = 500, errors) {
|
|
36
44
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
37
45
|
this.name = 'ServerException';
|
|
46
|
+
this.error = error || 'server_error';
|
|
38
47
|
this.statusCode = statusCode;
|
|
48
|
+
this.errors = errors;
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
51
|
export class TimeoutException extends Error {
|
|
42
|
-
constructor(message) {
|
|
52
|
+
constructor(message, error, errors) {
|
|
43
53
|
super(Array.isArray(message) ? message.join(', ') : message);
|
|
44
54
|
this.statusCode = 408;
|
|
45
55
|
this.name = 'TimeoutException';
|
|
56
|
+
this.error = error || 'timeout';
|
|
57
|
+
this.errors = errors;
|
|
46
58
|
}
|
|
47
59
|
}
|
|
@@ -18,11 +18,19 @@ export interface FlexbeErrorResponse {
|
|
|
18
18
|
message: string | string[];
|
|
19
19
|
error: string;
|
|
20
20
|
statusCode: number;
|
|
21
|
+
errors?: FlexbeBulkError[];
|
|
21
22
|
}
|
|
22
23
|
export interface FlexbeError {
|
|
23
24
|
message: string | string[];
|
|
24
25
|
error: string;
|
|
25
26
|
statusCode: number;
|
|
27
|
+
errors?: FlexbeBulkError[];
|
|
28
|
+
}
|
|
29
|
+
export interface FlexbeBulkError {
|
|
30
|
+
id: number;
|
|
31
|
+
message: string;
|
|
32
|
+
error: string;
|
|
33
|
+
code: number;
|
|
26
34
|
}
|
|
27
35
|
export interface JwtToken {
|
|
28
36
|
accessToken: string;
|
|
@@ -38,26 +46,38 @@ export interface Pagination {
|
|
|
38
46
|
}
|
|
39
47
|
export declare class NotFoundException extends Error {
|
|
40
48
|
readonly statusCode = 404;
|
|
41
|
-
|
|
49
|
+
readonly errors?: FlexbeBulkError[];
|
|
50
|
+
readonly error: string;
|
|
51
|
+
constructor(message: string | string[], error?: string, errors?: FlexbeBulkError[]);
|
|
42
52
|
}
|
|
43
53
|
export declare class ForbiddenException extends Error {
|
|
44
54
|
readonly statusCode = 403;
|
|
45
|
-
|
|
55
|
+
readonly errors?: FlexbeBulkError[];
|
|
56
|
+
readonly error: string;
|
|
57
|
+
constructor(message: string | string[], error?: string, errors?: FlexbeBulkError[]);
|
|
46
58
|
}
|
|
47
59
|
export declare class BadRequestException extends Error {
|
|
48
60
|
readonly statusCode = 400;
|
|
49
|
-
|
|
61
|
+
readonly errors?: FlexbeBulkError[];
|
|
62
|
+
readonly error: string;
|
|
63
|
+
constructor(message: string | string[], error?: string, errors?: FlexbeBulkError[]);
|
|
50
64
|
}
|
|
51
65
|
export declare class UnauthorizedException extends Error {
|
|
52
66
|
readonly statusCode = 401;
|
|
53
|
-
|
|
67
|
+
readonly errors?: FlexbeBulkError[];
|
|
68
|
+
readonly error: string;
|
|
69
|
+
constructor(message: string | string[], error?: string, errors?: FlexbeBulkError[]);
|
|
54
70
|
}
|
|
55
71
|
export declare class ServerException extends Error {
|
|
56
72
|
readonly statusCode: number;
|
|
57
|
-
|
|
73
|
+
readonly errors?: FlexbeBulkError[];
|
|
74
|
+
readonly error: string;
|
|
75
|
+
constructor(message: string | string[], error?: string, statusCode?: number, errors?: FlexbeBulkError[]);
|
|
58
76
|
}
|
|
59
77
|
export declare class TimeoutException extends Error {
|
|
60
78
|
readonly statusCode = 408;
|
|
61
|
-
|
|
79
|
+
readonly errors?: FlexbeBulkError[];
|
|
80
|
+
readonly error: string;
|
|
81
|
+
constructor(message: string | string[], error?: string, errors?: FlexbeBulkError[]);
|
|
62
82
|
}
|
|
63
83
|
export type SiteApi = import('../client/site-api').SiteApi;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pagination } from './index';
|
|
1
|
+
import { FlexbeBulkError, Pagination } from './index';
|
|
2
2
|
export interface GridConfig {
|
|
3
3
|
color?: string;
|
|
4
4
|
desktop?: {
|
|
@@ -99,14 +99,9 @@ export interface UpdatePageParams {
|
|
|
99
99
|
export interface BulkUpdatePageItem extends UpdatePageParams {
|
|
100
100
|
id: number;
|
|
101
101
|
}
|
|
102
|
-
export interface BulkUpdateError {
|
|
103
|
-
id: number;
|
|
104
|
-
code: number;
|
|
105
|
-
message: string;
|
|
106
|
-
}
|
|
107
102
|
export interface BulkUpdateResponse {
|
|
108
103
|
updated: Page[];
|
|
109
|
-
errors:
|
|
104
|
+
errors: FlexbeBulkError[];
|
|
110
105
|
}
|
|
111
106
|
export interface BulkUpdateFolderItem extends UpdateFolderParams {
|
|
112
107
|
id: number;
|