-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathcommon.ts
282 lines (233 loc) · 8.1 KB
/
common.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { Dictionary } from '@spec_utils/Dictionary'
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
import { double, integer, long } from './Numeric'
import { AdditionalProperties } from '@spec_utils/behaviors'
/**
* A field value.
* @codegen_names long, double, string, boolean
*/
// FIXME: representation of geopoints and ip addresses?
export type FieldValue = long | double | string | boolean
export class UrlParameter {}
export type Uri = string
//strongly typed path parameters these are aliases so we can expose documentation
//Some languages that support type alias or typed value types might want to keep these types
//others might rewrite to the underlying valuetypes
// TODO clean up Id and Name variants and make sure all API's use one purposefully
// Id includes numeric support, Name does not
export type ScrollId = string
export type ScrollIds = string // TODO: array of ScrollIds
export type CategoryId = string
export type ActionIds = string // TODO: check if this should be an array of ActionId
export type Id = string
export type Ids = Id | Id[]
export type NodeId = string
export type NodeIds = NodeId | NodeId[]
export type IndexName = string
export type Indices = IndexName | IndexName[]
export type IndexAlias = string
export type IndexPattern = string
export type IndexPatterns = IndexPattern[]
export type Type = string
export type Types = Type | Type[]
export type Routing = string
export type LongId = string
//TODO encode metrics as API specific enums
export type IndexMetrics = string
export type Metrics = string | string[]
export type Name = string
export type Names = Name | Name[]
export type Namespace = string
export type Service = string
export type PipelineName = string
/** @doc_url https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html#modules-node */
export type NodeName = string
/** @doc_url https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-data-stream.html#indices-create-data-stream-api-path-params */
export type DataStreamName = string
export type DataStreamNames = DataStreamName | DataStreamName[]
/** @doc_url https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#byte-units */
export type ByteSize = long | string
export type Metadata = Dictionary<string, UserDefinedValue>
// Versioning Numbers & Strings
export type VersionNumber = long
export type VersionNumbers = VersionNumber[]
export type VersionString = string
export type VersionStrings = VersionString[]
export enum VersionType {
internal = 0,
external = 1,
external_gte = 2,
force = 3
}
// TODO: replace all uuid's with this type
export type Uuid = string
// _seq_no
export type SequenceNumber = long
export type PropertyName = string
export type RelationName = string
export type TaskId = string | integer
export type Fuzziness = string | integer
/** @doc_url https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-term-rewrite.html */
export type MultiTermQueryRewrite = string
/** Path to field or array of paths. Some API's support wildcards in the path to select multiple fields. */
export type Field = string
export type Fields = Field | Field[]
/** @codegen_names count, option */
export type WaitForActiveShards = integer | WaitForActiveShardOptions
/**
* The aggregation name as returned from the server. Depending whether typed_keys is specified this could come back
* in the form of `name#type` instead of simply `name`
*/
export type AggregateName = string
/**
* The suggestion name as returned from the server. Depending whether typed_keys is specified this could come back
* in the form of `name#type` instead of simply `name`
*/
export type SuggestionName = string
// Container Type for HTTP Headers
export type HttpHeaders = Dictionary<string, string | string[]>
/** For empty Class assignments */
export class EmptyObject {}
/**
* The minimum number of terms that should match as integer, percentage or range
* @doc_url https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
*/
export type MinimumShouldMatch = integer | string
/**
* Byte size units. These units use powers of 1024, so 1 kB means 1024 bytes.
*
* @doc_url https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#byte-units
*/
export enum Bytes {
/** @codegen_name bytes */
b,
/** @codegen_name kilo_bytes */
kb,
/** @codegen_name mega_bytes */
mb,
/** @codegen_name giga_bytes */
gb,
/** @codegen_name tera_bytes */
tb,
/** @codegen_name peta_bytes */
pb
}
export enum Conflicts {
abort = 0,
proceed = 1
}
export type Username = string
export type Password = string
export class ElasticsearchResponseBase {}
export class ElasticsearchUrlFormatter {}
/**
* Type of index that wildcard expressions can match.
*/
export enum ExpandWildcard {
/** Match any data stream or index, including hidden ones. */
all = 0,
/** Match open, non-hidden indices. Also matches any non-hidden data stream. */
open = 1,
/** Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed. */
closed = 2,
/** Match hidden data streams and hidden indices. Must be combined with open, closed, or both. */
hidden = 3,
/** Wildcard expressions are not accepted. */
none = 4
}
export type ExpandWildcards = ExpandWildcard | ExpandWildcard[]
/**
* Health status of the cluster, based on the state of its primary and replica shards.
*/
export enum Health {
/** All shards are assigned. */
green = 0,
/** All primary shards are assigned, but one or more replica shards are unassigned. If a node in the cluster fails, some data could be unavailable until that node is repaired. */
yellow = 1,
/** One or more primary shards are unassigned, so some data is unavailable. This can occur briefly during cluster startup as primary shards are assigned. */
red = 2
}
export enum HttpMethod {
GET = 0,
POST = 1,
PUT = 2,
DELETE = 3,
HEAD = 4
}
export enum Level {
cluster = 0,
indices = 1,
shards = 2
}
export enum OpType {
index = 0,
create = 1
}
// Note: ES also accepts plain booleans for true and false. The TS generator implements this leniency rule.
export enum Refresh {
true,
false,
wait_for
}
export enum SearchType {
/** Documents are scored using local term and document frequencies for the shard. This is usually faster but less accurate. */
query_then_fetch = 0,
/** Documents are scored using global term and document frequencies across all shards. This is usually slower but more accurate. */
dfs_query_then_fetch = 1
}
export enum SuggestMode {
missing = 0,
popular = 1,
always = 2
}
export enum ThreadType {
cpu = 0,
wait = 1,
block = 2
}
// TODO: @see WaitForActiveShards & https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
export enum WaitForActiveShardOptions {
'all' = 0
}
export enum WaitForEvents {
immediate = 0,
urgent = 1,
high = 2,
normal = 3,
low = 4,
languid = 5
}
export enum WaitForStatus {
green = 0,
yellow = 1,
red = 2
}
// Additional properties are the meta fields
export class InlineGet<TDocument>
implements AdditionalProperties<string, UserDefinedValue>
{
fields?: Dictionary<string, UserDefinedValue>
found: boolean
_seq_no?: SequenceNumber
_primary_term?: long
_routing?: Routing
_source: TDocument
}