@omni-co/embed 0.3.11 → 0.3.13

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
@@ -55,7 +55,7 @@ const iframeUrl = await embedSsoDashboard({
55
55
  This is the type signature for the embedSsoDashboard function:
56
56
 
57
57
  ```ts
58
- type EmbedSsoDashboardProps = {
58
+ type EmbedSsoProps = {
59
59
  // Short GUID of the dashboard. Can be obtained via the dashboard's url.
60
60
  contentId: string;
61
61
 
@@ -1,38 +1,9 @@
1
- type UserAttributeValue = string | string[] | number | number[];
2
- export type CustomThemeProperties = {
3
- "dashboard-background"?: string;
4
- "dashboard-tile-background"?: string;
5
- "dashboard-tile-text-body-color"?: string;
6
- "dashboard-tile-text-secondary-color"?: string;
7
- "dashboard-tile-border-color"?: string;
8
- "dashboard-tile-border-radius"?: string;
9
- "dashboard-tile-border-style"?: string;
10
- "dashboard-tile-border-width"?: string;
11
- "dashboard-tile-title-font-size"?: string;
12
- "dashboard-tile-title-font-weight"?: string;
13
- "dashboard-tile-title-text-color"?: string;
14
- "dashboard-tile-title-font-family"?: string;
15
- "dashboard-tile-text-body-font-family"?: string;
16
- "dashboard-tile-text-code-font-family"?: string;
17
- "dashboard-key-color"?: string;
18
- "dashboard-key-text-color"?: string;
19
- };
20
- type EmbedSsoProps = {
21
- contentId: string;
22
- externalId: string;
23
- name: string;
24
- organizationName: string;
25
- secret: string;
26
- entity?: string;
27
- userAttributes?: Record<string, UserAttributeValue>;
28
- prefersDark?: string;
29
- theme?: string;
30
- filterSearchParam?: string;
31
- linkAccess?: string;
32
- customTheme?: CustomThemeProperties;
33
- domain?: string;
34
- nonce?: string;
35
- port?: number;
36
- };
37
- export declare const embedSsoDashboard: (props: EmbedSsoProps) => Promise<string>;
38
- export {};
1
+ import { EmbedSsoContentDiscoveryProps, EmbedSsoDashboardProps, EmbedSsoWorkbookProps } from "./types";
2
+ export declare const embedSsoDashboard: (props: EmbedSsoDashboardProps) => Promise<string>;
3
+ export declare const embedSsoWorkbook: (props: EmbedSsoWorkbookProps) => Promise<string>;
4
+ /**
5
+ * *IN BETA* Generates an embed login URL using the passed-in content discovery page id.
6
+ * @param EmbedSsoContentDiscoveryProps
7
+ * @returns Promise wrapped around a generated embed login url.
8
+ */
9
+ export declare const embedSsoContentDiscovery: (props: EmbedSsoContentDiscoveryProps) => Promise<string>;
package/lib/cjs/embed.js CHANGED
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.embedSsoDashboard = void 0;
3
+ exports.embedSsoContentDiscovery = exports.embedSsoWorkbook = exports.embedSsoDashboard = void 0;
4
4
  const random_str_1 = require("./random-str");
5
5
  const signature_1 = require("./signature");
6
+ const types_1 = require("./types");
6
7
  const defaultEmbedDomain = "embed-omniapp.co";
7
- const embedLoginRoute = "/embed/login";
8
- const embedDashboardPath = "/embed/dashboards";
8
+ const embedLoginPath = "/embed/login";
9
9
  const validateProps = (props) => {
10
- const { contentId, externalId, name, nonce, organizationName, secret, userAttributes, } = props;
11
- if (!contentId) {
12
- throw new Error("contentId is required");
13
- }
10
+ const { externalId, name, nonce, organizationName, secret, userAttributes } = props;
14
11
  if (!externalId) {
15
12
  throw new Error("externalId is required");
16
13
  }
@@ -32,18 +29,16 @@ const validateProps = (props) => {
32
29
  }
33
30
  }
34
31
  };
35
- const embedSsoDashboard = async (props) => {
32
+ const embedSsoContent = async (props) => {
36
33
  validateProps(props);
37
- let { contentId, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
34
+ let { contentPath, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
38
35
  // Handle defaults
39
36
  nonce = nonce !== null && nonce !== void 0 ? nonce : (await (0, random_str_1.random32ByteString)());
40
37
  domain = domain !== null && domain !== void 0 ? domain : defaultEmbedDomain;
41
38
  const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
42
39
  const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
43
40
  // Generate the url for the embed login route
44
- const url = new URL(embedLoginRoute, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
45
- // Generate the content path
46
- const contentPath = `${embedDashboardPath}/${contentId}`;
41
+ const url = new URL(embedLoginPath, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
47
42
  // Get a signature for the request
48
43
  const signature = (0, signature_1.getSignature)({
49
44
  loginUrl: url.toString(),
@@ -76,4 +71,27 @@ const embedSsoDashboard = async (props) => {
76
71
  customTheme && url.searchParams.append("customTheme", customTheme);
77
72
  return url.toString();
78
73
  };
74
+ const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
75
+ const embedSsoDashboard = async (props) => {
76
+ const contentPath = buildContentPath(types_1.EmbeddedContent.Dashboard, props.contentId);
77
+ return embedSsoContent({ ...props, contentPath });
78
+ };
79
79
  exports.embedSsoDashboard = embedSsoDashboard;
80
+ const embedSsoWorkbook = async (props) => {
81
+ const contentPath = `${buildContentPath(types_1.EmbeddedContent.Workbook, props.contentId)}/duplicate`;
82
+ return embedSsoContent({ ...props, contentPath });
83
+ };
84
+ exports.embedSsoWorkbook = embedSsoWorkbook;
85
+ /**
86
+ * *IN BETA* Generates an embed login URL using the passed-in content discovery page id.
87
+ * @param EmbedSsoContentDiscoveryProps
88
+ * @returns Promise wrapped around a generated embed login url.
89
+ */
90
+ const embedSsoContentDiscovery = async (props) => {
91
+ const contentPath = `/${props.path}`;
92
+ return embedSsoContent({
93
+ ...props,
94
+ contentPath,
95
+ });
96
+ };
97
+ exports.embedSsoContentDiscovery = embedSsoContentDiscovery;
@@ -1,2 +1,3 @@
1
1
  export * from "./embed";
2
+ export * from "./types";
2
3
  export * from "./signature";
package/lib/cjs/index.js CHANGED
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./embed"), exports);
18
+ __exportStar(require("./types"), exports);
18
19
  __exportStar(require("./signature"), exports);
@@ -0,0 +1,62 @@
1
+ type UserAttributeValue = string | string[] | number | number[];
2
+ type EmbedSsoBaseProps = {
3
+ externalId: string;
4
+ name: string;
5
+ organizationName: string;
6
+ secret: string;
7
+ entity?: string;
8
+ userAttributes?: Record<string, UserAttributeValue>;
9
+ prefersDark?: string;
10
+ theme?: string;
11
+ domain?: string;
12
+ nonce?: string;
13
+ port?: number;
14
+ };
15
+ type EmbedSsoDashboardOnlyProps = {
16
+ filterSearchParam?: string;
17
+ linkAccess?: string;
18
+ customTheme?: CustomThemeProperties;
19
+ };
20
+ type EmbedContentIdProp = {
21
+ contentId: string;
22
+ };
23
+ type EmbedContentPathProp = {
24
+ contentPath: string;
25
+ };
26
+ export type CustomThemeProperties = {
27
+ "dashboard-background"?: string;
28
+ "dashboard-tile-background"?: string;
29
+ "dashboard-tile-text-body-color"?: string;
30
+ "dashboard-tile-text-secondary-color"?: string;
31
+ "dashboard-tile-border-color"?: string;
32
+ "dashboard-tile-border-radius"?: string;
33
+ "dashboard-tile-border-style"?: string;
34
+ "dashboard-tile-border-width"?: string;
35
+ "dashboard-tile-title-font-size"?: string;
36
+ "dashboard-tile-title-font-weight"?: string;
37
+ "dashboard-tile-title-text-color"?: string;
38
+ "dashboard-tile-title-font-family"?: string;
39
+ "dashboard-tile-text-body-font-family"?: string;
40
+ "dashboard-tile-text-code-font-family"?: string;
41
+ "dashboard-key-color"?: string;
42
+ "dashboard-key-text-color"?: string;
43
+ };
44
+ export declare enum EmbeddedContent {
45
+ Dashboard = "dashboards",
46
+ Workbook = "w"
47
+ }
48
+ export declare const EmbedSsoContentDiscoveryPaths: readonly ["my"];
49
+ export type EmbedSsoContentDiscoveryPath = (typeof EmbedSsoContentDiscoveryPaths)[number];
50
+ export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp;
51
+ /**
52
+ * Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
53
+ */
54
+ export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
55
+ export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
56
+ export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
57
+ /**
58
+ * Path name of the content discovery page to embed.
59
+ */
60
+ path: EmbedSsoContentDiscoveryPath;
61
+ };
62
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmbedSsoContentDiscoveryPaths = exports.EmbeddedContent = void 0;
4
+ var EmbeddedContent;
5
+ (function (EmbeddedContent) {
6
+ EmbeddedContent["Dashboard"] = "dashboards";
7
+ EmbeddedContent["Workbook"] = "w";
8
+ })(EmbeddedContent || (exports.EmbeddedContent = EmbeddedContent = {}));
9
+ exports.EmbedSsoContentDiscoveryPaths = ["my"];
@@ -1,38 +1,9 @@
1
- type UserAttributeValue = string | string[] | number | number[];
2
- export type CustomThemeProperties = {
3
- "dashboard-background"?: string;
4
- "dashboard-tile-background"?: string;
5
- "dashboard-tile-text-body-color"?: string;
6
- "dashboard-tile-text-secondary-color"?: string;
7
- "dashboard-tile-border-color"?: string;
8
- "dashboard-tile-border-radius"?: string;
9
- "dashboard-tile-border-style"?: string;
10
- "dashboard-tile-border-width"?: string;
11
- "dashboard-tile-title-font-size"?: string;
12
- "dashboard-tile-title-font-weight"?: string;
13
- "dashboard-tile-title-text-color"?: string;
14
- "dashboard-tile-title-font-family"?: string;
15
- "dashboard-tile-text-body-font-family"?: string;
16
- "dashboard-tile-text-code-font-family"?: string;
17
- "dashboard-key-color"?: string;
18
- "dashboard-key-text-color"?: string;
19
- };
20
- type EmbedSsoProps = {
21
- contentId: string;
22
- externalId: string;
23
- name: string;
24
- organizationName: string;
25
- secret: string;
26
- entity?: string;
27
- userAttributes?: Record<string, UserAttributeValue>;
28
- prefersDark?: string;
29
- theme?: string;
30
- filterSearchParam?: string;
31
- linkAccess?: string;
32
- customTheme?: CustomThemeProperties;
33
- domain?: string;
34
- nonce?: string;
35
- port?: number;
36
- };
37
- export declare const embedSsoDashboard: (props: EmbedSsoProps) => Promise<string>;
38
- export {};
1
+ import { EmbedSsoContentDiscoveryProps, EmbedSsoDashboardProps, EmbedSsoWorkbookProps } from "./types";
2
+ export declare const embedSsoDashboard: (props: EmbedSsoDashboardProps) => Promise<string>;
3
+ export declare const embedSsoWorkbook: (props: EmbedSsoWorkbookProps) => Promise<string>;
4
+ /**
5
+ * *IN BETA* Generates an embed login URL using the passed-in content discovery page id.
6
+ * @param EmbedSsoContentDiscoveryProps
7
+ * @returns Promise wrapped around a generated embed login url.
8
+ */
9
+ export declare const embedSsoContentDiscovery: (props: EmbedSsoContentDiscoveryProps) => Promise<string>;
package/lib/esm/embed.js CHANGED
@@ -1,13 +1,10 @@
1
1
  import { random32ByteString } from "./random-str";
2
2
  import { getSignature } from "./signature";
3
+ import { EmbeddedContent, } from "./types";
3
4
  const defaultEmbedDomain = "embed-omniapp.co";
4
- const embedLoginRoute = "/embed/login";
5
- const embedDashboardPath = "/embed/dashboards";
5
+ const embedLoginPath = "/embed/login";
6
6
  const validateProps = (props) => {
7
- const { contentId, externalId, name, nonce, organizationName, secret, userAttributes, } = props;
8
- if (!contentId) {
9
- throw new Error("contentId is required");
10
- }
7
+ const { externalId, name, nonce, organizationName, secret, userAttributes } = props;
11
8
  if (!externalId) {
12
9
  throw new Error("externalId is required");
13
10
  }
@@ -29,18 +26,16 @@ const validateProps = (props) => {
29
26
  }
30
27
  }
31
28
  };
32
- export const embedSsoDashboard = async (props) => {
29
+ const embedSsoContent = async (props) => {
33
30
  validateProps(props);
34
- let { contentId, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
31
+ let { contentPath, customTheme: rawCustomTheme, domain, externalId, filterSearchParam, linkAccess, name, nonce, organizationName, port, secret, userAttributes: rawUserAttributes, entity, prefersDark, theme, } = props;
35
32
  // Handle defaults
36
33
  nonce = nonce !== null && nonce !== void 0 ? nonce : (await random32ByteString());
37
34
  domain = domain !== null && domain !== void 0 ? domain : defaultEmbedDomain;
38
35
  const userAttributes = rawUserAttributes && JSON.stringify(rawUserAttributes);
39
36
  const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
40
37
  // Generate the url for the embed login route
41
- const url = new URL(embedLoginRoute, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
42
- // Generate the content path
43
- const contentPath = `${embedDashboardPath}/${contentId}`;
38
+ const url = new URL(embedLoginPath, `https://${organizationName.toLocaleLowerCase()}.${domain}${port ? `:${port}` : ""}`);
44
39
  // Get a signature for the request
45
40
  const signature = getSignature({
46
41
  loginUrl: url.toString(),
@@ -73,3 +68,24 @@ export const embedSsoDashboard = async (props) => {
73
68
  customTheme && url.searchParams.append("customTheme", customTheme);
74
69
  return url.toString();
75
70
  };
71
+ const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
72
+ export const embedSsoDashboard = async (props) => {
73
+ const contentPath = buildContentPath(EmbeddedContent.Dashboard, props.contentId);
74
+ return embedSsoContent({ ...props, contentPath });
75
+ };
76
+ export const embedSsoWorkbook = async (props) => {
77
+ const contentPath = `${buildContentPath(EmbeddedContent.Workbook, props.contentId)}/duplicate`;
78
+ return embedSsoContent({ ...props, contentPath });
79
+ };
80
+ /**
81
+ * *IN BETA* Generates an embed login URL using the passed-in content discovery page id.
82
+ * @param EmbedSsoContentDiscoveryProps
83
+ * @returns Promise wrapped around a generated embed login url.
84
+ */
85
+ export const embedSsoContentDiscovery = async (props) => {
86
+ const contentPath = `/${props.path}`;
87
+ return embedSsoContent({
88
+ ...props,
89
+ contentPath,
90
+ });
91
+ };
@@ -1,2 +1,3 @@
1
1
  export * from "./embed";
2
+ export * from "./types";
2
3
  export * from "./signature";
package/lib/esm/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./embed";
2
+ export * from "./types";
2
3
  export * from "./signature";
@@ -0,0 +1,62 @@
1
+ type UserAttributeValue = string | string[] | number | number[];
2
+ type EmbedSsoBaseProps = {
3
+ externalId: string;
4
+ name: string;
5
+ organizationName: string;
6
+ secret: string;
7
+ entity?: string;
8
+ userAttributes?: Record<string, UserAttributeValue>;
9
+ prefersDark?: string;
10
+ theme?: string;
11
+ domain?: string;
12
+ nonce?: string;
13
+ port?: number;
14
+ };
15
+ type EmbedSsoDashboardOnlyProps = {
16
+ filterSearchParam?: string;
17
+ linkAccess?: string;
18
+ customTheme?: CustomThemeProperties;
19
+ };
20
+ type EmbedContentIdProp = {
21
+ contentId: string;
22
+ };
23
+ type EmbedContentPathProp = {
24
+ contentPath: string;
25
+ };
26
+ export type CustomThemeProperties = {
27
+ "dashboard-background"?: string;
28
+ "dashboard-tile-background"?: string;
29
+ "dashboard-tile-text-body-color"?: string;
30
+ "dashboard-tile-text-secondary-color"?: string;
31
+ "dashboard-tile-border-color"?: string;
32
+ "dashboard-tile-border-radius"?: string;
33
+ "dashboard-tile-border-style"?: string;
34
+ "dashboard-tile-border-width"?: string;
35
+ "dashboard-tile-title-font-size"?: string;
36
+ "dashboard-tile-title-font-weight"?: string;
37
+ "dashboard-tile-title-text-color"?: string;
38
+ "dashboard-tile-title-font-family"?: string;
39
+ "dashboard-tile-text-body-font-family"?: string;
40
+ "dashboard-tile-text-code-font-family"?: string;
41
+ "dashboard-key-color"?: string;
42
+ "dashboard-key-text-color"?: string;
43
+ };
44
+ export declare enum EmbeddedContent {
45
+ Dashboard = "dashboards",
46
+ Workbook = "w"
47
+ }
48
+ export declare const EmbedSsoContentDiscoveryPaths: readonly ["my"];
49
+ export type EmbedSsoContentDiscoveryPath = (typeof EmbedSsoContentDiscoveryPaths)[number];
50
+ export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentPathProp;
51
+ /**
52
+ * Consumers of this SDK will rely on these three types to embed workbooks and dashboards.
53
+ */
54
+ export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
55
+ export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
56
+ export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
57
+ /**
58
+ * Path name of the content discovery page to embed.
59
+ */
60
+ path: EmbedSsoContentDiscoveryPath;
61
+ };
62
+ export {};
@@ -0,0 +1,6 @@
1
+ export var EmbeddedContent;
2
+ (function (EmbeddedContent) {
3
+ EmbeddedContent["Dashboard"] = "dashboards";
4
+ EmbeddedContent["Workbook"] = "w";
5
+ })(EmbeddedContent || (EmbeddedContent = {}));
6
+ export const EmbedSsoContentDiscoveryPaths = ["my"];
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.11",
2
+ "version": "0.3.13",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",