@ai-matrx/records-ui 0.116.56 → 0.116.58
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 +32 -1
- package/dist/{SaveToTable-EM2JT3OS.js → SaveToTable-2TQKEYJA.js} +3 -3
- package/dist/{chunk-GZJ7GRM2.js → chunk-F3NGOSYY.js} +3 -3
- package/dist/{chunk-7LELV7UI.js → chunk-NGOPU3AJ.js} +128 -44
- package/dist/chunk-NGOPU3AJ.js.map +1 -0
- package/dist/{chunk-BZ6PLCAR.js → chunk-Y6U5OFJX.js} +2 -2
- package/dist/index.cjs +10026 -9840
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +149 -61
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +2018 -1961
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-7LELV7UI.js.map +0 -1
- /package/dist/{SaveToTable-EM2JT3OS.js.map → SaveToTable-2TQKEYJA.js.map} +0 -0
- /package/dist/{chunk-GZJ7GRM2.js.map → chunk-F3NGOSYY.js.map} +0 -0
- /package/dist/{chunk-BZ6PLCAR.js.map → chunk-Y6U5OFJX.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -5915,7 +5915,7 @@ interface PageCanvasProps {
|
|
|
5915
5915
|
/** Called with a chart edited in settings (an Interface copies a published chart before changing it). */
|
|
5916
5916
|
onChart?: ((chart: ChartSpec) => void) | undefined;
|
|
5917
5917
|
}
|
|
5918
|
-
declare function PageCanvas(
|
|
5918
|
+
declare function PageCanvas(props: PageCanvasProps): react.JSX.Element;
|
|
5919
5919
|
|
|
5920
5920
|
interface InterfaceScreenProps {
|
|
5921
5921
|
interfaceId?: Uuid$1 | null | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -5915,7 +5915,7 @@ interface PageCanvasProps {
|
|
|
5915
5915
|
/** Called with a chart edited in settings (an Interface copies a published chart before changing it). */
|
|
5916
5916
|
onChart?: ((chart: ChartSpec) => void) | undefined;
|
|
5917
5917
|
}
|
|
5918
|
-
declare function PageCanvas(
|
|
5918
|
+
declare function PageCanvas(props: PageCanvasProps): react.JSX.Element;
|
|
5919
5919
|
|
|
5920
5920
|
interface InterfaceScreenProps {
|
|
5921
5921
|
interfaceId?: Uuid$1 | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -182,7 +182,7 @@ import {
|
|
|
182
182
|
withoutAddition,
|
|
183
183
|
withoutLeadingBlank,
|
|
184
184
|
workedOutErrorFor
|
|
185
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-F3NGOSYY.js";
|
|
186
186
|
import {
|
|
187
187
|
CHART_PLOT_PX,
|
|
188
188
|
EMBEDDED_ROW_PX,
|
|
@@ -293,7 +293,7 @@ import {
|
|
|
293
293
|
visibilityLaneFor,
|
|
294
294
|
whyNotAskable,
|
|
295
295
|
writeOnTheWinningVersion_exports
|
|
296
|
-
} from "./chunk-
|
|
296
|
+
} from "./chunk-Y6U5OFJX.js";
|
|
297
297
|
import {
|
|
298
298
|
ACTION_CHECKING_ACCESS_REASON,
|
|
299
299
|
ACTION_NOT_HERE_REASON,
|
|
@@ -346,6 +346,7 @@ import {
|
|
|
346
346
|
PickOrAdd,
|
|
347
347
|
ROLLUP_AGG_LABEL,
|
|
348
348
|
ROLLUP_AGG_VALUES,
|
|
349
|
+
ReadRefusalDock,
|
|
349
350
|
RecordsUiProvider,
|
|
350
351
|
RefusalLine,
|
|
351
352
|
RefusalNotice,
|
|
@@ -364,6 +365,7 @@ import {
|
|
|
364
365
|
WORK_INBOX_KIND_GROUP_LABEL,
|
|
365
366
|
WORK_INBOX_KIND_LABEL,
|
|
366
367
|
addFields,
|
|
368
|
+
askWithOneRetry,
|
|
367
369
|
cardTitleField,
|
|
368
370
|
changedRecordName,
|
|
369
371
|
choiceNudgeOf,
|
|
@@ -397,12 +399,14 @@ import {
|
|
|
397
399
|
tokenFor,
|
|
398
400
|
useChoiceNudge,
|
|
399
401
|
usePickerTables,
|
|
402
|
+
useReadAgain,
|
|
403
|
+
useReadRefusal,
|
|
400
404
|
useRecordRights,
|
|
401
405
|
useRecordsUi,
|
|
402
406
|
useRowRights,
|
|
403
407
|
useTableRights,
|
|
404
408
|
withoutInternalCodes
|
|
405
|
-
} from "./chunk-
|
|
409
|
+
} from "./chunk-NGOPU3AJ.js";
|
|
406
410
|
import {
|
|
407
411
|
FEWEST_KEY_VALUE_PAIRS,
|
|
408
412
|
FEWEST_LIST_ITEMS,
|
|
@@ -2568,11 +2572,13 @@ import { useRecordsClient as useRecordsClient5 } from "@ai-matrx/records/react";
|
|
|
2568
2572
|
function useWholeTableCount(args) {
|
|
2569
2573
|
const client = useRecordsClient5();
|
|
2570
2574
|
const [count, setCount] = useState5(null);
|
|
2575
|
+
const reads = useReadRefusal("record_aggregate");
|
|
2576
|
+
const [attempt, again] = useReadAgain();
|
|
2571
2577
|
useEffect6(() => {
|
|
2572
2578
|
if (!args.needed) return;
|
|
2573
2579
|
let live = true;
|
|
2574
|
-
void client.recordAggregate({ table_id: args.tableId, measures: [{ op: "count" }] }).then((answer) => {
|
|
2575
|
-
if (!live || !answer
|
|
2580
|
+
void askWithOneRetry(() => client.recordAggregate({ table_id: args.tableId, measures: [{ op: "count" }] })).then((answer) => {
|
|
2581
|
+
if (!live || !reads.take(answer, again)) return;
|
|
2576
2582
|
const row = answer.data?.[0];
|
|
2577
2583
|
const n = Number(row?.measures?.["count"] ?? row?.row_count);
|
|
2578
2584
|
setCount(Number.isFinite(n) ? { tableId: args.tableId, n } : null);
|
|
@@ -2580,7 +2586,7 @@ function useWholeTableCount(args) {
|
|
|
2580
2586
|
return () => {
|
|
2581
2587
|
live = false;
|
|
2582
2588
|
};
|
|
2583
|
-
}, [client, args.tableId, args.needed, args.version]);
|
|
2589
|
+
}, [client, args.tableId, args.needed, args.version, attempt]);
|
|
2584
2590
|
return args.needed && count && count.tableId === args.tableId ? count.n : null;
|
|
2585
2591
|
}
|
|
2586
2592
|
|
|
@@ -2606,6 +2612,8 @@ function useTableDecorations(tableId, revision) {
|
|
|
2606
2612
|
const [state, setState] = useState6({ data: null, loading: Boolean(tableId) });
|
|
2607
2613
|
const seen = useRef5({ tableId: void 0, revision: void 0 });
|
|
2608
2614
|
const ticket = useRef5(0);
|
|
2615
|
+
const reads = useReadRefusal("table_decorations");
|
|
2616
|
+
const [attempt, again] = useReadAgain();
|
|
2609
2617
|
useEffect7(() => {
|
|
2610
2618
|
if (!tableId) {
|
|
2611
2619
|
ticket.current += 1;
|
|
@@ -2620,11 +2628,12 @@ function useTableDecorations(tableId, revision) {
|
|
|
2620
2628
|
}
|
|
2621
2629
|
const mine = ticket.current += 1;
|
|
2622
2630
|
setState((held) => ({ data: held.data, loading: true }));
|
|
2623
|
-
void client.tableDecorations({ table_id: tableId }).then((result) => {
|
|
2631
|
+
void askWithOneRetry(() => client.tableDecorations({ table_id: tableId })).then((result) => {
|
|
2624
2632
|
if (mine !== ticket.current) return;
|
|
2625
|
-
setState({ data:
|
|
2633
|
+
if (!reads.take(result, again)) return setState((held) => ({ data: held.data, loading: false }));
|
|
2634
|
+
setState({ data: result.data, loading: false });
|
|
2626
2635
|
});
|
|
2627
|
-
}, [client, tableId, revision]);
|
|
2636
|
+
}, [client, tableId, revision, attempt]);
|
|
2628
2637
|
useEffect7(() => () => {
|
|
2629
2638
|
ticket.current += 1;
|
|
2630
2639
|
}, []);
|
|
@@ -4450,17 +4459,32 @@ function useChoiceOptions(fields, keys) {
|
|
|
4450
4459
|
const client = useRecordsClient13();
|
|
4451
4460
|
const [index, setIndex] = useState14(() => /* @__PURE__ */ new Map());
|
|
4452
4461
|
const wantedKey = keys.join("\0");
|
|
4462
|
+
const reads = useReadRefusal("field_options");
|
|
4463
|
+
const [attempt, again] = useReadAgain();
|
|
4453
4464
|
useEffect11(() => {
|
|
4454
4465
|
const missing = keys.map((key) => fields.find((f) => f.key === key)).filter((f) => f !== void 0 && !index.has(f.key));
|
|
4455
4466
|
if (missing.length === 0) return;
|
|
4456
4467
|
let cancelled = false;
|
|
4457
4468
|
void Promise.all(
|
|
4458
4469
|
missing.map(async (field) => {
|
|
4459
|
-
const got = await (0, askOnce_exports.fieldOptionsOnce)(client, field.id);
|
|
4460
|
-
return [field.key, got
|
|
4470
|
+
const got = await askWithOneRetry(() => (0, askOnce_exports.fieldOptionsOnce)(client, field.id));
|
|
4471
|
+
return [field.key, got];
|
|
4461
4472
|
})
|
|
4462
|
-
).then((
|
|
4473
|
+
).then((pairs) => {
|
|
4463
4474
|
if (cancelled) return;
|
|
4475
|
+
const refused = pairs.find(([, got]) => !got.ok);
|
|
4476
|
+
const refusedKeys = pairs.filter(([, got]) => !got.ok).map(([key]) => key);
|
|
4477
|
+
const askAgain = () => {
|
|
4478
|
+
setIndex((held) => {
|
|
4479
|
+
const next = new Map(held);
|
|
4480
|
+
for (const key of refusedKeys) next.delete(key);
|
|
4481
|
+
return next;
|
|
4482
|
+
});
|
|
4483
|
+
again();
|
|
4484
|
+
};
|
|
4485
|
+
if (refused) reads.take(refused[1], askAgain);
|
|
4486
|
+
else reads.take({ ok: true, data: null }, askAgain);
|
|
4487
|
+
const answers = pairs.map(([key, got]) => [key, got.ok ? (got.data ?? []).map(lookOf) : null]);
|
|
4464
4488
|
setIndex((held) => {
|
|
4465
4489
|
const next = new Map(held);
|
|
4466
4490
|
for (const [key, looks] of answers) next.set(key, looks ?? []);
|
|
@@ -4470,7 +4494,7 @@ function useChoiceOptions(fields, keys) {
|
|
|
4470
4494
|
return () => {
|
|
4471
4495
|
cancelled = true;
|
|
4472
4496
|
};
|
|
4473
|
-
}, [client, wantedKey, fields]);
|
|
4497
|
+
}, [client, wantedKey, fields, attempt]);
|
|
4474
4498
|
return index;
|
|
4475
4499
|
}
|
|
4476
4500
|
function lookOf(option) {
|
|
@@ -5018,20 +5042,23 @@ function useFormulaReadings(tableId, formulas) {
|
|
|
5018
5042
|
const client = useRecordsClient14();
|
|
5019
5043
|
const [readings, setReadings] = useState15({});
|
|
5020
5044
|
const key = formulas.join("\0");
|
|
5045
|
+
const reads = useReadRefusal("formula_parse");
|
|
5046
|
+
const [attempt, again] = useReadAgain();
|
|
5021
5047
|
useEffect12(() => {
|
|
5022
5048
|
if (!tableId) return;
|
|
5023
5049
|
let live = true;
|
|
5024
5050
|
for (const text of formulas) {
|
|
5025
5051
|
if (!text.trim() || text in readings) continue;
|
|
5026
|
-
void client.formulaParse({ table_id: tableId, text }).then((answer) => {
|
|
5052
|
+
void askWithOneRetry(() => client.formulaParse({ table_id: tableId, text })).then((answer) => {
|
|
5027
5053
|
if (!live) return;
|
|
5028
|
-
|
|
5054
|
+
if (!reads.take(answer, again)) return;
|
|
5055
|
+
setReadings((was) => ({ ...was, [text]: answer.data }));
|
|
5029
5056
|
});
|
|
5030
5057
|
}
|
|
5031
5058
|
return () => {
|
|
5032
5059
|
live = false;
|
|
5033
5060
|
};
|
|
5034
|
-
}, [client, tableId, key]);
|
|
5061
|
+
}, [client, tableId, key, attempt]);
|
|
5035
5062
|
return readings;
|
|
5036
5063
|
}
|
|
5037
5064
|
function ActionRowPreview({
|
|
@@ -6048,14 +6075,17 @@ function useColumnSummaries(args) {
|
|
|
6048
6075
|
};
|
|
6049
6076
|
}, [client, tableId, chosenKey, filterKey, version]);
|
|
6050
6077
|
const asking = useRef8(false);
|
|
6051
|
-
const
|
|
6052
|
-
|
|
6078
|
+
const operationReads = useReadRefusal("agg_operations");
|
|
6079
|
+
const operationsAsked = useRef8(() => void 0);
|
|
6080
|
+
operationsAsked.current = (force) => {
|
|
6081
|
+
if (!force && operations !== null || asking.current) return;
|
|
6053
6082
|
asking.current = true;
|
|
6054
|
-
void client.aggOperations().then((answered) => {
|
|
6083
|
+
void askWithOneRetry(() => client.aggOperations()).then((answered) => {
|
|
6055
6084
|
asking.current = false;
|
|
6056
|
-
setOperations(answered.
|
|
6085
|
+
setOperations(operationReads.take(answered, () => operationsAsked.current(true)) ? answered.data ?? [] : []);
|
|
6057
6086
|
});
|
|
6058
|
-
}
|
|
6087
|
+
};
|
|
6088
|
+
const askOperations = useCallback10(() => operationsAsked.current(false), []);
|
|
6059
6089
|
return { values, withheld, rowCount, loading, error, operations, askOperations };
|
|
6060
6090
|
}
|
|
6061
6091
|
function withSummaryCells(columns, render) {
|
|
@@ -6822,6 +6852,8 @@ function useMergedGridControls(args) {
|
|
|
6822
6852
|
const choiceKeys = useMemo13(() => enabled ? fields.filter(isChoiceField).map((f) => f.key) : [], [enabled, fields]);
|
|
6823
6853
|
const choiceOptions = useChoiceOptions(fields, choiceKeys);
|
|
6824
6854
|
const searchWords = (args.search ?? "").trim();
|
|
6855
|
+
const countReads = useReadRefusal("value_counts");
|
|
6856
|
+
const [countAttempt, countAgain] = useReadAgain();
|
|
6825
6857
|
const countQuestionKey = JSON.stringify([choiceKeys, query.columnFilters, args.filter ?? null, searchWords]);
|
|
6826
6858
|
const rowsKey = rows.map((row) => `${row.id}:${row.version ?? ""}`).join(",");
|
|
6827
6859
|
const fieldsRef = useRef9(fields);
|
|
@@ -6844,7 +6876,7 @@ function useMergedGridControls(args) {
|
|
|
6844
6876
|
() => client.recordAggregate({ table_id: tableId, groupBy: [key], measures: [{ op: "count" }], ...asked2.filter ? { filter: asked2.filter } : {}, ...searched ? { search: searched } : {}, limit: 500 }),
|
|
6845
6877
|
VALUE_COUNTS_FRESH_MS
|
|
6846
6878
|
).then((answer) => {
|
|
6847
|
-
if (cancelled || !answer
|
|
6879
|
+
if (cancelled || !countReads.take(answer, countAgain)) return;
|
|
6848
6880
|
const counted = /* @__PURE__ */ new Map();
|
|
6849
6881
|
for (const row of answer.data ?? []) {
|
|
6850
6882
|
const value = row.groups?.[key];
|
|
@@ -6857,7 +6889,7 @@ function useMergedGridControls(args) {
|
|
|
6857
6889
|
return () => {
|
|
6858
6890
|
cancelled = true;
|
|
6859
6891
|
};
|
|
6860
|
-
}, [enabled, countQuestionKey, client, tableId, rowsKey]);
|
|
6892
|
+
}, [enabled, countQuestionKey, client, tableId, rowsKey, countAttempt]);
|
|
6861
6893
|
const filterFor = useCallback12(
|
|
6862
6894
|
(key) => {
|
|
6863
6895
|
if (!enabled) return void 0;
|
|
@@ -8504,14 +8536,16 @@ function useAddedRows(args) {
|
|
|
8504
8536
|
}, [pageKey, tableId]);
|
|
8505
8537
|
const pinnedKey = added.map((r) => r.id).join(",");
|
|
8506
8538
|
const asked2 = useRef12(0);
|
|
8539
|
+
const reads = useReadRefusal("list_by_ids");
|
|
8540
|
+
const [attempt, again] = useReadAgain();
|
|
8507
8541
|
useEffect22(() => {
|
|
8508
8542
|
if (!enabled || added.length === 0) return;
|
|
8509
8543
|
const onPage = new Set(pageRows.map((r) => r.id));
|
|
8510
8544
|
const missing = added.filter((r) => !onPage.has(r.id)).map((r) => r.id);
|
|
8511
8545
|
if (missing.length === 0) return;
|
|
8512
8546
|
const ticket = asked2.current += 1;
|
|
8513
|
-
void client.listByIds({ table_id: tableId, ids: missing }).then((answer) => {
|
|
8514
|
-
if (ticket !== asked2.current || !answer
|
|
8547
|
+
void askWithOneRetry(() => client.listByIds({ table_id: tableId, ids: missing })).then((answer) => {
|
|
8548
|
+
if (ticket !== asked2.current || !reads.take(answer, again)) return;
|
|
8515
8549
|
const fresh = new Map(answer.data.map((r) => [r.id, r]));
|
|
8516
8550
|
setAdded(
|
|
8517
8551
|
(held) => held.flatMap((row) => {
|
|
@@ -8521,7 +8555,7 @@ function useAddedRows(args) {
|
|
|
8521
8555
|
})
|
|
8522
8556
|
);
|
|
8523
8557
|
});
|
|
8524
|
-
}, [enabled, pageRows, pinnedKey, client, tableId]);
|
|
8558
|
+
}, [enabled, pageRows, pinnedKey, client, tableId, attempt]);
|
|
8525
8559
|
const rows = useMemo16(() => enabled ? placePinnedRows(pageRows, added, anchors) : pageRows, [enabled, pageRows, added, anchors]);
|
|
8526
8560
|
const pin = useCallback13((row, after) => {
|
|
8527
8561
|
setAdded((held) => held.some((r) => r.id === row.id) ? held : [...held, row]);
|
|
@@ -12278,17 +12312,19 @@ function useStructureHidden(tableId, level) {
|
|
|
12278
12312
|
const client = useRecordsClient33();
|
|
12279
12313
|
const asks = tableId !== null && mayHideStructure(level);
|
|
12280
12314
|
const [answer, setAnswer] = useState40(null);
|
|
12315
|
+
const reads = useReadRefusal("table_level_facts");
|
|
12316
|
+
const [attempt, again] = useReadAgain();
|
|
12281
12317
|
useEffect34(() => {
|
|
12282
12318
|
if (!asks || tableId === null) return;
|
|
12283
12319
|
let live = true;
|
|
12284
|
-
void client.tableLevelFacts({ table_id: tableId }).then((facts) => {
|
|
12320
|
+
void askWithOneRetry(() => client.tableLevelFacts({ table_id: tableId })).then((facts) => {
|
|
12285
12321
|
if (!live) return;
|
|
12286
|
-
setAnswer({ tableId, hidden: facts
|
|
12322
|
+
setAnswer({ tableId, hidden: reads.take(facts, again) && facts.data.structure_hidden === true });
|
|
12287
12323
|
});
|
|
12288
12324
|
return () => {
|
|
12289
12325
|
live = false;
|
|
12290
12326
|
};
|
|
12291
|
-
}, [client, tableId, asks]);
|
|
12327
|
+
}, [client, tableId, asks, attempt]);
|
|
12292
12328
|
if (!asks) return { settled: true, hidden: false };
|
|
12293
12329
|
const mine = answer !== null && answer.tableId === tableId ? answer : null;
|
|
12294
12330
|
return { settled: mine !== null, hidden: mine?.hidden ?? false };
|
|
@@ -24142,12 +24178,14 @@ function useLinkGroupNamer(block, tableId) {
|
|
|
24142
24178
|
const [named, setNamed] = useState74({});
|
|
24143
24179
|
const [choices, setChoices] = useState74([]);
|
|
24144
24180
|
const labels = useRecordLabels(choices);
|
|
24181
|
+
const reads = useReadRefusal("fields_and_relation_words");
|
|
24182
|
+
const [attempt, again] = useReadAgain();
|
|
24145
24183
|
useEffect65(() => {
|
|
24146
24184
|
if (!client || groupBy.length === 0 || rows.length === 0) return;
|
|
24147
24185
|
let cancelled = false;
|
|
24148
24186
|
void (async () => {
|
|
24149
|
-
const fields = await client.fields({ table_id: tableId });
|
|
24150
|
-
if (!fields
|
|
24187
|
+
const fields = await askWithOneRetry(() => client.fields({ table_id: tableId }));
|
|
24188
|
+
if (cancelled || !reads.take(fields, again)) return;
|
|
24151
24189
|
const grouped = groupBy.map((key) => fields.data.find((f) => f.key === key)).filter((f) => !!f && f.type === "list" && editorKindFor(f) !== "relation");
|
|
24152
24190
|
if (grouped.length > 0) setChoices(grouped);
|
|
24153
24191
|
const links = groupBy.map((key) => fields.data.find((f) => f.key === key)).filter((f) => !!f && editorKindFor(f) === "relation");
|
|
@@ -24159,17 +24197,20 @@ function useLinkGroupNamer(block, tableId) {
|
|
|
24159
24197
|
const v = r.groups?.[field.key];
|
|
24160
24198
|
return typeof v === "string" ? linkIdsOf(v) : [];
|
|
24161
24199
|
}))];
|
|
24162
|
-
if (ids.length === 0) return [field.key, { words: {}, done: true }];
|
|
24163
|
-
const words2 = await client.relationWordsMany({ field_id: field.id, record_ids: ids });
|
|
24164
|
-
return [field.key, { words: words2.ok ? words2.data : {}, done: true }];
|
|
24200
|
+
if (ids.length === 0) return [field.key, { ok: true, data: {} }, { words: {}, done: true }];
|
|
24201
|
+
const words2 = await askWithOneRetry(() => client.relationWordsMany({ field_id: field.id, record_ids: ids }));
|
|
24202
|
+
return [field.key, words2, { words: words2.ok ? words2.data : {}, done: true }];
|
|
24165
24203
|
})
|
|
24166
24204
|
);
|
|
24167
|
-
if (
|
|
24205
|
+
if (cancelled) return;
|
|
24206
|
+
const refused = answered.find(([, got]) => !got.ok);
|
|
24207
|
+
if (refused) reads.take(refused[1], again);
|
|
24208
|
+
setNamed(Object.fromEntries(answered.map(([key, , column]) => [key, column])));
|
|
24168
24209
|
})();
|
|
24169
24210
|
return () => {
|
|
24170
24211
|
cancelled = true;
|
|
24171
24212
|
};
|
|
24172
|
-
}, [client, ask2]);
|
|
24213
|
+
}, [client, ask2, attempt]);
|
|
24173
24214
|
return useMemo46(() => {
|
|
24174
24215
|
if (Object.keys(named).length === 0 && choices.length === 0) return void 0;
|
|
24175
24216
|
return (key, value) => {
|
|
@@ -26376,6 +26417,8 @@ function useFarFields(all) {
|
|
|
26376
26417
|
const client = useRecordsClient63();
|
|
26377
26418
|
const targets = lookupTargets(all).sort().join(",");
|
|
26378
26419
|
const [far, setFar] = useState81(() => /* @__PURE__ */ new Map());
|
|
26420
|
+
const reads = useReadRefusal("fields");
|
|
26421
|
+
const [attempt, again] = useReadAgain();
|
|
26379
26422
|
useEffect72(() => {
|
|
26380
26423
|
let cancelled = false;
|
|
26381
26424
|
const ids = targets ? targets.split(",") : [];
|
|
@@ -26383,14 +26426,17 @@ function useFarFields(all) {
|
|
|
26383
26426
|
setFar(/* @__PURE__ */ new Map());
|
|
26384
26427
|
return;
|
|
26385
26428
|
}
|
|
26386
|
-
void Promise.all(ids.map(async (id) => [id, await client.fields({ table_id: id })])).then((answers) => {
|
|
26429
|
+
void Promise.all(ids.map(async (id) => [id, await askWithOneRetry(() => client.fields({ table_id: id }))])).then((answers) => {
|
|
26387
26430
|
if (cancelled) return;
|
|
26431
|
+
const refused = answers.find(([, r]) => !r.ok);
|
|
26432
|
+
if (refused) reads.take(refused[1], again);
|
|
26433
|
+
else reads.take({ ok: true, data: null }, again);
|
|
26388
26434
|
setFar(new Map(answers.flatMap(([id, r]) => r.ok ? [[id, r.data]] : [])));
|
|
26389
26435
|
});
|
|
26390
26436
|
return () => {
|
|
26391
26437
|
cancelled = true;
|
|
26392
26438
|
};
|
|
26393
|
-
}, [client, targets]);
|
|
26439
|
+
}, [client, targets, attempt]);
|
|
26394
26440
|
return far;
|
|
26395
26441
|
}
|
|
26396
26442
|
function offerableFields(all, want, placing) {
|
|
@@ -26415,17 +26461,20 @@ function useStageField(tableId) {
|
|
|
26415
26461
|
asked: false,
|
|
26416
26462
|
key: null
|
|
26417
26463
|
});
|
|
26464
|
+
const reads = useReadRefusal("table_stage_field");
|
|
26465
|
+
const [attempt, again] = useReadAgain();
|
|
26418
26466
|
useEffect72(() => {
|
|
26419
26467
|
let cancelled = false;
|
|
26420
26468
|
setStage({ asked: false, key: null });
|
|
26421
|
-
void client.tableStageField({ table_id: tableId }).then((r) => {
|
|
26469
|
+
void askWithOneRetry(() => client.tableStageField({ table_id: tableId })).then((r) => {
|
|
26422
26470
|
if (cancelled) return;
|
|
26423
|
-
|
|
26471
|
+
if (!reads.take(r, again)) return;
|
|
26472
|
+
setStage({ asked: true, key: r.data ?? null });
|
|
26424
26473
|
});
|
|
26425
26474
|
return () => {
|
|
26426
26475
|
cancelled = true;
|
|
26427
26476
|
};
|
|
26428
|
-
}, [client, tableId]);
|
|
26477
|
+
}, [client, tableId, attempt]);
|
|
26429
26478
|
return stage;
|
|
26430
26479
|
}
|
|
26431
26480
|
function boardColumnChoice(fields, chosenKey, stage) {
|
|
@@ -32002,6 +32051,24 @@ function FormRunner(props) {
|
|
|
32002
32051
|
}
|
|
32003
32052
|
return /* @__PURE__ */ jsx105(ConnectedFormRunner, { ...props });
|
|
32004
32053
|
}
|
|
32054
|
+
var SEND_CEILING_MS = 6e4;
|
|
32055
|
+
async function sendWithin(send, values, ceilingMs) {
|
|
32056
|
+
const notLanded = (why) => ({
|
|
32057
|
+
ok: false,
|
|
32058
|
+
message: `This answer did not land: ${why} Your answers are still here; pressing send again is safe.`
|
|
32059
|
+
});
|
|
32060
|
+
let timer;
|
|
32061
|
+
const ceiling = new Promise((resolve) => {
|
|
32062
|
+
timer = setTimeout(() => resolve(notLanded("it took too long to get an answer.")), ceilingMs);
|
|
32063
|
+
});
|
|
32064
|
+
try {
|
|
32065
|
+
return await Promise.race([send(values), ceiling]);
|
|
32066
|
+
} catch {
|
|
32067
|
+
return notLanded("the send failed before it was answered.");
|
|
32068
|
+
} finally {
|
|
32069
|
+
if (timer) clearTimeout(timer);
|
|
32070
|
+
}
|
|
32071
|
+
}
|
|
32005
32072
|
function ConnectedFormRunner(props) {
|
|
32006
32073
|
const client = useOptionalRecordsClient9();
|
|
32007
32074
|
const fields = useFields24(props.form.subject);
|
|
@@ -32229,7 +32296,7 @@ function FormStage({
|
|
|
32229
32296
|
live.map((q) => [q.key, answers[q.key] ?? null])
|
|
32230
32297
|
);
|
|
32231
32298
|
if (honeypotKey) values[honeypotKey] = decoy.current;
|
|
32232
|
-
const outcome = await onSubmit
|
|
32299
|
+
const outcome = await sendWithin(onSubmit, values, SEND_CEILING_MS);
|
|
32233
32300
|
setWriting(false);
|
|
32234
32301
|
if (!outcome.ok) {
|
|
32235
32302
|
const inWords = (text) => questions.reduce(
|
|
@@ -36332,20 +36399,25 @@ function useNames(tableId, ids) {
|
|
|
36332
36399
|
const [names, setNames] = useState103({});
|
|
36333
36400
|
const titleField = table.data?.title_field ?? null;
|
|
36334
36401
|
const key = ids.join("|");
|
|
36402
|
+
const reads = useReadRefusal("record_read");
|
|
36403
|
+
const [attempt, again] = useReadAgain();
|
|
36335
36404
|
useEffect92(() => {
|
|
36336
36405
|
let live = true;
|
|
36337
|
-
void Promise.all(
|
|
36338
|
-
|
|
36339
|
-
|
|
36340
|
-
|
|
36341
|
-
})
|
|
36342
|
-
|
|
36343
|
-
|
|
36406
|
+
void Promise.all(ids.map(async (id) => [id, await askWithOneRetry(() => client.recordRead({ record_id: id }))])).then((pairs) => {
|
|
36407
|
+
if (!live) return;
|
|
36408
|
+
const refused = pairs.find(([, got]) => !got.ok);
|
|
36409
|
+
if (refused) reads.take(refused[1], again);
|
|
36410
|
+
else reads.take({ ok: true, data: null }, again);
|
|
36411
|
+
setNames(
|
|
36412
|
+
Object.fromEntries(
|
|
36413
|
+
pairs.flatMap(([id, got]) => got.ok ? [[id, recordName(got.data.document, titleField, "Untitled")]] : [])
|
|
36414
|
+
)
|
|
36415
|
+
);
|
|
36344
36416
|
});
|
|
36345
36417
|
return () => {
|
|
36346
36418
|
live = false;
|
|
36347
36419
|
};
|
|
36348
|
-
}, [client, key, titleField]);
|
|
36420
|
+
}, [client, key, titleField, attempt]);
|
|
36349
36421
|
return names;
|
|
36350
36422
|
}
|
|
36351
36423
|
function AgentAnswer({
|
|
@@ -36521,7 +36593,13 @@ function CsvButton({ name, fields, rows }) {
|
|
|
36521
36593
|
function sameRows(had, rows) {
|
|
36522
36594
|
return had === rows || had !== void 0 && had.length === 0 && rows.length === 0;
|
|
36523
36595
|
}
|
|
36524
|
-
function PageCanvas(
|
|
36596
|
+
function PageCanvas(props) {
|
|
36597
|
+
return /* @__PURE__ */ jsxs108(Fragment50, { children: [
|
|
36598
|
+
/* @__PURE__ */ jsx115(PageCanvasBody, { ...props }),
|
|
36599
|
+
/* @__PURE__ */ jsx115(ReadRefusalDock, {})
|
|
36600
|
+
] });
|
|
36601
|
+
}
|
|
36602
|
+
function PageCanvasBody({ blocks, charts, run, subject, viewerUserId, editing, canEdit, onSave, onChart }) {
|
|
36525
36603
|
const [selected, setSelected] = useState104({});
|
|
36526
36604
|
const [listRows, setListRows] = useState104({});
|
|
36527
36605
|
const [filterValues, setFilterValues] = useState104({});
|
|
@@ -36600,6 +36678,10 @@ function useMemberQuestion(block, viewerUserId, extra, mineOn, enabled = true) {
|
|
|
36600
36678
|
const fields = useFields31(enabled ? block.table_id : null);
|
|
36601
36679
|
const all = useMemo64(() => onePerKey3(fields.data ?? []), [fields.data]);
|
|
36602
36680
|
const [view, setView] = useState104(block.view_id ? "reading" : null);
|
|
36681
|
+
const viewReads = useReadRefusal("views");
|
|
36682
|
+
const [viewAttempt, viewAgain] = useReadAgain();
|
|
36683
|
+
const meReads = useReadRefusal("me_record");
|
|
36684
|
+
const [meAttempt, meAgain] = useReadAgain();
|
|
36603
36685
|
useEffect93(() => {
|
|
36604
36686
|
if (!block.view_id || !enabled) {
|
|
36605
36687
|
setView(null);
|
|
@@ -36607,15 +36689,16 @@ function useMemberQuestion(block, viewerUserId, extra, mineOn, enabled = true) {
|
|
|
36607
36689
|
}
|
|
36608
36690
|
let live = true;
|
|
36609
36691
|
setView("reading");
|
|
36610
|
-
void client.views({ table_id: block.table_id }).then((answered) => {
|
|
36692
|
+
void askWithOneRetry(() => client.views({ table_id: block.table_id })).then((answered) => {
|
|
36611
36693
|
if (!live) return;
|
|
36612
|
-
|
|
36694
|
+
if (!viewReads.take(answered, viewAgain)) return setView(null);
|
|
36695
|
+
const row = answered.data.find((v) => v.view_id === block.view_id);
|
|
36613
36696
|
setView(row ? viewFromRow(row) : null);
|
|
36614
36697
|
});
|
|
36615
36698
|
return () => {
|
|
36616
36699
|
live = false;
|
|
36617
36700
|
};
|
|
36618
|
-
}, [client, block.table_id, block.view_id, enabled]);
|
|
36701
|
+
}, [client, block.table_id, block.view_id, enabled, viewAttempt]);
|
|
36619
36702
|
const mine = mineOn || block.me_only === true;
|
|
36620
36703
|
const meField = block.me_field ? all.find((f) => f.key === block.me_field) : void 0;
|
|
36621
36704
|
const [me, setMe] = useState104(null);
|
|
@@ -36626,13 +36709,14 @@ function useMemberQuestion(block, viewerUserId, extra, mineOn, enabled = true) {
|
|
|
36626
36709
|
}
|
|
36627
36710
|
let live = true;
|
|
36628
36711
|
setMe("reading");
|
|
36629
|
-
void client.list({ table_id: meField.relation_target, filter: { user_id: viewerUserId }, limit: 1 }).then((answered) => {
|
|
36630
|
-
if (live)
|
|
36712
|
+
void askWithOneRetry(() => client.list({ table_id: meField.relation_target, filter: { user_id: viewerUserId }, limit: 1 })).then((answered) => {
|
|
36713
|
+
if (!live) return;
|
|
36714
|
+
setMe({ id: meReads.take(answered, meAgain) ? answered.data.rows[0]?.id ?? null : null });
|
|
36631
36715
|
});
|
|
36632
36716
|
return () => {
|
|
36633
36717
|
live = false;
|
|
36634
36718
|
};
|
|
36635
|
-
}, [client, enabled, mine, meField?.relation_target, viewerUserId]);
|
|
36719
|
+
}, [client, enabled, mine, meField?.relation_target, viewerUserId, meAttempt]);
|
|
36636
36720
|
const own = {
|
|
36637
36721
|
...Object.fromEntries(Object.entries(block.filter ?? {}).filter(([, v]) => v !== null && v !== void 0)),
|
|
36638
36722
|
...extra
|
|
@@ -41980,7 +42064,8 @@ function TablePage({
|
|
|
41980
42064
|
) : null
|
|
41981
42065
|
] })
|
|
41982
42066
|
] }),
|
|
41983
|
-
embedded ? null : /* @__PURE__ */ jsx132(GridShortcutsHelp, {})
|
|
42067
|
+
embedded ? null : /* @__PURE__ */ jsx132(GridShortcutsHelp, {}),
|
|
42068
|
+
/* @__PURE__ */ jsx132(ReadRefusalDock, {})
|
|
41984
42069
|
] });
|
|
41985
42070
|
}
|
|
41986
42071
|
var PUBLIC_READ_ONLY = "Public \xB7 read only";
|
|
@@ -41988,6 +42073,8 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
|
|
|
41988
42073
|
const readOnly = rights.known && rights.read && !rights.write;
|
|
41989
42074
|
const marked = table?.published_to_web;
|
|
41990
42075
|
const [isPublic, setIsPublic] = useState121(false);
|
|
42076
|
+
const reads = useReadRefusal("table_facts");
|
|
42077
|
+
const [attempt, again] = useReadAgain();
|
|
41991
42078
|
useEffect106(() => {
|
|
41992
42079
|
if (!readOnly || !table) {
|
|
41993
42080
|
setIsPublic(false);
|
|
@@ -41998,15 +42085,16 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
|
|
|
41998
42085
|
return;
|
|
41999
42086
|
}
|
|
42000
42087
|
let live = true;
|
|
42001
|
-
void client.tableFacts(organizationId ? { organization_id: organizationId } : {}).then((answered) => {
|
|
42088
|
+
void askWithOneRetry(() => client.tableFacts(organizationId ? { organization_id: organizationId } : {})).then((answered) => {
|
|
42002
42089
|
if (!live) return;
|
|
42003
|
-
|
|
42090
|
+
if (!reads.take(answered, again)) return;
|
|
42091
|
+
const fact = (answered.data ?? []).find((f) => f.table_id === tableId);
|
|
42004
42092
|
setIsPublic(Boolean(fact && (fact.published_to_web ?? fact.visibility === "public")));
|
|
42005
42093
|
});
|
|
42006
42094
|
return () => {
|
|
42007
42095
|
live = false;
|
|
42008
42096
|
};
|
|
42009
|
-
}, [client, organizationId, tableId, readOnly, marked, table]);
|
|
42097
|
+
}, [client, organizationId, tableId, readOnly, marked, table, attempt]);
|
|
42010
42098
|
return readOnly && isPublic;
|
|
42011
42099
|
}
|
|
42012
42100
|
|