diff --git a/apps/api/src/app/workflows-v2/usecases/build-payload-schema/build-payload-schema.usecase.ts b/apps/api/src/app/workflows-v2/usecases/build-payload-schema/build-payload-schema.usecase.ts index 1c4bcbf717e..a17ea777f8f 100644 --- a/apps/api/src/app/workflows-v2/usecases/build-payload-schema/build-payload-schema.usecase.ts +++ b/apps/api/src/app/workflows-v2/usecases/build-payload-schema/build-payload-schema.usecase.ts @@ -17,12 +17,20 @@ export class BuildPayloadSchema { const controlValues = await this.buildControlValues(command); if (!controlValues.length) { - return {}; + return { + type: 'object', + properties: {}, + additionalProperties: true, + }; } const templateVars = this.extractTemplateVariables(controlValues); if (templateVars.length === 0) { - return {}; + return { + type: 'object', + properties: {}, + additionalProperties: true, + }; } const variablesExample = pathsToObject(templateVars, { diff --git a/apps/api/src/app/workflows-v2/usecases/build-variable-schema/build-available-variable-schema.usecase.ts b/apps/api/src/app/workflows-v2/usecases/build-variable-schema/build-available-variable-schema.usecase.ts index 5f08ff76558..aeaef56a4c5 100644 --- a/apps/api/src/app/workflows-v2/usecases/build-variable-schema/build-available-variable-schema.usecase.ts +++ b/apps/api/src/app/workflows-v2/usecases/build-variable-schema/build-available-variable-schema.usecase.ts @@ -39,6 +39,12 @@ export class BuildAvailableVariableSchemaUsecase { format: 'date-time', description: 'The last time the subscriber was online (optional)', }, + data: { + type: 'object', + properties: {}, + description: 'Additional data about the subscriber', + additionalProperties: true, + }, }, required: ['firstName', 'lastName', 'email', 'subscriberId'], additionalProperties: false, @@ -56,7 +62,13 @@ export class BuildAvailableVariableSchemaUsecase { command: BuildAvailableVariableSchemaCommand ): Promise { if (workflow.payloadSchema) { - return parsePayloadSchema(workflow.payloadSchema, { safe: true }) || {}; + return ( + parsePayloadSchema(workflow.payloadSchema, { safe: true }) || { + type: 'object', + properties: {}, + additionalProperties: true, + } + ); } return this.buildPayloadSchema.execute( diff --git a/apps/dashboard/src/utils/parseStepVariablesToLiquidVariables.ts b/apps/dashboard/src/utils/parseStepVariablesToLiquidVariables.ts index 24c3ab6be14..a8d02515f52 100644 --- a/apps/dashboard/src/utils/parseStepVariablesToLiquidVariables.ts +++ b/apps/dashboard/src/utils/parseStepVariablesToLiquidVariables.ts @@ -20,11 +20,13 @@ export function parseStepVariablesToLiquidVariables(schema: JSONSchemaDefinition for (const [key, value] of Object.entries(obj.properties)) { const fullPath = path ? `${path}.${key}` : key; - // Add each property as a variable for autocompletion - variables.push({ - type: 'variable', - label: `${fullPath}`, - }); + // Only push variables that are not of type "object" or have additionalProperties set to true + if (typeof value === 'object' && (value.type !== 'object' || value.additionalProperties === true)) { + variables.push({ + type: 'variable', + label: `${fullPath}`, + }); + } // Recursively process nested objects if (typeof value === 'object' && (value.type === 'object' || value.type === 'array')) {