joist-core 2.5.0-next.2 → 2.5.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/BaseEntity.cjs +33 -3
- package/build/BaseEntity.cjs.map +1 -1
- package/build/BaseEntity.d.cts +6 -4
- package/build/BaseEntity.d.cts.map +1 -1
- package/build/BaseEntity.d.mts +6 -4
- package/build/BaseEntity.d.mts.map +1 -1
- package/build/BaseEntity.js +33 -4
- package/build/BaseEntity.js.map +1 -1
- package/build/Entity.cjs +2 -3
- package/build/Entity.d.cts +0 -2
- package/build/Entity.d.cts.map +1 -1
- package/build/Entity.d.mts +0 -2
- package/build/Entity.d.mts.map +1 -1
- package/build/Entity.js +2 -3
- package/build/EntityFields.d.cts +0 -2
- package/build/EntityFields.d.cts.map +1 -1
- package/build/EntityFields.d.mts +0 -2
- package/build/EntityFields.d.mts.map +1 -1
- package/build/EntityManager.cjs +185 -103
- package/build/EntityManager.cjs.map +1 -1
- package/build/EntityManager.d.cts +50 -37
- package/build/EntityManager.d.cts.map +1 -1
- package/build/EntityManager.d.mts +50 -37
- package/build/EntityManager.d.mts.map +1 -1
- package/build/EntityManager.js +185 -104
- package/build/EntityManager.js.map +1 -1
- package/build/EntityMetadata.cjs +3 -4
- package/build/EntityMetadata.cjs.map +1 -1
- package/build/EntityMetadata.d.cts +8 -6
- package/build/EntityMetadata.d.cts.map +1 -1
- package/build/EntityMetadata.d.mts +8 -6
- package/build/EntityMetadata.d.mts.map +1 -1
- package/build/EntityMetadata.js +3 -4
- package/build/EntityMetadata.js.map +1 -1
- package/build/EnumMetadata.d.cts +0 -2
- package/build/EnumMetadata.d.cts.map +1 -1
- package/build/EnumMetadata.d.mts +0 -2
- package/build/EnumMetadata.d.mts.map +1 -1
- package/build/IndexManager.cjs +4 -5
- package/build/IndexManager.d.cts +1 -3
- package/build/IndexManager.d.cts.map +1 -1
- package/build/IndexManager.d.mts +1 -3
- package/build/IndexManager.d.mts.map +1 -1
- package/build/IndexManager.js +4 -5
- package/build/InstanceData.cjs +12 -6
- package/build/InstanceData.cjs.map +1 -1
- package/build/InstanceData.d.cts +9 -5
- package/build/InstanceData.d.cts.map +1 -1
- package/build/InstanceData.d.mts +9 -5
- package/build/InstanceData.d.mts.map +1 -1
- package/build/InstanceData.js +12 -6
- package/build/InstanceData.js.map +1 -1
- package/build/PluginManager.cjs +21 -8
- package/build/PluginManager.cjs.map +1 -1
- package/build/PluginManager.d.cts +19 -7
- package/build/PluginManager.d.cts.map +1 -1
- package/build/PluginManager.d.mts +19 -7
- package/build/PluginManager.d.mts.map +1 -1
- package/build/PluginManager.js +21 -8
- package/build/PluginManager.js.map +1 -1
- package/build/RowData.cjs +1 -2
- package/build/RowData.d.cts +0 -2
- package/build/RowData.d.cts.map +1 -1
- package/build/RowData.d.mts +0 -2
- package/build/RowData.d.mts.map +1 -1
- package/build/RowData.js +1 -2
- package/build/_virtual/_rolldown/runtime.cjs +1 -2
- package/build/batchloaders/BatchLoader.cjs +1 -2
- package/build/batchloaders/BatchLoader.d.cts +0 -2
- package/build/batchloaders/BatchLoader.d.cts.map +1 -1
- package/build/batchloaders/BatchLoader.d.mts +0 -2
- package/build/batchloaders/BatchLoader.d.mts.map +1 -1
- package/build/batchloaders/BatchLoader.js +1 -2
- package/build/batchloaders/enumCollectionBatchLoader.cjs +4 -5
- package/build/batchloaders/enumCollectionBatchLoader.cjs.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.cts +1 -3
- package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.mts +1 -3
- package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.js +4 -5
- package/build/batchloaders/enumCollectionBatchLoader.js.map +1 -1
- package/build/batchloaders/loadBatchLoader.cjs +9 -9
- package/build/batchloaders/loadBatchLoader.cjs.map +1 -1
- package/build/batchloaders/loadBatchLoader.d.cts +3 -5
- package/build/batchloaders/loadBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/loadBatchLoader.d.mts +3 -5
- package/build/batchloaders/loadBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/loadBatchLoader.js +9 -9
- package/build/batchloaders/loadBatchLoader.js.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.cjs +5 -6
- package/build/batchloaders/manyToManyBatchLoader.cjs.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.d.cts +1 -3
- package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.d.mts +1 -3
- package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.js +5 -6
- package/build/batchloaders/manyToManyBatchLoader.js.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.cjs +5 -6
- package/build/batchloaders/oneToManyBatchLoader.cjs.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.d.cts +2 -4
- package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.d.mts +2 -4
- package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.js +6 -7
- package/build/batchloaders/oneToManyBatchLoader.js.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.cjs +7 -8
- package/build/batchloaders/oneToOneBatchLoader.cjs.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.d.cts +2 -4
- package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.d.mts +2 -4
- package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.js +7 -8
- package/build/batchloaders/oneToOneBatchLoader.js.map +1 -1
- package/build/batchloaders/populateBatchLoader.cjs +14 -18
- package/build/batchloaders/populateBatchLoader.cjs.map +1 -1
- package/build/batchloaders/populateBatchLoader.d.cts +2 -4
- package/build/batchloaders/populateBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/populateBatchLoader.d.mts +2 -4
- package/build/batchloaders/populateBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/populateBatchLoader.js +14 -18
- package/build/batchloaders/populateBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs +11 -11
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +2 -4
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +2 -4
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.js +11 -11
- package/build/batchloaders/recursiveChildrenBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.cjs +7 -8
- package/build/batchloaders/recursiveM2mBatchLoader.cjs.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts +2 -4
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts +2 -4
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.js +7 -8
- package/build/batchloaders/recursiveM2mBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.cjs +7 -8
- package/build/batchloaders/recursiveParentsBatchLoader.cjs.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts +2 -4
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts +2 -4
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.js +7 -8
- package/build/batchloaders/recursiveParentsBatchLoader.js.map +1 -1
- package/build/changes.cjs +7 -8
- package/build/changes.d.cts +3 -5
- package/build/changes.d.cts.map +1 -1
- package/build/changes.d.mts +3 -5
- package/build/changes.d.mts.map +1 -1
- package/build/changes.js +7 -8
- package/build/config.cjs +9 -10
- package/build/config.d.cts +6 -8
- package/build/config.d.cts.map +1 -1
- package/build/config.d.mts +6 -8
- package/build/config.d.mts.map +1 -1
- package/build/config.js +9 -10
- package/build/configure.cjs +11 -12
- package/build/configure.d.cts +3 -5
- package/build/configure.d.cts.map +1 -1
- package/build/configure.d.mts +3 -5
- package/build/configure.d.mts.map +1 -1
- package/build/configure.js +11 -12
- package/build/dataloaders/buildCandidateBatchQuery.cjs +499 -0
- package/build/dataloaders/buildCandidateBatchQuery.cjs.map +1 -0
- package/build/dataloaders/buildCandidateBatchQuery.d.cts +57 -0
- package/build/dataloaders/buildCandidateBatchQuery.d.cts.map +1 -0
- package/build/dataloaders/buildCandidateBatchQuery.d.mts +57 -0
- package/build/dataloaders/buildCandidateBatchQuery.d.mts.map +1 -0
- package/build/dataloaders/buildCandidateBatchQuery.js +498 -0
- package/build/dataloaders/buildCandidateBatchQuery.js.map +1 -0
- package/build/dataloaders/collectFindArguments.cjs +48 -0
- package/build/dataloaders/collectFindArguments.cjs.map +1 -0
- package/build/dataloaders/collectFindArguments.d.cts +31 -0
- package/build/dataloaders/collectFindArguments.d.cts.map +1 -0
- package/build/dataloaders/collectFindArguments.d.mts +31 -0
- package/build/dataloaders/collectFindArguments.d.mts.map +1 -0
- package/build/dataloaders/collectFindArguments.js +47 -0
- package/build/dataloaders/collectFindArguments.js.map +1 -0
- package/build/dataloaders/fastWhereFilterHash.cjs +3 -4
- package/build/dataloaders/fastWhereFilterHash.d.cts +0 -2
- package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.d.mts +0 -2
- package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.js +3 -4
- package/build/dataloaders/findByUniqueDataLoader.cjs +2 -3
- package/build/dataloaders/findByUniqueDataLoader.d.cts +2 -4
- package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findByUniqueDataLoader.d.mts +2 -4
- package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findByUniqueDataLoader.js +2 -3
- package/build/dataloaders/findCountDataLoader.cjs +8 -9
- package/build/dataloaders/findCountDataLoader.d.cts +3 -5
- package/build/dataloaders/findCountDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findCountDataLoader.d.mts +3 -5
- package/build/dataloaders/findCountDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findCountDataLoader.js +8 -9
- package/build/dataloaders/findDataLoader.cjs +48 -77
- package/build/dataloaders/findDataLoader.cjs.map +1 -1
- package/build/dataloaders/findDataLoader.d.cts +5 -7
- package/build/dataloaders/findDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findDataLoader.d.mts +5 -7
- package/build/dataloaders/findDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findDataLoader.js +48 -77
- package/build/dataloaders/findDataLoader.js.map +1 -1
- package/build/dataloaders/findIdsDataLoader.cjs +6 -7
- package/build/dataloaders/findIdsDataLoader.d.cts +2 -4
- package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findIdsDataLoader.d.mts +2 -4
- package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findIdsDataLoader.js +6 -7
- package/build/dataloaders/findOrCreateDataLoader.cjs +7 -8
- package/build/dataloaders/findOrCreateDataLoader.d.cts +2 -4
- package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.d.mts +2 -4
- package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.js +7 -8
- package/build/dataloaders/findPaginatedDataLoader.cjs +6 -7
- package/build/dataloaders/findPaginatedDataLoader.d.cts +3 -5
- package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.d.mts +3 -5
- package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.js +6 -7
- package/build/dataloaders/lensDataLoader.cjs +5 -6
- package/build/dataloaders/lensDataLoader.d.cts +1 -3
- package/build/dataloaders/lensDataLoader.d.cts.map +1 -1
- package/build/dataloaders/lensDataLoader.d.mts +1 -3
- package/build/dataloaders/lensDataLoader.d.mts.map +1 -1
- package/build/dataloaders/lensDataLoader.js +5 -6
- package/build/dataloaders/manyToManyFindDataLoader.cjs +1 -2
- package/build/dataloaders/manyToManyFindDataLoader.d.cts +2 -4
- package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.mts +2 -4
- package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.js +1 -2
- package/build/dataloaders/oneToManyFindDataLoader.cjs +7 -5
- package/build/dataloaders/oneToManyFindDataLoader.cjs.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.cts +2 -4
- package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.mts +2 -4
- package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.js +8 -6
- package/build/dataloaders/oneToManyFindDataLoader.js.map +1 -1
- package/build/defaults.cjs +7 -8
- package/build/defaults.d.cts +2 -4
- package/build/defaults.d.cts.map +1 -1
- package/build/defaults.d.mts +2 -4
- package/build/defaults.d.mts.map +1 -1
- package/build/defaults.js +7 -8
- package/build/drivers/Driver.cjs +1 -1
- package/build/drivers/Driver.d.cts +2 -4
- package/build/drivers/Driver.d.cts.map +1 -1
- package/build/drivers/Driver.d.mts +2 -4
- package/build/drivers/Driver.d.mts.map +1 -1
- package/build/drivers/Driver.js +1 -1
- package/build/drivers/EntityWriter.cjs +6 -7
- package/build/drivers/EntityWriter.d.cts +1 -3
- package/build/drivers/EntityWriter.d.cts.map +1 -1
- package/build/drivers/EntityWriter.d.mts +1 -3
- package/build/drivers/EntityWriter.d.mts.map +1 -1
- package/build/drivers/EntityWriter.js +6 -7
- package/build/drivers/IdAssigner.cjs +7 -4
- package/build/drivers/IdAssigner.cjs.map +1 -1
- package/build/drivers/IdAssigner.d.cts +1 -2
- package/build/drivers/IdAssigner.d.cts.map +1 -1
- package/build/drivers/IdAssigner.d.mts +1 -2
- package/build/drivers/IdAssigner.d.mts.map +1 -1
- package/build/drivers/IdAssigner.js +7 -4
- package/build/drivers/IdAssigner.js.map +1 -1
- package/build/drivers/driverApi.cjs +4 -5
- package/build/drivers/driverApi.d.cts +2 -4
- package/build/drivers/driverApi.d.cts.map +1 -1
- package/build/drivers/driverApi.d.mts +2 -4
- package/build/drivers/driverApi.d.mts.map +1 -1
- package/build/drivers/driverApi.js +4 -5
- package/build/drivers/index.d.cts +1 -1
- package/build/drivers/index.d.mts +1 -1
- package/build/fields.cjs +87 -17
- package/build/fields.cjs.map +1 -1
- package/build/fields.d.cts +8 -2
- package/build/fields.d.cts.map +1 -1
- package/build/fields.d.mts +8 -2
- package/build/fields.d.mts.map +1 -1
- package/build/fields.js +87 -19
- package/build/fields.js.map +1 -1
- package/build/flush/FlushLock.cjs +1 -2
- package/build/flush/FlushLock.cjs.map +1 -1
- package/build/flush/FlushLock.d.cts +0 -2
- package/build/flush/FlushLock.d.cts.map +1 -1
- package/build/flush/FlushLock.d.mts +0 -2
- package/build/flush/FlushLock.d.mts.map +1 -1
- package/build/flush/FlushLock.js +1 -2
- package/build/flush/JoinRows.cjs +10 -10
- package/build/flush/JoinRows.cjs.map +1 -1
- package/build/flush/JoinRows.d.cts +2 -4
- package/build/flush/JoinRows.d.cts.map +1 -1
- package/build/flush/JoinRows.d.mts +2 -4
- package/build/flush/JoinRows.d.mts.map +1 -1
- package/build/flush/JoinRows.js +10 -10
- package/build/flush/JoinRows.js.map +1 -1
- package/build/flush/PendingChanges.d.cts +0 -2
- package/build/flush/PendingChanges.d.cts.map +1 -1
- package/build/flush/PendingChanges.d.mts +0 -2
- package/build/flush/PendingChanges.d.mts.map +1 -1
- package/build/flush/ReadDrift.cjs +7 -8
- package/build/flush/ReadDrift.cjs.map +1 -1
- package/build/flush/ReadDrift.d.cts +2 -4
- package/build/flush/ReadDrift.d.cts.map +1 -1
- package/build/flush/ReadDrift.d.mts +2 -4
- package/build/flush/ReadDrift.d.mts.map +1 -1
- package/build/flush/ReadDrift.js +7 -8
- package/build/flush/ReadDrift.js.map +1 -1
- package/build/flush/Todo.cjs +3 -4
- package/build/flush/Todo.d.cts +2 -4
- package/build/flush/Todo.d.cts.map +1 -1
- package/build/flush/Todo.d.mts +2 -4
- package/build/flush/Todo.d.mts.map +1 -1
- package/build/flush/Todo.js +3 -4
- package/build/getProperties.cjs +3 -4
- package/build/getProperties.d.cts +0 -2
- package/build/getProperties.d.cts.map +1 -1
- package/build/getProperties.d.mts +0 -2
- package/build/getProperties.d.mts.map +1 -1
- package/build/getProperties.js +3 -4
- package/build/index.cjs +59 -57
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +51 -53
- package/build/index.d.cts.map +1 -1
- package/build/index.d.mts +51 -53
- package/build/index.d.mts.map +1 -1
- package/build/index.js +59 -58
- package/build/index.js.map +1 -1
- package/build/json.cjs +12 -13
- package/build/json.cjs.map +1 -1
- package/build/json.d.cts +5 -7
- package/build/json.d.cts.map +1 -1
- package/build/json.d.mts +5 -7
- package/build/json.d.mts.map +1 -1
- package/build/json.js +12 -13
- package/build/json.js.map +1 -1
- package/build/k.cjs +1 -2
- package/build/k.js +1 -2
- package/build/keys.cjs +5 -6
- package/build/keys.d.cts +3 -5
- package/build/keys.d.cts.map +1 -1
- package/build/keys.d.mts +3 -5
- package/build/keys.d.mts.map +1 -1
- package/build/keys.js +5 -6
- package/build/loading/HintTree.cjs +1 -2
- package/build/loading/HintTree.d.cts +2 -4
- package/build/loading/HintTree.d.cts.map +1 -1
- package/build/loading/HintTree.d.mts +2 -4
- package/build/loading/HintTree.d.mts.map +1 -1
- package/build/loading/HintTree.js +1 -2
- package/build/loading/IsLoadedCache.cjs +1 -2
- package/build/loading/IsLoadedCache.d.cts +0 -2
- package/build/loading/IsLoadedCache.d.cts.map +1 -1
- package/build/loading/IsLoadedCache.d.mts +0 -2
- package/build/loading/IsLoadedCache.d.mts.map +1 -1
- package/build/loading/IsLoadedCache.js +1 -2
- package/build/loading/loadHints.cjs +1 -2
- package/build/loading/loadHints.d.cts +4 -6
- package/build/loading/loadHints.d.cts.map +1 -1
- package/build/loading/loadHints.d.mts +4 -6
- package/build/loading/loadHints.d.mts.map +1 -1
- package/build/loading/loadHints.js +1 -2
- package/build/loading/loadLens.cjs +11 -8
- package/build/loading/loadLens.cjs.map +1 -1
- package/build/loading/loadLens.d.cts +2 -4
- package/build/loading/loadLens.d.cts.map +1 -1
- package/build/loading/loadLens.d.mts +2 -4
- package/build/loading/loadLens.d.mts.map +1 -1
- package/build/loading/loadLens.js +11 -8
- package/build/loading/loadLens.js.map +1 -1
- package/build/loading/withLoaded.cjs +1 -2
- package/build/loading/withLoaded.d.cts +2 -4
- package/build/loading/withLoaded.d.cts.map +1 -1
- package/build/loading/withLoaded.d.mts +2 -4
- package/build/loading/withLoaded.d.mts.map +1 -1
- package/build/loading/withLoaded.js +1 -2
- package/build/logging/FactoryLogger.cjs +2 -3
- package/build/logging/FactoryLogger.d.cts +1 -3
- package/build/logging/FactoryLogger.d.cts.map +1 -1
- package/build/logging/FactoryLogger.d.mts +1 -3
- package/build/logging/FactoryLogger.d.mts.map +1 -1
- package/build/logging/FactoryLogger.js +2 -3
- package/build/logging/FieldLogger.cjs +1 -2
- package/build/logging/FieldLogger.d.cts +0 -2
- package/build/logging/FieldLogger.d.cts.map +1 -1
- package/build/logging/FieldLogger.d.mts +0 -2
- package/build/logging/FieldLogger.d.mts.map +1 -1
- package/build/logging/FieldLogger.js +1 -2
- package/build/logging/ReactionLogger.cjs +3 -4
- package/build/logging/ReactionLogger.d.cts +3 -5
- package/build/logging/ReactionLogger.d.cts.map +1 -1
- package/build/logging/ReactionLogger.d.mts +3 -5
- package/build/logging/ReactionLogger.d.mts.map +1 -1
- package/build/logging/ReactionLogger.js +3 -4
- package/build/metrics/EntityMetrics.cjs +1 -2
- package/build/metrics/EntityMetrics.d.cts +0 -2
- package/build/metrics/EntityMetrics.d.cts.map +1 -1
- package/build/metrics/EntityMetrics.d.mts +0 -2
- package/build/metrics/EntityMetrics.d.mts.map +1 -1
- package/build/metrics/EntityMetrics.js +1 -2
- package/build/newEntity.cjs +5 -6
- package/build/newEntity.cjs.map +1 -1
- package/build/newEntity.d.cts +2 -4
- package/build/newEntity.d.cts.map +1 -1
- package/build/newEntity.d.mts +2 -4
- package/build/newEntity.d.mts.map +1 -1
- package/build/newEntity.js +5 -6
- package/build/newEntity.js.map +1 -1
- package/build/newTestInstance.cjs +9 -10
- package/build/newTestInstance.d.cts +3 -5
- package/build/newTestInstance.d.cts.map +1 -1
- package/build/newTestInstance.d.mts +3 -5
- package/build/newTestInstance.d.mts.map +1 -1
- package/build/newTestInstance.js +9 -10
- package/build/normalizeHints.cjs +1 -2
- package/build/normalizeHints.d.cts +1 -3
- package/build/normalizeHints.d.cts.map +1 -1
- package/build/normalizeHints.d.mts +1 -3
- package/build/normalizeHints.d.mts.map +1 -1
- package/build/normalizeHints.js +1 -2
- package/build/nowUTC.cjs +1 -2
- package/build/nowUTC.d.cts +0 -2
- package/build/nowUTC.d.cts.map +1 -1
- package/build/nowUTC.d.mts +0 -2
- package/build/nowUTC.d.mts.map +1 -1
- package/build/nowUTC.js +1 -2
- package/build/plugins/ImmutableEntitiesPlugin.cjs +3 -4
- package/build/plugins/ImmutableEntitiesPlugin.d.cts +1 -3
- package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.mts +1 -3
- package/build/plugins/ImmutableEntitiesPlugin.d.mts.map +1 -1
- package/build/plugins/ImmutableEntitiesPlugin.js +3 -4
- package/build/plugins/PreloadPlugin.cjs +1 -1
- package/build/plugins/PreloadPlugin.d.cts +4 -6
- package/build/plugins/PreloadPlugin.d.cts.map +1 -1
- package/build/plugins/PreloadPlugin.d.mts +4 -6
- package/build/plugins/PreloadPlugin.d.mts.map +1 -1
- package/build/plugins/PreloadPlugin.js +1 -1
- package/build/preloading/JsonAggregatePreloader.cjs +13 -13
- package/build/preloading/JsonAggregatePreloader.cjs.map +1 -1
- package/build/preloading/JsonAggregatePreloader.d.cts +3 -5
- package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -1
- package/build/preloading/JsonAggregatePreloader.d.mts +3 -5
- package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -1
- package/build/preloading/JsonAggregatePreloader.js +13 -13
- package/build/preloading/JsonAggregatePreloader.js.map +1 -1
- package/build/preloading/canPreload.cjs +1 -2
- package/build/preloading/canPreload.d.cts +0 -2
- package/build/preloading/canPreload.d.cts.map +1 -1
- package/build/preloading/canPreload.d.mts +0 -2
- package/build/preloading/canPreload.d.mts.map +1 -1
- package/build/preloading/canPreload.js +1 -2
- package/build/preloading/partitionHint.cjs +4 -5
- package/build/preloading/partitionHint.d.cts +1 -3
- package/build/preloading/partitionHint.d.cts.map +1 -1
- package/build/preloading/partitionHint.d.mts +1 -3
- package/build/preloading/partitionHint.d.mts.map +1 -1
- package/build/preloading/partitionHint.js +4 -5
- package/build/queries/ConditionBuilder.cjs +2 -3
- package/build/queries/ConditionBuilder.d.cts +1 -3
- package/build/queries/ConditionBuilder.d.cts.map +1 -1
- package/build/queries/ConditionBuilder.d.mts +1 -3
- package/build/queries/ConditionBuilder.d.mts.map +1 -1
- package/build/queries/ConditionBuilder.js +2 -3
- package/build/queries/conditions.cjs +1 -2
- package/build/queries/conditions.d.cts +0 -2
- package/build/queries/conditions.d.cts.map +1 -1
- package/build/queries/conditions.d.mts +0 -2
- package/build/queries/conditions.d.mts.map +1 -1
- package/build/queries/conditions.js +1 -2
- package/build/queries/entityQueryUtils.cjs +2 -3
- package/build/queries/entityQueryUtils.d.cts +1 -3
- package/build/queries/entityQueryUtils.d.cts.map +1 -1
- package/build/queries/entityQueryUtils.d.mts +1 -3
- package/build/queries/entityQueryUtils.d.mts.map +1 -1
- package/build/queries/entityQueryUtils.js +2 -3
- package/build/queries/find/Aliases.cjs +4 -5
- package/build/queries/find/Aliases.d.cts +5 -7
- package/build/queries/find/Aliases.d.cts.map +1 -1
- package/build/queries/find/Aliases.d.mts +5 -7
- package/build/queries/find/Aliases.d.mts.map +1 -1
- package/build/queries/find/Aliases.js +4 -5
- package/build/queries/find/DeferredAlias.cjs +1 -2
- package/build/queries/find/DeferredAlias.d.cts +2 -4
- package/build/queries/find/DeferredAlias.d.cts.map +1 -1
- package/build/queries/find/DeferredAlias.d.mts +2 -4
- package/build/queries/find/DeferredAlias.d.mts.map +1 -1
- package/build/queries/find/DeferredAlias.js +1 -2
- package/build/queries/find/EntityFilter.cjs +1 -2
- package/build/queries/find/EntityFilter.d.cts +3 -5
- package/build/queries/find/EntityFilter.d.cts.map +1 -1
- package/build/queries/find/EntityFilter.d.mts +3 -5
- package/build/queries/find/EntityFilter.d.mts.map +1 -1
- package/build/queries/find/EntityFilter.js +1 -2
- package/build/queries/find/EntityGraphQLFilter.cjs +1 -2
- package/build/queries/find/EntityGraphQLFilter.d.cts +2 -4
- package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -1
- package/build/queries/find/EntityGraphQLFilter.d.mts +2 -4
- package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -1
- package/build/queries/find/EntityGraphQLFilter.js +1 -2
- package/build/queries/find/QueryParser.cjs +9 -10
- package/build/queries/find/QueryParser.cjs.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.cjs +1 -2
- package/build/queries/find/QueryParser.collectionJoins.d.cts +0 -2
- package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.d.mts +0 -2
- package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.js +1 -2
- package/build/queries/find/QueryParser.d.cts +4 -4
- package/build/queries/find/QueryParser.d.cts.map +1 -1
- package/build/queries/find/QueryParser.d.mts +4 -4
- package/build/queries/find/QueryParser.d.mts.map +1 -1
- package/build/queries/find/QueryParser.js +9 -10
- package/build/queries/find/QueryParser.js.map +1 -1
- package/build/queries/find/QueryParser.pruning.cjs +2 -3
- package/build/queries/find/QueryParser.pruning.d.cts +0 -2
- package/build/queries/find/QueryParser.pruning.d.cts.map +1 -1
- package/build/queries/find/QueryParser.pruning.d.mts +0 -2
- package/build/queries/find/QueryParser.pruning.d.mts.map +1 -1
- package/build/queries/find/QueryParser.pruning.js +2 -3
- package/build/queries/find/QueryVisitor.cjs +1 -2
- package/build/queries/find/QueryVisitor.d.cts +0 -2
- package/build/queries/find/QueryVisitor.d.cts.map +1 -1
- package/build/queries/find/QueryVisitor.d.mts +0 -2
- package/build/queries/find/QueryVisitor.d.mts.map +1 -1
- package/build/queries/find/QueryVisitor.js +1 -2
- package/build/queries/find/buildFindQuery.cjs +5 -6
- package/build/queries/find/buildFindQuery.cjs.map +1 -1
- package/build/queries/find/buildFindQuery.d.cts +0 -2
- package/build/queries/find/buildFindQuery.d.cts.map +1 -1
- package/build/queries/find/buildFindQuery.d.mts +0 -2
- package/build/queries/find/buildFindQuery.d.mts.map +1 -1
- package/build/queries/find/buildFindQuery.js +5 -6
- package/build/queries/find/buildFindQuery.js.map +1 -1
- package/build/queries/find/scopes.cjs +1 -2
- package/build/queries/find/scopes.d.cts +5 -7
- package/build/queries/find/scopes.d.cts.map +1 -1
- package/build/queries/find/scopes.d.mts +5 -7
- package/build/queries/find/scopes.d.mts.map +1 -1
- package/build/queries/find/scopes.js +1 -2
- package/build/queries/parsedConditions.cjs +1 -2
- package/build/queries/parsedConditions.d.cts +0 -2
- package/build/queries/parsedConditions.d.cts.map +1 -1
- package/build/queries/parsedConditions.d.mts +0 -2
- package/build/queries/parsedConditions.d.mts.map +1 -1
- package/build/queries/parsedConditions.js +1 -2
- package/build/queries/renderConditions.cjs +3 -4
- package/build/queries/renderConditions.d.cts +0 -2
- package/build/queries/renderConditions.d.cts.map +1 -1
- package/build/queries/renderConditions.d.mts +0 -2
- package/build/queries/renderConditions.d.mts.map +1 -1
- package/build/queries/renderConditions.js +3 -4
- package/build/queries/skipCondition.cjs +1 -2
- package/build/queries/skipCondition.d.cts +0 -2
- package/build/queries/skipCondition.d.cts.map +1 -1
- package/build/queries/skipCondition.d.mts +0 -2
- package/build/queries/skipCondition.d.mts.map +1 -1
- package/build/queries/skipCondition.js +1 -2
- package/build/queries/sql/AliasAssigner.cjs +1 -2
- package/build/queries/sql/AliasAssigner.d.cts +0 -2
- package/build/queries/sql/AliasAssigner.d.cts.map +1 -1
- package/build/queries/sql/AliasAssigner.d.mts +0 -2
- package/build/queries/sql/AliasAssigner.d.mts.map +1 -1
- package/build/queries/sql/AliasAssigner.js +1 -2
- package/build/queries/sql/Expr.cjs +3 -4
- package/build/queries/sql/Expr.d.cts +2 -4
- package/build/queries/sql/Expr.d.cts.map +1 -1
- package/build/queries/sql/Expr.d.mts +2 -4
- package/build/queries/sql/Expr.d.mts.map +1 -1
- package/build/queries/sql/Expr.js +3 -4
- package/build/queries/sql/JoinTree.cjs +3 -4
- package/build/queries/sql/JoinTree.d.cts +5 -7
- package/build/queries/sql/JoinTree.d.cts.map +1 -1
- package/build/queries/sql/JoinTree.d.mts +5 -7
- package/build/queries/sql/JoinTree.d.mts.map +1 -1
- package/build/queries/sql/JoinTree.js +3 -4
- package/build/queries/sql/Tables.cjs +8 -9
- package/build/queries/sql/Tables.d.cts +5 -7
- package/build/queries/sql/Tables.d.cts.map +1 -1
- package/build/queries/sql/Tables.d.mts +5 -7
- package/build/queries/sql/Tables.d.mts.map +1 -1
- package/build/queries/sql/Tables.js +8 -9
- package/build/queries/sql/custom.cjs +1 -2
- package/build/queries/sql/custom.d.cts +2 -4
- package/build/queries/sql/custom.d.cts.map +1 -1
- package/build/queries/sql/custom.d.mts +2 -4
- package/build/queries/sql/custom.d.mts.map +1 -1
- package/build/queries/sql/custom.js +1 -2
- package/build/queries/sql/execute.cjs +6 -7
- package/build/queries/sql/execute.d.cts +6 -8
- package/build/queries/sql/execute.d.cts.map +1 -1
- package/build/queries/sql/execute.d.mts +6 -8
- package/build/queries/sql/execute.d.mts.map +1 -1
- package/build/queries/sql/execute.js +6 -7
- package/build/queries/sql/expressions/arrayAgg.cjs +2 -3
- package/build/queries/sql/expressions/arrayAgg.d.cts +1 -3
- package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -1
- package/build/queries/sql/expressions/arrayAgg.d.mts +1 -3
- package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -1
- package/build/queries/sql/expressions/arrayAgg.js +2 -3
- package/build/queries/sql/expressions/case.cjs +2 -3
- package/build/queries/sql/expressions/case.d.cts +1 -3
- package/build/queries/sql/expressions/case.d.cts.map +1 -1
- package/build/queries/sql/expressions/case.d.mts +1 -3
- package/build/queries/sql/expressions/case.d.mts.map +1 -1
- package/build/queries/sql/expressions/case.js +2 -3
- package/build/queries/sql/expressions/coalesce.cjs +2 -3
- package/build/queries/sql/expressions/coalesce.d.cts +1 -3
- package/build/queries/sql/expressions/coalesce.d.cts.map +1 -1
- package/build/queries/sql/expressions/coalesce.d.mts +1 -3
- package/build/queries/sql/expressions/coalesce.d.mts.map +1 -1
- package/build/queries/sql/expressions/coalesce.js +2 -3
- package/build/queries/sql/expressions/codecs.cjs +2 -3
- package/build/queries/sql/expressions/codecs.d.cts +0 -2
- package/build/queries/sql/expressions/codecs.d.cts.map +1 -1
- package/build/queries/sql/expressions/codecs.d.mts +0 -2
- package/build/queries/sql/expressions/codecs.d.mts.map +1 -1
- package/build/queries/sql/expressions/codecs.js +2 -3
- package/build/queries/sql/expressions/expression.cjs +4 -5
- package/build/queries/sql/expressions/expression.d.cts +2 -4
- package/build/queries/sql/expressions/expression.d.cts.map +1 -1
- package/build/queries/sql/expressions/expression.d.mts +2 -4
- package/build/queries/sql/expressions/expression.d.mts.map +1 -1
- package/build/queries/sql/expressions/expression.js +4 -5
- package/build/queries/sql/expressions/greatest.cjs +2 -3
- package/build/queries/sql/expressions/greatest.d.cts +1 -3
- package/build/queries/sql/expressions/greatest.d.cts.map +1 -1
- package/build/queries/sql/expressions/greatest.d.mts +1 -3
- package/build/queries/sql/expressions/greatest.d.mts.map +1 -1
- package/build/queries/sql/expressions/greatest.js +2 -3
- package/build/queries/sql/expressions/least.cjs +2 -3
- package/build/queries/sql/expressions/least.d.cts +1 -3
- package/build/queries/sql/expressions/least.d.cts.map +1 -1
- package/build/queries/sql/expressions/least.d.mts +1 -3
- package/build/queries/sql/expressions/least.d.mts.map +1 -1
- package/build/queries/sql/expressions/least.js +2 -3
- package/build/queries/sql/expressions/nullIf.cjs +2 -3
- package/build/queries/sql/expressions/nullIf.d.cts +1 -3
- package/build/queries/sql/expressions/nullIf.d.cts.map +1 -1
- package/build/queries/sql/expressions/nullIf.d.mts +1 -3
- package/build/queries/sql/expressions/nullIf.d.mts.map +1 -1
- package/build/queries/sql/expressions/nullIf.js +2 -3
- package/build/queries/sql/expressions/parseExpression.cjs +3 -4
- package/build/queries/sql/expressions/parseExpression.d.cts +0 -2
- package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -1
- package/build/queries/sql/expressions/parseExpression.d.mts +0 -2
- package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -1
- package/build/queries/sql/expressions/parseExpression.js +3 -4
- package/build/queries/sql/expressions/types.d.cts +1 -3
- package/build/queries/sql/expressions/types.d.cts.map +1 -1
- package/build/queries/sql/expressions/types.d.mts +1 -3
- package/build/queries/sql/expressions/types.d.mts.map +1 -1
- package/build/queries/sql/keywords.cjs +1 -2
- package/build/queries/sql/keywords.d.cts +0 -2
- package/build/queries/sql/keywords.d.cts.map +1 -1
- package/build/queries/sql/keywords.d.mts +0 -2
- package/build/queries/sql/keywords.d.mts.map +1 -1
- package/build/queries/sql/keywords.js +1 -2
- package/build/queries/sql/query.cjs +9 -10
- package/build/queries/sql/query.d.cts +6 -8
- package/build/queries/sql/query.d.cts.map +1 -1
- package/build/queries/sql/query.d.mts +6 -8
- package/build/queries/sql/query.d.mts.map +1 -1
- package/build/queries/sql/query.js +9 -10
- package/build/queries/unnest.cjs +1 -2
- package/build/queries/unnest.d.cts +1 -3
- package/build/queries/unnest.d.cts.map +1 -1
- package/build/queries/unnest.d.mts +1 -3
- package/build/queries/unnest.d.mts.map +1 -1
- package/build/queries/unnest.js +1 -2
- package/build/queries/valueFilters.cjs +3 -4
- package/build/queries/valueFilters.d.cts +2 -4
- package/build/queries/valueFilters.d.cts.map +1 -1
- package/build/queries/valueFilters.d.mts +2 -4
- package/build/queries/valueFilters.d.mts.map +1 -1
- package/build/queries/valueFilters.js +3 -4
- package/build/reactivity/ReactionsManager.cjs +6 -7
- package/build/reactivity/ReactionsManager.d.cts +2 -4
- package/build/reactivity/ReactionsManager.d.cts.map +1 -1
- package/build/reactivity/ReactionsManager.d.mts +2 -4
- package/build/reactivity/ReactionsManager.d.mts.map +1 -1
- package/build/reactivity/ReactionsManager.js +6 -7
- package/build/reactivity/reactiveHints.cjs +8 -9
- package/build/reactivity/reactiveHints.d.cts +8 -10
- package/build/reactivity/reactiveHints.d.cts.map +1 -1
- package/build/reactivity/reactiveHints.d.mts +8 -10
- package/build/reactivity/reactiveHints.d.mts.map +1 -1
- package/build/reactivity/reactiveHints.js +8 -9
- package/build/relations/AbstractPropertyImpl.cjs +1 -2
- package/build/relations/AbstractPropertyImpl.d.cts +0 -2
- package/build/relations/AbstractPropertyImpl.d.cts.map +1 -1
- package/build/relations/AbstractPropertyImpl.d.mts +0 -2
- package/build/relations/AbstractPropertyImpl.d.mts.map +1 -1
- package/build/relations/AbstractPropertyImpl.js +1 -2
- package/build/relations/AbstractRelationImpl.cjs +1 -2
- package/build/relations/AbstractRelationImpl.d.cts +0 -2
- package/build/relations/AbstractRelationImpl.d.cts.map +1 -1
- package/build/relations/AbstractRelationImpl.d.mts +0 -2
- package/build/relations/AbstractRelationImpl.d.mts.map +1 -1
- package/build/relations/AbstractRelationImpl.js +1 -2
- package/build/relations/AsyncProperty.cjs +3 -4
- package/build/relations/AsyncProperty.d.cts +2 -4
- package/build/relations/AsyncProperty.d.cts.map +1 -1
- package/build/relations/AsyncProperty.d.mts +2 -4
- package/build/relations/AsyncProperty.d.mts.map +1 -1
- package/build/relations/AsyncProperty.js +3 -4
- package/build/relations/AsyncReactiveField.cjs +10 -11
- package/build/relations/AsyncReactiveField.d.cts +4 -6
- package/build/relations/AsyncReactiveField.d.cts.map +1 -1
- package/build/relations/AsyncReactiveField.d.mts +4 -6
- package/build/relations/AsyncReactiveField.d.mts.map +1 -1
- package/build/relations/AsyncReactiveField.js +10 -11
- package/build/relations/Collection.cjs +3 -4
- package/build/relations/Collection.d.cts +2 -4
- package/build/relations/Collection.d.cts.map +1 -1
- package/build/relations/Collection.d.mts +2 -4
- package/build/relations/Collection.d.mts.map +1 -1
- package/build/relations/Collection.js +3 -4
- package/build/relations/CustomCollection.cjs +40 -8
- package/build/relations/CustomCollection.cjs.map +1 -1
- package/build/relations/CustomCollection.d.cts +6 -6
- package/build/relations/CustomCollection.d.cts.map +1 -1
- package/build/relations/CustomCollection.d.mts +6 -6
- package/build/relations/CustomCollection.d.mts.map +1 -1
- package/build/relations/CustomCollection.js +40 -8
- package/build/relations/CustomCollection.js.map +1 -1
- package/build/relations/CustomReference.cjs +36 -8
- package/build/relations/CustomReference.cjs.map +1 -1
- package/build/relations/CustomReference.d.cts +8 -8
- package/build/relations/CustomReference.d.cts.map +1 -1
- package/build/relations/CustomReference.d.mts +8 -8
- package/build/relations/CustomReference.d.mts.map +1 -1
- package/build/relations/CustomReference.js +36 -8
- package/build/relations/CustomReference.js.map +1 -1
- package/build/relations/EnumCollection.cjs +4 -5
- package/build/relations/EnumCollection.d.cts +3 -5
- package/build/relations/EnumCollection.d.cts.map +1 -1
- package/build/relations/EnumCollection.d.mts +3 -5
- package/build/relations/EnumCollection.d.mts.map +1 -1
- package/build/relations/EnumCollection.js +4 -5
- package/build/relations/LargeCollection.cjs +2 -2
- package/build/relations/LargeCollection.d.cts +2 -4
- package/build/relations/LargeCollection.d.cts.map +1 -1
- package/build/relations/LargeCollection.d.mts +2 -4
- package/build/relations/LargeCollection.d.mts.map +1 -1
- package/build/relations/LargeCollection.js +2 -2
- package/build/relations/LazyField.cjs +14 -15
- package/build/relations/LazyField.cjs.map +1 -1
- package/build/relations/LazyField.d.cts +2 -4
- package/build/relations/LazyField.d.cts.map +1 -1
- package/build/relations/LazyField.d.mts +2 -4
- package/build/relations/LazyField.d.mts.map +1 -1
- package/build/relations/LazyField.js +14 -15
- package/build/relations/LazyField.js.map +1 -1
- package/build/relations/ManyToManyCollection.cjs +68 -13
- package/build/relations/ManyToManyCollection.cjs.map +1 -1
- package/build/relations/ManyToManyCollection.d.cts +2 -4
- package/build/relations/ManyToManyCollection.d.cts.map +1 -1
- package/build/relations/ManyToManyCollection.d.mts +2 -4
- package/build/relations/ManyToManyCollection.d.mts.map +1 -1
- package/build/relations/ManyToManyCollection.js +68 -13
- package/build/relations/ManyToManyCollection.js.map +1 -1
- package/build/relations/ManyToManyLargeCollection.cjs +35 -13
- package/build/relations/ManyToManyLargeCollection.cjs.map +1 -1
- package/build/relations/ManyToManyLargeCollection.d.cts +6 -8
- package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -1
- package/build/relations/ManyToManyLargeCollection.d.mts +6 -8
- package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -1
- package/build/relations/ManyToManyLargeCollection.js +35 -13
- package/build/relations/ManyToManyLargeCollection.js.map +1 -1
- package/build/relations/ManyToOneReference.cjs +35 -19
- package/build/relations/ManyToOneReference.cjs.map +1 -1
- package/build/relations/ManyToOneReference.d.cts +6 -8
- package/build/relations/ManyToOneReference.d.cts.map +1 -1
- package/build/relations/ManyToOneReference.d.mts +6 -8
- package/build/relations/ManyToOneReference.d.mts.map +1 -1
- package/build/relations/ManyToOneReference.js +35 -19
- package/build/relations/ManyToOneReference.js.map +1 -1
- package/build/relations/OneToManyCollection.cjs +71 -15
- package/build/relations/OneToManyCollection.cjs.map +1 -1
- package/build/relations/OneToManyCollection.d.cts +3 -5
- package/build/relations/OneToManyCollection.d.cts.map +1 -1
- package/build/relations/OneToManyCollection.d.mts +3 -5
- package/build/relations/OneToManyCollection.d.mts.map +1 -1
- package/build/relations/OneToManyCollection.js +71 -15
- package/build/relations/OneToManyCollection.js.map +1 -1
- package/build/relations/OneToManyLargeCollection.cjs +25 -10
- package/build/relations/OneToManyLargeCollection.cjs.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.cts +4 -6
- package/build/relations/OneToManyLargeCollection.d.cts.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.mts +4 -6
- package/build/relations/OneToManyLargeCollection.d.mts.map +1 -1
- package/build/relations/OneToManyLargeCollection.js +25 -10
- package/build/relations/OneToManyLargeCollection.js.map +1 -1
- package/build/relations/OneToOneReference.cjs +41 -13
- package/build/relations/OneToOneReference.cjs.map +1 -1
- package/build/relations/OneToOneReference.d.cts +6 -8
- package/build/relations/OneToOneReference.d.cts.map +1 -1
- package/build/relations/OneToOneReference.d.mts +6 -8
- package/build/relations/OneToOneReference.d.mts.map +1 -1
- package/build/relations/OneToOneReference.js +41 -13
- package/build/relations/OneToOneReference.js.map +1 -1
- package/build/relations/PolymorphicReference.cjs +33 -17
- package/build/relations/PolymorphicReference.cjs.map +1 -1
- package/build/relations/PolymorphicReference.d.cts +5 -7
- package/build/relations/PolymorphicReference.d.cts.map +1 -1
- package/build/relations/PolymorphicReference.d.mts +5 -7
- package/build/relations/PolymorphicReference.d.mts.map +1 -1
- package/build/relations/PolymorphicReference.js +33 -17
- package/build/relations/PolymorphicReference.js.map +1 -1
- package/build/relations/PropertySymbols.cjs +1 -2
- package/build/relations/PropertySymbols.d.cts +0 -2
- package/build/relations/PropertySymbols.d.cts.map +1 -1
- package/build/relations/PropertySymbols.d.mts +0 -2
- package/build/relations/PropertySymbols.d.mts.map +1 -1
- package/build/relations/PropertySymbols.js +1 -2
- package/build/relations/ReactiveField.cjs +9 -10
- package/build/relations/ReactiveField.d.cts +4 -6
- package/build/relations/ReactiveField.d.cts.map +1 -1
- package/build/relations/ReactiveField.d.mts +4 -6
- package/build/relations/ReactiveField.d.mts.map +1 -1
- package/build/relations/ReactiveField.js +9 -10
- package/build/relations/ReactiveGetter.cjs +2 -3
- package/build/relations/ReactiveGetter.d.cts +2 -4
- package/build/relations/ReactiveGetter.d.cts.map +1 -1
- package/build/relations/ReactiveGetter.d.mts +2 -4
- package/build/relations/ReactiveGetter.d.mts.map +1 -1
- package/build/relations/ReactiveGetter.js +2 -3
- package/build/relations/ReactiveManyToMany.cjs +59 -17
- package/build/relations/ReactiveManyToMany.cjs.map +1 -1
- package/build/relations/ReactiveManyToMany.d.cts +7 -6
- package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
- package/build/relations/ReactiveManyToMany.d.mts +7 -6
- package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
- package/build/relations/ReactiveManyToMany.js +59 -17
- package/build/relations/ReactiveManyToMany.js.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.cjs +41 -10
- package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.cts +4 -6
- package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.mts +4 -6
- package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.js +41 -10
- package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
- package/build/relations/ReactiveReference.cjs +29 -12
- package/build/relations/ReactiveReference.cjs.map +1 -1
- package/build/relations/ReactiveReference.d.cts +7 -9
- package/build/relations/ReactiveReference.d.cts.map +1 -1
- package/build/relations/ReactiveReference.d.mts +7 -9
- package/build/relations/ReactiveReference.d.mts.map +1 -1
- package/build/relations/ReactiveReference.js +29 -12
- package/build/relations/ReactiveReference.js.map +1 -1
- package/build/relations/ReadOnlyCollection.cjs +3 -4
- package/build/relations/ReadOnlyCollection.d.cts +1 -3
- package/build/relations/ReadOnlyCollection.d.cts.map +1 -1
- package/build/relations/ReadOnlyCollection.d.mts +1 -3
- package/build/relations/ReadOnlyCollection.d.mts.map +1 -1
- package/build/relations/ReadOnlyCollection.js +3 -4
- package/build/relations/RecursiveCollection.cjs +60 -11
- package/build/relations/RecursiveCollection.cjs.map +1 -1
- package/build/relations/RecursiveCollection.d.cts +3 -5
- package/build/relations/RecursiveCollection.d.cts.map +1 -1
- package/build/relations/RecursiveCollection.d.mts +3 -5
- package/build/relations/RecursiveCollection.d.mts.map +1 -1
- package/build/relations/RecursiveCollection.js +60 -11
- package/build/relations/RecursiveCollection.js.map +1 -1
- package/build/relations/RecursiveCycleError.cjs +1 -2
- package/build/relations/RecursiveCycleError.d.cts +0 -2
- package/build/relations/RecursiveCycleError.d.cts.map +1 -1
- package/build/relations/RecursiveCycleError.d.mts +0 -2
- package/build/relations/RecursiveCycleError.d.mts.map +1 -1
- package/build/relations/RecursiveCycleError.js +1 -2
- package/build/relations/Reference.cjs +4 -5
- package/build/relations/Reference.d.cts +3 -5
- package/build/relations/Reference.d.cts.map +1 -1
- package/build/relations/Reference.d.mts +3 -5
- package/build/relations/Reference.d.mts.map +1 -1
- package/build/relations/Reference.js +4 -5
- package/build/relations/ReferenceSymbols.cjs +1 -2
- package/build/relations/ReferenceSymbols.d.cts +0 -2
- package/build/relations/ReferenceSymbols.d.cts.map +1 -1
- package/build/relations/ReferenceSymbols.d.mts +0 -2
- package/build/relations/ReferenceSymbols.d.mts.map +1 -1
- package/build/relations/ReferenceSymbols.js +1 -2
- package/build/relations/Relation.cjs +3 -4
- package/build/relations/Relation.d.cts +1 -3
- package/build/relations/Relation.d.cts.map +1 -1
- package/build/relations/Relation.d.mts +1 -3
- package/build/relations/Relation.d.mts.map +1 -1
- package/build/relations/Relation.js +3 -4
- package/build/relations/RelationSymbols.cjs +1 -2
- package/build/relations/RelationSymbols.d.cts +0 -2
- package/build/relations/RelationSymbols.d.cts.map +1 -1
- package/build/relations/RelationSymbols.d.mts +0 -2
- package/build/relations/RelationSymbols.d.mts.map +1 -1
- package/build/relations/RelationSymbols.js +1 -2
- package/build/relations/hasAsyncMethod.cjs +6 -7
- package/build/relations/hasAsyncMethod.d.cts +2 -4
- package/build/relations/hasAsyncMethod.d.cts.map +1 -1
- package/build/relations/hasAsyncMethod.d.mts +2 -4
- package/build/relations/hasAsyncMethod.d.mts.map +1 -1
- package/build/relations/hasAsyncMethod.js +6 -7
- package/build/relations/hasManyDerived.cjs +5 -6
- package/build/relations/hasManyDerived.cjs.map +1 -1
- package/build/relations/hasManyDerived.d.cts +2 -4
- package/build/relations/hasManyDerived.d.cts.map +1 -1
- package/build/relations/hasManyDerived.d.mts +2 -4
- package/build/relations/hasManyDerived.d.mts.map +1 -1
- package/build/relations/hasManyDerived.js +5 -6
- package/build/relations/hasManyDerived.js.map +1 -1
- package/build/relations/hasManyThrough.cjs +4 -5
- package/build/relations/hasManyThrough.cjs.map +1 -1
- package/build/relations/hasManyThrough.d.cts +0 -2
- package/build/relations/hasManyThrough.d.cts.map +1 -1
- package/build/relations/hasManyThrough.d.mts +0 -2
- package/build/relations/hasManyThrough.d.mts.map +1 -1
- package/build/relations/hasManyThrough.js +4 -5
- package/build/relations/hasManyThrough.js.map +1 -1
- package/build/relations/hasOneDerived.cjs +5 -6
- package/build/relations/hasOneDerived.cjs.map +1 -1
- package/build/relations/hasOneDerived.d.cts +2 -4
- package/build/relations/hasOneDerived.d.cts.map +1 -1
- package/build/relations/hasOneDerived.d.mts +2 -4
- package/build/relations/hasOneDerived.d.mts.map +1 -1
- package/build/relations/hasOneDerived.js +5 -6
- package/build/relations/hasOneDerived.js.map +1 -1
- package/build/relations/hasOneThrough.cjs +4 -5
- package/build/relations/hasOneThrough.cjs.map +1 -1
- package/build/relations/hasOneThrough.d.cts +0 -2
- package/build/relations/hasOneThrough.d.cts.map +1 -1
- package/build/relations/hasOneThrough.d.mts +0 -2
- package/build/relations/hasOneThrough.d.mts.map +1 -1
- package/build/relations/hasOneThrough.js +4 -5
- package/build/relations/hasOneThrough.js.map +1 -1
- package/build/relations/hasProperty.cjs +5 -6
- package/build/relations/hasProperty.d.cts +2 -4
- package/build/relations/hasProperty.d.cts.map +1 -1
- package/build/relations/hasProperty.d.mts +2 -4
- package/build/relations/hasProperty.d.mts.map +1 -1
- package/build/relations/hasProperty.js +5 -6
- package/build/relations/hasReactiveAsyncMethod.cjs +5 -6
- package/build/relations/hasReactiveAsyncMethod.d.cts +3 -5
- package/build/relations/hasReactiveAsyncMethod.d.cts.map +1 -1
- package/build/relations/hasReactiveAsyncMethod.d.mts +3 -5
- package/build/relations/hasReactiveAsyncMethod.d.mts.map +1 -1
- package/build/relations/hasReactiveAsyncMethod.js +5 -6
- package/build/relations/index.cjs +9 -9
- package/build/relations/index.d.cts +3 -3
- package/build/relations/index.d.mts +3 -3
- package/build/relations/index.js +9 -9
- package/build/relations/isCascadeDelete.cjs +1 -2
- package/build/relations/isCascadeDelete.d.cts +0 -2
- package/build/relations/isCascadeDelete.d.cts.map +1 -1
- package/build/relations/isCascadeDelete.d.mts +0 -2
- package/build/relations/isCascadeDelete.d.mts.map +1 -1
- package/build/relations/isCascadeDelete.js +1 -2
- package/build/relations/relationVisibility.cjs +51 -0
- package/build/relations/relationVisibility.cjs.map +1 -0
- package/build/relations/relationVisibility.d.cts +10 -0
- package/build/relations/relationVisibility.d.cts.map +1 -0
- package/build/relations/relationVisibility.d.mts +10 -0
- package/build/relations/relationVisibility.d.mts.map +1 -0
- package/build/relations/relationVisibility.js +47 -0
- package/build/relations/relationVisibility.js.map +1 -0
- package/build/resurrection.cjs +4 -5
- package/build/resurrection.d.cts +2 -4
- package/build/resurrection.d.cts.map +1 -1
- package/build/resurrection.d.mts +2 -4
- package/build/resurrection.d.mts.map +1 -1
- package/build/resurrection.js +4 -5
- package/build/rules.cjs +6 -7
- package/build/rules.d.cts +3 -5
- package/build/rules.d.cts.map +1 -1
- package/build/rules.d.mts +3 -5
- package/build/rules.d.mts.map +1 -1
- package/build/rules.js +6 -7
- package/build/runtimeConfig.cjs +1 -2
- package/build/runtimeConfig.d.cts +0 -2
- package/build/runtimeConfig.d.cts.map +1 -1
- package/build/runtimeConfig.d.mts +0 -2
- package/build/runtimeConfig.d.mts.map +1 -1
- package/build/runtimeConfig.js +1 -2
- package/build/serde/TypeInfo.cjs +1 -2
- package/build/serde/TypeInfo.d.cts +0 -2
- package/build/serde/TypeInfo.d.cts.map +1 -1
- package/build/serde/TypeInfo.d.mts +0 -2
- package/build/serde/TypeInfo.d.mts.map +1 -1
- package/build/serde/TypeInfo.js +1 -2
- package/build/serde/columns.cjs +1 -2
- package/build/serde/columns.d.cts +2 -4
- package/build/serde/columns.d.cts.map +1 -1
- package/build/serde/columns.d.mts +2 -4
- package/build/serde/columns.d.mts.map +1 -1
- package/build/serde/columns.js +1 -2
- package/build/serde/fieldSerde.cjs +4 -5
- package/build/serde/fieldSerde.d.cts +4 -6
- package/build/serde/fieldSerde.d.cts.map +1 -1
- package/build/serde/fieldSerde.d.mts +4 -6
- package/build/serde/fieldSerde.d.mts.map +1 -1
- package/build/serde/fieldSerde.js +4 -5
- package/build/serde/serde.cjs +4 -5
- package/build/serde/serde.cjs.map +1 -1
- package/build/serde/serde.d.cts +0 -2
- package/build/serde/serde.d.cts.map +1 -1
- package/build/serde/serde.d.mts +0 -2
- package/build/serde/serde.d.mts.map +1 -1
- package/build/serde/serde.js +4 -5
- package/build/serde/temporal.cjs +1 -2
- package/build/serde/temporal.cjs.map +1 -1
- package/build/serde/temporal.d.cts +0 -2
- package/build/serde/temporal.d.cts.map +1 -1
- package/build/serde/temporal.d.mts +0 -2
- package/build/serde/temporal.d.mts.map +1 -1
- package/build/serde/temporal.js +1 -2
- package/build/serde/temporalMappers.cjs +1 -2
- package/build/serde/temporalMappers.d.cts +1 -3
- package/build/serde/temporalMappers.d.cts.map +1 -1
- package/build/serde/temporalMappers.d.mts +1 -3
- package/build/serde/temporalMappers.d.mts.map +1 -1
- package/build/serde/temporalMappers.js +1 -2
- package/build/transitions.cjs +2 -3
- package/build/transitions.d.cts +3 -5
- package/build/transitions.d.cts.map +1 -1
- package/build/transitions.d.mts +3 -5
- package/build/transitions.d.mts.map +1 -1
- package/build/transitions.js +2 -3
- package/build/trusted.cjs +1 -2
- package/build/trusted.cjs.map +1 -1
- package/build/trusted.d.cts +0 -2
- package/build/trusted.d.cts.map +1 -1
- package/build/trusted.d.mts +0 -2
- package/build/trusted.d.mts.map +1 -1
- package/build/trusted.js +1 -2
- package/build/typeMap.cjs +1 -1
- package/build/typeMap.d.cts +1 -3
- package/build/typeMap.d.cts.map +1 -1
- package/build/typeMap.d.mts +1 -3
- package/build/typeMap.d.mts.map +1 -1
- package/build/typeMap.js +1 -1
- package/build/upsert.cjs +7 -8
- package/build/upsert.d.cts +3 -5
- package/build/upsert.d.cts.map +1 -1
- package/build/upsert.d.mts +3 -5
- package/build/upsert.d.mts.map +1 -1
- package/build/upsert.js +7 -8
- package/build/utils.cjs +3 -4
- package/build/utils.d.cts +2 -4
- package/build/utils.d.cts.map +1 -1
- package/build/utils.d.mts +2 -4
- package/build/utils.d.mts.map +1 -1
- package/build/utils.js +3 -4
- package/package.json +6 -6
package/build/EntityMetadata.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_BaseEntity = require("./BaseEntity.cjs");
|
|
2
3
|
const require_configure = require("./configure.cjs");
|
|
3
|
-
require("./EntityManager.cjs");
|
|
4
4
|
const require_Entity = require("./Entity.cjs");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
require("./EntityManager.cjs");
|
|
6
|
+
// src/EntityMetadata.ts
|
|
7
7
|
function getMetadata(param) {
|
|
8
8
|
if (!param) throw new Error(`Cannot getMetadata of ${param}`);
|
|
9
9
|
return typeof param === "function" ? param.metadata : "cstr" in param ? param : require_BaseEntity.getInstanceData(param).metadata;
|
|
@@ -55,7 +55,6 @@ function getBaseMeta(meta) {
|
|
|
55
55
|
if (!meta.baseType) return meta;
|
|
56
56
|
else return meta.baseTypes[0];
|
|
57
57
|
}
|
|
58
|
-
//#endregion
|
|
59
58
|
exports.getBaseAndSelfMetas = getBaseAndSelfMetas;
|
|
60
59
|
exports.getBaseMeta = getBaseMeta;
|
|
61
60
|
exports.getBaseSelfAndSubMetas = getBaseSelfAndSubMetas;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityMetadata.cjs","names":["getInstanceData","getMetadataForType","isEntity"],"sources":["../src/EntityMetadata.ts"],"sourcesContent":["import { getInstanceData } from \"src/BaseEntity.ts\";\nimport type { ConfigApi, Reactable, ReactiveRule } from \"src/config.ts\";\nimport { getMetadataForType } from \"src/configure.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityManager, type MaybeAbstractEntityConstructor, type TimestampFields } from \"src/EntityManager.ts\";\nimport { type EnumMetadata } from \"src/EnumMetadata.ts\";\nimport type { DeepNew } from \"src/loading/loadHints.ts\";\nimport type { SimpleRule } from \"src/rules.ts\";\nimport type { Column, ColumnDescriptors } from \"src/serde/columns.ts\";\nimport type { FieldSerde, PolymorphicKeySerde } from \"src/serde/fieldSerde.ts\";\nimport type { FieldTransitions } from \"src/transitions.ts\";\n\nexport function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;\nexport function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;\nexport function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;\nexport function getMetadata<T extends Entity>(\n param: T | MaybeAbstractEntityConstructor<T> | EntityMetadata,\n): EntityMetadata {\n if (!param) throw new Error(`Cannot getMetadata of ${param}`);\n return (\n typeof param === \"function\" ? (param as any).metadata : \"cstr\" in param ? param : getInstanceData(param).metadata\n ) as EntityMetadata;\n}\n\n/** Returns the metadata layer that declares `fieldName`, i.e. `Task.tags` for `TaskOld.tags`. */\nexport function getMetadataForField(meta: EntityMetadata, fieldName: string): EntityMetadata {\n if (!meta.allFields[fieldName]) throw new Error(`Field '${fieldName}' not found on ${meta.type}`);\n // I.e. `TaskOld.tags` is an STI-inherited `Task.tags` and should walk up, but `SmallPublisherGroup.publishers`\n // is a CTI-specialized `PublisherGroup.publishers` and should stay on `SmallPublisherGroup`.\n while (!(fieldName in meta.fields) && meta.allFields[fieldName]?.specialized !== true && meta.baseType) {\n meta = getMetadataForType(meta.baseType);\n }\n return meta;\n}\n\n/**\n * Runtime metadata about an entity.\n *\n * The `joist-codegen` step will generate this by reading the database schema at build/codegen\n * time, along with any customizations in `joist-config.json`.\n *\n * Note: This has no generic, like `T extends Entity`, because `Entity<IdType>` i.e. with\n * an unknown string/id type, causes issues when we want to generically mix `EntityMetadata`\n * of different types, that even liberally using `EntityMetadata<any>` did not avoid.\n */\nexport interface EntityMetadata<T extends Entity = any> {\n cstr: MaybeAbstractEntityConstructor<T>;\n type: string;\n /** How the domain entity's id is represented. */\n idType: \"tagged-string\" | \"untagged-string\" | \"number\";\n /** The database column type, i.e. used to do `::type` casts in Postgres. */\n idDbType: \"bigint\" | \"int\" | \"uuid\" | \"text\";\n tableName: string;\n /** Whether codegen verified this table is a supported SQL mutation target; does not gate reads. */\n supportsEmExecute?: boolean;\n /** If we're a subtype, our immediate base type's name, e.g. for `SmallPublisher` this would be `Publisher`. */\n baseType: string | undefined;\n inheritanceType?: \"sti\" | \"cti\" | undefined;\n /** Indicates the field to use to derive which subtype to instantiate; only set on the base meta. */\n stiDiscriminatorField?: string;\n /** The discriminator enum value for this subtype; only set on sub metas. */\n stiDiscriminatorValue?: number;\n /** Whether this type is abstract (cannot be instantiated directly). */\n ctiAbstract?: boolean;\n tagName: string;\n fields: Record<string, Field>;\n /** Physical storage descriptors, without CTI base columns; STI metadata shares its base table. */\n columns: ColumnDescriptors;\n allFields: Record<string, Field & { aliasSuffix: string; specialized?: true }>;\n /** Usually polys are in `allFields`, but we pull the components out for comp-specific finds, like `parentBook`. */\n polyComponentFields?: Record<string, Field & { aliasSuffix: string }>;\n // Using `any` to avoid type errors between BaseType.metadata & SubType.metadata static fields\n config: ConfigApi<any, any>;\n /** The lazy lookup of transition config by field, including config from base types. */\n transitions?: ReadonlyMap<string, FieldTransitions>;\n /** The lazy list of non-read-only reactables for this metadata and its base types. */\n reactables?: Reactable[];\n /** The lazy lookup of non-read-only reactables by source field name. */\n reactablesByField?: ReadonlyMap<string, Reactable[]>;\n /** The lazy list of all reactables for this metadata and its base types. */\n reactablesIncludingReadOnly?: Reactable[];\n /** The lazy lookup of all reactables by source field name. */\n reactablesIncludingReadOnlyByField?: ReadonlyMap<string, Reactable[]>;\n /** The lazy list of reactive validation rules for this metadata and its subtypes. */\n reactiveRules?: ReactiveRule[];\n /** The lazy list of reactive *commit* rules (post-flush/pre-commit) for this metadata and its subtypes. */\n reactiveCommitRules?: ReactiveRule[];\n /** The lazy list of non-reactive validation rules, prepared for this concrete type. */\n simpleRules?: SimpleRule[];\n /** The lazy list of non-reactive commit rules, prepared for this concrete type. */\n simpleCommitRules?: SimpleRule[];\n /** Lazily-cached: whether flushing an entity of this type could trigger any `addCommitRule` work. */\n hasCommitRules?: boolean;\n /** The lazily-cached set of own `lazy` primitive field names, i.e. columns excluded from the default SELECT. */\n lazyFieldNames?: ReadonlySet<string>;\n /** The lazily-cached list of sync-derived (`hasReactiveField`-less) field names, recalced during flush. */\n syncDerivedFields?: string[];\n /** Lazily-cached: whether this entity has any `lazy` columns, i.e. so the default SELECT lists columns explicitly. */\n hasLazyColumns?: boolean;\n orderBy: string | undefined;\n /** Flat field names that can be used to find existing rows before creating. I.e. [[\"email\"], [\"author\", \"title\"]]. */\n uniqueBy?: string[][];\n timestampFields: TimestampFields | undefined;\n // Ideally this would be the application-specific EntityManager (to avoid anys), but it doesn't really matter\n factory: (em: EntityManager<any, any, any>, opts?: any) => DeepNew<T>;\n /** The list of base types for this subtype, e.g. for Dog it'd be [Animal, Mammal]. */\n baseTypes: EntityMetadata[];\n /** The list of subtypes for this base type, e.g. for Animal it'd be `[Mammal, Dog]`. */\n subTypes: EntityMetadata[];\n /** Cached `[...baseTypes, this]` set up by `configureMetadata`, so hot paths avoid re-allocating it. */\n baseSelfMetas?: EntityMetadata[];\n /** Cached `[...baseTypes, this, ...subTypes]` set up by `configureMetadata`, so hot paths avoid re-allocating it. */\n baseSelfAndSubMetas?: EntityMetadata[];\n /** The lazy lookup of subtypes by type name, i.e. `Animal.metadata.subTypesByType.get(\"Dog\")`. */\n subTypesByType?: ReadonlyMap<string, EntityMetadata>;\n /** The lazy lookup of STI subtypes by discriminator value, i.e. `Task.metadata.subTypesByStiValue.get(1)`. */\n subTypesByStiValue?: ReadonlyMap<unknown, EntityMetadata>;\n /** The lazy STI discriminator column name, i.e. `Task.metadata.stiDiscriminatorColumnName`. */\n stiDiscriminatorColumnName?: string;\n /** If the schema is lacking deferred FKs, this is our insertion order. */\n nonDeferredFkOrder?: number;\n}\n\nexport type Field = (\n | PrimaryKeyField\n | PrimitiveField\n | EnumField\n | OneToManyField\n | LargeOneToManyField\n | ManyToOneField\n | ManyToManyField\n | ManyToManyEnumField\n | OneToOneField\n | PolymorphicField\n) & {\n /** When true, application reads mark this entity for read locking at flush. */\n assertUnchanged?: boolean;\n};\n\n// Only the fields that have defined `serde` keys; should be a mapped type of Field\nexport type SerdeField = PrimaryKeyField | PrimitiveField | EnumField | ManyToOneField | PolymorphicField;\n\nexport type PrimaryKeyField = {\n kind: \"primaryKey\";\n fieldName: string;\n fieldIdName: undefined;\n required: true;\n serde: FieldSerde;\n immutable: true;\n};\n\nexport type PrimitiveField = {\n kind: \"primitive\";\n fieldName: string;\n fieldIdName: undefined;\n required: boolean;\n derived: \"orm\" | \"sync\" | \"async\" | false;\n protected: boolean;\n type: string | Function;\n serde: FieldSerde;\n immutable: boolean;\n citext?: boolean;\n default?: \"schema\" | \"config\";\n sanitize?: boolean;\n /** When true, this column is excluded from the entity's default SELECT and lazy-loaded via a `LazyField`. */\n lazy?: boolean;\n};\n\nexport type EnumField = {\n kind: \"enum\";\n fieldName: string;\n fieldIdName: undefined;\n required: boolean;\n derived: \"sync\" | \"async\" | false;\n enumDetailType: EnumMetadata<any, { name: string }>;\n /** The enum object, i.e. `{ Draft: \"DRAFT\" }`. */\n enumType: Record<string, unknown>;\n serde: FieldSerde;\n immutable: boolean;\n default?: \"schema\" | \"config\";\n};\n\nexport type OneToManyField = {\n kind: \"o2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n orderBy?: { field: string; direction: \"ASC\" | \"DESC\" };\n /** When `\"include\"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */\n softDeletes?: \"include\" | \"exclude\";\n};\n\nexport type LargeOneToManyField = {\n kind: \"lo2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n};\n\nexport type ManyToOneField = {\n kind: \"m2o\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n serde: FieldSerde;\n immutable: boolean;\n derived: \"async\" | false;\n default?: \"schema\" | \"config\";\n};\n\nexport type ManyToManyField = {\n kind: \"m2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n derived: \"async\" | \"otherSide\" | false;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n serde: undefined;\n immutable: false;\n joinTableName: string;\n columnNames: [string, string];\n /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */\n hasJoinTableId: boolean;\n /** When `\"include\"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */\n softDeletes?: \"include\" | \"exclude\";\n};\n\n/**\n * A many-to-many between an entity and an enum \"table\", e.g. `Publisher.logoColors` backed by a\n * `publisher_logo_colors` join table joining `publishers` to the `color` enum table.\n *\n * To the user this looks like an array of enum codes (`Color[]`), but unlike an enum-array column it\n * is lazy (needs a load hint) because it lives in its own join table.\n */\nexport type ManyToManyEnumField = {\n kind: \"m2mEnum\";\n fieldName: string;\n fieldIdName: undefined;\n required: false;\n derived: false;\n /** The enum's metadata, used to map enum codes <-> their numeric ids. */\n enumDetailType: EnumMetadata<any, any, number>;\n serde: undefined;\n immutable: false;\n joinTableName: string;\n /** `[entityColumn, enumColumn]`, e.g. `[\"publisher_id\", \"color_id\"]`. */\n columnNames: [string, string];\n /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */\n hasJoinTableId: boolean;\n};\n\nexport type OneToOneField = {\n kind: \"o2o\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n};\n\nexport type PolymorphicField = {\n kind: \"poly\";\n fieldName: string; // eg `parent`\n fieldIdName: string; // `parentId`\n required: boolean;\n components: PolymorphicFieldComponent[];\n serde: PolymorphicKeySerde;\n immutable: boolean;\n};\n\nexport type PolymorphicFieldComponent = {\n otherMetadata: () => EntityMetadata;\n otherFieldName: string; // eg `comment` or `comments`\n columnName: string; // eg `parent_book_id` or `parent_book_review_id`\n column: Column;\n};\n\nexport function isOneToManyField(ormField: Field): ormField is OneToManyField {\n return ormField.kind === \"o2m\";\n}\n\nexport function isManyToOneField(ormField: Field): ormField is ManyToOneField {\n return ormField.kind === \"m2o\";\n}\n\nexport function isManyToManyField(ormField: Field): ormField is ManyToManyField {\n return ormField.kind === \"m2m\";\n}\n\nexport function isManyToManyEnumField(ormField: Field): ormField is ManyToManyEnumField {\n return ormField.kind === \"m2mEnum\";\n}\n\nexport function isOneToOneField(ormField: Field): ormField is OneToOneField {\n return ormField.kind === \"o2o\";\n}\n\nexport function isPolymorphicField(ormField: Field): ormField is PolymorphicField {\n return ormField.kind === \"poly\";\n}\n\nexport function isReferenceField(ormField: Field): ormField is ManyToOneField | OneToOneField | PolymorphicField {\n return ormField.kind === \"m2o\" || ormField.kind === \"o2o\" || ormField.kind === \"poly\";\n}\n\nexport function isCollectionField(ormField: Field): ormField is OneToManyField | ManyToManyField {\n return ormField.kind === \"o2m\" || ormField.kind === \"m2m\";\n}\n\nexport function getBaseAndSelfMetas(meta: EntityMetadata): EntityMetadata[];\nexport function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];\nexport function getBaseAndSelfMetas(param: Entity | EntityMetadata): EntityMetadata[] {\n return isEntity(param)\n ? getBaseSelfAndSubMetas(getMetadata(param))\n : (param.baseSelfMetas ?? [...param.baseTypes, param]);\n}\n\nexport function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[] {\n return meta.baseSelfAndSubMetas ?? [...meta.baseTypes, meta, ...meta.subTypes];\n}\n\nexport function getSubMetas(meta: EntityMetadata): EntityMetadata[] {\n // We should do recursion at some point\n return meta.subTypes;\n}\n\nexport function getBaseMeta(meta: EntityMetadata): EntityMetadata {\n if (!meta.baseType) {\n return meta;\n } else {\n return meta.baseTypes[0];\n }\n}\n"],"mappings":";;;;;;AAeA,SAAgB,YACd,OACgB;CAChB,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,yBAAyB,OAAO;CAC5D,OACE,OAAO,UAAU,aAAc,MAAc,WAAW,UAAU,QAAQ,QAAQA,mBAAAA,gBAAgB,KAAK,CAAC,CAAC;AAE7G;;AAGA,SAAgB,oBAAoB,MAAsB,WAAmC;CAC3F,IAAI,CAAC,KAAK,UAAU,YAAY,MAAM,IAAI,MAAM,UAAU,UAAU,iBAAiB,KAAK,MAAM;CAGhG,OAAO,EAAE,aAAa,KAAK,WAAW,KAAK,UAAU,UAAU,EAAE,gBAAgB,QAAQ,KAAK,UAC5F,OAAOC,kBAAAA,mBAAmB,KAAK,QAAQ;CAEzC,OAAO;AACT;AAuQA,SAAgB,iBAAiB,UAA6C;CAC5E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,UAA6C;CAC5E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,kBAAkB,UAA8C;CAC9E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,sBAAsB,UAAkD;CACtF,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,gBAAgB,UAA4C;CAC1E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,mBAAmB,UAA+C;CAChF,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,UAAgF;CAC/G,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS;AACjF;AAEA,SAAgB,kBAAkB,UAA+D;CAC/F,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS;AACtD;AAIA,SAAgB,oBAAoB,OAAkD;CACpF,OAAOC,eAAAA,SAAS,KAAK,IACjB,uBAAuB,YAAY,KAAK,CAAC,IACxC,MAAM,iBAAiB,CAAC,GAAG,MAAM,WAAW,KAAK;AACxD;AAEA,SAAgB,uBAAuB,MAAwC;CAC7E,OAAO,KAAK,uBAAuB;EAAC,GAAG,KAAK;EAAW;EAAM,GAAG,KAAK;CAAQ;AAC/E;AAEA,SAAgB,YAAY,MAAwC;CAElE,OAAO,KAAK;AACd;AAEA,SAAgB,YAAY,MAAsC;CAChE,IAAI,CAAC,KAAK,UACR,OAAO;MAEP,OAAO,KAAK,UAAU;AAE1B"}
|
|
1
|
+
{"version":3,"file":"EntityMetadata.cjs","names":["getInstanceData","getMetadataForType","isEntity"],"sources":["../src/EntityMetadata.ts"],"sourcesContent":["import { getInstanceData } from \"src/BaseEntity.ts\";\nimport type { ConfigApi, Reactable, ReactiveRule } from \"src/config.ts\";\nimport { getMetadataForType } from \"src/configure.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityManager, type MaybeAbstractEntityConstructor, type TimestampFields } from \"src/EntityManager.ts\";\nimport { type EnumMetadata } from \"src/EnumMetadata.ts\";\nimport type { DeepNew } from \"src/loading/loadHints.ts\";\nimport type { SimpleRule } from \"src/rules.ts\";\nimport type { Column, ColumnDescriptors } from \"src/serde/columns.ts\";\nimport type { FieldSerde, PolymorphicKeySerde } from \"src/serde/fieldSerde.ts\";\nimport type { FieldTransitions } from \"src/transitions.ts\";\n\nexport function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;\nexport function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;\nexport function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;\nexport function getMetadata<T extends Entity>(\n param: T | MaybeAbstractEntityConstructor<T> | EntityMetadata,\n): EntityMetadata {\n if (!param) throw new Error(`Cannot getMetadata of ${param}`);\n return (\n typeof param === \"function\" ? (param as any).metadata : \"cstr\" in param ? param : getInstanceData(param).metadata\n ) as EntityMetadata;\n}\n\n/** Returns the metadata layer that declares `fieldName`, i.e. `Task.tags` for `TaskOld.tags`. */\nexport function getMetadataForField(meta: EntityMetadata, fieldName: string): EntityMetadata {\n if (!meta.allFields[fieldName]) throw new Error(`Field '${fieldName}' not found on ${meta.type}`);\n // I.e. `TaskOld.tags` is an STI-inherited `Task.tags` and should walk up, but `SmallPublisherGroup.publishers`\n // is a CTI-specialized `PublisherGroup.publishers` and should stay on `SmallPublisherGroup`.\n while (!(fieldName in meta.fields) && meta.allFields[fieldName]?.specialized !== true && meta.baseType) {\n meta = getMetadataForType(meta.baseType);\n }\n return meta;\n}\n\n/**\n * Runtime metadata about an entity.\n *\n * The `joist-codegen` step will generate this by reading the database schema at build/codegen\n * time, along with any customizations in `joist-config.json`.\n *\n * Note: This has no generic, like `T extends Entity`, because `Entity<IdType>` i.e. with\n * an unknown string/id type, causes issues when we want to generically mix `EntityMetadata`\n * of different types, that even liberally using `EntityMetadata<any>` did not avoid.\n */\nexport interface EntityMetadata<T extends Entity = any> {\n cstr: MaybeAbstractEntityConstructor<T>;\n type: string;\n /** How the domain entity's id is represented. */\n idType: \"tagged-string\" | \"untagged-string\" | \"number\";\n /** The database column type, i.e. used to do `::type` casts in Postgres. */\n idDbType: \"bigint\" | \"int\" | \"uuid\" | \"text\";\n tableName: string;\n /** Whether codegen verified this table is a supported SQL mutation target; does not gate reads. */\n supportsEmExecute?: boolean;\n /** If we're a subtype, our immediate base type's name, e.g. for `SmallPublisher` this would be `Publisher`. */\n baseType: string | undefined;\n inheritanceType?: \"sti\" | \"cti\" | undefined;\n /** Indicates the field to use to derive which subtype to instantiate; only set on the base meta. */\n stiDiscriminatorField?: string;\n /** The discriminator enum value for this subtype; only set on sub metas. */\n stiDiscriminatorValue?: number;\n /** Whether this type is abstract (cannot be instantiated directly). */\n ctiAbstract?: boolean;\n tagName: string;\n fields: Record<string, Field>;\n /** Physical storage descriptors, without CTI base columns; STI metadata shares its base table. */\n columns: ColumnDescriptors;\n allFields: Record<string, Field & { aliasSuffix: string; specialized?: true }>;\n /** Usually polys are in `allFields`, but we pull the components out for comp-specific finds, like `parentBook`. */\n polyComponentFields?: Record<string, Field & { aliasSuffix: string }>;\n // Using `any` to avoid type errors between BaseType.metadata & SubType.metadata static fields\n config: ConfigApi<any, any>;\n /** The lazy lookup of transition config by field, including config from base types. */\n transitions?: ReadonlyMap<string, FieldTransitions>;\n /** The lazy list of non-read-only reactables for this metadata and its base types. */\n reactables?: Reactable[];\n /** The lazy lookup of non-read-only reactables by source field name. */\n reactablesByField?: ReadonlyMap<string, Reactable[]>;\n /** The lazy list of all reactables for this metadata and its base types. */\n reactablesIncludingReadOnly?: Reactable[];\n /** The lazy lookup of all reactables by source field name. */\n reactablesIncludingReadOnlyByField?: ReadonlyMap<string, Reactable[]>;\n /** The lazy list of reactive validation rules for this metadata and its subtypes. */\n reactiveRules?: ReactiveRule[];\n /** The lazy list of reactive *commit* rules (post-flush/pre-commit) for this metadata and its subtypes. */\n reactiveCommitRules?: ReactiveRule[];\n /** The lazy list of non-reactive validation rules, prepared for this concrete type. */\n simpleRules?: SimpleRule[];\n /** The lazy list of non-reactive commit rules, prepared for this concrete type. */\n simpleCommitRules?: SimpleRule[];\n /** Lazily-cached: whether flushing an entity of this type could trigger any `addCommitRule` work. */\n hasCommitRules?: boolean;\n /** The lazily-cached set of own `lazy` primitive field names, i.e. columns excluded from the default SELECT. */\n lazyFieldNames?: ReadonlySet<string>;\n /** The lazily-cached list of sync-derived (`hasReactiveField`-less) field names, recalced during flush. */\n syncDerivedFields?: string[];\n /** Lazily-cached: whether this entity has any `lazy` columns, i.e. so the default SELECT lists columns explicitly. */\n hasLazyColumns?: boolean;\n orderBy: string | undefined;\n /** Flat field names that can be used to find existing rows before creating. I.e. [[\"email\"], [\"author\", \"title\"]]. */\n uniqueBy?: string[][];\n timestampFields: TimestampFields | undefined;\n // Ideally this would be the application-specific EntityManager (to avoid anys), but it doesn't really matter\n factory: (em: EntityManager<any, any, any>, opts?: any) => DeepNew<T>;\n /** The list of base types for this subtype, e.g. for Dog it'd be [Animal, Mammal]. */\n baseTypes: EntityMetadata[];\n /** The list of subtypes for this base type, e.g. for Animal it'd be `[Mammal, Dog]`. */\n subTypes: EntityMetadata[];\n /** Cached `[...baseTypes, this]` set up by `configureMetadata`, so hot paths avoid re-allocating it. */\n baseSelfMetas?: EntityMetadata[];\n /** Cached `[...baseTypes, this, ...subTypes]` set up by `configureMetadata`, so hot paths avoid re-allocating it. */\n baseSelfAndSubMetas?: EntityMetadata[];\n /** The lazy lookup of subtypes by type name, i.e. `Animal.metadata.subTypesByType.get(\"Dog\")`. */\n subTypesByType?: ReadonlyMap<string, EntityMetadata>;\n /** The lazy lookup of STI subtypes by discriminator value, i.e. `Task.metadata.subTypesByStiValue.get(1)`. */\n subTypesByStiValue?: ReadonlyMap<unknown, EntityMetadata>;\n /** Codegen-assigned family-wide field ordinals, shared by metadata and generated first-read guards. */\n readonly fieldReadIndexes: Readonly<Record<string, number>>;\n /** Codegen-assigned number of first-read words to initialize on each entity in this inheritance family. */\n readonly fieldReadWordCount: number;\n /** The lazy STI discriminator column name, i.e. `Task.metadata.stiDiscriminatorColumnName`. */\n stiDiscriminatorColumnName?: string;\n /** If the schema is lacking deferred FKs, this is our insertion order. */\n nonDeferredFkOrder?: number;\n}\n\nexport type Field = (\n | PrimaryKeyField\n | PrimitiveField\n | EnumField\n | OneToManyField\n | LargeOneToManyField\n | ManyToOneField\n | ManyToManyField\n | ManyToManyEnumField\n | OneToOneField\n | PolymorphicField\n) & {\n /** When true, application reads mark this entity for read locking at flush. */\n assertUnchanged?: boolean;\n};\n\n// Only the fields that have defined `serde` keys; should be a mapped type of Field\nexport type SerdeField = PrimaryKeyField | PrimitiveField | EnumField | ManyToOneField | PolymorphicField;\n\nexport type PrimaryKeyField = {\n kind: \"primaryKey\";\n fieldName: string;\n fieldIdName: undefined;\n required: true;\n serde: FieldSerde;\n immutable: true;\n};\n\nexport type PrimitiveField = {\n kind: \"primitive\";\n fieldName: string;\n fieldIdName: undefined;\n required: boolean;\n derived: \"orm\" | \"sync\" | \"async\" | false;\n protected: boolean;\n type: string | Function;\n serde: FieldSerde;\n immutable: boolean;\n citext?: boolean;\n default?: \"schema\" | \"config\";\n sanitize?: boolean;\n /** When true, this column is excluded from the entity's default SELECT and lazy-loaded via a `LazyField`. */\n lazy?: boolean;\n};\n\nexport type EnumField = {\n kind: \"enum\";\n fieldName: string;\n fieldIdName: undefined;\n required: boolean;\n derived: \"sync\" | \"async\" | false;\n enumDetailType: EnumMetadata<any, { name: string }>;\n /** The enum object, i.e. `{ Draft: \"DRAFT\" }`. */\n enumType: Record<string, unknown>;\n serde: FieldSerde;\n immutable: boolean;\n default?: \"schema\" | \"config\";\n};\n\nexport type OneToManyField = {\n kind: \"o2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n orderBy?: { field: string; direction: \"ASC\" | \"DESC\" };\n /** When `\"include\"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */\n softDeletes?: \"include\" | \"exclude\";\n};\n\nexport type LargeOneToManyField = {\n kind: \"lo2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n};\n\nexport type ManyToOneField = {\n kind: \"m2o\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n serde: FieldSerde;\n immutable: boolean;\n derived: \"async\" | false;\n default?: \"schema\" | \"config\";\n};\n\nexport type ManyToManyField = {\n kind: \"m2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n derived: \"async\" | \"otherSide\" | false;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n serde: undefined;\n immutable: false;\n joinTableName: string;\n columnNames: [string, string];\n /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */\n hasJoinTableId: boolean;\n /** When `\"include\"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */\n softDeletes?: \"include\" | \"exclude\";\n};\n\n/**\n * A many-to-many between an entity and an enum \"table\", e.g. `Publisher.logoColors` backed by a\n * `publisher_logo_colors` join table joining `publishers` to the `color` enum table.\n *\n * To the user this looks like an array of enum codes (`Color[]`), but unlike an enum-array column it\n * is lazy (needs a load hint) because it lives in its own join table.\n */\nexport type ManyToManyEnumField = {\n kind: \"m2mEnum\";\n fieldName: string;\n fieldIdName: undefined;\n required: false;\n derived: false;\n /** The enum's metadata, used to map enum codes <-> their numeric ids. */\n enumDetailType: EnumMetadata<any, any, number>;\n serde: undefined;\n immutable: false;\n joinTableName: string;\n /** `[entityColumn, enumColumn]`, e.g. `[\"publisher_id\", \"color_id\"]`. */\n columnNames: [string, string];\n /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */\n hasJoinTableId: boolean;\n};\n\nexport type OneToOneField = {\n kind: \"o2o\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n};\n\nexport type PolymorphicField = {\n kind: \"poly\";\n fieldName: string; // eg `parent`\n fieldIdName: string; // `parentId`\n required: boolean;\n components: PolymorphicFieldComponent[];\n serde: PolymorphicKeySerde;\n immutable: boolean;\n};\n\nexport type PolymorphicFieldComponent = {\n otherMetadata: () => EntityMetadata;\n otherFieldName: string; // eg `comment` or `comments`\n columnName: string; // eg `parent_book_id` or `parent_book_review_id`\n column: Column;\n};\n\nexport function isOneToManyField(ormField: Field): ormField is OneToManyField {\n return ormField.kind === \"o2m\";\n}\n\nexport function isManyToOneField(ormField: Field): ormField is ManyToOneField {\n return ormField.kind === \"m2o\";\n}\n\nexport function isManyToManyField(ormField: Field): ormField is ManyToManyField {\n return ormField.kind === \"m2m\";\n}\n\nexport function isManyToManyEnumField(ormField: Field): ormField is ManyToManyEnumField {\n return ormField.kind === \"m2mEnum\";\n}\n\nexport function isOneToOneField(ormField: Field): ormField is OneToOneField {\n return ormField.kind === \"o2o\";\n}\n\nexport function isPolymorphicField(ormField: Field): ormField is PolymorphicField {\n return ormField.kind === \"poly\";\n}\n\nexport function isReferenceField(ormField: Field): ormField is ManyToOneField | OneToOneField | PolymorphicField {\n return ormField.kind === \"m2o\" || ormField.kind === \"o2o\" || ormField.kind === \"poly\";\n}\n\nexport function isCollectionField(ormField: Field): ormField is OneToManyField | ManyToManyField {\n return ormField.kind === \"o2m\" || ormField.kind === \"m2m\";\n}\n\nexport function getBaseAndSelfMetas(meta: EntityMetadata): EntityMetadata[];\nexport function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];\nexport function getBaseAndSelfMetas(param: Entity | EntityMetadata): EntityMetadata[] {\n return isEntity(param)\n ? getBaseSelfAndSubMetas(getMetadata(param))\n : (param.baseSelfMetas ?? [...param.baseTypes, param]);\n}\n\nexport function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[] {\n return meta.baseSelfAndSubMetas ?? [...meta.baseTypes, meta, ...meta.subTypes];\n}\n\nexport function getSubMetas(meta: EntityMetadata): EntityMetadata[] {\n // We should do recursion at some point\n return meta.subTypes;\n}\n\nexport function getBaseMeta(meta: EntityMetadata): EntityMetadata {\n if (!meta.baseType) {\n return meta;\n } else {\n return meta.baseTypes[0];\n }\n}\n"],"mappings":";;;;;;AAeA,SAAgB,YACd,OACgB;CAChB,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,yBAAyB,OAAO;CAC5D,OACE,OAAO,UAAU,aAAc,MAAc,WAAW,UAAU,QAAQ,QAAQA,mBAAAA,gBAAgB,KAAK,CAAC,CAAC;AAE7G;;AAGA,SAAgB,oBAAoB,MAAsB,WAAmC;CAC3F,IAAI,CAAC,KAAK,UAAU,YAAY,MAAM,IAAI,MAAM,UAAU,UAAU,iBAAiB,KAAK,MAAM;CAGhG,OAAO,EAAE,aAAa,KAAK,WAAW,KAAK,UAAU,UAAU,EAAE,gBAAgB,QAAQ,KAAK,UAC5F,OAAOC,kBAAAA,mBAAmB,KAAK,QAAQ;CAEzC,OAAO;AACT;AA2QA,SAAgB,iBAAiB,UAA6C;CAC5E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,UAA6C;CAC5E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,kBAAkB,UAA8C;CAC9E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,sBAAsB,UAAkD;CACtF,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,gBAAgB,UAA4C;CAC1E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,mBAAmB,UAA+C;CAChF,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,UAAgF;CAC/G,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS;AACjF;AAEA,SAAgB,kBAAkB,UAA+D;CAC/F,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS;AACtD;AAIA,SAAgB,oBAAoB,OAAkD;CACpF,OAAOC,eAAAA,SAAS,KAAK,IACjB,uBAAuB,YAAY,KAAK,CAAC,IACxC,MAAM,iBAAiB,CAAC,GAAG,MAAM,WAAW,KAAK;AACxD;AAEA,SAAgB,uBAAuB,MAAwC;CAC7E,OAAO,KAAK,uBAAuB;EAAC,GAAG,KAAK;EAAW;EAAM,GAAG,KAAK;CAAQ;AAC/E;AAEA,SAAgB,YAAY,MAAwC;CAElE,OAAO,KAAK;AACd;AAEA,SAAgB,YAAY,MAAsC;CAChE,IAAI,CAAC,KAAK,UACR,OAAO;MAEP,OAAO,KAAK,UAAU;AAE1B"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import { ConfigApi, Reactable, ReactiveRule } from "./config.cjs";
|
|
2
|
+
import { Entity } from "./Entity.cjs";
|
|
3
|
+
import { EntityManager, MaybeAbstractEntityConstructor, TimestampFields } from "./EntityManager.cjs";
|
|
1
4
|
import { EnumMetadata } from "./EnumMetadata.cjs";
|
|
2
5
|
import { DeepNew } from "./loading/loadHints.cjs";
|
|
3
6
|
import { SimpleRule } from "./rules.cjs";
|
|
4
|
-
import { FieldTransitions } from "./transitions.cjs";
|
|
5
|
-
import { ConfigApi, Reactable, ReactiveRule } from "./config.cjs";
|
|
6
7
|
import { Column, ColumnDescriptors } from "./serde/columns.cjs";
|
|
7
8
|
import { FieldSerde, PolymorphicKeySerde } from "./serde/fieldSerde.cjs";
|
|
8
|
-
import {
|
|
9
|
-
import { Entity } from "./Entity.cjs";
|
|
10
|
-
//#region src/EntityMetadata.d.ts
|
|
9
|
+
import { FieldTransitions } from "./transitions.cjs";
|
|
11
10
|
export declare function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;
|
|
12
11
|
export declare function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;
|
|
13
12
|
export declare function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;
|
|
@@ -98,6 +97,10 @@ export interface EntityMetadata<T extends Entity = any> {
|
|
|
98
97
|
subTypesByType?: ReadonlyMap<string, EntityMetadata>;
|
|
99
98
|
/** The lazy lookup of STI subtypes by discriminator value, i.e. `Task.metadata.subTypesByStiValue.get(1)`. */
|
|
100
99
|
subTypesByStiValue?: ReadonlyMap<unknown, EntityMetadata>;
|
|
100
|
+
/** Codegen-assigned family-wide field ordinals, shared by metadata and generated first-read guards. */
|
|
101
|
+
readonly fieldReadIndexes: Readonly<Record<string, number>>;
|
|
102
|
+
/** Codegen-assigned number of first-read words to initialize on each entity in this inheritance family. */
|
|
103
|
+
readonly fieldReadWordCount: number;
|
|
101
104
|
/** The lazy STI discriminator column name, i.e. `Task.metadata.stiDiscriminatorColumnName`. */
|
|
102
105
|
stiDiscriminatorColumnName?: string;
|
|
103
106
|
/** If the schema is lacking deferred FKs, this is our insertion order. */
|
|
@@ -269,5 +272,4 @@ export declare function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];
|
|
|
269
272
|
export declare function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[];
|
|
270
273
|
export declare function getSubMetas(meta: EntityMetadata): EntityMetadata[];
|
|
271
274
|
export declare function getBaseMeta(meta: EntityMetadata): EntityMetadata;
|
|
272
|
-
//#endregion
|
|
273
275
|
//# sourceMappingURL=EntityMetadata.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityMetadata.d.cts","names":[],"sources":["../src/EntityMetadata.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityMetadata.d.cts","names":[],"sources":["../src/EntityMetadata.ts"],"mappings":";;;;;;;;;wBAYgB,YAAY,UAAU,QAAQ,QAAQ,IAAI,eAAe;wBACzD,YAAY,UAAU,QAAQ,MAAM,+BAA+B,KAAK,eAAe;wBACvF,YAAY,UAAU,QAAQ,MAAM,iBAAiB;;wBAWrD,oBAAoB,MAAM,gBAAgB,oBAAoB;;;;;;;;;;;iBAoB7D,eAAe,UAAU;EACxC,MAAM,+BAA+B;EACrC;;EAEA;;EAEA;EACA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;EAEA;EACA;EACA,QAAQ,eAAe;;EAEvB,SAAS;EACT,WAAW,eAAe;IAAU;IAAqB;;;EAEzD,sBAAsB,eAAe;IAAU;;EAE/C,QAAQ;;EAER,cAAc,oBAAoB;;EAElC,aAAa;;EAEb,oBAAoB,oBAAoB;;EAExC,8BAA8B;;EAE9B,qCAAqC,oBAAoB;;EAEzD,gBAAgB;;EAEhB,sBAAsB;;EAEtB,cAAc;;EAEd,oBAAoB;;EAEpB;;EAEA,iBAAiB;;EAEjB;;EAEA;EACA;;EAEA;EACA,iBAAiB;EAEjB,UAAU,IAAI,8BAA8B,eAAe,QAAQ;;EAEnE,WAAW;;EAEX,UAAU;;EAEV,gBAAgB;;EAEhB,sBAAsB;;EAEtB,iBAAiB,oBAAoB;;EAErC,qBAAqB,qBAAqB;;WAEjC,kBAAkB,SAAS;;WAE3B;;EAET;;EAEA;;YAGU,SACR,kBACA,iBACA,YACA,iBACA,sBACA,iBACA,kBACA,sBACA,gBACA;;EAGF;;YAIU,aAAa,kBAAkB,iBAAiB,YAAY,iBAAiB;YAE7E;EACV;EACA;EACA;EACA;EACA,OAAO;EACP;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,OAAO;EACP;EACA;EACA;EACA;;EAEA;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA,gBAAgB;IAAoB;;;EAEpC,UAAU;EACV,OAAO;EACP;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;EACA;IAAY;IAAe;;;EAE3B;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;EACA,OAAO;EACP;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;;;;;;;;YAUU;EACV;EACA;EACA;EACA;EACA;;EAEA,gBAAgB;EAChB;EACA;EACA;;EAEA;;EAEA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,YAAY;EACZ,OAAO;EACP;;YAGU;EACV,qBAAqB;EACrB;EACA;EACA,QAAQ;;wBAGM,iBAAiB,UAAU,QAAQ,YAAY;wBAI/C,iBAAiB,UAAU,QAAQ,YAAY;wBAI/C,kBAAkB,UAAU,QAAQ,YAAY;wBAIhD,sBAAsB,UAAU,QAAQ,YAAY;wBAIpD,gBAAgB,UAAU,QAAQ,YAAY;wBAI9C,mBAAmB,UAAU,QAAQ,YAAY;wBAIjD,iBAAiB,UAAU,QAAQ,YAAY,iBAAiB,gBAAgB;wBAIhF,kBAAkB,UAAU,QAAQ,YAAY,iBAAiB;wBAIjE,oBAAoB,MAAM,iBAAiB;wBAC3C,oBAAoB,QAAQ,SAAS;wBAOrC,uBAAuB,MAAM,iBAAiB;wBAI9C,YAAY,MAAM,iBAAiB;wBAKnC,YAAY,MAAM,iBAAiB"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import { ConfigApi, Reactable, ReactiveRule } from "./config.mjs";
|
|
2
|
+
import { Entity } from "./Entity.mjs";
|
|
3
|
+
import { EntityManager, MaybeAbstractEntityConstructor, TimestampFields } from "./EntityManager.mjs";
|
|
1
4
|
import { EnumMetadata } from "./EnumMetadata.mjs";
|
|
2
5
|
import { DeepNew } from "./loading/loadHints.mjs";
|
|
3
6
|
import { SimpleRule } from "./rules.mjs";
|
|
4
|
-
import { FieldTransitions } from "./transitions.mjs";
|
|
5
|
-
import { ConfigApi, Reactable, ReactiveRule } from "./config.mjs";
|
|
6
7
|
import { Column, ColumnDescriptors } from "./serde/columns.mjs";
|
|
7
8
|
import { FieldSerde, PolymorphicKeySerde } from "./serde/fieldSerde.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { Entity } from "./Entity.mjs";
|
|
10
|
-
//#region src/EntityMetadata.d.ts
|
|
9
|
+
import { FieldTransitions } from "./transitions.mjs";
|
|
11
10
|
export declare function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;
|
|
12
11
|
export declare function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;
|
|
13
12
|
export declare function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;
|
|
@@ -98,6 +97,10 @@ export interface EntityMetadata<T extends Entity = any> {
|
|
|
98
97
|
subTypesByType?: ReadonlyMap<string, EntityMetadata>;
|
|
99
98
|
/** The lazy lookup of STI subtypes by discriminator value, i.e. `Task.metadata.subTypesByStiValue.get(1)`. */
|
|
100
99
|
subTypesByStiValue?: ReadonlyMap<unknown, EntityMetadata>;
|
|
100
|
+
/** Codegen-assigned family-wide field ordinals, shared by metadata and generated first-read guards. */
|
|
101
|
+
readonly fieldReadIndexes: Readonly<Record<string, number>>;
|
|
102
|
+
/** Codegen-assigned number of first-read words to initialize on each entity in this inheritance family. */
|
|
103
|
+
readonly fieldReadWordCount: number;
|
|
101
104
|
/** The lazy STI discriminator column name, i.e. `Task.metadata.stiDiscriminatorColumnName`. */
|
|
102
105
|
stiDiscriminatorColumnName?: string;
|
|
103
106
|
/** If the schema is lacking deferred FKs, this is our insertion order. */
|
|
@@ -269,5 +272,4 @@ export declare function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];
|
|
|
269
272
|
export declare function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[];
|
|
270
273
|
export declare function getSubMetas(meta: EntityMetadata): EntityMetadata[];
|
|
271
274
|
export declare function getBaseMeta(meta: EntityMetadata): EntityMetadata;
|
|
272
|
-
//#endregion
|
|
273
275
|
//# sourceMappingURL=EntityMetadata.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityMetadata.d.mts","names":[],"sources":["../src/EntityMetadata.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityMetadata.d.mts","names":[],"sources":["../src/EntityMetadata.ts"],"mappings":";;;;;;;;;wBAYgB,YAAY,UAAU,QAAQ,QAAQ,IAAI,eAAe;wBACzD,YAAY,UAAU,QAAQ,MAAM,+BAA+B,KAAK,eAAe;wBACvF,YAAY,UAAU,QAAQ,MAAM,iBAAiB;;wBAWrD,oBAAoB,MAAM,gBAAgB,oBAAoB;;;;;;;;;;;iBAoB7D,eAAe,UAAU;EACxC,MAAM,+BAA+B;EACrC;;EAEA;;EAEA;EACA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;EAEA;EACA;EACA,QAAQ,eAAe;;EAEvB,SAAS;EACT,WAAW,eAAe;IAAU;IAAqB;;;EAEzD,sBAAsB,eAAe;IAAU;;EAE/C,QAAQ;;EAER,cAAc,oBAAoB;;EAElC,aAAa;;EAEb,oBAAoB,oBAAoB;;EAExC,8BAA8B;;EAE9B,qCAAqC,oBAAoB;;EAEzD,gBAAgB;;EAEhB,sBAAsB;;EAEtB,cAAc;;EAEd,oBAAoB;;EAEpB;;EAEA,iBAAiB;;EAEjB;;EAEA;EACA;;EAEA;EACA,iBAAiB;EAEjB,UAAU,IAAI,8BAA8B,eAAe,QAAQ;;EAEnE,WAAW;;EAEX,UAAU;;EAEV,gBAAgB;;EAEhB,sBAAsB;;EAEtB,iBAAiB,oBAAoB;;EAErC,qBAAqB,qBAAqB;;WAEjC,kBAAkB,SAAS;;WAE3B;;EAET;;EAEA;;YAGU,SACR,kBACA,iBACA,YACA,iBACA,sBACA,iBACA,kBACA,sBACA,gBACA;;EAGF;;YAIU,aAAa,kBAAkB,iBAAiB,YAAY,iBAAiB;YAE7E;EACV;EACA;EACA;EACA;EACA,OAAO;EACP;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,OAAO;EACP;EACA;EACA;EACA;;EAEA;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA,gBAAgB;IAAoB;;;EAEpC,UAAU;EACV,OAAO;EACP;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;EACA;IAAY;IAAe;;;EAE3B;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;EACA,OAAO;EACP;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;;;;;;;;YAUU;EACV;EACA;EACA;EACA;EACA;;EAEA,gBAAgB;EAChB;EACA;EACA;;EAEA;;EAEA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,YAAY;EACZ,OAAO;EACP;;YAGU;EACV,qBAAqB;EACrB;EACA;EACA,QAAQ;;wBAGM,iBAAiB,UAAU,QAAQ,YAAY;wBAI/C,iBAAiB,UAAU,QAAQ,YAAY;wBAI/C,kBAAkB,UAAU,QAAQ,YAAY;wBAIhD,sBAAsB,UAAU,QAAQ,YAAY;wBAIpD,gBAAgB,UAAU,QAAQ,YAAY;wBAI9C,mBAAmB,UAAU,QAAQ,YAAY;wBAIjD,iBAAiB,UAAU,QAAQ,YAAY,iBAAiB,gBAAgB;wBAIhF,kBAAkB,UAAU,QAAQ,YAAY,iBAAiB;wBAIjE,oBAAoB,MAAM,iBAAiB;wBAC3C,oBAAoB,QAAQ,SAAS;wBAOrC,uBAAuB,MAAM,iBAAiB;wBAI9C,YAAY,MAAM,iBAAiB;wBAKnC,YAAY,MAAM,iBAAiB"}
|
package/build/EntityMetadata.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { getInstanceData } from "./BaseEntity.js";
|
|
1
2
|
import { getMetadataForType } from "./configure.js";
|
|
2
|
-
import "./EntityManager.js";
|
|
3
3
|
import { isEntity } from "./Entity.js";
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import "./EntityManager.js";
|
|
5
|
+
// src/EntityMetadata.ts
|
|
6
6
|
function getMetadata(param) {
|
|
7
7
|
if (!param) throw new Error(`Cannot getMetadata of ${param}`);
|
|
8
8
|
return typeof param === "function" ? param.metadata : "cstr" in param ? param : getInstanceData(param).metadata;
|
|
@@ -54,7 +54,6 @@ function getBaseMeta(meta) {
|
|
|
54
54
|
if (!meta.baseType) return meta;
|
|
55
55
|
else return meta.baseTypes[0];
|
|
56
56
|
}
|
|
57
|
-
//#endregion
|
|
58
57
|
export { getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getMetadata, getMetadataForField, getSubMetas, isCollectionField, isManyToManyEnumField, isManyToManyField, isManyToOneField, isOneToManyField, isOneToOneField, isPolymorphicField, isReferenceField };
|
|
59
58
|
|
|
60
59
|
//# sourceMappingURL=EntityMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityMetadata.js","names":[],"sources":["../src/EntityMetadata.ts"],"sourcesContent":["import { getInstanceData } from \"src/BaseEntity.ts\";\nimport type { ConfigApi, Reactable, ReactiveRule } from \"src/config.ts\";\nimport { getMetadataForType } from \"src/configure.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityManager, type MaybeAbstractEntityConstructor, type TimestampFields } from \"src/EntityManager.ts\";\nimport { type EnumMetadata } from \"src/EnumMetadata.ts\";\nimport type { DeepNew } from \"src/loading/loadHints.ts\";\nimport type { SimpleRule } from \"src/rules.ts\";\nimport type { Column, ColumnDescriptors } from \"src/serde/columns.ts\";\nimport type { FieldSerde, PolymorphicKeySerde } from \"src/serde/fieldSerde.ts\";\nimport type { FieldTransitions } from \"src/transitions.ts\";\n\nexport function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;\nexport function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;\nexport function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;\nexport function getMetadata<T extends Entity>(\n param: T | MaybeAbstractEntityConstructor<T> | EntityMetadata,\n): EntityMetadata {\n if (!param) throw new Error(`Cannot getMetadata of ${param}`);\n return (\n typeof param === \"function\" ? (param as any).metadata : \"cstr\" in param ? param : getInstanceData(param).metadata\n ) as EntityMetadata;\n}\n\n/** Returns the metadata layer that declares `fieldName`, i.e. `Task.tags` for `TaskOld.tags`. */\nexport function getMetadataForField(meta: EntityMetadata, fieldName: string): EntityMetadata {\n if (!meta.allFields[fieldName]) throw new Error(`Field '${fieldName}' not found on ${meta.type}`);\n // I.e. `TaskOld.tags` is an STI-inherited `Task.tags` and should walk up, but `SmallPublisherGroup.publishers`\n // is a CTI-specialized `PublisherGroup.publishers` and should stay on `SmallPublisherGroup`.\n while (!(fieldName in meta.fields) && meta.allFields[fieldName]?.specialized !== true && meta.baseType) {\n meta = getMetadataForType(meta.baseType);\n }\n return meta;\n}\n\n/**\n * Runtime metadata about an entity.\n *\n * The `joist-codegen` step will generate this by reading the database schema at build/codegen\n * time, along with any customizations in `joist-config.json`.\n *\n * Note: This has no generic, like `T extends Entity`, because `Entity<IdType>` i.e. with\n * an unknown string/id type, causes issues when we want to generically mix `EntityMetadata`\n * of different types, that even liberally using `EntityMetadata<any>` did not avoid.\n */\nexport interface EntityMetadata<T extends Entity = any> {\n cstr: MaybeAbstractEntityConstructor<T>;\n type: string;\n /** How the domain entity's id is represented. */\n idType: \"tagged-string\" | \"untagged-string\" | \"number\";\n /** The database column type, i.e. used to do `::type` casts in Postgres. */\n idDbType: \"bigint\" | \"int\" | \"uuid\" | \"text\";\n tableName: string;\n /** Whether codegen verified this table is a supported SQL mutation target; does not gate reads. */\n supportsEmExecute?: boolean;\n /** If we're a subtype, our immediate base type's name, e.g. for `SmallPublisher` this would be `Publisher`. */\n baseType: string | undefined;\n inheritanceType?: \"sti\" | \"cti\" | undefined;\n /** Indicates the field to use to derive which subtype to instantiate; only set on the base meta. */\n stiDiscriminatorField?: string;\n /** The discriminator enum value for this subtype; only set on sub metas. */\n stiDiscriminatorValue?: number;\n /** Whether this type is abstract (cannot be instantiated directly). */\n ctiAbstract?: boolean;\n tagName: string;\n fields: Record<string, Field>;\n /** Physical storage descriptors, without CTI base columns; STI metadata shares its base table. */\n columns: ColumnDescriptors;\n allFields: Record<string, Field & { aliasSuffix: string; specialized?: true }>;\n /** Usually polys are in `allFields`, but we pull the components out for comp-specific finds, like `parentBook`. */\n polyComponentFields?: Record<string, Field & { aliasSuffix: string }>;\n // Using `any` to avoid type errors between BaseType.metadata & SubType.metadata static fields\n config: ConfigApi<any, any>;\n /** The lazy lookup of transition config by field, including config from base types. */\n transitions?: ReadonlyMap<string, FieldTransitions>;\n /** The lazy list of non-read-only reactables for this metadata and its base types. */\n reactables?: Reactable[];\n /** The lazy lookup of non-read-only reactables by source field name. */\n reactablesByField?: ReadonlyMap<string, Reactable[]>;\n /** The lazy list of all reactables for this metadata and its base types. */\n reactablesIncludingReadOnly?: Reactable[];\n /** The lazy lookup of all reactables by source field name. */\n reactablesIncludingReadOnlyByField?: ReadonlyMap<string, Reactable[]>;\n /** The lazy list of reactive validation rules for this metadata and its subtypes. */\n reactiveRules?: ReactiveRule[];\n /** The lazy list of reactive *commit* rules (post-flush/pre-commit) for this metadata and its subtypes. */\n reactiveCommitRules?: ReactiveRule[];\n /** The lazy list of non-reactive validation rules, prepared for this concrete type. */\n simpleRules?: SimpleRule[];\n /** The lazy list of non-reactive commit rules, prepared for this concrete type. */\n simpleCommitRules?: SimpleRule[];\n /** Lazily-cached: whether flushing an entity of this type could trigger any `addCommitRule` work. */\n hasCommitRules?: boolean;\n /** The lazily-cached set of own `lazy` primitive field names, i.e. columns excluded from the default SELECT. */\n lazyFieldNames?: ReadonlySet<string>;\n /** The lazily-cached list of sync-derived (`hasReactiveField`-less) field names, recalced during flush. */\n syncDerivedFields?: string[];\n /** Lazily-cached: whether this entity has any `lazy` columns, i.e. so the default SELECT lists columns explicitly. */\n hasLazyColumns?: boolean;\n orderBy: string | undefined;\n /** Flat field names that can be used to find existing rows before creating. I.e. [[\"email\"], [\"author\", \"title\"]]. */\n uniqueBy?: string[][];\n timestampFields: TimestampFields | undefined;\n // Ideally this would be the application-specific EntityManager (to avoid anys), but it doesn't really matter\n factory: (em: EntityManager<any, any, any>, opts?: any) => DeepNew<T>;\n /** The list of base types for this subtype, e.g. for Dog it'd be [Animal, Mammal]. */\n baseTypes: EntityMetadata[];\n /** The list of subtypes for this base type, e.g. for Animal it'd be `[Mammal, Dog]`. */\n subTypes: EntityMetadata[];\n /** Cached `[...baseTypes, this]` set up by `configureMetadata`, so hot paths avoid re-allocating it. */\n baseSelfMetas?: EntityMetadata[];\n /** Cached `[...baseTypes, this, ...subTypes]` set up by `configureMetadata`, so hot paths avoid re-allocating it. */\n baseSelfAndSubMetas?: EntityMetadata[];\n /** The lazy lookup of subtypes by type name, i.e. `Animal.metadata.subTypesByType.get(\"Dog\")`. */\n subTypesByType?: ReadonlyMap<string, EntityMetadata>;\n /** The lazy lookup of STI subtypes by discriminator value, i.e. `Task.metadata.subTypesByStiValue.get(1)`. */\n subTypesByStiValue?: ReadonlyMap<unknown, EntityMetadata>;\n /** The lazy STI discriminator column name, i.e. `Task.metadata.stiDiscriminatorColumnName`. */\n stiDiscriminatorColumnName?: string;\n /** If the schema is lacking deferred FKs, this is our insertion order. */\n nonDeferredFkOrder?: number;\n}\n\nexport type Field = (\n | PrimaryKeyField\n | PrimitiveField\n | EnumField\n | OneToManyField\n | LargeOneToManyField\n | ManyToOneField\n | ManyToManyField\n | ManyToManyEnumField\n | OneToOneField\n | PolymorphicField\n) & {\n /** When true, application reads mark this entity for read locking at flush. */\n assertUnchanged?: boolean;\n};\n\n// Only the fields that have defined `serde` keys; should be a mapped type of Field\nexport type SerdeField = PrimaryKeyField | PrimitiveField | EnumField | ManyToOneField | PolymorphicField;\n\nexport type PrimaryKeyField = {\n kind: \"primaryKey\";\n fieldName: string;\n fieldIdName: undefined;\n required: true;\n serde: FieldSerde;\n immutable: true;\n};\n\nexport type PrimitiveField = {\n kind: \"primitive\";\n fieldName: string;\n fieldIdName: undefined;\n required: boolean;\n derived: \"orm\" | \"sync\" | \"async\" | false;\n protected: boolean;\n type: string | Function;\n serde: FieldSerde;\n immutable: boolean;\n citext?: boolean;\n default?: \"schema\" | \"config\";\n sanitize?: boolean;\n /** When true, this column is excluded from the entity's default SELECT and lazy-loaded via a `LazyField`. */\n lazy?: boolean;\n};\n\nexport type EnumField = {\n kind: \"enum\";\n fieldName: string;\n fieldIdName: undefined;\n required: boolean;\n derived: \"sync\" | \"async\" | false;\n enumDetailType: EnumMetadata<any, { name: string }>;\n /** The enum object, i.e. `{ Draft: \"DRAFT\" }`. */\n enumType: Record<string, unknown>;\n serde: FieldSerde;\n immutable: boolean;\n default?: \"schema\" | \"config\";\n};\n\nexport type OneToManyField = {\n kind: \"o2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n orderBy?: { field: string; direction: \"ASC\" | \"DESC\" };\n /** When `\"include\"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */\n softDeletes?: \"include\" | \"exclude\";\n};\n\nexport type LargeOneToManyField = {\n kind: \"lo2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n};\n\nexport type ManyToOneField = {\n kind: \"m2o\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n serde: FieldSerde;\n immutable: boolean;\n derived: \"async\" | false;\n default?: \"schema\" | \"config\";\n};\n\nexport type ManyToManyField = {\n kind: \"m2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n derived: \"async\" | \"otherSide\" | false;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n serde: undefined;\n immutable: false;\n joinTableName: string;\n columnNames: [string, string];\n /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */\n hasJoinTableId: boolean;\n /** When `\"include\"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */\n softDeletes?: \"include\" | \"exclude\";\n};\n\n/**\n * A many-to-many between an entity and an enum \"table\", e.g. `Publisher.logoColors` backed by a\n * `publisher_logo_colors` join table joining `publishers` to the `color` enum table.\n *\n * To the user this looks like an array of enum codes (`Color[]`), but unlike an enum-array column it\n * is lazy (needs a load hint) because it lives in its own join table.\n */\nexport type ManyToManyEnumField = {\n kind: \"m2mEnum\";\n fieldName: string;\n fieldIdName: undefined;\n required: false;\n derived: false;\n /** The enum's metadata, used to map enum codes <-> their numeric ids. */\n enumDetailType: EnumMetadata<any, any, number>;\n serde: undefined;\n immutable: false;\n joinTableName: string;\n /** `[entityColumn, enumColumn]`, e.g. `[\"publisher_id\", \"color_id\"]`. */\n columnNames: [string, string];\n /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */\n hasJoinTableId: boolean;\n};\n\nexport type OneToOneField = {\n kind: \"o2o\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n};\n\nexport type PolymorphicField = {\n kind: \"poly\";\n fieldName: string; // eg `parent`\n fieldIdName: string; // `parentId`\n required: boolean;\n components: PolymorphicFieldComponent[];\n serde: PolymorphicKeySerde;\n immutable: boolean;\n};\n\nexport type PolymorphicFieldComponent = {\n otherMetadata: () => EntityMetadata;\n otherFieldName: string; // eg `comment` or `comments`\n columnName: string; // eg `parent_book_id` or `parent_book_review_id`\n column: Column;\n};\n\nexport function isOneToManyField(ormField: Field): ormField is OneToManyField {\n return ormField.kind === \"o2m\";\n}\n\nexport function isManyToOneField(ormField: Field): ormField is ManyToOneField {\n return ormField.kind === \"m2o\";\n}\n\nexport function isManyToManyField(ormField: Field): ormField is ManyToManyField {\n return ormField.kind === \"m2m\";\n}\n\nexport function isManyToManyEnumField(ormField: Field): ormField is ManyToManyEnumField {\n return ormField.kind === \"m2mEnum\";\n}\n\nexport function isOneToOneField(ormField: Field): ormField is OneToOneField {\n return ormField.kind === \"o2o\";\n}\n\nexport function isPolymorphicField(ormField: Field): ormField is PolymorphicField {\n return ormField.kind === \"poly\";\n}\n\nexport function isReferenceField(ormField: Field): ormField is ManyToOneField | OneToOneField | PolymorphicField {\n return ormField.kind === \"m2o\" || ormField.kind === \"o2o\" || ormField.kind === \"poly\";\n}\n\nexport function isCollectionField(ormField: Field): ormField is OneToManyField | ManyToManyField {\n return ormField.kind === \"o2m\" || ormField.kind === \"m2m\";\n}\n\nexport function getBaseAndSelfMetas(meta: EntityMetadata): EntityMetadata[];\nexport function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];\nexport function getBaseAndSelfMetas(param: Entity | EntityMetadata): EntityMetadata[] {\n return isEntity(param)\n ? getBaseSelfAndSubMetas(getMetadata(param))\n : (param.baseSelfMetas ?? [...param.baseTypes, param]);\n}\n\nexport function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[] {\n return meta.baseSelfAndSubMetas ?? [...meta.baseTypes, meta, ...meta.subTypes];\n}\n\nexport function getSubMetas(meta: EntityMetadata): EntityMetadata[] {\n // We should do recursion at some point\n return meta.subTypes;\n}\n\nexport function getBaseMeta(meta: EntityMetadata): EntityMetadata {\n if (!meta.baseType) {\n return meta;\n } else {\n return meta.baseTypes[0];\n }\n}\n"],"mappings":";;;;;AAeA,SAAgB,YACd,OACgB;CAChB,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,yBAAyB,OAAO;CAC5D,OACE,OAAO,UAAU,aAAc,MAAc,WAAW,UAAU,QAAQ,QAAQ,gBAAgB,KAAK,CAAC,CAAC;AAE7G;;AAGA,SAAgB,oBAAoB,MAAsB,WAAmC;CAC3F,IAAI,CAAC,KAAK,UAAU,YAAY,MAAM,IAAI,MAAM,UAAU,UAAU,iBAAiB,KAAK,MAAM;CAGhG,OAAO,EAAE,aAAa,KAAK,WAAW,KAAK,UAAU,UAAU,EAAE,gBAAgB,QAAQ,KAAK,UAC5F,OAAO,mBAAmB,KAAK,QAAQ;CAEzC,OAAO;AACT;AAuQA,SAAgB,iBAAiB,UAA6C;CAC5E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,UAA6C;CAC5E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,kBAAkB,UAA8C;CAC9E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,sBAAsB,UAAkD;CACtF,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,gBAAgB,UAA4C;CAC1E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,mBAAmB,UAA+C;CAChF,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,UAAgF;CAC/G,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS;AACjF;AAEA,SAAgB,kBAAkB,UAA+D;CAC/F,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS;AACtD;AAIA,SAAgB,oBAAoB,OAAkD;CACpF,OAAO,SAAS,KAAK,IACjB,uBAAuB,YAAY,KAAK,CAAC,IACxC,MAAM,iBAAiB,CAAC,GAAG,MAAM,WAAW,KAAK;AACxD;AAEA,SAAgB,uBAAuB,MAAwC;CAC7E,OAAO,KAAK,uBAAuB;EAAC,GAAG,KAAK;EAAW;EAAM,GAAG,KAAK;CAAQ;AAC/E;AAEA,SAAgB,YAAY,MAAwC;CAElE,OAAO,KAAK;AACd;AAEA,SAAgB,YAAY,MAAsC;CAChE,IAAI,CAAC,KAAK,UACR,OAAO;MAEP,OAAO,KAAK,UAAU;AAE1B"}
|
|
1
|
+
{"version":3,"file":"EntityMetadata.js","names":[],"sources":["../src/EntityMetadata.ts"],"sourcesContent":["import { getInstanceData } from \"src/BaseEntity.ts\";\nimport type { ConfigApi, Reactable, ReactiveRule } from \"src/config.ts\";\nimport { getMetadataForType } from \"src/configure.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityManager, type MaybeAbstractEntityConstructor, type TimestampFields } from \"src/EntityManager.ts\";\nimport { type EnumMetadata } from \"src/EnumMetadata.ts\";\nimport type { DeepNew } from \"src/loading/loadHints.ts\";\nimport type { SimpleRule } from \"src/rules.ts\";\nimport type { Column, ColumnDescriptors } from \"src/serde/columns.ts\";\nimport type { FieldSerde, PolymorphicKeySerde } from \"src/serde/fieldSerde.ts\";\nimport type { FieldTransitions } from \"src/transitions.ts\";\n\nexport function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;\nexport function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;\nexport function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;\nexport function getMetadata<T extends Entity>(\n param: T | MaybeAbstractEntityConstructor<T> | EntityMetadata,\n): EntityMetadata {\n if (!param) throw new Error(`Cannot getMetadata of ${param}`);\n return (\n typeof param === \"function\" ? (param as any).metadata : \"cstr\" in param ? param : getInstanceData(param).metadata\n ) as EntityMetadata;\n}\n\n/** Returns the metadata layer that declares `fieldName`, i.e. `Task.tags` for `TaskOld.tags`. */\nexport function getMetadataForField(meta: EntityMetadata, fieldName: string): EntityMetadata {\n if (!meta.allFields[fieldName]) throw new Error(`Field '${fieldName}' not found on ${meta.type}`);\n // I.e. `TaskOld.tags` is an STI-inherited `Task.tags` and should walk up, but `SmallPublisherGroup.publishers`\n // is a CTI-specialized `PublisherGroup.publishers` and should stay on `SmallPublisherGroup`.\n while (!(fieldName in meta.fields) && meta.allFields[fieldName]?.specialized !== true && meta.baseType) {\n meta = getMetadataForType(meta.baseType);\n }\n return meta;\n}\n\n/**\n * Runtime metadata about an entity.\n *\n * The `joist-codegen` step will generate this by reading the database schema at build/codegen\n * time, along with any customizations in `joist-config.json`.\n *\n * Note: This has no generic, like `T extends Entity`, because `Entity<IdType>` i.e. with\n * an unknown string/id type, causes issues when we want to generically mix `EntityMetadata`\n * of different types, that even liberally using `EntityMetadata<any>` did not avoid.\n */\nexport interface EntityMetadata<T extends Entity = any> {\n cstr: MaybeAbstractEntityConstructor<T>;\n type: string;\n /** How the domain entity's id is represented. */\n idType: \"tagged-string\" | \"untagged-string\" | \"number\";\n /** The database column type, i.e. used to do `::type` casts in Postgres. */\n idDbType: \"bigint\" | \"int\" | \"uuid\" | \"text\";\n tableName: string;\n /** Whether codegen verified this table is a supported SQL mutation target; does not gate reads. */\n supportsEmExecute?: boolean;\n /** If we're a subtype, our immediate base type's name, e.g. for `SmallPublisher` this would be `Publisher`. */\n baseType: string | undefined;\n inheritanceType?: \"sti\" | \"cti\" | undefined;\n /** Indicates the field to use to derive which subtype to instantiate; only set on the base meta. */\n stiDiscriminatorField?: string;\n /** The discriminator enum value for this subtype; only set on sub metas. */\n stiDiscriminatorValue?: number;\n /** Whether this type is abstract (cannot be instantiated directly). */\n ctiAbstract?: boolean;\n tagName: string;\n fields: Record<string, Field>;\n /** Physical storage descriptors, without CTI base columns; STI metadata shares its base table. */\n columns: ColumnDescriptors;\n allFields: Record<string, Field & { aliasSuffix: string; specialized?: true }>;\n /** Usually polys are in `allFields`, but we pull the components out for comp-specific finds, like `parentBook`. */\n polyComponentFields?: Record<string, Field & { aliasSuffix: string }>;\n // Using `any` to avoid type errors between BaseType.metadata & SubType.metadata static fields\n config: ConfigApi<any, any>;\n /** The lazy lookup of transition config by field, including config from base types. */\n transitions?: ReadonlyMap<string, FieldTransitions>;\n /** The lazy list of non-read-only reactables for this metadata and its base types. */\n reactables?: Reactable[];\n /** The lazy lookup of non-read-only reactables by source field name. */\n reactablesByField?: ReadonlyMap<string, Reactable[]>;\n /** The lazy list of all reactables for this metadata and its base types. */\n reactablesIncludingReadOnly?: Reactable[];\n /** The lazy lookup of all reactables by source field name. */\n reactablesIncludingReadOnlyByField?: ReadonlyMap<string, Reactable[]>;\n /** The lazy list of reactive validation rules for this metadata and its subtypes. */\n reactiveRules?: ReactiveRule[];\n /** The lazy list of reactive *commit* rules (post-flush/pre-commit) for this metadata and its subtypes. */\n reactiveCommitRules?: ReactiveRule[];\n /** The lazy list of non-reactive validation rules, prepared for this concrete type. */\n simpleRules?: SimpleRule[];\n /** The lazy list of non-reactive commit rules, prepared for this concrete type. */\n simpleCommitRules?: SimpleRule[];\n /** Lazily-cached: whether flushing an entity of this type could trigger any `addCommitRule` work. */\n hasCommitRules?: boolean;\n /** The lazily-cached set of own `lazy` primitive field names, i.e. columns excluded from the default SELECT. */\n lazyFieldNames?: ReadonlySet<string>;\n /** The lazily-cached list of sync-derived (`hasReactiveField`-less) field names, recalced during flush. */\n syncDerivedFields?: string[];\n /** Lazily-cached: whether this entity has any `lazy` columns, i.e. so the default SELECT lists columns explicitly. */\n hasLazyColumns?: boolean;\n orderBy: string | undefined;\n /** Flat field names that can be used to find existing rows before creating. I.e. [[\"email\"], [\"author\", \"title\"]]. */\n uniqueBy?: string[][];\n timestampFields: TimestampFields | undefined;\n // Ideally this would be the application-specific EntityManager (to avoid anys), but it doesn't really matter\n factory: (em: EntityManager<any, any, any>, opts?: any) => DeepNew<T>;\n /** The list of base types for this subtype, e.g. for Dog it'd be [Animal, Mammal]. */\n baseTypes: EntityMetadata[];\n /** The list of subtypes for this base type, e.g. for Animal it'd be `[Mammal, Dog]`. */\n subTypes: EntityMetadata[];\n /** Cached `[...baseTypes, this]` set up by `configureMetadata`, so hot paths avoid re-allocating it. */\n baseSelfMetas?: EntityMetadata[];\n /** Cached `[...baseTypes, this, ...subTypes]` set up by `configureMetadata`, so hot paths avoid re-allocating it. */\n baseSelfAndSubMetas?: EntityMetadata[];\n /** The lazy lookup of subtypes by type name, i.e. `Animal.metadata.subTypesByType.get(\"Dog\")`. */\n subTypesByType?: ReadonlyMap<string, EntityMetadata>;\n /** The lazy lookup of STI subtypes by discriminator value, i.e. `Task.metadata.subTypesByStiValue.get(1)`. */\n subTypesByStiValue?: ReadonlyMap<unknown, EntityMetadata>;\n /** Codegen-assigned family-wide field ordinals, shared by metadata and generated first-read guards. */\n readonly fieldReadIndexes: Readonly<Record<string, number>>;\n /** Codegen-assigned number of first-read words to initialize on each entity in this inheritance family. */\n readonly fieldReadWordCount: number;\n /** The lazy STI discriminator column name, i.e. `Task.metadata.stiDiscriminatorColumnName`. */\n stiDiscriminatorColumnName?: string;\n /** If the schema is lacking deferred FKs, this is our insertion order. */\n nonDeferredFkOrder?: number;\n}\n\nexport type Field = (\n | PrimaryKeyField\n | PrimitiveField\n | EnumField\n | OneToManyField\n | LargeOneToManyField\n | ManyToOneField\n | ManyToManyField\n | ManyToManyEnumField\n | OneToOneField\n | PolymorphicField\n) & {\n /** When true, application reads mark this entity for read locking at flush. */\n assertUnchanged?: boolean;\n};\n\n// Only the fields that have defined `serde` keys; should be a mapped type of Field\nexport type SerdeField = PrimaryKeyField | PrimitiveField | EnumField | ManyToOneField | PolymorphicField;\n\nexport type PrimaryKeyField = {\n kind: \"primaryKey\";\n fieldName: string;\n fieldIdName: undefined;\n required: true;\n serde: FieldSerde;\n immutable: true;\n};\n\nexport type PrimitiveField = {\n kind: \"primitive\";\n fieldName: string;\n fieldIdName: undefined;\n required: boolean;\n derived: \"orm\" | \"sync\" | \"async\" | false;\n protected: boolean;\n type: string | Function;\n serde: FieldSerde;\n immutable: boolean;\n citext?: boolean;\n default?: \"schema\" | \"config\";\n sanitize?: boolean;\n /** When true, this column is excluded from the entity's default SELECT and lazy-loaded via a `LazyField`. */\n lazy?: boolean;\n};\n\nexport type EnumField = {\n kind: \"enum\";\n fieldName: string;\n fieldIdName: undefined;\n required: boolean;\n derived: \"sync\" | \"async\" | false;\n enumDetailType: EnumMetadata<any, { name: string }>;\n /** The enum object, i.e. `{ Draft: \"DRAFT\" }`. */\n enumType: Record<string, unknown>;\n serde: FieldSerde;\n immutable: boolean;\n default?: \"schema\" | \"config\";\n};\n\nexport type OneToManyField = {\n kind: \"o2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n orderBy?: { field: string; direction: \"ASC\" | \"DESC\" };\n /** When `\"include\"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */\n softDeletes?: \"include\" | \"exclude\";\n};\n\nexport type LargeOneToManyField = {\n kind: \"lo2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n};\n\nexport type ManyToOneField = {\n kind: \"m2o\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n serde: FieldSerde;\n immutable: boolean;\n derived: \"async\" | false;\n default?: \"schema\" | \"config\";\n};\n\nexport type ManyToManyField = {\n kind: \"m2m\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n derived: \"async\" | \"otherSide\" | false;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n serde: undefined;\n immutable: false;\n joinTableName: string;\n columnNames: [string, string];\n /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */\n hasJoinTableId: boolean;\n /** When `\"include\"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */\n softDeletes?: \"include\" | \"exclude\";\n};\n\n/**\n * A many-to-many between an entity and an enum \"table\", e.g. `Publisher.logoColors` backed by a\n * `publisher_logo_colors` join table joining `publishers` to the `color` enum table.\n *\n * To the user this looks like an array of enum codes (`Color[]`), but unlike an enum-array column it\n * is lazy (needs a load hint) because it lives in its own join table.\n */\nexport type ManyToManyEnumField = {\n kind: \"m2mEnum\";\n fieldName: string;\n fieldIdName: undefined;\n required: false;\n derived: false;\n /** The enum's metadata, used to map enum codes <-> their numeric ids. */\n enumDetailType: EnumMetadata<any, any, number>;\n serde: undefined;\n immutable: false;\n joinTableName: string;\n /** `[entityColumn, enumColumn]`, e.g. `[\"publisher_id\", \"color_id\"]`. */\n columnNames: [string, string];\n /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */\n hasJoinTableId: boolean;\n};\n\nexport type OneToOneField = {\n kind: \"o2o\";\n fieldName: string;\n fieldIdName: string;\n required: boolean;\n otherMetadata: () => EntityMetadata;\n otherFieldName: string;\n /** Useful when our other side is a poly, to find which component points back to us. */\n otherColumnName: string;\n serde: undefined;\n immutable: false;\n};\n\nexport type PolymorphicField = {\n kind: \"poly\";\n fieldName: string; // eg `parent`\n fieldIdName: string; // `parentId`\n required: boolean;\n components: PolymorphicFieldComponent[];\n serde: PolymorphicKeySerde;\n immutable: boolean;\n};\n\nexport type PolymorphicFieldComponent = {\n otherMetadata: () => EntityMetadata;\n otherFieldName: string; // eg `comment` or `comments`\n columnName: string; // eg `parent_book_id` or `parent_book_review_id`\n column: Column;\n};\n\nexport function isOneToManyField(ormField: Field): ormField is OneToManyField {\n return ormField.kind === \"o2m\";\n}\n\nexport function isManyToOneField(ormField: Field): ormField is ManyToOneField {\n return ormField.kind === \"m2o\";\n}\n\nexport function isManyToManyField(ormField: Field): ormField is ManyToManyField {\n return ormField.kind === \"m2m\";\n}\n\nexport function isManyToManyEnumField(ormField: Field): ormField is ManyToManyEnumField {\n return ormField.kind === \"m2mEnum\";\n}\n\nexport function isOneToOneField(ormField: Field): ormField is OneToOneField {\n return ormField.kind === \"o2o\";\n}\n\nexport function isPolymorphicField(ormField: Field): ormField is PolymorphicField {\n return ormField.kind === \"poly\";\n}\n\nexport function isReferenceField(ormField: Field): ormField is ManyToOneField | OneToOneField | PolymorphicField {\n return ormField.kind === \"m2o\" || ormField.kind === \"o2o\" || ormField.kind === \"poly\";\n}\n\nexport function isCollectionField(ormField: Field): ormField is OneToManyField | ManyToManyField {\n return ormField.kind === \"o2m\" || ormField.kind === \"m2m\";\n}\n\nexport function getBaseAndSelfMetas(meta: EntityMetadata): EntityMetadata[];\nexport function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];\nexport function getBaseAndSelfMetas(param: Entity | EntityMetadata): EntityMetadata[] {\n return isEntity(param)\n ? getBaseSelfAndSubMetas(getMetadata(param))\n : (param.baseSelfMetas ?? [...param.baseTypes, param]);\n}\n\nexport function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[] {\n return meta.baseSelfAndSubMetas ?? [...meta.baseTypes, meta, ...meta.subTypes];\n}\n\nexport function getSubMetas(meta: EntityMetadata): EntityMetadata[] {\n // We should do recursion at some point\n return meta.subTypes;\n}\n\nexport function getBaseMeta(meta: EntityMetadata): EntityMetadata {\n if (!meta.baseType) {\n return meta;\n } else {\n return meta.baseTypes[0];\n }\n}\n"],"mappings":";;;;;AAeA,SAAgB,YACd,OACgB;CAChB,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,yBAAyB,OAAO;CAC5D,OACE,OAAO,UAAU,aAAc,MAAc,WAAW,UAAU,QAAQ,QAAQ,gBAAgB,KAAK,CAAC,CAAC;AAE7G;;AAGA,SAAgB,oBAAoB,MAAsB,WAAmC;CAC3F,IAAI,CAAC,KAAK,UAAU,YAAY,MAAM,IAAI,MAAM,UAAU,UAAU,iBAAiB,KAAK,MAAM;CAGhG,OAAO,EAAE,aAAa,KAAK,WAAW,KAAK,UAAU,UAAU,EAAE,gBAAgB,QAAQ,KAAK,UAC5F,OAAO,mBAAmB,KAAK,QAAQ;CAEzC,OAAO;AACT;AA2QA,SAAgB,iBAAiB,UAA6C;CAC5E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,UAA6C;CAC5E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,kBAAkB,UAA8C;CAC9E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,sBAAsB,UAAkD;CACtF,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,gBAAgB,UAA4C;CAC1E,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,mBAAmB,UAA+C;CAChF,OAAO,SAAS,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,UAAgF;CAC/G,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS,SAAS;AACjF;AAEA,SAAgB,kBAAkB,UAA+D;CAC/F,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS;AACtD;AAIA,SAAgB,oBAAoB,OAAkD;CACpF,OAAO,SAAS,KAAK,IACjB,uBAAuB,YAAY,KAAK,CAAC,IACxC,MAAM,iBAAiB,CAAC,GAAG,MAAM,WAAW,KAAK;AACxD;AAEA,SAAgB,uBAAuB,MAAwC;CAC7E,OAAO,KAAK,uBAAuB;EAAC,GAAG,KAAK;EAAW;EAAM,GAAG,KAAK;CAAQ;AAC/E;AAEA,SAAgB,YAAY,MAAwC;CAElE,OAAO,KAAK;AACd;AAEA,SAAgB,YAAY,MAAsC;CAChE,IAAI,CAAC,KAAK,UACR,OAAO;MAEP,OAAO,KAAK,UAAU;AAE1B"}
|
package/build/EnumMetadata.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/EnumMetadata.d.ts
|
|
2
1
|
export interface EnumMetadata<C, D, I extends number | string = number | string> {
|
|
3
2
|
/** Returns the enum type's name, i.e. `AuthorStatus`. */
|
|
4
3
|
name: string;
|
|
@@ -13,5 +12,4 @@ export interface EnumMetadata<C, D, I extends number | string = number | string>
|
|
|
13
12
|
/** Returns all the details. */
|
|
14
13
|
getDetails(): ReadonlyArray<D>;
|
|
15
14
|
}
|
|
16
|
-
//#endregion
|
|
17
15
|
//# sourceMappingURL=EnumMetadata.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumMetadata.d.cts","names":[],"sources":["../src/EnumMetadata.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EnumMetadata.d.cts","names":[],"sources":["../src/EnumMetadata.ts"],"mappings":"A,iBAAiB,aAAa,GAAG,GAAG;;EAElC;;EAGA,UAAU,MAAM,IAAI;;EAGpB,WAAW,eAAe;;EAG1B,SAAS,IAAI,IAAI;;EAGjB,aAAa,cAAc;;EAG3B,cAAc,cAAc"}
|
package/build/EnumMetadata.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/EnumMetadata.d.ts
|
|
2
1
|
export interface EnumMetadata<C, D, I extends number | string = number | string> {
|
|
3
2
|
/** Returns the enum type's name, i.e. `AuthorStatus`. */
|
|
4
3
|
name: string;
|
|
@@ -13,5 +12,4 @@ export interface EnumMetadata<C, D, I extends number | string = number | string>
|
|
|
13
12
|
/** Returns all the details. */
|
|
14
13
|
getDetails(): ReadonlyArray<D>;
|
|
15
14
|
}
|
|
16
|
-
//#endregion
|
|
17
15
|
//# sourceMappingURL=EnumMetadata.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumMetadata.d.mts","names":[],"sources":["../src/EnumMetadata.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EnumMetadata.d.mts","names":[],"sources":["../src/EnumMetadata.ts"],"mappings":"A,iBAAiB,aAAa,GAAG,GAAG;;EAElC;;EAGA,UAAU,MAAM,IAAI;;EAGpB,WAAW,eAAe;;EAG1B,SAAS,IAAI,IAAI;;EAGjB,aAAa,cAAc;;EAG3B,cAAc,cAAc"}
|
package/build/IndexManager.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_relations_Reference = require("./relations/Reference.cjs");
|
|
3
|
-
require("./relations/index.cjs");
|
|
4
|
-
const require_utils = require("./utils.cjs");
|
|
5
|
-
const require_EntityMetadata = require("./EntityMetadata.cjs");
|
|
6
3
|
const require_dataloaders_fastWhereFilterHash = require("./dataloaders/fastWhereFilterHash.cjs");
|
|
7
4
|
const require_Entity = require("./Entity.cjs");
|
|
8
|
-
|
|
5
|
+
const require_EntityMetadata = require("./EntityMetadata.cjs");
|
|
6
|
+
require("./relations/index.cjs");
|
|
7
|
+
const require_utils = require("./utils.cjs");
|
|
8
|
+
// src/IndexManager.ts
|
|
9
9
|
const emptySet = /* @__PURE__ */ new Set();
|
|
10
10
|
const indexThreshold = 500;
|
|
11
11
|
/**
|
|
@@ -189,7 +189,6 @@ function intersectSets(set1, set2) {
|
|
|
189
189
|
for (const item of smaller) if (larger.has(item)) result.add(item);
|
|
190
190
|
return result;
|
|
191
191
|
}
|
|
192
|
-
//#endregion
|
|
193
192
|
exports.IndexManager = IndexManager;
|
|
194
193
|
exports.indexThreshold = indexThreshold;
|
|
195
194
|
|
package/build/IndexManager.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { EntityMetadata } from "./EntityMetadata.cjs";
|
|
2
1
|
import { Entity } from "./Entity.cjs";
|
|
3
|
-
|
|
2
|
+
import { EntityMetadata } from "./EntityMetadata.cjs";
|
|
4
3
|
export declare const indexThreshold = 500;
|
|
5
4
|
/**
|
|
6
5
|
* IndexManager provides field-based indexing for entity queries to avoid O(n) linear scans of `em.entities`.
|
|
@@ -31,5 +30,4 @@ export declare class IndexManager {
|
|
|
31
30
|
/** Lazily indexes newly-registered entities only for fields that are queried. */
|
|
32
31
|
private indexUnindexedEntities;
|
|
33
32
|
}
|
|
34
|
-
//#endregion
|
|
35
33
|
//# sourceMappingURL=IndexManager.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexManager.d.cts","names":[],"sources":["../src/IndexManager.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IndexManager.d.cts","names":[],"sources":["../src/IndexManager.ts"],"mappings":";;qBAkBa;;;;;;;;;qBAUA;;;EAIX,gBAAgB;;EAKhB,UAAU;;EAKV,sBAAsB,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK;;EAsBhF,sBAAsB,QAAQ,QAAQ,mBAAmB,eAAe;;;;;;;EAqBxE,aAAa,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK,aAAa,YAAY;UA0BxF;;UAuBA"}
|
package/build/IndexManager.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { EntityMetadata } from "./EntityMetadata.mjs";
|
|
2
1
|
import { Entity } from "./Entity.mjs";
|
|
3
|
-
|
|
2
|
+
import { EntityMetadata } from "./EntityMetadata.mjs";
|
|
4
3
|
export declare const indexThreshold = 500;
|
|
5
4
|
/**
|
|
6
5
|
* IndexManager provides field-based indexing for entity queries to avoid O(n) linear scans of `em.entities`.
|
|
@@ -31,5 +30,4 @@ export declare class IndexManager {
|
|
|
31
30
|
/** Lazily indexes newly-registered entities only for fields that are queried. */
|
|
32
31
|
private indexUnindexedEntities;
|
|
33
32
|
}
|
|
34
|
-
//#endregion
|
|
35
33
|
//# sourceMappingURL=IndexManager.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexManager.d.mts","names":[],"sources":["../src/IndexManager.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IndexManager.d.mts","names":[],"sources":["../src/IndexManager.ts"],"mappings":";;qBAkBa;;;;;;;;;qBAUA;;;EAIX,gBAAgB;;EAKhB,UAAU;;EAKV,sBAAsB,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK;;EAsBhF,sBAAsB,QAAQ,QAAQ,mBAAmB,eAAe;;;;;;;EAqBxE,aAAa,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK,aAAa,YAAY;UA0BxF;;UAuBA"}
|
package/build/IndexManager.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isLoadedReference } from "./relations/Reference.js";
|
|
2
|
-
import "./relations/index.js";
|
|
3
|
-
import { groupBy } from "./utils.js";
|
|
4
|
-
import { getMetadata } from "./EntityMetadata.js";
|
|
5
2
|
import { fastWhereFilterHash } from "./dataloaders/fastWhereFilterHash.js";
|
|
6
3
|
import { isEntity } from "./Entity.js";
|
|
7
|
-
|
|
4
|
+
import { getMetadata } from "./EntityMetadata.js";
|
|
5
|
+
import "./relations/index.js";
|
|
6
|
+
import { groupBy } from "./utils.js";
|
|
7
|
+
// src/IndexManager.ts
|
|
8
8
|
const emptySet = /* @__PURE__ */ new Set();
|
|
9
9
|
const indexThreshold = 500;
|
|
10
10
|
/**
|
|
@@ -188,7 +188,6 @@ function intersectSets(set1, set2) {
|
|
|
188
188
|
for (const item of smaller) if (larger.has(item)) result.add(item);
|
|
189
189
|
return result;
|
|
190
190
|
}
|
|
191
|
-
//#endregion
|
|
192
191
|
export { IndexManager, indexThreshold };
|
|
193
192
|
|
|
194
193
|
//# sourceMappingURL=IndexManager.js.map
|
package/build/InstanceData.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./Entity.cjs");
|
|
3
|
+
const require_EntityManager = require("./EntityManager.cjs");
|
|
4
|
+
require("./EntityMetadata.cjs");
|
|
2
5
|
const require_RowData = require("./RowData.cjs");
|
|
3
6
|
const require_utils = require("./utils.cjs");
|
|
4
|
-
|
|
5
|
-
const require_EntityManager = require("./EntityManager.cjs");
|
|
6
|
-
require("./Entity.cjs");
|
|
7
|
-
//#region src/InstanceData.ts
|
|
7
|
+
// src/InstanceData.ts
|
|
8
8
|
/** The `#orm` metadata field we track on each instance. */
|
|
9
9
|
var InstanceData = class {
|
|
10
10
|
/** The entity this instance data belongs to. */
|
|
@@ -21,6 +21,12 @@ var InstanceData = class {
|
|
|
21
21
|
rowIndex = 0;
|
|
22
22
|
/** The domain-value of fields, lazily converted (if needed) on read from the database columns. */
|
|
23
23
|
data;
|
|
24
|
+
/** Present only on visibility-aware entities; untrusted reads never reuse these approvals. */
|
|
25
|
+
trustedReadFields = void 0;
|
|
26
|
+
/** Reentrancy is transient, independent of whether a read may be cached. */
|
|
27
|
+
activeReadFields = void 0;
|
|
28
|
+
/** Number/untagged ID conversions are cached once; assigned entity IDs never change. */
|
|
29
|
+
idCache = void 0;
|
|
24
30
|
/** A bag to keep the original values, allocated on first mutation (most entities are never mutated). */
|
|
25
31
|
#originalData = void 0;
|
|
26
32
|
/** Reference values that were set during this unit of work, allocated on first m2o/poly change. */
|
|
@@ -144,7 +150,8 @@ var InstanceData = class {
|
|
|
144
150
|
/** Called by `em.delete`, returns true if this is new information. */
|
|
145
151
|
markDeleted() {
|
|
146
152
|
if (this.#deleted === void 0) {
|
|
147
|
-
|
|
153
|
+
const api = require_EntityManager.getEmInternalApi(this.em);
|
|
154
|
+
for (const field of Object.values(this.metadata.allFields)) if (field.kind === "m2o" || field.kind === "poly" || field.kind === "m2m" || field.kind === "m2mEnum") api.isLoadedCache.resetIsLoaded(this.entity, field.fieldName);
|
|
148
155
|
else if (field.kind === "primitive" || field.kind === "enum" || field.kind === "primaryKey") {} else if (field.kind === "o2m" || field.kind === "o2o") {} else if (field.kind === "lo2m") {} else throw new Error(`Unhandled field kind ${field}`);
|
|
149
156
|
this.#deleted = 1;
|
|
150
157
|
this.markMaybePending();
|
|
@@ -212,7 +219,6 @@ var InstanceData = class {
|
|
|
212
219
|
const emptyObject = Object.freeze({});
|
|
213
220
|
/** A shared frozen array for fields with no remembered reference values. */
|
|
214
221
|
const emptyArray = Object.freeze([]);
|
|
215
|
-
//#endregion
|
|
216
222
|
exports.InstanceData = InstanceData;
|
|
217
223
|
|
|
218
224
|
//# sourceMappingURL=InstanceData.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstanceData.cjs","names":["emptyRowData","hasAnyKey"],"sources":["../src/InstanceData.ts"],"sourcesContent":["import { type Entity } from \"src/Entity.ts\";\nimport { type EntityManager, getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata } from \"src/EntityMetadata.ts\";\nimport { type RowData, emptyRowData } from \"src/RowData.ts\";\nimport { hasAnyKey } from \"src/utils.ts\";\n\n/** The `#orm` metadata field we track on each instance. */\nexport class InstanceData {\n /** The entity this instance data belongs to. */\n readonly entity: Entity;\n /** All entities must be associated to an `EntityManager` to handle lazy loading/etc. */\n readonly em: EntityManager;\n /** A pointer to our entity type's metadata. */\n readonly metadata: EntityMetadata;\n /** A bag for our lazy-initialized relations, allocated on first relation access. */\n relations: Record<any, any> | undefined = undefined;\n /** The as-loaded database row, i.e. our `rowIndex`-th row within our query's `RowData` result. */\n rowData: RowData = emptyRowData;\n /** Our row's index within `rowData`; see {@link RowData}. */\n rowIndex: number = 0;\n /** The domain-value of fields, lazily converted (if needed) on read from the database columns. */\n data: Record<string, any>;\n /** A bag to keep the original values, allocated on first mutation (most entities are never mutated). */\n #originalData: Record<any, any> | undefined = undefined;\n /** Reference values that were set during this unit of work, allocated on first m2o/poly change. */\n #referenceHistory: Record<string, any[]> | undefined = undefined;\n /** A bag to keep the flushed-to-database values, only for AsyncReactiveField reactivity. */\n flushedData: Record<any, any> | undefined;\n /** Packs the new/deleted `Operation`s + isTouched into one slot; see the accessors below. */\n #flags: number = 0;\n /** The `a#1`, `a#2` index if we're an em.create-d entity. We never unset this, to keep ids stable across flushes. */\n createId: string | undefined;\n /** The zero-based order this entity was registered with its EntityManager. */\n entityIndex: number = -1;\n\n /** Whether our entity is new or not. */\n get #new(): Operation | undefined {\n const value = this.#flags & 0b11;\n return value === 0 ? undefined : value;\n }\n\n set #new(op: Operation | undefined) {\n this.#flags = (this.#flags & ~0b11) | (op ?? 0);\n }\n\n /**\n * Whether our entity has been deleted or not.\n *\n * - `pending` means we've been marked for deletion via `em.delete` but not issued a `DELETE`\n * - `flushed` means we've flushed a `DELETE` but `em.flush` hasn't fully completed yet, likely due to AsyncReactiveField calcs\n * - `deleted` means we've been flushed and `em.flush` has completed\n */\n get #deleted(): Operation | undefined {\n const value = (this.#flags >> 2) & 0b11;\n return value === 0 ? undefined : value;\n }\n\n set #deleted(op: Operation | undefined) {\n this.#flags = (this.#flags & ~0b1100) | ((op ?? 0) << 2);\n }\n\n /** Whether our entity should flush regardless of any other changes. */\n get isTouched(): boolean {\n return (this.#flags & 0b10000) !== 0;\n }\n\n set isTouched(value: boolean) {\n this.#flags = value ? this.#flags | 0b10000 : this.#flags & ~0b10000;\n }\n\n /** Creates the `#orm` field. */\n constructor(em: EntityManager, entity: Entity, metadata: EntityMetadata, isNew: boolean) {\n this.entity = entity;\n this.em = em;\n this.metadata = metadata;\n if (isNew) {\n this.#new = Operation.Pending;\n this.data = {};\n this.flushedData = undefined;\n if (em) this.markMaybePending();\n } else {\n this.#new = undefined;\n this.data = {};\n this.flushedData = undefined;\n }\n }\n\n /**\n * Returns the as-loaded value of `columnName`, i.e. `getColumn(\"rank\")`.\n *\n * This saves callers from knowing that `rowData`/`rowIndex` are a pair, but note it is\n * a snapshot of the query that loaded us, and specifically:\n *\n * - The value is driver-level, i.e. numeric enum ids, untagged foreign keys, and temporals\n * as strings; use `getField` if you want the domain value, and\n * - The value is not updated by `em.flush`, so after a flush it is the pre-flush value, and\n * - New entities have no row, so every column is `undefined`.\n */\n getColumn(columnName: string): any {\n return this.rowData.get(this.rowIndex, columnName);\n }\n\n /** If `em.flush` has detected a dirty RQF, reset our internal dirty state, w/o reseting our external-dirty state. */\n resetForRqfLoop() {\n this.flushedData = {};\n if (this.#new === Operation.Pending) this.#new = Operation.Flushed;\n if (this.#deleted === Operation.Pending) this.#deleted = Operation.Flushed;\n }\n\n resetAfterFlushed() {\n this.#originalData = undefined;\n this.#referenceHistory = undefined;\n this.flushedData = undefined;\n this.isTouched = false;\n if (this.#new === Operation.Pending || this.#new === Operation.Flushed) {\n this.#new = Operation.Complete;\n }\n if (this.#deleted === Operation.Pending || this.#deleted === Operation.Flushed) {\n this.#deleted = Operation.Complete;\n }\n this.unmarkMaybePending();\n }\n\n /** Our public-facing `isNewEntity`. */\n get isNewEntity(): boolean {\n return this.#new !== undefined && this.#new !== Operation.Complete;\n }\n\n /** Our public-facing `isDeletedEntity`. */\n get isDeletedEntity(): boolean {\n return this.#deleted !== undefined;\n }\n\n /** The original values of mutated fields; a shared empty object until the entity is actually mutated. */\n get originalData(): Record<any, any> {\n return this.#originalData ?? emptyObject;\n }\n\n /** Our public-facing `isDirtyEntity`. */\n get isDirtyEntity(): boolean {\n return hasAnyKey(this.#originalData);\n }\n\n /** This is our internal \"is pending flush\", which is aware of RQF micro-flush loops. */\n get pendingOperation(): \"insert\" | \"update\" | \"delete\" | \"none\" | \"created-then-deleted\" {\n if (this.#deleted !== undefined) {\n // Mark entities that were created and them immediately `em.delete`-d; granted this is\n // probably rare, but we shouldn't run hooks or have the driver try and delete these.\n // Note that we return them, instead of skipping entirely, so that fixupCreatedThenDeleted\n // can later be called.\n return this.#deleted === Operation.Pending && this.#new === Operation.Pending\n ? \"created-then-deleted\"\n : this.#deleted === Operation.Pending\n ? \"delete\"\n : \"none\";\n } else if (this.#new === Operation.Pending) {\n // Per ^, if `#new === flushed`, we fall through to check if micro-flush UPDATEs are required\n return \"insert\";\n } else if (this.flushedData) {\n return hasAnyKey(this.flushedData) ? \"update\" : \"none\";\n } else {\n return this.isTouched || hasAnyKey(this.#originalData) ? \"update\" : \"none\";\n }\n }\n\n get changedFields(): string[] {\n return Object.keys(this.changedData);\n }\n\n /** The changed-fields bag (flushedData during RQF loops, else originalData) without allocating a keys array. */\n get changedData(): Record<any, any> {\n return this.flushedData ?? this.#originalData ?? emptyObject;\n }\n\n /** Called when an `em.load` tries to find the entity and it's just gone from the db. */\n markDeletedBecauseNotFound(): void {\n this.#deleted = Operation.Complete;\n }\n\n /** Called by `em.delete`, returns true if this is new information. */\n markDeleted(): boolean {\n if (this.#deleted === undefined) {\n // Let any OneToManyCollection/ReactiveField/ReactiveReference.get caches know that they should recalc\n // (i.e. their filterDeleted logic) by asserting the `deleteBook.author` field is changing.\n for (const field of Object.values(this.metadata.allFields)) {\n // We only do reference/collection fields and skip the primitives, b/c we assume something like\n // `{ books: \"title\" }` doesn't need `resetIsLoaded(..., \"title\")` b/c the same hint will also\n // be watching \"did books change\", and so get reset that way.\n if (field.kind === \"m2o\" || field.kind === \"poly\" || field.kind === \"m2m\" || field.kind === \"m2mEnum\") {\n getEmInternalApi(this.em).isLoadedCache.resetIsLoaded(this.entity, field.fieldName);\n } else if (field.kind === \"primitive\" || field.kind === \"enum\" || field.kind === \"primaryKey\") {\n // Any reactable watching these fields will also be watching reference/collection\n } else if (field.kind === \"o2m\" || field.kind === \"o2o\") {\n // Any reactable watching these actually gets triggered by the primary m2o/poly side changing\n } else if (field.kind === \"lo2m\") {\n // Doesn't support reactivity\n } else {\n throw new Error(`Unhandled field kind ${field}`);\n }\n }\n this.#deleted = Operation.Pending;\n this.markMaybePending();\n return true;\n }\n return false;\n }\n\n fixupCreatedThenDeleted(): void {\n // Ideally we could do this via `resetAfterFlushed`?\n this.#deleted = Operation.Complete;\n this.unmarkMaybePending();\n }\n\n /** Marks this entity as needing a flush even if no fields changed. */\n markTouched(): void {\n this.isTouched = true;\n this.markMaybePending();\n }\n\n /** Marks a field as dirty with its pre-mutation value. */\n markFieldDirty(fieldName: string, value: any): void {\n (this.#originalData ??= {})[fieldName] = value;\n this.markMaybePending();\n }\n\n /** Marks a reverted field as clean again. */\n markFieldClean(fieldName: string): void {\n if (this.#originalData) delete this.#originalData[fieldName];\n this.markMaybePending();\n }\n\n /** Marks this entity as a possible flush candidate. */\n markMaybePending(): void {\n getEmInternalApi(this.em).markMaybePending(this.entity);\n }\n\n /** Removes this entity from the possible flush candidate set. */\n private unmarkMaybePending(): void {\n getEmInternalApi(this.em).unmarkMaybePending(this.entity);\n }\n\n /** Remembers a reference value that may need to be reverse-walked later. */\n rememberReferenceValue(fieldName: string, value: any): void {\n if (value === undefined) return;\n const values = ((this.#referenceHistory ??= {})[fieldName] ??= []);\n if (!values.includes(value)) values.push(value);\n }\n\n /** Returns reference values that may need to be reverse-walked later. */\n getReferenceHistory(fieldName: string): readonly any[] {\n return this.#referenceHistory?.[fieldName] ?? emptyArray;\n }\n\n get isDeletedAndFlushed(): boolean {\n return this.#deleted === Operation.Complete;\n }\n\n /**\n * Returns true if the entity is new or was new in this EM.\n *\n * This is primarily used for lazy-initializing relations, i.e. if:\n *\n * - A new `Author` is created\n * - We `em.flush` the author to the database\n * - Then `a1.books` is accessed for the first time\n *\n * We can have a high-confidence that `a1` has no books, because we just\n * created it, so we can set the OneToManyCollection to loaded.\n */\n get isOrWasNew(): boolean {\n // #new will be left as `complete`\n return this.#new !== undefined;\n }\n}\n\n/** An enum to track our insert/delete state progression. */\nenum Operation {\n Pending = 1,\n Flushed = 2,\n Complete = 3,\n}\n\n/** A shared frozen bag for un-mutated entities; strict mode makes accidental writes throw. */\nconst emptyObject: Record<any, any> = Object.freeze({});\n\n/** A shared frozen array for fields with no remembered reference values. */\nconst emptyArray: readonly any[] = Object.freeze([]);\n"],"mappings":";;;;;;;;AAOA,IAAa,eAAb,MAA0B;;CAExB;;CAEA;;CAEA;;CAEA,YAA0C,KAAA;;CAE1C,UAAmBA,gBAAAA;;CAEnB,WAAmB;;CAEnB;;CAEA,gBAA8C,KAAA;;CAE9C,oBAAuD,KAAA;;CAEvD;;CAEA,SAAiB;;CAEjB;;CAEA,cAAsB;;CAGtB,IAAI,OAA8B;EAChC,MAAM,QAAQ,KAAK,SAAS;EAC5B,OAAO,UAAU,IAAI,KAAA,IAAY;CACnC;CAEA,IAAI,KAAK,IAA2B;EAClC,KAAK,SAAU,KAAK,SAAS,MAAU,MAAM;CAC/C;;;;;;;;CASA,IAAI,WAAkC;EACpC,MAAM,QAAS,KAAK,UAAU,IAAK;EACnC,OAAO,UAAU,IAAI,KAAA,IAAY;CACnC;CAEA,IAAI,SAAS,IAA2B;EACtC,KAAK,SAAU,KAAK,SAAS,OAAa,MAAM,MAAM;CACxD;;CAGA,IAAI,YAAqB;EACvB,QAAQ,KAAK,SAAS,QAAa;CACrC;CAEA,IAAI,UAAU,OAAgB;EAC5B,KAAK,SAAS,QAAQ,KAAK,SAAS,KAAU,KAAK,SAAS;CAC9D;;CAGA,YAAY,IAAmB,QAAgB,UAA0B,OAAgB;EACvF,KAAK,SAAS;EACd,KAAK,KAAK;EACV,KAAK,WAAW;EAChB,IAAI,OAAO;GACT,KAAK,OAAA;GACL,KAAK,OAAO,CAAC;GACb,KAAK,cAAc,KAAA;GACnB,IAAI,IAAI,KAAK,iBAAiB;EAChC,OAAO;GACL,KAAK,OAAO,KAAA;GACZ,KAAK,OAAO,CAAC;GACb,KAAK,cAAc,KAAA;EACrB;CACF;;;;;;;;;;;;CAaA,UAAU,YAAyB;EACjC,OAAO,KAAK,QAAQ,IAAI,KAAK,UAAU,UAAU;CACnD;;CAGA,kBAAkB;EAChB,KAAK,cAAc,CAAC;EACpB,IAAI,KAAK,SAAA,GAA4B,KAAK,OAAA;EAC1C,IAAI,KAAK,aAAA,GAAgC,KAAK,WAAA;CAChD;CAEA,oBAAoB;EAClB,KAAK,gBAAgB,KAAA;EACrB,KAAK,oBAAoB,KAAA;EACzB,KAAK,cAAc,KAAA;EACnB,KAAK,YAAY;EACjB,IAAI,KAAK,SAAA,KAA8B,KAAK,SAAA,GAC1C,KAAK,OAAA;EAEP,IAAI,KAAK,aAAA,KAAkC,KAAK,aAAA,GAC9C,KAAK,WAAA;EAEP,KAAK,mBAAmB;CAC1B;;CAGA,IAAI,cAAuB;EACzB,OAAO,KAAK,SAAS,KAAA,KAAa,KAAK,SAAA;CACzC;;CAGA,IAAI,kBAA2B;EAC7B,OAAO,KAAK,aAAa,KAAA;CAC3B;;CAGA,IAAI,eAAiC;EACnC,OAAO,KAAK,iBAAiB;CAC/B;;CAGA,IAAI,gBAAyB;EAC3B,OAAOC,cAAAA,UAAU,KAAK,aAAa;CACrC;;CAGA,IAAI,mBAAqF;EACvF,IAAI,KAAK,aAAa,KAAA,GAKpB,OAAO,KAAK,aAAA,KAAkC,KAAK,SAAA,IAC/C,yBACA,KAAK,aAAA,IACH,WACA;OACD,IAAI,KAAK,SAAA,GAEd,OAAO;OACF,IAAI,KAAK,aACd,OAAOA,cAAAA,UAAU,KAAK,WAAW,IAAI,WAAW;OAEhD,OAAO,KAAK,aAAaA,cAAAA,UAAU,KAAK,aAAa,IAAI,WAAW;CAExE;CAEA,IAAI,gBAA0B;EAC5B,OAAO,OAAO,KAAK,KAAK,WAAW;CACrC;;CAGA,IAAI,cAAgC;EAClC,OAAO,KAAK,eAAe,KAAK,iBAAiB;CACnD;;CAGA,6BAAmC;EACjC,KAAK,WAAA;CACP;;CAGA,cAAuB;EACrB,IAAI,KAAK,aAAa,KAAA,GAAW;GAG/B,KAAK,MAAM,SAAS,OAAO,OAAO,KAAK,SAAS,SAAS,GAIvD,IAAI,MAAM,SAAS,SAAS,MAAM,SAAS,UAAU,MAAM,SAAS,SAAS,MAAM,SAAS,WAC1F,sBAAA,iBAAiB,KAAK,EAAE,CAAC,CAAC,cAAc,cAAc,KAAK,QAAQ,MAAM,SAAS;QAC7E,IAAI,MAAM,SAAS,eAAe,MAAM,SAAS,UAAU,MAAM,SAAS,cAAc,CAE/F,OAAO,IAAI,MAAM,SAAS,SAAS,MAAM,SAAS,OAAO,CAEzD,OAAO,IAAI,MAAM,SAAS,QAAQ,CAElC,OACE,MAAM,IAAI,MAAM,wBAAwB,OAAO;GAGnD,KAAK,WAAA;GACL,KAAK,iBAAiB;GACtB,OAAO;EACT;EACA,OAAO;CACT;CAEA,0BAAgC;EAE9B,KAAK,WAAA;EACL,KAAK,mBAAmB;CAC1B;;CAGA,cAAoB;EAClB,KAAK,YAAY;EACjB,KAAK,iBAAiB;CACxB;;CAGA,eAAe,WAAmB,OAAkB;EAClD,CAAC,KAAK,kBAAkB,CAAC,EAAA,CAAG,aAAa;EACzC,KAAK,iBAAiB;CACxB;;CAGA,eAAe,WAAyB;EACtC,IAAI,KAAK,eAAe,OAAO,KAAK,cAAc;EAClD,KAAK,iBAAiB;CACxB;;CAGA,mBAAyB;EACvB,sBAAA,iBAAiB,KAAK,EAAE,CAAC,CAAC,iBAAiB,KAAK,MAAM;CACxD;;CAGA,qBAAmC;EACjC,sBAAA,iBAAiB,KAAK,EAAE,CAAC,CAAC,mBAAmB,KAAK,MAAM;CAC1D;;CAGA,uBAAuB,WAAmB,OAAkB;EAC1D,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAU,CAAC,KAAK,sBAAsB,CAAC,EAAA,CAAG,eAAe,CAAC;EAChE,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO,KAAK,KAAK;CAChD;;CAGA,oBAAoB,WAAmC;EACrD,OAAO,KAAK,oBAAoB,cAAc;CAChD;CAEA,IAAI,sBAA+B;EACjC,OAAO,KAAK,aAAA;CACd;;;;;;;;;;;;;CAcA,IAAI,aAAsB;EAExB,OAAO,KAAK,SAAS,KAAA;CACvB;AACF;;AAUA,MAAM,cAAgC,OAAO,OAAO,CAAC,CAAC;;AAGtD,MAAM,aAA6B,OAAO,OAAO,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"InstanceData.cjs","names":["emptyRowData","hasAnyKey","getEmInternalApi"],"sources":["../src/InstanceData.ts"],"sourcesContent":["import { type Entity } from \"src/Entity.ts\";\nimport { type EntityManager, getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata } from \"src/EntityMetadata.ts\";\nimport { type RowData, emptyRowData } from \"src/RowData.ts\";\nimport { hasAnyKey } from \"src/utils.ts\";\n\n/** The `#orm` metadata field we track on each instance. */\nexport class InstanceData {\n /** The entity this instance data belongs to. */\n readonly entity: Entity;\n /** All entities must be associated to an `EntityManager` to handle lazy loading/etc. */\n readonly em: EntityManager;\n /** A pointer to our entity type's metadata. */\n readonly metadata: EntityMetadata;\n /** A bag for our lazy-initialized relations, allocated on first relation access. */\n relations: Record<any, any> | undefined = undefined;\n /** The as-loaded database row, i.e. our `rowIndex`-th row within our query's `RowData` result. */\n rowData: RowData = emptyRowData;\n /** Our row's index within `rowData`; see {@link RowData}. */\n rowIndex: number = 0;\n /** The domain-value of fields, lazily converted (if needed) on read from the database columns. */\n data: Record<string, any>;\n /** Present only on visibility-aware entities; untrusted reads never reuse these approvals. */\n trustedReadFields: number[] | undefined = undefined;\n /** Reentrancy is transient, independent of whether a read may be cached. */\n activeReadFields: Set<string> | undefined = undefined;\n /** Number/untagged ID conversions are cached once; assigned entity IDs never change. */\n idCache: string | number | undefined = undefined;\n /** A bag to keep the original values, allocated on first mutation (most entities are never mutated). */\n #originalData: Record<any, any> | undefined = undefined;\n /** Reference values that were set during this unit of work, allocated on first m2o/poly change. */\n #referenceHistory: Record<string, any[]> | undefined = undefined;\n /** A bag to keep the flushed-to-database values, only for AsyncReactiveField reactivity. */\n flushedData: Record<any, any> | undefined;\n /** Packs the new/deleted `Operation`s + isTouched into one slot; see the accessors below. */\n #flags: number = 0;\n /** The `a#1`, `a#2` index if we're an em.create-d entity. We never unset this, to keep ids stable across flushes. */\n createId: string | undefined;\n /** The zero-based order this entity was registered with its EntityManager. */\n entityIndex: number = -1;\n\n /** Whether our entity is new or not. */\n get #new(): Operation | undefined {\n const value = this.#flags & 0b11;\n return value === 0 ? undefined : value;\n }\n\n set #new(op: Operation | undefined) {\n this.#flags = (this.#flags & ~0b11) | (op ?? 0);\n }\n\n /**\n * Whether our entity has been deleted or not.\n *\n * - `pending` means we've been marked for deletion via `em.delete` but not issued a `DELETE`\n * - `flushed` means we've flushed a `DELETE` but `em.flush` hasn't fully completed yet, likely due to AsyncReactiveField calcs\n * - `deleted` means we've been flushed and `em.flush` has completed\n */\n get #deleted(): Operation | undefined {\n const value = (this.#flags >> 2) & 0b11;\n return value === 0 ? undefined : value;\n }\n\n set #deleted(op: Operation | undefined) {\n this.#flags = (this.#flags & ~0b1100) | ((op ?? 0) << 2);\n }\n\n /** Whether our entity should flush regardless of any other changes. */\n get isTouched(): boolean {\n return (this.#flags & 0b10000) !== 0;\n }\n\n set isTouched(value: boolean) {\n this.#flags = value ? this.#flags | 0b10000 : this.#flags & ~0b10000;\n }\n\n /** Creates the `#orm` field. */\n constructor(em: EntityManager, entity: Entity, metadata: EntityMetadata, isNew: boolean) {\n this.entity = entity;\n this.em = em;\n this.metadata = metadata;\n if (isNew) {\n this.#new = Operation.Pending;\n this.data = {};\n this.flushedData = undefined;\n if (em) this.markMaybePending();\n } else {\n this.#new = undefined;\n this.data = {};\n this.flushedData = undefined;\n }\n }\n\n /**\n * Returns the as-loaded value of `columnName`, i.e. `getColumn(\"rank\")`.\n *\n * This saves callers from knowing that `rowData`/`rowIndex` are a pair, but note it is\n * a snapshot of the query that loaded us, and specifically:\n *\n * - The value is driver-level, i.e. numeric enum ids, untagged foreign keys, and temporals\n * as strings; use `getField` if you want the domain value, and\n * - The value is not updated by `em.flush`, so after a flush it is the pre-flush value, and\n * - New entities have no row, so every column is `undefined`.\n */\n getColumn(columnName: string): any {\n return this.rowData.get(this.rowIndex, columnName);\n }\n\n /** If `em.flush` has detected a dirty RQF, reset our internal dirty state, w/o reseting our external-dirty state. */\n resetForRqfLoop() {\n this.flushedData = {};\n if (this.#new === Operation.Pending) this.#new = Operation.Flushed;\n if (this.#deleted === Operation.Pending) this.#deleted = Operation.Flushed;\n }\n\n resetAfterFlushed() {\n this.#originalData = undefined;\n this.#referenceHistory = undefined;\n this.flushedData = undefined;\n this.isTouched = false;\n if (this.#new === Operation.Pending || this.#new === Operation.Flushed) {\n this.#new = Operation.Complete;\n }\n if (this.#deleted === Operation.Pending || this.#deleted === Operation.Flushed) {\n this.#deleted = Operation.Complete;\n }\n this.unmarkMaybePending();\n }\n\n /** Our public-facing `isNewEntity`. */\n get isNewEntity(): boolean {\n return this.#new !== undefined && this.#new !== Operation.Complete;\n }\n\n /** Our public-facing `isDeletedEntity`. */\n get isDeletedEntity(): boolean {\n return this.#deleted !== undefined;\n }\n\n /** The original values of mutated fields; a shared empty object until the entity is actually mutated. */\n get originalData(): Record<any, any> {\n return this.#originalData ?? emptyObject;\n }\n\n /** Our public-facing `isDirtyEntity`. */\n get isDirtyEntity(): boolean {\n return hasAnyKey(this.#originalData);\n }\n\n /** This is our internal \"is pending flush\", which is aware of RQF micro-flush loops. */\n get pendingOperation(): \"insert\" | \"update\" | \"delete\" | \"none\" | \"created-then-deleted\" {\n if (this.#deleted !== undefined) {\n // Mark entities that were created and them immediately `em.delete`-d; granted this is\n // probably rare, but we shouldn't run hooks or have the driver try and delete these.\n // Note that we return them, instead of skipping entirely, so that fixupCreatedThenDeleted\n // can later be called.\n return this.#deleted === Operation.Pending && this.#new === Operation.Pending\n ? \"created-then-deleted\"\n : this.#deleted === Operation.Pending\n ? \"delete\"\n : \"none\";\n } else if (this.#new === Operation.Pending) {\n // Per ^, if `#new === flushed`, we fall through to check if micro-flush UPDATEs are required\n return \"insert\";\n } else if (this.flushedData) {\n return hasAnyKey(this.flushedData) ? \"update\" : \"none\";\n } else {\n return this.isTouched || hasAnyKey(this.#originalData) ? \"update\" : \"none\";\n }\n }\n\n get changedFields(): string[] {\n return Object.keys(this.changedData);\n }\n\n /** The changed-fields bag (flushedData during RQF loops, else originalData) without allocating a keys array. */\n get changedData(): Record<any, any> {\n return this.flushedData ?? this.#originalData ?? emptyObject;\n }\n\n /** Called when an `em.load` tries to find the entity and it's just gone from the db. */\n markDeletedBecauseNotFound(): void {\n this.#deleted = Operation.Complete;\n }\n\n /** Called by `em.delete`, returns true if this is new information. */\n markDeleted(): boolean {\n if (this.#deleted === undefined) {\n // Let any OneToManyCollection/ReactiveField/ReactiveReference.get caches know that they should recalc\n // (i.e. their filterDeleted logic) by asserting the `deleteBook.author` field is changing.\n const api = getEmInternalApi(this.em);\n for (const field of Object.values(this.metadata.allFields)) {\n // We only do reference/collection fields and skip the primitives, b/c we assume something like\n // `{ books: \"title\" }` doesn't need `resetIsLoaded(..., \"title\")` b/c the same hint will also\n // be watching \"did books change\", and so get reset that way.\n if (field.kind === \"m2o\" || field.kind === \"poly\" || field.kind === \"m2m\" || field.kind === \"m2mEnum\") {\n api.isLoadedCache.resetIsLoaded(this.entity, field.fieldName);\n } else if (field.kind === \"primitive\" || field.kind === \"enum\" || field.kind === \"primaryKey\") {\n // Any reactable watching these fields will also be watching reference/collection\n } else if (field.kind === \"o2m\" || field.kind === \"o2o\") {\n // Any reactable watching these actually gets triggered by the primary m2o/poly side changing\n } else if (field.kind === \"lo2m\") {\n // Doesn't support reactivity\n } else {\n throw new Error(`Unhandled field kind ${field}`);\n }\n }\n this.#deleted = Operation.Pending;\n this.markMaybePending();\n return true;\n }\n return false;\n }\n\n fixupCreatedThenDeleted(): void {\n // Ideally we could do this via `resetAfterFlushed`?\n this.#deleted = Operation.Complete;\n this.unmarkMaybePending();\n }\n\n /** Marks this entity as needing a flush even if no fields changed. */\n markTouched(): void {\n this.isTouched = true;\n this.markMaybePending();\n }\n\n /** Marks a field as dirty with its pre-mutation value. */\n markFieldDirty(fieldName: string, value: any): void {\n (this.#originalData ??= {})[fieldName] = value;\n this.markMaybePending();\n }\n\n /** Marks a reverted field as clean again. */\n markFieldClean(fieldName: string): void {\n if (this.#originalData) delete this.#originalData[fieldName];\n this.markMaybePending();\n }\n\n /** Marks this entity as a possible flush candidate. */\n markMaybePending(): void {\n getEmInternalApi(this.em).markMaybePending(this.entity);\n }\n\n /** Removes this entity from the possible flush candidate set. */\n private unmarkMaybePending(): void {\n getEmInternalApi(this.em).unmarkMaybePending(this.entity);\n }\n\n /** Remembers a reference value that may need to be reverse-walked later. */\n rememberReferenceValue(fieldName: string, value: any): void {\n if (value === undefined) return;\n const values = ((this.#referenceHistory ??= {})[fieldName] ??= []);\n if (!values.includes(value)) values.push(value);\n }\n\n /** Returns reference values that may need to be reverse-walked later. */\n getReferenceHistory(fieldName: string): readonly any[] {\n return this.#referenceHistory?.[fieldName] ?? emptyArray;\n }\n\n get isDeletedAndFlushed(): boolean {\n return this.#deleted === Operation.Complete;\n }\n\n /**\n * Returns true if the entity is new or was new in this EM.\n *\n * This is primarily used for lazy-initializing relations, i.e. if:\n *\n * - A new `Author` is created\n * - We `em.flush` the author to the database\n * - Then `a1.books` is accessed for the first time\n *\n * We can have a high-confidence that `a1` has no books, because we just\n * created it, so we can set the OneToManyCollection to loaded.\n */\n get isOrWasNew(): boolean {\n // #new will be left as `complete`\n return this.#new !== undefined;\n }\n}\n\n/** An enum to track our insert/delete state progression. */\nenum Operation {\n Pending = 1,\n Flushed = 2,\n Complete = 3,\n}\n\n/** A shared frozen bag for un-mutated entities; strict mode makes accidental writes throw. */\nconst emptyObject: Record<any, any> = Object.freeze({});\n\n/** A shared frozen array for fields with no remembered reference values. */\nconst emptyArray: readonly any[] = Object.freeze([]);\n"],"mappings":";;;;;;;;AAOA,IAAa,eAAb,MAA0B;;CAExB;;CAEA;;CAEA;;CAEA,YAA0C,KAAA;;CAE1C,UAAmBA,gBAAAA;;CAEnB,WAAmB;;CAEnB;;CAEA,oBAA0C,KAAA;;CAE1C,mBAA4C,KAAA;;CAE5C,UAAuC,KAAA;;CAEvC,gBAA8C,KAAA;;CAE9C,oBAAuD,KAAA;;CAEvD;;CAEA,SAAiB;;CAEjB;;CAEA,cAAsB;;CAGtB,IAAI,OAA8B;EAChC,MAAM,QAAQ,KAAK,SAAS;EAC5B,OAAO,UAAU,IAAI,KAAA,IAAY;CACnC;CAEA,IAAI,KAAK,IAA2B;EAClC,KAAK,SAAU,KAAK,SAAS,MAAU,MAAM;CAC/C;;;;;;;;CASA,IAAI,WAAkC;EACpC,MAAM,QAAS,KAAK,UAAU,IAAK;EACnC,OAAO,UAAU,IAAI,KAAA,IAAY;CACnC;CAEA,IAAI,SAAS,IAA2B;EACtC,KAAK,SAAU,KAAK,SAAS,OAAa,MAAM,MAAM;CACxD;;CAGA,IAAI,YAAqB;EACvB,QAAQ,KAAK,SAAS,QAAa;CACrC;CAEA,IAAI,UAAU,OAAgB;EAC5B,KAAK,SAAS,QAAQ,KAAK,SAAS,KAAU,KAAK,SAAS;CAC9D;;CAGA,YAAY,IAAmB,QAAgB,UAA0B,OAAgB;EACvF,KAAK,SAAS;EACd,KAAK,KAAK;EACV,KAAK,WAAW;EAChB,IAAI,OAAO;GACT,KAAK,OAAA;GACL,KAAK,OAAO,CAAC;GACb,KAAK,cAAc,KAAA;GACnB,IAAI,IAAI,KAAK,iBAAiB;EAChC,OAAO;GACL,KAAK,OAAO,KAAA;GACZ,KAAK,OAAO,CAAC;GACb,KAAK,cAAc,KAAA;EACrB;CACF;;;;;;;;;;;;CAaA,UAAU,YAAyB;EACjC,OAAO,KAAK,QAAQ,IAAI,KAAK,UAAU,UAAU;CACnD;;CAGA,kBAAkB;EAChB,KAAK,cAAc,CAAC;EACpB,IAAI,KAAK,SAAA,GAA4B,KAAK,OAAA;EAC1C,IAAI,KAAK,aAAA,GAAgC,KAAK,WAAA;CAChD;CAEA,oBAAoB;EAClB,KAAK,gBAAgB,KAAA;EACrB,KAAK,oBAAoB,KAAA;EACzB,KAAK,cAAc,KAAA;EACnB,KAAK,YAAY;EACjB,IAAI,KAAK,SAAA,KAA8B,KAAK,SAAA,GAC1C,KAAK,OAAA;EAEP,IAAI,KAAK,aAAA,KAAkC,KAAK,aAAA,GAC9C,KAAK,WAAA;EAEP,KAAK,mBAAmB;CAC1B;;CAGA,IAAI,cAAuB;EACzB,OAAO,KAAK,SAAS,KAAA,KAAa,KAAK,SAAA;CACzC;;CAGA,IAAI,kBAA2B;EAC7B,OAAO,KAAK,aAAa,KAAA;CAC3B;;CAGA,IAAI,eAAiC;EACnC,OAAO,KAAK,iBAAiB;CAC/B;;CAGA,IAAI,gBAAyB;EAC3B,OAAOC,cAAAA,UAAU,KAAK,aAAa;CACrC;;CAGA,IAAI,mBAAqF;EACvF,IAAI,KAAK,aAAa,KAAA,GAKpB,OAAO,KAAK,aAAA,KAAkC,KAAK,SAAA,IAC/C,yBACA,KAAK,aAAA,IACH,WACA;OACD,IAAI,KAAK,SAAA,GAEd,OAAO;OACF,IAAI,KAAK,aACd,OAAOA,cAAAA,UAAU,KAAK,WAAW,IAAI,WAAW;OAEhD,OAAO,KAAK,aAAaA,cAAAA,UAAU,KAAK,aAAa,IAAI,WAAW;CAExE;CAEA,IAAI,gBAA0B;EAC5B,OAAO,OAAO,KAAK,KAAK,WAAW;CACrC;;CAGA,IAAI,cAAgC;EAClC,OAAO,KAAK,eAAe,KAAK,iBAAiB;CACnD;;CAGA,6BAAmC;EACjC,KAAK,WAAA;CACP;;CAGA,cAAuB;EACrB,IAAI,KAAK,aAAa,KAAA,GAAW;GAG/B,MAAM,MAAMC,sBAAAA,iBAAiB,KAAK,EAAE;GACpC,KAAK,MAAM,SAAS,OAAO,OAAO,KAAK,SAAS,SAAS,GAIvD,IAAI,MAAM,SAAS,SAAS,MAAM,SAAS,UAAU,MAAM,SAAS,SAAS,MAAM,SAAS,WAC1F,IAAI,cAAc,cAAc,KAAK,QAAQ,MAAM,SAAS;QACvD,IAAI,MAAM,SAAS,eAAe,MAAM,SAAS,UAAU,MAAM,SAAS,cAAc,CAE/F,OAAO,IAAI,MAAM,SAAS,SAAS,MAAM,SAAS,OAAO,CAEzD,OAAO,IAAI,MAAM,SAAS,QAAQ,CAElC,OACE,MAAM,IAAI,MAAM,wBAAwB,OAAO;GAGnD,KAAK,WAAA;GACL,KAAK,iBAAiB;GACtB,OAAO;EACT;EACA,OAAO;CACT;CAEA,0BAAgC;EAE9B,KAAK,WAAA;EACL,KAAK,mBAAmB;CAC1B;;CAGA,cAAoB;EAClB,KAAK,YAAY;EACjB,KAAK,iBAAiB;CACxB;;CAGA,eAAe,WAAmB,OAAkB;EAClD,CAAC,KAAK,kBAAkB,CAAC,EAAA,CAAG,aAAa;EACzC,KAAK,iBAAiB;CACxB;;CAGA,eAAe,WAAyB;EACtC,IAAI,KAAK,eAAe,OAAO,KAAK,cAAc;EAClD,KAAK,iBAAiB;CACxB;;CAGA,mBAAyB;EACvB,sBAAA,iBAAiB,KAAK,EAAE,CAAC,CAAC,iBAAiB,KAAK,MAAM;CACxD;;CAGA,qBAAmC;EACjC,sBAAA,iBAAiB,KAAK,EAAE,CAAC,CAAC,mBAAmB,KAAK,MAAM;CAC1D;;CAGA,uBAAuB,WAAmB,OAAkB;EAC1D,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAU,CAAC,KAAK,sBAAsB,CAAC,EAAA,CAAG,eAAe,CAAC;EAChE,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO,KAAK,KAAK;CAChD;;CAGA,oBAAoB,WAAmC;EACrD,OAAO,KAAK,oBAAoB,cAAc;CAChD;CAEA,IAAI,sBAA+B;EACjC,OAAO,KAAK,aAAA;CACd;;;;;;;;;;;;;CAcA,IAAI,aAAsB;EAExB,OAAO,KAAK,SAAS,KAAA;CACvB;AACF;;AAUA,MAAM,cAAgC,OAAO,OAAO,CAAC,CAAC;;AAGtD,MAAM,aAA6B,OAAO,OAAO,CAAC,CAAC"}
|
package/build/InstanceData.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RowData } from "./RowData.cjs";
|
|
2
|
-
import { EntityMetadata } from "./EntityMetadata.cjs";
|
|
3
|
-
import { EntityManager } from "./EntityManager.cjs";
|
|
4
1
|
import { Entity } from "./Entity.cjs";
|
|
5
|
-
|
|
2
|
+
import { EntityManager } from "./EntityManager.cjs";
|
|
3
|
+
import { EntityMetadata } from "./EntityMetadata.cjs";
|
|
4
|
+
import { RowData } from "./RowData.cjs";
|
|
6
5
|
/** The `#orm` metadata field we track on each instance. */
|
|
7
6
|
export declare class InstanceData {
|
|
8
7
|
#private;
|
|
@@ -20,6 +19,12 @@ export declare class InstanceData {
|
|
|
20
19
|
rowIndex: number;
|
|
21
20
|
/** The domain-value of fields, lazily converted (if needed) on read from the database columns. */
|
|
22
21
|
data: Record<string, any>;
|
|
22
|
+
/** Present only on visibility-aware entities; untrusted reads never reuse these approvals. */
|
|
23
|
+
trustedReadFields: number[] | undefined;
|
|
24
|
+
/** Reentrancy is transient, independent of whether a read may be cached. */
|
|
25
|
+
activeReadFields: Set<string> | undefined;
|
|
26
|
+
/** Number/untagged ID conversions are cached once; assigned entity IDs never change. */
|
|
27
|
+
idCache: string | number | undefined;
|
|
23
28
|
/** A bag to keep the flushed-to-database values, only for AsyncReactiveField reactivity. */
|
|
24
29
|
flushedData: Record<any, any> | undefined;
|
|
25
30
|
/** The `a#1`, `a#2` index if we're an em.create-d entity. We never unset this, to keep ids stable across flushes. */
|
|
@@ -93,5 +98,4 @@ export declare class InstanceData {
|
|
|
93
98
|
*/
|
|
94
99
|
get isOrWasNew(): boolean;
|
|
95
100
|
}
|
|
96
|
-
//#endregion
|
|
97
101
|
//# sourceMappingURL=InstanceData.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstanceData.d.cts","names":[],"sources":["../src/InstanceData.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"InstanceData.d.cts","names":[],"sources":["../src/InstanceData.ts"],"mappings":";;;;;qBAOa;;;WAEF,QAAQ;;WAER,IAAI;;WAEJ,UAAU;;EAEnB,WAAW;;EAEX,SAAS;;EAET;;EAEA,MAAM;;EAEN;;EAEA,kBAAkB;;EAElB;;EAMA,aAAa;;EAIb;;EAEA;;MA6BI;MAIA,UAAU;;EAKd,YAAY,IAAI,eAAe,QAAQ,QAAQ,UAAU,gBAAgB;;;;;;;;;;;;EA2BzE,UAAU;;EAKV;EAMA;;MAeI;;MAKA;;MAKA,gBAAgB;;MAKhB;;MAKA;MAqBA;;MAKA,eAAe;;EAKnB;;EAKA;EA4BA;;EAOA;;EAMA,eAAe,mBAAmB;;EAMlC,eAAe;;EAMf;;UAKQ;;EAKR,uBAAuB,mBAAmB;;EAO1C,oBAAoB;MAIhB;;;;;;;;;;;;;MAgBA"}
|