@somewhere-cloud/cli 0.38.57 → 0.38.60
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 +77 -80
- package/README.md +52 -27
- package/dist/commands/ai.js +1 -1
- package/dist/commands/ai.js.map +1 -1
- package/dist/commands/api.d.ts +1 -1
- package/dist/commands/api.js +2 -2
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/auth.d.ts +3 -3
- package/dist/commands/auth.js +4 -4
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/browser.d.ts +1 -1
- package/dist/commands/browser.js +9 -9
- package/dist/commands/browser.js.map +1 -1
- package/dist/commands/call.d.ts +2 -2
- package/dist/commands/call.js +2 -2
- package/dist/commands/call.js.map +1 -1
- package/dist/commands/check.js +2 -2
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/claim.d.ts +1 -1
- package/dist/commands/claim.js +1 -1
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/cron.d.ts +1 -1
- package/dist/commands/cron.js +2 -2
- package/dist/commands/cron.js.map +1 -1
- package/dist/commands/db.js +1 -1
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts +9 -9
- package/dist/commands/deploy.js +38 -38
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +2 -2
- package/dist/commands/dev.js +2 -2
- package/dist/commands/docs.d.ts +2 -2
- package/dist/commands/docs.js +8 -8
- package/dist/commands/docs.js.map +1 -1
- package/dist/commands/env.js +1 -1
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/logs.js +2 -2
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/promote.js +2 -2
- package/dist/commands/promote.js.map +1 -1
- package/dist/commands/rollback.d.ts +1 -1
- package/dist/commands/rollback.js +1 -1
- package/dist/commands/rollback.js.map +1 -1
- package/dist/commands/status.js +2 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/test.js +10 -8
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/typecheck.js +1 -1
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/update.js +1 -1
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/verify.js +5 -5
- package/dist/commands/verify.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/auth.js +1 -1
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/base-files.d.ts +1 -1
- package/dist/lib/browser-actions.js +1 -1
- package/dist/lib/browser-actions.js.map +1 -1
- package/dist/lib/browser-run.d.ts +1 -1
- package/dist/lib/browser-run.js +3 -3
- package/dist/lib/browser-run.js.map +1 -1
- package/dist/lib/build-errors.js +1 -1
- package/dist/lib/claim-handoff.js +1 -1
- package/dist/lib/claim-handoff.js.map +1 -1
- package/dist/lib/client.d.ts +5 -5
- package/dist/lib/client.js +10 -10
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/config.d.ts +5 -5
- package/dist/lib/config.js +5 -5
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/declared-data.js +1 -1
- package/dist/lib/declared-data.js.map +1 -1
- package/dist/lib/deploy-check.d.ts +1 -1
- package/dist/lib/deploy-check.js +2 -2
- package/dist/lib/deploy-check.js.map +1 -1
- package/dist/lib/files.d.ts +4 -4
- package/dist/lib/files.js +5 -5
- package/dist/lib/files.js.map +1 -1
- package/dist/lib/http.d.ts +1 -1
- package/dist/lib/http.js +1 -1
- package/dist/lib/init-agent-guide.d.ts +2 -2
- package/dist/lib/init-agent-guide.js +2 -2
- package/dist/lib/init-feature-template.js +1 -1
- package/dist/lib/init-feature-template.js.map +1 -1
- package/dist/lib/last-run.d.ts +2 -2
- package/dist/lib/last-run.js +1 -1
- package/dist/lib/link-hint.d.ts +1 -1
- package/dist/lib/link-hint.js +1 -1
- package/dist/lib/notify/providers/update.d.ts +1 -1
- package/dist/lib/notify/providers/update.js +1 -1
- package/dist/lib/notify/providers/update.js.map +1 -1
- package/dist/lib/output.d.ts +2 -2
- package/dist/lib/output.js +2 -2
- package/dist/lib/platform-contract.js +1 -1
- package/dist/lib/platform-tools.d.ts +1 -1
- package/dist/lib/platform-tools.js +2 -2
- package/dist/lib/platform-tools.js.map +1 -1
- package/dist/lib/playwright-fixtures.js +10 -11
- package/dist/lib/playwright-fixtures.js.map +1 -1
- package/dist/lib/post-live-render.d.ts +1 -1
- package/dist/lib/post-live-render.js +1 -1
- package/dist/lib/project-pin.d.ts +1 -1
- package/dist/lib/project-pin.js +1 -1
- package/dist/lib/promote-outcome.d.ts +2 -2
- package/dist/lib/promote-outcome.js +2 -2
- package/dist/lib/publish-surface.js +1 -1
- package/dist/lib/repro-packet.d.ts +1 -1
- package/dist/lib/repro-packet.js +2 -2
- package/dist/lib/scaffold.d.ts +1 -1
- package/dist/lib/scaffold.js +1 -1
- package/dist/lib/source-lint.d.ts +1 -1
- package/dist/lib/surface-counts.d.ts +1 -1
- package/dist/lib/temp-auth.d.ts +2 -2
- package/dist/lib/temp-auth.js +2 -2
- package/dist/lib/terminal-text.d.ts +1 -1
- package/dist/lib/terminal-text.js +2 -2
- package/dist/lib/test-connectivity.js +0 -2
- package/dist/lib/test-connectivity.js.map +1 -1
- package/dist/lib/test-diagnostics.js +2 -0
- package/dist/lib/test-diagnostics.js.map +1 -1
- package/dist/lib/test-reporter.js +1 -1
- package/dist/lib/test-reporter.js.map +1 -1
- package/dist/lib/test-target.d.ts +10 -0
- package/dist/lib/test-target.js +18 -0
- package/dist/lib/test-target.js.map +1 -0
- package/dist/lib/typecheck.d.ts +3 -3
- package/dist/lib/typecheck.js +2 -2
- package/dist/lib/vendor/deploy-paths.d.ts +0 -11
- package/dist/lib/vendor/deploy-paths.js +0 -27
- package/dist/lib/vendor/deploy-paths.js.map +1 -1
- package/dist/lib/vendor/repro-guidance.d.ts +0 -31
- package/dist/lib/vendor/repro-guidance.js +0 -37
- package/dist/lib/vendor/repro-guidance.js.map +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/lib/version.js.map +1 -1
- package/dist/types.d.ts +4 -4
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/runtime/DECLARED-DATA-VENDOR.json +8 -7
- package/runtime/PLATFORM-SOURCE.json +1 -2
- package/runtime/SOURCE-LINT-VENDOR.json +9 -8
- package/runtime/VENDOR.json +1 -2
- package/runtime/browser-probes.mjs +1 -1
- package/runtime/declared-data.cjs +163 -143
- package/runtime/source-lint.cjs +542 -500
|
@@ -24,52 +24,67 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
26
26
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
31
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
|
|
37
|
+
function createConsoleDiagnostics() {
|
|
38
|
+
function sanitizeMessage(input) {
|
|
39
|
+
return input.slice(0, 8192).replace(/https?:\/\/[^\s<>"')]+/gi, (url) => url.replace(/(https?:\/\/)[^/@\s]+@/gi, "$1<redacted>@").split(/[?#]/, 1)[0]).replace(/(["']?(?:password|code|token|key|secret|signature|access_token|refresh_token|authorization|cookie)["']?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s,}]+)/gi, "$1<redacted>").replace(/\b(?:Cookie|Set-Cookie)\s*[:=]\s*[^\r\n]+/gi, "Cookie: <redacted>").replace(/\bBearer\s+[^\s,;'"<>]+/gi, "Bearer <redacted>").replace(/\b(?:token|code|key|secret|password|signature|access_token|refresh_token|session|sid|sessionid)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s&;,]+)/gi, (match) => match.slice(0, match.indexOf("=") + 1) + "<redacted>").replace(/[A-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "<email>").replace(/\b[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g, "<redacted>").replace(/\b(?:smt_|(?:sk|pk)[_-])[A-Za-z0-9_-]+/g, "<redacted>").replace(/[A-Za-z0-9+/_-]{32,}={0,2}/g, "<redacted>").slice(0, 300);
|
|
40
|
+
}
|
|
41
|
+
function safeError(value) {
|
|
42
|
+
try {
|
|
43
|
+
const record2 = Object.create(null);
|
|
44
|
+
if (value && typeof value === "object") {
|
|
45
|
+
let current = value;
|
|
46
|
+
for (let depth = 0; current && depth < 6; depth++, current = Object.getPrototypeOf(current)) {
|
|
47
|
+
for (const key of ["name", "message", "status", "code", "stack"]) {
|
|
48
|
+
if (Object.hasOwn(record2, key)) continue;
|
|
49
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
50
|
+
if (descriptor) record2[key] = "value" in descriptor ? descriptor.value : "[Getter]";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const name = typeof record2.name === "string" ? sanitizeMessage(record2.name).slice(0, 80) : "Error";
|
|
55
|
+
const message = typeof record2.message === "string" ? record2.message : typeof value === "string" ? value : "Unknown error";
|
|
56
|
+
const status = typeof record2.status === "number" && Number.isInteger(record2.status) && record2.status >= 100 && record2.status <= 599 ? record2.status : 0;
|
|
57
|
+
const failure = /Network connection lost/i.test(message) ? "connection_lost" : /DEADLINE|timed? ?out/i.test(message) ? "deadline_exceeded" : /object.*reset|reset.*object/i.test(message) ? "object_reset" : /no such column/i.test(message) ? "missing_column" : /no such table/i.test(message) ? "missing_table" : /SQLITE_CONSTRAINT|constraint failed/i.test(message) ? "constraint" : /overload|too many requests/i.test(message) ? "overloaded" : "unclassified";
|
|
58
|
+
const code = typeof record2.code === "string" && /^[A-Z][A-Z0-9_]{0,63}$/.test(record2.code) ? sanitizeMessage(record2.code) : void 0;
|
|
59
|
+
const frames = typeof record2.stack === "string" ? record2.stack.split("\n").slice(1).flatMap((line) => {
|
|
60
|
+
const match = line.match(/([^\s()]+?):(\d+)(?::\d+)?\)?$/);
|
|
61
|
+
if (!match) return [];
|
|
62
|
+
const file = match[1].split(/[\\/]/).pop() ?? "";
|
|
63
|
+
return [sanitizeMessage(file) + ":" + match[2]];
|
|
64
|
+
}).slice(0, 2) : [];
|
|
65
|
+
return name + " message=" + JSON.stringify(sanitizeMessage(message)) + " status=" + status + (code ? " code=" + code : "") + " class=" + failure + (frames.length ? " frames=" + frames.join(",") : "");
|
|
66
|
+
} catch {
|
|
67
|
+
return "Error class=uninspectable";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { sanitizeMessage, safeError };
|
|
71
|
+
}
|
|
72
|
+
var diagnostics, sanitizeConsoleMessage, safeConsoleError;
|
|
73
|
+
var init_console_privacy = __esm({
|
|
74
|
+
"worker/src/utils/console-privacy.ts"() {
|
|
40
75
|
"use strict";
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// OAuth callbacks carry one-use credentials even when validation refuses them.
|
|
45
|
-
"code",
|
|
46
|
-
"state",
|
|
47
|
-
// A creator or link secret belongs only in a request body; a stray query copy is never kept.
|
|
48
|
-
"creator_secret",
|
|
49
|
-
"secret",
|
|
50
|
-
"signature",
|
|
51
|
-
"api_key",
|
|
52
|
-
"apikey",
|
|
53
|
-
"token",
|
|
54
|
-
"key",
|
|
55
|
-
"sig",
|
|
56
|
-
// A DSN carries its own password, and percent-encoding hides it from the
|
|
57
|
-
// Postgres URI rule below. `password` covers the other connection-string
|
|
58
|
-
// form, `postgres://reader@host/db?password=…`, which has no userinfo
|
|
59
|
-
// password for that rule to match.
|
|
60
|
-
"dsn",
|
|
61
|
-
"password"
|
|
62
|
-
];
|
|
63
|
-
SENSITIVE_PARAM_NAMES = new Set(SENSITIVE_PARAMS);
|
|
76
|
+
diagnostics = createConsoleDiagnostics();
|
|
77
|
+
sanitizeConsoleMessage = diagnostics.sanitizeMessage;
|
|
78
|
+
safeConsoleError = diagnostics.safeError;
|
|
64
79
|
}
|
|
65
80
|
});
|
|
66
81
|
|
|
67
|
-
|
|
82
|
+
|
|
68
83
|
var require_declared_data_contract = __commonJS({
|
|
69
84
|
"worker/containers/compile/declared-data-contract.cjs"(exports2, module2) {
|
|
70
85
|
"use strict";
|
|
71
86
|
var identifier = /^[a-z_][a-z0-9_]*$/;
|
|
72
|
-
var types =
|
|
87
|
+
var types = new Set(["integer", "bigint", "number", "text", "boolean", "timestamp", "json", "blob"]);
|
|
73
88
|
function canonicalBigintText(value) {
|
|
74
89
|
if (typeof value !== "string" || !/^(0|-?[1-9][0-9]*)$/.test(value)) return false;
|
|
75
90
|
const digits = value.startsWith("-") ? value.slice(1) : value;
|
|
@@ -144,8 +159,8 @@ var require_declared_data_contract = __commonJS({
|
|
|
144
159
|
}
|
|
145
160
|
function hiddenByBranch(table) {
|
|
146
161
|
const reads = table.policy && table.policy.k === "a" ? table.policy.reads : void 0;
|
|
147
|
-
if (!reads) return
|
|
148
|
-
const hidden =
|
|
162
|
+
if (!reads) return new Set();
|
|
163
|
+
const hidden = new Set();
|
|
149
164
|
for (const list of reads) if (list) {
|
|
150
165
|
for (const column of table.columns) if (!list.includes(column.n)) hidden.add(column.n);
|
|
151
166
|
}
|
|
@@ -182,7 +197,7 @@ var require_declared_data_contract = __commonJS({
|
|
|
182
197
|
record2(scopes, "scopes");
|
|
183
198
|
const tables = [];
|
|
184
199
|
const membershipTables = new Set(Object.values(schema).filter((table) => table && table.member).map((table) => table.member.m));
|
|
185
|
-
const grantTables =
|
|
200
|
+
const grantTables = new Set();
|
|
186
201
|
for (const table of Object.values(schema)) if (table?.policy) policyMembershipTables(table.policy, membershipTables, grantTables);
|
|
187
202
|
for (const name of grantTables) {
|
|
188
203
|
const grant = schema[name];
|
|
@@ -203,7 +218,7 @@ var require_declared_data_contract = __commonJS({
|
|
|
203
218
|
if (!identifier.test(name) || name.startsWith("_") || name.startsWith("sqlite_")) fail(`table ${name}`);
|
|
204
219
|
record2(table.client, `${name}.client`);
|
|
205
220
|
if (!Array.isArray(table.columns) || !table.columns.length) fail(`${name}.columns`);
|
|
206
|
-
const seen =
|
|
221
|
+
const seen = new Set();
|
|
207
222
|
const columns = table.columns.map((column) => {
|
|
208
223
|
record2(column, `${name}.column`);
|
|
209
224
|
if (typeof column.n !== "string" || !identifier.test(column.n) || seen.has(column.n) || !types.has(column.t)) fail(`${name}.column`);
|
|
@@ -350,7 +365,7 @@ var require_declared_data_contract = __commonJS({
|
|
|
350
365
|
if (declared === void 0) continue;
|
|
351
366
|
if (!Array.isArray(declared)) fail(`${table.name}.relations`);
|
|
352
367
|
const relations = [];
|
|
353
|
-
const names =
|
|
368
|
+
const names = new Set();
|
|
354
369
|
for (const relation of declared) {
|
|
355
370
|
record2(relation, `${table.name}.relation`);
|
|
356
371
|
if (Object.keys(relation).some((key) => !["name", "kind", "table", "fk", "parentKey"].includes(key))) fail(`${table.name}.relation`);
|
|
@@ -388,7 +403,7 @@ var require_declared_data_contract = __commonJS({
|
|
|
388
403
|
const type = { integer: "number", bigint: "string", number: "number", text: "string", timestamp: "string", boolean: "boolean", json: "Json", blob: "number[]" }[column.t];
|
|
389
404
|
return column.nul ? `${type} | null` : type;
|
|
390
405
|
}
|
|
391
|
-
function shape(columns, names, mode, required =
|
|
406
|
+
function shape(columns, names, mode, required = new Set(), hidden = new Set()) {
|
|
392
407
|
const values = names.map((name) => {
|
|
393
408
|
const column = columns.find((candidate) => candidate.n === name);
|
|
394
409
|
const optional = mode === "update" || mode === "create" && !required.has(name) && (column.d || column.nul) || mode === "read" && hidden.has(name);
|
|
@@ -582,8 +597,8 @@ async function intake(table, reference, values, extra) {
|
|
|
582
597
|
for (const table of tables) {
|
|
583
598
|
const { name, columns, client, primaryKey } = table;
|
|
584
599
|
const readable = client.read === true ? columns.filter((column) => column.n !== table.author).map((column) => column.n) : client.read || [];
|
|
585
|
-
const hidden = generation >= 5 ? hiddenByBranch(table) :
|
|
586
|
-
const row = shape(columns, readable, "read",
|
|
600
|
+
const hidden = generation >= 5 ? hiddenByBranch(table) : new Set();
|
|
601
|
+
const row = shape(columns, readable, "read", new Set(), hidden);
|
|
587
602
|
const id = columnType(columns.find((column) => column.n === primaryKey));
|
|
588
603
|
const operations = [];
|
|
589
604
|
const methods = [];
|
|
@@ -618,7 +633,7 @@ async function intake(table, reference, values, extra) {
|
|
|
618
633
|
}
|
|
619
634
|
const mutation = client.read === false ? "{ count: number; changes: number }" : `{ data: ${row} | null; count: number; changes: number }`;
|
|
620
635
|
if (client.create !== null) {
|
|
621
|
-
const required = table.policy?.k === "p" ?
|
|
636
|
+
const required = table.policy?.k === "p" ? new Set([table.policy.v]) : new Set();
|
|
622
637
|
const eligible = columns.some((column) => column.n === primaryKey && column.t === "integer") && !columns.some((column) => column.t === "blob");
|
|
623
638
|
if (receiptCapable && eligible) receiptTables.push(name);
|
|
624
639
|
operations.push(`create(values: ${shape(columns, client.create, "create", required)}): Promise<${receiptCapable && eligible ? `InsertResult<${mutation}>` : mutation}>`);
|
|
@@ -648,7 +663,7 @@ async function intake(table, reference, values, extra) {
|
|
|
648
663
|
childRelations.push(`${JSON.stringify(relationName)}: { list<const L extends number = number>(parentId: ${id}, options?: { limit?: L & (number extends L ? unknown : [L] extends [PageSize] ? unknown : never); after?: ${childId} }): Promise<{ data: ${childRow}[]; next: ${childId} | null; has_more: boolean }> }`);
|
|
649
664
|
const childUpdate = child.client.update ? child.client.update.filter((field) => field !== relation.fk) : [];
|
|
650
665
|
const childOps = [];
|
|
651
|
-
if (child.client.create !== null) childOps.push(`create(values: ${shape(child.columns, child.client.create, "create",
|
|
666
|
+
if (child.client.create !== null) childOps.push(`create(values: ${shape(child.columns, child.client.create, "create", new Set([relation.fk]))}): Promise<{ data: ${childRow} | null; count: number; changes: number }>`);
|
|
652
667
|
if (childUpdate.length) childOps.push(`update(id: ${childId}, values: ${shape(child.columns, childUpdate, "update")}): Promise<{ data: ${childRow} | null; count: number; changes: number }>`);
|
|
653
668
|
if (childOps.length) creatorDeclarations.push(`${JSON.stringify(child.name)}: { ${childOps.join("; ")} }`);
|
|
654
669
|
childSpecs.push([relationName, child.name, child.client.create !== null, childUpdate.length > 0]);
|
|
@@ -708,7 +723,7 @@ async function intake(table, reference, values, extra) {
|
|
|
708
723
|
const canCreate = links.edit.length > 0 && child.client.create !== null;
|
|
709
724
|
const childUpdate = child.client.update ? child.client.update.filter((field) => field !== relation.fk) : [];
|
|
710
725
|
const canUpdate = links.edit.length > 0 && childUpdate.length > 0;
|
|
711
|
-
if (canCreate) childOps.push(`create(values: ${shape(child.columns, child.client.create, "create",
|
|
726
|
+
if (canCreate) childOps.push(`create(values: ${shape(child.columns, child.client.create, "create", new Set([relation.fk]))}): Promise<{ data: ${childRow} | null; count: number; changes: number }>`);
|
|
712
727
|
if (canUpdate) childOps.push(`update(id: ${childId}, values: ${shape(child.columns, childUpdate, "update")}): Promise<{ data: ${childRow} | null; count: number; changes: number }>`);
|
|
713
728
|
if (childOps.length) linkedDeclarations.push(`${JSON.stringify(child.name)}: { ${childOps.join("; ")} }`);
|
|
714
729
|
childSpecs.push([relationName, child.name, canCreate, canUpdate]);
|
|
@@ -751,7 +766,7 @@ export{data,DataError};
|
|
|
751
766
|
}
|
|
752
767
|
});
|
|
753
768
|
|
|
754
|
-
|
|
769
|
+
|
|
755
770
|
var require_typed_data = __commonJS({
|
|
756
771
|
"worker/containers/compile/typed-data.cjs"(exports2, module2) {
|
|
757
772
|
"use strict";
|
|
@@ -780,7 +795,7 @@ var require_typed_data = __commonJS({
|
|
|
780
795
|
}
|
|
781
796
|
});
|
|
782
797
|
|
|
783
|
-
|
|
798
|
+
|
|
784
799
|
var require_groups_types = __commonJS({
|
|
785
800
|
"worker/containers/compile/groups-types.cjs"(exports2, module2) {
|
|
786
801
|
"use strict";
|
|
@@ -791,7 +806,7 @@ var require_groups_types = __commonJS({
|
|
|
791
806
|
}
|
|
792
807
|
function roleList(value, field) {
|
|
793
808
|
if (!Array.isArray(value)) fail(`${field} must be an array`);
|
|
794
|
-
const seen =
|
|
809
|
+
const seen = new Set();
|
|
795
810
|
for (const name of value) {
|
|
796
811
|
if (typeof name !== "string" || !ROLE_NAME2.test(name)) fail(`${field} has an invalid role name`);
|
|
797
812
|
if (seen.has(name)) fail(`${field} repeats ${name}`);
|
|
@@ -977,7 +992,7 @@ interface SomewhereRuntimeContext {
|
|
|
977
992
|
}
|
|
978
993
|
});
|
|
979
994
|
|
|
980
|
-
|
|
995
|
+
|
|
981
996
|
var require_runtime_types = __commonJS({
|
|
982
997
|
"worker/containers/compile/runtime-types.cjs"(exports2, module2) {
|
|
983
998
|
"use strict";
|
|
@@ -3989,7 +4004,7 @@ interface SomewhereEndpointConfig<Auth extends SomewhereEndpointAuth, Schema ext
|
|
|
3989
4004
|
const scopes = authority && authority.scopes || {};
|
|
3990
4005
|
const names = Object.keys(schema).sort();
|
|
3991
4006
|
if (!names.length) return "";
|
|
3992
|
-
const rowShares =
|
|
4007
|
+
const rowShares = new Set();
|
|
3993
4008
|
for (const name of names) {
|
|
3994
4009
|
const policy = schema[name].policy, branch = policy && policy.k === "a" ? policy.p[1] : null;
|
|
3995
4010
|
if (branch && branch.k === "m" && branch.m.og && branch.m.g.length === 2) rowShares.add(String(branch.m.m).toLowerCase());
|
|
@@ -4019,7 +4034,7 @@ interface SomewhereEndpointConfig<Auth extends SomewhereEndpointAuth, Schema ext
|
|
|
4019
4034
|
}
|
|
4020
4035
|
});
|
|
4021
4036
|
|
|
4022
|
-
|
|
4037
|
+
|
|
4023
4038
|
var require_typed_files = __commonJS({
|
|
4024
4039
|
"worker/containers/compile/typed-files.cjs"(exports2, module2) {
|
|
4025
4040
|
"use strict";
|
|
@@ -4189,7 +4204,7 @@ export{files};
|
|
|
4189
4204
|
}
|
|
4190
4205
|
});
|
|
4191
4206
|
|
|
4192
|
-
|
|
4207
|
+
|
|
4193
4208
|
var require_schema_types = __commonJS({
|
|
4194
4209
|
"worker/containers/compile/schema-types.cjs"(exports2, module2) {
|
|
4195
4210
|
"use strict";
|
|
@@ -4278,7 +4293,7 @@ ${(signatures + policySignatures).replace(/^function /gm, " export function ")}
|
|
|
4278
4293
|
}
|
|
4279
4294
|
});
|
|
4280
4295
|
|
|
4281
|
-
|
|
4296
|
+
|
|
4282
4297
|
var require_checker_contract = __commonJS({
|
|
4283
4298
|
"worker/containers/compile/checker-contract.cjs"(exports2, module2) {
|
|
4284
4299
|
"use strict";
|
|
@@ -4364,7 +4379,7 @@ var require_checker_contract = __commonJS({
|
|
|
4364
4379
|
}
|
|
4365
4380
|
});
|
|
4366
4381
|
|
|
4367
|
-
|
|
4382
|
+
|
|
4368
4383
|
var require_generated_declarations = __commonJS({
|
|
4369
4384
|
"worker/containers/compile/generated-declarations.cjs"(exports2, module2) {
|
|
4370
4385
|
"use strict";
|
|
@@ -4408,7 +4423,7 @@ var require_generated_declarations = __commonJS({
|
|
|
4408
4423
|
}
|
|
4409
4424
|
});
|
|
4410
4425
|
|
|
4411
|
-
|
|
4426
|
+
|
|
4412
4427
|
var require_generated_declarations_render = __commonJS({
|
|
4413
4428
|
"worker/containers/compile/generated-declarations-render.cjs"(exports2, module2) {
|
|
4414
4429
|
"use strict";
|
|
@@ -4440,13 +4455,13 @@ var require_generated_declarations_render = __commonJS({
|
|
|
4440
4455
|
}
|
|
4441
4456
|
});
|
|
4442
4457
|
|
|
4443
|
-
|
|
4458
|
+
|
|
4444
4459
|
var require_consumer_contract = __commonJS({
|
|
4445
4460
|
"worker/containers/compile/consumer-contract.cjs"(exports2, module2) {
|
|
4446
4461
|
"use strict";
|
|
4447
4462
|
var CONSUMER_CONTRACT2 = Object.freeze({
|
|
4448
|
-
version:
|
|
4449
|
-
digest: "
|
|
4463
|
+
version: 8,
|
|
4464
|
+
digest: "bd4347b462f02a15962801ba7ac69c5482e589d4081593d9570e196410694cf7"
|
|
4450
4465
|
});
|
|
4451
4466
|
var MEMBERSHIPS = "memberships: table({ id: id(), team_id: text(), member_id: text() }, { scope: owner(), client: { read: true } }),";
|
|
4452
4467
|
var SHARES = "shares: table({ id: id(), grantee_id: text() }, { scope: owner(), client: { read: true, create: ['grantee_id'], delete: true }, unique: [['user_id', 'grantee_id']] }),";
|
|
@@ -4473,7 +4488,7 @@ export default schema({
|
|
|
4473
4488
|
["allOf(member(), owner())", one("owner, member, allOf", `${MEMBERSHIPS}
|
|
4474
4489
|
${contacts(`allOf(${MEMBER}, owner())`)}`)],
|
|
4475
4490
|
["parent()", one("owner, parent, hasMany", "tickets: table({ id: id(), subject: text() }, { scope: owner(), client: { read: true }, relations: { comments: hasMany('comments', 'ticket_id') } }),\n comments: table({ id: id(), ticket_id: text({ references: 'tickets' }), body: text() }, { scope: parent({ via: 'ticket_id' }), client: { read: true } }),")],
|
|
4476
|
-
|
|
4491
|
+
|
|
4477
4492
|
["refused: grant() inside allOf", one("owner, member, anyOf, allOf, grant", `${SHARES}
|
|
4478
4493
|
${MEMBERSHIPS}
|
|
4479
4494
|
${contacts(`allOf(${MEMBER}, anyOf(owner(), grant({ table: 'shares', grantee: 'grantee_id', operations: ['read'] })))`)}`)],
|
|
@@ -4548,7 +4563,7 @@ export default schema({
|
|
|
4548
4563
|
}
|
|
4549
4564
|
});
|
|
4550
4565
|
|
|
4551
|
-
|
|
4566
|
+
|
|
4552
4567
|
var declared_data_vendor_entry_exports = {};
|
|
4553
4568
|
__export(declared_data_vendor_entry_exports, {
|
|
4554
4569
|
CONSUMER_CONTRACT: () => import_consumer_contract.CONSUMER_CONTRACT,
|
|
@@ -4571,7 +4586,7 @@ __export(declared_data_vendor_entry_exports, {
|
|
|
4571
4586
|
});
|
|
4572
4587
|
module.exports = __toCommonJS(declared_data_vendor_entry_exports);
|
|
4573
4588
|
|
|
4574
|
-
|
|
4589
|
+
|
|
4575
4590
|
function isCanonicalBigintText(value) {
|
|
4576
4591
|
if (!/^(0|-?[1-9][0-9]*)$/.test(value)) return false;
|
|
4577
4592
|
const negative = value.startsWith("-");
|
|
@@ -4580,10 +4595,10 @@ function isCanonicalBigintText(value) {
|
|
|
4580
4595
|
return digits.length < limit.length || digits.length === limit.length && digits <= limit;
|
|
4581
4596
|
}
|
|
4582
4597
|
|
|
4583
|
-
|
|
4598
|
+
|
|
4584
4599
|
var SHARED_AUTHOR_COLUMN = "_sw_author_id";
|
|
4585
4600
|
|
|
4586
|
-
|
|
4601
|
+
|
|
4587
4602
|
function tableAllowsClientWrites(table) {
|
|
4588
4603
|
return Boolean(table.client && (table.client.create !== null || table.client.update !== null || table.client.delete || table.client.intake !== void 0));
|
|
4589
4604
|
}
|
|
@@ -4850,12 +4865,12 @@ function parseLinkPermissions(value, read, update, create, columns, scope) {
|
|
|
4850
4865
|
return { read: linkRead, edit, children, maxDays, ...input.anonymousCreate === true ? { anonymousCreate: true } : {} };
|
|
4851
4866
|
}
|
|
4852
4867
|
|
|
4853
|
-
|
|
4868
|
+
|
|
4854
4869
|
function record(value) {
|
|
4855
4870
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
4856
4871
|
}
|
|
4857
4872
|
function bakeIntakePermissions(schema, declarations, intents, scopes) {
|
|
4858
|
-
const membershipTables =
|
|
4873
|
+
const membershipTables = new Set();
|
|
4859
4874
|
const members = (policy) => {
|
|
4860
4875
|
if (policy.k === "m") membershipTables.add(policy.m.m);
|
|
4861
4876
|
else if (policy.k === "a") policy.p.forEach(members);
|
|
@@ -4898,16 +4913,16 @@ function bakeIntakePermissions(schema, declarations, intents, scopes) {
|
|
|
4898
4913
|
}
|
|
4899
4914
|
}
|
|
4900
4915
|
|
|
4901
|
-
|
|
4916
|
+
|
|
4902
4917
|
var STALE_JOB_WINDOW_MS = 45 * 60 * 1e3;
|
|
4903
4918
|
|
|
4904
|
-
|
|
4919
|
+
|
|
4905
4920
|
var BINDING_OPERATIONS = ["read", "create", "update", "delete"];
|
|
4906
4921
|
var ROW_OPERATIONS = ["read", "update", "delete"];
|
|
4907
4922
|
var MAX_JOB_BINDING_SECONDS = STALE_JOB_WINDOW_MS / 1e3;
|
|
4908
4923
|
var NAME = /^[a-z][a-z0-9_]{0,63}$/;
|
|
4909
4924
|
var BUILT_IN_GROUP_ROLES = ["admin", "member", "owner"];
|
|
4910
|
-
var lines =
|
|
4925
|
+
var lines = new WeakMap();
|
|
4911
4926
|
var byName = (list) => list.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
4912
4927
|
function readString(r, fail, ctx) {
|
|
4913
4928
|
const t = r.next();
|
|
@@ -4953,7 +4968,7 @@ function readNamed(r, fail, option, kind, keys, readField) {
|
|
|
4953
4968
|
r.expectPunct("{", `opening ${kind} "${key.name}"`);
|
|
4954
4969
|
const fields = {};
|
|
4955
4970
|
const fieldLines = { "": key.line };
|
|
4956
|
-
const seen =
|
|
4971
|
+
const seen = new Set();
|
|
4957
4972
|
while (!r.tryPunct("}")) {
|
|
4958
4973
|
const opt = r.readKey(`for an option of ${kind} "${key.name}"`);
|
|
4959
4974
|
if (!keys.includes(opt.name)) fail(opt.line, `${kind} "${key.name}" has an unknown option "${opt.name}". Allowed: ${keys.join(", ")}.`);
|
|
@@ -5103,14 +5118,14 @@ function validateBindings(input, tableInfo, errors) {
|
|
|
5103
5118
|
const writable = [...info.table.client?.create ?? [], ...info.table.client?.update ?? [], ...info.table.client?.intake?.fields ?? []];
|
|
5104
5119
|
if (writable.includes(name)) errors.push(`${at(p, field)}payment binding "${p.name}": "${p.table}"."${name}" is browser-writable through client.create, client.update or client.intake, and a payment binding requires it not to be; the server sets prices and the payment sets the status.`);
|
|
5105
5120
|
}
|
|
5106
|
-
if ((
|
|
5121
|
+
if (( new Set([p.amount, p.currency, p.status.column])).size !== 3) errors.push(`${at(p, "")}payment binding "${p.name}" must name three different columns for amount, currency and status.`);
|
|
5107
5122
|
const status = column(p.status.column);
|
|
5108
5123
|
if (status && !(status.hasDefault && typeof status.default === "string" && p.status.from.includes(status.default))) {
|
|
5109
5124
|
errors.push(`${at(p, "onPaid")}payment binding "${p.name}": "${p.table}"."${p.status.column}" must declare a default that is one of its unpaid from states (${p.status.from.join(", ")}), so a new row starts unpaid.`);
|
|
5110
5125
|
}
|
|
5111
5126
|
}
|
|
5112
5127
|
for (const j of input.jobs ?? []) rowTable(j, "job binding");
|
|
5113
|
-
const taken =
|
|
5128
|
+
const taken = new Set([...BUILT_IN_GROUP_ROLES, ...input.groups?.roles ?? [], ...(input.appRoles ?? []).map((role) => role.name)]);
|
|
5114
5129
|
for (const s of input.serviceRoles ?? []) {
|
|
5115
5130
|
if (taken.has(s.name)) errors.push(`${at(s, "")}service role "${s.name}" has the name of a group or app role. Service roles are a separate namespace for unattended work, so the name must differ.`);
|
|
5116
5131
|
const tableLines = lines.get(s.tables) ?? {};
|
|
@@ -5120,7 +5135,7 @@ function validateBindings(input, tableInfo, errors) {
|
|
|
5120
5135
|
}
|
|
5121
5136
|
}
|
|
5122
5137
|
|
|
5123
|
-
|
|
5138
|
+
|
|
5124
5139
|
var ROLE_NAME_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
5125
5140
|
var EMAIL_DOMAIN_PATTERN = /^(?=.{4,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z0-9-]{0,61}[a-z0-9]$/;
|
|
5126
5141
|
function validRoleDomainMap(value) {
|
|
@@ -5137,13 +5152,18 @@ var ROLE_DOMAIN_MAP_JS = `
|
|
|
5137
5152
|
return true;
|
|
5138
5153
|
}`;
|
|
5139
5154
|
|
|
5140
|
-
|
|
5155
|
+
|
|
5156
|
+
init_console_privacy();
|
|
5157
|
+
|
|
5158
|
+
|
|
5159
|
+
init_console_privacy();
|
|
5160
|
+
|
|
5161
|
+
|
|
5162
|
+
init_console_privacy();
|
|
5163
|
+
init_console_privacy();
|
|
5141
5164
|
var COMPILE_UNAVAILABLE_REALERT_MS = 60 * 60 * 1e3;
|
|
5142
5165
|
|
|
5143
|
-
// worker/src/utils/authority.ts
|
|
5144
|
-
init_log_sanitize();
|
|
5145
5166
|
|
|
5146
|
-
// worker/src/utils/authority/scope-enforcement.ts
|
|
5147
5167
|
var SAFE_SCOPE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
5148
5168
|
var GROUP_ROLE_NAME = /^[a-z][a-z0-9_]{0,63}$/;
|
|
5149
5169
|
function validGroupRoles(value) {
|
|
@@ -5395,7 +5415,7 @@ function bakedPolicyFromDeclared(value, depth = 0, edges = 0, underParent = fals
|
|
|
5395
5415
|
function bakedRelationsFromDeclared(value) {
|
|
5396
5416
|
if (!Array.isArray(value) || value.length === 0) return void 0;
|
|
5397
5417
|
const out = [];
|
|
5398
|
-
const seen =
|
|
5418
|
+
const seen = new Set();
|
|
5399
5419
|
for (const entry of value) {
|
|
5400
5420
|
if (entry === null || typeof entry !== "object") continue;
|
|
5401
5421
|
const rel = entry;
|
|
@@ -5446,14 +5466,14 @@ function bakedMemberFromDeclared(scope, explicitOperations = false) {
|
|
|
5446
5466
|
return validBakedMemberScope(member) ? member : null;
|
|
5447
5467
|
}
|
|
5448
5468
|
|
|
5449
|
-
|
|
5469
|
+
|
|
5450
5470
|
function readGrantScope(r, table, line, fail) {
|
|
5451
5471
|
r.expectPunct("(", "after grant");
|
|
5452
5472
|
r.expectPunct("{", "in grant options");
|
|
5453
5473
|
let membership, grantee, row;
|
|
5454
5474
|
let operations;
|
|
5455
5475
|
let read;
|
|
5456
|
-
const seen =
|
|
5476
|
+
const seen = new Set();
|
|
5457
5477
|
while (!r.tryPunct("}")) {
|
|
5458
5478
|
const key = r.readKey("in grant options");
|
|
5459
5479
|
if (seen.has(key.name)) fail(key.line, `Duplicate grant option "${key.name}".`);
|
|
@@ -5583,9 +5603,9 @@ function validateDeclaredMemberships(tables, tableByName, knownColumns, errors)
|
|
|
5583
5603
|
}
|
|
5584
5604
|
}
|
|
5585
5605
|
|
|
5586
|
-
|
|
5587
|
-
var LITERAL_WORDS =
|
|
5588
|
-
var STATEMENT_WORDS =
|
|
5606
|
+
|
|
5607
|
+
var LITERAL_WORDS = new Set(["true", "false", "null"]);
|
|
5608
|
+
var STATEMENT_WORDS = new Set([
|
|
5589
5609
|
"import",
|
|
5590
5610
|
"export",
|
|
5591
5611
|
"default",
|
|
@@ -5607,7 +5627,7 @@ var isIdent = (t, value) => !!t && t.kind === "ident" && t.value === value;
|
|
|
5607
5627
|
function resolveSchemaConstants(tokens, callable, maxTokens, fail) {
|
|
5608
5628
|
const out = [];
|
|
5609
5629
|
let i = 0;
|
|
5610
|
-
const imported =
|
|
5630
|
+
const imported = new Set();
|
|
5611
5631
|
while (isIdent(tokens[i], "import")) {
|
|
5612
5632
|
const start = i;
|
|
5613
5633
|
while (tokens[i].kind !== "eof" && !isIdent(tokens[i], "from")) {
|
|
@@ -5618,8 +5638,8 @@ function resolveSchemaConstants(tokens, callable, maxTokens, fail) {
|
|
|
5618
5638
|
if (isPunct(tokens[i], ";")) i++;
|
|
5619
5639
|
append(out, tokens.slice(start, i));
|
|
5620
5640
|
}
|
|
5621
|
-
const constants =
|
|
5622
|
-
const declaredLater =
|
|
5641
|
+
const constants = new Map();
|
|
5642
|
+
const declaredLater = new Map();
|
|
5623
5643
|
for (let k = i; k < tokens.length; k++) {
|
|
5624
5644
|
const t = tokens[k];
|
|
5625
5645
|
if ((isIdent(t, "const") || isIdent(t, "let") || isIdent(t, "var")) && tokens[k + 1]?.kind === "ident") {
|
|
@@ -5806,15 +5826,15 @@ function matchingClose(tokens, open) {
|
|
|
5806
5826
|
return -1;
|
|
5807
5827
|
}
|
|
5808
5828
|
|
|
5809
|
-
|
|
5829
|
+
|
|
5810
5830
|
var MAX_PARENT_EDGES2 = 4;
|
|
5811
|
-
var parentScopeLines =
|
|
5831
|
+
var parentScopeLines = new WeakMap();
|
|
5812
5832
|
function rememberParentLine(sentinel, line) {
|
|
5813
5833
|
parentScopeLines.set(sentinel, line);
|
|
5814
5834
|
}
|
|
5815
5835
|
function resolveParentChains(tables, tableByName, privatePolicy, errors) {
|
|
5816
|
-
const parentEdges =
|
|
5817
|
-
const resolvingParents =
|
|
5836
|
+
const parentEdges = new Map();
|
|
5837
|
+
const resolvingParents = new Set();
|
|
5818
5838
|
const resolveParent = (t) => {
|
|
5819
5839
|
if (t.scope.kind !== "policy" || t.scope.policy.kind !== "parent") return 0;
|
|
5820
5840
|
if (parentEdges.has(t.name)) return parentEdges.get(t.name);
|
|
@@ -5890,7 +5910,7 @@ function fileParentTarget(t) {
|
|
|
5890
5910
|
};
|
|
5891
5911
|
}
|
|
5892
5912
|
|
|
5893
|
-
|
|
5913
|
+
|
|
5894
5914
|
function validateDeclaredRelations(tables, tableByName, knownColumns, markedGone, errors) {
|
|
5895
5915
|
const columnByName = (t, col) => t.columns.find((c) => c.name === col);
|
|
5896
5916
|
for (const t of tables) {
|
|
@@ -5947,9 +5967,9 @@ function validateDeclaredRelations(tables, tableByName, knownColumns, markedGone
|
|
|
5947
5967
|
}
|
|
5948
5968
|
}
|
|
5949
5969
|
|
|
5950
|
-
|
|
5970
|
+
|
|
5951
5971
|
function validateRowLinks(tables, tableByName, errors) {
|
|
5952
|
-
const childOf =
|
|
5972
|
+
const childOf = new Map();
|
|
5953
5973
|
for (const t of tables) {
|
|
5954
5974
|
const links = t.client?.links;
|
|
5955
5975
|
if (!links) continue;
|
|
@@ -5984,7 +6004,7 @@ function validateRowLinks(tables, tableByName, errors) {
|
|
|
5984
6004
|
}
|
|
5985
6005
|
}
|
|
5986
6006
|
|
|
5987
|
-
|
|
6007
|
+
|
|
5988
6008
|
var REFERENCE_HELPERS = ["id", "text", "integer", "bigint"];
|
|
5989
6009
|
function validateIntake(tables, tableByName, errors) {
|
|
5990
6010
|
for (const t of tables) {
|
|
@@ -6034,7 +6054,7 @@ function validateIntake(tables, tableByName, errors) {
|
|
|
6034
6054
|
}
|
|
6035
6055
|
}
|
|
6036
6056
|
|
|
6037
|
-
|
|
6057
|
+
|
|
6038
6058
|
var FILE_OPERATIONS = ["read", "upload", "replace", "delete"];
|
|
6039
6059
|
var MAX_FILE_COLLECTIONS = 20;
|
|
6040
6060
|
var COLLECTION_NAME = /^[a-z][a-z0-9_]{0,63}$/;
|
|
@@ -6082,7 +6102,7 @@ function readStringList(r, fail, ctx) {
|
|
|
6082
6102
|
function readFileMember(r, fail, name, line) {
|
|
6083
6103
|
r.expectPunct("(", 'after "member"');
|
|
6084
6104
|
r.expectPunct("{", `in member() for file collection "${name}" \u2014 member() needs { group, membership, member_user, member_group }`);
|
|
6085
|
-
const seen =
|
|
6105
|
+
const seen = new Map();
|
|
6086
6106
|
let operations;
|
|
6087
6107
|
while (!r.tryPunct("}")) {
|
|
6088
6108
|
const key = r.readKey(`for a member() option of file collection "${name}"`);
|
|
@@ -6141,7 +6161,7 @@ function readFileOwner(r, fail, name) {
|
|
|
6141
6161
|
function readFileParent(r, fail, name, line) {
|
|
6142
6162
|
r.expectPunct("(", 'after "parent"');
|
|
6143
6163
|
r.expectPunct("{", `in parent() for file collection "${name}" \u2014 parent() needs { table, via }`);
|
|
6144
|
-
const seen =
|
|
6164
|
+
const seen = new Map();
|
|
6145
6165
|
while (!r.tryPunct("}")) {
|
|
6146
6166
|
const key = r.readKey(`for a parent() option of file collection "${name}"`);
|
|
6147
6167
|
r.expectPunct(":", `after "${key.name}" in parent() for file collection "${name}"`);
|
|
@@ -6204,7 +6224,7 @@ function readCollection(r, fail, name, errors) {
|
|
|
6204
6224
|
if (callee.value !== "files") fail(callee.line, `file collection "${name}" must be declared with files({ \u2026 }).`);
|
|
6205
6225
|
r.expectPunct("(", 'after "files"');
|
|
6206
6226
|
r.expectPunct("{", `opening files() options for "${name}"`);
|
|
6207
|
-
const seen =
|
|
6227
|
+
const seen = new Set();
|
|
6208
6228
|
let path;
|
|
6209
6229
|
let scope = null;
|
|
6210
6230
|
let isPublic = false;
|
|
@@ -6377,7 +6397,7 @@ function canonicalFileCollectionsJson(collections) {
|
|
|
6377
6397
|
});
|
|
6378
6398
|
}
|
|
6379
6399
|
|
|
6380
|
-
|
|
6400
|
+
|
|
6381
6401
|
var BUILT_IN_GROUP_ROLES2 = ["owner", "admin", "member"];
|
|
6382
6402
|
var ROLE_NAME = /^[a-z][a-z0-9_]{0,63}$/;
|
|
6383
6403
|
function isPrototypeName(name) {
|
|
@@ -6386,7 +6406,7 @@ function isPrototypeName(name) {
|
|
|
6386
6406
|
function roleVocabularyErrors(policy) {
|
|
6387
6407
|
const errors = [];
|
|
6388
6408
|
const dupes = (list, what) => {
|
|
6389
|
-
const seen =
|
|
6409
|
+
const seen = new Set();
|
|
6390
6410
|
for (const name of list) {
|
|
6391
6411
|
if (seen.has(name)) errors.push(`${what} lists "${name}" twice.`);
|
|
6392
6412
|
seen.add(name);
|
|
@@ -6418,11 +6438,11 @@ function roleVocabularyErrors(policy) {
|
|
|
6418
6438
|
return errors;
|
|
6419
6439
|
}
|
|
6420
6440
|
|
|
6421
|
-
|
|
6441
|
+
|
|
6422
6442
|
var GROUP_OPERATIONS = ["read", "create", "update", "delete"];
|
|
6423
6443
|
var DEFAULT_GROUP_COLUMN = "group_id";
|
|
6424
6444
|
var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
6425
|
-
var declaredGroupRoles =
|
|
6445
|
+
var declaredGroupRoles = new WeakMap();
|
|
6426
6446
|
function readRoleList(r, fail, ctx) {
|
|
6427
6447
|
const open = r.next();
|
|
6428
6448
|
if (open.kind !== "punct" || open.value !== "[") fail(open.line, `${ctx} must be a list of quoted role names, such as ['owner', 'admin'].`);
|
|
@@ -6446,7 +6466,7 @@ function readGroupScope(r, tableName, line, fail) {
|
|
|
6446
6466
|
const explicit = {};
|
|
6447
6467
|
if (!r.tryPunct(")")) {
|
|
6448
6468
|
r.expectPunct("{", `in group() options for table "${tableName}"`);
|
|
6449
|
-
const seen =
|
|
6469
|
+
const seen = new Set();
|
|
6450
6470
|
while (!r.tryPunct("}")) {
|
|
6451
6471
|
const key = r.readKey(`for a group() option of table "${tableName}"`);
|
|
6452
6472
|
if (seen.has(key.name)) fail(key.line, `group() on table "${tableName}" declares ${key.name} twice.`);
|
|
@@ -6581,9 +6601,9 @@ function resolveGroupsAndParents(tables, tableByName, privatePolicy, vocabulary,
|
|
|
6581
6601
|
resolveGroupReferences(tables, errors);
|
|
6582
6602
|
}
|
|
6583
6603
|
|
|
6584
|
-
|
|
6604
|
+
|
|
6585
6605
|
var APP_ROLE_OPERATIONS = ["read", "create", "update", "delete"];
|
|
6586
|
-
var declaredLines =
|
|
6606
|
+
var declaredLines = new WeakMap();
|
|
6587
6607
|
function readAppRoleScope(r, tableName, line, fail) {
|
|
6588
6608
|
const where = `appRole() on table "${tableName}"`;
|
|
6589
6609
|
r.expectPunct("(", 'after "appRole"');
|
|
@@ -6608,7 +6628,7 @@ function readAppRoleScope(r, tableName, line, fail) {
|
|
|
6608
6628
|
sawRoles = true;
|
|
6609
6629
|
r.expectPunct(":", `after "roles" in ${where}`);
|
|
6610
6630
|
r.expectPunct("{", `opening appRole({ roles }) on table "${tableName}"`);
|
|
6611
|
-
const seenOps =
|
|
6631
|
+
const seenOps = new Set();
|
|
6612
6632
|
while (!r.tryPunct("}")) {
|
|
6613
6633
|
const op = r.readKey(`for an operation in appRole({ roles }) on table "${tableName}"`);
|
|
6614
6634
|
if (!APP_ROLE_OPERATIONS.includes(op.name)) {
|
|
@@ -6686,7 +6706,7 @@ function resolveAppRoleScopes(tables, appRoles, errors) {
|
|
|
6686
6706
|
}
|
|
6687
6707
|
}
|
|
6688
6708
|
|
|
6689
|
-
|
|
6709
|
+
|
|
6690
6710
|
var EMAIL_DOMAIN = EMAIL_DOMAIN_PATTERN;
|
|
6691
6711
|
var GROUP_KEYS = ["roles", "adminGrantableRoles"];
|
|
6692
6712
|
var APP_ROLE_KEYS = ["grantableBy", "emailDomain"];
|
|
@@ -6708,7 +6728,7 @@ function readStringList2(r, fail, ctx) {
|
|
|
6708
6728
|
}
|
|
6709
6729
|
function readGroupRoles(r, fail) {
|
|
6710
6730
|
r.expectPunct("{", "opening schema option groups");
|
|
6711
|
-
const seen =
|
|
6731
|
+
const seen = new Set();
|
|
6712
6732
|
const out = { roles: [], adminGrantableRoles: [] };
|
|
6713
6733
|
while (!r.tryPunct("}")) {
|
|
6714
6734
|
const key = r.readKey("for a groups option");
|
|
@@ -6735,7 +6755,7 @@ function readAppRoles(r, fail) {
|
|
|
6735
6755
|
r.expectPunct(":", `after app role "${key.name}"`);
|
|
6736
6756
|
r.expectPunct("{", `opening app role "${key.name}", which takes { grantableBy: [...], emailDomain: '...' }`);
|
|
6737
6757
|
const role = { name: key.name, grantableBy: [] };
|
|
6738
|
-
const seen =
|
|
6758
|
+
const seen = new Set();
|
|
6739
6759
|
while (!r.tryPunct("}")) {
|
|
6740
6760
|
const opt = r.readKey(`for an option of app role "${key.name}"`);
|
|
6741
6761
|
if (!APP_ROLE_KEYS.includes(opt.name)) {
|
|
@@ -6777,7 +6797,7 @@ function canonicalRoleVocabulary(groups, appRoles) {
|
|
|
6777
6797
|
};
|
|
6778
6798
|
}
|
|
6779
6799
|
function validateDeclaredRoles(groups, appRoles) {
|
|
6780
|
-
const delegation =
|
|
6800
|
+
const delegation = Object.create(null);
|
|
6781
6801
|
for (const role of appRoles ?? []) delegation[role.name] = role.grantableBy;
|
|
6782
6802
|
return [...emailDomainRoleErrors(appRoles ?? []), ...roleVocabularyErrors({
|
|
6783
6803
|
groupRoles: groups?.roles ?? [],
|
|
@@ -6800,7 +6820,7 @@ function emailDomainRoleErrors(appRoles) {
|
|
|
6800
6820
|
return errors;
|
|
6801
6821
|
}
|
|
6802
6822
|
|
|
6803
|
-
|
|
6823
|
+
|
|
6804
6824
|
function readSchemaOptions(reader, fail, fileErrors) {
|
|
6805
6825
|
const o = {};
|
|
6806
6826
|
if (!reader.tryPunct(",") || reader.peek().kind === "punct" && reader.peek().value === ")") return o;
|
|
@@ -6845,7 +6865,7 @@ function readSchemaOptions(reader, fail, fileErrors) {
|
|
|
6845
6865
|
return o;
|
|
6846
6866
|
}
|
|
6847
6867
|
|
|
6848
|
-
|
|
6868
|
+
|
|
6849
6869
|
function policyOwner(policy) {
|
|
6850
6870
|
if (policy.kind === "owner") return policy;
|
|
6851
6871
|
if (policy.kind === "any_of") return policy.policies.map(policyOwner).find((value) => value !== null) ?? null;
|
|
@@ -6920,7 +6940,7 @@ function validateRoomsOption(input, rawName, nameLine, columns, scope, client, r
|
|
|
6920
6940
|
}
|
|
6921
6941
|
return out;
|
|
6922
6942
|
}
|
|
6923
|
-
var COLUMN_HELPERS =
|
|
6943
|
+
var COLUMN_HELPERS = new Set([
|
|
6924
6944
|
"id",
|
|
6925
6945
|
"text",
|
|
6926
6946
|
"number",
|
|
@@ -6931,9 +6951,9 @@ var COLUMN_HELPERS = /* @__PURE__ */ new Set([
|
|
|
6931
6951
|
"json",
|
|
6932
6952
|
"blob"
|
|
6933
6953
|
]);
|
|
6934
|
-
var SCOPE_HELPERS =
|
|
6935
|
-
var TABLE_MARKER_HELPERS =
|
|
6936
|
-
var SCHEMA_CALLABLE =
|
|
6954
|
+
var SCOPE_HELPERS = new Set(["owner", "shared", "serverOnly", "member", "anyOf", "allOf", "parent", "group", "appRole"]);
|
|
6955
|
+
var TABLE_MARKER_HELPERS = new Set(["removedTable", "exported"]);
|
|
6956
|
+
var SCHEMA_CALLABLE = new Set([
|
|
6937
6957
|
...COLUMN_HELPERS,
|
|
6938
6958
|
...SCOPE_HELPERS,
|
|
6939
6959
|
...TABLE_MARKER_HELPERS,
|
|
@@ -7058,7 +7078,7 @@ var Reader = class {
|
|
|
7058
7078
|
this.bareIdIsText = (table) => !options.legacyIntegerIdDefault && !options.integerKeyTables?.has(table.toLowerCase());
|
|
7059
7079
|
}
|
|
7060
7080
|
pos = 0;
|
|
7061
|
-
|
|
7081
|
+
|
|
7062
7082
|
bareIdIsText;
|
|
7063
7083
|
peek() {
|
|
7064
7084
|
return this.tokens[this.pos];
|
|
@@ -7090,7 +7110,7 @@ var Reader = class {
|
|
|
7090
7110
|
}
|
|
7091
7111
|
return t;
|
|
7092
7112
|
}
|
|
7093
|
-
|
|
7113
|
+
|
|
7094
7114
|
readKey(context) {
|
|
7095
7115
|
const t = this.next();
|
|
7096
7116
|
if (t.kind === "ident" || t.kind === "string") return { name: t.value, line: t.line };
|
|
@@ -7107,10 +7127,10 @@ var Reader = class {
|
|
|
7107
7127
|
`line ${t.line}: expected a literal value (string, number, true/false, or null) ${context}, found ${describeToken(t)}. Computed values are not allowed \u2014 the declaration must be readable without running it.`
|
|
7108
7128
|
);
|
|
7109
7129
|
}
|
|
7110
|
-
|
|
7130
|
+
|
|
7111
7131
|
readLiteralObject(context) {
|
|
7112
7132
|
this.expectPunct("{", context);
|
|
7113
|
-
const out =
|
|
7133
|
+
const out = new Map();
|
|
7114
7134
|
while (!this.tryPunct("}")) {
|
|
7115
7135
|
const key = this.readKey(`for an option key ${context}`);
|
|
7116
7136
|
this.expectPunct(":", `after "${key.name}" ${context}`);
|
|
@@ -7135,7 +7155,7 @@ function describeToken(t) {
|
|
|
7135
7155
|
}
|
|
7136
7156
|
function readClientPermissions(r) {
|
|
7137
7157
|
r.expectPunct("{", "opening client permissions");
|
|
7138
|
-
const out =
|
|
7158
|
+
const out = Object.create(null);
|
|
7139
7159
|
while (!r.tryPunct("}")) {
|
|
7140
7160
|
const key = r.readKey("for a client permission");
|
|
7141
7161
|
if (Object.prototype.hasOwnProperty.call(out, key.name)) r.fail(`client declares "${key.name}" twice.`);
|
|
@@ -7219,7 +7239,7 @@ function readColumn(r, tableName, rawName, line) {
|
|
|
7219
7239
|
);
|
|
7220
7240
|
}
|
|
7221
7241
|
r.expectPunct("(", `after "${helper}"`);
|
|
7222
|
-
let opts =
|
|
7242
|
+
let opts = new Map();
|
|
7223
7243
|
if (!r.tryPunct(")")) {
|
|
7224
7244
|
opts = r.readLiteralObject(`in ${helper}() options for "${tableName}"."${rawName}"`);
|
|
7225
7245
|
r.tryPunct(",");
|
|
@@ -7239,7 +7259,7 @@ function readColumn(r, tableName, rawName, line) {
|
|
|
7239
7259
|
onDelete: "restrict",
|
|
7240
7260
|
renamedFrom: null
|
|
7241
7261
|
};
|
|
7242
|
-
const allowed = helper === "id" ?
|
|
7262
|
+
const allowed = helper === "id" ? new Set(["uuid"]) : new Set(["nullable", "default", "unique", "references", "onDelete", "renamedFrom"]);
|
|
7243
7263
|
for (const [key, { value, line: optLine }] of opts) {
|
|
7244
7264
|
if (!allowed.has(key)) {
|
|
7245
7265
|
throw new SchemaTsError(
|
|
@@ -7349,7 +7369,7 @@ function readSingleColumn(r, ctx) {
|
|
|
7349
7369
|
return t.value.toLowerCase();
|
|
7350
7370
|
}
|
|
7351
7371
|
function validateMemberColumns(names, optionLabel, tableName, line) {
|
|
7352
|
-
const seen =
|
|
7372
|
+
const seen = new Set();
|
|
7353
7373
|
for (const name of names) {
|
|
7354
7374
|
if (!SAFE_IDENT.test(name) || name.length > MAX_NAME_LENGTH) {
|
|
7355
7375
|
throw new SchemaTsError(`line ${line}: member(${optionLabel}) on table "${tableName}" names an invalid column "${name}".`);
|
|
@@ -7362,7 +7382,7 @@ function validateMemberColumns(names, optionLabel, tableName, line) {
|
|
|
7362
7382
|
}
|
|
7363
7383
|
function readMemberOperations(r, tableName) {
|
|
7364
7384
|
r.expectPunct("[", `for member({ operations }) on table "${tableName}"`);
|
|
7365
|
-
const seen =
|
|
7385
|
+
const seen = new Set();
|
|
7366
7386
|
while (!r.tryPunct("]")) {
|
|
7367
7387
|
const token = r.next();
|
|
7368
7388
|
if (token.kind !== "string" || !MEMBER_OPERATIONS.includes(token.value)) {
|
|
@@ -7442,14 +7462,14 @@ function readMemberScope(r, tableName, scopeLine) {
|
|
|
7442
7462
|
if (operationsSeen) explicitMemberOperations.add(node);
|
|
7443
7463
|
return node;
|
|
7444
7464
|
}
|
|
7445
|
-
var explicitMemberOperations =
|
|
7465
|
+
var explicitMemberOperations = new WeakSet();
|
|
7446
7466
|
function readPolicyOwner(r, tableName, line) {
|
|
7447
7467
|
r.expectPunct("(", 'after "owner"');
|
|
7448
7468
|
let column = DEFAULT_OWNER_COLUMN;
|
|
7449
7469
|
let read;
|
|
7450
7470
|
if (!r.tryPunct(")")) {
|
|
7451
7471
|
r.expectPunct("{", `in owner() inside anyOf() for table "${tableName}"`);
|
|
7452
|
-
const seen =
|
|
7472
|
+
const seen = new Set();
|
|
7453
7473
|
while (!r.tryPunct("}")) {
|
|
7454
7474
|
const key = r.readKey(`for an owner() option inside anyOf() for table "${tableName}"`);
|
|
7455
7475
|
if (seen.has(key.name)) throw new SchemaTsError(`line ${key.line}: option "${key.name}" appears twice in owner() inside anyOf() for table "${tableName}".`);
|
|
@@ -7600,7 +7620,7 @@ function readParentScope(r, tableName, line) {
|
|
|
7600
7620
|
function readRelations(r, tableName) {
|
|
7601
7621
|
r.expectPunct("{", `for "relations" of table "${tableName}"`);
|
|
7602
7622
|
const out = [];
|
|
7603
|
-
const seen =
|
|
7623
|
+
const seen = new Set();
|
|
7604
7624
|
while (!r.tryPunct("}")) {
|
|
7605
7625
|
const key = r.readKey(`for a relation name of table "${tableName}"`);
|
|
7606
7626
|
if (!SAFE_IDENT.test(key.name) || key.name.length > MAX_NAME_LENGTH) {
|
|
@@ -7668,7 +7688,7 @@ function readScope(r, tableName) {
|
|
|
7668
7688
|
return scope;
|
|
7669
7689
|
}
|
|
7670
7690
|
r.expectPunct("(", `after "${tok.value}"`);
|
|
7671
|
-
let opts =
|
|
7691
|
+
let opts = new Map();
|
|
7672
7692
|
if (!r.tryPunct(")")) {
|
|
7673
7693
|
opts = r.readLiteralObject(`in ${tok.value}() options for table "${tableName}"`);
|
|
7674
7694
|
r.tryPunct(",");
|
|
@@ -7763,7 +7783,7 @@ function readTable(r, rawName, nameLine) {
|
|
|
7763
7783
|
r.expectPunct("{", `opening the columns of table "${rawName}"`);
|
|
7764
7784
|
const columns = [];
|
|
7765
7785
|
const removedColumns = [];
|
|
7766
|
-
const seen =
|
|
7786
|
+
const seen = new Set();
|
|
7767
7787
|
while (!r.tryPunct("}")) {
|
|
7768
7788
|
const key = r.readKey(`for a column of table "${rawName}"`);
|
|
7769
7789
|
r.expectPunct(":", `after column "${key.name}"`);
|
|
@@ -7856,7 +7876,7 @@ function readTable(r, rawName, nameLine) {
|
|
|
7856
7876
|
}
|
|
7857
7877
|
}
|
|
7858
7878
|
const declaredNow = new Set(columns.map((c) => c.name));
|
|
7859
|
-
const renameSources =
|
|
7879
|
+
const renameSources = new Set();
|
|
7860
7880
|
for (const c of columns) {
|
|
7861
7881
|
if (!c.renamedFrom) continue;
|
|
7862
7882
|
if (declaredNow.has(c.renamedFrom)) {
|
|
@@ -7985,7 +8005,7 @@ function extractSchemaTs(source, options = {}) {
|
|
|
7985
8005
|
const tables = [];
|
|
7986
8006
|
const removedTables = [];
|
|
7987
8007
|
const exportedTables = [];
|
|
7988
|
-
const seen =
|
|
8008
|
+
const seen = new Set();
|
|
7989
8009
|
const reader = r;
|
|
7990
8010
|
while (!reader.tryPunct("}")) {
|
|
7991
8011
|
const key = reader.readKey("for a table name");
|
|
@@ -8114,21 +8134,21 @@ function canonicalTableShape(t) {
|
|
|
8114
8134
|
unique: c.unique,
|
|
8115
8135
|
references: c.references,
|
|
8116
8136
|
onDelete: c.onDelete,
|
|
8117
|
-
|
|
8137
|
+
|
|
8118
8138
|
...c.renamedFrom ? { renamedFrom: c.renamedFrom } : {}
|
|
8119
8139
|
})),
|
|
8120
8140
|
indexes: t.indexes,
|
|
8121
8141
|
uniques: t.uniques,
|
|
8122
8142
|
...t.removedColumns.length > 0 ? { removedColumns: t.removedColumns } : {},
|
|
8123
|
-
|
|
8143
|
+
|
|
8124
8144
|
...t.rooms ? { rooms: t.rooms } : {},
|
|
8125
|
-
|
|
8126
|
-
|
|
8145
|
+
|
|
8146
|
+
|
|
8127
8147
|
...t.groupRefs && t.groupRefs.length > 0 ? { groupRefs: t.groupRefs } : {},
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8148
|
+
|
|
8149
|
+
|
|
8150
|
+
|
|
8151
|
+
|
|
8132
8152
|
...t.relations.length > 0 ? {
|
|
8133
8153
|
relations: t.relations.map((rel) => ({
|
|
8134
8154
|
name: rel.name,
|
|
@@ -8141,7 +8161,7 @@ function canonicalTableShape(t) {
|
|
|
8141
8161
|
};
|
|
8142
8162
|
}
|
|
8143
8163
|
|
|
8144
|
-
|
|
8164
|
+
|
|
8145
8165
|
var import_declared_data_contract = __toESM(require_declared_data_contract());
|
|
8146
8166
|
function declareEntry(dictionary, name, value) {
|
|
8147
8167
|
Object.defineProperty(dictionary, name, { value, writable: true, enumerable: true, configurable: true });
|
|
@@ -8186,7 +8206,7 @@ function declaredRolesFromSource(files) {
|
|
|
8186
8206
|
));
|
|
8187
8207
|
}
|
|
8188
8208
|
|
|
8189
|
-
|
|
8209
|
+
|
|
8190
8210
|
var import_declared_data_contract2 = __toESM(require_declared_data_contract());
|
|
8191
8211
|
var import_typed_data = __toESM(require_typed_data());
|
|
8192
8212
|
var import_runtime_types2 = __toESM(require_runtime_types());
|
|
@@ -8197,7 +8217,7 @@ var import_runtime_types3 = __toESM(require_runtime_types());
|
|
|
8197
8217
|
var import_typed_files2 = __toESM(require_typed_files());
|
|
8198
8218
|
var checkerContract = __toESM(require_checker_contract());
|
|
8199
8219
|
|
|
8200
|
-
|
|
8220
|
+
|
|
8201
8221
|
var import_runtime_types = __toESM(require_runtime_types());
|
|
8202
8222
|
var import_generated_declarations = __toESM(require_generated_declarations());
|
|
8203
8223
|
var import_generated_declarations_render = __toESM(require_generated_declarations_render());
|
|
@@ -8222,7 +8242,7 @@ function isRuntimeEndpointGlobal(diag, functions) {
|
|
|
8222
8242
|
return RUNTIME_ENDPOINT_ACCESS.test(lines2.slice(diag.line - 1).join("\n").slice(diag.column - 1));
|
|
8223
8243
|
}
|
|
8224
8244
|
|
|
8225
|
-
|
|
8245
|
+
|
|
8226
8246
|
var import_consumer_contract = __toESM(require_consumer_contract());
|
|
8227
8247
|
function generateFromFiles(files) {
|
|
8228
8248
|
const authority = clientAuthorityFromSource(files);
|
|
@@ -8242,7 +8262,7 @@ function filesDeclarationFromFiles(files) {
|
|
|
8242
8262
|
const canonical = declaredFilesFromSource(files);
|
|
8243
8263
|
return canonical ? (0, import_typed_files.describeFilesClient)(canonical).declaration : void 0;
|
|
8244
8264
|
}
|
|
8245
|
-
|
|
8265
|
+
|
|
8246
8266
|
0 && (module.exports = {
|
|
8247
8267
|
CONSUMER_CONTRACT,
|
|
8248
8268
|
ENDPOINT_DECLARATION,
|