@go1/go1-embedding-react-sdk 0.0.8 → 0.0.10

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
@@ -73,7 +73,14 @@ export interface FeatureAttributesAIChat {
73
73
  desiredRole?: string; // e.g. "Senior Account Manager"
74
74
  }
75
75
 
76
- export type FeatureAttributes = FeatureAttributesAIChat
76
+ /**
77
+ * Used to configure the `preview` feature
78
+ */
79
+ export interface FeatureAttributesPreview {
80
+ id: number
81
+ }
82
+
83
+ export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
77
84
 
78
85
  export interface AdditionalUserInfo {
79
86
  jobTitle: string;
@@ -81,7 +88,7 @@ export interface AdditionalUserInfo {
81
88
 
82
89
  interface InitOptions {
83
90
  /** Mandatory identifier for the embedded feature */
84
- feature: 'ai-chat' | 'content-hub' | 'preview';
91
+ feature: 'ai-chat' | 'content-hub' | 'preview' | 'library' | 'search';
85
92
  /** Optional parameters to configure the feature. See associated types for examples */
86
93
  featureAttributes?: FeatureAttributes;
87
94
  /** Optional Go1 portal URL, used for login purposes if no `oneTimeToken` is provided */
package/dist/README.md CHANGED
@@ -73,7 +73,14 @@ export interface FeatureAttributesAIChat {
73
73
  desiredRole?: string; // e.g. "Senior Account Manager"
74
74
  }
75
75
 
76
- export type FeatureAttributes = FeatureAttributesAIChat
76
+ /**
77
+ * Used to configure the `preview` feature
78
+ */
79
+ export interface FeatureAttributesPreview {
80
+ id: number
81
+ }
82
+
83
+ export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
77
84
 
78
85
  export interface AdditionalUserInfo {
79
86
  jobTitle: string;
@@ -81,7 +88,7 @@ export interface AdditionalUserInfo {
81
88
 
82
89
  interface InitOptions {
83
90
  /** Mandatory identifier for the embedded feature */
84
- feature: 'ai-chat' | 'content-hub' | 'preview';
91
+ feature: 'ai-chat' | 'content-hub' | 'preview' | 'library' | 'search';
85
92
  /** Optional parameters to configure the feature. See associated types for examples */
86
93
  featureAttributes?: FeatureAttributes;
87
94
  /** Optional Go1 portal URL, used for login purposes if no `oneTimeToken` is provided */
@@ -1,2 +1,3 @@
1
- export declare function addPortalURL(url: URL, portalURL: string): void;
1
+ export declare function addPortalURL(url: URL, portalURL: string, env?: 'qa' | 'prod'): void;
2
2
  export declare function addOneTimeToken(url: URL, oneTimeToken: string): void;
3
+ export declare function isValidFeature(feature: string): boolean;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addOneTimeToken = exports.addPortalURL = void 0;
4
- function addPortalURL(url, portalURL) {
5
- const validPortalURL = /^(?=.{1,255}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,245}[a-zA-Z0-9])?\.mygo1\.com$/;
3
+ exports.isValidFeature = exports.addOneTimeToken = exports.addPortalURL = void 0;
4
+ function addPortalURL(url, portalURL, env = 'prod') {
5
+ let validPortalURL = /^(?=.{1,255}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,245}[a-zA-Z0-9])?\.mygo1\.com$/;
6
+ if (env === 'qa') {
7
+ validPortalURL = /^(?=.{1,255}$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,245}[a-zA-Z0-9])?\.qa\.go1\.cloud$/;
8
+ }
6
9
  if (validPortalURL.test(portalURL)) {
7
10
  url.searchParams.append('portal_url', portalURL);
8
11
  }
@@ -21,3 +24,7 @@ function addOneTimeToken(url, oneTimeToken) {
21
24
  }
22
25
  }
23
26
  exports.addOneTimeToken = addOneTimeToken;
27
+ function isValidFeature(feature) {
28
+ return ['ai-chat', 'content-hub', 'preview', 'library', 'search'].includes(feature);
29
+ }
30
+ exports.isValidFeature = isValidFeature;
@@ -24,12 +24,15 @@ export interface FeatureAttributesAIChat {
24
24
  desiredSkills?: string[];
25
25
  desiredRole?: string;
26
26
  }
27
- export type FeatureAttributes = FeatureAttributesAIChat;
27
+ export interface FeatureAttributesPreview {
28
+ id: number;
29
+ }
30
+ export type FeatureAttributes = FeatureAttributesAIChat | FeatureAttributesPreview;
28
31
  export interface AdditionalUserInfo {
29
32
  jobTitle: string;
30
33
  }
31
34
  export interface InitOptions {
32
- feature: 'ai-chat' | 'content-hub' | 'preview';
35
+ feature: 'ai-chat' | 'content-hub' | 'preview' | 'library' | 'search';
33
36
  iframeParentId?: string;
34
37
  iframeParentElement?: HTMLElement;
35
38
  featureAttributes?: FeatureAttributes;
@@ -1,7 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { InitOptions, SendMessageToGo1 } from '../../common/types';
3
3
  export type ContentViewProps = Omit<InitOptions, 'iframeParentId' | 'iframeParentElement'>;
4
- export declare function useGo1ContentView(props: ContentViewProps): {
4
+ type EnvProps = {
5
+ env?: 'qa' | 'prod';
6
+ };
7
+ export declare function useGo1ContentView(props: ContentViewProps & EnvProps): {
5
8
  sendMessageToGo1: SendMessageToGo1;
6
9
  ContentView: (userProps?: React.IframeHTMLAttributes<HTMLIFrameElement>) => React.JSX.Element;
7
10
  };
11
+ export {};
@@ -6,20 +6,26 @@ 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, } = props;
9
+ const { feature, featureAttributes, portalURL, oneTimeToken, onGo1MessageReceived, additionalUserInfo, themeInformation, env = 'prod', } = props;
10
10
  const iframeRef = (0, react_1.useRef)(null);
11
- const url = 'https://embedding.go1.com';
11
+ let url = 'https://embedding.go1.com';
12
+ if (env === 'qa') {
13
+ url = 'https://embedding.qa.go1.cloud';
14
+ }
15
+ if (!(0, params_1.isValidFeature)(feature)) {
16
+ throw new Error('Unsupported feature');
17
+ }
12
18
  let { iframeURL, iframeID } = (0, react_1.useMemo)(() => {
13
19
  let iframeURL = new URL(`${url}/${feature}`);
14
20
  if (portalURL) {
15
- (0, params_1.addPortalURL)(iframeURL, portalURL);
21
+ (0, params_1.addPortalURL)(iframeURL, portalURL, env);
16
22
  }
17
23
  if (oneTimeToken) {
18
24
  (0, params_1.addOneTimeToken)(iframeURL, oneTimeToken);
19
25
  }
20
26
  const iframeID = `go1-iframe-${feature}`;
21
27
  return { iframeURL, iframeID };
22
- }, [url, feature, oneTimeToken, portalURL]);
28
+ }, [url, feature, portalURL, oneTimeToken, env]);
23
29
  const sendMessageToGo1 = (0, react_1.useCallback)((message) => {
24
30
  iframeRef.current?.contentWindow?.postMessage(message, url);
25
31
  }, [url]);
@@ -30,11 +36,11 @@ function useGo1ContentView(props) {
30
36
  let payload = {
31
37
  additionalUserInfo,
32
38
  themeInformation,
33
- featureAttributes
39
+ featureAttributes,
34
40
  };
35
41
  sendMessageToGo1({
36
42
  type: 'set_additional_embedding_data',
37
- payload
43
+ payload,
38
44
  });
39
45
  }
40
46
  else {
@@ -48,7 +54,7 @@ function useGo1ContentView(props) {
48
54
  sendMessageToGo1,
49
55
  onGo1MessageReceived,
50
56
  themeInformation,
51
- featureAttributes
57
+ featureAttributes,
52
58
  ]);
53
59
  (0, react_1.useEffect)(() => {
54
60
  window.addEventListener('message', eventListenerInstance);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go1/go1-embedding-react-sdk",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
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": [