lemon-core 4.2.7 → 5.0.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.
Files changed (167) hide show
  1. package/README.md +128 -2
  2. package/dist/common/lemon-error.d.ts +34 -0
  3. package/dist/common/lemon-error.js +52 -0
  4. package/dist/common/lemon-error.js.map +1 -0
  5. package/dist/controllers/general-api-controller.d.ts +7 -0
  6. package/dist/controllers/general-api-controller.js +7 -0
  7. package/dist/controllers/general-api-controller.js.map +1 -1
  8. package/dist/cores/api/api-service.js +10 -43
  9. package/dist/cores/api/api-service.js.map +1 -1
  10. package/dist/cores/aws/aws-kms-service.d.ts +13 -5
  11. package/dist/cores/aws/aws-kms-service.js +23 -9
  12. package/dist/cores/aws/aws-kms-service.js.map +1 -1
  13. package/dist/cores/aws/aws-s3-service.d.ts +30 -4
  14. package/dist/cores/aws/aws-s3-service.js +35 -15
  15. package/dist/cores/aws/aws-s3-service.js.map +1 -1
  16. package/dist/cores/aws/aws-sns-service.js +59 -9
  17. package/dist/cores/aws/aws-sns-service.js.map +1 -1
  18. package/dist/cores/aws/aws-sqs-service.d.ts +1 -1
  19. package/dist/cores/aws/aws-sqs-service.js +54 -12
  20. package/dist/cores/aws/aws-sqs-service.js.map +1 -1
  21. package/dist/cores/cache/cache-service.d.ts +10 -9
  22. package/dist/cores/cache/cache-service.js +9 -346
  23. package/dist/cores/cache/cache-service.js.map +1 -1
  24. package/dist/cores/config/config-service.d.ts +3 -15
  25. package/dist/cores/config/config-service.js +5 -34
  26. package/dist/cores/config/config-service.js.map +1 -1
  27. package/dist/cores/dynamo/dynamo-query-service.js +42 -2
  28. package/dist/cores/dynamo/dynamo-query-service.js.map +1 -1
  29. package/dist/cores/dynamo/dynamo-scan-service.js +42 -2
  30. package/dist/cores/dynamo/dynamo-scan-service.js.map +1 -1
  31. package/dist/cores/dynamo/dynamo-service.d.ts +45 -14
  32. package/dist/cores/dynamo/dynamo-service.js +48 -21
  33. package/dist/cores/dynamo/dynamo-service.js.map +1 -1
  34. package/dist/cores/dynamo/tools/expressions.js +32 -22
  35. package/dist/cores/dynamo/tools/expressions.js.map +1 -1
  36. package/dist/cores/dynamo/tools/lang.d.ts +30 -0
  37. package/dist/cores/dynamo/tools/lang.js +75 -0
  38. package/dist/cores/dynamo/tools/lang.js.map +1 -0
  39. package/dist/cores/dynamo/tools/query.js +20 -21
  40. package/dist/cores/dynamo/tools/query.js.map +1 -1
  41. package/dist/cores/dynamo/tools/scan.js +15 -16
  42. package/dist/cores/dynamo/tools/scan.js.map +1 -1
  43. package/dist/cores/dynamo/tools/serializer.js +40 -38
  44. package/dist/cores/dynamo/tools/serializer.js.map +1 -1
  45. package/dist/cores/dynamo/tools/utils.d.ts +6 -2
  46. package/dist/cores/dynamo/tools/utils.js +11 -8
  47. package/dist/cores/dynamo/tools/utils.js.map +1 -1
  48. package/dist/cores/elastic/elastic6-query-service.d.ts +1 -104
  49. package/dist/cores/elastic/elastic6-query-service.js +15 -489
  50. package/dist/cores/elastic/elastic6-query-service.js.map +1 -1
  51. package/dist/cores/elastic/elastic6-service.d.ts +1 -482
  52. package/dist/cores/elastic/elastic6-service.js +15 -1153
  53. package/dist/cores/elastic/elastic6-service.js.map +1 -1
  54. package/dist/cores/elastic/index.d.ts +2 -2
  55. package/dist/cores/elastic/index.js +3 -2
  56. package/dist/cores/elastic/index.js.map +1 -1
  57. package/dist/cores/elastic/os2-query-service.d.ts +104 -0
  58. package/dist/cores/elastic/os2-query-service.js +495 -0
  59. package/dist/cores/elastic/os2-query-service.js.map +1 -0
  60. package/dist/cores/elastic/os2-service.d.ts +372 -0
  61. package/dist/cores/elastic/os2-service.js +943 -0
  62. package/dist/cores/elastic/os2-service.js.map +1 -0
  63. package/dist/cores/index.d.ts +6 -1
  64. package/dist/cores/index.js +9 -2
  65. package/dist/cores/index.js.map +1 -1
  66. package/dist/cores/lambda/index.js +2 -1
  67. package/dist/cores/lambda/index.js.map +1 -1
  68. package/dist/cores/lambda/lambda-cron-handler.d.ts +1 -0
  69. package/dist/cores/lambda/lambda-cron-handler.js +5 -1
  70. package/dist/cores/lambda/lambda-cron-handler.js.map +1 -1
  71. package/dist/cores/lambda/lambda-dynamo-stream-handler.d.ts +5 -4
  72. package/dist/cores/lambda/lambda-dynamo-stream-handler.js +18 -5
  73. package/dist/cores/lambda/lambda-dynamo-stream-handler.js.map +1 -1
  74. package/dist/cores/lambda/lambda-handler.d.ts +22 -2
  75. package/dist/cores/lambda/lambda-handler.js +85 -23
  76. package/dist/cores/lambda/lambda-handler.js.map +1 -1
  77. package/dist/cores/lambda/lambda-sns-handler.d.ts +1 -0
  78. package/dist/cores/lambda/lambda-sns-handler.js +5 -0
  79. package/dist/cores/lambda/lambda-sns-handler.js.map +1 -1
  80. package/dist/cores/lambda/lambda-sqs-handler.d.ts +1 -0
  81. package/dist/cores/lambda/lambda-sqs-handler.js +20 -5
  82. package/dist/cores/lambda/lambda-sqs-handler.js.map +1 -1
  83. package/dist/cores/lambda/lambda-web-handler.d.ts +10 -0
  84. package/dist/cores/lambda/lambda-web-handler.js +107 -41
  85. package/dist/cores/lambda/lambda-web-handler.js.map +1 -1
  86. package/dist/cores/protocol/aws-lambda-helper.js +58 -11
  87. package/dist/cores/protocol/aws-lambda-helper.js.map +1 -1
  88. package/dist/cores/protocol/index.js +3 -0
  89. package/dist/cores/protocol/index.js.map +1 -1
  90. package/dist/cores/protocol/protocol-service.d.ts +26 -5
  91. package/dist/cores/protocol/protocol-service.js +42 -12
  92. package/dist/cores/protocol/protocol-service.js.map +1 -1
  93. package/dist/cores/protocol/protocol-sign.d.ts +72 -0
  94. package/dist/cores/protocol/protocol-sign.js +194 -0
  95. package/dist/cores/protocol/protocol-sign.js.map +1 -0
  96. package/dist/cores/storage/index.d.ts +0 -1
  97. package/dist/cores/storage/index.js +0 -1
  98. package/dist/cores/storage/index.js.map +1 -1
  99. package/dist/cores/storage/model-fields.d.ts +7 -0
  100. package/dist/cores/storage/model-fields.js +21 -0
  101. package/dist/cores/storage/model-fields.js.map +1 -0
  102. package/dist/cores/storage/model-manager.d.ts +3 -2
  103. package/dist/cores/storage/model-manager.js +7 -3
  104. package/dist/cores/storage/model-manager.js.map +1 -1
  105. package/dist/engine/builder.js +20 -2
  106. package/dist/engine/builder.js.map +1 -1
  107. package/dist/engine/engine.d.ts +2 -2
  108. package/dist/engine/engine.js +4 -4
  109. package/dist/engine/engine.js.map +1 -1
  110. package/dist/engine/utilities.d.ts +11 -12
  111. package/dist/engine/utilities.js +30 -82
  112. package/dist/engine/utilities.js.map +1 -1
  113. package/dist/environ.d.ts +0 -6
  114. package/dist/environ.js +1 -12
  115. package/dist/environ.js.map +1 -1
  116. package/dist/esm/index.mjs +140 -0
  117. package/dist/esm/testing.mjs +12 -0
  118. package/dist/extended/abstract-service.d.ts +48 -139
  119. package/dist/extended/abstract-service.js +46 -382
  120. package/dist/extended/abstract-service.js.map +1 -1
  121. package/dist/extended/cores/abstract-controllers.d.ts +170 -0
  122. package/dist/extended/cores/abstract-controllers.js +533 -0
  123. package/dist/extended/cores/abstract-controllers.js.map +1 -0
  124. package/dist/extended/cores/abstract-rest-apis.d.ts +142 -0
  125. package/dist/extended/cores/abstract-rest-apis.js +203 -0
  126. package/dist/extended/cores/abstract-rest-apis.js.map +1 -0
  127. package/dist/extended/cores/abstract-services.d.ts +771 -0
  128. package/dist/extended/cores/abstract-services.js +2042 -0
  129. package/dist/extended/cores/abstract-services.js.map +1 -0
  130. package/dist/extended/cores/browser-cache.d.ts +2 -0
  131. package/dist/extended/cores/browser-cache.js +34 -0
  132. package/dist/extended/cores/browser-cache.js.map +1 -0
  133. package/dist/extended/cores/commons.d.ts +20 -0
  134. package/dist/extended/cores/commons.js +31 -0
  135. package/dist/extended/cores/commons.js.map +1 -0
  136. package/dist/extended/cores/index.d.ts +15 -0
  137. package/dist/extended/cores/index.js +32 -0
  138. package/dist/extended/cores/index.js.map +1 -0
  139. package/dist/extended/cores/types.d.ts +14 -0
  140. package/dist/extended/cores/types.js +31 -0
  141. package/dist/extended/cores/types.js.map +1 -0
  142. package/dist/helpers/helpers.d.ts +10 -5
  143. package/dist/helpers/helpers.js +46 -58
  144. package/dist/helpers/helpers.js.map +1 -1
  145. package/dist/helpers/types.d.ts +22 -10
  146. package/dist/index.d.ts +4 -0
  147. package/dist/index.js +12 -1
  148. package/dist/index.js.map +1 -1
  149. package/dist/lib/http-fetch.d.ts +54 -0
  150. package/dist/lib/http-fetch.js +133 -0
  151. package/dist/lib/http-fetch.js.map +1 -0
  152. package/dist/lib/lazy.d.ts +22 -0
  153. package/dist/lib/lazy.js +54 -0
  154. package/dist/lib/lazy.js.map +1 -0
  155. package/dist/lib/perf.d.ts +35 -0
  156. package/dist/lib/perf.js +52 -0
  157. package/dist/lib/perf.js.map +1 -0
  158. package/dist/tools/tools.d.ts +15 -3
  159. package/dist/tools/tools.js +21 -4
  160. package/dist/tools/tools.js.map +1 -1
  161. package/package.json +96 -39
  162. package/dist/cores/storage/redis-storage-service.d.ts +0 -183
  163. package/dist/cores/storage/redis-storage-service.js +0 -377
  164. package/dist/cores/storage/redis-storage-service.js.map +0 -1
  165. package/dist/generated/field-registry.d.ts +0 -10
  166. package/dist/generated/field-registry.js +0 -17
  167. package/dist/generated/field-registry.js.map +0 -1
