@go1/go1-embedding-react-sdk 0.0.78 → 0.2.0

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
@@ -159,6 +159,13 @@ export interface FeatureAttributesGo1LearnSearch extends FeatureAttributeCommon
159
159
  searchProvider?: string; // If the embedding search feature includes a search provider, the app will initialize with the pre-filled search provider.
160
160
  }
161
161
 
162
+ export type FeatureAttributesRecommendations = Omit<FeatureAttributesGo1LearnSearch, 'searchProvider'> & {
163
+ providers?: string[]; // If the embedding recommendations feature includes a search providers, the app will initialize with the pre-filled search provider
164
+ skills?: string[]; // If the embedding recommendations feature includes a search skills, the app will initialize with the pre-filled search skills
165
+ topics?: string[]; // If the embedding recommendations feature includes a search topics, the app will initialize with the pre-filled search topics
166
+ sort?: string; // If the embedding recommendations feature includes a search sort, the app will initialize with the pre-filled search sort
167
+ }
168
+
162
169
  export type FeatureAttributes =
163
170
  | FeatureAttributesAIChat
164
171
  | FeatureAttributesPreview
@@ -166,7 +173,8 @@ export type FeatureAttributes =
166
173
  | FeatureAttributesLibrary
167
174
  | FeatureAttributesSearch
168
175
  | FeatureAttributesMyPlaylists
169
- | FeatureAttributesMyLearning;;
176
+ | FeatureAttributesMyLearning
177
+ | FeatureAttributesRecommendations;
170
178
 
171
179
  export interface AdditionalUserInfo {
172
180
  jobTitle: string;
@@ -0,0 +1,13 @@
1
+ # @go1/go1-embedding-react-sdk
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - new Go1MessageType 'contact_go1_navigation'
8
+
9
+ ## 0.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - New featureAttributes for Select Welcome Modal and Recommendation
package/dist/README.md CHANGED
@@ -159,6 +159,13 @@ export interface FeatureAttributesGo1LearnSearch extends FeatureAttributeCommon
159
159
  searchProvider?: string; // If the embedding search feature includes a search provider, the app will initialize with the pre-filled search provider.
160
160
  }
161
161
 
162
+ export type FeatureAttributesRecommendations = Omit<FeatureAttributesGo1LearnSearch, 'searchProvider'> & {
163
+ providers?: string[]; // If the embedding recommendations feature includes a search providers, the app will initialize with the pre-filled search provider
164
+ skills?: string[]; // If the embedding recommendations feature includes a search skills, the app will initialize with the pre-filled search skills
165
+ topics?: string[]; // If the embedding recommendations feature includes a search topics, the app will initialize with the pre-filled search topics
166
+ sort?: string; // If the embedding recommendations feature includes a search sort, the app will initialize with the pre-filled search sort
167
+ }
168
+
162
169
  export type FeatureAttributes =
163
170
  | FeatureAttributesAIChat
164
171
  | FeatureAttributesPreview
@@ -166,7 +173,8 @@ export type FeatureAttributes =
166
173
  | FeatureAttributesLibrary
167
174
  | FeatureAttributesSearch
168
175
  | FeatureAttributesMyPlaylists
169
- | FeatureAttributesMyLearning;;
176
+ | FeatureAttributesMyLearning
177
+ | FeatureAttributesRecommendations;
170
178
 
