@mnmal-ai/substrate 1.0.0-alpha.1 → 1.0.0-alpha.11
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 +48 -6
- package/dist/boot-store-C5vNZJ3i.js +4065 -0
- package/dist/{runtime-metrics-DwpDJ8vz.d.ts → bridge-COu0Tg_h.d.ts} +2 -87
- package/dist/cli-BrwW4tjO.js +3144 -0
- package/dist/client.d.ts +129 -8
- package/dist/client.js +6 -5
- package/dist/{agent-token-BIboWOU0.js → env-utils-CGNazUNt.js} +31 -2
- package/dist/{errors-D4vKuwz8.d.ts → errors-BOllGhVx.d.ts} +15 -2
- package/dist/{index-D7mSOFlM.d.ts → index-Cp74OcmS.d.ts} +1 -1
- package/dist/node-version-C5FSmwJX.js +26 -0
- package/dist/pack.d.ts +2 -2
- package/dist/pack.js +1 -1
- package/dist/pg-edges-store-BLsbcXkk.js +381 -0
- package/dist/{plugin-BuQQEzL-.js → plugin-DIYm2cZE.js} +171 -18
- package/dist/proposals-bootstrap.js +6 -4
- package/dist/proposals.config.schema.json +5 -0
- package/dist/proposals.d.ts +14 -4
- package/dist/proposals.default-config.json +2 -1
- package/dist/proposals.js +2 -2
- package/dist/recall-bootstrap.js +13 -4
- package/dist/recall.config.schema.json +12 -0
- package/dist/recall.d.ts +53 -9
- package/dist/recall.js +2 -2
- package/dist/{repl-C52wyfMs.js → repl-B8gy0YM7.js} +63 -30
- package/dist/{row-ByLFE2Wx.d.ts → row-DwaDU4b-.d.ts} +58 -9
- package/dist/run-B18qtGKc.js +2012 -0
- package/dist/{plugin-t2g2wX0b.d.ts → schema-CijHRfuk.d.ts} +957 -16
- package/dist/script-C6DSa_Na.js +134 -0
- package/dist/sdk.d.ts +104 -16
- package/dist/sdk.js +5 -110
- package/dist/{src-DuopV8u7.js → src-Br6aDUti.js} +153 -20
- package/dist/{src-5hVbeiAu.js → src-D041j6GS.js} +697 -57
- package/dist/{src-YXlv_RyL.js → src-DK7VEQT6.js} +4099 -1040
- package/dist/{src-C4DzaIQZ.js → src-Dbvuel6w.js} +392 -282
- package/dist/{row-DK7lPZVe.js → src-DpPdw2oL.js} +11 -11
- package/dist/{src-zcyUofMJ.js → src-DptNGNYQ.js} +39 -15
- package/dist/src-gz4I1F29.js +5097 -0
- package/dist/substrate-admin.js +17 -781
- package/dist/substrate.js +4 -5476
- package/dist/testing.d.ts +582 -9
- package/dist/testing.js +39 -3
- package/dist/{ws-C72iVS5T.d.ts → ws-DC8OhMaV.d.ts} +2 -3
- package/package.json +22 -20
- package/dist/dataset-DOXGRz50.js +0 -1535
- package/dist/env-utils-B7SGmoeJ.js +0 -21
- package/dist/schema-g4FQLr0V.d.ts +0 -433
- package/dist/src-CjEwiKXw.js +0 -2327
package/dist/testing.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import { $ as PolicyProbeContext, A as ScheduledTask, B as StartOpts, C as QualifiedFrame, D as RegistryEntryInput, E as RegistryEntry, F as HttpMethod, G as WsConnection, H as SubstrateResponse, I as PluginRouter, K as WsHandler, P as HttpHandler, Q as PolicyDecision, R as RequestObserver, St as WriteResult, T as RegistryBase, U as SubstrateServer, V as SubstrateRequest, Y as Identity, _t as ReadResult, a as EngineHandle, ct as Dataset, dt as DropResult, et as RequestContext, g as NamespaceConfig, gt as ReadParams, lt as DatasetRegistry, mt as FilterCapabilities, n as DropParticipant, o as EngineInput, p as KernelPlugin, st as ConditionalUpdateResult, t as CoordinatorPlugin, ut as DeleteResult, w as Registry$1, xt as WriteOptions, yt as UpdateFieldRef, z as RuntimeOp } from "./plugin-t2g2wX0b.js";
|
|
4
|
-
import { a as WsResponseFrame, f as IdempotencyStore, l as SweepDeps, s as BridgeRegistry, u as SweepState } from "./ws-C72iVS5T.js";
|
|
1
|
+
import { $ as PluginRouter, $t as WriteOptions, A as KernelPlugin, B as QualifiedFrame, Bt as ReadResult, Cn as Row, Dt as Dataset, En as WriteRow, Et as ConditionalUpdateResult, Gt as TypeStorageReport, H as RegistryBase, Ht as StorageReport, It as IndexPlan, Kt as UpdateFieldRef, N as NamespaceConfig, Ot as DatasetRegistry, Pt as FilterCapabilities, Q as HttpMethod, S as EngineInput, T as IndexDecl, U as RegistryEntry, Ut as TxScopeHandles, V as Registry$1, W as RegistryEntryInput, Z as HttpHandler, _ as CoordinatorPlugin, _n as ActorIdentity, _t as RequestContext, an as RuntimeErrors, at as SubstrateResponse, bn as Id, cn as TypeStats, ct as WsConnection, d as OrderedBy, dn as EdgePatch, en as WriteResult, f as PackEnvelope, fn as EdgeRef, ft as Identity, gt as PolicyProbeContext, ht as PolicyDecision, i as FieldDef, it as SubstrateRequest, jt as DropResult, kt as DeleteResult, ln as CanDeleteResult, lt as WsHandler, m as Schema, mn as EdgesStore, nn as ResolveObservation, nt as RuntimeOp, ot as SubstrateServer, pn as EdgeWriteInput, q as ScheduledTask, rn as ResolverStat, rt as StartOpts, sn as SlowRequest, tn as ProcessStat, tt as RequestObserver, un as Edge, v as DropParticipant, x as EngineHandle, yt as ResolverArgs, zt as ReadParams } from "./schema-CijHRfuk.js";
|
|
2
|
+
import { a as WsResponseFrame, f as IdempotencyStore, l as SweepDeps, s as BridgeRegistry, u as SweepState } from "./ws-DC8OhMaV.js";
|
|
5
3
|
import { t as Embedder } from "./types-8c0gtnd2.js";
|
|
4
|
+
import { Sql, TransactionSql } from "postgres";
|
|
6
5
|
//#region ../../packages/substrate-compose/src/auth.d.ts
|
|
7
6
|
type JwtAlg = 'RS256' | 'ES256' | 'HS256' | 'EdDSA';
|
|
8
7
|
interface AuthKey {
|
|
@@ -55,8 +54,8 @@ interface AuthConfig {
|
|
|
55
54
|
maxTokenLifetimeSeconds?: number;
|
|
56
55
|
/**
|
|
57
56
|
* The origins this server answers as (`SUBSTRATE_PUBLIC_ORIGIN`). When set, a
|
|
58
|
-
* token
|
|
59
|
-
*
|
|
57
|
+
* token must carry `aud` naming one of them, or it is refused. Absent → `aud`
|
|
58
|
+
* is not checked.
|
|
60
59
|
*/
|
|
61
60
|
audiences?: ReadonlyArray<string>;
|
|
62
61
|
/**
|
|
@@ -75,6 +74,13 @@ export declare function signHs256(payload: Record<string, unknown>, secret: stri
|
|
|
75
74
|
kid?: string;
|
|
76
75
|
}): string;
|
|
77
76
|
//#endregion
|
|
77
|
+
//#region ../../packages/substrate-compose/src/advisor/profiles.d.ts
|
|
78
|
+
/**
|
|
79
|
+
* Sizing profiles: how sensitive the index advisor is. A profile only tunes
|
|
80
|
+
* when a recommendation is written; nothing is ever built without approval.
|
|
81
|
+
*/
|
|
82
|
+
type StoreProfileName = 'personal' | 'growth' | 'scale';
|
|
83
|
+
//#endregion
|
|
78
84
|
//#region ../../packages/substrate-compose/src/_system/types.d.ts
|
|
79
85
|
/**
|
|
80
86
|
* Where the operator's agent DIRECTORY lives, so `POST /substrate/v1/_system/keys` can
|
|
@@ -187,6 +193,38 @@ interface RateLimiter {
|
|
|
187
193
|
dispose(): void;
|
|
188
194
|
}
|
|
189
195
|
//#endregion
|
|
196
|
+
//#region ../../packages/substrate-core/src/advisor/shape-recorder.d.ts
|
|
197
|
+
interface ReadShape {
|
|
198
|
+
namespace: string;
|
|
199
|
+
type: string;
|
|
200
|
+
filters: Array<{
|
|
201
|
+
field: string;
|
|
202
|
+
op: string;
|
|
203
|
+
}>;
|
|
204
|
+
orderBy: Array<[string, 'asc' | 'desc']>;
|
|
205
|
+
/** An OR or a NOT somewhere in the filter: no composite index serves it as a conjunction. */
|
|
206
|
+
disjunctive?: true;
|
|
207
|
+
/**
|
|
208
|
+
* The boolean or null operand of each top-level (or AND-ed) `eq`, the only
|
|
209
|
+
* operand values kept: they decide whether a partial index's predicate
|
|
210
|
+
* holds, and have three possible values.
|
|
211
|
+
*/
|
|
212
|
+
literals?: Record<string, boolean | null>;
|
|
213
|
+
}
|
|
214
|
+
declare class ShapeRecorder {
|
|
215
|
+
#private;
|
|
216
|
+
/** When this recorder was created or last drained: the start of what `drain` returns. */
|
|
217
|
+
since: number;
|
|
218
|
+
constructor(now?: () => number);
|
|
219
|
+
observe(shape: ReadShape, durationMs: number): void;
|
|
220
|
+
/** Every shape seen since the last drain, with its count and p95; then forgets them. */
|
|
221
|
+
drain(): Array<{
|
|
222
|
+
shape: ReadShape;
|
|
223
|
+
count: number;
|
|
224
|
+
p95Ms: number;
|
|
225
|
+
}>;
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
190
228
|
//#region ../../packages/substrate-core/src/registry.d.ts
|
|
191
229
|
type TypeKey = string | {
|
|
192
230
|
readonly name: string;
|
|
@@ -232,6 +270,12 @@ interface EngineOptions {
|
|
|
232
270
|
* does no timing at all.
|
|
233
271
|
*/
|
|
234
272
|
onResolve?: (o: ResolveObservation) => void;
|
|
273
|
+
/**
|
|
274
|
+
* Observes each successful local read of a type: its shape (filtered fields
|
|
275
|
+
* and operators, the effective order including the natural one) and how long
|
|
276
|
+
* the resolver took. For the index advisor; absent means no recording.
|
|
277
|
+
*/
|
|
278
|
+
shapeRecorder?: Pick<ShapeRecorder, 'observe'>;
|
|
235
279
|
/**
|
|
236
280
|
* Idempotency dedup (§5.13). Absent → no dedup; `FrameEntry.idempotencyKey`
|
|
237
281
|
* is ignored on mutate (queries ignore it unconditionally). Present → the
|
|
@@ -472,7 +516,7 @@ declare class Engine {
|
|
|
472
516
|
* caller's `probe` context so policies reading headers, `clientIp`, `meta`
|
|
473
517
|
* or `authEnabled` decide as they would in dispatch.
|
|
474
518
|
*/
|
|
475
|
-
evaluateReadPolicy(ns: string, type: string, identity: Identity | null, probe?: PolicyProbeContext): PolicyDecision;
|
|
519
|
+
evaluateReadPolicy(ns: string, type: string, identity: Identity | null, probe?: PolicyProbeContext, args?: ResolverArgs): PolicyDecision;
|
|
476
520
|
/**
|
|
477
521
|
* Refresh the cached schemas for every registered bridge. Callers invoke
|
|
478
522
|
* this at composition-root wire-up time to populate `federatedSchema()`'s
|
|
@@ -728,11 +772,39 @@ interface MemoryDatasetOptions {
|
|
|
728
772
|
* tests without spinning up pg.
|
|
729
773
|
*/
|
|
730
774
|
txScopeId?: string;
|
|
775
|
+
/**
|
|
776
|
+
* The namespace's field declarations. Lets `date` fields filter and sort as
|
|
777
|
+
* instants, as the pg dataset's lookup does; without it they compare as text.
|
|
778
|
+
*/
|
|
779
|
+
fieldDefLookup?: (type: string, field: string) => FieldDef | undefined;
|
|
780
|
+
/**
|
|
781
|
+
* The namespace's type definitions; a type declared `ordering: 'visible'`
|
|
782
|
+
* gets `_metadata.seq` on insert, as the pg dataset's lookup does.
|
|
783
|
+
*/
|
|
784
|
+
typeDefLookup?: (type: string, namespace: string) => {
|
|
785
|
+
ordering?: 'visible';
|
|
786
|
+
} | undefined;
|
|
787
|
+
/**
|
|
788
|
+
* Internal: binding assignments one read's walks may try before refusing
|
|
789
|
+
* `walk_budget_exceeded`. Defaults to `WALK_EVALUATION_BUDGET`; tests lower it.
|
|
790
|
+
*/
|
|
791
|
+
walkBudget?: number;
|
|
792
|
+
/**
|
|
793
|
+
* Test-only: declare and answer the typed-edge-walk grammar. The memory
|
|
794
|
+
* dataset is the parity reference for the pg walk compiler, not a walk
|
|
795
|
+
* store; without this the engine refuses walks on it (`walks_unsupported_store`).
|
|
796
|
+
*/
|
|
797
|
+
walkReference?: boolean;
|
|
731
798
|
}
|
|
732
799
|
export declare class MemoryDataset implements Dataset {
|
|
733
800
|
#private;
|
|
734
801
|
readonly namespace: string;
|
|
735
802
|
readonly txScopeId: string;
|
|
803
|
+
private readonly typeDefLookup;
|
|
804
|
+
private readonly walkBudget;
|
|
805
|
+
private readonly walkReference;
|
|
806
|
+
/** Last seq assigned per visible-order type; never decreases, as pg's `visible_seqs`. */
|
|
807
|
+
private seqs;
|
|
736
808
|
readonly capabilities: FilterCapabilities;
|
|
737
809
|
/** See `Dataset.withAdvisoryLock`. Excludes holders on this instance. */
|
|
738
810
|
withAdvisoryLock<T>(key: string, fn: () => Promise<T>): Promise<T>;
|
|
@@ -741,7 +813,13 @@ export declare class MemoryDataset implements Dataset {
|
|
|
741
813
|
constructor(options: MemoryDatasetOptions);
|
|
742
814
|
private bucket;
|
|
743
815
|
read(type: string, params: ReadParams): Promise<ReadResult>;
|
|
744
|
-
|
|
816
|
+
/**
|
|
817
|
+
* Walks over this namespace's live rows, for one read. Neighbours follow the
|
|
818
|
+
* row body's crossRef value (spec 2026-10-24-typed-edge-walks §1), indexed
|
|
819
|
+
* per (type, field) on first use.
|
|
820
|
+
*/
|
|
821
|
+
private walkContext;
|
|
822
|
+
write(type: string, rows: WriteRow[], options?: WriteOptions): Promise<WriteResult>;
|
|
745
823
|
tombstone(type: string, ids: Id[]): Promise<DeleteResult>;
|
|
746
824
|
purge(type: string, ids: Id[]): Promise<DeleteResult>;
|
|
747
825
|
dropType(type: string): Promise<DropResult>;
|
|
@@ -979,6 +1057,20 @@ interface ComposeOpts {
|
|
|
979
1057
|
* second reading of the environment. Omitted by programmatic embedders.
|
|
980
1058
|
*/
|
|
981
1059
|
configReport?: ConfigReport;
|
|
1060
|
+
/** Reported beside `configReport`; ignored without it. */
|
|
1061
|
+
storageReport?: () => Promise<StorageReport>;
|
|
1062
|
+
/**
|
|
1063
|
+
* The index advisor. Every `intervalMs` (`SUBSTRATE_ADVISOR_INTERVAL_MS`)
|
|
1064
|
+
* it turns the reads the engine recorded and the store's statistics into
|
|
1065
|
+
* `_system/IndexRecommendation` rows. Omitted or `intervalMs: 0`: off, and
|
|
1066
|
+
* no read is recorded. `storeProfile` seeds `_system/StoreProfile` when it
|
|
1067
|
+
* has no row yet.
|
|
1068
|
+
*/
|
|
1069
|
+
advisor?: {
|
|
1070
|
+
intervalMs: number;
|
|
1071
|
+
storeProfile?: StoreProfileName;
|
|
1072
|
+
writeHeavy?: boolean;
|
|
1073
|
+
};
|
|
982
1074
|
}
|
|
983
1075
|
interface ComposeResult {
|
|
984
1076
|
engine: Engine;
|
|
@@ -1001,6 +1093,10 @@ interface ComposeResult {
|
|
|
1001
1093
|
* loop in `main.ts`.
|
|
1002
1094
|
*/
|
|
1003
1095
|
runSweepNow: () => Promise<SweepState>;
|
|
1096
|
+
/** Run one index-advisor pass now, for tests; null while the advisor is off. */
|
|
1097
|
+
runAdvisorNow: (() => Promise<{
|
|
1098
|
+
upserted: number;
|
|
1099
|
+
}>) | null;
|
|
1004
1100
|
/**
|
|
1005
1101
|
* Non-null when any coordinator plugin contributed a `schedule`. The
|
|
1006
1102
|
* composition root constructs the scheduler, registers every plugin's
|
|
@@ -1017,6 +1113,466 @@ interface ComposeResult {
|
|
|
1017
1113
|
}
|
|
1018
1114
|
export declare function compose(opts: ComposeOpts): Promise<ComposeResult>;
|
|
1019
1115
|
//#endregion
|
|
1116
|
+
//#region ../../packages/substrate-dataset-pg/src/disk-guard.d.ts
|
|
1117
|
+
/**
|
|
1118
|
+
* Refuses a background index build that would leave less than a margin of
|
|
1119
|
+
* free space on the database volume. Postgres cannot report filesystem space,
|
|
1120
|
+
* so the volume is a local path the operator names; with none, every build is
|
|
1121
|
+
* allowed and `path` is undefined so the storage report can say checks are off.
|
|
1122
|
+
*/
|
|
1123
|
+
interface DiskGuard {
|
|
1124
|
+
readonly path: string | undefined;
|
|
1125
|
+
check(estimateBytes: number): Promise<{
|
|
1126
|
+
ok: true;
|
|
1127
|
+
} | {
|
|
1128
|
+
ok: false;
|
|
1129
|
+
freeBytes: number;
|
|
1130
|
+
needBytes: number;
|
|
1131
|
+
}>;
|
|
1132
|
+
}
|
|
1133
|
+
//#endregion
|
|
1134
|
+
//#region ../../packages/substrate-dataset-pg/src/layout.d.ts
|
|
1135
|
+
type StorageLayout = 'legacy' | 'partitioned';
|
|
1136
|
+
//#endregion
|
|
1137
|
+
//#region ../../packages/substrate-dataset-pg/src/pg-sql/primitives.d.ts
|
|
1138
|
+
/**
|
|
1139
|
+
* A body key mirrored into a dedicated column on `rows`, so filters and
|
|
1140
|
+
* sorts on it hit an index instead of extracting from JSONB.
|
|
1141
|
+
*
|
|
1142
|
+
* `column` is a BARE column name, not a qualified `r.<col>` fragment: taking a
|
|
1143
|
+
* fragment from a caller would put caller text into `sql.unsafe`.
|
|
1144
|
+
*/
|
|
1145
|
+
interface PromotedBodyColumn {
|
|
1146
|
+
column: string;
|
|
1147
|
+
kind: 'boolean' | 'text';
|
|
1148
|
+
}
|
|
1149
|
+
type PromotedBodyColumnMap = Readonly<Record<string, PromotedBodyColumn>>;
|
|
1150
|
+
//#endregion
|
|
1151
|
+
//#region ../../packages/substrate-dataset-pg/src/migrate.d.ts
|
|
1152
|
+
/**
|
|
1153
|
+
* Public migration shape accepted by the runner. Either supply both
|
|
1154
|
+
* `txStatements` + (optional) `concurrentStatements`, OR a legacy
|
|
1155
|
+
* `statements` bucket — the runner treats `statements` as `txStatements`
|
|
1156
|
+
* with no concurrent statements. Mixing `statements` and `txStatements`
|
|
1157
|
+
* is a configuration error.
|
|
1158
|
+
*/
|
|
1159
|
+
type MigrationInput = {
|
|
1160
|
+
readonly version: string;
|
|
1161
|
+
readonly txStatements: ReadonlyArray<string>;
|
|
1162
|
+
readonly concurrentStatements?: ReadonlyArray<string>;
|
|
1163
|
+
readonly statements?: never;
|
|
1164
|
+
} | {
|
|
1165
|
+
readonly version: string;
|
|
1166
|
+
readonly statements: ReadonlyArray<string>;
|
|
1167
|
+
readonly txStatements?: never;
|
|
1168
|
+
readonly concurrentStatements?: never;
|
|
1169
|
+
};
|
|
1170
|
+
interface RunMigrationsOptions {
|
|
1171
|
+
/**
|
|
1172
|
+
* When true, drop the `migrations` tracking table before running.
|
|
1173
|
+
* Forces every migration to re-apply on this call. Intended for tests
|
|
1174
|
+
* that DROP schema objects between runs and need the framework to
|
|
1175
|
+
* recreate them; production paths should never set this.
|
|
1176
|
+
*/
|
|
1177
|
+
force?: boolean;
|
|
1178
|
+
/**
|
|
1179
|
+
* Override the `SUBSTRATE_ENFORCE_UUID_CHECK=true` env-var gate for the gated
|
|
1180
|
+
* UUID-format CHECK constraint migration (0002). Defaults to whatever the
|
|
1181
|
+
* env says. Tests that need to exercise the constrained path explicitly
|
|
1182
|
+
* pass `true`; tests that need to opt out of an env-set gate pass `false`.
|
|
1183
|
+
* Production bootstraps shouldn't pass this — let the env decide.
|
|
1184
|
+
*/
|
|
1185
|
+
enforceUuidCheck?: boolean;
|
|
1186
|
+
/**
|
|
1187
|
+
* The layout for a database with no `rows` yet. Ignored once `rows` exists,
|
|
1188
|
+
* since a database keeps its layout. Defaults to `SUBSTRATE_STORAGE_LAYOUT`,
|
|
1189
|
+
* then `partitioned`.
|
|
1190
|
+
*/
|
|
1191
|
+
layout?: StorageLayout;
|
|
1192
|
+
}
|
|
1193
|
+
export declare function runMigrations(sql: Sql, opts?: RunMigrationsOptions): Promise<void>;
|
|
1194
|
+
/**
|
|
1195
|
+
* One `field.list({ indexed: true })` or `field.json({ indexed: true })` field
|
|
1196
|
+
* that should be backed by a GIN over `(body -> field)`.
|
|
1197
|
+
*/
|
|
1198
|
+
interface IndexedListField {
|
|
1199
|
+
readonly namespace: string;
|
|
1200
|
+
readonly type: string;
|
|
1201
|
+
readonly field: string;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Derives the tracked, idempotent CONCURRENTLY GIN migration for one indexed
|
|
1205
|
+
* field. The version key uses the raw ns/type/field.
|
|
1206
|
+
*/
|
|
1207
|
+
export declare function deriveListIndexMigration(f: IndexedListField): MigrationInput;
|
|
1208
|
+
/**
|
|
1209
|
+
* Applies migrations derived from field definitions through the same tracked,
|
|
1210
|
+
* advisory-locked machinery as the static list. Called after plugins load,
|
|
1211
|
+
* since `runMigrations` has no field-def knowledge. Idempotent: applied
|
|
1212
|
+
* versions are skipped.
|
|
1213
|
+
*
|
|
1214
|
+
* On the partitioned layout the list/json GIN migrations are skipped: those
|
|
1215
|
+
* indexes live on each type's partition, built by `reconcileTypeIndexes`, and
|
|
1216
|
+
* Postgres cannot build one CONCURRENTLY on the partitioned parent.
|
|
1217
|
+
*/
|
|
1218
|
+
export declare function runDerivedMigrations(sql: Sql, all: ReadonlyArray<MigrationInput>): Promise<void>;
|
|
1219
|
+
//#endregion
|
|
1220
|
+
//#region ../../packages/substrate-dataset-pg/src/tx-scope.d.ts
|
|
1221
|
+
type PgHandle = Sql | TransactionSql;
|
|
1222
|
+
//#endregion
|
|
1223
|
+
//#region ../../packages/substrate-dataset-pg/src/pg-edges-store.d.ts
|
|
1224
|
+
interface PgEdgesStoreOptions {
|
|
1225
|
+
sql: Sql;
|
|
1226
|
+
/** Injected clock for tests. Defaults to `() => new Date()`. */
|
|
1227
|
+
now?: () => Date;
|
|
1228
|
+
/**
|
|
1229
|
+
* Per-statement batch size for chunked admin deletes. Defaults to
|
|
1230
|
+
* {@link DEFAULT_DROP_BATCH_SIZE}.
|
|
1231
|
+
*/
|
|
1232
|
+
dropBatchSize?: number;
|
|
1233
|
+
}
|
|
1234
|
+
interface InternalPgEdgesStoreOptions {
|
|
1235
|
+
sql: PgHandle;
|
|
1236
|
+
now: () => Date;
|
|
1237
|
+
inTx: boolean;
|
|
1238
|
+
/**
|
|
1239
|
+
* Tx-bound instances inherit their parent's txScopeId. The public
|
|
1240
|
+
* constructor derives it from the Sql reference.
|
|
1241
|
+
*/
|
|
1242
|
+
txScopeId?: string;
|
|
1243
|
+
dropBatchSize?: number;
|
|
1244
|
+
}
|
|
1245
|
+
export declare class PgEdgesStore implements EdgesStore {
|
|
1246
|
+
#private;
|
|
1247
|
+
readonly txScopeId: string;
|
|
1248
|
+
constructor(options: PgEdgesStoreOptions | InternalPgEdgesStoreOptions);
|
|
1249
|
+
write(input: EdgeWriteInput): Promise<Edge>;
|
|
1250
|
+
tombstone(id: string, at?: Date): Promise<void>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Hard-deletes tombstoned edges whose `deleted_at` is older than
|
|
1253
|
+
* `olderThan`. Called by the sweep loop. Returns the number deleted.
|
|
1254
|
+
*/
|
|
1255
|
+
purgeTombstonedEdges(opts: {
|
|
1256
|
+
olderThan: Date;
|
|
1257
|
+
}): Promise<{
|
|
1258
|
+
deleted: number;
|
|
1259
|
+
}>;
|
|
1260
|
+
update(patch: EdgePatch): Promise<void>;
|
|
1261
|
+
readNextBatch(cursorId: string | null, size: number): Promise<{
|
|
1262
|
+
edges: Edge[];
|
|
1263
|
+
lastId: string | null;
|
|
1264
|
+
}>;
|
|
1265
|
+
findEdgesTo(ref: EdgeRef): Promise<Edge[]>;
|
|
1266
|
+
findEdgesToMany(refs: readonly EdgeRef[]): Promise<Edge[]>;
|
|
1267
|
+
findEdgesFrom(ref: EdgeRef): Promise<Edge[]>;
|
|
1268
|
+
findEdgesTouchingNamespace(namespace: string, limit: number): Promise<Edge[]>;
|
|
1269
|
+
findEdgesTouchingType(namespace: string, type: string, limit: number): Promise<Edge[]>;
|
|
1270
|
+
namespacesLinkedTo(namespace: string, type?: string): Promise<string[]>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Chunked physical delete of every edge touching `namespace`, at most
|
|
1273
|
+
* `dropBatchSize` rows per statement, so a large delete does not hold every
|
|
1274
|
+
* row lock at once. Returns the number deleted.
|
|
1275
|
+
*
|
|
1276
|
+
* Outside a tx each batch auto-commits. Inside a caller's tx the batches
|
|
1277
|
+
* stay in it, so a throw still rolls back the whole drop.
|
|
1278
|
+
*/
|
|
1279
|
+
dropEdgesByNamespace(namespace: string, within?: readonly string[]): Promise<number>;
|
|
1280
|
+
/**
|
|
1281
|
+
* Chunked physical delete of every edge touching `(namespace, type)`.
|
|
1282
|
+
* See {@link dropEdgesByNamespace} for the lock-hold + tx semantics.
|
|
1283
|
+
*/
|
|
1284
|
+
dropEdgesByType(namespace: string, type: string, within?: readonly string[]): Promise<number>;
|
|
1285
|
+
canDelete(ref: EdgeRef): Promise<CanDeleteResult>;
|
|
1286
|
+
findBlocked(): Promise<Edge[]>;
|
|
1287
|
+
/**
|
|
1288
|
+
* `sql.begin`-backed atomicity. Same flattening pattern as PgDataset —
|
|
1289
|
+
* nested re-entry skips the inner begin and runs on the existing tx handle
|
|
1290
|
+
* so an inner throw propagates to the outer `sql.begin` for rollback.
|
|
1291
|
+
*/
|
|
1292
|
+
withTransaction<T>(fn: (tx: EdgesStore) => Promise<T>): Promise<T>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Engine-only. Returns a tx-bound clone on the supplied `TransactionSql`,
|
|
1295
|
+
* for `PgDataset.withScopedTransaction`. The caller has verified
|
|
1296
|
+
* the txScopeIds match.
|
|
1297
|
+
*/
|
|
1298
|
+
_enlistInTx(txSql: PgHandle): PgEdgesStore;
|
|
1299
|
+
}
|
|
1300
|
+
//#endregion
|
|
1301
|
+
//#region ../../packages/substrate-dataset-pg/src/pg-dataset.d.ts
|
|
1302
|
+
/**
|
|
1303
|
+
* Returns the declared FieldDef for a type's field, or undefined when unknown
|
|
1304
|
+
* (body-key sorts then fall back to text compare). Lets the SQL builders cast
|
|
1305
|
+
* body values by declared kind, so `count` sorts 2 before 10 — see
|
|
1306
|
+
* `resolveBodyOrderByCast`.
|
|
1307
|
+
*/
|
|
1308
|
+
type FieldDefLookup = (type: string, field: string) => FieldDef | undefined;
|
|
1309
|
+
/**
|
|
1310
|
+
* A type's declared fields and indexes, or undefined when the type is unknown.
|
|
1311
|
+
* Called with the asking dataset's namespace, so a `forNamespace` clone that
|
|
1312
|
+
* inherits the lookup resolves its own types.
|
|
1313
|
+
*/
|
|
1314
|
+
type TypeDefLookup = (type: string, namespace: string) => {
|
|
1315
|
+
fields: Record<string, FieldDef>;
|
|
1316
|
+
indexes?: IndexDecl[];
|
|
1317
|
+
orderedBy?: OrderedBy;
|
|
1318
|
+
ordering?: 'visible';
|
|
1319
|
+
expectedSize?: 'small' | 'large';
|
|
1320
|
+
} | undefined;
|
|
1321
|
+
interface PgDatasetOptions {
|
|
1322
|
+
namespace: string;
|
|
1323
|
+
sql: Sql;
|
|
1324
|
+
/**
|
|
1325
|
+
* Optional sibling `PgEdgesStore` to enlist into this dataset's substrate
|
|
1326
|
+
* transactions. When supplied, MUST share the same `Sql` pool (verified
|
|
1327
|
+
* via `txScopeId === txScopeIdFor(sql)`); the dataset throws on
|
|
1328
|
+
* construction otherwise.
|
|
1329
|
+
*
|
|
1330
|
+
* When supplied, `withScopedTransaction` yields a tx-bound edges store
|
|
1331
|
+
* on the same `TransactionSql` as the tx-bound datasets. When omitted, it
|
|
1332
|
+
* yields `edges: null` and the engine runs edge ops in a separate tx.
|
|
1333
|
+
*/
|
|
1334
|
+
edgesStore?: PgEdgesStore;
|
|
1335
|
+
/**
|
|
1336
|
+
* Optional field-def lookup so orderBy + cursor compares on body fields can
|
|
1337
|
+
* cast to the declared scalar pg type (numeric / timestamptz / boolean)
|
|
1338
|
+
* instead of falling back to lexicographic text compare. When omitted, every
|
|
1339
|
+
* body-key orderBy compares as text.
|
|
1340
|
+
*
|
|
1341
|
+
* A cast sort cannot use an index on the uncast `(body ->> 'field')`
|
|
1342
|
+
* expression; it needs a matching cast expression index.
|
|
1343
|
+
*/
|
|
1344
|
+
fieldDefLookup?: FieldDefLookup;
|
|
1345
|
+
/**
|
|
1346
|
+
* Body keys mirrored into dedicated columns on `rows`, so filters and
|
|
1347
|
+
* sorts on them use an index instead of extracting from JSONB.
|
|
1348
|
+
*
|
|
1349
|
+
* None by default. A namespace declares its own (`NamespaceDefinition`'s
|
|
1350
|
+
* `promotedColumns`), and the plugin that declares them adds the columns in
|
|
1351
|
+
* its kernel migrations: the engine creates none. Three things that bite:
|
|
1352
|
+
*
|
|
1353
|
+
* - Filters and sorts route to the column and ONLY the column, so a column
|
|
1354
|
+
* added over existing rows must be backfilled from the body first, or
|
|
1355
|
+
* those rows miss every filter. Reads return the body.
|
|
1356
|
+
* - `column` is a BARE name (`'severity'`, not `'r.severity'`) and is
|
|
1357
|
+
* validated as an identifier at construction, because it is interpolated
|
|
1358
|
+
* into SQL as an identifier.
|
|
1359
|
+
* - Text columns compare `COLLATE "C"` in every operator, eq included,
|
|
1360
|
+
* so an index meant to serve them must key `(column COLLATE "C")`, as
|
|
1361
|
+
* declared `indexes` do.
|
|
1362
|
+
*/
|
|
1363
|
+
promotedColumns?: PromotedBodyColumnMap;
|
|
1364
|
+
/**
|
|
1365
|
+
* The namespace's type definitions, which `ensureTypeStorage` builds the
|
|
1366
|
+
* type's indexes from. Without it only the engine's own indexes are built.
|
|
1367
|
+
*/
|
|
1368
|
+
typeDefLookup?: TypeDefLookup;
|
|
1369
|
+
/**
|
|
1370
|
+
* Checked before each non-unique index build `ensureTypeStorage` runs; a
|
|
1371
|
+
* refused build stays `pending` (`insufficient_disk`) until a later pass.
|
|
1372
|
+
* Without one nothing is checked. With one that has no path, nothing is
|
|
1373
|
+
* checked either, and `storageReport` says so.
|
|
1374
|
+
*/
|
|
1375
|
+
diskGuard?: DiskGuard;
|
|
1376
|
+
}
|
|
1377
|
+
interface InternalPgSubstrateDatasetOptions {
|
|
1378
|
+
namespace: string;
|
|
1379
|
+
sql: PgHandle;
|
|
1380
|
+
inTx: boolean;
|
|
1381
|
+
/**
|
|
1382
|
+
* Tx-bound instances reuse the root's txScopeId so one substrate never
|
|
1383
|
+
* advertises two ids. The public constructor derives it from the Sql.
|
|
1384
|
+
*/
|
|
1385
|
+
txScopeId?: string;
|
|
1386
|
+
edgesStore?: PgEdgesStore;
|
|
1387
|
+
fieldDefLookup?: FieldDefLookup;
|
|
1388
|
+
/** See `PgDatasetOptions.promotedColumns`. */
|
|
1389
|
+
promotedColumns?: PromotedBodyColumnMap;
|
|
1390
|
+
/** Shared with the instance this one was derived from. */
|
|
1391
|
+
layoutCache?: LayoutCache;
|
|
1392
|
+
typeDefLookup?: TypeDefLookup;
|
|
1393
|
+
diskGuard?: DiskGuard;
|
|
1394
|
+
}
|
|
1395
|
+
/** The detected layout, shared by an instance and every clone of it. */
|
|
1396
|
+
interface LayoutCache {
|
|
1397
|
+
layout?: StorageLayout;
|
|
1398
|
+
}
|
|
1399
|
+
export declare class PgDataset implements Dataset {
|
|
1400
|
+
#private;
|
|
1401
|
+
readonly namespace: string;
|
|
1402
|
+
readonly capabilities: FilterCapabilities;
|
|
1403
|
+
readonly txScopeId: string;
|
|
1404
|
+
constructor(options: PgDatasetOptions | InternalPgSubstrateDatasetOptions);
|
|
1405
|
+
/**
|
|
1406
|
+
* The walk grammar (spec 2026-10-24-typed-edge-walks §3) runs on the
|
|
1407
|
+
* partitioned layout only, and in a transaction under a `SET LOCAL`
|
|
1408
|
+
* statement timeout, since pg has no walk evaluation budget. Other reads
|
|
1409
|
+
* are unchanged.
|
|
1410
|
+
*/
|
|
1411
|
+
read(type: string, params: ReadParams): Promise<ReadResult>;
|
|
1412
|
+
/**
|
|
1413
|
+
* Upsert `rows`. A row without an `id` gets one from the database's
|
|
1414
|
+
* `uuidv7()`, returned in `ids` in input order. Limits of a v7 id: it is
|
|
1415
|
+
* never a happened-before signal; ids sort in creation order only within one
|
|
1416
|
+
* connection (across connections within a millisecond, and for
|
|
1417
|
+
* client-supplied ids, order is arbitrary); it reveals its creation time;
|
|
1418
|
+
* and deciding who won (last-writer-wins, `conditionalUpdate`) uses the
|
|
1419
|
+
* database's transaction time or a per-row version, never the id.
|
|
1420
|
+
*
|
|
1421
|
+
* A supplied id repeated in one batch: under `insertOnly` the first
|
|
1422
|
+
* occurrence lands and the rest are skipped; otherwise the batch is refused.
|
|
1423
|
+
*
|
|
1424
|
+
* On an `ordering: 'visible'` type each inserted row gets the next `seq`,
|
|
1425
|
+
* consecutive in input order, under a per-type transaction lock held until
|
|
1426
|
+
* commit, so seq order is commit order. A row that already exists keeps its
|
|
1427
|
+
* seq, and one `insertOnly` skips gets none.
|
|
1428
|
+
*/
|
|
1429
|
+
write(type: string, rows: WriteRow[], options?: WriteOptions): Promise<WriteResult>;
|
|
1430
|
+
tombstone(type: string, ids: Id[]): Promise<DeleteResult>;
|
|
1431
|
+
purge(type: string, ids: Id[]): Promise<DeleteResult>;
|
|
1432
|
+
/**
|
|
1433
|
+
* Hard-deletes tombstoned rows whose `deleted_at` is older than `olderThan`,
|
|
1434
|
+
* across ALL namespaces (the table is substrate-shared). Called by the sweep
|
|
1435
|
+
* loop. Returns the number of rows deleted.
|
|
1436
|
+
*
|
|
1437
|
+
* Short-id mappings are left in place, as in `purge()`: a row id can
|
|
1438
|
+
* reappear after a tombstone + rewrite.
|
|
1439
|
+
*/
|
|
1440
|
+
purgeTombstonedRows(opts: {
|
|
1441
|
+
olderThan: Date;
|
|
1442
|
+
}): Promise<{
|
|
1443
|
+
deleted: number;
|
|
1444
|
+
}>;
|
|
1445
|
+
/**
|
|
1446
|
+
* Hard-delete every row for `type` in this namespace, including tombstoned
|
|
1447
|
+
* rows (`deleted_at IS NOT NULL`). Short-id mappings for that type are
|
|
1448
|
+
* removed in the same logical operation. Both deletes run through `this.#sql`
|
|
1449
|
+
* so they participate in any surrounding `withTransaction` boundary.
|
|
1450
|
+
*/
|
|
1451
|
+
dropType(type: string): Promise<DropResult>;
|
|
1452
|
+
/**
|
|
1453
|
+
* Hard-delete every row across all types in this namespace, including
|
|
1454
|
+
* tombstoned rows. Short-id mappings for all types are removed too.
|
|
1455
|
+
*/
|
|
1456
|
+
dropNamespace(): Promise<DropResult>;
|
|
1457
|
+
/**
|
|
1458
|
+
* Compare-and-update (spec §5.12): merges `updates` into the live row only
|
|
1459
|
+
* if every `match` field equals its expected value. Returns `matched` and
|
|
1460
|
+
* the updated row.
|
|
1461
|
+
*
|
|
1462
|
+
* One `UPDATE ... WHERE <pk> AND <match>`, so the row lock makes exactly one
|
|
1463
|
+
* of N concurrent callers match. `_deletedAt` and `id` are dropped from
|
|
1464
|
+
* `updates`.
|
|
1465
|
+
*/
|
|
1466
|
+
conditionalUpdate(type: string, id: Id, match: Record<string, unknown>, updates: Record<string, unknown>, actor?: ActorIdentity, now?: Date): Promise<ConditionalUpdateResult>;
|
|
1467
|
+
updateField(ref: UpdateFieldRef, fieldName: string, value: unknown): Promise<void>;
|
|
1468
|
+
/**
|
|
1469
|
+
* `sql.begin`-backed atomicity. Spec §5.3 / G1.
|
|
1470
|
+
*
|
|
1471
|
+
* Nested calls flatten: postgres.js's `begin` inside a `begin` would create
|
|
1472
|
+
* a savepoint (inner rolls back independently of outer), which is stricter
|
|
1473
|
+
* than the G1 contract promises. To match the memory impl — where an inner
|
|
1474
|
+
* throw tears down outer writes too — we detect the re-entry via `#inTx`
|
|
1475
|
+
* and skip the nested begin entirely. The inner throw then propagates to
|
|
1476
|
+
* the outer `sql.begin`, which rolls back the whole thing.
|
|
1477
|
+
*/
|
|
1478
|
+
withTransaction<T>(fn: (tx: Dataset) => Promise<T>): Promise<T>;
|
|
1479
|
+
/**
|
|
1480
|
+
* Runs `fn` in one pg transaction with a tx-bound dataset per requested
|
|
1481
|
+
* namespace (and the edges store, when wired), all on one `TransactionSql`.
|
|
1482
|
+
* A throw rolls back every namespace. Spec §5.3.
|
|
1483
|
+
*
|
|
1484
|
+
* Nested calls flatten onto the current transaction rather than opening a
|
|
1485
|
+
* savepoint.
|
|
1486
|
+
*/
|
|
1487
|
+
withScopedTransaction<T>(namespaces: ReadonlyArray<string>, fn: (handles: TxScopeHandles) => Promise<T>): Promise<T>;
|
|
1488
|
+
/**
|
|
1489
|
+
* See `Dataset.withAdvisoryLock`. Excludes every session on the
|
|
1490
|
+
* same schema, across processes. On a tx-bound instance the lock is
|
|
1491
|
+
* `pg_advisory_xact_lock` on the transaction's own connection, held until
|
|
1492
|
+
* it commits or rolls back: a session lock would need a second connection
|
|
1493
|
+
* beside the open transaction.
|
|
1494
|
+
*/
|
|
1495
|
+
withAdvisoryLock<T>(key: string, fn: () => Promise<T>): Promise<T>;
|
|
1496
|
+
allocateShortId(type: string): Promise<number>;
|
|
1497
|
+
bindShortId(type: string, shortId: number, rowId: string): Promise<void>;
|
|
1498
|
+
resolveShortId(type: string, shortId: number): Promise<string | null>;
|
|
1499
|
+
getShortIdForRow(type: string, rowId: string): Promise<number | null>;
|
|
1500
|
+
forNamespace(namespace: string): Dataset;
|
|
1501
|
+
/**
|
|
1502
|
+
* See `Dataset.ensureTypeStorage`. On the partitioned layout, creates this
|
|
1503
|
+
* namespace's partition and the type's, then reconciles the type's indexes
|
|
1504
|
+
* on it; on legacy, reconciles only its declared `indexes`. Index builds
|
|
1505
|
+
* run CONCURRENTLY, outside any transaction, so a tx-bound instance refuses.
|
|
1506
|
+
* Logs each index it created, adopted or swapped, and records each one
|
|
1507
|
+
* left pending, building or failed for `describeStorage` and `storageReport`.
|
|
1508
|
+
*/
|
|
1509
|
+
ensureTypeStorage(type: string, opts?: {
|
|
1510
|
+
indexes?: 'all' | 'unique' | 'nonUnique';
|
|
1511
|
+
signal?: AbortSignal;
|
|
1512
|
+
}): Promise<void>;
|
|
1513
|
+
/**
|
|
1514
|
+
* The type's non-unique indexes the next build pass would build or swap,
|
|
1515
|
+
* each with the disk guard's estimate. Empty when the store or the type's
|
|
1516
|
+
* storage does not exist yet. Changes nothing.
|
|
1517
|
+
*/
|
|
1518
|
+
pendingIndexBuilds(type: string): Promise<Array<{
|
|
1519
|
+
name: string;
|
|
1520
|
+
estimateBytes: number;
|
|
1521
|
+
}>>;
|
|
1522
|
+
/** See `Dataset.describeStorage`. Reads the catalog only, in a fixed number of queries. */
|
|
1523
|
+
describeStorage(type: string): Promise<TypeStorageReport>;
|
|
1524
|
+
/**
|
|
1525
|
+
* See `Dataset.storageReport`. Spans every namespace of the database. Reads
|
|
1526
|
+
* the partition tree and every index on it in one query each, so its cost
|
|
1527
|
+
* does not grow with the number of partitions.
|
|
1528
|
+
*/
|
|
1529
|
+
storageReport(opts: {
|
|
1530
|
+
partitionBudget: number;
|
|
1531
|
+
}): Promise<StorageReport>;
|
|
1532
|
+
/** See `Dataset.indexPlan`. */
|
|
1533
|
+
indexPlan(type: string, namespace: string): Promise<IndexPlan | undefined>;
|
|
1534
|
+
/**
|
|
1535
|
+
* See `Dataset.dropEngineIndex`. Checks and drops under the table's index
|
|
1536
|
+
* build lock, so a reconcile cannot rebuild or swap the index in between.
|
|
1537
|
+
* Ownership is the reconciler's marker and generated name on an index of
|
|
1538
|
+
* this type (`typeIndexesOf`); the wanted set is the reconciler's own
|
|
1539
|
+
* (`desiredIndexKeys`), so only a leftover or a retracted declaration goes.
|
|
1540
|
+
* Refuses with `IndexDropRefusedError`.
|
|
1541
|
+
*
|
|
1542
|
+
* The drop waits for every transaction holding a lock on the table, and pg
|
|
1543
|
+
* cannot see a cycle through a caller that waits on this call, so each wait
|
|
1544
|
+
* is bounded by `lockTimeoutMs` (default `DROP_LOCK_TIMEOUT_MS`).
|
|
1545
|
+
*/
|
|
1546
|
+
dropEngineIndex(type: string, name: string, opts?: {
|
|
1547
|
+
beforeDrop?: () => Promise<void>;
|
|
1548
|
+
lockTimeoutMs?: number;
|
|
1549
|
+
}): Promise<void>;
|
|
1550
|
+
/**
|
|
1551
|
+
* See `Dataset.dropNamespaceIndexes`. On legacy, the engine-owned partial
|
|
1552
|
+
* indexes on `rows` scoped to this namespace; on partitioned, the
|
|
1553
|
+
* engine-owned indexes on its type partitions, which a namespace drop
|
|
1554
|
+
* empties but keeps. Unique ones only when `opts.unique`. Each table's under
|
|
1555
|
+
* its index-build lock, CONCURRENTLY; the wait for that lock and each lock
|
|
1556
|
+
* wait of a drop are bounded by `lockTimeoutMs` (default
|
|
1557
|
+
* `DROP_LOCK_TIMEOUT_MS`), past which it throws `index_drop_timeout`.
|
|
1558
|
+
*/
|
|
1559
|
+
dropNamespaceIndexes(opts?: {
|
|
1560
|
+
unique?: boolean;
|
|
1561
|
+
lockTimeoutMs?: number;
|
|
1562
|
+
}): Promise<string[]>;
|
|
1563
|
+
/** See `Dataset.indexDeclarationOf`. */
|
|
1564
|
+
indexDeclarationOf(type: string, name: string): Promise<IndexDecl | undefined>;
|
|
1565
|
+
/**
|
|
1566
|
+
* See `Dataset.typeStats`. Spans every namespace of the database, in a fixed
|
|
1567
|
+
* number of queries. Partitioned: each type partition's own statistics;
|
|
1568
|
+
* `liveRows` is `reltuples` (or `n_live_tup` before the first ANALYZE) and
|
|
1569
|
+
* counts tombstoned rows too. Legacy: see the shortcut below.
|
|
1570
|
+
*/
|
|
1571
|
+
typeStats(): Promise<TypeStats[]>;
|
|
1572
|
+
private materialize;
|
|
1573
|
+
private extractOriginalId;
|
|
1574
|
+
}
|
|
1575
|
+
//#endregion
|
|
1020
1576
|
//#region ../../packages/substrate-dataset-pg/src/testing.d.ts
|
|
1021
1577
|
/**
|
|
1022
1578
|
* Safety rails for pg integration tests. Shared by every package whose suites
|
|
@@ -1139,6 +1695,23 @@ export declare function publicLeftoverWarning(names: readonly string[], packageN
|
|
|
1139
1695
|
* Call from `globalSetup`, so forked workers inherit the rewritten URL.
|
|
1140
1696
|
*/
|
|
1141
1697
|
export declare function preparePgTestSchema(url: string | undefined, opts: SchemaIsolationOptions): Promise<string | undefined>;
|
|
1698
|
+
/**
|
|
1699
|
+
* The storage layout this run's pg suites build, from `SUBSTRATE_TEST_LAYOUT`
|
|
1700
|
+
* (default `legacy`). Copies it into `SUBSTRATE_STORAGE_LAYOUT`, which
|
|
1701
|
+
* `runMigrations` reads on a fresh database, and returns the package name to
|
|
1702
|
+
* isolate under, so each layout gets a schema of its own.
|
|
1703
|
+
*
|
|
1704
|
+
* Call from `globalSetup`, before `preparePgTestSchema`.
|
|
1705
|
+
*/
|
|
1706
|
+
export declare function selectPgTestLayout(packageName: string): {
|
|
1707
|
+
layout: 'legacy' | 'partitioned';
|
|
1708
|
+
packageName: string;
|
|
1709
|
+
};
|
|
1710
|
+
/**
|
|
1711
|
+
* A `createSchema` for `preparePgTestSchema` that drops and recreates the
|
|
1712
|
+
* schema, so every run builds its layout from an empty database.
|
|
1713
|
+
*/
|
|
1714
|
+
export declare function recreatePgTestSchema(url: string, schema: string): Promise<void>;
|
|
1142
1715
|
//#endregion
|
|
1143
1716
|
//#region ../../packages/substrate-embedder/src/fake.d.ts
|
|
1144
1717
|
interface FakeEmbedderOptions {
|
|
@@ -1237,4 +1810,4 @@ export declare class MemorySubstrateServer implements SubstrateServer {
|
|
|
1237
1810
|
*/
|
|
1238
1811
|
export declare function matchRoute(registered: string, actual: string): Record<string, string> | null;
|
|
1239
1812
|
//#endregion
|
|
1240
|
-
export type { AuthConfig, ComposeResult, MemoryWsClient };
|
|
1813
|
+
export type { AuthConfig, ComposeResult, FieldDefLookup, IndexedListField, MemoryWsClient, PgDatasetOptions, PgEdgesStoreOptions };
|