@rpcbase/db 0.138.0 → 0.140.0

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/dist/index.js CHANGED
@@ -3217,7 +3217,9 @@ var createProvisionedTenant = async (Tenant, tenant) => {
3217
3217
  },
3218
3218
  $unset: { provisioningError: "" }
3219
3219
  });
3220
- if (activation.matchedCount !== void 0 && activation.matchedCount !== 1) throw new Error(`Tenant ${tenant.tenantId} provisioning state changed before activation`);
3220
+ if (activation.matchedCount !== void 0 && activation.matchedCount !== 1) {
3221
+ if ((await Tenant.findOne?.({ tenantId: tenant.tenantId }))?.provisioningStatus !== "active") throw new Error(`Tenant ${tenant.tenantId} provisioning state changed before activation`);
3222
+ }
3221
3223
  } catch (error) {
3222
3224
  await Tenant.updateOne({ tenantId: tenant.tenantId }, { $set: {
3223
3225
  provisioningStatus: "failed",