@mnmal-ai/substrate 1.0.0-alpha.16 → 1.0.0-alpha.18
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/README.md +5 -4
- package/dist/{boot-store-HxCgbvNl.js → boot-store-C8KrACZ5.js} +51 -72
- package/dist/{bridge-CvZGzNIO.d.ts → bridge-5VHZiH9o.d.ts} +1 -1
- package/dist/{cli-6mjAWiEZ.js → cli-zZ7nHhY5.js} +235 -16
- package/dist/client.d.ts +8 -3
- package/dist/client.js +4 -4
- package/dist/{errors-BXxm9eZF.d.ts → errors-DHgT7Fa8.d.ts} +8 -2
- package/dist/{index-EN-nQsX8.d.ts → index-DKJXQ031.d.ts} +1 -1
- package/dist/{node-version-C5FSmwJX.js → node-version-CxqcqECU.js} +1 -1
- package/dist/pack.d.ts +18 -2
- package/dist/pack.js +2 -2
- package/dist/{pg-edges-store-De5F1tUf.js → pg-edges-store-D7etFxNK.js} +1 -1
- package/dist/{plugin-Dpa_Y7Ep.js → plugin-DcoJGEMM.js} +2 -2
- package/dist/proposals-bootstrap.js +2 -2
- package/dist/proposals.d.ts +5 -3
- package/dist/proposals.js +1 -1
- package/dist/recall-bootstrap.js +2 -2
- package/dist/recall.d.ts +1 -1
- package/dist/recall.js +2 -2
- package/dist/{repl-2WfRPUb0.js → repl-SY8cLOZl.js} +1 -1
- package/dist/{row-Dh57ShWL.d.ts → row-DHxnCnhA.d.ts} +10 -8
- package/dist/{run-ChcHBIN3.js → run-Cr-53N3F.js} +142 -106
- package/dist/{schema-B--_bHjn.d.ts → schema-B5WBO8yh.d.ts} +79 -19
- package/dist/{script-C6DSa_Na.js → script-B-32wZGY.js} +11 -1
- package/dist/script-runner.js +78 -0
- package/dist/sdk.d.ts +51 -8
- package/dist/sdk.js +4 -4
- package/dist/{src-B4sqnLRy.js → src-B4dTiEWw.js} +77 -28
- package/dist/{src-DHLw3eCn.js → src-BcuotITf.js} +1016 -231
- package/dist/{src-DWqzrm3O.js → src-CdbUzLhB.js} +209 -36
- package/dist/{src-BMHI_rTJ.js → src-D55T3ZcP.js} +2203 -499
- package/dist/{src-Bi3NhEsT.js → src-DR_hUj2p.js} +1 -1
- package/dist/{src-CHND7-Pm.js → src-DV6PcXym.js} +2 -2
- package/dist/{src--uyAqssS.js → src-DZfgQ2gR.js} +3 -3
- package/dist/substrate-admin.js +2 -2
- package/dist/substrate.js +2 -2
- package/dist/testing.d.ts +5 -3
- package/dist/testing.js +4 -4
- package/dist/{ws-CpHWxwp9.d.ts → ws-BL9nSELO.d.ts} +2 -2
- package/package.json +21 -21
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { En as Edge, On as EdgeRef } from "./schema-B5WBO8yh.js";
|
|
2
2
|
//#region ../../packages/substrate-types/src/errors.d.ts
|
|
3
3
|
/** A by-filter write matched more rows than `SUBSTRATE_FILTER_WRITE_MAX_MATCH`; nothing changed. */
|
|
4
4
|
declare const FILTER_TOO_BROAD = "filter_too_broad";
|
|
@@ -11,6 +11,12 @@ declare const WALK_BUDGET_EXCEEDED = "walk_budget_exceeded";
|
|
|
11
11
|
declare const WALKS_UNSUPPORTED_STORE = "walks_unsupported_store";
|
|
12
12
|
/** A read cancelled by the store's statement timeout; `details: { timeoutMs }`. */
|
|
13
13
|
declare const QUERY_TIMEOUT = "query_timeout";
|
|
14
|
+
/** No store connection came free within the wait limit, so the request never started; retry later. */
|
|
15
|
+
declare const STORE_BUSY = "store_busy";
|
|
16
|
+
/** An aggregate or expression whose value leaves its type's range (an int64 sum past 2^63-1); the same code on every engine. */
|
|
17
|
+
declare const VALUE_OUT_OF_RANGE = "value_out_of_range";
|
|
18
|
+
/** A regex call on the memory evaluator that would take more steps than its budget; `details: { budget }`. */
|
|
19
|
+
declare const REGEX_BUDGET_EXCEEDED = "regex_budget_exceeded";
|
|
14
20
|
/**
|
|
15
21
|
* A walk construct refused where it cannot be answered: inside a struct, over
|
|
16
22
|
* a list or struct-nested crossRef, under a reused field name, on a virtual
|
|
@@ -161,4 +167,4 @@ declare function isResolverFrameError(err: unknown): err is ResolverFrameError;
|
|
|
161
167
|
*/
|
|
162
168
|
declare function isRestrictViolation(err: unknown): err is RestrictViolation;
|
|
163
169
|
//#endregion
|
|
164
|
-
export {
|
|
170
|
+
export { isBatchElementError as C, isAuthCause as S, isRestrictViolation as T, WALKS_NEED_PARTITIONED as _, NamespaceMismatch as a, WALK_UNSUPPORTED_REF as b, ROW_POLICY_BLOCKS_WALK as c, RestrictViolation as d, STORE_BUSY as f, WALKS_IN_SUBSCRIPTION as g, WALKS_IN_MUTATION as h, MissingReferentError as i, ReservedField as l, VALUE_OUT_OF_RANGE as m, BridgeUnreachableError as n, QUERY_TIMEOUT as o, UnsupportedFilterError as p, FILTER_TOO_BROAD as r, REGEX_BUDGET_EXCEEDED as s, BatchElementError as t, ResolverFrameError as u, WALKS_UNSUPPORTED_STORE as v, isResolverFrameError as w, filterTooBroad as x, WALK_BUDGET_EXCEEDED as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as PackEnvelope, i as FieldDef, l as FieldInput, m as Schema } from "./schema-
|
|
1
|
+
import { f as PackEnvelope, i as FieldDef, l as FieldInput, m as Schema } from "./schema-B5WBO8yh.js";
|
|
2
2
|
import { pack as packFrame, unpack as unpackFrame } from "msgpackr";
|
|
3
3
|
//#region ../../packages/substrate-pack/src/decoder.d.ts
|
|
4
4
|
interface DecodeContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
2
|
//#region src/node-version.ts
|
|
3
3
|
/** The oldest Node the binaries run on; matches `engines.node` in package.json. */
|
|
4
|
-
const MIN_NODE_VERSION = "26.
|
|
4
|
+
const MIN_NODE_VERSION = "26.13.1";
|
|
5
5
|
/** Returns a refusal message when `version` (e.g. `process.versions.node`) is below the minimum, else null. */
|
|
6
6
|
function nodeVersionRefusal(version) {
|
|
7
7
|
const have = version.split(".").map(Number);
|
package/dist/pack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as PackEnvelope, i as FieldDef, l as FieldInput, m as Schema } from "./schema-
|
|
2
|
-
import { a as DecodeEnvelopeCtx, c as decodeEnvelope, i as DecodeContext, l as decodePositional, n as packFrame, o as PackDecodeError, r as unpackFrame, s as SchemaDriftError, t as WS_SUBPROTOCOL_SUBSTRATE_PACK, u as decodePositionalFromFieldDef } from "./index-
|
|
1
|
+
import { f as PackEnvelope, i as FieldDef, l as FieldInput, m as Schema } from "./schema-B5WBO8yh.js";
|
|
2
|
+
import { a as DecodeEnvelopeCtx, c as decodeEnvelope, i as DecodeContext, l as decodePositional, n as packFrame, o as PackDecodeError, r as unpackFrame, s as SchemaDriftError, t as WS_SUBPROTOCOL_SUBSTRATE_PACK, u as decodePositionalFromFieldDef } from "./index-DKJXQ031.js";
|
|
3
3
|
//#region ../../packages/substrate-pack/src/content-type.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Content-type negotiation. Spec: §7.0.
|
|
@@ -61,6 +61,22 @@ export declare function encodePositional(value: unknown, fields: FieldInput, sch
|
|
|
61
61
|
*/
|
|
62
62
|
export declare function encodePositionalFromFieldDef(value: unknown, def: FieldDef, schema: Schema, ctx: EncodeContext, path?: string[]): unknown;
|
|
63
63
|
export declare function encodeEnvelope(envelope: PackEnvelope, ctx: EncodeEnvelopeCtx): Buffer;
|
|
64
|
+
/**
|
|
65
|
+
* The wire form of `envelope.data[key]`, or of `value` in its place: rows as
|
|
66
|
+
* positional tuples, or the value as-is when nothing positions it. A `list`
|
|
67
|
+
* value's rows encode one by one, so a slice of its rows gives that slice of
|
|
68
|
+
* the whole value's wire form.
|
|
69
|
+
*/
|
|
70
|
+
export declare function positionValue(envelope: PackEnvelope, ctx: EncodeEnvelopeCtx, key: string, value?: unknown): unknown;
|
|
71
|
+
/** `envelope` with `data` replaced by its wire form; `pack` of it is the response body. */
|
|
72
|
+
export declare function withData(envelope: PackEnvelope, data: Record<string, unknown>): PackEnvelope;
|
|
73
|
+
/**
|
|
74
|
+
* `pack(wire)` in pieces, a long row list `rowsPerPart` rows per piece, for a
|
|
75
|
+
* `wire` envelope from `withData`. msgpackr's default `pack` writes every
|
|
76
|
+
* object as a map16 (`de`) and records no shared state between values, so
|
|
77
|
+
* the pieces concatenate to the same bytes.
|
|
78
|
+
*/
|
|
79
|
+
export declare function packEnvelopeParts(wire: PackEnvelope, rowsPerPart: number): Generator<Uint8Array>;
|
|
64
80
|
//#endregion
|
|
65
81
|
//#region ../../packages/substrate-pack/src/stream-chunk.d.ts
|
|
66
82
|
/**
|
package/dist/pack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import { _ as encodeEnvelope, a as buildDecodePlan, c as isPlainRequestData, d as PackDecodeError, f as SchemaDriftError, g as PackEncodeError, h as decodePositionalFromFieldDef, i as applyDecodePlanInPlace, l as decodeStreamChunk, m as decodePositional, n as packFrame, o as decodeWsEnvelope, p as decodeEnvelope, r as unpackFrame, s as encodeWsFrame, t as WS_SUBPROTOCOL_SUBSTRATE_PACK, u as encodeStreamChunk, v as encodePositional, y as encodePositionalFromFieldDef } from "./src-
|
|
2
|
+
import { S as withData, _ as encodeEnvelope, a as buildDecodePlan, b as packEnvelopeParts, c as isPlainRequestData, d as PackDecodeError, f as SchemaDriftError, g as PackEncodeError, h as decodePositionalFromFieldDef, i as applyDecodePlanInPlace, l as decodeStreamChunk, m as decodePositional, n as packFrame, o as decodeWsEnvelope, p as decodeEnvelope, r as unpackFrame, s as encodeWsFrame, t as WS_SUBPROTOCOL_SUBSTRATE_PACK, u as encodeStreamChunk, v as encodePositional, x as positionValue, y as encodePositionalFromFieldDef } from "./src-CdbUzLhB.js";
|
|
3
3
|
import { n as acceptsPack, t as PACK_MIME } from "./content-type-C7T28xNb.js";
|
|
4
4
|
|
|
5
|
-
export { PACK_MIME, PackDecodeError, PackEncodeError, SchemaDriftError, WS_SUBPROTOCOL_SUBSTRATE_PACK, acceptsPack, applyDecodePlanInPlace, buildDecodePlan, decodeEnvelope, decodePositional, decodePositionalFromFieldDef, decodeStreamChunk, decodeWsEnvelope, encodeEnvelope, encodePositional, encodePositionalFromFieldDef, encodeStreamChunk, encodeWsFrame, isPlainRequestData, packFrame, unpackFrame };
|
|
5
|
+
export { PACK_MIME, PackDecodeError, PackEncodeError, SchemaDriftError, WS_SUBPROTOCOL_SUBSTRATE_PACK, acceptsPack, applyDecodePlanInPlace, buildDecodePlan, decodeEnvelope, decodePositional, decodePositionalFromFieldDef, decodeStreamChunk, decodeWsEnvelope, encodeEnvelope, encodePositional, encodePositionalFromFieldDef, encodeStreamChunk, encodeWsFrame, isPlainRequestData, packEnvelopeParts, packFrame, positionValue, unpackFrame, withData };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
2
|
+
import { r as txScopeIdFor } from "./src-BcuotITf.js";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
|
|
5
5
|
//#region ../../packages/substrate-dataset-pg/src/pg-edges-store.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
import "./src-
|
|
2
|
+
import { Lt as buildContext, tt as applyObligations, vn as ResolverFrameError, zt as jsonResponse } from "./src-D55T3ZcP.js";
|
|
3
|
+
import "./src-CdbUzLhB.js";
|
|
4
4
|
import { Worker } from "node:worker_threads";
|
|
5
5
|
|
|
6
6
|
//#region ../../plugins/substrate-recall/src/candidate-selection.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-
|
|
2
|
+
import { zn as defineBootstrap } from "./src-D55T3ZcP.js";
|
|
3
|
+
import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-B4dTiEWw.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
//#region ../../plugins/substrate-proposals/src/bootstrap.ts
|
package/dist/proposals.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { jn as OnDelete, jt as Dataset, x as CoordinatorPlugin } from "./schema-B5WBO8yh.js";
|
|
2
|
+
import { u as ResolverFrameError } from "./errors-DHgT7Fa8.js";
|
|
3
3
|
//#region ../../plugins/substrate-proposals/src/config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Multi-instance invalidation transport used by the plugin to broadcast
|
|
@@ -23,6 +23,8 @@ interface PubSub {
|
|
|
23
23
|
notify(channel: string, payload: string): Promise<void>;
|
|
24
24
|
}
|
|
25
25
|
interface ProposalsPluginConfig {
|
|
26
|
+
/** Where a one-line warning goes, such as a stored proposal skipped at replay. Defaults to `console.warn`. */
|
|
27
|
+
log?: (line: string) => void;
|
|
26
28
|
/**
|
|
27
29
|
* Namespaces this plugin owns. Propose mutations outside this list are
|
|
28
30
|
* rejected at resolver entry. A proposed crossRef must target a type in an
|
|
@@ -90,7 +92,7 @@ export declare class ProposalError extends ResolverFrameError {
|
|
|
90
92
|
}
|
|
91
93
|
//#endregion
|
|
92
94
|
//#region ../../plugins/substrate-proposals/src/field-spec-json.d.ts
|
|
93
|
-
type ScalarType = 'string' | 'number' | 'boolean' | 'date' | 'json';
|
|
95
|
+
type ScalarType = 'string' | 'number' | 'int16' | 'int32' | 'int64' | 'boolean' | 'date' | 'json';
|
|
94
96
|
interface ScalarSpec {
|
|
95
97
|
kind: 'scalar';
|
|
96
98
|
type: ScalarType;
|
package/dist/proposals.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import { i as ProposalError, n as createNoopPubSub, r as storageSettled, t as createProposalsPlugin } from "./src-
|
|
2
|
+
import { i as ProposalError, n as createNoopPubSub, r as storageSettled, t as createProposalsPlugin } from "./src-B4dTiEWw.js";
|
|
3
3
|
|
|
4
4
|
export { ProposalError, createNoopPubSub, createProposalsPlugin, storageSettled };
|
package/dist/recall-bootstrap.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
2
|
+
import { zn as defineBootstrap } from "./src-D55T3ZcP.js";
|
|
3
3
|
import { t as FakeEmbedder } from "./fake-DUVtKVSE.js";
|
|
4
|
-
import { t as createRecallPlugin } from "./plugin-
|
|
4
|
+
import { t as createRecallPlugin } from "./plugin-DcoJGEMM.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
//#region ../../packages/substrate-embedder/src/types.ts
|
package/dist/recall.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { An as EdgesStore, C as EmbedSourceContext, Ct as ResolverArgs, D as FilterOperatorDef, I as McpToolRegistration, P as KernelPlugin, U as PostWriteHook, bt as PolicyProbeContext, gt as Identity, i as FieldDef, j as KernelMigration, jt as Dataset, tt as HttpHandler, xt as RequestContext, yt as PolicyDecision, zn as Row } from "./schema-B5WBO8yh.js";
|
|
2
2
|
import { t as Embedder } from "./types-8c0gtnd2.js";
|
|
3
3
|
import postgres, { Sql } from "postgres";
|
|
4
4
|
//#region ../../plugins/substrate-recall/src/candidate-selection.d.ts
|
package/dist/recall.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore, t as RECALL_VERSION } from "./src
|
|
3
|
-
import { $ as CLUSTERER_BACKEND_VERSION, A as CLUSTER_MEMBER_FIELDS, C as EmbedSourceRegistry, D as makeReembed, E as makeEmbedPostWrite, F as unknownParams, G as DEFAULT_CRYSTALLISE_CONFIG, H as CRYSTALLISE_IN_FLIGHT_CODE, I as handleRecallRequest, J as runClusterer, K as handleCrystallise, L as RRF_K, M as recallRouteHandler, N as checkParams, O as crystalliseRouteHandler, P as unknownParamMessage, Q as CLUSTERER_BACKEND, R as armRanks, S as createEmbedStats, T as embedRowReporting, U as createCrystalliseGuard, X as l2normalize, _ as EMBEDDINGS_FETCH_MAX_REFS, a as REINDEX_MAX_LIMIT, b as handleLexicalCoverage, c as SALIENCE_BOOST_MAX_TARGETS, d as embeddingsMigration, et as memberKey, f as recallMcpTool, g as embeddingsFetchRouteHandler, h as embeddingSimilarOperator, i as REINDEX_DEFAULT_LIMIT, j as buildClusterSurface, k as CLUSTER_FIELDS, l as lexicalMigration, m as makeLexicalPostWrite, n as salienceBoostRouteHandler, nt as validateSelector, o as handleReindex, p as makeLexicalClassify, q as validateCrystalliseInput, r as reindexRouteHandler, s as validateReindexInput, t as createRecallPlugin, tt as SELECT_CANDIDATES_MAX_LIMIT, u as recallClustersMigration, v as embedStatsRouteHandler, w as embedAndStore, x as validateLexicalCoverageInput, y as handleEmbedStatsRequest, z as fuseByRank } from "./plugin-
|
|
2
|
+
import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore, t as RECALL_VERSION } from "./src-DZfgQ2gR.js";
|
|
3
|
+
import { $ as CLUSTERER_BACKEND_VERSION, A as CLUSTER_MEMBER_FIELDS, C as EmbedSourceRegistry, D as makeReembed, E as makeEmbedPostWrite, F as unknownParams, G as DEFAULT_CRYSTALLISE_CONFIG, H as CRYSTALLISE_IN_FLIGHT_CODE, I as handleRecallRequest, J as runClusterer, K as handleCrystallise, L as RRF_K, M as recallRouteHandler, N as checkParams, O as crystalliseRouteHandler, P as unknownParamMessage, Q as CLUSTERER_BACKEND, R as armRanks, S as createEmbedStats, T as embedRowReporting, U as createCrystalliseGuard, X as l2normalize, _ as EMBEDDINGS_FETCH_MAX_REFS, a as REINDEX_MAX_LIMIT, b as handleLexicalCoverage, c as SALIENCE_BOOST_MAX_TARGETS, d as embeddingsMigration, et as memberKey, f as recallMcpTool, g as embeddingsFetchRouteHandler, h as embeddingSimilarOperator, i as REINDEX_DEFAULT_LIMIT, j as buildClusterSurface, k as CLUSTER_FIELDS, l as lexicalMigration, m as makeLexicalPostWrite, n as salienceBoostRouteHandler, nt as validateSelector, o as handleReindex, p as makeLexicalClassify, q as validateCrystalliseInput, r as reindexRouteHandler, s as validateReindexInput, t as createRecallPlugin, tt as SELECT_CANDIDATES_MAX_LIMIT, u as recallClustersMigration, v as embedStatsRouteHandler, w as embedAndStore, x as validateLexicalCoverageInput, y as handleEmbedStatsRequest, z as fuseByRank } from "./plugin-DcoJGEMM.js";
|
|
4
4
|
|
|
5
5
|
export { CLUSTERER_BACKEND, CLUSTERER_BACKEND_VERSION, CLUSTER_FIELDS, CLUSTER_MEMBER_FIELDS, CRYSTALLISE_IN_FLIGHT_CODE, DEFAULT_CRYSTALLISE_CONFIG, EMBEDDINGS_FETCH_MAX_REFS, EmbedSourceRegistry, InMemoryClusterStore, InMemoryEmbeddingsStore, InMemoryLexicalStore, PgClusterStore, PgEmbeddingsStore, PgLexicalStore, RECALL_VERSION, REINDEX_DEFAULT_LIMIT, REINDEX_MAX_LIMIT, RRF_K, SALIENCE_BOOST_MAX_TARGETS, SELECT_CANDIDATES_MAX_LIMIT, armRanks, buildClusterSurface, checkParams, createCrystalliseGuard, createEmbedStats, createRecallPlugin, crystalliseRouteHandler, embedAndStore, embedRowReporting, embedStatsRouteHandler, embeddingSimilarOperator, embeddingsFetchRouteHandler, embeddingsMigration, fuseByRank, handleCrystallise, handleEmbedStatsRequest, handleLexicalCoverage, handleRecallRequest, handleReindex, l2normalize, lexicalMigration, makeEmbedPostWrite, makeLexicalClassify, makeLexicalPostWrite, makeReembed, memberKey, recallClustersMigration, recallMcpTool, recallRouteHandler, reindexRouteHandler, runClusterer, salienceBoostRouteHandler, unknownParamMessage, unknownParams, validateCrystalliseInput, validateLexicalCoverageInput, validateReindexInput, validateSelector };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import { a as parsePositive, i as DEFAULT_SIZING, n as defaultPluginsForPersona, r as parsePort, t as KNOWN_PLUGINS } from "./cli-
|
|
2
|
+
import { a as parsePositive, i as DEFAULT_SIZING, n as defaultPluginsForPersona, r as parsePort, t as KNOWN_PLUGINS } from "./cli-zZ7nHhY5.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as BridgeCredential } from "./bridge-
|
|
1
|
+
import { ht as AutoCrudVerb, l as FieldInput, n as Dropped, on as WhereClause, p as PlanClause, vt as Policy, xt as RequestContext, yt as PolicyDecision, zn as Row } from "./schema-B5WBO8yh.js";
|
|
2
|
+
import { n as BridgeCredential } from "./bridge-5VHZiH9o.js";
|
|
3
3
|
//#region ../../packages/substrate-types/src/nl.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The engine-dispatchable frame a successful NL translation produces. Keys
|
|
@@ -97,7 +97,7 @@ type NlOutcome = {
|
|
|
97
97
|
/**
|
|
98
98
|
* On an `aggregate` answer: `fn` of `field` over the rows the frame matches,
|
|
99
99
|
* as one `value`, or per group keyed by `by` (a field, or the `day`/`hour`
|
|
100
|
-
*
|
|
100
|
+
* date group). Absent when the engine refused the frame, with `errors` saying why.
|
|
101
101
|
*/
|
|
102
102
|
aggregate?: NlAggregate;
|
|
103
103
|
errors?: unknown[];
|
|
@@ -287,15 +287,17 @@ interface NlFieldPhrase {
|
|
|
287
287
|
value?: unknown;
|
|
288
288
|
/** Needs `field`: the implicit filter on that field's type. Never silent: it shows in `plan`. */
|
|
289
289
|
exclude?: WhereClause;
|
|
290
|
-
/** A
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
290
|
+
/** A difference (`sub`) or quotient (`div`) that orders; operands are `'<Type>.<field>'`, both on one type. */
|
|
291
|
+
select?: {
|
|
292
|
+
sub: [string, string];
|
|
293
|
+
} | {
|
|
294
|
+
div: [string, string];
|
|
295
|
+
};
|
|
294
296
|
/** A namespace default pick for this phrase. */
|
|
295
297
|
pick?: 'latest' | 'max' | 'min';
|
|
296
298
|
}
|
|
297
299
|
interface NlNamespaceRulings {
|
|
298
|
-
/** Phrases bound to fields, values, implicit filters,
|
|
300
|
+
/** Phrases bound to fields, values, implicit filters, computed orderings and pick defaults. Keys are normalised (trimmed, single-spaced, lower-cased). */
|
|
299
301
|
fieldPhrases?: Record<string, NlFieldPhrase>;
|
|
300
302
|
/** Types never scoped to the asking project (their `project` means "belongs to", not "applies to"). */
|
|
301
303
|
unscopedTypes?: string[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import { _ as AUDIT_EVENT_TYPE, g as buildAuditRow } from "./src-
|
|
2
|
+
import { _ as AUDIT_EVENT_TYPE, g as buildAuditRow } from "./src-D55T3ZcP.js";
|
|
3
3
|
import { n as trimTrailingSlashes } from "./env-utils-CGNazUNt.js";
|
|
4
|
-
import { I as decodeList, L as encodeList, M as grantEntryError, g as checkUpdatable, h as checkRevocable, y as newlyGranted } from "./src-
|
|
5
|
-
import "./src-
|
|
6
|
-
import { A as UPDATE_EXIT_CODES, B as readKeyById, C as grantLines, D as parseBootstrapArgs, E as formatBootstrapOutput, F as CLI_ACTOR_KID, G as validateArgv, H as resolveAdminAuth, I as base64Url, J as argvError, K as RESTART_NOTE, L as forUpdate, M as runKeyPatchViaRoute, N as ACTOR_HINT, O as runBootstrap, P as BootstrapError, R as generateAdminKeypair, S as runRegisterViaRoute, T as formatDoctorReport, U as resolveAdminTarget, V as describeAdminTarget, W as ARGV_SPEC, X as pgNoticeOptions, Y as AdminCliError, _ as openPgDataset, b as parseRegisterArgs, c as refuseContractViolation, d as registeredTypes, g as version, h as loadPluginsFromDir, j as runKeyListViaRoute, k as REVOKE_EXIT_CODES, l as buildDeferredIndexes, n as resolvePluginDir, q as USAGE, r as BINARY_CONTRACT_VERSION, s as parseEnv, t as bootStore, v as onboardCommand, w as doctorCommand, x as runRegister, y as formatRegisterOutput, z as listActiveAdminKeys } from "./boot-store-
|
|
7
|
-
import { C as
|
|
4
|
+
import { I as decodeList, L as encodeList, M as grantEntryError, g as checkUpdatable, h as checkRevocable, y as newlyGranted } from "./src-DR_hUj2p.js";
|
|
5
|
+
import "./src-CdbUzLhB.js";
|
|
6
|
+
import { A as UPDATE_EXIT_CODES, B as readKeyById, C as grantLines, D as parseBootstrapArgs, E as formatBootstrapOutput, F as CLI_ACTOR_KID, G as validateArgv, H as resolveAdminAuth, I as base64Url, J as argvError, K as RESTART_NOTE, L as forUpdate, M as runKeyPatchViaRoute, N as ACTOR_HINT, O as runBootstrap, P as BootstrapError, R as generateAdminKeypair, S as runRegisterViaRoute, T as formatDoctorReport, U as resolveAdminTarget, V as describeAdminTarget, W as ARGV_SPEC, X as pgNoticeOptions, Y as AdminCliError, _ as openPgDataset, b as parseRegisterArgs, c as refuseContractViolation, d as registeredTypes, g as version, h as loadPluginsFromDir, j as runKeyListViaRoute, k as REVOKE_EXIT_CODES, l as buildDeferredIndexes, n as resolvePluginDir, q as USAGE, r as BINARY_CONTRACT_VERSION, s as parseEnv, t as bootStore, v as onboardCommand, w as doctorCommand, x as runRegister, y as formatRegisterOutput, z as listActiveAdminKeys } from "./boot-store-C8KrACZ5.js";
|
|
7
|
+
import { C as copyRows, S as detectLayout, a as ensureTypeTable, b as UUID_CHECK_MIGRATION, c as typeTableRef, d as PLAIN_SCHEMA_NAME, g as isDerivedMigration, i as seqName, p as assertStoreSchema, s as loadTypeTable, u as MIGRATE_STORE_MARKER_TABLE, w as parseSourceBody, x as UUID_REGEX } from "./src-BcuotITf.js";
|
|
8
8
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { dirname } from "node:path";
|
|
10
10
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -201,6 +201,137 @@ var RowCounter = class extends Transform {
|
|
|
201
201
|
}
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/admin/migrate-store/source.ts
|
|
206
|
+
/**
|
|
207
|
+
* Read-only inventory of a migrate-store source. Every read runs in one
|
|
208
|
+
* REPEATABLE READ, READ ONLY transaction, so the inventory is one snapshot and
|
|
209
|
+
* nothing here can write to the source. It never runs migrations and never
|
|
210
|
+
* goes through `assertServerVersion`: the source may be PG 17.
|
|
211
|
+
*/
|
|
212
|
+
async function inspectSource(sql) {
|
|
213
|
+
return await sql.begin("isolation level repeatable read read only", async (tx) => {
|
|
214
|
+
await assertStoreSchema(tx);
|
|
215
|
+
const layout = await detectLayout(tx);
|
|
216
|
+
if (layout === "absent") throw new Error("the source schema holds no rows table");
|
|
217
|
+
if (layout === "tables") throw new Error("the source is already in the tables layout; migrate-store copies a legacy or partitioned store");
|
|
218
|
+
const [version] = await tx`SELECT current_setting('server_version_num')::int AS v`;
|
|
219
|
+
const [ledger] = await tx`SELECT to_regclass('migrations') IS NOT NULL AS present`;
|
|
220
|
+
const appliedMigrations = ledger?.present ? (await tx`SELECT version FROM migrations ORDER BY version`).map((r) => r.version) : [];
|
|
221
|
+
const tableRows = await tx`
|
|
222
|
+
SELECT c.relname AS name,
|
|
223
|
+
-- pg_partition_tree is empty for an ordinary table.
|
|
224
|
+
(CASE WHEN c.relkind = 'p'
|
|
225
|
+
THEN (SELECT coalesce(sum(pg_table_size(t.relid)), 0) FROM pg_partition_tree(c.oid) t WHERE t.isleaf)
|
|
226
|
+
ELSE pg_table_size(c.oid) END)::text AS bytes
|
|
227
|
+
FROM pg_class c
|
|
228
|
+
WHERE c.relnamespace = current_schema()::regnamespace
|
|
229
|
+
AND c.relkind IN ('r', 'p') AND NOT c.relispartition
|
|
230
|
+
ORDER BY c.relname`;
|
|
231
|
+
const colRows = await tx`
|
|
232
|
+
SELECT c.relname AS "table", a.attname AS col
|
|
233
|
+
FROM pg_attribute a JOIN pg_class c ON c.oid = a.attrelid
|
|
234
|
+
WHERE c.relnamespace = current_schema()::regnamespace
|
|
235
|
+
AND c.relkind IN ('r', 'p') AND NOT c.relispartition
|
|
236
|
+
AND a.attnum > 0 AND NOT a.attisdropped AND a.attgenerated = ''
|
|
237
|
+
ORDER BY c.relname, a.attnum`;
|
|
238
|
+
const columns = {};
|
|
239
|
+
for (const r of colRows) {
|
|
240
|
+
const list = columns[r.table] ?? [];
|
|
241
|
+
list.push(r.col);
|
|
242
|
+
columns[r.table] = list;
|
|
243
|
+
}
|
|
244
|
+
const types = await tx`
|
|
245
|
+
SELECT namespace, type,
|
|
246
|
+
count(*) FILTER (WHERE deleted_at IS NULL)::text AS live,
|
|
247
|
+
count(*) FILTER (WHERE deleted_at IS NOT NULL)::text AS deleted,
|
|
248
|
+
coalesce(sum(pg_column_size(r.*)), 0)::text AS bytes
|
|
249
|
+
FROM rows r GROUP BY namespace, type ORDER BY namespace, type`;
|
|
250
|
+
const nonUuid = (table, column, nsCol, typeCol) => tx`
|
|
251
|
+
SELECT ${tx(nsCol)} AS namespace, ${tx(typeCol)} AS type, ${tx(column)} AS id
|
|
252
|
+
FROM ${tx(table)} WHERE ${tx(column)} !~ ${UUID_REGEX}
|
|
253
|
+
ORDER BY 1, 2, 3 LIMIT 20`.then((rs) => rs.map((r) => ({
|
|
254
|
+
table,
|
|
255
|
+
column,
|
|
256
|
+
...r
|
|
257
|
+
})));
|
|
258
|
+
const nonUuidIds = appliedMigrations.includes("0002_uuid_format_check") ? [] : [
|
|
259
|
+
...await nonUuid("rows", "id", "namespace", "type"),
|
|
260
|
+
...columns.short_ids ? await nonUuid("short_ids", "row_id", "namespace", "type") : [],
|
|
261
|
+
...columns.edges ? await nonUuid("edges", "from_id", "from_ns", "from_type") : [],
|
|
262
|
+
...columns.edges ? await nonUuid("edges", "to_id", "to_ns", "to_type") : []
|
|
263
|
+
];
|
|
264
|
+
const [dims] = columns.embeddings ? await tx`
|
|
265
|
+
SELECT a.atttypmod AS dims FROM pg_attribute a
|
|
266
|
+
WHERE a.attrelid = to_regclass('embeddings') AND a.attname = 'embedding' AND NOT a.attisdropped` : [];
|
|
267
|
+
const extensions = await tx`SELECT extname, extversion FROM pg_extension ORDER BY extname`;
|
|
268
|
+
const sessions = await tx`
|
|
269
|
+
SELECT pid, extract(epoch FROM backend_start)::text AS start, usename,
|
|
270
|
+
application_name AS "applicationName", client_addr::text AS "clientAddr",
|
|
271
|
+
backend_type AS "backendType", state
|
|
272
|
+
FROM pg_stat_activity
|
|
273
|
+
WHERE datname = current_database() AND pid <> pg_backend_pid()
|
|
274
|
+
-- Another role's session shows a NULL backend_type to a non-monitoring role.
|
|
275
|
+
AND (backend_type = 'client backend' OR (backend_type IS NULL AND usesysid IS NOT NULL))
|
|
276
|
+
ORDER BY pid`;
|
|
277
|
+
return {
|
|
278
|
+
serverVersionNum: version?.v ?? 0,
|
|
279
|
+
layout,
|
|
280
|
+
appliedMigrations,
|
|
281
|
+
hasSeq: columns.rows?.includes("seq") ?? false,
|
|
282
|
+
hasVisibleSeqs: columns.visible_seqs !== void 0,
|
|
283
|
+
types: types.map((t) => ({
|
|
284
|
+
...t,
|
|
285
|
+
live: Number(t.live),
|
|
286
|
+
deleted: Number(t.deleted),
|
|
287
|
+
bytes: Number(t.bytes)
|
|
288
|
+
})),
|
|
289
|
+
tables: tableRows.map((t) => t.name),
|
|
290
|
+
columns,
|
|
291
|
+
tableBytes: Object.fromEntries(tableRows.map((t) => [t.name, Number(t.bytes)])),
|
|
292
|
+
nonUuidIds,
|
|
293
|
+
vectorDims: dims !== void 0 && dims.dims > 0 ? dims.dims : null,
|
|
294
|
+
extensions: Object.fromEntries(extensions.map((e) => [e.extname, e.extversion])),
|
|
295
|
+
otherSessions: sessions.length,
|
|
296
|
+
sessions
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/** The `rows` columns the engine itself defined in the legacy and partitioned layouts. */
|
|
301
|
+
const ENGINE_ROWS_COLUMNS = /* @__PURE__ */ new Set([
|
|
302
|
+
"namespace",
|
|
303
|
+
"type",
|
|
304
|
+
"id",
|
|
305
|
+
"body",
|
|
306
|
+
"deleted_at",
|
|
307
|
+
"created_at",
|
|
308
|
+
"updated_at",
|
|
309
|
+
"created_by_kind",
|
|
310
|
+
"created_by_id",
|
|
311
|
+
"updated_by_kind",
|
|
312
|
+
"updated_by_id",
|
|
313
|
+
"seq"
|
|
314
|
+
]);
|
|
315
|
+
/** The fields a target type table declares, orphaned columns excluded. */
|
|
316
|
+
function declaredFields(table) {
|
|
317
|
+
if (table === void 0) return [];
|
|
318
|
+
return [...table.columns().filter((c) => c.state !== "orphaned").map((c) => c.field), ...table.pending];
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* SQL for a source row's body as the old engine read it. A plugin migration could add a `rows`
|
|
322
|
+
* column mirroring a body field (cortext's `archived boolean NOT NULL DEFAULT false`), and old
|
|
323
|
+
* filters read that column, so a body lacking the key still matched `archived eq false`. A
|
|
324
|
+
* non-null mirror column named after a declared field fills that field when the body lacks it;
|
|
325
|
+
* where the body has the key, the body wins.
|
|
326
|
+
* shortcut: matches a mirror column to its field by name only (every known plugin uses the field
|
|
327
|
+
* name); a plugin that renamed its column would need its promotedColumns map read here.
|
|
328
|
+
*/
|
|
329
|
+
function sourceBodySql(rowsColumns, declared) {
|
|
330
|
+
const mirrored = rowsColumns.filter((c) => !ENGINE_ROWS_COLUMNS.has(c) && declared.includes(c));
|
|
331
|
+
if (mirrored.length === 0) return "body";
|
|
332
|
+
return `(jsonb_strip_nulls(jsonb_build_object(${mirrored.map((c) => `'${c.replace(/'/g, "''")}', "${c.replace(/"/g, "\"\"")}"`).join(", ")})) || body)`;
|
|
333
|
+
}
|
|
334
|
+
|
|
204
335
|
//#endregion
|
|
205
336
|
//#region src/admin/migrate-store/copy.ts
|
|
206
337
|
/**
|
|
@@ -552,7 +683,7 @@ async function convertRows(src, tsql, t, filter, tables, counter, batchRows, mis
|
|
|
552
683
|
const table = tables.get(key);
|
|
553
684
|
if (table === void 0) throw new Error(`internal: no table prepared for ${key}`);
|
|
554
685
|
const cursor = src`
|
|
555
|
-
SELECT id,
|
|
686
|
+
SELECT id, ${src.unsafe(sourceBodySql(t.columns, declaredFields(table)))}::text AS body, deleted_at::text, created_at::text, updated_at::text,
|
|
556
687
|
created_by_kind, created_by_id, updated_by_kind, updated_by_id,
|
|
557
688
|
${seq} AS seq
|
|
558
689
|
FROM rows WHERE namespace = ${namespace} AND type = ${type} ${where}
|
|
@@ -673,103 +804,6 @@ async function markStep(tsql, step) {
|
|
|
673
804
|
ON CONFLICT (step) DO UPDATE SET done_at = excluded.done_at`;
|
|
674
805
|
}
|
|
675
806
|
|
|
676
|
-
//#endregion
|
|
677
|
-
//#region src/admin/migrate-store/source.ts
|
|
678
|
-
/**
|
|
679
|
-
* Read-only inventory of a migrate-store source. Every read runs in one
|
|
680
|
-
* REPEATABLE READ, READ ONLY transaction, so the inventory is one snapshot and
|
|
681
|
-
* nothing here can write to the source. It never runs migrations and never
|
|
682
|
-
* goes through `assertServerVersion`: the source may be PG 17.
|
|
683
|
-
*/
|
|
684
|
-
async function inspectSource(sql) {
|
|
685
|
-
return await sql.begin("isolation level repeatable read read only", async (tx) => {
|
|
686
|
-
await assertStoreSchema(tx);
|
|
687
|
-
const layout = await detectLayout(tx);
|
|
688
|
-
if (layout === "absent") throw new Error("the source schema holds no rows table");
|
|
689
|
-
if (layout === "tables") throw new Error("the source is already in the tables layout; migrate-store copies a legacy or partitioned store");
|
|
690
|
-
const [version] = await tx`SELECT current_setting('server_version_num')::int AS v`;
|
|
691
|
-
const [ledger] = await tx`SELECT to_regclass('migrations') IS NOT NULL AS present`;
|
|
692
|
-
const appliedMigrations = ledger?.present ? (await tx`SELECT version FROM migrations ORDER BY version`).map((r) => r.version) : [];
|
|
693
|
-
const tableRows = await tx`
|
|
694
|
-
SELECT c.relname AS name,
|
|
695
|
-
-- pg_partition_tree is empty for an ordinary table.
|
|
696
|
-
(CASE WHEN c.relkind = 'p'
|
|
697
|
-
THEN (SELECT coalesce(sum(pg_table_size(t.relid)), 0) FROM pg_partition_tree(c.oid) t WHERE t.isleaf)
|
|
698
|
-
ELSE pg_table_size(c.oid) END)::text AS bytes
|
|
699
|
-
FROM pg_class c
|
|
700
|
-
WHERE c.relnamespace = current_schema()::regnamespace
|
|
701
|
-
AND c.relkind IN ('r', 'p') AND NOT c.relispartition
|
|
702
|
-
ORDER BY c.relname`;
|
|
703
|
-
const colRows = await tx`
|
|
704
|
-
SELECT c.relname AS "table", a.attname AS col
|
|
705
|
-
FROM pg_attribute a JOIN pg_class c ON c.oid = a.attrelid
|
|
706
|
-
WHERE c.relnamespace = current_schema()::regnamespace
|
|
707
|
-
AND c.relkind IN ('r', 'p') AND NOT c.relispartition
|
|
708
|
-
AND a.attnum > 0 AND NOT a.attisdropped AND a.attgenerated = ''
|
|
709
|
-
ORDER BY c.relname, a.attnum`;
|
|
710
|
-
const columns = {};
|
|
711
|
-
for (const r of colRows) {
|
|
712
|
-
const list = columns[r.table] ?? [];
|
|
713
|
-
list.push(r.col);
|
|
714
|
-
columns[r.table] = list;
|
|
715
|
-
}
|
|
716
|
-
const types = await tx`
|
|
717
|
-
SELECT namespace, type,
|
|
718
|
-
count(*) FILTER (WHERE deleted_at IS NULL)::text AS live,
|
|
719
|
-
count(*) FILTER (WHERE deleted_at IS NOT NULL)::text AS deleted,
|
|
720
|
-
coalesce(sum(pg_column_size(r.*)), 0)::text AS bytes
|
|
721
|
-
FROM rows r GROUP BY namespace, type ORDER BY namespace, type`;
|
|
722
|
-
const nonUuid = (table, column, nsCol, typeCol) => tx`
|
|
723
|
-
SELECT ${tx(nsCol)} AS namespace, ${tx(typeCol)} AS type, ${tx(column)} AS id
|
|
724
|
-
FROM ${tx(table)} WHERE ${tx(column)} !~ ${UUID_REGEX}
|
|
725
|
-
ORDER BY 1, 2, 3 LIMIT 20`.then((rs) => rs.map((r) => ({
|
|
726
|
-
table,
|
|
727
|
-
column,
|
|
728
|
-
...r
|
|
729
|
-
})));
|
|
730
|
-
const nonUuidIds = appliedMigrations.includes("0002_uuid_format_check") ? [] : [
|
|
731
|
-
...await nonUuid("rows", "id", "namespace", "type"),
|
|
732
|
-
...columns.short_ids ? await nonUuid("short_ids", "row_id", "namespace", "type") : [],
|
|
733
|
-
...columns.edges ? await nonUuid("edges", "from_id", "from_ns", "from_type") : [],
|
|
734
|
-
...columns.edges ? await nonUuid("edges", "to_id", "to_ns", "to_type") : []
|
|
735
|
-
];
|
|
736
|
-
const [dims] = columns.embeddings ? await tx`
|
|
737
|
-
SELECT a.atttypmod AS dims FROM pg_attribute a
|
|
738
|
-
WHERE a.attrelid = to_regclass('embeddings') AND a.attname = 'embedding' AND NOT a.attisdropped` : [];
|
|
739
|
-
const extensions = await tx`SELECT extname, extversion FROM pg_extension ORDER BY extname`;
|
|
740
|
-
const sessions = await tx`
|
|
741
|
-
SELECT pid, extract(epoch FROM backend_start)::text AS start, usename,
|
|
742
|
-
application_name AS "applicationName", client_addr::text AS "clientAddr",
|
|
743
|
-
backend_type AS "backendType", state
|
|
744
|
-
FROM pg_stat_activity
|
|
745
|
-
WHERE datname = current_database() AND pid <> pg_backend_pid()
|
|
746
|
-
-- Another role's session shows a NULL backend_type to a non-monitoring role.
|
|
747
|
-
AND (backend_type = 'client backend' OR (backend_type IS NULL AND usesysid IS NOT NULL))
|
|
748
|
-
ORDER BY pid`;
|
|
749
|
-
return {
|
|
750
|
-
serverVersionNum: version?.v ?? 0,
|
|
751
|
-
layout,
|
|
752
|
-
appliedMigrations,
|
|
753
|
-
hasSeq: columns.rows?.includes("seq") ?? false,
|
|
754
|
-
hasVisibleSeqs: columns.visible_seqs !== void 0,
|
|
755
|
-
types: types.map((t) => ({
|
|
756
|
-
...t,
|
|
757
|
-
live: Number(t.live),
|
|
758
|
-
deleted: Number(t.deleted),
|
|
759
|
-
bytes: Number(t.bytes)
|
|
760
|
-
})),
|
|
761
|
-
tables: tableRows.map((t) => t.name),
|
|
762
|
-
columns,
|
|
763
|
-
tableBytes: Object.fromEntries(tableRows.map((t) => [t.name, Number(t.bytes)])),
|
|
764
|
-
nonUuidIds,
|
|
765
|
-
vectorDims: dims !== void 0 && dims.dims > 0 ? dims.dims : null,
|
|
766
|
-
extensions: Object.fromEntries(extensions.map((e) => [e.extname, e.extversion])),
|
|
767
|
-
otherSessions: sessions.length,
|
|
768
|
-
sessions
|
|
769
|
-
};
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
|
|
773
807
|
//#endregion
|
|
774
808
|
//#region src/admin/migrate-store/preflight.ts
|
|
775
809
|
/** Pure preflight: turns a source inventory plus target facts into refusals, warnings and a copy plan. */
|
|
@@ -1152,13 +1186,15 @@ async function snapshot(tx, side, seeds, other, opts, types) {
|
|
|
1152
1186
|
}
|
|
1153
1187
|
const hasSeq = side === "source" ? (await colsOf("rows"))?.includes("seq") === true : other?.columns.get("rows")?.includes("seq") !== false;
|
|
1154
1188
|
const meta = `row(${META}, ${hasSeq ? "seq::text" : "NULL::text"})::text`;
|
|
1189
|
+
const rowsColumns = side === "source" ? (await tx`
|
|
1190
|
+
SELECT attname AS col FROM pg_attribute
|
|
1191
|
+
WHERE attrelid = to_regclass('rows') AND attnum > 0 AND NOT attisdropped AND attgenerated = ''`).map((r) => r.col) : [];
|
|
1155
1192
|
for (const { namespace, type } of counted) {
|
|
1156
1193
|
let rows;
|
|
1157
1194
|
let params;
|
|
1158
1195
|
if (side === "source") {
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1161
|
-
rows = `SELECT id || E'\n' || (SELECT coalesce(jsonb_object_agg(k, v), '{}'::jsonb) FROM jsonb_each(body) e(k, v)
|
|
1196
|
+
const declared = declaredFields(types.get(`${namespace}/${type}`));
|
|
1197
|
+
rows = `SELECT id || E'\n' || (SELECT coalesce(jsonb_object_agg(k, v), '{}'::jsonb) FROM jsonb_each(${sourceBodySql(rowsColumns, declared)}) e(k, v)
|
|
1162
1198
|
WHERE NOT (v = 'null'::jsonb AND k = ANY($3::text[])))::text || E'\n' || ${meta} AS h
|
|
1163
1199
|
FROM rows WHERE namespace = $1 AND type = $2 ORDER BY md5(id) COLLATE "C" LIMIT ${limit}`;
|
|
1164
1200
|
params = [
|