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