@decaf-ts/db-decorators 0.12.0 → 0.14.0
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/lib/cjs/identity/decorators.cjs +5 -4
- package/lib/cjs/identity/decorators.cjs.map +1 -0
- package/lib/cjs/identity/index.cjs +1 -0
- package/lib/cjs/identity/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +2 -1
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/interfaces/BulkCrudOperator.cjs +1 -0
- package/lib/cjs/interfaces/BulkCrudOperator.cjs.map +1 -0
- package/lib/cjs/interfaces/Contextual.cjs +1 -0
- package/lib/cjs/interfaces/Contextual.cjs.map +1 -0
- package/lib/cjs/interfaces/CrudOperator.cjs +1 -0
- package/lib/cjs/interfaces/CrudOperator.cjs.map +1 -0
- package/lib/cjs/interfaces/IRepository.cjs +1 -0
- package/lib/cjs/interfaces/IRepository.cjs.map +1 -0
- package/lib/cjs/interfaces/index.cjs +1 -0
- package/lib/cjs/interfaces/index.cjs.map +1 -0
- package/lib/cjs/model/constants.cjs +1 -0
- package/lib/cjs/model/constants.cjs.map +1 -0
- package/lib/cjs/model/decorators.cjs +25 -24
- package/lib/cjs/model/decorators.cjs.map +1 -0
- package/lib/cjs/model/index.cjs +1 -0
- package/lib/cjs/model/index.cjs.map +1 -0
- package/lib/cjs/model/model.cjs +1 -0
- package/lib/cjs/model/model.cjs.map +1 -0
- package/lib/cjs/model/validation.cjs +1 -0
- package/lib/cjs/model/validation.cjs.map +1 -0
- package/lib/cjs/operations/Operations.cjs +6 -5
- package/lib/cjs/operations/Operations.cjs.map +1 -0
- package/lib/cjs/operations/OperationsRegistry.cjs +1 -0
- package/lib/cjs/operations/OperationsRegistry.cjs.map +1 -0
- package/lib/cjs/operations/constants.cjs +15 -39
- package/lib/cjs/operations/constants.cjs.map +1 -0
- package/lib/cjs/operations/decorators.cjs +42 -41
- package/lib/cjs/operations/decorators.cjs.map +1 -0
- package/lib/cjs/operations/index.cjs +1 -0
- package/lib/cjs/operations/index.cjs.map +1 -0
- package/lib/cjs/operations/types.cjs +1 -0
- package/lib/cjs/operations/types.cjs.map +1 -0
- package/lib/cjs/overrides/Metadata.cjs +1 -0
- package/lib/cjs/overrides/Metadata.cjs.map +1 -0
- package/lib/cjs/overrides/Model.cjs +1 -0
- package/lib/cjs/overrides/Model.cjs.map +1 -0
- package/lib/cjs/overrides/ModelBuilderExtensions.cjs +8 -7
- package/lib/cjs/overrides/ModelBuilderExtensions.cjs.map +1 -0
- package/lib/cjs/overrides/index.cjs +1 -0
- package/lib/cjs/overrides/index.cjs.map +1 -0
- package/lib/cjs/overrides/overrides.cjs +21 -20
- package/lib/cjs/overrides/overrides.cjs.map +1 -0
- package/lib/cjs/repository/Context.cjs +3 -2
- package/lib/cjs/repository/Context.cjs.map +1 -0
- package/lib/cjs/repository/Repository.cjs +42 -41
- package/lib/cjs/repository/Repository.cjs.map +1 -0
- package/lib/cjs/repository/constants.cjs +1 -0
- package/lib/cjs/repository/constants.cjs.map +1 -0
- package/lib/cjs/repository/errors.cjs +1 -0
- package/lib/cjs/repository/errors.cjs.map +1 -0
- package/lib/cjs/repository/index.cjs +1 -0
- package/lib/cjs/repository/index.cjs.map +1 -0
- package/lib/cjs/repository/types.cjs +1 -0
- package/lib/cjs/repository/types.cjs.map +1 -0
- package/lib/cjs/repository/utils.cjs +10 -9
- package/lib/cjs/repository/utils.cjs.map +1 -0
- package/lib/cjs/repository/wrappers.cjs +8 -7
- package/lib/cjs/repository/wrappers.cjs.map +1 -0
- package/lib/cjs/validation/constants.cjs +4 -3
- package/lib/cjs/validation/constants.cjs.map +1 -0
- package/lib/cjs/validation/decorators.cjs +22 -21
- package/lib/cjs/validation/decorators.cjs.map +1 -0
- package/lib/cjs/validation/index.cjs +1 -0
- package/lib/cjs/validation/index.cjs.map +1 -0
- package/lib/cjs/validation/validation.cjs +3 -2
- package/lib/cjs/validation/validation.cjs.map +1 -0
- package/lib/cjs/validation/validators/ReadOnlyValidator.cjs +14 -8
- package/lib/cjs/validation/validators/ReadOnlyValidator.cjs.map +1 -0
- package/lib/cjs/validation/validators/TimestampValidator.cjs +14 -8
- package/lib/cjs/validation/validators/TimestampValidator.cjs.map +1 -0
- package/lib/cjs/validation/validators/UpdateValidator.cjs +1 -0
- package/lib/cjs/validation/validators/UpdateValidator.cjs.map +1 -0
- package/lib/cjs/validation/validators/index.cjs +1 -0
- package/lib/cjs/validation/validators/index.cjs.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/identity/decorators.d.cts +8 -0
- package/lib/types/identity/decorators.d.mts +8 -0
- package/lib/types/identity/index.d.cts +6 -0
- package/lib/types/identity/index.d.mts +6 -0
- package/lib/types/index.d.cts +15 -0
- package/lib/types/index.d.mts +15 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/interfaces/BulkCrudOperator.d.cts +47 -0
- package/lib/types/interfaces/BulkCrudOperator.d.mts +47 -0
- package/lib/types/interfaces/Contextual.d.cts +23 -0
- package/lib/types/interfaces/Contextual.d.mts +23 -0
- package/lib/types/interfaces/CrudOperator.d.cts +46 -0
- package/lib/types/interfaces/CrudOperator.d.mts +46 -0
- package/lib/types/interfaces/IRepository.d.cts +19 -0
- package/lib/types/interfaces/IRepository.d.mts +19 -0
- package/lib/types/interfaces/index.d.cts +9 -0
- package/lib/types/interfaces/index.d.mts +9 -0
- package/lib/types/model/constants.d.cts +37 -0
- package/lib/types/model/constants.d.mts +37 -0
- package/lib/types/model/decorators.d.cts +145 -0
- package/lib/types/model/decorators.d.mts +145 -0
- package/lib/types/model/index.d.cts +9 -0
- package/lib/types/model/index.d.mts +9 -0
- package/lib/types/model/model.d.cts +6 -0
- package/lib/types/model/model.d.mts +6 -0
- package/lib/types/model/validation.d.cts +57 -0
- package/lib/types/model/validation.d.mts +57 -0
- package/lib/types/operations/Operations.d.cts +80 -0
- package/lib/types/operations/Operations.d.mts +80 -0
- package/lib/types/operations/OperationsRegistry.d.cts +72 -0
- package/lib/types/operations/OperationsRegistry.d.mts +72 -0
- package/lib/types/operations/constants.d.cts +106 -0
- package/lib/types/operations/constants.d.mts +106 -0
- package/lib/types/operations/decorators.d.cts +348 -0
- package/lib/types/operations/decorators.d.mts +348 -0
- package/lib/types/operations/index.d.cts +10 -0
- package/lib/types/operations/index.d.mts +10 -0
- package/lib/types/operations/types.d.cts +60 -0
- package/lib/types/operations/types.d.mts +60 -0
- package/lib/types/overrides/Metadata.d.cts +54 -0
- package/lib/types/overrides/Metadata.d.mts +54 -0
- package/lib/types/overrides/Model.d.cts +84 -0
- package/lib/types/overrides/Model.d.mts +84 -0
- package/lib/types/overrides/ModelBuilderExtensions.d.cts +15 -0
- package/lib/types/overrides/ModelBuilderExtensions.d.mts +15 -0
- package/lib/types/overrides/index.d.cts +10 -0
- package/lib/types/overrides/index.d.mts +10 -0
- package/lib/types/overrides/overrides.d.cts +1 -0
- package/lib/types/overrides/overrides.d.mts +1 -0
- package/lib/types/repository/Context.d.cts +112 -0
- package/lib/types/repository/Context.d.mts +112 -0
- package/lib/types/repository/Repository.d.cts +352 -0
- package/lib/types/repository/Repository.d.mts +352 -0
- package/lib/types/repository/constants.d.cts +9 -0
- package/lib/types/repository/constants.d.mts +9 -0
- package/lib/types/repository/errors.d.cts +126 -0
- package/lib/types/repository/errors.d.mts +126 -0
- package/lib/types/repository/index.d.cts +12 -0
- package/lib/types/repository/index.d.mts +12 -0
- package/lib/types/repository/types.d.cts +62 -0
- package/lib/types/repository/types.d.mts +62 -0
- package/lib/types/repository/utils.d.cts +34 -0
- package/lib/types/repository/utils.d.mts +34 -0
- package/lib/types/repository/wrappers.d.cts +39 -0
- package/lib/types/repository/wrappers.d.mts +39 -0
- package/lib/types/validation/constants.d.cts +45 -0
- package/lib/types/validation/constants.d.mts +45 -0
- package/lib/types/validation/decorators.d.cts +143 -0
- package/lib/types/validation/decorators.d.mts +143 -0
- package/lib/types/validation/index.d.cts +4 -0
- package/lib/types/validation/index.d.mts +4 -0
- package/lib/types/validation/validation.d.cts +41 -0
- package/lib/types/validation/validation.d.mts +41 -0
- package/lib/types/validation/validators/ReadOnlyValidator.d.cts +47 -0
- package/lib/types/validation/validators/ReadOnlyValidator.d.mts +47 -0
- package/lib/types/validation/validators/TimestampValidator.d.cts +48 -0
- package/lib/types/validation/validators/TimestampValidator.d.mts +48 -0
- package/lib/types/validation/validators/UpdateValidator.d.cts +40 -0
- package/lib/types/validation/validators/UpdateValidator.d.mts +40 -0
- package/lib/types/validation/validators/index.d.cts +3 -0
- package/lib/types/validation/validators/index.d.mts +3 -0
- package/package.json +4 -4
- package/lib/cjs/identity/decorators.js.map +0 -1
- package/lib/cjs/identity/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/BulkCrudOperator.js.map +0 -1
- package/lib/cjs/interfaces/Contextual.js.map +0 -1
- package/lib/cjs/interfaces/CrudOperator.js.map +0 -1
- package/lib/cjs/interfaces/IRepository.js.map +0 -1
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/cjs/model/constants.js.map +0 -1
- package/lib/cjs/model/decorators.js.map +0 -1
- package/lib/cjs/model/index.js.map +0 -1
- package/lib/cjs/model/model.js.map +0 -1
- package/lib/cjs/model/validation.js.map +0 -1
- package/lib/cjs/operations/Operations.js.map +0 -1
- package/lib/cjs/operations/OperationsRegistry.js.map +0 -1
- package/lib/cjs/operations/constants.js.map +0 -1
- package/lib/cjs/operations/decorators.js.map +0 -1
- package/lib/cjs/operations/index.js.map +0 -1
- package/lib/cjs/operations/types.js.map +0 -1
- package/lib/cjs/overrides/Metadata.js.map +0 -1
- package/lib/cjs/overrides/Model.js.map +0 -1
- package/lib/cjs/overrides/ModelBuilderExtensions.js.map +0 -1
- package/lib/cjs/overrides/index.js.map +0 -1
- package/lib/cjs/overrides/overrides.js.map +0 -1
- package/lib/cjs/repository/Context.js.map +0 -1
- package/lib/cjs/repository/Repository.js.map +0 -1
- package/lib/cjs/repository/constants.js.map +0 -1
- package/lib/cjs/repository/errors.js.map +0 -1
- package/lib/cjs/repository/index.js.map +0 -1
- package/lib/cjs/repository/types.js.map +0 -1
- package/lib/cjs/repository/utils.js.map +0 -1
- package/lib/cjs/repository/wrappers.js.map +0 -1
- package/lib/cjs/validation/constants.js.map +0 -1
- package/lib/cjs/validation/decorators.js.map +0 -1
- package/lib/cjs/validation/index.js.map +0 -1
- package/lib/cjs/validation/validation.js.map +0 -1
- package/lib/cjs/validation/validators/ReadOnlyValidator.js.map +0 -1
- package/lib/cjs/validation/validators/TimestampValidator.js.map +0 -1
- package/lib/cjs/validation/validators/UpdateValidator.js.map +0 -1
- package/lib/cjs/validation/validators/index.js.map +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { OperationHandler } from "./types.cjs";
|
|
2
|
+
import { OperationKeys } from "./constants.cjs";
|
|
3
|
+
import { IRepository } from "../interfaces/IRepository.cjs";
|
|
4
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
+
/**
|
|
6
|
+
* @description Registry for database operation handlers
|
|
7
|
+
* @summary Manages and stores operation handlers for different model properties and operations
|
|
8
|
+
* @class OperationsRegistry
|
|
9
|
+
* @template M - Model type
|
|
10
|
+
* @template R - Repository type
|
|
11
|
+
* @template V - Metadata type
|
|
12
|
+
* @template F - Repository flags
|
|
13
|
+
* @template C - Context type
|
|
14
|
+
* @example
|
|
15
|
+
* // Create a registry and register a handler
|
|
16
|
+
* const registry = new OperationsRegistry();
|
|
17
|
+
* registry.register(myHandler, OperationKeys.CREATE, targetModel, 'propertyName');
|
|
18
|
+
*
|
|
19
|
+
* // Get handlers for a specific operation
|
|
20
|
+
* const handlers = registry.get(targetModel.constructor.name, 'propertyName', 'onCreate');
|
|
21
|
+
*
|
|
22
|
+
* @mermaid
|
|
23
|
+
* classDiagram
|
|
24
|
+
* class OperationsRegistry {
|
|
25
|
+
* -cache: Record~string, Record~string|symbol, Record~string, Record~string, OperationHandler~~~~
|
|
26
|
+
* +get(target, propKey, operation, accum)
|
|
27
|
+
* +register(handler, operation, target, propKey)
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
export declare class OperationsRegistry {
|
|
31
|
+
private readonly cache;
|
|
32
|
+
/**
|
|
33
|
+
* @description Retrieves operation handlers for a specific target and operation
|
|
34
|
+
* @summary Finds all registered handlers for a given target, property, and operation, including from parent classes
|
|
35
|
+
* @template M - Model type extending Model
|
|
36
|
+
* @template R - Repository type extending IRepository
|
|
37
|
+
* @template V - Metadata type
|
|
38
|
+
* @param {string | Record<string, any>} target - The target class name or object
|
|
39
|
+
* @param {string} propKey - The property key to get handlers for
|
|
40
|
+
* @param {string} operation - The operation key to get handlers for
|
|
41
|
+
* @param {OperationHandler[]} [accum] - Accumulator for recursive calls
|
|
42
|
+
* @return {OperationHandler[] | undefined} Array of handlers or undefined if none found
|
|
43
|
+
*/
|
|
44
|
+
get<M extends Model, R extends IRepository<M, any>, V>(target: string | Record<string, any>, propKey: string, operation: string, accum?: OperationHandler<M, R, V>[]): OperationHandler<M, R, V>[] | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* @description Registers an operation handler for a specific target and operation
|
|
47
|
+
* @summary Stores a handler in the registry for a given target, property, and operation
|
|
48
|
+
* @template M - Model type extending Model
|
|
49
|
+
* @template R - Repository type extending IRepository
|
|
50
|
+
* @template V - Metadata type
|
|
51
|
+
* @template F - Repository flags extending RepositoryFlags
|
|
52
|
+
* @template C - Context type extending Context<F>
|
|
53
|
+
* @param {OperationHandler} handler - The handler function to register
|
|
54
|
+
* @param {OperationKeys} operation - The operation key to register the handler for
|
|
55
|
+
* @param {M} target - The target model instance
|
|
56
|
+
* @param {string | symbol} propKey - The property key to register the handler for
|
|
57
|
+
* @return {void}
|
|
58
|
+
*/
|
|
59
|
+
register<M extends Model, R extends IRepository<M, any>, V>(handler: OperationHandler<M, R, V>, operation: OperationKeys, target: M, propKey: string | symbol): void;
|
|
60
|
+
private resolveOwner;
|
|
61
|
+
private resolveTargetName;
|
|
62
|
+
private resolveFlavour;
|
|
63
|
+
private selectHandlers;
|
|
64
|
+
private firstBucket;
|
|
65
|
+
/**
|
|
66
|
+
* @description Gets a unique name for an operation handler
|
|
67
|
+
* @summary Returns the name of the handler function or generates a hash if name is not available
|
|
68
|
+
* @param {OperationHandler<any, any, any>} handler - The handler function to get the name for
|
|
69
|
+
* @return {string} The name of the handler or a generated hash
|
|
70
|
+
*/
|
|
71
|
+
static getHandlerName(handler: OperationHandler<any, any, any>): any;
|
|
72
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { OperationHandler } from "./types.js";
|
|
2
|
+
import { OperationKeys } from "./constants.js";
|
|
3
|
+
import { IRepository } from "../interfaces/IRepository.js";
|
|
4
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
+
/**
|
|
6
|
+
* @description Registry for database operation handlers
|
|
7
|
+
* @summary Manages and stores operation handlers for different model properties and operations
|
|
8
|
+
* @class OperationsRegistry
|
|
9
|
+
* @template M - Model type
|
|
10
|
+
* @template R - Repository type
|
|
11
|
+
* @template V - Metadata type
|
|
12
|
+
* @template F - Repository flags
|
|
13
|
+
* @template C - Context type
|
|
14
|
+
* @example
|
|
15
|
+
* // Create a registry and register a handler
|
|
16
|
+
* const registry = new OperationsRegistry();
|
|
17
|
+
* registry.register(myHandler, OperationKeys.CREATE, targetModel, 'propertyName');
|
|
18
|
+
*
|
|
19
|
+
* // Get handlers for a specific operation
|
|
20
|
+
* const handlers = registry.get(targetModel.constructor.name, 'propertyName', 'onCreate');
|
|
21
|
+
*
|
|
22
|
+
* @mermaid
|
|
23
|
+
* classDiagram
|
|
24
|
+
* class OperationsRegistry {
|
|
25
|
+
* -cache: Record~string, Record~string|symbol, Record~string, Record~string, OperationHandler~~~~
|
|
26
|
+
* +get(target, propKey, operation, accum)
|
|
27
|
+
* +register(handler, operation, target, propKey)
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
export declare class OperationsRegistry {
|
|
31
|
+
private readonly cache;
|
|
32
|
+
/**
|
|
33
|
+
* @description Retrieves operation handlers for a specific target and operation
|
|
34
|
+
* @summary Finds all registered handlers for a given target, property, and operation, including from parent classes
|
|
35
|
+
* @template M - Model type extending Model
|
|
36
|
+
* @template R - Repository type extending IRepository
|
|
37
|
+
* @template V - Metadata type
|
|
38
|
+
* @param {string | Record<string, any>} target - The target class name or object
|
|
39
|
+
* @param {string} propKey - The property key to get handlers for
|
|
40
|
+
* @param {string} operation - The operation key to get handlers for
|
|
41
|
+
* @param {OperationHandler[]} [accum] - Accumulator for recursive calls
|
|
42
|
+
* @return {OperationHandler[] | undefined} Array of handlers or undefined if none found
|
|
43
|
+
*/
|
|
44
|
+
get<M extends Model, R extends IRepository<M, any>, V>(target: string | Record<string, any>, propKey: string, operation: string, accum?: OperationHandler<M, R, V>[]): OperationHandler<M, R, V>[] | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* @description Registers an operation handler for a specific target and operation
|
|
47
|
+
* @summary Stores a handler in the registry for a given target, property, and operation
|
|
48
|
+
* @template M - Model type extending Model
|
|
49
|
+
* @template R - Repository type extending IRepository
|
|
50
|
+
* @template V - Metadata type
|
|
51
|
+
* @template F - Repository flags extending RepositoryFlags
|
|
52
|
+
* @template C - Context type extending Context<F>
|
|
53
|
+
* @param {OperationHandler} handler - The handler function to register
|
|
54
|
+
* @param {OperationKeys} operation - The operation key to register the handler for
|
|
55
|
+
* @param {M} target - The target model instance
|
|
56
|
+
* @param {string | symbol} propKey - The property key to register the handler for
|
|
57
|
+
* @return {void}
|
|
58
|
+
*/
|
|
59
|
+
register<M extends Model, R extends IRepository<M, any>, V>(handler: OperationHandler<M, R, V>, operation: OperationKeys, target: M, propKey: string | symbol): void;
|
|
60
|
+
private resolveOwner;
|
|
61
|
+
private resolveTargetName;
|
|
62
|
+
private resolveFlavour;
|
|
63
|
+
private selectHandlers;
|
|
64
|
+
private firstBucket;
|
|
65
|
+
/**
|
|
66
|
+
* @description Gets a unique name for an operation handler
|
|
67
|
+
* @summary Returns the name of the handler function or generates a hash if name is not available
|
|
68
|
+
* @param {OperationHandler<any, any, any>} handler - The handler function to get the name for
|
|
69
|
+
* @return {string} The name of the handler or a generated hash
|
|
70
|
+
*/
|
|
71
|
+
static getHandlerName(handler: OperationHandler<any, any, any>): any;
|
|
72
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Database operation key constants
|
|
3
|
+
* @summary Enum defining CRUD operations and their lifecycle phases
|
|
4
|
+
* @enum {string}
|
|
5
|
+
* @readonly
|
|
6
|
+
* @memberOf module:db-decorators
|
|
7
|
+
*/
|
|
8
|
+
export declare enum OperationKeys {
|
|
9
|
+
REFLECT = "decaf.model.db.operations.",
|
|
10
|
+
CREATE = "create",
|
|
11
|
+
READ = "read",
|
|
12
|
+
UPDATE = "update",
|
|
13
|
+
DELETE = "delete",
|
|
14
|
+
ON = "on.",
|
|
15
|
+
AFTER = "after.",
|
|
16
|
+
BLOCK = "block"
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @description Database operation key naming constants
|
|
20
|
+
* @summary Enum defining operations naming
|
|
21
|
+
* @enum {string}
|
|
22
|
+
* @readonly
|
|
23
|
+
* @memberOf module:db-decorators
|
|
24
|
+
*/
|
|
25
|
+
export declare enum ModelOperations {
|
|
26
|
+
OPERATIONS = "operations",
|
|
27
|
+
RELATIONS = "relations"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @description Type for basic CRUD operations
|
|
31
|
+
* @summary Union type of the four basic database operations: create, read, update, delete
|
|
32
|
+
* @typedef {string} CrudOperations
|
|
33
|
+
* @memberOf module:db-decorators
|
|
34
|
+
*/
|
|
35
|
+
export type CrudOperations = OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE;
|
|
36
|
+
/**
|
|
37
|
+
* @description Bulk database operation key constants
|
|
38
|
+
* @summary Enum defining bulk CRUD operations for handling multiple records at once
|
|
39
|
+
* @enum {string}
|
|
40
|
+
* @readonly
|
|
41
|
+
* @memberOf module:db-decorators
|
|
42
|
+
*/
|
|
43
|
+
export declare enum BulkCrudOperationKeys {
|
|
44
|
+
CREATE_ALL = "createAll",
|
|
45
|
+
READ_ALL = "readAll",
|
|
46
|
+
UPDATE_ALL = "updateAll",
|
|
47
|
+
DELETE_ALL = "deleteAll"
|
|
48
|
+
}
|
|
49
|
+
export declare enum BulkOperationBlockTarget {
|
|
50
|
+
ALL = "bulkAll"
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @description Type for bulk CRUD operations
|
|
54
|
+
* @summary Union type of the four bulk database operations for handling multiple records at once
|
|
55
|
+
* @typedef {string} BulkCrudOperations
|
|
56
|
+
* @memberOf module:db-decorators
|
|
57
|
+
*/
|
|
58
|
+
export type BulkCrudOperations = BulkCrudOperationKeys.CREATE_ALL | BulkCrudOperationKeys.READ_ALL | BulkCrudOperationKeys.UPDATE_ALL | BulkCrudOperationKeys.DELETE_ALL;
|
|
59
|
+
/**
|
|
60
|
+
* @description Grouped CRUD operations for decorator mapping
|
|
61
|
+
* @summary Maps out groups of CRUD operations for easier mapping of decorators
|
|
62
|
+
* @const DBOperations
|
|
63
|
+
* @memberOf module:db-decorators
|
|
64
|
+
*/
|
|
65
|
+
export declare const DBOperations: Record<string, CrudOperations[]>;
|
|
66
|
+
/**
|
|
67
|
+
* @description Block target categories
|
|
68
|
+
* @summary Indicates whether the block applies to CRUD ops, prepared statements, or query keys
|
|
69
|
+
* @typedef {"crud" | "statement" | "query"} BlockOperationKind
|
|
70
|
+
* @memberOf module:db-decorators
|
|
71
|
+
*/
|
|
72
|
+
export type BlockOperationKind = "crud" | "statement" | "query" | "bulk";
|
|
73
|
+
/**
|
|
74
|
+
* @description Descriptor for a single blocked operation target
|
|
75
|
+
* @summary Includes the target kind and identifier (CRUD operation, statement name, query key)
|
|
76
|
+
* @typedef BlockOperationDescriptor
|
|
77
|
+
* @property {"crud"} kind
|
|
78
|
+
* @property {CrudOperations} value
|
|
79
|
+
*
|
|
80
|
+
* @property {"statement"} kind
|
|
81
|
+
* @property {string} value
|
|
82
|
+
*
|
|
83
|
+
* @property {"query"} kind
|
|
84
|
+
* @property {string} value
|
|
85
|
+
* @memberOf module:db-decorators
|
|
86
|
+
*/
|
|
87
|
+
export type BlockOperationDescriptor = {
|
|
88
|
+
kind: "crud";
|
|
89
|
+
value: CrudOperations;
|
|
90
|
+
} | {
|
|
91
|
+
kind: "statement";
|
|
92
|
+
value: string;
|
|
93
|
+
} | {
|
|
94
|
+
kind: "query";
|
|
95
|
+
value: string;
|
|
96
|
+
} | {
|
|
97
|
+
kind: "bulk";
|
|
98
|
+
value: BulkCrudOperations | BulkOperationBlockTarget;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* @description Inputs accepted by @BlockOperations decorator
|
|
102
|
+
* @summary Accepts either a CRUD operation, a descriptor, or an array of both
|
|
103
|
+
* @typedef {CrudOperations | BlockOperationDescriptor | Array<CrudOperations | BlockOperationDescriptor>} BlockOperationsInput
|
|
104
|
+
* @memberOf module:db-decorators
|
|
105
|
+
*/
|
|
106
|
+
export type BlockOperationsInput = CrudOperations | BulkCrudOperations | BulkOperationBlockTarget | BlockOperationDescriptor | (CrudOperations | BulkCrudOperations | BulkOperationBlockTarget | BlockOperationDescriptor)[];
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Database operation key constants
|
|
3
|
+
* @summary Enum defining CRUD operations and their lifecycle phases
|
|
4
|
+
* @enum {string}
|
|
5
|
+
* @readonly
|
|
6
|
+
* @memberOf module:db-decorators
|
|
7
|
+
*/
|
|
8
|
+
export declare enum OperationKeys {
|
|
9
|
+
REFLECT = "decaf.model.db.operations.",
|
|
10
|
+
CREATE = "create",
|
|
11
|
+
READ = "read",
|
|
12
|
+
UPDATE = "update",
|
|
13
|
+
DELETE = "delete",
|
|
14
|
+
ON = "on.",
|
|
15
|
+
AFTER = "after.",
|
|
16
|
+
BLOCK = "block"
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @description Database operation key naming constants
|
|
20
|
+
* @summary Enum defining operations naming
|
|
21
|
+
* @enum {string}
|
|
22
|
+
* @readonly
|
|
23
|
+
* @memberOf module:db-decorators
|
|
24
|
+
*/
|
|
25
|
+
export declare enum ModelOperations {
|
|
26
|
+
OPERATIONS = "operations",
|
|
27
|
+
RELATIONS = "relations"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @description Type for basic CRUD operations
|
|
31
|
+
* @summary Union type of the four basic database operations: create, read, update, delete
|
|
32
|
+
* @typedef {string} CrudOperations
|
|
33
|
+
* @memberOf module:db-decorators
|
|
34
|
+
*/
|
|
35
|
+
export type CrudOperations = OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE;
|
|
36
|
+
/**
|
|
37
|
+
* @description Bulk database operation key constants
|
|
38
|
+
* @summary Enum defining bulk CRUD operations for handling multiple records at once
|
|
39
|
+
* @enum {string}
|
|
40
|
+
* @readonly
|
|
41
|
+
* @memberOf module:db-decorators
|
|
42
|
+
*/
|
|
43
|
+
export declare enum BulkCrudOperationKeys {
|
|
44
|
+
CREATE_ALL = "createAll",
|
|
45
|
+
READ_ALL = "readAll",
|
|
46
|
+
UPDATE_ALL = "updateAll",
|
|
47
|
+
DELETE_ALL = "deleteAll"
|
|
48
|
+
}
|
|
49
|
+
export declare enum BulkOperationBlockTarget {
|
|
50
|
+
ALL = "bulkAll"
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @description Type for bulk CRUD operations
|
|
54
|
+
* @summary Union type of the four bulk database operations for handling multiple records at once
|
|
55
|
+
* @typedef {string} BulkCrudOperations
|
|
56
|
+
* @memberOf module:db-decorators
|
|
57
|
+
*/
|
|
58
|
+
export type BulkCrudOperations = BulkCrudOperationKeys.CREATE_ALL | BulkCrudOperationKeys.READ_ALL | BulkCrudOperationKeys.UPDATE_ALL | BulkCrudOperationKeys.DELETE_ALL;
|
|
59
|
+
/**
|
|
60
|
+
* @description Grouped CRUD operations for decorator mapping
|
|
61
|
+
* @summary Maps out groups of CRUD operations for easier mapping of decorators
|
|
62
|
+
* @const DBOperations
|
|
63
|
+
* @memberOf module:db-decorators
|
|
64
|
+
*/
|
|
65
|
+
export declare const DBOperations: Record<string, CrudOperations[]>;
|
|
66
|
+
/**
|
|
67
|
+
* @description Block target categories
|
|
68
|
+
* @summary Indicates whether the block applies to CRUD ops, prepared statements, or query keys
|
|
69
|
+
* @typedef {"crud" | "statement" | "query"} BlockOperationKind
|
|
70
|
+
* @memberOf module:db-decorators
|
|
71
|
+
*/
|
|
72
|
+
export type BlockOperationKind = "crud" | "statement" | "query" | "bulk";
|
|
73
|
+
/**
|
|
74
|
+
* @description Descriptor for a single blocked operation target
|
|
75
|
+
* @summary Includes the target kind and identifier (CRUD operation, statement name, query key)
|
|
76
|
+
* @typedef BlockOperationDescriptor
|
|
77
|
+
* @property {"crud"} kind
|
|
78
|
+
* @property {CrudOperations} value
|
|
79
|
+
*
|
|
80
|
+
* @property {"statement"} kind
|
|
81
|
+
* @property {string} value
|
|
82
|
+
*
|
|
83
|
+
* @property {"query"} kind
|
|
84
|
+
* @property {string} value
|
|
85
|
+
* @memberOf module:db-decorators
|
|
86
|
+
*/
|
|
87
|
+
export type BlockOperationDescriptor = {
|
|
88
|
+
kind: "crud";
|
|
89
|
+
value: CrudOperations;
|
|
90
|
+
} | {
|
|
91
|
+
kind: "statement";
|
|
92
|
+
value: string;
|
|
93
|
+
} | {
|
|
94
|
+
kind: "query";
|
|
95
|
+
value: string;
|
|
96
|
+
} | {
|
|
97
|
+
kind: "bulk";
|
|
98
|
+
value: BulkCrudOperations | BulkOperationBlockTarget;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* @description Inputs accepted by @BlockOperations decorator
|
|
102
|
+
* @summary Accepts either a CRUD operation, a descriptor, or an array of both
|
|
103
|
+
* @typedef {CrudOperations | BlockOperationDescriptor | Array<CrudOperations | BlockOperationDescriptor>} BlockOperationsInput
|
|
104
|
+
* @memberOf module:db-decorators
|
|
105
|
+
*/
|
|
106
|
+
export type BlockOperationsInput = CrudOperations | BulkCrudOperations | BulkOperationBlockTarget | BlockOperationDescriptor | (CrudOperations | BulkCrudOperations | BulkOperationBlockTarget | BlockOperationDescriptor)[];
|