@saasquatch/component-environment 1.0.0-0 → 1.0.0-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 +13 -0
- package/README.md +46 -0
- package/dist/index.d.ts +226 -5
- package/dist/index.js +431 -5
- package/dist/index.mjs +386 -0
- package/package.json +6 -4
- package/src/fetchLocale.ts +10 -4
- package/src/listeners.ts +16 -15
- package/tsconfig.json +1 -1
- package/dist/LocaleContext.d.ts +0 -7
- package/dist/LocaleContext.js +0 -43
- package/dist/ProgramContext.d.ts +0 -13
- package/dist/ProgramContext.js +0 -29
- package/dist/UserIdentityContext.d.ts +0 -10
- package/dist/UserIdentityContext.js +0 -124
- package/dist/contexts/LocaleContext.d.ts +0 -18
- package/dist/contexts/LocaleContext.js +0 -41
- package/dist/contexts/ProgramContext.d.ts +0 -18
- package/dist/contexts/ProgramContext.js +0 -42
- package/dist/contexts/UserIdentityContext.d.ts +0 -26
- package/dist/contexts/UserIdentityContext.js +0 -146
- package/dist/debug.d.ts +0 -1
- package/dist/debug.js +0 -6
- package/dist/environment.d.ts +0 -15
- package/dist/environment.js +0 -98
- package/dist/fetchLocale.d.ts +0 -1
- package/dist/fetchLocale.js +0 -37
- package/dist/listeners.d.ts +0 -1
- package/dist/listeners.js +0 -44
- package/dist/types.d.ts +0 -147
- package/dist/types.js +0 -4
package/dist/types.d.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import type { ContextProvider } from "dom-context";
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
SquatchPortal?: PortalEnv;
|
|
5
|
-
widgetIdent?: WidgetIdent;
|
|
6
|
-
squatchUserIdentity?: ContextProvider<UserIdentity | undefined>;
|
|
7
|
-
squatchLocale?: ContextProvider<string | undefined>;
|
|
8
|
-
squatchProgramId?: ContextProvider<string | undefined>;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export declare type UserContextName = "sq:user-identity";
|
|
12
|
-
export declare type LocaleContextName = "sq:locale";
|
|
13
|
-
export declare type ProgramContextName = "sq:program-id";
|
|
14
|
-
export declare const USER_CONTEXT_NAME: UserContextName;
|
|
15
|
-
export declare const LOCALE_CONTEXT_NAME: LocaleContextName;
|
|
16
|
-
export declare const PROGRAM_CONTEXT_NAME: ProgramContextName;
|
|
17
|
-
/**
|
|
18
|
-
* The value stored in the UserContext
|
|
19
|
-
*/
|
|
20
|
-
export declare type UserIdentity = {
|
|
21
|
-
id: string;
|
|
22
|
-
accountId: string;
|
|
23
|
-
jwt?: string;
|
|
24
|
-
managedIdentity?: {
|
|
25
|
-
email: string;
|
|
26
|
-
emailVerified: boolean;
|
|
27
|
-
sessionData?: {
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export declare type UserId = {
|
|
33
|
-
id: string;
|
|
34
|
-
accountId: string;
|
|
35
|
-
};
|
|
36
|
-
export interface DecodedSquatchJWT {
|
|
37
|
-
exp?: number;
|
|
38
|
-
user: {
|
|
39
|
-
accountId: string;
|
|
40
|
-
id: string;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export interface DecodedWidgetAPIJWT {
|
|
44
|
-
exp?: number;
|
|
45
|
-
sub: string;
|
|
46
|
-
}
|
|
47
|
-
export declare type EngagementMedium = "EMBED" | "POPUP";
|
|
48
|
-
export declare const DEFAULT_MEDIUM: EngagementMedium;
|
|
49
|
-
/**
|
|
50
|
-
* Provided by the SaaSquatch GraphQL backend when a widget is rendered.
|
|
51
|
-
*
|
|
52
|
-
* Source: https://github.com/saasquatch/saasquatch/blob/805e51284f818f8656b6458bcee6181f378819d3/packages/saasquatch-core/app/saasquatch/controllers/api/widget/WidgetApi.java
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
export interface WidgetIdent {
|
|
56
|
-
tenantAlias: string;
|
|
57
|
-
appDomain: string;
|
|
58
|
-
token: string;
|
|
59
|
-
userId: string;
|
|
60
|
-
accountId: string;
|
|
61
|
-
locale?: string;
|
|
62
|
-
engagementMedium?: "POPUP" | "EMBED";
|
|
63
|
-
programId?: string;
|
|
64
|
-
env?: string;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Portal env doesn't include User Id
|
|
68
|
-
*/
|
|
69
|
-
export declare type PortalEnv = Pick<WidgetIdent, "tenantAlias" | "appDomain" | "programId">;
|
|
70
|
-
/**
|
|
71
|
-
* An interface for interacting with the SaaSquatch Admin Portal.
|
|
72
|
-
*
|
|
73
|
-
* Used for rendering widgets in a preview/demo mode.
|
|
74
|
-
*/
|
|
75
|
-
export interface SquatchAdmin {
|
|
76
|
-
/**
|
|
77
|
-
* Provides a way of providing user feedback when a widget is rendered in the SaaSquatch admin portal
|
|
78
|
-
*
|
|
79
|
-
* @param text
|
|
80
|
-
*/
|
|
81
|
-
showMessage(text: string): void;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Type for the Javascript environment added by https://github.com/saasquatch/squatch-android
|
|
85
|
-
*
|
|
86
|
-
* Should exist as `window.SquatchAndroid`
|
|
87
|
-
*/
|
|
88
|
-
export interface SquatchAndroid {
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
* @param shareLink
|
|
92
|
-
* @param messageLink fallback URL to redirect to if the app is not installed
|
|
93
|
-
*/
|
|
94
|
-
shareOnFacebook(shareLink: string, messageLink: string): void;
|
|
95
|
-
/**
|
|
96
|
-
* Shows a native Android toast
|
|
97
|
-
*
|
|
98
|
-
* @param text
|
|
99
|
-
*/
|
|
100
|
-
showToast(text: string): void;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* An interface provided by Squatch.js V2 for widgets.
|
|
104
|
-
*
|
|
105
|
-
* See: https://github.com/saasquatch/squatch-js/blob/8f2b218c9d55567e0cc12d27d635a5fb545e6842/src/widgets/Widget.ts#L47
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
export interface SquatchJS2 {
|
|
109
|
-
/**
|
|
110
|
-
* Opens the current popup widget (if loaded as a popup)
|
|
111
|
-
*/
|
|
112
|
-
open?: () => void;
|
|
113
|
-
/**
|
|
114
|
-
* Closes the current popup widget (if loaded as a popup)
|
|
115
|
-
*/
|
|
116
|
-
close?: () => void;
|
|
117
|
-
/**
|
|
118
|
-
* DEPRECATED used to update user details from inside the widget.
|
|
119
|
-
*
|
|
120
|
-
* Should no longer be used. Replace with natively using the GraphQL API and re-rendering locally. Will be removed in a future version of Squatch.js
|
|
121
|
-
*
|
|
122
|
-
* @deprecated
|
|
123
|
-
*/
|
|
124
|
-
reload(userDetails: {
|
|
125
|
-
email: string;
|
|
126
|
-
firstName: string;
|
|
127
|
-
lastName: string;
|
|
128
|
-
}, jwt: string): void;
|
|
129
|
-
}
|
|
130
|
-
export declare type Environment = EnvironmentSDK["type"];
|
|
131
|
-
export declare type EnvironmentSDK = {
|
|
132
|
-
type: "SquatchJS2";
|
|
133
|
-
api: SquatchJS2;
|
|
134
|
-
widgetIdent: WidgetIdent;
|
|
135
|
-
} | {
|
|
136
|
-
type: "SquatchAndroid";
|
|
137
|
-
android: SquatchAndroid;
|
|
138
|
-
widgetIdent: WidgetIdent;
|
|
139
|
-
} | {
|
|
140
|
-
type: "SquatchPortal";
|
|
141
|
-
env: PortalEnv;
|
|
142
|
-
} | {
|
|
143
|
-
type: "SquatchAdmin";
|
|
144
|
-
adminSDK: SquatchAdmin;
|
|
145
|
-
} | {
|
|
146
|
-
type: "None";
|
|
147
|
-
};
|
package/dist/types.js
DELETED