@decaf-ts/db-decorators 0.6.0 → 0.6.2
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 +21 -157
- package/README.md +571 -10
- package/dist/db-decorators.cjs +1375 -327
- package/dist/db-decorators.esm.cjs +1375 -328
- package/lib/esm/identity/decorators.d.ts +7 -0
- package/lib/esm/identity/decorators.js +11 -4
- package/lib/esm/identity/index.js +3 -3
- package/lib/esm/identity/utils.d.ts +36 -23
- package/lib/esm/identity/utils.js +38 -25
- package/lib/esm/index.d.ts +12 -27
- package/lib/esm/index.js +13 -28
- package/lib/esm/interfaces/BulkCrudOperator.d.ts +39 -0
- package/lib/esm/interfaces/BulkCrudOperator.js +1 -1
- package/lib/esm/interfaces/Contextual.d.ts +19 -2
- package/lib/esm/interfaces/Contextual.js +1 -1
- package/lib/esm/interfaces/CrudOperator.d.ts +26 -23
- package/lib/esm/interfaces/CrudOperator.js +1 -1
- package/lib/esm/interfaces/IRepository.d.ts +10 -2
- package/lib/esm/interfaces/IRepository.js +1 -1
- package/lib/esm/interfaces/index.js +5 -5
- package/lib/esm/model/constants.d.ts +11 -13
- package/lib/esm/model/constants.js +12 -14
- package/lib/esm/model/decorators.d.ts +112 -23
- package/lib/esm/model/decorators.js +119 -29
- package/lib/esm/model/index.d.ts +1 -0
- package/lib/esm/model/index.js +7 -6
- package/lib/esm/model/model.d.ts +2 -141
- package/lib/esm/model/model.js +2 -13
- package/lib/esm/model/overrides.d.ts +1 -0
- package/lib/esm/model/overrides.js +23 -0
- package/lib/esm/model/utils.d.ts +39 -0
- package/lib/esm/model/utils.js +43 -4
- package/lib/esm/model/validation.d.ts +26 -8
- package/lib/esm/model/validation.js +29 -11
- package/lib/esm/operations/Operations.d.ts +65 -3
- package/lib/esm/operations/Operations.js +68 -6
- package/lib/esm/operations/OperationsRegistry.d.ts +44 -16
- package/lib/esm/operations/OperationsRegistry.js +46 -18
- package/lib/esm/operations/constants.d.ts +34 -8
- package/lib/esm/operations/constants.js +23 -9
- package/lib/esm/operations/decorators.d.ts +140 -134
- package/lib/esm/operations/decorators.js +152 -137
- package/lib/esm/operations/index.js +6 -6
- package/lib/esm/operations/types.d.ts +10 -0
- package/lib/esm/operations/types.js +1 -1
- package/lib/esm/repository/BaseRepository.d.ts +324 -0
- package/lib/esm/repository/BaseRepository.js +309 -9
- package/lib/esm/repository/Context.d.ts +153 -2
- package/lib/esm/repository/Context.js +154 -6
- package/lib/esm/repository/Repository.d.ts +89 -0
- package/lib/esm/repository/Repository.js +96 -7
- package/lib/esm/repository/constants.d.ts +7 -0
- package/lib/esm/repository/constants.js +9 -1
- package/lib/esm/repository/errors.d.ts +61 -34
- package/lib/esm/repository/errors.js +62 -35
- package/lib/esm/repository/index.js +9 -9
- package/lib/esm/repository/types.d.ts +26 -0
- package/lib/esm/repository/types.js +1 -1
- package/lib/esm/repository/utils.d.ts +11 -0
- package/lib/esm/repository/utils.js +7 -7
- package/lib/esm/repository/wrappers.d.ts +2 -2
- package/lib/esm/repository/wrappers.js +5 -5
- package/lib/esm/validation/constants.d.ts +20 -5
- package/lib/esm/validation/constants.js +22 -7
- package/lib/esm/validation/decorators.d.ts +101 -19
- package/lib/esm/validation/decorators.js +109 -27
- package/lib/esm/validation/index.js +5 -5
- package/lib/esm/validation/validation.js +10 -2
- package/lib/esm/validation/validators/ReadOnlyValidator.d.ts +32 -8
- package/lib/esm/validation/validators/ReadOnlyValidator.js +34 -10
- package/lib/esm/validation/validators/TimestampValidator.d.ts +37 -3
- package/lib/esm/validation/validators/TimestampValidator.js +39 -5
- package/lib/esm/validation/validators/UpdateValidator.d.ts +28 -11
- package/lib/esm/validation/validators/UpdateValidator.js +23 -8
- package/lib/esm/validation/validators/index.js +4 -4
- package/lib/identity/decorators.cjs +8 -1
- package/lib/identity/decorators.d.ts +7 -0
- package/lib/identity/utils.cjs +35 -22
- package/lib/identity/utils.d.ts +36 -23
- package/lib/index.cjs +14 -28
- package/lib/index.d.ts +12 -27
- package/lib/interfaces/BulkCrudOperator.cjs +1 -1
- package/lib/interfaces/BulkCrudOperator.d.ts +39 -0
- package/lib/interfaces/Contextual.cjs +1 -1
- package/lib/interfaces/Contextual.d.ts +19 -2
- package/lib/interfaces/CrudOperator.cjs +1 -1
- package/lib/interfaces/CrudOperator.d.ts +26 -23
- package/lib/interfaces/IRepository.cjs +1 -1
- package/lib/interfaces/IRepository.d.ts +10 -2
- package/lib/model/constants.cjs +12 -14
- package/lib/model/constants.d.ts +11 -13
- package/lib/model/decorators.cjs +114 -24
- package/lib/model/decorators.d.ts +112 -23
- package/lib/model/index.cjs +2 -1
- package/lib/model/index.d.ts +1 -0
- package/lib/model/model.cjs +1 -13
- package/lib/model/model.d.ts +2 -141
- package/lib/model/overrides.cjs +25 -0
- package/lib/model/overrides.d.ts +1 -0
- package/lib/model/utils.cjs +41 -2
- package/lib/model/utils.d.ts +39 -0
- package/lib/model/validation.cjs +27 -9
- package/lib/model/validation.d.ts +26 -8
- package/lib/operations/Operations.cjs +66 -4
- package/lib/operations/Operations.d.ts +65 -3
- package/lib/operations/OperationsRegistry.cjs +45 -17
- package/lib/operations/OperationsRegistry.d.ts +44 -16
- package/lib/operations/constants.cjs +24 -10
- package/lib/operations/constants.d.ts +34 -8
- package/lib/operations/decorators.cjs +150 -135
- package/lib/operations/decorators.d.ts +140 -134
- package/lib/operations/types.cjs +1 -1
- package/lib/operations/types.d.ts +10 -0
- package/lib/repository/BaseRepository.cjs +303 -3
- package/lib/repository/BaseRepository.d.ts +324 -0
- package/lib/repository/Context.cjs +153 -5
- package/lib/repository/Context.d.ts +153 -2
- package/lib/repository/Repository.cjs +90 -1
- package/lib/repository/Repository.d.ts +89 -0
- package/lib/repository/constants.cjs +9 -1
- package/lib/repository/constants.d.ts +7 -0
- package/lib/repository/errors.cjs +62 -35
- package/lib/repository/errors.d.ts +61 -34
- package/lib/repository/types.cjs +1 -1
- package/lib/repository/types.d.ts +26 -0
- package/lib/repository/utils.cjs +3 -3
- package/lib/repository/utils.d.ts +11 -0
- package/lib/repository/wrappers.cjs +3 -3
- package/lib/repository/wrappers.d.ts +2 -2
- package/lib/validation/constants.cjs +21 -6
- package/lib/validation/constants.d.ts +20 -5
- package/lib/validation/decorators.cjs +102 -20
- package/lib/validation/decorators.d.ts +101 -19
- package/lib/validation/validation.cjs +9 -1
- package/lib/validation/validators/ReadOnlyValidator.cjs +33 -9
- package/lib/validation/validators/ReadOnlyValidator.d.ts +32 -8
- package/lib/validation/validators/TimestampValidator.cjs +38 -4
- package/lib/validation/validators/TimestampValidator.d.ts +37 -3
- package/lib/validation/validators/UpdateValidator.cjs +23 -8
- package/lib/validation/validators/UpdateValidator.d.ts +28 -11
- package/package.json +2 -2
|
@@ -5,18 +5,80 @@ import { IRepository } from "../interfaces";
|
|
|
5
5
|
import { Context } from "../repository";
|
|
6
6
|
import { RepositoryFlags } from "../repository/types";
|
|
7
7
|
/**
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
8
|
+
* @description Static utility class for database operation management
|
|
9
|
+
* @summary Provides functionality for registering, retrieving, and managing database operation handlers
|
|
10
10
|
* @class Operations
|
|
11
|
+
* @template M - Model type
|
|
12
|
+
* @template R - Repository type
|
|
13
|
+
* @template V - Metadata type
|
|
14
|
+
* @template F - Repository flags
|
|
15
|
+
* @template C - Context type
|
|
16
|
+
* @example
|
|
17
|
+
* // Register a handler for a create operation
|
|
18
|
+
* Operations.register(myHandler, OperationKeys.CREATE, targetModel, 'propertyName');
|
|
19
|
+
*
|
|
20
|
+
* // Get handlers for a specific operation
|
|
21
|
+
* const handlers = Operations.get(targetModel.constructor.name, 'propertyName', 'onCreate');
|
|
11
22
|
*
|
|
12
|
-
* @
|
|
23
|
+
* @mermaid
|
|
24
|
+
* classDiagram
|
|
25
|
+
* class Operations {
|
|
26
|
+
* -registry: OperationsRegistry
|
|
27
|
+
* +getHandlerName(handler)
|
|
28
|
+
* +key(str)
|
|
29
|
+
* +get(targetName, propKey, operation)
|
|
30
|
+
* -getOpRegistry()
|
|
31
|
+
* +register(handler, operation, target, propKey)
|
|
32
|
+
* }
|
|
33
|
+
* Operations --> OperationsRegistry : uses
|
|
13
34
|
*/
|
|
14
35
|
export declare class Operations {
|
|
15
36
|
private static registry;
|
|
16
37
|
private constructor();
|
|
38
|
+
/**
|
|
39
|
+
* @description Gets a unique name for an operation handler
|
|
40
|
+
* @summary Returns the name of the handler function or generates a hash if name is not available
|
|
41
|
+
* @param {OperationHandler<any, any, any, any, any>} handler - The handler function to get the name for
|
|
42
|
+
* @return {string} The name of the handler or a generated hash
|
|
43
|
+
*/
|
|
17
44
|
static getHandlerName(handler: OperationHandler<any, any, any, any, any>): any;
|
|
45
|
+
/**
|
|
46
|
+
* @description Generates a reflection metadata key
|
|
47
|
+
* @summary Creates a fully qualified metadata key by prefixing with the reflection namespace
|
|
48
|
+
* @param {string} str - The operation key string to prefix
|
|
49
|
+
* @return {string} The fully qualified metadata key
|
|
50
|
+
*/
|
|
18
51
|
static key(str: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* @description Retrieves operation handlers for a specific target and operation
|
|
54
|
+
* @summary Gets registered handlers from the operations registry for a given target, property, and operation
|
|
55
|
+
* @template M - Model type extending Model
|
|
56
|
+
* @template R - Repository type extending IRepository
|
|
57
|
+
* @template V - Metadata type, defaults to object
|
|
58
|
+
* @template F - Repository flags extending RepositoryFlags
|
|
59
|
+
* @template C - Context type extending Context<F>
|
|
60
|
+
* @param {string | Record<string, any>} targetName - The target class name or object
|
|
61
|
+
* @param {string} propKey - The property key to get handlers for
|
|
62
|
+
* @param {string} operation - The operation key to get handlers for
|
|
63
|
+
* @return {any} The registered handlers for the specified target, property, and operation
|
|
64
|
+
*/
|
|
19
65
|
static get<M extends Model, R extends IRepository<M, F, C>, V = object, F extends RepositoryFlags = RepositoryFlags, C extends Context<F> = Context<F>>(targetName: string | Record<string, any>, propKey: string, operation: string): OperationHandler<M, R, V, F, C>[] | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* @description Gets or initializes the operations registry
|
|
68
|
+
* @summary Returns the existing registry or creates a new one if it doesn't exist
|
|
69
|
+
* @return {OperationsRegistry} The operations registry instance
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
20
72
|
private static getOpRegistry;
|
|
73
|
+
/**
|
|
74
|
+
* @description Registers an operation handler for a specific target and operation
|
|
75
|
+
* @summary Adds a handler to the operations registry for a given target, property, and operation
|
|
76
|
+
* @template V - Model type extending Model
|
|
77
|
+
* @param {OperationHandler<V, any, any>} handler - The handler function to register
|
|
78
|
+
* @param {OperationKeys} operation - The operation key to register the handler for
|
|
79
|
+
* @param {V} target - The target model instance
|
|
80
|
+
* @param {string | symbol} propKey - The property key to register the handler for
|
|
81
|
+
* @return {void}
|
|
82
|
+
*/
|
|
21
83
|
static register<V extends Model>(handler: OperationHandler<V, any, any>, operation: OperationKeys, target: V, propKey: string | symbol): void;
|
|
22
84
|
}
|
|
@@ -3,26 +3,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OperationsRegistry = void 0;
|
|
4
4
|
const Operations_1 = require("./Operations.cjs");
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
6
|
+
* @description Registry for database operation handlers
|
|
7
|
+
* @summary Manages and stores operation handlers for different model properties and operations
|
|
8
8
|
* @class OperationsRegistry
|
|
9
|
-
* @
|
|
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');
|
|
10
18
|
*
|
|
11
|
-
*
|
|
19
|
+
* // Get handlers for a specific operation
|
|
20
|
+
* const handlers = registry.get(targetModel.constructor.name, 'propertyName', 'onCreate');
|
|
12
21
|
*
|
|
13
|
-
* @
|
|
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
|
+
* }
|
|
14
29
|
*/
|
|
15
30
|
class OperationsRegistry {
|
|
16
31
|
constructor() {
|
|
17
32
|
this.cache = {};
|
|
18
33
|
}
|
|
19
34
|
/**
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
35
|
+
* @description Retrieves operation handlers for a specific target and operation
|
|
36
|
+
* @summary Finds all registered handlers for a given target, property, and operation, including from parent classes
|
|
37
|
+
* @template M - Model type extending Model
|
|
38
|
+
* @template R - Repository type extending IRepository
|
|
39
|
+
* @template V - Metadata type
|
|
40
|
+
* @template F - Repository flags extending RepositoryFlags
|
|
41
|
+
* @template C - Context type extending Context<F>
|
|
42
|
+
* @param {string | Record<string, any>} target - The target class name or object
|
|
43
|
+
* @param {string} propKey - The property key to get handlers for
|
|
44
|
+
* @param {string} operation - The operation key to get handlers for
|
|
45
|
+
* @param {OperationHandler[]} [accum] - Accumulator for recursive calls
|
|
46
|
+
* @return {OperationHandler[] | undefined} Array of handlers or undefined if none found
|
|
26
47
|
*/
|
|
27
48
|
get(target, propKey, operation, accum) {
|
|
28
49
|
accum = accum || [];
|
|
@@ -44,11 +65,18 @@ class OperationsRegistry {
|
|
|
44
65
|
return this.get(proto, propKey, operation, accum);
|
|
45
66
|
}
|
|
46
67
|
/**
|
|
47
|
-
* @
|
|
48
|
-
* @
|
|
49
|
-
* @
|
|
50
|
-
* @
|
|
51
|
-
* @
|
|
68
|
+
* @description Registers an operation handler for a specific target and operation
|
|
69
|
+
* @summary Stores a handler in the registry for a given target, property, and operation
|
|
70
|
+
* @template M - Model type extending Model
|
|
71
|
+
* @template R - Repository type extending IRepository
|
|
72
|
+
* @template V - Metadata type
|
|
73
|
+
* @template F - Repository flags extending RepositoryFlags
|
|
74
|
+
* @template C - Context type extending Context<F>
|
|
75
|
+
* @param {OperationHandler} handler - The handler function to register
|
|
76
|
+
* @param {OperationKeys} operation - The operation key to register the handler for
|
|
77
|
+
* @param {M} target - The target model instance
|
|
78
|
+
* @param {string | symbol} propKey - The property key to register the handler for
|
|
79
|
+
* @return {void}
|
|
52
80
|
*/
|
|
53
81
|
register(handler, operation, target, propKey) {
|
|
54
82
|
const name = target.constructor.name;
|
|
@@ -65,4 +93,4 @@ class OperationsRegistry {
|
|
|
65
93
|
}
|
|
66
94
|
}
|
|
67
95
|
exports.OperationsRegistry = OperationsRegistry;
|
|
68
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
96
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiT3BlcmF0aW9uc1JlZ2lzdHJ5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29wZXJhdGlvbnMvT3BlcmF0aW9uc1JlZ2lzdHJ5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUdBLGlEQUEwQztBQUsxQzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBd0JHO0FBQ0gsTUFBYSxrQkFBa0I7SUFBL0I7UUFDbUIsVUFBSyxHQU1sQixFQUFFLENBQUM7SUF1RlQsQ0FBQztJQXJGQzs7Ozs7Ozs7Ozs7OztPQWFHO0lBQ0gsR0FBRyxDQU9ELE1BQW9DLEVBQ3BDLE9BQWUsRUFDZixTQUFpQixFQUNqQixLQUF5QztRQUV6QyxLQUFLLEdBQUcsS0FBSyxJQUFJLEVBQUUsQ0FBQztRQUNwQixJQUFJLElBQUksQ0FBQztRQUNULElBQUksQ0FBQztZQUNILElBQUksR0FBRyxPQUFPLE1BQ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iAgICB0aGlzLmNhY2hlW25hbWVdW3Byb3BLZXldW29wZXJhdGlvbl1baGFuZGxlck5hbWVdID0gaGFuZGxlcjtcbiAgfVxufVxuIl19
|
|
@@ -5,32 +5,60 @@ import { Model } from "@decaf-ts/decorator-validation";
|
|
|
5
5
|
import { Context } from "../repository";
|
|
6
6
|
import { RepositoryFlags } from "../repository/types";
|
|
7
7
|
/**
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
8
|
+
* @description Registry for database operation handlers
|
|
9
|
+
* @summary Manages and stores operation handlers for different model properties and operations
|
|
10
10
|
* @class OperationsRegistry
|
|
11
|
-
* @
|
|
11
|
+
* @template M - Model type
|
|
12
|
+
* @template R - Repository type
|
|
13
|
+
* @template V - Metadata type
|
|
14
|
+
* @template F - Repository flags
|
|
15
|
+
* @template C - Context type
|
|
16
|
+
* @example
|
|
17
|
+
* // Create a registry and register a handler
|
|
18
|
+
* const registry = new OperationsRegistry();
|
|
19
|
+
* registry.register(myHandler, OperationKeys.CREATE, targetModel, 'propertyName');
|
|
12
20
|
*
|
|
13
|
-
*
|
|
21
|
+
* // Get handlers for a specific operation
|
|
22
|
+
* const handlers = registry.get(targetModel.constructor.name, 'propertyName', 'onCreate');
|
|
14
23
|
*
|
|
15
|
-
* @
|
|
24
|
+
* @mermaid
|
|
25
|
+
* classDiagram
|
|
26
|
+
* class OperationsRegistry {
|
|
27
|
+
* -cache: Record~string, Record~string|symbol, Record~string, Record~string, OperationHandler~~~~
|
|
28
|
+
* +get(target, propKey, operation, accum)
|
|
29
|
+
* +register(handler, operation, target, propKey)
|
|
30
|
+
* }
|
|
16
31
|
*/
|
|
17
32
|
export declare class OperationsRegistry {
|
|
18
33
|
private readonly cache;
|
|
19
34
|
/**
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
35
|
+
* @description Retrieves operation handlers for a specific target and operation
|
|
36
|
+
* @summary Finds all registered handlers for a given target, property, and operation, including from parent classes
|
|
37
|
+
* @template M - Model type extending Model
|
|
38
|
+
* @template R - Repository type extending IRepository
|
|
39
|
+
* @template V - Metadata type
|
|
40
|
+
* @template F - Repository flags extending RepositoryFlags
|
|
41
|
+
* @template C - Context type extending Context<F>
|
|
42
|
+
* @param {string | Record<string, any>} target - The target class name or object
|
|
43
|
+
* @param {string} propKey - The property key to get handlers for
|
|
44
|
+
* @param {string} operation - The operation key to get handlers for
|
|
45
|
+
* @param {OperationHandler[]} [accum] - Accumulator for recursive calls
|
|
46
|
+
* @return {OperationHandler[] | undefined} Array of handlers or undefined if none found
|
|
26
47
|
*/
|
|
27
48
|
get<M extends Model, R extends IRepository<M, F, C>, V, F extends RepositoryFlags, C extends Context<F>>(target: string | Record<string, any>, propKey: string, operation: string, accum?: OperationHandler<M, R, V, F, C>[]): OperationHandler<M, R, V, F, C>[] | undefined;
|
|
28
49
|
/**
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
50
|
+
* @description Registers an operation handler for a specific target and operation
|
|
51
|
+
* @summary Stores a handler in the registry for a given target, property, and operation
|
|
52
|
+
* @template M - Model type extending Model
|
|
53
|
+
* @template R - Repository type extending IRepository
|
|
54
|
+
* @template V - Metadata type
|
|
55
|
+
* @template F - Repository flags extending RepositoryFlags
|
|
56
|
+
* @template C - Context type extending Context<F>
|
|
57
|
+
* @param {OperationHandler} handler - The handler function to register
|
|
58
|
+
* @param {OperationKeys} operation - The operation key to register the handler for
|
|
59
|
+
* @param {M} target - The target model instance
|
|
60
|
+
* @param {string | symbol} propKey - The property key to register the handler for
|
|
61
|
+
* @return {void}
|
|
34
62
|
*/
|
|
35
63
|
register<M extends Model, R extends IRepository<M, F, C>, V, F extends RepositoryFlags, C extends Context<F>>(handler: OperationHandler<M, R, V, F, C>, operation: OperationKeys, target: M, propKey: string | symbol): void;
|
|
36
64
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DBOperations = exports.OperationKeys = void 0;
|
|
3
|
+
exports.DBOperations = exports.BulkCrudOperationKeys = exports.OperationKeys = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
5
|
+
* @description Database operation key constants
|
|
6
|
+
* @summary Enum defining CRUD operations and their lifecycle phases
|
|
7
|
+
* @enum {string}
|
|
8
|
+
* @readonly
|
|
9
|
+
* @memberOf module:db-decorators
|
|
9
10
|
*/
|
|
10
11
|
var OperationKeys;
|
|
11
12
|
(function (OperationKeys) {
|
|
@@ -18,11 +19,24 @@ var OperationKeys;
|
|
|
18
19
|
OperationKeys["AFTER"] = "after.";
|
|
19
20
|
})(OperationKeys || (exports.OperationKeys = OperationKeys = {}));
|
|
20
21
|
/**
|
|
22
|
+
* @description Bulk database operation key constants
|
|
23
|
+
* @summary Enum defining bulk CRUD operations for handling multiple records at once
|
|
24
|
+
* @enum {string}
|
|
25
|
+
* @readonly
|
|
26
|
+
* @memberOf module:db-decorators
|
|
27
|
+
*/
|
|
28
|
+
var BulkCrudOperationKeys;
|
|
29
|
+
(function (BulkCrudOperationKeys) {
|
|
30
|
+
BulkCrudOperationKeys["CREATE_ALL"] = "createAll";
|
|
31
|
+
BulkCrudOperationKeys["READ_ALL"] = "readAll";
|
|
32
|
+
BulkCrudOperationKeys["UPDATE_ALL"] = "updateAll";
|
|
33
|
+
BulkCrudOperationKeys["DELETE_ALL"] = "deleteAll";
|
|
34
|
+
})(BulkCrudOperationKeys || (exports.BulkCrudOperationKeys = BulkCrudOperationKeys = {}));
|
|
35
|
+
/**
|
|
36
|
+
* @description Grouped CRUD operations for decorator mapping
|
|
21
37
|
* @summary Maps out groups of CRUD operations for easier mapping of decorators
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
24
|
-
*
|
|
25
|
-
* @memberOf module:db-decorators.Operations
|
|
38
|
+
* @const DBOperations
|
|
39
|
+
* @memberOf module:db-decorators
|
|
26
40
|
*/
|
|
27
41
|
exports.DBOperations = {
|
|
28
42
|
CREATE: [OperationKeys.CREATE],
|
|
@@ -38,4 +52,4 @@ exports.DBOperations = {
|
|
|
38
52
|
OperationKeys.DELETE,
|
|
39
53
|
],
|
|
40
54
|
};
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
55
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29wZXJhdGlvbnMvY29uc3RhbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBOzs7Ozs7R0FNRztBQUNILElBQVksYUFRWDtBQVJELFdBQVksYUFBYTtJQUN2Qix1REFBc0MsQ0FBQTtJQUN0QyxrQ0FBaUIsQ0FBQTtJQUNqQiw4QkFBYSxDQUFBO0lBQ2Isa0NBQWlCLENBQUE7SUFDakIsa0NBQWlCLENBQUE7SUFDakIsMkJBQVUsQ0FBQTtJQUNWLGlDQUFnQixDQUFBO0FBQ2xCLENBQUMsRUFSVyxhQUFhLDZCQUFiLGFBQWEsUUFReEI7QUFjRDs7Ozs7O0dBTUc7QUFDSCxJQUFZLHFCQUtYO0FBTEQsV0FBWSxxQkFBcUI7SUFDL0IsaURBQXdCLENBQUE7SUFDeEIsNkNBQW9CLENBQUE7SUFDcEIsaURBQXdCLENBQUE7SUFDeEIsaURBQXdCLENBQUE7QUFDMUIsQ0FBQyxFQUxXLHFCQUFxQixxQ0FBckIscUJBQXFCLFFBS2hDO0FBY0Q7Ozs7O0dBS0c7QUFDVSxRQUFBLFlBQVksR0FBcUM7SUFDNUQsTUFBTSxFQUFFLENBQUMsYUFBYSxDQUFDLE1BQU0sQ0FBQztJQUM5QixJQUFJLEVBQUUsQ0FBQyx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FJFQURfQ1JFQVRFOiBbT3BlcmF0aW9uS2V5cy5SRUFELCBPcGVyYXRpb25LZXlzLkNSRUFURV0sXG4gIEFMTDogW1xuICAgIE9wZXJhdGlvbktleXMuQ1JFQVRFLFxuICAgIE9wZXJhdGlvbktleXMuUkVBRCxcbiAgICBPcGVyYXRpb25LZXlzLlVQREFURSxcbiAgICBPcGVyYXRpb25LZXlzLkRFTEVURSxcbiAgXSxcbn07XG4iXX0=
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
3
|
-
* @
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
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
|
|
6
7
|
*/
|
|
7
8
|
export declare enum OperationKeys {
|
|
8
9
|
REFLECT = "decaf.model.db.operations.",
|
|
@@ -13,12 +14,37 @@ export declare enum OperationKeys {
|
|
|
13
14
|
ON = "on.",
|
|
14
15
|
AFTER = "after."
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* @description Type for basic CRUD operations
|
|
19
|
+
* @summary Union type of the four basic database operations: create, read, update, delete
|
|
20
|
+
* @typedef {string} CrudOperations
|
|
21
|
+
* @memberOf module:db-decorators
|
|
22
|
+
*/
|
|
16
23
|
export type CrudOperations = OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE;
|
|
17
24
|
/**
|
|
25
|
+
* @description Bulk database operation key constants
|
|
26
|
+
* @summary Enum defining bulk CRUD operations for handling multiple records at once
|
|
27
|
+
* @enum {string}
|
|
28
|
+
* @readonly
|
|
29
|
+
* @memberOf module:db-decorators
|
|
30
|
+
*/
|
|
31
|
+
export declare enum BulkCrudOperationKeys {
|
|
32
|
+
CREATE_ALL = "createAll",
|
|
33
|
+
READ_ALL = "readAll",
|
|
34
|
+
UPDATE_ALL = "updateAll",
|
|
35
|
+
DELETE_ALL = "deleteAll"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @description Type for bulk CRUD operations
|
|
39
|
+
* @summary Union type of the four bulk database operations for handling multiple records at once
|
|
40
|
+
* @typedef {string} BulkCrudOperations
|
|
41
|
+
* @memberOf module:db-decorators
|
|
42
|
+
*/
|
|
43
|
+
export type BulkCrudOperations = BulkCrudOperationKeys.CREATE_ALL | BulkCrudOperationKeys.READ_ALL | BulkCrudOperationKeys.UPDATE_ALL | BulkCrudOperationKeys.DELETE_ALL;
|
|
44
|
+
/**
|
|
45
|
+
* @description Grouped CRUD operations for decorator mapping
|
|
18
46
|
* @summary Maps out groups of CRUD operations for easier mapping of decorators
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
* @memberOf module:db-decorators.Operations
|
|
47
|
+
* @const DBOperations
|
|
48
|
+
* @memberOf module:db-decorators
|
|
23
49
|
*/
|
|
24
50
|
export declare const DBOperations: Record<string, CrudOperations[]>;
|