( triggerType, auth, parseObject, originalParseObject, config, context, isGet )
| 273 | } |
| 274 | |
| 275 | export function getRequestObject( |
| 276 | triggerType, |
| 277 | auth, |
| 278 | parseObject, |
| 279 | originalParseObject, |
| 280 | config, |
| 281 | context, |
| 282 | isGet |
| 283 | ) { |
| 284 | const request = { |
| 285 | triggerName: triggerType, |
| 286 | object: parseObject, |
| 287 | master: false, |
| 288 | isReadOnly: false, |
| 289 | log: config.loggerController, |
| 290 | headers: config.headers, |
| 291 | ip: config.ip, |
| 292 | config, |
| 293 | }; |
| 294 | |
| 295 | if (isGet !== undefined) { |
| 296 | request.isGet = !!isGet; |
| 297 | } |
| 298 | |
| 299 | if (originalParseObject) { |
| 300 | request.original = originalParseObject; |
| 301 | } |
| 302 | if ( |
| 303 | triggerType === Types.beforeSave || |
| 304 | triggerType === Types.afterSave || |
| 305 | triggerType === Types.beforeDelete || |
| 306 | triggerType === Types.afterDelete || |
| 307 | triggerType === Types.beforeLogin || |
| 308 | triggerType === Types.afterLogin || |
| 309 | triggerType === Types.beforePasswordResetRequest || |
| 310 | triggerType === Types.afterFind |
| 311 | ) { |
| 312 | // Set a copy of the context on the request object. |
| 313 | request.context = Object.assign(Object.create(null), context); |
| 314 | } |
| 315 | |
| 316 | if (!auth) { |
| 317 | return request; |
| 318 | } |
| 319 | if (auth.isMaster) { |
| 320 | request['master'] = true; |
| 321 | } |
| 322 | if (auth.isReadOnly) { |
| 323 | request['isReadOnly'] = true; |
| 324 | } |
| 325 | if (auth.user) { |
| 326 | request['user'] = auth.user; |
| 327 | } |
| 328 | if (auth.installationId) { |
| 329 | request['installationId'] = auth.installationId; |
| 330 | } |
| 331 | return request; |
| 332 | } |
no test coverage detected