@omni-co/embed 0.12.2 → 0.14.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
@@ -210,6 +210,9 @@ type EmbedSsoDashboardProps = {
210
210
  */
211
211
  mode?: EmbedSessionMode;
212
212
 
213
+ // Optional object that determines the model permissions for the embed user.
214
+ modelRoles?: Record<string, EmbedConnectionRoles>;
215
+
213
216
  // Required name of the external user.
214
217
  name: string;
215
218
 
@@ -227,6 +230,13 @@ type EmbedSsoDashboardProps = {
227
230
  // Optional dark mode setting. Can be one of "true", "false", or "system".
228
231
  prefersDark?: string;
229
232
 
233
+ /**
234
+ * When true, an existing content role for the embed user on the entity folder will not be overwritten
235
+ * by the `entityFolderContentRole` value. If a content role does not exist on the entity folder for the embed user,
236
+ * the `entityFolderContentRole` value will be applied.
237
+ */
238
+ preserveEntityFolderContentRole?: boolean;
239
+
230
240
  // Signing secret available to Omni admins.
231
241
  secret: string;
232
242
 
@@ -346,6 +356,9 @@ type EmbedSsoWorkbookProps = {
346
356
  */
347
357
  mode?: EmbedSessionMode;
348
358
 
359
+ // Optional object that determines the model permissions for the embed user.
360
+ modelRoles?: Record<string, EmbedConnectionRoles>;
361
+
349
362
  // Required name of the external user.
350
363
  name: string;
351
364
 
@@ -363,6 +376,13 @@ type EmbedSsoWorkbookProps = {
363
376
  // Optional dark mode setting. Can be one of "true", "false", or "system".
364
377
  prefersDark?: string;
365
378
 
379
+ /**
380
+ * When true, an existing content role for the embed user on the entity folder will not be overwritten
381
+ * by the `entityFolderContentRole` value. If a content role does not exist on the entity folder for the embed user,
382
+ * the `entityFolderContentRole` value will be applied.
383
+ */
384
+ preserveEntityFolderContentRole?: boolean;
385
+
366
386
  // Signing secret available to Omni admins.
367
387
  secret: string;
368
388
 
@@ -474,6 +494,9 @@ type EmbedSsoContentDiscoveryProps = {
474
494
  */
475
495
  mode?: EmbedSessionMode;
476
496
 
497
+ // Optional object that determines the model permissions for the embed user.
498
+ modelRoles?: Record<string, EmbedConnectionRoles>;
499
+
477
500
  // Required name of the external user.
478
501
  name: string;
479
502
 
@@ -501,6 +524,13 @@ type EmbedSsoContentDiscoveryProps = {
501
524
  // Optional dark mode setting. Can be one of "true", "false", or "system".
502
525
  prefersDark?: string;
503
526
 
527
+ /**
528
+ * When true, an existing content role for the embed user on the entity folder will not be overwritten
529
+ * by the `entityFolderContentRole` value. If a content role does not exist on the entity folder for the embed user,
530
+ * the `entityFolderContentRole` value will be applied.
531
+ */
532
+ preserveEntityFolderContentRole?: boolean;
533
+
504
534
  // Signing secret available to Omni admins.
505
535
  secret: string;
506
536
 
@@ -634,6 +664,9 @@ type CreateSessionTokenProps = {
634
664
  */
635
665
  mode?: EmbedSessionMode;
636
666
 
667
+ // Optional object that determines the model permissions for the embed user.
668
+ modelRoles?: Record<string, EmbedConnectionRoles>;
669
+
637
670
  // Required name of the external user.
638
671
  name: string;
639
672
 
@@ -648,6 +681,13 @@ type CreateSessionTokenProps = {
648
681
  // Port of host.
649
682
  port?: number;
650
683
 
684
+ /**
685
+ * When true, an existing content role for the embed user on the entity folder will not be overwritten
686
+ * by the `entityFolderContentRole` value. If a content role does not exist on the entity folder for the embed user,
687
+ * the `entityFolderContentRole` value will be applied.
688
+ */
689
+ preserveEntityFolderContentRole?: boolean;
690
+
651
691
  // Optional UI settings object to control appearance of embed experience.
652
692
  uiSettings?: Record<EmbedUiSettings, boolean>;
653
693
 
package/lib/cjs/embed.js CHANGED
@@ -54,7 +54,7 @@ const validateProps = (props) => {
54
54
  };
55
55
  const embedSsoContent = async (props) => {
56
56
  validateProps(props);
57
- let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, externalId, filterSearchParam, groups: rawGroups, host, linkAccess, mode, name, nonce, organizationName, prefersDark, port, secret, theme, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, } = props;
57
+ let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, externalId, filterSearchParam, groups: rawGroups, host, linkAccess, mode, modelRoles: rawModelRoles, name, nonce, organizationName, preserveEntityFolderContentRole, prefersDark, port, secret, theme, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, } = props;
58
58
  // Handle defaults
59
59
  nonce = nonce !== null && nonce !== void 0 ? nonce : (await (0, random_str_1.random32ByteString)());
60
60
  const uiSettings = rawUiSettings && JSON.stringify(rawUiSettings);
@@ -62,6 +62,7 @@ const embedSsoContent = async (props) => {
62
62
  const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
63
63
  const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
64
64
  const groups = rawGroups && JSON.stringify(rawGroups);
65
+ const modelRoles = rawModelRoles && JSON.stringify(rawModelRoles);
65
66
  const url = createEmbedRequestUrl({
66
67
  domain,
67
68
  host,
@@ -93,7 +94,9 @@ const embedSsoContent = async (props) => {
93
94
  groups,
94
95
  linkAccess,
95
96
  mode,
97
+ modelRoles,
96
98
  prefersDark,
99
+ preserveEntityFolderContentRole,
97
100
  theme,
98
101
  uiSettings,
99
102
  userAttributes,
@@ -118,6 +121,7 @@ const embedSsoContent = async (props) => {
118
121
  connectionRoles &&
119
122
  url.searchParams.append("connectionRoles", connectionRoles);
120
123
  mode && url.searchParams.append("mode", mode);
124
+ modelRoles && url.searchParams.append("modelRoles", modelRoles);
121
125
  entityFolderContentRole &&
122
126
  url.searchParams.append("entityFolderContentRole", entityFolderContentRole);
123
127
  entityFolderGroupContentRole &&
@@ -129,6 +133,8 @@ const embedSsoContent = async (props) => {
129
133
  url.searchParams.append("entityGroupLabel", entityGroupLabel);
130
134
  entityFolderLabel &&
131
135
  url.searchParams.append("entityFolderLabel", entityFolderLabel);
136
+ preserveEntityFolderContentRole !== undefined &&
137
+ url.searchParams.append("preserveEntityFolderContentRole", preserveEntityFolderContentRole.toString());
132
138
  return url.toString();
133
139
  };
134
140
  const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
@@ -86,10 +86,20 @@ type SignatureProps = {
86
86
  * The mode of the embedded content.
87
87
  */
88
88
  mode?: string;
89
+ /**
90
+ * The model roles to be associated with the embed user. Expected to be a stringified JSON object.
91
+ */
92
+ modelRoles?: string;
89
93
  /**
90
94
  * Whether the user prefers light, dark, or system theme.
91
95
  */
92
96
  prefersDark?: string;
97
+ /**
98
+ * When true, the embed will not apply a custom theme to the embedded content.
99
+ * This is useful when the embed is used in a context where the custom theme
100
+ * is already applied, such as in an Omni app.
101
+ */
102
+ preserveEntityFolderContentRole?: boolean;
93
103
  /**
94
104
  * The theme of the embed.
95
105
  */
@@ -125,6 +135,6 @@ type SignSessionRedemptionProps = Pick<SignatureProps, "nonce" | "prefersDark" |
125
135
  */
126
136
  export declare const signSessionRedemption: ({ requestUrl, nonce, sessionId, secret, prefersDark, theme, }: SignSessionRedemptionProps) => string;
127
137
  export declare const TEST_ONLY: {
128
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
138
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
129
139
  };
130
140
  export {};
@@ -17,7 +17,7 @@ const generateStringForSignature = ({
17
17
  // Required parameters
18
18
  loginUrl, contentPath, externalId, name, nonce,
19
19
  // Optional parameters
20
- accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, uiSettings, userAttributes, }) => {
20
+ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }) => {
21
21
  // We create a map of optional params and convert it to an array
22
22
  // to ensure that the order of the optional params is alphabetical and consistent.
23
23
  const optionalParamsMap = {
@@ -35,7 +35,11 @@ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityF
35
35
  ...(groups && { groups }),
36
36
  ...(linkAccess && { linkAccess }),
37
37
  ...(mode && { mode }),
38
+ ...(modelRoles && { modelRoles }),
38
39
  ...(prefersDark && { prefersDark }),
40
+ ...(preserveEntityFolderContentRole !== undefined && {
41
+ preserveEntityFolderContentRole: preserveEntityFolderContentRole.toString(),
42
+ }),
39
43
  ...(theme && { theme }),
40
44
  ...(uiSettings && { uiSettings }),
41
45
  ...(userAttributes && { userAttributes }),
@@ -47,6 +47,11 @@ type EmbedSsoBaseProps = {
47
47
  * Object values should be connection roles.
48
48
  */
49
49
  connectionRoles?: Record<string, EmbedConnectionRoles>;
50
+ /**
51
+ * Optional model roles setting. Object keys should be model IDs from the embedded Omni instance.
52
+ * Object values should be connection roles.
53
+ */
54
+ modelRoles?: Record<string, EmbedConnectionRoles>;
50
55
  /**
51
56
  * Optional mode setting that determines whether the entire application should be embedded or a single piece of content.
52
57
  *
@@ -79,6 +84,12 @@ type EmbedSsoBaseProps = {
79
84
  * NO_ACCESS: all entity group embed users will not have access to the entity folder.
80
85
  */
81
86
  entityFolderGroupContentRole?: EmbedEntityFolderContentRoles;
87
+ /**
88
+ * When true, an existing content role for the embed user on the entity folder will not be overwritten
89
+ * by the `entityFolderContentRole` value. If a content role does not exist on the entity folder for the embed user,
90
+ * the `entityFolderContentRole` value will be applied.
91
+ */
92
+ preserveEntityFolderContentRole?: boolean;
82
93
  /**
83
94
  * Optional setting that customizes the generated entity folder label. This only affects the entity folder
84
95
  * corresponding to the `entity` parameter value in the relevant generated SSO embed URL.
@@ -248,16 +259,23 @@ export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProp
248
259
  export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
249
260
  export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
250
261
  export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
262
+ /**
263
+ * Path name of the content discovery page to embed.
264
+ */
265
+ path: string;
266
+ } & ({
251
267
  /**
252
268
  * Required connection roles object. Object keys should be connection IDs from the embedded Omni instance.
253
269
  * Object values should be connection roles.
254
270
  */
255
271
  connectionRoles: Record<string, EmbedConnectionRoles>;
272
+ } | {
256
273
  /**
257
- * Path name of the content discovery page to embed.
274
+ * Required model roles object. Object keys should be connection IDs from the embedded Omni instance.
275
+ * Object values should be connection roles.
258
276
  */
259
- path: string;
260
- };
277
+ modelRoles: Record<string, EmbedConnectionRoles>;
278
+ });
261
279
  export type CreateSessionTokenProps = Omit<EmbedSsoContentProps, "prefersDark" | "theme" | "secret" | "nonce"> & {
262
280
  apiKey: string;
263
281
  } & HostProps;
package/lib/esm/embed.js CHANGED
@@ -51,7 +51,7 @@ const validateProps = (props) => {
51
51
  };
52
52
  const embedSsoContent = async (props) => {
53
53
  validateProps(props);
54
- let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, externalId, filterSearchParam, groups: rawGroups, host, linkAccess, mode, name, nonce, organizationName, prefersDark, port, secret, theme, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, } = props;
54
+ let { accessBoost, connectionRoles: rawConnectionRoles, contentPath, customTheme: rawCustomTheme, customThemeId, domain, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, externalId, filterSearchParam, groups: rawGroups, host, linkAccess, mode, modelRoles: rawModelRoles, name, nonce, organizationName, preserveEntityFolderContentRole, prefersDark, port, secret, theme, uiSettings: rawUiSettings, userAttributes: rawUserAttributes, } = props;
55
55
  // Handle defaults
56
56
  nonce = nonce !== null && nonce !== void 0 ? nonce : (await random32ByteString());
57
57
  const uiSettings = rawUiSettings && JSON.stringify(rawUiSettings);
@@ -59,6 +59,7 @@ const embedSsoContent = async (props) => {
59
59
  const customTheme = rawCustomTheme && JSON.stringify(rawCustomTheme);
60
60
  const connectionRoles = rawConnectionRoles && JSON.stringify(rawConnectionRoles);
61
61
  const groups = rawGroups && JSON.stringify(rawGroups);
62
+ const modelRoles = rawModelRoles && JSON.stringify(rawModelRoles);
62
63
  const url = createEmbedRequestUrl({
63
64
  domain,
64
65
  host,
@@ -90,7 +91,9 @@ const embedSsoContent = async (props) => {
90
91
  groups,
91
92
  linkAccess,
92
93
  mode,
94
+ modelRoles,
93
95
  prefersDark,
96
+ preserveEntityFolderContentRole,
94
97
  theme,
95
98
  uiSettings,
96
99
  userAttributes,
@@ -115,6 +118,7 @@ const embedSsoContent = async (props) => {
115
118
  connectionRoles &&
116
119
  url.searchParams.append("connectionRoles", connectionRoles);
117
120
  mode && url.searchParams.append("mode", mode);
121
+ modelRoles && url.searchParams.append("modelRoles", modelRoles);
118
122
  entityFolderContentRole &&
119
123
  url.searchParams.append("entityFolderContentRole", entityFolderContentRole);
120
124
  entityFolderGroupContentRole &&
@@ -126,6 +130,8 @@ const embedSsoContent = async (props) => {
126
130
  url.searchParams.append("entityGroupLabel", entityGroupLabel);
127
131
  entityFolderLabel &&
128
132
  url.searchParams.append("entityFolderLabel", entityFolderLabel);
133
+ preserveEntityFolderContentRole !== undefined &&
134
+ url.searchParams.append("preserveEntityFolderContentRole", preserveEntityFolderContentRole.toString());
129
135
  return url.toString();
130
136
  };
131
137
  const buildContentPath = (contentType, contentId) => `/${contentType}/${contentId}`;
@@ -86,10 +86,20 @@ type SignatureProps = {
86
86
  * The mode of the embedded content.
87
87
  */
88
88
  mode?: string;
89
+ /**
90
+ * The model roles to be associated with the embed user. Expected to be a stringified JSON object.
91
+ */
92
+ modelRoles?: string;
89
93
  /**
90
94
  * Whether the user prefers light, dark, or system theme.
91
95
  */
92
96
  prefersDark?: string;
97
+ /**
98
+ * When true, the embed will not apply a custom theme to the embedded content.
99
+ * This is useful when the embed is used in a context where the custom theme
100
+ * is already applied, such as in an Omni app.
101
+ */
102
+ preserveEntityFolderContentRole?: boolean;
93
103
  /**
94
104
  * The theme of the embed.
95
105
  */
@@ -125,6 +135,6 @@ type SignSessionRedemptionProps = Pick<SignatureProps, "nonce" | "prefersDark" |
125
135
  */
126
136
  export declare const signSessionRedemption: ({ requestUrl, nonce, sessionId, secret, prefersDark, theme, }: SignSessionRedemptionProps) => string;
127
137
  export declare const TEST_ONLY: {
128
- generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
138
+ generateStringForSignature: ({ loginUrl, contentPath, externalId, name, nonce, accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }: Omit<SignatureProps, "secret">) => string;
129
139
  };
130
140
  export {};
@@ -10,7 +10,7 @@ const generateStringForSignature = ({
10
10
  // Required parameters
11
11
  loginUrl, contentPath, externalId, name, nonce,
12
12
  // Optional parameters
13
- accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, prefersDark, theme, uiSettings, userAttributes, }) => {
13
+ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityFolderContentRole, entityFolderGroupContentRole, entityFolderLabel, entityGroupLabel, filterSearchParam, groups, linkAccess, mode, modelRoles, prefersDark, preserveEntityFolderContentRole, theme, uiSettings, userAttributes, }) => {
14
14
  // We create a map of optional params and convert it to an array
15
15
  // to ensure that the order of the optional params is alphabetical and consistent.
16
16
  const optionalParamsMap = {
@@ -28,7 +28,11 @@ accessBoost, connectionRoles, customTheme, customThemeId, email, entity, entityF
28
28
  ...(groups && { groups }),
29
29
  ...(linkAccess && { linkAccess }),
30
30
  ...(mode && { mode }),
31
+ ...(modelRoles && { modelRoles }),
31
32
  ...(prefersDark && { prefersDark }),
33
+ ...(preserveEntityFolderContentRole !== undefined && {
34
+ preserveEntityFolderContentRole: preserveEntityFolderContentRole.toString(),
35
+ }),
32
36
  ...(theme && { theme }),
33
37
  ...(uiSettings && { uiSettings }),
34
38
  ...(userAttributes && { userAttributes }),
@@ -47,6 +47,11 @@ type EmbedSsoBaseProps = {
47
47
  * Object values should be connection roles.
48
48
  */
49
49
  connectionRoles?: Record<string, EmbedConnectionRoles>;
50
+ /**
51
+ * Optional model roles setting. Object keys should be model IDs from the embedded Omni instance.
52
+ * Object values should be connection roles.
53
+ */
54
+ modelRoles?: Record<string, EmbedConnectionRoles>;
50
55
  /**
51
56
  * Optional mode setting that determines whether the entire application should be embedded or a single piece of content.
52
57
  *
@@ -79,6 +84,12 @@ type EmbedSsoBaseProps = {
79
84
  * NO_ACCESS: all entity group embed users will not have access to the entity folder.
80
85
  */
81
86
  entityFolderGroupContentRole?: EmbedEntityFolderContentRoles;
87
+ /**
88
+ * When true, an existing content role for the embed user on the entity folder will not be overwritten
89
+ * by the `entityFolderContentRole` value. If a content role does not exist on the entity folder for the embed user,
90
+ * the `entityFolderContentRole` value will be applied.
91
+ */
92
+ preserveEntityFolderContentRole?: boolean;
82
93
  /**
83
94
  * Optional setting that customizes the generated entity folder label. This only affects the entity folder
84
95
  * corresponding to the `entity` parameter value in the relevant generated SSO embed URL.
@@ -248,16 +259,23 @@ export type EmbedSsoContentProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProp
248
259
  export type EmbedSsoDashboardProps = EmbedSsoBaseProps & EmbedSsoDashboardOnlyProps & EmbedContentIdProp;
249
260
  export type EmbedSsoWorkbookProps = EmbedSsoBaseProps & EmbedContentIdProp;
250
261
  export type EmbedSsoContentDiscoveryProps = EmbedSsoBaseProps & {
262
+ /**
263
+ * Path name of the content discovery page to embed.
264
+ */
265
+ path: string;
266
+ } & ({
251
267
  /**
252
268
  * Required connection roles object. Object keys should be connection IDs from the embedded Omni instance.
253
269
  * Object values should be connection roles.
254
270
  */
255
271
  connectionRoles: Record<string, EmbedConnectionRoles>;
272
+ } | {
256
273
  /**
257
- * Path name of the content discovery page to embed.
274
+ * Required model roles object. Object keys should be connection IDs from the embedded Omni instance.
275
+ * Object values should be connection roles.
258
276
  */
259
- path: string;
260
- };
277
+ modelRoles: Record<string, EmbedConnectionRoles>;
278
+ });
261
279
  export type CreateSessionTokenProps = Omit<EmbedSsoContentProps, "prefersDark" | "theme" | "secret" | "nonce"> & {
262
280
  apiKey: string;
263
281
  } & HostProps;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.12.2",
2
+ "version": "0.14.0",
3
3
  "license": "MIT",
4
4
  "name": "@omni-co/embed",
5
5
  "author": "Nate Agrin <nate@exploreomni.com>",