mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
[Parse] Add missing context on AfterSaveRequest and BeforeSaveRequest (#34944)
* Add missing context on AfterSaveRequest and BeforeSaveRequest * Before/After SaveRequest: switch context from any to object
This commit is contained in:
parent
e09e79218d
commit
8445dd431b
9
types/parse/index.d.ts
vendored
9
types/parse/index.d.ts
vendored
@ -10,6 +10,7 @@
|
||||
// Alexandre Hétu Rivard <https://github.com/AlexandreHetu>
|
||||
// Diamond Lewis <https://github.com/dplewis>
|
||||
// Jong Eun Lee <https://github.com/yomybaby>
|
||||
// Julien Quere <https://github.com/jlnquere>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@ -784,10 +785,14 @@ subscription.on('close', () => {});
|
||||
original?: Parse.Object;
|
||||
}
|
||||
|
||||
interface AfterSaveRequest extends TriggerRequest { }
|
||||
interface AfterSaveRequest extends TriggerRequest {
|
||||
context: object;
|
||||
}
|
||||
interface AfterDeleteRequest extends TriggerRequest { }
|
||||
interface BeforeDeleteRequest extends TriggerRequest { }
|
||||
interface BeforeSaveRequest extends TriggerRequest { }
|
||||
interface BeforeSaveRequest extends TriggerRequest {
|
||||
context: object;
|
||||
}
|
||||
|
||||
// Read preference describes how MongoDB driver route read operations to the members of a replica set.
|
||||
enum ReadPreferenceOption {
|
||||
|
||||
@ -375,6 +375,9 @@ function test_cloud_functions() {
|
||||
});
|
||||
|
||||
Parse.Cloud.afterSave('MyCustomClass', (request: Parse.Cloud.AfterSaveRequest) => {
|
||||
if(!request.context) {
|
||||
throw new Error('Request context should be defined')
|
||||
}
|
||||
// result
|
||||
});
|
||||
|
||||
@ -390,6 +393,7 @@ function test_cloud_functions() {
|
||||
const CUSTOM_ERROR_IMMUTABLE_FIELD = 1002
|
||||
|
||||
Parse.Cloud.beforeSave('MyCustomClass', async (request: Parse.Cloud.BeforeSaveRequest) => {
|
||||
|
||||
if (request.object.isNew()) {
|
||||
if (!request.object.has('immutable')) throw new Error('Field immutable is required')
|
||||
} else {
|
||||
@ -402,6 +406,9 @@ function test_cloud_functions() {
|
||||
throw new Parse.Error(CUSTOM_ERROR_IMMUTABLE_FIELD, 'This field cannot be changed')
|
||||
}
|
||||
}
|
||||
if(!request.context) {
|
||||
throw new Error('Request context should be defined')
|
||||
}
|
||||
});
|
||||
|
||||
Parse.Cloud.beforeFind('MyCustomClass', (request: Parse.Cloud.BeforeFindRequest) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user