@somewhere-cloud/cli 0.38.185 → 0.38.187
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 +12 -0
- package/README.md +1 -1
- package/dist/lib/bundle.js +20 -14
- package/dist/lib/bundle.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.38.187
|
|
4
|
+
|
|
5
|
+
- Test output distinguishes allowed control reads from the requests it expects to refuse.
|
|
6
|
+
- The starter guide explains how to choose team access rules and where to find guidance on server-rendered pages and sitemaps.
|
|
7
|
+
- The starter guide gives the current timing for changes to published rows.
|
|
8
|
+
|
|
9
|
+
## 0.38.186
|
|
10
|
+
|
|
11
|
+
- The starter guide explains team access, publishing drafts and handling updates that change no rows.
|
|
12
|
+
- `somewhere privacy` explains who can see each table and file, and which server calls can bypass those rules.
|
|
13
|
+
- When a test, `somewhere data`, `somewhere test` or `somewhere support` runs in a folder that is not linked to a project, the error names the folder and the command that links it.
|
|
14
|
+
|
|
3
15
|
## 0.38.185
|
|
4
16
|
|
|
5
17
|
- `env set --stdin`, `ai keys set --stdin`, `auth set` and the Postgres key read a pipe written by another program, such as `somewhere call … | somewhere env set KEY --stdin`. A piped value that is not set is kept in a file only you can read, with the command to finish.
|
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ For optional after-edit checking, explicitly run `somewhere hooks install --host
|
|
|
105
105
|
| `somewhere dev` | Frontend hot reload on localhost with your project's own Vite; API requests go to your deployed project |
|
|
106
106
|
| `somewhere preview` | Run your whole app on the platform — every save goes to a private URL, and production is untouched until you promote |
|
|
107
107
|
| `somewhere deploy` | Deploy current directory to linked project |
|
|
108
|
-
| `somewhere privacy` |
|
|
108
|
+
| `somewhere privacy` | Who can see what in the live app: each table and file rule in words, server code that goes beyond them, and outside domains |
|
|
109
109
|
| `somewhere deploy --dry-run` | Upload source to compute the deploy diff without publishing |
|
|
110
110
|
| `somewhere deploy --scope functions` | Deploy backend only (leave the site untouched) |
|
|
111
111
|
| `somewhere deploy --force` | Intentionally overwrite remote changes made since this machine last deployed |
|
package/dist/lib/bundle.js
CHANGED
|
@@ -44301,14 +44301,15 @@ var init_init_agent_guide = __esm({
|
|
|
44301
44301
|
|
|
44302
44302
|
| Does your app verify emails? | Choose the declared access rule |
|
|
44303
44303
|
| --- | --- |
|
|
44304
|
-
|
|
|
44305
|
-
|
|
|
44304
|
+
| Either, teams people join | Use \`group()\` and \`sw.groups\` for invitations, membership and owner/admin permissions, whether or not sign-up verifies emails: an invitee joins by opening the emailed link, which proves the address. See \`somewhere docs sw.groups --section team-example\`. |
|
|
44305
|
+
| Either, a roster the app keeps itself | Only for a relationship that is not a team people join. Use \`member()\` over your own roster table. Scope the roster and the team table with \`member()\` as well, so members read both without server code. For "author or team owner edits", add a second \`member()\` branch with \`where: { role: 'owner' }\`. Creating a team and changing its roster still need a function with \`sw.db.server\`. See \`somewhere docs declared-data --section teams-without-email-verification\`. |
|
|
44306
44306
|
| Yes, staff by domain | Use \`appRole()\` and \`appRoles: { staff: { emailDomain: 'staff.example' } }\`. The address must be verified. |
|
|
44307
|
+
| No, staff by domain | Anyone can sign up with an address they do not own, so tell whoever set the rule. If it stays, declare \`appRoles: { staff: { assignedBy: 'server' } }\`, grant the role once in the sign-up route with \`sw.auth.server.setRoles\`, and keep every staff table on \`appRole()\`. Never compare the address in each handler. See \`somewhere docs sw.auth --section server-assigned-app-roles-setroles\`. |
|
|
44307
44308
|
| No, staff by invitation | Use \`appRole()\` and \`assignedBy: 'server'\`. Redeem an app-issued invitation and call \`sw.auth.server.setRoles\` inside the sign-up route. See \`somewhere docs sw.auth --section server-assigned-app-roles-setroles\`. |
|
|
44308
44309
|
| Either, personal rows | Use \`owner()\`. The platform stamps the owner from the signed-in user. |
|
|
44309
44310
|
| Either, shared private row | Use a read-only \`grant()\` for a known app-user ID. Adding the grant widens existing caller-scoped reads. See \`somewhere docs declared-data --section read-only-sharing-without-email-verification\`. |
|
|
44310
44311
|
| No, share by email address | Without verification, whoever signs up first with an address owns it. Match the existing account, tell the sharer plainly when none exists, and show the sharer that the recipient's address is unverified so they can revoke. For private data, grant the share only after the recipient opens an \`sw.auth.invite\` link sent to that address. See \`somewhere docs declared-data --section sharing-by-email-without-verification\`. |
|
|
44311
|
-
| Either, public pages from private drafts | Use conditional \`client.publicRead\`.
|
|
44312
|
+
| Either, public pages from private drafts | Use conditional \`client.publicRead: { where: { published: true } }\`. A change, an unpublish included, reaches signed-out readers within about a minute, usually within seconds. Publish from a function with caller-scoped \`sw.db.update\`, so the table's update rule decides who may publish. |
|
|
44312
44313
|
|
|
44313
44314
|
### Schema and data
|
|
44314
44315
|
|
|
@@ -44318,9 +44319,9 @@ Existing integer IDs stay integers. Declare composite uniqueness with \`unique:
|
|
|
44318
44319
|
|
|
44319
44320
|
- Browser reads and writes use generated \`somewhere:data\`. \`client\` sets allowed operations and fields. Include the key in explicit read lists. Browser calls throw errors, and list pages use the returned \`next\` as \`after\` (at most 100 rows per page).
|
|
44320
44321
|
- \`anyOf()\` grants access through either branch. \`allOf()\` requires both the membership gate and the action rule. \`parent()\` inherits the parent row's access. Declare \`parent({ author, update, delete })\` on the child table's first deploy. If you display the author's email, use a signed-in creation endpoint that takes the address from the session and leave browser create disabled. For staff replies through \`parent()\`, grant staff create permission on the ticket's rule. See \`somewhere docs declared-data --section comments-that-their-author-may-edit\`.
|
|
44321
|
-
- \`sw.db.from/insert/update/remove\` apply the caller's scope and return \`{ data, count, changes }\`. An insert puts the new row in \`data[0]\`. Use \`where\`, \`columns\`, \`order\`, \`limit\` and \`offset\` for server reads. \`sw.db.tx\` takes an array of write intents. Supply related IDs up front.
|
|
44322
|
-
- Authorize before \`sw.db.server\` calls, which bypass the caller's scope. Keep declared scopes on records users work with, even when an exceptional write needs server authority. Use \`serverOnly()\` for protected ledgers and job state. Raw SQL uses a separate raw database.
|
|
44323
|
-
-
|
|
44322
|
+
- \`sw.db.from/insert/update/remove\` apply the caller's scope and return \`{ data, count, changes }\`. An insert puts the new row in \`data[0]\`. An update or remove that matches no row the caller may change does not throw: it returns \`changes: 0\`, the same for a missing row and a refused one, so an endpoint answers 404 when \`changes\` is 0 instead of reporting success. Use \`where\`, \`columns\`, \`order\`, \`limit\` and \`offset\` for server reads. \`sw.db.tx\` takes an array of write intents. Supply related IDs up front.
|
|
44323
|
+
- Authorize before \`sw.db.server\` calls, which bypass the caller's scope. Keep declared scopes on records users work with, even when an exceptional write needs server authority. Use \`serverOnly()\` for protected ledgers and job state, not to protect a field: a column left out of \`client.create\` and \`client.update\` stays out of the browser's reach, and your functions still write it as the caller. Raw SQL uses a separate raw database.
|
|
44324
|
+
- To find the declared rule for a need (a row two people share, a team's rows, something public that can be withdrawn, an action only one role may take, work with no signed-in user, a count or limit, an invite), see \`somewhere docs architecture-patterns --section access-rules-by-what-the-app-needs\`. Two parties on one row: \`somewhere docs sw.db --section provider-or-booker-and-owner-or-staff-recipes\`. For browser paging, server paging and transactions, see \`somewhere docs sw.db\`.
|
|
44324
44325
|
|
|
44325
44326
|
Use \`client.intake\` for public submissions to a private parent row. See
|
|
44326
44327
|
\`somewhere docs declared-data\` for intake, scoped writes and related rows.
|
|
@@ -44328,10 +44329,11 @@ Use \`client.intake\` for public submissions to a private parent row. See
|
|
|
44328
44329
|
### Routes and auth
|
|
44329
44330
|
|
|
44330
44331
|
- Add React pages where your app handles navigation. To serve a dynamic endpoint such as \`/api/notes/:id\`, create \`api/notes/[id].ts\`. A root \`[...path].ts\` handles document routes, including \`/\`. Underscore-prefixed files are import-only helpers.
|
|
44332
|
+
- A page search engines and link previews must read (an article, a public profile) is server-rendered: return its HTML from the root \`[...path].ts\`. The generated sitemap lists only deployed HTML files, so supply a sitemap with those URLs. See \`somewhere docs recipe-seo --section 5-server-rendered-pages-and-redirects\` and \`--section 3-sitemap-and-robots\`.
|
|
44331
44333
|
- JSON routes use \`sw.endpoint({ auth, body, rateLimit, handler })\`. Set \`auth\` to \`'required'\`, \`'optional'\` or \`'none'\`. Use a limit like \`'30/minute'\`. Read route parameters from the handler's \`params\`. Use a default handler or named HTTP method exports. For streaming, webhooks or custom responses, use a bare \`(req, sw)\` handler and \`sw.params\`. See \`somewhere docs functions\`.
|
|
44332
44334
|
- Keep the SDK auth handler at \`api/auth/[...path].ts\` when your app uses sign-in. Gate private UI on auth state. Password sign-up starts unverified, and signed-in unverified users pass \`auth: 'required'\`. See \`somewhere docs auth-client\`.
|
|
44333
44335
|
- Mail from the app's built-in address reaches only the owner and app users who verified their email and signed in. Password sign-up starts unverified: if the app emails its users (confirmations, reminders), keep the starter's "Verify your email" step, or verify your own sender domain. See \`somewhere docs sw.email\`.
|
|
44334
|
-
- When users must see each other's changes without reloading (a queue, chat or status board), do not poll. Return the list through \`sw.rooms.live\` and follow it in the page with \`watchLive\`. See \`somewhere docs live --section realtime-live-updates-two-users-see-the-same-change\`.
|
|
44336
|
+
- When users must see each other's changes without reloading (a queue, chat or status board), do not poll. Return the list through \`sw.rooms.live\` and follow it in the page with \`watchLive\`. See \`somewhere docs live --section realtime-live-updates-two-users-see-the-same-change\`. Live updates need a claimed app: on a temporary app, poll a function every few seconds until it is claimed.
|
|
44335
44337
|
- Render a view when the reads it depends on finish. Keep inputs disabled until their initial data and identity are ready, and preserve edits when a late response arrives.
|
|
44336
44338
|
- Browser requests use same-origin cookies. For scripted writes with a cookie session, send the app's origin in the \`Origin\` header. Use the CLI test helper to send data endpoint calls with the deployed contract digest. For an update, use \`data(table, { operation: 'update', id, values: { title } })\`.
|
|
44337
44339
|
|
|
@@ -74199,7 +74201,7 @@ var init_platform_tools = __esm({
|
|
|
74199
74201
|
|
|
74200
74202
|
// dist/commands/privacy.js
|
|
74201
74203
|
function registerPrivacy(program2) {
|
|
74202
|
-
program2.command("privacy").description("
|
|
74204
|
+
program2.command("privacy").description("Who can see what in the live app: each table and file rule in words, server code that goes beyond them, and outside domains").option("-p, --project <project>", "Project slug or ID").option("--json", "Print the release record as JSON").action(async (opts) => {
|
|
74203
74205
|
try {
|
|
74204
74206
|
const data2 = unwrapPlatformData(await callPlatformTool("project_privacy_facts", {
|
|
74205
74207
|
project_id: resolveProjectRef(opts.project)
|
|
@@ -78819,7 +78821,7 @@ function formatChecksReport(check) {
|
|
|
78819
78821
|
const coverage = check?.not_checked ?? null;
|
|
78820
78822
|
if (coverage) {
|
|
78821
78823
|
if (typeof check?.routes_discovered === "number")
|
|
78822
|
-
lines.push(check.routes_checked ? `${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.` : `This check called none of your ${check.routes_discovered} app routes
|
|
78824
|
+
lines.push(check.routes_checked ? `${check.routes_checked} of ${check.routes_discovered} app routes had a completed read check.` : `This check called none of your ${check.routes_discovered} app routes. To have it call them after every deploy, add them as steps to a checks/<name>.json list: ${cliInvocation()} docs test --section the-after-deploy-check-list.`);
|
|
78823
78825
|
const { routes_without_read_check: reads, routes_without_write_check: writes, schedules_not_run: schedules, other } = coverage;
|
|
78824
78826
|
if (reads === null || writes === null)
|
|
78825
78827
|
lines.push("App route coverage could not be listed.");
|
|
@@ -136982,7 +136984,7 @@ function registerData(program2) {
|
|
|
136982
136984
|
}
|
|
136983
136985
|
const projectId = loadProjectConfig()?.project_id;
|
|
136984
136986
|
if (!projectId)
|
|
136985
|
-
throw new Error("Run somewhere data from a linked project folder.");
|
|
136987
|
+
throw new Error("Run somewhere data from a linked project folder." + unlinkedFolderHint());
|
|
136986
136988
|
const target = await loadTestTarget(new ApiClient(getToken()), projectId);
|
|
136987
136989
|
const origin = new URL(target.origin);
|
|
136988
136990
|
if (origin.protocol !== "https:" && !["localhost", "127.0.0.1", "[::1]"].includes(origin.hostname)) {
|
|
@@ -137013,6 +137015,7 @@ var init_data = __esm({
|
|
|
137013
137015
|
init_config();
|
|
137014
137016
|
init_prepared_actor_session();
|
|
137015
137017
|
init_test_target();
|
|
137018
|
+
init_link_hint();
|
|
137016
137019
|
__name(parseJson, "parseJson");
|
|
137017
137020
|
__name(registerData, "registerData");
|
|
137018
137021
|
}
|
|
@@ -137231,7 +137234,7 @@ function registerTest(program2) {
|
|
|
137231
137234
|
const root = process.cwd();
|
|
137232
137235
|
const projectId = loadProjectConfig()?.project_id;
|
|
137233
137236
|
if (!projectId)
|
|
137234
|
-
throw new Error("Run somewhere test from a linked project folder");
|
|
137237
|
+
throw new Error("Run somewhere test from a linked project folder." + unlinkedFolderHint());
|
|
137235
137238
|
if (opts.only !== void 0 && (files.length || opts.preview || opts.failed)) {
|
|
137236
137239
|
throw new Error("--only runs a single part of the hosted smoke check. Use it without file arguments, --preview, or --failed.");
|
|
137237
137240
|
}
|
|
@@ -137297,6 +137300,7 @@ var init_test = __esm({
|
|
|
137297
137300
|
"use strict";
|
|
137298
137301
|
init_client();
|
|
137299
137302
|
init_config();
|
|
137303
|
+
init_link_hint();
|
|
137300
137304
|
init_test_run();
|
|
137301
137305
|
init_test_timeline();
|
|
137302
137306
|
init_reference_check_note();
|
|
@@ -137716,7 +137720,7 @@ async function tracePacket(opts) {
|
|
|
137716
137720
|
throw new Error(projectRefConflictMessage(chosen));
|
|
137717
137721
|
const projectId = chosen.kind === "ref" ? chosen.ref : loadProjectConfig()?.project_id;
|
|
137718
137722
|
if (!projectId)
|
|
137719
|
-
throw new Error("No project. Pass --project <ref> or run from a linked directory.");
|
|
137723
|
+
throw new Error("No project. Pass --project <ref> or run from a linked directory." + unlinkedFolderHint());
|
|
137720
137724
|
const result = await new ApiClient(getToken()).call("GET", "/logs", void 0, { project_id: projectId, trace_id: traceId, limit: 50 });
|
|
137721
137725
|
const record3 = buildCrashRecord(result.logs, { cliVersion: CLI_VERSION2, traceId, projectId });
|
|
137722
137726
|
if (!record3) {
|
|
@@ -137770,6 +137774,7 @@ var init_support = __esm({
|
|
|
137770
137774
|
init_cli_invocation();
|
|
137771
137775
|
init_client();
|
|
137772
137776
|
init_config();
|
|
137777
|
+
init_link_hint();
|
|
137773
137778
|
init_output();
|
|
137774
137779
|
init_project_ref();
|
|
137775
137780
|
init_repro_packet();
|
|
@@ -139285,7 +139290,7 @@ async function openTestApp(options2 = {}) {
|
|
|
139285
139290
|
const root = resolve26(options2.projectDir ?? process.cwd());
|
|
139286
139291
|
const projectId = loadProjectConfig(root)?.project_id;
|
|
139287
139292
|
if (!projectId)
|
|
139288
|
-
throw new Error(
|
|
139293
|
+
throw new Error(`No linked Somewhere app in ${root} (no .somewhere.json): run the test from the folder you deploy from, or pass projectDir.` + unlinkedFolderHint());
|
|
139289
139294
|
const setup = options2.preview ? previewCredentialFor(root, projectId) : void 0;
|
|
139290
139295
|
const tool = setup && previewToolClient(setup.credential);
|
|
139291
139296
|
const client = tool ? void 0 : new ApiClient(testingDeveloperToken(), projectId);
|
|
@@ -139563,7 +139568,7 @@ async function openTestApp(options2 = {}) {
|
|
|
139563
139568
|
const reads = requests.filter((request2) => request2[0] === "GET" || request2[0] === "DATA" && (request2[2].operation === "get" || request2[2].operation === "list"));
|
|
139564
139569
|
const controls = await Promise.allSettled(reads.map((request2) => send(options3.control, request2)));
|
|
139565
139570
|
controls.forEach((settled, i) => {
|
|
139566
|
-
const line = `${label}: control ${options3.control.name} ${named2(reads[i])}`;
|
|
139571
|
+
const line = `${label}: control ${options3.control.name} was allowed ${named2(reads[i])}`;
|
|
139567
139572
|
if (settled.status === "rejected") {
|
|
139568
139573
|
all = results.check(line, false, settled.reason) && all;
|
|
139569
139574
|
return;
|
|
@@ -139778,6 +139783,7 @@ var init_testing_app = __esm({
|
|
|
139778
139783
|
init_client();
|
|
139779
139784
|
init_form_accounts();
|
|
139780
139785
|
init_config();
|
|
139786
|
+
init_link_hint();
|
|
139781
139787
|
init_preview_credential();
|
|
139782
139788
|
init_test_control();
|
|
139783
139789
|
init_test_identities();
|