proto.io 0.0.188 → 0.0.190
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/database.d.ts +2 -2
- package/dist/adapters/file/filesystem.d.ts +2 -2
- package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
- package/dist/adapters/storage/progres.d.ts +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/client.mjs +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-C3PZ692k.mjs → index-BAbXyJEC.mjs} +226 -226
- package/dist/internals/{index-C3PZ692k.mjs.map → index-BAbXyJEC.mjs.map} +1 -1
- package/dist/internals/{index-fdvea17W.d.ts → index-BDHXW8gd.d.ts} +2 -1
- package/dist/internals/index-BDHXW8gd.d.ts.map +1 -0
- package/dist/internals/{index-wofihxjH.d.ts → index-BfsVioOA.d.ts} +2 -2
- package/dist/internals/index-BfsVioOA.d.ts.map +1 -0
- package/dist/internals/{index-BvaBC85z.js → index-M-VqTiz9.js} +226 -226
- package/dist/internals/{index-BvaBC85z.js.map → index-M-VqTiz9.js.map} +1 -1
- package/dist/internals/{index-DSxxREND.d.ts → index-z8mWupzT.d.ts} +2 -2
- package/dist/internals/index-z8mWupzT.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/internals/index-DSxxREND.d.ts.map +0 -1
- package/dist/internals/index-fdvea17W.d.ts.map +0 -1
- package/dist/internals/index-wofihxjH.d.ts.map +0 -1
|
@@ -1854,6 +1854,7 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
1854
1854
|
withTransaction<T>(callback: (connection: ProtoService<Ext>) => PromiseLike<T>, options?: TransactionOptions): PromiseLike<T>;
|
|
1855
1855
|
generateUploadToken(options?: {
|
|
1856
1856
|
maxUploadSize?: number;
|
|
1857
|
+
attributes?: Record<string, TValue>;
|
|
1857
1858
|
jwtSignOptions?: jwt.SignOptions;
|
|
1858
1859
|
}): string;
|
|
1859
1860
|
jwtSign(payload: any, options: jwt.SignOptions): string;
|
|
@@ -1869,4 +1870,4 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
1869
1870
|
}
|
|
1870
1871
|
|
|
1871
1872
|
export { type TQueryRandomOptions as A, type TPubSub as B, type TFileInfo as C, type DeserializeOptions as D, type ExtraOptions as E, type FindOptions as F, type InsertOptions as I, ProtoService as P, QuerySelector as Q, type RelationOptions as R, type SerializeOptions as S, TSchema as T, type _TValue as _, type ProtoServiceOptions as a, type ProtoServiceKeyOptions as b, type TFileStorage as c, type TSerializable as d, deserialize as e, type TExtensions as f, TQuery as g, TObject as h, TUser as i, TRole as j, TFile as k, TJob as l, ProtoType as m, type PathName as n, type TObjectType as o, type EventData as p, type DecodedQuery as q, type DecodedSortOption as r, serialize as s, type TValue as t, type FindOneOptions as u, type TUpdateOp as v, FieldSelectorExpression as w, QueryExpression as x, type TStorage as y, type TransactionOptions as z };
|
|
1872
|
-
//# sourceMappingURL=index-
|
|
1873
|
+
//# sourceMappingURL=index-BDHXW8gd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BDHXW8gd.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as TFileStorage, T as TSchema, P as ProtoService, C as TFileInfo } from './index-
|
|
1
|
+
import { c as TFileStorage, T as TSchema, P as ProtoService, C as TFileInfo } from './index-BDHXW8gd.js';
|
|
2
2
|
import { BinaryData } from '@o2ter/utils-js';
|
|
3
3
|
|
|
4
4
|
type FileStorageOptions = {
|
|
@@ -23,4 +23,4 @@ declare abstract class FileStorageBase implements TFileStorage {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export { FileStorageBase as F, type FileStorageOptions as a };
|
|
26
|
-
//# sourceMappingURL=index-
|
|
26
|
+
//# sourceMappingURL=index-BfsVioOA.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BfsVioOA.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -529,7 +529,7 @@ const AUTH_COOKIE_KEY = 'x-proto-auth';
|
|
|
529
529
|
const PROTO_NOTY_MSG = 'PROTO_NOTY_MSG';
|
|
530
530
|
|
|
531
531
|
//
|
|
532
|
-
//
|
|
532
|
+
// file.ts
|
|
533
533
|
//
|
|
534
534
|
// The MIT License
|
|
535
535
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -552,14 +552,45 @@ const PROTO_NOTY_MSG = 'PROTO_NOTY_MSG';
|
|
|
552
552
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
553
553
|
// THE SOFTWARE.
|
|
554
554
|
//
|
|
555
|
-
|
|
555
|
+
/**
|
|
556
|
+
* Class representing a file.
|
|
557
|
+
*/
|
|
558
|
+
class TFile extends index.TObject {
|
|
556
559
|
constructor(attributes) {
|
|
557
|
-
super('
|
|
560
|
+
super('File', attributes);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Gets the filename of the file.
|
|
564
|
+
* @returns The filename.
|
|
565
|
+
*/
|
|
566
|
+
get filename() {
|
|
567
|
+
return this.get('filename');
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Gets the size of the file.
|
|
571
|
+
* @returns The size of the file.
|
|
572
|
+
*/
|
|
573
|
+
get size() {
|
|
574
|
+
return this.get('size');
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Gets the type of the file.
|
|
578
|
+
* @returns The type of the file.
|
|
579
|
+
*/
|
|
580
|
+
get type() {
|
|
581
|
+
return this.get('type');
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Gets the token of the file.
|
|
585
|
+
* @returns The token of the file.
|
|
586
|
+
*/
|
|
587
|
+
get token() {
|
|
588
|
+
return this.get('token');
|
|
558
589
|
}
|
|
559
590
|
}
|
|
560
591
|
|
|
561
592
|
//
|
|
562
|
-
//
|
|
593
|
+
// job.ts
|
|
563
594
|
//
|
|
564
595
|
// The MIT License
|
|
565
596
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -583,52 +614,59 @@ class TUser extends index.TObject {
|
|
|
583
614
|
// THE SOFTWARE.
|
|
584
615
|
//
|
|
585
616
|
/**
|
|
586
|
-
* Class representing a
|
|
617
|
+
* Class representing a Job.
|
|
587
618
|
* @extends TObject
|
|
588
619
|
*/
|
|
589
|
-
class
|
|
620
|
+
class TJob extends index.TObject {
|
|
590
621
|
constructor(attributes) {
|
|
591
|
-
super('
|
|
622
|
+
super('_Job', attributes);
|
|
592
623
|
}
|
|
593
624
|
/**
|
|
594
|
-
* Get the name of the
|
|
595
|
-
* @return {string
|
|
625
|
+
* Get the name of the job.
|
|
626
|
+
* @return {string} The name of the job.
|
|
596
627
|
*/
|
|
597
628
|
get name() {
|
|
598
629
|
return this.get('name');
|
|
599
630
|
}
|
|
600
631
|
/**
|
|
601
|
-
* Get the
|
|
602
|
-
* @return {
|
|
632
|
+
* Get the data of the job.
|
|
633
|
+
* @return {TValue | undefined} The data of the job.
|
|
603
634
|
*/
|
|
604
|
-
get
|
|
605
|
-
return this.get('
|
|
635
|
+
get data() {
|
|
636
|
+
return this.get('data');
|
|
606
637
|
}
|
|
607
638
|
/**
|
|
608
|
-
*
|
|
609
|
-
* @
|
|
639
|
+
* Get the user associated with the job.
|
|
640
|
+
* @return {TUser | undefined} The user associated with the job.
|
|
610
641
|
*/
|
|
611
|
-
|
|
612
|
-
this.
|
|
642
|
+
get user() {
|
|
643
|
+
return this.get('user');
|
|
613
644
|
}
|
|
614
645
|
/**
|
|
615
|
-
* Get the
|
|
616
|
-
* @return {
|
|
646
|
+
* Get the error of the job.
|
|
647
|
+
* @return {TValue | undefined} The error of the job.
|
|
617
648
|
*/
|
|
618
|
-
get
|
|
619
|
-
return this.get('
|
|
649
|
+
get error() {
|
|
650
|
+
return this.get('error');
|
|
620
651
|
}
|
|
621
652
|
/**
|
|
622
|
-
*
|
|
623
|
-
* @
|
|
653
|
+
* Get the start time of the job.
|
|
654
|
+
* @return {Date | undefined} The start time of the job.
|
|
624
655
|
*/
|
|
625
|
-
|
|
626
|
-
this.
|
|
656
|
+
get startedAt() {
|
|
657
|
+
return this.get('startedAt');
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Get the completion time of the job.
|
|
661
|
+
* @return {Date | undefined} The completion time of the job.
|
|
662
|
+
*/
|
|
663
|
+
get completedAt() {
|
|
664
|
+
return this.get('completedAt');
|
|
627
665
|
}
|
|
628
666
|
}
|
|
629
667
|
|
|
630
668
|
//
|
|
631
|
-
//
|
|
669
|
+
// role.ts
|
|
632
670
|
//
|
|
633
671
|
// The MIT License
|
|
634
672
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -652,44 +690,52 @@ class TRole extends index.TObject {
|
|
|
652
690
|
// THE SOFTWARE.
|
|
653
691
|
//
|
|
654
692
|
/**
|
|
655
|
-
* Class representing a
|
|
693
|
+
* Class representing a Role.
|
|
694
|
+
* @extends TObject
|
|
656
695
|
*/
|
|
657
|
-
class
|
|
696
|
+
class TRole extends index.TObject {
|
|
658
697
|
constructor(attributes) {
|
|
659
|
-
super('
|
|
698
|
+
super('Role', attributes);
|
|
660
699
|
}
|
|
661
700
|
/**
|
|
662
|
-
*
|
|
663
|
-
* @
|
|
701
|
+
* Get the name of the role.
|
|
702
|
+
* @return {string | undefined} The name of the role.
|
|
664
703
|
*/
|
|
665
|
-
get
|
|
666
|
-
return this.get('
|
|
704
|
+
get name() {
|
|
705
|
+
return this.get('name');
|
|
667
706
|
}
|
|
668
707
|
/**
|
|
669
|
-
*
|
|
670
|
-
* @
|
|
708
|
+
* Get the users associated with the role.
|
|
709
|
+
* @return {TUser[]} The users associated with the role.
|
|
671
710
|
*/
|
|
672
|
-
get
|
|
673
|
-
return this.get('
|
|
711
|
+
get users() {
|
|
712
|
+
return this.get('users') ?? [];
|
|
674
713
|
}
|
|
675
714
|
/**
|
|
676
|
-
*
|
|
677
|
-
* @
|
|
715
|
+
* Set the users associated with the role.
|
|
716
|
+
* @param {TUser[]} value - The users to associate with the role.
|
|
678
717
|
*/
|
|
679
|
-
|
|
680
|
-
|
|
718
|
+
set users(value) {
|
|
719
|
+
this.set('users', value);
|
|
681
720
|
}
|
|
682
721
|
/**
|
|
683
|
-
*
|
|
684
|
-
* @
|
|
722
|
+
* Get the roles associated with the role.
|
|
723
|
+
* @return {TRole[]} The roles associated with the role.
|
|
685
724
|
*/
|
|
686
|
-
get
|
|
687
|
-
return this.get('
|
|
725
|
+
get roles() {
|
|
726
|
+
return this.get('roles') ?? [];
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Set the roles associated with the role.
|
|
730
|
+
* @param {TRole[]} value - The roles to associate with the role.
|
|
731
|
+
*/
|
|
732
|
+
set roles(value) {
|
|
733
|
+
this.set('roles', value);
|
|
688
734
|
}
|
|
689
735
|
}
|
|
690
736
|
|
|
691
737
|
//
|
|
692
|
-
//
|
|
738
|
+
// user.ts
|
|
693
739
|
//
|
|
694
740
|
// The MIT License
|
|
695
741
|
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
@@ -712,55 +758,9 @@ class TFile extends index.TObject {
|
|
|
712
758
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
713
759
|
// THE SOFTWARE.
|
|
714
760
|
//
|
|
715
|
-
|
|
716
|
-
* Class representing a Job.
|
|
717
|
-
* @extends TObject
|
|
718
|
-
*/
|
|
719
|
-
class TJob extends index.TObject {
|
|
761
|
+
class TUser extends index.TObject {
|
|
720
762
|
constructor(attributes) {
|
|
721
|
-
super('
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Get the name of the job.
|
|
725
|
-
* @return {string} The name of the job.
|
|
726
|
-
*/
|
|
727
|
-
get name() {
|
|
728
|
-
return this.get('name');
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* Get the data of the job.
|
|
732
|
-
* @return {TValue | undefined} The data of the job.
|
|
733
|
-
*/
|
|
734
|
-
get data() {
|
|
735
|
-
return this.get('data');
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Get the user associated with the job.
|
|
739
|
-
* @return {TUser | undefined} The user associated with the job.
|
|
740
|
-
*/
|
|
741
|
-
get user() {
|
|
742
|
-
return this.get('user');
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Get the error of the job.
|
|
746
|
-
* @return {TValue | undefined} The error of the job.
|
|
747
|
-
*/
|
|
748
|
-
get error() {
|
|
749
|
-
return this.get('error');
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Get the start time of the job.
|
|
753
|
-
* @return {Date | undefined} The start time of the job.
|
|
754
|
-
*/
|
|
755
|
-
get startedAt() {
|
|
756
|
-
return this.get('startedAt');
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* Get the completion time of the job.
|
|
760
|
-
* @return {Date | undefined} The completion time of the job.
|
|
761
|
-
*/
|
|
762
|
-
get completedAt() {
|
|
763
|
-
return this.get('completedAt');
|
|
763
|
+
super('User', attributes);
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
766
|
|
|
@@ -821,6 +821,137 @@ const TObjectTypes = {
|
|
|
821
821
|
//
|
|
822
822
|
const isObjKey = (key, obj) => key in obj;
|
|
823
823
|
|
|
824
|
+
//
|
|
825
|
+
// codec.ts
|
|
826
|
+
//
|
|
827
|
+
// The MIT License
|
|
828
|
+
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
829
|
+
//
|
|
830
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
831
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
832
|
+
// in the Software without restriction, including without limitation the rights
|
|
833
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
834
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
835
|
+
// furnished to do so, subject to the following conditions:
|
|
836
|
+
//
|
|
837
|
+
// The above copyright notice and this permission notice shall be included in
|
|
838
|
+
// all copies or substantial portions of the Software.
|
|
839
|
+
//
|
|
840
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
841
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
842
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
843
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
844
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
845
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
846
|
+
// THE SOFTWARE.
|
|
847
|
+
//
|
|
848
|
+
const encodeEJSON = (x, stack, options) => {
|
|
849
|
+
if (_.isNil(x) || _.isNumber(x) || _.isBoolean(x) || _.isString(x))
|
|
850
|
+
return x ?? null;
|
|
851
|
+
if (_.isDate(x))
|
|
852
|
+
return { $date: x.valueOf() };
|
|
853
|
+
if (_.isRegExp(x))
|
|
854
|
+
return { $regex: x.source, $options: x.flags };
|
|
855
|
+
if (x instanceof BigInt)
|
|
856
|
+
return { $integer: x.toString() };
|
|
857
|
+
if (x instanceof Decimal.Decimal)
|
|
858
|
+
return { $decimal: x.toString() };
|
|
859
|
+
const found = _.indexOf(stack, x);
|
|
860
|
+
if (found !== -1)
|
|
861
|
+
return { $ref: found };
|
|
862
|
+
if (_.isArray(x))
|
|
863
|
+
return x.map(v => encodeEJSON(v, [...stack, x], options));
|
|
864
|
+
if (x instanceof index.TObject) {
|
|
865
|
+
const attributes = options.objAttrs ? _.pick(x.attributes, ...options.objAttrs) : x.attributes;
|
|
866
|
+
return {
|
|
867
|
+
$object: {
|
|
868
|
+
className: x.className,
|
|
869
|
+
attributes: _.mapValues(attributes, v => encodeEJSON(v, [...stack, x], options)),
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
const props = _.uniq(_.flatMap([x, ...utilsJs.prototypes(x)], x => Object.getOwnPropertyNames(x)));
|
|
874
|
+
return _.transform(_.pick(x, props), (r, v, k) => {
|
|
875
|
+
if (_.isFunction(v))
|
|
876
|
+
return;
|
|
877
|
+
r[k.startsWith('$') ? `$${k}` : k] = encodeEJSON(v, [...stack, x], options);
|
|
878
|
+
}, {});
|
|
879
|
+
};
|
|
880
|
+
const decodeEJSON = (x, stack, options) => {
|
|
881
|
+
if (_.isNil(x) || _.isNumber(x) || _.isBoolean(x) || _.isString(x))
|
|
882
|
+
return x ?? null;
|
|
883
|
+
if (_.isArray(x)) {
|
|
884
|
+
return _.transform(x, (r, v) => {
|
|
885
|
+
r.push(decodeEJSON(v, [...stack, r], options));
|
|
886
|
+
}, []);
|
|
887
|
+
}
|
|
888
|
+
if (!_.isNil(x.$date))
|
|
889
|
+
return new Date(x.$date);
|
|
890
|
+
if (!_.isNil(x.$regex))
|
|
891
|
+
return new RegExp(x.$regex, x.$options || '');
|
|
892
|
+
if (!_.isNil(x.$integer))
|
|
893
|
+
return BigInt(x.$integer);
|
|
894
|
+
if (!_.isNil(x.$decimal))
|
|
895
|
+
return new Decimal.Decimal(x.$decimal);
|
|
896
|
+
if (!_.isNil(x.$ref))
|
|
897
|
+
return stack[x.$ref];
|
|
898
|
+
if (!_.isNil(x.$object)) {
|
|
899
|
+
const { className, attributes } = x.$object;
|
|
900
|
+
const _attributes = (self) => _.mapValues(options.objAttrs ? _.pick(attributes, ...options.objAttrs) : attributes, v => decodeEJSON(v, [...stack, self], options));
|
|
901
|
+
return isObjKey(className, TObjectTypes) ? new TObjectTypes[className](_attributes) : new index.TObject(className, _attributes);
|
|
902
|
+
}
|
|
903
|
+
return _.transform(x, (r, v, k) => {
|
|
904
|
+
if (_.isString(k))
|
|
905
|
+
r[k.startsWith('$') ? k.substring(1) : k] = decodeEJSON(v, [...stack, r], options);
|
|
906
|
+
}, {});
|
|
907
|
+
};
|
|
908
|
+
const serialize = (x, options) => JSON.stringify(encodeEJSON(x, [], options ?? {}), undefined, options?.space);
|
|
909
|
+
const deserialize = (buffer, options) => decodeEJSON(JSON.parse(buffer), [], options ?? {});
|
|
910
|
+
|
|
911
|
+
//
|
|
912
|
+
// index.ts
|
|
913
|
+
//
|
|
914
|
+
// The MIT License
|
|
915
|
+
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
916
|
+
//
|
|
917
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
918
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
919
|
+
// in the Software without restriction, including without limitation the rights
|
|
920
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
921
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
922
|
+
// furnished to do so, subject to the following conditions:
|
|
923
|
+
//
|
|
924
|
+
// The above copyright notice and this permission notice shall be included in
|
|
925
|
+
// all copies or substantial portions of the Software.
|
|
926
|
+
//
|
|
927
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
928
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
929
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
930
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
931
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
932
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
933
|
+
// THE SOFTWARE.
|
|
934
|
+
//
|
|
935
|
+
const classExtends = (x) => x;
|
|
936
|
+
const isQuery = (x) => {
|
|
937
|
+
return x instanceof TQuery;
|
|
938
|
+
};
|
|
939
|
+
const isObject = (x) => {
|
|
940
|
+
return x instanceof index.TObject;
|
|
941
|
+
};
|
|
942
|
+
const isUser = (x) => {
|
|
943
|
+
return x instanceof TUser;
|
|
944
|
+
};
|
|
945
|
+
const isRole = (x) => {
|
|
946
|
+
return x instanceof TRole;
|
|
947
|
+
};
|
|
948
|
+
const isFile = (x) => {
|
|
949
|
+
return x instanceof TFile;
|
|
950
|
+
};
|
|
951
|
+
const isJob = (x) => {
|
|
952
|
+
return x instanceof TJob;
|
|
953
|
+
};
|
|
954
|
+
|
|
824
955
|
//
|
|
825
956
|
// methods.ts
|
|
826
957
|
//
|
|
@@ -968,137 +1099,6 @@ const applyObjectMethods = (object, proto) => {
|
|
|
968
1099
|
return Object.defineProperties(object, _props);
|
|
969
1100
|
};
|
|
970
1101
|
|
|
971
|
-
//
|
|
972
|
-
// codec.ts
|
|
973
|
-
//
|
|
974
|
-
// The MIT License
|
|
975
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
976
|
-
//
|
|
977
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
978
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
979
|
-
// in the Software without restriction, including without limitation the rights
|
|
980
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
981
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
982
|
-
// furnished to do so, subject to the following conditions:
|
|
983
|
-
//
|
|
984
|
-
// The above copyright notice and this permission notice shall be included in
|
|
985
|
-
// all copies or substantial portions of the Software.
|
|
986
|
-
//
|
|
987
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
988
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
989
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
990
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
991
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
992
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
993
|
-
// THE SOFTWARE.
|
|
994
|
-
//
|
|
995
|
-
const encodeEJSON = (x, stack, options) => {
|
|
996
|
-
if (_.isNil(x) || _.isNumber(x) || _.isBoolean(x) || _.isString(x))
|
|
997
|
-
return x ?? null;
|
|
998
|
-
if (_.isDate(x))
|
|
999
|
-
return { $date: x.valueOf() };
|
|
1000
|
-
if (_.isRegExp(x))
|
|
1001
|
-
return { $regex: x.source, $options: x.flags };
|
|
1002
|
-
if (x instanceof BigInt)
|
|
1003
|
-
return { $integer: x.toString() };
|
|
1004
|
-
if (x instanceof Decimal.Decimal)
|
|
1005
|
-
return { $decimal: x.toString() };
|
|
1006
|
-
const found = _.indexOf(stack, x);
|
|
1007
|
-
if (found !== -1)
|
|
1008
|
-
return { $ref: found };
|
|
1009
|
-
if (_.isArray(x))
|
|
1010
|
-
return x.map(v => encodeEJSON(v, [...stack, x], options));
|
|
1011
|
-
if (x instanceof index.TObject) {
|
|
1012
|
-
const attributes = options.objAttrs ? _.pick(x.attributes, ...options.objAttrs) : x.attributes;
|
|
1013
|
-
return {
|
|
1014
|
-
$object: {
|
|
1015
|
-
className: x.className,
|
|
1016
|
-
attributes: _.mapValues(attributes, v => encodeEJSON(v, [...stack, x], options)),
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
const props = _.uniq(_.flatMap([x, ...utilsJs.prototypes(x)], x => Object.getOwnPropertyNames(x)));
|
|
1021
|
-
return _.transform(_.pick(x, props), (r, v, k) => {
|
|
1022
|
-
if (_.isFunction(v))
|
|
1023
|
-
return;
|
|
1024
|
-
r[k.startsWith('$') ? `$${k}` : k] = encodeEJSON(v, [...stack, x], options);
|
|
1025
|
-
}, {});
|
|
1026
|
-
};
|
|
1027
|
-
const decodeEJSON = (x, stack, options) => {
|
|
1028
|
-
if (_.isNil(x) || _.isNumber(x) || _.isBoolean(x) || _.isString(x))
|
|
1029
|
-
return x ?? null;
|
|
1030
|
-
if (_.isArray(x)) {
|
|
1031
|
-
return _.transform(x, (r, v) => {
|
|
1032
|
-
r.push(decodeEJSON(v, [...stack, r], options));
|
|
1033
|
-
}, []);
|
|
1034
|
-
}
|
|
1035
|
-
if (!_.isNil(x.$date))
|
|
1036
|
-
return new Date(x.$date);
|
|
1037
|
-
if (!_.isNil(x.$regex))
|
|
1038
|
-
return new RegExp(x.$regex, x.$options || '');
|
|
1039
|
-
if (!_.isNil(x.$integer))
|
|
1040
|
-
return BigInt(x.$integer);
|
|
1041
|
-
if (!_.isNil(x.$decimal))
|
|
1042
|
-
return new Decimal.Decimal(x.$decimal);
|
|
1043
|
-
if (!_.isNil(x.$ref))
|
|
1044
|
-
return stack[x.$ref];
|
|
1045
|
-
if (!_.isNil(x.$object)) {
|
|
1046
|
-
const { className, attributes } = x.$object;
|
|
1047
|
-
const _attributes = (self) => _.mapValues(options.objAttrs ? _.pick(attributes, ...options.objAttrs) : attributes, v => decodeEJSON(v, [...stack, self], options));
|
|
1048
|
-
return isObjKey(className, TObjectTypes) ? new TObjectTypes[className](_attributes) : new index.TObject(className, _attributes);
|
|
1049
|
-
}
|
|
1050
|
-
return _.transform(x, (r, v, k) => {
|
|
1051
|
-
if (_.isString(k))
|
|
1052
|
-
r[k.startsWith('$') ? k.substring(1) : k] = decodeEJSON(v, [...stack, r], options);
|
|
1053
|
-
}, {});
|
|
1054
|
-
};
|
|
1055
|
-
const serialize = (x, options) => JSON.stringify(encodeEJSON(x, [], options ?? {}), undefined, options?.space);
|
|
1056
|
-
const deserialize = (buffer, options) => decodeEJSON(JSON.parse(buffer), [], options ?? {});
|
|
1057
|
-
|
|
1058
|
-
//
|
|
1059
|
-
// index.ts
|
|
1060
|
-
//
|
|
1061
|
-
// The MIT License
|
|
1062
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
1063
|
-
//
|
|
1064
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1065
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
1066
|
-
// in the Software without restriction, including without limitation the rights
|
|
1067
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1068
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
1069
|
-
// furnished to do so, subject to the following conditions:
|
|
1070
|
-
//
|
|
1071
|
-
// The above copyright notice and this permission notice shall be included in
|
|
1072
|
-
// all copies or substantial portions of the Software.
|
|
1073
|
-
//
|
|
1074
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1075
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1076
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1077
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1078
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1079
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1080
|
-
// THE SOFTWARE.
|
|
1081
|
-
//
|
|
1082
|
-
const classExtends = (x) => x;
|
|
1083
|
-
const isQuery = (x) => {
|
|
1084
|
-
return x instanceof TQuery;
|
|
1085
|
-
};
|
|
1086
|
-
const isObject = (x) => {
|
|
1087
|
-
return x instanceof index.TObject;
|
|
1088
|
-
};
|
|
1089
|
-
const isUser = (x) => {
|
|
1090
|
-
return x instanceof TUser;
|
|
1091
|
-
};
|
|
1092
|
-
const isRole = (x) => {
|
|
1093
|
-
return x instanceof TRole;
|
|
1094
|
-
};
|
|
1095
|
-
const isFile = (x) => {
|
|
1096
|
-
return x instanceof TFile;
|
|
1097
|
-
};
|
|
1098
|
-
const isJob = (x) => {
|
|
1099
|
-
return x instanceof TJob;
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
1102
|
//
|
|
1103
1103
|
// proto.ts
|
|
1104
1104
|
//
|
|
@@ -1903,4 +1903,4 @@ exports.isQuery = isQuery;
|
|
|
1903
1903
|
exports.isRole = isRole;
|
|
1904
1904
|
exports.isUser = isUser;
|
|
1905
1905
|
exports.serialize = serialize;
|
|
1906
|
-
//# sourceMappingURL=index-
|
|
1906
|
+
//# sourceMappingURL=index-M-VqTiz9.js.map
|