@cakemail-org/ui-components-v2 2.0.59 → 2.0.61

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.
@@ -20,14 +20,18 @@ export type TFilterBar = {
20
20
  })[];
21
21
  dropMenuProps?: {
22
22
  tabs?: Pick<TSubNavItem, "name" | "text" | "disabled">[];
23
- actions?: {
24
- tab: string;
25
- text: string;
26
- onClick: TButtonClick;
27
- }[];
28
- emptyTexts?: TFilterBarText[];
29
- titles?: TFilterBarText[];
30
23
  disabledTabs?: string[];
24
+ options?: {
25
+ [tabName: string]: {
26
+ action?: {
27
+ text: string;
28
+ onClick: TButtonClick;
29
+ };
30
+ emptyText?: TFilterBarText;
31
+ title?: TFilterBarText;
32
+ disableLocalSearch?: boolean;
33
+ };
34
+ };
31
35
  };
32
36
  replacePartial?: boolean;
33
37
  onSearchUpdate?: ({ value, tab }: TFilterBarSearchUpdate) => void;
@@ -50,5 +54,4 @@ export type TFilterBarFilterTerm = {
50
54
  export type TFilterBarText = {
51
55
  text?: string;
52
56
  desc?: string;
53
- tab: string;
54
57
  };
@@ -1,9 +1,12 @@
1
- import { FormModel } from "../../models";
1
+ import { EnhancedFormModel, FormModel, SummaryEnhancedFormModel } from "../../models";
2
2
  import { TGenericListParams, TGenericListReturn } from "../../types/services";
3
3
  export declare class FormsFactory {
4
4
  static get({ id }: {
5
5
  id: string;
6
- }): Promise<FormModel>;
7
- static list({ ...options }: TGenericListParams): Promise<TGenericListReturn<FormModel>>;
6
+ }): Promise<FormModel | EnhancedFormModel>;
7
+ static list({ ...options }: TGenericListParams): Promise<TGenericListReturn<FormModel | SummaryEnhancedFormModel>>;
8
+ static create({ form }: {
9
+ form: Partial<FormModel | EnhancedFormModel>;
10
+ }): Promise<EnhancedFormModel | FormModel>;
8
11
  }
9
12
  export * from "./types";
package/dist/cjs/index.js CHANGED
@@ -5243,6 +5243,11 @@ exports.EEvents = void 0;
5243
5243
  EEvents["FORM_CREATED"] = "Form.Created";
5244
5244
  EEvents["FORM_UPDATED"] = "Form.Updated";
5245
5245
  EEvents["FORM_DELETED"] = "Form.Deleted";
5246
+ EEvents["FORM_ENABLED"] = "Form.Enabled";
5247
+ EEvents["FORM_DISABLED"] = "Form.Disabled";
5248
+ EEvents["FORM_PUBLISHED"] = "Form.Published";
5249
+ EEvents["FORM_RENDERED"] = "Form.Rendered";
5250
+ EEvents["FORM_RENDERED_PUBLISHED"] = "Form.Rendered.Published";
5246
5251
  EEvents["AUTOMATION_CREATED"] = "Automation.Created";
5247
5252
  EEvents["AUTOMATION_UPDATED"] = "Automation.Updated";
5248
5253
  EEvents["AUTOMATION_DELETED"] = "Automation.Deleted";
@@ -8748,13 +8753,13 @@ var css_248z$9 = ".filter-bar-component-v2 {\n background: var(--cloud, #F4F4F4
8748
8753
  styleInject(css_248z$9);
8749
8754
 
