@omni-co/embed 0.9.0 → 0.10.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
@@ -62,6 +62,38 @@ const iframeUrl = await embedSsoContentDiscovery({
62
62
  });
63
63
  ```
64
64
 
65
+ ## 2-step Example
66
+
67
+ ```ts
68
+ // Step 1
69
+ const { success, sessionToken } = await createSessionToken({
70
+ apiKey: "<YOUR API KEY>",
71
+ connectionRoles: {
72
+ "abcd1234-abcd-efgh-ijkl-abcdef123456":
73
+ EmbedConnectionRoles.RESTRICTED_QUERIER,
74
+ },
75
+ contentPath: "/dashboards/abcd1234",
76
+ externalId: "dodgers-17",
77
+ host: "myorg.embed-omniapp.co",
78
+ mode: EmbedSessionMode.Application,
79
+ name: "Shohei Ohtani",
80
+ });
81
+ if (!success) throw new Error("Failed to generate session");
82
+
83
+ // Step 2
84
+ const redeemSessionUrl = await redeemSessionToken({
85
+ host: "myorg.embed-omniapp.co",
86
+ prefersDark: "false",
87
+ theme: "vibes",
88
+ secret: "<YOUR EMBED SECRET>",
89
+ sessionToken,
90
+ });
91
+
92
+ ...
93
+
94
+ <iframe src={redeemSessionUrl} />
95
+ ```
96
+
65
97
  ## Using Vanity Domains
66
98
 
67
99
  ```ts
