@decaf-ts/db-decorators 0.16.0 → 0.17.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/index.cjs +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/types/identity/index.d.cts +1 -1
- package/lib/types/identity/index.d.mts +1 -1
- package/lib/types/index.d.cts +8 -8
- package/lib/types/index.d.mts +8 -8
- package/lib/types/interfaces/BulkCrudOperator.d.cts +2 -2
- package/lib/types/interfaces/BulkCrudOperator.d.mts +2 -2
- package/lib/types/interfaces/Contextual.d.cts +2 -2
- package/lib/types/interfaces/Contextual.d.mts +2 -2
- package/lib/types/interfaces/CrudOperator.d.cts +1 -1
- package/lib/types/interfaces/CrudOperator.d.mts +1 -1
- package/lib/types/interfaces/IRepository.d.cts +2 -2
- package/lib/types/interfaces/IRepository.d.mts +2 -2
- package/lib/types/interfaces/index.d.cts +4 -4
- package/lib/types/interfaces/index.d.mts +4 -4
- package/lib/types/model/decorators.d.cts +3 -3
- package/lib/types/model/decorators.d.mts +3 -3
- package/lib/types/model/index.d.cts +4 -4
- package/lib/types/model/index.d.mts +4 -4
- package/lib/types/operations/Operations.d.cts +3 -3
- package/lib/types/operations/Operations.d.mts +3 -3
- package/lib/types/operations/OperationsRegistry.d.cts +3 -3
- package/lib/types/operations/OperationsRegistry.d.mts +3 -3
- package/lib/types/operations/decorators.d.cts +3 -3
- package/lib/types/operations/decorators.d.mts +3 -3
- package/lib/types/operations/index.d.cts +5 -5
- package/lib/types/operations/index.d.mts +5 -5
- package/lib/types/operations/types.d.cts +3 -3
- package/lib/types/operations/types.d.mts +3 -3
- package/lib/types/overrides/Model.d.cts +2 -2
- package/lib/types/overrides/Model.d.mts +2 -2
- package/lib/types/overrides/index.d.cts +4 -4
- package/lib/types/overrides/index.d.mts +4 -4
- package/lib/types/repository/Context.d.cts +4 -4
- package/lib/types/repository/Context.d.mts +4 -4
- package/lib/types/repository/Repository.d.cts +3 -3
- package/lib/types/repository/Repository.d.mts +3 -3
- package/lib/types/repository/constants.d.cts +1 -1
- package/lib/types/repository/constants.d.mts +1 -1
- package/lib/types/repository/index.d.cts +7 -7
- package/lib/types/repository/index.d.mts +7 -7
- package/lib/types/repository/types.d.cts +3 -3
- package/lib/types/repository/types.d.mts +3 -3
- package/lib/types/repository/utils.d.cts +3 -3
- package/lib/types/repository/utils.d.mts +3 -3
- package/lib/types/validation/decorators.d.cts +3 -3
- package/lib/types/validation/decorators.d.mts +3 -3
- package/lib/types/validation/index.d.cts +4 -4
- package/lib/types/validation/index.d.mts +4 -4
- package/lib/types/validation/validators/index.d.cts +3 -3
- package/lib/types/validation/validators/index.d.mts +3 -3
- package/package.json +1 -1
- package/lib/types/identity/decorators.d.ts +0 -8
- package/lib/types/identity/index.d.ts +0 -6
- package/lib/types/index.d.ts +0 -15
- package/lib/types/interfaces/BulkCrudOperator.d.ts +0 -47
- package/lib/types/interfaces/Contextual.d.ts +0 -23
- package/lib/types/interfaces/CrudOperator.d.ts +0 -46
- package/lib/types/interfaces/IRepository.d.ts +0 -19
- package/lib/types/interfaces/index.d.ts +0 -9
- package/lib/types/model/constants.d.ts +0 -37
- package/lib/types/model/decorators.d.ts +0 -145
- package/lib/types/model/index.d.ts +0 -9
- package/lib/types/model/model.d.ts +0 -6
- package/lib/types/model/validation.d.ts +0 -57
- package/lib/types/operations/Operations.d.ts +0 -80
- package/lib/types/operations/OperationsRegistry.d.ts +0 -72
- package/lib/types/operations/constants.d.ts +0 -106
- package/lib/types/operations/decorators.d.ts +0 -348
- package/lib/types/operations/index.d.ts +0 -10
- package/lib/types/operations/types.d.ts +0 -60
- package/lib/types/overrides/Metadata.d.ts +0 -54
- package/lib/types/overrides/Model.d.ts +0 -84
- package/lib/types/overrides/ModelBuilderExtensions.d.ts +0 -15
- package/lib/types/overrides/index.d.ts +0 -10
- package/lib/types/overrides/overrides.d.ts +0 -1
- package/lib/types/repository/Context.d.ts +0 -112
- package/lib/types/repository/Repository.d.ts +0 -352
- package/lib/types/repository/constants.d.ts +0 -9
- package/lib/types/repository/errors.d.ts +0 -126
- package/lib/types/repository/index.d.ts +0 -12
- package/lib/types/repository/types.d.ts +0 -62
- package/lib/types/repository/utils.d.ts +0 -34
- package/lib/types/repository/wrappers.d.ts +0 -39
- package/lib/types/validation/constants.d.ts +0 -45
- package/lib/types/validation/decorators.d.ts +0 -143
- package/lib/types/validation/index.d.ts +0 -4
- package/lib/types/validation/validation.d.ts +0 -41
- package/lib/types/validation/validators/ReadOnlyValidator.d.ts +0 -47
- package/lib/types/validation/validators/TimestampValidator.d.ts +0 -48
- package/lib/types/validation/validators/UpdateValidator.d.ts +0 -40
- package/lib/types/validation/validators/index.d.ts +0 -3
|
@@ -1,106 +0,0 @@
|
|
|
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)[];
|
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import { GeneralOperationHandler, GeneralUpdateOperationHandler, IdOperationHandler, OperationHandler, StandardOperationHandler, UpdateOperationHandler } from "./types";
|
|
2
|
-
import { CrudOperations, OperationKeys, BlockOperationDescriptor, BlockOperationKind, BlockOperationsInput } from "./constants";
|
|
3
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
-
import { IRepository } from "../interfaces";
|
|
5
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
6
|
-
/**
|
|
7
|
-
* @description Represents sorting parameters for grouping decorators
|
|
8
|
-
* @summary Defines the structure for specifying group sorting options
|
|
9
|
-
* @typedef {Object} GroupSort
|
|
10
|
-
* @property {number} priority - The priority of the sorting operation, lower numbers represent higher priority
|
|
11
|
-
* @property {string} [group] - Optional property to group decorators, used for grouping related operations
|
|
12
|
-
* @property {number} [groupPriority] - Optional property to specify the priority within a group, lower numbers represent higher priority within the group
|
|
13
|
-
* @category Type Definitions
|
|
14
|
-
*/
|
|
15
|
-
export type GroupSort = {
|
|
16
|
-
priority: number;
|
|
17
|
-
group?: string;
|
|
18
|
-
groupPriority?: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* @description DecoratorObject type definition
|
|
22
|
-
* @summary Defines the structure of an object used to represent a decorator in the context of database operations.
|
|
23
|
-
* @typedef {Object} DecoratorObject
|
|
24
|
-
* @property {OperationHandler<any, any, any>} handler - The handler function to be executed during the operation
|
|
25
|
-
* @property {object} data - Optional metadata to be passed to the handler function
|
|
26
|
-
* @property {string} prop - The property key to which the decorator is applied
|
|
27
|
-
* @category Type Definitions
|
|
28
|
-
*/
|
|
29
|
-
export type DecoratorObject = {
|
|
30
|
-
handler: OperationHandler<any, any, any>;
|
|
31
|
-
data: Record<string, any>[];
|
|
32
|
-
prop: string[];
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* @summary retrieves the arguments for the handler
|
|
36
|
-
* @param {any} dec the decorator
|
|
37
|
-
* @param {string} prop the property name
|
|
38
|
-
* @param {{}} m the model
|
|
39
|
-
* @param {{}} [accum] accumulator used for internal recursiveness
|
|
40
|
-
*
|
|
41
|
-
* @function getHandlerArgs
|
|
42
|
-
* @memberOf module:db-decorators.Repository
|
|
43
|
-
*/
|
|
44
|
-
export declare const getHandlerArgs: (dec: any, prop: string, m: Constructor<any>, accum?: Record<string, {
|
|
45
|
-
args: string[];
|
|
46
|
-
}>) => Record<string, {
|
|
47
|
-
args: string[];
|
|
48
|
-
}> | void;
|
|
49
|
-
/**
|
|
50
|
-
* @description Retrieves decorator objects for handling database operations
|
|
51
|
-
* @summary Retrieves a list of decorator objects representing operation handlers for a given model and decorators
|
|
52
|
-
* @template M - Type for the model, defaults to Model<true | false>
|
|
53
|
-
* @template R - Type for the repository, defaults to IRepository<M, F, C>
|
|
54
|
-
* @template V - Type for metadata, defaults to object
|
|
55
|
-
* @template F - Type for repository flags, defaults to RepositoryFlags
|
|
56
|
-
* @template C - Type for context, defaults to Context<F>
|
|
57
|
-
* @param {Model} model - The model for which to retrieve decorator objects
|
|
58
|
-
* @param {Record<string, DecoratorMetadata[]>} decorators - The decorators associated with the model properties
|
|
59
|
-
* @param {string} prefix - The operation prefix (e.g., 'on', 'after')
|
|
60
|
-
* @return {DecoratorObject[]} An array of decorator objects representing operation handlers
|
|
61
|
-
* @function getHandlersDecorators
|
|
62
|
-
* @category Function
|
|
63
|
-
*/
|
|
64
|
-
export declare function getHandlersDecorators<M extends Model<true | false>, R extends IRepository<M, any>, V extends object = object>(model: Model, decorators: Record<string, DecoratorMetadata[]>, prefix: string): DecoratorObject[];
|
|
65
|
-
/**
|
|
66
|
-
* @description Groups decorators based on their group property
|
|
67
|
-
* @summary Groups decorator objects by their group property, combining data and properties within each group
|
|
68
|
-
* @param {DecoratorObject[]} decorators - The array of decorator objects to group
|
|
69
|
-
* @return {DecoratorObject[]} An array of grouped decorator objects
|
|
70
|
-
* @function groupDecorators
|
|
71
|
-
* @category Function
|
|
72
|
-
*/
|
|
73
|
-
export declare function groupDecorators(decorators: DecoratorObject[]): DecoratorObject[];
|
|
74
|
-
/**
|
|
75
|
-
* @description Sorts decorator objects based on their priority
|
|
76
|
-
* @summary Sorts an array of decorator objects by the priority of their first data element
|
|
77
|
-
* @param {DecoratorObject[]} decorators - The array of decorator objects to sort
|
|
78
|
-
* @return {DecoratorObject[]} The sorted array of decorator objects
|
|
79
|
-
* @function sortDecorators
|
|
80
|
-
* @category Function
|
|
81
|
-
*/
|
|
82
|
-
export declare function sortDecorators(decorators: DecoratorObject[]): DecoratorObject[];
|
|
83
|
-
/**
|
|
84
|
-
* @description Decorator for handling create and update operations
|
|
85
|
-
* @summary Defines a behavior to execute during both create and update operations
|
|
86
|
-
* @template V - Type for metadata, defaults to object
|
|
87
|
-
* @param {GeneralOperationHandler<any, any, V, any, any> | GeneralUpdateOperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
88
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
89
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
90
|
-
* @function onCreateUpdate
|
|
91
|
-
* @category Property Decorators
|
|
92
|
-
*/
|
|
93
|
-
export declare function onCreateUpdate<V = object>(handler: GeneralOperationHandler<any, any, V> | GeneralUpdateOperationHandler<any, any, V>, data?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
94
|
-
/**
|
|
95
|
-
* @description Decorator for handling update operations
|
|
96
|
-
* @summary Defines a behavior to execute during update operations
|
|
97
|
-
* @template V - Type for metadata, defaults to object
|
|
98
|
-
* @param {UpdateOperationHandler<any, any, V, any>} handler - The method called upon the operation
|
|
99
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
100
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
101
|
-
* @function onUpdate
|
|
102
|
-
* @category Property Decorators
|
|
103
|
-
*/
|
|
104
|
-
export declare function onUpdate<V = object>(handler: UpdateOperationHandler<any, any, V>, data?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
105
|
-
/**
|
|
106
|
-
* @description Decorator for handling create operations
|
|
107
|
-
* @summary Defines a behavior to execute during create operations
|
|
108
|
-
* @template V - Type for metadata, defaults to object
|
|
109
|
-
* @param {GeneralOperationHandler<any, any, V>} handler - The method called upon the operation
|
|
110
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
111
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
112
|
-
* @function onCreate
|
|
113
|
-
* @category Property Decorators
|
|
114
|
-
*/
|
|
115
|
-
export declare function onCreate<V = object>(handler: GeneralOperationHandler<any, any, V>, data?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
116
|
-
/**
|
|
117
|
-
* @description Decorator for handling read operations
|
|
118
|
-
* @summary Defines a behavior to execute during read operations
|
|
119
|
-
* @template V - Type for metadata, defaults to object
|
|
120
|
-
* @param {IdOperationHandler<any, any, V>} handler - The method called upon the operation
|
|
121
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
122
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
123
|
-
* @function onRead
|
|
124
|
-
* @category Property Decorators
|
|
125
|
-
*/
|
|
126
|
-
export declare function onRead<V = object>(handler: IdOperationHandler<any, any, V>, data: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
127
|
-
/**
|
|
128
|
-
* @description Decorator for handling delete operations
|
|
129
|
-
* @summary Defines a behavior to execute during delete operations
|
|
130
|
-
* @template V - Type for metadata, defaults to object
|
|
131
|
-
* @param {OperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
132
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
133
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
134
|
-
* @function onDelete
|
|
135
|
-
* @category Property Decorators
|
|
136
|
-
*/
|
|
137
|
-
export declare function onDelete<V = object>(handler: OperationHandler<any, any, V>, data: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
138
|
-
/**
|
|
139
|
-
* @description Decorator for handling all operation types
|
|
140
|
-
* @summary Defines a behavior to execute during any database operation
|
|
141
|
-
* @template V - Type for metadata, defaults to object
|
|
142
|
-
* @param {OperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
143
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
144
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
145
|
-
* @function onAny
|
|
146
|
-
* @category Property Decorators
|
|
147
|
-
*/
|
|
148
|
-
export declare function onAny<V = object>(handler: OperationHandler<any, any, V>, data: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
149
|
-
/**
|
|
150
|
-
* @description Base decorator for handling database operations
|
|
151
|
-
* @summary Defines a behavior to execute during specified database operations
|
|
152
|
-
* @template V - Type for metadata, defaults to object
|
|
153
|
-
* @param {OperationKeys[] | DBOperations} [op=DBOperations.ALL] - One or more operation types to handle
|
|
154
|
-
* @param {OperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
155
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
156
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
157
|
-
* @function on
|
|
158
|
-
* @category Property Decorators
|
|
159
|
-
* @example
|
|
160
|
-
* // Example usage:
|
|
161
|
-
* class MyModel {
|
|
162
|
-
* @on(DBOperations.CREATE, myHandler)
|
|
163
|
-
* myProperty: string;
|
|
164
|
-
* }
|
|
165
|
-
*/
|
|
166
|
-
export declare function on<V = object>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, V>, data?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
167
|
-
/**
|
|
168
|
-
* @description Decorator for handling post-create and post-update operations
|
|
169
|
-
* @summary Defines a behavior to execute after both create and update operations
|
|
170
|
-
* @template V - Type for metadata, defaults to object
|
|
171
|
-
* @param {StandardOperationHandler<any, any, V> | UpdateOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
172
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
173
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
174
|
-
* @function afterCreateUpdate
|
|
175
|
-
* @category Property Decorators
|
|
176
|
-
*/
|
|
177
|
-
export declare function afterCreateUpdate<V = object>(handler: StandardOperationHandler<any, any, V> | UpdateOperationHandler<any, any, V>, data: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
178
|
-
/**
|
|
179
|
-
* @description Decorator for handling post-update operations
|
|
180
|
-
* @summary Defines a behavior to execute after update operations
|
|
181
|
-
* @template V - Type for metadata, defaults to object
|
|
182
|
-
* @param {UpdateOperationHandler<any, any, V>} handler - The method called after the operation
|
|
183
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
184
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
185
|
-
* @function afterUpdate
|
|
186
|
-
* @category Property Decorators
|
|
187
|
-
*/
|
|
188
|
-
export declare function afterUpdate<V = object>(handler: UpdateOperationHandler<any, any, V>, data: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
189
|
-
/**
|
|
190
|
-
* @description Decorator for handling post-create operations
|
|
191
|
-
* @summary Defines a behavior to execute after create operations
|
|
192
|
-
* @template V - Type for metadata, defaults to object
|
|
193
|
-
* @param {StandardOperationHandler<any, any, V>} handler - The method called after the operation
|
|
194
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
195
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
196
|
-
* @function afterCreate
|
|
197
|
-
* @category Property Decorators
|
|
198
|
-
*/
|
|
199
|
-
export declare function afterCreate<V = object>(handler: StandardOperationHandler<any, any, V>, data: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
200
|
-
/**
|
|
201
|
-
* @description Decorator for handling post-read operations
|
|
202
|
-
* @summary Defines a behavior to execute after read operations
|
|
203
|
-
* @template V - Type for metadata, defaults to object
|
|
204
|
-
* @param {StandardOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
205
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
206
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
207
|
-
* @function afterRead
|
|
208
|
-
* @category Property Decorators
|
|
209
|
-
*/
|
|
210
|
-
export declare function afterRead<V = object>(handler: StandardOperationHandler<any, any, V>, data?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
211
|
-
/**
|
|
212
|
-
* @description Decorator for handling post-delete operations
|
|
213
|
-
* @summary Defines a behavior to execute after delete operations
|
|
214
|
-
* @template V - Type for metadata, defaults to object
|
|
215
|
-
* @param {StandardOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
216
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
217
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
218
|
-
* @function afterDelete
|
|
219
|
-
* @category Property Decorators
|
|
220
|
-
*/
|
|
221
|
-
export declare function afterDelete<V = object>(handler: StandardOperationHandler<any, any, V>, data?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
222
|
-
/**
|
|
223
|
-
* @description Decorator for handling post-operation for all operation types
|
|
224
|
-
* @summary Defines a behavior to execute after any database operation
|
|
225
|
-
* @template V - Type for metadata, defaults to object
|
|
226
|
-
* @param {StandardOperationHandler<any, any, V>} handler - The method called after the operation
|
|
227
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
228
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
229
|
-
* @function afterAny
|
|
230
|
-
* @category Property Decorators
|
|
231
|
-
*/
|
|
232
|
-
export declare function afterAny<V = object>(handler: StandardOperationHandler<any, any, V>, data?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
233
|
-
/**
|
|
234
|
-
* @description Base decorator for handling post-operation behaviors
|
|
235
|
-
* @summary Defines a behavior to execute after specified database operations
|
|
236
|
-
* @template V - Type for metadata, defaults to object
|
|
237
|
-
* @param {OperationKeys[] | DBOperations} [op=DBOperations.ALL] - One or more operation types to handle
|
|
238
|
-
* @param {OperationHandler<any, any, Vy>} handler - The method called after the operation
|
|
239
|
-
* @param {V} [data] - Optional metadata to pass to the handler
|
|
240
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
241
|
-
* @function after
|
|
242
|
-
* @category Property Decorators
|
|
243
|
-
* @example
|
|
244
|
-
* // Example usage:
|
|
245
|
-
* class MyModel {
|
|
246
|
-
* @after(DBOperations.CREATE, myHandler)
|
|
247
|
-
* myProperty: string;
|
|
248
|
-
* }
|
|
249
|
-
*/
|
|
250
|
-
export declare function after<V = object>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, V>, data?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
251
|
-
/**
|
|
252
|
-
* @description Core decorator factory for operation handlers
|
|
253
|
-
* @summary Creates decorators that register handlers for database operations
|
|
254
|
-
* @template V - Type for metadata, defaults to object
|
|
255
|
-
* @param {OperationKeys.ON | OperationKeys.AFTER} baseOp - Whether the handler runs during or after the operation
|
|
256
|
-
* @param {OperationKeys[]} [operation=DBOperations.ALL] - The specific operations to handle
|
|
257
|
-
* @param {OperationHandler<any, any, V>} handler - The handler function to execute
|
|
258
|
-
* @param {V} [dataToAdd] - Optional metadata to pass to the handler
|
|
259
|
-
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
260
|
-
* @function operation
|
|
261
|
-
* @category Property Decorators
|
|
262
|
-
* @mermaid
|
|
263
|
-
* sequenceDiagram
|
|
264
|
-
* participant Client
|
|
265
|
-
* participant Decorator as @operation
|
|
266
|
-
* participant Operations as Operations Registry
|
|
267
|
-
* participant Handler
|
|
268
|
-
*
|
|
269
|
-
* Client->>Decorator: Apply to property
|
|
270
|
-
* Decorator->>Operations: Register handler
|
|
271
|
-
* Decorator->>Decorator: Store metadata
|
|
272
|
-
*
|
|
273
|
-
* Note over Client,Handler: Later, during operation execution
|
|
274
|
-
* Client->>Operations: Execute operation
|
|
275
|
-
* Operations->>Handler: Call registered handler
|
|
276
|
-
* Handler-->>Operations: Return result
|
|
277
|
-
* Operations-->>Client: Return final result
|
|
278
|
-
*/
|
|
279
|
-
export declare function operation<V = object>(baseOp: OperationKeys.ON | OperationKeys.AFTER, operation: OperationKeys[] | undefined, handler: OperationHandler<any, any, V>, dataToAdd?: V, groupsort?: GroupSort): (target: any, propertyKey?: any) => void;
|
|
280
|
-
/**
|
|
281
|
-
* @description
|
|
282
|
-
* Creates a higher-order function that attaches a metadata entry containing a handler
|
|
283
|
-
* and its execution parameters, to be conditionally evaluated later.
|
|
284
|
-
*
|
|
285
|
-
* @summary
|
|
286
|
-
* The `executeIf` function is a decorator factory designed to wrap a handler function
|
|
287
|
-
* and associate it with a specific metadata key. When invoked, it stores both the
|
|
288
|
-
* parameters passed and the handler reference inside the metadata system for deferred
|
|
289
|
-
* or conditional evaluation. This is particularly useful for dynamically applying logic
|
|
290
|
-
* or decorators only when certain conditions are met.
|
|
291
|
-
*
|
|
292
|
-
* @template P - Represents a tuple of any parameter types that the handler function accepts.
|
|
293
|
-
*
|
|
294
|
-
* @param {string} key - The metadata key used to store and later retrieve the handler and its parameters.
|
|
295
|
-
* @param {function(...P):boolean} handler - A predicate or handler function that receives the same parameters as the decorator
|
|
296
|
-
* and determines whether the associated logic should execute.
|
|
297
|
-
*
|
|
298
|
-
* @return {function(...P):function(...Partial<P>):void}
|
|
299
|
-
* Returns a function that, when invoked with the given parameters, stores a metadata object containing
|
|
300
|
-
* both the parameters and the handler reference under the provided key.
|
|
301
|
-
*
|
|
302
|
-
* @function storeHandlerMetadata
|
|
303
|
-
*
|
|
304
|
-
* @mermaid
|
|
305
|
-
* sequenceDiagram
|
|
306
|
-
* participant Dev as Developer
|
|
307
|
-
* participant executeIf as executeIf()
|
|
308
|
-
* participant ReturnedFn as Returned Function
|
|
309
|
-
* participant Metadata as metadata()
|
|
310
|
-
*
|
|
311
|
-
* Dev->>executeIf: Calls executeIf(key, handler)
|
|
312
|
-
* executeIf->>ReturnedFn: Returns function(...params)
|
|
313
|
-
* Dev->>ReturnedFn: Invokes returned function with (...params)
|
|
314
|
-
* ReturnedFn->>Metadata: Calls metadata(key, { args: params, handler })
|
|
315
|
-
* Metadata-->>ReturnedFn: Returns stored metadata reference
|
|
316
|
-
* ReturnedFn-->>Dev: Returns metadata response
|
|
317
|
-
*
|
|
318
|
-
*/
|
|
319
|
-
export declare function storeHandlerMetadata<P extends any[]>(key: string, handler: (...params: P) => boolean): (...params: Partial<P>) => (model: any, prop?: any, descriptor?: PropertyDescriptor | number) => void;
|
|
320
|
-
export declare const BlockOperations: (operations: BlockOperationsInput) => (model: any, prop?: any, descriptor?: PropertyDescriptor | number) => void;
|
|
321
|
-
/**
|
|
322
|
-
* @description
|
|
323
|
-
* Decorator factory that conditionally blocks specific CRUD operations
|
|
324
|
-
* from being executed on a model or controller.
|
|
325
|
-
*
|
|
326
|
-
* @summary
|
|
327
|
-
* The `BlockOperations` decorator integrates with the `executeIf` mechanism to
|
|
328
|
-
* associate metadata that defines which CRUD operations should be restricted.
|
|
329
|
-
* When applied, it registers a conditional handler that evaluates whether a given
|
|
330
|
-
* operation is included in the list of blocked operations. This enables dynamic,
|
|
331
|
-
* metadata-driven control over allowed operations in CRUD-based systems.
|
|
332
|
-
*
|
|
333
|
-
* @template CrudOperations - Enum or type representing valid CRUD operations.
|
|
334
|
-
*
|
|
335
|
-
* @param {function(any[]): boolean} handler - An array of CRUD operations that should be blocked.
|
|
336
|
-
* The handler will later check if the requested operation is part of this list.
|
|
337
|
-
*
|
|
338
|
-
* Returns a decorator that stores metadata indicating which operations are blocked.
|
|
339
|
-
* The metadata can be inspected or enforced later within the application's lifecycle.
|
|
340
|
-
*
|
|
341
|
-
* @function BlockOperationIf
|
|
342
|
-
|
|
343
|
-
* @category decorators
|
|
344
|
-
*/
|
|
345
|
-
type LegacyBlockOperationHandler = (operations: CrudOperations[], operation: CrudOperations) => boolean;
|
|
346
|
-
type BlockOperationIfHandler = (targets: BlockOperationDescriptor[], kind: BlockOperationKind, value: string) => boolean;
|
|
347
|
-
export declare const BlockOperationIf: (handler: LegacyBlockOperationHandler | BlockOperationIfHandler) => (model: any, prop?: any, descriptor?: PropertyDescriptor | number) => void;
|
|
348
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description Exports for the operations module.
|
|
3
|
-
* @summary This file exports all the necessary components for the operations functionality, including constants, decorators, and the Operations class.
|
|
4
|
-
* @module db-decorators/operations
|
|
5
|
-
*/
|
|
6
|
-
export * from "./constants";
|
|
7
|
-
export * from "./decorators";
|
|
8
|
-
export * from "./Operations";
|
|
9
|
-
export * from "./OperationsRegistry";
|
|
10
|
-
export * from "./types";
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { OperationKeys } from "./constants";
|
|
2
|
-
import { IRepository } from "../interfaces/IRepository";
|
|
3
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
-
import { ContextOfRepository } from "../repository/index";
|
|
5
|
-
/**
|
|
6
|
-
* @description Metadata for database operations
|
|
7
|
-
* @summary Contains information about an operation, its handler, and associated metadata
|
|
8
|
-
* @template V - Type of the metadata
|
|
9
|
-
* @typedef {Object} OperationMetadata
|
|
10
|
-
* @property {OperationKeys} operation - The type of operation
|
|
11
|
-
* @property {string} handler - The name of the handler function
|
|
12
|
-
* @property {V} [metadata] - Optional metadata associated with the operation
|
|
13
|
-
* @memberOf module:db-decorators
|
|
14
|
-
*/
|
|
15
|
-
export type OperationMetadata<V> = {
|
|
16
|
-
operation: OperationKeys;
|
|
17
|
-
handler: string;
|
|
18
|
-
metadata?: V;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* @description Union type for all operation handler types
|
|
22
|
-
* @summary Represents any type of operation handler function that can be used with database operations
|
|
23
|
-
* @template M - Model type extending Model
|
|
24
|
-
* @template R - Repository type extending IRepository
|
|
25
|
-
* @template V - Metadata type, defaults to object
|
|
26
|
-
* @template F - Repository flags extending RepositoryFlags
|
|
27
|
-
* @template C - Context type extending Context<F>
|
|
28
|
-
* @memberOf module:db-decorators
|
|
29
|
-
*/
|
|
30
|
-
export type OperationHandler<M extends Model, R extends IRepository<M, any>, V = object> = StandardOperationHandler<M, R, V> | UpdateOperationHandler<M, R, V> | IdOperationHandler<M, R, V> | GroupOperationHandler<M, R, V> | GroupUpdateOperationHandler<M, R, V>;
|
|
31
|
-
export type StandardOperationHandler<M extends Model, R extends IRepository<M, any>, V = object> = (this: R, context: ContextOfRepository<R>, metadata: V, key: keyof M, model: M) => Promise<void> | void;
|
|
32
|
-
export type IdOperationHandler<M extends Model, R extends IRepository<M, any>, V = object> = (this: R, context: ContextOfRepository<R>, decorator: V, key: keyof M, id: string) => Promise<void> | void;
|
|
33
|
-
export type UpdateOperationHandler<M extends Model, R extends IRepository<M, any>, V = object> = (this: R, context: ContextOfRepository<R>, decorator: V, key: keyof M, model: M, oldModel: M) => Promise<void> | void;
|
|
34
|
-
export type GroupOperationHandler<M extends Model, R extends IRepository<M, any>, V = object> = (this: R, context: ContextOfRepository<R>, metadata: V[], keys: (keyof M)[], model: M) => Promise<void> | void;
|
|
35
|
-
export type GroupUpdateOperationHandler<M extends Model, R extends IRepository<M, any>, V = object> = (this: R, context: ContextOfRepository<R>, decorator: V[], keys: (keyof M)[], model: M, oldModel: M) => Promise<void> | void;
|
|
36
|
-
/**
|
|
37
|
-
* @description General handler type for database operations
|
|
38
|
-
* @summary Function signature for handlers that process operations like create and read
|
|
39
|
-
* @template M - Model type extending Model
|
|
40
|
-
* @template R - Repository type extending IRepository
|
|
41
|
-
* @template V - Metadata type, defaults to object
|
|
42
|
-
* @template F - Repository flags extending RepositoryFlags
|
|
43
|
-
* @template C - Context type extending Context<F>
|
|
44
|
-
* @typedef {Function} GeneralOperationHandler
|
|
45
|
-
* @return {Promise<void> | void} Nothing or a Promise resolving to nothing
|
|
46
|
-
* @memberOf module:db-decorators
|
|
47
|
-
*/
|
|
48
|
-
export type GeneralOperationHandler<M extends Model, R extends IRepository<M, any>, V = object> = StandardOperationHandler<M, R, V> | GroupOperationHandler<M, R, V>;
|
|
49
|
-
/**
|
|
50
|
-
* @description General handler type for group update database operations
|
|
51
|
-
* @summary Function signature for handlers that process update operations with both new and old model states
|
|
52
|
-
* @template M - Model type extending Model
|
|
53
|
-
* @template R - Repository type extending IRepository
|
|
54
|
-
* @template V - Metadata type, defaults to object
|
|
55
|
-
* @template F - Repository flags extending RepositoryFlags
|
|
56
|
-
* @template C - Context type extending Context<F>
|
|
57
|
-
* @typedef {Function} GeneralUpdateOperationHandler
|
|
58
|
-
* @memberOf module:db-decorators
|
|
59
|
-
*/
|
|
60
|
-
export type GeneralUpdateOperationHandler<M extends Model, R extends IRepository<M, any>, V = object> = UpdateOperationHandler<M, R, V> | GroupUpdateOperationHandler<M, R, V>;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import "@decaf-ts/decoration";
|
|
2
|
-
import type { Constructor } from "@decaf-ts/decoration";
|
|
3
|
-
import type { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
-
declare module "@decaf-ts/decoration" {
|
|
5
|
-
namespace Metadata {
|
|
6
|
-
/**
|
|
7
|
-
* @description Saves metadata under a key for a specific operation
|
|
8
|
-
* @summary Saves metadata under a key for a specific operation
|
|
9
|
-
*
|
|
10
|
-
* @template M - The model type extending from Model
|
|
11
|
-
* @param {Constructor<M>} model - The constructor of the target model class
|
|
12
|
-
* @param {keyof M} propertyKey - The property key to store metadata for
|
|
13
|
-
* @param {string} operation - The type of operation being done. Eg. on.update
|
|
14
|
-
* @param {any} metadata - The metadata to store to for the operation
|
|
15
|
-
* @return {void}
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* class User extends Model {
|
|
19
|
-
*
|
|
20
|
-
* // Set metatada for 'User' for key updatedOn, for operation on.create
|
|
21
|
-
* Metadata.saveOperation(User.constructor,'updatedOn','on.create',metadata);
|
|
22
|
-
*/
|
|
23
|
-
function saveOperation<M extends Model>(model: Constructor<M>, propertyKey: keyof M, operation: string, metadata: any): void;
|
|
24
|
-
function pk<M extends Model<boolean>>(model: M | Constructor<M>): keyof M;
|
|
25
|
-
function pk<M extends Model<boolean>>(model: M, keyValue: boolean): M[keyof M];
|
|
26
|
-
function pk<M extends Model<boolean>>(model: M | Constructor<M>, keyValue?: boolean): keyof M | M[keyof M];
|
|
27
|
-
/**
|
|
28
|
-
* @description Reads the metadata under a key for a specific operation
|
|
29
|
-
* @summary Reads the metadata under a key for a specific operation
|
|
30
|
-
*
|
|
31
|
-
* @template M - The model type extending from Model
|
|
32
|
-
* @param {Constructor<M>} model - The constructor of the target model class
|
|
33
|
-
* @param {keyof M} propertyKey - The property key to store metadata for
|
|
34
|
-
* @param {string} operation - The type of operation being done. Eg. on.update
|
|
35
|
-
* @return {any} metadata - The metadata to store to for the operation
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* class User extends Model {
|
|
39
|
-
*
|
|
40
|
-
* // Get metatada for 'User' for key updatedOn, for operation on.create
|
|
41
|
-
* const metadata = Metadata.readOperation(User.constructor,'updatedOn','on.create');
|
|
42
|
-
*/
|
|
43
|
-
function readOperation<M extends Model>(model: Constructor<M>, propertyKey?: keyof M, operation?: string): any;
|
|
44
|
-
/**
|
|
45
|
-
* @description Checks if a model is marked as transient
|
|
46
|
-
* @summary Determines whether a model class has been decorated with the transient decorator
|
|
47
|
-
* @template M - Type extending Model
|
|
48
|
-
* @param {M | Constructor<M>} model - The model instance to check
|
|
49
|
-
* @return {boolean} True if the model is transient, false otherwise
|
|
50
|
-
* @function isTransient
|
|
51
|
-
*/
|
|
52
|
-
function isTransient<M extends Model>(model: M | Constructor<M>): boolean;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
2
|
-
import "@decaf-ts/decorator-validation";
|
|
3
|
-
import { ComposedFromMetadata } from "../model/index";
|
|
4
|
-
import { Context } from "../repository/index";
|
|
5
|
-
declare module "@decaf-ts/decorator-validation" {
|
|
6
|
-
interface Model {
|
|
7
|
-
isTransient(): boolean;
|
|
8
|
-
segregate<M extends Model<boolean>>(this: M): {
|
|
9
|
-
model: M;
|
|
10
|
-
transient?: Record<keyof M, M[keyof M]>;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
namespace Model {
|
|
14
|
-
/**
|
|
15
|
-
* @description Retrieves primary key information for a model
|
|
16
|
-
* @summary Retrieves primary key information or it's value for a model from it's metadata.
|
|
17
|
-
*
|
|
18
|
-
* @template model - The model type extending from Model
|
|
19
|
-
* @param {M | Constructor<M>} model - The model class or it's constructor
|
|
20
|
-
* @param {boolean} keyValue - Optional keyValue flag, to return the value of the id instead of the property. Does not work with constructor.
|
|
21
|
-
* @return {any} The property of the id of the model, or it's value
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* class User extends Model {
|
|
25
|
-
*
|
|
26
|
-
* const idProp = Model.pk(newModel);
|
|
27
|
-
* const id = Model.pk(newModel, true);
|
|
28
|
-
*/
|
|
29
|
-
function pk<M extends Model<boolean>>(model: M | Constructor<M>): keyof M;
|
|
30
|
-
function pk<M extends Model<boolean>>(model: M, keyValue: boolean): M[keyof M];
|
|
31
|
-
function pk<M extends Model<boolean>>(model: M | Constructor<M>, keyValue?: boolean): keyof M | M[keyof M];
|
|
32
|
-
function pkProps<M extends Model<boolean>>(model: Constructor<M>): any;
|
|
33
|
-
function isTransient<M extends Model<boolean>>(model: M | Constructor<M>): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* @description Separates transient properties from a model
|
|
36
|
-
* @summary Extracts properties marked as transient into a separate object
|
|
37
|
-
* @template M - Type extending Model
|
|
38
|
-
* @param {M} model - The model instance to process
|
|
39
|
-
* @return {Object} Object containing the model without transient properties and a separate transient object
|
|
40
|
-
* @property {M} model - The model with transient properties removed
|
|
41
|
-
* @property {Record<string, any>} [transient] - Object containing the transient properties
|
|
42
|
-
* @function segregate
|
|
43
|
-
* @mermaid
|
|
44
|
-
* sequenceDiagram
|
|
45
|
-
* participant Caller
|
|
46
|
-
* participant modelToTransient
|
|
47
|
-
* participant isTransient
|
|
48
|
-
* participant Metadata.validatableProperties
|
|
49
|
-
*
|
|
50
|
-
* Caller->>modelToTransient: model
|
|
51
|
-
* modelToTransient->>isTransient: check if model is transient
|
|
52
|
-
* isTransient-->>modelToTransient: transient status
|
|
53
|
-
* alt model is not transient
|
|
54
|
-
* modelToTransient-->>Caller: {model}
|
|
55
|
-
* else model is transient
|
|
56
|
-
* modelToTransient->>Metadata.validatableProperties: get decorated properties, combine with model props
|
|
57
|
-
* modelToTransient->>get transient properties from Metadata
|
|
58
|
-
* modelToTransient->>modelToTransient: separate properties
|
|
59
|
-
* modelToTransient->>Model.build: rebuild model without transient props
|
|
60
|
-
* modelToTransient-->>Caller: {model, transient}
|
|
61
|
-
* end
|
|
62
|
-
*/
|
|
63
|
-
function segregate<M extends Model<boolean>>(model: M): {
|
|
64
|
-
model: M;
|
|
65
|
-
transient?: Record<keyof M, M[keyof M]>;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* @description Merges two model instances into a new instance.
|
|
69
|
-
* @summary Creates a new model instance by combining properties from an old model and a new model.
|
|
70
|
-
* Properties from the new model override properties from the old model if they are defined.
|
|
71
|
-
* @param {M} oldModel - The original model instance
|
|
72
|
-
* @param {M} model - The new model instance with updated properties
|
|
73
|
-
* @return {M} A new model instance with merged properties
|
|
74
|
-
*/
|
|
75
|
-
function merge<M extends Model<boolean>>(oldModel: M, newModel: M, constructor?: Constructor<M>): M;
|
|
76
|
-
function composed<M extends Model<boolean>>(model: Constructor<M>): boolean;
|
|
77
|
-
function composed<M extends Model<boolean>>(model: Constructor<M> | M, prop: keyof M): ComposedFromMetadata | undefined;
|
|
78
|
-
function composed<M extends Model<boolean>>(model: Constructor<M> | M, prop?: keyof M): boolean | ComposedFromMetadata | undefined;
|
|
79
|
-
function generated<M extends Model>(model: M | Constructor<M>, prop: keyof M): boolean | string;
|
|
80
|
-
function shouldGenerate<M extends Model>(model: M, prop: keyof M, ctx: Context<any>): boolean;
|
|
81
|
-
function versionProp<M extends Model<boolean>>(model: M): keyof M;
|
|
82
|
-
function versionOf<M extends Model<boolean>>(model: M): number;
|
|
83
|
-
}
|
|
84
|
-
}
|