@@ -0,0 +1,771 @@
1
+ import { SearchType, OS2CoreService, OS2BaseOption, OS2QueryService } from '../../cores/';
2
+ import { DynamoScanFilter, ApiHttpProxy } from '../../cores/';
3
+ import { OS2Item } from '../../cores/';
4
+ import type { Client } from '@opensearch-project/opensearch';
5
+ import { OS2Synchronizer, CoreManager, CoreService, SearchResult, ManagerProxy, AbstractProxy, AbstractOS2Instance, OS2ConstructParams } from '../abstract-service';
6
+ export { sourceToItem } from '../abstract-service';
7
+ import { Incrementable, CoreModel, SearchBody, SearchQuery, NextContext, NextIdentity, SortTerm, SimpleSet, GeneralItem } from 'lemon-model';
8
+ import { BulkItemsResult, IdentityToken, ListResult, PaginateParam } from './types';
9
+ import { CrendentialForAWS } from '../../environ';
10
+ import { ModelClass } from '../../cores/storage/model-fields';
11
+ export type SearchParam<T> = T & {
12
+ [key: string]: string | number;
13
+ };
14
+ /**
15
+ * lookup table for common types.
16
+ */
17
+ declare const $LUT: {
18
+ /**
19
+ * type: `CanDoAction`
20
+ */
21
+ CanDoAction: {
22
+ list: string;
23
+ read: string;
24
+ create: string;
25
+ update: string;
26
+ delete: string;
27
+ };
28
+ };
29
+ /**
30
+ * type: `CanDoActionType`
31
+ */
32
+ export type CanDoActionType = keyof typeof $LUT.CanDoAction;
33
+ /**
34
+ * Optional parameters for `canDo()`
35
+ */
36
+ export interface CanDoOptions {
37
+ /** error scope to print */
38
+ errScope?: string;
39
+ /** flag to throw error if not allowed (default false) */
40
+ throwable?: boolean;
41
+ /** flag to use session (default true) */
42
+ useSession?: boolean;
43
+ /** current context to override */
44
+ context?: NextContext;
45
+ }
46
+ /**
47
+ * type: `ScanLastParams`
48
+ */
49
+ export interface ScanLastParams<T = any> {
50
+ /** last cursor during scan */
51
+ last?: T;
52
+ /** (optional) limit to 1x scan */
53
+ limit?: number;
54
+ /** filter to scan */
55
+ filter?: DynamoScanFilter;
56
+ }
57
+ /**
58
+ * type: `ScanLastResult`
59
+ */
60
+ export interface ScanLastResult<T = any> extends ListResult<T> {
61
+ /** count of scan */
62
+ count?: number;
63
+ /** (optinoal) last of scan if there are more */
64
+ last?: any;
65
+ }
66
+ /**
67
+ * type: `doSyncScanLastResult`
68
+ *
69
+ * @param .list can be BulkResponseItem[]
70
+ */
71
+ export interface DoSyncScanLastResult<T = any> extends ListResult<T> {
72
+ /** count of scan */
73
+ count?: number;
74
+ /** (optinoal) last of scan if there are more */
75
+ last?: any;
76
+ /** errors of saveBulk */
77
+ errors?: boolean[];
78
+ /** statusCodes of saveBulk */
79
+ statusCodes?: number[];
80
+ }
81
+ /**
82
+ * class: `MyCoreService`
83
+ * - CoreService의 공통 부분을 채워넣는다.
84
+ */
85
+ export declare abstract class MyCoreService<Model extends CoreModel<ModelType>, ModelType extends string, Proxy extends MyCoreProxy<ModelType, any>> extends CoreService<Model, ModelType> {
86
+ constructor(tableName?: string, ns?: string);
87
+ /**
88
+ * make proxy instance w/ this service.
89
+ */
90
+ abstract createProxy(context: NextContext): Proxy;
91
+ /**
92
+ * make proxy, and use callback to handle.
93
+ * - it will save automatically on success.
94
+ * - v5: on exception it saves only when `options.saveOnError` is true (default false, B5 § 6.7).
95
+ */
96
+ guardProxy: <T>(context: NextContext, callback: (proxy: Proxy) => Promise<T>, options?: {
97
+ saveOnError?: boolean;
98
+ }) => Promise<T>;
99
+ /**
100
+ * run search (via `$OS2`)
101
+ * - override this to hide `$OS2`
102
+ */
103
+ doSearch<T>(body: SearchBody): Promise<SearchResult<T>>;
104
+ /**
105
+ * check if using useSession from environ.
106
+ */
107
+ isUseSession(): boolean;
108
+ /**
109
+ * check if search-engine is supportable
110
+ * @returns
111
+ */
112
+ hasSearchEngine(): boolean;
113
+ }
114
+ /**
115
+ * class: `CoreManager`
116
+ * - shared core manager for all model
117
+ *
118
+ * @abstract
119
+ */
120
+ export declare abstract class MyCoreManager<Model extends CoreModel<ModelType>, ModelType extends string, Service extends MyCoreService<Model, ModelType, any>> extends CoreManager<Model, ModelType, Service> {
121
+ readonly options?: {
122
+ /** enable to sync with the search engine (v5 default false — B5 § 6.7) */
123
+ enableSync?: boolean;
124
+ /** unique field */
125
+ uniqueField?: string;
126
+ /** initial next-id number of auto-seq (default 1000000) */
127
+ initialNo?: number;
128
+ };
129
+ /**
130
+ * namespace for log(print)
131
+ */
132
+ protected readonly logNS: string;
133
+ /**
134
+ * constructor
135
+ * @protected
136
+ */
137
+ protected constructor(type: ModelType, parent: Service, fields: string[] | ModelClass, options?: {
138
+ /** enable to sync with the search engine (v5 default false — B5 § 6.7) */
139
+ enableSync?: boolean;
140
+ /** unique field */
141
+ uniqueField?: string;
142
+ /** initial next-id number of auto-seq (default 1000000) */
143
+ initialNo?: number;
144
+ });
145
+ /**
146
+ * get the next sequenced no from `initialNo` (default 1000000)
147
+ *
148
+ * @param step (optional) next-step (>= 0)
149
+ * @returns next seq-no
150
+ */
151
+ nextId(step?: number): Promise<number>;
152
+ /**
153
+ * build default model for creation.
154
+ */
155
+ buildDefault(id: string): Model;
156
+ /**
157
+ * validate the request's model before saving.
158
+ * - `$org`에 따라서, 신규 생성인지 업데이트인지 구분 가능함.
159
+ *
160
+ * @param model request's model
161
+ * @param $org (optional) the origin model (valid ONLY if 업데이트)
162
+ * @returns validatated model.
163
+ */
164
+ validateModel(model: Model, $org?: Model): Promise<Model>;
165
+ /**
166
+ * find lookup-model (improved @2022)
167
+ * - lookup to `auto-id` by key.
168
+ * - if not exits, make the new id (auto-seq) and store the key.
169
+ * - type should be like `#<type>`.
170
+ *
171
+ * NOTE! must to support race condition.
172
+ *
173
+ * @param key any string
174
+ */
175
+ findLookup$(key: string | number, params?: {
176
+ /** rate to reset lock (default 0.9) */
177
+ resetRate?: number;
178
+ /** flag to use sha256 for hash (default true) */
179
+ useSha256?: boolean;
180
+ /** use meta to save lookup info (default false) */
181
+ isUseMeta?: boolean;
182
+ /** throw if lookup is not found (default false) - useful to check if exists of key */
183
+ throwable?: boolean;
184
+ }): Promise<Model>;
185
+ /**
186
+ * build search query from filters
187
+ */
188
+ buildQuery<T extends Model>(param: PaginateParam, model?: SearchParam<T>, options?: {
189
+ errScope?: string;
190
+ hidden?: boolean | number;
191
+ aggregation?: string;
192
+ aggrLimit?: number;
193
+ }): SearchBody;
194
+ /**
195
+ * Query 기준 추가하기.
196
+ */
197
+ addQueryTerm(body: SearchBody, term: 'filter' | 'must' | 'must_not', query: SearchQuery | SearchQuery[]): SearchBody;
198
+ /**
199
+ * sort 기준 추가하기.
200
+ */
201
+ addSortTerm(body: SearchBody, param?: PaginateParam): SearchBody;
202
+ /**
203
+ * build filter for scan.
204
+ * @returns DynamoScanFilter
205
+ */
206
+ buildScanFilter(params?: SearchParam<Model>): DynamoScanFilter;
207
+ /**
208
+ * execute scan with filter.
209
+ *
210
+ * @param $page
211
+ * @param filter
212
+ * @returns
213
+ */
214
+ doScan<R = {
215
+ key: string;
216
+ count: number;
217
+ }>($page: PaginateParam, filter?: DynamoScanFilter): Promise<ListResult<Model, R>>;
218
+ /**
219
+ * execute scan-last with filter.
220
+ *
221
+ * @param $param ScanLastParams
222
+ * @returns
223
+ */
224
+ doScanLast($param: ScanLastParams): Promise<ScanLastResult<Model>>;
225
+ /**
226
+ * basic ElasticSearch Query.
227
+ * you can override this method for customization.
228
+ *
229
+ * @param limit pagination limit (default 10)
230
+ * @param page page number (starts from 0)
231
+ * @param filters model filters
232
+ * @param param (optional) addtion params
233
+ */
234
+ list<R = {
235
+ key: string;
236
+ count: number;
237
+ }>($page: PaginateParam, $param?: SearchParam<Model>, options?: {
238
+ hidden?: boolean | number;
239
+ aggregation?: string;
240
+ }): Promise<ListResult<Model, R>>;
241
+ /**
242
+ * list of projection fields
243
+ * - ONLY fields defined in `goods-model`
244
+ * - 모델별 추가 필드목록만 추림
245
+ */
246
+ listProjections(params?: {
247
+ includes?: string[];
248
+ excludes?: string[];
249
+ sorted?: boolean;
250
+ }): string[];
251
+ /**
252
+ * fetch all list of goods for filtering.
253
+ *
254
+ * @override if required.
255
+ */
256
+ buildSearchAll(params?: {
257
+ size?: number;
258
+ }, sort?: SortTerm): SearchBody;
259
+ /**
260
+ * sync by scan with last record.
261
+ *
262
+ * **[좋은코드]**
263
+ * 1. 보기 좋아야함; 변수이름, 로직도 잘보이고, 함수의 목적
264
+ * 2. 테스트 가능한 코드 (또는 테스트가된 코드)
265
+ * - Unit Test: 테스트 가능한 최소단위 (함수.. 블럭)
266
+ * - Integrated Test: Group of Units (ex: my_sequence)
267
+ *
268
+ * @param $param
269
+ * @param options
270
+ * @returns
271
+ */
272
+ doSyncScanLast($param: ScanLastParams, options?: {
273
+ /** chunk-size of bulk (default: 10) */
274
+ size?: number;
275
+ }): Promise<DoSyncScanLastResult>;
276
+ }
277
+ /**
278
+ * class: `MyCoreProxy`
279
+ * - common parent of proxy.
280
+ */
281
+ export declare class MyCoreProxy<U extends string, MyService extends MyCoreService<CoreModel<any>, any, any>> extends AbstractProxy<any, MyService> {
282
+ readonly managerProxies: {
283
+ [propKey: string]: MyManagerProxy<any, any, MyService>;
284
+ };
285
+ constructor(context: NextContext, service: MyService, cacheScope?: string);
286
+ /**
287
+ * check if in mocks mode.
288
+ * - override this to set mocks.
289
+ *
290
+ * @returns boolean
291
+ */
292
+ isMocks(): boolean;
293
+ /**
294
+ * register this.
295
+ */
296
+ register(mgr: MyManagerProxy<any, any, MyService>): number;
297
+ /**
298
+ * add into proxy lookup.
299
+ */
300
+ protected addManagerProxy(modelType: U, proxy: MyManagerProxy<any, any, MyService>): void;
301
+ /**
302
+ * get from lookup table.
303
+ */
304
+ getManagerProxy<Model, ModelManager extends MyCoreManager<Model, any, MyService>>(modelType: U): MyManagerProxy<Model, ModelManager, MyService>;
305
+ /**
306
+ * @override fetchIdentityAccess
307
+ * @deprecated not supported.
308
+ */
309
+ protected fetchIdentityAccess(identityId: string, domain?: string): Promise<any>;
310
+ /**
311
+ * get the `identity-token` (as session) from current req-context.
312
+ * - 1차 호출(front에서) 에서는 이 세션이 꼭 필요함.
313
+ * - 2차 호출(protocol이용) 에서는 선택사항으로, 조절가능해야함! (#TODO - 이걸 어떻게 구불할것인가?)
314
+ * - 로컬) 로컬 개발에서는 시뮬레이션 방법은 #TODO
315
+ *
316
+ * @param options.throwable flag to throw (default true)
317
+ */
318
+ getCurrentSession(options?: {
319
+ /** (default true) */
320
+ throwable?: boolean;
321
+ /** (default true) */
322
+ normalize?: boolean;
323
+ /** (default true) */
324
+ useSession?: string | boolean;
325
+ /** (optional) env.LOCAL_ACCOUNT */
326
+ LOCAL_ACCOUNT?: string;
327
+ /** (optional) env.USE_SESSION */
328
+ USE_SESSION?: string;
329
+ /** (optional) next context to override */
330
+ context?: NextContext;
331
+ }): IdentityToken;
332
+ /**
333
+ * find the current identity-id from context.
334
+ * - or, use env[LOCAL_ACCOUNT]
335
+ */
336
+ asCurrentIdentityId: (context?: NextContext) => string | null;
337
+ /**
338
+ * assert context condition.
339
+ */
340
+ assertContext(params?: {
341
+ /** call in local */
342
+ isLocal?: boolean;
343
+ /** authed by cognito identity-provider */
344
+ isAuthed?: boolean;
345
+ /** signed call with access-key */
346
+ isSigned?: boolean;
347
+ /** check if session has role */
348
+ hasRole?: string;
349
+ },
350
+ /** (optional) */
351
+ options?: {
352
+ /** (optional) throwable to throw error if error */
353
+ throwable?: boolean;
354
+ /** (optional) errScope to override in error */
355
+ errScope?: string;
356
+ /** (optional) next context to override */
357
+ context?: NextContext;
358
+ }): boolean;
359
+ /**
360
+ * check if current context has `admin` access
361
+ * 1. run in local mode (`$U.isLocalMode()`, v5 — no longer `domain='localhost'`)
362
+ * 2. access via signed access-key
363
+ * 3. authorized cognito and has `admin` role in identity-token.
364
+ *
365
+ * @param role (default) admin
366
+ * @param options optionals
367
+ * @returns boolean
368
+ */
369
+ hasAdminRole(role?: string, options?: {
370
+ errScope?: string;
371
+ context?: NextContext;
372
+ }): boolean;
373
+ /**
374
+ * prepare `next-context` w/ the customized { domain, userAgent }
375
+ *
376
+ * @param identityId the target identity-id
377
+ * @param options additional options.
378
+ */
379
+ asNextContext<T extends NextIdentity>(identityId?: string, options?: {
380
+ /** (optional) domain to override */
381
+ domain?: string;
382
+ /** (optional) userAgent to override */
383
+ userAgent?: string;
384
+ /** (optional) identity(object) to override */
385
+ identity?: T;
386
+ /** (optional) session(object) to override */
387
+ session?: IdentityToken;
388
+ }): NextContext<T>;
389
+ /**
390
+ * from `identity-token`, make base of model { sid, uid }
391
+ *
392
+ * @param proxy the current proxy.
393
+ * @returns base model
394
+ */
395
+ makeModelBase<M extends CoreModel<U>>(model: M, options?: {
396
+ /** use this parent to prepare base-model. (hiher than session) */
397
+ parent?: CoreModel;
398
+ /** flag to use session (default as confUseSession) */
399
+ useSession?: boolean;
400
+ /** flag to throw error (default true) */
401
+ throwable?: boolean;
402
+ }): Promise<M>;
403
+ /**
404
+ * Check if the user can perform a specific action on a model.
405
+ * - override this method to implement custom logic.
406
+ *
407
+ * @param action The action to check.
408
+ * @param model The model to check against. (.type is used to find the manager-proxy)
409
+ * @param options Optional parameters for the check.
410
+ * @returns True if the action is allowed, false otherwise.
411
+ */
412
+ canDo<M extends CoreModel<U>>(action: CanDoActionType, model?: M, options?: CanDoOptions): boolean;
413
+ }
414
+ /**
415
+ * class: `MyProxy`
416
+ * - common parent of manager-proxy.
417
+ */
418
+ export declare class MyManagerProxy<MyModel extends CoreModel<ModelType>, MyManager extends MyCoreManager<MyModel, ModelType, MyService>, MyService extends MyCoreService<MyModel, ModelType, any>, ModelType extends string = string> extends ManagerProxy<MyModel, MyManager, ModelType> {
419
+ readonly proxy: MyCoreProxy<ModelType, MyService>;
420
+ constructor(proxy: MyCoreProxy<ModelType, MyService>, mgr: MyManager);
421
+ /**
422
+ * @override the default `normal()` to support _name.
423
+ */
424
+ normal: (N: MyModel) => MyModel;
425
+ /**
426
+ * pack the query parameter for list
427
+ * - `param` has the string values only including '', '!'
428
+ * - `model` has the valid data type. (number | string | ... )
429
+ *
430
+ * ```ts
431
+ * let model = bodyToModel(param)
432
+ * ```
433
+ *
434
+ * @param param the original query parameter.
435
+ * @param model the transformed model from `param`.
436
+ * @param options (optional)
437
+ * @returns
438
+ */
439
+ packSearchParam(param: SimpleSet, model?: MyModel, options?: {
440
+ /** flag to use identity-token (default false) */
441
+ useSession?: boolean;
442
+ /** flag to throw error (default true) */
443
+ throwable?: boolean;
444
+ /** default limit (default 10) */
445
+ limit?: number;
446
+ /** (optional) error scope to use */
447
+ errScope?: string;
448
+ }): {
449
+ $page: PaginateParam;
450
+ $param: SearchParam<MyModel>;
451
+ };
452
+ /**
453
+ * override this to validate request'body.
454
+ * @param model model from request.
455
+ * @param modelId (optional) modelId if to update the target model.
456
+ * @return validated model to save.
457
+ */
458
+ validateModel<T extends MyModel>(model: T, modelId?: string): Promise<T>;
459
+ /**
460
+ * callback before saving model.
461
+ * - could change field before saving.
462
+ *
463
+ * @param model the last model to save.
464
+ * @param $org (optional) original model (null if creating)
465
+ */
466
+ onBeforeSave<T extends MyModel>(model: T, $org?: T): Promise<T>;
467
+ /**
468
+ * callback after saving model.
469
+ * - could trigger the next step if created.
470
+ *
471
+ * @param model the saved model (null if deleted)
472
+ * @param $org (optional) original model (null if new created)
473
+ */
474
+ onAfterSave<T extends MyModel>(model: T, $org?: T): Promise<T>;
475
+ /**
476
+ * generate the next id
477
+ */
478
+ nextId(step?: number): Promise<string>;
479
+ /**
480
+ * create new model
481
+ * - use `.id` or `nextId()` for model-id
482
+ * - validate model in seperate way before using this.
483
+ *
484
+ * @param model creation model
485
+ * @param validate (optional) flag to validate (default is true)
486
+ */
487
+ makeModel<T extends MyModel>(model: T, validate?: boolean): Promise<T>;
488
+ /**
489
+ * Check if the current user can perform the specified action on the given model.
490
+ * - override this method to implement custom logic.
491
+ *
492
+ * @param action The action to check.
493
+ * @param model The model to check against.
494
+ * @param options Additional options for the check.
495
+ * @returns True if the action is allowed, false otherwise.
496
+ */
497
+ canDo<T extends MyModel>(action: CanDoActionType, model?: T, options?: CanDoOptions): boolean;
498
+ /**
499
+ * read multiple nodes.
500
+ * @param ids list of object-ids
501
+ * @param throwable (optional) flag to throw error if not found
502
+ */
503
+ mget<T extends MyModel = MyModel>(ids: string[], options?: {
504
+ throwable?: boolean;
505
+ } | boolean): Promise<T[]>;
506
+ /**
507
+ * update multiple nodes.
508
+ * @param updates list of models (should include id)
509
+ */
510
+ mset<T extends MyModel>(updates: Array<T>): Promise<T[]>;
511
+ }
512
+ /**
513
+ * parameters for Elasticsearch operations.
514
+ *
515
+ * @template T type of the body content.
516
+ */
517
+ interface ElasticParams<T extends object = any> {
518
+ /**
519
+ * index name.
520
+ */
521
+ index: string;
522
+ /**
523
+ * document ID.
524
+ */
525
+ id?: string;
526
+ /**
527
+ * body content.
528
+ */
529
+ body: T;
530
+ }
531
+ /**
532
+ * parameters for Elasticsearch search operations.
533
+ *
534
+ * @template T type of the body content.
535
+ */
536
+ interface ElasticSearchParams<T extends object = any> {
537
+ /**
538
+ * index name.
539
+ */
540
+ index: string;
541
+ /**
542
+ * search body content.
543
+ */
544
+ body: T;
545
+ /**
546
+ * search type
547
+ * (e.g., 'query_then_fetch', 'dfs_query_then_fetch').
548
+ */
549
+ search_type?: SearchType;
550
+ }
551
+ /**
552
+ * class: `OS2Service`
553
+ * - Master 권한 전용 Elasticsearch 관리 서비스
554
+ * - service for OS2: data path via FGAC (`$fgac`), index management via the master client.
555
+ */
556
+ export declare class OS2Service<T extends OS2Item = any> extends OS2CoreService<any> {
557
+ readonly $fgac: OS2FGACManager;
558
+ /**
559
+ * constructor (no client here; the master client is created on first `client` access)
560
+ */
561
+ constructor(options: OS2BaseOption, fgac: OS2FGACManager);
562
+ /**
563
+ * build the master client: `auth` is read from config now (after engine init), and set only when both exist.
564
+ */
565
+ protected createClient(): Client;
566
+ /**
567
+ * delete index by name
568
+ */
569
+ deleteIndex(indexName: string): Promise<any>;
570
+ /**
571
+ * save single item
572
+ *
573
+ * @param id - id
574
+ * @param item - item to save
575
+ * @param type - document type (default: doc-type given at construction time)
576
+ */
577
+ saveItem(id: string, item: T): Promise<T>;
578
+ /**
579
+ * bulk save multiple items using elasticsearch client
580
+ *
581
+ * @param items - array of items to save
582
+ */
583
+ bulkItems(items: T[], options?: {
584
+ idName?: string;
585
+ }): Promise<BulkItemsResult>;
586
+ /**
587
+ * push item for time-series data (via FGAC; the result is the response body itself).
588
+ *
589
+ * @param item - item to push
590
+ */
591
+ pushItem(item: T): Promise<T>;
592
+ /**
593
+ * read item with projections
594
+ *
595
+ * @param id - item-id
596
+ * @param views - projections
597
+ */
598
+ readItem(id: string, views?: string[] | object): Promise<T>;
599
+ /**
600
+ * delete item with projections
601
+ *
602
+ * @param id - item-id
603
+ */
604
+ deleteItem(id: string): Promise<T>;
605
+ /**
606
+ * update item (throw if not exist)
607
+ * `update table set a=1, b=b+2 where id='a1'`
608
+ * 0. no of `a1` -> 1,2 (created)
609
+ * 1. a,b := 10,20 -> 11,22
610
+ * 2. a,b := 10,null -> 11,2 (upsert)
611
+ * 3. a,b := null,20 -> 1,22
612
+ *
613
+ * @param id - item-id
614
+ * @param item - item to update
615
+ * @param increments - item to increase
616
+ * @param options - (optional) request option of client.
617
+ */
618
+ updateItem(id: string, item: T | null, increments?: Incrementable, options?: {
619
+ maxRetries?: number;
620
+ }): Promise<T>;
621
+ /**
622
+ * run search and get the raw response.
623
+ * @param body - Elasticsearch Query DSL that defines the search request (e.g., size, query, filters).
624
+ * @param searchType - type of search (e.g., 'query_then_fetch', 'dfs_query_then_fetch').
625
+ */
626
+ searchRaw<T extends object = any>(body: SearchBody, searchType?: SearchType): Promise<T>;
627
+ }
628
+ /**
629
+ * type: `OS2FGACManager`
630
+ * - FGAC(Fine Grained Access Controll) Proxy for OS2
631
+ */
632
+ export declare class OS2FGACManager {
633
+ private _fgacProxy;
634
+ readonly options: OS2BaseOption;
635
+ constructor(options: OS2BaseOption);
636
+ hello: () => string;
637
+ get proxy(): ApiHttpProxy;
638
+ /** FGAC 기반 검색 */
639
+ doFgacSearch<R = any>(params: ElasticSearchParams): Promise<R>;
640
+ /** FGAC 기반 읽기: client.get() 대응 */
641
+ doFgacRead<R = any>(params: ElasticParams): Promise<R>;
642
+ /** FGAC 기반 저장: client.index() 대응 */
643
+ doFgacSave<R = any>(params: ElasticParams): Promise<R>;
644
+ /** FGAC 기반 저장: client.index() 대응 */
645
+ doFgacBulk(bulk: ElasticParams<any[]>): Promise<any[]>;
646
+ /** FGAC 기반 업데이트: client.update() 대응 */
647
+ doFgacUpdate<R = any>(params: ElasticParams): Promise<R>;
648
+ /** FGAC 기반 삭제: client.delete() 대응 */
649
+ doFgacDelete<R = any>(params: ElasticParams): Promise<R>;
650
+ /** FGAC 기반 Create (Strict - 존재하면 실패): client.create() 대응 */
651
+ doFgacCreate<R = any>(params: ElasticParams): Promise<R>;
652
+ /** FGAC 기반 인덱스 삭제: client.indices.delete() 대응 */
653
+ doFgacDeleteIndex<R = any>(index: string): Promise<R>;
654
+ /**
655
+ * FGAC 기반 인덱스 설명: client.indices.describe() 대응
656
+ */
657
+ doFgacDescribe<R = any>(index: string): Promise<{
658
+ settings: R;
659
+ mappings: R;
660
+ }>;
661
+ /**
662
+ * FGAC 기반 인덱스 Settings 변경: client.indices.putSettings() 대응
663
+ */
664
+ doFgacPutSettings<R = any>(index: string, settings: Record<string, any>): Promise<R>;
665
+ /**
666
+ * FGAC 기반 인덱스 Settings 조회: client.indices.getSettings() 대응
667
+ */
668
+ doFgacGetSettings<R = any>(index: string): Promise<R>;
669
+ /**
670
+ * FGAC 기반 인덱스 Mapping 조회: client.indices.getMapping() 대응
671
+ */
672
+ doFgacGetMapping<R = any>(index: string): Promise<R>;
673
+ /**
674
+ * FGAC 기반 인덱스 Mapping 변경: client.indices.putMapping() 대응
675
+ */
676
+ doFgacPutMapping<R = any>(index: string, mapping: Record<string, any>): Promise<R>;
677
+ /**
678
+ * FGAC 기반 인덱스 닫기: client.indices.close() 대응
679
+ */
680
+ doFgacCloseIndex<R = any>(index: string): Promise<R>;
681
+ /**
682
+ * FGAC 기반 인덱스 열기: client.indices.open() 대응
683
+ */
684
+ doFgacOpenIndex<R = any>(index: string): Promise<R>;
685
+ }
686
+ /** extended option for `OS2Instance` */
687
+ export interface OS2Option extends OS2BaseOption {
688
+ /** (optional) role-name in FGAC */
689
+ roleName?: string;
690
+ /** (optional) user-name in FGAC */
691
+ userName?: string;
692
+ }
693
+ /**
694
+ * OS2 인스턴스
695
+ * - describeIndex(), destroyIndex(), search() with elastic initialized by master-key
696
+ * - one service set (fgac, elastic, query, synchronizer) only when `endpoint && indexName`.
697
+ */
698
+ export declare class OS2Instance extends AbstractOS2Instance {
699
+ readonly elastic?: OS2Service;
700
+ readonly query?: OS2QueryService<any>;
701
+ readonly synchronizer?: OS2Synchronizer;
702
+ readonly fgac?: OS2FGACManager;
703
+ /**
704
+ * build one service set when `endpoint && indexName` (no client: it is created on first use).
705
+ */
706
+ constructor({ endpoint, indexName, idName, tableName, autocompleteFields, roleName, userName, }: OS2ConstructParams & {
707
+ /** (optional) id-name (default `$id`, `null` = unset) */
708
+ idName?: string;
709
+ /** (optional) role-name in FGAC */
710
+ roleName?: string;
711
+ /** (optional) user-name in FGAC */
712
+ userName?: string;
713
+ });
714
+ hello: () => string;
715
+ get options(): OS2Option;
716
+ get $X2(): typeof $X2;
717
+ /**
718
+ * search
719
+ */
720
+ search<T>(body: SearchBody, params?: {
721
+ indexName?: string;
722
+ searchType?: 'query_then_fetch' | 'dfs_query_then_fetch';
723
+ }): Promise<SearchResult<T>>;
724
+ /** synchronize dynamo contents to os2 */
725
+ synchronizeContents(options?: {
726
+ stopOnError?: boolean;
727
+ } & PaginateParam): Promise<{
728
+ index: string;
729
+ total: number;
730
+ failed: (CoreModel<any> & GeneralItem)[];
731
+ list?: (CoreModel<any> & GeneralItem)[];
732
+ }>;
733
+ /** bulk items with auto-complete options */
734
+ bulkItems(items: any[], options?: {
735
+ idName?: string;
736
+ }): Promise<BulkItemsResult>;
737
+ }
738
+ /**
739
+ * internal tools
740
+ */
741
+ declare const $X2: {
742
+ /** describe endpoint-url into component */
743
+ describeEndpointUrl: (url: string, options?: {
744
+ throwable?: boolean;
745
+ errScope?: string;
746
+ }) => {
747
+ protocol: string;
748
+ host: string;
749
+ port: number;
750
+ region: string;
751
+ isTunnel: boolean;
752
+ isProxy: boolean;
753
+ };
754
+ /** load local credentials (for dev) */
755
+ loadCredentials: (profile?: string) => Promise<CrendentialForAWS>;
756
+ };
757
+ /**
758
+ * factory of `OS2Instance`
759
+ * - reads `OS2_ENDPOINT`, `OS2_INDEX`, `MY_DYNAMO_TABLE`, `OS2_AUTOCOMPLETE_FIELDS` (no version, no doc-type).
760
+ */
761
+ export declare const _OS2: (options?: OS2Option) => OS2Instance;
762
+ /**
763
+ * the default `OS2Instance`, built lazily by `_OS2()` on first access (S-25).
764
+ * - nothing is built at import: no client, no dynamo-stream listener.
765
+ * - without `OS2_ENDPOINT` it is an `OS2Instance` with `options === null`.
766
+ */
767
+ export declare const $OS2: OS2Instance;
768
+ /**
769
+ * explicit alias of `$OS2` (the same object). The name is kept; the meaning is OS2.
770
+ */
771
+ export declare const $ES6Routed: OS2Instance;