@somewhere-cloud/cli 0.38.150 → 0.38.152

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.
@@ -79,6 +79,7 @@ export declare class ApiClient {
79
79
  callRaw(method: string, path: string, body?: unknown, opts?: {
80
80
  timeoutMs?: number;
81
81
  captureIncompleteBody?: true;
82
+ redirect?: 'error';
82
83
  }): Promise<{
83
84
  status: number;
84
85
  ok: boolean;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.150",
3
+ "version": "0.38.152",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@somewhere-cloud/cli",
9
- "version": "0.38.150",
9
+ "version": "0.38.152",
10
10
  "license": "MIT",
11
11
  "bin": {
12
12
  "somewhere": "bin/somewhere.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.150",
3
+ "version": "0.38.152",
4
4
  "description": "CLI for somewhere.cloud — auth, projects, deploy, pull, promote, db, logs, env, MCP bridge.",
5
5
  "keywords": [
6
6
  "somewhere",
@@ -66,5 +66,5 @@
66
66
  },
67
67
  "bundleDependencies": [],
68
68
  "bundledDependencies": [],
69
- "gitHead": "a6ed5dcef34a2f6a099440149a0cf341d15e4495"
69
+ "gitHead": "7ba42b6b038a584e68e46796d7c8c5c42f1540d2"
70
70
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "source_commit": "4a65c43c7dbb317dab97c8716b004ddba32da243",
2
+ "source_commit": "3fd5f988ec49589e943fca1f3471ad136a738444",
3
3
  "esbuild": "0.24.0",
4
4
  "source_files": {
5
5
  "shared/app-model-catalog.ts": "c9a0119366beabb10157fcc9866f4d32b320b680f1c5717d837a5ca99875fa13",
@@ -9,12 +9,12 @@
9
9
  "shared/transient-read.ts": "2f22daebdc74fed6255a29df7deda0db307f9165c1d9988dba3ee872b2584ffd",
10
10
  "shared/types/placeholder-identity.ts": "089a46e2474a21193d3611eddd9c94b6bbe62441b3039ed80fc8499bada447ca",
11
11
  "worker/containers/compile/checker-contract.cjs": "c6d4ebc9ec058b3562655cc4f18dc1cea7e4492eb35b7f0fd0d87e974c26b492",
12
- "worker/containers/compile/consumer-contract.cjs": "3827f2fcd4bb5a3cd6682f07ae63c3cee6f48411b0bd9afe2baaa0664d808e47",
13
- "worker/containers/compile/declared-data-contract.cjs": "1261275ab4ff75b3001456a30b041a7c639578ffff0b67b42706d7b0ff11d744",
12
+ "worker/containers/compile/consumer-contract.cjs": "2255630f2db257db723570007542d6a5aebce0dd5efbe82117d3d7c8db485d2f",
13
+ "worker/containers/compile/declared-data-contract.cjs": "ebdc7dbc12283a7218c28e0e912e736ac27a8e9d513b82c097ebff6df3c1dd91",
14
14
  "worker/containers/compile/generated-declarations-render.cjs": "7ffdb34645cc9eccac6eba39dc86b646a41c4de8a1a038d2b5b46f42df9f1157",
15
15
  "worker/containers/compile/generated-declarations.cjs": "6e9902e054c5c784fd9b3c3fafc1869e79954100a45014e1132247cd82833ec4",
16
16
  "worker/containers/compile/groups-types.cjs": "7c22b4bb96c9391005d434852600dc02bc8a6bbb99d78d2b8e3eb152f7b72c58",
17
- "worker/containers/compile/runtime-types.cjs": "ab8d1ff84c1a671e8206e23f5bab351f8f1ccc9c8c159694d71b09b195d0a276",
17
+ "worker/containers/compile/runtime-types.cjs": "a74ee2d726c395f2216528e070813293d08ee7340fbca63f94e015ede1ee6df1",
18
18
  "worker/containers/compile/schema-types.cjs": "6bd92695cd275b0c6bc7dc79daaf3189fb275449321342c967a2030f287cfdfa",
19
19
  "worker/containers/compile/typed-data.cjs": "1c8bec853fbee4ffd34c651076a4e1f4d8b18c0c2be5e99e31df7c9283207627",
20
20
  "worker/containers/compile/typed-files.cjs": "f2568567a53994575ede91f9a0839965e64f94eb92ae11315650189b6de0f79c",
@@ -54,13 +54,13 @@
54
54
  "worker/src/utils/db-schema-deploy/extract-schema-parents.ts": "623a0034c5196e7655574387493574ce59555d0a1cffd88ff696ce85b9f56228",
55
55
  "worker/src/utils/db-schema-deploy/extract-schema-relations.ts": "f5deac350ee915758f61d4be33711d23bad51ab20abcf153a463f0c90bfc3e27",
56
56
  "worker/src/utils/db-schema-deploy/extract-schema-roles.ts": "a5cc7524108c19121445ea2feb85c155067b790075eb823a5d5f8c2a12e92e78",
57
- "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "e84d3dd48731e6b6dbb2cfa33006aab1e420059d7a67e863941d62ade3ca8167",
57
+ "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "6ece9f185e2de72b720c6c5fb942609701874ea3951b679b8c8dc7c92b10aba3",
58
58
  "worker/src/utils/db-schema-deploy/schema-constants.ts": "9742bc649f494963af4ae2039a1d6062cc6dbe087285bdf470f6ee71d9f76aac",
59
59
  "worker/src/utils/db-schema-deploy/schema-ownership.ts": "e6c811a87bc657707be3518dfe547c6d97718ac073108b126eb7f791c9c08202",
60
60
  "worker/src/utils/dev-health-class.ts": "fd430f31b9c8469f3d90e118fd8c75d1836ebcf705c1f9e93915ffa53a4cb066",
61
61
  "worker/src/utils/errors.ts": "f57505fc7cb515abb2e2e62fc8211f359200df1183689dc621dec10c8c7f03e3",
62
62
  "worker/src/utils/event-log.ts": "167a2ac478ff9b8b58c4f22ae39aa20ff25331c22a9e8f21d96e374b04458c78",
63
- "worker/src/utils/feed-kinds.ts": "a2f4a77707c09f04397cc2d67665b10c9303951e713c2ceb9d3c4f22cbfabe8d",
63
+ "worker/src/utils/feed-kinds.ts": "bbefa02184c09846481c55f4db6bc9e78f0e824383120d888f4a523c9b619b40",
64
64
  "worker/src/utils/journey-segment.ts": "623837dec9b24c211b1f3be4908f6780bb4cdba175f2dfa5f34ccccfe5a1a5fc",
65
65
  "worker/src/utils/json-exact-integers.ts": "e2eb8d3b2e17da363eb14fb46d876208579e2e92bfac173fb27527e6c4fb575e",
66
66
  "worker/src/utils/log-sanitize.ts": "f4591089c16a34e4cbc271ec22b48566b970a62e30d3e9856b7dcd9c479fb0e8",
@@ -74,5 +74,5 @@
74
74
  "worker/src/utils/telegram.ts": "9aaaa2597c366da1eeee9e2252e9b73e611ea97ed9558f7e07e694d9b393f053",
75
75
  "worker/src/utils/workers-ai-comparison.ts": "18b5d5ea96f817387a5ef49733ba611c99cbb14987143c28118b1c90f3b637d4"
76
76
  },
77
- "sha256": "38338fa7baa58d409e17b7ce199c1088437734d1397d8384d0ee965ce26f864e"
77
+ "sha256": "bc5bfcd5f4cb91e55691654bfe11f21a37a2efae763de4db56810c96c9c99425"
78
78
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "sha256": "fcfd291f7c9106868c470c4c90270ed20669ec5142a0f2e88fded7d695ec3f4f"
2
+ "sha256": "8a8d3ab2c5326736228ddc800ca30824916562461d581c1ba96dc5eb6f9bbf50"
3
3
  }
@@ -25,7 +25,7 @@
25
25
  "worker/src/utils/db-schema-deploy/extract-schema-parents.ts": "623a0034c5196e7655574387493574ce59555d0a1cffd88ff696ce85b9f56228",
26
26
  "worker/src/utils/db-schema-deploy/extract-schema-relations.ts": "f5deac350ee915758f61d4be33711d23bad51ab20abcf153a463f0c90bfc3e27",
27
27
  "worker/src/utils/db-schema-deploy/extract-schema-roles.ts": "a5cc7524108c19121445ea2feb85c155067b790075eb823a5d5f8c2a12e92e78",
28
- "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "e84d3dd48731e6b6dbb2cfa33006aab1e420059d7a67e863941d62ade3ca8167",
28
+ "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "6ece9f185e2de72b720c6c5fb942609701874ea3951b679b8c8dc7c92b10aba3",
29
29
  "worker/src/utils/db-schema-deploy/schema-constants.ts": "9742bc649f494963af4ae2039a1d6062cc6dbe087285bdf470f6ee71d9f76aac",
30
30
  "worker/src/utils/db-schema-deploy/schema-ownership.ts": "e6c811a87bc657707be3518dfe547c6d97718ac073108b126eb7f791c9c08202",
31
31
  "worker/src/utils/deploy-classify.ts": "d565b3c1d7628932ba69a1d93a82364319b66cfed1147b8639fff567a1e63b88",
@@ -33,6 +33,6 @@
33
33
  "worker/src/utils/managed-groups/errors.ts": "18d952edd7f46bb7e459d4e6678226f4bd6e040ab40073ee5a8d0802be2f3721",
34
34
  "worker/src/utils/managed-groups/policy.ts": "2c5b48479a2925bea9a820022c63ca5fa827e2ff5531fe1ab6c0b058b7212b39"
35
35
  },
36
- "sha256": "b8175e05ebb059ff4c0d4b06bdbad78e6111901987e15e06c9101f24741c64c3",
36
+ "sha256": "06b04ae4ef754320bf441d74986d74b6b44ac298d6dcc8ec24d8373875dda34f",
37
37
  "fixtures_sha256": "908827d1430f4af5a83cae59ed476abc51dc9648757eac0089fe6e6db95f66c5"
38
38
  }
