@saasquatch/squatch-js 2.4.3-4 → 2.4.3
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/CHANGELOG.md +291 -278
- package/LICENSE +20 -20
- package/README.md +1 -0
- package/demo/sandbox.ts +5 -7
- package/demo/toolbar.tsx +1 -1
- package/dist/api/AnalyticsApi.d.ts +1 -1
- package/dist/api/WidgetApi.d.ts +17 -4
- package/dist/squatch.d.ts +2 -12
- package/dist/squatch.esm.js +159 -267
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +158 -268
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +3 -3
- package/dist/squatch.min.js.map +1 -1
- package/dist/squatch.modern.js +1 -1
- package/dist/squatch.modern.js.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/types.d.ts +8 -10
- package/dist/utils/cookieUtils.d.ts +0 -1
- package/dist/utils/io.d.ts +1 -2
- package/dist/utils/validate.d.ts +0 -2
- package/dist/widgets/Widgets.d.ts +17 -3
- package/package.json +105 -104
- package/dist/utils/utmUtils.d.ts +0 -14
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import Widget from "./widgets/Widget";
|
|
2
|
-
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
3
|
-
[P in K]-?: T[P];
|
|
4
|
-
};
|
|
5
2
|
/**
|
|
6
3
|
* When you load Squatch.js you need to provide these configuration options.
|
|
7
4
|
*
|
|
@@ -26,14 +23,12 @@ export interface ConfigOptions {
|
|
|
26
23
|
* @param jwt the JSON Web Token (JWT) that is used
|
|
27
24
|
*/
|
|
28
25
|
export interface WidgetConfig {
|
|
29
|
-
user
|
|
26
|
+
user: User;
|
|
30
27
|
widgetType?: WidgetType;
|
|
31
28
|
engagementMedium?: EngagementMedium;
|
|
32
29
|
container?: HTMLElement | string;
|
|
33
30
|
trigger?: string;
|
|
34
31
|
jwt?: JWT;
|
|
35
|
-
locale?: string;
|
|
36
|
-
displayOnLoad?: boolean;
|
|
37
32
|
}
|
|
38
33
|
/**
|
|
39
34
|
* @param user The user details
|
|
@@ -77,19 +72,18 @@ export declare type EngagementMedium =
|
|
|
77
72
|
/** Displays the widget embedded in the page. Create an {@link EmbedWidget} */
|
|
78
73
|
| "EMBED";
|
|
79
74
|
export declare type WidgetContext = {
|
|
80
|
-
type: "cookie" | "error"
|
|
75
|
+
type: "cookie" | "error";
|
|
81
76
|
engagementMedium?: EngagementMedium;
|
|
82
77
|
container?: HTMLElement | string;
|
|
83
78
|
trigger?: string;
|
|
84
|
-
displayOnLoad?: boolean;
|
|
85
79
|
} | {
|
|
86
80
|
type: "upsert";
|
|
87
|
-
user
|
|
81
|
+
user: User;
|
|
88
82
|
engagementMedium?: EngagementMedium;
|
|
89
83
|
container?: HTMLElement | string;
|
|
90
84
|
trigger?: string;
|
|
91
85
|
};
|
|
92
|
-
export declare type WidgetContextType = "upsert" | "cookie" | "error"
|
|
86
|
+
export declare type WidgetContextType = "upsert" | "cookie" | "error";
|
|
93
87
|
/**
|
|
94
88
|
* WidgetType is an enum for types of ways a Widget can be displayed.
|
|
95
89
|
*/
|
|
@@ -100,3 +94,7 @@ export declare type WidgetType =
|
|
|
100
94
|
| "CONVERSION_WIDGET" | string;
|
|
101
95
|
export declare type ShareMedium = string;
|
|
102
96
|
export declare type JWT = string;
|
|
97
|
+
export declare type ReferralCookie = {
|
|
98
|
+
codes: string[];
|
|
99
|
+
encodedCookie: string;
|
|
100
|
+
};
|
package/dist/utils/io.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JWT } from "../types";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function doGet(url: any, jwt?: string): Promise<any>;
|
|
2
|
+
export declare function doGet<T>(url: any, jwt?: string): Promise<T>;
|
|
4
3
|
/**
|
|
5
4
|
* @hidden
|
|
6
5
|
*
|
package/dist/utils/validate.d.ts
CHANGED
|
@@ -10,7 +10,5 @@ declare type Required<T> = T extends object ? {
|
|
|
10
10
|
[P in keyof T]-?: NonNullable<T[P]>;
|
|
11
11
|
} : T;
|
|
12
12
|
export declare function validateConfig(raw: unknown): Required<ConfigOptions>;
|
|
13
|
-
export declare function validateLocale(locale?: string): string | undefined;
|
|
14
13
|
export declare function validateWidgetConfig(raw: unknown): WidgetConfig;
|
|
15
|
-
export declare function validatePasswordlessConfig(raw: unknown): WidgetConfig;
|
|
16
14
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WidgetApi from "../api/WidgetApi";
|
|
2
|
-
import { WidgetResult
|
|
2
|
+
import { WidgetResult } from "../types";
|
|
3
3
|
import { ConfigOptions, WidgetConfig } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
@@ -30,6 +30,20 @@ export default class Widgets {
|
|
|
30
30
|
* let widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});
|
|
31
31
|
*/
|
|
32
32
|
constructor(configin: ConfigOptions);
|
|
33
|
+
/**
|
|
34
|
+
* This function calls the {@link WidgetApi.cookieUser} method, and it renders
|
|
35
|
+
* the widget if it is successful. Otherwise it shows the "error" widget.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} config Config details
|
|
38
|
+
* @param {WidgetType} config.widgetType The content of the widget.
|
|
39
|
+
* @param {EngagementMedium} config.engagementMedium How to display the widget.
|
|
40
|
+
* @param {User} config.user An optional user to include
|
|
41
|
+
* @param {string} config.jwt the JSON Web Token (JWT) that is used to
|
|
42
|
+
* validate the data (can be disabled)
|
|
43
|
+
*
|
|
44
|
+
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details.
|
|
45
|
+
*/
|
|
46
|
+
createCookieUser(config: WidgetConfig): Promise<WidgetResult>;
|
|
33
47
|
/**
|
|
34
48
|
* This function calls the {@link WidgetApi.upsertUser} method, and it renders
|
|
35
49
|
* the widget if it is successful. Otherwise it shows the "error" widget.
|
|
@@ -46,7 +60,7 @@ export default class Widgets {
|
|
|
46
60
|
*
|
|
47
61
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details.
|
|
48
62
|
*/
|
|
49
|
-
upsertUser(config:
|
|
63
|
+
upsertUser(config: WidgetConfig): Promise<{
|
|
50
64
|
widget: any;
|
|
51
65
|
user: any;
|
|
52
66
|
}>;
|
|
@@ -65,7 +79,7 @@ export default class Widgets {
|
|
|
65
79
|
*
|
|
66
80
|
* @return {Promise<WidgetResult>} json object if true, with a Widget and user details.
|
|
67
81
|
*/
|
|
68
|
-
render(config: WidgetConfig): Promise<WidgetResult
|
|
82
|
+
render(config: WidgetConfig): Promise<WidgetResult>;
|
|
69
83
|
/**
|
|
70
84
|
* Autofills a referral code into an element when someone has been referred.
|
|
71
85
|
* Uses {@link WidgetApi.squatchReferralCookie} behind the scenes.
|
package/package.json
CHANGED
|
@@ -1,104 +1,105 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@saasquatch/squatch-js",
|
|
3
|
-
"version": "2.4.3
|
|
4
|
-
"description": "The official Referral SaaSquatch Javascript Web/Browser SDK https://docs.referralsaasquatch.com/developer/squatchjs/",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"build:
|
|
30
|
-
"build
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"test:
|
|
35
|
-
"test:
|
|
36
|
-
"test:
|
|
37
|
-
"test
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"deploy
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"demo
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"parcel
|
|
47
|
-
"parcel:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"@babel/
|
|
52
|
-
"@babel/plugin-
|
|
53
|
-
"@babel/
|
|
54
|
-
"@babel/preset-
|
|
55
|
-
"@babel/
|
|
56
|
-
"@babel/
|
|
57
|
-
"@
|
|
58
|
-
"@types/
|
|
59
|
-
"@types/
|
|
60
|
-
"@types/
|
|
61
|
-
"@types/
|
|
62
|
-
"@types/
|
|
63
|
-
"@types/
|
|
64
|
-
"@types/
|
|
65
|
-
"@
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"parcel
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"react
|
|
81
|
-
"react-
|
|
82
|
-
"react-
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"ts-
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"webpack
|
|
91
|
-
"webpack-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@saasquatch/squatch-js",
|
|
3
|
+
"version": "2.4.3",
|
|
4
|
+
"description": "The official Referral SaaSquatch Javascript Web/Browser SDK https://docs.referralsaasquatch.com/developer/squatchjs/",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "ReferralSaaSquatch.com, Inc.",
|
|
7
|
+
"types": "dist/squatch.d.ts",
|
|
8
|
+
"source": "src/squatch.ts",
|
|
9
|
+
"main": "dist/squatch.js",
|
|
10
|
+
"module": "dist/squatch.esm.js",
|
|
11
|
+
"umd:main": "dist/squatch.min.js",
|
|
12
|
+
"browser": "dist/squatch.min.js",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/saasquatch/squatch-js/issues",
|
|
15
|
+
"email": "support@referralsaasquatch.com"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=12.16.0"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/saasquatch/squatch-js.git"
|
|
23
|
+
},
|
|
24
|
+
"tsd": {
|
|
25
|
+
"directory": "test/tsd"
|
|
26
|
+
},
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build:es": "microbundle --target node --format cjs,es",
|
|
30
|
+
"build:umd": "webpack",
|
|
31
|
+
"build": "run-s build:es build:umd",
|
|
32
|
+
"watch": "microbundle watch",
|
|
33
|
+
"declaration": "tsc --emitDeclarationOnly",
|
|
34
|
+
"test:browser": "cucumber-js",
|
|
35
|
+
"test:webkit": "cross-env BROWSER=webkit cucumber-js",
|
|
36
|
+
"test:firefox": "cross-env BROWSER=firefox cucumber-js",
|
|
37
|
+
"test:types": "tsd",
|
|
38
|
+
"test": "run-s test:types test:browser",
|
|
39
|
+
"build:docs": "typedoc --out docs/ src/ ",
|
|
40
|
+
"deploy": "np --no-cleanup",
|
|
41
|
+
"deploy:docs": "surge ./ -d squathjsv2.surge.sh",
|
|
42
|
+
"preversion": "run-s build",
|
|
43
|
+
"demo": "msw init demo/dist/ --save && run-p static parcel",
|
|
44
|
+
"demo:deploy": "run-s parcel:build parcel:deploy",
|
|
45
|
+
"static": "serve dist",
|
|
46
|
+
"parcel": "cd demo && parcel index.html",
|
|
47
|
+
"parcel:build": "cd demo && parcel build index.html",
|
|
48
|
+
"parcel:deploy": "surge demo/dist -d squathjs-demo.surge.sh"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@babel/core": "^7.14.3",
|
|
52
|
+
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
53
|
+
"@babel/plugin-transform-runtime": "^7.14.3",
|
|
54
|
+
"@babel/preset-env": "^7.14.2",
|
|
55
|
+
"@babel/preset-typescript": "^7.13.0",
|
|
56
|
+
"@babel/register": "^7.13.16",
|
|
57
|
+
"@babel/runtime-corejs2": "^7.14.0",
|
|
58
|
+
"@types/chai": "^4.2.11",
|
|
59
|
+
"@types/cucumber": "^6.0.1",
|
|
60
|
+
"@types/debug": "4.1.5",
|
|
61
|
+
"@types/express": "^4.17.6",
|
|
62
|
+
"@types/js-cookie": "^2.2.6",
|
|
63
|
+
"@types/jsdom-global": "^3.0.2",
|
|
64
|
+
"@types/react": "^16.9.35",
|
|
65
|
+
"@types/superagent": "^4.1.7",
|
|
66
|
+
"@ungap/url-search-params": "^0.2.0",
|
|
67
|
+
"babel-loader": "^8.2.2",
|
|
68
|
+
"base64-url": "^2.3.3",
|
|
69
|
+
"chai": "^4.2.0",
|
|
70
|
+
"cross-env": "^7.0.2",
|
|
71
|
+
"cucumber": "^6.0.5",
|
|
72
|
+
"express": "^4.17.1",
|
|
73
|
+
"microbundle": "^0.13.0",
|
|
74
|
+
"msw": "^0.36.0",
|
|
75
|
+
"np": "^6.2.3",
|
|
76
|
+
"npm-run-all": "^4.1.5",
|
|
77
|
+
"parcel": "^1.12.3",
|
|
78
|
+
"parcel-bundler": "^1.12.4",
|
|
79
|
+
"playwright": "^1.0.2",
|
|
80
|
+
"react": "^16.13.1",
|
|
81
|
+
"react-bootstrap": "^1.0.1",
|
|
82
|
+
"react-dom": "^16.13.1",
|
|
83
|
+
"react-url-query": "^1.5.0",
|
|
84
|
+
"serve": "^11.3.0",
|
|
85
|
+
"ts-loader": "^7.0.4",
|
|
86
|
+
"ts-node": "^8.10.2",
|
|
87
|
+
"tsd": "^0.13.1",
|
|
88
|
+
"typedoc": "^0.17.7",
|
|
89
|
+
"typescript": "^3.9.3",
|
|
90
|
+
"webpack": "^4.46.0",
|
|
91
|
+
"webpack-cli": "^3.3.12",
|
|
92
|
+
"webpack-visualizer-plugin": "^0.1.11"
|
|
93
|
+
},
|
|
94
|
+
"prettier": {},
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"debug": "^3.2.6",
|
|
97
|
+
"eventbusjs": "^0.2.0",
|
|
98
|
+
"js-cookie": "^2.2.1",
|
|
99
|
+
"superagent": "^5.2.2"
|
|
100
|
+
},
|
|
101
|
+
"browserslist": "> 0.25%, not dead",
|
|
102
|
+
"msw": {
|
|
103
|
+
"workerDirectory": "demo\\dist"
|
|
104
|
+
}
|
|
105
|
+
}
|
package/dist/utils/utmUtils.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ConfigOptions, WidgetConfig } from "../types";
|
|
2
|
-
export declare function _getAutoConfig(configIn: ConfigOptions): {
|
|
3
|
-
widgetConfig: WidgetConfig;
|
|
4
|
-
squatchConfig: ConfigOptions;
|
|
5
|
-
} | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* Converts _saasquatchExtra into
|
|
8
|
-
* @param obj
|
|
9
|
-
*/
|
|
10
|
-
export declare function convertExtraToConfig(obj: Record<string, any>): {
|
|
11
|
-
domain: string | undefined;
|
|
12
|
-
tenantAlias: string;
|
|
13
|
-
widgetConfig: any;
|
|
14
|
-
};
|