parse 8.0.1-alpha.1 → 8.0.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/parse.js +1 -1
- package/dist/parse.min.js +1 -1
- package/dist/parse.weapp.js +1 -1
- package/dist/parse.weapp.min.js +1 -1
- package/lib/browser/CloudCode.js +222 -195
- package/lib/browser/CoreManager.js +1 -1
- package/lib/node/CloudCode.js +221 -195
- package/lib/node/CoreManager.js +1 -1
- package/lib/react-native/CloudCode.js +12 -0
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/weapp/CloudCode.js +222 -195
- package/lib/weapp/CoreManager.js +1 -1
- package/package.json +12 -11
- package/types/CloudCode.d.ts +391 -175
- package/types/node.d.ts +46 -0
- package/types/tests.ts +238 -151
package/types/node.d.ts
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
1
|
import * as parse from './index';
|
|
2
2
|
|
|
3
|
+
// Augment Cloud module to include server-side types for parse/node
|
|
4
|
+
declare module './Cloud' {
|
|
5
|
+
// Request types - alias to CloudCode definitions
|
|
6
|
+
export type FunctionRequest<T = Record<string, any>> = import('./CloudCode').FunctionRequest<T>;
|
|
7
|
+
export type FunctionResponse = import('./CloudCode').FunctionResponse;
|
|
8
|
+
export type TriggerRequest<T extends import('./ParseObject').default = import('./ParseObject').default> = import('./CloudCode').TriggerRequest<T>;
|
|
9
|
+
export type BeforeSaveRequest<T extends import('./ParseObject').default = import('./ParseObject').default> = import('./CloudCode').BeforeSaveRequest<T>;
|
|
10
|
+
export type AfterSaveRequest<T extends import('./ParseObject').default = import('./ParseObject').default> = import('./CloudCode').AfterSaveRequest<T>;
|
|
11
|
+
export type BeforeDeleteRequest<T extends import('./ParseObject').default = import('./ParseObject').default> = import('./CloudCode').BeforeDeleteRequest<T>;
|
|
12
|
+
export type AfterDeleteRequest<T extends import('./ParseObject').default = import('./ParseObject').default> = import('./CloudCode').AfterDeleteRequest<T>;
|
|
13
|
+
export type BeforeFindRequest<T extends import('./ParseObject').default = import('./ParseObject').default> = import('./CloudCode').BeforeFindRequest<T>;
|
|
14
|
+
export type AfterFindRequest<T extends import('./ParseObject').default = import('./ParseObject').default> = import('./CloudCode').AfterFindRequest<T>;
|
|
15
|
+
export type FileTriggerRequest = import('./CloudCode').FileTriggerRequest;
|
|
16
|
+
export type ConnectTriggerRequest = import('./CloudCode').ConnectTriggerRequest;
|
|
17
|
+
export type LiveQueryEventTrigger<T extends import('./ParseObject').default = import('./ParseObject').default> = import('./CloudCode').LiveQueryEventTrigger<T>;
|
|
18
|
+
export type JobRequest = import('./CloudCode').JobRequest;
|
|
19
|
+
export type ValidatorField = import('./CloudCode').ValidatorField;
|
|
20
|
+
export type ValidatorObject = import('./CloudCode').ValidatorObject;
|
|
21
|
+
export type HTTPOptions = import('./CloudCode').HTTPOptions;
|
|
22
|
+
export type HTTPResponse = import('./CloudCode').HTTPResponse;
|
|
23
|
+
export const ReadPreferenceOption: typeof import('./CloudCode').ReadPreferenceOption;
|
|
24
|
+
|
|
25
|
+
// Functions - reuse signatures from CloudCode
|
|
26
|
+
export const define: typeof import('./CloudCode').define;
|
|
27
|
+
export const job: typeof import('./CloudCode').job;
|
|
28
|
+
export const beforeSave: typeof import('./CloudCode').beforeSave;
|
|
29
|
+
export const afterSave: typeof import('./CloudCode').afterSave;
|
|
30
|
+
export const beforeDelete: typeof import('./CloudCode').beforeDelete;
|
|
31
|
+
export const afterDelete: typeof import('./CloudCode').afterDelete;
|
|
32
|
+
export const beforeFind: typeof import('./CloudCode').beforeFind;
|
|
33
|
+
export const afterFind: typeof import('./CloudCode').afterFind;
|
|
34
|
+
export const beforeLogin: typeof import('./CloudCode').beforeLogin;
|
|
35
|
+
export const afterLogin: typeof import('./CloudCode').afterLogin;
|
|
36
|
+
export const afterLogout: typeof import('./CloudCode').afterLogout;
|
|
37
|
+
export const beforePasswordResetRequest: typeof import('./CloudCode').beforePasswordResetRequest;
|
|
38
|
+
export const beforeSaveFile: typeof import('./CloudCode').beforeSaveFile;
|
|
39
|
+
export const afterSaveFile: typeof import('./CloudCode').afterSaveFile;
|
|
40
|
+
export const beforeDeleteFile: typeof import('./CloudCode').beforeDeleteFile;
|
|
41
|
+
export const afterDeleteFile: typeof import('./CloudCode').afterDeleteFile;
|
|
42
|
+
export const beforeConnect: typeof import('./CloudCode').beforeConnect;
|
|
43
|
+
export const beforeSubscribe: typeof import('./CloudCode').beforeSubscribe;
|
|
44
|
+
export const afterLiveQueryEvent: typeof import('./CloudCode').afterLiveQueryEvent;
|
|
45
|
+
export const httpRequest: typeof import('./CloudCode').httpRequest;
|
|
46
|
+
export const sendEmail: typeof import('./CloudCode').sendEmail;
|
|
47
|
+
}
|
|
48
|
+
|
|
3
49
|
export = parse;
|
package/types/tests.ts
CHANGED
|
@@ -549,170 +549,256 @@ async function test_facebook_util() {
|
|
|
549
549
|
async function test_cloud_functions() {
|
|
550
550
|
// $ExpectType any
|
|
551
551
|
await Parse.Cloud.run('SomeFunction');
|
|
552
|
+
|
|
552
553
|
// $ExpectType any
|
|
553
554
|
await Parse.Cloud.run('SomeFunction', { something: 'whatever' });
|
|
555
|
+
|
|
554
556
|
// $ExpectType any
|
|
555
557
|
await Parse.Cloud.run('SomeFunction', null, { useMasterKey: true });
|
|
556
|
-
|
|
558
|
+
|
|
559
|
+
// $ExpectType boolean
|
|
557
560
|
await Parse.Cloud.run<() => boolean>('SomeFunction');
|
|
561
|
+
|
|
558
562
|
// $ExpectType boolean
|
|
559
563
|
await Parse.Cloud.run<() => boolean>('SomeFunction', null);
|
|
564
|
+
|
|
560
565
|
// $ExpectType boolean
|
|
561
566
|
await Parse.Cloud.run<() => boolean>('SomeFunction', null, { useMasterKey: true });
|
|
567
|
+
|
|
562
568
|
// $ExpectType number
|
|
563
|
-
await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction', {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
// $ExpectError
|
|
569
|
+
await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction', { paramA: 'hello' });
|
|
570
|
+
|
|
571
|
+
// @ts-expect-error - params are required
|
|
567
572
|
await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction');
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
573
|
+
|
|
574
|
+
// @ts-expect-error - wrong param name
|
|
575
|
+
await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction', { paramZ: 'hello' });
|
|
576
|
+
|
|
577
|
+
// @ts-expect-error - params are required, null not allowed
|
|
578
|
+
await Parse.Cloud.run<(params: { paramA: string }) => number>('SomeFunction', null, { useMasterKey: true });
|
|
579
|
+
|
|
580
|
+
// @ts-expect-error - params must be object not string
|
|
581
|
+
await Parse.Cloud.run<(params: string) => any>('SomeFunction', 'hello');
|
|
582
|
+
|
|
583
|
+
ParseNode.Cloud.afterDelete('MyCustomClass', request => {
|
|
584
|
+
request.object;
|
|
585
|
+
request.user;
|
|
571
586
|
});
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
587
|
+
|
|
588
|
+
ParseNode.Cloud.afterSave('MyCustomClass', request => {
|
|
589
|
+
if (!request.context) {
|
|
590
|
+
throw new Error('Request context should be defined');
|
|
591
|
+
}
|
|
592
|
+
request.object;
|
|
575
593
|
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
594
|
+
|
|
595
|
+
ParseNode.Cloud.beforeDelete('MyCustomClass', request => {
|
|
596
|
+
request.object;
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
ParseNode.Cloud.beforeSave('MyCustomClass', request => {
|
|
600
|
+
if (request.object.isNew()) {
|
|
601
|
+
if (!request.object.has('immutable')) throw new Error('Field immutable is required');
|
|
602
|
+
} else {
|
|
603
|
+
const original = request.original;
|
|
604
|
+
if (original == null) {
|
|
605
|
+
throw new Error('Original must be defined for an existing object');
|
|
606
|
+
}
|
|
607
|
+
if (original.get('immutable') !== request.object.get('immutable')) {
|
|
608
|
+
throw new Error('This field cannot be changed');
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
if (!request.context) {
|
|
612
|
+
throw new Error('Request context should be defined');
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
ParseNode.Cloud.beforeFind('MyCustomClass', request => {
|
|
617
|
+
request.query;
|
|
618
|
+
request.user;
|
|
619
|
+
request.master;
|
|
620
|
+
request.count;
|
|
621
|
+
request.isGet;
|
|
622
|
+
|
|
623
|
+
request.readPreference = ParseNode.Cloud.ReadPreferenceOption.Primary;
|
|
624
|
+
request.readPreference = ParseNode.Cloud.ReadPreferenceOption.PrimaryPreferred;
|
|
625
|
+
request.readPreference = ParseNode.Cloud.ReadPreferenceOption.Secondary;
|
|
626
|
+
request.readPreference = ParseNode.Cloud.ReadPreferenceOption.SecondaryPreferred;
|
|
627
|
+
request.readPreference = ParseNode.Cloud.ReadPreferenceOption.Nearest;
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
ParseNode.Cloud.beforeFind('MyCustomClass', request => {
|
|
631
|
+
request.query;
|
|
632
|
+
return new Parse.Query('QueryMe!');
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
ParseNode.Cloud.afterFind('MyCustomClass', request => {
|
|
636
|
+
request.results;
|
|
637
|
+
return request.results;
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
ParseNode.Cloud.beforeLogin(request => {
|
|
641
|
+
request.object;
|
|
642
|
+
request.user;
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
ParseNode.Cloud.afterLogin(request => {
|
|
646
|
+
request.object;
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
ParseNode.Cloud.afterLogout(request => {
|
|
650
|
+
request.object;
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
ParseNode.Cloud.beforeSaveFile(request => {
|
|
654
|
+
request.file;
|
|
655
|
+
request.fileSize;
|
|
656
|
+
return new Parse.File('myFile.txt', { base64: '' });
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
ParseNode.Cloud.beforeSaveFile(request => {
|
|
660
|
+
request.file;
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
ParseNode.Cloud.beforeDeleteFile(request => {
|
|
664
|
+
request.file;
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
ParseNode.Cloud.afterDeleteFile(request => {
|
|
668
|
+
request.file;
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
ParseNode.Cloud.beforeConnect(request => {
|
|
672
|
+
request.user;
|
|
673
|
+
request.installationId;
|
|
674
|
+
request.useMasterKey;
|
|
675
|
+
request.clients;
|
|
676
|
+
request.subscriptions;
|
|
677
|
+
request.sessionToken;
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
ParseNode.Cloud.beforeSubscribe('MyCustomClass', request => {
|
|
681
|
+
request.object;
|
|
682
|
+
request.user;
|
|
683
|
+
request.original;
|
|
684
|
+
request.installationId;
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
ParseNode.Cloud.afterLiveQueryEvent('MyCustomClass', request => {
|
|
688
|
+
request.event;
|
|
689
|
+
request.object;
|
|
690
|
+
request.original;
|
|
691
|
+
request.user;
|
|
692
|
+
request.sendEvent;
|
|
693
|
+
request.clients;
|
|
694
|
+
request.subscriptions;
|
|
695
|
+
request.sessionToken;
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
ParseNode.Cloud.beforePasswordResetRequest(request => {
|
|
699
|
+
request.object;
|
|
700
|
+
request.user;
|
|
701
|
+
request.master;
|
|
702
|
+
request.ip;
|
|
703
|
+
request.headers;
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
void ParseNode.Cloud.httpRequest({
|
|
707
|
+
url: 'https://example.com',
|
|
708
|
+
method: 'GET',
|
|
709
|
+
headers: { 'Content-Type': 'application/json' },
|
|
710
|
+
body: { key: 'value' },
|
|
711
|
+
followRedirects: true,
|
|
712
|
+
}).then(response => {
|
|
713
|
+
response.status;
|
|
714
|
+
response.data;
|
|
715
|
+
response.text;
|
|
716
|
+
response.headers;
|
|
717
|
+
response.buffer;
|
|
718
|
+
response.cookies;
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
void ParseNode.Cloud.sendEmail({
|
|
722
|
+
to: 'test@example.com',
|
|
723
|
+
from: 'sender@example.com',
|
|
724
|
+
subject: 'Test Subject',
|
|
725
|
+
text: 'Plain text content',
|
|
726
|
+
html: '<p>HTML content</p>',
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
ParseNode.Cloud.define('AFunc', request => {
|
|
730
|
+
request.params;
|
|
731
|
+
return 'Some result';
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
ParseNode.Cloud.define(
|
|
735
|
+
'AFunc',
|
|
736
|
+
request => {
|
|
737
|
+
request.params;
|
|
738
|
+
return 'Some result';
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
requireUser: true,
|
|
742
|
+
requireMaster: true,
|
|
743
|
+
validateMasterKey: true,
|
|
744
|
+
skipWithMasterKey: true,
|
|
745
|
+
requireAnyUserRoles: ['a'],
|
|
746
|
+
requireAllUserRoles: ['a'],
|
|
747
|
+
fields: {
|
|
748
|
+
name: {
|
|
749
|
+
type: String,
|
|
750
|
+
constant: true,
|
|
751
|
+
default: true,
|
|
752
|
+
options: [],
|
|
753
|
+
error: 'invalid field.',
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
requireUserKeys: {
|
|
757
|
+
name: {
|
|
758
|
+
type: String,
|
|
759
|
+
constant: true,
|
|
760
|
+
default: true,
|
|
761
|
+
options: [],
|
|
762
|
+
error: 'invalid field.',
|
|
763
|
+
},
|
|
764
|
+
},
|
|
765
|
+
},
|
|
766
|
+
);
|
|
767
|
+
|
|
768
|
+
ParseNode.Cloud.define('AFunc', request => {
|
|
769
|
+
request.params;
|
|
770
|
+
request.params.anything;
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
ParseNode.Cloud.job('AJob', request => {
|
|
774
|
+
request.params;
|
|
775
|
+
request.message('Message to associate with this job run');
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
void Parse.Cloud.startJob('AJob', {}).then(v => v);
|
|
779
|
+
|
|
780
|
+
void Parse.Cloud.getJobStatus('AJob').then(v => v);
|
|
781
|
+
|
|
782
|
+
void Parse.Cloud.getJobsData().then(v => v);
|
|
783
|
+
|
|
784
|
+
// @ts-expect-error - define should not exist on browser Parse.Cloud
|
|
785
|
+
Parse.Cloud.define('test', () => {});
|
|
786
|
+
// @ts-expect-error - beforeSave should not exist on browser Parse.Cloud
|
|
787
|
+
Parse.Cloud.beforeSave('Test', () => {});
|
|
788
|
+
// @ts-expect-error - job should not exist on browser Parse.Cloud
|
|
789
|
+
Parse.Cloud.job('test', () => {});
|
|
790
|
+
// @ts-expect-error - httpRequest should not exist on browser Parse.Cloud
|
|
791
|
+
void Parse.Cloud.httpRequest({ url: '' });
|
|
792
|
+
// @ts-expect-error - beforeConnect should not exist on browser Parse.Cloud
|
|
793
|
+
Parse.Cloud.beforeConnect(() => {});
|
|
794
|
+
// @ts-expect-error - beforeSubscribe should not exist on browser Parse.Cloud
|
|
795
|
+
Parse.Cloud.beforeSubscribe('Test', () => {});
|
|
796
|
+
// @ts-expect-error - afterLiveQueryEvent should not exist on browser Parse.Cloud
|
|
797
|
+
Parse.Cloud.afterLiveQueryEvent('Test', () => {});
|
|
798
|
+
// @ts-expect-error - beforePasswordResetRequest should not exist on browser Parse.Cloud
|
|
799
|
+
Parse.Cloud.beforePasswordResetRequest(() => {});
|
|
800
|
+
// @ts-expect-error - sendEmail should not exist on browser Parse.Cloud
|
|
801
|
+
void Parse.Cloud.sendEmail({ to: '' });
|
|
716
802
|
}
|
|
717
803
|
|
|
718
804
|
class PlaceObject extends Parse.Object {}
|
|
@@ -2256,3 +2342,4 @@ function LiveQueryEvents() {
|
|
|
2256
2342
|
Parse.LiveQuery.on('error', (error: any) => {});
|
|
2257
2343
|
}
|
|
2258
2344
|
}
|
|
2345
|
+
|