lemon-core 3.1.0 → 3.1.1
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 +1 -0
- package/dist/controllers/dummy-controller.d.ts +1 -1
- package/dist/controllers/dummy-controller.js +2 -2
- package/dist/controllers/dummy-controller.js.map +1 -1
- package/dist/controllers/general-api-controller.d.ts +1 -1
- package/dist/cores/api/api-service.d.ts +239 -0
- package/dist/cores/api/api-service.js +674 -0
- package/dist/cores/api/api-service.js.map +1 -0
- package/dist/cores/api/index.d.ts +10 -0
- package/dist/cores/api/index.js +27 -0
- package/dist/cores/api/index.js.map +1 -0
- package/dist/cores/aws/aws-kms-service.d.ts +53 -2
- package/dist/cores/aws/aws-kms-service.js +104 -17
- package/dist/cores/aws/aws-kms-service.js.map +1 -1
- package/dist/cores/cache/cache-service.d.ts +440 -0
- package/dist/cores/cache/cache-service.js +967 -0
- package/dist/cores/cache/cache-service.js.map +1 -0
- package/dist/cores/cache/index.d.ts +10 -0
- package/dist/cores/cache/index.js +27 -0
- package/dist/cores/cache/index.js.map +1 -0
- package/dist/cores/cache-service.d.ts +54 -18
- package/dist/cores/cache-service.js +37 -26
- package/dist/cores/cache-service.js.map +1 -1
- package/dist/cores/core-types.d.ts +42 -12
- package/dist/cores/dynamo/dynamo-query-service.d.ts +52 -0
- package/dist/cores/dynamo/dynamo-query-service.js +127 -0
- package/dist/cores/dynamo/dynamo-query-service.js.map +1 -0
- package/dist/cores/dynamo/dynamo-scan-service.d.ts +70 -0
- package/dist/cores/dynamo/dynamo-scan-service.js +164 -0
- package/dist/cores/dynamo/dynamo-scan-service.js.map +1 -0
- package/dist/cores/dynamo/dynamo-service.d.ts +192 -0
- package/dist/cores/dynamo/dynamo-service.js +525 -0
- package/dist/cores/dynamo/dynamo-service.js.map +1 -0
- package/dist/cores/dynamo/index.d.ts +12 -0
- package/dist/cores/dynamo/index.js +29 -0
- package/dist/cores/dynamo/index.js.map +1 -0
- package/dist/cores/elastic/elastic6-query-service.d.ts +104 -0
- package/dist/cores/elastic/elastic6-query-service.js +510 -0
- package/dist/cores/elastic/elastic6-query-service.js.map +1 -0
- package/dist/cores/elastic/elastic6-service.d.ts +273 -0
- package/dist/cores/elastic/elastic6-service.js +903 -0
- package/dist/cores/elastic/elastic6-service.js.map +1 -0
- package/dist/cores/elastic/hangul-service.d.ts +102 -0
- package/dist/cores/elastic/hangul-service.js +205 -0
- package/dist/cores/elastic/hangul-service.js.map +1 -0
- package/dist/cores/elastic/index.d.ts +12 -0
- package/dist/cores/elastic/index.js +29 -0
- package/dist/cores/elastic/index.js.map +1 -0
- package/dist/cores/hangul-service.d.ts +17 -3
- package/dist/cores/hangul-service.js +17 -8
- package/dist/cores/hangul-service.js.map +1 -1
- package/dist/cores/index.d.ts +5 -11
- package/dist/cores/index.js +8 -13
- package/dist/cores/index.js.map +1 -1
- package/dist/cores/lambda/lambda-dynamo-stream-handler.d.ts +2 -2
- package/dist/cores/lambda/lambda-web-handler.d.ts +158 -8
- package/dist/cores/lambda/lambda-web-handler.js +283 -77
- package/dist/cores/lambda/lambda-web-handler.js.map +1 -1
- package/dist/cores/protocol/protocol-service.d.ts +4 -0
- package/dist/cores/protocol/protocol-service.js +12 -7
- package/dist/cores/protocol/protocol-service.js.map +1 -1
- package/dist/cores/storage/http-storage-service.d.ts +22 -0
- package/dist/cores/storage/http-storage-service.js +129 -0
- package/dist/cores/storage/http-storage-service.js.map +1 -0
- package/dist/cores/storage/index.d.ts +14 -0
- package/dist/cores/storage/index.js +31 -0
- package/dist/cores/storage/index.js.map +1 -0
- package/dist/cores/storage/model-manager.d.ts +93 -0
- package/dist/cores/storage/model-manager.js +192 -0
- package/dist/cores/storage/model-manager.js.map +1 -0
- package/dist/cores/storage/proxy-storage-service.d.ts +573 -0
- package/dist/cores/storage/proxy-storage-service.js +913 -0
- package/dist/cores/storage/proxy-storage-service.js.map +1 -0
- package/dist/cores/storage/redis-storage-service.d.ts +183 -0
- package/dist/cores/storage/redis-storage-service.js +391 -0
- package/dist/cores/storage/redis-storage-service.js.map +1 -0
- package/dist/cores/storage/storage-service.d.ts +169 -0
- package/dist/cores/storage/storage-service.js +374 -0
- package/dist/cores/storage/storage-service.js.map +1 -0
- package/dist/cores/storage-service.d.ts +1 -1
- package/dist/cores/storage-service.js +2 -2
- package/dist/cores/storage-service.js.map +1 -1
- package/dist/engine/utilities.d.ts +4 -3
- package/dist/engine/utilities.js +6 -6
- package/dist/engine/utilities.js.map +1 -1
- package/dist/environ.d.ts +2 -2
- package/dist/environ.js +7 -4
- package/dist/environ.js.map +1 -1
- package/dist/extended/abstract-service.d.ts +533 -0
- package/dist/extended/abstract-service.js +915 -0
- package/dist/extended/abstract-service.js.map +1 -0
- package/dist/extended/index.d.ts +10 -0
- package/dist/extended/index.js +27 -0
- package/dist/extended/index.js.map +1 -0
- package/dist/helpers/helpers.d.ts +7 -0
- package/dist/helpers/helpers.js +7 -0
- package/dist/helpers/helpers.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DynamoDBRecord } from 'aws-lambda';
|
|
2
2
|
import { LambdaHandler, DynamoStreamHandler, LambdaSubHandler } from './lambda-handler';
|
|
3
3
|
import { NextHandler } from '../core-types';
|
|
4
|
-
import { Elastic6Service, Elastic6Item } from '../
|
|
5
|
-
import { DynamoOption } from '../dynamo
|
|
4
|
+
import { Elastic6Service, Elastic6Item } from '../elastic/';
|
|
5
|
+
import { DynamoOption } from '../dynamo/';
|
|
6
6
|
export declare type DynamoStreamEvent = DynamoDBRecord['eventName'];
|
|
7
7
|
export interface DynamoStreamParam {
|
|
8
8
|
region?: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { NextDecoder, NextContext, ProtocolParam } from './../core-services';
|
|
2
|
-
import { APIGatewayProxyResult, APIGatewayProxyEvent } from 'aws-lambda';
|
|
1
|
+
import { NextDecoder, NextContext, ProtocolParam, NextIdentity } from './../core-services';
|
|
3
2
|
import { LambdaHandler, WEBHandler, Context, LambdaSubHandler, WEBEvent } from './lambda-handler';
|
|
3
|
+
import { APIGatewayProxyResult, APIGatewayEventRequestContext, APIGatewayProxyEvent } from 'aws-lambda';
|
|
4
|
+
import { AWSKMSService } from '../aws/aws-kms-service';
|
|
5
|
+
import { NextIdentityJwt } from '../core-types';
|
|
4
6
|
/**
|
|
5
7
|
* class: `WEBController`
|
|
6
8
|
* - common controller interface.
|
|
@@ -17,9 +19,17 @@ interface ProxyParams {
|
|
|
17
19
|
declare type ProxyResult = APIGatewayProxyResult;
|
|
18
20
|
declare type ProxyResponser = () => ProxyResult;
|
|
19
21
|
declare type ProxyChain = ProxyParams | ProxyResponser;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* build http response body
|
|
24
|
+
* - if body is string type, then content-type would be text/<some>.
|
|
25
|
+
* - or default type is json
|
|
26
|
+
*
|
|
27
|
+
* @param statusCode http response code like 200
|
|
28
|
+
* @param body string or object
|
|
29
|
+
* @param contentType (optional) the target content-type
|
|
30
|
+
* @param origin (optional) the allow origin (default *)
|
|
31
|
+
* @returns http response body
|
|
32
|
+
*/
|
|
23
33
|
export declare const buildResponse: (statusCode: number, body: any, contentType?: string, origin?: string) => ProxyResult;
|
|
24
34
|
export declare const success: (body: any, contentType?: string, origin?: string) => APIGatewayProxyResult;
|
|
25
35
|
export declare const notfound: (body: any) => APIGatewayProxyResult;
|
|
@@ -84,12 +94,152 @@ export declare class LambdaWEBHandler extends LambdaSubHandler<WEBHandler> {
|
|
|
84
94
|
* @param event (optional) origin event object.
|
|
85
95
|
*/
|
|
86
96
|
handleProtocol<TResult = any>(param: ProtocolParam, event?: APIGatewayProxyEvent): Promise<TResult>;
|
|
97
|
+
/**
|
|
98
|
+
* builder of tools for http-headers
|
|
99
|
+
* - extracting header content, and parse.
|
|
100
|
+
*/
|
|
101
|
+
tools: (headers: HttpHeaderSet) => HttpHeaderTool;
|
|
87
102
|
/**
|
|
88
103
|
* pack the request context for Http request.
|
|
89
104
|
*
|
|
90
|
-
* @param event
|
|
91
|
-
* @param
|
|
105
|
+
* @param event origin Event.
|
|
106
|
+
* @param orgContext (optional) original lambda.Context
|
|
107
|
+
*/
|
|
108
|
+
packContext(event: APIGatewayProxyEvent, orgContext?: Context): Promise<NextContext>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* class: `HttpHeaderSet`
|
|
112
|
+
* - header has only <string> value (or values)
|
|
113
|
+
*/
|
|
114
|
+
export interface HttpHeaderSet {
|
|
115
|
+
[name: string]: string | string[];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* class: `HttpHeaderTool`
|
|
119
|
+
* - parse header and extract identity.
|
|
120
|
+
*/
|
|
121
|
+
export interface HttpHeaderTool {
|
|
122
|
+
/** say hello */
|
|
123
|
+
hello(): string;
|
|
124
|
+
/**
|
|
125
|
+
* get values by name
|
|
126
|
+
* @param name case-insentive name of header
|
|
127
|
+
*/
|
|
128
|
+
getHeaders(name: string): string[];
|
|
129
|
+
/**
|
|
130
|
+
* get the last value in header by name
|
|
131
|
+
* @param name case-insentive name of header
|
|
132
|
+
*/
|
|
133
|
+
getHeader(name: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* parse of header[`env(HEADER_LEMON_IDENTITY)`] to get `NextIdentity`
|
|
136
|
+
* @param name (optional) name of header (default is 'x-lemon-identity')
|
|
137
|
+
*/
|
|
138
|
+
parseIdentityHeader(name?: string): Promise<NextIdentity>;
|
|
139
|
+
/**
|
|
140
|
+
* parse of header[`env(HEADER_LEMON_LANGUAGE)`] to get language-type.
|
|
141
|
+
* @param name (optional) name of header (default is 'x-lemon-language')
|
|
142
|
+
*/
|
|
143
|
+
parseLanguageHeader(name?: string): string;
|
|
144
|
+
/**
|
|
145
|
+
* parse of header[`env(HEADER_LEMON_LANGUAGE)] to get cookie-set.
|
|
146
|
+
* @param name (optional) name of header (default is 'cookie')
|
|
147
|
+
*/
|
|
148
|
+
parseCookiesHeader(name?: string): {
|
|
149
|
+
[key: string]: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* override with AWS request-context
|
|
153
|
+
* @param $org the current request-context.
|
|
154
|
+
* @param reqContext (optional) request-context from AWS lambda handler.
|
|
155
|
+
*/
|
|
156
|
+
prepareContext($org: NextContext, reqContext?: APIGatewayEventRequestContext): Promise<NextContext>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* class: `MyHttpHeaderTool`
|
|
160
|
+
* - basic implementation of HttpHeaderTool
|
|
161
|
+
*/
|
|
162
|
+
export declare class MyHttpHeaderTool implements HttpHeaderTool {
|
|
163
|
+
protected handler: LambdaWEBHandler;
|
|
164
|
+
protected headers: HttpHeaderSet;
|
|
165
|
+
/**
|
|
166
|
+
* default constructor.
|
|
167
|
+
* @param headers
|
|
168
|
+
*/
|
|
169
|
+
constructor(handler: LambdaWEBHandler, headers: HttpHeaderSet);
|
|
170
|
+
hello(): string;
|
|
171
|
+
/**
|
|
172
|
+
* get values by name
|
|
173
|
+
* @param name case-insentive name of field
|
|
174
|
+
*/
|
|
175
|
+
getHeaders: (name: string) => string[];
|
|
176
|
+
/**
|
|
177
|
+
* get the last value in header by name
|
|
178
|
+
*/
|
|
179
|
+
getHeader: (name: string) => string;
|
|
180
|
+
/**
|
|
181
|
+
* check if this request is from externals (like API-GW)
|
|
182
|
+
* @returns true if in external
|
|
183
|
+
*/
|
|
184
|
+
isExternal: () => boolean;
|
|
185
|
+
/**
|
|
186
|
+
* parse of header[`x-lemon-identity`] to get the instance of `NextIdentity`
|
|
187
|
+
* - lambda 호출의 2가지 방법이 있음 (interval vs external)
|
|
188
|
+
* - internal는 AWS 같은 계정내 호출로 labmda 직접 호출이 가능함.
|
|
189
|
+
* - external는 API-GW를 통한 호출로 JWT 지원 (since 3.1.2).
|
|
190
|
+
*
|
|
191
|
+
* **[FOR INTERNAL CALL BY LAMBDA]**
|
|
192
|
+
* - `x-lemon-identity` 정보로부터, 계정 정보를 얻음 (for direct call via lambda)
|
|
193
|
+
* - 외부 호출과 구분하기 위해서 headr[host]가 비어 있어야함 (API-GW에서는 무조건 있으므로)
|
|
194
|
+
*
|
|
195
|
+
* **[FOR EXTERNAL CALL BY API-GW]**
|
|
196
|
+
* - support ONLY JWT Token authentication (verification).
|
|
197
|
+
* - iat
|
|
198
|
+
*/
|
|
199
|
+
parseIdentityHeader: <T extends NextIdentity<any> = NextIdentity<any>>(name?: string) => Promise<T>;
|
|
200
|
+
/**
|
|
201
|
+
* parse as identity from json encoded text.
|
|
202
|
+
*/
|
|
203
|
+
parseIdentityJson: (val: string) => Promise<NextIdentity<any>>;
|
|
204
|
+
/**
|
|
205
|
+
* find(or make) the proper KMSService per key
|
|
206
|
+
* @param keyId key of KMS
|
|
207
|
+
* @returns service
|
|
208
|
+
*/
|
|
209
|
+
protected findKMSService(keyId: string): AWSKMSService;
|
|
210
|
+
/**
|
|
211
|
+
* encode as JWT string.
|
|
212
|
+
*/
|
|
213
|
+
encodeIdentityJWT: (identity: NextIdentity, params?: {
|
|
214
|
+
/** KMS alias to use */
|
|
215
|
+
alias?: string;
|
|
216
|
+
/** current ms */
|
|
217
|
+
current?: number;
|
|
218
|
+
}) => Promise<{
|
|
219
|
+
signature: string;
|
|
220
|
+
message: string;
|
|
221
|
+
token: string;
|
|
222
|
+
}>;
|
|
223
|
+
/**
|
|
224
|
+
* parse as jwt-token, and validate the signature.
|
|
225
|
+
*/
|
|
226
|
+
parseIdentityJWT: <T extends NextIdentityJwt<any> = NextIdentityJwt<any>>(token: string, params?: {
|
|
227
|
+
/** current ms */
|
|
228
|
+
current?: number;
|
|
229
|
+
}) => Promise<T>;
|
|
230
|
+
/**
|
|
231
|
+
* parse of header[HEADER_LEMON_LANGUAGE] to get language-type.
|
|
232
|
+
*/
|
|
233
|
+
parseLanguageHeader: (name?: string) => string;
|
|
234
|
+
/**
|
|
235
|
+
* parse of header[HEADER_LEMON_LANGUAGE] to get cookie-set.
|
|
236
|
+
*/
|
|
237
|
+
parseCookiesHeader: (name?: string) => {
|
|
238
|
+
[key: string]: string;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* override with AWS request-context
|
|
92
242
|
*/
|
|
93
|
-
|
|
243
|
+
prepareContext: ($org: NextContext, reqContext: APIGatewayEventRequestContext) => Promise<NextContext>;
|
|
94
244
|
}
|
|
95
245
|
export {};
|