@rechat/sdk 0.1.5 → 0.2.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/rechat.min.js +1 -1
- package/esm/LeadCapture.d.ts +8 -0
- package/esm/index.all.d.ts +3 -0
- package/esm/index.all.js +1 -0
- package/esm/index.d.ts +8 -0
- package/esm/types/index.d.ts +4 -0
- package/esm/types/lead-capture.d.ts +21 -0
- package/esm/types/lead-form.d.ts +5 -0
- package/package.json +9 -2
package/dist/rechat.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Rechat=function(t){"use strict";var
|
|
1
|
+
var Rechat=function(t){"use strict";var e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{c(r.next(t))}catch(t){o(t)}}function u(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,u)}c((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var a=function(){function t(t){this._settings=t}return t.prototype.getLeadMetaDataFromUrl=function(){var t=new URLSearchParams(window.location.search);return["user_id","brand_id","ad_campaign_id","email_campaign_id"].reduce((function(n,r){var a,o;return e(e({},n),((a={})[r]=null!==(o=t.get("rechat_".concat(r)))&&void 0!==o?o:"",a))}),{})},t.prototype.capture=function(t,a){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,o){fetch("https://api.rechat.com/leads",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({lead:a,metadata:e(e({},n.getLeadMetaDataFromUrl()),t)})}).then((function(){return r()})).catch(o)}))]}))}))},t.prototype.form=function(t,n,r){var a=this;t.addEventListener("submit",(function(o){var i;o.preventDefault();var u=Object.values(t).reduce((function(t,n){var r;return n.name?e(e({},t),((r={})[n.name]=n.value,r)):t}),{});!1!==(null===(i=r.validate)||void 0===i?void 0:i.call(r,u))&&a.capture(n,u).then(r.onSuccess).catch(r.onError)}))},t}(),o=function(){function t(t){void 0===t&&(t={}),this._settings=t,this._leads=new a(t)}return Object.defineProperty(t.prototype,"Leads",{get:function(){return this._leads},enumerable:!1,configurable:!0}),t}();return t.Sdk=o,t}({});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IFormEvents, ILeadMetaData, ILeadInput, ISdkSettings } from './types';
|
|
2
|
+
export declare class LeadCapture {
|
|
3
|
+
private _settings;
|
|
4
|
+
constructor(settings: ISdkSettings);
|
|
5
|
+
private getLeadMetaDataFromUrl;
|
|
6
|
+
capture(metadata: ILeadMetaData, lead: ILeadInput): Promise<void>;
|
|
7
|
+
form(element: HTMLFormElement, channel: ILeadMetaData, events: IFormEvents): void;
|
|
8
|
+
}
|
package/esm/index.all.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e,n,r){return new(n||(n=Promise))((function(o,a){function i(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,u)}c((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(){function r(t){this._settings=t}return r.prototype.getLeadMetaDataFromUrl=function(){var e=new URLSearchParams(window.location.search);return["user_id","brand_id","ad_campaign_id","email_campaign_id"].reduce((function(n,r){var o,a;return t(t({},n),((o={})[r]=null!==(a=e.get("rechat_".concat(r)))&&void 0!==a?a:"",o))}),{})},r.prototype.capture=function(r,o){return e(this,void 0,void 0,(function(){var e=this;return n(this,(function(n){return[2,new Promise((function(n,a){fetch("https://api.rechat.com/leads",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({lead:o,metadata:t(t({},e.getLeadMetaDataFromUrl()),r)})}).then((function(){return n()})).catch(a)}))]}))}))},r.prototype.form=function(e,n,r){var o=this;e.addEventListener("submit",(function(a){var i;a.preventDefault();var u=Object.values(e).reduce((function(e,n){var r;return n.name?t(t({},e),((r={})[n.name]=n.value,r)):e}),{});!1!==(null===(i=r.validate)||void 0===i?void 0:i.call(r,u))&&o.capture(n,u).then(r.onSuccess).catch(r.onError)}))},r}(),o=function(){function t(t){void 0===t&&(t={}),this._settings=t,this._leads=new r(t)}return Object.defineProperty(t.prototype,"Leads",{get:function(){return this._leads},enumerable:!1,configurable:!0}),t}();export{r as LeadCapture,o as Sdk};
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ILeadMetaData {
|
|
2
|
+
channel_id: string;
|
|
3
|
+
user_id?: string;
|
|
4
|
+
brand_id?: string;
|
|
5
|
+
agent_emails?: string[];
|
|
6
|
+
email_campaign_id?: string;
|
|
7
|
+
ad_campaign_id?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ILeadInput {
|
|
10
|
+
first_name?: string;
|
|
11
|
+
last_name?: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
phone_number?: string;
|
|
14
|
+
tag?: string;
|
|
15
|
+
lead_source?: string;
|
|
16
|
+
note?: string;
|
|
17
|
+
address?: string;
|
|
18
|
+
referer_url?: string;
|
|
19
|
+
mlsid?: string;
|
|
20
|
+
agent_mlsid?: string;
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rechat/sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"clean:sdk": "rimraf umd",
|
|
7
|
+
"clean:sdk": "rimraf umd && rimraf esm",
|
|
8
8
|
"clean:docs": "rimraf api",
|
|
9
9
|
"build:docs": "npm run clean:docs && typedoc --readme README.md && npm run docs:examples",
|
|
10
10
|
"build:sdk": "npm run clean:sdk && rollup --config --bundleConfigAsCjs",
|
|
@@ -13,11 +13,15 @@
|
|
|
13
13
|
"keywords": [],
|
|
14
14
|
"author": "Rechat INC.",
|
|
15
15
|
"license": "ISC",
|
|
16
|
+
"homepage": "https://rechat.com",
|
|
17
|
+
"readmeFilename": "README.md",
|
|
16
18
|
"publishConfig": {
|
|
17
19
|
"access": "public"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
22
|
"@jsdevtools/npm-publish": "^3.1.1",
|
|
23
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
24
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
21
25
|
"@rollup/plugin-terser": "^0.4.4",
|
|
22
26
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
23
27
|
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
@@ -35,10 +39,13 @@
|
|
|
35
39
|
"typescript": "^5.4.5"
|
|
36
40
|
},
|
|
37
41
|
"type": "module",
|
|
42
|
+
"typings": "esm/index.all.d.ts",
|
|
43
|
+
"module": "esm/index.all.js",
|
|
38
44
|
"unpkg": "dist/rechat.min.js",
|
|
39
45
|
"sideEffects": false,
|
|
40
46
|
"files": [
|
|
41
47
|
"dist",
|
|
48
|
+
"esm",
|
|
42
49
|
"LICENSE",
|
|
43
50
|
"README"
|
|
44
51
|
]
|