@cakemail-org/ui-components-v2 2.1.1 → 2.1.2

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/cjs/index.js CHANGED
@@ -9501,6 +9501,7 @@ var AccountModel = /** @class */ (function () {
9501
9501
  this.overrides = params.overrides || {};
9502
9502
  this.stripe_customer_id = params.stripe_customer_id || "";
9503
9503
  this.metadata = params.metadata || {};
9504
+ this.usage = params.usage || undefined;
9504
9505
  if (params.isMainAccount) {
9505
9506
  this.getUsageReport();
9506
9507
  }
@@ -9601,56 +9602,43 @@ var AccountModel = /** @class */ (function () {
9601
9602
  return this.partner || this.organization;
9602
9603
  };
9603
9604
  AccountModel.prototype.hasAccessTo = function (_a) {
9604
- return __awaiter(this, arguments, void 0, function (_b) {
9605
- var featureValue, brandDisabledLimitsFeatures;
9606
- var feature = _b.feature, partnerBrand = _b.partnerBrand, userCount = _b.userCount;
9607
- return __generator(this, function (_c) {
9608
- switch (_c.label) {
9609
- case 0:
9610
- featureValue = this.usage_limits[feature];
9611
- if (featureValue === undefined) {
9612
- return [2 /*return*/, false];
9613
- }
9614
- brandDisabledLimitsFeatures = getNestedProperty(partnerBrand, "config.disabledLimitsFeatures") || [];
9615
- if (brandDisabledLimitsFeatures.includes(feature))
9616
- return [2 /*return*/, true];
9617
- if (!(typeof featureValue === "boolean" || Number.isNaN(featureValue))) return [3 /*break*/, 1];
9618
- //Some feature flags are inverted
9619
- if (feature === "insert_reseller_logo") {
9620
- return [2 /*return*/, !featureValue];
9621
- }
9622
- else {
9623
- return [2 /*return*/, Boolean(featureValue)];
9624
- }
9625
- case 1:
9626
- if (!!this.usage) return [3 /*break*/, 3];
9627
- return [4 /*yield*/, this.getUsageReport()];
9628
- case 2:
9629
- _c.sent();
9630
- _c.label = 3;
9631
- case 3:
9632
- if (this.usage) {
9633
- if (feature === "lists") {
9634
- return [2 /*return*/, this.usage.current_lists <= featureValue];
9635
- }
9636
- else if (feature === "users" && userCount !== undefined) {
9637
- return [2 /*return*/, userCount <= featureValue];
9638
- }
9639
- else if (feature === "per_month") {
9640
- return [2 /*return*/, this.usage.emails_usage <= 100];
9641
- }
9642
- else if (feature === "maximum_contacts") {
9643
- return [2 /*return*/, this.usage.active_contacts <= featureValue];
9644
- }
9645
- throw new Error("Requested Feature does not exist in account usage");
9646
- }
9647
- else {
9648
- return [2 /*return*/, true];
9649
- }
9650
- case 4: return [2 /*return*/];
9605
+ var feature = _a.feature, partnerBrand = _a.partnerBrand, userCount = _a.userCount;
9606
+ var featureValue = this.usage_limits[feature];
9607
+ if (featureValue === undefined) {
9608
+ return false;
9609
+ }
9610
+ var brandDisabledLimitsFeatures = getNestedProperty(partnerBrand, "config.disabledLimitsFeatures") || [];
9611
+ if (brandDisabledLimitsFeatures.includes(feature))
9612
+ return true;
9613
+ if (typeof featureValue === "boolean" || Number.isNaN(featureValue)) {
9614
+ //Some feature flags are inverted
9615
+ if (feature === "insert_reseller_logo") {
9616
+ return !featureValue;
9617
+ }
9618
+ else {
9619
+ return Boolean(featureValue);
9620
+ }
9621
+ }
9622
+ else {
9623
+ if (this.usage) {
9624
+ if (feature === "lists") {
9625
+ return this.usage.current_lists <= featureValue;
9651
9626
  }
9652
- });
9653
- });
9627
+ else if (feature === "users" && userCount !== undefined) {
9628
+ return userCount <= featureValue;
9629
+ }
9630
+ else if (feature === "per_month") {
9631
+ return this.usage.emails_usage <= 100;
9632
+ }
9633
+ else if (feature === "maximum_contacts") {
9634
+ return this.usage.active_contacts <= featureValue;
9635
+ }
9636
+ throw new Error("Requested Feature does not exist in account usage");
9637
+ }
9638
+ else {
9639
+ throw new Error("Usage not fetched, please call getUsageReport() before calling hasAccessTo() with usage-based features");
9640
+ }
9641
+ }
9654
9642
  };
9655
9643
  return AccountModel;
9656
9644
  }());
@@ -21,6 +21,7 @@ export declare class AccountModel {
21
21
  usage?: TAccountReport;
22
22
  constructor(params: Partial<TAccountModel> & {
23
23
  isMainAccount?: boolean;
24
+ usage?: TAccountReport;
24
25
  });
25
26
  toJson(): any;
26
27
  set<T extends keyof this>(property: T, value: this[T]): void;
@@ -39,6 +40,6 @@ export declare class AccountModel {
39
40
  feature: keyof TAccountLimits;
40
41
  partnerBrand?: TBrand;
41
42
  userCount?: number;
42
- }): Promise<boolean>;
43
+ }): boolean;
43
44
  }
44
45
  export * from "./types";
package/dist/esm/index.js CHANGED
@@ -9481,6 +9481,7 @@ var AccountModel = /** @class */ (function () {
9481
9481
  this.overrides = params.overrides || {};
9482
9482
  this.stripe_customer_id = params.stripe_customer_id || "";
9483
9483
  this.metadata = params.metadata || {};
9484
+ this.usage = params.usage || undefined;
9484
9485
  if (params.isMainAccount) {
9485
9486
  this.getUsageReport();
9486
9487
  }
@@ -9581,56 +9582,43 @@ var AccountModel = /** @class */ (function () {
9581
9582
  return this.partner || this.organization;
9582
9583
  };
9583
9584
  AccountModel.prototype.hasAccessTo = function (_a) {
9584
- return __awaiter(this, arguments, void 0, function (_b) {
9585
- var featureValue, brandDisabledLimitsFeatures;
9586
- var feature = _b.feature, partnerBrand = _b.partnerBrand, userCount = _b.userCount;
9587
- return __generator(this, function (_c) {
9588
- switch (_c.label) {
9589
- case 0:
9590
- featureValue = this.usage_limits[feature];
9591
- if (featureValue === undefined) {
9592
- return [2 /*return*/, false];
9593
- }
9594
- brandDisabledLimitsFeatures = getNestedProperty(partnerBrand, "config.disabledLimitsFeatures") || [];
9595
- if (brandDisabledLimitsFeatures.includes(feature))
9596
- return [2 /*return*/, true];
9597
- if (!(typeof featureValue === "boolean" || Number.isNaN(featureValue))) return [3 /*break*/, 1];
9598
- //Some feature flags are inverted
9599
- if (feature === "insert_reseller_logo") {
9600
- return [2 /*return*/, !featureValue];
9601
- }
9602
- else {
9603
- return [2 /*return*/, Boolean(featureValue)];
9604
- }
9605
- case 1:
9606
- if (!!this.usage) return [3 /*break*/, 3];
9607
- return [4 /*yield*/, this.getUsageReport()];
9608
- case 2:
9609
- _c.sent();
9610
- _c.label = 3;
9611
- case 3:
9612
- if (this.usage) {
9613
- if (feature === "lists") {
9614
- return [2 /*return*/, this.usage.current_lists <= featureValue];
9615
- }
9616
- else if (feature === "users" && userCount !== undefined) {
9617
- return [2 /*return*/, userCount <= featureValue];
9618
- }
9619
- else if (feature === "per_month") {
9620
- return [2 /*return*/, this.usage.emails_usage <= 100];
9621
- }
9622
- else if (feature === "maximum_contacts") {
9623
- return [2 /*return*/, this.usage.active_contacts <= featureValue];
9624
- }
9625
- throw new Error("Requested Feature does not exist in account usage");
9626
- }
9627
- else {
9628
- return [2 /*return*/, true];
9629
- }
9630
- case 4: return [2 /*return*/];
9585
+ var feature = _a.feature, partnerBrand = _a.partnerBrand, userCount = _a.userCount;
9586
+ var featureValue = this.usage_limits[feature];
9587
+ if (featureValue === undefined) {
9588
+ return false;
9589
+ }
9590
+ var brandDisabledLimitsFeatures = getNestedProperty(partnerBrand, "config.disabledLimitsFeatures") || [];
9591
+ if (brandDisabledLimitsFeatures.includes(feature))
9592
+ return true;
9593
+ if (typeof featureValue === "boolean" || Number.isNaN(featureValue)) {
9594
+ //Some feature flags are inverted
9595
+ if (feature === "insert_reseller_logo") {
9596
+ return !featureValue;
9597
+ }
9598
+ else {
9599
+ return Boolean(featureValue);
9600
+ }
9601
+ }
9602
+ else {
9603
+ if (this.usage) {
9604
+ if (feature === "lists") {
9605
+ return this.usage.current_lists <= featureValue;
9631
9606
  }
9632
- });
9633
- });
9607
+ else if (feature === "users" && userCount !== undefined) {
9608
+ return userCount <= featureValue;
9609
+ }
9610
+ else if (feature === "per_month") {
9611
+ return this.usage.emails_usage <= 100;
9612
+ }
9613
+ else if (feature === "maximum_contacts") {
9614
+ return this.usage.active_contacts <= featureValue;
9615
+ }
9616
+ throw new Error("Requested Feature does not exist in account usage");
9617
+ }
9618
+ else {
9619
+ throw new Error("Usage not fetched, please call getUsageReport() before calling hasAccessTo() with usage-based features");
9620
+ }
9621
+ }
9634
9622
  };
9635
9623
  return AccountModel;
9636
9624
  }());
@@ -21,6 +21,7 @@ export declare class AccountModel {
21
21
  usage?: TAccountReport;
22
22
  constructor(params: Partial<TAccountModel> & {
23
23
  isMainAccount?: boolean;
24
+ usage?: TAccountReport;
24
25
  });
25
26
  toJson(): any;
26
27
  set<T extends keyof this>(property: T, value: this[T]): void;
@@ -39,6 +40,6 @@ export declare class AccountModel {
39
40
  feature: keyof TAccountLimits;
40
41
  partnerBrand?: TBrand;
41
42
  userCount?: number;
42
- }): Promise<boolean>;
43
+ }): boolean;
43
44
  }
44
45
  export * from "./types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cakemail-org/ui-components-v2",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "ui library kit made with material UI",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",