@@ -614,8 +614,8 @@ async function intake(table, reference, values, extra) {
614
614
  export interface InsertRequest<T> { readonly key: string; readonly createdAt: number; retry(): Promise<T>; }
615
615
  export type InsertResult<T> = T & { readonly idempotency: InsertReceipt; readonly request: InsertRequest<InsertResult<T>> };
616
616
  `;
617
- var CLIENT_GENERATION2 = 5;
618
- var ACCEPTED_CLIENT_GENERATIONS2 = Object.freeze([5, 4, 3, 2, 1]);
617
+ var CLIENT_GENERATION2 = 6;
618
+ var ACCEPTED_CLIENT_GENERATIONS2 = Object.freeze([6, 5, 4, 3, 2, 1]);
619
619
  var PUBLIC_BOOTSTRAP_CLIENT_RUNTIME = 'const swCanon=(v,d)=>{if(v===null||typeof v==="string"||typeof v==="boolean"||(typeof v==="number"&&Number.isFinite(v)))return JSON.stringify(v);if(d===0||typeof v!=="object"||Array.isArray(v))return null;const parts=[];for(const k of Object.keys(v).sort()){if(v[k]===undefined)continue;const e=swCanon(v[k],d-1);if(e===null)return null;parts.push(JSON.stringify(k)+":"+e)}return"{"+parts.join(",")+"}"};let swBoot;const swBootTake=body=>{try{if(swBoot===undefined){swBoot=null;const el=typeof document!=="undefined"&&document.getElementById?document.getElementById("__sw_public_data"):null;if(el&&el.type==="application/json"&&(el.parentNode===document.head||el.parentNode===document.body)){const p=JSON.parse(el.textContent||"null");if(p&&p.v===1&&p.contract===contract&&Number.isSafeInteger(p.validated_at)&&p.validated_at<=Date.now()&&Number.isInteger(p.max_age)&&p.max_age>0&&p.max_age<=120&&p.entries&&typeof p.entries==="object"&&!Array.isArray(p.entries)&&typeof p.path==="string"&&typeof location!=="undefined")swBoot={until:p.validated_at+p.max_age*1000,path:p.path,entries:new Map(Object.entries(p.entries))}}if(el&&el.parentNode)el.parentNode.removeChild(el)}if(!swBoot)return undefined;if(Date.now()>=swBoot.until||location.pathname!==swBoot.path){swBoot=null;return undefined}const key=swCanon(body,2);if(key===null||!swBoot.entries.has(key))return undefined;const value=swBoot.entries.get(key);swBoot.entries.delete(key);return value}catch(error){swBoot=null;return undefined}};';
620
620
  var PUBLIC_BOOTSTRAP_INVOKE = 'if(operation==="list"||operation==="get"||operation==="aggregate"||operation==="relation_list"){const booted=swBootTake({...input,contract,table,operation});if(booted!==undefined)return booted}else swBoot=null;';
621
621
  function describeDataClient2(authority, contract_digest, insertReceiptCapability, localTypes = false, generation = CLIENT_GENERATION2) {
@@ -638,17 +638,18 @@ async function intake(table, reference, values, extra) {
638
638
  const hidden = generation >= 5 ? hiddenByBranch(table) : new Set();
639
639
  const row = shape(columns, readable, "read", new Set(), hidden);
640
640
  const id = columnType(columns.find((column) => column.n === primaryKey));
641
+ const ownerOnly = generation >= 6 && !client.publicRead && (table.owner || table.policy?.k === "a" && table.policy.p[0].k === "o" || table.policy?.k === "n" && ["o", "a"].includes(table.policy.w.k));
641
642
  const operations = [];
642
643
  const methods = [];
643
644
  if (client.read !== false) {
644
645
  const equality = readable.filter((field) => !["json", "blob"].includes(columns.find((column) => column.n === field).t) && !hidden.has(field));
645
646
  if (generation >= 2) {
646
- const listOptions = `limit?: L & (number extends L ? unknown : [L] extends [PageSize] ? unknown : never); after?: ${id}; where?: ${shape(columns, equality, "update")}`;
647
+ const listOptions = `limit?: L & (number extends L ? unknown : [L] extends [PageSize] ? unknown : never); after?: ${id}; where?: ${shape(columns, equality, "update")}${ownerOnly ? "; ownerOnly?: true" : ""}`;
647
648
  const hinted = generation >= 4 ? "RowHints" : "{ can: RowCan }";
648
649
  operations.push(`list<const L extends number = number>(options: { ${listOptions}; can: true }): Promise<{ data: (${row} & ${hinted})[]; next: ${id} | null; has_more: boolean }>`);
649
650
  operations.push(`list<const L extends number = number>(options?: { ${listOptions}; can?: false }): Promise<{ data: ${row}[]; next: ${id} | null; has_more: boolean }>`);
650
- operations.push(`get(id: ${id}, options: { can: true }): Promise<{ data: (${row} & ${hinted}) | null }>`);
651
- operations.push(`get(id: ${id}, options?: { can?: false }): Promise<{ data: ${row} | null }>`);
651
+ operations.push(`get(id: ${id}, options: { can: true${ownerOnly ? "; ownerOnly?: true" : ""} }): Promise<{ data: (${row} & ${hinted}) | null }>`);
652
+ operations.push(`get(id: ${id}, options?: { can?: false${ownerOnly ? "; ownerOnly?: true" : ""} }): Promise<{ data: ${row} | null }>`);
652
653
  } else {
653
654
  operations.push(`list<const L extends number = number>(options?: { limit?: L & (number extends L ? unknown : [L] extends [PageSize] ? unknown : never); after?: ${id}; where?: ${shape(columns, equality, "update")} }): Promise<{ data: ${row}[]; next: ${id} | null; has_more: boolean }>`);
654
655
  operations.push(`get(id: ${id}): Promise<{ data: ${row} | null }>`);
@@ -657,6 +658,7 @@ async function intake(table, reference, values, extra) {
657
658
  const numeric = equality.filter((field) => ["integer", "number"].includes(columns.find((column) => column.n === field).t));
658
659
  const fieldUnion = (list) => list.map((field) => JSON.stringify(field)).join(" | ");
659
660
  const aggregateOptions = ["count?: true"];
661
+ if (ownerOnly) aggregateOptions.push("ownerOnly?: true");
660
662
  if (numeric.length) aggregateOptions.push(`sum?: ${fieldUnion(numeric)}`, `avg?: ${fieldUnion(numeric)}`);
661
663
  if (equality.length) {
662
664
  aggregateOptions.push(`min?: ${fieldUnion(equality)}`, `max?: ${fieldUnion(equality)}`);
@@ -792,7 +794,7 @@ ${generation >= 4 ? ROW_HINTS_DECLARATION : generation >= 2 ? ROW_CAN_DECLARATIO
792
794
  class DataError extends Error{constructor(status,payload){super(payload&&typeof payload.message==="string"?payload.message:payload&&typeof payload.error==="string"?payload.error:"Data operation failed");this.name="DataError";this.status=status;this.code=payload&&typeof payload.error==="string"?payload.error:null}}
793
795
  const validateListLimit=input=>{if(input.limit!==undefined&&(!Number.isInteger(input.limit)||input.limit<1||input.limit>100))throw new DataError(400,{error:"DATA_INPUT_INVALID",message:"limit must be an integer from 1 to 100"})};
794
796
  let swReadSession=null,swInFlight=0,swStarts=0;const swReadSessionVoid=()=>{swReadSession=null;swStarts++};${generation >= 3 ? PUBLIC_BOOTSTRAP_CLIENT_RUNTIME : ""}const invoke=async(table,operation,input)=>{if(operation==="list"||operation==="relation_list")validateListLimit(input);${generation >= 3 ? PUBLIC_BOOTSTRAP_INVOKE : ""}const alone=swInFlight===0,start=++swStarts,isRead=operation==="list"||operation==="get"||operation==="aggregate"||operation==="relation_list";swInFlight++;let response;try{response=await fetch("/__sw/data",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",...(swReadSession?{"X-Sw-Read-Session":swReadSession}:{})},body:JSON.stringify({...input,contract,table,operation})})}catch(error){if(!isRead)swReadSession=null;throw error}finally{swInFlight--}const next=response.headers&&typeof response.headers.get==="function"?response.headers.get("X-Sw-Read-Session"):null;if(!alone||swStarts!==start||swInFlight!==0)swReadSession=null;else if(next&&/^swrs1[.][A-Za-z0-9_-]+[.][A-Za-z0-9_-]+$/.test(next))swReadSession=next;else if(!isRead||!response.ok)swReadSession=null;const payload=await response.json().catch(()=>{throw new DataError(response.status,{error:"INVALID_DATA_RESPONSE",message:"Data operation returned an invalid response"})});if(!response.ok)throw new DataError(response.status,payload);return payload};
795
- ${receiptCapable ? INSERT_CLIENT_RUNTIME + "const receiptTables=" + JSON.stringify(receiptTables) + ";\n" : ""}${anonymousTables.length ? ANONYMOUS_CLIENT_RUNTIME + CREATOR_CLIENT_RUNTIME : ""}${intakeTables.length ? INTAKE_CLIENT_RUNTIME : ""}${linkedSpec.length ? LINK_CLIENT_RUNTIME : ""}const data=Object.freeze(Object.fromEntries(${JSON.stringify(runtimeTables)}.map(([table,operations,relations])=>{const entries=operations.map(operation=>[operation,operation==="list"||operation==="aggregate"?(options={})=>invoke(table,operation,options):operation==="create"?${receiptCapable ? "(values,...extra)=>createWithReceipt(table,values,extra,receiptTables.includes(table))" : '(values,...extra)=>{if(extra.length!==0)throw new DataError(400,{error:"DATA_INPUT_INVALID",message:"create takes only the values to insert. Nothing was sent."});return invoke(table,operation,{values})}'}:${anonymousTables.length ? 'operation==="createAnonymous"?(values,...extra)=>createAnonymous(table,values,extra):' : ""}${intakeTables.length ? 'operation==="intake"?(reference,values,...extra)=>intake(table,reference,values,extra):' : ""}operation==="update"?(id,values)=>invoke(table,operation,{id,values}):operation==="createLink"?(id,options)=>createLink(table,id,options):operation==="links"?id=>invoke(table,"link_list",{id}):operation==="revokeLink"?(id,link_id)=>invoke(table,"link_revoke",{id,link_id}):${generation >= 2 ? 'operation==="get"?(id,options={})=>invoke(table,operation,options&&options.can===true?{id,can:true}:{id}):' : ""}id=>invoke(table,operation,{id})]);if(relations.length)entries.push(["relations",Object.freeze(Object.fromEntries(relations.map(relation=>[relation,Object.freeze({list:(parent_id,options={})=>invoke(table,"relation_list",{...options,relation,parent_id})})])))]);return[table,Object.freeze(Object.fromEntries(entries))];}).concat(${linkedSpec.length ? `[["links",links],["linked",linkedView(${JSON.stringify(linkedSpec)})]]` : "[]"})${creatorSpec.length ? `.concat([["creators",creators],["creator",creatorView(${JSON.stringify(creatorSpec)})]])` : ""}));
797
+ ${receiptCapable ? INSERT_CLIENT_RUNTIME + "const receiptTables=" + JSON.stringify(receiptTables) + ";\n" : ""}${anonymousTables.length ? ANONYMOUS_CLIENT_RUNTIME + CREATOR_CLIENT_RUNTIME : ""}${intakeTables.length ? INTAKE_CLIENT_RUNTIME : ""}${linkedSpec.length ? LINK_CLIENT_RUNTIME : ""}const data=Object.freeze(Object.fromEntries(${JSON.stringify(runtimeTables)}.map(([table,operations,relations])=>{const entries=operations.map(operation=>[operation,operation==="list"||operation==="aggregate"?(options={})=>invoke(table,operation,options):operation==="create"?${receiptCapable ? "(values,...extra)=>createWithReceipt(table,values,extra,receiptTables.includes(table))" : '(values,...extra)=>{if(extra.length!==0)throw new DataError(400,{error:"DATA_INPUT_INVALID",message:"create takes only the values to insert. Nothing was sent."});return invoke(table,operation,{values})}'}:${anonymousTables.length ? 'operation==="createAnonymous"?(values,...extra)=>createAnonymous(table,values,extra):' : ""}${intakeTables.length ? 'operation==="intake"?(reference,values,...extra)=>intake(table,reference,values,extra):' : ""}operation==="update"?(id,values)=>invoke(table,operation,{id,values}):operation==="createLink"?(id,options)=>createLink(table,id,options):operation==="links"?id=>invoke(table,"link_list",{id}):operation==="revokeLink"?(id,link_id)=>invoke(table,"link_revoke",{id,link_id}):${generation >= 6 ? 'operation==="get"?(id,options={})=>invoke(table,operation,{id,...(options?.can===true?{can:true}:{}),...(options?.ownerOnly===undefined?{}:{ownerOnly:options.ownerOnly})}):' : generation >= 2 ? 'operation==="get"?(id,options={})=>invoke(table,operation,options&&options.can===true?{id,can:true}:{id}):' : ""}id=>invoke(table,operation,{id})]);if(relations.length)entries.push(["relations",Object.freeze(Object.fromEntries(relations.map(relation=>[relation,Object.freeze({list:(parent_id,options={})=>invoke(table,"relation_list",{...options,relation,parent_id})})])))]);return[table,Object.freeze(Object.fromEntries(entries))];}).concat(${linkedSpec.length ? `[["links",links],["linked",linkedView(${JSON.stringify(linkedSpec)})]]` : "[]"})${creatorSpec.length ? `.concat([["creators",creators],["creator",creatorView(${JSON.stringify(creatorSpec)})]])` : ""}));
796
798
  export{data,DataError};
797
799
  `;
798
800
  return { contract_digest, declaration, runtime, manifest: { version: 1, contract_digest, tables, declaration, ...insertReceiptCapability === void 0 ? {} : { insert_receipt: insertReceiptCapability } } };
@@ -1072,6 +1074,7 @@ interface SomewhereDbRowHints {
1072
1074
  readonly mine: boolean;
1073
1075
  }
1074
1076
  interface SomewhereDbCountOptions { where?: SomewhereDbWhere | null }
1077
+ type SomewhereCallerReadScope = { ownerOnly?: true; asServer?: never } | { ownerOnly?: never; asServer?: true };
1075
1078
  interface SomewhereDbPlainInsertOptions { onConflict?: 'ignore' | 'update' | null }
1076
1079
  // idempotencyKey: an explicit key (16-128 of A-Z a-z 0-9 - _) for a single plain insert by a
1077
1080
  // signed-in user or visitor on a table keyed by id() with no blob() column. Any other insert
@@ -1196,10 +1199,10 @@ interface SomewhereCallerDb extends Omit<SomewhereServerDb, 'from' | 'count' | '
1196
1199
  tx(intents: readonly SomewhereDbCallerWriteIntent[]): Promise<SomewhereDbResult[]>;
1197
1200
  // can: true (signed-in callers only; never with asServer): each row also carries the row hints.
1198
1201
  from<T extends SomewhereDbTable, const C extends readonly SomewhereDbColumn<T>[] = readonly SomewhereDbColumn<T>[], const I extends readonly SomewhereDbRelationName<T>[] = []>(
1199
- table: T, options: SomewhereDbReadOptionsFor<T, C, I> & { can: true; asServer?: never }): Promise<SomewhereDbResult<SomewhereDbReadRow<T, C, I> & SomewhereDbRowHints>>;
1202
+ table: T, options: SomewhereDbReadOptionsFor<T, C, I> & { can: true; asServer?: never; ownerOnly?: true }): Promise<SomewhereDbResult<SomewhereDbReadRow<T, C, I> & SomewhereDbRowHints>>;
1200
1203
  from<T extends SomewhereDbTable, const C extends readonly SomewhereDbColumn<T>[] = readonly SomewhereDbColumn<T>[], const I extends readonly SomewhereDbRelationName<T>[] = []>(
1201
- table: T, options?: (SomewhereDbReadOptionsFor<T, C, I> & { asServer?: true; can?: false }) | null): Promise<SomewhereDbResult<SomewhereDbReadRow<T, C, I>>>;
1202
- count(table: SomewhereDbTable, options?: (SomewhereDbCountOptions & { asServer?: true }) | null): Promise<{ data: number; error: null }>;
1204
+ table: T, options?: (SomewhereDbReadOptionsFor<T, C, I> & SomewhereCallerReadScope & { can?: false }) | null): Promise<SomewhereDbResult<SomewhereDbReadRow<T, C, I>>>;
1205
+ count(table: SomewhereDbTable, options?: (SomewhereDbCountOptions & SomewhereCallerReadScope) | null): Promise<{ data: number; error: null }>;
1203
1206
  delete<T extends SomewhereDbTable>(table: T, spec?: SomewhereDbRemove | null): Promise<SomewhereDbResult<SomewhereDbRow<T>>>;
