Resolve prolems with saved task (#1340)
This commit is contained in:
@@ -121,7 +121,10 @@ function CreateNewTaskFormPage() {
|
||||
dataExtractionGoal:
|
||||
data.workflow_definition.blocks[0].data_extraction_goal,
|
||||
extractedInformationSchema: JSON.stringify(dataSchema, null, 2),
|
||||
navigationPayload,
|
||||
navigationPayload:
|
||||
typeof navigationPayload === "string"
|
||||
? navigationPayload
|
||||
: JSON.stringify(navigationPayload, null, 2),
|
||||
maxStepsOverride,
|
||||
totpIdentifier: data.workflow_definition.blocks[0].totp_identifier,
|
||||
totpVerificationUrl:
|
||||
|
||||
@@ -43,61 +43,35 @@ function transform(value: unknown) {
|
||||
}
|
||||
|
||||
function createTaskRequestObject(formValues: SavedTaskFormValues) {
|
||||
let extractedInformationSchema = null;
|
||||
if (formValues.extractedInformationSchema) {
|
||||
try {
|
||||
extractedInformationSchema = JSON.parse(
|
||||
formValues.extractedInformationSchema,
|
||||
);
|
||||
} catch (e) {
|
||||
extractedInformationSchema = formValues.extractedInformationSchema;
|
||||
}
|
||||
}
|
||||
|
||||
let errorCodeMapping = null;
|
||||
if (formValues.errorCodeMapping) {
|
||||
try {
|
||||
errorCodeMapping = JSON.parse(formValues.errorCodeMapping);
|
||||
} catch (e) {
|
||||
errorCodeMapping = formValues.errorCodeMapping;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
title: formValues.title,
|
||||
url: formValues.url,
|
||||
webhook_callback_url: transform(formValues.webhookCallbackUrl),
|
||||
navigation_goal: transform(formValues.navigationGoal),
|
||||
data_extraction_goal: transform(formValues.dataExtractionGoal),
|
||||
proxy_location: transform(formValues.proxyLocation),
|
||||
navigation_payload: transform(formValues.navigationPayload),
|
||||
extracted_information_schema: extractedInformationSchema,
|
||||
extracted_information_schema: safeParseMaybeJSONString(
|
||||
formValues.extractedInformationSchema,
|
||||
),
|
||||
totp_verification_url: transform(formValues.totpVerificationUrl),
|
||||
totp_identifier: transform(formValues.totpIdentifier),
|
||||
error_code_mapping: errorCodeMapping,
|
||||
error_code_mapping: safeParseMaybeJSONString(formValues.errorCodeMapping),
|
||||
};
|
||||
}
|
||||
|
||||
function safeParseMaybeJSONString(payload: unknown) {
|
||||
if (typeof payload === "string") {
|
||||
try {
|
||||
return JSON.parse(payload);
|
||||
} catch {
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
function createTaskTemplateRequestObject(values: SavedTaskFormValues) {
|
||||
let extractedInformationSchema = null;
|
||||
if (values.extractedInformationSchema) {
|
||||
try {
|
||||
extractedInformationSchema = JSON.parse(
|
||||
values.extractedInformationSchema,
|
||||
);
|
||||
} catch (e) {
|
||||
extractedInformationSchema = values.extractedInformationSchema;
|
||||
}
|
||||
}
|
||||
|
||||
let errorCodeMapping = null;
|
||||
if (values.errorCodeMapping) {
|
||||
try {
|
||||
errorCodeMapping = JSON.parse(values.errorCodeMapping);
|
||||
} catch (e) {
|
||||
errorCodeMapping = values.errorCodeMapping;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
title: values.title,
|
||||
description: values.description,
|
||||
@@ -110,7 +84,7 @@ function createTaskTemplateRequestObject(values: SavedTaskFormValues) {
|
||||
parameter_type: "workflow",
|
||||
workflow_parameter_type: "json",
|
||||
key: "navigation_payload",
|
||||
default_value: JSON.stringify(values.navigationPayload),
|
||||
default_value: safeParseMaybeJSONString(values.navigationPayload),
|
||||
},
|
||||
],
|
||||
blocks: [
|
||||
@@ -120,11 +94,13 @@ function createTaskTemplateRequestObject(values: SavedTaskFormValues) {
|
||||
url: values.url,
|
||||
navigation_goal: values.navigationGoal,
|
||||
data_extraction_goal: values.dataExtractionGoal,
|
||||
data_schema: extractedInformationSchema,
|
||||
data_schema: safeParseMaybeJSONString(
|
||||
values.extractedInformationSchema,
|
||||
),
|
||||
max_steps_per_run: values.maxStepsOverride,
|
||||
totp_verification_url: values.totpVerificationUrl,
|
||||
totp_identifier: values.totpIdentifier,
|
||||
error_code_mapping: errorCodeMapping,
|
||||
error_code_mapping: safeParseMaybeJSONString(values.errorCodeMapping),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user