@lotics/app-sdk 0.133.45 → 0.133.48
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/AGENTS.md +1 -1
- package/dist/{chunk-WW2P5AH3.js → chunk-NS3BIL73.js} +28 -4
- package/dist/index.js +309 -149
- package/dist/queries.d.ts +13 -0
- package/dist/router.js +1 -1
- package/dist/rpc.d.ts +7 -3
- package/dist/shared_types.d.ts +2 -2
- package/dist/store.d.ts +10 -2
- package/dist/viewer.d.ts +2 -0
- package/docs/data_fetching.md +6 -4
- package/docs/members_and_options.md +5 -1
- package/docs/queries.md +8 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
subtractDecimal,
|
|
63
63
|
sumDecimal,
|
|
64
64
|
urlParam
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-NS3BIL73.js";
|
|
66
66
|
|
|
67
67
|
// src/mount.tsx
|
|
68
68
|
import { createRoot } from "react-dom/client";
|
|
@@ -571,10 +571,11 @@ function release(paint, slot) {
|
|
|
571
571
|
paint.waiting.delete(slot);
|
|
572
572
|
if (paint.waiting.size === 0) draw(paint);
|
|
573
573
|
}
|
|
574
|
-
function slotOf(key, fetcher, aliases) {
|
|
574
|
+
function slotOf(key, fetcher, aliases, patcher = null) {
|
|
575
575
|
const held2 = slots.get(key);
|
|
576
576
|
if (held2 !== void 0) {
|
|
577
577
|
held2.fetcher = fetcher;
|
|
578
|
+
held2.patcher = patcher;
|
|
578
579
|
held2.aliases = aliases;
|
|
579
580
|
return held2;
|
|
580
581
|
}
|
|
@@ -588,6 +589,7 @@ function slotOf(key, fetcher, aliases) {
|
|
|
588
589
|
paint: null,
|
|
589
590
|
stagings: [],
|
|
590
591
|
fetcher,
|
|
592
|
+
patcher,
|
|
591
593
|
aliases,
|
|
592
594
|
mounts: /* @__PURE__ */ new Map(),
|
|
593
595
|
listeners: /* @__PURE__ */ new Set(),
|
|
@@ -605,7 +607,7 @@ function tick() {
|
|
|
605
607
|
clock += 1;
|
|
606
608
|
return clock;
|
|
607
609
|
}
|
|
608
|
-
function ask(slot, fresh) {
|
|
610
|
+
function ask(slot, fresh, patch) {
|
|
609
611
|
if (slot.inflight !== null) {
|
|
610
612
|
if (fresh) slot.stale = true;
|
|
611
613
|
return slot.inflight;
|
|
@@ -636,7 +638,7 @@ function ask(slot, fresh) {
|
|
|
636
638
|
release(paint, slot);
|
|
637
639
|
});
|
|
638
640
|
};
|
|
639
|
-
const inflight = slot.fetcher(askedAt, slot.answer).then(
|
|
641
|
+
const inflight = (patch ?? slot.fetcher)(askedAt, slot.answer).then(
|
|
640
642
|
(answer) => settle2(() => {
|
|
641
643
|
if (askedAt >= slot.askedAt) {
|
|
642
644
|
slot.answer = answer;
|
|
@@ -663,17 +665,17 @@ function readNow(aliases) {
|
|
|
663
665
|
function refetchReads(aliases) {
|
|
664
666
|
for (const slot of readNow(aliases)) void ask(slot, true);
|
|
665
667
|
}
|
|
666
|
-
function askInOnePaint(read2) {
|
|
668
|
+
function askInOnePaint(read2, changes) {
|
|
667
669
|
if (read2.length === 0) return;
|
|
668
670
|
const paint = { waiting: new Set(read2), held: [], drawn: false, cap: setTimeout(() => draw(paint), PAINT_CAP_MS) };
|
|
669
671
|
for (const slot of read2) {
|
|
670
672
|
if (slot.paint !== null) release(slot.paint, slot);
|
|
671
673
|
slot.paint = paint;
|
|
672
674
|
}
|
|
673
|
-
for (const slot of read2) void ask(slot, true);
|
|
675
|
+
for (const slot of read2) void ask(slot, true, changes === void 0 || slot.error !== null ? void 0 : slot.patcher?.(slot.answer, changes, slot.askedAt) ?? void 0);
|
|
674
676
|
}
|
|
675
|
-
function refetchPushed(aliases) {
|
|
676
|
-
askInOnePaint(readNow(aliases));
|
|
677
|
+
function refetchPushed(aliases, changes) {
|
|
678
|
+
askInOnePaint(readNow(aliases), changes);
|
|
677
679
|
}
|
|
678
680
|
var listening = false;
|
|
679
681
|
function listen() {
|
|
@@ -704,7 +706,7 @@ function useKey(key, fetcher, opts = {}) {
|
|
|
704
706
|
const focus = opts.focus ?? true;
|
|
705
707
|
const arrival = opts.arrival ?? true;
|
|
706
708
|
const aliases = opts.aliases === void 0 ? NO_ALIASES : new Set(opts.aliases);
|
|
707
|
-
const slot = key === null ? null : slotOf(key, fetcher, aliases);
|
|
709
|
+
const slot = key === null ? null : slotOf(key, fetcher, aliases, opts.patch ?? null);
|
|
708
710
|
const mounted = useRef(null);
|
|
709
711
|
if (mounted.current === null || mounted.current.key !== key) mounted.current = { key, at: clock };
|
|
710
712
|
const mountedAt = mounted.current.at;
|
|
@@ -827,6 +829,37 @@ function setKey(key, answer) {
|
|
|
827
829
|
// src/written.ts
|
|
828
830
|
import { useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
829
831
|
|
|
832
|
+
// ../shared/src/cut_list.ts
|
|
833
|
+
var CutListError = class extends Error {
|
|
834
|
+
constructor(lookup, matched, read2, asked) {
|
|
835
|
+
super(`${asked} reads every row of lookups.${lookup}, which matched ${matched} rows and read ${read2}`);
|
|
836
|
+
this.lookup = lookup;
|
|
837
|
+
this.matched = matched;
|
|
838
|
+
this.read = read2;
|
|
839
|
+
this.asked = asked;
|
|
840
|
+
this.name = "CutListError";
|
|
841
|
+
}
|
|
842
|
+
lookup;
|
|
843
|
+
matched;
|
|
844
|
+
read;
|
|
845
|
+
asked;
|
|
846
|
+
};
|
|
847
|
+
var CUT_LIST_HELPERS = /* @__PURE__ */ new Map([
|
|
848
|
+
["size", "length"],
|
|
849
|
+
["length", "length"],
|
|
850
|
+
["first", "prefix"],
|
|
851
|
+
["requireFirst", "prefix"],
|
|
852
|
+
["isEmpty", "emptiness"],
|
|
853
|
+
["isNull", "emptiness"],
|
|
854
|
+
["isNotNull", "emptiness"]
|
|
855
|
+
]);
|
|
856
|
+
function refuseCut(lists, asked, ...values2) {
|
|
857
|
+
for (const value of values2) {
|
|
858
|
+
const cut = lists.within(value);
|
|
859
|
+
if (cut !== void 0) throw new CutListError(cut.lookup, cut.matched, cut.read, asked);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
830
863
|
// ../shared/src/schemas/select_options.ts
|
|
831
864
|
function selectOptionsOf(field) {
|
|
832
865
|
if (field.type === "select") return field.options;
|
|
@@ -6356,123 +6389,6 @@ var TZDate = class _TZDate extends TZDateMini {
|
|
|
6356
6389
|
//#endregion
|
|
6357
6390
|
};
|
|
6358
6391
|
|
|
6359
|
-
// ../shared/src/cadence_rows.ts
|
|
6360
|
-
var MAX_DATES_ON_DAYS = 3660;
|
|
6361
|
-
var CadenceDayError = class extends Error {
|
|
6362
|
-
constructor(message2) {
|
|
6363
|
-
super(message2);
|
|
6364
|
-
this.name = "CadenceDayError";
|
|
6365
|
-
}
|
|
6366
|
-
};
|
|
6367
|
-
var DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
6368
|
-
var MS_PER_DAY = 864e5;
|
|
6369
|
-
function dayMs(day) {
|
|
6370
|
-
const ms = DAY.test(day) ? Date.parse(`${day}T00:00:00Z`) : Number.NaN;
|
|
6371
|
-
if (Number.isNaN(ms)) throw new CadenceDayError(`"${day}" is no day: a day is written yyyy-MM-dd`);
|
|
6372
|
-
return ms;
|
|
6373
|
-
}
|
|
6374
|
-
var dayOf = (ms) => new Date(ms).toISOString().slice(0, 10);
|
|
6375
|
-
function weekdayOf(ms) {
|
|
6376
|
-
const day = WEEKDAYS[(new Date(ms).getUTCDay() + 6) % 7];
|
|
6377
|
-
if (day === void 0) throw new CadenceDayError(`"${dayOf(ms)}" has no weekday`);
|
|
6378
|
-
return day;
|
|
6379
|
-
}
|
|
6380
|
-
function overlong(from, until) {
|
|
6381
|
-
const length2 = (dayMs(until) - dayMs(from)) / MS_PER_DAY + 1;
|
|
6382
|
-
return length2 > MAX_DATES_ON_DAYS ? `${from} to ${until} is ${length2} days; list at most ${MAX_DATES_ON_DAYS}` : void 0;
|
|
6383
|
-
}
|
|
6384
|
-
function datesOn(from, until, days) {
|
|
6385
|
-
for (const named of days) {
|
|
6386
|
-
if (!WEEKDAYS.some((weekday) => weekday === named)) throw new CadenceDayError(`"${named}" is no weekday: use ${WEEKDAYS.join(", ")}`);
|
|
6387
|
-
}
|
|
6388
|
-
const first2 = dayMs(from);
|
|
6389
|
-
const last2 = dayMs(until);
|
|
6390
|
-
if (last2 < first2) return [];
|
|
6391
|
-
const tooLong = overlong(from, until);
|
|
6392
|
-
if (tooLong !== void 0) throw new CadenceDayError(tooLong);
|
|
6393
|
-
const length2 = (last2 - first2) / MS_PER_DAY + 1;
|
|
6394
|
-
return Array.from({ length: length2 }, (_, at2) => first2 + at2 * MS_PER_DAY).filter((ms) => days.includes(weekdayOf(ms))).map(dayOf);
|
|
6395
|
-
}
|
|
6396
|
-
|
|
6397
|
-
// ../shared/src/format_date.ts
|
|
6398
|
-
var ISO_YEAR = /^(\d{4})$/;
|
|
6399
|
-
var ISO_YEAR_MONTH = /^(\d{4})-(\d{2})$/;
|
|
6400
|
-
var ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/;
|
|
6401
|
-
var ISO_INSTANT = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)$/i;
|
|
6402
|
-
function writtenParts(s) {
|
|
6403
|
-
const y = ISO_YEAR.exec(s);
|
|
6404
|
-
if (y) return { year: Number(y[1]), month: 0, day: 1, hour: 0, minute: 0, second: 0, precision: "year" };
|
|
6405
|
-
const ym = ISO_YEAR_MONTH.exec(s);
|
|
6406
|
-
if (ym) return { year: Number(ym[1]), month: Number(ym[2]) - 1, day: 1, hour: 0, minute: 0, second: 0, precision: "month" };
|
|
6407
|
-
const m = ISO_DATE_TIME.exec(s);
|
|
6408
|
-
if (!m) return null;
|
|
6409
|
-
return {
|
|
6410
|
-
year: Number(m[1]),
|
|
6411
|
-
month: Number(m[2]) - 1,
|
|
6412
|
-
day: Number(m[3]),
|
|
6413
|
-
hour: Number(m[4] ?? 0),
|
|
6414
|
-
minute: Number(m[5] ?? 0),
|
|
6415
|
-
second: Number(m[6] ?? 0),
|
|
6416
|
-
precision: "day"
|
|
6417
|
-
};
|
|
6418
|
-
}
|
|
6419
|
-
function localParts(date2) {
|
|
6420
|
-
return {
|
|
6421
|
-
year: date2.getFullYear(),
|
|
6422
|
-
month: date2.getMonth(),
|
|
6423
|
-
day: date2.getDate(),
|
|
6424
|
-
hour: date2.getHours(),
|
|
6425
|
-
minute: date2.getMinutes(),
|
|
6426
|
-
second: date2.getSeconds(),
|
|
6427
|
-
precision: "day"
|
|
6428
|
-
};
|
|
6429
|
-
}
|
|
6430
|
-
function zoneClock(zone) {
|
|
6431
|
-
let clock2 = zoneClocks.get(zone);
|
|
6432
|
-
if (clock2 === void 0) {
|
|
6433
|
-
clock2 = new Intl.DateTimeFormat("en-US", {
|
|
6434
|
-
timeZone: zone,
|
|
6435
|
-
hourCycle: "h23",
|
|
6436
|
-
year: "numeric",
|
|
6437
|
-
month: "numeric",
|
|
6438
|
-
day: "numeric",
|
|
6439
|
-
hour: "numeric",
|
|
6440
|
-
minute: "numeric",
|
|
6441
|
-
second: "numeric"
|
|
6442
|
-
});
|
|
6443
|
-
zoneClocks.set(zone, clock2);
|
|
6444
|
-
}
|
|
6445
|
-
return clock2;
|
|
6446
|
-
}
|
|
6447
|
-
var zoneClocks = /* @__PURE__ */ new Map();
|
|
6448
|
-
function zonedParts(instant, zone) {
|
|
6449
|
-
const parts = zoneClock(zone).formatToParts(instant);
|
|
6450
|
-
const part = (type) => Number(parts.find((p) => p.type === type)?.value);
|
|
6451
|
-
return {
|
|
6452
|
-
year: part("year"),
|
|
6453
|
-
month: part("month") - 1,
|
|
6454
|
-
day: part("day"),
|
|
6455
|
-
hour: part("hour"),
|
|
6456
|
-
minute: part("minute"),
|
|
6457
|
-
second: part("second"),
|
|
6458
|
-
precision: "day"
|
|
6459
|
-
};
|
|
6460
|
-
}
|
|
6461
|
-
function readWallClock(value, zone) {
|
|
6462
|
-
if (value == null) return null;
|
|
6463
|
-
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : localParts(value);
|
|
6464
|
-
const s = value.trim();
|
|
6465
|
-
if (!s) return null;
|
|
6466
|
-
const written = writtenParts(s);
|
|
6467
|
-
if (written) return written;
|
|
6468
|
-
const native = new Date(s);
|
|
6469
|
-
if (Number.isNaN(native.getTime())) return null;
|
|
6470
|
-
return zone !== void 0 && ISO_INSTANT.test(s) ? zonedParts(native, zone) : localParts(native);
|
|
6471
|
-
}
|
|
6472
|
-
function datePrecision(value) {
|
|
6473
|
-
return readWallClock(value, void 0)?.precision ?? null;
|
|
6474
|
-
}
|
|
6475
|
-
|
|
6476
6392
|
// ../shared/src/date_string_helpers.ts
|
|
6477
6393
|
function parseDate2(dateStr) {
|
|
6478
6394
|
if (dateStr.includes("T")) {
|
|
@@ -6981,6 +6897,123 @@ function matchesTimeOfDay(recordValue, startTime, endTime) {
|
|
|
6981
6897
|
return isInTimeRange(recordValue, startTime, endTime);
|
|
6982
6898
|
}
|
|
6983
6899
|
|
|
6900
|
+
// ../shared/src/cadence_rows.ts
|
|
6901
|
+
var MAX_DATES_ON_DAYS = 3660;
|
|
6902
|
+
var CadenceDayError = class extends Error {
|
|
6903
|
+
constructor(message2) {
|
|
6904
|
+
super(message2);
|
|
6905
|
+
this.name = "CadenceDayError";
|
|
6906
|
+
}
|
|
6907
|
+
};
|
|
6908
|
+
var DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
6909
|
+
var MS_PER_DAY = 864e5;
|
|
6910
|
+
function dayMs(day) {
|
|
6911
|
+
const ms = DAY.test(day) ? Date.parse(`${day}T00:00:00Z`) : Number.NaN;
|
|
6912
|
+
if (Number.isNaN(ms)) throw new CadenceDayError(`"${day}" is no day: a day is written yyyy-MM-dd`);
|
|
6913
|
+
return ms;
|
|
6914
|
+
}
|
|
6915
|
+
var dayOf = (ms) => new Date(ms).toISOString().slice(0, 10);
|
|
6916
|
+
function weekdayOf(ms) {
|
|
6917
|
+
const day = WEEKDAYS[(new Date(ms).getUTCDay() + 6) % 7];
|
|
6918
|
+
if (day === void 0) throw new CadenceDayError(`"${dayOf(ms)}" has no weekday`);
|
|
6919
|
+
return day;
|
|
6920
|
+
}
|
|
6921
|
+
function overlong(from, until) {
|
|
6922
|
+
const length2 = (dayMs(until) - dayMs(from)) / MS_PER_DAY + 1;
|
|
6923
|
+
return length2 > MAX_DATES_ON_DAYS ? `${from} to ${until} is ${length2} days; list at most ${MAX_DATES_ON_DAYS}` : void 0;
|
|
6924
|
+
}
|
|
6925
|
+
function datesOn(from, until, days) {
|
|
6926
|
+
for (const named of days) {
|
|
6927
|
+
if (!WEEKDAYS.some((weekday) => weekday === named)) throw new CadenceDayError(`"${named}" is no weekday: use ${WEEKDAYS.join(", ")}`);
|
|
6928
|
+
}
|
|
6929
|
+
const first2 = dayMs(from);
|
|
6930
|
+
const last2 = dayMs(until);
|
|
6931
|
+
if (last2 < first2) return [];
|
|
6932
|
+
const tooLong = overlong(from, until);
|
|
6933
|
+
if (tooLong !== void 0) throw new CadenceDayError(tooLong);
|
|
6934
|
+
const length2 = (last2 - first2) / MS_PER_DAY + 1;
|
|
6935
|
+
return Array.from({ length: length2 }, (_, at2) => first2 + at2 * MS_PER_DAY).filter((ms) => days.includes(weekdayOf(ms))).map(dayOf);
|
|
6936
|
+
}
|
|
6937
|
+
|
|
6938
|
+
// ../shared/src/format_date.ts
|
|
6939
|
+
var ISO_YEAR = /^(\d{4})$/;
|
|
6940
|
+
var ISO_YEAR_MONTH = /^(\d{4})-(\d{2})$/;
|
|
6941
|
+
var ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/;
|
|
6942
|
+
var ISO_INSTANT = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)$/i;
|
|
6943
|
+
function writtenParts(s) {
|
|
6944
|
+
const y = ISO_YEAR.exec(s);
|
|
6945
|
+
if (y) return { year: Number(y[1]), month: 0, day: 1, hour: 0, minute: 0, second: 0, precision: "year" };
|
|
6946
|
+
const ym = ISO_YEAR_MONTH.exec(s);
|
|
6947
|
+
if (ym) return { year: Number(ym[1]), month: Number(ym[2]) - 1, day: 1, hour: 0, minute: 0, second: 0, precision: "month" };
|
|
6948
|
+
const m = ISO_DATE_TIME.exec(s);
|
|
6949
|
+
if (!m) return null;
|
|
6950
|
+
return {
|
|
6951
|
+
year: Number(m[1]),
|
|
6952
|
+
month: Number(m[2]) - 1,
|
|
6953
|
+
day: Number(m[3]),
|
|
6954
|
+
hour: Number(m[4] ?? 0),
|
|
6955
|
+
minute: Number(m[5] ?? 0),
|
|
6956
|
+
second: Number(m[6] ?? 0),
|
|
6957
|
+
precision: "day"
|
|
6958
|
+
};
|
|
6959
|
+
}
|
|
6960
|
+
function localParts(date2) {
|
|
6961
|
+
return {
|
|
6962
|
+
year: date2.getFullYear(),
|
|
6963
|
+
month: date2.getMonth(),
|
|
6964
|
+
day: date2.getDate(),
|
|
6965
|
+
hour: date2.getHours(),
|
|
6966
|
+
minute: date2.getMinutes(),
|
|
6967
|
+
second: date2.getSeconds(),
|
|
6968
|
+
precision: "day"
|
|
6969
|
+
};
|
|
6970
|
+
}
|
|
6971
|
+
function zoneClock(zone) {
|
|
6972
|
+
let clock2 = zoneClocks.get(zone);
|
|
6973
|
+
if (clock2 === void 0) {
|
|
6974
|
+
clock2 = new Intl.DateTimeFormat("en-US", {
|
|
6975
|
+
timeZone: zone,
|
|
6976
|
+
hourCycle: "h23",
|
|
6977
|
+
year: "numeric",
|
|
6978
|
+
month: "numeric",
|
|
6979
|
+
day: "numeric",
|
|
6980
|
+
hour: "numeric",
|
|
6981
|
+
minute: "numeric",
|
|
6982
|
+
second: "numeric"
|
|
6983
|
+
});
|
|
6984
|
+
zoneClocks.set(zone, clock2);
|
|
6985
|
+
}
|
|
6986
|
+
return clock2;
|
|
6987
|
+
}
|
|
6988
|
+
var zoneClocks = /* @__PURE__ */ new Map();
|
|
6989
|
+
function zonedParts(instant, zone) {
|
|
6990
|
+
const parts = zoneClock(zone).formatToParts(instant);
|
|
6991
|
+
const part = (type) => Number(parts.find((p) => p.type === type)?.value);
|
|
6992
|
+
return {
|
|
6993
|
+
year: part("year"),
|
|
6994
|
+
month: part("month") - 1,
|
|
6995
|
+
day: part("day"),
|
|
6996
|
+
hour: part("hour"),
|
|
6997
|
+
minute: part("minute"),
|
|
6998
|
+
second: part("second"),
|
|
6999
|
+
precision: "day"
|
|
7000
|
+
};
|
|
7001
|
+
}
|
|
7002
|
+
function readWallClock(value, zone) {
|
|
7003
|
+
if (value == null) return null;
|
|
7004
|
+
if (value instanceof Date) return Number.isNaN(value.getTime()) ? null : localParts(value);
|
|
7005
|
+
const s = value.trim();
|
|
7006
|
+
if (!s) return null;
|
|
7007
|
+
const written = writtenParts(s);
|
|
7008
|
+
if (written) return written;
|
|
7009
|
+
const native = new Date(s);
|
|
7010
|
+
if (Number.isNaN(native.getTime())) return null;
|
|
7011
|
+
return zone !== void 0 && ISO_INSTANT.test(s) ? zonedParts(native, zone) : localParts(native);
|
|
7012
|
+
}
|
|
7013
|
+
function datePrecision(value) {
|
|
7014
|
+
return readWallClock(value, void 0)?.precision ?? null;
|
|
7015
|
+
}
|
|
7016
|
+
|
|
6984
7017
|
// ../shared/src/compare_holds.ts
|
|
6985
7018
|
function momentAt(zone, instant) {
|
|
6986
7019
|
const wall = (on) => ({ day: getTodayString(on, instant), at: getNowString(on, instant) });
|
|
@@ -8342,7 +8375,9 @@ var TOOL_INPUT_SEMANTICS = {
|
|
|
8342
8375
|
table_id: { kind: "table_ref", rows: "none" },
|
|
8343
8376
|
record_id: { kind: "record_ref" },
|
|
8344
8377
|
// `{fld_…}` tokens of `table_id`, resolved against its fields at execute time.
|
|
8345
|
-
expression: { kind: "dynamic" }
|
|
8378
|
+
expression: { kind: "dynamic" },
|
|
8379
|
+
// Read in place of the row's stored values; nothing is written.
|
|
8380
|
+
values: { kind: "record_data", table_from: "table_id", writes: "none" }
|
|
8346
8381
|
},
|
|
8347
8382
|
get_record: {
|
|
8348
8383
|
// Schema only takes `record_id`; table_id is optional/derived.
|
|
@@ -9340,6 +9375,16 @@ var WorkflowEvalError = class extends Error {
|
|
|
9340
9375
|
}
|
|
9341
9376
|
detail;
|
|
9342
9377
|
};
|
|
9378
|
+
function walkCutList(cut, segment, ctx) {
|
|
9379
|
+
if ((segment.at === "key" || segment.at === "field") && segment.key === "length") return cut.matched;
|
|
9380
|
+
if (segment.at !== "index") throw new CutListError(cut.lookup, cut.matched, cut.read, "a read of its rows");
|
|
9381
|
+
const row2 = (at3) => {
|
|
9382
|
+
if (at3 >= cut.read) throw new CutListError(cut.lookup, cut.matched, cut.read, "an index past the rows it read");
|
|
9383
|
+
return cut.list[at3];
|
|
9384
|
+
};
|
|
9385
|
+
const at2 = typeof segment.index === "number" ? segment.index : resolveIndexExpression(segment.index, ctx, "array index");
|
|
9386
|
+
return at2 instanceof Promise ? at2.then(row2) : row2(at2);
|
|
9387
|
+
}
|
|
9343
9388
|
var WorkflowTimeBudgetError = class extends Error {
|
|
9344
9389
|
/** `waitedFor`: what the run's deadline passed waiting on, when that was not the run's own work. */
|
|
9345
9390
|
constructor(subject, budgetMs, waitedFor) {
|
|
@@ -9574,6 +9619,7 @@ function evaluateWorkflowExpression(expr2, ctx, options = {}) {
|
|
|
9574
9619
|
budget.settled = true;
|
|
9575
9620
|
options.onNodes?.(budget.nodes);
|
|
9576
9621
|
}).then((answer) => {
|
|
9622
|
+
if (ctx.cut_lists !== void 0) refuseCut(ctx.cut_lists, "its answer", answer);
|
|
9577
9623
|
if (budget.bounded && expandedSize(answer, MAX_IN_PLACE_BYTES, budget.held) > MAX_IN_PLACE_BYTES) throw new ExpressionNotCheapError();
|
|
9578
9624
|
return answer;
|
|
9579
9625
|
}).catch((error) => {
|
|
@@ -9659,6 +9705,7 @@ async function chargeAfter(values2, ctx) {
|
|
|
9659
9705
|
return chargedArray(await Promise.all(values2), ctx);
|
|
9660
9706
|
}
|
|
9661
9707
|
function chargedArray(elements, ctx) {
|
|
9708
|
+
if (ctx.cut_lists !== void 0) refuseCut(ctx.cut_lists, "a list literal", ...elements);
|
|
9662
9709
|
charge(ctx, builtSize(elements));
|
|
9663
9710
|
return elements;
|
|
9664
9711
|
}
|
|
@@ -9667,13 +9714,16 @@ function fillObjectLiteral(out, entries3, from, ctx) {
|
|
|
9667
9714
|
const entry = entries3[at2];
|
|
9668
9715
|
const value = evaluateExpression(entry.value, ctx);
|
|
9669
9716
|
if (value instanceof Promise) return fillObjectAfter(out, entries3, at2, value, ctx);
|
|
9717
|
+
if (ctx.cut_lists !== void 0) refuseCut(ctx.cut_lists, "an object literal", value);
|
|
9670
9718
|
defineOwn(out, entry.key, value);
|
|
9671
9719
|
}
|
|
9672
9720
|
charge(ctx, builtSize(out));
|
|
9673
9721
|
return out;
|
|
9674
9722
|
}
|
|
9675
9723
|
async function fillObjectAfter(out, entries3, at2, value, ctx) {
|
|
9676
|
-
|
|
9724
|
+
const settled = await value;
|
|
9725
|
+
if (ctx.cut_lists !== void 0) refuseCut(ctx.cut_lists, "an object literal", settled);
|
|
9726
|
+
defineOwn(out, entries3[at2].key, settled);
|
|
9677
9727
|
return fillObjectLiteral(out, entries3, at2 + 1, ctx);
|
|
9678
9728
|
}
|
|
9679
9729
|
function checkClock(ctx) {
|
|
@@ -9713,7 +9763,12 @@ function evaluateLambda(params, body, ctx, items) {
|
|
|
9713
9763
|
if (pause !== null) return pause.then(() => call(...args));
|
|
9714
9764
|
const frame2 = /* @__PURE__ */ Object.create(null);
|
|
9715
9765
|
for (let i = 0; i < params.length; i++) frame2[params[i]] = args[i];
|
|
9716
|
-
|
|
9766
|
+
const answer = evaluateExpression(body, { ...bodyCtx, lambda_params: [...stack, frame2] });
|
|
9767
|
+
const lists = bodyCtx.cut_lists;
|
|
9768
|
+
if (lists === void 0) return answer;
|
|
9769
|
+
if (answer instanceof Promise) return answer.then((settled) => (refuseCut(lists, "a callback's answer", settled), settled));
|
|
9770
|
+
refuseCut(lists, "a callback's answer", answer);
|
|
9771
|
+
return answer;
|
|
9717
9772
|
};
|
|
9718
9773
|
return Object.assign(call, { workers: ctx.evaluation_budget.workers });
|
|
9719
9774
|
}
|
|
@@ -10062,6 +10117,8 @@ function findField(table, fieldKey) {
|
|
|
10062
10117
|
return table.fields.find((f) => f.key === fieldKey);
|
|
10063
10118
|
}
|
|
10064
10119
|
function walkSegment(value, segment, ctx) {
|
|
10120
|
+
const cut = ctx.cut_lists?.of(value);
|
|
10121
|
+
if (cut !== void 0) return walkCutList(cut, segment, ctx);
|
|
10065
10122
|
switch (segment.at) {
|
|
10066
10123
|
case "key":
|
|
10067
10124
|
case "field": {
|
|
@@ -10276,6 +10333,13 @@ async function callAfter(helper, pending, ctx) {
|
|
|
10276
10333
|
}
|
|
10277
10334
|
function callHelper({ fn, call, cost }, values2, ctx) {
|
|
10278
10335
|
const counted = /* @__PURE__ */ new Set();
|
|
10336
|
+
const lists = ctx.cut_lists;
|
|
10337
|
+
if (lists !== void 0) {
|
|
10338
|
+
const cut = lists.of(values2[0]);
|
|
10339
|
+
const use = CUT_LIST_HELPERS.get(fn);
|
|
10340
|
+
refuseCut(lists, `${fn}()`, ...cut !== void 0 && use !== void 0 ? values2.slice(1) : values2);
|
|
10341
|
+
if (cut !== void 0 && use === "length") return cut.matched;
|
|
10342
|
+
}
|
|
10279
10343
|
const held2 = countsHeldByReference(fn, cost) ? ctx.evaluation_budget.held : void 0;
|
|
10280
10344
|
assertWithin(ctx.evaluation_budget, MAX_IN_PLACE_HELPER_BYTES, values2, cost === "reads" ? (value, max3) => writtenSize(value, max3, held2) : (value, max3) => expandedSize(value, max3, held2, counted));
|
|
10281
10345
|
if (cost === "parses") charge(ctx, parsedSize(values2[0]));
|
|
@@ -10329,6 +10393,7 @@ async function binaryAfter(op, left, right, ctx) {
|
|
|
10329
10393
|
return applyBinary(op, leftValue, rightValue, ctx);
|
|
10330
10394
|
}
|
|
10331
10395
|
function applyBinary(op, left, right, ctx) {
|
|
10396
|
+
if (ctx.cut_lists !== void 0) refuseCut(ctx.cut_lists, `the operator "${op}"`, left, right);
|
|
10332
10397
|
switch (op) {
|
|
10333
10398
|
case "eq":
|
|
10334
10399
|
case "neq":
|
|
@@ -10430,12 +10495,13 @@ function describeValue(value) {
|
|
|
10430
10495
|
}
|
|
10431
10496
|
function evaluateUnary(op, argExpr, ctx) {
|
|
10432
10497
|
const value = evaluateExpression(argExpr, ctx);
|
|
10433
|
-
return value instanceof Promise ? unaryAfter(op, value) : applyUnary(op, value);
|
|
10498
|
+
return value instanceof Promise ? unaryAfter(op, value, ctx) : applyUnary(op, value, ctx);
|
|
10434
10499
|
}
|
|
10435
|
-
async function unaryAfter(op, value) {
|
|
10436
|
-
return applyUnary(op, await value);
|
|
10500
|
+
async function unaryAfter(op, value, ctx) {
|
|
10501
|
+
return applyUnary(op, await value, ctx);
|
|
10437
10502
|
}
|
|
10438
|
-
function applyUnary(op, value) {
|
|
10503
|
+
function applyUnary(op, value, ctx) {
|
|
10504
|
+
if (ctx.cut_lists !== void 0) refuseCut(ctx.cut_lists, `the operator "${op}"`, value);
|
|
10439
10505
|
switch (op) {
|
|
10440
10506
|
case "not":
|
|
10441
10507
|
return !value;
|
|
@@ -10469,6 +10535,7 @@ async function templateAfter(pending, ctx) {
|
|
|
10469
10535
|
return writeTemplate(evaluated2, ctx);
|
|
10470
10536
|
}
|
|
10471
10537
|
function writeTemplate(evaluated2, ctx) {
|
|
10538
|
+
if (ctx.cut_lists !== void 0) refuseCut(ctx.cut_lists, "a template", ...evaluated2);
|
|
10472
10539
|
assertCheap(ctx.evaluation_budget, ...evaluated2);
|
|
10473
10540
|
assertTextWithin("template", ...evaluated2);
|
|
10474
10541
|
const text2 = evaluated2.map(stringifyForTemplate).join("");
|
|
@@ -11093,6 +11160,7 @@ function useAppContext() {
|
|
|
11093
11160
|
memberId: data?.member_id ?? null,
|
|
11094
11161
|
insider: data !== void 0 && data.member_id !== null && data.group_ids !== void 0,
|
|
11095
11162
|
groupIds: data?.group_ids ?? null,
|
|
11163
|
+
admin: data?.admin === true,
|
|
11096
11164
|
absences: data?.absences ?? null,
|
|
11097
11165
|
commentsEnabled: data?.comments_enabled ?? false,
|
|
11098
11166
|
recordingEnabled: data?.recording_enabled === true,
|
|
@@ -14051,6 +14119,7 @@ function isThreeArgumentCall(expression, from) {
|
|
|
14051
14119
|
}
|
|
14052
14120
|
function prepareFormulaExpression(expression, fields) {
|
|
14053
14121
|
const keys2 = new Set(fields.map((field) => field.key));
|
|
14122
|
+
const yesNo = new Set(fields.filter((field) => field.type === "boolean").map((field) => field.key));
|
|
14054
14123
|
const referencedKeys = [];
|
|
14055
14124
|
const photoPlaceKeys = [];
|
|
14056
14125
|
const unresolved = [];
|
|
@@ -14071,21 +14140,26 @@ function prepareFormulaExpression(expression, fields) {
|
|
|
14071
14140
|
seenKeys.add(key);
|
|
14072
14141
|
referencedKeys.push(key);
|
|
14073
14142
|
}
|
|
14074
|
-
const
|
|
14143
|
+
const cell = `data[${JSON.stringify(key)}]`;
|
|
14144
|
+
const read2 = yesNo.has(key) && !isEmptinessArgument(expression, offset, raw.length) ? `coalesce(${cell}, false)` : cell;
|
|
14075
14145
|
if (distanced !== void 0) {
|
|
14076
|
-
if (!isThreeArgumentCall(expression, offset + raw.length)) return `distance(${
|
|
14146
|
+
if (!isThreeArgumentCall(expression, offset + raw.length)) return `distance(${cell},`;
|
|
14077
14147
|
if (!photoPlaceKeys.includes(key)) photoPlaceKeys.push(key);
|
|
14078
14148
|
return `${PHOTO_DISTANCE_HELPER}(${LOWERED_PLACES}[${JSON.stringify(key)}],`;
|
|
14079
14149
|
}
|
|
14080
|
-
return labelled2 === void 0 ? read2 : `label(${
|
|
14150
|
+
return labelled2 === void 0 ? read2 : `label(${cell}, names[${JSON.stringify(key)}], ${JSON.stringify(nameByKey.get(key))})`;
|
|
14081
14151
|
});
|
|
14082
14152
|
return {
|
|
14083
14153
|
evaluable: unresolved.length > 0 ? null : lowered,
|
|
14084
14154
|
referencedKeys,
|
|
14155
|
+
yesNoKeys: referencedKeys.filter((key) => yesNo.has(key)),
|
|
14085
14156
|
unresolved,
|
|
14086
14157
|
photoPlaceKeys
|
|
14087
14158
|
};
|
|
14088
14159
|
}
|
|
14160
|
+
function isEmptinessArgument(expression, offset, length2) {
|
|
14161
|
+
return /(?<![\w.$])(?:isEmpty|isNull|isNotNull)\(\s*$/.test(expression.slice(0, offset)) && /^\s*\)/.test(expression.slice(offset + length2));
|
|
14162
|
+
}
|
|
14089
14163
|
function referencedFieldKeys(expression, fields) {
|
|
14090
14164
|
return prepareFormulaExpression(expression, fields).referencedKeys;
|
|
14091
14165
|
}
|
|
@@ -14273,7 +14347,7 @@ function computeFormulaFieldsWithContext(row2, fields, context, linkedTableRecor
|
|
|
14273
14347
|
erroredFormulaKeys.add(formulaField.key);
|
|
14274
14348
|
continue;
|
|
14275
14349
|
}
|
|
14276
|
-
const everyReferenceEmpty =
|
|
14350
|
+
const everyReferenceEmpty = readsAreAllEmpty(prepared.refs, evaluationContext);
|
|
14277
14351
|
const evaluated2 = evaluateFormulaWithJS(
|
|
14278
14352
|
prepared.parsed,
|
|
14279
14353
|
{ data: evaluationContext, names: context.names, places },
|
|
@@ -14454,6 +14528,9 @@ function readsFieldsOnlyThroughEmptinessPredicates(node, taken) {
|
|
|
14454
14528
|
function isFieldRead(node) {
|
|
14455
14529
|
return node !== void 0 && node.type === "Index" && node.receiver.type === "ID" && node.receiver.value === "data";
|
|
14456
14530
|
}
|
|
14531
|
+
function readsAreAllEmpty(prepared, data) {
|
|
14532
|
+
return prepared.referencedKeys.length > 0 && prepared.referencedKeys.every((key) => !prepared.yesNoKeys.includes(key) && data[key] === null);
|
|
14533
|
+
}
|
|
14457
14534
|
function evaluateFormulaWithJS(parsed, data, dates, everyReferenceEmpty) {
|
|
14458
14535
|
try {
|
|
14459
14536
|
if (parsed.kind === "unparsable") throw parsed.error;
|
|
@@ -15159,7 +15236,8 @@ function readCriteria(read2) {
|
|
|
15159
15236
|
params: { ...read2.params },
|
|
15160
15237
|
...read2.filter === void 0 ? {} : { filter: read2.filter },
|
|
15161
15238
|
...sort2 === void 0 ? {} : { sort: sort2 },
|
|
15162
|
-
...read2.aggregate === void 0 ? {} : { aggregate: read2.aggregate }
|
|
15239
|
+
...read2.aggregate === void 0 ? {} : { aggregate: read2.aggregate },
|
|
15240
|
+
...read2.fields === void 0 ? {} : { fields: [...read2.fields] }
|
|
15163
15241
|
};
|
|
15164
15242
|
}
|
|
15165
15243
|
|
|
@@ -15199,18 +15277,82 @@ function knownCount(alias, call) {
|
|
|
15199
15277
|
if (counted instanceof Promise) leaveToTheRead(counted);
|
|
15200
15278
|
return counted === null || counted instanceof Promise ? void 0 : counted;
|
|
15201
15279
|
}
|
|
15202
|
-
async function
|
|
15280
|
+
async function readRows(alias, call) {
|
|
15203
15281
|
const mocked = getMockRows(alias, call);
|
|
15204
15282
|
if (mocked !== null) return pageOf(await mocked, call);
|
|
15205
|
-
|
|
15283
|
+
return rpc("query", {
|
|
15206
15284
|
alias,
|
|
15207
15285
|
...readCriteria(call),
|
|
15208
15286
|
...call.limit === void 0 ? {} : { limit: call.limit },
|
|
15209
15287
|
...call.keyset === true ? { keyset: true, ...call.cursor == null ? {} : { cursor: call.cursor } } : { offset: call.offset ?? 0 }
|
|
15210
15288
|
});
|
|
15289
|
+
}
|
|
15290
|
+
async function askRows(key, alias, askedAt, call, since = askedAt) {
|
|
15291
|
+
const answer = await readRows(alias, call);
|
|
15211
15292
|
noteAnswer(key, alias, askedAt, answer.rows, since);
|
|
15212
15293
|
return answer;
|
|
15213
15294
|
}
|
|
15295
|
+
function patchIds(held2, alias, fields, changes) {
|
|
15296
|
+
const tables = changes[alias];
|
|
15297
|
+
if (held2.refresh === void 0 || held2.truncated || tables === void 0) return null;
|
|
15298
|
+
if (typeof held2.refresh.by === "object" && fields !== void 0 && !fields.includes(held2.refresh.by.column)) return null;
|
|
15299
|
+
const ids = /* @__PURE__ */ new Set();
|
|
15300
|
+
const entries3 = Object.entries(tables);
|
|
15301
|
+
if (entries3.length === 0) return null;
|
|
15302
|
+
for (const [table, named] of entries3) {
|
|
15303
|
+
if (named === null || !held2.refresh.tables.includes(table)) return null;
|
|
15304
|
+
for (const id of named) ids.add(id);
|
|
15305
|
+
}
|
|
15306
|
+
return ids.size === 0 ? null : [...ids];
|
|
15307
|
+
}
|
|
15308
|
+
var idOf = (row2) => String(row2.__source_record_id);
|
|
15309
|
+
async function patchRows(key, alias, askedAt, { held: held2, since, ids }, call) {
|
|
15310
|
+
const { refresh } = held2;
|
|
15311
|
+
if (refresh === void 0) throw new Error(`A patch of "${alias}" needs the answer held to state \`refresh\`.`);
|
|
15312
|
+
const changed2 = new Set(ids);
|
|
15313
|
+
const idFilter = { node_type: "condition", type: "record_id", operator: "is_any_of", value: ids };
|
|
15314
|
+
const patched = (rows, reread) => {
|
|
15315
|
+
noteAnswer(key, alias, askedAt, reread, since);
|
|
15316
|
+
return { ...held2, rows };
|
|
15317
|
+
};
|
|
15318
|
+
if (refresh.by === "record") {
|
|
15319
|
+
const read2 = await readRows(alias, { ...call, filter: within(call.filter, idFilter) });
|
|
15320
|
+
const answered2 = new Map(read2.rows.map((row2) => [idOf(row2), row2]));
|
|
15321
|
+
const heldIds = new Set(held2.rows.map(idOf));
|
|
15322
|
+
const kept = held2.rows.flatMap((row2) => {
|
|
15323
|
+
if (!changed2.has(idOf(row2))) return [row2];
|
|
15324
|
+
const next = answered2.get(idOf(row2));
|
|
15325
|
+
return next === void 0 ? [] : [next];
|
|
15326
|
+
});
|
|
15327
|
+
return patched([...kept, ...read2.rows.filter((row2) => !heldIds.has(idOf(row2)))], read2.rows);
|
|
15328
|
+
}
|
|
15329
|
+
const { column } = refresh.by;
|
|
15330
|
+
const groupsOf2 = (row2) => readLinks(row2[column]).map((link2) => link2.id);
|
|
15331
|
+
const now = await readRows(alias, { params: call.params, filter: idFilter, fields: [column], offset: 0 });
|
|
15332
|
+
const groups = /* @__PURE__ */ new Set();
|
|
15333
|
+
let empty = false;
|
|
15334
|
+
for (const row2 of [...held2.rows.filter((one) => changed2.has(idOf(one))), ...now.rows]) {
|
|
15335
|
+
const named = groupsOf2(row2);
|
|
15336
|
+
if (named.length === 0) empty = true;
|
|
15337
|
+
for (const id of named) groups.add(id);
|
|
15338
|
+
}
|
|
15339
|
+
const inGroup = (row2) => {
|
|
15340
|
+
const named = groupsOf2(row2);
|
|
15341
|
+
return named.length === 0 ? empty : named.some((id) => groups.has(id));
|
|
15342
|
+
};
|
|
15343
|
+
const parts = [
|
|
15344
|
+
...groups.size === 0 ? [] : [{ node_type: "condition", field_key: column, operator: "has_any_of", value: [...groups] }],
|
|
15345
|
+
...empty ? [{ node_type: "condition", field_key: column, operator: "is_empty" }] : []
|
|
15346
|
+
];
|
|
15347
|
+
const [only] = parts;
|
|
15348
|
+
if (only === void 0) return patched(held2.rows, []);
|
|
15349
|
+
if (held2.rows.filter(inGroup).length * 2 > held2.rows.length) return askRows(key, alias, askedAt, call);
|
|
15350
|
+
const again = await readRows(alias, { ...call, filter: within(call.filter, parts.length === 1 ? only : { node_type: "group", logic: "or", children: parts }) });
|
|
15351
|
+
if (again.truncated) return askRows(key, alias, askedAt, call);
|
|
15352
|
+
const at2 = held2.rows.findIndex(inGroup);
|
|
15353
|
+
const rest = held2.rows.filter((row2) => !inGroup(row2));
|
|
15354
|
+
return patched(at2 < 0 ? [...rest, ...again.rows] : [...rest.slice(0, at2), ...again.rows, ...rest.slice(at2)], again.rows);
|
|
15355
|
+
}
|
|
15214
15356
|
async function askCount(key, alias, askedAt, call) {
|
|
15215
15357
|
const mocked = mockCount(alias, call);
|
|
15216
15358
|
if (mocked !== null) return mocked;
|
|
@@ -15245,24 +15387,31 @@ function useQuery(alias, params = {}, opts = {}) {
|
|
|
15245
15387
|
const totalAsked = opts.total ?? opts.page !== void 0;
|
|
15246
15388
|
const by = typeof totalAsked === "object" && "by" in totalAsked ? totalAsked.by : void 0;
|
|
15247
15389
|
const where = typeof totalAsked === "object" && "where" in totalAsked ? totalAsked.where : void 0;
|
|
15248
|
-
const
|
|
15390
|
+
const fields = opts.fields;
|
|
15391
|
+
const call = JSON.stringify([params, filter2 ?? null, sort2 ?? null, fields ?? null]);
|
|
15249
15392
|
const mocking = hasMockFlag();
|
|
15250
15393
|
const [paging, setPaging] = useState3({ call, page: 0 });
|
|
15251
15394
|
const held2 = opts.page === void 0 ? void 0 : opts.pageAt;
|
|
15252
15395
|
const page = held2 !== void 0 ? Math.max(0, held2.at) : opts.page === void 0 || paging.call !== call ? 0 : paging.page;
|
|
15253
15396
|
const turn2 = held2?.onChange;
|
|
15254
15397
|
const setPage = useCallback5((next) => turn2 === void 0 ? setPaging({ call, page: Math.max(0, next) }) : turn2(Math.max(0, next)), [call, turn2]);
|
|
15255
|
-
const
|
|
15398
|
+
const patches = opts.refresh === "changed" && opts.limit === void 0 && opts.page === void 0 && opts.more === void 0;
|
|
15399
|
+
const rowsKey = !enabled || !wantsRows || opts.more !== void 0 ? null : JSON.stringify(["rows", alias, call, opts.limit ?? null, opts.page ?? null, page, opts.refresh ?? null, ...apart]);
|
|
15400
|
+
const patchRowsRead = !patches ? void 0 : (held3, changes, since) => {
|
|
15401
|
+
const ids = held3 === void 0 ? null : patchIds(held3, alias, fields, changes);
|
|
15402
|
+
return held3 === void 0 || ids === null ? null : (askedAt) => patchRows(rowsKey ?? "", alias, askedAt, { held: held3, ids, since }, { params, filter: filter2, sort: sort2, ...fields === void 0 ? {} : { fields }, offset: 0 });
|
|
15403
|
+
};
|
|
15256
15404
|
const rows = useKey(
|
|
15257
15405
|
rowsKey,
|
|
15258
15406
|
(askedAt) => askRows(rowsKey ?? "", alias, askedAt, {
|
|
15259
15407
|
params,
|
|
15260
15408
|
filter: filter2,
|
|
15261
15409
|
sort: sort2,
|
|
15410
|
+
...fields === void 0 ? {} : { fields },
|
|
15262
15411
|
limit: opts.page ?? opts.limit,
|
|
15263
15412
|
offset: opts.page === void 0 ? 0 : page * opts.page
|
|
15264
15413
|
}),
|
|
15265
|
-
{ focus, aliases, known: mocking ? () => knownRows(alias, { params, filter: filter2, sort: sort2, limit: opts.page ?? opts.limit, offset: opts.page === void 0 ? 0 : page * opts.page }) : void 0 }
|
|
15414
|
+
{ focus, aliases, patch: patchRowsRead, known: mocking ? () => knownRows(alias, { params, filter: filter2, sort: sort2, limit: opts.page ?? opts.limit, offset: opts.page === void 0 ? 0 : page * opts.page }) : void 0 }
|
|
15266
15415
|
);
|
|
15267
15416
|
const feedKey = !enabled || !wantsRows || opts.more === void 0 ? null : JSON.stringify(["feed", alias, call, opts.more, ...apart]);
|
|
15268
15417
|
const feedSize = opts.more ?? 0;
|
|
@@ -15275,13 +15424,13 @@ function useQuery(alias, params = {}, opts = {}) {
|
|
|
15275
15424
|
const last2 = current?.pages.at(-1);
|
|
15276
15425
|
if (current !== void 0 && last2 !== void 0 && wants > current.pages.length && last2.next_cursor != null) {
|
|
15277
15426
|
const since = current.pages[0]?.askedAt ?? askedAt;
|
|
15278
|
-
const next = await askRows(key, alias, askedAt, { params, filter: filter2, sort: sort2, limit: feedSize, cursor: last2.next_cursor, keyset: true }, since);
|
|
15427
|
+
const next = await askRows(key, alias, askedAt, { params, filter: filter2, sort: sort2, ...fields === void 0 ? {} : { fields }, limit: feedSize, cursor: last2.next_cursor, keyset: true }, since);
|
|
15279
15428
|
return { pages: [...current.pages, { ...next, askedAt }] };
|
|
15280
15429
|
}
|
|
15281
15430
|
const pages = [];
|
|
15282
15431
|
let cursor = null;
|
|
15283
15432
|
for (let at2 = 0; at2 < Math.min(wants, current?.pages.length ?? 1); at2 += 1) {
|
|
15284
|
-
const next = await askRows(key, alias, askedAt, { params, filter: filter2, sort: sort2, limit: feedSize, cursor, keyset: true });
|
|
15433
|
+
const next = await askRows(key, alias, askedAt, { params, filter: filter2, sort: sort2, ...fields === void 0 ? {} : { fields }, limit: feedSize, cursor, keyset: true });
|
|
15285
15434
|
pages.push({ ...next, askedAt });
|
|
15286
15435
|
cursor = next.next_cursor ?? null;
|
|
15287
15436
|
if (cursor === null) break;
|
|
@@ -15372,22 +15521,33 @@ async function askGroups(key, alias, askedAt, aggregate, call) {
|
|
|
15372
15521
|
noteAnswer(key, alias, askedAt, []);
|
|
15373
15522
|
return answer;
|
|
15374
15523
|
}
|
|
15375
|
-
async function askCall(key, call, askedAt) {
|
|
15524
|
+
async function askCall(key, call, askedAt, patch) {
|
|
15376
15525
|
const params = call.params ?? {};
|
|
15377
15526
|
const sort2 = statedSort(call.sort);
|
|
15378
15527
|
const rows = call.rows === false ? null : settle(
|
|
15379
|
-
call.aggregate !== void 0 ? askGroups(key, call.alias, askedAt, call.aggregate, { params, filter: call.filter, sort: sort2 }) : askRows(key, call.alias, askedAt, { params, filter: call.filter, sort: sort2 })
|
|
15528
|
+
patch !== void 0 ? patchRows(key, call.alias, askedAt, patch, { params, filter: call.filter, sort: sort2, ...call.fields === void 0 ? {} : { fields: call.fields }, offset: 0 }) : call.aggregate !== void 0 ? askGroups(key, call.alias, askedAt, call.aggregate, { params, filter: call.filter, sort: sort2 }) : askRows(key, call.alias, askedAt, { params, filter: call.filter, sort: sort2, ...call.fields === void 0 ? {} : { fields: call.fields } })
|
|
15380
15529
|
);
|
|
15381
15530
|
const count = call.total === true ? settle(askCount(key, call.alias, askedAt, { params, filter: call.filter })) : null;
|
|
15382
15531
|
return { rows: rows === null ? null : await rows, count: count === null ? null : await count };
|
|
15383
15532
|
}
|
|
15384
15533
|
function useQueries(calls, opts = {}) {
|
|
15385
15534
|
const enabled = opts.enabled ?? true;
|
|
15386
|
-
const shape = JSON.stringify(calls.map((call) => [call.alias, call.params ?? {}, call.filter ?? null, statedSort(call.sort) ?? null, call.aggregate ?? null, call.total ?? false, call.rows ?? true]));
|
|
15535
|
+
const shape = JSON.stringify(calls.map((call) => [call.alias, call.params ?? {}, call.filter ?? null, statedSort(call.sort) ?? null, call.aggregate ?? null, call.total ?? false, call.rows ?? true, call.fields ?? null, call.refresh ?? null]));
|
|
15387
15536
|
const key = !enabled || calls.length === 0 ? null : JSON.stringify(["calls", shape]);
|
|
15388
15537
|
const answers = useKey(key, (askedAt) => Promise.all(calls.map((call) => askCall(key ?? "", call, askedAt))), {
|
|
15389
15538
|
focus: opts.revalidateOnFocus ?? true,
|
|
15390
|
-
aliases: calls.map((call) => call.alias)
|
|
15539
|
+
aliases: calls.map((call) => call.alias),
|
|
15540
|
+
// A call that opted in and can be patched is; the others of the key are asked whole in the same push.
|
|
15541
|
+
patch: (held2, changes, since) => {
|
|
15542
|
+
if (held2 === void 0) return null;
|
|
15543
|
+
const patched = calls.map((call, at2) => {
|
|
15544
|
+
const rows = held2[at2]?.rows?.answer;
|
|
15545
|
+
if (call.refresh !== "changed" || call.aggregate !== void 0 || call.rows === false || rows === void 0) return void 0;
|
|
15546
|
+
const ids = patchIds(rows, call.alias, call.fields, changes);
|
|
15547
|
+
return ids === null ? void 0 : { held: rows, since, ids };
|
|
15548
|
+
});
|
|
15549
|
+
return patched.every((one) => one === void 0) ? null : (askedAt) => Promise.all(calls.map((call, at2) => askCall(key ?? "", call, askedAt, patched[at2])));
|
|
15550
|
+
}
|
|
15391
15551
|
});
|
|
15392
15552
|
const version2 = useWrittenVersion();
|
|
15393
15553
|
return useMemo3(
|