feat: Add Cloud Code triggers Parse.Cloud.beforeSave and Parse.Cloud.afterSave for Parse Config (#9232)

This commit is contained in:
Diamond Lewis
2024-07-20 13:35:41 -05:00
committed by GitHub
parent 4d86ace2cc
commit 90a1e4a200
5 changed files with 308 additions and 5 deletions

View File

@@ -1027,3 +1027,38 @@ export async function maybeRunFileTrigger(triggerType, fileObject, config, auth)
}
return fileObject;
}
export async function maybeRunGlobalConfigTrigger(triggerType, auth, configObject, originalConfigObject, config, context) {
const GlobalConfigClassName = getClassName(Parse.Config);
const configTrigger = getTrigger(GlobalConfigClassName, triggerType, config.applicationId);
if (typeof configTrigger === 'function') {
try {
const request = getRequestObject(triggerType, auth, configObject, originalConfigObject, config, context);
await maybeRunValidator(request, `${triggerType}.${GlobalConfigClassName}`, auth);
if (request.skipWithMasterKey) {
return configObject;
}
const result = await configTrigger(request);
logTriggerSuccessBeforeHook(
triggerType,
'Parse.Config',
configObject,
result,
auth,
config.logLevels.triggerBeforeSuccess
);
return result || configObject;
} catch (error) {
logTriggerErrorBeforeHook(
triggerType,
'Parse.Config',
configObject,
auth,
error,
config.logLevels.triggerBeforeError
);
throw error;
}
}
return configObject;
}