@omni-co/embed 0.3.11 → 0.3.12
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 +1 -1
- package/lib/cjs/embed.d.ts +3 -38
- package/lib/cjs/embed.js +17 -12
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types.d.ts +51 -0
- package/lib/cjs/types.js +8 -0
- package/lib/esm/embed.d.ts +3 -38
- package/lib/esm/embed.js +15 -11
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types.d.ts +51 -0
- package/lib/esm/types.js +5 -0
- package/package.json +1 -1
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
|
|
58
|
+
type EmbedSsoProps = {
|
|
59
59
|
// Short GUID of the dashboard. Can be obtained via the dashboard's url.
|
|
60
60
|
contentId: string;
|
|
61
61
|
|
package/lib/cjs/embed.d.ts
CHANGED
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
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 { EmbedSsoDashboardProps, EmbedSsoWorkbookProps } from "./types";
|
|
2
|
+
export declare const embedSsoDashboard: (props: EmbedSsoDashboardProps) => Promise<string>;
|
|
3
|
+
export declare const embedSsoWorkbook: (props: EmbedSsoWorkbookProps) => 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.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
|
|
8
|
-
const embedDashboardPath = "/embed/dashboards";
|
|
8
|
+
const embedLoginPath = '/embed/login';
|
|
9
9
|
const validateProps = (props) => {
|
|
10
|
-
const {
|
|
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
|
|
32
|
+
const embedSsoContent = async (props) => {
|
|
36
33
|
validateProps(props);
|
|
37
|
-
let {
|
|
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(
|
|
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,14 @@ 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;
|
package/lib/cjs/index.d.ts
CHANGED
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,51 @@
|
|
|
1
|
+
type UserAttributeValue = string | string[] | number | number[];
|
|
2
|
+
type EmbedSsoBaseProps = {
|
|
3
|
+
contentId: string;
|
|
4
|
+
externalId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
organizationName: string;
|
|
7
|
+
secret: string;
|
|
8
|
+
entity?: string;
|
|
9
|
+
userAttributes?: Record<string, UserAttributeValue>;
|
|
10
|
+
prefersDark?: string;
|
|
11
|
+
theme?: string;
|
|
12
|
+
domain?: string;
|
|
13
|
+
nonce?: string;
|
|
14
|
+
port?: number;
|
|
15
|
+
};
|
|
16
|
+
type EmbedSsoDashboardOnlyProps = {
|
|
17
|
+
filterSearchParam?: string;
|
|
18
|
+
linkAccess?: string;
|
|
19
|
+
customTheme?: CustomThemeProperties;
|
|
20
|
+
};
|
|
21
|
+
type EmbedContentIdProp = {
|
|
22
|
+
contentId: string;
|
|
23
|
+
};
|
|
24
|
+
export type CustomThemeProperties = {
|
|
25
|
+
"dashboard-background"?: string;
|
|
26
|
+
"dashboard-tile-background"?: string;
|
|
27
|
+
"dashboard-tile-text-body-color"?: string;
|
|
28
|
+
"dashboard-tile-text-secondary-color"?: string;
|
|
29
|
+
"dashboard-tile-border-color"?: string;
|
|
30
|
+
"dashboard-tile-border-radius"?: string;
|
|
31
|
+
"dashboard-tile-border-style"?: string;
|
|
32
|
+
"dashboard-tile-border-width"?: string;
|
|
33
|
+
"dashboard-tile-title-font-size"?: string;
|
|
34
|
+
"dashboard-tile-title-font-weight"?: string;
|
|
35
|
+
"dashboard-tile-title-text-color"?: string;
|
|
36
|
+
"dashboard-tile-title-font-family"?: string;
|
|
37
|
+
"dashboard-tile-text-body-font-family"?: string;
|
|
38
|
+
"dashboard-tile-text-code-font-family"?: string;
|
|
39
|
+
"dashboard-key-color"?: string;
|
|
40
|
+
"dashboard-key-text-color"?: string;
|
|
41
|
+
};
|
|
42
|
+
export declare enum EmbeddedContent {
|
|
43
|
+
Dashboard = "dashboards",
|
|
44
|
+
Workbook = "w"
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Consumers of this SDK will rely on these two types to embed workbooks and dashboards.
|
|
48
|
+
*/
|
|
49
|
+
export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
|
|
50
|
+
export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
|
|
51
|
+
export {};
|
package/lib/cjs/types.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmbeddedContent = void 0;
|
|
4
|
+
var EmbeddedContent;
|
|
5
|
+
(function (EmbeddedContent) {
|
|
6
|
+
EmbeddedContent["Dashboard"] = "dashboards";
|
|
7
|
+
EmbeddedContent["Workbook"] = "w";
|
|
8
|
+
})(EmbeddedContent || (exports.EmbeddedContent = EmbeddedContent = {}));
|
package/lib/esm/embed.d.ts
CHANGED
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
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 { EmbedSsoDashboardProps, EmbedSsoWorkbookProps } from "./types";
|
|
2
|
+
export declare const embedSsoDashboard: (props: EmbedSsoDashboardProps) => Promise<string>;
|
|
3
|
+
export declare const embedSsoWorkbook: (props: EmbedSsoWorkbookProps) => 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
|
|
5
|
-
const embedDashboardPath = "/embed/dashboards";
|
|
5
|
+
const embedLoginPath = '/embed/login';
|
|
6
6
|
const validateProps = (props) => {
|
|
7
|
-
const {
|
|
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
|
-
|
|
29
|
+
const embedSsoContent = async (props) => {
|
|
33
30
|
validateProps(props);
|
|
34
|
-
let {
|
|
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(
|
|
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,12 @@ 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
|
+
};
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
type UserAttributeValue = string | string[] | number | number[];
|
|
2
|
+
type EmbedSsoBaseProps = {
|
|
3
|
+
contentId: string;
|
|
4
|
+
externalId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
organizationName: string;
|
|
7
|
+
secret: string;
|
|
8
|
+
entity?: string;
|
|
9
|
+
userAttributes?: Record<string, UserAttributeValue>;
|
|
10
|
+
prefersDark?: string;
|
|
11
|
+
theme?: string;
|
|
12
|
+
domain?: string;
|
|
13
|
+
nonce?: string;
|
|
14
|
+
port?: number;
|
|
15
|
+
};
|
|
16
|
+
type EmbedSsoDashboardOnlyProps = {
|
|
17
|
+
filterSearchParam?: string;
|
|
18
|
+
linkAccess?: string;
|
|
19
|
+
customTheme?: CustomThemeProperties;
|
|
20
|
+
};
|
|
21
|
+
type EmbedContentIdProp = {
|
|
22
|
+
contentId: string;
|
|
23
|
+
};
|
|
24
|
+
export type CustomThemeProperties = {
|
|
25
|
+
"dashboard-background"?: string;
|
|
26
|
+
"dashboard-tile-background"?: string;
|
|
27
|
+
"dashboard-tile-text-body-color"?: string;
|
|
28
|
+
"dashboard-tile-text-secondary-color"?: string;
|
|
29
|
+
"dashboard-tile-border-color"?: string;
|
|
30
|
+
"dashboard-tile-border-radius"?: string;
|
|
31
|
+
"dashboard-tile-border-style"?: string;
|
|
32
|
+
"dashboard-tile-border-width"?: string;
|
|
33
|
+
"dashboard-tile-title-font-size"?: string;
|
|
34
|
+
"dashboard-tile-title-font-weight"?: string;
|
|
35
|
+
"dashboard-tile-title-text-color"?: string;
|
|
36
|
+
"dashboard-tile-title-font-family"?: string;
|
|
37
|
+
"dashboard-tile-text-body-font-family"?: string;
|
|
38
|
+
"dashboard-tile-text-code-font-family"?: string;
|
|
39
|
+
"dashboard-key-color"?: string;
|
|
40
|
+
"dashboard-key-text-color"?: string;
|
|
41
|
+
};
|
|
42
|
+
export declare enum EmbeddedContent {
|
|
43
|
+
Dashboard = "dashboards",
|
|
44
|
+
Workbook = "w"
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Consumers of this SDK will rely on these two types to embed workbooks and dashboards.
|
|
48
|
+
*/
|
|
49
|
+
export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
|
|
50
|
+
export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
|
|
51
|
+
export {};
|
package/lib/esm/types.js
ADDED
package/package.json
CHANGED