@somewhere-cloud/cli 0.38.149 → 0.38.151
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 +10 -0
- package/README.md +6 -3
- package/dist/lib/bundle.js +274 -276
- package/dist/lib/bundle.js.map +3 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/runtime/DECLARED-DATA-VENDOR.json +12 -11
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/SOURCE-LINT-VENDOR.json +2 -2
- package/runtime/declared-data.cjs +29 -15
- package/runtime/source-lint.cjs +1 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@somewhere-cloud/cli",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.151",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@somewhere-cloud/cli",
|
|
9
|
-
"version": "0.38.
|
|
9
|
+
"version": "0.38.151",
|
|
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.
|
|
3
|
+
"version": "0.38.151",
|
|
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": "
|
|
69
|
+
"gitHead": "569ccf56d0e679bf9649ead7a745df97b383a802"
|
|
70
70
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
+
"source_commit": "3fd5f988ec49589e943fca1f3471ad136a738444",
|
|
2
3
|
"esbuild": "0.24.0",
|
|
3
4
|
"source_files": {
|
|
4
|
-
"shared/app-model-catalog.ts": "
|
|
5
|
+
"shared/app-model-catalog.ts": "c9a0119366beabb10157fcc9866f4d32b320b680f1c5717d837a5ca99875fa13",
|
|
5
6
|
"shared/cloud-dev-entitlement.ts": "1993a9e1c781d9daed29b3cfef0e8a370e150ce06d2acc7c408c2a24c50b4960",
|
|
6
7
|
"shared/d1-region.ts": "71cda96cfead241b4f4e35b8cd6b1d8e577f072257e91a8dbe0deaa1b142b378",
|
|
7
8
|
"shared/d1-session.ts": "2ae29b74bba68016c86d25fa2a58f8c2fce4aca8fe57fafc253d380c47a3c0ab",
|
|
8
9
|
"shared/transient-read.ts": "2f22daebdc74fed6255a29df7deda0db307f9165c1d9988dba3ee872b2584ffd",
|
|
9
10
|
"shared/types/placeholder-identity.ts": "089a46e2474a21193d3611eddd9c94b6bbe62441b3039ed80fc8499bada447ca",
|
|
10
11
|
"worker/containers/compile/checker-contract.cjs": "c6d4ebc9ec058b3562655cc4f18dc1cea7e4492eb35b7f0fd0d87e974c26b492",
|
|
11
|
-
"worker/containers/compile/consumer-contract.cjs": "
|
|
12
|
-
"worker/containers/compile/declared-data-contract.cjs": "
|
|
12
|
+
"worker/containers/compile/consumer-contract.cjs": "2255630f2db257db723570007542d6a5aebce0dd5efbe82117d3d7c8db485d2f",
|
|
13
|
+
"worker/containers/compile/declared-data-contract.cjs": "ebdc7dbc12283a7218c28e0e912e736ac27a8e9d513b82c097ebff6df3c1dd91",
|
|
13
14
|
"worker/containers/compile/generated-declarations-render.cjs": "7ffdb34645cc9eccac6eba39dc86b646a41c4de8a1a038d2b5b46f42df9f1157",
|
|
14
15
|
"worker/containers/compile/generated-declarations.cjs": "6e9902e054c5c784fd9b3c3fafc1869e79954100a45014e1132247cd82833ec4",
|
|
15
16
|
"worker/containers/compile/groups-types.cjs": "7c22b4bb96c9391005d434852600dc02bc8a6bbb99d78d2b8e3eb152f7b72c58",
|
|
16
|
-
"worker/containers/compile/runtime-types.cjs": "
|
|
17
|
+
"worker/containers/compile/runtime-types.cjs": "a74ee2d726c395f2216528e070813293d08ee7340fbca63f94e015ede1ee6df1",
|
|
17
18
|
"worker/containers/compile/schema-types.cjs": "6bd92695cd275b0c6bc7dc79daaf3189fb275449321342c967a2030f287cfdfa",
|
|
18
19
|
"worker/containers/compile/typed-data.cjs": "1c8bec853fbee4ffd34c651076a4e1f4d8b18c0c2be5e99e31df7c9283207627",
|
|
19
20
|
"worker/containers/compile/typed-files.cjs": "f2568567a53994575ede91f9a0839965e64f94eb92ae11315650189b6de0f79c",
|
|
@@ -53,14 +54,14 @@
|
|
|
53
54
|
"worker/src/utils/db-schema-deploy/extract-schema-parents.ts": "623a0034c5196e7655574387493574ce59555d0a1cffd88ff696ce85b9f56228",
|
|
54
55
|
"worker/src/utils/db-schema-deploy/extract-schema-relations.ts": "f5deac350ee915758f61d4be33711d23bad51ab20abcf153a463f0c90bfc3e27",
|
|
55
56
|
"worker/src/utils/db-schema-deploy/extract-schema-roles.ts": "a5cc7524108c19121445ea2feb85c155067b790075eb823a5d5f8c2a12e92e78",
|
|
56
|
-
"worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "
|
|
57
|
+
"worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "6ece9f185e2de72b720c6c5fb942609701874ea3951b679b8c8dc7c92b10aba3",
|
|
57
58
|
"worker/src/utils/db-schema-deploy/schema-constants.ts": "9742bc649f494963af4ae2039a1d6062cc6dbe087285bdf470f6ee71d9f76aac",
|
|
58
59
|
"worker/src/utils/db-schema-deploy/schema-ownership.ts": "e6c811a87bc657707be3518dfe547c6d97718ac073108b126eb7f791c9c08202",
|
|
59
60
|
"worker/src/utils/dev-health-class.ts": "fd430f31b9c8469f3d90e118fd8c75d1836ebcf705c1f9e93915ffa53a4cb066",
|
|
60
|
-
"worker/src/utils/errors.ts": "
|
|
61
|
-
"worker/src/utils/event-log.ts": "
|
|
62
|
-
"worker/src/utils/feed-kinds.ts": "
|
|
63
|
-
"worker/src/utils/journey-segment.ts": "
|
|
61
|
+
"worker/src/utils/errors.ts": "f57505fc7cb515abb2e2e62fc8211f359200df1183689dc621dec10c8c7f03e3",
|
|
62
|
+
"worker/src/utils/event-log.ts": "167a2ac478ff9b8b58c4f22ae39aa20ff25331c22a9e8f21d96e374b04458c78",
|
|
63
|
+
"worker/src/utils/feed-kinds.ts": "bbefa02184c09846481c55f4db6bc9e78f0e824383120d888f4a523c9b619b40",
|
|
64
|
+
"worker/src/utils/journey-segment.ts": "623837dec9b24c211b1f3be4908f6780bb4cdba175f2dfa5f34ccccfe5a1a5fc",
|
|
64
65
|
"worker/src/utils/json-exact-integers.ts": "e2eb8d3b2e17da363eb14fb46d876208579e2e92bfac173fb27527e6c4fb575e",
|
|
65
66
|
"worker/src/utils/log-sanitize.ts": "f4591089c16a34e4cbc271ec22b48566b970a62e30d3e9856b7dcd9c479fb0e8",
|
|
66
67
|
"worker/src/utils/managed-groups/errors.ts": "18d952edd7f46bb7e459d4e6678226f4bd6e040ab40073ee5a8d0802be2f3721",
|
|
@@ -68,10 +69,10 @@
|
|
|
68
69
|
"worker/src/utils/platform-compile-failure.ts": "eb4cea8a54599e2ca852b67f576a4402fb0281da4c7f45a7ed735bc36a684883",
|
|
69
70
|
"worker/src/utils/project-custom-hosts.ts": "ef693b4ea70f93fd66f3b3cda88ce68664540366caa33fa0169bf7bcfce80b2a",
|
|
70
71
|
"worker/src/utils/public-urls.ts": "44e455118f85c111316f6d8346d61e736ffcd1971c4539ea146100084aa6f21e",
|
|
71
|
-
"worker/src/utils/reference-check-inputs.ts": "
|
|
72
|
+
"worker/src/utils/reference-check-inputs.ts": "32f01f67fd971cf526af13385fbe6ae3d7876d0d15c4e8098069203eefa5e22e",
|
|
72
73
|
"worker/src/utils/telegram-attempt-receipts.ts": "a9ba55ae71f63ada44a105f1ceae04b0491bda0d6e77e5762db2dbecdd2981dd",
|
|
73
74
|
"worker/src/utils/telegram.ts": "9aaaa2597c366da1eeee9e2252e9b73e611ea97ed9558f7e07e694d9b393f053",
|
|
74
75
|
"worker/src/utils/workers-ai-comparison.ts": "18b5d5ea96f817387a5ef49733ba611c99cbb14987143c28118b1c90f3b637d4"
|
|
75
76
|
},
|
|
76
|
-
"sha256": "
|
|
77
|
+
"sha256": "bc5bfcd5f4cb91e55691654bfe11f21a37a2efae763de4db56810c96c9c99425"
|
|
77
78
|
}
|
|
@@ -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": "
|
|
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": "
|
|
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 =
|
|
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
|
|
@@ -1123,9 +1126,13 @@ type SomewhereDbColumn<T extends string> = Extract<keyof SomewhereDbRow<T>, stri
|
|
|
1123
1126
|
type SomewhereDbRelations<T extends string> = __SomewhereDeclared<T, 'relations', Record<string, unknown>>;
|
|
1124
1127
|
type SomewhereDbRelationName<T extends string> = Extract<keyof SomewhereDbRelations<T>, string>;
|
|
1125
1128
|
// A column list narrows the rows to those columns; each included relation adds
|
|
1126
|
-
// its related rows under its name.
|
|
1129
|
+
// its related rows under its name. An empty list selects all columns, just as
|
|
1130
|
+
// the structured query does when columns is omitted.
|
|
1131
|
+
type __SomewhereDbSelectedColumns<T extends string, C> = [C] extends [readonly []]
|
|
1132
|
+
? keyof SomewhereDbRow<T>
|
|
1133
|
+
: Extract<C extends readonly (infer K)[] ? K : never, keyof SomewhereDbRow<T>>;
|
|
1127
1134
|
type SomewhereDbReadRow<T extends string, C, I> = T extends keyof SomewhereDeclaredTables
|
|
1128
|
-
? Pick<SomewhereDbRow<T>,
|
|
1135
|
+
? Pick<SomewhereDbRow<T>, __SomewhereDbSelectedColumns<T, C>>
|
|
1129
1136
|
& Pick<SomewhereDbRelations<T>, Extract<I extends readonly (infer K)[] ? K : never, keyof SomewhereDbRelations<T>>>
|
|
1130
1137
|
: Record<string, unknown>;
|
|
1131
1138
|
type SomewhereDbReadOptionsFor<T extends string, C, I> = Omit<SomewhereDbReadOptions, 'columns' | 'include'> & {
|
|
@@ -1192,10 +1199,10 @@ interface SomewhereCallerDb extends Omit<SomewhereServerDb, 'from' | 'count' | '
|
|
|
1192
1199
|
tx(intents: readonly SomewhereDbCallerWriteIntent[]): Promise<SomewhereDbResult[]>;
|
|
1193
1200
|
// can: true (signed-in callers only; never with asServer): each row also carries the row hints.
|
|
1194
1201
|
from<T extends SomewhereDbTable, const C extends readonly SomewhereDbColumn<T>[] = readonly SomewhereDbColumn<T>[], const I extends readonly SomewhereDbRelationName<T>[] = []>(
|
|
1195
|
-
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>>;
|
|
1196
1203
|
from<T extends SomewhereDbTable, const C extends readonly SomewhereDbColumn<T>[] = readonly SomewhereDbColumn<T>[], const I extends readonly SomewhereDbRelationName<T>[] = []>(
|
|
1197
|
-
table: T, options?: (SomewhereDbReadOptionsFor<T, C, I> &
|
|
1198
|
-
count(table: SomewhereDbTable, options?: (SomewhereDbCountOptions &
|
|
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 }>;
|
|
1199
1206
|
delete<T extends SomewhereDbTable>(table: T, spec?: SomewhereDbRemove | null): Promise<SomewhereDbResult<SomewhereDbRow<T>>>;
|
|
1200
1207
|
readonly server: SomewhereServerDb;
|
|
1201
1208
|
}
|
|
@@ -1343,7 +1350,7 @@ interface SomewhereCallerDb {
|
|
|
1343
1350
|
live(name: 'sw.db.live was replaced by sw.rooms.live(name, sw.db.from(...))', read: never): never;
|
|
1344
1351
|
query(sql: string, params?: readonly unknown[] | null, options?: SomewhereDbRawCallerOptions | null): Promise<SomewhereDbResult>;
|
|
1345
1352
|
batch(statements: readonly SomewhereRawDbStatement[], options?: SomewhereDbRawCallerOptions | null): Promise<SomewhereRawBatchResult[]>;
|
|
1346
|
-
aggregate<T extends SomewhereDbTable, const G extends SomewhereDbGroupBy<T> = SomewhereDbGroupBy<T>>(table: T, options: SomewhereDbAggregateOptionsFor<T> &
|
|
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>>>;
|
|
1347
1354
|
tables(): Promise<string[]>;
|
|
1348
1355
|
readonly scope: SomewhereDbScopeApi;
|
|
1349
1356
|
}
|
|
@@ -4511,8 +4518,8 @@ var require_consumer_contract = __commonJS({
|
|
|
4511
4518
|
"worker/containers/compile/consumer-contract.cjs"(exports2, module2) {
|
|
4512
4519
|
"use strict";
|
|
4513
4520
|
var CONSUMER_CONTRACT2 = Object.freeze({
|
|
4514
|
-
version:
|
|
4515
|
-
digest: "
|
|
4521
|
+
version: 41,
|
|
4522
|
+
digest: "f452cd4f0c1387cd4f77d2a5371baf563a93e1307e75dbef61dbad29bf0435a3"
|
|
4516
4523
|
});
|
|
4517
4524
|
var MEMBERSHIPS = "memberships: table({ id: id(), team_id: text(), member_id: text() }, { scope: owner(), client: { read: true } }),";
|
|
4518
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']] }),";
|
|
@@ -4629,6 +4636,7 @@ __export(declared_data_vendor_entry_exports, {
|
|
|
4629
4636
|
declaredTablesFromFiles: () => declaredTablesFromFiles,
|
|
4630
4637
|
filesDeclarationFromFiles: () => filesDeclarationFromFiles,
|
|
4631
4638
|
generateFromFiles: () => generateFromFiles,
|
|
4639
|
+
isPlainPageScript: () => isPlainPageScript,
|
|
4632
4640
|
isRuntimeEndpointGlobal: () => isRuntimeEndpointGlobal,
|
|
4633
4641
|
localDeclarationFromFiles: () => localDeclarationFromFiles,
|
|
4634
4642
|
parseConsumerContractHeader: () => import_consumer_contract.parseConsumerContractHeader,
|
|
@@ -8299,7 +8307,7 @@ function readTable(r, rawName, nameLine) {
|
|
|
8299
8307
|
}
|
|
8300
8308
|
if (entry.columns.length < 2) {
|
|
8301
8309
|
throw new SchemaTsError(
|
|
8302
|
-
`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.
|
|
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']].`
|
|
8303
8311
|
);
|
|
8304
8312
|
}
|
|
8305
8313
|
uniques.push(entry.columns);
|
|
@@ -8648,6 +8656,11 @@ function referenceCheckDeclarations(graphFiles) {
|
|
|
8648
8656
|
hasSchema: graphFiles["db/schema.ts"] !== void 0
|
|
8649
8657
|
});
|
|
8650
8658
|
}
|
|
8659
|
+
function isPlainPageScript(file, functions) {
|
|
8660
|
+
if (!/\.(?:js|jsx|mjs|cjs)$/i.test(file)) return false;
|
|
8661
|
+
if (typeof functions?.[file] === "string") return false;
|
|
8662
|
+
return !file.startsWith("functions/");
|
|
8663
|
+
}
|
|
8651
8664
|
var RUNTIME_ENDPOINT_ACCESS = /^sw(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*\n)*\??\.(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*\n)*endpoint(?![\w$])/;
|
|
8652
8665
|
function isRuntimeEndpointGlobal(diag, functions) {
|
|
8653
8666
|
if (!/^Cannot find name 'sw'\./.test(diag.message)) return false;
|
|
@@ -8692,6 +8705,7 @@ function filesDeclarationFromFiles(files) {
|
|
|
8692
8705
|
declaredTablesFromFiles,
|
|
8693
8706
|
filesDeclarationFromFiles,
|
|
8694
8707
|
generateFromFiles,
|
|
8708
|
+
isPlainPageScript,
|
|
8695
8709
|
isRuntimeEndpointGlobal,
|
|
8696
8710
|
localDeclarationFromFiles,
|
|
8697
8711
|
parseConsumerContractHeader,
|