@somewhere-cloud/cli 0.38.153 → 0.38.155
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/CHANGELOG.md +11 -0
- package/dist/docs/adopt.md +39 -0
- package/dist/docs/analytics.md +161 -0
- package/dist/docs/api-reference.md +339 -0
- package/dist/docs/api-surface.md +2067 -0
- package/dist/docs/app-mcp.md +162 -0
- package/dist/docs/architecture-patterns.md +334 -0
- package/dist/docs/auth-client.md +531 -0
- package/dist/docs/billing.md +76 -0
- package/dist/docs/browser.md +639 -0
- package/dist/docs/calendar.md +298 -0
- package/dist/docs/changes.md +323 -0
- package/dist/docs/cli.md +407 -0
- package/dist/docs/common-mistakes.md +199 -0
- package/dist/docs/connect-agent.md +72 -0
- package/dist/docs/cors.md +114 -0
- package/dist/docs/cron.md +167 -0
- package/dist/docs/database-engine.md +167 -0
- package/dist/docs/declared-data.md +1656 -0
- package/dist/docs/declared-files.md +475 -0
- package/dist/docs/deploy-intelligence.md +188 -0
- package/dist/docs/deploy.md +733 -0
- package/dist/docs/design-system.md +273 -0
- package/dist/docs/dev-environments.md +496 -0
- package/dist/docs/domain-ownership.md +31 -0
- package/dist/docs/domains.md +370 -0
- package/dist/docs/feedback.md +88 -0
- package/dist/docs/file-tools.md +116 -0
- package/dist/docs/functions.md +489 -0
- package/dist/docs/getting-started.md +238 -0
- package/dist/docs/github.md +95 -0
- package/dist/docs/google-calendar.md +212 -0
- package/dist/docs/groups.md +836 -0
- package/dist/docs/guarantees.md +58 -0
- package/dist/docs/handled-for-you.md +224 -0
- package/dist/docs/inspect.md +171 -0
- package/dist/docs/limits.md +68 -0
- package/dist/docs/live-data.md +197 -0
- package/dist/docs/live.md +92 -0
- package/dist/docs/local-dev.md +30 -0
- package/dist/docs/migration-supabase.md +58 -0
- package/dist/docs/payments.md +1102 -0
- package/dist/docs/portability.md +194 -0
- package/dist/docs/postgres.md +301 -0
- package/dist/docs/pricing-comparison.md +42 -0
- package/dist/docs/pricing.md +39 -0
- package/dist/docs/project-groups.md +107 -0
- package/dist/docs/projects.md +380 -0
- package/dist/docs/recipe-ai-agent.md +112 -0
- package/dist/docs/recipe-ai-features.md +227 -0
- package/dist/docs/recipe-ai-receipts.md +783 -0
- package/dist/docs/recipe-background-jobs.md +369 -0
- package/dist/docs/recipe-booking.md +348 -0
- package/dist/docs/recipe-csv-import.md +390 -0
- package/dist/docs/recipe-ecommerce.md +127 -0
- package/dist/docs/recipe-email.md +282 -0
- package/dist/docs/recipe-escalation.md +133 -0
- package/dist/docs/recipe-file-uploads.md +159 -0
- package/dist/docs/recipe-import-app.md +110 -0
- package/dist/docs/recipe-login.md +457 -0
- package/dist/docs/recipe-multi-chat.md +198 -0
- package/dist/docs/recipe-paid-api.md +161 -0
- package/dist/docs/recipe-pdfs.md +205 -0
- package/dist/docs/recipe-push-notifications.md +107 -0
- package/dist/docs/recipe-seo.md +200 -0
- package/dist/docs/recipe-signed-in-app.md +330 -0
- package/dist/docs/render.md +99 -0
- package/dist/docs/rooms.md +554 -0
- package/dist/docs/sdk.md +287 -0
- package/dist/docs/sdks.md +24 -0
- package/dist/docs/search.md +199 -0
- package/dist/docs/security-model.md +168 -0
- package/dist/docs/setup.md +212 -0
- package/dist/docs/smoke.md +102 -0
- package/dist/docs/speed.md +298 -0
- package/dist/docs/sql-compatibility.md +96 -0
- package/dist/docs/sw.agent.md +248 -0
- package/dist/docs/sw.ai.md +1291 -0
- package/dist/docs/sw.auth.md +1811 -0
- package/dist/docs/sw.billing.md +171 -0
- package/dist/docs/sw.db.md +2128 -0
- package/dist/docs/sw.email.md +661 -0
- package/dist/docs/sw.endpoint.md +187 -0
- package/dist/docs/sw.env.md +303 -0
- package/dist/docs/sw.fetch.md +115 -0
- package/dist/docs/sw.fs.md +424 -0
- package/dist/docs/sw.groups.md +836 -0
- package/dist/docs/sw.image.md +69 -0
- package/dist/docs/sw.jobs.md +520 -0
- package/dist/docs/sw.logs.md +61 -0
- package/dist/docs/sw.mail.md +106 -0
- package/dist/docs/sw.notifications.md +78 -0
- package/dist/docs/sw.push.md +161 -0
- package/dist/docs/sw.rateLimit.md +67 -0
- package/dist/docs/sw.web.md +128 -0
- package/dist/docs/tasks.md +269 -0
- package/dist/docs/test.md +220 -0
- package/dist/docs/tool-reference-account.md +7 -0
- package/dist/docs/tool-reference-ai.md +121 -0
- package/dist/docs/tool-reference-analytics.md +37 -0
- package/dist/docs/tool-reference-api.md +19 -0
- package/dist/docs/tool-reference-artifacts.md +35 -0
- package/dist/docs/tool-reference-auth.md +163 -0
- package/dist/docs/tool-reference-browser.md +114 -0
- package/dist/docs/tool-reference-code.md +26 -0
- package/dist/docs/tool-reference-connect.md +21 -0
- package/dist/docs/tool-reference-cron.md +48 -0
- package/dist/docs/tool-reference-db.md +282 -0
- package/dist/docs/tool-reference-domains.md +107 -0
- package/dist/docs/tool-reference-email.md +55 -0
- package/dist/docs/tool-reference-env.md +19 -0
- package/dist/docs/tool-reference-feedback.md +56 -0
- package/dist/docs/tool-reference-fs.md +265 -0
- package/dist/docs/tool-reference-github.md +57 -0
- package/dist/docs/tool-reference-groups.md +85 -0
- package/dist/docs/tool-reference-help.md +29 -0
- package/dist/docs/tool-reference-jobs.md +39 -0
- package/dist/docs/tool-reference-live.md +48 -0
- package/dist/docs/tool-reference-logs.md +16 -0
- package/dist/docs/tool-reference-payments.md +44 -0
- package/dist/docs/tool-reference-project.md +706 -0
- package/dist/docs/tool-reference-push.md +78 -0
- package/dist/docs/tool-reference-rate-limit.md +18 -0
- package/dist/docs/tool-reference-search.md +68 -0
- package/dist/docs/tool-reference-security.md +42 -0
- package/dist/docs/tool-reference-smoke.md +17 -0
- package/dist/docs/tool-reference-stock-photos.md +20 -0
- package/dist/docs/tool-reference-tasks.md +73 -0
- package/dist/docs/tool-reference-telegram.md +32 -0
- package/dist/docs/tool-reference-usage.md +9 -0
- package/dist/docs/tool-reference-web.md +71 -0
- package/dist/docs/tool-reference-webhooks.md +9 -0
- package/dist/docs/troubleshooting.md +411 -0
- package/dist/docs/typed-functions.md +94 -0
- package/dist/docs/verify-before-deploy.md +67 -0
- package/dist/docs/vs-supabase.md +75 -0
- package/dist/docs/vs-vercel.md +103 -0
- package/dist/lib/bundle.js +303 -221
- package/dist/lib/bundle.js.map +3 -3
- package/dist/types/lib/test-session.d.ts +8 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -2
- package/runtime/DECLARED-DATA-VENDOR.json +5 -5
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/SOURCE-LINT-VENDOR.json +2 -2
- package/runtime/declared-data.cjs +37 -19
- package/runtime/source-lint.cjs +1 -1
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
# Files
|
|
2
|
+
|
|
3
|
+
Declare a file collection in `db/schema.ts`: who may upload, read, replace
|
|
4
|
+
and delete its files. For collection files, the platform checks those rules
|
|
5
|
+
on every request from the generated `somewhere:files` client, so a private
|
|
6
|
+
document stays private without an access check of your own. Server paths with
|
|
7
|
+
project authority, such as `sw.fs.server`, are separate: your function
|
|
8
|
+
authorizes the caller before using them.
|
|
9
|
+
|
|
10
|
+
For built-in Groups, declare a group-scoped row, then make its files follow
|
|
11
|
+
that row with `parent({ table, via })`. Open **Files that follow a group row**
|
|
12
|
+
below for the schema and browser calls, and `sw.groups` for creating groups
|
|
13
|
+
and inviting members. `group()` is a table scope; use `parent()` for its files.
|
|
14
|
+
|
|
15
|
+
## Declare a collection and use it
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// db/schema.ts
|
|
19
|
+
import { files, owner, schema } from 'somewhere/db';
|
|
20
|
+
|
|
21
|
+
export default schema({}, {
|
|
22
|
+
files: {
|
|
23
|
+
documents: files({
|
|
24
|
+
path: '/documents',
|
|
25
|
+
scope: owner(),
|
|
26
|
+
client: { read: true, upload: true, replace: true, delete: true },
|
|
27
|
+
limits: { maxSize: '10MB', types: ['application/pdf', 'text/*', 'image/*'] },
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If your schema already declares tables, keep them in the first argument and
|
|
34
|
+
add `files` beside them.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// src/services/documents.ts
|
|
38
|
+
import { files, type FileMeta } from 'somewhere:files';
|
|
39
|
+
|
|
40
|
+
// owner() limits every call to the signed-in user's own documents.
|
|
41
|
+
export async function uploadDocument(file: File): Promise<FileMeta['id']> {
|
|
42
|
+
const { data, error } = await files.documents.upload(file);
|
|
43
|
+
if (error) throw new Error(error.message);
|
|
44
|
+
return data.id;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function listDocuments(): Promise<FileMeta[]> {
|
|
48
|
+
const { data, error } = await files.documents.list({ limit: 50 });
|
|
49
|
+
if (error) throw new Error(error.message);
|
|
50
|
+
return data.items;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// For <a href> or <img src>: each request is checked against the session.
|
|
54
|
+
export function documentUrl(id: string): string {
|
|
55
|
+
return files.documents.url(id);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// A link anyone can open until it expires.
|
|
59
|
+
export async function shareDocument(id: string): Promise<string> {
|
|
60
|
+
const { data, error } = await files.documents.shareLink(id, { expiresIn: 600 });
|
|
61
|
+
if (error) throw new Error(error.message);
|
|
62
|
+
return data.url;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function deleteDocument(id: string): Promise<void> {
|
|
66
|
+
const { error } = await files.documents.delete(id);
|
|
67
|
+
if (error) throw new Error(error.message);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Run `somewhere typecheck`, then `somewhere deploy`. Sign in with two accounts
|
|
72
|
+
and upload a file from each. Each account lists and opens only its own
|
|
73
|
+
documents.
|
|
74
|
+
|
|
75
|
+
`upload`, `list`, `get`, `shareLink`, `replace` and `delete` resolve to
|
|
76
|
+
`{ data, error }`. A refusal, such as a type outside `limits`, arrives in
|
|
77
|
+
`error` with a `code` and `status`. A transport failure arrives the same way,
|
|
78
|
+
with code `NETWORK_ERROR`. None of them throws for these
|
|
79
|
+
cases. `url(id)` returns the URL string right away. An operation the
|
|
80
|
+
collection doesn't declare isn't on the client, so calling it fails the
|
|
81
|
+
typecheck. The client checks `limits` before sending, and the platform
|
|
82
|
+
enforces them regardless. `'10MB'` and the type list are this example's
|
|
83
|
+
choices. Your plan's per-file ceiling is in `limits`.
|
|
84
|
+
|
|
85
|
+
## Files that follow a group row
|
|
86
|
+
|
|
87
|
+
Create a group with `sw.groups`, then create a `team_documents` row with its
|
|
88
|
+
`group_id`. The parent row must exist before uploading an attachment.
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
// db/schema.ts
|
|
92
|
+
import { files, group, id, parent, schema, table, text } from 'somewhere/db';
|
|
93
|
+
|
|
94
|
+
export default schema({
|
|
95
|
+
team_documents: table({ id: id(), group_id: text(), title: text() }, {
|
|
96
|
+
scope: group({ roles: { update: ['owner', 'admin'], delete: ['owner', 'admin'] } }),
|
|
97
|
+
client: { read: true, create: ['group_id', 'title'], update: ['title'], delete: true },
|
|
98
|
+
}),
|
|
99
|
+
}, {
|
|
100
|
+
files: {
|
|
101
|
+
attachments: files({
|
|
102
|
+
path: '/team-attachments',
|
|
103
|
+
scope: parent({ table: 'team_documents', via: 'documentId' }),
|
|
104
|
+
client: { read: true, upload: true, replace: true, delete: true },
|
|
105
|
+
limits: { maxSize: '10MB', types: ['application/pdf', 'image/*'] },
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
// src/services/team-files.ts
|
|
113
|
+
import { files } from 'somewhere:files';
|
|
114
|
+
|
|
115
|
+
// documentId is the id of the existing team_documents row.
|
|
116
|
+
export function uploadAttachment(documentId: string, file: File) {
|
|
117
|
+
return files.attachments.upload(file, { documentId });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function listAttachments(documentId: string) {
|
|
121
|
+
return files.attachments.list({ documentId, limit: 50 });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function attachmentUrl(fileId: string): string {
|
|
125
|
+
return files.attachments.url(fileId);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function replaceAttachment(fileId: string, file: File) {
|
|
129
|
+
return files.attachments.replace(fileId, file);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function deleteAttachment(fileId: string) {
|
|
133
|
+
return files.attachments.delete(fileId);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Members may download and list these attachments because they may read the
|
|
138
|
+
parent row. Upload, replace and delete require permission to update that row;
|
|
139
|
+
here only owners and admins have it. The collection's `client` must also
|
|
140
|
+
allow the requested file operation. `via` names the browser option, so upload
|
|
141
|
+
and list require `documentId`; get, download, replace and delete use the file's
|
|
142
|
+
stored parent. A text-keyed parent takes a string instead of a number.
|
|
143
|
+
|
|
144
|
+
Every request checks the current parent row and its access rules. Removing
|
|
145
|
+
membership, changing the row's group, or deleting the row can remove access
|
|
146
|
+
to its files. A share link requires parent-row read access when created and
|
|
147
|
+
stops working if its creator loses that access; anyone holding a still-valid
|
|
148
|
+
link may use it. An already-authorized request may finish during a concurrent
|
|
149
|
+
revocation. Keep these collections private; `public: true` is refused for
|
|
150
|
+
`parent()` collections.
|
|
151
|
+
|
|
152
|
+
## Who can retrieve a file
|
|
153
|
+
|
|
154
|
+
| How it's reached | Who can get the bytes |
|
|
155
|
+
|---|---|
|
|
156
|
+
| `files.documents.url(id)` | Only a signed-in user the collection allows, checked on every request. For `owner()`, that's the uploader. |
|
|
157
|
+
| `shareLink(id, { expiresIn })` | Anyone holding the link, until it expires. It stops working when the file is replaced or deleted, or when the link's creator can no longer read the file. There's no per-link revocation, so keep links short. |
|
|
158
|
+
| A collection declared `public: true` | Anyone, at the file's public URL. Public covers reading only. Upload, replace and delete still follow `scope` and `client`. |
|
|
159
|
+
| `sw.fs` in a function | Acts as the signed-in caller, with the same collection rules. |
|
|
160
|
+
| `sw.fs.server` in a function | Your project's authority over every file. Authorize the caller in your function before using it. |
|
|
161
|
+
|
|
162
|
+
A missing file and someone else's file both answer `FILE_NOT_FOUND`. They
|
|
163
|
+
look the same on purpose. Use `public: true` only for files meant for
|
|
164
|
+
everyone, such as avatars or product images. A public collection can't also
|
|
165
|
+
grant `client.read`.
|
|
166
|
+
|
|
167
|
+
Built-in Groups use `parent()` to follow a group-scoped row. `shared()`,
|
|
168
|
+
custom membership (`member`, `anyOf`) and server-only collections use the
|
|
169
|
+
same declaration. Other scopes and public collections:
|
|
170
|
+
`declared-files` → `declare`.
|
|
171
|
+
|
|
172
|
+
## Files outside a collection
|
|
173
|
+
|
|
174
|
+
Functions can also store generated files, such as an export or a rendered
|
|
175
|
+
PDF, with `sw.fs.server.write` after their own authorization check. Those
|
|
176
|
+
files are private unless you write them public, and a signed-in user's
|
|
177
|
+
`sw.fs` can't reach them: it creates no file outside a collection and can't
|
|
178
|
+
read or change the project's files. To hand one to a browser, create a
|
|
179
|
+
time-limited link with `sw.fs.server.signedUrl(path, { expiresIn })`. Never
|
|
180
|
+
pass a path the caller chose to `sw.fs.server`. Confine it to a folder your
|
|
181
|
+
function has authorized for that user.
|
|
182
|
+
|
|
183
|
+
## More on files
|
|
184
|
+
|
|
185
|
+
| Need | Where |
|
|
186
|
+
|---|---|
|
|
187
|
+
| Team, shared, public and server-only collections; limits; refusal codes | `declared-files` → `declare`, `answers` |
|
|
188
|
+
| Files inheriting built-in group access | `declared-files` → `files-that-follow-a-group-row`; `sw.groups` |
|
|
189
|
+
| Browser client details, group keys, public URLs | `declared-files` → `use-from-the-browser` |
|
|
190
|
+
| Share-link lifetime and revocation | `declared-files` → `share-links` |
|
|
191
|
+
| `sw.fs` and `sw.fs.server` in functions | `declared-files` → `in-your-functions` |
|
|
192
|
+
| Moving a hand-written upload endpoint to a collection | `declared-files` → `files-you-already-have` |
|
|
193
|
+
| Write, read, versions, move | `sw.fs` → `swfswritepath-content-options`, `swfsreadpath-options`, `swfsversionspath`, `swfsmovefrom-to-opts` |
|
|
194
|
+
| Signed and public URLs for non-collection files | `sw.fs` → `swfssignedurlpath-expiresin-`, `swfspublicurlpath-makepublic-` |
|
|
195
|
+
| Upload URLs for large files | `sw.fs` → `swfsuploadurl-path-maxsize-contenttype-expiresin-` |
|
|
196
|
+
| Searching document contents | **AI and search** (`search`) |
|
|
197
|
+
|
|
198
|
+
## Declare
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
import { schema, table, id, text, owner, member, anyOf, serverOnly, files } from 'somewhere/db';
|
|
202
|
+
|
|
203
|
+
export default schema({
|
|
204
|
+
teams: table({ id: id(), name: text() }, { scope: owner(), client: { read: ['id', 'name'], create: ['name'] } }),
|
|
205
|
+
team_members: table({ id: id(), team_id: text(), user_id: text() }, { scope: serverOnly() }),
|
|
206
|
+
}, {
|
|
207
|
+
files: {
|
|
208
|
+
// Only the signed-in uploader sees or touches their files.
|
|
209
|
+
uploads: files({
|
|
210
|
+
path: '/uploads', scope: owner(),
|
|
211
|
+
client: { read: true, upload: true, replace: true, delete: true },
|
|
212
|
+
limits: { maxSize: '25MB', types: ['image/*', 'application/pdf'] },
|
|
213
|
+
}),
|
|
214
|
+
// Team members read and upload; only the uploader replaces or deletes.
|
|
215
|
+
attachments: files({
|
|
216
|
+
path: '/attachments',
|
|
217
|
+
scope: anyOf(owner(), member({ group: 'team_id', membership: 'team_members',
|
|
218
|
+
member_user: 'user_id', member_group: 'team_id', operations: ['read', 'upload'] })),
|
|
219
|
+
client: { read: true, upload: true, replace: true, delete: true },
|
|
220
|
+
}),
|
|
221
|
+
// Anyone may view; only the owner uploads, replaces or deletes.
|
|
222
|
+
avatars: files({ path: '/avatars', scope: owner(), public: true,
|
|
223
|
+
client: { upload: true, replace: true, delete: true }, limits: { maxSize: '2MB', types: ['image/*'] } }),
|
|
224
|
+
// Public, written only by your functions or you.
|
|
225
|
+
assets: files({ path: '/assets', scope: serverOnly(), public: true }),
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
- **client** lists the browser operations: `read` (list, metadata, download,
|
|
231
|
+
share links), `upload`, `replace`, `delete`. An operation you do not list
|
|
232
|
+
does not exist in the client and is refused by the platform.
|
|
233
|
+
- **scope**: `parent({ table, via })` follows a private row's read and update
|
|
234
|
+
access, including built-in group rules. `owner()`: the uploader only.
|
|
235
|
+
`member({ group, membership, member_user, member_group, operations })`:
|
|
236
|
+
members of the file's group; `operations` takes `read`, `upload`,
|
|
237
|
+
`replace`, `delete` (replace/delete need read) and defaults to every
|
|
238
|
+
declared operation. `anyOf(owner(), member(...))`: members, or the
|
|
239
|
+
uploader while in the file's group (team files belong to the team).
|
|
240
|
+
`shared()`: every signed-in user reads, only the uploader replaces or
|
|
241
|
+
deletes. `serverOnly()`: no browser operations. `member()` is available
|
|
242
|
+
for an existing custom membership table; a new built-in Groups app uses
|
|
243
|
+
the parent-row example above.
|
|
244
|
+
- **public: true** lets anyone read every file in the collection at its public
|
|
245
|
+
URL. It never grants upload, replace or delete, cannot be combined with
|
|
246
|
+
`client.read`, and cannot be used on a member collection.
|
|
247
|
+
- **limits**: `maxSize` (`'25MB'` or bytes, at most your plan's per-file
|
|
248
|
+
limit) and `types` (`'image/png'`, `'image/*'`).
|
|
249
|
+
- **path** is the collection's folder. Every upload is stored at
|
|
250
|
+
`<path>/<file id>/<name>`. Collections cannot share or nest folders; up to
|
|
251
|
+
20 collections.
|
|
252
|
+
- The membership table must not allow browser writes: change membership in a
|
|
253
|
+
server function.
|
|
254
|
+
|
|
255
|
+
A declaration the platform cannot enforce refuses the deploy with
|
|
256
|
+
`SCHEMA_DECLARATION_INVALID` and one line per problem; nothing is applied.
|
|
257
|
+
Each deploy reports every collection and how many existing files sit in its
|
|
258
|
+
folder outside it.
|
|
259
|
+
|
|
260
|
+
## Use from the browser
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
import { files, type FileResult, type UploadedFile } from 'somewhere:files';
|
|
264
|
+
|
|
265
|
+
type Progress = (progress: { loaded: number; total: number }) => void;
|
|
266
|
+
|
|
267
|
+
// Upload, then return the file and its same-origin URL (authorized by the session on every request).
|
|
268
|
+
export async function uploadFile(file: File, onProgress?: Progress): Promise<FileResult<{ file: UploadedFile; url: string }>> {
|
|
269
|
+
const result = await files.uploads.upload(file, { onProgress });
|
|
270
|
+
if (result.error) return { data: null, error: result.error }; // { code, message, status }; nothing throws
|
|
271
|
+
return { data: { file: result.data, url: files.uploads.url(result.data.id) }, error: null };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// One page: { items, next, has_more }; pass next back as cursor for more.
|
|
275
|
+
export function listUploads(cursor?: string | null) {
|
|
276
|
+
return files.uploads.list({ limit: 20, cursor });
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export function replaceUpload(id: string, file: Blob, onProgress?: Progress) {
|
|
280
|
+
return files.uploads.replace(id, file, { onProgress });
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function deleteUpload(id: string) {
|
|
284
|
+
return files.uploads.delete(id);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// A time-limited link: { url, expires_at, expires_in }.
|
|
288
|
+
export function shareUpload(id: string, expiresIn = 600) {
|
|
289
|
+
return files.uploads.shareLink(id, { expiresIn });
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Member collection: the group key is named by the declaration (team_id).
|
|
293
|
+
export function uploadAttachment(teamId: string, file: File) {
|
|
294
|
+
return files.attachments.upload(file, { team_id: teamId, name: file.name });
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Omit teamId to list every group you belong to.
|
|
298
|
+
export function listAttachments(teamId?: string) {
|
|
299
|
+
return files.attachments.list({ team_id: teamId });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Public collection: the upload result's url is the public URL.
|
|
303
|
+
export async function uploadAvatar(file: File): Promise<FileResult<string>> {
|
|
304
|
+
const result = await files.avatars.upload(file);
|
|
305
|
+
if (result.error) return { data: null, error: result.error };
|
|
306
|
+
return { data: result.data.url, error: null };
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export function avatarUrl(id: string, name: string): string {
|
|
310
|
+
return files.avatars.publicUrl(id, name);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// serverOnly + public: a path inside the collection's folder.
|
|
314
|
+
export function assetUrl(path: string): string {
|
|
315
|
+
return files.assets.publicUrl(path);
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Every call returns `{ data, error }`. The client picks a single request or a
|
|
320
|
+
multipart upload by size, and checks `limits` before sending anything; the
|
|
321
|
+
platform enforces them regardless. A file's metadata is `{ id, name, size,
|
|
322
|
+
content_type, version, created_at, updated_at, mine }`, plus the group key in
|
|
323
|
+
member collections. It never carries another user's id or a storage path.
|
|
324
|
+
|
|
325
|
+
The client talks to your app's own origin (`/__sw/files`), so it works only
|
|
326
|
+
in pages served by the app. The files endpoint is served with your app's server
|
|
327
|
+
functions: an app with no function under `api/` and no declared browser data
|
|
328
|
+
answers `FILES_CLIENT_UNAVAILABLE` until it has one. A downloaded file that
|
|
329
|
+
is not an image, video, audio or PDF is delivered as a download, never
|
|
330
|
+
rendered inside your app.
|
|
331
|
+
|
|
332
|
+
## Answers
|
|
333
|
+
|
|
334
|
+
| Status | Code | Meaning |
|
|
335
|
+
|---|---|---|
|
|
336
|
+
| 401 | `AUTH_REQUIRED` | No signed-in user. Visitors (not signed in) cannot upload. |
|
|
337
|
+
| 403 | `FILE_ACCESS_DENIED` | The collection does not declare this operation. |
|
|
338
|
+
| 403 | `MEMBERSHIP_REQUIRED` | Uploading into a group you are not a member of. |
|
|
339
|
+
| 404 | `FILE_NOT_FOUND` | Missing, someone else's, another team's, or another collection's file — deliberately indistinguishable. |
|
|
340
|
+
| 409 | `FILES_CONTRACT_MISMATCH` | The declaration changed since the page loaded; reload. |
|
|
341
|
+
| 413 / 415 | `PAYLOAD_TOO_LARGE` / `FILE_TYPE_NOT_ALLOWED` | Outside `limits`. |
|
|
342
|
+
|
|
343
|
+
## Share links
|
|
344
|
+
|
|
345
|
+
- Default 10 minutes, at most 24 hours; a longer request is shortened, never
|
|
346
|
+
refused, and `expires_at` shows the real time.
|
|
347
|
+
- A link stops working when the file is replaced or deleted (410
|
|
348
|
+
`SIGNED_URL_STALE`), and when the person who made it can no longer read the
|
|
349
|
+
file — removed from the team, for example (410 `SIGNED_URL_REVOKED`).
|
|
350
|
+
- Anyone holding a link can download until then. There is no per-link
|
|
351
|
+
revocation; keep links short.
|
|
352
|
+
- Removing someone from a team takes effect on their very next request. Under
|
|
353
|
+
`anyOf(owner(), member(...))` that includes the files they uploaded
|
|
354
|
+
themselves, as with table rows; file access is checked on each request,
|
|
355
|
+
before the file is served, rather than inside one database statement.
|
|
356
|
+
|
|
357
|
+
## In your functions
|
|
358
|
+
|
|
359
|
+
- Default `sw.fs` acts as the signed-in user with the collection's own rule:
|
|
360
|
+
ownership grants access only where the scope includes `owner()` or
|
|
361
|
+
`shared()` (under `anyOf(owner(), …)`, only while the uploader is in the
|
|
362
|
+
file's group); a member may perform the
|
|
363
|
+
operations the collection grants members on files of their groups, and a
|
|
364
|
+
pure `member()` collection gives the uploader nothing beyond membership.
|
|
365
|
+
- A folder path is not membership. A signed-in `sw.fs` write, upload URL,
|
|
366
|
+
copy or move that would put a new file inside a collection's folder answers
|
|
367
|
+
409 `FILE_COLLECTION_PATH`, naming the way in: `files.<collection>.upload(...)`,
|
|
368
|
+
or a `sw.fs.server` write adopted with `sw.fs.server.setOwner`.
|
|
369
|
+
- A collection file stays in its collection. A signed-in copy or move of it
|
|
370
|
+
works inside the collection's folder (a copy is a new file of the
|
|
371
|
+
collection, in the same group, allowed when that user may upload there) and
|
|
372
|
+
answers 409 `FILE_COLLECTION_TRANSFER` anywhere else.
|
|
373
|
+
- `sw.fs.server` has project authority over every file; each operation is
|
|
374
|
+
logged with authority `server`. You and your developer tools (CLI, MCP,
|
|
375
|
+
dashboard) keep full access.
|
|
376
|
+
- Whether a collection file is public comes from the declaration:
|
|
377
|
+
`make_public`, make-private and `visibility: 'public'` writes on it answer
|
|
378
|
+
`FILE_VISIBILITY_DECLARED`.
|
|
379
|
+
|
|
380
|
+
## Files you already have
|
|
381
|
+
|
|
382
|
+
What a signed-in user's `sw.fs` may do with a file comes from that file's
|
|
383
|
+
own record and the current declaration, never from when the app or the file
|
|
384
|
+
was created:
|
|
385
|
+
|
|
386
|
+
- A collection file follows its collection's current rules.
|
|
387
|
+
- A file outside every collection is readable when it is public, and readable
|
|
388
|
+
and changeable by the app user recorded as its owner.
|
|
389
|
+
- Any other private file belongs to the project. Only `sw.fs.server`, after
|
|
390
|
+
your function's own check, and your developer tools reach it.
|
|
391
|
+
|
|
392
|
+
A signed-in user's `sw.fs` never creates a new file outside a collection
|
|
393
|
+
(403 `FILE_ACCESS_DENIED`) or inside a collection's folder (409
|
|
394
|
+
`FILE_COLLECTION_PATH`), so an upload endpoint that writes new files as the
|
|
395
|
+
signed-in user is refused. Declaring a collection changes nothing about
|
|
396
|
+
existing files, including files already inside its folder. A file joins a
|
|
397
|
+
collection only by being uploaded through `somewhere:files`, or by explicit
|
|
398
|
+
adoption.
|
|
399
|
+
|
|
400
|
+
A user's upload is stored privately in one of two ways:
|
|
401
|
+
|
|
402
|
+
- **Collection upload (the default).** Declare a collection and upload from
|
|
403
|
+
the browser with `files.<collection>.upload(...)`. The platform checks the
|
|
404
|
+
collection's rules on every request; no function is needed.
|
|
405
|
+
- **A privileged server function.** Verify the actor with
|
|
406
|
+
`sw.auth.requireUser(req)`, check explicitly that this user may store or
|
|
407
|
+
read this file, then call `sw.fs.server` with a path your code builds and
|
|
408
|
+
confines to that user, such as `/uploads/${user.id}/${crypto.randomUUID()}`.
|
|
409
|
+
Never pass a path the caller chose. Serve the file back the same way, or
|
|
410
|
+
with a short `sw.fs.server.signedUrl` after the same check.
|
|
411
|
+
|
|
412
|
+
To move an app with a hand-written upload endpoint across, at its own pace:
|
|
413
|
+
|
|
414
|
+
1. Declare the collection (its folder may be the one the old endpoint uses).
|
|
415
|
+
2. Switch new browser uploads to `files.<collection>.upload(...)`. Old files
|
|
416
|
+
stay readable under the rules above; serve project-owned ones from a
|
|
417
|
+
function with `sw.fs.server` after your own check.
|
|
418
|
+
3. Adopt old files whenever convenient, from a function or `run_code`:
|
|
419
|
+
`await sw.fs.server.setOwner(path, userId, { collection: 'uploads' })`
|
|
420
|
+
(add `group` for a member collection). The file keeps its path and takes
|
|
421
|
+
the collection's visibility. Refused outside the collection's folder and
|
|
422
|
+
from a user's request. Safe to repeat.
|
|
423
|
+
4. Delete the old endpoint when it serves nothing. Skipping step 3 is fine.
|
|
424
|
+
|
|
425
|
+
### Automatic display images
|
|
426
|
+
|
|
427
|
+
Images shown in a page (including CSS backgrounds and script-created images) are delivered as
|
|
428
|
+
WebP at the same dimensions when the browser accepts WebP and the bytes identify a static JPEG
|
|
429
|
+
or non-animated PNG. Conversion is lossy, at quality 82, including PNG; pixels can change.
|
|
430
|
+
The WebP encoder removes embedded metadata, including EXIF location; the public original can still contain it.
|
|
431
|
+
A damaged image that still decodes may be shown as the encoder decodes it; downloads always return the uploaded bytes.
|
|
432
|
+
Downloads and script fetches get the original. `?original=1` always requests original bytes,
|
|
433
|
+
including with `w`; saving the displayed image (Save image as) may save the display copy.
|
|
434
|
+
Animated images, SVG and unrecognized inputs stay original. Explicit widths below remain for right-sizing.
|
|
435
|
+
|
|
436
|
+
A CDN or proxy placed in front of a custom domain must honour `Vary: Accept, Sec-Fetch-Dest`,
|
|
437
|
+
forward these headers, preserve queries and revalidate, or not cache these responses.
|
|
438
|
+
Customer service-worker/offline copies must revalidate mutable storage; retained offline bytes
|
|
439
|
+
are outside negotiation and revocation guarantees. Previously fresh browser entries may remain until expiry.
|
|
440
|
+
|
|
441
|
+
Cost: one more parameter combination per image revision per calendar month as the provider bills it;
|
|
442
|
+
the encoding work itself can repeat at another location or after eviction.
|
|
443
|
+
Worker execution and storage reads can repeat too.
|
|
444
|
+
|
|
445
|
+
### Responsive public images
|
|
446
|
+
|
|
447
|
+
Public uploaded PNG, JPEG, WebP and AVIF files accept exactly `?w=192`, `384`,
|
|
448
|
+
`768` or `1536`, returning WebP with the aspect ratio preserved and no enlargement.
|
|
449
|
+
Other widths, duplicate `w`, extra query parameters, Range requests and files
|
|
450
|
+
without a content revision use the original. SVG and other types stay original.
|
|
451
|
+
Each width of an image is encoded when first requested at a location and then served from that location's cache; it may be encoded again at another location or after eviction. Cloudflare bills a unique image-and-width once per calendar month.
|
|
452
|
+
|
|
453
|
+
All public storage responses revalidate access on each use, including originals and transform fallbacks.
|
|
454
|
+
A failed transform serves the guarded original.
|
|
455
|
+
`url(id)` remains the authorized file door; `publicUrl` only addresses public files.
|
|
456
|
+
For public server-only collections, use `publicUrl(path, width)`.
|
|
457
|
+
|
|
458
|
+
```tsx
|
|
459
|
+
// src/Avatar.tsx
|
|
460
|
+
import { files } from 'somewhere:files';
|
|
461
|
+
|
|
462
|
+
export function Avatar({ id, name }: { id: string; name: string }) {
|
|
463
|
+
return <img
|
|
464
|
+
src={files.avatars.publicUrl(id, name, 768)}
|
|
465
|
+
srcSet={([192, 384, 768, 1536] as const).map(w =>
|
|
466
|
+
`${files.avatars.publicUrl(id, name, w)} ${w}w`
|
|
467
|
+
).join(', ')}
|
|
468
|
+
sizes="(max-width: 768px) 100vw, 768px"
|
|
469
|
+
alt="Profile photo"
|
|
470
|
+
/>;
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
Choose `sizes` for your layout and dimensions from the actual image aspect ratio.
|
|
475
|
+
Use lazy loading for below-fold images, leaving the primary visible image eager.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Deploy intelligence — what a deploy records, and where to read it
|
|
2
|
+
|
|
3
|
+
A successful live deploy, patch or promote queues two background jobs for the
|
|
4
|
+
release that just went live:
|
|
5
|
+
|
|
6
|
+
- **Project docs**, generated from that release's exact source. `project_get`
|
|
7
|
+
includes an overview. Read the full document with `project_docs`.
|
|
8
|
+
- **Homepage screenshots**. Read them with `project_screenshots`.
|
|
9
|
+
|
|
10
|
+
The deploy response returns while these jobs run. If a job fails, the release
|
|
11
|
+
stays live; the reads below show which outputs are available. A **security review** of your deployed
|
|
12
|
+
functions runs when you call `security_review`. Your plan decides how deep it
|
|
13
|
+
goes and whether reviews also run automatically.
|
|
14
|
+
|
|
15
|
+
## Project docs
|
|
16
|
+
|
|
17
|
+
Start with `project_get({ project_id: "my-app" })` for entry files, pages, API
|
|
18
|
+
routes, tables and job handlers in the active release. Active schedules are
|
|
19
|
+
configured separately and listed by `cron_list`. Use `docs_query` for a specific
|
|
20
|
+
route, symbol or file. To read the full generated document, call `project_docs`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{ "project_id": "my-app" }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"version": 42,
|
|
29
|
+
"version_source": "active_release",
|
|
30
|
+
"release_id": "rel_…",
|
|
31
|
+
"docs": { "status": "deterministic", "markdown": "…", "prose": null, "prose_label": null },
|
|
32
|
+
"mermaid": "flowchart LR …",
|
|
33
|
+
"routes": [], "symbols": [], "tables": [], "graph": {}, "coverage": {}, "files": [],
|
|
34
|
+
"partial": false
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The response above is trimmed. REST: `GET /v1/project-docs?project_id=my-app`,
|
|
39
|
+
plus `&version=41` for an earlier release.
|
|
40
|
+
|
|
41
|
+
- **What it describes.** The release that is live now, built from the source it
|
|
42
|
+
was published from. Routes, tables, symbols and the dependency graph come from that source.
|
|
43
|
+
Check `coverage` and `partial` for parts the analysis could not resolve. `mermaid` is a diagram of the same facts; the dashboard draws
|
|
44
|
+
it on the project overview.
|
|
45
|
+
- **What to trust.** `docs.markdown` and the structured fields are generated
|
|
46
|
+
from source without a model call.
|
|
47
|
+
- **Which version.** With no `version`, you get the active release's docs only.
|
|
48
|
+
There is no fallback to another version.
|
|
49
|
+
- **No docs stored.** The call returns 404 `PROJECT_DOCS_NOT_FOUND`, and
|
|
50
|
+
`status` and `no_sidecar_reason` say why. Read the source instead
|
|
51
|
+
(`project_files_list`, `project_file_read`). The next successful live deploy
|
|
52
|
+
queues docs again.
|
|
53
|
+
- **After a rollback.** Nothing new is queued. You read whatever docs are stored
|
|
54
|
+
for the release now active.
|
|
55
|
+
|
|
56
|
+
For one route, file or symbol, `docs_query` answers from the same docs:
|
|
57
|
+
`docs_query({ project_id: "my-app", route: "POST /api/checkout" })`, or
|
|
58
|
+
`GET /v1/docs-query?project_id=my-app&route=POST%20/api/checkout`.
|
|
59
|
+
|
|
60
|
+
## Screenshots
|
|
61
|
+
|
|
62
|
+
Call `project_screenshots`:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{ "project_id": "my-app" }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
It returns one entry per stored image (`version`, `viewport`, `captured_at`,
|
|
69
|
+
`size_bytes`). Pass `"include_data": true` for the PNG as a data URL. REST:
|
|
70
|
+
`GET /v1/deploy/screenshots?project_id=my-app[&version=42]` includes `data_url`
|
|
71
|
+
and `signed_url` by default; add `include_data_url=false` to leave the image out.
|
|
72
|
+
|
|
73
|
+
The capture covers the homepage on your custom domain if one is attached,
|
|
74
|
+
otherwise your `*.somewhere.site` address. It shoots desktop
|
|
75
|
+
(1280 × 800) and mobile (375 × 667).
|
|
76
|
+
Previews are not captured. A failed capture never affects the deploy; that
|
|
77
|
+
version just has fewer images. A blank page is warned about by the
|
|
78
|
+
after-deploy check, never rolled back for you (`docs({ topic: 'deploy' })`).
|
|
79
|
+
|
|
80
|
+
## Security review
|
|
81
|
+
|
|
82
|
+
Call `security_review` after a deploy. `focus` is optional:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{ "project_id": "my-app", "focus": "the new checkout handler" }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"status": "risks_found",
|
|
91
|
+
"verdict_reasons": [],
|
|
92
|
+
"findings": "## Findings\n### …",
|
|
93
|
+
"finding_count": 1,
|
|
94
|
+
"tier_unlocks_deep_review": false,
|
|
95
|
+
"review_run_id": "…",
|
|
96
|
+
"version": 42,
|
|
97
|
+
"release_id": "rel_…",
|
|
98
|
+
"files_shown": 6,
|
|
99
|
+
"files_total": 6
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The response above is trimmed; it also carries `model`, `release_seq`,
|
|
104
|
+
`source_authority` and `usage`. REST: `POST /v1/security/review` with the same
|
|
105
|
+
body. It needs editor access to the project.
|
|
106
|
+
|
|
107
|
+
**What it reads.** The live release's server functions: up to
|
|
108
|
+
40 files, and the first
|
|
109
|
+
8,000 characters of each. Frontend code and declared
|
|
110
|
+
data access are outside its scope. `focus` (up to
|
|
111
|
+
500 characters) points it at one area.
|
|
112
|
+
|
|
113
|
+
**Reading the result.** `findings` is a Markdown report rendered from a
|
|
114
|
+
validated result: findings, then platform best practices, then a risk summary.
|
|
115
|
+
Act on `status`:
|
|
116
|
+
|
|
117
|
+
- `risks_found` — fix each finding. Each one names its severity, file, region,
|
|
118
|
+
impact and fix.
|
|
119
|
+
- `clear` — no risks found. A review returns `clear` only after reading every
|
|
120
|
+
function in full.
|
|
121
|
+
- `indeterminate` — no conclusion either way. The review has already re-asked
|
|
122
|
+
once before answering. Check `verdict_reasons` and compare `files_shown` with
|
|
123
|
+
`files_total` before doing anything else:
|
|
124
|
+
- `partial_input`, or `files_shown` below `files_total`: the code was cut to
|
|
125
|
+
fit, so the review can report risks but can never return `clear`. Running it
|
|
126
|
+
again on the same release reads the same cut-down input. To get a full read,
|
|
127
|
+
split oversized function files, then deploy.
|
|
128
|
+
- Any other reason: the reviewer's answer failed validation, and the platform
|
|
129
|
+
has been alerted. Review again after your next deploy instead of repeating
|
|
130
|
+
it now; each run is a fresh AI review.
|
|
131
|
+
|
|
132
|
+
Errors carry a `retry` field. Retry only when it says to.
|
|
133
|
+
|
|
134
|
+
**What it looks for:**
|
|
135
|
+
|
|
136
|
+
1. **Auth bypass** — a public route trusts a caller-supplied user id, session or
|
|
137
|
+
role instead of `sw.auth.fromRequest(req)`.
|
|
138
|
+
2. **Raw SQL exposure** — request input concatenated into a query string.
|
|
139
|
+
3. **Unsafe payment metadata** — `sw.payments.checkout` with caller-controlled
|
|
140
|
+
metadata or user id.
|
|
141
|
+
4. **Env leakage** — a handler returns `sw.env` values to the caller.
|
|
142
|
+
5. **Privilege escalation** — a public handler performs an admin-level action
|
|
143
|
+
for any caller.
|
|
144
|
+
6. **Code execution** — `eval`, `new Function` or dynamic `import` of
|
|
145
|
+
caller-controlled strings.
|
|
146
|
+
7. **Email spoofing** — `sw.email.send` with a `from` taken from the request.
|
|
147
|
+
8. **Conversation access** — `sw.ai` already ties a signed-in user's
|
|
148
|
+
conversations to that user. The risk is code that reaches another user's
|
|
149
|
+
history: `sw.ai.conversations.forUser(id)` or `sw.ai.scoped(id)` with an `id`
|
|
150
|
+
taken from the request.
|
|
151
|
+
9. **CSRF** — a destructive POST with no origin or token check.
|
|
152
|
+
|
|
153
|
+
It also suggests **platform best practices**: an ownership filter missing from
|
|
154
|
+
raw SQL on a user-owned table, queries inside a loop, repeated endpoint
|
|
155
|
+
boilerplate, `fetch` calls from a function to the platform's own REST API, and
|
|
156
|
+
hand-written CORS headers. Best practices never change `status`. A review only
|
|
157
|
+
advises; it never blocks or changes a deploy.
|
|
158
|
+
|
|
159
|
+
**What your plan changes.** Every plan can request a review. Paid plans get a
|
|
160
|
+
longer report. Eligible paid plans also review when a preview is promoted.
|
|
161
|
+
When `tier_unlocks_deep_review` is `true`, the on-demand output limit is
|
|
162
|
+
2,048 tokens, versus 1,024 on Free. Both use the same
|
|
163
|
+
review model and `minimal` reasoning. Eligible promote reviews also use
|
|
164
|
+
`minimal` reasoning, with output limits of 2,048, 4,096 or 6,144 tokens for the
|
|
165
|
+
existing `pro`, `scale` and `enterprise` review depth settings respectively.
|
|
166
|
+
These settings limit report length; they do not certify the whole app.
|
|
167
|
+
Automatic runs appear in review history with `trigger: "deploy"`.
|
|
168
|
+
Historical scheduled runs remain in review history. There is no daily scheduled review.
|
|
169
|
+
|
|
170
|
+
```http
|
|
171
|
+
GET /v1/security/reviews?project_id=my-app[&limit=20][&cursor=…]
|
|
172
|
+
GET /v1/security/reviews/{review_run_id}?project_id=my-app
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Each history entry carries `trigger`, `outcome`, `failure_reason`, `coverage`
|
|
176
|
+
(including `complete` and `limitations`) and `finding_count`. `limit` runs from
|
|
177
|
+
1 to 50.
|
|
178
|
+
|
|
179
|
+
## Where to read each output
|
|
180
|
+
|
|
181
|
+
| Output | Queued or run | MCP | REST |
|
|
182
|
+
| --------------- | ------------------------------------------------------ | ---------------------------- | ------------------------------------------------------ |
|
|
183
|
+
| Project docs | After a successful live deploy, patch or promote | `project_docs`, `docs_query` | `GET /v1/project-docs`, `GET /v1/docs-query` |
|
|
184
|
+
| Screenshots | After a successful live deploy, patch or promote | `project_screenshots` | `GET /v1/deploy/screenshots` |
|
|
185
|
+
| Security review | On demand; automatically on some plans | `security_review` | `POST /v1/security/review`, `GET /v1/security/reviews` |
|
|
186
|
+
|
|
187
|
+
`GET /v1/deploy/architecture` returns the same diagram as `project_docs`, with
|
|
188
|
+
`superseded_by: "/v1/project-docs"`. For what an app does, read `project_docs`.
|