@aeriajs/types 0.0.127 → 0.0.128
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/functionSchemas.d.ts +4 -0
- package/dist/http.d.ts +10 -2
- package/dist/property.d.ts +9 -4
- package/dist/resultSchemas.d.ts +4 -0
- package/dist/resultSchemas.js +4 -0
- package/dist/resultSchemas.mjs +8 -4
- package/dist/schema.d.ts +3 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ export declare const insertError: () => {
|
|
|
6
6
|
};
|
|
7
7
|
readonly result: {
|
|
8
8
|
readonly const: undefined;
|
|
9
|
+
readonly isConstUndefined: true;
|
|
9
10
|
};
|
|
10
11
|
readonly error: {
|
|
11
12
|
readonly type: "object";
|
|
@@ -36,6 +37,7 @@ export declare const getError: () => {
|
|
|
36
37
|
};
|
|
37
38
|
readonly result: {
|
|
38
39
|
readonly const: undefined;
|
|
40
|
+
readonly isConstUndefined: true;
|
|
39
41
|
};
|
|
40
42
|
readonly error: {
|
|
41
43
|
readonly type: "object";
|
|
@@ -66,6 +68,7 @@ export declare const getAllError: () => {
|
|
|
66
68
|
};
|
|
67
69
|
readonly result: {
|
|
68
70
|
readonly const: undefined;
|
|
71
|
+
readonly isConstUndefined: true;
|
|
69
72
|
};
|
|
70
73
|
readonly error: {
|
|
71
74
|
readonly type: "object";
|
|
@@ -96,6 +99,7 @@ export declare const countError: () => {
|
|
|
96
99
|
};
|
|
97
100
|
readonly result: {
|
|
98
101
|
readonly const: undefined;
|
|
102
|
+
readonly isConstUndefined: true;
|
|
99
103
|
};
|
|
100
104
|
readonly error: {
|
|
101
105
|
readonly type: "object";
|
package/dist/http.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Result, ExtractError, ExtractResult } from './result.js';
|
|
|
3
3
|
import type { EndpointError } from './endpointError.js';
|
|
4
4
|
import type { ACError } from './accessControl.js';
|
|
5
5
|
import type { RateLimitingError } from './security.js';
|
|
6
|
+
import { type Contract } from './contract.js';
|
|
7
|
+
import { type InferProperties, type InferProperty, type PackReferences } from './schema.js';
|
|
6
8
|
export declare const REQUEST_METHODS: readonly ["GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "PATCH", "TRACE", "SEARCH"];
|
|
7
9
|
export declare const HTTPStatus: {
|
|
8
10
|
readonly Ok: 200;
|
|
@@ -35,6 +37,12 @@ type ExtractHTTPStatus<TRouteResponse> = TRouteResponse extends EndpointError<st
|
|
|
35
37
|
export type NativeError = typeof ACError.AuthenticationError | typeof ACError.AuthorizationError | typeof RateLimitingError.LimitReached | typeof RateLimitingError.Unauthenticated;
|
|
36
38
|
export type NativeHTTPErrorStatus = typeof HTTPStatus.Unauthorized | typeof HTTPStatus.TooManyRequests;
|
|
37
39
|
export type WithACErrors<TRouteResponse> = TRouteResponse extends Result.Either<infer InferredError, unknown> ? Result.Either<ExtractError<TRouteResponse> | EndpointError<ExtractCode<InferredError> | NativeError, unknown, ExtractHTTPStatus<InferredError> | NativeHTTPErrorStatus>, ExtractResult<TRouteResponse>> : TRouteResponse | Result.Error<EndpointError<NativeError, unknown, NativeHTTPErrorStatus>>;
|
|
38
|
-
export type
|
|
39
|
-
export type
|
|
40
|
+
export type InferEndpointFunction<TRouteResponse, TRoutePayload> = TRoutePayload extends null ? <T = TRouteResponse>(payload?: unknown) => Promise<WithACErrors<T>> : TRoutePayload extends undefined ? <T = TRouteResponse>() => Promise<WithACErrors<T>> : <T = TRouteResponse>(payload: TRoutePayload) => Promise<WithACErrors<T>>;
|
|
41
|
+
export type InferEndpointFromContract<TContract extends Contract> = TContract extends {
|
|
42
|
+
response: infer RouteResponse;
|
|
43
|
+
} | {
|
|
44
|
+
payload: infer RoutePayload;
|
|
45
|
+
} | {
|
|
46
|
+
query: infer RoutePayload;
|
|
47
|
+
} ? InferEndpointFunction<RouteResponse extends {} ? InferProperties<RouteResponse> : unknown, RoutePayload extends {} ? PackReferences<InferProperty<RoutePayload>> : undefined> : never;
|
|
40
48
|
export {};
|
package/dist/property.d.ts
CHANGED
|
@@ -94,16 +94,21 @@ export type BooleanProperty = {
|
|
|
94
94
|
element?: 'checkbox';
|
|
95
95
|
};
|
|
96
96
|
export type GetterProperty = {
|
|
97
|
-
|
|
97
|
+
type: 'getter';
|
|
98
|
+
getter?: (document: unknown & {
|
|
98
99
|
_id: ObjectId;
|
|
99
100
|
}, context: RouteContext) => unknown;
|
|
100
101
|
requires?: string[];
|
|
101
102
|
};
|
|
102
103
|
export type ConstProperty = {
|
|
103
|
-
const: string | number | boolean |
|
|
104
|
+
const: string | number | boolean | null;
|
|
104
105
|
};
|
|
105
|
-
export type
|
|
106
|
-
|
|
106
|
+
export type ConstUndefinedProperty = {
|
|
107
|
+
const?: undefined;
|
|
108
|
+
isConstUndefined: true;
|
|
109
|
+
};
|
|
110
|
+
export type MixedProperty = RefProperty | FileProperty | EnumProperty | ArrayProperty | ObjectProperty | StringProperty | NumberProperty | BooleanProperty | GetterProperty | ConstProperty | ConstUndefinedProperty;
|
|
111
|
+
export type NonCircularMixedProperty = NonCircularRefProperty | FileProperty | EnumProperty | ArrayProperty | ObjectProperty | StringProperty | NumberProperty | BooleanProperty | GetterProperty | ConstProperty | ConstUndefinedProperty;
|
|
107
112
|
export type PropertyBase = {
|
|
108
113
|
description?: string;
|
|
109
114
|
readOnly?: boolean;
|
package/dist/resultSchemas.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const errorSchema: <const TError extends Property>(error: TError)
|
|
|
9
9
|
readonly error: TError;
|
|
10
10
|
readonly result: {
|
|
11
11
|
readonly const: undefined;
|
|
12
|
+
readonly isConstUndefined: true;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
};
|
|
@@ -20,6 +21,7 @@ export declare const resultSchema: <const TResult extends Property>(result: TRes
|
|
|
20
21
|
};
|
|
21
22
|
readonly error: {
|
|
22
23
|
readonly const: undefined;
|
|
24
|
+
readonly isConstUndefined: true;
|
|
23
25
|
};
|
|
24
26
|
readonly result: TResult;
|
|
25
27
|
};
|
|
@@ -35,6 +37,7 @@ export declare const endpointErrorSchema: <const THTTPStatus extends (typeof HTT
|
|
|
35
37
|
};
|
|
36
38
|
readonly result: {
|
|
37
39
|
readonly const: undefined;
|
|
40
|
+
readonly isConstUndefined: true;
|
|
38
41
|
};
|
|
39
42
|
readonly error: {
|
|
40
43
|
readonly type: "object";
|
|
@@ -65,6 +68,7 @@ export declare const genericEndpointErrorSchema: () => {
|
|
|
65
68
|
};
|
|
66
69
|
readonly result: {
|
|
67
70
|
readonly const: undefined;
|
|
71
|
+
readonly isConstUndefined: true;
|
|
68
72
|
};
|
|
69
73
|
readonly error: {
|
|
70
74
|
readonly type: "object";
|
package/dist/resultSchemas.js
CHANGED
|
@@ -11,6 +11,7 @@ const errorSchema = (error) => {
|
|
|
11
11
|
error,
|
|
12
12
|
result: {
|
|
13
13
|
const: undefined,
|
|
14
|
+
isConstUndefined: true,
|
|
14
15
|
},
|
|
15
16
|
},
|
|
16
17
|
};
|
|
@@ -26,6 +27,7 @@ const resultSchema = (result) => {
|
|
|
26
27
|
},
|
|
27
28
|
error: {
|
|
28
29
|
const: undefined,
|
|
30
|
+
isConstUndefined: true,
|
|
29
31
|
},
|
|
30
32
|
result,
|
|
31
33
|
},
|
|
@@ -42,6 +44,7 @@ const endpointErrorSchema = (error) => {
|
|
|
42
44
|
},
|
|
43
45
|
result: {
|
|
44
46
|
const: undefined,
|
|
47
|
+
isConstUndefined: true,
|
|
45
48
|
},
|
|
46
49
|
error: {
|
|
47
50
|
type: 'object',
|
|
@@ -78,6 +81,7 @@ const genericEndpointErrorSchema = () => {
|
|
|
78
81
|
},
|
|
79
82
|
result: {
|
|
80
83
|
const: undefined,
|
|
84
|
+
isConstUndefined: true,
|
|
81
85
|
},
|
|
82
86
|
error: {
|
|
83
87
|
type: 'object',
|
package/dist/resultSchemas.mjs
CHANGED
|
@@ -8,7 +8,8 @@ export const errorSchema = (error) => {
|
|
|
8
8
|
},
|
|
9
9
|
error,
|
|
10
10
|
result: {
|
|
11
|
-
const: void 0
|
|
11
|
+
const: void 0,
|
|
12
|
+
isConstUndefined: true
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
};
|
|
@@ -22,7 +23,8 @@ export const resultSchema = (result) => {
|
|
|
22
23
|
const: "Result"
|
|
23
24
|
},
|
|
24
25
|
error: {
|
|
25
|
-
const: void 0
|
|
26
|
+
const: void 0,
|
|
27
|
+
isConstUndefined: true
|
|
26
28
|
},
|
|
27
29
|
result
|
|
28
30
|
}
|
|
@@ -37,7 +39,8 @@ export const endpointErrorSchema = (error) => {
|
|
|
37
39
|
const: "Error"
|
|
38
40
|
},
|
|
39
41
|
result: {
|
|
40
|
-
const: void 0
|
|
42
|
+
const: void 0,
|
|
43
|
+
isConstUndefined: true
|
|
41
44
|
},
|
|
42
45
|
error: {
|
|
43
46
|
type: "object",
|
|
@@ -72,7 +75,8 @@ export const genericEndpointErrorSchema = () => {
|
|
|
72
75
|
const: "Error"
|
|
73
76
|
},
|
|
74
77
|
result: {
|
|
75
|
-
const: void 0
|
|
78
|
+
const: void 0,
|
|
79
|
+
isConstUndefined: true
|
|
76
80
|
},
|
|
77
81
|
error: {
|
|
78
82
|
type: "object",
|
package/dist/schema.d.ts
CHANGED
|
@@ -41,7 +41,9 @@ export type InferProperty<T> = T extends TestType<{
|
|
|
41
41
|
getter: (doc: unknown) => infer K;
|
|
42
42
|
}> ? Awaited<K> : T extends TestType<{
|
|
43
43
|
const: infer K;
|
|
44
|
-
}> ? K :
|
|
44
|
+
}> ? K : T extends TestType<{
|
|
45
|
+
isConstUndefined: true;
|
|
46
|
+
}> ? undefined : never;
|
|
45
47
|
type ExtractRequiredPropNames<T> = T extends readonly (infer PropName)[] ? PropName : Record<never, never> extends T ? null : keyof {
|
|
46
48
|
[K in keyof T as T[K] extends true ? K : never]: never;
|
|
47
49
|
};
|