@agent-foundry/studio 1.0.1 → 1.0.2

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.
@@ -1,7 +1,38 @@
1
1
  /**
2
2
  * Deployments Repository
3
3
  *
4
- * CRUD operations for studio_deployments table.
4
+ * Provides access to studio_deployments table via Supabase client.
5
+ *
6
+ * ## Important: Hybrid Access Pattern
7
+ *
8
+ * Due to RLS (Row Level Security) restrictions, this repository should
9
+ * primarily be used for **read operations only**.
10
+ *
11
+ * **For write operations, use the BFF client or DirectUploader:**
12
+ *
13
+ * ```typescript
14
+ * import { DirectUploader } from '@agent-foundry/studio/oss';
15
+ *
16
+ * // DirectUploader handles the complete deployment workflow via BFF
17
+ * const uploader = new DirectUploader({
18
+ * bffBaseUrl: 'http://localhost:11001',
19
+ * authToken: 'your-jwt-token',
20
+ * });
21
+ *
22
+ * const result = await uploader.upload({
23
+ * projectId: 'project-uuid',
24
+ * files: distFiles,
25
+ * });
26
+ * ```
27
+ *
28
+ * Or use the BFF client directly:
29
+ *
30
+ * ```typescript
31
+ * import { createBFFClient } from '@agent-foundry/studio/bff';
32
+ *
33
+ * const bff = createBFFClient({ ... });
34
+ * const deployment = await bff.deployments.start({ projectId: '...' });
35
+ * ```
5
36
  */
6
37
 
7
38
  import { SupabaseClient } from '@supabase/supabase-js';
