joist-core 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/BaseEntity.cjs +112 -0
- package/build/BaseEntity.cjs.map +1 -0
- package/build/BaseEntity.d.cts +73 -0
- package/build/BaseEntity.d.cts.map +1 -0
- package/build/BaseEntity.d.mts +73 -0
- package/build/BaseEntity.d.mts.map +1 -0
- package/build/BaseEntity.js +99 -110
- package/build/BaseEntity.js.map +1 -1
- package/build/Entity.cjs +12 -0
- package/build/Entity.cjs.map +1 -0
- package/build/Entity.d.cts +42 -0
- package/build/Entity.d.cts.map +1 -0
- package/build/Entity.d.mts +42 -0
- package/build/Entity.d.mts.map +1 -0
- package/build/Entity.js +8 -5
- package/build/Entity.js.map +1 -1
- package/build/EntityFields.cjs +1 -0
- package/build/EntityFields.d.cts +36 -0
- package/build/EntityFields.d.cts.map +1 -0
- package/build/EntityFields.d.mts +36 -0
- package/build/EntityFields.d.mts.map +1 -0
- package/build/EntityFields.js +1 -3
- package/build/EntityManager.cjs +1935 -0
- package/build/EntityManager.cjs.map +1 -0
- package/build/EntityManager.d.cts +835 -0
- package/build/EntityManager.d.cts.map +1 -0
- package/build/EntityManager.d.mts +835 -0
- package/build/EntityManager.d.mts.map +1 -0
- package/build/EntityManager.js +1812 -2211
- package/build/EntityManager.js.map +1 -1
- package/build/EntityMetadata.cjs +75 -0
- package/build/EntityMetadata.cjs.map +1 -0
- package/build/EntityMetadata.d.cts +262 -0
- package/build/EntityMetadata.d.cts.map +1 -0
- package/build/EntityMetadata.d.mts +262 -0
- package/build/EntityMetadata.d.mts.map +1 -0
- package/build/EntityMetadata.js +31 -48
- package/build/EntityMetadata.js.map +1 -1
- package/build/EnumMetadata.cjs +1 -0
- package/build/EnumMetadata.d.cts +18 -0
- package/build/EnumMetadata.d.cts.map +1 -0
- package/build/EnumMetadata.d.mts +18 -0
- package/build/EnumMetadata.d.mts.map +1 -0
- package/build/EnumMetadata.js +1 -3
- package/build/IndexManager.cjs +176 -0
- package/build/IndexManager.cjs.map +1 -0
- package/build/IndexManager.d.cts +36 -0
- package/build/IndexManager.d.cts.map +1 -0
- package/build/IndexManager.d.mts +36 -0
- package/build/IndexManager.d.mts.map +1 -0
- package/build/IndexManager.js +167 -218
- package/build/IndexManager.js.map +1 -1
- package/build/InstanceData.cjs +218 -0
- package/build/InstanceData.cjs.map +1 -0
- package/build/InstanceData.d.cts +98 -0
- package/build/InstanceData.d.cts.map +1 -0
- package/build/InstanceData.d.mts +98 -0
- package/build/InstanceData.d.mts.map +1 -0
- package/build/InstanceData.js +215 -222
- package/build/InstanceData.js.map +1 -1
- package/build/PluginManager.cjs +89 -0
- package/build/PluginManager.cjs.map +1 -0
- package/build/PluginManager.d.cts +112 -0
- package/build/PluginManager.d.cts.map +1 -0
- package/build/PluginManager.d.mts +112 -0
- package/build/PluginManager.d.mts.map +1 -0
- package/build/PluginManager.js +80 -106
- package/build/PluginManager.js.map +1 -1
- package/build/RowData.cjs +37 -0
- package/build/RowData.cjs.map +1 -0
- package/build/RowData.d.cts +53 -0
- package/build/RowData.d.cts.map +1 -0
- package/build/RowData.d.mts +53 -0
- package/build/RowData.d.mts.map +1 -0
- package/build/RowData.js +35 -0
- package/build/RowData.js.map +1 -0
- package/build/_virtual/_rolldown/runtime.cjs +23 -0
- package/build/batchloaders/BatchLoader.cjs +49 -0
- package/build/batchloaders/BatchLoader.cjs.map +1 -0
- package/build/batchloaders/BatchLoader.d.cts +17 -0
- package/build/batchloaders/BatchLoader.d.cts.map +1 -0
- package/build/batchloaders/BatchLoader.d.mts +17 -0
- package/build/batchloaders/BatchLoader.d.mts.map +1 -0
- package/build/batchloaders/BatchLoader.js +45 -54
- package/build/batchloaders/BatchLoader.js.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.cjs +66 -0
- package/build/batchloaders/enumCollectionBatchLoader.cjs.map +1 -0
- package/build/batchloaders/enumCollectionBatchLoader.d.cts +11 -0
- package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/enumCollectionBatchLoader.d.mts +11 -0
- package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/enumCollectionBatchLoader.js +58 -48
- package/build/batchloaders/enumCollectionBatchLoader.js.map +1 -1
- package/build/batchloaders/loadBatchLoader.cjs +78 -0
- package/build/batchloaders/loadBatchLoader.cjs.map +1 -0
- package/build/batchloaders/loadBatchLoader.d.cts +20 -0
- package/build/batchloaders/loadBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/loadBatchLoader.d.mts +20 -0
- package/build/batchloaders/loadBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/loadBatchLoader.js +72 -51
- package/build/batchloaders/loadBatchLoader.js.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.cjs +78 -0
- package/build/batchloaders/manyToManyBatchLoader.cjs.map +1 -0
- package/build/batchloaders/manyToManyBatchLoader.d.cts +11 -0
- package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/manyToManyBatchLoader.d.mts +11 -0
- package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/manyToManyBatchLoader.js +70 -61
- package/build/batchloaders/manyToManyBatchLoader.js.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.cjs +63 -0
- package/build/batchloaders/oneToManyBatchLoader.cjs.map +1 -0
- package/build/batchloaders/oneToManyBatchLoader.d.cts +11 -0
- package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/oneToManyBatchLoader.d.mts +11 -0
- package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/oneToManyBatchLoader.js +58 -48
- package/build/batchloaders/oneToManyBatchLoader.js.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.cjs +64 -0
- package/build/batchloaders/oneToOneBatchLoader.cjs.map +1 -0
- package/build/batchloaders/oneToOneBatchLoader.d.cts +10 -0
- package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/oneToOneBatchLoader.d.mts +10 -0
- package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/oneToOneBatchLoader.js +59 -50
- package/build/batchloaders/oneToOneBatchLoader.js.map +1 -1
- package/build/batchloaders/populateBatchLoader.cjs +155 -0
- package/build/batchloaders/populateBatchLoader.cjs.map +1 -0
- package/build/batchloaders/populateBatchLoader.d.cts +17 -0
- package/build/batchloaders/populateBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/populateBatchLoader.d.mts +17 -0
- package/build/batchloaders/populateBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/populateBatchLoader.js +147 -203
- package/build/batchloaders/populateBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs +78 -0
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs.map +1 -0
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +10 -0
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +10 -0
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/recursiveChildrenBatchLoader.js +71 -72
- package/build/batchloaders/recursiveChildrenBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.cjs +83 -0
- package/build/batchloaders/recursiveM2mBatchLoader.cjs.map +1 -0
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts +10 -0
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts +10 -0
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/recursiveM2mBatchLoader.js +76 -79
- package/build/batchloaders/recursiveM2mBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.cjs +65 -0
- package/build/batchloaders/recursiveParentsBatchLoader.cjs.map +1 -0
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts +10 -0
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -0
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts +10 -0
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -0
- package/build/batchloaders/recursiveParentsBatchLoader.js +58 -55
- package/build/batchloaders/recursiveParentsBatchLoader.js.map +1 -1
- package/build/changes.cjs +221 -0
- package/build/changes.cjs.map +1 -0
- package/build/changes.d.cts +95 -0
- package/build/changes.d.cts.map +1 -0
- package/build/changes.d.mts +95 -0
- package/build/changes.d.mts.map +1 -0
- package/build/changes.js +208 -285
- package/build/changes.js.map +1 -1
- package/build/config.cjs +295 -0
- package/build/config.cjs.map +1 -0
- package/build/config.d.cts +277 -0
- package/build/config.d.cts.map +1 -0
- package/build/config.d.mts +277 -0
- package/build/config.d.mts.map +1 -0
- package/build/config.js +255 -301
- package/build/config.js.map +1 -1
- package/build/configure.cjs +324 -0
- package/build/configure.cjs.map +1 -0
- package/build/configure.d.cts +19 -0
- package/build/configure.d.cts.map +1 -0
- package/build/configure.d.mts +19 -0
- package/build/configure.d.mts.map +1 -0
- package/build/configure.js +265 -348
- package/build/configure.js.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.cjs +140 -0
- package/build/dataloaders/fastWhereFilterHash.cjs.map +1 -0
- package/build/dataloaders/fastWhereFilterHash.d.cts +18 -0
- package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -0
- package/build/dataloaders/fastWhereFilterHash.d.mts +18 -0
- package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -0
- package/build/dataloaders/fastWhereFilterHash.js +108 -133
- package/build/dataloaders/fastWhereFilterHash.js.map +1 -1
- package/build/dataloaders/findByUniqueDataLoader.cjs +58 -0
- package/build/dataloaders/findByUniqueDataLoader.cjs.map +1 -0
- package/build/dataloaders/findByUniqueDataLoader.d.cts +10 -0
- package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -0
- package/build/dataloaders/findByUniqueDataLoader.d.mts +10 -0
- package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -0
- package/build/dataloaders/findByUniqueDataLoader.js +53 -44
- package/build/dataloaders/findByUniqueDataLoader.js.map +1 -1
- package/build/dataloaders/findCountDataLoader.cjs +123 -0
- package/build/dataloaders/findCountDataLoader.cjs.map +1 -0
- package/build/dataloaders/findCountDataLoader.d.cts +19 -0
- package/build/dataloaders/findCountDataLoader.d.cts.map +1 -0
- package/build/dataloaders/findCountDataLoader.d.mts +19 -0
- package/build/dataloaders/findCountDataLoader.d.mts.map +1 -0
- package/build/dataloaders/findCountDataLoader.js +112 -109
- package/build/dataloaders/findCountDataLoader.js.map +1 -1
- package/build/dataloaders/findDataLoader.cjs +365 -0
- package/build/dataloaders/findDataLoader.cjs.map +1 -0
- package/build/dataloaders/findDataLoader.d.cts +79 -0
- package/build/dataloaders/findDataLoader.d.cts.map +1 -0
- package/build/dataloaders/findDataLoader.d.mts +79 -0
- package/build/dataloaders/findDataLoader.d.mts.map +1 -0
- package/build/dataloaders/findDataLoader.js +298 -382
- package/build/dataloaders/findDataLoader.js.map +1 -1
- package/build/dataloaders/findIdsDataLoader.cjs +82 -0
- package/build/dataloaders/findIdsDataLoader.cjs.map +1 -0
- package/build/dataloaders/findIdsDataLoader.d.cts +9 -0
- package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -0
- package/build/dataloaders/findIdsDataLoader.d.mts +9 -0
- package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -0
- package/build/dataloaders/findIdsDataLoader.js +77 -74
- package/build/dataloaders/findIdsDataLoader.js.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.cjs +120 -0
- package/build/dataloaders/findOrCreateDataLoader.cjs.map +1 -0
- package/build/dataloaders/findOrCreateDataLoader.d.cts +15 -0
- package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -0
- package/build/dataloaders/findOrCreateDataLoader.d.mts +15 -0
- package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -0
- package/build/dataloaders/findOrCreateDataLoader.js +102 -164
- package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.cjs +98 -0
- package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -0
- package/build/dataloaders/findPaginatedDataLoader.d.cts +10 -0
- package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -0
- package/build/dataloaders/findPaginatedDataLoader.d.mts +10 -0
- package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -0
- package/build/dataloaders/findPaginatedDataLoader.js +93 -80
- package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
- package/build/dataloaders/lensDataLoader.cjs +178 -0
- package/build/dataloaders/lensDataLoader.cjs.map +1 -0
- package/build/dataloaders/lensDataLoader.d.cts +15 -0
- package/build/dataloaders/lensDataLoader.d.cts.map +1 -0
- package/build/dataloaders/lensDataLoader.d.mts +15 -0
- package/build/dataloaders/lensDataLoader.d.mts.map +1 -0
- package/build/dataloaders/lensDataLoader.js +172 -176
- package/build/dataloaders/lensDataLoader.js.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.cjs +84 -0
- package/build/dataloaders/manyToManyFindDataLoader.cjs.map +1 -0
- package/build/dataloaders/manyToManyFindDataLoader.d.cts +12 -0
- package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -0
- package/build/dataloaders/manyToManyFindDataLoader.d.mts +12 -0
- package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -0
- package/build/dataloaders/manyToManyFindDataLoader.js +76 -70
- package/build/dataloaders/manyToManyFindDataLoader.js.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.cjs +77 -0
- package/build/dataloaders/oneToManyFindDataLoader.cjs.map +1 -0
- package/build/dataloaders/oneToManyFindDataLoader.d.cts +12 -0
- package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -0
- package/build/dataloaders/oneToManyFindDataLoader.d.mts +12 -0
- package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -0
- package/build/dataloaders/oneToManyFindDataLoader.js +71 -67
- package/build/dataloaders/oneToManyFindDataLoader.js.map +1 -1
- package/build/defaults.cjs +195 -0
- package/build/defaults.cjs.map +1 -0
- package/build/defaults.d.cts +56 -0
- package/build/defaults.d.cts.map +1 -0
- package/build/defaults.d.mts +56 -0
- package/build/defaults.d.mts.map +1 -0
- package/build/defaults.js +171 -271
- package/build/defaults.js.map +1 -1
- package/build/drivers/Driver.cjs +3 -0
- package/build/drivers/Driver.d.cts +51 -0
- package/build/drivers/Driver.d.cts.map +1 -0
- package/build/drivers/Driver.d.mts +51 -0
- package/build/drivers/Driver.d.mts.map +1 -0
- package/build/drivers/Driver.js +3 -3
- package/build/drivers/EntityWriter.cjs +208 -0
- package/build/drivers/EntityWriter.cjs.map +1 -0
- package/build/drivers/EntityWriter.d.cts +66 -0
- package/build/drivers/EntityWriter.d.cts.map +1 -0
- package/build/drivers/EntityWriter.d.mts +66 -0
- package/build/drivers/EntityWriter.d.mts.map +1 -0
- package/build/drivers/EntityWriter.js +183 -219
- package/build/drivers/EntityWriter.js.map +1 -1
- package/build/drivers/IdAssigner.cjs +89 -0
- package/build/drivers/IdAssigner.cjs.map +1 -0
- package/build/drivers/IdAssigner.d.cts +50 -0
- package/build/drivers/IdAssigner.d.cts.map +1 -0
- package/build/drivers/IdAssigner.d.mts +50 -0
- package/build/drivers/IdAssigner.d.mts.map +1 -0
- package/build/drivers/IdAssigner.js +80 -124
- package/build/drivers/IdAssigner.js.map +1 -1
- package/build/drivers/driverApi.cjs +19 -0
- package/build/drivers/driverApi.cjs.map +1 -0
- package/build/drivers/driverApi.d.cts +22 -0
- package/build/drivers/driverApi.d.cts.map +1 -0
- package/build/drivers/driverApi.d.mts +22 -0
- package/build/drivers/driverApi.d.mts.map +1 -0
- package/build/drivers/driverApi.js +18 -0
- package/build/drivers/driverApi.js.map +1 -0
- package/build/drivers/index.cjs +7 -0
- package/build/drivers/index.d.cts +4 -0
- package/build/drivers/index.d.mts +4 -0
- package/build/drivers/index.js +3 -22
- package/build/fields.cjs +127 -0
- package/build/fields.cjs.map +1 -0
- package/build/fields.d.cts +29 -0
- package/build/fields.d.cts.map +1 -0
- package/build/fields.d.mts +29 -0
- package/build/fields.d.mts.map +1 -0
- package/build/fields.js +98 -160
- package/build/fields.js.map +1 -1
- package/build/flush/FlushLock.cjs +51 -0
- package/build/flush/FlushLock.cjs.map +1 -0
- package/build/flush/FlushLock.d.cts +29 -0
- package/build/flush/FlushLock.d.cts.map +1 -0
- package/build/flush/FlushLock.d.mts +29 -0
- package/build/flush/FlushLock.d.mts.map +1 -0
- package/build/flush/FlushLock.js +51 -0
- package/build/flush/FlushLock.js.map +1 -0
- package/build/flush/JoinRows.cjs +263 -0
- package/build/flush/JoinRows.cjs.map +1 -0
- package/build/flush/JoinRows.d.cts +120 -0
- package/build/flush/JoinRows.d.cts.map +1 -0
- package/build/flush/JoinRows.d.mts +120 -0
- package/build/flush/JoinRows.d.mts.map +1 -0
- package/build/flush/JoinRows.js +261 -0
- package/build/flush/JoinRows.js.map +1 -0
- package/build/flush/PendingChanges.cjs +1 -0
- package/build/flush/PendingChanges.d.cts +29 -0
- package/build/flush/PendingChanges.d.cts.map +1 -0
- package/build/flush/PendingChanges.d.mts +29 -0
- package/build/flush/PendingChanges.d.mts.map +1 -0
- package/build/flush/PendingChanges.js +1 -0
- package/build/flush/Todo.cjs +71 -0
- package/build/flush/Todo.cjs.map +1 -0
- package/build/flush/Todo.d.cts +38 -0
- package/build/flush/Todo.d.cts.map +1 -0
- package/build/flush/Todo.d.mts +38 -0
- package/build/flush/Todo.d.mts.map +1 -0
- package/build/flush/Todo.js +67 -0
- package/build/flush/Todo.js.map +1 -0
- package/build/getProperties.cjs +87 -0
- package/build/getProperties.cjs.map +1 -0
- package/build/getProperties.d.cts +30 -0
- package/build/getProperties.d.cts.map +1 -0
- package/build/getProperties.d.mts +30 -0
- package/build/getProperties.d.mts.map +1 -0
- package/build/getProperties.js +71 -128
- package/build/getProperties.js.map +1 -1
- package/build/index.cjs +524 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.cts +180 -0
- package/build/index.d.cts.map +1 -0
- package/build/index.d.mts +180 -0
- package/build/index.d.mts.map +1 -0
- package/build/index.js +171 -292
- package/build/index.js.map +1 -1
- package/build/json.cjs +79 -0
- package/build/json.cjs.map +1 -0
- package/build/json.d.cts +76 -0
- package/build/json.d.cts.map +1 -0
- package/build/json.d.mts +76 -0
- package/build/json.d.mts.map +1 -0
- package/build/json.js +68 -106
- package/build/json.js.map +1 -1
- package/build/k.cjs +9 -0
- package/build/k.cjs.map +1 -0
- package/build/k.d.cts +1 -0
- package/build/k.d.mts +1 -0
- package/build/k.js +6 -6
- package/build/k.js.map +1 -1
- package/build/keys.cjs +181 -0
- package/build/keys.cjs.map +1 -0
- package/build/keys.d.cts +55 -0
- package/build/keys.d.cts.map +1 -0
- package/build/keys.d.mts +55 -0
- package/build/keys.d.mts.map +1 -0
- package/build/keys.js +129 -162
- package/build/keys.js.map +1 -1
- package/build/loading/HintTree.cjs +67 -0
- package/build/loading/HintTree.cjs.map +1 -0
- package/build/loading/HintTree.d.cts +45 -0
- package/build/loading/HintTree.d.cts.map +1 -0
- package/build/loading/HintTree.d.mts +45 -0
- package/build/loading/HintTree.d.mts.map +1 -0
- package/build/loading/HintTree.js +66 -0
- package/build/loading/HintTree.js.map +1 -0
- package/build/loading/IsLoadedCache.cjs +58 -0
- package/build/loading/IsLoadedCache.cjs.map +1 -0
- package/build/loading/IsLoadedCache.d.cts +35 -0
- package/build/loading/IsLoadedCache.d.cts.map +1 -0
- package/build/loading/IsLoadedCache.d.mts +35 -0
- package/build/loading/IsLoadedCache.d.mts.map +1 -0
- package/build/loading/IsLoadedCache.js +57 -0
- package/build/loading/IsLoadedCache.js.map +1 -0
- package/build/loading/loadHints.cjs +95 -0
- package/build/loading/loadHints.cjs.map +1 -0
- package/build/loading/loadHints.d.cts +116 -0
- package/build/loading/loadHints.d.cts.map +1 -0
- package/build/loading/loadHints.d.mts +116 -0
- package/build/loading/loadHints.d.mts.map +1 -0
- package/build/loading/loadHints.js +88 -0
- package/build/loading/loadHints.js.map +1 -0
- package/build/loading/loadLens.cjs +212 -0
- package/build/loading/loadLens.cjs.map +1 -0
- package/build/loading/loadLens.d.cts +77 -0
- package/build/loading/loadLens.d.cts.map +1 -0
- package/build/loading/loadLens.d.mts +77 -0
- package/build/loading/loadLens.d.mts.map +1 -0
- package/build/loading/loadLens.js +201 -0
- package/build/loading/loadLens.js.map +1 -0
- package/build/loading/withLoaded.cjs +64 -0
- package/build/loading/withLoaded.cjs.map +1 -0
- package/build/loading/withLoaded.d.cts +65 -0
- package/build/loading/withLoaded.d.cts.map +1 -0
- package/build/loading/withLoaded.d.mts +65 -0
- package/build/loading/withLoaded.d.mts.map +1 -0
- package/build/loading/withLoaded.js +61 -0
- package/build/loading/withLoaded.js.map +1 -0
- package/build/logging/FactoryLogger.cjs +66 -0
- package/build/logging/FactoryLogger.cjs.map +1 -0
- package/build/logging/FactoryLogger.d.cts +27 -0
- package/build/logging/FactoryLogger.d.cts.map +1 -0
- package/build/logging/FactoryLogger.d.mts +27 -0
- package/build/logging/FactoryLogger.d.mts.map +1 -0
- package/build/logging/FactoryLogger.js +58 -73
- package/build/logging/FactoryLogger.js.map +1 -1
- package/build/logging/FieldLogger.cjs +57 -0
- package/build/logging/FieldLogger.cjs.map +1 -0
- package/build/logging/FieldLogger.d.cts +32 -0
- package/build/logging/FieldLogger.d.cts.map +1 -0
- package/build/logging/FieldLogger.d.mts +32 -0
- package/build/logging/FieldLogger.d.mts.map +1 -0
- package/build/logging/FieldLogger.js +51 -67
- package/build/logging/FieldLogger.js.map +1 -1
- package/build/logging/ReactionLogger.cjs +93 -0
- package/build/logging/ReactionLogger.cjs.map +1 -0
- package/build/logging/ReactionLogger.d.cts +37 -0
- package/build/logging/ReactionLogger.d.cts.map +1 -0
- package/build/logging/ReactionLogger.d.mts +37 -0
- package/build/logging/ReactionLogger.d.mts.map +1 -0
- package/build/logging/ReactionLogger.js +76 -66
- package/build/logging/ReactionLogger.js.map +1 -1
- package/build/newEntity.cjs +89 -0
- package/build/newEntity.cjs.map +1 -0
- package/build/newEntity.d.cts +48 -0
- package/build/newEntity.d.cts.map +1 -0
- package/build/newEntity.d.mts +48 -0
- package/build/newEntity.d.mts.map +1 -0
- package/build/newEntity.js +71 -94
- package/build/newEntity.js.map +1 -1
- package/build/newTestInstance.cjs +539 -0
- package/build/newTestInstance.cjs.map +1 -0
- package/build/newTestInstance.d.cts +207 -0
- package/build/newTestInstance.d.cts.map +1 -0
- package/build/newTestInstance.d.mts +207 -0
- package/build/newTestInstance.d.mts.map +1 -0
- package/build/newTestInstance.js +459 -721
- package/build/newTestInstance.js.map +1 -1
- package/build/normalizeHints.cjs +58 -0
- package/build/normalizeHints.cjs.map +1 -0
- package/build/normalizeHints.d.cts +24 -0
- package/build/normalizeHints.d.cts.map +1 -0
- package/build/normalizeHints.d.mts +24 -0
- package/build/normalizeHints.d.mts.map +1 -0
- package/build/normalizeHints.js +40 -55
- package/build/normalizeHints.js.map +1 -1
- package/build/nowUTC.cjs +15 -0
- package/build/nowUTC.cjs.map +1 -0
- package/build/nowUTC.d.cts +10 -0
- package/build/nowUTC.d.cts.map +1 -0
- package/build/nowUTC.d.mts +10 -0
- package/build/nowUTC.d.mts.map +1 -0
- package/build/nowUTC.js +14 -0
- package/build/nowUTC.js.map +1 -0
- package/build/plugins/ImmutableEntitiesPlugin.cjs +21 -0
- package/build/plugins/ImmutableEntitiesPlugin.cjs.map +1 -0
- package/build/plugins/ImmutableEntitiesPlugin.d.cts +12 -0
- package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -0
- package/build/plugins/ImmutableEntitiesPlugin.d.mts +12 -0
- package/build/plugins/ImmutableEntitiesPlugin.d.mts.map +1 -0
- package/build/plugins/ImmutableEntitiesPlugin.js +19 -20
- package/build/plugins/ImmutableEntitiesPlugin.js.map +1 -1
- package/build/plugins/PreloadPlugin.cjs +3 -0
- package/build/plugins/PreloadPlugin.d.cts +77 -0
- package/build/plugins/PreloadPlugin.d.cts.map +1 -0
- package/build/plugins/PreloadPlugin.d.mts +77 -0
- package/build/plugins/PreloadPlugin.d.mts.map +1 -0
- package/build/plugins/PreloadPlugin.js +3 -3
- package/build/preloading/JsonAggregatePreloader.cjs +280 -0
- package/build/preloading/JsonAggregatePreloader.cjs.map +1 -0
- package/build/preloading/JsonAggregatePreloader.d.cts +19 -0
- package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -0
- package/build/preloading/JsonAggregatePreloader.d.mts +19 -0
- package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -0
- package/build/preloading/JsonAggregatePreloader.js +270 -320
- package/build/preloading/JsonAggregatePreloader.js.map +1 -1
- package/build/preloading/canPreload.cjs +19 -0
- package/build/preloading/canPreload.cjs.map +1 -0
- package/build/preloading/canPreload.d.cts +6 -0
- package/build/preloading/canPreload.d.cts.map +1 -0
- package/build/preloading/canPreload.d.mts +6 -0
- package/build/preloading/canPreload.d.mts.map +1 -0
- package/build/preloading/canPreload.js +15 -21
- package/build/preloading/canPreload.js.map +1 -1
- package/build/preloading/partitionHint.cjs +43 -0
- package/build/preloading/partitionHint.cjs.map +1 -0
- package/build/preloading/partitionHint.d.cts +8 -0
- package/build/preloading/partitionHint.d.cts.map +1 -0
- package/build/preloading/partitionHint.d.mts +8 -0
- package/build/preloading/partitionHint.d.mts.map +1 -0
- package/build/preloading/partitionHint.js +36 -56
- package/build/preloading/partitionHint.js.map +1 -1
- package/build/queries/ConditionBuilder.cjs +106 -0
- package/build/queries/ConditionBuilder.cjs.map +1 -0
- package/build/queries/ConditionBuilder.d.cts +31 -0
- package/build/queries/ConditionBuilder.d.cts.map +1 -0
- package/build/queries/ConditionBuilder.d.mts +31 -0
- package/build/queries/ConditionBuilder.d.mts.map +1 -0
- package/build/queries/ConditionBuilder.js +105 -0
- package/build/queries/ConditionBuilder.js.map +1 -0
- package/build/queries/conditions.cjs +15 -0
- package/build/queries/conditions.cjs.map +1 -0
- package/build/queries/conditions.d.cts +38 -0
- package/build/queries/conditions.d.cts.map +1 -0
- package/build/queries/conditions.d.mts +38 -0
- package/build/queries/conditions.d.mts.map +1 -0
- package/build/queries/conditions.js +13 -0
- package/build/queries/conditions.js.map +1 -0
- package/build/queries/entityQueryUtils.cjs +60 -0
- package/build/queries/entityQueryUtils.cjs.map +1 -0
- package/build/queries/entityQueryUtils.d.cts +19 -0
- package/build/queries/entityQueryUtils.d.cts.map +1 -0
- package/build/queries/entityQueryUtils.d.mts +19 -0
- package/build/queries/entityQueryUtils.d.mts.map +1 -0
- package/build/queries/entityQueryUtils.js +56 -0
- package/build/queries/entityQueryUtils.js.map +1 -0
- package/build/queries/find/Aliases.cjs +301 -0
- package/build/queries/find/Aliases.cjs.map +1 -0
- package/build/queries/find/Aliases.d.cts +122 -0
- package/build/queries/find/Aliases.d.cts.map +1 -0
- package/build/queries/find/Aliases.d.mts +122 -0
- package/build/queries/find/Aliases.d.mts.map +1 -0
- package/build/queries/find/Aliases.js +293 -0
- package/build/queries/find/Aliases.js.map +1 -0
- package/build/queries/find/DeferredAlias.cjs +25 -0
- package/build/queries/find/DeferredAlias.cjs.map +1 -0
- package/build/queries/find/DeferredAlias.d.cts +22 -0
- package/build/queries/find/DeferredAlias.d.cts.map +1 -0
- package/build/queries/find/DeferredAlias.d.mts +22 -0
- package/build/queries/find/DeferredAlias.d.mts.map +1 -0
- package/build/queries/find/DeferredAlias.js +22 -0
- package/build/queries/find/DeferredAlias.js.map +1 -0
- package/build/queries/find/EntityFilter.cjs +27 -0
- package/build/queries/find/EntityFilter.cjs.map +1 -0
- package/build/queries/find/EntityFilter.d.cts +127 -0
- package/build/queries/find/EntityFilter.d.cts.map +1 -0
- package/build/queries/find/EntityFilter.d.mts +127 -0
- package/build/queries/find/EntityFilter.d.mts.map +1 -0
- package/build/queries/find/EntityFilter.js +26 -0
- package/build/queries/find/EntityFilter.js.map +1 -0
- package/build/queries/find/EntityGraphQLFilter.cjs +52 -0
- package/build/queries/find/EntityGraphQLFilter.cjs.map +1 -0
- package/build/queries/find/EntityGraphQLFilter.d.cts +59 -0
- package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -0
- package/build/queries/find/EntityGraphQLFilter.d.mts +59 -0
- package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -0
- package/build/queries/find/EntityGraphQLFilter.js +50 -0
- package/build/queries/find/EntityGraphQLFilter.js.map +1 -0
- package/build/queries/find/QueryParser.cjs +553 -0
- package/build/queries/find/QueryParser.cjs.map +1 -0
- package/build/queries/find/QueryParser.collectionJoins.cjs +353 -0
- package/build/queries/find/QueryParser.collectionJoins.cjs.map +1 -0
- package/build/queries/find/QueryParser.collectionJoins.d.cts +30 -0
- package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -0
- package/build/queries/find/QueryParser.collectionJoins.d.mts +30 -0
- package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -0
- package/build/queries/find/QueryParser.collectionJoins.js +352 -0
- package/build/queries/find/QueryParser.collectionJoins.js.map +1 -0
- package/build/queries/find/QueryParser.d.cts +192 -0
- package/build/queries/find/QueryParser.d.cts.map +1 -0
- package/build/queries/find/QueryParser.d.mts +192 -0
- package/build/queries/find/QueryParser.d.mts.map +1 -0
- package/build/queries/find/QueryParser.js +546 -0
- package/build/queries/find/QueryParser.js.map +1 -0
- package/build/queries/find/QueryParser.pruning.cjs +115 -0
- package/build/queries/find/QueryParser.pruning.cjs.map +1 -0
- package/build/queries/find/QueryParser.pruning.d.cts +8 -0
- package/build/queries/find/QueryParser.pruning.d.cts.map +1 -0
- package/build/queries/find/QueryParser.pruning.d.mts +8 -0
- package/build/queries/find/QueryParser.pruning.d.mts.map +1 -0
- package/build/queries/find/QueryParser.pruning.js +113 -0
- package/build/queries/find/QueryParser.pruning.js.map +1 -0
- package/build/queries/find/QueryVisitor.cjs +77 -0
- package/build/queries/find/QueryVisitor.cjs.map +1 -0
- package/build/queries/find/QueryVisitor.d.cts +24 -0
- package/build/queries/find/QueryVisitor.d.cts.map +1 -0
- package/build/queries/find/QueryVisitor.d.mts +24 -0
- package/build/queries/find/QueryVisitor.d.mts.map +1 -0
- package/build/queries/find/QueryVisitor.js +74 -0
- package/build/queries/find/QueryVisitor.js.map +1 -0
- package/build/queries/find/buildFindQuery.cjs +112 -0
- package/build/queries/find/buildFindQuery.cjs.map +1 -0
- package/build/queries/find/buildFindQuery.d.cts +24 -0
- package/build/queries/find/buildFindQuery.d.cts.map +1 -0
- package/build/queries/find/buildFindQuery.d.mts +24 -0
- package/build/queries/find/buildFindQuery.d.mts.map +1 -0
- package/build/queries/find/buildFindQuery.js +110 -0
- package/build/queries/find/buildFindQuery.js.map +1 -0
- package/build/queries/find/scopes.cjs +301 -0
- package/build/queries/find/scopes.cjs.map +1 -0
- package/build/queries/find/scopes.d.cts +188 -0
- package/build/queries/find/scopes.d.cts.map +1 -0
- package/build/queries/find/scopes.d.mts +188 -0
- package/build/queries/find/scopes.d.mts.map +1 -0
- package/build/queries/find/scopes.js +296 -0
- package/build/queries/find/scopes.js.map +1 -0
- package/build/queries/parsedConditions.cjs +21 -0
- package/build/queries/parsedConditions.cjs.map +1 -0
- package/build/queries/parsedConditions.d.cts +127 -0
- package/build/queries/parsedConditions.d.cts.map +1 -0
- package/build/queries/parsedConditions.d.mts +127 -0
- package/build/queries/parsedConditions.d.mts.map +1 -0
- package/build/queries/parsedConditions.js +20 -0
- package/build/queries/parsedConditions.js.map +1 -0
- package/build/queries/renderConditions.cjs +66 -0
- package/build/queries/renderConditions.cjs.map +1 -0
- package/build/queries/renderConditions.d.cts +15 -0
- package/build/queries/renderConditions.d.cts.map +1 -0
- package/build/queries/renderConditions.d.mts +15 -0
- package/build/queries/renderConditions.d.mts.map +1 -0
- package/build/queries/renderConditions.js +64 -0
- package/build/queries/renderConditions.js.map +1 -0
- package/build/queries/skipCondition.cjs +14 -0
- package/build/queries/skipCondition.cjs.map +1 -0
- package/build/queries/skipCondition.d.cts +7 -0
- package/build/queries/skipCondition.d.cts.map +1 -0
- package/build/queries/skipCondition.d.mts +7 -0
- package/build/queries/skipCondition.d.mts.map +1 -0
- package/build/queries/skipCondition.js +13 -0
- package/build/queries/skipCondition.js.map +1 -0
- package/build/queries/sql/AliasAssigner.cjs +35 -0
- package/build/queries/sql/AliasAssigner.cjs.map +1 -0
- package/build/queries/sql/AliasAssigner.d.cts +13 -0
- package/build/queries/sql/AliasAssigner.d.cts.map +1 -0
- package/build/queries/sql/AliasAssigner.d.mts +13 -0
- package/build/queries/sql/AliasAssigner.d.mts.map +1 -0
- package/build/queries/sql/AliasAssigner.js +34 -0
- package/build/queries/sql/AliasAssigner.js.map +1 -0
- package/build/queries/sql/Expr.cjs +529 -0
- package/build/queries/sql/Expr.cjs.map +1 -0
- package/build/queries/sql/Expr.d.cts +284 -0
- package/build/queries/sql/Expr.d.cts.map +1 -0
- package/build/queries/sql/Expr.d.mts +284 -0
- package/build/queries/sql/Expr.d.mts.map +1 -0
- package/build/queries/sql/Expr.js +512 -0
- package/build/queries/sql/Expr.js.map +1 -0
- package/build/queries/sql/JoinTree.cjs +72 -0
- package/build/queries/sql/JoinTree.cjs.map +1 -0
- package/build/queries/sql/JoinTree.d.cts +107 -0
- package/build/queries/sql/JoinTree.d.cts.map +1 -0
- package/build/queries/sql/JoinTree.d.mts +107 -0
- package/build/queries/sql/JoinTree.d.mts.map +1 -0
- package/build/queries/sql/JoinTree.js +71 -0
- package/build/queries/sql/JoinTree.js.map +1 -0
- package/build/queries/sql/Tables.cjs +803 -0
- package/build/queries/sql/Tables.cjs.map +1 -0
- package/build/queries/sql/Tables.d.cts +322 -0
- package/build/queries/sql/Tables.d.cts.map +1 -0
- package/build/queries/sql/Tables.d.mts +322 -0
- package/build/queries/sql/Tables.d.mts.map +1 -0
- package/build/queries/sql/Tables.js +786 -0
- package/build/queries/sql/Tables.js.map +1 -0
- package/build/queries/sql/custom.cjs +52 -0
- package/build/queries/sql/custom.cjs.map +1 -0
- package/build/queries/sql/custom.d.cts +85 -0
- package/build/queries/sql/custom.d.cts.map +1 -0
- package/build/queries/sql/custom.d.mts +85 -0
- package/build/queries/sql/custom.d.mts.map +1 -0
- package/build/queries/sql/custom.js +49 -0
- package/build/queries/sql/custom.js.map +1 -0
- package/build/queries/sql/execute.cjs +276 -0
- package/build/queries/sql/execute.cjs.map +1 -0
- package/build/queries/sql/execute.d.cts +294 -0
- package/build/queries/sql/execute.d.cts.map +1 -0
- package/build/queries/sql/execute.d.mts +294 -0
- package/build/queries/sql/execute.d.mts.map +1 -0
- package/build/queries/sql/execute.js +273 -0
- package/build/queries/sql/execute.js.map +1 -0
- package/build/queries/sql/expressions/arrayAgg.cjs +63 -0
- package/build/queries/sql/expressions/arrayAgg.cjs.map +1 -0
- package/build/queries/sql/expressions/arrayAgg.d.cts +24 -0
- package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -0
- package/build/queries/sql/expressions/arrayAgg.d.mts +24 -0
- package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -0
- package/build/queries/sql/expressions/arrayAgg.js +61 -0
- package/build/queries/sql/expressions/arrayAgg.js.map +1 -0
- package/build/queries/sql/expressions/case.cjs +71 -0
- package/build/queries/sql/expressions/case.cjs.map +1 -0
- package/build/queries/sql/expressions/case.d.cts +57 -0
- package/build/queries/sql/expressions/case.d.cts.map +1 -0
- package/build/queries/sql/expressions/case.d.mts +57 -0
- package/build/queries/sql/expressions/case.d.mts.map +1 -0
- package/build/queries/sql/expressions/case.js +68 -0
- package/build/queries/sql/expressions/case.js.map +1 -0
- package/build/queries/sql/expressions/coalesce.cjs +25 -0
- package/build/queries/sql/expressions/coalesce.cjs.map +1 -0
- package/build/queries/sql/expressions/coalesce.d.cts +21 -0
- package/build/queries/sql/expressions/coalesce.d.cts.map +1 -0
- package/build/queries/sql/expressions/coalesce.d.mts +21 -0
- package/build/queries/sql/expressions/coalesce.d.mts.map +1 -0
- package/build/queries/sql/expressions/coalesce.js +22 -0
- package/build/queries/sql/expressions/coalesce.js.map +1 -0
- package/build/queries/sql/expressions/codecs.cjs +126 -0
- package/build/queries/sql/expressions/codecs.cjs.map +1 -0
- package/build/queries/sql/expressions/codecs.d.cts +11 -0
- package/build/queries/sql/expressions/codecs.d.cts.map +1 -0
- package/build/queries/sql/expressions/codecs.d.mts +11 -0
- package/build/queries/sql/expressions/codecs.d.mts.map +1 -0
- package/build/queries/sql/expressions/codecs.js +125 -0
- package/build/queries/sql/expressions/codecs.js.map +1 -0
- package/build/queries/sql/expressions/expression.cjs +102 -0
- package/build/queries/sql/expressions/expression.cjs.map +1 -0
- package/build/queries/sql/expressions/expression.d.cts +23 -0
- package/build/queries/sql/expressions/expression.d.cts.map +1 -0
- package/build/queries/sql/expressions/expression.d.mts +23 -0
- package/build/queries/sql/expressions/expression.d.mts.map +1 -0
- package/build/queries/sql/expressions/expression.js +97 -0
- package/build/queries/sql/expressions/expression.js.map +1 -0
- package/build/queries/sql/expressions/greatest.cjs +25 -0
- package/build/queries/sql/expressions/greatest.cjs.map +1 -0
- package/build/queries/sql/expressions/greatest.d.cts +21 -0
- package/build/queries/sql/expressions/greatest.d.cts.map +1 -0
- package/build/queries/sql/expressions/greatest.d.mts +21 -0
- package/build/queries/sql/expressions/greatest.d.mts.map +1 -0
- package/build/queries/sql/expressions/greatest.js +22 -0
- package/build/queries/sql/expressions/greatest.js.map +1 -0
- package/build/queries/sql/expressions/least.cjs +25 -0
- package/build/queries/sql/expressions/least.cjs.map +1 -0
- package/build/queries/sql/expressions/least.d.cts +21 -0
- package/build/queries/sql/expressions/least.d.cts.map +1 -0
- package/build/queries/sql/expressions/least.d.mts +21 -0
- package/build/queries/sql/expressions/least.d.mts.map +1 -0
- package/build/queries/sql/expressions/least.js +22 -0
- package/build/queries/sql/expressions/least.js.map +1 -0
- package/build/queries/sql/expressions/nullIf.cjs +27 -0
- package/build/queries/sql/expressions/nullIf.cjs.map +1 -0
- package/build/queries/sql/expressions/nullIf.d.cts +22 -0
- package/build/queries/sql/expressions/nullIf.d.cts.map +1 -0
- package/build/queries/sql/expressions/nullIf.d.mts +22 -0
- package/build/queries/sql/expressions/nullIf.d.mts.map +1 -0
- package/build/queries/sql/expressions/nullIf.js +24 -0
- package/build/queries/sql/expressions/nullIf.js.map +1 -0
- package/build/queries/sql/expressions/parseExpression.cjs +75 -0
- package/build/queries/sql/expressions/parseExpression.cjs.map +1 -0
- package/build/queries/sql/expressions/parseExpression.d.cts +19 -0
- package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -0
- package/build/queries/sql/expressions/parseExpression.d.mts +19 -0
- package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -0
- package/build/queries/sql/expressions/parseExpression.js +70 -0
- package/build/queries/sql/expressions/parseExpression.js.map +1 -0
- package/build/queries/sql/expressions/types.cjs +1 -0
- package/build/queries/sql/expressions/types.d.cts +114 -0
- package/build/queries/sql/expressions/types.d.cts.map +1 -0
- package/build/queries/sql/expressions/types.d.mts +114 -0
- package/build/queries/sql/expressions/types.d.mts.map +1 -0
- package/build/queries/sql/expressions/types.js +1 -0
- package/build/queries/sql/keywords.cjs +136 -0
- package/build/queries/sql/keywords.cjs.map +1 -0
- package/build/queries/sql/keywords.d.cts +18 -0
- package/build/queries/sql/keywords.d.cts.map +1 -0
- package/build/queries/sql/keywords.d.mts +18 -0
- package/build/queries/sql/keywords.d.mts.map +1 -0
- package/build/queries/sql/keywords.js +132 -0
- package/build/queries/sql/keywords.js.map +1 -0
- package/build/queries/sql/query.cjs +1610 -0
- package/build/queries/sql/query.cjs.map +1 -0
- package/build/queries/sql/query.d.cts +844 -0
- package/build/queries/sql/query.d.cts.map +1 -0
- package/build/queries/sql/query.d.mts +844 -0
- package/build/queries/sql/query.d.mts.map +1 -0
- package/build/queries/sql/query.js +1592 -0
- package/build/queries/sql/query.js.map +1 -0
- package/build/queries/unnest.cjs +62 -0
- package/build/queries/unnest.cjs.map +1 -0
- package/build/queries/unnest.d.cts +16 -0
- package/build/queries/unnest.d.cts.map +1 -0
- package/build/queries/unnest.d.mts +16 -0
- package/build/queries/unnest.d.mts.map +1 -0
- package/build/queries/unnest.js +60 -0
- package/build/queries/unnest.js.map +1 -0
- package/build/queries/valueFilters.cjs +240 -0
- package/build/queries/valueFilters.cjs.map +1 -0
- package/build/queries/valueFilters.d.cts +26 -0
- package/build/queries/valueFilters.d.cts.map +1 -0
- package/build/queries/valueFilters.d.mts +26 -0
- package/build/queries/valueFilters.d.mts.map +1 -0
- package/build/queries/valueFilters.js +236 -0
- package/build/queries/valueFilters.js.map +1 -0
- package/build/reactivity/ReactionsManager.cjs +264 -0
- package/build/reactivity/ReactionsManager.cjs.map +1 -0
- package/build/reactivity/ReactionsManager.d.cts +98 -0
- package/build/reactivity/ReactionsManager.d.cts.map +1 -0
- package/build/reactivity/ReactionsManager.d.mts +98 -0
- package/build/reactivity/ReactionsManager.d.mts.map +1 -0
- package/build/reactivity/ReactionsManager.js +263 -0
- package/build/reactivity/ReactionsManager.js.map +1 -0
- package/build/reactivity/reactiveHints.cjs +328 -0
- package/build/reactivity/reactiveHints.cjs.map +1 -0
- package/build/reactivity/reactiveHints.d.cts +143 -0
- package/build/reactivity/reactiveHints.d.cts.map +1 -0
- package/build/reactivity/reactiveHints.d.mts +143 -0
- package/build/reactivity/reactiveHints.d.mts.map +1 -0
- package/build/reactivity/reactiveHints.js +321 -0
- package/build/reactivity/reactiveHints.js.map +1 -0
- package/build/relations/AbstractPropertyImpl.cjs +16 -0
- package/build/relations/AbstractPropertyImpl.cjs.map +1 -0
- package/build/relations/AbstractPropertyImpl.d.cts +11 -0
- package/build/relations/AbstractPropertyImpl.d.cts.map +1 -0
- package/build/relations/AbstractPropertyImpl.d.mts +11 -0
- package/build/relations/AbstractPropertyImpl.d.mts.map +1 -0
- package/build/relations/AbstractPropertyImpl.js +13 -13
- package/build/relations/AbstractPropertyImpl.js.map +1 -1
- package/build/relations/AbstractRelationImpl.cjs +15 -0
- package/build/relations/AbstractRelationImpl.cjs.map +1 -0
- package/build/relations/AbstractRelationImpl.d.cts +43 -0
- package/build/relations/AbstractRelationImpl.d.cts.map +1 -0
- package/build/relations/AbstractRelationImpl.d.mts +43 -0
- package/build/relations/AbstractRelationImpl.d.mts.map +1 -0
- package/build/relations/AbstractRelationImpl.js +12 -17
- package/build/relations/AbstractRelationImpl.js.map +1 -1
- package/build/relations/AsyncProperty.cjs +75 -0
- package/build/relations/AsyncProperty.cjs.map +1 -0
- package/build/relations/AsyncProperty.d.cts +40 -0
- package/build/relations/AsyncProperty.d.cts.map +1 -0
- package/build/relations/AsyncProperty.d.mts +40 -0
- package/build/relations/AsyncProperty.d.mts.map +1 -0
- package/build/relations/AsyncProperty.js +61 -70
- package/build/relations/AsyncProperty.js.map +1 -1
- package/build/relations/AsyncReactiveField.cjs +110 -0
- package/build/relations/AsyncReactiveField.cjs.map +1 -0
- package/build/relations/AsyncReactiveField.d.cts +50 -0
- package/build/relations/AsyncReactiveField.d.cts.map +1 -0
- package/build/relations/AsyncReactiveField.d.mts +50 -0
- package/build/relations/AsyncReactiveField.d.mts.map +1 -0
- package/build/relations/AsyncReactiveField.js +97 -116
- package/build/relations/AsyncReactiveField.js.map +1 -1
- package/build/relations/Collection.cjs +23 -0
- package/build/relations/Collection.cjs.map +1 -0
- package/build/relations/Collection.d.cts +37 -0
- package/build/relations/Collection.d.cts.map +1 -0
- package/build/relations/Collection.d.mts +37 -0
- package/build/relations/Collection.d.mts.map +1 -0
- package/build/relations/Collection.js +14 -11
- package/build/relations/Collection.js.map +1 -1
- package/build/relations/CustomCollection.cjs +144 -0
- package/build/relations/CustomCollection.cjs.map +1 -0
- package/build/relations/CustomCollection.d.cts +74 -0
- package/build/relations/CustomCollection.d.cts.map +1 -0
- package/build/relations/CustomCollection.d.mts +74 -0
- package/build/relations/CustomCollection.d.mts.map +1 -0
- package/build/relations/CustomCollection.js +138 -162
- package/build/relations/CustomCollection.js.map +1 -1
- package/build/relations/CustomReference.cjs +142 -0
- package/build/relations/CustomReference.cjs.map +1 -0
- package/build/relations/CustomReference.d.cts +76 -0
- package/build/relations/CustomReference.d.cts.map +1 -0
- package/build/relations/CustomReference.d.mts +76 -0
- package/build/relations/CustomReference.d.mts.map +1 -0
- package/build/relations/CustomReference.js +135 -147
- package/build/relations/CustomReference.js.map +1 -1
- package/build/relations/EnumCollection.cjs +178 -0
- package/build/relations/EnumCollection.cjs.map +1 -0
- package/build/relations/EnumCollection.d.cts +86 -0
- package/build/relations/EnumCollection.d.cts.map +1 -0
- package/build/relations/EnumCollection.d.mts +86 -0
- package/build/relations/EnumCollection.d.mts.map +1 -0
- package/build/relations/EnumCollection.js +172 -207
- package/build/relations/EnumCollection.js.map +1 -1
- package/build/relations/LargeCollection.cjs +4 -0
- package/build/relations/LargeCollection.d.cts +22 -0
- package/build/relations/LargeCollection.d.cts.map +1 -0
- package/build/relations/LargeCollection.d.mts +22 -0
- package/build/relations/LargeCollection.d.mts.map +1 -0
- package/build/relations/LargeCollection.js +4 -3
- package/build/relations/LazyField.cjs +140 -0
- package/build/relations/LazyField.cjs.map +1 -0
- package/build/relations/LazyField.d.cts +51 -0
- package/build/relations/LazyField.d.cts.map +1 -0
- package/build/relations/LazyField.d.mts +51 -0
- package/build/relations/LazyField.d.mts.map +1 -0
- package/build/relations/LazyField.js +134 -0
- package/build/relations/LazyField.js.map +1 -0
- package/build/relations/ManyToManyCollection.cjs +421 -0
- package/build/relations/ManyToManyCollection.cjs.map +1 -0
- package/build/relations/ManyToManyCollection.d.cts +59 -0
- package/build/relations/ManyToManyCollection.d.cts.map +1 -0
- package/build/relations/ManyToManyCollection.d.mts +59 -0
- package/build/relations/ManyToManyCollection.d.mts.map +1 -0
- package/build/relations/ManyToManyCollection.js +411 -471
- package/build/relations/ManyToManyCollection.js.map +1 -1
- package/build/relations/ManyToManyLargeCollection.cjs +91 -0
- package/build/relations/ManyToManyLargeCollection.cjs.map +1 -0
- package/build/relations/ManyToManyLargeCollection.d.cts +34 -0
- package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -0
- package/build/relations/ManyToManyLargeCollection.d.mts +34 -0
- package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -0
- package/build/relations/ManyToManyLargeCollection.js +85 -118
- package/build/relations/ManyToManyLargeCollection.js.map +1 -1
- package/build/relations/ManyToOneReference.cjs +364 -0
- package/build/relations/ManyToOneReference.cjs.map +1 -0
- package/build/relations/ManyToOneReference.d.cts +121 -0
- package/build/relations/ManyToOneReference.d.cts.map +1 -0
- package/build/relations/ManyToOneReference.d.mts +121 -0
- package/build/relations/ManyToOneReference.d.mts.map +1 -0
- package/build/relations/ManyToOneReference.js +344 -411
- package/build/relations/ManyToOneReference.js.map +1 -1
- package/build/relations/OneToManyCollection.cjs +492 -0
- package/build/relations/OneToManyCollection.cjs.map +1 -0
- package/build/relations/OneToManyCollection.d.cts +69 -0
- package/build/relations/OneToManyCollection.d.cts.map +1 -0
- package/build/relations/OneToManyCollection.d.mts +69 -0
- package/build/relations/OneToManyCollection.d.mts.map +1 -0
- package/build/relations/OneToManyCollection.js +480 -579
- package/build/relations/OneToManyCollection.js.map +1 -1
- package/build/relations/OneToManyLargeCollection.cjs +85 -0
- package/build/relations/OneToManyLargeCollection.cjs.map +1 -0
- package/build/relations/OneToManyLargeCollection.d.cts +29 -0
- package/build/relations/OneToManyLargeCollection.d.cts.map +1 -0
- package/build/relations/OneToManyLargeCollection.d.mts +29 -0
- package/build/relations/OneToManyLargeCollection.d.mts.map +1 -0
- package/build/relations/OneToManyLargeCollection.js +79 -99
- package/build/relations/OneToManyLargeCollection.js.map +1 -1
- package/build/relations/OneToOneReference.cjs +209 -0
- package/build/relations/OneToOneReference.cjs.map +1 -0
- package/build/relations/OneToOneReference.d.cts +97 -0
- package/build/relations/OneToOneReference.d.cts.map +1 -0
- package/build/relations/OneToOneReference.d.mts +97 -0
- package/build/relations/OneToOneReference.d.mts.map +1 -0
- package/build/relations/OneToOneReference.js +193 -221
- package/build/relations/OneToOneReference.js.map +1 -1
- package/build/relations/PolymorphicReference.cjs +210 -0
- package/build/relations/PolymorphicReference.cjs.map +1 -0
- package/build/relations/PolymorphicReference.d.cts +93 -0
- package/build/relations/PolymorphicReference.d.cts.map +1 -0
- package/build/relations/PolymorphicReference.d.mts +93 -0
- package/build/relations/PolymorphicReference.d.mts.map +1 -0
- package/build/relations/PolymorphicReference.js +200 -237
- package/build/relations/PolymorphicReference.js.map +1 -1
- package/build/relations/PropertySymbols.cjs +7 -0
- package/build/relations/PropertySymbols.cjs.map +1 -0
- package/build/relations/PropertySymbols.d.cts +5 -0
- package/build/relations/PropertySymbols.d.cts.map +1 -0
- package/build/relations/PropertySymbols.d.mts +5 -0
- package/build/relations/PropertySymbols.d.mts.map +1 -0
- package/build/relations/PropertySymbols.js +6 -0
- package/build/relations/PropertySymbols.js.map +1 -0
- package/build/relations/ReactiveField.cjs +114 -0
- package/build/relations/ReactiveField.cjs.map +1 -0
- package/build/relations/ReactiveField.d.cts +88 -0
- package/build/relations/ReactiveField.d.cts.map +1 -0
- package/build/relations/ReactiveField.d.mts +88 -0
- package/build/relations/ReactiveField.d.mts.map +1 -0
- package/build/relations/ReactiveField.js +104 -137
- package/build/relations/ReactiveField.js.map +1 -1
- package/build/relations/ReactiveGetter.cjs +40 -0
- package/build/relations/ReactiveGetter.cjs.map +1 -0
- package/build/relations/ReactiveGetter.d.cts +33 -0
- package/build/relations/ReactiveGetter.d.cts.map +1 -0
- package/build/relations/ReactiveGetter.d.mts +33 -0
- package/build/relations/ReactiveGetter.d.mts.map +1 -0
- package/build/relations/ReactiveGetter.js +30 -31
- package/build/relations/ReactiveGetter.js.map +1 -1
- package/build/relations/ReactiveManyToMany.cjs +198 -0
- package/build/relations/ReactiveManyToMany.cjs.map +1 -0
- package/build/relations/ReactiveManyToMany.d.cts +63 -0
- package/build/relations/ReactiveManyToMany.d.cts.map +1 -0
- package/build/relations/ReactiveManyToMany.d.mts +63 -0
- package/build/relations/ReactiveManyToMany.d.mts.map +1 -0
- package/build/relations/ReactiveManyToMany.js +187 -238
- package/build/relations/ReactiveManyToMany.js.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.cjs +148 -0
- package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -0
- package/build/relations/ReactiveManyToManyOtherSide.d.cts +53 -0
- package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -0
- package/build/relations/ReactiveManyToManyOtherSide.d.mts +53 -0
- package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -0
- package/build/relations/ReactiveManyToManyOtherSide.js +139 -152
- package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
- package/build/relations/ReactiveReference.cjs +336 -0
- package/build/relations/ReactiveReference.cjs.map +1 -0
- package/build/relations/ReactiveReference.d.cts +124 -0
- package/build/relations/ReactiveReference.d.cts.map +1 -0
- package/build/relations/ReactiveReference.d.mts +124 -0
- package/build/relations/ReactiveReference.d.mts.map +1 -0
- package/build/relations/ReactiveReference.js +321 -385
- package/build/relations/ReactiveReference.js.map +1 -1
- package/build/relations/ReadOnlyCollection.cjs +18 -0
- package/build/relations/ReadOnlyCollection.cjs.map +1 -0
- package/build/relations/ReadOnlyCollection.d.cts +22 -0
- package/build/relations/ReadOnlyCollection.d.cts.map +1 -0
- package/build/relations/ReadOnlyCollection.d.mts +22 -0
- package/build/relations/ReadOnlyCollection.d.mts.map +1 -0
- package/build/relations/ReadOnlyCollection.js +9 -9
- package/build/relations/ReadOnlyCollection.js.map +1 -1
- package/build/relations/RecursiveCollection.cjs +386 -0
- package/build/relations/RecursiveCollection.cjs.map +1 -0
- package/build/relations/RecursiveCollection.d.cts +112 -0
- package/build/relations/RecursiveCollection.d.cts.map +1 -0
- package/build/relations/RecursiveCollection.d.mts +112 -0
- package/build/relations/RecursiveCollection.d.mts.map +1 -0
- package/build/relations/RecursiveCollection.js +367 -427
- package/build/relations/RecursiveCollection.js.map +1 -1
- package/build/relations/RecursiveCycleError.cjs +17 -0
- package/build/relations/RecursiveCycleError.cjs.map +1 -0
- package/build/relations/RecursiveCycleError.d.cts +15 -0
- package/build/relations/RecursiveCycleError.d.cts.map +1 -0
- package/build/relations/RecursiveCycleError.d.mts +15 -0
- package/build/relations/RecursiveCycleError.d.mts.map +1 -0
- package/build/relations/RecursiveCycleError.js +14 -13
- package/build/relations/RecursiveCycleError.js.map +1 -1
- package/build/relations/Reference.cjs +25 -0
- package/build/relations/Reference.cjs.map +1 -0
- package/build/relations/Reference.d.cts +39 -0
- package/build/relations/Reference.d.cts.map +1 -0
- package/build/relations/Reference.d.mts +39 -0
- package/build/relations/Reference.d.mts.map +1 -0
- package/build/relations/Reference.js +15 -14
- package/build/relations/Reference.js.map +1 -1
- package/build/relations/ReferenceSymbols.cjs +7 -0
- package/build/relations/ReferenceSymbols.cjs.map +1 -0
- package/build/relations/ReferenceSymbols.d.cts +5 -0
- package/build/relations/ReferenceSymbols.d.cts.map +1 -0
- package/build/relations/ReferenceSymbols.d.mts +5 -0
- package/build/relations/ReferenceSymbols.d.mts.map +1 -0
- package/build/relations/ReferenceSymbols.js +6 -0
- package/build/relations/ReferenceSymbols.js.map +1 -0
- package/build/relations/Relation.cjs +17 -0
- package/build/relations/Relation.cjs.map +1 -0
- package/build/relations/Relation.d.cts +16 -0
- package/build/relations/Relation.d.cts.map +1 -0
- package/build/relations/Relation.d.mts +16 -0
- package/build/relations/Relation.d.mts.map +1 -0
- package/build/relations/Relation.js +10 -8
- package/build/relations/Relation.js.map +1 -1
- package/build/relations/RelationSymbols.cjs +9 -0
- package/build/relations/RelationSymbols.cjs.map +1 -0
- package/build/relations/RelationSymbols.d.cts +6 -0
- package/build/relations/RelationSymbols.d.cts.map +1 -0
- package/build/relations/RelationSymbols.d.mts +6 -0
- package/build/relations/RelationSymbols.d.mts.map +1 -0
- package/build/relations/RelationSymbols.js +7 -0
- package/build/relations/RelationSymbols.js.map +1 -0
- package/build/relations/hasAsyncMethod.cjs +47 -0
- package/build/relations/hasAsyncMethod.cjs.map +1 -0
- package/build/relations/hasAsyncMethod.d.cts +29 -0
- package/build/relations/hasAsyncMethod.d.cts.map +1 -0
- package/build/relations/hasAsyncMethod.d.mts +29 -0
- package/build/relations/hasAsyncMethod.d.mts.map +1 -0
- package/build/relations/hasAsyncMethod.js +40 -43
- package/build/relations/hasAsyncMethod.js.map +1 -1
- package/build/relations/hasManyDerived.cjs +35 -0
- package/build/relations/hasManyDerived.cjs.map +1 -0
- package/build/relations/hasManyDerived.d.cts +25 -0
- package/build/relations/hasManyDerived.d.cts.map +1 -0
- package/build/relations/hasManyDerived.d.mts +25 -0
- package/build/relations/hasManyDerived.d.mts.map +1 -0
- package/build/relations/hasManyDerived.js +30 -28
- package/build/relations/hasManyDerived.js.map +1 -1
- package/build/relations/hasManyThrough.cjs +29 -0
- package/build/relations/hasManyThrough.cjs.map +1 -0
- package/build/relations/hasManyThrough.d.cts +16 -0
- package/build/relations/hasManyThrough.d.cts.map +1 -0
- package/build/relations/hasManyThrough.d.mts +16 -0
- package/build/relations/hasManyThrough.d.mts.map +1 -0
- package/build/relations/hasManyThrough.js +24 -20
- package/build/relations/hasManyThrough.js.map +1 -1
- package/build/relations/hasOneDerived.cjs +32 -0
- package/build/relations/hasOneDerived.cjs.map +1 -0
- package/build/relations/hasOneDerived.d.cts +15 -0
- package/build/relations/hasOneDerived.d.cts.map +1 -0
- package/build/relations/hasOneDerived.d.mts +15 -0
- package/build/relations/hasOneDerived.d.mts.map +1 -0
- package/build/relations/hasOneDerived.js +27 -20
- package/build/relations/hasOneDerived.js.map +1 -1
- package/build/relations/hasOneThrough.cjs +31 -0
- package/build/relations/hasOneThrough.cjs.map +1 -0
- package/build/relations/hasOneThrough.d.cts +16 -0
- package/build/relations/hasOneThrough.d.cts.map +1 -0
- package/build/relations/hasOneThrough.d.mts +16 -0
- package/build/relations/hasOneThrough.d.mts.map +1 -0
- package/build/relations/hasOneThrough.js +26 -22
- package/build/relations/hasOneThrough.js.map +1 -1
- package/build/relations/hasProperty.cjs +109 -0
- package/build/relations/hasProperty.cjs.map +1 -0
- package/build/relations/hasProperty.d.cts +53 -0
- package/build/relations/hasProperty.d.cts.map +1 -0
- package/build/relations/hasProperty.d.mts +53 -0
- package/build/relations/hasProperty.d.mts.map +1 -0
- package/build/relations/hasProperty.js +90 -95
- package/build/relations/hasProperty.js.map +1 -1
- package/build/relations/index.cjs +99 -0
- package/build/relations/index.d.cts +32 -0
- package/build/relations/index.d.mts +32 -0
- package/build/relations/index.js +31 -97
- package/build/relations/isCascadeDelete.cjs +11 -0
- package/build/relations/isCascadeDelete.cjs.map +1 -0
- package/build/relations/isCascadeDelete.d.cts +7 -0
- package/build/relations/isCascadeDelete.d.cts.map +1 -0
- package/build/relations/isCascadeDelete.d.mts +7 -0
- package/build/relations/isCascadeDelete.d.mts.map +1 -0
- package/build/relations/isCascadeDelete.js +10 -0
- package/build/relations/isCascadeDelete.js.map +1 -0
- package/build/resurrection.cjs +74 -0
- package/build/resurrection.cjs.map +1 -0
- package/build/resurrection.d.cts +13 -0
- package/build/resurrection.d.cts.map +1 -0
- package/build/resurrection.d.mts +13 -0
- package/build/resurrection.d.mts.map +1 -0
- package/build/resurrection.js +48 -69
- package/build/resurrection.js.map +1 -1
- package/build/rules.cjs +227 -0
- package/build/rules.cjs.map +1 -0
- package/build/rules.d.cts +145 -0
- package/build/rules.d.cts.map +1 -0
- package/build/rules.d.mts +145 -0
- package/build/rules.d.mts.map +1 -0
- package/build/rules.js +189 -204
- package/build/rules.js.map +1 -1
- package/build/runtimeConfig.cjs +25 -0
- package/build/runtimeConfig.cjs.map +1 -0
- package/build/runtimeConfig.d.cts +24 -0
- package/build/runtimeConfig.d.cts.map +1 -0
- package/build/runtimeConfig.d.mts +24 -0
- package/build/runtimeConfig.d.mts.map +1 -0
- package/build/runtimeConfig.js +16 -12
- package/build/runtimeConfig.js.map +1 -1
- package/build/serde/TypeInfo.cjs +80 -0
- package/build/serde/TypeInfo.cjs.map +1 -0
- package/build/serde/TypeInfo.d.cts +57 -0
- package/build/serde/TypeInfo.d.cts.map +1 -0
- package/build/serde/TypeInfo.d.mts +57 -0
- package/build/serde/TypeInfo.d.mts.map +1 -0
- package/build/serde/TypeInfo.js +78 -0
- package/build/serde/TypeInfo.js.map +1 -0
- package/build/serde/columns.cjs +63 -0
- package/build/serde/columns.cjs.map +1 -0
- package/build/serde/columns.d.cts +38 -0
- package/build/serde/columns.d.cts.map +1 -0
- package/build/serde/columns.d.mts +38 -0
- package/build/serde/columns.d.mts.map +1 -0
- package/build/serde/columns.js +62 -0
- package/build/serde/columns.js.map +1 -0
- package/build/serde/fieldSerde.cjs +188 -0
- package/build/serde/fieldSerde.cjs.map +1 -0
- package/build/serde/fieldSerde.d.cts +87 -0
- package/build/serde/fieldSerde.d.cts.map +1 -0
- package/build/serde/fieldSerde.d.mts +87 -0
- package/build/serde/fieldSerde.d.mts.map +1 -0
- package/build/serde/fieldSerde.js +182 -0
- package/build/serde/fieldSerde.js.map +1 -0
- package/build/serde/serde.cjs +499 -0
- package/build/serde/serde.cjs.map +1 -0
- package/build/serde/serde.d.cts +248 -0
- package/build/serde/serde.d.cts.map +1 -0
- package/build/serde/serde.d.mts +248 -0
- package/build/serde/serde.d.mts.map +1 -0
- package/build/serde/serde.js +485 -0
- package/build/serde/serde.js.map +1 -0
- package/build/serde/temporal.cjs +57 -0
- package/build/serde/temporal.cjs.map +1 -0
- package/build/serde/temporal.d.cts +44 -0
- package/build/serde/temporal.d.cts.map +1 -0
- package/build/serde/temporal.d.mts +44 -0
- package/build/serde/temporal.d.mts.map +1 -0
- package/build/serde/temporal.js +55 -0
- package/build/serde/temporal.js.map +1 -0
- package/build/serde/temporalMappers.cjs +62 -0
- package/build/serde/temporalMappers.cjs.map +1 -0
- package/build/serde/temporalMappers.d.cts +36 -0
- package/build/serde/temporalMappers.d.cts.map +1 -0
- package/build/serde/temporalMappers.d.mts +36 -0
- package/build/serde/temporalMappers.d.mts.map +1 -0
- package/build/serde/temporalMappers.js +58 -0
- package/build/serde/temporalMappers.js.map +1 -0
- package/build/trusted.cjs +16 -0
- package/build/trusted.cjs.map +1 -0
- package/build/trusted.d.cts +8 -0
- package/build/trusted.d.cts.map +1 -0
- package/build/trusted.d.mts +8 -0
- package/build/trusted.d.mts.map +1 -0
- package/build/trusted.js +8 -8
- package/build/trusted.js.map +1 -1
- package/build/typeMap.cjs +3 -0
- package/build/typeMap.d.cts +88 -0
- package/build/typeMap.d.cts.map +1 -0
- package/build/typeMap.d.mts +88 -0
- package/build/typeMap.d.mts.map +1 -0
- package/build/typeMap.js +3 -3
- package/build/upsert.cjs +175 -0
- package/build/upsert.cjs.map +1 -0
- package/build/upsert.d.cts +42 -0
- package/build/upsert.d.cts.map +1 -0
- package/build/upsert.d.mts +42 -0
- package/build/upsert.d.mts.map +1 -0
- package/build/upsert.js +159 -274
- package/build/upsert.js.map +1 -1
- package/build/utils.cjs +204 -0
- package/build/utils.cjs.map +1 -0
- package/build/utils.d.cts +65 -0
- package/build/utils.d.cts.map +1 -0
- package/build/utils.d.mts +65 -0
- package/build/utils.d.mts.map +1 -0
- package/build/utils.js +123 -192
- package/build/utils.js.map +1 -1
- package/package.json +34 -14
- package/build/AliasAssigner.d.ts +0 -10
- package/build/AliasAssigner.d.ts.map +0 -1
- package/build/AliasAssigner.js +0 -39
- package/build/AliasAssigner.js.map +0 -1
- package/build/Aliases.d.ts +0 -117
- package/build/Aliases.d.ts.map +0 -1
- package/build/Aliases.js +0 -457
- package/build/Aliases.js.map +0 -1
- package/build/BaseEntity.d.ts +0 -68
- package/build/BaseEntity.d.ts.map +0 -1
- package/build/ConditionBuilder.d.ts +0 -29
- package/build/ConditionBuilder.d.ts.map +0 -1
- package/build/ConditionBuilder.js +0 -112
- package/build/ConditionBuilder.js.map +0 -1
- package/build/Entity.d.ts +0 -39
- package/build/Entity.d.ts.map +0 -1
- package/build/EntityFields.d.ts +0 -37
- package/build/EntityFields.d.ts.map +0 -1
- package/build/EntityFields.js.map +0 -1
- package/build/EntityFilter.d.ts +0 -134
- package/build/EntityFilter.d.ts.map +0 -1
- package/build/EntityFilter.js +0 -21
- package/build/EntityFilter.js.map +0 -1
- package/build/EntityGraphQLFilter.d.ts +0 -56
- package/build/EntityGraphQLFilter.d.ts.map +0 -1
- package/build/EntityGraphQLFilter.js +0 -53
- package/build/EntityGraphQLFilter.js.map +0 -1
- package/build/EntityManager.d.ts +0 -740
- package/build/EntityManager.d.ts.map +0 -1
- package/build/EntityMetadata.d.ts +0 -233
- package/build/EntityMetadata.d.ts.map +0 -1
- package/build/EnumMetadata.d.ts +0 -15
- package/build/EnumMetadata.d.ts.map +0 -1
- package/build/EnumMetadata.js.map +0 -1
- package/build/FlushLock.d.ts +0 -26
- package/build/FlushLock.d.ts.map +0 -1
- package/build/FlushLock.js +0 -57
- package/build/FlushLock.js.map +0 -1
- package/build/HintTree.d.ts +0 -42
- package/build/HintTree.d.ts.map +0 -1
- package/build/HintTree.js +0 -64
- package/build/HintTree.js.map +0 -1
- package/build/IndexManager.d.ts +0 -31
- package/build/IndexManager.d.ts.map +0 -1
- package/build/InstanceData.d.ts +0 -79
- package/build/InstanceData.d.ts.map +0 -1
- package/build/IsLoadedCache.d.ts +0 -32
- package/build/IsLoadedCache.d.ts.map +0 -1
- package/build/IsLoadedCache.js +0 -91
- package/build/IsLoadedCache.js.map +0 -1
- package/build/JoinRows.d.ts +0 -117
- package/build/JoinRows.d.ts.map +0 -1
- package/build/JoinRows.js +0 -320
- package/build/JoinRows.js.map +0 -1
- package/build/PendingChanges.d.ts +0 -26
- package/build/PendingChanges.d.ts.map +0 -1
- package/build/PendingChanges.js +0 -3
- package/build/PendingChanges.js.map +0 -1
- package/build/PluginManager.d.ts +0 -102
- package/build/PluginManager.d.ts.map +0 -1
- package/build/QueryParser.collectionJoins.d.ts +0 -27
- package/build/QueryParser.collectionJoins.d.ts.map +0 -1
- package/build/QueryParser.collectionJoins.js +0 -466
- package/build/QueryParser.collectionJoins.js.map +0 -1
- package/build/QueryParser.collectionJoins.test.d.ts +0 -2
- package/build/QueryParser.collectionJoins.test.d.ts.map +0 -1
- package/build/QueryParser.collectionJoins.test.js +0 -772
- package/build/QueryParser.collectionJoins.test.js.map +0 -1
- package/build/QueryParser.d.ts +0 -336
- package/build/QueryParser.d.ts.map +0 -1
- package/build/QueryParser.js +0 -965
- package/build/QueryParser.js.map +0 -1
- package/build/QueryParser.pruning.d.ts +0 -7
- package/build/QueryParser.pruning.d.ts.map +0 -1
- package/build/QueryParser.pruning.js +0 -195
- package/build/QueryParser.pruning.js.map +0 -1
- package/build/QueryParser.pruning.test.d.ts +0 -2
- package/build/QueryParser.pruning.test.d.ts.map +0 -1
- package/build/QueryParser.pruning.test.js +0 -106
- package/build/QueryParser.pruning.test.js.map +0 -1
- package/build/QueryParser.test.d.ts +0 -2
- package/build/QueryParser.test.d.ts.map +0 -1
- package/build/QueryParser.test.js +0 -27
- package/build/QueryParser.test.js.map +0 -1
- package/build/QueryVisitor.d.ts +0 -19
- package/build/QueryVisitor.d.ts.map +0 -1
- package/build/QueryVisitor.js +0 -106
- package/build/QueryVisitor.js.map +0 -1
- package/build/ReactionsManager.d.ts +0 -85
- package/build/ReactionsManager.d.ts.map +0 -1
- package/build/ReactionsManager.js +0 -315
- package/build/ReactionsManager.js.map +0 -1
- package/build/Todo.d.ts +0 -35
- package/build/Todo.d.ts.map +0 -1
- package/build/Todo.js +0 -73
- package/build/Todo.js.map +0 -1
- package/build/batchloaders/BatchLoader.d.ts +0 -14
- package/build/batchloaders/BatchLoader.d.ts.map +0 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.ts +0 -7
- package/build/batchloaders/enumCollectionBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/loadBatchLoader.d.ts +0 -17
- package/build/batchloaders/loadBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/manyToManyBatchLoader.d.ts +0 -7
- package/build/batchloaders/manyToManyBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/oneToManyBatchLoader.d.ts +0 -7
- package/build/batchloaders/oneToManyBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/oneToOneBatchLoader.d.ts +0 -7
- package/build/batchloaders/oneToOneBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/populateBatchLoader.d.ts +0 -13
- package/build/batchloaders/populateBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.ts +0 -7
- package/build/batchloaders/recursiveChildrenBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.ts +0 -7
- package/build/batchloaders/recursiveM2mBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.ts +0 -7
- package/build/batchloaders/recursiveParentsBatchLoader.d.ts.map +0 -1
- package/build/changes.d.ts +0 -92
- package/build/changes.d.ts.map +0 -1
- package/build/config.d.ts +0 -250
- package/build/config.d.ts.map +0 -1
- package/build/config.test.d.ts +0 -2
- package/build/config.test.d.ts.map +0 -1
- package/build/config.test.js +0 -53
- package/build/config.test.js.map +0 -1
- package/build/configure.d.ts +0 -15
- package/build/configure.d.ts.map +0 -1
- package/build/dataloaders/fastWhereFilterHash.d.ts +0 -15
- package/build/dataloaders/fastWhereFilterHash.d.ts.map +0 -1
- package/build/dataloaders/fastWhereFilterHash.test.d.ts +0 -2
- package/build/dataloaders/fastWhereFilterHash.test.d.ts.map +0 -1
- package/build/dataloaders/fastWhereFilterHash.test.js +0 -59
- package/build/dataloaders/fastWhereFilterHash.test.js.map +0 -1
- package/build/dataloaders/findByUniqueDataLoader.d.ts +0 -7
- package/build/dataloaders/findByUniqueDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findCountDataLoader.d.ts +0 -16
- package/build/dataloaders/findCountDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findDataLoader.d.ts +0 -76
- package/build/dataloaders/findDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findIdsDataLoader.d.ts +0 -6
- package/build/dataloaders/findIdsDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findOrCreateDataLoader.d.ts +0 -13
- package/build/dataloaders/findOrCreateDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findPaginatedDataLoader.d.ts +0 -7
- package/build/dataloaders/findPaginatedDataLoader.d.ts.map +0 -1
- package/build/dataloaders/lensDataLoader.d.ts +0 -12
- package/build/dataloaders/lensDataLoader.d.ts.map +0 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.ts +0 -8
- package/build/dataloaders/manyToManyFindDataLoader.d.ts.map +0 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.ts +0 -8
- package/build/dataloaders/oneToManyFindDataLoader.d.ts.map +0 -1
- package/build/defaults.d.ts +0 -54
- package/build/defaults.d.ts.map +0 -1
- package/build/driverApi.d.ts +0 -19
- package/build/driverApi.d.ts.map +0 -1
- package/build/driverApi.js +0 -17
- package/build/driverApi.js.map +0 -1
- package/build/drivers/Driver.d.ts +0 -26
- package/build/drivers/Driver.d.ts.map +0 -1
- package/build/drivers/Driver.js.map +0 -1
- package/build/drivers/EntityWriter.d.ts +0 -64
- package/build/drivers/EntityWriter.d.ts.map +0 -1
- package/build/drivers/IdAssigner.d.ts +0 -48
- package/build/drivers/IdAssigner.d.ts.map +0 -1
- package/build/drivers/buildRawQuery.d.ts +0 -22
- package/build/drivers/buildRawQuery.d.ts.map +0 -1
- package/build/drivers/buildRawQuery.js +0 -153
- package/build/drivers/buildRawQuery.js.map +0 -1
- package/build/drivers/buildUtils.d.ts +0 -9
- package/build/drivers/buildUtils.d.ts.map +0 -1
- package/build/drivers/buildUtils.js +0 -88
- package/build/drivers/buildUtils.js.map +0 -1
- package/build/drivers/index.d.ts +0 -6
- package/build/drivers/index.d.ts.map +0 -1
- package/build/drivers/index.js.map +0 -1
- package/build/fields.d.ts +0 -26
- package/build/fields.d.ts.map +0 -1
- package/build/getProperties.d.ts +0 -28
- package/build/getProperties.d.ts.map +0 -1
- package/build/index.d.ts +0 -133
- package/build/index.d.ts.map +0 -1
- package/build/json.d.ts +0 -77
- package/build/json.d.ts.map +0 -1
- package/build/k.d.ts +0 -2
- package/build/k.d.ts.map +0 -1
- package/build/keys.d.ts +0 -49
- package/build/keys.d.ts.map +0 -1
- package/build/keywords.d.ts +0 -5
- package/build/keywords.d.ts.map +0 -1
- package/build/keywords.js +0 -124
- package/build/keywords.js.map +0 -1
- package/build/loadHints.d.ts +0 -121
- package/build/loadHints.d.ts.map +0 -1
- package/build/loadHints.js +0 -129
- package/build/loadHints.js.map +0 -1
- package/build/loadLens.d.ts +0 -77
- package/build/loadLens.d.ts.map +0 -1
- package/build/loadLens.js +0 -320
- package/build/loadLens.js.map +0 -1
- package/build/logging/FactoryLogger.d.ts +0 -24
- package/build/logging/FactoryLogger.d.ts.map +0 -1
- package/build/logging/FieldLogger.d.ts +0 -27
- package/build/logging/FieldLogger.d.ts.map +0 -1
- package/build/logging/ReactionLogger.d.ts +0 -27
- package/build/logging/ReactionLogger.d.ts.map +0 -1
- package/build/newEntity.d.ts +0 -45
- package/build/newEntity.d.ts.map +0 -1
- package/build/newTestInstance.d.ts +0 -208
- package/build/newTestInstance.d.ts.map +0 -1
- package/build/normalizeHints.d.ts +0 -23
- package/build/normalizeHints.d.ts.map +0 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.ts +0 -9
- package/build/plugins/ImmutableEntitiesPlugin.d.ts.map +0 -1
- package/build/plugins/PreloadPlugin.d.ts +0 -69
- package/build/plugins/PreloadPlugin.d.ts.map +0 -1
- package/build/plugins/PreloadPlugin.js.map +0 -1
- package/build/preloading/JsonAggregatePreloader.d.ts +0 -16
- package/build/preloading/JsonAggregatePreloader.d.ts.map +0 -1
- package/build/preloading/canPreload.d.ts +0 -3
- package/build/preloading/canPreload.d.ts.map +0 -1
- package/build/preloading/partitionHint.d.ts +0 -5
- package/build/preloading/partitionHint.d.ts.map +0 -1
- package/build/reactiveHints.d.ts +0 -146
- package/build/reactiveHints.d.ts.map +0 -1
- package/build/reactiveHints.js +0 -509
- package/build/reactiveHints.js.map +0 -1
- package/build/relations/AbstractPropertyImpl.d.ts +0 -8
- package/build/relations/AbstractPropertyImpl.d.ts.map +0 -1
- package/build/relations/AbstractRelationImpl.d.ts +0 -41
- package/build/relations/AbstractRelationImpl.d.ts.map +0 -1
- package/build/relations/AsyncProperty.d.ts +0 -36
- package/build/relations/AsyncProperty.d.ts.map +0 -1
- package/build/relations/AsyncReactiveField.d.ts +0 -41
- package/build/relations/AsyncReactiveField.d.ts.map +0 -1
- package/build/relations/Collection.d.ts +0 -33
- package/build/relations/Collection.d.ts.map +0 -1
- package/build/relations/CustomCollection.d.ts +0 -69
- package/build/relations/CustomCollection.d.ts.map +0 -1
- package/build/relations/CustomReference.d.ts +0 -71
- package/build/relations/CustomReference.d.ts.map +0 -1
- package/build/relations/EnumCollection.d.ts +0 -81
- package/build/relations/EnumCollection.d.ts.map +0 -1
- package/build/relations/LargeCollection.d.ts +0 -19
- package/build/relations/LargeCollection.d.ts.map +0 -1
- package/build/relations/LargeCollection.js.map +0 -1
- package/build/relations/ManyToManyCollection.d.ts +0 -52
- package/build/relations/ManyToManyCollection.d.ts.map +0 -1
- package/build/relations/ManyToManyLargeCollection.d.ts +0 -31
- package/build/relations/ManyToManyLargeCollection.d.ts.map +0 -1
- package/build/relations/ManyToOneReference.d.ts +0 -117
- package/build/relations/ManyToOneReference.d.ts.map +0 -1
- package/build/relations/OneToManyCollection.d.ts +0 -62
- package/build/relations/OneToManyCollection.d.ts.map +0 -1
- package/build/relations/OneToManyLargeCollection.d.ts +0 -26
- package/build/relations/OneToManyLargeCollection.d.ts.map +0 -1
- package/build/relations/OneToOneReference.d.ts +0 -93
- package/build/relations/OneToOneReference.d.ts.map +0 -1
- package/build/relations/PolymorphicReference.d.ts +0 -89
- package/build/relations/PolymorphicReference.d.ts.map +0 -1
- package/build/relations/ReactiveField.d.ts +0 -85
- package/build/relations/ReactiveField.d.ts.map +0 -1
- package/build/relations/ReactiveGetter.d.ts +0 -30
- package/build/relations/ReactiveGetter.d.ts.map +0 -1
- package/build/relations/ReactiveManyToMany.d.ts +0 -57
- package/build/relations/ReactiveManyToMany.d.ts.map +0 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.ts +0 -48
- package/build/relations/ReactiveManyToManyOtherSide.d.ts.map +0 -1
- package/build/relations/ReactiveReference.d.ts +0 -119
- package/build/relations/ReactiveReference.d.ts.map +0 -1
- package/build/relations/ReadOnlyCollection.d.ts +0 -19
- package/build/relations/ReadOnlyCollection.d.ts.map +0 -1
- package/build/relations/RecursiveCollection.d.ts +0 -108
- package/build/relations/RecursiveCollection.d.ts.map +0 -1
- package/build/relations/RecursiveCycleError.d.ts +0 -13
- package/build/relations/RecursiveCycleError.d.ts.map +0 -1
- package/build/relations/Reference.d.ts +0 -35
- package/build/relations/Reference.d.ts.map +0 -1
- package/build/relations/Relation.d.ts +0 -14
- package/build/relations/Relation.d.ts.map +0 -1
- package/build/relations/hasAsyncMethod.d.ts +0 -27
- package/build/relations/hasAsyncMethod.d.ts.map +0 -1
- package/build/relations/hasManyDerived.d.ts +0 -22
- package/build/relations/hasManyDerived.d.ts.map +0 -1
- package/build/relations/hasManyThrough.d.ts +0 -10
- package/build/relations/hasManyThrough.d.ts.map +0 -1
- package/build/relations/hasOneDerived.d.ts +0 -12
- package/build/relations/hasOneDerived.d.ts.map +0 -1
- package/build/relations/hasOneThrough.d.ts +0 -10
- package/build/relations/hasOneThrough.d.ts.map +0 -1
- package/build/relations/hasProperty.d.ts +0 -50
- package/build/relations/hasProperty.d.ts.map +0 -1
- package/build/relations/index.d.ts +0 -30
- package/build/relations/index.d.ts.map +0 -1
- package/build/relations/index.js.map +0 -1
- package/build/resurrection.d.ts +0 -10
- package/build/resurrection.d.ts.map +0 -1
- package/build/rules.d.ts +0 -123
- package/build/rules.d.ts.map +0 -1
- package/build/runtimeConfig.d.ts +0 -17
- package/build/runtimeConfig.d.ts.map +0 -1
- package/build/scopes.d.ts +0 -185
- package/build/scopes.d.ts.map +0 -1
- package/build/scopes.js +0 -302
- package/build/scopes.js.map +0 -1
- package/build/serde.d.ts +0 -277
- package/build/serde.d.ts.map +0 -1
- package/build/serde.js +0 -517
- package/build/serde.js.map +0 -1
- package/build/temporal.d.ts +0 -46
- package/build/temporal.d.ts.map +0 -1
- package/build/temporal.js +0 -66
- package/build/temporal.js.map +0 -1
- package/build/temporalMappers.d.ts +0 -25
- package/build/temporalMappers.d.ts.map +0 -1
- package/build/temporalMappers.js +0 -59
- package/build/temporalMappers.js.map +0 -1
- package/build/trusted.d.ts +0 -5
- package/build/trusted.d.ts.map +0 -1
- package/build/typeMap.d.ts +0 -68
- package/build/typeMap.d.ts.map +0 -1
- package/build/typeMap.js.map +0 -1
- package/build/unnest.d.ts +0 -13
- package/build/unnest.d.ts.map +0 -1
- package/build/unnest.js +0 -85
- package/build/unnest.js.map +0 -1
- package/build/upsert.d.ts +0 -42
- package/build/upsert.d.ts.map +0 -1
- package/build/utils.d.ts +0 -60
- package/build/utils.d.ts.map +0 -1
- package/build/withLoaded.d.ts +0 -56
- package/build/withLoaded.d.ts.map +0 -1
- package/build/withLoaded.js +0 -76
- package/build/withLoaded.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryParser.cjs","names":["ConditionBuilder","abbreviation","filterSoftDeletes","getBaseMeta","isScope","parseEntityFilter","isAlias","kq","kqDot","getAliasMgmt","resolveScope","newAlias","isScopeJoinFilter","fail","getConstructorFromTaggedId","groupBy","mapToDb","keyToNumber","maybeResolveReferenceToId","getMaybeCtiAlias","alias","lazyExcludedSelects","getMetadataForTable","isDeferredCondition","predicateBrand","isDeferredAliasCondition","deferredAliasSym","stiSubtypeFilter"],"sources":["../../../src/queries/find/QueryParser.ts"],"sourcesContent":["import { groupBy } from \"joist-utils\";\nimport { getConstructorFromTaggedId, getMetadataForTable } from \"src/configure.ts\";\nimport type { Entity } from \"src/Entity.ts\";\nimport { type EntityMetadata, type Field, getBaseMeta } from \"src/EntityMetadata.ts\";\nimport { keyToNumber, maybeResolveReferenceToId } from \"src/keys.ts\";\nimport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nimport { type ConditionInput, predicateBrand } from \"src/queries/conditions.ts\";\nimport { filterSoftDeletes, lazyExcludedSelects, stiSubtypeFilter } from \"src/queries/entityQueryUtils.ts\";\nimport {\n type AliasMgmt,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n alias as newAlias,\n} from \"src/queries/find/Aliases.ts\";\nimport { deferredAliasSym, isDeferredAliasCondition } from \"src/queries/find/DeferredAlias.ts\";\nimport type { ExpressionFilter, OrderBy } from \"src/queries/find/EntityFilter.ts\";\nimport { pruneUnusedJoins } from \"src/queries/find/QueryParser.pruning.ts\";\nimport { visitConditions } from \"src/queries/find/QueryVisitor.ts\";\nimport { type Scope, isScope, isScopeJoinFilter, resolveScope } from \"src/queries/find/scopes.ts\";\nimport type { ColumnCondition, ParsedExpressionFilter, RawCondition } from \"src/queries/parsedConditions.ts\";\nimport { isDeferredCondition } from \"src/queries/sql/Expr.ts\";\nimport { kq, kqDot } from \"src/queries/sql/keywords.ts\";\nimport { type ParsedEntityFilter, mapToDb, parseEntityFilter, parseValueFilter } from \"src/queries/valueFilters.ts\";\nimport { abbreviation, fail } from \"src/utils.ts\";\n\n// `skipCondition` lives in its own leaf module, shared by domain aliases and SQL expressions\n// without a load-order cycle; `index.ts` re-exports it directly.\n\nexport interface PrimaryTable {\n join: \"primary\";\n alias: string;\n table: string;\n}\n\nexport interface JoinTable {\n join: \"inner\" | \"outer\";\n alias: string;\n table: string;\n col1: string;\n col2: string;\n distinct?: boolean;\n /**\n * Metadata used by `optimizeCollectionJoins` to rewrite collection joins into EXISTS.\n *\n * I.e. for `Author.books.reviews`:\n * ```sql\n * authors a\n * LEFT JOIN books b ON a.id = b.author_id\n * LEFT JOIN book_reviews br ON b.id = br.book_id\n * ```\n * `books b` has `parentAlias: \"a\"` and `rootAlias: \"b\"`, while `book_reviews br` has\n * `parentAlias: \"b\"` and `rootAlias: \"br\"`.\n *\n * I.e. for `Author.tags`, the m2m join table is the collection root:\n * ```sql\n * authors a\n * LEFT JOIN authors_to_tags att ON a.id = att.author_id\n * LEFT JOIN tags t ON att.tag_id = t.id\n * ```\n * `authors_to_tags att` has `alias: \"att\"` and `rootAlias: \"att\"`, while `tags t` has `alias: \"t\"`\n * but still has `rootAlias: \"att\"` because it belongs to the m2m subtree rooted at the join table.\n */\n collection?: {\n /** The collection relation type, i.e. `o2m` for `Author.books`, or `m2m` for `Author.tags`. */\n kind: \"o2m\" | \"m2m\";\n /** The alias that owns this collection path, i.e. `a` for `Author.books`, or `att` for `Author.tags -> tags`. */\n parentAlias: string;\n /** The top-level alias in this collection subtree, i.e. `b` for `Author.books.reviews`, or `att` for `Author.tags`. */\n rootAlias: string;\n };\n}\n\n/**\n * Creates a `CROSS JOIN`, currently used for our `em.find` batching.\n *\n * I.e. queries like:\n *\n * ```sql\n * WITH _find (tag, arg1, arg2) AS (VALUES\n * (0::int, 'a'::varchar, 'a'::varchar),\n * (1, 'b', 'b'),\n * (2, 'c', 'c')\n * )\n * SELECT a.*, array_agg(_find.tag) AS _tags\n * FROM authors a\n * CROSS JOIN _find AS _find\n * WHERE a.first_name = _find.arg0 OR a.last_name = _find.arg1\n * GROUP BY a.id\n * ```\n */\nexport interface CrossJoinTable {\n join: \"cross\";\n /** The new alias for the joined table. */\n alias: string;\n /** The table name to join into the query. */\n table: string;\n}\n\n/**\n * Adds `WITH` CTE clauses to the query.\n *\n * I.e. queries like:\n *\n * ```sql\n * WITH _find (tag, arg0, arg1) AS (\n * VALUES ($1::int, $2::character varying, $3::character varying), ($4, $5, $6)\n * )\n * ```\n */\nexport interface ParsedCteClause {\n /** The new alias for the CTE, i.e. `_find` in the above query. */\n alias: string;\n /** The columns, i.e. `tag, arg0, arg1` in the above query. */\n columns?: { columnName: string; dbType: string }[];\n /** The subquery for the AS of the CTE clause. */\n query: { kind: \"raw\"; sql: string; bindings: readonly any[] } | { kind: \"ast\"; query: ParsedFindQuery };\n /** Whether to include a `RECURSIVE` keyword after the `WITH`. */\n recursive?: boolean;\n}\n\n/**\n * Creates `LATERAL JOIN`s, currently used by `findCount` and JSON preloading.\n */\nexport interface LateralJoinTable {\n join: \"lateral\";\n alias: string;\n /** Used for join dependency tracking. */\n fromAlias: string;\n /** Used more for bookkeeping/consistency with other join tables than the query itself. */\n table: string;\n /** The subquery that will look for/roll-up N children. */\n query: ParsedFindQuery;\n /** Optional settings for the subquery, i.e. per-parent pagination. */\n settings?: { limit?: number; offset?: number };\n}\n\nexport type ParsedTable = PrimaryTable | JoinTable | CrossJoinTable | LateralJoinTable;\n\nexport interface ParsedOrderBy {\n alias: string;\n column: string;\n order: OrderBy;\n}\n\nexport type ParsedGroupBy = { alias: string; column: string } | { expression: string };\n\nexport type ParsedSelect = string | ParsedSelectWithBindings;\ntype ParsedSelectWithBindings = { sql: string; bindings: any[]; aliases: string[] };\n\n/** The result of parsing an `em.find` filter. */\nexport interface ParsedFindQuery {\n selects: ParsedSelect[];\n /** The primary table plus any joins. */\n tables: ParsedTable[];\n /** The query's conditions. */\n condition?: ParsedExpressionFilter;\n /** Extremely optional group bys; we generally don't support adhoc/aggregate queries, but the auto-batching infra uses these. */\n groupBys?: ParsedGroupBy[];\n /** Any optional orders to add before the default 'order by id'. */\n orderBys: ParsedOrderBy[];\n /** Optional CTE to prefix to the query, i.e. for recursive relations. */\n ctes?: ParsedCteClause[];\n}\n\n/**\n * Parses an `em.find` filter into a logical `ParsedFindQuery` AST, leaving optimization/pruning to callers.\n *\n * The main execution flow is:\n * parseFindQuery -> beforeFind plugins -> optimizeCollectionJoins -> pruneUnusedJoins -> execute SQL.\n */\nexport function parseFindQuery(\n meta: EntityMetadata,\n filter: any,\n opts: {\n conditions?: ExpressionFilter;\n orderBy?: any;\n pruneJoins?: boolean;\n keepAliases?: string[];\n softDeletes?: \"include\" | \"exclude\";\n allowMultipleLeftJoins?: boolean;\n optimizeJoinsToExists?: boolean;\n } = {},\n): ParsedFindQuery {\n const selects: string[] = [];\n const tables: ParsedTable[] = [];\n const orderBys: ParsedOrderBy[] = [];\n const query: ParsedFindQuery = { selects, tables, orderBys };\n const { orderBy, conditions: optsExpression, softDeletes = \"exclude\", pruneJoins = false, keepAliases = [] } = opts;\n const cb = new ConditionBuilder();\n // Where each user-created `alias(...)` is bound in this parse's join literal; alias-built conditions\n // (`a.firstName.eq(...)`) are resolved against it once the whole tree is walked\n const aliasBindings = new Map<AliasMgmt, { meta: EntityMetadata; alias: string }>();\n\n const aliases: Record<string, number> = {};\n function getAlias(tableName: string): string {\n const abbrev = abbreviation(tableName);\n const i = aliases[abbrev] || 0;\n aliases[abbrev] = i + 1;\n return i === 0 ? abbrev : `${abbrev}${i}`;\n }\n\n /** Adds a `deleted_at IS NULL` condition for `alias`, i.e. for the primary table or a collection join. */\n function addSoftDeleteCondition(meta: EntityMetadata, alias: string, targetCb: ConditionBuilder): void {\n if (filterSoftDeletes(meta, softDeletes)) {\n const column = meta.allFields[getBaseMeta(meta).timestampFields!.deletedAt!].serde?.columns[0]!;\n targetCb.addSimpleCondition({\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: { kind: \"is-null\" },\n pruneable: true,\n });\n }\n }\n\n function addTable(\n meta: EntityMetadata,\n alias: string,\n join: ParsedTable[\"join\"],\n col1: string,\n col2: string,\n filter: any,\n fieldName?: string,\n targetCb: ConditionBuilder = cb,\n /** Whether this table is the \"other side\" of a collection, i.e. `books` in `em.find(Author, { books: ... })`. */\n isCollection: boolean = false,\n ): void {\n // look at filter, is it `{ book: \"b2\" }` or `{ book: { ... } }`\n const scopeFilter = isScope(filter);\n const ef = scopeFilter ? undefined : parseEntityFilter(meta, filter);\n if (!scopeFilter && !ef && join !== \"primary\" && !isAlias(filter)) {\n return;\n }\n\n if (join === \"primary\") {\n tables.push({ alias, table: meta.tableName, join });\n addTablePerClassJoinsAndClassTag({ selects, tables, orderBys }, meta, alias, true);\n } else if (meta.inheritanceType === \"cti\" && fieldName && !(fieldName in meta.fields)) {\n // For cti, our meta might be a subtype while the FK is actually on the base table. This should only be the case\n // when the fk is on another table (e.g. o2o/o2m). In these cases, we'll be passed a field name and can verify if\n // its directly in our meta, if not we should assume it's in the base type and join that in first.\n meta.baseTypes.forEach((bt, i) => {\n tables.push({\n alias: `${alias}_b${i}`,\n table: bt.tableName,\n join: \"outer\",\n col1,\n col2: `${kq(`${alias}_b${i}`)}.${col2.split(\".\")[1]}`,\n distinct: false,\n });\n // and we still need to join in our subtype as well in case its own fields are queried against\n tables.push({\n alias: `${alias}`,\n table: meta.tableName,\n join: \"outer\",\n col1: kqDot(alias, \"id\"),\n col2: kqDot(`${alias}_b${i}`, \"id\"),\n distinct: false,\n });\n });\n } else if (join === \"lateral\" || join === \"cross\") {\n fail(\"Unexpected lateral join\");\n } else {\n tables.push({ alias, table: meta.tableName, join, col1, col2 });\n // Maybe only do this if we're the primary, or have a field that needs it?\n addTablePerClassJoinsAndClassTag({ selects, tables, orderBys }, meta, alias, false);\n }\n\n if (needsStiDiscriminator(meta)) {\n addStiSubtypeFilter(targetCb, meta, alias);\n }\n\n // Only the primary table & collection joins filter soft-deletes, to match the in-memory relation\n // semantics of \"o2m/m2m collections filter out soft-deletes, but m2o/o2o references still return\n // them\". I.e. `book.author.get` returns a soft-deleted author, so `em.find(Book, { author: ... })`\n // should still match the book, as long as the book itself is not soft-deleted.\n if (join === \"primary\" || isCollection) {\n addSoftDeleteCondition(meta, alias, targetCb);\n }\n\n // The user's locally declared aliases, i.e. `const [a, b] = aliases(Author, Book)`,\n // aren't guaranteed to line up with the aliases we've assigned internally, like `a`\n // might actually be `a1` if there are two `authors` tables in the query, so push the\n // canonical alias value for the current clause into the Alias.\n if (filter && typeof filter === \"object\" && \"as\" in filter && isAlias(filter.as)) {\n aliasBindings.set(getAliasMgmt(filter.as), { meta, alias });\n } else if (isAlias(filter)) {\n aliasBindings.set(getAliasMgmt(filter), { meta, alias });\n }\n\n addFilterAt(meta, alias, filter, targetCb, ef, join);\n }\n\n function addFilterAt(\n meta: EntityMetadata,\n tableAlias: string,\n filter: any,\n targetCb: ConditionBuilder,\n parsed: ParsedEntityFilter | undefined = parseEntityFilter(meta, filter),\n parentJoin: ParsedTable[\"join\"] = \"primary\",\n ): void {\n if (isScope(filter)) {\n addScopeFilterAt(meta, tableAlias, filter, targetCb, parentJoin);\n } else if (parsed && parsed.kind === \"join\") {\n addSubFilter(meta, tableAlias, parsed.subFilter, targetCb, parentJoin);\n } else if (parsed) {\n const column = meta.fields[\"id\"].serde!.columns[0];\n targetCb.addValueFilter(tableAlias, column, parsed);\n }\n }\n\n function addScopeFilterAt<T extends Entity>(\n meta: EntityMetadata<T>,\n tableAlias: string,\n scope: Scope<T>,\n targetCb: ConditionBuilder,\n parentJoin: ParsedTable[\"join\"],\n ): void {\n for (const fragment of resolveScope(scope).fragments) {\n if (fragment.kind === \"filter\") {\n addFilterAt(meta, tableAlias, fragment.filter, targetCb, undefined, parentJoin);\n } else {\n const a = newAlias(meta.cstr);\n const result = fragment.fn(a);\n aliasBindings.set(getAliasMgmt(a), { meta, alias: tableAlias });\n if (isScopeJoinFilter(result)) {\n // Parse the join tree first so its `as:` bindings re-root the aliases that\n // `conditions` reference, then add the conditions against the now-bound aliases.\n addFilterAt(meta, tableAlias, result.where, targetCb, undefined, parentJoin);\n checkDomainCondition(result.conditions);\n targetCb.maybeAddExpression(result.conditions);\n } else {\n const conditions = Array.isArray(result) ? result : [result];\n for (const condition of conditions) checkDomainCondition(condition);\n if (conditions.length > 0) targetCb.maybeAddExpression({ and: conditions });\n }\n }\n }\n }\n\n function addSubFilter(\n meta: EntityMetadata,\n tableAlias: string,\n subFilter: object,\n targetCb: ConditionBuilder,\n parentJoin: ParsedTable[\"join\"],\n ): void {\n // subFilter really means we're matching against the entity columns/further joins\n Object.keys(subFilter).forEach((key) => {\n // Skip the `{ as: ... }` alias binding\n if (key === \"as\") return;\n if (key === \"and\" || key === \"or\") {\n addLogicalFilter(meta, tableAlias, key, (subFilter as any)[key], targetCb, parentJoin);\n return;\n }\n const field = findFilterField(meta, key) ?? fail(`Field '${key}' not found on ${meta.tableName}`);\n const fa = `${tableAlias}${field.aliasSuffix}`;\n if (field.kind === \"primitive\" || field.kind === \"primaryKey\" || field.kind === \"enum\") {\n const column = field.serde.columns[0];\n parseValueFilter((subFilter as any)[key]).forEach((filter) => {\n targetCb.addValueFilter(fa, column, filter);\n });\n } else if (field.kind === \"m2o\") {\n const column = field.serde.columns[0];\n const sub = (subFilter as any)[key];\n const joinKind = field.required && parentJoin !== \"outer\" ? \"inner\" : \"outer\";\n if (isAlias(sub)) {\n const a = getAlias(field.otherMetadata().tableName);\n addTable(\n field.otherMetadata(),\n a,\n joinKind,\n kqDot(fa, column.columnName),\n kqDot(a, \"id\"),\n sub,\n undefined,\n targetCb,\n );\n }\n const f = parseEntityFilter(field.otherMetadata(), sub);\n // Probe the filter and see if it's just an id, if so we can avoid the join; m2os don't need\n // a join for soft-delete filtering because references don't filter out soft-deletes.\n if (!f) {\n // skip\n } else if (f.kind === \"join\") {\n const a = getAlias(field.otherMetadata().tableName);\n addTable(\n field.otherMetadata(),\n a,\n joinKind,\n kqDot(fa, column.columnName),\n kqDot(a, \"id\"),\n sub,\n undefined,\n targetCb,\n );\n } else {\n targetCb.addValueFilter(fa, column, f);\n }\n } else if (field.kind === \"poly\") {\n const f = parseEntityFilter(meta, (subFilter as any)[key]);\n if (!f) {\n // skip\n } else if (f.kind === \"join\") {\n throw new Error(\"Joins through polys are not supported\");\n } else {\n // We're left with basically a ValueFilter against the ids\n // For now only support eq/ne/in/is-null\n if (f.kind === \"eq\" || f.kind === \"ne\") {\n const comp = field.components.find((p) => {\n const otherMeta = p.otherMetadata();\n const cstr = getConstructorFromTaggedId(f.value as string);\n // tagged ids from subclasses always map to the base class, so we should compare to the base class if we don't directly match\n return otherMeta.cstr === cstr || otherMeta.baseType === cstr.name;\n });\n if (!comp) fail(`Invalid tagged id passed to ${meta.type}.${key}: ${f.value}`);\n const column = field.serde.columns.find((c) => c.columnName === comp.columnName)!;\n targetCb.addValueFilter(fa, column, f);\n } else if (f.kind === \"is-null\") {\n // Add a condition for every component--these can be AND-d with the rest of the simple/inline conditions\n field.components.forEach((comp) => {\n const column = field.serde.columns.find((c) => c.columnName === comp.columnName)!;\n targetCb.addSimpleCondition({\n kind: \"column\",\n alias: fa,\n column: comp.columnName,\n dbType: column.dbType,\n cond: f,\n });\n });\n } else if (f.kind === \"not-null\") {\n const conditions = field.components.map((comp) => {\n const column = field.serde.columns.find((c) => c.columnName === comp.columnName)!;\n return {\n kind: \"column\",\n alias: fa,\n column: comp.columnName,\n dbType: column.dbType,\n cond: { kind: \"not-null\" },\n };\n }) satisfies ColumnCondition[];\n targetCb.addParsedExpression({ kind: \"exp\", op: \"or\", conditions });\n } else if (f.kind === \"in\") {\n // An empty `in` matches nothing, so emit a single always-false condition (consistent\n // with a non-poly m2o `{ relation: [] }`); otherwise grouping by constructor would yield\n // zero conditions and prune the filter entirely, incorrectly matching every row.\n if (f.value.length === 0) {\n targetCb.addValueFilter(fa, field.serde.columns[0], { kind: \"in\", value: [] });\n return;\n }\n // Split up the ids by constructor\n const idsByConstructor = groupBy(f.value, (id) => getConstructorFromTaggedId(id as string).name);\n // Or together `parent_book_id in (1,2,3) OR parent_author_id IN (4,5,6)`\n // ...if there is a `parent IN [b:1, b:2, a:1, null]` we'd need to pull the `null` out and do an `OR (all columns are null)`...\n const conditions = Object.entries(idsByConstructor).map(([cstrName, ids]) => {\n const column =\n field.serde.columns.find(\n // tagged ids from subclasses always map to the base class, so we should compare to the base class if we don't directly match\n (c) => c.otherMetadata().cstr.name === cstrName || c.otherMetadata().baseType === cstrName,\n ) ?? fail(`Invalid tagged ids passed to ${meta.type}.${key}: ${ids}`);\n return {\n kind: \"column\",\n alias: fa,\n column: column.columnName,\n dbType: column.dbType,\n cond: mapToDb(column, { kind: \"in\", value: ids }),\n } satisfies ColumnCondition;\n });\n targetCb.addParsedExpression({ kind: \"exp\", op: \"or\", conditions });\n } else {\n throw new Error(`Filters on polys for ${f.kind} are not supported`);\n }\n }\n } else if (field.kind === \"o2o\") {\n // We have to always join into o2os, i.e. we can't probe the filter like we do for m2os\n const otherMeta = field.otherMetadata();\n const a = getAlias(otherMeta.tableName);\n const otherField = otherMeta.allFields[field.otherFieldName];\n const otherColumn =\n // if our other is a poly, we need to find a matching column rather than just picking the first\n otherField.kind === \"poly\"\n ? otherField.components.find((c) => c.otherMetadata() === meta || c.otherMetadata() === getBaseMeta(meta))!\n .columnName\n : otherField.serde!.columns[0].columnName;\n addTable(\n field.otherMetadata(),\n a,\n \"outer\",\n kqDot(tableAlias, \"id\"),\n kqDot(a, otherColumn),\n (subFilter as any)[key],\n field.otherFieldName,\n targetCb,\n );\n } else if (field.kind === \"o2m\") {\n const otherMeta = field.otherMetadata();\n const otherField = otherMeta.allFields[field.otherFieldName];\n let otherColumn = otherField.serde!.columns[0].columnName;\n if (otherField.kind === \"poly\") {\n const otherComponent =\n otherField.components.find((c) => c.otherMetadata() === meta) ??\n fail(`No poly component found for ${otherField.fieldName}`);\n otherColumn = otherComponent.columnName;\n }\n const isCtiBaseFk =\n otherMeta.inheritanceType === \"cti\" && field.otherFieldName && !(field.otherFieldName in otherMeta.fields);\n const a = getAlias(otherMeta.tableName);\n addTable(\n otherMeta,\n a,\n \"outer\",\n kqDot(tableAlias, \"id\"),\n kqDot(a, otherColumn),\n (subFilter as any)[key],\n field.otherFieldName,\n targetCb,\n true,\n );\n if (!isCtiBaseFk) {\n const table = tables.find((t) => t.alias === a);\n if (table && (table.join === \"inner\" || table.join === \"outer\")) {\n table.collection = { parentAlias: tableAlias, rootAlias: a, kind: \"o2m\" };\n }\n }\n } else if (field.kind === \"m2m\") {\n const sub = (subFilter as any)[key];\n const f = parseEntityFilter(field.otherMetadata(), sub);\n if (!f && !isAlias(sub)) return;\n\n const ja = getAlias(field.joinTableName);\n tables.push({\n join: \"outer\",\n alias: ja,\n table: field.joinTableName,\n col1: kqDot(tableAlias, \"id\"),\n col2: kqDot(ja, field.columnNames[0]),\n collection: { parentAlias: tableAlias, rootAlias: ja, kind: \"m2m\" },\n });\n\n if (isAlias(sub) || f?.kind === \"join\" || filterSoftDeletes(field.otherMetadata(), softDeletes)) {\n const a = getAlias(field.otherMetadata().tableName);\n addTable(\n field.otherMetadata(),\n a,\n \"outer\",\n kqDot(ja, field.columnNames[1]),\n kqDot(a, \"id\"),\n sub,\n undefined,\n targetCb,\n true,\n );\n const table = tables.find((t) => t.alias === a);\n if (table && (table.join === \"inner\" || table.join === \"outer\")) {\n table.collection = { parentAlias: ja, rootAlias: ja, kind: \"m2m\" };\n }\n } else if (f) {\n const otherMeta = field.otherMetadata();\n const column: any = {\n columnName: field.columnNames[1],\n dbType: otherMeta.idDbType,\n mapToDb(value: any) {\n return value === null ? value : keyToNumber(otherMeta, maybeResolveReferenceToId(value));\n },\n };\n targetCb.addSimpleCondition({\n kind: \"column\",\n alias: ja,\n column: field.columnNames[1],\n dbType: otherMeta.idDbType,\n cond: mapToDb(column, f),\n });\n }\n } else if (field.kind === \"m2mEnum\") {\n // Membership filter, e.g. `{ logoColors: Color.Red }` / `{ logoColors: [Red, Green] }`: join the\n // join table and filter its enum-id column, mapping enum codes -> their numeric ids.\n const ja = getAlias(field.joinTableName);\n tables.push({\n join: \"outer\",\n alias: ja,\n table: field.joinTableName,\n col1: kqDot(tableAlias, \"id\"),\n col2: kqDot(ja, field.columnNames[0]),\n collection: { parentAlias: tableAlias, rootAlias: ja, kind: \"m2m\" },\n });\n const column: any = {\n columnName: field.columnNames[1],\n dbType: \"int\",\n mapToDb(value: any) {\n return value === null || value === undefined ? value : field.enumDetailType.getByCode(value).id;\n },\n };\n parseValueFilter((subFilter as any)[key]).forEach((filter) => {\n targetCb.addValueFilter(ja, column, filter);\n });\n } else {\n throw new Error(`Unsupported field ${key}`);\n }\n });\n }\n\n function addLogicalFilter(\n meta: EntityMetadata,\n tableAlias: string,\n op: \"and\" | \"or\",\n value: unknown,\n targetCb: ConditionBuilder,\n parentJoin: ParsedTable[\"join\"],\n ): void {\n const filters = Array.isArray(value) ? value : [value];\n const conditions = filters.flatMap((filter) => {\n const branchCb = new ConditionBuilder();\n addFilterAt(meta, tableAlias, filter, branchCb, undefined, parentJoin);\n const condition = branchCb.toExpressionFilter();\n return condition ? [condition] : [];\n });\n if (conditions.length > 0) targetCb.addParsedExpression({ kind: \"exp\", op, conditions });\n }\n\n function addOrderBy(meta: EntityMetadata, alias: string, orderBy: Record<string, any>): void {\n const entries = Object.entries(orderBy);\n if (entries.length === 0) return;\n for (const [key, value] of entries) {\n if (!value) continue; // prune undefined\n const field = meta.allFields[key] ?? fail(`${key} not found on ${meta.tableName}`);\n if (field.kind === \"primitive\" || field.kind === \"primaryKey\" || field.kind === \"enum\") {\n const column = field.serde.columns[0];\n orderBys.push({\n alias: `${alias}${field.aliasSuffix ?? \"\"}`,\n column: column.columnName,\n order: value as OrderBy,\n });\n } else if (field.kind === \"m2o\") {\n // Do we already this table joined in?\n let table = tables.find((t) => t.table === field.otherMetadata().tableName);\n if (table) {\n addTablePerClassJoinsAndClassTag(query, field.otherMetadata(), table.alias, false);\n addOrderBy(field.otherMetadata(), table.alias, value);\n } else {\n const table = field.otherMetadata().tableName;\n const a = getAlias(table);\n const column = field.serde.columns[0].columnName;\n const fa = getMaybeCtiAlias(meta, field, meta, alias);\n // If we don't have a join, don't force this to be an inner join\n tables.push({\n alias: a,\n table,\n join: \"outer\",\n col1: kqDot(fa, column),\n col2: kqDot(a, \"id\"),\n distinct: false,\n });\n addTablePerClassJoinsAndClassTag(query, field.otherMetadata(), a, false);\n addOrderBy(field.otherMetadata(), a, value);\n }\n } else {\n throw new Error(`Unsupported field ${key}`);\n }\n }\n }\n\n // always add the main table\n const alias = getAlias(meta.tableName);\n if (meta.hasLazyColumns) {\n selects.push(...lazyExcludedSelects(meta, alias));\n } else {\n selects.push(`${kq(alias)}.*`);\n }\n addTable(meta, alias, \"primary\", \"n/a\", \"n/a\", filter);\n\n // If they passed extra `conditions: ...`, parse that\n if (optsExpression) {\n checkDomainCondition(optsExpression);\n cb.maybeAddExpression(optsExpression);\n }\n\n Object.assign(query, {\n condition: cb.toExpressionFilter(),\n });\n\n // Resolve alias-built conditions against this parse's bindings, before anything reads their\n // aliases (the id-not-null injection just below, and join pruning)\n resolveAliasConditions(query, aliasBindings);\n\n if (query.tables.some((t) => t.join === \"outer\")) {\n maybeAddIdNotNulls(query);\n }\n\n if (orderBy) {\n if (Array.isArray(orderBy)) {\n for (const ob of orderBy) addOrderBy(meta, alias, ob);\n } else {\n addOrderBy(meta, alias, orderBy);\n }\n }\n maybeAddOrderBy(query, meta, alias);\n\n if (pruneJoins) {\n pruneUnusedJoins(query, keepAliases);\n }\n return query;\n}\n\n/**\n * Look for conditions doing `some_column IS NULL` in an outer join that\n * need an `id IS NOT NULL` to make sure they don't match inadvertently on\n * the child row simply not existing.\n *\n * Note: Instead of injecting an extra `id IS NOT NULL` condition, I had tried\n * using all INNER JOINs and flipping joins to OUTER only if the user explicit\n * had `id IS NULL` in their filter, but that didn't work for queries that wanted\n * to do an `OR` across two different children (which queries both children being\n * OUTER JOINs, and detecting that case seemed complicated).\n */\nexport function maybeAddIdNotNulls(query: ParsedFindQuery): void {\n visitConditions(query, {\n visitCond(c: ColumnCondition) {\n // Check `c.prunable` to make sure we don't catch our injected `deleted_at is null` conditions\n if (c.cond.kind !== \"is-null\" || c.column === \"id\" || c.pruneable) {\n return c;\n }\n // This is an `some_column IS NULL`, is it in an outer join?\n const table = query.tables.find((t) => t.alias === c.alias);\n if (table && table.join === \"outer\") {\n const meta = getMetadataForTable(table.table);\n return {\n kind: \"exp\",\n op: \"and\",\n conditions: [\n c,\n {\n kind: \"column\",\n alias: c.alias,\n column: \"id\",\n dbType: meta.idDbType,\n cond: { kind: \"not-null\" },\n },\n ],\n } satisfies ParsedExpressionFilter;\n }\n return c;\n },\n });\n}\n\n/** Returns the `a` from `\"a\".*`. */\nexport function parseAlias(alias: string): string {\n return alias.split(\".\")[0].replaceAll(`\"`, \"\");\n}\n\n/** Finds a filter field by fieldName or generated fieldIdName. */\nexport function findFilterField(meta: EntityMetadata, key: string): (Field & { aliasSuffix: string }) | undefined {\n return (\n meta.allFields[key] ??\n meta.polyComponentFields?.[key] ??\n Object.values(meta.allFields).find((field) => field.fieldIdName === key) ??\n Object.values(meta.polyComponentFields ?? {}).find((field) => field.fieldIdName === key)\n );\n}\n\n/** Adds any user-configured default order, plus an \"always order by id\" for determinism. */\nexport function maybeAddOrderBy(query: ParsedFindQuery, meta: EntityMetadata, alias: string): void {\n const { orderBys } = query;\n if (meta.orderBy) {\n const field = meta.allFields[meta.orderBy] ?? fail(`${meta.orderBy} not found on ${meta.tableName}`);\n const column = field.serde!.columns[0].columnName;\n const hasAlready = orderBys.find((o) => o.alias === alias && o.column === column);\n if (!hasAlready) {\n orderBys.push({ alias, column, order: \"ASC\" });\n }\n }\n // Even if they already added orders, add id as the last one to get deterministic output\n const hasIdOrder = orderBys.find((o) => o.alias === alias && o.column === \"id\");\n if (!hasIdOrder) {\n orderBys.push({ alias, column: \"id\", order: \"ASC\" });\n }\n}\n\nexport function addTablePerClassJoinsAndClassTag(\n query: ParsedFindQuery,\n meta: EntityMetadata,\n alias: string,\n isPrimary: boolean,\n): void {\n if (!needsClassPerTableJoins(meta)) return;\n const { selects, tables } = query;\n // When `.load(SmallPublisher)` is called, join in base tables like `Publisher`\n meta.baseTypes.forEach((bt, i) => {\n if (isPrimary) {\n selects.push(`${alias}_b${i}.*`);\n }\n tables.push({\n alias: `${alias}_b${i}`,\n table: bt.tableName,\n join: \"outer\",\n col1: kqDot(alias, \"id\"),\n col2: `${alias}_b${i}.id`,\n distinct: false,\n });\n });\n\n // We always join in the base table in case a query happens to use\n // it as a filter, but we only need to do the subtype joins + selects\n // if this is the primary table\n if (isPrimary) {\n // Watch for subTypes that share column names. It'd be great to do\n // this statically at codegen time, like a meta.sharedSubtypeColumns.\n const stColumns: { stAlias: string; columnName: string }[] = [];\n\n // When `.load(Publisher)` is called, join in sub tables like `SmallPublisher` and `LargePublisher`\n meta.subTypes.forEach((st, i) => {\n const stAlias = `${alias}_s${i}`;\n selects.push(`${stAlias}.*`);\n tables.push({\n alias: stAlias,\n table: st.tableName,\n join: \"outer\",\n col1: kqDot(alias, \"id\"),\n col2: `${alias}_s${i}.id`,\n distinct: false,\n });\n for (const field of Object.values(st.fields)) {\n if (field.fieldName !== \"id\" && field.serde) {\n for (const c of field.serde?.columns) {\n stColumns.push({ stAlias, columnName: c.columnName });\n }\n }\n }\n });\n\n // Nominate a specific `id` column to avoid ambiguity\n selects.push(`${kq(alias)}.id as id`);\n\n // Add an explicit coalesce for shared columns\n Object.values(groupBy(stColumns, (c) => c.columnName))\n .filter((columns) => columns.length > 1)\n .forEach((columns) => {\n const { columnName } = columns[0];\n selects.push(`COALESCE(${columns.map((c) => `${c.stAlias}.${columnName}`).join(\", \")}) as ${columnName}`);\n });\n\n // If our meta has no subtypes, we're a left type and don't need a __class\n const cases = meta.subTypes.map((st, i) => `WHEN ${alias}_s${i}.id IS NOT NULL THEN '${st.type}'`);\n if (cases.length > 0) {\n selects.push(`CASE ${cases.join(\" \")} ELSE '_' END as __class`);\n }\n }\n}\n\n/** Rejects SQL predicates throughout a domain condition tree before optional-filter pruning. */\nfunction checkDomainCondition(condition: ConditionInput | undefined): void {\n if (!condition) return;\n if (isDeferredCondition(condition) || (predicateBrand in condition && condition[predicateBrand] === \"sql\")) {\n fail(\"SQL predicates are only supported by em.query/em.execute; use alias(...) predicates in em.find and scopes.\");\n }\n if (\"and\" in condition && condition.and) {\n for (const child of condition.and) checkDomainCondition(child);\n } else if (\"or\" in condition && condition.or) {\n for (const child of condition.or) checkDomainCondition(child);\n }\n}\n\n/** Resolves every `DeferredAliasCondition` in `query` against the parse's alias bindings. */\nfunction resolveAliasConditions(\n query: ParsedFindQuery,\n bindings: Map<AliasMgmt, { meta: EntityMetadata; alias: string }>,\n): void {\n function resolve(handle: AliasMgmt): { meta: EntityMetadata; alias: string } {\n return bindings.get(handle) ?? fail(`Alias for ${handle.tableName} is not bound to this query's join literal`);\n }\n function maybeResolve<C extends ColumnCondition | RawCondition>(c: C): C | undefined {\n return isDeferredAliasCondition(c) ? c[deferredAliasSym](resolve) : undefined;\n }\n visitConditions(query, { visitCond: maybeResolve, visitRaw: maybeResolve });\n}\n\nexport function getTables(query: ParsedFindQuery): [PrimaryTable, JoinTable[], LateralJoinTable[], CrossJoinTable[]] {\n let primary: PrimaryTable;\n const joins: JoinTable[] = [];\n const laterals: LateralJoinTable[] = [];\n const crosses: CrossJoinTable[] = [];\n for (const table of query.tables) {\n if (table.join === \"primary\") {\n primary = table;\n } else if (table.join === \"lateral\") {\n laterals.push(table);\n } else if (table.join === \"cross\") {\n crosses.push(table);\n } else {\n joins.push(table);\n }\n }\n return [primary!, joins, laterals, crosses];\n}\n\nfunction needsClassPerTableJoins(meta: EntityMetadata): boolean {\n return meta.inheritanceType === \"cti\" && (meta.subTypes.length > 0 || meta.baseTypes.length > 0);\n}\n\nfunction needsStiDiscriminator(meta: EntityMetadata): boolean {\n return meta.inheritanceType === \"sti\" && !meta.stiDiscriminatorField;\n}\n\nfunction addStiSubtypeFilter(cb: ConditionBuilder, subtypeMeta: EntityMetadata, alias: string): void {\n const cond = stiSubtypeFilter(subtypeMeta, alias);\n if (cond) cb.addSimpleCondition(cond);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2KA,SAAgB,eACd,MACA,QACA,OAQI,CAAC,GACY;CACjB,MAAM,UAAoB,CAAC;CAC3B,MAAM,SAAwB,CAAC;CAC/B,MAAM,WAA4B,CAAC;CACnC,MAAM,QAAyB;EAAE;EAAS;EAAQ;CAAS;CAC3D,MAAM,EAAE,SAAS,YAAY,gBAAgB,cAAc,WAAW,aAAa,OAAO,cAAc,CAAC,MAAM;CAC/G,MAAM,KAAK,IAAIA,iCAAAA,i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AqB;CACnG,MAAM,OAAOC,iCAAAA,iBAAiB,aAAa,KAAK;CAChD,IAAI,MAAM,GAAG,mBAAmB,IAAI;AACtC"}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_queries_find_QueryParser_pruning = require("./QueryParser.pruning.cjs");
|
|
3
|
+
const require_queries_find_QueryParser = require("./QueryParser.cjs");
|
|
4
|
+
const require_utils = require("../../utils.cjs");
|
|
5
|
+
//#region src/queries/find/QueryParser.collectionJoins.ts
|
|
6
|
+
/**
|
|
7
|
+
* Rewrites eligible logical collection LEFT JOINs into EXISTS after plugins have mutated the AST.
|
|
8
|
+
*
|
|
9
|
+
* QueryParser intentionally leaves collection filters as ordinary joins so `beforeFind` plugins see
|
|
10
|
+
* stabler/simpler input than "sometimes JOINs / sometimes EXISTS".
|
|
11
|
+
*
|
|
12
|
+
* This pass runs after plugins and before SQL rendering:
|
|
13
|
+
*
|
|
14
|
+
* 1. `rewriteCollectionJoins` finds top-level collection joins and moves conditions that reference only
|
|
15
|
+
* that subtree into a correlated EXISTS subquery. I.e. `{ books: { title: "b1" } }` becomes
|
|
16
|
+
* `EXISTS (SELECT 1 FROM books b WHERE a.id = b.author_id AND b.title = 'b1')`.
|
|
17
|
+
* 2. The same helper recurses into the generated subquery, so nested collections become nested EXISTS clauses.
|
|
18
|
+
* I.e. `{ books: { reviews: { rating: 5 } } }` becomes EXISTS(books WHERE EXISTS(reviews)).
|
|
19
|
+
* 3. Conditions that cannot be safely moved stay as LEFT JOINs. I.e. `OR(b.title = 'x', a.first_name = 'x')`
|
|
20
|
+
* needs both aliases in one SQL scope, so `b` remains a join instead of becoming an EXISTS.
|
|
21
|
+
* 4. Remaining fanout LEFT JOIN roots are rejected unless `allowMultipleLeftJoins` is set,
|
|
22
|
+
* because they can produce cross-product row explosions.
|
|
23
|
+
* 5. Finally, `maybeAddIdNotNulls` and `pruneUnusedJoins` clean up the joins that remain.
|
|
24
|
+
*/
|
|
25
|
+
function optimizeCollectionJoins(query, opts = {}) {
|
|
26
|
+
const { allowMultipleLeftJoins = false, optimizeJoinsToExists = true, pruneJoins = true, keepAliases = [] } = opts;
|
|
27
|
+
for (const table of query.tables) if (table.join === "lateral") optimizeCollectionJoins(table.query, {
|
|
28
|
+
...opts,
|
|
29
|
+
pruneJoins: false
|
|
30
|
+
});
|
|
31
|
+
if (optimizeJoinsToExists) rewriteCollectionJoins(query, keepAliases);
|
|
32
|
+
const fanoutLeftJoinAliases = getCollectionRoots(query).filter((root) => conditionBlocksExistsRewrite(query.condition, root.aliases)).map((root) => root.table.alias);
|
|
33
|
+
if (optimizeJoinsToExists && !allowMultipleLeftJoins && fanoutLeftJoinAliases.length > 1) throw new Error(`em.find would issue multiple LEFT JOINs across collection relations (${fanoutLeftJoinAliases.join(", ")}); pass allowMultipleLeftJoins: true if this fanout is intentional`);
|
|
34
|
+
if (query.tables.some((t) => t.join === "outer")) require_queries_find_QueryParser.maybeAddIdNotNulls(query);
|
|
35
|
+
if (pruneJoins) require_queries_find_QueryParser_pruning.pruneUnusedJoins(query, keepAliases);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Rewrites root-level collection join subtrees into EXISTS when their conditions are locally scoped.
|
|
39
|
+
*
|
|
40
|
+
* I.e. for `authors a -> books b -> book_reviews br`, `b` is the collection root and `br` is part of its subtree.
|
|
41
|
+
*/
|
|
42
|
+
function rewriteCollectionJoins(query, keepAliases = []) {
|
|
43
|
+
const roots = getCollectionRoots(query);
|
|
44
|
+
if (query.condition) rewriteSiblingOrExpression(query, query.condition, roots, keepAliases);
|
|
45
|
+
for (const root of roots) {
|
|
46
|
+
if (queryReferencesAliasesOutsideConditions(query, root.aliases, keepAliases)) continue;
|
|
47
|
+
if (conditionHasCrossScopeReference(query.condition, root.aliases)) continue;
|
|
48
|
+
const moved = query.condition ? removeLocallyScopedConditions(query.condition, root.aliases) : [];
|
|
49
|
+
if (moved.length === 0) continue;
|
|
50
|
+
const exists = createExistsCondition(query, root, moved);
|
|
51
|
+
if (!exists) {
|
|
52
|
+
addConditions(query, moved);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
addConditions(query, [exists]);
|
|
56
|
+
query.tables = query.tables.filter((t) => !root.aliases.has(t.alias));
|
|
57
|
+
}
|
|
58
|
+
removeEmptyExpressions(query.condition);
|
|
59
|
+
}
|
|
60
|
+
/** Rewrites eligible sibling collection ORs while preserving outer/mixed-scope ORs as joins. */
|
|
61
|
+
function rewriteSiblingOrExpression(query, condition, roots, keepAliases) {
|
|
62
|
+
if (condition.kind !== "exp") return;
|
|
63
|
+
if (condition.op === "or" && rewriteSiblingOrExpressionChildren(query, condition, roots, keepAliases)) return;
|
|
64
|
+
if (condition.op === "and") for (const child of condition.conditions) rewriteSiblingOrExpression(query, child, roots, keepAliases);
|
|
65
|
+
}
|
|
66
|
+
/** Returns true when OR branches that are scoped to collection subtrees became EXISTS conditions. */
|
|
67
|
+
function rewriteSiblingOrExpressionChildren(query, exp, roots, keepAliases) {
|
|
68
|
+
const matches = [];
|
|
69
|
+
const usedAliases = /* @__PURE__ */ new Set();
|
|
70
|
+
const usedRoots = /* @__PURE__ */ new Set();
|
|
71
|
+
let hasAntiJoinBranch = false;
|
|
72
|
+
for (const condition of exp.conditions) {
|
|
73
|
+
if (!isRealCondition(condition)) return false;
|
|
74
|
+
const match = roots.find((root) => conditionReferencesOnlyAliases(condition, root.aliases));
|
|
75
|
+
if (!match) {
|
|
76
|
+
const found = conditionAliases(condition);
|
|
77
|
+
if (roots.some((root) => hasAnyAlias(found, root.aliases))) return false;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
matches.push({
|
|
81
|
+
collectionRoot: match,
|
|
82
|
+
condition
|
|
83
|
+
});
|
|
84
|
+
usedRoots.add(match.table.alias);
|
|
85
|
+
hasAntiJoinBranch ||= isCollectionAntiJoin(condition, match);
|
|
86
|
+
for (const alias of match.aliases) usedAliases.add(alias);
|
|
87
|
+
}
|
|
88
|
+
if (matches.length === 0) return false;
|
|
89
|
+
if (matches.length === exp.conditions.length && usedRoots.size < 2 && !hasAntiJoinBranch || conditionReferencesAliasesOutside(query.condition, exp, usedAliases) || queryReferencesAliasesOutsideConditions(query, usedAliases, keepAliases)) return false;
|
|
90
|
+
const existsConditions = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const match of matches) {
|
|
92
|
+
const exists = createExistsCondition(query, match.collectionRoot, [match.condition]);
|
|
93
|
+
if (!exists) return false;
|
|
94
|
+
existsConditions.set(match.condition, exists);
|
|
95
|
+
}
|
|
96
|
+
exp.conditions = exp.conditions.map((condition) => existsConditions.get(condition) ?? condition);
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
/** Creates an EXISTS/NOT EXISTS condition for moved collection filters, or undefined when a LEFT JOIN must stay. */
|
|
100
|
+
function createExistsCondition(query, collectionRoot, moved) {
|
|
101
|
+
const root = collectionRoot.table;
|
|
102
|
+
const hasOnlyAntiJoin = moved.length === 1 && isCollectionAntiJoin(moved[0], collectionRoot);
|
|
103
|
+
if (!hasOnlyAntiJoin && !moved.some(isRealCondition)) return;
|
|
104
|
+
if (!hasOnlyAntiJoin && moved.some((c) => conditionContainsCollectionAntiJoin(c, collectionRoot))) return;
|
|
105
|
+
const correlationAliases = joinDependencies(root);
|
|
106
|
+
const correlation = {
|
|
107
|
+
kind: "raw",
|
|
108
|
+
aliases: [root.alias, ...correlationAliases],
|
|
109
|
+
condition: `${root.col1} = ${root.col2}`,
|
|
110
|
+
bindings: [],
|
|
111
|
+
pruneable: false
|
|
112
|
+
};
|
|
113
|
+
const conditions = hasOnlyAntiJoin ? [correlation] : [correlation, ...moved];
|
|
114
|
+
const subquery = {
|
|
115
|
+
selects: ["1"],
|
|
116
|
+
tables: query.tables.filter((t) => hasOnlyAntiJoin ? t.alias === root.alias : collectionRoot.aliases.has(t.alias)).map((t) => {
|
|
117
|
+
if (t.alias === root.alias) return {
|
|
118
|
+
join: "primary",
|
|
119
|
+
alias: t.alias,
|
|
120
|
+
table: t.table
|
|
121
|
+
};
|
|
122
|
+
if (t.join === "outer") return {
|
|
123
|
+
...t,
|
|
124
|
+
distinct: false
|
|
125
|
+
};
|
|
126
|
+
return t;
|
|
127
|
+
}),
|
|
128
|
+
condition: {
|
|
129
|
+
kind: "exp",
|
|
130
|
+
op: "and",
|
|
131
|
+
conditions
|
|
132
|
+
},
|
|
133
|
+
orderBys: []
|
|
134
|
+
};
|
|
135
|
+
rewriteCollectionJoins(subquery);
|
|
136
|
+
return {
|
|
137
|
+
kind: "exists",
|
|
138
|
+
negate: hasOnlyAntiJoin,
|
|
139
|
+
subquery,
|
|
140
|
+
outerAliases: correlationAliases
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/** Appends conditions to the top-level expression, creating an AND wrapper when needed. */
|
|
144
|
+
function addConditions(query, conditions) {
|
|
145
|
+
query.condition ??= {
|
|
146
|
+
kind: "exp",
|
|
147
|
+
op: "and",
|
|
148
|
+
conditions: []
|
|
149
|
+
};
|
|
150
|
+
query.condition.conditions.push(...conditions);
|
|
151
|
+
}
|
|
152
|
+
/** Returns top-level collection roots with their full join subtrees. */
|
|
153
|
+
function getCollectionRoots(query) {
|
|
154
|
+
return getTopLevelCollectionRoots(query).map((table) => {
|
|
155
|
+
const aliases = collectJoinSubtreeAliases(query, table.alias);
|
|
156
|
+
return {
|
|
157
|
+
table,
|
|
158
|
+
aliases,
|
|
159
|
+
joinTables: query.tables.filter((t) => isJoinTable(t) && aliases.has(t.alias))
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/** Returns top-level collection roots, i.e. `books b` but not nested `book_reviews br`. */
|
|
164
|
+
function getTopLevelCollectionRoots(query) {
|
|
165
|
+
const joinTables = query.tables.filter(isJoinTable);
|
|
166
|
+
const collectionAliases = new Set(joinTables.flatMap((t) => t.collection ? [t.alias] : []));
|
|
167
|
+
return joinTables.filter((t) => t.collection?.rootAlias === t.alias && !collectionAliases.has(t.collection.parentAlias));
|
|
168
|
+
}
|
|
169
|
+
/** Returns true if a remaining real condition prevents this subtree from becoming EXISTS, i.e. a cross-scope OR. */
|
|
170
|
+
function conditionBlocksExistsRewrite(condition, aliases) {
|
|
171
|
+
if (!condition || !isRealCondition(condition)) return false;
|
|
172
|
+
if (condition.kind === "exp" && condition.op === "and") return condition.conditions.some((c) => conditionBlocksExistsRewrite(c, aliases));
|
|
173
|
+
return conditionReferencesAnyAlias(condition, aliases);
|
|
174
|
+
}
|
|
175
|
+
/** Collects a collection root and all joins that depend on it, i.e. `b -> br -> c`. */
|
|
176
|
+
function collectJoinSubtreeAliases(query, rootAlias) {
|
|
177
|
+
const aliases = /* @__PURE__ */ new Set([rootAlias]);
|
|
178
|
+
let changed = true;
|
|
179
|
+
while (changed) {
|
|
180
|
+
changed = false;
|
|
181
|
+
for (const table of query.tables) {
|
|
182
|
+
if (!isJoinTable(table)) continue;
|
|
183
|
+
if (!aliases.has(table.alias) && joinReferencesAnyAlias(table, aliases)) {
|
|
184
|
+
aliases.add(table.alias);
|
|
185
|
+
changed = true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return aliases;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Removes AND-safe conditions whose aliases all live inside one collection subtree.
|
|
193
|
+
*
|
|
194
|
+
* I.e. in `a.age = 1 AND b.title = 'x'`, only `b.title = 'x'` moves. In `b.title = 'x' OR br.rating = 5`,
|
|
195
|
+
* the whole OR moves only if every alias is inside the same subtree.
|
|
196
|
+
*/
|
|
197
|
+
function removeLocallyScopedConditions(exp, aliases) {
|
|
198
|
+
if (exp.op === "or") {
|
|
199
|
+
if (!conditionReferencesOnlyAliases(exp, aliases)) return [];
|
|
200
|
+
const moved = {
|
|
201
|
+
...exp,
|
|
202
|
+
conditions: [...exp.conditions]
|
|
203
|
+
};
|
|
204
|
+
exp.conditions = [];
|
|
205
|
+
return [moved];
|
|
206
|
+
}
|
|
207
|
+
const moved = [];
|
|
208
|
+
for (let i = exp.conditions.length - 1; i >= 0; i--) {
|
|
209
|
+
const condition = exp.conditions[i];
|
|
210
|
+
if (condition.kind === "exp" && condition.op === "and") {
|
|
211
|
+
moved.push(...removeLocallyScopedConditions(condition, aliases));
|
|
212
|
+
if (condition.conditions.length === 0) exp.conditions.splice(i, 1);
|
|
213
|
+
} else if (conditionReferencesOnlyAliases(condition, aliases)) {
|
|
214
|
+
moved.unshift(condition);
|
|
215
|
+
exp.conditions.splice(i, 1);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return moved;
|
|
219
|
+
}
|
|
220
|
+
/** Returns true when a condition references at least one alias and all aliases are in `aliases`, i.e. only `b`/`br`. */
|
|
221
|
+
function conditionReferencesOnlyAliases(condition, aliases) {
|
|
222
|
+
const found = conditionAliases(condition);
|
|
223
|
+
return found.size > 0 && [...found].every((alias) => aliases.has(alias));
|
|
224
|
+
}
|
|
225
|
+
/** Returns true when `aliases` are referenced by a real condition other than the targeted OR expression. */
|
|
226
|
+
function conditionReferencesAliasesOutside(condition, target, aliases) {
|
|
227
|
+
if (!condition || condition === target || !isRealCondition(condition)) return false;
|
|
228
|
+
if (condition.kind === "exp") return condition.conditions.some((child) => conditionReferencesAliasesOutside(child, target, aliases));
|
|
229
|
+
return conditionReferencesAnyAlias(condition, aliases);
|
|
230
|
+
}
|
|
231
|
+
/** Returns true when selected/ordered aliases would force these joins to remain in the outer query. */
|
|
232
|
+
function queryReferencesAliasesOutsideConditions(query, aliases, keepAliases) {
|
|
233
|
+
return hasAnyAlias(queryRequiredAliasesOutsideConditions(query, keepAliases), aliases);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Returns aliases needed by SELECT/GROUP/ORDER plus their join dependencies.
|
|
237
|
+
*
|
|
238
|
+
* I.e. `array_agg(br.rating)` requires `br`, and then `br` requires `b` because it joins through `b`.
|
|
239
|
+
*/
|
|
240
|
+
function queryRequiredAliasesOutsideConditions(query, keepAliases) {
|
|
241
|
+
const required = /* @__PURE__ */ new Set();
|
|
242
|
+
for (const alias of keepAliases) required.add(alias);
|
|
243
|
+
for (const orderBy of query.orderBys) required.add(orderBy.alias);
|
|
244
|
+
for (const groupBy of query.groupBys ?? []) if ("expression" in groupBy) addSelectAliases(query, required, groupBy.expression);
|
|
245
|
+
else required.add(groupBy.alias);
|
|
246
|
+
for (const select of query.selects) if (typeof select === "string") addSelectAliases(query, required, select);
|
|
247
|
+
else if ("aliases" in select) {
|
|
248
|
+
for (const alias of select.aliases) required.add(alias);
|
|
249
|
+
addSelectAliases(query, required, select.sql);
|
|
250
|
+
}
|
|
251
|
+
const todo = [...required];
|
|
252
|
+
while (todo.length > 0) {
|
|
253
|
+
const alias = todo.pop();
|
|
254
|
+
const table = query.tables.find((t) => t.alias === alias);
|
|
255
|
+
if (!table || !isJoinTable(table)) continue;
|
|
256
|
+
for (const dependency of joinDependencies(table)) if (!required.has(dependency)) {
|
|
257
|
+
required.add(dependency);
|
|
258
|
+
todo.push(dependency);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return required;
|
|
262
|
+
}
|
|
263
|
+
/** Adds aliases referenced by raw select SQL, i.e. `array_agg(br.rating)` requires `br`. */
|
|
264
|
+
function addSelectAliases(query, required, select) {
|
|
265
|
+
for (const table of query.tables) if (require_queries_find_QueryParser_pruning.selectReferencesAlias(select, table.alias)) required.add(table.alias);
|
|
266
|
+
}
|
|
267
|
+
/** Returns the aliases needed to evaluate a join's ON clause, excluding the joined alias itself. */
|
|
268
|
+
function joinDependencies(table) {
|
|
269
|
+
return [require_queries_find_QueryParser.parseAlias(table.col1), require_queries_find_QueryParser.parseAlias(table.col2)].filter((alias) => alias !== table.alias);
|
|
270
|
+
}
|
|
271
|
+
/** Returns true when a condition references this subtree and another scope, i.e. `b.title = 'x' OR c.text = 'x'`. */
|
|
272
|
+
function conditionHasCrossScopeReference(condition, aliases) {
|
|
273
|
+
if (!condition || !isRealCondition(condition)) return false;
|
|
274
|
+
if (condition.kind === "exp" && condition.op === "and") return condition.conditions.some((child) => conditionHasCrossScopeReference(child, aliases));
|
|
275
|
+
const found = conditionAliases(condition);
|
|
276
|
+
return hasAnyAlias(found, aliases) && ![...found].every((alias) => aliases.has(alias));
|
|
277
|
+
}
|
|
278
|
+
/** Returns true when a condition references any alias in `aliases`, i.e. `b` in `b.title = c.text`. */
|
|
279
|
+
function conditionReferencesAnyAlias(condition, aliases) {
|
|
280
|
+
return hasAnyAlias(conditionAliases(condition), aliases);
|
|
281
|
+
}
|
|
282
|
+
/** Returns true when `table` is an ordinary SQL join. */
|
|
283
|
+
function isJoinTable(table) {
|
|
284
|
+
return table.join === "inner" || table.join === "outer";
|
|
285
|
+
}
|
|
286
|
+
/** Returns true when a join's ON clause references any alias in `aliases`. */
|
|
287
|
+
function joinReferencesAnyAlias(table, aliases) {
|
|
288
|
+
return joinDependencies(table).some((alias) => aliases.has(alias));
|
|
289
|
+
}
|
|
290
|
+
/** Returns true when two alias sets overlap. */
|
|
291
|
+
function hasAnyAlias(found, aliases) {
|
|
292
|
+
return [...found].some((alias) => aliases.has(alias));
|
|
293
|
+
}
|
|
294
|
+
/** Returns true for collection anti-joins, i.e. `b.id IS NULL` or m2m target `t.id IS NULL` for root `att`. */
|
|
295
|
+
function isCollectionAntiJoin(condition, root) {
|
|
296
|
+
return collectionAntiJoinAliases(root).some((alias) => isAliasIdNull(condition, alias));
|
|
297
|
+
}
|
|
298
|
+
/** Returns aliases whose `id IS NULL` means the collection root has no matching row. */
|
|
299
|
+
function collectionAntiJoinAliases(root) {
|
|
300
|
+
return [...root.aliases].filter((alias) => {
|
|
301
|
+
if (alias === root.table.alias) return true;
|
|
302
|
+
return rootTable(root, alias)?.collection?.rootAlias === root.table.alias;
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
/** Returns a join table from a collection subtree by alias. */
|
|
306
|
+
function rootTable(root, alias) {
|
|
307
|
+
return root.joinTables.find((table) => table.alias === alias);
|
|
308
|
+
}
|
|
309
|
+
/** Returns true for `alias.id IS NULL`, i.e. the parse shape for `{ books: { id: null } }`. */
|
|
310
|
+
function isAliasIdNull(condition, alias) {
|
|
311
|
+
return condition.kind === "column" && condition.alias === alias && condition.column === "id" && condition.cond.kind === "is-null";
|
|
312
|
+
}
|
|
313
|
+
/** Returns true when a condition tree contains a collection anti-join branch inside an OR. */
|
|
314
|
+
function conditionContainsCollectionAntiJoin(condition, root) {
|
|
315
|
+
if (isCollectionAntiJoin(condition, root)) return true;
|
|
316
|
+
if (condition.kind === "exp") return condition.conditions.some((c) => conditionContainsCollectionAntiJoin(c, root));
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
/** Removes empty expression wrappers left behind by condition movement, i.e. `AND []` after all children moved. */
|
|
320
|
+
function removeEmptyExpressions(exp) {
|
|
321
|
+
if (!exp) return;
|
|
322
|
+
for (let i = exp.conditions.length - 1; i >= 0; i--) {
|
|
323
|
+
const condition = exp.conditions[i];
|
|
324
|
+
if (condition.kind === "exp") {
|
|
325
|
+
removeEmptyExpressions(condition);
|
|
326
|
+
if (condition.conditions.length === 0) exp.conditions.splice(i, 1);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/** Returns true if a condition must be preserved to maintain query semantics, i.e. user filters vs soft-delete filters. */
|
|
331
|
+
function isRealCondition(condition) {
|
|
332
|
+
if (condition.kind === "column" || condition.kind === "raw") return !condition.pruneable;
|
|
333
|
+
else if (condition.kind === "exists") return true;
|
|
334
|
+
else if (condition.kind === "exp") return condition.conditions.some(isRealCondition);
|
|
335
|
+
else require_utils.assertNever(condition);
|
|
336
|
+
}
|
|
337
|
+
/** Returns all aliases referenced by a condition, i.e. `b` and `a` in an OR. */
|
|
338
|
+
function conditionAliases(condition) {
|
|
339
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
340
|
+
collectAllAliases(condition, aliases);
|
|
341
|
+
return aliases;
|
|
342
|
+
}
|
|
343
|
+
/** Collects all aliases referenced by a condition, including inside nested expressions, i.e. `b` and `a` in an OR. */
|
|
344
|
+
function collectAllAliases(cond, out) {
|
|
345
|
+
if (cond.kind === "column") out.add(cond.alias);
|
|
346
|
+
else if (cond.kind === "raw") for (const a of cond.aliases) out.add(a);
|
|
347
|
+
else if (cond.kind === "exp") for (const c of cond.conditions) collectAllAliases(c, out);
|
|
348
|
+
else if (cond.kind === "exists") {} else require_utils.assertNever(cond);
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
351
|
+
exports.optimizeCollectionJoins = optimizeCollectionJoins;
|
|
352
|
+
|
|
353
|
+
//# sourceMappingURL=QueryParser.collectionJoins.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryParser.collectionJoins.cjs","names":["selectReferencesAlias","parseAlias"],"sources":["../../../src/queries/find/QueryParser.collectionJoins.ts"],"sourcesContent":["import { pruneUnusedJoins, selectReferencesAlias } from \"src/queries/find/QueryParser.pruning.ts\";\nimport {\n type JoinTable,\n type ParsedFindQuery,\n type PrimaryTable,\n maybeAddIdNotNulls,\n parseAlias,\n} from \"src/queries/find/QueryParser.ts\";\nimport type {\n ExistsCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nimport { assertNever } from \"src/utils.ts\";\n\n/** A collection root plus every join nested under it, i.e. `books b` with `book_reviews br`. */\ninterface CollectionRoot {\n /** The top-level collection join that becomes the EXISTS FROM table, i.e. `books b`. */\n table: JoinTable;\n /** Every alias in this collection subtree, i.e. `b` and `br` for `authors -> books -> reviews`. */\n aliases: Set<string>;\n /** Every join table in this collection subtree, i.e. `att` and `t` for an m2m tag filter. */\n joinTables: JoinTable[];\n}\n\n/**\n * Rewrites eligible logical collection LEFT JOINs into EXISTS after plugins have mutated the AST.\n *\n * QueryParser intentionally leaves collection filters as ordinary joins so `beforeFind` plugins see\n * stabler/simpler input than \"sometimes JOINs / sometimes EXISTS\".\n *\n * This pass runs after plugins and before SQL rendering:\n *\n * 1. `rewriteCollectionJoins` finds top-level collection joins and moves conditions that reference only\n * that subtree into a correlated EXISTS subquery. I.e. `{ books: { title: \"b1\" } }` becomes\n * `EXISTS (SELECT 1 FROM books b WHERE a.id = b.author_id AND b.title = 'b1')`.\n * 2. The same helper recurses into the generated subquery, so nested collections become nested EXISTS clauses.\n * I.e. `{ books: { reviews: { rating: 5 } } }` becomes EXISTS(books WHERE EXISTS(reviews)).\n * 3. Conditions that cannot be safely moved stay as LEFT JOINs. I.e. `OR(b.title = 'x', a.first_name = 'x')`\n * needs both aliases in one SQL scope, so `b` remains a join instead of becoming an EXISTS.\n * 4. Remaining fanout LEFT JOIN roots are rejected unless `allowMultipleLeftJoins` is set,\n * because they can produce cross-product row explosions.\n * 5. Finally, `maybeAddIdNotNulls` and `pruneUnusedJoins` clean up the joins that remain.\n */\nexport function optimizeCollectionJoins(\n query: ParsedFindQuery,\n opts: {\n allowMultipleLeftJoins?: boolean;\n optimizeJoinsToExists?: boolean;\n pruneJoins?: boolean;\n keepAliases?: string[];\n } = {},\n): void {\n const { allowMultipleLeftJoins = false, optimizeJoinsToExists = true, pruneJoins = true, keepAliases = [] } = opts;\n for (const table of query.tables) {\n // I.e. batched find/count queries wrap the real query in a LATERAL subquery; optimize that inner query too,\n // but let the outer query decide final pruning so it can keep the lateral alias itself.\n if (table.join === \"lateral\") optimizeCollectionJoins(table.query, { ...opts, pruneJoins: false });\n }\n if (optimizeJoinsToExists) rewriteCollectionJoins(query, keepAliases);\n\n // I.e. collection LEFT JOINs now fall into three buckets:\n // 1. local real filters, like `{ books: { title: \"b1\" } }`, were rewritten to EXISTS above;\n // 2. no local real filters, like `{ books: {}, comments: {} }`, are safe because pruning will remove them;\n // 3. blocked real filters, like cross-scope ORs, must stay as LEFT JOINs and can multiply rows.\n // Only the third bucket should trip the fanout guard.\n const fanoutLeftJoinAliases = getCollectionRoots(query)\n .filter((root) => conditionBlocksExistsRewrite(query.condition, root.aliases))\n .map((root) => root.table.alias);\n if (optimizeJoinsToExists && !allowMultipleLeftJoins && fanoutLeftJoinAliases.length > 1) {\n throw new Error(\n `em.find would issue multiple LEFT JOINs across collection relations (${fanoutLeftJoinAliases.join(\n \", \",\n )}); pass allowMultipleLeftJoins: true if this fanout is intentional`,\n );\n }\n\n if (query.tables.some((t) => t.join === \"outer\")) {\n // I.e. preserve legacy LEFT JOIN null semantics for any joins that could not become EXISTS.\n maybeAddIdNotNulls(query);\n }\n if (pruneJoins) {\n // I.e. remove logical collection joins that were replaced by EXISTS and any joins only needed before plugin edits.\n pruneUnusedJoins(query, keepAliases);\n }\n}\n\n/**\n * Rewrites root-level collection join subtrees into EXISTS when their conditions are locally scoped.\n *\n * I.e. for `authors a -> books b -> book_reviews br`, `b` is the collection root and `br` is part of its subtree.\n */\nfunction rewriteCollectionJoins(query: ParsedFindQuery, keepAliases: string[] = []): void {\n const roots = getCollectionRoots(query);\n if (query.condition) rewriteSiblingOrExpression(query, query.condition, roots, keepAliases);\n for (const root of roots) {\n if (queryReferencesAliasesOutsideConditions(query, root.aliases, keepAliases)) continue;\n if (conditionHasCrossScopeReference(query.condition, root.aliases)) continue;\n // I.e. move `b.title = 'x'` and `(br.rating = 5 OR br.rating = 4)`, but not `b.title = 'x' OR a.first_name = 'x'`.\n const moved = query.condition ? removeLocallyScopedConditions(query.condition, root.aliases) : [];\n if (moved.length === 0) continue;\n const exists = createExistsCondition(query, root, moved);\n if (!exists) {\n addConditions(query, moved);\n continue;\n }\n addConditions(query, [exists]);\n // I.e. after adding EXISTS, remove `books b` and its children from the outer FROM list.\n query.tables = query.tables.filter((t) => !root.aliases.has(t.alias));\n }\n removeEmptyExpressions(query.condition);\n}\n\n/** Rewrites eligible sibling collection ORs while preserving outer/mixed-scope ORs as joins. */\nfunction rewriteSiblingOrExpression(\n query: ParsedFindQuery,\n condition: ParsedExpressionCondition,\n roots: CollectionRoot[],\n keepAliases: string[],\n): void {\n if (condition.kind !== \"exp\") return;\n if (condition.op === \"or\" && rewriteSiblingOrExpressionChildren(query, condition, roots, keepAliases)) return;\n if (condition.op === \"and\") {\n for (const child of condition.conditions) rewriteSiblingOrExpression(query, child, roots, keepAliases);\n }\n}\n\n/** Returns true when OR branches that are scoped to collection subtrees became EXISTS conditions. */\nfunction rewriteSiblingOrExpressionChildren(\n query: ParsedFindQuery,\n exp: ParsedExpressionFilter,\n roots: CollectionRoot[],\n keepAliases: string[],\n): boolean {\n const matches: { collectionRoot: CollectionRoot; condition: ParsedExpressionCondition }[] = [];\n const usedAliases = new Set<string>();\n const usedRoots = new Set<string>();\n let hasAntiJoinBranch = false;\n for (const condition of exp.conditions) {\n if (!isRealCondition(condition)) return false;\n const match = roots.find((root) => conditionReferencesOnlyAliases(condition, root.aliases));\n if (!match) {\n const found = conditionAliases(condition);\n // I.e. `a.first_name = 'x'` can stay in the OR while `b.title = 'x'` becomes EXISTS, but\n // `a.first_name = 'x' AND b.title = 'x'` must stay joined because one branch spans both scopes.\n if (roots.some((root) => hasAnyAlias(found, root.aliases))) return false;\n continue;\n }\n matches.push({ collectionRoot: match, condition });\n usedRoots.add(match.table.alias);\n hasAntiJoinBranch ||= isCollectionAntiJoin(condition, match);\n for (const alias of match.aliases) usedAliases.add(alias);\n }\n if (matches.length === 0) return false;\n // I.e. rewrite true sibling collection ORs like `b.id IS NOT NULL OR c.id IS NOT NULL`, and same-root\n // anti-join ORs like `b.id IS NULL OR br.rating = 5` that need `b.id IS NULL` to become `NOT EXISTS`.\n // skip positive-only single-root ORs, i.e. ORs with no `b.id IS NULL` anti-join branch like\n // `b.title = 'x' OR br.rating = 5`; mixed ordinary/collection ORs like `a.first_name = 'x' OR b.title = 'x'`\n // are safe because only the collection branch is replaced. Aliases are also filtered elsewhere like\n // `b.order = 1 AND (b.title = 'x' OR c.text = 'x')`, and aliases that must stay projected/sorted like\n // `SELECT b.title` or `ORDER BY b.title`.\n if (\n (matches.length === exp.conditions.length && usedRoots.size < 2 && !hasAntiJoinBranch) ||\n conditionReferencesAliasesOutside(query.condition, exp, usedAliases) ||\n queryReferencesAliasesOutsideConditions(query, usedAliases, keepAliases)\n ) {\n return false;\n }\n\n const existsConditions = new Map<ParsedExpressionCondition, ExistsCondition>();\n for (const match of matches) {\n const exists = createExistsCondition(query, match.collectionRoot, [match.condition]);\n if (!exists) return false;\n existsConditions.set(match.condition, exists);\n }\n exp.conditions = exp.conditions.map((condition) => existsConditions.get(condition) ?? condition);\n // I.e. leave the collection joins in place for now; pruning removes them after all rewrites.\n return true;\n}\n\n/** Creates an EXISTS/NOT EXISTS condition for moved collection filters, or undefined when a LEFT JOIN must stay. */\nfunction createExistsCondition(\n query: ParsedFindQuery,\n collectionRoot: CollectionRoot,\n moved: ParsedExpressionCondition[],\n): ExistsCondition | undefined {\n const root = collectionRoot.table;\n const hasOnlyAntiJoin = moved.length === 1 && isCollectionAntiJoin(moved[0], collectionRoot);\n if (!hasOnlyAntiJoin && !moved.some(isRealCondition)) {\n // I.e. only soft-delete/STI conditions moved; don't create an EXISTS that changes nothing.\n return undefined;\n }\n if (!hasOnlyAntiJoin && moved.some((c) => conditionContainsCollectionAntiJoin(c, collectionRoot))) {\n // I.e. `b.id IS NULL OR br.rating = 5` is not a pure anti-join; leave it as a LEFT JOIN for SQL semantics.\n return undefined;\n }\n\n // I.e. `rpm` may correlate through `_pp_version.id = rpm.ready_plan_version_id`, so pruning must keep\n // `_pp_version` even when the collection metadata's parent alias is only `pp`.\n const correlationAliases = joinDependencies(root);\n const correlation: RawCondition = {\n kind: \"raw\",\n aliases: [root.alias, ...correlationAliases],\n condition: `${root.col1} = ${root.col2}`,\n bindings: [],\n pruneable: false,\n };\n // I.e. a pure `b.id IS NULL` anti-join becomes `NOT EXISTS (SELECT 1 FROM books b WHERE a.id = b.author_id)`.\n const conditions = hasOnlyAntiJoin ? [correlation] : [correlation, ...moved];\n const subquery: ParsedFindQuery = {\n selects: [\"1\"],\n tables: query.tables\n .filter((t) => (hasOnlyAntiJoin ? t.alias === root.alias : collectionRoot.aliases.has(t.alias)))\n .map((t) => {\n // I.e. the collection root becomes the subquery's FROM table; children remain joins off that root.\n if (t.alias === root.alias) return { join: \"primary\", alias: t.alias, table: t.table } satisfies PrimaryTable;\n // I.e. preserve nullable paths like `LEFT JOIN p ... LEFT JOIN sp ... WHERE p.id = 1 OR sp.id = 1`; forcing\n // children to INNER JOIN would require every optional branch to exist before the OR can match any branch.\n if (t.join === \"outer\") return { ...t, distinct: false };\n return t;\n }),\n condition: { kind: \"exp\", op: \"and\", conditions },\n orderBys: [],\n };\n // I.e. nested `books.reviews` first creates an EXISTS for books, then this recursive call creates EXISTS for reviews.\n rewriteCollectionJoins(subquery);\n return {\n kind: \"exists\",\n negate: hasOnlyAntiJoin,\n subquery,\n outerAliases: correlationAliases,\n };\n}\n\n/** Appends conditions to the top-level expression, creating an AND wrapper when needed. */\nfunction addConditions(query: ParsedFindQuery, conditions: ParsedExpressionCondition[]): void {\n query.condition ??= { kind: \"exp\", op: \"and\", conditions: [] };\n query.condition.conditions.push(...conditions);\n}\n\n/** Returns top-level collection roots with their full join subtrees. */\nfunction getCollectionRoots(query: ParsedFindQuery): CollectionRoot[] {\n return getTopLevelCollectionRoots(query).map((table) => {\n const aliases = collectJoinSubtreeAliases(query, table.alias);\n return {\n table,\n aliases,\n joinTables: query.tables.filter((t): t is JoinTable => isJoinTable(t) && aliases.has(t.alias)),\n };\n });\n}\n\n/** Returns top-level collection roots, i.e. `books b` but not nested `book_reviews br`. */\nfunction getTopLevelCollectionRoots(query: ParsedFindQuery): JoinTable[] {\n // I.e. if `books b` is nested under another collection root, the parent pass should absorb it; don't rewrite it here.\n const joinTables = query.tables.filter(isJoinTable);\n const collectionAliases = new Set(joinTables.flatMap((t) => (t.collection ? [t.alias] : [])));\n return joinTables.filter(\n (t) => t.collection?.rootAlias === t.alias && !collectionAliases.has(t.collection.parentAlias),\n );\n}\n\n/** Returns true if a remaining real condition prevents this subtree from becoming EXISTS, i.e. a cross-scope OR. */\nfunction conditionBlocksExistsRewrite(condition: ParsedExpressionCondition | undefined, aliases: Set<string>): boolean {\n if (!condition || !isRealCondition(condition)) return false;\n if (condition.kind === \"exp\" && condition.op === \"and\") {\n return condition.conditions.some((c) => conditionBlocksExistsRewrite(c, aliases));\n }\n return conditionReferencesAnyAlias(condition, aliases);\n}\n\n/** Collects a collection root and all joins that depend on it, i.e. `b -> br -> c`. */\nfunction collectJoinSubtreeAliases(query: ParsedFindQuery, rootAlias: string): Set<string> {\n const aliases = new Set([rootAlias]);\n let changed = true;\n while (changed) {\n changed = false;\n for (const table of query.tables) {\n if (!isJoinTable(table)) continue;\n // I.e. `book_reviews br ON b.id = br.book_id` depends on `b`, so `br` belongs in the `b` subtree.\n if (!aliases.has(table.alias) && joinReferencesAnyAlias(table, aliases)) {\n aliases.add(table.alias);\n changed = true;\n }\n }\n }\n return aliases;\n}\n\n/**\n * Removes AND-safe conditions whose aliases all live inside one collection subtree.\n *\n * I.e. in `a.age = 1 AND b.title = 'x'`, only `b.title = 'x'` moves. In `b.title = 'x' OR br.rating = 5`,\n * the whole OR moves only if every alias is inside the same subtree.\n */\nfunction removeLocallyScopedConditions(exp: ParsedExpressionFilter, aliases: Set<string>): ParsedExpressionCondition[] {\n if (exp.op === \"or\") {\n // I.e. OR cannot be split across scopes; either move the whole OR into the EXISTS, or leave it outside.\n if (!conditionReferencesOnlyAliases(exp, aliases)) return [];\n const moved = { ...exp, conditions: [...exp.conditions] } satisfies ParsedExpressionFilter;\n exp.conditions = [];\n return [moved];\n }\n const moved: ParsedExpressionCondition[] = [];\n for (let i = exp.conditions.length - 1; i >= 0; i--) {\n const condition = exp.conditions[i];\n if (condition.kind === \"exp\" && condition.op === \"and\") {\n // I.e. flatten nested AND movement so `a AND (b AND br)` can still move `b` and `br` into the EXISTS.\n moved.push(...removeLocallyScopedConditions(condition, aliases));\n if (condition.conditions.length === 0) exp.conditions.splice(i, 1);\n } else if (conditionReferencesOnlyAliases(condition, aliases)) {\n // I.e. move `b.title = 'x'` out of the parent AND and into the collection EXISTS.\n moved.unshift(condition);\n exp.conditions.splice(i, 1);\n }\n }\n return moved;\n}\n\n/** Returns true when a condition references at least one alias and all aliases are in `aliases`, i.e. only `b`/`br`. */\nfunction conditionReferencesOnlyAliases(condition: ParsedExpressionCondition, aliases: Set<string>): boolean {\n const found = conditionAliases(condition);\n return found.size > 0 && [...found].every((alias) => aliases.has(alias));\n}\n\n/** Returns true when `aliases` are referenced by a real condition other than the targeted OR expression. */\nfunction conditionReferencesAliasesOutside(\n condition: ParsedExpressionCondition | undefined,\n target: ParsedExpressionCondition,\n aliases: Set<string>,\n): boolean {\n if (!condition || condition === target || !isRealCondition(condition)) return false;\n if (condition.kind === \"exp\") {\n return condition.conditions.some((child) => conditionReferencesAliasesOutside(child, target, aliases));\n }\n return conditionReferencesAnyAlias(condition, aliases);\n}\n\n/** Returns true when selected/ordered aliases would force these joins to remain in the outer query. */\nfunction queryReferencesAliasesOutsideConditions(\n query: ParsedFindQuery,\n aliases: Set<string>,\n keepAliases: string[],\n): boolean {\n const requiredAliases = queryRequiredAliasesOutsideConditions(query, keepAliases);\n // I.e. if `array_agg(br.rating)` requires `br`, then `b` is required too because `br` joins through `b`; don't\n // move `b` under EXISTS just because the select references only its child alias directly.\n return hasAnyAlias(requiredAliases, aliases);\n}\n\n/**\n * Returns aliases needed by SELECT/GROUP/ORDER plus their join dependencies.\n *\n * I.e. `array_agg(br.rating)` requires `br`, and then `br` requires `b` because it joins through `b`.\n */\nfunction queryRequiredAliasesOutsideConditions(query: ParsedFindQuery, keepAliases: string[]): Set<string> {\n const required = new Set<string>();\n for (const alias of keepAliases) required.add(alias);\n for (const orderBy of query.orderBys) required.add(orderBy.alias);\n for (const groupBy of query.groupBys ?? []) {\n if (\"expression\" in groupBy) {\n addSelectAliases(query, required, groupBy.expression);\n } else {\n required.add(groupBy.alias);\n }\n }\n for (const select of query.selects) {\n if (typeof select === \"string\") {\n addSelectAliases(query, required, select);\n } else if (\"aliases\" in select) {\n for (const alias of select.aliases) required.add(alias);\n addSelectAliases(query, required, select.sql);\n }\n }\n\n const todo = [...required];\n while (todo.length > 0) {\n const alias = todo.pop()!;\n const table = query.tables.find((t) => t.alias === alias);\n if (!table || !isJoinTable(table)) continue;\n for (const dependency of joinDependencies(table)) {\n if (!required.has(dependency)) {\n required.add(dependency);\n todo.push(dependency);\n }\n }\n }\n return required;\n}\n\n/** Adds aliases referenced by raw select SQL, i.e. `array_agg(br.rating)` requires `br`. */\nfunction addSelectAliases(query: ParsedFindQuery, required: Set<string>, select: string): void {\n for (const table of query.tables) {\n if (selectReferencesAlias(select, table.alias)) required.add(table.alias);\n }\n}\n\n/** Returns the aliases needed to evaluate a join's ON clause, excluding the joined alias itself. */\nfunction joinDependencies(table: JoinTable): string[] {\n return [parseAlias(table.col1), parseAlias(table.col2)].filter((alias) => alias !== table.alias);\n}\n\n/** Returns true when a condition references this subtree and another scope, i.e. `b.title = 'x' OR c.text = 'x'`. */\nfunction conditionHasCrossScopeReference(\n condition: ParsedExpressionCondition | undefined,\n aliases: Set<string>,\n): boolean {\n if (!condition || !isRealCondition(condition)) return false;\n if (condition.kind === \"exp\" && condition.op === \"and\") {\n return condition.conditions.some((child) => conditionHasCrossScopeReference(child, aliases));\n }\n const found = conditionAliases(condition);\n return hasAnyAlias(found, aliases) && ![...found].every((alias) => aliases.has(alias));\n}\n\n/** Returns true when a condition references any alias in `aliases`, i.e. `b` in `b.title = c.text`. */\nfunction conditionReferencesAnyAlias(condition: ParsedExpressionCondition, aliases: Set<string>): boolean {\n return hasAnyAlias(conditionAliases(condition), aliases);\n}\n\n/** Returns true when `table` is an ordinary SQL join. */\nfunction isJoinTable(table: ParsedFindQuery[\"tables\"][number]): table is JoinTable {\n return table.join === \"inner\" || table.join === \"outer\";\n}\n\n/** Returns true when a join's ON clause references any alias in `aliases`. */\nfunction joinReferencesAnyAlias(table: JoinTable, aliases: Set<string>): boolean {\n return joinDependencies(table).some((alias) => aliases.has(alias));\n}\n\n/** Returns true when two alias sets overlap. */\nfunction hasAnyAlias(found: Set<string>, aliases: Set<string>): boolean {\n return [...found].some((alias) => aliases.has(alias));\n}\n\n/** Returns true for collection anti-joins, i.e. `b.id IS NULL` or m2m target `t.id IS NULL` for root `att`. */\nfunction isCollectionAntiJoin(condition: ParsedExpressionCondition, root: CollectionRoot): boolean {\n return collectionAntiJoinAliases(root).some((alias) => isAliasIdNull(condition, alias));\n}\n\n/** Returns aliases whose `id IS NULL` means the collection root has no matching row. */\nfunction collectionAntiJoinAliases(root: CollectionRoot): string[] {\n return [...root.aliases].filter((alias) => {\n if (alias === root.table.alias) return true;\n const table = rootTable(root, alias);\n // I.e. for m2m `authors -> authors_to_tags att -> tags t`, `t.id IS NULL` means no tag membership.\n return table?.collection?.rootAlias === root.table.alias;\n });\n}\n\n/** Returns a join table from a collection subtree by alias. */\nfunction rootTable(root: CollectionRoot, alias: string): JoinTable | undefined {\n return root.joinTables.find((table) => table.alias === alias);\n}\n\n/** Returns true for `alias.id IS NULL`, i.e. the parse shape for `{ books: { id: null } }`. */\nfunction isAliasIdNull(condition: ParsedExpressionCondition, alias: string): boolean {\n return (\n condition.kind === \"column\" &&\n condition.alias === alias &&\n condition.column === \"id\" &&\n condition.cond.kind === \"is-null\"\n );\n}\n\n/** Returns true when a condition tree contains a collection anti-join branch inside an OR. */\nfunction conditionContainsCollectionAntiJoin(condition: ParsedExpressionCondition, root: CollectionRoot): boolean {\n if (isCollectionAntiJoin(condition, root)) return true;\n if (condition.kind === \"exp\") return condition.conditions.some((c) => conditionContainsCollectionAntiJoin(c, root));\n return false;\n}\n\n/** Removes empty expression wrappers left behind by condition movement, i.e. `AND []` after all children moved. */\nfunction removeEmptyExpressions(exp: ParsedExpressionFilter | undefined): void {\n if (!exp) return;\n for (let i = exp.conditions.length - 1; i >= 0; i--) {\n const condition = exp.conditions[i];\n if (condition.kind === \"exp\") {\n removeEmptyExpressions(condition);\n if (condition.conditions.length === 0) exp.conditions.splice(i, 1);\n }\n }\n}\n\n/** Returns true if a condition must be preserved to maintain query semantics, i.e. user filters vs soft-delete filters. */\nfunction isRealCondition(condition: ParsedExpressionCondition): boolean {\n if (condition.kind === \"column\" || condition.kind === \"raw\") {\n return !condition.pruneable;\n } else if (condition.kind === \"exists\") {\n return true;\n } else if (condition.kind === \"exp\") {\n return condition.conditions.some(isRealCondition);\n } else {\n assertNever(condition);\n }\n}\n\n/** Returns all aliases referenced by a condition, i.e. `b` and `a` in an OR. */\nfunction conditionAliases(condition: ParsedExpressionCondition): Set<string> {\n const aliases = new Set<string>();\n collectAllAliases(condition, aliases);\n return aliases;\n}\n\n/** Collects all aliases referenced by a condition, including inside nested expressions, i.e. `b` and `a` in an OR. */\nfunction collectAllAliases(cond: ParsedExpressionCondition, out: Set<string>): void {\n if (cond.kind === \"column\") {\n out.add(cond.alias);\n } else if (cond.kind === \"raw\") {\n for (const a of cond.aliases) out.add(a);\n } else if (cond.kind === \"exp\") {\n for (const c of cond.conditions) collectAllAliases(c, out);\n } else if (cond.kind === \"exists\") {\n // I.e. an EXISTS subquery is already a scoped unit; outer movement decisions should not inspect its internals.\n } else {\n assertNever(cond);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,wBACd,OACA,OAKI,CAAC,GACC;CACN,MAAM,EAAE,yBAAyB,OAAO,wBAAwB,MAAM,aAAa,MAAM,cAAc,CAAC,MAAM;CAC9G,KAAK,MAAM,SAAS,MAAM,QAGxB,IAAI,MAAM,SAAS,WAAW,wBAAwB,MAAM,OAAO;EAAE,GAAG;EAAM,YAAY;CAAM,CAAC;CAEnG,IAAI,uBAAuB,uBAAuB,OAAO,WAAW;CAOpE,MAAM,wBAAwB,mBAAmB,KAAK,CAAC,CACpD,QAAQ,SAAS,6BAA6B,MAAM,WAAW,KAAK,OAAO,CAAC,CAAC,CAC7E,KAAK,SAAS,KAAK,MAAM,KAAK;CACjC,IAAI,yBAAyB,CAAC,0BAA0B,sBA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uBAAuB,SAAS;GAChC,IAAI,UAAU,WAAW,WAAW,GAAG,IAAI,WAAW,OAAO,GAAG,CAAC;EACnE;CACF;AACF;;AAGA,SAAS,gBAAgB,WAA+C;CACtE,IAAI,UAAU,SAAS,YAAY,UAAU,SAAS,OACpD,OAAO,CAAC,UAAU;MACb,IAAI,UAAU,SAAS,UAC5B,OAAO;MACF,IAAI,UAAU,SAAS,OAC5B,OAAO,UAAU,WAAW,KAAK,eAAe;MAEhD,cAAA,YAAY,SAAS;AAEzB;;AAGA,SAAS,iBAAiB,WAAmD;CAC3E,MAAM,0BAAU,IAAI,IAAY;CAChC,kBAAkB,WAAW,OAAO;CACpC,OAAO;AACT;;AAGA,SAAS,kBAAkB,MAAiC,KAAwB;CAClF,IAAI,KAAK,SAAS,UAChB,IAAI,IAAI,KAAK,KAAK;MACb,IAAI,KAAK,SAAS,OACvB,KAAK,MAAM,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC;MAClC,IAAI,KAAK,SAAS,OACvB,KAAK,MAAM,KAAK,KAAK,YAAY,kBAAkB,GAAG,GAAG;MACpD,IAAI,KAAK,SAAS,UAAU,CAEnC,OACE,cAAA,YAAY,IAAI;AAEpB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ParsedFindQuery } from "./QueryParser.cjs";
|
|
2
|
+
//#region src/queries/find/QueryParser.collectionJoins.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Rewrites eligible logical collection LEFT JOINs into EXISTS after plugins have mutated the AST.
|
|
5
|
+
*
|
|
6
|
+
* QueryParser intentionally leaves collection filters as ordinary joins so `beforeFind` plugins see
|
|
7
|
+
* stabler/simpler input than "sometimes JOINs / sometimes EXISTS".
|
|
8
|
+
*
|
|
9
|
+
* This pass runs after plugins and before SQL rendering:
|
|
10
|
+
*
|
|
11
|
+
* 1. `rewriteCollectionJoins` finds top-level collection joins and moves conditions that reference only
|
|
12
|
+
* that subtree into a correlated EXISTS subquery. I.e. `{ books: { title: "b1" } }` becomes
|
|
13
|
+
* `EXISTS (SELECT 1 FROM books b WHERE a.id = b.author_id AND b.title = 'b1')`.
|
|
14
|
+
* 2. The same helper recurses into the generated subquery, so nested collections become nested EXISTS clauses.
|
|
15
|
+
* I.e. `{ books: { reviews: { rating: 5 } } }` becomes EXISTS(books WHERE EXISTS(reviews)).
|
|
16
|
+
* 3. Conditions that cannot be safely moved stay as LEFT JOINs. I.e. `OR(b.title = 'x', a.first_name = 'x')`
|
|
17
|
+
* needs both aliases in one SQL scope, so `b` remains a join instead of becoming an EXISTS.
|
|
18
|
+
* 4. Remaining fanout LEFT JOIN roots are rejected unless `allowMultipleLeftJoins` is set,
|
|
19
|
+
* because they can produce cross-product row explosions.
|
|
20
|
+
* 5. Finally, `maybeAddIdNotNulls` and `pruneUnusedJoins` clean up the joins that remain.
|
|
21
|
+
*/
|
|
22
|
+
declare function optimizeCollectionJoins(query: ParsedFindQuery, opts?: {
|
|
23
|
+
allowMultipleLeftJoins?: boolean;
|
|
24
|
+
optimizeJoinsToExists?: boolean;
|
|
25
|
+
pruneJoins?: boolean;
|
|
26
|
+
keepAliases?: string[];
|
|
27
|
+
}): void;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { optimizeCollectionJoins };
|
|
30
|
+
//# sourceMappingURL=QueryParser.collectionJoins.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryParser.collectionJoins.d.cts","names":[],"sources":["../../../src/queries/find/QueryParser.collectionJoins.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;iBA6CgB,wBACd,OAAO,iBACP;EACE;EACA;EACA;EACA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ParsedFindQuery } from "./QueryParser.mjs";
|
|
2
|
+
//#region src/queries/find/QueryParser.collectionJoins.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Rewrites eligible logical collection LEFT JOINs into EXISTS after plugins have mutated the AST.
|
|
5
|
+
*
|
|
6
|
+
* QueryParser intentionally leaves collection filters as ordinary joins so `beforeFind` plugins see
|
|
7
|
+
* stabler/simpler input than "sometimes JOINs / sometimes EXISTS".
|
|
8
|
+
*
|
|
9
|
+
* This pass runs after plugins and before SQL rendering:
|
|
10
|
+
*
|
|
11
|
+
* 1. `rewriteCollectionJoins` finds top-level collection joins and moves conditions that reference only
|
|
12
|
+
* that subtree into a correlated EXISTS subquery. I.e. `{ books: { title: "b1" } }` becomes
|
|
13
|
+
* `EXISTS (SELECT 1 FROM books b WHERE a.id = b.author_id AND b.title = 'b1')`.
|
|
14
|
+
* 2. The same helper recurses into the generated subquery, so nested collections become nested EXISTS clauses.
|
|
15
|
+
* I.e. `{ books: { reviews: { rating: 5 } } }` becomes EXISTS(books WHERE EXISTS(reviews)).
|
|
16
|
+
* 3. Conditions that cannot be safely moved stay as LEFT JOINs. I.e. `OR(b.title = 'x', a.first_name = 'x')`
|
|
17
|
+
* needs both aliases in one SQL scope, so `b` remains a join instead of becoming an EXISTS.
|
|
18
|
+
* 4. Remaining fanout LEFT JOIN roots are rejected unless `allowMultipleLeftJoins` is set,
|
|
19
|
+
* because they can produce cross-product row explosions.
|
|
20
|
+
* 5. Finally, `maybeAddIdNotNulls` and `pruneUnusedJoins` clean up the joins that remain.
|
|
21
|
+
*/
|
|
22
|
+
declare function optimizeCollectionJoins(query: ParsedFindQuery, opts?: {
|
|
23
|
+
allowMultipleLeftJoins?: boolean;
|
|
24
|
+
optimizeJoinsToExists?: boolean;
|
|
25
|
+
pruneJoins?: boolean;
|
|
26
|
+
keepAliases?: string[];
|
|
27
|
+
}): void;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { optimizeCollectionJoins };
|
|
30
|
+
//# sourceMappingURL=QueryParser.collectionJoins.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryParser.collectionJoins.d.mts","names":[],"sources":["../../../src/queries/find/QueryParser.collectionJoins.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;iBA6CgB,wBACd,OAAO,iBACP;EACE;EACA;EACA;EACA"}
|