Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Aug 19, 2024
1 parent 65adea8 commit 9173fc3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import type {
PropertyName as EsPropertyName,
MappingProperty as EsMappingProperty,
MappingPropertyBase as EsMappingPropertyBase,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

/**
Expand Down Expand Up @@ -64,19 +65,20 @@ export interface SavedObjectsMappingProperties {
*
* @public
*/
export type SavedObjectsFieldMapping = EsMappingProperty & {
/**
* The dynamic property of the mapping, either `false` or `'strict'`. If
* unspecified `dynamic: 'strict'` will be inherited from the top-level
* index mappings.
*
* Note: To limit the number of mapping fields Saved Object types should
* *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<EsPropertyName, EsMappingProperty>;
};
export type SavedObjectsFieldMapping = EsMappingProperty &
EsMappingPropertyBase & {
/**
* The dynamic property of the mapping, either `false` or `'strict'`. If
* unspecified `dynamic: 'strict'` will be inherited from the top-level
* index mappings.
*
* Note: To limit the number of mapping fields Saved Object types should
* *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<EsPropertyName, EsMappingProperty>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type ScriptedPhraseFilter = Filter & {
meta: PhraseFilterMeta;
query: {
script: {
script: estypes.InlineScript;
script: estypes.Script;
};
};
};
Expand Down Expand Up @@ -134,7 +134,7 @@ export const getPhraseScript = (field: DataViewFieldBase, value: PhraseFilterVal
params: {
value: convertedValue,
},
} as estypes.InlineScript,
} as estypes.Script,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type ScriptedRangeFilter = Filter & {
meta: RangeFilterMeta;
query: {
script: {
script: estypes.InlineScript;
script: estypes.Script;
};
};
};
Expand Down Expand Up @@ -189,7 +189,7 @@ export const buildRangeFilter = (
* @internal
*/
export const getRangeScript = (field: DataViewFieldBase, params: RangeFilterParams) => {
const knownParams: estypes.InlineScript['params'] = mapValues(
const knownParams: estypes.Script['params'] = mapValues(
pickBy(params, (val, key) => key in operators),
(value) => (field.type === 'number' && typeof value === 'string' ? parseFloat(value) : value)
);
Expand Down

0 comments on commit 9173fc3

Please sign in to comment.