zibri 1.6.1 → 1.7.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/dist/index.d.mts +619 -94
- package/dist/index.d.ts +619 -94
- package/dist/index.js +1304 -469
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1291 -468
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import express, { Request, Response as Response$1, NextFunction, RequestHandler } from 'express';
|
|
2
|
+
import { EntitySchemaRelationOptions, DataSourceOptions as DataSourceOptions$1, ColumnType as ColumnType$1, QueryRunner, FindManyOptions, FindOneOptions as FindOneOptions$1, Repository as Repository$1, EntityTarget, EntityMetadata as EntityMetadata$1, DataSource as DataSource$1, EntitySchema, EntitySchemaColumnOptions, TableColumnOptions } from 'typeorm';
|
|
2
3
|
import { oas31 } from 'openapi3-ts';
|
|
3
4
|
import { ScheduledTask } from 'node-cron';
|
|
4
|
-
import { EntitySchemaRelationOptions, DataSourceOptions as DataSourceOptions$1, ColumnType as ColumnType$1, QueryRunner, FindManyOptions, FindOneOptions as FindOneOptions$1, Repository as Repository$1, EntityTarget, EntityMetadata as EntityMetadata$1, DataSource as DataSource$1, EntitySchema, EntitySchemaColumnOptions, TableColumnOptions } from 'typeorm';
|
|
5
5
|
import { IsolationLevel } from 'typeorm/driver/types/IsolationLevel';
|
|
6
6
|
import { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata';
|
|
7
7
|
import { SecuritySchemeObject } from 'openapi3-ts/dist/oas31';
|
|
@@ -23,6 +23,10 @@ type BasePropertyMetadata = {
|
|
|
23
23
|
* A description of the property.
|
|
24
24
|
*/
|
|
25
25
|
description: string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Whether or not this property should be excluded when generating change sets.
|
|
28
|
+
*/
|
|
29
|
+
excludeFromChangeSets: boolean;
|
|
26
30
|
};
|
|
27
31
|
/**
|
|
28
32
|
* Adds a default property which can be used to fill empty properties with default values.
|
|
@@ -149,16 +153,6 @@ type ObjectPropertyMetadata = BasePropertyMetadata & {
|
|
|
149
153
|
*/
|
|
150
154
|
type ObjectPropertyMetadataInput = Partial<OmitStrict<ObjectPropertyMetadata, 'type'>> & Pick<ObjectPropertyMetadata, 'cls'>;
|
|
151
155
|
|
|
152
|
-
/**
|
|
153
|
-
* A base entity that all db entities need to implement.
|
|
154
|
-
*/
|
|
155
|
-
type BaseEntity = {
|
|
156
|
-
/**
|
|
157
|
-
* The id of the entity.
|
|
158
|
-
*/
|
|
159
|
-
id: string;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
156
|
/**
|
|
163
157
|
* Metadata for boolean properties.
|
|
164
158
|
*/
|
|
@@ -509,7 +503,7 @@ type BaseRelationMetadata<T extends BaseEntity> = BasePropertyMetadata & Require
|
|
|
509
503
|
* The name of the inverse property on the target,
|
|
510
504
|
* e.g. 'user' if Posts has `@ManyToOne(() => User, 'post')`.
|
|
511
505
|
*/
|
|
512
|
-
inverseSide: keyof T
|
|
506
|
+
inverseSide: keyof T;
|
|
513
507
|
};
|
|
514
508
|
|
|
515
509
|
/**
|
|
@@ -534,7 +528,7 @@ type ManyToOnePropertyMetadata<T extends BaseEntity> = BaseRelationMetadata<T> &
|
|
|
534
528
|
/**
|
|
535
529
|
* Input Metadata for many to one properties.
|
|
536
530
|
*/
|
|
537
|
-
type ManyToOnePropertyMetadataInput<T extends BaseEntity> = Partial<OmitStrict<ManyToOnePropertyMetadata<T>, 'type'>> & Pick<ManyToOnePropertyMetadata<T>, 'target'>;
|
|
531
|
+
type ManyToOnePropertyMetadataInput<T extends BaseEntity> = Partial<OmitStrict<ManyToOnePropertyMetadata<T>, 'type'>> & Pick<ManyToOnePropertyMetadata<T>, 'target' | 'inverseSide'>;
|
|
538
532
|
|
|
539
533
|
/**
|
|
540
534
|
* Metadata for one to many properties.
|
|
@@ -548,7 +542,7 @@ type OneToManyPropertyMetadata<T extends BaseEntity> = BaseRelationMetadata<T> &
|
|
|
548
542
|
/**
|
|
549
543
|
* Input Metadata for one to many properties.
|
|
550
544
|
*/
|
|
551
|
-
type OneToManyPropertyMetadataInput<T extends BaseEntity> = Partial<OmitStrict<OneToManyPropertyMetadata<T>, 'type'>> & Pick<OneToManyPropertyMetadata<T>, 'target'>;
|
|
545
|
+
type OneToManyPropertyMetadataInput<T extends BaseEntity> = Partial<OmitStrict<OneToManyPropertyMetadata<T>, 'type'>> & Pick<OneToManyPropertyMetadata<T>, 'target' | 'inverseSide'>;
|
|
552
546
|
|
|
553
547
|
/**
|
|
554
548
|
* Metadata for one to one properties.
|
|
@@ -558,11 +552,23 @@ type OneToOnePropertyMetadata<T extends BaseEntity> = BaseRelationMetadata<T> &
|
|
|
558
552
|
* The type of the property.
|
|
559
553
|
*/
|
|
560
554
|
type: Relation.ONE_TO_ONE;
|
|
555
|
+
/**
|
|
556
|
+
* Whether or not this entity has a join column.
|
|
557
|
+
*/
|
|
558
|
+
joinColumn: boolean;
|
|
561
559
|
};
|
|
562
560
|
/**
|
|
563
561
|
* Input Metadata for one to one properties.
|
|
564
562
|
*/
|
|
565
|
-
type OneToOnePropertyMetadataInput<T extends BaseEntity> = Partial<OmitStrict<OneToOnePropertyMetadata<T>, 'type'>> & Pick<OneToOnePropertyMetadata<T>, 'target'>;
|
|
563
|
+
type OneToOnePropertyMetadataInput<T extends BaseEntity> = Partial<OmitStrict<OneToOnePropertyMetadata<T>, 'type'>> & Pick<OneToOnePropertyMetadata<T>, 'target' | 'inverseSide' | 'cascade'>;
|
|
564
|
+
/**
|
|
565
|
+
* Input Metadata for has one properties.
|
|
566
|
+
*/
|
|
567
|
+
type HasOnePropertyMetadataInput<T extends BaseEntity> = OmitStrict<OneToOnePropertyMetadataInput<T>, 'cascade' | 'joinColumn'> & Partial<Pick<OneToOnePropertyMetadataInput<T>, 'cascade'>>;
|
|
568
|
+
/**
|
|
569
|
+
* Input Metadata for belongs to one properties.
|
|
570
|
+
*/
|
|
571
|
+
type BelongsToOnePropertyMetadataInput<T extends BaseEntity> = HasOnePropertyMetadataInput<T>;
|
|
566
572
|
|
|
567
573
|
/**
|
|
568
574
|
* Metadata for many to many properties.
|
|
@@ -573,14 +579,14 @@ type ManyToManyPropertyMetadata<T extends BaseEntity> = BaseRelationMetadata<T>
|
|
|
573
579
|
*/
|
|
574
580
|
type: Relation.MANY_TO_MANY;
|
|
575
581
|
/**
|
|
576
|
-
* Whether or not this entity should
|
|
582
|
+
* Whether or not this entity should own the join table.
|
|
577
583
|
*/
|
|
578
584
|
joinTable: boolean;
|
|
579
585
|
};
|
|
580
586
|
/**
|
|
581
587
|
* Input Metadata for many to many properties.
|
|
582
588
|
*/
|
|
583
|
-
type ManyToManyPropertyMetadataInput<T extends BaseEntity> = Partial<OmitStrict<ManyToManyPropertyMetadata<T>, 'type'>> & Pick<ManyToManyPropertyMetadata<T>, 'target' | 'joinTable'>;
|
|
589
|
+
type ManyToManyPropertyMetadataInput<T extends BaseEntity> = Partial<OmitStrict<ManyToManyPropertyMetadata<T>, 'type'>> & Pick<ManyToManyPropertyMetadata<T>, 'target' | 'joinTable' | 'inverseSide'>;
|
|
584
590
|
|
|
585
591
|
/**
|
|
586
592
|
* The metadata of a property.
|
|
@@ -597,7 +603,7 @@ type PropertyMetadataInput = StringPropertyMetadataInput | NumberPropertyMetadat
|
|
|
597
603
|
/**
|
|
598
604
|
* The metadata input to define a relation property.
|
|
599
605
|
*/
|
|
600
|
-
type RelationMetadataInput<T extends BaseEntity> = ManyToOnePropertyMetadataInput<T> | OneToManyPropertyMetadataInput<T> | OneToOnePropertyMetadataInput<T> | ManyToManyPropertyMetadataInput<T>;
|
|
606
|
+
type RelationMetadataInput<T extends BaseEntity> = ManyToOnePropertyMetadataInput<T> | OneToManyPropertyMetadataInput<T> | OneToOnePropertyMetadataInput<T> | HasOnePropertyMetadataInput<T> | BelongsToOnePropertyMetadataInput<T> | ManyToManyPropertyMetadataInput<T>;
|
|
601
607
|
/**
|
|
602
608
|
* Bundles decorators for properties.
|
|
603
609
|
*/
|
|
@@ -653,16 +659,27 @@ declare namespace Property {
|
|
|
653
659
|
*/
|
|
654
660
|
function oneToMany<T extends BaseEntity>(metadata: OneToManyPropertyMetadataInput<T>): PropertyDecorator;
|
|
655
661
|
/**
|
|
656
|
-
* Defines a
|
|
662
|
+
* Defines a has one property.
|
|
663
|
+
* @param metadata - Additional data to specify the property.
|
|
664
|
+
*/
|
|
665
|
+
function hasOne<T extends BaseEntity>(metadata: HasOnePropertyMetadataInput<T>): PropertyDecorator;
|
|
666
|
+
/**
|
|
667
|
+
* Defines a belongs to one property.
|
|
657
668
|
* @param metadata - Additional data to specify the property.
|
|
658
669
|
*/
|
|
659
|
-
function
|
|
670
|
+
function belongsToOne<T extends BaseEntity>(metadata: BelongsToOnePropertyMetadataInput<T>): PropertyDecorator;
|
|
660
671
|
/**
|
|
661
672
|
* Defines a many to many property.
|
|
662
673
|
* @param metadata - Additional data to specify the property.
|
|
663
674
|
*/
|
|
664
675
|
function manyToMany<T extends BaseEntity>(metadata: ManyToManyPropertyMetadataInput<T>): PropertyDecorator;
|
|
665
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* The base entity that all db entities need to extend from.
|
|
679
|
+
*/
|
|
680
|
+
declare class BaseEntity {
|
|
681
|
+
id: string;
|
|
682
|
+
}
|
|
666
683
|
/**
|
|
667
684
|
* Creates full metadata for an array property item.
|
|
668
685
|
* @param data - The array item input data.
|
|
@@ -780,7 +797,7 @@ type BaseParamMetadata = {
|
|
|
780
797
|
/**
|
|
781
798
|
* Metadata for string parameters.
|
|
782
799
|
*/
|
|
783
|
-
type StringParamMetadata = BaseParamMetadata & OmitStrict<StringPropertyMetadata, 'primary' | 'default'>;
|
|
800
|
+
type StringParamMetadata = BaseParamMetadata & OmitStrict<StringPropertyMetadata, 'primary' | 'default' | 'excludeFromChangeSets'>;
|
|
784
801
|
/**
|
|
785
802
|
* Metadata Input for string parameters.
|
|
786
803
|
*/
|
|
@@ -789,7 +806,7 @@ type StringParamMetadataInput = Partial<OmitStrict<StringParamMetadata, 'name'>>
|
|
|
789
806
|
/**
|
|
790
807
|
* Metadata for number parameters.
|
|
791
808
|
*/
|
|
792
|
-
type NumberParamMetadata = BaseParamMetadata & OmitStrict<NumberPropertyMetadata, 'primary' | 'default'>;
|
|
809
|
+
type NumberParamMetadata = BaseParamMetadata & OmitStrict<NumberPropertyMetadata, 'primary' | 'default' | 'excludeFromChangeSets'>;
|
|
793
810
|
/**
|
|
794
811
|
* Metadata Input for number parameters.
|
|
795
812
|
*/
|
|
@@ -798,7 +815,7 @@ type NumberParamMetadataInput = Partial<OmitStrict<NumberParamMetadata, 'name'>>
|
|
|
798
815
|
/**
|
|
799
816
|
* Metadata for boolean parameters.
|
|
800
817
|
*/
|
|
801
|
-
type BooleanParamMetadata = BaseParamMetadata & OmitStrict<BooleanPropertyMetadata, 'default'>;
|
|
818
|
+
type BooleanParamMetadata = BaseParamMetadata & OmitStrict<BooleanPropertyMetadata, 'default' | 'excludeFromChangeSets'>;
|
|
802
819
|
/**
|
|
803
820
|
* Metadata Input for boolean parameters.
|
|
804
821
|
*/
|
|
@@ -807,7 +824,7 @@ type BooleanParamMetadataInput = Partial<OmitStrict<BooleanParamMetadata, 'name'
|
|
|
807
824
|
/**
|
|
808
825
|
* Metadata for Date parameters.
|
|
809
826
|
*/
|
|
810
|
-
type DateParamMetadata = BaseParamMetadata & OmitStrict<DatePropertyMetadata, 'default'>;
|
|
827
|
+
type DateParamMetadata = BaseParamMetadata & OmitStrict<DatePropertyMetadata, 'default' | 'excludeFromChangeSets'>;
|
|
811
828
|
/**
|
|
812
829
|
* Metadata Input for Date parameters.
|
|
813
830
|
*/
|
|
@@ -816,16 +833,29 @@ type DateParamMetadataInput = Partial<OmitStrict<DateParamMetadata, 'name'>> & P
|
|
|
816
833
|
/**
|
|
817
834
|
* Metadata for object parameters.
|
|
818
835
|
*/
|
|
819
|
-
type ObjectParamMetadata = BaseParamMetadata & ObjectPropertyMetadata
|
|
836
|
+
type ObjectParamMetadata = BaseParamMetadata & OmitStrict<ObjectPropertyMetadata, 'excludeFromChangeSets'>;
|
|
820
837
|
/**
|
|
821
838
|
* Metadata Input for object parameters.
|
|
822
839
|
*/
|
|
823
840
|
type ObjectParamMetadataInput = Partial<OmitStrict<ObjectParamMetadata, 'name'>> & Pick<ObjectParamMetadata, 'cls' | 'type'>;
|
|
824
841
|
|
|
842
|
+
/**
|
|
843
|
+
* Metadata for an item of an array parameter.
|
|
844
|
+
*/
|
|
845
|
+
type ArrayParamItemMetadata = OmitStrict<StringParamMetadata, 'name'> | OmitStrict<NumberParamMetadata, 'name'> | OmitStrict<BooleanParamMetadata, 'name'> | OmitStrict<DateParamMetadata, 'name'> | OmitStrict<ObjectParamMetadata, 'name'> | OmitStrict<ArrayParamMetadata, 'name'>;
|
|
846
|
+
/**
|
|
847
|
+
* Input metadata for an item of an array parameter.
|
|
848
|
+
*/
|
|
849
|
+
type ArrayParamItemMetadataInput = StringParamMetadataInput | NumberParamMetadataInput | BooleanParamMetadataInput | DateParamMetadataInput | ObjectParamMetadataInput | ArrayParamMetadataInput;
|
|
825
850
|
/**
|
|
826
851
|
* Metadata for array parameters.
|
|
827
852
|
*/
|
|
828
|
-
type ArrayParamMetadata = BaseParamMetadata & ArrayPropertyMetadata
|
|
853
|
+
type ArrayParamMetadata = BaseParamMetadata & OmitStrict<ArrayPropertyMetadata, 'excludeFromChangeSets' | 'items'> & {
|
|
854
|
+
/**
|
|
855
|
+
* Metadata for the items inside this array parameter.
|
|
856
|
+
*/
|
|
857
|
+
items: ArrayParamItemMetadata;
|
|
858
|
+
};
|
|
829
859
|
/**
|
|
830
860
|
* Metadata Input for array parameters.
|
|
831
861
|
*/
|
|
@@ -833,7 +863,7 @@ type ArrayParamMetadataInput = Partial<OmitStrict<ArrayParamMetadata, 'type' | '
|
|
|
833
863
|
/**
|
|
834
864
|
* Metadata of the array items.
|
|
835
865
|
*/
|
|
836
|
-
items:
|
|
866
|
+
items: ArrayParamItemMetadataInput;
|
|
837
867
|
};
|
|
838
868
|
|
|
839
869
|
/**
|
|
@@ -892,7 +922,7 @@ declare namespace Param {
|
|
|
892
922
|
/**
|
|
893
923
|
* Base metadata shared by all possible http request body properties.
|
|
894
924
|
*/
|
|
895
|
-
type BaseBodyMetadata = BasePropertyMetadata & {
|
|
925
|
+
type BaseBodyMetadata = OmitStrict<BasePropertyMetadata, 'excludeFromChangeSets'> & {
|
|
896
926
|
/**
|
|
897
927
|
* The class that defines the structure of the body metadata.
|
|
898
928
|
*/
|
|
@@ -970,8 +1000,8 @@ type MergeRequired<I, M> = I extends {
|
|
|
970
1000
|
} : M & {
|
|
971
1001
|
required: true;
|
|
972
1002
|
};
|
|
973
|
-
type RawParamMetadataToType<M extends (PathParamMetadata | QueryParamMetadata | HeaderParamMetadata | ArrayPropertyItemMetadata)> = M extends StringParamMetadata ? string : M extends NumberParamMetadata ? number : M extends BooleanParamMetadata ? boolean : M extends DateParamMetadata ? Date : M extends ObjectParamMetadata ? InstanceType<ReturnType<M['cls']>> : M extends ArrayParamMetadata ? ParamMetadataToType<M['items']>[] : never;
|
|
974
|
-
type ParamMetadataToType<M extends (PathParamMetadata | QueryParamMetadata | HeaderParamMetadata | ArrayPropertyItemMetadata)> = M extends {
|
|
1003
|
+
type RawParamMetadataToType<M extends (PathParamMetadata | QueryParamMetadata | HeaderParamMetadata | ArrayPropertyItemMetadata | OmitStrict<PathParamMetadata, 'name'> | OmitStrict<QueryParamMetadata, 'name'> | OmitStrict<HeaderParamMetadata, 'name'>)> = M extends StringParamMetadata ? string : M extends NumberParamMetadata ? number : M extends BooleanParamMetadata ? boolean : M extends DateParamMetadata ? Date : M extends ObjectParamMetadata ? InstanceType<ReturnType<M['cls']>> : M extends ArrayParamMetadata ? ParamMetadataToType<M['items']>[] : never;
|
|
1004
|
+
type ParamMetadataToType<M extends (PathParamMetadata | QueryParamMetadata | HeaderParamMetadata | ArrayPropertyItemMetadata | OmitStrict<PathParamMetadata, 'name'> | OmitStrict<QueryParamMetadata, 'name'> | OmitStrict<HeaderParamMetadata, 'name'>)> = M extends {
|
|
975
1005
|
required: false;
|
|
976
1006
|
} ? RawParamMetadataToType<M> | undefined : RawParamMetadataToType<M>;
|
|
977
1007
|
type InferModel<T> = T extends {
|
|
@@ -1124,6 +1154,20 @@ declare class Router implements RouterInterface {
|
|
|
1124
1154
|
private resolveRouteParams;
|
|
1125
1155
|
}
|
|
1126
1156
|
|
|
1157
|
+
/**
|
|
1158
|
+
* Runs the given function with the request saved in async local storage.
|
|
1159
|
+
* @param req - The request.
|
|
1160
|
+
* @param fn - The function to run.
|
|
1161
|
+
* @returns The result of the function.
|
|
1162
|
+
*/
|
|
1163
|
+
declare function runWithRequest<T>(req: HttpRequest, fn: () => T): T;
|
|
1164
|
+
/**
|
|
1165
|
+
* Resolves the currently active request from the async local storage.
|
|
1166
|
+
* @returns The currently active http request.
|
|
1167
|
+
* @throws When the async local storage store has not been initialized yet.
|
|
1168
|
+
*/
|
|
1169
|
+
declare function getCurrentRequest(): HttpRequest;
|
|
1170
|
+
|
|
1127
1171
|
/**
|
|
1128
1172
|
* Alias for the root OpenAPI 3.1 document object.
|
|
1129
1173
|
*/
|
|
@@ -1353,24 +1397,10 @@ type PaginationResult<T> = {
|
|
|
1353
1397
|
totalAmount: number;
|
|
1354
1398
|
};
|
|
1355
1399
|
|
|
1356
|
-
/**
|
|
1357
|
-
* Common properties shared by all users.
|
|
1358
|
-
*/
|
|
1359
|
-
type BaseUser<Role extends string> = BaseEntity & {
|
|
1360
|
-
/**
|
|
1361
|
-
* The email of the user.
|
|
1362
|
-
*/
|
|
1363
|
-
email: string;
|
|
1364
|
-
/**
|
|
1365
|
-
* The roles of the user.
|
|
1366
|
-
*/
|
|
1367
|
-
roles: Role[];
|
|
1368
|
-
};
|
|
1369
|
-
|
|
1370
1400
|
/**
|
|
1371
1401
|
* Interface for an auth strategy.
|
|
1372
1402
|
*/
|
|
1373
|
-
interface AuthStrategyInterface<RoleType extends string, UserType extends BaseUser<RoleType>, AuthDataType, CredentialType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType> {
|
|
1403
|
+
interface AuthStrategyInterface<RoleType extends string, UserType extends BaseUser<RoleType>, AuthDataType, CredentialType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutData> {
|
|
1374
1404
|
/**
|
|
1375
1405
|
* Initializes the strategy.
|
|
1376
1406
|
*/
|
|
@@ -1383,6 +1413,10 @@ interface AuthStrategyInterface<RoleType extends string, UserType extends BaseUs
|
|
|
1383
1413
|
* Logs in a user.
|
|
1384
1414
|
*/
|
|
1385
1415
|
login: (credentials: CredentialType) => Promise<AuthDataType>;
|
|
1416
|
+
/**
|
|
1417
|
+
* Logs out the current user.
|
|
1418
|
+
*/
|
|
1419
|
+
logout: (data: LogoutData) => Promise<void>;
|
|
1386
1420
|
/**
|
|
1387
1421
|
* Refreshes the login of a user.
|
|
1388
1422
|
*/
|
|
@@ -1417,10 +1451,40 @@ interface AuthStrategyInterface<RoleType extends string, UserType extends BaseUs
|
|
|
1417
1451
|
name: string;
|
|
1418
1452
|
}
|
|
1419
1453
|
|
|
1454
|
+
/**
|
|
1455
|
+
* Common properties shared by all users.
|
|
1456
|
+
*/
|
|
1457
|
+
type BaseUser<Role extends string> = BaseEntity & {
|
|
1458
|
+
/**
|
|
1459
|
+
* The email of the user.
|
|
1460
|
+
*/
|
|
1461
|
+
email: string;
|
|
1462
|
+
/**
|
|
1463
|
+
* The roles of the user.
|
|
1464
|
+
*/
|
|
1465
|
+
roles: Role[];
|
|
1466
|
+
};
|
|
1467
|
+
/**
|
|
1468
|
+
* Defines a base user entity class with the specified roles.
|
|
1469
|
+
* @param roleValue - The enum that is used for defining the roles of the user.
|
|
1470
|
+
*/
|
|
1471
|
+
declare function BaseUserEntity<Role extends string>(roleValue: AnyEnum<Role>): Newable<BaseUser<Role>>;
|
|
1472
|
+
/**
|
|
1473
|
+
* Checks whether or not the given value is a base user.
|
|
1474
|
+
* @param value - The value to check.
|
|
1475
|
+
* @returns True if the value has "id", "createdAt", "updatedAt", "email" and "roles" keys, false otherwise.
|
|
1476
|
+
*/
|
|
1477
|
+
declare function isBaseUser(value: unknown): value is BaseUser<string>;
|
|
1478
|
+
|
|
1420
1479
|
/**
|
|
1421
1480
|
* A generic auth strategy array.
|
|
1422
1481
|
*/
|
|
1423
|
-
type AuthStrategies = Newable<AuthStrategyInterface<string, BaseUser<string>, any, any, any, any, any>>[];
|
|
1482
|
+
type AuthStrategies = Newable<AuthStrategyInterface<string, BaseUser<string>, any, any, any, any, any, any>>[];
|
|
1483
|
+
|
|
1484
|
+
/**
|
|
1485
|
+
* Metadata for the \@Auth.skip decorator.
|
|
1486
|
+
*/
|
|
1487
|
+
type SkipAuthMetadata = object;
|
|
1424
1488
|
|
|
1425
1489
|
/**
|
|
1426
1490
|
* Metadata for the \@Auth.isLoggedIn decorator.
|
|
@@ -1436,7 +1500,7 @@ type IsLoggedInMetadata = {
|
|
|
1436
1500
|
/**
|
|
1437
1501
|
* Metadata for the \@Auth.isLoggedIn.skip decorator.
|
|
1438
1502
|
*/
|
|
1439
|
-
type SkipIsLoggedInMetadata =
|
|
1503
|
+
type SkipIsLoggedInMetadata = SkipAuthMetadata;
|
|
1440
1504
|
|
|
1441
1505
|
/**
|
|
1442
1506
|
* Interface for a User Repository.
|
|
@@ -1479,7 +1543,7 @@ type HasRoleMetadata = {
|
|
|
1479
1543
|
/**
|
|
1480
1544
|
* Metadata for the \@Auth.hasRole.skip decorator.
|
|
1481
1545
|
*/
|
|
1482
|
-
type SkipHasRoleMetadata =
|
|
1546
|
+
type SkipHasRoleMetadata = SkipAuthMetadata;
|
|
1483
1547
|
|
|
1484
1548
|
/**
|
|
1485
1549
|
* Metadata for the \@Auth.isNotLoggedIn decorator.
|
|
@@ -1495,7 +1559,7 @@ type IsNotLoggedInMetadata = {
|
|
|
1495
1559
|
/**
|
|
1496
1560
|
* Metadata for the \@Auth.isNotLoggedIn.skip decorator.
|
|
1497
1561
|
*/
|
|
1498
|
-
type SkipIsNotLoggedInMetadata =
|
|
1562
|
+
type SkipIsNotLoggedInMetadata = SkipAuthMetadata;
|
|
1499
1563
|
|
|
1500
1564
|
/**
|
|
1501
1565
|
* Metadata for the \@Auth.belongsTo decorator.
|
|
@@ -1523,18 +1587,12 @@ type BelongsToMetadata<TargetEntity extends Newable<BaseEntity>> = {
|
|
|
1523
1587
|
/**
|
|
1524
1588
|
* Metadata for the \@Auth.belongsTo.skip decorator.
|
|
1525
1589
|
*/
|
|
1526
|
-
type SkipBelongsToMetadata =
|
|
1527
|
-
|
|
1528
|
-
/**
|
|
1529
|
-
* Metadata for the \@Auth.skip decorator.
|
|
1530
|
-
*/
|
|
1531
|
-
type SkipAuthMetadata = {};
|
|
1590
|
+
type SkipBelongsToMetadata = SkipAuthMetadata;
|
|
1532
1591
|
|
|
1533
1592
|
/**
|
|
1534
1593
|
* A short lived token used to confirm a password reset.
|
|
1535
1594
|
*/
|
|
1536
|
-
declare class PasswordResetToken
|
|
1537
|
-
id: string;
|
|
1595
|
+
declare class PasswordResetToken extends BaseEntity {
|
|
1538
1596
|
/**
|
|
1539
1597
|
* The expiration date of the password reset token.
|
|
1540
1598
|
*/
|
|
@@ -1732,23 +1790,27 @@ interface AuthServiceInterface {
|
|
|
1732
1790
|
/**
|
|
1733
1791
|
* Logs in a user using the provided auth strategy and credentials.
|
|
1734
1792
|
*/
|
|
1735
|
-
login: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>>, credentials: CredentialsType) => Promise<AuthDataType>;
|
|
1793
|
+
login: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, credentials: CredentialsType) => Promise<AuthDataType>;
|
|
1736
1794
|
/**
|
|
1737
1795
|
* Refreshes the login of a user using the provided auth strategy and refresh login data.
|
|
1738
1796
|
*/
|
|
1739
|
-
refreshLogin: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>>, data: RefreshLoginDataType) => Promise<AuthDataType>;
|
|
1797
|
+
refreshLogin: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, data: RefreshLoginDataType) => Promise<AuthDataType>;
|
|
1740
1798
|
/**
|
|
1741
1799
|
* Get's the currently logged in user. When required is set to false this can return undefined.
|
|
1742
1800
|
*/
|
|
1743
|
-
getCurrentUser: <Role extends string, UserType extends BaseUser<Role>, B extends boolean = true>(request: HttpRequest,
|
|
1801
|
+
getCurrentUser: <Role extends string, UserType extends BaseUser<Role>, B extends boolean = true>(request: HttpRequest, allowedStrategies: AuthStrategies, required: B) => Promise<B extends false ? UserType | undefined : UserType>;
|
|
1744
1802
|
/**
|
|
1745
1803
|
* Request a new password for a user using the provided auth strategy and request password reset data.
|
|
1746
1804
|
*/
|
|
1747
|
-
requestPasswordReset: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>>, data: RequestPasswordResetDataType) => void | Promise<void>;
|
|
1805
|
+
requestPasswordReset: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, data: RequestPasswordResetDataType) => void | Promise<void>;
|
|
1748
1806
|
/**
|
|
1749
1807
|
* Confirms a new password for a user using the provided auth strategy and confirm password reset data.
|
|
1750
1808
|
*/
|
|
1751
|
-
confirmPasswordReset: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>>, data: ConfirmPasswordResetDataType) => void | Promise<void>;
|
|
1809
|
+
confirmPasswordReset: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, data: ConfirmPasswordResetDataType) => void | Promise<void>;
|
|
1810
|
+
/**
|
|
1811
|
+
* Logs out the current user.
|
|
1812
|
+
*/
|
|
1813
|
+
logout: <Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, data: LogoutDataType) => void | Promise<void>;
|
|
1752
1814
|
}
|
|
1753
1815
|
|
|
1754
1816
|
/**
|
|
@@ -1846,8 +1908,7 @@ declare class LoggedError {
|
|
|
1846
1908
|
/**
|
|
1847
1909
|
* The data saved for a log entry.
|
|
1848
1910
|
*/
|
|
1849
|
-
declare class Log
|
|
1850
|
-
id: string;
|
|
1911
|
+
declare class Log extends BaseEntity {
|
|
1851
1912
|
/**
|
|
1852
1913
|
* The log level.
|
|
1853
1914
|
*/
|
|
@@ -1909,8 +1970,7 @@ declare enum EmailStatus {
|
|
|
1909
1970
|
/**
|
|
1910
1971
|
* Definition of a Email.
|
|
1911
1972
|
*/
|
|
1912
|
-
declare class Email
|
|
1913
|
-
id: string;
|
|
1973
|
+
declare class Email extends BaseEntity {
|
|
1914
1974
|
/**
|
|
1915
1975
|
* The createdAt date. Is set to now by default.
|
|
1916
1976
|
*/
|
|
@@ -1961,7 +2021,7 @@ declare class Email implements BaseEntity {
|
|
|
1961
2021
|
priority: EmailPriority;
|
|
1962
2022
|
}
|
|
1963
2023
|
|
|
1964
|
-
declare const CreateEmailData_base: Newable<Omit<Email, "
|
|
2024
|
+
declare const CreateEmailData_base: Newable<Omit<Email, "createdAt" | "id">>;
|
|
1965
2025
|
/**
|
|
1966
2026
|
* Data for creating a new email in the db.
|
|
1967
2027
|
*/
|
|
@@ -2284,17 +2344,21 @@ type WhereFilterProperty<T> = T extends string ? StringWhereFilter : T extends n
|
|
|
2284
2344
|
/**
|
|
2285
2345
|
* Options for finding multiple entities.
|
|
2286
2346
|
*/
|
|
2287
|
-
type FindAllOptions<T extends BaseEntity> = BaseRepositoryOptions & OmitStrict<FindManyOptions<T>, 'transaction' | 'where'> & {
|
|
2347
|
+
type FindAllOptions<T extends BaseEntity> = BaseRepositoryOptions & OmitStrict<FindManyOptions<T>, 'transaction' | 'where' | 'relations' | 'withDeleted'> & {
|
|
2288
2348
|
/**
|
|
2289
2349
|
* The where filter to find the options by.
|
|
2290
2350
|
*/
|
|
2291
2351
|
where?: Where<T>;
|
|
2352
|
+
/**
|
|
2353
|
+
* The relations to include in the found entities.
|
|
2354
|
+
*/
|
|
2355
|
+
relations?: (keyof T)[];
|
|
2292
2356
|
};
|
|
2293
2357
|
|
|
2294
2358
|
/**
|
|
2295
2359
|
* Options for deleting multiple entities.
|
|
2296
2360
|
*/
|
|
2297
|
-
type DeleteAllOptions<T extends BaseEntity> = FindAllOptions<T>;
|
|
2361
|
+
type DeleteAllOptions<T extends BaseEntity> = OmitStrict<FindAllOptions<T>, 'where'>;
|
|
2298
2362
|
|
|
2299
2363
|
/**
|
|
2300
2364
|
* Options for deleting an entity by its id.
|
|
@@ -2309,17 +2373,26 @@ type FindAllPaginatedOptions<T extends BaseEntity> = OmitStrict<FindAllOptions<T
|
|
|
2309
2373
|
/**
|
|
2310
2374
|
* Options for finding a single entity.
|
|
2311
2375
|
*/
|
|
2312
|
-
type FindOneOptions<T extends BaseEntity> = BaseRepositoryOptions & OmitStrict<FindOneOptions$1<T>, 'where' | 'transaction'> & {
|
|
2376
|
+
type FindOneOptions<T extends BaseEntity> = BaseRepositoryOptions & OmitStrict<FindOneOptions$1<T>, 'where' | 'transaction' | 'relations' | 'withDeleted'> & {
|
|
2313
2377
|
/**
|
|
2314
2378
|
* The where filter to find the entity by.
|
|
2315
2379
|
*/
|
|
2316
2380
|
where?: Where<T>;
|
|
2381
|
+
/**
|
|
2382
|
+
* The relations to include in the found entity.
|
|
2383
|
+
*/
|
|
2384
|
+
relations?: (keyof T)[];
|
|
2317
2385
|
};
|
|
2318
2386
|
|
|
2319
2387
|
/**
|
|
2320
2388
|
* Options for finding a single entity by its id.
|
|
2321
2389
|
*/
|
|
2322
|
-
type FindByIdOptions<T extends BaseEntity> = OmitStrict<FindOneOptions<T>, 'where'
|
|
2390
|
+
type FindByIdOptions<T extends BaseEntity> = OmitStrict<FindOneOptions<T>, 'where' | 'relations'> & {
|
|
2391
|
+
/**
|
|
2392
|
+
* The relations to include in the found entity.
|
|
2393
|
+
*/
|
|
2394
|
+
relations?: (keyof T)[];
|
|
2395
|
+
};
|
|
2323
2396
|
|
|
2324
2397
|
/**
|
|
2325
2398
|
* Options for updating multiple entities at once.
|
|
@@ -2347,7 +2420,7 @@ type UpdateByIdOptions = BaseRepositoryOptions & {
|
|
|
2347
2420
|
* A repository that handles database related things for its entity.
|
|
2348
2421
|
*/
|
|
2349
2422
|
declare class Repository<T extends BaseEntity, CreateData extends DeepPartial<T> = DeepPartial<T>, UpdateData extends DeepPartial<T> = DeepPartial<T>> {
|
|
2350
|
-
|
|
2423
|
+
protected readonly entityClass: Newable<T>;
|
|
2351
2424
|
protected readonly logger: LoggerInterface;
|
|
2352
2425
|
private readonly typeOrmRepository;
|
|
2353
2426
|
constructor(entityClass: Newable<T>, repo: Repository$1<T> | Repository<T>);
|
|
@@ -2425,14 +2498,13 @@ declare class Repository<T extends BaseEntity, CreateData extends DeepPartial<T>
|
|
|
2425
2498
|
* @param options - Additional options, like a transaction.
|
|
2426
2499
|
* @returns An array of all the updated entities.
|
|
2427
2500
|
*/
|
|
2428
|
-
deleteAll(where: Where<T>, options?:
|
|
2501
|
+
deleteAll(where: Where<T>, options?: DeleteAllOptions<T>): Promise<T[]>;
|
|
2429
2502
|
}
|
|
2430
2503
|
|
|
2431
2504
|
/**
|
|
2432
2505
|
* The migration entity that is stored in the db.
|
|
2433
2506
|
*/
|
|
2434
|
-
declare class MigrationEntity
|
|
2435
|
-
id: string;
|
|
2507
|
+
declare class MigrationEntity extends BaseEntity {
|
|
2436
2508
|
/**
|
|
2437
2509
|
* The name of the migration.
|
|
2438
2510
|
*/
|
|
@@ -2560,7 +2632,8 @@ declare abstract class BaseDataSource {
|
|
|
2560
2632
|
* @param metadata - The relation metadata to transform.
|
|
2561
2633
|
* @returns Typeorm relation options.
|
|
2562
2634
|
*/
|
|
2563
|
-
protected propertyToRelationOptions<T extends BaseEntity>(metadata:
|
|
2635
|
+
protected propertyToRelationOptions<T extends BaseEntity>(metadata: RelationMetadata<T>): EntitySchemaRelationOptions;
|
|
2636
|
+
private hasCascadeFlag;
|
|
2564
2637
|
/**
|
|
2565
2638
|
* Transforms the given property metadata to typeorm column options.
|
|
2566
2639
|
* @param metadata - The property metadata to transform.
|
|
@@ -2712,8 +2785,7 @@ declare class EmailService implements EmailServiceInterface {
|
|
|
2712
2785
|
/**
|
|
2713
2786
|
* A mailing list like a newsletter that people can easily subscribe and unsubscribe to.
|
|
2714
2787
|
*/
|
|
2715
|
-
declare class MailingList
|
|
2716
|
-
id: string;
|
|
2788
|
+
declare class MailingList extends BaseEntity {
|
|
2717
2789
|
/**
|
|
2718
2790
|
* The name of the mailing list.
|
|
2719
2791
|
*/
|
|
@@ -2727,8 +2799,7 @@ declare class MailingList implements BaseEntity {
|
|
|
2727
2799
|
/**
|
|
2728
2800
|
* Defines a subscriber to a single or multiple mailing lists.
|
|
2729
2801
|
*/
|
|
2730
|
-
declare class MailingListSubscriber
|
|
2731
|
-
id: string;
|
|
2802
|
+
declare class MailingListSubscriber extends BaseEntity {
|
|
2732
2803
|
/**
|
|
2733
2804
|
* The optional name of the subscriber.
|
|
2734
2805
|
*/
|
|
@@ -2746,8 +2817,7 @@ declare class MailingListSubscriber implements BaseEntity {
|
|
|
2746
2817
|
/**
|
|
2747
2818
|
* A short lived token used to confirm a mailing list subscription.
|
|
2748
2819
|
*/
|
|
2749
|
-
declare class MailingListSubscriptionConfirmationToken
|
|
2750
|
-
id: string;
|
|
2820
|
+
declare class MailingListSubscriptionConfirmationToken extends BaseEntity {
|
|
2751
2821
|
/**
|
|
2752
2822
|
* The expiration date of the confirmation token.
|
|
2753
2823
|
*/
|
|
@@ -3227,11 +3297,11 @@ declare class AuthService implements AuthServiceInterface {
|
|
|
3227
3297
|
readonly strategies: AuthStrategies;
|
|
3228
3298
|
constructor();
|
|
3229
3299
|
init(authStrategies: AuthStrategies): Promise<void>;
|
|
3230
|
-
login<Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>>, credentials: CredentialsType): Promise<AuthDataType>;
|
|
3231
|
-
refreshLogin<Role extends string, UserType extends BaseUser<Role>, RefreshLoginDataType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>>, data: RefreshLoginDataType): Promise<AuthDataType>;
|
|
3300
|
+
login<Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, credentials: CredentialsType): Promise<AuthDataType>;
|
|
3301
|
+
refreshLogin<Role extends string, UserType extends BaseUser<Role>, RefreshLoginDataType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, data: RefreshLoginDataType): Promise<AuthDataType>;
|
|
3232
3302
|
getCurrentUser<Role extends string, UserType extends BaseUser<Role>, B extends boolean = true>(request: HttpRequest, allowedStrategies: AuthStrategies, required: B): Promise<B extends false ? UserType | undefined : UserType>;
|
|
3233
|
-
requestPasswordReset<Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>>, data: RequestPasswordResetDataType): Promise<void>;
|
|
3234
|
-
confirmPasswordReset<Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType>>, data: ConfirmPasswordResetDataType): Promise<void>;
|
|
3303
|
+
requestPasswordReset<Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, data: RequestPasswordResetDataType): Promise<void>;
|
|
3304
|
+
confirmPasswordReset<Role extends string, UserType extends BaseUser<Role>, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, data: ConfirmPasswordResetDataType): Promise<void>;
|
|
3235
3305
|
checkAccess(controllerClass: Newable<unknown>, controllerMethod: string, request: HttpRequest): Promise<void>;
|
|
3236
3306
|
isLoggedIn(request: HttpRequest, allowedStrategies: AuthStrategies): Promise<boolean>;
|
|
3237
3307
|
hasRole(request: HttpRequest, allowedStrategies: AuthStrategies, allowedRoles: string[]): Promise<boolean>;
|
|
@@ -3240,6 +3310,7 @@ declare class AuthService implements AuthServiceInterface {
|
|
|
3240
3310
|
resolveIsNotLoggedInMetadata(controllerClass: Newable<unknown>, controllerMethod: string): Promise<IsNotLoggedInMetadata | undefined>;
|
|
3241
3311
|
resolveHasRoleMetadata(controllerClass: Newable<unknown>, controllerMethod: string): Promise<HasRoleMetadata | undefined>;
|
|
3242
3312
|
resolveBelongsToMetadata(controllerClass: Newable<unknown>, controllerMethod: string): Promise<BelongsToMetadata<Newable<BaseEntity>> | undefined>;
|
|
3313
|
+
logout<Role extends string, UserType extends BaseUser<Role>, RefreshLoginDataType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, LogoutDataType>(strategy: Newable<AuthStrategyInterface<Role, UserType, AuthDataType, CredentialsType, RequestPasswordResetDataType, ConfirmPasswordResetDataType, RefreshLoginDataType, LogoutDataType>>, data: LogoutDataType): Promise<void>;
|
|
3243
3314
|
}
|
|
3244
3315
|
|
|
3245
3316
|
/**
|
|
@@ -3328,7 +3399,7 @@ declare class JwtCredentials implements Pick<BaseUser<string>, 'id' | 'email'> {
|
|
|
3328
3399
|
*/
|
|
3329
3400
|
password: string;
|
|
3330
3401
|
}
|
|
3331
|
-
declare const JwtCredentialsDto_base: Newable<Omit<JwtCredentials, "
|
|
3402
|
+
declare const JwtCredentialsDto_base: Newable<Omit<JwtCredentials, "userId" | "id">>;
|
|
3332
3403
|
/**
|
|
3333
3404
|
* The actual credentials sent over http.
|
|
3334
3405
|
*/
|
|
@@ -3373,7 +3444,7 @@ type JwtRequestPasswordResetData<RoleType extends string, UserType extends BaseU
|
|
|
3373
3444
|
/**
|
|
3374
3445
|
* Jwt auth strategy implementation of Zibri.
|
|
3375
3446
|
*/
|
|
3376
|
-
declare class JwtAuthStrategy<RoleType extends string, UserType extends BaseUser<RoleType> = BaseUser<RoleType>> implements AuthStrategyInterface<RoleType, UserType, JwtAuthData<RoleType>, JwtCredentialsDto, JwtRequestPasswordResetData<RoleType, UserType>, JwtConfirmPasswordResetData, JwtRefreshLoginData> {
|
|
3447
|
+
declare class JwtAuthStrategy<RoleType extends string, UserType extends BaseUser<RoleType> = BaseUser<RoleType>> implements AuthStrategyInterface<RoleType, UserType, JwtAuthData<RoleType>, JwtCredentialsDto, JwtRequestPasswordResetData<RoleType, UserType>, JwtConfirmPasswordResetData, JwtRefreshLoginData, JwtRefreshLoginData> {
|
|
3377
3448
|
readonly name: string;
|
|
3378
3449
|
readonly securityScheme: SecuritySchemeObject;
|
|
3379
3450
|
private readonly accessTokenSecret;
|
|
@@ -3391,6 +3462,7 @@ declare class JwtAuthStrategy<RoleType extends string, UserType extends BaseUser
|
|
|
3391
3462
|
init(): void;
|
|
3392
3463
|
private checkForEntities;
|
|
3393
3464
|
login(credentials: JwtCredentialsDto): Promise<JwtAuthData<RoleType>>;
|
|
3465
|
+
logout(data: JwtRefreshLoginData): Promise<void>;
|
|
3394
3466
|
private createRefreshToken;
|
|
3395
3467
|
refreshLogin(data: JwtRefreshLoginData): Promise<JwtAuthData<RoleType>>;
|
|
3396
3468
|
private verifyAndResolveRefreshToken;
|
|
@@ -3459,8 +3531,7 @@ type JwtRefreshTokenPayload<Role extends string, T extends BaseUser<Role>> = {
|
|
|
3459
3531
|
/**
|
|
3460
3532
|
* The jwt refresh token that gets stored in the database.
|
|
3461
3533
|
*/
|
|
3462
|
-
declare class JwtRefreshToken
|
|
3463
|
-
id: string;
|
|
3534
|
+
declare class JwtRefreshToken extends BaseEntity {
|
|
3464
3535
|
/**
|
|
3465
3536
|
* The id of the user that this token belongs to.
|
|
3466
3537
|
*/
|
|
@@ -3589,8 +3660,7 @@ declare abstract class HashUtilities {
|
|
|
3589
3660
|
/**
|
|
3590
3661
|
* The cron job entity that is stored in the db.
|
|
3591
3662
|
*/
|
|
3592
|
-
declare class CronJobEntity
|
|
3593
|
-
id: string;
|
|
3663
|
+
declare class CronJobEntity extends BaseEntity {
|
|
3594
3664
|
/**
|
|
3595
3665
|
* The name of the cron job.
|
|
3596
3666
|
*/
|
|
@@ -3864,6 +3934,7 @@ declare const ZIBRI_DI_TOKENS: {
|
|
|
3864
3934
|
readonly EMAIL_SERVICE: "zi.email_service";
|
|
3865
3935
|
readonly EMAIL_CONFIG: "zi.email_config";
|
|
3866
3936
|
readonly MAILING_LIST_SERVICE: "zi.mailing_list_service";
|
|
3937
|
+
readonly CURRENT_REQUEST: "zi.current_request";
|
|
3867
3938
|
};
|
|
3868
3939
|
|
|
3869
3940
|
/**
|
|
@@ -4103,6 +4174,36 @@ declare class HtmlResponse {
|
|
|
4103
4174
|
static fromStream(stream: Readable): HtmlResponse;
|
|
4104
4175
|
}
|
|
4105
4176
|
|
|
4177
|
+
/**
|
|
4178
|
+
* A bundle of providers, controllers, cronJobs, bodyParsers and authStrategies.
|
|
4179
|
+
*/
|
|
4180
|
+
type ZibriPlugin = {
|
|
4181
|
+
/**
|
|
4182
|
+
* The DI providers to register/override.
|
|
4183
|
+
*/
|
|
4184
|
+
providers?: DiProvider<unknown>[];
|
|
4185
|
+
/**
|
|
4186
|
+
* The controllers to register in the app.
|
|
4187
|
+
*/
|
|
4188
|
+
controllers?: Newable<unknown>[];
|
|
4189
|
+
/**
|
|
4190
|
+
* The cron jobs to register in the app.
|
|
4191
|
+
*/
|
|
4192
|
+
cronJobs?: Newable<CronJob>[];
|
|
4193
|
+
/**
|
|
4194
|
+
* The body parsers to register.
|
|
4195
|
+
*
|
|
4196
|
+
* If nothing is provided, the Zibri default parsers will be used.
|
|
4197
|
+
*/
|
|
4198
|
+
bodyParsers?: Newable<BodyParserInterface>[];
|
|
4199
|
+
/**
|
|
4200
|
+
* The auth strategies to register.
|
|
4201
|
+
*
|
|
4202
|
+
* If nothing is provided, the Zibri default jwt auth strategy will be used.
|
|
4203
|
+
*/
|
|
4204
|
+
authStrategies?: AuthStrategies;
|
|
4205
|
+
};
|
|
4206
|
+
|
|
4106
4207
|
/**
|
|
4107
4208
|
* All options for a Zibri application.
|
|
4108
4209
|
*/
|
|
@@ -4150,9 +4251,13 @@ type ZibriApplicationOptions = {
|
|
|
4150
4251
|
* The cron jobs to register in the app.
|
|
4151
4252
|
*/
|
|
4152
4253
|
cronJobs?: Newable<CronJob>[];
|
|
4254
|
+
/**
|
|
4255
|
+
* The plugins to be used.
|
|
4256
|
+
*/
|
|
4257
|
+
plugins?: ZibriPlugin[];
|
|
4153
4258
|
};
|
|
4154
4259
|
|
|
4155
|
-
type FullZibriApplicationOptions = Required<ZibriApplicationOptions
|
|
4260
|
+
type FullZibriApplicationOptions = Required<OmitStrict<ZibriApplicationOptions, 'plugins'>>;
|
|
4156
4261
|
/**
|
|
4157
4262
|
* A Zibri application.
|
|
4158
4263
|
*/
|
|
@@ -4197,6 +4302,7 @@ declare class ZibriApplication {
|
|
|
4197
4302
|
* @throws When the app has already been started.
|
|
4198
4303
|
*/
|
|
4199
4304
|
start(port: number): Promise<void>;
|
|
4305
|
+
private createFullOptions;
|
|
4200
4306
|
}
|
|
4201
4307
|
|
|
4202
4308
|
/**
|
|
@@ -4661,6 +4767,425 @@ declare class PrometheusMetricsService implements MetricsServiceInterface {
|
|
|
4661
4767
|
getMetricSnapshots(): MetricsSnapshot[];
|
|
4662
4768
|
}
|
|
4663
4769
|
|
|
4770
|
+
/**
|
|
4771
|
+
* The type of the change set.
|
|
4772
|
+
* Can bei either CREATE, REPLACE, RESET, UPDATE or DELETE.
|
|
4773
|
+
*/
|
|
4774
|
+
declare enum ChangeSetType {
|
|
4775
|
+
CREATE = "create",
|
|
4776
|
+
REPLACE = "replace",
|
|
4777
|
+
RESET = "reset",
|
|
4778
|
+
UPDATE = "update",
|
|
4779
|
+
DELETE = "delete",
|
|
4780
|
+
RESTORE = "restore"
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4783
|
+
/**
|
|
4784
|
+
* Defines a single value change of an change set.
|
|
4785
|
+
*/
|
|
4786
|
+
declare class Change<T = unknown> extends BaseEntity {
|
|
4787
|
+
/**
|
|
4788
|
+
* The key of the value that has been changed.
|
|
4789
|
+
*/
|
|
4790
|
+
key: string;
|
|
4791
|
+
/**
|
|
4792
|
+
* The value before it was changed.
|
|
4793
|
+
*/
|
|
4794
|
+
previousValue?: T;
|
|
4795
|
+
/**
|
|
4796
|
+
* The value after it was changed.
|
|
4797
|
+
*/
|
|
4798
|
+
newValue?: T;
|
|
4799
|
+
/**
|
|
4800
|
+
* The change set that this change belongs to.
|
|
4801
|
+
*/
|
|
4802
|
+
changeSet: ChangeSet;
|
|
4803
|
+
}
|
|
4804
|
+
/**
|
|
4805
|
+
* The data required to create a change.
|
|
4806
|
+
*/
|
|
4807
|
+
type CreateChangeData = OmitStrict<Change, 'id'>;
|
|
4808
|
+
/**
|
|
4809
|
+
* A new change.
|
|
4810
|
+
*/
|
|
4811
|
+
type NewChange = OmitStrict<Change, 'id' | 'changeSet'>;
|
|
4812
|
+
|
|
4813
|
+
/**
|
|
4814
|
+
* A single change set.
|
|
4815
|
+
* Gets automatically created for configured entities whenever they are changed.
|
|
4816
|
+
*/
|
|
4817
|
+
declare class ChangeSet extends BaseEntity {
|
|
4818
|
+
/**
|
|
4819
|
+
* Whether this change set was initialized on creating, updating or deleting the entity.
|
|
4820
|
+
*/
|
|
4821
|
+
type: ChangeSetType;
|
|
4822
|
+
/**
|
|
4823
|
+
* The time at which the change happened.
|
|
4824
|
+
*/
|
|
4825
|
+
createdAt: Date;
|
|
4826
|
+
/**
|
|
4827
|
+
* The id of the user that changed something.
|
|
4828
|
+
*/
|
|
4829
|
+
createdBy?: string;
|
|
4830
|
+
/**
|
|
4831
|
+
* The things that have been changed.
|
|
4832
|
+
*/
|
|
4833
|
+
changes: Change[];
|
|
4834
|
+
/**
|
|
4835
|
+
* The id of the related entity that this change set belongs to.
|
|
4836
|
+
*/
|
|
4837
|
+
changeSetEntityId: string;
|
|
4838
|
+
}
|
|
4839
|
+
/**
|
|
4840
|
+
* The data required to create a new change set.
|
|
4841
|
+
*/
|
|
4842
|
+
type CreateChangeSetData = OmitStrict<ChangeSet, 'id' | 'changes'> & {
|
|
4843
|
+
/**
|
|
4844
|
+
* The changes of the changes set.
|
|
4845
|
+
*/
|
|
4846
|
+
changes: NewChange[];
|
|
4847
|
+
};
|
|
4848
|
+
|
|
4849
|
+
/**
|
|
4850
|
+
* An entity that can be handled by the ChangeSetRepository.
|
|
4851
|
+
* Has an uuid id and a relation to all its changeSets.
|
|
4852
|
+
*/
|
|
4853
|
+
type ChangeSetEntity = BaseEntity & {
|
|
4854
|
+
/**
|
|
4855
|
+
* The change sets of the entity.
|
|
4856
|
+
*/
|
|
4857
|
+
changeSets: ChangeSet[];
|
|
4858
|
+
};
|
|
4859
|
+
/**
|
|
4860
|
+
* Checks whether the given class is a ChangeSetEntity class.
|
|
4861
|
+
* @param cls - The class to check.
|
|
4862
|
+
* @returns True if it has a changeSets property of type array.
|
|
4863
|
+
*/
|
|
4864
|
+
declare function isChangeSetEntityNewable(cls: Newable<unknown>): cls is Newable<ChangeSetEntity>;
|
|
4865
|
+
|
|
4866
|
+
/**
|
|
4867
|
+
* An entity that can be handled by the SoftDeleteRepository.
|
|
4868
|
+
* Has an uuid id, a relation to all its changeSets and a flag that determines whether it is "soft deleted" or not.
|
|
4869
|
+
*/
|
|
4870
|
+
type SoftDeleteEntity = ChangeSetEntity & {
|
|
4871
|
+
/**
|
|
4872
|
+
* Whether or not the entity is soft deleted.
|
|
4873
|
+
*/
|
|
4874
|
+
deleted: boolean;
|
|
4875
|
+
};
|
|
4876
|
+
/**
|
|
4877
|
+
* Checks whether the given class is a SoftDeleteEntity class.
|
|
4878
|
+
* @param cls - The class to check.
|
|
4879
|
+
* @returns True if it is a ChangeSetEntity class and also has a deleted property of type boolean.
|
|
4880
|
+
*/
|
|
4881
|
+
declare function isSoftDeleteEntityNewable(cls: Newable<unknown>): cls is Newable<SoftDeleteEntity>;
|
|
4882
|
+
|
|
4883
|
+
/**
|
|
4884
|
+
* A single where filter for a soft delete entity.
|
|
4885
|
+
*/
|
|
4886
|
+
type SoftDeleteWhereFilter<T extends SoftDeleteEntity> = OmitStrict<WhereFilter<T>, 'deleted'>;
|
|
4887
|
+
/**
|
|
4888
|
+
* The type for a soft delete where property. Can either be a single where filter or an array of where filters.
|
|
4889
|
+
*/
|
|
4890
|
+
type SoftDeleteWhere<T extends SoftDeleteEntity> = SoftDeleteWhereFilter<T> | SoftDeleteWhereFilter<T>[];
|
|
4891
|
+
|
|
4892
|
+
/**
|
|
4893
|
+
* Options for finding multiple soft delete entities.
|
|
4894
|
+
*/
|
|
4895
|
+
type SoftDeleteFindAllOptions<T extends SoftDeleteEntity> = OmitStrict<FindAllOptions<T>, 'where'> & {
|
|
4896
|
+
/**
|
|
4897
|
+
* The where filter to find the options by.
|
|
4898
|
+
*/
|
|
4899
|
+
where?: SoftDeleteWhere<T>;
|
|
4900
|
+
/**
|
|
4901
|
+
* Whether or not soft deleted entities should be included.
|
|
4902
|
+
*/
|
|
4903
|
+
withDeleted?: boolean;
|
|
4904
|
+
};
|
|
4905
|
+
|
|
4906
|
+
/**
|
|
4907
|
+
* Options for finding a single soft delete entity by its id.
|
|
4908
|
+
*/
|
|
4909
|
+
type SoftDeleteFindByIdOptions<T extends SoftDeleteEntity> = FindByIdOptions<T> & {
|
|
4910
|
+
/**
|
|
4911
|
+
* Whether or not soft deleted entities should be included.
|
|
4912
|
+
*/
|
|
4913
|
+
withDeleted?: boolean;
|
|
4914
|
+
};
|
|
4915
|
+
|
|
4916
|
+
/**
|
|
4917
|
+
* Options for finding a single entity.
|
|
4918
|
+
*/
|
|
4919
|
+
type SoftDeleteFindOneOptions<T extends SoftDeleteEntity> = OmitStrict<FindOneOptions<T>, 'where'> & {
|
|
4920
|
+
/**
|
|
4921
|
+
* The where filter to find the options by.
|
|
4922
|
+
*/
|
|
4923
|
+
where?: SoftDeleteWhere<T>;
|
|
4924
|
+
/**
|
|
4925
|
+
* Whether or not soft deleted entities should be included.
|
|
4926
|
+
*/
|
|
4927
|
+
withDeleted?: boolean;
|
|
4928
|
+
};
|
|
4929
|
+
|
|
4930
|
+
/**
|
|
4931
|
+
* Options for finding soft delete entities in paginated form.
|
|
4932
|
+
*/
|
|
4933
|
+
type SoftDeleteFindAllPaginatedOptions<T extends SoftDeleteEntity> = OmitStrict<FindAllPaginatedOptions<T>, 'where'> & {
|
|
4934
|
+
/**
|
|
4935
|
+
* The where filter to find the options by.
|
|
4936
|
+
*/
|
|
4937
|
+
where?: SoftDeleteWhere<T>;
|
|
4938
|
+
/**
|
|
4939
|
+
* Whether or not soft deleted entities should be included.
|
|
4940
|
+
*/
|
|
4941
|
+
withDeleted?: boolean;
|
|
4942
|
+
};
|
|
4943
|
+
|
|
4944
|
+
/**
|
|
4945
|
+
* Options for updating multiple soft delete entities at once.
|
|
4946
|
+
*/
|
|
4947
|
+
type SoftDeleteUpdateAllOptions = UpdateAllOptions & {
|
|
4948
|
+
/**
|
|
4949
|
+
* Whether or not soft deleted entities should be included.
|
|
4950
|
+
*/
|
|
4951
|
+
withDeleted?: boolean;
|
|
4952
|
+
};
|
|
4953
|
+
|
|
4954
|
+
/**
|
|
4955
|
+
* Options for updating a soft delete entity by its id.
|
|
4956
|
+
*/
|
|
4957
|
+
type SoftDeleteUpdateByIdOptions = UpdateByIdOptions & {
|
|
4958
|
+
/**
|
|
4959
|
+
* Whether or not soft deleted entities should be included.
|
|
4960
|
+
*/
|
|
4961
|
+
withDeleted?: boolean;
|
|
4962
|
+
};
|
|
4963
|
+
|
|
4964
|
+
/**
|
|
4965
|
+
* The result for resetting a change set on an entity.
|
|
4966
|
+
*/
|
|
4967
|
+
type ResetChangeSetResult<T extends ChangeSetEntity> = {
|
|
4968
|
+
/**
|
|
4969
|
+
* The entity after the change set has been reset.
|
|
4970
|
+
*/
|
|
4971
|
+
entity: T;
|
|
4972
|
+
/**
|
|
4973
|
+
* The values that were changed by resetting the change set.
|
|
4974
|
+
*/
|
|
4975
|
+
changedValues: DeepPartial<T>;
|
|
4976
|
+
};
|
|
4977
|
+
/**
|
|
4978
|
+
* A base repository that automatically handles creation of change sets.
|
|
4979
|
+
*/
|
|
4980
|
+
declare class ChangeSetRepository<T extends ChangeSetEntity, CreateData extends DeepPartial<T> = DeepPartial<T>, UpdateData extends DeepPartial<T> = DeepPartial<T>> extends Repository<T, CreateData, UpdateData> {
|
|
4981
|
+
/**
|
|
4982
|
+
* Any keys that should be excluded from the change set.
|
|
4983
|
+
*/
|
|
4984
|
+
protected readonly keysToExcludeFromChangeSets: (keyof T)[];
|
|
4985
|
+
private get changeSetRepository();
|
|
4986
|
+
private get authService();
|
|
4987
|
+
constructor(entityClass: Newable<T>, repo: Repository$1<T> | Repository<T>);
|
|
4988
|
+
create(data: CreateData, options?: CreateOptions): Promise<T>;
|
|
4989
|
+
createAll(data: CreateData[], options?: CreateAllOptions): Promise<T[]>;
|
|
4990
|
+
updateById(id: T['id'], data: UpdateData, options?: UpdateByIdOptions): Promise<T>;
|
|
4991
|
+
updateAll(where: Where<T>, data: UpdateData, options?: UpdateAllOptions): Promise<T[]>;
|
|
4992
|
+
/**
|
|
4993
|
+
* Update an entity by id with property/value pairs in the data object.
|
|
4994
|
+
* @param id - Value for the entity id.
|
|
4995
|
+
* @param data - Data attributes to be updated.
|
|
4996
|
+
* @param options - Options for the operations.
|
|
4997
|
+
* @returns
|
|
4998
|
+
* A promise that will be resolve if the operation succeeded or will be rejected if the entity was not found.
|
|
4999
|
+
*/
|
|
5000
|
+
updateByIdWithoutChangeSet(id: T['id'], data: UpdateData, options?: UpdateByIdOptions): Promise<T>;
|
|
5001
|
+
/**
|
|
5002
|
+
* Updates all entities that match the provided where filter.
|
|
5003
|
+
* @param where - The where filter to find the entities that should be updated.
|
|
5004
|
+
* @param data - The data to update the entities with.
|
|
5005
|
+
* @param options - Additional options, like a transaction.
|
|
5006
|
+
* @returns An array of all the updated entities.
|
|
5007
|
+
*/
|
|
5008
|
+
updateAllWithoutChangeSet(where: Where<T>, data: UpdateData, options?: UpdateAllOptions): Promise<T[]>;
|
|
5009
|
+
/**
|
|
5010
|
+
* Resets the changes of a single change set on the given entity to the state before the change set.
|
|
5011
|
+
* This DOES preserve any changes that happened after the change set.
|
|
5012
|
+
* The given change set gets deleted afterwards.
|
|
5013
|
+
* @param entity - The entity that should be reset.
|
|
5014
|
+
* @param changeSetId - The id of the changeSet to reset.
|
|
5015
|
+
* @param createChangeSet - Whether or not a change set should be created.
|
|
5016
|
+
* @param preserveCreateChangeSet - Whether or not create change sets should be preserved.
|
|
5017
|
+
* In that case the entity gets reset to the state after the create change set. Also, the change set isn't deleted.
|
|
5018
|
+
* @param options - Additional options, eg. Transaction.
|
|
5019
|
+
* @returns The updated entity.
|
|
5020
|
+
*/
|
|
5021
|
+
resetSingleChangeSet(entity: T, changeSetId: string, createChangeSet?: boolean, preserveCreateChangeSet?: boolean, options?: BaseRepositoryOptions): Promise<ResetChangeSetResult<T>>;
|
|
5022
|
+
/**
|
|
5023
|
+
* Resets the changes of a single change set on the entity with the given id to the state before the oldest change set.
|
|
5024
|
+
* This DOES preserve any changes that happened after the change set.
|
|
5025
|
+
* The given change set gets deleted afterwards.
|
|
5026
|
+
* @param id - The id of the entity that should be reset.
|
|
5027
|
+
* @param changeSetId - The id of the changeSet to reset.
|
|
5028
|
+
* @param createChangeSet - Whether or not a change set should be created.
|
|
5029
|
+
* @param preserveCreateChangeSet - Whether or not create change sets should be preserved.
|
|
5030
|
+
* In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.
|
|
5031
|
+
* @param options - Additional options, eg. Transaction.
|
|
5032
|
+
* @returns The updated entity.
|
|
5033
|
+
*/
|
|
5034
|
+
resetSingleChangeSetById(id: T['id'], changeSetId: string, createChangeSet?: boolean, preserveCreateChangeSet?: boolean, options?: BaseRepositoryOptions): Promise<ResetChangeSetResult<T>>;
|
|
5035
|
+
/**
|
|
5036
|
+
* Rolls back all changes on the given entity that have happened since the given change set.
|
|
5037
|
+
* This DOES NOT preserve any changes that happened after the change set.
|
|
5038
|
+
* The given change set and any change sets after that will be deleted in the end.
|
|
5039
|
+
* Calls rollbackByDate on the change set date internally.
|
|
5040
|
+
* @param entity - The entity to rollback.
|
|
5041
|
+
* @param changeSetId - The id of the changeSet to rollback to.
|
|
5042
|
+
* @param createChangeSet - Whether or not a change set should be created.
|
|
5043
|
+
* @param preserveCreateChangeSet - Whether or not create change sets should be preserved.
|
|
5044
|
+
* In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.
|
|
5045
|
+
* @param options - Additional options, eg. Transaction.
|
|
5046
|
+
* @returns The updated entity.
|
|
5047
|
+
*/
|
|
5048
|
+
rollbackToChangeSet(entity: T, changeSetId: string, createChangeSet?: boolean, preserveCreateChangeSet?: boolean, options?: BaseRepositoryOptions): Promise<T>;
|
|
5049
|
+
/**
|
|
5050
|
+
* Rolls back all changes on the entity with the given id that have happened since the given change set.
|
|
5051
|
+
* This DOES NOT preserve any changes that happened after the change set.
|
|
5052
|
+
* The given change set and any change sets after that will be deleted in the end.
|
|
5053
|
+
* Calls rollbackByDate on the change set date internally.
|
|
5054
|
+
* @param id - The id of the entity to rollback.
|
|
5055
|
+
* @param changeSetId - The id of the changeSet to rollback to.
|
|
5056
|
+
* @param createChangeSet - Whether or not a change set should be created.
|
|
5057
|
+
* @param preserveCreateChangeSet - Whether or not create change sets should be preserved.
|
|
5058
|
+
* In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.
|
|
5059
|
+
* @param options - Additional options, eg. Transaction.
|
|
5060
|
+
* @returns The updated entity.
|
|
5061
|
+
*/
|
|
5062
|
+
rollbackToChangeSetById(id: T['id'], changeSetId: string, createChangeSet?: boolean, preserveCreateChangeSet?: boolean, options?: BaseRepositoryOptions): Promise<T>;
|
|
5063
|
+
/**
|
|
5064
|
+
* Rolls back all changes on the given entity that have happened since the given date.
|
|
5065
|
+
* This DOES NOT preserve any changes that happened after the date.
|
|
5066
|
+
* Any change sets after the given date will be deleted in the end.
|
|
5067
|
+
* @param entity - The entity to rollback.
|
|
5068
|
+
* @param date - The date to which the rollback should happen.
|
|
5069
|
+
* @param createChangeSet - Whether or not a change set should be created.
|
|
5070
|
+
* @param preserveCreateChangeSet - Whether or not create change sets should be preserved.
|
|
5071
|
+
* In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.
|
|
5072
|
+
* @param options - Additional options, eg. Transaction.
|
|
5073
|
+
* @returns The updated entity.
|
|
5074
|
+
*/
|
|
5075
|
+
rollbackToDate(entity: T, date: Date, createChangeSet?: boolean, preserveCreateChangeSet?: boolean, options?: BaseRepositoryOptions): Promise<T>;
|
|
5076
|
+
/**
|
|
5077
|
+
* Rolls back all changes on the entity with the given id that have happened since the given date.
|
|
5078
|
+
* This DOES NOT preserve any changes that happened after the date.
|
|
5079
|
+
* Any change sets after the given date will be deleted in the end.
|
|
5080
|
+
* @param id - The id of the entity to rollback.
|
|
5081
|
+
* @param date - The date to which the rollback should happen.
|
|
5082
|
+
* @param createChangeSet - Whether or not a change set should be created.
|
|
5083
|
+
* @param preserveCreateChangeSet - Whether or not create change sets should be preserved.
|
|
5084
|
+
* In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.
|
|
5085
|
+
* @param options - Additional options, eg. Transaction.
|
|
5086
|
+
* @returns The updated entity.
|
|
5087
|
+
*/
|
|
5088
|
+
rollbackToDateById(id: T['id'], date: Date, createChangeSet?: boolean, preserveCreateChangeSet?: boolean, options?: BaseRepositoryOptions): Promise<T>;
|
|
5089
|
+
/**
|
|
5090
|
+
* Rolls back all changes on the entities found with the given where filter to the state of the given date.
|
|
5091
|
+
* This DOES NOT preserve any changes that happened after the date.
|
|
5092
|
+
* Any change sets after the given date will be deleted in the end.
|
|
5093
|
+
* @param date - The date to which the rollback should happen.
|
|
5094
|
+
* @param where - A filter to only rollback some entities.
|
|
5095
|
+
* @param createChangeSet - Whether or not a change set should be created.
|
|
5096
|
+
* @param preserveCreateChangeSet - Whether or not create change sets should be preserved.
|
|
5097
|
+
* In that case the entity gets reset to the state after the create change set. Also, the create change set isn't deleted.
|
|
5098
|
+
* @param options - Additional options, eg. Transaction.
|
|
5099
|
+
* @returns The updated entity.
|
|
5100
|
+
*/
|
|
5101
|
+
rollbackAllToDate(date: Date, where?: Where<T>, createChangeSet?: boolean, preserveCreateChangeSet?: boolean, options?: BaseRepositoryOptions): Promise<number>;
|
|
5102
|
+
/**
|
|
5103
|
+
* Creates a change set for the related entity id.
|
|
5104
|
+
* Also generates the changes from the given data.
|
|
5105
|
+
* @param entityPriorChanges - The entity for which the change set gets created.
|
|
5106
|
+
* @param data - The data of the operation eg. The update body.
|
|
5107
|
+
* @param type - Whether the change set is for create, update or delete.
|
|
5108
|
+
* @param options - Additional options (e.g. Transaction etc.).
|
|
5109
|
+
* @param force - Whether or not the creation of a change set without changes should be forced.
|
|
5110
|
+
*/
|
|
5111
|
+
protected createChangeSet(entityPriorChanges: T, data: CreateData | UpdateData | DeepPartial<T>, type: ChangeSetType, options?: CreateOptions, force?: boolean): Promise<void>;
|
|
5112
|
+
/**
|
|
5113
|
+
* Creates all change sets for the related entities.
|
|
5114
|
+
* Also generates the changes from the given data.
|
|
5115
|
+
* @param entitiesPriorChanges - The entities to create the change sets for.
|
|
5116
|
+
* @param data - The data of the operation eg. The update bodies.
|
|
5117
|
+
* @param type - Whether the change set is for create, update or delete.
|
|
5118
|
+
* @param options - Additional options (e.g. Transaction etc.).
|
|
5119
|
+
* @param force - Whether or not the creation of a change set without changes should be forced.
|
|
5120
|
+
*/
|
|
5121
|
+
protected createAllChangeSets(entitiesPriorChanges: T[], data: (CreateData | UpdateData | DeepPartial<T>)[], type: ChangeSetType, options?: CreateOptions, force?: boolean): Promise<void>;
|
|
5122
|
+
/**
|
|
5123
|
+
* Get all changes from the given data that should be added to a new change set.
|
|
5124
|
+
* @param entityPriorChanges - The entity that has been changed.
|
|
5125
|
+
* @param data - The changed data.
|
|
5126
|
+
* @param type - The type of the change set to create.
|
|
5127
|
+
* @returns An array of changes for the change set.
|
|
5128
|
+
* Filtered by values that have actually changed and aren't in the "keysToExcludeFromChangeSets" array.
|
|
5129
|
+
*/
|
|
5130
|
+
protected getChangesFromData(entityPriorChanges: T, data: CreateData | UpdateData | DeepPartial<T>, type: ChangeSetType): NewChange[];
|
|
5131
|
+
/**
|
|
5132
|
+
* Tries to get a currently logged in user.
|
|
5133
|
+
* @returns The id of the currently logged in user or undefined if that didn't work.
|
|
5134
|
+
*/
|
|
5135
|
+
protected getCreatedBy(): Promise<string | undefined>;
|
|
5136
|
+
/**
|
|
5137
|
+
* Gets the keys of values that should be included in change sets.
|
|
5138
|
+
* @param data - The new values.
|
|
5139
|
+
* @returns The keys that should be included in the change set.
|
|
5140
|
+
*/
|
|
5141
|
+
protected getKeysToIncludeInChangeSet(data: CreateData | UpdateData | DeepPartial<T>): (keyof (CreateData | UpdateData | DeepPartial<T>))[];
|
|
5142
|
+
/**
|
|
5143
|
+
* Checks whether or not a value has actually changed.
|
|
5144
|
+
* This is used to determine whether or not a change should be created or not.
|
|
5145
|
+
* @param previousValue - The value before any changes.
|
|
5146
|
+
* @param newValue - The value after changes.
|
|
5147
|
+
* @returns Whether or not the given values are not equal.
|
|
5148
|
+
*/
|
|
5149
|
+
protected hasValueChanged(previousValue?: T[keyof T], newValue?: CreateData[keyof CreateData] | UpdateData[keyof UpdateData] | DeepPartial<T>[keyof DeepPartial<T>]): boolean;
|
|
5150
|
+
}
|
|
5151
|
+
|
|
5152
|
+
/**
|
|
5153
|
+
* Options for deleting a soft delete entity by its id.
|
|
5154
|
+
*/
|
|
5155
|
+
type SoftDeleteByIdOptions = DeleteByIdOptions & {
|
|
5156
|
+
/**
|
|
5157
|
+
* Whether or not to "actual" delete entities, rather than marking them as deleted.
|
|
5158
|
+
*/
|
|
5159
|
+
hardDelete?: boolean;
|
|
5160
|
+
};
|
|
5161
|
+
/**
|
|
5162
|
+
* Options for deleting multiple soft delete entities.
|
|
5163
|
+
*/
|
|
5164
|
+
type SoftDeleteAllOptions<T extends SoftDeleteEntity> = DeleteAllOptions<T> & {
|
|
5165
|
+
/**
|
|
5166
|
+
* Whether or not to "actual" delete entities, rather than marking them as deleted.
|
|
5167
|
+
*/
|
|
5168
|
+
hardDelete?: boolean;
|
|
5169
|
+
};
|
|
5170
|
+
/**
|
|
5171
|
+
* A base crud repository that automatically handles creation of change sets and offers the option to "soft" delete entities
|
|
5172
|
+
* (Meaning they are flagged as deleted but still kept for restoration).
|
|
5173
|
+
*/
|
|
5174
|
+
declare class SoftDeleteRepository<T extends SoftDeleteEntity, CreateData extends DeepPartial<T> = DeepPartial<T>, UpdateData extends DeepPartial<T> = DeepPartial<T>> extends ChangeSetRepository<T, CreateData, UpdateData> {
|
|
5175
|
+
protected readonly keysToExcludeFromChangeSets: (keyof T)[];
|
|
5176
|
+
constructor(entityClass: Newable<T>, repo: Repository$1<T> | Repository<T>);
|
|
5177
|
+
findAll(options?: SoftDeleteFindAllOptions<T>): Promise<T[]>;
|
|
5178
|
+
findOne<B extends boolean = true>(options: SoftDeleteFindOneOptions<T>, required?: B): Promise<B extends false ? T | undefined : T>;
|
|
5179
|
+
findById(id: T['id'], options?: SoftDeleteFindByIdOptions<T>): Promise<T>;
|
|
5180
|
+
findAllPaginated(page: number, limit: number, options?: SoftDeleteFindAllPaginatedOptions<T>): Promise<PaginationResult<T>>;
|
|
5181
|
+
updateAll(where: SoftDeleteWhere<T>, data: UpdateData, options?: SoftDeleteUpdateAllOptions): Promise<T[]>;
|
|
5182
|
+
updateById(id: T['id'], data: UpdateData, options?: SoftDeleteUpdateByIdOptions): Promise<T>;
|
|
5183
|
+
updateByIdWithoutChangeSet(id: T['id'], data: UpdateData, options?: SoftDeleteUpdateByIdOptions): Promise<T>;
|
|
5184
|
+
deleteById(id: T['id'], options?: SoftDeleteByIdOptions): Promise<void>;
|
|
5185
|
+
deleteAll(where: SoftDeleteWhere<T>, options?: SoftDeleteAllOptions<T> | undefined): Promise<T[]>;
|
|
5186
|
+
private softDeleteWhereToWhere;
|
|
5187
|
+
}
|
|
5188
|
+
|
|
4664
5189
|
/**
|
|
4665
5190
|
* Compares the given versions and check if the first one is bigger, equal or smaller than the second one.
|
|
4666
5191
|
* @param v1 - The first version.
|
|
@@ -4697,4 +5222,4 @@ type ChunkingOptions = {
|
|
|
4697
5222
|
*/
|
|
4698
5223
|
declare function chunkedPromiseAll<T>(promises: Promise<T>[], options?: ChunkingOptions): Promise<T[]>;
|
|
4699
5224
|
|
|
4700
|
-
export { type AppData, AppState, type ArrayParamMetadata, type ArrayParamMetadataInput, type ArrayPropertyItemMetadata, type ArrayPropertyItemMetadataInput, type ArrayPropertyMetadata, type ArrayPropertyMetadataInput, type ArrayWhereFilter, AssetService, type AssetServiceInterface, Auth, type AuthControllerInterface, AuthService, type AuthServiceInterface, type AuthStrategies, type AuthStrategyInterface, BadRequestError, BaseDataSource, type BaseEmailTemplateData, type BaseEmailTemplateDataInput,
|
|
5225
|
+
export { type AppData, AppState, type ArrayParamItemMetadata, type ArrayParamItemMetadataInput, type ArrayParamMetadata, type ArrayParamMetadataInput, type ArrayPropertyItemMetadata, type ArrayPropertyItemMetadataInput, type ArrayPropertyMetadata, type ArrayPropertyMetadataInput, type ArrayWhereFilter, AssetService, type AssetServiceInterface, Auth, type AuthControllerInterface, AuthService, type AuthServiceInterface, type AuthStrategies, type AuthStrategyInterface, BadRequestError, BaseDataSource, type BaseEmailTemplateData, type BaseEmailTemplateDataInput, BaseEntity, type BaseLoggerTransportConfig, type BaseMailingListEmailTemplateData, type BasePageTemplateData, type BasePageTemplateDataInput, type BaseRepositoryOptions, type BaseUser, BaseUserEntity, type BelongsToMetadata, type BelongsToOnePropertyMetadataInput, Body, type BodyMetadata, type BodyMetadataInput, BodyParser, type BodyParserInterface, type BooleanParamMetadata, type BooleanParamMetadataInput, type BooleanPropertyMetadata, type BooleanPropertyMetadataInput, type BooleanWhereFilter, CLEANUP_AT_FILE_NAME, Change, ChangeSet, type ChangeSetEntity, ChangeSetRepository, ChangeSetType, type ChunkingOptions, type ColumnType, CombinedType, Controller, type ControllerRouteConfiguration, type CounterInterface, type CounterMetricName, type CreateAllOptions, type CreateChangeData, type CreateChangeSetData, type CreateCronJobEntityData, CreateEmailData, type CreateOptions, type CronConfig, CronJob, CronJobEntity, CronService, type CronServiceInterface, type CronUpdateData, CurrentUser, type CurrentUserMetadata, DataSource, type DataSourceOptions, DataSourceService, type DataSourceServiceInterface, type DateParamMetadata, type DateParamMetadataInput, type DatePropertyMetadata, type DatePropertyMetadataInput, type DateWhereFilter, Delete, type DeleteAllOptions, type DeleteByIdOptions, type DiProvider, type DiToken, Email, EmailAttachment, type EmailConfig, type EmailConfigInput, EmailPriority, EmailService, type EmailServiceInterface, EmailStatus, type EncodedJwtAccessToken, Entity, type EntityMetadata, type ErrorOpenApiResponse, File, type FileExtension, type FileMimeType, type FileOpenApiResponse, type FilePropertyMetadata, type FilePropertyMetadataInput, FileResponse, type FileSize, type FindAllOptions, type FindAllPaginatedOptions, type FindByIdOptions, type FindOneOptions, FormData, type FormDataBodyMetadata, FormDataBodyParser, type FormDataValue, type FormatDateFn, type GaugeInterface, type GaugeMetricName, Get, type GlobalErrorHandler, GlobalRegistry, HandlebarUtilities, type HasOnePropertyMetadataInput, type HasRoleMetadata, HashUtilities, type Header, type HeaderParamMetadata, type HeaderParamMetadataInput, type HistogramInterface, type HistogramMetricName, type HtmlOpenApiResponse, HtmlResponse, HttpError, HttpMethod, type HttpRequest, type HttpResponse, HttpStatus, type InitialCronConfig, Inject, InjectRepository, Injectable, InternalServerError, type IsLoggedInMetadata, type IsNotLoggedInMetadata, IsRequiredValidationProblem, type JsonBodyMetadata, JsonBodyParser, type JsonOpenApiResponse, Jwt, type JwtAccessTokenPayload, JwtAuthController, JwtAuthData, JwtAuthStrategy, JwtConfirmPasswordResetData, JwtCredentials, JwtCredentialsCreateData, JwtCredentialsDto, JwtRefreshToken, JwtRefreshTokenCreateDto, type JwtRefreshTokenPayload, type JwtRequestPasswordResetData, JwtUtilities, KnownHeader, Log, LogLevel, LoggedError, Logger, type LoggerInterface, LoggerTransport, type LoggerTransportSend, type LooseFileMimeType, MailingList, type MailingListQueueEmailData, MailingListService, type MailingListServiceInterface, MailingListSubscriber, MailingListSubscriberCreateData, MailingListSubscriptionConfirmationToken, MailingListSubscriptionConfirmationTokenCreateData, type ManyToManyPropertyMetadata, type ManyToManyPropertyMetadataInput, type ManyToOnePropertyMetadata, type ManyToOnePropertyMetadataInput, MaxFileSizeValidationProblem, Metric, MetricType, type MetricsServiceInterface, type MetricsSnapshot, Migration, MigrationEntity, MimeType, MimeTypeMismatchValidationProblem, type MulterFile, NO_USER_REPOSITORIES_PROVIDED_ERROR_MESSAGE, type NewChange, type Newable, NotFoundError, type NumberParamMetadata, type NumberParamMetadataInput, type NumberPropertyMetadata, type NumberPropertyMetadataInput, type NumberWhereFilter, type ObjectParamMetadata, type ObjectParamMetadataInput, type ObjectPropertyMetadata, type ObjectPropertyMetadataInput, type ObjectWhereFilter, OmitType, type OneToManyPropertyMetadata, type OneToManyPropertyMetadataInput, type OneToOnePropertyMetadata, type OneToOnePropertyMetadataInput, type OpenApiDefinition, type OpenApiOperation, type OpenApiParameter, type OpenApiPaths, type OpenApiRequestBodyObject, type OpenApiResponse, type OpenApiRouteConfiguration, type OpenApiSchemaObject, type OpenApiSecurityRequirementObject, type OpenApiSecuritySchemeObject, OpenApiService, type OpenApiServiceInterface, type PaginationResult, Param, Parser, type ParserInterface, PartialType, PasswordResetToken, PasswordResetTokenCreateData, Patch, type PathParamMetadata, type PathParamMetadataInput, type PathTree, PickType, Post, PrometheusMetricsService, Property, type PropertyMetadata, type PropertyMetadataInput, type QueryParamMetadata, type QueryParamMetadataInput, QueueEmailData, RateLimiter, Relation, type RelationMetadata, type RelationMetadataInput, RelationsNotAllowedValidationProblem, Repository, type ResetChangeSetResult, Response, type Route, type RouteConfiguration, type RouteConfigurationInput, type RouteHandler, Router, type RouterInterface, type SkipAuthMetadata, type SkipBelongsToMetadata, type SkipHasRoleMetadata, type SkipIsLoggedInMetadata, type SkipIsNotLoggedInMetadata, type SoftDeleteAllOptions, type SoftDeleteByIdOptions, type SoftDeleteEntity, type SoftDeleteFindAllOptions, type SoftDeleteFindAllPaginatedOptions, type SoftDeleteFindByIdOptions, type SoftDeleteFindOneOptions, SoftDeleteRepository, type SoftDeleteUpdateAllOptions, type SoftDeleteUpdateByIdOptions, type SoftDeleteWhere, type SoftDeleteWhereFilter, type StringFormat, type StringParamMetadata, type StringParamMetadataInput, type StringPropertyMetadata, type StringPropertyMetadataInput, type StringWhereFilter, TooManyRequestsError, type Transaction, type TreeNode, TypeMismatchValidationProblem, UnauthorizedError, type UnknownPropertyMetadata, type UnknownPropertyMetadataInput, UnmatchedRouteError, type UpdateAllOptions, type UpdateByIdOptions, UpdateMailingListPreferences, UserRepo, type UserRepositories, type UserRepositoryInterface, UserService, type UserServiceInterface, ValidationError, type ValidationProblem, ValidationService, type ValidationServiceInterface, type Version, type Where, type WhereFilter, type WhereFilterProperty, ZIBRI_DI_TOKENS, ZibriApplication, type ZibriApplicationOptions, type ZibriPlugin, chunkedPromiseAll, compareVersion, createArrayItemPropertyMetadata, errorHandler, errorToLoggedError, fileSizeToBytes, generateHandlebarType, generateHandlebarTypeFiles, getCurrentRequest, inject, isBaseUser, isChangeSetEntityNewable, isHttpError, isMimeType, isSoftDeleteEntityNewable, isVersion, renderEmailTemplate, renderPageTemplate, renderTemplate, renderTemplateString, repositoryTokenFor, resolveFileExtension, resolveMimeType, runWithRequest };
|