@@ -186,6 +218,9 @@ type EmbedSsoDashboardProps = {
186
218
  // Optional theme setting. Can be one of "dawn", "vibes", "breeze" or "blank".
187
219
  theme?: string;
188
220
 
221
+ // Optional UI settings object to control appearance of embed experience.
222
+ uiSettings?: Record<EmbedUiSettings, boolean>;
223
+
189
224
  /**
190
225
  * Optional user attributes to be passed to user associated with the
191
226
  * externalId. User attributes must be created in Omni before being
@@ -304,6 +339,9 @@ type EmbedSsoWorkbookProps = {
304
339
  // Optional theme setting. Can be one of "dawn", "vibes", "breeze" or "blank".
305
340
  theme?: string;
306
341
 
342
+ // Optional UI settings object to control appearance of embed experience.
343
+ uiSettings?: Record<EmbedUiSettings, boolean>;
344
+
307
345
  /**
308
346
  * Optional user attributes to be passed to user associated with the
309
347
  * externalId. User attributes must be created in Omni before being
@@ -424,6 +462,9 @@ type EmbedSsoContentDiscoveryProps = {
424
462
  // Optional theme setting. Can be one of "dawn", "vibes", "breeze" or "blank".
425
463
  theme?: string;
426
464
 
465
+ // Optional UI settings object to control appearance of embed experience.
466
+ uiSettings?: Record<EmbedUiSettings, boolean>;
467
+
427
468
  /**
428
469
  * Optional user attributes to be passed to user associated with the
429
470
  * externalId. User attributes must be created in Omni before being
@@ -442,3 +483,182 @@ type EmbedSsoContentDiscoveryProps = {
442
483
  domain?: string;
443
484
  };
444
485
  ```
486
+
487
+ ## createSessionToken
488
+
489
+ This is the type signature for the `createSessionToken` function:
490
+
491
+ ```ts
492
+ type CreateSessionTokenProps = {
493
+ // Optional boolean property that toggles the dashboard's Access Boost setting.
494
+ accessBoost?: boolean;
495
+
496
+ // An Omni API key used for authentication purposes. Can be generated in your Omni application in the Admin > API Keys section.
497
+ apiKey: string;
498
+
499
+ // Optional object that determines the connection permissions for the embed user.
500
+ connectionRoles?: Record<string, EmbedConnectionRoles>;
501
+
502
+ // Short GUID of the dashboard. Can be obtained via the dashboard's url.
503
+ contentId: string;
504
+
505
+ // Optional custom theme object that styles the embedded dashboard.
506
+ customTheme?: CustomThemeProperties;
507
+
508
+ /**
509
+ * Optional custom theme ID setting that styles the embedded dashboard.
510
+ * This ID should be from a theme created within the Omni application.
511
+ */
512
+ customThemeId?: string;
513
+
514
+ // Optional email parameter that sets the default scheduling email for the embed user.
515
+ email?: string;
516
+
517
+ /**
518
+ * Optional identifier to associate the user with an external organization or system.
519
+ * Note that each distinct entity will generate its own folder and group. These can be used by
520
+ * an embed user to share content with other members in the same entity.
521
+ */
522
+ entity?: string;
523
+
524
+ /**
525
+ * Optional content role setting for the entity folder. Can be one of "MANAGER", "EDITOR", or "VIEWER".
526
+ *
527
+ * MANAGER: the user will have the ability to manage content and content permissions of the entity folder.
528
+ * EDITOR: the user will have the ability to manage content in the entity folder.
529
+ * VIEWER: the user will only be able to view content in the entity folder.
530
+ */
531
+ entityFolderContentRole?: EmbedEntityFolderContentRoles;
532
+
533
+ // Required identifier to associate the external user with an automatically generated internal Omni user.
534
+ externalId: string;
535
+
536
+ /**
537
+ * Optional url filter search parameter. Should be the same as the filter search parameters on a dashboard url.
538
+ * Example: f--inventory_items.cost=%7B"kind"%3A"EQUALS"%2C"type"%3A"number"%2C"values"%3A%5B%5D%2C"is_negative"%3Afalse%2C"is_inclusive"%3Afalse%7D&f--users.state=%7B"kind"%3A"EQUALS"%2C"type"%3A"string"%2C"values"%3A%5B"Aberdeen"%2C"Alabama"%5D%2C"is_negative"%3Afalse%7D&f--users.country=%7B"kind"%3A"EQUALS"%2C"type"%3A"string"%2C"values"%3A%5B"UK"%5D%2C"is_negative"%3Afalse%7D
539
+ *
540
+ */
541
+ filterSearchParam?: string;
542
+
543
+ /*
544
+ * Optional groups array property. The array should be a list of group names from the Omni application, which the embed user will be added to.
545
+ */
546
+ groups?: string[];
547
+
548
+ /**
549
+ * Used to set the host of signed embed URL, required when using vanity domains.
550
+ * Protocol is not required, as https is assumed.
551
+ * Port is not accepted. If required, use the `port` prop.
552
+ *
553
+ * @throws Error if `domain` or `organizationName` are provided.
554
+ * @example "omni.example.com"
555
+ * @example "omni.another-example.app"
556
+ */
557
+ host?: string;
558
+
559
+ /**
560
+ * Optional link access setting to control which Omni dashboard links are shown. Note that regardless of the linkAccess value,
561
+ * all non-Omni dashboard links will be shown and allowed in drill menus. Acceptable values include:
562
+ *
563
+ * "__omni_link_access_open": Special string keyword that permisses and shows all Omni dashboard links on the embedded dashboard.
564
+ * "abcd1234,efgh5678,ijkl9999": An allowlist of dashboard IDs that permisses and shows links to the specified dashboards.
565
+ * undefined: If left undefined, the default behavior is to hide and disallow all links to other Omni dashboards on the embedded dashboard.
566
+ */
567
+ linkAccess?: string;
568
+
569
+ /**
570
+ * Optional mode setting that determines whether the entire application should be embedded or a single piece of content.
571
+ *
572
+ * APPLICATION: the entire application will be embedded, meaning in-app navigation and document header options will be available.
573
+ * SINGLE_CONTENT: only the content specified in the contentId will be embedded and application mode features will be hidden.
574
+ */
575
+ mode?: EmbedSessionMode;
576
+
577
+ // Required name of the external user.
578
+ name: string;
579
+
580
+ /**
581
+ * Name of the organization the content belongs to. If provided, generates a default embed host
582
+ * URL in the form of `https://<organizationName>.embed-omniapp.co`.
583
+ *
584
+ * @throws Error if `host` is provided.
585
+ */
586
+ organizationName?: string;
587
+
588
+ // Port of host.
589
+ port?: number;
590
+
591
+ // Optional UI settings object to control appearance of embed experience.
592
+ uiSettings?: Record<EmbedUiSettings, boolean>;
593
+
594
+ /**
595
+ * Optional user attributes to be passed to user associated with the
596
+ * externalId. User attributes must be created in Omni before being
597
+ * defined and given a value here.
598
+ */
599
+ userAttributes?: Record<string, string | string[] | number | number[]>;
600
+
601
+ // DEPRECATED
602
+
603
+ /**
604
+ * @deprecated Introduced for internal testing only. For vanity domains, use the `host`
605
+ * prop instead. Will be dropped in a v1.0.0 release.
606
+ *
607
+ * @throws Error if `host` is provided.
608
+ */
609
+ domain?: string;
610
+ };
611
+ ```
612
+
613
+ ## redeemSessionToken
614
+
615
+ This is the type signature for the `redeemSessionToken` function:
616
+
617
+ ```ts
618
+ type RedeemSessionTokenProps = {
619
+ /**
620
+ * Used to set the host of signed embed URL, required when using vanity domains.
621
+ * Protocol is not required, as https is assumed.
622
+ * Port is not accepted. If required, use the `port` prop.
623
+ *
624
+ * @throws Error if `domain` or `organizationName` are provided.
625
+ * @example "omni.example.com"
626
+ * @example "omni.another-example.app"
627
+ */
628
+ host?: string;
629
+
630
+ /**
631
+ * Name of the organization the content belongs to. If provided, generates a default embed host
632
+ * URL in the form of `https://<organizationName>.embed-omniapp.co`.
633
+ *
634
+ * @throws Error if `host` is provided.
635
+ */
636
+ organizationName?: string;
637
+
638
+ // Port of host.
639
+ port?: number;
640
+
641
+ // Optional dark mode setting. Can be one of "true", "false", or "system".
642
+ prefersDark?: string;
643
+
644
+ // Signing secret available to Omni admins.
645
+ secret: string;
646
+
647
+ // Session token string. The `createSessionToken` sdk function returns a session token that
648
+ // can be used as the `sessionToken` parameter here in `redeemSessionToken`.
649
+ sessionToken: string;
650
+
651
+ // Optional theme setting. Can be one of "dawn", "vibes", "breeze" or "blank".
652
+ theme?: string;
653
+
654
+ // DEPRECATED
655
+
656
+ /**
657
+ * @deprecated Introduced for internal testing only. For vanity domains, use the `host`
658
+ * prop instead. Will be dropped in a v1.0.0 release.
659
+ *
660
+ * @throws Error if `host` is provided.
661
+ */
662
+ domain?: string;
663
+ };
664
+ ```
@@ -1,4 +1,4 @@
1
- import { EmbedSsoContentDiscoveryProps, EmbedSsoDashboardProps, EmbedSsoWorkbookProps, GenerateEmbedSsoSessionProps, RedeemEmbedSsoSessionProps } from "./types";
1
+ import { EmbedSsoContentDiscoveryProps, EmbedSsoDashboardProps, EmbedSsoWorkbookProps, CreateSessionTokenProps, RedeemSessionTokenProps } from "./types";
2
2
  export declare const embedSsoDashboard: (props: EmbedSsoDashboardProps) => Promise<string>;
3
3
  export declare const embedSsoWorkbook: (props: EmbedSsoWorkbookProps) => Promise<string>;
4
4
  /**
@@ -15,7 +15,7 @@ export declare const embedSsoContentDiscovery: (props: EmbedSsoContentDiscoveryP
15
15
  * To elaborate, this function upserts an SSO embed user and session to the specified Omni
16
16
  * organization / host. The returned session token corresponds to the generated session.
17
17
  */
18
- export declare const createSessionToken: ({ apiKey, domain, host, organizationName, port, ...restProps }: GenerateEmbedSsoSessionProps) => Promise<{
18
+ export declare const createSessionToken: ({ apiKey, domain, host, organizationName, port, ...restProps }: CreateSessionTokenProps) => Promise<{
19
19
  success: true;
20
20
  sessionToken: string;
21
21
  error?: never;
@@ -29,4 +29,4 @@ export declare const createSessionToken: ({ apiKey, domain, host, organizationNa
29
29
  * to output an session redemption URL that can be used to display embedded content.
30
30
  * The returned URL should be passed into an `iframe`'s src attribute.
31
31
  */
32
- export declare const redeemSessionToken: ({ domain, host, organizationName, port, nonce: propsNonce, secret, prefersDark, sessionToken: sessionId, theme, }: RedeemEmbedSsoSessionProps) => Promise<string>;
32
+ export declare const redeemSessionToken: ({ domain, host, organizationName, port, nonce: propsNonce, secret, prefersDark, sessionToken: sessionId, theme, }: RedeemSessionTokenProps) => Promise<string>;
@@ -58,7 +58,9 @@ type EmbedSsoBaseProps = {
58
58
  * Optional content role setting. Can be one of "MANAGER", "EDITOR", or "VIEWER".
59
59
  *
60
60
  * MANAGER: the user will have the ability to manage content and content permissions of the entity folder.
61
+ *
61
62
  * EDITOR: the user will have the ability to manage content in the entity folder.
63
+ *
62
64
  * VIEWER: the user will only be able to view content in the entity folder.
63
65
  */
64
66
  entityFolderContentRole?: EmbedEntityFolderContentRoles;
@@ -230,10 +232,10 @@ export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
230
232
  */
231
233
  path: string;
232
234
  };
233
- export type GenerateEmbedSsoSessionProps = Omit<EmbedSsoContentProps, "prefersDark" | "theme" | "secret" | "nonce"> & {
235
+ export type CreateSessionTokenProps = Omit<EmbedSsoContentProps, "prefersDark" | "theme" | "secret" | "nonce"> & {
234
236
  apiKey: string;
235
237
  } & HostProps;
236
- export type RedeemEmbedSsoSessionProps = Pick<EmbedSsoContentProps, "nonce" | "prefersDark" | "secret" | "theme" | "port"> & {
238
+ export type RedeemSessionTokenProps = Pick<EmbedSsoContentProps, "nonce" | "prefersDark" | "secret" | "theme" | "port"> & {
237
239
  sessionToken: string;
238
240
  } & HostProps;
239
241
  export {};
@@ -1,4 +1,4 @@
1
- import { EmbedSsoContentDiscoveryProps, EmbedSsoDashboardProps, EmbedSsoWorkbookProps, GenerateEmbedSsoSessionProps, RedeemEmbedSsoSessionProps } from "./types";
1
+ import { EmbedSsoContentDiscoveryProps, EmbedSsoDashboardProps, EmbedSsoWorkbookProps, CreateSessionTokenProps, RedeemSessionTokenProps } from "./types";
2
2
  export declare const embedSsoDashboard: (props: EmbedSsoDashboardProps) => Promise<string>;
3
3
  export declare const embedSsoWorkbook: (props: EmbedSsoWorkbookProps) => Promise<string>;
4
4
  /**
@@ -15,7 +15,7 @@ export declare const embedSsoContentDiscovery: (props: EmbedSsoContentDiscoveryP
15
15
  * To elaborate, this function upserts an SSO embed user and session to the specified Omni
16
16
  * organization / host. The returned session token corresponds to the generated session.
17
17
  */
18
- export declare const createSessionToken: ({ apiKey, domain, host, organizationName, port, ...restProps }: GenerateEmbedSsoSessionProps) => Promise<{
18
+ export declare const createSessionToken: ({ apiKey, domain, host, organizationName, port, ...restProps }: CreateSessionTokenProps) => Promise<{
19
19
  success: true;
20
20
  sessionToken: string;
21
21
  error?: never;
@@ -29,4 +29,4 @@ export declare const createSessionToken: ({ apiKey, domain, host, organizationNa
29
29
  * to output an session redemption URL that can be used to display embedded content.
30
30
  * The returned URL should be passed into an `iframe`'s src attribute.
31
31
  */
32
- export declare const redeemSessionToken: ({ domain, host, organizationName, port, nonce: propsNonce, secret, prefersDark, sessionToken: sessionId, theme, }: RedeemEmbedSsoSessionProps) => Promise<string>;
32
+ export declare const redeemSessionToken: ({ domain, host, organizationName, port, nonce: propsNonce, secret, prefersDark, sessionToken: sessionId, theme, }: RedeemSessionTokenProps) => Promise<string>;
@@ -58,7 +58,9 @@ type EmbedSsoBaseProps = {
58
58
  * Optional content role setting. Can be one of "MANAGER", "EDITOR", or "VIEWER".
59
59
  *
60
60
  * MANAGER: the user will have the ability to manage content and content permissions of the entity folder.
61
+ *
61
62
  * EDITOR: the user will have the ability to manage content in the entity folder.
63
+ *
62
64
  * VIEWER: the user will only be able to view content in the entity folder.
63
65
  */
64
66
  entityFolderContentRole?: EmbedEntityFolderContentRoles;
@@ -230,10 +232,10 @@ export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
230
232
  */
231
233
  path: string;
232
234
  };
233
- export type GenerateEmbedSsoSessionProps = Omit<EmbedSsoContentProps, "prefersDark" | "theme" | "secret" | "nonce"> & {
235
+ export type CreateSessionTokenProps = Omit<EmbedSsoContentProps, "prefersDark" | "theme" | "secret" | "nonce"> & {
234
236
  apiKey: string;
235
237
  } & HostProps;
236
- export type RedeemEmbedSsoSessionProps = Pick<EmbedSsoContentProps, "nonce" | "prefersDark" | "secret" | "theme" | "port"> & {
238
+ export type RedeemSessionTokenProps = Pick<EmbedSsoContentProps, "nonce" | "prefersDark" | "secret" | "theme" | "port"> & {
237
239
  sessionToken: string;
238
240
  } & HostProps;
239
241
  export {};
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.0",
2
+ "version": "0.10.0",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",