proto.io 0.0.221 → 0.0.223

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.
Files changed (34) hide show
  1. package/dist/adapters/file/aliyun-oss.d.ts +3 -3
  2. package/dist/adapters/file/database.d.ts +2 -2
  3. package/dist/adapters/file/filesystem.d.ts +3 -3
  4. package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
  5. package/dist/adapters/storage/progres.d.ts +1 -1
  6. package/dist/client.d.ts +3 -3
  7. package/dist/client.js +1 -1
  8. package/dist/client.mjs +2 -2
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +126 -87
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +127 -88
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/internals/{base-C1uAg1dD.d.ts → base-D7eiLTdl.d.ts} +2 -2
  15. package/dist/internals/base-D7eiLTdl.d.ts.map +1 -0
  16. package/dist/internals/{chunk-CpgqvFNO.d.ts → chunk-B95QS-B7.d.ts} +3 -3
  17. package/dist/internals/chunk-B95QS-B7.d.ts.map +1 -0
  18. package/dist/internals/{index-82GLvDiN.d.ts → index-B9kyejqo.d.ts} +38 -27
  19. package/dist/internals/index-B9kyejqo.d.ts.map +1 -0
  20. package/dist/internals/{index-CsclRNTO.mjs → index-BozJOOCD.mjs} +49 -1
  21. package/dist/internals/index-BozJOOCD.mjs.map +1 -0
  22. package/dist/internals/{index-dk8iIkyr.js → index-C01HL8O6.js} +49 -1
  23. package/dist/internals/index-C01HL8O6.js.map +1 -0
  24. package/dist/internals/index-CLKTEIj0.js.map +1 -1
  25. package/dist/internals/{index-Cc-yXi8f.d.ts → index-DRgs8WkW.d.ts} +2 -2
  26. package/dist/internals/index-DRgs8WkW.d.ts.map +1 -0
  27. package/dist/internals/index-gWcE22mf.mjs.map +1 -1
  28. package/package.json +25 -3
  29. package/dist/internals/base-C1uAg1dD.d.ts.map +0 -1
  30. package/dist/internals/chunk-CpgqvFNO.d.ts.map +0 -1
  31. package/dist/internals/index-82GLvDiN.d.ts.map +0 -1
  32. package/dist/internals/index-Cc-yXi8f.d.ts.map +0 -1
  33. package/dist/internals/index-CsclRNTO.mjs.map +0 -1
  34. package/dist/internals/index-dk8iIkyr.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { d as TFileStorage, T as TSchema, P as ProtoService, G as TFileInfo } from './index-82GLvDiN.js';
1
+ import { d as TFileStorage, T as TSchema, P as ProtoService, G as TFileInfo } from './index-B9kyejqo.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=base-C1uAg1dD.d.ts.map
26
+ //# sourceMappingURL=base-D7eiLTdl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-D7eiLTdl.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,5 +1,5 @@
1
- import { F as FileStorageBase } from './base-C1uAg1dD.js';
2
- import { P as ProtoService } from './index-82GLvDiN.js';
1
+ import { F as FileStorageBase } from './base-D7eiLTdl.js';
2
+ import { P as ProtoService } from './index-B9kyejqo.js';
3
3
 
4
4
  declare abstract class FileChunkStorageBase<File> extends FileStorageBase {
5
5
  abstract listChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{
@@ -14,4 +14,4 @@ declare abstract class FileChunkStorageBase<File> extends FileStorageBase {
14
14
  }
15
15
 
16
16
  export { FileChunkStorageBase as F };
17
- //# sourceMappingURL=chunk-CpgqvFNO.d.ts.map
17
+ //# sourceMappingURL=chunk-B95QS-B7.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-B95QS-B7.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -164,11 +164,27 @@ declare class TJob extends TObject {
164
164
  get completedAt(): Date | undefined;
165
165
  }
166
166
 
167
+ declare class TSession extends TObject {
168
+ constructor(attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>));
169
+ /**
170
+ * Get the session ID.
171
+ * @return {string} The session ID.
172
+ */
173
+ get sessionId(): string;
174
+ /**
175
+ * Get the user associated with the session.
176
+ * @return {TObject | undefined} The user associated with the session.
177
+ */
178
+ get user(): TObject | undefined;
179
+ get loginedAt(): Date | undefined;
180
+ }
181
+
167
182
  declare const TObjectTypes: {
168
183
  User: typeof TUser;
169
184
  Role: typeof TRole;
170
185
  File: typeof TFile;
171
186
  _Job: typeof TJob;
187
+ _Session: typeof TSession;
172
188
  };
