@somewhere-cloud/cli 0.38.155 → 0.38.157

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/commands/docs.js +1 -1
  3. package/dist/lib/bundle.js +286 -188
  4. package/dist/lib/bundle.js.map +3 -3
  5. package/npm-shrinkwrap.json +2 -2
  6. package/package.json +2 -3
  7. package/dist/docs/adopt.md +0 -39
  8. package/dist/docs/analytics.md +0 -161
  9. package/dist/docs/api-reference.md +0 -339
  10. package/dist/docs/api-surface.md +0 -2067
  11. package/dist/docs/app-mcp.md +0 -162
  12. package/dist/docs/architecture-patterns.md +0 -334
  13. package/dist/docs/auth-client.md +0 -531
  14. package/dist/docs/billing.md +0 -76
  15. package/dist/docs/browser.md +0 -639
  16. package/dist/docs/calendar.md +0 -298
  17. package/dist/docs/changes.md +0 -323
  18. package/dist/docs/cli.md +0 -407
  19. package/dist/docs/common-mistakes.md +0 -199
  20. package/dist/docs/connect-agent.md +0 -72
  21. package/dist/docs/cors.md +0 -114
  22. package/dist/docs/cron.md +0 -167
  23. package/dist/docs/database-engine.md +0 -167
  24. package/dist/docs/declared-data.md +0 -1656
  25. package/dist/docs/declared-files.md +0 -475
  26. package/dist/docs/deploy-intelligence.md +0 -188
  27. package/dist/docs/deploy.md +0 -733
  28. package/dist/docs/design-system.md +0 -273
  29. package/dist/docs/dev-environments.md +0 -496
  30. package/dist/docs/domain-ownership.md +0 -31
  31. package/dist/docs/domains.md +0 -370
  32. package/dist/docs/feedback.md +0 -88
  33. package/dist/docs/file-tools.md +0 -116
  34. package/dist/docs/functions.md +0 -489
  35. package/dist/docs/getting-started.md +0 -238
  36. package/dist/docs/github.md +0 -95
  37. package/dist/docs/google-calendar.md +0 -212
  38. package/dist/docs/groups.md +0 -836
  39. package/dist/docs/guarantees.md +0 -58
  40. package/dist/docs/handled-for-you.md +0 -224
  41. package/dist/docs/inspect.md +0 -171
  42. package/dist/docs/limits.md +0 -68
  43. package/dist/docs/live-data.md +0 -197
  44. package/dist/docs/live.md +0 -92
  45. package/dist/docs/local-dev.md +0 -30
  46. package/dist/docs/migration-supabase.md +0 -58
  47. package/dist/docs/payments.md +0 -1102
  48. package/dist/docs/portability.md +0 -194
  49. package/dist/docs/postgres.md +0 -301
  50. package/dist/docs/pricing-comparison.md +0 -42
  51. package/dist/docs/pricing.md +0 -39
  52. package/dist/docs/project-groups.md +0 -107
  53. package/dist/docs/projects.md +0 -380
  54. package/dist/docs/recipe-ai-agent.md +0 -112
  55. package/dist/docs/recipe-ai-features.md +0 -227
  56. package/dist/docs/recipe-ai-receipts.md +0 -783
  57. package/dist/docs/recipe-background-jobs.md +0 -369
  58. package/dist/docs/recipe-booking.md +0 -348
  59. package/dist/docs/recipe-csv-import.md +0 -390
  60. package/dist/docs/recipe-ecommerce.md +0 -127
  61. package/dist/docs/recipe-email.md +0 -282
  62. package/dist/docs/recipe-escalation.md +0 -133
  63. package/dist/docs/recipe-file-uploads.md +0 -159
  64. package/dist/docs/recipe-import-app.md +0 -110
  65. package/dist/docs/recipe-login.md +0 -457
  66. package/dist/docs/recipe-multi-chat.md +0 -198
  67. package/dist/docs/recipe-paid-api.md +0 -161
  68. package/dist/docs/recipe-pdfs.md +0 -205
  69. package/dist/docs/recipe-push-notifications.md +0 -107
  70. package/dist/docs/recipe-seo.md +0 -200
  71. package/dist/docs/recipe-signed-in-app.md +0 -330
  72. package/dist/docs/render.md +0 -99
  73. package/dist/docs/rooms.md +0 -554
  74. package/dist/docs/sdk.md +0 -287
  75. package/dist/docs/sdks.md +0 -24
  76. package/dist/docs/search.md +0 -199
  77. package/dist/docs/security-model.md +0 -168
  78. package/dist/docs/setup.md +0 -212
  79. package/dist/docs/smoke.md +0 -102
  80. package/dist/docs/speed.md +0 -298
  81. package/dist/docs/sql-compatibility.md +0 -96
  82. package/dist/docs/sw.agent.md +0 -248
  83. package/dist/docs/sw.ai.md +0 -1291
  84. package/dist/docs/sw.auth.md +0 -1811
  85. package/dist/docs/sw.billing.md +0 -171
  86. package/dist/docs/sw.db.md +0 -2128
  87. package/dist/docs/sw.email.md +0 -661
  88. package/dist/docs/sw.endpoint.md +0 -187
  89. package/dist/docs/sw.env.md +0 -303
  90. package/dist/docs/sw.fetch.md +0 -115
  91. package/dist/docs/sw.fs.md +0 -424
  92. package/dist/docs/sw.groups.md +0 -836
  93. package/dist/docs/sw.image.md +0 -69
  94. package/dist/docs/sw.jobs.md +0 -520
  95. package/dist/docs/sw.logs.md +0 -61
  96. package/dist/docs/sw.mail.md +0 -106
  97. package/dist/docs/sw.notifications.md +0 -78
  98. package/dist/docs/sw.push.md +0 -161
  99. package/dist/docs/sw.rateLimit.md +0 -67
  100. package/dist/docs/sw.web.md +0 -128
  101. package/dist/docs/tasks.md +0 -269
  102. package/dist/docs/test.md +0 -220
  103. package/dist/docs/tool-reference-account.md +0 -7
  104. package/dist/docs/tool-reference-ai.md +0 -121
  105. package/dist/docs/tool-reference-analytics.md +0 -37
  106. package/dist/docs/tool-reference-api.md +0 -19
  107. package/dist/docs/tool-reference-artifacts.md +0 -35
  108. package/dist/docs/tool-reference-auth.md +0 -163
  109. package/dist/docs/tool-reference-browser.md +0 -114
  110. package/dist/docs/tool-reference-code.md +0 -26
  111. package/dist/docs/tool-reference-connect.md +0 -21
  112. package/dist/docs/tool-reference-cron.md +0 -48
  113. package/dist/docs/tool-reference-db.md +0 -282
  114. package/dist/docs/tool-reference-domains.md +0 -107
  115. package/dist/docs/tool-reference-email.md +0 -55
  116. package/dist/docs/tool-reference-env.md +0 -19
  117. package/dist/docs/tool-reference-feedback.md +0 -56
  118. package/dist/docs/tool-reference-fs.md +0 -265
  119. package/dist/docs/tool-reference-github.md +0 -57
  120. package/dist/docs/tool-reference-groups.md +0 -85
  121. package/dist/docs/tool-reference-help.md +0 -29
  122. package/dist/docs/tool-reference-jobs.md +0 -39
  123. package/dist/docs/tool-reference-live.md +0 -48
  124. package/dist/docs/tool-reference-logs.md +0 -16
  125. package/dist/docs/tool-reference-payments.md +0 -44
  126. package/dist/docs/tool-reference-project.md +0 -706
  127. package/dist/docs/tool-reference-push.md +0 -78
  128. package/dist/docs/tool-reference-rate-limit.md +0 -18
  129. package/dist/docs/tool-reference-search.md +0 -68
  130. package/dist/docs/tool-reference-security.md +0 -42
  131. package/dist/docs/tool-reference-smoke.md +0 -17
  132. package/dist/docs/tool-reference-stock-photos.md +0 -20
  133. package/dist/docs/tool-reference-tasks.md +0 -73
  134. package/dist/docs/tool-reference-telegram.md +0 -32
  135. package/dist/docs/tool-reference-usage.md +0 -9
  136. package/dist/docs/tool-reference-web.md +0 -71
  137. package/dist/docs/tool-reference-webhooks.md +0 -9
  138. package/dist/docs/troubleshooting.md +0 -411
  139. package/dist/docs/typed-functions.md +0 -94
  140. package/dist/docs/verify-before-deploy.md +0 -67
  141. package/dist/docs/vs-supabase.md +0 -75
  142. package/dist/docs/vs-vercel.md +0 -103
