Skip to content

Commit 837aabc

Browse files
authored
v0.5.32: google sheets fix, schedule input format
2 parents f9cfca9 + f7d2c96 commit 837aabc

File tree

3 files changed

+39
-26
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/starter
    • blocks/blocks
    • serializer

3 files changed

+39
-26
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/starter/input-format.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ export function FieldFormat({
9191
placeholder = 'fieldName',
9292
showType = true,
9393
showValue = false,
94-
valuePlaceholder = 'Enter test value',
95-
config,
94+
valuePlaceholder = 'Enter default value',
9695
}: FieldFormatProps) {
9796
const [storeValue, setStoreValue] = useSubBlockValue<Field[]>(blockId, subBlockId)
9897
const valueInputRefs = useRef<Record<string, HTMLInputElement | HTMLTextAreaElement>>({})
@@ -454,7 +453,6 @@ export function FieldFormat({
454453
)
455454
}
456455

457-
// Export specific components for backward compatibility
458456
export function InputFormat(props: Omit<FieldFormatProps, 'title' | 'placeholder'>) {
459457
return <FieldFormat {...props} title='Input' placeholder='firstName' />
460458
}

apps/sim/blocks/blocks/schedule.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ export const ScheduleBlock: BlockConfig = {
155155
condition: { field: 'scheduleType', value: ['minutes', 'hourly'], not: true },
156156
},
157157

158+
{
159+
id: 'inputFormat',
160+
title: 'Input Format',
161+
type: 'input-format',
162+
description:
163+
'Define input parameters that will be available when the schedule triggers. Use Value to set default values for scheduled executions.',
164+
mode: 'trigger',
165+
},
166+
158167
{
159168
id: 'scheduleSave',
160169
type: 'schedule-save',

apps/sim/serializer/index.ts

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,7 @@ export class Serializer {
402402

403403
// Second pass: filter by mode and conditions
404404
Object.entries(block.subBlocks).forEach(([id, subBlock]) => {
405-
// Find the corresponding subblock config to check its mode and condition
406-
const subBlockConfig = blockConfig.subBlocks.find((config) => config.id === id)
405+
const matchingConfigs = blockConfig.subBlocks.filter((config) => config.id === id)
407406

408407
// Include field if it matches current mode OR if it's the starter inputFormat with values
409408
const hasStarterInputFormatValues =
@@ -417,13 +416,17 @@ export class Serializer {
417416
const isLegacyAgentField =
418417
isAgentBlock && ['systemPrompt', 'userPrompt', 'memories'].includes(id)
419418

420-
// Check if field's condition is met (conditionally-hidden fields should be excluded)
421-
const conditionMet = subBlockConfig
422-
? evaluateCondition(subBlockConfig.condition, allValues)
423-
: true
419+
const anyConditionMet =
420+
matchingConfigs.length === 0
421+
? true
422+
: matchingConfigs.some(
423+
(config) =>
424+
shouldIncludeField(config, isAdvancedMode) &&
425+
evaluateCondition(config.condition, allValues)
426+
)
424427

425428
if (
426-
(subBlockConfig && shouldIncludeField(subBlockConfig, isAdvancedMode) && conditionMet) ||
429+
(matchingConfigs.length > 0 && anyConditionMet) ||
427430
hasStarterInputFormatValues ||
428431
isLegacyAgentField
429432
) {
@@ -540,26 +543,26 @@ export class Serializer {
540543
// Iterate through the tool's parameters, not the block's subBlocks
541544
Object.entries(currentTool.params || {}).forEach(([paramId, paramConfig]) => {
542545
if (paramConfig.required && paramConfig.visibility === 'user-only') {
543-
const subBlockConfig = blockConfig.subBlocks?.find((sb: any) => sb.id === paramId)
546+
const matchingConfigs = blockConfig.subBlocks?.filter((sb: any) => sb.id === paramId) || []
544547

545548
let shouldValidateParam = true
546549

547-
if (subBlockConfig) {
550+
if (matchingConfigs.length > 0) {
548551
const isAdvancedMode = block.advancedMode ?? false
549-
const includedByMode = shouldIncludeField(subBlockConfig, isAdvancedMode)
550552

551-
// Check visibility condition
552-
const includedByCondition = evaluateCondition(subBlockConfig.condition, params)
553+
shouldValidateParam = matchingConfigs.some((subBlockConfig: any) => {
554+
const includedByMode = shouldIncludeField(subBlockConfig, isAdvancedMode)
553555

554-
// Check if field is required based on its required condition (if it's a condition object)
555-
const isRequired = (() => {
556-
if (!subBlockConfig.required) return false
557-
if (typeof subBlockConfig.required === 'boolean') return subBlockConfig.required
558-
// If required is a condition object, evaluate it
559-
return evaluateCondition(subBlockConfig.required, params)
560-
})()
556+
const includedByCondition = evaluateCondition(subBlockConfig.condition, params)
561557

562-
shouldValidateParam = includedByMode && includedByCondition && isRequired
558+
const isRequired = (() => {
559+
if (!subBlockConfig.required) return false
560+
if (typeof subBlockConfig.required === 'boolean') return subBlockConfig.required
561+
return evaluateCondition(subBlockConfig.required, params)
562+
})()
563+
564+
return includedByMode && includedByCondition && isRequired
565+
})
563566
}
564567

565568
if (!shouldValidateParam) {
@@ -568,7 +571,12 @@ export class Serializer {
568571

569572
const fieldValue = params[paramId]
570573
if (fieldValue === undefined || fieldValue === null || fieldValue === '') {
571-
const displayName = subBlockConfig?.title || paramId
574+
const activeConfig = matchingConfigs.find(
575+
(config: any) =>
576+
shouldIncludeField(config, block.advancedMode ?? false) &&
577+
evaluateCondition(config.condition, params)
578+
)
579+
const displayName = activeConfig?.title || paramId
572580
missingFields.push(displayName)
573581
}
574582
}
@@ -596,8 +604,6 @@ export class Serializer {
596604
const accessibleIds = new Set<string>(ancestorIds)
597605
accessibleIds.add(blockId)
598606

599-
// Only add starter block if it's actually upstream (already in ancestorIds)
600-
// Don't add it just because it exists on the canvas
601607
if (starterBlock && ancestorIds.includes(starterBlock.id)) {
602608
accessibleIds.add(starterBlock.id)
603609
}

0 commit comments

Comments
 (0)