@cakemail-org/ui-components-v2 2.0.99 → 2.1.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/dist/cjs/index.js +127 -62
- package/dist/cjs/models/account/index.d.ts +10 -2
- package/dist/cjs/models/form/index.d.ts +1 -1
- package/dist/cjs/utils/components.d.ts +1 -1
- package/dist/esm/index.js +127 -62
- package/dist/esm/models/account/index.d.ts +10 -2
- package/dist/esm/models/form/index.d.ts +1 -1
- package/dist/esm/utils/components.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2746,11 +2746,15 @@ function ElementContains(element, target) {
|
|
|
2746
2746
|
}
|
|
2747
2747
|
return false;
|
|
2748
2748
|
}
|
|
2749
|
-
function modelToJson(model) {
|
|
2749
|
+
function modelToJson(model, exclude) {
|
|
2750
|
+
if (exclude === void 0) { exclude = []; }
|
|
2750
2751
|
var obj = {};
|
|
2751
2752
|
Object.keys(model).forEach(function (key) {
|
|
2752
2753
|
var _a;
|
|
2753
2754
|
var value = model[key];
|
|
2755
|
+
if (exclude.includes(key)) {
|
|
2756
|
+
return;
|
|
2757
|
+
}
|
|
2754
2758
|
if (value != null && typeof value === "object") {
|
|
2755
2759
|
if (((_a = Object.keys(value)) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
2756
2760
|
obj[key] = value;
|
|
@@ -9497,17 +9501,33 @@ var AccountModel = /** @class */ (function () {
|
|
|
9497
9501
|
this.overrides = params.overrides || {};
|
|
9498
9502
|
this.stripe_customer_id = params.stripe_customer_id || "";
|
|
9499
9503
|
this.metadata = params.metadata || {};
|
|
9504
|
+
if (params.isMainAccount) {
|
|
9505
|
+
this.getUsageReport();
|
|
9506
|
+
}
|
|
9500
9507
|
}
|
|
9501
9508
|
AccountModel.prototype.toJson = function () {
|
|
9502
|
-
return modelToJson(this);
|
|
9509
|
+
return modelToJson(this, ["usage"]);
|
|
9503
9510
|
};
|
|
9504
9511
|
AccountModel.prototype.set = function (property, value) {
|
|
9505
9512
|
modelSet(this, property, value);
|
|
9506
9513
|
};
|
|
9514
|
+
AccountModel.prototype.getUsageReport = function () {
|
|
9515
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
9516
|
+
var _this = this;
|
|
9517
|
+
return __generator(this, function (_a) {
|
|
9518
|
+
return [2 /*return*/, this.getReport({}).then(function (report) {
|
|
9519
|
+
_this.usage = report;
|
|
9520
|
+
})];
|
|
9521
|
+
});
|
|
9522
|
+
});
|
|
9523
|
+
};
|
|
9507
9524
|
AccountModel.prototype.getReport = function (_a) {
|
|
9508
9525
|
return __awaiter(this, void 0, void 0, function () {
|
|
9509
9526
|
var options = __rest(_a, []);
|
|
9510
9527
|
return __generator(this, function (_b) {
|
|
9528
|
+
if (!this.id) {
|
|
9529
|
+
throw new Error("Account was not initialized");
|
|
9530
|
+
}
|
|
9511
9531
|
return [2 /*return*/, getAccountReport(__assign(__assign({}, options), { accountId: this.id })).then(function (result) {
|
|
9512
9532
|
return result.data;
|
|
9513
9533
|
})];
|
|
@@ -9518,6 +9538,9 @@ var AccountModel = /** @class */ (function () {
|
|
|
9518
9538
|
return __awaiter(this, arguments, void 0, function (byContext) {
|
|
9519
9539
|
if (byContext === void 0) { byContext = true; }
|
|
9520
9540
|
return __generator(this, function (_a) {
|
|
9541
|
+
if (!this.id) {
|
|
9542
|
+
throw new Error("Account was not initialized");
|
|
9543
|
+
}
|
|
9521
9544
|
return [2 /*return*/, impersonateService({ id: this.id, byContext: byContext })];
|
|
9522
9545
|
});
|
|
9523
9546
|
});
|
|
@@ -9525,6 +9548,9 @@ var AccountModel = /** @class */ (function () {
|
|
|
9525
9548
|
AccountModel.prototype.getDomains = function () {
|
|
9526
9549
|
return __awaiter(this, void 0, void 0, function () {
|
|
9527
9550
|
return __generator(this, function (_a) {
|
|
9551
|
+
if (!this.id) {
|
|
9552
|
+
throw new Error("Account was not initialized");
|
|
9553
|
+
}
|
|
9528
9554
|
return [2 /*return*/, getDomainsService({ id: this.id }).then(function (data) { return data.data; })];
|
|
9529
9555
|
});
|
|
9530
9556
|
});
|
|
@@ -9532,6 +9558,9 @@ var AccountModel = /** @class */ (function () {
|
|
|
9532
9558
|
AccountModel.prototype.getCustomer = function () {
|
|
9533
9559
|
return __awaiter(this, void 0, void 0, function () {
|
|
9534
9560
|
return __generator(this, function (_a) {
|
|
9561
|
+
if (!this.id) {
|
|
9562
|
+
throw new Error("Account was not initialized");
|
|
9563
|
+
}
|
|
9535
9564
|
return [2 /*return*/, BillingFactory.get({ id: this.id })];
|
|
9536
9565
|
});
|
|
9537
9566
|
});
|
|
@@ -9539,6 +9568,9 @@ var AccountModel = /** @class */ (function () {
|
|
|
9539
9568
|
AccountModel.prototype.update = function (account) {
|
|
9540
9569
|
return __awaiter(this, void 0, void 0, function () {
|
|
9541
9570
|
return __generator(this, function (_a) {
|
|
9571
|
+
if (!this.id) {
|
|
9572
|
+
throw new Error("Account was not initialized");
|
|
9573
|
+
}
|
|
9542
9574
|
trackEvent(exports.EEvents.ACCOUNT_UPDATED, {
|
|
9543
9575
|
id: account === null || account === void 0 ? void 0 : account.id,
|
|
9544
9576
|
address: account === null || account === void 0 ? void 0 : account.address,
|
|
@@ -9568,45 +9600,57 @@ var AccountModel = /** @class */ (function () {
|
|
|
9568
9600
|
AccountModel.prototype.isPartnerOrOrganization = function () {
|
|
9569
9601
|
return this.partner || this.organization;
|
|
9570
9602
|
};
|
|
9571
|
-
AccountModel.prototype.hasAccessTo = function (
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9603
|
+
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*/];
|
|
9651
|
+
}
|
|
9652
|
+
});
|
|
9653
|
+
});
|
|
9610
9654
|
};
|
|
9611
9655
|
return AccountModel;
|
|
9612
9656
|
}());
|
|
@@ -10478,7 +10522,7 @@ var GenericWrapperContext = React.createContext({
|
|
|
10478
10522
|
function GenericWrapper(_a) {
|
|
10479
10523
|
var children = _a.children, brandObj = _a.brandObj, userBrandObj = _a.userBrandObj, brandId = _a.brandId, brandHost = _a.brandHost, account = _a.account, user = _a.user, _b = _a.setPageHead, setPageHead = _b === void 0 ? true : _b, _c = _a.setPostHog, setPostHog = _c === void 0 ? true : _c, LocizeInitializer = _a.LocizeInitializer, brandThemeContext = _a.brandThemeContext, proxyUrl = _a.proxyUrl, _d = _a.styleOverride, styleOverride = _d === void 0 ? {} : _d, _e = _a.includeHandlers, includeHandlers = _e === void 0 ? true : _e;
|
|
10480
10524
|
var _f = React.useState(brandObj ? buildMUITheme({ brand: brandObj }) : undefined), mUITheme = _f[0], setMUITheme = _f[1];
|
|
10481
|
-
var _g = React.useState(brandObj),
|
|
10525
|
+
var _g = React.useState(brandObj), partnerBrand = _g[0], setPartnerBrand = _g[1];
|
|
10482
10526
|
var _h = React.useState(userBrandObj), userBrand = _h[0], setUserBrand = _h[1];
|
|
10483
10527
|
var _j = reactI18next.useTranslation(); _j.t; _j.i18n;
|
|
10484
10528
|
var dialogRef = React.useRef(undefined);
|
|
@@ -10493,7 +10537,7 @@ function GenericWrapper(_a) {
|
|
|
10493
10537
|
var _a, _b;
|
|
10494
10538
|
if (user) {
|
|
10495
10539
|
//@ts-ignore
|
|
10496
|
-
var locale = getBestLocalMatch((_a = user === null || user === void 0 ? void 0 : user.language) === null || _a === void 0 ? void 0 : _a.replace("_", "-"), (_b =
|
|
10540
|
+
var locale = getBestLocalMatch((_a = user === null || user === void 0 ? void 0 : user.language) === null || _a === void 0 ? void 0 : _a.replace("_", "-"), (_b = partnerBrand === null || partnerBrand === void 0 ? void 0 : partnerBrand.client_config) === null || _b === void 0 ? void 0 : _b.languages);
|
|
10497
10541
|
if (LocizeInitializer) {
|
|
10498
10542
|
LocizeInitializer.changeLanguage(locale);
|
|
10499
10543
|
}
|
|
@@ -10537,13 +10581,13 @@ function GenericWrapper(_a) {
|
|
|
10537
10581
|
}
|
|
10538
10582
|
var content = React.createElement(BrandWrapper, { MUITheme: mUITheme, brandId: brandId, styleOverride: styleOverride, brandHost: brandHost, onBrandSuccess: function (compiledBrand, theme) {
|
|
10539
10583
|
initPH(compiledBrand);
|
|
10540
|
-
|
|
10584
|
+
setPartnerBrand(compiledBrand);
|
|
10541
10585
|
setMUITheme(theme);
|
|
10542
10586
|
}, onBrandError: function () {
|
|
10543
10587
|
setMUITheme(buildMUITheme({ brand: whiteLabelBrand }));
|
|
10544
|
-
}, noFetch: !!brandObj, setPageHead: setPageHead, brandThemeContext: brandThemeContext, includeHandlers: false },
|
|
10588
|
+
}, noFetch: !!brandObj, setPageHead: setPageHead, brandThemeContext: brandThemeContext, includeHandlers: false }, partnerBrand &&
|
|
10545
10589
|
React.createElement(GenericWrapperContext.Provider, { value: {
|
|
10546
|
-
partnerBrand:
|
|
10590
|
+
partnerBrand: partnerBrand,
|
|
10547
10591
|
userBrand: userBrand,
|
|
10548
10592
|
account: account ? new AccountModel(account) : new AccountModel({}),
|
|
10549
10593
|
user: user ? new UserModel(user) : new UserModel({})
|
|
@@ -17108,28 +17152,37 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17108
17152
|
__extends(SummaryEnhancedFormModel, _super);
|
|
17109
17153
|
function SummaryEnhancedFormModel(_a) {
|
|
17110
17154
|
var id = _a.id, list_id = _a.list_id, enabled = _a.enabled, name = _a.name, description = _a.description, tags = _a.tags, post_redirect_url = _a.post_redirect_url, double_opt_in = _a.double_opt_in, double_opt_in_redirect_url = _a.double_opt_in_redirect_url, submission_url = _a.submission_url, async_processing = _a.async_processing, branding = _a.branding, created_on = _a.created_on, updated_on = _a.updated_on, published_on = _a.published_on, edited_by = _a.edited_by, thumbnail_url = _a.thumbnail_url, recaptcha = _a.recaptcha, published_url = _a.published_url;
|
|
17111
|
-
var _this = _super.call(this, { id: id, name: name, list_id: list_id, double_opt_in: double_opt_in }) || this;
|
|
17112
|
-
_this.enabled = enabled;
|
|
17113
|
-
_this.description = description;
|
|
17114
|
-
_this.tags = tags;
|
|
17115
|
-
_this.post_redirect_url = post_redirect_url;
|
|
17116
|
-
_this.double_opt_in_redirect_url = double_opt_in_redirect_url;
|
|
17117
|
-
_this.submission_url = submission_url;
|
|
17118
|
-
_this.async_processing = async_processing;
|
|
17119
|
-
_this.branding = branding;
|
|
17120
|
-
_this.created_on = created_on;
|
|
17121
|
-
_this.updated_on = updated_on;
|
|
17122
|
-
_this.published_on = published_on;
|
|
17123
|
-
_this.edited_by = edited_by
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17155
|
+
var _this = _super.call(this, { id: id || "", name: name || "", list_id: list_id || 0, double_opt_in: double_opt_in || true }) || this;
|
|
17156
|
+
_this.enabled = enabled || true;
|
|
17157
|
+
_this.description = description || "";
|
|
17158
|
+
_this.tags = tags || [];
|
|
17159
|
+
_this.post_redirect_url = post_redirect_url || "";
|
|
17160
|
+
_this.double_opt_in_redirect_url = double_opt_in_redirect_url || "";
|
|
17161
|
+
_this.submission_url = submission_url || "";
|
|
17162
|
+
_this.async_processing = async_processing || false;
|
|
17163
|
+
_this.branding = branding || "";
|
|
17164
|
+
_this.created_on = created_on || 0;
|
|
17165
|
+
_this.updated_on = updated_on || 0;
|
|
17166
|
+
_this.published_on = published_on || 0;
|
|
17167
|
+
_this.edited_by = edited_by || {
|
|
17168
|
+
id: 0,
|
|
17169
|
+
email: ""
|
|
17170
|
+
};
|
|
17171
|
+
_this.thumbnail_url = thumbnail_url || "";
|
|
17172
|
+
_this.recaptcha = recaptcha || {
|
|
17173
|
+
secret: "",
|
|
17174
|
+
domain: ""
|
|
17175
|
+
};
|
|
17176
|
+
_this.published_url = published_url || "";
|
|
17127
17177
|
return _this;
|
|
17128
17178
|
}
|
|
17129
17179
|
SummaryEnhancedFormModel.prototype.enable = function () {
|
|
17130
17180
|
return __awaiter(this, void 0, void 0, function () {
|
|
17131
17181
|
var _this = this;
|
|
17132
17182
|
return __generator(this, function (_a) {
|
|
17183
|
+
if (!this.id) {
|
|
17184
|
+
throw new Error("Form was not initialized");
|
|
17185
|
+
}
|
|
17133
17186
|
return [2 /*return*/, enableForm({ id: this.id.toString() }).then(function (data) {
|
|
17134
17187
|
trackEvent(exports.EEvents.FORM_ENABLED, { id: _this.id });
|
|
17135
17188
|
return data.data;
|
|
@@ -17141,6 +17194,9 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17141
17194
|
return __awaiter(this, void 0, void 0, function () {
|
|
17142
17195
|
var _this = this;
|
|
17143
17196
|
return __generator(this, function (_a) {
|
|
17197
|
+
if (!this.id) {
|
|
17198
|
+
throw new Error("Form was not initialized");
|
|
17199
|
+
}
|
|
17144
17200
|
return [2 /*return*/, disableForm({ id: this.id.toString() }).then(function (data) {
|
|
17145
17201
|
trackEvent(exports.EEvents.FORM_DISABLED, { id: _this.id });
|
|
17146
17202
|
return data.data;
|
|
@@ -17152,6 +17208,9 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17152
17208
|
return __awaiter(this, void 0, void 0, function () {
|
|
17153
17209
|
var _this = this;
|
|
17154
17210
|
return __generator(this, function (_a) {
|
|
17211
|
+
if (!this.id) {
|
|
17212
|
+
throw new Error("Form was not initialized");
|
|
17213
|
+
}
|
|
17155
17214
|
return [2 /*return*/, publishForm({ id: this.id.toString() }).then(function (data) {
|
|
17156
17215
|
trackEvent(exports.EEvents.FORM_PUBLISHED, { id: _this.id });
|
|
17157
17216
|
return data.data;
|
|
@@ -17164,6 +17223,9 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17164
17223
|
var _this = this;
|
|
17165
17224
|
if (published === void 0) { published = false; }
|
|
17166
17225
|
return __generator(this, function (_a) {
|
|
17226
|
+
if (!this.id) {
|
|
17227
|
+
throw new Error("Form was not initialized");
|
|
17228
|
+
}
|
|
17167
17229
|
return [2 /*return*/, renderForm({ id: this.id.toString(), published: published }).then(function (data) {
|
|
17168
17230
|
trackEvent(published ? exports.EEvents.FORM_RENDERED_PUBLISHED : exports.EEvents.FORM_RENDERED, { id: _this.id });
|
|
17169
17231
|
return data.data;
|
|
@@ -17175,6 +17237,9 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17175
17237
|
return __awaiter(this, void 0, void 0, function () {
|
|
17176
17238
|
var _this = this;
|
|
17177
17239
|
return __generator(this, function (_a) {
|
|
17240
|
+
if (!this.id) {
|
|
17241
|
+
throw new Error("Form was not initialized");
|
|
17242
|
+
}
|
|
17178
17243
|
return [2 /*return*/, patchForm({ id: this.id.toString(), data: this.toJson() }).then(function (data) {
|
|
17179
17244
|
trackEvent(exports.EEvents.FORM_UPDATED, { id: _this.id });
|
|
17180
17245
|
return data.data;
|
|
@@ -18,9 +18,13 @@ export declare class AccountModel {
|
|
|
18
18
|
overrides: any;
|
|
19
19
|
stripe_customer_id: string;
|
|
20
20
|
metadata: any;
|
|
21
|
-
|
|
21
|
+
usage?: TAccountReport;
|
|
22
|
+
constructor(params: Partial<TAccountModel> & {
|
|
23
|
+
isMainAccount?: boolean;
|
|
24
|
+
});
|
|
22
25
|
toJson(): any;
|
|
23
26
|
set<T extends keyof this>(property: T, value: this[T]): void;
|
|
27
|
+
getUsageReport(): Promise<void>;
|
|
24
28
|
getReport({ ...options }: TGetAccountReport): Promise<TAccountReport>;
|
|
25
29
|
impersonate(byContext?: boolean): Promise<any>;
|
|
26
30
|
getDomains(): Promise<TAccountDomains>;
|
|
@@ -31,6 +35,10 @@ export declare class AccountModel {
|
|
|
31
35
|
}>;
|
|
32
36
|
logOut(): Promise<any>;
|
|
33
37
|
isPartnerOrOrganization(): boolean;
|
|
34
|
-
hasAccessTo(feature
|
|
38
|
+
hasAccessTo({ feature, partnerBrand, userCount }: {
|
|
39
|
+
feature: keyof TAccountLimits;
|
|
40
|
+
partnerBrand?: TBrand;
|
|
41
|
+
userCount?: number;
|
|
42
|
+
}): Promise<boolean>;
|
|
35
43
|
}
|
|
36
44
|
export * from "./types";
|
|
@@ -54,7 +54,7 @@ export declare class SummaryEnhancedFormModel extends CommonFormModel {
|
|
|
54
54
|
readonly edited_by: TEnhancedFormEditedBy;
|
|
55
55
|
readonly thumbnail_url: string;
|
|
56
56
|
readonly published_url: string;
|
|
57
|
-
constructor({ id, list_id, enabled, name, description, tags, post_redirect_url, double_opt_in, double_opt_in_redirect_url, submission_url, async_processing, branding, created_on, updated_on, published_on, edited_by, thumbnail_url, recaptcha, published_url }: TSummaryEnhancedFormModel);
|
|
57
|
+
constructor({ id, list_id, enabled, name, description, tags, post_redirect_url, double_opt_in, double_opt_in_redirect_url, submission_url, async_processing, branding, created_on, updated_on, published_on, edited_by, thumbnail_url, recaptcha, published_url }: Partial<TSummaryEnhancedFormModel>);
|
|
58
58
|
enable(): Promise<EnhancedFormModel>;
|
|
59
59
|
disable(): Promise<EnhancedFormModel>;
|
|
60
60
|
publish(): Promise<EnhancedFormModel>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function ElementContains(element: HTMLElement, target: Node): boolean;
|
|
2
|
-
export declare function modelToJson<T extends Record<string, any>>(model: T): any;
|
|
2
|
+
export declare function modelToJson<T extends Record<string, any>>(model: T, exclude?: string[]): any;
|
|
3
3
|
export declare function modelSet<T extends Record<string, any>>(model: T, property: string | number | symbol, value: any): void;
|
package/dist/esm/index.js
CHANGED
|
@@ -2726,11 +2726,15 @@ function ElementContains(element, target) {
|
|
|
2726
2726
|
}
|
|
2727
2727
|
return false;
|
|
2728
2728
|
}
|
|
2729
|
-
function modelToJson(model) {
|
|
2729
|
+
function modelToJson(model, exclude) {
|
|
2730
|
+
if (exclude === void 0) { exclude = []; }
|
|
2730
2731
|
var obj = {};
|
|
2731
2732
|
Object.keys(model).forEach(function (key) {
|
|
2732
2733
|
var _a;
|
|
2733
2734
|
var value = model[key];
|
|
2735
|
+
if (exclude.includes(key)) {
|
|
2736
|
+
return;
|
|
2737
|
+
}
|
|
2734
2738
|
if (value != null && typeof value === "object") {
|
|
2735
2739
|
if (((_a = Object.keys(value)) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
2736
2740
|
obj[key] = value;
|
|
@@ -9477,17 +9481,33 @@ var AccountModel = /** @class */ (function () {
|
|
|
9477
9481
|
this.overrides = params.overrides || {};
|
|
9478
9482
|
this.stripe_customer_id = params.stripe_customer_id || "";
|
|
9479
9483
|
this.metadata = params.metadata || {};
|
|
9484
|
+
if (params.isMainAccount) {
|
|
9485
|
+
this.getUsageReport();
|
|
9486
|
+
}
|
|
9480
9487
|
}
|
|
9481
9488
|
AccountModel.prototype.toJson = function () {
|
|
9482
|
-
return modelToJson(this);
|
|
9489
|
+
return modelToJson(this, ["usage"]);
|
|
9483
9490
|
};
|
|
9484
9491
|
AccountModel.prototype.set = function (property, value) {
|
|
9485
9492
|
modelSet(this, property, value);
|
|
9486
9493
|
};
|
|
9494
|
+
AccountModel.prototype.getUsageReport = function () {
|
|
9495
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
9496
|
+
var _this = this;
|
|
9497
|
+
return __generator(this, function (_a) {
|
|
9498
|
+
return [2 /*return*/, this.getReport({}).then(function (report) {
|
|
9499
|
+
_this.usage = report;
|
|
9500
|
+
})];
|
|
9501
|
+
});
|
|
9502
|
+
});
|
|
9503
|
+
};
|
|
9487
9504
|
AccountModel.prototype.getReport = function (_a) {
|
|
9488
9505
|
return __awaiter(this, void 0, void 0, function () {
|
|
9489
9506
|
var options = __rest(_a, []);
|
|
9490
9507
|
return __generator(this, function (_b) {
|
|
9508
|
+
if (!this.id) {
|
|
9509
|
+
throw new Error("Account was not initialized");
|
|
9510
|
+
}
|
|
9491
9511
|
return [2 /*return*/, getAccountReport(__assign(__assign({}, options), { accountId: this.id })).then(function (result) {
|
|
9492
9512
|
return result.data;
|
|
9493
9513
|
})];
|
|
@@ -9498,6 +9518,9 @@ var AccountModel = /** @class */ (function () {
|
|
|
9498
9518
|
return __awaiter(this, arguments, void 0, function (byContext) {
|
|
9499
9519
|
if (byContext === void 0) { byContext = true; }
|
|
9500
9520
|
return __generator(this, function (_a) {
|
|
9521
|
+
if (!this.id) {
|
|
9522
|
+
throw new Error("Account was not initialized");
|
|
9523
|
+
}
|
|
9501
9524
|
return [2 /*return*/, impersonateService({ id: this.id, byContext: byContext })];
|
|
9502
9525
|
});
|
|
9503
9526
|
});
|
|
@@ -9505,6 +9528,9 @@ var AccountModel = /** @class */ (function () {
|
|
|
9505
9528
|
AccountModel.prototype.getDomains = function () {
|
|
9506
9529
|
return __awaiter(this, void 0, void 0, function () {
|
|
9507
9530
|
return __generator(this, function (_a) {
|
|
9531
|
+
if (!this.id) {
|
|
9532
|
+
throw new Error("Account was not initialized");
|
|
9533
|
+
}
|
|
9508
9534
|
return [2 /*return*/, getDomainsService({ id: this.id }).then(function (data) { return data.data; })];
|
|
9509
9535
|
});
|
|
9510
9536
|
});
|
|
@@ -9512,6 +9538,9 @@ var AccountModel = /** @class */ (function () {
|
|
|
9512
9538
|
AccountModel.prototype.getCustomer = function () {
|
|
9513
9539
|
return __awaiter(this, void 0, void 0, function () {
|
|
9514
9540
|
return __generator(this, function (_a) {
|
|
9541
|
+
if (!this.id) {
|
|
9542
|
+
throw new Error("Account was not initialized");
|
|
9543
|
+
}
|
|
9515
9544
|
return [2 /*return*/, BillingFactory.get({ id: this.id })];
|
|
9516
9545
|
});
|
|
9517
9546
|
});
|
|
@@ -9519,6 +9548,9 @@ var AccountModel = /** @class */ (function () {
|
|
|
9519
9548
|
AccountModel.prototype.update = function (account) {
|
|
9520
9549
|
return __awaiter(this, void 0, void 0, function () {
|
|
9521
9550
|
return __generator(this, function (_a) {
|
|
9551
|
+
if (!this.id) {
|
|
9552
|
+
throw new Error("Account was not initialized");
|
|
9553
|
+
}
|
|
9522
9554
|
trackEvent(EEvents.ACCOUNT_UPDATED, {
|
|
9523
9555
|
id: account === null || account === void 0 ? void 0 : account.id,
|
|
9524
9556
|
address: account === null || account === void 0 ? void 0 : account.address,
|
|
@@ -9548,45 +9580,57 @@ var AccountModel = /** @class */ (function () {
|
|
|
9548
9580
|
AccountModel.prototype.isPartnerOrOrganization = function () {
|
|
9549
9581
|
return this.partner || this.organization;
|
|
9550
9582
|
};
|
|
9551
|
-
AccountModel.prototype.hasAccessTo = function (
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9583
|
+
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*/];
|
|
9631
|
+
}
|
|
9632
|
+
});
|
|
9633
|
+
});
|
|
9590
9634
|
};
|
|
9591
9635
|
return AccountModel;
|
|
9592
9636
|
}());
|
|
@@ -10458,7 +10502,7 @@ var GenericWrapperContext = createContext({
|
|
|
10458
10502
|
function GenericWrapper(_a) {
|
|
10459
10503
|
var children = _a.children, brandObj = _a.brandObj, userBrandObj = _a.userBrandObj, brandId = _a.brandId, brandHost = _a.brandHost, account = _a.account, user = _a.user, _b = _a.setPageHead, setPageHead = _b === void 0 ? true : _b, _c = _a.setPostHog, setPostHog = _c === void 0 ? true : _c, LocizeInitializer = _a.LocizeInitializer, brandThemeContext = _a.brandThemeContext, proxyUrl = _a.proxyUrl, _d = _a.styleOverride, styleOverride = _d === void 0 ? {} : _d, _e = _a.includeHandlers, includeHandlers = _e === void 0 ? true : _e;
|
|
10460
10504
|
var _f = useState(brandObj ? buildMUITheme({ brand: brandObj }) : undefined), mUITheme = _f[0], setMUITheme = _f[1];
|
|
10461
|
-
var _g = useState(brandObj),
|
|
10505
|
+
var _g = useState(brandObj), partnerBrand = _g[0], setPartnerBrand = _g[1];
|
|
10462
10506
|
var _h = useState(userBrandObj), userBrand = _h[0], setUserBrand = _h[1];
|
|
10463
10507
|
var _j = useTranslation(); _j.t; _j.i18n;
|
|
10464
10508
|
var dialogRef = useRef(undefined);
|
|
@@ -10473,7 +10517,7 @@ function GenericWrapper(_a) {
|
|
|
10473
10517
|
var _a, _b;
|
|
10474
10518
|
if (user) {
|
|
10475
10519
|
//@ts-ignore
|
|
10476
|
-
var locale = getBestLocalMatch((_a = user === null || user === void 0 ? void 0 : user.language) === null || _a === void 0 ? void 0 : _a.replace("_", "-"), (_b =
|
|
10520
|
+
var locale = getBestLocalMatch((_a = user === null || user === void 0 ? void 0 : user.language) === null || _a === void 0 ? void 0 : _a.replace("_", "-"), (_b = partnerBrand === null || partnerBrand === void 0 ? void 0 : partnerBrand.client_config) === null || _b === void 0 ? void 0 : _b.languages);
|
|
10477
10521
|
if (LocizeInitializer) {
|
|
10478
10522
|
LocizeInitializer.changeLanguage(locale);
|
|
10479
10523
|
}
|
|
@@ -10517,13 +10561,13 @@ function GenericWrapper(_a) {
|
|
|
10517
10561
|
}
|
|
10518
10562
|
var content = React__default.createElement(BrandWrapper, { MUITheme: mUITheme, brandId: brandId, styleOverride: styleOverride, brandHost: brandHost, onBrandSuccess: function (compiledBrand, theme) {
|
|
10519
10563
|
initPH(compiledBrand);
|
|
10520
|
-
|
|
10564
|
+
setPartnerBrand(compiledBrand);
|
|
10521
10565
|
setMUITheme(theme);
|
|
10522
10566
|
}, onBrandError: function () {
|
|
10523
10567
|
setMUITheme(buildMUITheme({ brand: whiteLabelBrand }));
|
|
10524
|
-
}, noFetch: !!brandObj, setPageHead: setPageHead, brandThemeContext: brandThemeContext, includeHandlers: false },
|
|
10568
|
+
}, noFetch: !!brandObj, setPageHead: setPageHead, brandThemeContext: brandThemeContext, includeHandlers: false }, partnerBrand &&
|
|
10525
10569
|
React__default.createElement(GenericWrapperContext.Provider, { value: {
|
|
10526
|
-
partnerBrand:
|
|
10570
|
+
partnerBrand: partnerBrand,
|
|
10527
10571
|
userBrand: userBrand,
|
|
10528
10572
|
account: account ? new AccountModel(account) : new AccountModel({}),
|
|
10529
10573
|
user: user ? new UserModel(user) : new UserModel({})
|
|
@@ -17088,28 +17132,37 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17088
17132
|
__extends(SummaryEnhancedFormModel, _super);
|
|
17089
17133
|
function SummaryEnhancedFormModel(_a) {
|
|
17090
17134
|
var id = _a.id, list_id = _a.list_id, enabled = _a.enabled, name = _a.name, description = _a.description, tags = _a.tags, post_redirect_url = _a.post_redirect_url, double_opt_in = _a.double_opt_in, double_opt_in_redirect_url = _a.double_opt_in_redirect_url, submission_url = _a.submission_url, async_processing = _a.async_processing, branding = _a.branding, created_on = _a.created_on, updated_on = _a.updated_on, published_on = _a.published_on, edited_by = _a.edited_by, thumbnail_url = _a.thumbnail_url, recaptcha = _a.recaptcha, published_url = _a.published_url;
|
|
17091
|
-
var _this = _super.call(this, { id: id, name: name, list_id: list_id, double_opt_in: double_opt_in }) || this;
|
|
17092
|
-
_this.enabled = enabled;
|
|
17093
|
-
_this.description = description;
|
|
17094
|
-
_this.tags = tags;
|
|
17095
|
-
_this.post_redirect_url = post_redirect_url;
|
|
17096
|
-
_this.double_opt_in_redirect_url = double_opt_in_redirect_url;
|
|
17097
|
-
_this.submission_url = submission_url;
|
|
17098
|
-
_this.async_processing = async_processing;
|
|
17099
|
-
_this.branding = branding;
|
|
17100
|
-
_this.created_on = created_on;
|
|
17101
|
-
_this.updated_on = updated_on;
|
|
17102
|
-
_this.published_on = published_on;
|
|
17103
|
-
_this.edited_by = edited_by
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17135
|
+
var _this = _super.call(this, { id: id || "", name: name || "", list_id: list_id || 0, double_opt_in: double_opt_in || true }) || this;
|
|
17136
|
+
_this.enabled = enabled || true;
|
|
17137
|
+
_this.description = description || "";
|
|
17138
|
+
_this.tags = tags || [];
|
|
17139
|
+
_this.post_redirect_url = post_redirect_url || "";
|
|
17140
|
+
_this.double_opt_in_redirect_url = double_opt_in_redirect_url || "";
|
|
17141
|
+
_this.submission_url = submission_url || "";
|
|
17142
|
+
_this.async_processing = async_processing || false;
|
|
17143
|
+
_this.branding = branding || "";
|
|
17144
|
+
_this.created_on = created_on || 0;
|
|
17145
|
+
_this.updated_on = updated_on || 0;
|
|
17146
|
+
_this.published_on = published_on || 0;
|
|
17147
|
+
_this.edited_by = edited_by || {
|
|
17148
|
+
id: 0,
|
|
17149
|
+
email: ""
|
|
17150
|
+
};
|
|
17151
|
+
_this.thumbnail_url = thumbnail_url || "";
|
|
17152
|
+
_this.recaptcha = recaptcha || {
|
|
17153
|
+
secret: "",
|
|
17154
|
+
domain: ""
|
|
17155
|
+
};
|
|
17156
|
+
_this.published_url = published_url || "";
|
|
17107
17157
|
return _this;
|
|
17108
17158
|
}
|
|
17109
17159
|
SummaryEnhancedFormModel.prototype.enable = function () {
|
|
17110
17160
|
return __awaiter(this, void 0, void 0, function () {
|
|
17111
17161
|
var _this = this;
|
|
17112
17162
|
return __generator(this, function (_a) {
|
|
17163
|
+
if (!this.id) {
|
|
17164
|
+
throw new Error("Form was not initialized");
|
|
17165
|
+
}
|
|
17113
17166
|
return [2 /*return*/, enableForm({ id: this.id.toString() }).then(function (data) {
|
|
17114
17167
|
trackEvent(EEvents.FORM_ENABLED, { id: _this.id });
|
|
17115
17168
|
return data.data;
|
|
@@ -17121,6 +17174,9 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17121
17174
|
return __awaiter(this, void 0, void 0, function () {
|
|
17122
17175
|
var _this = this;
|
|
17123
17176
|
return __generator(this, function (_a) {
|
|
17177
|
+
if (!this.id) {
|
|
17178
|
+
throw new Error("Form was not initialized");
|
|
17179
|
+
}
|
|
17124
17180
|
return [2 /*return*/, disableForm({ id: this.id.toString() }).then(function (data) {
|
|
17125
17181
|
trackEvent(EEvents.FORM_DISABLED, { id: _this.id });
|
|
17126
17182
|
return data.data;
|
|
@@ -17132,6 +17188,9 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17132
17188
|
return __awaiter(this, void 0, void 0, function () {
|
|
17133
17189
|
var _this = this;
|
|
17134
17190
|
return __generator(this, function (_a) {
|
|
17191
|
+
if (!this.id) {
|
|
17192
|
+
throw new Error("Form was not initialized");
|
|
17193
|
+
}
|
|
17135
17194
|
return [2 /*return*/, publishForm({ id: this.id.toString() }).then(function (data) {
|
|
17136
17195
|
trackEvent(EEvents.FORM_PUBLISHED, { id: _this.id });
|
|
17137
17196
|
return data.data;
|
|
@@ -17144,6 +17203,9 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17144
17203
|
var _this = this;
|
|
17145
17204
|
if (published === void 0) { published = false; }
|
|
17146
17205
|
return __generator(this, function (_a) {
|
|
17206
|
+
if (!this.id) {
|
|
17207
|
+
throw new Error("Form was not initialized");
|
|
17208
|
+
}
|
|
17147
17209
|
return [2 /*return*/, renderForm({ id: this.id.toString(), published: published }).then(function (data) {
|
|
17148
17210
|
trackEvent(published ? EEvents.FORM_RENDERED_PUBLISHED : EEvents.FORM_RENDERED, { id: _this.id });
|
|
17149
17211
|
return data.data;
|
|
@@ -17155,6 +17217,9 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
|
|
|
17155
17217
|
return __awaiter(this, void 0, void 0, function () {
|
|
17156
17218
|
var _this = this;
|
|
17157
17219
|
return __generator(this, function (_a) {
|
|
17220
|
+
if (!this.id) {
|
|
17221
|
+
throw new Error("Form was not initialized");
|
|
17222
|
+
}
|
|
17158
17223
|
return [2 /*return*/, patchForm({ id: this.id.toString(), data: this.toJson() }).then(function (data) {
|
|
17159
17224
|
trackEvent(EEvents.FORM_UPDATED, { id: _this.id });
|
|
17160
17225
|
return data.data;
|
|
@@ -18,9 +18,13 @@ export declare class AccountModel {
|
|
|
18
18
|
overrides: any;
|
|
19
19
|
stripe_customer_id: string;
|
|
20
20
|
metadata: any;
|
|
21
|
-
|
|
21
|
+
usage?: TAccountReport;
|
|
22
|
+
constructor(params: Partial<TAccountModel> & {
|
|
23
|
+
isMainAccount?: boolean;
|
|
24
|
+
});
|
|
22
25
|
toJson(): any;
|
|
23
26
|
set<T extends keyof this>(property: T, value: this[T]): void;
|
|
27
|
+
getUsageReport(): Promise<void>;
|
|
24
28
|
getReport({ ...options }: TGetAccountReport): Promise<TAccountReport>;
|
|
25
29
|
impersonate(byContext?: boolean): Promise<any>;
|
|
26
30
|
getDomains(): Promise<TAccountDomains>;
|
|
@@ -31,6 +35,10 @@ export declare class AccountModel {
|
|
|
31
35
|
}>;
|
|
32
36
|
logOut(): Promise<any>;
|
|
33
37
|
isPartnerOrOrganization(): boolean;
|
|
34
|
-
hasAccessTo(feature
|
|
38
|
+
hasAccessTo({ feature, partnerBrand, userCount }: {
|
|
39
|
+
feature: keyof TAccountLimits;
|
|
40
|
+
partnerBrand?: TBrand;
|
|
41
|
+
userCount?: number;
|
|
42
|
+
}): Promise<boolean>;
|
|
35
43
|
}
|
|
36
44
|
export * from "./types";
|
|
@@ -54,7 +54,7 @@ export declare class SummaryEnhancedFormModel extends CommonFormModel {
|
|
|
54
54
|
readonly edited_by: TEnhancedFormEditedBy;
|
|
55
55
|
readonly thumbnail_url: string;
|
|
56
56
|
readonly published_url: string;
|
|
57
|
-
constructor({ id, list_id, enabled, name, description, tags, post_redirect_url, double_opt_in, double_opt_in_redirect_url, submission_url, async_processing, branding, created_on, updated_on, published_on, edited_by, thumbnail_url, recaptcha, published_url }: TSummaryEnhancedFormModel);
|
|
57
|
+
constructor({ id, list_id, enabled, name, description, tags, post_redirect_url, double_opt_in, double_opt_in_redirect_url, submission_url, async_processing, branding, created_on, updated_on, published_on, edited_by, thumbnail_url, recaptcha, published_url }: Partial<TSummaryEnhancedFormModel>);
|
|
58
58
|
enable(): Promise<EnhancedFormModel>;
|
|
59
59
|
disable(): Promise<EnhancedFormModel>;
|
|
60
60
|
publish(): Promise<EnhancedFormModel>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function ElementContains(element: HTMLElement, target: Node): boolean;
|
|
2
|
-
export declare function modelToJson<T extends Record<string, any>>(model: T): any;
|
|
2
|
+
export declare function modelToJson<T extends Record<string, any>>(model: T, exclude?: string[]): any;
|
|
3
3
|
export declare function modelSet<T extends Record<string, any>>(model: T, property: string | number | symbol, value: any): void;
|