@@ -1,411 +0,0 @@
1
- # Troubleshooting — Common errors and what to do
2
-
3
- Start from what the platform recorded, then apply the fix for that error below.
4
-
5
- Read the newest errors first:
6
- `project_logs({ project_id, level: 'error', limit: 20 })` from an MCP client,
7
- or `somewhere errors` in the project folder. An uncaught function exception
8
- shows its code (`FUNCTION_ERROR`), the route, and a `stack` that names the
9
- file and line in your code. If a page or route is missing,
10
- `deploy_status({ project_id })` shows the active release and version that is
11
- serving. For what a visitor's browser saw — failed requests, console errors and
12
- the rendered page — use `browser` → `read-what-happened`.
13
-
14
- Then find the error code in the sections below; each gives the cause and the
15
- fix. `troubleshooting` → `how-to-read-your-error-logs` has the full log
16
- format. Use the returned `hint` for the next step;
17
- `all-api-errors-include-a-hint-field` explains that field.
18
-
19
- To rule out a platform problem, read the live status:
20
- `curl https://somewhere.cloud/status.txt` lists every component (sites,
21
- functions, app databases, sign-in, file storage, AI, payments, email API,
22
- deploys, API and MCP, and the somewhere.cloud website) with its state
23
- (Operational or Disrupted), when it was last checked, what it covers, and
24
- whether a check failed in the period on record (up to seven days). A
25
- component whose latest check is late shows its last known state, and a
26
- single failed check is re-run before a component shows Disrupted; the feed
27
- has no pending or unknown state. The same data is at
28
- https://somewhere.cloud/status and, as JSON, at
29
- https://api.somewhere.cloud/v1/status.
30
-
31
- ## "FUNCTION_NOT_FOUND" or 404 on a /api/* route
32
-
33
- The function file isn't deployed, or the route doesn't match.
34
-
35
- Check:
36
- 1. Did you actually deploy the function? `deploy_status({ project_id })`
37
- lists deployed functions.
38
- 2. Does the file path match the URL? `api/users/[id].ts` serves
39
- `/api/users/123`. `api/users.ts` serves `/api/users`.
40
- 3. Was the deploy actually successful? Re-run `project_deploy` and
41
- check the response — every deploy goes live; if the route still
42
- 404s, the function isn't in the bundle.
43
-
44
- ## "API key is invalid" inside sw.* calls
45
-
46
- Inside a deployed function, `sw.*` calls authenticate with the project's
47
- own key. Read the error first: a thrown `sw.*` error carries `code` and `status`.
48
-
49
- - `AUTHORITY_UNAVAILABLE` (503) is temporary. Retry after
50
- `retry_after_ms`.
51
- - `INVALID_API_KEY` (401): confirm the call runs in the project and
52
- release you expect (`somewhere status`, or
53
- `deploy_status({ project_id })`), then read `somewhere errors` and
54
- `somewhere logs` for the failing path. If it persists on the current
55
- release, send the code, project id and release id with
56
- `support_ticket`.
57
-
58
- Don't copy a developer key or CLI session into source or environment
59
- variables to work around it.
60
-
61
- ## "AI_SPEND_CAP_REACHED"
62
-
63
- The project reached its monthly AI spend cap (HTTP 429). Your code is
64
- not at fault: every AI call from the project is refused until the month
65
- turns (UTC), and the rest of the app keeps working. `data` shows the cap,
66
- the spend so far and when it resets.
67
-
68
- Fix: if the spend is expected, the project owner raises the cap with
69
- `PATCH /v1/projects/{id}` `{ "ai_spend_cap_cents": <cents> }` (MCP
70
- `project_update`), or turns it off with `null`. The prepaid balance
71
- still bounds spend. Details: docs({ topic: 'sw.ai' }).
72
-
73
- The cap is per-project, not per-account, and it is not divided among
74
- your app's users: to stop one user spending the project's allowance, add
75
- `rateLimit` to that endpoint (`docs({ topic: 'sw.endpoint' })`) or use
76
- `sw.rateLimit`.
77
-
78
- ## Auth emails (signup, password reset) not arriving
79
-
80
- Two common causes:
81
-
82
- **Sender not verified** — Without `from`, mail goes from your app's
83
- own `somewhere.site` address, and auth emails from `noreply@somewhere.cloud`. Some inboxes flag this as suspicious. Follow the [sender domain setup](https://somewhere.cloud/docs/sw.email.txt#your-own-sender-domain) to send auth emails from your own domain.
84
-
85
- **A send failed** — Sign-in links and email verification codes report a
86
- failed send to the caller with an error code,
87
- for example `EMAIL_SUPPRESSED` (422),
88
- `EMAIL_PROJECT_PAUSED` (503), or `EMAIL_SEND_FAILED` /
89
- `EMAIL_DELIVERY_UNKNOWN` (502). A 202 response marked pending means the
90
- send is not confirmed yet. The password-reset email and the welcome email
91
- after sign-up (unless `auth_welcome_email` is false) are sent in the background: the request succeeds even when the
92
- send fails, and a reset request always gets the same answer, so it never
93
- reveals whether an account exists. To check those two, use an account at
94
- `<name>@<subdomain>.test.somewhere.site` and read its mail with
95
- `somewhere email test-inbox <address>`. In a function, `sw.email.send`
96
- throws on failure; the error's `code` and `status` say why.
97
-
98
- ## A deploy failure that needs no change from you
99
-
100
- Some deploy failures come from the platform's build, not from your source. The
101
- live version stays as it was. Don't rename or move files for these:
102
-
103
- - `COMPILED_ASSET_COLLISION`: The compiler produced an asset whose filename already belongs to different bytes. Use the failure reference to investigate the compiled asset. No source change is required.
104
- - `POSTVERIFY_MISMATCH`: The deploy did not complete because the served version did not match the release being verified. The project deploy logs record the recovery outcome; no source change is required. Platform support requests are accepted at POST /v1/platform-feedback.
105
- - `DEPLOY_COMPILE_TIMEOUT`: The platform compiler exceeded its time limit while preparing this deploy. Your live version is unchanged. An immediate repeat of the same request meets the same time limit. Exact pinned dependency versions in package.json, rather than latest ranges, shorten the install for a raw-source deploy. When the versions are already pinned, platform support requests that include the failure reference are accepted at POST /v1/platform-feedback.
106
-
107
- The failed deploy's reference is in `project_deploy_log({ project_id })`.
108
- Report it with that reference through `support_ticket({ message })`.
109
-
110
- ## "Site not loading after deploy"
111
-
112
- Every `project_deploy` and `project_patch` writes to the live serving
113
- slot. If the live site still shows
114
- the old version, it's almost always cache:
115
-
116
- 1. **Browser cache.** Hard reload (Cmd-Shift-R) or open the URL in a
117
- private window.
118
- 2. **Edge cache.** `curl -sI https://{subdomain}.somewhere.site/`
119
- shows the response headers. Where present, `X-Somewhere-Edge-Cache`
120
- reports a platform cache hit or miss. `Cache-Control` describes what
121
- the browser may cache; it does not tell you whether the platform reused
122
- stored bytes.
123
- 3. **Wrong project.** Confirm the `project_id` matches the subdomain
124
- you're hitting.
125
-
126
- If a deploy genuinely failed silently, `deploy_status({ project_id })`
127
- returns the most recent timestamp — older than your last deploy means
128
- the deploy errored.
129
-
130
- ## Managed-mode raw SQL errors
131
-
132
- The project has a deployed `db/schema.ts`, so it is in managed mode.
133
- On an older shared database, ordinary `sw.db.query` / `sw.db.batch` fail
134
- before transport with `MANAGED_RAW_SQL_REQUIRES_SERVER_AUTHORITY`, including
135
- in job, queue, and cron handlers; with a separate SQL database they run there
136
- and never see declared tables. Explicit `sw.db.server.query` / `sw.db.server.batch` reads
137
- run as written after your function authorizes the caller. A raw write through
138
- them reaches only a separate SQL database, never declared tables; on an older
139
- shared database it fails with `MANAGED_RAW_WRITE_FORBIDDEN`.
140
-
141
- Fix: write with `sw.db.insert` / `sw.db.update` / `sw.db.remove` (the
142
- table needs a declared intent), or run the statement with developer
143
- authority (`db_query` / `db_batch` / `db_migrate`), which is
144
- unaffected. There is no flag that switches the project back to SQL mode;
145
- the owner-approved managed exit is the one path.
146
- Full contract: `docs({ topic: 'sw.db' })`, "Managed mode".
147
-
148
- ## "AUTH_REQUIRED" from sw.db.from / insert / count on an owner() table
149
-
150
- The table is user-owned, so the platform scopes it to a principal, and this
151
- request had none: there is no signed-in user, and this table does not declare
152
- `owner({ visitors: true })`, which is the declaration that accepts a stable
153
- anonymous visitor identity. Inspect the table in `db_scope_list`; its
154
- `owner_principal` summary describes both declaration forms.
155
-
156
- Fix: send the request signed in (same-origin session cookie, or
157
- `Authorization: Bearer <app-user token>`); or, after the handler independently
158
- checks that this caller is allowed to read across users, use the deliberate
159
- server-side cross-user mode `{ asServer: true }` with
160
- `sw.db.from` / `sw.db.count` for that exceptional operation. For anonymous-owned
161
- rows, declare `owner({ visitors: true })` and use the generated browser client;
162
- do not replace declared ownership with a hand-written visitor key.
163
-
164
- ## "REALTIME_RETIRED" (410) or "CHANNEL_FORBIDDEN" (403)
165
-
166
- The platform does not offer caller-named channels. This is not a configuration
167
- problem and there is no flag to turn them on.
168
-
169
- Fix: for browser live updates declare a live view —
170
- `sw.rooms.live(name, sw.db.from(...))` + `watchLive`. Developer tooling can
171
- subscribe to the reserved platform system channels with
172
- `events_subscribe_project` or `events_subscribe_user`. See
173
- `docs({ topic: 'live' })`.
174
-
175
- ## "payload is required" from sw.push.send
176
-
177
- `sw.push.send` takes ONE object with the notification nested inside it:
178
- `sw.push.send({ payload: { title, body }, user_id })`. The
179
- two-argument `send(payload, options)` form is not accepted.
180
-
181
- ## Schema changes with explicit SQL
182
-
183
- Schema changes outside `db/schema.ts` go through `db_migrate` with explicit SQL: it takes an automatic
184
- named bookmark before production-targeted statements and applies them atomically,
185
- exactly as written (the platform does not analyze raw migration SQL). In-place
186
- restore is unavailable. Save a copy before migration with `db_dump` or
187
- `POST /v1/db/dump`. Access
188
- rules are set in `db/schema.ts` and take effect on deploy.
189
-
190
- ## "DOMAIN_NOT_VERIFIED" on a custom domain
191
-
192
- This code comes from receiving-mail setup, not from serving the site: a mail
193
- address names a host that is not a receiving host with inbound mail on for this
194
- project. Attach the claimed domain to the project, run
195
- `domain_enable_email({ id })`, then register the address again on its
196
- `receiving_host` (the domain, or reply.<domain> when it has its own mail
197
- provider).
198
-
199
- A domain that does not serve the site yet is a separate check:
200
-
201
- 1. Claimed domain: `domain_check_ns({ id })` shows `claim_status`.
202
- `pending_ns` means the registrar does not yet show the two nameservers
203
- from `domain_claim`; compare them with `dig +short NS <domain>`.
204
- 2. DNS-record domain: `domain_verify({ project_id, domain })` returns
205
- `cname_ok`, `txt_ok` and `next_step`, which names the record that is
206
- missing or wrong. The TXT record is
207
- `_somewhere-verify.<domain>`; check it with
208
- `dig +short TXT _somewhere-verify.<domain>`.
209
- 3. Two TXT records on that name: delete the old one.
210
-
211
- ## A claimed domain is active but does not resolve
212
-
213
- `domain_owned` shows `claim_status: "active"` and `zone_status:
214
- "active"`, but `dig <domain>` returns NXDOMAIN or no answer: the domain's
215
- platform records are incomplete. Repair them with:
216
-
217
- domain_publish({ id })
218
-
219
- It sets the apex and `www` records and the routing again and returns any
220
- `failures`. It is idempotent and never changes the domain's mail records.
221
-
222
- ## "API_KEY is invalid" from sw.ai
223
-
224
- With a dedicated provider key stored for the project
225
- (`somewhere ai keys set <provider> --project <project>` or
226
- `POST /v1/ai/provider-keys`), each completion that
227
- selects that provider reads its current key. After you rotate the key at the
228
- provider, store the new one the same way; the next matching completion uses
229
- it, with no redeploy. A key the provider
230
- rejects returns `UPSTREAM_AUTH_FAILED`.
231
-
232
- Without a dedicated key, `sw.ai` uses platform-managed credentials, which
233
- never reach your deployed code, so a redeploy does not change the result.
234
- Send the error code with `support_ticket`.
235
-
236
- ## An existing hosted workspace shows "Disconnected code=4001"
237
-
238
- The workspace machine is on an outdated agent version. The platform
239
- restart-loops it until either the image gets fixed or the machine is
240
- replaced.
241
-
242
- Fix is on our side. If you hit this, submit a `support_ticket` with your
243
- `project_id` and the error text — it's not user-fixable.
244
-
245
- ## "Origin not allowed" when calling from a custom subdomain
246
-
247
- The project's CORS allowlist doesn't include the origin you're
248
- calling from. By default the platform allows the project's own
249
- `*.somewhere.site` URL plus any verified custom domains for the
250
- project.
251
-
252
- Fix: add the exact origin to the project's allowlist. From the CLI/MCP,
253
- read it with `project_allowed_origins_get` and set the full list with
254
- `project_allowed_origins_set` (owner or platform admin only), e.g.
255
- `somewhere call project_allowed_origins_set '{"project_id":"my-app","allowed_origins":["https://app.example.com"]}'`.
256
- Each entry is an exact origin — scheme + host + optional port, no path or
257
- wildcards. Server-to-server callers can use the `smt_` key.
258
-
259
- ## End-users see "Something went wrong" on my live site
260
-
261
- When the deployed function throws or crashes during a page load, the
262
- platform serves a branded fallback page so visitors never see a raw
263
- infrastructure error or JSON blob. It looks like:
264
-
265
- > # Something went wrong
266
- > The app ran into a problem. Try again in a moment.
267
-
268
- Three things to know:
269
-
270
- 1. **The crash is in your function — read the stack trace.** Every
271
- uncaught exception is captured to your project's logs with the
272
- full stack:
273
- ```
274
- project_logs({ project_id, level: 'error', limit: 20 })
275
- ```
276
- Each row has `data.stack`, `data.path`, `data.method`, `data.route`,
277
- and `data.request_id` (the `cf-ray` you can correlate with deeper
278
- logs if you contact support).
279
- 2. **The fallback only triggers for page loads.** `/api/*` requests
280
- still return JSON to JS callers — your client error handling stays
281
- the same. The branded page only appears when a *page* request
282
- itself fails.
283
- 3. **You can customize the page.** Upload a `_error.html` file (or
284
- `_error/index.html`) in your project. If present, the platform
285
- serves that on any unhandled error instead of the default. Plain
286
- static HTML — no templating, no function dispatch needed.
287
-
288
- ## `somewhere test`: "the browser could not read its own files" (macOS)
289
-
290
- On a Mac, when the project is on an external drive and the command is started by an app that cannot show the macOS permission prompt, macOS refuses the browser the volume it is on (Chromium: "icudtl.dat not found", "GPU process isn't usable"): give that app access to removable volumes (System Settings > Privacy & Security > Files and Folders), or start the command as `node node_modules/@somewhere-cloud/cli/bin/somewhere.js test`.
291
-
292
- ## How to read your error logs
293
-
294
- Read application errors and record your own error messages:
295
-
296
- - **MCP**: `project_logs({ project_id, level: 'error', limit: 50 })` returns
297
- the most recent error rows in JSON. Add `search: '/api/checkout'` to
298
- match message text, `source: 'function'` to select a source, or
299
- `trace_id` to follow one distributed request.
300
- - **From inside a function**: `sw.logs.error(message, data)` writes
301
- a row with source='server'. Use this for known-bad branches your
302
- code handles deliberately.
303
-
304
- What you'll see for an uncaught function exception:
305
-
306
- ```json
307
- {
308
- "level": "error",
309
- "source": "server",
310
- "message": "FUNCTION_ERROR: Cannot read properties of undefined (reading 'id')",
311
- "data": {
312
- "code": "FUNCTION_ERROR",
313
- "stack": "TypeError: Cannot read properties of undefined...\n at handler (api/users.ts:14:18)\n ...",
314
- "request_id": "8f3c1d2a4b5e6789-LHR",
315
- "method": "POST",
316
- "path": "/api/users",
317
- "route": "/api/users",
318
- "slot": "prod"
319
- },
320
- "created_at": 1715551234567
321
- }
322
- ```
323
-
324
- The `stack` field is the single most useful field for debugging — it
325
- tells you the exact file + line in your code where the throw
326
- originated. `CONTEXT_BUILD_FAILED` means the function's project context could
327
- not be assembled before the handler ran. Page-dispatch failures (the function
328
- could not start or timed out) show up with `FUNCTION_DISPATCH_FAILED`; a
329
- runtime that fails before it can answer reports `FUNCTION_RUNTIME_FAILED`
330
- (docs({ topic: 'limits' })); an uncaught
331
- handler exception is `FUNCTION_ERROR`. Match `data.request_id` to the response's
332
- `x-request-id` when tracing one request.
333
-
334
- The platform records the error separately from serving the fallback page.
335
-
336
- Write the HTML with `fs_write` or include it in your next deploy:
337
-
338
- ```html
339
- <!doctype html><h1>my-app is down</h1><p>back in a sec</p>
340
- ```
341
-
342
- The default page is the right call most of the time — only override
343
- when your app's design needs a matching aesthetic.
344
-
345
- ## Find a crashed function's stack
346
-
347
- When a function throws, the caller gets 500 `FUNCTION_ERROR` with a
348
- neutral `message` ("Function handler threw an error."), a `request_id`,
349
- a 32-character `trace_id` (also the `X-Trace-Id` header) and a `hint`
350
- for the developer naming that trace. With CLI 0.37.69 or later, read that one
351
- request:
352
-
353
- ```bash
354
- # Set TRACE_ID to the trace_id from the error response.
355
- somewhere logs --trace "$TRACE_ID"
356
- ```
357
-
358
- It shows the request's lines with the recorded stack, file and line. Logs show
359
- your thrown message exactly as you wrote it, so keep secrets and personal data
360
- out of error messages. `somewhere support packet --trace <trace_id>` builds a
361
- repro packet for that request locally; it leaves out the message, the stack and
362
- the request body, and uploads nothing.
363
-
364
- ## Words for errors: GET /v1/error-words
365
-
366
- `GET /v1/error-words` (no key needed) returns words for common error
367
- codes from one catalogue: `{ words: { CODE: { person, next } } }`. Look
368
- up the `error` code of any platform error answer: show `person` to a
369
- person as it is instead of writing your own wording, and use `next` as the
370
- agent's next step. The answer's own `message` stays the detailed
371
- explanation.
372
-
373
- ## All API errors include a hint field
374
-
375
- Every JSON error from the platform now ships with a `hint` field
376
- that names the most relevant `docs` topic. Read the hint
377
- instead of guessing what to call next:
378
-
379
- ```json
380
- {
381
- "ok": false,
382
- "error": "STALE_RELEASE_BASE",
383
- "message": "This deploy was prepared from release rel_previous, but release rel_current is live now, so nothing was changed. An earlier attempt (for example one that timed out) may already have completed; the project's status and source show whether it did. Otherwise the change applies on top of the current source.",
384
- "data": { "base_release_id": "rel_previous", "active_release_id": "rel_current" },
385
- "hint": "Usage details: docs({ topic: 'deploy' }). Platform bug reports: support_ticket({ message }) returns a ticket_id, and support_ticket({ ticket_id }) returns its response. Advisor: somewhere advisor \"<what you were doing> — <error code>\" (or advisor({ question }) over MCP) explains this error from its code."
386
- }
387
- ```
388
-
389
- Every hint ends with that same advisor line. Put what you were doing
390
- and the error code in the question — the advisor answers best with the
391
- code in hand. The line appears only in API error responses for you and
392
- your agent; the error pages and function errors your app's visitors
393
- see never include it.
394
-
395
- If a hint looks misleading, send `support_ticket({ message })` —
396
- you'll get a ticket_id you can check with `support_ticket({ ticket_id })`.
397
-
398
- A failed MCP tool call that reached the platform also carries `_repro`, a
399
- `somewhere.repro/1` packet built only from typed, validated fields, each when
400
- present: the code, outcome, HTTP status, operation (the tool name), request,
401
- trace and project ids, the platform's retry verdict and `retry_after_ms`, and
402
- the location of an invalid field. Its `omitted` list
403
- names what it leaves out (the message, arguments, tokens, SQL and more), and
404
- `recipe` describes reproducing the same call shape on a disposable test
405
- project. Nothing is sent automatically: review it, and if it shows a platform
406
- bug, pass it as `context` to `support_ticket({ message, context })`. An
407
- error raised before the call reaches the platform, such as an unknown project
408
- name, has no packet. From the CLI (0.37.65 or later),
409
- `somewhere support packet` builds the same kind of packet for the last failed
410
- command, locally, and also records the command and how long it ran;
411
- `--out <file>` writes it as a private file, and nothing is uploaded.
@@ -1,94 +0,0 @@
1
- # Typed functions — one contract, both sides
2
-
3
- Opt in per function. Declare the contract next to the handler; the browser gets
4
- a typed client generated from what you actually deployed, not from a router you
5
- maintain separately.
6
-
7
- ## Server — `api/tasks/create.ts`
8
-
9
- The table it writes, declared in `db/schema.ts`; `somewhere typecheck` types
10
- its rows from this file:
11
-
12
- ```ts
13
- // db/schema.ts
14
- import { schema, table, id, text, owner } from 'somewhere/db'
15
-
16
- export default schema({
17
- tasks: table({ id: id({ uuid: true }), text: text() }, { scope: owner() }),
18
- })
19
- ```
20
-
21
- ```ts
22
- // api/tasks/create.ts
23
- export const typed = 'somewhere:v1' as const
24
- export type Contract = {
25
- input: { text: string }
26
- output:
27
- | { ok: true; task: { id: string; text: string } }
28
- | { ok: false; error: 'TEXT_REQUIRED' | 'TEXT_TOO_LONG' }
29
- }
30
- const MAX_TEXT = 500
31
-
32
- export default (async (req, sw) => {
33
- await sw.auth.requireUser(req) // signed out: 401 before any write
34
- const input: unknown = await req.json().catch(() => null) // the contract is a type, not a check
35
- const raw = typeof input === 'object' && input !== null && 'text' in input ? input.text : undefined
36
- const text = typeof raw === 'string' ? raw.trim() : ''
37
- if (!text) return { ok: false, error: 'TEXT_REQUIRED' }
38
- if (text.length > MAX_TEXT) return { ok: false, error: 'TEXT_TOO_LONG' }
39
- const { data: [task] } = await sw.db.insert('tasks', { text }) // owner column set by the platform
40
- return { ok: true, task: { id: task.id, text: task.text } }
41
- }) satisfies ServerFunction<Contract>
42
- ```
43
-
44
- Three parts, all required: the `typed` sentinel, an exported `Contract` type
45
- with `input` and `output`, and `satisfies ServerFunction<Contract>` on the
46
- default export. A function without the sentinel is a normal function and keeps
47
- working exactly as before — this is additive, never required.
48
- `ServerFunction` is a global type from the platform's generated declarations,
49
- like `SomewhereRuntimeContext`, so there is nothing to import.
50
-
51
- The contract types the call; it does not check what arrives. Read the body as
52
- `unknown` and validate it. A typed function returns its `output` type, so
53
- report an expected refusal as a value in that type, as `{ ok: false, error }`
54
- does here. Errors from platform calls, such as the 401 from
55
- `sw.auth.requireUser`, reach the browser as a `FunctionError` with that
56
- status.
57
-
58
- ## Browser — `src/main.tsx`
59
-
60
- ```ts
61
- import { api } from 'somewhere:api'
62
-
63
- try {
64
- const result = await api.tasks.create({ text: 'ship' })
65
- if (result.ok) console.log('created', result.task.id)
66
- else console.log('not created:', result.error) // TEXT_REQUIRED or TEXT_TOO_LONG
67
- } catch (err) {
68
- if (err instanceof Error && 'status' in err && err.status === 401) console.log('sign in first')
69
- else throw err
70
- }
71
- ```
72
-
73
- `somewhere:api` is a virtual module the platform generates at deploy. The file
74
- path determines the client path and the route: `api/tasks/create.ts` becomes
75
- `api.tasks.create(...)` calling `POST /api/tasks/create`.
76
-
77
- ## What the platform does with it
78
-
79
- Each deploy writes a manifest — one entry per procedure with its file, client
80
- path, route, input type and output type — plus a `contract_digest` over the
81
- whole surface. Because the digest is versioned with the release, the platform
82
- compares the contract you are shipping against the one currently live and warns
83
- when a change would break existing callers. That check is only possible because
84
- the platform holds both the previous and the incoming contract.
85
-
86
- ## Portability — what you take with you
87
-
88
- The contract is plain data at `_internal/typed-functions.json` inside the
89
- release, and your handlers are ordinary async functions with no framework
90
- imports. Porting means keeping the handler bodies and replacing the generated
91
- client with any HTTP client — the routes are the same paths you already see.
92
- There is no adapter to reimplement and no runtime to replace.
93
-
94
- Related: `functions`, `deploy`, `portability`, `sw.db`.
@@ -1,67 +0,0 @@
1
- # Verify before deploy
2
-
3
- Pick the narrowest check that answers the question. These tools are
4
- complementary; a green local typecheck is not a live browser health check.
5
-
6
- | Question | Command | Runs where | Changes live state? |
7
- |---|---|---|---|
8
- | Are TypeScript types and imports coherent? | `somewhere typecheck` | Local `tsc --noEmit` | No |
9
- | Will the real deploy compiler accept this source? | `somewhere deploy-check` | Platform compile pipeline | No |
10
- | Does one handler answer correctly before I deploy? | `somewhere deploy-check --run /api/<path>` | Platform check runner, every plan (Free: 60 per project per hour) | No; never your live database |
11
- | Does a seed/backfill/check script work against real bindings? | `somewhere run <script>` | One-off local module + real bindings | No deploy; may mutate project data |
12
- | Is the deployed page healthy for a real browser? | `somewhere browser <url>` | Live browser | Read/drive only unless your steps submit actions |
13
-
14
- Every deploy is followed by the after-deploy check, at no extra step: it
15
- loads the homepage in a real browser and reports a blank page, or errors the
16
- page throws while loading, as a warning (`access_check` in the deploy log).
17
- A blank or throwing page is never rolled back for you; the release stays live.
18
- When the previous version worked, `access_check.go_back` names it, and
19
- `somewhere restore <version> --project <project_id> --yes`, or over MCP `project_rollback({ project_id, version })` puts it back.
20
- `somewhere verify` adds what one page load cannot show: named flows (clicks, forms, expected requests), the phone
21
- viewport, and screenshots on demand.
22
-
23
- Recommended sequence for a new TypeScript app: `typecheck` → deploy →
24
- `verify`/`browser`. Deploy runs the same compile, schema and secret checks as
25
- `deploy-check`, then applies `db/schema.ts` before the new version goes live;
26
- use `deploy-check` to diagnose a refusal or review a change without
27
- publishing. Add `run` only for a one-off operation against the live project.
28
- A tiny JavaScript app with no `package.json` can skip local typecheck.
29
-
30
- `somewhere dev` serves only the frontend; it runs no backend code, so it
31
- cannot test a handler. Use `deploy-check --run` for that. See the
32
- deploy-check section of docs({ topic: 'cli' }).
33
-
34
- ## Unit tests
35
-
36
- The platform does not run your tests; a deploy compiles and checks the app.
37
- Run unit tests locally, with Vitest for example, on logic that is pure and
38
- easy to get wrong: parsing, pricing, validation, date handling.
39
-
40
- ```bash
41
- npm install -D vitest
42
- npx vitest run
43
- ```
44
-
45
- ```ts
46
- // src/lib/price.ts
47
- export function totalCents(lines: { cents: number; qty: number }[], taxRate: number): number {
48
- const subtotal = lines.reduce((sum, line) => sum + line.cents * line.qty, 0);
49
- return Math.round(subtotal * (1 + taxRate));
50
- }
51
- ```
52
-
53
- ```ts
54
- // src/lib/price.test.ts
55
- import { expect, test } from 'vitest';
56
- import { totalCents } from './price';
57
-
58
- test('adds tax once', () => {
59
- expect(totalCents([{ cents: 1000, qty: 2 }], 0.1)).toBe(2200);
60
- });
61
- ```
62
-
63
- Add `*.test.ts` to `.somewhereignore` so test files are not uploaded; a
64
- test file under `api/` would otherwise become a route. Unit tests check a
65
- function's logic. `deploy-check --run` invokes one handler without
66
- deploying; its database and network access depend on the project (see
67
- `cli`). `somewhere verify` runs a journey in a real browser.
@@ -1,75 +0,0 @@
1
- # somewhere.cloud vs Supabase — honest comparison
2
-
3
- ## When to use somewhere.cloud
4
-
5
- ✓ **You want one platform for the whole backend.** Database + auth + files
6
- + email + payments + AI + cron + background jobs all behind one API and one bill.
7
- Supabase covers database + auth + storage + edge functions; you still
8
- wire Stripe, Resend, Inngest, Pinecone, OpenAI yourself.
9
- ✓ **You're shipping fast** — typically AI-built apps from Claude Code or
10
- Cursor. The MCP server gives the coding agent tools to deploy,
11
- query, and configure without leaving the chat.
12
- ✓ **Payments built in.** Stripe Connect is wired for you — no separate
13
- Stripe/billing integration to stand up. Supabase doesn't offer this.
14
- ✓ **Predictable pricing.** Flat monthly tiers — current ladder at /v1/pricing.
15
- No per-MAU jumps or project caps. Bandwidth is included on every plan. We do not meter it or bill for it. Fair use applies: this covers normal traffic to your app's pages, functions and files.
16
-
17
- ## When to use Supabase
18
-
19
- ✗ **Heavy Postgres dependency you want managed FOR you.** pgvector tuning,
20
- PostGIS, listen/notify, or an extension we don't substitute for. Worth
21
- knowing before you decide: you can attach your own PostgreSQL database here
22
- instead of leaving — any plan, Free included, your provider account and your
23
- bill (`docs({ topic: 'postgres' })`). What Supabase gives you that an
24
- attachment does not is Postgres managed as a product, with their console,
25
- their backups and their support behind it.
26
- ✗ **Existing Supabase project with momentum.** No reason to migrate
27
- for migration's sake.
28
- ✗ **One very large relational database you resize yourself.** Each project
29
- has its own managed SQL database. Managed data grows with your app:
30
- Somewhere handles storage as it grows, measured across your account under
31
- your plan, rather than through a self-serve resize. File contents, platform logs, analytics and
32
- search vectors are stored separately. Attach PostgreSQL when the relational
33
- workload needs it. Moving existing managed tables and their access rules is
34
- separate migration work, not an automatic result of attaching a database.
35
- ✗ **Self-host requirement.** Supabase is open-source and you can
36
- self-host the whole thing. We are not self-hostable.
37
- ✗ **You want Postgres-native client libraries.** PostgREST, postgrest-js,
38
- the broader Postgres tooling ecosystem. An attached database here speaks to
39
- the provider's official driver, not to PostgREST.
40
-
41
- ## What's roughly equivalent
42
-
43
- | Need | somewhere.cloud | Supabase |
44
- |---|---|---|
45
- | Database | `sw.db` (full SQL) | `supabase.from()` (Postgres) |
46
- | Real PostgreSQL | attach your own, `sw.postgres` | built in, managed by them |
47
- | Auth | `sw.auth` (Google, magic link) | `supabase.auth` |
48
- | Storage | `sw.fs` (no egress fees) | `supabase.storage` (S3) |
49
- | Row-level security | `sw.db.from/insert/update` (auto-scoped) | Postgres RLS policies |
50
- | Database change events | developer-side `db_webhook_*` tools | Postgres replication |
51
- | Vector search | `sw.search` (built-in) | pgvector (add-on) |
52
- | Edge functions | every `api/*` file | `/functions/v1/*` |
53
- | Email send/receive | `sw.email` + mail API | not included — wire Resend |
54
- | Payments | `sw.payments` | not included — wire Stripe |
55
- | AI | `sw.ai` (multi-provider proxy) | not included — wire OpenAI |
56
- | Background jobs | `sw.jobs` / `sw.cron` | not included — wire Inngest |
57
- | Pricing | flat tiers — see /v1/pricing | $25/mo Pro + usage |
58
-
59
- ## Migration paths
60
-
61
- → **somewhere.cloud → Supabase**: `db_dump` → load into a database file →
62
- `pgloader` that file into Postgres. Application data comes out in full.
63
- Password export is not available, so users set a password in the new
64
- app; `db_dump` and `auth_users_list` never return password hashes.
65
- See `migration.txt` for the same portability contract.
66
- → **Supabase → somewhere.cloud**: today this is a per-piece migration, and
67
- each piece is its own move — there is no one-shot import, and copying a
68
- database would not carry auth, files or functions with it. Steps:
69
- `pg_dump` → import via `db_migrate` +
70
- `db_import_csv` per table. Auth users: importing users with their
71
- passwords is not available, so each user creates their account again
72
- with the same email. `auth_users_list` is a READ tool and cannot create
73
- users.
74
-
75
- Related: `portability`, `database-engine`, `pricing-comparison`.