@aptly-as/types 2.7.15 → 2.8.0
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/enums/index.d.ts +0 -5
- package/enums/index.js +0 -6
- package/error/error.d.ts +10 -6
- package/error/error.js +15 -10
- package/error/error.utils.d.ts +5 -0
- package/error/error.utils.js +6 -0
- package/error/index.d.ts +1 -0
- package/error/index.js +1 -0
- package/package.json +1 -1
package/enums/index.d.ts
CHANGED
|
@@ -83,11 +83,6 @@ export declare enum AptlySignageSignerRef {
|
|
|
83
83
|
Customer = "customer",
|
|
84
84
|
Admin = "admin"
|
|
85
85
|
}
|
|
86
|
-
export declare enum AptlyErrorCode {
|
|
87
|
-
Default = "default",
|
|
88
|
-
InvalidFields = "invalid-fields",
|
|
89
|
-
SessionExpired = "session-expired"
|
|
90
|
-
}
|
|
91
86
|
export declare enum AptlyQueueDownloadType {
|
|
92
87
|
Document = "document",
|
|
93
88
|
Image = "image"
|
package/enums/index.js
CHANGED
|
@@ -95,12 +95,6 @@ export var AptlySignageSignerRef;
|
|
|
95
95
|
AptlySignageSignerRef["Customer"] = "customer";
|
|
96
96
|
AptlySignageSignerRef["Admin"] = "admin";
|
|
97
97
|
})(AptlySignageSignerRef || (AptlySignageSignerRef = {}));
|
|
98
|
-
export var AptlyErrorCode;
|
|
99
|
-
(function (AptlyErrorCode) {
|
|
100
|
-
AptlyErrorCode["Default"] = "default";
|
|
101
|
-
AptlyErrorCode["InvalidFields"] = "invalid-fields";
|
|
102
|
-
AptlyErrorCode["SessionExpired"] = "session-expired";
|
|
103
|
-
})(AptlyErrorCode || (AptlyErrorCode = {}));
|
|
104
98
|
export var AptlyQueueDownloadType;
|
|
105
99
|
(function (AptlyQueueDownloadType) {
|
|
106
100
|
AptlyQueueDownloadType["Document"] = "document";
|
package/error/error.d.ts
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
+
import { AptlyErrorCode } from './error.utils.js';
|
|
1
2
|
export interface AptlyErrorBody {
|
|
2
3
|
name: 'AptlyError';
|
|
3
4
|
status: number;
|
|
4
|
-
|
|
5
|
+
message: string;
|
|
5
6
|
id?: string;
|
|
6
|
-
code?:
|
|
7
|
+
code?: AptlyErrorCode;
|
|
7
8
|
detail?: string;
|
|
8
9
|
errors?: AptlyErrorBodySimple[];
|
|
9
10
|
link?: string;
|
|
11
|
+
title?: string;
|
|
10
12
|
error?: string;
|
|
11
13
|
}
|
|
12
|
-
export type AptlyErrorBodySimple = Pick<AptlyErrorBody, 'status' | '
|
|
14
|
+
export type AptlyErrorBodySimple = Pick<AptlyErrorBody, 'status' | 'message' | 'detail' | 'link'>;
|
|
13
15
|
export declare class AptlyError extends Error {
|
|
14
16
|
readonly data: Omit<AptlyErrorBody, 'name'>;
|
|
15
17
|
readonly error?: Error | undefined;
|
|
16
18
|
readonly name = "AptlyError";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
readonly _status: number;
|
|
20
|
+
readonly id: string;
|
|
19
21
|
static fromFetchResponse(response: Response): Promise<AptlyError>;
|
|
22
|
+
static fromResponse(response: Response): Promise<AptlyError>;
|
|
23
|
+
constructor(data: Omit<AptlyErrorBody, 'name'>, error?: Error | undefined);
|
|
20
24
|
get status(): number;
|
|
21
25
|
get title(): string;
|
|
22
|
-
get code():
|
|
26
|
+
get code(): AptlyErrorCode | undefined;
|
|
23
27
|
get detail(): string | undefined;
|
|
24
28
|
get link(): string | undefined;
|
|
25
29
|
get errors(): AptlyErrorBodySimple[];
|
package/error/error.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
export class AptlyError extends Error {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
this.data = data;
|
|
5
|
-
this.error = error;
|
|
6
|
-
this.name = 'AptlyError';
|
|
7
|
-
this.id = data.id || '';
|
|
2
|
+
static fromFetchResponse(response) {
|
|
3
|
+
return AptlyError.fromResponse(response);
|
|
8
4
|
}
|
|
9
|
-
static async
|
|
5
|
+
static async fromResponse(response) {
|
|
10
6
|
if (response.headers.get('content-type') !== 'application/json') {
|
|
11
7
|
const body = await response.json();
|
|
12
8
|
if (body.name === AptlyError.name) {
|
|
@@ -16,15 +12,24 @@ export class AptlyError extends Error {
|
|
|
16
12
|
throw new AptlyError({
|
|
17
13
|
id: 'unknown',
|
|
18
14
|
status: response.status,
|
|
19
|
-
|
|
15
|
+
message: response.statusText,
|
|
20
16
|
detail: `Failed to fetch from url: ${response.url}`,
|
|
21
17
|
});
|
|
22
18
|
}
|
|
19
|
+
constructor(data, error) {
|
|
20
|
+
super(data.title || data.message);
|
|
21
|
+
this.data = data;
|
|
22
|
+
this.error = error;
|
|
23
|
+
this.name = 'AptlyError';
|
|
24
|
+
this._status = 500;
|
|
25
|
+
this._status = data.status;
|
|
26
|
+
this.id = data.id || '';
|
|
27
|
+
}
|
|
23
28
|
get status() {
|
|
24
|
-
return this.
|
|
29
|
+
return this._status;
|
|
25
30
|
}
|
|
26
31
|
get title() {
|
|
27
|
-
return this.data.
|
|
32
|
+
return this.data.message;
|
|
28
33
|
}
|
|
29
34
|
get code() {
|
|
30
35
|
return this.data.code;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var AptlyErrorCode;
|
|
2
|
+
(function (AptlyErrorCode) {
|
|
3
|
+
AptlyErrorCode[AptlyErrorCode["NotFound"] = 4040] = "NotFound";
|
|
4
|
+
AptlyErrorCode[AptlyErrorCode["Duplicate"] = 4090] = "Duplicate";
|
|
5
|
+
AptlyErrorCode[AptlyErrorCode["Error"] = 5000] = "Error";
|
|
6
|
+
})(AptlyErrorCode || (AptlyErrorCode = {}));
|
package/error/index.d.ts
CHANGED
package/error/index.js
CHANGED