joist-core 2.4.0 → 2.5.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/BaseEntity.cjs +9 -3
- package/build/BaseEntity.cjs.map +1 -1
- package/build/BaseEntity.d.cts +7 -8
- package/build/BaseEntity.d.cts.map +1 -1
- package/build/BaseEntity.d.mts +7 -8
- package/build/BaseEntity.d.mts.map +1 -1
- package/build/BaseEntity.js +9 -3
- package/build/BaseEntity.js.map +1 -1
- package/build/Entity.cjs +2 -3
- package/build/Entity.d.cts +3 -6
- package/build/Entity.d.cts.map +1 -1
- package/build/Entity.d.mts +3 -6
- package/build/Entity.d.mts.map +1 -1
- package/build/Entity.js +2 -3
- package/build/EntityFields.d.cts +3 -6
- package/build/EntityFields.d.cts.map +1 -1
- package/build/EntityFields.d.mts +3 -6
- package/build/EntityFields.d.mts.map +1 -1
- package/build/EntityManager.cjs +150 -68
- package/build/EntityManager.cjs.map +1 -1
- package/build/EntityManager.d.cts +126 -83
- package/build/EntityManager.d.cts.map +1 -1
- package/build/EntityManager.d.mts +126 -83
- package/build/EntityManager.d.mts.map +1 -1
- package/build/EntityManager.js +149 -69
- package/build/EntityManager.js.map +1 -1
- package/build/EntityMetadata.cjs +3 -5
- package/build/EntityMetadata.cjs.map +1 -1
- package/build/EntityMetadata.d.cts +54 -41
- package/build/EntityMetadata.d.cts.map +1 -1
- package/build/EntityMetadata.d.mts +54 -41
- package/build/EntityMetadata.d.mts.map +1 -1
- package/build/EntityMetadata.js +3 -5
- package/build/EntityMetadata.js.map +1 -1
- package/build/EnumMetadata.d.cts +1 -4
- package/build/EnumMetadata.d.cts.map +1 -1
- package/build/EnumMetadata.d.mts +1 -4
- package/build/EnumMetadata.d.mts.map +1 -1
- package/build/IndexManager.cjs +28 -9
- package/build/IndexManager.cjs.map +1 -1
- package/build/IndexManager.d.cts +3 -6
- package/build/IndexManager.d.cts.map +1 -1
- package/build/IndexManager.d.mts +3 -6
- package/build/IndexManager.d.mts.map +1 -1
- package/build/IndexManager.js +28 -9
- package/build/IndexManager.js.map +1 -1
- package/build/InstanceData.cjs +9 -5
- package/build/InstanceData.cjs.map +1 -1
- package/build/InstanceData.d.cts +9 -7
- package/build/InstanceData.d.cts.map +1 -1
- package/build/InstanceData.d.mts +9 -7
- package/build/InstanceData.d.mts.map +1 -1
- package/build/InstanceData.js +9 -5
- package/build/InstanceData.js.map +1 -1
- package/build/PluginManager.cjs +3 -4
- package/build/PluginManager.cjs.map +1 -1
- package/build/PluginManager.d.cts +11 -10
- package/build/PluginManager.d.cts.map +1 -1
- package/build/PluginManager.d.mts +11 -10
- package/build/PluginManager.d.mts.map +1 -1
- package/build/PluginManager.js +3 -4
- package/build/PluginManager.js.map +1 -1
- package/build/RowData.cjs +1 -2
- package/build/RowData.d.cts +3 -6
- package/build/RowData.d.cts.map +1 -1
- package/build/RowData.d.mts +3 -6
- 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.cjs.map +1 -1
- package/build/batchloaders/BatchLoader.d.cts +1 -4
- package/build/batchloaders/BatchLoader.d.cts.map +1 -1
- package/build/batchloaders/BatchLoader.d.mts +1 -4
- package/build/batchloaders/BatchLoader.d.mts.map +1 -1
- package/build/batchloaders/BatchLoader.js +1 -2
- package/build/batchloaders/BatchLoader.js.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.cjs +3 -4
- package/build/batchloaders/enumCollectionBatchLoader.d.cts +3 -6
- package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.mts +3 -6
- package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/enumCollectionBatchLoader.js +3 -4
- package/build/batchloaders/loadBatchLoader.cjs +5 -6
- package/build/batchloaders/loadBatchLoader.d.cts +4 -7
- package/build/batchloaders/loadBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/loadBatchLoader.d.mts +4 -7
- package/build/batchloaders/loadBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/loadBatchLoader.js +5 -6
- package/build/batchloaders/manyToManyBatchLoader.cjs +4 -5
- package/build/batchloaders/manyToManyBatchLoader.d.cts +3 -6
- package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.d.mts +3 -6
- package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.js +4 -5
- package/build/batchloaders/oneToManyBatchLoader.cjs +5 -6
- package/build/batchloaders/oneToManyBatchLoader.d.cts +4 -7
- package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.d.mts +4 -7
- package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToManyBatchLoader.js +5 -6
- package/build/batchloaders/oneToOneBatchLoader.cjs +6 -7
- package/build/batchloaders/oneToOneBatchLoader.d.cts +4 -7
- package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.d.mts +4 -7
- package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/oneToOneBatchLoader.js +6 -7
- package/build/batchloaders/populateBatchLoader.cjs +11 -12
- package/build/batchloaders/populateBatchLoader.d.cts +4 -7
- package/build/batchloaders/populateBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/populateBatchLoader.d.mts +4 -7
- package/build/batchloaders/populateBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/populateBatchLoader.js +11 -12
- package/build/batchloaders/recursiveChildrenBatchLoader.cjs +7 -8
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +4 -7
- package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +4 -7
- package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.js +7 -8
- package/build/batchloaders/recursiveM2mBatchLoader.cjs +5 -6
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts +4 -7
- package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts +4 -7
- package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.js +5 -6
- package/build/batchloaders/recursiveParentsBatchLoader.cjs +7 -8
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts +4 -7
- package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts +4 -7
- package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.js +7 -8
- package/build/changes.cjs +8 -9
- package/build/changes.cjs.map +1 -1
- package/build/changes.d.cts +12 -15
- package/build/changes.d.cts.map +1 -1
- package/build/changes.d.mts +12 -15
- package/build/changes.d.mts.map +1 -1
- package/build/changes.js +8 -9
- package/build/changes.js.map +1 -1
- package/build/config.cjs +171 -33
- package/build/config.cjs.map +1 -1
- package/build/config.d.cts +115 -25
- package/build/config.d.cts.map +1 -1
- package/build/config.d.mts +115 -25
- package/build/config.d.mts.map +1 -1
- package/build/config.js +171 -33
- package/build/config.js.map +1 -1
- package/build/configure.cjs +40 -11
- package/build/configure.cjs.map +1 -1
- package/build/configure.d.cts +11 -14
- package/build/configure.d.cts.map +1 -1
- package/build/configure.d.mts +11 -14
- package/build/configure.d.mts.map +1 -1
- package/build/configure.js +40 -11
- package/build/configure.js.map +1 -1
- 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 +1 -4
- package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.d.mts +1 -4
- 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 +4 -7
- package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findByUniqueDataLoader.d.mts +4 -7
- 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 +7 -10
- package/build/dataloaders/findCountDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findCountDataLoader.d.mts +7 -10
- 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 +16 -19
- package/build/dataloaders/findDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findDataLoader.d.mts +16 -19
- 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 +4 -7
- package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findIdsDataLoader.d.mts +4 -7
- package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findIdsDataLoader.js +6 -7
- package/build/dataloaders/findOrCreateDataLoader.cjs +12 -9
- package/build/dataloaders/findOrCreateDataLoader.cjs.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.d.cts +5 -7
- package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.d.mts +5 -7
- package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.js +12 -9
- package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.cjs +16 -19
- package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.d.cts +4 -7
- package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.d.mts +4 -7
- package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.js +16 -19
- package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
- package/build/dataloaders/lensDataLoader.cjs +5 -6
- package/build/dataloaders/lensDataLoader.d.cts +3 -6
- package/build/dataloaders/lensDataLoader.d.cts.map +1 -1
- package/build/dataloaders/lensDataLoader.d.mts +3 -6
- 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 +4 -7
- package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.mts +4 -7
- package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
- package/build/dataloaders/manyToManyFindDataLoader.js +1 -2
- package/build/dataloaders/oneToManyFindDataLoader.cjs +1 -2
- package/build/dataloaders/oneToManyFindDataLoader.d.cts +4 -7
- package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.mts +4 -7
- package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
- package/build/dataloaders/oneToManyFindDataLoader.js +1 -2
- package/build/defaults.cjs +7 -8
- package/build/defaults.cjs.map +1 -1
- package/build/defaults.d.cts +9 -11
- package/build/defaults.d.cts.map +1 -1
- package/build/defaults.d.mts +9 -11
- package/build/defaults.d.mts.map +1 -1
- package/build/defaults.js +7 -8
- package/build/defaults.js.map +1 -1
- package/build/drivers/Driver.cjs +1 -1
- package/build/drivers/Driver.d.cts +4 -7
- package/build/drivers/Driver.d.cts.map +1 -1
- package/build/drivers/Driver.d.mts +4 -7
- package/build/drivers/Driver.d.mts.map +1 -1
- package/build/drivers/Driver.js +1 -1
- package/build/drivers/EntityWriter.cjs +8 -8
- package/build/drivers/EntityWriter.cjs.map +1 -1
- package/build/drivers/EntityWriter.d.cts +20 -10
- package/build/drivers/EntityWriter.d.cts.map +1 -1
- package/build/drivers/EntityWriter.d.mts +20 -10
- package/build/drivers/EntityWriter.d.mts.map +1 -1
- package/build/drivers/EntityWriter.js +8 -8
- package/build/drivers/EntityWriter.js.map +1 -1
- package/build/drivers/IdAssigner.cjs +7 -4
- package/build/drivers/IdAssigner.cjs.map +1 -1
- package/build/drivers/IdAssigner.d.cts +6 -7
- package/build/drivers/IdAssigner.d.cts.map +1 -1
- package/build/drivers/IdAssigner.d.mts +6 -7
- 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 +4 -7
- package/build/drivers/driverApi.d.cts.map +1 -1
- package/build/drivers/driverApi.d.mts +4 -7
- 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 +81 -23
- package/build/fields.cjs.map +1 -1
- package/build/fields.d.cts +12 -13
- package/build/fields.d.cts.map +1 -1
- package/build/fields.d.mts +12 -13
- package/build/fields.d.mts.map +1 -1
- package/build/fields.js +81 -23
- 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 +1 -4
- package/build/flush/FlushLock.d.cts.map +1 -1
- package/build/flush/FlushLock.d.mts +1 -4
- package/build/flush/FlushLock.d.mts.map +1 -1
- package/build/flush/FlushLock.js +1 -2
- package/build/flush/FlushLock.js.map +1 -1
- package/build/flush/JoinRows.cjs +3 -4
- package/build/flush/JoinRows.cjs.map +1 -1
- package/build/flush/JoinRows.d.cts +7 -10
- package/build/flush/JoinRows.d.cts.map +1 -1
- package/build/flush/JoinRows.d.mts +7 -10
- package/build/flush/JoinRows.d.mts.map +1 -1
- package/build/flush/JoinRows.js +3 -4
- package/build/flush/JoinRows.js.map +1 -1
- package/build/flush/PendingChanges.d.cts +5 -8
- package/build/flush/PendingChanges.d.cts.map +1 -1
- package/build/flush/PendingChanges.d.mts +5 -8
- package/build/flush/PendingChanges.d.mts.map +1 -1
- package/build/flush/ReadDrift.cjs +89 -0
- package/build/flush/ReadDrift.cjs.map +1 -0
- package/build/flush/ReadDrift.d.cts +23 -0
- package/build/flush/ReadDrift.d.cts.map +1 -0
- package/build/flush/ReadDrift.d.mts +23 -0
- package/build/flush/ReadDrift.d.mts.map +1 -0
- package/build/flush/ReadDrift.js +86 -0
- package/build/flush/ReadDrift.js.map +1 -0
- package/build/flush/Todo.cjs +3 -4
- package/build/flush/Todo.d.cts +7 -10
- package/build/flush/Todo.d.cts.map +1 -1
- package/build/flush/Todo.d.mts +7 -10
- package/build/flush/Todo.d.mts.map +1 -1
- package/build/flush/Todo.js +3 -4
- package/build/getProperties.cjs +4 -5
- package/build/getProperties.d.cts +3 -6
- package/build/getProperties.d.cts.map +1 -1
- package/build/getProperties.d.mts +3 -6
- package/build/getProperties.d.mts.map +1 -1
- package/build/getProperties.js +4 -5
- package/build/index.cjs +71 -57
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +68 -66
- package/build/index.d.cts.map +1 -1
- package/build/index.d.mts +68 -66
- package/build/index.d.mts.map +1 -1
- package/build/index.js +66 -58
- package/build/index.js.map +1 -1
- package/build/json.cjs +8 -9
- package/build/json.d.cts +13 -15
- package/build/json.d.cts.map +1 -1
- package/build/json.d.mts +13 -15
- package/build/json.d.mts.map +1 -1
- package/build/json.js +8 -9
- package/build/k.cjs +1 -2
- package/build/k.js +1 -2
- package/build/keys.cjs +5 -6
- package/build/keys.d.cts +30 -32
- package/build/keys.d.cts.map +1 -1
- package/build/keys.d.mts +30 -32
- 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 +5 -8
- package/build/loading/HintTree.d.cts.map +1 -1
- package/build/loading/HintTree.d.mts +5 -8
- package/build/loading/HintTree.d.mts.map +1 -1
- package/build/loading/HintTree.js +1 -2
- package/build/loading/IsLoadedCache.cjs +3 -4
- package/build/loading/IsLoadedCache.cjs.map +1 -1
- package/build/loading/IsLoadedCache.d.cts +3 -6
- package/build/loading/IsLoadedCache.d.cts.map +1 -1
- package/build/loading/IsLoadedCache.d.mts +3 -6
- package/build/loading/IsLoadedCache.d.mts.map +1 -1
- package/build/loading/IsLoadedCache.js +3 -4
- package/build/loading/IsLoadedCache.js.map +1 -1
- package/build/loading/loadHints.cjs +1 -2
- package/build/loading/loadHints.d.cts +21 -23
- package/build/loading/loadHints.d.cts.map +1 -1
- package/build/loading/loadHints.d.mts +21 -23
- package/build/loading/loadHints.d.mts.map +1 -1
- package/build/loading/loadHints.js +1 -2
- package/build/loading/loadLens.cjs +6 -7
- package/build/loading/loadLens.d.cts +15 -17
- package/build/loading/loadLens.d.cts.map +1 -1
- package/build/loading/loadLens.d.mts +15 -17
- package/build/loading/loadLens.d.mts.map +1 -1
- package/build/loading/loadLens.js +6 -7
- package/build/loading/withLoaded.cjs +1 -2
- package/build/loading/withLoaded.d.cts +7 -10
- package/build/loading/withLoaded.d.cts.map +1 -1
- package/build/loading/withLoaded.d.mts +7 -10
- package/build/loading/withLoaded.d.mts.map +1 -1
- package/build/loading/withLoaded.js +1 -2
- package/build/logging/FactoryLogger.cjs +3 -4
- package/build/logging/FactoryLogger.cjs.map +1 -1
- package/build/logging/FactoryLogger.d.cts +4 -7
- package/build/logging/FactoryLogger.d.cts.map +1 -1
- package/build/logging/FactoryLogger.d.mts +4 -7
- package/build/logging/FactoryLogger.d.mts.map +1 -1
- package/build/logging/FactoryLogger.js +4 -5
- package/build/logging/FactoryLogger.js.map +1 -1
- package/build/logging/FieldLogger.cjs +1 -2
- package/build/logging/FieldLogger.cjs.map +1 -1
- package/build/logging/FieldLogger.d.cts +4 -7
- package/build/logging/FieldLogger.d.cts.map +1 -1
- package/build/logging/FieldLogger.d.mts +4 -7
- package/build/logging/FieldLogger.d.mts.map +1 -1
- package/build/logging/FieldLogger.js +1 -2
- package/build/logging/FieldLogger.js.map +1 -1
- package/build/logging/ReactionLogger.cjs +3 -4
- package/build/logging/ReactionLogger.d.cts +10 -12
- package/build/logging/ReactionLogger.d.cts.map +1 -1
- package/build/logging/ReactionLogger.d.mts +10 -12
- package/build/logging/ReactionLogger.d.mts.map +1 -1
- package/build/logging/ReactionLogger.js +3 -4
- package/build/metrics/EntityMetrics.cjs +80 -0
- package/build/metrics/EntityMetrics.cjs.map +1 -0
- package/build/metrics/EntityMetrics.d.cts +53 -0
- package/build/metrics/EntityMetrics.d.cts.map +1 -0
- package/build/metrics/EntityMetrics.d.mts +53 -0
- package/build/metrics/EntityMetrics.d.mts.map +1 -0
- package/build/metrics/EntityMetrics.js +78 -0
- package/build/metrics/EntityMetrics.js.map +1 -0
- package/build/newEntity.cjs +6 -7
- package/build/newEntity.cjs.map +1 -1
- package/build/newEntity.d.cts +6 -9
- package/build/newEntity.d.cts.map +1 -1
- package/build/newEntity.d.mts +6 -9
- package/build/newEntity.d.mts.map +1 -1
- package/build/newEntity.js +6 -7
- package/build/newEntity.js.map +1 -1
- package/build/newTestInstance.cjs +10 -10
- package/build/newTestInstance.cjs.map +1 -1
- package/build/newTestInstance.d.cts +24 -26
- package/build/newTestInstance.d.cts.map +1 -1
- package/build/newTestInstance.d.mts +24 -26
- package/build/newTestInstance.d.mts.map +1 -1
- package/build/newTestInstance.js +10 -10
- package/build/newTestInstance.js.map +1 -1
- package/build/normalizeHints.cjs +1 -2
- package/build/normalizeHints.d.cts +8 -11
- package/build/normalizeHints.d.cts.map +1 -1
- package/build/normalizeHints.d.mts +8 -11
- 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 +4 -7
- package/build/nowUTC.d.cts.map +1 -1
- package/build/nowUTC.d.mts +4 -7
- 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 +2 -5
- package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.mts +2 -5
- 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 +7 -10
- package/build/plugins/PreloadPlugin.d.cts.map +1 -1
- package/build/plugins/PreloadPlugin.d.mts +7 -10
- package/build/plugins/PreloadPlugin.d.mts.map +1 -1
- package/build/plugins/PreloadPlugin.js +1 -1
- package/build/preloading/JsonAggregatePreloader.cjs +9 -10
- package/build/preloading/JsonAggregatePreloader.d.cts +4 -7
- package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -1
- package/build/preloading/JsonAggregatePreloader.d.mts +4 -7
- package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -1
- package/build/preloading/JsonAggregatePreloader.js +9 -10
- package/build/preloading/canPreload.cjs +1 -2
- package/build/preloading/canPreload.d.cts +1 -4
- package/build/preloading/canPreload.d.cts.map +1 -1
- package/build/preloading/canPreload.d.mts +1 -4
- package/build/preloading/canPreload.d.mts.map +1 -1
- package/build/preloading/canPreload.js +1 -2
- package/build/preloading/partitionHint.cjs +5 -6
- package/build/preloading/partitionHint.d.cts +2 -5
- package/build/preloading/partitionHint.d.cts.map +1 -1
- package/build/preloading/partitionHint.d.mts +2 -5
- package/build/preloading/partitionHint.d.mts.map +1 -1
- package/build/preloading/partitionHint.js +5 -6
- package/build/queries/ConditionBuilder.cjs +2 -3
- package/build/queries/ConditionBuilder.d.cts +3 -5
- package/build/queries/ConditionBuilder.d.cts.map +1 -1
- package/build/queries/ConditionBuilder.d.mts +3 -5
- 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 +11 -14
- package/build/queries/conditions.d.cts.map +1 -1
- package/build/queries/conditions.d.mts +11 -14
- 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 +5 -8
- package/build/queries/entityQueryUtils.d.cts.map +1 -1
- package/build/queries/entityQueryUtils.d.mts +5 -8
- 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 +21 -23
- package/build/queries/find/Aliases.d.cts.map +1 -1
- package/build/queries/find/Aliases.d.mts +21 -23
- 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 +7 -10
- package/build/queries/find/DeferredAlias.d.cts.map +1 -1
- package/build/queries/find/DeferredAlias.d.mts +7 -10
- 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 +15 -18
- package/build/queries/find/EntityFilter.d.cts.map +1 -1
- package/build/queries/find/EntityFilter.d.mts +15 -18
- 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 +10 -13
- package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -1
- package/build/queries/find/EntityGraphQLFilter.d.mts +10 -13
- package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -1
- package/build/queries/find/EntityGraphQLFilter.js +1 -2
- package/build/queries/find/QueryParser.cjs +27 -17
- package/build/queries/find/QueryParser.cjs.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.cjs +3 -3
- package/build/queries/find/QueryParser.collectionJoins.cjs.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.d.cts +1 -4
- package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.d.mts +1 -4
- package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -1
- package/build/queries/find/QueryParser.collectionJoins.js +3 -3
- package/build/queries/find/QueryParser.collectionJoins.js.map +1 -1
- package/build/queries/find/QueryParser.d.cts +43 -22
- package/build/queries/find/QueryParser.d.cts.map +1 -1
- package/build/queries/find/QueryParser.d.mts +43 -22
- package/build/queries/find/QueryParser.d.mts.map +1 -1
- package/build/queries/find/QueryParser.js +27 -17
- package/build/queries/find/QueryParser.js.map +1 -1
- package/build/queries/find/QueryParser.pruning.cjs +52 -4
- package/build/queries/find/QueryParser.pruning.cjs.map +1 -1
- package/build/queries/find/QueryParser.pruning.d.cts +15 -5
- package/build/queries/find/QueryParser.pruning.d.cts.map +1 -1
- package/build/queries/find/QueryParser.pruning.d.mts +15 -5
- package/build/queries/find/QueryParser.pruning.d.mts.map +1 -1
- package/build/queries/find/QueryParser.pruning.js +52 -4
- package/build/queries/find/QueryParser.pruning.js.map +1 -1
- package/build/queries/find/QueryVisitor.cjs +1 -2
- package/build/queries/find/QueryVisitor.d.cts +4 -6
- package/build/queries/find/QueryVisitor.d.cts.map +1 -1
- package/build/queries/find/QueryVisitor.d.mts +4 -6
- 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 +3 -5
- package/build/queries/find/buildFindQuery.d.cts.map +1 -1
- package/build/queries/find/buildFindQuery.d.mts +3 -5
- 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.cjs.map +1 -1
- package/build/queries/find/scopes.d.cts +17 -20
- package/build/queries/find/scopes.d.cts.map +1 -1
- package/build/queries/find/scopes.d.mts +17 -20
- package/build/queries/find/scopes.d.mts.map +1 -1
- package/build/queries/find/scopes.js +1 -2
- package/build/queries/find/scopes.js.map +1 -1
- package/build/queries/parsedConditions.cjs +1 -2
- package/build/queries/parsedConditions.d.cts +7 -10
- package/build/queries/parsedConditions.d.cts.map +1 -1
- package/build/queries/parsedConditions.d.mts +7 -10
- 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 +3 -6
- package/build/queries/renderConditions.d.cts.map +1 -1
- package/build/queries/renderConditions.d.mts +3 -6
- 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 +1 -4
- package/build/queries/skipCondition.d.cts.map +1 -1
- package/build/queries/skipCondition.d.mts +1 -4
- 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.cjs.map +1 -1
- package/build/queries/sql/AliasAssigner.d.cts +1 -4
- package/build/queries/sql/AliasAssigner.d.cts.map +1 -1
- package/build/queries/sql/AliasAssigner.d.mts +1 -4
- package/build/queries/sql/AliasAssigner.d.mts.map +1 -1
- package/build/queries/sql/AliasAssigner.js +1 -2
- package/build/queries/sql/AliasAssigner.js.map +1 -1
- package/build/queries/sql/Expr.cjs +41 -4
- package/build/queries/sql/Expr.cjs.map +1 -1
- package/build/queries/sql/Expr.d.cts +47 -31
- package/build/queries/sql/Expr.d.cts.map +1 -1
- package/build/queries/sql/Expr.d.mts +47 -31
- package/build/queries/sql/Expr.d.mts.map +1 -1
- package/build/queries/sql/Expr.js +41 -5
- package/build/queries/sql/Expr.js.map +1 -1
- package/build/queries/sql/JoinTree.cjs +3 -4
- package/build/queries/sql/JoinTree.d.cts +10 -12
- package/build/queries/sql/JoinTree.d.cts.map +1 -1
- package/build/queries/sql/JoinTree.d.mts +10 -12
- package/build/queries/sql/JoinTree.d.mts.map +1 -1
- package/build/queries/sql/JoinTree.js +3 -4
- package/build/queries/sql/Tables.cjs +17 -9
- package/build/queries/sql/Tables.cjs.map +1 -1
- package/build/queries/sql/Tables.d.cts +51 -46
- package/build/queries/sql/Tables.d.cts.map +1 -1
- package/build/queries/sql/Tables.d.mts +51 -46
- package/build/queries/sql/Tables.d.mts.map +1 -1
- package/build/queries/sql/Tables.js +17 -9
- package/build/queries/sql/Tables.js.map +1 -1
- package/build/queries/sql/custom.cjs +1 -2
- package/build/queries/sql/custom.d.cts +16 -18
- package/build/queries/sql/custom.d.cts.map +1 -1
- package/build/queries/sql/custom.d.mts +16 -18
- package/build/queries/sql/custom.d.mts.map +1 -1
- package/build/queries/sql/custom.js +1 -2
- package/build/queries/sql/execute.cjs +74 -96
- package/build/queries/sql/execute.cjs.map +1 -1
- package/build/queries/sql/execute.d.cts +54 -39
- package/build/queries/sql/execute.d.cts.map +1 -1
- package/build/queries/sql/execute.d.mts +54 -39
- package/build/queries/sql/execute.d.mts.map +1 -1
- package/build/queries/sql/execute.js +75 -97
- package/build/queries/sql/execute.js.map +1 -1
- package/build/queries/sql/expressions/arrayAgg.cjs +2 -3
- package/build/queries/sql/expressions/arrayAgg.d.cts +6 -9
- package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -1
- package/build/queries/sql/expressions/arrayAgg.d.mts +6 -9
- 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 +11 -13
- package/build/queries/sql/expressions/case.d.cts.map +1 -1
- package/build/queries/sql/expressions/case.d.mts +11 -13
- 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 +6 -9
- package/build/queries/sql/expressions/coalesce.d.cts.map +1 -1
- package/build/queries/sql/expressions/coalesce.d.mts +6 -9
- 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 +1 -4
- package/build/queries/sql/expressions/codecs.d.cts.map +1 -1
- package/build/queries/sql/expressions/codecs.d.mts +1 -4
- 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 +8 -10
- package/build/queries/sql/expressions/expression.d.cts.map +1 -1
- package/build/queries/sql/expressions/expression.d.mts +8 -10
- 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 +6 -9
- package/build/queries/sql/expressions/greatest.d.cts.map +1 -1
- package/build/queries/sql/expressions/greatest.d.mts +6 -9
- 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 +6 -9
- package/build/queries/sql/expressions/least.d.cts.map +1 -1
- package/build/queries/sql/expressions/least.d.mts +6 -9
- 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 +6 -9
- package/build/queries/sql/expressions/nullIf.d.cts.map +1 -1
- package/build/queries/sql/expressions/nullIf.d.mts +6 -9
- 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 +5 -8
- package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -1
- package/build/queries/sql/expressions/parseExpression.d.mts +5 -8
- 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 +12 -14
- package/build/queries/sql/expressions/types.d.cts.map +1 -1
- package/build/queries/sql/expressions/types.d.mts +12 -14
- 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 +4 -7
- package/build/queries/sql/keywords.d.cts.map +1 -1
- package/build/queries/sql/keywords.d.mts +4 -7
- package/build/queries/sql/keywords.d.mts.map +1 -1
- package/build/queries/sql/keywords.js +1 -2
- package/build/queries/sql/query.cjs +86 -40
- package/build/queries/sql/query.cjs.map +1 -1
- package/build/queries/sql/query.d.cts +125 -84
- package/build/queries/sql/query.d.cts.map +1 -1
- package/build/queries/sql/query.d.mts +125 -84
- package/build/queries/sql/query.d.mts.map +1 -1
- package/build/queries/sql/query.js +84 -40
- package/build/queries/sql/query.js.map +1 -1
- package/build/queries/unnest.cjs +5 -7
- package/build/queries/unnest.cjs.map +1 -1
- package/build/queries/unnest.d.cts +3 -6
- package/build/queries/unnest.d.cts.map +1 -1
- package/build/queries/unnest.d.mts +3 -6
- package/build/queries/unnest.d.mts.map +1 -1
- package/build/queries/unnest.js +5 -7
- package/build/queries/unnest.js.map +1 -1
- package/build/queries/valueFilters.cjs +3 -4
- package/build/queries/valueFilters.d.cts +7 -10
- package/build/queries/valueFilters.d.cts.map +1 -1
- package/build/queries/valueFilters.d.mts +7 -10
- package/build/queries/valueFilters.d.mts.map +1 -1
- package/build/queries/valueFilters.js +3 -4
- package/build/reactivity/ReactionsManager.cjs +176 -8
- package/build/reactivity/ReactionsManager.cjs.map +1 -1
- package/build/reactivity/ReactionsManager.d.cts +58 -8
- package/build/reactivity/ReactionsManager.d.cts.map +1 -1
- package/build/reactivity/ReactionsManager.d.mts +58 -8
- package/build/reactivity/ReactionsManager.d.mts.map +1 -1
- package/build/reactivity/ReactionsManager.js +176 -8
- package/build/reactivity/ReactionsManager.js.map +1 -1
- package/build/reactivity/reactiveHints.cjs +16 -11
- package/build/reactivity/reactiveHints.cjs.map +1 -1
- package/build/reactivity/reactiveHints.d.cts +26 -27
- package/build/reactivity/reactiveHints.d.cts.map +1 -1
- package/build/reactivity/reactiveHints.d.mts +26 -27
- package/build/reactivity/reactiveHints.d.mts.map +1 -1
- package/build/reactivity/reactiveHints.js +16 -11
- package/build/reactivity/reactiveHints.js.map +1 -1
- package/build/relations/AbstractPropertyImpl.cjs +1 -2
- package/build/relations/AbstractPropertyImpl.cjs.map +1 -1
- package/build/relations/AbstractPropertyImpl.d.cts +1 -4
- package/build/relations/AbstractPropertyImpl.d.cts.map +1 -1
- package/build/relations/AbstractPropertyImpl.d.mts +1 -4
- package/build/relations/AbstractPropertyImpl.d.mts.map +1 -1
- package/build/relations/AbstractPropertyImpl.js +1 -2
- package/build/relations/AbstractPropertyImpl.js.map +1 -1
- package/build/relations/AbstractRelationImpl.cjs +1 -2
- package/build/relations/AbstractRelationImpl.d.cts +1 -4
- package/build/relations/AbstractRelationImpl.d.cts.map +1 -1
- package/build/relations/AbstractRelationImpl.d.mts +1 -4
- package/build/relations/AbstractRelationImpl.d.mts.map +1 -1
- package/build/relations/AbstractRelationImpl.js +1 -2
- package/build/relations/AsyncProperty.cjs +4 -5
- package/build/relations/AsyncProperty.cjs.map +1 -1
- package/build/relations/AsyncProperty.d.cts +7 -10
- package/build/relations/AsyncProperty.d.cts.map +1 -1
- package/build/relations/AsyncProperty.d.mts +7 -10
- package/build/relations/AsyncProperty.d.mts.map +1 -1
- package/build/relations/AsyncProperty.js +4 -5
- package/build/relations/AsyncProperty.js.map +1 -1
- package/build/relations/AsyncReactiveField.cjs +30 -13
- package/build/relations/AsyncReactiveField.cjs.map +1 -1
- package/build/relations/AsyncReactiveField.d.cts +11 -12
- package/build/relations/AsyncReactiveField.d.cts.map +1 -1
- package/build/relations/AsyncReactiveField.d.mts +11 -12
- package/build/relations/AsyncReactiveField.d.mts.map +1 -1
- package/build/relations/AsyncReactiveField.js +30 -13
- package/build/relations/AsyncReactiveField.js.map +1 -1
- package/build/relations/Collection.cjs +3 -4
- package/build/relations/Collection.d.cts +6 -9
- package/build/relations/Collection.d.cts.map +1 -1
- package/build/relations/Collection.d.mts +6 -9
- package/build/relations/Collection.d.mts.map +1 -1
- package/build/relations/Collection.js +3 -4
- package/build/relations/CustomCollection.cjs +6 -7
- package/build/relations/CustomCollection.cjs.map +1 -1
- package/build/relations/CustomCollection.d.cts +7 -10
- package/build/relations/CustomCollection.d.cts.map +1 -1
- package/build/relations/CustomCollection.d.mts +7 -10
- package/build/relations/CustomCollection.d.mts.map +1 -1
- package/build/relations/CustomCollection.js +6 -7
- package/build/relations/CustomCollection.js.map +1 -1
- package/build/relations/CustomReference.cjs +9 -10
- package/build/relations/CustomReference.cjs.map +1 -1
- package/build/relations/CustomReference.d.cts +9 -12
- package/build/relations/CustomReference.d.cts.map +1 -1
- package/build/relations/CustomReference.d.mts +9 -12
- package/build/relations/CustomReference.d.mts.map +1 -1
- package/build/relations/CustomReference.js +9 -10
- package/build/relations/CustomReference.js.map +1 -1
- package/build/relations/EnumCollection.cjs +5 -6
- package/build/relations/EnumCollection.cjs.map +1 -1
- package/build/relations/EnumCollection.d.cts +8 -10
- package/build/relations/EnumCollection.d.cts.map +1 -1
- package/build/relations/EnumCollection.d.mts +8 -10
- package/build/relations/EnumCollection.d.mts.map +1 -1
- package/build/relations/EnumCollection.js +5 -6
- package/build/relations/EnumCollection.js.map +1 -1
- package/build/relations/LargeCollection.cjs +2 -2
- package/build/relations/LargeCollection.d.cts +3 -6
- package/build/relations/LargeCollection.d.cts.map +1 -1
- package/build/relations/LargeCollection.d.mts +3 -6
- package/build/relations/LargeCollection.d.mts.map +1 -1
- package/build/relations/LargeCollection.js +2 -2
- package/build/relations/LazyField.cjs +23 -10
- package/build/relations/LazyField.cjs.map +1 -1
- package/build/relations/LazyField.d.cts +15 -12
- package/build/relations/LazyField.d.cts.map +1 -1
- package/build/relations/LazyField.d.mts +15 -12
- package/build/relations/LazyField.d.mts.map +1 -1
- package/build/relations/LazyField.js +23 -10
- package/build/relations/LazyField.js.map +1 -1
- package/build/relations/ManyToManyCollection.cjs +7 -8
- package/build/relations/ManyToManyCollection.cjs.map +1 -1
- package/build/relations/ManyToManyCollection.d.cts +4 -7
- package/build/relations/ManyToManyCollection.d.cts.map +1 -1
- package/build/relations/ManyToManyCollection.d.mts +4 -7
- package/build/relations/ManyToManyCollection.d.mts.map +1 -1
- package/build/relations/ManyToManyCollection.js +7 -8
- package/build/relations/ManyToManyCollection.js.map +1 -1
- package/build/relations/ManyToManyLargeCollection.cjs +8 -9
- package/build/relations/ManyToManyLargeCollection.d.cts +6 -9
- package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -1
- package/build/relations/ManyToManyLargeCollection.d.mts +6 -9
- package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -1
- package/build/relations/ManyToManyLargeCollection.js +8 -9
- package/build/relations/ManyToOneReference.cjs +11 -12
- package/build/relations/ManyToOneReference.cjs.map +1 -1
- package/build/relations/ManyToOneReference.d.cts +12 -15
- package/build/relations/ManyToOneReference.d.cts.map +1 -1
- package/build/relations/ManyToOneReference.d.mts +12 -15
- package/build/relations/ManyToOneReference.d.mts.map +1 -1
- package/build/relations/ManyToOneReference.js +11 -12
- package/build/relations/ManyToOneReference.js.map +1 -1
- package/build/relations/OneToManyCollection.cjs +8 -9
- package/build/relations/OneToManyCollection.cjs.map +1 -1
- package/build/relations/OneToManyCollection.d.cts +5 -8
- package/build/relations/OneToManyCollection.d.cts.map +1 -1
- package/build/relations/OneToManyCollection.d.mts +5 -8
- package/build/relations/OneToManyCollection.d.mts.map +1 -1
- package/build/relations/OneToManyCollection.js +8 -9
- package/build/relations/OneToManyCollection.js.map +1 -1
- package/build/relations/OneToManyLargeCollection.cjs +7 -8
- package/build/relations/OneToManyLargeCollection.cjs.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.cts +6 -9
- package/build/relations/OneToManyLargeCollection.d.cts.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.mts +6 -9
- package/build/relations/OneToManyLargeCollection.d.mts.map +1 -1
- package/build/relations/OneToManyLargeCollection.js +7 -8
- package/build/relations/OneToManyLargeCollection.js.map +1 -1
- package/build/relations/OneToOneReference.cjs +10 -11
- package/build/relations/OneToOneReference.cjs.map +1 -1
- package/build/relations/OneToOneReference.d.cts +12 -14
- package/build/relations/OneToOneReference.d.cts.map +1 -1
- package/build/relations/OneToOneReference.d.mts +12 -14
- package/build/relations/OneToOneReference.d.mts.map +1 -1
- package/build/relations/OneToOneReference.js +10 -11
- package/build/relations/OneToOneReference.js.map +1 -1
- package/build/relations/PolymorphicReference.cjs +13 -14
- package/build/relations/PolymorphicReference.cjs.map +1 -1
- package/build/relations/PolymorphicReference.d.cts +9 -12
- package/build/relations/PolymorphicReference.d.cts.map +1 -1
- package/build/relations/PolymorphicReference.d.mts +9 -12
- package/build/relations/PolymorphicReference.d.mts.map +1 -1
- package/build/relations/PolymorphicReference.js +13 -14
- package/build/relations/PolymorphicReference.js.map +1 -1
- package/build/relations/PropertySymbols.cjs +1 -2
- package/build/relations/PropertySymbols.d.cts +1 -4
- package/build/relations/PropertySymbols.d.cts.map +1 -1
- package/build/relations/PropertySymbols.d.mts +1 -4
- package/build/relations/PropertySymbols.d.mts.map +1 -1
- package/build/relations/PropertySymbols.js +1 -2
- package/build/relations/ReactiveField.cjs +35 -15
- package/build/relations/ReactiveField.cjs.map +1 -1
- package/build/relations/ReactiveField.d.cts +14 -12
- package/build/relations/ReactiveField.d.cts.map +1 -1
- package/build/relations/ReactiveField.d.mts +14 -12
- package/build/relations/ReactiveField.d.mts.map +1 -1
- package/build/relations/ReactiveField.js +35 -15
- package/build/relations/ReactiveField.js.map +1 -1
- package/build/relations/ReactiveGetter.cjs +3 -4
- package/build/relations/ReactiveGetter.cjs.map +1 -1
- package/build/relations/ReactiveGetter.d.cts +6 -9
- package/build/relations/ReactiveGetter.d.cts.map +1 -1
- package/build/relations/ReactiveGetter.d.mts +6 -9
- package/build/relations/ReactiveGetter.d.mts.map +1 -1
- package/build/relations/ReactiveGetter.js +3 -4
- package/build/relations/ReactiveGetter.js.map +1 -1
- package/build/relations/ReactiveManyToMany.cjs +22 -15
- package/build/relations/ReactiveManyToMany.cjs.map +1 -1
- package/build/relations/ReactiveManyToMany.d.cts +8 -11
- package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
- package/build/relations/ReactiveManyToMany.d.mts +8 -11
- package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
- package/build/relations/ReactiveManyToMany.js +22 -15
- package/build/relations/ReactiveManyToMany.js.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.cjs +4 -5
- package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.cts +8 -11
- package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.mts +8 -11
- package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -1
- package/build/relations/ReactiveManyToManyOtherSide.js +4 -5
- package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
- package/build/relations/ReactiveReference.cjs +12 -13
- package/build/relations/ReactiveReference.cjs.map +1 -1
- package/build/relations/ReactiveReference.d.cts +12 -15
- package/build/relations/ReactiveReference.d.cts.map +1 -1
- package/build/relations/ReactiveReference.d.mts +12 -15
- package/build/relations/ReactiveReference.d.mts.map +1 -1
- package/build/relations/ReactiveReference.js +12 -13
- package/build/relations/ReactiveReference.js.map +1 -1
- package/build/relations/ReadOnlyCollection.cjs +3 -4
- package/build/relations/ReadOnlyCollection.d.cts +5 -8
- package/build/relations/ReadOnlyCollection.d.cts.map +1 -1
- package/build/relations/ReadOnlyCollection.d.mts +5 -8
- package/build/relations/ReadOnlyCollection.d.mts.map +1 -1
- package/build/relations/ReadOnlyCollection.js +3 -4
- package/build/relations/RecursiveCollection.cjs +5 -6
- package/build/relations/RecursiveCollection.cjs.map +1 -1
- package/build/relations/RecursiveCollection.d.cts +13 -15
- package/build/relations/RecursiveCollection.d.cts.map +1 -1
- package/build/relations/RecursiveCollection.d.mts +13 -15
- package/build/relations/RecursiveCollection.d.mts.map +1 -1
- package/build/relations/RecursiveCollection.js +5 -6
- package/build/relations/RecursiveCollection.js.map +1 -1
- package/build/relations/RecursiveCycleError.cjs +1 -2
- package/build/relations/RecursiveCycleError.d.cts +2 -4
- package/build/relations/RecursiveCycleError.d.cts.map +1 -1
- package/build/relations/RecursiveCycleError.d.mts +2 -4
- 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 +8 -10
- package/build/relations/Reference.d.cts.map +1 -1
- package/build/relations/Reference.d.mts +8 -10
- 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 +1 -4
- package/build/relations/ReferenceSymbols.d.cts.map +1 -1
- package/build/relations/ReferenceSymbols.d.mts +1 -4
- 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 +4 -6
- package/build/relations/Relation.d.cts.map +1 -1
- package/build/relations/Relation.d.mts +4 -6
- 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 +2 -5
- package/build/relations/RelationSymbols.d.cts.map +1 -1
- package/build/relations/RelationSymbols.d.mts +2 -5
- package/build/relations/RelationSymbols.d.mts.map +1 -1
- package/build/relations/RelationSymbols.js +1 -2
- package/build/relations/hasAsyncMethod.cjs +25 -7
- package/build/relations/hasAsyncMethod.cjs.map +1 -1
- package/build/relations/hasAsyncMethod.d.cts +10 -11
- package/build/relations/hasAsyncMethod.d.cts.map +1 -1
- package/build/relations/hasAsyncMethod.d.mts +10 -11
- package/build/relations/hasAsyncMethod.d.mts.map +1 -1
- package/build/relations/hasAsyncMethod.js +25 -8
- package/build/relations/hasAsyncMethod.js.map +1 -1
- package/build/relations/hasManyDerived.cjs +4 -5
- package/build/relations/hasManyDerived.d.cts +4 -6
- package/build/relations/hasManyDerived.d.cts.map +1 -1
- package/build/relations/hasManyDerived.d.mts +4 -6
- package/build/relations/hasManyDerived.d.mts.map +1 -1
- package/build/relations/hasManyDerived.js +4 -5
- package/build/relations/hasManyThrough.cjs +3 -4
- package/build/relations/hasManyThrough.d.cts +1 -4
- package/build/relations/hasManyThrough.d.cts.map +1 -1
- package/build/relations/hasManyThrough.d.mts +1 -4
- package/build/relations/hasManyThrough.d.mts.map +1 -1
- package/build/relations/hasManyThrough.js +3 -4
- package/build/relations/hasOneDerived.cjs +5 -6
- package/build/relations/hasOneDerived.d.cts +3 -6
- package/build/relations/hasOneDerived.d.cts.map +1 -1
- package/build/relations/hasOneDerived.d.mts +3 -6
- package/build/relations/hasOneDerived.d.mts.map +1 -1
- package/build/relations/hasOneDerived.js +5 -6
- package/build/relations/hasOneThrough.cjs +3 -4
- package/build/relations/hasOneThrough.d.cts +1 -4
- package/build/relations/hasOneThrough.d.cts.map +1 -1
- package/build/relations/hasOneThrough.d.mts +1 -4
- package/build/relations/hasOneThrough.d.mts.map +1 -1
- package/build/relations/hasOneThrough.js +3 -4
- package/build/relations/hasProperty.cjs +6 -7
- package/build/relations/hasProperty.cjs.map +1 -1
- package/build/relations/hasProperty.d.cts +10 -12
- package/build/relations/hasProperty.d.cts.map +1 -1
- package/build/relations/hasProperty.d.mts +10 -12
- package/build/relations/hasProperty.d.mts.map +1 -1
- package/build/relations/hasProperty.js +6 -7
- package/build/relations/hasProperty.js.map +1 -1
- package/build/relations/hasReactiveAsyncMethod.cjs +86 -0
- package/build/relations/hasReactiveAsyncMethod.cjs.map +1 -0
- package/build/relations/hasReactiveAsyncMethod.d.cts +30 -0
- package/build/relations/hasReactiveAsyncMethod.d.cts.map +1 -0
- package/build/relations/hasReactiveAsyncMethod.d.mts +30 -0
- package/build/relations/hasReactiveAsyncMethod.d.mts.map +1 -0
- package/build/relations/hasReactiveAsyncMethod.js +84 -0
- package/build/relations/hasReactiveAsyncMethod.js.map +1 -0
- package/build/relations/index.cjs +10 -8
- package/build/relations/index.d.cts +5 -4
- package/build/relations/index.d.mts +5 -4
- package/build/relations/index.js +10 -9
- package/build/relations/isCascadeDelete.cjs +1 -2
- package/build/relations/isCascadeDelete.d.cts +1 -4
- package/build/relations/isCascadeDelete.d.cts.map +1 -1
- package/build/relations/isCascadeDelete.d.mts +1 -4
- package/build/relations/isCascadeDelete.d.mts.map +1 -1
- package/build/relations/isCascadeDelete.js +1 -2
- package/build/resurrection.cjs +15 -6
- package/build/resurrection.cjs.map +1 -1
- package/build/resurrection.d.cts +6 -6
- package/build/resurrection.d.cts.map +1 -1
- package/build/resurrection.d.mts +6 -6
- package/build/resurrection.d.mts.map +1 -1
- package/build/resurrection.js +15 -7
- package/build/resurrection.js.map +1 -1
- package/build/rules.cjs +6 -7
- package/build/rules.cjs.map +1 -1
- package/build/rules.d.cts +28 -25
- package/build/rules.d.cts.map +1 -1
- package/build/rules.d.mts +28 -25
- package/build/rules.d.mts.map +1 -1
- package/build/rules.js +6 -7
- package/build/rules.js.map +1 -1
- package/build/runtimeConfig.cjs +1 -2
- package/build/runtimeConfig.d.cts +4 -7
- package/build/runtimeConfig.d.cts.map +1 -1
- package/build/runtimeConfig.d.mts +4 -7
- 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 +3 -6
- package/build/serde/TypeInfo.d.cts.map +1 -1
- package/build/serde/TypeInfo.d.mts +3 -6
- package/build/serde/TypeInfo.d.mts.map +1 -1
- package/build/serde/TypeInfo.js +1 -2
- package/build/serde/columns.cjs +4 -2
- package/build/serde/columns.cjs.map +1 -1
- package/build/serde/columns.d.cts +5 -7
- package/build/serde/columns.d.cts.map +1 -1
- package/build/serde/columns.d.mts +5 -7
- package/build/serde/columns.d.mts.map +1 -1
- package/build/serde/columns.js +4 -2
- package/build/serde/columns.js.map +1 -1
- package/build/serde/fieldSerde.cjs +7 -5
- package/build/serde/fieldSerde.cjs.map +1 -1
- package/build/serde/fieldSerde.d.cts +14 -15
- package/build/serde/fieldSerde.d.cts.map +1 -1
- package/build/serde/fieldSerde.d.mts +14 -15
- package/build/serde/fieldSerde.d.mts.map +1 -1
- package/build/serde/fieldSerde.js +7 -5
- package/build/serde/fieldSerde.js.map +1 -1
- package/build/serde/serde.cjs +64 -5
- package/build/serde/serde.cjs.map +1 -1
- package/build/serde/serde.d.cts +58 -21
- package/build/serde/serde.d.cts.map +1 -1
- package/build/serde/serde.d.mts +58 -21
- package/build/serde/serde.d.mts.map +1 -1
- package/build/serde/serde.js +64 -6
- package/build/serde/serde.js.map +1 -1
- package/build/serde/temporal.cjs +8 -14
- package/build/serde/temporal.cjs.map +1 -1
- package/build/serde/temporal.d.cts +6 -8
- package/build/serde/temporal.d.cts.map +1 -1
- package/build/serde/temporal.d.mts +6 -8
- package/build/serde/temporal.d.mts.map +1 -1
- package/build/serde/temporal.js +8 -14
- package/build/serde/temporal.js.map +1 -1
- package/build/serde/temporalMappers.cjs +9 -6
- package/build/serde/temporalMappers.cjs.map +1 -1
- package/build/serde/temporalMappers.d.cts +5 -8
- package/build/serde/temporalMappers.d.cts.map +1 -1
- package/build/serde/temporalMappers.d.mts +5 -8
- package/build/serde/temporalMappers.d.mts.map +1 -1
- package/build/serde/temporalMappers.js +9 -6
- package/build/serde/temporalMappers.js.map +1 -1
- package/build/transitions.cjs +90 -0
- package/build/transitions.cjs.map +1 -0
- package/build/transitions.d.cts +113 -0
- package/build/transitions.d.cts.map +1 -0
- package/build/transitions.d.mts +113 -0
- package/build/transitions.d.mts.map +1 -0
- package/build/transitions.js +85 -0
- package/build/transitions.js.map +1 -0
- package/build/trusted.cjs +1 -2
- package/build/trusted.cjs.map +1 -1
- package/build/trusted.d.cts +2 -5
- package/build/trusted.d.cts.map +1 -1
- package/build/trusted.d.mts +2 -5
- 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 +18 -20
- package/build/typeMap.d.cts.map +1 -1
- package/build/typeMap.d.mts +18 -20
- 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 +7 -9
- package/build/upsert.d.cts.map +1 -1
- package/build/upsert.d.mts +7 -9
- 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 +29 -32
- package/build/utils.d.cts.map +1 -1
- package/build/utils.d.mts +29 -32
- package/build/utils.d.mts.map +1 -1
- package/build/utils.js +3 -4
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporalMappers.js","names":[],"sources":["../../src/serde/temporalMappers.ts"],"sourcesContent":["import type { CustomSerde } from \"src/serde/serde.ts\";\nimport { type Temporal, maybeRequireTemporal } from \"src/serde/temporal.ts\";\nimport { fail } from \"src/utils.ts\";\n\nconst { Temporal: t } = maybeRequireTemporal() ?? {};\nconst temporalNotAvailable = {\n fromDb: () => fail(\"Temporal not available\"),\n toDb: () => fail(\"Temporal not available\"),\n};\n\n/**\n * Converts Postgres `DATE` to/from Temporal.PlainDate.\n *\n * `fromDb` accepts either pg's text form (classic/knex text queries, json_agg preloads) or an\n * already-constructed `PlainDate` (lazy binary queries decode wire bytes -> Temporal directly).\n */\nexport const plainDateMapper: CustomSerde<Temporal.PlainDate, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainDate) => (value instanceof t.PlainDate ? value : t.PlainDate.from(value)),\n toDb: (p) => p.toString(),\n }\n : temporalNotAvailable;\n\n/** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */\nexport const plainTimeMapper: CustomSerde<Temporal.PlainTime, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainTime) => (value instanceof t.PlainTime ? value : t.PlainTime.from(value)),\n toDb: (pt) => pt.toString(),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;\n * `fromDb` also passes binary-decoded instances through.\n */\nexport const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string> = t\n ? {\n // Text values look like `2018-01-01 10:00:00`\n fromDb: (value: string | Temporal.PlainDateTime) =>\n value instanceof t.PlainDateTime ? value : t.PlainDateTime.from(value),\n toDb: (p) => p.toString(),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.\n *\n * Specifically, Postgres uses ISO 8601, which Temporal supports as well, except that PG ouputs a space instead of `T`\n * between the date/time for output.\n *\n * Additionally, `Temporal.ZonedDateTime.from` expects a time zone literal name to be supplied as part of the string,\n * but this is not stored by postgres.\n *\n * As such, we parse the offset and append it to string passed to `from` as the time zone. This means that if we did a\n * round trip of generating a db value then parsing it, then it may not strictly equal the original zdt.\n *\n * Finally, PG stores dates as UTC and converts them to its local time zone for output, so we could get any offset\n * theoretically. If, somehow, we don't get an offset, then we assume UTC.\n */\nexport const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string> = t\n ? {\n // Produce a ZDT from a PG output like \"2021-01-01 12:00:00-05:00\"; binary-decoded\n // instances (lazy queries construct ZonedDateTimes directly) pass through\n fromDb: (value: string | Temporal.ZonedDateTime) => {\n if (typeof value !== \"string\") return value;\n const [offset] = value.match(/([+-]\\d{2}(?::?\\d{2})?)$/) ?? [];\n return t.ZonedDateTime.from(`${value}[${!offset || /^\\+00(:?00)?$/.test(offset) ? \"UTC\" : offset}]`);\n },\n // Match a PG `TIMESTAMPTZ` input format, i.e. \"2021-01-01T12:00:00-05:00\"\n toDb: (zdt) => zdt.toString({ timeZoneName: \"never\" }),\n }\n : temporalNotAvailable;\n"],"mappings":";;;AAIA,MAAM,EAAE,UAAU,MAAM,qBAAqB,KAAK,CAAC;AACnD,MAAM,uBAAuB;CAC3B,cAAc,KAAK,wBAAwB;CAC3C,YAAY,KAAK,wBAAwB;AAC3C;;;;;;;AAQA,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,MAAM,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"temporalMappers.js","names":[],"sources":["../../src/serde/temporalMappers.ts"],"sourcesContent":["import type { CustomSerde } from \"src/serde/serde.ts\";\nimport { type Temporal, maybeRequireTemporal } from \"src/serde/temporal.ts\";\nimport { fail } from \"src/utils.ts\";\n\nconst { Temporal: t } = maybeRequireTemporal() ?? {};\nconst temporalNotAvailable = {\n fromDb: () => fail(\"Temporal not available\"),\n toDb: () => fail(\"Temporal not available\"),\n};\n\n/**\n * Converts Postgres `DATE` to/from Temporal.PlainDate.\n *\n * `fromDb` accepts either pg's text form (classic/knex text queries, json_agg preloads) or an\n * already-constructed `PlainDate` (lazy binary queries decode wire bytes -> Temporal directly).\n */\nexport const plainDateMapper: CustomSerde<Temporal.PlainDate, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainDate) => (value instanceof t.PlainDate ? value : t.PlainDate.from(value)),\n toDb: (p) => p.toString(),\n getUnnestMarker: () => t.PlainDate.from(\"2000-01-01\"),\n }\n : temporalNotAvailable;\n\n/** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */\nexport const plainTimeMapper: CustomSerde<Temporal.PlainTime, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainTime) => (value instanceof t.PlainTime ? value : t.PlainTime.from(value)),\n toDb: (pt) => pt.toString(),\n getUnnestMarker: () => t.PlainTime.from(\"00:00:00\"),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;\n * `fromDb` also passes binary-decoded instances through.\n */\nexport const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string> = t\n ? {\n // Text values look like `2018-01-01 10:00:00`\n fromDb: (value: string | Temporal.PlainDateTime) =>\n value instanceof t.PlainDateTime ? value : t.PlainDateTime.from(value),\n toDb: (p) => p.toString(),\n getUnnestMarker: () => t.PlainDateTime.from(\"2000-01-01T00:00:00\"),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.\n *\n * Specifically, Postgres uses ISO 8601, which Temporal supports as well, except that PG ouputs a space instead of `T`\n * between the date/time for output.\n *\n * Additionally, `Temporal.ZonedDateTime.from` expects a time zone literal name to be supplied as part of the string,\n * but this is not stored by postgres.\n *\n * As such, we parse the offset and append it to string passed to `from` as the time zone. This means that if we did a\n * round trip of generating a db value then parsing it, then it may not strictly equal the original zdt.\n *\n * Finally, PG stores dates as UTC and converts them to its local time zone for output, so we could get any offset\n * theoretically. If, somehow, we don't get an offset, then we assume UTC.\n */\nexport const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string> = t\n ? {\n // Produce a ZDT from a PG output like \"2021-01-01 12:00:00-05:00\"; binary-decoded\n // instances (lazy queries construct ZonedDateTimes directly) pass through\n fromDb: (value: string | Temporal.ZonedDateTime) => {\n if (typeof value !== \"string\") return value;\n const [offset] = value.match(/([+-]\\d{2}(?::?\\d{2})?)$/) ?? [];\n return t.ZonedDateTime.from(`${value}[${!offset || /^\\+00(:?00)?$/.test(offset) ? \"UTC\" : offset}]`);\n },\n // Match a PG `TIMESTAMPTZ` input format, i.e. \"2021-01-01T12:00:00-05:00\"\n toDb: (zdt) => zdt.toString({ timeZoneName: \"never\" }),\n getUnnestMarker: () => t.ZonedDateTime.from(\"2000-01-01T00:00:00+00:00[UTC]\"),\n }\n : temporalNotAvailable;\n"],"mappings":";;;AAIA,MAAM,EAAE,UAAU,MAAM,qBAAqB,KAAK,CAAC;AACnD,MAAM,uBAAuB;CAC3B,cAAc,KAAK,wBAAwB;CAC3C,YAAY,KAAK,wBAAwB;AAC3C;;;;;;;AAQA,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,MAAM,EAAE,SAAS;CACxB,uBAAuB,EAAE,UAAU,KAAK,YAAY;AACtD,IACA;;AAGJ,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,OAAO,GAAG,SAAS;CAC1B,uBAAuB,EAAE,UAAU,KAAK,UAAU;AACpD,IACA;;;;;AAMJ,MAAa,sBAAmE,IAC5E;CAEE,SAAS,UACP,iBAAiB,EAAE,gBAAgB,QAAQ,EAAE,cAAc,KAAK,KAAK;CACvE,OAAO,MAAM,EAAE,SAAS;CACxB,uBAAuB,EAAE,cAAc,KAAK,qBAAqB;AACnE,IACA;;;;;;;;;;;;;;;;AAiBJ,MAAa,sBAAmE,IAC5E;CAGE,SAAS,UAA2C;EAClD,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,MAAM,CAAC,UAAU,MAAM,MAAM,0BAA0B,KAAK,CAAC;EAC7D,OAAO,EAAE,cAAc,KAAK,GAAG,MAAM,GAAG,CAAC,UAAU,gBAAgB,KAAK,MAAM,IAAI,QAAQ,OAAO,EAAE;CACrG;CAEA,OAAO,QAAQ,IAAI,SAAS,EAAE,cAAc,QAAQ,CAAC;CACrD,uBAAuB,EAAE,cAAc,KAAK,gCAAgC;AAC9E,IACA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_EntityMetadata = require("./EntityMetadata.cjs");
|
|
3
|
+
const require_metrics_EntityMetrics = require("./metrics/EntityMetrics.cjs");
|
|
4
|
+
const require_utils = require("./utils.cjs");
|
|
5
|
+
// src/transitions.ts
|
|
6
|
+
/** The "from" state of a just-created entity, because `undefined` can be a real field value. */
|
|
7
|
+
const created = Symbol("created");
|
|
8
|
+
/** Converts an internal step to the `Transition` that guards and reactions receive. */
|
|
9
|
+
function toTransition(step) {
|
|
10
|
+
return {
|
|
11
|
+
from: step.from === created ? void 0 : step.from,
|
|
12
|
+
to: step.to
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Merges the transition config of `meta` and its base types by field, converting accessors to codes.
|
|
17
|
+
*
|
|
18
|
+
* This runs after boot, because the config is written before the enum metadata exists.
|
|
19
|
+
*/
|
|
20
|
+
function buildFieldTransitions(meta) {
|
|
21
|
+
const byField = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const m of require_EntityMetadata.getBaseAndSelfMetas(meta)) for (const [fieldName, config] of Object.entries(m.config.__data.transitions)) {
|
|
23
|
+
let merged = byField.get(fieldName);
|
|
24
|
+
if (!merged) byField.set(fieldName, merged = {
|
|
25
|
+
tables: [],
|
|
26
|
+
guards: [],
|
|
27
|
+
callbacks: []
|
|
28
|
+
});
|
|
29
|
+
if (config.table) merged.tables.push(toCodesTable(meta, fieldName, config.table));
|
|
30
|
+
for (const { match, run } of config.guards) merged.guards.push({
|
|
31
|
+
matcher: toMatcher(meta, fieldName, match),
|
|
32
|
+
run
|
|
33
|
+
});
|
|
34
|
+
for (const { name, match, run } of config.callbacks) {
|
|
35
|
+
const matcher = toMatcher(meta, fieldName, match);
|
|
36
|
+
merged.callbacks.push({
|
|
37
|
+
name,
|
|
38
|
+
phase: match.phase ?? "flush",
|
|
39
|
+
matcher,
|
|
40
|
+
evaluation: new require_metrics_EntityMetrics.EvaluationSlot(`${meta.type}.${name}`),
|
|
41
|
+
run
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return byField;
|
|
46
|
+
}
|
|
47
|
+
/** Returns whether `step` matches `matcher`'s `from`, `to`, and `onCreate` settings. */
|
|
48
|
+
function matchesTransition(matcher, step) {
|
|
49
|
+
if (step.from === created) {
|
|
50
|
+
if (!matcher.onCreate) return false;
|
|
51
|
+
} else if (matcher.from && !matcher.from.includes(step.from)) return false;
|
|
52
|
+
return !matcher.to || matcher.to.includes(step.to);
|
|
53
|
+
}
|
|
54
|
+
/** Uses the enum's display name in error messages when there is one, i.e. `Approved` instead of `APPROVED`. */
|
|
55
|
+
function describeValue(meta, fieldName, value) {
|
|
56
|
+
if (value === void 0) return "unset";
|
|
57
|
+
const field = meta.allFields[fieldName];
|
|
58
|
+
return field?.kind === "enum" ? field.enumDetailType.getByCode(value)?.name ?? String(value) : String(value);
|
|
59
|
+
}
|
|
60
|
+
/** Converts a `transitions` table's keys and values to codes, so it can be compared to field values. */
|
|
61
|
+
function toCodesTable(meta, fieldName, table) {
|
|
62
|
+
return new Map(Object.entries(table).map(([from, tos]) => [accessorToCode(meta, fieldName, from), toCodes(meta, fieldName, tos ?? [])]));
|
|
63
|
+
}
|
|
64
|
+
/** Converts a `match`'s accessors to codes. */
|
|
65
|
+
function toMatcher(meta, fieldName, match) {
|
|
66
|
+
return {
|
|
67
|
+
from: toCodes(meta, fieldName, match.from),
|
|
68
|
+
to: toCodes(meta, fieldName, match.to),
|
|
69
|
+
onCreate: match.onCreate !== false && match.from === void 0
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Converts an enum accessor, i.e. `Rejected`, to its code, i.e. `REJECTED`, and fails on anything else. */
|
|
73
|
+
function accessorToCode(meta, fieldName, value) {
|
|
74
|
+
const field = meta.allFields[fieldName];
|
|
75
|
+
if (field?.kind !== "enum") require_utils.fail(`${meta.type}.${fieldName} is not an enum field, so it can't have transitions`);
|
|
76
|
+
if (typeof value !== "string" || !Object.hasOwn(field.enumType, value)) require_utils.fail(`Unknown ${meta.type}.${fieldName} accessor ${String(value)}, i.e. use "Draft" for AuthorStatus.Draft`);
|
|
77
|
+
return field.enumType[value];
|
|
78
|
+
}
|
|
79
|
+
/** Converts one or more enum accessors to an array of codes, preserving an omitted match. */
|
|
80
|
+
function toCodes(meta, fieldName, values) {
|
|
81
|
+
if (values === void 0) return void 0;
|
|
82
|
+
return typeof values === "string" ? [accessorToCode(meta, fieldName, values)] : values.map((v) => accessorToCode(meta, fieldName, v));
|
|
83
|
+
}
|
|
84
|
+
exports.buildFieldTransitions = buildFieldTransitions;
|
|
85
|
+
exports.created = created;
|
|
86
|
+
exports.describeValue = describeValue;
|
|
87
|
+
exports.matchesTransition = matchesTransition;
|
|
88
|
+
exports.toTransition = toTransition;
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=transitions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitions.cjs","names":["getBaseAndSelfMetas","EvaluationSlot"],"sources":["../src/transitions.ts"],"sourcesContent":["import type { Entity } from \"src/Entity.ts\";\nimport { type EntityMetadata, getBaseAndSelfMetas } from \"src/EntityMetadata.ts\";\nimport { EvaluationSlot } from \"src/metrics/EntityMetrics.ts\";\nimport type { ValidationRuleResult } from \"src/rules.ts\";\nimport { type MaybePromise, fail } from \"src/utils.ts\";\n\n/**\n * Which state transitions of an enum field an `addTransitionRule` cares about.\n *\n * Omitting `from` or `to` matches any state. Guards never run on creation.\n */\nexport interface GuardTransitionMatch<V> {\n from?: V | readonly V[];\n to?: V | readonly V[];\n}\n\n/**\n * Which state transitions of an enum field an `addTransitionReaction` callback handles.\n *\n * Creating an entity with a matching `to` state also matches, unless `from` is set or `onCreate` is `false`.\n */\nexport interface OnTransitionMatch<V> extends GuardTransitionMatch<V> {\n /**\n * Whether `addTransitionReaction` fires when an entity is created with a matching `to` state, defaults to `true`.\n *\n * Entering a state by creation usually needs the same side effects as entering it by a transition, and\n * forgetting them is easy to miss. Set `false` for reactions that only make sense for a transition.\n */\n onCreate?: boolean;\n /** `commit` runs in `beforeCommit`, i.e. to enqueue jobs; `flush` (the default) runs as a reaction. */\n phase?: \"flush\" | \"commit\";\n}\n\n/** Maps each state to the states it may transition to, i.e. `{ Draft: [\"Open\"], Open: [\"Closed\"] }`. */\nexport type TransitionTable<V extends PropertyKey> = Partial<Record<V, readonly V[]>>;\n\n/**\n * The transition a guard or reaction is handling, i.e. `{ from: \"DRAFT\", to: \"OPEN\" }`.\n *\n * Guards and callbacks run during reaction passes, after the assignment, so the entity may already be in a\n * later state. This tells them which transition they're handling. `from` is `undefined` for creation.\n */\nexport interface Transition<V> {\n from: V | undefined;\n to: V;\n}\n\n/** The \"from\" state of a just-created entity, because `undefined` can be a real field value. */\nexport const created: unique symbol = Symbol(\"created\");\n\n/** A single recorded transition of a field, with `from` as `created` for creation. */\nexport interface TransitionStep {\n from: unknown;\n to: unknown;\n}\n\n/** An `addTransitionRule` as registered in config, with its `match` still using accessors. */\nexport interface TransitionGuardConfig<T extends Entity = Entity> {\n match: GuardTransitionMatch<string>;\n run(entity: T, step: TransitionStep): MaybePromise<ValidationRuleResult>;\n}\n\n/**\n * An `addTransitionReaction` as registered in config, with its `match` still using accessors.\n *\n * @internal Joist invokes `run`; the application callback does not receive the metrics slot.\n */\nexport interface TransitionCallbackConfig<T extends Entity = Entity, C = unknown> {\n name: string;\n match: OnTransitionMatch<string>;\n run(entity: T, ctx: C, step: TransitionStep, evaluation: EvaluationSlot): MaybePromise<unknown>;\n}\n\n/** One field's `setTransitions`, `addTransitionRule`, and `addTransitionReaction` config on a single entity type. */\nexport interface FieldTransitionsConfig<T extends Entity = Entity, C = unknown> {\n /** The `transitions` table, if any; subtypes add their own tables on their own configs. */\n table?: TransitionTable<string>;\n guards: TransitionGuardConfig<T>[];\n callbacks: TransitionCallbackConfig<T, C>[];\n}\n\n/** A `match` with accessors converted to codes, so it can be compared to recorded steps. */\nexport interface TransitionMatcher {\n /** The allowed previous states, or `undefined` for any state. */\n from: readonly unknown[] | undefined;\n /** The allowed new states, or `undefined` for any state. */\n to: readonly unknown[] | undefined;\n /** Whether creation matches, which is never true when `from` is set. */\n onCreate: boolean;\n}\n\n/** A guard with its `match` converted to codes. */\nexport interface TransitionGuard {\n matcher: TransitionMatcher;\n run(entity: Entity, step: TransitionStep): MaybePromise<ValidationRuleResult>;\n}\n\n/** A callback with its `match` converted to codes, dispatched only after its transition's guards pass. */\nexport interface TransitionCallback {\n name: string;\n phase: \"flush\" | \"commit\";\n matcher: TransitionMatcher;\n evaluation: EvaluationSlot;\n run(entity: Entity, ctx: unknown, step: TransitionStep, evaluation: EvaluationSlot): MaybePromise<unknown>;\n}\n\n/** One field's transition config from an entity type and its base types, with accessors converted to codes. */\nexport interface FieldTransitions {\n /** Each table maps a `from` code to its allowed `to` codes; every table must allow a change. */\n tables: ReadonlyMap<unknown, readonly unknown[]>[];\n guards: TransitionGuard[];\n callbacks: TransitionCallback[];\n}\n\n/** Converts an internal step to the `Transition` that guards and reactions receive. */\nexport function toTransition(step: TransitionStep): Transition<any> {\n return { from: step.from === created ? undefined : step.from, to: step.to };\n}\n\n/**\n * Merges the transition config of `meta` and its base types by field, converting accessors to codes.\n *\n * This runs after boot, because the config is written before the enum metadata exists.\n */\nexport function buildFieldTransitions(meta: EntityMetadata): Map<string, FieldTransitions> {\n const byField = new Map<string, FieldTransitions>();\n for (const m of getBaseAndSelfMetas(meta)) {\n for (const [fieldName, config] of Object.entries(m.config.__data.transitions)) {\n let merged = byField.get(fieldName);\n if (!merged) byField.set(fieldName, (merged = { tables: [], guards: [], callbacks: [] }));\n if (config.table) merged.tables.push(toCodesTable(meta, fieldName, config.table));\n for (const { match, run } of config.guards) {\n merged.guards.push({ matcher: toMatcher(meta, fieldName, match), run });\n }\n for (const { name, match, run } of config.callbacks) {\n const matcher = toMatcher(meta, fieldName, match);\n merged.callbacks.push({\n name,\n phase: match.phase ?? \"flush\",\n matcher,\n evaluation: new EvaluationSlot(`${meta.type}.${name}`),\n run,\n });\n }\n }\n }\n return byField;\n}\n\n/** Returns whether `step` matches `matcher`'s `from`, `to`, and `onCreate` settings. */\nexport function matchesTransition(matcher: TransitionMatcher, step: TransitionStep): boolean {\n if (step.from === created) {\n if (!matcher.onCreate) return false;\n } else if (matcher.from && !matcher.from.includes(step.from)) {\n return false;\n }\n return !matcher.to || matcher.to.includes(step.to);\n}\n\n/** Uses the enum's display name in error messages when there is one, i.e. `Approved` instead of `APPROVED`. */\nexport function describeValue(meta: EntityMetadata, fieldName: string, value: unknown): string {\n if (value === undefined) return \"unset\";\n const field = meta.allFields[fieldName];\n return field?.kind === \"enum\" ? (field.enumDetailType.getByCode(value)?.name ?? String(value)) : String(value);\n}\n\n/** Converts a `transitions` table's keys and values to codes, so it can be compared to field values. */\nfunction toCodesTable(\n meta: EntityMetadata,\n fieldName: string,\n table: TransitionTable<string>,\n): Map<unknown, readonly unknown[]> {\n return new Map(\n Object.entries(table).map(([from, tos]) => [\n accessorToCode(meta, fieldName, from),\n toCodes(meta, fieldName, tos ?? [])!,\n ]),\n );\n}\n\n/** Converts a `match`'s accessors to codes. */\nfunction toMatcher(meta: EntityMetadata, fieldName: string, match: OnTransitionMatch<string>): TransitionMatcher {\n return {\n from: toCodes(meta, fieldName, match.from),\n to: toCodes(meta, fieldName, match.to),\n // `from` describes a previous state, which a new entity doesn't have\n onCreate: match.onCreate !== false && match.from === undefined,\n };\n}\n\n/** Converts an enum accessor, i.e. `Rejected`, to its code, i.e. `REJECTED`, and fails on anything else. */\nfunction accessorToCode(meta: EntityMetadata, fieldName: string, value: unknown): unknown {\n const field = meta.allFields[fieldName];\n if (field?.kind !== \"enum\") fail(`${meta.type}.${fieldName} is not an enum field, so it can't have transitions`);\n // Only accessors are accepted, even from untyped callers, so every table reads the same way\n if (typeof value !== \"string\" || !Object.hasOwn(field.enumType, value)) {\n fail(`Unknown ${meta.type}.${fieldName} accessor ${String(value)}, i.e. use \"Draft\" for AuthorStatus.Draft`);\n }\n return field.enumType[value];\n}\n\n/** Converts one or more enum accessors to an array of codes, preserving an omitted match. */\nfunction toCodes(\n meta: EntityMetadata,\n fieldName: string,\n values: string | readonly string[] | undefined,\n): unknown[] | undefined {\n if (values === undefined) return undefined;\n return typeof values === \"string\"\n ? [accessorToCode(meta, fieldName, values)]\n : values.map((v) => accessorToCode(meta, fieldName, v));\n}\n"],"mappings":";;;;;;AAgDA,MAAa,UAAyB,OAAO,SAAS;;AAmEtD,SAAgB,aAAa,MAAuC;CAClE,OAAO;EAAE,MAAM,KAAK,SAAS,UAAU,KAAA,IAAY,KAAK;EAAM,IAAI,KAAK;CAAG;AAC5E;;;;;;AAOA,SAAgB,sBAAsB,MAAqD;CACzF,MAAM,0BAAU,IAAI,IAA8B;CAClD,KAAK,MAAM,KAAKA,uBAAAA,oBAAoB,IAAI,GACtC,KAAK,MAAM,CAAC,WAAW,WAAW,OAAO,QAAQ,EAAE,OAAO,OAAO,WAAW,GAAG;EAC7E,IAAI,SAAS,QAAQ,IAAI,SAAS;EAClC,IAAI,CAAC,QAAQ,QAAQ,IAAI,WAAY,SAAS;GAAE,QAAQ,CAAC;GAAG,QAAQ,CAAC;GAAG,WAAW,CAAC;EAAE,CAAE;EACxF,IAAI,OAAO,OAAO,OAAO,OAAO,KAAK,aAAa,MAAM,WAAW,OAAO,KAAK,CAAC;EAChF,KAAK,MAAM,EAAE,OAAO,SAAS,OAAO,QAClC,OAAO,OAAO,KAAK;GAAE,SAAS,UAAU,MAAM,WAAW,KAAK;GAAG;EAAI,CAAC;EAExE,KAAK,MAAM,EAAE,MAAM,OAAO,SAAS,OAAO,WAAW;GACnD,MAAM,UAAU,UAAU,MAAM,WAAW,KAAK;GAChD,OAAO,UAAU,KAAK;IACpB;IACA,OAAO,MAAM,SAAS;IACtB;IACA,YAAY,IAAIC,8BAAAA,eAAe,GAAG,KAAK,KAAK,GAAG,MAAM;IACrD;GACF,CAAC;EACH;CACF;CAEF,OAAO;AACT;;AAGA,SAAgB,kBAAkB,SAA4B,MAA+B;CAC3F,IAAI,KAAK,SAAS,SACZ;MAAA,CAAC,QAAQ,UAAU,OAAO;CAAA,OACzB,IAAI,QAAQ,QAAQ,CAAC,QAAQ,KAAK,SAAS,KAAK,IAAI,GACzD,OAAO;CAET,OAAO,CAAC,QAAQ,MAAM,QAAQ,GAAG,SAAS,KAAK,EAAE;AACnD;;AAGA,SAAgB,cAAc,MAAsB,WAAmB,OAAwB;CAC7F,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAQ,KAAK,UAAU;CAC7B,OAAO,OAAO,SAAS,SAAU,MAAM,eAAe,UAAU,KAAK,CAAC,EAAE,QAAQ,OAAO,KAAK,IAAK,OAAO,KAAK;AAC/G;;AAGA,SAAS,aACP,MACA,WACA,OACkC;CAClC,OAAO,IAAI,IACT,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,SAAS,CACzC,eAAe,MAAM,WAAW,IAAI,GACpC,QAAQ,MAAM,WAAW,OAAO,CAAC,CAAC,CACpC,CAAC,CACH;AACF;;AAGA,SAAS,UAAU,MAAsB,WAAmB,OAAqD;CAC/G,OAAO;EACL,MAAM,QAAQ,MAAM,WAAW,MAAM,IAAI;EACzC,IAAI,QAAQ,MAAM,WAAW,MAAM,EAAE;EAErC,UAAU,MAAM,aAAa,SAAS,MAAM,SAAS,KAAA;CACvD;AACF;;AAGA,SAAS,eAAe,MAAsB,WAAmB,OAAyB;CACxF,MAAM,QAAQ,KAAK,UAAU;CAC7B,IAAI,OAAO,SAAS,QAAQ,cAAA,KAAK,GAAG,KAAK,KAAK,GAAG,UAAU,oDAAoD;CAE/G,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,OAAO,MAAM,UAAU,KAAK,GACnE,cAAA,KAAK,WAAW,KAAK,KAAK,GAAG,UAAU,YAAY,OAAO,KAAK,EAAE,0CAA0C;CAE7G,OAAO,MAAM,SAAS;AACxB;;AAGA,SAAS,QACP,MACA,WACA,QACuB;CACvB,IAAI,WAAW,KAAA,GAAW,OAAO,KAAA;CACjC,OAAO,OAAO,WAAW,WACrB,CAAC,eAAe,MAAM,WAAW,MAAM,CAAC,IACxC,OAAO,KAAK,MAAM,eAAe,MAAM,WAAW,CAAC,CAAC;AAC1D"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Entity } from "./Entity.cjs";
|
|
2
|
+
import { EntityMetadata } from "./EntityMetadata.cjs";
|
|
3
|
+
import { EvaluationSlot } from "./metrics/EntityMetrics.cjs";
|
|
4
|
+
import { ValidationRuleResult } from "./rules.cjs";
|
|
5
|
+
import { MaybePromise } from "./utils.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* Which state transitions of an enum field an `addTransitionRule` cares about.
|
|
8
|
+
*
|
|
9
|
+
* Omitting `from` or `to` matches any state. Guards never run on creation.
|
|
10
|
+
*/
|
|
11
|
+
export interface GuardTransitionMatch<V> {
|
|
12
|
+
from?: V | readonly V[];
|
|
13
|
+
to?: V | readonly V[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Which state transitions of an enum field an `addTransitionReaction` callback handles.
|
|
17
|
+
*
|
|
18
|
+
* Creating an entity with a matching `to` state also matches, unless `from` is set or `onCreate` is `false`.
|
|
19
|
+
*/
|
|
20
|
+
export interface OnTransitionMatch<V> extends GuardTransitionMatch<V> {
|
|
21
|
+
/**
|
|
22
|
+
* Whether `addTransitionReaction` fires when an entity is created with a matching `to` state, defaults to `true`.
|
|
23
|
+
*
|
|
24
|
+
* Entering a state by creation usually needs the same side effects as entering it by a transition, and
|
|
25
|
+
* forgetting them is easy to miss. Set `false` for reactions that only make sense for a transition.
|
|
26
|
+
*/
|
|
27
|
+
onCreate?: boolean;
|
|
28
|
+
/** `commit` runs in `beforeCommit`, i.e. to enqueue jobs; `flush` (the default) runs as a reaction. */
|
|
29
|
+
phase?: "flush" | "commit";
|
|
30
|
+
}
|
|
31
|
+
/** Maps each state to the states it may transition to, i.e. `{ Draft: ["Open"], Open: ["Closed"] }`. */
|
|
32
|
+
export type TransitionTable<V extends PropertyKey> = Partial<Record<V, readonly V[]>>;
|
|
33
|
+
/**
|
|
34
|
+
* The transition a guard or reaction is handling, i.e. `{ from: "DRAFT", to: "OPEN" }`.
|
|
35
|
+
*
|
|
36
|
+
* Guards and callbacks run during reaction passes, after the assignment, so the entity may already be in a
|
|
37
|
+
* later state. This tells them which transition they're handling. `from` is `undefined` for creation.
|
|
38
|
+
*/
|
|
39
|
+
export interface Transition<V> {
|
|
40
|
+
from: V | undefined;
|
|
41
|
+
to: V;
|
|
42
|
+
}
|
|
43
|
+
/** The "from" state of a just-created entity, because `undefined` can be a real field value. */
|
|
44
|
+
export declare const created: unique symbol;
|
|
45
|
+
/** A single recorded transition of a field, with `from` as `created` for creation. */
|
|
46
|
+
export interface TransitionStep {
|
|
47
|
+
from: unknown;
|
|
48
|
+
to: unknown;
|
|
49
|
+
}
|
|
50
|
+
/** An `addTransitionRule` as registered in config, with its `match` still using accessors. */
|
|
51
|
+
export interface TransitionGuardConfig<T extends Entity = Entity> {
|
|
52
|
+
match: GuardTransitionMatch<string>;
|
|
53
|
+
run(entity: T, step: TransitionStep): MaybePromise<ValidationRuleResult>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* An `addTransitionReaction` as registered in config, with its `match` still using accessors.
|
|
57
|
+
*
|
|
58
|
+
* @internal Joist invokes `run`; the application callback does not receive the metrics slot.
|
|
59
|
+
*/
|
|
60
|
+
export interface TransitionCallbackConfig<T extends Entity = Entity, C = unknown> {
|
|
61
|
+
name: string;
|
|
62
|
+
match: OnTransitionMatch<string>;
|
|
63
|
+
run(entity: T, ctx: C, step: TransitionStep, evaluation: EvaluationSlot): MaybePromise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
/** One field's `setTransitions`, `addTransitionRule`, and `addTransitionReaction` config on a single entity type. */
|
|
66
|
+
export interface FieldTransitionsConfig<T extends Entity = Entity, C = unknown> {
|
|
67
|
+
/** The `transitions` table, if any; subtypes add their own tables on their own configs. */
|
|
68
|
+
table?: TransitionTable<string>;
|
|
69
|
+
guards: TransitionGuardConfig<T>[];
|
|
70
|
+
callbacks: TransitionCallbackConfig<T, C>[];
|
|
71
|
+
}
|
|
72
|
+
/** A `match` with accessors converted to codes, so it can be compared to recorded steps. */
|
|
73
|
+
export interface TransitionMatcher {
|
|
74
|
+
/** The allowed previous states, or `undefined` for any state. */
|
|
75
|
+
from: readonly unknown[] | undefined;
|
|
76
|
+
/** The allowed new states, or `undefined` for any state. */
|
|
77
|
+
to: readonly unknown[] | undefined;
|
|
78
|
+
/** Whether creation matches, which is never true when `from` is set. */
|
|
79
|
+
onCreate: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** A guard with its `match` converted to codes. */
|
|
82
|
+
export interface TransitionGuard {
|
|
83
|
+
matcher: TransitionMatcher;
|
|
84
|
+
run(entity: Entity, step: TransitionStep): MaybePromise<ValidationRuleResult>;
|
|
85
|
+
}
|
|
86
|
+
/** A callback with its `match` converted to codes, dispatched only after its transition's guards pass. */
|
|
87
|
+
export interface TransitionCallback {
|
|
88
|
+
name: string;
|
|
89
|
+
phase: "flush" | "commit";
|
|
90
|
+
matcher: TransitionMatcher;
|
|
91
|
+
evaluation: EvaluationSlot;
|
|
92
|
+
run(entity: Entity, ctx: unknown, step: TransitionStep, evaluation: EvaluationSlot): MaybePromise<unknown>;
|
|
93
|
+
}
|
|
94
|
+
/** One field's transition config from an entity type and its base types, with accessors converted to codes. */
|
|
95
|
+
export interface FieldTransitions {
|
|
96
|
+
/** Each table maps a `from` code to its allowed `to` codes; every table must allow a change. */
|
|
97
|
+
tables: ReadonlyMap<unknown, readonly unknown[]>[];
|
|
98
|
+
guards: TransitionGuard[];
|
|
99
|
+
callbacks: TransitionCallback[];
|
|
100
|
+
}
|
|
101
|
+
/** Converts an internal step to the `Transition` that guards and reactions receive. */
|
|
102
|
+
export declare function toTransition(step: TransitionStep): Transition<any>;
|
|
103
|
+
/**
|
|
104
|
+
* Merges the transition config of `meta` and its base types by field, converting accessors to codes.
|
|
105
|
+
*
|
|
106
|
+
* This runs after boot, because the config is written before the enum metadata exists.
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildFieldTransitions(meta: EntityMetadata): Map<string, FieldTransitions>;
|
|
109
|
+
/** Returns whether `step` matches `matcher`'s `from`, `to`, and `onCreate` settings. */
|
|
110
|
+
export declare function matchesTransition(matcher: TransitionMatcher, step: TransitionStep): boolean;
|
|
111
|
+
/** Uses the enum's display name in error messages when there is one, i.e. `Approved` instead of `APPROVED`. */
|
|
112
|
+
export declare function describeValue(meta: EntityMetadata, fieldName: string, value: unknown): string;
|
|
113
|
+
//# sourceMappingURL=transitions.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitions.d.cts","names":[],"sources":["../src/transitions.ts"],"mappings":";;;;;;;;;;iBAWiB,qBAAqB;EACpC,OAAO,aAAa;EACpB,KAAK,aAAa;;;;;;;iBAQH,kBAAkB,WAAW,qBAAqB;;;;;;;EAOjE;;EAEA;;;YAIU,gBAAgB,UAAU,eAAe,QAAQ,OAAO,YAAY;;;;;;;iBAQ/D,WAAW;EAC1B,MAAM;EACN,IAAI;;;qBAIO;;iBAGI;EACf;EACA;;;iBAIe,sBAAsB,UAAU,SAAS;EACxD,OAAO;EACP,IAAI,QAAQ,GAAG,MAAM,iBAAiB,aAAa;;;;;;;iBAQpC,yBAAyB,UAAU,SAAS,QAAQ;EACnE;EACA,OAAO;EACP,IAAI,QAAQ,GAAG,KAAK,GAAG,MAAM,gBAAgB,YAAY,iBAAiB;;;iBAI3D,uBAAuB,UAAU,SAAS,QAAQ;;EAEjE,QAAQ;EACR,QAAQ,sBAAsB;EAC9B,WAAW,yBAAyB,GAAG;;;iBAIxB;;EAEf;;EAEA;;EAEA;;;iBAIe;EACf,SAAS;EACT,IAAI,QAAQ,QAAQ,MAAM,iBAAiB,aAAa;;;iBAIzC;EACf;EACA;EACA,SAAS;EACT,YAAY;EACZ,IAAI,QAAQ,QAAQ,cAAc,MAAM,gBAAgB,YAAY,iBAAiB;;;iBAItE;;EAEf,QAAQ;EACR,QAAQ;EACR,WAAW;;;wBAIG,aAAa,MAAM,iBAAiB;;;;;;wBASpC,sBAAsB,MAAM,iBAAiB,YAAY;;wBA0BzD,kBAAkB,SAAS,mBAAmB,MAAM;;wBAUpD,cAAc,MAAM,gBAAgB,mBAAmB"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Entity } from "./Entity.mjs";
|
|
2
|
+
import { EntityMetadata } from "./EntityMetadata.mjs";
|
|
3
|
+
import { EvaluationSlot } from "./metrics/EntityMetrics.mjs";
|
|
4
|
+
import { ValidationRuleResult } from "./rules.mjs";
|
|
5
|
+
import { MaybePromise } from "./utils.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Which state transitions of an enum field an `addTransitionRule` cares about.
|
|
8
|
+
*
|
|
9
|
+
* Omitting `from` or `to` matches any state. Guards never run on creation.
|
|
10
|
+
*/
|
|
11
|
+
export interface GuardTransitionMatch<V> {
|
|
12
|
+
from?: V | readonly V[];
|
|
13
|
+
to?: V | readonly V[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Which state transitions of an enum field an `addTransitionReaction` callback handles.
|
|
17
|
+
*
|
|
18
|
+
* Creating an entity with a matching `to` state also matches, unless `from` is set or `onCreate` is `false`.
|
|
19
|
+
*/
|
|
20
|
+
export interface OnTransitionMatch<V> extends GuardTransitionMatch<V> {
|
|
21
|
+
/**
|
|
22
|
+
* Whether `addTransitionReaction` fires when an entity is created with a matching `to` state, defaults to `true`.
|
|
23
|
+
*
|
|
24
|
+
* Entering a state by creation usually needs the same side effects as entering it by a transition, and
|
|
25
|
+
* forgetting them is easy to miss. Set `false` for reactions that only make sense for a transition.
|
|
26
|
+
*/
|
|
27
|
+
onCreate?: boolean;
|
|
28
|
+
/** `commit` runs in `beforeCommit`, i.e. to enqueue jobs; `flush` (the default) runs as a reaction. */
|
|
29
|
+
phase?: "flush" | "commit";
|
|
30
|
+
}
|
|
31
|
+
/** Maps each state to the states it may transition to, i.e. `{ Draft: ["Open"], Open: ["Closed"] }`. */
|
|
32
|
+
export type TransitionTable<V extends PropertyKey> = Partial<Record<V, readonly V[]>>;
|
|
33
|
+
/**
|
|
34
|
+
* The transition a guard or reaction is handling, i.e. `{ from: "DRAFT", to: "OPEN" }`.
|
|
35
|
+
*
|
|
36
|
+
* Guards and callbacks run during reaction passes, after the assignment, so the entity may already be in a
|
|
37
|
+
* later state. This tells them which transition they're handling. `from` is `undefined` for creation.
|
|
38
|
+
*/
|
|
39
|
+
export interface Transition<V> {
|
|
40
|
+
from: V | undefined;
|
|
41
|
+
to: V;
|
|
42
|
+
}
|
|
43
|
+
/** The "from" state of a just-created entity, because `undefined` can be a real field value. */
|
|
44
|
+
export declare const created: unique symbol;
|
|
45
|
+
/** A single recorded transition of a field, with `from` as `created` for creation. */
|
|
46
|
+
export interface TransitionStep {
|
|
47
|
+
from: unknown;
|
|
48
|
+
to: unknown;
|
|
49
|
+
}
|
|
50
|
+
/** An `addTransitionRule` as registered in config, with its `match` still using accessors. */
|
|
51
|
+
export interface TransitionGuardConfig<T extends Entity = Entity> {
|
|
52
|
+
match: GuardTransitionMatch<string>;
|
|
53
|
+
run(entity: T, step: TransitionStep): MaybePromise<ValidationRuleResult>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* An `addTransitionReaction` as registered in config, with its `match` still using accessors.
|
|
57
|
+
*
|
|
58
|
+
* @internal Joist invokes `run`; the application callback does not receive the metrics slot.
|
|
59
|
+
*/
|
|
60
|
+
export interface TransitionCallbackConfig<T extends Entity = Entity, C = unknown> {
|
|
61
|
+
name: string;
|
|
62
|
+
match: OnTransitionMatch<string>;
|
|
63
|
+
run(entity: T, ctx: C, step: TransitionStep, evaluation: EvaluationSlot): MaybePromise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
/** One field's `setTransitions`, `addTransitionRule`, and `addTransitionReaction` config on a single entity type. */
|
|
66
|
+
export interface FieldTransitionsConfig<T extends Entity = Entity, C = unknown> {
|
|
67
|
+
/** The `transitions` table, if any; subtypes add their own tables on their own configs. */
|
|
68
|
+
table?: TransitionTable<string>;
|
|
69
|
+
guards: TransitionGuardConfig<T>[];
|
|
70
|
+
callbacks: TransitionCallbackConfig<T, C>[];
|
|
71
|
+
}
|
|
72
|
+
/** A `match` with accessors converted to codes, so it can be compared to recorded steps. */
|
|
73
|
+
export interface TransitionMatcher {
|
|
74
|
+
/** The allowed previous states, or `undefined` for any state. */
|
|
75
|
+
from: readonly unknown[] | undefined;
|
|
76
|
+
/** The allowed new states, or `undefined` for any state. */
|
|
77
|
+
to: readonly unknown[] | undefined;
|
|
78
|
+
/** Whether creation matches, which is never true when `from` is set. */
|
|
79
|
+
onCreate: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** A guard with its `match` converted to codes. */
|
|
82
|
+
export interface TransitionGuard {
|
|
83
|
+
matcher: TransitionMatcher;
|
|
84
|
+
run(entity: Entity, step: TransitionStep): MaybePromise<ValidationRuleResult>;
|
|
85
|
+
}
|
|
86
|
+
/** A callback with its `match` converted to codes, dispatched only after its transition's guards pass. */
|
|
87
|
+
export interface TransitionCallback {
|
|
88
|
+
name: string;
|
|
89
|
+
phase: "flush" | "commit";
|
|
90
|
+
matcher: TransitionMatcher;
|
|
91
|
+
evaluation: EvaluationSlot;
|
|
92
|
+
run(entity: Entity, ctx: unknown, step: TransitionStep, evaluation: EvaluationSlot): MaybePromise<unknown>;
|
|
93
|
+
}
|
|
94
|
+
/** One field's transition config from an entity type and its base types, with accessors converted to codes. */
|
|
95
|
+
export interface FieldTransitions {
|
|
96
|
+
/** Each table maps a `from` code to its allowed `to` codes; every table must allow a change. */
|
|
97
|
+
tables: ReadonlyMap<unknown, readonly unknown[]>[];
|
|
98
|
+
guards: TransitionGuard[];
|
|
99
|
+
callbacks: TransitionCallback[];
|
|
100
|
+
}
|
|
101
|
+
/** Converts an internal step to the `Transition` that guards and reactions receive. */
|
|
102
|
+
export declare function toTransition(step: TransitionStep): Transition<any>;
|
|
103
|
+
/**
|
|
104
|
+
* Merges the transition config of `meta` and its base types by field, converting accessors to codes.
|
|
105
|
+
*
|
|
106
|
+
* This runs after boot, because the config is written before the enum metadata exists.
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildFieldTransitions(meta: EntityMetadata): Map<string, FieldTransitions>;
|
|
109
|
+
/** Returns whether `step` matches `matcher`'s `from`, `to`, and `onCreate` settings. */
|
|
110
|
+
export declare function matchesTransition(matcher: TransitionMatcher, step: TransitionStep): boolean;
|
|
111
|
+
/** Uses the enum's display name in error messages when there is one, i.e. `Approved` instead of `APPROVED`. */
|
|
112
|
+
export declare function describeValue(meta: EntityMetadata, fieldName: string, value: unknown): string;
|
|
113
|
+
//# sourceMappingURL=transitions.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitions.d.mts","names":[],"sources":["../src/transitions.ts"],"mappings":";;;;;;;;;;iBAWiB,qBAAqB;EACpC,OAAO,aAAa;EACpB,KAAK,aAAa;;;;;;;iBAQH,kBAAkB,WAAW,qBAAqB;;;;;;;EAOjE;;EAEA;;;YAIU,gBAAgB,UAAU,eAAe,QAAQ,OAAO,YAAY;;;;;;;iBAQ/D,WAAW;EAC1B,MAAM;EACN,IAAI;;;qBAIO;;iBAGI;EACf;EACA;;;iBAIe,sBAAsB,UAAU,SAAS;EACxD,OAAO;EACP,IAAI,QAAQ,GAAG,MAAM,iBAAiB,aAAa;;;;;;;iBAQpC,yBAAyB,UAAU,SAAS,QAAQ;EACnE;EACA,OAAO;EACP,IAAI,QAAQ,GAAG,KAAK,GAAG,MAAM,gBAAgB,YAAY,iBAAiB;;;iBAI3D,uBAAuB,UAAU,SAAS,QAAQ;;EAEjE,QAAQ;EACR,QAAQ,sBAAsB;EAC9B,WAAW,yBAAyB,GAAG;;;iBAIxB;;EAEf;;EAEA;;EAEA;;;iBAIe;EACf,SAAS;EACT,IAAI,QAAQ,QAAQ,MAAM,iBAAiB,aAAa;;;iBAIzC;EACf;EACA;EACA,SAAS;EACT,YAAY;EACZ,IAAI,QAAQ,QAAQ,cAAc,MAAM,gBAAgB,YAAY,iBAAiB;;;iBAItE;;EAEf,QAAQ;EACR,QAAQ;EACR,WAAW;;;wBAIG,aAAa,MAAM,iBAAiB;;;;;;wBASpC,sBAAsB,MAAM,iBAAiB,YAAY;;wBA0BzD,kBAAkB,SAAS,mBAAmB,MAAM;;wBAUpD,cAAc,MAAM,gBAAgB,mBAAmB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { getBaseAndSelfMetas } from "./EntityMetadata.js";
|
|
2
|
+
import { EvaluationSlot } from "./metrics/EntityMetrics.js";
|
|
3
|
+
import { fail } from "./utils.js";
|
|
4
|
+
// src/transitions.ts
|
|
5
|
+
/** The "from" state of a just-created entity, because `undefined` can be a real field value. */
|
|
6
|
+
const created = Symbol("created");
|
|
7
|
+
/** Converts an internal step to the `Transition` that guards and reactions receive. */
|
|
8
|
+
function toTransition(step) {
|
|
9
|
+
return {
|
|
10
|
+
from: step.from === created ? void 0 : step.from,
|
|
11
|
+
to: step.to
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Merges the transition config of `meta` and its base types by field, converting accessors to codes.
|
|
16
|
+
*
|
|
17
|
+
* This runs after boot, because the config is written before the enum metadata exists.
|
|
18
|
+
*/
|
|
19
|
+
function buildFieldTransitions(meta) {
|
|
20
|
+
const byField = /* @__PURE__ */ new Map();
|
|
21
|
+
for (const m of getBaseAndSelfMetas(meta)) for (const [fieldName, config] of Object.entries(m.config.__data.transitions)) {
|
|
22
|
+
let merged = byField.get(fieldName);
|
|
23
|
+
if (!merged) byField.set(fieldName, merged = {
|
|
24
|
+
tables: [],
|
|
25
|
+
guards: [],
|
|
26
|
+
callbacks: []
|
|
27
|
+
});
|
|
28
|
+
if (config.table) merged.tables.push(toCodesTable(meta, fieldName, config.table));
|
|
29
|
+
for (const { match, run } of config.guards) merged.guards.push({
|
|
30
|
+
matcher: toMatcher(meta, fieldName, match),
|
|
31
|
+
run
|
|
32
|
+
});
|
|
33
|
+
for (const { name, match, run } of config.callbacks) {
|
|
34
|
+
const matcher = toMatcher(meta, fieldName, match);
|
|
35
|
+
merged.callbacks.push({
|
|
36
|
+
name,
|
|
37
|
+
phase: match.phase ?? "flush",
|
|
38
|
+
matcher,
|
|
39
|
+
evaluation: new EvaluationSlot(`${meta.type}.${name}`),
|
|
40
|
+
run
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return byField;
|
|
45
|
+
}
|
|
46
|
+
/** Returns whether `step` matches `matcher`'s `from`, `to`, and `onCreate` settings. */
|
|
47
|
+
function matchesTransition(matcher, step) {
|
|
48
|
+
if (step.from === created) {
|
|
49
|
+
if (!matcher.onCreate) return false;
|
|
50
|
+
} else if (matcher.from && !matcher.from.includes(step.from)) return false;
|
|
51
|
+
return !matcher.to || matcher.to.includes(step.to);
|
|
52
|
+
}
|
|
53
|
+
/** Uses the enum's display name in error messages when there is one, i.e. `Approved` instead of `APPROVED`. */
|
|
54
|
+
function describeValue(meta, fieldName, value) {
|
|
55
|
+
if (value === void 0) return "unset";
|
|
56
|
+
const field = meta.allFields[fieldName];
|
|
57
|
+
return field?.kind === "enum" ? field.enumDetailType.getByCode(value)?.name ?? String(value) : String(value);
|
|
58
|
+
}
|
|
59
|
+
/** Converts a `transitions` table's keys and values to codes, so it can be compared to field values. */
|
|
60
|
+
function toCodesTable(meta, fieldName, table) {
|
|
61
|
+
return new Map(Object.entries(table).map(([from, tos]) => [accessorToCode(meta, fieldName, from), toCodes(meta, fieldName, tos ?? [])]));
|
|
62
|
+
}
|
|
63
|
+
/** Converts a `match`'s accessors to codes. */
|
|
64
|
+
function toMatcher(meta, fieldName, match) {
|
|
65
|
+
return {
|
|
66
|
+
from: toCodes(meta, fieldName, match.from),
|
|
67
|
+
to: toCodes(meta, fieldName, match.to),
|
|
68
|
+
onCreate: match.onCreate !== false && match.from === void 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Converts an enum accessor, i.e. `Rejected`, to its code, i.e. `REJECTED`, and fails on anything else. */
|
|
72
|
+
function accessorToCode(meta, fieldName, value) {
|
|
73
|
+
const field = meta.allFields[fieldName];
|
|
74
|
+
if (field?.kind !== "enum") fail(`${meta.type}.${fieldName} is not an enum field, so it can't have transitions`);
|
|
75
|
+
if (typeof value !== "string" || !Object.hasOwn(field.enumType, value)) fail(`Unknown ${meta.type}.${fieldName} accessor ${String(value)}, i.e. use "Draft" for AuthorStatus.Draft`);
|
|
76
|
+
return field.enumType[value];
|
|
77
|
+
}
|
|
78
|
+
/** Converts one or more enum accessors to an array of codes, preserving an omitted match. */
|
|
79
|
+
function toCodes(meta, fieldName, values) {
|
|
80
|
+
if (values === void 0) return void 0;
|
|
81
|
+
return typeof values === "string" ? [accessorToCode(meta, fieldName, values)] : values.map((v) => accessorToCode(meta, fieldName, v));
|
|
82
|
+
}
|
|
83
|
+
export { buildFieldTransitions, created, describeValue, matchesTransition, toTransition };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=transitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitions.js","names":[],"sources":["../src/transitions.ts"],"sourcesContent":["import type { Entity } from \"src/Entity.ts\";\nimport { type EntityMetadata, getBaseAndSelfMetas } from \"src/EntityMetadata.ts\";\nimport { EvaluationSlot } from \"src/metrics/EntityMetrics.ts\";\nimport type { ValidationRuleResult } from \"src/rules.ts\";\nimport { type MaybePromise, fail } from \"src/utils.ts\";\n\n/**\n * Which state transitions of an enum field an `addTransitionRule` cares about.\n *\n * Omitting `from` or `to` matches any state. Guards never run on creation.\n */\nexport interface GuardTransitionMatch<V> {\n from?: V | readonly V[];\n to?: V | readonly V[];\n}\n\n/**\n * Which state transitions of an enum field an `addTransitionReaction` callback handles.\n *\n * Creating an entity with a matching `to` state also matches, unless `from` is set or `onCreate` is `false`.\n */\nexport interface OnTransitionMatch<V> extends GuardTransitionMatch<V> {\n /**\n * Whether `addTransitionReaction` fires when an entity is created with a matching `to` state, defaults to `true`.\n *\n * Entering a state by creation usually needs the same side effects as entering it by a transition, and\n * forgetting them is easy to miss. Set `false` for reactions that only make sense for a transition.\n */\n onCreate?: boolean;\n /** `commit` runs in `beforeCommit`, i.e. to enqueue jobs; `flush` (the default) runs as a reaction. */\n phase?: \"flush\" | \"commit\";\n}\n\n/** Maps each state to the states it may transition to, i.e. `{ Draft: [\"Open\"], Open: [\"Closed\"] }`. */\nexport type TransitionTable<V extends PropertyKey> = Partial<Record<V, readonly V[]>>;\n\n/**\n * The transition a guard or reaction is handling, i.e. `{ from: \"DRAFT\", to: \"OPEN\" }`.\n *\n * Guards and callbacks run during reaction passes, after the assignment, so the entity may already be in a\n * later state. This tells them which transition they're handling. `from` is `undefined` for creation.\n */\nexport interface Transition<V> {\n from: V | undefined;\n to: V;\n}\n\n/** The \"from\" state of a just-created entity, because `undefined` can be a real field value. */\nexport const created: unique symbol = Symbol(\"created\");\n\n/** A single recorded transition of a field, with `from` as `created` for creation. */\nexport interface TransitionStep {\n from: unknown;\n to: unknown;\n}\n\n/** An `addTransitionRule` as registered in config, with its `match` still using accessors. */\nexport interface TransitionGuardConfig<T extends Entity = Entity> {\n match: GuardTransitionMatch<string>;\n run(entity: T, step: TransitionStep): MaybePromise<ValidationRuleResult>;\n}\n\n/**\n * An `addTransitionReaction` as registered in config, with its `match` still using accessors.\n *\n * @internal Joist invokes `run`; the application callback does not receive the metrics slot.\n */\nexport interface TransitionCallbackConfig<T extends Entity = Entity, C = unknown> {\n name: string;\n match: OnTransitionMatch<string>;\n run(entity: T, ctx: C, step: TransitionStep, evaluation: EvaluationSlot): MaybePromise<unknown>;\n}\n\n/** One field's `setTransitions`, `addTransitionRule`, and `addTransitionReaction` config on a single entity type. */\nexport interface FieldTransitionsConfig<T extends Entity = Entity, C = unknown> {\n /** The `transitions` table, if any; subtypes add their own tables on their own configs. */\n table?: TransitionTable<string>;\n guards: TransitionGuardConfig<T>[];\n callbacks: TransitionCallbackConfig<T, C>[];\n}\n\n/** A `match` with accessors converted to codes, so it can be compared to recorded steps. */\nexport interface TransitionMatcher {\n /** The allowed previous states, or `undefined` for any state. */\n from: readonly unknown[] | undefined;\n /** The allowed new states, or `undefined` for any state. */\n to: readonly unknown[] | undefined;\n /** Whether creation matches, which is never true when `from` is set. */\n onCreate: boolean;\n}\n\n/** A guard with its `match` converted to codes. */\nexport interface TransitionGuard {\n matcher: TransitionMatcher;\n run(entity: Entity, step: TransitionStep): MaybePromise<ValidationRuleResult>;\n}\n\n/** A callback with its `match` converted to codes, dispatched only after its transition's guards pass. */\nexport interface TransitionCallback {\n name: string;\n phase: \"flush\" | \"commit\";\n matcher: TransitionMatcher;\n evaluation: EvaluationSlot;\n run(entity: Entity, ctx: unknown, step: TransitionStep, evaluation: EvaluationSlot): MaybePromise<unknown>;\n}\n\n/** One field's transition config from an entity type and its base types, with accessors converted to codes. */\nexport interface FieldTransitions {\n /** Each table maps a `from` code to its allowed `to` codes; every table must allow a change. */\n tables: ReadonlyMap<unknown, readonly unknown[]>[];\n guards: TransitionGuard[];\n callbacks: TransitionCallback[];\n}\n\n/** Converts an internal step to the `Transition` that guards and reactions receive. */\nexport function toTransition(step: TransitionStep): Transition<any> {\n return { from: step.from === created ? undefined : step.from, to: step.to };\n}\n\n/**\n * Merges the transition config of `meta` and its base types by field, converting accessors to codes.\n *\n * This runs after boot, because the config is written before the enum metadata exists.\n */\nexport function buildFieldTransitions(meta: EntityMetadata): Map<string, FieldTransitions> {\n const byField = new Map<string, FieldTransitions>();\n for (const m of getBaseAndSelfMetas(meta)) {\n for (const [fieldName, config] of Object.entries(m.config.__data.transitions)) {\n let merged = byField.get(fieldName);\n if (!merged) byField.set(fieldName, (merged = { tables: [], guards: [], callbacks: [] }));\n if (config.table) merged.tables.push(toCodesTable(meta, fieldName, config.table));\n for (const { match, run } of config.guards) {\n merged.guards.push({ matcher: toMatcher(meta, fieldName, match), run });\n }\n for (const { name, match, run } of config.callbacks) {\n const matcher = toMatcher(meta, fieldName, match);\n merged.callbacks.push({\n name,\n phase: match.phase ?? \"flush\",\n matcher,\n evaluation: new EvaluationSlot(`${meta.type}.${name}`),\n run,\n });\n }\n }\n }\n return byField;\n}\n\n/** Returns whether `step` matches `matcher`'s `from`, `to`, and `onCreate` settings. */\nexport function matchesTransition(matcher: TransitionMatcher, step: TransitionStep): boolean {\n if (step.from === created) {\n if (!matcher.onCreate) return false;\n } else if (matcher.from && !matcher.from.includes(step.from)) {\n return false;\n }\n return !matcher.to || matcher.to.includes(step.to);\n}\n\n/** Uses the enum's display name in error messages when there is one, i.e. `Approved` instead of `APPROVED`. */\nexport function describeValue(meta: EntityMetadata, fieldName: string, value: unknown): string {\n if (value === undefined) return \"unset\";\n const field = meta.allFields[fieldName];\n return field?.kind === \"enum\" ? (field.enumDetailType.getByCode(value)?.name ?? String(value)) : String(value);\n}\n\n/** Converts a `transitions` table's keys and values to codes, so it can be compared to field values. */\nfunction toCodesTable(\n meta: EntityMetadata,\n fieldName: string,\n table: TransitionTable<string>,\n): Map<unknown, readonly unknown[]> {\n return new Map(\n Object.entries(table).map(([from, tos]) => [\n accessorToCode(meta, fieldName, from),\n toCodes(meta, fieldName, tos ?? [])!,\n ]),\n );\n}\n\n/** Converts a `match`'s accessors to codes. */\nfunction toMatcher(meta: EntityMetadata, fieldName: string, match: OnTransitionMatch<string>): TransitionMatcher {\n return {\n from: toCodes(meta, fieldName, match.from),\n to: toCodes(meta, fieldName, match.to),\n // `from` describes a previous state, which a new entity doesn't have\n onCreate: match.onCreate !== false && match.from === undefined,\n };\n}\n\n/** Converts an enum accessor, i.e. `Rejected`, to its code, i.e. `REJECTED`, and fails on anything else. */\nfunction accessorToCode(meta: EntityMetadata, fieldName: string, value: unknown): unknown {\n const field = meta.allFields[fieldName];\n if (field?.kind !== \"enum\") fail(`${meta.type}.${fieldName} is not an enum field, so it can't have transitions`);\n // Only accessors are accepted, even from untyped callers, so every table reads the same way\n if (typeof value !== \"string\" || !Object.hasOwn(field.enumType, value)) {\n fail(`Unknown ${meta.type}.${fieldName} accessor ${String(value)}, i.e. use \"Draft\" for AuthorStatus.Draft`);\n }\n return field.enumType[value];\n}\n\n/** Converts one or more enum accessors to an array of codes, preserving an omitted match. */\nfunction toCodes(\n meta: EntityMetadata,\n fieldName: string,\n values: string | readonly string[] | undefined,\n): unknown[] | undefined {\n if (values === undefined) return undefined;\n return typeof values === \"string\"\n ? [accessorToCode(meta, fieldName, values)]\n : values.map((v) => accessorToCode(meta, fieldName, v));\n}\n"],"mappings":";;;;;AAgDA,MAAa,UAAyB,OAAO,SAAS;;AAmEtD,SAAgB,aAAa,MAAuC;CAClE,OAAO;EAAE,MAAM,KAAK,SAAS,UAAU,KAAA,IAAY,KAAK;EAAM,IAAI,KAAK;CAAG;AAC5E;;;;;;AAOA,SAAgB,sBAAsB,MAAqD;CACzF,MAAM,0BAAU,IAAI,IAA8B;CAClD,KAAK,MAAM,KAAK,oBAAoB,IAAI,GACtC,KAAK,MAAM,CAAC,WAAW,WAAW,OAAO,QAAQ,EAAE,OAAO,OAAO,WAAW,GAAG;EAC7E,IAAI,SAAS,QAAQ,IAAI,SAAS;EAClC,IAAI,CAAC,QAAQ,QAAQ,IAAI,WAAY,SAAS;GAAE,QAAQ,CAAC;GAAG,QAAQ,CAAC;GAAG,WAAW,CAAC;EAAE,CAAE;EACxF,IAAI,OAAO,OAAO,OAAO,OAAO,KAAK,aAAa,MAAM,WAAW,OAAO,KAAK,CAAC;EAChF,KAAK,MAAM,EAAE,OAAO,SAAS,OAAO,QAClC,OAAO,OAAO,KAAK;GAAE,SAAS,UAAU,MAAM,WAAW,KAAK;GAAG;EAAI,CAAC;EAExE,KAAK,MAAM,EAAE,MAAM,OAAO,SAAS,OAAO,WAAW;GACnD,MAAM,UAAU,UAAU,MAAM,WAAW,KAAK;GAChD,OAAO,UAAU,KAAK;IACpB;IACA,OAAO,MAAM,SAAS;IACtB;IACA,YAAY,IAAI,eAAe,GAAG,KAAK,KAAK,GAAG,MAAM;IACrD;GACF,CAAC;EACH;CACF;CAEF,OAAO;AACT;;AAGA,SAAgB,kBAAkB,SAA4B,MAA+B;CAC3F,IAAI,KAAK,SAAS,SACZ;MAAA,CAAC,QAAQ,UAAU,OAAO;CAAA,OACzB,IAAI,QAAQ,QAAQ,CAAC,QAAQ,KAAK,SAAS,KAAK,IAAI,GACzD,OAAO;CAET,OAAO,CAAC,QAAQ,MAAM,QAAQ,GAAG,SAAS,KAAK,EAAE;AACnD;;AAGA,SAAgB,cAAc,MAAsB,WAAmB,OAAwB;CAC7F,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAQ,KAAK,UAAU;CAC7B,OAAO,OAAO,SAAS,SAAU,MAAM,eAAe,UAAU,KAAK,CAAC,EAAE,QAAQ,OAAO,KAAK,IAAK,OAAO,KAAK;AAC/G;;AAGA,SAAS,aACP,MACA,WACA,OACkC;CAClC,OAAO,IAAI,IACT,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,SAAS,CACzC,eAAe,MAAM,WAAW,IAAI,GACpC,QAAQ,MAAM,WAAW,OAAO,CAAC,CAAC,CACpC,CAAC,CACH;AACF;;AAGA,SAAS,UAAU,MAAsB,WAAmB,OAAqD;CAC/G,OAAO;EACL,MAAM,QAAQ,MAAM,WAAW,MAAM,IAAI;EACzC,IAAI,QAAQ,MAAM,WAAW,MAAM,EAAE;EAErC,UAAU,MAAM,aAAa,SAAS,MAAM,SAAS,KAAA;CACvD;AACF;;AAGA,SAAS,eAAe,MAAsB,WAAmB,OAAyB;CACxF,MAAM,QAAQ,KAAK,UAAU;CAC7B,IAAI,OAAO,SAAS,QAAQ,KAAK,GAAG,KAAK,KAAK,GAAG,UAAU,oDAAoD;CAE/G,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,OAAO,MAAM,UAAU,KAAK,GACnE,KAAK,WAAW,KAAK,KAAK,GAAG,UAAU,YAAY,OAAO,KAAK,EAAE,0CAA0C;CAE7G,OAAO,MAAM,SAAS;AACxB;;AAGA,SAAS,QACP,MACA,WACA,QACuB;CACvB,IAAI,WAAW,KAAA,GAAW,OAAO,KAAA;CACjC,OAAO,OAAO,WAAW,WACrB,CAAC,eAAe,MAAM,WAAW,MAAM,CAAC,IACxC,OAAO,KAAK,MAAM,eAAe,MAAM,WAAW,CAAC,CAAC;AAC1D"}
|
package/build/trusted.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// src/trusted.ts
|
|
3
3
|
const trustedContext = new (require("async_hooks")).AsyncLocalStorage();
|
|
4
4
|
/** Returns true if we're inside a trusted context, i.e. hooks, reactions, validations, or defaults. */
|
|
5
5
|
function isInTrustedContext() {
|
|
@@ -9,7 +9,6 @@ function isInTrustedContext() {
|
|
|
9
9
|
function runInTrustedContext(fn) {
|
|
10
10
|
return trustedContext.run(true, fn);
|
|
11
11
|
}
|
|
12
|
-
//#endregion
|
|
13
12
|
exports.isInTrustedContext = isInTrustedContext;
|
|
14
13
|
exports.runInTrustedContext = runInTrustedContext;
|
|
15
14
|
|
package/build/trusted.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trusted.cjs","names":["AsyncLocalStorage"],"sources":["../src/trusted.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"async_hooks\";\n\nconst trustedContext = new AsyncLocalStorage<boolean>();\n\n/** Returns true if we're inside a trusted context, i.e. hooks, reactions, validations, or defaults. */\nexport function isInTrustedContext(): boolean {\n return trustedContext.getStore() === true;\n}\n\n/** Runs the given function within a trusted context. */\nexport function runInTrustedContext<T>(fn: () => T): T {\n return trustedContext.run(true, fn);\n}\n"],"mappings":";;AAEA,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"trusted.cjs","names":["AsyncLocalStorage"],"sources":["../src/trusted.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"async_hooks\";\n\nconst trustedContext = new AsyncLocalStorage<boolean>();\n\n/** Returns true if we're inside a trusted context, i.e. hooks, reactions, validations, or defaults. */\nexport function isInTrustedContext(): boolean {\n return trustedContext.getStore() === true;\n}\n\n/** Runs the given function within a trusted context. */\nexport function runInTrustedContext<T>(fn: () => T): T {\n return trustedContext.run(true, fn);\n}\n"],"mappings":";;AAEA,MAAM,iBAAiB,K,qBAAIA,EAAAA,CAAAA,kBAA2B;;AAGtD,SAAgB,qBAA8B;CAC5C,OAAO,eAAe,SAAS,MAAM;AACvC;;AAGA,SAAgB,oBAAuB,IAAgB;CACrD,OAAO,eAAe,IAAI,MAAM,EAAE;AACpC"}
|
package/build/trusted.d.cts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
//#region src/trusted.d.ts
|
|
2
1
|
/** Returns true if we're inside a trusted context, i.e. hooks, reactions, validations, or defaults. */
|
|
3
|
-
declare function isInTrustedContext(): boolean;
|
|
2
|
+
export declare function isInTrustedContext(): boolean;
|
|
4
3
|
/** Runs the given function within a trusted context. */
|
|
5
|
-
declare function runInTrustedContext<T>(fn: () => T): T;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { isInTrustedContext, runInTrustedContext };
|
|
4
|
+
export declare function runInTrustedContext<T>(fn: () => T): T;
|
|
8
5
|
//# sourceMappingURL=trusted.d.cts.map
|
package/build/trusted.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trusted.d.cts","names":[],"sources":["../src/trusted.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"trusted.d.cts","names":[],"sources":["../src/trusted.ts"],"mappings":";wBAKgB;;wBAKA,oBAAoB,GAAG,UAAU,IAAI"}
|
package/build/trusted.d.mts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
//#region src/trusted.d.ts
|
|
2
1
|
/** Returns true if we're inside a trusted context, i.e. hooks, reactions, validations, or defaults. */
|
|
3
|
-
declare function isInTrustedContext(): boolean;
|
|
2
|
+
export declare function isInTrustedContext(): boolean;
|
|
4
3
|
/** Runs the given function within a trusted context. */
|
|
5
|
-
declare function runInTrustedContext<T>(fn: () => T): T;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { isInTrustedContext, runInTrustedContext };
|
|
4
|
+
export declare function runInTrustedContext<T>(fn: () => T): T;
|
|
8
5
|
//# sourceMappingURL=trusted.d.mts.map
|
package/build/trusted.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trusted.d.mts","names":[],"sources":["../src/trusted.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"trusted.d.mts","names":[],"sources":["../src/trusted.ts"],"mappings":";wBAKgB;;wBAKA,oBAAoB,GAAG,UAAU,IAAI"}
|
package/build/trusted.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "async_hooks";
|
|
2
|
-
|
|
2
|
+
// src/trusted.ts
|
|
3
3
|
const trustedContext = new AsyncLocalStorage();
|
|
4
4
|
/** Returns true if we're inside a trusted context, i.e. hooks, reactions, validations, or defaults. */
|
|
5
5
|
function isInTrustedContext() {
|
|
@@ -9,7 +9,6 @@ function isInTrustedContext() {
|
|
|
9
9
|
function runInTrustedContext(fn) {
|
|
10
10
|
return trustedContext.run(true, fn);
|
|
11
11
|
}
|
|
12
|
-
//#endregion
|
|
13
12
|
export { isInTrustedContext, runInTrustedContext };
|
|
14
13
|
|
|
15
14
|
//# sourceMappingURL=trusted.js.map
|
package/build/typeMap.cjs
CHANGED