8750
8755
  function FilterBar(_a) {
8751
- var _b, _c, _d, _e, _f;
8756
+ var _b, _c, _d, _e, _f, _g, _h, _j;
8752
8757
  var operatorOptions = _a.operatorOptions, initOperatorValue = _a.initOperatorValue, operatorValue = _a.operatorValue, onSave = _a.onSave, saveTxt = _a.saveTxt, onClear = _a.onClear, clearTxt = _a.clearTxt, onUpdate = _a.onUpdate, onSearchUpdate = _a.onSearchUpdate, loading = _a.loading, addFilterTxt = _a.addFilterTxt, filterTerms = _a.filterTerms, initFilterTerms = _a.initFilterTerms, dropMenuOptions = _a.dropMenuOptions, dropMenuProps = _a.dropMenuProps, replacePartial = _a.replacePartial;
8753
- var _g = React.useState(false), showSearch = _g[0], setShowSearch = _g[1];
8754
- var _h = React.useState(""), search = _h[0], setSearch = _h[1];
8755
- var _j = React.useState((_c = (_b = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.tabs) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name), selectedTab = _j[0], setSelectedTab = _j[1];
8756
- var _k = React.useState(filterTerms !== undefined ? filterTerms : initFilterTerms !== undefined ? initFilterTerms : []), filterTermState = _k[0], setFilterTermState = _k[1];
8757
- var _l = React.useState(operatorValue !== undefined ? operatorValue : initOperatorValue !== undefined ? initOperatorValue : exports.EOperatorTypes.and), operatorState = _l[0], setOperatorState = _l[1];
8758
+ var _k = React.useState(false), showSearch = _k[0], setShowSearch = _k[1];
8759
+ var _l = React.useState(""), search = _l[0], setSearch = _l[1];
8760
+ var _m = React.useState((_c = (_b = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.tabs) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.name), selectedTab = _m[0], setSelectedTab = _m[1];
8761
+ var _o = React.useState(filterTerms !== undefined ? filterTerms : initFilterTerms !== undefined ? initFilterTerms : []), filterTermState = _o[0], setFilterTermState = _o[1];
8762
+ var _p = React.useState(operatorValue !== undefined ? operatorValue : initOperatorValue !== undefined ? initOperatorValue : exports.EOperatorTypes.and), operatorState = _p[0], setOperatorState = _p[1];
8758
8763
  var cFilterTerms = filterTerms !== undefined ? filterTerms : filterTermState;
8759
8764
  var cOperatorValue = operatorValue !== undefined ? operatorValue : operatorState;
8760
8765
  React.useEffect(handleSearchFocus, [showSearch]);
@@ -8824,23 +8829,26 @@ function FilterBar(_a) {
8824
8829
  function handleFilterSets(event, item) {
8825
8830
  setSelectedTab(item.name);
8826
8831
  }
8827
- // Filter out current pills & search
8828
- dropMenuOptions = dropMenuOptions === null || dropMenuOptions === void 0 ? void 0 : dropMenuOptions.filter(function (i) {
8829
- var _a, _b;
8830
- var item = (_a = cFilterTerms.find(function (cF) { return i.value === cF.value; })) === null || _a === void 0 ? void 0 : _a.value;
8831
- return (i.value !== item || i.value == null) && ((_b = i.value) === null || _b === void 0 ? void 0 : _b.includes(search));
8832
- });
8833
8832
  //Filter current set
8834
8833
  dropMenuOptions = dropMenuOptions === null || dropMenuOptions === void 0 ? void 0 : dropMenuOptions.filter(function (i) {
8835
8834
  return i.tab === selectedTab;
8836
8835
  });
8836
+ // Filter out current pills & search
8837
+ dropMenuOptions = dropMenuOptions === null || dropMenuOptions === void 0 ? void 0 : dropMenuOptions.filter(function (i) {
8838
+ var _a, _b, _c, _d;
8839
+ if ((_b = (_a = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.options) === null || _a === void 0 ? void 0 : _a[i.tab || ""]) === null || _b === void 0 ? void 0 : _b.disableLocalSearch) {
8840
+ return true;
8841
+ }
8842
+ var item = (_c = cFilterTerms.find(function (cF) { return i.value === cF.value; })) === null || _c === void 0 ? void 0 : _c.value;
8843
+ return (i.value !== item || i.value == null) && ((_d = i.value) === null || _d === void 0 ? void 0 : _d.includes(search));
8844
+ });
8837
8845
  //set onClick
8838
8846
  dropMenuOptions = dropMenuOptions === null || dropMenuOptions === void 0 ? void 0 : dropMenuOptions.map(function (i) {
8839
8847
  var _a;
8840
8848
  return __assign(__assign({}, i), { disabled: (_a = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.disabledTabs) === null || _a === void 0 ? void 0 : _a.includes(i.tab), onClick: function () { handleDropMenuClick(i === null || i === void 0 ? void 0 : i.value); } });
8841
8849
  });
8842
8850
  if (dropMenuOptions && (dropMenuOptions === null || dropMenuOptions === void 0 ? void 0 : dropMenuOptions.length) > 0) {
8843
- var foundTitle = (_d = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.titles) === null || _d === void 0 ? void 0 : _d.find(function (title) { return selectedTab === title.tab; });
8851
+ var foundTitle = (_e = (_d = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.options) === null || _d === void 0 ? void 0 : _d[selectedTab || ""]) === null || _e === void 0 ? void 0 : _e.title;
8844
8852
  if (foundTitle) {
8845
8853
  dropMenuOptions.unshift({
8846
8854
  tab: selectedTab || "partial",
@@ -8851,7 +8859,7 @@ function FilterBar(_a) {
8851
8859
  }
8852
8860
  }
8853
8861
  if (dropMenuOptions && (dropMenuOptions === null || dropMenuOptions === void 0 ? void 0 : dropMenuOptions.length) === 0) {
8854
- var foundEmptyText = (_e = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.emptyTexts) === null || _e === void 0 ? void 0 : _e.find(function (text) { return selectedTab === text.tab; });
8862
+ var foundEmptyText = (_g = (_f = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.options) === null || _f === void 0 ? void 0 : _f[selectedTab || ""]) === null || _g === void 0 ? void 0 : _g.emptyText;
8855
8863
  if (foundEmptyText) {
8856
8864
  dropMenuOptions.push({
8857
8865
  tab: selectedTab || "partial",
@@ -8861,7 +8869,7 @@ function FilterBar(_a) {
8861
8869
  });
8862
8870
  }
8863
8871
  }
8864
- var currentActionSet = (_f = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.actions) === null || _f === void 0 ? void 0 : _f.find(function (action) { return selectedTab === action.tab; });
8872
+ var currentAction = (_j = (_h = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.options) === null || _h === void 0 ? void 0 : _h[selectedTab || ""]) === null || _j === void 0 ? void 0 : _j.action;
8865
8873
  if (dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.tabs) {
8866
8874
  dropMenuProps.tabs = dropMenuProps.tabs.map(function (t) {
8867
8875
  var _a;
@@ -8880,15 +8888,14 @@ function FilterBar(_a) {
8880
8888
  React.createElement(material.Stack, { className: "dropMenuContainer" },
8881
8889
  (dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.tabs) && dropMenuProps.tabs.length > 1 && React.createElement(SubNav, { initialSelected: selectedTab, items: dropMenuProps.tabs, onClick: handleFilterSets }),
8882
8890
  React.createElement(DropMenu, { inlineMenu: true, options: dropMenuOptions }),
8883
- currentActionSet && React.createElement(Button, { color: "cloud", onClick: currentActionSet.onClick }, currentActionSet.text)))),
8891
+ currentAction && React.createElement(Button, { color: "cloud", onClick: currentAction.onClick }, currentAction.text)))),
8884
8892
  !showSearch &&
8885
8893
  React.createElement(material.Link, { color: "secondary", onClick: handleShowSearch, alignItems: "center", justifyContent: "center", display: "flex", gap: 3 },
8886
8894
  React.createElement(Icon, { name: "Add18", color: "secondary" }),
8887
8895
  " ",
8888
8896
  addFilterTxt)),
8889
8897
  React.createElement(material.Stack, { direction: "row", className: "pillContainer ".concat(cFilterTerms.length === 0 ? "empty" : ""), alignItems: "center", justifyContent: "flex-start", flex: 1, gap: 2 }, cFilterTerms.map(function (term) {
8890
- var _a;
8891
- var isDisabled = (_a = dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.disabledTabs) === null || _a === void 0 ? void 0 : _a.includes(String(term.tab));
8898
+ var isDisabled = Object.keys((dropMenuProps === null || dropMenuProps === void 0 ? void 0 : dropMenuProps.options) || {}).includes(String(term.tab));
8892
8899
  var isPartial = term.tab === "partial";
8893
8900
  return React.createElement(Chip, { className: isDisabled ? "disabled" : "", label: isPartial ? React.createElement(React.Fragment, null,
8894
8901
  " ",
@@ -9724,6 +9731,16 @@ function getEmail(_a) {
9724
9731
  });
9725
9732
  }
9726
9733
 
9734
+ function createForm(_a) {
9735
+ var form = _a.form;
9736
+ return callApi({
9737
+ url: uiKitConfig.GATEWAY_PROXY + "/forms",
9738
+ fetchOptions: {
9739
+ body: form,
9740
+ method: exports.EMethods.post
9741
+ }
9742
+ });
9743
+ }
9727
9744
  function listForms(_a) {
9728
9745
  var useImpersonationTree = _a.useImpersonationTree, options = __rest(_a, ["useImpersonationTree"]);
9729
9746
  return callApi({
@@ -9735,6 +9752,16 @@ function listForms(_a) {
9735
9752
  useImpersonationTree: useImpersonationTree
9736
9753
  });
9737
9754
  }
9755
+ function patchForm(_a) {
9756
+ var id = _a.id, data = _a.data;
9757
+ return callApi({
9758
+ url: uiKitConfig.GATEWAY_PROXY + "/forms/" + id,
9759
+ fetchOptions: {
9760
+ method: exports.EMethods.patch,
9761
+ body: data
9762
+ }
9763
+ });
9764
+ }
9738
9765
  function getForm(_a) {
9739
9766
  var id = _a.id;
9740
9767
  return callApi({
@@ -9744,6 +9771,52 @@ function getForm(_a) {
9744
9771
  }
9745
9772
  });
9746
9773
  }
9774
+ function deleteForm(_a) {
9775
+ var id = _a.id;
9776
+ return callApi({
9777
+ url: uiKitConfig.GATEWAY_PROXY + "/forms/" + id,
9778
+ fetchOptions: {
9779
+ method: exports.EMethods.delete
9780
+ }
9781
+ });
9782
+ }
9783
+ function enableForm(_a) {
9784
+ var id = _a.id;
9785
+ return callApi({
9786
+ url: uiKitConfig.GATEWAY_PROXY + "/forms/" + id + "/enable",
9787
+ fetchOptions: {
9788
+ method: exports.EMethods.post
9789
+ }
9790
+ });
9791
+ }
9792
+ function disableForm(_a) {
9793
+ var id = _a.id;
9794
+ return callApi({
9795
+ url: uiKitConfig.GATEWAY_PROXY + "/forms/" + id + "/disable",
9796
+ fetchOptions: {
9797
+ method: exports.EMethods.post
9798
+ }
9799
+ });
9800
+ }
9801
+ function publishForm(_a) {
9802
+ var id = _a.id;
9803
+ return callApi({
9804
+ url: uiKitConfig.GATEWAY_PROXY + "/forms/" + id + "/publish",
9805
+ fetchOptions: {
9806
+ method: exports.EMethods.post
9807
+ }
9808
+ });
9809
+ }
9810
+ function renderForm(_a) {
9811
+ var id = _a.id, published = _a.published;
9812
+ return callApi({
9813
+ url: uiKitConfig.GATEWAY_PROXY + "/forms/" + id + "/render",
9814
+ query: camelCase({ published: published }),
9815
+ fetchOptions: {
9816
+ method: exports.EMethods.get
9817
+ }
9818
+ });
9819
+ }
9747
9820
 
9748
9821
  function requestSupportService(_a) {
9749
9822
  var requestOptions = __rest(_a, []);
@@ -16533,22 +16606,48 @@ var EmailAPIFactory = /** @class */ (function () {
16533
16606
  return EmailAPIFactory;
16534
16607
  }());
16535
16608
 
16536
- var FormModel = /** @class */ (function () {
16537
- function FormModel(_a) {
16538
- var id = _a.id, name = _a.name, status = _a.status, content = _a.content, language = _a.language, created_on = _a.created_on, last_updated_on = _a.last_updated_on, url = _a.url, thumbnail_url = _a.thumbnail_url, redirections = _a.redirections, list_id = _a.list_id, double_opt_in = _a.double_opt_in;
16609
+ var CommonFormModel = /** @class */ (function () {
16610
+ function CommonFormModel(_a) {
16611
+ var id = _a.id, name = _a.name, list_id = _a.list_id, double_opt_in = _a.double_opt_in;
16539
16612
  this.id = id;
16540
16613
  this.name = name;
16541
- this.status = status;
16542
- this.content = content;
16543
- this.language = language;
16544
- this.created_on = created_on;
16545
- this.last_updated_on = last_updated_on;
16546
- this.url = url;
16547
- this.thumbnail_url = thumbnail_url;
16548
- this.redirections = redirections;
16549
16614
  this.list_id = list_id;
16550
16615
  this.double_opt_in = double_opt_in;
16551
16616
  }
16617
+ CommonFormModel.prototype.toJson = function () {
16618
+ return modelToJson(this);
16619
+ };
16620
+ CommonFormModel.prototype.set = function (property, value) {
16621
+ modelSet(this, property, value);
16622
+ };
16623
+ CommonFormModel.prototype.delete = function () {
16624
+ return __awaiter(this, void 0, void 0, function () {
16625
+ var _this = this;
16626
+ return __generator(this, function (_a) {
16627
+ return [2 /*return*/, deleteForm({ id: this.id.toString() }).then(function (data) {
16628
+ trackEvent(exports.EEvents.FORM_DELETED, { id: _this.id });
16629
+ return data;
16630
+ })];
16631
+ });
16632
+ });
16633
+ };
16634
+ return CommonFormModel;
16635
+ }());
16636
+ var FormModel = /** @class */ (function (_super) {
16637
+ __extends(FormModel, _super);
16638
+ function FormModel(_a) {
16639
+ var id = _a.id, name = _a.name, status = _a.status, content = _a.content, language = _a.language, created_on = _a.created_on, last_updated_on = _a.last_updated_on, url = _a.url, thumbnail_url = _a.thumbnail_url, redirections = _a.redirections, list_id = _a.list_id, double_opt_in = _a.double_opt_in;
16640
+ var _this = _super.call(this, { id: id, name: name, list_id: list_id, double_opt_in: double_opt_in }) || this;
16641
+ _this.status = status;
16642
+ _this.content = content;
16643
+ _this.language = language;
16644
+ _this.created_on = created_on;
16645
+ _this.last_updated_on = last_updated_on;
16646
+ _this.url = url;
16647
+ _this.thumbnail_url = thumbnail_url;
16648
+ _this.redirections = redirections;
16649
+ return _this;
16650
+ }
16552
16651
  FormModel.prototype.toJson = function () {
16553
16652
  return modelToJson(this);
16554
16653
  };
@@ -16556,7 +16655,106 @@ var FormModel = /** @class */ (function () {
16556
16655
  modelSet(this, property, value);
16557
16656
  };
16558
16657
  return FormModel;
16559
- }());
16658
+ }(CommonFormModel));
16659
+ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
16660
+ __extends(SummaryEnhancedFormModel, _super);
16661
+ function SummaryEnhancedFormModel(_a) {
16662
+ 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_at = _a.created_at, updated_at = _a.updated_at, published_at = _a.published_at, edited_by = _a.edited_by, thumbnail_url = _a.thumbnail_url, recaptcha = _a.recaptcha;
16663
+ var _this = _super.call(this, { id: id, name: name, list_id: list_id, double_opt_in: double_opt_in }) || this;
16664
+ _this.enabled = enabled;
16665
+ _this.description = description;
16666
+ _this.tags = tags;
16667
+ _this.post_redirect_url = post_redirect_url;
16668
+ _this.double_opt_in_redirect_url = double_opt_in_redirect_url;
16669
+ _this.submission_url = submission_url;
16670
+ _this.async_processing = async_processing;
16671
+ _this.branding = branding;
16672
+ _this.created_at = created_at;
16673
+ _this.updated_at = updated_at;
16674
+ _this.published_at = published_at;
16675
+ _this.edited_by = edited_by;
16676
+ _this.thumbnail_url = thumbnail_url;
16677
+ _this.recaptcha = recaptcha;
16678
+ return _this;
16679
+ }
16680
+ SummaryEnhancedFormModel.prototype.enable = function () {
16681
+ return __awaiter(this, void 0, void 0, function () {
16682
+ var _this = this;
16683
+ return __generator(this, function (_a) {
16684
+ return [2 /*return*/, enableForm({ id: this.id.toString() }).then(function (data) {
16685
+ trackEvent(exports.EEvents.FORM_ENABLED, { id: _this.id });
16686
+ return data;
16687
+ })];
16688
+ });
16689
+ });
16690
+ };
16691
+ SummaryEnhancedFormModel.prototype.disable = function () {
16692
+ return __awaiter(this, void 0, void 0, function () {
16693
+ var _this = this;
16694
+ return __generator(this, function (_a) {
16695
+ return [2 /*return*/, disableForm({ id: this.id.toString() }).then(function (data) {
16696
+ trackEvent(exports.EEvents.FORM_DISABLED, { id: _this.id });
16697
+ return data;
16698
+ })];
16699
+ });
16700
+ });
16701
+ };
16702
+ SummaryEnhancedFormModel.prototype.publish = function () {
16703
+ return __awaiter(this, void 0, void 0, function () {
16704
+ var _this = this;
16705
+ return __generator(this, function (_a) {
16706
+ return [2 /*return*/, publishForm({ id: this.id.toString() }).then(function (data) {
16707
+ trackEvent(exports.EEvents.FORM_PUBLISHED, { id: _this.id });
16708
+ return data;
16709
+ })];
16710
+ });
16711
+ });
16712
+ };
16713
+ SummaryEnhancedFormModel.prototype.render = function () {
16714
+ return __awaiter(this, arguments, void 0, function (published) {
16715
+ var _this = this;
16716
+ if (published === void 0) { published = false; }
16717
+ return __generator(this, function (_a) {
16718
+ return [2 /*return*/, renderForm({ id: this.id.toString(), published: published }).then(function (data) {
16719
+ trackEvent(published ? exports.EEvents.FORM_RENDERED_PUBLISHED : exports.EEvents.FORM_RENDERED, { id: _this.id });
16720
+ return data;
16721
+ })];
16722
+ });
16723
+ });
16724
+ };
16725
+ SummaryEnhancedFormModel.prototype.save = function () {
16726
+ return __awaiter(this, void 0, void 0, function () {
16727
+ var _this = this;
16728
+ return __generator(this, function (_a) {
16729
+ return [2 /*return*/, patchForm({ id: this.id.toString(), data: this.toJson() }).then(function (data) {
16730
+ trackEvent(exports.EEvents.FORM_UPDATED, { id: _this.id });
16731
+ return data;
16732
+ })];
16733
+ });
16734
+ });
16735
+ };
16736
+ SummaryEnhancedFormModel.prototype.toJson = function () {
16737
+ return modelToJson(this);
16738
+ };
16739
+ SummaryEnhancedFormModel.prototype.set = function (property, value) {
16740
+ modelSet(this, property, value);
16741
+ };
16742
+ return SummaryEnhancedFormModel;
16743
+ }(CommonFormModel));
16744
+ var EnhancedFormModel = /** @class */ (function (_super) {
16745
+ __extends(EnhancedFormModel, _super);
16746
+ function EnhancedFormModel(_a) {
16747
+ var _this = this;
16748
+ var content = _a.content, rest = __rest(_a, ["content"]);
16749
+ _this = _super.call(this, rest) || this;
16750
+ _this.content = content;
16751
+ return _this;
16752
+ }
16753
+ EnhancedFormModel.prototype.toJson = function () {
16754
+ return modelToJson(this);
16755
+ };
16756
+ return EnhancedFormModel;
16757
+ }(SummaryEnhancedFormModel));
16560
16758
 
16561
16759
  var ListModel = /** @class */ (function () {
16562
16760
  function ListModel(params) {
@@ -16755,6 +16953,9 @@ var FormsFactory = /** @class */ (function () {
16755
16953
  var id = _b.id;
16756
16954
  return __generator(this, function (_c) {
16757
16955
  return [2 /*return*/, getForm({ id: id }).then(function (data) {
16956
+ if ("enabled" in data.data) {
16957
+ return new EnhancedFormModel(data.data);
16958
+ }
16758
16959
  return new FormModel(data.data);
16759
16960
  })];
16760
16961
  });
@@ -16766,6 +16967,9 @@ var FormsFactory = /** @class */ (function () {
16766
16967
  return __generator(this, function (_b) {
16767
16968
  return [2 /*return*/, listForms(options).then(function (data) {
16768
16969
  data.data = data.data.map(function (form) {
16970
+ if ("enabled" in form) {
16971
+ return new SummaryEnhancedFormModel(form);
16972
+ }
16769
16973
  return new FormModel(form);
16770
16974
  });
16771
16975
  return data;
@@ -16773,6 +16977,19 @@ var FormsFactory = /** @class */ (function () {
16773
16977
  });
16774
16978
  });
16775
16979
  };
16980
+ FormsFactory.create = function (_a) {
16981
+ return __awaiter(this, arguments, void 0, function (_b) {
16982
+ var form = _b.form;
16983
+ return __generator(this, function (_c) {
16984
+ return [2 /*return*/, createForm({ form: form }).then(function (data) {
16985
+ if ("enabled" in data.data) {
16986
+ return new EnhancedFormModel(data.data);
16987
+ }
16988
+ return new FormModel(data.data);
16989
+ })];
16990
+ });
16991
+ });
16992
+ };
16776
16993
  return FormsFactory;
16777
16994
  }());
16778
16995
 
@@ -17057,6 +17274,7 @@ exports.CircularProgress = CircularProgress;
17057
17274
  exports.CodeInput = CodeInput;
17058
17275
  exports.ColManager = ColManager;
17059
17276
  exports.ColorTextField = ColorTextField;
17277
+ exports.CommonFormModel = CommonFormModel;
17060
17278
  exports.ContactModel = ContactModel;
17061
17279
  exports.ContactsFactory = ContactsFactory;
17062
17280
  exports.ContentSectionContainer = ContentSectionContainer;
@@ -17083,6 +17301,7 @@ exports.ElementContains = ElementContains;
17083
17301
  exports.Email = Email;
17084
17302
  exports.EmailAPIFactory = EmailAPIFactory;
17085
17303
  exports.EmptyContent = EmptyContent;
17304
+ exports.EnhancedFormModel = EnhancedFormModel;
17086
17305
  exports.FileUpload = FileUpload;
17087
17306
  exports.FilterBar = FilterBar;
17088
17307
  exports.FormModel = FormModel;
@@ -17118,6 +17337,7 @@ exports.SideMenu = SideMenu;
17118
17337
  exports.SideMenuContainer = SideMenuContainer;
17119
17338
  exports.SideMenuItem = SideMenuItem;
17120
17339
  exports.SubNav = SubNav;
17340
+ exports.SummaryEnhancedFormModel = SummaryEnhancedFormModel;
17121
17341
  exports.SupportFactory = SupportFactory;
17122
17342
  exports.SystemEmailsFactory = SystemEmailsFactory;
17123
17343
  exports.SystemEmailsModel = SystemEmailsModel;
@@ -17152,18 +17372,22 @@ exports.createBrand = createBrand;
17152
17372
  exports.createCampaign = createCampaign;
17153
17373
  exports.createCampaignLogsExports = createCampaignLogsExports;
17154
17374
  exports.createCampaignsReportsExport = createCampaignsReportsExport;
17375
+ exports.createForm = createForm;
17155
17376
  exports.createTemplate = createTemplate;
17156
17377
  exports.deepMergeObject = deepMergeObject;
17157
17378
  exports.deleteCampaign = deleteCampaign;
17158
17379
  exports.deleteCampaignsReportsExport = deleteCampaignsReportsExport;
17380
+ exports.deleteForm = deleteForm;
17159
17381
  exports.deletePartialInformation = deletePartialInformation;
17160
17382
  exports.deleteStorageItem = deleteStorageItem;
17161
17383
  exports.deleteTemplate = deleteTemplate;
17162
17384
  exports.descendingComparator = descendingComparator;
17385
+ exports.disableForm = disableForm;
17163
17386
  exports.downloadCampaignLogExport = downloadCampaignLogExport;
17164
17387
  exports.downloadCampaignsReportsExport = downloadCampaignsReportsExport;
17165
17388
  exports.emptyAccountAddress = emptyAccountAddress;
17166
17389
  exports.emptyAccountLimits = emptyAccountLimits;
17390
+ exports.enableForm = enableForm;
17167
17391
  exports.enrichBrand = enrichBrand;
17168
17392
  exports.enrichOrganization = enrichOrganization;
17169
17393
  exports.enrichProfile = enrichProfile;
@@ -17246,13 +17470,16 @@ exports.miliToSecond = miliToSecond;
17246
17470
  exports.modelSet = modelSet;
17247
17471
  exports.modelToJson = modelToJson;
17248
17472
  exports.originalBrand = originalBrand;
17473
+ exports.patchForm = patchForm;
17249
17474
  exports.popImpersonificationTree = popImpersonificationTree;
17250
17475
  exports.postMessage = postMessage;
17476
+ exports.publishForm = publishForm;
17251
17477
  exports.reScheduleCampaign = reScheduleCampaign;
17252
17478
  exports.removeEmptyProperties = removeEmptyProperties;
17253
17479
  exports.removeQueryParams = removeQueryParams;
17254
17480
  exports.removeTrailingChar = removeTrailingChar;
17255
17481
  exports.renderCampaign = renderCampaign;
17482
+ exports.renderForm = renderForm;
17256
17483
  exports.renderTemplate = renderTemplate;
17257
17484
  exports.requestSupportService = requestSupportService;
17258
17485
  exports.resumeCampaign = resumeCampaign;
@@ -1,8 +1,21 @@
1
- import { EApiLanguages } from "../../types";
2
- import { TFormModel } from "./types";
3
- export declare class FormModel {
4
- readonly id: number;
1
+ import { EApiLanguages, TDeleteApiResource, TDisableApiResource, TEnableApiResource, TGenericReturn } from "../../types";
2
+ import { TEnhancedFormContent, TEnhancedFormEditedBy, TEnhancedFormModel, TEnhancedFormRecaptcha, TFormModel, TSummaryEnhancedFormModel } from "./types";
3
+ export declare class CommonFormModel {
4
+ readonly id: string;
5
5
  name: string;
6
+ list_id: number;
7
+ double_opt_in: boolean;
8
+ constructor({ id, name, list_id, double_opt_in }: {
9
+ id: string;
10
+ name: string;
11
+ list_id: number;
12
+ double_opt_in: boolean;
13
+ });
14
+ toJson(): any;
15
+ set<T extends keyof this>(property: T, value: this[T]): void;
16
+ delete(): Promise<TDeleteApiResource>;
17
+ }
18
+ export declare class FormModel extends CommonFormModel {
6
19
  readonly status: string;
7
20
  content: {
8
21
  linked: string;
@@ -21,10 +34,37 @@ export declare class FormModel {
21
34
  after_double_opt_in: string;
22
35
  after_opt_out: string;
23
36
  };
24
- list_id: number;
25
- double_opt_in: boolean;
26
37
  constructor({ id, name, status, content, language, created_on, last_updated_on, url, thumbnail_url, redirections, list_id, double_opt_in, }: TFormModel);
27
38
  toJson(): any;
28
39
  set<T extends keyof this>(property: T, value: this[T]): void;
29
40
  }
41
+ export declare class SummaryEnhancedFormModel extends CommonFormModel {
42
+ readonly enabled: boolean;
43
+ description: string;
44
+ tags: string[];
45
+ post_redirect_url: string;
46
+ double_opt_in_redirect_url: string;
47
+ submission_url: string;
48
+ async_processing: boolean;
49
+ branding: string;
50
+ readonly created_at: number;
51
+ readonly updated_at: number;
52
+ readonly published_at: number;
53
+ readonly edited_by: TEnhancedFormEditedBy;
54
+ readonly thumbnail_url: string;
55
+ recaptcha: TEnhancedFormRecaptcha;
56
+ 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_at, updated_at, published_at, edited_by, thumbnail_url, recaptcha, }: TSummaryEnhancedFormModel);
57
+ enable(): Promise<TEnableApiResource>;
58
+ disable(): Promise<TDisableApiResource>;
59
+ publish(): Promise<TGenericReturn<EnhancedFormModel>>;
60
+ render(published?: boolean): Promise<TGenericReturn<EnhancedFormModel>>;
61
+ save(): Promise<TGenericReturn<EnhancedFormModel>>;
62
+ toJson(): any;
63
+ set<T extends keyof this>(property: T, value: this[T]): void;
64
+ }
65
+ export declare class EnhancedFormModel extends SummaryEnhancedFormModel {
66
+ content: TEnhancedFormContent;
67
+ constructor({ content, ...rest }: TEnhancedFormModel);
68
+ toJson(): any;
69
+ }
30
70
  export * from "./types";
@@ -1,6 +1,6 @@
1
1
  import { EApiLanguages } from "../../types";
2
2
  export type TFormModel = {
3
- readonly id: number;
3
+ readonly id: string;
4
4
  name: string;
5
5
  readonly status: string;
6
6
  content: {
@@ -23,3 +23,37 @@ export type TFormModel = {
23
23
  list_id: number;
24
24
  double_opt_in: boolean;
25
25
  };
26
+ export type TEnhancedFormEditedBy = {
27
+ id: number;
28
+ email: string;
29
+ };
30
+ export type TEnhancedFormRecaptcha = {
31
+ secret: string;
32
+ domain: string;
33
+ };
34
+ export type TEnhancedFormContent = {
35
+ json: any;
36
+ };
37
+ export interface TSummaryEnhancedFormModel {
38
+ readonly id: string;
39
+ list_id: number;
40
+ readonly enabled: boolean;
41
+ name: string;
42
+ description: string;
43
+ tags: string[];
44
+ post_redirect_url: string;
45
+ double_opt_in: boolean;
46
+ double_opt_in_redirect_url: string;
47
+ submission_url: string;
48
+ async_processing: boolean;
49
+ branding: string;
50
+ readonly created_at: number;
51
+ readonly updated_at: number;
52
+ readonly published_at: number;
53
+ readonly edited_by: TEnhancedFormEditedBy;
54
+ readonly thumbnail_url: string;
55
+ recaptcha: TEnhancedFormRecaptcha;
56
+ }
57
+ export interface TEnhancedFormModel extends TSummaryEnhancedFormModel {
58
+ content: TEnhancedFormContent;
59
+ }
@@ -1,6 +1,30 @@
1
+ import { EnhancedFormModel, FormModel } from "../../models";
1
2
  import { TGenericListParams } from "../../types";
3
+ export declare function createForm({ form }: {
4
+ form: Partial<FormModel | EnhancedFormModel>;
5
+ }): Promise<any>;
2
6
  export declare function listForms({ useImpersonationTree, ...options }: TGenericListParams): Promise<any>;
7
+ export declare function patchForm({ id, data }: {
8
+ id: string;
9
+ data: Partial<FormModel | EnhancedFormModel>;
10
+ }): Promise<any>;
3
11
  export declare function getForm({ id }: {
4
12
  id: string;
5
13
  }): Promise<any>;
14
+ export declare function deleteForm({ id }: {
15
+ id: string;
16
+ }): Promise<any>;
17
+ export declare function enableForm({ id }: {
18
+ id: string;
19
+ }): Promise<any>;
20
+ export declare function disableForm({ id }: {
21
+ id: string;
22
+ }): Promise<any>;
23
+ export declare function publishForm({ id }: {
24
+ id: string;
25
+ }): Promise<any>;
26
+ export declare function renderForm({ id, published }: {
27
+ id: string;
28
+ published: boolean;
29
+ }): Promise<any>;
6
30
  export * from "./types";
@@ -90,6 +90,16 @@ export type TDeleteApiResource = {
90
90
  object: string;
91
91
  deleted: boolean;
92
92
  };
93
+ export type TEnableApiResource = {
94
+ id: TNumStr;
95
+ object: string;
96
+ enabled: boolean;
97
+ };
98
+ export type TDisableApiResource = {
99
+ id: TNumStr;
100
+ object: string;
101
+ disabled: boolean;
102
+ };
93
103
  export type TUpdateApiResource<T> = {
94
104
  updated: boolean;
95
105
  object: string;