1204
1207
  readonly server: SomewhereServerDb;
1205
1208
  }
@@ -1347,7 +1350,7 @@ interface SomewhereCallerDb {
1347
1350
  live(name: 'sw.db.live was replaced by sw.rooms.live(name, sw.db.from(...))', read: never): never;
1348
1351
  query(sql: string, params?: readonly unknown[] | null, options?: SomewhereDbRawCallerOptions | null): Promise<SomewhereDbResult>;
1349
1352
  batch(statements: readonly SomewhereRawDbStatement[], options?: SomewhereDbRawCallerOptions | null): Promise<SomewhereRawBatchResult[]>;
1350
- aggregate<T extends SomewhereDbTable, const G extends SomewhereDbGroupBy<T> = SomewhereDbGroupBy<T>>(table: T, options: SomewhereDbAggregateOptionsFor<T> & { asServer?: true } & { groupBy?: G }): Promise<SomewhereDbAggregateResult<SomewhereDbAggregateRow<T, G>>>;
1353
+ aggregate<T extends SomewhereDbTable, const G extends SomewhereDbGroupBy<T> = SomewhereDbGroupBy<T>>(table: T, options: SomewhereDbAggregateOptionsFor<T> & SomewhereCallerReadScope & { groupBy?: G }): Promise<SomewhereDbAggregateResult<SomewhereDbAggregateRow<T, G>>>;
1351
1354
  tables(): Promise<string[]>;
1352
1355
  readonly scope: SomewhereDbScopeApi;
1353
1356
  }