171
179
  export interface AdditionalUserInfo {
172
180
  jobTitle: string;
@@ -1,5 +1,6 @@
1
1
  import { FeatureType } from './types';
2
2
  export declare function addPortalURL(url: URL, portalURL: string, env?: 'staging' | 'production'): void;
3
3
  export declare function addOneTimeToken(url: URL, oneTimeToken: string): void;
4
+ export declare function addForceReauth(url: URL): void;
4
5
  export declare function isValidOTT(oneTimeToken: string): boolean;
5
6
  export declare function isValidFeature(feature: FeatureType): boolean;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidFeature = exports.isValidOTT = exports.addOneTimeToken = exports.addPortalURL = void 0;
3
+ exports.addPortalURL = addPortalURL;
4
+ exports.addOneTimeToken = addOneTimeToken;
5
+ exports.addForceReauth = addForceReauth;
6
+ exports.isValidOTT = isValidOTT;
7
+ exports.isValidFeature = isValidFeature;
4
8
  const types_1 = require("./types");
5
9
  function addPortalURL(url, portalURL, env = 'production') {
6
10
  let validPortalURL = /^(?=.{1,255}$)([a-zA-Z0-9-]+\.)+mygo1\.com$/;
@@ -14,7 +18,6 @@ function addPortalURL(url, portalURL, env = 'production') {
14
18
  throw new Error(`Invalid formatting for portalURL ${portalURL}, env ${env}`);
15
19
  }
16
20
  }
17
- exports.addPortalURL = addPortalURL;
18
21
  function addOneTimeToken(url, oneTimeToken) {
19
22
  if (isValidOTT(oneTimeToken)) {
20
23
  url.searchParams.append('one_time_token', oneTimeToken);
@@ -23,13 +26,13 @@ function addOneTimeToken(url, oneTimeToken) {
23
26
  throw new Error('Invalid formatting for oneTimeToken');
24
27
  }
25
28
  }
26
- exports.addOneTimeToken = addOneTimeToken;
29
+ function addForceReauth(url) {
30
+ url.searchParams.append('force_reauth', 'true');
31
+ }
27
32
  function isValidOTT(oneTimeToken) {
28
33
  const validOTT = /^[A-Za-z0-9]+$/;
29
34
  return validOTT.test(oneTimeToken);
30
35
  }
31
- exports.isValidOTT = isValidOTT;
32
36
  function isValidFeature(feature) {
33
37
  return types_1.features.includes(feature);
34
38
  }
35
- exports.isValidFeature = isValidFeature;
@@ -16,7 +16,7 @@ export interface AdditionalInfoMessage {
16
16
  export interface ThemeInformation {
17
17
  accent: string;
18
18
  }
19
- 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' | 'search_redirected' | 'pass_ott' | 'logout' | 'sync_content' | 'open_save_to_playlist_modal' | 'update_experience' | 'inter_feature_navigation' | 'side_drawer_open' | 'side_drawer_close' | 'elysium_modal_open' | 'elysium_modal_close' | 'play_content' | 'go1pay_custom_data' | 'bulk_upload_content' | 'bulk_upload_metadata' | 'bulk_upload_close';
19
+ 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' | 'search_redirected' | 'pass_ott' | 'set_access_token' | 'logout' | 'sync_content' | 'open_save_to_playlist_modal' | 'update_experience' | 'inter_feature_navigation' | 'side_drawer_open' | 'side_drawer_close' | 'elysium_modal_open' | 'elysium_modal_close' | 'play_content' | 'go1pay_custom_data' | 'bulk_upload_content' | 'bulk_upload_metadata' | 'bulk_upload_close' | 'contact_go1_navigation';
20
20
  export type Go1Message = {
21
21
  type: Go1MessageType;
22
22
  payload?: any;
@@ -25,6 +25,7 @@ export type ExternalExperience = 'manager' | 'learner' | 'role-aware';
25
25
  export interface FeatureAttributeCommon {
26
26
  shouldSuppressPreview?: boolean;
27
27
  shouldSuppressOpeningPlayer?: boolean;
28
+ shouldShowSelectWelcomeModal?: boolean;
28
29
  experience?: ExternalExperience;
29
30
  contentScope?: 'subscription' | 'library';
30
31
  }
@@ -82,7 +83,14 @@ export interface FeatureAttributesGo1LearnSearch extends FeatureAttributeCommon
82
83
  searchTerm?: string;
83
84
  searchProvider?: string;
84
85
  }
85
- export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet | FeatureAttributesLibrary | FeatureAttributesSearch | FeatureAttributesMyPlaylists | FeatureAttributesMyLearning | FeatureAttributesBulkUpload | FeatureAttributesContentStatus | FeatureAttributesGo1LearnSearch;
86
+ export type SearchLearningObjectsOptions = {
87
+ providers?: string[];
88
+ skills?: string[];
89
+ topics?: string[];
90
+ sort?: string;
91
+ };
92
+ export type FeatureAttributesRecommendations = Omit<FeatureAttributesGo1LearnSearch, 'searchProvider'> & SearchLearningObjectsOptions;
93
+ export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet | FeatureAttributesLibrary | FeatureAttributesSearch | FeatureAttributesMyPlaylists | FeatureAttributesMyLearning | FeatureAttributesBulkUpload | FeatureAttributesContentStatus | FeatureAttributesGo1LearnSearch | FeatureAttributesRecommendations;
86
94
  export interface AdditionalUserInfo {
87
95
  jobTitle: string;
88
96
  }
@@ -98,6 +106,7 @@ export interface InitOptions {
98
106
  additionalUserInfo?: AdditionalUserInfo;
99
107
  themeInformation?: ThemeInformation;
100
108
  oneTimeToken?: string;
109
+ accessToken?: string;
101
110
  integrationSystemId?: string;
102
111
  presentingIntegrationSystemId?: string;
103
112
  previewHost?: string;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useGo1ContentView = void 0;
3
+ exports.useGo1ContentView = useGo1ContentView;
4
4
  const React = require("react");
5
5
  const react_1 = require("react");
6
6
  const constants_1 = require("../../common/constants");
7
7
  const params_1 = require("../../common/params");
8
8
  function useGo1ContentView(props) {
9
- const { feature, featureAttributes, portalURL, oneTimeToken, onGo1MessageReceived, additionalUserInfo, themeInformation, integrationSystemId, presentingIntegrationSystemId, env = 'production', previewHost, disableFSOuterScript, } = props;
9
+ const { feature, featureAttributes, portalURL, oneTimeToken, onGo1MessageReceived, additionalUserInfo, themeInformation, integrationSystemId, presentingIntegrationSystemId, env = 'production', previewHost, disableFSOuterScript, accessToken, } = props;
10
10
  const iframeRef = (0, react_1.useRef)(null);
11
11
  let url = 'https://embedding.go1.com';
12
12
  if (previewHost) {
@@ -29,9 +29,12 @@ function useGo1ContentView(props) {
29
29
  if (oneTimeToken || oneTimeToken === '') {
30
30
  (0, params_1.addOneTimeToken)(iframeURL, oneTimeToken);
31
31
  }
32
+ if (accessToken) {
33
+ (0, params_1.addForceReauth)(iframeURL);
34
+ }
32
35
  const iframeID = `go1-iframe-${feature}`;
33
36
  return { iframeURL, iframeID };
34
- }, [url, feature, portalURL, oneTimeToken, env]);
37
+ }, [url, feature, portalURL, oneTimeToken, env, accessToken]);
35
38
  const eventListenerInstance = (0, react_1.useCallback)((event) => {
36
39
  const { _type, ...rest } = event.data;
37
40
  if (_type === constants_1.GO1_MESSAGE) {
@@ -50,6 +53,14 @@ function useGo1ContentView(props) {
50
53
  payload,
51
54
  });
52
55
  }
56
+ else if (rest.type === 'ott_required' && rest.payload?.init === true && accessToken) {
57
+ sendMessageToGo1({
58
+ type: 'set_access_token',
59
+ payload: {
60
+ accessToken,
61
+ },
62
+ });
63
+ }
53
64
  else {
54
65
  if (onGo1MessageReceived) {
55
66
  onGo1MessageReceived(rest);
@@ -66,6 +77,7 @@ function useGo1ContentView(props) {
66
77
  onGo1MessageReceived,
67
78
  feature,
68
79
  disableFSOuterScript,
80
+ accessToken,
69
81
  ]);
70
82
  (0, react_1.useEffect)(() => {
71
83
  window.addEventListener('message', eventListenerInstance);
@@ -78,7 +90,6 @@ function useGo1ContentView(props) {
78
90
  }, [iframeRef, iframeURL, iframeID]);
79
91
  return { sendMessageToGo1, ContentView };
80
92
  }
81
- exports.useGo1ContentView = useGo1ContentView;
82
93
  function Go1ContentView(iframeRef, iframeURL, iframeID, userProps) {
83
94
  return (React.createElement("iframe", { id: iframeID, ref: iframeRef, src: iframeURL.toString(), style: { border: 0, width: '100%', height: '100%' }, ...userProps }));
84
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go1/go1-embedding-react-sdk",
3
- "version": "0.0.78",
3
+ "version": "0.2.0",
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": [
@@ -22,12 +22,12 @@
22
22
  "devDependencies": {
23
23
  "@testing-library/jest-dom": "5.17.0",
24
24
  "@testing-library/react": "14.0.0",
25
- "@testing-library/user-event": "14.4.3",
25
+ "@testing-library/user-event": "14.5.2",
26
26
  "jest": "^29.6.2",
27
27
  "react": "18.2.0",
28
28
  "react-dom": "^18.2.0",
29
29
  "ts-jest": "^29.1.1",
30
- "typescript": "^5.1.6"
30
+ "typescript": "^5.8.3"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=16.8"