@ai-matrx/records-ui 0.116.45 → 0.116.47
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 +29 -1
- package/dist/{SaveToTable-SL5DUNI4.js → SaveToTable-HG3HQMAQ.js} +5 -5
- package/dist/{chunk-KQR2RA4V.js → chunk-ABIUJCNS.js} +3 -3
- package/dist/chunk-ABIUJCNS.js.map +1 -0
- package/dist/{chunk-F4SAKQKQ.js → chunk-K3B5IRXY.js} +79 -76
- package/dist/chunk-K3B5IRXY.js.map +1 -0
- package/dist/{chunk-OV6QBL5R.js → chunk-LBZZDHV6.js} +8 -8
- package/dist/chunk-LBZZDHV6.js.map +1 -0
- package/dist/{chunk-NKZBAIU4.js → chunk-MDXDJVDB.js} +8 -6
- package/dist/chunk-MDXDJVDB.js.map +1 -0
- package/dist/{chunk-XKI6S5KF.js → chunk-VJDJQDDI.js} +7 -7
- package/dist/{chunk-XKI6S5KF.js.map → chunk-VJDJQDDI.js.map} +1 -1
- package/dist/helpers.cjs +14 -12
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.js +14 -12
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +137 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -30
- package/dist/index.js.map +1 -1
- package/dist/object-actions.cjs +8 -8
- package/dist/object-actions.cjs.map +1 -1
- package/dist/object-actions.d.cts +1 -1
- package/dist/object-actions.d.ts +1 -1
- package/dist/object-actions.js +2 -2
- package/dist/{objectActions-Be9sBGvW.d.cts → objectActions-DK-qa5zC.d.cts} +1 -1
- package/dist/{objectActions-Be9sBGvW.d.ts → objectActions-DK-qa5zC.d.ts} +1 -1
- package/dist/pickers.cjs +90 -86
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +3 -3
- package/package.json +5 -5
- package/dist/chunk-F4SAKQKQ.js.map +0 -1
- package/dist/chunk-KQR2RA4V.js.map +0 -1
- package/dist/chunk-NKZBAIU4.js.map +0 -1
- package/dist/chunk-OV6QBL5R.js.map +0 -1
- /package/dist/{SaveToTable-SL5DUNI4.js.map → SaveToTable-HG3HQMAQ.js.map} +0 -0
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
// src/rights.ts
|
|
4
4
|
import { atLeast } from "@ai-matrx/records/field-kinds";
|
|
5
5
|
var LEVEL_WORD = {
|
|
6
|
-
viewer: "
|
|
7
|
-
commenter: "
|
|
8
|
-
edit_content: "
|
|
9
|
-
editor: "
|
|
10
|
-
admin: "
|
|
6
|
+
viewer: "View access",
|
|
7
|
+
commenter: "Comment access",
|
|
8
|
+
edit_content: "Edit access",
|
|
9
|
+
editor: "Edit access",
|
|
10
|
+
admin: "Full access"
|
|
11
11
|
};
|
|
12
12
|
var NEEDS = {
|
|
13
13
|
read: "viewer",
|
|
@@ -32,7 +32,7 @@ function levelNeededFor(what) {
|
|
|
32
32
|
return NEEDS[what];
|
|
33
33
|
}
|
|
34
34
|
var NOT_YET = "Checking what you may do here. Nothing is offered until then.";
|
|
35
|
-
var NOTHING_AT_ALL = "You have not been given this. Ask somebody
|
|
35
|
+
var NOTHING_AT_ALL = "You have not been given this. Ask somebody with Full access on it to share it with you.";
|
|
36
36
|
function sentenceFor(what, level) {
|
|
37
37
|
if (level === null) return NOTHING_AT_ALL;
|
|
38
38
|
const need = LEVEL_WORD[NEEDS[what]];
|
|
@@ -46,7 +46,7 @@ function sentenceFor(what, level) {
|
|
|
46
46
|
share: "pass this on to somebody else",
|
|
47
47
|
structure: "change the columns of this table"
|
|
48
48
|
};
|
|
49
|
-
return `You
|
|
49
|
+
return `You have ${have} here, and it takes ${need} to ${doing[what]}. Ask somebody with Full access on it to move you up.`;
|
|
50
50
|
}
|
|
51
51
|
function whatYouMayDo(level, known = true) {
|
|
52
52
|
const may = (what) => known && atLeast(level, NEEDS[what]);
|
|
@@ -92,4 +92,4 @@ export {
|
|
|
92
92
|
tableIsLocked,
|
|
93
93
|
DATABASE_LOCKED_REASON
|
|
94
94
|
};
|
|
95
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-LBZZDHV6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rights.ts"],"sourcesContent":["// src/rights.ts — @ai-matrx/records-ui\n//\n// THE ONE PLACE A LEVEL BECOMES A SCREEN.\n//\n// WHAT A PERSON HIT (independent verdict, sixth pass, 19-20 September). A\n// colleague who had been shared a table at viewer opened it, double-clicked a\n// cell, got a live editor, typed a value and pressed Enter — and only THEN was\n// told she may not write. \"The permission is right; the screen told her she\n// could.\" Measured against Airtable, Notion and Linear the verdict called it\n// out by name: \"None of these three products lets you start an action it\n// already knows it will reject.\"\n//\n// WHY THE SCREEN COULD NOT KNOW. The rights question was a PORT with two honest\n// answers and no third: `NO_RIGHTS` (every administering control absent, which\n// is useless for a host whose authority IS the store's) and\n// `storeDecidesRights` — `{admin: true, comment: true, write: true}` for every\n// non-kernel table, for everybody. That second one is the defect, written down:\n// it is the screen ASSUMING the answer and letting the door say no afterwards.\n//\n// WHAT REPLACES IT. The store already answers this, and the client now carries\n// it: `custom.read_records` returns the reader's level on the TABLE on every\n// row (so `Table.your_level` costs nothing), and `custom.my_levels` — the door\n// this lane added — answers the caller's level on any subject they name, one\n// call for a whole page. This file is the only place in the package that turns\n// one of those four words into what a screen may DRAW.\n//\n// THE LADDER IS THE STORE'S, NOT OURS: viewer < commenter < editor < admin, and\n// which rung each door requires is read from the doors themselves —\n// `custom.record_update` asserts `editor` on the record, `custom.field_declare`\n// asserts `admin` on the TABLE (\"the SHAPE of this table, which is an admin's\n// right and not an editor's\"), `custom.io_comment_write` admits a commenter.\n// Nothing here invents a rule; it mirrors the four assertions those doors make\n// and is wrong the moment they change, which is what the suite is for.\n//\n// ABSENT OR HONEST, NEVER DEAD. Every `false` here carries the sentence that\n// says why and what to do about it, so a control can be left out AND explained.\n// A screen that hid a control with nothing to say is the silent half of the\n// same defect.\n\nimport { atLeast, type PermissionLevel } from \"@ai-matrx/records/field-kinds\";\nimport type { Table } from \"@ai-matrx/records\";\n\n/** The six things a person does to a record or a table, as the screens offer them. */\nexport type Capability = \"read\" | \"comment\" | \"write\" | \"organise\" | \"remove\" | \"share\" | \"structure\";\n\nexport interface WhatYouMayDo {\n /** The word the store answered, or null when it answered nothing. */\n level: PermissionLevel | null;\n /**\n * Whether the store has ANSWERED yet. `false` is a third state and not a\n * refusal: a screen that drew \"you may not\" while the answer was in flight\n * would blink every control off on every reload, which is its own lie.\n */\n known: boolean;\n read: boolean;\n comment: boolean;\n write: boolean;\n /** Duplicate, merge, restore, make a layout the default: the doors that ask `editor`, above content. */\n organise: boolean;\n remove: boolean;\n share: boolean;\n structure: boolean;\n /** Why this person may not do that, in one sentence naming the way in. */\n why: (what: Capability) => string;\n}\n\n/** What each rung of the ladder is called where a person reads it. */\nexport const LEVEL_WORD: Record<PermissionLevel, string> = {\n viewer: \"View access\",\n commenter: \"Comment access\",\n edit_content: \"Edit access\",\n editor: \"Edit access\",\n admin: \"Full access\",\n};\n\n/**\n * WHICH RUNG EACH DOOR ASKS FOR. Read off the doors themselves, in one place,\n * so a screen never re-decides it and the suite has one thing to check.\n */\nconst NEEDS: Record<Capability, PermissionLevel> = {\n read: \"viewer\",\n // custom.io_comment_write\n comment: \"commenter\",\n // custom.record_update / custom.record_write — `edit_content` changes rows and page content;\n // columns, views and settings (structure) stay with admin below, and sharing with admin.\n write: \"edit_content\",\n // custom.view_designate / view_declare / migrate_merge / record_restore — all ask `editor`: more than\n // changing content (`edit_content`), less than changing columns (`admin`).\n organise: \"editor\",\n // custom.record_delete\n remove: \"editor\",\n // custom.share_grant — ONE-LADDER (2026-10-10): Edit may pass View / Comment / Edit on inside the\n // organization (iam.may_grant_as, knobs access.sharing/*). Which levels, and to whom, is the share\n // dialog's own question (iam.my_grantable_levels); the Share button only has to open for Edit.\n share: \"editor\",\n // custom.field_declare / field_update / field_retire / table settings\n structure: \"admin\",\n};\n\n/** The rung a capability asks for — so a short \"Needs Full access\" never re-decides the ladder. */\nexport function levelNeededFor(what: Capability): PermissionLevel {\n return NEEDS[what];\n}\n\nconst NOT_YET =\n \"Checking what you may do here. Nothing is offered until then.\";\n\nconst NOTHING_AT_ALL =\n \"You have not been given this. Ask somebody with Full access on it to share it with you.\";\n\n/** The sentence for one refusal: what the level is, what it would have to be. */\nfunction sentenceFor(what: Capability, level: PermissionLevel | null): string {\n if (level === null) return NOTHING_AT_ALL;\n const need = LEVEL_WORD[NEEDS[what]];\n const have = LEVEL_WORD[level];\n const doing: Record<Capability, string> = {\n read: \"open this\",\n comment: \"leave a comment\",\n write: \"change anything here\",\n organise: \"organize this\",\n remove: \"delete this\",\n share: \"pass this on to somebody else\",\n structure: \"change the columns of this table\",\n };\n return `You have ${have} here, and it takes ${need} to ${doing[what]}. Ask somebody with Full access on it to move you up.`;\n}\n\n/**\n * WHAT ONE LEVEL LETS A PERSON DO. `level` null and `known` true means the\n * store said \"nothing\" — a real answer. `known` false means it has not said.\n */\nexport function whatYouMayDo(level: PermissionLevel | null, known = true): WhatYouMayDo {\n const may = (what: Capability) => known && atLeast(level, NEEDS[what]);\n return {\n level: known ? level : null,\n known,\n read: may(\"read\"),\n comment: may(\"comment\"),\n write: may(\"write\"),\n organise: may(\"organise\"),\n remove: may(\"remove\"),\n share: may(\"share\"),\n structure: may(\"structure\"),\n why: (what) => (known ? sentenceFor(what, level) : NOT_YET),\n };\n}\n\n/** Nothing offered, because nothing is known yet. */\nexport const NOT_ANSWERED_YET: WhatYouMayDo = whatYouMayDo(null, false);\n\n/**\n * REC-27. The nine Tables the platform ships are not administered from a\n * person's screen whatever level they hold on them — so the structure controls\n * are absent for a kernel Table and say why, and everything else follows the\n * level as usual.\n */\nexport const KERNEL_REASON =\n \"This is one of the tables the platform ships, so its columns are not changed from a screen. \" +\n \"Make your own table to change columns.\";\n\nexport function whatYouMayDoWithTable(\n table: Table | null | undefined,\n level: PermissionLevel | null,\n known: boolean,\n): WhatYouMayDo {\n const base = whatYouMayDo(level, known);\n // A LOCKED DATABASE (lane NOTION-SMALL-2): the columns and the table's settings stay as they are until\n // somebody unlocks it. An editing convenience, never a permission — the lock changes what is OFFERED, the\n // store's ladder is untouched and anyone who may edit the table may unlock it.\n if (!table?.is_kernel) return table && tableIsLocked(table) ? lockedStructure(base) : base;\n return {\n ...base,\n structure: false,\n why: (what) => (what === \"structure\" ? KERNEL_REASON : base.why(what)),\n };\n}\n\n/** Is this table locked against column and settings changes? Kept on the table's own metadata. */\nexport function tableIsLocked(table: Pick<Table, \"metadata\"> | null | undefined): boolean {\n return table?.metadata?.[\"locked\"] === true;\n}\n\nexport const DATABASE_LOCKED_REASON = \"This database is locked, so its columns and settings are read-only. Unlock it to change them.\";\n\nfunction lockedStructure(base: WhatYouMayDo): WhatYouMayDo {\n return { ...base, structure: false, why: (what) => (what === \"structure\" ? DATABASE_LOCKED_REASON : base.why(what)) };\n}\n"],"mappings":";;;AAuCA,SAAS,eAAqC;AA4BvC,IAAM,aAA8C;AAAA,EACzD,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,OAAO;AACT;AAMA,IAAM,QAA6C;AAAA,EACjD,MAAM;AAAA;AAAA,EAEN,SAAS;AAAA;AAAA;AAAA,EAGT,OAAO;AAAA;AAAA;AAAA,EAGP,UAAU;AAAA;AAAA,EAEV,QAAQ;AAAA;AAAA;AAAA;AAAA,EAIR,OAAO;AAAA;AAAA,EAEP,WAAW;AACb;AAGO,SAAS,eAAe,MAAmC;AAChE,SAAO,MAAM,IAAI;AACnB;AAEA,IAAM,UACJ;AAEF,IAAM,iBACJ;AAGF,SAAS,YAAY,MAAkB,OAAuC;AAC5E,MAAI,UAAU,KAAM,QAAO;AAC3B,QAAM,OAAO,WAAW,MAAM,IAAI,CAAC;AACnC,QAAM,OAAO,WAAW,KAAK;AAC7B,QAAM,QAAoC;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@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
NOT_ANSWERED_YET,
|
|
4
4
|
whatYouMayDo,
|
|
5
5
|
whatYouMayDoWithTable
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LBZZDHV6.js";
|
|
7
7
|
import {
|
|
8
8
|
__reExport
|
|
9
9
|
} from "./chunk-HKYEHBQT.js";
|
|
@@ -328,23 +328,25 @@ function exampleOf(error) {
|
|
|
328
328
|
const example = detail.example;
|
|
329
329
|
return typeof example === "string" && example.trim() !== "" ? example.trim() : null;
|
|
330
330
|
}
|
|
331
|
+
var TIMED_OUT_SAID = "That took too long. Nothing was lost; try again.";
|
|
331
332
|
function refusalForAPerson(error) {
|
|
332
333
|
const code = error.code ?? "internal";
|
|
334
|
+
const timedOut = code === "timed_out" || error.sqlstate === "57014" || /canceling statement due to statement timeout/i.test(String(error.message ?? ""));
|
|
333
335
|
const ours = error.ours === true;
|
|
334
336
|
const hint = plainSentence(String(error.hint ?? ""));
|
|
335
337
|
const message = ours ? plainSentence(String(error.message ?? "")) : peopleSentence(String(error.message ?? ""));
|
|
336
|
-
const title = TITLE[code] ?? "That was refused";
|
|
338
|
+
const title = timedOut ? TITLE["timed_out"] : TITLE[code] ?? "That was refused";
|
|
337
339
|
const hintIsForEngineers = isDeveloperHint(String(error.hint ?? ""));
|
|
338
340
|
const example = exampleOf(error);
|
|
339
|
-
const remedy = (example ? `Enter it like ${example}.` : null) ?? (hintIsForEngineers ? null : hint.kept) ?? REMEDY[code] ?? REMEDY["internal"];
|
|
341
|
+
const remedy = (example ? `Enter it like ${example}.` : null) ?? (hintIsForEngineers ? null : hint.kept) ?? (timedOut ? REMEDY["timed_out"] : REMEDY[code]) ?? REMEDY["internal"];
|
|
340
342
|
const messageIsForEngineers = isEngineerText(String(error.message ?? ""));
|
|
341
|
-
const said = (messageIsForEngineers ? "" : message.kept ?? "").trim();
|
|
343
|
+
const said = timedOut ? TIMED_OUT_SAID : (messageIsForEngineers ? "" : message.kept ?? "").trim();
|
|
342
344
|
const forEngineers = [
|
|
343
345
|
error.sqlstate ? `SQLSTATE ${error.sqlstate}.` : null,
|
|
344
346
|
// The client's own note about a class it did not recognize, or a call that
|
|
345
347
|
// never reached the store. It is rendered out of sight, never as a sentence.
|
|
346
348
|
error.diagnostic ? error.diagnostic : null,
|
|
347
|
-
messageIsForEngineers ? `Message: ${error.message}` : null,
|
|
349
|
+
messageIsForEngineers || timedOut ? `Message: ${error.message}` : null,
|
|
348
350
|
error.hint && (hintIsForEngineers || hint.kept !== error.hint) ? `Hint: ${error.hint}` : null,
|
|
349
351
|
message.dropped.length > 0 || hint.dropped.length > 0 ? `Dropped from the person's view: ${[...message.dropped, ...hint.dropped].join(" | ")}` : null
|
|
350
352
|
].filter(Boolean).join(" ");
|
|
@@ -1430,4 +1432,4 @@ export {
|
|
|
1430
1432
|
choiceNudgeOf,
|
|
1431
1433
|
useChoiceNudge
|
|
1432
1434
|
};
|
|
1433
|
-
//# sourceMappingURL=chunk-
|
|
1435
|
+
//# sourceMappingURL=chunk-MDXDJVDB.js.map
|