joist-core 2.5.0-next.2 → 2.5.0-next.21
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.cjs +33 -3
- package/build/BaseEntity.cjs.map +1 -1
- package/build/BaseEntity.d.cts +6 -4
- package/build/BaseEntity.d.cts.map +1 -1
- package/build/BaseEntity.d.mts +6 -4
- package/build/BaseEntity.d.mts.map +1 -1
- package/build/BaseEntity.js +33 -4
- package/build/BaseEntity.js.map +1 -1
- package/build/Entity.cjs +2 -3
- package/build/Entity.d.cts +0 -2
- package/build/Entity.d.cts.map +1 -1
- package/build/Entity.d.mts +0 -2
- package/build/Entity.d.mts.map +1 -1
- package/build/Entity.js +2 -3
- package/build/EntityFields.d.cts +0 -2
- package/build/EntityFields.d.cts.map +1 -1
- package/build/EntityFields.d.mts +0 -2
- package/build/EntityFields.d.mts.map +1 -1
- package/build/EntityManager.cjs +185 -103
- package/build/EntityManager.cjs.map +1 -1
- package/build/EntityManager.d.cts +50 -37
- package/build/EntityManager.d.cts.map +1 -1
- package/build/EntityManager.d.mts +50 -37
- package/build/EntityManager.d.mts.map +1 -1
- package/build/EntityManager.js +185 -104
- package/build/EntityManager.js.map +1 -1
- package/build/EntityMetadata.cjs +3 -4
- package/build/EntityMetadata.cjs.map +1 -1
- package/build/EntityMetadata.d.cts +8 -6
- package/build/EntityMetadata.d.cts.map +1 -1
- package/build/EntityMetadata.d.mts +8 -6
- package/build/EntityMetadata.d.mts.map +1 -1
- package/build/EntityMetadata.js +3 -4
- package/build/EntityMetadata.js.map +1 -1
- package/build/EnumMetadata.d.cts +0 -2
- package/build/EnumMetadata.d.cts.map +1 -1
- package/build/EnumMetadata.d.mts +0 -2
- package/build/EnumMetadata.d.mts.map +1 -1
- package/build/IndexManager.cjs +4 -5
- package/build/IndexManager.d.cts +1 -3
- package/build/IndexManager.d.cts.map +1 -1
- package/build/IndexManager.d.mts +1 -3
- package/build/IndexManager.d.mts.map +1 -1
- package/build/IndexManager.js +4 -5
- package/build/InstanceData.cjs +12 -6
- package/build/InstanceData.cjs.map +1 -1
- package/build/InstanceData.d.cts +9 -5
- package/build/InstanceData.d.cts.map +1 -1
- package/build/InstanceData.d.mts +9 -5
- package/build/InstanceData.d.mts.map +1 -1
- package/build/InstanceData.js +12 -6
- package/build/InstanceData.js.map +1 -1
- package/build/PluginManager.cjs +21 -8
- package/build/PluginManager.cjs.map +1 -1
- package/build/PluginManager.d.cts +19 -7
- package/build/PluginManager.d.cts.map +1 -1
- package/build/PluginManager.d.mts +19 -7
- package/build/PluginManager.d.mts.map +1 -1
- package/build/PluginManager.js +21 -8
- package/build/PluginManager.js.map +1 -1
- package/build/RowData.cjs +1 -2
- package/build/RowData.d.cts +0 -2
- package/build/RowData.d.cts.map +1 -1
- package/build/RowData.d.mts +0 -2
- package/build/RowData.d.mts.map +1 -1
- package/build/RowData.js +1 -2
- package/build/_virtual/_rolldown/runtime.cjs +1 -2
- package/build/batchloaders/BatchLoader.cjs +1 -2
- package/build/batchloaders/BatchLoader.d.cts +0 -2
- package/build/batchloaders/BatchLoader.d.cts.map +1 -1
- package/build/batchloaders/BatchLoader.d.mts +0 -2
- package/build/batchloaders/BatchLoader.d.mts.map +1 -1
- package/build/batchloaders/BatchLoader.js +1 -2
- package/build/batchloaders/enumCollectionBatchLoader.cjs +4 -5
- package/build/batchloaders/enumCollectionBatchLoader.cjs.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.cts +1 -3
- package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.mts +1 -3
- package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.js +4 -5
- package/build/batchloaders/enumCollectionBatchLoader.js.map +1 -1
- package/build/batchloaders/loadBatchLoader.cjs +9 -9
- package/build/batchloaders/loadBatchLoader.cjs.map +1 -1
- package/build/batchloaders/loadBatchLoader.d.cts +3 -5
- package/build/batchloaders/loadBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/loadBatchLoader.d.mts +3 -5
- package/build/batchloaders/loadBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/loadBatchLoader.js +9 -9
- package/build/batchloaders/loadBatchLoader.js.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.cjs +5 -6
- package/build/batchloaders/manyToManyBatchLoader.cjs.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.d.cts +1 -3
- package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.d.mts +1 -3
- package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.js +5 -6
- package/build/batchloaders/manyToManyBatchLoader.js.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.cjs +5 -6
- package/build/batchloaders/oneToManyBatchLoader.cjs.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.d.cts +2 -4
- package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.d.mts +2 -4
- package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.js +6 -7
- package/build/batchloaders/oneToManyBatchLoader.js.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.cjs +7 -8
- package/build/batchloaders/oneToOneBatchLoader.cjs.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.d.cts +2 -4
- package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.d.mts +2 -4
- package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.js +7 -8
- package/build/batchloaders/oneToOneBatchLoader.js.map +1 -1
- package/build/batchloaders/populateBatchLoader.cjs +14 -18
- package/build/batchloaders/populateBatchLoader.cjs.map +1 -1
- package/build/batchloaders/populateBatchLoader.d.cts +2 -4
- package/build/batchloaders/populateBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/populateBatchLoader.d.mts +2 -4
- package/build/batchloaders/populateBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/populateBatchLoader.js +14 -18
- package/build/batchloaders/populateBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs +11 -11
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +2 -4
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +2 -4
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.js +11 -11
- package/build/batchloaders/recursiveChildrenBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.cjs +7 -8
- package/build/batchloaders/recursiveM2mBatchLoader.cjs.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts +2 -4
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts +2 -4
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.js +7 -8
- package/build/batchloaders/recursiveM2mBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.cjs +7 -8
- package/build/batchloaders/recursiveParentsBatchLoader.cjs.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts +2 -4
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts +2 -4
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.js +7 -8
- package/build/batchloaders/recursiveParentsBatchLoader.js.map +1 -1
- package/build/changes.cjs +7 -8
- package/build/changes.d.cts +3 -5
- package/build/changes.d.cts.map +1 -1
- package/build/changes.d.mts +3 -5
- package/build/changes.d.mts.map +1 -1
- package/build/changes.js +7 -8
- package/build/config.cjs +9 -10
- package/build/config.d.cts +6 -8
- package/build/config.d.cts.map +1 -1
- package/build/config.d.mts +6 -8
- package/build/config.d.mts.map +1 -1
- package/build/config.js +9 -10
- package/build/configure.cjs +11 -12
- package/build/configure.d.cts +3 -5
- package/build/configure.d.cts.map +1 -1
- package/build/configure.d.mts +3 -5
- package/build/configure.d.mts.map +1 -1
- package/build/configure.js +11 -12
- package/build/dataloaders/buildCandidateBatchQuery.cjs +499 -0
- package/build/dataloaders/buildCandidateBatchQuery.cjs.map +1 -0
- package/build/dataloaders/buildCandidateBatchQuery.d.cts +57 -0
- package/build/dataloaders/buildCandidateBatchQuery.d.cts.map +1 -0
- package/build/dataloaders/buildCandidateBatchQuery.d.mts +57 -0
- package/build/dataloaders/buildCandidateBatchQuery.d.mts.map +1 -0
- package/build/dataloaders/buildCandidateBatchQuery.js +498 -0
- package/build/dataloaders/buildCandidateBatchQuery.js.map +1 -0
- package/build/dataloaders/collectFindArguments.cjs +48 -0
- package/build/dataloaders/collectFindArguments.cjs.map +1 -0
- package/build/dataloaders/collectFindArguments.d.cts +31 -0
- package/build/dataloaders/collectFindArguments.d.cts.map +1 -0
- package/build/dataloaders/collectFindArguments.d.mts +31 -0
- package/build/dataloaders/collectFindArguments.d.mts.map +1 -0
- package/build/dataloaders/collectFindArguments.js +47 -0
- package/build/dataloaders/collectFindArguments.js.map +1 -0
- package/build/dataloaders/fastWhereFilterHash.cjs +3 -4
- package/build/dataloaders/fastWhereFilterHash.d.cts +0 -2
- package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.d.mts +0 -2
- package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.js +3 -4
- package/build/dataloaders/findByUniqueDataLoader.cjs +2 -3
- package/build/dataloaders/findByUniqueDataLoader.d.cts +2 -4
- package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findByUniqueDataLoader.d.mts +2 -4
- package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findByUniqueDataLoader.js +2 -3
- package/build/dataloaders/findCountDataLoader.cjs +8 -9
- package/build/dataloaders/findCountDataLoader.d.cts +3 -5
- package/build/dataloaders/findCountDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findCountDataLoader.d.mts +3 -5
- package/build/dataloaders/findCountDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findCountDataLoader.js +8 -9
- package/build/dataloaders/findDataLoader.cjs +48 -77
- package/build/dataloaders/findDataLoader.cjs.map +1 -1
- package/build/dataloaders/findDataLoader.d.cts +5 -7
- package/build/dataloaders/findDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findDataLoader.d.mts +5 -7
- package/build/dataloaders/findDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findDataLoader.js +48 -77
- package/build/dataloaders/findDataLoader.js.map +1 -1
- package/build/dataloaders/findIdsDataLoader.cjs +6 -7
- package/build/dataloaders/findIdsDataLoader.d.cts +2 -4
- package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findIdsDataLoader.d.mts +2 -4
- package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findIdsDataLoader.js +6 -7
- package/build/dataloaders/findOrCreateDataLoader.cjs +7 -8
- package/build/dataloaders/findOrCreateDataLoader.d.cts +2 -4
- package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.d.mts +2 -4
- package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.js +7 -8
- package/build/dataloaders/findPaginatedDataLoader.cjs +6 -7
- package/build/dataloaders/findPaginatedDataLoader.d.cts +3 -5
- package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.d.mts +3 -5
- package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.js +6 -7
- package/build/dataloaders/lensDataLoader.cjs +5 -6
- package/build/dataloaders/lensDataLoader.d.cts +1 -3
- package/build/dataloaders/lensDataLoader.d.cts.map +1 -1
- package/build/dataloaders/lensDataLoader.d.mts +1 -3
- package/build/dataloaders/lensDataLoader.d.mts.map +1 -1
- package/build/dataloaders/lensDataLoader.js +5 -6
- package/build/dataloaders/manyToManyFindDataLoader.cjs +1 -2
- package/build/dataloaders/manyToManyFindDataLoader.d.cts +2 -4
- package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.mts +2 -4
- package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.js +1 -2
- package/build/dataloaders/oneToManyFindDataLoader.cjs +7 -5
- package/build/dataloaders/oneToManyFindDataLoader.cjs.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.cts +2 -4
- package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.mts +2 -4
- package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.js +8 -6
- package/build/dataloaders/oneToManyFindDataLoader.js.map +1 -1
- package/build/defaults.cjs +7 -8
- package/build/defaults.d.cts +2 -4
- package/build/defaults.d.cts.map +1 -1
- package/build/defaults.d.mts +2 -4
- package/build/defaults.d.mts.map +1 -1
- package/build/defaults.js +7 -8
- package/build/drivers/Driver.cjs +1 -1
- package/build/drivers/Driver.d.cts +2 -4
- package/build/drivers/Driver.d.cts.map +1 -1
- package/build/drivers/Driver.d.mts +2 -4
- package/build/drivers/Driver.d.mts.map +1 -1
- package/build/drivers/Driver.js +1 -1
- package/build/drivers/EntityWriter.cjs +6 -7
- package/build/drivers/EntityWriter.d.cts +1 -3
- package/build/drivers/EntityWriter.d.cts.map +1 -1
- package/build/drivers/EntityWriter.d.mts +1 -3
- package/build/drivers/EntityWriter.d.mts.map +1 -1
- package/build/drivers/EntityWriter.js +6 -7
- package/build/drivers/IdAssigner.cjs +7 -4
- package/build/drivers/IdAssigner.cjs.map +1 -1
- package/build/drivers/IdAssigner.d.cts +1 -2
- package/build/drivers/IdAssigner.d.cts.map +1 -1
- package/build/drivers/IdAssigner.d.mts +1 -2
- package/build/drivers/IdAssigner.d.mts.map +1 -1
- package/build/drivers/IdAssigner.js +7 -4
- package/build/drivers/IdAssigner.js.map +1 -1
- package/build/drivers/driverApi.cjs +4 -5
- package/build/drivers/driverApi.d.cts +2 -4
- package/build/drivers/driverApi.d.cts.map +1 -1
- package/build/drivers/driverApi.d.mts +2 -4
- package/build/drivers/driverApi.d.mts.map +1 -1
- package/build/drivers/driverApi.js +4 -5
- package/build/drivers/index.d.cts +1 -1
- package/build/drivers/index.d.mts +1 -1
- package/build/fields.cjs +87 -17
- package/build/fields.cjs.map +1 -1
- package/build/fields.d.cts +8 -2
- package/build/fields.d.cts.map +1 -1
- package/build/fields.d.mts +8 -2
- package/build/fields.d.mts.map +1 -1
- package/build/fields.js +87 -19
- package/build/fields.js.map +1 -1
- package/build/flush/FlushLock.cjs +1 -2
- package/build/flush/FlushLock.cjs.map +1 -1
- package/build/flush/FlushLock.d.cts +0 -2
- package/build/flush/FlushLock.d.cts.map +1 -1
- package/build/flush/FlushLock.d.mts +0 -2
- package/build/flush/FlushLock.d.mts.map +1 -1
- package/build/flush/FlushLock.js +1 -2
- package/build/flush/JoinRows.cjs +10 -10
- package/build/flush/JoinRows.cjs.map +1 -1
- package/build/flush/JoinRows.d.cts +2 -4
- package/build/flush/JoinRows.d.cts.map +1 -1
- package/build/flush/JoinRows.d.mts +2 -4
- package/build/flush/JoinRows.d.mts.map +1 -1
- package/build/flush/JoinRows.js +10 -10
- package/build/flush/JoinRows.js.map +1 -1
- package/build/flush/PendingChanges.d.cts +0 -2
- package/build/flush/PendingChanges.d.cts.map +1 -1
- package/build/flush/PendingChanges.d.mts +0 -2
- package/build/flush/PendingChanges.d.mts.map +1 -1
- package/build/flush/ReadDrift.cjs +7 -8
- package/build/flush/ReadDrift.cjs.map +1 -1
- package/build/flush/ReadDrift.d.cts +2 -4
- package/build/flush/ReadDrift.d.cts.map +1 -1
- package/build/flush/ReadDrift.d.mts +2 -4
- package/build/flush/ReadDrift.d.mts.map +1 -1
- package/build/flush/ReadDrift.js +7 -8
- package/build/flush/ReadDrift.js.map +1 -1
- package/build/flush/Todo.cjs +3 -4
- package/build/flush/Todo.d.cts +2 -4
- package/build/flush/Todo.d.cts.map +1 -1
- package/build/flush/Todo.d.mts +2 -4
- package/build/flush/Todo.d.mts.map +1 -1
- package/build/flush/Todo.js +3 -4
- package/build/getProperties.cjs +3 -4
- package/build/getProperties.d.cts +0 -2
- package/build/getProperties.d.cts.map +1 -1
- package/build/getProperties.d.mts +0 -2
- package/build/getProperties.d.mts.map +1 -1
- package/build/getProperties.js +3 -4
- package/build/index.cjs +59 -57
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +51 -53
- package/build/index.d.cts.map +1 -1
- package/build/index.d.mts +51 -53
- package/build/index.d.mts.map +1 -1
- package/build/index.js +59 -58
- package/build/index.js.map +1 -1
- package/build/json.cjs +12 -13
- package/build/json.cjs.map +1 -1
- package/build/json.d.cts +5 -7
- package/build/json.d.cts.map +1 -1
- package/build/json.d.mts +5 -7
- package/build/json.d.mts.map +1 -1
- package/build/json.js +12 -13
- package/build/json.js.map +1 -1
- package/build/k.cjs +1 -2
- package/build/k.js +1 -2
- package/build/keys.cjs +5 -6
- package/build/keys.d.cts +3 -5
- package/build/keys.d.cts.map +1 -1
- package/build/keys.d.mts +3 -5
- package/build/keys.d.mts.map +1 -1
- package/build/keys.js +5 -6
- package/build/loading/HintTree.cjs +1 -2
- package/build/loading/HintTree.d.cts +2 -4
- package/build/loading/HintTree.d.cts.map +1 -1
- package/build/loading/HintTree.d.mts +2 -4
- package/build/loading/HintTree.d.mts.map +1 -1
- package/build/loading/HintTree.js +1 -2
- package/build/loading/IsLoadedCache.cjs +1 -2
- package/build/loading/IsLoadedCache.d.cts +0 -2
- package/build/loading/IsLoadedCache.d.cts.map +1 -1
- package/build/loading/IsLoadedCache.d.mts +0 -2
- package/build/loading/IsLoadedCache.d.mts.map +1 -1
- package/build/loading/IsLoadedCache.js +1 -2
- package/build/loading/loadHints.cjs +1 -2
- package/build/loading/loadHints.d.cts +4 -6
- package/build/loading/loadHints.d.cts.map +1 -1
- package/build/loading/loadHints.d.mts +4 -6
- package/build/loading/loadHints.d.mts.map +1 -1
- package/build/loading/loadHints.js +1 -2
- package/build/loading/loadLens.cjs +11 -8
- package/build/loading/loadLens.cjs.map +1 -1
- package/build/loading/loadLens.d.cts +2 -4
- package/build/loading/loadLens.d.cts.map +1 -1
- package/build/loading/loadLens.d.mts +2 -4
- package/build/loading/loadLens.d.mts.map +1 -1
- package/build/loading/loadLens.js +11 -8
- package/build/loading/loadLens.js.map +1 -1
- package/build/loading/withLoaded.cjs +1 -2
- package/build/loading/withLoaded.d.cts +2 -4
- package/build/loading/withLoaded.d.cts.map +1 -1
- package/build/loading/withLoaded.d.mts +2 -4
- package/build/loading/withLoaded.d.mts.map +1 -1
- package/build/loading/withLoaded.js +1 -2
- package/build/logging/FactoryLogger.cjs +2 -3
- package/build/logging/FactoryLogger.d.cts +1 -3
- package/build/logging/FactoryLogger.d.cts.map +1 -1
- package/build/logging/FactoryLogger.d.mts +1 -3
- package/build/logging/FactoryLogger.d.mts.map +1 -1
- package/build/logging/FactoryLogger.js +2 -3
- package/build/logging/FieldLogger.cjs +1 -2
- package/build/logging/FieldLogger.d.cts +0 -2
- package/build/logging/FieldLogger.d.cts.map +1 -1
- package/build/logging/FieldLogger.d.mts +0 -2
- package/build/logging/FieldLogger.d.mts.map +1 -1
- package/build/logging/FieldLogger.js +1 -2
- package/build/logging/ReactionLogger.cjs +3 -4
- package/build/logging/ReactionLogger.d.cts +3 -5
- package/build/logging/ReactionLogger.d.cts.map +1 -1
- package/build/logging/ReactionLogger.d.mts +3 -5
- package/build/logging/ReactionLogger.d.mts.map +1 -1
- package/build/logging/ReactionLogger.js +3 -4
- package/build/metrics/EntityMetrics.cjs +1 -2
- package/build/metrics/EntityMetrics.d.cts +0 -2
- package/build/metrics/EntityMetrics.d.cts.map +1 -1
- package/build/metrics/EntityMetrics.d.mts +0 -2
- package/build/metrics/EntityMetrics.d.mts.map +1 -1
- package/build/metrics/EntityMetrics.js +1 -2
- package/build/newEntity.cjs +5 -6
- package/build/newEntity.cjs.map +1 -1
- package/build/newEntity.d.cts +2 -4
- package/build/newEntity.d.cts.map +1 -1
- package/build/newEntity.d.mts +2 -4
- package/build/newEntity.d.mts.map +1 -1
- package/build/newEntity.js +5 -6
- package/build/newEntity.js.map +1 -1
- package/build/newTestInstance.cjs +9 -10
- package/build/newTestInstance.d.cts +3 -5
- package/build/newTestInstance.d.cts.map +1 -1
- package/build/newTestInstance.d.mts +3 -5
- package/build/newTestInstance.d.mts.map +1 -1
- package/build/newTestInstance.js +9 -10
- package/build/normalizeHints.cjs +1 -2
- package/build/normalizeHints.d.cts +1 -3
- package/build/normalizeHints.d.cts.map +1 -1
- package/build/normalizeHints.d.mts +1 -3
- package/build/normalizeHints.d.mts.map +1 -1
- package/build/normalizeHints.js +1 -2
- package/build/nowUTC.cjs +1 -2
- package/build/nowUTC.d.cts +0 -2
- package/build/nowUTC.d.cts.map +1 -1
- package/build/nowUTC.d.mts +0 -2
- package/build/nowUTC.d.mts.map +1 -1
- package/build/nowUTC.js +1 -2
- package/build/plugins/ImmutableEntitiesPlugin.cjs +3 -4
- package/build/plugins/ImmutableEntitiesPlugin.d.cts +1 -3
- package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.mts +1 -3
- package/build/plugins/ImmutableEntitiesPlugin.d.mts.map +1 -1
- package/build/plugins/ImmutableEntitiesPlugin.js +3 -4
- package/build/plugins/PreloadPlugin.cjs +1 -1
- package/build/plugins/PreloadPlugin.d.cts +4 -6
- package/build/plugins/PreloadPlugin.d.cts.map +1 -1
- package/build/plugins/PreloadPlugin.d.mts +4 -6
- package/build/plugins/PreloadPlugin.d.mts.map +1 -1
- package/build/plugins/PreloadPlugin.js +1 -1
- package/build/preloading/JsonAggregatePreloader.cjs +13 -13
- package/build/preloading/JsonAggregatePreloader.cjs.map +1 -1
- package/build/preloading/JsonAggregatePreloader.d.cts +3 -5
- package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -1
- package/build/preloading/JsonAggregatePreloader.d.mts +3 -5
- package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -1
- package/build/preloading/JsonAggregatePreloader.js +13 -13
- package/build/preloading/JsonAggregatePreloader.js.map +1 -1
- package/build/preloading/canPreload.cjs +1 -2
- package/build/preloading/canPreload.d.cts +0 -2
- package/build/preloading/canPreload.d.cts.map +1 -1
- package/build/preloading/canPreload.d.mts +0 -2
- package/build/preloading/canPreload.d.mts.map +1 -1
- package/build/preloading/canPreload.js +1 -2
- package/build/preloading/partitionHint.cjs +4 -5
- package/build/preloading/partitionHint.d.cts +1 -3
- package/build/preloading/partitionHint.d.cts.map +1 -1
- package/build/preloading/partitionHint.d.mts +1 -3
- package/build/preloading/partitionHint.d.mts.map +1 -1
- package/build/preloading/partitionHint.js +4 -5
- package/build/queries/ConditionBuilder.cjs +2 -3
- package/build/queries/ConditionBuilder.d.cts +1 -3
- package/build/queries/ConditionBuilder.d.cts.map +1 -1
- package/build/queries/ConditionBuilder.d.mts +1 -3
- package/build/queries/ConditionBuilder.d.mts.map +1 -1
- package/build/queries/ConditionBuilder.js +2 -3
- package/build/queries/conditions.cjs +1 -2
- package/build/queries/conditions.d.cts +0 -2
- package/build/queries/conditions.d.cts.map +1 -1
- package/build/queries/conditions.d.mts +0 -2
- package/build/queries/conditions.d.mts.map +1 -1
- package/build/queries/conditions.js +1 -2
- package/build/queries/entityQueryUtils.cjs +2 -3
- package/build/queries/entityQueryUtils.d.cts +1 -3
- package/build/queries/entityQueryUtils.d.cts.map +1 -1
- package/build/queries/entityQueryUtils.d.mts +1 -3
- package/build/queries/entityQueryUtils.d.mts.map +1 -1
- package/build/queries/entityQueryUtils.js +2 -3
- package/build/queries/find/Aliases.cjs +4 -5
- package/build/queries/find/Aliases.d.cts +5 -7
- package/build/queries/find/Aliases.d.cts.map +1 -1
- package/build/queries/find/Aliases.d.mts +5 -7
- package/build/queries/find/Aliases.d.mts.map +1 -1
- package/build/queries/find/Aliases.js +4 -5
- package/build/queries/find/DeferredAlias.cjs +1 -2
- package/build/queries/find/DeferredAlias.d.cts +2 -4
- package/build/queries/find/DeferredAlias.d.cts.map +1 -1
- package/build/queries/find/DeferredAlias.d.mts +2 -4
- package/build/queries/find/DeferredAlias.d.mts.map +1 -1
- package/build/queries/find/DeferredAlias.js +1 -2
- package/build/queries/find/EntityFilter.cjs +1 -2
- package/build/queries/find/EntityFilter.d.cts +3 -5
- package/build/queries/find/EntityFilter.d.cts.map +1 -1
- package/build/queries/find/EntityFilter.d.mts +3 -5
- package/build/queries/find/EntityFilter.d.mts.map +1 -1
- package/build/queries/find/EntityFilter.js +1 -2
- package/build/queries/find/EntityGraphQLFilter.cjs +1 -2
- package/build/queries/find/EntityGraphQLFilter.d.cts +2 -4
- package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -1
- package/build/queries/find/EntityGraphQLFilter.d.mts +2 -4
- package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -1
- package/build/queries/find/EntityGraphQLFilter.js +1 -2
- package/build/queries/find/QueryParser.cjs +9 -10
- package/build/queries/find/QueryParser.cjs.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.cjs +1 -2
- package/build/queries/find/QueryParser.collectionJoins.d.cts +0 -2
- package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.d.mts +0 -2
- package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.js +1 -2
- package/build/queries/find/QueryParser.d.cts +4 -4
- package/build/queries/find/QueryParser.d.cts.map +1 -1
- package/build/queries/find/QueryParser.d.mts +4 -4
- package/build/queries/find/QueryParser.d.mts.map +1 -1
- package/build/queries/find/QueryParser.js +9 -10
- package/build/queries/find/QueryParser.js.map +1 -1
- package/build/queries/find/QueryParser.pruning.cjs +2 -3
- package/build/queries/find/QueryParser.pruning.d.cts +0 -2
- package/build/queries/find/QueryParser.pruning.d.cts.map +1 -1
- package/build/queries/find/QueryParser.pruning.d.mts +0 -2
- package/build/queries/find/QueryParser.pruning.d.mts.map +1 -1
- package/build/queries/find/QueryParser.pruning.js +2 -3
- package/build/queries/find/QueryVisitor.cjs +1 -2
- package/build/queries/find/QueryVisitor.d.cts +0 -2
- package/build/queries/find/QueryVisitor.d.cts.map +1 -1
- package/build/queries/find/QueryVisitor.d.mts +0 -2
- package/build/queries/find/QueryVisitor.d.mts.map +1 -1
- package/build/queries/find/QueryVisitor.js +1 -2
- package/build/queries/find/buildFindQuery.cjs +5 -6
- package/build/queries/find/buildFindQuery.cjs.map +1 -1
- package/build/queries/find/buildFindQuery.d.cts +0 -2
- package/build/queries/find/buildFindQuery.d.cts.map +1 -1
- package/build/queries/find/buildFindQuery.d.mts +0 -2
- package/build/queries/find/buildFindQuery.d.mts.map +1 -1
- package/build/queries/find/buildFindQuery.js +5 -6
- package/build/queries/find/buildFindQuery.js.map +1 -1
- package/build/queries/find/scopes.cjs +1 -2
- package/build/queries/find/scopes.d.cts +5 -7
- package/build/queries/find/scopes.d.cts.map +1 -1
- package/build/queries/find/scopes.d.mts +5 -7
- package/build/queries/find/scopes.d.mts.map +1 -1
- package/build/queries/find/scopes.js +1 -2
- package/build/queries/parsedConditions.cjs +1 -2
- package/build/queries/parsedConditions.d.cts +0 -2
- package/build/queries/parsedConditions.d.cts.map +1 -1
- package/build/queries/parsedConditions.d.mts +0 -2
- package/build/queries/parsedConditions.d.mts.map +1 -1
- package/build/queries/parsedConditions.js +1 -2
- package/build/queries/renderConditions.cjs +3 -4
- package/build/queries/renderConditions.d.cts +0 -2
- package/build/queries/renderConditions.d.cts.map +1 -1
- package/build/queries/renderConditions.d.mts +0 -2
- package/build/queries/renderConditions.d.mts.map +1 -1
- package/build/queries/renderConditions.js +3 -4
- package/build/queries/skipCondition.cjs +1 -2
- package/build/queries/skipCondition.d.cts +0 -2
- package/build/queries/skipCondition.d.cts.map +1 -1
- package/build/queries/skipCondition.d.mts +0 -2
- package/build/queries/skipCondition.d.mts.map +1 -1
- package/build/queries/skipCondition.js +1 -2
- package/build/queries/sql/AliasAssigner.cjs +1 -2
- package/build/queries/sql/AliasAssigner.d.cts +0 -2
- package/build/queries/sql/AliasAssigner.d.cts.map +1 -1
- package/build/queries/sql/AliasAssigner.d.mts +0 -2
- package/build/queries/sql/AliasAssigner.d.mts.map +1 -1
- package/build/queries/sql/AliasAssigner.js +1 -2
- package/build/queries/sql/Expr.cjs +3 -4
- package/build/queries/sql/Expr.d.cts +2 -4
- package/build/queries/sql/Expr.d.cts.map +1 -1
- package/build/queries/sql/Expr.d.mts +2 -4
- package/build/queries/sql/Expr.d.mts.map +1 -1
- package/build/queries/sql/Expr.js +3 -4
- package/build/queries/sql/JoinTree.cjs +3 -4
- package/build/queries/sql/JoinTree.d.cts +5 -7
- package/build/queries/sql/JoinTree.d.cts.map +1 -1
- package/build/queries/sql/JoinTree.d.mts +5 -7
- package/build/queries/sql/JoinTree.d.mts.map +1 -1
- package/build/queries/sql/JoinTree.js +3 -4
- package/build/queries/sql/Tables.cjs +8 -9
- package/build/queries/sql/Tables.d.cts +5 -7
- package/build/queries/sql/Tables.d.cts.map +1 -1
- package/build/queries/sql/Tables.d.mts +5 -7
- package/build/queries/sql/Tables.d.mts.map +1 -1
- package/build/queries/sql/Tables.js +8 -9
- package/build/queries/sql/custom.cjs +1 -2
- package/build/queries/sql/custom.d.cts +2 -4
- package/build/queries/sql/custom.d.cts.map +1 -1
- package/build/queries/sql/custom.d.mts +2 -4
- package/build/queries/sql/custom.d.mts.map +1 -1
- package/build/queries/sql/custom.js +1 -2
- package/build/queries/sql/execute.cjs +6 -7
- package/build/queries/sql/execute.d.cts +6 -8
- package/build/queries/sql/execute.d.cts.map +1 -1
- package/build/queries/sql/execute.d.mts +6 -8
- package/build/queries/sql/execute.d.mts.map +1 -1
- package/build/queries/sql/execute.js +6 -7
- package/build/queries/sql/expressions/arrayAgg.cjs +2 -3
- package/build/queries/sql/expressions/arrayAgg.d.cts +1 -3
- package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -1
- package/build/queries/sql/expressions/arrayAgg.d.mts +1 -3
- package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -1
- package/build/queries/sql/expressions/arrayAgg.js +2 -3
- package/build/queries/sql/expressions/case.cjs +2 -3
- package/build/queries/sql/expressions/case.d.cts +1 -3
- package/build/queries/sql/expressions/case.d.cts.map +1 -1
- package/build/queries/sql/expressions/case.d.mts +1 -3
- package/build/queries/sql/expressions/case.d.mts.map +1 -1
- package/build/queries/sql/expressions/case.js +2 -3
- package/build/queries/sql/expressions/coalesce.cjs +2 -3
- package/build/queries/sql/expressions/coalesce.d.cts +1 -3
- package/build/queries/sql/expressions/coalesce.d.cts.map +1 -1
- package/build/queries/sql/expressions/coalesce.d.mts +1 -3
- package/build/queries/sql/expressions/coalesce.d.mts.map +1 -1
- package/build/queries/sql/expressions/coalesce.js +2 -3
- package/build/queries/sql/expressions/codecs.cjs +2 -3
- package/build/queries/sql/expressions/codecs.d.cts +0 -2
- package/build/queries/sql/expressions/codecs.d.cts.map +1 -1
- package/build/queries/sql/expressions/codecs.d.mts +0 -2
- package/build/queries/sql/expressions/codecs.d.mts.map +1 -1
- package/build/queries/sql/expressions/codecs.js +2 -3
- package/build/queries/sql/expressions/expression.cjs +4 -5
- package/build/queries/sql/expressions/expression.d.cts +2 -4
- package/build/queries/sql/expressions/expression.d.cts.map +1 -1
- package/build/queries/sql/expressions/expression.d.mts +2 -4
- package/build/queries/sql/expressions/expression.d.mts.map +1 -1
- package/build/queries/sql/expressions/expression.js +4 -5
- package/build/queries/sql/expressions/greatest.cjs +2 -3
- package/build/queries/sql/expressions/greatest.d.cts +1 -3
- package/build/queries/sql/expressions/greatest.d.cts.map +1 -1
- package/build/queries/sql/expressions/greatest.d.mts +1 -3
- package/build/queries/sql/expressions/greatest.d.mts.map +1 -1
- package/build/queries/sql/expressions/greatest.js +2 -3
- package/build/queries/sql/expressions/least.cjs +2 -3
- package/build/queries/sql/expressions/least.d.cts +1 -3
- package/build/queries/sql/expressions/least.d.cts.map +1 -1
- package/build/queries/sql/expressions/least.d.mts +1 -3
- package/build/queries/sql/expressions/least.d.mts.map +1 -1
- package/build/queries/sql/expressions/least.js +2 -3
- package/build/queries/sql/expressions/nullIf.cjs +2 -3
- package/build/queries/sql/expressions/nullIf.d.cts +1 -3
- package/build/queries/sql/expressions/nullIf.d.cts.map +1 -1
- package/build/queries/sql/expressions/nullIf.d.mts +1 -3
- package/build/queries/sql/expressions/nullIf.d.mts.map +1 -1
- package/build/queries/sql/expressions/nullIf.js +2 -3
- package/build/queries/sql/expressions/parseExpression.cjs +3 -4
- package/build/queries/sql/expressions/parseExpression.d.cts +0 -2
- package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -1
- package/build/queries/sql/expressions/parseExpression.d.mts +0 -2
- package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -1
- package/build/queries/sql/expressions/parseExpression.js +3 -4
- package/build/queries/sql/expressions/types.d.cts +1 -3
- package/build/queries/sql/expressions/types.d.cts.map +1 -1
- package/build/queries/sql/expressions/types.d.mts +1 -3
- package/build/queries/sql/expressions/types.d.mts.map +1 -1
- package/build/queries/sql/keywords.cjs +1 -2
- package/build/queries/sql/keywords.d.cts +0 -2
- package/build/queries/sql/keywords.d.cts.map +1 -1
- package/build/queries/sql/keywords.d.mts +0 -2
- package/build/queries/sql/keywords.d.mts.map +1 -1
- package/build/queries/sql/keywords.js +1 -2
- package/build/queries/sql/query.cjs +9 -10
- package/build/queries/sql/query.d.cts +6 -8
- package/build/queries/sql/query.d.cts.map +1 -1
- package/build/queries/sql/query.d.mts +6 -8
- package/build/queries/sql/query.d.mts.map +1 -1
- package/build/queries/sql/query.js +9 -10
- package/build/queries/unnest.cjs +1 -2
- package/build/queries/unnest.d.cts +1 -3
- package/build/queries/unnest.d.cts.map +1 -1
- package/build/queries/unnest.d.mts +1 -3
- package/build/queries/unnest.d.mts.map +1 -1
- package/build/queries/unnest.js +1 -2
- package/build/queries/valueFilters.cjs +3 -4
- package/build/queries/valueFilters.d.cts +2 -4
- package/build/queries/valueFilters.d.cts.map +1 -1
- package/build/queries/valueFilters.d.mts +2 -4
- package/build/queries/valueFilters.d.mts.map +1 -1
- package/build/queries/valueFilters.js +3 -4
- package/build/reactivity/ReactionsManager.cjs +6 -7
- package/build/reactivity/ReactionsManager.d.cts +2 -4
- package/build/reactivity/ReactionsManager.d.cts.map +1 -1
- package/build/reactivity/ReactionsManager.d.mts +2 -4
- package/build/reactivity/ReactionsManager.d.mts.map +1 -1
- package/build/reactivity/ReactionsManager.js +6 -7
- package/build/reactivity/reactiveHints.cjs +8 -9
- package/build/reactivity/reactiveHints.d.cts +8 -10
- package/build/reactivity/reactiveHints.d.cts.map +1 -1
- package/build/reactivity/reactiveHints.d.mts +8 -10
- package/build/reactivity/reactiveHints.d.mts.map +1 -1
- package/build/reactivity/reactiveHints.js +8 -9
- package/build/relations/AbstractPropertyImpl.cjs +1 -2
- package/build/relations/AbstractPropertyImpl.d.cts +0 -2
- package/build/relations/AbstractPropertyImpl.d.cts.map +1 -1
- package/build/relations/AbstractPropertyImpl.d.mts +0 -2
- package/build/relations/AbstractPropertyImpl.d.mts.map +1 -1
- package/build/relations/AbstractPropertyImpl.js +1 -2
- package/build/relations/AbstractRelationImpl.cjs +1 -2
- package/build/relations/AbstractRelationImpl.d.cts +0 -2
- package/build/relations/AbstractRelationImpl.d.cts.map +1 -1
- package/build/relations/AbstractRelationImpl.d.mts +0 -2
- package/build/relations/AbstractRelationImpl.d.mts.map +1 -1
- package/build/relations/AbstractRelationImpl.js +1 -2
- package/build/relations/AsyncProperty.cjs +3 -4
- package/build/relations/AsyncProperty.d.cts +2 -4
- package/build/relations/AsyncProperty.d.cts.map +1 -1
- package/build/relations/AsyncProperty.d.mts +2 -4
- package/build/relations/AsyncProperty.d.mts.map +1 -1
- package/build/relations/AsyncProperty.js +3 -4
- package/build/relations/AsyncReactiveField.cjs +10 -11
- package/build/relations/AsyncReactiveField.d.cts +4 -6
- package/build/relations/AsyncReactiveField.d.cts.map +1 -1
- package/build/relations/AsyncReactiveField.d.mts +4 -6
- package/build/relations/AsyncReactiveField.d.mts.map +1 -1
- package/build/relations/AsyncReactiveField.js +10 -11
- package/build/relations/Collection.cjs +3 -4
- package/build/relations/Collection.d.cts +2 -4
- package/build/relations/Collection.d.cts.map +1 -1
- package/build/relations/Collection.d.mts +2 -4
- package/build/relations/Collection.d.mts.map +1 -1
- package/build/relations/Collection.js +3 -4
- package/build/relations/CustomCollection.cjs +40 -8
- package/build/relations/CustomCollection.cjs.map +1 -1
- package/build/relations/CustomCollection.d.cts +6 -6
- package/build/relations/CustomCollection.d.cts.map +1 -1
- package/build/relations/CustomCollection.d.mts +6 -6
- package/build/relations/CustomCollection.d.mts.map +1 -1
- package/build/relations/CustomCollection.js +40 -8
- package/build/relations/CustomCollection.js.map +1 -1
- package/build/relations/CustomReference.cjs +36 -8
- package/build/relations/CustomReference.cjs.map +1 -1
- package/build/relations/CustomReference.d.cts +8 -8
- package/build/relations/CustomReference.d.cts.map +1 -1
- package/build/relations/CustomReference.d.mts +8 -8
- package/build/relations/CustomReference.d.mts.map +1 -1
- package/build/relations/CustomReference.js +36 -8
- package/build/relations/CustomReference.js.map +1 -1
- package/build/relations/EnumCollection.cjs +4 -5
- package/build/relations/EnumCollection.d.cts +3 -5
- package/build/relations/EnumCollection.d.cts.map +1 -1
- package/build/relations/EnumCollection.d.mts +3 -5
- package/build/relations/EnumCollection.d.mts.map +1 -1
- package/build/relations/EnumCollection.js +4 -5
- package/build/relations/LargeCollection.cjs +2 -2
- package/build/relations/LargeCollection.d.cts +2 -4
- package/build/relations/LargeCollection.d.cts.map +1 -1
- package/build/relations/LargeCollection.d.mts +2 -4
- package/build/relations/LargeCollection.d.mts.map +1 -1
- package/build/relations/LargeCollection.js +2 -2
- package/build/relations/LazyField.cjs +14 -15
- package/build/relations/LazyField.cjs.map +1 -1
- package/build/relations/LazyField.d.cts +2 -4
- package/build/relations/LazyField.d.cts.map +1 -1
- package/build/relations/LazyField.d.mts +2 -4
- package/build/relations/LazyField.d.mts.map +1 -1
- package/build/relations/LazyField.js +14 -15
- package/build/relations/LazyField.js.map +1 -1
- package/build/relations/ManyToManyCollection.cjs +68 -13
- package/build/relations/ManyToManyCollection.cjs.map +1 -1
- package/build/relations/ManyToManyCollection.d.cts +2 -4
- package/build/relations/ManyToManyCollection.d.cts.map +1 -1
- package/build/relations/ManyToManyCollection.d.mts +2 -4
- package/build/relations/ManyToManyCollection.d.mts.map +1 -1
- package/build/relations/ManyToManyCollection.js +68 -13
- package/build/relations/ManyToManyCollection.js.map +1 -1
- package/build/relations/ManyToManyLargeCollection.cjs +35 -13
- package/build/relations/ManyToManyLargeCollection.cjs.map +1 -1
- package/build/relations/ManyToManyLargeCollection.d.cts +6 -8
- package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -1
- package/build/relations/ManyToManyLargeCollection.d.mts +6 -8
- package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -1
- package/build/relations/ManyToManyLargeCollection.js +35 -13
- package/build/relations/ManyToManyLargeCollection.js.map +1 -1
- package/build/relations/ManyToOneReference.cjs +35 -19
- package/build/relations/ManyToOneReference.cjs.map +1 -1
- package/build/relations/ManyToOneReference.d.cts +6 -8
- package/build/relations/ManyToOneReference.d.cts.map +1 -1
- package/build/relations/ManyToOneReference.d.mts +6 -8
- package/build/relations/ManyToOneReference.d.mts.map +1 -1
- package/build/relations/ManyToOneReference.js +35 -19
- package/build/relations/ManyToOneReference.js.map +1 -1
- package/build/relations/OneToManyCollection.cjs +71 -15
- package/build/relations/OneToManyCollection.cjs.map +1 -1
- package/build/relations/OneToManyCollection.d.cts +3 -5
- package/build/relations/OneToManyCollection.d.cts.map +1 -1
- package/build/relations/OneToManyCollection.d.mts +3 -5
- package/build/relations/OneToManyCollection.d.mts.map +1 -1
- package/build/relations/OneToManyCollection.js +71 -15
- package/build/relations/OneToManyCollection.js.map +1 -1
- package/build/relations/OneToManyLargeCollection.cjs +25 -10
- package/build/relations/OneToManyLargeCollection.cjs.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.cts +4 -6
- package/build/relations/OneToManyLargeCollection.d.cts.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.mts +4 -6
- package/build/relations/OneToManyLargeCollection.d.mts.map +1 -1
- package/build/relations/OneToManyLargeCollection.js +25 -10
- package/build/relations/OneToManyLargeCollection.js.map +1 -1
- package/build/relations/OneToOneReference.cjs +41 -13
- package/build/relations/OneToOneReference.cjs.map +1 -1
- package/build/relations/OneToOneReference.d.cts +6 -8
- package/build/relations/OneToOneReference.d.cts.map +1 -1
- package/build/relations/OneToOneReference.d.mts +6 -8
- package/build/relations/OneToOneReference.d.mts.map +1 -1
- package/build/relations/OneToOneReference.js +41 -13
- package/build/relations/OneToOneReference.js.map +1 -1
- package/build/relations/PolymorphicReference.cjs +33 -17
- package/build/relations/PolymorphicReference.cjs.map +1 -1
- package/build/relations/PolymorphicReference.d.cts +5 -7
- package/build/relations/PolymorphicReference.d.cts.map +1 -1
- package/build/relations/PolymorphicReference.d.mts +5 -7
- package/build/relations/PolymorphicReference.d.mts.map +1 -1
- package/build/relations/PolymorphicReference.js +33 -17
- package/build/relations/PolymorphicReference.js.map +1 -1
- package/build/relations/PropertySymbols.cjs +1 -2
- package/build/relations/PropertySymbols.d.cts +0 -2
- package/build/relations/PropertySymbols.d.cts.map +1 -1
- package/build/relations/PropertySymbols.d.mts +0 -2
- package/build/relations/PropertySymbols.d.mts.map +1 -1
- package/build/relations/PropertySymbols.js +1 -2
- package/build/relations/ReactiveField.cjs +9 -10
- package/build/relations/ReactiveField.d.cts +4 -6
- package/build/relations/ReactiveField.d.cts.map +1 -1
- package/build/relations/ReactiveField.d.mts +4 -6
- package/build/relations/ReactiveField.d.mts.map +1 -1
- package/build/relations/ReactiveField.js +9 -10
- package/build/relations/ReactiveGetter.cjs +2 -3
- package/build/relations/ReactiveGetter.d.cts +2 -4
- package/build/relations/ReactiveGetter.d.cts.map +1 -1
- package/build/relations/ReactiveGetter.d.mts +2 -4
- package/build/relations/ReactiveGetter.d.mts.map +1 -1
- package/build/relations/ReactiveGetter.js +2 -3
- package/build/relations/ReactiveManyToMany.cjs +59 -17
- package/build/relations/ReactiveManyToMany.cjs.map +1 -1
- package/build/relations/ReactiveManyToMany.d.cts +7 -6
- package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
- package/build/relations/ReactiveManyToMany.d.mts +7 -6
- package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
- package/build/relations/ReactiveManyToMany.js +59 -17
- package/build/relations/ReactiveManyToMany.js.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.cjs +41 -10
- package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.cts +4 -6
- package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.mts +4 -6
- package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.js +41 -10
- package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
- package/build/relations/ReactiveReference.cjs +29 -12
- package/build/relations/ReactiveReference.cjs.map +1 -1
- package/build/relations/ReactiveReference.d.cts +7 -9
- package/build/relations/ReactiveReference.d.cts.map +1 -1
- package/build/relations/ReactiveReference.d.mts +7 -9
- package/build/relations/ReactiveReference.d.mts.map +1 -1
- package/build/relations/ReactiveReference.js +29 -12
- package/build/relations/ReactiveReference.js.map +1 -1
- package/build/relations/ReadOnlyCollection.cjs +3 -4
- package/build/relations/ReadOnlyCollection.d.cts +1 -3
- package/build/relations/ReadOnlyCollection.d.cts.map +1 -1
- package/build/relations/ReadOnlyCollection.d.mts +1 -3
- package/build/relations/ReadOnlyCollection.d.mts.map +1 -1
- package/build/relations/ReadOnlyCollection.js +3 -4
- package/build/relations/RecursiveCollection.cjs +60 -11
- package/build/relations/RecursiveCollection.cjs.map +1 -1
- package/build/relations/RecursiveCollection.d.cts +3 -5
- package/build/relations/RecursiveCollection.d.cts.map +1 -1
- package/build/relations/RecursiveCollection.d.mts +3 -5
- package/build/relations/RecursiveCollection.d.mts.map +1 -1
- package/build/relations/RecursiveCollection.js +60 -11
- package/build/relations/RecursiveCollection.js.map +1 -1
- package/build/relations/RecursiveCycleError.cjs +1 -2
- package/build/relations/RecursiveCycleError.d.cts +0 -2
- package/build/relations/RecursiveCycleError.d.cts.map +1 -1
- package/build/relations/RecursiveCycleError.d.mts +0 -2
- package/build/relations/RecursiveCycleError.d.mts.map +1 -1
- package/build/relations/RecursiveCycleError.js +1 -2
- package/build/relations/Reference.cjs +4 -5
- package/build/relations/Reference.d.cts +3 -5
- package/build/relations/Reference.d.cts.map +1 -1
- package/build/relations/Reference.d.mts +3 -5
- package/build/relations/Reference.d.mts.map +1 -1
- package/build/relations/Reference.js +4 -5
- package/build/relations/ReferenceSymbols.cjs +1 -2
- package/build/relations/ReferenceSymbols.d.cts +0 -2
- package/build/relations/ReferenceSymbols.d.cts.map +1 -1
- package/build/relations/ReferenceSymbols.d.mts +0 -2
- package/build/relations/ReferenceSymbols.d.mts.map +1 -1
- package/build/relations/ReferenceSymbols.js +1 -2
- package/build/relations/Relation.cjs +3 -4
- package/build/relations/Relation.d.cts +1 -3
- package/build/relations/Relation.d.cts.map +1 -1
- package/build/relations/Relation.d.mts +1 -3
- package/build/relations/Relation.d.mts.map +1 -1
- package/build/relations/Relation.js +3 -4
- package/build/relations/RelationSymbols.cjs +1 -2
- package/build/relations/RelationSymbols.d.cts +0 -2
- package/build/relations/RelationSymbols.d.cts.map +1 -1
- package/build/relations/RelationSymbols.d.mts +0 -2
- package/build/relations/RelationSymbols.d.mts.map +1 -1
- package/build/relations/RelationSymbols.js +1 -2
- package/build/relations/hasAsyncMethod.cjs +6 -7
- package/build/relations/hasAsyncMethod.d.cts +2 -4
- package/build/relations/hasAsyncMethod.d.cts.map +1 -1
- package/build/relations/hasAsyncMethod.d.mts +2 -4
- package/build/relations/hasAsyncMethod.d.mts.map +1 -1
- package/build/relations/hasAsyncMethod.js +6 -7
- package/build/relations/hasManyDerived.cjs +5 -6
- package/build/relations/hasManyDerived.cjs.map +1 -1
- package/build/relations/hasManyDerived.d.cts +2 -4
- package/build/relations/hasManyDerived.d.cts.map +1 -1
- package/build/relations/hasManyDerived.d.mts +2 -4
- package/build/relations/hasManyDerived.d.mts.map +1 -1
- package/build/relations/hasManyDerived.js +5 -6
- package/build/relations/hasManyDerived.js.map +1 -1
- package/build/relations/hasManyThrough.cjs +4 -5
- package/build/relations/hasManyThrough.cjs.map +1 -1
- package/build/relations/hasManyThrough.d.cts +0 -2
- package/build/relations/hasManyThrough.d.cts.map +1 -1
- package/build/relations/hasManyThrough.d.mts +0 -2
- package/build/relations/hasManyThrough.d.mts.map +1 -1
- package/build/relations/hasManyThrough.js +4 -5
- package/build/relations/hasManyThrough.js.map +1 -1
- package/build/relations/hasOneDerived.cjs +5 -6
- package/build/relations/hasOneDerived.cjs.map +1 -1
- package/build/relations/hasOneDerived.d.cts +2 -4
- package/build/relations/hasOneDerived.d.cts.map +1 -1
- package/build/relations/hasOneDerived.d.mts +2 -4
- package/build/relations/hasOneDerived.d.mts.map +1 -1
- package/build/relations/hasOneDerived.js +5 -6
- package/build/relations/hasOneDerived.js.map +1 -1
- package/build/relations/hasOneThrough.cjs +4 -5
- package/build/relations/hasOneThrough.cjs.map +1 -1
- package/build/relations/hasOneThrough.d.cts +0 -2
- package/build/relations/hasOneThrough.d.cts.map +1 -1
- package/build/relations/hasOneThrough.d.mts +0 -2
- package/build/relations/hasOneThrough.d.mts.map +1 -1
- package/build/relations/hasOneThrough.js +4 -5
- package/build/relations/hasOneThrough.js.map +1 -1
- package/build/relations/hasProperty.cjs +5 -6
- package/build/relations/hasProperty.d.cts +2 -4
- package/build/relations/hasProperty.d.cts.map +1 -1
- package/build/relations/hasProperty.d.mts +2 -4
- package/build/relations/hasProperty.d.mts.map +1 -1
- package/build/relations/hasProperty.js +5 -6
- package/build/relations/hasReactiveAsyncMethod.cjs +5 -6
- package/build/relations/hasReactiveAsyncMethod.d.cts +3 -5
- package/build/relations/hasReactiveAsyncMethod.d.cts.map +1 -1
- package/build/relations/hasReactiveAsyncMethod.d.mts +3 -5
- package/build/relations/hasReactiveAsyncMethod.d.mts.map +1 -1
- package/build/relations/hasReactiveAsyncMethod.js +5 -6
- package/build/relations/index.cjs +9 -9
- package/build/relations/index.d.cts +3 -3
- package/build/relations/index.d.mts +3 -3
- package/build/relations/index.js +9 -9
- package/build/relations/isCascadeDelete.cjs +1 -2
- package/build/relations/isCascadeDelete.d.cts +0 -2
- package/build/relations/isCascadeDelete.d.cts.map +1 -1
- package/build/relations/isCascadeDelete.d.mts +0 -2
- package/build/relations/isCascadeDelete.d.mts.map +1 -1
- package/build/relations/isCascadeDelete.js +1 -2
- package/build/relations/relationVisibility.cjs +51 -0
- package/build/relations/relationVisibility.cjs.map +1 -0
- package/build/relations/relationVisibility.d.cts +10 -0
- package/build/relations/relationVisibility.d.cts.map +1 -0
- package/build/relations/relationVisibility.d.mts +10 -0
- package/build/relations/relationVisibility.d.mts.map +1 -0
- package/build/relations/relationVisibility.js +47 -0
- package/build/relations/relationVisibility.js.map +1 -0
- package/build/resurrection.cjs +4 -5
- package/build/resurrection.d.cts +2 -4
- package/build/resurrection.d.cts.map +1 -1
- package/build/resurrection.d.mts +2 -4
- package/build/resurrection.d.mts.map +1 -1
- package/build/resurrection.js +4 -5
- package/build/rules.cjs +6 -7
- package/build/rules.d.cts +3 -5
- package/build/rules.d.cts.map +1 -1
- package/build/rules.d.mts +3 -5
- package/build/rules.d.mts.map +1 -1
- package/build/rules.js +6 -7
- package/build/runtimeConfig.cjs +1 -2
- package/build/runtimeConfig.d.cts +0 -2
- package/build/runtimeConfig.d.cts.map +1 -1
- package/build/runtimeConfig.d.mts +0 -2
- package/build/runtimeConfig.d.mts.map +1 -1
- package/build/runtimeConfig.js +1 -2
- package/build/serde/TypeInfo.cjs +1 -2
- package/build/serde/TypeInfo.d.cts +0 -2
- package/build/serde/TypeInfo.d.cts.map +1 -1
- package/build/serde/TypeInfo.d.mts +0 -2
- package/build/serde/TypeInfo.d.mts.map +1 -1
- package/build/serde/TypeInfo.js +1 -2
- package/build/serde/columns.cjs +1 -2
- package/build/serde/columns.d.cts +2 -4
- package/build/serde/columns.d.cts.map +1 -1
- package/build/serde/columns.d.mts +2 -4
- package/build/serde/columns.d.mts.map +1 -1
- package/build/serde/columns.js +1 -2
- package/build/serde/fieldSerde.cjs +4 -5
- package/build/serde/fieldSerde.d.cts +4 -6
- package/build/serde/fieldSerde.d.cts.map +1 -1
- package/build/serde/fieldSerde.d.mts +4 -6
- package/build/serde/fieldSerde.d.mts.map +1 -1
- package/build/serde/fieldSerde.js +4 -5
- package/build/serde/serde.cjs +4 -5
- package/build/serde/serde.cjs.map +1 -1
- package/build/serde/serde.d.cts +0 -2
- package/build/serde/serde.d.cts.map +1 -1
- package/build/serde/serde.d.mts +0 -2
- package/build/serde/serde.d.mts.map +1 -1
- package/build/serde/serde.js +4 -5
- package/build/serde/temporal.cjs +1 -2
- package/build/serde/temporal.cjs.map +1 -1
- package/build/serde/temporal.d.cts +0 -2
- package/build/serde/temporal.d.cts.map +1 -1
- package/build/serde/temporal.d.mts +0 -2
- package/build/serde/temporal.d.mts.map +1 -1
- package/build/serde/temporal.js +1 -2
- package/build/serde/temporalMappers.cjs +1 -2
- package/build/serde/temporalMappers.d.cts +1 -3
- package/build/serde/temporalMappers.d.cts.map +1 -1
- package/build/serde/temporalMappers.d.mts +1 -3
- package/build/serde/temporalMappers.d.mts.map +1 -1
- package/build/serde/temporalMappers.js +1 -2
- package/build/transitions.cjs +2 -3
- package/build/transitions.d.cts +3 -5
- package/build/transitions.d.cts.map +1 -1
- package/build/transitions.d.mts +3 -5
- package/build/transitions.d.mts.map +1 -1
- package/build/transitions.js +2 -3
- package/build/trusted.cjs +1 -2
- package/build/trusted.cjs.map +1 -1
- package/build/trusted.d.cts +0 -2
- package/build/trusted.d.cts.map +1 -1
- package/build/trusted.d.mts +0 -2
- package/build/trusted.d.mts.map +1 -1
- package/build/trusted.js +1 -2
- package/build/typeMap.cjs +1 -1
- package/build/typeMap.d.cts +1 -3
- package/build/typeMap.d.cts.map +1 -1
- package/build/typeMap.d.mts +1 -3
- package/build/typeMap.d.mts.map +1 -1
- package/build/typeMap.js +1 -1
- package/build/upsert.cjs +7 -8
- package/build/upsert.d.cts +3 -5
- package/build/upsert.d.cts.map +1 -1
- package/build/upsert.d.mts +3 -5
- package/build/upsert.d.mts.map +1 -1
- package/build/upsert.js +7 -8
- package/build/utils.cjs +3 -4
- package/build/utils.d.cts +2 -4
- package/build/utils.d.cts.map +1 -1
- package/build/utils.d.mts +2 -4
- package/build/utils.d.mts.map +1 -1
- package/build/utils.js +3 -4
- package/package.json +6 -6
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const require_queries_ConditionBuilder = require("../queries/ConditionBuilder.cjs");
|
|
5
|
-
const require_queries_find_QueryParser = require("../queries/find/QueryParser.cjs");
|
|
6
|
-
const require_utils = require("../utils.cjs");
|
|
2
|
+
require("../Entity.cjs");
|
|
3
|
+
const require_EntityManager = require("../EntityManager.cjs");
|
|
7
4
|
const require_EntityMetadata = require("../EntityMetadata.cjs");
|
|
5
|
+
const require_keys = require("../keys.cjs");
|
|
6
|
+
require("../plugins/PreloadPlugin.cjs");
|
|
8
7
|
const require_preloading_canPreload = require("./canPreload.cjs");
|
|
9
8
|
const require_preloading_partitionHint = require("./partitionHint.cjs");
|
|
9
|
+
const require_queries_ConditionBuilder = require("../queries/ConditionBuilder.cjs");
|
|
10
|
+
const require_queries_find_QueryParser = require("../queries/find/QueryParser.cjs");
|
|
10
11
|
const require_queries_sql_AliasAssigner = require("../queries/sql/AliasAssigner.cjs");
|
|
11
|
-
require("../
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
//#region src/preloading/JsonAggregatePreloader.ts
|
|
12
|
+
const require_queries_sql_keywords = require("../queries/sql/keywords.cjs");
|
|
13
|
+
const require_utils = require("../utils.cjs");
|
|
14
|
+
// src/preloading/JsonAggregatePreloader.ts
|
|
15
15
|
/**
|
|
16
16
|
* A PreloadPlugin implementation that uses `CROSS LATERAL JOIN` and `json_aggregate`
|
|
17
17
|
* to preload/reduce a subtree of data while still being a single row of data.
|
|
@@ -174,21 +174,22 @@ function calcLateralJoins(assigner, root, tree, parentAlias, parentMeta, pathPre
|
|
|
174
174
|
const { em } = root;
|
|
175
175
|
if (subTree.entitiesKind === "instances" && !subTree.entities.has(root)) return;
|
|
176
176
|
if (subTree.entitiesKind === "ids" && !subTree.entities.has(root.idTagged)) return;
|
|
177
|
+
const api = require_EntityManager.getEmInternalApi(em);
|
|
177
178
|
const children = arrays.map((array) => {
|
|
178
179
|
const taggedId = require_keys.keyToTaggedId(otherMeta, array[m2mOffset]);
|
|
179
180
|
const row = {};
|
|
180
181
|
for (let i = 0; i < columns.length; i++) row[columnNames[i]] = columns[i].mapFromJsonAgg(array[m2mOffset + i]);
|
|
181
|
-
const entity =
|
|
182
|
+
const entity = api.getEntity(taggedId) ?? api.hydrate(otherMeta.cstr, [row], { overwriteExisting: false })[0];
|
|
182
183
|
if (field.kind === "m2m") {
|
|
183
184
|
const m2m = parent[key];
|
|
184
|
-
|
|
185
|
+
api.joinRows(m2m).addPreloadedRow(m2m, field.hasJoinTableId ? array[0] : void 0, parent, entity);
|
|
185
186
|
}
|
|
186
187
|
subJoins.forEach((sub, i) => {
|
|
187
188
|
sub.hydrator(root, entity, array[m2mOffset + columns.length + i] ?? []);
|
|
188
189
|
});
|
|
189
190
|
return entity;
|
|
190
191
|
});
|
|
191
|
-
|
|
192
|
+
api.setPreloadedRelation(parent.idTagged, key, children);
|
|
192
193
|
};
|
|
193
194
|
results.push({
|
|
194
195
|
alias: otherAlias,
|
|
@@ -274,7 +275,6 @@ function calcEnumLateralJoin(assigner, root, subTree, parentAlias, field, key, p
|
|
|
274
275
|
function readRowValue(rows, rowIndex, columnName) {
|
|
275
276
|
return Array.isArray(rows) ? rows[rowIndex][columnName] : rows.get(rowIndex, columnName);
|
|
276
277
|
}
|
|
277
|
-
//#endregion
|
|
278
278
|
exports.JsonAggregatePreloader = JsonAggregatePreloader;
|
|
279
279
|
|
|
280
280
|
//# sourceMappingURL=JsonAggregatePreloader.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonAggregatePreloader.cjs","names":["partitionHint","AliasAssigner","getTables","kqDot","kq","canPreload","ConditionBuilder","fail","keyToNumber","keyToTaggedId","getMetadataForField","getMetadata","getEmInternalApi"],"sources":["../../src/preloading/JsonAggregatePreloader.ts"],"sourcesContent":["import { type Entity } from \"src/Entity.ts\";\nimport { getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, type ManyToManyEnumField, getMetadata, getMetadataForField } from \"src/EntityMetadata.ts\";\nimport type { ManyToManyLike } from \"src/flush/JoinRows.ts\";\nimport { keyToNumber, keyToTaggedId } from \"src/keys.ts\";\nimport type { EntityOrId, HintNode } from \"src/loading/HintTree.ts\";\nimport type { LoadHint, NestedLoadHint } from \"src/loading/loadHints.ts\";\nimport { type JoinResult, type PreloadHydrator, type PreloadPlugin } from \"src/plugins/PreloadPlugin.ts\";\nimport { canPreload } from \"src/preloading/canPreload.ts\";\nimport { partitionHint } from \"src/preloading/partitionHint.ts\";\nimport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nimport {\n type JoinTable,\n type LateralJoinTable,\n type ParsedFindQuery,\n getTables,\n} from \"src/queries/find/QueryParser.ts\";\nimport { AliasAssigner } from \"src/queries/sql/AliasAssigner.ts\";\nimport { kq, kqDot } from \"src/queries/sql/keywords.ts\";\nimport { type RowData } from \"src/RowData.ts\";\nimport { fail } from \"src/utils.ts\";\n\n/**\n * A PreloadPlugin implementation that uses `CROSS LATERAL JOIN` and `json_aggregate`\n * to preload/reduce a subtree of data while still being a single row of data.\n */\nexport class JsonAggregatePreloader implements PreloadPlugin {\n partitionHint(\n meta: EntityMetadata | undefined,\n hint: LoadHint<any>,\n ): [NestedLoadHint<any> | undefined, NestedLoadHint<any> | undefined] {\n return partitionHint(meta, hint);\n }\n\n addPreloading<T extends Entity>(\n meta: EntityMetadata,\n root: HintNode<T>,\n query: ParsedFindQuery,\n ): PreloadHydrator | undefined {\n const assigner = new AliasAssigner(query);\n\n // Get the existing primary alias\n const alias = getTables(query)[0].alias;\n const joins = calcLateralJoins(assigner, { tree: root, alias, meta }, root, alias, meta);\n // If there are no sql-based preload in the hints, just return\n if (joins.length === 0) return undefined;\n\n // Include the aggregate `_b1._ as _prequel`, `_c._ as _randomComment`\n for (const { alias, relationAlias, join } of joins) {\n query.selects.push({\n sql: `${kqDot(alias, \"_\")} as ${kq(relationAlias)}`,\n aliases: [alias],\n bindings: [],\n });\n query.tables.push(join);\n }\n\n return (rows, entities) => {\n for (let i = 0; i < entities.length; i++) {\n const parent = entities[i];\n for (const { relationAlias, hydrator } of joins) {\n hydrator(parent, parent, readRowValue(rows, i, relationAlias) ?? []);\n }\n }\n };\n }\n\n getPreloadJoins<T extends Entity>(meta: EntityMetadata, root: HintNode<T>, query: ParsedFindQuery): JoinResult[] {\n const assigner = new AliasAssigner(query);\n\n // Get the existing primary alias\n const alias = getTables(query)[0].alias;\n const joins = calcLateralJoins(assigner, { tree: root, alias, meta }, root, alias, meta);\n // If there are no sql-based preload in the hints, just return\n\n // Adapt our json aggregate joins to the higher-level JoinResult\n return joins.map((join) => {\n return {\n selects: [{ value: kqDot(join.alias, \"_\"), as: join.relationAlias }],\n join: join.join,\n hydrator: (rows, entities) => {\n for (let i = 0; i < entities.length; i++) {\n const parent = entities[i];\n join.hydrator(parent, parent, readRowValue(rows, i, join.relationAlias) ?? []);\n }\n },\n };\n });\n }\n}\n\n/** Decodes an array-of-arrays of children entries, and stores them the `parent`'s relation. */\ntype AggregateJsonHydrator = (root: Entity, parent: Entity, arrays: unknown[][]) => void;\n\n/**\n * For a given hint tree `hint`, finds all SQL-able relations and preloads them.\n *\n * Specifically we use `json_agg` & `json_build_array` to `CROSS LATERAL JOIN`\n * children/grand children back as arbitrarily-deeply nested arrays, and then\n * stash the results in the `EntityManager` `joinLoadedRelations` cache, which\n * each join-instrumented relation will check before making its SQL calls.\n *\n * https://sqlfum.pt/?n=60&indent=2&spaces=1&simplify=1&align=0&case=lower&sql=c2VsZWN0IGEuaWQsIGIuXyBhcyBiLCBjMS5fIGFzIGMxLCBhMS5fIGFzIGExIGZyb20gYXV0aG9ycyBhIGNyb3NzIGpvaW4gbGF0ZXJhbCAoIHNlbGVjdCBqc29uX2FnZyhqc29uX2J1aWxkX2FycmF5KGIuaWQsIGIudGl0bGUsIGIuIm9yZGVyIiwgYi5kZWxldGVkX2F0LCBiLmNyZWF0ZWRfYXQsIGIudXBkYXRlZF9hdCwgYi5hdXRob3JfaWQsIGJyLl8pKSBhcyBfIGZyb20gYm9va3MgYiBjcm9zcyBqb2luIGxhdGVyYWwgKCBzZWxlY3QganNvbl9hZ2coanNvbl9idWlsZF9hcnJheShici5pZCwgYnIucmF0aW5nLCB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GExLmJvb2tfY29tbWVudHMsIGExLmlzX3BvcHVsYXIsIGExLmFnZSwgYTEuZ3JhZHVhdGVkLCBhMS5uaWNrX25hbWVzLCBhMS53YXNfZXZlcl9wb3B1bGFyLCBhMS5hZGRyZXNzLCBhMS5idXNpbmVzc19hZGRyZXNzLCBhMS5xdW90ZXMsIGExLm51bWJlcl9vZl9hdG9tcywgYTEuZGVsZXRlZF9hdCwgYTEubnVtYmVyX29mX3B1YmxpY19yZXZpZXdzLCBhMS4ibnVtYmVyT2ZQdWJsaWNSZXZpZXdzMiIsIGExLnRhZ3Nfb2ZfYWxsX2Jvb2tzLCBhMS5jcmVhdGVkX2F0LCBhMS51cGRhdGVkX2F0LCBhMS5mYXZvcml0ZV9zaGFwZSwgYTEuZmF2b3JpdGVfY29sb3JzLCBhMS5tZW50b3JfaWQsIGExLmN1cnJlbnRfZHJhZnRfYm9va19pZCwgYTEuZmF2b3JpdGVfYm9va19pZCwgYTEucHVibGlzaGVyX2lkKSkgYXMgXyBmcm9tIGF1dGhvcnMgYTEgd2hlcmUgYTEuaWQgPSBhLm1lbnRvcl9pZCApIGExIHdoZXJlIGEuaWQgPSAxOw%3D%3D\n */\n\n/**\n * Given a `parent` like Author, and a hint of `{ books: ..., comments: ... }`, create `CROSS JOIN LATERAL`s\n * that will pull in the `books` & `comments` children.\n */\nfunction calcLateralJoins<I extends EntityOrId>(\n assigner: AliasAssigner,\n root: { tree: HintNode<I>; alias: string; meta: EntityMetadata },\n tree: HintNode<I>,\n parentAlias: string,\n parentMeta: EntityMetadata,\n pathPrefix: string = \"\",\n): AggregateJoinResult[] {\n const results: AggregateJoinResult[] = [];\n\n // Join in SQL-able hints from parent\n Object.entries(tree.hints).forEach(([key, subTree]) => {\n const field = parentMeta.allFields[key];\n // AsyncProperties don't have fields, which is fine, skip for now...\n if (field && canPreload(parentMeta, field)) {\n // Enum m2ms have no \"other\" entity to join/hydrate; just aggregate the join table's enum ids.\n if (field.kind === \"m2mEnum\") {\n results.push(calcEnumLateralJoin(assigner, root, subTree, parentAlias, field, key, pathPrefix));\n return;\n }\n const otherMeta = field.otherMetadata();\n const otherField = otherMeta.allFields[field.otherFieldName];\n\n // Short table alias for column refs inside the subquery, e.g. `_b1`\n const otherAlias = `_${assigner.getAlias(otherMeta.tableName)}`;\n // Readable path-based column alias for the outer AS clause, e.g. `_books_reviews`\n const pathKey = key.toLowerCase();\n const relationAlias = `_${assigner.getLiteralAlias(`${pathPrefix}${pathKey}`)}`;\n\n // Do the recursion up-front, so we can work it into our own join/hydrator\n const subJoins = calcLateralJoins(assigner, root, subTree, otherAlias, otherMeta, `${pathPrefix}${pathKey}_`);\n\n // Get all fields with serdes and flatten out the columns, skipping `lazy` columns (fetched on-demand)\n const columns = Object.values(otherMeta.allFields)\n .filter((f) => f.serde && !(f.kind === \"primitive\" && f.lazy))\n .flatMap((f) => f.serde!.columns);\n const selects = [\n ...columns.map((c) => kqDot(otherAlias, c.columnName)),\n // We eventually need to handle parent types/subtypes here...\n // Combine any grandchilden\n ...subJoins.map((sb) => kqDot(sb.alias, \"_\")),\n ];\n\n const aliasMaybeSuffix = kq(`${parentAlias}${field.aliasSuffix}`);\n\n const cb = new ConditionBuilder();\n let m2mTable: JoinTable | undefined;\n let m2mAlias: string | undefined;\n if (otherField.kind === \"m2o\") {\n cb.addRawCondition({\n aliases: [otherAlias, parentAlias],\n condition: `${kqDot(otherAlias, otherField.serde.columns[0].columnName)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"poly\") {\n // Get the component that points to us\n // const comp = otherField.components.find((c) => getAllMetas(parentMeta).some((m) => m.cstr === c.otherMetadata().cstr)) ??\n const comp =\n otherField.components.find((c) => parentMeta.cstr === c.otherMetadata().cstr) ??\n fail(`No component found for ${field.fieldName} -> ${otherField.fieldName}`);\n cb.addRawCondition({\n aliases: [otherAlias, parentAlias],\n condition: `${kqDot(otherAlias, comp.columnName)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"o2m\" || otherField.kind === \"lo2m\") {\n cb.addRawCondition({\n aliases: [otherAlias, aliasMaybeSuffix],\n condition: `${kqDot(otherAlias, \"id\")} = ${aliasMaybeSuffix}.${kq(field.serde!.columns[0].columnName)}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"o2o\") {\n cb.addRawCondition({\n aliases: [otherAlias, aliasMaybeSuffix],\n condition: `${kqDot(otherAlias, \"id\")} = ${aliasMaybeSuffix}.${kq(field.serde!.columns[0].columnName)}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"m2m\") {\n m2mAlias = assigner.getAlias(otherField.joinTableName);\n // Get the m2m row's id to track in JoinRows; id-less tables have no surrogate id.\n if (otherField.hasJoinTableId) selects.unshift(kqDot(m2mAlias, \"id\"));\n m2mTable = {\n join: \"inner\",\n table: otherField.joinTableName,\n alias: m2mAlias,\n col1: kqDot(parentAlias, \"id\"),\n col2: kqDot(m2mAlias, otherField.columnNames[1]),\n };\n cb.addRawCondition({\n aliases: [m2mAlias, otherAlias],\n condition: `${kqDot(m2mAlias, otherField.columnNames[0])} = ${kqDot(otherAlias, \"id\")}`,\n pruneable: true,\n });\n } else {\n throw new Error(`Unsupported otherField.kind ${otherField.kind}`);\n }\n\n const needsSubSelect = subTree.entities.size !== root.tree.entities.size;\n if (needsSubSelect) {\n cb.addRawCondition({\n aliases: [root.alias],\n condition: `${kqDot(root.alias, \"id\")} = ANY(?)`,\n bindings: [\n [...subTree.entities]\n .filter((e) => typeof e === \"string\" || !e.isNewEntity)\n .map((e) => keyToNumber(root.meta, typeof e === \"string\" ? e : e.id)),\n ],\n pruneable: true,\n });\n }\n\n // For m2m, order by the join-row's id so preloaded results match the order the lazy batch\n // loader returns (which orders by join-row id). Id-less join tables have no surrogate id,\n // so order by the other entity's FK column (matching the lazy loader & getOthers). Otherwise,\n // order by the target entity's id.\n const orderBy =\n otherField.kind === \"m2m\" && !otherField.hasJoinTableId\n ? `${kq(m2mAlias!)}.${kq(otherField.columnNames[0])}`\n : `${kq(m2mAlias ?? otherAlias)}.id`;\n\n const join: LateralJoinTable = {\n join: \"lateral\",\n alias: otherAlias,\n // Do we need to say which alias we're coming from, to avoid having it pruned?\n // ...maybe not because preloading is always on the primary table?\n fromAlias: \"unset\",\n table: otherMeta.tableName,\n query: {\n selects: [`json_agg(json_build_array(${selects.join(\", \")}) order by ${orderBy}) as _`],\n tables: [\n { join: \"primary\", table: otherMeta.tableName, alias: otherAlias },\n ...(m2mTable ? [m2mTable] : []),\n ...subJoins.map((sj) => sj.join),\n ],\n condition: cb.toExpressionFilter(),\n orderBys: [],\n },\n };\n\n // Pre-compute column names so we don't re-read them per entity\n const columnNames = columns.map((c) => c.columnName);\n // If we've snuck the m2m row id into the json array, ignore it (id-less tables have no id)\n const m2mOffset = field.kind === \"m2m\" && field.hasJoinTableId ? 1 : 0;\n\n const hydrator: AggregateJsonHydrator = (root, parent, arrays) => {\n const { em } = root;\n\n // If we had overlapping load hints, i.e. `author.books` for [a1, a2] and `author.comments` for [a1], and\n // we're processing the arrays of comments, but for a root author like `a2` that didn't ask for our load\n // hint, then skip it to keep the relation unloaded.\n if (subTree.entitiesKind === \"instances\" && !subTree.entities.has(root as any)) return;\n if (subTree.entitiesKind === \"ids\" && !subTree.entities.has(root.idTagged as any)) return;\n\n // We get back an array of [[1, title], [2, title], [3, title]]\n const children = arrays.map((array) => {\n const taggedId = keyToTaggedId(otherMeta, array[m2mOffset] as any)!;\n const row: Record<string, any> = {};\n for (let i = 0; i < columns.length; i++) {\n row[columnNames[i]] = columns[i].mapFromJsonAgg(array[m2mOffset + i]);\n }\n const entity =\n em.findExistingInstance<Entity>(taggedId) ??\n (em.hydrate(otherMeta.cstr, [row], { overwriteExisting: false }) as Entity[])[0];\n // Tell the internal JoinRow booking-keeping about this m2m row\n if (field.kind === \"m2m\") {\n // TODO This `addExisting` needs to be pulled up, out of the `arrays.map`, so we can do a `loadRows`-ish\n // call that passes all now-known m2m rows into JoinRows as a single list, so that it can mark any\n // deleted-from-under-us m2m rows as deleted.\n const m2m = (parent as any)[key];\n getEmInternalApi(em)\n .joinRows(m2m)\n .addPreloadedRow(m2m, field.hasJoinTableId ? (array[0] as any) : undefined, parent, entity);\n }\n // Within each child, look for grandchildren\n subJoins.forEach((sub, i) => {\n // array[i] could be null if there are no grandchildren, but still call `sub` to\n // process it so that we store the empty array into the em.joinLoadedRelations, to\n // avoid the relation.load method later doing a SQL for rows we know are not there.\n sub.hydrator(root, entity, (array[m2mOffset + columns.length + i] as any) ?? []);\n });\n return entity;\n });\n // Cache the entities so `.load`s will see them\n getEmInternalApi(em).setPreloadedRelation(parent.idTagged, key, children);\n };\n\n results.push({ alias: otherAlias, relationAlias, join, hydrator });\n }\n });\n\n return results;\n}\n\n/**\n * Builds the `CROSS JOIN LATERAL` that aggregates an enum-m2m join table (e.g. `publisher_logo_colors`)\n * into a json array of enum ids, e.g. `[[1], [3]]` (or `[[1, id], [3, id]]` for id-ful join tables).\n */\nfunction calcEnumLateralJoin<I extends EntityOrId>(\n assigner: AliasAssigner,\n root: { tree: HintNode<I>; alias: string; meta: EntityMetadata },\n subTree: HintNode<I>,\n parentAlias: string,\n field: ManyToManyEnumField,\n key: string,\n pathPrefix: string,\n): AggregateJoinResult {\n const [entityColumn, enumColumn] = field.columnNames;\n const jtAlias = `_${assigner.getAlias(field.joinTableName)}`;\n const relationAlias = `_${assigner.getLiteralAlias(`${pathPrefix}${key.toLowerCase()}`)}`;\n\n const parts = [kqDot(jtAlias, enumColumn)];\n if (field.hasJoinTableId) parts.push(kqDot(jtAlias, \"id\"));\n\n const cb = new ConditionBuilder();\n cb.addRawCondition({\n aliases: [jtAlias, parentAlias],\n condition: `${kqDot(jtAlias, entityColumn)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n\n const needsSubSelect = subTree.entities.size !== root.tree.entities.size;\n if (needsSubSelect) {\n cb.addRawCondition({\n aliases: [root.alias],\n condition: `${kqDot(root.alias, \"id\")} = ANY(?)`,\n bindings: [\n [...subTree.entities]\n .filter((e) => typeof e === \"string\" || !e.isNewEntity)\n .map((e) => keyToNumber(root.meta, typeof e === \"string\" ? e : e.id)),\n ],\n pruneable: true,\n });\n }\n\n const orderBy = `${kq(jtAlias)}.${kq(field.hasJoinTableId ? \"id\" : enumColumn)}`;\n const join: LateralJoinTable = {\n join: \"lateral\",\n alias: jtAlias,\n fromAlias: \"unset\",\n table: field.joinTableName,\n query: {\n selects: [`json_agg(json_build_array(${parts.join(\", \")}) order by ${orderBy}) as _`],\n tables: [{ join: \"primary\", table: field.joinTableName, alias: jtAlias }],\n condition: cb.toExpressionFilter(),\n orderBys: [],\n },\n };\n\n const hydrator: AggregateJsonHydrator = (root, parent, arrays) => {\n const { em } = root;\n if (subTree.entitiesKind === \"instances\" && !subTree.entities.has(root as any)) return;\n if (subTree.entitiesKind === \"ids\" && !subTree.entities.has(root.idTagged as any)) return;\n const like: ManyToManyLike = {\n entity: parent,\n joinTableName: field.joinTableName,\n columnName: entityColumn,\n otherColumnName: enumColumn,\n fieldName: key,\n meta: getMetadataForField(getMetadata(parent), key),\n otherEnum: field.enumDetailType,\n hasJoinTableId: field.hasJoinTableId,\n };\n const api = getEmInternalApi(em);\n const joinRows = api.joinRows(like);\n const codes: any[] = [];\n for (const array of arrays) {\n const enumId = array[0] as number;\n joinRows.addPreloadedRow(like, field.hasJoinTableId ? (array[1] as number) : undefined, parent, enumId);\n codes.push(field.enumDetailType.findById(enumId)!.code);\n }\n api.setPreloadedRelation(parent.idTagged, key, codes);\n };\n\n return { alias: jtAlias, relationAlias, join, hydrator };\n}\n\n/** A preload-loadable join for a given child, with potentially grand-child joins contained within it. */\ntype AggregateJoinResult = {\n /** The short table alias used for column references inside the subquery, e.g. `_b1`. */\n alias: string;\n /** The readable relation-name alias used in the outer `AS` clause, e.g. `_prequel`. */\n relationAlias: string;\n /** The SQL for this child's lateral join, which itself might have recursive lateral joins. */\n join: LateralJoinTable;\n /** The hydrator for this child's lateral join, which itself might recursively hydrator subjoins. */\n hydrator: AggregateJsonHydrator;\n};\n\n/** Reads one column from either classic POJO rows or a lazy `RowData` result. */\nfunction readRowValue(rows: any[] | RowData, rowIndex: number, columnName: string): any {\n return Array.isArray(rows) ? rows[rowIndex][columnName] : rows.get(rowIndex, columnName);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAa,yBAAb,MAA6D;CAC3D,cACE,MACA,MACoE;EACpE,OAAOA,iCAAAA,cAAc,MAAM,IAAI;CACjC;CAEA,cACE,MACA,MACA,OAC6B;EAC7B,MAAM,WAAW,IAAIC,kCAAAA,cAAc,KAAK;EAGxC,MAAM,QAAQC,iCAAAA,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;EAClC,MAAM,QAAQ,iBAAiB,UAAU;GAAE,MAAM;GAAM;GAAO;EAAK,GAAG,MAAM,OAAO,IAAI;EAEvF,IAAI,MAAM,WAAW,GAAG,OAAO,KAAA;EAG/B,KAAK,MAAM,EAAE,OAAO,eAAe,UAAU,OAAO;GAClD,MAAM,QAAQ,KAAK;IACjB,KAAK,GAAGC,6BAAAA,MAAM,OAAO,GAAG,EAAE,MAAMC,6BAAAA,GAAG,aAAa;IAChD,SAAS,CAAC,KAAK;IACf,UAAU,CAAC;GACb,CAAC;GACD,MAAM,OAAO,KAAK,IAAI;EACxB;EAEA,QAAQ,MAAM,aAAa;GACzB,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;IACxC,MAAM,SAAS,SAAS;IACxB,KAAK,MAAM,EAAE,eAAe,cAAc,OACxC,SAAS,QAAQ,QAAQ,aAAa,MAAM,GAAG,aAAa,KAAK,CAAC,CAAC;GAEvE;EACF;CACF;CAEA,gBAAkC,MAAsB,MAAmB,OAAsC;EAC/G,MAAM,WAAW,IAAIH,kCAAAA,cAAc,KAAK;EAGxC,MAAM,QAAQC,iCAAAA,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;EAKlC,OAJc,iBAAiB,UAAU;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,SAAS,CAAC,cAAc,KAAK,IAAI,UAAU,UAAU;AACzF"}
|
|
1
|
+
{"version":3,"file":"JsonAggregatePreloader.cjs","names":["partitionHint","AliasAssigner","getTables","kqDot","kq","canPreload","ConditionBuilder","fail","keyToNumber","getEmInternalApi","keyToTaggedId","getMetadataForField","getMetadata"],"sources":["../../src/preloading/JsonAggregatePreloader.ts"],"sourcesContent":["import { type Entity } from \"src/Entity.ts\";\nimport { getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, type ManyToManyEnumField, getMetadata, getMetadataForField } from \"src/EntityMetadata.ts\";\nimport type { ManyToManyLike } from \"src/flush/JoinRows.ts\";\nimport { keyToNumber, keyToTaggedId } from \"src/keys.ts\";\nimport type { EntityOrId, HintNode } from \"src/loading/HintTree.ts\";\nimport type { LoadHint, NestedLoadHint } from \"src/loading/loadHints.ts\";\nimport { type JoinResult, type PreloadHydrator, type PreloadPlugin } from \"src/plugins/PreloadPlugin.ts\";\nimport { canPreload } from \"src/preloading/canPreload.ts\";\nimport { partitionHint } from \"src/preloading/partitionHint.ts\";\nimport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nimport {\n type JoinTable,\n type LateralJoinTable,\n type ParsedFindQuery,\n getTables,\n} from \"src/queries/find/QueryParser.ts\";\nimport { AliasAssigner } from \"src/queries/sql/AliasAssigner.ts\";\nimport { kq, kqDot } from \"src/queries/sql/keywords.ts\";\nimport { type RowData } from \"src/RowData.ts\";\nimport { fail } from \"src/utils.ts\";\n\n/**\n * A PreloadPlugin implementation that uses `CROSS LATERAL JOIN` and `json_aggregate`\n * to preload/reduce a subtree of data while still being a single row of data.\n */\nexport class JsonAggregatePreloader implements PreloadPlugin {\n partitionHint(\n meta: EntityMetadata | undefined,\n hint: LoadHint<any>,\n ): [NestedLoadHint<any> | undefined, NestedLoadHint<any> | undefined] {\n return partitionHint(meta, hint);\n }\n\n addPreloading<T extends Entity>(\n meta: EntityMetadata,\n root: HintNode<T>,\n query: ParsedFindQuery,\n ): PreloadHydrator | undefined {\n const assigner = new AliasAssigner(query);\n\n // Get the existing primary alias\n const alias = getTables(query)[0].alias;\n const joins = calcLateralJoins(assigner, { tree: root, alias, meta }, root, alias, meta);\n // If there are no sql-based preload in the hints, just return\n if (joins.length === 0) return undefined;\n\n // Include the aggregate `_b1._ as _prequel`, `_c._ as _randomComment`\n for (const { alias, relationAlias, join } of joins) {\n query.selects.push({\n sql: `${kqDot(alias, \"_\")} as ${kq(relationAlias)}`,\n aliases: [alias],\n bindings: [],\n });\n query.tables.push(join);\n }\n\n return (rows, entities) => {\n for (let i = 0; i < entities.length; i++) {\n const parent = entities[i];\n for (const { relationAlias, hydrator } of joins) {\n hydrator(parent, parent, readRowValue(rows, i, relationAlias) ?? []);\n }\n }\n };\n }\n\n getPreloadJoins<T extends Entity>(meta: EntityMetadata, root: HintNode<T>, query: ParsedFindQuery): JoinResult[] {\n const assigner = new AliasAssigner(query);\n\n // Get the existing primary alias\n const alias = getTables(query)[0].alias;\n const joins = calcLateralJoins(assigner, { tree: root, alias, meta }, root, alias, meta);\n // If there are no sql-based preload in the hints, just return\n\n // Adapt our json aggregate joins to the higher-level JoinResult\n return joins.map((join) => {\n return {\n selects: [{ value: kqDot(join.alias, \"_\"), as: join.relationAlias }],\n join: join.join,\n hydrator: (rows, entities) => {\n for (let i = 0; i < entities.length; i++) {\n const parent = entities[i];\n join.hydrator(parent, parent, readRowValue(rows, i, join.relationAlias) ?? []);\n }\n },\n };\n });\n }\n}\n\n/** Decodes an array-of-arrays of children entries, and stores them the `parent`'s relation. */\ntype AggregateJsonHydrator = (root: Entity, parent: Entity, arrays: unknown[][]) => void;\n\n/**\n * For a given hint tree `hint`, finds all SQL-able relations and preloads them.\n *\n * Specifically we use `json_agg` & `json_build_array` to `CROSS LATERAL JOIN`\n * children/grand children back as arbitrarily-deeply nested arrays, and then\n * stash the results in the `EntityManager` `joinLoadedRelations` cache, which\n * each join-instrumented relation will check before making its SQL calls.\n *\n * https://sqlf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**\n * Given a `parent` like Author, and a hint of `{ books: ..., comments: ... }`, create `CROSS JOIN LATERAL`s\n * that will pull in the `books` & `comments` children.\n */\nfunction calcLateralJoins<I extends EntityOrId>(\n assigner: AliasAssigner,\n root: { tree: HintNode<I>; alias: string; meta: EntityMetadata },\n tree: HintNode<I>,\n parentAlias: string,\n parentMeta: EntityMetadata,\n pathPrefix: string = \"\",\n): AggregateJoinResult[] {\n const results: AggregateJoinResult[] = [];\n\n // Join in SQL-able hints from parent\n Object.entries(tree.hints).forEach(([key, subTree]) => {\n const field = parentMeta.allFields[key];\n // AsyncProperties don't have fields, which is fine, skip for now...\n if (field && canPreload(parentMeta, field)) {\n // Enum m2ms have no \"other\" entity to join/hydrate; just aggregate the join table's enum ids.\n if (field.kind === \"m2mEnum\") {\n results.push(calcEnumLateralJoin(assigner, root, subTree, parentAlias, field, key, pathPrefix));\n return;\n }\n const otherMeta = field.otherMetadata();\n const otherField = otherMeta.allFields[field.otherFieldName];\n\n // Short table alias for column refs inside the subquery, e.g. `_b1`\n const otherAlias = `_${assigner.getAlias(otherMeta.tableName)}`;\n // Readable path-based column alias for the outer AS clause, e.g. `_books_reviews`\n const pathKey = key.toLowerCase();\n const relationAlias = `_${assigner.getLiteralAlias(`${pathPrefix}${pathKey}`)}`;\n\n // Do the recursion up-front, so we can work it into our own join/hydrator\n const subJoins = calcLateralJoins(assigner, root, subTree, otherAlias, otherMeta, `${pathPrefix}${pathKey}_`);\n\n // Get all fields with serdes and flatten out the columns, skipping `lazy` columns (fetched on-demand)\n const columns = Object.values(otherMeta.allFields)\n .filter((f) => f.serde && !(f.kind === \"primitive\" && f.lazy))\n .flatMap((f) => f.serde!.columns);\n const selects = [\n ...columns.map((c) => kqDot(otherAlias, c.columnName)),\n // We eventually need to handle parent types/subtypes here...\n // Combine any grandchilden\n ...subJoins.map((sb) => kqDot(sb.alias, \"_\")),\n ];\n\n const aliasMaybeSuffix = kq(`${parentAlias}${field.aliasSuffix}`);\n\n const cb = new ConditionBuilder();\n let m2mTable: JoinTable | undefined;\n let m2mAlias: string | undefined;\n if (otherField.kind === \"m2o\") {\n cb.addRawCondition({\n aliases: [otherAlias, parentAlias],\n condition: `${kqDot(otherAlias, otherField.serde.columns[0].columnName)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"poly\") {\n // Get the component that points to us\n // const comp = otherField.components.find((c) => getAllMetas(parentMeta).some((m) => m.cstr === c.otherMetadata().cstr)) ??\n const comp =\n otherField.components.find((c) => parentMeta.cstr === c.otherMetadata().cstr) ??\n fail(`No component found for ${field.fieldName} -> ${otherField.fieldName}`);\n cb.addRawCondition({\n aliases: [otherAlias, parentAlias],\n condition: `${kqDot(otherAlias, comp.columnName)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"o2m\" || otherField.kind === \"lo2m\") {\n cb.addRawCondition({\n aliases: [otherAlias, aliasMaybeSuffix],\n condition: `${kqDot(otherAlias, \"id\")} = ${aliasMaybeSuffix}.${kq(field.serde!.columns[0].columnName)}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"o2o\") {\n cb.addRawCondition({\n aliases: [otherAlias, aliasMaybeSuffix],\n condition: `${kqDot(otherAlias, \"id\")} = ${aliasMaybeSuffix}.${kq(field.serde!.columns[0].columnName)}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"m2m\") {\n m2mAlias = assigner.getAlias(otherField.joinTableName);\n // Get the m2m row's id to track in JoinRows; id-less tables have no surrogate id.\n if (otherField.hasJoinTableId) selects.unshift(kqDot(m2mAlias, \"id\"));\n m2mTable = {\n join: \"inner\",\n table: otherField.joinTableName,\n alias: m2mAlias,\n col1: kqDot(parentAlias, \"id\"),\n col2: kqDot(m2mAlias, otherField.columnNames[1]),\n };\n cb.addRawCondition({\n aliases: [m2mAlias, otherAlias],\n condition: `${kqDot(m2mAlias, otherField.columnNames[0])} = ${kqDot(otherAlias, \"id\")}`,\n pruneable: true,\n });\n } else {\n throw new Error(`Unsupported otherField.kind ${otherField.kind}`);\n }\n\n const needsSubSelect = subTree.entities.size !== root.tree.entities.size;\n if (needsSubSelect) {\n cb.addRawCondition({\n aliases: [root.alias],\n condition: `${kqDot(root.alias, \"id\")} = ANY(?)`,\n bindings: [\n [...subTree.entities]\n .filter((e) => typeof e === \"string\" || !e.isNewEntity)\n .map((e) => keyToNumber(root.meta, typeof e === \"string\" ? e : e.id)),\n ],\n pruneable: true,\n });\n }\n\n // For m2m, order by the join-row's id so preloaded results match the order the lazy batch\n // loader returns (which orders by join-row id). Id-less join tables have no surrogate id,\n // so order by the other entity's FK column (matching the lazy loader & getOthers). Otherwise,\n // order by the target entity's id.\n const orderBy =\n otherField.kind === \"m2m\" && !otherField.hasJoinTableId\n ? `${kq(m2mAlias!)}.${kq(otherField.columnNames[0])}`\n : `${kq(m2mAlias ?? otherAlias)}.id`;\n\n const join: LateralJoinTable = {\n join: \"lateral\",\n alias: otherAlias,\n // Do we need to say which alias we're coming from, to avoid having it pruned?\n // ...maybe not because preloading is always on the primary table?\n fromAlias: \"unset\",\n table: otherMeta.tableName,\n query: {\n selects: [`json_agg(json_build_array(${selects.join(\", \")}) order by ${orderBy}) as _`],\n tables: [\n { join: \"primary\", table: otherMeta.tableName, alias: otherAlias },\n ...(m2mTable ? [m2mTable] : []),\n ...subJoins.map((sj) => sj.join),\n ],\n condition: cb.toExpressionFilter(),\n orderBys: [],\n },\n };\n\n // Pre-compute column names so we don't re-read them per entity\n const columnNames = columns.map((c) => c.columnName);\n // If we've snuck the m2m row id into the json array, ignore it (id-less tables have no id)\n const m2mOffset = field.kind === \"m2m\" && field.hasJoinTableId ? 1 : 0;\n\n const hydrator: AggregateJsonHydrator = (root, parent, arrays) => {\n const { em } = root;\n\n // If we had overlapping load hints, i.e. `author.books` for [a1, a2] and `author.comments` for [a1], and\n // we're processing the arrays of comments, but for a root author like `a2` that didn't ask for our load\n // hint, then skip it to keep the relation unloaded.\n if (subTree.entitiesKind === \"instances\" && !subTree.entities.has(root as any)) return;\n if (subTree.entitiesKind === \"ids\" && !subTree.entities.has(root.idTagged as any)) return;\n\n // We get back an array of [[1, title], [2, title], [3, title]]\n const api = getEmInternalApi(em);\n const children = arrays.map((array) => {\n const taggedId = keyToTaggedId(otherMeta, array[m2mOffset] as any)!;\n const row: Record<string, any> = {};\n for (let i = 0; i < columns.length; i++) {\n row[columnNames[i]] = columns[i].mapFromJsonAgg(array[m2mOffset + i]);\n }\n const entity =\n api.getEntity(taggedId) ??\n (api.hydrate(otherMeta.cstr, [row], { overwriteExisting: false }) as Entity[])[0];\n // Tell the internal JoinRow booking-keeping about this m2m row\n if (field.kind === \"m2m\") {\n // TODO This `addExisting` needs to be pulled up, out of the `arrays.map`, so we can do a `loadRows`-ish\n // call that passes all now-known m2m rows into JoinRows as a single list, so that it can mark any\n // deleted-from-under-us m2m rows as deleted.\n const m2m = (parent as any)[key];\n api\n .joinRows(m2m)\n .addPreloadedRow(m2m, field.hasJoinTableId ? (array[0] as any) : undefined, parent, entity);\n }\n // Within each child, look for grandchildren\n subJoins.forEach((sub, i) => {\n // array[i] could be null if there are no grandchildren, but still call `sub` to\n // process it so that we store the empty array into the em.joinLoadedRelations, to\n // avoid the relation.load method later doing a SQL for rows we know are not there.\n sub.hydrator(root, entity, (array[m2mOffset + columns.length + i] as any) ?? []);\n });\n return entity;\n });\n // Cache the entities so `.load`s will see them\n api.setPreloadedRelation(parent.idTagged, key, children);\n };\n\n results.push({ alias: otherAlias, relationAlias, join, hydrator });\n }\n });\n\n return results;\n}\n\n/**\n * Builds the `CROSS JOIN LATERAL` that aggregates an enum-m2m join table (e.g. `publisher_logo_colors`)\n * into a json array of enum ids, e.g. `[[1], [3]]` (or `[[1, id], [3, id]]` for id-ful join tables).\n */\nfunction calcEnumLateralJoin<I extends EntityOrId>(\n assigner: AliasAssigner,\n root: { tree: HintNode<I>; alias: string; meta: EntityMetadata },\n subTree: HintNode<I>,\n parentAlias: string,\n field: ManyToManyEnumField,\n key: string,\n pathPrefix: string,\n): AggregateJoinResult {\n const [entityColumn, enumColumn] = field.columnNames;\n const jtAlias = `_${assigner.getAlias(field.joinTableName)}`;\n const relationAlias = `_${assigner.getLiteralAlias(`${pathPrefix}${key.toLowerCase()}`)}`;\n\n const parts = [kqDot(jtAlias, enumColumn)];\n if (field.hasJoinTableId) parts.push(kqDot(jtAlias, \"id\"));\n\n const cb = new ConditionBuilder();\n cb.addRawCondition({\n aliases: [jtAlias, parentAlias],\n condition: `${kqDot(jtAlias, entityColumn)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n\n const needsSubSelect = subTree.entities.size !== root.tree.entities.size;\n if (needsSubSelect) {\n cb.addRawCondition({\n aliases: [root.alias],\n condition: `${kqDot(root.alias, \"id\")} = ANY(?)`,\n bindings: [\n [...subTree.entities]\n .filter((e) => typeof e === \"string\" || !e.isNewEntity)\n .map((e) => keyToNumber(root.meta, typeof e === \"string\" ? e : e.id)),\n ],\n pruneable: true,\n });\n }\n\n const orderBy = `${kq(jtAlias)}.${kq(field.hasJoinTableId ? \"id\" : enumColumn)}`;\n const join: LateralJoinTable = {\n join: \"lateral\",\n alias: jtAlias,\n fromAlias: \"unset\",\n table: field.joinTableName,\n query: {\n selects: [`json_agg(json_build_array(${parts.join(\", \")}) order by ${orderBy}) as _`],\n tables: [{ join: \"primary\", table: field.joinTableName, alias: jtAlias }],\n condition: cb.toExpressionFilter(),\n orderBys: [],\n },\n };\n\n const hydrator: AggregateJsonHydrator = (root, parent, arrays) => {\n const { em } = root;\n if (subTree.entitiesKind === \"instances\" && !subTree.entities.has(root as any)) return;\n if (subTree.entitiesKind === \"ids\" && !subTree.entities.has(root.idTagged as any)) return;\n const like: ManyToManyLike = {\n entity: parent,\n joinTableName: field.joinTableName,\n columnName: entityColumn,\n otherColumnName: enumColumn,\n fieldName: key,\n meta: getMetadataForField(getMetadata(parent), key),\n otherEnum: field.enumDetailType,\n hasJoinTableId: field.hasJoinTableId,\n };\n const api = getEmInternalApi(em);\n const joinRows = api.joinRows(like);\n const codes: any[] = [];\n for (const array of arrays) {\n const enumId = array[0] as number;\n joinRows.addPreloadedRow(like, field.hasJoinTableId ? (array[1] as number) : undefined, parent, enumId);\n codes.push(field.enumDetailType.findById(enumId)!.code);\n }\n api.setPreloadedRelation(parent.idTagged, key, codes);\n };\n\n return { alias: jtAlias, relationAlias, join, hydrator };\n}\n\n/** A preload-loadable join for a given child, with potentially grand-child joins contained within it. */\ntype AggregateJoinResult = {\n /** The short table alias used for column references inside the subquery, e.g. `_b1`. */\n alias: string;\n /** The readable relation-name alias used in the outer `AS` clause, e.g. `_prequel`. */\n relationAlias: string;\n /** The SQL for this child's lateral join, which itself might have recursive lateral joins. */\n join: LateralJoinTable;\n /** The hydrator for this child's lateral join, which itself might recursively hydrator subjoins. */\n hydrator: AggregateJsonHydrator;\n};\n\n/** Reads one column from either classic POJO rows or a lazy `RowData` result. */\nfunction readRowValue(rows: any[] | RowData, rowIndex: number, columnName: string): any {\n return Array.isArray(rows) ? rows[rowIndex][columnName] : rows.get(rowIndex, columnName);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAa,yBAAb,MAA6D;CAC3D,cACE,MACA,MACoE;EACpE,OAAOA,iCAAAA,cAAc,MAAM,IAAI;CACjC;CAEA,cACE,MACA,MACA,OAC6B;EAC7B,MAAM,WAAW,IAAIC,kCAAAA,cAAc,KAAK;EAGxC,MAAM,QAAQC,iCAAAA,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;EAClC,MAAM,QAAQ,iBAAiB,UAAU;GAAE,MAAM;GAAM;GAAO;EAAK,GAAG,MAAM,OAAO,IAAI;EAEvF,IAAI,MAAM,WAAW,GAAG,OAAO,KAAA;EAG/B,KAAK,MAAM,EAAE,OAAO,eAAe,UAAU,OAAO;GAClD,MAAM,QAAQ,KAAK;IACjB,KAAK,GAAGC,6BAAAA,MAAM,OAAO,GAAG,EAAE,MAAMC,6BAAAA,GAAG,aAAa;IAChD,S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iBAAiB,EAAE;EAC/B,MAAM,WAAW,IAAI,SAAS,IAAI;EAClC,MAAM,QAAe,CAAC;EACtB,KAAK,MAAM,SAAS,QAAQ;GAC1B,MAAM,SAAS,MAAM;GACrB,SAAS,gBAAgB,MAAM,MAAM,iBAAkB,MAAM,KAAgB,KAAA,GAAW,QAAQ,MAAM;GACtG,MAAM,KAAK,MAAM,eAAe,SAAS,MAAM,CAAC,CAAE,IAAI;EACxD;EACA,IAAI,qBAAqB,OAAO,UAAU,KAAK,KAAK;CACtD;CAEA,OAAO;EAAE,OAAO;EAAS;EAAe;EAAM;CAAS;AACzD;;AAeA,SAAS,aAAa,MAAuB,UAAkB,YAAyB;CACtF,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC,cAAc,KAAK,IAAI,UAAU,UAAU;AACzF"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LoadHint, NestedLoadHint } from "../loading/loadHints.cjs";
|
|
1
|
+
import { Entity } from "../Entity.cjs";
|
|
3
2
|
import { EntityMetadata } from "../EntityMetadata.cjs";
|
|
4
3
|
import { HintNode } from "../loading/HintTree.cjs";
|
|
4
|
+
import { LoadHint, NestedLoadHint } from "../loading/loadHints.cjs";
|
|
5
5
|
import { JoinResult, PreloadHydrator, PreloadPlugin } from "../plugins/PreloadPlugin.cjs";
|
|
6
|
-
import {
|
|
7
|
-
//#region src/preloading/JsonAggregatePreloader.d.ts
|
|
6
|
+
import { ParsedFindQuery } from "../queries/find/QueryParser.cjs";
|
|
8
7
|
/**
|
|
9
8
|
* A PreloadPlugin implementation that uses `CROSS LATERAL JOIN` and `json_aggregate`
|
|
10
9
|
* to preload/reduce a subtree of data while still being a single row of data.
|
|
@@ -14,5 +13,4 @@ export declare class JsonAggregatePreloader implements PreloadPlugin {
|
|
|
14
13
|
addPreloading<T extends Entity>(meta: EntityMetadata, root: HintNode<T>, query: ParsedFindQuery): PreloadHydrator | undefined;
|
|
15
14
|
getPreloadJoins<T extends Entity>(meta: EntityMetadata, root: HintNode<T>, query: ParsedFindQuery): JoinResult[];
|
|
16
15
|
}
|
|
17
|
-
//#endregion
|
|
18
16
|
//# sourceMappingURL=JsonAggregatePreloader.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonAggregatePreloader.d.cts","names":[],"sources":["../../src/preloading/JsonAggregatePreloader.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"JsonAggregatePreloader.d.cts","names":[],"sources":["../../src/preloading/JsonAggregatePreloader.ts"],"mappings":";;;;;;;;;;qBA0Ba,kCAAkC;EAC7C,cACE,MAAM,4BACN,MAAM,iBACJ,iCAAiC;EAIrC,cAAc,UAAU,QACtB,MAAM,gBACN,MAAM,SAAS,IACf,OAAO,kBACN;EA6BH,gBAAgB,UAAU,QAAQ,MAAM,gBAAgB,MAAM,SAAS,IAAI,OAAO,kBAAkB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LoadHint, NestedLoadHint } from "../loading/loadHints.mjs";
|
|
1
|
+
import { Entity } from "../Entity.mjs";
|
|
3
2
|
import { EntityMetadata } from "../EntityMetadata.mjs";
|
|
4
3
|
import { HintNode } from "../loading/HintTree.mjs";
|
|
4
|
+
import { LoadHint, NestedLoadHint } from "../loading/loadHints.mjs";
|
|
5
5
|
import { JoinResult, PreloadHydrator, PreloadPlugin } from "../plugins/PreloadPlugin.mjs";
|
|
6
|
-
import {
|
|
7
|
-
//#region src/preloading/JsonAggregatePreloader.d.ts
|
|
6
|
+
import { ParsedFindQuery } from "../queries/find/QueryParser.mjs";
|
|
8
7
|
/**
|
|
9
8
|
* A PreloadPlugin implementation that uses `CROSS LATERAL JOIN` and `json_aggregate`
|
|
10
9
|
* to preload/reduce a subtree of data while still being a single row of data.
|
|
@@ -14,5 +13,4 @@ export declare class JsonAggregatePreloader implements PreloadPlugin {
|
|
|
14
13
|
addPreloading<T extends Entity>(meta: EntityMetadata, root: HintNode<T>, query: ParsedFindQuery): PreloadHydrator | undefined;
|
|
15
14
|
getPreloadJoins<T extends Entity>(meta: EntityMetadata, root: HintNode<T>, query: ParsedFindQuery): JoinResult[];
|
|
16
15
|
}
|
|
17
|
-
//#endregion
|
|
18
16
|
//# sourceMappingURL=JsonAggregatePreloader.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonAggregatePreloader.d.mts","names":[],"sources":["../../src/preloading/JsonAggregatePreloader.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"JsonAggregatePreloader.d.mts","names":[],"sources":["../../src/preloading/JsonAggregatePreloader.ts"],"mappings":";;;;;;;;;;qBA0Ba,kCAAkC;EAC7C,cACE,MAAM,4BACN,MAAM,iBACJ,iCAAiC;EAIrC,cAAc,UAAU,QACtB,MAAM,gBACN,MAAM,SAAS,IACf,OAAO,kBACN;EA6BH,gBAAgB,UAAU,QAAQ,MAAM,gBAAgB,MAAM,SAAS,IAAI,OAAO,kBAAkB"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { ConditionBuilder } from "../queries/ConditionBuilder.js";
|
|
4
|
-
import { getTables } from "../queries/find/QueryParser.js";
|
|
5
|
-
import { fail } from "../utils.js";
|
|
1
|
+
import "../Entity.js";
|
|
2
|
+
import { getEmInternalApi } from "../EntityManager.js";
|
|
6
3
|
import { getMetadata, getMetadataForField } from "../EntityMetadata.js";
|
|
4
|
+
import { keyToNumber, keyToTaggedId } from "../keys.js";
|
|
5
|
+
import "../plugins/PreloadPlugin.js";
|
|
7
6
|
import { canPreload } from "./canPreload.js";
|
|
8
7
|
import { partitionHint } from "./partitionHint.js";
|
|
8
|
+
import { ConditionBuilder } from "../queries/ConditionBuilder.js";
|
|
9
|
+
import { getTables } from "../queries/find/QueryParser.js";
|
|
9
10
|
import { AliasAssigner } from "../queries/sql/AliasAssigner.js";
|
|
10
|
-
import "../
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
//#region src/preloading/JsonAggregatePreloader.ts
|
|
11
|
+
import { kq, kqDot } from "../queries/sql/keywords.js";
|
|
12
|
+
import { fail } from "../utils.js";
|
|
13
|
+
// src/preloading/JsonAggregatePreloader.ts
|
|
14
14
|
/**
|
|
15
15
|
* A PreloadPlugin implementation that uses `CROSS LATERAL JOIN` and `json_aggregate`
|
|
16
16
|
* to preload/reduce a subtree of data while still being a single row of data.
|
|
@@ -173,21 +173,22 @@ function calcLateralJoins(assigner, root, tree, parentAlias, parentMeta, pathPre
|
|
|
173
173
|
const { em } = root;
|
|
174
174
|
if (subTree.entitiesKind === "instances" && !subTree.entities.has(root)) return;
|
|
175
175
|
if (subTree.entitiesKind === "ids" && !subTree.entities.has(root.idTagged)) return;
|
|
176
|
+
const api = getEmInternalApi(em);
|
|
176
177
|
const children = arrays.map((array) => {
|
|
177
178
|
const taggedId = keyToTaggedId(otherMeta, array[m2mOffset]);
|
|
178
179
|
const row = {};
|
|
179
180
|
for (let i = 0; i < columns.length; i++) row[columnNames[i]] = columns[i].mapFromJsonAgg(array[m2mOffset + i]);
|
|
180
|
-
const entity =
|
|
181
|
+
const entity = api.getEntity(taggedId) ?? api.hydrate(otherMeta.cstr, [row], { overwriteExisting: false })[0];
|
|
181
182
|
if (field.kind === "m2m") {
|
|
182
183
|
const m2m = parent[key];
|
|
183
|
-
|
|
184
|
+
api.joinRows(m2m).addPreloadedRow(m2m, field.hasJoinTableId ? array[0] : void 0, parent, entity);
|
|
184
185
|
}
|
|
185
186
|
subJoins.forEach((sub, i) => {
|
|
186
187
|
sub.hydrator(root, entity, array[m2mOffset + columns.length + i] ?? []);
|
|
187
188
|
});
|
|
188
189
|
return entity;
|
|
189
190
|
});
|
|
190
|
-
|
|
191
|
+
api.setPreloadedRelation(parent.idTagged, key, children);
|
|
191
192
|
};
|
|
192
193
|
results.push({
|
|
193
194
|
alias: otherAlias,
|
|
@@ -273,7 +274,6 @@ function calcEnumLateralJoin(assigner, root, subTree, parentAlias, field, key, p
|
|
|
273
274
|
function readRowValue(rows, rowIndex, columnName) {
|
|
274
275
|
return Array.isArray(rows) ? rows[rowIndex][columnName] : rows.get(rowIndex, columnName);
|
|
275
276
|
}
|
|
276
|
-
//#endregion
|
|
277
277
|
export { JsonAggregatePreloader };
|
|
278
278
|
|
|
279
279
|
//# sourceMappingURL=JsonAggregatePreloader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonAggregatePreloader.js","names":[],"sources":["../../src/preloading/JsonAggregatePreloader.ts"],"sourcesContent":["import { type Entity } from \"src/Entity.ts\";\nimport { getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, type ManyToManyEnumField, getMetadata, getMetadataForField } from \"src/EntityMetadata.ts\";\nimport type { ManyToManyLike } from \"src/flush/JoinRows.ts\";\nimport { keyToNumber, keyToTaggedId } from \"src/keys.ts\";\nimport type { EntityOrId, HintNode } from \"src/loading/HintTree.ts\";\nimport type { LoadHint, NestedLoadHint } from \"src/loading/loadHints.ts\";\nimport { type JoinResult, type PreloadHydrator, type PreloadPlugin } from \"src/plugins/PreloadPlugin.ts\";\nimport { canPreload } from \"src/preloading/canPreload.ts\";\nimport { partitionHint } from \"src/preloading/partitionHint.ts\";\nimport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nimport {\n type JoinTable,\n type LateralJoinTable,\n type ParsedFindQuery,\n getTables,\n} from \"src/queries/find/QueryParser.ts\";\nimport { AliasAssigner } from \"src/queries/sql/AliasAssigner.ts\";\nimport { kq, kqDot } from \"src/queries/sql/keywords.ts\";\nimport { type RowData } from \"src/RowData.ts\";\nimport { fail } from \"src/utils.ts\";\n\n/**\n * A PreloadPlugin implementation that uses `CROSS LATERAL JOIN` and `json_aggregate`\n * to preload/reduce a subtree of data while still being a single row of data.\n */\nexport class JsonAggregatePreloader implements PreloadPlugin {\n partitionHint(\n meta: EntityMetadata | undefined,\n hint: LoadHint<any>,\n ): [NestedLoadHint<any> | undefined, NestedLoadHint<any> | undefined] {\n return partitionHint(meta, hint);\n }\n\n addPreloading<T extends Entity>(\n meta: EntityMetadata,\n root: HintNode<T>,\n query: ParsedFindQuery,\n ): PreloadHydrator | undefined {\n const assigner = new AliasAssigner(query);\n\n // Get the existing primary alias\n const alias = getTables(query)[0].alias;\n const joins = calcLateralJoins(assigner, { tree: root, alias, meta }, root, alias, meta);\n // If there are no sql-based preload in the hints, just return\n if (joins.length === 0) return undefined;\n\n // Include the aggregate `_b1._ as _prequel`, `_c._ as _randomComment`\n for (const { alias, relationAlias, join } of joins) {\n query.selects.push({\n sql: `${kqDot(alias, \"_\")} as ${kq(relationAlias)}`,\n aliases: [alias],\n bindings: [],\n });\n query.tables.push(join);\n }\n\n return (rows, entities) => {\n for (let i = 0; i < entities.length; i++) {\n const parent = entities[i];\n for (const { relationAlias, hydrator } of joins) {\n hydrator(parent, parent, readRowValue(rows, i, relationAlias) ?? []);\n }\n }\n };\n }\n\n getPreloadJoins<T extends Entity>(meta: EntityMetadata, root: HintNode<T>, query: ParsedFindQuery): JoinResult[] {\n const assigner = new AliasAssigner(query);\n\n // Get the existing primary alias\n const alias = getTables(query)[0].alias;\n const joins = calcLateralJoins(assigner, { tree: root, alias, meta }, root, alias, meta);\n // If there are no sql-based preload in the hints, just return\n\n // Adapt our json aggregate joins to the higher-level JoinResult\n return joins.map((join) => {\n return {\n selects: [{ value: kqDot(join.alias, \"_\"), as: join.relationAlias }],\n join: join.join,\n hydrator: (rows, entities) => {\n for (let i = 0; i < entities.length; i++) {\n const parent = entities[i];\n join.hydrator(parent, parent, readRowValue(rows, i, join.relationAlias) ?? []);\n }\n },\n };\n });\n }\n}\n\n/** Decodes an array-of-arrays of children entries, and stores them the `parent`'s relation. */\ntype AggregateJsonHydrator = (root: Entity, parent: Entity, arrays: unknown[][]) => void;\n\n/**\n * For a given hint tree `hint`, finds all SQL-able relations and preloads them.\n *\n * Specifically we use `json_agg` & `json_build_array` to `CROSS LATERAL JOIN`\n * children/grand children back as arbitrarily-deeply nested arrays, and then\n * stash the results in the `EntityManager` `joinLoadedRelations` cache, which\n * each join-instrumented relation will check before making its SQL calls.\n *\n * https://sqlfum.pt/?n=60&indent=2&spaces=1&simplify=1&align=0&case=lower&sql=c2VsZWN0IGEuaWQsIGIuXyBhcyBiLCBjMS5fIGFzIGMxLCBhMS5fIGFzIGExIGZyb20gYXV0aG9ycyBhIGNyb3NzIGpvaW4gbGF0ZXJhbCAoIHNlbGVjdCBqc29uX2FnZyhqc29uX2J1aWxkX2FycmF5KGIuaWQsIGIudGl0bGUsIGIuIm9yZGVyIiwgYi5kZWxldGVkX2F0LCBiLmNyZWF0ZWRfYXQsIGIudXBkYXRlZF9hdCwgYi5hdXRob3JfaWQsIGJyLl8pKSBhcyBfIGZyb20gYm9va3MgYiBjcm9zcyBqb2luIGxhdGVyYWwgKCBzZWxlY3QganNvbl9hZ2coanNvbl9idWlsZF9hcnJheShici5pZCwgYnIucmF0aW5nLCBici5pc19wdWJsaWMsIGJyLmlzX3Rlc3QsIGJyLmNyZWF0ZWRfYXQsIGJyLnVwZGF0ZWRfYXQsIGJyLmJvb2tfaWQsIGMuXykpIGFzIF8gZnJvbSBib29rX3Jldmlld3MgYnIgY3Jvc3Mgam9pbiBsYXRlcmFsICggc2VsZWN0IGpzb25fYWdnKGpzb25fYnVpbGRfYXJyYXkoYy5pZCwgYy50ZXh0LCBjLmNyZWF0ZWRfYXQsIGMudXBkYXRlZF9hdCwgYy51c2VyX2lkLCBjLnBhcmVudF9hdXRob3JfaWQsIGMucGFyZW50X2Jvb2tfaWQsIGMucGFyZW50X2Jvb2tfcmV2aWV3X2lkLCBjLnBhcmVudF9wdWJsaXNoZXJfaWQpKSBhcyBfIGZyb20gY29tbWVudHMgYyB3aGVyZSBjLnBhcmVudF9ib29rX3Jldmlld19pZCA9IGJyLmlkICkgYyB3aGVyZSBici5ib29rX2lkID0gYi5pZCApIGJyIHdoZXJlIGIuYXV0aG9yX2lkID0gY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XyBmcm9tIGF1dGhvcnMgYTEgd2hlcmUgYTEuaWQgPSBhLm1lbnRvcl9pZCApIGExIHdoZXJlIGEuaWQgPSAxOw%3D%3D\n */\n\n/**\n * Given a `parent` like Author, and a hint of `{ books: ..., comments: ... }`, create `CROSS JOIN LATERAL`s\n * that will pull in the `books` & `comments` children.\n */\nfunction calcLateralJoins<I extends EntityOrId>(\n assigner: AliasAssigner,\n root: { tree: HintNode<I>; alias: string; meta: EntityMetadata },\n tree: HintNode<I>,\n parentAlias: string,\n parentMeta: EntityMetadata,\n pathPrefix: string = \"\",\n): AggregateJoinResult[] {\n const results: AggregateJoinResult[] = [];\n\n // Join in SQL-able hints from parent\n Object.entries(tree.hints).forEach(([key, subTree]) => {\n const field = parentMeta.allFields[key];\n // AsyncProperties don't have fields, which is fine, skip for now...\n if (field && canPreload(parentMeta, field)) {\n // Enum m2ms have no \"other\" entity to join/hydrate; just aggregate the join table's enum ids.\n if (field.kind === \"m2mEnum\") {\n results.push(calcEnumLateralJoin(assigner, root, subTree, parentAlias, field, key, pathPrefix));\n return;\n }\n const otherMeta = field.otherMetadata();\n const otherField = otherMeta.allFields[field.otherFieldName];\n\n // Short table alias for column refs inside the subquery, e.g. `_b1`\n const otherAlias = `_${assigner.getAlias(otherMeta.tableName)}`;\n // Readable path-based column alias for the outer AS clause, e.g. `_books_reviews`\n const pathKey = key.toLowerCase();\n const relationAlias = `_${assigner.getLiteralAlias(`${pathPrefix}${pathKey}`)}`;\n\n // Do the recursion up-front, so we can work it into our own join/hydrator\n const subJoins = calcLateralJoins(assigner, root, subTree, otherAlias, otherMeta, `${pathPrefix}${pathKey}_`);\n\n // Get all fields with serdes and flatten out the columns, skipping `lazy` columns (fetched on-demand)\n const columns = Object.values(otherMeta.allFields)\n .filter((f) => f.serde && !(f.kind === \"primitive\" && f.lazy))\n .flatMap((f) => f.serde!.columns);\n const selects = [\n ...columns.map((c) => kqDot(otherAlias, c.columnName)),\n // We eventually need to handle parent types/subtypes here...\n // Combine any grandchilden\n ...subJoins.map((sb) => kqDot(sb.alias, \"_\")),\n ];\n\n const aliasMaybeSuffix = kq(`${parentAlias}${field.aliasSuffix}`);\n\n const cb = new ConditionBuilder();\n let m2mTable: JoinTable | undefined;\n let m2mAlias: string | undefined;\n if (otherField.kind === \"m2o\") {\n cb.addRawCondition({\n aliases: [otherAlias, parentAlias],\n condition: `${kqDot(otherAlias, otherField.serde.columns[0].columnName)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"poly\") {\n // Get the component that points to us\n // const comp = otherField.components.find((c) => getAllMetas(parentMeta).some((m) => m.cstr === c.otherMetadata().cstr)) ??\n const comp =\n otherField.components.find((c) => parentMeta.cstr === c.otherMetadata().cstr) ??\n fail(`No component found for ${field.fieldName} -> ${otherField.fieldName}`);\n cb.addRawCondition({\n aliases: [otherAlias, parentAlias],\n condition: `${kqDot(otherAlias, comp.columnName)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"o2m\" || otherField.kind === \"lo2m\") {\n cb.addRawCondition({\n aliases: [otherAlias, aliasMaybeSuffix],\n condition: `${kqDot(otherAlias, \"id\")} = ${aliasMaybeSuffix}.${kq(field.serde!.columns[0].columnName)}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"o2o\") {\n cb.addRawCondition({\n aliases: [otherAlias, aliasMaybeSuffix],\n condition: `${kqDot(otherAlias, \"id\")} = ${aliasMaybeSuffix}.${kq(field.serde!.columns[0].columnName)}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"m2m\") {\n m2mAlias = assigner.getAlias(otherField.joinTableName);\n // Get the m2m row's id to track in JoinRows; id-less tables have no surrogate id.\n if (otherField.hasJoinTableId) selects.unshift(kqDot(m2mAlias, \"id\"));\n m2mTable = {\n join: \"inner\",\n table: otherField.joinTableName,\n alias: m2mAlias,\n col1: kqDot(parentAlias, \"id\"),\n col2: kqDot(m2mAlias, otherField.columnNames[1]),\n };\n cb.addRawCondition({\n aliases: [m2mAlias, otherAlias],\n condition: `${kqDot(m2mAlias, otherField.columnNames[0])} = ${kqDot(otherAlias, \"id\")}`,\n pruneable: true,\n });\n } else {\n throw new Error(`Unsupported otherField.kind ${otherField.kind}`);\n }\n\n const needsSubSelect = subTree.entities.size !== root.tree.entities.size;\n if (needsSubSelect) {\n cb.addRawCondition({\n aliases: [root.alias],\n condition: `${kqDot(root.alias, \"id\")} = ANY(?)`,\n bindings: [\n [...subTree.entities]\n .filter((e) => typeof e === \"string\" || !e.isNewEntity)\n .map((e) => keyToNumber(root.meta, typeof e === \"string\" ? e : e.id)),\n ],\n pruneable: true,\n });\n }\n\n // For m2m, order by the join-row's id so preloaded results match the order the lazy batch\n // loader returns (which orders by join-row id). Id-less join tables have no surrogate id,\n // so order by the other entity's FK column (matching the lazy loader & getOthers). Otherwise,\n // order by the target entity's id.\n const orderBy =\n otherField.kind === \"m2m\" && !otherField.hasJoinTableId\n ? `${kq(m2mAlias!)}.${kq(otherField.columnNames[0])}`\n : `${kq(m2mAlias ?? otherAlias)}.id`;\n\n const join: LateralJoinTable = {\n join: \"lateral\",\n alias: otherAlias,\n // Do we need to say which alias we're coming from, to avoid having it pruned?\n // ...maybe not because preloading is always on the primary table?\n fromAlias: \"unset\",\n table: otherMeta.tableName,\n query: {\n selects: [`json_agg(json_build_array(${selects.join(\", \")}) order by ${orderBy}) as _`],\n tables: [\n { join: \"primary\", table: otherMeta.tableName, alias: otherAlias },\n ...(m2mTable ? [m2mTable] : []),\n ...subJoins.map((sj) => sj.join),\n ],\n condition: cb.toExpressionFilter(),\n orderBys: [],\n },\n };\n\n // Pre-compute column names so we don't re-read them per entity\n const columnNames = columns.map((c) => c.columnName);\n // If we've snuck the m2m row id into the json array, ignore it (id-less tables have no id)\n const m2mOffset = field.kind === \"m2m\" && field.hasJoinTableId ? 1 : 0;\n\n const hydrator: AggregateJsonHydrator = (root, parent, arrays) => {\n const { em } = root;\n\n // If we had overlapping load hints, i.e. `author.books` for [a1, a2] and `author.comments` for [a1], and\n // we're processing the arrays of comments, but for a root author like `a2` that didn't ask for our load\n // hint, then skip it to keep the relation unloaded.\n if (subTree.entitiesKind === \"instances\" && !subTree.entities.has(root as any)) return;\n if (subTree.entitiesKind === \"ids\" && !subTree.entities.has(root.idTagged as any)) return;\n\n // We get back an array of [[1, title], [2, title], [3, title]]\n const children = arrays.map((array) => {\n const taggedId = keyToTaggedId(otherMeta, array[m2mOffset] as any)!;\n const row: Record<string, any> = {};\n for (let i = 0; i < columns.length; i++) {\n row[columnNames[i]] = columns[i].mapFromJsonAgg(array[m2mOffset + i]);\n }\n const entity =\n em.findExistingInstance<Entity>(taggedId) ??\n (em.hydrate(otherMeta.cstr, [row], { overwriteExisting: false }) as Entity[])[0];\n // Tell the internal JoinRow booking-keeping about this m2m row\n if (field.kind === \"m2m\") {\n // TODO This `addExisting` needs to be pulled up, out of the `arrays.map`, so we can do a `loadRows`-ish\n // call that passes all now-known m2m rows into JoinRows as a single list, so that it can mark any\n // deleted-from-under-us m2m rows as deleted.\n const m2m = (parent as any)[key];\n getEmInternalApi(em)\n .joinRows(m2m)\n .addPreloadedRow(m2m, field.hasJoinTableId ? (array[0] as any) : undefined, parent, entity);\n }\n // Within each child, look for grandchildren\n subJoins.forEach((sub, i) => {\n // array[i] could be null if there are no grandchildren, but still call `sub` to\n // process it so that we store the empty array into the em.joinLoadedRelations, to\n // avoid the relation.load method later doing a SQL for rows we know are not there.\n sub.hydrator(root, entity, (array[m2mOffset + columns.length + i] as any) ?? []);\n });\n return entity;\n });\n // Cache the entities so `.load`s will see them\n getEmInternalApi(em).setPreloadedRelation(parent.idTagged, key, children);\n };\n\n results.push({ alias: otherAlias, relationAlias, join, hydrator });\n }\n });\n\n return results;\n}\n\n/**\n * Builds the `CROSS JOIN LATERAL` that aggregates an enum-m2m join table (e.g. `publisher_logo_colors`)\n * into a json array of enum ids, e.g. `[[1], [3]]` (or `[[1, id], [3, id]]` for id-ful join tables).\n */\nfunction calcEnumLateralJoin<I extends EntityOrId>(\n assigner: AliasAssigner,\n root: { tree: HintNode<I>; alias: string; meta: EntityMetadata },\n subTree: HintNode<I>,\n parentAlias: string,\n field: ManyToManyEnumField,\n key: string,\n pathPrefix: string,\n): AggregateJoinResult {\n const [entityColumn, enumColumn] = field.columnNames;\n const jtAlias = `_${assigner.getAlias(field.joinTableName)}`;\n const relationAlias = `_${assigner.getLiteralAlias(`${pathPrefix}${key.toLowerCase()}`)}`;\n\n const parts = [kqDot(jtAlias, enumColumn)];\n if (field.hasJoinTableId) parts.push(kqDot(jtAlias, \"id\"));\n\n const cb = new ConditionBuilder();\n cb.addRawCondition({\n aliases: [jtAlias, parentAlias],\n condition: `${kqDot(jtAlias, entityColumn)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n\n const needsSubSelect = subTree.entities.size !== root.tree.entities.size;\n if (needsSubSelect) {\n cb.addRawCondition({\n aliases: [root.alias],\n condition: `${kqDot(root.alias, \"id\")} = ANY(?)`,\n bindings: [\n [...subTree.entities]\n .filter((e) => typeof e === \"string\" || !e.isNewEntity)\n .map((e) => keyToNumber(root.meta, typeof e === \"string\" ? e : e.id)),\n ],\n pruneable: true,\n });\n }\n\n const orderBy = `${kq(jtAlias)}.${kq(field.hasJoinTableId ? \"id\" : enumColumn)}`;\n const join: LateralJoinTable = {\n join: \"lateral\",\n alias: jtAlias,\n fromAlias: \"unset\",\n table: field.joinTableName,\n query: {\n selects: [`json_agg(json_build_array(${parts.join(\", \")}) order by ${orderBy}) as _`],\n tables: [{ join: \"primary\", table: field.joinTableName, alias: jtAlias }],\n condition: cb.toExpressionFilter(),\n orderBys: [],\n },\n };\n\n const hydrator: AggregateJsonHydrator = (root, parent, arrays) => {\n const { em } = root;\n if (subTree.entitiesKind === \"instances\" && !subTree.entities.has(root as any)) return;\n if (subTree.entitiesKind === \"ids\" && !subTree.entities.has(root.idTagged as any)) return;\n const like: ManyToManyLike = {\n entity: parent,\n joinTableName: field.joinTableName,\n columnName: entityColumn,\n otherColumnName: enumColumn,\n fieldName: key,\n meta: getMetadataForField(getMetadata(parent), key),\n otherEnum: field.enumDetailType,\n hasJoinTableId: field.hasJoinTableId,\n };\n const api = getEmInternalApi(em);\n const joinRows = api.joinRows(like);\n const codes: any[] = [];\n for (const array of arrays) {\n const enumId = array[0] as number;\n joinRows.addPreloadedRow(like, field.hasJoinTableId ? (array[1] as number) : undefined, parent, enumId);\n codes.push(field.enumDetailType.findById(enumId)!.code);\n }\n api.setPreloadedRelation(parent.idTagged, key, codes);\n };\n\n return { alias: jtAlias, relationAlias, join, hydrator };\n}\n\n/** A preload-loadable join for a given child, with potentially grand-child joins contained within it. */\ntype AggregateJoinResult = {\n /** The short table alias used for column references inside the subquery, e.g. `_b1`. */\n alias: string;\n /** The readable relation-name alias used in the outer `AS` clause, e.g. `_prequel`. */\n relationAlias: string;\n /** The SQL for this child's lateral join, which itself might have recursive lateral joins. */\n join: LateralJoinTable;\n /** The hydrator for this child's lateral join, which itself might recursively hydrator subjoins. */\n hydrator: AggregateJsonHydrator;\n};\n\n/** Reads one column from either classic POJO rows or a lazy `RowData` result. */\nfunction readRowValue(rows: any[] | RowData, rowIndex: number, columnName: string): any {\n return Array.isArray(rows) ? rows[rowIndex][columnName] : rows.get(rowIndex, columnName);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,IAAa,yBAAb,MAA6D;CAC3D,cACE,MACA,MACoE;EACpE,OAAO,cAAc,MAAM,IAAI;CACjC;CAEA,cACE,MACA,MACA,OAC6B;EAC7B,MAAM,WAAW,IAAI,cAAc,KAAK;EAGxC,MAAM,QAAQ,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;EAClC,MAAM,QAAQ,iBAAiB,UAAU;GAAE,MAAM;GAAM;GAAO;EAAK,GAAG,MAAM,OAAO,IAAI;EAEvF,IAAI,MAAM,WAAW,GAAG,OAAO,KAAA;EAG/B,KAAK,MAAM,EAAE,OAAO,eAAe,UAAU,OAAO;GAClD,MAA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qB,OAAO,UAAU,KAAK,KAAK;CACtD;CAEA,OAAO;EAAE,OAAO;EAAS;EAAe;EAAM;CAAS;AACzD;;AAeA,SAAS,aAAa,MAAuB,UAAkB,YAAyB;CACtF,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC,cAAc,KAAK,IAAI,UAAU,UAAU;AACzF"}
|
|
1
|
+
{"version":3,"file":"JsonAggregatePreloader.js","names":[],"sources":["../../src/preloading/JsonAggregatePreloader.ts"],"sourcesContent":["import { type Entity } from \"src/Entity.ts\";\nimport { getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, type ManyToManyEnumField, getMetadata, getMetadataForField } from \"src/EntityMetadata.ts\";\nimport type { ManyToManyLike } from \"src/flush/JoinRows.ts\";\nimport { keyToNumber, keyToTaggedId } from \"src/keys.ts\";\nimport type { EntityOrId, HintNode } from \"src/loading/HintTree.ts\";\nimport type { LoadHint, NestedLoadHint } from \"src/loading/loadHints.ts\";\nimport { type JoinResult, type PreloadHydrator, type PreloadPlugin } from \"src/plugins/PreloadPlugin.ts\";\nimport { canPreload } from \"src/preloading/canPreload.ts\";\nimport { partitionHint } from \"src/preloading/partitionHint.ts\";\nimport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nimport {\n type JoinTable,\n type LateralJoinTable,\n type ParsedFindQuery,\n getTables,\n} from \"src/queries/find/QueryParser.ts\";\nimport { AliasAssigner } from \"src/queries/sql/AliasAssigner.ts\";\nimport { kq, kqDot } from \"src/queries/sql/keywords.ts\";\nimport { type RowData } from \"src/RowData.ts\";\nimport { fail } from \"src/utils.ts\";\n\n/**\n * A PreloadPlugin implementation that uses `CROSS LATERAL JOIN` and `json_aggregate`\n * to preload/reduce a subtree of data while still being a single row of data.\n */\nexport class JsonAggregatePreloader implements PreloadPlugin {\n partitionHint(\n meta: EntityMetadata | undefined,\n hint: LoadHint<any>,\n ): [NestedLoadHint<any> | undefined, NestedLoadHint<any> | undefined] {\n return partitionHint(meta, hint);\n }\n\n addPreloading<T extends Entity>(\n meta: EntityMetadata,\n root: HintNode<T>,\n query: ParsedFindQuery,\n ): PreloadHydrator | undefined {\n const assigner = new AliasAssigner(query);\n\n // Get the existing primary alias\n const alias = getTables(query)[0].alias;\n const joins = calcLateralJoins(assigner, { tree: root, alias, meta }, root, alias, meta);\n // If there are no sql-based preload in the hints, just return\n if (joins.length === 0) return undefined;\n\n // Include the aggregate `_b1._ as _prequel`, `_c._ as _randomComment`\n for (const { alias, relationAlias, join } of joins) {\n query.selects.push({\n sql: `${kqDot(alias, \"_\")} as ${kq(relationAlias)}`,\n aliases: [alias],\n bindings: [],\n });\n query.tables.push(join);\n }\n\n return (rows, entities) => {\n for (let i = 0; i < entities.length; i++) {\n const parent = entities[i];\n for (const { relationAlias, hydrator } of joins) {\n hydrator(parent, parent, readRowValue(rows, i, relationAlias) ?? []);\n }\n }\n };\n }\n\n getPreloadJoins<T extends Entity>(meta: EntityMetadata, root: HintNode<T>, query: ParsedFindQuery): JoinResult[] {\n const assigner = new AliasAssigner(query);\n\n // Get the existing primary alias\n const alias = getTables(query)[0].alias;\n const joins = calcLateralJoins(assigner, { tree: root, alias, meta }, root, alias, meta);\n // If there are no sql-based preload in the hints, just return\n\n // Adapt our json aggregate joins to the higher-level JoinResult\n return joins.map((join) => {\n return {\n selects: [{ value: kqDot(join.alias, \"_\"), as: join.relationAlias }],\n join: join.join,\n hydrator: (rows, entities) => {\n for (let i = 0; i < entities.length; i++) {\n const parent = entities[i];\n join.hydrator(parent, parent, readRowValue(rows, i, join.relationAlias) ?? []);\n }\n },\n };\n });\n }\n}\n\n/** Decodes an array-of-arrays of children entries, and stores them the `parent`'s relation. */\ntype AggregateJsonHydrator = (root: Entity, parent: Entity, arrays: unknown[][]) => void;\n\n/**\n * For a given hint tree `hint`, finds all SQL-able relations and preloads them.\n *\n * Specifically we use `json_agg` & `json_build_array` to `CROSS LATERAL JOIN`\n * children/grand children back as arbitrarily-deeply nested arrays, and then\n * stash the results in the `EntityManager` `joinLoadedRelations` cache, which\n * each join-instrumented relation will check before making its SQL calls.\n *\n * https://sqlfum.pt/?n=60&indent=2&spaces=1&simplify=1&align=0&case=lower&sql=c2VsZWN0IGEuaWQsIGIuXyBhcyBiLCBjMS5fIGFzIGMxLCBhMS5fIGFzIGExIGZyb20gYXV0aG9ycyBhIGNyb3NzIGpvaW4gbGF0ZXJhbCAoIHNlbGVjdCBqc29uX2FnZyhqc29uX2J1aWxkX2FycmF5KGIuaWQsIGIudGl0bGUsIGIuIm9yZGVyIiwgYi5kZWxldGVkX2F0LCBiLmNyZWF0ZWRfYXQsIGIudXBkYXRlZF9hdCwgYi5hdXRob3JfaWQsIGJyLl8pKSBhcyBfIGZyb20gYm9va3MgYiBjcm9zcyBqb2luIGxhdGVyYWwgKCBzZWxlY3QganNvbl9hZ2coanNvbl9idWlsZF9hcnJheShici5pZCwgYnIucmF0aW5nLCBici5pc19wdWJsaWMsIGJyLmlzX3Rlc3QsIGJyLmNyZWF0ZWRfYXQsIGJyLnVwZGF0ZWRfYXQsIGJyLmJvb2tfaWQsIGMuXykpIGFzIF8gZnJvbSBib29rX3Jldmlld3MgYnIgY3Jvc3Mgam9pbiBsYXRlcmFsICggc2VsZWN0IGpzb25fYWdnKGpzb25fYnVpbGRfYXJyYXkoYy5pZCwgYy50ZXh0LCBjLmNyZWF0ZWRfYXQsIGMudXBkYXRlZF9hdCwgYy51c2VyX2lkLCBjLnBhcmVudF9hdXRob3JfaWQsIGMucGFyZW50X2Jvb2tfaWQsIGMucGFyZW50X2Jvb2tfcmV2aWV3X2lkLCBjLnBhcmVudF9wdWJsaXNoZXJfaWQpKSBhcyBfIGZyb20gY29tbWVudHMgYyB3aGVyZSBjLnBhcmVudF9ib29rX3Jldmlld19pZCA9IGJyLmlkICkgYyB3aGVyZSBici5ib29rX2lkID0gYi5pZCApIGJyIHdoZXJlIGIuYXV0aG9yX2lkID0gYS5pZCApIGIgY3Jvc3Mgam9pbiBsYXRlcmFsICggc2V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PSBhLm1lbnRvcl9pZCApIGExIHdoZXJlIGEuaWQgPSAxOw%3D%3D\n */\n\n/**\n * Given a `parent` like Author, and a hint of `{ books: ..., comments: ... }`, create `CROSS JOIN LATERAL`s\n * that will pull in the `books` & `comments` children.\n */\nfunction calcLateralJoins<I extends EntityOrId>(\n assigner: AliasAssigner,\n root: { tree: HintNode<I>; alias: string; meta: EntityMetadata },\n tree: HintNode<I>,\n parentAlias: string,\n parentMeta: EntityMetadata,\n pathPrefix: string = \"\",\n): AggregateJoinResult[] {\n const results: AggregateJoinResult[] = [];\n\n // Join in SQL-able hints from parent\n Object.entries(tree.hints).forEach(([key, subTree]) => {\n const field = parentMeta.allFields[key];\n // AsyncProperties don't have fields, which is fine, skip for now...\n if (field && canPreload(parentMeta, field)) {\n // Enum m2ms have no \"other\" entity to join/hydrate; just aggregate the join table's enum ids.\n if (field.kind === \"m2mEnum\") {\n results.push(calcEnumLateralJoin(assigner, root, subTree, parentAlias, field, key, pathPrefix));\n return;\n }\n const otherMeta = field.otherMetadata();\n const otherField = otherMeta.allFields[field.otherFieldName];\n\n // Short table alias for column refs inside the subquery, e.g. `_b1`\n const otherAlias = `_${assigner.getAlias(otherMeta.tableName)}`;\n // Readable path-based column alias for the outer AS clause, e.g. `_books_reviews`\n const pathKey = key.toLowerCase();\n const relationAlias = `_${assigner.getLiteralAlias(`${pathPrefix}${pathKey}`)}`;\n\n // Do the recursion up-front, so we can work it into our own join/hydrator\n const subJoins = calcLateralJoins(assigner, root, subTree, otherAlias, otherMeta, `${pathPrefix}${pathKey}_`);\n\n // Get all fields with serdes and flatten out the columns, skipping `lazy` columns (fetched on-demand)\n const columns = Object.values(otherMeta.allFields)\n .filter((f) => f.serde && !(f.kind === \"primitive\" && f.lazy))\n .flatMap((f) => f.serde!.columns);\n const selects = [\n ...columns.map((c) => kqDot(otherAlias, c.columnName)),\n // We eventually need to handle parent types/subtypes here...\n // Combine any grandchilden\n ...subJoins.map((sb) => kqDot(sb.alias, \"_\")),\n ];\n\n const aliasMaybeSuffix = kq(`${parentAlias}${field.aliasSuffix}`);\n\n const cb = new ConditionBuilder();\n let m2mTable: JoinTable | undefined;\n let m2mAlias: string | undefined;\n if (otherField.kind === \"m2o\") {\n cb.addRawCondition({\n aliases: [otherAlias, parentAlias],\n condition: `${kqDot(otherAlias, otherField.serde.columns[0].columnName)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"poly\") {\n // Get the component that points to us\n // const comp = otherField.components.find((c) => getAllMetas(parentMeta).some((m) => m.cstr === c.otherMetadata().cstr)) ??\n const comp =\n otherField.components.find((c) => parentMeta.cstr === c.otherMetadata().cstr) ??\n fail(`No component found for ${field.fieldName} -> ${otherField.fieldName}`);\n cb.addRawCondition({\n aliases: [otherAlias, parentAlias],\n condition: `${kqDot(otherAlias, comp.columnName)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"o2m\" || otherField.kind === \"lo2m\") {\n cb.addRawCondition({\n aliases: [otherAlias, aliasMaybeSuffix],\n condition: `${kqDot(otherAlias, \"id\")} = ${aliasMaybeSuffix}.${kq(field.serde!.columns[0].columnName)}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"o2o\") {\n cb.addRawCondition({\n aliases: [otherAlias, aliasMaybeSuffix],\n condition: `${kqDot(otherAlias, \"id\")} = ${aliasMaybeSuffix}.${kq(field.serde!.columns[0].columnName)}`,\n pruneable: true,\n });\n } else if (otherField.kind === \"m2m\") {\n m2mAlias = assigner.getAlias(otherField.joinTableName);\n // Get the m2m row's id to track in JoinRows; id-less tables have no surrogate id.\n if (otherField.hasJoinTableId) selects.unshift(kqDot(m2mAlias, \"id\"));\n m2mTable = {\n join: \"inner\",\n table: otherField.joinTableName,\n alias: m2mAlias,\n col1: kqDot(parentAlias, \"id\"),\n col2: kqDot(m2mAlias, otherField.columnNames[1]),\n };\n cb.addRawCondition({\n aliases: [m2mAlias, otherAlias],\n condition: `${kqDot(m2mAlias, otherField.columnNames[0])} = ${kqDot(otherAlias, \"id\")}`,\n pruneable: true,\n });\n } else {\n throw new Error(`Unsupported otherField.kind ${otherField.kind}`);\n }\n\n const needsSubSelect = subTree.entities.size !== root.tree.entities.size;\n if (needsSubSelect) {\n cb.addRawCondition({\n aliases: [root.alias],\n condition: `${kqDot(root.alias, \"id\")} = ANY(?)`,\n bindings: [\n [...subTree.entities]\n .filter((e) => typeof e === \"string\" || !e.isNewEntity)\n .map((e) => keyToNumber(root.meta, typeof e === \"string\" ? e : e.id)),\n ],\n pruneable: true,\n });\n }\n\n // For m2m, order by the join-row's id so preloaded results match the order the lazy batch\n // loader returns (which orders by join-row id). Id-less join tables have no surrogate id,\n // so order by the other entity's FK column (matching the lazy loader & getOthers). Otherwise,\n // order by the target entity's id.\n const orderBy =\n otherField.kind === \"m2m\" && !otherField.hasJoinTableId\n ? `${kq(m2mAlias!)}.${kq(otherField.columnNames[0])}`\n : `${kq(m2mAlias ?? otherAlias)}.id`;\n\n const join: LateralJoinTable = {\n join: \"lateral\",\n alias: otherAlias,\n // Do we need to say which alias we're coming from, to avoid having it pruned?\n // ...maybe not because preloading is always on the primary table?\n fromAlias: \"unset\",\n table: otherMeta.tableName,\n query: {\n selects: [`json_agg(json_build_array(${selects.join(\", \")}) order by ${orderBy}) as _`],\n tables: [\n { join: \"primary\", table: otherMeta.tableName, alias: otherAlias },\n ...(m2mTable ? [m2mTable] : []),\n ...subJoins.map((sj) => sj.join),\n ],\n condition: cb.toExpressionFilter(),\n orderBys: [],\n },\n };\n\n // Pre-compute column names so we don't re-read them per entity\n const columnNames = columns.map((c) => c.columnName);\n // If we've snuck the m2m row id into the json array, ignore it (id-less tables have no id)\n const m2mOffset = field.kind === \"m2m\" && field.hasJoinTableId ? 1 : 0;\n\n const hydrator: AggregateJsonHydrator = (root, parent, arrays) => {\n const { em } = root;\n\n // If we had overlapping load hints, i.e. `author.books` for [a1, a2] and `author.comments` for [a1], and\n // we're processing the arrays of comments, but for a root author like `a2` that didn't ask for our load\n // hint, then skip it to keep the relation unloaded.\n if (subTree.entitiesKind === \"instances\" && !subTree.entities.has(root as any)) return;\n if (subTree.entitiesKind === \"ids\" && !subTree.entities.has(root.idTagged as any)) return;\n\n // We get back an array of [[1, title], [2, title], [3, title]]\n const api = getEmInternalApi(em);\n const children = arrays.map((array) => {\n const taggedId = keyToTaggedId(otherMeta, array[m2mOffset] as any)!;\n const row: Record<string, any> = {};\n for (let i = 0; i < columns.length; i++) {\n row[columnNames[i]] = columns[i].mapFromJsonAgg(array[m2mOffset + i]);\n }\n const entity =\n api.getEntity(taggedId) ??\n (api.hydrate(otherMeta.cstr, [row], { overwriteExisting: false }) as Entity[])[0];\n // Tell the internal JoinRow booking-keeping about this m2m row\n if (field.kind === \"m2m\") {\n // TODO This `addExisting` needs to be pulled up, out of the `arrays.map`, so we can do a `loadRows`-ish\n // call that passes all now-known m2m rows into JoinRows as a single list, so that it can mark any\n // deleted-from-under-us m2m rows as deleted.\n const m2m = (parent as any)[key];\n api\n .joinRows(m2m)\n .addPreloadedRow(m2m, field.hasJoinTableId ? (array[0] as any) : undefined, parent, entity);\n }\n // Within each child, look for grandchildren\n subJoins.forEach((sub, i) => {\n // array[i] could be null if there are no grandchildren, but still call `sub` to\n // process it so that we store the empty array into the em.joinLoadedRelations, to\n // avoid the relation.load method later doing a SQL for rows we know are not there.\n sub.hydrator(root, entity, (array[m2mOffset + columns.length + i] as any) ?? []);\n });\n return entity;\n });\n // Cache the entities so `.load`s will see them\n api.setPreloadedRelation(parent.idTagged, key, children);\n };\n\n results.push({ alias: otherAlias, relationAlias, join, hydrator });\n }\n });\n\n return results;\n}\n\n/**\n * Builds the `CROSS JOIN LATERAL` that aggregates an enum-m2m join table (e.g. `publisher_logo_colors`)\n * into a json array of enum ids, e.g. `[[1], [3]]` (or `[[1, id], [3, id]]` for id-ful join tables).\n */\nfunction calcEnumLateralJoin<I extends EntityOrId>(\n assigner: AliasAssigner,\n root: { tree: HintNode<I>; alias: string; meta: EntityMetadata },\n subTree: HintNode<I>,\n parentAlias: string,\n field: ManyToManyEnumField,\n key: string,\n pathPrefix: string,\n): AggregateJoinResult {\n const [entityColumn, enumColumn] = field.columnNames;\n const jtAlias = `_${assigner.getAlias(field.joinTableName)}`;\n const relationAlias = `_${assigner.getLiteralAlias(`${pathPrefix}${key.toLowerCase()}`)}`;\n\n const parts = [kqDot(jtAlias, enumColumn)];\n if (field.hasJoinTableId) parts.push(kqDot(jtAlias, \"id\"));\n\n const cb = new ConditionBuilder();\n cb.addRawCondition({\n aliases: [jtAlias, parentAlias],\n condition: `${kqDot(jtAlias, entityColumn)} = ${kqDot(parentAlias, \"id\")}`,\n pruneable: true,\n });\n\n const needsSubSelect = subTree.entities.size !== root.tree.entities.size;\n if (needsSubSelect) {\n cb.addRawCondition({\n aliases: [root.alias],\n condition: `${kqDot(root.alias, \"id\")} = ANY(?)`,\n bindings: [\n [...subTree.entities]\n .filter((e) => typeof e === \"string\" || !e.isNewEntity)\n .map((e) => keyToNumber(root.meta, typeof e === \"string\" ? e : e.id)),\n ],\n pruneable: true,\n });\n }\n\n const orderBy = `${kq(jtAlias)}.${kq(field.hasJoinTableId ? \"id\" : enumColumn)}`;\n const join: LateralJoinTable = {\n join: \"lateral\",\n alias: jtAlias,\n fromAlias: \"unset\",\n table: field.joinTableName,\n query: {\n selects: [`json_agg(json_build_array(${parts.join(\", \")}) order by ${orderBy}) as _`],\n tables: [{ join: \"primary\", table: field.joinTableName, alias: jtAlias }],\n condition: cb.toExpressionFilter(),\n orderBys: [],\n },\n };\n\n const hydrator: AggregateJsonHydrator = (root, parent, arrays) => {\n const { em } = root;\n if (subTree.entitiesKind === \"instances\" && !subTree.entities.has(root as any)) return;\n if (subTree.entitiesKind === \"ids\" && !subTree.entities.has(root.idTagged as any)) return;\n const like: ManyToManyLike = {\n entity: parent,\n joinTableName: field.joinTableName,\n columnName: entityColumn,\n otherColumnName: enumColumn,\n fieldName: key,\n meta: getMetadataForField(getMetadata(parent), key),\n otherEnum: field.enumDetailType,\n hasJoinTableId: field.hasJoinTableId,\n };\n const api = getEmInternalApi(em);\n const joinRows = api.joinRows(like);\n const codes: any[] = [];\n for (const array of arrays) {\n const enumId = array[0] as number;\n joinRows.addPreloadedRow(like, field.hasJoinTableId ? (array[1] as number) : undefined, parent, enumId);\n codes.push(field.enumDetailType.findById(enumId)!.code);\n }\n api.setPreloadedRelation(parent.idTagged, key, codes);\n };\n\n return { alias: jtAlias, relationAlias, join, hydrator };\n}\n\n/** A preload-loadable join for a given child, with potentially grand-child joins contained within it. */\ntype AggregateJoinResult = {\n /** The short table alias used for column references inside the subquery, e.g. `_b1`. */\n alias: string;\n /** The readable relation-name alias used in the outer `AS` clause, e.g. `_prequel`. */\n relationAlias: string;\n /** The SQL for this child's lateral join, which itself might have recursive lateral joins. */\n join: LateralJoinTable;\n /** The hydrator for this child's lateral join, which itself might recursively hydrator subjoins. */\n hydrator: AggregateJsonHydrator;\n};\n\n/** Reads one column from either classic POJO rows or a lazy `RowData` result. */\nfunction readRowValue(rows: any[] | RowData, rowIndex: number, columnName: string): any {\n return Array.isArray(rows) ? rows[rowIndex][columnName] : rows.get(rowIndex, columnName);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,IAAa,yBAAb,MAA6D;CAC3D,cACE,MACA,MACoE;EACpE,OAAO,cAAc,MAAM,IAAI;CACjC;CAEA,cACE,MACA,MACA,OAC6B;EAC7B,MAAM,WAAW,IAAI,cAAc,KAAK;EAGxC,MAAM,QAAQ,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;EAClC,MAAM,QAAQ,iBAAiB,UAAU;GAAE,MAAM;GAAM;GAAO;EAAK,GAAG,MAAM,OAAO,IAAI;EAEvF,IAAI,MAAM,WAAW,GAAG,OAAO,KAAA;EAG/B,KAAK,MAAM,EAAE,OAAO,eAAe,UAAU,OAAO;GAClD,MAAM,QAAQ,KAAK;IACjB,KAAK,GAAG,MAAM,OAAO,GAAG,EAAE,MAA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M;CAAS;AACzD;;AAeA,SAAS,aAAa,MAAuB,UAAkB,YAAyB;CACtF,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC,cAAc,KAAK,IAAI,UAAU,UAAU;AACzF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../EntityMetadata.cjs");
|
|
3
|
-
|
|
3
|
+
// src/preloading/canPreload.ts
|
|
4
4
|
function canPreload(meta, field) {
|
|
5
5
|
if (field.kind === "m2mEnum") return true;
|
|
6
6
|
if (field.kind === "o2m" || field.kind === "o2o" || field.kind === "m2o" || field.kind === "m2m") {
|
|
@@ -13,7 +13,6 @@ function canPreload(meta, field) {
|
|
|
13
13
|
}
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
exports.canPreload = canPreload;
|
|
18
17
|
|
|
19
18
|
//# sourceMappingURL=canPreload.cjs.map
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { EntityMetadata, Field, ManyToManyEnumField, ManyToManyField, ManyToOneField, OneToManyField, OneToOneField } from "../EntityMetadata.cjs";
|
|
2
|
-
//#region src/preloading/canPreload.d.ts
|
|
3
2
|
export declare function canPreload(meta: EntityMetadata, field: Field): field is OneToManyField | ManyToOneField | ManyToManyField | ManyToManyEnumField | OneToOneField;
|
|
4
|
-
//#endregion
|
|
5
3
|
//# sourceMappingURL=canPreload.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canPreload.d.cts","names":[],"sources":["../../src/preloading/canPreload.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"canPreload.d.cts","names":[],"sources":["../../src/preloading/canPreload.ts"],"mappings":";wBAUgB,WACd,MAAM,gBACN,OAAO,QACN,SAAS,iBAAiB,iBAAiB,kBAAkB,sBAAsB"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { EntityMetadata, Field, ManyToManyEnumField, ManyToManyField, ManyToOneField, OneToManyField, OneToOneField } from "../EntityMetadata.mjs";
|
|
2
|
-
//#region src/preloading/canPreload.d.ts
|
|
3
2
|
export declare function canPreload(meta: EntityMetadata, field: Field): field is OneToManyField | ManyToOneField | ManyToManyField | ManyToManyEnumField | OneToOneField;
|
|
4
|
-
//#endregion
|
|
5
3
|
//# sourceMappingURL=canPreload.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canPreload.d.mts","names":[],"sources":["../../src/preloading/canPreload.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"canPreload.d.mts","names":[],"sources":["../../src/preloading/canPreload.ts"],"mappings":";wBAUgB,WACd,MAAM,gBACN,OAAO,QACN,SAAS,iBAAiB,iBAAiB,kBAAkB,sBAAsB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../EntityMetadata.js";
|
|
2
|
-
|
|
2
|
+
// src/preloading/canPreload.ts
|
|
3
3
|
function canPreload(meta, field) {
|
|
4
4
|
if (field.kind === "m2mEnum") return true;
|
|
5
5
|
if (field.kind === "o2m" || field.kind === "o2o" || field.kind === "m2o" || field.kind === "m2m") {
|
|
@@ -12,7 +12,6 @@ function canPreload(meta, field) {
|
|
|
12
12
|
}
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { canPreload };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=canPreload.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../EntityMetadata.cjs");
|
|
2
3
|
const require_getProperties = require("../getProperties.cjs");
|
|
3
|
-
const require_normalizeHints = require("../normalizeHints.cjs");
|
|
4
4
|
const require_relations_ReactiveReference = require("../relations/ReactiveReference.cjs");
|
|
5
|
-
require("../
|
|
6
|
-
require("../EntityMetadata.cjs");
|
|
5
|
+
const require_normalizeHints = require("../normalizeHints.cjs");
|
|
7
6
|
const require_preloading_canPreload = require("./canPreload.cjs");
|
|
8
|
-
|
|
7
|
+
require("../relations/index.cjs");
|
|
8
|
+
// src/preloading/partitionHint.ts
|
|
9
9
|
/** Partitions a hint into SQL-able and non-SQL-able hints. */
|
|
10
10
|
function partitionHint(meta, hint) {
|
|
11
11
|
let sql = void 0;
|
|
@@ -37,7 +37,6 @@ function partitionHint(meta, hint) {
|
|
|
37
37
|
function deepMerge(a, b) {
|
|
38
38
|
for (const [key, value] of Object.entries(b)) deepMerge(a[key] ??= {}, value);
|
|
39
39
|
}
|
|
40
|
-
//#endregion
|
|
41
40
|
exports.partitionHint = partitionHint;
|
|
42
41
|
|
|
43
42
|
//# sourceMappingURL=partitionHint.cjs.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { LoadHint, NestedLoadHint } from "../loading/loadHints.cjs";
|
|
2
1
|
import { EntityMetadata } from "../EntityMetadata.cjs";
|
|
3
|
-
|
|
2
|
+
import { LoadHint, NestedLoadHint } from "../loading/loadHints.cjs";
|
|
4
3
|
/** Partitions a hint into SQL-able and non-SQL-able hints. */
|
|
5
4
|
export declare function partitionHint(meta: EntityMetadata | undefined, hint: LoadHint<any>): [NestedLoadHint<any> | undefined, NestedLoadHint<any> | undefined];
|
|
6
|
-
//#endregion
|
|
7
5
|
//# sourceMappingURL=partitionHint.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partitionHint.d.cts","names":[],"sources":["../../src/preloading/partitionHint.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"partitionHint.d.cts","names":[],"sources":["../../src/preloading/partitionHint.ts"],"mappings":";;;wBAQgB,cACd,MAAM,4BACN,MAAM,iBACJ,iCAAiC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { LoadHint, NestedLoadHint } from "../loading/loadHints.mjs";
|
|
2
1
|
import { EntityMetadata } from "../EntityMetadata.mjs";
|
|
3
|
-
|
|
2
|
+
import { LoadHint, NestedLoadHint } from "../loading/loadHints.mjs";
|
|
4
3
|
/** Partitions a hint into SQL-able and non-SQL-able hints. */
|
|
5
4
|
export declare function partitionHint(meta: EntityMetadata | undefined, hint: LoadHint<any>): [NestedLoadHint<any> | undefined, NestedLoadHint<any> | undefined];
|
|
6
|
-
//#endregion
|
|
7
5
|
//# sourceMappingURL=partitionHint.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partitionHint.d.mts","names":[],"sources":["../../src/preloading/partitionHint.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"partitionHint.d.mts","names":[],"sources":["../../src/preloading/partitionHint.ts"],"mappings":";;;wBAQgB,cACd,MAAM,4BACN,MAAM,iBACJ,iCAAiC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import "../EntityMetadata.js";
|
|
1
2
|
import { getProperties } from "../getProperties.js";
|
|
2
|
-
import { deepNormalizeHint, normalizeHint } from "../normalizeHints.js";
|
|
3
3
|
import { ReactiveReferenceImpl } from "../relations/ReactiveReference.js";
|
|
4
|
-
import "../
|
|
5
|
-
import "../EntityMetadata.js";
|
|
4
|
+
import { deepNormalizeHint, normalizeHint } from "../normalizeHints.js";
|
|
6
5
|
import { canPreload } from "./canPreload.js";
|
|
7
|
-
|
|
6
|
+
import "../relations/index.js";
|
|
7
|
+
// src/preloading/partitionHint.ts
|
|
8
8
|
/** Partitions a hint into SQL-able and non-SQL-able hints. */
|
|
9
9
|
function partitionHint(meta, hint) {
|
|
10
10
|
let sql = void 0;
|
|
@@ -36,7 +36,6 @@ function partitionHint(meta, hint) {
|
|
|
36
36
|
function deepMerge(a, b) {
|
|
37
37
|
for (const [key, value] of Object.entries(b)) deepMerge(a[key] ??= {}, value);
|
|
38
38
|
}
|
|
39
|
-
//#endregion
|
|
40
39
|
export { partitionHint };
|
|
41
40
|
|
|
42
41
|
//# sourceMappingURL=partitionHint.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_EntityManager = require("../EntityManager.cjs");
|
|
2
3
|
const require_queries_skipCondition = require("./skipCondition.cjs");
|
|
3
4
|
const require_queries_valueFilters = require("./valueFilters.cjs");
|
|
4
5
|
const require_utils = require("../utils.cjs");
|
|
5
|
-
|
|
6
|
-
//#region src/queries/ConditionBuilder.ts
|
|
6
|
+
// src/queries/ConditionBuilder.ts
|
|
7
7
|
/** Converts domain-level values like string ids/enums into their db equivalent. */
|
|
8
8
|
var ConditionBuilder = class {
|
|
9
9
|
/** Simple, single-column conditions, which will be AND-d together. */
|
|
@@ -100,7 +100,6 @@ function parseExpression(expression) {
|
|
|
100
100
|
conditions: valid.filter(require_EntityManager.isDefined)
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
//#endregion
|
|
104
103
|
exports.ConditionBuilder = ConditionBuilder;
|
|
105
104
|
|
|
106
105
|
//# sourceMappingURL=ConditionBuilder.cjs.map
|