@somewhere-tech/cli 0.37.19 → 0.37.21
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.
|
@@ -60,6 +60,7 @@ export function prepareDeclaredData(projectDir) {
|
|
|
60
60
|
generatedContents(filesPath);
|
|
61
61
|
let client;
|
|
62
62
|
// Server reads and writes of the declared tables are typed from the same schema.
|
|
63
|
+
let localDeclaration;
|
|
63
64
|
let tables;
|
|
64
65
|
let runtimeDeclaration;
|
|
65
66
|
let filesDeclaration;
|
|
@@ -67,6 +68,7 @@ export function prepareDeclaredData(projectDir) {
|
|
|
67
68
|
try {
|
|
68
69
|
const files = { 'db/schema.ts': readFileSync(schemaPath, 'utf8') };
|
|
69
70
|
client = generator.generateFromFiles(files);
|
|
71
|
+
localDeclaration = generator.localDeclarationFromFiles(files);
|
|
70
72
|
tables = generator.declaredTablesFromFiles(files);
|
|
71
73
|
runtimeDeclaration = generator.runtimeDeclarationFromFiles(files);
|
|
72
74
|
filesDeclaration = generator.filesDeclarationFromFiles(files);
|
|
@@ -80,7 +82,7 @@ export function prepareDeclaredData(projectDir) {
|
|
|
80
82
|
throw error;
|
|
81
83
|
}
|
|
82
84
|
const declaration = GENERATED_DATA_HEADER + runtimeDeclaration + tables
|
|
83
|
-
+ generator.ENDPOINT_DECLARATION + SW_ENDPOINT_GLOBAL + generator.SCHEMA_DECLARATION + (
|
|
85
|
+
+ generator.ENDPOINT_DECLARATION + SW_ENDPOINT_GLOBAL + generator.SCHEMA_DECLARATION + (localDeclaration ?? '');
|
|
84
86
|
if (declaration !== previous)
|
|
85
87
|
writeFileSync(declarationPath, declaration);
|
|
86
88
|
// Only declared collections exist on somewhere:files; with none, the module is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declared-data.js","sourceRoot":"","sources":["../../src/lib/declared-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EA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|
"": {
|
|
8
8
|
"name": "@somewhere-tech/cli",
|
|
9
|
-
"version": "0.37.
|
|
9
|
+
"version": "0.37.21",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@modelcontextprotocol/sdk",
|
|
12
12
|
"chokidar",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@somewhere-tech/cli",
|
|
3
|
-
"version": "0.37.
|
|
4
|
-
"description": "CLI for somewhere.tech
|
|
3
|
+
"version": "0.37.21",
|
|
4
|
+
"description": "CLI for somewhere.tech \u2014 auth, projects, deploy, pull, promote, db, logs, env, MCP bridge.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"somewhere",
|
|
7
7
|
"somewhere.tech",
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"esbuild": "0.24.0",
|
|
3
3
|
"source_files": {
|
|
4
|
-
"worker/containers/compile/declared-data-contract.cjs": "
|
|
4
|
+
"worker/containers/compile/declared-data-contract.cjs": "dc5597c4b138a8450927b9881982769e08d558f73bb2c635de5bcbe17da4fc2c",
|
|
5
5
|
"worker/containers/compile/groups-types.cjs": "f0f38ca6f160561f997b20af44763bd07232deb2668a536cd52c1974fcfed2c8",
|
|
6
|
-
"worker/containers/compile/runtime-types.cjs": "
|
|
6
|
+
"worker/containers/compile/runtime-types.cjs": "75e3e32654c3795915ddc56d5ff9f7088a305db8e2006c764f24b436cdae22b7",
|
|
7
7
|
"worker/containers/compile/schema-types.cjs": "97941a4f80f50f4a48b828a6a2695f6f0c606ab6e74b4511fbb99e786dc4f0c4",
|
|
8
|
-
"worker/containers/compile/typed-data.cjs": "
|
|
8
|
+
"worker/containers/compile/typed-data.cjs": "1c8bec853fbee4ffd34c651076a4e1f4d8b18c0c2be5e99e31df7c9283207627",
|
|
9
9
|
"worker/containers/compile/typed-files.cjs": "a0b1818afbc7673f84583c76436a3b3ca1d1fdf63d8d8db138b36646103f0708",
|
|
10
10
|
"worker/src/services/jobs/limits.ts": "f806f045dcb92f7da1e830aab65b74185ebd3071aeade368db776f3a0546de38",
|
|
11
|
-
"worker/src/utils/authority/scope-enforcement.ts": "
|
|
11
|
+
"worker/src/utils/authority/scope-enforcement.ts": "35735e46295d3a6a38ebdf87e5325721e097355b90efd80deba520792828031f",
|
|
12
12
|
"worker/src/utils/db-schema-deploy/bigint-text.ts": "ef3f581daeecb234d2c1e288bc09495a6facd7b0354b300134918f6c0cf10cc2",
|
|
13
|
-
"worker/src/utils/db-schema-deploy/client-contract-source.ts": "
|
|
13
|
+
"worker/src/utils/db-schema-deploy/client-contract-source.ts": "b56cc7f2f6dd5c05e02534bc6fabdf8afe09595ab5e56fad882d51871423277e",
|
|
14
14
|
"worker/src/utils/db-schema-deploy/client-permissions.ts": "9c0aecd4a9698a9813aa8ec3315c1a8c99ba2fd1150d6d820a86ea3ec7b9890b",
|
|
15
15
|
"worker/src/utils/db-schema-deploy/extract-schema-app-roles.ts": "7f0e6ce3e213d56b678a60de133d10ed6f51f3a42ba73071d821d42a48c676a2",
|
|
16
16
|
"worker/src/utils/db-schema-deploy/extract-schema-bindings.ts": "34a2bf98da533afa60cc3fe46c3ff029300f06fef0bfecd98e028bff181ca1b3",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"worker/src/utils/managed-groups/errors.ts": "4830b1ad7357a79760b0bcc68884e562cfbc07d12a37cc73651a6fcb256d682f",
|
|
28
28
|
"worker/src/utils/managed-groups/policy.ts": "2259a883645c8bfd607ead7c37387f3ffd42ac9dfb86722c72b224adb498511e"
|
|
29
29
|
},
|
|
30
|
-
"sha256": "
|
|
30
|
+
"sha256": "b1331bdb68e3d6c564986351609f7ebe8276001036e40281521de2fedfd71ee9"
|
|
31
31
|
}
|
|
@@ -102,7 +102,12 @@ var require_declared_data_contract = __commonJS({
|
|
|
102
102
|
else if (value.k === "a") value.p.forEach((item) => policyMembershipTables(item, out));
|
|
103
103
|
else if (value.k === "p") policyMembershipTables(value.p, out);
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function validateInsertReceiptCapability(value) {
|
|
106
|
+
if (value !== void 0 && value !== "insert-v1") fail("insert receipt capability");
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
function canonicalize2(schema, intents, scopes, insertReceiptCapability) {
|
|
110
|
+
validateInsertReceiptCapability(insertReceiptCapability);
|
|
106
111
|
record(schema, "schema");
|
|
107
112
|
record(intents, "intents");
|
|
108
113
|
record(scopes, "scopes");
|
|
@@ -258,7 +263,7 @@ var require_declared_data_contract = __commonJS({
|
|
|
258
263
|
if (!relation || !child || child.policy?.k !== "p" || child.policy.v !== relation.fk || child.policy.t !== table.name) fail(`${table.name}.links.children`);
|
|
259
264
|
}
|
|
260
265
|
}
|
|
261
|
-
return JSON.stringify({ version: 1, tables });
|
|
266
|
+
return JSON.stringify({ version: 1, tables, ...insertReceiptCapability === void 0 ? {} : { insert_receipt: insertReceiptCapability } });
|
|
262
267
|
}
|
|
263
268
|
function columnType(column) {
|
|
264
269
|
const type = { integer: "number", bigint: "string", number: "number", text: "string", timestamp: "string", boolean: "boolean", json: "Json", blob: "number[]" }[column.t];
|
|
@@ -273,11 +278,69 @@ var require_declared_data_contract = __commonJS({
|
|
|
273
278
|
return values.length ? `{ ${values.join("; ")} }` : "Record<string, never>";
|
|
274
279
|
}
|
|
275
280
|
var LINK_CLIENT_RUNTIME = 'const b64url=s=>btoa(unescape(encodeURIComponent(s))).replace(/\\+/g,"-").replace(/\\//g,"_").replace(/=+$/,"");const createLink=async(table,id,options={})=>{const result=await invoke(table,"link_create",{id,access:options.access,...(options.expiresInDays===undefined?{}:{expires_in_days:options.expiresInDays})});const route=typeof options.returnTo==="string"?options.returnTo:location.pathname+location.search+location.hash;return{link_id:result.link_id,url:location.origin+"/__sw/link#"+result.secret+"."+b64url(route),expires_at:result.expires_at}};const linkDoor=async(path,init)=>{const response=await fetch(path,{credentials:"same-origin",cache:"no-store",...init});const payload=await response.json().catch(()=>({error:"INVALID_DATA_RESPONSE",message:"Link operation returned an invalid response"}));if(!response.ok)throw new DataError(response.status,payload);return payload};const links=Object.freeze({opened:()=>{try{const list=JSON.parse(sessionStorage.getItem("__sw_links_opened")||"[]");return Array.isArray(list)?list:[]}catch(_){return[]}},sessions:async()=>{const payload=await linkDoor("/__sw/link/sessions",{method:"GET"});return{data:payload.data}},forget:async linkId=>{await linkDoor("/__sw/link/forget",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(linkId===undefined?{}:{link_id:linkId})})}});const linkedView=spec=>link=>{if(typeof link!=="string"||!/^lnk_[0-9a-f]{32}$/.test(link))throw new DataError(400,{error:"DATA_INPUT_INVALID",message:"linked() needs a link id"});const view={};for(const[table,canUpdate,children]of spec){const relations={};const root={get:id=>invoke(table,"get",{id,link})};if(canUpdate)root.update=(id,values)=>invoke(table,"update",{id,values,link});for(const[relation,child,canCreate,canUpdateChild]of children){relations[relation]=Object.freeze({list:(parent_id,options={})=>invoke(table,"relation_list",{...options,relation,parent_id,link})});const childOps={};if(canCreate)childOps.create=values=>invoke(child,"create",{values,link});if(canUpdateChild)childOps.update=(id,values)=>invoke(child,"update",{id,values,link});if(canCreate||canUpdateChild)view[child]=Object.freeze(childOps)}if(children.length)root.relations=Object.freeze(relations);view[table]=Object.freeze(root)}return Object.freeze(view)};\n';
|
|
276
|
-
|
|
277
|
-
|
|
281
|
+
var INSERT_CLIENT_RUNTIME = String.raw`
|
|
282
|
+
function insertReceipt(value) {
|
|
283
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)
|
|
284
|
+
|| Object.keys(value).sort().join(',') !== 'created_at,refuse_until,replayed,result_until'
|
|
285
|
+
|| typeof value.replayed !== 'boolean' || !Number.isSafeInteger(value.created_at) || value.created_at <= 0
|
|
286
|
+
|| value.result_until !== value.created_at + 86400000 || value.refuse_until !== value.created_at + 691200000) return null;
|
|
287
|
+
return Object.freeze({...value});
|
|
288
|
+
}
|
|
289
|
+
function insertError(status, payload) {
|
|
290
|
+
const error = new DataError(status, payload);
|
|
291
|
+
if (payload && ['committed', 'unknown', 'read_failed', 'not_committed'].includes(payload.outcome)) error.outcome = payload.outcome;
|
|
292
|
+
if (payload && payload.write_committed === true) error.write_committed = true;
|
|
293
|
+
error.retry = false; error.retryable = false;
|
|
294
|
+
const receipt = insertReceipt(payload && payload.idempotency);
|
|
295
|
+
if (receipt) error.idempotency = receipt;
|
|
296
|
+
return error;
|
|
297
|
+
}
|
|
298
|
+
async function createWithReceipt(table, values, extra, eligible) {
|
|
299
|
+
// create takes only values: the retry key is a private random nonce this client allocates,
|
|
300
|
+
// never a caller choice. Anything more refuses before the network.
|
|
301
|
+
if (extra.length !== 0) throw new DataError(400, {error:'DATA_INPUT_INVALID', message:'create takes only the values to insert. Nothing was sent.'});
|
|
302
|
+
if (!eligible) return invoke(table, 'create', {values});
|
|
303
|
+
// 128 random bits as 32 lowercase hex characters: the platform's exact client key format.
|
|
304
|
+
const key = Array.from(crypto.getRandomValues(new Uint8Array(16)), byte => byte.toString(16).padStart(2,'0')).join('');
|
|
305
|
+
const createdAt = Date.now();
|
|
306
|
+
// Serialize once: retries never observe later caller mutations or re-run toJSON.
|
|
307
|
+
const body = JSON.stringify({values, contract, table, operation:'create', idempotency_key:key});
|
|
308
|
+
let handle;
|
|
309
|
+
const attach = target => { Object.defineProperty(target, 'request', {value:handle, enumerable:false, writable:false, configurable:false}); return target; };
|
|
310
|
+
const send = async () => {
|
|
311
|
+
const now = Date.now();
|
|
312
|
+
if (!Number.isFinite(createdAt) || !Number.isFinite(now) || now < createdAt || now >= createdAt + 691200000) {
|
|
313
|
+
throw attach(insertError(410, {error:'IDEMPOTENCY_RETRY_EXPIRED', message:'This request can no longer be retried safely. Nothing was sent.'}));
|
|
314
|
+
}
|
|
315
|
+
let response, payload;
|
|
316
|
+
try { response = await fetch('/__sw/data', {method:'POST', credentials:'same-origin', headers:{'Content-Type':'application/json'}, body}); }
|
|
317
|
+
catch (_) { throw attach(insertError(503, {error:'DB_WRITE_OUTCOME_UNKNOWN', message:'The write outcome could not be confirmed. Retry this request with its original key.', outcome:'unknown'})); }
|
|
318
|
+
try { payload = await response.json(); }
|
|
319
|
+
catch (_) { throw attach(insertError(response.status, {error:'INVALID_DATA_RESPONSE', message:'The write response could not be read. Retry this request with its original key.', outcome:'unknown'})); }
|
|
320
|
+
if (!response.ok) throw attach(insertError(response.status, payload));
|
|
321
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload) || !insertReceipt(payload.idempotency)) {
|
|
322
|
+
// A successful old/malformed response cannot establish receipt protection.
|
|
323
|
+
throw insertError(502, {error:'IDEMPOTENCY_RECEIPT_INVALID', message:'The write succeeded, but retry protection could not be confirmed. Do not retry it.', outcome:'committed', write_committed:true});
|
|
324
|
+
}
|
|
325
|
+
payload.idempotency = insertReceipt(payload.idempotency);
|
|
326
|
+
return attach(payload);
|
|
327
|
+
};
|
|
328
|
+
handle = Object.freeze({key, createdAt, retry:send});
|
|
329
|
+
return send();
|
|
330
|
+
}
|
|
331
|
+
`;
|
|
332
|
+
var INSERT_CLIENT_DECLARATIONS = `
|
|
333
|
+
export interface InsertReceipt { readonly replayed: boolean; readonly created_at: number; readonly result_until: number; readonly refuse_until: number; }
|
|
334
|
+
export interface InsertRequest<T> { readonly key: string; readonly createdAt: number; retry(): Promise<T>; }
|
|
335
|
+
export type InsertResult<T> = T & { readonly idempotency: InsertReceipt; readonly request: InsertRequest<InsertResult<T>> };
|
|
336
|
+
`;
|
|
337
|
+
function describeDataClient2(authority, contract_digest, insertReceiptCapability, localTypes = false) {
|
|
338
|
+
const canonical = authority ? canonicalize2(authority.schema, authority.intents, authority.scopes, insertReceiptCapability) : canonicalize2({}, {}, {}, insertReceiptCapability);
|
|
278
339
|
const { tables } = JSON.parse(canonical);
|
|
279
340
|
const declarations = [];
|
|
280
341
|
const runtimeTables = [];
|
|
342
|
+
const receiptTables = [];
|
|
343
|
+
const receiptCapable = insertReceiptCapability === "insert-v1";
|
|
281
344
|
const linkedDeclarations = [];
|
|
282
345
|
const linkedSpec = [];
|
|
283
346
|
for (const table of tables) {
|
|
@@ -310,7 +373,9 @@ var require_declared_data_contract = __commonJS({
|
|
|
310
373
|
const mutation = client.read === false ? "{ count: number; changes: number }" : `{ data: ${row} | null; count: number; changes: number }`;
|
|
311
374
|
if (client.create !== null) {
|
|
312
375
|
const required = table.policy?.k === "p" ? /* @__PURE__ */ new Set([table.policy.v]) : /* @__PURE__ */ new Set();
|
|
313
|
-
|
|
376
|
+
const eligible = columns.some((column) => column.n === primaryKey && column.t === "integer") && !columns.some((column) => column.t === "blob");
|
|
377
|
+
if (receiptCapable && eligible) receiptTables.push(name);
|
|
378
|
+
operations.push(`create(values: ${shape(columns, client.create, "create", required)}): Promise<${receiptCapable && eligible ? `InsertResult<${mutation}>` : mutation}>`);
|
|
314
379
|
methods.push("create");
|
|
315
380
|
}
|
|
316
381
|
if (client.update !== null) {
|
|
@@ -374,19 +439,22 @@ var require_declared_data_contract = __commonJS({
|
|
|
374
439
|
}
|
|
375
440
|
const declaration = `declare module ${JSON.stringify("somewhere:data")} {
|
|
376
441
|
export type Json = string | number | boolean | null | Json[] | { [key: string]: Json };
|
|
377
|
-
export class DataError extends Error { readonly status: number; readonly code: string | null; constructor(status: number, payload: unknown); }
|
|
442
|
+
${receiptCapable ? localTypes ? INSERT_CLIENT_DECLARATIONS.replace("readonly idempotency:", "readonly idempotency?:").replace("readonly request:", "readonly request?:") : INSERT_CLIENT_DECLARATIONS : ""} export class DataError extends Error { readonly status: number; readonly code: string | null;${receiptCapable ? " readonly request?: InsertRequest<unknown>; readonly outcome?: string; readonly write_committed?: boolean; readonly retry?: false; readonly retryable?: false; readonly idempotency?: InsertReceipt;" : ""} constructor(status: number, payload: unknown); }
|
|
378
443
|
export const data: { ${declarations.join(";\n ")} };
|
|
379
444
|
}
|
|
380
445
|
`;
|
|
381
446
|
const runtime = `const contract=${JSON.stringify(contract_digest)};
|
|
382
447
|
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}}
|
|
383
448
|
const invoke=async(table,operation,input)=>{const response=await fetch("/__sw/data",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({...input,contract,table,operation})});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};
|
|
384
|
-
${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"?values=>invoke(table,operation,{values}):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}):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)})]]` : "[]"})));
|
|
449
|
+
${receiptCapable ? INSERT_CLIENT_RUNTIME + "const receiptTables=" + JSON.stringify(receiptTables) + ";\n" : ""}${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=>invoke(table,operation,{values})"}: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}):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)})]]` : "[]"})));
|
|
385
450
|
export{data,DataError};
|
|
386
451
|
`;
|
|
387
|
-
return { contract_digest, declaration, runtime, manifest: { version: 1, contract_digest, tables, declaration } };
|
|
452
|
+
return { contract_digest, declaration, runtime, manifest: { version: 1, contract_digest, tables, declaration, ...insertReceiptCapability === void 0 ? {} : { insert_receipt: insertReceiptCapability } } };
|
|
453
|
+
}
|
|
454
|
+
function describeDataClientLocalDeclaration2(authority) {
|
|
455
|
+
return describeDataClient2(authority, "", "insert-v1", true).declaration;
|
|
388
456
|
}
|
|
389
|
-
module2.exports = { canonicalize: canonicalize2, describeDataClient: describeDataClient2 };
|
|
457
|
+
module2.exports = { canonicalize: canonicalize2, describeDataClient: describeDataClient2, describeDataClientLocalDeclaration: describeDataClientLocalDeclaration2, validateInsertReceiptCapability };
|
|
390
458
|
}
|
|
391
459
|
});
|
|
392
460
|
|
|
@@ -399,9 +467,9 @@ var require_typed_data = __commonJS({
|
|
|
399
467
|
var MODULE_NAME = "somewhere:data";
|
|
400
468
|
var CLIENT_FILE2 = "__somewhere_data.d.ts";
|
|
401
469
|
var MANIFEST_PATH = "_internal/declared-data.json";
|
|
402
|
-
function generateDataClient2(authority) {
|
|
403
|
-
const canonical = authority ? canonicalize2(authority.schema, authority.intents, authority.scopes) : canonicalize2({}, {}, {});
|
|
404
|
-
return describeDataClient2(authority, crypto2.createHash("sha256").update(canonical).digest("hex"));
|
|
470
|
+
function generateDataClient2(authority, insertReceiptCapability) {
|
|
471
|
+
const canonical = authority ? canonicalize2(authority.schema, authority.intents, authority.scopes, insertReceiptCapability) : canonicalize2({}, {}, {}, insertReceiptCapability);
|
|
472
|
+
return describeDataClient2(authority, crypto2.createHash("sha256").update(canonical).digest("hex"), insertReceiptCapability);
|
|
405
473
|
}
|
|
406
474
|
function virtualDataPlugin(analysis) {
|
|
407
475
|
return {
|
|
@@ -619,7 +687,15 @@ interface SomewhereDbReadOptions {
|
|
|
619
687
|
has?: Readonly<Record<string, SomewhereDbWhere>> | null;
|
|
620
688
|
}
|
|
621
689
|
interface SomewhereDbCountOptions { where?: SomewhereDbWhere | null }
|
|
622
|
-
interface
|
|
690
|
+
interface SomewhereDbPlainInsertOptions { onConflict?: 'ignore' | 'update' | null }
|
|
691
|
+
// idempotencyKey: an explicit key (16-128 of A-Z a-z 0-9 - _) for a single plain insert by a
|
|
692
|
+
// signed-in user or visitor on a table keyed by id() with no blob() column. Any other insert
|
|
693
|
+
// given a key refuses before anything runs. Eligible inserts without one get a fresh key.
|
|
694
|
+
interface SomewhereDbInsertOptions extends SomewhereDbPlainInsertOptions { idempotencyKey?: string }
|
|
695
|
+
interface SomewhereDbReceipt { readonly replayed: boolean; readonly created_at: number; readonly result_until: number; readonly refuse_until: number }
|
|
696
|
+
// Process-local: retry() repeats this exact request with the same key under the current
|
|
697
|
+
// context's authority, until eight days after createdAt. It never runs by itself.
|
|
698
|
+
interface SomewhereDbInsertRequest<R> { readonly key: string; readonly createdAt: number; retry(): Promise<R> }
|
|
623
699
|
type SomewhereDbValues = Readonly<Record<string, __SomewhereJson>>;
|
|
624
700
|
type SomewhereDbIncrement = Readonly<Record<string, number>>;
|
|
625
701
|
type SomewhereDbUpdate = {
|
|
@@ -630,7 +706,7 @@ type SomewhereDbUpdate = {
|
|
|
630
706
|
);
|
|
631
707
|
interface SomewhereDbRemove { where?: SomewhereDbWhere | null }
|
|
632
708
|
type SomewhereDbWriteIntent =
|
|
633
|
-
| { op: 'insert'; table: string; values: SomewhereDbValues; options?:
|
|
709
|
+
| { op: 'insert'; table: string; values: SomewhereDbValues; options?: SomewhereDbPlainInsertOptions | null }
|
|
634
710
|
| ({ op: 'update'; table: string } & SomewhereDbUpdate)
|
|
635
711
|
| { op: 'remove'; table: string; where?: SomewhereDbWhere | null };
|
|
636
712
|
// db/schema.ts's tables, one entry each, generated beside this declaration
|
|
@@ -679,6 +755,12 @@ interface SomewhereDbResult<Row = Record<string, unknown>> {
|
|
|
679
755
|
live_delivery?: { delivery: 'invalidated' }
|
|
680
756
|
| { delivery: 'resync_required'; reason: string };
|
|
681
757
|
}
|
|
758
|
+
// A keyed insert's result (whether an insert is keyed is decided at run time): the receipt
|
|
759
|
+
// bounds, and a non-enumerable request handle. A replay carries the original values.
|
|
760
|
+
interface SomewhereDbInsertResult<Row = Record<string, unknown>> extends SomewhereDbResult<Row> {
|
|
761
|
+
idempotency?: SomewhereDbReceipt;
|
|
762
|
+
readonly request?: SomewhereDbInsertRequest<SomewhereDbInsertResult<Row>>;
|
|
763
|
+
}
|
|
682
764
|
interface SomewhereRawDbStatement {
|
|
683
765
|
sql: string;
|
|
684
766
|
params?: readonly unknown[];
|
|
@@ -695,7 +777,7 @@ interface SomewhereServerDb {
|
|
|
695
777
|
table: T, options?: SomewhereDbReadOptionsFor<T, C, I> | null): Promise<SomewhereDbResult<SomewhereDbReadRow<T, C, I>>>;
|
|
696
778
|
count(table: SomewhereDbTable, options?: SomewhereDbCountOptions | null): Promise<{ data: number; error: null }>;
|
|
697
779
|
// Server authority names row identity (owner column or shared authorship) explicitly on insert.
|
|
698
|
-
insert<T extends SomewhereDbTable>(table: T, values: __SomewhereDeclared<T, 'serverInsert', SomewhereDbValues>, options?:
|
|
780
|
+
insert<T extends SomewhereDbTable>(table: T, values: __SomewhereDeclared<T, 'serverInsert', SomewhereDbValues>, options?: SomewhereDbPlainInsertOptions | null): Promise<SomewhereDbResult<SomewhereDbRow<T>>>;
|
|
699
781
|
update<T extends SomewhereDbTable>(table: T, spec: SomewhereDbUpdateFor<T, 'serverSet'>): Promise<SomewhereDbResult<SomewhereDbRow<T>>>;
|
|
700
782
|
remove<T extends SomewhereDbTable>(table: T, spec?: SomewhereDbRemove | null): Promise<SomewhereDbResult<SomewhereDbRow<T>>>;
|
|
701
783
|
// Closed atomic batch, 1-100 intents checked before execution. No callback,
|
|
@@ -705,7 +787,7 @@ interface SomewhereServerDb {
|
|
|
705
787
|
}
|
|
706
788
|
interface SomewhereCallerDb extends Omit<SomewhereServerDb, 'from' | 'count' | 'insert' | 'update'> {
|
|
707
789
|
// The platform composes row identity from the verified user.
|
|
708
|
-
insert<T extends SomewhereDbTable>(table: T, values: __SomewhereDeclared<T, 'insert', SomewhereDbValues>, options?: SomewhereDbInsertOptions | null): Promise<
|
|
790
|
+
insert<T extends SomewhereDbTable>(table: T, values: __SomewhereDeclared<T, 'insert', SomewhereDbValues>, options?: SomewhereDbInsertOptions | null): Promise<SomewhereDbInsertResult<SomewhereDbRow<T>>>;
|
|
709
791
|
update<T extends SomewhereDbTable>(table: T, spec: SomewhereDbUpdateFor<T, 'set'>): Promise<SomewhereDbResult<SomewhereDbRow<T>>>;
|
|
710
792
|
from<T extends SomewhereDbTable, const C extends readonly SomewhereDbColumn<T>[] = readonly SomewhereDbColumn<T>[], const I extends readonly SomewhereDbRelationName<T>[] = []>(
|
|
711
793
|
table: T, options?: (SomewhereDbReadOptionsFor<T, C, I> & { asServer?: true }) | null): Promise<SomewhereDbResult<SomewhereDbReadRow<T, C, I>>>;
|
|
@@ -2347,8 +2429,45 @@ interface SomewhereAiModerationResult {
|
|
|
2347
2429
|
model: string;
|
|
2348
2430
|
provider: string;
|
|
2349
2431
|
}
|
|
2432
|
+
// sw.ai.evaluate: typed decisions. Probabilities are model output, not
|
|
2433
|
+
// calibrated guarantees; choose thresholds from labelled cases.
|
|
2434
|
+
type SomewhereAiEvaluateQuestion =
|
|
2435
|
+
| { type: 'noul'; instructions: string | SomewhereJsonObject | readonly unknown[]; criteria?: { true?: unknown; false?: unknown } }
|
|
2436
|
+
| { type: 'choice'; instructions: string | SomewhereJsonObject | readonly unknown[]; criteria: Record<string, unknown> }
|
|
2437
|
+
| { type: 'score'; instructions: string | SomewhereJsonObject | readonly unknown[]; criteria: readonly unknown[] };
|
|
2438
|
+
type SomewhereAiEvaluateImage =
|
|
2439
|
+
| string
|
|
2440
|
+
| { content_type: 'image/png' | 'image/jpeg' | 'image/webp'; base64: string };
|
|
2441
|
+
type SomewhereAiEvaluateOptions<Q extends Record<string, SomewhereAiEvaluateQuestion>> = {
|
|
2442
|
+
state: string | SomewhereJsonObject | readonly unknown[];
|
|
2443
|
+
questions: Q;
|
|
2444
|
+
} & (
|
|
2445
|
+
// Text routes to jev and images to clef-flash when model is omitted; jev reads text only.
|
|
2446
|
+
| { model: 'jev'; images?: never }
|
|
2447
|
+
| { model?: 'clef-flash'; images?: readonly SomewhereAiEvaluateImage[] }
|
|
2448
|
+
);
|
|
2449
|
+
interface SomewhereAiEvaluateNoulAnswer { type: 'noul'; noul: number }
|
|
2450
|
+
interface SomewhereAiEvaluateChoiceAnswer<O extends string = string> {
|
|
2451
|
+
type: 'choice'; choice: O; probabilities: Record<O, number>; confidence: number;
|
|
2452
|
+
}
|
|
2453
|
+
interface SomewhereAiEvaluateScoreAnswer {
|
|
2454
|
+
type: 'score'; score: number; legend: Record<string, unknown>; probabilities: Record<string, number>; confidence: number;
|
|
2455
|
+
}
|
|
2456
|
+
type SomewhereAiEvaluateAnswer<Q> =
|
|
2457
|
+
Q extends { type: 'noul' } ? SomewhereAiEvaluateNoulAnswer
|
|
2458
|
+
: Q extends { type: 'choice'; criteria: infer C } ? SomewhereAiEvaluateChoiceAnswer<Extract<keyof C, string>>
|
|
2459
|
+
: Q extends { type: 'score' } ? SomewhereAiEvaluateScoreAnswer
|
|
2460
|
+
: never;
|
|
2461
|
+
interface SomewhereAiEvaluateResult<Q extends Record<string, SomewhereAiEvaluateQuestion>> {
|
|
2462
|
+
model: 'clef-flash' | 'jev';
|
|
2463
|
+
provider_model: string;
|
|
2464
|
+
routed_by: 'model' | 'images' | 'text';
|
|
2465
|
+
answers: { [K in keyof Q]: SomewhereAiEvaluateAnswer<Q[K]> };
|
|
2466
|
+
usage: { input_tokens: number };
|
|
2467
|
+
cost: SomewhereAiCost;
|
|
2468
|
+
}
|
|
2350
2469
|
interface SomewhereAiCatalogEntry {
|
|
2351
|
-
feature: 'transcribe' | 'tts' | 'generate_image' | 'remove_background' | 'embed' | 'complete';
|
|
2470
|
+
feature: 'transcribe' | 'tts' | 'generate_image' | 'remove_background' | 'embed' | 'complete' | 'evaluate';
|
|
2352
2471
|
model: string;
|
|
2353
2472
|
provider: string;
|
|
2354
2473
|
label: string;
|
|
@@ -2386,6 +2505,7 @@ interface SomewhereRuntimeAi {
|
|
|
2386
2505
|
removeBackground(options: SomewhereAiRemoveBackgroundOptions): Promise<never>;
|
|
2387
2506
|
embeddings(options: SomewhereAiEmbeddingsOptions): Promise<SomewhereAiEmbeddingsResult>;
|
|
2388
2507
|
moderate(text: string): Promise<SomewhereAiModerationResult>;
|
|
2508
|
+
evaluate<const Q extends Record<string, SomewhereAiEvaluateQuestion>>(options: SomewhereAiEvaluateOptions<Q>): Promise<SomewhereAiEvaluateResult<Q>>;
|
|
2389
2509
|
catalog(): Promise<SomewhereAiCatalog>;
|
|
2390
2510
|
}
|
|
2391
2511
|
|
|
@@ -3596,6 +3716,7 @@ __export(declared_data_vendor_entry_exports, {
|
|
|
3596
3716
|
declaredTablesFromFiles: () => declaredTablesFromFiles,
|
|
3597
3717
|
filesDeclarationFromFiles: () => filesDeclarationFromFiles,
|
|
3598
3718
|
generateFromFiles: () => generateFromFiles,
|
|
3719
|
+
localDeclarationFromFiles: () => localDeclarationFromFiles,
|
|
3599
3720
|
runtimeDeclarationFromFiles: () => runtimeDeclarationFromFiles
|
|
3600
3721
|
});
|
|
3601
3722
|
module.exports = __toCommonJS(declared_data_vendor_entry_exports);
|
|
@@ -4079,7 +4200,7 @@ function bakedTableSchemaFromDeclared(declaredJson) {
|
|
|
4079
4200
|
if (declaredScope.kind !== "owner" || typeof declaredScope.visitors !== "boolean") return null;
|
|
4080
4201
|
if (declaredScope.visitors) visitors = true;
|
|
4081
4202
|
}
|
|
4082
|
-
let browser = {};
|
|
4203
|
+
let browser = primaryKeys.length === 1 ? { primaryKey: primaryKeys[0] } : {};
|
|
4083
4204
|
if (Object.prototype.hasOwnProperty.call(shape, "client")) {
|
|
4084
4205
|
if (!scope || typeof scope !== "object" || primaryKeys.length !== 1) return null;
|
|
4085
4206
|
const sc = scope;
|
|
@@ -4094,7 +4215,7 @@ function bakedTableSchemaFromDeclared(declaredJson) {
|
|
|
4094
4215
|
});
|
|
4095
4216
|
if (!parsed.ok) return null;
|
|
4096
4217
|
if (Array.isArray(parsed.permissions.read) && !parsed.permissions.read.includes(primaryKeys[0])) return null;
|
|
4097
|
-
browser = { client: parsed.permissions, clientPrimaryKey: primaryKeys[0] };
|
|
4218
|
+
browser = { ...browser, client: parsed.permissions, clientPrimaryKey: primaryKeys[0] };
|
|
4098
4219
|
}
|
|
4099
4220
|
if (scope !== null && typeof scope === "object" && scope.kind === "member") {
|
|
4100
4221
|
const member = bakedMemberFromDeclared(scope);
|
|
@@ -6551,6 +6672,7 @@ function declaredRolesFromSource(files) {
|
|
|
6551
6672
|
}
|
|
6552
6673
|
|
|
6553
6674
|
// declared-data-vendor-entry.js
|
|
6675
|
+
var import_declared_data_contract2 = __toESM(require_declared_data_contract());
|
|
6554
6676
|
var import_typed_data = __toESM(require_typed_data());
|
|
6555
6677
|
var import_runtime_types = __toESM(require_runtime_types());
|
|
6556
6678
|
var import_groups_types = __toESM(require_groups_types());
|
|
@@ -6562,6 +6684,10 @@ function generateFromFiles(files) {
|
|
|
6562
6684
|
const authority = clientAuthorityFromSource(files);
|
|
6563
6685
|
return authority ? (0, import_typed_data.generateDataClient)(authority) : void 0;
|
|
6564
6686
|
}
|
|
6687
|
+
function localDeclarationFromFiles(files) {
|
|
6688
|
+
const authority = clientAuthorityFromSource(files);
|
|
6689
|
+
return authority ? (0, import_declared_data_contract2.describeDataClientLocalDeclaration)(authority) : void 0;
|
|
6690
|
+
}
|
|
6565
6691
|
function runtimeDeclarationFromFiles(files) {
|
|
6566
6692
|
return (0, import_runtime_types.runtimeContextDeclaration)((0, import_groups_types.declaredRoles)(declaredRolesFromSource(files)));
|
|
6567
6693
|
}
|
|
@@ -6581,5 +6707,6 @@ function filesDeclarationFromFiles(files) {
|
|
|
6581
6707
|
declaredTablesFromFiles,
|
|
6582
6708
|
filesDeclarationFromFiles,
|
|
6583
6709
|
generateFromFiles,
|
|
6710
|
+
localDeclarationFromFiles,
|
|
6584
6711
|
runtimeDeclarationFromFiles
|
|
6585
6712
|
});
|