@saasquatch/squatch-js 2.4.3-3 → 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/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,13 +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?: 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
- displayOnLoad?: boolean;
36
32
  }
37
33
  /**
38
34
  * @param user The user details
@@ -76,19 +72,18 @@ export declare type EngagementMedium =
76
72
  /** Displays the widget embedded in the page. Create an {@link EmbedWidget} */
77
73
  | "EMBED";
78
74
  export declare type WidgetContext = {
79
- type: "cookie" | "error" | "passwordless";
75
+ type: "cookie" | "error";
80
76
  engagementMedium?: EngagementMedium;
81
77
  container?: HTMLElement | string;
82
78
  trigger?: string;
83
- displayOnLoad?: boolean;
84
79
  } | {
85
80
  type: "upsert";
86
- user?: User | null;
81
+ user: User;
87
82
  engagementMedium?: EngagementMedium;
88
83
  container?: HTMLElement | string;
89
84
  trigger?: string;
90
85
  };
91
- export declare type WidgetContextType = "upsert" | "cookie" | "error" | "passwordless";
86
+ export declare type WidgetContextType = "upsert" | "cookie" | "error";
92
87
  /**
93
88
  * WidgetType is an enum for types of ways a Widget can be displayed.
94
89
  */
@@ -99,3 +94,7 @@ export declare type WidgetType =
99
94
  | "CONVERSION_WIDGET" | string;
100
95
  export declare type ShareMedium = string;
101
96
  export declare type JWT = string;
97
+ export declare type ReferralCookie = {
98
+ codes: string[];
99
+ encodedCookie: string;
100
+ };
@@ -1,2 +1 @@
1
- export declare function b64decode(input: any): string;
2
1
  export declare function _pushCookie(): void;
@@ -1,6 +1,5 @@
1
1
  import { JWT } from "../types";
2
- export declare function doQuery(url: string, query: string, variables: any, token: string | undefined): Promise<any>;
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
  *
@@ -11,5 +11,4 @@ declare type Required<T> = T extends object ? {
11
11
  } : T;
12
12
  export declare function validateConfig(raw: unknown): Required<ConfigOptions>;
13
13
  export declare function validateWidgetConfig(raw: unknown): WidgetConfig;
14
- export declare function validatePasswordlessConfig(raw: unknown): WidgetConfig;
15
14
  export {};
@@ -1,5 +1,5 @@
1
1
  import WidgetApi from "../api/WidgetApi";
2
- import { WidgetResult, WithRequired } from "../types";
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: WithRequired<WidgetConfig, "user">): Promise<{
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 | undefined>;
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-3",
4
- "description": "The official Referral SaaSquatch Javascript Web/Browser SDK https://docs.referralsaasquatch.com/developer/squatchjs/",
5
- "license": "MIT",
6
- "types": "dist/squatch.d.ts",
7
- "source": "src/squatch.ts",
8
- "main": "dist/squatch.js",
9
- "module": "dist/squatch.esm.js",
10
- "umd:main": "dist/squatch.min.js",
11
- "browser": "dist/squatch.min.js",
12
- "bugs": {
13
- "url": "https://github.com/saasquatch/squatch-js/issues",
14
- "email": "support@referralsaasquatch.com"
15
- },
16
- "engines": {
17
- "node": ">=12.16.0"
18
- },
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/saasquatch/squatch-js.git"
22
- },
23
- "tsd": {
24
- "directory": "test/tsd"
25
- },
26
- "sideEffects": false,
27
- "scripts": {
28
- "build:es": "microbundle --target node --format cjs,es",
29
- "build:umd": "webpack",
30
- "build": "run-s build:es build:umd",
31
- "watch": "webpack --watch",
32
- "declaration": "tsc --emitDeclarationOnly",
33
- "test:browser": "cucumber-js",
34
- "test:webkit": "cross-env BROWSER=webkit cucumber-js",
35
- "test:firefox": "cross-env BROWSER=firefox cucumber-js",
36
- "test:types": "tsd",
37
- "test": "run-s test:types test:browser",
38
- "build:docs": "typedoc --out docs/ src/ ",
39
- "deploy": "np --no-cleanup",
40
- "deploy:docs": "surge ./ -d squathjsv2.surge.sh",
41
- "preversion": "run-s build",
42
- "demo": "msw init demo/dist/ --save && run-p static parcel",
43
- "demo:deploy": "run-s parcel:build parcel:deploy",
44
- "static": "serve -l 3333 -s dist",
45
- "parcel": "cd demo && parcel index.html",
46
- "parcel:build": "cd demo && parcel build index.html",
47
- "parcel:deploy": "surge demo/dist -d squathjs-demo.surge.sh"
48
- },
49
- "devDependencies": {
50
- "@babel/core": "^7.14.3",
51
- "@babel/plugin-proposal-class-properties": "^7.13.0",
52
- "@babel/plugin-transform-runtime": "^7.14.3",
53
- "@babel/preset-env": "^7.14.2",
54
- "@babel/preset-typescript": "^7.13.0",
55
- "@babel/register": "^7.13.16",
56
- "@babel/runtime-corejs2": "^7.14.0",
57
- "@types/chai": "^4.2.11",
58
- "@types/cucumber": "^6.0.1",
59
- "@types/debug": "4.1.5",
60
- "@types/express": "^4.17.6",
61
- "@types/js-cookie": "^2.2.6",
62
- "@types/jsdom-global": "^3.0.2",
63
- "@types/react": "^16.9.35",
64
- "@types/superagent": "^4.1.7",
65
- "@ungap/url-search-params": "^0.2.0",
66
- "babel-loader": "^8.2.2",
67
- "base64-url": "^2.3.3",
68
- "chai": "^4.2.0",
69
- "cross-env": "^7.0.2",
70
- "cucumber": "^6.0.5",
71
- "express": "^4.17.1",
72
- "microbundle": "^0.13.0",
73
- "msw": "^0.36.0",
74
- "np": "^6.2.3",
75
- "npm-run-all": "^4.1.5",
76
- "parcel": "^1.12.3",
77
- "parcel-bundler": "^1.12.4",
78
- "playwright": "^1.33.0-alpha-mar-29-2023",
79
- "react": "^16.13.1",
80
- "react-bootstrap": "^1.0.1",
81
- "react-dom": "^16.13.1",
82
- "react-url-query": "^1.5.0",
83
- "serve": "^11.3.0",
84
- "ts-loader": "^7.0.4",
85
- "ts-node": "^8.10.2",
86
- "tsd": "^0.13.1",
87
- "typedoc": "^0.17.7",
88
- "typescript": "^3.9.3",
89
- "webpack": "^4.46.0",
90
- "webpack-cli": "^3.3.12",
91
- "webpack-visualizer-plugin": "^0.1.11"
92
- },
93
- "prettier": {},
94
- "dependencies": {
95
- "debug": "^3.2.6",
96
- "eventbusjs": "^0.2.0",
97
- "js-cookie": "^2.2.1",
98
- "superagent": "^5.2.2"
99
- },
100
- "browserslist": "> 0.25%, not dead",
101
- "msw": {
102
- "workerDirectory": "demo/dist"
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
+ }
@@ -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
- };