diff --git a/src/lib/components/payload-input.svelte b/src/lib/components/payload-input.svelte
new file mode 100644
index 000000000..390e233cb
--- /dev/null
+++ b/src/lib/components/payload-input.svelte
@@ -0,0 +1,90 @@
+
+
+
Input
+
+
+
+
+
+
+
+
+
+ {translate('workflows.signal-payload-input-label-hint')}
+
+
+
+ {#if error}
+
+ {/if}
+
+
diff --git a/src/lib/components/schedule/schedule-form-view.svelte b/src/lib/components/schedule/schedule-form-view.svelte
index 44cac18b9..93f404060 100644
--- a/src/lib/components/schedule/schedule-form-view.svelte
+++ b/src/lib/components/schedule/schedule-form-view.svelte
@@ -70,6 +70,7 @@
let workflowId = decodedWorkflow?.workflowId ?? '';
let taskQueue = decodedWorkflow?.taskQueue?.name ?? '';
let input = '';
+ let encoding = '';
let daysOfWeek: string[] = [];
let daysOfMonth: number[] = [];
let months: string[] = [];
@@ -90,6 +91,7 @@
workflowId,
taskQueue,
input,
+ encoding,
hour,
minute,
second,
@@ -163,7 +165,6 @@
{title}
{/if}
diff --git a/src/lib/components/schedule/schedule-input-payload.svelte b/src/lib/components/schedule/schedule-input-payload.svelte
index 4797a08d5..c37f505b0 100644
--- a/src/lib/components/schedule/schedule-input-payload.svelte
+++ b/src/lib/components/schedule/schedule-input-payload.svelte
@@ -1,45 +1,30 @@
-
-
- {#key decodedValue}
-
+
+ {#key loading}
+
{/key}
-
- {translate('workflows.signal-payload-input-label-hint')}
-
diff --git a/src/lib/components/workflow/client-actions/signal-confirmation-modal.svelte b/src/lib/components/workflow/client-actions/signal-confirmation-modal.svelte
index 74d5eecda..b1342fa2a 100644
--- a/src/lib/components/workflow/client-actions/signal-confirmation-modal.svelte
+++ b/src/lib/components/workflow/client-actions/signal-confirmation-modal.svelte
@@ -1,7 +1,7 @@
@@ -78,21 +74,6 @@
required
bind:value={name}
/>
-
- {translate('workflows.signal-payload-input-label')}
-
- {translate('workflows.signal-payload-input-label-hint')}
-
-
-
+
diff --git a/src/lib/i18n/locales/en/workflows.ts b/src/lib/i18n/locales/en/workflows.ts
index b73bcc729..1fd5a4cdc 100644
--- a/src/lib/i18n/locales/en/workflows.ts
+++ b/src/lib/i18n/locales/en/workflows.ts
@@ -103,7 +103,7 @@ export const Strings = {
'Are you sure you want to terminate this workflow? This action cannot be undone.',
'signal-modal-title': 'Send a Signal',
'signal-name-label': 'Signal name',
- 'signal-payload-input-label': 'Input',
+ 'signal-payload-input-label': 'Payload',
'signal-payload-input-label-hint': '(only single JSON payload supported)',
'cancel-request-sent': 'Cancel Request Sent',
'cancel-request-sent-description':
diff --git a/src/lib/pages/schedule-edit.svelte b/src/lib/pages/schedule-edit.svelte
index c61b73824..69eaa2ebd 100644
--- a/src/lib/pages/schedule-edit.svelte
+++ b/src/lib/pages/schedule-edit.svelte
@@ -36,6 +36,7 @@
workflowId,
taskQueue,
input,
+ encoding,
hour,
minute,
second,
@@ -54,6 +55,7 @@
workflowId,
taskQueue,
input,
+ encoding,
searchAttributes,
};
const spec: Partial = {
diff --git a/src/lib/pages/schedules-create.svelte b/src/lib/pages/schedules-create.svelte
index 60750bf1d..047127cae 100644
--- a/src/lib/pages/schedules-create.svelte
+++ b/src/lib/pages/schedules-create.svelte
@@ -23,6 +23,7 @@
workflowId,
taskQueue,
input,
+ encoding,
hour,
minute,
second,
@@ -42,6 +43,7 @@
workflowId,
taskQueue,
input,
+ encoding,
searchAttributes,
};
const spec: Partial = {
diff --git a/src/lib/pages/start-workflow.svelte b/src/lib/pages/start-workflow.svelte
index efcbef130..3200d8fb1 100644
--- a/src/lib/pages/start-workflow.svelte
+++ b/src/lib/pages/start-workflow.svelte
@@ -5,13 +5,12 @@
import { goto } from '$app/navigation';
import { page } from '$app/stores';
+ import PayloadInput from '$lib/components/payload-input.svelte';
import AddSearchAttributes from '$lib/components/workflow/add-search-attributes.svelte';
import Alert from '$lib/holocene/alert.svelte';
import Button from '$lib/holocene/button.svelte';
- import CodeBlock from '$lib/holocene/code-block.svelte';
import FileInput from '$lib/holocene/file-input.svelte';
import Input from '$lib/holocene/input/input.svelte';
- import Label from '$lib/holocene/label.svelte';
import Link from '$lib/holocene/link.svelte';
import Tooltip from '$lib/holocene/tooltip.svelte';
import { translate } from '$lib/i18n/translate';
@@ -39,11 +38,11 @@
let taskQueue = '';
let workflowType = '';
let input = '';
+ let encoding = 'json/plain';
let inputRetrieved = 0;
let initialWorkflowId = '';
let initialWorkflowType = '';
- let initialInput = '';
let error = '';
let pollerCount: undefined | number = undefined;
@@ -65,10 +64,6 @@
}
});
- const handleInputChange = (event: CustomEvent) => {
- input = event.detail;
- };
-
const onWorkflowStart = async () => {
try {
error = '';
@@ -78,6 +73,7 @@
taskQueue,
workflowType,
input,
+ encoding,
searchAttributes,
});
goto(routeForWorkflows({ namespace }));
@@ -109,8 +105,8 @@
workflowId: id,
workflowType: type,
});
- initialInput = initialValues.input;
- input = initialInput;
+ input = initialValues.input;
+ encoding = initialValues.encoding;
inputRetrieved = Date.now();
if (initialValues?.searchAttributes) {
const customSAKeys = Object.keys($customSearchAttributes);
@@ -232,31 +228,13 @@
label="Workflow Type"
on:blur={(e) => onInputChange(e, 'workflowType')}
/>
-
-
-
-
-
-
-
-
- {#key inputRetrieved}
-
- {/key}
- {#if !inputValid}
-
- {/if}
-
-
+ {#key inputRetrieved}
+
+
+
+
+
+ {/key}
{#if viewAdvancedOptions}
{/if}
diff --git a/src/lib/services/workflow-service.ts b/src/lib/services/workflow-service.ts
index 5ce0a2876..a7046f055 100644
--- a/src/lib/services/workflow-service.ts
+++ b/src/lib/services/workflow-service.ts
@@ -35,6 +35,7 @@ import type {
ListWorkflowExecutionsResponse,
WorkflowExecution,
} from '$lib/types/workflows';
+import { atob } from '$lib/utilities/atob';
import {
cloneAllPotentialPayloadsWithCodec,
type PotentiallyDecodable,
@@ -82,6 +83,7 @@ type SignalWorkflowOptions = {
workflow: WorkflowExecution;
name: string;
input: string;
+ encoding: string;
};
type StartWorkflowOptions = {
@@ -90,6 +92,7 @@ type StartWorkflowOptions = {
taskQueue: string;
workflowType: string;
input: string;
+ encoding: string;
searchAttributes: SearchAttributeInput[];
};
@@ -316,13 +319,14 @@ export async function signalWorkflow({
workflow: { id: workflowId, runId },
name,
input,
+ encoding,
}: SignalWorkflowOptions) {
const route = routeForApi('workflow.signal', {
namespace,
workflowId,
signalName: name,
});
- const payloads = await encodePayloads(input);
+ const payloads = await encodePayloads(input, encoding);
const settings = get(page).data.settings;
const version = settings?.version ?? '';
const newVersion = isVersionNewer(version, '2.22');
@@ -481,7 +485,9 @@ export const setSearchAttributes = (
const searchAttributes: SearchAttribute = {};
attributes.forEach((attribute) => {
- searchAttributes[attribute.attribute] = setBase64Payload(attribute.value);
+ searchAttributes[attribute.attribute] = setBase64Payload(
+ String(attribute.value),
+ );
});
return searchAttributes;
@@ -493,6 +499,7 @@ export async function startWorkflow({
taskQueue,
workflowType,
input,
+ encoding,
searchAttributes,
}: StartWorkflowOptions) {
const route = routeForApi('workflow', {
@@ -503,7 +510,7 @@ export async function startWorkflow({
if (input) {
try {
- payloads = await encodePayloads(input);
+ payloads = await encodePayloads(input, encoding);
} catch (_) {
console.error('Could not decode input for starting workflow');
}
@@ -547,12 +554,17 @@ export const fetchInitialValuesForStartWorkflow = async ({
workflowId?: string;
}): Promise<{
input: string;
+ encoding: string;
searchAttributes: Record | undefined;
}> => {
const handleError: ErrorCallback = (err) => {
console.error(err);
};
- const emptyValues = { input: '', searchAttributes: undefined };
+ const emptyValues = {
+ input: '',
+ encoding: 'json/plain',
+ searchAttributes: undefined,
+ };
try {
let query = '';
if (workflowType && workflowId) {
@@ -590,8 +602,15 @@ export const fetchInitialValuesForStartWorkflow = async ({
)) as PotentiallyDecodable;
const input = stringifyWithBigInt(convertedAttributes?.payloads[0]);
+ const encoding = atob(
+ String(
+ convertedAttributes?.payloads[0]?.metadata?.encoding ?? 'json/plain',
+ ),
+ );
+
return {
input,
+ encoding,
searchAttributes: workflow?.searchAttributes?.indexedFields,
};
} catch (e) {
diff --git a/src/lib/stores/schedules.ts b/src/lib/stores/schedules.ts
index 4a61e8fd1..872b5d109 100644
--- a/src/lib/stores/schedules.ts
+++ b/src/lib/stores/schedules.ts
@@ -88,6 +88,7 @@ export const submitCreateSchedule = async ({
workflowType,
taskQueue,
input,
+ encoding,
searchAttributes,
} = action;
@@ -95,7 +96,7 @@ export const submitCreateSchedule = async ({
if (input) {
try {
- payloads = await encodePayloads(input);
+ payloads = await encodePayloads(input, encoding);
} catch (e) {
error.set(`${translate('data-encoder.encode-error')}: ${e?.message}`);
return;
@@ -163,6 +164,7 @@ export const submitEditSchedule = async (
workflowType,
taskQueue,
input,
+ encoding,
searchAttributes,
} = action;
@@ -170,7 +172,7 @@ export const submitEditSchedule = async (
if (input) {
try {
- payloads = await encodePayloads(input);
+ payloads = await encodePayloads(input, encoding);
} catch (e) {
error.set(`${translate('data-encoder.encode-error')}: ${e?.message}`);
return;
diff --git a/src/lib/types/schedule.ts b/src/lib/types/schedule.ts
index 932989948..ca9632b31 100644
--- a/src/lib/types/schedule.ts
+++ b/src/lib/types/schedule.ts
@@ -38,6 +38,7 @@ export type ScheduleActionParameters = {
workflowId: string;
taskQueue: string;
input: string;
+ encoding: string;
searchAttributes: SearchAttributeInput[];
};
diff --git a/src/lib/utilities/decode-payload.ts b/src/lib/utilities/decode-payload.ts
index ec96a7e8b..70ac764a6 100644
--- a/src/lib/utilities/decode-payload.ts
+++ b/src/lib/utilities/decode-payload.ts
@@ -61,15 +61,15 @@ export function decodePayload(
const encoding = atob(String(payload?.metadata?.encoding ?? ''));
- if (encoding?.startsWith('json/')) {
- try {
- const data = parseWithBigInt(atob(String(payload?.data ?? '')));
- return returnDataOnly ? data : { ...payload, data };
- } catch (_e) {
- console.warn('Could not parse payload: ', _e);
- // Couldn't correctly decode this just let the user deal with the data as is
- }
+ // if (encoding?.startsWith('json/')) {
+ try {
+ const data = parseWithBigInt(atob(String(payload?.data ?? '')));
+ return returnDataOnly ? data : { ...payload, data };
+ } catch (_e) {
+ console.warn('Could not parse payload: ', _e);
+ // Couldn't correctly decode this just let the user deal with the data as is
}
+ // }
if (encoding === 'binary/null') {
return returnDataOnly ? null : { ...payload, data: null };
diff --git a/src/lib/utilities/encode-payload.ts b/src/lib/utilities/encode-payload.ts
index d4bf31cb0..4557d22a9 100644
--- a/src/lib/utilities/encode-payload.ts
+++ b/src/lib/utilities/encode-payload.ts
@@ -19,22 +19,21 @@ export const getSinglePayload = (decodedValue: string): string => {
return '';
};
-export const setBase64Payload = (payload: unknown) => {
+export const setBase64Payload = (payload: string, encoding = 'json/plain') => {
return {
metadata: {
- encoding: btoa('json/plain'),
+ encoding: btoa(encoding),
},
data: btoa(JSON.stringify(payload)),
};
};
-export const encodePayloads = async (input: string) => {
+export const encodePayloads = async (input: string, encoding: string) => {
let payloads = null;
if (input) {
const parsedInput = JSON.parse(input);
- payloads = [setBase64Payload(parsedInput)];
-
+ payloads = [setBase64Payload(parsedInput, encoding)];
const endpoint = get(dataEncoder).endpoint;
if (endpoint) {
const awaitData = await encodePayloadsWithCodec({
diff --git a/src/routes/(app)/nexus/[id]/edit/+page.svelte b/src/routes/(app)/nexus/[id]/edit/+page.svelte
index 9386bfe13..6827ca723 100644
--- a/src/routes/(app)/nexus/[id]/edit/+page.svelte
+++ b/src/routes/(app)/nexus/[id]/edit/+page.svelte
@@ -36,6 +36,7 @@
const payloads = await encodePayloads(
JSON.stringify(body.spec.descriptionString),
+ 'json/plain',
);
body.spec.description = payloads[0];
diff --git a/src/routes/(app)/nexus/create/+page.svelte b/src/routes/(app)/nexus/create/+page.svelte
index ffdf28588..e6688d887 100644
--- a/src/routes/(app)/nexus/create/+page.svelte
+++ b/src/routes/(app)/nexus/create/+page.svelte
@@ -21,6 +21,7 @@
const body = { ...$endpointForm };
const payloads = await encodePayloads(
JSON.stringify(body.spec.descriptionString),
+ 'json/plain',
);
body.spec.description = payloads[0];