@palettelab/sdk 0.1.20 → 0.1.22

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
@@ -122,8 +122,20 @@ import {
122
122
  PluginProvider,
123
123
  usePlatform,
124
124
  createPaletteClient,
125
+ palette,
125
126
  DataRoomClient,
127
+ dataRooms,
126
128
  StorageClient,
129
+ UserClient,
130
+ OrganizationClient,
131
+ getConnections,
132
+ startConnection,
133
+ disconnectConnection,
134
+ requireConnection,
135
+ broker,
136
+ servicesProxy,
137
+ BrokerCallError,
138
+ events,
127
139
  usePluginTranslations,
128
140
  translate,
129
141
  normalizePaletteLanguage,
@@ -162,12 +174,14 @@ import { PluginProvider } from "@palettelab/sdk/components"
162
174
  Public frontend helpers exported by `@palettelab/sdk`:
163
175
 
164
176
  - Provider/context: `PluginProvider`, `usePlatform`, `PlatformCtx`.
165
- - Client facade: `createPaletteClient(platform?)`.
177
+ - Client facade: `createPaletteClient(platform?)`; `palette` is the default no-argument client used by generated broker clients.
166
178
  - API: `apiFetch(path, init?)`, `apiUpload(path, file, fieldName?, extraFields?)`, `setBaseUrl(url)`, `getBaseUrl()`.
167
179
  - Errors: `PaletteApiError`, `errorFromResponse(response)`, `isPaletteApiError(error)`.
168
180
  - Data Rooms: `DataRoomClient`, `dataRooms`, plus `list`, `create`, `get`, `folder`, `ensureRoom`, `requireRoomByName`, `findRoomByName`, `createFolder`, `ensureFolder`, `findFolderByName`, `resolveFolderPath`, `findFileByName`, `requestUpload`, `confirmUpload`, and `uploadFile`.
169
181
  - Storage: `StorageClient`, `upload(file, options)`, `resume(file, options)`, and `uploadToSignedUrl(uploadUrl, file, contentType?)`.
170
182
  - Install config: `getInstallConfig(pluginId)`, `updateInstallConfig(pluginId, values)`.
183
+ - Connections: `getConnections(pluginId)`, `startConnection(pluginId, connectionId)`, `disconnectConnection(pluginId, connectionId)`, and `requireConnection(pluginId, connectionId)`.
184
+ - App-to-app broker: `broker.call(target, payload?)`, `broker.emit(target, payload?)`, `servicesProxy(namespaceVersion)`, `events.on(target, handler)`, `events.emit(target, payload?)`, and `BrokerCallError`.
171
185
  - Organization/user: `UserClient`, `OrganizationClient`, including `current`, `updateProfile`, `listMine`, `listMembers`, `getMember`, `getMemberByEmail`, `inviteMember`, and `updateMemberRole`.
172
186
  - Permissions: `hasPermission(ctx, permission)`, `hasAnyPermission(ctx, permissions)`, `hasAllPermissions(ctx, permissions)`.
173
187
  - Translations: `normalizePaletteLanguage`, `translate`, `usePluginTranslations`.
@@ -311,6 +325,7 @@ Included clients:
311
325
  - `palette.organization.currentId()`, `currentRole()`, `listMine()`, `listMembers()`, `getMember()`, `getMemberByEmail()`, `inviteMember()`, and `updateMemberRole()`
312
326
  - `palette.dataRooms.list()`, `create()`, `get()`, `folder()`, `createFolder()`, `ensureFolder()`, `findRoomByName()`, `findFolderByName()`, `resolveFolderPath()`, `findFileByName()`, and `uploadFile()`
313
327
  - `palette.config.get()` and `palette.config.update(values)`, with optional plugin ID override
328
+ - `palette.connections.list()`, `connect()`, `disconnect()`, and `require()`
314
329
  - `palette.permissions.has()`, `hasAny()`, and `hasAll()`
315
330
  - `palette.storage.upload(file, options)`, `resume(file, options)`, and `uploadToSignedUrl()`
316
331
  - `palette.toast.success()`, `error()`, and `info()`
@@ -344,6 +359,37 @@ updates. When the runtime provides declared app permissions, these helpers check
344
359
  those permissions before calling the platform API. Member deletion/removal is
345
360
  intentionally not exposed through the app SDK.
346
361
 
362
+ ### App-To-App Broker
363
+
364
+ Frontend apps can call declared broker services and subscribe to declared broker
365
+ events through the SDK. The app manifest must list the targets under
366
+ `consumes.services` or `consumes.events`; Palette checks the manifest and the
367
+ org install grant before dispatching.
368
+
369
+ ```tsx
370
+ import { createPaletteClient, usePlatform } from "@palettelab/sdk"
371
+
372
+ const palette = createPaletteClient(usePlatform())
373
+
374
+ const chain = await palette.services("hr/v1").approvalChain.get({ user_id })
375
+
376
+ const unsubscribe = palette.events.on("hr/v1#hierarchy.updated", (payload) => {
377
+ console.log(payload)
378
+ })
379
+
380
+ await palette.events.emit("leave/v1#leave.requested", { user_id, chain })
381
+ await palette.events.publishDurable("leave/v1#leave.requested", { user_id, chain })
382
+ unsubscribe()
383
+ ```
384
+
385
+ Use `palette.broker.call("hr/v1#approvalChain.get", payload)` for a low-level
386
+ call when a generated helper is not available.
387
+
388
+ `pltt services pull` generates nested TypeScript clients under
389
+ `.palette/types/services.ts`, so app code can import helpers instead of
390
+ managing target strings by hand. Broker failures are surfaced as
391
+ `MissingDependencyError`, `CrossAppGrantError`, or `BrokerCallError`.
392
+
347
393
  ### Data Room Folders By Name
348
394
 
349
395
  Apps can create or reuse custom Data Room folders by name:
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import react__default from 'react';
3
- import { P as PlatformContext } from '../plugin-dpLzOtF6.mjs';
3
+ import { P as PlatformContext } from '../plugin-DXqw6d0s.mjs';
4
4
 
5
5
  /**
6
6
  * Provider that wraps plugin components with the platform context.
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import react__default from 'react';
3
- import { P as PlatformContext } from '../plugin-dpLzOtF6.js';
3
+ import { P as PlatformContext } from '../plugin-DXqw6d0s.js';
4
4
 
5
5
  /**
6
6
  * Provider that wraps plugin components with the platform context.
@@ -1,4 +1,4 @@
1
- export { P as PlatformCtx, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from '../index-DsfTFnZb.mjs';
1
+ export { P as PlatformCtx, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from '../index-CmY9M7Rg.mjs';
2
2
  import 'react';
3
- import '../plugin-dpLzOtF6.mjs';
3
+ import '../plugin-DXqw6d0s.mjs';
4
4
  import '../data-room-Dtd9LLHf.mjs';
@@ -1,4 +1,4 @@
1
- export { P as PlatformCtx, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from '../index-D0i35Hem.js';
1
+ export { P as PlatformCtx, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from '../index-CGSwI4TZ.js';
2
2
  import 'react';
3
- import '../plugin-dpLzOtF6.js';
3
+ import '../plugin-DXqw6d0s.js';
4
4
  import '../data-room-Dtd9LLHf.js';
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { d as PaletteLanguage, P as PlatformContext } from './plugin-dpLzOtF6.js';
2
+ import { d as PaletteLanguage, P as PlatformContext } from './plugin-DXqw6d0s.js';
3
3
  import { T as Task, i as TaskStats, g as TaskCreatePayload, l as TaskUpdatePayload, D as DataRoom, a as DataRoomFolder, b as DataRoomFile, d as ChatThread, c as ChatMessage } from './data-room-Dtd9LLHf.js';
4
4
 
5
5
  type TranslationPrimitive = string | number | boolean | null;
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { d as PaletteLanguage, P as PlatformContext } from './plugin-dpLzOtF6.mjs';
2
+ import { d as PaletteLanguage, P as PlatformContext } from './plugin-DXqw6d0s.mjs';
3
3
  import { T as Task, i as TaskStats, g as TaskCreatePayload, l as TaskUpdatePayload, D as DataRoom, a as DataRoomFolder, b as DataRoomFile, d as ChatThread, c as ChatMessage } from './data-room-Dtd9LLHf.mjs';
4
4
 
5
5
  type TranslationPrimitive = string | number | boolean | null;
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
- import { P as PlatformContext, O as OrgSummary, U as User } from './plugin-dpLzOtF6.mjs';
2
- export { A as Agent, a as AgentConfig, b as AppCategory, c as AuthContextValue, d as PaletteLanguage, e as PluginAgentDefinition, f as PluginComponentProps, g as PluginConnectionDefinition, h as PluginManifest, i as PluginToolDefinition } from './plugin-dpLzOtF6.mjs';
1
+ import { P as PlatformContext, O as OrgSummary, U as User } from './plugin-DXqw6d0s.mjs';
2
+ export { A as Agent, a as AgentConfig, b as AppCategory, c as AuthContextValue, d as PaletteLanguage, e as PluginAgentDefinition, f as PluginComponentProps, g as PluginConnectionDefinition, h as PluginManifest, i as PluginToolDefinition } from './plugin-DXqw6d0s.mjs';
3
3
  import { D as DataRoom, a as DataRoomFolder, b as DataRoomFile } from './data-room-Dtd9LLHf.mjs';
4
4
  export { C as ChatAttachment, c as ChatMessage, d as ChatThread, e as DataRoomPermission, T as Task, f as TaskAgentSnippet, g as TaskCreatePayload, h as TaskPriority, i as TaskStats, j as TaskStatus, k as TaskType, l as TaskUpdatePayload } from './data-room-Dtd9LLHf.mjs';
5
5
  export { AgentResource, ResourcesByGroup } from './types/index.mjs';
6
6
  import { ReactElement } from 'react';
7
- export { P as PlatformCtx, T as TranslateOptions, a as TranslationDictionary, b as TranslationPrimitive, c as TranslationResources, d as TranslationValues, U as UsePluginTranslationsOptions, n as normalizePaletteLanguage, t as translate, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from './index-DsfTFnZb.mjs';
7
+ export { P as PlatformCtx, T as TranslateOptions, a as TranslationDictionary, b as TranslationPrimitive, c as TranslationResources, d as TranslationValues, U as UsePluginTranslationsOptions, n as normalizePaletteLanguage, t as translate, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from './index-CmY9M7Rg.mjs';
8
8
  export { Link, PaletteAppRoute, PaletteAppRouter, notFound, useParams, usePathname, useRouter, useSearchParams } from './router/index.mjs';
9
9
  export { PluginProvider } from './components/index.mjs';
10
10
  import 'react/jsx-runtime';
@@ -40,6 +40,37 @@ declare function errorFromResponse(response: Response): Promise<PaletteApiError>
40
40
  declare function isPaletteApiError(error: unknown): error is PaletteApiError;
41
41
 
42
42
  type ToastType = "success" | "error" | "info";
43
+ /**
44
+ * Broker message kinds the host page must proxy on behalf of sandboxed iframe
45
+ * apps. Each message carries a unique `id` for request/response correlation.
46
+ *
47
+ * - `palette.broker.call` → host POSTs /api/v1/os-broker/dispatch, replies `{ id, result | error }`.
48
+ * - `palette.broker.emit` → host POSTs /api/v1/os-broker/events/emit, replies `{ id, error? }`.
49
+ * - `palette.broker.subscribe` → host adds the target to its SSE stream; events arrive as `palette.broker.event` messages.
50
+ * - `palette.broker.unsubscribe` → host removes the target.
51
+ *
52
+ * Events from the host to the guest use the `palette.broker.event` message
53
+ * shape `{ kind, target, payload, meta }`.
54
+ */
55
+ type SandboxBrokerMessage = {
56
+ kind: "palette.broker.call";
57
+ id: string;
58
+ target: string;
59
+ payload: unknown;
60
+ callerAppId?: string;
61
+ } | {
62
+ kind: "palette.broker.emit";
63
+ id: string;
64
+ target: string;
65
+ payload: unknown;
66
+ callerAppId?: string;
67
+ } | {
68
+ kind: "palette.broker.subscribe";
69
+ target: string;
70
+ } | {
71
+ kind: "palette.broker.unsubscribe";
72
+ target: string;
73
+ };
43
74
  type SandboxBridge = {
44
75
  apiFetch: PlatformContext["apiFetch"];
45
76
  navigate: (path: string) => void;
@@ -82,6 +113,80 @@ declare function requireConnection(pluginId: string, connectionId: string): Prom
82
113
  declare function createMockPlatformContext(overrides?: Partial<PlatformContext>): PlatformContext;
83
114
  declare function withPluginProvider(element: ReactElement, platform?: Partial<PlatformContext>): ReactElement;
84
115
 
116
+ /**
117
+ * OS broker events — subscribe + emit.
118
+ *
119
+ * import { palette } from "@palettelab/sdk"
120
+ *
121
+ * const unsubscribe = palette.events.on("org/v1#member.updated", (payload) => {
122
+ * // ...
123
+ * })
124
+ *
125
+ * await palette.events.emit("hr/v1#review.completed", { user_id: 42 })
126
+ *
127
+ * Subscriptions ride a single SSE connection to `GET /api/v1/os-broker/events/stream`.
128
+ * Sandboxed iframe apps subscribe via the host page's postMessage bridge.
129
+ */
130
+
131
+ type Handler = (payload: unknown, meta: EventMeta) => void;
132
+ type EventMeta = {
133
+ target: string;
134
+ organizationId: number | null;
135
+ occurredAt: string;
136
+ };
137
+ declare const events: {
138
+ on(target: string, handler: Handler): () => void;
139
+ emit(target: string, payload?: unknown): Promise<void>;
140
+ publishDurable(target: string, payload?: unknown): Promise<void>;
141
+ emitDurable(target: string, payload?: unknown): Promise<void>;
142
+ /** Diagnostic: list active subscriptions in this page. */
143
+ active(): string[];
144
+ };
145
+
146
+ /**
147
+ * OS broker client — request/response helpers.
148
+ *
149
+ * import { palette } from "@palettelab/sdk"
150
+ *
151
+ * const { items } = await palette.services("org/v1").members.list({ team_id: 7 })
152
+ *
153
+ * // or, untyped low-level form:
154
+ * const result = await palette.broker.call("org/v1#members.list", { team_id: 7 })
155
+ *
156
+ * Apps never know each other's URLs. Every call hits the broker, which checks
157
+ * the consumer's manifest `consumes` block and the org admin's grant before
158
+ * dispatching to the provider in-process (or, for out-of-process backends,
159
+ * via the platform's signed internal-call transport).
160
+ *
161
+ * In a sandboxed iframe app, the SDK forwards the call to the parent host
162
+ * page via postMessage rather than calling the broker endpoint directly —
163
+ * the host is the only frame holding the session cookie.
164
+ */
165
+ declare class BrokerCallError extends Error {
166
+ readonly target: string;
167
+ readonly status?: number | undefined;
168
+ constructor(message: string, target: string, status?: number | undefined);
169
+ }
170
+ declare class MissingDependencyError extends BrokerCallError {
171
+ constructor(message: string, target: string, status?: number);
172
+ }
173
+ declare class CrossAppGrantError extends BrokerCallError {
174
+ constructor(message: string, target: string, status?: number);
175
+ }
176
+ type BrokerCallOptions = {
177
+ /** Override the caller app id sent to the broker. Inferred from the URL when omitted. */
178
+ callerAppId?: string;
179
+ /** AbortSignal forwarded to fetch. */
180
+ signal?: AbortSignal;
181
+ };
182
+ /** Low-level broker API. Prefer the typed `palette.services(...)` proxy. */
183
+ declare const broker: {
184
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
185
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
186
+ };
187
+ /** Typed proxy: `palette.services("org/v1").members.list({ ... })`. */
188
+ declare function servicesProxy(namespaceVersion: string): any;
189
+
85
190
  interface DataRoomContents {
86
191
  room?: DataRoom;
87
192
  folders: DataRoomFolder[];
@@ -241,11 +346,77 @@ declare function createPaletteClient(ctx?: PlatformContext): {
241
346
  error: (message: string) => void | undefined;
242
347
  info: (message: string) => void | undefined;
243
348
  };
349
+ /**
350
+ * OS-broker RPC. Typed entry point: `palette.services("org/v1").members.list({...})`.
351
+ * The proxy resolves a dotted method chain into a qualified target string
352
+ * and dispatches via the broker (in-process for plugins on the host,
353
+ * postMessage for sandboxed iframe apps).
354
+ */
355
+ services: (namespaceVersion: string) => any;
356
+ /** Low-level broker accessor when you don't want the typed proxy. */
357
+ broker: {
358
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
359
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
360
+ };
361
+ /** OS-broker pub/sub. `events.on(target, fn)` returns an unsubscribe function. */
362
+ events: {
363
+ on(target: string, handler: (payload: unknown, meta: EventMeta) => void): () => void;
364
+ emit(target: string, payload?: unknown): Promise<void>;
365
+ publishDurable(target: string, payload?: unknown): Promise<void>;
366
+ emitDurable(target: string, payload?: unknown): Promise<void>;
367
+ active(): string[];
368
+ };
244
369
  };
245
370
  type PaletteClient = ReturnType<typeof createPaletteClient>;
371
+ declare const palette: {
372
+ user: UserClient;
373
+ organization: OrganizationClient;
374
+ dataRooms: DataRoomClient;
375
+ storage: StorageClient;
376
+ config: {
377
+ get: (pluginId?: string) => Promise<InstallConfig>;
378
+ update: (values: Record<string, unknown>, pluginId?: string) => Promise<InstallConfig>;
379
+ };
380
+ connections: {
381
+ list: (pluginId?: string) => Promise<ConnectionStatus[]>;
382
+ connect: (connectionId: string, pluginId?: string) => Promise<ConnectionAuthStart>;
383
+ disconnect: (connectionId: string, pluginId?: string) => Promise<void>;
384
+ require: (connectionId: string, pluginId?: string) => Promise<ConnectionStatus>;
385
+ };
386
+ permissions: {
387
+ has: (permission: string) => boolean;
388
+ hasAny: (permissions: string[]) => boolean;
389
+ hasAll: (permissions: string[]) => boolean;
390
+ };
391
+ toast: {
392
+ success: (message: string) => void | undefined;
393
+ error: (message: string) => void | undefined;
394
+ info: (message: string) => void | undefined;
395
+ };
396
+ /**
397
+ * OS-broker RPC. Typed entry point: `palette.services("org/v1").members.list({...})`.
398
+ * The proxy resolves a dotted method chain into a qualified target string
399
+ * and dispatches via the broker (in-process for plugins on the host,
400
+ * postMessage for sandboxed iframe apps).
401
+ */
402
+ services: (namespaceVersion: string) => any;
403
+ /** Low-level broker accessor when you don't want the typed proxy. */
404
+ broker: {
405
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
406
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
407
+ };
408
+ /** OS-broker pub/sub. `events.on(target, fn)` returns an unsubscribe function. */
409
+ events: {
410
+ on(target: string, handler: (payload: unknown, meta: EventMeta) => void): () => void;
411
+ emit(target: string, payload?: unknown): Promise<void>;
412
+ publishDurable(target: string, payload?: unknown): Promise<void>;
413
+ emitDurable(target: string, payload?: unknown): Promise<void>;
414
+ active(): string[];
415
+ };
416
+ };
246
417
 
247
418
  declare function hasPermission(ctx: PlatformContext, permission: string): boolean;
248
419
  declare function hasAnyPermission(ctx: PlatformContext, permissions: string[]): boolean;
249
420
  declare function hasAllPermissions(ctx: PlatformContext, permissions: string[]): boolean;
250
421
 
251
- export { type ConnectionAuthStart, type ConnectionStatus, type ConnectionStatusValue, DataRoom, DataRoomClient, type DataRoomContents, DataRoomFile, DataRoomFolder, type DataRoomUploadOptions, type InstallConfig, type OrgInviteMemberInput, type OrgInviteMemberResponse, type OrgMember, type OrgMemberRole, OrgSummary, OrganizationClient, PaletteApiError, type PaletteClient, PlatformContext, type SandboxBridge, StorageClient, type StorageUploadOptions, type StorageUploadProgress, type StorageUploadResult, type StorageUploadState, User, UserClient, apiFetch, apiUpload, createMockPlatformContext, createPaletteClient, createSandboxBridge, dataRooms, disconnectConnection, errorFromResponse, getBaseUrl, getConnections, getInstallConfig, hasAllPermissions, hasAnyPermission, hasPermission, isPaletteApiError, isSandboxRuntime, requireConnection, setBaseUrl, startConnection, updateInstallConfig, uploadToSignedUrl, withPluginProvider };
422
+ export { BrokerCallError, type BrokerCallOptions, type ConnectionAuthStart, type ConnectionStatus, type ConnectionStatusValue, CrossAppGrantError, DataRoom, DataRoomClient, type DataRoomContents, DataRoomFile, DataRoomFolder, type DataRoomUploadOptions, type EventMeta, type InstallConfig, MissingDependencyError, type OrgInviteMemberInput, type OrgInviteMemberResponse, type OrgMember, type OrgMemberRole, OrgSummary, OrganizationClient, PaletteApiError, type PaletteClient, PlatformContext, type SandboxBridge, type SandboxBrokerMessage, StorageClient, type StorageUploadOptions, type StorageUploadProgress, type StorageUploadResult, type StorageUploadState, User, UserClient, apiFetch, apiUpload, broker, createMockPlatformContext, createPaletteClient, createSandboxBridge, dataRooms, disconnectConnection, errorFromResponse, events, getBaseUrl, getConnections, getInstallConfig, hasAllPermissions, hasAnyPermission, hasPermission, isPaletteApiError, isSandboxRuntime, palette, requireConnection, servicesProxy, setBaseUrl, startConnection, updateInstallConfig, uploadToSignedUrl, withPluginProvider };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { P as PlatformContext, O as OrgSummary, U as User } from './plugin-dpLzOtF6.js';
2
- export { A as Agent, a as AgentConfig, b as AppCategory, c as AuthContextValue, d as PaletteLanguage, e as PluginAgentDefinition, f as PluginComponentProps, g as PluginConnectionDefinition, h as PluginManifest, i as PluginToolDefinition } from './plugin-dpLzOtF6.js';
1
+ import { P as PlatformContext, O as OrgSummary, U as User } from './plugin-DXqw6d0s.js';
2
+ export { A as Agent, a as AgentConfig, b as AppCategory, c as AuthContextValue, d as PaletteLanguage, e as PluginAgentDefinition, f as PluginComponentProps, g as PluginConnectionDefinition, h as PluginManifest, i as PluginToolDefinition } from './plugin-DXqw6d0s.js';
3
3
  import { D as DataRoom, a as DataRoomFolder, b as DataRoomFile } from './data-room-Dtd9LLHf.js';
4
4
  export { C as ChatAttachment, c as ChatMessage, d as ChatThread, e as DataRoomPermission, T as Task, f as TaskAgentSnippet, g as TaskCreatePayload, h as TaskPriority, i as TaskStats, j as TaskStatus, k as TaskType, l as TaskUpdatePayload } from './data-room-Dtd9LLHf.js';
5
5
  export { AgentResource, ResourcesByGroup } from './types/index.js';
6
6
  import { ReactElement } from 'react';
7
- export { P as PlatformCtx, T as TranslateOptions, a as TranslationDictionary, b as TranslationPrimitive, c as TranslationResources, d as TranslationValues, U as UsePluginTranslationsOptions, n as normalizePaletteLanguage, t as translate, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from './index-D0i35Hem.js';
7
+ export { P as PlatformCtx, T as TranslateOptions, a as TranslationDictionary, b as TranslationPrimitive, c as TranslationResources, d as TranslationValues, U as UsePluginTranslationsOptions, n as normalizePaletteLanguage, t as translate, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from './index-CGSwI4TZ.js';
8
8
  export { Link, PaletteAppRoute, PaletteAppRouter, notFound, useParams, usePathname, useRouter, useSearchParams } from './router/index.js';
9
9
  export { PluginProvider } from './components/index.js';
10
10
  import 'react/jsx-runtime';
@@ -40,6 +40,37 @@ declare function errorFromResponse(response: Response): Promise<PaletteApiError>
40
40
  declare function isPaletteApiError(error: unknown): error is PaletteApiError;
41
41
 
42
42
  type ToastType = "success" | "error" | "info";
43
+ /**
44
+ * Broker message kinds the host page must proxy on behalf of sandboxed iframe
45
+ * apps. Each message carries a unique `id` for request/response correlation.
46
+ *
47
+ * - `palette.broker.call` → host POSTs /api/v1/os-broker/dispatch, replies `{ id, result | error }`.
48
+ * - `palette.broker.emit` → host POSTs /api/v1/os-broker/events/emit, replies `{ id, error? }`.
49
+ * - `palette.broker.subscribe` → host adds the target to its SSE stream; events arrive as `palette.broker.event` messages.
50
+ * - `palette.broker.unsubscribe` → host removes the target.
51
+ *
52
+ * Events from the host to the guest use the `palette.broker.event` message
53
+ * shape `{ kind, target, payload, meta }`.
54
+ */
55
+ type SandboxBrokerMessage = {
56
+ kind: "palette.broker.call";
57
+ id: string;
58
+ target: string;
59
+ payload: unknown;
60
+ callerAppId?: string;
61
+ } | {
62
+ kind: "palette.broker.emit";
63
+ id: string;
64
+ target: string;
65
+ payload: unknown;
66
+ callerAppId?: string;
67
+ } | {
68
+ kind: "palette.broker.subscribe";
69
+ target: string;
70
+ } | {
71
+ kind: "palette.broker.unsubscribe";
72
+ target: string;
73
+ };
43
74
  type SandboxBridge = {
44
75
  apiFetch: PlatformContext["apiFetch"];
45
76
  navigate: (path: string) => void;
@@ -82,6 +113,80 @@ declare function requireConnection(pluginId: string, connectionId: string): Prom
82
113
  declare function createMockPlatformContext(overrides?: Partial<PlatformContext>): PlatformContext;
83
114
  declare function withPluginProvider(element: ReactElement, platform?: Partial<PlatformContext>): ReactElement;
84
115
 
116
+ /**
117
+ * OS broker events — subscribe + emit.
118
+ *
119
+ * import { palette } from "@palettelab/sdk"
120
+ *
121
+ * const unsubscribe = palette.events.on("org/v1#member.updated", (payload) => {
122
+ * // ...
123
+ * })
124
+ *
125
+ * await palette.events.emit("hr/v1#review.completed", { user_id: 42 })
126
+ *
127
+ * Subscriptions ride a single SSE connection to `GET /api/v1/os-broker/events/stream`.
128
+ * Sandboxed iframe apps subscribe via the host page's postMessage bridge.
129
+ */
130
+
131
+ type Handler = (payload: unknown, meta: EventMeta) => void;
132
+ type EventMeta = {
133
+ target: string;
134
+ organizationId: number | null;
135
+ occurredAt: string;
136
+ };
137
+ declare const events: {
138
+ on(target: string, handler: Handler): () => void;
139
+ emit(target: string, payload?: unknown): Promise<void>;
140
+ publishDurable(target: string, payload?: unknown): Promise<void>;
141
+ emitDurable(target: string, payload?: unknown): Promise<void>;
142
+ /** Diagnostic: list active subscriptions in this page. */
143
+ active(): string[];
144
+ };
145
+
146
+ /**
147
+ * OS broker client — request/response helpers.
148
+ *
149
+ * import { palette } from "@palettelab/sdk"
150
+ *
151
+ * const { items } = await palette.services("org/v1").members.list({ team_id: 7 })
152
+ *
153
+ * // or, untyped low-level form:
154
+ * const result = await palette.broker.call("org/v1#members.list", { team_id: 7 })
155
+ *
156
+ * Apps never know each other's URLs. Every call hits the broker, which checks
157
+ * the consumer's manifest `consumes` block and the org admin's grant before
158
+ * dispatching to the provider in-process (or, for out-of-process backends,
159
+ * via the platform's signed internal-call transport).
160
+ *
161
+ * In a sandboxed iframe app, the SDK forwards the call to the parent host
162
+ * page via postMessage rather than calling the broker endpoint directly —
163
+ * the host is the only frame holding the session cookie.
164
+ */
165
+ declare class BrokerCallError extends Error {
166
+ readonly target: string;
167
+ readonly status?: number | undefined;
168
+ constructor(message: string, target: string, status?: number | undefined);
169
+ }
170
+ declare class MissingDependencyError extends BrokerCallError {
171
+ constructor(message: string, target: string, status?: number);
172
+ }
173
+ declare class CrossAppGrantError extends BrokerCallError {
174
+ constructor(message: string, target: string, status?: number);
175
+ }
176
+ type BrokerCallOptions = {
177
+ /** Override the caller app id sent to the broker. Inferred from the URL when omitted. */
178
+ callerAppId?: string;
179
+ /** AbortSignal forwarded to fetch. */
180
+ signal?: AbortSignal;
181
+ };
182
+ /** Low-level broker API. Prefer the typed `palette.services(...)` proxy. */
183
+ declare const broker: {
184
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
185
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
186
+ };
187
+ /** Typed proxy: `palette.services("org/v1").members.list({ ... })`. */
188
+ declare function servicesProxy(namespaceVersion: string): any;
189
+
85
190
  interface DataRoomContents {
86
191
  room?: DataRoom;
87
192
  folders: DataRoomFolder[];
@@ -241,11 +346,77 @@ declare function createPaletteClient(ctx?: PlatformContext): {
241
346
  error: (message: string) => void | undefined;
242
347
  info: (message: string) => void | undefined;
243
348
  };
349
+ /**
350
+ * OS-broker RPC. Typed entry point: `palette.services("org/v1").members.list({...})`.
351
+ * The proxy resolves a dotted method chain into a qualified target string
352
+ * and dispatches via the broker (in-process for plugins on the host,
353
+ * postMessage for sandboxed iframe apps).
354
+ */
355
+ services: (namespaceVersion: string) => any;
356
+ /** Low-level broker accessor when you don't want the typed proxy. */
357
+ broker: {
358
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
359
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
360
+ };
361
+ /** OS-broker pub/sub. `events.on(target, fn)` returns an unsubscribe function. */
362
+ events: {
363
+ on(target: string, handler: (payload: unknown, meta: EventMeta) => void): () => void;
364
+ emit(target: string, payload?: unknown): Promise<void>;
365
+ publishDurable(target: string, payload?: unknown): Promise<void>;
366
+ emitDurable(target: string, payload?: unknown): Promise<void>;
367
+ active(): string[];
368
+ };
244
369
  };
245
370
  type PaletteClient = ReturnType<typeof createPaletteClient>;
371
+ declare const palette: {
372
+ user: UserClient;
373
+ organization: OrganizationClient;
374
+ dataRooms: DataRoomClient;
375
+ storage: StorageClient;
376
+ config: {
377
+ get: (pluginId?: string) => Promise<InstallConfig>;
378
+ update: (values: Record<string, unknown>, pluginId?: string) => Promise<InstallConfig>;
379
+ };
380
+ connections: {
381
+ list: (pluginId?: string) => Promise<ConnectionStatus[]>;
382
+ connect: (connectionId: string, pluginId?: string) => Promise<ConnectionAuthStart>;
383
+ disconnect: (connectionId: string, pluginId?: string) => Promise<void>;
384
+ require: (connectionId: string, pluginId?: string) => Promise<ConnectionStatus>;
385
+ };
386
+ permissions: {
387
+ has: (permission: string) => boolean;
388
+ hasAny: (permissions: string[]) => boolean;
389
+ hasAll: (permissions: string[]) => boolean;
390
+ };
391
+ toast: {
392
+ success: (message: string) => void | undefined;
393
+ error: (message: string) => void | undefined;
394
+ info: (message: string) => void | undefined;
395
+ };
396
+ /**
397
+ * OS-broker RPC. Typed entry point: `palette.services("org/v1").members.list({...})`.
398
+ * The proxy resolves a dotted method chain into a qualified target string
399
+ * and dispatches via the broker (in-process for plugins on the host,
400
+ * postMessage for sandboxed iframe apps).
401
+ */
402
+ services: (namespaceVersion: string) => any;
403
+ /** Low-level broker accessor when you don't want the typed proxy. */
404
+ broker: {
405
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
406
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
407
+ };
408
+ /** OS-broker pub/sub. `events.on(target, fn)` returns an unsubscribe function. */
409
+ events: {
410
+ on(target: string, handler: (payload: unknown, meta: EventMeta) => void): () => void;
411
+ emit(target: string, payload?: unknown): Promise<void>;
412
+ publishDurable(target: string, payload?: unknown): Promise<void>;
413
+ emitDurable(target: string, payload?: unknown): Promise<void>;
414
+ active(): string[];
415
+ };
416
+ };
246
417
 
247
418
  declare function hasPermission(ctx: PlatformContext, permission: string): boolean;
248
419
  declare function hasAnyPermission(ctx: PlatformContext, permissions: string[]): boolean;
249
420
  declare function hasAllPermissions(ctx: PlatformContext, permissions: string[]): boolean;
250
421
 
251
- export { type ConnectionAuthStart, type ConnectionStatus, type ConnectionStatusValue, DataRoom, DataRoomClient, type DataRoomContents, DataRoomFile, DataRoomFolder, type DataRoomUploadOptions, type InstallConfig, type OrgInviteMemberInput, type OrgInviteMemberResponse, type OrgMember, type OrgMemberRole, OrgSummary, OrganizationClient, PaletteApiError, type PaletteClient, PlatformContext, type SandboxBridge, StorageClient, type StorageUploadOptions, type StorageUploadProgress, type StorageUploadResult, type StorageUploadState, User, UserClient, apiFetch, apiUpload, createMockPlatformContext, createPaletteClient, createSandboxBridge, dataRooms, disconnectConnection, errorFromResponse, getBaseUrl, getConnections, getInstallConfig, hasAllPermissions, hasAnyPermission, hasPermission, isPaletteApiError, isSandboxRuntime, requireConnection, setBaseUrl, startConnection, updateInstallConfig, uploadToSignedUrl, withPluginProvider };
422
+ export { BrokerCallError, type BrokerCallOptions, type ConnectionAuthStart, type ConnectionStatus, type ConnectionStatusValue, CrossAppGrantError, DataRoom, DataRoomClient, type DataRoomContents, DataRoomFile, DataRoomFolder, type DataRoomUploadOptions, type EventMeta, type InstallConfig, MissingDependencyError, type OrgInviteMemberInput, type OrgInviteMemberResponse, type OrgMember, type OrgMemberRole, OrgSummary, OrganizationClient, PaletteApiError, type PaletteClient, PlatformContext, type SandboxBridge, type SandboxBrokerMessage, StorageClient, type StorageUploadOptions, type StorageUploadProgress, type StorageUploadResult, type StorageUploadState, User, UserClient, apiFetch, apiUpload, broker, createMockPlatformContext, createPaletteClient, createSandboxBridge, dataRooms, disconnectConnection, errorFromResponse, events, getBaseUrl, getConnections, getInstallConfig, hasAllPermissions, hasAnyPermission, hasPermission, isPaletteApiError, isSandboxRuntime, palette, requireConnection, servicesProxy, setBaseUrl, startConnection, updateInstallConfig, uploadToSignedUrl, withPluginProvider };