@rocicorp/zero 0.24.2025100900 → 0.24.2025101200
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.d.ts.map +1 -1
- package/out/analyze-query/src/bin-analyze.js +4 -3
- package/out/analyze-query/src/bin-analyze.js.map +1 -1
- package/out/analyze-query/src/run-ast.d.ts.map +1 -1
- package/out/analyze-query/src/run-ast.js +12 -4
- package/out/analyze-query/src/run-ast.js.map +1 -1
- package/out/ast-to-zql/src/ast-to-zql.js +1 -1
- package/out/ast-to-zql/src/ast-to-zql.js.map +1 -1
- package/out/{chunk-2MVN6X6T.js → chunk-5J6ROZSO.js} +4521 -164
- package/out/chunk-5J6ROZSO.js.map +7 -0
- package/out/{chunk-IQYQOLDZ.js → chunk-6AP73APB.js} +15 -8
- package/out/chunk-6AP73APB.js.map +7 -0
- package/out/chunk-HLJ3FQU5.js +4122 -0
- package/out/chunk-HLJ3FQU5.js.map +7 -0
- package/out/{lazy-inspector-A5VQLZYJ.js → lazy-inspector-YKNSCAI3.js} +21 -3
- package/out/lazy-inspector-YKNSCAI3.js.map +7 -0
- package/out/react-native.js +1 -71
- package/out/react-native.js.map +4 -4
- package/out/react.js +2 -2
- package/out/replicache/src/btree/read.d.ts.map +1 -1
- package/out/replicache/src/btree/write.d.ts.map +1 -1
- package/out/replicache/src/dag/lazy-store.d.ts.map +1 -1
- package/out/replicache/src/persist/gather-not-cached-visitor.d.ts.map +1 -1
- package/out/shared/src/size-of-value.d.ts.map +1 -0
- package/out/solid.js +7 -7
- package/out/solid.js.map +2 -2
- package/out/zero/package.json +8 -7
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +1 -0
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.d.ts +10 -0
- package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
- package/out/zero-cache/src/server/inspector-delegate.js +33 -0
- package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +8 -3
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
- package/out/zero-cache/src/services/analyze.js +2 -2
- package/out/zero-cache/src/services/analyze.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +6 -5
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js +26 -22
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts +50 -36
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/run-ast.d.ts +21 -0
- package/out/zero-cache/src/services/run-ast.d.ts.map +1 -0
- package/out/zero-cache/src/services/run-ast.js +91 -0
- package/out/zero-cache/src/services/run-ast.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +10 -0
- package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js +95 -0
- package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -0
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +6 -5
- 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 +59 -115
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-client/src/client/inspector/inspector.d.ts +4 -0
- package/out/zero-client/src/client/inspector/inspector.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.d.ts +4 -1
- package/out/zero-client/src/client/inspector/lazy-inspector.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +4 -4
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/mod.d.ts +1 -1
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-events/src/index.d.ts +4 -6
- package/out/zero-events/src/index.d.ts.map +1 -1
- package/out/zero-events/src/index.js +1 -27
- package/out/zero-events/src/index.js.map +1 -1
- package/out/zero-events/src/status.d.ts +43 -111
- package/out/zero-events/src/status.d.ts.map +1 -1
- package/out/zero-events/src/status.js +2 -73
- package/out/zero-events/src/status.js.map +1 -1
- package/out/zero-events/src/util.d.ts +26 -0
- package/out/zero-events/src/util.d.ts.map +1 -0
- package/out/zero-events/src/util.js +2 -0
- package/out/zero-events/src/util.js.map +1 -0
- package/out/zero-protocol/src/analyze-query-result.d.ts +5 -0
- package/out/zero-protocol/src/analyze-query-result.d.ts.map +1 -1
- package/out/zero-protocol/src/analyze-query-result.js +5 -0
- package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
- package/out/zero-protocol/src/ast.d.ts +2 -1
- package/out/zero-protocol/src/ast.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.js +1 -0
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/down.d.ts +8 -0
- package/out/zero-protocol/src/down.d.ts.map +1 -1
- package/out/zero-protocol/src/inspect-down.d.ts +26 -0
- package/out/zero-protocol/src/inspect-down.d.ts.map +1 -1
- package/out/zero-protocol/src/inspect-down.js +5 -1
- package/out/zero-protocol/src/inspect-down.js.map +1 -1
- package/out/zero-protocol/src/inspect-up.d.ts +18 -6
- package/out/zero-protocol/src/inspect-up.d.ts.map +1 -1
- package/out/zero-protocol/src/inspect-up.js +6 -1
- 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 +3 -1
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/push.d.ts +1 -1
- package/out/zero-protocol/src/push.d.ts.map +1 -1
- package/out/zero-protocol/src/up.d.ts +5 -2
- package/out/zero-protocol/src/up.d.ts.map +1 -1
- package/out/zero-react-native/src/mod.d.ts +0 -1
- package/out/zero-react-native/src/mod.d.ts.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.d.ts +3 -25
- package/out/zero-schema/src/builder/schema-builder.d.ts.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
- package/out/zero-schema/src/name-mapper.d.ts +2 -19
- package/out/zero-schema/src/name-mapper.d.ts.map +1 -1
- package/out/zero-schema/src/name-mapper.js +2 -44
- package/out/zero-schema/src/name-mapper.js.map +1 -1
- package/out/zero-schema/src/permissions.d.ts +1 -0
- package/out/zero-schema/src/permissions.d.ts.map +1 -1
- package/out/zero-schema/src/schema-config.d.ts +1 -1
- package/out/zero-schema/src/table-schema.d.ts +3 -55
- package/out/zero-schema/src/table-schema.d.ts.map +1 -1
- package/out/zero-schema/src/table-schema.js +0 -6
- package/out/zero-schema/src/table-schema.js.map +1 -1
- package/out/zero-server/src/process-mutations.d.ts +1 -1
- package/out/zero-server/src/process-mutations.d.ts.map +1 -1
- package/out/zero-server/src/query.d.ts +2 -2
- package/out/zero-server/src/query.d.ts.map +1 -1
- package/out/zero-server/src/query.js +2 -1
- package/out/zero-server/src/query.js.map +1 -1
- package/out/zero-server/src/zql-database.d.ts +1 -1
- package/out/zero-server/src/zql-database.d.ts.map +1 -1
- package/out/zero-server/src/zql-database.js +10 -0
- package/out/zero-server/src/zql-database.js.map +1 -1
- package/out/zero-solid/src/use-query.d.ts +3 -1
- package/out/zero-solid/src/use-query.d.ts.map +1 -1
- package/out/zero-solid/src/use-zero.d.ts +4 -1
- package/out/zero-solid/src/use-zero.d.ts.map +1 -1
- package/out/zero-types/src/format.d.ts +11 -0
- package/out/zero-types/src/format.d.ts.map +1 -0
- package/out/zero-types/src/format.js +5 -0
- package/out/zero-types/src/format.js.map +1 -0
- package/out/zero-types/src/name-mapper.d.ts +19 -0
- package/out/zero-types/src/name-mapper.d.ts.map +1 -0
- package/out/zero-types/src/name-mapper.js +45 -0
- package/out/zero-types/src/name-mapper.js.map +1 -0
- package/out/zero-types/src/schema-value.d.ts +36 -0
- package/out/zero-types/src/schema-value.d.ts.map +1 -0
- package/out/zero-types/src/schema-value.js +2 -0
- package/out/zero-types/src/schema-value.js.map +1 -0
- package/out/zero-types/src/schema.d.ts +54 -0
- package/out/zero-types/src/schema.d.ts.map +1 -0
- package/out/zero-types/src/schema.js +2 -0
- package/out/zero-types/src/schema.js.map +1 -0
- package/out/zero.js +4 -5
- package/out/zql/src/ivm/default-format.d.ts +2 -0
- package/out/zql/src/ivm/default-format.d.ts.map +1 -0
- package/out/zql/src/ivm/default-format.js +2 -0
- package/out/zql/src/ivm/default-format.js.map +1 -0
- package/out/zql/src/ivm/memory-source.d.ts +2 -2
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +2 -2
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/schema.d.ts +1 -1
- package/out/zql/src/ivm/schema.d.ts.map +1 -1
- package/out/zql/src/ivm/view.d.ts +3 -5
- package/out/zql/src/ivm/view.d.ts.map +1 -1
- package/out/zql/src/mutate/custom.d.ts +2 -2
- package/out/zql/src/mutate/custom.d.ts.map +1 -1
- package/out/zql/src/mutate/custom.js.map +1 -1
- package/out/zql/src/query/expression.d.ts +1 -1
- package/out/zql/src/query/expression.d.ts.map +1 -1
- package/out/zql/src/query/named.d.ts +2 -3
- package/out/zql/src/query/named.d.ts.map +1 -1
- package/out/zql/src/query/named.js.map +1 -1
- package/out/zql/src/query/query-delegate.d.ts +1 -1
- package/out/zql/src/query/query-delegate.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +4 -10
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +12 -19
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query.d.ts +7 -5
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/query.js.map +1 -1
- package/out/zql/src/query/static-query.d.ts +1 -1
- package/out/zql/src/query/static-query.d.ts.map +1 -1
- package/out/zql/src/query/static-query.js +2 -1
- package/out/zql/src/query/static-query.js.map +1 -1
- package/out/zqlite/src/explain-queries.d.ts +4 -0
- package/out/zqlite/src/explain-queries.d.ts.map +1 -0
- package/out/zqlite/src/explain-queries.js +18 -0
- package/out/zqlite/src/explain-queries.js.map +1 -0
- package/out/zqlite/src/mod.d.ts +2 -1
- package/out/zqlite/src/mod.d.ts.map +1 -1
- package/out/zqlite/src/mod.js +2 -1
- package/out/zqlite/src/mod.js.map +1 -1
- package/package.json +8 -7
- package/out/chunk-2MVN6X6T.js.map +0 -7
- package/out/chunk-IQYQOLDZ.js.map +0 -7
- package/out/chunk-YXYKEMHQ.js +0 -8491
- package/out/chunk-YXYKEMHQ.js.map +0 -7
- package/out/lazy-inspector-A5VQLZYJ.js.map +0 -7
- package/out/replicache/src/kv/op-sqlite/store.d.ts +0 -14
- package/out/replicache/src/kv/op-sqlite/store.d.ts.map +0 -1
- package/out/replicache/src/kv/op-sqlite/types.d.ts +0 -13
- package/out/replicache/src/kv/op-sqlite/types.d.ts.map +0 -1
- package/out/replicache/src/size-of-value.d.ts.map +0 -1
- /package/out/{replicache → shared}/src/size-of-value.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pusher.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/mutagen/pusher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAMjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uCAAuC,CAAC;AAEtE,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,QAAQ,E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AAC,MAAM,EAAE,UAAU;IAW7C,GAAG;IAKH,KAAK;IAQL,OAAO,IAAI,OAAO;IAIlB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAKpB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQtB;AAED,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,KAAK,iBAAiB,GAAG,WAAW,GAAG,MAAM,CAAC;AAsS9C;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,CAAC,iBAAiB,GAAG,SAAS,CAAC,EAAE,GAClD,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAqC1B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LogContext } from '@rocicorp/logger';
|
|
2
|
+
import type { AnalyzeQueryResult } from '../../../zero-protocol/src/analyze-query-result.ts';
|
|
3
|
+
import type { AST } from '../../../zero-protocol/src/ast.ts';
|
|
4
|
+
import type { PermissionsConfig } from '../../../zero-schema/src/compiled-permissions.ts';
|
|
5
|
+
import type { NameMapper } from '../../../zero-schema/src/name-mapper.ts';
|
|
6
|
+
import { type BuilderDelegate } from '../../../zql/src/builder/builder.ts';
|
|
7
|
+
import type { Database } from '../../../zqlite/src/db.ts';
|
|
8
|
+
import type { LiteAndZqlSpec } from '../db/specs.ts';
|
|
9
|
+
export type RunAstOptions = {
|
|
10
|
+
applyPermissions?: boolean | undefined;
|
|
11
|
+
authData?: string | undefined;
|
|
12
|
+
clientToServerMapper?: NameMapper | undefined;
|
|
13
|
+
db: Database;
|
|
14
|
+
host: BuilderDelegate;
|
|
15
|
+
permissions?: PermissionsConfig | undefined;
|
|
16
|
+
syncedRows?: boolean | undefined;
|
|
17
|
+
tableSpecs: Map<string, LiteAndZqlSpec>;
|
|
18
|
+
vendedRows?: boolean | undefined;
|
|
19
|
+
};
|
|
20
|
+
export declare function runAst(lc: LogContext, ast: AST, isTransformed: boolean, options: RunAstOptions): Promise<AnalyzeQueryResult>;
|
|
21
|
+
//# sourceMappingURL=run-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-ast.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/services/run-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAQ5C,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oDAAoD,CAAC;AAC3F,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,mCAAmC,CAAC;AAI3D,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,kDAAkD,CAAC;AACxF,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AAGxD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAGnD,MAAM,MAAM,aAAa,GAAG;IAC1B,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,oBAAoB,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9C,EAAE,EAAE,QAAQ,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;IACtB,WAAW,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC5C,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,wBAAsB,MAAM,CAC1B,EAAE,EAAE,UAAU,EACd,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,OAAO,EACtB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,kBAAkB,CAAC,CA6F7B"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { LogContext } from '@rocicorp/logger';
|
|
2
|
+
// @circular-dep-ignore
|
|
3
|
+
import { astToZQL } from "../../../ast-to-zql/src/ast-to-zql.js";
|
|
4
|
+
// @circular-dep-ignore
|
|
5
|
+
import { formatOutput } from "../../../ast-to-zql/src/format.js";
|
|
6
|
+
import { assert } from "../../../shared/src/asserts.js";
|
|
7
|
+
import { must } from "../../../shared/src/must.js";
|
|
8
|
+
import { sleep } from "../../../shared/src/sleep.js";
|
|
9
|
+
import { mapAST } from "../../../zero-protocol/src/ast.js";
|
|
10
|
+
import { hashOfAST } from "../../../zero-protocol/src/query-hash.js";
|
|
11
|
+
import { buildPipeline, } from "../../../zql/src/builder/builder.js";
|
|
12
|
+
import { transformAndHashQuery } from "../auth/read-authorizer.js";
|
|
13
|
+
import { computeZqlSpecs } from "../db/lite-tables.js";
|
|
14
|
+
import { hydrate } from "./view-syncer/pipeline-driver.js";
|
|
15
|
+
export async function runAst(lc, ast, isTransformed, options) {
|
|
16
|
+
const { clientToServerMapper, permissions, host, db } = options;
|
|
17
|
+
const result = {
|
|
18
|
+
warnings: [],
|
|
19
|
+
syncedRows: undefined,
|
|
20
|
+
syncedRowCount: 0,
|
|
21
|
+
start: 0,
|
|
22
|
+
end: 0,
|
|
23
|
+
afterPermissions: undefined,
|
|
24
|
+
readRows: undefined,
|
|
25
|
+
readRowCountsByQuery: {},
|
|
26
|
+
readRowCount: undefined,
|
|
27
|
+
};
|
|
28
|
+
if (!isTransformed) {
|
|
29
|
+
// map the AST to server names if not already transformed
|
|
30
|
+
ast = mapAST(ast, must(clientToServerMapper));
|
|
31
|
+
}
|
|
32
|
+
if (options.applyPermissions) {
|
|
33
|
+
const authData = options.authData ? JSON.parse(options.authData) : {};
|
|
34
|
+
if (!options.authData) {
|
|
35
|
+
result.warnings.push('No auth data provided. Permission rules will compare to `NULL` wherever an auth data field is referenced.');
|
|
36
|
+
}
|
|
37
|
+
ast = transformAndHashQuery(lc, 'clientGroupIDForAnalyze', ast, must(permissions), authData, false).transformedAst;
|
|
38
|
+
result.afterPermissions = await formatOutput(ast.table + astToZQL(ast));
|
|
39
|
+
}
|
|
40
|
+
const tableSpecs = computeZqlSpecs(lc, db);
|
|
41
|
+
const pipeline = buildPipeline(ast, host, 'query-id');
|
|
42
|
+
const start = performance.now();
|
|
43
|
+
let syncedRowCount = 0;
|
|
44
|
+
const rowsByTable = {};
|
|
45
|
+
const seenByTable = new Set();
|
|
46
|
+
for (const rowChange of hydrate(pipeline, hashOfAST(ast), tableSpecs)) {
|
|
47
|
+
assert(rowChange.type === 'add');
|
|
48
|
+
// yield to other tasks to avoid blocking for too long
|
|
49
|
+
if (syncedRowCount % 10 === 0) {
|
|
50
|
+
await Promise.resolve();
|
|
51
|
+
}
|
|
52
|
+
if (syncedRowCount % 100 === 0) {
|
|
53
|
+
await sleep(1);
|
|
54
|
+
}
|
|
55
|
+
let rows = rowsByTable[rowChange.table];
|
|
56
|
+
const s = rowChange.table + '.' + JSON.stringify(rowChange.row);
|
|
57
|
+
if (seenByTable.has(s)) {
|
|
58
|
+
continue; // skip duplicates
|
|
59
|
+
}
|
|
60
|
+
syncedRowCount++;
|
|
61
|
+
seenByTable.add(s);
|
|
62
|
+
if (options.syncedRows) {
|
|
63
|
+
if (!rows) {
|
|
64
|
+
rows = [];
|
|
65
|
+
rowsByTable[rowChange.table] = rows;
|
|
66
|
+
}
|
|
67
|
+
rows.push(rowChange.row);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const end = performance.now();
|
|
71
|
+
if (options.syncedRows) {
|
|
72
|
+
result.syncedRows = rowsByTable;
|
|
73
|
+
}
|
|
74
|
+
result.start = start;
|
|
75
|
+
result.end = end;
|
|
76
|
+
// Always include the count of synced and vended rows.
|
|
77
|
+
result.syncedRowCount = syncedRowCount;
|
|
78
|
+
result.readRowCountsByQuery = host.debug?.getVendedRowCounts() ?? {};
|
|
79
|
+
let readRowCount = 0;
|
|
80
|
+
for (const c of Object.values(result.readRowCountsByQuery)) {
|
|
81
|
+
for (const v of Object.values(c)) {
|
|
82
|
+
readRowCount += v;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
result.readRowCount = readRowCount;
|
|
86
|
+
if (options.vendedRows) {
|
|
87
|
+
result.readRows = host.debug?.getVendedRows();
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=run-ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-ast.js","sourceRoot":"","sources":["../../../../../zero-cache/src/services/run-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,uBAAuB;AACvB,OAAO,EAAC,QAAQ,EAAC,MAAM,uCAAuC,CAAC;AAC/D,uBAAuB;AACvB,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAC,IAAI,EAAC,MAAM,6BAA6B,CAAC;AACjD,OAAO,EAAC,KAAK,EAAC,MAAM,8BAA8B,CAAC;AAGnD,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAEzD,OAAO,EAAC,SAAS,EAAC,MAAM,0CAA0C,CAAC;AAGnE,OAAO,EACL,aAAa,GAEd,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAC,OAAO,EAAC,MAAM,kCAAkC,CAAC;AAczD,MAAM,CAAC,KAAK,UAA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ACH,CAAC;IAED,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC9B,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,MAAM,CAAC,UAAU,GAAG,WAAW,CAAC;IAClC,CAAC;IACD,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IAEjB,sDAAsD;IACtD,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;IACrE,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC3D,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YACjC,YAAY,IAAI,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;IAEnC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC;IAChD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LogContext } from '@rocicorp/logger';
|
|
2
|
+
import type { InspectUpBody } from '../../../../zero-protocol/src/inspect-up.ts';
|
|
3
|
+
import type { NormalizedZeroConfig } from '../../config/normalize.ts';
|
|
4
|
+
import type { HeaderOptions } from '../../custom/fetch.ts';
|
|
5
|
+
import type { InspectorDelegate } from '../../server/inspector-delegate.ts';
|
|
6
|
+
import type { ClientHandler } from './client-handler.ts';
|
|
7
|
+
import type { CVRStore } from './cvr-store.ts';
|
|
8
|
+
import type { CVRSnapshot } from './cvr.ts';
|
|
9
|
+
export declare function handleInspect(lc: LogContext, body: InspectUpBody, cvr: CVRSnapshot, client: ClientHandler, inspectorDelegate: InspectorDelegate, clientGroupID: string, cvrStore: CVRStore, config: NormalizedZeroConfig, headerOptions: HeaderOptions, userQueryURL: string | undefined): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=inspect-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect-handler.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/view-syncer/inspect-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,6CAA6C,CAAC;AAC/E,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAKpE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAE1C,wBAAsB,aAAa,CACjC,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,aAAa,EACrB,iBAAiB,EAAE,iBAAiB,EACpC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,oBAAoB,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAAC,IAAI,CAAC,CAmHf"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { unreachable } from "../../../../shared/src/asserts.js";
|
|
2
|
+
import { getServerVersion, isAdminPasswordValid, } from "../../config/zero-config.js";
|
|
3
|
+
import { analyzeQuery } from "../analyze.js";
|
|
4
|
+
export async function handleInspect(lc, body, cvr, client, inspectorDelegate, clientGroupID, cvrStore, config, headerOptions, userQueryURL) {
|
|
5
|
+
// Check if the client is already authenticated. We only authenticate the clientGroup
|
|
6
|
+
// once per "worker".
|
|
7
|
+
if (body.op !== 'authenticate' &&
|
|
8
|
+
!inspectorDelegate.isAuthenticated(clientGroupID)) {
|
|
9
|
+
lc.info?.('Client not authenticated to access the inspector protocol. Sending authentication challenge');
|
|
10
|
+
client.sendInspectResponse(lc, {
|
|
11
|
+
op: 'authenticated',
|
|
12
|
+
id: body.id,
|
|
13
|
+
value: false,
|
|
14
|
+
});
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
switch (body.op) {
|
|
19
|
+
case 'queries': {
|
|
20
|
+
const queryRows = await cvrStore.inspectQueries(lc, cvr.ttlClock, body.clientID);
|
|
21
|
+
// Enhance query rows with server-side materialization metrics
|
|
22
|
+
const enhancedRows = queryRows.map(row => ({
|
|
23
|
+
...row,
|
|
24
|
+
ast: row.ast ?? inspectorDelegate.getASTForQuery(row.queryID) ?? null,
|
|
25
|
+
metrics: inspectorDelegate.getMetricsJSONForQuery(row.queryID),
|
|
26
|
+
}));
|
|
27
|
+
client.sendInspectResponse(lc, {
|
|
28
|
+
op: 'queries',
|
|
29
|
+
id: body.id,
|
|
30
|
+
value: enhancedRows,
|
|
31
|
+
});
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case 'metrics': {
|
|
35
|
+
client.sendInspectResponse(lc, {
|
|
36
|
+
op: 'metrics',
|
|
37
|
+
id: body.id,
|
|
38
|
+
value: inspectorDelegate.getMetricsJSON(),
|
|
39
|
+
});
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 'version':
|
|
43
|
+
client.sendInspectResponse(lc, {
|
|
44
|
+
op: 'version',
|
|
45
|
+
id: body.id,
|
|
46
|
+
value: getServerVersion(config),
|
|
47
|
+
});
|
|
48
|
+
break;
|
|
49
|
+
case 'authenticate': {
|
|
50
|
+
const password = body.value;
|
|
51
|
+
const ok = isAdminPasswordValid(lc, config, password);
|
|
52
|
+
if (ok) {
|
|
53
|
+
inspectorDelegate.setAuthenticated(clientGroupID);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
inspectorDelegate.clearAuthenticated(clientGroupID);
|
|
57
|
+
}
|
|
58
|
+
client.sendInspectResponse(lc, {
|
|
59
|
+
op: 'authenticated',
|
|
60
|
+
id: body.id,
|
|
61
|
+
value: ok,
|
|
62
|
+
});
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case 'analyze-query': {
|
|
66
|
+
let ast = body.ast ?? body.value;
|
|
67
|
+
if (ast === undefined && body.name && body.args) {
|
|
68
|
+
// Get the AST from the API server by transforming the named query
|
|
69
|
+
ast = await inspectorDelegate.transformCustomQuery(body.name, body.args, headerOptions, userQueryURL);
|
|
70
|
+
}
|
|
71
|
+
if (ast === undefined) {
|
|
72
|
+
throw new Error('AST is required for analyze-query operation. Either provide an AST directly or ensure custom query transformation is configured.');
|
|
73
|
+
}
|
|
74
|
+
const result = await analyzeQuery(lc, config, ast, body.options);
|
|
75
|
+
client.sendInspectResponse(lc, {
|
|
76
|
+
op: 'analyze-query',
|
|
77
|
+
id: body.id,
|
|
78
|
+
value: result,
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
default:
|
|
83
|
+
unreachable(body);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
lc.error?.('Error handling inspect message', e);
|
|
88
|
+
client.sendInspectResponse(lc, {
|
|
89
|
+
op: 'error',
|
|
90
|
+
id: body.id,
|
|
91
|
+
value: e.message,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=inspect-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect-handler.js","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/view-syncer/inspect-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,mCAAmC,CAAC;AAG9D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAK3C,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,EAAc,EACd,IAAmB,EACnB,GAAgB,EAChB,MAAqB,EACrB,iBAAoC,EACpC,aAAqB,EACrB,QAAkB,EAClB,MAA4B,EAC5B,aAA4B,EAC5B,YAAgC;IAEhC,qFAAqF;IACrF,qBAAqB;IACrB,IACE,IAAI,CAAC,EAAE,KAAK,cAAc;QAC1B,CAAC,iBAAiB,CAAC,eAAe,CAAC,aAAa,CAAC,EACjD,CAAC;QACD,EAAE,CAAC,IAAI,EAAE,CACP,6FAA6F,CAC9F,CAAC;QACF,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE;YAC7B,EAAE,EAAE,eAAe;YACnB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,QAAQ,IAAI,CAAC,EAAE,EAAE,CAAC;YAChB,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,cAAc,CAC7C,EAAE,EACF,GAAG,CAAC,QAAQ,EACZ,IAAI,CAAC,QAAQ,CACd,CAAC;gBAEF,8DAA8D;gBAC9D,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBACzC,GAAG,GAAG;oBACN,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,iBAAiB,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,I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AAC;YAED,KAAK,eAAe,CAAC,CAAC,CAAC;gBACrB,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC;gBAEjC,IAAI,GAAG,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;oBAChD,kEAAkE;oBAClE,GAAG,GAAG,MAAM,iBAAiB,CAAC,oBAAoB,CAChD,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,EACT,aAAa,EACb,YAAY,CACb,CAAC;gBACJ,CAAC;gBAED,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;oBACtB,MAAM,IAAI,KAAK,CACb,kIAAkI,CACnI,CAAC;gBACJ,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBACjE,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE;oBAC7B,EAAE,EAAE,eAAe;oBACnB,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,KAAK,EAAE,MAAM;iBACd,CAAC,CAAC;gBACH,MAAM;YACR,CAAC;YAED;gBACE,WAAW,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,EAAE,CAAC,KAAK,EAAE,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QAChD,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE;YAC7B,EAAE,EAAE,OAAO;YACX,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAG,CAAW,CAAC,OAAO;SAC5B,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -6,6 +6,7 @@ import type { DeleteClientsMessage } from '../../../../zero-protocol/src/delete-
|
|
|
6
6
|
import type { Downstream } from '../../../../zero-protocol/src/down.ts';
|
|
7
7
|
import type { InspectUpMessage } from '../../../../zero-protocol/src/inspect-up.ts';
|
|
8
8
|
import type { NormalizedZeroConfig } from '../../config/normalize.ts';
|
|
9
|
+
import { CustomQueryTransformer } from '../../custom-queries/transform-query.ts';
|
|
9
10
|
import { InspectorDelegate } from '../../server/inspector-delegate.ts';
|
|
10
11
|
import type { PostgresDB } from '../../types/pg.ts';
|
|
11
12
|
import type { ShardID } from '../../types/shards.ts';
|
|
@@ -52,7 +53,7 @@ export declare class ViewSyncerService implements ViewSyncer, ActivityBasedServi
|
|
|
52
53
|
#private;
|
|
53
54
|
readonly id: string;
|
|
54
55
|
userQueryURL?: string | undefined;
|
|
55
|
-
constructor(config: NormalizedZeroConfig, lc: LogContext, shard: ShardID, taskID: string, clientGroupID: string, cvrDb: PostgresDB, upstreamDb: PostgresDB | undefined, pipelineDriver: PipelineDriver, versionChanges: Subscription<ReplicaState>, drainCoordinator: DrainCoordinator, slowHydrateThreshold: number, inspectorDelegate: InspectorDelegate, keepaliveMs?: number, setTimeoutFn?: SetTimeout);
|
|
56
|
+
constructor(config: NormalizedZeroConfig, lc: LogContext, shard: ShardID, taskID: string, clientGroupID: string, cvrDb: PostgresDB, upstreamDb: PostgresDB | undefined, pipelineDriver: PipelineDriver, versionChanges: Subscription<ReplicaState>, drainCoordinator: DrainCoordinator, slowHydrateThreshold: number, inspectorDelegate: InspectorDelegate, customQueryTransformer: CustomQueryTransformer | undefined, keepaliveMs?: number, setTimeoutFn?: SetTimeout);
|
|
56
57
|
run(): Promise<void>;
|
|
57
58
|
/**
|
|
58
59
|
* Guarantees that the ViewSyncer will remain running for at least
|
|
@@ -71,12 +72,12 @@ export declare class ViewSyncerService implements ViewSyncer, ActivityBasedServi
|
|
|
71
72
|
stop(): Promise<void>;
|
|
72
73
|
}
|
|
73
74
|
export declare function pickToken(lc: LogContext, previousToken: TokenData | undefined, newToken: TokenData | undefined): TokenData | undefined;
|
|
74
|
-
export declare class
|
|
75
|
+
export declare class TimeSliceTimer {
|
|
75
76
|
#private;
|
|
76
|
-
start(): this
|
|
77
|
-
|
|
77
|
+
start(): Promise<this>;
|
|
78
|
+
startWithoutYielding(): this;
|
|
79
|
+
yieldProcess(): Promise<void>;
|
|
78
80
|
elapsedLap(): number;
|
|
79
|
-
stopLap(): void;
|
|
80
81
|
/** @returns the total elapsed time */
|
|
81
82
|
stop(): number;
|
|
82
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-syncer.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/view-syncer/view-syncer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAerC,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,yDAAyD,CAAC;AACzG,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,iDAAiD,CAAC;AAC1F,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uCAAuC,CAAC;AAEtE,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,6CAA6C,CAAC;AAMrD,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"view-syncer.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/services/view-syncer/view-syncer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAerC,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,yDAAyD,CAAC;AACzG,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,iDAAiD,CAAC;AAC1F,OAAO,KAAK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,SAAS,EAC1D,WAAW,SAAuB,EAClC,YAAY,GAAE,UAAwC;IAmFlD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAiG1B;;;;;;;;OAQG;IACH,SAAS,IAAI,OAAO;IAwEpB,cAAc,CACZ,GAAG,EAAE,WAAW,EAChB,qBAAqB,EAAE,qBAAqB,GAC3C,MAAM,CAAC,UAAU,CAAC;IA+Ff,oBAAoB,CACxB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,2BAA2B,GAC/B,OAAO,CAAC,IAAI,CAAC;IAIV,aAAa,CACjB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,IAAI,CAAC;IAgpChB,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAmBtB;AA6ED,wBAAgB,SAAS,CACvB,EAAE,EAAE,UAAU,EACd,aAAa,EAAE,SAAS,GAAG,SAAS,EACpC,QAAQ,EAAE,SAAS,GAAG,SAAS,yBA+ChC;AAyCD,qBAAa,cAAc;;IAInB,KAAK;IAOX,oBAAoB;IAMd,YAAY;IAWlB,UAAU;IAWV,sCAAsC;IACtC,IAAI,IAAI,MAAM;IAKd;;;OAGG;IACH,YAAY,IAAI,MAAM;CAKvB"}
|
|
@@ -12,18 +12,17 @@ import { randInt } from "../../../../shared/src/rand.js";
|
|
|
12
12
|
import { ErrorKind } from "../../../../zero-protocol/src/error-kind.js";
|
|
13
13
|
import { clampTTL, MAX_TTL_MS } from "../../../../zql/src/query/ttl.js";
|
|
14
14
|
import { transformAndHashQuery, } from "../../auth/read-authorizer.js";
|
|
15
|
-
import { getServerVersion, isAdminPasswordValid, } from "../../config/zero-config.js";
|
|
16
15
|
import { CustomQueryTransformer } from "../../custom-queries/transform-query.js";
|
|
17
16
|
import { getOrCreateCounter, getOrCreateHistogram, getOrCreateUpDownCounter, } from "../../observability/metrics.js";
|
|
18
17
|
import { InspectorDelegate } from "../../server/inspector-delegate.js";
|
|
19
18
|
import { ErrorForClient, getLogLevel } from "../../types/error-for-client.js";
|
|
20
19
|
import { rowIDString } from "../../types/row-key.js";
|
|
21
20
|
import { Subscription } from "../../types/subscription.js";
|
|
22
|
-
import { analyzeQuery } from "../analyze.js";
|
|
23
21
|
import { ZERO_VERSION_COLUMN_NAME } from "../replicator/schema/replication-state.js";
|
|
24
22
|
import { ClientHandler, startPoke, } from "./client-handler.js";
|
|
25
23
|
import { CVRStore } from "./cvr-store.js";
|
|
26
24
|
import { CVRConfigDrivenUpdater, CVRQueryDrivenUpdater, CVRUpdater, nextEvictionTime, } from "./cvr.js";
|
|
25
|
+
import { handleInspect } from "./inspect-handler.js";
|
|
27
26
|
import { PipelineDriver } from "./pipeline-driver.js";
|
|
28
27
|
import { cmpVersions, EMPTY_CVR_VERSION, versionFromString, versionString, versionToCookie, } from "./schema/types.js";
|
|
29
28
|
import { ResetPipelinesSignal } from "./snapshotter.js";
|
|
@@ -100,6 +99,8 @@ export class ViewSyncerService {
|
|
|
100
99
|
// DEPRECATED: remove `authData` in favor of forwarding
|
|
101
100
|
// auth and cookie headers directly
|
|
102
101
|
#authData;
|
|
102
|
+
// Not sure why lint can't see that this is used?
|
|
103
|
+
// eslint-disable-next-line no-unused-private-class-members
|
|
103
104
|
#httpCookie;
|
|
104
105
|
#expiredQueriesTimer = 0;
|
|
105
106
|
#setTimeout;
|
|
@@ -116,7 +117,7 @@ export class ViewSyncerService {
|
|
|
116
117
|
});
|
|
117
118
|
#inspectorDelegate;
|
|
118
119
|
#config;
|
|
119
|
-
constructor(config, lc, shard, taskID, clientGroupID, cvrDb, upstreamDb, pipelineDriver, versionChanges, drainCoordinator, slowHydrateThreshold, inspectorDelegate, keepaliveMs = DEFAULT_KEEPALIVE_MS, setTimeoutFn = setTimeout.bind(globalThis)) {
|
|
120
|
+
constructor(config, lc, shard, taskID, clientGroupID, cvrDb, upstreamDb, pipelineDriver, versionChanges, drainCoordinator, slowHydrateThreshold, inspectorDelegate, customQueryTransformer, keepaliveMs = DEFAULT_KEEPALIVE_MS, setTimeoutFn = setTimeout.bind(globalThis)) {
|
|
120
121
|
const { getQueries: pullConfig } = config;
|
|
121
122
|
this.#config = config;
|
|
122
123
|
this.id = clientGroupID;
|
|
@@ -129,20 +130,22 @@ export class ViewSyncerService {
|
|
|
129
130
|
this.#keepaliveMs = keepaliveMs;
|
|
130
131
|
this.#slowHydrateThreshold = slowHydrateThreshold;
|
|
131
132
|
this.#inspectorDelegate = inspectorDelegate;
|
|
133
|
+
this.#customQueryTransformer = customQueryTransformer;
|
|
132
134
|
this.#cvrStore = new CVRStore(lc, cvrDb, upstreamDb, shard, taskID, clientGroupID,
|
|
133
135
|
// On failure, cancel the #stateChanges subscription. The run()
|
|
134
136
|
// loop will then await #cvrStore.flushed() which rejects if necessary.
|
|
135
137
|
() => this.#stateChanges.cancel());
|
|
136
138
|
this.#setTimeout = setTimeoutFn;
|
|
137
|
-
if (pullConfig.url) {
|
|
138
|
-
this.#customQueryTransformer = new CustomQueryTransformer(this.#lc, {
|
|
139
|
-
url: pullConfig.url,
|
|
140
|
-
forwardCookies: pullConfig.forwardCookies,
|
|
141
|
-
}, shard);
|
|
142
|
-
}
|
|
143
139
|
// Wait for the first connection to init.
|
|
144
140
|
this.keepalive();
|
|
145
141
|
}
|
|
142
|
+
#getHeaderOptions(forwardCookie) {
|
|
143
|
+
return {
|
|
144
|
+
apiKey: this.#queryConfig.apiKey,
|
|
145
|
+
token: this.#authData?.raw,
|
|
146
|
+
cookie: forwardCookie ? this.#httpCookie : undefined,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
146
149
|
#runInLockWithCVR(fn) {
|
|
147
150
|
const rid = randomID();
|
|
148
151
|
this.#lc.debug?.('about to acquire lock for cvr ', rid);
|
|
@@ -659,13 +662,7 @@ export class ViewSyncerService {
|
|
|
659
662
|
const [_, byOriginalHash] = this.#pipelines.addedQueries();
|
|
660
663
|
if (this.#customQueryTransformer && customQueries.size > 0) {
|
|
661
664
|
const filteredCustomQueries = this.#filterCustomQueries(customQueries.values(), byOriginalHash, undefined);
|
|
662
|
-
const transformedCustomQueries = await this.#customQueryTransformer.transform(
|
|
663
|
-
apiKey: this.#queryConfig.apiKey,
|
|
664
|
-
token: this.#authData?.raw,
|
|
665
|
-
cookie: this.#queryConfig.forwardCookies
|
|
666
|
-
? this.#httpCookie
|
|
667
|
-
: undefined,
|
|
668
|
-
}, filteredCustomQueries, this.userQueryURL);
|
|
665
|
+
const transformedCustomQueries = await this.#customQueryTransformer.transform(this.#getHeaderOptions(this.#queryConfig.forwardCookies), filteredCustomQueries, this.userQueryURL);
|
|
669
666
|
this.#processTransformedCustomQueries(lc, transformedCustomQueries, (q) => transformedQueries.push(q), customQueries);
|
|
670
667
|
}
|
|
671
668
|
for (const q of otherQueries) {
|
|
@@ -678,18 +675,16 @@ export class ViewSyncerService {
|
|
|
678
675
|
}
|
|
679
676
|
}
|
|
680
677
|
for (const { id: queryID, transformationHash, transformedAst, } of transformedQueries) {
|
|
681
|
-
const timer = new
|
|
678
|
+
const timer = new TimeSliceTimer();
|
|
682
679
|
let count = 0;
|
|
683
680
|
await startAsyncSpan(tracer, 'vs.#hydrateUnchangedQueries.addQuery', async (span) => {
|
|
684
681
|
span.setAttribute('queryHash', queryID);
|
|
685
682
|
span.setAttribute('transformationHash', transformationHash);
|
|
686
683
|
span.setAttribute('table', transformedAst.table);
|
|
687
|
-
for (const _ of this.#pipelines.addQuery(transformationHash, queryID, transformedAst, timer.start())) {
|
|
684
|
+
for (const _ of this.#pipelines.addQuery(transformationHash, queryID, transformedAst, await timer.start())) {
|
|
688
685
|
if (++count % TIME_SLICE_CHECK_SIZE === 0) {
|
|
689
686
|
if (timer.elapsedLap() > TIME_SLICE_MS) {
|
|
690
|
-
timer.
|
|
691
|
-
await yieldProcess(this.#setTimeout);
|
|
692
|
-
timer.startLap();
|
|
687
|
+
await timer.yieldProcess();
|
|
693
688
|
}
|
|
694
689
|
}
|
|
695
690
|
}
|
|
@@ -805,11 +800,7 @@ export class ViewSyncerService {
|
|
|
805
800
|
});
|
|
806
801
|
}
|
|
807
802
|
});
|
|
808
|
-
const transformedCustomQueries = await this.#customQueryTransformer.transform(
|
|
809
|
-
apiKey: this.#queryConfig.apiKey,
|
|
810
|
-
token: this.#authData?.raw,
|
|
811
|
-
cookie: this.#httpCookie,
|
|
812
|
-
}, filteredCustomQueries, this.userQueryURL);
|
|
803
|
+
const transformedCustomQueries = await this.#customQueryTransformer.transform(this.#getHeaderOptions(true), filteredCustomQueries, this.userQueryURL);
|
|
813
804
|
erroredQueries = this.#processTransformedCustomQueries(lc, transformedCustomQueries, (q) => transformedQueries.push({
|
|
814
805
|
id: q.id,
|
|
815
806
|
origQuery: must(customQueries.get(q.id)),
|
|
@@ -912,19 +903,22 @@ export class ViewSyncerService {
|
|
|
912
903
|
}
|
|
913
904
|
}
|
|
914
905
|
let totalProcessTime = 0;
|
|
915
|
-
const timer = new
|
|
906
|
+
const timer = new TimeSliceTimer();
|
|
916
907
|
const pipelines = this.#pipelines;
|
|
917
908
|
const hydrations = this.#hydrations;
|
|
918
909
|
const hydrationTime = this.#hydrationTime;
|
|
919
910
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
920
911
|
const self = this;
|
|
912
|
+
// yield at the very beginning so that the first time slice
|
|
913
|
+
// is properly processed by the time-slice queue.
|
|
914
|
+
await yieldProcess();
|
|
921
915
|
function* generateRowChanges(slowHydrateThreshold) {
|
|
922
916
|
for (const q of addQueries) {
|
|
923
917
|
lc = lc
|
|
924
918
|
.withContext('hash', q.id)
|
|
925
919
|
.withContext('transformationHash', q.transformationHash);
|
|
926
920
|
lc.debug?.(`adding pipeline for query`, q.ast);
|
|
927
|
-
yield* pipelines.addQuery(q.transformationHash, q.id, q.ast, timer.
|
|
921
|
+
yield* pipelines.addQuery(q.transformationHash, q.id, q.ast, timer.startWithoutYielding());
|
|
928
922
|
const elapsed = timer.stop();
|
|
929
923
|
totalProcessTime += elapsed;
|
|
930
924
|
self.#addQueryMaterializationServerMetric(q.transformationHash, elapsed);
|
|
@@ -1078,9 +1072,7 @@ export class ViewSyncerService {
|
|
|
1078
1072
|
}
|
|
1079
1073
|
if (rows.size % TIME_SLICE_CHECK_SIZE === 0) {
|
|
1080
1074
|
if (timer.elapsedLap() > TIME_SLICE_MS) {
|
|
1081
|
-
timer.
|
|
1082
|
-
await yieldProcess(this.#setTimeout);
|
|
1083
|
-
timer.startLap();
|
|
1075
|
+
await timer.yieldProcess();
|
|
1084
1076
|
}
|
|
1085
1077
|
}
|
|
1086
1078
|
}
|
|
@@ -1103,7 +1095,7 @@ export class ViewSyncerService {
|
|
|
1103
1095
|
return startAsyncSpan(tracer, 'vs.#advancePipelines', async () => {
|
|
1104
1096
|
assert(this.#pipelines.initialized(), 'pipelines must be initialized (advancePipelines');
|
|
1105
1097
|
const start = performance.now();
|
|
1106
|
-
const timer = new
|
|
1098
|
+
const timer = new TimeSliceTimer();
|
|
1107
1099
|
const { version, numChanges, changes } = this.#pipelines.advance(timer);
|
|
1108
1100
|
lc = lc.withContext('newVersion', version);
|
|
1109
1101
|
// Probably need a new updater type. CVRAdvancementUpdater?
|
|
@@ -1115,7 +1107,7 @@ export class ViewSyncerService {
|
|
|
1115
1107
|
lc.debug?.(`applying ${numChanges} to advance to ${version}`);
|
|
1116
1108
|
const hashToIDs = createHashToIDs(cvr);
|
|
1117
1109
|
try {
|
|
1118
|
-
await this.#processChanges(lc, timer.start(), changes, updater, pokers, hashToIDs);
|
|
1110
|
+
await this.#processChanges(lc, await timer.start(), changes, updater, pokers, hashToIDs);
|
|
1119
1111
|
}
|
|
1120
1112
|
catch (e) {
|
|
1121
1113
|
if (e instanceof ResetPipelinesSignal) {
|
|
@@ -1141,80 +1133,7 @@ export class ViewSyncerService {
|
|
|
1141
1133
|
// eslint-disable-next-line require-await
|
|
1142
1134
|
#handleInspect = async (lc, clientID, body, cvr) => {
|
|
1143
1135
|
const client = must(this.#clients.get(clientID));
|
|
1144
|
-
|
|
1145
|
-
// once per "worker".
|
|
1146
|
-
if (body.op !== 'authenticate' &&
|
|
1147
|
-
!this.#inspectorDelegate.isAuthenticated(this.id)) {
|
|
1148
|
-
lc.info?.('Client not authenticated to access the inspector protocol. Sending authentication challenge');
|
|
1149
|
-
client.sendInspectResponse(lc, {
|
|
1150
|
-
op: 'authenticated',
|
|
1151
|
-
id: body.id,
|
|
1152
|
-
value: false,
|
|
1153
|
-
});
|
|
1154
|
-
return;
|
|
1155
|
-
}
|
|
1156
|
-
switch (body.op) {
|
|
1157
|
-
case 'queries': {
|
|
1158
|
-
const queryRows = await this.#cvrStore.inspectQueries(lc, cvr.ttlClock, body.clientID);
|
|
1159
|
-
// Enhance query rows with server-side materialization metrics
|
|
1160
|
-
const enhancedRows = queryRows.map(row => ({
|
|
1161
|
-
...row,
|
|
1162
|
-
ast: row.ast ??
|
|
1163
|
-
this.#inspectorDelegate.getASTForQuery(row.queryID) ??
|
|
1164
|
-
null,
|
|
1165
|
-
metrics: this.#inspectorDelegate.getMetricsJSONForQuery(row.queryID),
|
|
1166
|
-
}));
|
|
1167
|
-
client.sendInspectResponse(lc, {
|
|
1168
|
-
op: 'queries',
|
|
1169
|
-
id: body.id,
|
|
1170
|
-
value: enhancedRows,
|
|
1171
|
-
});
|
|
1172
|
-
break;
|
|
1173
|
-
}
|
|
1174
|
-
case 'metrics': {
|
|
1175
|
-
client.sendInspectResponse(lc, {
|
|
1176
|
-
op: 'metrics',
|
|
1177
|
-
id: body.id,
|
|
1178
|
-
value: this.#inspectorDelegate.getMetricsJSON(),
|
|
1179
|
-
});
|
|
1180
|
-
break;
|
|
1181
|
-
}
|
|
1182
|
-
case 'version':
|
|
1183
|
-
client.sendInspectResponse(lc, {
|
|
1184
|
-
op: 'version',
|
|
1185
|
-
id: body.id,
|
|
1186
|
-
value: getServerVersion(this.#config),
|
|
1187
|
-
});
|
|
1188
|
-
break;
|
|
1189
|
-
case 'authenticate': {
|
|
1190
|
-
const password = body.value;
|
|
1191
|
-
const ok = isAdminPasswordValid(lc, this.#config, password);
|
|
1192
|
-
if (ok) {
|
|
1193
|
-
this.#inspectorDelegate.setAuthenticated(this.id);
|
|
1194
|
-
}
|
|
1195
|
-
else {
|
|
1196
|
-
this.#inspectorDelegate.clearAuthenticated(this.id);
|
|
1197
|
-
}
|
|
1198
|
-
client.sendInspectResponse(lc, {
|
|
1199
|
-
op: 'authenticated',
|
|
1200
|
-
id: body.id,
|
|
1201
|
-
value: ok,
|
|
1202
|
-
});
|
|
1203
|
-
break;
|
|
1204
|
-
}
|
|
1205
|
-
case 'analyze-query': {
|
|
1206
|
-
const ast = body.value;
|
|
1207
|
-
const result = await analyzeQuery(lc, this.#config, ast, body.options);
|
|
1208
|
-
client.sendInspectResponse(lc, {
|
|
1209
|
-
op: 'analyze-query',
|
|
1210
|
-
id: body.id,
|
|
1211
|
-
value: result,
|
|
1212
|
-
});
|
|
1213
|
-
break;
|
|
1214
|
-
}
|
|
1215
|
-
default:
|
|
1216
|
-
unreachable(body);
|
|
1217
|
-
}
|
|
1136
|
+
return handleInspect(lc, body, cvr, client, this.#inspectorDelegate, this.id, this.#cvrStore, this.#config, this.#getHeaderOptions(this.#queryConfig.forwardCookies ?? false), this.userQueryURL);
|
|
1218
1137
|
};
|
|
1219
1138
|
stop() {
|
|
1220
1139
|
this.#lc.info?.('stopping view syncer');
|
|
@@ -1256,8 +1175,22 @@ function createHashToIDs(cvr) {
|
|
|
1256
1175
|
}
|
|
1257
1176
|
return hashToIDs;
|
|
1258
1177
|
}
|
|
1259
|
-
|
|
1260
|
-
|
|
1178
|
+
// A global Lock acts as a queue to run a single IVM time slice per iteration
|
|
1179
|
+
// of the node event loop, thus bounding I/O delay to the duration of a single
|
|
1180
|
+
// time slice.
|
|
1181
|
+
//
|
|
1182
|
+
// Refresher:
|
|
1183
|
+
// https://nodejs.org/en/learn/asynchronous-work/event-loop-timers-and-nexttick#phases-overview
|
|
1184
|
+
//
|
|
1185
|
+
// Note that recursive use of setImmediate() (i.e. calling setImmediate() from
|
|
1186
|
+
// within a setImmediate() callback), results in enqueuing the latter
|
|
1187
|
+
// callback in the *next* event loop iteration, as documented in:
|
|
1188
|
+
// https://nodejs.org/api/timers.html#setimmediatecallback-args
|
|
1189
|
+
//
|
|
1190
|
+
// This effectively achieves the desired one-per-event-loop-iteration behavior.
|
|
1191
|
+
const timeSliceQueue = new Lock();
|
|
1192
|
+
function yieldProcess() {
|
|
1193
|
+
return timeSliceQueue.withLock(() => new Promise(setImmediate));
|
|
1261
1194
|
}
|
|
1262
1195
|
function contentsAndVersion(row) {
|
|
1263
1196
|
const { [ZERO_VERSION_COLUMN_NAME]: version, ...contents } = row;
|
|
@@ -1352,15 +1285,26 @@ function hasExpiredQueries(cvr) {
|
|
|
1352
1285
|
}
|
|
1353
1286
|
return false;
|
|
1354
1287
|
}
|
|
1355
|
-
export class
|
|
1288
|
+
export class TimeSliceTimer {
|
|
1356
1289
|
#total = 0;
|
|
1357
1290
|
#start = 0;
|
|
1358
|
-
start() {
|
|
1291
|
+
async start() {
|
|
1292
|
+
// yield at the very beginning so that the first time slice
|
|
1293
|
+
// is properly processed by the time-slice queue.
|
|
1294
|
+
await yieldProcess();
|
|
1295
|
+
return this.startWithoutYielding();
|
|
1296
|
+
}
|
|
1297
|
+
startWithoutYielding() {
|
|
1359
1298
|
this.#total = 0;
|
|
1360
|
-
this
|
|
1299
|
+
this.#startLap();
|
|
1361
1300
|
return this;
|
|
1362
1301
|
}
|
|
1363
|
-
|
|
1302
|
+
async yieldProcess() {
|
|
1303
|
+
this.#stopLap();
|
|
1304
|
+
await yieldProcess();
|
|
1305
|
+
this.#startLap();
|
|
1306
|
+
}
|
|
1307
|
+
#startLap() {
|
|
1364
1308
|
assert(this.#start === 0, 'already running');
|
|
1365
1309
|
this.#start = performance.now();
|
|
1366
1310
|
}
|
|
@@ -1368,14 +1312,14 @@ export class Timer {
|
|
|
1368
1312
|
assert(this.#start !== 0, 'not running');
|
|
1369
1313
|
return performance.now() - this.#start;
|
|
1370
1314
|
}
|
|
1371
|
-
stopLap() {
|
|
1315
|
+
#stopLap() {
|
|
1372
1316
|
assert(this.#start !== 0, 'not running');
|
|
1373
1317
|
this.#total += performance.now() - this.#start;
|
|
1374
1318
|
this.#start = 0;
|
|
1375
1319
|
}
|
|
1376
1320
|
/** @returns the total elapsed time */
|
|
1377
1321
|
stop() {
|
|
1378
|
-
this
|
|
1322
|
+
this.#stopLap();
|
|
1379
1323
|
return this.#total;
|
|
1380
1324
|
}
|
|
1381
1325
|
/**
|