@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/AGENTS.md
CHANGED
|
@@ -14,7 +14,7 @@ This file is the index. The **exact type** of anything is its shipped declaratio
|
|
|
14
14
|
|
|
15
15
|
| Doc | Read it for |
|
|
16
16
|
|---|---|
|
|
17
|
-
| [docs/data_fetching.md](./docs/data_fetching.md) | The reads: `useQuery(alias, params, opts)` — its rows (`limit`), numbered pages (`page`), a keyset feed (`more`), its `total` or the total alone, with `total: { by }` a count per value of one column and `total: { where }` a count per named filter, from one scan — `useQueries` for reads known only at render, `queryAll` outside React, `exportQuery` for a file of them the server makes, `exportApp` for the workbook of a JSON app's List; every hook answers one `QueryState`. The ROW type (`RowOf` — the alias's projected columns and nothing else), runtime `sort`/`filter` keys, cell readers (`row.*`, `readSelect`, `readMembers`, `readLinks`, `readFiles`, `readLocked`/`readLockedBy`, `readCreatedAt`/`readUpdatedAt`), the SDK's own cache — **arrival revalidates** — **realtime push** and `answeredAt` (the server answering again what a screen drew), a write drawn on every read from the press, a count as its own full scan, and the search-as-you-type and record-picker patterns. |
|
|
17
|
+
| [docs/data_fetching.md](./docs/data_fetching.md) | The reads: `useQuery(alias, params, opts)` — its rows (`limit`), numbered pages (`page`), a keyset feed (`more`), its `total` or the total alone, only the columns it draws (`fields`), a push re-reading only the records it changed (`refresh: "changed"`), with `total: { by }` a count per value of one column and `total: { where }` a count per named filter, from one scan — `useQueries` for reads known only at render, `queryAll` outside React, `exportQuery` for a file of them the server makes, `exportApp` for the workbook of a JSON app's List; every hook answers one `QueryState`. The ROW type (`RowOf` — the alias's projected columns and nothing else), runtime `sort`/`filter` keys, cell readers (`row.*`, `readSelect`, `readMembers`, `readLinks`, `readFiles`, `readLocked`/`readLockedBy`, `readCreatedAt`/`readUpdatedAt`), the SDK's own cache — **arrival revalidates** — **realtime push** and `answeredAt` (the server answering again what a screen drew), a write drawn on every read from the press, a count as its own full scan, and the search-as-you-type and record-picker patterns. |
|
|
18
18
|
| [docs/queries.md](./docs/queries.md) | **The query engine reference** — AST node kinds, per-field-type operators, filters/params/pruning, free-text search, combining tables, shaping (aggregates, date buckets, windows), runtime refinement bounds, limits and the efficiency playbook. |
|
|
19
19
|
| [docs/mutations.md](./docs/mutations.md) | `useWorkflow` (the ONLY write path; `useWorkflows` for writes that are data), the `WorkflowResult` resolve-never-throw contract (`field_errors`), typed inputs, every write drawn on every read from the press — predicted from the workflow's own steps, taken back on a refusal, `pending` meanwhile — the re-read a successful write triggers over the tables its body names, diff-before-update, locked records, `useNewRecord`, read-after-write ordering (`writesSettled()`), `useRecording`, `useRecordings` over several aliases. |
|
|
20
20
|
| [docs/workflows.md](./docs/workflows.md) | **The workflow-BODY reference** — the JS subset a body may use, opaque `fld_*`/`opt_*` keys, every step form, the accepted sugar, helpers, record-write surfaces, the traps and the verify loop. |
|
|
@@ -323,6 +323,7 @@ function openTarget(address) {
|
|
|
323
323
|
|
|
324
324
|
// ../shared/src/app_host/api_base_meta.ts
|
|
325
325
|
var API_BASE_META_NAME = "lotics-api-base";
|
|
326
|
+
var APP_VERSION_META_NAME = "lotics-app-version";
|
|
326
327
|
|
|
327
328
|
// ../shared/src/transport_error.ts
|
|
328
329
|
function gatewayErrorMessage(status) {
|
|
@@ -1607,8 +1608,23 @@ function notifyLocalWrite(reads) {
|
|
|
1607
1608
|
if (aliases.length === 0) return;
|
|
1608
1609
|
queriesChanged(aliases);
|
|
1609
1610
|
}
|
|
1610
|
-
function queriesChanged(aliases) {
|
|
1611
|
-
for (const cb of refetchSubscribers) cb([...aliases]);
|
|
1611
|
+
function queriesChanged(aliases, changes) {
|
|
1612
|
+
for (const cb of refetchSubscribers) cb([...aliases], changes);
|
|
1613
|
+
}
|
|
1614
|
+
function readQueryChanges(raw) {
|
|
1615
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return void 0;
|
|
1616
|
+
const changes = [];
|
|
1617
|
+
for (const [alias, tables] of Object.entries(raw)) {
|
|
1618
|
+
if (typeof tables !== "object" || tables === null || Array.isArray(tables)) return void 0;
|
|
1619
|
+
const read = [];
|
|
1620
|
+
for (const [tableId, ids] of Object.entries(tables)) {
|
|
1621
|
+
if (ids === null) read.push([tableId, null]);
|
|
1622
|
+
else if (Array.isArray(ids) && ids.every((id) => typeof id === "string")) read.push([tableId, ids]);
|
|
1623
|
+
else return void 0;
|
|
1624
|
+
}
|
|
1625
|
+
changes.push([alias, Object.fromEntries(read)]);
|
|
1626
|
+
}
|
|
1627
|
+
return Object.fromEntries(changes);
|
|
1612
1628
|
}
|
|
1613
1629
|
var pending = /* @__PURE__ */ new Map();
|
|
1614
1630
|
var streaming = /* @__PURE__ */ new Map();
|
|
@@ -1633,7 +1649,10 @@ function ensureListener() {
|
|
|
1633
1649
|
return;
|
|
1634
1650
|
}
|
|
1635
1651
|
if (msg.type === "queriesChanged" && Array.isArray(msg.aliases)) {
|
|
1636
|
-
queriesChanged(
|
|
1652
|
+
queriesChanged(
|
|
1653
|
+
msg.aliases.filter((a) => typeof a === "string"),
|
|
1654
|
+
readQueryChanges(msg.changes)
|
|
1655
|
+
);
|
|
1637
1656
|
return;
|
|
1638
1657
|
}
|
|
1639
1658
|
if (msg.type === "recordingChanged") {
|
|
@@ -1885,6 +1904,10 @@ function apiBase() {
|
|
|
1885
1904
|
apiBaseCache = content.replace(/\/+$/, "");
|
|
1886
1905
|
return apiBaseCache;
|
|
1887
1906
|
}
|
|
1907
|
+
function servedVersionId() {
|
|
1908
|
+
const content = document.querySelector(`meta[name="${APP_VERSION_META_NAME}"]`)?.getAttribute("content")?.trim();
|
|
1909
|
+
return content ? content : void 0;
|
|
1910
|
+
}
|
|
1888
1911
|
var PASSWORD_REQUIRED_CODE = "PASSWORD_REQUIRED";
|
|
1889
1912
|
var bootPromise = null;
|
|
1890
1913
|
var appInfoPromise = null;
|
|
@@ -2205,6 +2228,7 @@ async function sendAskedReads() {
|
|
|
2205
2228
|
return void 0;
|
|
2206
2229
|
});
|
|
2207
2230
|
if (booted === void 0) return;
|
|
2231
|
+
const versionId = servedVersionId();
|
|
2208
2232
|
for (let at = 0; at < asked.length; at += APP_QUERY_BATCH_MAX) {
|
|
2209
2233
|
const chunk = asked.slice(at, at + APP_QUERY_BATCH_MAX);
|
|
2210
2234
|
const answerRead = (k, answer) => {
|
|
@@ -2213,7 +2237,7 @@ async function sendAskedReads() {
|
|
|
2213
2237
|
if ("result" in answer) read.resolve(answer.result);
|
|
2214
2238
|
else read.reject(new ApiRefusal(answer.error.status, answer.error));
|
|
2215
2239
|
};
|
|
2216
|
-
apiQueryBatch(`/v1/apps/${booted.app_id}/query_batch`, { reads: chunk.map((read) => read.payload) }, chunk.length, answerRead).then((answered) => {
|
|
2240
|
+
apiQueryBatch(`/v1/apps/${booted.app_id}/query_batch`, { reads: chunk.map((read) => versionId === void 0 ? read.payload : { ...read.payload, app_version_id: versionId }) }, chunk.length, answerRead).then((answered) => {
|
|
2217
2241
|
chunk.forEach((read, k) => {
|
|
2218
2242
|
if (!answered.has(k)) read.reject(new Error(`The server answered ${answered.size} of ${chunk.length} reads.`));
|
|
2219
2243
|
});
|