proto.io 0.0.222 → 0.0.224
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 +1 -1
- package/dist/adapters/file/database.mjs +1 -1
- 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 +1 -1
- package/dist/adapters/storage/progres.js +3 -3
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +3 -3
- package/dist/adapters/storage/progres.mjs.map +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 +171 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +172 -131
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-C1uAg1dD.d.ts → base-NZIvB1zK.d.ts} +2 -2
- package/dist/internals/base-NZIvB1zK.d.ts.map +1 -0
- package/dist/internals/{chunk-CpgqvFNO.d.ts → chunk-B9i8NMB_.d.ts} +3 -3
- package/dist/internals/chunk-B9i8NMB_.d.ts.map +1 -0
- package/dist/internals/{index-82GLvDiN.d.ts → index-BOboD1oK.d.ts} +121 -61
- package/dist/internals/index-BOboD1oK.d.ts.map +1 -0
- package/dist/internals/{index-CsclRNTO.mjs → index-BZ79Ljis.mjs} +60 -1
- package/dist/internals/index-BZ79Ljis.mjs.map +1 -0
- package/dist/internals/{index-Cc-yXi8f.d.ts → index-BcNiVp-e.d.ts} +3 -2
- package/dist/internals/index-BcNiVp-e.d.ts.map +1 -0
- package/dist/internals/index-CLKTEIj0.js.map +1 -1
- package/dist/internals/index-gWcE22mf.mjs.map +1 -1
- package/dist/internals/{index-dk8iIkyr.js → index-vOFh8pVc.js} +60 -1
- package/dist/internals/index-vOFh8pVc.js.map +1 -0
- package/dist/internals/{validator-DX2nXeQo.mjs → validator-0I1kvhsL.mjs} +42 -10
- package/dist/internals/validator-0I1kvhsL.mjs.map +1 -0
- package/dist/internals/{validator-B5yHpyvb.js → validator-Bc1jRJfA.js} +42 -10
- package/dist/internals/validator-Bc1jRJfA.js.map +1 -0
- package/package.json +1 -1
- package/dist/internals/base-C1uAg1dD.d.ts.map +0 -1
- package/dist/internals/chunk-CpgqvFNO.d.ts.map +0 -1
- package/dist/internals/index-82GLvDiN.d.ts.map +0 -1
- package/dist/internals/index-Cc-yXi8f.d.ts.map +0 -1
- package/dist/internals/index-CsclRNTO.mjs.map +0 -1
- package/dist/internals/index-dk8iIkyr.js.map +0 -1
- package/dist/internals/validator-B5yHpyvb.js.map +0 -1
- package/dist/internals/validator-DX2nXeQo.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as TFileStorage, T as TSchema, P as ProtoService, G as TFileInfo } from './index-
|
|
1
|
+
import { d as TFileStorage, T as TSchema, P as ProtoService, G as TFileInfo } from './index-BOboD1oK.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-
|
|
26
|
+
//# sourceMappingURL=base-NZIvB1zK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-NZIvB1zK.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FileStorageBase } from './base-
|
|
2
|
-
import { P as ProtoService } from './index-
|
|
1
|
+
import { F as FileStorageBase } from './base-NZIvB1zK.js';
|
|
2
|
+
import { P as ProtoService } from './index-BOboD1oK.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-
|
|
17
|
+
//# sourceMappingURL=chunk-B9i8NMB_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-B9i8NMB_.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
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
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,10 +1050,19 @@ 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?:
|
|
1053
|
+
session?: _Session;
|
|
1033
1054
|
}) => T)): Promise<this & {
|
|
1034
|
-
session?:
|
|
1055
|
+
session?: _Session;
|
|
1035
1056
|
} & T>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Refreshes the authentication/session status for the socket connection.
|
|
1059
|
+
*
|
|
1060
|
+
* This method should be called when the session token or authentication state changes,
|
|
1061
|
+
* ensuring that any active socket connections are updated to reflect the new session.
|
|
1062
|
+
* Useful for maintaining real-time features (such as LiveQuery) after login, logout,
|
|
1063
|
+
* or session renewal.
|
|
1064
|
+
*/
|
|
1065
|
+
refreshSocketSession(): void;
|
|
1036
1066
|
/**
|
|
1037
1067
|
* Sets the session token.
|
|
1038
1068
|
* @param token - The session token.
|
|
@@ -1174,6 +1204,8 @@ type ExtraOptions<M extends boolean> = {
|
|
|
1174
1204
|
abortSignal?: AbortSignal;
|
|
1175
1205
|
/**
|
|
1176
1206
|
* Disable the triggers.
|
|
1207
|
+
*
|
|
1208
|
+
* Only effective when `master` is `true`.
|
|
1177
1209
|
*/
|
|
1178
1210
|
silent?: boolean;
|
|
1179
1211
|
};
|
|
@@ -1186,7 +1218,7 @@ interface TObject {
|
|
|
1186
1218
|
* Clones the object.
|
|
1187
1219
|
* @returns A clone of the object.
|
|
1188
1220
|
*/
|
|
1189
|
-
clone():
|
|
1221
|
+
clone(): this;
|
|
1190
1222
|
/**
|
|
1191
1223
|
* Gets a relation query for the specified key.
|
|
1192
1224
|
* @param key - The key of the relation.
|
|
@@ -1409,113 +1441,147 @@ type ExactOneProp<T> = {
|
|
|
1409
1441
|
|
|
1410
1442
|
declare namespace TSchema {
|
|
1411
1443
|
/**
|
|
1412
|
-
* Access Control List
|
|
1444
|
+
* Access Control List (ACL).
|
|
1445
|
+
*
|
|
1446
|
+
* An array of strings representing users or roles that have access to a resource.
|
|
1413
1447
|
*/
|
|
1414
1448
|
type ACL = string[];
|
|
1415
1449
|
/**
|
|
1416
1450
|
* Access Control Lists for read and update operations.
|
|
1451
|
+
*
|
|
1452
|
+
* Defines separate ACLs for reading and updating an object.
|
|
1417
1453
|
*/
|
|
1418
1454
|
type ACLs = {
|
|
1419
1455
|
/**
|
|
1420
1456
|
* ACL for read operation.
|
|
1457
|
+
* Users or roles allowed to read the object.
|
|
1421
1458
|
*/
|
|
1422
1459
|
read: TSchema.ACL;
|
|
1423
1460
|
/**
|
|
1424
1461
|
* ACL for update operation.
|
|
1462
|
+
* Users or roles allowed to update the object.
|
|
1425
1463
|
*/
|
|
1426
1464
|
update: TSchema.ACL;
|
|
1427
1465
|
};
|
|
1428
1466
|
/**
|
|
1429
|
-
*
|
|
1467
|
+
* Supported primitive data types.
|
|
1430
1468
|
*/
|
|
1431
1469
|
type Primitive = 'boolean' | 'number' | 'decimal' | 'string' | 'string[]' | 'date' | 'object' | 'array';
|
|
1432
1470
|
/**
|
|
1433
|
-
* Primitive type with
|
|
1471
|
+
* Primitive type with optional default value.
|
|
1472
|
+
*
|
|
1473
|
+
* Can be a string literal (e.g., 'string') or an object specifying the type and a default value.
|
|
1434
1474
|
*/
|
|
1435
1475
|
type PrimitiveType = Primitive | {
|
|
1436
1476
|
/**
|
|
1437
|
-
* The type
|
|
1477
|
+
* The primitive type.
|
|
1438
1478
|
*/
|
|
1439
1479
|
type: Primitive;
|
|
1440
1480
|
/**
|
|
1441
|
-
* Optional default value.
|
|
1481
|
+
* Optional default value for the field.
|
|
1442
1482
|
*/
|
|
1443
1483
|
default?: TValueWithoutObject;
|
|
1444
1484
|
};
|
|
1445
1485
|
/**
|
|
1446
|
-
* Vector type with a specified dimension and
|
|
1486
|
+
* Vector type with a specified dimension and optional default value.
|
|
1487
|
+
*
|
|
1488
|
+
* Used for fields storing fixed-length numeric arrays (vectors).
|
|
1447
1489
|
*/
|
|
1448
1490
|
type VectorType = {
|
|
1449
1491
|
/**
|
|
1450
|
-
* The type of the vector.
|
|
1492
|
+
* The type of the field. Always 'vector'.
|
|
1451
1493
|
*/
|
|
1452
1494
|
type: 'vector';
|
|
1453
1495
|
/**
|
|
1454
|
-
* The dimension of the vector.
|
|
1496
|
+
* The dimension (length) of the vector.
|
|
1455
1497
|
*/
|
|
1456
1498
|
dimension: number;
|
|
1457
1499
|
/**
|
|
1458
|
-
* Optional default value.
|
|
1500
|
+
* Optional default value for the vector.
|
|
1459
1501
|
*/
|
|
1460
1502
|
default?: number[];
|
|
1461
1503
|
};
|
|
1462
1504
|
/**
|
|
1463
|
-
* Shape type
|
|
1505
|
+
* Shape type for nested objects.
|
|
1506
|
+
*
|
|
1507
|
+
* Allows defining complex, nested object structures with their own field types.
|
|
1464
1508
|
*/
|
|
1465
1509
|
type ShapeType = {
|
|
1466
1510
|
/**
|
|
1467
|
-
* The type of the shape.
|
|
1511
|
+
* The type of the field. Always 'shape'.
|
|
1468
1512
|
*/
|
|
1469
1513
|
type: 'shape';
|
|
1470
1514
|
/**
|
|
1471
|
-
* The shape definition.
|
|
1515
|
+
* The shape definition, mapping field names to their data types.
|
|
1472
1516
|
*/
|
|
1473
1517
|
shape: Record<string, DataType>;
|
|
1474
1518
|
};
|
|
1475
1519
|
/**
|
|
1476
|
-
|
|
1477
|
-
|
|
1520
|
+
* Pointer type for referencing another class.
|
|
1521
|
+
*
|
|
1522
|
+
* Represents a one-to-one relationship to another object.
|
|
1523
|
+
*/
|
|
1478
1524
|
type PointerType = {
|
|
1479
1525
|
/**
|
|
1480
|
-
* The type of the pointer.
|
|
1526
|
+
* The type of the field. Always 'pointer'.
|
|
1481
1527
|
*/
|
|
1482
1528
|
type: 'pointer';
|
|
1483
1529
|
/**
|
|
1484
|
-
* The target class
|
|
1530
|
+
* The name of the target class being referenced.
|
|
1485
1531
|
*/
|
|
1486
1532
|
target: string;
|
|
1487
1533
|
};
|
|
1488
1534
|
/**
|
|
1489
|
-
* Relation type
|
|
1535
|
+
* Relation type for referencing multiple objects in another class.
|
|
1536
|
+
*
|
|
1537
|
+
* Represents a one-to-many or many-to-many relationship.
|
|
1538
|
+
* - `target`: The related class name.
|
|
1539
|
+
* - `foreignField`: (Optional) The field in the target class that refers back to this class.
|
|
1540
|
+
* - `match`: (Optional) Default match query options (filter, sort, etc.) applied when querying this relation.
|
|
1541
|
+
* Only used if `foreignField` is set.
|
|
1490
1542
|
*/
|
|
1491
1543
|
type RelationType = {
|
|
1492
1544
|
/**
|
|
1493
|
-
* The type of the relation.
|
|
1545
|
+
* The type of the field. Always 'relation'.
|
|
1494
1546
|
*/
|
|
1495
1547
|
type: 'relation';
|
|
1496
1548
|
/**
|
|
1497
|
-
* The target class
|
|
1549
|
+
* The name of the target class for this relation.
|
|
1498
1550
|
*/
|
|
1499
1551
|
target: string;
|
|
1500
1552
|
/**
|
|
1501
|
-
* Optional
|
|
1553
|
+
* (Optional) The field in the target class that refers back to this class.
|
|
1554
|
+
* If provided, the relation is managed via this foreign key.
|
|
1502
1555
|
*/
|
|
1503
1556
|
foreignField?: string;
|
|
1557
|
+
/**
|
|
1558
|
+
* (Optional) Default match query options for this relation.
|
|
1559
|
+
*
|
|
1560
|
+
* These options define default query behaviors—such as filtering, sorting, limiting results, and other query parameters—
|
|
1561
|
+
* that will be automatically applied when querying this relation via the specified `foreignField`.
|
|
1562
|
+
*
|
|
1563
|
+
* Note: `match` is only applicable if `foreignField` is set. If `foreignField` is not provided, `match` will be ignored.
|
|
1564
|
+
*/
|
|
1565
|
+
match?: TQueryBaseOptions;
|
|
1504
1566
|
};
|
|
1505
1567
|
/**
|
|
1506
|
-
* Data type
|
|
1568
|
+
* Data type for schema fields.
|
|
1569
|
+
*
|
|
1570
|
+
* Can be a primitive, vector, shape, pointer, or relation type.
|
|
1507
1571
|
*/
|
|
1508
1572
|
type DataType = PrimitiveType | VectorType | ShapeType | PointerType | RelationType;
|
|
1509
1573
|
/**
|
|
1510
|
-
* Class Level Permissions.
|
|
1574
|
+
* Class Level Permissions (CLPs).
|
|
1575
|
+
*
|
|
1576
|
+
* Defines access control for various operations at the class level.
|
|
1511
1577
|
*/
|
|
1512
1578
|
type CLPs = {
|
|
1513
1579
|
/**
|
|
1514
|
-
* ACL for get operation.
|
|
1580
|
+
* ACL for get (read single object) operation.
|
|
1515
1581
|
*/
|
|
1516
1582
|
get?: TSchema.ACL;
|
|
1517
1583
|
/**
|
|
1518
|
-
* ACL for find operation.
|
|
1584
|
+
* ACL for find (query multiple objects) operation.
|
|
1519
1585
|
*/
|
|
1520
1586
|
find?: TSchema.ACL;
|
|
1521
1587
|
/**
|
|
@@ -1536,32 +1602,36 @@ declare namespace TSchema {
|
|
|
1536
1602
|
delete?: TSchema.ACL;
|
|
1537
1603
|
};
|
|
1538
1604
|
/**
|
|
1539
|
-
* Field Level Permissions.
|
|
1605
|
+
* Field Level Permissions (FLPs).
|
|
1606
|
+
*
|
|
1607
|
+
* Defines access control for individual fields.
|
|
1540
1608
|
*/
|
|
1541
1609
|
type FLPs = {
|
|
1542
1610
|
/**
|
|
1543
|
-
* ACL for
|
|
1611
|
+
* ACL for reading the field.
|
|
1544
1612
|
*/
|
|
1545
1613
|
read?: TSchema.ACL;
|
|
1546
1614
|
/**
|
|
1547
|
-
* ACL for
|
|
1615
|
+
* ACL for creating the field.
|
|
1548
1616
|
*/
|
|
1549
1617
|
create?: TSchema.ACL;
|
|
1550
1618
|
/**
|
|
1551
|
-
* ACL for
|
|
1619
|
+
* ACL for updating the field.
|
|
1552
1620
|
*/
|
|
1553
1621
|
update?: TSchema.ACL;
|
|
1554
1622
|
};
|
|
1555
1623
|
/**
|
|
1556
|
-
*
|
|
1624
|
+
* Index definitions for the schema.
|
|
1625
|
+
*
|
|
1626
|
+
* Supports both basic and vector indexes.
|
|
1557
1627
|
*/
|
|
1558
1628
|
type Indexes = {
|
|
1559
1629
|
/**
|
|
1560
|
-
* Type of the index
|
|
1630
|
+
* Type of the index. Default is 'basic'.
|
|
1561
1631
|
*/
|
|
1562
1632
|
type?: 'basic';
|
|
1563
1633
|
/**
|
|
1564
|
-
* Keys for the index.
|
|
1634
|
+
* Keys for the index, mapping field names to sort order (1 for ascending, -1 for descending).
|
|
1565
1635
|
*/
|
|
1566
1636
|
keys: Record<string, 1 | -1>;
|
|
1567
1637
|
/**
|
|
@@ -1570,15 +1640,15 @@ declare namespace TSchema {
|
|
|
1570
1640
|
unique?: boolean;
|
|
1571
1641
|
} | {
|
|
1572
1642
|
/**
|
|
1573
|
-
* Type of the index
|
|
1643
|
+
* Type of the index. Must be 'vector' for vector indexes.
|
|
1574
1644
|
*/
|
|
1575
1645
|
type: 'vector';
|
|
1576
1646
|
/**
|
|
1577
|
-
* Keys for the vector index.
|
|
1647
|
+
* Keys for the vector index. Can be a single field or an array of fields.
|
|
1578
1648
|
*/
|
|
1579
1649
|
keys: string | string[];
|
|
1580
1650
|
/**
|
|
1581
|
-
* Method for the vector index.
|
|
1651
|
+
* Method for the vector index. Supported: 'hnsw', 'ivfflat'.
|
|
1582
1652
|
*/
|
|
1583
1653
|
method?: 'hnsw' | 'ivfflat';
|
|
1584
1654
|
};
|
|
@@ -1810,10 +1880,6 @@ type ProtoServiceOptions<Ext> = {
|
|
|
1810
1880
|
* The schema definitions for the service.
|
|
1811
1881
|
*/
|
|
1812
1882
|
schema: Record<string, TSchema>;
|
|
1813
|
-
/**
|
|
1814
|
-
* User resolver configuration.
|
|
1815
|
-
*/
|
|
1816
|
-
userResolver?: (proto: ProtoService<Ext>, user?: TUser) => Awaitable<TUser | undefined>;
|
|
1817
1883
|
/**
|
|
1818
1884
|
* Role resolver configuration.
|
|
1819
1885
|
*/
|
|
@@ -1911,7 +1977,7 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
1911
1977
|
private _storage?;
|
|
1912
1978
|
private _schedule;
|
|
1913
1979
|
req?: Request;
|
|
1914
|
-
session?:
|
|
1980
|
+
session?: _Session;
|
|
1915
1981
|
constructor(options: ProtoServiceOptions<Ext> & ProtoServiceKeyOptions);
|
|
1916
1982
|
shutdown(): Promise<void>;
|
|
1917
1983
|
get logger(): Logger;
|
|
@@ -1919,20 +1985,14 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
1919
1985
|
Query<T extends string>(className: T): TQuery<T, Ext, boolean>;
|
|
1920
1986
|
Relation<T extends string>(object: TObject, key: PathName<T>): TQuery<string, Ext, boolean>;
|
|
1921
1987
|
InsecureQuery<T extends string>(className: T): TQuery<T, Ext, true>;
|
|
1922
|
-
|
|
1923
|
-
sessionInfo(): Promise<Session | {
|
|
1924
|
-
loginedAt: Date | undefined;
|
|
1988
|
+
sessionInfo(): Promise<{
|
|
1925
1989
|
user?: TObject | undefined;
|
|
1926
|
-
_roles?:
|
|
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;
|
|
1990
|
+
_roles?: TRole[] | undefined;
|
|
1934
1991
|
sessionId?: string | undefined;
|
|
1935
1992
|
createdAt?: Date | undefined;
|
|
1993
|
+
updatedAt?: Date | undefined;
|
|
1994
|
+
loginedAt?: Date | undefined;
|
|
1995
|
+
cookieOptions?: any;
|
|
1936
1996
|
} | undefined>;
|
|
1937
1997
|
currentUser(): Promise<TUser | undefined>;
|
|
1938
1998
|
_currentRoles(): Promise<TRole[]>;
|
|
@@ -1945,9 +2005,9 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
1945
2005
|
req: R;
|
|
1946
2006
|
} & T;
|
|
1947
2007
|
connectWithSessionToken<T extends object>(token: string, attrs?: T | ((x: this & {
|
|
1948
|
-
session?:
|
|
2008
|
+
session?: _Session;
|
|
1949
2009
|
}) => T)): Promise<this & {
|
|
1950
|
-
session?:
|
|
2010
|
+
session?: _Session;
|
|
1951
2011
|
} & T>;
|
|
1952
2012
|
userRoles(user: TUser): Promise<TRole[]>;
|
|
1953
2013
|
becomeUser(req: Request, user: TUser, options?: {
|
|
@@ -2001,4 +2061,4 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
2001
2061
|
}
|
|
2002
2062
|
|
|
2003
2063
|
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-
|
|
2064
|
+
//# sourceMappingURL=index-BOboD1oK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BOboD1oK.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
|
//
|
|
@@ -1479,6 +1527,11 @@ class Service {
|
|
|
1479
1527
|
this.retryLimit = retryLimit;
|
|
1480
1528
|
this.cookieKey = cookieKey || AUTH_COOKIE_KEY;
|
|
1481
1529
|
}
|
|
1530
|
+
refreshSocketSession() {
|
|
1531
|
+
for (const socket of this.sockets) {
|
|
1532
|
+
socket.emit('auth', this.token);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1482
1535
|
setSessionToken(token) {
|
|
1483
1536
|
this.token = token;
|
|
1484
1537
|
if (typeof window === 'undefined') {
|
|
@@ -1650,6 +1703,9 @@ class ProtoClientInternal {
|
|
|
1650
1703
|
});
|
|
1651
1704
|
return proto.rebind(deserialize(res.data));
|
|
1652
1705
|
}
|
|
1706
|
+
refreshSocketSession() {
|
|
1707
|
+
this.service.refreshSocketSession();
|
|
1708
|
+
}
|
|
1653
1709
|
setSessionToken(proto, token) {
|
|
1654
1710
|
this.service.setSessionToken(token);
|
|
1655
1711
|
}
|
|
@@ -1991,6 +2047,9 @@ class ProtoClient extends ProtoType {
|
|
|
1991
2047
|
...(options ?? {})
|
|
1992
2048
|
});
|
|
1993
2049
|
}
|
|
2050
|
+
refreshSocketSession() {
|
|
2051
|
+
this[PVK].refreshSocketSession();
|
|
2052
|
+
}
|
|
1994
2053
|
setSessionToken(token) {
|
|
1995
2054
|
this[PVK].setSessionToken(this, token);
|
|
1996
2055
|
}
|
|
@@ -2024,4 +2083,4 @@ class ProtoClient extends ProtoType {
|
|
|
2024
2083
|
}
|
|
2025
2084
|
|
|
2026
2085
|
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-
|
|
2086
|
+
//# sourceMappingURL=index-BZ79Ljis.mjs.map
|