@aeriajs/common 0.0.60 → 0.0.62
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/schema.d.ts +12 -32
- package/dist/schema.js +13 -13
- package/dist/schema.mjs +10 -10
- package/package.json +2 -2
package/dist/schema.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { Property, ObjectToSchema, HTTPStatus } from '@aeriajs/types';
|
|
2
2
|
export declare const fromLiteral: <const TObject, TRequired extends (keyof TObject & string)[]>(object: TObject, required?: TRequired) => ObjectToSchema<TObject, TRequired>;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const errorSchema: <const TObject extends Property>(object: TObject) => {
|
|
4
4
|
readonly type: "object";
|
|
5
5
|
readonly properties: {
|
|
6
6
|
readonly _tag: {
|
|
7
|
-
readonly const: "
|
|
7
|
+
readonly const: "Error";
|
|
8
8
|
};
|
|
9
|
-
readonly
|
|
9
|
+
readonly error: Property;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const resultSchema: <const TObject extends Property>(object: TObject) => {
|
|
13
13
|
readonly type: "object";
|
|
14
14
|
readonly properties: {
|
|
15
15
|
readonly _tag: {
|
|
16
|
-
readonly const: "
|
|
16
|
+
readonly const: "Result";
|
|
17
17
|
};
|
|
18
|
-
readonly
|
|
18
|
+
readonly result: Property;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
export declare const endpointErrorSchema: <const THTTPStatus extends HTTPStatus[], const TCode extends string[]>(error: {
|
|
@@ -23,39 +23,19 @@ export declare const endpointErrorSchema: <const THTTPStatus extends HTTPStatus[
|
|
|
23
23
|
code: TCode;
|
|
24
24
|
}) => {
|
|
25
25
|
readonly type: "object";
|
|
26
|
-
readonly required: readonly ["httpStatus", "code"];
|
|
27
26
|
readonly properties: {
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
30
|
-
};
|
|
31
|
-
readonly code: {
|
|
32
|
-
readonly enum: TCode;
|
|
33
|
-
};
|
|
34
|
-
readonly message: {
|
|
35
|
-
readonly type: "string";
|
|
36
|
-
};
|
|
37
|
-
readonly details: {
|
|
38
|
-
readonly type: "object";
|
|
39
|
-
readonly variable: true;
|
|
27
|
+
readonly _tag: {
|
|
28
|
+
readonly const: "Error";
|
|
40
29
|
};
|
|
30
|
+
readonly error: Property;
|
|
41
31
|
};
|
|
42
32
|
};
|
|
43
33
|
export declare const genericEndpointErrorSchema: () => {
|
|
44
34
|
readonly type: "object";
|
|
45
|
-
readonly required: readonly ["httpStatus", "code"];
|
|
46
35
|
readonly properties: {
|
|
47
|
-
readonly
|
|
48
|
-
readonly
|
|
49
|
-
};
|
|
50
|
-
readonly code: {
|
|
51
|
-
readonly type: "string";
|
|
52
|
-
};
|
|
53
|
-
readonly message: {
|
|
54
|
-
readonly type: "string";
|
|
55
|
-
};
|
|
56
|
-
readonly details: {
|
|
57
|
-
readonly type: "object";
|
|
58
|
-
readonly variable: true;
|
|
36
|
+
readonly _tag: {
|
|
37
|
+
readonly const: "Error";
|
|
59
38
|
};
|
|
39
|
+
readonly error: Property;
|
|
60
40
|
};
|
|
61
41
|
};
|
package/dist/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.genericEndpointErrorSchema = exports.endpointErrorSchema = exports.
|
|
3
|
+
exports.genericEndpointErrorSchema = exports.endpointErrorSchema = exports.resultSchema = exports.errorSchema = exports.fromLiteral = void 0;
|
|
4
4
|
const mapValueToProperty = (value) => {
|
|
5
5
|
if (value.constructor === Object) {
|
|
6
6
|
return Object.assign({
|
|
@@ -48,32 +48,32 @@ const fromLiteral = (object, required) => {
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
exports.fromLiteral = fromLiteral;
|
|
51
|
-
const
|
|
51
|
+
const errorSchema = (object) => {
|
|
52
52
|
return {
|
|
53
53
|
type: 'object',
|
|
54
54
|
properties: {
|
|
55
55
|
_tag: {
|
|
56
|
-
const: '
|
|
56
|
+
const: 'Error',
|
|
57
57
|
},
|
|
58
|
-
|
|
58
|
+
error: object,
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
exports.
|
|
63
|
-
const
|
|
62
|
+
exports.errorSchema = errorSchema;
|
|
63
|
+
const resultSchema = (object) => {
|
|
64
64
|
return {
|
|
65
65
|
type: 'object',
|
|
66
66
|
properties: {
|
|
67
67
|
_tag: {
|
|
68
|
-
const: '
|
|
68
|
+
const: 'Result',
|
|
69
69
|
},
|
|
70
|
-
|
|
70
|
+
result: object,
|
|
71
71
|
},
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
-
exports.
|
|
74
|
+
exports.resultSchema = resultSchema;
|
|
75
75
|
const endpointErrorSchema = (error) => {
|
|
76
|
-
return {
|
|
76
|
+
return (0, exports.errorSchema)({
|
|
77
77
|
type: 'object',
|
|
78
78
|
required: [
|
|
79
79
|
'httpStatus',
|
|
@@ -94,11 +94,11 @@ const endpointErrorSchema = (error) => {
|
|
|
94
94
|
variable: true,
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
|
-
};
|
|
97
|
+
});
|
|
98
98
|
};
|
|
99
99
|
exports.endpointErrorSchema = endpointErrorSchema;
|
|
100
100
|
const genericEndpointErrorSchema = () => {
|
|
101
|
-
return {
|
|
101
|
+
return (0, exports.errorSchema)({
|
|
102
102
|
type: 'object',
|
|
103
103
|
required: [
|
|
104
104
|
'httpStatus',
|
|
@@ -119,6 +119,6 @@ const genericEndpointErrorSchema = () => {
|
|
|
119
119
|
variable: true,
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
|
-
};
|
|
122
|
+
});
|
|
123
123
|
};
|
|
124
124
|
exports.genericEndpointErrorSchema = genericEndpointErrorSchema;
|
package/dist/schema.mjs
CHANGED
|
@@ -45,30 +45,30 @@ export const fromLiteral = (object, required) => {
|
|
|
45
45
|
properties
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
|
-
export const
|
|
48
|
+
export const errorSchema = (object) => {
|
|
49
49
|
return {
|
|
50
50
|
type: "object",
|
|
51
51
|
properties: {
|
|
52
52
|
_tag: {
|
|
53
|
-
const: "
|
|
53
|
+
const: "Error"
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
error: object
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
-
export const
|
|
59
|
+
export const resultSchema = (object) => {
|
|
60
60
|
return {
|
|
61
61
|
type: "object",
|
|
62
62
|
properties: {
|
|
63
63
|
_tag: {
|
|
64
|
-
const: "
|
|
64
|
+
const: "Result"
|
|
65
65
|
},
|
|
66
|
-
|
|
66
|
+
result: object
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
70
|
export const endpointErrorSchema = (error) => {
|
|
71
|
-
return {
|
|
71
|
+
return errorSchema({
|
|
72
72
|
type: "object",
|
|
73
73
|
required: [
|
|
74
74
|
"httpStatus",
|
|
@@ -89,10 +89,10 @@ export const endpointErrorSchema = (error) => {
|
|
|
89
89
|
variable: true
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
};
|
|
92
|
+
});
|
|
93
93
|
};
|
|
94
94
|
export const genericEndpointErrorSchema = () => {
|
|
95
|
-
return {
|
|
95
|
+
return errorSchema({
|
|
96
96
|
type: "object",
|
|
97
97
|
required: [
|
|
98
98
|
"httpStatus",
|
|
@@ -113,5 +113,5 @@ export const genericEndpointErrorSchema = () => {
|
|
|
113
113
|
variable: true
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
};
|
|
116
|
+
});
|
|
117
117
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
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.58",
|
|
35
35
|
"bson": "^6.5.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|