proto.io 0.0.216 → 0.0.218
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/dist/adapters/file/aliyun-oss.d.ts +3 -3
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/database.js +2 -2
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/filesystem.d.ts +3 -3
- package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
- package/dist/adapters/storage/progres.d.ts +5 -3
- package/dist/adapters/storage/progres.js +511 -148
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +511 -148
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -8
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +3 -3
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +28 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -29
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-BO3ZP6EF.d.ts → base-CqeIQTE9.d.ts} +2 -2
- package/dist/internals/base-CqeIQTE9.d.ts.map +1 -0
- package/dist/internals/{chunk-DDkLpKXp.d.ts → chunk-CLKTwfRe.d.ts} +3 -3
- package/dist/internals/chunk-CLKTwfRe.d.ts.map +1 -0
- package/dist/internals/{index-B8TESzd9.js → index-CLKTEIj0.js} +2 -2
- package/dist/internals/index-CLKTEIj0.js.map +1 -0
- package/dist/internals/{index-DF2AfSGK.mjs → index-CZ5fKgiJ.mjs} +159 -166
- package/dist/internals/index-CZ5fKgiJ.mjs.map +1 -0
- package/dist/internals/{index-CYhA8SU8.d.ts → index-Ci8d33k-.d.ts} +3 -9
- package/dist/internals/index-Ci8d33k-.d.ts.map +1 -0
- package/dist/internals/{index-HdMgLYtD.d.ts → index-DQHWdslW.d.ts} +59 -22
- package/dist/internals/index-DQHWdslW.d.ts.map +1 -0
- package/dist/internals/{index-BzDsTt4R.mjs → index-gWcE22mf.mjs} +2 -2
- package/dist/internals/index-gWcE22mf.mjs.map +1 -0
- package/dist/internals/{index-DfnPpl1I.js → index-xHeu-AjT.js} +158 -171
- package/dist/internals/index-xHeu-AjT.js.map +1 -0
- package/dist/internals/{validator-BBjOdLiT.js → validator-B5yHpyvb.js} +743 -36
- package/dist/internals/validator-B5yHpyvb.js.map +1 -0
- package/dist/internals/{validator-LNgZGT_l.mjs → validator-DX2nXeQo.mjs} +736 -35
- package/dist/internals/validator-DX2nXeQo.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/internals/base-BO3ZP6EF.d.ts.map +0 -1
- package/dist/internals/chunk-DDkLpKXp.d.ts.map +0 -1
- package/dist/internals/index-B8TESzd9.js.map +0 -1
- package/dist/internals/index-BzDsTt4R.mjs.map +0 -1
- package/dist/internals/index-CYhA8SU8.d.ts.map +0 -1
- package/dist/internals/index-DF2AfSGK.mjs.map +0 -1
- package/dist/internals/index-DfnPpl1I.js.map +0 -1
- package/dist/internals/index-HdMgLYtD.d.ts.map +0 -1
- package/dist/internals/validator-BBjOdLiT.js.map +0 -1
- package/dist/internals/validator-LNgZGT_l.mjs.map +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var utilsJs = require('@o2ter/utils-js');
|
|
4
4
|
var _private = require('./private-Ciddhure.js');
|
|
5
5
|
var _ = require('lodash');
|
|
6
|
-
var index = require('./index-
|
|
6
|
+
var index = require('./index-CLKTEIj0.js');
|
|
7
7
|
var axios = require('axios');
|
|
8
8
|
var _const$1 = require('./const-C3I6cfav.js');
|
|
9
9
|
var _const = require('@o2ter/server-js/dist/const');
|
|
@@ -200,6 +200,24 @@ class TQueryFilterBase {
|
|
|
200
200
|
notContainedIn(key, value) {
|
|
201
201
|
return this.filter({ [key]: { $nin: value } });
|
|
202
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Filters the query to include only documents where the specified key contains all of the specified values.
|
|
205
|
+
* @param key - The key to check for containing values.
|
|
206
|
+
* @param value - The array of values to check against.
|
|
207
|
+
* @returns The current instance for chaining.
|
|
208
|
+
*/
|
|
209
|
+
containedBy(key, value) {
|
|
210
|
+
return this.filter({ [key]: { $superset: value } });
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Filters the query to exclude documents where the specified key contains all of the specified values.
|
|
214
|
+
* @param key - The key to check for superset.
|
|
215
|
+
* @param value - The array of values to check against.
|
|
216
|
+
* @returns The current instance for chaining.
|
|
217
|
+
*/
|
|
218
|
+
notContainedBy(key, value) {
|
|
219
|
+
return this.filter({ [key]: { $not: { $superset: value } } });
|
|
220
|
+
}
|
|
203
221
|
/**
|
|
204
222
|
* Filters the query to include only documents where the specified key is a subset of the specified values.
|
|
205
223
|
* @param key - The key to check for subset.
|
|
@@ -602,7 +620,7 @@ class LiveQuerySubscription {
|
|
|
602
620
|
}
|
|
603
621
|
|
|
604
622
|
//
|
|
605
|
-
//
|
|
623
|
+
// user.ts
|
|
606
624
|
//
|
|
607
625
|
// The MIT License
|
|
608
626
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -625,45 +643,14 @@ class LiveQuerySubscription {
|
|
|
625
643
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
626
644
|
// THE SOFTWARE.
|
|
627
645
|
//
|
|
628
|
-
|
|
629
|
-
* Class representing a file.
|
|
630
|
-
*/
|
|
631
|
-
class TFile extends index.TObject {
|
|
646
|
+
class TUser extends index.TObject {
|
|
632
647
|
constructor(attributes) {
|
|
633
|
-
super('
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Gets the filename of the file.
|
|
637
|
-
* @returns The filename.
|
|
638
|
-
*/
|
|
639
|
-
get filename() {
|
|
640
|
-
return this.get('filename');
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Gets the size of the file.
|
|
644
|
-
* @returns The size of the file.
|
|
645
|
-
*/
|
|
646
|
-
get size() {
|
|
647
|
-
return this.get('size');
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Gets the type of the file.
|
|
651
|
-
* @returns The type of the file.
|
|
652
|
-
*/
|
|
653
|
-
get type() {
|
|
654
|
-
return this.get('type');
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* Gets the token of the file.
|
|
658
|
-
* @returns The token of the file.
|
|
659
|
-
*/
|
|
660
|
-
get token() {
|
|
661
|
-
return this.get('token');
|
|
648
|
+
super('User', attributes);
|
|
662
649
|
}
|
|
663
650
|
}
|
|
664
651
|
|
|
665
652
|
//
|
|
666
|
-
//
|
|
653
|
+
// role.ts
|
|
667
654
|
//
|
|
668
655
|
// The MIT License
|
|
669
656
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -687,59 +674,52 @@ class TFile extends index.TObject {
|
|
|
687
674
|
// THE SOFTWARE.
|
|
688
675
|
//
|
|
689
676
|
/**
|
|
690
|
-
* Class representing a
|
|
677
|
+
* Class representing a Role.
|
|
691
678
|
* @extends TObject
|
|
692
679
|
*/
|
|
693
|
-
class
|
|
680
|
+
class TRole extends index.TObject {
|
|
694
681
|
constructor(attributes) {
|
|
695
|
-
super('
|
|
682
|
+
super('Role', attributes);
|
|
696
683
|
}
|
|
697
684
|
/**
|
|
698
|
-
* Get the name of the
|
|
699
|
-
* @return {string} The name of the
|
|
685
|
+
* Get the name of the role.
|
|
686
|
+
* @return {string | undefined} The name of the role.
|
|
700
687
|
*/
|
|
701
688
|
get name() {
|
|
702
689
|
return this.get('name');
|
|
703
690
|
}
|
|
704
691
|
/**
|
|
705
|
-
* Get the
|
|
706
|
-
* @return {
|
|
707
|
-
*/
|
|
708
|
-
get data() {
|
|
709
|
-
return this.get('data');
|
|
710
|
-
}
|
|
711
|
-
/**
|
|
712
|
-
* Get the user associated with the job.
|
|
713
|
-
* @return {TUser | undefined} The user associated with the job.
|
|
692
|
+
* Get the users associated with the role.
|
|
693
|
+
* @return {TUser[]} The users associated with the role.
|
|
714
694
|
*/
|
|
715
|
-
get
|
|
716
|
-
return this.get('
|
|
695
|
+
get users() {
|
|
696
|
+
return this.get('users') ?? [];
|
|
717
697
|
}
|
|
718
698
|
/**
|
|
719
|
-
*
|
|
720
|
-
* @
|
|
699
|
+
* Set the users associated with the role.
|
|
700
|
+
* @param {TUser[]} value - The users to associate with the role.
|
|
721
701
|
*/
|
|
722
|
-
|
|
723
|
-
|
|
702
|
+
set users(value) {
|
|
703
|
+
this.set('users', value);
|
|
724
704
|
}
|
|
725
705
|
/**
|
|
726
|
-
* Get the
|
|
727
|
-
* @return {
|
|
706
|
+
* Get the roles associated with the role.
|
|
707
|
+
* @return {TRole[]} The roles associated with the role.
|
|
728
708
|
*/
|
|
729
|
-
get
|
|
730
|
-
return this.get('
|
|
709
|
+
get roles() {
|
|
710
|
+
return this.get('roles') ?? [];
|
|
731
711
|
}
|
|
732
712
|
/**
|
|
733
|
-
*
|
|
734
|
-
* @
|
|
713
|
+
* Set the roles associated with the role.
|
|
714
|
+
* @param {TRole[]} value - The roles to associate with the role.
|
|
735
715
|
*/
|
|
736
|
-
|
|
737
|
-
|
|
716
|
+
set roles(value) {
|
|
717
|
+
this.set('roles', value);
|
|
738
718
|
}
|
|
739
719
|
}
|
|
740
720
|
|
|
741
721
|
//
|
|
742
|
-
//
|
|
722
|
+
// file.ts
|
|
743
723
|
//
|
|
744
724
|
// The MIT License
|
|
745
725
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -763,52 +743,44 @@ class TJob extends index.TObject {
|
|
|
763
743
|
// THE SOFTWARE.
|
|
764
744
|
//
|
|
765
745
|
/**
|
|
766
|
-
* Class representing a
|
|
767
|
-
* @extends TObject
|
|
746
|
+
* Class representing a file.
|
|
768
747
|
*/
|
|
769
|
-
class
|
|
748
|
+
class TFile extends index.TObject {
|
|
770
749
|
constructor(attributes) {
|
|
771
|
-
super('
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* Get the name of the role.
|
|
775
|
-
* @return {string | undefined} The name of the role.
|
|
776
|
-
*/
|
|
777
|
-
get name() {
|
|
778
|
-
return this.get('name');
|
|
750
|
+
super('File', attributes);
|
|
779
751
|
}
|
|
780
752
|
/**
|
|
781
|
-
*
|
|
782
|
-
* @
|
|
753
|
+
* Gets the filename of the file.
|
|
754
|
+
* @returns The filename.
|
|
783
755
|
*/
|
|
784
|
-
get
|
|
785
|
-
return this.get('
|
|
756
|
+
get filename() {
|
|
757
|
+
return this.get('filename');
|
|
786
758
|
}
|
|
787
759
|
/**
|
|
788
|
-
*
|
|
789
|
-
* @
|
|
760
|
+
* Gets the size of the file.
|
|
761
|
+
* @returns The size of the file.
|
|
790
762
|
*/
|
|
791
|
-
|
|
792
|
-
this.
|
|
763
|
+
get size() {
|
|
764
|
+
return this.get('size');
|
|
793
765
|
}
|
|
794
766
|
/**
|
|
795
|
-
*
|
|
796
|
-
* @
|
|
767
|
+
* Gets the type of the file.
|
|
768
|
+
* @returns The type of the file.
|
|
797
769
|
*/
|
|
798
|
-
get
|
|
799
|
-
return this.get('
|
|
770
|
+
get type() {
|
|
771
|
+
return this.get('type');
|
|
800
772
|
}
|
|
801
773
|
/**
|
|
802
|
-
*
|
|
803
|
-
* @
|
|
774
|
+
* Gets the token of the file.
|
|
775
|
+
* @returns The token of the file.
|
|
804
776
|
*/
|
|
805
|
-
|
|
806
|
-
this.
|
|
777
|
+
get token() {
|
|
778
|
+
return this.get('token');
|
|
807
779
|
}
|
|
808
780
|
}
|
|
809
781
|
|
|
810
782
|
//
|
|
811
|
-
//
|
|
783
|
+
// job.ts
|
|
812
784
|
//
|
|
813
785
|
// The MIT License
|
|
814
786
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -831,9 +803,55 @@ class TRole extends index.TObject {
|
|
|
831
803
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
832
804
|
// THE SOFTWARE.
|
|
833
805
|
//
|
|
834
|
-
|
|
806
|
+
/**
|
|
807
|
+
* Class representing a Job.
|
|
808
|
+
* @extends TObject
|
|
809
|
+
*/
|
|
810
|
+
class TJob extends index.TObject {
|
|
835
811
|
constructor(attributes) {
|
|
836
|
-
super('
|
|
812
|
+
super('_Job', attributes);
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Get the name of the job.
|
|
816
|
+
* @return {string} The name of the job.
|
|
817
|
+
*/
|
|
818
|
+
get name() {
|
|
819
|
+
return this.get('name');
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Get the data of the job.
|
|
823
|
+
* @return {TValue | undefined} The data of the job.
|
|
824
|
+
*/
|
|
825
|
+
get data() {
|
|
826
|
+
return this.get('data');
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Get the user associated with the job.
|
|
830
|
+
* @return {TUser | undefined} The user associated with the job.
|
|
831
|
+
*/
|
|
832
|
+
get user() {
|
|
833
|
+
return this.get('user');
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Get the error of the job.
|
|
837
|
+
* @return {TValue | undefined} The error of the job.
|
|
838
|
+
*/
|
|
839
|
+
get error() {
|
|
840
|
+
return this.get('error');
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Get the start time of the job.
|
|
844
|
+
* @return {Date | undefined} The start time of the job.
|
|
845
|
+
*/
|
|
846
|
+
get startedAt() {
|
|
847
|
+
return this.get('startedAt');
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Get the completion time of the job.
|
|
851
|
+
* @return {Date | undefined} The completion time of the job.
|
|
852
|
+
*/
|
|
853
|
+
get completedAt() {
|
|
854
|
+
return this.get('completedAt');
|
|
837
855
|
}
|
|
838
856
|
}
|
|
839
857
|
|
|
@@ -869,7 +887,7 @@ const TObjectTypes = {
|
|
|
869
887
|
};
|
|
870
888
|
|
|
871
889
|
//
|
|
872
|
-
//
|
|
890
|
+
// index.ts
|
|
873
891
|
//
|
|
874
892
|
// The MIT License
|
|
875
893
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -893,6 +911,25 @@ const TObjectTypes = {
|
|
|
893
911
|
// THE SOFTWARE.
|
|
894
912
|
//
|
|
895
913
|
const isObjKey = (key, obj) => key in obj;
|
|
914
|
+
const classExtends = (x) => x;
|
|
915
|
+
const isQuery = (x) => {
|
|
916
|
+
return x instanceof TQuery;
|
|
917
|
+
};
|
|
918
|
+
const isObject = (x) => {
|
|
919
|
+
return x instanceof index.TObject;
|
|
920
|
+
};
|
|
921
|
+
const isUser = (x) => {
|
|
922
|
+
return x instanceof TUser;
|
|
923
|
+
};
|
|
924
|
+
const isRole = (x) => {
|
|
925
|
+
return x instanceof TRole;
|
|
926
|
+
};
|
|
927
|
+
const isFile = (x) => {
|
|
928
|
+
return x instanceof TFile;
|
|
929
|
+
};
|
|
930
|
+
const isJob = (x) => {
|
|
931
|
+
return x instanceof TJob;
|
|
932
|
+
};
|
|
896
933
|
|
|
897
934
|
//
|
|
898
935
|
// codec.ts
|
|
@@ -981,50 +1018,6 @@ const decodeEJSON = (x, stack, options) => {
|
|
|
981
1018
|
const serialize = (x, options) => JSON.stringify(encodeEJSON(x, [], options ?? {}), undefined, options?.space);
|
|
982
1019
|
const deserialize = (buffer, options) => decodeEJSON(JSON.parse(buffer), [], options ?? {});
|
|
983
1020
|
|
|
984
|
-
//
|
|
985
|
-
// index.ts
|
|
986
|
-
//
|
|
987
|
-
// The MIT License
|
|
988
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
989
|
-
//
|
|
990
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
991
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
992
|
-
// in the Software without restriction, including without limitation the rights
|
|
993
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
994
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
995
|
-
// furnished to do so, subject to the following conditions:
|
|
996
|
-
//
|
|
997
|
-
// The above copyright notice and this permission notice shall be included in
|
|
998
|
-
// all copies or substantial portions of the Software.
|
|
999
|
-
//
|
|
1000
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1001
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1002
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1003
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1004
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1005
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1006
|
-
// THE SOFTWARE.
|
|
1007
|
-
//
|
|
1008
|
-
const classExtends = (x) => x;
|
|
1009
|
-
const isQuery = (x) => {
|
|
1010
|
-
return x instanceof TQuery;
|
|
1011
|
-
};
|
|
1012
|
-
const isObject = (x) => {
|
|
1013
|
-
return x instanceof index.TObject;
|
|
1014
|
-
};
|
|
1015
|
-
const isUser = (x) => {
|
|
1016
|
-
return x instanceof TUser;
|
|
1017
|
-
};
|
|
1018
|
-
const isRole = (x) => {
|
|
1019
|
-
return x instanceof TRole;
|
|
1020
|
-
};
|
|
1021
|
-
const isFile = (x) => {
|
|
1022
|
-
return x instanceof TFile;
|
|
1023
|
-
};
|
|
1024
|
-
const isJob = (x) => {
|
|
1025
|
-
return x instanceof TJob;
|
|
1026
|
-
};
|
|
1027
|
-
|
|
1028
1021
|
//
|
|
1029
1022
|
// methods.ts
|
|
1030
1023
|
//
|
|
@@ -1084,10 +1077,10 @@ const applyObjectMethods = (object, proto) => {
|
|
|
1084
1077
|
url: {
|
|
1085
1078
|
get() {
|
|
1086
1079
|
const filename = this.filename;
|
|
1087
|
-
if (_.isNil(this.
|
|
1080
|
+
if (_.isNil(this.id) || _.isNil(filename))
|
|
1088
1081
|
return;
|
|
1089
1082
|
const endpoint = proto[_private.PVK].options.endpoint;
|
|
1090
|
-
const path = `files/${this.
|
|
1083
|
+
const path = `files/${this.id}/${encodeURIComponent(filename)}`;
|
|
1091
1084
|
return endpoint.endsWith('/') ? `${endpoint}${path}` : `${endpoint}/${path}`;
|
|
1092
1085
|
}
|
|
1093
1086
|
},
|
|
@@ -1115,7 +1108,7 @@ const applyObjectMethods = (object, proto) => {
|
|
|
1115
1108
|
},
|
|
1116
1109
|
fetchWithInclude: {
|
|
1117
1110
|
async value(keys, options) {
|
|
1118
|
-
const fetched = await query().equalTo('_id', this.
|
|
1111
|
+
const fetched = await query().equalTo('_id', this.id).includes(keys).first(options);
|
|
1119
1112
|
if (!fetched)
|
|
1120
1113
|
throw Error('Unable to fetch document');
|
|
1121
1114
|
this[_private.PVK].attributes = fetched.attributes;
|
|
@@ -1128,13 +1121,13 @@ const applyObjectMethods = (object, proto) => {
|
|
|
1128
1121
|
if (options?.cascadeSave !== false) {
|
|
1129
1122
|
for (const update of _.values(mutated)) {
|
|
1130
1123
|
const [, value] = index.decodeUpdateOp(update);
|
|
1131
|
-
if (value instanceof index.TObject && (_.isNil(value.
|
|
1124
|
+
if (value instanceof index.TObject && (_.isNil(value.id) || value.isDirty))
|
|
1132
1125
|
await value.save(options);
|
|
1133
1126
|
}
|
|
1134
1127
|
}
|
|
1135
|
-
if (this.
|
|
1128
|
+
if (this.id) {
|
|
1136
1129
|
const updated = await query()
|
|
1137
|
-
.equalTo('_id', this.
|
|
1130
|
+
.equalTo('_id', this.id)
|
|
1138
1131
|
.includes(...this.keys())
|
|
1139
1132
|
.updateOne(this[_private.PVK].mutated, options);
|
|
1140
1133
|
if (!updated)
|
|
@@ -1155,7 +1148,7 @@ const applyObjectMethods = (object, proto) => {
|
|
|
1155
1148
|
destroy: {
|
|
1156
1149
|
async value(options) {
|
|
1157
1150
|
const deleted = await query()
|
|
1158
|
-
.equalTo('_id', this.
|
|
1151
|
+
.equalTo('_id', this.id)
|
|
1159
1152
|
.includes(...this.keys())
|
|
1160
1153
|
.deleteOne(options);
|
|
1161
1154
|
if (!deleted)
|
|
@@ -1239,11 +1232,11 @@ class ProtoType {
|
|
|
1239
1232
|
/**
|
|
1240
1233
|
* Creates a new object.
|
|
1241
1234
|
* @param className - The name of the class to create.
|
|
1242
|
-
* @param
|
|
1235
|
+
* @param id - The ID of the object to create.
|
|
1243
1236
|
* @returns The created object.
|
|
1244
1237
|
*/
|
|
1245
|
-
Object(className,
|
|
1246
|
-
const attrs =
|
|
1238
|
+
Object(className, id) {
|
|
1239
|
+
const attrs = id ? { _id: id } : {};
|
|
1247
1240
|
const obj = isObjKey(className, TObjectTypes) ? new TObjectTypes[className](attrs) : new index.TObject(className, attrs);
|
|
1248
1241
|
return this.rebind(obj);
|
|
1249
1242
|
}
|
|
@@ -1564,7 +1557,7 @@ class Service {
|
|
|
1564
1557
|
const objects = deserialize(JSON.stringify(data));
|
|
1565
1558
|
for (const [id, { callback }] of _.entries(queries)) {
|
|
1566
1559
|
const keys = _.keys(_.pickBy(ids, v => _.includes(v, id)));
|
|
1567
|
-
callback(_.filter(objects, x => _.includes(keys, x.
|
|
1560
|
+
callback(_.filter(objects, x => _.includes(keys, x.id)));
|
|
1568
1561
|
}
|
|
1569
1562
|
});
|
|
1570
1563
|
socket.on('connect', register);
|
|
@@ -1726,7 +1719,7 @@ class ProtoClientInternal {
|
|
|
1726
1719
|
});
|
|
1727
1720
|
}
|
|
1728
1721
|
async setPassword(user, password, options) {
|
|
1729
|
-
if (!user.
|
|
1722
|
+
if (!user.id)
|
|
1730
1723
|
throw Error('Invalid user');
|
|
1731
1724
|
if (_.isEmpty(password))
|
|
1732
1725
|
throw Error('Invalid password');
|
|
@@ -1734,20 +1727,20 @@ class ProtoClientInternal {
|
|
|
1734
1727
|
await this.service.request({
|
|
1735
1728
|
method: 'post',
|
|
1736
1729
|
baseURL: this.options.endpoint,
|
|
1737
|
-
url: `user/${user.
|
|
1730
|
+
url: `user/${user.id}/password`,
|
|
1738
1731
|
data: serialize({ password }, serializeOpts),
|
|
1739
1732
|
responseType: 'text',
|
|
1740
1733
|
...opts,
|
|
1741
1734
|
});
|
|
1742
1735
|
}
|
|
1743
1736
|
async unsetPassword(user, options) {
|
|
1744
|
-
if (!user.
|
|
1737
|
+
if (!user.id)
|
|
1745
1738
|
throw Error('Invalid user');
|
|
1746
1739
|
const { serializeOpts, ...opts } = options ?? {};
|
|
1747
1740
|
await this.service.request({
|
|
1748
1741
|
method: 'post',
|
|
1749
1742
|
baseURL: this.options.endpoint,
|
|
1750
|
-
url: `user/${user.
|
|
1743
|
+
url: `user/${user.id}/password`,
|
|
1751
1744
|
responseType: 'text',
|
|
1752
1745
|
...opts,
|
|
1753
1746
|
});
|
|
@@ -1765,7 +1758,7 @@ class ProtoClientInternal {
|
|
|
1765
1758
|
}
|
|
1766
1759
|
async updateFile(proto, object, options) {
|
|
1767
1760
|
const updated = await proto.Query(object.className)
|
|
1768
|
-
.equalTo('_id', object.
|
|
1761
|
+
.equalTo('_id', object.id)
|
|
1769
1762
|
.includes(...object.keys())
|
|
1770
1763
|
.updateOne(object[_private.PVK].mutated, options);
|
|
1771
1764
|
if (updated) {
|
|
@@ -1816,11 +1809,11 @@ class ProtoClientInternal {
|
|
|
1816
1809
|
return object;
|
|
1817
1810
|
}
|
|
1818
1811
|
async saveFile(proto, object, options) {
|
|
1819
|
-
return object.
|
|
1812
|
+
return object.id ? this.updateFile(proto, object, options) : this.createFile(proto, object, options);
|
|
1820
1813
|
}
|
|
1821
1814
|
async deleteFile(proto, object, options) {
|
|
1822
1815
|
const deleted = await proto.Query(object.className)
|
|
1823
|
-
.equalTo('_id', object.
|
|
1816
|
+
.equalTo('_id', object.id)
|
|
1824
1817
|
.deleteOne(options);
|
|
1825
1818
|
if (deleted) {
|
|
1826
1819
|
object[_private.PVK].attributes = deleted.attributes;
|
|
@@ -1838,7 +1831,7 @@ class ProtoClientInternal {
|
|
|
1838
1831
|
const res = await this.service.request({
|
|
1839
1832
|
method: 'get',
|
|
1840
1833
|
baseURL: this.options.endpoint,
|
|
1841
|
-
url: `files/${object.
|
|
1834
|
+
url: `files/${object.id}/${encodeURIComponent(filename)}`,
|
|
1842
1835
|
responseType: 'stream',
|
|
1843
1836
|
headers: {
|
|
1844
1837
|
'Content-Type': 'multipart/form-data',
|
|
@@ -1902,14 +1895,14 @@ class ProtoClientInternal {
|
|
|
1902
1895
|
};
|
|
1903
1896
|
}
|
|
1904
1897
|
refs(proto, object, options) {
|
|
1905
|
-
if (!object.
|
|
1898
|
+
if (!object.id)
|
|
1906
1899
|
throw Error('Invalid object');
|
|
1907
1900
|
const request = async () => {
|
|
1908
1901
|
const { serializeOpts, ...opts } = options ?? {};
|
|
1909
1902
|
const res = await this.service.request({
|
|
1910
1903
|
method: 'get',
|
|
1911
1904
|
baseURL: this.options.endpoint,
|
|
1912
|
-
url: `classes/${encodeURIComponent(object.className)}/${object.
|
|
1905
|
+
url: `classes/${encodeURIComponent(object.className)}/${object.id}/refs`,
|
|
1913
1906
|
serializeOpts: {
|
|
1914
1907
|
objAttrs: index.TObject.defaultReadonlyKeys,
|
|
1915
1908
|
},
|
|
@@ -1957,13 +1950,13 @@ class ProtoClient extends ProtoType {
|
|
|
1957
1950
|
return new ProtoClientQuery(className, this, {});
|
|
1958
1951
|
}
|
|
1959
1952
|
Relation(object, key) {
|
|
1960
|
-
const
|
|
1961
|
-
if (!
|
|
1953
|
+
const id = object.id;
|
|
1954
|
+
if (!id)
|
|
1962
1955
|
throw Error('Invalid object');
|
|
1963
1956
|
return new ProtoClientRelationQuery(this, {
|
|
1964
1957
|
relatedBy: {
|
|
1965
1958
|
className: object.className,
|
|
1966
|
-
|
|
1959
|
+
id,
|
|
1967
1960
|
key,
|
|
1968
1961
|
},
|
|
1969
1962
|
});
|
|
@@ -2035,11 +2028,5 @@ exports.TUser = TUser;
|
|
|
2035
2028
|
exports._logLevels = _logLevels;
|
|
2036
2029
|
exports.classExtends = classExtends;
|
|
2037
2030
|
exports.deserialize = deserialize;
|
|
2038
|
-
exports.isFile = isFile;
|
|
2039
|
-
exports.isJob = isJob;
|
|
2040
|
-
exports.isObject = isObject;
|
|
2041
|
-
exports.isQuery = isQuery;
|
|
2042
|
-
exports.isRole = isRole;
|
|
2043
|
-
exports.isUser = isUser;
|
|
2044
2031
|
exports.serialize = serialize;
|
|
2045
|
-
//# sourceMappingURL=index-
|
|
2032
|
+
//# sourceMappingURL=index-xHeu-AjT.js.map
|