@decaf-ts/db-decorators 0.4.30 → 0.4.33
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/LICENSE.md +0 -0
- package/README.md +32 -108
- package/dist/db-decorators.js +2 -0
- package/dist/{db-decorators.bundle.min.js.LICENSE.txt → db-decorators.js.LICENSE.txt} +0 -0
- package/dist/esm/db-decorators.js +2 -0
- package/dist/esm/{db-decorators.bundle.min.esm.js.LICENSE.txt → db-decorators.js.LICENSE.txt} +0 -0
- package/{lib/esm → dist/types}/identity/decorators.d.ts +0 -0
- package/{lib/esm → dist/types}/identity/index.d.ts +0 -0
- package/{lib/esm → dist/types}/identity/utils.d.ts +0 -0
- package/{lib/esm → dist/types}/index.d.ts +0 -0
- package/{lib/esm → dist/types}/interfaces/BulkCrudOperator.d.ts +0 -0
- package/{lib/esm → dist/types}/interfaces/Contextual.d.ts +0 -0
- package/{lib/esm → dist/types}/interfaces/CrudOperator.d.ts +0 -0
- package/{lib/esm → dist/types}/interfaces/IRepository.d.ts +0 -0
- package/{lib/esm → dist/types}/interfaces/index.d.ts +0 -0
- package/{lib/esm → dist/types}/model/constants.d.ts +0 -0
- package/{lib/esm → dist/types}/model/decorators.d.ts +0 -0
- package/{lib/esm → dist/types}/model/index.d.ts +0 -0
- package/{lib/esm → dist/types}/model/model.d.ts +0 -0
- package/{lib/esm → dist/types}/model/validation.d.ts +0 -0
- package/{lib/esm → dist/types}/operations/Operations.d.ts +0 -0
- package/{lib/esm → dist/types}/operations/OperationsRegistry.d.ts +0 -0
- package/{lib/esm → dist/types}/operations/constants.d.ts +0 -0
- package/{lib/esm → dist/types}/operations/decorators.d.ts +0 -0
- package/{lib/esm → dist/types}/operations/index.d.ts +0 -0
- package/{lib/esm → dist/types}/operations/types.d.ts +0 -0
- package/{lib/esm → dist/types}/repository/BaseRepository.d.ts +0 -0
- package/{lib/esm → dist/types}/repository/Context.d.ts +0 -0
- package/{lib/esm → dist/types}/repository/DataCache.d.ts +0 -0
- package/{lib/esm → dist/types}/repository/Repository.d.ts +0 -0
- package/{lib/esm → dist/types}/repository/errors.d.ts +0 -0
- package/{lib/esm → dist/types}/repository/index.d.ts +0 -0
- package/{lib/esm → dist/types}/repository/utils.d.ts +0 -0
- package/{lib/esm → dist/types}/repository/wrappers.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/constants.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/decorators.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/index.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/validation.d.ts +1 -1
- package/{lib/esm → dist/types}/validation/validators/ReadOnlyValidator.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/validators/TimestampValidator.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/validators/UpdateValidator.d.ts +0 -0
- package/{lib/esm → dist/types}/validation/validators/index.d.ts +0 -0
- package/lib/esm/identity/decorators.js +0 -0
- package/lib/esm/identity/index.js +0 -0
- package/lib/esm/identity/utils.js +0 -0
- package/lib/esm/index.js +0 -0
- package/lib/esm/interfaces/BulkCrudOperator.js +0 -0
- package/lib/esm/interfaces/Contextual.js +0 -0
- package/lib/esm/interfaces/CrudOperator.js +0 -0
- package/lib/esm/interfaces/IRepository.js +0 -0
- package/lib/esm/interfaces/index.js +0 -0
- package/lib/esm/model/constants.js +0 -0
- package/lib/esm/model/decorators.js +0 -0
- package/lib/esm/model/index.js +0 -0
- package/lib/esm/model/model.js +0 -0
- package/lib/esm/model/validation.js +0 -0
- package/lib/esm/operations/Operations.js +0 -0
- package/lib/esm/operations/OperationsRegistry.js +0 -0
- package/lib/esm/operations/constants.js +0 -0
- package/lib/esm/operations/decorators.js +0 -0
- package/lib/esm/operations/index.js +0 -0
- package/lib/esm/operations/types.js +0 -0
- package/lib/esm/repository/BaseRepository.js +0 -0
- package/lib/esm/repository/Context.js +0 -0
- package/lib/esm/repository/DataCache.js +0 -0
- package/lib/esm/repository/Repository.js +0 -0
- package/lib/esm/repository/errors.js +0 -0
- package/lib/esm/repository/index.js +0 -0
- package/lib/esm/repository/utils.js +0 -0
- package/lib/esm/repository/wrappers.js +0 -0
- package/lib/esm/validation/constants.js +0 -0
- package/lib/esm/validation/decorators.js +0 -0
- package/lib/esm/validation/index.js +0 -0
- package/lib/esm/validation/validation.js +1 -1
- package/lib/esm/validation/validators/ReadOnlyValidator.js +0 -0
- package/lib/esm/validation/validators/TimestampValidator.js +0 -0
- package/lib/esm/validation/validators/UpdateValidator.js +20 -0
- package/lib/esm/validation/validators/index.js +5 -0
- package/lib/identity/decorators.cjs +2 -0
- package/lib/identity/index.cjs +2 -0
- package/lib/identity/utils.cjs +2 -0
- package/lib/index.cjs +2 -0
- package/lib/interfaces/BulkCrudOperator.cjs +2 -0
- package/lib/interfaces/Contextual.cjs +2 -0
- package/lib/interfaces/CrudOperator.cjs +2 -0
- package/lib/interfaces/IRepository.cjs +2 -0
- package/lib/interfaces/index.cjs +2 -0
- package/lib/model/constants.cjs +2 -0
- package/lib/model/decorators.cjs +2 -0
- package/lib/model/index.cjs +2 -0
- package/lib/model/model.cjs +2 -0
- package/lib/model/validation.cjs +2 -0
- package/lib/operations/Operations.cjs +2 -0
- package/lib/operations/OperationsRegistry.cjs +2 -0
- package/lib/operations/constants.cjs +2 -0
- package/lib/operations/decorators.cjs +2 -0
- package/lib/operations/index.cjs +2 -0
- package/lib/operations/types.cjs +2 -0
- package/lib/repository/BaseRepository.cjs +2 -0
- package/lib/repository/Context.cjs +2 -0
- package/lib/repository/DataCache.cjs +2 -0
- package/lib/repository/Repository.cjs +2 -0
- package/lib/repository/errors.cjs +2 -0
- package/lib/repository/index.cjs +2 -0
- package/lib/repository/utils.cjs +2 -0
- package/lib/repository/wrappers.cjs +2 -0
- package/lib/validation/constants.cjs +2 -0
- package/lib/validation/decorators.cjs +2 -0
- package/lib/validation/index.cjs +2 -0
- package/lib/validation/validation.cjs +2 -0
- package/lib/validation/validators/ReadOnlyValidator.cjs +2 -0
- package/lib/validation/validators/TimestampValidator.cjs +2 -0
- package/lib/validation/validators/UpdateValidator.cjs +2 -0
- package/lib/validation/validators/index.cjs +2 -0
- package/package.json +27 -16
- package/dist/db-decorators.bundle.min.js +0 -2
- package/dist/esm/db-decorators.bundle.min.esm.js +0 -2
- package/lib/identity/decorators.d.ts +0 -1
- package/lib/identity/index.d.ts +0 -2
- package/lib/identity/utils.d.ts +0 -34
- package/lib/index.d.ts +0 -33
- package/lib/interfaces/BulkCrudOperator.d.ts +0 -7
- package/lib/interfaces/Contextual.d.ts +0 -6
- package/lib/interfaces/CrudOperator.d.ts +0 -42
- package/lib/interfaces/IRepository.d.ts +0 -11
- package/lib/interfaces/index.d.ts +0 -4
- package/lib/model/constants.d.ts +0 -37
- package/lib/model/decorators.d.ts +0 -50
- package/lib/model/index.d.ts +0 -4
- package/lib/model/model.d.ts +0 -112
- package/lib/model/validation.d.ts +0 -14
- package/lib/operations/Operations.d.ts +0 -19
- package/lib/operations/OperationsRegistry.d.ts +0 -34
- package/lib/operations/constants.d.ts +0 -24
- package/lib/operations/decorators.d.ts +0 -193
- package/lib/operations/index.d.ts +0 -5
- package/lib/operations/types.d.ts +0 -29
- package/lib/repository/BaseRepository.d.ts +0 -36
- package/lib/repository/Context.d.ts +0 -17
- package/lib/repository/DataCache.d.ts +0 -9
- package/lib/repository/Repository.d.ts +0 -10
- package/lib/repository/errors.d.ts +0 -69
- package/lib/repository/index.d.ts +0 -7
- package/lib/repository/utils.d.ts +0 -62
- package/lib/repository/wrappers.d.ts +0 -38
- package/lib/validation/constants.d.ts +0 -30
- package/lib/validation/decorators.d.ts +0 -58
- package/lib/validation/index.d.ts +0 -4
- package/lib/validation/validation.d.ts +0 -41
- package/lib/validation/validators/ReadOnlyValidator.d.ts +0 -23
- package/lib/validation/validators/TimestampValidator.d.ts +0 -14
- package/lib/validation/validators/UpdateValidator.d.ts +0 -23
- package/lib/validation/validators/index.d.ts +0 -3
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { IRepository } from "../interfaces/IRepository";
|
|
2
|
-
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
|
3
|
-
import { Context } from "./Context";
|
|
4
|
-
export declare abstract class BaseRepository<M extends Model> implements IRepository<M> {
|
|
5
|
-
private readonly _class;
|
|
6
|
-
private _pk;
|
|
7
|
-
get class(): Constructor<M>;
|
|
8
|
-
get pk(): string;
|
|
9
|
-
protected constructor(clazz?: Constructor<M>);
|
|
10
|
-
abstract create(model: M, ...args: any[]): Promise<M>;
|
|
11
|
-
createAll(models: M[], ...args: any[]): Promise<M[]>;
|
|
12
|
-
protected createPrefix(model: M, ...args: any[]): Promise<any[]>;
|
|
13
|
-
protected createSuffix(model: M, context: Context<M>): Promise<M>;
|
|
14
|
-
protected createAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
|
|
15
|
-
protected createAllSuffix(models: M[], context: Context<M>): Promise<M[]>;
|
|
16
|
-
abstract read(key: string | number, ...args: any[]): Promise<M>;
|
|
17
|
-
readAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
|
|
18
|
-
protected readSuffix(model: M, context: Context<M>): Promise<M>;
|
|
19
|
-
protected readPrefix(key: string, ...args: any[]): Promise<any[]>;
|
|
20
|
-
protected readAllPrefix(keys: string[] | number[], ...args: any[]): Promise<any[]>;
|
|
21
|
-
protected readAllSuffix(models: M[], context: Context<M>): Promise<M[]>;
|
|
22
|
-
abstract update(model: M, ...args: any[]): Promise<M>;
|
|
23
|
-
updateAll(models: M[], ...args: any): Promise<M[]>;
|
|
24
|
-
protected updateSuffix(model: M, context: Context<M>): Promise<M>;
|
|
25
|
-
protected updatePrefix(model: M, ...args: any[]): Promise<any[]>;
|
|
26
|
-
protected updateAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
|
|
27
|
-
protected updateAllSuffix(models: M[], context: Context<M>): Promise<M[]>;
|
|
28
|
-
abstract delete(key: string | number, ...args: any[]): Promise<M>;
|
|
29
|
-
deleteAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
|
|
30
|
-
protected deleteSuffix(model: M, context: Context<M>): Promise<M>;
|
|
31
|
-
protected deletePrefix(key: any, ...args: any[]): Promise<any[]>;
|
|
32
|
-
protected deleteAllPrefix(keys: string[] | number[], ...args: any[]): Promise<any[]>;
|
|
33
|
-
protected deleteAllSuffix(models: M[], context: Context<M>): Promise<M[]>;
|
|
34
|
-
protected merge(oldModel: M, model: M): M;
|
|
35
|
-
toString(): string;
|
|
36
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DataCache } from "./DataCache";
|
|
2
|
-
import { ContextArgs } from "./utils";
|
|
3
|
-
import { Contextual } from "../interfaces/Contextual";
|
|
4
|
-
import { OperationKeys } from "../operations/constants";
|
|
5
|
-
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
|
6
|
-
export declare class Context<M extends Model> extends DataCache {
|
|
7
|
-
protected operation: OperationKeys;
|
|
8
|
-
protected model?: Constructor<M> | undefined;
|
|
9
|
-
protected parent?: Context<any> | undefined;
|
|
10
|
-
protected constructor(operation: OperationKeys, model?: Constructor<M> | undefined, parent?: Context<any> | undefined);
|
|
11
|
-
get timestamp(): Date;
|
|
12
|
-
get(key: string): Promise<any>;
|
|
13
|
-
pop(key: string): Promise<any>;
|
|
14
|
-
child<N extends Model>(operation: OperationKeys, model?: Constructor<N>): Context<N>;
|
|
15
|
-
static from<M extends Model, C extends Context<M>>(operation: OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE, model: Constructor<M>, ...args: any[]): Promise<C>;
|
|
16
|
-
static args<M extends Model>(operation: OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE, model: Constructor<M>, args: any[], contextual?: Contextual<M>): Promise<ContextArgs<M>>;
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class DataCache {
|
|
2
|
-
protected cache: Record<string, any>;
|
|
3
|
-
get(key: string): Promise<any>;
|
|
4
|
-
push(key: string, value: any): Promise<void>;
|
|
5
|
-
put(key: string, value: any): Promise<void>;
|
|
6
|
-
pop(key: string): Promise<any>;
|
|
7
|
-
filter(filter: string | RegExp): Promise<any[]>;
|
|
8
|
-
purge(key?: string): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseRepository } from "./BaseRepository";
|
|
2
|
-
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
|
3
|
-
export declare abstract class Repository<M extends Model> extends BaseRepository<M> {
|
|
4
|
-
protected constructor(clazz?: Constructor<M>);
|
|
5
|
-
protected createPrefix(model: M, ...args: any[]): Promise<[M, ...any[]]>;
|
|
6
|
-
protected createAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
|
|
7
|
-
protected updatePrefix(model: M, ...args: any[]): Promise<[M, ...args: any[]]>;
|
|
8
|
-
protected updateAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
|
|
9
|
-
static key(key: string): string;
|
|
10
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @summary Base Error
|
|
3
|
-
*
|
|
4
|
-
* @param {string} msg the error message
|
|
5
|
-
*
|
|
6
|
-
* @class BaseDLTError
|
|
7
|
-
* @extends Error
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class BaseError extends Error {
|
|
10
|
-
protected constructor(name: string, msg: string | Error);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @summary Represents a failure in the Model details
|
|
14
|
-
*
|
|
15
|
-
* @param {string} msg the error message
|
|
16
|
-
*
|
|
17
|
-
* @class ValidationError
|
|
18
|
-
* @extends BaseError
|
|
19
|
-
*/
|
|
20
|
-
export declare class ValidationError extends BaseError {
|
|
21
|
-
constructor(msg: string | Error);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* @summary Represents an internal failure (should mean an error in code)
|
|
25
|
-
*
|
|
26
|
-
* @param {string} msg the error message
|
|
27
|
-
*
|
|
28
|
-
* @class InternalError
|
|
29
|
-
* @extends BaseError
|
|
30
|
-
*/
|
|
31
|
-
export declare class InternalError extends BaseError {
|
|
32
|
-
constructor(msg: string | Error);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @summary Represents a failure in the Model de/serialization
|
|
36
|
-
*
|
|
37
|
-
* @param {string} msg the error message
|
|
38
|
-
*
|
|
39
|
-
* @class SerializationError
|
|
40
|
-
* @extends BaseError
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
export declare class SerializationError extends BaseError {
|
|
44
|
-
constructor(msg: string | Error);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @summary Represents a failure in finding a model
|
|
48
|
-
*
|
|
49
|
-
* @param {string} msg the error message
|
|
50
|
-
*
|
|
51
|
-
* @class NotFoundError
|
|
52
|
-
* @extends BaseError
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
export declare class NotFoundError extends BaseError {
|
|
56
|
-
constructor(msg: string | Error);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* @summary Represents a conflict in the storage
|
|
60
|
-
*
|
|
61
|
-
* @param {string} msg the error message
|
|
62
|
-
*
|
|
63
|
-
* @class ConflictError
|
|
64
|
-
* @extends BaseError
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
export declare class ConflictError extends BaseError {
|
|
68
|
-
constructor(msg: string | Error);
|
|
69
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { IRepository } from "../interfaces/IRepository";
|
|
2
|
-
import { DecoratorMetadata } from "@decaf-ts/reflection";
|
|
3
|
-
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
|
4
|
-
import { Context } from "./Context";
|
|
5
|
-
export type ContextArgs<M extends Model> = {
|
|
6
|
-
context: Context<M>;
|
|
7
|
-
args: any[];
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* @summary retrieves the arguments for the handler
|
|
11
|
-
* @param {any} dec the decorator
|
|
12
|
-
* @param {string} prop the property name
|
|
13
|
-
* @param {{}} m the model
|
|
14
|
-
* @param {{}} [accum] accumulator used for internal recursiveness
|
|
15
|
-
*
|
|
16
|
-
* @function getHandlerArgs
|
|
17
|
-
* @memberOf module:db-decorators.Repository
|
|
18
|
-
*/
|
|
19
|
-
export declare const getHandlerArgs: (dec: any, prop: string, m: Constructor<any>, accum?: Record<string, {
|
|
20
|
-
args: string[];
|
|
21
|
-
}>) => Record<string, {
|
|
22
|
-
args: string[];
|
|
23
|
-
}> | void;
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {IRepository<T>} repo
|
|
27
|
-
* @param context
|
|
28
|
-
* @param {T} model
|
|
29
|
-
* @param operation
|
|
30
|
-
* @param prefix
|
|
31
|
-
*
|
|
32
|
-
* @param oldModel
|
|
33
|
-
* @function enforceDBPropertyDecoratorsAsync
|
|
34
|
-
*
|
|
35
|
-
* @memberOf db-decorators.utils
|
|
36
|
-
*/
|
|
37
|
-
export declare function enforceDBDecorators<M extends Model, Y extends IRepository<M>, V>(repo: Y, context: Context<M>, model: M, operation: string, prefix: string, oldModel?: M): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Specific for DB Decorators
|
|
40
|
-
* @param {T} model
|
|
41
|
-
* @param {string} operation CRUD {@link OperationKeys}
|
|
42
|
-
* @param {string} [extraPrefix]
|
|
43
|
-
*
|
|
44
|
-
* @function getDbPropertyDecorators
|
|
45
|
-
*
|
|
46
|
-
* @memberOf db-decorators.utils
|
|
47
|
-
*/
|
|
48
|
-
export declare function getDbDecorators<T extends Model>(model: T, operation: string, extraPrefix?: string): Record<string, DecoratorMetadata[]> | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* @summary Retrieves the decorators for an object's properties prefixed by {@param prefixes} recursively
|
|
51
|
-
* @param model
|
|
52
|
-
* @param accum
|
|
53
|
-
* @param prefixes
|
|
54
|
-
*
|
|
55
|
-
* @function getAllPropertyDecoratorsRecursive
|
|
56
|
-
* @memberOf module:db-decorators.Repository
|
|
57
|
-
*/
|
|
58
|
-
export declare const getAllPropertyDecoratorsRecursive: <T extends Model>(model: T, accum: {
|
|
59
|
-
[indexer: string]: any[];
|
|
60
|
-
} | undefined, ...prefixes: string[]) => {
|
|
61
|
-
[indexer: string]: any[];
|
|
62
|
-
} | undefined;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @summary Util method to change a method of an object prefixing it with another
|
|
3
|
-
* @param {any} obj The Base Object
|
|
4
|
-
* @param {Function} after The original method
|
|
5
|
-
* @param {Function} prefix The Prefix method. The output will be used as arguments in the original method
|
|
6
|
-
* @param {string} [afterName] When the after function anme cannot be extracted, pass it here
|
|
7
|
-
*
|
|
8
|
-
* @function prefixMethod
|
|
9
|
-
*
|
|
10
|
-
* @memberOf module:db-decorators.Repository
|
|
11
|
-
*/
|
|
12
|
-
export declare function prefixMethod(obj: any, after: (...args: any[]) => any, prefix: (...args: any[]) => any, afterName?: string): void;
|
|
13
|
-
/**
|
|
14
|
-
* @summary Util method to change a method of an object suffixing it with another
|
|
15
|
-
* @param {any} obj The Base Object
|
|
16
|
-
* @param {Function} before The original method
|
|
17
|
-
* @param {Function} suffix The Prefix method. The output will be used as arguments in the original method
|
|
18
|
-
* @param {string} [beforeName] When the after function anme cannot be extracted, pass it here
|
|
19
|
-
*
|
|
20
|
-
* @function suffixMethod
|
|
21
|
-
*
|
|
22
|
-
* @memberOf module:db-decorators.Repository
|
|
23
|
-
*/
|
|
24
|
-
export declare function suffixMethod(obj: any, before: (...args: any[]) => any, suffix: (...args: any[]) => any, beforeName?: string): void;
|
|
25
|
-
/**
|
|
26
|
-
* @summary Util method to wrap a method of an object with additional logic
|
|
27
|
-
*
|
|
28
|
-
* @param {any} obj The Base Object
|
|
29
|
-
* @param {Function} before the method to be prefixed
|
|
30
|
-
* @param {Function} method the method to be wrapped
|
|
31
|
-
* @param {Function} after The method to be suffixed
|
|
32
|
-
* @param {string} [methodName] When the after function anme cannot be extracted, pass it here
|
|
33
|
-
*
|
|
34
|
-
* @function wrapMethodWithContext
|
|
35
|
-
*
|
|
36
|
-
* @memberOf module:db-decorators.Repository
|
|
37
|
-
*/
|
|
38
|
-
export declare function wrapMethodWithContext(obj: any, before: (...args: any[]) => any, method: (...args: any[]) => any, after: (...args: any[]) => any, methodName?: string): void;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @summary holds the default error messages
|
|
3
|
-
* @const DEFAULT_ERROR_MESSAGES
|
|
4
|
-
*
|
|
5
|
-
* @memberOf module:db-decorators.Model
|
|
6
|
-
*/
|
|
7
|
-
export declare const DEFAULT_ERROR_MESSAGES: {
|
|
8
|
-
ID: {
|
|
9
|
-
INVALID: string;
|
|
10
|
-
REQUIRED: string;
|
|
11
|
-
};
|
|
12
|
-
READONLY: {
|
|
13
|
-
INVALID: string;
|
|
14
|
-
};
|
|
15
|
-
TIMESTAMP: {
|
|
16
|
-
REQUIRED: string;
|
|
17
|
-
DATE: string;
|
|
18
|
-
INVALID: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* @summary Update reflection keys
|
|
23
|
-
* @const UpdateValidationKeys
|
|
24
|
-
* @memberOf module:db-decorators.Operations
|
|
25
|
-
*/
|
|
26
|
-
export declare const UpdateValidationKeys: {
|
|
27
|
-
REFLECT: string;
|
|
28
|
-
TIMESTAMP: string;
|
|
29
|
-
READONLY: string;
|
|
30
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
-
import { OperationKeys } from "../operations/constants";
|
|
3
|
-
import { IRepository } from "../interfaces/IRepository";
|
|
4
|
-
import { Context } from "../repository/Context";
|
|
5
|
-
/**
|
|
6
|
-
* Marks the property as readonly.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES.READONLY.INVALID}
|
|
9
|
-
*
|
|
10
|
-
* @decorator readonly
|
|
11
|
-
*
|
|
12
|
-
* @category Decorators
|
|
13
|
-
*/
|
|
14
|
-
export declare function readonly(message?: string): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
|
|
15
|
-
export declare function timestampHandler<M extends Model, V extends IRepository<M>, Y = any>(this: V, context: Context<M>, data: Y, key: string, model: M): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Marks the property as timestamp.
|
|
18
|
-
* Makes it {@link required}
|
|
19
|
-
* Makes it a {@link date}
|
|
20
|
-
*
|
|
21
|
-
* Date Format:
|
|
22
|
-
*
|
|
23
|
-
* <pre>
|
|
24
|
-
* Using similar formatting as Moment.js, Class DateTimeFormatter (Java), and Class SimpleDateFormat (Java),
|
|
25
|
-
* I implemented a comprehensive solution formatDate(date, patternStr) where the code is easy to read and modify.
|
|
26
|
-
* You can display date, time, AM/PM, etc.
|
|
27
|
-
*
|
|
28
|
-
* Date and Time Patterns
|
|
29
|
-
* yy = 2-digit year; yyyy = full year
|
|
30
|
-
* M = digit month; MM = 2-digit month; MMM = short month name; MMMM = full month name
|
|
31
|
-
* EEEE = full weekday name; EEE = short weekday name
|
|
32
|
-
* d = digit day; dd = 2-digit day
|
|
33
|
-
* h = hours am/pm; hh = 2-digit hours am/pm; H = hours; HH = 2-digit hours
|
|
34
|
-
* m = minutes; mm = 2-digit minutes; aaa = AM/PM
|
|
35
|
-
* s = seconds; ss = 2-digit seconds
|
|
36
|
-
* S = miliseconds
|
|
37
|
-
* </pre>
|
|
38
|
-
*
|
|
39
|
-
* @param {string[]} operation The {@link DBOperations} to act on. Defaults to {@link DBOperations.CREATE_UPDATE}
|
|
40
|
-
* @param {string} [format] The TimeStamp format. defaults to {@link DEFAULT_TIMESTAMP_FORMAT}
|
|
41
|
-
* @param {{new: UpdateValidator}} [validator] defaults to {@link TimestampValidator}
|
|
42
|
-
*
|
|
43
|
-
* @decorator timestamp
|
|
44
|
-
*
|
|
45
|
-
* @category Decorators
|
|
46
|
-
*/
|
|
47
|
-
export declare function timestamp(operation?: OperationKeys[], format?: string): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
|
|
48
|
-
export declare function serializeOnCreateUpdate<T extends Model, V extends IRepository<T>, Y = any>(this: V, data: Y, key: string, model: T, oldModel: T): Promise<void>;
|
|
49
|
-
export declare function serializeAfterAll<T extends Model, V extends IRepository<T>, Y = any>(this: V, data: Y, key: string, model: T): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* @summary Serialize Decorator
|
|
52
|
-
* @description properties decorated will the serialized before stored in the db
|
|
53
|
-
*
|
|
54
|
-
* @function serialize
|
|
55
|
-
*
|
|
56
|
-
* @memberOf module:wallet-db.Decorators
|
|
57
|
-
*/
|
|
58
|
-
export declare function serialize(): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Validator, IValidatorRegistry, ValidatorDefinition } from "@decaf-ts/decorator-validation";
|
|
2
|
-
declare module "@decaf-ts/decorator-validation" {
|
|
3
|
-
class Validation {
|
|
4
|
-
private static actingValidatorRegistry?;
|
|
5
|
-
private constructor();
|
|
6
|
-
/**
|
|
7
|
-
* @summary Defines the acting ValidatorRegistry
|
|
8
|
-
*
|
|
9
|
-
* @param {IValidatorRegistry} validatorRegistry the new implementation of the validator Registry
|
|
10
|
-
* @param {function(Validator): Validator} [migrationHandler] the method to map the validator if required;
|
|
11
|
-
*/
|
|
12
|
-
static setRegistry(validatorRegistry: IValidatorRegistry<Validator>, migrationHandler?: (validator: Validator) => Validator): void;
|
|
13
|
-
/**
|
|
14
|
-
* @summary Returns the current ValidatorRegistry
|
|
15
|
-
*
|
|
16
|
-
* @return IValidatorRegistry, defaults to {@link ValidatorRegistry}
|
|
17
|
-
*/
|
|
18
|
-
private static getRegistry;
|
|
19
|
-
/**
|
|
20
|
-
* @summary Retrieves a validator
|
|
21
|
-
*
|
|
22
|
-
* @param {string} validatorKey one of the {@link ValidationKeys}
|
|
23
|
-
* @return {Validator | undefined} the registered Validator or undefined if there is nono matching the provided key
|
|
24
|
-
*/
|
|
25
|
-
static get<T extends Validator>(validatorKey: string): T | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* @summary Registers the provided validators onto the registry
|
|
28
|
-
*
|
|
29
|
-
* @param {T[] | ValidatorDefinition[]} validator
|
|
30
|
-
*/
|
|
31
|
-
static register<T extends Validator>(...validator: (ValidatorDefinition | T)[]): void;
|
|
32
|
-
/**
|
|
33
|
-
* @summary Builds the key to store as Metadata under Reflections
|
|
34
|
-
* @description concatenates {@link ValidationKeys#REFLECT} with the provided key
|
|
35
|
-
*
|
|
36
|
-
* @param {string} key
|
|
37
|
-
*/
|
|
38
|
-
static key(key: string): string;
|
|
39
|
-
static updateKey(key: string): string;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Validator } from "@decaf-ts/decorator-validation";
|
|
2
|
-
/**
|
|
3
|
-
* @summary Validator for the {@link readonly} decorator
|
|
4
|
-
*
|
|
5
|
-
* @class ReadOnlyValidator
|
|
6
|
-
* @extends Validator
|
|
7
|
-
*
|
|
8
|
-
* @category Validators
|
|
9
|
-
*/
|
|
10
|
-
export declare class ReadOnlyValidator extends Validator {
|
|
11
|
-
constructor();
|
|
12
|
-
/**
|
|
13
|
-
* @inheritDoc
|
|
14
|
-
*/
|
|
15
|
-
hasErrors(value: any, ...args: any[]): string | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* @summary Validates a value has not changed
|
|
18
|
-
* @param {any} value
|
|
19
|
-
* @param {any} oldValue
|
|
20
|
-
* @param {string} [message] the error message override
|
|
21
|
-
*/
|
|
22
|
-
updateHasErrors(value: any, oldValue: any, message?: string): string | undefined;
|
|
23
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Validator } from "@decaf-ts/decorator-validation";
|
|
2
|
-
/**
|
|
3
|
-
* @summary Validates the update of a timestamp
|
|
4
|
-
*
|
|
5
|
-
* @class TimestampValidator
|
|
6
|
-
* @extends Validator
|
|
7
|
-
*
|
|
8
|
-
* @category Validators
|
|
9
|
-
*/
|
|
10
|
-
export declare class TimestampValidator extends Validator {
|
|
11
|
-
constructor();
|
|
12
|
-
hasErrors(value: any, ...args: any[]): string | undefined;
|
|
13
|
-
updateHasErrors(value: Date | string | number, oldValue: Date | string | number, message?: string): string | undefined;
|
|
14
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Validator } from "@decaf-ts/decorator-validation";
|
|
2
|
-
/**
|
|
3
|
-
* @summary Base class for an Update validator
|
|
4
|
-
*
|
|
5
|
-
* @param {string} [message] error message. defaults to {@link DecoratorMessages#DEFAULT}
|
|
6
|
-
* @param {string[]} [acceptedTypes] the accepted value types by the decorator
|
|
7
|
-
*
|
|
8
|
-
* @class UpdateValidator
|
|
9
|
-
* @abstract
|
|
10
|
-
* @extends Validator
|
|
11
|
-
*
|
|
12
|
-
* @category Validators
|
|
13
|
-
*/
|
|
14
|
-
export declare abstract class UpdateValidator extends Validator {
|
|
15
|
-
protected constructor(message?: string, ...acceptedTypes: string[]);
|
|
16
|
-
/**
|
|
17
|
-
* @summary validates a value by comparing to its old version
|
|
18
|
-
* @param {any} value
|
|
19
|
-
* @param {any} oldValue
|
|
20
|
-
* @param {any[]} args
|
|
21
|
-
*/
|
|
22
|
-
abstract updateHasErrors(value: any, oldValue: any, ...args: any[]): string | undefined;
|
|
23
|
-
}
|