mirror of
https://github.com/penpot/penpot.git
synced 2026-09-14 07:59:36 +00:00
✨ Apply throwValidationErrors flag during MCP code executions #8682
This commit is contained in:
parent
1539c074b4
commit
1f7afcebe3
@ -195,16 +195,19 @@ export class ExecuteCodeTaskHandler extends TaskHandler<ExecuteCodeTaskParams> {
|
|||||||
const context = this.context;
|
const context = this.context;
|
||||||
const code = task.params.code;
|
const code = task.params.code;
|
||||||
|
|
||||||
// set the penpot.flags.naturalChildOrdering to true during code execution.
|
// set the flags naturalChildOrdering and throwValidationErrors to true during code execution.
|
||||||
// NOTE: This significantly simplifies API usage (see )
|
// TODO: Remove all ts-ignore once Penpot types have been updated
|
||||||
// TODO: Remove ts-ignore once Penpot types have been updated
|
let originalNaturalChildOrdering: any, originalThrowValidationErrors: any;
|
||||||
let originalNaturalChildOrdering: any;
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (penpot.flags) {
|
if (penpot.flags) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
originalNaturalChildOrdering = penpot.flags.naturalChildOrdering;
|
originalNaturalChildOrdering = penpot.flags.naturalChildOrdering;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
penpot.flags.naturalChildOrdering = true;
|
penpot.flags.naturalChildOrdering = true;
|
||||||
|
// @ts-ignore
|
||||||
|
originalThrowValidationErrors = penpot.flags.throwValidationErrors;
|
||||||
|
// @ts-ignore
|
||||||
|
penpot.flags.throwValidationErrors = true;
|
||||||
} else {
|
} else {
|
||||||
// TODO: This can be removed once `flags` has been merged to PROD
|
// TODO: This can be removed once `flags` has been merged to PROD
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -224,9 +227,11 @@ export class ExecuteCodeTaskHandler extends TaskHandler<ExecuteCodeTaskParams> {
|
|||||||
return fn(...Object.values(ctx));
|
return fn(...Object.values(ctx));
|
||||||
})(context);
|
})(context);
|
||||||
} finally {
|
} finally {
|
||||||
// restore the original value of penpot.flags.naturalChildOrdering
|
// restore the original value of the flags
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
penpot.flags.naturalChildOrdering = originalNaturalChildOrdering;
|
penpot.flags.naturalChildOrdering = originalNaturalChildOrdering;
|
||||||
|
// @ts-ignore
|
||||||
|
penpot.flags.throwValidationErrors = originalThrowValidationErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Code execution result:", result);
|
console.log("Code execution result:", result);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user