Skip to content

Commit

Permalink
Updated opensearch-js to reflect the latest OpenSearch API spec (2024…
Browse files Browse the repository at this point in the history
…-12-15)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
nhtruong authored and github-actions[bot] committed Dec 15, 2024
1 parent fc7bc20 commit 612f6ec
Show file tree
Hide file tree
Showing 67 changed files with 1,354 additions and 313 deletions.
39 changes: 38 additions & 1 deletion api/OpenSearchApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ export default class OpenSearchAPI {
searchModels (params: API.Knn_SearchModels_Request, callback: callbackFn<API.Knn_SearchModels_Response>): TransportRequestCallback;
searchModels (params: API.Knn_SearchModels_Request, options: TransportRequestOptions, callback: callbackFn<API.Knn_SearchModels_Response>): TransportRequestCallback;

trainModel (params: API.Knn_TrainModel_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Knn_TrainModel_Response>;
trainModel (params?: API.Knn_TrainModel_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Knn_TrainModel_Response>;
trainModel (callback: callbackFn<API.Knn_TrainModel_Response>): TransportRequestCallback;
trainModel (params: API.Knn_TrainModel_Request, callback: callbackFn<API.Knn_TrainModel_Response>): TransportRequestCallback;
trainModel (params: API.Knn_TrainModel_Request, options: TransportRequestOptions, callback: callbackFn<API.Knn_TrainModel_Response>): TransportRequestCallback;

Expand Down Expand Up @@ -1344,6 +1345,42 @@ export default class OpenSearchAPI {

};

sm: {
getPolicies (params?: API.Sm_GetPolicies_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Sm_GetPolicies_Response>;
getPolicies (callback: callbackFn<API.Sm_GetPolicies_Response>): TransportRequestCallback;
getPolicies (params: API.Sm_GetPolicies_Request, callback: callbackFn<API.Sm_GetPolicies_Response>): TransportRequestCallback;
getPolicies (params: API.Sm_GetPolicies_Request, options: TransportRequestOptions, callback: callbackFn<API.Sm_GetPolicies_Response>): TransportRequestCallback;

deletePolicy (params: API.Sm_DeletePolicy_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Sm_DeletePolicy_Response>;
deletePolicy (params: API.Sm_DeletePolicy_Request, callback: callbackFn<API.Sm_DeletePolicy_Response>): TransportRequestCallback;
deletePolicy (params: API.Sm_DeletePolicy_Request, options: TransportRequestOptions, callback: callbackFn<API.Sm_DeletePolicy_Response>): TransportRequestCallback;

getPolicy (params: API.Sm_GetPolicy_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Sm_GetPolicy_Response>;
getPolicy (params: API.Sm_GetPolicy_Request, callback: callbackFn<API.Sm_GetPolicy_Response>): TransportRequestCallback;
getPolicy (params: API.Sm_GetPolicy_Request, options: TransportRequestOptions, callback: callbackFn<API.Sm_GetPolicy_Response>): TransportRequestCallback;

createPolicy (params: API.Sm_CreatePolicy_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Sm_CreatePolicy_Response>;
createPolicy (params: API.Sm_CreatePolicy_Request, callback: callbackFn<API.Sm_CreatePolicy_Response>): TransportRequestCallback;
createPolicy (params: API.Sm_CreatePolicy_Request, options: TransportRequestOptions, callback: callbackFn<API.Sm_CreatePolicy_Response>): TransportRequestCallback;

updatePolicy (params: API.Sm_UpdatePolicy_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Sm_UpdatePolicy_Response>;
updatePolicy (params: API.Sm_UpdatePolicy_Request, callback: callbackFn<API.Sm_UpdatePolicy_Response>): TransportRequestCallback;
updatePolicy (params: API.Sm_UpdatePolicy_Request, options: TransportRequestOptions, callback: callbackFn<API.Sm_UpdatePolicy_Response>): TransportRequestCallback;

explainPolicy (params: API.Sm_ExplainPolicy_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Sm_ExplainPolicy_Response>;
explainPolicy (params: API.Sm_ExplainPolicy_Request, callback: callbackFn<API.Sm_ExplainPolicy_Response>): TransportRequestCallback;
explainPolicy (params: API.Sm_ExplainPolicy_Request, options: TransportRequestOptions, callback: callbackFn<API.Sm_ExplainPolicy_Response>): TransportRequestCallback;

startPolicy (params: API.Sm_StartPolicy_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Sm_StartPolicy_Response>;
startPolicy (params: API.Sm_StartPolicy_Request, callback: callbackFn<API.Sm_StartPolicy_Response>): TransportRequestCallback;
startPolicy (params: API.Sm_StartPolicy_Request, options: TransportRequestOptions, callback: callbackFn<API.Sm_StartPolicy_Response>): TransportRequestCallback;

stopPolicy (params: API.Sm_StopPolicy_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Sm_StopPolicy_Response>;
stopPolicy (params: API.Sm_StopPolicy_Request, callback: callbackFn<API.Sm_StopPolicy_Response>): TransportRequestCallback;
stopPolicy (params: API.Sm_StopPolicy_Request, options: TransportRequestOptions, callback: callbackFn<API.Sm_StopPolicy_Response>): TransportRequestCallback;

};

snapshot: {
getRepository (params?: API.Snapshot_GetRepository_Request, options?: TransportRequestOptions): TransportRequestPromise<API.Snapshot_GetRepository_Response>;
getRepository (callback: callbackFn<API.Snapshot_GetRepository_Response>): TransportRequestCallback;
Expand Down
2 changes: 2 additions & 0 deletions api/OpenSearchApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class OpenSearchAPI {
rollups: new(require('./rollups/_api'))(this),
searchPipeline: new(require('./searchPipeline/_api'))(this),
security: new(require('./security/_api'))(this),
sm: new(require('./sm/_api'))(this),
snapshot: new(require('./snapshot/_api'))(this),
sql: new(require('./sql/_api'))(this),
tasks: new(require('./tasks/_api'))(this),
Expand Down Expand Up @@ -175,6 +176,7 @@ class OpenSearchAPI {
rollups: { get() { return this[kApiModules].rollups } },
searchPipeline: { get() { return this[kApiModules].searchPipeline } },
security: { get() { return this[kApiModules].security } },
sm: { get() { return this[kApiModules].sm } },
snapshot: { get() { return this[kApiModules].snapshot } },
sql: { get() { return this[kApiModules].sql } },
tasks: { get() { return this[kApiModules].tasks } },
Expand Down
4 changes: 2 additions & 2 deletions api/_core/renderSearchTemplate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export type RenderSearchTemplate_Request = Global.Params & {
}

export type RenderSearchTemplate_RequestBody = {
file?: string;
params?: Record<string, Record<string, any>>;
id?: Common.Id;
params?: Record<string, any>;
source?: string;
}

Expand Down
11 changes: 11 additions & 0 deletions api/_core/searchShards.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as Global from '../_types/_global'

export type SearchShards_Request = Global.Params & {
allow_no_indices?: boolean;
body?: SearchShards_RequestBody;
expand_wildcards?: Common.ExpandWildcards;
ignore_unavailable?: boolean;
index?: Common.Indices;
Expand All @@ -29,6 +30,16 @@ export type SearchShards_Request = Global.Params & {
routing?: Common.RoutingInQueryString;
}

export type SearchShards_RequestBody = {
_source?: boolean | string[];
allow_partial_search_results?: boolean;
from?: number;
indices_boost?: Record<string, number>;
query?: Record<string, Record<string, any>>;
size?: number;
sort?: Record<string, string>[];
}

export type SearchShards_Response = ApiResponse & {
body: SearchShards_ResponseBody;
}
Expand Down
1 change: 1 addition & 0 deletions api/_core/searchShards.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const { normalizeArguments, parsePathParam } = require('../utils');
* @param {string} [params.preference=random] - Specifies the node or shard the operation should be performed on. Random by default.
* @param {string} [params.routing] - Custom value used to route operations to a specific shard.
* @param {string} [params.index] - Returns the indexes and shards that a search request would be executed against.
* @param {object} [params.body] - Defines the parameters that can be used in the `search_shards` endpoint request. See documentation for supported query syntax.
*
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
* @param {function} [callback] - Callback that handles errors and response
Expand Down
1 change: 1 addition & 0 deletions api/_core/searchTemplate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type SearchTemplate_ResponseBody = {
num_reduce_phases?: number;
pit_id?: Common.Id;
profile?: Core_Search.Profile;
status?: number;
suggest?: Record<string, Core_Search.Suggest[]>;
terminated_early?: boolean;
timed_out: boolean;
Expand Down
44 changes: 17 additions & 27 deletions api/_types/_common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import * as Cluster_AllocationExplain from './cluster.allocation_explain'
import * as Common_Mapping from './_common.mapping'
import * as Common_QueryDsl from './_common.query_dsl'
import * as Indices_Stats from './indices.stats'

Expand Down Expand Up @@ -202,11 +203,19 @@ export type FieldSizeUsage = {
size_in_bytes: ByteCount;
}

export type FieldValue = boolean | undefined | number | Record<string, any> | string
export type FieldSort = SortOrder | {
format?: string;
missing?: FieldValue;
mode?: SortMode;
nested?: NestedSortValue;
numeric_type?: FieldSortNumericType;
order?: SortOrder;
unmapped_type?: Common_Mapping.FieldType;
}

export type FieldWithDirection = Record<string, SortOrder>
export type FieldSortNumericType = 'date' | 'date_nanos' | 'double' | 'long'

export type FieldWithOrder = Record<string, ScoreSort>
export type FieldValue = boolean | undefined | number | string

export type FlushStats = {
periodic: number;
Expand Down Expand Up @@ -265,9 +274,7 @@ export type GetStats = {
total: number;
}

export type HealthStatus = 'green' | 'red' | 'yellow'

export type HealthStatusCapitalized = 'GREEN' | 'RED' | 'YELLOW'
export type HealthStatus = 'green' | 'GREEN' | 'yellow' | 'YELLOW' | 'red' | 'RED'

export type Host = string

Expand Down Expand Up @@ -342,17 +349,6 @@ export type InlineScript = string | (ScriptBase & {

export type Ip = string

export type KnnField = {
boost?: number;
filter?: Common_QueryDsl.QueryContainer | Common_QueryDsl.QueryContainer[];
k?: number;
max_distance?: number;
method_parameters?: Record<string, number>;
min_score?: number;
rescore?: Record<string, number>;
vector: QueryVector;
}

export type LatLonGeoLocation = {
lat: number;
lon: number;
Expand Down Expand Up @@ -384,7 +380,7 @@ export type Metadata = Record<string, any>

export type MinimumShouldMatch = number | string

export type MultiTermQueryRewrite = 'constant_score' | 'constant_score_boolean' | 'scoring_boolean' | 'top_terms_N' | 'top_terms_blended_freqs_N' | 'top_terms_boost_N'
export type MultiTermQueryRewrite = 'constant_score' | 'constant_score_boolean' | 'scoring_boolean' | string

export type Name = string

Expand Down Expand Up @@ -469,8 +465,6 @@ export type PhaseTook = {

export type PipelineName = string

export type PipeSeparatedFlagsSimpleQueryStringFlag = Common_QueryDsl.SimpleQueryStringFlag | string

export type PluginStats = {
classname: string;
custom_foldername?: undefined | string;
Expand All @@ -495,8 +489,6 @@ export type QueryCacheStats = {
total_count: number;
}

export type QueryVector = number[]

export type RankBase = Record<string, any>

export type RankContainer = {
Expand Down Expand Up @@ -783,18 +775,16 @@ export type Slices = number | SlicesCalculation

export type SlicesCalculation = 'auto'

export type Sort = SortCombinations | SortCombinations[]

export type SortCombinations = Field | FieldWithDirection | FieldWithOrder | SortOptions
export type Sort = SortOptions | SortOptions[]

export type SortMode = 'avg' | 'max' | 'median' | 'min' | 'sum'

export type SortOptions = {
export type SortOptions = '_score' | '_doc' | string | {
_doc?: ScoreSort;
_geo_distance?: GeoDistanceSort;
_score?: ScoreSort;
_script?: ScriptSort;
}
} | Record<string, FieldSort>

export type SortOrder = 'asc' | 'desc'

Expand Down
2 changes: 2 additions & 0 deletions api/_types/_common.mapping.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ export type FieldNamesField = {
enabled: boolean;
}

export type FieldType = 'aggregate_metric_double' | 'alias' | 'binary' | 'boolean' | 'byte' | 'completion' | 'constant_keyword' | 'date' | 'date_nanos' | 'date_range' | 'double' | 'double_range' | 'flat_object' | 'float' | 'float_range' | 'geo_point' | 'geo_shape' | 'half_float' | 'histogram' | 'icu_collation_keyword' | 'integer' | 'integer_range' | 'ip' | 'ip_range' | 'join' | 'keyword' | 'knn_vector' | 'long' | 'long_range' | 'match_only_text' | 'murmur3' | 'nested' | 'object' | 'percolator' | 'rank_feature' | 'rank_features' | 'scaled_float' | 'search_as_you_type' | 'short' | 'text' | 'token_count' | 'unsigned_long' | 'version' | 'wildcard' | 'xy_point' | 'xy_shape'

export type FlatObjectProperty = PropertyBase & {
aggregatable?: boolean;
searchable?: boolean;
Expand Down
Loading

0 comments on commit 612f6ec

Please sign in to comment.