@somewhere-cloud/cli 0.38.163 → 0.38.164

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.164
4
+
5
+ - `somewhere docs` opens the overview. Use `--full` for the full manual, `--list` for the topic index, and `somewhere docs <topic> --search "<words>"` to search within one topic.
6
+ - `somewhere test-users prepare` reports the deployed data contract for named-user tests. Local declarations cover transaction receipts and configurable read projections.
7
+ - `somewhere auth export --help` directs verified app owners to migration support.
8
+
3
9
  ## 0.38.163
4
10
 
5
11
  - `somewhere auth set` accepts temporary deployment keys from `SOMEWHERE_TOKEN` or stdin. The CLI keeps the workspace expiry and claim link for deploy. Once the workspace expires, the CLI stops sending its key and shows how to start a new workspace or sign in.
@@ -43339,7 +43339,7 @@ function registerAuth(program2) {
43339
43339
  if (!config2.temporary)
43340
43340
  info(`Token: ${config2.token.slice(0, 8)}\u2026${config2.token.slice(-4)}`);
43341
43341
  });
43342
- auth2.command("export [project]").description("Export portable end-user password credentials after verified-owner email approval").option("--project <ref>", "Project ID, name, slug, or subdomain (defaults to the linked project)").requiredOption("--output <path>", "New local JSON file to create (existing paths are never overwritten)").allowExcessArguments(false).showHelpAfterError("The approval code is read from a hidden prompt or stdin; never pass it as an argument.").action(async (project, opts) => {
43342
+ auth2.command("export [project]").description(PASSWORD_EXPORT_REQUEST).option("--project <ref>", "Project ID, name, slug, or subdomain (defaults to the linked project)").requiredOption("--output <path>", "New local JSON file to create (existing paths are never overwritten)").allowExcessArguments(false).action(async (project, opts) => {
43343
43343
  let outputFd = null;
43344
43344
  let outputCreated = false;
43345
43345
  let wroteOutput = false;
@@ -43404,7 +43404,11 @@ function registerAuth(program2) {
43404
43404
  } catch {
43405
43405
  }
43406
43406
  }
43407
- error(err instanceof Error ? err.message : String(err), err);
43407
+ if (err instanceof CliApiError && err.statusCode === 501 && err.code === "AUTH_FEATURE_UNAVAILABLE") {
43408
+ error(PASSWORD_EXPORT_REQUEST, void 0, err);
43409
+ } else {
43410
+ error(err instanceof Error ? err.message : String(err), err);
43411
+ }
43408
43412
  process.exitCode = 1;
43409
43413
  }
43410
43414
  });
@@ -43595,7 +43599,7 @@ async function runBrowserCallbackLogin() {
43595
43599
  process.exit(1);
43596
43600
  }
43597
43601
  }
