joist-core 2.4.0 → 2.5.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/build/BaseEntity.d.cts +3 -4
- package/build/BaseEntity.d.cts.map +1 -1
- package/build/BaseEntity.d.mts +3 -4
- package/build/BaseEntity.d.mts.map +1 -1
- package/build/Entity.d.cts +3 -4
- package/build/Entity.d.cts.map +1 -1
- package/build/Entity.d.mts +3 -4
- package/build/Entity.d.mts.map +1 -1
- package/build/EntityFields.d.cts +3 -4
- package/build/EntityFields.d.cts.map +1 -1
- package/build/EntityFields.d.mts +3 -4
- package/build/EntityFields.d.mts.map +1 -1
- package/build/EntityManager.cjs +102 -22
- package/build/EntityManager.cjs.map +1 -1
- package/build/EntityManager.d.cts +99 -54
- package/build/EntityManager.d.cts.map +1 -1
- package/build/EntityManager.d.mts +99 -54
- package/build/EntityManager.d.mts.map +1 -1
- package/build/EntityManager.js +102 -24
- package/build/EntityManager.js.map +1 -1
- package/build/EntityMetadata.cjs +0 -1
- package/build/EntityMetadata.cjs.map +1 -1
- package/build/EntityMetadata.d.cts +47 -36
- package/build/EntityMetadata.d.cts.map +1 -1
- package/build/EntityMetadata.d.mts +47 -36
- package/build/EntityMetadata.d.mts.map +1 -1
- package/build/EntityMetadata.js +0 -1
- package/build/EntityMetadata.js.map +1 -1
- package/build/EnumMetadata.d.cts +1 -2
- package/build/EnumMetadata.d.cts.map +1 -1
- package/build/EnumMetadata.d.mts +1 -2
- package/build/EnumMetadata.d.mts.map +1 -1
- package/build/IndexManager.cjs +25 -5
- package/build/IndexManager.cjs.map +1 -1
- package/build/IndexManager.d.cts +2 -3
- package/build/IndexManager.d.cts.map +1 -1
- package/build/IndexManager.d.mts +2 -3
- package/build/IndexManager.d.mts.map +1 -1
- package/build/IndexManager.js +25 -5
- package/build/IndexManager.js.map +1 -1
- package/build/InstanceData.cjs.map +1 -1
- package/build/InstanceData.d.cts +1 -2
- package/build/InstanceData.d.cts.map +1 -1
- package/build/InstanceData.d.mts +1 -2
- package/build/InstanceData.d.mts.map +1 -1
- package/build/InstanceData.js.map +1 -1
- package/build/PluginManager.cjs.map +1 -1
- package/build/PluginManager.d.cts +4 -4
- package/build/PluginManager.d.cts.map +1 -1
- package/build/PluginManager.d.mts +4 -4
- package/build/PluginManager.d.mts.map +1 -1
- package/build/PluginManager.js.map +1 -1
- package/build/RowData.d.cts +3 -4
- package/build/RowData.d.cts.map +1 -1
- package/build/RowData.d.mts +3 -4
- package/build/RowData.d.mts.map +1 -1
- package/build/batchloaders/BatchLoader.cjs.map +1 -1
- package/build/batchloaders/BatchLoader.d.cts +1 -2
- package/build/batchloaders/BatchLoader.d.cts.map +1 -1
- package/build/batchloaders/BatchLoader.d.mts +1 -2
- package/build/batchloaders/BatchLoader.d.mts.map +1 -1
- package/build/batchloaders/BatchLoader.js.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.cts +2 -3
- package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.mts +2 -3
- package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/loadBatchLoader.d.cts +2 -3
- package/build/batchloaders/loadBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/loadBatchLoader.d.mts +2 -3
- package/build/batchloaders/loadBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.d.cts +2 -3
- package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.d.mts +2 -3
- package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.cjs +1 -1
- package/build/batchloaders/oneToManyBatchLoader.d.cts +2 -3
- package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.d.mts +2 -3
- package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.js +1 -1
- package/build/batchloaders/oneToOneBatchLoader.cjs +1 -1
- package/build/batchloaders/oneToOneBatchLoader.d.cts +2 -3
- package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.d.mts +2 -3
- package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.js +1 -1
- package/build/batchloaders/populateBatchLoader.d.cts +2 -3
- package/build/batchloaders/populateBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/populateBatchLoader.d.mts +2 -3
- package/build/batchloaders/populateBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +2 -3
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +2 -3
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.js +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts +2 -3
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts +2 -3
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.cjs +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts +2 -3
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts +2 -3
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.js +1 -1
- package/build/changes.cjs +1 -1
- package/build/changes.cjs.map +1 -1
- package/build/changes.d.cts +9 -10
- package/build/changes.d.cts.map +1 -1
- package/build/changes.d.mts +9 -10
- package/build/changes.d.mts.map +1 -1
- package/build/changes.js +1 -1
- package/build/changes.js.map +1 -1
- package/build/config.cjs +165 -26
- package/build/config.cjs.map +1 -1
- package/build/config.d.cts +111 -19
- package/build/config.d.cts.map +1 -1
- package/build/config.d.mts +111 -19
- package/build/config.d.mts.map +1 -1
- package/build/config.js +165 -26
- package/build/config.js.map +1 -1
- package/build/configure.cjs +32 -2
- package/build/configure.cjs.map +1 -1
- package/build/configure.d.cts +8 -9
- package/build/configure.d.cts.map +1 -1
- package/build/configure.d.mts +8 -9
- package/build/configure.d.mts.map +1 -1
- package/build/configure.js +32 -2
- package/build/configure.js.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.d.cts +1 -2
- package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.d.mts +1 -2
- package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
- package/build/dataloaders/findByUniqueDataLoader.d.cts +2 -3
- package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findByUniqueDataLoader.d.mts +2 -3
- package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findCountDataLoader.d.cts +4 -5
- package/build/dataloaders/findCountDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findCountDataLoader.d.mts +4 -5
- package/build/dataloaders/findCountDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findDataLoader.cjs +1 -1
- package/build/dataloaders/findDataLoader.d.cts +11 -12
- package/build/dataloaders/findDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findDataLoader.d.mts +11 -12
- package/build/dataloaders/findDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findDataLoader.js +1 -1
- package/build/dataloaders/findIdsDataLoader.d.cts +2 -3
- package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findIdsDataLoader.d.mts +2 -3
- package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.cjs +6 -2
- package/build/dataloaders/findOrCreateDataLoader.cjs.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.d.cts +3 -3
- package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.d.mts +3 -3
- package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.js +7 -3
- package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.cjs +10 -12
- package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.d.cts +1 -2
- package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.d.mts +1 -2
- package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.js +10 -12
- package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
- package/build/dataloaders/lensDataLoader.d.cts +2 -3
- package/build/dataloaders/lensDataLoader.d.cts.map +1 -1
- package/build/dataloaders/lensDataLoader.d.mts +2 -3
- package/build/dataloaders/lensDataLoader.d.mts.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.cts +2 -3
- package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.mts +2 -3
- package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.cts +2 -3
- package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.mts +2 -3
- package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
- package/build/defaults.cjs +1 -1
- package/build/defaults.cjs.map +1 -1
- package/build/defaults.d.cts +7 -7
- package/build/defaults.d.cts.map +1 -1
- package/build/defaults.d.mts +7 -7
- package/build/defaults.d.mts.map +1 -1
- package/build/defaults.js +1 -1
- package/build/defaults.js.map +1 -1
- package/build/drivers/Driver.d.cts +2 -3
- package/build/drivers/Driver.d.cts.map +1 -1
- package/build/drivers/Driver.d.mts +2 -3
- package/build/drivers/Driver.d.mts.map +1 -1
- package/build/drivers/EntityWriter.cjs +4 -3
- package/build/drivers/EntityWriter.cjs.map +1 -1
- package/build/drivers/EntityWriter.d.cts +19 -7
- package/build/drivers/EntityWriter.d.cts.map +1 -1
- package/build/drivers/EntityWriter.d.mts +19 -7
- package/build/drivers/EntityWriter.d.mts.map +1 -1
- package/build/drivers/EntityWriter.js +5 -4
- package/build/drivers/EntityWriter.js.map +1 -1
- package/build/drivers/IdAssigner.cjs.map +1 -1
- package/build/drivers/IdAssigner.d.cts +5 -5
- package/build/drivers/IdAssigner.d.cts.map +1 -1
- package/build/drivers/IdAssigner.d.mts +5 -5
- package/build/drivers/IdAssigner.d.mts.map +1 -1
- package/build/drivers/IdAssigner.js.map +1 -1
- package/build/drivers/driverApi.d.cts +2 -3
- package/build/drivers/driverApi.d.cts.map +1 -1
- package/build/drivers/driverApi.d.mts +2 -3
- package/build/drivers/driverApi.d.mts.map +1 -1
- package/build/fields.cjs +12 -9
- package/build/fields.cjs.map +1 -1
- package/build/fields.d.cts +10 -11
- package/build/fields.d.cts.map +1 -1
- package/build/fields.d.mts +10 -11
- package/build/fields.d.mts.map +1 -1
- package/build/fields.js +12 -9
- package/build/fields.js.map +1 -1
- package/build/flush/FlushLock.cjs.map +1 -1
- package/build/flush/FlushLock.d.cts +1 -2
- package/build/flush/FlushLock.d.cts.map +1 -1
- package/build/flush/FlushLock.d.mts +1 -2
- package/build/flush/FlushLock.d.mts.map +1 -1
- package/build/flush/FlushLock.js.map +1 -1
- package/build/flush/JoinRows.cjs.map +1 -1
- package/build/flush/JoinRows.d.cts +5 -6
- package/build/flush/JoinRows.d.cts.map +1 -1
- package/build/flush/JoinRows.d.mts +5 -6
- package/build/flush/JoinRows.d.mts.map +1 -1
- package/build/flush/JoinRows.js.map +1 -1
- package/build/flush/PendingChanges.d.cts +5 -6
- package/build/flush/PendingChanges.d.cts.map +1 -1
- package/build/flush/PendingChanges.d.mts +5 -6
- package/build/flush/PendingChanges.d.mts.map +1 -1
- package/build/flush/ReadDrift.cjs +90 -0
- package/build/flush/ReadDrift.cjs.map +1 -0
- package/build/flush/ReadDrift.d.cts +25 -0
- package/build/flush/ReadDrift.d.cts.map +1 -0
- package/build/flush/ReadDrift.d.mts +25 -0
- package/build/flush/ReadDrift.d.mts.map +1 -0
- package/build/flush/ReadDrift.js +87 -0
- package/build/flush/ReadDrift.js.map +1 -0
- package/build/flush/Todo.d.cts +5 -6
- package/build/flush/Todo.d.cts.map +1 -1
- package/build/flush/Todo.d.mts +5 -6
- package/build/flush/Todo.d.mts.map +1 -1
- package/build/getProperties.cjs +1 -1
- package/build/getProperties.d.cts +3 -4
- package/build/getProperties.d.cts.map +1 -1
- package/build/getProperties.d.mts +3 -4
- package/build/getProperties.d.mts.map +1 -1
- package/build/getProperties.js +1 -1
- package/build/index.cjs +20 -7
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +23 -19
- package/build/index.d.cts.map +1 -1
- package/build/index.d.mts +23 -19
- package/build/index.d.mts.map +1 -1
- package/build/index.js +17 -10
- package/build/index.js.map +1 -1
- package/build/json.d.cts +11 -11
- package/build/json.d.cts.map +1 -1
- package/build/json.d.mts +11 -11
- package/build/json.d.mts.map +1 -1
- package/build/keys.d.cts +27 -27
- package/build/keys.d.cts.map +1 -1
- package/build/keys.d.mts +27 -27
- package/build/keys.d.mts.map +1 -1
- package/build/loading/HintTree.d.cts +3 -4
- package/build/loading/HintTree.d.cts.map +1 -1
- package/build/loading/HintTree.d.mts +3 -4
- package/build/loading/HintTree.d.mts.map +1 -1
- package/build/loading/IsLoadedCache.cjs +2 -2
- package/build/loading/IsLoadedCache.cjs.map +1 -1
- package/build/loading/IsLoadedCache.d.cts +3 -4
- package/build/loading/IsLoadedCache.d.cts.map +1 -1
- package/build/loading/IsLoadedCache.d.mts +3 -4
- package/build/loading/IsLoadedCache.d.mts.map +1 -1
- package/build/loading/IsLoadedCache.js +2 -2
- package/build/loading/IsLoadedCache.js.map +1 -1
- package/build/loading/loadHints.d.cts +17 -17
- package/build/loading/loadHints.d.cts.map +1 -1
- package/build/loading/loadHints.d.mts +17 -17
- package/build/loading/loadHints.d.mts.map +1 -1
- package/build/loading/loadLens.d.cts +13 -13
- package/build/loading/loadLens.d.cts.map +1 -1
- package/build/loading/loadLens.d.mts +13 -13
- package/build/loading/loadLens.d.mts.map +1 -1
- package/build/loading/withLoaded.d.cts +5 -6
- package/build/loading/withLoaded.d.cts.map +1 -1
- package/build/loading/withLoaded.d.mts +5 -6
- package/build/loading/withLoaded.d.mts.map +1 -1
- package/build/logging/FactoryLogger.cjs +1 -1
- package/build/logging/FactoryLogger.cjs.map +1 -1
- package/build/logging/FactoryLogger.d.cts +3 -4
- package/build/logging/FactoryLogger.d.cts.map +1 -1
- package/build/logging/FactoryLogger.d.mts +3 -4
- package/build/logging/FactoryLogger.d.mts.map +1 -1
- package/build/logging/FactoryLogger.js +2 -2
- package/build/logging/FactoryLogger.js.map +1 -1
- package/build/logging/FieldLogger.cjs.map +1 -1
- package/build/logging/FieldLogger.d.cts +4 -5
- package/build/logging/FieldLogger.d.cts.map +1 -1
- package/build/logging/FieldLogger.d.mts +4 -5
- package/build/logging/FieldLogger.d.mts.map +1 -1
- package/build/logging/FieldLogger.js.map +1 -1
- package/build/logging/ReactionLogger.d.cts +7 -7
- package/build/logging/ReactionLogger.d.cts.map +1 -1
- package/build/logging/ReactionLogger.d.mts +7 -7
- package/build/logging/ReactionLogger.d.mts.map +1 -1
- package/build/metrics/EntityMetrics.cjs +81 -0
- package/build/metrics/EntityMetrics.cjs.map +1 -0
- package/build/metrics/EntityMetrics.d.cts +55 -0
- package/build/metrics/EntityMetrics.d.cts.map +1 -0
- package/build/metrics/EntityMetrics.d.mts +55 -0
- package/build/metrics/EntityMetrics.d.mts.map +1 -0
- package/build/metrics/EntityMetrics.js +79 -0
- package/build/metrics/EntityMetrics.js.map +1 -0
- package/build/newEntity.cjs +1 -1
- package/build/newEntity.cjs.map +1 -1
- package/build/newEntity.d.cts +4 -5
- package/build/newEntity.d.cts.map +1 -1
- package/build/newEntity.d.mts +4 -5
- package/build/newEntity.d.mts.map +1 -1
- package/build/newEntity.js +1 -1
- package/build/newEntity.js.map +1 -1
- package/build/newTestInstance.cjs +1 -0
- package/build/newTestInstance.cjs.map +1 -1
- package/build/newTestInstance.d.cts +21 -21
- package/build/newTestInstance.d.cts.map +1 -1
- package/build/newTestInstance.d.mts +21 -21
- package/build/newTestInstance.d.mts.map +1 -1
- package/build/newTestInstance.js +1 -0
- package/build/newTestInstance.js.map +1 -1
- package/build/normalizeHints.d.cts +7 -8
- package/build/normalizeHints.d.cts.map +1 -1
- package/build/normalizeHints.d.mts +7 -8
- package/build/normalizeHints.d.mts.map +1 -1
- package/build/nowUTC.d.cts +4 -5
- package/build/nowUTC.d.cts.map +1 -1
- package/build/nowUTC.d.mts +4 -5
- package/build/nowUTC.d.mts.map +1 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.cts +1 -2
- package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.mts +1 -2
- package/build/plugins/ImmutableEntitiesPlugin.d.mts.map +1 -1
- package/build/plugins/PreloadPlugin.d.cts +3 -4
- package/build/plugins/PreloadPlugin.d.cts.map +1 -1
- package/build/plugins/PreloadPlugin.d.mts +3 -4
- package/build/plugins/PreloadPlugin.d.mts.map +1 -1
- package/build/preloading/JsonAggregatePreloader.d.cts +1 -2
- package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -1
- package/build/preloading/JsonAggregatePreloader.d.mts +1 -2
- package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -1
- package/build/preloading/canPreload.d.cts +1 -2
- package/build/preloading/canPreload.d.cts.map +1 -1
- package/build/preloading/canPreload.d.mts +1 -2
- package/build/preloading/canPreload.d.mts.map +1 -1
- package/build/preloading/partitionHint.cjs +1 -1
- package/build/preloading/partitionHint.d.cts +1 -2
- package/build/preloading/partitionHint.d.cts.map +1 -1
- package/build/preloading/partitionHint.d.mts +1 -2
- package/build/preloading/partitionHint.d.mts.map +1 -1
- package/build/preloading/partitionHint.js +1 -1
- package/build/queries/ConditionBuilder.d.cts +2 -2
- package/build/queries/ConditionBuilder.d.cts.map +1 -1
- package/build/queries/ConditionBuilder.d.mts +2 -2
- package/build/queries/ConditionBuilder.d.mts.map +1 -1
- package/build/queries/conditions.d.cts +11 -12
- package/build/queries/conditions.d.cts.map +1 -1
- package/build/queries/conditions.d.mts +11 -12
- package/build/queries/conditions.d.mts.map +1 -1
- package/build/queries/entityQueryUtils.d.cts +4 -5
- package/build/queries/entityQueryUtils.d.cts.map +1 -1
- package/build/queries/entityQueryUtils.d.mts +4 -5
- package/build/queries/entityQueryUtils.d.mts.map +1 -1
- package/build/queries/find/Aliases.d.cts +16 -16
- package/build/queries/find/Aliases.d.cts.map +1 -1
- package/build/queries/find/Aliases.d.mts +16 -16
- package/build/queries/find/Aliases.d.mts.map +1 -1
- package/build/queries/find/DeferredAlias.d.cts +5 -6
- package/build/queries/find/DeferredAlias.d.cts.map +1 -1
- package/build/queries/find/DeferredAlias.d.mts +5 -6
- package/build/queries/find/DeferredAlias.d.mts.map +1 -1
- package/build/queries/find/EntityFilter.d.cts +12 -13
- package/build/queries/find/EntityFilter.d.cts.map +1 -1
- package/build/queries/find/EntityFilter.d.mts +12 -13
- package/build/queries/find/EntityFilter.d.mts.map +1 -1
- package/build/queries/find/EntityGraphQLFilter.d.cts +8 -9
- package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -1
- package/build/queries/find/EntityGraphQLFilter.d.mts +8 -9
- package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.d.cts +1 -2
- package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.d.mts +1 -2
- package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -1
- package/build/queries/find/QueryParser.d.cts +18 -18
- package/build/queries/find/QueryParser.d.cts.map +1 -1
- package/build/queries/find/QueryParser.d.mts +18 -18
- package/build/queries/find/QueryParser.d.mts.map +1 -1
- package/build/queries/find/QueryParser.pruning.d.cts +2 -3
- package/build/queries/find/QueryParser.pruning.d.cts.map +1 -1
- package/build/queries/find/QueryParser.pruning.d.mts +2 -3
- package/build/queries/find/QueryParser.pruning.d.mts.map +1 -1
- package/build/queries/find/QueryVisitor.d.cts +4 -4
- package/build/queries/find/QueryVisitor.d.cts.map +1 -1
- package/build/queries/find/QueryVisitor.d.mts +4 -4
- package/build/queries/find/QueryVisitor.d.mts.map +1 -1
- package/build/queries/find/buildFindQuery.d.cts +3 -3
- package/build/queries/find/buildFindQuery.d.cts.map +1 -1
- package/build/queries/find/buildFindQuery.d.mts +3 -3
- package/build/queries/find/buildFindQuery.d.mts.map +1 -1
- package/build/queries/find/scopes.cjs.map +1 -1
- package/build/queries/find/scopes.d.cts +12 -13
- package/build/queries/find/scopes.d.cts.map +1 -1
- package/build/queries/find/scopes.d.mts +12 -13
- package/build/queries/find/scopes.d.mts.map +1 -1
- package/build/queries/find/scopes.js.map +1 -1
- package/build/queries/parsedConditions.d.cts +7 -8
- package/build/queries/parsedConditions.d.cts.map +1 -1
- package/build/queries/parsedConditions.d.mts +7 -8
- package/build/queries/parsedConditions.d.mts.map +1 -1
- package/build/queries/renderConditions.d.cts +3 -4
- package/build/queries/renderConditions.d.cts.map +1 -1
- package/build/queries/renderConditions.d.mts +3 -4
- package/build/queries/renderConditions.d.mts.map +1 -1
- package/build/queries/skipCondition.d.cts +1 -2
- package/build/queries/skipCondition.d.cts.map +1 -1
- package/build/queries/skipCondition.d.mts +1 -2
- package/build/queries/skipCondition.d.mts.map +1 -1
- package/build/queries/sql/AliasAssigner.cjs.map +1 -1
- package/build/queries/sql/AliasAssigner.d.cts +1 -2
- package/build/queries/sql/AliasAssigner.d.cts.map +1 -1
- package/build/queries/sql/AliasAssigner.d.mts +1 -2
- package/build/queries/sql/AliasAssigner.d.mts.map +1 -1
- package/build/queries/sql/AliasAssigner.js.map +1 -1
- package/build/queries/sql/Expr.cjs +38 -0
- package/build/queries/sql/Expr.cjs.map +1 -1
- package/build/queries/sql/Expr.d.cts +45 -27
- package/build/queries/sql/Expr.d.cts.map +1 -1
- package/build/queries/sql/Expr.d.mts +45 -27
- package/build/queries/sql/Expr.d.mts.map +1 -1
- package/build/queries/sql/Expr.js +38 -1
- package/build/queries/sql/Expr.js.map +1 -1
- package/build/queries/sql/JoinTree.d.cts +5 -5
- package/build/queries/sql/JoinTree.d.cts.map +1 -1
- package/build/queries/sql/JoinTree.d.mts +5 -5
- package/build/queries/sql/JoinTree.d.mts.map +1 -1
- package/build/queries/sql/Tables.cjs +9 -0
- package/build/queries/sql/Tables.cjs.map +1 -1
- package/build/queries/sql/Tables.d.cts +46 -39
- package/build/queries/sql/Tables.d.cts.map +1 -1
- package/build/queries/sql/Tables.d.mts +46 -39
- package/build/queries/sql/Tables.d.mts.map +1 -1
- package/build/queries/sql/Tables.js +10 -1
- package/build/queries/sql/Tables.js.map +1 -1
- package/build/queries/sql/custom.d.cts +14 -14
- package/build/queries/sql/custom.d.cts.map +1 -1
- package/build/queries/sql/custom.d.mts +14 -14
- package/build/queries/sql/custom.d.mts.map +1 -1
- package/build/queries/sql/execute.cjs +68 -89
- package/build/queries/sql/execute.cjs.map +1 -1
- package/build/queries/sql/execute.d.cts +49 -32
- package/build/queries/sql/execute.d.cts.map +1 -1
- package/build/queries/sql/execute.d.mts +49 -32
- package/build/queries/sql/execute.d.mts.map +1 -1
- package/build/queries/sql/execute.js +70 -91
- package/build/queries/sql/execute.js.map +1 -1
- package/build/queries/sql/expressions/arrayAgg.d.cts +5 -6
- package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -1
- package/build/queries/sql/expressions/arrayAgg.d.mts +5 -6
- package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -1
- package/build/queries/sql/expressions/case.d.cts +10 -10
- package/build/queries/sql/expressions/case.d.cts.map +1 -1
- package/build/queries/sql/expressions/case.d.mts +10 -10
- package/build/queries/sql/expressions/case.d.mts.map +1 -1
- package/build/queries/sql/expressions/coalesce.d.cts +5 -6
- package/build/queries/sql/expressions/coalesce.d.cts.map +1 -1
- package/build/queries/sql/expressions/coalesce.d.mts +5 -6
- package/build/queries/sql/expressions/coalesce.d.mts.map +1 -1
- package/build/queries/sql/expressions/codecs.d.cts +1 -2
- package/build/queries/sql/expressions/codecs.d.cts.map +1 -1
- package/build/queries/sql/expressions/codecs.d.mts +1 -2
- package/build/queries/sql/expressions/codecs.d.mts.map +1 -1
- package/build/queries/sql/expressions/expression.d.cts +6 -6
- package/build/queries/sql/expressions/expression.d.cts.map +1 -1
- package/build/queries/sql/expressions/expression.d.mts +6 -6
- package/build/queries/sql/expressions/expression.d.mts.map +1 -1
- package/build/queries/sql/expressions/greatest.d.cts +5 -6
- package/build/queries/sql/expressions/greatest.d.cts.map +1 -1
- package/build/queries/sql/expressions/greatest.d.mts +5 -6
- package/build/queries/sql/expressions/greatest.d.mts.map +1 -1
- package/build/queries/sql/expressions/least.d.cts +5 -6
- package/build/queries/sql/expressions/least.d.cts.map +1 -1
- package/build/queries/sql/expressions/least.d.mts +5 -6
- package/build/queries/sql/expressions/least.d.mts.map +1 -1
- package/build/queries/sql/expressions/nullIf.d.cts +5 -6
- package/build/queries/sql/expressions/nullIf.d.cts.map +1 -1
- package/build/queries/sql/expressions/nullIf.d.mts +5 -6
- package/build/queries/sql/expressions/nullIf.d.mts.map +1 -1
- package/build/queries/sql/expressions/parseExpression.d.cts +5 -6
- package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -1
- package/build/queries/sql/expressions/parseExpression.d.mts +5 -6
- package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -1
- package/build/queries/sql/expressions/types.d.cts +11 -11
- package/build/queries/sql/expressions/types.d.cts.map +1 -1
- package/build/queries/sql/expressions/types.d.mts +11 -11
- package/build/queries/sql/expressions/types.d.mts.map +1 -1
- package/build/queries/sql/keywords.d.cts +4 -5
- package/build/queries/sql/keywords.d.cts.map +1 -1
- package/build/queries/sql/keywords.d.mts +4 -5
- package/build/queries/sql/keywords.d.mts.map +1 -1
- package/build/queries/sql/query.cjs +77 -30
- package/build/queries/sql/query.cjs.map +1 -1
- package/build/queries/sql/query.d.cts +119 -76
- package/build/queries/sql/query.d.cts.map +1 -1
- package/build/queries/sql/query.d.mts +119 -76
- package/build/queries/sql/query.d.mts.map +1 -1
- package/build/queries/sql/query.js +75 -30
- package/build/queries/sql/query.js.map +1 -1
- package/build/queries/unnest.cjs +4 -5
- package/build/queries/unnest.cjs.map +1 -1
- package/build/queries/unnest.d.cts +2 -3
- package/build/queries/unnest.d.cts.map +1 -1
- package/build/queries/unnest.d.mts +2 -3
- package/build/queries/unnest.d.mts.map +1 -1
- package/build/queries/unnest.js +4 -5
- package/build/queries/unnest.js.map +1 -1
- package/build/queries/valueFilters.d.cts +5 -6
- package/build/queries/valueFilters.d.cts.map +1 -1
- package/build/queries/valueFilters.d.mts +5 -6
- package/build/queries/valueFilters.d.mts.map +1 -1
- package/build/reactivity/ReactionsManager.cjs +171 -2
- package/build/reactivity/ReactionsManager.cjs.map +1 -1
- package/build/reactivity/ReactionsManager.d.cts +56 -4
- package/build/reactivity/ReactionsManager.d.cts.map +1 -1
- package/build/reactivity/ReactionsManager.d.mts +56 -4
- package/build/reactivity/ReactionsManager.d.mts.map +1 -1
- package/build/reactivity/ReactionsManager.js +172 -3
- package/build/reactivity/ReactionsManager.js.map +1 -1
- package/build/reactivity/reactiveHints.cjs +9 -3
- package/build/reactivity/reactiveHints.cjs.map +1 -1
- package/build/reactivity/reactiveHints.d.cts +19 -18
- package/build/reactivity/reactiveHints.d.cts.map +1 -1
- package/build/reactivity/reactiveHints.d.mts +19 -18
- package/build/reactivity/reactiveHints.d.mts.map +1 -1
- package/build/reactivity/reactiveHints.js +9 -3
- package/build/reactivity/reactiveHints.js.map +1 -1
- package/build/relations/AbstractPropertyImpl.cjs.map +1 -1
- package/build/relations/AbstractPropertyImpl.d.cts +1 -2
- package/build/relations/AbstractPropertyImpl.d.cts.map +1 -1
- package/build/relations/AbstractPropertyImpl.d.mts +1 -2
- package/build/relations/AbstractPropertyImpl.d.mts.map +1 -1
- package/build/relations/AbstractPropertyImpl.js.map +1 -1
- package/build/relations/AbstractRelationImpl.d.cts +1 -2
- package/build/relations/AbstractRelationImpl.d.cts.map +1 -1
- package/build/relations/AbstractRelationImpl.d.mts +1 -2
- package/build/relations/AbstractRelationImpl.d.mts.map +1 -1
- package/build/relations/AsyncProperty.cjs +1 -1
- package/build/relations/AsyncProperty.cjs.map +1 -1
- package/build/relations/AsyncProperty.d.cts +5 -6
- package/build/relations/AsyncProperty.d.cts.map +1 -1
- package/build/relations/AsyncProperty.d.mts +5 -6
- package/build/relations/AsyncProperty.d.mts.map +1 -1
- package/build/relations/AsyncProperty.js +1 -1
- package/build/relations/AsyncProperty.js.map +1 -1
- package/build/relations/AsyncReactiveField.cjs +23 -5
- package/build/relations/AsyncReactiveField.cjs.map +1 -1
- package/build/relations/AsyncReactiveField.d.cts +7 -6
- package/build/relations/AsyncReactiveField.d.cts.map +1 -1
- package/build/relations/AsyncReactiveField.d.mts +7 -6
- package/build/relations/AsyncReactiveField.d.mts.map +1 -1
- package/build/relations/AsyncReactiveField.js +23 -5
- package/build/relations/AsyncReactiveField.js.map +1 -1
- package/build/relations/Collection.d.cts +4 -5
- package/build/relations/Collection.d.cts.map +1 -1
- package/build/relations/Collection.d.mts +4 -5
- package/build/relations/Collection.d.mts.map +1 -1
- package/build/relations/CustomCollection.cjs +1 -1
- package/build/relations/CustomCollection.cjs.map +1 -1
- package/build/relations/CustomCollection.d.cts +3 -4
- package/build/relations/CustomCollection.d.cts.map +1 -1
- package/build/relations/CustomCollection.d.mts +3 -4
- package/build/relations/CustomCollection.d.mts.map +1 -1
- package/build/relations/CustomCollection.js +1 -1
- package/build/relations/CustomCollection.js.map +1 -1
- package/build/relations/CustomReference.cjs +2 -2
- package/build/relations/CustomReference.cjs.map +1 -1
- package/build/relations/CustomReference.d.cts +3 -4
- package/build/relations/CustomReference.d.cts.map +1 -1
- package/build/relations/CustomReference.d.mts +3 -4
- package/build/relations/CustomReference.d.mts.map +1 -1
- package/build/relations/CustomReference.js +2 -2
- package/build/relations/CustomReference.js.map +1 -1
- package/build/relations/EnumCollection.cjs +1 -1
- package/build/relations/EnumCollection.cjs.map +1 -1
- package/build/relations/EnumCollection.d.cts +5 -5
- package/build/relations/EnumCollection.d.cts.map +1 -1
- package/build/relations/EnumCollection.d.mts +5 -5
- package/build/relations/EnumCollection.d.mts.map +1 -1
- package/build/relations/EnumCollection.js +1 -1
- package/build/relations/EnumCollection.js.map +1 -1
- package/build/relations/LargeCollection.d.cts +1 -2
- package/build/relations/LargeCollection.d.cts.map +1 -1
- package/build/relations/LargeCollection.d.mts +1 -2
- package/build/relations/LargeCollection.d.mts.map +1 -1
- package/build/relations/LazyField.cjs +16 -2
- package/build/relations/LazyField.cjs.map +1 -1
- package/build/relations/LazyField.d.cts +13 -8
- package/build/relations/LazyField.d.cts.map +1 -1
- package/build/relations/LazyField.d.mts +13 -8
- package/build/relations/LazyField.d.mts.map +1 -1
- package/build/relations/LazyField.js +16 -2
- package/build/relations/LazyField.js.map +1 -1
- package/build/relations/ManyToManyCollection.cjs +1 -1
- package/build/relations/ManyToManyCollection.cjs.map +1 -1
- package/build/relations/ManyToManyCollection.d.cts +2 -3
- package/build/relations/ManyToManyCollection.d.cts.map +1 -1
- package/build/relations/ManyToManyCollection.d.mts +2 -3
- package/build/relations/ManyToManyCollection.d.mts.map +1 -1
- package/build/relations/ManyToManyCollection.js +1 -1
- package/build/relations/ManyToManyCollection.js.map +1 -1
- package/build/relations/ManyToManyLargeCollection.cjs +1 -1
- package/build/relations/ManyToManyLargeCollection.d.cts +2 -3
- package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -1
- package/build/relations/ManyToManyLargeCollection.d.mts +2 -3
- package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -1
- package/build/relations/ManyToManyLargeCollection.js +1 -1
- package/build/relations/ManyToOneReference.cjs +2 -2
- package/build/relations/ManyToOneReference.cjs.map +1 -1
- package/build/relations/ManyToOneReference.d.cts +6 -7
- package/build/relations/ManyToOneReference.d.cts.map +1 -1
- package/build/relations/ManyToOneReference.d.mts +6 -7
- package/build/relations/ManyToOneReference.d.mts.map +1 -1
- package/build/relations/ManyToOneReference.js +2 -2
- package/build/relations/ManyToOneReference.js.map +1 -1
- package/build/relations/OneToManyCollection.cjs +1 -1
- package/build/relations/OneToManyCollection.cjs.map +1 -1
- package/build/relations/OneToManyCollection.d.cts +2 -3
- package/build/relations/OneToManyCollection.d.cts.map +1 -1
- package/build/relations/OneToManyCollection.d.mts +2 -3
- package/build/relations/OneToManyCollection.d.mts.map +1 -1
- package/build/relations/OneToManyCollection.js +1 -1
- package/build/relations/OneToManyCollection.js.map +1 -1
- package/build/relations/OneToManyLargeCollection.cjs +1 -1
- package/build/relations/OneToManyLargeCollection.cjs.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.cts +2 -3
- package/build/relations/OneToManyLargeCollection.d.cts.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.mts +2 -3
- package/build/relations/OneToManyLargeCollection.d.mts.map +1 -1
- package/build/relations/OneToManyLargeCollection.js +1 -1
- package/build/relations/OneToManyLargeCollection.js.map +1 -1
- package/build/relations/OneToOneReference.cjs +2 -2
- package/build/relations/OneToOneReference.cjs.map +1 -1
- package/build/relations/OneToOneReference.d.cts +7 -7
- package/build/relations/OneToOneReference.d.cts.map +1 -1
- package/build/relations/OneToOneReference.d.mts +7 -7
- package/build/relations/OneToOneReference.d.mts.map +1 -1
- package/build/relations/OneToOneReference.js +2 -2
- package/build/relations/OneToOneReference.js.map +1 -1
- package/build/relations/PolymorphicReference.cjs +2 -2
- package/build/relations/PolymorphicReference.cjs.map +1 -1
- package/build/relations/PolymorphicReference.d.cts +4 -5
- package/build/relations/PolymorphicReference.d.cts.map +1 -1
- package/build/relations/PolymorphicReference.d.mts +4 -5
- package/build/relations/PolymorphicReference.d.mts.map +1 -1
- package/build/relations/PolymorphicReference.js +2 -2
- package/build/relations/PolymorphicReference.js.map +1 -1
- package/build/relations/PropertySymbols.d.cts +1 -2
- package/build/relations/PropertySymbols.d.cts.map +1 -1
- package/build/relations/PropertySymbols.d.mts +1 -2
- package/build/relations/PropertySymbols.d.mts.map +1 -1
- package/build/relations/ReactiveField.cjs +27 -6
- package/build/relations/ReactiveField.cjs.map +1 -1
- package/build/relations/ReactiveField.d.cts +11 -7
- package/build/relations/ReactiveField.d.cts.map +1 -1
- package/build/relations/ReactiveField.d.mts +11 -7
- package/build/relations/ReactiveField.d.mts.map +1 -1
- package/build/relations/ReactiveField.js +27 -6
- package/build/relations/ReactiveField.js.map +1 -1
- package/build/relations/ReactiveGetter.cjs +1 -1
- package/build/relations/ReactiveGetter.cjs.map +1 -1
- package/build/relations/ReactiveGetter.d.cts +4 -5
- package/build/relations/ReactiveGetter.d.cts.map +1 -1
- package/build/relations/ReactiveGetter.d.mts +4 -5
- package/build/relations/ReactiveGetter.d.mts.map +1 -1
- package/build/relations/ReactiveGetter.js +1 -1
- package/build/relations/ReactiveGetter.js.map +1 -1
- package/build/relations/ReactiveManyToMany.cjs +1 -1
- package/build/relations/ReactiveManyToMany.cjs.map +1 -1
- package/build/relations/ReactiveManyToMany.d.cts +4 -5
- package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
- package/build/relations/ReactiveManyToMany.d.mts +4 -5
- package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
- package/build/relations/ReactiveManyToMany.js +1 -1
- package/build/relations/ReactiveManyToMany.js.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.cjs +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.cts +4 -5
- package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.mts +4 -5
- package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.js +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
- package/build/relations/ReactiveReference.cjs +2 -2
- package/build/relations/ReactiveReference.cjs.map +1 -1
- package/build/relations/ReactiveReference.d.cts +6 -7
- package/build/relations/ReactiveReference.d.cts.map +1 -1
- package/build/relations/ReactiveReference.d.mts +6 -7
- package/build/relations/ReactiveReference.d.mts.map +1 -1
- package/build/relations/ReactiveReference.js +2 -2
- package/build/relations/ReactiveReference.js.map +1 -1
- package/build/relations/ReadOnlyCollection.d.cts +4 -5
- package/build/relations/ReadOnlyCollection.d.cts.map +1 -1
- package/build/relations/ReadOnlyCollection.d.mts +4 -5
- package/build/relations/ReadOnlyCollection.d.mts.map +1 -1
- package/build/relations/RecursiveCollection.cjs +1 -1
- package/build/relations/RecursiveCollection.cjs.map +1 -1
- package/build/relations/RecursiveCollection.d.cts +10 -10
- package/build/relations/RecursiveCollection.d.cts.map +1 -1
- package/build/relations/RecursiveCollection.d.mts +10 -10
- package/build/relations/RecursiveCollection.d.mts.map +1 -1
- package/build/relations/RecursiveCollection.js +1 -1
- package/build/relations/RecursiveCollection.js.map +1 -1
- package/build/relations/RecursiveCycleError.d.cts +2 -2
- package/build/relations/RecursiveCycleError.d.cts.map +1 -1
- package/build/relations/RecursiveCycleError.d.mts +2 -2
- package/build/relations/RecursiveCycleError.d.mts.map +1 -1
- package/build/relations/Reference.d.cts +5 -5
- package/build/relations/Reference.d.cts.map +1 -1
- package/build/relations/Reference.d.mts +5 -5
- package/build/relations/Reference.d.mts.map +1 -1
- package/build/relations/ReferenceSymbols.d.cts +1 -2
- package/build/relations/ReferenceSymbols.d.cts.map +1 -1
- package/build/relations/ReferenceSymbols.d.mts +1 -2
- package/build/relations/ReferenceSymbols.d.mts.map +1 -1
- package/build/relations/Relation.d.cts +3 -3
- package/build/relations/Relation.d.cts.map +1 -1
- package/build/relations/Relation.d.mts +3 -3
- package/build/relations/Relation.d.mts.map +1 -1
- package/build/relations/RelationSymbols.d.cts +2 -3
- package/build/relations/RelationSymbols.d.cts.map +1 -1
- package/build/relations/RelationSymbols.d.mts +2 -3
- package/build/relations/RelationSymbols.d.mts.map +1 -1
- package/build/relations/hasAsyncMethod.cjs +24 -5
- package/build/relations/hasAsyncMethod.cjs.map +1 -1
- package/build/relations/hasAsyncMethod.d.cts +9 -8
- package/build/relations/hasAsyncMethod.d.cts.map +1 -1
- package/build/relations/hasAsyncMethod.d.mts +9 -8
- package/build/relations/hasAsyncMethod.d.mts.map +1 -1
- package/build/relations/hasAsyncMethod.js +24 -6
- package/build/relations/hasAsyncMethod.js.map +1 -1
- package/build/relations/hasManyDerived.cjs +1 -1
- package/build/relations/hasManyDerived.d.cts +2 -2
- package/build/relations/hasManyDerived.d.cts.map +1 -1
- package/build/relations/hasManyDerived.d.mts +2 -2
- package/build/relations/hasManyDerived.d.mts.map +1 -1
- package/build/relations/hasManyDerived.js +1 -1
- package/build/relations/hasManyThrough.cjs +1 -1
- package/build/relations/hasManyThrough.d.cts +1 -2
- package/build/relations/hasManyThrough.d.cts.map +1 -1
- package/build/relations/hasManyThrough.d.mts +1 -2
- package/build/relations/hasManyThrough.d.mts.map +1 -1
- package/build/relations/hasManyThrough.js +1 -1
- package/build/relations/hasOneDerived.cjs +1 -1
- package/build/relations/hasOneDerived.d.cts +1 -2
- package/build/relations/hasOneDerived.d.cts.map +1 -1
- package/build/relations/hasOneDerived.d.mts +1 -2
- package/build/relations/hasOneDerived.d.mts.map +1 -1
- package/build/relations/hasOneDerived.js +1 -1
- package/build/relations/hasOneThrough.cjs +1 -1
- package/build/relations/hasOneThrough.d.cts +1 -2
- package/build/relations/hasOneThrough.d.cts.map +1 -1
- package/build/relations/hasOneThrough.d.mts +1 -2
- package/build/relations/hasOneThrough.d.mts.map +1 -1
- package/build/relations/hasOneThrough.js +1 -1
- package/build/relations/hasProperty.cjs +1 -1
- package/build/relations/hasProperty.cjs.map +1 -1
- package/build/relations/hasProperty.d.cts +8 -8
- package/build/relations/hasProperty.d.cts.map +1 -1
- package/build/relations/hasProperty.d.mts +8 -8
- package/build/relations/hasProperty.d.mts.map +1 -1
- package/build/relations/hasProperty.js +1 -1
- package/build/relations/hasProperty.js.map +1 -1
- package/build/relations/hasReactiveAsyncMethod.cjs +87 -0
- package/build/relations/hasReactiveAsyncMethod.cjs.map +1 -0
- package/build/relations/hasReactiveAsyncMethod.d.cts +32 -0
- package/build/relations/hasReactiveAsyncMethod.d.cts.map +1 -0
- package/build/relations/hasReactiveAsyncMethod.d.mts +32 -0
- package/build/relations/hasReactiveAsyncMethod.d.mts.map +1 -0
- package/build/relations/hasReactiveAsyncMethod.js +85 -0
- package/build/relations/hasReactiveAsyncMethod.js.map +1 -0
- package/build/relations/index.cjs +2 -0
- package/build/relations/index.d.cts +2 -1
- package/build/relations/index.d.mts +2 -1
- package/build/relations/index.js +2 -1
- package/build/relations/isCascadeDelete.d.cts +1 -2
- package/build/relations/isCascadeDelete.d.cts.map +1 -1
- package/build/relations/isCascadeDelete.d.mts +1 -2
- package/build/relations/isCascadeDelete.d.mts.map +1 -1
- package/build/resurrection.cjs +11 -1
- package/build/resurrection.cjs.map +1 -1
- package/build/resurrection.d.cts +5 -3
- package/build/resurrection.d.cts.map +1 -1
- package/build/resurrection.d.mts +5 -3
- package/build/resurrection.d.mts.map +1 -1
- package/build/resurrection.js +11 -2
- package/build/resurrection.js.map +1 -1
- package/build/rules.cjs +1 -1
- package/build/rules.cjs.map +1 -1
- package/build/rules.d.cts +25 -20
- package/build/rules.d.cts.map +1 -1
- package/build/rules.d.mts +25 -20
- package/build/rules.d.mts.map +1 -1
- package/build/rules.js +1 -1
- package/build/rules.js.map +1 -1
- package/build/runtimeConfig.d.cts +4 -5
- package/build/runtimeConfig.d.cts.map +1 -1
- package/build/runtimeConfig.d.mts +4 -5
- package/build/runtimeConfig.d.mts.map +1 -1
- package/build/serde/TypeInfo.d.cts +3 -4
- package/build/serde/TypeInfo.d.cts.map +1 -1
- package/build/serde/TypeInfo.d.mts +3 -4
- package/build/serde/TypeInfo.d.mts.map +1 -1
- package/build/serde/columns.cjs +3 -0
- package/build/serde/columns.cjs.map +1 -1
- package/build/serde/columns.d.cts +3 -3
- package/build/serde/columns.d.cts.map +1 -1
- package/build/serde/columns.d.mts +3 -3
- package/build/serde/columns.d.mts.map +1 -1
- package/build/serde/columns.js +3 -0
- package/build/serde/columns.js.map +1 -1
- package/build/serde/fieldSerde.cjs +3 -0
- package/build/serde/fieldSerde.cjs.map +1 -1
- package/build/serde/fieldSerde.d.cts +10 -9
- package/build/serde/fieldSerde.d.cts.map +1 -1
- package/build/serde/fieldSerde.d.mts +10 -9
- package/build/serde/fieldSerde.d.mts.map +1 -1
- package/build/serde/fieldSerde.js +3 -0
- package/build/serde/fieldSerde.js.map +1 -1
- package/build/serde/serde.cjs +60 -0
- package/build/serde/serde.cjs.map +1 -1
- package/build/serde/serde.d.cts +58 -19
- package/build/serde/serde.d.cts.map +1 -1
- package/build/serde/serde.d.mts +58 -19
- package/build/serde/serde.d.mts.map +1 -1
- package/build/serde/serde.js +60 -1
- package/build/serde/serde.js.map +1 -1
- package/build/serde/temporal.cjs +7 -12
- package/build/serde/temporal.cjs.map +1 -1
- package/build/serde/temporal.d.cts +6 -6
- package/build/serde/temporal.d.cts.map +1 -1
- package/build/serde/temporal.d.mts +6 -6
- package/build/serde/temporal.d.mts.map +1 -1
- package/build/serde/temporal.js +7 -12
- package/build/serde/temporal.js.map +1 -1
- package/build/serde/temporalMappers.cjs +8 -4
- package/build/serde/temporalMappers.cjs.map +1 -1
- package/build/serde/temporalMappers.d.cts +4 -5
- package/build/serde/temporalMappers.d.cts.map +1 -1
- package/build/serde/temporalMappers.d.mts +4 -5
- package/build/serde/temporalMappers.d.mts.map +1 -1
- package/build/serde/temporalMappers.js +8 -4
- package/build/serde/temporalMappers.js.map +1 -1
- package/build/transitions.cjs +91 -0
- package/build/transitions.cjs.map +1 -0
- package/build/transitions.d.cts +115 -0
- package/build/transitions.d.cts.map +1 -0
- package/build/transitions.d.mts +115 -0
- package/build/transitions.d.mts.map +1 -0
- package/build/transitions.js +86 -0
- package/build/transitions.js.map +1 -0
- package/build/trusted.d.cts +2 -3
- package/build/trusted.d.cts.map +1 -1
- package/build/trusted.d.mts +2 -3
- package/build/trusted.d.mts.map +1 -1
- package/build/typeMap.d.cts +17 -17
- package/build/typeMap.d.cts.map +1 -1
- package/build/typeMap.d.mts +17 -17
- package/build/typeMap.d.mts.map +1 -1
- package/build/upsert.cjs +1 -1
- package/build/upsert.d.cts +4 -4
- package/build/upsert.d.cts.map +1 -1
- package/build/upsert.d.mts +4 -4
- package/build/upsert.d.mts.map +1 -1
- package/build/upsert.js +1 -1
- package/build/utils.d.cts +27 -28
- package/build/utils.d.cts.map +1 -1
- package/build/utils.d.mts +27 -28
- package/build/utils.d.mts.map +1 -1
- package/package.json +6 -6
|
@@ -6,8 +6,8 @@ import { EntityMetadata } from "../EntityMetadata.cjs";
|
|
|
6
6
|
import { EntityManager, MaybeAbstractEntityConstructor } from "../EntityManager.cjs";
|
|
7
7
|
import { Entity } from "../Entity.cjs";
|
|
8
8
|
//#region src/dataloaders/findDataLoader.d.ts
|
|
9
|
-
declare const findOperation = "find";
|
|
10
|
-
declare function findDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>, hint: LoadHint<T> | undefined): Promise<T[]>;
|
|
9
|
+
export declare const findOperation = "find";
|
|
10
|
+
export declare function findDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>, hint: LoadHint<T> | undefined): Promise<T[]>;
|
|
11
11
|
/**
|
|
12
12
|
* Returns a stable cache key from the already-parsed query rather than the raw `where`.
|
|
13
13
|
*
|
|
@@ -15,19 +15,19 @@ declare function findDataLoader<T extends Entity>(em: EntityManager, type: Maybe
|
|
|
15
15
|
* to: by this point the scope's structure and values are already worked into the `ParsedFindQuery`, so
|
|
16
16
|
* hashing that distinguishes e.g. `Author.adult` (age>=18) from `Author.senior` (age>=65) correctly.
|
|
17
17
|
*/
|
|
18
|
-
declare function queryFilterHash(entry: {
|
|
18
|
+
export declare function queryFilterHash(entry: {
|
|
19
19
|
query: ParsedFindQuery;
|
|
20
20
|
findSettings: object;
|
|
21
21
|
}): any;
|
|
22
|
-
declare function whereFilterHash(where: object): any;
|
|
22
|
+
export declare function whereFilterHash(where: object): any;
|
|
23
23
|
/** Filters pending-delete entities in place to avoid allocating a replacement array for the common find path. */
|
|
24
|
-
declare function filterDeletedEntities<T extends Entity>(em: EntityManager, entities: T[]): T[];
|
|
24
|
+
export declare function filterDeletedEntities<T extends Entity>(em: EntityManager, entities: T[]): T[];
|
|
25
25
|
/**
|
|
26
26
|
* A single batched arg: the `_find` CTE column to create, plus the index into each entry's `bindings`
|
|
27
27
|
* array that fills it. `bindingIndex` can differ from the column's position because inlined constants
|
|
28
28
|
* are skipped — see {@link collectAndReplaceArgs}.
|
|
29
29
|
*/
|
|
30
|
-
interface CteArg {
|
|
30
|
+
export interface CteArg {
|
|
31
31
|
column: OpColumn;
|
|
32
32
|
bindingIndex: number;
|
|
33
33
|
}
|
|
@@ -45,7 +45,7 @@ interface CteArg {
|
|
|
45
45
|
* @param query the initial query in the batch, that all other queries structurally match
|
|
46
46
|
* @param entries the values (bindings) for each query in the batch
|
|
47
47
|
*/
|
|
48
|
-
declare function collectAndReplaceArgs(query: ParsedFindQuery, entries: readonly {
|
|
48
|
+
export declare function collectAndReplaceArgs(query: ParsedFindQuery, entries: readonly {
|
|
49
49
|
bindings: any[];
|
|
50
50
|
}[]): CteArg[];
|
|
51
51
|
/**
|
|
@@ -54,11 +54,11 @@ declare function collectAndReplaceArgs(query: ParsedFindQuery, entries: readonly
|
|
|
54
54
|
* Column 0 is the per-entry `tag`; the remaining columns mirror `args` 1:1, each pulling its
|
|
55
55
|
* `bindingIndex` from every entry's `bindings` (so inlined constants are naturally skipped).
|
|
56
56
|
*/
|
|
57
|
-
declare function createColumnValuesFromPrepared(args: readonly CteArg[], entries: readonly {
|
|
57
|
+
export declare function createColumnValuesFromPrepared(args: readonly CteArg[], entries: readonly {
|
|
58
58
|
bindings: any[];
|
|
59
59
|
}[]): any[][];
|
|
60
60
|
/** Pushes the arg values of a given query in the cross-query `bindings` array. */
|
|
61
|
-
declare function collectValues(bindings: any[], query: ParsedFindQuery): void;
|
|
61
|
+
export declare function collectValues(bindings: any[], query: ParsedFindQuery): void;
|
|
62
62
|
/**
|
|
63
63
|
* Creates a `VALUES (...), (...)` SQL string for use in a CTE, typically for our
|
|
64
64
|
* batch INSERTs/UPDATEs where the CTE is how we inject N rows of data/params into
|
|
@@ -69,11 +69,10 @@ declare function collectValues(bindings: any[], query: ParsedFindQuery): void;
|
|
|
69
69
|
*
|
|
70
70
|
* @deprecated Use newUnnestCte instead because it uses arrays to have a bounded number of parameters.
|
|
71
71
|
*/
|
|
72
|
-
declare function buildValuesCte(alias: string, columns: {
|
|
72
|
+
export declare function buildValuesCte(alias: string, columns: {
|
|
73
73
|
columnName: string;
|
|
74
74
|
dbType: string;
|
|
75
75
|
}[], rows: readonly any[], bindings: readonly any[]): ParsedCteClause;
|
|
76
|
-
declare function getBatchKeyFromGenericStructure(meta: EntityMetadata, query: ParsedFindQuery): string;
|
|
76
|
+
export declare function getBatchKeyFromGenericStructure(meta: EntityMetadata, query: ParsedFindQuery): string;
|
|
77
77
|
//#endregion
|
|
78
|
-
export { CteArg, buildValuesCte, collectAndReplaceArgs, collectValues, createColumnValuesFromPrepared, filterDeletedEntities, findDataLoader, findOperation, getBatchKeyFromGenericStructure, queryFilterHash, whereFilterHash };
|
|
79
78
|
//# sourceMappingURL=findDataLoader.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findDataLoader.d.cts","names":[],"sources":["../../src/dataloaders/findDataLoader.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"findDataLoader.d.cts","names":[],"sources":["../../src/dataloaders/findDataLoader.ts"],"mappings":";;;;;;;;qBA0Ba;wBAUG,eAAe,UAAU,QACvC,IAAI,eACJ,MAAM,+BAA+B,IACrC,QAAQ,kBAAkB,IAC1B,MAAM,SAAS,iBACd,QAAQ;;;;;;;;wBAwHK,gBAAgB;EAAS,OAAO;EAAiB;;wBAIjD,gBAAgB;;wBAOhB,sBAAsB,UAAU,QAAQ,IAAI,eAAe,UAAU,MAAM;;;;;;iBA8B1E;EACf,QAAQ;EACR;;;;;;;;;;;;;;;;wBAiBc,sBAAsB,OAAO,iBAAiB;EAAoB;MAAsB;;;;;;;wBAoExF,+BACd,eAAe,UACf;EAAoB;;;wBAcN,cAAc,iBAAiB,OAAO;;;;;;;;;;;wBAoItC,eACd,eACA;EAAW;EAAoB;KAC/B,sBAEA,2BACC;wBA2Ca,gCAAgC,MAAM,gBAAgB,OAAO"}
|
|
@@ -6,8 +6,8 @@ import { EntityMetadata } from "../EntityMetadata.mjs";
|
|
|
6
6
|
import { EntityManager, MaybeAbstractEntityConstructor } from "../EntityManager.mjs";
|
|
7
7
|
import { Entity } from "../Entity.mjs";
|
|
8
8
|
//#region src/dataloaders/findDataLoader.d.ts
|
|
9
|
-
declare const findOperation = "find";
|
|
10
|
-
declare function findDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>, hint: LoadHint<T> | undefined): Promise<T[]>;
|
|
9
|
+
export declare const findOperation = "find";
|
|
10
|
+
export declare function findDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>, hint: LoadHint<T> | undefined): Promise<T[]>;
|
|
11
11
|
/**
|
|
12
12
|
* Returns a stable cache key from the already-parsed query rather than the raw `where`.
|
|
13
13
|
*
|
|
@@ -15,19 +15,19 @@ declare function findDataLoader<T extends Entity>(em: EntityManager, type: Maybe
|
|
|
15
15
|
* to: by this point the scope's structure and values are already worked into the `ParsedFindQuery`, so
|
|
16
16
|
* hashing that distinguishes e.g. `Author.adult` (age>=18) from `Author.senior` (age>=65) correctly.
|
|
17
17
|
*/
|
|
18
|
-
declare function queryFilterHash(entry: {
|
|
18
|
+
export declare function queryFilterHash(entry: {
|
|
19
19
|
query: ParsedFindQuery;
|
|
20
20
|
findSettings: object;
|
|
21
21
|
}): any;
|
|
22
|
-
declare function whereFilterHash(where: object): any;
|
|
22
|
+
export declare function whereFilterHash(where: object): any;
|
|
23
23
|
/** Filters pending-delete entities in place to avoid allocating a replacement array for the common find path. */
|
|
24
|
-
declare function filterDeletedEntities<T extends Entity>(em: EntityManager, entities: T[]): T[];
|
|
24
|
+
export declare function filterDeletedEntities<T extends Entity>(em: EntityManager, entities: T[]): T[];
|
|
25
25
|
/**
|
|
26
26
|
* A single batched arg: the `_find` CTE column to create, plus the index into each entry's `bindings`
|
|
27
27
|
* array that fills it. `bindingIndex` can differ from the column's position because inlined constants
|
|
28
28
|
* are skipped — see {@link collectAndReplaceArgs}.
|
|
29
29
|
*/
|
|
30
|
-
interface CteArg {
|
|
30
|
+
export interface CteArg {
|
|
31
31
|
column: OpColumn;
|
|
32
32
|
bindingIndex: number;
|
|
33
33
|
}
|
|
@@ -45,7 +45,7 @@ interface CteArg {
|
|
|
45
45
|
* @param query the initial query in the batch, that all other queries structurally match
|
|
46
46
|
* @param entries the values (bindings) for each query in the batch
|
|
47
47
|
*/
|
|
48
|
-
declare function collectAndReplaceArgs(query: ParsedFindQuery, entries: readonly {
|
|
48
|
+
export declare function collectAndReplaceArgs(query: ParsedFindQuery, entries: readonly {
|
|
49
49
|
bindings: any[];
|
|
50
50
|
}[]): CteArg[];
|
|
51
51
|
/**
|
|
@@ -54,11 +54,11 @@ declare function collectAndReplaceArgs(query: ParsedFindQuery, entries: readonly
|
|
|
54
54
|
* Column 0 is the per-entry `tag`; the remaining columns mirror `args` 1:1, each pulling its
|
|
55
55
|
* `bindingIndex` from every entry's `bindings` (so inlined constants are naturally skipped).
|
|
56
56
|
*/
|
|
57
|
-
declare function createColumnValuesFromPrepared(args: readonly CteArg[], entries: readonly {
|
|
57
|
+
export declare function createColumnValuesFromPrepared(args: readonly CteArg[], entries: readonly {
|
|
58
58
|
bindings: any[];
|
|
59
59
|
}[]): any[][];
|
|
60
60
|
/** Pushes the arg values of a given query in the cross-query `bindings` array. */
|
|
61
|
-
declare function collectValues(bindings: any[], query: ParsedFindQuery): void;
|
|
61
|
+
export declare function collectValues(bindings: any[], query: ParsedFindQuery): void;
|
|
62
62
|
/**
|
|
63
63
|
* Creates a `VALUES (...), (...)` SQL string for use in a CTE, typically for our
|
|
64
64
|
* batch INSERTs/UPDATEs where the CTE is how we inject N rows of data/params into
|
|
@@ -69,11 +69,10 @@ declare function collectValues(bindings: any[], query: ParsedFindQuery): void;
|
|
|
69
69
|
*
|
|
70
70
|
* @deprecated Use newUnnestCte instead because it uses arrays to have a bounded number of parameters.
|
|
71
71
|
*/
|
|
72
|
-
declare function buildValuesCte(alias: string, columns: {
|
|
72
|
+
export declare function buildValuesCte(alias: string, columns: {
|
|
73
73
|
columnName: string;
|
|
74
74
|
dbType: string;
|
|
75
75
|
}[], rows: readonly any[], bindings: readonly any[]): ParsedCteClause;
|
|
76
|
-
declare function getBatchKeyFromGenericStructure(meta: EntityMetadata, query: ParsedFindQuery): string;
|
|
76
|
+
export declare function getBatchKeyFromGenericStructure(meta: EntityMetadata, query: ParsedFindQuery): string;
|
|
77
77
|
//#endregion
|
|
78
|
-
export { CteArg, buildValuesCte, collectAndReplaceArgs, collectValues, createColumnValuesFromPrepared, filterDeletedEntities, findDataLoader, findOperation, getBatchKeyFromGenericStructure, queryFilterHash, whereFilterHash };
|
|
79
78
|
//# sourceMappingURL=findDataLoader.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findDataLoader.d.mts","names":[],"sources":["../../src/dataloaders/findDataLoader.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"findDataLoader.d.mts","names":[],"sources":["../../src/dataloaders/findDataLoader.ts"],"mappings":";;;;;;;;qBA0Ba;wBAUG,eAAe,UAAU,QACvC,IAAI,eACJ,MAAM,+BAA+B,IACrC,QAAQ,kBAAkB,IAC1B,MAAM,SAAS,iBACd,QAAQ;;;;;;;;wBAwHK,gBAAgB;EAAS,OAAO;EAAiB;;wBAIjD,gBAAgB;;wBAOhB,sBAAsB,UAAU,QAAQ,IAAI,eAAe,UAAU,MAAM;;;;;;iBA8B1E;EACf,QAAQ;EACR;;;;;;;;;;;;;;;;wBAiBc,sBAAsB,OAAO,iBAAiB;EAAoB;MAAsB;;;;;;;wBAoExF,+BACd,eAAe,UACf;EAAoB;;;wBAcN,cAAc,iBAAiB,OAAO;;;;;;;;;;;wBAoItC,eACd,eACA;EAAW;EAAoB;KAC/B,sBAEA,2BACC;wBA2Ca,gCAAgC,MAAM,gBAAgB,OAAO"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { hintKey } from "../normalizeHints.js";
|
|
2
|
-
import { equal, equalArrays } from "../fields.js";
|
|
3
2
|
import { kqDot } from "../queries/sql/keywords.js";
|
|
4
3
|
import { isQueryProvablyEmpty, visitConditions } from "../queries/find/QueryVisitor.js";
|
|
5
4
|
import { getTables, parseAlias, parseFindQuery } from "../queries/find/QueryParser.js";
|
|
6
5
|
import { assertNever, fail } from "../utils.js";
|
|
6
|
+
import { equal, equalArrays } from "../fields.js";
|
|
7
7
|
import { getMetadata } from "../EntityMetadata.js";
|
|
8
8
|
import { opToFn } from "../queries/find/EntityGraphQLFilter.js";
|
|
9
9
|
import { fastWhereFilterHash } from "./fastWhereFilterHash.js";
|
|
@@ -2,8 +2,7 @@ import { FilterAndSettings } from "../queries/find/EntityFilter.cjs";
|
|
|
2
2
|
import { EntityManager, MaybeAbstractEntityConstructor } from "../EntityManager.cjs";
|
|
3
3
|
import { Entity } from "../Entity.cjs";
|
|
4
4
|
//#region src/dataloaders/findIdsDataLoader.d.ts
|
|
5
|
-
declare const findIdsOperation = "find-ids";
|
|
6
|
-
declare function findIdsDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>): Promise<string[]>;
|
|
5
|
+
export declare const findIdsOperation = "find-ids";
|
|
6
|
+
export declare function findIdsDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>): Promise<string[]>;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { findIdsDataLoader, findIdsOperation };
|
|
9
8
|
//# sourceMappingURL=findIdsDataLoader.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findIdsDataLoader.d.cts","names":[],"sources":["../../src/dataloaders/findIdsDataLoader.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"findIdsDataLoader.d.cts","names":[],"sources":["../../src/dataloaders/findIdsDataLoader.ts"],"mappings":";;;;qBAkBa;wBAEG,kBAAkB,UAAU,QAC1C,IAAI,eACJ,MAAM,+BAA+B,IACrC,QAAQ,kBAAkB,KACzB"}
|
|
@@ -2,8 +2,7 @@ import { FilterAndSettings } from "../queries/find/EntityFilter.mjs";
|
|
|
2
2
|
import { EntityManager, MaybeAbstractEntityConstructor } from "../EntityManager.mjs";
|
|
3
3
|
import { Entity } from "../Entity.mjs";
|
|
4
4
|
//#region src/dataloaders/findIdsDataLoader.d.ts
|
|
5
|
-
declare const findIdsOperation = "find-ids";
|
|
6
|
-
declare function findIdsDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>): Promise<string[]>;
|
|
5
|
+
export declare const findIdsOperation = "find-ids";
|
|
6
|
+
export declare function findIdsDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>): Promise<string[]>;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { findIdsDataLoader, findIdsOperation };
|
|
9
8
|
//# sourceMappingURL=findIdsDataLoader.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findIdsDataLoader.d.mts","names":[],"sources":["../../src/dataloaders/findIdsDataLoader.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"findIdsDataLoader.d.mts","names":[],"sources":["../../src/dataloaders/findIdsDataLoader.ts"],"mappings":";;;;qBAkBa;wBAEG,kBAAkB,UAAU,QAC1C,IAAI,eACJ,MAAM,+BAA+B,IACrC,QAAQ,kBAAkB,KACzB"}
|
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_relations_Reference = require("../relations/Reference.cjs");
|
|
3
3
|
require("../relations/index.cjs");
|
|
4
4
|
const require_utils = require("../utils.cjs");
|
|
5
|
+
const require_fields = require("../fields.cjs");
|
|
5
6
|
const require_EntityMetadata = require("../EntityMetadata.cjs");
|
|
6
7
|
const require_dataloaders_findDataLoader = require("./findDataLoader.cjs");
|
|
7
8
|
const require_resurrection = require("../resurrection.cjs");
|
|
@@ -38,7 +39,7 @@ function findOrCreateDataLoader(em, type, where, softDeletes) {
|
|
|
38
39
|
if (upsert) entity.set(upsert);
|
|
39
40
|
return keys.map(() => entity);
|
|
40
41
|
}
|
|
41
|
-
const entities = await em.find(type,
|
|
42
|
+
const entities = await em.find(type, require_resurrection.newWhereEqual(meta, where), { softDeletes: "include" });
|
|
42
43
|
let entity;
|
|
43
44
|
if (entities.length > 1) throw new require_EntityManager.TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);
|
|
44
45
|
else if (entities.length === 1) {
|
|
@@ -61,7 +62,10 @@ function entityMatches(entity, opts) {
|
|
|
61
62
|
switch (field.kind) {
|
|
62
63
|
case "primaryKey":
|
|
63
64
|
case "enum": return entity[fn] === value;
|
|
64
|
-
case "primitive": if (
|
|
65
|
+
case "primitive": if (meta.columns[fieldName]?.isArray) {
|
|
66
|
+
const current = entity[fn];
|
|
67
|
+
return Array.isArray(current) && Array.isArray(value) ? require_fields.equalArrays(current, value) : current === value;
|
|
68
|
+
} else if (field.citext) return compareCaseInsensitive(entity[fn], value);
|
|
65
69
|
else return entity[fn] === value;
|
|
66
70
|
case "m2o":
|
|
67
71
|
case "poly":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOrCreateDataLoader.cjs","names":["getMetadata","whereFilterHash","fail","TooManyError","isEntity","isLoadedReference","sameEntity","cleanStringValue"],"sources":["../../src/dataloaders/findOrCreateDataLoader.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport { whereFilterHash } from \"src/dataloaders/findDataLoader.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type EntityManager, TooManyError, sameEntity } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getMetadata } from \"src/EntityMetadata.ts\";\nimport { type ManyToOneReference, type PolymorphicReference, isLoadedReference } from \"src/relations/index.ts\";\nimport { resurrectIfSoftDeleted } from \"src/resurrection.ts\";\nimport type { OptsOf } from \"src/typeMap.ts\";\nimport { cleanStringValue, fail } from \"src/utils.ts\";\n\ninterface FindOrCreateKey<T extends Entity> {\n ifNew: OptsOf<T>;\n upsert: Partial<OptsOf<T>> | undefined;\n}\n\nexport function findOrCreateDataLoader<T extends Entity>(\n em: EntityManager,\n type: EntityConstructor<T>,\n where: Partial<OptsOf<T>>,\n softDeletes: \"include\" | \"exclude\",\n): DataLoader<FindOrCreateKey<T>, T> {\n const meta = getMetadata(type);\n\n // Do some extra logic to make unclean strings/citext not create duplicate entities\n const hasAnyStrings = Object.values(meta.allFields).some((f) => f.kind === \"primitive\" && f.type === \"string\");\n const hasAnyCitext = Object.values(meta.allFields).some((f) => f.kind === \"primitive\" && f.citext);\n\n // The `where` here will be later used to `em.create`, so we only clean (not lower for citext)\n where = hasAnyStrings ? maybeClean(meta, where) : where;\n // Use `whereFilterHash` to batch the same `findOrCreate` `where: { firstName: \"a1\" }` calls together to avoid duplicates\n const whereValue = whereFilterHash(\n // Only maybeLower for the purposes of batching, not the later em.create\n hasAnyCitext ? maybeLower(meta, where) : (where as any),\n );\n const batchKey = `${type.name}-${whereValue}-${softDeletes}`;\n\n const invalidKeys = Object.keys(where).filter((key) => {\n const field = meta.allFields[key] ?? fail(`Invalid field ${key}`);\n const supported =\n field.kind === \"primitive\" || field.kind === \"enum\" || field.kind === \"m2o\" || field.kind === \"poly\";\n return !supported;\n });\n if (invalidKeys.length > 0) {\n throw new Error(\n \"findOrCreate only supports primitive, enum, m2o, or poly fields in the where clause. Invalid keys: \" +\n invalidKeys.join(\", \"),\n );\n }\n\n return em.getLoader<FindOrCreateKey<T>, T>(\n \"find-or-create\",\n batchKey,\n async (keys) => {\n // Because our `batchKey` is based only on the `where` clause, if the user called\n // `findOrCreate({ firstName: a1 })` multiple times, but with different ifNew/upsert\n // conditions (or different cased strings and is using a citext column), we'll end\n // up with multiple keys...\n //\n // This is fundamentally asking to create the same entity, but with different ifNew/upsert\n // conditions, which we could fail on, but for now just take the first tuple of\n // {where/ifNew/upsert} and assume it wins\n const [{ ifNew, upsert }] = keys;\n\n // Before we find/create an entity, see if we have a maybe-new one in the EM already.\n // This will also use any WIP changes we've made to the found entity, which ideally is\n // something `em.find` would do as well, but its queries are much more complex...\n const inMemory = em.filterEntities(type, where);\n if (inMemory.length > 1) {\n throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);\n } else if (inMemory.length === 1) {\n const entity = inMemory[0] as T;\n resurrectIfSoftDeleted(entity);\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n }\n\n // If there is a param like `{ publisher: newPublisherEntity }`, then we know that\n // an entity matching this condition can't be in the db anyway, so skip the em.find\n const hasNewEntityParam = Object.values(where).some((v) => isEntity(v) && v.isNewEntity);\n if (hasNewEntityParam) {\n const entity = em.create(type, { ...where, ...(ifNew as object) } as OptsOf<T>);\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n }\n\n // If we didn't find it in the EM, do the db query/em.create\n const entities = await em.find(\n type,\n // Convert `publisher: undefined` --> `publisher: null`, and we need to make a copy anyway\n Object.fromEntries(Object.entries(where).map(([k, v]) => [k, v === undefined ? null : v])) as any,\n // Always include soft-deleted rows so findOrCreate can resurrect them instead of creating duplicates.\n { softDeletes: \"include\" },\n );\n let entity: T;\n if (entities.length > 1) {\n throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);\n } else if (entities.length === 1) {\n entity = entities[0];\n resurrectIfSoftDeleted(entity);\n } else {\n entity = em.create(type, { ...where, ...(ifNew as object) } as OptsOf<T>);\n }\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n },\n // Our filter tuple is a complex object, so use a stable cache key to ensure caching works.\n { cacheKeyFn: whereFilterHash as any },\n );\n}\n\n/** A simple in-memory match of `entity` against a mini/flat \"WHERE clause\" of `opts`. */\nexport function entityMatches<T extends Entity>(entity: T, opts: Partial<OptsOf<T>>): boolean {\n const meta = getMetadata(entity);\n return Object.entries(opts).every(([fieldName, value]) => {\n const field = meta.allFields[fieldName] ?? fail(`Invalid field ${fieldName}`);\n const fn = fieldName as keyof T & keyof OptsOf<T>;\n switch (field.kind) {\n case \"primaryKey\":\n case \"enum\":\n return entity[fn] === value;\n case \"primitive\":\n if (field.citext) {\n return compareCaseInsensitive(entity[fn], value);\n } else {\n return entity[fn] === value;\n }\n case \"m2o\":\n case \"poly\":\n const relation = entity[fn] as ManyToOneReference<T, any, any> | PolymorphicReference<T, any, any>;\n if (isLoadedReference(relation)) {\n // Prefer using `.get` because it will handle new/id-less entities\n return sameEntity(relation.get, value as any);\n } else if (relation.isSet) {\n // Otherwise use ids\n return sameEntity(relation.id as any, value as any);\n } else {\n // Relation is not set, match if value is null-ish (null or undefined)\n return value === undefined || value === null;\n }\n default:\n throw new Error(`Unsupported field ${fieldName}`);\n }\n });\n}\n\nfunction whereAsString(where: object): string {\n return Object.entries(where)\n .map(([key, value]) => `${key}=${value}`)\n .join(\", \");\n}\n\nfunction compareCaseInsensitive(str1: any, str2: any): boolean {\n return (\n str1 !== undefined &&\n str2 !== undefined &&\n typeof str1 === \"string\" &&\n typeof str2 === \"string\" &&\n str1.toLowerCase() === str2.toLowerCase()\n );\n}\n\n/** Returns a copy of `opts` with any `citext` values turned to lower case. */\nfunction maybeLower<T extends object | undefined>(meta: EntityMetadata, opts: T): T {\n if (!opts) return opts;\n let result: T | undefined = undefined;\n for (const k in opts) {\n const v = (opts as any)[k];\n const field = meta.allFields[k];\n const isString = field && field.kind === \"primitive\" && field.type === \"string\";\n if (isString && field.citext) {\n const lowered = v?.toLowerCase();\n if (lowered !== v) {\n result ??= { ...opts };\n (result as any)[k] = lowered as any;\n }\n }\n }\n return result ?? opts;\n}\n\n/** Returns a copy of `opts` with any string values trimmed/coalesced. */\nfunction maybeClean<T extends object | undefined>(meta: EntityMetadata, opts: T): T {\n if (!opts) return opts;\n let result: T | undefined = undefined;\n for (const k in opts) {\n const v = (opts as any)[k];\n const field = meta.allFields[k];\n const isString = field && field.kind === \"primitive\" && field.type === \"string\";\n if (isString && field.sanitize !== false) {\n const cleaned = cleanStringValue(v);\n if (cleaned !== v) {\n result ??= { ...opts }; // Only create copy on first change\n (result as any)[k] = cleaned;\n }\n }\n }\n return result ?? opts;\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAgB,uBACd,IACA,MACA,OACA,aACmC;CACnC,MAAM,OAAOA,uBAAAA,YAAY,IAAI;CAG7B,MAAM,gBAAgB,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM,MAAM,EAAE,SAAS,eAAe,EAAE,SAAS,QAAQ;CAC7G,MAAM,eAAe,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM,MAAM,EA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K,CAAC,CACzB,KAAK,CAAC,KAAK,WAAW,GAAG,IAAI,GAAG,OAAO,CAAC,CACxC,KAAK,IAAI;AACd;AAEA,SAAS,uBAAuB,MAAW,MAAoB;CAC7D,OACE,SAAS,KAAA,KACT,SAAS,KAAA,KACT,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,KAAK,YAAY,MAAM,KAAK,YAAY;AAE5C;;AAGA,SAAS,WAAyC,MAAsB,MAAY;CAClF,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,SAAwB,KAAA;CAC5B,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,IAAK,KAAa;EACxB,MAAM,QAAQ,KAAK,UAAU;EAE7B,IADiB,SAAS,MAAM,SAAS,eAAe,MAAM,SAAS,YACvD,MAAM,QAAQ;GAC5B,MAAM,UAAU,GAAG,YAAY;GAC/B,IAAI,YAAY,GAAG;IACjB,WAAW,EAAE,GAAG,KAAK;IACrB,OAAgB,KAAK;GACvB;EACF;CACF;CACA,OAAO,UAAU;AACnB;;AAGA,SAAS,WAAyC,MAAsB,MAAY;CAClF,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,SAAwB,KAAA;CAC5B,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,IAAK,KAAa;EACxB,MAAM,QAAQ,KAAK,UAAU;EAE7B,IADiB,SAAS,MAAM,SAAS,eAAe,MAAM,SAAS,YACvD,MAAM,aAAa,OAAO;GACxC,MAAM,UAAUC,cAAAA,iBAAiB,CAAC;GAClC,IAAI,YAAY,GAAG;IACjB,WAAW,EAAE,GAAG,KAAK;IACrB,OAAgB,KAAK;GACvB;EACF;CACF;CACA,OAAO,UAAU;AACnB"}
|
|
1
|
+
{"version":3,"file":"findOrCreateDataLoader.cjs","names":["getMetadata","whereFilterHash","fail","TooManyError","isEntity","newWhereEqual","equalArrays","isLoadedReference","sameEntity","cleanStringValue"],"sources":["../../src/dataloaders/findOrCreateDataLoader.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport { whereFilterHash } from \"src/dataloaders/findDataLoader.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type EntityManager, TooManyError, sameEntity } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getMetadata } from \"src/EntityMetadata.ts\";\nimport { equalArrays } from \"src/fields.ts\";\nimport { type ManyToOneReference, type PolymorphicReference, isLoadedReference } from \"src/relations/index.ts\";\nimport { newWhereEqual, resurrectIfSoftDeleted } from \"src/resurrection.ts\";\nimport type { OptsOf } from \"src/typeMap.ts\";\nimport { cleanStringValue, fail } from \"src/utils.ts\";\n\ninterface FindOrCreateKey<T extends Entity> {\n ifNew: OptsOf<T>;\n upsert: Partial<OptsOf<T>> | undefined;\n}\n\nexport function findOrCreateDataLoader<T extends Entity>(\n em: EntityManager,\n type: EntityConstructor<T>,\n where: Partial<OptsOf<T>>,\n softDeletes: \"include\" | \"exclude\",\n): DataLoader<FindOrCreateKey<T>, T> {\n const meta = getMetadata(type);\n\n // Do some extra logic to make unclean strings/citext not create duplicate entities\n const hasAnyStrings = Object.values(meta.allFields).some((f) => f.kind === \"primitive\" && f.type === \"string\");\n const hasAnyCitext = Object.values(meta.allFields).some((f) => f.kind === \"primitive\" && f.citext);\n\n // The `where` here will be later used to `em.create`, so we only clean (not lower for citext)\n where = hasAnyStrings ? maybeClean(meta, where) : where;\n // Use `whereFilterHash` to batch the same `findOrCreate` `where: { firstName: \"a1\" }` calls together to avoid duplicates\n const whereValue = whereFilterHash(\n // Only maybeLower for the purposes of batching, not the later em.create\n hasAnyCitext ? maybeLower(meta, where) : (where as any),\n );\n const batchKey = `${type.name}-${whereValue}-${softDeletes}`;\n\n const invalidKeys = Object.keys(where).filter((key) => {\n const field = meta.allFields[key] ?? fail(`Invalid field ${key}`);\n const supported =\n field.kind === \"primitive\" || field.kind === \"enum\" || field.kind === \"m2o\" || field.kind === \"poly\";\n return !supported;\n });\n if (invalidKeys.length > 0) {\n throw new Error(\n \"findOrCreate only supports primitive, enum, m2o, or poly fields in the where clause. Invalid keys: \" +\n invalidKeys.join(\", \"),\n );\n }\n\n return em.getLoader<FindOrCreateKey<T>, T>(\n \"find-or-create\",\n batchKey,\n async (keys) => {\n // Because our `batchKey` is based only on the `where` clause, if the user called\n // `findOrCreate({ firstName: a1 })` multiple times, but with different ifNew/upsert\n // conditions (or different cased strings and is using a citext column), we'll end\n // up with multiple keys...\n //\n // This is fundamentally asking to create the same entity, but with different ifNew/upsert\n // conditions, which we could fail on, but for now just take the first tuple of\n // {where/ifNew/upsert} and assume it wins\n const [{ ifNew, upsert }] = keys;\n\n // Before we find/create an entity, see if we have a maybe-new one in the EM already.\n // This will also use any WIP changes we've made to the found entity, which ideally is\n // something `em.find` would do as well, but its queries are much more complex...\n const inMemory = em.filterEntities(type, where);\n if (inMemory.length > 1) {\n throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);\n } else if (inMemory.length === 1) {\n const entity = inMemory[0] as T;\n resurrectIfSoftDeleted(entity);\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n }\n\n // If there is a param like `{ publisher: newPublisherEntity }`, then we know that\n // an entity matching this condition can't be in the db anyway, so skip the em.find\n const hasNewEntityParam = Object.values(where).some((v) => isEntity(v) && v.isNewEntity);\n if (hasNewEntityParam) {\n const entity = em.create(type, { ...where, ...(ifNew as object) } as OptsOf<T>);\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n }\n\n // If we didn't find it in the EM, do the db query/em.create\n const entities = await em.find(\n type,\n newWhereEqual(meta, where) as any,\n // Always include soft-deleted rows so findOrCreate can resurrect them instead of creating duplicates.\n { softDeletes: \"include\" },\n );\n let entity: T;\n if (entities.length > 1) {\n throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);\n } else if (entities.length === 1) {\n entity = entities[0];\n resurrectIfSoftDeleted(entity);\n } else {\n entity = em.create(type, { ...where, ...(ifNew as object) } as OptsOf<T>);\n }\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n },\n // Our filter tuple is a complex object, so use a stable cache key to ensure caching works.\n { cacheKeyFn: whereFilterHash as any },\n );\n}\n\n/** A simple in-memory match of `entity` against a mini/flat \"WHERE clause\" of `opts`. */\nexport function entityMatches<T extends Entity>(entity: T, opts: Partial<OptsOf<T>>): boolean {\n const meta = getMetadata(entity);\n return Object.entries(opts).every(([fieldName, value]) => {\n const field = meta.allFields[fieldName] ?? fail(`Invalid field ${fieldName}`);\n const fn = fieldName as keyof T & keyof OptsOf<T>;\n switch (field.kind) {\n case \"primaryKey\":\n case \"enum\":\n return entity[fn] === value;\n case \"primitive\":\n if (meta.columns[fieldName]?.isArray) {\n const current = entity[fn];\n return Array.isArray(current) && Array.isArray(value) ? equalArrays(current, value) : current === value;\n } else if (field.citext) {\n return compareCaseInsensitive(entity[fn], value);\n } else {\n return entity[fn] === value;\n }\n case \"m2o\":\n case \"poly\":\n const relation = entity[fn] as ManyToOneReference<T, any, any> | PolymorphicReference<T, any, any>;\n if (isLoadedReference(relation)) {\n // Prefer using `.get` because it will handle new/id-less entities\n return sameEntity(relation.get, value as any);\n } else if (relation.isSet) {\n // Otherwise use ids\n return sameEntity(relation.id as any, value as any);\n } else {\n // Relation is not set, match if value is null-ish (null or undefined)\n return value === undefined || value === null;\n }\n default:\n throw new Error(`Unsupported field ${fieldName}`);\n }\n });\n}\n\nfunction whereAsString(where: object): string {\n return Object.entries(where)\n .map(([key, value]) => `${key}=${value}`)\n .join(\", \");\n}\n\nfunction compareCaseInsensitive(str1: any, str2: any): boolean {\n return (\n str1 !== undefined &&\n str2 !== undefined &&\n typeof str1 === \"string\" &&\n typeof str2 === \"string\" &&\n str1.toLowerCase() === str2.toLowerCase()\n );\n}\n\n/** Returns a copy of `opts` with any `citext` values turned to lower case. */\nfunction maybeLower<T extends object | undefined>(meta: EntityMetadata, opts: T): T {\n if (!opts) return opts;\n let result: T | undefined = undefined;\n for (const k in opts) {\n const v = (opts as any)[k];\n const field = meta.allFields[k];\n const isString = field && field.kind === \"primitive\" && field.type === \"string\";\n if (isString && field.citext) {\n const lowered = v?.toLowerCase();\n if (lowered !== v) {\n result ??= { ...opts };\n (result as any)[k] = lowered as any;\n }\n }\n }\n return result ?? opts;\n}\n\n/** Returns a copy of `opts` with any string values trimmed/coalesced. */\nfunction maybeClean<T extends object | undefined>(meta: EntityMetadata, opts: T): T {\n if (!opts) return opts;\n let result: T | undefined = undefined;\n for (const k in opts) {\n const v = (opts as any)[k];\n const field = meta.allFields[k];\n const isString = field && field.kind === \"primitive\" && field.type === \"string\";\n if (isString && field.sanitize !== false) {\n const cleaned = cleanStringValue(v);\n if (cleaned !== v) {\n result ??= { ...opts }; // Only create copy on first change\n (result as any)[k] = cleaned;\n }\n }\n }\n return result ?? opts;\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,uBACd,IACA,MACA,OACA,aACmC;CACnC,MAAM,OAAOA,uBAAAA,YAAY,IAAI;CAG7B,MAAM,gBAAgB,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM,MAAM,EAAE,SAAS,eAAe,EAAE,SAAS,QAAQ;CAC7G,MAAM,eAAe,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM,MAAM,EAAE,SAAS,eAAe,EAAE,MAAM;CAGjG,QAAQ,gBAAgB,WAAW,MAAM,KAAK,IAAI;CAElD,MAAM,aAAaC,mCAAAA,gBAEjB,eAAe,WAAW,MAAM,KAAK,IAAK,KAC5C;CACA,MAAM,WAAW,GAAG,KAAK,KAAK,GAAG,WAAW,GAAG;CAE/C,MAAM,cAAc,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAQ;EACrD,MAAM,QAAQ,KAAK,UAAU,QAAQC,cAAAA,KAAK,iBAAiB,KAAK;EAGhE,OAAO,EADL,MAAM,SAAS,eAAe,MAAM,SAAS,UAAU,MAAM,SAAS,SAAS,MAAM,SAAS;CAElG,CAAC;CACD,IAAI,YAAY,SAAS,GACvB,MAAM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,KAAa;EACxB,MAAM,QAAQ,KAAK,UAAU;EAE7B,IADiB,SAAS,MAAM,SAAS,eAAe,MAAM,SAAS,YACvD,MAAM,QAAQ;GAC5B,MAAM,UAAU,GAAG,YAAY;GAC/B,IAAI,YAAY,GAAG;IACjB,WAAW,EAAE,GAAG,KAAK;IACrB,OAAgB,KAAK;GACvB;EACF;CACF;CACA,OAAO,UAAU;AACnB;;AAGA,SAAS,WAAyC,MAAsB,MAAY;CAClF,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,SAAwB,KAAA;CAC5B,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,IAAK,KAAa;EACxB,MAAM,QAAQ,KAAK,UAAU;EAE7B,IADiB,SAAS,MAAM,SAAS,eAAe,MAAM,SAAS,YACvD,MAAM,aAAa,OAAO;GACxC,MAAM,UAAUC,cAAAA,iBAAiB,CAAC;GAClC,IAAI,YAAY,GAAG;IACjB,WAAW,EAAE,GAAG,KAAK;IACrB,OAAgB,KAAK;GACvB;EACF;CACF;CACA,OAAO,UAAU;AACnB"}
|
|
@@ -7,9 +7,9 @@ interface FindOrCreateKey<T extends Entity> {
|
|
|
7
7
|
ifNew: OptsOf<T>;
|
|
8
8
|
upsert: Partial<OptsOf<T>> | undefined;
|
|
9
9
|
}
|
|
10
|
-
declare function findOrCreateDataLoader<T extends Entity>(em: EntityManager, type: EntityConstructor<T>, where: Partial<OptsOf<T>>, softDeletes: "include" | "exclude"): DataLoader<FindOrCreateKey<T>, T>;
|
|
10
|
+
export declare function findOrCreateDataLoader<T extends Entity>(em: EntityManager, type: EntityConstructor<T>, where: Partial<OptsOf<T>>, softDeletes: "include" | "exclude"): DataLoader<FindOrCreateKey<T>, T>;
|
|
11
11
|
/** A simple in-memory match of `entity` against a mini/flat "WHERE clause" of `opts`. */
|
|
12
|
-
declare function entityMatches<T extends Entity>(entity: T, opts: Partial<OptsOf<T>>): boolean;
|
|
12
|
+
export declare function entityMatches<T extends Entity>(entity: T, opts: Partial<OptsOf<T>>): boolean;
|
|
13
13
|
//#endregion
|
|
14
|
-
export {
|
|
14
|
+
export {};
|
|
15
15
|
//# sourceMappingURL=findOrCreateDataLoader.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOrCreateDataLoader.d.cts","names":[],"sources":["../../src/dataloaders/findOrCreateDataLoader.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"findOrCreateDataLoader.d.cts","names":[],"sources":["../../src/dataloaders/findOrCreateDataLoader.ts"],"mappings":";;;;;UAWU,gBAAgB,UAAU;EAClC,OAAO,OAAO;EACd,QAAQ,QAAQ,OAAO;;wBAGT,uBAAuB,UAAU,QAC/C,IAAI,eACJ,MAAM,kBAAkB,IACxB,OAAO,QAAQ,OAAO,KACtB,qCACC,WAAW,gBAAgB,IAAI;;wBAgGlB,cAAc,UAAU,QAAQ,QAAQ,GAAG,MAAM,QAAQ,OAAO"}
|
|
@@ -7,9 +7,9 @@ interface FindOrCreateKey<T extends Entity> {
|
|
|
7
7
|
ifNew: OptsOf<T>;
|
|
8
8
|
upsert: Partial<OptsOf<T>> | undefined;
|
|
9
9
|
}
|
|
10
|
-
declare function findOrCreateDataLoader<T extends Entity>(em: EntityManager, type: EntityConstructor<T>, where: Partial<OptsOf<T>>, softDeletes: "include" | "exclude"): DataLoader<FindOrCreateKey<T>, T>;
|
|
10
|
+
export declare function findOrCreateDataLoader<T extends Entity>(em: EntityManager, type: EntityConstructor<T>, where: Partial<OptsOf<T>>, softDeletes: "include" | "exclude"): DataLoader<FindOrCreateKey<T>, T>;
|
|
11
11
|
/** A simple in-memory match of `entity` against a mini/flat "WHERE clause" of `opts`. */
|
|
12
|
-
declare function entityMatches<T extends Entity>(entity: T, opts: Partial<OptsOf<T>>): boolean;
|
|
12
|
+
export declare function entityMatches<T extends Entity>(entity: T, opts: Partial<OptsOf<T>>): boolean;
|
|
13
13
|
//#endregion
|
|
14
|
-
export {
|
|
14
|
+
export {};
|
|
15
15
|
//# sourceMappingURL=findOrCreateDataLoader.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOrCreateDataLoader.d.mts","names":[],"sources":["../../src/dataloaders/findOrCreateDataLoader.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"findOrCreateDataLoader.d.mts","names":[],"sources":["../../src/dataloaders/findOrCreateDataLoader.ts"],"mappings":";;;;;UAWU,gBAAgB,UAAU;EAClC,OAAO,OAAO;EACd,QAAQ,QAAQ,OAAO;;wBAGT,uBAAuB,UAAU,QAC/C,IAAI,eACJ,MAAM,kBAAkB,IACxB,OAAO,QAAQ,OAAO,KACtB,qCACC,WAAW,gBAAgB,IAAI;;wBAgGlB,cAAc,UAAU,QAAQ,QAAQ,GAAG,MAAM,QAAQ,OAAO"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { isLoadedReference } from "../relations/Reference.js";
|
|
2
2
|
import "../relations/index.js";
|
|
3
3
|
import { cleanStringValue, fail } from "../utils.js";
|
|
4
|
+
import { equalArrays } from "../fields.js";
|
|
4
5
|
import { getMetadata } from "../EntityMetadata.js";
|
|
5
6
|
import { whereFilterHash } from "./findDataLoader.js";
|
|
6
|
-
import { resurrectIfSoftDeleted } from "../resurrection.js";
|
|
7
|
+
import { newWhereEqual, resurrectIfSoftDeleted } from "../resurrection.js";
|
|
7
8
|
import { TooManyError, sameEntity } from "../EntityManager.js";
|
|
8
9
|
import { isEntity } from "../Entity.js";
|
|
9
10
|
//#region src/dataloaders/findOrCreateDataLoader.ts
|
|
@@ -37,7 +38,7 @@ function findOrCreateDataLoader(em, type, where, softDeletes) {
|
|
|
37
38
|
if (upsert) entity.set(upsert);
|
|
38
39
|
return keys.map(() => entity);
|
|
39
40
|
}
|
|
40
|
-
const entities = await em.find(type,
|
|
41
|
+
const entities = await em.find(type, newWhereEqual(meta, where), { softDeletes: "include" });
|
|
41
42
|
let entity;
|
|
42
43
|
if (entities.length > 1) throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);
|
|
43
44
|
else if (entities.length === 1) {
|
|
@@ -60,7 +61,10 @@ function entityMatches(entity, opts) {
|
|
|
60
61
|
switch (field.kind) {
|
|
61
62
|
case "primaryKey":
|
|
62
63
|
case "enum": return entity[fn] === value;
|
|
63
|
-
case "primitive": if (
|
|
64
|
+
case "primitive": if (meta.columns[fieldName]?.isArray) {
|
|
65
|
+
const current = entity[fn];
|
|
66
|
+
return Array.isArray(current) && Array.isArray(value) ? equalArrays(current, value) : current === value;
|
|
67
|
+
} else if (field.citext) return compareCaseInsensitive(entity[fn], value);
|
|
64
68
|
else return entity[fn] === value;
|
|
65
69
|
case "m2o":
|
|
66
70
|
case "poly":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOrCreateDataLoader.js","names":[],"sources":["../../src/dataloaders/findOrCreateDataLoader.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport { whereFilterHash } from \"src/dataloaders/findDataLoader.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type EntityManager, TooManyError, sameEntity } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getMetadata } from \"src/EntityMetadata.ts\";\nimport { type ManyToOneReference, type PolymorphicReference, isLoadedReference } from \"src/relations/index.ts\";\nimport { resurrectIfSoftDeleted } from \"src/resurrection.ts\";\nimport type { OptsOf } from \"src/typeMap.ts\";\nimport { cleanStringValue, fail } from \"src/utils.ts\";\n\ninterface FindOrCreateKey<T extends Entity> {\n ifNew: OptsOf<T>;\n upsert: Partial<OptsOf<T>> | undefined;\n}\n\nexport function findOrCreateDataLoader<T extends Entity>(\n em: EntityManager,\n type: EntityConstructor<T>,\n where: Partial<OptsOf<T>>,\n softDeletes: \"include\" | \"exclude\",\n): DataLoader<FindOrCreateKey<T>, T> {\n const meta = getMetadata(type);\n\n // Do some extra logic to make unclean strings/citext not create duplicate entities\n const hasAnyStrings = Object.values(meta.allFields).some((f) => f.kind === \"primitive\" && f.type === \"string\");\n const hasAnyCitext = Object.values(meta.allFields).some((f) => f.kind === \"primitive\" && f.citext);\n\n // The `where` here will be later used to `em.create`, so we only clean (not lower for citext)\n where = hasAnyStrings ? maybeClean(meta, where) : where;\n // Use `whereFilterHash` to batch the same `findOrCreate` `where: { firstName: \"a1\" }` calls together to avoid duplicates\n const whereValue = whereFilterHash(\n // Only maybeLower for the purposes of batching, not the later em.create\n hasAnyCitext ? maybeLower(meta, where) : (where as any),\n );\n const batchKey = `${type.name}-${whereValue}-${softDeletes}`;\n\n const invalidKeys = Object.keys(where).filter((key) => {\n const field = meta.allFields[key] ?? fail(`Invalid field ${key}`);\n const supported =\n field.kind === \"primitive\" || field.kind === \"enum\" || field.kind === \"m2o\" || field.kind === \"poly\";\n return !supported;\n });\n if (invalidKeys.length > 0) {\n throw new Error(\n \"findOrCreate only supports primitive, enum, m2o, or poly fields in the where clause. Invalid keys: \" +\n invalidKeys.join(\", \"),\n );\n }\n\n return em.getLoader<FindOrCreateKey<T>, T>(\n \"find-or-create\",\n batchKey,\n async (keys) => {\n // Because our `batchKey` is based only on the `where` clause, if the user called\n // `findOrCreate({ firstName: a1 })` multiple times, but with different ifNew/upsert\n // conditions (or different cased strings and is using a citext column), we'll end\n // up with multiple keys...\n //\n // This is fundamentally asking to create the same entity, but with different ifNew/upsert\n // conditions, which we could fail on, but for now just take the first tuple of\n // {where/ifNew/upsert} and assume it wins\n const [{ ifNew, upsert }] = keys;\n\n // Before we find/create an entity, see if we have a maybe-new one in the EM already.\n // This will also use any WIP changes we've made to the found entity, which ideally is\n // something `em.find` would do as well, but its queries are much more complex...\n const inMemory = em.filterEntities(type, where);\n if (inMemory.length > 1) {\n throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);\n } else if (inMemory.length === 1) {\n const entity = inMemory[0] as T;\n resurrectIfSoftDeleted(entity);\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n }\n\n // If there is a param like `{ publisher: newPublisherEntity }`, then we know that\n // an entity matching this condition can't be in the db anyway, so skip the em.find\n const hasNewEntityParam = Object.values(where).some((v) => isEntity(v) && v.isNewEntity);\n if (hasNewEntityParam) {\n const entity = em.create(type, { ...where, ...(ifNew as object) } as OptsOf<T>);\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n }\n\n // If we didn't find it in the EM, do the db query/em.create\n const entities = await em.find(\n type,\n // Convert `publisher: undefined` --> `publisher: null`, and we need to make a copy anyway\n Object.fromEntries(Object.entries(where).map(([k, v]) => [k, v === undefined ? null : v])) as any,\n // Always include soft-deleted rows so findOrCreate can resurrect them instead of creating duplicates.\n { softDeletes: \"include\" },\n );\n let entity: T;\n if (entities.length > 1) {\n throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);\n } else if (entities.length === 1) {\n entity = entities[0];\n resurrectIfSoftDeleted(entity);\n } else {\n entity = em.create(type, { ...where, ...(ifNew as object) } as OptsOf<T>);\n }\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n },\n // Our filter tuple is a complex object, so use a stable cache key to ensure caching works.\n { cacheKeyFn: whereFilterHash as any },\n );\n}\n\n/** A simple in-memory match of `entity` against a mini/flat \"WHERE clause\" of `opts`. */\nexport function entityMatches<T extends Entity>(entity: T, opts: Partial<OptsOf<T>>): boolean {\n const meta = getMetadata(entity);\n return Object.entries(opts).every(([fieldName, value]) => {\n const field = meta.allFields[fieldName] ?? fail(`Invalid field ${fieldName}`);\n const fn = fieldName as keyof T & keyof OptsOf<T>;\n switch (field.kind) {\n case \"primaryKey\":\n case \"enum\":\n return entity[fn] === value;\n case \"primitive\":\n if (field.citext) {\n return compareCaseInsensitive(entity[fn], value);\n } else {\n return entity[fn] === value;\n }\n case \"m2o\":\n case \"poly\":\n const relation = entity[fn] as ManyToOneReference<T, any, any> | PolymorphicReference<T, any, any>;\n if (isLoadedReference(relation)) {\n // Prefer using `.get` because it will handle new/id-less entities\n return sameEntity(relation.get, value as any);\n } else if (relation.isSet) {\n // Otherwise use ids\n return sameEntity(relation.id as any, value as any);\n } else {\n // Relation is not set, match if value is null-ish (null or undefined)\n return value === undefined || value === null;\n }\n default:\n throw new Error(`Unsupported field ${fieldName}`);\n }\n });\n}\n\nfunction whereAsString(where: object): string {\n return Object.entries(where)\n .map(([key, value]) => `${key}=${value}`)\n .join(\", \");\n}\n\nfunction compareCaseInsensitive(str1: any, str2: any): boolean {\n return (\n str1 !== undefined &&\n str2 !== undefined &&\n typeof str1 === \"string\" &&\n typeof str2 === \"string\" &&\n str1.toLowerCase() === str2.toLowerCase()\n );\n}\n\n/** Returns a copy of `opts` with any `citext` values turned to lower case. */\nfunction maybeLower<T extends object | undefined>(meta: EntityMetadata, opts: T): T {\n if (!opts) return opts;\n let result: T | undefined = undefined;\n for (const k in opts) {\n const v = (opts as any)[k];\n const field = meta.allFields[k];\n const isString = field && field.kind === \"primitive\" && field.type === \"string\";\n if (isString && field.citext) {\n const lowered = v?.toLowerCase();\n if (lowered !== v) {\n result ??= { ...opts };\n (result as any)[k] = lowered as any;\n }\n }\n }\n return result ?? opts;\n}\n\n/** Returns a copy of `opts` with any string values trimmed/coalesced. */\nfunction maybeClean<T extends object | undefined>(meta: EntityMetadata, opts: T): T {\n if (!opts) return opts;\n let result: T | undefined = undefined;\n for (const k in opts) {\n const v = (opts as any)[k];\n const field = meta.allFields[k];\n const isString = field && field.kind === \"primitive\" && field.type === \"string\";\n if (isString && field.sanitize !== false) {\n const cleaned = cleanStringValue(v);\n if (cleaned !== v) {\n result ??= { ...opts }; // Only create copy on first change\n (result as any)[k] = cleaned;\n }\n }\n }\n return result ?? opts;\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,uBACd,IACA,MACA,OACA,aACmC;CACnC,MAAM,OAAO,YAAY,IAAI;CAG7B,MAAM,gBAAgB,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM,MAAM,EAAE,SAAS,eAAe,EAAE,SAAS,QAAQ;CAC7G,MAAM,eAAe,O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AC,CACxC,KAAK,IAAI;AACd;AAEA,SAAS,uBAAuB,MAAW,MAAoB;CAC7D,OACE,SAAS,KAAA,KACT,SAAS,KAAA,KACT,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,KAAK,YAAY,MAAM,KAAK,YAAY;AAE5C;;AAGA,SAAS,WAAyC,MAAsB,MAAY;CAClF,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,SAAwB,KAAA;CAC5B,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,IAAK,KAAa;EACxB,MAAM,QAAQ,KAAK,UAAU;EAE7B,IADiB,SAAS,MAAM,SAAS,eAAe,MAAM,SAAS,YACvD,MAAM,QAAQ;GAC5B,MAAM,UAAU,GAAG,YAAY;GAC/B,IAAI,YAAY,GAAG;IACjB,WAAW,EAAE,GAAG,KAAK;IACrB,OAAgB,KAAK;GACvB;EACF;CACF;CACA,OAAO,UAAU;AACnB;;AAGA,SAAS,WAAyC,MAAsB,MAAY;CAClF,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,SAAwB,KAAA;CAC5B,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,IAAK,KAAa;EACxB,MAAM,QAAQ,KAAK,UAAU;EAE7B,IADiB,SAAS,MAAM,SAAS,eAAe,MAAM,SAAS,YACvD,MAAM,aAAa,OAAO;GACxC,MAAM,UAAU,iBAAiB,CAAC;GAClC,IAAI,YAAY,GAAG;IACjB,WAAW,EAAE,GAAG,KAAK;IACrB,OAAgB,KAAK;GACvB;EACF;CACF;CACA,OAAO,UAAU;AACnB"}
|
|
1
|
+
{"version":3,"file":"findOrCreateDataLoader.js","names":[],"sources":["../../src/dataloaders/findOrCreateDataLoader.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport { whereFilterHash } from \"src/dataloaders/findDataLoader.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type EntityManager, TooManyError, sameEntity } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getMetadata } from \"src/EntityMetadata.ts\";\nimport { equalArrays } from \"src/fields.ts\";\nimport { type ManyToOneReference, type PolymorphicReference, isLoadedReference } from \"src/relations/index.ts\";\nimport { newWhereEqual, resurrectIfSoftDeleted } from \"src/resurrection.ts\";\nimport type { OptsOf } from \"src/typeMap.ts\";\nimport { cleanStringValue, fail } from \"src/utils.ts\";\n\ninterface FindOrCreateKey<T extends Entity> {\n ifNew: OptsOf<T>;\n upsert: Partial<OptsOf<T>> | undefined;\n}\n\nexport function findOrCreateDataLoader<T extends Entity>(\n em: EntityManager,\n type: EntityConstructor<T>,\n where: Partial<OptsOf<T>>,\n softDeletes: \"include\" | \"exclude\",\n): DataLoader<FindOrCreateKey<T>, T> {\n const meta = getMetadata(type);\n\n // Do some extra logic to make unclean strings/citext not create duplicate entities\n const hasAnyStrings = Object.values(meta.allFields).some((f) => f.kind === \"primitive\" && f.type === \"string\");\n const hasAnyCitext = Object.values(meta.allFields).some((f) => f.kind === \"primitive\" && f.citext);\n\n // The `where` here will be later used to `em.create`, so we only clean (not lower for citext)\n where = hasAnyStrings ? maybeClean(meta, where) : where;\n // Use `whereFilterHash` to batch the same `findOrCreate` `where: { firstName: \"a1\" }` calls together to avoid duplicates\n const whereValue = whereFilterHash(\n // Only maybeLower for the purposes of batching, not the later em.create\n hasAnyCitext ? maybeLower(meta, where) : (where as any),\n );\n const batchKey = `${type.name}-${whereValue}-${softDeletes}`;\n\n const invalidKeys = Object.keys(where).filter((key) => {\n const field = meta.allFields[key] ?? fail(`Invalid field ${key}`);\n const supported =\n field.kind === \"primitive\" || field.kind === \"enum\" || field.kind === \"m2o\" || field.kind === \"poly\";\n return !supported;\n });\n if (invalidKeys.length > 0) {\n throw new Error(\n \"findOrCreate only supports primitive, enum, m2o, or poly fields in the where clause. Invalid keys: \" +\n invalidKeys.join(\", \"),\n );\n }\n\n return em.getLoader<FindOrCreateKey<T>, T>(\n \"find-or-create\",\n batchKey,\n async (keys) => {\n // Because our `batchKey` is based only on the `where` clause, if the user called\n // `findOrCreate({ firstName: a1 })` multiple times, but with different ifNew/upsert\n // conditions (or different cased strings and is using a citext column), we'll end\n // up with multiple keys...\n //\n // This is fundamentally asking to create the same entity, but with different ifNew/upsert\n // conditions, which we could fail on, but for now just take the first tuple of\n // {where/ifNew/upsert} and assume it wins\n const [{ ifNew, upsert }] = keys;\n\n // Before we find/create an entity, see if we have a maybe-new one in the EM already.\n // This will also use any WIP changes we've made to the found entity, which ideally is\n // something `em.find` would do as well, but its queries are much more complex...\n const inMemory = em.filterEntities(type, where);\n if (inMemory.length > 1) {\n throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);\n } else if (inMemory.length === 1) {\n const entity = inMemory[0] as T;\n resurrectIfSoftDeleted(entity);\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n }\n\n // If there is a param like `{ publisher: newPublisherEntity }`, then we know that\n // an entity matching this condition can't be in the db anyway, so skip the em.find\n const hasNewEntityParam = Object.values(where).some((v) => isEntity(v) && v.isNewEntity);\n if (hasNewEntityParam) {\n const entity = em.create(type, { ...where, ...(ifNew as object) } as OptsOf<T>);\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n }\n\n // If we didn't find it in the EM, do the db query/em.create\n const entities = await em.find(\n type,\n newWhereEqual(meta, where) as any,\n // Always include soft-deleted rows so findOrCreate can resurrect them instead of creating duplicates.\n { softDeletes: \"include\" },\n );\n let entity: T;\n if (entities.length > 1) {\n throw new TooManyError(`Found more than one existing ${type.name} with ${whereAsString(where)}`);\n } else if (entities.length === 1) {\n entity = entities[0];\n resurrectIfSoftDeleted(entity);\n } else {\n entity = em.create(type, { ...where, ...(ifNew as object) } as OptsOf<T>);\n }\n if (upsert) {\n entity.set(upsert);\n }\n return keys.map(() => entity);\n },\n // Our filter tuple is a complex object, so use a stable cache key to ensure caching works.\n { cacheKeyFn: whereFilterHash as any },\n );\n}\n\n/** A simple in-memory match of `entity` against a mini/flat \"WHERE clause\" of `opts`. */\nexport function entityMatches<T extends Entity>(entity: T, opts: Partial<OptsOf<T>>): boolean {\n const meta = getMetadata(entity);\n return Object.entries(opts).every(([fieldName, value]) => {\n const field = meta.allFields[fieldName] ?? fail(`Invalid field ${fieldName}`);\n const fn = fieldName as keyof T & keyof OptsOf<T>;\n switch (field.kind) {\n case \"primaryKey\":\n case \"enum\":\n return entity[fn] === value;\n case \"primitive\":\n if (meta.columns[fieldName]?.isArray) {\n const current = entity[fn];\n return Array.isArray(current) && Array.isArray(value) ? equalArrays(current, value) : current === value;\n } else if (field.citext) {\n return compareCaseInsensitive(entity[fn], value);\n } else {\n return entity[fn] === value;\n }\n case \"m2o\":\n case \"poly\":\n const relation = entity[fn] as ManyToOneReference<T, any, any> | PolymorphicReference<T, any, any>;\n if (isLoadedReference(relation)) {\n // Prefer using `.get` because it will handle new/id-less entities\n return sameEntity(relation.get, value as any);\n } else if (relation.isSet) {\n // Otherwise use ids\n return sameEntity(relation.id as any, value as any);\n } else {\n // Relation is not set, match if value is null-ish (null or undefined)\n return value === undefined || value === null;\n }\n default:\n throw new Error(`Unsupported field ${fieldName}`);\n }\n });\n}\n\nfunction whereAsString(where: object): string {\n return Object.entries(where)\n .map(([key, value]) => `${key}=${value}`)\n .join(\", \");\n}\n\nfunction compareCaseInsensitive(str1: any, str2: any): boolean {\n return (\n str1 !== undefined &&\n str2 !== undefined &&\n typeof str1 === \"string\" &&\n typeof str2 === \"string\" &&\n str1.toLowerCase() === str2.toLowerCase()\n );\n}\n\n/** Returns a copy of `opts` with any `citext` values turned to lower case. */\nfunction maybeLower<T extends object | undefined>(meta: EntityMetadata, opts: T): T {\n if (!opts) return opts;\n let result: T | undefined = undefined;\n for (const k in opts) {\n const v = (opts as any)[k];\n const field = meta.allFields[k];\n const isString = field && field.kind === \"primitive\" && field.type === \"string\";\n if (isString && field.citext) {\n const lowered = v?.toLowerCase();\n if (lowered !== v) {\n result ??= { ...opts };\n (result as any)[k] = lowered as any;\n }\n }\n }\n return result ?? opts;\n}\n\n/** Returns a copy of `opts` with any string values trimmed/coalesced. */\nfunction maybeClean<T extends object | undefined>(meta: EntityMetadata, opts: T): T {\n if (!opts) return opts;\n let result: T | undefined = undefined;\n for (const k in opts) {\n const v = (opts as any)[k];\n const field = meta.allFields[k];\n const isString = field && field.kind === \"primitive\" && field.type === \"string\";\n if (isString && field.sanitize !== false) {\n const cleaned = cleanStringValue(v);\n if (cleaned !== v) {\n result ??= { ...opts }; // Only create copy on first change\n (result as any)[k] = cleaned;\n }\n }\n }\n return result ?? opts;\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,uBACd,IACA,MACA,OACA,aACmC;CACnC,MAAM,OAAO,YAAY,IAAI;CAG7B,MAAM,gBAAgB,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM,MAAM,EAAE,SAAS,eAAe,EAAE,SAAS,QAAQ;CAC7G,MAAM,eAAe,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,MAAM,MAAM,EAAE,SAAS,eAAe,EAAE,MAAM;CAGjG,QAAQ,gBAAgB,WAAW,MAAM,KAAK,IAAI;CAElD,MAAM,aAAa,gBAEjB,eAAe,WAAW,MAAM,KAAK,IAAK,KAC5C;CACA,MAAM,WAAW,GAAG,KAAK,KAAK,GAAG,WAAW,GAAG;CAE/C,MAAM,cAAc,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAQ;EACrD,MAAM,QAAQ,KAAK,UAAU,QAAQ,KAAK,iBAAiB,KAAK;EAGhE,OAAO,EADL,MAAM,SAAS,eAAe,MAAM,SAAS,UAAU,MAAM,SAAS,SAAS,MAAM,SAAS;CAElG,CAAC;CACD,IAAI,YAAY,SAAS,GACvB,MAAM,IAAI,MACR,wGACE,YAAY,KAAK,IAAI,CACzB;CAGF,OAAO,GAAG,UACR,kBACA,UACA,OAAO,SAAS;EASd,MAAM,CAAC,EAAE,OAAO,YAAY;EAK5B,MAAM,WAAW,GAAG,eAAe,MAAM,KAAK;EAC9C,IAAI,S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,CAAC,MAAM,OAAO;CAClB,IAAI,SAAwB,KAAA;CAC5B,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,IAAK,KAAa;EACxB,MAAM,QAAQ,KAAK,UAAU;EAE7B,IADiB,SAAS,MAAM,SAAS,eAAe,MAAM,SAAS,YACvD,MAAM,aAAa,OAAO;GACxC,MAAM,UAAU,iBAAiB,CAAC;GAClC,IAAI,YAAY,GAAG;IACjB,WAAW,EAAE,GAAG,KAAK;IACrB,OAAgB,KAAK;GACvB;EACF;CACF;CACA,OAAO,UAAU;AACnB"}
|
|
@@ -41,9 +41,8 @@ function findPaginatedDataLoader(em, type, filter, hint) {
|
|
|
41
41
|
const { query, findSettings } = entries[0];
|
|
42
42
|
const { preloader } = require_EntityManager.getEmInternalApi(em);
|
|
43
43
|
const preloadHydrator = preloader && hint && preloader.addPreloading(meta, require_loading_HintTree.buildHintTree(hint), query);
|
|
44
|
-
const
|
|
45
|
-
const entities = em
|
|
46
|
-
preloadHydrator?.(rows, entities);
|
|
44
|
+
const rowData = await em["executePreparedFindRowData"](meta, require_dataloaders_findDataLoader.findOperation, query, findSettings, false);
|
|
45
|
+
const entities = em["hydrateAndFinalize"](type, rowData, { sidecars: (entities) => preloadHydrator?.(rowData, entities) });
|
|
47
46
|
return [require_dataloaders_findDataLoader.filterDeletedEntities(em, entities)];
|
|
48
47
|
}
|
|
49
48
|
const { query, findSettings, limit, offset } = entries[0];
|
|
@@ -75,20 +74,19 @@ function findPaginatedDataLoader(em, type, filter, hint) {
|
|
|
75
74
|
ctes: [require_queries_unnest.buildUnnestCte("_find", argsColumns, columnValues)],
|
|
76
75
|
orderBys: []
|
|
77
76
|
};
|
|
78
|
-
const
|
|
77
|
+
const rowData = await em["executePreparedFindRowData"](meta, require_dataloaders_findDataLoader.findOperation, query2, {
|
|
79
78
|
...findSettings,
|
|
80
79
|
limit: void 0,
|
|
81
80
|
offset: void 0
|
|
82
81
|
}, false);
|
|
83
|
-
const entities = em.hydrate(type, rows);
|
|
84
|
-
preloadHydrator?.(rows, entities);
|
|
85
82
|
const results = entries.map(() => []);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
em["hydrateAndFinalize"](type, rowData, { sidecars: (entities) => {
|
|
84
|
+
preloadHydrator?.(rowData, entities);
|
|
85
|
+
for (let i = 0; i < entities.length; i++) {
|
|
86
|
+
const entity = entities[i];
|
|
87
|
+
if (!entity.isDeletedEntity) results[rowData.get(i, "tag")].push(entity);
|
|
88
|
+
}
|
|
89
|
+
} });
|
|
92
90
|
return results;
|
|
93
91
|
}, { cacheKeyFn: require_dataloaders_findDataLoader.queryFilterHash }).load(prepared);
|
|
94
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPaginatedDataLoader.cjs","names":["getMetadata","parseFindQuery","findOperation","isQueryProvablyEmpty","getBatchKeyFromGenericStructure","hintKey","getEmInternalApi","buildHintTree","filterDeletedEntities","collectAndReplaceArgs","createColumnValuesFromPrepared","buildUnnestCte","queryFilterHash"],"sources":["../../src/dataloaders/findPaginatedDataLoader.ts"],"sourcesContent":["import {\n collectAndReplaceArgs,\n collectValues,\n createColumnValuesFromPrepared,\n filterDeletedEntities,\n findOperation,\n getBatchKeyFromGenericStructure,\n queryFilterHash,\n} from \"src/dataloaders/findDataLoader.ts\";\nimport type { Entity } from \"src/Entity.ts\";\nimport { type EntityManager, type MaybeAbstractEntityConstructor, getEmInternalApi } from \"src/EntityManager.ts\";\nimport { getMetadata } from \"src/EntityMetadata.ts\";\nimport { buildHintTree } from \"src/loading/HintTree.ts\";\nimport type { LoadHint } from \"src/loading/loadHints.ts\";\nimport { hintKey } from \"src/normalizeHints.ts\";\nimport type { FilterAndSettings } from \"src/queries/find/EntityFilter.ts\";\nimport { type ParsedFindQuery, parseFindQuery } from \"src/queries/find/QueryParser.ts\";\nimport { isQueryProvablyEmpty } from \"src/queries/find/QueryVisitor.ts\";\nimport { buildUnnestCte } from \"src/queries/unnest.ts\";\n\ninterface PreparedPaginatedFindEntry<T extends Entity> {\n filter: FilterAndSettings<T>;\n query: ParsedFindQuery;\n bindings: any[];\n findSettings: any;\n limit: number | undefined;\n offset: number | undefined;\n}\n\n/** Returns a dataloader that batches paginated finds by applying pagination inside each lateral subquery. */\nexport function findPaginatedDataLoader<T extends Entity>(\n em: EntityManager,\n type: MaybeAbstractEntityConstructor<T>,\n filter: FilterAndSettings<T>,\n hint: LoadHint<T> | undefined,\n): Promise<T[]> {\n const { where, limit, offset, ...opts } = filter;\n const meta = getMetadata(type);\n const query = parseFindQuery(meta, where, opts);\n const { findSettings } = em[\"prepareFind\"](meta, findOperation, query, { ...opts, limit, offset, checkLimit: false });\n if (isQueryProvablyEmpty(query)) return Promise.resolve([]);\n\n const bindings: any[] = [];\n collectValues(bindings, query);\n const prepared = {\n filter,\n query,\n bindings,\n findSettings,\n limit: findSettings.limit,\n offset: findSettings.offset,\n };\n const batchKey = [\n getBatchKeyFromGenericStructure(meta, query),\n hintKey(hint),\n findSettings.limit,\n findSettings.offset,\n ].join(\"-\");\n\n return em\n .getLoader<PreparedPaginatedFindEntry<T>, T[]>(\n findOperation,\n batchKey,\n async (entries) => {\n if (entries.length === 1) {\n // Skip batching & just execute the query as-is\n const { query, findSettings } = entries[0];\n const { preloader } = getEmInternalApi(em);\n const preloadHydrator = preloader && hint && preloader.addPreloading(meta, buildHintTree(hint), query);\n const
|
|
1
|
+
{"version":3,"file":"findPaginatedDataLoader.cjs","names":["getMetadata","parseFindQuery","findOperation","isQueryProvablyEmpty","getBatchKeyFromGenericStructure","hintKey","getEmInternalApi","buildHintTree","filterDeletedEntities","collectAndReplaceArgs","createColumnValuesFromPrepared","buildUnnestCte","queryFilterHash"],"sources":["../../src/dataloaders/findPaginatedDataLoader.ts"],"sourcesContent":["import {\n collectAndReplaceArgs,\n collectValues,\n createColumnValuesFromPrepared,\n filterDeletedEntities,\n findOperation,\n getBatchKeyFromGenericStructure,\n queryFilterHash,\n} from \"src/dataloaders/findDataLoader.ts\";\nimport type { Entity } from \"src/Entity.ts\";\nimport { type EntityManager, type MaybeAbstractEntityConstructor, getEmInternalApi } from \"src/EntityManager.ts\";\nimport { getMetadata } from \"src/EntityMetadata.ts\";\nimport { buildHintTree } from \"src/loading/HintTree.ts\";\nimport type { LoadHint } from \"src/loading/loadHints.ts\";\nimport { hintKey } from \"src/normalizeHints.ts\";\nimport type { FilterAndSettings } from \"src/queries/find/EntityFilter.ts\";\nimport { type ParsedFindQuery, parseFindQuery } from \"src/queries/find/QueryParser.ts\";\nimport { isQueryProvablyEmpty } from \"src/queries/find/QueryVisitor.ts\";\nimport { buildUnnestCte } from \"src/queries/unnest.ts\";\n\ninterface PreparedPaginatedFindEntry<T extends Entity> {\n filter: FilterAndSettings<T>;\n query: ParsedFindQuery;\n bindings: any[];\n findSettings: any;\n limit: number | undefined;\n offset: number | undefined;\n}\n\n/** Returns a dataloader that batches paginated finds by applying pagination inside each lateral subquery. */\nexport function findPaginatedDataLoader<T extends Entity>(\n em: EntityManager,\n type: MaybeAbstractEntityConstructor<T>,\n filter: FilterAndSettings<T>,\n hint: LoadHint<T> | undefined,\n): Promise<T[]> {\n const { where, limit, offset, ...opts } = filter;\n const meta = getMetadata(type);\n const query = parseFindQuery(meta, where, opts);\n const { findSettings } = em[\"prepareFind\"](meta, findOperation, query, { ...opts, limit, offset, checkLimit: false });\n if (isQueryProvablyEmpty(query)) return Promise.resolve([]);\n\n const bindings: any[] = [];\n collectValues(bindings, query);\n const prepared = {\n filter,\n query,\n bindings,\n findSettings,\n limit: findSettings.limit,\n offset: findSettings.offset,\n };\n const batchKey = [\n getBatchKeyFromGenericStructure(meta, query),\n hintKey(hint),\n findSettings.limit,\n findSettings.offset,\n ].join(\"-\");\n\n return em\n .getLoader<PreparedPaginatedFindEntry<T>, T[]>(\n findOperation,\n batchKey,\n async (entries) => {\n if (entries.length === 1) {\n // Skip batching & just execute the query as-is\n const { query, findSettings } = entries[0];\n const { preloader } = getEmInternalApi(em);\n const preloadHydrator = preloader && hint && preloader.addPreloading(meta, buildHintTree(hint), query);\n const rowData = await em[\"executePreparedFindRowData\"](meta, findOperation, query, findSettings, false);\n const entities = em[\"hydrateAndFinalize\"](type, rowData, {\n sidecars: (entities) => preloadHydrator?.(rowData, entities),\n });\n return [filterDeletedEntities(em, entities)];\n }\n\n const { query, findSettings, limit, offset } = entries[0];\n const { preloader } = getEmInternalApi(em);\n const preloadHydrator = preloader && hint && preloader.addPreloading(meta, buildHintTree(hint), query);\n\n // Now craft the actual batched query\n const args = collectAndReplaceArgs(query, entries);\n const argsColumns = [{ columnName: \"tag\", dbType: \"int\" }, ...args.map((a) => a.column)];\n const columnValues = createColumnValuesFromPrepared(args, entries);\n const query2: ParsedFindQuery = {\n selects: [\"_find.tag as tag\", \"_data.*\"],\n tables: [\n { join: \"primary\", table: \"_find\", alias: \"_find\" },\n {\n join: \"lateral\",\n query,\n table: meta.tableName,\n alias: \"_data\",\n fromAlias: \"_find\",\n settings: { limit, offset },\n },\n ],\n ctes: [buildUnnestCte(\"_find\", argsColumns, columnValues)],\n orderBys: [],\n };\n\n const rowData = await em[\"executePreparedFindRowData\"](\n meta,\n findOperation,\n query2,\n { ...findSettings, limit: undefined, offset: undefined },\n false,\n );\n const results = entries.map(() => [] as T[]);\n em[\"hydrateAndFinalize\"](type, rowData, {\n sidecars: (entities) => {\n preloadHydrator?.(rowData, entities);\n // Read tags before compaction drops rows already present in the identity map.\n for (let i = 0; i < entities.length; i++) {\n const entity = entities[i];\n if (!entity.isDeletedEntity) {\n results[rowData.get(i, \"tag\")].push(entity);\n }\n }\n },\n });\n return results;\n },\n { cacheKeyFn: queryFilterHash },\n )\n .load(prepared);\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAgB,wBACd,IACA,MACA,QACA,MACc;CACd,MAAM,EAAE,OAAO,OAAO,QAAQ,GAAG,SAAS;CAC1C,MAAM,OAAOA,uBAAAA,YAAY,IAAI;CAC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AA,sBAAsB,OAAO,OAAO;EACjD,MAAM,cAAc,CAAC;GAAE,YAAY;GAAO,QAAQ;EAAM,GAAG,GAAG,KAAK,KAAK,MAAM,EAAE,MAAM,CAAC;EACvF,MAAM,eAAeC,mCAAAA,+BAA+B,MAAM,OAAO;EACjE,MAAM,SAA0B;GAC9B,SAAS,CAAC,oBAAoB,SAAS;GACvC,QAAQ,CACN;IAAE,MAAM;IAAW,OAAO;IAAS,OAAO;GAAQ,GAClD;IACE,MAAM;IACN;IACA,OAAO,KAAK;IACZ,OAAO;IACP,WAAW;IACX,UAAU;KAAE;KAAO;IAAO;GAC5B,CACF;GACA,MAAM,CAACC,uBAAAA,eAAe,SAAS,aAAa,YAAY,CAAC;GACzD,UAAU,CAAC;EACb;EAEA,MAAM,UAAU,MAAM,GAAG,6BAA6B,CACpD,MACAT,mCAAAA,eACA,QACA;GAAE,GAAG;GAAc,OAAO,KAAA;GAAW,QAAQ,KAAA;EAAU,GACvD,KACF;EACA,MAAM,UAAU,QAAQ,UAAU,CAAC,CAAQ;EAC3C,GAAG,qBAAqB,CAAC,MAAM,SAAS,EACtC,WAAW,aAAa;GACtB,kBAAkB,SAAS,QAAQ;GAEnC,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;IACxC,MAAM,SAAS,SAAS;IACxB,IAAI,CAAC,OAAO,iBACV,QAAQ,QAAQ,IAAI,GAAG,KAAK,EAAE,CAAC,KAAK,MAAM;GAE9C;EACF,EACF,CAAC;EACD,OAAO;CACT,GACA,EAAE,YAAYU,mCAAAA,gBAAgB,CAChC,CAAC,CACA,KAAK,QAAQ;AAClB"}
|
|
@@ -4,7 +4,6 @@ import { EntityManager, MaybeAbstractEntityConstructor } from "../EntityManager.
|
|
|
4
4
|
import { Entity } from "../Entity.cjs";
|
|
5
5
|
//#region src/dataloaders/findPaginatedDataLoader.d.ts
|
|
6
6
|
/** Returns a dataloader that batches paginated finds by applying pagination inside each lateral subquery. */
|
|
7
|
-
declare function findPaginatedDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>, hint: LoadHint<T> | undefined): Promise<T[]>;
|
|
7
|
+
export declare function findPaginatedDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>, hint: LoadHint<T> | undefined): Promise<T[]>;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { findPaginatedDataLoader };
|
|
10
9
|
//# sourceMappingURL=findPaginatedDataLoader.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPaginatedDataLoader.d.cts","names":[],"sources":["../../src/dataloaders/findPaginatedDataLoader.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"findPaginatedDataLoader.d.cts","names":[],"sources":["../../src/dataloaders/findPaginatedDataLoader.ts"],"mappings":";;;;;;wBA8BgB,wBAAwB,UAAU,QAChD,IAAI,eACJ,MAAM,+BAA+B,IACrC,QAAQ,kBAAkB,IAC1B,MAAM,SAAS,iBACd,QAAQ"}
|
|
@@ -4,7 +4,6 @@ import { EntityManager, MaybeAbstractEntityConstructor } from "../EntityManager.
|
|
|
4
4
|
import { Entity } from "../Entity.mjs";
|
|
5
5
|
//#region src/dataloaders/findPaginatedDataLoader.d.ts
|
|
6
6
|
/** Returns a dataloader that batches paginated finds by applying pagination inside each lateral subquery. */
|
|
7
|
-
declare function findPaginatedDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>, hint: LoadHint<T> | undefined): Promise<T[]>;
|
|
7
|
+
export declare function findPaginatedDataLoader<T extends Entity>(em: EntityManager, type: MaybeAbstractEntityConstructor<T>, filter: FilterAndSettings<T>, hint: LoadHint<T> | undefined): Promise<T[]>;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { findPaginatedDataLoader };
|
|
10
9
|
//# sourceMappingURL=findPaginatedDataLoader.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPaginatedDataLoader.d.mts","names":[],"sources":["../../src/dataloaders/findPaginatedDataLoader.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"findPaginatedDataLoader.d.mts","names":[],"sources":["../../src/dataloaders/findPaginatedDataLoader.ts"],"mappings":";;;;;;wBA8BgB,wBAAwB,UAAU,QAChD,IAAI,eACJ,MAAM,+BAA+B,IACrC,QAAQ,kBAAkB,IAC1B,MAAM,SAAS,iBACd,QAAQ"}
|
|
@@ -40,9 +40,8 @@ function findPaginatedDataLoader(em, type, filter, hint) {
|
|
|
40
40
|
const { query, findSettings } = entries[0];
|
|
41
41
|
const { preloader } = getEmInternalApi(em);
|
|
42
42
|
const preloadHydrator = preloader && hint && preloader.addPreloading(meta, buildHintTree(hint), query);
|
|
43
|
-
const
|
|
44
|
-
const entities = em
|
|
45
|
-
preloadHydrator?.(rows, entities);
|
|
43
|
+
const rowData = await em["executePreparedFindRowData"](meta, findOperation, query, findSettings, false);
|
|
44
|
+
const entities = em["hydrateAndFinalize"](type, rowData, { sidecars: (entities) => preloadHydrator?.(rowData, entities) });
|
|
46
45
|
return [filterDeletedEntities(em, entities)];
|
|
47
46
|
}
|
|
48
47
|
const { query, findSettings, limit, offset } = entries[0];
|
|
@@ -74,20 +73,19 @@ function findPaginatedDataLoader(em, type, filter, hint) {
|
|
|
74
73
|
ctes: [buildUnnestCte("_find", argsColumns, columnValues)],
|
|
75
74
|
orderBys: []
|
|
76
75
|
};
|
|
77
|
-
const
|
|
76
|
+
const rowData = await em["executePreparedFindRowData"](meta, findOperation, query2, {
|
|
78
77
|
...findSettings,
|
|
79
78
|
limit: void 0,
|
|
80
79
|
offset: void 0
|
|
81
80
|
}, false);
|
|
82
|
-
const entities = em.hydrate(type, rows);
|
|
83
|
-
preloadHydrator?.(rows, entities);
|
|
84
81
|
const results = entries.map(() => []);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
em["hydrateAndFinalize"](type, rowData, { sidecars: (entities) => {
|
|
83
|
+
preloadHydrator?.(rowData, entities);
|
|
84
|
+
for (let i = 0; i < entities.length; i++) {
|
|
85
|
+
const entity = entities[i];
|
|
86
|
+
if (!entity.isDeletedEntity) results[rowData.get(i, "tag")].push(entity);
|
|
87
|
+
}
|
|
88
|
+
} });
|
|
91
89
|
return results;
|
|
92
90
|
}, { cacheKeyFn: queryFilterHash }).load(prepared);
|
|
93
91
|
}
|