@somewhere-cloud/cli 0.38.181 → 0.38.182
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 +5 -0
- package/dist/commands/init.js +1 -1
- package/dist/lib/bundle.js +63 -107
- package/dist/lib/bundle.js.map +2 -2
- package/dist/types/lib/client.d.ts +6 -1
- package/dist/types/lib/test-control.d.ts +1 -1
- package/dist/types/lib/test-session.d.ts +3 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/runtime/DECLARED-DATA-VENDOR.json +7 -7
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/declared-data.cjs +5 -3
package/CHANGELOG.md
CHANGED
package/dist/commands/init.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { loadEntry } from "../lib/bundle.js";
|
|
2
2
|
const entry = loadEntry("commands/init.js");
|
|
3
3
|
export const { linkExisting, registerInit, runInit, writeInitSkills } = entry;
|
|
4
|
-
const DEFAULT_AUTH_SELECTION = { requested: ['auth'
|
|
4
|
+
const DEFAULT_AUTH_SELECTION = { requested: ['auth'], added: [], modules: ['auth'], ui: 'styled' };
|
package/dist/lib/bundle.js
CHANGED
|
@@ -34013,13 +34013,15 @@ var init_client = __esm({
|
|
|
34013
34013
|
static {
|
|
34014
34014
|
__name(this, "ApiClient");
|
|
34015
34015
|
}
|
|
34016
|
+
linkedProjectId;
|
|
34016
34017
|
/** Mutable: the refresh-on-401 path swaps in a fresh access key in place so
|
|
34017
34018
|
* the retry (and every later call on this instance) uses the new token. */
|
|
34018
34019
|
/** null: an unauthenticated client (no Authorization header, never a
|
|
34019
34020
|
* stored-login refresh), for the public anonymous-deploy routes. */
|
|
34020
34021
|
token;
|
|
34021
34022
|
temporaryConfig;
|
|
34022
|
-
constructor(token) {
|
|
34023
|
+
constructor(token, linkedProjectId) {
|
|
34024
|
+
this.linkedProjectId = linkedProjectId;
|
|
34023
34025
|
this.token = token;
|
|
34024
34026
|
const saved = token === null ? null : loadConfig();
|
|
34025
34027
|
this.temporaryConfig = saved?.temporary && saved.token === token ? saved : null;
|
|
@@ -34033,6 +34035,25 @@ var init_client = __esm({
|
|
|
34033
34035
|
this.checkTemporaryExpiry();
|
|
34034
34036
|
return this.token === null ? {} : { Authorization: `Bearer ${this.token}` };
|
|
34035
34037
|
}
|
|
34038
|
+
/** A refusal for a target selected from .somewhere.json may identify only
|
|
34039
|
+
* the caller. Its status and code cannot distinguish a missing project
|
|
34040
|
+
* from one the caller cannot access. Explicit project refs omit this context. */
|
|
34041
|
+
async linkedProjectError(error3, path3, body, query) {
|
|
34042
|
+
const id = this.linkedProjectId;
|
|
34043
|
+
if (!id || this.token === null || !(error3 instanceof CliApiError) || error3.statusCode !== 404 || error3.code !== "PROJECT_NOT_FOUND")
|
|
34044
|
+
return error3;
|
|
34045
|
+
const target = `/projects/${encodeURIComponent(id)}`;
|
|
34046
|
+
if (path3 !== target && !path3.startsWith(target + "/") && query?.project_id !== id && !(body && typeof body === "object" && "project_id" in body && body.project_id === id))
|
|
34047
|
+
return error3;
|
|
34048
|
+
const identity = await this.call("GET", "/auth/whoami", void 0, void 0, { timeoutMs: 3e3, refresh: false }).then((answer) => {
|
|
34049
|
+
if (typeof answer?.user?.email !== "string")
|
|
34050
|
+
return "";
|
|
34051
|
+
const match = /^([a-z0-9])[^@\s]*@([a-z0-9])[^@\s]*$/i.exec(answer.user.email);
|
|
34052
|
+
return match ? ` Signed in as ${match[1]}\u2026@${match[2]}\u2026.` : "";
|
|
34053
|
+
}).catch(() => "");
|
|
34054
|
+
error3.message = `This sign-in cannot open the project in this folder's .somewhere.json.${identity} Check whether the folder was linked with a different account or CLI configuration.`;
|
|
34055
|
+
return error3;
|
|
34056
|
+
}
|
|
34036
34057
|
/** Run a one-off script against the project's live DEV bindings via the
|
|
34037
34058
|
* dedicated runner worker. Same auth + `{ ok, data }` envelope as call(), but
|
|
34038
34059
|
* rooted at RUNNER_BASE_URL instead of the /v1 API (see that constant for the
|
|
@@ -34067,11 +34088,13 @@ var init_client = __esm({
|
|
|
34067
34088
|
if (err instanceof CliApiError && err.statusCode === 401)
|
|
34068
34089
|
this.checkTemporaryExpiry();
|
|
34069
34090
|
if (!(err instanceof CliApiError) || err.code !== "API_KEY_EXPIRED" || opts?.refresh === false || this.token === null)
|
|
34070
|
-
throw err;
|
|
34091
|
+
throw await this.linkedProjectError(err, path3, body, query);
|
|
34071
34092
|
const refreshed = await this.refreshAccessKey(opts?.timeoutMs);
|
|
34072
34093
|
if (!refreshed)
|
|
34073
34094
|
throw err;
|
|
34074
|
-
return await this.request(method, path3, body, query, opts)
|
|
34095
|
+
return await this.request(method, path3, body, query, opts).catch(async (retryError) => {
|
|
34096
|
+
throw await this.linkedProjectError(retryError, path3, body, query);
|
|
34097
|
+
});
|
|
34075
34098
|
}
|
|
34076
34099
|
}
|
|
34077
34100
|
/** Authenticated request whose body and response remain streams. The body is
|
|
@@ -44255,7 +44278,7 @@ Existing integer IDs stay integers. Declare composite uniqueness with \`unique:
|
|
|
44255
44278
|
|
|
44256
44279
|
- 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).
|
|
44257
44280
|
- \`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\`.
|
|
44258
|
-
- \`sw.db.from/insert/update/remove\` apply the caller's scope and return \`{ data, count, changes }\`. Use \`where\`, \`columns\`, \`order\`, \`limit\` and \`offset\` for server reads. \`sw.db.tx\` takes an array of write intents. Supply related IDs up front.
|
|
44281
|
+
- \`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.
|
|
44259
44282
|
- 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.
|
|
44260
44283
|
- For booking and help desk schemas, see \`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\`.
|
|
44261
44284
|
|
|
@@ -44268,7 +44291,7 @@ Use \`client.intake\` for public submissions to a private parent row. See
|
|
|
44268
44291
|
- 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\`.
|
|
44269
44292
|
- 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\`.
|
|
44270
44293
|
- 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.
|
|
44271
|
-
- 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.
|
|
44294
|
+
- 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 } })\`.
|
|
44272
44295
|
|
|
44273
44296
|
### Run and verify
|
|
44274
44297
|
|
|
@@ -44586,16 +44609,12 @@ function createGreenTemplate(appName = "somewhere-starter") {
|
|
|
44586
44609
|
},
|
|
44587
44610
|
{ path: "src/App.tsx", content: APP },
|
|
44588
44611
|
{ path: "src/main.tsx", content: MAIN },
|
|
44589
|
-
{ path: "src/services/greeting.ts", content: SERVICE },
|
|
44590
44612
|
{ path: "src/styles.css", content: STYLES },
|
|
44591
|
-
{ path: "api/greeting.ts", content: API },
|
|
44592
44613
|
{ path: "api/auth/[...path].ts", content: "export { somewhereAuth as default } from '@somewhere-cloud/sdk/server';\n" },
|
|
44593
|
-
{ path: "db/schema.ts", content: SCHEMA },
|
|
44594
|
-
{ path: "types/app.ts", content: APP_TYPES },
|
|
44595
44614
|
ASSET_TYPES_FILE
|
|
44596
44615
|
];
|
|
44597
44616
|
}
|
|
44598
|
-
var packageJson, TSCONFIG,
|
|
44617
|
+
var packageJson, TSCONFIG, APP, MAIN, STYLES, README;
|
|
44599
44618
|
var init_init_green_template = __esm({
|
|
44600
44619
|
"dist/lib/init-green-template.js"() {
|
|
44601
44620
|
"use strict";
|
|
@@ -44648,67 +44667,11 @@ var init_init_green_template = __esm({
|
|
|
44648
44667
|
"include": ["src", "api", "db", "types", "*.ts"]
|
|
44649
44668
|
}
|
|
44650
44669
|
`;
|
|
44651
|
-
|
|
44652
|
-
message: string;
|
|
44653
|
-
}
|
|
44654
|
-
`;
|
|
44655
|
-
SCHEMA = `// Starter table. To replace the greeting with your app, declare your own tables here
|
|
44656
|
-
// (a schema needs at least one) and delete the greeting files: api/greeting.ts,
|
|
44657
|
-
// src/services/greeting.ts, types/app.ts and the greeting code in src/App.tsx. Then:
|
|
44658
|
-
// - Never deployed: delete the greetings table below.
|
|
44659
|
-
// - Already deployed: replace it with \`greetings: removedTable()\` (import removedTable
|
|
44660
|
-
// from 'somewhere/db'). The deploy retires it and keeps its rows for 30 days;
|
|
44661
|
-
// declaring it again within 30 days restores them. Leave it declared to keep it.
|
|
44662
|
-
// - Unsure: delete it and run \`somewhere deploy-check .\`. A deployed table is refused
|
|
44663
|
-
// with SCHEMA_DEPLOY_REFUSED naming it and nothing changes; then use removedTable().
|
|
44664
|
-
import { id, schema, serverOnly, table, text } from 'somewhere/db';
|
|
44665
|
-
|
|
44666
|
-
export default schema({
|
|
44667
|
-
greetings: table({
|
|
44668
|
-
id: id(),
|
|
44669
|
-
message: text({ default: 'Your full-stack app is ready.' }),
|
|
44670
|
-
}, {
|
|
44671
|
-
scope: serverOnly(),
|
|
44672
|
-
}),
|
|
44673
|
-
});
|
|
44674
|
-
`;
|
|
44675
|
-
API = `// Starter endpoint. To remove the greeting, follow the steps at the top of db/schema.ts.
|
|
44676
|
-
export default sw.endpoint({
|
|
44677
|
-
auth: 'none', // deliberate: public and read-only; anyone can fetch the greeting
|
|
44678
|
-
handler: async (_input, sw) => {
|
|
44679
|
-
const result = await sw.db.from('greetings', { limit: 1 });
|
|
44680
|
-
const message = result.data[0]?.message;
|
|
44681
|
-
return { message: typeof message === 'string' ? message : 'Your full-stack app is ready.' };
|
|
44682
|
-
},
|
|
44683
|
-
});
|
|
44684
|
-
`;
|
|
44685
|
-
SERVICE = `import type { GreetingResponse } from '../../types/app';
|
|
44686
|
-
|
|
44687
|
-
export async function loadGreeting(): Promise<GreetingResponse> {
|
|
44688
|
-
const response = await fetch('/api/greeting');
|
|
44689
|
-
if (!response.ok) throw new Error(\`Request failed (\${response.status})\`);
|
|
44690
|
-
return response.json() as Promise<GreetingResponse>;
|
|
44691
|
-
}
|
|
44692
|
-
`;
|
|
44693
|
-
APP = `import { useEffect, useState } from 'react';
|
|
44694
|
-
import { loadGreeting } from './services/greeting';
|
|
44695
|
-
|
|
44696
|
-
export function App() {
|
|
44697
|
-
const [message, setMessage] = useState('Connecting frontend, function, and database\u2026');
|
|
44698
|
-
|
|
44699
|
-
useEffect(() => {
|
|
44700
|
-
void loadGreeting()
|
|
44701
|
-
.then((result) => setMessage(result.message))
|
|
44702
|
-
.catch((error: unknown) => {
|
|
44703
|
-
setMessage(error instanceof Error ? error.message : 'Could not load the greeting.');
|
|
44704
|
-
});
|
|
44705
|
-
}, []);
|
|
44706
|
-
|
|
44670
|
+
APP = `export function App() {
|
|
44707
44671
|
return (
|
|
44708
44672
|
<main>
|
|
44709
44673
|
<p className="eyebrow">somewhere.cloud starter</p>
|
|
44710
|
-
<h1>Start
|
|
44711
|
-
<p className="message">{message}</p>
|
|
44674
|
+
<h1>Start building your app.</h1>
|
|
44712
44675
|
<p className="hint">Edit <code>src/App.tsx</code>, then deploy the raw source.</p>
|
|
44713
44676
|
</main>
|
|
44714
44677
|
);
|
|
@@ -44736,7 +44699,6 @@ body { margin: 0; min-width: 320px; }
|
|
|
44736
44699
|
main { width: min(720px, calc(100% - 32px)); margin: 14vh auto; }
|
|
44737
44700
|
h1 { max-width: 660px; margin: 12px 0 24px; font-size: clamp(2.7rem, 8vw, 5.5rem); line-height: .94; letter-spacing: -.06em; }
|
|
44738
44701
|
.eyebrow { color: #14734c; font-weight: 750; text-transform: uppercase; letter-spacing: .12em; }
|
|
44739
|
-
.message { padding: 20px 22px; border: 1px solid #c6d8ce; border-radius: 16px; background: rgba(255, 255, 255, .82); }
|
|
44740
44702
|
.hint { color: #4f665b; }
|
|
44741
44703
|
code { color: #0e6542; }
|
|
44742
44704
|
`;
|
|
@@ -44744,19 +44706,11 @@ code { color: #0e6542; }
|
|
|
44744
44706
|
|
|
44745
44707
|
${PROJECT_LINK_README}
|
|
44746
44708
|
|
|
44747
|
-
|
|
44748
|
-
|
|
44749
|
-
|
|
44750
|
-
the greeting message; add caller authorization before serving private data.
|
|
44751
|
-
The SDK and \`api/auth/[...path].ts\` are included; add your sign-in UI or use
|
|
44752
|
-
\`somewhere init --template auth\` for the complete sign-in screens.
|
|
44709
|
+
Start with a React page and the SDK auth route at \`api/auth/[...path].ts\`.
|
|
44710
|
+
Edit \`src/App.tsx\` to build your UI, or choose \`somewhere init --template auth\`
|
|
44711
|
+
when you want generated sign-in screens.
|
|
44753
44712
|
|
|
44754
|
-
|
|
44755
|
-
they cover a table that was never deployed, one that was, and not knowing
|
|
44756
|
-
which. A missing optional include directory is harmless.
|
|
44757
|
-
|
|
44758
|
-
The greeting's \`serverOnly()\` scope demonstrates a trusted public endpoint;
|
|
44759
|
-
it is not the default for your app's data. Choose fitting declared access
|
|
44713
|
+
Choose fitting declared access
|
|
44760
44714
|
before the first deploy: \`owner()\` for personal rows, \`group()\` for teams,
|
|
44761
44715
|
and \`anyOf()\` for combined access. For booking and help-desk rules, read:
|
|
44762
44716
|
\`somewhere docs sw.db --section provider-or-booker-and-owner-or-staff-recipes\`
|
|
@@ -48641,13 +48595,13 @@ export const SHOW_EMAIL_VERIFICATION = false;
|
|
|
48641
48595
|
}
|
|
48642
48596
|
function schemaTs(privateData, agent) {
|
|
48643
48597
|
if (!agent)
|
|
48644
|
-
return
|
|
48598
|
+
return SCHEMA;
|
|
48645
48599
|
const imports = `import { id, owner, schema, table, text, timestamp } from 'somewhere/db';
|
|
48646
48600
|
|
|
48647
48601
|
`;
|
|
48648
48602
|
if (!privateData)
|
|
48649
48603
|
return imports + AGENT_SCHEMA_NOTE + "export default schema({\n" + AGENT_TABLES + "});\n";
|
|
48650
|
-
const notes =
|
|
48604
|
+
const notes = SCHEMA.slice(SCHEMA.indexOf("// notes:"));
|
|
48651
48605
|
return imports + AGENT_SCHEMA_NOTE + notes.replace(/\n\}\);\n$/, "\n" + AGENT_TABLES + "});\n");
|
|
48652
48606
|
}
|
|
48653
48607
|
function homePage(privateData, agent) {
|
|
@@ -48877,7 +48831,7 @@ function createFeatureTemplate(selection, options2) {
|
|
|
48877
48831
|
}
|
|
48878
48832
|
return files;
|
|
48879
48833
|
}
|
|
48880
|
-
var packageJson2, TSCONFIG2, AUTH_API, AUTH_TYPES, PROVIDER_SIGN_IN_HOOK, AUTH_CALLBACK_PAGE, AUTH_SERVICE, AUTH_HOOKS, ROUTES, APP2,
|
|
48834
|
+
var packageJson2, TSCONFIG2, AUTH_API, AUTH_TYPES, PROVIDER_SIGN_IN_HOOK, AUTH_CALLBACK_PAGE, AUTH_SERVICE, AUTH_HOOKS, ROUTES, APP2, SCHEMA, NOTES_TYPES, NOTES_SERVICE, USE_NOTES, AGENT_TABLES, AGENT_SCHEMA_NOTE, CHAT_API, PROPOSALS_API, ASSISTANT_TYPES, ASSISTANT_SERVICE, USE_ASSISTANT, ASSISTANT_FIXTURES, ASSISTANT_FIXTURES_PAGE, ASSISTANT_FIXTURES_FLOW, STYLED_ASSISTANT_PANEL, PLAIN_ASSISTANT_PANEL, MFA_HOOK, MFA_VIEW, SIGN_IN_PAGE, SIGNED_IN_LAYOUT, NOTE_DETAIL_PAGE, DETAIL_PAGE, NOT_FOUND_PAGE, STYLED_FEEDBACK, STYLED_APP_SHELL, STYLED_NOTES_BOARD, PLAIN_FEEDBACK, PLAIN_APP_SHELL, PLAIN_NOTES_BOARD, NOTES_CSS, ASSISTANT_CSS, MAGIC_LINK_TYPES, MAGIC_LINK_HOOKS, CONNECTION_RETURN, MAGIC_LINK_PAGE, MAGIC_SIGN_IN_PAGE, STYLED_MAGIC_LINK, PLAIN_MAGIC_LINK, FORGOT_PASSWORD_API, RESET_PASSWORD_API, PASSWORD_RESET_PAGE, VERIFY_EMAIL_HOOK, PLAIN_VERIFY_EMAIL;
|
|
48881
48835
|
var init_init_feature_template = __esm({
|
|
48882
48836
|
"dist/lib/init-feature-template.js"() {
|
|
48883
48837
|
"use strict";
|
|
@@ -49380,7 +49334,7 @@ function PrivateRoutes({ user }: { user: User }) {
|
|
|
49380
49334
|
__name(mainTsx, "mainTsx");
|
|
49381
49335
|
__name(mainTsxWithFixtures, "mainTsxWithFixtures");
|
|
49382
49336
|
__name(configTs, "configTs");
|
|
49383
|
-
|
|
49337
|
+
SCHEMA = `import { id, owner, schema, table, text } from 'somewhere/db';
|
|
49384
49338
|
|
|
49385
49339
|
// notes: owner() gives each signed-in user their own rows through the
|
|
49386
49340
|
// generated somewhere:data client, so the browser code sends no user filter.
|
|
@@ -51980,7 +51934,7 @@ the SDK client in src/services/auth.ts, hooks in src/auth/, pages in src/pages/,
|
|
|
51980
51934
|
replaceable views in src/ui/ and styles in src/styles/, plus an AGENTS.md workflow
|
|
51981
51935
|
(deploy, then test). Sign-in and invitation links (sw.auth.invite) open
|
|
51982
51936
|
/auth/magic, which the starter routes before the sign-in gate.
|
|
51983
|
-
\`--template minimal\` includes the SDK and auth route without sign-in screens.
|
|
51937
|
+
\`--template minimal\` includes the SDK and auth route without sign-in screens. Add the notes example with --features auth,private-data.
|
|
51984
51938
|
Init installs React, the SDK and editor types. The platform builds your source when you deploy.
|
|
51985
51939
|
TypeScript is fetched when first needed. Vite and Playwright are installed only if you choose to use them.
|
|
51986
51940
|
New starters and --bare also install agent skills in .agents/skills, pinned by skills-lock.json.
|
|
@@ -52446,7 +52400,7 @@ var init_init = __esm({
|
|
|
52446
52400
|
init_output();
|
|
52447
52401
|
INSTALL_STARTER_MESSAGE = "Installing the starter's pinned dependencies with `npm install` (downloads from npm and runs package install scripts)\u2026";
|
|
52448
52402
|
INIT_TEMPLATES = ["auth", "minimal", "bare"];
|
|
52449
|
-
DEFAULT_AUTH_SELECTION = { requested: ["auth"
|
|
52403
|
+
DEFAULT_AUTH_SELECTION = { requested: ["auth"], added: [], modules: ["auth"], ui: "styled" };
|
|
52450
52404
|
__name(registerInit, "registerInit");
|
|
52451
52405
|
__name(runInit, "runInit");
|
|
52452
52406
|
__name(planFeatures, "planFeatures");
|
|
@@ -75204,7 +75158,7 @@ var init_typecheck = __esm({
|
|
|
75204
75158
|
PAGE_LIMIT_EXPLANATION = "A data list call reads at most 100 rows: limit must be a number from 1 to 100. Read further pages with { after: page.next } while page.has_more is true.";
|
|
75205
75159
|
__name(explainPageLimit, "explainPageLimit");
|
|
75206
75160
|
DIAGNOSTIC_HINTS = [
|
|
75207
|
-
{ matches: /SomewhereDb(?:Caller)?WriteIntent|__SomewhereDbIntentFor|readonly.*WriteIntent/, hint: `Pass write intents as an array, e.g. sw.db.tx([{ op: "insert", table: "notes", values: { title } }]). For a separately declared array, use satisfies Parameters<typeof sw.db.tx>[0] to check the operation, table and columns where you declare it. Use the type of sw.db.server.tx for server writes. ${cliInvocation()} docs sw.db --section swdbtxintents-all-or-nothing-composed-writes` },
|
|
75161
|
+
{ matches: /SomewhereDb(?:Caller)?WriteIntent|__SomewhereDbIntentFor|readonly.*WriteIntent/, hint: `Pass write intents as an array, e.g. sw.db.tx([{ op: "insert", table: "notes", values: { title } }]). For a separately declared array, use satisfies Parameters<typeof sw.db.tx>[0] to check the operation, table and columns where you declare it. An inline array or an explicit as const also preserves literal operation and table names. Use the type of sw.db.server.tx for server writes. ${cliInvocation()} docs sw.db --section swdbtxintents-all-or-nothing-composed-writes` },
|
|
75208
75162
|
{ matches: /Expected 2 arguments, but got 3/, hint: `Database update shape: sw.db.update(table, { where: { id }, set: { title } }). ${cliInvocation()} docs sw.db --section builder-verbs-and-where-shapes` },
|
|
75209
75163
|
{ matches: /\border\b.*does not exist|limit\?: undefined|A data list call reads at most 100/, hint: "Browser list: limit 1\u2013100; paginate with after. Sort in the client or use a server endpoint." },
|
|
75210
75164
|
{ matches: /`\$\{number\}\/second`/, hint: "rateLimit is text: rateLimit: '30/minute' (per second, minute, hour or day), not an object." },
|
|
@@ -80118,8 +80072,8 @@ function productionControl(client, target, options2 = {}) {
|
|
|
80118
80072
|
}
|
|
80119
80073
|
};
|
|
80120
80074
|
}
|
|
80121
|
-
async function openProductionControl(projectId, target) {
|
|
80122
|
-
const client = new ApiClient(getToken());
|
|
80075
|
+
async function openProductionControl(projectId, target, fromProjectFile = false) {
|
|
80076
|
+
const client = new ApiClient(getToken(), fromProjectFile ? projectId : void 0);
|
|
80123
80077
|
return productionControl(client, target ?? await loadTestTarget(client, projectId));
|
|
80124
80078
|
}
|
|
80125
80079
|
function previewFailure(error3, what) {
|
|
@@ -85124,7 +85078,7 @@ Existing app: \`${cliInvocation()} pull <app>\` downloads the live source and li
|
|
|
85124
85078
|
} else {
|
|
85125
85079
|
token = getToken();
|
|
85126
85080
|
}
|
|
85127
|
-
const client = new ApiClient(token);
|
|
85081
|
+
const client = new ApiClient(token, !opts.project && !besideRealLogin ? foundProjectEntry?.config.project_id : void 0);
|
|
85128
85082
|
let scope;
|
|
85129
85083
|
if (opts.scope !== void 0) {
|
|
85130
85084
|
if (opts.scope !== "functions" && opts.scope !== "static") {
|
|
@@ -85764,7 +85718,7 @@ ${dim("Build")}`);
|
|
|
85764
85718
|
process.exit(1);
|
|
85765
85719
|
}
|
|
85766
85720
|
if (err instanceof CliApiError && targetFromLink && !deployAnswered && (err.code === "PROJECT_NOT_FOUND" || err.code === "FORBIDDEN" && err.statusCode === 403)) {
|
|
85767
|
-
const message3 = formatLinkedProjectAccessRefusal(!tempSession, dir);
|
|
85721
|
+
const message3 = err.statusCode === 404 ? `${err.message} To publish a new project instead and update .somewhere.json, run \`${newProjectCommand(dir)}\`.` : formatLinkedProjectAccessRefusal(!tempSession, dir);
|
|
85768
85722
|
if (opts.json) {
|
|
85769
85723
|
printJsonError(err.code, message3, {
|
|
85770
85724
|
...platformErrorEnvelope(err)?.extra ?? {},
|
|
@@ -86352,7 +86306,7 @@ function registerDeploys(program2) {
|
|
|
86352
86306
|
const deploys = program2.command("deploys").description("List recent deploys with their time, note and restore command.").option("--project <ref>", "Project ID or subdomain (defaults to the linked project)").option("--json", "Print deploy history as JSON").action(async (options2) => {
|
|
86353
86307
|
try {
|
|
86354
86308
|
const project = projectRef(options2.project);
|
|
86355
|
-
const result = await new ApiClient(getToken()).call("GET", `/projects/${encodeURIComponent(project)}/deploys`);
|
|
86309
|
+
const result = await new ApiClient(getToken(), options2.project ? void 0 : project).call("GET", `/projects/${encodeURIComponent(project)}/deploys`);
|
|
86356
86310
|
if (options2.json)
|
|
86357
86311
|
return printJson(result);
|
|
86358
86312
|
if (result.deploys.length === 0)
|
|
@@ -86374,8 +86328,9 @@ function registerDeploys(program2) {
|
|
|
86374
86328
|
const options2 = command.optsWithGlobals();
|
|
86375
86329
|
try {
|
|
86376
86330
|
const version2 = deployVersion(versionArg);
|
|
86377
|
-
const
|
|
86378
|
-
|
|
86331
|
+
const project = projectRef(options2.project);
|
|
86332
|
+
const result = await new ApiClient(getToken(), options2.project ? void 0 : project).call("PATCH", "/deploy/note", {
|
|
86333
|
+
project_id: project,
|
|
86379
86334
|
version: version2,
|
|
86380
86335
|
message: message3
|
|
86381
86336
|
});
|
|
@@ -86389,7 +86344,7 @@ function registerDeploys(program2) {
|
|
|
86389
86344
|
program2.command("file <path>").description("Print one deployed source file. Redirect stdout to save it.").requiredOption("--version <number>", "Retained production version to read (required)").option("--project <ref>", "Project ID or subdomain (defaults to the linked project)").action(async (path3, options2) => {
|
|
86390
86345
|
const project = projectRef(options2.project);
|
|
86391
86346
|
const version2 = deployVersion(options2.version);
|
|
86392
|
-
const file = await new ApiClient(getToken()).call("GET", "/deploy/file", void 0, { project_id: project, path: path3, version: version2 });
|
|
86347
|
+
const file = await new ApiClient(getToken(), options2.project ? void 0 : project).call("GET", "/deploy/file", void 0, { project_id: project, path: path3, version: version2 });
|
|
86393
86348
|
process.stdout.write(Buffer.from(file.content, file.encoding));
|
|
86394
86349
|
});
|
|
86395
86350
|
}
|
|
@@ -89649,7 +89604,6 @@ function registerLogs(program2) {
|
|
|
89649
89604
|
process.exit(1);
|
|
89650
89605
|
}
|
|
89651
89606
|
const token = getToken();
|
|
89652
|
-
const client = new ApiClient(token);
|
|
89653
89607
|
const chosen = chooseProjectRef(project, opts.project);
|
|
89654
89608
|
if (chosen.kind === "conflict") {
|
|
89655
89609
|
error(projectRefConflictMessage(chosen));
|
|
@@ -89664,6 +89618,7 @@ function registerLogs(program2) {
|
|
|
89664
89618
|
}
|
|
89665
89619
|
projectId = config2.project_id;
|
|
89666
89620
|
}
|
|
89621
|
+
const client = new ApiClient(token, chosen.kind === "none" ? projectId : void 0);
|
|
89667
89622
|
if (opts.function && opts.endpoint && opts.function !== opts.endpoint) {
|
|
89668
89623
|
error("--function and --endpoint cannot specify different paths.");
|
|
89669
89624
|
process.exit(1);
|
|
@@ -89869,7 +89824,7 @@ var init_logs = __esm({
|
|
|
89869
89824
|
// dist/commands/errors.js
|
|
89870
89825
|
function registerErrors(program2) {
|
|
89871
89826
|
program2.command("errors [project]").description("Show what recently went wrong in a project \u2014 the curated 24h view (endpoint, status, error, time). The fastest way to see what is breaking in production without digging through raw logs. Rows are split into EXCEPTIONS (nobody chose it \u2014 an uncaught throw or a 5xx) and REFUSALS (your handler answered 4xx on purpose, e.g. a 401 from your own auth gate). Platform-generated diagnostics are labeled separately. Use --exceptions to hide your handler's deliberate refusals.").option("--project <ref>", "Project ID, name, slug, or subdomain \u2014 the same flag every other command takes. The positional form still works.").option("--limit <n>", "Max rows to show (default 20, max 100)", "20").option("--exceptions", "Hide the 4xx your own handlers returned on purpose; keep exceptions and platform diagnostics.").option("--json", "Print rows as JSON; platform-generated diagnostics include diagnostic_origin.").action(async (projectArg, opts) => {
|
|
89872
|
-
const
|
|
89827
|
+
const token = getToken();
|
|
89873
89828
|
const chosen = chooseProjectRef(projectArg, opts.project);
|
|
89874
89829
|
if (chosen.kind === "conflict") {
|
|
89875
89830
|
error(projectRefConflictMessage(chosen));
|
|
@@ -89884,6 +89839,7 @@ function registerErrors(program2) {
|
|
|
89884
89839
|
}
|
|
89885
89840
|
projectId = config2.project_id;
|
|
89886
89841
|
}
|
|
89842
|
+
const client = new ApiClient(token, chosen.kind === "none" ? projectId : void 0);
|
|
89887
89843
|
const limit = Math.min(parseInt(String(opts.limit), 10) || 20, 100);
|
|
89888
89844
|
let rows;
|
|
89889
89845
|
try {
|
|
@@ -90293,7 +90249,7 @@ function registerRun(program2) {
|
|
|
90293
90249
|
error("This command sends one script. Inline local helpers or bundle them into a single ES module, then run that file.");
|
|
90294
90250
|
process.exit(1);
|
|
90295
90251
|
}
|
|
90296
|
-
const client = new ApiClient(getToken());
|
|
90252
|
+
const client = new ApiClient(getToken(), opts.project ? void 0 : projectId);
|
|
90297
90253
|
let timeoutMs;
|
|
90298
90254
|
if (opts.timeout !== void 0) {
|
|
90299
90255
|
timeoutMs = parseInt(String(opts.timeout), 10);
|
|
@@ -90459,7 +90415,6 @@ function printProductionDeployment(deployment) {
|
|
|
90459
90415
|
function registerStatus(program2) {
|
|
90460
90416
|
program2.command("status [project]").description("Show project and workspace status").option("--project <ref>", "Project ID, name, slug, or subdomain \u2014 the same flag every other command takes. The positional form still works.").option("--json", "Print the raw status responses as JSON").action(async (projectArg, opts) => {
|
|
90461
90417
|
const token = getToken();
|
|
90462
|
-
const client = new ApiClient(token);
|
|
90463
90418
|
const claimConnection = Boolean(loadConfig()?.claim_access);
|
|
90464
90419
|
const chosen = chooseProjectRef(projectArg, opts.project);
|
|
90465
90420
|
if (chosen.kind === "conflict") {
|
|
@@ -90475,6 +90430,7 @@ function registerStatus(program2) {
|
|
|
90475
90430
|
}
|
|
90476
90431
|
projectId = config2.project_id;
|
|
90477
90432
|
}
|
|
90433
|
+
const client = new ApiClient(token, chosen.kind === "none" ? projectId : void 0);
|
|
90478
90434
|
let projectStatus = null;
|
|
90479
90435
|
let projectError = null;
|
|
90480
90436
|
let deploymentStatus = null;
|
|
@@ -90633,7 +90589,6 @@ function registerOpen(program2) {
|
|
|
90633
90589
|
return;
|
|
90634
90590
|
}
|
|
90635
90591
|
const token = getToken();
|
|
90636
|
-
const client = new ApiClient(token);
|
|
90637
90592
|
const chosen = chooseProjectRef(project, opts.project);
|
|
90638
90593
|
if (chosen.kind === "conflict") {
|
|
90639
90594
|
error(projectRefConflictMessage(chosen));
|
|
@@ -90648,6 +90603,7 @@ function registerOpen(program2) {
|
|
|
90648
90603
|
error("No project linked. Pass a project name (positionally or with --project) or run from a linked directory." + unlinkedFolderHint());
|
|
90649
90604
|
process.exit(1);
|
|
90650
90605
|
}
|
|
90606
|
+
const client = new ApiClient(token, chosen.kind === "none" ? projectRef3 : void 0);
|
|
90651
90607
|
try {
|
|
90652
90608
|
const servingUrl = await getProjectServingUrl(client, projectRef3);
|
|
90653
90609
|
if (!servingUrl)
|
|
@@ -92391,7 +92347,7 @@ function registerCheck(program2) {
|
|
|
92391
92347
|
}
|
|
92392
92348
|
projectId = config2.project_id;
|
|
92393
92349
|
}
|
|
92394
|
-
const client = new ApiClient(getToken());
|
|
92350
|
+
const client = new ApiClient(getToken(), opts.project ? void 0 : projectId);
|
|
92395
92351
|
const collected = collectFiles(targetDir);
|
|
92396
92352
|
const sensitiveRefusal = sensitiveReferenceRefusal(collected);
|
|
92397
92353
|
if (sensitiveRefusal) {
|
|
@@ -136146,7 +136102,7 @@ var init_app_test = __esm({
|
|
|
136146
136102
|
if (!projectId)
|
|
136147
136103
|
throw new Error(`${root} is not a linked Somewhere project (no .somewhere.json with a project_id).`);
|
|
136148
136104
|
const preview = options2.preview !== void 0 && options2.preview !== false;
|
|
136149
|
-
const control = preview ? await openPreviewControl({ root, projectId, ...typeof options2.preview === "string" ? { previewSessionId: options2.preview } : {} }) : await openProductionControl(projectId);
|
|
136105
|
+
const control = preview ? await openPreviewControl({ root, projectId, ...typeof options2.preview === "string" ? { previewSessionId: options2.preview } : {} }) : await openProductionControl(projectId, void 0, true);
|
|
136150
136106
|
const target = control.target;
|
|
136151
136107
|
if ((options2.undeployed ?? "refuse") === "refuse") {
|
|
136152
136108
|
const local = undeployedChanges(root, projectId, preview);
|
|
@@ -137139,7 +137095,7 @@ function registerTest(program2) {
|
|
|
137139
137095
|
throw new Error(`${unsupported.join(", ")} apply to Playwright specs and scripts; the platform runs checks/*.json as saved.`);
|
|
137140
137096
|
let check;
|
|
137141
137097
|
try {
|
|
137142
|
-
check = await runChecksNow(new ApiClient(getToken()), projectId, { again: opts.again === true, only: opts.only });
|
|
137098
|
+
check = await runChecksNow(new ApiClient(getToken(), projectId), projectId, { again: opts.again === true, only: opts.only });
|
|
137143
137099
|
} catch (cause) {
|
|
137144
137100
|
const sentence = cause instanceof Error ? cause.message : "The platform could not start the checks.";
|
|
137145
137101
|
check = opts.only ? partialCheckUnavailable(opts.only, sentence) : { status: "unavailable", sentence };
|
|
@@ -137181,7 +137137,7 @@ function registerTest(program2) {
|
|
|
137181
137137
|
}
|
|
137182
137138
|
if (opts.failFast)
|
|
137183
137139
|
throw new Error("--fail-fast applies to app-check scripts (tests/*.mjs or *.cjs).");
|
|
137184
|
-
const outcome2 = await runTests({ root, ...opts.preview ? {} : { client: new ApiClient(getToken()) }, projectId, prepared: prepareRunner(root), options: { ...opts, files } });
|
|
137140
|
+
const outcome2 = await runTests({ root, ...opts.preview ? {} : { client: new ApiClient(getToken(), projectId) }, projectId, prepared: prepareRunner(root), options: { ...opts, files } });
|
|
137185
137141
|
await note;
|
|
137186
137142
|
mark("cli:exit");
|
|
137187
137143
|
process.exitCode = outcome2.exitCode;
|
|
@@ -138960,7 +138916,7 @@ var init_playwright_fixtures = __esm({
|
|
|
138960
138916
|
return this.loading ??= (async () => {
|
|
138961
138917
|
const control = this.preview ?? await timed(this.info, "target snapshot", async () => {
|
|
138962
138918
|
const projectId = linkedProject();
|
|
138963
|
-
return openProductionControl(projectId, runTarget(projectId) ?? void 0);
|
|
138919
|
+
return openProductionControl(projectId, runTarget(projectId) ?? void 0, true);
|
|
138964
138920
|
});
|
|
138965
138921
|
diagnostics(this.info).release = control.target.releaseId;
|
|
138966
138922
|
return { control };
|
|
@@ -139160,7 +139116,7 @@ async function openTestApp(options2 = {}) {
|
|
|
139160
139116
|
throw new Error("Run the test from a linked Somewhere app folder.");
|
|
139161
139117
|
const setup = options2.preview ? previewCredentialFor(root, projectId) : void 0;
|
|
139162
139118
|
const tool = setup && previewToolClient(setup.credential);
|
|
139163
|
-
const client = tool ? void 0 : new ApiClient(testingDeveloperToken());
|
|
139119
|
+
const client = tool ? void 0 : new ApiClient(testingDeveloperToken(), projectId);
|
|
139164
139120
|
const target = tool && setup ? await readPreviewTarget(tool, projectId, setup.previewSessionId) : await loadTestTarget(client, projectId);
|
|
139165
139121
|
const control = tool ? previewControl(tool, target) : void 0;
|
|
139166
139122
|
const inbox2 = control ?? productionControl(client, target, { liveInboxOnly: true });
|