@aeriajs/common 0.0.53 → 0.0.55
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 +5 -5
- package/dist/error.js +14 -9
- package/dist/error.mjs +10 -8
- package/dist/pipe.d.ts +2 -2
- package/dist/pipe.js +1 -1
- package/dist/pipe.mjs +1 -1
- package/dist/schema.d.ts +23 -10
- package/dist/schema.js +21 -8
- package/dist/schema.mjs +21 -8
- package/package.json +2 -2
package/dist/error.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { EndpointError, EndpointErrorContent
|
|
2
|
-
export declare const error: <TEndpointErrorContent extends EndpointErrorContent>(
|
|
3
|
-
|
|
4
|
-
readonly error: TEndpointErrorContent;
|
|
1
|
+
import type { EndpointError, EndpointErrorContent } from '@aeriajs/types';
|
|
2
|
+
export declare const error: <const TEndpointErrorContent extends EndpointErrorContent>(value: TEndpointErrorContent) => EndpointError & {
|
|
3
|
+
value: TEndpointErrorContent;
|
|
5
4
|
};
|
|
6
|
-
export declare const isError: (object: any) => object is EndpointError<
|
|
5
|
+
export declare const isError: <TEndpointErrorContent extends EndpointErrorContent>(object: EndpointError<TEndpointErrorContent> | any) => object is EndpointError<TEndpointErrorContent>;
|
|
6
|
+
export declare const unwrapError: <TEndpointErrorContent extends EndpointErrorContent>(error: EndpointError<TEndpointErrorContent>) => TEndpointErrorContent;
|
package/dist/error.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isError = exports.error = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
return {
|
|
3
|
+
exports.unwrapError = exports.isError = exports.error = void 0;
|
|
4
|
+
const types_1 = require("@aeriajs/types");
|
|
5
|
+
const error = (value) => {
|
|
6
|
+
const wrappedError = {
|
|
7
|
+
[types_1.ERROR_SYMBOL]: true,
|
|
10
8
|
_tag: 'Error',
|
|
11
|
-
|
|
9
|
+
value,
|
|
12
10
|
};
|
|
11
|
+
return wrappedError;
|
|
13
12
|
};
|
|
14
13
|
exports.error = error;
|
|
15
14
|
const isError = (object) => {
|
|
16
|
-
return object
|
|
15
|
+
return object
|
|
16
|
+
&& typeof object === 'object'
|
|
17
|
+
&& (types_1.ERROR_SYMBOL in object || types_1.ERROR_SYMBOL_DESCRIPTION in object);
|
|
17
18
|
};
|
|
18
19
|
exports.isError = isError;
|
|
20
|
+
const unwrapError = (error) => {
|
|
21
|
+
return error.value;
|
|
22
|
+
};
|
|
23
|
+
exports.unwrapError = unwrapError;
|
package/dist/error.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
return {
|
|
2
|
+
import { ERROR_SYMBOL, ERROR_SYMBOL_DESCRIPTION } from "@aeriajs/types";
|
|
3
|
+
export const error = (value) => {
|
|
4
|
+
const wrappedError = {
|
|
5
|
+
[ERROR_SYMBOL]: true,
|
|
8
6
|
_tag: "Error",
|
|
9
|
-
|
|
7
|
+
value
|
|
10
8
|
};
|
|
9
|
+
return wrappedError;
|
|
11
10
|
};
|
|
12
11
|
export const isError = (object) => {
|
|
13
|
-
return object
|
|
12
|
+
return object && typeof object === "object" && (ERROR_SYMBOL in object || ERROR_SYMBOL_DESCRIPTION in object);
|
|
13
|
+
};
|
|
14
|
+
export const unwrapError = (error2) => {
|
|
15
|
+
return error2.value;
|
|
14
16
|
};
|
package/dist/pipe.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type PipeOptions = {
|
|
2
|
-
returnFirst?: boolean | ((value: any) =>
|
|
2
|
+
returnFirst?: boolean | ((value: any) => any);
|
|
3
3
|
};
|
|
4
|
-
export declare const pipe: <TFunction extends (...args: any) => any>(functions: TFunction[], options?: PipeOptions) => (value: Parameters<TFunction>[0], ...args: Parameters<TFunction> extends [unknown, ...infer Tail] ? Tail : []) => Promise<
|
|
4
|
+
export declare const pipe: <TFunction extends (...args: any) => any>(functions: TFunction[], options?: PipeOptions) => (value: Parameters<TFunction>[0], ...args: Parameters<TFunction> extends [unknown, ...infer Tail] ? Tail : []) => Promise<any>;
|
package/dist/pipe.js
CHANGED
package/dist/pipe.mjs
CHANGED
package/dist/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Property, ObjectToSchema,
|
|
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
3
|
export declare const leftSchema: <const TObject extends Property>(object: TObject) => {
|
|
4
4
|
readonly type: "object";
|
|
@@ -18,17 +18,30 @@ export declare const rightSchema: <const TObject extends Property>(object: TObje
|
|
|
18
18
|
readonly value: Property;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
export declare const endpointErrorSchema: (error:
|
|
21
|
+
export declare const endpointErrorSchema: <THTTPStatus extends HTTPStatus[], TCode extends string[]>(error: {
|
|
22
|
+
httpStatus: THTTPStatus;
|
|
23
|
+
code: TCode;
|
|
24
|
+
}) => {
|
|
22
25
|
readonly type: "object";
|
|
23
26
|
readonly properties: {
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
readonly value: {
|
|
28
|
+
readonly type: "object";
|
|
29
|
+
readonly required: readonly ["httpStatus", "code"];
|
|
30
|
+
readonly properties: {
|
|
31
|
+
readonly httpStatus: {
|
|
32
|
+
readonly enum: THTTPStatus;
|
|
33
|
+
};
|
|
34
|
+
readonly code: {
|
|
35
|
+
readonly enum: TCode;
|
|
36
|
+
};
|
|
37
|
+
readonly message: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
};
|
|
40
|
+
readonly details: {
|
|
41
|
+
readonly type: "object";
|
|
42
|
+
readonly variable: true;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
32
45
|
};
|
|
33
46
|
};
|
|
34
47
|
};
|
package/dist/schema.js
CHANGED
|
@@ -76,14 +76,27 @@ const endpointErrorSchema = (error) => {
|
|
|
76
76
|
return {
|
|
77
77
|
type: 'object',
|
|
78
78
|
properties: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
value: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
required: [
|
|
82
|
+
'httpStatus',
|
|
83
|
+
'code',
|
|
84
|
+
],
|
|
85
|
+
properties: {
|
|
86
|
+
httpStatus: {
|
|
87
|
+
enum: error.httpStatus,
|
|
88
|
+
},
|
|
89
|
+
code: {
|
|
90
|
+
enum: error.code,
|
|
91
|
+
},
|
|
92
|
+
message: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
},
|
|
95
|
+
details: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
variable: true,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
87
100
|
},
|
|
88
101
|
},
|
|
89
102
|
};
|
package/dist/schema.mjs
CHANGED
|
@@ -71,14 +71,27 @@ export const endpointErrorSchema = (error) => {
|
|
|
71
71
|
return {
|
|
72
72
|
type: "object",
|
|
73
73
|
properties: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
value: {
|
|
75
|
+
type: "object",
|
|
76
|
+
required: [
|
|
77
|
+
"httpStatus",
|
|
78
|
+
"code"
|
|
79
|
+
],
|
|
80
|
+
properties: {
|
|
81
|
+
httpStatus: {
|
|
82
|
+
enum: error.httpStatus
|
|
83
|
+
},
|
|
84
|
+
code: {
|
|
85
|
+
enum: error.code
|
|
86
|
+
},
|
|
87
|
+
message: {
|
|
88
|
+
type: "string"
|
|
89
|
+
},
|
|
90
|
+
details: {
|
|
91
|
+
type: "object",
|
|
92
|
+
variable: true
|
|
93
|
+
}
|
|
94
|
+
}
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
97
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
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.52",
|
|
35
35
|
"bson": "^6.5.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|