MCPcopy Create free account
hub / github.com/parse-community/parse-dashboard / executeScript

Function executeScript

src/lib/ScriptUtils.js:81–111  ·  view source on GitHub ↗
(script, className, objectId, showNote, onRefresh, onRefreshObjects, onFormResponse)

Source from the content-addressed store, hash-verified

79 * @param {Function} onFormResponse - Callback when response contains a form definition
80 */
81export async function executeScript(script, className, objectId, showNote, onRefresh, onRefreshObjects, onFormResponse) {
82 try {
83 const object = Parse.Object.extend(className).createWithoutData(objectId);
84 const response = await Parse.Cloud.run(
85 script.cloudCodeFunction,
86 { object: object.toPointer() },
87 { useMasterKey: true }
88 );
89 if (isFormResponse(response) && onFormResponse) {
90 onFormResponse({
91 response,
92 script,
93 className,
94 objectIds: [objectId],
95 });
96 return;
97 }
98 const note =
99 (typeof response === 'object' ? JSON.stringify(response) : response) ||
100 `Ran script "${script.title}" on "${className}" object "${object.id}".`;
101 showNote?.(note);
102 if (onRefreshObjects) {
103 onRefreshObjects([objectId]);
104 } else {
105 onRefresh?.();
106 }
107 } catch (e) {
108 showNote?.(e.message, true);
109 console.error(`Could not run ${script.title}:`, e);
110 }
111}
112
113/**
114 * Executes a script callback after form submission

Callers 1

Calls 3

isFormResponseFunction · 0.85
showNoteFunction · 0.50
onRefreshFunction · 0.50

Tested by

no test coverage detected