lemon-core 3.0.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.
Files changed (189) hide show
  1. package/README.md +13 -21
  2. package/dist/common/test-helper.js +19 -11
  3. package/dist/common/test-helper.js.map +1 -1
  4. package/dist/controllers/dummy-controller.d.ts +1 -1
  5. package/dist/controllers/dummy-controller.js +2 -2
  6. package/dist/controllers/dummy-controller.js.map +1 -1
  7. package/dist/controllers/general-api-controller.d.ts +1 -1
  8. package/dist/controllers/general-api-controller.js +5 -5
  9. package/dist/controllers/general-api-controller.js.map +1 -1
  10. package/dist/controllers/general-controller.js +2 -1
  11. package/dist/controllers/general-controller.js.map +1 -1
  12. package/dist/controllers/index.js +6 -2
  13. package/dist/controllers/index.js.map +1 -1
  14. package/dist/cores/api/api-service.d.ts +239 -0
  15. package/dist/cores/api/api-service.js +674 -0
  16. package/dist/cores/api/api-service.js.map +1 -0
  17. package/dist/cores/api/index.d.ts +10 -0
  18. package/dist/cores/api/index.js +27 -0
  19. package/dist/cores/api/index.js.map +1 -0
  20. package/dist/cores/api-service.js +19 -18
  21. package/dist/cores/api-service.js.map +1 -1
  22. package/dist/cores/aws/aws-kms-service.d.ts +53 -2
  23. package/dist/cores/aws/aws-kms-service.js +112 -29
  24. package/dist/cores/aws/aws-kms-service.js.map +1 -1
  25. package/dist/cores/aws/aws-s3-service.js +19 -18
  26. package/dist/cores/aws/aws-s3-service.js.map +1 -1
  27. package/dist/cores/aws/aws-sns-service.js +10 -10
  28. package/dist/cores/aws/aws-sns-service.js.map +1 -1
  29. package/dist/cores/aws/aws-sqs-service.js +12 -12
  30. package/dist/cores/aws/aws-sqs-service.js.map +1 -1
  31. package/dist/cores/aws/index.js +1 -1
  32. package/dist/cores/cache/cache-service.d.ts +440 -0
  33. package/dist/cores/cache/cache-service.js +967 -0
  34. package/dist/cores/cache/cache-service.js.map +1 -0
  35. package/dist/cores/cache/index.d.ts +10 -0
  36. package/dist/cores/cache/index.js +27 -0
  37. package/dist/cores/cache/index.js.map +1 -0
  38. package/dist/cores/cache-service.d.ts +54 -18
  39. package/dist/cores/cache-service.js +56 -45
  40. package/dist/cores/cache-service.js.map +1 -1
  41. package/dist/cores/config/config-service.js +11 -10
  42. package/dist/cores/config/config-service.js.map +1 -1
  43. package/dist/cores/core-services.js +6 -2
  44. package/dist/cores/core-services.js.map +1 -1
  45. package/dist/cores/core-types.d.ts +42 -12
  46. package/dist/cores/dynamo/dynamo-query-service.d.ts +52 -0
  47. package/dist/cores/dynamo/dynamo-query-service.js +127 -0
  48. package/dist/cores/dynamo/dynamo-query-service.js.map +1 -0
  49. package/dist/cores/dynamo/dynamo-scan-service.d.ts +70 -0
  50. package/dist/cores/dynamo/dynamo-scan-service.js +164 -0
  51. package/dist/cores/dynamo/dynamo-scan-service.js.map +1 -0
  52. package/dist/cores/dynamo/dynamo-service.d.ts +192 -0
  53. package/dist/cores/dynamo/dynamo-service.js +525 -0
  54. package/dist/cores/dynamo/dynamo-service.js.map +1 -0
  55. package/dist/cores/dynamo/index.d.ts +12 -0
  56. package/dist/cores/dynamo/index.js +29 -0
  57. package/dist/cores/dynamo/index.js.map +1 -0
  58. package/dist/cores/dynamo-query-service.js +7 -7
  59. package/dist/cores/dynamo-query-service.js.map +1 -1
  60. package/dist/cores/dynamo-scan-service.js +8 -8
  61. package/dist/cores/dynamo-scan-service.js.map +1 -1
  62. package/dist/cores/dynamo-service.js +19 -19
  63. package/dist/cores/dynamo-service.js.map +1 -1
  64. package/dist/cores/elastic/elastic6-query-service.d.ts +104 -0
  65. package/dist/cores/elastic/elastic6-query-service.js +510 -0
  66. package/dist/cores/elastic/elastic6-query-service.js.map +1 -0
  67. package/dist/cores/elastic/elastic6-service.d.ts +273 -0
  68. package/dist/cores/elastic/elastic6-service.js +903 -0
  69. package/dist/cores/elastic/elastic6-service.js.map +1 -0
  70. package/dist/cores/elastic/hangul-service.d.ts +102 -0
  71. package/dist/cores/elastic/hangul-service.js +205 -0
  72. package/dist/cores/elastic/hangul-service.js.map +1 -0
  73. package/dist/cores/elastic/index.d.ts +12 -0
  74. package/dist/cores/elastic/index.js +29 -0
  75. package/dist/cores/elastic/index.js.map +1 -0
  76. package/dist/cores/elastic6-query-service.js +7 -7
  77. package/dist/cores/elastic6-query-service.js.map +1 -1
  78. package/dist/cores/elastic6-service.js +57 -65
  79. package/dist/cores/elastic6-service.js.map +1 -1
  80. package/dist/cores/hangul-service.d.ts +17 -3
  81. package/dist/cores/hangul-service.js +17 -8
  82. package/dist/cores/hangul-service.js.map +1 -1
  83. package/dist/cores/http-storage-service.js +1 -1
  84. package/dist/cores/http-storage-service.js.map +1 -1
  85. package/dist/cores/index.d.ts +9 -15
  86. package/dist/cores/index.js +14 -15
  87. package/dist/cores/index.js.map +1 -1
  88. package/dist/cores/lambda/index.js +8 -4
  89. package/dist/cores/lambda/index.js.map +1 -1
  90. package/dist/cores/lambda/lambda-cognito-handler.js +2 -2
  91. package/dist/cores/lambda/lambda-cognito-handler.js.map +1 -1
  92. package/dist/cores/lambda/lambda-cron-handler.js +2 -2
  93. package/dist/cores/lambda/lambda-cron-handler.js.map +1 -1
  94. package/dist/cores/lambda/lambda-dynamo-stream-handler.d.ts +2 -2
  95. package/dist/cores/lambda/lambda-dynamo-stream-handler.js +20 -20
  96. package/dist/cores/lambda/lambda-dynamo-stream-handler.js.map +1 -1
  97. package/dist/cores/lambda/lambda-handler.js +12 -11
  98. package/dist/cores/lambda/lambda-handler.js.map +1 -1
  99. package/dist/cores/lambda/lambda-notification-handler.js +10 -10
  100. package/dist/cores/lambda/lambda-notification-handler.js.map +1 -1
  101. package/dist/cores/lambda/lambda-sns-handler.js +13 -13
  102. package/dist/cores/lambda/lambda-sns-handler.js.map +1 -1
  103. package/dist/cores/lambda/lambda-sqs-handler.js +13 -13
  104. package/dist/cores/lambda/lambda-sqs-handler.js.map +1 -1
  105. package/dist/cores/lambda/lambda-web-handler.d.ts +158 -8
  106. package/dist/cores/lambda/lambda-web-handler.js +330 -119
  107. package/dist/cores/lambda/lambda-web-handler.js.map +1 -1
  108. package/dist/cores/lambda/lambda-wss-handler.js +16 -12
  109. package/dist/cores/lambda/lambda-wss-handler.js.map +1 -1
  110. package/dist/cores/model-manager.js +11 -11
  111. package/dist/cores/model-manager.js.map +1 -1
  112. package/dist/cores/protocol/protocol-service.d.ts +4 -0
  113. package/dist/cores/protocol/protocol-service.js +46 -40
  114. package/dist/cores/protocol/protocol-service.js.map +1 -1
  115. package/dist/cores/proxy-storage-service.js +7 -10
  116. package/dist/cores/proxy-storage-service.js.map +1 -1
  117. package/dist/cores/redis-storage-service.js +13 -13
  118. package/dist/cores/redis-storage-service.js.map +1 -1
  119. package/dist/cores/storage/http-storage-service.d.ts +22 -0
  120. package/dist/cores/storage/http-storage-service.js +129 -0
  121. package/dist/cores/storage/http-storage-service.js.map +1 -0
  122. package/dist/cores/storage/index.d.ts +14 -0
  123. package/dist/cores/storage/index.js +31 -0
  124. package/dist/cores/storage/index.js.map +1 -0
  125. package/dist/cores/storage/model-manager.d.ts +93 -0
  126. package/dist/cores/storage/model-manager.js +192 -0
  127. package/dist/cores/storage/model-manager.js.map +1 -0
  128. package/dist/cores/storage/proxy-storage-service.d.ts +573 -0
  129. package/dist/cores/storage/proxy-storage-service.js +913 -0
  130. package/dist/cores/storage/proxy-storage-service.js.map +1 -0
  131. package/dist/cores/storage/redis-storage-service.d.ts +183 -0
  132. package/dist/cores/storage/redis-storage-service.js +391 -0
  133. package/dist/cores/storage/redis-storage-service.js.map +1 -0
  134. package/dist/cores/storage/storage-service.d.ts +169 -0
  135. package/dist/cores/storage/storage-service.js +374 -0
  136. package/dist/cores/storage/storage-service.js.map +1 -0
  137. package/dist/cores/storage-service.d.ts +1 -1
  138. package/dist/cores/storage-service.js +10 -8
  139. package/dist/cores/storage-service.js.map +1 -1
  140. package/dist/engine/builder.js +27 -20
  141. package/dist/engine/builder.js.map +1 -1
  142. package/dist/engine/engine.js +53 -44
  143. package/dist/engine/engine.js.map +1 -1
  144. package/dist/engine/index.js +8 -4
  145. package/dist/engine/index.js.map +1 -1
  146. package/dist/engine/utilities.d.ts +4 -3
  147. package/dist/engine/utilities.js +32 -37
  148. package/dist/engine/utilities.js.map +1 -1
  149. package/dist/environ.d.ts +2 -2
  150. package/dist/environ.js +20 -10
  151. package/dist/environ.js.map +1 -1
  152. package/dist/exec-cli.js +26 -26
  153. package/dist/exec-cli.js.map +1 -1
  154. package/dist/extended/abstract-service.d.ts +533 -0
  155. package/dist/extended/abstract-service.js +915 -0
  156. package/dist/extended/abstract-service.js.map +1 -0
  157. package/dist/extended/index.d.ts +10 -0
  158. package/dist/extended/index.js +27 -0
  159. package/dist/extended/index.js.map +1 -0
  160. package/dist/helpers/helpers.d.ts +273 -0
  161. package/dist/helpers/helpers.js +613 -0
  162. package/dist/helpers/helpers.js.map +1 -0
  163. package/dist/helpers/index.d.ts +10 -0
  164. package/dist/helpers/index.js +27 -0
  165. package/dist/helpers/index.js.map +1 -0
  166. package/dist/index.d.ts +7 -5
  167. package/dist/index.js +11 -4
  168. package/dist/index.js.map +1 -1
  169. package/dist/lib/dynamo/expressions.js +35 -27
  170. package/dist/lib/dynamo/expressions.js.map +1 -1
  171. package/dist/lib/dynamo/query.js +24 -20
  172. package/dist/lib/dynamo/query.js.map +1 -1
  173. package/dist/lib/dynamo/scan.js +17 -13
  174. package/dist/lib/dynamo/scan.js.map +1 -1
  175. package/dist/lib/dynamo/serializer.js +11 -7
  176. package/dist/lib/dynamo/serializer.js.map +1 -1
  177. package/dist/lib/dynamo/utils.js +19 -14
  178. package/dist/lib/dynamo/utils.js.map +1 -1
  179. package/dist/lib/dynamodb-value.js +3 -3
  180. package/dist/lib/dynamodb-value.js.map +1 -1
  181. package/dist/lib/index.js +6 -2
  182. package/dist/lib/index.js.map +1 -1
  183. package/dist/tools/express.js +21 -15
  184. package/dist/tools/express.js.map +1 -1
  185. package/dist/tools/index.js +6 -2
  186. package/dist/tools/index.js.map +1 -1
  187. package/dist/tools/shared.js +12 -6
  188. package/dist/tools/shared.js.map +1 -1
  189. package/package.json +16 -15
