@capybara-hq/plugin-sdk 0.1.0-rc.32 → 0.1.0-rc.33

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.
@@ -12,4 +12,6 @@ Contract: FilePreviewProvider (`file-preview.ts`)
12
12
 
13
13
  Declare which file types you can preview and render them through schema views or an approved embed. Enabled per org.
14
14
 
15
+ `render` args are a union on `source`: `"conversation"` (org, account, conversation) or `"share"` (org and share id; `file.id` is the share id; no account or conversation). A previewer that needs the conversation declines `source: "share"` by throwing; the kernel reports the failure and the share page falls to the next previewer. A share token is valid only for the `file.preview` slot, never for `/api`.
16
+
15
17
  See `extensions` for the rules every extension follows.
@@ -34,14 +34,12 @@ export interface FilePreviewer {
34
34
  export interface FilePreviewProvider {
35
35
  previewers: FilePreviewer[];
36
36
  }
37
- /** Arguments of {@link FilePreviewer.render}; identities come from the kernel after authentication. */
38
- export interface FilePreviewArgs {
39
- orgId: string;
40
- accountId: string;
41
- conversationId: string;
37
+ /** What every {@link FilePreviewArgs} variant carries. */
38
+ export interface FilePreviewArgsBase {
42
39
  locale: Locale;
43
40
  /** Aborted at the kernel's time limit: stop reading and rendering. */
44
41
  signal: AbortSignal;
42
+ /** In the share variant `file.id` is the share id. */
45
43
  file: {
46
44
  id: string;
47
45
  name: string;
@@ -62,6 +60,25 @@ export interface FilePreviewArgs {
62
60
  */
63
61
  config?: unknown;
64
62
  }
63
+ /** A preview inside a conversation; identities come from the kernel after authentication. */
64
+ export interface FilePreviewConversationArgs extends FilePreviewArgsBase {
65
+ source: "conversation";
66
+ orgId: string;
67
+ accountId: string;
68
+ conversationId: string;
69
+ }
70
+ /**
71
+ * A preview on a share page: there is no account and no conversation. A previewer that needs the
72
+ * conversation declines this variant by throwing; the kernel reports the failure and the page falls
73
+ * to the next previewer.
74
+ */
75
+ export interface FilePreviewShareArgs extends FilePreviewArgsBase {
76
+ source: "share";
77
+ orgId: string;
78
+ shareId: string;
79
+ }
80
+ /** Arguments of {@link FilePreviewer.render}: narrow on `source`. */
81
+ export type FilePreviewArgs = FilePreviewConversationArgs | FilePreviewShareArgs;
65
82
  /** Checks a `file-preview@1` provider; returns the problems (empty = valid). */
66
83
  export declare function validateFilePreviewProvider(p: unknown): string[];
67
84
  /** Whether a previewer takes this file: its type or extension is accepted and it is within `maxBytes`. */
@@ -43,6 +43,16 @@ export type RouteCaller = {
43
43
  contribution: string;
44
44
  /** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
45
45
  exp: number;
46
+ } | {
47
+ /** A share page's `file.preview` embed: no account, no role. */
48
+ access: "embed";
49
+ scope: "share";
50
+ orgId: string;
51
+ shareId: string;
52
+ contribution: string;
53
+ /** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
54
+ exp: number;
55
+ config: unknown;
46
56
  } | {
47
57
  access: "member" | "admin";
48
58
  orgId: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.32";
1
+ export declare const SDK_VERSION = "0.1.0-rc.33";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./bootstrap.js";
4
4
  export * from "./cards.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = "0.1.0-rc.32";
1
+ export const SDK_VERSION = "0.1.0-rc.33";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./bootstrap.js";
4
4
  export * from "./cards.js";
package/dist/ui.d.ts CHANGED
@@ -270,10 +270,9 @@ export type UiActionResult = {
270
270
  } | {
271
271
  view: UiView;
272
272
  };
273
- /** The embed claims both scopes share. `exp` is Unix seconds. */
273
+ /** The embed claims every scope shares. `exp` is Unix seconds. */
274
274
  export interface EmbedClaimsBase {
275
275
  plugin: string;
276
- accountId: string;
277
276
  contribution: string;
278
277
  exp: number;
279
278
  }
@@ -281,6 +280,7 @@ export interface EmbedClaimsBase {
281
280
  export interface OrgEmbedClaims extends EmbedClaimsBase {
282
281
  scope: "org";
283
282
  orgId: string;
283
+ accountId: string;
284
284
  /**
285
285
  * The caller's role: written at issuance; `ctx.ui.verifyEmbedToken` returns the current role at
286
286
  * validation time.
@@ -295,18 +295,33 @@ export interface OrgEmbedClaims extends EmbedClaimsBase {
295
295
  /** A `platform.page` embed token's claims: a super admin's, with no org, conversation, agent or file. */
296
296
  export interface PlatformEmbedClaims extends EmbedClaimsBase {
297
297
  scope: "platform";
298
+ accountId: string;
298
299
  orgId?: undefined;
299
300
  role: "superAdmin";
300
301
  conversationId?: undefined;
301
302
  agentId?: undefined;
302
303
  fileId?: undefined;
303
304
  }
305
+ /**
306
+ * A share page's `file.preview` embed token's claims: no account and no role, only the org, the
307
+ * share and the share's generation. Valid only for the `file.preview` slot, never for `/api`.
308
+ */
309
+ export interface ShareEmbedClaims extends EmbedClaimsBase {
310
+ scope: "share";
311
+ orgId: string;
312
+ shareId: string;
313
+ generation: number;
314
+ accountId?: undefined;
315
+ role?: undefined;
316
+ conversationId?: undefined;
317
+ agentId?: undefined;
318
+ fileId?: undefined;
319
+ }
304
320
  /**
305
321
  * Claims in an embed token (trustworthy after validation by `ctx.ui.verifyEmbedToken`): narrow on
306
- * `scope` (`"platform"` has no
307
- * `orgId` and `role` `"superAdmin"`).
322
+ * `scope` (`"platform"` has no `orgId` and `role` `"superAdmin"`; `"share"` has no account or role).
308
323
  */
309
- export type EmbedClaims = OrgEmbedClaims | PlatformEmbedClaims;
324
+ export type EmbedClaims = OrgEmbedClaims | PlatformEmbedClaims | ShareEmbedClaims;
310
325
  /**
311
326
  * The version marker of the `postMessage` protocol between the outer page and the embedded iframe.
312
327
  */
@@ -314,7 +329,7 @@ export declare const EMBED_PROTOCOL = "capybara-embed/1";
314
329
  /**
315
330
  * What an embed's `init` says about where it is shown, narrowed on `scope` like {@link EmbedClaims}:
316
331
  * an org's page, panel, section or previewer (`orgId`, and the conversation when there is one), or
317
- * a platform page of the admin console (no org).
332
+ * a platform page of the admin console (no org), or a share page (no org or conversation).
318
333
  */
319
334
  export type EmbedInitContext = {
320
335
  scope: "org";
@@ -324,6 +339,10 @@ export type EmbedInitContext = {
324
339
  scope: "platform";
325
340
  orgId?: undefined;
326
341
  conversationId?: undefined;
342
+ } | {
343
+ scope: "share";
344
+ orgId?: undefined;
345
+ conversationId?: undefined;
327
346
  };
328
347
  /** Messages the outer page sends to the iframe. */
329
348
  export type EmbedParentMessage = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-sdk",
3
- "version": "0.1.0-rc.32",
3
+ "version": "0.1.0-rc.33",
4
4
  "description": "Capybara plugin SDK: the types and pure functions plugins are written against",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {