@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
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
return
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
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
|
-
}):
|
|
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
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
return
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
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
|
-
}):
|
|
43
|
+
}): boolean;
|
|
43
44
|
}
|
|
44
45
|
export * from "./types";
|