@mrxsys/mrx-core 2.4.0 → 2.5.1
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/CHANGELOG.md +329 -31
- package/README.md +3 -3
- package/dist/chunk-1a3wj3m1.js +272 -0
- package/dist/chunk-370444pc.js +43 -0
- package/dist/chunk-5qtpggzv.js +38 -0
- package/dist/chunk-84mqvfsk.js +69 -0
- package/dist/chunk-cq973ydc.js +82 -0
- package/dist/chunk-f5z7x01b.js +352 -0
- package/dist/chunk-pc66jgqv.js +220 -0
- package/dist/chunk-s07amdhx.js +77 -0
- package/dist/chunk-v8v7982b.js +58 -0
- package/dist/chunk-vknq69e0.js +23 -0
- package/dist/chunk-yvyahr2h.js +40 -0
- package/dist/errors/baseError.d.ts +9 -0
- package/dist/errors/enums/httpErrorStatusCodes.d.ts +42 -0
- package/dist/errors/httpError.d.ts +14 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +11 -0
- package/dist/errors/types/baseErrorOptions.d.ts +15 -0
- package/dist/errors/types/httpErrorOptions.d.ts +13 -0
- package/dist/errors/types/index.d.ts +2 -0
- package/dist/modules/data/data.d.ts +115 -0
- package/dist/modules/data/enums/dataErrorKeys.d.ts +3 -0
- package/dist/modules/data/index.d.ts +1 -0
- package/dist/modules/data/index.js +16 -0
- package/dist/modules/data/transformers/camelCase.d.ts +25 -0
- package/dist/modules/data/transformers/index.d.ts +4 -0
- package/dist/modules/data/transformers/index.js +32 -0
- package/dist/modules/data/transformers/kebabCase.d.ts +25 -0
- package/dist/modules/data/transformers/pascalCase.d.ts +25 -0
- package/dist/modules/data/transformers/snakeCase.d.ts +25 -0
- package/dist/modules/data/types/camelCase.d.ts +1 -0
- package/dist/modules/data/types/caseTransformer.d.ts +13 -0
- package/dist/modules/data/types/index.d.ts +10 -0
- package/dist/modules/data/types/kebabCase.d.ts +1 -0
- package/dist/modules/data/types/pascalCase.d.ts +2 -0
- package/dist/modules/data/types/snakeCase.d.ts +1 -0
- package/dist/modules/data/types/transformKeysCamelCase.d.ts +4 -0
- package/dist/modules/data/types/transformKeysKebabCase.d.ts +4 -0
- package/dist/modules/data/types/transformKeysPascalCase.d.ts +4 -0
- package/dist/modules/data/types/transformKeysSnakeCase.d.ts +4 -0
- package/dist/modules/data/types/transformObjectKeys.d.ts +9 -0
- package/dist/modules/database/enums/databaseErrorKeys.d.ts +28 -0
- package/dist/modules/database/enums/mssqlErrorCode.d.ts +25 -0
- package/dist/modules/database/events/index.d.ts +2 -0
- package/dist/modules/database/events/mssqlEventMap.d.ts +6 -0
- package/dist/modules/database/events/tableEventMap.d.ts +7 -0
- package/dist/modules/database/index.d.ts +2 -0
- package/dist/modules/database/index.js +14 -0
- package/dist/{database → modules/database}/mssql.d.ts +21 -25
- package/dist/{database → modules/database}/table.d.ts +6 -6
- package/dist/modules/database/types/index.d.ts +3 -0
- package/dist/{database → modules/database}/types/mssqlDatabaseOption.d.ts +16 -37
- package/dist/modules/database/types/mssqlEventLog.d.ts +14 -0
- package/dist/modules/database/types/queryContext.d.ts +11 -0
- package/dist/modules/elysia/crud/crud.d.ts +46 -0
- package/dist/modules/elysia/crud/index.d.ts +1 -0
- package/dist/modules/elysia/crud/index.js +299 -0
- package/dist/modules/elysia/crud/types/crudOperationBaseOptions.d.ts +6 -0
- package/dist/modules/elysia/crud/types/crudOperationCountOptions.d.ts +2 -0
- package/dist/modules/elysia/crud/types/crudOperationDeleteOneOptions.d.ts +2 -0
- package/dist/modules/elysia/crud/types/crudOperationDeleteOptions.d.ts +2 -0
- package/dist/modules/elysia/crud/types/crudOperationFindOneOptions.d.ts +2 -0
- package/dist/modules/elysia/crud/types/crudOperationFindOptions.d.ts +2 -0
- package/dist/modules/elysia/crud/types/crudOperationInsertOptions.d.ts +2 -0
- package/dist/modules/elysia/crud/types/crudOperationUpdateOneOptions.d.ts +2 -0
- package/dist/modules/elysia/crud/types/crudOperationUpdateOptions.d.ts +2 -0
- package/dist/modules/elysia/crud/types/crudOperationsOptions.d.ts +18 -0
- package/dist/modules/elysia/crud/types/crudOptions.d.ts +23 -0
- package/dist/modules/elysia/crud/types/index.d.ts +11 -0
- package/dist/modules/elysia/crudSchema/crudSchema.d.ts +18 -0
- package/dist/modules/elysia/crudSchema/index.d.ts +1 -0
- package/dist/modules/elysia/crudSchema/index.js +10 -0
- package/dist/modules/elysia/crudSchema/types/adaptiveWhereClauseSchema.d.ts +31 -0
- package/dist/modules/elysia/crudSchema/types/crudModelsType.d.ts +14 -0
- package/dist/modules/elysia/crudSchema/types/crudSchemaOperations.d.ts +10 -0
- package/dist/modules/elysia/crudSchema/types/crudSchemaOptions.d.ts +13 -0
- package/dist/modules/elysia/crudSchema/types/index.d.ts +8 -0
- package/dist/modules/elysia/crudSchema/types/orderSchema.d.ts +11 -0
- package/dist/modules/elysia/crudSchema/types/qSchema.d.ts +15 -0
- package/dist/modules/elysia/crudSchema/types/queryOptionsBuilderOptions.d.ts +11 -0
- package/dist/modules/elysia/crudSchema/types/selectedFieldSchema.d.ts +6 -0
- package/dist/modules/elysia/crudSchema/utils/createAdaptiveWhereClauseSchema.d.ts +17 -0
- package/dist/modules/elysia/crudSchema/utils/createCountResponse200Schema.d.ts +11 -0
- package/dist/modules/elysia/crudSchema/utils/createCountSchema.d.ts +16 -0
- package/dist/modules/elysia/crudSchema/utils/createDeleteSchema.d.ts +18 -0
- package/dist/modules/elysia/crudSchema/utils/createFiltersSchema.d.ts +17 -0
- package/dist/modules/elysia/crudSchema/utils/createFindSchema.d.ts +22 -0
- package/dist/modules/elysia/crudSchema/utils/createIdParamSchema.d.ts +4 -0
- package/dist/modules/elysia/crudSchema/utils/createInsertSchema.d.ts +8 -0
- package/dist/modules/elysia/crudSchema/utils/createOrderSchema.d.ts +12 -0
- package/dist/modules/elysia/crudSchema/utils/createPropertiesSchema.d.ts +12 -0
- package/dist/modules/elysia/crudSchema/utils/createQSchema.d.ts +12 -0
- package/dist/modules/elysia/crudSchema/utils/createResponse200Schema.d.ts +5 -0
- package/dist/modules/elysia/crudSchema/utils/createSelectedFieldsSchema.d.ts +12 -0
- package/dist/modules/elysia/crudSchema/utils/createUpdateOneSchema.d.ts +4 -0
- package/dist/modules/elysia/crudSchema/utils/createUpdateSchema.d.ts +10 -0
- package/dist/modules/elysia/crudSchema/utils/index.d.ts +15 -0
- package/dist/modules/elysia/crudSchema/utils/index.js +37 -0
- package/dist/modules/elysia/crudSchema/utils/isDateFromElysiaTypeBox.d.ts +2 -0
- package/dist/modules/elysia/dbResolver/dbResolver.d.ts +17 -0
- package/dist/modules/elysia/dbResolver/enums/dbResolverErrorKeys.d.ts +3 -0
- package/dist/modules/elysia/dbResolver/index.d.ts +1 -0
- package/dist/modules/elysia/dbResolver/index.js +14 -0
- package/dist/modules/elysia/dbResolver/types/dynamicDbOptions.d.ts +7 -0
- package/dist/modules/elysia/dbResolver/types/index.d.ts +1 -0
- package/dist/modules/elysia/error/error.d.ts +34 -0
- package/dist/modules/elysia/error/index.d.ts +1 -0
- package/dist/modules/elysia/error/index.js +58 -0
- package/dist/modules/elysia/jwt/enums/jwtErrorKeys.d.ts +4 -0
- package/dist/modules/elysia/jwt/index.d.ts +1 -0
- package/dist/modules/elysia/jwt/index.js +81 -0
- package/dist/modules/elysia/jwt/jwt.d.ts +119 -0
- package/dist/modules/elysia/jwt/types/index.d.ts +1 -0
- package/dist/modules/elysia/jwt/types/jwtOptions.d.ts +98 -0
- package/dist/modules/elysia/microservice/index.d.ts +1 -0
- package/dist/modules/elysia/microservice/index.js +96 -0
- package/dist/{elysia → modules/elysia/microservice}/microservice.d.ts +1 -1
- package/dist/modules/elysia/ratelimit/enums/ratelimitErrorKeys.d.ts +3 -0
- package/dist/modules/elysia/ratelimit/index.d.ts +1 -0
- package/dist/modules/elysia/ratelimit/index.js +55 -0
- package/dist/{elysia → modules/elysia/ratelimit}/ratelimit.d.ts +3 -13
- package/dist/modules/elysia/ratelimit/types/index.d.ts +1 -0
- package/dist/{elysia → modules/elysia/ratelimit}/types/rateLimitOptions.d.ts +6 -16
- package/dist/modules/logger/enums/loggerErrorKeys.d.ts +6 -0
- package/dist/modules/logger/events/index.d.ts +1 -0
- package/dist/modules/logger/events/loggerEvents.d.ts +11 -0
- package/dist/modules/logger/index.d.ts +1 -0
- package/dist/modules/logger/index.js +139 -0
- package/dist/modules/logger/logger.d.ts +189 -0
- package/dist/{logger → modules/logger}/strategies/consoleLogger.d.ts +4 -4
- package/dist/{logger → modules/logger}/strategies/fileLogger.d.ts +4 -4
- package/dist/modules/logger/strategies/index.d.ts +2 -0
- package/dist/modules/logger/strategies/index.js +44 -0
- package/dist/modules/logger/types/index.d.ts +6 -0
- package/dist/modules/logger/types/index.js +1 -0
- package/dist/{logger → modules/logger}/types/logStreamChunk.d.ts +4 -4
- package/dist/{logger → modules/logger}/types/loggerStrategy.d.ts +1 -1
- package/dist/modules/mailer/enums/mailerErrorKeys.d.ts +5 -0
- package/dist/modules/mailer/index.d.ts +1 -0
- package/dist/modules/mailer/index.js +64 -0
- package/dist/{mailer → modules/mailer}/smtp.d.ts +6 -6
- package/dist/modules/mailer/types/index.d.ts +3 -0
- package/dist/modules/mailer/types/index.js +1 -0
- package/dist/{mailer → modules/mailer}/types/smtpCredentials.d.ts +2 -2
- package/dist/{mailer → modules/mailer}/types/smtpOptions.d.ts +5 -5
- package/dist/{mailer → modules/mailer}/types/smtpPoolOptions.d.ts +1 -1
- package/dist/modules/repository/index.d.ts +1 -0
- package/dist/modules/repository/index.js +10 -0
- package/dist/modules/repository/repository.d.ts +421 -0
- package/dist/modules/repository/types/adaptiveWhereClause.d.ts +30 -0
- package/dist/modules/repository/types/filter.d.ts +43 -0
- package/dist/modules/repository/types/index.d.ts +8 -0
- package/dist/modules/repository/types/index.js +1 -0
- package/dist/modules/repository/types/orderByItem.d.ts +42 -0
- package/dist/modules/repository/types/queryOptions.d.ts +36 -0
- package/dist/{repository → modules/repository}/types/queryOptionsExtendPagination.d.ts +2 -2
- package/dist/{repository → modules/repository}/types/queryOptionsExtendStream.d.ts +1 -1
- package/dist/modules/repository/types/selectedFields.d.ts +37 -0
- package/dist/modules/singletonManager/enums/singletonManagerErrorKeys.d.ts +4 -0
- package/dist/modules/singletonManager/index.d.ts +1 -0
- package/dist/modules/singletonManager/index.js +8 -0
- package/dist/modules/singletonManager/singletonManager.d.ts +75 -0
- package/dist/modules/typedEventEmitter/index.d.ts +1 -0
- package/dist/modules/typedEventEmitter/index.js +7 -0
- package/dist/{typedEventEmitter → modules/typedEventEmitter}/typedEventEmitter.d.ts +33 -11
- package/dist/modules/typedEventEmitter/types/index.d.ts +1 -0
- package/dist/modules/typedEventEmitter/types/index.js +1 -0
- package/dist/utils/enums/utilsErrorKeys.d.ts +3 -0
- package/dist/utils/env.d.ts +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +32 -1
- package/dist/utils/isDateString.d.ts +16 -0
- package/dist/utils/stream.d.ts +12 -1
- package/dist/utils/types/index.d.ts +1 -1
- package/dist/utils/types/streamWithAsyncIterable.d.ts +12 -5
- package/package.json +157 -128
- package/dist/chunk-1c7w5cx7.js +0 -3
- package/dist/chunk-40pg2cqx.js +0 -2
- package/dist/chunk-4v4tp5qj.js +0 -2
- package/dist/chunk-4w7nd4nw.js +0 -2
- package/dist/chunk-5nvsx7md.js +0 -2
- package/dist/chunk-89mnpfvy.js +0 -2
- package/dist/chunk-91srr77d.js +0 -2
- package/dist/chunk-9hj714bv.js +0 -2
- package/dist/chunk-9rss6865.js +0 -2
- package/dist/chunk-df9xr1f5.js +0 -2
- package/dist/chunk-dq00mfya.js +0 -2
- package/dist/chunk-fnb68m68.js +0 -2
- package/dist/chunk-g6a16nyh.js +0 -2
- package/dist/chunk-gtgpa8nc.js +0 -2
- package/dist/chunk-gxjax5n3.js +0 -2
- package/dist/chunk-h9er1sh5.js +0 -2
- package/dist/chunk-mwpajm9x.js +0 -2
- package/dist/chunk-n5w9cwwg.js +0 -2
- package/dist/chunk-pt7wrvtr.js +0 -2
- package/dist/chunk-qndyhwdn.js +0 -2
- package/dist/chunk-v5dfx8mh.js +0 -2
- package/dist/chunk-wgq0yyqw.js +0 -2
- package/dist/chunk-wtfcgg9s.js +0 -2
- package/dist/chunk-z00b1r18.js +0 -2
- package/dist/data/data.d.ts +0 -99
- package/dist/data/enums/dataErrorKeys.d.ts +0 -7
- package/dist/data/enums/index.d.ts +0 -1
- package/dist/data/enums/index.js +0 -2
- package/dist/data/index.d.ts +0 -1
- package/dist/data/index.js +0 -2
- package/dist/data/transformers/camelCase.d.ts +0 -25
- package/dist/data/transformers/index.d.ts +0 -4
- package/dist/data/transformers/index.js +0 -2
- package/dist/data/transformers/kebabCase.d.ts +0 -25
- package/dist/data/transformers/pascalCase.d.ts +0 -25
- package/dist/data/transformers/snakeCase.d.ts +0 -25
- package/dist/data/types/index.d.ts +0 -1
- package/dist/data/types/keyTransformer.d.ts +0 -11
- package/dist/database/enums/databaseErrorKeys.d.ts +0 -52
- package/dist/database/enums/index.d.ts +0 -2
- package/dist/database/enums/index.js +0 -2
- package/dist/database/enums/mssqlErrorCode.d.ts +0 -25
- package/dist/database/events/index.d.ts +0 -2
- package/dist/database/events/mssqlEventMap.d.ts +0 -6
- package/dist/database/events/tableEventMap.d.ts +0 -7
- package/dist/database/index.d.ts +0 -2
- package/dist/database/index.js +0 -2
- package/dist/database/types/index.d.ts +0 -3
- package/dist/database/types/mssqlEventLog.d.ts +0 -29
- package/dist/database/types/queryContext.d.ts +0 -11
- package/dist/elysia/advancedSearch.d.ts +0 -460
- package/dist/elysia/crud.d.ts +0 -609
- package/dist/elysia/dynamicDatabaseSelector.d.ts +0 -352
- package/dist/elysia/enums/elysiaErrorKeys.d.ts +0 -12
- package/dist/elysia/enums/httpStatusCode.d.ts +0 -241
- package/dist/elysia/enums/index.d.ts +0 -2
- package/dist/elysia/enums/index.js +0 -2
- package/dist/elysia/error.d.ts +0 -46
- package/dist/elysia/index.d.ts +0 -7
- package/dist/elysia/index.js +0 -2
- package/dist/elysia/jwt.d.ts +0 -46
- package/dist/elysia/schemas/index.d.ts +0 -2
- package/dist/elysia/schemas/index.js +0 -2
- package/dist/elysia/types/crudOptions.d.ts +0 -126
- package/dist/elysia/types/crudRoutes.d.ts +0 -2
- package/dist/elysia/types/dynamicDatabaseSelectorPluginOptions.d.ts +0 -30
- package/dist/elysia/types/index.d.ts +0 -5
- package/dist/elysia/types/jwtOptions.d.ts +0 -92
- package/dist/error/coreError.d.ts +0 -89
- package/dist/error/index.d.ts +0 -1
- package/dist/error/index.js +0 -2
- package/dist/error/types/coreErrorOptions.d.ts +0 -21
- package/dist/error/types/index.d.ts +0 -1
- package/dist/index.d.ts +0 -68
- package/dist/index.js +0 -2
- package/dist/logger/enums/index.d.ts +0 -1
- package/dist/logger/enums/index.js +0 -2
- package/dist/logger/enums/loggerErrorKeys.d.ts +0 -6
- package/dist/logger/events/index.d.ts +0 -1
- package/dist/logger/events/loggerEvents.d.ts +0 -4
- package/dist/logger/index.d.ts +0 -1
- package/dist/logger/index.js +0 -2
- package/dist/logger/logger.d.ts +0 -173
- package/dist/logger/strategies/index.d.ts +0 -2
- package/dist/logger/strategies/index.js +0 -2
- package/dist/logger/types/index.d.ts +0 -6
- package/dist/mailer/enums/index.d.ts +0 -1
- package/dist/mailer/enums/index.js +0 -2
- package/dist/mailer/enums/mailerErrorKeys.d.ts +0 -8
- package/dist/mailer/index.d.ts +0 -1
- package/dist/mailer/index.js +0 -2
- package/dist/mailer/types/index.d.ts +0 -3
- package/dist/repository/index.d.ts +0 -1
- package/dist/repository/index.js +0 -2
- package/dist/repository/repository.d.ts +0 -378
- package/dist/repository/types/advancedSearch.d.ts +0 -47
- package/dist/repository/types/index.d.ts +0 -8
- package/dist/repository/types/orderBy.d.ts +0 -21
- package/dist/repository/types/queryOptions.d.ts +0 -33
- package/dist/repository/types/selectedFields.d.ts +0 -16
- package/dist/repository/types/whereClause.d.ts +0 -15
- package/dist/singletonManager/enums/index.d.ts +0 -1
- package/dist/singletonManager/enums/index.js +0 -2
- package/dist/singletonManager/enums/singletonManagerErrorKeys.d.ts +0 -7
- package/dist/singletonManager/index.d.ts +0 -1
- package/dist/singletonManager/index.js +0 -2
- package/dist/singletonManager/singletonManager.d.ts +0 -112
- package/dist/store/index.d.ts +0 -1
- package/dist/store/index.js +0 -2
- package/dist/store/redis.d.ts +0 -6
- package/dist/typedEventEmitter/index.d.ts +0 -1
- package/dist/typedEventEmitter/index.js +0 -2
- package/dist/typedEventEmitter/types/index.d.ts +0 -1
- package/dist/utils/enums/index.d.ts +0 -1
- package/dist/utils/enums/index.js +0 -2
- package/dist/utils/enums/utilErrorKeys.d.ts +0 -4
- package/dist/utils/isIsoDateString.d.ts +0 -1
- /package/dist/{data → errors}/types/index.js +0 -0
- /package/dist/{database/events → modules/data/types}/index.js +0 -0
- /package/dist/{database/types → modules/database/events}/index.js +0 -0
- /package/dist/{elysia → modules/database}/types/index.js +0 -0
- /package/dist/{error → modules/elysia/crud}/types/index.js +0 -0
- /package/dist/{logger/events → modules/elysia/crudSchema/types}/index.js +0 -0
- /package/dist/{logger → modules/elysia/dbResolver}/types/index.js +0 -0
- /package/dist/{mailer → modules/elysia/jwt}/types/index.js +0 -0
- /package/dist/{elysia → modules/elysia/microservice}/schemas/info.d.ts +0 -0
- /package/dist/{elysia → modules/elysia/microservice}/schemas/ping.d.ts +0 -0
- /package/dist/{repository → modules/elysia/ratelimit}/types/index.js +0 -0
- /package/dist/{typedEventEmitter/types → modules/logger/events}/index.js +0 -0
- /package/dist/{logger → modules/logger}/types/bodiesIntersection.d.ts +0 -0
- /package/dist/{logger → modules/logger}/types/logLevels.d.ts +0 -0
- /package/dist/{logger → modules/logger}/types/strategyBody.d.ts +0 -0
- /package/dist/{logger → modules/logger}/types/strategyMap.d.ts +0 -0
- /package/dist/{repository → modules/repository}/types/transaction.d.ts +0 -0
- /package/dist/{typedEventEmitter → modules/typedEventEmitter}/types/eventMap.d.ts +0 -0
package/dist/logger/logger.d.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { TypedEventEmitter } from '../typedEventEmitter/typedEventEmitter';
|
|
2
|
-
import type { LoggerEvent } from './events/loggerEvents';
|
|
3
|
-
import type { BodiesIntersection } from './types/bodiesIntersection';
|
|
4
|
-
import type { LoggerStrategy } from './types/loggerStrategy';
|
|
5
|
-
import type { StrategyMap } from './types/strategyMap';
|
|
6
|
-
/**
|
|
7
|
-
* Logger provides a flexible, type-safe logging system that allows multiple strategies for log output.
|
|
8
|
-
* The logger uses a transform stream to process log entries and execute the logging strategies.
|
|
9
|
-
*
|
|
10
|
-
* Logger extends the {@link TypedEventEmitter} class to emit typed events when an error occurs or when the logger ends.
|
|
11
|
-
* The logger can log messages with different levels: error, warn, info, debug, and log.
|
|
12
|
-
*
|
|
13
|
-
* @template TStrategies - The map of strategy names to LoggerStrategy types.
|
|
14
|
-
*/
|
|
15
|
-
export declare class Logger<TStrategies extends StrategyMap = {}> extends TypedEventEmitter<LoggerEvent> {
|
|
16
|
-
/**
|
|
17
|
-
* The map of strategies.
|
|
18
|
-
*/
|
|
19
|
-
private readonly _strategies;
|
|
20
|
-
/**
|
|
21
|
-
* The transform stream for processing log entries.
|
|
22
|
-
*/
|
|
23
|
-
private readonly _logStream;
|
|
24
|
-
/**
|
|
25
|
-
* The queue of pending log entries.
|
|
26
|
-
*/
|
|
27
|
-
private readonly _pendingLogs;
|
|
28
|
-
/**
|
|
29
|
-
* The maximum number of pending logs.
|
|
30
|
-
* @defaultValue 10_000
|
|
31
|
-
*/
|
|
32
|
-
private readonly _maxPendingLogs;
|
|
33
|
-
/**
|
|
34
|
-
* Flag to indicate if the logger is currently writing logs.
|
|
35
|
-
*/
|
|
36
|
-
private _isWriting;
|
|
37
|
-
/**
|
|
38
|
-
* Construct a Logger.
|
|
39
|
-
*
|
|
40
|
-
* @template TStrategies - The map of strategy names to LoggerStrategy types.
|
|
41
|
-
* @param strategies - Initial strategies map.
|
|
42
|
-
* @param maxPendingLogs - Maximum number of logs in the queue (default: 10_000)
|
|
43
|
-
*/
|
|
44
|
-
constructor(strategies?: TStrategies, maxPendingLogs?: number);
|
|
45
|
-
/**
|
|
46
|
-
* Register a new logging strategy.
|
|
47
|
-
*
|
|
48
|
-
* @template Key - The name of the strategy.
|
|
49
|
-
* @template Strategy - The strategy type.
|
|
50
|
-
*
|
|
51
|
-
* @throws ({@link CoreError}): If the strategy is already added. ({@link loggerErrorKeys.stategyAlreadyAdded})
|
|
52
|
-
*
|
|
53
|
-
* @returns A new Logger instance with the added strategy.
|
|
54
|
-
*/
|
|
55
|
-
registerStrategy<Key extends string, Strategy extends LoggerStrategy>(name: Key, strategy: Strategy): Logger<TStrategies & Record<Key, Strategy>>;
|
|
56
|
-
/**
|
|
57
|
-
* Unregister a logging strategy.
|
|
58
|
-
*
|
|
59
|
-
* @template Key - The name of the strategy.
|
|
60
|
-
*
|
|
61
|
-
* @throws ({@link CoreError}): If the strategy is not found. ({@link loggerErrorKeys.strategyNotFound})
|
|
62
|
-
*
|
|
63
|
-
* @returns A new Logger instance without the removed strategy.
|
|
64
|
-
*/
|
|
65
|
-
unregisterStrategy<Key extends keyof TStrategies>(name: Key): Logger<Omit<TStrategies, Key>>;
|
|
66
|
-
/**
|
|
67
|
-
* Register multiple strategies at once.
|
|
68
|
-
*
|
|
69
|
-
* @template TNew - The new strategies to add.
|
|
70
|
-
*
|
|
71
|
-
* @throws ({@link CoreError}): If any strategy is already added. ({@link loggerErrorKeys.stategyAlreadyAdded})
|
|
72
|
-
*
|
|
73
|
-
* @returns A new Logger instance with the added strategies.
|
|
74
|
-
*/
|
|
75
|
-
registerStrategies<TNew extends [string, LoggerStrategy][] = [string, LoggerStrategy][]>(strategies: TNew): Logger<TStrategies & {
|
|
76
|
-
[K in TNew[number][0]]: Extract<TNew[number], [K, LoggerStrategy]>[1];
|
|
77
|
-
}>;
|
|
78
|
-
/**
|
|
79
|
-
* Unregister multiple strategies at once.
|
|
80
|
-
*
|
|
81
|
-
* @template Keys - The names of the strategies to remove.
|
|
82
|
-
*
|
|
83
|
-
* @throws ({@link CoreError}): If any strategy is not found. ({@link loggerErrorKeys.strategyNotFound})
|
|
84
|
-
*
|
|
85
|
-
* @returns A new Logger instance without the removed strategies.
|
|
86
|
-
*/
|
|
87
|
-
unregisterStrategies<Keys extends Extract<keyof TStrategies, string>>(names: Keys[]): Logger<Omit<TStrategies, Keys>>;
|
|
88
|
-
/**
|
|
89
|
-
* Remove all strategies.
|
|
90
|
-
*
|
|
91
|
-
* @returns A new Logger instance without any strategies.
|
|
92
|
-
*/
|
|
93
|
-
clearStrategies(): Logger;
|
|
94
|
-
/**
|
|
95
|
-
* Log an error message.
|
|
96
|
-
*
|
|
97
|
-
* @template SNames - The names of the strategies to use.
|
|
98
|
-
*
|
|
99
|
-
* @param object - The object to log. ({@link BodiesIntersection})
|
|
100
|
-
* @param strategiesNames - The names of the strategies to use. If not provided, all strategies will be used.
|
|
101
|
-
*
|
|
102
|
-
* @throws ({@link CoreError}): If no strategy is added. ({@link loggerErrorKeys.noStrategyAdded})
|
|
103
|
-
*/
|
|
104
|
-
error<SNames extends (keyof TStrategies)[] = (keyof TStrategies)[]>(object: BodiesIntersection<TStrategies, SNames[number]>, strategiesNames?: SNames): void;
|
|
105
|
-
/**
|
|
106
|
-
* Log a warning message.
|
|
107
|
-
*
|
|
108
|
-
* @template SNames - The names of the strategies to use.
|
|
109
|
-
*
|
|
110
|
-
* @param object - The object to log. ({@link BodiesIntersection})
|
|
111
|
-
* @param strategiesNames - The names of the strategies to use. If not provided, all strategies will be used.
|
|
112
|
-
*
|
|
113
|
-
* @throws ({@link CoreError}): If no strategy is added. ({@link loggerErrorKeys.noStrategyAdded})
|
|
114
|
-
*/
|
|
115
|
-
warn<SNames extends (keyof TStrategies)[] = (keyof TStrategies)[]>(object: BodiesIntersection<TStrategies, SNames[number]>, strategiesNames?: SNames): void;
|
|
116
|
-
/**
|
|
117
|
-
* Log an info message.
|
|
118
|
-
*
|
|
119
|
-
* @template SNames - The names of the strategies to use.
|
|
120
|
-
*
|
|
121
|
-
* @param object - The object to log. ({@link BodiesIntersection})
|
|
122
|
-
* @param strategiesNames - The names of the strategies to use. If not provided, all strategies will be used.
|
|
123
|
-
*
|
|
124
|
-
* @throws ({@link CoreError}): If no strategy is added. ({@link loggerErrorKeys.noStrategyAdded})
|
|
125
|
-
*/
|
|
126
|
-
info<SNames extends (keyof TStrategies)[] = (keyof TStrategies)[]>(object: BodiesIntersection<TStrategies, SNames[number]>, strategiesNames?: SNames): void;
|
|
127
|
-
/**
|
|
128
|
-
* Log a debug message.
|
|
129
|
-
*
|
|
130
|
-
* @template SNames - The names of the strategies to use.
|
|
131
|
-
*
|
|
132
|
-
* @param object - The object to log. ({@link BodiesIntersection})
|
|
133
|
-
* @param strategiesNames - The names of the strategies to use. If not provided, all strategies will be used.
|
|
134
|
-
*
|
|
135
|
-
* @throws ({@link CoreError}): If no strategy is added. ({@link loggerErrorKeys.noStrategyAdded})
|
|
136
|
-
*/
|
|
137
|
-
debug<SNames extends (keyof TStrategies)[] = (keyof TStrategies)[]>(object: BodiesIntersection<TStrategies, SNames[number]>, strategiesNames?: SNames): void;
|
|
138
|
-
/**
|
|
139
|
-
* Log a generic message.
|
|
140
|
-
*
|
|
141
|
-
* @template SNames - The names of the strategies to use.
|
|
142
|
-
*
|
|
143
|
-
* @param object - The object to log. ({@link BodiesIntersection})
|
|
144
|
-
* @param strategiesNames - The names of the strategies to use. If not provided, all strategies will be used.
|
|
145
|
-
*
|
|
146
|
-
* @throws ({@link CoreError}): If no strategy is added. ({@link loggerErrorKeys.noStrategyAdded})
|
|
147
|
-
*/
|
|
148
|
-
log<SNames extends (keyof TStrategies)[] = (keyof TStrategies)[]>(object: BodiesIntersection<TStrategies, SNames[number]>, strategiesNames?: SNames): void;
|
|
149
|
-
/**
|
|
150
|
-
* Internal: execute all strategies for a log event.
|
|
151
|
-
*
|
|
152
|
-
* @template TLogObject - The type of the log object.
|
|
153
|
-
*
|
|
154
|
-
* @throws ({@link CoreError}): If a strategy throws. ({@link loggerErrorKeys.loggerStrategyError})
|
|
155
|
-
*/
|
|
156
|
-
private _executeStrategies;
|
|
157
|
-
/**
|
|
158
|
-
* Internal: queue a log event and start writing if not already.
|
|
159
|
-
*
|
|
160
|
-
* @template TLogObject - The type of the log object.
|
|
161
|
-
*
|
|
162
|
-
* @param level - The log level. ({@link LogLevels})
|
|
163
|
-
* @param object - The object to log.
|
|
164
|
-
* @param strategiesNames - The names of the strategies to use. If not provided, all strategies will be used.
|
|
165
|
-
*
|
|
166
|
-
* @throws ({@link CoreError}): If no strategy is added. ({@link loggerErrorKeys.noStrategyAdded})
|
|
167
|
-
*/
|
|
168
|
-
private _out;
|
|
169
|
-
/**
|
|
170
|
-
* Internal: process the log queue and emit 'end' when done.
|
|
171
|
-
*/
|
|
172
|
-
private _writeLog;
|
|
173
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './mailerErrorKeys';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const mailerErrorKeys: {
|
|
2
|
-
/** Error when failing to connect to SMTP server. */
|
|
3
|
-
readonly smtpConnectionError: "core.error.mailer.smtp.connection_error";
|
|
4
|
-
/** Error when SMTP server is not connected. */
|
|
5
|
-
readonly smtpNotConnected: "core.error.mailer.smtp.not_connected";
|
|
6
|
-
/** Error when SMTP server is already connected. */
|
|
7
|
-
readonly smtpAlreadyConnected: "core.error.mailer.smtp.already_connected";
|
|
8
|
-
};
|
package/dist/mailer/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './smtp';
|
package/dist/mailer/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './repository';
|
package/dist/repository/index.js
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import type { Knex } from 'knex';
|
|
2
|
-
import type { Table } from '../database/table';
|
|
3
|
-
import type { StreamWithAsyncIterable } from '../utils/types/streamWithAsyncIterable';
|
|
4
|
-
import type { AdvancedSearch } from './types/advancedSearch';
|
|
5
|
-
import type { QueryOptions } from './types/queryOptions';
|
|
6
|
-
import type { QueryOptionsExtendPagination } from './types/queryOptionsExtendPagination';
|
|
7
|
-
import type { QueryOptionsExtendStream } from './types/queryOptionsExtendStream';
|
|
8
|
-
/**
|
|
9
|
-
* Provides a type-safe, extensible interface for database operations (CRUD, search, streaming) on a table.
|
|
10
|
-
*
|
|
11
|
-
* - Wraps Knex.js for query building and execution.
|
|
12
|
-
* - Supports advanced search, pagination, field selection, and streaming.
|
|
13
|
-
* - Centralizes error handling for MSSQL.
|
|
14
|
-
*
|
|
15
|
-
* @template TModel - The data model type handled by the repository.
|
|
16
|
-
*
|
|
17
|
-
* Example:
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const repo = new Repository<User>(knex, userTable);
|
|
20
|
-
* const users = await repo.find({ limit: 10 });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare class Repository<TModel = unknown> {
|
|
24
|
-
/**
|
|
25
|
-
* The Knex instance used for database operations.
|
|
26
|
-
*/
|
|
27
|
-
protected readonly _knex: Knex;
|
|
28
|
-
/**
|
|
29
|
-
* The table associated with this repository.
|
|
30
|
-
* @see {@link Table}
|
|
31
|
-
*/
|
|
32
|
-
protected readonly _table: Table;
|
|
33
|
-
/**
|
|
34
|
-
* Creates a new `Repository` instance with the specified Knex.js instance and table object.
|
|
35
|
-
*
|
|
36
|
-
* @param knex - The Knex.js instance used to interact with the database.
|
|
37
|
-
* @param table - The table object representing the database table to interact with.
|
|
38
|
-
*/
|
|
39
|
-
constructor(knex: Knex, table: Table);
|
|
40
|
-
/**
|
|
41
|
-
* Finds records in the database based on the specified query options and returns a stream
|
|
42
|
-
* for async iteration. This method is particularly useful when working with large datasets
|
|
43
|
-
* that would be inefficient to load entirely into memory.
|
|
44
|
-
*
|
|
45
|
-
* The stream emits data events for each record and an end event when the stream is finished.
|
|
46
|
-
* It can be consumed using either async iteration or event listeners.
|
|
47
|
-
*
|
|
48
|
-
* @template KModel - The type of the object to retrieve.
|
|
49
|
-
* @param options - The query options to apply to the search. ({@link QueryOptionsExtendStream})
|
|
50
|
-
*
|
|
51
|
-
* @returns A stream with an async iterable interface for consuming the results. ({@link StreamWithAsyncIterable})
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* ### Usage Examples:
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* // Basic usage with async iteration
|
|
58
|
-
* const stream = userRepository.findStream();
|
|
59
|
-
* for await (const user of stream) {
|
|
60
|
-
* console.log(user);
|
|
61
|
-
* }
|
|
62
|
-
*
|
|
63
|
-
* // With ordering and field selection
|
|
64
|
-
* const stream = userRepository.findStream({
|
|
65
|
-
* selectedFields: ['id', 'name', 'email'],
|
|
66
|
-
* orderBy: ['createdDate', 'desc']
|
|
67
|
-
* });
|
|
68
|
-
*
|
|
69
|
-
* // Using event listeners
|
|
70
|
-
* const stream = userRepository.findStream();
|
|
71
|
-
* stream.on('data', (user) => {
|
|
72
|
-
* console.log('User:', user);
|
|
73
|
-
* });
|
|
74
|
-
* stream.on('error', (error) => {
|
|
75
|
-
* console.error('Stream error:', error);
|
|
76
|
-
* });
|
|
77
|
-
* stream.on('end', () => {
|
|
78
|
-
* console.log('Stream completed');
|
|
79
|
-
* });
|
|
80
|
-
*
|
|
81
|
-
* // With transform function to process records
|
|
82
|
-
* const stream = userRepository.findStream({
|
|
83
|
-
* transform: (chunk, encoding, callback) => {
|
|
84
|
-
* // Transform the data
|
|
85
|
-
* const transformedData = { ...chunk, processed: true };
|
|
86
|
-
* callback(null, transformedData);
|
|
87
|
-
* }
|
|
88
|
-
* });
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
findStream<KModel extends TModel = NoInfer<TModel>>(options?: QueryOptionsExtendStream<KModel>): StreamWithAsyncIterable<KModel[]>;
|
|
92
|
-
/**
|
|
93
|
-
* Finds records in the database based on the specified query options and returns the results
|
|
94
|
-
* as an array. This method supports comprehensive filtering, pagination, field selection, and sorting
|
|
95
|
-
* to provide flexible data retrieval capabilities.
|
|
96
|
-
*
|
|
97
|
-
* @template KModel - The type of the object to retrieve.
|
|
98
|
-
* @param options - The query options to apply to the search. ({@link QueryOptionsExtendPagination})
|
|
99
|
-
*
|
|
100
|
-
* @throws ({@link CoreError}) Throws an error if no records are found and the `throwIfNoResult` option is enabled. ({@link databaseErrorKeys.mssqlNoResult})
|
|
101
|
-
* @throws ({@link CoreError}) Throws an error if an MSSQL-specific error occurs during the query execution. ({@link databaseErrorKeys})
|
|
102
|
-
*
|
|
103
|
-
* @returns An array of records matching the query options. ({@link KModel})
|
|
104
|
-
*
|
|
105
|
-
* ### Usage Examples:
|
|
106
|
-
* @example
|
|
107
|
-
* ```typescript
|
|
108
|
-
* // Basic usage with pagination
|
|
109
|
-
* const users = await userRepository.find({
|
|
110
|
-
* limit: 25,
|
|
111
|
-
* offset: 50 // Get users 51-75
|
|
112
|
-
* });
|
|
113
|
-
*
|
|
114
|
-
* // With field selection
|
|
115
|
-
* const userNames = await userRepository.find({
|
|
116
|
-
* selectedFields: ['id', 'firstName', 'lastName']
|
|
117
|
-
* });
|
|
118
|
-
*
|
|
119
|
-
* // With advanced filtering
|
|
120
|
-
* const activeAdmins = await userRepository.find({
|
|
121
|
-
* advancedSearch: {
|
|
122
|
-
* role: 'admin',
|
|
123
|
-
* status: { $eq: 'active' },
|
|
124
|
-
* lastLogin: { $gte: new Date('2023-01-01') }
|
|
125
|
-
* }
|
|
126
|
-
* });
|
|
127
|
-
*
|
|
128
|
-
* // With OR conditions
|
|
129
|
-
* const results = await userRepository.find({
|
|
130
|
-
* advancedSearch: [
|
|
131
|
-
* { department: 'engineering' },
|
|
132
|
-
* { department: 'design', role: 'lead' }
|
|
133
|
-
* ]
|
|
134
|
-
* });
|
|
135
|
-
*
|
|
136
|
-
* // With sorting
|
|
137
|
-
* const sortedUsers = await userRepository.find({
|
|
138
|
-
* orderBy: ['lastName', 'asc']
|
|
139
|
-
* });
|
|
140
|
-
*
|
|
141
|
-
* // Using a transaction
|
|
142
|
-
* await knex.transaction(async (trx) => {
|
|
143
|
-
* const users = await userRepository.find({
|
|
144
|
-
* advancedSearch: { department: 'finance' },
|
|
145
|
-
* transaction: trx
|
|
146
|
-
* });
|
|
147
|
-
* });
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
find<KModel extends TModel = NoInfer<TModel>>(options?: QueryOptionsExtendPagination<KModel>): Promise<KModel[]>;
|
|
151
|
-
/**
|
|
152
|
-
* Finds a single record in the database based on the specified query options and returns the result.
|
|
153
|
-
* This method supports comprehensive filtering, field selection, and sorting to provide flexible data retrieval capabilities.
|
|
154
|
-
*
|
|
155
|
-
* @template KModel - The type of the object to retrieve.
|
|
156
|
-
* @param options - The query options to apply to the search. ({@link QueryOptionsExtendPagination})
|
|
157
|
-
*
|
|
158
|
-
* @throws ({@link CoreError}) Throws an error if no records are found and the `throwIfNoResult` option is enabled. ({@link databaseErrorKeys.mssqlNoResult})
|
|
159
|
-
* @throws ({@link CoreError}) Throws an error if an MSSQL-specific error occurs during the query execution. ({@link databaseErrorKeys})
|
|
160
|
-
*
|
|
161
|
-
* @returns A single record matching the query options. ({@link KModel})
|
|
162
|
-
*
|
|
163
|
-
* ### Usage Examples:
|
|
164
|
-
* @example
|
|
165
|
-
* ```typescript
|
|
166
|
-
* // Basic usage
|
|
167
|
-
* const user = await userRepository.findOne({
|
|
168
|
-
* advancedSearch: { id: 1 }
|
|
169
|
-
* });
|
|
170
|
-
*
|
|
171
|
-
* // With field selection
|
|
172
|
-
* const user = await userRepository.findOne({
|
|
173
|
-
* selectedFields: ['id', 'firstName', 'lastName'],
|
|
174
|
-
* advancedSearch: { id: 1 }
|
|
175
|
-
* });
|
|
176
|
-
*
|
|
177
|
-
* // With advanced filtering
|
|
178
|
-
* const user = await userRepository.findOne({
|
|
179
|
-
* advancedSearch: {
|
|
180
|
-
* role: 'admin',
|
|
181
|
-
* status: { $eq: 'active' },
|
|
182
|
-
* }
|
|
183
|
-
* });
|
|
184
|
-
*
|
|
185
|
-
* // With sorting
|
|
186
|
-
* const user = await userRepository.findOne({
|
|
187
|
-
* orderBy: ['lastName', 'asc']
|
|
188
|
-
* });
|
|
189
|
-
*
|
|
190
|
-
* // Using a transaction
|
|
191
|
-
* await knex.transaction(async (trx) => {
|
|
192
|
-
* const user = await userRepository.findOne({
|
|
193
|
-
* advancedSearch: { department: 'finance' },
|
|
194
|
-
* transaction: trx
|
|
195
|
-
* });
|
|
196
|
-
* });
|
|
197
|
-
* ```
|
|
198
|
-
*/
|
|
199
|
-
findOne<KModel extends TModel = NoInfer<TModel>>(options: Omit<QueryOptions<KModel>, 'advancedSearch'> & Required<Pick<QueryOptions<KModel>, 'advancedSearch'>>): Promise<KModel>;
|
|
200
|
-
/**
|
|
201
|
-
* Counts the number of records in the database based on the specified query options.
|
|
202
|
-
* This method supports advanced search capabilities to filter the records before counting.
|
|
203
|
-
*
|
|
204
|
-
* @template KModel - The type of the object to count.
|
|
205
|
-
* @param options - The query options to apply to the search. ({@link QueryOptions})
|
|
206
|
-
*
|
|
207
|
-
* @throws ({@link CoreError}) Throws an error if no records are found and the `throwIfNoResult` option is enabled. ({@link databaseErrorKeys.mssqlNoResult})
|
|
208
|
-
* @throws ({@link CoreError}) Throws an error if an MSSQL-specific error occurs during the query execution. ({@link databaseErrorKeys})
|
|
209
|
-
*
|
|
210
|
-
* @returns The count of records matching the query options.
|
|
211
|
-
*
|
|
212
|
-
* ### Usage Examples:
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* // Basic usage
|
|
216
|
-
* const userCount = await userRepository.count();
|
|
217
|
-
*
|
|
218
|
-
* // With advanced filtering
|
|
219
|
-
* const activeUserCount = await userRepository.count({
|
|
220
|
-
* advancedSearch: { status: 'active' }
|
|
221
|
-
* });
|
|
222
|
-
*
|
|
223
|
-
* // Using a transaction
|
|
224
|
-
* await knex.transaction(async (trx) => {
|
|
225
|
-
* const userCount = await userRepository.count({
|
|
226
|
-
* advancedSearch: { department: 'finance' },
|
|
227
|
-
* transaction: trx
|
|
228
|
-
* });
|
|
229
|
-
* });
|
|
230
|
-
* ```
|
|
231
|
-
*/
|
|
232
|
-
count<KModel extends TModel = NoInfer<TModel>>(options?: Omit<QueryOptions<KModel>, 'selectedFields' | 'orderBy'>): Promise<number>;
|
|
233
|
-
/**
|
|
234
|
-
* Inserts new records into the database and returns the inserted records.
|
|
235
|
-
* This method supports bulk insertion of multiple records at once.
|
|
236
|
-
*
|
|
237
|
-
* @template KModel - The type of the object to insert.
|
|
238
|
-
* @param data - The data to insert. Can be a single object or an array of objects.
|
|
239
|
-
* @param options - The query options to apply to the insertion. ({@link QueryOptions})
|
|
240
|
-
*
|
|
241
|
-
* @throws ({@link CoreError}) Throws an error if an MSSQL-specific error occurs during the query execution. ({@link databaseErrorKeys})
|
|
242
|
-
*
|
|
243
|
-
* @returns An array of inserted records.
|
|
244
|
-
*
|
|
245
|
-
* ### Usage Examples:
|
|
246
|
-
* @example
|
|
247
|
-
* ```typescript
|
|
248
|
-
* // Basic usage
|
|
249
|
-
* const newUser = await userRepository.insert({ name: 'John Doe', email: 'john.doe@example.com' });
|
|
250
|
-
*
|
|
251
|
-
* // With bulk insertion
|
|
252
|
-
* const users = await userRepository.insert([
|
|
253
|
-
* { name: 'Jane Doe', email: 'jane.doe@example.com' },
|
|
254
|
-
* { name: 'John Smith', email: 'john.smith@example.com' }
|
|
255
|
-
* ]);
|
|
256
|
-
*
|
|
257
|
-
* // Using a transaction
|
|
258
|
-
* await knex.transaction(async (trx) => {
|
|
259
|
-
* const newUser = await userRepository.insert({ name: 'John Doe', email: 'john.doe@example.com' }, {
|
|
260
|
-
* transaction: trx
|
|
261
|
-
* });
|
|
262
|
-
* });
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
insert<KModel extends TModel = NoInfer<TModel>>(data: Partial<KModel> | Partial<KModel>[], options?: Omit<QueryOptions<KModel>, 'advancedSearch' | 'orderBy'>): Promise<KModel[]>;
|
|
266
|
-
/**
|
|
267
|
-
* Updates existing records in the database based on the specified query options and returns the updated records.
|
|
268
|
-
* This method supports advanced search capabilities to filter the records before updating.
|
|
269
|
-
*
|
|
270
|
-
* @template KModel - The type of the object to update.
|
|
271
|
-
* @param data - The data to update. Can be a single object or an array of objects.
|
|
272
|
-
* @param options - The query options to apply to the update. ({@link QueryOptions})
|
|
273
|
-
*
|
|
274
|
-
* @throws ({@link CoreError}) Throws an error if an MSSQL-specific error occurs during the query execution. ({@link databaseErrorKeys})
|
|
275
|
-
*
|
|
276
|
-
* @returns An array of updated records.
|
|
277
|
-
*
|
|
278
|
-
* ### Usage Examples:
|
|
279
|
-
* @example
|
|
280
|
-
* ```typescript
|
|
281
|
-
* // Basic usage
|
|
282
|
-
* const updatedUser = await userRepository.update({ name: 'John Doe' }, {
|
|
283
|
-
* advancedSearch: { id: 1 }
|
|
284
|
-
* });
|
|
285
|
-
*
|
|
286
|
-
* // With advanced filtering
|
|
287
|
-
* const updatedUsers = await userRepository.update({ status: 'inactive' }, {
|
|
288
|
-
* advancedSearch: { role: 'admin' }
|
|
289
|
-
* });
|
|
290
|
-
*
|
|
291
|
-
* // Using a transaction
|
|
292
|
-
* await knex.transaction(async (trx) => {
|
|
293
|
-
* const updatedUser = await userRepository.update({ name: 'John Doe' }, {
|
|
294
|
-
* advancedSearch: { id: 1 },
|
|
295
|
-
* transaction: trx
|
|
296
|
-
* });
|
|
297
|
-
* });
|
|
298
|
-
* ```
|
|
299
|
-
*/
|
|
300
|
-
update<KModel extends TModel = NoInfer<TModel>>(data: Partial<KModel>, options: Omit<QueryOptions<KModel>, 'orderBy' | 'advancedSearch'> & Required<Pick<QueryOptions<KModel>, 'advancedSearch'>>): Promise<KModel[]>;
|
|
301
|
-
/**
|
|
302
|
-
* Deletes records from the database based on the specified query options and returns the deleted records.
|
|
303
|
-
* This method supports advanced search capabilities to filter the records before deletion.
|
|
304
|
-
*
|
|
305
|
-
* @template KModel - The type of the object to delete.
|
|
306
|
-
* @param options - The query options to apply to the deletion. ({@link QueryOptions})
|
|
307
|
-
*
|
|
308
|
-
* @throws ({@link CoreError}) Throws an error if an MSSQL-specific error occurs during the query execution. ({@link databaseErrorKeys})
|
|
309
|
-
*
|
|
310
|
-
* @returns An array of deleted records.
|
|
311
|
-
*
|
|
312
|
-
* ### Usage Examples:
|
|
313
|
-
* @example
|
|
314
|
-
* ```typescript
|
|
315
|
-
* // Basic usage
|
|
316
|
-
* const deletedUser = await userRepository.delete({
|
|
317
|
-
* advancedSearch: { id: 1 }
|
|
318
|
-
* });
|
|
319
|
-
*
|
|
320
|
-
* // With advanced filtering
|
|
321
|
-
* const deletedUsers = await userRepository.delete({
|
|
322
|
-
* advancedSearch: { status: 'inactive' }
|
|
323
|
-
* });
|
|
324
|
-
*
|
|
325
|
-
* // Using a transaction
|
|
326
|
-
* await knex.transaction(async (trx) => {
|
|
327
|
-
* const deletedUser = await userRepository.delete({
|
|
328
|
-
* advancedSearch: { id: 1 },
|
|
329
|
-
* transaction: trx
|
|
330
|
-
* });
|
|
331
|
-
* });
|
|
332
|
-
* ```
|
|
333
|
-
*/
|
|
334
|
-
delete<KModel extends TModel = NoInfer<TModel>>(options: Omit<QueryOptions<KModel>, 'orderBy' | 'advancedSearch'> & Required<Pick<QueryOptions<KModel>, 'advancedSearch'>>): Promise<KModel[]>;
|
|
335
|
-
/**
|
|
336
|
-
* Applies advanced search criteria to a Knex.js query builder. This method supports complex queries
|
|
337
|
-
* using operators like `$eq`, `$neq`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$nin`, `$between`, `$nbetween`,
|
|
338
|
-
* `$like`, `$nlike`, and `$isNull`. It also supports basic string searches and field selection.
|
|
339
|
-
*
|
|
340
|
-
* @template KModel - The type of the object to search for.
|
|
341
|
-
* @param query - The Knex.js query builder to apply the search criteria to. ({@link Knex.QueryBuilder})
|
|
342
|
-
* @param search - The advanced search criteria to apply. Can be a single object or an array of objects. ({@link AdvancedSearch})
|
|
343
|
-
*/
|
|
344
|
-
protected _applySearch<KModel>(query: Knex.QueryBuilder, search: AdvancedSearch<KModel> | AdvancedSearch<KModel>[]): void;
|
|
345
|
-
/**
|
|
346
|
-
* Handles errors that occur during query execution. This method centralizes error handling
|
|
347
|
-
* for MSSQL-specific errors and throws a {@link CoreError} with relevant information.
|
|
348
|
-
*
|
|
349
|
-
* @param error - The error object thrown by Knex.js.
|
|
350
|
-
* @param query - The Knex.js query builder that caused the error.
|
|
351
|
-
*
|
|
352
|
-
* @throws ({@link CoreError}) Throws an error if an MSSQL-specific error occurs during the query execution. ({@link databaseErrorKeys})
|
|
353
|
-
*
|
|
354
|
-
* @returns Never returns, always throws an error.
|
|
355
|
-
*/
|
|
356
|
-
protected _handleError(error: unknown, query: Knex.QueryBuilder): never;
|
|
357
|
-
/**
|
|
358
|
-
* Determines if the provided data is a complex query (i.e., a WhereClause).
|
|
359
|
-
*
|
|
360
|
-
* @param data - The data to check.
|
|
361
|
-
* @returns True if the data is a WhereClause, false otherwise.
|
|
362
|
-
*/
|
|
363
|
-
private _isComplexQuery;
|
|
364
|
-
/**
|
|
365
|
-
* Executes a Knex.js query and returns the result. This method provides centralized
|
|
366
|
-
* error handling and supports the option to throw an error if no records are found.
|
|
367
|
-
*
|
|
368
|
-
* @template KModel - The type of the records returned by the query.
|
|
369
|
-
* @param query - The Knex.js query builder to execute.
|
|
370
|
-
* @param throwIfNoResult - Whether to throw an error if no records are found.
|
|
371
|
-
*
|
|
372
|
-
* @throws ({@link CoreError}) Throws an error if no records are found and the `throwIfNoResult` option is enabled. ({@link databaseErrorKeys.mssqlNoResult})
|
|
373
|
-
* @throws ({@link CoreError}) Throws an error if an MSSQL-specific error occurs during the query execution. ({@link databaseErrorKeys})
|
|
374
|
-
*
|
|
375
|
-
* @returns An array of records returned by the query.
|
|
376
|
-
*/
|
|
377
|
-
protected _executeQuery<KModel>(query: Knex.QueryBuilder, throwIfNoResult?: boolean): Promise<KModel[]>;
|
|
378
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { WhereClause } from './whereClause';
|
|
2
|
-
import type { SelectedFields } from './selectedFields';
|
|
3
|
-
/**
|
|
4
|
-
* Defines an advanced search model using either plain partials of the model T or a {@link WhereClause} filter for more dynamic querying.
|
|
5
|
-
*
|
|
6
|
-
* @template TModel - The model type to be used for the advanced search.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* interface User {
|
|
11
|
-
* id: number;
|
|
12
|
-
* name: string;
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* interface Basket {
|
|
16
|
-
* id: number;
|
|
17
|
-
* userId: number;
|
|
18
|
-
* products: Product[];
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* const example1: AdvancedSearch<User> = {
|
|
22
|
-
* id: 1
|
|
23
|
-
* };
|
|
24
|
-
*
|
|
25
|
-
* const example2: AdvancedSearch<User> = {
|
|
26
|
-
* name: {
|
|
27
|
-
* $eq: 'John'
|
|
28
|
-
* }
|
|
29
|
-
* };
|
|
30
|
-
*
|
|
31
|
-
* const example3: AdvancedSearch<User> = {
|
|
32
|
-
* $q: 'John'
|
|
33
|
-
* };
|
|
34
|
-
*
|
|
35
|
-
* const example4: AdvancedSearch<User & Basket> = {
|
|
36
|
-
* 'basket.id': 1,
|
|
37
|
-
* };
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export type AdvancedSearch<TModel> = {
|
|
41
|
-
$q?: string | number | {
|
|
42
|
-
selectedFields: SelectedFields<TModel>;
|
|
43
|
-
value: string | number;
|
|
44
|
-
};
|
|
45
|
-
} & {
|
|
46
|
-
[Key in keyof TModel]?: TModel[Key] | Partial<WhereClause<TModel[Key]>>;
|
|
47
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type * from './advancedSearch';
|
|
2
|
-
export type * from './orderBy';
|
|
3
|
-
export type * from './queryOptions';
|
|
4
|
-
export type * from './queryOptionsExtendPagination';
|
|
5
|
-
export type * from './queryOptionsExtendStream';
|
|
6
|
-
export type * from './selectedFields';
|
|
7
|
-
export type * from './transaction';
|
|
8
|
-
export type * from './whereClause';
|