@go1/go1-embedding-react-sdk 0.0.15 → 0.0.18

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 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 "react";
17
- import { ContentViewProps, useGo1ContentView } from "@go1/go1-embedding-react-sdk";
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: "100vw", height: "100vh" }}>
36
+ <div style={{ width: '100vw', height: '100vh' }}>
37
37
  <ContentView />
38
38
  </div>
39
39
  );
@@ -50,14 +50,14 @@ type OnGo1MessageReceived = (message: Go1Message) => void;
50
50
  type SendMessageToGo1 = (message: Go1Message) => void;
51
51
 
52
52
  type Go1MessageType =
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';
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';
61
61
 
62
62
  interface Go1Message {
63
63
  type: Go1MessageType;
@@ -87,10 +87,10 @@ export interface FeatureAttributesAIChat {
87
87
  export interface FeatureAttributesPreview {
88
88
  id: number;
89
89
  experience?: 'manager' | 'learner';
90
- uiConfig?: UIConfig;
90
+ startWith1Player?: boolean;
91
91
  }
92
92
 
93
- export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
93
+ export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
94
94
 
95
95
  export interface AdditionalUserInfo {
96
96
  jobTitle: string;
@@ -108,7 +108,7 @@ interface InitOptions {
108
108
  /** Optional end user information that can enhance the context and provide a better experience. No PII is needed, please do not send any. */
109
109
  additionalUserInfo?: AdditionalUserInfo;
110
110
  /** Optional UI configuration */
111
- themeInformation?: ThemeInformation
111
+ themeInformation?: ThemeInformation;
112
112
  /** Optional token that is used to pre-authorize the user without them needing to log in */
113
113
  oneTimeToken?: string;
114
114
  }
@@ -131,7 +131,7 @@ function useGo1ContentView(options: InitOptions): {
131
131
  ### Usage
132
132
 
133
133
  ```typescript
134
- const onGo1MessageReceived = useCallback(message => {
134
+ const onGo1MessageReceived = useCallback((message) => {
135
135
  console.log('Received postMessage from Go1');
136
136
  console.log(message);
137
137
  }, []);
@@ -145,12 +145,12 @@ const options = useMemo<ContentViewProps>(() => {
145
145
  },
146
146
  onGo1MessageReceived,
147
147
  additionalUserInfo: {
148
- jobTitle: 'Sales development representative'
148
+ jobTitle: 'Sales development representative',
149
149
  },
150
150
  themeInformation: {
151
- accent: '#0437F2'
151
+ accent: '#0437F2',
152
152
  },
153
- oneTimeToken: '907687a6e81a458190fe4c21f05ee689'
153
+ oneTimeToken: '907687a6e81a458190fe4c21f05ee689',
154
154
  };
155
155
  }, []);
156
156
 
@@ -171,7 +171,7 @@ function sendMessageToGo1(message: Go1Message): void;
171
171
 
172
172
  ```typescript
173
173
  const message = {
174
- type: "return_to_home_screen",
174
+ type: 'return_to_home_screen',
175
175
  };
176
176
  sendMessageToGo1(message);
177
177
  ```
@@ -185,12 +185,12 @@ Respond to events that have occurred in the Go1 content view. Useful to control
185
185
  ```typescript
186
186
  const onGo1MessageReceived = (message) => {
187
187
  switch (message.type) {
188
- case "enrolment_created": {
188
+ case 'enrolment_created': {
189
189
  const { userId, courseId } = message.payload;
190
190
  // perform appropriate actions for when a new enrolment is created
191
191
  break;
192
192
  }
193
- case "category_favourite_added": {
193
+ case 'category_favourite_added': {
194
194
  const { userId, category } = message.payload;
195
195
  // perform appropriate actions for when a new category is favourited
196
196
  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 "react";
17
- import { ContentViewProps, useGo1ContentView } from "@go1/go1-embedding-react-sdk";
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: "100vw", height: "100vh" }}>
36
+ <div style={{ width: '100vw', height: '100vh' }}>
37
37
  <ContentView />
38
38
  </div>
39
39
  );
@@ -50,14 +50,14 @@ type OnGo1MessageReceived = (message: Go1Message) => void;
50
50
  type SendMessageToGo1 = (message: Go1Message) => void;
51
51
 
52
52
  type Go1MessageType =
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';
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';
61
61
 
62
62
  interface Go1Message {
63
63
  type: Go1MessageType;
@@ -87,10 +87,10 @@ export interface FeatureAttributesAIChat {
87
87
  export interface FeatureAttributesPreview {
88
88
  id: number;
89
89
  experience?: 'manager' | 'learner';
90
- uiConfig?: UIConfig;
90
+ startWith1Player?: boolean;
91
91
  }
92
92
 
93
- export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
93
+ export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
94
94
 
95
95
  export interface AdditionalUserInfo {
96
96
  jobTitle: string;
@@ -108,7 +108,7 @@ interface InitOptions {
108
108
  /** Optional end user information that can enhance the context and provide a better experience. No PII is needed, please do not send any. */
109
109
  additionalUserInfo?: AdditionalUserInfo;
110
110
  /** Optional UI configuration */
111
- themeInformation?: ThemeInformation
111
+ themeInformation?: ThemeInformation;
112
112
  /** Optional token that is used to pre-authorize the user without them needing to log in */
113
113
  oneTimeToken?: string;
114
114
  }
@@ -131,7 +131,7 @@ function useGo1ContentView(options: InitOptions): {
131
131
  ### Usage
132
132
 
133
133
  ```typescript
134
- const onGo1MessageReceived = useCallback(message => {
134
+ const onGo1MessageReceived = useCallback((message) => {
135
135
  console.log('Received postMessage from Go1');
136
136
  console.log(message);
137
137
  }, []);
@@ -145,12 +145,12 @@ const options = useMemo<ContentViewProps>(() => {
145
145
  },
146
146
  onGo1MessageReceived,
147
147
  additionalUserInfo: {
148
- jobTitle: 'Sales development representative'
148
+ jobTitle: 'Sales development representative',
149
149
  },
150
150
  themeInformation: {
151
- accent: '#0437F2'
151
+ accent: '#0437F2',
152
152
  },
153
- oneTimeToken: '907687a6e81a458190fe4c21f05ee689'
153
+ oneTimeToken: '907687a6e81a458190fe4c21f05ee689',
154
154
  };
155
155
  }, []);
156
156
 
@@ -171,7 +171,7 @@ function sendMessageToGo1(message: Go1Message): void;
171
171
 
172
172
  ```typescript
173
173
  const message = {
174
- type: "return_to_home_screen",
174
+ type: 'return_to_home_screen',
175
175
  };
176
176
  sendMessageToGo1(message);
177
177
  ```
@@ -185,12 +185,12 @@ Respond to events that have occurred in the Go1 content view. Useful to control
185
185
  ```typescript
186
186
  const onGo1MessageReceived = (message) => {
187
187
  switch (message.type) {
188
- case "enrolment_created": {
188
+ case 'enrolment_created': {
189
189
  const { userId, courseId } = message.payload;
190
190
  // perform appropriate actions for when a new enrolment is created
191
191
  break;
192
192
  }
193
- case "category_favourite_added": {
193
+ case 'category_favourite_added': {
194
194
  const { userId, category } = message.payload;
195
195
  // perform appropriate actions for when a new category is favourited
196
196
  break;
@@ -4,8 +4,7 @@ exports.isValidFeature = exports.isValidOTT = exports.addOneTimeToken = exports.
4
4
  function addPortalURL(url, portalURL, env = 'production') {
5
5
  let validPortalURL = /^(?=.{1,255}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,245}[a-zA-Z0-9])?\.mygo1\.com$/;
6
6
  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$/;
7
+ validPortalURL = /^(?=.{1,255}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,245}[a-zA-Z0-9])?\.qa\.go1\.cloud$/;
9
8
  }
10
9
  if (validPortalURL.test(portalURL)) {
11
10
  url.searchParams.append('portal_url', portalURL);
@@ -30,14 +29,6 @@ function isValidOTT(oneTimeToken) {
30
29
  }
31
30
  exports.isValidOTT = isValidOTT;
32
31
  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);
32
+ return ['ai-chat', 'content-hub', 'preview', 'library', 'search', 'wallet', 'learner-search'].includes(feature);
42
33
  }
43
34
  exports.isValidFeature = isValidFeature;
@@ -11,7 +11,7 @@ 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' | '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;
@@ -27,11 +27,16 @@ export interface FeatureAttributesAIChat {
27
27
  export interface FeatureAttributesPreview {
28
28
  id: number;
29
29
  experience?: 'manager' | 'learner';
30
+ startWith1Player?: boolean;
30
31
  }
31
32
  export interface FeatureAttributesWallet {
32
33
  walletMode: 'setup' | 'main';
33
34
  }
34
- export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet;
35
+ export interface FeatureAttributesLearnerSearch {
36
+ isGo1MobileApp?: boolean;
37
+ experience?: 'learner';
38
+ }
39
+ export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet | FeatureAttributesLearnerSearch;
35
40
  export interface AdditionalUserInfo {
36
41
  jobTitle: string;
37
42
  }
@@ -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 () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go1/go1-embedding-react-sdk",
3
- "version": "0.0.15",
3
+ "version": "0.0.18",
4
4
  "description": "A React library to embed Go1 content into your website.",
5
5
  "main": "dist/go1-embedding-react-sdk/src/index.js",
6
6
  "files": [