@decaf-ts/core 0.7.1 → 0.7.3
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/README.md +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/lib/esm/identity/decorators.d.ts +3 -4
- package/lib/esm/identity/decorators.js +4 -10
- package/lib/esm/identity/decorators.js.map +1 -1
- package/lib/esm/identity/index.d.ts +0 -1
- package/lib/esm/identity/index.js +0 -1
- package/lib/esm/identity/index.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/interfaces/ContextuallyLogged.d.ts +8 -0
- package/lib/esm/interfaces/ContextuallyLogged.js +2 -0
- package/lib/esm/interfaces/ContextuallyLogged.js.map +1 -0
- package/lib/esm/interfaces/ErrorParser.d.ts +2 -2
- package/lib/esm/interfaces/Executor.d.ts +1 -1
- package/lib/esm/interfaces/Observable.d.ts +8 -8
- package/lib/esm/interfaces/Observer.d.ts +2 -2
- package/lib/esm/interfaces/RawExecutor.d.ts +1 -1
- package/lib/esm/model/BaseModel.d.ts +2 -2
- package/lib/esm/model/BaseModel.js +2 -2
- package/lib/esm/model/construction.d.ts +9 -8
- package/lib/esm/model/construction.js +2 -2
- package/lib/esm/model/construction.js.map +1 -1
- package/lib/esm/model/decorators.d.ts +4 -3
- package/lib/esm/model/decorators.js +2 -2
- package/lib/esm/model/decorators.js.map +1 -1
- package/lib/esm/overrides/Metadata.d.ts +1 -8
- package/lib/esm/overrides/Model.d.ts +75 -0
- package/lib/esm/overrides/Model.js +2 -0
- package/lib/esm/overrides/Model.js.map +1 -0
- package/lib/esm/overrides/index.d.ts +2 -0
- package/lib/esm/overrides/index.js +2 -0
- package/lib/esm/overrides/index.js.map +1 -1
- package/lib/esm/overrides/injectables.d.ts +10 -0
- package/lib/esm/overrides/injectables.js +2 -0
- package/lib/esm/overrides/injectables.js.map +1 -0
- package/lib/esm/overrides/overrides.js +45 -3
- package/lib/esm/overrides/overrides.js.map +1 -1
- package/lib/esm/persistence/Adapter.d.ts +54 -51
- package/lib/esm/persistence/Adapter.js +78 -57
- package/lib/esm/persistence/Adapter.js.map +1 -1
- package/lib/esm/persistence/Dispatch.d.ts +7 -6
- package/lib/esm/persistence/Dispatch.js +25 -18
- package/lib/esm/persistence/Dispatch.js.map +1 -1
- package/lib/esm/persistence/ObserverHandler.d.ts +7 -6
- package/lib/esm/persistence/ObserverHandler.js +5 -4
- package/lib/esm/persistence/ObserverHandler.js.map +1 -1
- package/lib/esm/persistence/Sequence.d.ts +10 -17
- package/lib/esm/persistence/Sequence.js +10 -15
- package/lib/esm/persistence/Sequence.js.map +1 -1
- package/lib/esm/persistence/constants.d.ts +1 -0
- package/lib/esm/persistence/constants.js +1 -0
- package/lib/esm/persistence/constants.js.map +1 -1
- package/lib/esm/persistence/migrations.d.ts +8 -8
- package/lib/esm/persistence/migrations.js +8 -9
- package/lib/esm/persistence/migrations.js.map +1 -1
- package/lib/esm/persistence/types.d.ts +38 -20
- package/lib/esm/query/Paginator.d.ts +6 -5
- package/lib/esm/query/Paginator.js +4 -4
- package/lib/esm/query/Paginator.js.map +1 -1
- package/lib/esm/query/Statement.d.ts +9 -8
- package/lib/esm/query/Statement.js +23 -10
- package/lib/esm/query/Statement.js.map +1 -1
- package/lib/esm/ram/RamAdapter.d.ts +21 -21
- package/lib/esm/ram/RamAdapter.js +36 -23
- package/lib/esm/ram/RamAdapter.js.map +1 -1
- package/lib/esm/ram/RamPaginator.d.ts +2 -1
- package/lib/esm/ram/RamPaginator.js +5 -3
- package/lib/esm/ram/RamPaginator.js.map +1 -1
- package/lib/esm/ram/RamSequence.d.ts +4 -11
- package/lib/esm/ram/RamSequence.js +20 -24
- package/lib/esm/ram/RamSequence.js.map +1 -1
- package/lib/esm/ram/RamStatement.d.ts +7 -7
- package/lib/esm/ram/RamStatement.js.map +1 -1
- package/lib/esm/ram/handlers.d.ts +3 -4
- package/lib/esm/ram/handlers.js.map +1 -1
- package/lib/esm/ram/index.d.ts +0 -1
- package/lib/esm/ram/index.js +0 -1
- package/lib/esm/ram/index.js.map +1 -1
- package/lib/esm/ram/types.d.ts +4 -12
- package/lib/esm/repository/Repository.d.ts +31 -95
- package/lib/esm/repository/Repository.js +106 -201
- package/lib/esm/repository/Repository.js.map +1 -1
- package/lib/esm/repository/decorators.js +3 -2
- package/lib/esm/repository/decorators.js.map +1 -1
- package/lib/esm/repository/utils.d.ts +1 -1
- package/lib/esm/repository/utils.js +2 -3
- package/lib/esm/repository/utils.js.map +1 -1
- package/lib/esm/utils/ContextualLoggedClass.d.ts +16 -0
- package/lib/esm/utils/ContextualLoggedClass.js +29 -0
- package/lib/esm/utils/ContextualLoggedClass.js.map +1 -0
- package/lib/esm/utils/Services.d.ts +28 -0
- package/lib/esm/utils/Services.js +88 -0
- package/lib/esm/utils/Services.js.map +1 -0
- package/lib/esm/utils/decorators.d.ts +1 -9
- package/lib/esm/utils/decorators.js +26 -15
- package/lib/esm/utils/decorators.js.map +1 -1
- package/lib/esm/utils/index.d.ts +2 -1
- package/lib/esm/utils/index.js +2 -1
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/identity/decorators.cjs +3 -9
- package/lib/identity/decorators.d.ts +3 -4
- package/lib/identity/decorators.js.map +1 -1
- package/lib/identity/index.cjs +0 -1
- package/lib/identity/index.d.ts +0 -1
- package/lib/identity/index.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/interfaces/ContextuallyLogged.cjs +3 -0
- package/lib/interfaces/ContextuallyLogged.d.ts +8 -0
- package/lib/interfaces/ContextuallyLogged.js.map +1 -0
- package/lib/interfaces/ErrorParser.d.ts +2 -2
- package/lib/interfaces/Executor.d.ts +1 -1
- package/lib/interfaces/Observable.d.ts +8 -8
- package/lib/interfaces/Observer.d.ts +2 -2
- package/lib/interfaces/RawExecutor.d.ts +1 -1
- package/lib/model/BaseModel.cjs +2 -2
- package/lib/model/BaseModel.d.ts +2 -2
- package/lib/model/construction.cjs +2 -2
- package/lib/model/construction.d.ts +9 -8
- package/lib/model/construction.js.map +1 -1
- package/lib/model/decorators.cjs +1 -1
- package/lib/model/decorators.d.ts +4 -3
- package/lib/model/decorators.js.map +1 -1
- package/lib/overrides/Metadata.d.ts +1 -8
- package/lib/overrides/Model.cjs +4 -0
- package/lib/overrides/Model.d.ts +75 -0
- package/lib/overrides/Model.js.map +1 -0
- package/lib/overrides/index.cjs +2 -0
- package/lib/overrides/index.d.ts +2 -0
- package/lib/overrides/index.js.map +1 -1
- package/lib/overrides/injectables.cjs +4 -0
- package/lib/overrides/injectables.d.ts +10 -0
- package/lib/overrides/injectables.js.map +1 -0
- package/lib/overrides/overrides.cjs +43 -1
- package/lib/overrides/overrides.js.map +1 -1
- package/lib/persistence/Adapter.cjs +83 -62
- package/lib/persistence/Adapter.d.ts +54 -51
- package/lib/persistence/Adapter.js.map +1 -1
- package/lib/persistence/Dispatch.cjs +25 -18
- package/lib/persistence/Dispatch.d.ts +7 -6
- package/lib/persistence/Dispatch.js.map +1 -1
- package/lib/persistence/ObserverHandler.cjs +5 -4
- package/lib/persistence/ObserverHandler.d.ts +7 -6
- package/lib/persistence/ObserverHandler.js.map +1 -1
- package/lib/persistence/Sequence.cjs +10 -15
- package/lib/persistence/Sequence.d.ts +10 -17
- package/lib/persistence/Sequence.js.map +1 -1
- package/lib/persistence/constants.cjs +1 -0
- package/lib/persistence/constants.d.ts +1 -0
- package/lib/persistence/constants.js.map +1 -1
- package/lib/persistence/migrations.cjs +7 -8
- package/lib/persistence/migrations.d.ts +8 -8
- package/lib/persistence/migrations.js.map +1 -1
- package/lib/persistence/types.d.ts +38 -20
- package/lib/query/Paginator.cjs +4 -4
- package/lib/query/Paginator.d.ts +6 -5
- package/lib/query/Paginator.js.map +1 -1
- package/lib/query/Statement.cjs +34 -21
- package/lib/query/Statement.d.ts +9 -8
- package/lib/query/Statement.js.map +1 -1
- package/lib/ram/RamAdapter.cjs +35 -22
- package/lib/ram/RamAdapter.d.ts +21 -21
- package/lib/ram/RamAdapter.js.map +1 -1
- package/lib/ram/RamPaginator.cjs +5 -3
- package/lib/ram/RamPaginator.d.ts +2 -1
- package/lib/ram/RamPaginator.js.map +1 -1
- package/lib/ram/RamSequence.cjs +19 -23
- package/lib/ram/RamSequence.d.ts +4 -11
- package/lib/ram/RamSequence.js.map +1 -1
- package/lib/ram/RamStatement.d.ts +7 -7
- package/lib/ram/RamStatement.js.map +1 -1
- package/lib/ram/handlers.d.ts +3 -4
- package/lib/ram/handlers.js.map +1 -1
- package/lib/ram/index.cjs +0 -1
- package/lib/ram/index.d.ts +0 -1
- package/lib/ram/index.js.map +1 -1
- package/lib/ram/types.d.ts +4 -12
- package/lib/repository/Repository.cjs +107 -202
- package/lib/repository/Repository.d.ts +31 -95
- package/lib/repository/Repository.js.map +1 -1
- package/lib/repository/decorators.cjs +1 -0
- package/lib/repository/decorators.js.map +1 -1
- package/lib/repository/utils.cjs +2 -3
- package/lib/repository/utils.d.ts +1 -1
- package/lib/repository/utils.js.map +1 -1
- package/lib/utils/ContextualLoggedClass.cjs +33 -0
- package/lib/utils/ContextualLoggedClass.d.ts +16 -0
- package/lib/utils/ContextualLoggedClass.js.map +1 -0
- package/lib/utils/Services.cjs +93 -0
- package/lib/utils/Services.d.ts +28 -0
- package/lib/utils/Services.js.map +1 -0
- package/lib/utils/decorators.cjs +27 -16
- package/lib/utils/decorators.d.ts +1 -9
- package/lib/utils/decorators.js.map +1 -1
- package/lib/utils/index.cjs +2 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/lib/esm/identity/utils.d.ts +0 -24
- package/lib/esm/identity/utils.js +0 -44
- package/lib/esm/identity/utils.js.map +0 -1
- package/lib/esm/ram/RamContext.d.ts +0 -28
- package/lib/esm/ram/RamContext.js +0 -30
- package/lib/esm/ram/RamContext.js.map +0 -1
- package/lib/identity/utils.cjs +0 -49
- package/lib/identity/utils.d.ts +0 -24
- package/lib/identity/utils.js.map +0 -1
- package/lib/ram/RamContext.cjs +0 -34
- package/lib/ram/RamContext.d.ts +0 -28
- package/lib/ram/RamContext.js.map +0 -1
package/lib/ram/RamAdapter.cjs
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RamAdapter = void 0;
|
|
4
4
|
const RamStatement_1 = require("./RamStatement.cjs");
|
|
5
|
-
const RamContext_1 = require("./RamContext.cjs");
|
|
6
|
-
const Repository_1 = require("./../repository/Repository.cjs");
|
|
7
5
|
const persistence_1 = require("./../persistence/index.cjs");
|
|
8
6
|
const transactional_decorators_1 = require("@decaf-ts/transactional-decorators");
|
|
9
7
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
@@ -58,7 +56,7 @@ const decoration_1 = require("@decaf-ts/decoration");
|
|
|
58
56
|
class RamAdapter extends persistence_1.Adapter {
|
|
59
57
|
constructor(conf = {}, alias) {
|
|
60
58
|
super(conf, constants_1.RamFlavour, alias);
|
|
61
|
-
this.Context =
|
|
59
|
+
this.Context = db_decorators_1.Context;
|
|
62
60
|
this.indexes = {};
|
|
63
61
|
this.lock = new transactional_decorators_1.Lock();
|
|
64
62
|
}
|
|
@@ -110,9 +108,10 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
110
108
|
* @param pk - The primary key property name
|
|
111
109
|
* @return Object containing the record and ID
|
|
112
110
|
*/
|
|
113
|
-
prepare(model,
|
|
114
|
-
const
|
|
115
|
-
|
|
111
|
+
prepare(model, ...args) {
|
|
112
|
+
const ctx = args.pop();
|
|
113
|
+
const prepared = super.prepare(model, ...args, ctx);
|
|
114
|
+
delete prepared.record[decorator_validation_1.Model.pk(model.constructor)];
|
|
116
115
|
return prepared;
|
|
117
116
|
}
|
|
118
117
|
/**
|
|
@@ -121,13 +120,12 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
121
120
|
* This method is the inverse of the prepare method.
|
|
122
121
|
* @template M - The model type to revert to
|
|
123
122
|
* @param {Record<string, any>} obj - The stored record
|
|
124
|
-
* @param {
|
|
125
|
-
* @param
|
|
126
|
-
* @param {string | number} id - The primary key value
|
|
123
|
+
* @param {Constructor<M>} clazz - The model class or name
|
|
124
|
+
* @param {PrimaryKeyType} id - The primary key value
|
|
127
125
|
* @return {M} The reconstructed model instance
|
|
128
126
|
*/
|
|
129
|
-
revert(obj, clazz,
|
|
130
|
-
const res = super.revert(obj, clazz,
|
|
127
|
+
revert(obj, clazz, id, transient, ...args) {
|
|
128
|
+
const res = super.revert(obj, clazz, id, transient, ...args);
|
|
131
129
|
return res;
|
|
132
130
|
}
|
|
133
131
|
/**
|
|
@@ -135,7 +133,7 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
135
133
|
* @summary Stores a new record in the specified table with the given ID.
|
|
136
134
|
* This method acquires a lock to ensure thread safety, creates the table if it doesn't exist,
|
|
137
135
|
* checks for conflicts, and stores the model.
|
|
138
|
-
* @param {string}
|
|
136
|
+
* @param {string} clazz - The name of the table to store the record in
|
|
139
137
|
* @param {string | number} id - The unique identifier for the record
|
|
140
138
|
* @param {Record<string, any>} model - The record data to store
|
|
141
139
|
* @return {Promise<Record<string, any>>} A promise that resolves to the stored record
|
|
@@ -159,11 +157,15 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
159
157
|
* RamAdapter->>RamAdapter: lock.release()
|
|
160
158
|
* RamAdapter-->>Caller: model
|
|
161
159
|
*/
|
|
162
|
-
async create(
|
|
160
|
+
async create(clazz, id, model, ctx) {
|
|
161
|
+
const log = ctx.logger.for(this.create);
|
|
162
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
163
|
+
log.debug(`creating record in table ${tableName} with id ${id}`);
|
|
163
164
|
await this.lock.acquire();
|
|
164
165
|
if (!this.client.has(tableName))
|
|
165
166
|
this.client.set(tableName, new Map());
|
|
166
|
-
if (this.client.get(tableName) &&
|
|
167
|
+
if (this.client.get(tableName) &&
|
|
168
|
+
this.client.get(tableName)?.has(id))
|
|
167
169
|
throw new db_decorators_1.ConflictError(`Record with id ${id} already exists in table ${tableName}`);
|
|
168
170
|
this.client.get(tableName)?.set(id, model);
|
|
169
171
|
this.lock.release();
|
|
@@ -173,8 +175,8 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
173
175
|
* @description Retrieves a record from in-memory storage
|
|
174
176
|
* @summary Fetches a record with the specified ID from the given table.
|
|
175
177
|
* This method checks if the table and record exist and throws appropriate errors if not.
|
|
176
|
-
* @param {
|
|
177
|
-
* @param {
|
|
178
|
+
* @param {Constructor} clazz - The name of the table to retrieve from
|
|
179
|
+
* @param {PrimaryKeyType} id - The unique identifier of the record to retrieve
|
|
178
180
|
* @return {Promise<Record<string, any>>} A promise that resolves to the retrieved record
|
|
179
181
|
* @mermaid
|
|
180
182
|
* sequenceDiagram
|
|
@@ -195,7 +197,10 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
195
197
|
* Storage-->>RamAdapter: record
|
|
196
198
|
* RamAdapter-->>Caller: record
|
|
197
199
|
*/
|
|
198
|
-
async read(
|
|
200
|
+
async read(clazz, id,
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
202
|
+
ctx) {
|
|
203
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
199
204
|
if (!this.client.has(tableName))
|
|
200
205
|
throw new db_decorators_1.NotFoundError(`Table ${tableName} not found`);
|
|
201
206
|
if (!this.client.get(tableName)?.has(id))
|
|
@@ -231,7 +236,10 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
231
236
|
* RamAdapter->>RamAdapter: lock.release()
|
|
232
237
|
* RamAdapter-->>Caller: model
|
|
233
238
|
*/
|
|
234
|
-
async update(
|
|
239
|
+
async update(clazz, id, model, ctx) {
|
|
240
|
+
const log = ctx.logger.for(this.update);
|
|
241
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
242
|
+
log.debug(`updating record in table ${tableName} with id ${id}`);
|
|
235
243
|
await this.lock.acquire();
|
|
236
244
|
if (!this.client.has(tableName))
|
|
237
245
|
throw new db_decorators_1.NotFoundError(`Table ${tableName} not found`);
|
|
@@ -271,7 +279,10 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
271
279
|
* RamAdapter->>RamAdapter: lock.release()
|
|
272
280
|
* RamAdapter-->>Caller: record
|
|
273
281
|
*/
|
|
274
|
-
async delete(
|
|
282
|
+
async delete(clazz, id, ctx) {
|
|
283
|
+
const log = ctx.logger.for(this.delete);
|
|
284
|
+
const tableName = decorator_validation_1.Model.tableName(clazz);
|
|
285
|
+
log.debug(`deleting record from table ${tableName} with pk ${id}`);
|
|
275
286
|
await this.lock.acquire();
|
|
276
287
|
if (!this.client.has(tableName))
|
|
277
288
|
throw new db_decorators_1.NotFoundError(`Table ${tableName} not found`);
|
|
@@ -294,7 +305,7 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
294
305
|
tableFor(from) {
|
|
295
306
|
if (typeof from === "string")
|
|
296
307
|
from = decorator_validation_1.Model.get(from);
|
|
297
|
-
const table =
|
|
308
|
+
const table = decorator_validation_1.Model.tableName(from);
|
|
298
309
|
if (!this.client.has(table))
|
|
299
310
|
this.client.set(table, new Map());
|
|
300
311
|
return this.client.get(table);
|
|
@@ -342,7 +353,9 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
342
353
|
* end
|
|
343
354
|
* RamAdapter-->>Caller: result
|
|
344
355
|
*/
|
|
345
|
-
async raw(rawInput) {
|
|
356
|
+
async raw(rawInput, ctx) {
|
|
357
|
+
const log = ctx.logger.for(this.raw);
|
|
358
|
+
log.debug(`performing raw query: ${JSON.stringify(rawInput)}`);
|
|
346
359
|
const { where, sort, limit, skip, from } = rawInput;
|
|
347
360
|
let { select } = rawInput;
|
|
348
361
|
const collection = this.tableFor(from);
|
|
@@ -350,7 +363,7 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
350
363
|
throw new db_decorators_1.InternalError(`Table ${from} not found in RamAdapter`);
|
|
351
364
|
const id = decorator_validation_1.Model.pk(from);
|
|
352
365
|
const props = decoration_1.Metadata.get(from, decoration_1.Metadata.key(db_decorators_1.DBKeys.ID, id));
|
|
353
|
-
let result = Array.from(collection.entries()).map(([pk, r]) => this.revert(r, from,
|
|
366
|
+
let result = Array.from(collection.entries()).map(([pk, r]) => this.revert(r, from, persistence_1.Sequence.parseValue(props.type, pk), undefined, ctx));
|
|
354
367
|
result = where ? result.filter(where) : result;
|
|
355
368
|
if (sort)
|
|
356
369
|
result = result.sort(sort);
|
package/lib/ram/RamAdapter.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { RamFlags, RawRamQuery, RamStorage,
|
|
1
|
+
import { RamFlags, RawRamQuery, RamStorage, RamConfig, RamContext } from "./types";
|
|
2
2
|
import { RamStatement } from "./RamStatement";
|
|
3
|
-
import {
|
|
3
|
+
import { Repository } from "../repository/Repository";
|
|
4
4
|
import { Dispatch } from "../persistence/Dispatch";
|
|
5
5
|
import { Adapter, Sequence } from "../persistence";
|
|
6
6
|
import { SequenceOptions } from "../interfaces";
|
|
7
7
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
8
|
-
import { BaseError, OperationKeys } from "@decaf-ts/db-decorators";
|
|
8
|
+
import { BaseError, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
9
9
|
import { Constructor } from "@decaf-ts/decoration";
|
|
10
10
|
/**
|
|
11
11
|
* @description In-memory adapter for data persistence
|
|
@@ -50,7 +50,7 @@ import { Constructor } from "@decaf-ts/decoration";
|
|
|
50
50
|
* RamAdapter-->>Repository: model
|
|
51
51
|
* Repository-->>Client: model
|
|
52
52
|
*/
|
|
53
|
-
export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQuery
|
|
53
|
+
export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQuery, RamContext> {
|
|
54
54
|
constructor(conf?: RamConfig, alias?: string);
|
|
55
55
|
/**
|
|
56
56
|
* @description Gets the repository constructor for a model
|
|
@@ -59,7 +59,7 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
59
59
|
* @template M - The model type for the repository
|
|
60
60
|
* @return {Constructor<RamRepository<M>>} A constructor for creating RAM repositories
|
|
61
61
|
*/
|
|
62
|
-
repository<
|
|
62
|
+
repository<R extends Repository<any, Adapter<any, any, any, any>>>(): Constructor<R>;
|
|
63
63
|
/**
|
|
64
64
|
* @description Creates operation flags with UUID
|
|
65
65
|
* @summary Extends the base flags with a UUID for user identification.
|
|
@@ -71,8 +71,8 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
71
71
|
* @return {Promise<RamFlags>} Complete flags with UUID
|
|
72
72
|
*/
|
|
73
73
|
flags<M extends Model<boolean>>(operation: OperationKeys, model: Constructor<M>, flags: Partial<RamFlags>): Promise<RamFlags>;
|
|
74
|
-
protected Dispatch(): Dispatch
|
|
75
|
-
Context:
|
|
74
|
+
protected Dispatch(): Dispatch<RamAdapter>;
|
|
75
|
+
Context: Constructor<RamContext>;
|
|
76
76
|
private indexes;
|
|
77
77
|
private lock;
|
|
78
78
|
/**
|
|
@@ -92,9 +92,10 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
92
92
|
* @param pk - The primary key property name
|
|
93
93
|
* @return Object containing the record and ID
|
|
94
94
|
*/
|
|
95
|
-
prepare<M extends Model>(model: M,
|
|
95
|
+
prepare<M extends Model>(model: M, ...args: [...any[], RamContext]): {
|
|
96
96
|
record: Record<string, any>;
|
|
97
97
|
id: string;
|
|
98
|
+
transient?: Record<string, any>;
|
|
98
99
|
};
|
|
99
100
|
/**
|
|
100
101
|
* @description Converts a stored record back to a model instance
|
|
@@ -102,18 +103,17 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
102
103
|
* This method is the inverse of the prepare method.
|
|
103
104
|
* @template M - The model type to revert to
|
|
104
105
|
* @param {Record<string, any>} obj - The stored record
|
|
105
|
-
* @param {
|
|
106
|
-
* @param
|
|
107
|
-
* @param {string | number} id - The primary key value
|
|
106
|
+
* @param {Constructor<M>} clazz - The model class or name
|
|
107
|
+
* @param {PrimaryKeyType} id - The primary key value
|
|
108
108
|
* @return {M} The reconstructed model instance
|
|
109
109
|
*/
|
|
110
|
-
revert<M extends Model>(obj: Record<string, any>, clazz:
|
|
110
|
+
revert<M extends Model>(obj: Record<string, any>, clazz: Constructor<M>, id: PrimaryKeyType, transient?: Record<string, any>, ...args: [...any[], RamContext]): M;
|
|
111
111
|
/**
|
|
112
112
|
* @description Creates a new record in the in-memory storage
|
|
113
113
|
* @summary Stores a new record in the specified table with the given ID.
|
|
114
114
|
* This method acquires a lock to ensure thread safety, creates the table if it doesn't exist,
|
|
115
115
|
* checks for conflicts, and stores the model.
|
|
116
|
-
* @param {string}
|
|
116
|
+
* @param {string} clazz - The name of the table to store the record in
|
|
117
117
|
* @param {string | number} id - The unique identifier for the record
|
|
118
118
|
* @param {Record<string, any>} model - The record data to store
|
|
119
119
|
* @return {Promise<Record<string, any>>} A promise that resolves to the stored record
|
|
@@ -137,13 +137,13 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
137
137
|
* RamAdapter->>RamAdapter: lock.release()
|
|
138
138
|
* RamAdapter-->>Caller: model
|
|
139
139
|
*/
|
|
140
|
-
create(
|
|
140
|
+
create<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ctx: RamContext): Promise<Record<string, any>>;
|
|
141
141
|
/**
|
|
142
142
|
* @description Retrieves a record from in-memory storage
|
|
143
143
|
* @summary Fetches a record with the specified ID from the given table.
|
|
144
144
|
* This method checks if the table and record exist and throws appropriate errors if not.
|
|
145
|
-
* @param {
|
|
146
|
-
* @param {
|
|
145
|
+
* @param {Constructor} clazz - The name of the table to retrieve from
|
|
146
|
+
* @param {PrimaryKeyType} id - The unique identifier of the record to retrieve
|
|
147
147
|
* @return {Promise<Record<string, any>>} A promise that resolves to the retrieved record
|
|
148
148
|
* @mermaid
|
|
149
149
|
* sequenceDiagram
|
|
@@ -164,7 +164,7 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
164
164
|
* Storage-->>RamAdapter: record
|
|
165
165
|
* RamAdapter-->>Caller: record
|
|
166
166
|
*/
|
|
167
|
-
read(
|
|
167
|
+
read<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ctx: RamContext): Promise<Record<string, any>>;
|
|
168
168
|
/**
|
|
169
169
|
* @description Updates an existing record in the in-memory storage
|
|
170
170
|
* @summary Updates a record with the specified ID in the given table.
|
|
@@ -194,7 +194,7 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
194
194
|
* RamAdapter->>RamAdapter: lock.release()
|
|
195
195
|
* RamAdapter-->>Caller: model
|
|
196
196
|
*/
|
|
197
|
-
update(
|
|
197
|
+
update<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ctx: RamContext): Promise<Record<string, any>>;
|
|
198
198
|
/**
|
|
199
199
|
* @description Deletes a record from the in-memory storage
|
|
200
200
|
* @summary Removes a record with the specified ID from the given table.
|
|
@@ -225,7 +225,7 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
225
225
|
* RamAdapter->>RamAdapter: lock.release()
|
|
226
226
|
* RamAdapter-->>Caller: record
|
|
227
227
|
*/
|
|
228
|
-
delete(
|
|
228
|
+
delete<M extends Model>(clazz: Constructor<M>, id: PrimaryKeyType, ctx: RamContext): Promise<Record<string, any>>;
|
|
229
229
|
/**
|
|
230
230
|
* @description Gets or creates a table in the in-memory storage
|
|
231
231
|
* @summary Retrieves the Map representing a table for a given model or table name.
|
|
@@ -279,7 +279,7 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
279
279
|
* end
|
|
280
280
|
* RamAdapter-->>Caller: result
|
|
281
281
|
*/
|
|
282
|
-
raw<R>(rawInput: RawRamQuery<any
|
|
282
|
+
raw<R>(rawInput: RawRamQuery<any>, ctx: RamContext): Promise<R>;
|
|
283
283
|
/**
|
|
284
284
|
* @description Parses and converts errors to appropriate types
|
|
285
285
|
* @summary Ensures that errors are of the correct type for consistent error handling.
|
|
@@ -296,7 +296,7 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
296
296
|
* @template M - The model type for the statement
|
|
297
297
|
* @return {RamStatement<M, any>} A new statement builder instance
|
|
298
298
|
*/
|
|
299
|
-
Statement<M extends Model<boolean>>(): RamStatement<M, any
|
|
299
|
+
Statement<M extends Model<boolean>>(): RamStatement<M, any, Adapter<any, any, RawRamQuery<M>, RamContext>>;
|
|
300
300
|
/**
|
|
301
301
|
* @description Creates a new sequence for generating sequential IDs
|
|
302
302
|
* @summary Factory method that creates a new RamSequence instance for ID generation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RamAdapter.js","sourceRoot":"","sources":["../../src/ram/RamAdapter.ts"],"names":[],"mappings":";;;AAOA,qDAA8C;
|
|
1
|
+
{"version":3,"file":"RamAdapter.js","sourceRoot":"","sources":["../../src/ram/RamAdapter.ts"],"names":[],"mappings":";;;AAOA,qDAA8C;AAG9C,4DAAoE;AAEpE,iFAA0D;AAC1D,yEAAgE;AAChE,2DAWiC;AACjC,mDAA4C;AAC5C,6CAAwD;AACxD,+CAAyC;AACzC,qDAK8B;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAa,UAAW,SAAQ,qBAK/B;IACC,YAAY,OAAkB,EAAS,EAAE,KAAc;QACrD,KAAK,CAAC,IAAI,EAAE,sBAAU,EAAE,KAAK,CAAC,CAAC;QAwCxB,YAAO,GAA4B,uBAAO,CAAC;QAE5C,YAAO,GAGX,EAAE,CA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GAAG,6BAAe,CAAC,UAAU,CAAC;QAChD,uBAAU,CAAC,WAAW,CAAC,sBAAU,CAAC;aAC/B,GAAG,CAAC,YAAY,CAAC;aACjB,MAAM,CACL,IAAA,wBAAQ,EAAC,qCAA0B,CAAC,EACpC,IAAA,yBAAY,EAAC,YAAY,EAAE,EAAE,CAAC,CAC/B;aACA,KAAK,EAAE,CAAC;QACX,uBAAU,CAAC,WAAW,CAAC,sBAAU,CAAC;aAC/B,GAAG,CAAC,YAAY,CAAC;aACjB,MAAM,CACL,IAAA,8BAAc,EAAC,qCAA0B,CAAC,EAC1C,IAAA,yBAAY,EAAC,YAAY,EAAE,EAAE,CAAC,CAC/B;aACA,KAAK,EAAE,CAAC;IACb,CAAC;IAEkB,SAAS;QAC1B,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;CACF;AA9gBD,gCA8gBC"}
|
package/lib/ram/RamPaginator.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RamPaginator = void 0;
|
|
4
4
|
const query_1 = require("./../query/index.cjs");
|
|
5
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
5
6
|
/**
|
|
6
7
|
* @description RAM-specific paginator implementation
|
|
7
8
|
* @summary Extends the base Paginator class to provide pagination functionality for RAM adapter queries.
|
|
@@ -54,11 +55,12 @@ class RamPaginator extends query_1.Paginator {
|
|
|
54
55
|
* @param {number} [page=1] - The page number to retrieve (1-based)
|
|
55
56
|
* @return {Promise<R[]>} A promise that resolves to an array of results for the requested page
|
|
56
57
|
*/
|
|
57
|
-
async page(page = 1) {
|
|
58
|
+
async page(page = 1, ...args) {
|
|
59
|
+
const contextArgs = await db_decorators_1.Context.args(db_decorators_1.OperationKeys.READ, this.clazz, args, this.adapter);
|
|
58
60
|
const statement = this.prepare(this.statement);
|
|
59
61
|
if (!this._recordCount || !this._totalPages) {
|
|
60
62
|
this._totalPages = this._recordCount = 0;
|
|
61
|
-
const results = (await this.adapter.raw({ ...statement, limit: undefined })) || [];
|
|
63
|
+
const results = (await this.adapter.raw({ ...statement, limit: undefined }, contextArgs.context)) || [];
|
|
62
64
|
this._recordCount = results.length;
|
|
63
65
|
if (this._recordCount > 0) {
|
|
64
66
|
const size = statement?.limit || this.size;
|
|
@@ -67,7 +69,7 @@ class RamPaginator extends query_1.Paginator {
|
|
|
67
69
|
}
|
|
68
70
|
page = this.validatePage(page);
|
|
69
71
|
statement.skip = (page - 1) * this.size;
|
|
70
|
-
const results = await this.adapter.raw(statement);
|
|
72
|
+
const results = await this.adapter.raw(statement, await this.adapter.context(db_decorators_1.OperationKeys.READ, {}, this.clazz));
|
|
71
73
|
this._currentPage = page;
|
|
72
74
|
return results;
|
|
73
75
|
}
|
|
@@ -3,6 +3,7 @@ import { Paginator } from "../query";
|
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
4
|
import { Adapter } from "../persistence";
|
|
5
5
|
import { Constructor } from "@decaf-ts/decoration";
|
|
6
|
+
import { MaybeContextualArg } from "../utils/index";
|
|
6
7
|
/**
|
|
7
8
|
* @description RAM-specific paginator implementation
|
|
8
9
|
* @summary Extends the base Paginator class to provide pagination functionality for RAM adapter queries.
|
|
@@ -49,5 +50,5 @@ export declare class RamPaginator<M extends Model, R> extends Paginator<M, R, Ra
|
|
|
49
50
|
* @param {number} [page=1] - The page number to retrieve (1-based)
|
|
50
51
|
* @return {Promise<R[]>} A promise that resolves to an array of results for the requested page
|
|
51
52
|
*/
|
|
52
|
-
page(page?: number): Promise<R[]>;
|
|
53
|
+
page(page?: number, ...args: MaybeContextualArg<any>): Promise<R[]>;
|
|
53
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RamPaginator.js","sourceRoot":"","sources":["../../src/ram/RamPaginator.ts"],"names":[],"mappings":";;;AACA,gDAAqC;
|
|
1
|
+
{"version":3,"file":"RamPaginator.js","sourceRoot":"","sources":["../../src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AM,IAAI,GAAG,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC;gBAC3C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC/B,SAAS,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QACxC,MAAM,OAAO,GAAU,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAC3C,SAAS,EACT,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,6BAAa,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAC/D,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAlED,oCAkEC"}
|
package/lib/ram/RamSequence.cjs
CHANGED
|
@@ -33,7 +33,7 @@ const repository_1 = require("./../repository/index.cjs");
|
|
|
33
33
|
*/
|
|
34
34
|
class RamSequence extends persistence_1.Sequence {
|
|
35
35
|
constructor(options, adapter) {
|
|
36
|
-
super(options);
|
|
36
|
+
super(options, adapter);
|
|
37
37
|
this.repo = repository_1.Repository.forModel(RamSequenceModel_1.RamSequenceModel, adapter.alias);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
@@ -42,10 +42,12 @@ class RamSequence extends persistence_1.Sequence {
|
|
|
42
42
|
* doesn't exist yet, it returns the configured starting value.
|
|
43
43
|
* @return A promise that resolves to the current sequence value
|
|
44
44
|
*/
|
|
45
|
-
async current() {
|
|
45
|
+
async current(...args) {
|
|
46
|
+
const contextArgs = await db_decorators_1.Context.args(db_decorators_1.OperationKeys.READ, RamSequenceModel_1.RamSequenceModel, args, this.adapter);
|
|
47
|
+
const ctx = contextArgs.context;
|
|
46
48
|
const { name, startWith } = this.options;
|
|
47
49
|
try {
|
|
48
|
-
const sequence = await this.repo.read(name);
|
|
50
|
+
const sequence = await this.repo.read(name, ctx);
|
|
49
51
|
return this.parse(sequence.current);
|
|
50
52
|
}
|
|
51
53
|
catch (e) {
|
|
@@ -62,16 +64,6 @@ class RamSequence extends persistence_1.Sequence {
|
|
|
62
64
|
throw new db_decorators_1.InternalError(`Failed to retrieve current value for sequence ${name}: ${e}`);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
/**
|
|
66
|
-
* @description Parses a value according to the sequence type
|
|
67
|
-
* @summary Converts a value to the appropriate type for the sequence (string, number, or bigint)
|
|
68
|
-
* using the base Sequence class's parseValue method.
|
|
69
|
-
* @param {string | number | bigint} value - The value to parse
|
|
70
|
-
* @return {string | number | bigint} The parsed value in the correct type
|
|
71
|
-
*/
|
|
72
|
-
parse(value) {
|
|
73
|
-
return persistence_1.Sequence.parseValue(this.options.type, value);
|
|
74
|
-
}
|
|
75
67
|
/**
|
|
76
68
|
* @description Increments the sequence value
|
|
77
69
|
* @summary Increases the current sequence value by the specified amount and persists
|
|
@@ -80,7 +72,7 @@ class RamSequence extends persistence_1.Sequence {
|
|
|
80
72
|
* @param {number} [count] - Optional amount to increment by, defaults to the sequence's incrementBy value
|
|
81
73
|
* @return A promise that resolves to the new sequence value after incrementing
|
|
82
74
|
*/
|
|
83
|
-
async increment(current, count) {
|
|
75
|
+
async increment(current, count, ctx) {
|
|
84
76
|
const { type, incrementBy, name } = this.options;
|
|
85
77
|
let next;
|
|
86
78
|
const toIncrementBy = count || incrementBy;
|
|
@@ -101,16 +93,16 @@ class RamSequence extends persistence_1.Sequence {
|
|
|
101
93
|
}
|
|
102
94
|
let seq;
|
|
103
95
|
const repo = this.repo.override({
|
|
104
|
-
ignoredValidationProperties: ["
|
|
96
|
+
ignoredValidationProperties: ["updatedAt"],
|
|
105
97
|
});
|
|
106
98
|
try {
|
|
107
|
-
seq = await repo.update(new RamSequenceModel_1.RamSequenceModel({ id: name, current: next }));
|
|
99
|
+
seq = await repo.update(new RamSequenceModel_1.RamSequenceModel({ id: name, current: next }), ctx);
|
|
108
100
|
}
|
|
109
101
|
catch (e) {
|
|
110
102
|
if (!(e instanceof db_decorators_1.NotFoundError)) {
|
|
111
103
|
throw e;
|
|
112
104
|
}
|
|
113
|
-
seq = await repo.create(new RamSequenceModel_1.RamSequenceModel({ id: name, current: next }));
|
|
105
|
+
seq = await repo.create(new RamSequenceModel_1.RamSequenceModel({ id: name, current: next }), ctx);
|
|
114
106
|
}
|
|
115
107
|
return seq.current;
|
|
116
108
|
}
|
|
@@ -120,9 +112,11 @@ class RamSequence extends persistence_1.Sequence {
|
|
|
120
112
|
* configured increment amount. This is the main method used to get a new sequential value.
|
|
121
113
|
* @return A promise that resolves to the next value in the sequence
|
|
122
114
|
*/
|
|
123
|
-
async next() {
|
|
124
|
-
const
|
|
125
|
-
|
|
115
|
+
async next(...argz) {
|
|
116
|
+
const contextArgs = await db_decorators_1.Context.args(db_decorators_1.OperationKeys.UPDATE, RamSequenceModel_1.RamSequenceModel, argz, this.adapter);
|
|
117
|
+
const { context, args } = contextArgs;
|
|
118
|
+
const current = await this.current(...args);
|
|
119
|
+
return this.increment(current, undefined, context);
|
|
126
120
|
}
|
|
127
121
|
/**
|
|
128
122
|
* @description Generates a range of sequential values
|
|
@@ -132,10 +126,12 @@ class RamSequence extends persistence_1.Sequence {
|
|
|
132
126
|
* @param {number} count - The number of sequential values to generate
|
|
133
127
|
* @return A promise that resolves to an array of sequential values
|
|
134
128
|
*/
|
|
135
|
-
async range(count) {
|
|
136
|
-
const
|
|
129
|
+
async range(count, ...argz) {
|
|
130
|
+
const contextArgs = await db_decorators_1.Context.args(db_decorators_1.OperationKeys.UPDATE, RamSequenceModel_1.RamSequenceModel, argz, this.adapter);
|
|
131
|
+
const { context, args } = contextArgs;
|
|
132
|
+
const current = (await this.current(...args));
|
|
137
133
|
const incrementBy = this.parse(this.options.incrementBy);
|
|
138
|
-
const next = await this.increment(current, this.parse(count) * incrementBy);
|
|
134
|
+
const next = await this.increment(current, this.parse(count) * incrementBy, context);
|
|
139
135
|
const range = [];
|
|
140
136
|
for (let i = 1; i <= count; i++) {
|
|
141
137
|
range.push(current + incrementBy * this.parse(i));
|
package/lib/ram/RamSequence.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Sequence } from "../persistence";
|
|
|
3
3
|
import { SequenceOptions } from "../interfaces";
|
|
4
4
|
import { RamAdapter } from "./RamAdapter";
|
|
5
5
|
import { Repo } from "../repository";
|
|
6
|
+
import { MaybeContextualArg } from "../utils/index";
|
|
6
7
|
/**
|
|
7
8
|
* @description RAM-specific sequence implementation
|
|
8
9
|
* @summary Extends the base Sequence class to provide auto-incrementing sequence functionality
|
|
@@ -38,15 +39,7 @@ export declare class RamSequence extends Sequence {
|
|
|
38
39
|
* doesn't exist yet, it returns the configured starting value.
|
|
39
40
|
* @return A promise that resolves to the current sequence value
|
|
40
41
|
*/
|
|
41
|
-
current(): Promise<string | number | bigint>;
|
|
42
|
-
/**
|
|
43
|
-
* @description Parses a value according to the sequence type
|
|
44
|
-
* @summary Converts a value to the appropriate type for the sequence (string, number, or bigint)
|
|
45
|
-
* using the base Sequence class's parseValue method.
|
|
46
|
-
* @param {string | number | bigint} value - The value to parse
|
|
47
|
-
* @return {string | number | bigint} The parsed value in the correct type
|
|
48
|
-
*/
|
|
49
|
-
private parse;
|
|
42
|
+
current(...args: MaybeContextualArg<any>): Promise<string | number | bigint>;
|
|
50
43
|
/**
|
|
51
44
|
* @description Increments the sequence value
|
|
52
45
|
* @summary Increases the current sequence value by the specified amount and persists
|
|
@@ -62,7 +55,7 @@ export declare class RamSequence extends Sequence {
|
|
|
62
55
|
* configured increment amount. This is the main method used to get a new sequential value.
|
|
63
56
|
* @return A promise that resolves to the next value in the sequence
|
|
64
57
|
*/
|
|
65
|
-
next(): Promise<number | string | bigint>;
|
|
58
|
+
next(...argz: MaybeContextualArg<any>): Promise<number | string | bigint>;
|
|
66
59
|
/**
|
|
67
60
|
* @description Generates a range of sequential values
|
|
68
61
|
* @summary Retrieves a specified number of sequential values from the sequence.
|
|
@@ -71,5 +64,5 @@ export declare class RamSequence extends Sequence {
|
|
|
71
64
|
* @param {number} count - The number of sequential values to generate
|
|
72
65
|
* @return A promise that resolves to an array of sequential values
|
|
73
66
|
*/
|
|
74
|
-
range(count: number): Promise<(number | string | bigint)[]>;
|
|
67
|
+
range(count: number, ...argz: MaybeContextualArg<any>): Promise<(number | string | bigint)[]>;
|
|
75
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RamSequence.js","sourceRoot":"","sources":["../../src/ram/RamSequence.ts"],"names":[],"mappings":";;;AAAA,mEAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"RamSequence.js","sourceRoot":"","sources":["../../src/ram/RamSequence.ts"],"names":[],"mappings":";;;AAAA,mEAA4D;AAC5D,2DAKiC;AACjC,4DAA0C;AAG1C,0DAAiD;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,WAAY,SAAQ,sBAAQ;IAGvC,YAAY,OAAwB,EAAE,OAAmB;QACvD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,uBAAU,CAAC,QAAQ,CAAC,mCAAgB,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CACX,GAAG,IAA6B;QAEhC,MAAM,WAAW,GAAG,MAAM,uBAAO,CAAC,IAAI,CACpC,6BAAa,CAAC,IAAI,EAClB,mCAAgB,EAChB,IAAI,EACJ,IAAI,CAAC,OAAO,CACb,CAAC;QACF,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC;QAChC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACzC,IAAI,CAAC;YACH,MAA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SAAS,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,CACT,KAAa,EACb,GAAG,IAA6B;QAEhC,MAAM,WAAW,GAAG,MAAM,uBAAO,CAAC,IAAI,CACpC,6BAAa,CAAC,MAAM,EACpB,mCAAgB,EAChB,IAAI,EACJ,IAAI,CAAC,OAAO,CACb,CAAC;QACF,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;QACtC,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAW,CAAC;QACxD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,OAAO,CAAC,WAAqB,CACzB,CAAC;QACZ,MAAM,IAAI,GAA6B,MAAM,IAAI,CAAC,SAAS,CACzD,OAAO,EACN,IAAI,CAAC,KAAK,CAAC,KAAK,CAAY,GAAG,WAAW,EAC3C,OAAO,CACR,CAAC;QACF,MAAM,KAAK,GAAiC,EAAE,CAAC;QAC/C,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,WAAW,GAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAY,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ;YACpE,MAAM,IAAI,6BAAa,CAAC,yBAAyB,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAlKD,kCAkKC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Condition, Paginator } from "../query";
|
|
2
|
-
import { RawRamQuery } from "./types";
|
|
2
|
+
import { RamContext, RawRamQuery } from "./types";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
4
|
import { Statement } from "../query/Statement";
|
|
5
|
-
import {
|
|
5
|
+
import { Adapter } from "../persistence/index";
|
|
6
6
|
/**
|
|
7
7
|
* @description RAM-specific query statement builder
|
|
8
8
|
* @summary Extends the base Statement class to provide query building functionality for the RAM adapter.
|
|
@@ -30,8 +30,8 @@ import { RamAdapter } from "./RamAdapter";
|
|
|
30
30
|
* .execute();
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
export declare class RamStatement<M extends Model, R
|
|
34
|
-
constructor(adapter:
|
|
33
|
+
export declare class RamStatement<M extends Model, R, A extends Adapter<M, any, RawRamQuery<any>, RamContext>> extends Statement<M, A, R, RawRamQuery<any>> {
|
|
34
|
+
constructor(adapter: A);
|
|
35
35
|
/**
|
|
36
36
|
* @description Creates a sort comparator function
|
|
37
37
|
* @summary Generates a function that compares two model instances based on the orderBy criteria.
|
|
@@ -46,7 +46,7 @@ export declare class RamStatement<M extends Model, R> extends Statement<RawRamQu
|
|
|
46
46
|
* (select, from, where, limit, offset, sort) into the final query structure.
|
|
47
47
|
* @return {RawRamQuery<M>} The constructed RAM query object
|
|
48
48
|
*/
|
|
49
|
-
protected build(): RawRamQuery<
|
|
49
|
+
protected build(): RawRamQuery<any>;
|
|
50
50
|
/**
|
|
51
51
|
* @description Creates a paginator for the query
|
|
52
52
|
* @summary Builds the query and wraps it in a RamPaginator to enable pagination of results.
|
|
@@ -54,7 +54,7 @@ export declare class RamStatement<M extends Model, R> extends Statement<RawRamQu
|
|
|
54
54
|
* @param {number} size - The page size (number of results per page)
|
|
55
55
|
* @return {Promise<Paginator<M, R, RawRamQuery<M>>>} A promise that resolves to a paginator for the query
|
|
56
56
|
*/
|
|
57
|
-
paginate(size: number): Promise<Paginator<M, R, RawRamQuery<
|
|
57
|
+
paginate(size: number): Promise<Paginator<M, R, RawRamQuery<any>>>;
|
|
58
58
|
/**
|
|
59
59
|
* @description Parses a condition into a RAM query predicate
|
|
60
60
|
* @summary Converts a Condition object into a predicate function that can be used
|
|
@@ -82,5 +82,5 @@ export declare class RamStatement<M extends Model, R> extends Statement<RawRamQu
|
|
|
82
82
|
* end
|
|
83
83
|
* RamStatement-->>Caller: Return query with where predicate
|
|
84
84
|
*/
|
|
85
|
-
parseCondition
|
|
85
|
+
protected parseCondition(condition: Condition<M>): RawRamQuery<any>;
|
|
86
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RamStatement.js","sourceRoot":"","sources":["../../src/ram/RamStatement.ts"],"names":[],"mappings":";;;AAAA,gDAMkB;AAGlB,qDAA8C;AAC9C,2DAAwD;AACxD,wDAA+C;
|
|
1
|
+
{"version":3,"file":"RamStatement.js","sourceRoot":"","sources":["../../src/ram/RamStatement.ts"],"names":[],"mappings":";;;AAAA,gDAMkB;AAGlB,qDAA8C;AAC9C,2DAAwD;AACxD,wDAA+C;AAC/C,qDAAgD;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,YAIX,SAAQ,qBAAoC;IAC5C,YAAY,OAAU;QACpB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACK,OAAO;QACb,OAAO,CAAC,GAAU,EAAE,GAAU,EAAE,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,eAAe;gBACvB,MAAM,IAAI,6BAAa,CACrB,+CAA+C,CAChD,CAAC;YACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;YACtC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC;YAClC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,qBAAQ,CAAC,kBAAkB,CACtD,GAAG,CAAC,WAAkB,EACtB,GAAG,CACJ,CAAC;YACF,IAAI,CAAC,IAAI;gBACP,MAAM,IAAI,kBAAU,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;YAEpE,QAAQ,IA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