@forklaunch/core 0.1.5 → 0.1.6
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/cache/redisTtlCache.d.ts +1 -0
- package/dist/cache/redisTtlCache.js +1 -0
- package/dist/cache/redisTtlCache.js.map +1 -1
- package/dist/entityMapper/interfaces/entityMapper.interface.d.ts +1 -0
- package/dist/entityMapper/models/baseEntityMapper.model.d.ts +7 -7
- package/dist/entityMapper/models/baseEntityMapper.model.js +7 -7
- package/dist/entityMapper/models/baseEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/models/requestEntityMapper.model.d.ts +13 -9
- package/dist/entityMapper/models/requestEntityMapper.model.js +13 -9
- package/dist/entityMapper/models/requestEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/models/responseEntityMapper.model.d.ts +14 -7
- package/dist/entityMapper/models/responseEntityMapper.model.js +12 -6
- package/dist/entityMapper/models/responseEntityMapper.model.js.map +1 -1
- package/dist/entityMapper/types/entityMapper.types.d.ts +2 -2
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +1 -0
- package/dist/http/index.js.map +1 -1
- package/dist/http/middleware/request.middleware.d.ts +84 -0
- package/dist/http/middleware/request.middleware.js +105 -2
- package/dist/http/middleware/request.middleware.js.map +1 -1
- package/dist/http/middleware/response.middleware.d.ts +11 -0
- package/dist/http/middleware/response.middleware.js +23 -3
- package/dist/http/middleware/response.middleware.js.map +1 -1
- package/dist/http/openApiV3Generator.d.ts +9 -0
- package/dist/http/openApiV3Generator.js +46 -6
- package/dist/http/openApiV3Generator.js.map +1 -1
- package/dist/http/regex.d.ts +8 -0
- package/dist/http/regex.js +115 -0
- package/dist/http/regex.js.map +1 -0
- package/dist/http/types/api.types.d.ts +71 -0
- package/dist/http/types/forklaunch.types.d.ts +17 -0
- package/dist/http/types/primitive.types.d.ts +73 -0
- package/package.json +3 -2
@@ -1,13 +1,30 @@
|
|
1
1
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
2
|
import { HttpContractDetails, PathParamHttpContractDetails } from './primitive.types';
|
3
|
+
/**
|
4
|
+
* Interface representing a Forklaunch router.
|
5
|
+
*
|
6
|
+
* @template SV - A type that extends AnySchemaValidator.
|
7
|
+
*/
|
3
8
|
export interface ForklaunchRouter<SV extends AnySchemaValidator> {
|
9
|
+
/** The base path for the router */
|
4
10
|
basePath: string;
|
11
|
+
/** The routes associated with the router */
|
5
12
|
routes: ForklaunchRoute<SV>[];
|
6
13
|
}
|
14
|
+
/**
|
15
|
+
* Interface representing a Forklaunch route.
|
16
|
+
*
|
17
|
+
* @template SV - A type that extends AnySchemaValidator.
|
18
|
+
*/
|
7
19
|
export interface ForklaunchRoute<SV extends AnySchemaValidator> {
|
20
|
+
/** The base path for the route */
|
8
21
|
basePath: string;
|
22
|
+
/** The path for the route, which can be a string, RegExp, or an array of strings or RegExps */
|
9
23
|
path: string | RegExp | (string | RegExp)[];
|
24
|
+
/** The SDK path for the route */
|
10
25
|
sdkPath: string;
|
26
|
+
/** The HTTP method for the route */
|
11
27
|
method: 'get' | 'post' | 'put' | 'patch' | 'delete';
|
28
|
+
/** The contract details for the route */
|
12
29
|
contractDetails: PathParamHttpContractDetails<SV> | HttpContractDetails<SV>;
|
13
30
|
}
|
@@ -1,27 +1,89 @@
|
|
1
1
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
2
2
|
import { UnboxedObjectSchema } from '@forklaunch/validator/types';
|
3
|
+
/**
|
4
|
+
* Dictionary type for URL parameters.
|
5
|
+
*/
|
3
6
|
export type ParamsDictionary = {
|
4
7
|
[key: string]: string;
|
5
8
|
};
|
9
|
+
/**
|
10
|
+
* Type representing an object with only string keys.
|
11
|
+
*
|
12
|
+
* @template SV - A type that extends AnySchemaValidator.
|
13
|
+
*/
|
6
14
|
export type StringOnlyObject<SV extends AnySchemaValidator> = Omit<UnboxedObjectSchema<SV>, number | symbol>;
|
15
|
+
/**
|
16
|
+
* Type representing an object with only number keys.
|
17
|
+
*
|
18
|
+
* @template SV - A type that extends AnySchemaValidator.
|
19
|
+
*/
|
7
20
|
export type NumberOnlyObject<SV extends AnySchemaValidator> = Omit<UnboxedObjectSchema<SV>, string | symbol>;
|
21
|
+
/**
|
22
|
+
* Type representing the body object in a request.
|
23
|
+
*
|
24
|
+
* @template SV - A type that extends AnySchemaValidator.
|
25
|
+
*/
|
8
26
|
export type BodyObject<SV extends AnySchemaValidator> = StringOnlyObject<SV> & unknown;
|
27
|
+
/**
|
28
|
+
* Type representing the parameters object in a request.
|
29
|
+
*
|
30
|
+
* @template SV - A type that extends AnySchemaValidator.
|
31
|
+
*/
|
9
32
|
export type ParamsObject<SV extends AnySchemaValidator> = StringOnlyObject<SV> & unknown;
|
33
|
+
/**
|
34
|
+
* Type representing the query object in a request.
|
35
|
+
*
|
36
|
+
* @template SV - A type that extends AnySchemaValidator.
|
37
|
+
*/
|
10
38
|
export type QueryObject<SV extends AnySchemaValidator> = StringOnlyObject<SV> & unknown;
|
39
|
+
/**
|
40
|
+
* Type representing the headers object in a request.
|
41
|
+
*
|
42
|
+
* @template SV - A type that extends AnySchemaValidator.
|
43
|
+
*/
|
11
44
|
export type HeadersObject<SV extends AnySchemaValidator> = StringOnlyObject<SV> & unknown;
|
45
|
+
/**
|
46
|
+
* Type representing the responses object in a request.
|
47
|
+
*
|
48
|
+
* @template SV - A type that extends AnySchemaValidator.
|
49
|
+
*/
|
12
50
|
export type ResponsesObject<SV extends AnySchemaValidator> = {
|
13
51
|
[key: number]: SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV> | string | SV['string'];
|
14
52
|
} & unknown;
|
53
|
+
/**
|
54
|
+
* Type representing the body in a request.
|
55
|
+
*
|
56
|
+
* @template SV - A type that extends AnySchemaValidator.
|
57
|
+
*/
|
15
58
|
export type Body<SV extends AnySchemaValidator> = BodyObject<SV> | SV['_ValidSchemaObject'] | SV['_SchemaCatchall'];
|
59
|
+
/**
|
60
|
+
* Type representing the authentication method.
|
61
|
+
*/
|
16
62
|
export type AuthMethod = 'jwt' | 'session';
|
63
|
+
/**
|
64
|
+
* Interface representing HTTP contract details for path parameters.
|
65
|
+
*
|
66
|
+
* @template SV - A type that extends AnySchemaValidator.
|
67
|
+
* @template ParamSchemas - A type for parameter schemas, defaulting to ParamsObject.
|
68
|
+
* @template ResponseSchemas - A type for response schemas, defaulting to ResponsesObject.
|
69
|
+
* @template QuerySchemas - A type for query schemas, defaulting to QueryObject.
|
70
|
+
*/
|
17
71
|
export interface PathParamHttpContractDetails<SV extends AnySchemaValidator, ParamSchemas extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, QuerySchemas extends QueryObject<SV> = QueryObject<SV>> {
|
72
|
+
/** Name of the contract */
|
18
73
|
name: string;
|
74
|
+
/** Summary of the contract */
|
19
75
|
summary: string;
|
76
|
+
/** Response schemas for the contract */
|
20
77
|
responses: ResponseSchemas;
|
78
|
+
/** Optional request headers for the contract */
|
21
79
|
requestHeaders?: HeadersObject<SV>;
|
80
|
+
/** Optional response headers for the contract */
|
22
81
|
responseHeaders?: HeadersObject<SV>;
|
82
|
+
/** Optional parameter schemas for the contract */
|
23
83
|
params?: ParamSchemas;
|
84
|
+
/** Optional query schemas for the contract */
|
24
85
|
query?: QuerySchemas;
|
86
|
+
/** Optional authentication details for the contract */
|
25
87
|
auth?: {
|
26
88
|
method: AuthMethod;
|
27
89
|
allowedSlugs?: Set<string>;
|
@@ -30,7 +92,18 @@ export interface PathParamHttpContractDetails<SV extends AnySchemaValidator, Par
|
|
30
92
|
forbiddenRoles?: Set<string>;
|
31
93
|
};
|
32
94
|
}
|
95
|
+
/**
|
96
|
+
* Interface representing HTTP contract details.
|
97
|
+
*
|
98
|
+
* @template SV - A type that extends AnySchemaValidator.
|
99
|
+
* @template ParamSchemas - A type for parameter schemas, defaulting to ParamsObject.
|
100
|
+
* @template ResponseSchemas - A type for response schemas, defaulting to ResponsesObject.
|
101
|
+
* @template BodySchema - A type for the body schema, defaulting to Body.
|
102
|
+
* @template QuerySchemas - A type for query schemas, defaulting to QueryObject.
|
103
|
+
*/
|
33
104
|
export interface HttpContractDetails<SV extends AnySchemaValidator, ParamSchemas extends ParamsObject<SV> = ParamsObject<SV>, ResponseSchemas extends ResponsesObject<SV> = ResponsesObject<SV>, BodySchema extends Body<SV> = Body<SV>, QuerySchemas extends QueryObject<SV> = QueryObject<SV>> extends PathParamHttpContractDetails<SV, ParamSchemas, ResponseSchemas, QuerySchemas> {
|
105
|
+
/** Optional body schema for the contract */
|
34
106
|
body?: BodySchema;
|
107
|
+
/** Optional content type for the contract */
|
35
108
|
contentType?: 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded';
|
36
109
|
}
|
package/package.json
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@forklaunch/core",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.6",
|
4
4
|
"description": "forklaunch-js core package. Contains useful building blocks.",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
7
7
|
],
|
8
|
+
"types": "dist/index.d.ts",
|
8
9
|
"scripts": {
|
9
10
|
"test": "jest",
|
10
11
|
"build": "tsc",
|
@@ -24,7 +25,7 @@
|
|
24
25
|
},
|
25
26
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
26
27
|
"dependencies": {
|
27
|
-
"@forklaunch/validator": "^0.
|
28
|
+
"@forklaunch/validator": "^0.3.0",
|
28
29
|
"@mikro-orm/core": "^6.2.9",
|
29
30
|
"jose": "^5.6.2",
|
30
31
|
"redis": "^4.6.14",
|