@decaf-ts/core 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/auth/constants.cjs +2 -2
- package/lib/cjs/auth/constants.cjs.map +1 -0
- package/lib/cjs/auth/decorators.cjs +1 -0
- package/lib/cjs/auth/decorators.cjs.map +1 -0
- package/lib/cjs/auth/index.cjs +1 -0
- package/lib/cjs/auth/index.cjs.map +1 -0
- package/lib/cjs/fs/FilesystemAdapter.cjs +40 -39
- package/lib/cjs/fs/FilesystemAdapter.cjs.map +1 -0
- package/lib/cjs/fs/FsDispatch.cjs +3 -2
- package/lib/cjs/fs/FsDispatch.cjs.map +1 -0
- package/lib/cjs/fs/helpers.cjs +1 -0
- package/lib/cjs/fs/helpers.cjs.map +1 -0
- package/lib/cjs/fs/index.cjs +1 -0
- package/lib/cjs/fs/index.cjs.map +1 -0
- package/lib/cjs/fs/indexStore.cjs +8 -7
- package/lib/cjs/fs/indexStore.cjs.map +1 -0
- package/lib/cjs/fs/locks/FilesystemLock.cjs +3 -2
- package/lib/cjs/fs/locks/FilesystemLock.cjs.map +1 -0
- package/lib/cjs/fs/locks/FilesystemMultiLock.cjs +5 -4
- package/lib/cjs/fs/locks/FilesystemMultiLock.cjs.map +1 -0
- package/lib/cjs/fs/types.cjs +1 -0
- package/lib/cjs/fs/types.cjs.map +1 -0
- package/lib/cjs/identity/decorators.cjs +11 -10
- package/lib/cjs/identity/decorators.cjs.map +1 -0
- package/lib/cjs/identity/index.cjs +1 -0
- package/lib/cjs/identity/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +4 -3
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/interfaces/ContextuallyLogged.cjs +1 -0
- package/lib/cjs/interfaces/ContextuallyLogged.cjs.map +1 -0
- package/lib/cjs/interfaces/ErrorParser.cjs +1 -0
- package/lib/cjs/interfaces/ErrorParser.cjs.map +1 -0
- package/lib/cjs/interfaces/Executor.cjs +1 -0
- package/lib/cjs/interfaces/Executor.cjs.map +1 -0
- package/lib/cjs/interfaces/Observable.cjs +1 -0
- package/lib/cjs/interfaces/Observable.cjs.map +1 -0
- package/lib/cjs/interfaces/Observer.cjs +1 -0
- package/lib/cjs/interfaces/Observer.cjs.map +1 -0
- package/lib/cjs/interfaces/Paginatable.cjs +1 -0
- package/lib/cjs/interfaces/Paginatable.cjs.map +1 -0
- package/lib/cjs/interfaces/Queriable.cjs +1 -0
- package/lib/cjs/interfaces/Queriable.cjs.map +1 -0
- package/lib/cjs/interfaces/RawExecutor.cjs +1 -0
- package/lib/cjs/interfaces/RawExecutor.cjs.map +1 -0
- package/lib/cjs/interfaces/SequenceOptions.cjs +1 -0
- package/lib/cjs/interfaces/SequenceOptions.cjs.map +1 -0
- package/lib/cjs/interfaces/index.cjs +1 -0
- package/lib/cjs/interfaces/index.cjs.map +1 -0
- package/lib/cjs/migrations/Migration.cjs +16 -15
- package/lib/cjs/migrations/Migration.cjs.map +1 -0
- package/lib/cjs/migrations/MigrationService.cjs +38 -37
- package/lib/cjs/migrations/MigrationService.cjs.map +1 -0
- package/lib/cjs/migrations/MigrationTaskBuilder.cjs +3 -2
- package/lib/cjs/migrations/MigrationTaskBuilder.cjs.map +1 -0
- package/lib/cjs/migrations/MigrationTasks.cjs +22 -17
- package/lib/cjs/migrations/MigrationTasks.cjs.map +1 -0
- package/lib/cjs/migrations/MigrationVersioning.cjs +1 -0
- package/lib/cjs/migrations/MigrationVersioning.cjs.map +1 -0
- package/lib/cjs/migrations/SemverMigrationVersioning.cjs +1 -0
- package/lib/cjs/migrations/SemverMigrationVersioning.cjs.map +1 -0
- package/lib/cjs/migrations/StandardMigrationVersioning.cjs +1 -0
- package/lib/cjs/migrations/StandardMigrationVersioning.cjs.map +1 -0
- package/lib/cjs/migrations/constants.cjs +3 -2
- package/lib/cjs/migrations/constants.cjs.map +1 -0
- package/lib/cjs/migrations/decorators.cjs +10 -9
- package/lib/cjs/migrations/decorators.cjs.map +1 -0
- package/lib/cjs/migrations/index.cjs +6 -5
- package/lib/cjs/migrations/index.cjs.map +1 -0
- package/lib/cjs/migrations/types.cjs +1 -0
- package/lib/cjs/migrations/types.cjs.map +1 -0
- package/lib/cjs/model/BaseModel.cjs +14 -8
- package/lib/cjs/model/BaseModel.cjs.map +1 -0
- package/lib/cjs/model/SequenceModel.cjs +19 -13
- package/lib/cjs/model/SequenceModel.cjs.map +1 -0
- package/lib/cjs/model/construction.cjs +27 -26
- package/lib/cjs/model/construction.cjs.map +1 -0
- package/lib/cjs/model/decorators.cjs +48 -47
- package/lib/cjs/model/decorators.cjs.map +1 -0
- package/lib/cjs/model/index.cjs +1 -0
- package/lib/cjs/model/index.cjs.map +1 -0
- package/lib/cjs/model/indexing.cjs +6 -5
- package/lib/cjs/model/indexing.cjs.map +1 -0
- package/lib/cjs/model/types.cjs +1 -0
- package/lib/cjs/model/types.cjs.map +1 -0
- package/lib/cjs/overrides/Metadata.cjs +1 -0
- package/lib/cjs/overrides/Metadata.cjs.map +1 -0
- package/lib/cjs/overrides/Model.cjs +1 -0
- package/lib/cjs/overrides/Model.cjs.map +1 -0
- package/lib/cjs/overrides/ModelBuilder.cjs +1 -0
- package/lib/cjs/overrides/ModelBuilder.cjs.map +1 -0
- package/lib/cjs/overrides/index.cjs +1 -0
- package/lib/cjs/overrides/index.cjs.map +1 -0
- package/lib/cjs/overrides/injectables.cjs +1 -0
- package/lib/cjs/overrides/injectables.cjs.map +1 -0
- package/lib/cjs/overrides/overrides.cjs +22 -21
- package/lib/cjs/overrides/overrides.cjs.map +1 -0
- package/lib/cjs/persistence/Adapter.cjs +47 -41
- package/lib/cjs/persistence/Adapter.cjs.map +1 -0
- package/lib/cjs/persistence/Context.cjs +10 -7
- package/lib/cjs/persistence/Context.cjs.map +1 -0
- package/lib/cjs/persistence/ContextLock.cjs +1 -0
- package/lib/cjs/persistence/ContextLock.cjs.map +1 -0
- package/lib/cjs/persistence/Dispatch.cjs +15 -14
- package/lib/cjs/persistence/Dispatch.cjs.map +1 -0
- package/lib/cjs/persistence/ObserverHandler.cjs +3 -2
- package/lib/cjs/persistence/ObserverHandler.cjs.map +1 -0
- package/lib/cjs/persistence/Sequence.cjs +19 -18
- package/lib/cjs/persistence/Sequence.cjs.map +1 -0
- package/lib/cjs/persistence/constants.cjs +14 -21
- package/lib/cjs/persistence/constants.cjs.map +1 -0
- package/lib/cjs/persistence/decorators.cjs +6 -5
- package/lib/cjs/persistence/decorators.cjs.map +1 -0
- package/lib/cjs/persistence/errors.cjs +1 -0
- package/lib/cjs/persistence/errors.cjs.map +1 -0
- package/lib/cjs/persistence/event-filters.cjs +5 -4
- package/lib/cjs/persistence/event-filters.cjs.map +1 -0
- package/lib/cjs/persistence/generators.cjs +1 -0
- package/lib/cjs/persistence/generators.cjs.map +1 -0
- package/lib/cjs/persistence/index.cjs +1 -0
- package/lib/cjs/persistence/index.cjs.map +1 -0
- package/lib/cjs/persistence/transactions.cjs +9 -8
- package/lib/cjs/persistence/transactions.cjs.map +1 -0
- package/lib/cjs/persistence/types.cjs +1 -0
- package/lib/cjs/persistence/types.cjs.map +1 -0
- package/lib/cjs/query/Condition.cjs +173 -165
- package/lib/cjs/query/Condition.cjs.map +1 -0
- package/lib/cjs/query/MethodQueryBuilder.cjs +37 -34
- package/lib/cjs/query/MethodQueryBuilder.cjs.map +1 -0
- package/lib/cjs/query/Paginator.cjs +28 -27
- package/lib/cjs/query/Paginator.cjs.map +1 -0
- package/lib/cjs/query/Statement.cjs +90 -84
- package/lib/cjs/query/Statement.cjs.map +1 -0
- package/lib/cjs/query/constants.cjs +5 -21
- package/lib/cjs/query/constants.cjs.map +1 -0
- package/lib/cjs/query/decorators.cjs +16 -15
- package/lib/cjs/query/decorators.cjs.map +1 -0
- package/lib/cjs/query/errors.cjs +1 -0
- package/lib/cjs/query/errors.cjs.map +1 -0
- package/lib/cjs/query/index.cjs +1 -0
- package/lib/cjs/query/index.cjs.map +1 -0
- package/lib/cjs/query/options.cjs +1 -0
- package/lib/cjs/query/options.cjs.map +1 -0
- package/lib/cjs/query/selectors.cjs +1 -0
- package/lib/cjs/query/selectors.cjs.map +1 -0
- package/lib/cjs/query/types.cjs +2 -13
- package/lib/cjs/query/types.cjs.map +1 -0
- package/lib/cjs/query/utils.cjs +10 -9
- package/lib/cjs/query/utils.cjs.map +1 -0
- package/lib/cjs/ram/RamAdapter.cjs +21 -20
- package/lib/cjs/ram/RamAdapter.cjs.map +1 -0
- package/lib/cjs/ram/RamPaginator.cjs +3 -2
- package/lib/cjs/ram/RamPaginator.cjs.map +1 -0
- package/lib/cjs/ram/RamStatement.cjs +38 -37
- package/lib/cjs/ram/RamStatement.cjs.map +1 -0
- package/lib/cjs/ram/constants.cjs +1 -0
- package/lib/cjs/ram/constants.cjs.map +1 -0
- package/lib/cjs/ram/handlers.cjs +3 -2
- package/lib/cjs/ram/handlers.cjs.map +1 -0
- package/lib/cjs/ram/index.cjs +8 -7
- package/lib/cjs/ram/index.cjs.map +1 -0
- package/lib/cjs/ram/types.cjs +1 -0
- package/lib/cjs/ram/types.cjs.map +1 -0
- package/lib/cjs/repository/Repository.cjs +85 -79
- package/lib/cjs/repository/Repository.cjs.map +1 -0
- package/lib/cjs/repository/constants.cjs +5 -20
- package/lib/cjs/repository/constants.cjs.map +1 -0
- package/lib/cjs/repository/decorators.cjs +7 -6
- package/lib/cjs/repository/decorators.cjs.map +1 -0
- package/lib/cjs/repository/errors.cjs +1 -0
- package/lib/cjs/repository/errors.cjs.map +1 -0
- package/lib/cjs/repository/index.cjs +1 -0
- package/lib/cjs/repository/index.cjs.map +1 -0
- package/lib/cjs/repository/injectables.cjs +14 -13
- package/lib/cjs/repository/injectables.cjs.map +1 -0
- package/lib/cjs/repository/types.cjs +1 -0
- package/lib/cjs/repository/types.cjs.map +1 -0
- package/lib/cjs/repository/utils.cjs +3 -2
- package/lib/cjs/repository/utils.cjs.map +1 -0
- package/lib/cjs/services/ModelService.cjs +36 -30
- package/lib/cjs/services/ModelService.cjs.map +1 -0
- package/lib/cjs/services/PersistenceService.cjs +9 -8
- package/lib/cjs/services/PersistenceService.cjs.map +1 -0
- package/lib/cjs/services/index.cjs +1 -0
- package/lib/cjs/services/index.cjs.map +1 -0
- package/lib/cjs/services/services.cjs +37 -31
- package/lib/cjs/services/services.cjs.map +1 -0
- package/lib/cjs/tasks/CleanUpTask.cjs +30 -24
- package/lib/cjs/tasks/CleanUpTask.cjs.map +1 -0
- package/lib/cjs/tasks/TaskContext.cjs +16 -15
- package/lib/cjs/tasks/TaskContext.cjs.map +1 -0
- package/lib/cjs/tasks/TaskEngine.cjs +112 -111
- package/lib/cjs/tasks/TaskEngine.cjs.map +1 -0
- package/lib/cjs/tasks/TaskErrors.cjs +1 -0
- package/lib/cjs/tasks/TaskErrors.cjs.map +1 -0
- package/lib/cjs/tasks/TaskEventBus.cjs +7 -6
- package/lib/cjs/tasks/TaskEventBus.cjs.map +1 -0
- package/lib/cjs/tasks/TaskEventService.cjs +8 -7
- package/lib/cjs/tasks/TaskEventService.cjs.map +1 -0
- package/lib/cjs/tasks/TaskHandler.cjs +5 -4
- package/lib/cjs/tasks/TaskHandler.cjs.map +1 -0
- package/lib/cjs/tasks/TaskHandlerRegistry.cjs +1 -0
- package/lib/cjs/tasks/TaskHandlerRegistry.cjs.map +1 -0
- package/lib/cjs/tasks/TaskService.cjs +43 -37
- package/lib/cjs/tasks/TaskService.cjs.map +1 -0
- package/lib/cjs/tasks/TaskStateChangeError.cjs +1 -0
- package/lib/cjs/tasks/TaskStateChangeError.cjs.map +1 -0
- package/lib/cjs/tasks/TaskTracker.cjs +62 -61
- package/lib/cjs/tasks/TaskTracker.cjs.map +1 -0
- package/lib/cjs/tasks/builder.cjs +30 -24
- package/lib/cjs/tasks/builder.cjs.map +1 -0
- package/lib/cjs/tasks/constants.cjs +6 -10
- package/lib/cjs/tasks/constants.cjs.map +1 -0
- package/lib/cjs/tasks/decorators.cjs +5 -4
- package/lib/cjs/tasks/decorators.cjs.map +1 -0
- package/lib/cjs/tasks/index.cjs +6 -5
- package/lib/cjs/tasks/index.cjs.map +1 -0
- package/lib/cjs/tasks/logging.cjs +12 -11
- package/lib/cjs/tasks/logging.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskBackoffModel.cjs +16 -10
- package/lib/cjs/tasks/models/TaskBackoffModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskErrorModel.cjs +11 -5
- package/lib/cjs/tasks/models/TaskErrorModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskEventModel.cjs +29 -23
- package/lib/cjs/tasks/models/TaskEventModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskIOSerializer.cjs +4 -3
- package/lib/cjs/tasks/models/TaskIOSerializer.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskLogEntryModel.cjs +11 -5
- package/lib/cjs/tasks/models/TaskLogEntryModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskModel.cjs +72 -66
- package/lib/cjs/tasks/models/TaskModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskStepResultModel.cjs +14 -8
- package/lib/cjs/tasks/models/TaskStepResultModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskStepSpecModel.cjs +11 -5
- package/lib/cjs/tasks/models/TaskStepSpecModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/index.cjs +1 -0
- package/lib/cjs/tasks/models/index.cjs.map +1 -0
- package/lib/cjs/tasks/types.cjs +1 -0
- package/lib/cjs/tasks/types.cjs.map +1 -0
- package/lib/cjs/tasks/utils.cjs +6 -5
- package/lib/cjs/tasks/utils.cjs.map +1 -0
- package/lib/cjs/utils/ContextualLoggedClass.cjs +5 -4
- package/lib/cjs/utils/ContextualLoggedClass.cjs.map +1 -0
- package/lib/cjs/utils/decorators.cjs +9 -8
- package/lib/cjs/utils/decorators.cjs.map +1 -0
- package/lib/cjs/utils/errors.cjs +1 -0
- package/lib/cjs/utils/errors.cjs.map +1 -0
- package/lib/cjs/utils/index.cjs +1 -0
- package/lib/cjs/utils/index.cjs.map +1 -0
- package/lib/cjs/utils/throttling.cjs +4 -3
- package/lib/cjs/utils/throttling.cjs.map +1 -0
- package/lib/cjs/utils/types.cjs +1 -0
- package/lib/cjs/utils/types.cjs.map +1 -0
- package/lib/cjs/utils/utils.cjs +3 -2
- package/lib/cjs/utils/utils.cjs.map +1 -0
- package/lib/cjs/workers/TaskEngine.cjs +30 -29
- package/lib/cjs/workers/TaskEngine.cjs.map +1 -0
- package/lib/cjs/workers/WorkThreadEnvironment.cjs +1 -0
- package/lib/cjs/workers/WorkThreadEnvironment.cjs.map +1 -0
- package/lib/cjs/workers/index.cjs +1 -0
- package/lib/cjs/workers/index.cjs.map +1 -0
- package/lib/cjs/workers/messages.cjs +1 -0
- package/lib/cjs/workers/messages.cjs.map +1 -0
- package/lib/cjs/workers/types.cjs +1 -0
- package/lib/cjs/workers/types.cjs.map +1 -0
- package/lib/cjs/workers/workerThread.cjs +18 -17
- package/lib/cjs/workers/workerThread.cjs.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/auth/constants.d.cts +5 -0
- package/lib/types/auth/constants.d.mts +5 -0
- package/lib/types/auth/decorators.d.cts +5 -0
- package/lib/types/auth/decorators.d.mts +5 -0
- package/lib/types/auth/index.d.cts +2 -0
- package/lib/types/auth/index.d.mts +2 -0
- package/lib/types/fs/FilesystemAdapter.d.cts +70 -0
- package/lib/types/fs/FilesystemAdapter.d.mts +70 -0
- package/lib/types/fs/FsDispatch.d.cts +7 -0
- package/lib/types/fs/FsDispatch.d.mts +7 -0
- package/lib/types/fs/helpers.d.cts +17 -0
- package/lib/types/fs/helpers.d.mts +17 -0
- package/lib/types/fs/index.d.cts +4 -0
- package/lib/types/fs/index.d.mts +4 -0
- package/lib/types/fs/indexStore.d.cts +28 -0
- package/lib/types/fs/indexStore.d.mts +28 -0
- package/lib/types/fs/locks/FilesystemLock.d.cts +13 -0
- package/lib/types/fs/locks/FilesystemLock.d.mts +13 -0
- package/lib/types/fs/locks/FilesystemMultiLock.d.cts +8 -0
- package/lib/types/fs/locks/FilesystemMultiLock.d.mts +8 -0
- package/lib/types/fs/types.d.cts +40 -0
- package/lib/types/fs/types.d.mts +40 -0
- package/lib/types/identity/decorators.d.cts +72 -0
- package/lib/types/identity/decorators.d.mts +72 -0
- package/lib/types/identity/index.d.cts +6 -0
- package/lib/types/identity/index.d.mts +6 -0
- package/lib/types/index.d.cts +34 -0
- package/lib/types/index.d.mts +34 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/interfaces/ContextuallyLogged.d.cts +8 -0
- package/lib/types/interfaces/ContextuallyLogged.d.mts +8 -0
- package/lib/types/interfaces/ErrorParser.d.cts +16 -0
- package/lib/types/interfaces/ErrorParser.d.mts +16 -0
- package/lib/types/interfaces/Executor.d.cts +16 -0
- package/lib/types/interfaces/Executor.d.mts +16 -0
- package/lib/types/interfaces/Observable.d.cts +33 -0
- package/lib/types/interfaces/Observable.d.mts +33 -0
- package/lib/types/interfaces/Observer.d.cts +15 -0
- package/lib/types/interfaces/Observer.d.mts +15 -0
- package/lib/types/interfaces/Paginatable.d.cts +20 -0
- package/lib/types/interfaces/Paginatable.d.mts +20 -0
- package/lib/types/interfaces/Queriable.d.cts +47 -0
- package/lib/types/interfaces/Queriable.d.mts +47 -0
- package/lib/types/interfaces/RawExecutor.d.cts +28 -0
- package/lib/types/interfaces/RawExecutor.d.mts +28 -0
- package/lib/types/interfaces/SequenceOptions.d.cts +79 -0
- package/lib/types/interfaces/SequenceOptions.d.mts +79 -0
- package/lib/types/interfaces/index.d.cts +12 -0
- package/lib/types/interfaces/index.d.mts +12 -0
- package/lib/types/migrations/Migration.d.cts +19 -0
- package/lib/types/migrations/Migration.d.mts +19 -0
- package/lib/types/migrations/MigrationService.d.cts +63 -0
- package/lib/types/migrations/MigrationService.d.mts +63 -0
- package/lib/types/migrations/MigrationTaskBuilder.d.cts +10 -0
- package/lib/types/migrations/MigrationTaskBuilder.d.mts +10 -0
- package/lib/types/migrations/MigrationTasks.d.cts +9 -0
- package/lib/types/migrations/MigrationTasks.d.mts +9 -0
- package/lib/types/migrations/MigrationVersioning.d.cts +7 -0
- package/lib/types/migrations/MigrationVersioning.d.mts +7 -0
- package/lib/types/migrations/SemverMigrationVersioning.d.cts +10 -0
- package/lib/types/migrations/SemverMigrationVersioning.d.mts +10 -0
- package/lib/types/migrations/StandardMigrationVersioning.d.cts +12 -0
- package/lib/types/migrations/StandardMigrationVersioning.d.mts +12 -0
- package/lib/types/migrations/constants.d.cts +2 -0
- package/lib/types/migrations/constants.d.mts +2 -0
- package/lib/types/migrations/decorators.d.cts +12 -0
- package/lib/types/migrations/decorators.d.mts +12 -0
- package/lib/types/migrations/index.d.cts +15 -0
- package/lib/types/migrations/index.d.mts +15 -0
- package/lib/types/migrations/types.d.cts +46 -0
- package/lib/types/migrations/types.d.mts +46 -0
- package/lib/types/model/BaseModel.d.cts +37 -0
- package/lib/types/model/BaseModel.d.mts +37 -0
- package/lib/types/model/SequenceModel.d.cts +32 -0
- package/lib/types/model/SequenceModel.d.mts +32 -0
- package/lib/types/model/construction.d.cts +455 -0
- package/lib/types/model/construction.d.mts +455 -0
- package/lib/types/model/decorators.d.cts +237 -0
- package/lib/types/model/decorators.d.mts +237 -0
- package/lib/types/model/index.d.cts +11 -0
- package/lib/types/model/index.d.mts +11 -0
- package/lib/types/model/indexing.d.cts +20 -0
- package/lib/types/model/indexing.d.mts +20 -0
- package/lib/types/model/types.d.cts +60 -0
- package/lib/types/model/types.d.mts +60 -0
- package/lib/types/overrides/Metadata.d.cts +22 -0
- package/lib/types/overrides/Metadata.d.mts +22 -0
- package/lib/types/overrides/Model.d.cts +94 -0
- package/lib/types/overrides/Model.d.mts +94 -0
- package/lib/types/overrides/ModelBuilder.d.cts +31 -0
- package/lib/types/overrides/ModelBuilder.d.mts +31 -0
- package/lib/types/overrides/index.d.cts +11 -0
- package/lib/types/overrides/index.d.mts +11 -0
- package/lib/types/overrides/injectables.d.cts +10 -0
- package/lib/types/overrides/injectables.d.mts +10 -0
- package/lib/types/overrides/overrides.d.cts +1 -0
- package/lib/types/overrides/overrides.d.mts +1 -0
- package/lib/types/persistence/Adapter.d.cts +469 -0
- package/lib/types/persistence/Adapter.d.mts +469 -0
- package/lib/types/persistence/Context.d.cts +16 -0
- package/lib/types/persistence/Context.d.mts +16 -0
- package/lib/types/persistence/ContextLock.d.cts +18 -0
- package/lib/types/persistence/ContextLock.d.mts +18 -0
- package/lib/types/persistence/Dispatch.d.cts +128 -0
- package/lib/types/persistence/Dispatch.d.mts +128 -0
- package/lib/types/persistence/ObserverHandler.d.cts +111 -0
- package/lib/types/persistence/ObserverHandler.d.mts +111 -0
- package/lib/types/persistence/Sequence.d.cts +126 -0
- package/lib/types/persistence/Sequence.d.mts +126 -0
- package/lib/types/persistence/constants.d.cts +74 -0
- package/lib/types/persistence/constants.d.mts +74 -0
- package/lib/types/persistence/decorators.d.cts +28 -0
- package/lib/types/persistence/decorators.d.mts +28 -0
- package/lib/types/persistence/errors.d.cts +33 -0
- package/lib/types/persistence/errors.d.mts +33 -0
- package/lib/types/persistence/event-filters.d.cts +20 -0
- package/lib/types/persistence/event-filters.d.mts +20 -0
- package/lib/types/persistence/generators.d.cts +14 -0
- package/lib/types/persistence/generators.d.mts +14 -0
- package/lib/types/persistence/index.d.cts +18 -0
- package/lib/types/persistence/index.d.mts +18 -0
- package/lib/types/persistence/transactions.d.cts +4 -0
- package/lib/types/persistence/transactions.d.mts +4 -0
- package/lib/types/persistence/types.d.cts +86 -0
- package/lib/types/persistence/types.d.mts +86 -0
- package/lib/types/query/Condition.d.cts +131 -0
- package/lib/types/query/Condition.d.mts +131 -0
- package/lib/types/query/MethodQueryBuilder.d.cts +185 -0
- package/lib/types/query/MethodQueryBuilder.d.mts +185 -0
- package/lib/types/query/Paginator.d.cts +105 -0
- package/lib/types/query/Paginator.d.mts +105 -0
- package/lib/types/query/Statement.d.cts +136 -0
- package/lib/types/query/Statement.d.mts +136 -0
- package/lib/types/query/constants.d.cts +69 -0
- package/lib/types/query/constants.d.mts +69 -0
- package/lib/types/query/decorators.d.cts +8 -0
- package/lib/types/query/decorators.d.mts +8 -0
- package/lib/types/query/errors.d.cts +21 -0
- package/lib/types/query/errors.d.mts +21 -0
- package/lib/types/query/index.d.cts +16 -0
- package/lib/types/query/index.d.mts +16 -0
- package/lib/types/query/options.d.cts +393 -0
- package/lib/types/query/options.d.mts +393 -0
- package/lib/types/query/selectors.d.cts +39 -0
- package/lib/types/query/selectors.d.mts +39 -0
- package/lib/types/query/types.d.cts +158 -0
- package/lib/types/query/types.d.mts +158 -0
- package/lib/types/query/utils.d.cts +40 -0
- package/lib/types/query/utils.d.mts +40 -0
- package/lib/types/ram/RamAdapter.d.cts +341 -0
- package/lib/types/ram/RamAdapter.d.mts +341 -0
- package/lib/types/ram/RamPaginator.d.cts +54 -0
- package/lib/types/ram/RamPaginator.d.mts +54 -0
- package/lib/types/ram/RamStatement.d.cts +92 -0
- package/lib/types/ram/RamStatement.d.mts +92 -0
- package/lib/types/ram/constants.d.cts +8 -0
- package/lib/types/ram/constants.d.mts +8 -0
- package/lib/types/ram/handlers.d.cts +24 -0
- package/lib/types/ram/handlers.d.mts +24 -0
- package/lib/types/ram/index.d.cts +12 -0
- package/lib/types/ram/index.d.mts +12 -0
- package/lib/types/ram/types.d.cts +50 -0
- package/lib/types/ram/types.d.mts +50 -0
- package/lib/types/repository/Repository.d.cts +501 -0
- package/lib/types/repository/Repository.d.mts +501 -0
- package/lib/types/repository/constants.d.cts +36 -0
- package/lib/types/repository/constants.d.mts +36 -0
- package/lib/types/repository/decorators.d.cts +30 -0
- package/lib/types/repository/decorators.d.mts +30 -0
- package/lib/types/repository/errors.d.cts +19 -0
- package/lib/types/repository/errors.d.mts +19 -0
- package/lib/types/repository/index.d.cts +12 -0
- package/lib/types/repository/index.d.mts +12 -0
- package/lib/types/repository/injectables.d.cts +95 -0
- package/lib/types/repository/injectables.d.mts +95 -0
- package/lib/types/repository/types.d.cts +28 -0
- package/lib/types/repository/types.d.mts +28 -0
- package/lib/types/repository/utils.d.cts +36 -0
- package/lib/types/repository/utils.d.mts +36 -0
- package/lib/types/services/ModelService.d.cts +45 -0
- package/lib/types/services/ModelService.d.mts +45 -0
- package/lib/types/services/PersistenceService.d.cts +17 -0
- package/lib/types/services/PersistenceService.d.mts +17 -0
- package/lib/types/services/index.d.cts +8 -0
- package/lib/types/services/index.d.mts +8 -0
- package/lib/types/services/services.d.cts +96 -0
- package/lib/types/services/services.d.mts +96 -0
- package/lib/types/tasks/CleanUpTask.d.cts +15 -0
- package/lib/types/tasks/CleanUpTask.d.mts +15 -0
- package/lib/types/tasks/TaskContext.d.cts +30 -0
- package/lib/types/tasks/TaskContext.d.mts +30 -0
- package/lib/types/tasks/TaskEngine.d.cts +97 -0
- package/lib/types/tasks/TaskEngine.d.mts +97 -0
- package/lib/types/tasks/TaskErrors.d.cts +65 -0
- package/lib/types/tasks/TaskErrors.d.mts +65 -0
- package/lib/types/tasks/TaskEventBus.d.cts +17 -0
- package/lib/types/tasks/TaskEventBus.d.mts +17 -0
- package/lib/types/tasks/TaskEventService.d.cts +7 -0
- package/lib/types/tasks/TaskEventService.d.mts +7 -0
- package/lib/types/tasks/TaskHandler.d.cts +12 -0
- package/lib/types/tasks/TaskHandler.d.mts +12 -0
- package/lib/types/tasks/TaskHandlerRegistry.d.cts +8 -0
- package/lib/types/tasks/TaskHandlerRegistry.d.mts +8 -0
- package/lib/types/tasks/TaskService.d.cts +65 -0
- package/lib/types/tasks/TaskService.d.mts +65 -0
- package/lib/types/tasks/TaskStateChangeError.d.cts +11 -0
- package/lib/types/tasks/TaskStateChangeError.d.mts +11 -0
- package/lib/types/tasks/TaskTracker.d.cts +47 -0
- package/lib/types/tasks/TaskTracker.d.mts +47 -0
- package/lib/types/tasks/builder.d.cts +72 -0
- package/lib/types/tasks/builder.d.mts +72 -0
- package/lib/types/tasks/constants.d.cts +31 -0
- package/lib/types/tasks/constants.d.mts +31 -0
- package/lib/types/tasks/decorators.d.cts +4 -0
- package/lib/types/tasks/decorators.d.mts +4 -0
- package/lib/types/tasks/index.d.cts +23 -0
- package/lib/types/tasks/index.d.mts +23 -0
- package/lib/types/tasks/logging.d.cts +31 -0
- package/lib/types/tasks/logging.d.mts +31 -0
- package/lib/types/tasks/models/TaskBackoffModel.d.cts +9 -0
- package/lib/types/tasks/models/TaskBackoffModel.d.mts +9 -0
- package/lib/types/tasks/models/TaskErrorModel.d.cts +8 -0
- package/lib/types/tasks/models/TaskErrorModel.d.mts +8 -0
- package/lib/types/tasks/models/TaskEventModel.d.cts +11 -0
- package/lib/types/tasks/models/TaskEventModel.d.mts +11 -0
- package/lib/types/tasks/models/TaskIOSerializer.d.cts +33 -0
- package/lib/types/tasks/models/TaskIOSerializer.d.mts +33 -0
- package/lib/types/tasks/models/TaskLogEntryModel.d.cts +10 -0
- package/lib/types/tasks/models/TaskLogEntryModel.d.mts +10 -0
- package/lib/types/tasks/models/TaskModel.d.cts +43 -0
- package/lib/types/tasks/models/TaskModel.d.mts +43 -0
- package/lib/types/tasks/models/TaskStepResultModel.d.cts +9 -0
- package/lib/types/tasks/models/TaskStepResultModel.d.mts +9 -0
- package/lib/types/tasks/models/TaskStepSpecModel.d.cts +9 -0
- package/lib/types/tasks/models/TaskStepSpecModel.d.mts +9 -0
- package/lib/types/tasks/models/index.d.cts +8 -0
- package/lib/types/tasks/models/index.d.mts +8 -0
- package/lib/types/tasks/types.d.cts +71 -0
- package/lib/types/tasks/types.d.mts +71 -0
- package/lib/types/tasks/utils.d.cts +5 -0
- package/lib/types/tasks/utils.d.mts +5 -0
- package/lib/types/utils/ContextualLoggedClass.d.cts +37 -0
- package/lib/types/utils/ContextualLoggedClass.d.mts +37 -0
- package/lib/types/utils/decorators.d.cts +27 -0
- package/lib/types/utils/decorators.d.mts +27 -0
- package/lib/types/utils/errors.d.cts +56 -0
- package/lib/types/utils/errors.d.mts +56 -0
- package/lib/types/utils/index.d.cts +11 -0
- package/lib/types/utils/index.d.mts +11 -0
- package/lib/types/utils/throttling.d.cts +9 -0
- package/lib/types/utils/throttling.d.mts +9 -0
- package/lib/types/utils/types.d.cts +23 -0
- package/lib/types/utils/types.d.mts +23 -0
- package/lib/types/utils/utils.d.cts +22 -0
- package/lib/types/utils/utils.d.mts +22 -0
- package/lib/types/workers/TaskEngine.d.cts +40 -0
- package/lib/types/workers/TaskEngine.d.mts +40 -0
- package/lib/types/workers/WorkThreadEnvironment.d.cts +35 -0
- package/lib/types/workers/WorkThreadEnvironment.d.mts +35 -0
- package/lib/types/workers/index.d.cts +5 -0
- package/lib/types/workers/index.d.mts +5 -0
- package/lib/types/workers/messages.d.cts +69 -0
- package/lib/types/workers/messages.d.mts +69 -0
- package/lib/types/workers/types.d.cts +41 -0
- package/lib/types/workers/types.d.mts +41 -0
- package/lib/types/workers/workerThread.d.cts +1 -0
- package/lib/types/workers/workerThread.d.mts +1 -0
- package/package.json +4 -4
- package/lib/cjs/auth/constants.js.map +0 -1
- package/lib/cjs/auth/decorators.js.map +0 -1
- package/lib/cjs/auth/index.js.map +0 -1
- package/lib/cjs/fs/FilesystemAdapter.js.map +0 -1
- package/lib/cjs/fs/FsDispatch.js.map +0 -1
- package/lib/cjs/fs/helpers.js.map +0 -1
- package/lib/cjs/fs/index.js.map +0 -1
- package/lib/cjs/fs/indexStore.js.map +0 -1
- package/lib/cjs/fs/locks/FilesystemLock.js.map +0 -1
- package/lib/cjs/fs/locks/FilesystemMultiLock.js.map +0 -1
- package/lib/cjs/fs/types.js.map +0 -1
- package/lib/cjs/identity/decorators.js.map +0 -1
- package/lib/cjs/identity/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/ContextuallyLogged.js.map +0 -1
- package/lib/cjs/interfaces/ErrorParser.js.map +0 -1
- package/lib/cjs/interfaces/Executor.js.map +0 -1
- package/lib/cjs/interfaces/Observable.js.map +0 -1
- package/lib/cjs/interfaces/Observer.js.map +0 -1
- package/lib/cjs/interfaces/Paginatable.js.map +0 -1
- package/lib/cjs/interfaces/Queriable.js.map +0 -1
- package/lib/cjs/interfaces/RawExecutor.js.map +0 -1
- package/lib/cjs/interfaces/SequenceOptions.js.map +0 -1
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/cjs/migrations/Migration.js.map +0 -1
- package/lib/cjs/migrations/MigrationService.js.map +0 -1
- package/lib/cjs/migrations/MigrationTaskBuilder.js.map +0 -1
- package/lib/cjs/migrations/MigrationTasks.js.map +0 -1
- package/lib/cjs/migrations/MigrationVersioning.js.map +0 -1
- package/lib/cjs/migrations/SemverMigrationVersioning.js.map +0 -1
- package/lib/cjs/migrations/StandardMigrationVersioning.js.map +0 -1
- package/lib/cjs/migrations/constants.js.map +0 -1
- package/lib/cjs/migrations/decorators.js.map +0 -1
- package/lib/cjs/migrations/index.js.map +0 -1
- package/lib/cjs/migrations/types.js.map +0 -1
- package/lib/cjs/model/BaseModel.js.map +0 -1
- package/lib/cjs/model/SequenceModel.js.map +0 -1
- package/lib/cjs/model/construction.js.map +0 -1
- package/lib/cjs/model/decorators.js.map +0 -1
- package/lib/cjs/model/index.js.map +0 -1
- package/lib/cjs/model/indexing.js.map +0 -1
- package/lib/cjs/model/types.js.map +0 -1
- package/lib/cjs/overrides/Metadata.js.map +0 -1
- package/lib/cjs/overrides/Model.js.map +0 -1
- package/lib/cjs/overrides/ModelBuilder.js.map +0 -1
- package/lib/cjs/overrides/index.js.map +0 -1
- package/lib/cjs/overrides/injectables.js.map +0 -1
- package/lib/cjs/overrides/overrides.js.map +0 -1
- package/lib/cjs/persistence/Adapter.js.map +0 -1
- package/lib/cjs/persistence/Context.js.map +0 -1
- package/lib/cjs/persistence/ContextLock.js.map +0 -1
- package/lib/cjs/persistence/Dispatch.js.map +0 -1
- package/lib/cjs/persistence/ObserverHandler.js.map +0 -1
- package/lib/cjs/persistence/Sequence.js.map +0 -1
- package/lib/cjs/persistence/constants.js.map +0 -1
- package/lib/cjs/persistence/decorators.js.map +0 -1
- package/lib/cjs/persistence/errors.js.map +0 -1
- package/lib/cjs/persistence/event-filters.js.map +0 -1
- package/lib/cjs/persistence/generators.js.map +0 -1
- package/lib/cjs/persistence/index.js.map +0 -1
- package/lib/cjs/persistence/transactions.js.map +0 -1
- package/lib/cjs/persistence/types.js.map +0 -1
- package/lib/cjs/query/Condition.js.map +0 -1
- package/lib/cjs/query/MethodQueryBuilder.js.map +0 -1
- package/lib/cjs/query/Paginator.js.map +0 -1
- package/lib/cjs/query/Statement.js.map +0 -1
- package/lib/cjs/query/constants.js.map +0 -1
- package/lib/cjs/query/decorators.js.map +0 -1
- package/lib/cjs/query/errors.js.map +0 -1
- package/lib/cjs/query/index.js.map +0 -1
- package/lib/cjs/query/options.js.map +0 -1
- package/lib/cjs/query/selectors.js.map +0 -1
- package/lib/cjs/query/types.js.map +0 -1
- package/lib/cjs/query/utils.js.map +0 -1
- package/lib/cjs/ram/RamAdapter.js.map +0 -1
- package/lib/cjs/ram/RamPaginator.js.map +0 -1
- package/lib/cjs/ram/RamStatement.js.map +0 -1
- package/lib/cjs/ram/constants.js.map +0 -1
- package/lib/cjs/ram/handlers.js.map +0 -1
- package/lib/cjs/ram/index.js.map +0 -1
- package/lib/cjs/ram/types.js.map +0 -1
- package/lib/cjs/repository/Repository.js.map +0 -1
- package/lib/cjs/repository/constants.js.map +0 -1
- package/lib/cjs/repository/decorators.js.map +0 -1
- package/lib/cjs/repository/errors.js.map +0 -1
- package/lib/cjs/repository/index.js.map +0 -1
- package/lib/cjs/repository/injectables.js.map +0 -1
- package/lib/cjs/repository/types.js.map +0 -1
- package/lib/cjs/repository/utils.js.map +0 -1
- package/lib/cjs/services/ModelService.js.map +0 -1
- package/lib/cjs/services/PersistenceService.js.map +0 -1
- package/lib/cjs/services/index.js.map +0 -1
- package/lib/cjs/services/services.js.map +0 -1
- package/lib/cjs/tasks/CleanUpTask.js.map +0 -1
- package/lib/cjs/tasks/TaskContext.js.map +0 -1
- package/lib/cjs/tasks/TaskEngine.js.map +0 -1
- package/lib/cjs/tasks/TaskErrors.js.map +0 -1
- package/lib/cjs/tasks/TaskEventBus.js.map +0 -1
- package/lib/cjs/tasks/TaskEventService.js.map +0 -1
- package/lib/cjs/tasks/TaskHandler.js.map +0 -1
- package/lib/cjs/tasks/TaskHandlerRegistry.js.map +0 -1
- package/lib/cjs/tasks/TaskService.js.map +0 -1
- package/lib/cjs/tasks/TaskStateChangeError.js.map +0 -1
- package/lib/cjs/tasks/TaskTracker.js.map +0 -1
- package/lib/cjs/tasks/builder.js.map +0 -1
- package/lib/cjs/tasks/constants.js.map +0 -1
- package/lib/cjs/tasks/decorators.js.map +0 -1
- package/lib/cjs/tasks/index.js.map +0 -1
- package/lib/cjs/tasks/logging.js.map +0 -1
- package/lib/cjs/tasks/models/TaskBackoffModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskErrorModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskEventModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskIOSerializer.js.map +0 -1
- package/lib/cjs/tasks/models/TaskLogEntryModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskStepResultModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskStepSpecModel.js.map +0 -1
- package/lib/cjs/tasks/models/index.js.map +0 -1
- package/lib/cjs/tasks/types.js.map +0 -1
- package/lib/cjs/tasks/utils.js.map +0 -1
- package/lib/cjs/utils/ContextualLoggedClass.js.map +0 -1
- package/lib/cjs/utils/decorators.js.map +0 -1
- package/lib/cjs/utils/errors.js.map +0 -1
- package/lib/cjs/utils/index.js.map +0 -1
- package/lib/cjs/utils/throttling.js.map +0 -1
- package/lib/cjs/utils/types.js.map +0 -1
- package/lib/cjs/utils/utils.js.map +0 -1
- package/lib/cjs/workers/TaskEngine.js.map +0 -1
- package/lib/cjs/workers/WorkThreadEnvironment.js.map +0 -1
- package/lib/cjs/workers/index.js.map +0 -1
- package/lib/cjs/workers/messages.js.map +0 -1
- package/lib/cjs/workers/types.js.map +0 -1
- package/lib/cjs/workers/workerThread.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Paginator = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const errors_js_1 = require("./errors.cjs");
|
|
5
|
+
const Context_js_1 = require("./../persistence/Context.cjs");
|
|
6
|
+
const utils_js_1 = require("./../utils/utils.cjs");
|
|
7
|
+
const errors_js_2 = require("./../persistence/errors.cjs");
|
|
8
8
|
const logging_1 = require("@decaf-ts/logging");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const constants_js_1 = require("./constants.cjs");
|
|
10
|
+
const Repository_js_1 = require("./../repository/Repository.cjs");
|
|
11
11
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
12
12
|
/**
|
|
13
13
|
* @description Handles pagination for database queries
|
|
@@ -86,30 +86,30 @@ class Paginator extends logging_1.LoggedClass {
|
|
|
86
86
|
this.query = query;
|
|
87
87
|
this.size = size;
|
|
88
88
|
this.clazz = clazz;
|
|
89
|
-
(0,
|
|
89
|
+
(0, utils_js_1.prefixMethod)(this, this.page, this.pagePrefix, this.page.name);
|
|
90
90
|
}
|
|
91
91
|
isPreparedStatement() {
|
|
92
92
|
const query = this.query;
|
|
93
93
|
return (query.method &&
|
|
94
|
-
query.method.match(new RegExp(`${
|
|
94
|
+
query.method.match(new RegExp(`${constants_js_1.PreparedStatementKeys.FIND_BY}|${constants_js_1.PreparedStatementKeys.FIND_BY_PAGINATE}|${constants_js_1.PreparedStatementKeys.LIST_BY}|${constants_js_1.PreparedStatementKeys.PAGE_BY}|${constants_js_1.PreparedStatementKeys.FIND}`, "gi")));
|
|
95
95
|
}
|
|
96
96
|
async pagePrefix(page, ...args) {
|
|
97
|
-
const { ctxArgs } = (await this.adapter["logCtx"]([this.clazz, ...args],
|
|
97
|
+
const { ctxArgs } = (await this.adapter["logCtx"]([this.clazz, ...args], constants_js_1.PreparedStatementKeys.PAGE_BY, true)).for(this.pagePrefix);
|
|
98
98
|
ctxArgs.shift();
|
|
99
99
|
return [page, ...ctxArgs];
|
|
100
100
|
}
|
|
101
101
|
async pagePrepared(page, bookmark, ...argz) {
|
|
102
|
-
const { log, ctxArgs } = this.adapter["logCtx"](bookmark && !(bookmark instanceof
|
|
102
|
+
const { log, ctxArgs } = this.adapter["logCtx"](bookmark && !(bookmark instanceof Context_js_1.Context)
|
|
103
103
|
? [...argz]
|
|
104
104
|
: [bookmark, ...argz], this.pagePrepared);
|
|
105
105
|
log.debug(`Running paged prepared statement ${page} page${bookmark ? ` - bookmark ${bookmark}` : ""}`);
|
|
106
|
-
if (bookmark && !(bookmark instanceof
|
|
106
|
+
if (bookmark && !(bookmark instanceof Context_js_1.Context))
|
|
107
107
|
this._bookmark = bookmark;
|
|
108
|
-
const repo =
|
|
108
|
+
const repo = Repository_js_1.Repository.forModel(this.clazz, this.adapter.alias);
|
|
109
109
|
const statement = this.query;
|
|
110
110
|
const { method, args, params } = statement;
|
|
111
|
-
if (method ===
|
|
112
|
-
const preparedArgs = [
|
|
111
|
+
if (method === constants_js_1.PreparedStatementKeys.FIND) {
|
|
112
|
+
const preparedArgs = [constants_js_1.PreparedStatementKeys.PAGE, ...args];
|
|
113
113
|
const preparedParams = {
|
|
114
114
|
limit: this.size,
|
|
115
115
|
offset: page,
|
|
@@ -120,28 +120,28 @@ class Paginator extends logging_1.LoggedClass {
|
|
|
120
120
|
return this.apply(result);
|
|
121
121
|
}
|
|
122
122
|
let pagedMethod;
|
|
123
|
-
if (method ===
|
|
124
|
-
pagedMethod =
|
|
123
|
+
if (method === constants_js_1.PreparedStatementKeys.FIND_BY) {
|
|
124
|
+
pagedMethod = constants_js_1.PreparedStatementKeys.FIND_BY_PAGINATE;
|
|
125
125
|
}
|
|
126
|
-
else if (method.startsWith(
|
|
127
|
-
pagedMethod = method.replace(
|
|
126
|
+
else if (method.startsWith(constants_js_1.PreparedStatementKeys.FIND_BY)) {
|
|
127
|
+
pagedMethod = method.replace(constants_js_1.PreparedStatementKeys.FIND_BY, constants_js_1.PreparedStatementKeys.PAGE_BY);
|
|
128
128
|
}
|
|
129
|
-
else if (method ===
|
|
130
|
-
pagedMethod =
|
|
129
|
+
else if (method === constants_js_1.PreparedStatementKeys.LIST_BY) {
|
|
130
|
+
pagedMethod = constants_js_1.PreparedStatementKeys.PAGE_BY;
|
|
131
131
|
}
|
|
132
|
-
else if (method ===
|
|
133
|
-
method ===
|
|
132
|
+
else if (method === constants_js_1.PreparedStatementKeys.PAGE_BY ||
|
|
133
|
+
method === constants_js_1.PreparedStatementKeys.FIND_BY_PAGINATE) {
|
|
134
134
|
pagedMethod = method;
|
|
135
135
|
}
|
|
136
136
|
if (!pagedMethod)
|
|
137
|
-
throw new
|
|
137
|
+
throw new errors_js_2.UnsupportedError(`Method ${method} is not supported for pagination`);
|
|
138
138
|
const preparedArgs = [pagedMethod, ...args];
|
|
139
139
|
let preparedParams = {
|
|
140
140
|
limit: this.size,
|
|
141
141
|
offset: page,
|
|
142
142
|
bookmark: this._bookmark,
|
|
143
143
|
};
|
|
144
|
-
if (pagedMethod ===
|
|
144
|
+
if (pagedMethod === constants_js_1.PreparedStatementKeys.PAGE_BY &&
|
|
145
145
|
preparedArgs.length <= 2) {
|
|
146
146
|
preparedArgs.push(params.direction);
|
|
147
147
|
}
|
|
@@ -165,16 +165,16 @@ class Paginator extends logging_1.LoggedClass {
|
|
|
165
165
|
}
|
|
166
166
|
validatePage(page) {
|
|
167
167
|
if (page < 1 || !Number.isInteger(page))
|
|
168
|
-
throw new
|
|
168
|
+
throw new errors_js_1.PagingError("Page number cannot be under 1 and must be an integer");
|
|
169
169
|
if (typeof this._totalPages !== "undefined" && page > this._totalPages)
|
|
170
|
-
throw new
|
|
170
|
+
throw new errors_js_1.PagingError(`Only ${this._totalPages} are available. Cannot go to page ${page}`);
|
|
171
171
|
return page;
|
|
172
172
|
}
|
|
173
173
|
async page(page = 1, bookmark, ...args) {
|
|
174
174
|
const { ctxArgs } = this.adapter["logCtx"]([bookmark, ...args], this.page);
|
|
175
175
|
if (this.isPreparedStatement())
|
|
176
176
|
return (await this.pagePrepared(page, ...ctxArgs));
|
|
177
|
-
throw new
|
|
177
|
+
throw new errors_js_2.UnsupportedError("Raw support not available without subclassing this");
|
|
178
178
|
}
|
|
179
179
|
serialize(data, toString = false) {
|
|
180
180
|
const serialization = {
|
|
@@ -219,4 +219,5 @@ class Paginator extends logging_1.LoggedClass {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
exports.Paginator = Paginator;
|
|
222
|
+
//# sourceMappingURL=Paginator.js.map
|
|
222
223
|
//# sourceMappingURL=Paginator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Paginator.js","sourceRoot":"","sources":["Paginator.js"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,4DAAsD;AACtD,kDAAmD;AACnD,0DAA8D;AAC9D,+CAAgD;AAChD,iDAAuD;AACvD,iEAA2D;AAC3D,2DAA6D;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAa,SAAU,SAAQ,qBAAW;IACtC,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,IAAI,SAAS;QACT,IAAI,CAAC,IAAI,CAAC,UAAU;YAChB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,UAAU,CAAC;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D,MAAM,CAAC,gBAAgB,CAAC,GAAG;QACvB,OAAO,CAAC,GAAG;YACP,OAAO,GAAG,KAAK,QAAQ;YACvB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YACvB,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;YAC7B,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;YAC/B,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;IACvC,CAAC;CACJ;AAxJD,8BAwJC;AACD,qCAAqC"}
|
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Statement = void 0;
|
|
2
4
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
5
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5
|
-
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
7
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
+
else
|
|
9
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
10
|
+
if (d = decorators[i])
|
|
11
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
12
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
13
|
};
|
|
8
14
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
16
|
+
return Reflect.metadata(k, v);
|
|
10
17
|
};
|
|
11
18
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.Statement = void 0;
|
|
14
19
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
15
20
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
16
|
-
const
|
|
21
|
+
const Condition_js_1 = require("./Condition.cjs");
|
|
17
22
|
const db_decorators_2 = require("@decaf-ts/db-decorators");
|
|
18
23
|
const logging_1 = require("@decaf-ts/logging");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
24
|
+
const constants_js_1 = require("./../persistence/constants.cjs");
|
|
25
|
+
const errors_js_1 = require("./../persistence/errors.cjs");
|
|
26
|
+
const errors_js_2 = require("./errors.cjs");
|
|
27
|
+
const ContextualLoggedClass_js_1 = require("./../utils/ContextualLoggedClass.cjs");
|
|
28
|
+
const types_js_1 = require("./types.cjs");
|
|
29
|
+
const constants_js_2 = require("./constants.cjs");
|
|
30
|
+
const constants_js_3 = require("./../repository/constants.cjs");
|
|
31
|
+
const Repository_js_1 = require("./../repository/Repository.cjs");
|
|
27
32
|
/**
|
|
28
33
|
* @description Base class for database query statements
|
|
29
34
|
* @summary Provides a foundation for building and executing database queries
|
|
@@ -75,7 +80,7 @@ const Repository_1 = require("./../repository/Repository.cjs");
|
|
|
75
80
|
* Adapter-->>Statement: return processed results
|
|
76
81
|
* Statement-->>Client: return final results
|
|
77
82
|
*/
|
|
78
|
-
class Statement extends
|
|
83
|
+
class Statement extends ContextualLoggedClass_js_1.ContextualLoggedClass {
|
|
79
84
|
constructor(adapter, overrides) {
|
|
80
85
|
super();
|
|
81
86
|
this.adapter = adapter;
|
|
@@ -89,8 +94,8 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
89
94
|
}
|
|
90
95
|
async executionPrefix(method, ...args) {
|
|
91
96
|
const { ctx, ctxArgs, log } = (await this.adapter["logCtx"]([this.fromSelector, ...args], method.name === this.paginate.name
|
|
92
|
-
?
|
|
93
|
-
:
|
|
97
|
+
? constants_js_2.PreparedStatementKeys.PAGE_BY
|
|
98
|
+
: constants_js_1.PersistenceKeys.QUERY, true, this.overrides || {})).for(method);
|
|
94
99
|
ctxArgs.shift();
|
|
95
100
|
const forceSimple = ctx.get("forcePrepareSimpleQueries");
|
|
96
101
|
const forceComplex = ctx.get("forcePrepareComplexQueries");
|
|
@@ -130,7 +135,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
130
135
|
}
|
|
131
136
|
// Standalone distinct requires a selector
|
|
132
137
|
if (!selector) {
|
|
133
|
-
throw new
|
|
138
|
+
throw new errors_js_2.QueryError("distinct() requires a selector when not chained after count()");
|
|
134
139
|
}
|
|
135
140
|
this.distinctSelector = selector;
|
|
136
141
|
return this;
|
|
@@ -159,7 +164,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
159
164
|
from(selector) {
|
|
160
165
|
this.fromSelector = (typeof selector === "string" ? decorator_validation_1.Model.get(selector) : selector);
|
|
161
166
|
if (!this.fromSelector)
|
|
162
|
-
throw new
|
|
167
|
+
throw new errors_js_2.QueryError(`Could not find selector model: ${selector}`);
|
|
163
168
|
return this;
|
|
164
169
|
}
|
|
165
170
|
where(condition) {
|
|
@@ -176,12 +181,12 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
176
181
|
const isOrderingCriterion = Array.isArray(selectorOrAttribute) || typeof direction !== "undefined";
|
|
177
182
|
if (isOrderingCriterion) {
|
|
178
183
|
if (!this.orderBySelectors || !this.orderBySelectors.length)
|
|
179
|
-
throw new
|
|
184
|
+
throw new errors_js_2.QueryError("thenBy requires orderBy to be called first");
|
|
180
185
|
this.orderBySelectors.push(this.normalizeOrderCriterion(selectorOrAttribute, direction));
|
|
181
186
|
return this;
|
|
182
187
|
}
|
|
183
188
|
if (!this.groupBySelectors || !this.groupBySelectors.length)
|
|
184
|
-
throw new
|
|
189
|
+
throw new errors_js_2.QueryError("groupBy must be called before chaining group selectors");
|
|
185
190
|
this.groupBySelectors.push(selectorOrAttribute);
|
|
186
191
|
return this;
|
|
187
192
|
}
|
|
@@ -194,18 +199,18 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
194
199
|
}
|
|
195
200
|
normalizeOrderDirection(direction) {
|
|
196
201
|
if (!direction) {
|
|
197
|
-
throw new
|
|
202
|
+
throw new errors_js_2.QueryError("orderBy direction is required when specifying the attribute separately.");
|
|
198
203
|
}
|
|
199
204
|
const normalized = String(direction).toLowerCase();
|
|
200
|
-
if (normalized ===
|
|
201
|
-
return
|
|
202
|
-
if (normalized ===
|
|
203
|
-
return
|
|
204
|
-
throw new
|
|
205
|
+
if (normalized === constants_js_3.OrderDirection.ASC)
|
|
206
|
+
return constants_js_3.OrderDirection.ASC;
|
|
207
|
+
if (normalized === constants_js_3.OrderDirection.DSC)
|
|
208
|
+
return constants_js_3.OrderDirection.DSC;
|
|
209
|
+
throw new errors_js_2.QueryError(`Invalid OrderBy direction ${direction}. Expected one of: ${Object.values(constants_js_3.OrderDirection).join(", ")}.`);
|
|
205
210
|
}
|
|
206
211
|
groupBy(selector) {
|
|
207
212
|
if (this.orderBySelectors && this.orderBySelectors.length) {
|
|
208
|
-
throw new
|
|
213
|
+
throw new errors_js_2.QueryError("groupBy must be called before orderBy.");
|
|
209
214
|
}
|
|
210
215
|
this.groupBySelectors = [selector];
|
|
211
216
|
return this;
|
|
@@ -246,7 +251,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
246
251
|
return results;
|
|
247
252
|
}
|
|
248
253
|
catch (e) {
|
|
249
|
-
throw new
|
|
254
|
+
throw new errors_js_2.QueryError(e);
|
|
250
255
|
}
|
|
251
256
|
}
|
|
252
257
|
revertGroupedResults(value, processor) {
|
|
@@ -261,7 +266,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
261
266
|
return value;
|
|
262
267
|
}
|
|
263
268
|
async executePrepared(...argz) {
|
|
264
|
-
const repo =
|
|
269
|
+
const repo = Repository_js_1.Repository.forModel(this.fromSelector, this.adapter.alias);
|
|
265
270
|
const { method, args, params } = this.prepared;
|
|
266
271
|
return repo.statement(method, ...args, params, ...argz);
|
|
267
272
|
}
|
|
@@ -269,7 +274,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
269
274
|
const { ctx, ctxArgs } = this.logCtx(args, this.raw);
|
|
270
275
|
const allowRawStatements = ctx.get("allowRawStatements");
|
|
271
276
|
if (!allowRawStatements)
|
|
272
|
-
throw new
|
|
277
|
+
throw new errors_js_1.UnsupportedError("Raw statements are not allowed in the current configuration");
|
|
273
278
|
const results = await this.adapter.raw(rawInput, true, ...ctxArgs);
|
|
274
279
|
if (this.hasAggregation()) {
|
|
275
280
|
return results;
|
|
@@ -310,7 +315,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
310
315
|
return value;
|
|
311
316
|
}
|
|
312
317
|
getRepository() {
|
|
313
|
-
return
|
|
318
|
+
return Repository_js_1.Repository.forModel(this.fromSelector, this.adapter.alias);
|
|
314
319
|
}
|
|
315
320
|
prepareCondition(condition, ctx) {
|
|
316
321
|
// @ts-expect-error accessing protected properties
|
|
@@ -318,15 +323,15 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
318
323
|
let { attr1, operator, comparison } = condition;
|
|
319
324
|
const result = {};
|
|
320
325
|
switch (operator) {
|
|
321
|
-
case
|
|
322
|
-
case
|
|
326
|
+
case constants_js_2.GroupOperator.AND:
|
|
327
|
+
case constants_js_2.GroupOperator.OR: {
|
|
323
328
|
let side1 = attr1, side2 = comparison;
|
|
324
329
|
if (typeof attr1 !== "string") {
|
|
325
330
|
const condition1 = this.prepareCondition(attr1, ctx);
|
|
326
331
|
side1 = condition1.method;
|
|
327
332
|
result.args = [...(result.args || []), ...(condition1.args || [])];
|
|
328
333
|
}
|
|
329
|
-
if (comparison instanceof
|
|
334
|
+
if (comparison instanceof Condition_js_1.Condition) {
|
|
330
335
|
const condition2 = this.prepareCondition(comparison, ctx);
|
|
331
336
|
side2 = condition2.method;
|
|
332
337
|
result.args = [...(result.args || []), ...(condition2.args || [])];
|
|
@@ -334,39 +339,39 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
334
339
|
result.method = `${side1} ${operator.toLowerCase()} ${side2}`;
|
|
335
340
|
break;
|
|
336
341
|
}
|
|
337
|
-
case
|
|
342
|
+
case constants_js_2.Operator.EQUAL:
|
|
338
343
|
result.method = attr1;
|
|
339
344
|
result.args = [...(result.args || []), comparison];
|
|
340
345
|
break;
|
|
341
|
-
case
|
|
346
|
+
case constants_js_2.Operator.DIFFERENT:
|
|
342
347
|
result.method = `${attr1} diff`;
|
|
343
348
|
result.args = [...(result.args || []), comparison];
|
|
344
349
|
break;
|
|
345
|
-
case
|
|
350
|
+
case constants_js_2.Operator.REGEXP:
|
|
346
351
|
result.method = `${attr1} matches`;
|
|
347
352
|
result.args = [...(result.args || []), comparison];
|
|
348
353
|
break;
|
|
349
|
-
case
|
|
354
|
+
case constants_js_2.Operator.BIGGER:
|
|
350
355
|
result.method = `${attr1} bigger`;
|
|
351
356
|
result.args = [...(result.args || []), comparison];
|
|
352
357
|
break;
|
|
353
|
-
case
|
|
358
|
+
case constants_js_2.Operator.BIGGER_EQ:
|
|
354
359
|
result.method = `${attr1} bigger than equal`;
|
|
355
360
|
break;
|
|
356
|
-
case
|
|
361
|
+
case constants_js_2.Operator.SMALLER:
|
|
357
362
|
result.method = `${attr1} less`;
|
|
358
363
|
result.args = [...(result.args || []), comparison];
|
|
359
364
|
break;
|
|
360
|
-
case
|
|
365
|
+
case constants_js_2.Operator.SMALLER_EQ:
|
|
361
366
|
result.method = `${attr1} less than equal`;
|
|
362
367
|
result.args = [...(result.args || []), comparison];
|
|
363
368
|
break;
|
|
364
|
-
case
|
|
369
|
+
case constants_js_2.Operator.IN:
|
|
365
370
|
result.method = `${attr1} in`;
|
|
366
371
|
result.args = [...(result.args || []), comparison];
|
|
367
372
|
break;
|
|
368
373
|
default:
|
|
369
|
-
throw new
|
|
374
|
+
throw new errors_js_2.QueryError(`Unsupported operator ${operator}`);
|
|
370
375
|
}
|
|
371
376
|
return result;
|
|
372
377
|
}
|
|
@@ -377,7 +382,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
377
382
|
const direction = this.getOrderDirection();
|
|
378
383
|
return {
|
|
379
384
|
class: this.fromSelector,
|
|
380
|
-
method:
|
|
385
|
+
method: constants_js_2.PreparedStatementKeys.FIND,
|
|
381
386
|
args: [defaultQuery.value, direction],
|
|
382
387
|
params: {
|
|
383
388
|
direction,
|
|
@@ -386,7 +391,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
386
391
|
}
|
|
387
392
|
// If there's a where condition with complex conditions (nested Conditions), can't squash
|
|
388
393
|
if (this.whereCondition) {
|
|
389
|
-
if (this.whereCondition["comparison"] instanceof
|
|
394
|
+
if (this.whereCondition["comparison"] instanceof Condition_js_1.Condition)
|
|
390
395
|
return undefined;
|
|
391
396
|
}
|
|
392
397
|
// Try to squash simple aggregation queries without where conditions
|
|
@@ -396,7 +401,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
396
401
|
!this.countDistinctSelector) {
|
|
397
402
|
return {
|
|
398
403
|
class: this.fromSelector,
|
|
399
|
-
method:
|
|
404
|
+
method: constants_js_2.PreparedStatementKeys.COUNT_OF,
|
|
400
405
|
args: this.countSelector !== null ? [this.countSelector] : [],
|
|
401
406
|
params: {},
|
|
402
407
|
};
|
|
@@ -405,7 +410,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
405
410
|
if (this.maxSelector) {
|
|
406
411
|
return {
|
|
407
412
|
class: this.fromSelector,
|
|
408
|
-
method:
|
|
413
|
+
method: constants_js_2.PreparedStatementKeys.MAX_OF,
|
|
409
414
|
args: [this.maxSelector],
|
|
410
415
|
params: {},
|
|
411
416
|
};
|
|
@@ -414,7 +419,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
414
419
|
if (this.minSelector) {
|
|
415
420
|
return {
|
|
416
421
|
class: this.fromSelector,
|
|
417
|
-
method:
|
|
422
|
+
method: constants_js_2.PreparedStatementKeys.MIN_OF,
|
|
418
423
|
args: [this.minSelector],
|
|
419
424
|
params: {},
|
|
420
425
|
};
|
|
@@ -423,7 +428,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
423
428
|
if (this.avgSelector) {
|
|
424
429
|
return {
|
|
425
430
|
class: this.fromSelector,
|
|
426
|
-
method:
|
|
431
|
+
method: constants_js_2.PreparedStatementKeys.AVG_OF,
|
|
427
432
|
args: [this.avgSelector],
|
|
428
433
|
params: {},
|
|
429
434
|
};
|
|
@@ -432,7 +437,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
432
437
|
if (this.sumSelector) {
|
|
433
438
|
return {
|
|
434
439
|
class: this.fromSelector,
|
|
435
|
-
method:
|
|
440
|
+
method: constants_js_2.PreparedStatementKeys.SUM_OF,
|
|
436
441
|
args: [this.sumSelector],
|
|
437
442
|
params: {},
|
|
438
443
|
};
|
|
@@ -441,7 +446,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
441
446
|
if (this.distinctSelector) {
|
|
442
447
|
return {
|
|
443
448
|
class: this.fromSelector,
|
|
444
|
-
method:
|
|
449
|
+
method: constants_js_2.PreparedStatementKeys.DISTINCT_OF,
|
|
445
450
|
args: [this.distinctSelector],
|
|
446
451
|
params: {},
|
|
447
452
|
};
|
|
@@ -450,7 +455,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
450
455
|
if (this.groupBySelectors?.length === 1) {
|
|
451
456
|
return {
|
|
452
457
|
class: this.fromSelector,
|
|
453
|
-
method:
|
|
458
|
+
method: constants_js_2.PreparedStatementKeys.GROUP_OF,
|
|
454
459
|
args: [this.groupBySelectors[0]],
|
|
455
460
|
params: {},
|
|
456
461
|
};
|
|
@@ -480,8 +485,8 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
480
485
|
const order = this.orderBySelectors?.[0]
|
|
481
486
|
? this.orderBySelectors[0]
|
|
482
487
|
: attrFromWhere
|
|
483
|
-
? [attrFromWhere,
|
|
484
|
-
: [decorator_validation_1.Model.pk(this.fromSelector),
|
|
488
|
+
? [attrFromWhere, constants_js_3.OrderDirection.DSC]
|
|
489
|
+
: [decorator_validation_1.Model.pk(this.fromSelector), constants_js_3.OrderDirection.DSC];
|
|
485
490
|
const [attrFromOrderBy, sort] = order;
|
|
486
491
|
const params = {
|
|
487
492
|
direction: sort,
|
|
@@ -493,13 +498,13 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
493
498
|
const squashed = {
|
|
494
499
|
// listBy
|
|
495
500
|
class: this.fromSelector,
|
|
496
|
-
method:
|
|
501
|
+
method: constants_js_2.PreparedStatementKeys.LIST_BY,
|
|
497
502
|
args: [attrFromOrderBy],
|
|
498
503
|
params: params,
|
|
499
504
|
};
|
|
500
505
|
if (attrFromWhere) {
|
|
501
506
|
// findBy
|
|
502
|
-
squashed.method =
|
|
507
|
+
squashed.method = constants_js_2.PreparedStatementKeys.FIND_BY;
|
|
503
508
|
squashed.args = [
|
|
504
509
|
attrFromWhere,
|
|
505
510
|
this.whereCondition["comparison"],
|
|
@@ -542,7 +547,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
542
547
|
if (!condition)
|
|
543
548
|
return undefined;
|
|
544
549
|
const { attr1, operator, comparison } = condition;
|
|
545
|
-
if (operator ===
|
|
550
|
+
if (operator === constants_js_2.Operator.STARTS_WITH) {
|
|
546
551
|
if (typeof attr1 !== "string" || typeof comparison !== "string")
|
|
547
552
|
return undefined;
|
|
548
553
|
return {
|
|
@@ -550,11 +555,11 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
550
555
|
value: comparison,
|
|
551
556
|
};
|
|
552
557
|
}
|
|
553
|
-
if (operator ===
|
|
554
|
-
const left = attr1 instanceof
|
|
558
|
+
if (operator === constants_js_2.GroupOperator.OR) {
|
|
559
|
+
const left = attr1 instanceof Condition_js_1.Condition
|
|
555
560
|
? this.collectStartsWithAttributes(attr1)
|
|
556
561
|
: undefined;
|
|
557
|
-
const right = comparison instanceof
|
|
562
|
+
const right = comparison instanceof Condition_js_1.Condition
|
|
558
563
|
? this.collectStartsWithAttributes(comparison)
|
|
559
564
|
: undefined;
|
|
560
565
|
if (left && right && left.value === right.value) {
|
|
@@ -565,13 +570,13 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
565
570
|
}
|
|
566
571
|
return undefined;
|
|
567
572
|
}
|
|
568
|
-
if (operator ===
|
|
569
|
-
const left = attr1 instanceof
|
|
573
|
+
if (operator === constants_js_2.GroupOperator.AND) {
|
|
574
|
+
const left = attr1 instanceof Condition_js_1.Condition
|
|
570
575
|
? this.collectStartsWithAttributes(attr1)
|
|
571
576
|
: undefined;
|
|
572
577
|
if (left)
|
|
573
578
|
return left;
|
|
574
|
-
const right = comparison instanceof
|
|
579
|
+
const right = comparison instanceof Condition_js_1.Condition
|
|
575
580
|
? this.collectStartsWithAttributes(comparison)
|
|
576
581
|
: undefined;
|
|
577
582
|
return right;
|
|
@@ -579,12 +584,12 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
579
584
|
return undefined;
|
|
580
585
|
}
|
|
581
586
|
getOrderDirection() {
|
|
582
|
-
return (this.orderBySelectors?.[0]?.[1] ??
|
|
587
|
+
return (this.orderBySelectors?.[0]?.[1] ?? constants_js_3.OrderDirection.ASC);
|
|
583
588
|
}
|
|
584
589
|
async prepare(ctx) {
|
|
585
590
|
ctx =
|
|
586
591
|
ctx ||
|
|
587
|
-
(await this.adapter.context(
|
|
592
|
+
(await this.adapter.context(constants_js_1.PersistenceKeys.QUERY, this.overrides || {}, this.fromSelector));
|
|
588
593
|
if (this.isSimpleQuery() &&
|
|
589
594
|
ctx.get("forcePrepareSimpleQueries")) {
|
|
590
595
|
const squashed = this.squash(ctx);
|
|
@@ -610,40 +615,40 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
610
615
|
params,
|
|
611
616
|
};
|
|
612
617
|
// Determine the method prefix based on the query type
|
|
613
|
-
let methodPrefix =
|
|
618
|
+
let methodPrefix = types_js_1.QueryClause.FIND_BY;
|
|
614
619
|
let selectorField;
|
|
615
620
|
if (typeof this.countSelector !== "undefined") {
|
|
616
|
-
methodPrefix =
|
|
621
|
+
methodPrefix = types_js_1.QueryClause.COUNT_BY;
|
|
617
622
|
selectorField =
|
|
618
623
|
this.countSelector !== null
|
|
619
624
|
? this.countSelector
|
|
620
625
|
: undefined;
|
|
621
626
|
}
|
|
622
627
|
else if (this.sumSelector) {
|
|
623
|
-
methodPrefix =
|
|
628
|
+
methodPrefix = types_js_1.QueryClause.SUM_BY;
|
|
624
629
|
selectorField = this.sumSelector;
|
|
625
630
|
}
|
|
626
631
|
else if (this.avgSelector) {
|
|
627
|
-
methodPrefix =
|
|
632
|
+
methodPrefix = types_js_1.QueryClause.AVG_BY;
|
|
628
633
|
selectorField = this.avgSelector;
|
|
629
634
|
}
|
|
630
635
|
else if (this.minSelector) {
|
|
631
|
-
methodPrefix =
|
|
636
|
+
methodPrefix = types_js_1.QueryClause.MIN_BY;
|
|
632
637
|
selectorField = this.minSelector;
|
|
633
638
|
}
|
|
634
639
|
else if (this.maxSelector) {
|
|
635
|
-
methodPrefix =
|
|
640
|
+
methodPrefix = types_js_1.QueryClause.MAX_BY;
|
|
636
641
|
selectorField = this.maxSelector;
|
|
637
642
|
}
|
|
638
643
|
else if (this.distinctSelector) {
|
|
639
|
-
methodPrefix =
|
|
644
|
+
methodPrefix = types_js_1.QueryClause.DISTINCT_BY;
|
|
640
645
|
selectorField = this.distinctSelector;
|
|
641
646
|
}
|
|
642
647
|
else if (this.groupBySelectors?.length &&
|
|
643
648
|
!this.selectSelector?.length &&
|
|
644
649
|
!this.whereCondition) {
|
|
645
650
|
// Group-only query (no select, no where)
|
|
646
|
-
methodPrefix =
|
|
651
|
+
methodPrefix = types_js_1.QueryClause.GROUP_BY_PREFIX;
|
|
647
652
|
selectorField = this.groupBySelectors[0];
|
|
648
653
|
}
|
|
649
654
|
// If there's a where condition or selectSelector, use findBy prefix even with groupBy
|
|
@@ -658,30 +663,30 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
658
663
|
args.push(...parsed.args);
|
|
659
664
|
}
|
|
660
665
|
if (this.selectSelector)
|
|
661
|
-
method.push(
|
|
666
|
+
method.push(types_js_1.QueryClause.SELECT, this.selectSelector.join(` ${types_js_1.QueryClause.AND.toLowerCase()} `));
|
|
662
667
|
if (this.orderBySelectors?.length) {
|
|
663
668
|
const [primary, ...secondary] = this.orderBySelectors;
|
|
664
|
-
method.push(
|
|
669
|
+
method.push(types_js_1.QueryClause.ORDER_BY, primary[0]);
|
|
665
670
|
params.direction = primary[1];
|
|
666
671
|
if (secondary.length) {
|
|
667
672
|
params.order = this.orderBySelectors.map(([attr, dir]) => [attr, dir]);
|
|
668
673
|
secondary.forEach(([attr]) => {
|
|
669
|
-
method.push(
|
|
674
|
+
method.push(types_js_1.QueryClause.THEN_BY, attr);
|
|
670
675
|
});
|
|
671
676
|
}
|
|
672
677
|
}
|
|
673
678
|
// Handle groupBy for non-aggregation queries (already handled for group prefix)
|
|
674
679
|
if (this.groupBySelectors?.length &&
|
|
675
|
-
methodPrefix !==
|
|
680
|
+
methodPrefix !== types_js_1.QueryClause.GROUP_BY_PREFIX) {
|
|
676
681
|
const [primary, ...rest] = this.groupBySelectors;
|
|
677
|
-
method.push(
|
|
678
|
-
rest.forEach((attr) => method.push(
|
|
682
|
+
method.push(types_js_1.QueryClause.GROUP_BY, primary);
|
|
683
|
+
rest.forEach((attr) => method.push(types_js_1.QueryClause.THEN_BY, attr));
|
|
679
684
|
}
|
|
680
685
|
else if (this.groupBySelectors?.length &&
|
|
681
|
-
methodPrefix ===
|
|
686
|
+
methodPrefix === types_js_1.QueryClause.GROUP_BY_PREFIX) {
|
|
682
687
|
// For group prefix, add additional group fields as ThenBy
|
|
683
688
|
const rest = this.groupBySelectors.slice(1);
|
|
684
|
-
rest.forEach((attr) => method.push(
|
|
689
|
+
rest.forEach((attr) => method.push(types_js_1.QueryClause.THEN_BY, attr));
|
|
685
690
|
}
|
|
686
691
|
if (this.limitSelector)
|
|
687
692
|
params.limit = this.limitSelector;
|
|
@@ -728,7 +733,7 @@ class Statement extends ContextualLoggedClass_1.ContextualLoggedClass {
|
|
|
728
733
|
return this.adapter.Paginator(this.prepared || this.build(), size, this.fromSelector);
|
|
729
734
|
}
|
|
730
735
|
catch (e) {
|
|
731
|
-
throw new
|
|
736
|
+
throw new errors_js_2.QueryError(e);
|
|
732
737
|
}
|
|
733
738
|
}
|
|
734
739
|
toString() {
|
|
@@ -787,7 +792,7 @@ __decorate([
|
|
|
787
792
|
__decorate([
|
|
788
793
|
(0, logging_1.final)(),
|
|
789
794
|
__metadata("design:type", Function),
|
|
790
|
-
__metadata("design:paramtypes", [
|
|
795
|
+
__metadata("design:paramtypes", [Condition_js_1.Condition]),
|
|
791
796
|
__metadata("design:returntype", Object)
|
|
792
797
|
], Statement.prototype, "where", null);
|
|
793
798
|
__decorate([
|
|
@@ -826,4 +831,5 @@ __decorate([
|
|
|
826
831
|
__metadata("design:paramtypes", [void 0]),
|
|
827
832
|
__metadata("design:returntype", Promise)
|
|
828
833
|
], Statement.prototype, "execute", null);
|
|
834
|
+
//# sourceMappingURL=Statement.js.map
|
|
829
835
|
//# sourceMappingURL=Statement.js.map
|