@astralibx/email-rule-engine 12.10.0 → 12.10.1

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/README.md CHANGED
@@ -15,6 +15,7 @@ npm install @astralibx/email-rule-engine
15
15
 
16
16
  | Peer Dependency | Version |
17
17
  |-----------------|---------|
18
+ | `@astralibx/core` | `^1.2.0` |
18
19
  | `express` | `^4.18.0 \|\| ^5.0.0` |
19
20
  | `mongoose` | `^7.0.0 \|\| ^8.0.0` |
20
21
  | `ioredis` | `^5.0.0` |
package/dist/index.cjs CHANGED
@@ -205,7 +205,7 @@ function createEmailRuleSchema(platformValues, audienceValues, collectionPrefix)
205
205
  },
206
206
  conditions: [RuleConditionSchema],
207
207
  identifiers: [{ type: String }],
208
- collection: { type: String }
208
+ collectionName: { type: String }
209
209
  }, { _id: false });
210
210
  const RuleRunStatsSchema = createRunStatsSchema();
211
211
  const schema = new mongoose.Schema(
@@ -1093,8 +1093,8 @@ var RuleService = class {
1093
1093
  throw new RuleTemplateIncompatibleError("target.identifiers must be a non-empty array for list mode, validation failed");
1094
1094
  }
1095
1095
  }
1096
- if (isQueryTarget(input.target) && input.target.collection && this.config.collections?.length) {
1097
- const condErrors = validateConditions(input.target.conditions, input.target.collection, this.config.collections);
1096
+ if (isQueryTarget(input.target) && input.target.collectionName && this.config.collections?.length) {
1097
+ const condErrors = validateConditions(input.target.conditions, input.target.collectionName, this.config.collections);
1098
1098
  if (condErrors.length > 0) {
1099
1099
  throw new RuleTemplateIncompatibleError(
1100
1100
  `Invalid conditions: ${condErrors.map((e) => e.message).join("; ")}`
@@ -1132,8 +1132,8 @@ var RuleService = class {
1132
1132
  }
1133
1133
  if (isQueryTarget(effectiveTarget)) {
1134
1134
  const qt = effectiveTarget;
1135
- if (qt.collection && this.config.collections?.length) {
1136
- const condErrors = validateConditions(qt.conditions || [], qt.collection, this.config.collections);
1135
+ if (qt.collectionName && this.config.collections?.length) {
1136
+ const condErrors = validateConditions(qt.conditions || [], qt.collectionName, this.config.collections);
1137
1137
  if (condErrors.length > 0) {
1138
1138
  throw new RuleTemplateIncompatibleError(
1139
1139
  `Invalid conditions: ${condErrors.map((e) => e.message).join("; ")}`
@@ -1191,7 +1191,7 @@ var RuleService = class {
1191
1191
  return { matchedCount: matchedCount2, effectiveLimit, willProcess: willProcess2, ruleId: id, sample: sample2 };
1192
1192
  }
1193
1193
  const queryTarget = rule.target;
1194
- const collectionName = queryTarget.collection;
1194
+ const collectionName = queryTarget.collectionName;
1195
1195
  const collectionSchema = collectionName ? this.config.collections?.find((c) => c.name === collectionName) : void 0;
1196
1196
  const users = await this.config.adapters.queryUsers(rule.target, 5e4, collectionSchema ? { collectionSchema } : void 0);
1197
1197
  const matchedCount = users.length;
@@ -1710,7 +1710,7 @@ var RuleRunnerService = class {
1710
1710
  const limit = rule.maxPerRun || this.config.options?.defaultMaxPerRun || 500;
1711
1711
  let users;
1712
1712
  try {
1713
- const collectionName = rule.target?.collection;
1713
+ const collectionName = rule.target?.collectionName;
1714
1714
  const collectionSchema = collectionName ? this.config.collections?.find((c) => c.name === collectionName) : void 0;
1715
1715
  users = await this.config.adapters.queryUsers(rule.target, limit, collectionSchema ? { collectionSchema } : void 0);
1716
1716
  } catch (err) {