joist-core 2.3.0-next.2 → 2.3.0-next.20
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/AliasAssigner.d.ts +0 -1
- package/build/Aliases.d.ts +0 -1
- package/build/BaseEntity.d.ts +0 -1
- package/build/ConditionBuilder.d.ts +0 -1
- package/build/ConditionBuilder.js +1 -1
- package/build/ConditionBuilder.js.map +1 -1
- package/build/Entity.d.ts +0 -1
- package/build/EntityFields.d.ts +0 -1
- package/build/EntityFilter.d.ts +0 -1
- package/build/EntityGraphQLFilter.d.ts +0 -1
- package/build/EntityManager.d.ts +3 -3
- package/build/EntityManager.js +137 -28
- package/build/EntityManager.js.map +1 -1
- package/build/EntityMetadata.d.ts +16 -3
- package/build/EntityMetadata.js +1 -1
- package/build/EntityMetadata.js.map +1 -1
- package/build/EnumMetadata.d.ts +0 -1
- package/build/FlushLock.d.ts +0 -1
- package/build/HintTree.d.ts +0 -1
- package/build/IndexManager.d.ts +0 -1
- package/build/InstanceData.d.ts +0 -1
- package/build/IsLoadedCache.d.ts +0 -1
- package/build/JoinRows.d.ts +0 -1
- package/build/PendingChanges.d.ts +0 -1
- package/build/PluginManager.d.ts +0 -1
- package/build/QueryParser.collectionJoins.d.ts +0 -1
- package/build/QueryParser.d.ts +7 -1
- package/build/QueryParser.js +25 -1
- package/build/QueryParser.js.map +1 -1
- package/build/QueryParser.pruning.d.ts +0 -1
- package/build/QueryVisitor.d.ts +0 -1
- package/build/ReactionsManager.d.ts +1 -2
- package/build/ReactionsManager.js +17 -17
- package/build/ReactionsManager.js.map +1 -1
- package/build/Todo.d.ts +0 -1
- package/build/batchloaders/BatchLoader.d.ts +0 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.ts +0 -1
- package/build/batchloaders/loadBatchLoader.d.ts +0 -1
- package/build/batchloaders/loadBatchLoader.js +1 -1
- package/build/batchloaders/loadBatchLoader.js.map +1 -1
- package/build/batchloaders/manyToManyBatchLoader.d.ts +0 -1
- package/build/batchloaders/oneToManyBatchLoader.d.ts +0 -1
- package/build/batchloaders/oneToOneBatchLoader.d.ts +0 -1
- package/build/batchloaders/populateBatchLoader.d.ts +0 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.ts +0 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.js +3 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.ts +0 -1
- package/build/batchloaders/recursiveM2mBatchLoader.js +1 -1
- package/build/batchloaders/recursiveM2mBatchLoader.js.map +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.ts +0 -1
- package/build/batchloaders/recursiveParentsBatchLoader.js +1 -1
- package/build/batchloaders/recursiveParentsBatchLoader.js.map +1 -1
- package/build/changes.d.ts +0 -1
- package/build/changes.js +4 -1
- package/build/changes.js.map +1 -1
- package/build/config.d.ts +19 -1
- package/build/config.js +36 -23
- package/build/config.js.map +1 -1
- package/build/configure.d.ts +0 -1
- package/build/configure.js +55 -2
- package/build/configure.js.map +1 -1
- package/build/dataloaders/fastWhereFilterHash.d.ts +0 -1
- package/build/dataloaders/findByUniqueDataLoader.d.ts +0 -1
- package/build/dataloaders/findCountDataLoader.d.ts +0 -1
- package/build/dataloaders/findDataLoader.d.ts +0 -1
- package/build/dataloaders/findDataLoader.js +2 -2
- package/build/dataloaders/findDataLoader.js.map +1 -1
- package/build/dataloaders/findIdsDataLoader.d.ts +0 -1
- package/build/dataloaders/findOrCreateDataLoader.d.ts +0 -1
- package/build/dataloaders/findOrCreateDataLoader.js +2 -2
- package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
- package/build/dataloaders/findPaginatedDataLoader.d.ts +0 -1
- package/build/dataloaders/lensDataLoader.d.ts +0 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.ts +0 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.ts +0 -1
- package/build/defaults.d.ts +0 -1
- package/build/driverApi.d.ts +0 -1
- package/build/drivers/Driver.d.ts +0 -1
- package/build/drivers/EntityWriter.d.ts +0 -1
- package/build/drivers/EntityWriter.js +29 -1
- package/build/drivers/EntityWriter.js.map +1 -1
- package/build/drivers/IdAssigner.d.ts +0 -1
- package/build/drivers/buildRawQuery.d.ts +0 -1
- package/build/drivers/buildUtils.d.ts +0 -1
- package/build/drivers/index.d.ts +0 -1
- package/build/fields.d.ts +0 -1
- package/build/fields.js +2 -2
- package/build/fields.js.map +1 -1
- package/build/getProperties.d.ts +3 -4
- package/build/getProperties.js +3 -3
- package/build/getProperties.js.map +1 -1
- package/build/index.d.ts +1 -2
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/json.d.ts +0 -1
- package/build/k.d.ts +0 -1
- package/build/keys.d.ts +7 -7
- package/build/keys.js +102 -46
- package/build/keys.js.map +1 -1
- package/build/keywords.d.ts +0 -1
- package/build/loadHints.d.ts +0 -1
- package/build/loadLens.d.ts +0 -1
- package/build/logging/FactoryLogger.d.ts +0 -1
- package/build/logging/FieldLogger.d.ts +2 -1
- package/build/logging/FieldLogger.js +10 -1
- package/build/logging/FieldLogger.js.map +1 -1
- package/build/logging/ReactionLogger.d.ts +2 -1
- package/build/logging/ReactionLogger.js +15 -1
- package/build/logging/ReactionLogger.js.map +1 -1
- package/build/newEntity.d.ts +2 -3
- package/build/newEntity.js +6 -6
- package/build/newEntity.js.map +1 -1
- package/build/newTestInstance.d.ts +0 -1
- package/build/newTestInstance.js +4 -0
- package/build/newTestInstance.js.map +1 -1
- package/build/normalizeHints.d.ts +0 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.ts +0 -1
- package/build/plugins/PreloadPlugin.d.ts +0 -1
- package/build/preloading/JsonAggregatePreloader.d.ts +0 -1
- package/build/preloading/JsonAggregatePreloader.js +4 -3
- package/build/preloading/JsonAggregatePreloader.js.map +1 -1
- package/build/preloading/canPreload.d.ts +0 -1
- package/build/preloading/partitionHint.d.ts +0 -1
- package/build/reactiveHints.d.ts +0 -1
- package/build/relations/AbstractPropertyImpl.d.ts +0 -1
- package/build/relations/AbstractRelationImpl.d.ts +0 -1
- package/build/relations/AsyncProperty.d.ts +0 -1
- package/build/relations/AsyncReactiveField.d.ts +13 -9
- package/build/relations/AsyncReactiveField.js +22 -19
- package/build/relations/AsyncReactiveField.js.map +1 -1
- package/build/relations/Collection.d.ts +0 -1
- package/build/relations/CustomCollection.d.ts +0 -1
- package/build/relations/CustomReference.d.ts +0 -1
- package/build/relations/EnumCollection.d.ts +0 -1
- package/build/relations/LargeCollection.d.ts +0 -1
- package/build/relations/LazyField.d.ts +46 -0
- package/build/relations/LazyField.js +133 -0
- package/build/relations/LazyField.js.map +1 -0
- package/build/relations/ManyToManyCollection.d.ts +0 -1
- package/build/relations/ManyToManyCollection.js +5 -3
- package/build/relations/ManyToManyCollection.js.map +1 -1
- package/build/relations/ManyToManyLargeCollection.d.ts +0 -1
- package/build/relations/ManyToOneReference.d.ts +0 -1
- package/build/relations/OneToManyCollection.d.ts +0 -1
- package/build/relations/OneToManyCollection.js +3 -1
- package/build/relations/OneToManyCollection.js.map +1 -1
- package/build/relations/OneToManyLargeCollection.d.ts +0 -1
- package/build/relations/OneToOneReference.d.ts +0 -1
- package/build/relations/OneToOneReference.js +1 -1
- package/build/relations/OneToOneReference.js.map +1 -1
- package/build/relations/PolymorphicReference.d.ts +0 -1
- package/build/relations/ReactiveField.d.ts +0 -1
- package/build/relations/ReactiveGetter.d.ts +0 -1
- package/build/relations/ReactiveManyToMany.d.ts +0 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.ts +0 -1
- package/build/relations/ReactiveReference.d.ts +0 -1
- package/build/relations/ReadOnlyCollection.d.ts +0 -1
- package/build/relations/RecursiveCollection.d.ts +0 -1
- package/build/relations/RecursiveCycleError.d.ts +0 -1
- package/build/relations/Reference.d.ts +0 -1
- package/build/relations/Relation.d.ts +0 -1
- package/build/relations/hasAsyncMethod.d.ts +0 -1
- package/build/relations/hasManyDerived.d.ts +0 -1
- package/build/relations/hasManyThrough.d.ts +0 -1
- package/build/relations/hasOneDerived.d.ts +0 -1
- package/build/relations/hasOneThrough.d.ts +0 -1
- package/build/relations/hasProperty.d.ts +0 -1
- package/build/relations/index.d.ts +1 -1
- package/build/relations/index.js +7 -2
- package/build/relations/index.js.map +1 -1
- package/build/resurrection.d.ts +0 -1
- package/build/rules.d.ts +8 -1
- package/build/rules.js +17 -0
- package/build/rules.js.map +1 -1
- package/build/runtimeConfig.d.ts +4 -1
- package/build/runtimeConfig.js +5 -0
- package/build/runtimeConfig.js.map +1 -1
- package/build/scopes.d.ts +0 -1
- package/build/serde.d.ts +0 -1
- package/build/serde.js +9 -7
- package/build/serde.js.map +1 -1
- package/build/temporal.d.ts +0 -1
- package/build/temporalMappers.d.ts +0 -1
- package/build/trusted.d.ts +0 -1
- package/build/typeMap.d.ts +0 -1
- package/build/unnest.d.ts +0 -1
- package/build/upsert.d.ts +0 -1
- package/build/utils.d.ts +0 -1
- package/build/withLoaded.d.ts +0 -1
- package/package.json +2 -2
- package/build/AliasAssigner.d.ts.map +0 -1
- package/build/Aliases.d.ts.map +0 -1
- package/build/BaseEntity.d.ts.map +0 -1
- package/build/ConditionBuilder.d.ts.map +0 -1
- package/build/Entity.d.ts.map +0 -1
- package/build/EntityFields.d.ts.map +0 -1
- package/build/EntityFilter.d.ts.map +0 -1
- package/build/EntityGraphQLFilter.d.ts.map +0 -1
- package/build/EntityManager.d.ts.map +0 -1
- package/build/EntityMetadata.d.ts.map +0 -1
- package/build/EnumMetadata.d.ts.map +0 -1
- package/build/FlushLock.d.ts.map +0 -1
- package/build/HintTree.d.ts.map +0 -1
- package/build/IndexManager.d.ts.map +0 -1
- package/build/InstanceData.d.ts.map +0 -1
- package/build/IsLoadedCache.d.ts.map +0 -1
- package/build/JoinRows.d.ts.map +0 -1
- package/build/PendingChanges.d.ts.map +0 -1
- package/build/PluginManager.d.ts.map +0 -1
- package/build/QueryParser.collectionJoins.d.ts.map +0 -1
- package/build/QueryParser.collectionJoins.test.d.ts +0 -2
- package/build/QueryParser.collectionJoins.test.d.ts.map +0 -1
- package/build/QueryParser.collectionJoins.test.js +0 -772
- package/build/QueryParser.collectionJoins.test.js.map +0 -1
- package/build/QueryParser.d.ts.map +0 -1
- package/build/QueryParser.pruning.d.ts.map +0 -1
- package/build/QueryParser.pruning.test.d.ts +0 -2
- package/build/QueryParser.pruning.test.d.ts.map +0 -1
- package/build/QueryParser.pruning.test.js +0 -106
- package/build/QueryParser.pruning.test.js.map +0 -1
- package/build/QueryParser.test.d.ts +0 -2
- package/build/QueryParser.test.d.ts.map +0 -1
- package/build/QueryParser.test.js +0 -27
- package/build/QueryParser.test.js.map +0 -1
- package/build/QueryVisitor.d.ts.map +0 -1
- package/build/ReactionsManager.d.ts.map +0 -1
- package/build/Todo.d.ts.map +0 -1
- package/build/batchloaders/BatchLoader.d.ts.map +0 -1
- package/build/batchloaders/enumCollectionBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/loadBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/manyToManyBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/oneToManyBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/oneToOneBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/populateBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/recursiveChildrenBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/recursiveM2mBatchLoader.d.ts.map +0 -1
- package/build/batchloaders/recursiveParentsBatchLoader.d.ts.map +0 -1
- package/build/changes.d.ts.map +0 -1
- package/build/config.d.ts.map +0 -1
- package/build/config.test.d.ts +0 -2
- package/build/config.test.d.ts.map +0 -1
- package/build/config.test.js +0 -53
- package/build/config.test.js.map +0 -1
- package/build/configure.d.ts.map +0 -1
- package/build/dataloaders/fastWhereFilterHash.d.ts.map +0 -1
- package/build/dataloaders/fastWhereFilterHash.test.d.ts +0 -2
- package/build/dataloaders/fastWhereFilterHash.test.d.ts.map +0 -1
- package/build/dataloaders/fastWhereFilterHash.test.js +0 -59
- package/build/dataloaders/fastWhereFilterHash.test.js.map +0 -1
- package/build/dataloaders/findByUniqueDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findCountDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findIdsDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findOrCreateDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findPaginatedDataLoader.d.ts.map +0 -1
- package/build/dataloaders/lensDataLoader.d.ts.map +0 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.ts.map +0 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.ts.map +0 -1
- package/build/defaults.d.ts.map +0 -1
- package/build/driverApi.d.ts.map +0 -1
- package/build/drivers/Driver.d.ts.map +0 -1
- package/build/drivers/EntityWriter.d.ts.map +0 -1
- package/build/drivers/IdAssigner.d.ts.map +0 -1
- package/build/drivers/buildRawQuery.d.ts.map +0 -1
- package/build/drivers/buildUtils.d.ts.map +0 -1
- package/build/drivers/index.d.ts.map +0 -1
- package/build/fields.d.ts.map +0 -1
- package/build/getProperties.d.ts.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/json.d.ts.map +0 -1
- package/build/k.d.ts.map +0 -1
- package/build/keys.d.ts.map +0 -1
- package/build/keywords.d.ts.map +0 -1
- package/build/loadHints.d.ts.map +0 -1
- package/build/loadLens.d.ts.map +0 -1
- package/build/logging/FactoryLogger.d.ts.map +0 -1
- package/build/logging/FieldLogger.d.ts.map +0 -1
- package/build/logging/ReactionLogger.d.ts.map +0 -1
- package/build/newEntity.d.ts.map +0 -1
- package/build/newTestInstance.d.ts.map +0 -1
- package/build/normalizeHints.d.ts.map +0 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.ts.map +0 -1
- package/build/plugins/PreloadPlugin.d.ts.map +0 -1
- package/build/preloading/JsonAggregatePreloader.d.ts.map +0 -1
- package/build/preloading/canPreload.d.ts.map +0 -1
- package/build/preloading/partitionHint.d.ts.map +0 -1
- package/build/reactiveHints.d.ts.map +0 -1
- package/build/relations/AbstractPropertyImpl.d.ts.map +0 -1
- package/build/relations/AbstractRelationImpl.d.ts.map +0 -1
- package/build/relations/AsyncProperty.d.ts.map +0 -1
- package/build/relations/AsyncReactiveField.d.ts.map +0 -1
- package/build/relations/Collection.d.ts.map +0 -1
- package/build/relations/CustomCollection.d.ts.map +0 -1
- package/build/relations/CustomReference.d.ts.map +0 -1
- package/build/relations/EnumCollection.d.ts.map +0 -1
- package/build/relations/LargeCollection.d.ts.map +0 -1
- package/build/relations/ManyToManyCollection.d.ts.map +0 -1
- package/build/relations/ManyToManyLargeCollection.d.ts.map +0 -1
- package/build/relations/ManyToOneReference.d.ts.map +0 -1
- package/build/relations/OneToManyCollection.d.ts.map +0 -1
- package/build/relations/OneToManyLargeCollection.d.ts.map +0 -1
- package/build/relations/OneToOneReference.d.ts.map +0 -1
- package/build/relations/PolymorphicReference.d.ts.map +0 -1
- package/build/relations/ReactiveField.d.ts.map +0 -1
- package/build/relations/ReactiveGetter.d.ts.map +0 -1
- package/build/relations/ReactiveManyToMany.d.ts.map +0 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.ts.map +0 -1
- package/build/relations/ReactiveReference.d.ts.map +0 -1
- package/build/relations/ReadOnlyCollection.d.ts.map +0 -1
- package/build/relations/RecursiveCollection.d.ts.map +0 -1
- package/build/relations/RecursiveCycleError.d.ts.map +0 -1
- package/build/relations/Reference.d.ts.map +0 -1
- package/build/relations/Relation.d.ts.map +0 -1
- package/build/relations/hasAsyncMethod.d.ts.map +0 -1
- package/build/relations/hasManyDerived.d.ts.map +0 -1
- package/build/relations/hasManyThrough.d.ts.map +0 -1
- package/build/relations/hasOneDerived.d.ts.map +0 -1
- package/build/relations/hasOneThrough.d.ts.map +0 -1
- package/build/relations/hasProperty.d.ts.map +0 -1
- package/build/relations/index.d.ts.map +0 -1
- package/build/resurrection.d.ts.map +0 -1
- package/build/rules.d.ts.map +0 -1
- package/build/runtimeConfig.d.ts.map +0 -1
- package/build/scopes.d.ts.map +0 -1
- package/build/serde.d.ts.map +0 -1
- package/build/temporal.d.ts.map +0 -1
- package/build/temporalMappers.d.ts.map +0 -1
- package/build/trusted.d.ts.map +0 -1
- package/build/typeMap.d.ts.map +0 -1
- package/build/unnest.d.ts.map +0 -1
- package/build/upsert.d.ts.map +0 -1
- package/build/utils.d.ts.map +0 -1
- package/build/withLoaded.d.ts.map +0 -1
package/build/AliasAssigner.d.ts
CHANGED
package/build/Aliases.d.ts
CHANGED
package/build/BaseEntity.d.ts
CHANGED
|
@@ -65,4 +65,3 @@ export declare abstract class BaseEntity<EM extends EntityManager, I extends IdT
|
|
|
65
65
|
* on its `Object.create`-d instances.
|
|
66
66
|
*/
|
|
67
67
|
export declare function baseEntityCstr(em: EntityManager, entity: BaseEntity<any, any>, isNew: boolean): void;
|
|
68
|
-
//# sourceMappingURL=BaseEntity.d.ts.map
|
|
@@ -100,7 +100,7 @@ function parseExpression(expression) {
|
|
|
100
100
|
? ["and", expression.and]
|
|
101
101
|
: "or" in expression && expression.or
|
|
102
102
|
? ["or", expression.or]
|
|
103
|
-
: fail(`Invalid expression ${expression}`);
|
|
103
|
+
: (0, utils_1.fail)(`Invalid expression ${expression}`);
|
|
104
104
|
// Potentially recurse into nested expressions
|
|
105
105
|
const conditions = expressions.map((exp) => (exp && ("and" in exp || "or" in exp) ? parseExpression(exp) : exp));
|
|
106
106
|
const [skip, valid] = (0, utils_1.partition)(conditions, (cond) => cond === undefined || cond === QueryParser_1.skipCondition);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConditionBuilder.js","sourceRoot":"","sources":["../src/ConditionBuilder.ts"],"names":[],"mappings":";;;AACA,mDAA4C;AAC5C,+CAQuB;AAEvB,
|
|
1
|
+
{"version":3,"file":"ConditionBuilder.js","sourceRoot":"","sources":["../src/ConditionBuilder.ts"],"names":[],"mappings":";;;AACA,mDAA4C;AAC5C,+CA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C,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,2BAAa,CAAC,CAAC;IACpG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrF,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,yBAAS,CAAC,EAAE,CAAC;AAClE,CAAC"}
|
package/build/Entity.d.ts
CHANGED
package/build/EntityFields.d.ts
CHANGED
package/build/EntityFilter.d.ts
CHANGED
|
@@ -53,4 +53,3 @@ export type Operator = (typeof operators)[number];
|
|
|
53
53
|
export declare const opToFn: Record<Exclude<Operator, "in" | "nin" | "between">, string>;
|
|
54
54
|
/** A GraphQL version of EntityFilter. */
|
|
55
55
|
export type EntityGraphQLFilter<T extends Entity, I, F, N> = EntityFilter<T, I, F, N> | null;
|
|
56
|
-
//# sourceMappingURL=EntityGraphQLFilter.d.ts.map
|
package/build/EntityManager.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { PendingChange } from "./PendingChanges";
|
|
|
27
27
|
import { PluginManager } from "./PluginManager";
|
|
28
28
|
import { PreloadPlugin } from "./plugins/PreloadPlugin";
|
|
29
29
|
import { ReactionsManager } from "./ReactionsManager";
|
|
30
|
+
import { lazyColumnLoadOperation } from "./relations/LazyField";
|
|
30
31
|
import { Collection } from "./relations/Collection";
|
|
31
32
|
import { OptsOf, OrderOf } from "./typeMap";
|
|
32
33
|
import { MaybePromise } from "./utils";
|
|
@@ -106,7 +107,7 @@ export interface FlushOptions {
|
|
|
106
107
|
* - `writes` -- allows entity mutations and `em.flush` will `COMMIT` writes
|
|
107
108
|
*/
|
|
108
109
|
export type EntityManagerMode = "read-only" | "in-memory-writes" | "writes";
|
|
109
|
-
export type FindOperation = typeof findOperation | typeof findByUniqueOperation | typeof findCountOperation | typeof findIdsOperation | typeof lensOperation | typeof loadOperation | typeof manyToManyLoadOperation | typeof manyToManyFindOperation | typeof enumCollectionLoadOperation | typeof oneToManyLoadOperation | typeof oneToManyFindOperation | typeof oneToOneLoadOperation | typeof populateOperation | typeof recursiveChildrenOperation | typeof recursiveM2mOperation | typeof recursiveParentsOperation;
|
|
110
|
+
export type FindOperation = typeof findOperation | typeof findByUniqueOperation | typeof findCountOperation | typeof findIdsOperation | typeof lensOperation | typeof loadOperation | typeof manyToManyLoadOperation | typeof manyToManyFindOperation | typeof enumCollectionLoadOperation | typeof oneToManyLoadOperation | typeof oneToManyFindOperation | typeof oneToOneLoadOperation | typeof populateOperation | typeof recursiveChildrenOperation | typeof recursiveM2mOperation | typeof recursiveParentsOperation | typeof lazyColumnLoadOperation;
|
|
110
111
|
/**
|
|
111
112
|
* The EntityManager is the primary way nearly all code, i.e. anything that finds/creates/updates/deletes entities,
|
|
112
113
|
* will interact with the database.
|
|
@@ -689,7 +690,7 @@ export interface EntityManagerInternalApi {
|
|
|
689
690
|
isValidating: boolean;
|
|
690
691
|
checkWritesAllowed: () => void;
|
|
691
692
|
isMerging: (entity: Entity) => boolean;
|
|
692
|
-
get fieldLogger(): FieldLogger
|
|
693
|
+
get fieldLogger(): FieldLogger;
|
|
693
694
|
get isLoadedCache(): IsLoadedCache;
|
|
694
695
|
pluginManager: PluginManager;
|
|
695
696
|
clearDataloaders(): void;
|
|
@@ -737,4 +738,3 @@ export declare function createRowFromEntityData(e: Entity, opts?: {
|
|
|
737
738
|
preferOriginalData?: boolean;
|
|
738
739
|
}): Record<string, any>;
|
|
739
740
|
export {};
|
|
740
|
-
//# sourceMappingURL=EntityManager.d.ts.map
|
package/build/EntityManager.js
CHANGED
|
@@ -43,6 +43,7 @@ const index_1 = require("./index");
|
|
|
43
43
|
const IsLoadedCache_1 = require("./IsLoadedCache");
|
|
44
44
|
const JoinRows_1 = require("./JoinRows");
|
|
45
45
|
const loadHints_1 = require("./loadHints");
|
|
46
|
+
const FieldLogger_1 = require("./logging/FieldLogger");
|
|
46
47
|
const newEntity_1 = require("./newEntity");
|
|
47
48
|
const newTestInstance_1 = require("./newTestInstance");
|
|
48
49
|
const PluginManager_1 = require("./PluginManager");
|
|
@@ -50,6 +51,7 @@ const ReactionsManager_1 = require("./ReactionsManager");
|
|
|
50
51
|
const reactiveHints_1 = require("./reactiveHints");
|
|
51
52
|
const relations_1 = require("./relations");
|
|
52
53
|
const AsyncProperty_1 = require("./relations/AsyncProperty");
|
|
54
|
+
const LazyField_1 = require("./relations/LazyField");
|
|
53
55
|
const hasAsyncMethod_1 = require("./relations/hasAsyncMethod");
|
|
54
56
|
const RecursiveCollection_1 = require("./relations/RecursiveCollection");
|
|
55
57
|
const scopes_1 = require("./scopes");
|
|
@@ -98,6 +100,8 @@ class EntityManager {
|
|
|
98
100
|
// Provides field-based indexing for entity types with >1000 entities to optimize findWithNewOrChanged
|
|
99
101
|
#indexManager = new IndexManager_1.IndexManager();
|
|
100
102
|
#isValidating = false;
|
|
103
|
+
// Set while regular (pre-flush) validation rules run, so `em.find*` can fail fast (see #assertFindAllowed)
|
|
104
|
+
#findRestricted = false;
|
|
101
105
|
#pendingPercolate = new Map();
|
|
102
106
|
#preloadedRelations = new Map();
|
|
103
107
|
/**
|
|
@@ -124,7 +128,7 @@ class EntityManager {
|
|
|
124
128
|
afterCommit: [],
|
|
125
129
|
};
|
|
126
130
|
#preloader;
|
|
127
|
-
#fieldLogger;
|
|
131
|
+
#fieldLogger = FieldLogger_1.noopFieldLogger;
|
|
128
132
|
#isLoadedCache = new IsLoadedCache_1.IsLoadedCache();
|
|
129
133
|
#merging;
|
|
130
134
|
/** Track `a#1`, `a#2`, etc indexes for `em.create`-d entities. */
|
|
@@ -265,6 +269,7 @@ class EntityManager {
|
|
|
265
269
|
return this.#entitiesById.get(id);
|
|
266
270
|
}
|
|
267
271
|
async find(type, where, options) {
|
|
272
|
+
this.#assertFindAllowed("find");
|
|
268
273
|
const { populate, ...rest } = options || {};
|
|
269
274
|
const normalized = (0, index_1.mergeFindOptions)(where, rest);
|
|
270
275
|
const settings = { where: normalized.where, ...normalized.options };
|
|
@@ -278,6 +283,14 @@ class EntityManager {
|
|
|
278
283
|
}
|
|
279
284
|
return result;
|
|
280
285
|
}
|
|
286
|
+
/** Fails fast if `em.${method}` is called from a regular validation rule, i.e. steers to `config.addCommitRule`. */
|
|
287
|
+
#assertFindAllowed(method) {
|
|
288
|
+
if (this.#findRestricted) {
|
|
289
|
+
throw new Error(`em.${method} cannot be called from a validation rule (added via config.addRule), because rules run ` +
|
|
290
|
+
`before the flush and would query stale, pre-flush data. Use config.addCommitRule instead, which runs ` +
|
|
291
|
+
`after the INSERT/UPDATE/DELETEs are flushed (within the same transaction) and so sees the changed state.`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
281
294
|
/** Runs the post-parse find pipeline: plugins mutate the logical AST, then Joist optimizes/prunes before SQL. */
|
|
282
295
|
async executeFind(meta, operation, parsed, settings) {
|
|
283
296
|
const { checkLimit, findSettings } = this.prepareFind(meta, operation, parsed, settings);
|
|
@@ -348,6 +361,7 @@ class EntityManager {
|
|
|
348
361
|
return list[0];
|
|
349
362
|
}
|
|
350
363
|
async findByUnique(type, where, options = {}) {
|
|
364
|
+
this.#assertFindAllowed("findByUnique");
|
|
351
365
|
const { populate, softDeletes = "exclude" } = options;
|
|
352
366
|
const entries = Object.entries(where);
|
|
353
367
|
if (entries.length !== 1) {
|
|
@@ -383,6 +397,7 @@ class EntityManager {
|
|
|
383
397
|
* Note: this method is not currently auto-batched, so it will cause N+1s if called in a loop.
|
|
384
398
|
*/
|
|
385
399
|
async findCount(type, where, options = {}) {
|
|
400
|
+
this.#assertFindAllowed("findCount");
|
|
386
401
|
const normalized = (0, findCountDataLoader_1.mergeCountOptions)(where, options);
|
|
387
402
|
const settings = { where: normalized.where, ...normalized.options };
|
|
388
403
|
let count = await (0, findCountDataLoader_1.findCountDataLoader)(this, type, settings).catch(function findCount(err) {
|
|
@@ -416,6 +431,7 @@ class EntityManager {
|
|
|
416
431
|
* as `em.find`.
|
|
417
432
|
*/
|
|
418
433
|
async findIds(type, where, options = {}) {
|
|
434
|
+
this.#assertFindAllowed("findIds");
|
|
419
435
|
const normalized = (0, findCountDataLoader_1.mergeCountOptions)(where, options);
|
|
420
436
|
const settings = { where: normalized.where, ...normalized.options };
|
|
421
437
|
return (0, findIdsDataLoader_1.findIdsDataLoader)(this, type, settings).catch(function findIds(err) {
|
|
@@ -1059,16 +1075,25 @@ class EntityManager {
|
|
|
1059
1075
|
this.#isValidating = true;
|
|
1060
1076
|
await pluginManager.beforeValidate(changedEntities);
|
|
1061
1077
|
if (validate) {
|
|
1062
|
-
//
|
|
1063
|
-
// `
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1078
|
+
// Regular rules run pre-flush, so `em.find*` would query stale data; block it and steer
|
|
1079
|
+
// users to `config.addCommitRule` (which runs post-flush). Only rules are restricted —
|
|
1080
|
+
// `afterValidation` hooks & plugins below are left free to query.
|
|
1081
|
+
this.#findRestricted = true;
|
|
1082
|
+
try {
|
|
1083
|
+
// Run simple rules first b/c it includes not-null/required rules, so that then when we run
|
|
1084
|
+
// `validateReactiveRules` next, the app's lambdas won't see fundamentally invalid entities & NPE.
|
|
1085
|
+
await validateSimpleRules(entityTodos);
|
|
1086
|
+
// After we've let any "author is not set" simple rules fail before prematurely throwing
|
|
1087
|
+
// the "of course that caused an NPE" `TypeError`s, if all the authors *were* valid/set,
|
|
1088
|
+
// and we still have TypeErrors (from derived valeus), they were real, unrelated errors
|
|
1089
|
+
// that the user should see.
|
|
1090
|
+
if (suppressedDefaultTypeErrors.length > 0)
|
|
1091
|
+
throw suppressedDefaultTypeErrors[0];
|
|
1092
|
+
await validateReactiveRules(this, this.#rm.logger, entityTodos, joinRowTodos);
|
|
1093
|
+
}
|
|
1094
|
+
finally {
|
|
1095
|
+
this.#findRestricted = false;
|
|
1096
|
+
}
|
|
1072
1097
|
await afterValidation(this.ctx, entityTodos);
|
|
1073
1098
|
}
|
|
1074
1099
|
await pluginManager.afterValidate(changedEntities);
|
|
@@ -1077,6 +1102,61 @@ class EntityManager {
|
|
|
1077
1102
|
this.#isValidating = false;
|
|
1078
1103
|
}
|
|
1079
1104
|
};
|
|
1105
|
+
// Runs `addCommitRule`s, which look exactly like regular validation rules but fire here,
|
|
1106
|
+
// after the INSERT/UPDATE/DELETEs have hit the db (but before COMMIT), so that any
|
|
1107
|
+
// `em.find`s they make query the just-flushed/changed state within the transaction.
|
|
1108
|
+
const runCommitValidation = async (entityTodos, joinRowTodos) => {
|
|
1109
|
+
// Drop the pre-flush find/query caches so commit rules' `em.find`s re-query and see the
|
|
1110
|
+
// just-flushed rows, instead of stale results cached earlier in this same flush.
|
|
1111
|
+
this.#dataloaders = {};
|
|
1112
|
+
this.#batchLoaders = {};
|
|
1113
|
+
this.#preloadedRelations = new Map();
|
|
1114
|
+
try {
|
|
1115
|
+
// `isValidating` keeps derived-field reads from creating (now-unflushable) dirty state.
|
|
1116
|
+
this.#isValidating = true;
|
|
1117
|
+
await validateSimpleRules(entityTodos, (config) => config.commitRules);
|
|
1118
|
+
await validateReactiveRules(this, this.#rm.logger, entityTodos, joinRowTodos, (meta) => meta.reactiveCommitRules);
|
|
1119
|
+
}
|
|
1120
|
+
finally {
|
|
1121
|
+
this.#isValidating = false;
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
// Commit rules run once, at the end, over just the flushed entities/join-rows whose type has
|
|
1125
|
+
// commit rules (see `meta.hasCommitRules`). We accumulate that subset here as we flush — deduping
|
|
1126
|
+
// across the RQF loop below (which resets entity dirty-state) — so we neither keep every todo
|
|
1127
|
+
// nor re-scan/merge them afterwards; apps without commit rules leave these empty and pay ~nothing.
|
|
1128
|
+
const commitRuleTodos = {};
|
|
1129
|
+
const commitRuleJoinRowTodos = {};
|
|
1130
|
+
const commitRuleSeen = new Set();
|
|
1131
|
+
function collectCommitRuleTodos(entityTodos, joinRowTodos) {
|
|
1132
|
+
if (skipValidation)
|
|
1133
|
+
return;
|
|
1134
|
+
for (const todo of Object.values(entityTodos)) {
|
|
1135
|
+
if (!todo.metadata.hasCommitRules)
|
|
1136
|
+
continue;
|
|
1137
|
+
for (const key of ["inserts", "updates", "deletes"]) {
|
|
1138
|
+
for (const e of todo[key]) {
|
|
1139
|
+
if (!commitRuleSeen.has(e)) {
|
|
1140
|
+
commitRuleSeen.add(e);
|
|
1141
|
+
(0, Todo_1.getTodo)(commitRuleTodos, e)[key].push(e);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
for (const [table, todo] of Object.entries(joinRowTodos)) {
|
|
1147
|
+
if (!todo.m2m.meta.hasCommitRules && !todo.m2m.otherMeta?.hasCommitRules)
|
|
1148
|
+
continue;
|
|
1149
|
+
const into = (commitRuleJoinRowTodos[table] ??= { ...todo, newRows: [], deletedRows: [] });
|
|
1150
|
+
for (const key of ["newRows", "deletedRows"]) {
|
|
1151
|
+
for (const r of todo[key]) {
|
|
1152
|
+
if (!commitRuleSeen.has(r)) {
|
|
1153
|
+
commitRuleSeen.add(r);
|
|
1154
|
+
into[key].push(r);
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1080
1160
|
// Run hooks (in iterative loops if hooks mutate new entities) on pending entities
|
|
1081
1161
|
let entitiesToFlush = await runHooksOnPendingEntities();
|
|
1082
1162
|
for (const e of entitiesToFlush)
|
|
@@ -1095,6 +1175,8 @@ class EntityManager {
|
|
|
1095
1175
|
do {
|
|
1096
1176
|
if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0) {
|
|
1097
1177
|
await this.driver.flush(this, entityTodos, joinRowTodos);
|
|
1178
|
+
// Accumulate the commit-rule-relevant subset before the RQF loop clobbers/resets these
|
|
1179
|
+
collectCommitRuleTodos(entityTodos, joinRowTodos);
|
|
1098
1180
|
}
|
|
1099
1181
|
// Now that we've flushed, we can let plugins know what we've done.
|
|
1100
1182
|
pluginManager.afterWrite(entityTodos, joinRowTodos);
|
|
@@ -1130,6 +1212,18 @@ class EntityManager {
|
|
|
1130
1212
|
entityTodos = {};
|
|
1131
1213
|
}
|
|
1132
1214
|
} while (Object.keys(entityTodos).length > 0);
|
|
1215
|
+
// Now that all SQL has hit the db (but before COMMIT), run any `addCommitRule`s so their
|
|
1216
|
+
// `em.find`s see the changed state. `commitRuleTodos` is only non-empty if a flushed entity
|
|
1217
|
+
// actually has commit rules, so apps without them skip this (and its logging) entirely.
|
|
1218
|
+
if (Object.keys(commitRuleTodos).length > 0 || Object.keys(commitRuleJoinRowTodos).length > 0) {
|
|
1219
|
+
// Make just-inserted entities findable by id (like the RQF loop does) so commit rules'
|
|
1220
|
+
// `em.find`s return these same instances rather than hydrating duplicate ones.
|
|
1221
|
+
for (const e of allFlushedEntities) {
|
|
1222
|
+
if (e.isNewEntity && !e.isDeletedEntity)
|
|
1223
|
+
this.#entitiesById.set(e.idTagged, e);
|
|
1224
|
+
}
|
|
1225
|
+
await runCommitValidation(commitRuleTodos, commitRuleJoinRowTodos);
|
|
1226
|
+
}
|
|
1133
1227
|
// Run `beforeCommit once right before COMMIT
|
|
1134
1228
|
await beforeCommit(this.ctx, allFlushedEntities);
|
|
1135
1229
|
if (this.mode === "in-memory-writes") {
|
|
@@ -1144,9 +1238,9 @@ class EntityManager {
|
|
|
1144
1238
|
if (e.isNewEntity && !e.isDeletedEntity)
|
|
1145
1239
|
this.#entitiesById.set(e.idTagged, e);
|
|
1146
1240
|
(0, BaseEntity_1.getInstanceData)(e).resetAfterFlushed();
|
|
1147
|
-
// Reset AsyncQueryProperties since DB state may have changed
|
|
1241
|
+
// Reset AsyncQueryProperties & LazyFields since DB state may have changed
|
|
1148
1242
|
for (const rel of Object.values((0, BaseEntity_1.getInstanceData)(e).relations)) {
|
|
1149
|
-
if (rel instanceof AsyncProperty_1.AsyncPropertyImpl)
|
|
1243
|
+
if (rel instanceof AsyncProperty_1.AsyncPropertyImpl || rel instanceof LazyField_1.LazyFieldImpl)
|
|
1150
1244
|
rel.resetAfterFlush();
|
|
1151
1245
|
}
|
|
1152
1246
|
}
|
|
@@ -1185,16 +1279,28 @@ class EntityManager {
|
|
|
1185
1279
|
}
|
|
1186
1280
|
}
|
|
1187
1281
|
}
|
|
1282
|
+
// node-pg keeps the DETAIL line (i.e. "Key (identity_id, final_id)=(102591, null) already exists")
|
|
1283
|
+
// on a separate `detail` field, so keep it to suffix onto messages to help debugging.
|
|
1284
|
+
const detail = e && typeof e === "object" && "detail" in e && typeof e.detail === "string" ? e.detail : undefined;
|
|
1188
1285
|
if (e && typeof e === "object" && "constraint" in e && typeof e.constraint === "string") {
|
|
1189
1286
|
// node-pg errors use `constraint` to indicate the constraint name
|
|
1190
1287
|
const message = config_1.constraintNameToValidationError[e.constraint];
|
|
1191
1288
|
if (message) {
|
|
1192
|
-
|
|
1289
|
+
const errors = new index_1.ValidationErrors(message);
|
|
1290
|
+
// Keep the user-facing `errors[].message` pretty, but suffix the DETAIL onto the top-level
|
|
1291
|
+
// `message` so the debugging context survives into logs/stack traces.
|
|
1292
|
+
if (detail)
|
|
1293
|
+
errors.message = `${message} — ${detail}`;
|
|
1294
|
+
throw errors;
|
|
1193
1295
|
}
|
|
1194
1296
|
}
|
|
1195
1297
|
if (e instanceof InMemoryRollbackError) {
|
|
1196
1298
|
return [...allFlushedEntities].sort((a, b) => (0, BaseEntity_1.getInstanceData)(a).entityIndex - (0, BaseEntity_1.getInstanceData)(b).entityIndex);
|
|
1197
1299
|
}
|
|
1300
|
+
// For raw (non-pretty) pg errors, fold the DETAIL into `message` so it survives into logs.
|
|
1301
|
+
if (detail && e instanceof Error) {
|
|
1302
|
+
e.message = `${e.message} — ${detail}`;
|
|
1303
|
+
}
|
|
1198
1304
|
throw e;
|
|
1199
1305
|
}
|
|
1200
1306
|
finally {
|
|
@@ -1302,13 +1408,12 @@ class EntityManager {
|
|
|
1302
1408
|
*/
|
|
1303
1409
|
hydrate(type, rows, options) {
|
|
1304
1410
|
const maybeBaseMeta = (0, index_1.getMetadata)(type);
|
|
1305
|
-
const taggedIdPrefix = `${maybeBaseMeta.tagName}:`;
|
|
1306
1411
|
const overwriteExisting = options?.overwriteExisting === true;
|
|
1307
1412
|
let i = 0;
|
|
1308
1413
|
const entities = new Array(rows.length);
|
|
1309
1414
|
for (const row of rows) {
|
|
1310
1415
|
const id = row["id"];
|
|
1311
|
-
const taggedId = id === undefined || id === null ? (0, utils_1.fail)("No id column was available") :
|
|
1416
|
+
const taggedId = id === undefined || id === null ? (0, utils_1.fail)("No id column was available") : (0, index_1.keyToTaggedId)(maybeBaseMeta, id);
|
|
1312
1417
|
// See if this is already in our UoW
|
|
1313
1418
|
let entity = this.findExistingInstance(taggedId);
|
|
1314
1419
|
if (!entity) {
|
|
@@ -1460,7 +1565,7 @@ class EntityManager {
|
|
|
1460
1565
|
}
|
|
1461
1566
|
const writeFn = getDefaultWriteFn(this.ctx);
|
|
1462
1567
|
if (typeof arg === "boolean") {
|
|
1463
|
-
this.#fieldLogger = arg ? new index_1.FieldLogger([], writeFn) :
|
|
1568
|
+
this.#fieldLogger = arg ? new index_1.FieldLogger([], writeFn) : FieldLogger_1.noopFieldLogger;
|
|
1464
1569
|
}
|
|
1465
1570
|
else if (typeof arg === "string" || Array.isArray(arg)) {
|
|
1466
1571
|
const specs = Array.isArray(arg) ? arg : [arg];
|
|
@@ -1742,7 +1847,7 @@ class EntityManager {
|
|
|
1742
1847
|
}
|
|
1743
1848
|
// api will be undefined during getFakeInstance
|
|
1744
1849
|
const api = getEmInternalApi(this);
|
|
1745
|
-
api?.fieldLogger
|
|
1850
|
+
api?.fieldLogger.logCreate(entity);
|
|
1746
1851
|
(0, index_1.setOpts)(entity, opts, { partial, calledFromConstructor: true });
|
|
1747
1852
|
// Apply any synchronous defaults, after the opts have been applied
|
|
1748
1853
|
if (!this.fakeInstance) {
|
|
@@ -1851,8 +1956,10 @@ exports.TooManyError = TooManyError;
|
|
|
1851
1956
|
* from the currently-changed entities back to each rule's originally-defined-in entity,
|
|
1852
1957
|
* and ensure those entities are added to `todos`.
|
|
1853
1958
|
*/
|
|
1854
|
-
async function validateReactiveRules(em, logger, todos, joinRowTodos
|
|
1855
|
-
|
|
1959
|
+
async function validateReactiveRules(em, logger, todos, joinRowTodos,
|
|
1960
|
+
// Which list of reactive rules to run, i.e. the pre-flush `reactiveRules` or the post-flush `reactiveCommitRules`
|
|
1961
|
+
getRules = (meta) => meta.reactiveRules) {
|
|
1962
|
+
logger.logStartingValidate(em, todos);
|
|
1856
1963
|
// Use a map of rule -> Set<Entity> so that we only invoke a rule once per entity,
|
|
1857
1964
|
// even if it was triggered by multiple changed fields.
|
|
1858
1965
|
const fns = new Map();
|
|
@@ -1869,7 +1976,7 @@ async function validateReactiveRules(em, logger, todos, joinRowTodos) {
|
|
|
1869
1976
|
entities = new Set();
|
|
1870
1977
|
fns.set(rule.fn, entities);
|
|
1871
1978
|
}
|
|
1872
|
-
logger
|
|
1979
|
+
logger.logWalked(triggered, rule, found, "validate");
|
|
1873
1980
|
found.forEach((entity) => {
|
|
1874
1981
|
entities.add(entity);
|
|
1875
1982
|
});
|
|
@@ -1877,7 +1984,7 @@ async function validateReactiveRules(em, logger, todos, joinRowTodos) {
|
|
|
1877
1984
|
const p1 = Object.values(todos).flatMap((todo) => {
|
|
1878
1985
|
const entities = [...todo.inserts, ...todo.updates, ...todo.deletes];
|
|
1879
1986
|
// Find each statically-declared reactive rule for the given entity type
|
|
1880
|
-
const rules = todo.metadata
|
|
1987
|
+
const rules = getRules(todo.metadata);
|
|
1881
1988
|
return rules.map((rule) => {
|
|
1882
1989
|
// Of all changed entities of this type, how many specifically trigger this rule?
|
|
1883
1990
|
const triggered = entities.filter((e) => {
|
|
@@ -1903,8 +2010,8 @@ async function validateReactiveRules(em, logger, todos, joinRowTodos) {
|
|
|
1903
2010
|
// For enum m2ms the columns include the enum's numeric id, so keep only the entity values.
|
|
1904
2011
|
const entities = [...todo.newRows, ...todo.deletedRows].flatMap((jr) => Object.values(jr.columns)).filter(Entity_1.isEntity);
|
|
1905
2012
|
// The owning-entity side (applies to both entity-to-entity and entity-to-enum m2ms).
|
|
1906
|
-
const a = todo.m2m.meta
|
|
1907
|
-
.
|
|
2013
|
+
const a = getRules(todo.m2m.meta)
|
|
2014
|
+
.filter((rule) => rule.fields.includes(todo.m2m.fieldName))
|
|
1908
2015
|
.map((rule) => {
|
|
1909
2016
|
const triggered = entities.filter((e) => e instanceof todo.m2m.meta.cstr);
|
|
1910
2017
|
return followAndQueue(triggered, rule);
|
|
@@ -1912,8 +2019,8 @@ async function validateReactiveRules(em, logger, todos, joinRowTodos) {
|
|
|
1912
2019
|
// The "other" side only exists for entity-to-entity m2ms; enums have no reverse field.
|
|
1913
2020
|
const { otherMeta, otherFieldName } = todo.m2m;
|
|
1914
2021
|
const b = otherMeta
|
|
1915
|
-
? otherMeta
|
|
1916
|
-
.
|
|
2022
|
+
? getRules(otherMeta)
|
|
2023
|
+
.filter((rule) => rule.fields.includes(otherFieldName))
|
|
1917
2024
|
.map((rule) => {
|
|
1918
2025
|
const triggered = entities.filter((e) => e instanceof otherMeta.cstr);
|
|
1919
2026
|
return followAndQueue(triggered, rule);
|
|
@@ -1932,12 +2039,14 @@ async function validateReactiveRules(em, logger, todos, joinRowTodos) {
|
|
|
1932
2039
|
// Run *non-reactive* (those with `fields: undefined`) rules of explicitly mutated entities,
|
|
1933
2040
|
// because even for reactive validations on mutated entities, we defer to addReactiveValidations
|
|
1934
2041
|
// to mark only the rules that need to run.
|
|
1935
|
-
async function validateSimpleRules(todos
|
|
2042
|
+
async function validateSimpleRules(todos,
|
|
2043
|
+
// Which config list to pull rules from, i.e. the pre-flush `rules` or the post-flush `commitRules`
|
|
2044
|
+
getRules = (config) => config.rules) {
|
|
1936
2045
|
const p = Object.values(todos).flatMap(({ inserts, updates }) => {
|
|
1937
2046
|
return [...inserts, ...updates]
|
|
1938
2047
|
.filter((e) => !e.isDeletedEntity)
|
|
1939
2048
|
.flatMap((entity) => {
|
|
1940
|
-
const rules = (0, index_1.getBaseAndSelfMetas)((0, index_1.getMetadata)(entity)).flatMap((m) => m.config.__data
|
|
2049
|
+
const rules = (0, index_1.getBaseAndSelfMetas)((0, index_1.getMetadata)(entity)).flatMap((m) => getRules(m.config.__data));
|
|
1941
2050
|
return rules
|
|
1942
2051
|
.filter((rule) => rule.hint === undefined)
|
|
1943
2052
|
.flatMap(async ({ fn }) => coerceError(entity, await fn(entity)));
|