@@ -0,0 +1,239 @@
1
+ /**
2
+ * API headers.
3
+ */
4
+ export interface APIHeaders {
5
+ [key: string]: string;
6
+ }
7
+ /**
8
+ * class: `APIServiceClient`
9
+ * - General API Request Client w/ url like `GET <endpoint>/<id>?/<cmd>?`
10
+ */
11
+ export interface APIServiceClient {
12
+ hello(): string;
13
+ doGet<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
14
+ doPut<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
15
+ doPost<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
16
+ doPatch<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
17
+ doDelete<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
18
+ }
19
+ /**
20
+ * possible method.
21
+ */
22
+ export declare type APIHttpMethod = 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE';
23
+ /**
24
+ * class: `ApiHttpProxy`
25
+ * - http proxy service.
26
+ */
27
+ export interface ApiHttpProxy {
28
+ /**
29
+ * say this service name.
30
+ */
31
+ hello(): string;
32
+ /**
33
+ * call http request via proxy server.
34
+ *
35
+ * url := `<host>/<path?>?<param>`
36
+ *
37
+ * @param method http method
38
+ * @param host host name (or https://~)
39
+ * @param path object id
40
+ * @param param query paramters
41
+ * @param body body
42
+ * @param ctx context
43
+ * @param hash (optional) hash value (valid only for client-side).
44
+ */
45
+ doProxy<T = any>(method: APIHttpMethod, host: string, path?: string, param?: any, body?: any, ctx?: any, hash?: string): Promise<T>;
46
+ }
47
+ /**
48
+ * class: `APIProxyClient`
49
+ * - proxed APIServiceClient
50
+ */
51
+ export declare class APIProxyClient implements APIServiceClient {
52
+ protected service: APIServiceClient;
53
+ constructor(service: APIServiceClient);
54
+ hello: () => string;
55
+ doGet<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
56
+ doPut<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
57
+ doPost<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
58
+ doPatch<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
59
+ doDelete<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
60
+ }
61
+ /**
62
+ * class: `APIService`
63
+ * - use internal http-proxy service due to restriction internet-face in VPC lambda.
64
+ */
65
+ export declare class APIService implements APIServiceClient {
66
+ protected type: string;
67
+ protected endpoint: string;
68
+ protected headers: APIHeaders;
69
+ protected client: APIServiceClient;
70
+ /**
71
+ * create API service.
72
+ *
73
+ * ```js
74
+ * // basic
75
+ * const api = new API('web', 'http://localhost:8081', {});
76
+ * api.doGet('');
77
+ *
78
+ * // via python
79
+ * const api = new API('residents', 'http://localhost:8113', {});
80
+ * api.doGet('123'); // http GET :8113/residents/123
81
+ *
82
+ * // proxy server
83
+ * const api = new API('web', 'http://localhost:8081', {}, null, proxy);
84
+ * api.doGet('');
85
+ * ```
86
+ *
87
+ * @param type type in endpoint
88
+ * @param endpoint base endpoint (support ONLY http, https)
89
+ * @param headers common headers.
90
+ * @param client real api-client to use (or use proxy, or create default)
91
+ * @param proxy proxy-service to use if there is no client (or use backbone server)
92
+ */
93
+ constructor(type: string, endpoint: string, headers?: APIHeaders, client?: APIServiceClient, proxy?: ApiHttpProxy);
94
+ hello: () => string;
95
+ /**
96
+ * helper to make http client
97
+ *
98
+ * @param backbone backbone address like 'http://localhost:8081'
99
+ */
100
+ static buildClient(type: string, endpoint: string, headers?: APIHeaders, backbone?: string, proxy?: ApiHttpProxy): APIServiceClient;
101
+ /**
102
+ * make a client for sub-typed endpoint.
103
+ * @param type sub-type path.
104
+ */
105
+ buildSubTypeClient(type: string, useRecord?: boolean, folder?: string): APIServiceClient;
106
+ /**
107
+ * make api recorder of this service.
108
+ * @param folder base folder (default `./logs`)
109
+ */
110
+ buildRecorder(folder?: string): APIServiceClient;
111
+ /**
112
+ * class: `TypedEndpoint`
113
+ * - by using common proxy, extends endpoint by type.
114
+ * - endpoint := base+'/'+type.
115
+ */
116
+ private static ProxyServiceClient;
117
+ /**
118
+ * use sub-typed endpoint.
119
+ * - extends as endpoint := parent.endpoint + '/' + type
120
+ */
121
+ static SubTypeClient: {
122
+ new (parent: APIServiceClient, type: string): {
123
+ readonly parent: APIServiceClient;
124
+ readonly type: string;
125
+ hello: () => string;
126
+ asCmd: (id: string, cmd?: string) => string;
127
+ doGet(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
128
+ doPut(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
129
+ doPost(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
130
+ doPatch(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
131
+ doDelete(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
132
+ };
133
+ };
134
+ /**
135
+ * recorder of api-http-proxy client.
136
+ */
137
+ static ApiHttpProxyRecorder: {
138
+ new (target: ApiHttpProxy, folder?: string): {
139
+ readonly target: ApiHttpProxy;
140
+ readonly folder: string;
141
+ hello: () => string;
142
+ doProxy<T = any>(method: APIHttpMethod, host: string, path?: string, param?: any, body?: any, context?: any, hash?: string): Promise<T>;
143
+ };
144
+ next: number;
145
+ };
146
+ /**
147
+ * recorder of api-service client.
148
+ */
149
+ static APIServiceClientRecorder: {
150
+ new (target: APIServiceClient, endpoint: string, folder?: string): {
151
+ readonly target: APIServiceClient;
152
+ readonly endpoint: string;
153
+ readonly folder: string;
154
+ hello: () => string;
155
+ doRecord(method: APIHttpMethod, id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
156
+ doGet(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
157
+ doPut(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
158
+ doPost(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
159
+ doPatch(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
160
+ doDelete(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<any>;
161
+ };
162
+ next: number;
163
+ };
164
+ /**
165
+ * GET HOST/PATH?$param
166
+ */
167
+ doGet: (id: string, cmd?: string, $param?: any, $body?: any, hash?: string) => Promise<any>;
168
+ /**
169
+ * PUT HOST/PATH?$param
170
+ */
171
+ doPut: (id: string, cmd?: string, $param?: any, $body?: any, hash?: string) => Promise<any>;
172
+ /**
173
+ * POST HOST/PATH?$param
174
+ */
175
+ doPost: (id: string, cmd?: string, $param?: any, $body?: any, hash?: string) => Promise<any>;
176
+ /**
177
+ * PATCH HOST/PATH?$param
178
+ */
179
+ doPatch: (id: string, cmd?: string, $param?: any, $body?: any, hash?: string) => Promise<any>;
180
+ /**
181
+ * DELETE HOST/PATH?$param
182
+ */
183
+ doDelete: (id: string, cmd?: string, $param?: any, $body?: any, hash?: string) => Promise<any>;
184
+ }
185
+ /**
186
+ * create http-web-proxy agent which using endpoint as proxy server.
187
+ *
188
+ * # as cases.
189
+ * as proxy agent: GET <endpoint>/<host?>/<path?>
190
+ * as direct agent: GET <endpoint>/<id?>/<cmd?>
191
+ *
192
+ * @param name client-name
193
+ * @param endpoint service url (or backbone proxy-url)
194
+ * @param headers headers
195
+ * @param encoder path encoder (default encodeURIComponent)
196
+ * @param relayHeaderKey relay-key in headers for proxy.
197
+ * @param resultKey resultKey in response
198
+ */
199
+ export declare const createHttpWebProxy: (name: string, endpoint: string, headers?: APIHeaders, encoder?: (name: string, path: string) => string, relayHeaderKey?: string, resultKey?: string) => ApiHttpProxy;
200
+ /** ********************************************************************************************************************
201
+ * MOCKS API-SERVICE
202
+ ** ********************************************************************************************************************/
203
+ /**
204
+ * class: `MocksAPIService`
205
+ * - use <mock>.json file in `./data/mocks/` instead of real http request.
206
+ * - it redirect to url like `endpoint/type/id/cmd`
207
+ *
208
+ * ```ts
209
+ * // json format
210
+ * {
211
+ * param: { // input format
212
+ * method: string;
213
+ * endpoint: string;
214
+ * id?: string;
215
+ * cmd?: string;
216
+ * },
217
+ * data: { // response data
218
+ * ...
219
+ * },
220
+ * error?: string; // in case of error.
221
+ * }
222
+ * ```
223
+ */
224
+ export declare class MocksAPIService implements ApiHttpProxy, APIServiceClient {
225
+ private $map;
226
+ private type;
227
+ private endpoint;
228
+ constructor(type: string, endpoint: string);
229
+ protected loadSync(): void;
230
+ protected asPath: (id?: string, cmd?: string) => string;
231
+ doProxy<T = any>(method: APIHttpMethod, type: string, path: string, param?: any, body?: any, ctx?: any, hash?: string): Promise<T>;
232
+ protected na: (a: any, x: string, y: string) => string;
233
+ hello: () => string;
234
+ doGet<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
235
+ doPut<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
236
+ doPost<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
237
+ doPatch<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
238
+ doDelete<T = any>(id: string, cmd?: string, param?: any, body?: any, hash?: string): Promise<T>;
239
+ }