Skip to content

Commit

Permalink
linting and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
THardy98 committed Feb 6, 2025
1 parent 78b74a4 commit af0754e
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 194 deletions.
6 changes: 3 additions & 3 deletions packages/common/src/converter/payload-search-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ export class TypedSearchAttributePayloadConverter implements PayloadConverter {
}

// If no 'type' metadata field or no given value, we skip.
if (payload.metadata.type == undefined) {
if (payload.metadata.type == null) {
return undefined as T;
}
const type = toSearchAttributeType(decode(payload.metadata.type));
// Unrecognized metadata type (sanity check).
if (type === undefined) {
return undefined as T;
}

let value = this.jsonConverter.fromPayload(payload);

// Handle legacy values without KEYWORD_LIST type.
if (type !== SearchAttributeType.KEYWORD_LIST && Array.isArray(value)) {
// Cannot have an array with multiple values for non-KEYWORD_LIST type.
Expand Down
18 changes: 12 additions & 6 deletions packages/common/src/typed-search-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,21 @@ function searchAttributeKey<T extends SearchAttributeType>(name: string, type: T
return { name, type };
}

export function searchAttributePair<T extends SearchAttributeType>(name: string, type: T, value: IndexedValueTypeMapping[T]): TypedSearchAttributePair {
export function searchAttributePair<T extends SearchAttributeType>(
name: string,
type: T,
value: IndexedValueTypeMapping[T]
): TypedSearchAttributePair {
const key = searchAttributeKey(name, type);
const typedValue: TypedSearchAttributeValue<T> = [type, value];
return [key, typedValue] as TypedSearchAttributePair;
}

export function searchAttributeUpdatePair<T extends SearchAttributeType>(name: string, type: T, value: IndexedValueTypeMapping[T] | null): TypedSearchAttributeUpdatePair {
export function searchAttributeUpdatePair<T extends SearchAttributeType>(
name: string,
type: T,
value: IndexedValueTypeMapping[T] | null
): TypedSearchAttributeUpdatePair {
const key = searchAttributeKey(name, type);
const typedValue: TypedSearchAttributeValue<T> | null = value === null ? value : [type, value];
return [key, typedValue] as TypedSearchAttributeUpdatePair;
Expand Down Expand Up @@ -276,10 +284,7 @@ export class TypedSearchAttributes {
case 'string':
return searchAttributeKey(key, SearchAttributeType.TEXT);
case 'number':
return searchAttributeKey(
key,
Number.isInteger(val) ? SearchAttributeType.INT : SearchAttributeType.DOUBLE
);
return searchAttributeKey(key, Number.isInteger(val) ? SearchAttributeType.INT : SearchAttributeType.DOUBLE);
case 'boolean':
return searchAttributeKey(key, SearchAttributeType.BOOL);
case 'object':
Expand All @@ -289,6 +294,7 @@ export class TypedSearchAttributes {
if (Array.isArray(val) && val.every((item) => typeof item === 'string')) {
return searchAttributeKey(key, SearchAttributeType.KEYWORD_LIST);
}
return;
default:
return;
}
Expand Down
16 changes: 4 additions & 12 deletions packages/test/src/test-schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ if (RUN_INTEGRATION_TESTS) {
searchAttributes: {
CustomKeywordField: ['test-value2'],
},
typedSearchAttributes: [
searchAttributePair('CustomInt', SearchAttributeType.INT, 42),
],
typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)],
},
});

Expand Down Expand Up @@ -214,9 +212,7 @@ if (RUN_INTEGRATION_TESTS) {
searchAttributes: {
CustomKeywordField: ['test-value2'],
},
typedSearchAttributes: [
searchAttributePair('CustomInt', SearchAttributeType.INT, 42),
],
typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)],
},
});

Expand Down Expand Up @@ -346,9 +342,7 @@ if (RUN_INTEGRATION_TESTS) {
searchAttributes: {
CustomKeywordField: ['test-value2'],
},
typedSearchAttributes: [
searchAttributePair('CustomInt', SearchAttributeType.INT, 42),
],
typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)],
},
});

Expand Down Expand Up @@ -593,9 +587,7 @@ if (RUN_INTEGRATION_TESTS) {
taskQueue,
},
searchAttributes,
typedSearchAttributes: [
searchAttributePair('CustomInt', SearchAttributeType.INT, 42),
],
typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)],
})
);
}
Expand Down
Loading

0 comments on commit af0754e

Please sign in to comment.