Skip to content

Commit 985d516

Browse files
authored
Do a better job merging argument schema (specifically definitions). (#1801)
1 parent 95a1674 commit 985d516

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

packages/runner/src/runner.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,14 +585,32 @@ export class Runner implements IRunner {
585585
syncAllMentionedCells(inputs);
586586
await Promise.all(promises);
587587

588-
const sourceCell = resultCell.getSourceCell({
588+
// TODO(@ubik2): Move this to a more general method in schema.ts or cfc.ts
589+
const processCellSchema: any = {
589590
type: "object",
590591
properties: {
591592
[TYPE]: { type: "string" },
592-
argument: recipe.argumentSchema ?? {},
593+
argument: recipe.argumentSchema ?? true,
593594
},
594595
required: [TYPE],
595-
});
596+
};
597+
598+
if (
599+
isRecord(processCellSchema) && "properties" in processCellSchema &&
600+
isObject(recipe.argumentSchema)
601+
) {
602+
// extract $defs and definitions and remove them from argumentSchema
603+
const { $defs, definitions, ...rest } = recipe.argumentSchema;
604+
(processCellSchema as any).properties.argument = rest ?? true;
605+
if (isRecord($defs)) {
606+
(processCellSchema as any).$defs = $defs;
607+
}
608+
if (isRecord(definitions)) {
609+
(processCellSchema as any).definitions = definitions;
610+
}
611+
}
612+
613+
const sourceCell = resultCell.getSourceCell(processCellSchema);
596614
if (!sourceCell) return false;
597615

598616
await sourceCell.sync();

0 commit comments

Comments
 (0)