@@ -4515,8 +4518,8 @@ var require_consumer_contract = __commonJS({
4515
4518
  "worker/containers/compile/consumer-contract.cjs"(exports2, module2) {
4516
4519
  "use strict";
4517
4520
  var CONSUMER_CONTRACT2 = Object.freeze({
4518
- version: 40,
4519
- digest: "5a319ea5f381a0b3a0847d0b7a1ee3504b434c364fa7dfa338ebf71da502e329"
4521
+ version: 41,
4522
+ digest: "f452cd4f0c1387cd4f77d2a5371baf563a93e1307e75dbef61dbad29bf0435a3"
4520
4523
  });
4521
4524
  var MEMBERSHIPS = "memberships: table({ id: id(), team_id: text(), member_id: text() }, { scope: owner(), client: { read: true } }),";
4522
4525
  var SHARES = "shares: table({ id: id(), grantee_id: text() }, { scope: owner(), client: { read: true, create: ['grantee_id'], delete: true }, unique: [['user_id', 'grantee_id']] }),";
@@ -8304,7 +8307,7 @@ function readTable(r, rawName, nameLine) {
8304
8307
  }
8305
8308
  if (entry.columns.length < 2) {
8306
8309
  throw new SchemaTsError(
8307
- `line ${entry.line}: the "unique" option on table "${rawName}" lists only "${entry.columns[0]}", the owner column the platform manages, and an owner column cannot be unique on its own. Pair it with another column (for example [['${entry.columns[0]}', 'kind']]) for per-owner uniqueness.`
8310
+ `line ${entry.line}: the "unique" option on table "${rawName}" lists only "${entry.columns[0]}", the owner column the platform manages, and an owner column cannot be unique on its own. For one row per owner, add kind: text({ default: 'profile' }), keep kind out of client writes, omit it from server writes, and declare unique: [['${entry.columns[0]}', 'kind']].`
8308
8311
  );
8309
8312
  }
8310
8313
  uniques.push(entry.columns);