@rocicorp/zero 0.24.2025091100 → 0.24.2025092400
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/out/analyze-query/src/bin-analyze.js +7 -8
- package/out/analyze-query/src/bin-analyze.js.map +1 -1
- package/out/analyze-query/src/explain-queries.d.ts +1 -1
- package/out/analyze-query/src/explain-queries.d.ts.map +1 -1
- package/out/analyze-query/src/run-ast.d.ts +13 -23
- package/out/analyze-query/src/run-ast.d.ts.map +1 -1
- package/out/analyze-query/src/run-ast.js +25 -20
- package/out/analyze-query/src/run-ast.js.map +1 -1
- package/out/{chunk-V2KPKXLX.js → chunk-5JTC5G4I.js} +254 -156
- package/out/chunk-5JTC5G4I.js.map +7 -0
- package/out/chunk-ASRS2LFV.js +35 -0
- package/out/chunk-ASRS2LFV.js.map +7 -0
- package/out/{chunk-FH5Q72JS.js → chunk-OQGMEB3H.js} +3 -3
- package/out/{chunk-MLYQCVBG.js → chunk-QZPMFA73.js} +1465 -945
- package/out/chunk-QZPMFA73.js.map +7 -0
- package/out/{inspector-NC6TPMRA.js → lazy-inspector-TOTYUTBC.js} +298 -231
- package/out/lazy-inspector-TOTYUTBC.js.map +7 -0
- package/out/react-native.js +276 -278
- package/out/react-native.js.map +4 -4
- package/out/react.js +13 -25
- package/out/react.js.map +2 -2
- package/out/replicache/src/connection-loop.d.ts.map +1 -1
- package/out/replicache/src/deleted-clients.d.ts +17 -10
- package/out/replicache/src/deleted-clients.d.ts.map +1 -1
- package/out/replicache/src/kv/expo-sqlite/store.d.ts +11 -0
- package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -0
- package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
- package/out/replicache/src/kv/mem-store.d.ts.map +1 -1
- package/out/replicache/src/kv/op-sqlite/store.d.ts +14 -0
- package/out/replicache/src/kv/op-sqlite/store.d.ts.map +1 -0
- package/out/replicache/src/kv/op-sqlite/types.d.ts +13 -0
- package/out/replicache/src/kv/op-sqlite/types.d.ts.map +1 -0
- package/out/replicache/src/kv/read-impl.d.ts.map +1 -1
- package/out/replicache/src/kv/sqlite-store.d.ts +37 -63
- package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
- package/out/replicache/src/kv/throw-if-closed.d.ts +12 -0
- package/out/replicache/src/kv/throw-if-closed.d.ts.map +1 -0
- package/out/replicache/src/kv/write-impl-base.d.ts.map +1 -1
- package/out/replicache/src/kv/write-impl.d.ts.map +1 -1
- package/out/replicache/src/persist/client-gc.d.ts.map +1 -1
- package/out/replicache/src/persist/client-group-gc.d.ts +2 -3
- package/out/replicache/src/persist/client-group-gc.d.ts.map +1 -1
- package/out/replicache/src/persist/clients.d.ts +2 -1
- package/out/replicache/src/persist/clients.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
- package/out/replicache/src/process-scheduler.d.ts.map +1 -1
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/shared/src/sentinels.d.ts +2 -0
- package/out/shared/src/sentinels.d.ts.map +1 -1
- package/out/shared/src/sentinels.js +7 -0
- package/out/shared/src/sentinels.js.map +1 -0
- package/out/shared/src/valita.js +1 -1
- package/out/shared/src/valita.js.map +1 -1
- package/out/solid.js +4 -4
- package/out/zero/package.json +4 -4
- package/out/zero/src/zero-cache-dev.js +4 -0
- package/out/zero/src/zero-cache-dev.js.map +1 -1
- package/out/zero-cache/src/config/network.d.ts.map +1 -1
- package/out/zero-cache/src/config/network.js +1 -2
- package/out/zero-cache/src/config/network.js.map +1 -1
- package/out/zero-cache/src/config/normalize.d.ts +1 -0
- package/out/zero-cache/src/config/normalize.d.ts.map +1 -1
- package/out/zero-cache/src/config/normalize.js +6 -0
- package/out/zero-cache/src/config/normalize.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +3 -0
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +35 -1
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/server/anonymous-otel-start.d.ts +1 -0
- package/out/zero-cache/src/server/anonymous-otel-start.d.ts.map +1 -1
- package/out/zero-cache/src/server/anonymous-otel-start.js +18 -0
- package/out/zero-cache/src/server/anonymous-otel-start.js.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.d.ts +9 -0
- package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.js +19 -0
- package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
- package/out/zero-cache/src/server/reaper.d.ts.map +1 -1
- package/out/zero-cache/src/server/reaper.js +8 -0
- package/out/zero-cache/src/server/reaper.js.map +1 -1
- package/out/zero-cache/src/server/syncer.js +2 -2
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/analyze.d.ts +9 -1
- package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
- package/out/zero-cache/src/services/analyze.js +109 -39
- package/out/zero-cache/src/services/analyze.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js +3 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/init.js +1 -0
- package/out/zero-cache/src/services/change-streamer/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/heapz.d.ts +1 -1
- package/out/zero-cache/src/services/heapz.d.ts.map +1 -1
- package/out/zero-cache/src/services/heapz.js +2 -2
- package/out/zero-cache/src/services/heapz.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts +36 -0
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.js +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/replicator/incremental-sync.js +2 -2
- package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
- package/out/zero-cache/src/services/statz.d.ts +1 -1
- package/out/zero-cache/src/services/statz.d.ts.map +1 -1
- package/out/zero-cache/src/services/statz.js +3 -3
- package/out/zero-cache/src/services/statz.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/active-users-gauge.d.ts +16 -0
- package/out/zero-cache/src/services/view-syncer/active-users-gauge.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/active-users-gauge.js +50 -0
- package/out/zero-cache/src/services/view-syncer/active-users-gauge.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/client-schema.js +1 -1
- package/out/zero-cache/src/services/view-syncer/client-schema.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-purger.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-purger.js +21 -5
- package/out/zero-cache/src/services/view-syncer/cvr-purger.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js +1 -1
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +2 -3
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +41 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-client/src/client/active-clients-manager.d.ts +2 -1
- package/out/zero-client/src/client/active-clients-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/delete-clients-manager.d.ts +3 -3
- package/out/zero-client/src/client/delete-clients-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/client-group.d.ts +12 -0
- package/out/zero-client/src/client/inspector/client-group.d.ts.map +1 -0
- package/out/zero-client/src/client/inspector/client.d.ts +15 -0
- package/out/zero-client/src/client/inspector/client.d.ts.map +1 -0
- package/out/zero-client/src/client/inspector/html-dialog-prompt.d.ts +5 -0
- package/out/zero-client/src/client/inspector/html-dialog-prompt.d.ts.map +1 -0
- package/out/zero-client/src/client/inspector/inspector.d.ts +14 -18
- package/out/zero-client/src/client/inspector/inspector.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.d.ts +49 -0
- package/out/zero-client/src/client/inspector/lazy-inspector.d.ts.map +1 -0
- package/out/zero-client/src/client/inspector/query.d.ts +31 -0
- package/out/zero-client/src/client/inspector/query.d.ts.map +1 -0
- package/out/zero-client/src/client/options.d.ts +8 -4
- package/out/zero-client/src/client/options.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +6 -6
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/mod.d.ts +4 -1
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-protocol/src/analyze-query-result.d.ts +22 -0
- package/out/zero-protocol/src/analyze-query-result.d.ts.map +1 -0
- package/out/zero-protocol/src/analyze-query-result.js +18 -0
- package/out/zero-protocol/src/analyze-query-result.js.map +1 -0
- package/out/zero-protocol/src/ast.d.ts +2 -0
- package/out/zero-protocol/src/ast.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.js +2 -0
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/down.d.ts +20 -0
- package/out/zero-protocol/src/down.d.ts.map +1 -1
- package/out/zero-protocol/src/inspect-down.d.ts +64 -0
- package/out/zero-protocol/src/inspect-down.d.ts.map +1 -1
- package/out/zero-protocol/src/inspect-down.js +10 -1
- package/out/zero-protocol/src/inspect-down.js.map +1 -1
- package/out/zero-protocol/src/inspect-up.d.ts +73 -10
- package/out/zero-protocol/src/inspect-up.d.ts.map +1 -1
- package/out/zero-protocol/src/inspect-up.js +20 -3
- package/out/zero-protocol/src/inspect-up.js.map +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.js +4 -1
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/up.d.ts +19 -1
- package/out/zero-protocol/src/up.d.ts.map +1 -1
- package/out/zero-react/src/use-query.d.ts.map +1 -1
- package/out/zero-react-native/src/mod.d.ts +2 -2
- package/out/zero-react-native/src/mod.d.ts.map +1 -1
- package/out/zero.js +4 -4
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +23 -11
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/builder/debug-delegate.d.ts +2 -5
- package/out/zql/src/builder/debug-delegate.d.ts.map +1 -1
- package/out/zql/src/builder/debug-delegate.js +1 -0
- package/out/zql/src/builder/debug-delegate.js.map +1 -1
- package/out/zql/src/ivm/constraint.js +1 -1
- package/out/zql/src/ivm/constraint.js.map +1 -1
- package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
- package/out/zql/src/ivm/fan-in.js +3 -92
- package/out/zql/src/ivm/fan-in.js.map +1 -1
- package/out/zql/src/ivm/fan-out.js +2 -2
- package/out/zql/src/ivm/fan-out.js.map +1 -1
- package/out/zql/src/ivm/flipped-join.d.ts +33 -0
- package/out/zql/src/ivm/flipped-join.d.ts.map +1 -0
- package/out/zql/src/ivm/flipped-join.js +341 -0
- package/out/zql/src/ivm/flipped-join.js.map +1 -0
- package/out/zql/src/ivm/join-utils.d.ts +14 -0
- package/out/zql/src/ivm/join-utils.d.ts.map +1 -0
- package/out/zql/src/ivm/join-utils.js +94 -0
- package/out/zql/src/ivm/join-utils.js.map +1 -0
- package/out/zql/src/ivm/join.d.ts +1 -1
- package/out/zql/src/ivm/join.d.ts.map +1 -1
- package/out/zql/src/ivm/join.js +3 -101
- package/out/zql/src/ivm/join.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +15 -4
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/push-accumulated.d.ts +88 -0
- package/out/zql/src/ivm/push-accumulated.d.ts.map +1 -0
- package/out/zql/src/ivm/push-accumulated.js +326 -0
- package/out/zql/src/ivm/push-accumulated.js.map +1 -0
- package/out/zql/src/query/expression.d.ts +3 -3
- package/out/zql/src/query/expression.d.ts.map +1 -1
- package/out/zql/src/query/expression.js +1 -1
- package/out/zql/src/query/expression.js.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +3 -4
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +12 -5
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query.d.ts +6 -3
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/query.js.map +1 -1
- package/out/zqlite/src/db.d.ts +1 -1
- package/out/zqlite/src/db.d.ts.map +1 -1
- package/out/zqlite/src/db.js +3 -3
- package/out/zqlite/src/db.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts +0 -1
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +4 -5
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +4 -4
- package/out/chunk-MKB4RXL3.js +0 -15
- package/out/chunk-MKB4RXL3.js.map +0 -7
- package/out/chunk-MLYQCVBG.js.map +0 -7
- package/out/chunk-V2KPKXLX.js.map +0 -7
- package/out/inspector-NC6TPMRA.js.map +0 -7
- package/out/replicache/src/expo/store.d.ts +0 -4
- package/out/replicache/src/expo/store.d.ts.map +0 -1
- package/out/zero-client/src/client/inspector/types.d.ts +0 -50
- package/out/zero-client/src/client/inspector/types.d.ts.map +0 -1
- /package/out/{chunk-FH5Q72JS.js.map → chunk-OQGMEB3H.js.map} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Client,
|
|
2
3
|
ENTITIES_KEY_PREFIX,
|
|
3
4
|
Latest,
|
|
4
5
|
SUBQ_PREFIX,
|
|
@@ -6,6 +7,8 @@ import {
|
|
|
6
7
|
getClient,
|
|
7
8
|
getClientGroup,
|
|
8
9
|
getClients,
|
|
10
|
+
inspectAnalyzeQueryDownSchema,
|
|
11
|
+
inspectAuthenticatedDownSchema,
|
|
9
12
|
inspectMetricsDownSchema,
|
|
10
13
|
inspectQueriesDownSchema,
|
|
11
14
|
inspectVersionDownSchema,
|
|
@@ -17,13 +20,88 @@ import {
|
|
|
17
20
|
test,
|
|
18
21
|
valita_exports,
|
|
19
22
|
withRead
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-QZPMFA73.js";
|
|
21
24
|
import {
|
|
22
25
|
assert,
|
|
23
26
|
unreachable
|
|
24
27
|
} from "./chunk-SGW2EIVJ.js";
|
|
25
28
|
import "./chunk-424PT5DM.js";
|
|
26
29
|
|
|
30
|
+
// ../zero-client/src/client/inspector/html-dialog-prompt.ts
|
|
31
|
+
function canUseHTMLDialog() {
|
|
32
|
+
try {
|
|
33
|
+
if (typeof globalThis !== "undefined" && "__vitest_worker__" in globalThis) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return typeof document !== "undefined" && typeof document.createElement === "function" && typeof HTMLDialogElement !== "undefined" && document.body !== null && // Make sure we can actually create a dialog element
|
|
37
|
+
document.createElement("dialog") instanceof HTMLDialogElement;
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function createHTMLPasswordPrompt(message) {
|
|
43
|
+
if (!canUseHTMLDialog()) {
|
|
44
|
+
return Promise.resolve(prompt(message));
|
|
45
|
+
}
|
|
46
|
+
return new Promise((resolve) => {
|
|
47
|
+
const reset = "all:revert;";
|
|
48
|
+
const w = "rgba(255,255,255,";
|
|
49
|
+
const white = w + "1)";
|
|
50
|
+
const whiteTransp = w + "0.4)";
|
|
51
|
+
const r1 = "0.25rem";
|
|
52
|
+
const font = `font-family:system-ui,sans-serif;color:${white};`;
|
|
53
|
+
const btnBase = `${reset}${font}cursor:pointer;font-size:1rem;font-weight:500;border:none;padding:0.4rem 0.75rem;border-radius:${r1};background:`;
|
|
54
|
+
const dialog = document.createElement("dialog");
|
|
55
|
+
dialog.style.cssText = `${reset}${font}background:rgba(0,0,0,0.95);padding:2rem;border:1px solid ${whiteTransp};border-radius:0.5rem;`;
|
|
56
|
+
dialog.addEventListener("keydown", (e) => {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
});
|
|
59
|
+
dialog.oncancel = () => {
|
|
60
|
+
dialog.remove();
|
|
61
|
+
resolve(null);
|
|
62
|
+
};
|
|
63
|
+
const form = document.createElement("form");
|
|
64
|
+
form.method = "dialog";
|
|
65
|
+
form.style.cssText = `${reset}margin:0;`;
|
|
66
|
+
const messagePara = document.createElement("p");
|
|
67
|
+
messagePara.style.cssText = `${reset}${font}font-size:1.5rem;margin:0 0 1rem 0;`;
|
|
68
|
+
messagePara.append(message);
|
|
69
|
+
const passwordInput = document.createElement("input");
|
|
70
|
+
passwordInput.type = "password";
|
|
71
|
+
passwordInput.placeholder = "Admin password";
|
|
72
|
+
passwordInput.autocomplete = "current-password";
|
|
73
|
+
passwordInput.autofocus = true;
|
|
74
|
+
passwordInput.style.cssText = `${reset}${font}font-size:1rem;display:block;margin:0 0 1rem 0;padding:0.5rem;background:rgba(0,0,0,0.5);border:1px solid ${whiteTransp};border-radius:${r1};`;
|
|
75
|
+
const buttonDiv = document.createElement("div");
|
|
76
|
+
buttonDiv.style.cssText = reset;
|
|
77
|
+
const cancelBtn = document.createElement("button");
|
|
78
|
+
cancelBtn.type = "reset";
|
|
79
|
+
cancelBtn.append("Cancel");
|
|
80
|
+
cancelBtn.style.cssText = btnBase + w + "0.25);";
|
|
81
|
+
const okBtn = document.createElement("button");
|
|
82
|
+
okBtn.type = "submit";
|
|
83
|
+
okBtn.value = "ok";
|
|
84
|
+
okBtn.append("OK");
|
|
85
|
+
okBtn.style.cssText = btnBase + "rgba(19,106,235,1);margin-right:0.5rem;";
|
|
86
|
+
buttonDiv.append(okBtn, cancelBtn);
|
|
87
|
+
form.append(messagePara, passwordInput, buttonDiv);
|
|
88
|
+
dialog.append(form);
|
|
89
|
+
form.onreset = () => {
|
|
90
|
+
dialog.close();
|
|
91
|
+
};
|
|
92
|
+
dialog.onclose = () => {
|
|
93
|
+
if (dialog.returnValue === "ok") {
|
|
94
|
+
resolve(passwordInput.value || null);
|
|
95
|
+
} else {
|
|
96
|
+
resolve(null);
|
|
97
|
+
}
|
|
98
|
+
dialog.remove();
|
|
99
|
+
};
|
|
100
|
+
document.body.append(dialog);
|
|
101
|
+
dialog.showModal();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
27
105
|
// ../ast-to-zql/src/ast-to-zql.ts
|
|
28
106
|
function astToZQL(ast) {
|
|
29
107
|
let code = "";
|
|
@@ -194,72 +272,101 @@ function transformParameter(param) {
|
|
|
194
272
|
return `authParam(${fieldStr})`;
|
|
195
273
|
}
|
|
196
274
|
|
|
197
|
-
// ../zero-client/src/client/inspector/
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
);
|
|
227
|
-
this.
|
|
228
|
-
this.
|
|
229
|
-
this
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
275
|
+
// ../zero-client/src/client/inspector/query.ts
|
|
276
|
+
var Query = class {
|
|
277
|
+
#socket;
|
|
278
|
+
name;
|
|
279
|
+
args;
|
|
280
|
+
got;
|
|
281
|
+
ttl;
|
|
282
|
+
inactivatedAt;
|
|
283
|
+
rowCount;
|
|
284
|
+
deleted;
|
|
285
|
+
id;
|
|
286
|
+
clientID;
|
|
287
|
+
metrics;
|
|
288
|
+
clientZQL;
|
|
289
|
+
serverZQL;
|
|
290
|
+
#serverAST;
|
|
291
|
+
hydrateClient;
|
|
292
|
+
hydrateServer;
|
|
293
|
+
hydrateTotal;
|
|
294
|
+
updateClientP50;
|
|
295
|
+
updateClientP95;
|
|
296
|
+
updateServerP50;
|
|
297
|
+
updateServerP95;
|
|
298
|
+
constructor(row, delegate, socket) {
|
|
299
|
+
this.#socket = socket;
|
|
300
|
+
const { ast, queryID, inactivatedAt } = row;
|
|
301
|
+
this.clientID = row.clientID;
|
|
302
|
+
this.id = queryID;
|
|
303
|
+
this.inactivatedAt = inactivatedAt === null ? null : new Date(inactivatedAt);
|
|
304
|
+
this.ttl = normalizeTTL(row.ttl);
|
|
305
|
+
this.name = row.name;
|
|
306
|
+
this.args = row.args;
|
|
307
|
+
this.got = row.got;
|
|
308
|
+
this.rowCount = row.rowCount;
|
|
309
|
+
this.deleted = row.deleted;
|
|
310
|
+
this.#serverAST = ast;
|
|
311
|
+
this.serverZQL = ast ? ast.table + astToZQL(ast) : null;
|
|
312
|
+
const clientAST = delegate.getAST(queryID);
|
|
313
|
+
this.clientZQL = clientAST ? clientAST.table + astToZQL(clientAST) : null;
|
|
314
|
+
const clientMetrics = delegate.getQueryMetrics(queryID);
|
|
315
|
+
const serverMetrics = row.metrics;
|
|
316
|
+
const merged = mergeMetrics(clientMetrics, serverMetrics);
|
|
317
|
+
this.metrics = merged;
|
|
318
|
+
const percentile = (name, percentile2) => {
|
|
319
|
+
if (!merged?.[name]) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
const n = merged[name].quantile(percentile2);
|
|
323
|
+
return Number.isNaN(n) ? null : n;
|
|
324
|
+
};
|
|
325
|
+
this.hydrateClient = percentile("query-materialization-client", 0.5);
|
|
326
|
+
this.hydrateServer = percentile("query-materialization-server", 0.5);
|
|
327
|
+
this.hydrateTotal = percentile("query-materialization-end-to-end", 0.5);
|
|
328
|
+
this.updateClientP50 = percentile("query-update-client", 0.5);
|
|
329
|
+
this.updateClientP95 = percentile("query-update-client", 0.95);
|
|
330
|
+
this.updateServerP50 = percentile("query-update-server", 0.5);
|
|
331
|
+
this.updateServerP95 = percentile("query-update-server", 0.95);
|
|
332
|
+
}
|
|
333
|
+
async analyze(options) {
|
|
334
|
+
assert(this.#serverAST, "No server AST available for this query");
|
|
335
|
+
return rpc(
|
|
336
|
+
await this.#socket(),
|
|
337
|
+
{
|
|
338
|
+
op: "analyze-query",
|
|
339
|
+
value: this.#serverAST,
|
|
340
|
+
options
|
|
341
|
+
},
|
|
342
|
+
inspectAnalyzeQueryDownSchema
|
|
256
343
|
);
|
|
257
344
|
}
|
|
258
|
-
async serverVersion() {
|
|
259
|
-
return rpc(await this.socket(), { op: "version" }, inspectVersionDownSchema);
|
|
260
|
-
}
|
|
261
345
|
};
|
|
262
|
-
|
|
346
|
+
|
|
347
|
+
// ../zero-client/src/client/inspector/lazy-inspector.ts
|
|
348
|
+
async function rpc(socket, arg, downSchema) {
|
|
349
|
+
try {
|
|
350
|
+
return await rpcNoAuthTry(socket, arg, downSchema);
|
|
351
|
+
} catch (e) {
|
|
352
|
+
if (e instanceof UnauthenticatedError) {
|
|
353
|
+
const password = await createHTMLPasswordPrompt("Enter password:");
|
|
354
|
+
if (password) {
|
|
355
|
+
const authRes = await rpcNoAuthTry(
|
|
356
|
+
socket,
|
|
357
|
+
{ op: "authenticate", value: password },
|
|
358
|
+
inspectAuthenticatedDownSchema
|
|
359
|
+
);
|
|
360
|
+
if (authRes) {
|
|
361
|
+
return rpcNoAuthTry(socket, arg, downSchema);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
throw new Error("Authentication failed");
|
|
365
|
+
}
|
|
366
|
+
throw e;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function rpcNoAuthTry(socket, arg, downSchema) {
|
|
263
370
|
return new Promise((resolve, reject) => {
|
|
264
371
|
const id = nanoid();
|
|
265
372
|
const f = (ev) => {
|
|
@@ -273,118 +380,65 @@ function rpc(socket, arg, downSchema) {
|
|
|
273
380
|
if (res.ok) {
|
|
274
381
|
resolve(res.value.value);
|
|
275
382
|
} else {
|
|
383
|
+
const authRes = test(body, inspectAuthenticatedDownSchema);
|
|
384
|
+
if (authRes.ok) {
|
|
385
|
+
assert(
|
|
386
|
+
authRes.value.value === false,
|
|
387
|
+
"Expected unauthenticated response"
|
|
388
|
+
);
|
|
389
|
+
reject(new UnauthenticatedError());
|
|
390
|
+
}
|
|
276
391
|
reject(res.error);
|
|
277
392
|
}
|
|
278
393
|
socket.removeEventListener("message", f);
|
|
279
394
|
}
|
|
280
395
|
};
|
|
281
396
|
socket.addEventListener("message", f);
|
|
282
|
-
socket.send(
|
|
283
|
-
JSON.stringify(["inspect", { ...arg, id }])
|
|
284
|
-
);
|
|
397
|
+
socket.send(JSON.stringify(["inspect", { ...arg, id }]));
|
|
285
398
|
});
|
|
286
399
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
for await (const [key, value] of tree.scan(prefix)) {
|
|
330
|
-
if (!key.startsWith(prefix)) {
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
rows.push(value);
|
|
334
|
-
}
|
|
335
|
-
return rows;
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
var ClientGroup = class {
|
|
340
|
-
#rep;
|
|
341
|
-
id;
|
|
342
|
-
#schema;
|
|
343
|
-
#socket;
|
|
344
|
-
#delegate;
|
|
345
|
-
constructor(rep, delegate, socket, schema, id) {
|
|
346
|
-
this.#rep = rep;
|
|
347
|
-
this.#delegate = delegate;
|
|
348
|
-
this.#socket = socket;
|
|
349
|
-
this.#schema = schema;
|
|
350
|
-
this.id = id;
|
|
351
|
-
}
|
|
352
|
-
clients() {
|
|
353
|
-
return withDagRead(
|
|
354
|
-
this.#rep,
|
|
355
|
-
(dagRead) => clients(
|
|
356
|
-
this.#rep,
|
|
357
|
-
this.#delegate,
|
|
358
|
-
this.#socket,
|
|
359
|
-
this.#schema,
|
|
360
|
-
dagRead,
|
|
361
|
-
([_, v]) => v.clientGroupID === this.id
|
|
362
|
-
)
|
|
363
|
-
);
|
|
364
|
-
}
|
|
365
|
-
clientsWithQueries() {
|
|
366
|
-
return withDagRead(
|
|
367
|
-
this.#rep,
|
|
368
|
-
(dagRead) => clientsWithQueries(
|
|
369
|
-
this.#rep,
|
|
370
|
-
this.#delegate,
|
|
371
|
-
this.#socket,
|
|
372
|
-
this.#schema,
|
|
373
|
-
dagRead,
|
|
374
|
-
([_, v]) => v.clientGroupID === this.id
|
|
375
|
-
)
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
async queries() {
|
|
379
|
-
const rows = await rpc(
|
|
380
|
-
await this.#socket(),
|
|
381
|
-
{ op: "queries" },
|
|
382
|
-
inspectQueriesDownSchema
|
|
383
|
-
);
|
|
384
|
-
return rows.map((row) => new Query(row, this.#delegate));
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
async function withDagRead(rep, f) {
|
|
400
|
+
function mergeMetrics(clientMetrics, serverMetrics) {
|
|
401
|
+
return {
|
|
402
|
+
...clientMetrics ?? newClientMetrics(),
|
|
403
|
+
...serverMetrics ? convertServerMetrics(serverMetrics) : newServerMetrics()
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function newClientMetrics() {
|
|
407
|
+
return {
|
|
408
|
+
"query-materialization-client": new TDigest(),
|
|
409
|
+
"query-materialization-end-to-end": new TDigest(),
|
|
410
|
+
"query-update-client": new TDigest()
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function newServerMetrics() {
|
|
414
|
+
return {
|
|
415
|
+
"query-materialization-server": new TDigest(),
|
|
416
|
+
"query-update-server": new TDigest()
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function convertServerMetrics(metrics) {
|
|
420
|
+
return mapValues(metrics, (v) => TDigest.fromJSON(v));
|
|
421
|
+
}
|
|
422
|
+
async function inspectorMetrics(delegate) {
|
|
423
|
+
const clientMetrics = delegate.metrics;
|
|
424
|
+
const serverMetricsJSON = await rpc(
|
|
425
|
+
await delegate.getSocket(),
|
|
426
|
+
{ op: "metrics" },
|
|
427
|
+
inspectMetricsDownSchema
|
|
428
|
+
);
|
|
429
|
+
return mergeMetrics(clientMetrics, serverMetricsJSON);
|
|
430
|
+
}
|
|
431
|
+
function inspectorClients(delegate) {
|
|
432
|
+
return withDagRead(delegate, (dagRead) => clients(delegate, dagRead));
|
|
433
|
+
}
|
|
434
|
+
function inspectorClientsWithQueries(delegate) {
|
|
435
|
+
return withDagRead(
|
|
436
|
+
delegate,
|
|
437
|
+
(dagRead) => clientsWithQueries(delegate, dagRead)
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
async function withDagRead(delegate, f) {
|
|
441
|
+
const { rep } = delegate;
|
|
388
442
|
await rep.refresh();
|
|
389
443
|
await rep.persist();
|
|
390
444
|
return withRead(rep.perdag, f);
|
|
@@ -402,21 +456,14 @@ async function getBTree(dagRead, clientID) {
|
|
|
402
456
|
);
|
|
403
457
|
return dbRead.map;
|
|
404
458
|
}
|
|
405
|
-
async function clients(
|
|
459
|
+
async function clients(delegate, dagRead, predicate = () => true) {
|
|
406
460
|
const clients2 = await getClients(dagRead);
|
|
407
461
|
return [...clients2.entries()].filter(predicate).map(
|
|
408
|
-
([clientID, { clientGroupID }]) => new Client(
|
|
462
|
+
([clientID, { clientGroupID }]) => new Client(delegate, clientID, clientGroupID)
|
|
409
463
|
);
|
|
410
464
|
}
|
|
411
|
-
async function clientsWithQueries(
|
|
412
|
-
const allClients = await clients(
|
|
413
|
-
rep,
|
|
414
|
-
delegate,
|
|
415
|
-
socket,
|
|
416
|
-
schema,
|
|
417
|
-
dagRead,
|
|
418
|
-
predicate
|
|
419
|
-
);
|
|
465
|
+
async function clientsWithQueries(delegate, dagRead, predicate = () => true) {
|
|
466
|
+
const allClients = await clients(delegate, dagRead, predicate);
|
|
420
467
|
const clientsWithQueries2 = [];
|
|
421
468
|
await Promise.all(
|
|
422
469
|
allClients.map(async (client) => {
|
|
@@ -428,61 +475,81 @@ async function clientsWithQueries(rep, delegate, socket, schema, dagRead, predic
|
|
|
428
475
|
);
|
|
429
476
|
return clientsWithQueries2;
|
|
430
477
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
rowCount;
|
|
438
|
-
deleted;
|
|
439
|
-
id;
|
|
440
|
-
clientID;
|
|
441
|
-
metrics;
|
|
442
|
-
clientZQL;
|
|
443
|
-
serverZQL;
|
|
444
|
-
constructor(row, delegate) {
|
|
445
|
-
const { ast, queryID, inactivatedAt } = row;
|
|
446
|
-
this.clientID = row.clientID;
|
|
447
|
-
this.id = queryID;
|
|
448
|
-
this.inactivatedAt = inactivatedAt === null ? null : new Date(inactivatedAt);
|
|
449
|
-
this.ttl = normalizeTTL(row.ttl);
|
|
450
|
-
this.name = row.name;
|
|
451
|
-
this.args = row.args;
|
|
452
|
-
this.got = row.got;
|
|
453
|
-
this.rowCount = row.rowCount;
|
|
454
|
-
this.deleted = row.deleted;
|
|
455
|
-
this.serverZQL = ast ? ast.table + astToZQL(ast) : null;
|
|
456
|
-
const clientAST = delegate.getAST(queryID);
|
|
457
|
-
this.clientZQL = clientAST ? clientAST.table + astToZQL(clientAST) : null;
|
|
458
|
-
const clientMetrics = delegate.getQueryMetrics(queryID);
|
|
459
|
-
const serverMetrics = row.metrics;
|
|
460
|
-
this.metrics = mergeMetrics(clientMetrics, serverMetrics);
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
function mergeMetrics(clientMetrics, serverMetrics) {
|
|
464
|
-
return {
|
|
465
|
-
...clientMetrics ?? newClientMetrics(),
|
|
466
|
-
...serverMetrics ? convertServerMetrics(serverMetrics) : newServerMetrics()
|
|
467
|
-
};
|
|
478
|
+
async function clientGroupClients(delegate, clientGroupID) {
|
|
479
|
+
const id = await clientGroupID;
|
|
480
|
+
return withDagRead(
|
|
481
|
+
delegate,
|
|
482
|
+
(dagRead) => clients(delegate, dagRead, ([_, v]) => v.clientGroupID === id)
|
|
483
|
+
);
|
|
468
484
|
}
|
|
469
|
-
function
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
485
|
+
async function clientGroupClientsWithQueries(delegate, clientGroupID) {
|
|
486
|
+
const id = await clientGroupID;
|
|
487
|
+
return withDagRead(
|
|
488
|
+
delegate,
|
|
489
|
+
(dagRead) => clientsWithQueries(delegate, dagRead, ([_, v]) => v.clientGroupID === id)
|
|
490
|
+
);
|
|
475
491
|
}
|
|
476
|
-
function
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
"
|
|
480
|
-
|
|
492
|
+
async function clientGroupQueries(delegate) {
|
|
493
|
+
const rows = await rpc(
|
|
494
|
+
await delegate.getSocket(),
|
|
495
|
+
{ op: "queries" },
|
|
496
|
+
inspectQueriesDownSchema
|
|
497
|
+
);
|
|
498
|
+
return rows.map((row) => new Query(row, delegate, delegate.getSocket));
|
|
481
499
|
}
|
|
482
|
-
function
|
|
483
|
-
return
|
|
500
|
+
function clientMap(delegate, clientID) {
|
|
501
|
+
return withDagRead(delegate, async (dagRead) => {
|
|
502
|
+
const tree = await getBTree(dagRead, clientID);
|
|
503
|
+
const map = /* @__PURE__ */ new Map();
|
|
504
|
+
for await (const [key, value] of tree.scan("")) {
|
|
505
|
+
map.set(key, value);
|
|
506
|
+
}
|
|
507
|
+
return map;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function clientRows(delegate, clientID, tableName) {
|
|
511
|
+
return withDagRead(delegate, async (dagRead) => {
|
|
512
|
+
const prefix = ENTITIES_KEY_PREFIX + tableName + "/";
|
|
513
|
+
const tree = await getBTree(dagRead, clientID);
|
|
514
|
+
const rows = [];
|
|
515
|
+
for await (const [key, value] of tree.scan(prefix)) {
|
|
516
|
+
if (!key.startsWith(prefix)) {
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
rows.push(value);
|
|
520
|
+
}
|
|
521
|
+
return rows;
|
|
522
|
+
});
|
|
484
523
|
}
|
|
524
|
+
async function serverVersion(delegate) {
|
|
525
|
+
return rpc(
|
|
526
|
+
await delegate.getSocket(),
|
|
527
|
+
{ op: "version" },
|
|
528
|
+
inspectVersionDownSchema
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
async function clientQueries(delegate, clientID) {
|
|
532
|
+
const rows = await rpc(
|
|
533
|
+
await delegate.getSocket(),
|
|
534
|
+
{ op: "queries", clientID },
|
|
535
|
+
inspectQueriesDownSchema
|
|
536
|
+
);
|
|
537
|
+
return rows.map((row) => new Query(row, delegate, delegate.getSocket));
|
|
538
|
+
}
|
|
539
|
+
var UnauthenticatedError = class extends Error {
|
|
540
|
+
};
|
|
485
541
|
export {
|
|
486
|
-
|
|
542
|
+
clientGroupClients,
|
|
543
|
+
clientGroupClientsWithQueries,
|
|
544
|
+
clientGroupQueries,
|
|
545
|
+
clientMap,
|
|
546
|
+
clientQueries,
|
|
547
|
+
clientRows,
|
|
548
|
+
inspectorClients,
|
|
549
|
+
inspectorClientsWithQueries,
|
|
550
|
+
inspectorMetrics,
|
|
551
|
+
mergeMetrics,
|
|
552
|
+
rpc,
|
|
553
|
+
serverVersion
|
|
487
554
|
};
|
|
488
|
-
//# sourceMappingURL=inspector-
|
|
555
|
+
//# sourceMappingURL=lazy-inspector-TOTYUTBC.js.map
|