@midwayjs/faas 3.12.3 → 3.12.5
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/interface.d.ts +370 -1
- package/index.d.ts +372 -1
- package/package.json +6 -7
package/dist/interface.d.ts
CHANGED
|
@@ -1,7 +1,375 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { MidwayRequestContainer, IMidwayApplication, IConfigurationOptions, IMidwayContext, NextFunction as BaseNextFunction, CommonMiddlewareUnion, ContextMiddlewareManager, IMidwayBootstrapOptions, ObjectIdentifier } from '@midwayjs/core';
|
|
2
|
-
import { FaaSHTTPContext } from '@midwayjs/faas-typings';
|
|
3
3
|
import { ILogger } from '@midwayjs/logger';
|
|
4
4
|
import { Application as ServerlessHttpApplication, HttpResponseOptions } from '@midwayjs/serverless-http-parser';
|
|
5
|
+
import { Cookies } from '@midwayjs/cookies';
|
|
6
|
+
import { Writable } from 'stream';
|
|
7
|
+
interface ContextDelegatedRequest {
|
|
8
|
+
/**
|
|
9
|
+
* Check if the given `type(s)` is acceptable, returning
|
|
10
|
+
* the best match when true, otherwise `undefined`, in which
|
|
11
|
+
* case you should respond with 406 "Not Acceptable".
|
|
12
|
+
*
|
|
13
|
+
* The `type` value may be a single mime type string
|
|
14
|
+
* such as "application/json", the extension name
|
|
15
|
+
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
|
16
|
+
* or array is given the _best_ match, if any is returned.
|
|
17
|
+
*
|
|
18
|
+
* Examples:
|
|
19
|
+
*
|
|
20
|
+
* // Accept: text/html
|
|
21
|
+
* this.accepts('html');
|
|
22
|
+
* // => "html"
|
|
23
|
+
*
|
|
24
|
+
* // Accept: text/*, application/json
|
|
25
|
+
* this.accepts('html');
|
|
26
|
+
* // => "html"
|
|
27
|
+
* this.accepts('text/html');
|
|
28
|
+
* // => "text/html"
|
|
29
|
+
* this.accepts('json', 'text');
|
|
30
|
+
* // => "json"
|
|
31
|
+
* this.accepts('application/json');
|
|
32
|
+
* // => "application/json"
|
|
33
|
+
*
|
|
34
|
+
* // Accept: text/*, application/json
|
|
35
|
+
* this.accepts('image/png');
|
|
36
|
+
* this.accepts('png');
|
|
37
|
+
* // => undefined
|
|
38
|
+
*
|
|
39
|
+
* // Accept: text/*;q=.5, application/json
|
|
40
|
+
* this.accepts(['html', 'json']);
|
|
41
|
+
* this.accepts('html', 'json');
|
|
42
|
+
* // => "json"
|
|
43
|
+
*/
|
|
44
|
+
accepts(): string[] | boolean;
|
|
45
|
+
accepts(...types: string[]): string | boolean;
|
|
46
|
+
accepts(types: string[]): string | boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Return accepted encodings or best fit based on `encodings`.
|
|
49
|
+
*
|
|
50
|
+
* Given `Accept-Encoding: gzip, deflate`
|
|
51
|
+
* an array sorted by quality is returned:
|
|
52
|
+
*
|
|
53
|
+
* ['gzip', 'deflate']
|
|
54
|
+
*/
|
|
55
|
+
acceptsEncodings(): string[] | boolean;
|
|
56
|
+
acceptsEncodings(...encodings: string[]): string | boolean;
|
|
57
|
+
acceptsEncodings(encodings: string[]): string | boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Return accepted charsets or best fit based on `charsets`.
|
|
60
|
+
*
|
|
61
|
+
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
|
62
|
+
* an array sorted by quality is returned:
|
|
63
|
+
*
|
|
64
|
+
* ['utf-8', 'utf-7', 'iso-8859-1']
|
|
65
|
+
*/
|
|
66
|
+
acceptsCharsets(): string[] | boolean;
|
|
67
|
+
acceptsCharsets(...charsets: string[]): string | boolean;
|
|
68
|
+
acceptsCharsets(charsets: string[]): string | boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Return accepted languages or best fit based on `langs`.
|
|
71
|
+
*
|
|
72
|
+
* Given `Accept-Language: en;q=0.8, es, pt`
|
|
73
|
+
* an array sorted by quality is returned:
|
|
74
|
+
*
|
|
75
|
+
* ['es', 'pt', 'en']
|
|
76
|
+
*/
|
|
77
|
+
acceptsLanguages(): string[] | boolean;
|
|
78
|
+
acceptsLanguages(...langs: string[]): string | boolean;
|
|
79
|
+
acceptsLanguages(langs: string[]): string | boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Check if the incoming request contains the "Content-Type"
|
|
82
|
+
* header field, and it contains any of the give mime `type`s.
|
|
83
|
+
* If there is no request body, `null` is returned.
|
|
84
|
+
* If there is no content type, `false` is returned.
|
|
85
|
+
* Otherwise, it returns the first `type` that matches.
|
|
86
|
+
*
|
|
87
|
+
* Examples:
|
|
88
|
+
*
|
|
89
|
+
* // With Content-Type: text/html; charset=utf-8
|
|
90
|
+
* this.is('html'); // => 'html'
|
|
91
|
+
* this.is('text/html'); // => 'text/html'
|
|
92
|
+
* this.is('text/*', 'application/json'); // => 'text/html'
|
|
93
|
+
*
|
|
94
|
+
* // When Content-Type is application/json
|
|
95
|
+
* this.is('json', 'urlencoded'); // => 'json'
|
|
96
|
+
* this.is('application/json'); // => 'application/json'
|
|
97
|
+
* this.is('html', 'application/*'); // => 'application/json'
|
|
98
|
+
*
|
|
99
|
+
* this.is('html'); // => false
|
|
100
|
+
*/
|
|
101
|
+
is(...types: string[]): string | boolean;
|
|
102
|
+
is(types: string[]): string | boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Return request header. If the header is not set, will return an empty
|
|
105
|
+
* string.
|
|
106
|
+
*
|
|
107
|
+
* The `Referrer` header field is special-cased, both `Referrer` and
|
|
108
|
+
* `Referer` are interchangeable.
|
|
109
|
+
*
|
|
110
|
+
* Examples:
|
|
111
|
+
*
|
|
112
|
+
* this.get('Content-Type');
|
|
113
|
+
* // => "text/plain"
|
|
114
|
+
*
|
|
115
|
+
* this.get('content-type');
|
|
116
|
+
* // => "text/plain"
|
|
117
|
+
*
|
|
118
|
+
* this.get('Something');
|
|
119
|
+
* // => ''
|
|
120
|
+
*/
|
|
121
|
+
get(field: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* Get parsed host from event
|
|
124
|
+
*/
|
|
125
|
+
host: string;
|
|
126
|
+
/**
|
|
127
|
+
* Get parsed host from event
|
|
128
|
+
*/
|
|
129
|
+
hostname: string;
|
|
130
|
+
/**
|
|
131
|
+
* Request remote address.
|
|
132
|
+
*/
|
|
133
|
+
ip: string;
|
|
134
|
+
/**
|
|
135
|
+
* Get/Set request URL.
|
|
136
|
+
*/
|
|
137
|
+
url: string;
|
|
138
|
+
originalUrl: string;
|
|
139
|
+
accept: any;
|
|
140
|
+
/**
|
|
141
|
+
* Get request pathname.
|
|
142
|
+
*/
|
|
143
|
+
path: string;
|
|
144
|
+
/**
|
|
145
|
+
* Get request method.
|
|
146
|
+
*/
|
|
147
|
+
method: string;
|
|
148
|
+
/**
|
|
149
|
+
* Return request header.
|
|
150
|
+
*/
|
|
151
|
+
header: {
|
|
152
|
+
[key: string]: string;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Return request header, alias as request.header
|
|
156
|
+
*/
|
|
157
|
+
headers: {
|
|
158
|
+
[key: string]: string;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Get parsed query-string.
|
|
162
|
+
*/
|
|
163
|
+
query: {
|
|
164
|
+
[key: string]: any;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Get parsed params
|
|
168
|
+
*/
|
|
169
|
+
params: {
|
|
170
|
+
[key: string]: string;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export interface FaaSHTTPRequest extends ContextDelegatedRequest {
|
|
174
|
+
/**
|
|
175
|
+
* Get parsed request body from event
|
|
176
|
+
*/
|
|
177
|
+
body: any;
|
|
178
|
+
/**
|
|
179
|
+
* Get Parsed path parameters from event
|
|
180
|
+
*/
|
|
181
|
+
pathParameters: any;
|
|
182
|
+
}
|
|
183
|
+
interface ContextDelegatedResponse {
|
|
184
|
+
/**
|
|
185
|
+
* Get/Set response status code.
|
|
186
|
+
*/
|
|
187
|
+
status: number;
|
|
188
|
+
/**
|
|
189
|
+
* Get/Set response body.
|
|
190
|
+
*/
|
|
191
|
+
body: any;
|
|
192
|
+
/**
|
|
193
|
+
* Return parsed response Content-Length when present.
|
|
194
|
+
* Set Content-Length field to `n`.
|
|
195
|
+
*/
|
|
196
|
+
length: number;
|
|
197
|
+
/**
|
|
198
|
+
* Return the response mime type void of
|
|
199
|
+
* parameters such as "charset".
|
|
200
|
+
*
|
|
201
|
+
* Set Content-Type response header with `type` through `mime.lookup()`
|
|
202
|
+
* when it does not contain a charset.
|
|
203
|
+
*
|
|
204
|
+
* Examples:
|
|
205
|
+
*
|
|
206
|
+
* this.type = '.html';
|
|
207
|
+
* this.type = 'html';
|
|
208
|
+
* this.type = 'json';
|
|
209
|
+
* this.type = 'application/json';
|
|
210
|
+
* this.type = 'png';
|
|
211
|
+
*/
|
|
212
|
+
type: string;
|
|
213
|
+
/**
|
|
214
|
+
* Get the Last-Modified date in Date form, if it exists.
|
|
215
|
+
* Set the Last-Modified date using a string or a Date.
|
|
216
|
+
*
|
|
217
|
+
* this.response.lastModified = new Date();
|
|
218
|
+
* this.response.lastModified = '2013-09-13';
|
|
219
|
+
*/
|
|
220
|
+
lastModified: Date;
|
|
221
|
+
/**
|
|
222
|
+
* Get/Set the ETag of a response.
|
|
223
|
+
* This will normalize the quotes if necessary.
|
|
224
|
+
*
|
|
225
|
+
* this.response.etag = 'md5hashsum';
|
|
226
|
+
* this.response.etag = '"md5hashsum"';
|
|
227
|
+
* this.response.etag = 'W/"123456789"';
|
|
228
|
+
*
|
|
229
|
+
* @param {String} etag
|
|
230
|
+
* @api public
|
|
231
|
+
*/
|
|
232
|
+
etag: string;
|
|
233
|
+
/**
|
|
234
|
+
* Set header `field` to `val`, or pass
|
|
235
|
+
* an object of header fields.
|
|
236
|
+
*
|
|
237
|
+
* Examples:
|
|
238
|
+
*
|
|
239
|
+
* this.set('Foo', ['bar', 'baz']);
|
|
240
|
+
* this.set('Accept', 'application/json');
|
|
241
|
+
* this.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
|
|
242
|
+
*/
|
|
243
|
+
set(field: {
|
|
244
|
+
[key: string]: string;
|
|
245
|
+
}): void;
|
|
246
|
+
set(field: string, val: string | string[]): void;
|
|
247
|
+
/**
|
|
248
|
+
* Append additional header `field` with value `val`.
|
|
249
|
+
*
|
|
250
|
+
* Examples:
|
|
251
|
+
*
|
|
252
|
+
* ```
|
|
253
|
+
* this.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
|
|
254
|
+
* this.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
|
|
255
|
+
* this.append('Warning', '199 Miscellaneous warning');
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
append(field: string, val: string | string[]): void;
|
|
259
|
+
/**
|
|
260
|
+
* Remove header `field`.
|
|
261
|
+
*/
|
|
262
|
+
remove(field: string): void;
|
|
263
|
+
/**
|
|
264
|
+
* Perform a 302 redirect to `url`.
|
|
265
|
+
*
|
|
266
|
+
* The string "back" is special-cased
|
|
267
|
+
* to provide Referrer support, when Referrer
|
|
268
|
+
* is not present `alt` or "/" is used.
|
|
269
|
+
*
|
|
270
|
+
* Examples:
|
|
271
|
+
*
|
|
272
|
+
* this.redirect('back');
|
|
273
|
+
* this.redirect('back', '/index.html');
|
|
274
|
+
* this.redirect('/login');
|
|
275
|
+
* this.redirect('http://google.com');
|
|
276
|
+
*/
|
|
277
|
+
redirect(url: string, alt?: string): void;
|
|
278
|
+
/**
|
|
279
|
+
* Get/Set streaming response.
|
|
280
|
+
*
|
|
281
|
+
* this.streaming = true;
|
|
282
|
+
*
|
|
283
|
+
* @api public
|
|
284
|
+
*/
|
|
285
|
+
streaming: boolean;
|
|
286
|
+
}
|
|
287
|
+
export interface FaaSHTTPResponse extends ContextDelegatedResponse, Pick<Writable, 'write' | 'end'> {
|
|
288
|
+
/**
|
|
289
|
+
* Return response header.
|
|
290
|
+
*/
|
|
291
|
+
header: {
|
|
292
|
+
[key: string]: any;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Return response header, alias as response.header
|
|
296
|
+
*/
|
|
297
|
+
headers: {
|
|
298
|
+
[key: string]: any;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Check whether the response is one of the listed types.
|
|
302
|
+
* Pretty much the same as `this.request.is()`.
|
|
303
|
+
*
|
|
304
|
+
* @param {String|Array} types...
|
|
305
|
+
* @return {String|false}
|
|
306
|
+
* @api public
|
|
307
|
+
*/
|
|
308
|
+
is(...types: string[]): string;
|
|
309
|
+
is(types: string[]): string;
|
|
310
|
+
/**
|
|
311
|
+
* Return response header. If the header is not set, will return an empty
|
|
312
|
+
* string.
|
|
313
|
+
*
|
|
314
|
+
* The `Referrer` header field is special-cased, both `Referrer` and
|
|
315
|
+
* `Referer` are interchangeable.
|
|
316
|
+
*
|
|
317
|
+
* Examples:
|
|
318
|
+
*
|
|
319
|
+
* this.get('Content-Type');
|
|
320
|
+
* // => "text/plain"
|
|
321
|
+
*
|
|
322
|
+
* this.get('content-type');
|
|
323
|
+
* // => "text/plain"
|
|
324
|
+
*
|
|
325
|
+
* this.get('Something');
|
|
326
|
+
* // => ''
|
|
327
|
+
*/
|
|
328
|
+
get(field: string): string;
|
|
329
|
+
}
|
|
330
|
+
export interface FaaSHTTPContext extends ContextDelegatedRequest, ContextDelegatedResponse {
|
|
331
|
+
/**
|
|
332
|
+
* It's a http request mock object, please don't use it directly.
|
|
333
|
+
*/
|
|
334
|
+
req: any;
|
|
335
|
+
/**
|
|
336
|
+
* It's a http response mock object, please don't use it directly.
|
|
337
|
+
*/
|
|
338
|
+
res: any;
|
|
339
|
+
/**
|
|
340
|
+
* FaaS http request object
|
|
341
|
+
*/
|
|
342
|
+
request: FaaSHTTPRequest;
|
|
343
|
+
/**
|
|
344
|
+
* FaaS http response object
|
|
345
|
+
*/
|
|
346
|
+
response: FaaSHTTPResponse;
|
|
347
|
+
/**
|
|
348
|
+
* FaaS original event object.
|
|
349
|
+
*/
|
|
350
|
+
originEvent: Record<string, any>;
|
|
351
|
+
/**
|
|
352
|
+
* FaaS Cookies Object
|
|
353
|
+
*/
|
|
354
|
+
cookies: Cookies;
|
|
355
|
+
/**
|
|
356
|
+
* Throw an error with `msg` and optional `status`
|
|
357
|
+
* defaulting to 500. Note that these are user-level
|
|
358
|
+
* errors, and the message may be exposed to the client.
|
|
359
|
+
*
|
|
360
|
+
* this.throw(403)
|
|
361
|
+
* this.throw('name required', 400)
|
|
362
|
+
* this.throw(400, 'name required')
|
|
363
|
+
* this.throw('something exploded')
|
|
364
|
+
* this.throw(new Error('invalid'), 400);
|
|
365
|
+
* this.throw(400, new Error('invalid'));
|
|
366
|
+
*
|
|
367
|
+
* See: https://github.com/jshttp/http-errors
|
|
368
|
+
*/
|
|
369
|
+
throw(message: string, code?: number, properties?: Record<string, unknown>): never;
|
|
370
|
+
throw(status: number): never;
|
|
371
|
+
throw(...properties: Array<number | string | Record<string, unknown>>): never;
|
|
372
|
+
}
|
|
5
373
|
export interface FaaSContext extends IMidwayContext<FaaSHTTPContext> {
|
|
6
374
|
logger: ILogger;
|
|
7
375
|
env: string;
|
|
@@ -92,4 +460,5 @@ export interface HttpResponseFormat<T = unknown> {
|
|
|
92
460
|
}
|
|
93
461
|
export interface wrapHttpRequestOptions extends HttpResponseOptions {
|
|
94
462
|
}
|
|
463
|
+
export {};
|
|
95
464
|
//# sourceMappingURL=interface.d.ts.map
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,373 @@
|
|
|
1
|
-
export * from '@midwayjs/faas-typings';
|
|
2
1
|
export * from './dist/index';
|
|
2
|
+
|
|
3
|
+
interface SingleOSSEvent {
|
|
4
|
+
eventName: string;
|
|
5
|
+
eventSource: string;
|
|
6
|
+
eventTime: string;
|
|
7
|
+
eventVersion: string;
|
|
8
|
+
oss: {
|
|
9
|
+
bucket: {
|
|
10
|
+
arn: string;
|
|
11
|
+
name: string;
|
|
12
|
+
ownerIdentity: string;
|
|
13
|
+
virtualBucket: string;
|
|
14
|
+
};
|
|
15
|
+
object: {
|
|
16
|
+
deltaSize: number;
|
|
17
|
+
eTag: string;
|
|
18
|
+
key: string;
|
|
19
|
+
size: number;
|
|
20
|
+
};
|
|
21
|
+
ossSchemaVersion: string;
|
|
22
|
+
ruleId: string;
|
|
23
|
+
};
|
|
24
|
+
region: string;
|
|
25
|
+
requestParameters: {
|
|
26
|
+
sourceIPAddress: string;
|
|
27
|
+
};
|
|
28
|
+
responseElements: {
|
|
29
|
+
requestId: string;
|
|
30
|
+
};
|
|
31
|
+
userIdentity: {
|
|
32
|
+
principalId: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface SingleCDNEvent {
|
|
37
|
+
// 事件类型
|
|
38
|
+
eventName: string;
|
|
39
|
+
eventSource: string;
|
|
40
|
+
region: string;
|
|
41
|
+
eventVersion: string;
|
|
42
|
+
eventTime: string;
|
|
43
|
+
userIdentity: {
|
|
44
|
+
aliUid: string;
|
|
45
|
+
};
|
|
46
|
+
resource: {
|
|
47
|
+
domain: string;
|
|
48
|
+
};
|
|
49
|
+
eventParameter: {
|
|
50
|
+
domain: string;
|
|
51
|
+
endTime: number;
|
|
52
|
+
fileSize: number;
|
|
53
|
+
filePath: string;
|
|
54
|
+
startTime: number;
|
|
55
|
+
};
|
|
56
|
+
traceId: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface MNSStreamEvent {
|
|
60
|
+
body: string;
|
|
61
|
+
attrs: {
|
|
62
|
+
Extend: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface MNSJSONEvent {
|
|
67
|
+
Context: string;
|
|
68
|
+
TopicOwner: string;
|
|
69
|
+
Message: string;
|
|
70
|
+
Subscriber: string;
|
|
71
|
+
PublishTime: number;
|
|
72
|
+
SubscriptionName: string;
|
|
73
|
+
MessageMD5: string;
|
|
74
|
+
TopicName: string;
|
|
75
|
+
MessageId: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface TableStoreRecord {
|
|
79
|
+
Type: 'string';
|
|
80
|
+
Info: {
|
|
81
|
+
Timestamp: number;
|
|
82
|
+
};
|
|
83
|
+
PrimaryKey: [
|
|
84
|
+
{
|
|
85
|
+
ColumnName: string;
|
|
86
|
+
Value: any;
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
Columns: [
|
|
90
|
+
{
|
|
91
|
+
Type: string;
|
|
92
|
+
ColumnName: string;
|
|
93
|
+
Value: any;
|
|
94
|
+
Timestamp: number;
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated
|
|
101
|
+
*/
|
|
102
|
+
export namespace FC {
|
|
103
|
+
export interface OSSEvent {
|
|
104
|
+
events: SingleOSSEvent[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type MNSEvent = string | MNSStreamEvent | MNSJSONEvent;
|
|
108
|
+
|
|
109
|
+
export interface SLSEvent {
|
|
110
|
+
parameter: Record<string, unknown>;
|
|
111
|
+
source: {
|
|
112
|
+
endpoint: string;
|
|
113
|
+
projectName: string;
|
|
114
|
+
logstoreName: string;
|
|
115
|
+
shardId: number;
|
|
116
|
+
beginCursor: string;
|
|
117
|
+
endCursor: string;
|
|
118
|
+
};
|
|
119
|
+
jobName: string;
|
|
120
|
+
taskId: string;
|
|
121
|
+
cursorTime: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface CDNEvent {
|
|
125
|
+
events: SingleCDNEvent[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface TimerEvent {
|
|
129
|
+
triggerTime: string;
|
|
130
|
+
triggerName: string;
|
|
131
|
+
payload: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface APIGatewayEvent {
|
|
135
|
+
path: string;
|
|
136
|
+
httpMethod: string;
|
|
137
|
+
headers: { [key: string]: string };
|
|
138
|
+
queryParameters: { [key: string]: string };
|
|
139
|
+
pathParameters: { [key: string]: string };
|
|
140
|
+
body: string;
|
|
141
|
+
isBase64Encoded: 'true' | 'false';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface APIGatewayResponse {
|
|
145
|
+
isBase64Encoded: boolean;
|
|
146
|
+
statusCode: number;
|
|
147
|
+
headers: Record<string, unknown>;
|
|
148
|
+
body: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface TableStoreEvent {
|
|
152
|
+
Version: string;
|
|
153
|
+
Records: TableStoreRecord[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface InitializeContext {
|
|
157
|
+
requestId: string;
|
|
158
|
+
credentials: {
|
|
159
|
+
accessKeyId: string;
|
|
160
|
+
accessKeySecret: string;
|
|
161
|
+
securityToken: string;
|
|
162
|
+
};
|
|
163
|
+
function: {
|
|
164
|
+
name: string;
|
|
165
|
+
handler: string;
|
|
166
|
+
memory: number;
|
|
167
|
+
timeout: number;
|
|
168
|
+
initializer: string;
|
|
169
|
+
initializationTimeout: number;
|
|
170
|
+
};
|
|
171
|
+
service: {
|
|
172
|
+
name: string;
|
|
173
|
+
logProject: string;
|
|
174
|
+
logStore: string;
|
|
175
|
+
qualifier: string;
|
|
176
|
+
versionId: string;
|
|
177
|
+
};
|
|
178
|
+
region: string;
|
|
179
|
+
accountId: string;
|
|
180
|
+
logger: Console;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type RequestContext = InitializeContext;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
interface COSRecord {
|
|
187
|
+
cos: {
|
|
188
|
+
cosSchemaVersion: string;
|
|
189
|
+
cosObject: {
|
|
190
|
+
url: string;
|
|
191
|
+
meta: {
|
|
192
|
+
'x-cos-request-id': string;
|
|
193
|
+
'Content-Type': string;
|
|
194
|
+
};
|
|
195
|
+
vid: string;
|
|
196
|
+
key: string;
|
|
197
|
+
size: number;
|
|
198
|
+
};
|
|
199
|
+
cosBucket: {
|
|
200
|
+
region: string;
|
|
201
|
+
name: string;
|
|
202
|
+
appid: string;
|
|
203
|
+
};
|
|
204
|
+
cosNotificationId: string;
|
|
205
|
+
};
|
|
206
|
+
event: {
|
|
207
|
+
eventName: string;
|
|
208
|
+
eventVersion: string;
|
|
209
|
+
eventTime: number;
|
|
210
|
+
eventSource: string;
|
|
211
|
+
requestParameters: {
|
|
212
|
+
requestSourceIP: string;
|
|
213
|
+
requestHeaders: {
|
|
214
|
+
Authorization: string;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
eventQueue: string;
|
|
218
|
+
reservedInfo: string;
|
|
219
|
+
reqid: number;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface CMQRecord {
|
|
224
|
+
CMQ: {
|
|
225
|
+
type: string;
|
|
226
|
+
topicOwner: number;
|
|
227
|
+
topicName: string;
|
|
228
|
+
subscriptionName: string;
|
|
229
|
+
publishTime: string;
|
|
230
|
+
msgId: string;
|
|
231
|
+
requestId: string;
|
|
232
|
+
msgBody: string;
|
|
233
|
+
msgTag: string;
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
interface CKafkaRecord {
|
|
238
|
+
Ckafka: {
|
|
239
|
+
topic: string;
|
|
240
|
+
partition: number;
|
|
241
|
+
offset: number;
|
|
242
|
+
msgKey: string;
|
|
243
|
+
msgBody: string;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @deprecated
|
|
249
|
+
*/
|
|
250
|
+
export namespace SCF {
|
|
251
|
+
export interface COSEvent {
|
|
252
|
+
Records: COSRecord[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface TimerEvent {
|
|
256
|
+
Type: string;
|
|
257
|
+
TriggerName: string;
|
|
258
|
+
Time: string;
|
|
259
|
+
Message: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface CMQEvent {
|
|
263
|
+
Records: CMQRecord[];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface CKafkaEvent {
|
|
267
|
+
Records: CKafkaRecord[];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface APIGatewayEvent {
|
|
271
|
+
/**
|
|
272
|
+
* 请求来源的 API 网关的配置信息、请求标识、认证信息、来源信息。其中:
|
|
273
|
+
* serviceId,path,httpMethod 指向 API 网关的服务Id、API 的路径和方法;
|
|
274
|
+
* stage 指向请求来源 API 所在的环境;
|
|
275
|
+
* requestId 标识当前这次请求的唯一 ID;
|
|
276
|
+
* identity 标识用户的认证方法和认证的信息;
|
|
277
|
+
* sourceIp 标识请求来源 IP
|
|
278
|
+
*/
|
|
279
|
+
requestContext: {
|
|
280
|
+
serviceId: string;
|
|
281
|
+
path: string;
|
|
282
|
+
httpMethod: string;
|
|
283
|
+
requestId: string;
|
|
284
|
+
identity: {
|
|
285
|
+
secretId: string;
|
|
286
|
+
};
|
|
287
|
+
sourceIp: string;
|
|
288
|
+
stage: string;
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* 记录实际请求的完整 Header 内容
|
|
292
|
+
*/
|
|
293
|
+
headers: Record<string, unknown>;
|
|
294
|
+
/**
|
|
295
|
+
* 记录实际请求的完整 Body 内容
|
|
296
|
+
*/
|
|
297
|
+
body: string;
|
|
298
|
+
/**
|
|
299
|
+
* 记录在 API 网关中配置过的 Path 参数以及实际取值
|
|
300
|
+
*/
|
|
301
|
+
pathParameters: Record<string, unknown>;
|
|
302
|
+
/**
|
|
303
|
+
* 记录在 API 网关中配置过的 Query 参数以及实际取值
|
|
304
|
+
*/
|
|
305
|
+
queryStringParameters: Record<string, unknown>;
|
|
306
|
+
/**
|
|
307
|
+
* 记录在 API 网关中配置过的 Header 参数以及实际取值
|
|
308
|
+
*/
|
|
309
|
+
headerParameters: Record<string, unknown>;
|
|
310
|
+
stageVariables: {
|
|
311
|
+
stage: string;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* 记录实际请求的完整 Path 信息,注意 midway faas 为了获取真实 path 做过处理
|
|
315
|
+
*/
|
|
316
|
+
path: string;
|
|
317
|
+
/**
|
|
318
|
+
* 请求地址的查询参数
|
|
319
|
+
*/
|
|
320
|
+
queryString: Record<string, unknown>;
|
|
321
|
+
httpMethod: string;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export interface APIGatewayResponse {
|
|
325
|
+
isBase64Encoded: boolean;
|
|
326
|
+
statusCode: number;
|
|
327
|
+
headers: Record<string, unknown>;
|
|
328
|
+
body: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface APIGatewayWebSocketEvent {
|
|
332
|
+
requestContext: {
|
|
333
|
+
serviceName: string;
|
|
334
|
+
path: string;
|
|
335
|
+
httpMethod: string;
|
|
336
|
+
requestId: string;
|
|
337
|
+
identity: {
|
|
338
|
+
secretId: string;
|
|
339
|
+
};
|
|
340
|
+
sourceIp: string;
|
|
341
|
+
stage: string;
|
|
342
|
+
websocketEnable: boolean;
|
|
343
|
+
};
|
|
344
|
+
websocket: {
|
|
345
|
+
action: string;
|
|
346
|
+
secConnectionID: string;
|
|
347
|
+
secWebSocketProtocol: string;
|
|
348
|
+
secWebSocketExtensions: string;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface APIGatewayWebSocketResponse {
|
|
353
|
+
errNo: number;
|
|
354
|
+
errMsg: string;
|
|
355
|
+
websocket: {
|
|
356
|
+
action: string;
|
|
357
|
+
secConnectionID: string;
|
|
358
|
+
secWebSocketProtocol: string;
|
|
359
|
+
secWebSocketExtensions: string;
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface RequestContext {
|
|
364
|
+
callbackWaitsForEmptyEventLoop: boolean;
|
|
365
|
+
memory_limit_in_mb: number;
|
|
366
|
+
time_limit_in_ms: number;
|
|
367
|
+
request_id: string;
|
|
368
|
+
environ: string;
|
|
369
|
+
function_version: string;
|
|
370
|
+
function_name: string;
|
|
371
|
+
namespace: string;
|
|
372
|
+
}
|
|
373
|
+
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/faas",
|
|
3
|
-
"version": "3.12.
|
|
4
|
-
"main": "dist/index",
|
|
3
|
+
"version": "3.12.5",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@midwayjs/core": "^3.12.3",
|
|
8
|
-
"@midwayjs/faas-typings": "^3.10.13",
|
|
9
8
|
"@midwayjs/logger": "^2.15.0",
|
|
10
|
-
"@midwayjs/serverless-http-parser": "^3.
|
|
9
|
+
"@midwayjs/serverless-http-parser": "^3.12.5",
|
|
11
10
|
"@midwayjs/simple-lock": "^1.1.4"
|
|
12
11
|
},
|
|
13
12
|
"devDependencies": {
|
|
14
13
|
"@midwayjs/mock": "^3.12.3",
|
|
15
|
-
"@midwayjs/serverless-fc-starter": "^3.12.
|
|
16
|
-
"@midwayjs/serverless-scf-starter": "^3.
|
|
14
|
+
"@midwayjs/serverless-fc-starter": "^3.12.5",
|
|
15
|
+
"@midwayjs/serverless-scf-starter": "^3.12.5",
|
|
17
16
|
"mm": "3.3.0"
|
|
18
17
|
},
|
|
19
18
|
"engines": {
|
|
@@ -45,5 +44,5 @@
|
|
|
45
44
|
"url": "git@github.com:midwayjs/midway.git"
|
|
46
45
|
},
|
|
47
46
|
"license": "MIT",
|
|
48
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "24c6b9f7a3be1bf37b3182286f3e55fc418a2c99"
|
|
49
48
|
}
|