@go1/go1-embedding-react-sdk 0.0.16 → 0.0.19
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/README.md +78 -32
- package/dist/README.md +78 -32
- package/dist/common/params.d.ts +2 -1
- package/dist/common/params.js +3 -11
- package/dist/common/types.d.ts +20 -6
- package/dist/go1-embedding-react-sdk/src/index.js +1 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,11 +13,11 @@ npm install @go1/go1-embedding-react-sdk
|
|
|
13
13
|
Import the hook from the library and use it in your functional components.
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
|
-
import { useMemo, useCallback } from
|
|
17
|
-
import { ContentViewProps, useGo1ContentView } from
|
|
16
|
+
import { useMemo, useCallback } from 'react';
|
|
17
|
+
import { ContentViewProps, useGo1ContentView } from '@go1/go1-embedding-react-sdk';
|
|
18
18
|
|
|
19
19
|
export function YourHostingComponent() {
|
|
20
|
-
const onGo1MessageReceived = useCallback(message => {
|
|
20
|
+
const onGo1MessageReceived = useCallback((message) => {
|
|
21
21
|
console.log('Received postMessage from Go1');
|
|
22
22
|
console.log(message);
|
|
23
23
|
}, []);
|
|
@@ -33,7 +33,7 @@ export function YourHostingComponent() {
|
|
|
33
33
|
const { sendMessageToGo1, ContentView } = useGo1ContentView(options);
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<div style={{ width:
|
|
36
|
+
<div style={{ width: '100vw', height: '100vh' }}>
|
|
37
37
|
<ContentView />
|
|
38
38
|
</div>
|
|
39
39
|
);
|
|
@@ -45,34 +45,51 @@ export function YourHostingComponent() {
|
|
|
45
45
|
### Types
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
|
-
type OnGo1MessageReceived = (message: Go1Message) => void;
|
|
48
|
+
export type OnGo1MessageReceived = (message: Go1Message) => void;
|
|
49
49
|
|
|
50
|
-
type SendMessageToGo1 = (message: Go1Message) => void;
|
|
50
|
+
export type SendMessageToGo1 = (message: Go1Message) => void;
|
|
51
51
|
|
|
52
|
-
type
|
|
53
|
-
'preview_start_content' |
|
|
54
|
-
'preview_close' |
|
|
55
|
-
'preview_add_content_success' |
|
|
56
|
-
'preview_add_content_failure' |
|
|
57
|
-
'preview_remove_content_success' |
|
|
58
|
-
'preview_remove_content_failure' |
|
|
59
|
-
'set_additional_embedding_data' |
|
|
60
|
-
'go1_app_initialised';
|
|
52
|
+
export type IframesMap = { [key: string]: HTMLIFrameElement };
|
|
61
53
|
|
|
62
|
-
interface
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
export interface AdditionalInfoMessage {
|
|
55
|
+
additionalUserInfo?: AdditionalUserInfo;
|
|
56
|
+
featureAttributes?: FeatureAttributes;
|
|
57
|
+
themeInformation?: ThemeInformation;
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
interface ThemeInformation {
|
|
60
|
+
export interface ThemeInformation {
|
|
68
61
|
/** Hex string, starting with a #. Example #0437F2 */
|
|
69
62
|
accent: string;
|
|
70
63
|
}
|
|
71
64
|
|
|
65
|
+
export type Go1MessageType =
|
|
66
|
+
| 'preview_start_content'
|
|
67
|
+
| 'preview_close'
|
|
68
|
+
| 'preview_add_content_success'
|
|
69
|
+
| 'preview_add_content_failure'
|
|
70
|
+
| 'preview_remove_content_success'
|
|
71
|
+
| 'preview_remove_content_failure'
|
|
72
|
+
| 'parent_show_preview'
|
|
73
|
+
| 'set_additional_embedding_data'
|
|
74
|
+
| 'go1_app_initialised'
|
|
75
|
+
| 'ott_required'
|
|
76
|
+
| 'search_result_selected'
|
|
77
|
+
| 'search_filter_toggle'
|
|
78
|
+
| 'pass_ott';
|
|
79
|
+
|
|
80
|
+
export interface Go1Message {
|
|
81
|
+
type: Go1MessageType;
|
|
82
|
+
payload?: any;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface FeatureAttributeCommon {
|
|
86
|
+
shouldSuppressPreview?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
72
89
|
/**
|
|
73
90
|
* Used to configure the `ai-chat` feature
|
|
74
91
|
*/
|
|
75
|
-
export interface FeatureAttributesAIChat {
|
|
92
|
+
export interface FeatureAttributesAIChat extends FeatureAttributeCommon {
|
|
76
93
|
experience: 'manager' | 'learner';
|
|
77
94
|
intent?: 'skill_gap' | 'improve_skills' | 'next_role' | 'aspirations';
|
|
78
95
|
message?: string; // The desired message to start the chat, which will be shown to the user
|
|
@@ -84,31 +101,60 @@ export interface FeatureAttributesAIChat {
|
|
|
84
101
|
/**
|
|
85
102
|
* Used to configure the `preview` feature
|
|
86
103
|
*/
|
|
87
|
-
export interface FeatureAttributesPreview {
|
|
104
|
+
export interface FeatureAttributesPreview extends FeatureAttributeCommon {
|
|
88
105
|
id: number;
|
|
89
106
|
experience?: 'manager' | 'learner';
|
|
90
107
|
startWith1Player?: boolean;
|
|
91
108
|
}
|
|
92
109
|
|
|
93
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Used to configure the `wallet` feature
|
|
112
|
+
*/
|
|
113
|
+
export interface FeatureAttributesWallet extends FeatureAttributeCommon {
|
|
114
|
+
walletMode: 'setup' | 'main';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface FeatureAttributesLearnerSearch extends FeatureAttributeCommon {
|
|
118
|
+
isGo1MobileApp?: boolean;
|
|
119
|
+
experience?: 'learner';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface FeatureAttributesLibrary extends FeatureAttributeCommon {}
|
|
123
|
+
export interface FeatureAttributesSearch extends FeatureAttributeCommon {}
|
|
124
|
+
|
|
125
|
+
export type FeatureAttributes =
|
|
126
|
+
| FeatureAttributesAIChat
|
|
127
|
+
| FeatureAttributesPreview
|
|
128
|
+
| FeatureAttributesWallet
|
|
129
|
+
| FeatureAttributesLibrary
|
|
130
|
+
| FeatureAttributesSearch
|
|
131
|
+
| FeatureAttributesLearnerSearch;
|
|
94
132
|
|
|
95
133
|
export interface AdditionalUserInfo {
|
|
96
134
|
jobTitle: string;
|
|
97
135
|
}
|
|
98
136
|
|
|
99
|
-
|
|
137
|
+
export type FeatureType = 'ai-chat' | 'content-hub' | 'preview' | 'library' | 'search' | 'wallet' | 'learner-search';
|
|
138
|
+
|
|
139
|
+
export interface InitOptions {
|
|
100
140
|
/** Mandatory identifier for the embedded feature */
|
|
101
|
-
feature:
|
|
141
|
+
feature: FeatureType;
|
|
142
|
+
// eslint-disable-next-line max-len
|
|
143
|
+
/** Optional element id to search for, and use as the parent for the Go1 content view (use either this or `iframeParentElement`, not both) */
|
|
144
|
+
iframeParentId?: string;
|
|
145
|
+
/** Optional element to use as the parent for the Go1 content view (use either this or `iframeParentId`, not both) */
|
|
146
|
+
iframeParentElement?: HTMLElement;
|
|
102
147
|
/** Optional parameters to configure the feature. See associated types for examples */
|
|
103
148
|
featureAttributes?: FeatureAttributes;
|
|
104
149
|
/** Optional Go1 portal URL, used for login purposes if no `oneTimeToken` is provided */
|
|
105
150
|
portalURL?: string;
|
|
106
151
|
/** Optional function that is invoked when the Go1 content view emits a message */
|
|
107
152
|
onGo1MessageReceived?: OnGo1MessageReceived;
|
|
153
|
+
// eslint-disable-next-line max-len
|
|
108
154
|
/** Optional end user information that can enhance the context and provide a better experience. No PII is needed, please do not send any. */
|
|
109
155
|
additionalUserInfo?: AdditionalUserInfo;
|
|
110
156
|
/** Optional UI configuration */
|
|
111
|
-
themeInformation?: ThemeInformation
|
|
157
|
+
themeInformation?: ThemeInformation;
|
|
112
158
|
/** Optional token that is used to pre-authorize the user without them needing to log in */
|
|
113
159
|
oneTimeToken?: string;
|
|
114
160
|
}
|
|
@@ -131,7 +177,7 @@ function useGo1ContentView(options: InitOptions): {
|
|
|
131
177
|
### Usage
|
|
132
178
|
|
|
133
179
|
```typescript
|
|
134
|
-
const onGo1MessageReceived = useCallback(message => {
|
|
180
|
+
const onGo1MessageReceived = useCallback((message) => {
|
|
135
181
|
console.log('Received postMessage from Go1');
|
|
136
182
|
console.log(message);
|
|
137
183
|
}, []);
|
|
@@ -145,12 +191,12 @@ const options = useMemo<ContentViewProps>(() => {
|
|
|
145
191
|
},
|
|
146
192
|
onGo1MessageReceived,
|
|
147
193
|
additionalUserInfo: {
|
|
148
|
-
jobTitle: 'Sales development representative'
|
|
194
|
+
jobTitle: 'Sales development representative',
|
|
149
195
|
},
|
|
150
196
|
themeInformation: {
|
|
151
|
-
accent: '#0437F2'
|
|
197
|
+
accent: '#0437F2',
|
|
152
198
|
},
|
|
153
|
-
oneTimeToken: '907687a6e81a458190fe4c21f05ee689'
|
|
199
|
+
oneTimeToken: '907687a6e81a458190fe4c21f05ee689',
|
|
154
200
|
};
|
|
155
201
|
}, []);
|
|
156
202
|
|
|
@@ -171,7 +217,7 @@ function sendMessageToGo1(message: Go1Message): void;
|
|
|
171
217
|
|
|
172
218
|
```typescript
|
|
173
219
|
const message = {
|
|
174
|
-
type:
|
|
220
|
+
type: 'return_to_home_screen',
|
|
175
221
|
};
|
|
176
222
|
sendMessageToGo1(message);
|
|
177
223
|
```
|
|
@@ -185,12 +231,12 @@ Respond to events that have occurred in the Go1 content view. Useful to control
|
|
|
185
231
|
```typescript
|
|
186
232
|
const onGo1MessageReceived = (message) => {
|
|
187
233
|
switch (message.type) {
|
|
188
|
-
case
|
|
234
|
+
case 'enrolment_created': {
|
|
189
235
|
const { userId, courseId } = message.payload;
|
|
190
236
|
// perform appropriate actions for when a new enrolment is created
|
|
191
237
|
break;
|
|
192
238
|
}
|
|
193
|
-
case
|
|
239
|
+
case 'category_favourite_added': {
|
|
194
240
|
const { userId, category } = message.payload;
|
|
195
241
|
// perform appropriate actions for when a new category is favourited
|
|
196
242
|
break;
|
package/dist/README.md
CHANGED
|
@@ -13,11 +13,11 @@ npm install @go1/go1-embedding-react-sdk
|
|
|
13
13
|
Import the hook from the library and use it in your functional components.
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
|
-
import { useMemo, useCallback } from
|
|
17
|
-
import { ContentViewProps, useGo1ContentView } from
|
|
16
|
+
import { useMemo, useCallback } from 'react';
|
|
17
|
+
import { ContentViewProps, useGo1ContentView } from '@go1/go1-embedding-react-sdk';
|
|
18
18
|
|
|
19
19
|
export function YourHostingComponent() {
|
|
20
|
-
const onGo1MessageReceived = useCallback(message => {
|
|
20
|
+
const onGo1MessageReceived = useCallback((message) => {
|
|
21
21
|
console.log('Received postMessage from Go1');
|
|
22
22
|
console.log(message);
|
|
23
23
|
}, []);
|
|
@@ -33,7 +33,7 @@ export function YourHostingComponent() {
|
|
|
33
33
|
const { sendMessageToGo1, ContentView } = useGo1ContentView(options);
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<div style={{ width:
|
|
36
|
+
<div style={{ width: '100vw', height: '100vh' }}>
|
|
37
37
|
<ContentView />
|
|
38
38
|
</div>
|
|
39
39
|
);
|
|
@@ -45,34 +45,51 @@ export function YourHostingComponent() {
|
|
|
45
45
|
### Types
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
|
-
type OnGo1MessageReceived = (message: Go1Message) => void;
|
|
48
|
+
export type OnGo1MessageReceived = (message: Go1Message) => void;
|
|
49
49
|
|
|
50
|
-
type SendMessageToGo1 = (message: Go1Message) => void;
|
|
50
|
+
export type SendMessageToGo1 = (message: Go1Message) => void;
|
|
51
51
|
|
|
52
|
-
type
|
|
53
|
-
'preview_start_content' |
|
|
54
|
-
'preview_close' |
|
|
55
|
-
'preview_add_content_success' |
|
|
56
|
-
'preview_add_content_failure' |
|
|
57
|
-
'preview_remove_content_success' |
|
|
58
|
-
'preview_remove_content_failure' |
|
|
59
|
-
'set_additional_embedding_data' |
|
|
60
|
-
'go1_app_initialised';
|
|
52
|
+
export type IframesMap = { [key: string]: HTMLIFrameElement };
|
|
61
53
|
|
|
62
|
-
interface
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
export interface AdditionalInfoMessage {
|
|
55
|
+
additionalUserInfo?: AdditionalUserInfo;
|
|
56
|
+
featureAttributes?: FeatureAttributes;
|
|
57
|
+
themeInformation?: ThemeInformation;
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
interface ThemeInformation {
|
|
60
|
+
export interface ThemeInformation {
|
|
68
61
|
/** Hex string, starting with a #. Example #0437F2 */
|
|
69
62
|
accent: string;
|
|
70
63
|
}
|
|
71
64
|
|
|
65
|
+
export type Go1MessageType =
|
|
66
|
+
| 'preview_start_content'
|
|
67
|
+
| 'preview_close'
|
|
68
|
+
| 'preview_add_content_success'
|
|
69
|
+
| 'preview_add_content_failure'
|
|
70
|
+
| 'preview_remove_content_success'
|
|
71
|
+
| 'preview_remove_content_failure'
|
|
72
|
+
| 'parent_show_preview'
|
|
73
|
+
| 'set_additional_embedding_data'
|
|
74
|
+
| 'go1_app_initialised'
|
|
75
|
+
| 'ott_required'
|
|
76
|
+
| 'search_result_selected'
|
|
77
|
+
| 'search_filter_toggle'
|
|
78
|
+
| 'pass_ott';
|
|
79
|
+
|
|
80
|
+
export interface Go1Message {
|
|
81
|
+
type: Go1MessageType;
|
|
82
|
+
payload?: any;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface FeatureAttributeCommon {
|
|
86
|
+
shouldSuppressPreview?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
72
89
|
/**
|
|
73
90
|
* Used to configure the `ai-chat` feature
|
|
74
91
|
*/
|
|
75
|
-
export interface FeatureAttributesAIChat {
|
|
92
|
+
export interface FeatureAttributesAIChat extends FeatureAttributeCommon {
|
|
76
93
|
experience: 'manager' | 'learner';
|
|
77
94
|
intent?: 'skill_gap' | 'improve_skills' | 'next_role' | 'aspirations';
|
|
78
95
|
message?: string; // The desired message to start the chat, which will be shown to the user
|
|
@@ -84,31 +101,60 @@ export interface FeatureAttributesAIChat {
|
|
|
84
101
|
/**
|
|
85
102
|
* Used to configure the `preview` feature
|
|
86
103
|
*/
|
|
87
|
-
export interface FeatureAttributesPreview {
|
|
104
|
+
export interface FeatureAttributesPreview extends FeatureAttributeCommon {
|
|
88
105
|
id: number;
|
|
89
106
|
experience?: 'manager' | 'learner';
|
|
90
107
|
startWith1Player?: boolean;
|
|
91
108
|
}
|
|
92
109
|
|
|
93
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Used to configure the `wallet` feature
|
|
112
|
+
*/
|
|
113
|
+
export interface FeatureAttributesWallet extends FeatureAttributeCommon {
|
|
114
|
+
walletMode: 'setup' | 'main';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface FeatureAttributesLearnerSearch extends FeatureAttributeCommon {
|
|
118
|
+
isGo1MobileApp?: boolean;
|
|
119
|
+
experience?: 'learner';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface FeatureAttributesLibrary extends FeatureAttributeCommon {}
|
|
123
|
+
export interface FeatureAttributesSearch extends FeatureAttributeCommon {}
|
|
124
|
+
|
|
125
|
+
export type FeatureAttributes =
|
|
126
|
+
| FeatureAttributesAIChat
|
|
127
|
+
| FeatureAttributesPreview
|
|
128
|
+
| FeatureAttributesWallet
|
|
129
|
+
| FeatureAttributesLibrary
|
|
130
|
+
| FeatureAttributesSearch
|
|
131
|
+
| FeatureAttributesLearnerSearch;
|
|
94
132
|
|
|
95
133
|
export interface AdditionalUserInfo {
|
|
96
134
|
jobTitle: string;
|
|
97
135
|
}
|
|
98
136
|
|
|
99
|
-
|
|
137
|
+
export type FeatureType = 'ai-chat' | 'content-hub' | 'preview' | 'library' | 'search' | 'wallet' | 'learner-search';
|
|
138
|
+
|
|
139
|
+
export interface InitOptions {
|
|
100
140
|
/** Mandatory identifier for the embedded feature */
|
|
101
|
-
feature:
|
|
141
|
+
feature: FeatureType;
|
|
142
|
+
// eslint-disable-next-line max-len
|
|
143
|
+
/** Optional element id to search for, and use as the parent for the Go1 content view (use either this or `iframeParentElement`, not both) */
|
|
144
|
+
iframeParentId?: string;
|
|
145
|
+
/** Optional element to use as the parent for the Go1 content view (use either this or `iframeParentId`, not both) */
|
|
146
|
+
iframeParentElement?: HTMLElement;
|
|
102
147
|
/** Optional parameters to configure the feature. See associated types for examples */
|
|
103
148
|
featureAttributes?: FeatureAttributes;
|
|
104
149
|
/** Optional Go1 portal URL, used for login purposes if no `oneTimeToken` is provided */
|
|
105
150
|
portalURL?: string;
|
|
106
151
|
/** Optional function that is invoked when the Go1 content view emits a message */
|
|
107
152
|
onGo1MessageReceived?: OnGo1MessageReceived;
|
|
153
|
+
// eslint-disable-next-line max-len
|
|
108
154
|
/** Optional end user information that can enhance the context and provide a better experience. No PII is needed, please do not send any. */
|
|
109
155
|
additionalUserInfo?: AdditionalUserInfo;
|
|
110
156
|
/** Optional UI configuration */
|
|
111
|
-
themeInformation?: ThemeInformation
|
|
157
|
+
themeInformation?: ThemeInformation;
|
|
112
158
|
/** Optional token that is used to pre-authorize the user without them needing to log in */
|
|
113
159
|
oneTimeToken?: string;
|
|
114
160
|
}
|
|
@@ -131,7 +177,7 @@ function useGo1ContentView(options: InitOptions): {
|
|
|
131
177
|
### Usage
|
|
132
178
|
|
|
133
179
|
```typescript
|
|
134
|
-
const onGo1MessageReceived = useCallback(message => {
|
|
180
|
+
const onGo1MessageReceived = useCallback((message) => {
|
|
135
181
|
console.log('Received postMessage from Go1');
|
|
136
182
|
console.log(message);
|
|
137
183
|
}, []);
|
|
@@ -145,12 +191,12 @@ const options = useMemo<ContentViewProps>(() => {
|
|
|
145
191
|
},
|
|
146
192
|
onGo1MessageReceived,
|
|
147
193
|
additionalUserInfo: {
|
|
148
|
-
jobTitle: 'Sales development representative'
|
|
194
|
+
jobTitle: 'Sales development representative',
|
|
149
195
|
},
|
|
150
196
|
themeInformation: {
|
|
151
|
-
accent: '#0437F2'
|
|
197
|
+
accent: '#0437F2',
|
|
152
198
|
},
|
|
153
|
-
oneTimeToken: '907687a6e81a458190fe4c21f05ee689'
|
|
199
|
+
oneTimeToken: '907687a6e81a458190fe4c21f05ee689',
|
|
154
200
|
};
|
|
155
201
|
}, []);
|
|
156
202
|
|
|
@@ -171,7 +217,7 @@ function sendMessageToGo1(message: Go1Message): void;
|
|
|
171
217
|
|
|
172
218
|
```typescript
|
|
173
219
|
const message = {
|
|
174
|
-
type:
|
|
220
|
+
type: 'return_to_home_screen',
|
|
175
221
|
};
|
|
176
222
|
sendMessageToGo1(message);
|
|
177
223
|
```
|
|
@@ -185,12 +231,12 @@ Respond to events that have occurred in the Go1 content view. Useful to control
|
|
|
185
231
|
```typescript
|
|
186
232
|
const onGo1MessageReceived = (message) => {
|
|
187
233
|
switch (message.type) {
|
|
188
|
-
case
|
|
234
|
+
case 'enrolment_created': {
|
|
189
235
|
const { userId, courseId } = message.payload;
|
|
190
236
|
// perform appropriate actions for when a new enrolment is created
|
|
191
237
|
break;
|
|
192
238
|
}
|
|
193
|
-
case
|
|
239
|
+
case 'category_favourite_added': {
|
|
194
240
|
const { userId, category } = message.payload;
|
|
195
241
|
// perform appropriate actions for when a new category is favourited
|
|
196
242
|
break;
|
package/dist/common/params.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { FeatureType } from './types';
|
|
1
2
|
export declare function addPortalURL(url: URL, portalURL: string, env?: 'staging' | 'production'): void;
|
|
2
3
|
export declare function addOneTimeToken(url: URL, oneTimeToken: string): void;
|
|
3
4
|
export declare function isValidOTT(oneTimeToken: string): boolean;
|
|
4
|
-
export declare function isValidFeature(feature:
|
|
5
|
+
export declare function isValidFeature(feature: FeatureType): boolean;
|
package/dist/common/params.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isValidFeature = exports.isValidOTT = exports.addOneTimeToken = exports.addPortalURL = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
4
5
|
function addPortalURL(url, portalURL, env = 'production') {
|
|
5
6
|
let validPortalURL = /^(?=.{1,255}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,245}[a-zA-Z0-9])?\.mygo1\.com$/;
|
|
6
7
|
if (env === 'staging') {
|
|
7
|
-
validPortalURL =
|
|
8
|
-
/^(?=.{1,255}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,245}[a-zA-Z0-9])?\.qa\.go1\.cloud$/;
|
|
8
|
+
validPortalURL = /^(?=.{1,255}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,245}[a-zA-Z0-9])?\.qa\.go1\.cloud$/;
|
|
9
9
|
}
|
|
10
10
|
if (validPortalURL.test(portalURL)) {
|
|
11
11
|
url.searchParams.append('portal_url', portalURL);
|
|
@@ -30,14 +30,6 @@ function isValidOTT(oneTimeToken) {
|
|
|
30
30
|
}
|
|
31
31
|
exports.isValidOTT = isValidOTT;
|
|
32
32
|
function isValidFeature(feature) {
|
|
33
|
-
return
|
|
34
|
-
'ai-chat',
|
|
35
|
-
'content-hub',
|
|
36
|
-
'preview',
|
|
37
|
-
'library',
|
|
38
|
-
'search',
|
|
39
|
-
'wallet',
|
|
40
|
-
'learner-search',
|
|
41
|
-
].includes(feature);
|
|
33
|
+
return types_1.features.includes(feature);
|
|
42
34
|
}
|
|
43
35
|
exports.isValidFeature = isValidFeature;
|
package/dist/common/types.d.ts
CHANGED
|
@@ -11,12 +11,15 @@ export interface AdditionalInfoMessage {
|
|
|
11
11
|
export interface ThemeInformation {
|
|
12
12
|
accent: string;
|
|
13
13
|
}
|
|
14
|
-
export type Go1MessageType = 'preview_start_content' | 'preview_close' | 'preview_add_content_success' | 'preview_add_content_failure' | 'preview_remove_content_success' | 'preview_remove_content_failure' | 'set_additional_embedding_data' | 'go1_app_initialised' | 'ott_required' | 'pass_ott';
|
|
14
|
+
export type Go1MessageType = 'preview_start_content' | 'preview_close' | 'preview_add_content_success' | 'preview_add_content_failure' | 'preview_remove_content_success' | 'preview_remove_content_failure' | 'parent_show_preview' | 'set_additional_embedding_data' | 'go1_app_initialised' | 'ott_required' | 'search_result_selected' | 'search_filter_toggle' | 'pass_ott';
|
|
15
15
|
export interface Go1Message {
|
|
16
16
|
type: Go1MessageType;
|
|
17
17
|
payload?: any;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
interface FeatureAttributeCommon {
|
|
20
|
+
shouldSuppressPreview?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface FeatureAttributesAIChat extends FeatureAttributeCommon {
|
|
20
23
|
experience: 'manager' | 'learner';
|
|
21
24
|
intent?: 'skill_gap' | 'improve_skills' | 'next_role' | 'aspirations';
|
|
22
25
|
message?: string;
|
|
@@ -24,20 +27,30 @@ export interface FeatureAttributesAIChat {
|
|
|
24
27
|
desiredSkills?: string[];
|
|
25
28
|
desiredRole?: string;
|
|
26
29
|
}
|
|
27
|
-
export interface FeatureAttributesPreview {
|
|
30
|
+
export interface FeatureAttributesPreview extends FeatureAttributeCommon {
|
|
28
31
|
id: number;
|
|
29
32
|
experience?: 'manager' | 'learner';
|
|
30
33
|
startWith1Player?: boolean;
|
|
31
34
|
}
|
|
32
|
-
export interface FeatureAttributesWallet {
|
|
35
|
+
export interface FeatureAttributesWallet extends FeatureAttributeCommon {
|
|
33
36
|
walletMode: 'setup' | 'main';
|
|
34
37
|
}
|
|
35
|
-
export
|
|
38
|
+
export interface FeatureAttributesLearnerSearch extends FeatureAttributeCommon {
|
|
39
|
+
isGo1MobileApp?: boolean;
|
|
40
|
+
experience?: 'learner';
|
|
41
|
+
}
|
|
42
|
+
export interface FeatureAttributesLibrary extends FeatureAttributeCommon {
|
|
43
|
+
}
|
|
44
|
+
export interface FeatureAttributesSearch extends FeatureAttributeCommon {
|
|
45
|
+
}
|
|
46
|
+
export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet | FeatureAttributesLibrary | FeatureAttributesSearch | FeatureAttributesLearnerSearch;
|
|
36
47
|
export interface AdditionalUserInfo {
|
|
37
48
|
jobTitle: string;
|
|
38
49
|
}
|
|
50
|
+
export declare const features: readonly ["ai-chat", "content-hub", "preview", "library", "search", "wallet", "learner-search"];
|
|
51
|
+
export type FeatureType = (typeof features)[number];
|
|
39
52
|
export interface InitOptions {
|
|
40
|
-
feature:
|
|
53
|
+
feature: FeatureType;
|
|
41
54
|
iframeParentId?: string;
|
|
42
55
|
iframeParentElement?: HTMLElement;
|
|
43
56
|
featureAttributes?: FeatureAttributes;
|
|
@@ -47,3 +60,4 @@ export interface InitOptions {
|
|
|
47
60
|
themeInformation?: ThemeInformation;
|
|
48
61
|
oneTimeToken?: string;
|
|
49
62
|
}
|
|
63
|
+
export {};
|
|
@@ -49,13 +49,7 @@ function useGo1ContentView(props) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
}, [
|
|
53
|
-
additionalUserInfo,
|
|
54
|
-
sendMessageToGo1,
|
|
55
|
-
onGo1MessageReceived,
|
|
56
|
-
themeInformation,
|
|
57
|
-
featureAttributes,
|
|
58
|
-
]);
|
|
52
|
+
}, [additionalUserInfo, sendMessageToGo1, onGo1MessageReceived, themeInformation, featureAttributes]);
|
|
59
53
|
(0, react_1.useEffect)(() => {
|
|
60
54
|
window.addEventListener('message', eventListenerInstance);
|
|
61
55
|
return () => {
|