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

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
@@ -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 Go1MessageType =
52
+ export type IframesMap = { [key: string]: HTMLIFrameElement };
53
+
54
+ export interface AdditionalInfoMessage {
55
+ additionalUserInfo?: AdditionalUserInfo;
56
+ featureAttributes?: FeatureAttributes;
57
+ themeInformation?: ThemeInformation;
58
+ }
59
+
60
+ export interface ThemeInformation {
61
+ /** Hex string, starting with a #. Example #0437F2 */
62
+ accent: string;
63
+ }
64
+
65
+ export type Go1MessageType =
53
66
  | 'preview_start_content'
54
67
  | 'preview_close'
55
68
  | 'preview_add_content_success'
56
69
  | 'preview_add_content_failure'
57
70
  | 'preview_remove_content_success'
58
71
  | 'preview_remove_content_failure'
72
+ | 'parent_show_preview'
59
73
  | 'set_additional_embedding_data'
60
- | 'go1_app_initialised';
74
+ | 'go1_app_initialised'
75
+ | 'ott_required'
76
+ | 'search_result_selected'
77
+ | 'search_filter_toggle'
78
+ | 'pass_ott';
61
79
 
62
- interface Go1Message {
80
+ export interface Go1Message {
63
81
  type: Go1MessageType;
64
82
  payload?: any;
65
83
  }
66
84
 
67
- interface ThemeInformation {
68
- /** Hex string, starting with a #. Example #0437F2 */
69
- accent: string;
85
+ interface FeatureAttributeCommon {
86
+ shouldSuppressPreview?: boolean;
70
87
  }
71
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,27 +101,56 @@ 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
- export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
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
- interface InitOptions {
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: 'ai-chat' | 'content-hub' | 'preview' | 'library' | 'search';
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 */
package/dist/README.md CHANGED
@@ -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 Go1MessageType =
52
+ export type IframesMap = { [key: string]: HTMLIFrameElement };
53
+
54
+ export interface AdditionalInfoMessage {
55
+ additionalUserInfo?: AdditionalUserInfo;
56
+ featureAttributes?: FeatureAttributes;
57
+ themeInformation?: ThemeInformation;
58
+ }
59
+
60
+ export interface ThemeInformation {
61
+ /** Hex string, starting with a #. Example #0437F2 */
62
+ accent: string;
63
+ }
64
+
65
+ export type Go1MessageType =
53
66
  | 'preview_start_content'
54
67
  | 'preview_close'
55
68
  | 'preview_add_content_success'
56
69
  | 'preview_add_content_failure'
57
70
  | 'preview_remove_content_success'
58
71
  | 'preview_remove_content_failure'
72
+ | 'parent_show_preview'
59
73
  | 'set_additional_embedding_data'
60
- | 'go1_app_initialised';
74
+ | 'go1_app_initialised'
75
+ | 'ott_required'
76
+ | 'search_result_selected'
77
+ | 'search_filter_toggle'
78
+ | 'pass_ott';
61
79
 
62
- interface Go1Message {
80
+ export interface Go1Message {
63
81
  type: Go1MessageType;
64
82
  payload?: any;
65
83
  }
66
84
 
67
- interface ThemeInformation {
68
- /** Hex string, starting with a #. Example #0437F2 */
69
- accent: string;
85
+ interface FeatureAttributeCommon {
86
+ shouldSuppressPreview?: boolean;
70
87
  }
71
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,27 +101,56 @@ 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
- export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
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
- interface InitOptions {
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: 'ai-chat' | 'content-hub' | 'preview' | 'library' | 'search';
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 */
@@ -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: string): boolean;
5
+ export declare function isValidFeature(feature: FeatureType): boolean;
@@ -1,6 +1,7 @@
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') {
@@ -29,6 +30,6 @@ function isValidOTT(oneTimeToken) {
29
30
  }
30
31
  exports.isValidOTT = isValidOTT;
31
32
  function isValidFeature(feature) {
32
- return ['ai-chat', 'content-hub', 'preview', 'library', 'search', 'wallet', 'learner-search'].includes(feature);
33
+ return types_1.features.includes(feature);
33
34
  }
34
35
  exports.isValidFeature = isValidFeature;
@@ -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' | 'search_result_selected' | 'search_filter_toggle' | '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
- export interface FeatureAttributesAIChat {
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,24 +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 interface FeatureAttributesLearnerSearch {
38
+ export interface FeatureAttributesLearnerSearch extends FeatureAttributeCommon {
36
39
  isGo1MobileApp?: boolean;
37
40
  experience?: 'learner';
38
41
  }
39
- export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet | FeatureAttributesLearnerSearch;
42
+ export interface FeatureAttributesLibrary extends FeatureAttributeCommon {
43
+ }
44
+ export interface FeatureAttributesSearch extends FeatureAttributeCommon {
45
+ }
46
+ export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview | FeatureAttributesWallet | FeatureAttributesLibrary | FeatureAttributesSearch | FeatureAttributesLearnerSearch;
40
47
  export interface AdditionalUserInfo {
41
48
  jobTitle: string;
42
49
  }
50
+ export declare const features: readonly ["ai-chat", "content-hub", "preview", "library", "search", "wallet", "learner-search"];
51
+ export type FeatureType = (typeof features)[number];
43
52
  export interface InitOptions {
44
- feature: 'ai-chat' | 'content-hub' | 'preview' | 'library' | 'search' | 'wallet' | 'learner-search';
53
+ feature: FeatureType;
45
54
  iframeParentId?: string;
46
55
  iframeParentElement?: HTMLElement;
47
56
  featureAttributes?: FeatureAttributes;
@@ -51,3 +60,4 @@ export interface InitOptions {
51
60
  themeInformation?: ThemeInformation;
52
61
  oneTimeToken?: string;
53
62
  }
63
+ export {};
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.features = void 0;
4
+ exports.features = ['ai-chat', 'content-hub', 'preview', 'library', 'search', 'wallet', 'learner-search'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go1/go1-embedding-react-sdk",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
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": [