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,273 @@
1
+ import { GeneralItem, Incrementable, SearchBody } from '../core-types';
2
+ import elasticsearch from '@elastic/elasticsearch';
3
+ export declare type SearchType = 'query_then_fetch' | 'dfs_query_then_fetch';
4
+ export declare type SearchResponse = any;
5
+ /**
6
+ * options for construction.
7
+ */
8
+ export interface Elastic6Option {
9
+ /**
10
+ * endpoint url of ES6
11
+ */
12
+ endpoint: string;
13
+ /**
14
+ * index-name
15
+ */
16
+ indexName: string;
17
+ /**
18
+ * document type (default as `_doc` in ES6)
19
+ * - it must be `_doc` since ES6.x
20
+ */
21
+ docType?: string;
22
+ /**
23
+ * id-name (optional if time-seriese)
24
+ */
25
+ idName?: string;
26
+ /**
27
+ * is TIMESERIES data?
28
+ */
29
+ timeSeries?: boolean;
30
+ /**
31
+ * (optional) version of engine.
32
+ * - (default) 6.8
33
+ */
34
+ version?: string;
35
+ /**
36
+ * fields to provide autocomplete(Search-as-You-Type) feature
37
+ */
38
+ autocompleteFields?: string[];
39
+ }
40
+ /**
41
+ * common type of item
42
+ */
43
+ export interface Elastic6Item extends GeneralItem {
44
+ _id?: string;
45
+ _version?: number;
46
+ _score?: number;
47
+ }
48
+ /**
49
+ * class: `Elastic6Service`
50
+ * - basic CRUD service for Elastic Search 6
51
+ */
52
+ export declare class Elastic6Service<T extends Elastic6Item = any> {
53
+ static readonly DECOMPOSED_FIELD = "_decomposed";
54
+ static readonly QWERTY_FIELD = "_qwerty";
55
+ protected _options: Elastic6Option;
56
+ readonly _client: elasticsearch.Client;
57
+ /**
58
+ * simple instance maker.
59
+ *
60
+ * ```js
61
+ * const { client } = Elastic6Service.instance(endpoint);
62
+ * ```
63
+ *
64
+ * @param endpoint service-url
65
+ * @param version Elasticsearch version (default: '6.8')
66
+ * @see https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/16.x/configuration.html
67
+ */
68
+ static instance(endpoint: string): {
69
+ client: elasticsearch.Client;
70
+ };
71
+ /**
72
+ * default constuctor w/ options.
73
+ * @param options { endpoint, indexName } is required.
74
+ */
75
+ constructor(options: Elastic6Option);
76
+ /**
77
+ * say hello of identity.
78
+ */
79
+ hello: () => string;
80
+ /**
81
+ * get the client instance.
82
+ */
83
+ get client(): elasticsearch.Client;
84
+ /**
85
+ * get the current options.
86
+ */
87
+ get options(): Elastic6Option;
88
+ get version(): number;
89
+ /**
90
+ * list of index
91
+ */
92
+ listIndices(): Promise<{
93
+ list: {
94
+ pri: number;
95
+ rep: number;
96
+ docsCount: number;
97
+ docsDeleted: number;
98
+ health: string;
99
+ index: string;
100
+ status: string;
101
+ uuid: string;
102
+ priStoreSize: string;
103
+ storeSize: string;
104
+ }[];
105
+ }>;
106
+ /**
107
+ * find the index by name
108
+ */
109
+ findIndex(indexName?: string): Promise<{
110
+ pri: number;
111
+ rep: number;
112
+ docsCount: number;
113
+ docsDeleted: number;
114
+ health: string;
115
+ index: string;
116
+ status: string;
117
+ uuid: string;
118
+ priStoreSize: string;
119
+ storeSize: string;
120
+ }>;
121
+ /**
122
+ * create index by name
123
+ *
124
+ * @param settings creating settings
125
+ */
126
+ createIndex(settings?: any): Promise<{
127
+ status: any;
128
+ index: string;
129
+ acknowledged: any;
130
+ }>;
131
+ /**
132
+ * destroy search index
133
+ */
134
+ destroyIndex(): Promise<{
135
+ status: any;
136
+ index: string;
137
+ acknowledged: any;
138
+ }>;
139
+ /**
140
+ * refresh search index - refresh index to make all items searchable
141
+ */
142
+ refreshIndex(): Promise<any>;
143
+ /**
144
+ * flush search index - force store changes into search index immediately
145
+ */
146
+ flushIndex(): Promise<any>;
147
+ /**
148
+ * describe `settings` and `mappings` of index.
149
+ */
150
+ describe(): Promise<{
151
+ settings: any;
152
+ mappings: any;
153
+ }>;
154
+ /**
155
+ * save single item
156
+ *
157
+ * @param id id
158
+ * @param item item to save
159
+ * @param type document type (default: doc-type given at construction time)
160
+ */
161
+ saveItem(id: string, item: T, type?: string): Promise<T>;
162
+ /**
163
+ * push item for time-series data.
164
+ *
165
+ * @param item item to push
166
+ */
167
+ pushItem(item: T, type?: string): Promise<T>;
168
+ /**
169
+ * read item with projections
170
+ *
171
+ * @param id item-id
172
+ * @param views projections
173
+ */
174
+ readItem(id: string, views?: string[] | object): Promise<T>;
175
+ /**
176
+ * delete item with projections
177
+ *
178
+ * @param id item-id
179
+ */
180
+ deleteItem(id: string): Promise<T>;
181
+ /**
182
+ * update item
183
+ *
184
+ * @param id item-id
185
+ * @param item item to update
186
+ */
187
+ updateItem(id: string, item: T, increments?: Incrementable): Promise<T>;
188
+ /**
189
+ * run search and get the raw response.
190
+ */
191
+ searchRaw(body: SearchBody, searchType?: SearchType): Promise<SearchResponse>;
192
+ /**
193
+ * run search, and get the formatmted response.
194
+ */
195
+ search(body: SearchBody, searchType?: SearchType): Promise<{
196
+ total: any;
197
+ list: any;
198
+ last: any;
199
+ aggregations: any;
200
+ }>;
201
+ /**
202
+ * prepare default setting
203
+ * - migrated from engine-v2.
204
+ *
205
+ * @param docType document type name
206
+ * @param idName id-name
207
+ * @param shards number of shards (default 4)
208
+ * @param replicas number of replicas (default 1)
209
+ * @param timeSeries flag of TIMESERIES (default false)
210
+ */
211
+ static prepareSettings(params: {
212
+ docType: string;
213
+ idName: string;
214
+ version?: string;
215
+ timeSeries?: boolean;
216
+ shards?: number;
217
+ replicas?: number;
218
+ }): any;
219
+ /**
220
+ * generate autocomplete fields into the item body to be indexed
221
+ * @param body item body to be saved into ES6 index
222
+ * @private
223
+ */
224
+ private popullateAutocompleteFields;
225
+ }
226
+ interface ErrorReasonDetail {
227
+ status: number;
228
+ type: string;
229
+ reason?: string;
230
+ cause?: any;
231
+ }
232
+ interface ErrorReason {
233
+ status: number;
234
+ message: string;
235
+ reason: ErrorReasonDetail;
236
+ }
237
+ /**
238
+ * error samples
239
+ */
240
+ export declare const $ERROR: {
241
+ asJson: (e: any) => any;
242
+ throwAsJson: (e: any) => never;
243
+ parseMeta: <T extends {
244
+ [key: string]: any;
245
+ type?: string;
246
+ value?: any;
247
+ error?: string;
248
+ list?: any[];
249
+ }>(meta: any) => T;
250
+ asError: (e: any) => ErrorReason;
251
+ handler: (name: string, cb?: (e: Error, E?: ErrorReason) => any) => (e: any) => any;
252
+ };
253
+ /** ****************************************************************************************************************
254
+ * Dummy Elastic6 Service
255
+ ** ****************************************************************************************************************/
256
+ /**
257
+ * class: `DummyElastic6Service`
258
+ * - service in-memory dummy data
259
+ */
260
+ export declare class DummyElastic6Service<T extends GeneralItem> extends Elastic6Service<T> {
261
+ constructor(dataFile: string, options: Elastic6Option);
262
+ private buffer;
263
+ load(data: T[]): void;
264
+ /**
265
+ * say hello()
266
+ */
267
+ hello: () => string;
268
+ readItem(id: string): Promise<T>;
269
+ saveItem(id: string, item: T): Promise<T>;
270
+ deleteItem(id: string, sort?: string | number): Promise<T>;
271
+ updateItem(id: string, updates: T, increments?: Incrementable): Promise<T>;
272
+ }
273
+ export {};