Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update @elastic/elasticsearch to v8.2.0-canary.2 #128633

Merged
merged 11 commits into from
Apr 4, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ Please refer to [elasticsearch documentation](https://www.elastic.co/guide/en/el
```typescript
export declare type SavedObjectsFieldMapping = estypes.MappingProperty & {
dynamic?: false | 'strict';
properties?: Record<estypes.PropertyName, estypes.MappingProperty>;
};
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/charts": "45.1.1",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.2.0-canary.1",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.2.0-canary.2",
"@elastic/ems-client": "8.2.0",
"@elastic/eui": "53.0.1",
"@elastic/filesaver": "1.1.2",
Expand Down
5 changes: 5 additions & 0 deletions src/core/server/saved_objects/mappings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ export type SavedObjectsFieldMapping = estypes.MappingProperty & {
* *never* use `dynamic: true`.
*/
dynamic?: false | 'strict';
/**
* Some mapping types do not accept the `properties` attributes. Explicitly adding it as optional to our type
* to avoid type failures on all code using accessing them via `SavedObjectsFieldMapping.properties`.
*/
properties?: Record<estypes.PropertyName, estypes.MappingProperty>;
};

/** @internal */
Expand Down
1 change: 1 addition & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2366,6 +2366,7 @@ export interface SavedObjectsExportTransformContext {
// @public
export type SavedObjectsFieldMapping = estypes.MappingProperty & {
dynamic?: false | 'strict';
properties?: Record<estypes.PropertyName, estypes.MappingProperty>;
};

// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export async function getDataTelemetry(esClient: ElasticsearchClient) {
const indices = indexNames.map((name) => {
const baseIndexInfo = {
name,
// @ts-expect-error 'properties' does not exist on type 'MappingMatchOnlyTextProperty'
isECS: !!indexMappings[name]?.mappings?.properties?.ecs?.properties?.version?.type,
Comment on lines +231 to 232
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢

Copy link
Contributor Author

@pgayvallet pgayvallet Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, even if this is a proper type fix (not all mapping types accepts a properties property) this is actually a 'terrible' change for us.

TBH I blame TS a bit about this behavior:

type A = { foo: string; }
type B = { bar: string; }
type Composite = A | B;

const test: Composite = { foo: 'hello' };
// error 'foo' does not exist on type B
test.foo

I would love to have a way for TS to consider typeof test.foo as being string | undefined, but undeclared and undefined are two very distinct concepts for typescript...

shipper: indexMappings[name]?.mappings?._meta?.beat,
packageName: indexMappings[name]?.mappings?._meta?.package?.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const fetchIndices = async (client: IScopedClusterClient): Promise<Elasti
// node.js string length limit: https://github.com/nodejs/node/issues/33960
filter_path: ['*.aliases'],
// for better performance only compute aliases and settings of indices but not mappings
// @ts-expect-error new param https://github.com/elastic/elasticsearch-specification/issues/1382
features: ['aliases', 'settings'],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async function fetchIndicesCall(
'*.data_stream',
],
// for better performance only compute aliases and settings of indices but not mappings
// @ts-expect-error new param https://github.com/elastic/elasticsearch-specification/issues/1382
features: ['aliases', 'settings'],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class KibanaFramework {
} as estypes.MsearchRequest);
break;
case 'fieldCaps':
// @ts-expect-error FieldCapsRequest.fields is not optional, CallWithRequestParams.fields is
apiResult = elasticsearch.client.asCurrentUser.fieldCaps({
...params,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export function modelsProvider(client: IScopedClusterClient, mlClient: MlClient)
*/
async getNodesOverview(): Promise<NodesOverviewResponse> {
// TODO set node_id to ml:true when elasticsearch client is updated.
// @ts-expect-error typo in type definition: MlGetMemoryStatsResponse.cluser_name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be fixed in the next canary version

const response = (await mlClient.getMemoryStats()) as MemoryStatsResponse;

const { trained_model_stats: trainedModelStats } = await mlClient.getTrainedModelsStats({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const createMigrationIndex = async ({
body: {
settings: {
index: {
// @ts-expect-error `name` is required on IndicesIndexSettingsLifecycle
lifecycle: {
// @ts-expect-error typings don't contain the property yet
indexing_complete: true,
},
},
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1485,10 +1485,10 @@
dependencies:
"@elastic/ecs-helpers" "^1.1.0"

"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@8.2.0-canary.1":
version "8.2.0-canary.1"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.2.0-canary.1.tgz#da547aaf0a39846cda4484bc021dea2117acaf0c"
integrity sha512-MxDCQjcKgxQulX+PJiPWdwFJwYq5J1EVycU5EaE1sDODLnnJp5dvQFPtRRla9MM5Elyy52swtfzQA5ktGixyRg==
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@8.2.0-canary.2":
version "8.2.0-canary.2"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.2.0-canary.2.tgz#2513926cdbfe7c070e1fa6926f7829171b27cdba"
integrity sha512-Ki2lQ3/UlOnBaf5EjNw0WmCdXiW+J020aYtdVnIuCNhPSLoNPKoM7P+MlggdfeRnENvINlStrMy4bkYF/h6Vbw==
dependencies:
"@elastic/transport" "^8.0.2"
tslib "^2.3.0"
Expand Down