@midwayjs/faas 3.7.2-beta.1 → 3.8.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/LICENSE +21 -0
- package/dist/framework.d.ts +1 -1
- package/dist/framework.js +29 -10
- package/dist/interface.d.ts +4 -4
- package/package.json +5 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 - Now midwayjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/framework.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare class MidwayFaaSFramework extends BaseFramework<Application, Cont
|
|
|
32
32
|
* @param handlerMapping
|
|
33
33
|
*/
|
|
34
34
|
handleInvokeWrapper(handlerMapping: string): (...args: any[]) => Promise<any>;
|
|
35
|
-
|
|
35
|
+
invokeTriggerFunction(context: any, handlerMapping: string, options: HandlerOptions): Promise<any>;
|
|
36
36
|
wrapHttpRequest(req: http.IncomingMessage | Record<string, any>, res?: http.ServerResponse): Promise<unknown>;
|
|
37
37
|
/**
|
|
38
38
|
* @deprecated
|
package/dist/framework.js
CHANGED
|
@@ -92,16 +92,35 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
92
92
|
getEventMiddleware: () => {
|
|
93
93
|
return this.getEventMiddleware();
|
|
94
94
|
},
|
|
95
|
-
getServerlessInstance: (serviceClass) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
getServerlessInstance: async (serviceClass, customContext = {}) => {
|
|
96
|
+
const instance = new Proxy({}, {
|
|
97
|
+
get: (target, prop) => {
|
|
98
|
+
let funcInfo;
|
|
99
|
+
if (typeof serviceClass === 'string') {
|
|
100
|
+
funcInfo = this.funMappingStore.get(`${serviceClass}.${prop}`);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
funcInfo = Array.from(this.funMappingStore.values()).find(item => {
|
|
104
|
+
return (item.id === (0, core_1.getProviderUUId)(serviceClass) &&
|
|
105
|
+
item.method === prop);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (funcInfo) {
|
|
109
|
+
return async (...args) => {
|
|
110
|
+
const context = this.app.createAnonymousContext();
|
|
111
|
+
return this.invokeTriggerFunction(context, funcInfo.funcHandlerName, {
|
|
112
|
+
isHttpFunction: false,
|
|
113
|
+
originContext: customContext,
|
|
114
|
+
originEvent: args[0],
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
return instance;
|
|
102
121
|
},
|
|
103
|
-
|
|
104
|
-
return this.
|
|
122
|
+
invokeTriggerFunction: (context, handlerMapping, options) => {
|
|
123
|
+
return this.invokeTriggerFunction(context, handlerMapping, options);
|
|
105
124
|
},
|
|
106
125
|
});
|
|
107
126
|
// hack use method
|
|
@@ -195,7 +214,7 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
195
214
|
return await composeMiddleware(context);
|
|
196
215
|
};
|
|
197
216
|
}
|
|
198
|
-
async
|
|
217
|
+
async invokeTriggerFunction(context, handlerMapping, options) {
|
|
199
218
|
var _a, _b;
|
|
200
219
|
let funOptions = this.funMappingStore.get(handlerMapping);
|
|
201
220
|
const isHttpFunction = options.isHttpFunction;
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MidwayRequestContainer, IMidwayApplication, IConfigurationOptions, IMidwayContext, NextFunction as BaseNextFunction, CommonMiddlewareUnion, ContextMiddlewareManager, IMidwayBootstrapOptions } from '@midwayjs/core';
|
|
1
|
+
import { MidwayRequestContainer, IMidwayApplication, IConfigurationOptions, IMidwayContext, NextFunction as BaseNextFunction, CommonMiddlewareUnion, ContextMiddlewareManager, IMidwayBootstrapOptions, ObjectIdentifier } from '@midwayjs/core';
|
|
2
2
|
import { FaaSHTTPContext } from '@midwayjs/faas-typings';
|
|
3
3
|
import { ILogger } from '@midwayjs/logger';
|
|
4
4
|
import { Application as ServerlessHttpApplication } from '@midwayjs/serverless-http-parser';
|
|
@@ -35,10 +35,10 @@ export declare type IMidwayFaaSApplication = IMidwayApplication<Context, {
|
|
|
35
35
|
getFunctionServiceName(): string;
|
|
36
36
|
useEventMiddleware(middleware: CommonMiddlewareUnion<Context, NextFunction, undefined>): void;
|
|
37
37
|
getEventMiddleware(): ContextMiddlewareManager<Context, NextFunction, undefined>;
|
|
38
|
-
|
|
39
|
-
getServerlessInstance<T>(serviceClass: {
|
|
38
|
+
invokeTriggerFunction(context: any, handler: string, options: HandlerOptions): Promise<any>;
|
|
39
|
+
getServerlessInstance<T>(serviceClass: ObjectIdentifier | {
|
|
40
40
|
new (...args: any[]): T;
|
|
41
|
-
}): Promise<T>;
|
|
41
|
+
}, customContext?: any): Promise<T>;
|
|
42
42
|
}> & ServerlessHttpApplication;
|
|
43
43
|
export interface Application extends IMidwayFaaSApplication {
|
|
44
44
|
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/faas",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@midwayjs/core": "^3.
|
|
7
|
+
"@midwayjs/core": "^3.8.0",
|
|
8
8
|
"@midwayjs/faas-typings": "^3.6.0",
|
|
9
9
|
"@midwayjs/logger": "^2.15.0",
|
|
10
10
|
"@midwayjs/serverless-http-parser": "^3.6.0",
|
|
11
11
|
"@midwayjs/simple-lock": "^1.1.4"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@midwayjs/mock": "^3.
|
|
15
|
-
"@midwayjs/serverless-fc-starter": "^3.
|
|
14
|
+
"@midwayjs/mock": "^3.8.0",
|
|
15
|
+
"@midwayjs/serverless-fc-starter": "^3.8.0",
|
|
16
16
|
"@midwayjs/serverless-scf-starter": "^3.7.0",
|
|
17
17
|
"mm": "3.2.0"
|
|
18
18
|
},
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"url": "git@github.com:midwayjs/midway.git"
|
|
46
46
|
},
|
|
47
47
|
"license": "MIT",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "5c640c7182923587139f9f9c0aecf50585798e1e"
|
|
49
49
|
}
|