43598
- var import_prompts, SIGNUP_URL, SIGNUP_HINT;
43602
+ var import_prompts, PASSWORD_EXPORT_REQUEST, SIGNUP_URL, SIGNUP_HINT;
43599
43603
  var init_auth2 = __esm({
43600
43604
  "dist/commands/auth.js"() {
43601
43605
  "use strict";
@@ -43611,6 +43615,7 @@ var init_auth2 = __esm({
43611
43615
  init_next_actions();
43612
43616
  init_output();
43613
43617
  init_platform_command();
43618
+ PASSWORD_EXPORT_REQUEST = "The app's owner can request password hashes at migration@somewhere.cloud.";
43614
43619
  __name(readAuthToken, "readAuthToken");
43615
43620
  __name(readPasswordExportCode, "readPasswordExportCode");
43616
43621
  __name(createProtectedOutput, "createProtectedOutput");
@@ -44234,7 +44239,7 @@ var init_init_agent_guide = __esm({
44234
44239
  | Does your app verify emails? | Choose the declared access rule |
44235
44240
  | --- | --- |
44236
44241
  | Yes, invited teams | Use \`group()\` and \`sw.groups\` for invitations, membership and owner/admin permissions. See \`somewhere docs sw.groups --section team-example\`. |
44237
- | No, app-managed teams | Use \`member()\` over a server-only roster. Declare author-or-team-owner delete with \`anyOf()\` and a role-filtered branch. See \`somewhere docs declared-data --section teams-without-email-verification\`. |
44242
+ | No, app-managed teams | Use \`member()\` over a server-only roster. Add \`deleteWhere: { role: 'owner' }\` to reserve deletion for team owners on a standalone \`member()\` rule. For author-or-team-owner deletion, check either permission in a server endpoint before deleting. See \`somewhere docs declared-data --section teams-without-email-verification\`. |
44238
44243
  | Yes, staff by domain | Use \`appRole()\` and \`appRoles: { staff: { emailDomain: 'staff.example' } }\`. The address must be verified. |
44239
44244
  | 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\`. |
44240
44245
  | Either, personal rows | Use \`owner()\`. The platform stamps the owner from the signed-in user. |
@@ -44266,6 +44271,15 @@ Use \`client.intake\` for public submissions to a private parent row. See
44266
44271
 
44267
44272
  ### Run and verify
44268
44273
 
44274
+ On a test app, run \`somewhere test-users prepare <name>\`. Pass multiple
44275
+ names in the same command to prepare several actors. Use
44276
+ \`somewhere data list <table> --as <name>\` and
44277
+ \`somewhere data create <table> --as <name> --values '<json>'\` to check
44278
+ the table's client access. Run \`somewhere cron run <name> --wait\` for a
44279
+ schedule, \`somewhere db rows <table>\` to inspect the stored rows, and
44280
+ \`somewhere errors\` to see recent failures. Finish with
44281
+ \`somewhere test-users cleanup\`.
44282
+
44269
44283
  Run \`somewhere typecheck\` and focused tests. \`somewhere deploy-check\` checks compilation and schema without publishing. \`somewhere deploy\` uploads raw source directly to production. When testing changes with real users or data, use \`somewhere preview\`, test with \`somewhere test --preview\`, then promote. See \`somewhere docs dev-environments\`.
44270
44284
 
44271
44285
  Save journeys in \`checks/<name>.json\`, using \`checks/add-a-note.json\` from the notes starter as a model. Keep test IDs when restyling and click the item a person would use. Set \`"signed_in": true\` for a test user and \`"viewports": ["desktop", "mobile"]\` to check both sizes. Saved checks run after deploy. Use \`somewhere test\` to rerun them and \`somewhere verify --flow flow.json\` for a focused journey. For shared access, test the owner, a recipient and an unrelated user separately. The team fixture is in \`somewhere docs sw.groups --section team-example\`. For schedules, trigger \`somewhere cron run <id> --wait\` before asserting its effects. Inspect failures with \`somewhere errors\` and \`somewhere logs\`.
@@ -88093,6 +88107,11 @@ function findPublicDocsPage(pages, aliases, requested) {
88093
88107
  const target = own2(lower) ?? own2(normalized);
88094
88108
  return byId(requested) ?? (target ? byId(target) : void 0);
88095
88109
  }
88110
+ function docsConnectionError(cause) {
88111
+ const inner = cause?.cause;
88112
+ const reason = inner?.code ?? inner?.message ?? (cause instanceof Error ? cause.message : String(cause));
88113
+ return new Error(`Could not reach ${DOCS_BASE2} (${reason}) \u2014 check your connection. The docs are public and need no login.`, { cause });
88114
+ }
88096
88115
  async function fetchPublicManifestWithGroups() {
88097
88116
  let res;
88098
88117
  try {
@@ -88100,9 +88119,7 @@ async function fetchPublicManifestWithGroups() {
88100
88119
  headers: { "User-Agent": "somewhere-cli" }
88101
88120
  });
88102
88121
  } catch (cause) {
88103
- const inner = cause?.cause;
88104
- const reason = inner?.code ?? inner?.message ?? (cause instanceof Error ? cause.message : String(cause));
88105
- throw new Error(`Could not reach ${DOCS_BASE2} (${reason}) \u2014 check your connection. The docs are public and need no login.`);
88122
+ throw docsConnectionError(cause);
88106
88123
  }
88107
88124
  if (!res.ok) {
88108
88125
  throw new Error(`Could not fetch ${DOCS_BASE2}${PUBLIC_MANIFEST_PATH} (HTTP ${res.status}).`);
@@ -88165,7 +88182,7 @@ async function fetchDocsSearch(query, topic, includeApi) {
88165
88182
  });
88166
88183
  if (!res.ok) {
88167
88184
  if (topic && res.status === 404)
88168
- throw new Error(`Unknown docs topic "${topic}". Run ${cliInvocation()} docs for the topic index.`);
88185
+ throw new Error(`Unknown docs topic "${topic}". Run ${cliInvocation()} docs --list for the topic index.`);
88169
88186
  throw new Error(`Could not search docs at ${DOCS_BASE2} (HTTP ${res.status}).`);
88170
88187
  }
88171
88188
  const { results, total, version: version2 } = await res.json();
@@ -88248,9 +88265,9 @@ function displayDocs(content) {
88248
88265
  return withNewline(hasViewNotice(content) ? content.replace(/^\[docs\][^\n]*\n/, "") : content);
88249
88266
  }
88250
88267
  function registerDocs(program2) {
88251
- program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, prints the topic index. Search with \`${cliInvocation()} docs --search "<words>"\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", `List available topics (the same index bare \`${cliInvocation()} docs\` prints)`).option("--full", "Print the complete topic; with no topic, print the full manual").option("--search <words>", "Find matching builder docs and read the top section whole").option("--include-api", "Include the HTTP API catalog and developer tool reference in search").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
88268
+ program2.command("docs [topic] [terms...]").description(`Read platform docs. No login needed \u2014 every topic is public. With no topic, opens the platform overview. Search with \`${cliInvocation()} docs --search "<words>"\`. Quick topics: ` + Object.keys(TOPICS).join(", ") + `. Example manual topic: \`${cliInvocation()} docs sw.db\`.`).option("--list", "List available topics").option("--full", "Print the complete topic; with no topic, print the full manual").option("--search <words>", "Find matching builder docs, optionally within the given topic").option("--include-api", "Include the HTTP API catalog and developer tool reference in search").option("--section <id>", "Print one section of a topic (ids are listed in the summary)").option("--json", "Print the selected document in a JSON envelope").addHelpText("after", `
88252
88269
  Examples:
88253
- ${cliInvocation()} docs # topic index
88270
+ ${cliInvocation()} docs # platform overview
88254
88271
  ${cliInvocation()} docs --search "magic link" # matching builder docs
88255
88272
  ${cliInvocation()} docs pull # download Markdown into .somewhere/docs/
88256
88273
  ${cliInvocation()} docs sw.auth # topic summary when the whole topic is long
@@ -88333,8 +88350,8 @@ Examples:
88333
88350
  return;
88334
88351
  }
88335
88352
  if (searching) {
88336
- if (opts.full || opts.section !== void 0 || opts.list || opts.search !== void 0 && topic !== void 0) {
88337
- error('Use docs --search "<words>" with optional --include-api and --json.');
88353
+ if (opts.full || opts.section !== void 0 || opts.list) {
88354
+ error('Use docs [topic] --search "<words>" with optional --include-api and --json.');
88338
88355
  process.exitCode = 1;
88339
88356
  return;
88340
88357
  }
@@ -88372,7 +88389,7 @@ ${results[0].snippet}`);
88372
88389
  return;
88373
88390
  }
88374
88391
  const view = opts.section !== void 0 ? { kind: "section", id: opts.section } : opts.full ? { kind: "full" } : { kind: "default" };
88375
- if (opts.list || topic === void 0 && view.kind === "default") {
88392
+ if (opts.list) {
88376
88393
  try {
88377
88394
  const { pages, groups, version: version2 } = await fetchPublicManifestWithGroups();
88378
88395
  await warnIfLocalDocsOlder(version2);
@@ -88407,7 +88424,7 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88407
88424
  const lowerTopic = requestedTopic.toLowerCase();
88408
88425
  const key = ownKey(TOPICS, requestedTopic) ? requestedTopic : ownKey(ALIASES, lowerTopic) ? ALIASES[lowerTopic] : void 0;
88409
88426
  const resolvedTopic = key ?? requestedTopic;
88410
- const entry = key ? TOPICS[key] : void 0;
88427
+ const entry = key === "docs" && view.kind === "full" ? { path: "/manual.txt" } : key ? TOPICS[key] : void 0;
88411
88428
  if (entry && view.kind === "section") {
88412
88429
  reportDocsFailure({
88413
88430
  error: "DOCS_SECTION_INDEX_UNAVAILABLE",
@@ -88511,7 +88528,7 @@ ${dim(`No account yet? Start with: ${cliInvocation()} docs start`)}`);
88511
88528
  }
88512
88529
  await writeResponseBodyToStdout(res);
88513
88530
  } catch (e) {
88514
- error(`Could not reach ${DOCS_BASE2} \u2014 check your connection. (${e instanceof Error ? e.message : String(e)})`, e);
88531
+ error(docsConnectionError(e).message, e);
88515
88532
  process.exit(1);
88516
88533
  }
88517
88534
  });
@@ -88536,7 +88553,7 @@ var init_docs = __esm({
88536
88553
  },
88537
88554
  docs: {
88538
88555
  path: "/docs.txt",
88539
- blurb: "Full platform reference for agents (large)"
88556
+ blurb: "Platform overview, plans and topic links"
88540
88557
  },
88541
88558
  guides: {
88542
88559
  path: "/guides.txt",
@@ -88581,6 +88598,7 @@ var init_docs = __esm({
88581
88598
  __name(parsePublicDocsGroups, "parsePublicDocsGroups");
88582
88599
  __name(parsePublicDocsAliases, "parsePublicDocsAliases");
88583
88600
  __name(findPublicDocsPage, "findPublicDocsPage");
88601
+ __name(docsConnectionError, "docsConnectionError");
88584
88602
  __name(fetchPublicManifestWithGroups, "fetchPublicManifestWithGroups");
88585
88603
  __name(renderDocsIndex, "renderDocsIndex");
88586
88604
  __name(fetchDocsSearch, "fetchDocsSearch");
@@ -136371,7 +136389,7 @@ function registerTestUsers(program2) {
136371
136389
  "that signup or email verification works. Use `address` + `inbox` for real signup tests.",
136372
136390
  `${RETAINED_NOTE}`
136373
136391
  ].join("\n"));
136374
- group.command("prepare <actors...>").description("Create preverified test users and write one Playwright storageState file per actor (e.g. alice bob:admin)").option("-p, --project <project>", "Project slug or ID; defaults to the linked project").option("--origin <url>", "Only the project's production origin is supported; anything else is refused").option("--json", "Print the manifest (no tokens) as JSON").addHelpText("after", [
136392
+ group.command("prepare <actors...>").description("Create preverified test users and write one Playwright storageState file per actor (e.g. alice bob:admin)").option("-p, --project <project>", "Project slug or ID; defaults to the linked project").option("--origin <url>", "Only the project's production origin is supported; anything else is refused").option("--json", "Print the manifest and browser data contract digest as JSON").addHelpText("after", [
136375
136393
  "",
136376
136394
  "From the linked project folder, run somewhere test-users prepare alice. It writes .somewhere/test/<actor>.state.json (a standard Playwright storageState) and manifest.json.",
136377
136395
  'Playwright: const alice = await browser.newContext({ storageState: ".somewhere/test/alice.state.json" })',
@@ -136409,6 +136427,16 @@ function registerTestUsers(program2) {
136409
136427
  fail2(opts, Object.assign(new Error(`${TEST_STATE_DIR}/${MANIFEST_FILE} still records ${existing.actors.length} test user(s) from run ${existing.run_id}. Reuse the saved state if it still signs in, or run \`somewhere browser --auth-user <user-id>\` with the ID in the manifest to start a fresh hosted session. To replace the identities, run \`somewhere test-users cleanup\` and then prepare again.`), { code: "TEST_USERS_NOT_CLEANED" }));
136410
136428
  return;
136411
136429
  }
136430
+ let contractDigest = null;
136431
+ try {
136432
+ const map = await target.client.call("GET", "/db/access-map", void 0, { project_id: target.projectId });
136433
+ contractDigest = map.browser_data.contract_digest;
136434
+ } catch (cause) {
136435
+ if (!(cause instanceof CliApiError && cause.code === "NOT_FOUND")) {
136436
+ fail2(opts, cause);
136437
+ return;
136438
+ }
136439
+ }
136412
136440
  ensurePrivateDir(dir);
136413
136441
  const gitignore = ensureGitignored(target.root);
136414
136442
  const manifest = {
@@ -136463,7 +136491,7 @@ function registerTestUsers(program2) {
136463
136491
  if (failure2)
136464
136492
  fail2(opts, failure2, { manifest, state_dir: TEST_STATE_DIR, created: manifest.actors.length, requested: specs.length });
136465
136493
  else
136466
- printJson({ manifest, state_dir: TEST_STATE_DIR, gitignore });
136494
+ printJson({ manifest, state_dir: TEST_STATE_DIR, gitignore, contract_digest: contractDigest });
136467
136495
  return;
136468
136496
  }
136469
136497
  for (const actor of manifest.actors) {
@@ -136472,6 +136500,7 @@ function registerTestUsers(program2) {
136472
136500
  }
136473
136501
  if (gitignore !== "present")
136474
136502
  info(`${gitignore === "created" ? "Created" : "Updated"} .gitignore to ignore ${TEST_STATE_DIR}/.`);
136503
+ info(contractDigest ? `Data contract digest: ${contractDigest}` : "No browser data contract is deployed.");
136475
136504
  info(RETAINED_NOTE);
136476
136505
  if (failure2) {
136477
136506
  fail2(opts, failure2);