@palettelab/sdk 0.1.14 → 0.1.16

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
@@ -166,7 +166,7 @@ Public frontend helpers exported by `@palettelab/sdk`:
166
166
  - API: `apiFetch(path, init?)`, `apiUpload(path, file, fieldName?, extraFields?)`, `setBaseUrl(url)`, `getBaseUrl()`.
167
167
  - Errors: `PaletteApiError`, `errorFromResponse(response)`, `isPaletteApiError(error)`.
168
168
  - Data Rooms: `DataRoomClient`, `dataRooms`, plus `list`, `create`, `get`, `folder`, `ensureRoom`, `requireRoomByName`, `findRoomByName`, `createFolder`, `ensureFolder`, `findFolderByName`, `resolveFolderPath`, `findFileByName`, `requestUpload`, `confirmUpload`, and `uploadFile`.
169
- - Storage: `StorageClient`, `uploadToSignedUrl(uploadUrl, file, contentType?)`.
169
+ - Storage: `StorageClient`, `upload(file, options)`, `resume(file, options)`, and `uploadToSignedUrl(uploadUrl, file, contentType?)`.
170
170
  - Install config: `getInstallConfig(pluginId)`, `updateInstallConfig(pluginId, values)`.
171
171
  - Organization/user: `UserClient`, `OrganizationClient`, including `current`, `updateProfile`, `listMine`, `listMembers`, `getMember`, `getMemberByEmail`, `inviteMember`, and `updateMemberRole`.
172
172
  - Permissions: `hasPermission(ctx, permission)`, `hasAnyPermission(ctx, permissions)`, `hasAllPermissions(ctx, permissions)`.
@@ -257,6 +257,32 @@ The CLI reads that config in `pltt dev`, `pltt test`, `pltt package`, and
257
257
  `NEXT_PUBLIC_*` environment variables, and path aliases from
258
258
  `frontend/tsconfig.json`.
259
259
 
260
+ ## Palette App Router
261
+
262
+ For OS-native routed apps, set `frontend.framework` to `palette-app` and point
263
+ `frontend.entry` at `frontend/app`. The CLI scans app-directory UI files and
264
+ still publishes one safe browser bundle.
265
+
266
+ ```json
267
+ {
268
+ "frontend": {
269
+ "entry": "./frontend/app",
270
+ "sandbox": true,
271
+ "framework": "palette-app"
272
+ }
273
+ }
274
+ ```
275
+
276
+ Supported UI files are `layout.tsx`, `page.tsx`, `loading.tsx`, `error.tsx`,
277
+ and `not-found.tsx`. Static routes, route groups, `[id]`, `[...slug]`, and
278
+ `[[...slug]]` are supported. Use `Link`, `useRouter`, `usePathname`,
279
+ `useSearchParams`, and `useParams` from `@palettelab/sdk`, or use the
280
+ `next/link` and `next/navigation` compatibility imports in `palette-app`
281
+ projects.
282
+
283
+ Server-side Next features are intentionally not part of this mode. Put APIs,
284
+ database access, permissions, and secrets in the plugin backend.
285
+
260
286
  ## Palette Client
261
287
 
262
288
  Use `createPaletteClient()` when an app needs common Palette OS services without
@@ -286,12 +312,30 @@ Included clients:
286
312
  - `palette.dataRooms.list()`, `create()`, `get()`, `folder()`, `createFolder()`, `ensureFolder()`, `findRoomByName()`, `findFolderByName()`, `resolveFolderPath()`, `findFileByName()`, and `uploadFile()`
287
313
  - `palette.config.get()` and `palette.config.update(values)`, with optional plugin ID override
288
314
  - `palette.permissions.has()`, `hasAny()`, and `hasAll()`
289
- - `palette.storage.uploadToSignedUrl()`
315
+ - `palette.storage.upload(file, options)`, `resume(file, options)`, and `uploadToSignedUrl()`
290
316
  - `palette.toast.success()`, `error()`, and `info()`
291
317
 
292
318
  These helpers are intentionally thin wrappers over platform APIs. Apps can still
293
319
  use `apiFetch()` directly for custom backend routes.
294
320
 
