@aeriajs/common 0.0.56 → 0.0.58
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/error.d.ts +1 -1
- package/dist/schema.d.ts +28 -1
- package/dist/schema.js +36 -3
- package/dist/schema.mjs +33 -1
- package/package.json +2 -2
package/dist/error.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import type { EndpointError, EndpointErrorContent } from '@aeriajs/types';
|
|
|
2
2
|
export declare const error: <const TEndpointErrorContent extends EndpointErrorContent>(value: TEndpointErrorContent) => EndpointError & {
|
|
3
3
|
value: TEndpointErrorContent;
|
|
4
4
|
};
|
|
5
|
-
export declare const isError:
|
|
5
|
+
export declare const isError: (object: EndpointError | any) => object is EndpointError<any>;
|
|
6
6
|
export declare const unwrapError: <TEndpointErrorContent extends EndpointErrorContent>(error: EndpointError<TEndpointErrorContent>) => TEndpointErrorContent;
|
|
7
7
|
export declare const throwIfError: <TValue>(value: TValue, message?: any) => Exclude<TValue, EndpointError<any>>;
|
package/dist/schema.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const rightSchema: <const TObject extends Property>(object: TObje
|
|
|
18
18
|
readonly value: Property;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const errorSchema: <const THTTPStatus extends HTTPStatus[], const TCode extends string[]>(error: {
|
|
22
22
|
httpStatus: THTTPStatus;
|
|
23
23
|
code: TCode;
|
|
24
24
|
}) => {
|
|
@@ -48,3 +48,30 @@ export declare const endpointErrorSchema: <const THTTPStatus extends HTTPStatus[
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
+
export declare const genericErrorSchema: () => {
|
|
52
|
+
readonly type: "object";
|
|
53
|
+
readonly properties: {
|
|
54
|
+
readonly _tag: {
|
|
55
|
+
readonly const: "Error";
|
|
56
|
+
};
|
|
57
|
+
readonly value: {
|
|
58
|
+
readonly type: "object";
|
|
59
|
+
readonly required: readonly ["httpStatus", "code"];
|
|
60
|
+
readonly properties: {
|
|
61
|
+
readonly httpStatus: {
|
|
62
|
+
readonly type: "number";
|
|
63
|
+
};
|
|
64
|
+
readonly code: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
};
|
|
67
|
+
readonly message: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
};
|
|
70
|
+
readonly details: {
|
|
71
|
+
readonly type: "object";
|
|
72
|
+
readonly variable: true;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
package/dist/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.genericErrorSchema = exports.errorSchema = exports.rightSchema = exports.leftSchema = exports.fromLiteral = void 0;
|
|
4
4
|
const mapValueToProperty = (value) => {
|
|
5
5
|
if (value.constructor === Object) {
|
|
6
6
|
return Object.assign({
|
|
@@ -72,7 +72,7 @@ const rightSchema = (object) => {
|
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
exports.rightSchema = rightSchema;
|
|
75
|
-
const
|
|
75
|
+
const errorSchema = (error) => {
|
|
76
76
|
return {
|
|
77
77
|
type: 'object',
|
|
78
78
|
properties: {
|
|
@@ -104,4 +104,37 @@ const endpointErrorSchema = (error) => {
|
|
|
104
104
|
},
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
|
-
exports.
|
|
107
|
+
exports.errorSchema = errorSchema;
|
|
108
|
+
const genericErrorSchema = () => {
|
|
109
|
+
return {
|
|
110
|
+
type: 'object',
|
|
111
|
+
properties: {
|
|
112
|
+
_tag: {
|
|
113
|
+
const: 'Error',
|
|
114
|
+
},
|
|
115
|
+
value: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
required: [
|
|
118
|
+
'httpStatus',
|
|
119
|
+
'code',
|
|
120
|
+
],
|
|
121
|
+
properties: {
|
|
122
|
+
httpStatus: {
|
|
123
|
+
type: 'number',
|
|
124
|
+
},
|
|
125
|
+
code: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
},
|
|
128
|
+
message: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
},
|
|
131
|
+
details: {
|
|
132
|
+
type: 'object',
|
|
133
|
+
variable: true,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
exports.genericErrorSchema = genericErrorSchema;
|
package/dist/schema.mjs
CHANGED
|
@@ -67,7 +67,7 @@ export const rightSchema = (object) => {
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
-
export const
|
|
70
|
+
export const errorSchema = (error) => {
|
|
71
71
|
return {
|
|
72
72
|
type: "object",
|
|
73
73
|
properties: {
|
|
@@ -99,3 +99,35 @@ export const endpointErrorSchema = (error) => {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
+
export const genericErrorSchema = () => {
|
|
103
|
+
return {
|
|
104
|
+
type: "object",
|
|
105
|
+
properties: {
|
|
106
|
+
_tag: {
|
|
107
|
+
const: "Error"
|
|
108
|
+
},
|
|
109
|
+
value: {
|
|
110
|
+
type: "object",
|
|
111
|
+
required: [
|
|
112
|
+
"httpStatus",
|
|
113
|
+
"code"
|
|
114
|
+
],
|
|
115
|
+
properties: {
|
|
116
|
+
httpStatus: {
|
|
117
|
+
type: "number"
|
|
118
|
+
},
|
|
119
|
+
code: {
|
|
120
|
+
type: "string"
|
|
121
|
+
},
|
|
122
|
+
message: {
|
|
123
|
+
type: "string"
|
|
124
|
+
},
|
|
125
|
+
details: {
|
|
126
|
+
type: "object",
|
|
127
|
+
variable: true
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"bson": "^6.5.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@aeriajs/types": "^0.0.
|
|
34
|
+
"@aeriajs/types": "^0.0.54",
|
|
35
35
|
"bson": "^6.5.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|