@proteos/sdk 0.21.0 → 0.22.1

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/src/index.ts CHANGED
@@ -161,6 +161,23 @@ export {
161
161
  } from './auth/index.js'
162
162
  // Main client
163
163
  export { ProteosClient } from './client.js'
164
+ export type {
165
+ ConnectionScope as ConnectorConnectionScope,
166
+ ConnectionStatus as ConnectorConnectionStatus,
167
+ ConnectionTokenResponse as ConnectorConnectionTokenResponse,
168
+ Connector,
169
+ ConnectorConnection,
170
+ ConnectorMethod,
171
+ CreateConnectorConnectionRequest,
172
+ CredentialKind as ConnectorCredentialKind,
173
+ InstallConnectorConnectionResponse,
174
+ ListConnectorConnectionsQuery,
175
+ ListConnectorsQuery,
176
+ UpdateConnectorConnectionRequest,
177
+ WriteCredentialsRequest,
178
+ } from './connector/index.js'
179
+ // Connector client (connector-service)
180
+ export { ConnectorClient } from './connector/index.js'
164
181
  // Conversation types (conversation-service: connections, conversations, messages, listeners)
165
182
  export type {
166
183
  AgentListener,
@@ -190,17 +207,17 @@ export type {
190
207
  InstallConnectionResponse,
191
208
  ListAgentListenersQuery,
192
209
  ListConnectionsQuery,
193
- ListGlossaryTermsQuery,
194
210
  ListConversationsQuery,
211
+ ListGlossaryTermsQuery,
195
212
  ListMessagesQuery,
196
213
  ListParticipantsQuery,
197
214
  // Conversation-local page envelope ({meta, data}) — distinct from the
198
215
  // PageIterator-based ListResult used by the other modules.
199
216
  ListResponse,
200
217
  ListRoomsQuery,
218
+ MeetingService,
201
219
  Message,
202
220
  MessageDirection,
203
- MeetingService,
204
221
  MessagePreview,
205
222
  MessageRecipient,
206
223
  MessageService,
@@ -228,23 +245,6 @@ export type {
228
245
  } from './conversation/index.js'
229
246
  // Conversation client (conversation-service)
230
247
  export { ConversationClient } from './conversation/index.js'
231
- // Connector client (connector-service)
232
- export { ConnectorClient } from './connector/index.js'
233
- export type {
234
- Connector,
235
- ConnectorConnection,
236
- ConnectorMethod,
237
- ConnectionScope as ConnectorConnectionScope,
238
- ConnectionStatus as ConnectorConnectionStatus,
239
- ConnectionTokenResponse as ConnectorConnectionTokenResponse,
240
- CreateConnectorConnectionRequest,
241
- CredentialKind as ConnectorCredentialKind,
242
- InstallConnectorConnectionResponse,
243
- ListConnectorConnectionsQuery,
244
- ListConnectorsQuery,
245
- UpdateConnectorConnectionRequest,
246
- WriteCredentialsRequest,
247
- } from './connector/index.js'
248
248
  export type {
249
249
  BatchTransactionError,
250
250
  BatchTransactionStatus,
@@ -390,6 +390,7 @@ export type {
390
390
  ComponentService,
391
391
  CreateAppRequest,
392
392
  CreateComponentRequest,
393
+ CreateDesignReferenceRequest,
393
394
  CreateEntityRequest,
394
395
  CreateListRequest,
395
396
  CreateListViewRequest,
@@ -401,6 +402,10 @@ export type {
401
402
  CurrencySymbolSide,
402
403
  CurrencyValue,
403
404
  DeployModuleRequest,
405
+ // DesignReference types
406
+ DesignReference,
407
+ DesignReferenceContent,
408
+ DesignReferenceService,
404
409
  // Entity types
405
410
  Entity,
406
411
  EntityService,
@@ -413,6 +418,7 @@ export type {
413
418
  List,
414
419
  ListAppsOptions,
415
420
  ListComponentsOptions,
421
+ ListDesignReferencesOptions,
416
422
  ListEntitiesOptions,
417
423
  ListListsOptions,
418
424
  ListListViewsOptions,
@@ -439,17 +445,18 @@ export type {
439
445
  // Page types
440
446
  Page,
441
447
  PageAction,
448
+ PageLayout,
449
+ PageService,
442
450
  PageType,
443
451
  PublicPageComponent,
444
452
  PublicPageResponse,
445
- PageLayout,
446
- PageService,
447
453
  // Relation attribute meta
448
454
  RelationAttributeMeta,
449
455
  SortConfig,
450
456
  SortDirection,
451
457
  UpdateAppRequest,
452
458
  UpdateComponentRequest,
459
+ UpdateDesignReferenceRequest,
453
460
  UpdateEntityRequest,
454
461
  UpdateListRequest,
455
462
  UpdateListViewRequest,
@@ -473,6 +480,7 @@ export {
473
480
  currencyLabel,
474
481
  currencySymbol,
475
482
  currencySymbolSide,
483
+ DesignReferenceSchema,
476
484
  EntitySchema,
477
485
  EntityWithSchemaSchema,
478
486
  FilterElementSchema,
@@ -0,0 +1,127 @@
1
+ import type { ProteosClient } from '../client.js'
2
+ import { PageIterator } from '../iterator.js'
3
+ import type { ListResult } from '../types/common.js'
4
+ import type {
5
+ CreateDesignReferenceRequest,
6
+ DesignReference,
7
+ DesignReferenceContent,
8
+ ListDesignReferencesOptions,
9
+ UpdateDesignReferenceRequest,
10
+ } from './types.js'
11
+
12
+ const DESIGN_REFERENCES_BASE_PATH = '/meta/v1/design-references'
13
+
14
+ /**
15
+ * Service for managing an org's stored DESIGN.md documents (design references).
16
+ *
17
+ * The markdown body is split from the metadata methods: list/get never carry
18
+ * `content` — read it with {@link getContent} and write it with
19
+ * {@link setContent} (create may seed it in one shot).
20
+ */
21
+ export interface DesignReferenceService {
22
+ /** Lists design references (metadata only — no `content`). */
23
+ list(
24
+ options?: ListDesignReferencesOptions,
25
+ ): PageIterator<DesignReference, ListDesignReferencesOptions>
26
+
27
+ /** Fetches a single page of design references (metadata only). */
28
+ listPage(options?: ListDesignReferencesOptions): Promise<ListResult<DesignReference>>
29
+
30
+ /** Gets a single design reference by id (metadata only — no `content`). */
31
+ get(id: string): Promise<DesignReference>
32
+
33
+ /** Resolves a design reference by its per-org slug (metadata only). */
34
+ getBySlug(slug: string): Promise<DesignReference>
35
+
36
+ /** Creates a design reference; `content` optionally seeds the body. */
37
+ create(request: CreateDesignReferenceRequest): Promise<DesignReference>
38
+
39
+ /** Creates or (by slug) replaces a design reference, including its body. */
40
+ upsert(request: CreateDesignReferenceRequest): Promise<DesignReference>
41
+
42
+ /** Updates a design reference's metadata (name/description/slug). */
43
+ update(id: string, request: UpdateDesignReferenceRequest): Promise<DesignReference>
44
+
45
+ /** Deletes a design reference. */
46
+ delete(id: string): Promise<void>
47
+
48
+ /** Reads the markdown body for a design reference. */
49
+ getContent(id: string): Promise<string>
50
+
51
+ /** Overwrites the markdown body for a design reference (metadata untouched). */
52
+ setContent(id: string, content: string): Promise<void>
53
+ }
54
+
55
+ /**
56
+ * Implementation of DesignReferenceService.
57
+ */
58
+ export class DesignReferenceServiceImpl implements DesignReferenceService {
59
+ constructor(private readonly client: ProteosClient) {}
60
+
61
+ list(
62
+ options: ListDesignReferencesOptions = {},
63
+ ): PageIterator<DesignReference, ListDesignReferencesOptions> {
64
+ return new PageIterator((opts) => this.listPage(opts), options)
65
+ }
66
+
67
+ async listPage(options: ListDesignReferencesOptions = {}): Promise<ListResult<DesignReference>> {
68
+ return this.client.requestWithQuery<ListResult<DesignReference>>(
69
+ 'GET',
70
+ DESIGN_REFERENCES_BASE_PATH,
71
+ options,
72
+ )
73
+ }
74
+
75
+ async get(id: string): Promise<DesignReference> {
76
+ return this.client.request<DesignReference>('GET', `${DESIGN_REFERENCES_BASE_PATH}/${id}`)
77
+ }
78
+
79
+ async getBySlug(slug: string): Promise<DesignReference> {
80
+ const page = await this.listPage({ slug })
81
+ const match = page.data[0]
82
+ if (!match) {
83
+ throw new Error(`design reference with slug "${slug}" not found`)
84
+ }
85
+ return match
86
+ }
87
+
88
+ async create(request: CreateDesignReferenceRequest): Promise<DesignReference> {
89
+ return this.client.request<DesignReference>('POST', DESIGN_REFERENCES_BASE_PATH, request)
90
+ }
91
+
92
+ async upsert(request: CreateDesignReferenceRequest): Promise<DesignReference> {
93
+ return this.client.request<DesignReference>(
94
+ 'POST',
95
+ `${DESIGN_REFERENCES_BASE_PATH}/upsert`,
96
+ request,
97
+ )
98
+ }
99
+
100
+ async update(id: string, request: UpdateDesignReferenceRequest): Promise<DesignReference> {
101
+ return this.client.request<DesignReference>(
102
+ 'PATCH',
103
+ `${DESIGN_REFERENCES_BASE_PATH}/${id}`,
104
+ request,
105
+ )
106
+ }
107
+
108
+ async delete(id: string): Promise<void> {
109
+ await this.client.request<void>('DELETE', `${DESIGN_REFERENCES_BASE_PATH}/${id}`)
110
+ }
111
+
112
+ async getContent(id: string): Promise<string> {
113
+ const response = await this.client.request<DesignReferenceContent>(
114
+ 'GET',
115
+ `${DESIGN_REFERENCES_BASE_PATH}/${id}/content`,
116
+ )
117
+ return response.content
118
+ }
119
+
120
+ async setContent(id: string, content: string): Promise<void> {
121
+ await this.client.request<DesignReferenceContent>(
122
+ 'PUT',
123
+ `${DESIGN_REFERENCES_BASE_PATH}/${id}/content`,
124
+ { content },
125
+ )
126
+ }
127
+ }
@@ -82,6 +82,13 @@ export interface EntityService {
82
82
  */
83
83
  getWithSchema(slug: string): Promise<EntityWithSchema>
84
84
 
85
+ /**
86
+ * Gets a public-access (read) entity (with schema) through the UNAUTHENTICATED
87
+ * public endpoint — no Authorization header. A non-public or missing
88
+ * entity 404s identically.
89
+ */
90
+ getPublic(orgId: string, slug: string): Promise<EntityWithSchema>
91
+
85
92
  /**
86
93
  * Creates a new entity.
87
94
  *
@@ -175,6 +182,16 @@ export class EntityServiceImpl implements EntityService {
175
182
  })
176
183
  }
177
184
 
185
+ async getPublic(orgId: string, slug: string): Promise<EntityWithSchema> {
186
+ return this.client.requestWithQuery<EntityWithSchema>(
187
+ 'GET',
188
+ `/meta/v1/public/orgs/${encodeURIComponent(orgId)}/entities/${encodeURIComponent(slug)}`,
189
+ { with_schema: true },
190
+ undefined,
191
+ { skipAuth: true },
192
+ )
193
+ }
194
+
178
195
  async create(request: CreateEntityRequest): Promise<Entity> {
179
196
  return this.client.request<Entity>('POST', ENTITIES_BASE_PATH, request)
180
197
  }
package/src/meta/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ProteosClient } from '../client.js'
2
2
  import { type AppService, AppServiceImpl } from './apps.js'
3
3
  import { type ComponentService, ComponentServiceImpl } from './components.js'
4
+ import { type DesignReferenceService, DesignReferenceServiceImpl } from './design-references.js'
4
5
  import { type EntityService, EntityServiceImpl } from './entities.js'
5
6
  import { type ListViewService, ListViewServiceImpl } from './list-views.js'
6
7
  import { type ListService, ListServiceImpl } from './lists.js'
@@ -78,6 +79,11 @@ export class MetaClient {
78
79
  */
79
80
  readonly apps: AppService
80
81
 
82
+ /**
83
+ * Service for managing design references (stored DESIGN.md documents).
84
+ */
85
+ readonly designReferences: DesignReferenceService
86
+
81
87
  /**
82
88
  * Creates a new MetaClient instance.
83
89
  *
@@ -93,12 +99,14 @@ export class MetaClient {
93
99
  this.pages = new PageServiceImpl(client)
94
100
  this.menuConfigurations = new MenuConfigurationServiceImpl(client)
95
101
  this.apps = new AppServiceImpl(client)
102
+ this.designReferences = new DesignReferenceServiceImpl(client)
96
103
  }
97
104
  }
98
105
 
99
106
  export type { AppService } from './apps.js'
100
107
  export type { ComponentService } from './components.js'
101
108
  export * from './currency/index.js'
109
+ export type { DesignReferenceService } from './design-references.js'
102
110
  // Re-export service interfaces
103
111
  export type { EntityService } from './entities.js'
104
112
  // Re-export the layout module (PageLayout types + Zod schemas + control registry)
@@ -122,6 +130,7 @@ export type {
122
130
  Component,
123
131
  CreateAppRequest,
124
132
  CreateComponentRequest,
133
+ CreateDesignReferenceRequest,
125
134
  CreateEntityRequest,
126
135
  CreateListRequest,
127
136
  CreateListViewRequest,
@@ -134,6 +143,9 @@ export type {
134
143
  DatetimeAttributeMeta,
135
144
  DatetimeFormat,
136
145
  DeployModuleRequest,
146
+ // DesignReference types
147
+ DesignReference,
148
+ DesignReferenceContent,
137
149
  // Entity types
138
150
  Entity,
139
151
  EntityWithSchema,
@@ -147,6 +159,7 @@ export type {
147
159
  List,
148
160
  ListAppsOptions,
149
161
  ListComponentsOptions,
162
+ ListDesignReferencesOptions,
150
163
  ListEntitiesOptions,
151
164
  ListListsOptions,
152
165
  ListListViewsOptions,
@@ -182,6 +195,7 @@ export type {
182
195
  StringFormat,
183
196
  UpdateAppRequest,
184
197
  UpdateComponentRequest,
198
+ UpdateDesignReferenceRequest,
185
199
  UpdateEntityRequest,
186
200
  UpdateListRequest,
187
201
  UpdateListViewRequest,
@@ -201,6 +215,7 @@ export {
201
215
  ColumnSchema,
202
216
  ComponentSchema,
203
217
  CurrencyAttributeMetaSchema,
218
+ DesignReferenceSchema,
204
219
  EntitySchema,
205
220
  EntityWithSchemaSchema,
206
221
  FileAttributeMetaSchema,
@@ -33,9 +33,13 @@ export {
33
33
  type TextVariant,
34
34
  } from './elements.js'
35
35
  export {
36
+ PAGE_BACKGROUND_TOKENS,
37
+ type PageBackgroundToken,
36
38
  type PageLayout,
37
39
  PageLayoutSchema,
38
40
  type PageLayoutSidePanel,
39
41
  PageLayoutSidePanelSchema,
42
+ type PageStyle,
43
+ PageStyleSchema,
40
44
  } from './page-layout.js'
41
45
  export { type SizeValue, SizeValueSchema } from './size-value.js'
@@ -18,6 +18,58 @@ export const PageLayoutSidePanelSchema = z.object({
18
18
  content: LayoutElementSchema,
19
19
  })
20
20
 
21
+ /**
22
+ * Design-token keys a page background may name instead of a raw CSS color. The
23
+ * web resolver maps each to `var(--color-<key>)`. Keep in sync with
24
+ * `pageBackgroundTokens` in the metadata-service layout validator.
25
+ */
26
+ export const PAGE_BACKGROUND_TOKENS = [
27
+ 'bg',
28
+ 'bg-2',
29
+ 'bg-3',
30
+ 'ink',
31
+ 'ink-2',
32
+ 'ink-3',
33
+ 'ink-4',
34
+ 'rule',
35
+ 'rule-2',
36
+ 'accent',
37
+ 'accent-2',
38
+ 'accent-ink',
39
+ 'success',
40
+ 'warning',
41
+ 'danger',
42
+ 'info',
43
+ ] as const
44
+
45
+ export type PageBackgroundToken = (typeof PAGE_BACKGROUND_TOKENS)[number]
46
+
47
+ /**
48
+ * Per-page presentation of a standalone page shell: background color plus the
49
+ * content container's max-width and side / top padding. Every field is
50
+ * optional; an omitted field falls back to the renderer default (the historical
51
+ * bg / 1200px / 24px-32px look). `max_width: "fill"` (or `"auto"`) with zero
52
+ * padding lets a component fill the page edge-to-edge.
53
+ *
54
+ * Honored only on `public` and `kiosk` pages in v1 (enforced server-side).
55
+ */
56
+ export interface PageStyle {
57
+ /** Design-token key (see PAGE_BACKGROUND_TOKENS) or a raw CSS color. */
58
+ background?: string
59
+ /** Content max-width; `"fill"` / `"auto"` removes the cap. */
60
+ max_width?: SizeValue
61
+ /** Horizontal / vertical padding of the content container (Tailwind px/py). */
62
+ padding_x?: SizeValue
63
+ padding_y?: SizeValue
64
+ }
65
+
66
+ export const PageStyleSchema = z.object({
67
+ background: z.string().optional(),
68
+ max_width: SizeValueSchema.optional(),
69
+ padding_x: SizeValueSchema.optional(),
70
+ padding_y: SizeValueSchema.optional(),
71
+ })
72
+
21
73
  /**
22
74
  * Top-level page layout. Replaces the legacy `mainContent` / `side_panel`
23
75
  * arrays of `PageSection`s with a single typed element tree.
@@ -26,10 +78,12 @@ export interface PageLayout {
26
78
  version: 1
27
79
  main: LayoutElement
28
80
  side_panel?: PageLayoutSidePanel
81
+ style?: PageStyle
29
82
  }
30
83
 
31
84
  export const PageLayoutSchema = z.object({
32
85
  version: z.literal(1),
33
86
  main: LayoutElementSchema,
34
87
  side_panel: PageLayoutSidePanelSchema.optional(),
88
+ style: PageStyleSchema.optional(),
35
89
  })
package/src/meta/types.ts CHANGED
@@ -425,6 +425,15 @@ export function parseFileMeta(attr: Attribute): FileAttributeMeta | null {
425
425
  return parsed.success ? parsed.data : {}
426
426
  }
427
427
 
428
+ /**
429
+ * A single operation a resource may be publicly exposed for. Independent set
430
+ * (not a level): a resource can be public for `write` without `read`. Only
431
+ * `read` is honored on the platform today; `write`/`delete` are reserved.
432
+ */
433
+ export type PublicAccessOperation = 'read' | 'write' | 'delete'
434
+
435
+ export const PublicAccessOperationSchema = z.enum(['read', 'write', 'delete'])
436
+
428
437
  /**
429
438
  * Entity definition.
430
439
  * Note: Entity uses `slug` as its primary identifier, not `id`.
@@ -434,6 +443,14 @@ export interface Entity extends AuditFields {
434
443
  name: string
435
444
  description: string
436
445
  is_remote: boolean
446
+ /**
447
+ * Operations ALL records of the entity are exposed for on the
448
+ * unauthenticated public surface. Only `["read"]` is honored today (records
449
+ * become world-readable; the entity definition is implicitly readable so
450
+ * they can be interpreted); `write`/`delete` are reserved. Empty = private
451
+ * (default).
452
+ */
453
+ public_record_access: PublicAccessOperation[]
437
454
  module_slug: string
438
455
  /**
439
456
  * Liquid template that renders a human-readable title for an instance
@@ -453,6 +470,9 @@ export const EntitySchema = AuditFieldsSchema.extend({
453
470
  name: z.string(),
454
471
  description: z.string(),
455
472
  is_remote: z.boolean(),
473
+ // Default keeps older API responses (pre-`public_record_access` rollout)
474
+ // parsing cleanly.
475
+ public_record_access: z.array(PublicAccessOperationSchema).default([]),
456
476
  module_slug: z.string(),
457
477
  // Default keeps older API responses (pre-`title_template` rollout) parsing
458
478
  // cleanly — the field is non-optional in the TS surface but tolerant on
@@ -489,6 +509,12 @@ export interface CreateEntityRequest {
489
509
  slug: string
490
510
  name: string
491
511
  is_remote: boolean
512
+ /**
513
+ * Operations to expose all records of the entity for, unauthenticated (only
514
+ * `["read"]` accepted today). Full-replacement on upsert: an upsert without
515
+ * the field resets it to private.
516
+ */
517
+ public_record_access?: PublicAccessOperation[]
492
518
  module_slug: string
493
519
  description: string
494
520
  title_template?: string
@@ -501,6 +527,7 @@ export interface CreateEntityRequest {
501
527
  export interface UpdateEntityRequest {
502
528
  name?: string
503
529
  is_remote?: boolean
530
+ public_record_access?: PublicAccessOperation[]
504
531
  module_slug?: string
505
532
  description?: string
506
533
  title_template?: string
@@ -1152,3 +1179,70 @@ export interface UpdateAppRequest {
1152
1179
  description?: string
1153
1180
  icon_slug?: string
1154
1181
  }
1182
+
1183
+ // ============================================================================
1184
+ // DesignReference Types
1185
+ // ============================================================================
1186
+
1187
+ /**
1188
+ * A stored DESIGN.md document — a named design reference an org authors and that
1189
+ * design agents read as the source of truth for a surface. `name` + `description`
1190
+ * are the selector ("which reference, and when to use it").
1191
+ *
1192
+ * `content` (the markdown body) is NOT returned by list/get — fetch it via
1193
+ * {@link DesignReferenceService.getContent} and write it via `setContent`.
1194
+ */
1195
+ export interface DesignReference extends AuditFields {
1196
+ id: string
1197
+ org_id: string
1198
+ slug: string
1199
+ name: string
1200
+ description: string
1201
+ /** The DESIGN.md body. Only present on the dedicated content endpoint; undefined on list/get. */
1202
+ content?: string
1203
+ }
1204
+
1205
+ export const DesignReferenceSchema = AuditFieldsSchema.extend({
1206
+ id: z.string(),
1207
+ slug: z.string(),
1208
+ name: z.string(),
1209
+ description: z.string(),
1210
+ content: z.string().optional(),
1211
+ })
1212
+
1213
+ /**
1214
+ * Options for listing design references.
1215
+ */
1216
+ export interface ListDesignReferencesOptions extends MetaListOptions {
1217
+ id?: string
1218
+ slug?: string
1219
+ name?: string
1220
+ description?: string
1221
+ }
1222
+
1223
+ /**
1224
+ * Request to create a design reference. `content` optionally seeds the body.
1225
+ */
1226
+ export interface CreateDesignReferenceRequest {
1227
+ slug: string
1228
+ name: string
1229
+ description?: string
1230
+ content?: string
1231
+ }
1232
+
1233
+ /**
1234
+ * Request to update a design reference's metadata. Content is edited via the
1235
+ * dedicated content endpoint, not here.
1236
+ */
1237
+ export interface UpdateDesignReferenceRequest {
1238
+ slug?: string
1239
+ name?: string
1240
+ description?: string
1241
+ }
1242
+
1243
+ /**
1244
+ * The markdown body, from GET/PUT /design-references/:id/content.
1245
+ */
1246
+ export interface DesignReferenceContent {
1247
+ content: string
1248
+ }
@@ -70,6 +70,19 @@ export interface FileService {
70
70
  * {@link FileService.createDownloadUrl} for browser click-to-download.
71
71
  */
72
72
  download(id: string): Promise<Blob>
73
+
74
+ /**
75
+ * Downloads the current version of a public-read file through the
76
+ * UNAUTHENTICATED public endpoint (no Authorization header). A non-public
77
+ * or missing file 404s identically.
78
+ */
79
+ downloadPublic(orgId: string, id: string): Promise<Blob>
80
+
81
+ /**
82
+ * Builds the unauthenticated public download URL for a public-read
83
+ * file — usable directly as an <img src> / <a href> on public pages.
84
+ */
85
+ publicDownloadUrl(orgId: string, id: string): string
73
86
  }
74
87
 
75
88
  /**
@@ -180,4 +193,22 @@ export class FileServiceImpl implements FileService {
180
193
  const { response } = await this.client.requestRaw('GET', `${FILES_BASE_PATH}/${id}/download`)
181
194
  return await response.blob()
182
195
  }
196
+
197
+ async downloadPublic(orgId: string, id: string): Promise<Blob> {
198
+ const { response } = await this.client.requestRaw(
199
+ 'GET',
200
+ this.publicDownloadPath(orgId, id),
201
+ undefined,
202
+ { skipAuth: true },
203
+ )
204
+ return await response.blob()
205
+ }
206
+
207
+ publicDownloadUrl(orgId: string, id: string): string {
208
+ return `${this.client.baseUrl}${this.publicDownloadPath(orgId, id)}`
209
+ }
210
+
211
+ private publicDownloadPath(orgId: string, id: string): string {
212
+ return `/storage/v1/public/orgs/${encodeURIComponent(orgId)}/files/${encodeURIComponent(id)}/download`
213
+ }
183
214
  }
@@ -1,3 +1,5 @@
1
+ import type { PublicAccessOperation } from '../meta/types.js'
2
+
1
3
  /**
2
4
  * A version of a stored file. Each file has one or more versions; the file's
3
5
  * `current_version` points at the latest. Size is carried here, not on the
@@ -27,6 +29,12 @@ export interface StorageFile {
27
29
  is_deleted: boolean
28
30
  is_persisted: boolean
29
31
  is_locked: boolean
32
+ /**
33
+ * Operations the file is exposed for on the unauthenticated public surface.
34
+ * Only `["read"]` is honored (download via the public route). Empty =
35
+ * private (default).
36
+ */
37
+ public_access: PublicAccessOperation[]
30
38
  created_at: string
31
39
  updated_at: string
32
40
  }
@@ -38,6 +46,8 @@ export interface StorageFile {
38
46
  export interface CreateFileMetadata {
39
47
  name: string
40
48
  content_type?: string
49
+ /** See {@link StorageFile.public_access}. Only `["read"]` accepted today. */
50
+ public_access?: PublicAccessOperation[]
41
51
  }
42
52
 
43
53
  /**