@palettelab/sdk 0.1.20 → 0.1.21

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,35 @@ 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
+ unsubscribe()
382
+ ```
383
+
384
+ Use `palette.broker.call("hr/v1#approvalChain.get", payload)` for a low-level
385
+ call when a generated helper is not available.
386
+
387
+ `pltt services pull` generates TypeScript clients that import the SDK's default
388
+ `palette` client and write calls such as `palette.broker.call(...)` under
389
+ `.palette/types/services.ts`.
390
+
347
391
  ### Data Room Folders By Name
348
392
 
349
393
  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,72 @@ 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
+ /** Diagnostic: list active subscriptions in this page. */
141
+ active(): string[];
142
+ };
143
+
144
+ /**
145
+ * OS broker client — request/response helpers.
146
+ *
147
+ * import { palette } from "@palettelab/sdk"
148
+ *
149
+ * const { items } = await palette.services("org/v1").members.list({ team_id: 7 })
150
+ *
151
+ * // or, untyped low-level form:
152
+ * const result = await palette.broker.call("org/v1#members.list", { team_id: 7 })
153
+ *
154
+ * Apps never know each other's URLs. Every call hits the broker, which checks
155
+ * the consumer's manifest `consumes` block and the org admin's grant before
156
+ * dispatching to the provider in-process (or, for out-of-process backends,
157
+ * via the platform's signed internal-call transport).
158
+ *
159
+ * In a sandboxed iframe app, the SDK forwards the call to the parent host
160
+ * page via postMessage rather than calling the broker endpoint directly —
161
+ * the host is the only frame holding the session cookie.
162
+ */
163
+ declare class BrokerCallError extends Error {
164
+ readonly target: string;
165
+ readonly status?: number | undefined;
166
+ constructor(message: string, target: string, status?: number | undefined);
167
+ }
168
+ type BrokerCallOptions = {
169
+ /** Override the caller app id sent to the broker. Inferred from the URL when omitted. */
170
+ callerAppId?: string;
171
+ /** AbortSignal forwarded to fetch. */
172
+ signal?: AbortSignal;
173
+ };
174
+ /** Low-level broker API. Prefer the typed `palette.services(...)` proxy. */
175
+ declare const broker: {
176
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
177
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
178
+ };
179
+ /** Typed proxy: `palette.services("org/v1").members.list({ ... })`. */
180
+ declare function servicesProxy(namespaceVersion: string): any;
181
+
85
182
  interface DataRoomContents {
86
183
  room?: DataRoom;
87
184
  folders: DataRoomFolder[];
@@ -241,11 +338,73 @@ declare function createPaletteClient(ctx?: PlatformContext): {
241
338
  error: (message: string) => void | undefined;
242
339
  info: (message: string) => void | undefined;
243
340
  };
341
+ /**
342
+ * OS-broker RPC. Typed entry point: `palette.services("org/v1").members.list({...})`.
343
+ * The proxy resolves a dotted method chain into a qualified target string
344
+ * and dispatches via the broker (in-process for plugins on the host,
345
+ * postMessage for sandboxed iframe apps).
346
+ */
347
+ services: (namespaceVersion: string) => any;
348
+ /** Low-level broker accessor when you don't want the typed proxy. */
349
+ broker: {
350
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
351
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
352
+ };
353
+ /** OS-broker pub/sub. `events.on(target, fn)` returns an unsubscribe function. */
354
+ events: {
355
+ on(target: string, handler: (payload: unknown, meta: EventMeta) => void): () => void;
356
+ emit(target: string, payload?: unknown): Promise<void>;
357
+ active(): string[];
358
+ };
244
359
  };
245
360
  type PaletteClient = ReturnType<typeof createPaletteClient>;
361
+ declare const palette: {
362
+ user: UserClient;
363
+ organization: OrganizationClient;
364
+ dataRooms: DataRoomClient;
365
+ storage: StorageClient;
366
+ config: {
367
+ get: (pluginId?: string) => Promise<InstallConfig>;
368
+ update: (values: Record<string, unknown>, pluginId?: string) => Promise<InstallConfig>;
369
+ };
370
+ connections: {
371
+ list: (pluginId?: string) => Promise<ConnectionStatus[]>;
372
+ connect: (connectionId: string, pluginId?: string) => Promise<ConnectionAuthStart>;
373
+ disconnect: (connectionId: string, pluginId?: string) => Promise<void>;
374
+ require: (connectionId: string, pluginId?: string) => Promise<ConnectionStatus>;
375
+ };
376
+ permissions: {
377
+ has: (permission: string) => boolean;
378
+ hasAny: (permissions: string[]) => boolean;
379
+ hasAll: (permissions: string[]) => boolean;
380
+ };
381
+ toast: {
382
+ success: (message: string) => void | undefined;
383
+ error: (message: string) => void | undefined;
384
+ info: (message: string) => void | undefined;
385
+ };
386
+ /**
387
+ * OS-broker RPC. Typed entry point: `palette.services("org/v1").members.list({...})`.
388
+ * The proxy resolves a dotted method chain into a qualified target string
389
+ * and dispatches via the broker (in-process for plugins on the host,
390
+ * postMessage for sandboxed iframe apps).
391
+ */
392
+ services: (namespaceVersion: string) => any;
393
+ /** Low-level broker accessor when you don't want the typed proxy. */
394
+ broker: {
395
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
396
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
397
+ };
398
+ /** OS-broker pub/sub. `events.on(target, fn)` returns an unsubscribe function. */
399
+ events: {
400
+ on(target: string, handler: (payload: unknown, meta: EventMeta) => void): () => void;
401
+ emit(target: string, payload?: unknown): Promise<void>;
402
+ active(): string[];
403
+ };
404
+ };
246
405
 
247
406
  declare function hasPermission(ctx: PlatformContext, permission: string): boolean;
248
407
  declare function hasAnyPermission(ctx: PlatformContext, permissions: string[]): boolean;
249
408
  declare function hasAllPermissions(ctx: PlatformContext, permissions: string[]): boolean;
250
409
 
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 };
410
+ export { BrokerCallError, type BrokerCallOptions, type ConnectionAuthStart, type ConnectionStatus, type ConnectionStatusValue, DataRoom, DataRoomClient, type DataRoomContents, DataRoomFile, DataRoomFolder, type DataRoomUploadOptions, type EventMeta, type InstallConfig, 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,72 @@ 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
+ /** Diagnostic: list active subscriptions in this page. */
141
+ active(): string[];
142
+ };
143
+
144
+ /**
145
+ * OS broker client — request/response helpers.
146
+ *
147
+ * import { palette } from "@palettelab/sdk"
148
+ *
149
+ * const { items } = await palette.services("org/v1").members.list({ team_id: 7 })
150
+ *
151
+ * // or, untyped low-level form:
152
+ * const result = await palette.broker.call("org/v1#members.list", { team_id: 7 })
153
+ *
154
+ * Apps never know each other's URLs. Every call hits the broker, which checks
155
+ * the consumer's manifest `consumes` block and the org admin's grant before
156
+ * dispatching to the provider in-process (or, for out-of-process backends,
157
+ * via the platform's signed internal-call transport).
158
+ *
159
+ * In a sandboxed iframe app, the SDK forwards the call to the parent host
160
+ * page via postMessage rather than calling the broker endpoint directly —
161
+ * the host is the only frame holding the session cookie.
162
+ */
163
+ declare class BrokerCallError extends Error {
164
+ readonly target: string;
165
+ readonly status?: number | undefined;
166
+ constructor(message: string, target: string, status?: number | undefined);
167
+ }
168
+ type BrokerCallOptions = {
169
+ /** Override the caller app id sent to the broker. Inferred from the URL when omitted. */
170
+ callerAppId?: string;
171
+ /** AbortSignal forwarded to fetch. */
172
+ signal?: AbortSignal;
173
+ };
174
+ /** Low-level broker API. Prefer the typed `palette.services(...)` proxy. */
175
+ declare const broker: {
176
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
177
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
178
+ };
179
+ /** Typed proxy: `palette.services("org/v1").members.list({ ... })`. */
180
+ declare function servicesProxy(namespaceVersion: string): any;
181
+
85
182
  interface DataRoomContents {
86
183
  room?: DataRoom;
87
184
  folders: DataRoomFolder[];
@@ -241,11 +338,73 @@ declare function createPaletteClient(ctx?: PlatformContext): {
241
338
  error: (message: string) => void | undefined;
242
339
  info: (message: string) => void | undefined;
243
340
  };
341
+ /**
342
+ * OS-broker RPC. Typed entry point: `palette.services("org/v1").members.list({...})`.
343
+ * The proxy resolves a dotted method chain into a qualified target string
344
+ * and dispatches via the broker (in-process for plugins on the host,
345
+ * postMessage for sandboxed iframe apps).
346
+ */
347
+ services: (namespaceVersion: string) => any;
348
+ /** Low-level broker accessor when you don't want the typed proxy. */
349
+ broker: {
350
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
351
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
352
+ };
353
+ /** OS-broker pub/sub. `events.on(target, fn)` returns an unsubscribe function. */
354
+ events: {
355
+ on(target: string, handler: (payload: unknown, meta: EventMeta) => void): () => void;
356
+ emit(target: string, payload?: unknown): Promise<void>;
357
+ active(): string[];
358
+ };
244
359
  };
245
360
  type PaletteClient = ReturnType<typeof createPaletteClient>;
361
+ declare const palette: {
362
+ user: UserClient;
363
+ organization: OrganizationClient;
364
+ dataRooms: DataRoomClient;
365
+ storage: StorageClient;
366
+ config: {
367
+ get: (pluginId?: string) => Promise<InstallConfig>;
368
+ update: (values: Record<string, unknown>, pluginId?: string) => Promise<InstallConfig>;
369
+ };
370
+ connections: {
371
+ list: (pluginId?: string) => Promise<ConnectionStatus[]>;
372
+ connect: (connectionId: string, pluginId?: string) => Promise<ConnectionAuthStart>;
373
+ disconnect: (connectionId: string, pluginId?: string) => Promise<void>;
374
+ require: (connectionId: string, pluginId?: string) => Promise<ConnectionStatus>;
375
+ };
376
+ permissions: {
377
+ has: (permission: string) => boolean;
378
+ hasAny: (permissions: string[]) => boolean;
379
+ hasAll: (permissions: string[]) => boolean;
380
+ };
381
+ toast: {
382
+ success: (message: string) => void | undefined;
383
+ error: (message: string) => void | undefined;
384
+ info: (message: string) => void | undefined;
385
+ };
386
+ /**
387
+ * OS-broker RPC. Typed entry point: `palette.services("org/v1").members.list({...})`.
388
+ * The proxy resolves a dotted method chain into a qualified target string
389
+ * and dispatches via the broker (in-process for plugins on the host,
390
+ * postMessage for sandboxed iframe apps).
391
+ */
392
+ services: (namespaceVersion: string) => any;
393
+ /** Low-level broker accessor when you don't want the typed proxy. */
394
+ broker: {
395
+ call(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<unknown>;
396
+ emit(target: string, payload?: unknown, options?: BrokerCallOptions): Promise<void>;
397
+ };
398
+ /** OS-broker pub/sub. `events.on(target, fn)` returns an unsubscribe function. */
399
+ events: {
400
+ on(target: string, handler: (payload: unknown, meta: EventMeta) => void): () => void;
401
+ emit(target: string, payload?: unknown): Promise<void>;
402
+ active(): string[];
403
+ };
404
+ };
246
405
 
247
406
  declare function hasPermission(ctx: PlatformContext, permission: string): boolean;
248
407
  declare function hasAnyPermission(ctx: PlatformContext, permissions: string[]): boolean;
249
408
  declare function hasAllPermissions(ctx: PlatformContext, permissions: string[]): boolean;
250
409
 
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 };
410
+ export { BrokerCallError, type BrokerCallOptions, type ConnectionAuthStart, type ConnectionStatus, type ConnectionStatusValue, DataRoom, DataRoomClient, type DataRoomContents, DataRoomFile, DataRoomFolder, type DataRoomUploadOptions, type EventMeta, type InstallConfig, 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 };