@decaf-ts/core 0.5.0 → 0.5.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 +652 -15
- package/dist/core.cjs +2638 -1085
- package/dist/core.esm.cjs +2636 -1070
- package/lib/esm/identity/decorators.d.ts +52 -14
- package/lib/esm/identity/decorators.js +54 -16
- package/lib/esm/identity/utils.d.ts +20 -1
- package/lib/esm/identity/utils.js +22 -2
- package/lib/esm/index.d.ts +11 -15
- package/lib/esm/index.js +17 -19
- package/lib/esm/interfaces/ErrorParser.d.ts +12 -0
- package/lib/esm/interfaces/ErrorParser.js +1 -1
- package/lib/esm/interfaces/Executor.d.ts +10 -13
- package/lib/esm/interfaces/Executor.js +1 -1
- package/lib/esm/interfaces/Observable.d.ts +20 -18
- package/lib/esm/interfaces/Observable.js +1 -1
- package/lib/esm/interfaces/Observer.d.ts +7 -8
- package/lib/esm/interfaces/Observer.js +1 -1
- package/lib/esm/interfaces/Paginatable.d.ts +18 -2
- package/lib/esm/interfaces/Paginatable.js +1 -1
- package/lib/esm/interfaces/Queriable.d.ts +44 -3
- package/lib/esm/interfaces/Queriable.js +1 -1
- package/lib/esm/interfaces/RawExecutor.d.ts +10 -13
- package/lib/esm/interfaces/RawExecutor.js +1 -1
- package/lib/esm/interfaces/SequenceOptions.d.ts +50 -5
- package/lib/esm/interfaces/SequenceOptions.js +19 -1
- package/lib/esm/interfaces/index.d.ts +0 -1
- package/lib/esm/interfaces/index.js +1 -2
- package/lib/esm/model/BaseModel.d.ts +31 -0
- package/lib/esm/model/BaseModel.js +24 -1
- package/lib/esm/model/construction.d.ts +442 -9
- package/lib/esm/model/construction.js +441 -2
- package/lib/esm/model/decorators.d.ts +166 -42
- package/lib/esm/model/decorators.js +161 -37
- package/lib/esm/model/index.js +1 -2
- package/lib/esm/model/types.d.ts +9 -0
- package/lib/esm/model/types.js +1 -1
- package/lib/esm/persistence/Adapter.d.ts +384 -40
- package/lib/esm/persistence/Adapter.js +415 -59
- package/lib/esm/persistence/Dispatch.d.ts +131 -0
- package/lib/esm/persistence/Dispatch.js +187 -0
- package/lib/esm/persistence/ObserverHandler.d.ts +109 -0
- package/lib/esm/persistence/ObserverHandler.js +137 -0
- package/lib/esm/persistence/Sequence.d.ts +89 -8
- package/lib/esm/persistence/Sequence.js +91 -1
- package/lib/esm/persistence/constants.d.ts +22 -5
- package/lib/esm/persistence/constants.js +23 -7
- package/lib/esm/persistence/decorators.d.ts +10 -0
- package/lib/esm/persistence/decorators.js +11 -1
- package/lib/esm/persistence/errors.d.ts +23 -3
- package/lib/esm/persistence/errors.js +25 -7
- package/lib/esm/persistence/index.d.ts +3 -0
- package/lib/esm/persistence/index.js +4 -1
- package/lib/esm/persistence/types.d.ts +21 -0
- package/lib/esm/persistence/types.js +2 -0
- package/lib/esm/query/Condition.d.ts +88 -44
- package/lib/esm/query/Condition.js +144 -62
- package/lib/esm/query/Paginator.d.ts +67 -10
- package/lib/esm/query/Paginator.js +64 -10
- package/lib/esm/query/Statement.d.ts +82 -47
- package/lib/esm/query/Statement.js +175 -122
- package/lib/esm/query/constants.d.ts +25 -64
- package/lib/esm/query/constants.js +26 -68
- package/lib/esm/query/errors.d.ts +14 -0
- package/lib/esm/query/errors.js +15 -1
- package/lib/esm/query/index.d.ts +0 -5
- package/lib/esm/query/index.js +1 -6
- package/lib/esm/query/options.d.ts +69 -178
- package/lib/esm/query/options.js +1 -1
- package/lib/esm/query/selectors.d.ts +20 -24
- package/lib/esm/query/selectors.js +1 -1
- package/lib/esm/ram/RamAdapter.d.ts +322 -20
- package/lib/esm/ram/RamAdapter.js +360 -140
- package/lib/esm/ram/RamContext.d.ts +16 -1
- package/lib/esm/ram/RamContext.js +18 -3
- package/lib/esm/ram/RamPaginator.d.ts +51 -6
- package/lib/esm/ram/RamPaginator.js +58 -6
- package/lib/esm/ram/RamSequence.d.ts +49 -24
- package/lib/esm/ram/RamSequence.js +52 -40
- package/lib/esm/ram/RamStatement.d.ts +84 -6
- package/lib/esm/ram/RamStatement.js +175 -6
- package/lib/esm/ram/constants.d.ts +9 -0
- package/lib/esm/ram/constants.js +10 -0
- package/lib/esm/ram/handlers.d.ts +25 -0
- package/lib/esm/ram/handlers.js +27 -0
- package/lib/esm/ram/index.d.ts +4 -4
- package/lib/esm/ram/index.js +9 -5
- package/lib/esm/ram/model/RamSequence.d.ts +21 -9
- package/lib/esm/ram/model/RamSequence.js +19 -1
- package/lib/esm/ram/types.d.ts +47 -5
- package/lib/esm/ram/types.js +1 -1
- package/lib/esm/repository/Repository.d.ts +381 -22
- package/lib/esm/repository/Repository.js +446 -43
- package/lib/esm/repository/constants.d.ts +23 -13
- package/lib/esm/repository/constants.js +24 -14
- package/lib/esm/repository/decorators.d.ts +27 -0
- package/lib/esm/repository/decorators.js +28 -1
- package/lib/esm/repository/errors.d.ts +12 -11
- package/lib/esm/repository/errors.js +13 -16
- package/lib/esm/repository/injectables.d.ts +18 -0
- package/lib/esm/repository/injectables.js +19 -1
- package/lib/esm/repository/types.d.ts +13 -1
- package/lib/esm/repository/types.js +1 -1
- package/lib/esm/repository/utils.d.ts +11 -0
- package/lib/esm/repository/utils.js +12 -1
- package/lib/esm/utils/decorators.d.ts +9 -0
- package/lib/esm/utils/decorators.js +19 -0
- package/lib/esm/utils/errors.d.ts +56 -0
- package/lib/esm/utils/errors.js +63 -0
- package/lib/esm/utils/index.d.ts +2 -0
- package/lib/esm/utils/index.js +3 -0
- package/lib/identity/decorators.cjs +54 -16
- package/lib/identity/decorators.d.ts +52 -14
- package/lib/identity/utils.cjs +22 -2
- package/lib/identity/utils.d.ts +20 -1
- package/lib/index.cjs +17 -19
- package/lib/index.d.ts +11 -15
- package/lib/interfaces/ErrorParser.cjs +1 -1
- package/lib/interfaces/ErrorParser.d.ts +12 -0
- package/lib/interfaces/Executor.cjs +1 -1
- package/lib/interfaces/Executor.d.ts +10 -13
- package/lib/interfaces/Observable.cjs +1 -1
- package/lib/interfaces/Observable.d.ts +20 -18
- package/lib/interfaces/Observer.cjs +1 -1
- package/lib/interfaces/Observer.d.ts +7 -8
- package/lib/interfaces/Paginatable.cjs +1 -1
- package/lib/interfaces/Paginatable.d.ts +18 -2
- package/lib/interfaces/Queriable.cjs +1 -1
- package/lib/interfaces/Queriable.d.ts +44 -3
- package/lib/interfaces/RawExecutor.cjs +1 -1
- package/lib/interfaces/RawExecutor.d.ts +10 -13
- package/lib/interfaces/SequenceOptions.cjs +19 -1
- package/lib/interfaces/SequenceOptions.d.ts +50 -5
- package/lib/interfaces/index.cjs +1 -2
- package/lib/interfaces/index.d.ts +0 -1
- package/lib/model/BaseModel.cjs +24 -1
- package/lib/model/BaseModel.d.ts +31 -0
- package/lib/model/construction.cjs +441 -2
- package/lib/model/construction.d.ts +442 -9
- package/lib/model/decorators.cjs +161 -37
- package/lib/model/decorators.d.ts +166 -42
- package/lib/model/index.cjs +1 -2
- package/lib/model/types.cjs +1 -1
- package/lib/model/types.d.ts +9 -0
- package/lib/persistence/Adapter.cjs +414 -58
- package/lib/persistence/Adapter.d.ts +384 -40
- package/lib/persistence/Dispatch.cjs +191 -0
- package/lib/persistence/Dispatch.d.ts +131 -0
- package/lib/persistence/ObserverHandler.cjs +141 -0
- package/lib/persistence/ObserverHandler.d.ts +109 -0
- package/lib/persistence/Sequence.cjs +91 -1
- package/lib/persistence/Sequence.d.ts +89 -8
- package/lib/persistence/constants.cjs +24 -8
- package/lib/persistence/constants.d.ts +22 -5
- package/lib/persistence/decorators.cjs +11 -1
- package/lib/persistence/decorators.d.ts +10 -0
- package/lib/persistence/errors.cjs +26 -9
- package/lib/persistence/errors.d.ts +23 -3
- package/lib/persistence/index.cjs +4 -1
- package/lib/persistence/index.d.ts +3 -0
- package/lib/persistence/types.cjs +3 -0
- package/lib/persistence/types.d.ts +21 -0
- package/lib/query/Condition.cjs +143 -61
- package/lib/query/Condition.d.ts +88 -44
- package/lib/query/Paginator.cjs +64 -10
- package/lib/query/Paginator.d.ts +67 -10
- package/lib/query/Statement.cjs +174 -121
- package/lib/query/Statement.d.ts +82 -47
- package/lib/query/constants.cjs +27 -69
- package/lib/query/constants.d.ts +25 -64
- package/lib/query/errors.cjs +15 -1
- package/lib/query/errors.d.ts +14 -0
- package/lib/query/index.cjs +1 -6
- package/lib/query/index.d.ts +0 -5
- package/lib/query/options.cjs +1 -1
- package/lib/query/options.d.ts +69 -178
- package/lib/query/selectors.cjs +1 -1
- package/lib/query/selectors.d.ts +20 -24
- package/lib/ram/RamAdapter.cjs +358 -172
- package/lib/ram/RamAdapter.d.ts +322 -20
- package/lib/ram/RamContext.cjs +18 -3
- package/lib/ram/RamContext.d.ts +16 -1
- package/lib/ram/RamPaginator.cjs +58 -6
- package/lib/ram/RamPaginator.d.ts +51 -6
- package/lib/ram/RamSequence.cjs +52 -41
- package/lib/ram/RamSequence.d.ts +49 -24
- package/lib/ram/RamStatement.cjs +175 -6
- package/lib/ram/RamStatement.d.ts +84 -6
- package/lib/ram/constants.cjs +13 -0
- package/lib/ram/constants.d.ts +9 -0
- package/lib/ram/handlers.cjs +30 -0
- package/lib/ram/handlers.d.ts +25 -0
- package/lib/ram/index.cjs +9 -5
- package/lib/ram/index.d.ts +4 -4
- package/lib/ram/model/RamSequence.cjs +19 -1
- package/lib/ram/model/RamSequence.d.ts +21 -9
- package/lib/ram/types.cjs +1 -1
- package/lib/ram/types.d.ts +47 -5
- package/lib/repository/Repository.cjs +445 -42
- package/lib/repository/Repository.d.ts +381 -22
- package/lib/repository/constants.cjs +24 -14
- package/lib/repository/constants.d.ts +23 -13
- package/lib/repository/decorators.cjs +28 -1
- package/lib/repository/decorators.d.ts +27 -0
- package/lib/repository/errors.cjs +14 -19
- package/lib/repository/errors.d.ts +12 -11
- package/lib/repository/injectables.cjs +19 -1
- package/lib/repository/injectables.d.ts +18 -0
- package/lib/repository/types.cjs +1 -1
- package/lib/repository/types.d.ts +13 -1
- package/lib/repository/utils.cjs +12 -1
- package/lib/repository/utils.d.ts +11 -0
- package/lib/utils/decorators.cjs +22 -0
- package/lib/utils/decorators.d.ts +9 -0
- package/lib/utils/errors.cjs +69 -0
- package/lib/utils/errors.d.ts +56 -0
- package/lib/{validators → utils}/index.cjs +2 -2
- package/lib/utils/index.d.ts +2 -0
- package/package.json +5 -5
- package/lib/esm/interfaces/Builder.d.ts +0 -16
- package/lib/esm/interfaces/Builder.js +0 -2
- package/lib/esm/model/IdentifiedBaseModel.d.ts +0 -7
- package/lib/esm/model/IdentifiedBaseModel.js +0 -25
- package/lib/esm/query/Clause.d.ts +0 -50
- package/lib/esm/query/Clause.js +0 -82
- package/lib/esm/query/ClauseFactory.d.ts +0 -71
- package/lib/esm/query/ClauseFactory.js +0 -6
- package/lib/esm/query/Query.d.ts +0 -43
- package/lib/esm/query/Query.js +0 -54
- package/lib/esm/query/clauses/FromClause.d.ts +0 -45
- package/lib/esm/query/clauses/FromClause.js +0 -59
- package/lib/esm/query/clauses/GroupByClause.d.ts +0 -21
- package/lib/esm/query/clauses/GroupByClause.js +0 -19
- package/lib/esm/query/clauses/InsertClause.d.ts +0 -37
- package/lib/esm/query/clauses/InsertClause.js +0 -55
- package/lib/esm/query/clauses/LimitClause.d.ts +0 -29
- package/lib/esm/query/clauses/LimitClause.js +0 -27
- package/lib/esm/query/clauses/OffsetClause.d.ts +0 -21
- package/lib/esm/query/clauses/OffsetClause.js +0 -19
- package/lib/esm/query/clauses/OrderByClause.d.ts +0 -37
- package/lib/esm/query/clauses/OrderByClause.js +0 -39
- package/lib/esm/query/clauses/SelectClause.d.ts +0 -47
- package/lib/esm/query/clauses/SelectClause.js +0 -62
- package/lib/esm/query/clauses/SelectorBasedClause.d.ts +0 -25
- package/lib/esm/query/clauses/SelectorBasedClause.js +0 -44
- package/lib/esm/query/clauses/ValuesClause.d.ts +0 -21
- package/lib/esm/query/clauses/ValuesClause.js +0 -36
- package/lib/esm/query/clauses/WhereClause.d.ts +0 -46
- package/lib/esm/query/clauses/WhereClause.js +0 -71
- package/lib/esm/query/clauses/index.d.ts +0 -10
- package/lib/esm/query/clauses/index.js +0 -11
- package/lib/esm/query/types.d.ts +0 -2
- package/lib/esm/query/types.js +0 -2
- package/lib/esm/ram/RamClauseFactory.d.ts +0 -17
- package/lib/esm/ram/RamClauseFactory.js +0 -92
- package/lib/esm/ram/clauses/FromClause.d.ts +0 -7
- package/lib/esm/ram/clauses/FromClause.js +0 -11
- package/lib/esm/ram/clauses/InsertClause.d.ts +0 -7
- package/lib/esm/ram/clauses/InsertClause.js +0 -13
- package/lib/esm/ram/clauses/OrderByClause.d.ts +0 -7
- package/lib/esm/ram/clauses/OrderByClause.js +0 -39
- package/lib/esm/ram/clauses/SelectClause.d.ts +0 -7
- package/lib/esm/ram/clauses/SelectClause.js +0 -16
- package/lib/esm/ram/clauses/ValuesClause.d.ts +0 -7
- package/lib/esm/ram/clauses/ValuesClause.js +0 -12
- package/lib/esm/ram/clauses/WhereClause.d.ts +0 -7
- package/lib/esm/ram/clauses/WhereClause.js +0 -11
- package/lib/esm/ram/clauses/index.d.ts +0 -6
- package/lib/esm/ram/clauses/index.js +0 -7
- package/lib/esm/validators/ClauseSequenceValidator.d.ts +0 -28
- package/lib/esm/validators/ClauseSequenceValidator.js +0 -95
- package/lib/esm/validators/decorators.d.ts +0 -10
- package/lib/esm/validators/decorators.js +0 -24
- package/lib/esm/validators/index.d.ts +0 -2
- package/lib/esm/validators/index.js +0 -3
- package/lib/interfaces/Builder.cjs +0 -3
- package/lib/interfaces/Builder.d.ts +0 -16
- package/lib/model/IdentifiedBaseModel.cjs +0 -29
- package/lib/model/IdentifiedBaseModel.d.ts +0 -7
- package/lib/query/Clause.cjs +0 -86
- package/lib/query/Clause.d.ts +0 -50
- package/lib/query/ClauseFactory.cjs +0 -10
- package/lib/query/ClauseFactory.d.ts +0 -71
- package/lib/query/Query.cjs +0 -58
- package/lib/query/Query.d.ts +0 -43
- package/lib/query/clauses/FromClause.cjs +0 -63
- package/lib/query/clauses/FromClause.d.ts +0 -45
- package/lib/query/clauses/GroupByClause.cjs +0 -23
- package/lib/query/clauses/GroupByClause.d.ts +0 -21
- package/lib/query/clauses/InsertClause.cjs +0 -59
- package/lib/query/clauses/InsertClause.d.ts +0 -37
- package/lib/query/clauses/LimitClause.cjs +0 -31
- package/lib/query/clauses/LimitClause.d.ts +0 -29
- package/lib/query/clauses/OffsetClause.cjs +0 -23
- package/lib/query/clauses/OffsetClause.d.ts +0 -21
- package/lib/query/clauses/OrderByClause.cjs +0 -43
- package/lib/query/clauses/OrderByClause.d.ts +0 -37
- package/lib/query/clauses/SelectClause.cjs +0 -66
- package/lib/query/clauses/SelectClause.d.ts +0 -47
- package/lib/query/clauses/SelectorBasedClause.cjs +0 -48
- package/lib/query/clauses/SelectorBasedClause.d.ts +0 -25
- package/lib/query/clauses/ValuesClause.cjs +0 -40
- package/lib/query/clauses/ValuesClause.d.ts +0 -21
- package/lib/query/clauses/WhereClause.cjs +0 -75
- package/lib/query/clauses/WhereClause.d.ts +0 -46
- package/lib/query/clauses/index.cjs +0 -27
- package/lib/query/clauses/index.d.ts +0 -10
- package/lib/query/types.cjs +0 -3
- package/lib/query/types.d.ts +0 -2
- package/lib/ram/RamClauseFactory.cjs +0 -96
- package/lib/ram/RamClauseFactory.d.ts +0 -17
- package/lib/ram/clauses/FromClause.cjs +0 -15
- package/lib/ram/clauses/FromClause.d.ts +0 -7
- package/lib/ram/clauses/InsertClause.cjs +0 -17
- package/lib/ram/clauses/InsertClause.d.ts +0 -7
- package/lib/ram/clauses/OrderByClause.cjs +0 -43
- package/lib/ram/clauses/OrderByClause.d.ts +0 -7
- package/lib/ram/clauses/SelectClause.cjs +0 -20
- package/lib/ram/clauses/SelectClause.d.ts +0 -7
- package/lib/ram/clauses/ValuesClause.cjs +0 -16
- package/lib/ram/clauses/ValuesClause.d.ts +0 -7
- package/lib/ram/clauses/WhereClause.cjs +0 -15
- package/lib/ram/clauses/WhereClause.d.ts +0 -7
- package/lib/ram/clauses/index.cjs +0 -23
- package/lib/ram/clauses/index.d.ts +0 -6
- package/lib/validators/ClauseSequenceValidator.cjs +0 -98
- package/lib/validators/ClauseSequenceValidator.d.ts +0 -28
- package/lib/validators/decorators.cjs +0 -27
- package/lib/validators/decorators.d.ts +0 -10
- package/lib/validators/index.d.ts +0 -2
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createdByOnRamCreateUpdate = createdByOnRamCreateUpdate;
|
4
|
+
const persistence_1 = require("./../persistence/index.cjs");
|
5
|
+
/**
|
6
|
+
* @description Sets the created by field on a model during RAM create/update operations
|
7
|
+
* @summary Automatically populates a model field with the UUID from the context during create or update operations.
|
8
|
+
* This function is designed to be used as a handler for RAM operations to track entity creation.
|
9
|
+
* @template M - Type of the model being created/updated
|
10
|
+
* @template R - Type of the repository handling the model
|
11
|
+
* @template V - Type of the relations metadata
|
12
|
+
* @template F - Type of the RAM flags
|
13
|
+
* @template C - Type of the context
|
14
|
+
* @param {R} this - The repository instance
|
15
|
+
* @param {Context<F>} context - The operation context containing user identification
|
16
|
+
* @param {V} data - The relations metadata
|
17
|
+
* @param key - The property key to set with the UUID
|
18
|
+
* @param {M} model - The model instance being created/updated
|
19
|
+
* @return {Promise<void>} A promise that resolves when the field has been set
|
20
|
+
* @function createdByOnRamCreateUpdate
|
21
|
+
* @memberOf module:core
|
22
|
+
* @category Ram
|
23
|
+
*/
|
24
|
+
async function createdByOnRamCreateUpdate(context, data, key, model) {
|
25
|
+
const uuid = context.get("UUID");
|
26
|
+
if (!uuid)
|
27
|
+
throw new persistence_1.UnsupportedError("This adapter does not support user identification");
|
28
|
+
model[key] = uuid;
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcmFtL2hhbmRsZXJzLnRzIl0sIm5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rpb24gY3JlYXRlZEJ5T25SYW1DcmVhdGVVcGRhdGVcbiAqIEBtZW1iZXJPZiBtb2R1bGU6Y29yZVxuICogQGNhdGVnb3J5IFJhbVxuICovXG5leHBvcnQgYXN5bmMgZnVuY3Rpb24gY3JlYXRlZEJ5T25SYW1DcmVhdGVVcGRhdGU8XG4gIE0gZXh0ZW5kcyBNb2RlbCxcbiAgUiBleHRlbmRzIFJlcG88TSwgRiwgQz4sXG4gIFYgZXh0ZW5kcyBSZWxhdGlvbnNNZXRhZGF0YSxcbiAgRiBleHRlbmRzIFJhbUZsYWdzLFxuICBDIGV4dGVuZHMgQ29udGV4dDxGPixcbj4oXG4gIHRoaXM6IFIsXG4gIGNvbnRleHQ6IENvbnRleHQ8Rj4sXG4gIGRhdGE6IFYsXG4gIGtleToga2V5b2YgTSxcbiAgbW9kZWw6IE1cbik6IFByb21pc2U8dm9pZD4ge1xuICBjb25zdCB1dWlkOiBzdHJpbmcgPSBjb250ZXh0LmdldChcIlVVSURcIik7XG4gIGlmICghdXVpZClcbiAgICB0aHJvdyBuZXcgVW5zdXBwb3J0ZWRFcnJvcihcbiAgICAgIFwiVGhpcyBhZGFwdGVyIGRvZXMgbm90IHN1cHBvcnQgdXNlciBpZGVudGlmaWNhdGlvblwiXG4gICAgKTtcbiAgbW9kZWxba2V5XSA9IHV1aWQgYXMgTVtrZXlvZiBNXTtcbn1cbiJdfQ==
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
2
|
+
import { Repo } from "../repository";
|
3
|
+
import { RelationsMetadata } from "../model";
|
4
|
+
import { RamFlags } from "./types";
|
5
|
+
import { Context } from "@decaf-ts/db-decorators";
|
6
|
+
/**
|
7
|
+
* @description Sets the created by field on a model during RAM create/update operations
|
8
|
+
* @summary Automatically populates a model field with the UUID from the context during create or update operations.
|
9
|
+
* This function is designed to be used as a handler for RAM operations to track entity creation.
|
10
|
+
* @template M - Type of the model being created/updated
|
11
|
+
* @template R - Type of the repository handling the model
|
12
|
+
* @template V - Type of the relations metadata
|
13
|
+
* @template F - Type of the RAM flags
|
14
|
+
* @template C - Type of the context
|
15
|
+
* @param {R} this - The repository instance
|
16
|
+
* @param {Context<F>} context - The operation context containing user identification
|
17
|
+
* @param {V} data - The relations metadata
|
18
|
+
* @param key - The property key to set with the UUID
|
19
|
+
* @param {M} model - The model instance being created/updated
|
20
|
+
* @return {Promise<void>} A promise that resolves when the field has been set
|
21
|
+
* @function createdByOnRamCreateUpdate
|
22
|
+
* @memberOf module:core
|
23
|
+
* @category Ram
|
24
|
+
*/
|
25
|
+
export declare function createdByOnRamCreateUpdate<M extends Model, R extends Repo<M, F, C>, V extends RelationsMetadata, F extends RamFlags, C extends Context<F>>(this: R, context: Context<F>, data: V, key: keyof M, model: M): Promise<void>;
|
package/lib/ram/index.cjs
CHANGED
@@ -14,13 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
|
17
|
+
const RamAdapter_1 = require("./RamAdapter.cjs");
|
18
|
+
// Invoked there to ensure decoration override
|
19
|
+
RamAdapter_1.RamAdapter.decoration();
|
18
20
|
__exportStar(require("./model/index.cjs"), exports);
|
19
|
-
__exportStar(require("./
|
20
|
-
__exportStar(require("./
|
21
|
+
__exportStar(require("./constants.cjs"), exports);
|
22
|
+
__exportStar(require("./handlers.cjs"), exports);
|
21
23
|
__exportStar(require("./RamContext.cjs"), exports);
|
22
24
|
__exportStar(require("./RamPaginator.cjs"), exports);
|
23
|
-
__exportStar(require("./RamSequence.cjs"), exports);
|
24
25
|
__exportStar(require("./RamStatement.cjs"), exports);
|
26
|
+
__exportStar(require("./RamSequence.cjs"), exports);
|
25
27
|
__exportStar(require("./types.cjs"), exports);
|
26
|
-
|
28
|
+
// left to last on purpose
|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BcIi4vUmFtQWRhcHRlclwiO1xuIl19
|
package/lib/ram/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
export * from "./clauses";
|
2
1
|
export * from "./model";
|
3
|
-
export * from "./
|
4
|
-
export * from "./
|
2
|
+
export * from "./constants";
|
3
|
+
export * from "./handlers";
|
5
4
|
export * from "./RamContext";
|
6
5
|
export * from "./RamPaginator";
|
7
|
-
export * from "./RamSequence";
|
8
6
|
export * from "./RamStatement";
|
7
|
+
export * from "./RamSequence";
|
9
8
|
export * from "./types";
|
9
|
+
export * from "./RamAdapter";
|
@@ -13,6 +13,24 @@ exports.Sequence = void 0;
|
|
13
13
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
14
14
|
const model_1 = require("./../../model/index.cjs");
|
15
15
|
const identity_1 = require("./../../identity/index.cjs");
|
16
|
+
/**
|
17
|
+
* @description RAM sequence model for auto-incrementing values
|
18
|
+
* @summary A model class that represents a sequence in the RAM adapter. It stores the current value
|
19
|
+
* of a sequence that can be used for generating sequential identifiers for entities.
|
20
|
+
* The sequence is identified by its ID and maintains the current value.
|
21
|
+
* @param {ModelArg<Sequence>} seq - Initial sequence data
|
22
|
+
* @class Sequence
|
23
|
+
* @category Ram
|
24
|
+
* @example
|
25
|
+
* ```typescript
|
26
|
+
* // Create a new sequence
|
27
|
+
* const orderSequence = new Sequence({ id: 'order_seq', current: 1 });
|
28
|
+
*
|
29
|
+
* // Use the sequence to get the next value
|
30
|
+
* const nextOrderId = parseInt(orderSequence.current.toString()) + 1;
|
31
|
+
* orderSequence.current = nextOrderId;
|
32
|
+
* ```
|
33
|
+
*/
|
16
34
|
let Sequence = class Sequence extends model_1.BaseModel {
|
17
35
|
constructor(seq) {
|
18
36
|
super(seq);
|
@@ -33,4 +51,4 @@ exports.Sequence = Sequence = __decorate([
|
|
33
51
|
(0, decorator_validation_1.model)(),
|
34
52
|
__metadata("design:paramtypes", [Object])
|
35
53
|
], Sequence);
|
36
|
-
//# sourceMapping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2UgZXh0ZW5kcyBCYXNlTW9kZWwge1xuICAvKipcbiAgICogQGRlc2NyaXB0aW9uIFByaW1hcnkga2V5IGlkZW50aWZpZXIgZm9yIHRoZSBzZXF1ZW5jZVxuICAgKi9cbiAgQHBrKClcbiAgaWQhOiBzdHJpbmc7XG5cbiAgLyoqXG4gICAqIEBkZXNjcmlwdGlvbiBDdXJyZW50IHZhbHVlIG9mIHRoZSBzZXF1ZW5jZVxuICAgKiBVc2VkIHRvIGdlbmVyYXRlIHRoZSBuZXh0IHNlcXVlbnRpYWwgdmFsdWVcbiAgICovXG4gIEByZXF1aXJlZCgpXG4gIEBpbmRleCgpXG4gIGN1cnJlbnQhOiBzdHJpbmcgfCBudW1iZXI7XG5cbiAgY29uc3RydWN0b3Ioc2VxPzogTW9kZWxBcmc8U2VxdWVuY2U+KSB7XG4gICAgc3VwZXIoc2VxKTtcbiAgfVxufVxuIl19
|
@@ -1,19 +1,31 @@
|
|
1
1
|
import type { ModelArg } from "@decaf-ts/decorator-validation";
|
2
2
|
import { BaseModel } from "../../model";
|
3
|
+
/**
|
4
|
+
* @description RAM sequence model for auto-incrementing values
|
5
|
+
* @summary A model class that represents a sequence in the RAM adapter. It stores the current value
|
6
|
+
* of a sequence that can be used for generating sequential identifiers for entities.
|
7
|
+
* The sequence is identified by its ID and maintains the current value.
|
8
|
+
* @param {ModelArg<Sequence>} seq - Initial sequence data
|
9
|
+
* @class Sequence
|
10
|
+
* @category Ram
|
11
|
+
* @example
|
12
|
+
* ```typescript
|
13
|
+
* // Create a new sequence
|
14
|
+
* const orderSequence = new Sequence({ id: 'order_seq', current: 1 });
|
15
|
+
*
|
16
|
+
* // Use the sequence to get the next value
|
17
|
+
* const nextOrderId = parseInt(orderSequence.current.toString()) + 1;
|
18
|
+
* orderSequence.current = nextOrderId;
|
19
|
+
* ```
|
20
|
+
*/
|
3
21
|
export declare class Sequence extends BaseModel {
|
4
22
|
/**
|
5
|
-
* @
|
6
|
-
* @prop name
|
7
|
-
*
|
8
|
-
* @see pk
|
23
|
+
* @description Primary key identifier for the sequence
|
9
24
|
*/
|
10
25
|
id: string;
|
11
26
|
/**
|
12
|
-
* @
|
13
|
-
*
|
14
|
-
*
|
15
|
-
* @see required
|
16
|
-
* @see index
|
27
|
+
* @description Current value of the sequence
|
28
|
+
* Used to generate the next sequential value
|
17
29
|
*/
|
18
30
|
current: string | number;
|
19
31
|
constructor(seq?: ModelArg<Sequence>);
|
package/lib/ram/types.cjs
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcmFtL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBDb25zdHJ1Y3RvciwgTW9kZWwgfSBmcm9tIFwiQGRlY2FmLXRzL2RlY29yYXRvci12YWxpZGF0aW9uXCI7XG5pbXBvcnQgeyBSZXBvc2l0b3J5IH0gZnJvbSBcIi4uL3JlcG9zaXRvcnlcIjtcbmltcG9ydCB7IENvbnRleHQsIFJlcG9zaXRvcnlGbGFncyB9IGZyb20gXCJAZGVjYWYtdHMvZGItZGVjb3JhdG9yc1wiO1xuaW1wb3J0IHsgUmFtQWRhcHRlciB9IGZyb20gXCIuL1JhbUFkYXB0ZXJcIjtcblxuLyoqXG4gKiBAZGVzY3JpcHRpb24gSW4tbWVtb3J5IHN0b3JhZ2Ugc3RydWN0dXJlIGZvciB0aGUgUkFNIGFkYXB0ZXJcbiAqIEBzdW1tYXJ5IEEgbmVzdGVkIE1hcCBzdHJ1Y3R1cmUgdGhhdCBzdG9yZXMgYWxsIGVudGl0aWVzIGJ5IHRoZWl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mFtUmVwb3NpdG9yeTxNIGV4dGVuZHMgTW9kZWw+ID0gUmVwb3NpdG9yeTxcbiAgTSxcbiAgUmF3UmFtUXVlcnk8YW55PixcbiAgUmFtQWRhcHRlcixcbiAgUmFtRmxhZ3MsXG4gIENvbnRleHQ8UmFtRmxhZ3M+XG4+O1xuIl19
|
package/lib/ram/types.d.ts
CHANGED
@@ -2,16 +2,58 @@ import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
|
2
2
|
import { Repository } from "../repository";
|
3
3
|
import { Context, RepositoryFlags } from "@decaf-ts/db-decorators";
|
4
4
|
import { RamAdapter } from "./RamAdapter";
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
/**
|
6
|
+
* @description In-memory storage structure for the RAM adapter
|
7
|
+
* @summary A nested Map structure that stores all entities by their table name and primary key.
|
8
|
+
* The outer Map uses table names as keys, while the inner Map uses entity IDs as keys and entity instances as values.
|
9
|
+
* @typedef {Map<string, Map<string | number, any>>} RamStorage
|
10
|
+
* @memberOf module:core
|
11
|
+
* @category Ram
|
12
|
+
*/
|
13
|
+
export type RamStorage = Map<string, Map<string | number, any>>;
|
14
|
+
/**
|
15
|
+
* @description Query specification for RAM adapter
|
16
|
+
* @summary Defines the structure of a query for retrieving data from the in-memory storage.
|
17
|
+
* It specifies what fields to select, which model to query, filtering conditions,
|
18
|
+
* sorting criteria, and pagination options.
|
19
|
+
* @template M - The model type being queried
|
20
|
+
* @typedef {Object} RawRamQuery
|
21
|
+
* @property select - Fields to select from the model, or undefined for all fields
|
22
|
+
* @property {Constructor<M>} from - The model constructor to query
|
23
|
+
* @property {function(M): boolean} where - Predicate function for filtering entities
|
24
|
+
* @property {function(M, M): number} [sort] - Optional comparator function for sorting results
|
25
|
+
* @property {number} [limit] - Optional maximum number of results to return
|
26
|
+
* @property {number} [skip] - Optional number of results to skip (for pagination)
|
27
|
+
* @memberOf module:core
|
28
|
+
* @category Ram
|
29
|
+
*/
|
30
|
+
export type RawRamQuery<M extends Model> = {
|
31
|
+
select: undefined | (keyof M)[];
|
32
|
+
from: Constructor<M>;
|
9
33
|
where: (el: M) => boolean;
|
10
34
|
sort?: (el: M, el2: M) => number;
|
11
35
|
limit?: number;
|
12
36
|
skip?: number;
|
13
37
|
};
|
38
|
+
/**
|
39
|
+
* @description Flags for RAM adapter operations
|
40
|
+
* @summary Interface that extends the base repository flags with RAM-specific flags.
|
41
|
+
* Contains user identification information needed for tracking entity creation and updates.
|
42
|
+
* @interface RamFlags
|
43
|
+
* @property {string} UUID - Unique identifier for the current user
|
44
|
+
* @memberOf module:core
|
45
|
+
* @category Ram
|
46
|
+
*/
|
14
47
|
export interface RamFlags extends RepositoryFlags {
|
15
48
|
UUID: string;
|
16
49
|
}
|
17
|
-
|
50
|
+
/**
|
51
|
+
* @description Type definition for RAM-specific repository
|
52
|
+
* @summary A specialized repository type for working with models in the RAM adapter.
|
53
|
+
* It combines the model type with RAM-specific query, adapter, flags, and context types.
|
54
|
+
* @template M - The model type managed by the repository
|
55
|
+
* @typedef {Repository<M, RawRamQuery<any>, RamAdapter, RamFlags, Context<RamFlags>>} RamRepository
|
56
|
+
* @memberOf module:core
|
57
|
+
* @category Ram
|
58
|
+
*/
|
59
|
+
export type RamRepository<M extends Model> = Repository<M, RawRamQuery<any>, RamAdapter, RamFlags, Context<RamFlags>>;
|