lemon-core 4.3.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -2
- package/dist/common/lemon-error.d.ts +34 -0
- package/dist/common/lemon-error.js +52 -0
- package/dist/common/lemon-error.js.map +1 -0
- package/dist/controllers/general-api-controller.d.ts +7 -0
- package/dist/controllers/general-api-controller.js +7 -0
- package/dist/controllers/general-api-controller.js.map +1 -1
- package/dist/cores/api/api-service.js +10 -43
- package/dist/cores/api/api-service.js.map +1 -1
- package/dist/cores/aws/aws-kms-service.d.ts +13 -5
- package/dist/cores/aws/aws-kms-service.js +23 -9
- package/dist/cores/aws/aws-kms-service.js.map +1 -1
- package/dist/cores/aws/aws-s3-service.d.ts +30 -4
- package/dist/cores/aws/aws-s3-service.js +35 -15
- package/dist/cores/aws/aws-s3-service.js.map +1 -1
- package/dist/cores/aws/aws-sns-service.js +59 -9
- package/dist/cores/aws/aws-sns-service.js.map +1 -1
- package/dist/cores/aws/aws-sqs-service.d.ts +1 -1
- package/dist/cores/aws/aws-sqs-service.js +54 -12
- package/dist/cores/aws/aws-sqs-service.js.map +1 -1
- package/dist/cores/cache/cache-service.d.ts +10 -9
- package/dist/cores/cache/cache-service.js +9 -346
- package/dist/cores/cache/cache-service.js.map +1 -1
- package/dist/cores/config/config-service.d.ts +3 -15
- package/dist/cores/config/config-service.js +5 -34
- package/dist/cores/config/config-service.js.map +1 -1
- package/dist/cores/dynamo/dynamo-query-service.js +42 -2
- package/dist/cores/dynamo/dynamo-query-service.js.map +1 -1
- package/dist/cores/dynamo/dynamo-scan-service.js +42 -2
- package/dist/cores/dynamo/dynamo-scan-service.js.map +1 -1
- package/dist/cores/dynamo/dynamo-service.d.ts +45 -14
- package/dist/cores/dynamo/dynamo-service.js +48 -21
- package/dist/cores/dynamo/dynamo-service.js.map +1 -1
- package/dist/cores/dynamo/tools/expressions.js +32 -22
- package/dist/cores/dynamo/tools/expressions.js.map +1 -1
- package/dist/cores/dynamo/tools/lang.d.ts +30 -0
- package/dist/cores/dynamo/tools/lang.js +75 -0
- package/dist/cores/dynamo/tools/lang.js.map +1 -0
- package/dist/cores/dynamo/tools/query.js +20 -21
- package/dist/cores/dynamo/tools/query.js.map +1 -1
- package/dist/cores/dynamo/tools/scan.js +15 -16
- package/dist/cores/dynamo/tools/scan.js.map +1 -1
- package/dist/cores/dynamo/tools/serializer.js +40 -38
- package/dist/cores/dynamo/tools/serializer.js.map +1 -1
- package/dist/cores/dynamo/tools/utils.d.ts +6 -2
- package/dist/cores/dynamo/tools/utils.js +11 -8
- package/dist/cores/dynamo/tools/utils.js.map +1 -1
- package/dist/cores/elastic/elastic6-query-service.d.ts +1 -104
- package/dist/cores/elastic/elastic6-query-service.js +15 -489
- package/dist/cores/elastic/elastic6-query-service.js.map +1 -1
- package/dist/cores/elastic/elastic6-service.d.ts +1 -482
- package/dist/cores/elastic/elastic6-service.js +15 -1153
- package/dist/cores/elastic/elastic6-service.js.map +1 -1
- package/dist/cores/elastic/index.d.ts +2 -2
- package/dist/cores/elastic/index.js +3 -2
- package/dist/cores/elastic/index.js.map +1 -1
- package/dist/cores/elastic/os2-query-service.d.ts +104 -0
- package/dist/cores/elastic/os2-query-service.js +495 -0
- package/dist/cores/elastic/os2-query-service.js.map +1 -0
- package/dist/cores/elastic/os2-service.d.ts +372 -0
- package/dist/cores/elastic/os2-service.js +943 -0
- package/dist/cores/elastic/os2-service.js.map +1 -0
- package/dist/cores/index.d.ts +6 -1
- package/dist/cores/index.js +9 -2
- package/dist/cores/index.js.map +1 -1
- package/dist/cores/lambda/index.js +2 -1
- package/dist/cores/lambda/index.js.map +1 -1
- package/dist/cores/lambda/lambda-cron-handler.d.ts +1 -0
- package/dist/cores/lambda/lambda-cron-handler.js +5 -1
- package/dist/cores/lambda/lambda-cron-handler.js.map +1 -1
- package/dist/cores/lambda/lambda-dynamo-stream-handler.d.ts +5 -4
- package/dist/cores/lambda/lambda-dynamo-stream-handler.js +18 -5
- package/dist/cores/lambda/lambda-dynamo-stream-handler.js.map +1 -1
- package/dist/cores/lambda/lambda-handler.d.ts +22 -2
- package/dist/cores/lambda/lambda-handler.js +85 -23
- package/dist/cores/lambda/lambda-handler.js.map +1 -1
- package/dist/cores/lambda/lambda-sns-handler.d.ts +1 -0
- package/dist/cores/lambda/lambda-sns-handler.js +5 -0
- package/dist/cores/lambda/lambda-sns-handler.js.map +1 -1
- package/dist/cores/lambda/lambda-sqs-handler.d.ts +1 -0
- package/dist/cores/lambda/lambda-sqs-handler.js +20 -5
- package/dist/cores/lambda/lambda-sqs-handler.js.map +1 -1
- package/dist/cores/lambda/lambda-web-handler.d.ts +10 -0
- package/dist/cores/lambda/lambda-web-handler.js +107 -41
- package/dist/cores/lambda/lambda-web-handler.js.map +1 -1
- package/dist/cores/protocol/aws-lambda-helper.js +58 -11
- package/dist/cores/protocol/aws-lambda-helper.js.map +1 -1
- package/dist/cores/protocol/index.js +3 -0
- package/dist/cores/protocol/index.js.map +1 -1
- package/dist/cores/protocol/protocol-service.d.ts +26 -5
- package/dist/cores/protocol/protocol-service.js +42 -12
- package/dist/cores/protocol/protocol-service.js.map +1 -1
- package/dist/cores/protocol/protocol-sign.d.ts +72 -0
- package/dist/cores/protocol/protocol-sign.js +194 -0
- package/dist/cores/protocol/protocol-sign.js.map +1 -0
- package/dist/cores/storage/index.d.ts +0 -1
- package/dist/cores/storage/index.js +0 -1
- package/dist/cores/storage/index.js.map +1 -1
- package/dist/cores/storage/model-fields.d.ts +7 -0
- package/dist/cores/storage/model-fields.js +21 -0
- package/dist/cores/storage/model-fields.js.map +1 -0
- package/dist/cores/storage/model-manager.d.ts +5 -2
- package/dist/cores/storage/model-manager.js +11 -3
- package/dist/cores/storage/model-manager.js.map +1 -1
- package/dist/engine/builder.js +20 -2
- package/dist/engine/builder.js.map +1 -1
- package/dist/engine/engine.d.ts +2 -2
- package/dist/engine/engine.js +5 -5
- package/dist/engine/engine.js.map +1 -1
- package/dist/engine/utilities.d.ts +20 -12
- package/dist/engine/utilities.js +57 -86
- package/dist/engine/utilities.js.map +1 -1
- package/dist/environ.d.ts +0 -6
- package/dist/environ.js +1 -12
- package/dist/environ.js.map +1 -1
- package/dist/esm/index.mjs +141 -0
- package/dist/esm/testing.mjs +12 -0
- package/dist/extended/abstract-service.d.ts +48 -139
- package/dist/extended/abstract-service.js +46 -382
- package/dist/extended/abstract-service.js.map +1 -1
- package/dist/extended/cores/abstract-controllers.d.ts +25 -0
- package/dist/extended/cores/abstract-controllers.js +77 -7
- package/dist/extended/cores/abstract-controllers.js.map +1 -1
- package/dist/extended/cores/abstract-rest-apis.d.ts +2 -1
- package/dist/extended/cores/abstract-rest-apis.js +2 -1
- package/dist/extended/cores/abstract-rest-apis.js.map +1 -1
- package/dist/extended/cores/abstract-services.d.ts +48 -87
- package/dist/extended/cores/abstract-services.js +121 -248
- package/dist/extended/cores/abstract-services.js.map +1 -1
- package/dist/extended/cores/commons.d.ts +4 -113
- package/dist/extended/cores/commons.js +26 -180
- package/dist/extended/cores/commons.js.map +1 -1
- package/dist/extended/cores/fields-admin.d.ts +91 -0
- package/dist/extended/cores/fields-admin.js +142 -0
- package/dist/extended/cores/fields-admin.js.map +1 -0
- package/dist/extended/cores/index.d.ts +2 -0
- package/dist/extended/cores/index.js +2 -0
- package/dist/extended/cores/index.js.map +1 -1
- package/dist/extended/cores/types.d.ts +3 -225
- package/dist/extended/cores/types.js +28 -0
- package/dist/extended/cores/types.js.map +1 -1
- package/dist/helpers/helpers.d.ts +10 -5
- package/dist/helpers/helpers.js +46 -58
- package/dist/helpers/helpers.js.map +1 -1
- package/dist/helpers/types.d.ts +22 -10
- package/dist/index.d.ts +1 -5
- package/dist/index.js +8 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/http-fetch.d.ts +54 -0
- package/dist/lib/http-fetch.js +133 -0
- package/dist/lib/http-fetch.js.map +1 -0
- package/dist/lib/lazy.d.ts +22 -0
- package/dist/lib/lazy.js +54 -0
- package/dist/lib/lazy.js.map +1 -0
- package/dist/lib/perf.d.ts +35 -0
- package/dist/lib/perf.js +52 -0
- package/dist/lib/perf.js.map +1 -0
- package/dist/tools/tools.d.ts +15 -3
- package/dist/tools/tools.js +21 -4
- package/dist/tools/tools.js.map +1 -1
- package/package.json +96 -39
- package/dist/cores/storage/redis-storage-service.d.ts +0 -183
- package/dist/cores/storage/redis-storage-service.js +0 -377
- package/dist/cores/storage/redis-storage-service.js.map +0 -1
- package/dist/generated/field-registry.d.ts +0 -12
- package/dist/generated/field-registry.js +0 -21
- package/dist/generated/field-registry.js.map +0 -1
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { Incrementable, SearchBody } from 'lemon-model';
|
|
2
|
+
import type { Client, ClientOptions } from '@opensearch-project/opensearch';
|
|
3
|
+
import $hangul from './hangul-service';
|
|
4
|
+
export { $hangul };
|
|
5
|
+
export type SearchType = 'query_then_fetch' | 'dfs_query_then_fetch';
|
|
6
|
+
export interface SearchResponse<T = any> {
|
|
7
|
+
total: number;
|
|
8
|
+
list: Array<T>;
|
|
9
|
+
last: Array<T>;
|
|
10
|
+
aggregations: T;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* options for construction.
|
|
14
|
+
* - v5: the doc-type and version options are removed (typeless OpenSearch only).
|
|
15
|
+
*/
|
|
16
|
+
export interface OS2BaseOption {
|
|
17
|
+
/**
|
|
18
|
+
* endpoint url of OpenSearch
|
|
19
|
+
*/
|
|
20
|
+
endpoint: string;
|
|
21
|
+
/**
|
|
22
|
+
* index-name
|
|
23
|
+
*/
|
|
24
|
+
indexName: string;
|
|
25
|
+
/**
|
|
26
|
+
* id-name (optional if time-seriese)
|
|
27
|
+
*/
|
|
28
|
+
idName?: string;
|
|
29
|
+
/**
|
|
30
|
+
* is TIMESERIES data?
|
|
31
|
+
*/
|
|
32
|
+
timeSeries?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* fields to provide autocomplete(Search-as-You-Type) feature
|
|
35
|
+
*/
|
|
36
|
+
autocompleteFields?: string[] | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* common type of item
|
|
40
|
+
*/
|
|
41
|
+
export interface OS2Item {
|
|
42
|
+
_id?: string;
|
|
43
|
+
_version?: number;
|
|
44
|
+
_score?: number;
|
|
45
|
+
/**
|
|
46
|
+
* only has simple string or number (and in arrays)
|
|
47
|
+
*/
|
|
48
|
+
[key: string]: string | string[] | number | number[] | undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* options for retrying searchAll
|
|
52
|
+
*/
|
|
53
|
+
export interface RetryOptions {
|
|
54
|
+
/** do retry? (default true) */
|
|
55
|
+
do?: boolean;
|
|
56
|
+
/** retry after t msec (default 5000ms) */
|
|
57
|
+
t?: number;
|
|
58
|
+
/** maximum Retries (default 3 times) */
|
|
59
|
+
maxRetries?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* parameters for searchAll
|
|
63
|
+
*/
|
|
64
|
+
interface ElasticSearchAllParams {
|
|
65
|
+
/** search-type */
|
|
66
|
+
searchType?: SearchType;
|
|
67
|
+
/** limit (default -1) */
|
|
68
|
+
limit?: number;
|
|
69
|
+
/** options for retrying (default true)*/
|
|
70
|
+
retryOptions?: RetryOptions;
|
|
71
|
+
}
|
|
72
|
+
/** ****************************************************************************************************************
|
|
73
|
+
* OS2 Client Service
|
|
74
|
+
** ****************************************************************************************************************/
|
|
75
|
+
/**
|
|
76
|
+
* abstarct class: `OS2ClientService`
|
|
77
|
+
* - holds the options and the OpenSearch client.
|
|
78
|
+
* - the client is created on the first `client` access (not in the constructor).
|
|
79
|
+
*/
|
|
80
|
+
export declare abstract class OS2ClientService<T extends OS2Item = any> {
|
|
81
|
+
protected _options: OS2BaseOption;
|
|
82
|
+
/** the client, created on first access of `client` */
|
|
83
|
+
protected _client?: Client;
|
|
84
|
+
/**
|
|
85
|
+
* default constuctor w/ options (no client is created here).
|
|
86
|
+
* @param options { endpoint, indexName } is required.
|
|
87
|
+
*/
|
|
88
|
+
constructor(options: OS2BaseOption);
|
|
89
|
+
/**
|
|
90
|
+
* build the client for `options.endpoint` (override to add `auth`).
|
|
91
|
+
* @see https://opensearch.org/docs/latest/clients/javascript/index/
|
|
92
|
+
*/
|
|
93
|
+
protected createClient(): Client;
|
|
94
|
+
/**
|
|
95
|
+
* build a client for `options.endpoint` with extra client options (e.g. `auth`); loads the package on first use.
|
|
96
|
+
*/
|
|
97
|
+
protected newClient(extra?: Partial<ClientOptions>): Client;
|
|
98
|
+
/**
|
|
99
|
+
* get the client instance (created once, on first access).
|
|
100
|
+
*/
|
|
101
|
+
get client(): Client;
|
|
102
|
+
/**
|
|
103
|
+
* get the current options.
|
|
104
|
+
*/
|
|
105
|
+
get options(): OS2BaseOption;
|
|
106
|
+
/**
|
|
107
|
+
* say hello
|
|
108
|
+
*/
|
|
109
|
+
abstract hello(): string;
|
|
110
|
+
/**
|
|
111
|
+
* save an item
|
|
112
|
+
* @param id - item id
|
|
113
|
+
* @param item - item to save
|
|
114
|
+
*/
|
|
115
|
+
abstract saveItem(id: string, item: T): Promise<T>;
|
|
116
|
+
/**
|
|
117
|
+
* push item for time-series data
|
|
118
|
+
* @param item - item to push
|
|
119
|
+
*/
|
|
120
|
+
abstract pushItem(item: T): Promise<T>;
|
|
121
|
+
/**
|
|
122
|
+
* read item with projections
|
|
123
|
+
* @param id - item id
|
|
124
|
+
* @param views - projections
|
|
125
|
+
*/
|
|
126
|
+
abstract readItem(id: string, views?: string[] | object): Promise<T>;
|
|
127
|
+
/**
|
|
128
|
+
* delete an item by id
|
|
129
|
+
* @param id - item id
|
|
130
|
+
*/
|
|
131
|
+
abstract deleteItem(id: string): Promise<T>;
|
|
132
|
+
/**
|
|
133
|
+
* update an item
|
|
134
|
+
* @param id - item id
|
|
135
|
+
* @param item - item to update
|
|
136
|
+
* @param increments - fields to increment
|
|
137
|
+
*/
|
|
138
|
+
abstract updateItem(id: string, item: T | null, increments?: any, options?: {
|
|
139
|
+
maxRetries?: number;
|
|
140
|
+
}): Promise<T>;
|
|
141
|
+
/**
|
|
142
|
+
* search raw results using a query body
|
|
143
|
+
* @param body - search query
|
|
144
|
+
* @param searchType - type of search
|
|
145
|
+
*/
|
|
146
|
+
abstract searchRaw<T extends object = any>(body: any, searchType?: string): Promise<T>;
|
|
147
|
+
/**
|
|
148
|
+
* search and return formatted response
|
|
149
|
+
* @param body - search query
|
|
150
|
+
* @param searchType - type of search
|
|
151
|
+
*/
|
|
152
|
+
abstract search(body: any, searchType?: string): Promise<any>;
|
|
153
|
+
}
|
|
154
|
+
/** ****************************************************************************************************************
|
|
155
|
+
* OS2CoreService
|
|
156
|
+
** ****************************************************************************************************************/
|
|
157
|
+
/**
|
|
158
|
+
* class: `OS2CoreService`
|
|
159
|
+
* - extends `OS2ClientService`: document CRUD, search and index management via the client.
|
|
160
|
+
* - the parent of `OS2Service`.
|
|
161
|
+
*/
|
|
162
|
+
export declare class OS2CoreService<T extends OS2Item = any> extends OS2ClientService {
|
|
163
|
+
static readonly DECOMPOSED_FIELD = "_decomposed";
|
|
164
|
+
static readonly QWERTY_FIELD = "_qwerty";
|
|
165
|
+
/**
|
|
166
|
+
* default constuctor w/ options.
|
|
167
|
+
* @param options { endpoint, indexName } is required.
|
|
168
|
+
*/
|
|
169
|
+
constructor(options: OS2BaseOption);
|
|
170
|
+
/**
|
|
171
|
+
* say hello of identity.
|
|
172
|
+
*/
|
|
173
|
+
hello: () => string;
|
|
174
|
+
/**
|
|
175
|
+
* list of index
|
|
176
|
+
*/
|
|
177
|
+
listIndices(): Promise<{
|
|
178
|
+
list: {
|
|
179
|
+
pri: number;
|
|
180
|
+
rep: number;
|
|
181
|
+
docsCount: number;
|
|
182
|
+
docsDeleted: number;
|
|
183
|
+
health: string;
|
|
184
|
+
index: string;
|
|
185
|
+
status: string;
|
|
186
|
+
uuid: string;
|
|
187
|
+
priStoreSize: string;
|
|
188
|
+
storeSize: string;
|
|
189
|
+
}[];
|
|
190
|
+
}>;
|
|
191
|
+
/**
|
|
192
|
+
* get mapping of an index
|
|
193
|
+
* @param indexName - name of the index
|
|
194
|
+
*/
|
|
195
|
+
getIndexMapping(): Promise<any>;
|
|
196
|
+
/**
|
|
197
|
+
* find the index by name
|
|
198
|
+
* @param indexName - name of the index
|
|
199
|
+
*/
|
|
200
|
+
findIndex(indexName?: string): Promise<{
|
|
201
|
+
pri: number;
|
|
202
|
+
rep: number;
|
|
203
|
+
docsCount: number;
|
|
204
|
+
docsDeleted: number;
|
|
205
|
+
health: string;
|
|
206
|
+
index: string;
|
|
207
|
+
status: string;
|
|
208
|
+
uuid: string;
|
|
209
|
+
priStoreSize: string;
|
|
210
|
+
storeSize: string;
|
|
211
|
+
}>;
|
|
212
|
+
/**
|
|
213
|
+
* create index by name
|
|
214
|
+
* @param settings - creating settings
|
|
215
|
+
*/
|
|
216
|
+
createIndex(settings?: any): Promise<{
|
|
217
|
+
status: any;
|
|
218
|
+
index: string;
|
|
219
|
+
acknowledged: any;
|
|
220
|
+
}>;
|
|
221
|
+
/**
|
|
222
|
+
* destroy search index
|
|
223
|
+
*/
|
|
224
|
+
destroyIndex(): Promise<{
|
|
225
|
+
status: any;
|
|
226
|
+
index: string;
|
|
227
|
+
acknowledged: any;
|
|
228
|
+
}>;
|
|
229
|
+
/**
|
|
230
|
+
* refresh search index - refresh index to make all items searchable
|
|
231
|
+
*/
|
|
232
|
+
refreshIndex(): Promise<any>;
|
|
233
|
+
/**
|
|
234
|
+
* flush search index - force store changes into search index immediately
|
|
235
|
+
*/
|
|
236
|
+
flushIndex(): Promise<any>;
|
|
237
|
+
/**
|
|
238
|
+
* describe `settings` and `mappings` of index.
|
|
239
|
+
*/
|
|
240
|
+
describe(): Promise<{
|
|
241
|
+
settings: any;
|
|
242
|
+
mappings: any;
|
|
243
|
+
}>;
|
|
244
|
+
/**
|
|
245
|
+
* save single item
|
|
246
|
+
*
|
|
247
|
+
* - typeless: no `type` param (v5).
|
|
248
|
+
*
|
|
249
|
+
* @param id - id
|
|
250
|
+
* @param item - item to save
|
|
251
|
+
*/
|
|
252
|
+
saveItem(id: string, item: T): Promise<T>;
|
|
253
|
+
/**
|
|
254
|
+
* push item for time-series data.
|
|
255
|
+
*
|
|
256
|
+
* - typeless: no `type` param (v5).
|
|
257
|
+
*
|
|
258
|
+
* @param item - item to push
|
|
259
|
+
*/
|
|
260
|
+
pushItem(item: T): Promise<T>;
|
|
261
|
+
/**
|
|
262
|
+
* read item with projections (typeless `GET /{index}/_doc/{id}`)
|
|
263
|
+
*
|
|
264
|
+
* @param id - item-id
|
|
265
|
+
* @param views - projections
|
|
266
|
+
*/
|
|
267
|
+
readItem(id: string, views?: string[] | object): Promise<T>;
|
|
268
|
+
/**
|
|
269
|
+
* delete item with projections (typeless `DELETE /{index}/_doc/{id}`)
|
|
270
|
+
*
|
|
271
|
+
* @param id - item-id
|
|
272
|
+
*/
|
|
273
|
+
deleteItem(id: string): Promise<T>;
|
|
274
|
+
/**
|
|
275
|
+
* update item (throw if not exist)
|
|
276
|
+
* `update table set a=1, b=b+2 where id='a1'`
|
|
277
|
+
* 0. no of `a1` -> 1,2 (created)
|
|
278
|
+
* 1. a,b := 10,20 -> 11,22
|
|
279
|
+
* 2. a,b := 10,null -> 11,2 (upsert)
|
|
280
|
+
* 3. a,b := null,20 -> 1,22
|
|
281
|
+
*
|
|
282
|
+
* @param id - item-id
|
|
283
|
+
* @param item - item to update
|
|
284
|
+
* @param increments - item to increase
|
|
285
|
+
* @param options - (optional) request option of client.
|
|
286
|
+
*/
|
|
287
|
+
updateItem(id: string, item: T | null, increments?: Incrementable, options?: {
|
|
288
|
+
maxRetries?: number;
|
|
289
|
+
}): Promise<T>;
|
|
290
|
+
/**
|
|
291
|
+
* run search and get the raw response (`search_type` in the query string).
|
|
292
|
+
* @param body - Elasticsearch Query DSL that defines the search request (e.g., size, query, filters).
|
|
293
|
+
* @param searchType - type of search (e.g., 'query_then_fetch', 'dfs_query_then_fetch').
|
|
294
|
+
*/
|
|
295
|
+
searchRaw<T extends object = any>(body: SearchBody, searchType?: SearchType): Promise<T>;
|
|
296
|
+
/**
|
|
297
|
+
* run search, and get the formatmted response.
|
|
298
|
+
* @param body - Elasticsearch Query DSL that defines the search request (e.g., size, query, filters).
|
|
299
|
+
* @param searchType - type of search (e.g., 'query_then_fetch', 'dfs_query_then_fetch').
|
|
300
|
+
*
|
|
301
|
+
*/
|
|
302
|
+
search(body: SearchBody, searchType?: SearchType): Promise<SearchResponse>;
|
|
303
|
+
/**
|
|
304
|
+
* search all until limit (-1 means no-limit)
|
|
305
|
+
* @param body - Elasticsearch Query DSL that defines the search request (e.g., size, query, filters).
|
|
306
|
+
* @param params - parameters including search type, limit, and retry options.
|
|
307
|
+
*/
|
|
308
|
+
searchAll<T>(body: SearchBody, params?: ElasticSearchAllParams): Promise<T[]>;
|
|
309
|
+
/**
|
|
310
|
+
* create async generator that yields items queried until last
|
|
311
|
+
*
|
|
312
|
+
* @param body - Elasticsearch Query DSL that defines the search request (e.g., size, query, filters).
|
|
313
|
+
* @param params - parameters including search type, limit, and retry options.
|
|
314
|
+
*/
|
|
315
|
+
generateSearchResult(body: SearchBody, params?: ElasticSearchAllParams): AsyncGenerator<any[], void, unknown>;
|
|
316
|
+
/**
|
|
317
|
+
* prepare default setting
|
|
318
|
+
* - migrated from engine-v2.
|
|
319
|
+
* - v5: always the typeless mapping (`mappings.properties`); no doc-type or version, no `standard` filter.
|
|
320
|
+
*
|
|
321
|
+
* @param idName id-name
|
|
322
|
+
* @param shards number of shards (default 4)
|
|
323
|
+
* @param replicas number of replicas (default 1)
|
|
324
|
+
* @param timeSeries flag of TIMESERIES (default false)
|
|
325
|
+
*/
|
|
326
|
+
static prepareSettings(params: {
|
|
327
|
+
idName: string;
|
|
328
|
+
timeSeries?: boolean;
|
|
329
|
+
shards?: number;
|
|
330
|
+
replicas?: number;
|
|
331
|
+
}): any;
|
|
332
|
+
/**
|
|
333
|
+
* generate autocomplete fields into the item body to be indexed
|
|
334
|
+
* @param body item body to be saved into ES6 index
|
|
335
|
+
* @private
|
|
336
|
+
*/
|
|
337
|
+
protected popullateAutocompleteFields<T = any>(body: T): T;
|
|
338
|
+
}
|
|
339
|
+
interface ErrorReasonDetail<T = any> {
|
|
340
|
+
status: number;
|
|
341
|
+
type: string;
|
|
342
|
+
reason?: string;
|
|
343
|
+
cause?: T;
|
|
344
|
+
}
|
|
345
|
+
interface ErrorReason {
|
|
346
|
+
status: number;
|
|
347
|
+
message: string;
|
|
348
|
+
reason: ErrorReasonDetail;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* error samples
|
|
352
|
+
*/
|
|
353
|
+
export declare const $ERROR: {
|
|
354
|
+
asJson: (e: any) => any;
|
|
355
|
+
throwAsJson: (e: any) => never;
|
|
356
|
+
parseMeta: <T extends {
|
|
357
|
+
type?: string;
|
|
358
|
+
value?: any;
|
|
359
|
+
error?: string;
|
|
360
|
+
list?: any[];
|
|
361
|
+
[key: string]: any;
|
|
362
|
+
}>(meta: any) => T;
|
|
363
|
+
/**
|
|
364
|
+
* parse a client error into `{ status, message, reason }`.
|
|
365
|
+
* - `type` comes from `meta.body.error.type` (same in both clients); it falls back to `message` only
|
|
366
|
+
* when the body has no error type (e.g. a meta-only sample of elastic 7.x).
|
|
367
|
+
* - output form is unchanged: `<TYPE upper, last token dropped, _ as space>` like `VERSION CONFLICT ENGINE`.
|
|
368
|
+
* - errors without `meta` (FGAC `http-fetch`, network) give `reason = null` and are rethrown by `handler`.
|
|
369
|
+
*/
|
|
370
|
+
asError: (e: any) => ErrorReason;
|
|
371
|
+
handler: (name: string, cb?: (e: Error, E?: ErrorReason) => any) => (e: any) => any;
|
|
372
|
+
};
|