quantum-flow 1.12.3 → 1.15.0
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/README.md +118 -17
- package/dist/app/aws/lambda.d.ts +11 -4
- package/dist/app/aws/lambda.js +43 -18
- package/dist/app/aws/lambda.js.map +1 -1
- package/dist/app/aws/utils/request.d.ts +2 -2
- package/dist/app/aws/utils/response.d.ts +3 -2
- package/dist/app/aws/utils/response.js +1 -1
- package/dist/app/aws/utils/response.js.map +1 -1
- package/dist/app/http/Application.d.ts +12 -4
- package/dist/app/http/Application.js +67 -26
- package/dist/app/http/Application.js.map +1 -1
- package/dist/app/plugin.d.ts +8 -0
- package/dist/app/plugin.js +43 -0
- package/dist/app/plugin.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +9 -1
- package/dist/constants.js.map +1 -1
- package/dist/core/Controller.js +3 -1
- package/dist/core/Controller.js.map +1 -1
- package/dist/core/Endpoint.d.ts +2 -2
- package/dist/core/Endpoint.js +4 -4
- package/dist/graphql/decorators.d.ts +49 -0
- package/dist/graphql/decorators.js +100 -0
- package/dist/graphql/decorators.js.map +1 -0
- package/dist/graphql/index.d.ts +2 -0
- package/dist/graphql/index.js +18 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/module.d.ts +15 -0
- package/dist/graphql/module.js +190 -0
- package/dist/graphql/module.js.map +1 -0
- package/dist/plugins/aws.d.ts +1 -0
- package/dist/plugins/aws.js +3 -0
- package/dist/plugins/aws.js.map +1 -0
- package/dist/plugins/http.d.ts +1 -0
- package/dist/plugins/http.js +3 -0
- package/dist/plugins/http.js.map +1 -0
- package/dist/types/common.d.ts +1 -1
- package/dist/types/common.js +1 -1
- package/dist/types/graphql.d.ts +38 -0
- package/dist/types/graphql.js +3 -0
- package/dist/types/graphql.js.map +1 -0
- package/dist/types/http.d.ts +37 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/lambda.d.ts +38 -1
- package/dist/types/plugins.d.ts +30 -0
- package/dist/types/plugins.js +3 -0
- package/dist/types/plugins.js.map +1 -0
- package/dist/utils/controller.js +5 -6
- package/dist/utils/controller.js.map +1 -1
- package/dist/utils/endpoint.d.ts +1 -0
- package/dist/utils/endpoint.js +15 -0
- package/dist/utils/endpoint.js.map +1 -1
- package/dist/utils/graphql.d.ts +1 -0
- package/dist/utils/graphql.js +3 -0
- package/dist/utils/graphql.js.map +1 -0
- package/dist/utils/helper.d.ts +1 -0
- package/dist/utils/helper.js +4 -0
- package/dist/utils/helper.js.map +1 -1
- package/dist/utils/server.js.map +1 -1
- package/package.json +18 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MiddlewareCB, PluginHookKeys, PluginKeys } from '../types/index.js';
|
|
2
|
+
export declare class Plugin {
|
|
3
|
+
plugins: any[];
|
|
4
|
+
middlewares: MiddlewareCB[];
|
|
5
|
+
protected callPluginHook<K extends PluginHookKeys>(hookName: K, ...args: any): Promise<void>;
|
|
6
|
+
protected callPluginMethod<K extends PluginKeys>(hookName: PluginKeys, ...args: any): Promise<void>;
|
|
7
|
+
usePlugin(plugin: any): this;
|
|
8
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Plugin = void 0;
|
|
4
|
+
class Plugin {
|
|
5
|
+
plugins;
|
|
6
|
+
middlewares;
|
|
7
|
+
async callPluginHook(hookName, ...args) {
|
|
8
|
+
for (const plugin of this.plugins) {
|
|
9
|
+
const hook = plugin.hooks?.[hookName];
|
|
10
|
+
if (hook) {
|
|
11
|
+
try {
|
|
12
|
+
await Promise.resolve(hook(...args));
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
console.error(`Plugin ${plugin.name} hook ${hookName} error:`, error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async callPluginMethod(hookName, ...args) {
|
|
21
|
+
for (const plugin of this.plugins) {
|
|
22
|
+
const hook = plugin?.[hookName];
|
|
23
|
+
if (hook) {
|
|
24
|
+
try {
|
|
25
|
+
await Promise.resolve(hook(...args));
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error(`Plugin ${plugin.name} hook ${hookName} error:`, error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
usePlugin(plugin) {
|
|
34
|
+
this.plugins.push(plugin);
|
|
35
|
+
plugin.onInit?.(this);
|
|
36
|
+
if (plugin.middleware) {
|
|
37
|
+
this.middlewares?.unshift(plugin.middleware);
|
|
38
|
+
}
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Plugin = Plugin;
|
|
43
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/app/plugin.ts"],"names":[],"mappings":";;;AAEA,MAAa,MAAM;IACjB,OAAO,CAAQ;IACf,WAAW,CAAiB;IAClB,KAAK,CAAC,cAAc,CAC5B,QAAW,EACX,GAAG,IAAS;QAEZ,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC;YACtC,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,OAAO,CAAE,IAAY,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBAChD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,UAAU,MAAM,CAAC,IAAI,SAAS,QAAQ,SAAS,EAAE,KAAK,CAAC,CAAC;gBACxE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACS,KAAK,CAAC,gBAAgB,CAC9B,QAAoB,EACpB,GAAG,IAAS;QAEZ,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC;YAChC,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,OAAO,CAAE,IAAY,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBAChD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,UAAU,MAAM,CAAC,IAAI,SAAS,QAAQ,SAAS,EAAE,KAAK,CAAC,CAAC;gBACxE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,SAAS,CAAC,MAAW;QACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA3CD,wBA2CC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -25,3 +25,11 @@ export declare const SSE_METADATA_KEY = "sse:handlers";
|
|
|
25
25
|
export declare const SSE_TOPIC_KEY = "sse:topics";
|
|
26
26
|
export declare const SSE_SERVICE_KEY = "sse:service";
|
|
27
27
|
export declare const STATIC_METADATA_KEY = "static:config";
|
|
28
|
+
export declare const GRAPHQL_QUERY = "graphql:query";
|
|
29
|
+
export declare const GRAPHQL_MUTATION = "graphql:mutation";
|
|
30
|
+
export declare const GRAPHQL_SUBSCRIPTION = "graphql:subscription";
|
|
31
|
+
export declare const GRAPHQL_TYPE = "graphql:type";
|
|
32
|
+
export declare const GRAPHQL_INPUT_TYPE = "graphql:inputType";
|
|
33
|
+
export declare const GRAPHQL_FIELD = "graphql:field";
|
|
34
|
+
export declare const GRAPHQL_ARG = "graphql:arg";
|
|
35
|
+
export declare const GRAPHQL_RESOLVER = "graphql:resolver";
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.STATIC_METADATA_KEY = exports.SSE_SERVICE_KEY = exports.SSE_TOPIC_KEY = exports.SSE_METADATA_KEY = exports.CORS_METADATA = exports.INCREMENT_STATISTIC = exports.STATISTIC = exports.TO_VALIDATE = exports.OK_STATUSES = exports.STOPPED = exports.SANITIZE = exports.CATCH = exports.INTECEPT = exports.WS_SERVICE_KEY = exports.WS_TOPIC_KEY = exports.WS_HANDLER = exports.USE_MIDDLEWARE = exports.SERVER_CONFIG_KEY = exports.OK_METADATA_KEY = exports.ENDPOINT = exports.INTERCEPTOR = exports.CONTROLLERS = exports.MIDDLEWARES = exports.ROUTE_MIDDLEWARES = exports.ROUTE_PREFIX = exports.APP_METADATA_KEY = exports.PARAM_METADATA_KEY = void 0;
|
|
3
|
+
exports.GRAPHQL_RESOLVER = exports.GRAPHQL_ARG = exports.GRAPHQL_FIELD = exports.GRAPHQL_INPUT_TYPE = exports.GRAPHQL_TYPE = exports.GRAPHQL_SUBSCRIPTION = exports.GRAPHQL_MUTATION = exports.GRAPHQL_QUERY = exports.STATIC_METADATA_KEY = exports.SSE_SERVICE_KEY = exports.SSE_TOPIC_KEY = exports.SSE_METADATA_KEY = exports.CORS_METADATA = exports.INCREMENT_STATISTIC = exports.STATISTIC = exports.TO_VALIDATE = exports.OK_STATUSES = exports.STOPPED = exports.SANITIZE = exports.CATCH = exports.INTECEPT = exports.WS_SERVICE_KEY = exports.WS_TOPIC_KEY = exports.WS_HANDLER = exports.USE_MIDDLEWARE = exports.SERVER_CONFIG_KEY = exports.OK_METADATA_KEY = exports.ENDPOINT = exports.INTERCEPTOR = exports.CONTROLLERS = exports.MIDDLEWARES = exports.ROUTE_MIDDLEWARES = exports.ROUTE_PREFIX = exports.APP_METADATA_KEY = exports.PARAM_METADATA_KEY = void 0;
|
|
4
4
|
exports.PARAM_METADATA_KEY = 'design:parameters';
|
|
5
5
|
exports.APP_METADATA_KEY = 'app:configuration';
|
|
6
6
|
exports.ROUTE_PREFIX = 'route:prefix';
|
|
@@ -39,4 +39,12 @@ exports.SSE_METADATA_KEY = 'sse:handlers';
|
|
|
39
39
|
exports.SSE_TOPIC_KEY = 'sse:topics';
|
|
40
40
|
exports.SSE_SERVICE_KEY = 'sse:service';
|
|
41
41
|
exports.STATIC_METADATA_KEY = 'static:config';
|
|
42
|
+
exports.GRAPHQL_QUERY = 'graphql:query';
|
|
43
|
+
exports.GRAPHQL_MUTATION = 'graphql:mutation';
|
|
44
|
+
exports.GRAPHQL_SUBSCRIPTION = 'graphql:subscription';
|
|
45
|
+
exports.GRAPHQL_TYPE = 'graphql:type';
|
|
46
|
+
exports.GRAPHQL_INPUT_TYPE = 'graphql:inputType';
|
|
47
|
+
exports.GRAPHQL_FIELD = 'graphql:field';
|
|
48
|
+
exports.GRAPHQL_ARG = 'graphql:arg';
|
|
49
|
+
exports.GRAPHQL_RESOLVER = 'graphql:resolver';
|
|
42
50
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AACzC,QAAA,gBAAgB,GAAG,mBAAmB,CAAC;AACvC,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,WAAW,GAAG,wBAAwB,CAAC;AACvC,QAAA,WAAW,GAAG,iBAAiB,CAAC;AAChC,QAAA,WA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,QAAA,aAAa,GAAG,aAAa,CAAC;AAC9B,QAAA,gBAAgB,GAAG,cAAc,CAAC;AAClC,QAAA,aAAa,GAAG,YAAY,CAAC;AAC7B,QAAA,eAAe,GAAG,aAAa,CAAC;AAChC,QAAA,mBAAmB,GAAG,eAAe,CAAC;AACtC,QAAA,aAAa,GAAG,eAAe,CAAC;AAChC,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AACzC,QAAA,aAAa,GAAG,eAAe,CAAC;AAChC,QAAA,WAAW,GAAG,aAAa,CAAC;AAC5B,QAAA,gBAAgB,GAAG,kBAAkB,CAAC"}
|
package/dist/core/Controller.js
CHANGED
|
@@ -110,7 +110,7 @@ function Controller(config, middlewares = []) {
|
|
|
110
110
|
.filter(Boolean)
|
|
111
111
|
.join('/')
|
|
112
112
|
.replace(/\/+/g, '/');
|
|
113
|
-
if (
|
|
113
|
+
if ((0, _utils_1.pathStartsWithPrefix)(path, fullSubPath)) {
|
|
114
114
|
const walkerData = {
|
|
115
115
|
...context,
|
|
116
116
|
subPath: fullSubPath,
|
|
@@ -137,7 +137,9 @@ function Controller(config, middlewares = []) {
|
|
|
137
137
|
const handledCors = context.corsChain
|
|
138
138
|
.concat(cors ?? [])
|
|
139
139
|
.flat()
|
|
140
|
+
.filter((el) => !!el)
|
|
140
141
|
.reduce((acc, conf) => {
|
|
142
|
+
console.log(conf);
|
|
141
143
|
const cors = (0, _utils_1.handleCORS)(request, response, conf);
|
|
142
144
|
return {
|
|
143
145
|
permitted: acc.permitted && cors.permitted,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Controller.js","sourceRoot":"","sources":["../../src/core/Controller.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Controller.js","sourceRoot":"","sources":["../../src/core/Controller.ts"],"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7B,GAAG,CAAC;oBACJ,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iBAC9B,CAAC,CAAC,CAAC;YACN,CAAC;YAED,aAAa,GAAG,CAAC,QAAe,EAAE,IAAY,EAAE,EAAE;gBAChD,OAAO,QAAQ;qBACZ,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;qBACnC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;oBAChB,GAAG,CAAC;oBACJ,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iBAC9B,CAAC,CAAC,CAAC;YACR,CAAC,CAAC;SACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/core/Endpoint.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { HTTP_METHODS, MiddlewareCB } from '../types/index.js';
|
|
|
7
7
|
*
|
|
8
8
|
* It also allows attaching middlewares that will be applied when the endpoint is accessed.
|
|
9
9
|
*
|
|
10
|
-
* @param method - The HTTP method (e.g., 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', '
|
|
10
|
+
* @param method - The HTTP method (e.g., 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ANY').
|
|
11
11
|
* @param pathPattern - Optional route pattern string to match the endpoint path.
|
|
12
12
|
* @param middlewares - Optional array of middlewares to apply to this endpoint.
|
|
13
13
|
*
|
|
@@ -70,4 +70,4 @@ export declare const OPTIONS: (pathPattern?: string, middlewares?: MiddlewareCB[
|
|
|
70
70
|
* @returns Method decorator for DELETE endpoint.
|
|
71
71
|
*/
|
|
72
72
|
export declare const HEAD: (pathPattern?: string, middlewares?: MiddlewareCB[]) => (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
73
|
-
export declare function
|
|
73
|
+
export declare function ANY(middlewares?: MiddlewareCB[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
package/dist/core/Endpoint.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HEAD = exports.OPTIONS = exports.DELETE = exports.PATCH = exports.PUT = exports.POST = exports.GET = void 0;
|
|
4
4
|
exports.Endpoint = Endpoint;
|
|
5
|
-
exports.
|
|
5
|
+
exports.ANY = ANY;
|
|
6
6
|
const _constants_1 = require("../constants.js");
|
|
7
7
|
const _types_1 = require("../types/index.js");
|
|
8
8
|
/**
|
|
@@ -13,7 +13,7 @@ const _types_1 = require("../types/index.js");
|
|
|
13
13
|
*
|
|
14
14
|
* It also allows attaching middlewares that will be applied when the endpoint is accessed.
|
|
15
15
|
*
|
|
16
|
-
* @param method - The HTTP method (e.g., 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', '
|
|
16
|
+
* @param method - The HTTP method (e.g., 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'ANY').
|
|
17
17
|
* @param pathPattern - Optional route pattern string to match the endpoint path.
|
|
18
18
|
* @param middlewares - Optional array of middlewares to apply to this endpoint.
|
|
19
19
|
*
|
|
@@ -117,9 +117,9 @@ exports.HEAD = HEAD;
|
|
|
117
117
|
// * @param middlewares - Optional array of middlewares.
|
|
118
118
|
// * @returns Method decorator for middleware usage.
|
|
119
119
|
// */
|
|
120
|
-
function
|
|
120
|
+
function ANY(middlewares) {
|
|
121
121
|
return function (target, propertyKey, descriptor) {
|
|
122
|
-
Reflect.defineMetadata(_constants_1.ENDPOINT, ['
|
|
122
|
+
Reflect.defineMetadata(_constants_1.ENDPOINT, ['ANY', '/'], target, propertyKey);
|
|
123
123
|
Reflect.defineMetadata(_constants_1.MIDDLEWARES, middlewares || [], target, propertyKey);
|
|
124
124
|
(0, _constants_1.INCREMENT_STATISTIC)('routes');
|
|
125
125
|
return descriptor;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { ArgOptions, GraphQLType, QueryMetadata } from '../types/index.js';
|
|
3
|
+
export interface MutationMetadata extends QueryMetadata {
|
|
4
|
+
}
|
|
5
|
+
export interface SubscriptionMetadata extends QueryMetadata {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Class decorator to mark a class as a GraphQL ObjectType.
|
|
9
|
+
* @param {string} [name] - Optional name of the GraphQL ObjectType. Defaults to the class name.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ObjectType(name?: string): ClassDecorator;
|
|
12
|
+
/**
|
|
13
|
+
* Class decorator to mark a class as a GraphQL InputType.
|
|
14
|
+
* @param {string} [name] - Optional name of the GraphQL InputType. Defaults to the class name.
|
|
15
|
+
*/
|
|
16
|
+
export declare function InputType(name?: string): ClassDecorator;
|
|
17
|
+
/**
|
|
18
|
+
* Property decorator to mark a class property as a GraphQL Field.
|
|
19
|
+
* @param {GraphQLType | (() => GraphQLType) | { nullable: true }} [type] - The GraphQL type or a function returning the type. Can specify nullable.
|
|
20
|
+
*/
|
|
21
|
+
export declare function Field(type?: GraphQLType | (() => GraphQLType) | {
|
|
22
|
+
nullable: true;
|
|
23
|
+
}): PropertyDecorator;
|
|
24
|
+
/**
|
|
25
|
+
* Parameter decorator to define a GraphQL argument.
|
|
26
|
+
* @param {string} [name] - Name of the argument.
|
|
27
|
+
* @param {GraphQLType} [type] - GraphQL type of the argument.
|
|
28
|
+
* @param {ArgOptions} [options] - Additional options like required, description, defaultValue.
|
|
29
|
+
*/
|
|
30
|
+
export declare function Arg(name?: string, type?: GraphQLType, options?: ArgOptions): ParameterDecorator;
|
|
31
|
+
/**
|
|
32
|
+
* Method decorator to mark a method as a GraphQL Query.
|
|
33
|
+
* @param {GraphQLType | (() => GraphQLType)} [returnType] - Return type of the query.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Query(returnType?: GraphQLType | (() => GraphQLType)): MethodDecorator;
|
|
36
|
+
/**
|
|
37
|
+
* Method decorator to mark a method as a GraphQL Mutation.
|
|
38
|
+
* @param {GraphQLType | (() => GraphQLType)} [returnType] - Return type of the mutation.
|
|
39
|
+
*/
|
|
40
|
+
export declare function Mutation(returnType?: GraphQLType | (() => GraphQLType)): MethodDecorator;
|
|
41
|
+
/**
|
|
42
|
+
* Method decorator to mark a method as a GraphQL Subscription.
|
|
43
|
+
* @param {GraphQLType | (() => GraphQLType)} [returnType] - Return type of the subscription.
|
|
44
|
+
*/
|
|
45
|
+
export declare function Subscription(returnType?: GraphQLType | (() => GraphQLType)): MethodDecorator;
|
|
46
|
+
/**
|
|
47
|
+
* Class decorator to mark a class as a GraphQL Resolver.
|
|
48
|
+
*/
|
|
49
|
+
export declare function Resolver(): ClassDecorator;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectType = ObjectType;
|
|
4
|
+
exports.InputType = InputType;
|
|
5
|
+
exports.Field = Field;
|
|
6
|
+
exports.Arg = Arg;
|
|
7
|
+
exports.Query = Query;
|
|
8
|
+
exports.Mutation = Mutation;
|
|
9
|
+
exports.Subscription = Subscription;
|
|
10
|
+
exports.Resolver = Resolver;
|
|
11
|
+
const _constants_1 = require("../constants.js");
|
|
12
|
+
require("reflect-metadata");
|
|
13
|
+
/**
|
|
14
|
+
* Class decorator to mark a class as a GraphQL ObjectType.
|
|
15
|
+
* @param {string} [name] - Optional name of the GraphQL ObjectType. Defaults to the class name.
|
|
16
|
+
*/
|
|
17
|
+
function ObjectType(name) {
|
|
18
|
+
return function (target) {
|
|
19
|
+
Reflect.defineMetadata(_constants_1.GRAPHQL_TYPE, { name: name || target.name }, target);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Class decorator to mark a class as a GraphQL InputType.
|
|
24
|
+
* @param {string} [name] - Optional name of the GraphQL InputType. Defaults to the class name.
|
|
25
|
+
*/
|
|
26
|
+
function InputType(name) {
|
|
27
|
+
return function (target) {
|
|
28
|
+
Reflect.defineMetadata(_constants_1.GRAPHQL_INPUT_TYPE, { name: name || target.name }, target);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Property decorator to mark a class property as a GraphQL Field.
|
|
33
|
+
* @param {GraphQLType | (() => GraphQLType) | { nullable: true }} [type] - The GraphQL type or a function returning the type. Can specify nullable.
|
|
34
|
+
*/
|
|
35
|
+
function Field(type) {
|
|
36
|
+
return function (target, propertyKey) {
|
|
37
|
+
const fields = Reflect.getMetadata(_constants_1.GRAPHQL_FIELD, target) || [];
|
|
38
|
+
fields.push({ propertyKey: propertyKey, type });
|
|
39
|
+
Reflect.defineMetadata(_constants_1.GRAPHQL_FIELD, fields, target);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parameter decorator to define a GraphQL argument.
|
|
44
|
+
* @param {string} [name] - Name of the argument.
|
|
45
|
+
* @param {GraphQLType} [type] - GraphQL type of the argument.
|
|
46
|
+
* @param {ArgOptions} [options] - Additional options like required, description, defaultValue.
|
|
47
|
+
*/
|
|
48
|
+
function Arg(name, type, options) {
|
|
49
|
+
return function (target, propertyKey, parameterIndex) {
|
|
50
|
+
if (propertyKey === undefined) {
|
|
51
|
+
throw new Error('@Arg decorator must be used on a method parameter');
|
|
52
|
+
}
|
|
53
|
+
const args = Reflect.getMetadata(_constants_1.GRAPHQL_ARG, target, propertyKey) || [];
|
|
54
|
+
args.push({
|
|
55
|
+
index: parameterIndex,
|
|
56
|
+
name: name || `arg${parameterIndex}`,
|
|
57
|
+
type: type || String,
|
|
58
|
+
required: options?.required || false,
|
|
59
|
+
description: options?.description,
|
|
60
|
+
defaultValue: options?.defaultValue,
|
|
61
|
+
});
|
|
62
|
+
Reflect.defineMetadata(_constants_1.GRAPHQL_ARG, args, target, propertyKey);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Method decorator to mark a method as a GraphQL Query.
|
|
67
|
+
* @param {GraphQLType | (() => GraphQLType)} [returnType] - Return type of the query.
|
|
68
|
+
*/
|
|
69
|
+
function Query(returnType) {
|
|
70
|
+
return function (target, propertyKey, descriptor) {
|
|
71
|
+
Reflect.defineMetadata(_constants_1.GRAPHQL_QUERY, { type: returnType, method: propertyKey }, target, propertyKey);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Method decorator to mark a method as a GraphQL Mutation.
|
|
76
|
+
* @param {GraphQLType | (() => GraphQLType)} [returnType] - Return type of the mutation.
|
|
77
|
+
*/
|
|
78
|
+
function Mutation(returnType) {
|
|
79
|
+
return function (target, propertyKey, descriptor) {
|
|
80
|
+
Reflect.defineMetadata(_constants_1.GRAPHQL_MUTATION, { type: returnType, method: propertyKey }, target, propertyKey);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Method decorator to mark a method as a GraphQL Subscription.
|
|
85
|
+
* @param {GraphQLType | (() => GraphQLType)} [returnType] - Return type of the subscription.
|
|
86
|
+
*/
|
|
87
|
+
function Subscription(returnType) {
|
|
88
|
+
return function (target, propertyKey, descriptor) {
|
|
89
|
+
Reflect.defineMetadata(_constants_1.GRAPHQL_SUBSCRIPTION, { type: returnType, method: propertyKey }, target, propertyKey);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Class decorator to mark a class as a GraphQL Resolver.
|
|
94
|
+
*/
|
|
95
|
+
function Resolver() {
|
|
96
|
+
return function (target) {
|
|
97
|
+
Reflect.defineMetadata(_constants_1.GRAPHQL_RESOLVER, true, target);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/graphql/decorators.ts"],"names":[],"mappings":";;AA4BA,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,SAAgB,QAAQ;IACtB,OAAO,UAAU,MAAW;QAC1B,OAAO,CAAC,cAAc,CAAC,6BAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./decorators"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,+CAA6B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
export declare class GraphQLModule {
|
|
3
|
+
private controllers;
|
|
4
|
+
private schema;
|
|
5
|
+
private typeCache;
|
|
6
|
+
private inputTypeCache;
|
|
7
|
+
private typeMap;
|
|
8
|
+
constructor(controllers: any[]);
|
|
9
|
+
private buildSchema;
|
|
10
|
+
private convertToGraphQLType;
|
|
11
|
+
private createFieldConfig;
|
|
12
|
+
private getOrCreateObjectType;
|
|
13
|
+
private getOrCreateInputObjectType;
|
|
14
|
+
getSchema(): GraphQLSchema;
|
|
15
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphQLModule = void 0;
|
|
4
|
+
const _constants_1 = require("../constants.js");
|
|
5
|
+
const _utils_1 = require("../utils/index.js");
|
|
6
|
+
const graphql_1 = require("graphql");
|
|
7
|
+
class GraphQLModule {
|
|
8
|
+
controllers;
|
|
9
|
+
schema;
|
|
10
|
+
typeCache = new Map();
|
|
11
|
+
inputTypeCache = new Map();
|
|
12
|
+
typeMap = {
|
|
13
|
+
String: graphql_1.GraphQLString,
|
|
14
|
+
Number: graphql_1.GraphQLFloat,
|
|
15
|
+
Boolean: graphql_1.GraphQLBoolean,
|
|
16
|
+
Date: graphql_1.GraphQLString,
|
|
17
|
+
string: graphql_1.GraphQLString,
|
|
18
|
+
number: graphql_1.GraphQLFloat,
|
|
19
|
+
boolean: graphql_1.GraphQLBoolean,
|
|
20
|
+
int: graphql_1.GraphQLInt,
|
|
21
|
+
float: graphql_1.GraphQLFloat,
|
|
22
|
+
id: graphql_1.GraphQLID,
|
|
23
|
+
GraphQLString: graphql_1.GraphQLString,
|
|
24
|
+
GraphQLInt: graphql_1.GraphQLInt,
|
|
25
|
+
GraphQLFloat: graphql_1.GraphQLFloat,
|
|
26
|
+
GraphQLBoolean: graphql_1.GraphQLBoolean,
|
|
27
|
+
GraphQLID: graphql_1.GraphQLID,
|
|
28
|
+
};
|
|
29
|
+
constructor(controllers) {
|
|
30
|
+
this.controllers = controllers;
|
|
31
|
+
this.schema = this.buildSchema();
|
|
32
|
+
}
|
|
33
|
+
buildSchema() {
|
|
34
|
+
const queryFields = {};
|
|
35
|
+
const mutationFields = {};
|
|
36
|
+
const subscriptionFields = {};
|
|
37
|
+
let hasQueries = false;
|
|
38
|
+
let hasMutations = false;
|
|
39
|
+
for (const controller of this.controllers) {
|
|
40
|
+
const prototype = Object.getPrototypeOf(controller.constructor.prototype);
|
|
41
|
+
const methods = Object.getOwnPropertyNames(prototype).filter((m) => m !== 'constructor');
|
|
42
|
+
for (const methodName of methods) {
|
|
43
|
+
const queryMeta = Reflect.getMetadata(_constants_1.GRAPHQL_QUERY, prototype, methodName);
|
|
44
|
+
if (queryMeta) {
|
|
45
|
+
queryFields[methodName] = this.createFieldConfig(controller, prototype, methodName, queryMeta);
|
|
46
|
+
hasQueries = true;
|
|
47
|
+
}
|
|
48
|
+
const mutationMeta = Reflect.getMetadata(_constants_1.GRAPHQL_MUTATION, prototype, methodName);
|
|
49
|
+
if (mutationMeta) {
|
|
50
|
+
mutationFields[methodName] = this.createFieldConfig(controller, prototype, methodName, mutationMeta);
|
|
51
|
+
hasMutations = true;
|
|
52
|
+
}
|
|
53
|
+
const subMeta = Reflect.getMetadata(_constants_1.GRAPHQL_SUBSCRIPTION, prototype, methodName);
|
|
54
|
+
if (subMeta) {
|
|
55
|
+
subscriptionFields[methodName] = this.createFieldConfig(controller, prototype, methodName, subMeta);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!hasQueries) {
|
|
60
|
+
queryFields['_test'] = {
|
|
61
|
+
type: graphql_1.GraphQLString,
|
|
62
|
+
resolve: () => 'GraphQL is working!',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return new graphql_1.GraphQLSchema({
|
|
66
|
+
query: new graphql_1.GraphQLObjectType({
|
|
67
|
+
name: 'Query',
|
|
68
|
+
fields: queryFields,
|
|
69
|
+
}),
|
|
70
|
+
mutation: hasMutations
|
|
71
|
+
? new graphql_1.GraphQLObjectType({ name: 'Mutation', fields: mutationFields })
|
|
72
|
+
: undefined,
|
|
73
|
+
subscription: Object.keys(subscriptionFields).length > 0
|
|
74
|
+
? new graphql_1.GraphQLObjectType({ name: 'Subscription', fields: subscriptionFields })
|
|
75
|
+
: undefined,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
convertToGraphQLType(type, isInput = false) {
|
|
79
|
+
if (!type)
|
|
80
|
+
return graphql_1.GraphQLString;
|
|
81
|
+
if (Array.isArray(type)) {
|
|
82
|
+
const innerType = this.convertToGraphQLType(type[0], isInput);
|
|
83
|
+
return new graphql_1.GraphQLList(innerType);
|
|
84
|
+
}
|
|
85
|
+
if (typeof type === 'function') {
|
|
86
|
+
if (type === String)
|
|
87
|
+
return graphql_1.GraphQLString;
|
|
88
|
+
if (type === Number)
|
|
89
|
+
return graphql_1.GraphQLFloat;
|
|
90
|
+
if (type === Boolean)
|
|
91
|
+
return graphql_1.GraphQLBoolean;
|
|
92
|
+
if (type === Date)
|
|
93
|
+
return graphql_1.GraphQLString;
|
|
94
|
+
const hasInputType = Reflect.hasMetadata(_constants_1.GRAPHQL_INPUT_TYPE, type);
|
|
95
|
+
const hasObjectType = Reflect.hasMetadata(_constants_1.GRAPHQL_TYPE, type);
|
|
96
|
+
if (isInput || hasInputType) {
|
|
97
|
+
if (hasInputType) {
|
|
98
|
+
return this.getOrCreateInputObjectType(type);
|
|
99
|
+
}
|
|
100
|
+
return graphql_1.GraphQLString;
|
|
101
|
+
}
|
|
102
|
+
if (hasObjectType) {
|
|
103
|
+
return this.getOrCreateObjectType(type);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (typeof type === 'string' && this.typeMap[type]) {
|
|
107
|
+
return this.typeMap[type];
|
|
108
|
+
}
|
|
109
|
+
return graphql_1.GraphQLString;
|
|
110
|
+
}
|
|
111
|
+
createFieldConfig(controller, prototype, methodName, meta) {
|
|
112
|
+
const argMetas = Reflect.getMetadata(_constants_1.GRAPHQL_ARG, prototype, methodName) || [];
|
|
113
|
+
argMetas.sort((a, b) => a.index - b.index);
|
|
114
|
+
const args = {};
|
|
115
|
+
for (const arg of argMetas) {
|
|
116
|
+
const argType = this.convertToGraphQLType(arg.type, true);
|
|
117
|
+
args[arg.name] = {
|
|
118
|
+
type: arg.required ? new graphql_1.GraphQLNonNull(argType) : argType,
|
|
119
|
+
description: arg.description,
|
|
120
|
+
defaultValue: arg.defaultValue,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const returnType = this.convertToGraphQLType(meta.type);
|
|
124
|
+
return {
|
|
125
|
+
type: returnType,
|
|
126
|
+
args: args,
|
|
127
|
+
resolve: async (source, args, context, info) => {
|
|
128
|
+
try {
|
|
129
|
+
const methodArgs = argMetas.map((arg) => args[arg.name]);
|
|
130
|
+
return await controller[methodName](...methodArgs, context);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
console.error(`❌ Error in GraphQL resolver ${methodName}:`, error);
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
getOrCreateObjectType(cls) {
|
|
140
|
+
if (this.typeCache.has(cls)) {
|
|
141
|
+
return this.typeCache.get(cls);
|
|
142
|
+
}
|
|
143
|
+
const typeMeta = Reflect.getMetadata(_constants_1.GRAPHQL_TYPE, cls) || { name: cls.name };
|
|
144
|
+
const fieldsMeta = Reflect.getMetadata(_constants_1.GRAPHQL_FIELD, cls.prototype) || [];
|
|
145
|
+
const fields = {};
|
|
146
|
+
for (const field of fieldsMeta) {
|
|
147
|
+
if (typeof field.type === 'function' && !(0, _utils_1.isClass)(field.type)) {
|
|
148
|
+
field.type = field.type();
|
|
149
|
+
}
|
|
150
|
+
const convertedType = this.convertToGraphQLType(field.type);
|
|
151
|
+
fields[field.propertyKey] = {
|
|
152
|
+
type: convertedType,
|
|
153
|
+
resolve: (obj) => {
|
|
154
|
+
const value = obj[field.propertyKey];
|
|
155
|
+
return value;
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const objectType = new graphql_1.GraphQLObjectType({
|
|
160
|
+
name: typeMeta.name,
|
|
161
|
+
fields: fields,
|
|
162
|
+
});
|
|
163
|
+
this.typeCache.set(cls, objectType);
|
|
164
|
+
return objectType;
|
|
165
|
+
}
|
|
166
|
+
getOrCreateInputObjectType(cls) {
|
|
167
|
+
if (this.inputTypeCache.has(cls)) {
|
|
168
|
+
return this.inputTypeCache.get(cls);
|
|
169
|
+
}
|
|
170
|
+
const typeMeta = Reflect.getMetadata(_constants_1.GRAPHQL_INPUT_TYPE, cls) || { name: `${cls.name}Input` };
|
|
171
|
+
const fieldsMeta = Reflect.getMetadata(_constants_1.GRAPHQL_FIELD, cls.prototype) || [];
|
|
172
|
+
const fields = {};
|
|
173
|
+
for (const field of fieldsMeta) {
|
|
174
|
+
fields[field.propertyKey] = {
|
|
175
|
+
type: this.convertToGraphQLType(field.type, true),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const inputType = new graphql_1.GraphQLInputObjectType({
|
|
179
|
+
name: typeMeta.name,
|
|
180
|
+
fields: fields,
|
|
181
|
+
});
|
|
182
|
+
this.inputTypeCache.set(cls, inputType);
|
|
183
|
+
return inputType;
|
|
184
|
+
}
|
|
185
|
+
getSchema() {
|
|
186
|
+
return this.schema;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.GraphQLModule = GraphQLModule;
|
|
190
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/graphql/module.ts"],"names":[],"mappings":";;;AAAA,2CAQoB;AACpB,mCAAiC;AACjC,qCAWiB;AAEjB,MAAa,aAAa;IAuBJ;IAtBZ,MAAM,CAAgB;IACtB,SAAS,GAAgC,IAAI,GAAG,EAAE,CAAC;IACnD,cAAc,GAAqC,IAAI,GAAG,EAAE,CAAC;IAE7D,OAAO,GAAwB;QACrC,MAAM,EAAE,uBAAa;QACrB,MAAM,EAAE,sBAAY;QACpB,OAAO,EAAE,wBAAc;QACvB,IAAI,EAAE,uBAAa;QACnB,MAAM,EAAE,uBAAa;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-0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws.js","sourceRoot":"","sources":["../../src/plugins/aws.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HttpPlugin as Plugin } from '../types/index.js';
|