@@ -81,6 +112,12 @@ export class DeploymentsRepository {
81
112
 
82
113
  /**
83
114
  * Create a new deployment
115
+ *
116
+ * @deprecated Use `DirectUploader.upload()` or `createBFFClient().deployments.start()` instead.
117
+ *
118
+ * This method may fail with RLS errors. The recommended workflow is:
119
+ * 1. Use DirectUploader which handles the complete deployment lifecycle
120
+ * 2. Or use BFF client's deployments.start() to get STS credentials
84
121
  */
85
122
  async create(input: CreateDeploymentInput): Promise<Deployment> {
86
123
  const { data: { user } } = await this.supabase.auth.getUser();
@@ -170,6 +207,10 @@ export class DeploymentsRepository {
170
207
 
171
208
  /**
172
209
  * Update a deployment
210
+ *
211
+ * @deprecated Use `createBFFClient().deployments.updateStatus()` instead.
212
+ *
213
+ * This method may fail with RLS errors. Use BFF client for write operations.
173
214
  */
174
215
  async update(id: string, input: UpdateDeploymentInput): Promise<Deployment> {
175
216
  const updateData: Record<string, unknown> = {};
@@ -223,6 +264,8 @@ export class DeploymentsRepository {
223
264
 
224
265
  /**
225
266
  * Mark deployment as building
267
+ *
268
+ * @deprecated Use `createBFFClient().deployments.updateStatus()` instead.
226
269
  */
227
270
  async markBuilding(id: string): Promise<Deployment> {
228
271
  return this.update(id, { status: 'building' });
@@ -230,6 +273,8 @@ export class DeploymentsRepository {
230
273
 
231
274
  /**
232
275
  * Mark deployment as uploading
276
+ *
277
+ * @deprecated Use `createBFFClient().deployments.updateStatus()` instead.
233
278
  */
234
279
  async markUploading(id: string): Promise<Deployment> {
235
280
  return this.update(id, { status: 'uploading' });
@@ -237,6 +282,8 @@ export class DeploymentsRepository {
237
282
 
238
283
  /**
239
284
  * Mark deployment as published
285
+ *
286
+ * @deprecated Use `createBFFClient().deployments.complete()` instead.
240
287
  */
241
288
  async markPublished(
242
289
  id: string,
@@ -254,6 +301,8 @@ export class DeploymentsRepository {
254
301
 
255
302
  /**
256
303
  * Mark deployment as failed
304
+ *
305
+ * @deprecated Use `createBFFClient().deployments.fail()` instead.
257
306
  */
258
307
  async markFailed(id: string, errorMessage: string, buildLog?: string): Promise<Deployment> {
259
308
  return this.update(id, {
@@ -288,6 +337,9 @@ export class DeploymentsRepository {
288
337
 
289
338
  /**
290
339
  * Delete a deployment
340
+ *
341
+ * @deprecated Deployment deletion should be handled server-side.
342
+ * This method may fail with RLS errors.
291
343
  */
292
344
  async delete(id: string): Promise<void> {
293
345
  const { error } = await this.supabase
@@ -302,6 +354,9 @@ export class DeploymentsRepository {
302
354
 
303
355
  /**
304
356
  * Append to build log
357
+ *
358
+ * @deprecated Use `createBFFClient().deployments.updateStatus()` with buildLog field.
359
+ * This method may fail with RLS errors.
305
360
  */
306
361
  async appendBuildLog(id: string, logLine: string): Promise<void> {
307
362
  const existing = await this.getById(id);
@@ -318,6 +373,9 @@ export class DeploymentsRepository {
318
373
 
319
374
  /**
320
375
  * Link deployment to an artifact (called after publishing to Feed)
376
+ *
377
+ * @deprecated This is handled automatically by BFF's publish workflow.
378
+ * Use `createBFFClient().projects.publish()` instead.
321
379
  */
322
380
  async linkToArtifact(id: string, artifactId: string): Promise<Deployment> {
323
381
  const { data, error } = await this.supabase
package/src/db/index.ts CHANGED
@@ -1,5 +1,22 @@
1
1
  /**
2
2
  * Database module - Supabase client for Studio
3
+ *
4
+ * ## Important: Read-Only Usage Recommended
5
+ *
6
+ * Due to RLS (Row Level Security), this module should primarily be used
7
+ * for **read operations only**. For write operations, use the BFF client:
8
+ *
9
+ * ```typescript
10
+ * // Read operations - use this module
11
+ * import { createStudioClient } from '@agent-foundry/studio/db';
12
+ * const db = createStudioClient({ supabaseUrl: '...', supabaseKey: '...' });
13
+ * const projects = await db.projects.list();
14
+ *
15
+ * // Write operations - use BFF client
16
+ * import { createBFFClient } from '@agent-foundry/studio/bff';
17
+ * const bff = createBFFClient({ baseUrl: '...', authToken: '...' });
18
+ * const project = await bff.projects.create({ ... });
19
+ * ```
3
20
  */
4
21
 
5
22
  export { createStudioClient, type StudioClientConfig } from './client';
@@ -1,7 +1,29 @@
1
1
  /**
2
2
  * Projects Repository
3
3
  *
4
- * CRUD operations for studio_projects table.
4
+ * Provides access to studio_projects table via Supabase client.
5
+ *
6
+ * ## Important: Hybrid Access Pattern
7
+ *
8
+ * Due to RLS (Row Level Security) restrictions, this repository should
9
+ * primarily be used for **read operations only**.
10
+ *
11
+ * **For write operations (create, update, delete, fork), use the BFF client:**
12
+ *
13
+ * ```typescript
14
+ * import { createBFFClient } from '@agent-foundry/studio/bff';
15
+ *
16
+ * const bff = createBFFClient({
17
+ * baseUrl: 'http://localhost:11001',
18
+ * authToken: 'your-jwt-token',
19
+ * });
20
+ *
21
+ * // Create project via BFF (recommended)
22
+ * const project = await bff.projects.create({ ... });
23
+ * ```
24
+ *
25
+ * The BFF uses service_role credentials which bypass RLS, ensuring
26
+ * consistent and secure write operations.
5
27
  */
6
28
 
7
29
  import { SupabaseClient } from '@supabase/supabase-js';
@@ -61,6 +83,11 @@ export class ProjectsRepository {
61
83
 
62
84
  /**
63
85
  * Create a new project
86
+ *
87
+ * @deprecated Use BFF client instead: `createBFFClient().projects.create()`
88
+ *
89
+ * This method may fail with RLS errors when using anon key.
90
+ * The BFF client uses service_role credentials which bypass RLS.
64
91
  */
65
92
  async create(input: CreateProjectInput): Promise<StudioProject> {
66
93
  const { data: { user } } = await this.supabase.auth.getUser();
@@ -171,6 +198,11 @@ export class ProjectsRepository {
171
198
 
172
199
  /**
173
200
  * Update a project
201
+ *
202
+ * @deprecated Use BFF client instead: `createBFFClient().projects.update()`
203
+ *
204
+ * This method may fail with RLS errors when using anon key.
205
+ * The BFF client uses service_role credentials which bypass RLS.
174
206
  */
175
207
  async update(id: string, input: UpdateProjectInput): Promise<StudioProject> {
176
208
  const updateData: Record<string, unknown> = {};
@@ -206,6 +238,11 @@ export class ProjectsRepository {
206
238
 
207
239
  /**
208
240
  * Delete a project
241
+ *
242
+ * @deprecated Use BFF client instead: `createBFFClient().projects.delete()`
243
+ *
244
+ * This method may fail with RLS errors when using anon key.
245
+ * The BFF client uses service_role credentials which bypass RLS.
209
246
  */
210
247
  async delete(id: string): Promise<void> {
211
248
  const { error } = await this.supabase
@@ -220,6 +257,11 @@ export class ProjectsRepository {
220
257
 
221
258
  /**
222
259
  * Fork a project (create a copy)
260
+ *
261
+ * @deprecated Use BFF client instead: `createBFFClient().projects.fork()`
262
+ *
263
+ * This method may fail with RLS errors when using anon key.
264
+ * The BFF client uses service_role credentials which bypass RLS.
223
265
  */
224
266
  async fork(id: string, newSlug: string, newRootPath: string): Promise<StudioProject> {
225
267
  const original = await this.getById(id);
@@ -248,6 +290,9 @@ export class ProjectsRepository {
248
290
 
249
291
  /**
250
292
  * Link project to a registered app (called after publishing to Feed)
293
+ *
294
+ * @deprecated This is handled automatically by BFF's publish workflow.
295
+ * Use `createBFFClient().projects.publish()` instead.
251
296
  */
252
297
  async linkToApp(id: string, appId: string): Promise<StudioProject> {
253
298
  const { data, error } = await this.supabase
package/src/index.ts CHANGED
@@ -2,7 +2,18 @@
2
2
  * @agent-foundry/studio
3
3
  *
4
4
  * Full SDK for Agent Foundry Build Studio.
5
- * Provides types, Alibaba Cloud OSS upload utilities, and Supabase database client.
5
+ * Provides types, Alibaba Cloud OSS upload utilities, BFF API client, and Supabase database client.
6
+ *
7
+ * ## Recommended Usage Pattern (Hybrid Approach)
8
+ *
9
+ * - **Write operations**: Use BFF client (`@agent-foundry/studio/bff`)
10
+ * - **Read operations**: Use Supabase client (`@agent-foundry/studio/db`)
11
+ * - **File uploads**: Use DirectUploader (`@agent-foundry/studio/oss`)
12
+ *
13
+ * This pattern ensures:
14
+ * - Security: Write operations go through BFF with service_role (bypasses RLS)
15
+ * - Performance: Read operations use direct Supabase connection
16
+ * - Consistency: All writes are validated server-side
6
17
  */
7
18
 
8
19
  // Re-export all types
@@ -11,7 +22,12 @@ export * from './types';
11
22
  // Re-export OSS utilities
12
23
  export * from './oss';
13
24
 
14
- // Re-export database client
25
+ // Re-export BFF API client (recommended for write operations)
26
+ // Note: Use '@agent-foundry/studio/bff' for full BFF types
27
+ export { createBFFClient, BFFAPIError } from './bff';
28
+ export type { BFFClient, BFFClientConfig } from './bff';
29
+
30
+ // Re-export database client (recommended for read operations only)
15
31
  export * from './db';
16
32
 
17
33
  // Re-export utilities