joist-core 2.3.0 → 2.4.0-next.10
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 +178 -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 +169 -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 +255 -0
- package/build/queries/sql/execute.cjs.map +1 -0
- package/build/queries/sql/execute.d.cts +311 -0
- package/build/queries/sql/execute.d.cts.map +1 -0
- package/build/queries/sql/execute.d.mts +311 -0
- package/build/queries/sql/execute.d.mts.map +1 -0
- package/build/queries/sql/execute.js +252 -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 +1657 -0
- package/build/queries/sql/query.cjs.map +1 -0
- package/build/queries/sql/query.d.cts +887 -0
- package/build/queries/sql/query.d.cts.map +1 -0
- package/build/queries/sql/query.d.mts +887 -0
- package/build/queries/sql/query.d.mts.map +1 -0
- package/build/queries/sql/query.js +1637 -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
package/build/EntityManager.js
CHANGED
|
@@ -1,2312 +1,1913 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
import { BatchLoader } from "./batchloaders/BatchLoader.js";
|
|
2
|
+
import "./relations/Collection.js";
|
|
3
|
+
import { CustomCollection } from "./relations/CustomCollection.js";
|
|
4
|
+
import { CustomReference } from "./relations/CustomReference.js";
|
|
5
|
+
import { deepNormalizeHint } from "./normalizeHints.js";
|
|
6
|
+
import "./batchloaders/recursiveChildrenBatchLoader.js";
|
|
7
|
+
import "./batchloaders/recursiveM2mBatchLoader.js";
|
|
8
|
+
import "./batchloaders/recursiveParentsBatchLoader.js";
|
|
9
|
+
import { RecursiveCycleError } from "./relations/RecursiveCycleError.js";
|
|
10
|
+
import "./relations/RecursiveCollection.js";
|
|
11
|
+
import { followReverseHint } from "./reactivity/reactiveHints.js";
|
|
12
|
+
import { assertLoaded, isLoadedForPopulate } from "./loading/loadHints.js";
|
|
13
|
+
import { AsyncMethodPopulateSecret } from "./relations/hasAsyncMethod.js";
|
|
14
|
+
import { AsyncPropertyImpl } from "./relations/AsyncProperty.js";
|
|
15
|
+
import { getField, setField } from "./fields.js";
|
|
16
|
+
import { keyToNumber, keyToTaggedId, tagId, toTaggedId } from "./keys.js";
|
|
17
|
+
import { PojoRowData } from "./RowData.js";
|
|
18
|
+
import { LazyFieldImpl } from "./relations/LazyField.js";
|
|
19
|
+
import { isLoadedReference } from "./relations/Reference.js";
|
|
20
|
+
import "./batchloaders/manyToManyBatchLoader.js";
|
|
21
|
+
import "./batchloaders/oneToManyBatchLoader.js";
|
|
22
|
+
import { isSelectAllFilter } from "./queries/find/scopes.js";
|
|
23
|
+
import { OneToManyCollection } from "./relations/OneToManyCollection.js";
|
|
24
|
+
import { ManyToOneReferenceImpl } from "./relations/ManyToOneReference.js";
|
|
25
|
+
import "./batchloaders/oneToOneBatchLoader.js";
|
|
26
|
+
import { ReactiveReferenceImpl } from "./relations/ReactiveReference.js";
|
|
27
|
+
import { OneToOneReferenceImpl } from "./relations/OneToOneReference.js";
|
|
28
|
+
import { PolymorphicReferenceImpl } from "./relations/PolymorphicReference.js";
|
|
29
|
+
import "./relations/index.js";
|
|
30
|
+
import { assertNever, fail, failIfAnyRejected, getOrSet, groupBy, hasAnyKey, partition, toArray } from "./utils.js";
|
|
31
|
+
import { newEntity } from "./newEntity.js";
|
|
32
|
+
import "./typeMap.js";
|
|
33
|
+
import { ValidationErrors } from "./rules.js";
|
|
34
|
+
import { getConstructorFromTag, getConstructorFromTaggedId, getMetadataForType } from "./configure.js";
|
|
35
|
+
import { constraintNameToValidationError } from "./config.js";
|
|
36
|
+
import { getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getMetadata } from "./EntityMetadata.js";
|
|
37
|
+
import { runInTrustedContext } from "./trusted.js";
|
|
38
|
+
import { setAsyncDefaults, setSyncDefaults } from "./defaults.js";
|
|
39
|
+
import "./dataloaders/lensDataLoader.js";
|
|
40
|
+
import { loadLens } from "./loading/loadLens.js";
|
|
41
|
+
import "./logging/FactoryLogger.js";
|
|
42
|
+
import { resetFactoryCreated } from "./newTestInstance.js";
|
|
43
|
+
import { mergeFindOptions } from "./queries/find/EntityFilter.js";
|
|
44
|
+
import { JoinRows } from "./flush/JoinRows.js";
|
|
45
|
+
import { PluginManager } from "./PluginManager.js";
|
|
46
|
+
import { optimizeCollectionJoins } from "./queries/find/QueryParser.collectionJoins.js";
|
|
47
|
+
import { Todo, combineJoinRows, createTodos, getTodo } from "./flush/Todo.js";
|
|
48
|
+
import { findDataLoader } from "./dataloaders/findDataLoader.js";
|
|
49
|
+
import "./drivers/index.js";
|
|
50
|
+
import { FieldLogger, noopFieldLogger } from "./logging/FieldLogger.js";
|
|
51
|
+
import { ReactionLogger } from "./logging/ReactionLogger.js";
|
|
52
|
+
import "./plugins/PreloadPlugin.js";
|
|
53
|
+
import { parseRootQuery } from "./queries/sql/query.js";
|
|
54
|
+
import { upsert } from "./upsert.js";
|
|
55
|
+
import { NoIdError, asConcreteCstr, getRelationEntries, getRelations, setOpts } from "./index.js";
|
|
56
|
+
import "./batchloaders/enumCollectionBatchLoader.js";
|
|
57
|
+
import { loadBatchLoader } from "./batchloaders/loadBatchLoader.js";
|
|
58
|
+
import { populateBatchLoader } from "./batchloaders/populateBatchLoader.js";
|
|
59
|
+
import { findByUniqueDataLoader } from "./dataloaders/findByUniqueDataLoader.js";
|
|
60
|
+
import { findCountDataLoader, mergeCountOptions } from "./dataloaders/findCountDataLoader.js";
|
|
61
|
+
import { findIdsDataLoader } from "./dataloaders/findIdsDataLoader.js";
|
|
62
|
+
import { entityMatches, findOrCreateDataLoader } from "./dataloaders/findOrCreateDataLoader.js";
|
|
63
|
+
import { findPaginatedDataLoader } from "./dataloaders/findPaginatedDataLoader.js";
|
|
64
|
+
import { FlushLock } from "./flush/FlushLock.js";
|
|
65
|
+
import { IndexManager } from "./IndexManager.js";
|
|
66
|
+
import { IsLoadedCache } from "./loading/IsLoadedCache.js";
|
|
67
|
+
import { decodeStatementResult, isMutation, parseStatement } from "./queries/sql/execute.js";
|
|
68
|
+
import { ReactionsManager } from "./reactivity/ReactionsManager.js";
|
|
69
|
+
import { isEntity } from "./Entity.js";
|
|
70
|
+
import { getInstanceData } from "./BaseEntity.js";
|
|
71
|
+
import DataLoader from "dataloader";
|
|
72
|
+
//#region src/EntityManager.ts
|
|
61
73
|
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
62
74
|
function isId(value) {
|
|
63
|
-
|
|
75
|
+
return value && typeof value === "string";
|
|
64
76
|
}
|
|
65
77
|
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class EntityManager {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
* - Preload data for use as a cache
|
|
1520
|
-
* - Make speculative changes that may or may not be committed
|
|
1521
|
-
* - Escape a transaction scope
|
|
1522
|
-
*
|
|
1523
|
-
* The fork will:
|
|
1524
|
-
*
|
|
1525
|
-
* - Copy all currently loaded entities to the new EntityManager
|
|
1526
|
-
* - Copy any loaded relation data to keep `.isLoaded` / `.get` state consistent
|
|
1527
|
-
* - Copy and update references to the EntityManager and its entities in the context, which is itself shallowly copied
|
|
1528
|
-
*
|
|
1529
|
-
* The fork will NOT:
|
|
1530
|
-
*
|
|
1531
|
-
* - Copy any pending changes (must call .flush() first)
|
|
1532
|
-
* - Share any changes made in either EntityManager with the other
|
|
1533
|
-
*
|
|
1534
|
-
* @param opts options to control the fork behavior
|
|
1535
|
-
* - allowPendingChanges - allows the em being forked to have pending changes and forces the resulting em to have
|
|
1536
|
-
* `mode` set to "in-memory-writes". Changes to entities in the original em will be copied to the resulting em.
|
|
1537
|
-
* Optional. default: false
|
|
1538
|
-
*
|
|
1539
|
-
* @throws {Error} If called on an EntityManager with pending changes
|
|
1540
|
-
* @returns A new EntityManager with copied entity state
|
|
1541
|
-
*/
|
|
1542
|
-
fork(opts = {}) {
|
|
1543
|
-
const { allowPendingChanges = false } = opts;
|
|
1544
|
-
const oldEm = this;
|
|
1545
|
-
// copy the context so that it's distinct between the two ems, and so we can update any references from the old em
|
|
1546
|
-
// to the new one later
|
|
1547
|
-
const ctx = { ...oldEm.ctx };
|
|
1548
|
-
const newEm = new EntityManager(ctx, { em: oldEm });
|
|
1549
|
-
if (allowPendingChanges)
|
|
1550
|
-
newEm.mode = "in-memory-writes";
|
|
1551
|
-
// hydrate (ie, create) each entity from the oldEm in the newEm
|
|
1552
|
-
for (const [tag, entities] of oldEm.#entitiesByTag.entries()) {
|
|
1553
|
-
// tags are always defined by the base constructor, so we use that as hydrate expects the base class as its argument
|
|
1554
|
-
const baseCstr = (0, configure_1.getConstructorFromTag)(tag);
|
|
1555
|
-
let rows = new Array(entities.length);
|
|
1556
|
-
let i = 0;
|
|
1557
|
-
for (const entity of entities) {
|
|
1558
|
-
const instanceData = entity.__data;
|
|
1559
|
-
if (!allowPendingChanges && instanceData.pendingOperation !== "none") {
|
|
1560
|
-
(0, utils_1.fail)("Cannot fork an EntityManager with pending changes");
|
|
1561
|
-
}
|
|
1562
|
-
else if (instanceData.isNewEntity) {
|
|
1563
|
-
// Create blank entities in newEm for each unpersisted entity from oldEm. They will be populated later in the
|
|
1564
|
-
// allowPendingChanges step as they should not be present otherwise.
|
|
1565
|
-
// (I'd thought we should copy over `InstanceData.createId`, but since we're iterating over `oldEm.#entitiesByTag`
|
|
1566
|
-
// in stable as-created order, the `newEm.create` will assign the same/incrementing `createId`s as in oldEm.)
|
|
1567
|
-
newEm.create(entity.constructor, {});
|
|
1568
|
-
}
|
|
1569
|
-
else {
|
|
1570
|
-
// We copy the raw row data for each entity to avoid any potential conflict. Then we ensure the correct concrete
|
|
1571
|
-
// __class key is set for hydrate to use, if necessary (ie, cti), to actually instantiate the entity.
|
|
1572
|
-
rows[i] = createRowFromEntityData(entity);
|
|
1573
|
-
i++;
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
if (rows.length !== i)
|
|
1577
|
-
rows = rows.slice(0, i);
|
|
1578
|
-
newEm.hydrate(baseCstr, rows);
|
|
1579
|
-
}
|
|
1580
|
-
function mapEntity(oldEntity) {
|
|
1581
|
-
if (oldEntity.isNewEntity) {
|
|
1582
|
-
return newEm.#entitiesById.get(oldEntity.toTaggedString());
|
|
1583
|
-
}
|
|
1584
|
-
else {
|
|
1585
|
-
return newEm.#entitiesById.get(oldEntity.idTagged);
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
function mapEntities(v) {
|
|
1589
|
-
if (v === undefined)
|
|
1590
|
-
return undefined;
|
|
1591
|
-
const result = new Array(v.length);
|
|
1592
|
-
for (let i = 0; i < v.length; i++)
|
|
1593
|
-
result[i] = mapEntity(v[i]);
|
|
1594
|
-
return result;
|
|
1595
|
-
}
|
|
1596
|
-
// If we are allowing pending changes, then we need to copy any changes across to newEm
|
|
1597
|
-
if (allowPendingChanges) {
|
|
1598
|
-
for (const oldEntity of oldEm.entities) {
|
|
1599
|
-
const oldInstanceData = oldEntity.__data;
|
|
1600
|
-
if (!(oldInstanceData.isNewEntity || oldInstanceData.isDirtyEntity))
|
|
1601
|
-
continue;
|
|
1602
|
-
const { originalData: oldOriginalData, data: oldData } = oldInstanceData;
|
|
1603
|
-
const newEntity = mapEntity(oldEntity);
|
|
1604
|
-
const newInstanceData = newEntity.__data;
|
|
1605
|
-
const { data: newData } = newInstanceData;
|
|
1606
|
-
// for new entities, anything in `data` is changed and should be copied across. for existing entities, we
|
|
1607
|
-
// only care about changed fields, which are enumerated by originalData
|
|
1608
|
-
const maybeEntity = (value) => ((0, Entity_1.isEntity)(value) ? mapEntity(value) : value);
|
|
1609
|
-
const fields = Object.keys(oldEntity.isNewEntity ? oldData : oldOriginalData);
|
|
1610
|
-
for (const field of fields) {
|
|
1611
|
-
// copy over originalData so .changes is consistent across ems
|
|
1612
|
-
if (field in oldOriginalData)
|
|
1613
|
-
newInstanceData.markFieldDirty(field, maybeEntity(oldOriginalData[field]));
|
|
1614
|
-
newData[field] = maybeEntity(oldData[field]);
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
// import every loaded concrete (ie, not custom) relation into the new em
|
|
1619
|
-
for (const oldEntity of oldEm.entities) {
|
|
1620
|
-
const newEntity = mapEntity(oldEntity);
|
|
1621
|
-
if (oldEntity.isDeletedEntity) {
|
|
1622
|
-
// If the old entity was deleted, that should be persisted in the new em
|
|
1623
|
-
newEntity.__data.markDeleted();
|
|
1624
|
-
// deleted entities will fail if you try to `get` their relations, so skip them since they should be cleared
|
|
1625
|
-
// out regardless
|
|
1626
|
-
continue;
|
|
1627
|
-
}
|
|
1628
|
-
const { relations } = oldEntity.__data;
|
|
1629
|
-
for (const [field, relation] of Object.entries(relations)) {
|
|
1630
|
-
// With lazyRelation, custom relations are inserted into the `relations` map. Custom relations don't
|
|
1631
|
-
// store any data, so we can ignore them by checking if the relation implements `import`
|
|
1632
|
-
// TODO: add `import` to recursiveCollection
|
|
1633
|
-
if (!("import" in relation))
|
|
1634
|
-
continue;
|
|
1635
|
-
if (oldEntity.isNewEntity) {
|
|
1636
|
-
// every relation should be loaded on a new entity, so calling get should be safe
|
|
1637
|
-
const oldValue = relation.get;
|
|
1638
|
-
if (oldValue === undefined)
|
|
1639
|
-
continue;
|
|
1640
|
-
if (Array.isArray(oldValue) && oldValue.length === 0)
|
|
1641
|
-
continue;
|
|
1642
|
-
const newValue = Array.isArray(oldValue) ? mapEntities(oldValue) : mapEntity(oldValue);
|
|
1643
|
-
// we may have already copied over the instance data, in which case `setFromOpts` would detect this as
|
|
1644
|
-
// the same entity that's already set in data and early exit, so delete ourselves from data first
|
|
1645
|
-
delete newEntity.__data.data[field];
|
|
1646
|
-
newEntity[field].setFromOpts(newValue);
|
|
1647
|
-
}
|
|
1648
|
-
else {
|
|
1649
|
-
const isLoaded = "_isLoaded" in relation ? relation._isLoaded : relation.isLoaded;
|
|
1650
|
-
if (isLoaded)
|
|
1651
|
-
newEntity[field].import(relation, mapEntity, mapEntities);
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
// Inspect the top level keys in the context and replace any references from oldEm with newEm (ie, ctx.em === newEm)
|
|
1656
|
-
// while also replacing any entities from oldEm with their version in newEm (eg, if the user is stored in the
|
|
1657
|
-
// context, then `ctx.user.em === newEm`).
|
|
1658
|
-
for (const [key, value] of Object.entries(ctx)) {
|
|
1659
|
-
if ((0, Entity_1.isEntity)(value) && value.em === oldEm) {
|
|
1660
|
-
ctx[key] = mapEntity(value);
|
|
1661
|
-
}
|
|
1662
|
-
else if (value === oldEm) {
|
|
1663
|
-
ctx[key] = newEm;
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
return newEm;
|
|
1667
|
-
}
|
|
1668
|
-
importEntity(source, hint, normalizedHint) {
|
|
1669
|
-
if (source.isNewEntity)
|
|
1670
|
-
(0, utils_1.fail)("cannot import new entities");
|
|
1671
|
-
if (source.isDeletedEntity)
|
|
1672
|
-
(0, utils_1.fail)("cannot import deleted entities");
|
|
1673
|
-
if (source.isDirtyEntity)
|
|
1674
|
-
(0, utils_1.fail)("cannot import dirty entities");
|
|
1675
|
-
hint ??= {};
|
|
1676
|
-
if (!normalizedHint) {
|
|
1677
|
-
(0, index_1.assertLoaded)(source, hint);
|
|
1678
|
-
normalizedHint = (0, index_1.deepNormalizeHint)(hint);
|
|
1679
|
-
}
|
|
1680
|
-
if (source.em === this)
|
|
1681
|
-
return source;
|
|
1682
|
-
const meta = (0, index_1.getMetadata)(source);
|
|
1683
|
-
let result = this.#entitiesById.get(source.idTagged);
|
|
1684
|
-
if (!result) {
|
|
1685
|
-
const meta = (0, index_1.getMetadata)(source);
|
|
1686
|
-
const row = createRowFromEntityData(source);
|
|
1687
|
-
result = this.hydrate((0, index_1.getBaseMeta)(meta).cstr, [row])[0];
|
|
1688
|
-
}
|
|
1689
|
-
for (const [fieldName, subHint] of Object.entries(normalizedHint)) {
|
|
1690
|
-
const field = meta.allFields[fieldName];
|
|
1691
|
-
const relationOrProp = result[fieldName];
|
|
1692
|
-
if (!field) {
|
|
1693
|
-
let loadHint = relationOrProp.loadHint ?? (0, utils_1.fail)(`${source}.${fieldName} cannot be imported as it has no loadHint`);
|
|
1694
|
-
this.importEntity(source, loadHint);
|
|
1695
|
-
}
|
|
1696
|
-
else if ("import" in relationOrProp) {
|
|
1697
|
-
// Tell our version of the entity (result) to accept/copy the relation state of the source
|
|
1698
|
-
relationOrProp.import(source[fieldName], (e) => this.importEntity(e, subHint, subHint), (entities) => {
|
|
1699
|
-
if (entities === undefined)
|
|
1700
|
-
return undefined;
|
|
1701
|
-
const result = new Array(entities.length);
|
|
1702
|
-
for (let i = 0; i < entities.length; i++) {
|
|
1703
|
-
result[i] = this.importEntity(entities[i], subHint, subHint);
|
|
1704
|
-
}
|
|
1705
|
-
return result;
|
|
1706
|
-
});
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
return result;
|
|
1710
|
-
}
|
|
1711
|
-
addPlugin(plugin) {
|
|
1712
|
-
getEmInternalApi(this).pluginManager.addPlugin(plugin);
|
|
1713
|
-
}
|
|
1714
|
-
getPlugins() {
|
|
1715
|
-
return getEmInternalApi(this).pluginManager.plugins;
|
|
1716
|
-
}
|
|
1717
|
-
get isRefreshing() {
|
|
1718
|
-
return this.#isRefreshing;
|
|
1719
|
-
}
|
|
1720
|
-
get isFlushing() {
|
|
1721
|
-
return this.#fl.isFlushing;
|
|
1722
|
-
}
|
|
1723
|
-
/** Creates a new `type` and marks it as loaded, i.e. we know its collections are all safe to access in memory. */
|
|
1724
|
-
#doCreate(type, opts, partial) {
|
|
1725
|
-
const entity = (0, newEntity_1.newEntity)(this, type, true);
|
|
1726
|
-
// Assign the next `a#1`, `a#2`, etc. id
|
|
1727
|
-
const meta = (0, index_1.getMetadata)(type);
|
|
1728
|
-
const counter = (this.#createCounter ??= new Map());
|
|
1729
|
-
const i = (counter.get(meta.tagName) ?? 0) + 1;
|
|
1730
|
-
counter.set(meta.tagName, i);
|
|
1731
|
-
(0, BaseEntity_1.getInstanceData)(entity).createId = String(i);
|
|
1732
|
-
// Check opts.id for an explicitly-set id
|
|
1733
|
-
this.#doRegister(entity, opts.id);
|
|
1734
|
-
// Set a default createdAt/updatedAt
|
|
1735
|
-
const baseMeta = (0, index_1.getBaseMeta)((0, index_1.getMetadata)(entity));
|
|
1736
|
-
if (baseMeta.timestampFields) {
|
|
1737
|
-
this.#assignTimestamps(entity, baseMeta);
|
|
1738
|
-
}
|
|
1739
|
-
// Set the discriminator for STI
|
|
1740
|
-
if (baseMeta.inheritanceType === "sti") {
|
|
1741
|
-
setStiDiscriminatorValue(baseMeta, entity);
|
|
1742
|
-
}
|
|
1743
|
-
// api will be undefined during getFakeInstance
|
|
1744
|
-
const api = getEmInternalApi(this);
|
|
1745
|
-
api?.fieldLogger?.logCreate(entity);
|
|
1746
|
-
(0, index_1.setOpts)(entity, opts, { partial, calledFromConstructor: true });
|
|
1747
|
-
// Apply any synchronous defaults, after the opts have been applied
|
|
1748
|
-
if (!this.fakeInstance) {
|
|
1749
|
-
(0, defaults_1.setSyncDefaults)(entity);
|
|
1750
|
-
}
|
|
1751
|
-
this.#rm.queueAllDownstreamFields(entity, "created");
|
|
1752
|
-
return entity;
|
|
1753
|
-
}
|
|
1754
|
-
#assignTimestamps(entity, baseMeta) {
|
|
1755
|
-
const { createdAt, updatedAt } = baseMeta.timestampFields ?? {};
|
|
1756
|
-
const { data } = (0, BaseEntity_1.getInstanceData)(entity);
|
|
1757
|
-
const now = new Date();
|
|
1758
|
-
if (createdAt) {
|
|
1759
|
-
const serde = baseMeta.fields[createdAt].serde;
|
|
1760
|
-
data[createdAt] = serde.mapFromNow(now);
|
|
1761
|
-
}
|
|
1762
|
-
if (updatedAt) {
|
|
1763
|
-
const serde = baseMeta.fields[updatedAt].serde;
|
|
1764
|
-
data[updatedAt] = serde.mapFromNow(now);
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
/** Registers a newly-instantiated entity with our EntityManager; only called by #doCreate and hydrate. */
|
|
1768
|
-
#doRegister(entity, id, meta, skipDuplicateCheck = false) {
|
|
1769
|
-
// Keep our indexes up to date...
|
|
1770
|
-
const maybeId = id ?? entity.idTaggedMaybe;
|
|
1771
|
-
if (maybeId) {
|
|
1772
|
-
if (!skipDuplicateCheck && this.findExistingInstance(maybeId) !== undefined) {
|
|
1773
|
-
throw new Error(`Entity ${entity} has a duplicate instance already loaded`);
|
|
1774
|
-
}
|
|
1775
|
-
this.#entitiesById.set(maybeId, entity);
|
|
1776
|
-
}
|
|
1777
|
-
else {
|
|
1778
|
-
// Also register by the `a#1` style tagged string for new entities
|
|
1779
|
-
this.#entitiesById.set(entity.toTaggedString(), entity);
|
|
1780
|
-
}
|
|
1781
|
-
(0, BaseEntity_1.getInstanceData)(entity).entityIndex = this.#entitiesArray.length;
|
|
1782
|
-
this.#entitiesArray.push(entity);
|
|
1783
|
-
meta ??= (0, index_1.getMetadata)(entity);
|
|
1784
|
-
const set = this.#entitiesByTag.get(meta.tagName) ?? [];
|
|
1785
|
-
if (set.length === 0)
|
|
1786
|
-
this.#entitiesByTag.set(meta.tagName, set);
|
|
1787
|
-
set.push(entity);
|
|
1788
|
-
if (this.#entitiesArray.length >= this.entityLimit) {
|
|
1789
|
-
const topTypes = [...this.#entitiesByTag.entries()]
|
|
1790
|
-
.map(([tag, entities]) => ({ tag, count: entities.length }))
|
|
1791
|
-
.sort((a, b) => b.count - a.count)
|
|
1792
|
-
.slice(0, 3)
|
|
1793
|
-
.map(({ tag, count }) => `${tag}=${count}`)
|
|
1794
|
-
.join(", ");
|
|
1795
|
-
throw new Error(`More than ${this.entityLimit} entities have been instantiated (top entities: ${topTypes})`);
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
exports.EntityManager = EntityManager;
|
|
78
|
+
* The EntityManager is the primary way nearly all code, i.e. anything that finds/creates/updates/deletes entities,
|
|
79
|
+
* will interact with the database.
|
|
80
|
+
*
|
|
81
|
+
* It acts both an Identity Cache (preventing loading the same row twice into memory as separate entities, and then
|
|
82
|
+
* having drift between the two instances) and as a Unit of Work (tracking all changes to entities and then batch
|
|
83
|
+
* flushing only the entities that have changed).
|
|
84
|
+
*
|
|
85
|
+
* Note that the type parameters (C, I, and Entity) will be filled in by codegen with the values specific to your
|
|
86
|
+
* application, so you can import your app-specific EntityManager like:
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { EntityManager } from "src/entities";
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @param C The type of your application-specific app-wide/request-wide Context object that will be passed to hooks
|
|
93
|
+
* @typeParam C - the application-specific context (typically the request-level context)
|
|
94
|
+
* @typeParam Entity - the application's based entity type (i.e. with number ids or string ids)
|
|
95
|
+
* @typeParamTX - the application's Transaction type, i.e. `Knex`
|
|
96
|
+
*/
|
|
97
|
+
var EntityManager = class EntityManager {
|
|
98
|
+
ctx;
|
|
99
|
+
driver;
|
|
100
|
+
/** When we're flushing, the connection/transaction. */
|
|
101
|
+
txn;
|
|
102
|
+
entityLimit = defaultEntityLimit;
|
|
103
|
+
#entitiesArray = [];
|
|
104
|
+
#maybePendingFlushEntities = /* @__PURE__ */ new Set();
|
|
105
|
+
#entitiesById = /* @__PURE__ */ new Map();
|
|
106
|
+
#entitiesByTag = /* @__PURE__ */ new Map();
|
|
107
|
+
#indexManager = new IndexManager();
|
|
108
|
+
#isValidating = false;
|
|
109
|
+
#findRestricted = false;
|
|
110
|
+
#pendingPercolate = /* @__PURE__ */ new Map();
|
|
111
|
+
#preloadedRelations = /* @__PURE__ */ new Map();
|
|
112
|
+
/**
|
|
113
|
+
* Tracks cascade deletes.
|
|
114
|
+
*
|
|
115
|
+
* We originally used a beforeDelete lifecycle hook to implement this, but tracking this
|
|
116
|
+
* individually allows us to a) recursively cascade deletes even during the 1st iteration
|
|
117
|
+
* of our `flush` loop, and b) cascade deletions before we recalc fields & run user hooks,
|
|
118
|
+
* so that both see the most accurate state.
|
|
119
|
+
*/
|
|
120
|
+
#pendingDeletes = [];
|
|
121
|
+
#hasAnyDeletes = false;
|
|
122
|
+
#dataloaders = {};
|
|
123
|
+
#batchLoaders = {};
|
|
124
|
+
#joinRows = {};
|
|
125
|
+
/** Stores any `source -> downstream` reactions to recalc during `em.flush`. */
|
|
126
|
+
#rm = new ReactionsManager(this);
|
|
127
|
+
/** Ensures our `em.flush` method is not interrupted. */
|
|
128
|
+
#fl = new FlushLock();
|
|
129
|
+
#hooks = {
|
|
130
|
+
beforeBegin: [],
|
|
131
|
+
afterBegin: [],
|
|
132
|
+
beforeCommit: [],
|
|
133
|
+
afterCommit: []
|
|
134
|
+
};
|
|
135
|
+
#preloader;
|
|
136
|
+
#fieldLogger = noopFieldLogger;
|
|
137
|
+
#isLoadedCache = new IsLoadedCache();
|
|
138
|
+
#merging;
|
|
139
|
+
/** Track `a#1`, `a#2`, etc indexes for `em.create`-d entities. */
|
|
140
|
+
#createCounter = void 0;
|
|
141
|
+
__api;
|
|
142
|
+
#isRefreshing = false;
|
|
143
|
+
mode = "writes";
|
|
144
|
+
constructor(ctx, driverOrOpts) {
|
|
145
|
+
const opts = driverOrOpts.constructor === Object ? driverOrOpts : { driver: driverOrOpts };
|
|
146
|
+
this.ctx = ctx;
|
|
147
|
+
this.driver = opts.driver ?? opts.em.driver;
|
|
148
|
+
this.#preloader = opts.preloadPlugin ?? (opts.em ? opts.em.#preloader : this.driver.defaultPlugins.preloadPlugin);
|
|
149
|
+
const pluginManager = new PluginManager(this);
|
|
150
|
+
if (opts.em) {
|
|
151
|
+
this.#hooks = {
|
|
152
|
+
beforeBegin: [...opts.em.#hooks.beforeBegin],
|
|
153
|
+
afterBegin: [...opts.em.#hooks.afterBegin],
|
|
154
|
+
beforeCommit: [...opts.em.#hooks.beforeCommit],
|
|
155
|
+
afterCommit: [...opts.em.#hooks.afterCommit]
|
|
156
|
+
};
|
|
157
|
+
opts.em.__api.pluginManager.cloneTo(pluginManager);
|
|
158
|
+
}
|
|
159
|
+
const em = this;
|
|
160
|
+
this.__api = {
|
|
161
|
+
preloader: this.#preloader,
|
|
162
|
+
pendingPercolate: this.#pendingPercolate,
|
|
163
|
+
mutatedCollections: /* @__PURE__ */ new Set(),
|
|
164
|
+
pendingLoads: /* @__PURE__ */ new Set(),
|
|
165
|
+
hooks: this.#hooks,
|
|
166
|
+
rm: this.#rm,
|
|
167
|
+
indexManager: this.#indexManager,
|
|
168
|
+
isLoadedCache: this.#isLoadedCache,
|
|
169
|
+
pluginManager,
|
|
170
|
+
markMaybePending(entity) {
|
|
171
|
+
em.#maybePendingFlushEntities.add(entity);
|
|
172
|
+
},
|
|
173
|
+
unmarkMaybePending(entity) {
|
|
174
|
+
em.#maybePendingFlushEntities.delete(entity);
|
|
175
|
+
},
|
|
176
|
+
hasAnyDeletes() {
|
|
177
|
+
return em.#hasAnyDeletes;
|
|
178
|
+
},
|
|
179
|
+
pendingDeleteIds(type) {
|
|
180
|
+
return em.#pendingDeletes.filter((entity) => entity instanceof type && entity.idMaybe !== void 0).map((entity) => keyToNumber(getMetadata(entity), entity.id));
|
|
181
|
+
},
|
|
182
|
+
isMerging(entity) {
|
|
183
|
+
return em.#merging?.has(entity) ?? false;
|
|
184
|
+
},
|
|
185
|
+
joinRows(m2m) {
|
|
186
|
+
return getOrSet(em.#joinRows, m2m.joinTableName, () => new JoinRows(m2m, em.#rm));
|
|
187
|
+
},
|
|
188
|
+
/** Returns `a:1.books` if it's in our preload cache. */
|
|
189
|
+
getPreloadedRelation(taggedId, fieldName) {
|
|
190
|
+
return em.#preloadedRelations.get(taggedId)?.get(fieldName);
|
|
191
|
+
},
|
|
192
|
+
/** Stores `a:1.books` in our preload cache. */
|
|
193
|
+
setPreloadedRelation(taggedId, fieldName, children) {
|
|
194
|
+
let map = em.#preloadedRelations.get(taggedId);
|
|
195
|
+
if (!map) {
|
|
196
|
+
map = /* @__PURE__ */ new Map();
|
|
197
|
+
em.#preloadedRelations.set(taggedId, map);
|
|
198
|
+
}
|
|
199
|
+
map.set(fieldName, children);
|
|
200
|
+
},
|
|
201
|
+
get isValidating() {
|
|
202
|
+
return em.#isValidating;
|
|
203
|
+
},
|
|
204
|
+
checkWritesAllowed() {
|
|
205
|
+
if (em.mode === "read-only") throw new ReadOnlyError();
|
|
206
|
+
return em.#fl.checkWritesAllowed();
|
|
207
|
+
},
|
|
208
|
+
get fieldLogger() {
|
|
209
|
+
return em.#fieldLogger;
|
|
210
|
+
},
|
|
211
|
+
clearDataloaders() {
|
|
212
|
+
em.#dataloaders = {};
|
|
213
|
+
em.#batchLoaders = {};
|
|
214
|
+
},
|
|
215
|
+
clearPreloadedRelations() {
|
|
216
|
+
em.#preloadedRelations = /* @__PURE__ */ new Map();
|
|
217
|
+
},
|
|
218
|
+
setIsRefreshing(isRefreshing) {
|
|
219
|
+
em.#isRefreshing = isRefreshing;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/** Returns a read-only shallow copy of the currently-loaded entities. */
|
|
224
|
+
get entities() {
|
|
225
|
+
return [...this.#entitiesArray];
|
|
226
|
+
}
|
|
227
|
+
/** Returns a list of all pending creates, updates, deletes, and m2m changes that would be flushed. */
|
|
228
|
+
get pendingChanges() {
|
|
229
|
+
const changes = [];
|
|
230
|
+
for (const entity of this.#entitiesArray) switch (getInstanceData(entity).pendingOperation) {
|
|
231
|
+
case "insert":
|
|
232
|
+
changes.push({
|
|
233
|
+
kind: "create",
|
|
234
|
+
entity
|
|
235
|
+
});
|
|
236
|
+
break;
|
|
237
|
+
case "update":
|
|
238
|
+
changes.push({
|
|
239
|
+
kind: "update",
|
|
240
|
+
entity
|
|
241
|
+
});
|
|
242
|
+
break;
|
|
243
|
+
case "delete": changes.push({
|
|
244
|
+
kind: "delete",
|
|
245
|
+
entity
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
for (const joinRows of Object.values(this.#joinRows)) {
|
|
249
|
+
const todo = joinRows.toTodo();
|
|
250
|
+
if (todo && !todo.m2m.otherEnum) {
|
|
251
|
+
for (const row of todo.newRows) {
|
|
252
|
+
const entities = Object.values(row.columns);
|
|
253
|
+
changes.push({
|
|
254
|
+
kind: "m2m",
|
|
255
|
+
op: "add",
|
|
256
|
+
joinTableName: todo.m2m.joinTableName,
|
|
257
|
+
entities
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
for (const row of todo.deletedRows) {
|
|
261
|
+
const entities = Object.values(row.columns);
|
|
262
|
+
changes.push({
|
|
263
|
+
kind: "m2m",
|
|
264
|
+
op: "remove",
|
|
265
|
+
joinTableName: todo.m2m.joinTableName,
|
|
266
|
+
entities
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return changes;
|
|
272
|
+
}
|
|
273
|
+
/** Returns a read-only list of the currently-loaded entities of `type`. */
|
|
274
|
+
getEntities(type) {
|
|
275
|
+
const meta = getMetadata(type);
|
|
276
|
+
const entities = this.#entitiesByTag.get(meta.tagName) ?? [];
|
|
277
|
+
return meta.baseType ? entities.filter((e) => e instanceof type) : entities;
|
|
278
|
+
}
|
|
279
|
+
getEntity(id) {
|
|
280
|
+
return this.#entitiesById.get(id);
|
|
281
|
+
}
|
|
282
|
+
async find(type, where, options) {
|
|
283
|
+
this.#assertFindAllowed("find");
|
|
284
|
+
const { populate, ...rest } = options || {};
|
|
285
|
+
const normalized = mergeFindOptions(where, rest);
|
|
286
|
+
const settings = {
|
|
287
|
+
where: normalized.where,
|
|
288
|
+
...normalized.options
|
|
289
|
+
};
|
|
290
|
+
const result = await (hasPaginationSettings(normalized.options) ? findPaginatedDataLoader(this, type, settings, populate) : findDataLoader(this, type, settings, populate)).catch(function find(err) {
|
|
291
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
292
|
+
});
|
|
293
|
+
if (populate) await this.populate(result, populate);
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
query(q, options) {
|
|
297
|
+
this.#assertFindAllowed("query");
|
|
298
|
+
const em = this;
|
|
299
|
+
return (async function query() {
|
|
300
|
+
const plan = parseRootQuery(q);
|
|
301
|
+
if (options?.populate && plan.output.kind !== "entity") fail("em.query populate requires an entity selection");
|
|
302
|
+
const { rows } = await em.driver.executeQuery(em, plan.sql, plan.bindings);
|
|
303
|
+
const result = plan.decodeRows(em, rows);
|
|
304
|
+
if (options?.populate) await em.populate(result, options.populate);
|
|
305
|
+
return result;
|
|
306
|
+
})().catch(function query(err) {
|
|
307
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
execute(statement) {
|
|
311
|
+
const em = this;
|
|
312
|
+
return (async function execute() {
|
|
313
|
+
if (isMutation(statement)) {
|
|
314
|
+
if (em.mode === "read-only") throw new ReadOnlyError();
|
|
315
|
+
if (em.mode === "in-memory-writes") fail("SQL mutations do not support in-memory-writes mode");
|
|
316
|
+
} else em.#assertFindAllowed("execute");
|
|
317
|
+
const plan = parseStatement(statement);
|
|
318
|
+
if (!plan) return {
|
|
319
|
+
rowCount: 0,
|
|
320
|
+
rows: []
|
|
321
|
+
};
|
|
322
|
+
const result = await em.driver.executeQuery(em, plan.sql, plan.bindings);
|
|
323
|
+
return decodeStatementResult(em, plan, result);
|
|
324
|
+
})().catch(function execute(err) {
|
|
325
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
/** Fails fast if `em.${method}` is called from a regular validation rule, i.e. steers to `config.addCommitRule`. */
|
|
329
|
+
#assertFindAllowed(method) {
|
|
330
|
+
if (this.#findRestricted) throw new Error(`em.${method} cannot be called from a validation rule (added via config.addRule), because rules run before the flush and would query stale, pre-flush data. Use config.addCommitRule instead, which runs after the INSERT/UPDATE/DELETEs are flushed (within the same transaction) and so sees the changed state.`);
|
|
331
|
+
}
|
|
332
|
+
/** Runs the post-parse find pipeline: plugins mutate the logical AST, then Joist optimizes/prunes before SQL. */
|
|
333
|
+
async executeFind(meta, operation, parsed, settings) {
|
|
334
|
+
const { checkLimit, findSettings } = this.prepareFind(meta, operation, parsed, settings);
|
|
335
|
+
return this.executePreparedFind(meta, operation, parsed, findSettings, checkLimit);
|
|
336
|
+
}
|
|
337
|
+
/** Like {@link executeFind}, but returns a {@link RowData}; see {@link executePreparedFindRowData}. */
|
|
338
|
+
async executeFindRowData(meta, operation, parsed, settings) {
|
|
339
|
+
const { checkLimit, findSettings } = this.prepareFind(meta, operation, parsed, settings);
|
|
340
|
+
return this.executePreparedFindRowData(meta, operation, parsed, findSettings, checkLimit);
|
|
341
|
+
}
|
|
342
|
+
/** Executes a query that has already had find hooks and optimizations applied. */
|
|
343
|
+
async executePreparedFind(meta, operation, parsed, findSettings, checkLimit) {
|
|
344
|
+
const { pluginManager } = getEmInternalApi(this);
|
|
345
|
+
const rows = await this.driver.executeFind(this, parsed, findSettings);
|
|
346
|
+
if ((checkLimit ?? !("limit" in findSettings && findSettings.limit === void 0)) && rows.length >= this.entityLimit) throw new Error(`Query returned more than ${this.entityLimit} entityLimit rows`);
|
|
347
|
+
if (pluginManager.hasHook("afterFind")) pluginManager.afterFind(meta, operation, new PojoRowData(rows));
|
|
348
|
+
return rows;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Like {@link executePreparedFind}, but returns a {@link RowData}: lazy wire rows when the
|
|
352
|
+
* driver has `lazyRows` enabled, else classic POJO rows wrapped in a `PojoRowData` — so
|
|
353
|
+
* loaders can hydrate from one shape without caring which the driver provides.
|
|
354
|
+
*/
|
|
355
|
+
async executePreparedFindRowData(meta, operation, parsed, findSettings, checkLimit) {
|
|
356
|
+
const { executeFindRowData } = this.driver;
|
|
357
|
+
if (executeFindRowData === void 0) return new PojoRowData(await this.executePreparedFind(meta, operation, parsed, findSettings, checkLimit));
|
|
358
|
+
const { pluginManager } = getEmInternalApi(this);
|
|
359
|
+
const rowData = await executeFindRowData.call(this.driver, this, parsed, findSettings);
|
|
360
|
+
if ((checkLimit ?? !("limit" in findSettings && findSettings.limit === void 0)) && rowData.rowCount >= this.entityLimit) throw new Error(`Query returned more than ${this.entityLimit} entityLimit rows`);
|
|
361
|
+
pluginManager.afterFind(meta, operation, rowData);
|
|
362
|
+
return rowData;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Runs pre-SQL find hooks and optimizations against a parsed query.
|
|
366
|
+
*
|
|
367
|
+
* This allows plugins to see "pre-batched" / "logical" query ASTs, instead of our
|
|
368
|
+
* more complicated `_find` batched queries. The flow would be:
|
|
369
|
+
*
|
|
370
|
+
* - A loader calls `prepareFind(originalQuery)`
|
|
371
|
+
* - Plugins inspect/modify the query as/if needed
|
|
372
|
+
* - The loader crafts a new, more complicated query that embeds the originalQuery
|
|
373
|
+
* - The loader calls `executePreparedFind` with the 2nd query
|
|
374
|
+
*/
|
|
375
|
+
prepareFind(meta, operation, parsed, settings) {
|
|
376
|
+
const { checkLimit, ...findSettings } = settings;
|
|
377
|
+
const { pluginManager } = getEmInternalApi(this);
|
|
378
|
+
pluginManager.beforeFind(meta, operation, parsed, findSettings);
|
|
379
|
+
optimizeCollectionJoins(parsed, settings);
|
|
380
|
+
return {
|
|
381
|
+
checkLimit,
|
|
382
|
+
findSettings
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
async findGql(type, where, options) {
|
|
386
|
+
if (!options) return this.find(type, where);
|
|
387
|
+
const normalized = { ...options };
|
|
388
|
+
if ("limit" in normalized) normalized.limit = normalized.limit ?? void 0;
|
|
389
|
+
if ("offset" in normalized) normalized.offset = normalized.offset ?? void 0;
|
|
390
|
+
return this.find(type, where, normalized);
|
|
391
|
+
}
|
|
392
|
+
async findOne(type, where, options) {
|
|
393
|
+
const list = await this.find(type, where, options);
|
|
394
|
+
if (list.length === 0) return;
|
|
395
|
+
else if (list.length === 1) return list[0];
|
|
396
|
+
else throw new TooManyError(`Found more than one: ${list.map((e) => e.toString()).join(", ")}`);
|
|
397
|
+
}
|
|
398
|
+
async findOneOrFail(type, where, options) {
|
|
399
|
+
const list = await this.find(type, where, options);
|
|
400
|
+
if (list.length === 0) throw new NotFoundError(`Did not find ${type.name} for given query`);
|
|
401
|
+
else if (list.length > 1) throw new TooManyError(`Found more than one: ${list.map((e) => e.toString()).join(", ")}`);
|
|
402
|
+
return list[0];
|
|
403
|
+
}
|
|
404
|
+
async findByUnique(type, where, options = {}) {
|
|
405
|
+
this.#assertFindAllowed("findByUnique");
|
|
406
|
+
const { populate, softDeletes = "exclude" } = options;
|
|
407
|
+
const entries = Object.entries(where);
|
|
408
|
+
if (entries.length !== 1) throw new Error("findByUnique only accepts a single field");
|
|
409
|
+
const [fieldName, value] = entries[0];
|
|
410
|
+
const field = getMetadata(type).allFields[fieldName];
|
|
411
|
+
const row = await findByUniqueDataLoader(this, type, field, softDeletes).load(value).catch(function findByUnique(err) {
|
|
412
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
413
|
+
});
|
|
414
|
+
if (!row) return;
|
|
415
|
+
else {
|
|
416
|
+
const [entity] = this.hydrate(type, [row]);
|
|
417
|
+
if (this.#hasAnyDeletes && entity.isDeletedEntity) return;
|
|
418
|
+
if (populate) await this.populate(entity, populate);
|
|
419
|
+
return entity;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Returns the count of entities that match the `where` clause.
|
|
424
|
+
*
|
|
425
|
+
* The `where` clause, and any options.conditions, matches the same syntax
|
|
426
|
+
* as `em.find`.
|
|
427
|
+
*
|
|
428
|
+
* Note: this method is not currently auto-batched, so it will cause N+1s if called in a loop.
|
|
429
|
+
*/
|
|
430
|
+
async findCount(type, where, options = {}) {
|
|
431
|
+
this.#assertFindAllowed("findCount");
|
|
432
|
+
const normalized = mergeCountOptions(where, options);
|
|
433
|
+
const settings = {
|
|
434
|
+
where: normalized.where,
|
|
435
|
+
...normalized.options
|
|
436
|
+
};
|
|
437
|
+
let count = await findCountDataLoader(this, type, settings).catch(function findCount(err) {
|
|
438
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
439
|
+
});
|
|
440
|
+
if (isSelectAllFilter(where, options.conditions)) {
|
|
441
|
+
const tagged = this.#entitiesByTag.get(getMetadata(type).tagName) ?? [];
|
|
442
|
+
for (const entity of tagged) if (entity instanceof type) {
|
|
443
|
+
if (entity.isNewEntity) count++;
|
|
444
|
+
else if (entity.isDeletedEntity) count--;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return count;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Returns the IDs of entities that match the `where` clause.
|
|
451
|
+
*
|
|
452
|
+
* The `where` clause, and any options.conditions, matches the same syntax
|
|
453
|
+
* as `em.find`.
|
|
454
|
+
*/
|
|
455
|
+
async findIds(type, where, options = {}) {
|
|
456
|
+
this.#assertFindAllowed("findIds");
|
|
457
|
+
const normalized = mergeCountOptions(where, options);
|
|
458
|
+
const settings = {
|
|
459
|
+
where: normalized.where,
|
|
460
|
+
...normalized.options
|
|
461
|
+
};
|
|
462
|
+
return findIdsDataLoader(this, type, settings).catch(function findIds(err) {
|
|
463
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
async findWithNewOrChanged(type, where, options) {
|
|
467
|
+
const { softDeletes = "exclude", populate } = options ?? {};
|
|
468
|
+
const copy = Object.fromEntries(Object.entries(where).filter(([, v]) => v !== void 0));
|
|
469
|
+
const unchanged = (await this.find(type, copy, { softDeletes })).filter((e) => !e.isNewEntity && !e.isDirtyEntity && !e.isDeletedEntity);
|
|
470
|
+
const maybeNew = this.filterEntities(type, where).filter((e) => (e.isNewEntity || e.isDirtyEntity) && !e.isDeletedEntity);
|
|
471
|
+
const found = [...unchanged, ...maybeNew];
|
|
472
|
+
if (populate) await this.populate(found, populate);
|
|
473
|
+
return found;
|
|
474
|
+
}
|
|
475
|
+
async findOrCreate(type, where, ifNew, upsert, options) {
|
|
476
|
+
const { softDeletes = "exclude", populate } = options ?? {};
|
|
477
|
+
const entity = await findOrCreateDataLoader(this, type, where, softDeletes).load({
|
|
478
|
+
ifNew,
|
|
479
|
+
upsert
|
|
480
|
+
}).catch(function findOrCreate(err) {
|
|
481
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
482
|
+
});
|
|
483
|
+
if (populate) await this.populate(entity, populate);
|
|
484
|
+
return entity;
|
|
485
|
+
}
|
|
486
|
+
/** Creates a new `type` and marks it as loaded, i.e. we know its collections are all safe to access in memory. */
|
|
487
|
+
create(type, opts) {
|
|
488
|
+
return this.#doCreate(type, opts, false);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Creates a new `type` but with `opts` that are nullable, to accept partial-update-style input.
|
|
492
|
+
*
|
|
493
|
+
* Note that `createPartial` doesn't support the full upsert behavior, i.e. this method:
|
|
494
|
+
*
|
|
495
|
+
* - always creates,
|
|
496
|
+
* - does not support relation markers like `op`, `delete`, and `remove`,
|
|
497
|
+
* - does not accept deep input, but
|
|
498
|
+
* - fields set to `undefined` will be skipped instead of unset
|
|
499
|
+
*
|
|
500
|
+
* See `upsert` for the upsert/deep upsert behavior.
|
|
501
|
+
*/
|
|
502
|
+
createPartial(type, opts) {
|
|
503
|
+
return this.#doCreate(type, opts, true);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Create or updates `type` based on partial-update-style `input`.
|
|
507
|
+
*
|
|
508
|
+
* This supports upsert behavior, i.e.:
|
|
509
|
+
*
|
|
510
|
+
* - findOrCreate the primary entity being updated (based on the `id` key being provided),
|
|
511
|
+
* - upsert relation markers like `op`, `delete`, and `remove` are supported,
|
|
512
|
+
* - deep input is supported, i.e. `{ firstName: "Bob", books: [{ title: "b1" } ] }`, and
|
|
513
|
+
* - fields set to `undefined` will be skipped instead of unset
|
|
514
|
+
*/
|
|
515
|
+
upsert(type, input) {
|
|
516
|
+
return upsert(this, type, input);
|
|
517
|
+
}
|
|
518
|
+
async clone(entityOrArray, opts) {
|
|
519
|
+
const { deep = {}, skipIf, skip = {}, postClone } = opts ?? {};
|
|
520
|
+
const todo = /* @__PURE__ */ new Set();
|
|
521
|
+
const skipMap = /* @__PURE__ */ new WeakMap();
|
|
522
|
+
await crawl(todo, skipMap, Array.isArray(entityOrArray) ? entityOrArray : [entityOrArray], deep, {
|
|
523
|
+
skipIf,
|
|
524
|
+
skip
|
|
525
|
+
});
|
|
526
|
+
const deferredRelations = [];
|
|
527
|
+
const clones = [...todo].map((entity) => {
|
|
528
|
+
const skip = skipMap.get(entity) ?? [];
|
|
529
|
+
const meta = getMetadata(entity);
|
|
530
|
+
const copy = Object.fromEntries(Object.values(meta.allFields).map((f) => {
|
|
531
|
+
if (skip.includes(f.fieldName)) return void 0;
|
|
532
|
+
switch (f.kind) {
|
|
533
|
+
case "primitive": if (!f.derived && !f.protected) return [f.fieldName, getField(entity, f.fieldName)];
|
|
534
|
+
else return;
|
|
535
|
+
case "enum": if (f.derived) return;
|
|
536
|
+
else return [f.fieldName, getField(entity, f.fieldName)];
|
|
537
|
+
case "m2o":
|
|
538
|
+
case "poly": {
|
|
539
|
+
if (f.kind === "m2o" && f.derived) return void 0;
|
|
540
|
+
const existingIdOrEntity = getField(entity, f.fieldName);
|
|
541
|
+
const target = isEntity(existingIdOrEntity) ? existingIdOrEntity : this.getEntity(existingIdOrEntity);
|
|
542
|
+
if (target && todo.has(target)) {
|
|
543
|
+
deferredRelations.push([
|
|
544
|
+
entity,
|
|
545
|
+
f.fieldName,
|
|
546
|
+
target
|
|
547
|
+
]);
|
|
548
|
+
return [f.fieldName, void 0];
|
|
549
|
+
} else return [f.fieldName, existingIdOrEntity];
|
|
550
|
+
}
|
|
551
|
+
case "primaryKey":
|
|
552
|
+
case "o2m":
|
|
553
|
+
case "m2m":
|
|
554
|
+
case "m2mEnum":
|
|
555
|
+
case "o2o":
|
|
556
|
+
case "lo2m": return;
|
|
557
|
+
default: assertNever(f);
|
|
558
|
+
}
|
|
559
|
+
}).filter(isDefined));
|
|
560
|
+
return [entity, this.create(asConcreteCstr(meta.cstr), copy)];
|
|
561
|
+
});
|
|
562
|
+
const entityToClone = new Map(clones);
|
|
563
|
+
clones.forEach(([, clone]) => {
|
|
564
|
+
getRelationEntries(clone).forEach(([fieldName, value]) => {
|
|
565
|
+
if (value instanceof ManyToOneReferenceImpl || value instanceof PolymorphicReferenceImpl || value instanceof ReactiveReferenceImpl) {
|
|
566
|
+
const existingIdOrEntity = getField(clone, fieldName);
|
|
567
|
+
const existing = isEntity(existingIdOrEntity) ? existingIdOrEntity : this.getEntity(existingIdOrEntity);
|
|
568
|
+
if (existing) clone[fieldName].set(entityToClone.get(existing) ?? existing);
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
deferredRelations.forEach(([source, fieldName, target]) => {
|
|
573
|
+
entityToClone.get(source)[fieldName].set(entityToClone.get(target));
|
|
574
|
+
});
|
|
575
|
+
if (postClone) await Promise.all(clones.map(([original, clone]) => postClone(original, clone)));
|
|
576
|
+
return Array.isArray(entityOrArray) ? entityOrArray.filter((original) => entityToClone.has(original)).map((original) => entityToClone.get(original)) : clones[0] ? clones[0][1] : fail("no entities were cloned given the provided options");
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Merges multiple source entities into a target entity by updating all references that point
|
|
580
|
+
* to the source entities to instead point to the target entity.
|
|
581
|
+
*
|
|
582
|
+
* This method loads all relations from the source entities, updates any entity that
|
|
583
|
+
* references a source entity to reference the target entity instead, and then automatically
|
|
584
|
+
* deletes the source entities.
|
|
585
|
+
*
|
|
586
|
+
* @param target - The entity that will become the target of all merged references
|
|
587
|
+
* @param sources - Array of entities whose references will be redirected to the target
|
|
588
|
+
* @param opts - Options to control merge behavior
|
|
589
|
+
* @param autoDelete - Whether to automatically delete source entities (default: true)
|
|
590
|
+
* @returns Promise that resolves when all references have been updated and sources deleted
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* // Merge duplicate authors - all books pointing to author2 will now point to author1
|
|
594
|
+
* // author2 will be automatically deleted
|
|
595
|
+
* await em.merge(author1, [author2]);
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* // Merge multiple duplicate publishers into one
|
|
599
|
+
* // publisher2 and publisher3 will be automatically deleted
|
|
600
|
+
* await em.merge(publisher1, [publisher2, publisher3]);
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* // Merge without auto-deleting sources (for custom cleanup logic)
|
|
604
|
+
* await em.merge(author1, [author2], { autoDelete: false });
|
|
605
|
+
* // Custom logic here...
|
|
606
|
+
* em.delete(author2);
|
|
607
|
+
*/
|
|
608
|
+
async merge(target, sources, opts) {
|
|
609
|
+
const autoDelete = opts?.autoDelete ?? true;
|
|
610
|
+
if (sources.length === 0) return [];
|
|
611
|
+
this.#merging ??= /* @__PURE__ */ new Set();
|
|
612
|
+
this.#merging.add(target);
|
|
613
|
+
const targetMeta = getMetadata(target);
|
|
614
|
+
for (const source of sources) {
|
|
615
|
+
const sourceMeta = getMetadata(source);
|
|
616
|
+
if (sourceMeta.type !== targetMeta.type) throw new Error(`Cannot merge entities of different types: ${targetMeta.type} and ${sourceMeta.type}`);
|
|
617
|
+
}
|
|
618
|
+
const fields = Object.values(targetMeta.allFields).filter((field) => [
|
|
619
|
+
"o2m",
|
|
620
|
+
"m2o",
|
|
621
|
+
"m2m",
|
|
622
|
+
"o2o"
|
|
623
|
+
].includes(field.kind)).map((field) => field.fieldName);
|
|
624
|
+
await this.populate(sources, fields);
|
|
625
|
+
const changedEntities = [];
|
|
626
|
+
for (const source of sources) for (const field of Object.values(targetMeta.allFields)) {
|
|
627
|
+
const { kind } = field;
|
|
628
|
+
if (kind === "o2m") for (const other of source[field.fieldName].get) {
|
|
629
|
+
this.#merging.add(other);
|
|
630
|
+
other[field.otherFieldName].set(target);
|
|
631
|
+
changedEntities.push(other);
|
|
632
|
+
}
|
|
633
|
+
else if (kind === "o2o") {
|
|
634
|
+
const otherField = field.otherMetadata().allFields[field.otherFieldName];
|
|
635
|
+
if (otherField.kind === "m2o" && otherField.derived) continue;
|
|
636
|
+
const other = source[field.fieldName].get;
|
|
637
|
+
if (other) {
|
|
638
|
+
this.#merging.add(other);
|
|
639
|
+
other[field.otherFieldName].set(target);
|
|
640
|
+
changedEntities.push(other);
|
|
641
|
+
}
|
|
642
|
+
} else if (kind === "m2m") for (const other of source[field.fieldName].get) {
|
|
643
|
+
this.#merging.add(other);
|
|
644
|
+
const collection = other[field.otherFieldName];
|
|
645
|
+
collection.remove(source);
|
|
646
|
+
collection.add(target);
|
|
647
|
+
changedEntities.push(other);
|
|
648
|
+
}
|
|
649
|
+
else if (kind === "primitive" || kind === "primaryKey" || kind === "enum" || kind === "m2mEnum" || kind === "poly" || kind === "m2o" || kind === "lo2m") {} else assertNever(kind);
|
|
650
|
+
}
|
|
651
|
+
if (autoDelete) for (const source of sources) this.delete(source);
|
|
652
|
+
return changedEntities;
|
|
653
|
+
}
|
|
654
|
+
async load(typeOrId, id, hint) {
|
|
655
|
+
let type;
|
|
656
|
+
if (typeof typeOrId === "string") {
|
|
657
|
+
type = getConstructorFromTaggedId(typeOrId);
|
|
658
|
+
id = typeOrId;
|
|
659
|
+
} else {
|
|
660
|
+
type = typeOrId;
|
|
661
|
+
id = id || fail(`Invalid ${typeOrId.name} id: ${id}`);
|
|
662
|
+
}
|
|
663
|
+
const meta = getMetadata(type);
|
|
664
|
+
const taggedId = toTaggedId(meta, id);
|
|
665
|
+
let entity = this.findExistingInstance(taggedId);
|
|
666
|
+
if (!entity) {
|
|
667
|
+
await loadBatchLoader(this, meta).load({
|
|
668
|
+
taggedId,
|
|
669
|
+
hint
|
|
670
|
+
}).catch(function load(err) {
|
|
671
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
672
|
+
});
|
|
673
|
+
entity = this.findExistingInstance(taggedId);
|
|
674
|
+
}
|
|
675
|
+
if (!entity) throw new NotFoundError(`${taggedId} was not found`);
|
|
676
|
+
if (hint) await this.populate(entity, hint);
|
|
677
|
+
if (meta.inheritanceType === "sti" && !(entity instanceof type)) throw new Error(`${entity} is ${entity.constructor.name} but should be ${type.name}`);
|
|
678
|
+
return entity;
|
|
679
|
+
}
|
|
680
|
+
async loadAll(type, _ids, hint) {
|
|
681
|
+
const meta = getMetadata(type);
|
|
682
|
+
const entities = new Array(_ids.length);
|
|
683
|
+
let idsToLoad;
|
|
684
|
+
let positionsToLoad;
|
|
685
|
+
for (let i = 0; i < _ids.length; i++) {
|
|
686
|
+
const id = tagId(meta, _ids[i]);
|
|
687
|
+
const entity = this.findExistingInstance(id);
|
|
688
|
+
if (entity) entities[i] = entity;
|
|
689
|
+
else {
|
|
690
|
+
(idsToLoad ??= []).push(id);
|
|
691
|
+
(positionsToLoad ??= []).push(i);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (idsToLoad) {
|
|
695
|
+
await loadBatchLoader(this, meta).loadAll(idsToLoad.map((id) => ({
|
|
696
|
+
taggedId: id,
|
|
697
|
+
hint
|
|
698
|
+
}))).catch(function loadAll(err) {
|
|
699
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
700
|
+
});
|
|
701
|
+
let idsNotFound;
|
|
702
|
+
for (let j = 0; j < positionsToLoad.length; j++) {
|
|
703
|
+
const entity = this.findExistingInstance(idsToLoad[j]);
|
|
704
|
+
entities[positionsToLoad[j]] = entity;
|
|
705
|
+
if (entity === void 0) (idsNotFound ??= []).push(idsToLoad[j]);
|
|
706
|
+
}
|
|
707
|
+
if (idsNotFound) throw new NotFoundError(`${idsNotFound.join(",")} were not found`);
|
|
708
|
+
}
|
|
709
|
+
const loadedEntities = entities;
|
|
710
|
+
if (hint) await this.populate(loadedEntities, hint);
|
|
711
|
+
if (meta.inheritanceType === "sti" && meta.baseType) {
|
|
712
|
+
const wrongType = loadedEntities.filter((e) => !(e instanceof meta.cstr));
|
|
713
|
+
if (wrongType.length > 0) throw new Error(`${wrongType.join(", ")} were not of type ${meta.cstr.name}`);
|
|
714
|
+
}
|
|
715
|
+
return loadedEntities;
|
|
716
|
+
}
|
|
717
|
+
async loadAllIfExists(type, _ids, hint) {
|
|
718
|
+
const meta = getMetadata(type);
|
|
719
|
+
const maybeEntities = new Array(_ids.length);
|
|
720
|
+
let idsToLoad;
|
|
721
|
+
let positionsToLoad;
|
|
722
|
+
for (let i = 0; i < _ids.length; i++) {
|
|
723
|
+
const id = tagId(meta, _ids[i]);
|
|
724
|
+
const entity = this.findExistingInstance(id);
|
|
725
|
+
if (entity) maybeEntities[i] = entity;
|
|
726
|
+
else {
|
|
727
|
+
(idsToLoad ??= []).push(id);
|
|
728
|
+
(positionsToLoad ??= []).push(i);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
let entities;
|
|
732
|
+
if (idsToLoad) {
|
|
733
|
+
await loadBatchLoader(this, meta).loadAll(idsToLoad.map((id) => ({
|
|
734
|
+
taggedId: id,
|
|
735
|
+
hint
|
|
736
|
+
}))).catch(function loadAllIfExists(err) {
|
|
737
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
738
|
+
});
|
|
739
|
+
for (let j = 0; j < positionsToLoad.length; j++) maybeEntities[positionsToLoad[j]] = this.findExistingInstance(idsToLoad[j]);
|
|
740
|
+
entities = [];
|
|
741
|
+
for (const entity of maybeEntities) if (entity !== void 0) entities.push(entity);
|
|
742
|
+
} else entities = maybeEntities;
|
|
743
|
+
if (hint) await this.populate(entities, hint);
|
|
744
|
+
return entities;
|
|
745
|
+
}
|
|
746
|
+
async loadLens(entities, fn, populate) {
|
|
747
|
+
const result = await loadLens(entities, fn);
|
|
748
|
+
if (populate) await this.populate(result, populate);
|
|
749
|
+
return result;
|
|
750
|
+
}
|
|
751
|
+
loadFromQuery(type, rows, populate) {
|
|
752
|
+
if (Array.isArray(rows)) {
|
|
753
|
+
const entities = this.hydrate(type, rows);
|
|
754
|
+
if (populate) return this.populate(entities, populate);
|
|
755
|
+
return entities;
|
|
756
|
+
} else return rows.then((rows) => {
|
|
757
|
+
const entities = this.hydrate(type, rows);
|
|
758
|
+
if (populate) return this.populate(entities, populate);
|
|
759
|
+
return entities;
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
async loadFromRows(type, rows, populate) {
|
|
763
|
+
const entities = this.hydrate(type, rows);
|
|
764
|
+
if (populate) await this.populate(entities, populate);
|
|
765
|
+
return entities;
|
|
766
|
+
}
|
|
767
|
+
async populate(entityOrList, hintOrOpts, fn) {
|
|
768
|
+
const { hint: hintOpt, ...opts } = typeof hintOrOpts === "object" && "hint" in hintOrOpts ? hintOrOpts : { hint: hintOrOpts };
|
|
769
|
+
opts[AsyncMethodPopulateSecret] = true;
|
|
770
|
+
const list = toArray(entityOrList).filter((e) => {
|
|
771
|
+
return e !== void 0 && !getInstanceData(e).isDeletedAndFlushed;
|
|
772
|
+
});
|
|
773
|
+
if (list.length === 0) return !fn ? entityOrList : fn(entityOrList);
|
|
774
|
+
if (!opts.forceReload && list.every((entity) => !entity.isNewEntity && isLoadedForPopulate(entity, hintOpt))) return fn ? fn(entityOrList) : entityOrList;
|
|
775
|
+
const meta = getMetadata(list[0]);
|
|
776
|
+
if (this.#preloader) {
|
|
777
|
+
const [preload, non] = this.#preloader.partitionHint(meta, hintOpt);
|
|
778
|
+
if (preload) await populateBatchLoader(this, meta, preload, "preload", opts).loadAll(list.map((entity) => ({
|
|
779
|
+
entity,
|
|
780
|
+
hint: preload
|
|
781
|
+
}))).catch(function populate(err) {
|
|
782
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
783
|
+
});
|
|
784
|
+
if (non) await populateBatchLoader(this, meta, non, "intermixed", opts).loadAll(list.map((entity) => ({
|
|
785
|
+
entity,
|
|
786
|
+
hint: non
|
|
787
|
+
}))).catch(function populate(err) {
|
|
788
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
789
|
+
});
|
|
790
|
+
} else await populateBatchLoader(this, meta, hintOpt, "intermixed", opts).loadAll(list.map((entity) => ({
|
|
791
|
+
entity,
|
|
792
|
+
hint: hintOpt
|
|
793
|
+
}))).catch(function populate(err) {
|
|
794
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
795
|
+
});
|
|
796
|
+
return fn ? fn(entityOrList) : entityOrList;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Executes `fn` with a transaction, and automatically calls `flush`/`commit` at the end.
|
|
800
|
+
*
|
|
801
|
+
* This ensures both any `.find` and `.flush` operations happen within the same
|
|
802
|
+
* transaction, which is useful for enforcing cross-table/application-level invariants that
|
|
803
|
+
* cannot be enforced with database-level constraints.
|
|
804
|
+
*/
|
|
805
|
+
async transaction(fn) {
|
|
806
|
+
return this.driver.transaction(this, async (txn) => {
|
|
807
|
+
const result = await fn(txn);
|
|
808
|
+
await this.flush();
|
|
809
|
+
return result;
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
delete(entityOrArray) {
|
|
813
|
+
for (const entity of toArray(entityOrArray)) {
|
|
814
|
+
if (!getInstanceData(entity).markDeleted()) continue;
|
|
815
|
+
this.#hasAnyDeletes = true;
|
|
816
|
+
this.#rm.queueAllDownstreamFields(entity, "deleted");
|
|
817
|
+
getCascadeDeleteRelations(entity).forEach((r) => r.maybeCascadeDelete());
|
|
818
|
+
this.#pendingDeletes.push(entity);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
async assignNewIds() {
|
|
822
|
+
let pendingEntities = this.entities.filter((e) => e.isNewEntity && !e.isDeletedEntity && !e.idTaggedMaybe);
|
|
823
|
+
await this.getLoader("assign-new-ids", "global", async (entities) => {
|
|
824
|
+
let todos = createTodos(entities);
|
|
825
|
+
await this.driver.assignNewIds(this, todos);
|
|
826
|
+
for (const e of entities) this.#entitiesById.set(e.idTagged, e);
|
|
827
|
+
return entities;
|
|
828
|
+
}).loadMany(pendingEntities).catch(function assignNewIds(err) {
|
|
829
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Immediately assigns async defaults to `entities`.
|
|
834
|
+
*
|
|
835
|
+
* Normally async defaults wait until `em.flush` to run, because their async nature requires
|
|
836
|
+
* an `await` / `Promise` to be evaluated, and `em.create` is synchronous.
|
|
837
|
+
*
|
|
838
|
+
* This `assignDefaults` methods like you move that up, and immediately invoke
|
|
839
|
+
* any default logic against the `entities`.
|
|
840
|
+
*/
|
|
841
|
+
async setDefaults(entities) {
|
|
842
|
+
return runInTrustedContext(async () => {
|
|
843
|
+
const suppressedTypeErrors = [];
|
|
844
|
+
const entitiesByType = groupBy(entities.filter((e) => e.isNewEntity), (e) => getMetadata(e));
|
|
845
|
+
await setAsyncDefaults(suppressedTypeErrors, this.ctx, entitiesByType);
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Flushes the SQL for any changed entities to the database.
|
|
850
|
+
*
|
|
851
|
+
* If this is run outside of an existing transaction, it will `BEGIN` and `COMMIT`
|
|
852
|
+
* a new transaction on every `.flush()` call so that all of the `INSERT`s/etc.
|
|
853
|
+
* happen atomically.
|
|
854
|
+
*
|
|
855
|
+
* If this is run within an existing transaction, i.e. `EntityManager.transaction`,
|
|
856
|
+
* then it will only issue `INSERT`s/etc. and defer to the caller to `COMMIT`
|
|
857
|
+
* the transaction.
|
|
858
|
+
*
|
|
859
|
+
* It returns entities that have changed (an entity is considered changed if it has been deleted, inserted, or updated)
|
|
860
|
+
*/
|
|
861
|
+
async flush(flushOptions = {}) {
|
|
862
|
+
return runInTrustedContext(() => this.#flush(flushOptions));
|
|
863
|
+
}
|
|
864
|
+
async #flush(flushOptions = {}) {
|
|
865
|
+
if (this.mode === "read-only") throw new ReadOnlyError();
|
|
866
|
+
const { skipValidation = false } = flushOptions;
|
|
867
|
+
this.#fl.startLock();
|
|
868
|
+
const allFlushedEntities = /* @__PURE__ */ new Set();
|
|
869
|
+
try {
|
|
870
|
+
await this.#fl.allowWrites(async () => {
|
|
871
|
+
await this.flushDeletes();
|
|
872
|
+
await this.#rm.recalcPendingReactables("reactables");
|
|
873
|
+
});
|
|
874
|
+
const createdThenDeleted = /* @__PURE__ */ new Set();
|
|
875
|
+
const hooksInvoked = /* @__PURE__ */ new Set();
|
|
876
|
+
let hookLoops = 0;
|
|
877
|
+
let now = getNow();
|
|
878
|
+
const suppressedDefaultTypeErrors = [];
|
|
879
|
+
const runHooksOnPendingEntities = async () => {
|
|
880
|
+
if (hookLoops++ >= 10) throw new Error("runHooksOnPendingEntities has ran 10 iterations, aborting");
|
|
881
|
+
const pendingLoads = [...getEmInternalApi(this).pendingLoads];
|
|
882
|
+
if (pendingLoads.length > 0) {
|
|
883
|
+
getEmInternalApi(this).pendingLoads.clear();
|
|
884
|
+
await Promise.all(pendingLoads.map((collection) => collection.load()));
|
|
885
|
+
}
|
|
886
|
+
const pendingFlush = /* @__PURE__ */ new Set();
|
|
887
|
+
const pendingHooks = /* @__PURE__ */ new Set();
|
|
888
|
+
const alreadyRanHooks = /* @__PURE__ */ new Set();
|
|
889
|
+
findPendingFlushEntities(this.#maybePendingFlushEntities, hooksInvoked, pendingFlush, pendingHooks, alreadyRanHooks);
|
|
890
|
+
if (alreadyRanHooks.size > 0) maybeBumpUpdatedAt(this.#rm, createTodos(alreadyRanHooks), now);
|
|
891
|
+
while (pendingHooks.size > 0) await this.#fl.allowWrites(async () => {
|
|
892
|
+
let todos = createTodos(pendingHooks);
|
|
893
|
+
await setAsyncDefaults(suppressedDefaultTypeErrors, this.ctx, Todo.groupInsertsByTypeAndSubType(todos));
|
|
894
|
+
maybeBumpUpdatedAt(this.#rm, todos, now);
|
|
895
|
+
for (const group of maybeSetupHookOrdering(todos)) {
|
|
896
|
+
await beforeCreate(this.ctx, group);
|
|
897
|
+
await beforeUpdate(this.ctx, group);
|
|
898
|
+
await beforeFlush(this.ctx, group);
|
|
899
|
+
}
|
|
900
|
+
recalcSynchronousDerivedFields(todos);
|
|
901
|
+
do {
|
|
902
|
+
await this.flushDeletes();
|
|
903
|
+
await this.#rm.recalcPendingReactables("reactables");
|
|
904
|
+
} while (this.#pendingDeletes.length > 0);
|
|
905
|
+
if (this.#rm.hasPendingTypeErrors) {
|
|
906
|
+
await this.#rm.recalcPendingTypeErrors();
|
|
907
|
+
if (this.#rm.needsRecalc("reactables")) await this.#rm.recalcPendingReactables("reactables");
|
|
908
|
+
}
|
|
909
|
+
for (const e of pendingHooks) hooksInvoked.add(e);
|
|
910
|
+
pendingHooks.clear();
|
|
911
|
+
findPendingFlushEntities(this.#maybePendingFlushEntities, hooksInvoked, pendingFlush, pendingHooks, alreadyRanHooks);
|
|
912
|
+
if (pendingHooks.size === 0 && this.#rm.hasPendingTypeErrors) await this.#rm.recalcPendingTypeErrors();
|
|
913
|
+
});
|
|
914
|
+
return [...pendingFlush].filter((e) => {
|
|
915
|
+
const createThenDelete = e.isDeletedEntity && e.isNewEntity;
|
|
916
|
+
if (createThenDelete) createdThenDeleted.add(e);
|
|
917
|
+
return !createThenDelete;
|
|
918
|
+
});
|
|
919
|
+
};
|
|
920
|
+
const { pluginManager } = getEmInternalApi(this);
|
|
921
|
+
const runValidation = async (entityTodos, joinRowTodos, validate) => {
|
|
922
|
+
const changedEntities = entitiesFromTodos(entityTodos, joinRowTodos);
|
|
923
|
+
try {
|
|
924
|
+
this.#isValidating = true;
|
|
925
|
+
await pluginManager.beforeValidate(changedEntities);
|
|
926
|
+
if (validate) {
|
|
927
|
+
this.#findRestricted = true;
|
|
928
|
+
try {
|
|
929
|
+
await validateSimpleRules(entityTodos);
|
|
930
|
+
if (suppressedDefaultTypeErrors.length > 0) throw suppressedDefaultTypeErrors[0];
|
|
931
|
+
await validateReactiveRules(this, this.#rm.logger, entityTodos, joinRowTodos);
|
|
932
|
+
} finally {
|
|
933
|
+
this.#findRestricted = false;
|
|
934
|
+
}
|
|
935
|
+
await afterValidation(this.ctx, entityTodos);
|
|
936
|
+
}
|
|
937
|
+
await pluginManager.afterValidate(changedEntities);
|
|
938
|
+
} finally {
|
|
939
|
+
this.#isValidating = false;
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
const runCommitValidation = async (entityTodos, joinRowTodos) => {
|
|
943
|
+
this.#dataloaders = {};
|
|
944
|
+
this.#batchLoaders = {};
|
|
945
|
+
this.#preloadedRelations = /* @__PURE__ */ new Map();
|
|
946
|
+
try {
|
|
947
|
+
this.#isValidating = true;
|
|
948
|
+
await validateSimpleRules(entityTodos, (config) => config.commitRules);
|
|
949
|
+
await validateReactiveRules(this, this.#rm.logger, entityTodos, joinRowTodos, (meta) => meta.reactiveCommitRules);
|
|
950
|
+
} finally {
|
|
951
|
+
this.#isValidating = false;
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
const commitRuleTodos = {};
|
|
955
|
+
const commitRuleJoinRowTodos = {};
|
|
956
|
+
const commitRuleSeen = /* @__PURE__ */ new Set();
|
|
957
|
+
function collectCommitRuleTodos(entityTodos, joinRowTodos) {
|
|
958
|
+
if (skipValidation) return;
|
|
959
|
+
for (const todo of Object.values(entityTodos)) {
|
|
960
|
+
if (!todo.metadata.hasCommitRules) continue;
|
|
961
|
+
for (const key of [
|
|
962
|
+
"inserts",
|
|
963
|
+
"updates",
|
|
964
|
+
"deletes"
|
|
965
|
+
]) for (const e of todo[key]) if (!commitRuleSeen.has(e)) {
|
|
966
|
+
commitRuleSeen.add(e);
|
|
967
|
+
getTodo(commitRuleTodos, e)[key].push(e);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
for (const [table, todo] of Object.entries(joinRowTodos)) {
|
|
971
|
+
if (!todo.m2m.meta.hasCommitRules && !todo.m2m.otherMeta?.hasCommitRules) continue;
|
|
972
|
+
const into = commitRuleJoinRowTodos[table] ??= {
|
|
973
|
+
...todo,
|
|
974
|
+
newRows: [],
|
|
975
|
+
deletedRows: []
|
|
976
|
+
};
|
|
977
|
+
for (const key of ["newRows", "deletedRows"]) for (const r of todo[key]) if (!commitRuleSeen.has(r)) {
|
|
978
|
+
commitRuleSeen.add(r);
|
|
979
|
+
into[key].push(r);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
let entitiesToFlush = await runHooksOnPendingEntities();
|
|
984
|
+
for (const e of entitiesToFlush) allFlushedEntities.add(e);
|
|
985
|
+
let entityTodos = createTodos(entitiesToFlush);
|
|
986
|
+
let joinRowTodos = combineJoinRows(this.#joinRows);
|
|
987
|
+
await runValidation(entityTodos, joinRowTodos, !skipValidation);
|
|
988
|
+
this.#rm.throwIfAnySuppressedTypeErrors();
|
|
989
|
+
if (suppressedDefaultTypeErrors.length > 0) throw suppressedDefaultTypeErrors[0];
|
|
990
|
+
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0) {
|
|
991
|
+
await this.driver.transaction(this, async () => {
|
|
992
|
+
do {
|
|
993
|
+
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0) {
|
|
994
|
+
await this.driver.flush(this, entityTodos, joinRowTodos);
|
|
995
|
+
collectCommitRuleTodos(entityTodos, joinRowTodos);
|
|
996
|
+
}
|
|
997
|
+
pluginManager.afterWrite(entityTodos, joinRowTodos);
|
|
998
|
+
if (this.#rm.hasPendingReactiveQueries()) {
|
|
999
|
+
for (const e of entitiesToFlush) {
|
|
1000
|
+
if (e.isNewEntity && !e.isDeletedEntity) this.#entitiesById.set(e.idTagged, e);
|
|
1001
|
+
getInstanceData(e).resetForRqfLoop();
|
|
1002
|
+
}
|
|
1003
|
+
await this.#fl.allowWrites(async () => {
|
|
1004
|
+
await this.#rm.recalcPendingReactables("reactiveQueries");
|
|
1005
|
+
await this.#rm.recalcPendingReactables("reactables");
|
|
1006
|
+
});
|
|
1007
|
+
now = getNow();
|
|
1008
|
+
entitiesToFlush = await runHooksOnPendingEntities();
|
|
1009
|
+
for (const e of entitiesToFlush) allFlushedEntities.add(e);
|
|
1010
|
+
entityTodos = createTodos(entitiesToFlush);
|
|
1011
|
+
joinRowTodos = combineJoinRows(this.#joinRows);
|
|
1012
|
+
await runValidation(entityTodos, joinRowTodos, true);
|
|
1013
|
+
this.#rm.throwIfAnySuppressedTypeErrors();
|
|
1014
|
+
} else entityTodos = {};
|
|
1015
|
+
} while (Object.keys(entityTodos).length > 0);
|
|
1016
|
+
if (Object.keys(commitRuleTodos).length > 0 || Object.keys(commitRuleJoinRowTodos).length > 0) {
|
|
1017
|
+
for (const e of allFlushedEntities) if (e.isNewEntity && !e.isDeletedEntity) this.#entitiesById.set(e.idTagged, e);
|
|
1018
|
+
await runCommitValidation(commitRuleTodos, commitRuleJoinRowTodos);
|
|
1019
|
+
}
|
|
1020
|
+
await beforeCommit(this.ctx, allFlushedEntities);
|
|
1021
|
+
if (this.mode === "in-memory-writes") throw new InMemoryRollbackError();
|
|
1022
|
+
});
|
|
1023
|
+
await afterCommit(this.ctx, allFlushedEntities);
|
|
1024
|
+
for (const e of allFlushedEntities) {
|
|
1025
|
+
const instanceData = getInstanceData(e);
|
|
1026
|
+
if (e.isNewEntity && !e.isDeletedEntity) this.#entitiesById.set(e.idTagged, e);
|
|
1027
|
+
instanceData.resetAfterFlushed();
|
|
1028
|
+
const { relations } = instanceData;
|
|
1029
|
+
if (relations) {
|
|
1030
|
+
for (const rel of Object.values(relations)) if (rel instanceof AsyncPropertyImpl || rel instanceof LazyFieldImpl) rel.resetAfterFlush();
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
for (const joinRow of Object.values(joinRowTodos)) joinRow.resetAfterFlushed();
|
|
1034
|
+
const { mutatedCollections } = getEmInternalApi(this);
|
|
1035
|
+
for (const o2m of mutatedCollections.values()) o2m.resetAddedRemoved();
|
|
1036
|
+
mutatedCollections.clear();
|
|
1037
|
+
this.#dataloaders = {};
|
|
1038
|
+
this.#batchLoaders = {};
|
|
1039
|
+
this.#preloadedRelations = /* @__PURE__ */ new Map();
|
|
1040
|
+
this.#rm.clear();
|
|
1041
|
+
}
|
|
1042
|
+
for (const e of createdThenDeleted) getInstanceData(e).fixupCreatedThenDeleted();
|
|
1043
|
+
this.#merging?.clear();
|
|
1044
|
+
return [...allFlushedEntities].sort((a, b) => getInstanceData(a).entityIndex - getInstanceData(b).entityIndex);
|
|
1045
|
+
} catch (e) {
|
|
1046
|
+
if (e instanceof RecursiveCycleError) {
|
|
1047
|
+
const entity = e.entities[0];
|
|
1048
|
+
for (const meta of getBaseAndSelfMetas(getMetadata(entity))) {
|
|
1049
|
+
const messageFn = meta.config.__data.cycleMessages[e.fieldName] ?? meta.config.__data.cycleMessages[entity[e.fieldName]?.otherFieldName];
|
|
1050
|
+
if (messageFn) throw new ValidationErrors([{
|
|
1051
|
+
entity,
|
|
1052
|
+
message: messageFn(entity, e.entities)
|
|
1053
|
+
}]);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
const detail = e && typeof e === "object" && "detail" in e && typeof e.detail === "string" ? e.detail : void 0;
|
|
1057
|
+
if (e && typeof e === "object" && "constraint" in e && typeof e.constraint === "string") {
|
|
1058
|
+
const message = constraintNameToValidationError[e.constraint];
|
|
1059
|
+
if (message) {
|
|
1060
|
+
const errors = new ValidationErrors(message);
|
|
1061
|
+
if (detail) errors.message = `${message} — ${detail}`;
|
|
1062
|
+
throw errors;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
if (e instanceof InMemoryRollbackError) return [...allFlushedEntities].sort((a, b) => getInstanceData(a).entityIndex - getInstanceData(b).entityIndex);
|
|
1066
|
+
if (detail && e instanceof Error) e.message = `${e.message} — ${detail}`;
|
|
1067
|
+
throw e;
|
|
1068
|
+
} finally {
|
|
1069
|
+
this.#rm.clearSuppressedTypeErrors();
|
|
1070
|
+
this.#fl.releaseLock();
|
|
1071
|
+
resetFactoryCreated();
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* A very simple toJSON.
|
|
1076
|
+
*
|
|
1077
|
+
* This is not really meant to be useful, it's to prevent huge/circular output if
|
|
1078
|
+
* an EntityManager accidentally ends up getting logged to something like pino that
|
|
1079
|
+
* over-zealous toJSONs anything it touches.
|
|
1080
|
+
*/
|
|
1081
|
+
toJSON() {
|
|
1082
|
+
return `<EntityManager ${this.entities.length}>`;
|
|
1083
|
+
}
|
|
1084
|
+
async refresh(param) {
|
|
1085
|
+
this.#isRefreshing = true;
|
|
1086
|
+
this.#dataloaders = {};
|
|
1087
|
+
this.#batchLoaders = {};
|
|
1088
|
+
this.#preloadedRelations = /* @__PURE__ */ new Map();
|
|
1089
|
+
const deepLoad = param && "deepLoad" in param && param.deepLoad;
|
|
1090
|
+
let todo = param === void 0 ? this.#entitiesArray : Array.isArray(param) ? param : isEntity(param) ? [param] : this.#entitiesArray;
|
|
1091
|
+
const done = /* @__PURE__ */ new Set();
|
|
1092
|
+
while (todo.length > 0) {
|
|
1093
|
+
const copy = [...todo];
|
|
1094
|
+
copy.forEach((e) => done.add(e));
|
|
1095
|
+
todo = [];
|
|
1096
|
+
const entitiesToRefresh = copy.filter((e) => e.idTaggedMaybe && !e.isDeletedEntity);
|
|
1097
|
+
await Promise.all(entitiesToRefresh.map((entity) => {
|
|
1098
|
+
const hint = getRelationEntries(entity).filter(([_, r]) => deepLoad || r.isLoaded).map(([k]) => k);
|
|
1099
|
+
return loadBatchLoader(this, getMetadata(entity), true).load({
|
|
1100
|
+
taggedId: entity.idTagged,
|
|
1101
|
+
hint
|
|
1102
|
+
}).catch(function refresh(err) {
|
|
1103
|
+
throw appendStack(err, /* @__PURE__ */ new Error());
|
|
1104
|
+
});
|
|
1105
|
+
}));
|
|
1106
|
+
const [custom, builtin] = partition(entitiesToRefresh.filter((e) => !getInstanceData(e).isDeletedEntity).flatMap((entity) => getRelations(entity).filter((r) => deepLoad || r.isLoaded)), isCustomRelation);
|
|
1107
|
+
await Promise.all(builtin.map((r) => {
|
|
1108
|
+
if (r.isPreloaded && !r.isLoaded) {
|
|
1109
|
+
r.preload();
|
|
1110
|
+
return;
|
|
1111
|
+
} else return r.load({ forceReload: true });
|
|
1112
|
+
}));
|
|
1113
|
+
await Promise.all(custom.map((r) => r.load({ forceReload: true })));
|
|
1114
|
+
if (deepLoad) todo.push(...builtin.filter((r) => "get" in r).map((r) => r.get).flatMap((value) => Array.isArray(value) ? value : [value]).filter((value) => isEntity(value) && !done.has(value)));
|
|
1115
|
+
}
|
|
1116
|
+
this.#isRefreshing = false;
|
|
1117
|
+
}
|
|
1118
|
+
get numberOfEntities() {
|
|
1119
|
+
return this.entities.length;
|
|
1120
|
+
}
|
|
1121
|
+
findExistingInstance(id) {
|
|
1122
|
+
return this.#entitiesById.get(id);
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Takes a result `row` from a custom query and maps the db values into a new-or-existing domain object for that row.
|
|
1126
|
+
*
|
|
1127
|
+
* The `overwriteExisting` controls whether `row`'s values should overwrite the existing fields on
|
|
1128
|
+
* an entity. By default this is true, as we assume the user calling this means they know the DB has
|
|
1129
|
+
* updated values that should be put into the entities. A few internal callers set this to false,
|
|
1130
|
+
* i.e. when we're loading collections and have db results that are potentially stale compared to
|
|
1131
|
+
* the WIP entity state.
|
|
1132
|
+
*/
|
|
1133
|
+
hydrate(type, rows, options) {
|
|
1134
|
+
return this.hydrateFromRowData(type, new PojoRowData(rows), options);
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Hydrates a query's `RowData`, running any sidecar reads, and always `finalize`s the result.
|
|
1138
|
+
*
|
|
1139
|
+
* This is the internal API for Joist's find/load loaders: `sidecars` is where reads of
|
|
1140
|
+
* non-entity columns (preload aggregates, `_tags`, found-id checks) belong — they must run
|
|
1141
|
+
* before `finalize`, because compaction drops unretained rows — and the `try/finally`
|
|
1142
|
+
* guarantees a failed hydration or sidecar read still releases the result's unretained
|
|
1143
|
+
* buffers instead of pinning them.
|
|
1144
|
+
*/
|
|
1145
|
+
hydrateAndFinalize(type, rowData, opts) {
|
|
1146
|
+
try {
|
|
1147
|
+
const entities = this.hydrateFromRowData(type, rowData, opts);
|
|
1148
|
+
opts?.sidecars?.(entities);
|
|
1149
|
+
return entities;
|
|
1150
|
+
} finally {
|
|
1151
|
+
rowData.finalize?.();
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* Like {@link hydrate}, but reads rows from a {@link RowData}, i.e. a driver-produced
|
|
1156
|
+
* lazy query result, instead of an array of POJO rows.
|
|
1157
|
+
*
|
|
1158
|
+
* This is an internal API used by Joist's own find loaders (usually via
|
|
1159
|
+
* {@link hydrateAndFinalize}); rows whose entities are kept (newly created or
|
|
1160
|
+
* overwrite-refreshed) are `retain`-ed on the `RowData` so the caller can later `finalize`
|
|
1161
|
+
* (trim/compact) the result.
|
|
1162
|
+
*/
|
|
1163
|
+
hydrateFromRowData(type, rowData, options) {
|
|
1164
|
+
const maybeBaseMeta = getMetadata(type);
|
|
1165
|
+
const overwriteExisting = options?.overwriteExisting === true;
|
|
1166
|
+
const count = rowData.rowCount;
|
|
1167
|
+
const entities = new Array(count);
|
|
1168
|
+
for (let i = 0; i < count; i++) {
|
|
1169
|
+
const id = rowData.get(i, "id");
|
|
1170
|
+
const taggedId = id === void 0 || id === null ? fail("No id column was available") : keyToTaggedId(maybeBaseMeta, id);
|
|
1171
|
+
let entity = this.findExistingInstance(taggedId);
|
|
1172
|
+
if (!entity) {
|
|
1173
|
+
const meta = findConcreteMeta(maybeBaseMeta, rowData, i);
|
|
1174
|
+
entity = newEntity(this, asConcreteCstr(meta.cstr), false);
|
|
1175
|
+
const instanceData = getInstanceData(entity);
|
|
1176
|
+
instanceData.rowData = rowData;
|
|
1177
|
+
instanceData.rowIndex = i;
|
|
1178
|
+
rowData.retain?.(i);
|
|
1179
|
+
instanceData.data["id"] = taggedId;
|
|
1180
|
+
this.#doRegister(entity, taggedId, meta, true);
|
|
1181
|
+
} else if (overwriteExisting) {
|
|
1182
|
+
const instanceData = getInstanceData(entity);
|
|
1183
|
+
instanceData.rowData = rowData;
|
|
1184
|
+
instanceData.rowIndex = i;
|
|
1185
|
+
rowData.retain?.(i);
|
|
1186
|
+
const { data } = instanceData;
|
|
1187
|
+
const dataKeys = Object.keys(data);
|
|
1188
|
+
if (dataKeys.length > ("id" in data ? 1 : 0)) {
|
|
1189
|
+
const allFields = getMetadata(entity).allFields;
|
|
1190
|
+
const changedFields = instanceData.isNewEntity ? entity.changes.fieldsWithoutRelations : Object.keys(instanceData.originalData);
|
|
1191
|
+
for (const fieldName of dataKeys) {
|
|
1192
|
+
if (fieldName === "id") continue;
|
|
1193
|
+
data[fieldName] = (allFields[fieldName].serde ?? fail(`Missing serde for ${fieldName}`)).fromRow(rowData, i);
|
|
1194
|
+
if (changedFields.includes(fieldName)) instanceData.markFieldClean(fieldName);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
entities[i] = entity;
|
|
1199
|
+
}
|
|
1200
|
+
return entities;
|
|
1201
|
+
}
|
|
1202
|
+
touch(entityOrEntities) {
|
|
1203
|
+
for (const entity of toArray(entityOrEntities)) getInstanceData(entity).markTouched();
|
|
1204
|
+
}
|
|
1205
|
+
async recalc(entityOrEntities, reactionName) {
|
|
1206
|
+
const entities = toArray(entityOrEntities).filter((entity) => !entity.isDeletedEntity);
|
|
1207
|
+
if (reactionName !== void 0) {
|
|
1208
|
+
const reactions = entities.map((entity) => {
|
|
1209
|
+
return getBaseAndSelfMetas(getMetadata(entity)).flatMap((meta) => meta.config.__data.reactions).find((reaction) => reaction.name === reactionName) ?? fail(`Reaction '${reactionName}' not found on ${getMetadata(entity).type}`);
|
|
1210
|
+
});
|
|
1211
|
+
await runInTrustedContext(() => Promise.allSettled(reactions.map((reaction, i) => reaction.fn(entities[i], this.ctx))).then(failIfAnyRejected));
|
|
1212
|
+
await this.#rm.recalcPendingReactables("reactables");
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
const relations = entities.flatMap((entity) => Object.values(getMetadata(entity).allFields).filter((f) => "derived" in f && f.derived === "async").map((field) => entity[field.fieldName]));
|
|
1216
|
+
const results = await Promise.allSettled(relations.map((r) => r.load({ forceReload: true })));
|
|
1217
|
+
const relationsPendingAssignedIds = [];
|
|
1218
|
+
const failures = [];
|
|
1219
|
+
results.forEach((result, i) => {
|
|
1220
|
+
if (result.status === "rejected") {
|
|
1221
|
+
if (result.reason instanceof NoIdError) relationsPendingAssignedIds.push(relations[i]);
|
|
1222
|
+
else failures.push(result.reason);
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
if (relationsPendingAssignedIds.length > 0) {
|
|
1226
|
+
await this.assignNewIds();
|
|
1227
|
+
(await Promise.allSettled(relationsPendingAssignedIds.map((r) => r.load({ forceReload: true })))).forEach((result) => {
|
|
1228
|
+
if (result.status === "rejected") failures.push(result.reason);
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
if (failures.length > 0) throw failures[0];
|
|
1232
|
+
entities.flatMap((entity) => Object.values(getMetadata(entity).allFields).filter((f) => "derived" in f && f.derived === "sync").forEach((field) => {
|
|
1233
|
+
setField(entity, field.fieldName, entity[field.fieldName]);
|
|
1234
|
+
}));
|
|
1235
|
+
await this.#rm.recalcPendingReactables("reactables");
|
|
1236
|
+
}
|
|
1237
|
+
beforeBegin(fn) {
|
|
1238
|
+
this.#hooks.beforeBegin.push(fn);
|
|
1239
|
+
}
|
|
1240
|
+
afterBegin(fn) {
|
|
1241
|
+
this.#hooks.afterBegin.push(fn);
|
|
1242
|
+
}
|
|
1243
|
+
beforeCommit(fn) {
|
|
1244
|
+
this.#hooks.beforeCommit.push(fn);
|
|
1245
|
+
}
|
|
1246
|
+
afterCommit(fn) {
|
|
1247
|
+
this.#hooks.afterCommit.push(fn);
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Returns an EntityManager-scoped (i.e. request scoped) data loader.
|
|
1251
|
+
*
|
|
1252
|
+
* @param operation the operation being batched, i.e. `load` or `o2m-load`, to avoid clashing batch keys
|
|
1253
|
+
* across fundamentally different operations
|
|
1254
|
+
* @param batchKey for a given operation, i.e. `load`, a batch key `Author` to batch all Author loads together
|
|
1255
|
+
* @param fn the batch load function, i.e. that will accept all `.load(...)`-d Author ids to load as a single db call
|
|
1256
|
+
* @param opts optional DataLoader options
|
|
1257
|
+
* @returns a DataLoader scoped to the `operation` + `batchKey` combination
|
|
1258
|
+
*/
|
|
1259
|
+
getLoader(operation, batchKey, fn, opts) {
|
|
1260
|
+
const loadersForKind = this.#dataloaders[operation] ??= {};
|
|
1261
|
+
return getOrSet(loadersForKind, batchKey, () => new DataLoader(fn, opts));
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Like `getLoader`, but returns a `BatchLoader` where all callers in the same tick
|
|
1265
|
+
* share a single `Promise<void>` instead of getting per-key promises.
|
|
1266
|
+
*
|
|
1267
|
+
* The batch function should write results via side channels (e.g. `setPreloadedRelation`).
|
|
1268
|
+
*/
|
|
1269
|
+
getBatchLoader(operation, batchKey, fn) {
|
|
1270
|
+
const loadersForKind = this.#batchLoaders[operation] ??= {};
|
|
1271
|
+
return getOrSet(loadersForKind, batchKey, () => new BatchLoader(fn));
|
|
1272
|
+
}
|
|
1273
|
+
toString() {
|
|
1274
|
+
return "EntityManager";
|
|
1275
|
+
}
|
|
1276
|
+
/** Recursively cascades any pending deletions. */
|
|
1277
|
+
async flushDeletes() {
|
|
1278
|
+
let entities = this.#pendingDeletes;
|
|
1279
|
+
if (entities.length === 0) return;
|
|
1280
|
+
this.#pendingDeletes = [];
|
|
1281
|
+
let relationsToCleanup = [];
|
|
1282
|
+
while (entities.length > 0) {
|
|
1283
|
+
const p = entities.flatMap(getCascadeDeleteRelations).map((r) => r.load().then(() => r.maybeCascadeDelete()));
|
|
1284
|
+
await Promise.all(p);
|
|
1285
|
+
const todos = createTodos(entities);
|
|
1286
|
+
await beforeDelete(this.ctx, todos);
|
|
1287
|
+
for (const entity of entities) {
|
|
1288
|
+
const relations = getRelations(entity);
|
|
1289
|
+
const start = relationsToCleanup.length;
|
|
1290
|
+
relationsToCleanup.length += relations.length;
|
|
1291
|
+
for (let i = 0; i < relations.length; i++) relationsToCleanup[start + i] = relations[i];
|
|
1292
|
+
}
|
|
1293
|
+
entities = this.#pendingDeletes;
|
|
1294
|
+
this.#pendingDeletes = [];
|
|
1295
|
+
}
|
|
1296
|
+
await Promise.all(relationsToCleanup.map((r) => r.cleanupOnEntityDeleted()));
|
|
1297
|
+
}
|
|
1298
|
+
setReactionLogging(arg) {
|
|
1299
|
+
this.#rm.setLogger(typeof arg === "boolean" ? arg ? new ReactionLogger() : void 0 : arg);
|
|
1300
|
+
}
|
|
1301
|
+
setFieldLogging(arg) {
|
|
1302
|
+
if (arg instanceof FieldLogger) {
|
|
1303
|
+
this.#fieldLogger = arg;
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
const writeFn = getDefaultWriteFn(this.ctx);
|
|
1307
|
+
if (typeof arg === "boolean") this.#fieldLogger = arg ? new FieldLogger([], writeFn) : noopFieldLogger;
|
|
1308
|
+
else if (typeof arg === "string" || Array.isArray(arg)) {
|
|
1309
|
+
const watching = (Array.isArray(arg) ? arg : [arg]).map((spec) => {
|
|
1310
|
+
const [_, entity, fields, breakpoint] = spec.match(/^([^.!]+)(?:\.([^!]*))?(!)?$/) ?? fail(`Unsupported spec ${spec}`);
|
|
1311
|
+
const fieldNames = fields?.split(",");
|
|
1312
|
+
const meta = getMetadataForType(entity);
|
|
1313
|
+
fieldNames?.forEach((field) => {
|
|
1314
|
+
if (!meta.allFields[field]) throw new Error(`Field ${field} not found on ${entity}`);
|
|
1315
|
+
});
|
|
1316
|
+
return {
|
|
1317
|
+
entity,
|
|
1318
|
+
fieldNames,
|
|
1319
|
+
breakpoint: !!breakpoint
|
|
1320
|
+
};
|
|
1321
|
+
});
|
|
1322
|
+
this.#fieldLogger = new FieldLogger(watching, writeFn);
|
|
1323
|
+
} else throw new Error("Unsupported override for setFieldLogging");
|
|
1324
|
+
}
|
|
1325
|
+
async [Symbol.asyncDispose]() {
|
|
1326
|
+
await this.flush();
|
|
1327
|
+
}
|
|
1328
|
+
/** Returns entities matching the filter using indexed search when available. */
|
|
1329
|
+
filterEntities(cstr, where) {
|
|
1330
|
+
const meta = getMetadata(cstr);
|
|
1331
|
+
const entities = this.#entitiesByTag.get(meta.tagName) ?? [];
|
|
1332
|
+
if (!hasAnyKey(where)) return entities.filter((e) => e instanceof cstr && !e.isDeletedEntity);
|
|
1333
|
+
if (this.#indexManager.shouldIndexType(entities.length)) {
|
|
1334
|
+
this.#indexManager.enableIndexingForType(meta, entities, where);
|
|
1335
|
+
const result = [];
|
|
1336
|
+
for (const e of this.#indexManager.findMatching(meta, entities, where)) if (e instanceof cstr && !e.isDeletedEntity) result.push(e);
|
|
1337
|
+
return result;
|
|
1338
|
+
} else return entities.filter((e) => e instanceof cstr && !e.isDeletedEntity && entityMatches(e, where));
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Creates a new EntityManager that shares the same entities as the current one but allows independent changes.
|
|
1342
|
+
*
|
|
1343
|
+
* This is useful for scenarios where you want to:
|
|
1344
|
+
*
|
|
1345
|
+
* - Preload data for use as a cache
|
|
1346
|
+
* - Make speculative changes that may or may not be committed
|
|
1347
|
+
* - Escape a transaction scope
|
|
1348
|
+
*
|
|
1349
|
+
* The fork will:
|
|
1350
|
+
*
|
|
1351
|
+
* - Copy all currently loaded entities to the new EntityManager
|
|
1352
|
+
* - Copy any loaded relation data to keep `.isLoaded` / `.get` state consistent
|
|
1353
|
+
* - Copy and update references to the EntityManager and its entities in the context, which is itself shallowly copied
|
|
1354
|
+
*
|
|
1355
|
+
* The fork will NOT:
|
|
1356
|
+
*
|
|
1357
|
+
* - Copy any pending changes (must call .flush() first)
|
|
1358
|
+
* - Share any changes made in either EntityManager with the other
|
|
1359
|
+
*
|
|
1360
|
+
* @param opts options to control the fork behavior
|
|
1361
|
+
* - allowPendingChanges - allows the em being forked to have pending changes and forces the resulting em to have
|
|
1362
|
+
* `mode` set to "in-memory-writes". Changes to entities in the original em will be copied to the resulting em.
|
|
1363
|
+
* Optional. default: false
|
|
1364
|
+
*
|
|
1365
|
+
* @throws {Error} If called on an EntityManager with pending changes
|
|
1366
|
+
* @returns A new EntityManager with copied entity state
|
|
1367
|
+
*/
|
|
1368
|
+
fork(opts = {}) {
|
|
1369
|
+
const { allowPendingChanges = false } = opts;
|
|
1370
|
+
const oldEm = this;
|
|
1371
|
+
const ctx = { ...oldEm.ctx };
|
|
1372
|
+
const newEm = new EntityManager(ctx, { em: oldEm });
|
|
1373
|
+
if (allowPendingChanges) newEm.mode = "in-memory-writes";
|
|
1374
|
+
for (const [tag, entities] of oldEm.#entitiesByTag.entries()) {
|
|
1375
|
+
const baseCstr = getConstructorFromTag(tag);
|
|
1376
|
+
let rows = new Array(entities.length);
|
|
1377
|
+
let i = 0;
|
|
1378
|
+
for (const entity of entities) {
|
|
1379
|
+
const instanceData = entity.__data;
|
|
1380
|
+
if (!allowPendingChanges && instanceData.pendingOperation !== "none") fail("Cannot fork an EntityManager with pending changes");
|
|
1381
|
+
else if (instanceData.isNewEntity) newEm.create(entity.constructor, {});
|
|
1382
|
+
else {
|
|
1383
|
+
rows[i] = createRowFromEntityData(entity);
|
|
1384
|
+
i++;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
if (rows.length !== i) rows = rows.slice(0, i);
|
|
1388
|
+
newEm.hydrate(baseCstr, rows);
|
|
1389
|
+
}
|
|
1390
|
+
function mapEntity(oldEntity) {
|
|
1391
|
+
if (oldEntity.isNewEntity) return newEm.#entitiesById.get(oldEntity.toTaggedString());
|
|
1392
|
+
else return newEm.#entitiesById.get(oldEntity.idTagged);
|
|
1393
|
+
}
|
|
1394
|
+
function mapEntities(v) {
|
|
1395
|
+
if (v === void 0) return void 0;
|
|
1396
|
+
const result = new Array(v.length);
|
|
1397
|
+
for (let i = 0; i < v.length; i++) result[i] = mapEntity(v[i]);
|
|
1398
|
+
return result;
|
|
1399
|
+
}
|
|
1400
|
+
if (allowPendingChanges) for (const oldEntity of oldEm.entities) {
|
|
1401
|
+
const oldInstanceData = oldEntity.__data;
|
|
1402
|
+
if (!(oldInstanceData.isNewEntity || oldInstanceData.isDirtyEntity)) continue;
|
|
1403
|
+
const { originalData: oldOriginalData, data: oldData } = oldInstanceData;
|
|
1404
|
+
const newInstanceData = mapEntity(oldEntity).__data;
|
|
1405
|
+
const { data: newData } = newInstanceData;
|
|
1406
|
+
const maybeEntity = (value) => isEntity(value) ? mapEntity(value) : value;
|
|
1407
|
+
const fields = Object.keys(oldEntity.isNewEntity ? oldData : oldOriginalData);
|
|
1408
|
+
for (const field of fields) {
|
|
1409
|
+
if (field in oldOriginalData) newInstanceData.markFieldDirty(field, maybeEntity(oldOriginalData[field]));
|
|
1410
|
+
newData[field] = maybeEntity(oldData[field]);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
for (const oldEntity of oldEm.entities) {
|
|
1414
|
+
const newEntity = mapEntity(oldEntity);
|
|
1415
|
+
if (oldEntity.isDeletedEntity) {
|
|
1416
|
+
newEntity.__data.markDeleted();
|
|
1417
|
+
continue;
|
|
1418
|
+
}
|
|
1419
|
+
const { relations } = oldEntity.__data;
|
|
1420
|
+
if (!relations) continue;
|
|
1421
|
+
for (const [field, relation] of Object.entries(relations)) {
|
|
1422
|
+
if (!("import" in relation)) continue;
|
|
1423
|
+
if (oldEntity.isNewEntity) {
|
|
1424
|
+
const oldValue = relation.get;
|
|
1425
|
+
if (oldValue === void 0) continue;
|
|
1426
|
+
if (Array.isArray(oldValue) && oldValue.length === 0) continue;
|
|
1427
|
+
const newValue = Array.isArray(oldValue) ? mapEntities(oldValue) : mapEntity(oldValue);
|
|
1428
|
+
delete newEntity.__data.data[field];
|
|
1429
|
+
newEntity[field].setFromOpts(newValue);
|
|
1430
|
+
} else if ("_isLoaded" in relation ? relation._isLoaded : relation.isLoaded) newEntity[field].import(relation, mapEntity, mapEntities);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
for (const [key, value] of Object.entries(ctx)) if (isEntity(value) && value.em === oldEm) ctx[key] = mapEntity(value);
|
|
1434
|
+
else if (value === oldEm) ctx[key] = newEm;
|
|
1435
|
+
return newEm;
|
|
1436
|
+
}
|
|
1437
|
+
importEntity(source, hint, normalizedHint) {
|
|
1438
|
+
if (source.isNewEntity) fail("cannot import new entities");
|
|
1439
|
+
if (source.isDeletedEntity) fail("cannot import deleted entities");
|
|
1440
|
+
if (source.isDirtyEntity) fail("cannot import dirty entities");
|
|
1441
|
+
hint ??= {};
|
|
1442
|
+
if (!normalizedHint) {
|
|
1443
|
+
assertLoaded(source, hint);
|
|
1444
|
+
normalizedHint = deepNormalizeHint(hint);
|
|
1445
|
+
}
|
|
1446
|
+
if (source.em === this) return source;
|
|
1447
|
+
const meta = getMetadata(source);
|
|
1448
|
+
let result = this.#entitiesById.get(source.idTagged);
|
|
1449
|
+
if (!result) {
|
|
1450
|
+
const meta = getMetadata(source);
|
|
1451
|
+
const row = createRowFromEntityData(source);
|
|
1452
|
+
result = this.hydrate(getBaseMeta(meta).cstr, [row])[0];
|
|
1453
|
+
}
|
|
1454
|
+
for (const [fieldName, subHint] of Object.entries(normalizedHint)) {
|
|
1455
|
+
const field = meta.allFields[fieldName];
|
|
1456
|
+
const relationOrProp = result[fieldName];
|
|
1457
|
+
if (!field) {
|
|
1458
|
+
let loadHint = relationOrProp.loadHint ?? fail(`${source}.${fieldName} cannot be imported as it has no loadHint`);
|
|
1459
|
+
this.importEntity(source, loadHint);
|
|
1460
|
+
} else if ("import" in relationOrProp) relationOrProp.import(source[fieldName], (e) => this.importEntity(e, subHint, subHint), (entities) => {
|
|
1461
|
+
if (entities === void 0) return void 0;
|
|
1462
|
+
const result = new Array(entities.length);
|
|
1463
|
+
for (let i = 0; i < entities.length; i++) result[i] = this.importEntity(entities[i], subHint, subHint);
|
|
1464
|
+
return result;
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
return result;
|
|
1468
|
+
}
|
|
1469
|
+
addPlugin(plugin) {
|
|
1470
|
+
getEmInternalApi(this).pluginManager.addPlugin(plugin);
|
|
1471
|
+
}
|
|
1472
|
+
getPlugins() {
|
|
1473
|
+
return getEmInternalApi(this).pluginManager.plugins;
|
|
1474
|
+
}
|
|
1475
|
+
get isRefreshing() {
|
|
1476
|
+
return this.#isRefreshing;
|
|
1477
|
+
}
|
|
1478
|
+
get isFlushing() {
|
|
1479
|
+
return this.#fl.isFlushing;
|
|
1480
|
+
}
|
|
1481
|
+
/** Creates a new `type` and marks it as loaded, i.e. we know its collections are all safe to access in memory. */
|
|
1482
|
+
#doCreate(type, opts, partial) {
|
|
1483
|
+
const entity = newEntity(this, type, true);
|
|
1484
|
+
const meta = getMetadata(type);
|
|
1485
|
+
const counter = this.#createCounter ??= /* @__PURE__ */ new Map();
|
|
1486
|
+
const i = (counter.get(meta.tagName) ?? 0) + 1;
|
|
1487
|
+
counter.set(meta.tagName, i);
|
|
1488
|
+
getInstanceData(entity).createId = String(i);
|
|
1489
|
+
this.#doRegister(entity, opts.id);
|
|
1490
|
+
const baseMeta = getBaseMeta(getMetadata(entity));
|
|
1491
|
+
if (baseMeta.timestampFields) this.#assignTimestamps(entity, baseMeta);
|
|
1492
|
+
if (baseMeta.inheritanceType === "sti") setStiDiscriminatorValue(baseMeta, entity);
|
|
1493
|
+
getEmInternalApi(this)?.fieldLogger.logCreate(entity);
|
|
1494
|
+
setOpts(entity, opts, {
|
|
1495
|
+
partial,
|
|
1496
|
+
calledFromConstructor: true
|
|
1497
|
+
});
|
|
1498
|
+
if (!this.fakeInstance) setSyncDefaults(entity);
|
|
1499
|
+
this.#rm.queueAllDownstreamFields(entity, "created");
|
|
1500
|
+
return entity;
|
|
1501
|
+
}
|
|
1502
|
+
#assignTimestamps(entity, baseMeta) {
|
|
1503
|
+
const { createdAt, updatedAt } = baseMeta.timestampFields ?? {};
|
|
1504
|
+
const { data } = getInstanceData(entity);
|
|
1505
|
+
const now = /* @__PURE__ */ new Date();
|
|
1506
|
+
if (createdAt) data[createdAt] = baseMeta.fields[createdAt].serde.mapFromNow(now);
|
|
1507
|
+
if (updatedAt) data[updatedAt] = baseMeta.fields[updatedAt].serde.mapFromNow(now);
|
|
1508
|
+
}
|
|
1509
|
+
/** Registers a newly-instantiated entity with our EntityManager; only called by #doCreate and hydrate. */
|
|
1510
|
+
#doRegister(entity, id, meta, skipDuplicateCheck = false) {
|
|
1511
|
+
const maybeId = id ?? entity.idTaggedMaybe;
|
|
1512
|
+
if (maybeId) {
|
|
1513
|
+
if (!skipDuplicateCheck && this.findExistingInstance(maybeId) !== void 0) throw new Error(`Entity ${entity} has a duplicate instance already loaded`);
|
|
1514
|
+
this.#entitiesById.set(maybeId, entity);
|
|
1515
|
+
} else this.#entitiesById.set(entity.toTaggedString(), entity);
|
|
1516
|
+
getInstanceData(entity).entityIndex = this.#entitiesArray.length;
|
|
1517
|
+
this.#entitiesArray.push(entity);
|
|
1518
|
+
meta ??= getMetadata(entity);
|
|
1519
|
+
const set = this.#entitiesByTag.get(meta.tagName) ?? [];
|
|
1520
|
+
if (set.length === 0) this.#entitiesByTag.set(meta.tagName, set);
|
|
1521
|
+
set.push(entity);
|
|
1522
|
+
if (this.#entitiesArray.length >= this.entityLimit) {
|
|
1523
|
+
const topTypes = [...this.#entitiesByTag.entries()].map(([tag, entities]) => ({
|
|
1524
|
+
tag,
|
|
1525
|
+
count: entities.length
|
|
1526
|
+
})).sort((a, b) => b.count - a.count).slice(0, 3).map(({ tag, count }) => `${tag}=${count}`).join(", ");
|
|
1527
|
+
throw new Error(`More than ${this.entityLimit} entities have been instantiated (top entities: ${topTypes})`);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1800
1531
|
function getEmInternalApi(em) {
|
|
1801
|
-
|
|
1532
|
+
return em["__api"];
|
|
1802
1533
|
}
|
|
1803
|
-
let defaultEntityLimit =
|
|
1534
|
+
let defaultEntityLimit = 5e4;
|
|
1804
1535
|
function getDefaultEntityLimit() {
|
|
1805
|
-
|
|
1536
|
+
return defaultEntityLimit;
|
|
1806
1537
|
}
|
|
1807
1538
|
function setDefaultEntityLimit(limit) {
|
|
1808
|
-
|
|
1539
|
+
defaultEntityLimit = limit;
|
|
1809
1540
|
}
|
|
1810
1541
|
function resetDefaultEntityLimit() {
|
|
1811
|
-
|
|
1542
|
+
defaultEntityLimit = 5e4;
|
|
1812
1543
|
}
|
|
1813
1544
|
function isKey(k) {
|
|
1814
|
-
|
|
1545
|
+
return typeof k === "string";
|
|
1815
1546
|
}
|
|
1816
1547
|
/** Compares `a` to `b`, where `b` might be an id. */
|
|
1817
1548
|
function sameEntity(a, b) {
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
if (a === undefined || b === undefined || a === null || b === null) {
|
|
1823
|
-
return (a === undefined || a === null) && (b === undefined || b === null);
|
|
1824
|
-
}
|
|
1825
|
-
// If both are entities, return if they are the same reference
|
|
1826
|
-
if ((0, Entity_1.isEntity)(a) && (0, Entity_1.isEntity)(b)) {
|
|
1827
|
-
return a === b;
|
|
1828
|
-
}
|
|
1829
|
-
// Otherwise check by ID
|
|
1830
|
-
const aId = (0, Entity_1.isEntity)(a) ? a.idTaggedMaybe : a;
|
|
1831
|
-
const bId = (0, Entity_1.isEntity)(b) ? b.idTaggedMaybe : b;
|
|
1832
|
-
return aId === bId;
|
|
1549
|
+
if (a === b) return true;
|
|
1550
|
+
if (a === void 0 || b === void 0 || a === null || b === null) return (a === void 0 || a === null) && (b === void 0 || b === null);
|
|
1551
|
+
if (isEntity(a) && isEntity(b)) return a === b;
|
|
1552
|
+
return (isEntity(a) ? a.idTaggedMaybe : a) === (isEntity(b) ? b.idTaggedMaybe : b);
|
|
1833
1553
|
}
|
|
1834
1554
|
/** Compares the value `a` to `b`, with handling of new entities w/o ids assigned yet. */
|
|
1835
1555
|
function sameReference(a, b) {
|
|
1836
|
-
|
|
1556
|
+
return sameEntity(isLoadedReference(a) ? a.get : a.idTaggedMaybe, isLoadedReference(b) ? b.get : b.idTaggedMaybe);
|
|
1837
1557
|
}
|
|
1838
1558
|
/** Thrown by `findOneOrFail`, 'load' & 'loadAll' if an entity is not found. */
|
|
1839
|
-
|
|
1840
|
-
}
|
|
1841
|
-
exports.NotFoundError = NotFoundError;
|
|
1559
|
+
var NotFoundError = class extends Error {};
|
|
1842
1560
|
/** Thrown by `findOne` and `findOneOrFail` if more than one entity is found. */
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
}
|
|
1848
|
-
exports.TooManyError = TooManyError;
|
|
1561
|
+
var TooManyError = class extends Error {
|
|
1562
|
+
constructor(message) {
|
|
1563
|
+
super(message);
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1849
1566
|
/**
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
async function validateReactiveRules(em, logger, todos, joinRowTodos) {
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
const triggered = entities.filter((e) => e instanceof todo.m2m.meta.cstr);
|
|
1910
|
-
return followAndQueue(triggered, rule);
|
|
1911
|
-
});
|
|
1912
|
-
// The "other" side only exists for entity-to-entity m2ms; enums have no reverse field.
|
|
1913
|
-
const { otherMeta, otherFieldName } = todo.m2m;
|
|
1914
|
-
const b = otherMeta
|
|
1915
|
-
? otherMeta
|
|
1916
|
-
.reactiveRules.filter((rule) => rule.fields.includes(otherFieldName))
|
|
1917
|
-
.map((rule) => {
|
|
1918
|
-
const triggered = entities.filter((e) => e instanceof otherMeta.cstr);
|
|
1919
|
-
return followAndQueue(triggered, rule);
|
|
1920
|
-
})
|
|
1921
|
-
: [];
|
|
1922
|
-
return [...a, ...b];
|
|
1923
|
-
});
|
|
1924
|
-
(0, utils_1.failIfAnyRejected)(await Promise.allSettled([...p1, ...p2]));
|
|
1925
|
-
// Now that we've found the fn+entities to run, run them and collect any errors
|
|
1926
|
-
const p3 = [...fns.entries()].flatMap(([fn, entities]) => [...entities].map(async (entity) => coerceError(entity, await fn(entity))));
|
|
1927
|
-
const errors = (0, utils_1.failIfAnyRejected)(await Promise.allSettled(p3)).flat();
|
|
1928
|
-
if (errors.length > 0) {
|
|
1929
|
-
throw new index_1.ValidationErrors(errors);
|
|
1930
|
-
}
|
|
1567
|
+
* For the entities currently in `todos`, find any reactive validation rules that point
|
|
1568
|
+
* from the currently-changed entities back to each rule's originally-defined-in entity,
|
|
1569
|
+
* and ensure those entities are added to `todos`.
|
|
1570
|
+
*/
|
|
1571
|
+
async function validateReactiveRules(em, logger, todos, joinRowTodos, getRules = (meta) => meta.reactiveRules) {
|
|
1572
|
+
logger.logStartingValidate(em, todos);
|
|
1573
|
+
const fns = /* @__PURE__ */ new Map();
|
|
1574
|
+
const walks = [];
|
|
1575
|
+
async function followAndQueue(triggered, rule) {
|
|
1576
|
+
if (triggered.length === 0) return;
|
|
1577
|
+
const found = (await followReverseHint(rule.name, triggered, rule.path)).filter((entity) => !entity.isDeletedEntity).filter((e) => e instanceof rule.cstr);
|
|
1578
|
+
let entities = fns.get(rule.fn);
|
|
1579
|
+
if (!entities) {
|
|
1580
|
+
entities = /* @__PURE__ */ new Set();
|
|
1581
|
+
fns.set(rule.fn, entities);
|
|
1582
|
+
}
|
|
1583
|
+
walks.push({
|
|
1584
|
+
todo: triggered,
|
|
1585
|
+
r: rule,
|
|
1586
|
+
entities: found
|
|
1587
|
+
});
|
|
1588
|
+
found.forEach((entity) => {
|
|
1589
|
+
entities.add(entity);
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
const p1 = Object.values(todos).flatMap((todo) => {
|
|
1593
|
+
const rules = getRules(todo.metadata);
|
|
1594
|
+
if (rules.length === 0) return [];
|
|
1595
|
+
const entities = [
|
|
1596
|
+
...todo.inserts,
|
|
1597
|
+
...todo.updates,
|
|
1598
|
+
...todo.deletes
|
|
1599
|
+
];
|
|
1600
|
+
return rules.map((rule) => {
|
|
1601
|
+
return followAndQueue(entities.filter((e) => {
|
|
1602
|
+
if (!(e instanceof rule.source)) return false;
|
|
1603
|
+
if (e.isNewEntity || e.isDeletedEntity) return true;
|
|
1604
|
+
const { originalData } = getInstanceData(e);
|
|
1605
|
+
for (const field of rule.fields) if (field in originalData) return true;
|
|
1606
|
+
return false;
|
|
1607
|
+
}), rule);
|
|
1608
|
+
});
|
|
1609
|
+
});
|
|
1610
|
+
const p2 = Object.values(joinRowTodos).flatMap((todo) => {
|
|
1611
|
+
const entities = [...todo.newRows, ...todo.deletedRows].flatMap((jr) => Object.values(jr.columns)).filter(isEntity);
|
|
1612
|
+
const a = getRules(todo.m2m.meta).filter((rule) => rule.fields.includes(todo.m2m.fieldName)).map((rule) => {
|
|
1613
|
+
return followAndQueue(entities.filter((e) => e instanceof todo.m2m.meta.cstr), rule);
|
|
1614
|
+
});
|
|
1615
|
+
const { otherMeta, otherFieldName } = todo.m2m;
|
|
1616
|
+
const b = otherMeta ? getRules(otherMeta).filter((rule) => rule.fields.includes(otherFieldName)).map((rule) => {
|
|
1617
|
+
return followAndQueue(entities.filter((e) => e instanceof otherMeta.cstr), rule);
|
|
1618
|
+
}) : [];
|
|
1619
|
+
return [...a, ...b];
|
|
1620
|
+
});
|
|
1621
|
+
failIfAnyRejected(await Promise.allSettled([...p1, ...p2]));
|
|
1622
|
+
logger.logWalks(walks, "validate");
|
|
1623
|
+
const p3 = [...fns.entries()].flatMap(([fn, entities]) => [...entities].map(async (entity) => coerceError(entity, await fn(entity))));
|
|
1624
|
+
const errors = failIfAnyRejected(await Promise.allSettled(p3)).flat();
|
|
1625
|
+
if (errors.length > 0) throw new ValidationErrors(errors);
|
|
1931
1626
|
}
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1627
|
+
async function validateSimpleRules(todos, getRules = (config) => config.rules) {
|
|
1628
|
+
let p = void 0;
|
|
1629
|
+
for (const todoKey in todos) {
|
|
1630
|
+
const { inserts, updates } = todos[todoKey];
|
|
1631
|
+
for (const entities of [inserts, updates]) for (const entity of entities) {
|
|
1632
|
+
if (entity.isDeletedEntity) continue;
|
|
1633
|
+
for (const m of getBaseAndSelfMetas(getMetadata(entity))) for (const rule of getRules(m.config.__data)) {
|
|
1634
|
+
if (rule.hint !== void 0) continue;
|
|
1635
|
+
(p ??= []).push(invokeRule(entity, rule.fn));
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
if (!p) return;
|
|
1640
|
+
const errors = failIfAnyRejected(await Promise.allSettled(p)).flat();
|
|
1641
|
+
if (errors.length > 0) throw new ValidationErrors(errors);
|
|
1642
|
+
}
|
|
1643
|
+
/** Invokes a single validation rule, coercing its result/sync throws into a promise. */
|
|
1644
|
+
async function invokeRule(entity, fn) {
|
|
1645
|
+
return coerceError(entity, await fn(entity));
|
|
1950
1646
|
}
|
|
1951
1647
|
function driverBeforeBegin(em, txn) {
|
|
1952
|
-
|
|
1648
|
+
return Promise.all(getEmInternalApi(em).hooks.beforeBegin.map((fn) => fn(em, txn)));
|
|
1953
1649
|
}
|
|
1954
1650
|
function driverAfterBegin(em, txn) {
|
|
1955
|
-
|
|
1651
|
+
return Promise.all(getEmInternalApi(em).hooks.afterBegin.map((fn) => fn(em, txn)));
|
|
1956
1652
|
}
|
|
1957
1653
|
function driverBeforeCommit(em, txn) {
|
|
1958
|
-
|
|
1654
|
+
return Promise.all(getEmInternalApi(em).hooks.beforeCommit.map((fn) => fn(em, txn)));
|
|
1959
1655
|
}
|
|
1960
1656
|
function driverAfterCommit(em, txn) {
|
|
1961
|
-
|
|
1657
|
+
return Promise.all(getEmInternalApi(em).hooks.afterCommit.map((fn) => fn(em, txn)));
|
|
1962
1658
|
}
|
|
1963
1659
|
async function runHookOnTodos(ctx, hook, todos, keys) {
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1660
|
+
let entities = void 0;
|
|
1661
|
+
for (const todoKey in todos) {
|
|
1662
|
+
const todo = todos[todoKey];
|
|
1663
|
+
if (!metaHasHook(todo.metadata, hook)) continue;
|
|
1664
|
+
for (const k of keys) for (const e of todo[k]) {
|
|
1665
|
+
if (k !== "deletes" && e.isDeletedEntity) continue;
|
|
1666
|
+
(entities ??= []).push(e);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
if (entities) return runHook(ctx, hook, entities);
|
|
1670
|
+
}
|
|
1671
|
+
/** Returns whether `meta`'s base/self/sub hierarchy has any `hook` functions registered. */
|
|
1672
|
+
function metaHasHook(meta, hook) {
|
|
1673
|
+
for (const m of getBaseSelfAndSubMetas(meta)) if (m.config.__data.hooks[hook].length > 0) return true;
|
|
1674
|
+
return false;
|
|
1968
1675
|
}
|
|
1969
1676
|
async function runHook(ctx, hook, entities) {
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
(0, utils_1.failIfAnyRejected)(results);
|
|
1677
|
+
let p = void 0;
|
|
1678
|
+
for (const entity of entities) for (const m of getBaseAndSelfMetas(getMetadata(entity))) for (const fn of m.config.__data.hooks[hook]) (p ??= []).push(invokeHook(fn, entity, ctx));
|
|
1679
|
+
if (!p) return;
|
|
1680
|
+
const results = await Promise.allSettled(p);
|
|
1681
|
+
failIfAnyRejected(results);
|
|
1682
|
+
}
|
|
1683
|
+
/** Invokes a single hook fn, coercing sync throws into rejections. */
|
|
1684
|
+
async function invokeHook(fn, entity, ctx) {
|
|
1685
|
+
return fn(entity, ctx);
|
|
1980
1686
|
}
|
|
1981
1687
|
function beforeDelete(ctx, todos) {
|
|
1982
|
-
|
|
1688
|
+
return runHookOnTodos(ctx, "beforeDelete", todos, ["deletes"]);
|
|
1983
1689
|
}
|
|
1984
1690
|
function beforeFlush(ctx, todos) {
|
|
1985
|
-
|
|
1691
|
+
return runHookOnTodos(ctx, "beforeFlush", todos, ["inserts", "updates"]);
|
|
1986
1692
|
}
|
|
1987
1693
|
function beforeCreate(ctx, todos) {
|
|
1988
|
-
|
|
1694
|
+
return runHookOnTodos(ctx, "beforeCreate", todos, ["inserts"]);
|
|
1989
1695
|
}
|
|
1990
1696
|
function beforeUpdate(ctx, todos) {
|
|
1991
|
-
|
|
1697
|
+
return runHookOnTodos(ctx, "beforeUpdate", todos, ["updates"]);
|
|
1992
1698
|
}
|
|
1993
1699
|
function afterValidation(ctx, todos) {
|
|
1994
|
-
|
|
1700
|
+
return runHookOnTodos(ctx, "afterValidation", todos, ["inserts", "updates"]);
|
|
1995
1701
|
}
|
|
1996
1702
|
/** Collects changed entities from flush todos, i.e. m2m endpoint entities. */
|
|
1997
1703
|
function entitiesFromTodos(entityTodos, joinRowTodos) {
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
if ((0, Entity_1.isEntity)(value))
|
|
2007
|
-
entities.add(value);
|
|
2008
|
-
});
|
|
2009
|
-
});
|
|
2010
|
-
}
|
|
2011
|
-
return [...entities];
|
|
1704
|
+
const entities = /* @__PURE__ */ new Set();
|
|
1705
|
+
for (const todo of Object.values(entityTodos)) for (const list of [
|
|
1706
|
+
todo.inserts,
|
|
1707
|
+
todo.updates,
|
|
1708
|
+
todo.deletes
|
|
1709
|
+
]) for (const entity of list) entities.add(entity);
|
|
1710
|
+
for (const todo of Object.values(joinRowTodos)) for (const rows of [todo.newRows, todo.deletedRows]) for (const row of rows) for (const value of Object.values(row.columns)) if (isEntity(value)) entities.add(value);
|
|
1711
|
+
return [...entities];
|
|
2012
1712
|
}
|
|
2013
1713
|
function beforeCommit(ctx, entities) {
|
|
2014
|
-
|
|
1714
|
+
return runHook(ctx, "beforeCommit", [...entities]);
|
|
2015
1715
|
}
|
|
2016
1716
|
function afterCommit(ctx, entities) {
|
|
2017
|
-
|
|
1717
|
+
return runHook(ctx, "afterCommit", [...entities]);
|
|
2018
1718
|
}
|
|
2019
1719
|
/** Given a validation rule result `maybeError`, returns a canonical `ValidationError[]`. */
|
|
2020
1720
|
function coerceError(entity, maybeError) {
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
1721
|
+
if (maybeError === void 0) return [];
|
|
1722
|
+
else if (typeof maybeError === "string") return [{
|
|
1723
|
+
entity,
|
|
1724
|
+
message: maybeError
|
|
1725
|
+
}];
|
|
1726
|
+
else if (Array.isArray(maybeError)) return maybeError.map((e) => {
|
|
1727
|
+
if (typeof e === "string") return {
|
|
1728
|
+
entity,
|
|
1729
|
+
message: e
|
|
1730
|
+
};
|
|
1731
|
+
else return {
|
|
1732
|
+
entity,
|
|
1733
|
+
...e
|
|
1734
|
+
};
|
|
1735
|
+
});
|
|
1736
|
+
else return [{
|
|
1737
|
+
entity,
|
|
1738
|
+
...maybeError
|
|
1739
|
+
}];
|
|
2040
1740
|
}
|
|
2041
1741
|
/** Evaluates each (non-async) derived field to see if it's value has changed. */
|
|
2042
1742
|
function recalcSynchronousDerivedFields(todos) {
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
.filter((f) => (f.kind === "primitive" || f.kind === "enum") && f.derived === "sync")
|
|
2051
|
-
.map((f) => f.fieldName),
|
|
2052
|
-
];
|
|
2053
|
-
}));
|
|
2054
|
-
for (const entity of entities) {
|
|
2055
|
-
const derivedFields = derivedFieldsByMeta.get((0, index_1.getMetadata)(entity)) || [];
|
|
2056
|
-
derivedFields.forEach((fieldName) => {
|
|
2057
|
-
// setField will intelligently mark/not mark the field as dirty.
|
|
2058
|
-
(0, fields_1.setField)(entity, fieldName, entity[fieldName]);
|
|
2059
|
-
});
|
|
2060
|
-
}
|
|
1743
|
+
for (const todoKey in todos) {
|
|
1744
|
+
const todo = todos[todoKey];
|
|
1745
|
+
for (const entities of [todo.inserts, todo.updates]) for (const entity of entities) {
|
|
1746
|
+
if (entity.isDeletedEntity) continue;
|
|
1747
|
+
for (const fieldName of getMetadata(entity).syncDerivedFields) setField(entity, fieldName, entity[fieldName]);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
2061
1750
|
}
|
|
2062
1751
|
/** Recursively crawls through `entity`, with the given populate `deep` hint, and adds anything found to `found`. */
|
|
2063
|
-
async function crawl(found,
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
const _opts = { ...opts, skip: skip[relationName] };
|
|
2089
|
-
if (relation instanceof index_1.OneToManyCollection) {
|
|
2090
|
-
const relatedEntities = await relation.load();
|
|
2091
|
-
await crawl(found, skipMap, relatedEntities, nested, _opts);
|
|
2092
|
-
}
|
|
2093
|
-
else if (relation instanceof relations_1.OneToOneReferenceImpl) {
|
|
2094
|
-
const related = await relation.load();
|
|
2095
|
-
if (related) {
|
|
2096
|
-
await crawl(found, skipMap, [related], nested, _opts);
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
else if (relation instanceof relations_1.ManyToOneReferenceImpl) {
|
|
2100
|
-
const related = await relation.load();
|
|
2101
|
-
if (related) {
|
|
2102
|
-
await crawl(found, skipMap, [related], nested, _opts);
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
else if (relation instanceof relations_1.ReactiveReferenceImpl) {
|
|
2106
|
-
const relatedEntities = await relation.load();
|
|
2107
|
-
await crawl(found, skipMap, relatedEntities, nested, _opts);
|
|
2108
|
-
}
|
|
2109
|
-
else {
|
|
2110
|
-
(0, utils_1.fail)(`Uncloneable relation: ${relationName}`);
|
|
2111
|
-
}
|
|
2112
|
-
})));
|
|
1752
|
+
async function crawl(found, skipMap, entities, deep, opts = {}) {
|
|
1753
|
+
const { skipIf = () => false } = opts ?? {};
|
|
1754
|
+
const skip = deepNormalizeHint(opts.skip ?? {});
|
|
1755
|
+
const skipFields = Object.keys(skip).filter((key) => Object.keys(skip[key]).length === 0);
|
|
1756
|
+
const entitiesToClone = entities.filter((e) => !skipIf(e));
|
|
1757
|
+
for (const entity of entitiesToClone) {
|
|
1758
|
+
found.add(entity);
|
|
1759
|
+
skipMap.set(entity, skipFields);
|
|
1760
|
+
}
|
|
1761
|
+
await Promise.all(entitiesToClone.flatMap((entity) => Object.entries(adaptHint(deep)).map(async ([relationName, nested]) => {
|
|
1762
|
+
const relation = entity[relationName];
|
|
1763
|
+
const _opts = {
|
|
1764
|
+
...opts,
|
|
1765
|
+
skip: skip[relationName]
|
|
1766
|
+
};
|
|
1767
|
+
if (relation instanceof OneToManyCollection) await crawl(found, skipMap, await relation.load(), nested, _opts);
|
|
1768
|
+
else if (relation instanceof OneToOneReferenceImpl) {
|
|
1769
|
+
const related = await relation.load();
|
|
1770
|
+
if (related) await crawl(found, skipMap, [related], nested, _opts);
|
|
1771
|
+
} else if (relation instanceof ManyToOneReferenceImpl) {
|
|
1772
|
+
const related = await relation.load();
|
|
1773
|
+
if (related) await crawl(found, skipMap, [related], nested, _opts);
|
|
1774
|
+
} else if (relation instanceof ReactiveReferenceImpl) await crawl(found, skipMap, await relation.load(), nested, _opts);
|
|
1775
|
+
else fail(`Uncloneable relation: ${relationName}`);
|
|
1776
|
+
})));
|
|
2113
1777
|
}
|
|
2114
1778
|
/** Takes our flexible string or array or hash load hint and makes it always a hash. */
|
|
2115
1779
|
function adaptHint(hint) {
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
return Object.fromEntries(hint.map((relation) => [relation, {}]));
|
|
2121
|
-
}
|
|
2122
|
-
else if (hint) {
|
|
2123
|
-
return hint;
|
|
2124
|
-
}
|
|
2125
|
-
else {
|
|
2126
|
-
return {};
|
|
2127
|
-
}
|
|
1780
|
+
if (typeof hint === "string") return { [hint]: {} };
|
|
1781
|
+
else if (Array.isArray(hint)) return Object.fromEntries(hint.map((relation) => [relation, {}]));
|
|
1782
|
+
else if (hint) return hint;
|
|
1783
|
+
else return {};
|
|
2128
1784
|
}
|
|
2129
1785
|
function isDefined(param) {
|
|
2130
|
-
|
|
1786
|
+
return param !== null && param !== void 0;
|
|
2131
1787
|
}
|
|
2132
1788
|
function getCascadeDeleteRelations(entity) {
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
1789
|
+
return getBaseAndSelfMetas(getMetadata(entity)).flatMap((meta) => {
|
|
1790
|
+
return meta.config.__data.cascadeDeleteFields.map((fieldName) => entity[fieldName]);
|
|
1791
|
+
});
|
|
2136
1792
|
}
|
|
2137
1793
|
function isCustomRelation(r) {
|
|
2138
|
-
|
|
1794
|
+
return r instanceof CustomCollection || r instanceof CustomReference || r instanceof ReactiveReferenceImpl;
|
|
2139
1795
|
}
|
|
2140
1796
|
function maybeBumpUpdatedAt(rm, todos, now) {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
const serde = todo.metadata.fields[updatedAt].serde;
|
|
2152
|
-
orm.data[updatedAt] = serde.mapFromNow(now);
|
|
2153
|
-
rm.queueDownstreamReactables(e, updatedAt);
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
1797
|
+
for (const todo of Object.values(todos)) {
|
|
1798
|
+
const { updatedAt } = todo.metadata.timestampFields ?? {};
|
|
1799
|
+
if (updatedAt) for (const e of todo.updates) {
|
|
1800
|
+
const orm = getInstanceData(e);
|
|
1801
|
+
orm.markFieldDirty(updatedAt, getField(e, updatedAt));
|
|
1802
|
+
const serde = todo.metadata.fields[updatedAt].serde;
|
|
1803
|
+
orm.data[updatedAt] = serde.mapFromNow(now);
|
|
1804
|
+
rm.queueDownstreamReactables(e, updatedAt);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
2157
1807
|
}
|
|
2158
|
-
let lastNow =
|
|
2159
|
-
// exposed so tests that do their own time management can override lastNow to get correct updatedAt values
|
|
1808
|
+
let lastNow = void 0;
|
|
2160
1809
|
function setLastNow(now) {
|
|
2161
|
-
|
|
1810
|
+
lastNow = now;
|
|
2162
1811
|
}
|
|
2163
1812
|
function getNow() {
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
// didn't self-manage `updated_at`" and so bump it for them. Which is fine, but now
|
|
2169
|
-
// Joist doesn't know about the bumped time, and the 2nd `UPDATE` will fail.
|
|
2170
|
-
if (lastNow && (lastNow.getTime() === now.getTime() || now.getTime() < lastNow.getTime())) {
|
|
2171
|
-
now = new Date(lastNow.getTime() + 1);
|
|
2172
|
-
}
|
|
2173
|
-
lastNow = now;
|
|
2174
|
-
return now;
|
|
1813
|
+
let now = /* @__PURE__ */ new Date();
|
|
1814
|
+
if (lastNow && (lastNow.getTime() === now.getTime() || now.getTime() < lastNow.getTime())) now = new Date(lastNow.getTime() + 1);
|
|
1815
|
+
lastNow = now;
|
|
1816
|
+
return now;
|
|
2175
1817
|
}
|
|
2176
1818
|
/** Given a `row` from the db, resolves the CTI/STI subtype, if applicable. */
|
|
2177
|
-
function findConcreteMeta(maybeBaseMeta,
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
const value = row[baseMeta.stiDiscriminatorColumnName];
|
|
2193
|
-
return baseMeta.subTypesByStiValue.get(value) ?? baseMeta;
|
|
2194
|
-
}
|
|
2195
|
-
else {
|
|
2196
|
-
throw new Error("Unknown inheritance type");
|
|
2197
|
-
}
|
|
1819
|
+
function findConcreteMeta(maybeBaseMeta, rowData, rowIndex) {
|
|
1820
|
+
if (maybeBaseMeta.inheritanceType === void 0) return maybeBaseMeta;
|
|
1821
|
+
const __class = rowData.get(rowIndex, "__class");
|
|
1822
|
+
if (!__class && maybeBaseMeta.inheritanceType !== "sti") return maybeBaseMeta;
|
|
1823
|
+
if (__class) {
|
|
1824
|
+
if (__class === "_" && maybeBaseMeta.ctiAbstract) {
|
|
1825
|
+
const id = rowData.get(rowIndex, "id");
|
|
1826
|
+
throw new Error(`${maybeBaseMeta.type} ${tagId(maybeBaseMeta, id)} must be instantiated via a subtype`);
|
|
1827
|
+
}
|
|
1828
|
+
return maybeBaseMeta.subTypesByType.get(__class) ?? maybeBaseMeta;
|
|
1829
|
+
} else if (maybeBaseMeta.inheritanceType === "sti") {
|
|
1830
|
+
const baseMeta = getBaseMeta(maybeBaseMeta);
|
|
1831
|
+
const value = rowData.get(rowIndex, baseMeta.stiDiscriminatorColumnName);
|
|
1832
|
+
return baseMeta.subTypesByStiValue.get(value) ?? baseMeta;
|
|
1833
|
+
} else throw new Error("Unknown inheritance type");
|
|
2198
1834
|
}
|
|
2199
1835
|
/** Sets the `Animal.type` enum to the right subtype value. */
|
|
2200
1836
|
function setStiDiscriminatorValue(baseMeta, entity) {
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
}
|
|
2208
|
-
else {
|
|
2209
|
-
entity[baseMeta.stiDiscriminatorField] = undefined;
|
|
2210
|
-
}
|
|
1837
|
+
const typeName = entity.constructor.name;
|
|
1838
|
+
const st = baseMeta.subTypesByType.get(typeName);
|
|
1839
|
+
if (st) {
|
|
1840
|
+
const code = baseMeta.fields[baseMeta.stiDiscriminatorField].enumDetailType.findById(st.stiDiscriminatorValue).code;
|
|
1841
|
+
entity[baseMeta.stiDiscriminatorField] = code;
|
|
1842
|
+
} else entity[baseMeta.stiDiscriminatorField] = void 0;
|
|
2211
1843
|
}
|
|
2212
1844
|
function findPendingFlushEntities(maybePendingFlushEntities, hooksInvoked, pendingFlush, pendingHooks, alreadyRanHooks) {
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
alreadyRanHooks.add(e);
|
|
2223
|
-
}
|
|
2224
|
-
pendingFlush.add(e);
|
|
2225
|
-
}
|
|
1845
|
+
for (const e of maybePendingFlushEntities) {
|
|
1846
|
+
if (getInstanceData(e).pendingOperation === "none") {
|
|
1847
|
+
maybePendingFlushEntities.delete(e);
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
if (!hooksInvoked.has(e)) pendingHooks.add(e);
|
|
1851
|
+
else alreadyRanHooks.add(e);
|
|
1852
|
+
pendingFlush.add(e);
|
|
1853
|
+
}
|
|
2226
1854
|
}
|
|
2227
1855
|
/** Returns true if the caller explicitly asked `find` to use SQL pagination. */
|
|
2228
1856
|
function hasPaginationSettings(options) {
|
|
2229
|
-
|
|
1857
|
+
return "limit" in options || "offset" in options;
|
|
2230
1858
|
}
|
|
2231
1859
|
/** An error we throw to get knex to `ROLLBACK`, but then catch. */
|
|
2232
|
-
|
|
2233
|
-
}
|
|
1860
|
+
var InMemoryRollbackError = class extends Error {};
|
|
2234
1861
|
/** An error thrown when `em.mode === "read-only"` but entities are mutated/flushed. */
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
}
|
|
2240
|
-
exports.ReadOnlyError = ReadOnlyError;
|
|
1862
|
+
var ReadOnlyError = class extends Error {
|
|
1863
|
+
constructor() {
|
|
1864
|
+
super("EntityManager is read-only");
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
2241
1867
|
function maybeSetupHookOrdering(todos) {
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
group[todo.metadata.type] = todo;
|
|
2250
|
-
}
|
|
2251
|
-
return Object.keys(group1).length ? [group1, group2] : [group2];
|
|
1868
|
+
const group1 = {};
|
|
1869
|
+
const group2 = {};
|
|
1870
|
+
for (const todo of Object.values(todos)) {
|
|
1871
|
+
const group = todo.metadata.config.__data.runHooksBefore.some((cstr) => getBaseMeta(getMetadata(cstr)).type in todos) ? group1 : group2;
|
|
1872
|
+
group[todo.metadata.type] = todo;
|
|
1873
|
+
}
|
|
1874
|
+
return Object.keys(group1).length ? [group1, group2] : [group2];
|
|
2252
1875
|
}
|
|
2253
1876
|
/**
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
1877
|
+
* Given an `err` thrown in "a different context", i.e. a database error or dataloader error
|
|
1878
|
+
* that doesn't include our stack trace, append our stack for better debugging.
|
|
1879
|
+
*
|
|
1880
|
+
* See https://github.com/brianc/node-postgres/pull/2983
|
|
1881
|
+
*/
|
|
2259
1882
|
function appendStack(err, dummy) {
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
}
|
|
2263
|
-
return err;
|
|
1883
|
+
if (err && typeof err === "object" && "stack" in err) err.stack += dummy.stack.replace(/.*\n/, "\n");
|
|
1884
|
+
return err;
|
|
2264
1885
|
}
|
|
2265
1886
|
/** Probe for `ctx.logger.debug` if it exists, otherwise fallback on `console.log`. */
|
|
2266
1887
|
function getDefaultWriteFn(ctx) {
|
|
2267
|
-
|
|
2268
|
-
typeof ctx === "object" &&
|
|
2269
|
-
"logger" in ctx &&
|
|
2270
|
-
ctx.logger &&
|
|
2271
|
-
typeof ctx.logger === "object" &&
|
|
2272
|
-
"debug" in ctx.logger &&
|
|
2273
|
-
ctx.logger.debug instanceof Function
|
|
2274
|
-
? ctx.logger.debug.bind(ctx.logger)
|
|
2275
|
-
: console.log;
|
|
1888
|
+
return ctx && typeof ctx === "object" && "logger" in ctx && ctx.logger && typeof ctx.logger === "object" && "debug" in ctx.logger && ctx.logger.debug instanceof Function ? ctx.logger.debug.bind(ctx.logger) : console.log;
|
|
2276
1889
|
}
|
|
2277
1890
|
const fieldMap = {};
|
|
2278
|
-
// Generates what a row from the db would look like for a given entity
|
|
2279
1891
|
function createRowFromEntityData(e, opts = {}) {
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
// Ideally, we could only go through the serde for data that has actually changed since the last time it was
|
|
2298
|
-
// fetched from the db and just use the row value for everything else. Unfortunately, we lose track of which
|
|
2299
|
-
// fields are modified on flush. So we have to assume that anything present in `data` is a change and push it
|
|
2300
|
-
// through the serde.
|
|
2301
|
-
field.fieldName in originalData || field.fieldName in data
|
|
2302
|
-
? // If our field is in originalData, then the field has been changed since flush. Our `row` should
|
|
2303
|
-
// reflect what would come from the db if we queried it right now, so use originalData when present
|
|
2304
|
-
column.rowValue(preferOriginalData && field.fieldName in originalData ? originalData : data)
|
|
2305
|
-
: // `data` is lazy and isn't set until it's accessed, so if the field isn't present there, then we should
|
|
2306
|
-
// be safe to pull the raw data out of `row`
|
|
2307
|
-
oldRow[column.columnName];
|
|
2308
|
-
row[column.columnName] = value ?? null;
|
|
2309
|
-
}
|
|
2310
|
-
return row;
|
|
1892
|
+
const { preferOriginalData = true } = opts;
|
|
1893
|
+
const { rowData, rowIndex, data, originalData } = e.__data;
|
|
1894
|
+
const __class = e.constructor.name;
|
|
1895
|
+
const { metadata: meta } = e.__data;
|
|
1896
|
+
if (!fieldMap[__class]) {
|
|
1897
|
+
fieldMap[__class] = [];
|
|
1898
|
+
for (const field of Object.values(meta.allFields)) {
|
|
1899
|
+
if (!field.serde) continue;
|
|
1900
|
+
for (const column of field.serde.columns) fieldMap[__class].push([field, column]);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
const row = meta.inheritanceType === "cti" ? { __class } : {};
|
|
1904
|
+
for (const [field, column] of fieldMap[__class]) {
|
|
1905
|
+
const value = field.fieldName in originalData || field.fieldName in data ? column.rowValue(preferOriginalData && field.fieldName in originalData ? originalData : data) : rowData.get(rowIndex, column.columnName);
|
|
1906
|
+
row[column.columnName] = value ?? null;
|
|
1907
|
+
}
|
|
1908
|
+
return row;
|
|
2311
1909
|
}
|
|
1910
|
+
//#endregion
|
|
1911
|
+
export { EntityManager, NotFoundError, ReadOnlyError, TooManyError, appendStack, createRowFromEntityData, driverAfterBegin, driverAfterCommit, driverBeforeBegin, driverBeforeCommit, getDefaultEntityLimit, getEmInternalApi, isDefined, isId, isKey, resetDefaultEntityLimit, sameEntity, sameReference, setDefaultEntityLimit, setLastNow };
|
|
1912
|
+
|
|
2312
1913
|
//# sourceMappingURL=EntityManager.js.map
|