173
189
  type _TObjectType<K> = K extends keyof typeof TObjectTypes ? InstanceType<(typeof TObjectTypes)[K]> : TObject;
174
190
  type PickBy<T, C> = {
@@ -844,11 +860,16 @@ type ProtoJobFunctionOptions<E> = {
844
860
  validator?: Validator;
845
861
  };
846
862
 
847
- type Session = jwt.JwtPayload & {
848
- sessionId: string;
849
- createdAt: Date;
850
- loginedAt: Date;
851
- };
863
+ type _Session = Awaited<ReturnType<typeof session>>;
864
+ declare const session: <E>(proto: ProtoService<E>, request: Request) => Promise<{
865
+ user?: TObject | undefined;
866
+ _roles?: TRole[] | undefined;
867
+ sessionId?: string | undefined;
868
+ createdAt?: Date | undefined;
869
+ updatedAt?: Date | undefined;
870
+ loginedAt?: Date | undefined;
871
+ cookieOptions?: any;
872
+ }>;
852
873
 
853
874
  declare const _logLevels: readonly ["error", "warn", "info", "debug", "trace"];
854
875
  type _Logger = {
@@ -1029,9 +1050,9 @@ interface ProtoType<Ext> {
1029
1050
  * @returns A promise resolving to the instance with the session and attributes.
1030
1051
  */
1031
1052
  connectWithSessionToken<T extends object>(token: string, attrs?: T | ((x: this & {
1032
- session?: Session;
1053
+ session?: _Session;
1033
1054
  }) => T)): Promise<this & {
1034
- session?: Session;
1055
+ session?: _Session;
1035
1056
  } & T>;
1036
1057
  /**
1037
1058
  * Sets the session token.
@@ -1186,7 +1207,7 @@ interface TObject {
1186
1207
  * Clones the object.
1187
1208
  * @returns A clone of the object.
1188
1209
  */
1189
- clone(): TObject;
1210
+ clone(): this;
1190
1211
  /**
1191
1212
  * Gets a relation query for the specified key.
1192
1213
  * @param key - The key of the relation.
@@ -1810,10 +1831,6 @@ type ProtoServiceOptions<Ext> = {
1810
1831
  * The schema definitions for the service.
1811
1832
  */
1812
1833
  schema: Record<string, TSchema>;
1813
- /**
1814
- * User resolver configuration.
1815
- */
1816
- userResolver?: (proto: ProtoService<Ext>, user?: TUser) => Awaitable<TUser | undefined>;
1817
1834
  /**
1818
1835
  * Role resolver configuration.
1819
1836
  */
@@ -1911,7 +1928,7 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
1911
1928
  private _storage?;
1912
1929
  private _schedule;
1913
1930
  req?: Request;
1914
- session?: Session;
1931
+ session?: _Session;
1915
1932
  constructor(options: ProtoServiceOptions<Ext> & ProtoServiceKeyOptions);
1916
1933
  shutdown(): Promise<void>;
1917
1934
  get logger(): Logger;
@@ -1919,20 +1936,14 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
1919
1936
  Query<T extends string>(className: T): TQuery<T, Ext, boolean>;
1920
1937
  Relation<T extends string>(object: TObject, key: PathName<T>): TQuery<string, Ext, boolean>;
1921
1938
  InsecureQuery<T extends string>(className: T): TQuery<T, Ext, true>;
1922
- get sessionId(): string | undefined;
1923
- sessionInfo(): Promise<Session | {
1924
- loginedAt: Date | undefined;
1939
+ sessionInfo(): Promise<{
1925
1940
  user?: TObject | undefined;
1926
- _roles?: TObject[] | undefined;
1927
- iss?: string | undefined;
1928
- sub?: string | undefined;
1929
- aud?: string | string[] | undefined;
1930
- exp?: number | undefined;
1931
- nbf?: number | undefined;
1932
- iat?: number | undefined;
1933
- jti?: string | undefined;
1941
+ _roles?: TRole[] | undefined;
1934
1942
  sessionId?: string | undefined;
1935
1943
  createdAt?: Date | undefined;
1944
+ updatedAt?: Date | undefined;
1945
+ loginedAt?: Date | undefined;
1946
+ cookieOptions?: any;
1936
1947
  } | undefined>;
1937
1948
  currentUser(): Promise<TUser | undefined>;
1938
1949
  _currentRoles(): Promise<TRole[]>;
@@ -1945,9 +1956,9 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
1945
1956
  req: R;
1946
1957
  } & T;
1947
1958
  connectWithSessionToken<T extends object>(token: string, attrs?: T | ((x: this & {
1948
- session?: Session;
1959
+ session?: _Session;
1949
1960
  }) => T)): Promise<this & {
1950
- session?: Session;
1961
+ session?: _Session;
1951
1962
  } & T>;
1952
1963
  userRoles(user: TUser): Promise<TRole[]>;
1953
1964
  becomeUser(req: Request, user: TUser, options?: {
@@ -2001,4 +2012,4 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
2001
2012
  }
2002
2013
 
2003
2014
  export { type TransactionOptions as A, type QueryRandomOptions as B, type TPubSub as C, type DeserializeOptions as D, type ExtraOptions as E, FieldSelectorExpression as F, type TFileInfo as G, type InsertOptions as I, ProtoService as P, QueryExpression as Q, type RelationOptions as R, type SerializeOptions as S, TSchema as T, type TValueWithoutObject as a, type ProtoServiceOptions as b, type ProtoServiceKeyOptions as c, type TFileStorage as d, type TNumber as e, type TSerializable as f, deserialize as g, type TExtensions as h, ProtoType as i, TQuery as j, TObject as k, type PathName as l, type TObjectType as m, TUser as n, type EventData as o, type TQuerySelector as p, type TValueWithUndefined as q, type TValue as r, serialize as s, type TUpdateOp as t, QueryAccumulator as u, QuerySelector as v, type DecodedSortOption as w, type DecodedQuery as x, type FindOptions as y, type TStorage as z };
2004
- //# sourceMappingURL=index-82GLvDiN.d.ts.map
2015
+ //# sourceMappingURL=index-B9kyejqo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B9kyejqo.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -853,6 +853,53 @@ class TJob extends TObject {
853
853
  }
854
854
  }
855
855
 
856
+ //
857
+ // session.ts
858
+ //
859
+ // The MIT License
860
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
861
+ //
862
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
863
+ // of this software and associated documentation files (the "Software"), to deal
864
+ // in the Software without restriction, including without limitation the rights
865
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
866
+ // copies of the Software, and to permit persons to whom the Software is
867
+ // furnished to do so, subject to the following conditions:
868
+ //
869
+ // The above copyright notice and this permission notice shall be included in
870
+ // all copies or substantial portions of the Software.
871
+ //
872
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
873
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
874
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
875
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
876
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
877
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
878
+ // THE SOFTWARE.
879
+ //
880
+ class TSession extends TObject {
881
+ constructor(attributes) {
882
+ super('_Session', attributes);
883
+ }
884
+ /**
885
+ * Get the session ID.
886
+ * @return {string} The session ID.
887
+ */
888
+ get sessionId() {
889
+ return this.get('token');
890
+ }
891
+ /**
892
+ * Get the user associated with the session.
893
+ * @return {TObject | undefined} The user associated with the session.
894
+ */
895
+ get user() {
896
+ return this.get('user');
897
+ }
898
+ get loginedAt() {
899
+ return this.get('loginedAt');
900
+ }
901
+ }
902
+
856
903
  //
857
904
  // types.ts
858
905
  //
@@ -882,6 +929,7 @@ const TObjectTypes = {
882
929
  'Role': TRole,
883
930
  'File': TFile,
884
931
  '_Job': TJob,
932
+ '_Session': TSession,
885
933
  };
886
934
 
887
935
  //
@@ -2024,4 +2072,4 @@ class ProtoClient extends ProtoType {
2024
2072
  }
2025
2073
 
2026
2074
  export { LiveQuerySubscription as L, ProtoType as P, TQuery as T, _logLevels as _, TUser as a, ProtoClient as b, classExtends as c, deserialize as d, serialize as s };
2027
- //# sourceMappingURL=index-CsclRNTO.mjs.map
2075
+ //# sourceMappingURL=index-BozJOOCD.mjs.map