321
+ App storage uploads are scoped by Palette to:
322
+
323
+ ```text
324
+ uploads/apps/{app_name}_{plugin_id}/{organisation_slug}_{organisation_id}/{file}
325
+ ```
326
+
327
+ Declare `"storage"` in `platform_services`, then upload directly from the
328
+ browser with resumable chunking and progress:
329
+
330
+ ```tsx
331
+ const palette = createPaletteClient(usePlatform())
332
+
333
+ await palette.storage.upload(file, {
334
+ key: `receipts/${file.name}`,
335
+ onProgress: (p) => setPercent(p.percentage),
336
+ })
337
+ ```
338
+
295
339
  Member helpers operate on the active organisation. Use `members:read` for
296
340
  listing or looking up members, and `members:write` for invitations or role
297
341
  updates. When the runtime provides declared app permissions, these helpers check
@@ -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-UV46q1mU.mjs';
3
+ import { P as PlatformContext } from '../plugin-CG6spHKI.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-UV46q1mU.js';
3
+ import { P as PlatformContext } from '../plugin-CG6spHKI.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-Bu5EQGYo.mjs';
1
+ export { P as PlatformCtx, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from '../index-BGT6xBGD.mjs';
2
2
  import 'react';
3
- import '../plugin-UV46q1mU.mjs';
3
+ import '../plugin-CG6spHKI.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-BDVWt7DE.js';
1
+ export { P as PlatformCtx, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from '../index-Beo6F2Fr.js';
2
2
  import 'react';
3
- import '../plugin-UV46q1mU.js';
3
+ import '../plugin-CG6spHKI.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-UV46q1mU.mjs';
2
+ import { d as PaletteLanguage, P as PlatformContext } from './plugin-CG6spHKI.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;
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { d as PaletteLanguage, P as PlatformContext } from './plugin-UV46q1mU.js';
2
+ import { d as PaletteLanguage, P as PlatformContext } from './plugin-CG6spHKI.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;
package/dist/index.d.mts CHANGED
@@ -1,10 +1,11 @@
1
- import { P as PlatformContext, O as OrgSummary, U as User } from './plugin-UV46q1mU.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 PluginManifest, h as PluginToolDefinition } from './plugin-UV46q1mU.mjs';
1
+ import { P as PlatformContext, O as OrgSummary, U as User } from './plugin-CG6spHKI.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 PluginManifest, h as PluginToolDefinition } from './plugin-CG6spHKI.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-Bu5EQGYo.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-BGT6xBGD.mjs';
8
+ export { Link, PaletteAppRoute, PaletteAppRouter, notFound, useParams, usePathname, useRouter, useSearchParams } from './router/index.mjs';
8
9
  export { PluginProvider } from './components/index.mjs';
9
10
  import 'react/jsx-runtime';
10
11
 
@@ -107,8 +108,41 @@ declare class DataRoomClient {
107
108
  }
108
109
  declare const dataRooms: DataRoomClient;
109
110
 
111
+ type StorageUploadState = "starting" | "uploading" | "paused" | "complete";
112
+ type StorageUploadProgress = {
113
+ loaded: number;
114
+ total: number;
115
+ percentage: number;
116
+ chunkIndex: number;
117
+ chunkCount: number;
118
+ state: StorageUploadState;
119
+ };
120
+ type StorageUploadOptions = {
121
+ pluginId?: string;
122
+ key?: string;
123
+ contentType?: string;
124
+ chunkSize?: number;
125
+ resumable?: boolean;
126
+ onProgress?: (progress: StorageUploadProgress) => void;
127
+ signal?: AbortSignal;
128
+ };
129
+ type StorageUploadResult = {
130
+ uploadId: string;
131
+ mode: "gcs_resumable" | "local_resumable" | string;
132
+ bucket: string;
133
+ objectPath: string;
134
+ fileUrl: string;
135
+ contentType: string;
136
+ size: number;
137
+ };
110
138
  declare function uploadToSignedUrl(uploadUrl: string, file: Blob, contentType?: string): Promise<void>;
111
139
  declare class StorageClient {
140
+ private readonly ctx?;
141
+ constructor(ctx?: PlatformContext | undefined);
142
+ private pluginId;
143
+ private createSession;
144
+ upload(file: File, options?: StorageUploadOptions): Promise<StorageUploadResult>;
145
+ resume(file: File, options?: StorageUploadOptions): Promise<StorageUploadResult>;
112
146
  uploadToSignedUrl: typeof uploadToSignedUrl;
113
147
  }
114
148
 
@@ -179,4 +213,4 @@ declare function hasPermission(ctx: PlatformContext, permission: string): boolea
179
213
  declare function hasAnyPermission(ctx: PlatformContext, permissions: string[]): boolean;
180
214
  declare function hasAllPermissions(ctx: PlatformContext, permissions: string[]): boolean;
181
215
 
182
- export { 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, User, UserClient, apiFetch, apiUpload, createMockPlatformContext, createPaletteClient, createSandboxBridge, dataRooms, errorFromResponse, getBaseUrl, getInstallConfig, hasAllPermissions, hasAnyPermission, hasPermission, isPaletteApiError, isSandboxRuntime, setBaseUrl, updateInstallConfig, uploadToSignedUrl, withPluginProvider };
216
+ export { 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, errorFromResponse, getBaseUrl, getInstallConfig, hasAllPermissions, hasAnyPermission, hasPermission, isPaletteApiError, isSandboxRuntime, setBaseUrl, updateInstallConfig, uploadToSignedUrl, withPluginProvider };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { P as PlatformContext, O as OrgSummary, U as User } from './plugin-UV46q1mU.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 PluginManifest, h as PluginToolDefinition } from './plugin-UV46q1mU.js';
1
+ import { P as PlatformContext, O as OrgSummary, U as User } from './plugin-CG6spHKI.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 PluginManifest, h as PluginToolDefinition } from './plugin-CG6spHKI.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-BDVWt7DE.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-Beo6F2Fr.js';
8
+ export { Link, PaletteAppRoute, PaletteAppRouter, notFound, useParams, usePathname, useRouter, useSearchParams } from './router/index.js';
8
9
  export { PluginProvider } from './components/index.js';
9
10
  import 'react/jsx-runtime';
10
11
 
@@ -107,8 +108,41 @@ declare class DataRoomClient {
107
108
  }
108
109
  declare const dataRooms: DataRoomClient;
109
110
 
111
+ type StorageUploadState = "starting" | "uploading" | "paused" | "complete";
112
+ type StorageUploadProgress = {
113
+ loaded: number;
114
+ total: number;
115
+ percentage: number;
116
+ chunkIndex: number;
117
+ chunkCount: number;
118
+ state: StorageUploadState;
119
+ };
120
+ type StorageUploadOptions = {
121
+ pluginId?: string;
122
+ key?: string;
123
+ contentType?: string;
124
+ chunkSize?: number;
125
+ resumable?: boolean;
126
+ onProgress?: (progress: StorageUploadProgress) => void;
127
+ signal?: AbortSignal;
128
+ };
129
+ type StorageUploadResult = {
130
+ uploadId: string;
131
+ mode: "gcs_resumable" | "local_resumable" | string;
132
+ bucket: string;
133
+ objectPath: string;
134
+ fileUrl: string;
135
+ contentType: string;
136
+ size: number;
137
+ };
110
138
  declare function uploadToSignedUrl(uploadUrl: string, file: Blob, contentType?: string): Promise<void>;
111
139
  declare class StorageClient {
140
+ private readonly ctx?;
141
+ constructor(ctx?: PlatformContext | undefined);
142
+ private pluginId;
143
+ private createSession;
144
+ upload(file: File, options?: StorageUploadOptions): Promise<StorageUploadResult>;
145
+ resume(file: File, options?: StorageUploadOptions): Promise<StorageUploadResult>;
112
146
  uploadToSignedUrl: typeof uploadToSignedUrl;
113
147
  }
114
148
 
@@ -179,4 +213,4 @@ declare function hasPermission(ctx: PlatformContext, permission: string): boolea
179
213
  declare function hasAnyPermission(ctx: PlatformContext, permissions: string[]): boolean;
180
214
  declare function hasAllPermissions(ctx: PlatformContext, permissions: string[]): boolean;
181
215
 
182
- export { 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, User, UserClient, apiFetch, apiUpload, createMockPlatformContext, createPaletteClient, createSandboxBridge, dataRooms, errorFromResponse, getBaseUrl, getInstallConfig, hasAllPermissions, hasAnyPermission, hasPermission, isPaletteApiError, isSandboxRuntime, setBaseUrl, updateInstallConfig, uploadToSignedUrl, withPluginProvider };
216
+ export { 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, errorFromResponse, getBaseUrl, getInstallConfig, hasAllPermissions, hasAnyPermission, hasPermission, isPaletteApiError, isSandboxRuntime, setBaseUrl, updateInstallConfig, uploadToSignedUrl, withPluginProvider };