diff --git a/packages/test/src/test-integration-split-one.ts b/packages/test/src/test-integration-split-one.ts index e14ef994b..f011a1d91 100644 --- a/packages/test/src/test-integration-split-one.ts +++ b/packages/test/src/test-integration-split-one.ts @@ -698,8 +698,12 @@ test('Workflow can upsert Search Attributes', configMacro, async (t, config) => ); }); -export async function returnWorkflowInfo(): Promise { - return workflowInfo(); +export async function returnWorkflowInfo(): Promise { + const info = workflowInfo(); + return { + ...info, + isTypedSearchAttributesInstance: info.typedSearchAttributes instanceof TypedSearchAttributes, + }; } test('Workflow can read WorkflowInfo', configMacro, async (t, config) => { @@ -724,7 +728,10 @@ test('Workflow can read WorkflowInfo', configMacro, async (t, config) => { runId: handle.firstExecutionRunId, taskQueue, searchAttributes: {}, - typedSearchAttributes: new TypedSearchAttributes(), + // Ensure serialized data structure is correct + typedSearchAttributes: JSON.parse(JSON.stringify(new TypedSearchAttributes())), + // Ensure typed search attributes in workflow info is an instance of TypedSearchAttributes + isTypedSearchAttributesInstance: true, workflowType: 'returnWorkflowInfo', workflowId: handle.workflowId, historyLength: 3, diff --git a/packages/test/src/test-schedules.ts b/packages/test/src/test-schedules.ts index cf23142c7..d2c1c6524 100644 --- a/packages/test/src/test-schedules.ts +++ b/packages/test/src/test-schedules.ts @@ -13,7 +13,7 @@ import { SearchAttributes, } from '@temporalio/client'; import { msToNumber } from '@temporalio/common/lib/time'; -import { searchAttributePair, SearchAttributeType } from '@temporalio/common'; +import { searchAttributePair, SearchAttributeType, TypedSearchAttributes } from '@temporalio/common'; import { registerDefaultCustomSearchAttributes, RUN_INTEGRATION_TESTS } from './helpers'; export interface Context { @@ -169,7 +169,7 @@ if (RUN_INTEGRATION_TESTS) { searchAttributes: { CustomKeywordField: ['test-value2'], }, - typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)], + typedSearchAttributes: [searchAttributePair('CustomIntField', SearchAttributeType.INT, 42)], }, }); @@ -179,15 +179,14 @@ if (RUN_INTEGRATION_TESTS) { t.is(describedSchedule.action.type, 'startWorkflow'); t.is(describedSchedule.action.workflowType, 'dummyWorkflow'); t.deepEqual(describedSchedule.action.memo, { 'my-memo': 'foo' }); - t.deepEqual(describedSchedule.action.searchAttributes, [ - ['CustomKeywordField', ['test-value2']], - ['CustomInt', 42], - ]); - t.deepEqual(describedSchedule.action.typedSearchAttributes, [ - searchAttributePair('CustomInt', SearchAttributeType.INT, 42), - // Note that the typed search attribute infers type TEXT from the value. - searchAttributePair('CustomKeywordField', SearchAttributeType.TEXT, 'test-value2'), - ]); + t.deepEqual(describedSchedule.action.searchAttributes, { + 'CustomKeywordField': ['test-value2'], + 'CustomIntField': [42], + }); + t.deepEqual(describedSchedule.action.typedSearchAttributes, new TypedSearchAttributes([ + searchAttributePair('CustomIntField', SearchAttributeType.INT, 42), + searchAttributePair('CustomKeywordField', SearchAttributeType.KEYWORD, 'test-value2'), + ])); } finally { await handle.delete(); } @@ -212,7 +211,7 @@ if (RUN_INTEGRATION_TESTS) { searchAttributes: { CustomKeywordField: ['test-value2'], }, - typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)], + typedSearchAttributes: [searchAttributePair('CustomIntField', SearchAttributeType.INT, 42)], }, }); @@ -223,15 +222,14 @@ if (RUN_INTEGRATION_TESTS) { t.is(describedSchedule.action.workflowType, 'dummyWorkflowWith2Args'); t.deepEqual(describedSchedule.action.args, [3, 4]); t.deepEqual(describedSchedule.action.memo, { 'my-memo': 'foo' }); - t.deepEqual(describedSchedule.action.searchAttributes, [ - ['CustomKeywordField', ['test-value2']], - ['CustomInt', 42], - ]); - t.deepEqual(describedSchedule.action.typedSearchAttributes, [ - searchAttributePair('CustomInt', SearchAttributeType.INT, 42), - // Note that the typed search attribute "guesses" TEXT, inferred from the value. - searchAttributePair('CustomKeywordField', SearchAttributeType.TEXT, 'test-value2'), - ]); + t.deepEqual(describedSchedule.action.searchAttributes, { + 'CustomKeywordField': ['test-value2'], + 'CustomIntField': [42], + }); + t.deepEqual(describedSchedule.action.typedSearchAttributes, new TypedSearchAttributes([ + searchAttributePair('CustomIntField', SearchAttributeType.INT, 42), + searchAttributePair('CustomKeywordField', SearchAttributeType.KEYWORD, 'test-value2'), + ])); } finally { await handle.delete(); } @@ -342,7 +340,7 @@ if (RUN_INTEGRATION_TESTS) { searchAttributes: { CustomKeywordField: ['test-value2'], }, - typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)], + typedSearchAttributes: [searchAttributePair('CustomIntField', SearchAttributeType.INT, 42)], }, }); @@ -587,7 +585,7 @@ if (RUN_INTEGRATION_TESTS) { taskQueue, }, searchAttributes, - typedSearchAttributes: [searchAttributePair('CustomInt', SearchAttributeType.INT, 42)], + typedSearchAttributes: [searchAttributePair('CustomIntField', SearchAttributeType.INT, 42)], }) ); } diff --git a/packages/test/src/test-sinks.ts b/packages/test/src/test-sinks.ts index e7398b92c..98b6575f2 100644 --- a/packages/test/src/test-sinks.ts +++ b/packages/test/src/test-sinks.ts @@ -118,7 +118,7 @@ if (RUN_INTEGRATION_TESTS) { memo: {}, parent: undefined, searchAttributes: {}, - typedSearchAttributes: new TypedSearchAttributes(), + typedSearchAttributes: JSON.parse(JSON.stringify(new TypedSearchAttributes())), historyLength: 3, continueAsNewSuggested: false, // values ignored for the purpose of comparison diff --git a/packages/workflow/src/workflow.ts b/packages/workflow/src/workflow.ts index 014848d9a..8c1a21e85 100644 --- a/packages/workflow/src/workflow.ts +++ b/packages/workflow/src/workflow.ts @@ -937,9 +937,7 @@ export function makeContinueAsNewFunc( memo: options.memo && mapToPayloads(activator.payloadConverter, options.memo), searchAttributes: options.searchAttributes || options.typedSearchAttributes - ? { - indexedFields: encodeUnifiedSearchAttributes(options.searchAttributes, options.typedSearchAttributes), - } + ? encodeUnifiedSearchAttributes(options.searchAttributes, options.typedSearchAttributes) : undefined, workflowRunTimeout: msOptionalToTs(options.workflowRunTimeout), workflowTaskTimeout: msOptionalToTs(options.workflowTaskTimeout),