@mnmal-ai/substrate 0.0.0-stage → 1.0.0-alpha.0
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/LICENSE +202 -0
- package/README.md +119 -2
- package/dist/agent-token-BIboWOU0.js +200 -0
- package/dist/client.d.ts +782 -0
- package/dist/client.js +7 -0
- package/dist/cluster-worker.js +35 -0
- package/dist/content-type-C7T28xNb.js +25 -0
- package/dist/dataset-BXkus75W.js +1527 -0
- package/dist/env-utils-B7SGmoeJ.js +21 -0
- package/dist/errors-D4vKuwz8.d.ts +130 -0
- package/dist/fake-DUVtKVSE.js +36 -0
- package/dist/index-D7mSOFlM.d.ts +69 -0
- package/dist/pack.d.ts +192 -0
- package/dist/pack.js +5 -0
- package/dist/plugin-j1jt1l3n.js +3844 -0
- package/dist/plugin-t2g2wX0b.d.ts +1568 -0
- package/dist/proposals-bootstrap.js +37 -0
- package/dist/proposals.config.schema.json +20 -0
- package/dist/proposals.d.ts +118 -0
- package/dist/proposals.default-config.json +4 -0
- package/dist/proposals.js +4 -0
- package/dist/recall-bootstrap.js +451 -0
- package/dist/recall.config.schema.json +232 -0
- package/dist/recall.d.ts +1981 -0
- package/dist/recall.default-config.json +4 -0
- package/dist/recall.js +5 -0
- package/dist/repl-C52wyfMs.js +2213 -0
- package/dist/row-ByLFE2Wx.d.ts +719 -0
- package/dist/row-DK7lPZVe.js +732 -0
- package/dist/runtime-metrics-DwpDJ8vz.d.ts +159 -0
- package/dist/schema-g4FQLr0V.d.ts +433 -0
- package/dist/sdk.d.ts +694 -0
- package/dist/sdk.js +112 -0
- package/dist/src-C4DzaIQZ.js +837 -0
- package/dist/src-CrEgiMJQ.js +1015 -0
- package/dist/src-CzxvmhFn.js +2327 -0
- package/dist/src-D88LvCX8.js +1797 -0
- package/dist/src-D91yij6C.js +13523 -0
- package/dist/src-DuopV8u7.js +2408 -0
- package/dist/substrate-admin.js +808 -0
- package/dist/substrate.js +5477 -0
- package/dist/testing.d.ts +1240 -0
- package/dist/testing.js +702 -0
- package/dist/types-8c0gtnd2.d.ts +35 -0
- package/dist/ws-C72iVS5T.d.ts +143 -0
- package/package.json +117 -3
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import { E as Row, l as PackEnvelope, u as Schema } from "./schema-g4FQLr0V.js";
|
|
2
|
+
import { a as RuntimeErrors, i as RuntimeErrorEntry, o as RuntimeMetrics, r as ResolverStat, s as SlowRequest, t as ProcessStat } from "./runtime-metrics-DwpDJ8vz.js";
|
|
3
|
+
import { C as QualifiedFrame } from "./plugin-t2g2wX0b.js";
|
|
4
|
+
import { A as and, B as SYSTEM_NAMESPACE, C as flattenGrant, D as parseGrantEntries, E as intersectGrants, F as TokenProviderOpts, G as resolveAdminCredential, H as isActiveAdminKeyRow, I as adminClaimCapabilities, J as NlAskRequest, K as resolveDefaultKeyPath, L as isEncryptedKey, M as or, N as ADMIN_CAPABILITIES, O as decodeList, P as DEFAULT_CAPABILITIES, R as makeAuthorizationProvider, S as expandFlat, T as grantIsUniform, U as AdminCredential, V as describeGrant, W as AdminEnv, Y as NlAskResult, _ as newlyGrantedPairs, a as denyAll, b as capabilitiesFor, c as requireIdentity, d as KeyUpdateRefusal, f as checkRevocable, ft as NlWireEvent, g as newlyGranted, h as grantEntriesConfer, i as allowVerbs, j as not, k as encodeList, l as requireNamespace, lt as NlServedPack, m as grantCovers, n as row, o as denyVerbs, p as checkUpdatable, q as resolveDefaultKidPath, r as allowAll, rt as NlOutcome, s as requireCapability, t as applyRowFilters, u as KeyMutationRefusal, ut as NlTrailEvent, v as revokedAtIso, w as grantEntryError, x as encodeGrant, y as Grant, z as makeTokenProvider } from "./row-ByLFE2Wx.js";
|
|
5
|
+
import { s as SchemaDriftError } from "./index-D7mSOFlM.js";
|
|
6
|
+
import { Signal } from "@preact/signals-core";
|
|
7
|
+
//#region ../../packages/substrate-client/src/admin/surgery.d.ts
|
|
8
|
+
type AdminDropCascade = 'refuse' | 'delete';
|
|
9
|
+
interface AdminDropNamespaceInput {
|
|
10
|
+
readonly namespace: string;
|
|
11
|
+
/** What the server checks against the namespace. The TUI sends the operator's typed target on apply. */
|
|
12
|
+
readonly confirm: string;
|
|
13
|
+
readonly cascade?: AdminDropCascade;
|
|
14
|
+
readonly dryRun?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface AdminDropTypeInput {
|
|
17
|
+
readonly namespace: string;
|
|
18
|
+
readonly type: string;
|
|
19
|
+
/** Must equal `<namespace>/<type>` server-side. */
|
|
20
|
+
readonly confirm: string;
|
|
21
|
+
readonly cascade?: AdminDropCascade;
|
|
22
|
+
readonly dryRun?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface AdminDropResult {
|
|
25
|
+
readonly namespace: string;
|
|
26
|
+
/** Present for drop-type. */
|
|
27
|
+
readonly type?: string;
|
|
28
|
+
readonly dryRun: boolean;
|
|
29
|
+
readonly cascade: AdminDropCascade;
|
|
30
|
+
readonly rowsDeleted: number;
|
|
31
|
+
readonly edgesDeleted: number;
|
|
32
|
+
readonly shortIdsDeleted: number;
|
|
33
|
+
/** Always minted, dry run included. On a dry run it names an audit row that was rolled back: never present it as a reference. */
|
|
34
|
+
readonly auditEventId: string;
|
|
35
|
+
}
|
|
36
|
+
interface AdminNormaliseInput {
|
|
37
|
+
readonly namespace: string;
|
|
38
|
+
readonly type: string;
|
|
39
|
+
readonly field: string;
|
|
40
|
+
readonly reject?: readonly string[];
|
|
41
|
+
/** Omitted or false: a dry run. */
|
|
42
|
+
readonly apply?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface AdminNormaliseResult {
|
|
45
|
+
readonly namespace: string;
|
|
46
|
+
readonly type: string;
|
|
47
|
+
readonly field: string;
|
|
48
|
+
readonly strict: boolean;
|
|
49
|
+
readonly scanned: number;
|
|
50
|
+
/** The scan stopped at its row cap: every count below is partial. */
|
|
51
|
+
readonly truncated: boolean;
|
|
52
|
+
readonly plan: readonly {
|
|
53
|
+
readonly from: string;
|
|
54
|
+
readonly to: string;
|
|
55
|
+
readonly count: number;
|
|
56
|
+
}[];
|
|
57
|
+
/** Stored values no alias explains. */
|
|
58
|
+
readonly unmapped: readonly {
|
|
59
|
+
readonly value: string;
|
|
60
|
+
readonly count: number;
|
|
61
|
+
}[];
|
|
62
|
+
readonly applied: boolean;
|
|
63
|
+
/** Present when applied: one entry per alias actually migrated. */
|
|
64
|
+
readonly migrated?: readonly {
|
|
65
|
+
readonly from: string;
|
|
66
|
+
readonly to: string;
|
|
67
|
+
readonly count: number;
|
|
68
|
+
}[];
|
|
69
|
+
/** Present when applied: stored values left stranded (rejected). */
|
|
70
|
+
readonly stranded?: readonly {
|
|
71
|
+
readonly value: string;
|
|
72
|
+
readonly count: number;
|
|
73
|
+
}[];
|
|
74
|
+
}
|
|
75
|
+
/** Mirrors BACKFILL_MAX_ROWS in substrate-compose; the server enforces it. */
|
|
76
|
+
export declare const BACKFILL_CHUNK = 5000;
|
|
77
|
+
interface AdminBackfillInput {
|
|
78
|
+
readonly namespace: string;
|
|
79
|
+
readonly type: string;
|
|
80
|
+
readonly field: string;
|
|
81
|
+
/** Row id → value. */
|
|
82
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
83
|
+
/** Omitted or false: a dry run. */
|
|
84
|
+
readonly apply?: boolean;
|
|
85
|
+
/** Omitted or false: only empty values are filled. */
|
|
86
|
+
readonly overwrite?: boolean;
|
|
87
|
+
}
|
|
88
|
+
interface AdminBackfillSummary {
|
|
89
|
+
readonly requested: number;
|
|
90
|
+
readonly write: number;
|
|
91
|
+
readonly kept: number;
|
|
92
|
+
readonly unchanged: number;
|
|
93
|
+
readonly missing: readonly string[];
|
|
94
|
+
readonly counts: Readonly<Record<string, number>>;
|
|
95
|
+
readonly applied: boolean;
|
|
96
|
+
/** How many requests the values took. More than one means an apply is not atomic. */
|
|
97
|
+
readonly chunks: number;
|
|
98
|
+
}
|
|
99
|
+
interface AdminBackfillChunk {
|
|
100
|
+
readonly index: number;
|
|
101
|
+
readonly chunks: number;
|
|
102
|
+
/** The route's own response for this chunk, verbatim. */
|
|
103
|
+
readonly body: Readonly<Record<string, unknown>>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A chunk was refused. `chunksDone` chunks were already sent (and, on apply, WRITTEN); `partial` sums them.
|
|
107
|
+
*
|
|
108
|
+
* `cause` is the real failure and may be an `AuthError` (a rejected admin key) or a
|
|
109
|
+
* `NetworkError` (including one wrapping an `AbortError`). Callers must unwrap `cause`
|
|
110
|
+
* before applying an auth-lock rule or abort handling.
|
|
111
|
+
*
|
|
112
|
+
* `partial.applied` true means at least one chunk was accepted and written; `chunksDone` says how
|
|
113
|
+
* many. `false` does NOT prove nothing was written: a first chunk refused with anything but a 4xx
|
|
114
|
+
* may have partly written (below). A refusal with a 4xx status guarantees the failing chunk wrote nothing;
|
|
115
|
+
* anything else (a 5xx such as `verify_failed`, a dropped connection, an abort) may have
|
|
116
|
+
* partly written the failing chunk, since the route writes in non-transactional 200-row batches.
|
|
117
|
+
*/
|
|
118
|
+
export declare class AdminBackfillError extends Error {
|
|
119
|
+
readonly cause: unknown;
|
|
120
|
+
readonly chunksDone: number;
|
|
121
|
+
readonly chunks: number;
|
|
122
|
+
readonly partial: AdminBackfillSummary;
|
|
123
|
+
readonly name = "AdminBackfillError";
|
|
124
|
+
constructor(cause: unknown, chunksDone: number, chunks: number, partial: AdminBackfillSummary);
|
|
125
|
+
}
|
|
126
|
+
interface AdminReindexInput {
|
|
127
|
+
readonly namespace: string;
|
|
128
|
+
readonly type: string;
|
|
129
|
+
readonly cursor?: string;
|
|
130
|
+
/** Server default 100, max 1000. */
|
|
131
|
+
readonly limit?: number;
|
|
132
|
+
}
|
|
133
|
+
interface AdminReindexPage {
|
|
134
|
+
readonly namespace: string;
|
|
135
|
+
readonly type: string;
|
|
136
|
+
readonly scanned: number;
|
|
137
|
+
readonly embedded: number;
|
|
138
|
+
readonly unindexable: number;
|
|
139
|
+
readonly failed: number;
|
|
140
|
+
readonly failures: readonly {
|
|
141
|
+
readonly id: string;
|
|
142
|
+
readonly error: string;
|
|
143
|
+
}[];
|
|
144
|
+
readonly hasMore: boolean;
|
|
145
|
+
readonly nextCursor?: string;
|
|
146
|
+
}
|
|
147
|
+
interface AdminEmbedStats {
|
|
148
|
+
readonly enabled: boolean;
|
|
149
|
+
/** Absent and `[]` are different answers: absent means the server did not say. Never collapse with `?? []`. */
|
|
150
|
+
readonly embeddedTypes?: readonly {
|
|
151
|
+
readonly namespace: string;
|
|
152
|
+
readonly type: string;
|
|
153
|
+
}[];
|
|
154
|
+
readonly writes?: number;
|
|
155
|
+
readonly failures?: number;
|
|
156
|
+
}
|
|
157
|
+
interface SurgeryApi {
|
|
158
|
+
/** ONE page; the caller owns the loop so it can show progress and stop between pages. */
|
|
159
|
+
reindexPage(input: AdminReindexInput, opts?: {
|
|
160
|
+
signal?: AbortSignal;
|
|
161
|
+
}): Promise<AdminReindexPage>;
|
|
162
|
+
embedStats(opts?: {
|
|
163
|
+
signal?: AbortSignal;
|
|
164
|
+
}): Promise<AdminEmbedStats>;
|
|
165
|
+
/** `onChunk` must not throw: a throw escapes without `chunksDone`/`partial`. */
|
|
166
|
+
backfill(input: AdminBackfillInput, opts?: {
|
|
167
|
+
signal?: AbortSignal;
|
|
168
|
+
onChunk?: (chunk: AdminBackfillChunk) => void;
|
|
169
|
+
}): Promise<AdminBackfillSummary>;
|
|
170
|
+
dropNamespace(input: AdminDropNamespaceInput, opts?: {
|
|
171
|
+
signal?: AbortSignal;
|
|
172
|
+
}): Promise<AdminDropResult>;
|
|
173
|
+
dropType(input: AdminDropTypeInput, opts?: {
|
|
174
|
+
signal?: AbortSignal;
|
|
175
|
+
}): Promise<AdminDropResult>;
|
|
176
|
+
normalise(input: AdminNormaliseInput, opts?: {
|
|
177
|
+
signal?: AbortSignal;
|
|
178
|
+
}): Promise<AdminNormaliseResult>;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region ../../packages/substrate-client/src/admin/api.d.ts
|
|
182
|
+
interface AdminKeyRow {
|
|
183
|
+
readonly id: string;
|
|
184
|
+
readonly kid: string;
|
|
185
|
+
readonly name: string;
|
|
186
|
+
readonly algorithm: string;
|
|
187
|
+
/** Stored csv, as the route returns it; render with substrate-policy `describeGrant`. */
|
|
188
|
+
readonly namespaces: string;
|
|
189
|
+
readonly capabilities: string;
|
|
190
|
+
readonly createdAt: string;
|
|
191
|
+
}
|
|
192
|
+
interface AdminGrantChange {
|
|
193
|
+
readonly kid: string;
|
|
194
|
+
/** Grant entries, e.g. `['notes:read+mutate', 'tasks']`, as substrate-policy `encodeGrant` writes them. */
|
|
195
|
+
readonly namespaces: readonly string[];
|
|
196
|
+
/** The default capabilities a bare entry gets. */
|
|
197
|
+
readonly capabilities: readonly string[];
|
|
198
|
+
readonly widen?: boolean;
|
|
199
|
+
readonly allowAdmin?: boolean;
|
|
200
|
+
readonly allowUnknownNs?: boolean;
|
|
201
|
+
}
|
|
202
|
+
interface AdminUpdateResult {
|
|
203
|
+
readonly kid: string;
|
|
204
|
+
readonly revoked: false;
|
|
205
|
+
readonly namespaces: string[];
|
|
206
|
+
readonly capabilities: string[];
|
|
207
|
+
}
|
|
208
|
+
interface AdminRevokeResult {
|
|
209
|
+
readonly kid: string;
|
|
210
|
+
readonly revoked: true;
|
|
211
|
+
readonly revokedAt: string;
|
|
212
|
+
}
|
|
213
|
+
type AdminKeyAlgorithm = 'EdDSA' | 'RS256' | 'ES256';
|
|
214
|
+
interface AdminRegisterInput {
|
|
215
|
+
readonly kid: string;
|
|
216
|
+
/** PEM text of the PUBLIC key. */
|
|
217
|
+
readonly publicKey: string;
|
|
218
|
+
readonly algorithm: AdminKeyAlgorithm;
|
|
219
|
+
/** Omitted: the server uses the kid. */
|
|
220
|
+
readonly name?: string;
|
|
221
|
+
readonly namespaces: readonly string[];
|
|
222
|
+
readonly capabilities: readonly string[];
|
|
223
|
+
/** Omitted: the server writes the directory row when it has a directory configured. */
|
|
224
|
+
readonly directory?: boolean;
|
|
225
|
+
readonly allowAdmin?: boolean;
|
|
226
|
+
readonly allowUnknownNs?: boolean;
|
|
227
|
+
}
|
|
228
|
+
interface AdminRegisterResult {
|
|
229
|
+
readonly kid: string;
|
|
230
|
+
readonly name: string;
|
|
231
|
+
readonly fingerprint: string;
|
|
232
|
+
readonly algorithm: AdminKeyAlgorithm;
|
|
233
|
+
readonly namespaces: string[];
|
|
234
|
+
readonly capabilities: string[];
|
|
235
|
+
readonly replacedRevoked: boolean;
|
|
236
|
+
/** The identity-directory row beside the credential, as the register route reports it. */
|
|
237
|
+
readonly directory?: AdminRegisterDirectory;
|
|
238
|
+
}
|
|
239
|
+
/** `created: true` names the directory frame written; `false` says why none was
|
|
240
|
+
* (`not_configured`, `opted_out`). */
|
|
241
|
+
type AdminRegisterDirectory = {
|
|
242
|
+
readonly created: true;
|
|
243
|
+
readonly frame: string;
|
|
244
|
+
} | {
|
|
245
|
+
readonly created: false;
|
|
246
|
+
readonly reason: 'not_configured' | 'opted_out';
|
|
247
|
+
};
|
|
248
|
+
interface AdminInviteInput {
|
|
249
|
+
readonly namespaces: readonly string[];
|
|
250
|
+
readonly capabilities: readonly string[];
|
|
251
|
+
/** Omitted: the server's default TTL. */
|
|
252
|
+
readonly ttlMs?: number;
|
|
253
|
+
}
|
|
254
|
+
interface AdminInviteResult {
|
|
255
|
+
/** The one-time code. A secret until redeemed: never log or print it. */
|
|
256
|
+
readonly code: string;
|
|
257
|
+
readonly expiresAt: string;
|
|
258
|
+
readonly namespaces: string[];
|
|
259
|
+
readonly capabilities: string[];
|
|
260
|
+
}
|
|
261
|
+
interface AdminApi extends SurgeryApi {
|
|
262
|
+
/** GET /substrate/v1/_system/keys, paged to completion: a truncated key table is never silent. */
|
|
263
|
+
keys(opts?: {
|
|
264
|
+
signal?: AbortSignal;
|
|
265
|
+
}): Promise<AdminKeyRow[]>;
|
|
266
|
+
/** PATCH of a key's grant. REPLACES both lists (namespaces and capabilities) with `change`'s; nothing is merged with what the key held. */
|
|
267
|
+
update(change: AdminGrantChange, opts?: {
|
|
268
|
+
signal?: AbortSignal;
|
|
269
|
+
}): Promise<AdminUpdateResult>;
|
|
270
|
+
revoke(kid: string, opts?: {
|
|
271
|
+
signal?: AbortSignal;
|
|
272
|
+
}): Promise<AdminRevokeResult>;
|
|
273
|
+
register(input: AdminRegisterInput, opts?: {
|
|
274
|
+
signal?: AbortSignal;
|
|
275
|
+
}): Promise<AdminRegisterResult>;
|
|
276
|
+
invite(input: AdminInviteInput, opts?: {
|
|
277
|
+
signal?: AbortSignal;
|
|
278
|
+
}): Promise<AdminInviteResult>;
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region ../../packages/substrate-client/src/admin/diagnose.d.ts
|
|
282
|
+
/**
|
|
283
|
+
* `ok` — asked and answered yes. `no` — asked and answered no. `skip` — NOT
|
|
284
|
+
* ASKED, because a precondition failed.
|
|
285
|
+
*/
|
|
286
|
+
type DoctorStatus = 'ok' | 'no' | 'skip';
|
|
287
|
+
interface DoctorCheck {
|
|
288
|
+
/** Stable short label, safe to grep for in a support thread. */
|
|
289
|
+
readonly name: string;
|
|
290
|
+
readonly status: DoctorStatus;
|
|
291
|
+
/** What was measured, in the terms the operator typed. */
|
|
292
|
+
readonly detail: string;
|
|
293
|
+
/** Present on `no` — the next command, not a restatement of the failure. */
|
|
294
|
+
readonly fix?: string;
|
|
295
|
+
/** The HTTP status that decided this verdict, when a response decided it. Match on this,
|
|
296
|
+
* never on `detail`, which is prose for an operator and free to change. */
|
|
297
|
+
readonly httpStatus?: number;
|
|
298
|
+
}
|
|
299
|
+
interface DoctorReport {
|
|
300
|
+
readonly checks: readonly DoctorCheck[];
|
|
301
|
+
/** 0 when nothing answered `no`. Skips do not fail the run; they are visible. */
|
|
302
|
+
readonly exitCode: number;
|
|
303
|
+
}
|
|
304
|
+
interface DirectoryReconciliation {
|
|
305
|
+
/** Inactive directory row, live signing credential — the dangerous direction. */
|
|
306
|
+
readonly retiredWithLiveKey: readonly string[];
|
|
307
|
+
/** Live credential, no directory row, not admin-exempt. */
|
|
308
|
+
readonly liveKeyWithoutRow: readonly string[];
|
|
309
|
+
/** Active directory row with a live credential that is not admin-capable. */
|
|
310
|
+
readonly agentKids: readonly string[];
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Reconciles live Key rows against AgentIdentity rows, returning retired
|
|
314
|
+
* identities that still hold a live key and live keys with no directory row.
|
|
315
|
+
*
|
|
316
|
+
* Admin keys are exempt from the second list by CAPABILITY, never by kid: the
|
|
317
|
+
* bootstrap root of trust has no directory row by design.
|
|
318
|
+
*
|
|
319
|
+
* A row whose `active` is absent counts as ACTIVE — only an explicit `false`
|
|
320
|
+
* deactivates. Rows predating the field must not read as decommissioned.
|
|
321
|
+
* A key row with no string kid is unmatchable and ignored (doctor is not a
|
|
322
|
+
* corruption scanner).
|
|
323
|
+
*/
|
|
324
|
+
export declare function reconcileIdentities(keys: readonly Row[], identities: readonly Row[], adminCapability: string): DirectoryReconciliation;
|
|
325
|
+
/**
|
|
326
|
+
* What diagnose measured, as data. A field is ABSENT when the check that measures it did not
|
|
327
|
+
* run — absent never means empty, so a reader cannot take "not looked" for "none found".
|
|
328
|
+
*/
|
|
329
|
+
interface DiagnoseFacts {
|
|
330
|
+
readonly adminKids?: readonly string[];
|
|
331
|
+
readonly liveKeyCount?: number;
|
|
332
|
+
readonly retiredWithLiveKey?: readonly string[];
|
|
333
|
+
readonly liveKeyWithoutRow?: readonly string[];
|
|
334
|
+
readonly agentKids?: readonly string[];
|
|
335
|
+
}
|
|
336
|
+
/** The identity the server resolved, when the identity check passed; else null. */
|
|
337
|
+
interface DiagnoseResult extends DoctorReport {
|
|
338
|
+
readonly identity: string | null;
|
|
339
|
+
readonly facts: DiagnoseFacts;
|
|
340
|
+
}
|
|
341
|
+
type DiagnoseCredential = {
|
|
342
|
+
readonly authorization: () => string;
|
|
343
|
+
readonly label: string;
|
|
344
|
+
} |
|
|
345
|
+
/** `fix` replaces the default advice, which names the admin env: a caller diagnosing some
|
|
346
|
+
* other identity knows what that identity needs. */
|
|
347
|
+
{
|
|
348
|
+
readonly error: string;
|
|
349
|
+
readonly fix?: string;
|
|
350
|
+
};
|
|
351
|
+
interface DiagnoseOpts {
|
|
352
|
+
readonly baseUrl: string;
|
|
353
|
+
readonly credential: DiagnoseCredential;
|
|
354
|
+
/** Default 'admin'. */
|
|
355
|
+
readonly adminCapability?: string;
|
|
356
|
+
/** Default true. False: the admin-only checks are skipped as not asked, not failed. */
|
|
357
|
+
readonly expectAdmin?: boolean;
|
|
358
|
+
readonly fetch?: typeof fetch;
|
|
359
|
+
}
|
|
360
|
+
/** Every check `diagnose` can emit, in dependency order: what a caller marks NOT ASKED when it
|
|
361
|
+
* cannot run diagnose at all (the CLI's direct-to-postgres target). */
|
|
362
|
+
export declare const DIAGNOSE_CHECKS: readonly string[];
|
|
363
|
+
/**
|
|
364
|
+
* Runs every check against `opts.baseUrl`, in dependency order. A failure
|
|
365
|
+
* short-circuits its dependants into explicit skips.
|
|
366
|
+
*/
|
|
367
|
+
export declare function diagnose(opts: DiagnoseOpts): Promise<DiagnoseResult>;
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region ../../packages/substrate-client/src/admin/onboard.d.ts
|
|
370
|
+
type OnboardStepStatus = 'done' | 'todo' | 'blocked' | 'skipped';
|
|
371
|
+
type OnboardAction = {
|
|
372
|
+
readonly kind: 'bootstrap';
|
|
373
|
+
} | {
|
|
374
|
+
readonly kind: 'register-admin';
|
|
375
|
+
} | {
|
|
376
|
+
readonly kind: 'register-agent';
|
|
377
|
+
} | {
|
|
378
|
+
readonly kind: 'revoke';
|
|
379
|
+
readonly kids: readonly string[];
|
|
380
|
+
};
|
|
381
|
+
interface OnboardStep {
|
|
382
|
+
readonly name: string;
|
|
383
|
+
readonly status: OnboardStepStatus;
|
|
384
|
+
readonly detail: string;
|
|
385
|
+
/** Present on `todo`: what to do, whether or not an action can do it. */
|
|
386
|
+
readonly fix?: string;
|
|
387
|
+
/** Present only on `todo`, and only when a client can perform the fix. */
|
|
388
|
+
readonly action?: OnboardAction;
|
|
389
|
+
/** Optional steps never hold up completion. */
|
|
390
|
+
readonly optional: boolean;
|
|
391
|
+
readonly skippable: boolean;
|
|
392
|
+
}
|
|
393
|
+
interface PlanOnboardingOpts {
|
|
394
|
+
/** The caller can reach postgres (`SUBSTRATE_DATABASE_URL`), which `bootstrap` needs. */
|
|
395
|
+
readonly canBootstrap: boolean;
|
|
396
|
+
/** Steps the operator skipped this run. Honoured only for skippable steps. */
|
|
397
|
+
readonly skipped: ReadonlySet<string>;
|
|
398
|
+
/**
|
|
399
|
+
* Default true: a credential NO that bootstrap cannot fix is explained in onboarding's
|
|
400
|
+
* terms (SUBSTRATE_DATABASE_URL). A caller that only reports, about an identity that is not the
|
|
401
|
+
* admin's, passes false to keep the check's own fix.
|
|
402
|
+
*/
|
|
403
|
+
readonly explainNoBootstrap?: boolean;
|
|
404
|
+
}
|
|
405
|
+
export declare const ONBOARD_STEPS: readonly string[];
|
|
406
|
+
export declare const SKIPPABLE_STEPS: ReadonlySet<string>;
|
|
407
|
+
/** The checklist marks every surface draws, so the CLI and the TUI cannot drift. */
|
|
408
|
+
export declare const STEP_MARKS: Readonly<Record<OnboardStepStatus, string>>;
|
|
409
|
+
/** Marks the step the operator is on: the first `todo`. */
|
|
410
|
+
export declare const CURRENT_MARK = "▶";
|
|
411
|
+
export declare function planOnboarding(result: DiagnoseResult, opts: PlanOnboardingOpts): OnboardStep[];
|
|
412
|
+
/** The step the operator is on: the first one still to do. */
|
|
413
|
+
export declare function currentStep(steps: readonly OnboardStep[]): OnboardStep | undefined;
|
|
414
|
+
/** True while any required step is still to do — the `--check` verdict. */
|
|
415
|
+
export declare function requiredOutstanding(steps: readonly OnboardStep[]): boolean;
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region ../../packages/substrate-client/src/diagnostics.d.ts
|
|
418
|
+
/** The `_diagnostics` map exactly as substrate publishes it, not a local restatement. */
|
|
419
|
+
type EnvelopeDiagnostics = NonNullable<PackEnvelope['_diagnostics']>;
|
|
420
|
+
/** One type's worth of non-fatal diagnostics, already attributed to its frame key. */
|
|
421
|
+
interface Diagnostic {
|
|
422
|
+
/** The top-level frame key this concerns, e.g. `notes/Todo`. */
|
|
423
|
+
opKey: string;
|
|
424
|
+
/**
|
|
425
|
+
* Projection keys the type does not declare. Every one of them came back as
|
|
426
|
+
* `null` on every row.
|
|
427
|
+
*
|
|
428
|
+
* Always present, and EMPTY when this diagnostic reports something else; kept
|
|
429
|
+
* required so existing consumers keep getting an array.
|
|
430
|
+
*/
|
|
431
|
+
unknownProjectionFields: string[];
|
|
432
|
+
/**
|
|
433
|
+
* Present when the where-clause reached the substrate without being
|
|
434
|
+
* schema-validated, because the type is registered but absent from its
|
|
435
|
+
* namespace's published schema (e.g. runtime-created types). The value is
|
|
436
|
+
* substrate's explanation.
|
|
437
|
+
*
|
|
438
|
+
* Results are still correct — a substrate refuses a predicate it cannot
|
|
439
|
+
* honour. What is lost is the indexed-field check, so an unindexed filter
|
|
440
|
+
* SCANS instead of being rejected.
|
|
441
|
+
*/
|
|
442
|
+
filterValidationSkipped?: string;
|
|
443
|
+
/**
|
|
444
|
+
* Diagnostic keys the substrate reported that this client version does not
|
|
445
|
+
* understand — i.e. substrate-client is older than the substrate it is talking to.
|
|
446
|
+
*/
|
|
447
|
+
unrecognizedKeys?: string[];
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Sink for envelope diagnostics. Called once per affected frame key, per
|
|
451
|
+
* query/mutate response. Pass your own via `SubstrateClientOptions.onDiagnostics` to
|
|
452
|
+
* route into a logger or metrics pipeline; throwing from it in development is
|
|
453
|
+
* the third option substrate-types sanctions.
|
|
454
|
+
*/
|
|
455
|
+
type DiagnosticsSink = (diagnostic: Diagnostic) => void;
|
|
456
|
+
/**
|
|
457
|
+
* Extract diagnostics from a decoded envelope and hand each one to `sink`.
|
|
458
|
+
* Returns the flattened list so callers can also attach it to a mapped result.
|
|
459
|
+
*
|
|
460
|
+
* An envelope with no `_diagnostics` returns `[]` without the sink firing.
|
|
461
|
+
*/
|
|
462
|
+
export declare function collectDiagnostics(envDiagnostics: EnvelopeDiagnostics | undefined, sink: DiagnosticsSink | undefined): Diagnostic[];
|
|
463
|
+
/**
|
|
464
|
+
* Default sink: one `console.warn` per distinct observation set, naming the
|
|
465
|
+
* frame key and everything observed about it, plus the reason the reader should
|
|
466
|
+
* care in each case.
|
|
467
|
+
*
|
|
468
|
+
* ONE warning per diagnostic rather than one per observation. An entry carrying
|
|
469
|
+
* both an unknown projection and a skipped filter validation describes a single
|
|
470
|
+
* read, and splitting it reads as two independent defects.
|
|
471
|
+
*
|
|
472
|
+
* Deduping state is per-sink, so per-client: `new SubstrateClient(...)` starts
|
|
473
|
+
* fresh.
|
|
474
|
+
*/
|
|
475
|
+
export declare function createDefaultDiagnosticsSink(): DiagnosticsSink;
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region ../../packages/substrate-client/src/transport/ws.d.ts
|
|
478
|
+
type WsEncoding = 'json' | 'pack';
|
|
479
|
+
/**
|
|
480
|
+
* Minimal constructor shape for an injectable WebSocket implementation.
|
|
481
|
+
* Must be node-ws-compatible when headers are needed: `(url, protocols?,
|
|
482
|
+
* { headers })`. The WHATWG/browser constructor matches the first two
|
|
483
|
+
* parameters and simply cannot receive headers.
|
|
484
|
+
*/
|
|
485
|
+
type WebSocketImpl = new (url: string, protocols?: string | string[], options?: {
|
|
486
|
+
headers?: Record<string, string>;
|
|
487
|
+
}) => unknown;
|
|
488
|
+
/** Bounded auto-resubscribe policy for overload teardowns (contract class 1). */
|
|
489
|
+
interface WsOverloadResubscribeOpts {
|
|
490
|
+
/** Master switch. Default true. `false` restores terminal-on-overload. */
|
|
491
|
+
enabled?: boolean;
|
|
492
|
+
/** Retry budget per overload streak. Default 3. */
|
|
493
|
+
maxAttempts?: number;
|
|
494
|
+
/** Exponential backoff between retries. Defaults mirror reconnect. */
|
|
495
|
+
baseDelayMs?: number;
|
|
496
|
+
maxDelayMs?: number;
|
|
497
|
+
/** Fraction 0..1 of symmetric noise on each delay. Default 0.1. */
|
|
498
|
+
jitter?: number;
|
|
499
|
+
/**
|
|
500
|
+
* A subscription that stays healthy this long after its last overload gets
|
|
501
|
+
* a fresh retry budget. Reset-on-recovery alone would let a thrashing
|
|
502
|
+
* consumer loop forever. Default 60_000.
|
|
503
|
+
*/
|
|
504
|
+
healthyResetMs?: number;
|
|
505
|
+
}
|
|
506
|
+
/** Events emitted by the subscribe/stream AsyncIterable. */
|
|
507
|
+
type SubscribeEvent<T = unknown> = {
|
|
508
|
+
kind: 'snapshot';
|
|
509
|
+
data: T;
|
|
510
|
+
shapes?: Record<string, string>;
|
|
511
|
+
} | {
|
|
512
|
+
kind: 'add';
|
|
513
|
+
data: T;
|
|
514
|
+
shapes?: Record<string, string>;
|
|
515
|
+
} | {
|
|
516
|
+
kind: 'update';
|
|
517
|
+
data: T;
|
|
518
|
+
shapes?: Record<string, string>;
|
|
519
|
+
} | {
|
|
520
|
+
kind: 'remove';
|
|
521
|
+
removedId: string;
|
|
522
|
+
} | {
|
|
523
|
+
kind: 'chunk';
|
|
524
|
+
data: T;
|
|
525
|
+
shapes?: Record<string, string>;
|
|
526
|
+
sequence?: number;
|
|
527
|
+
} | {
|
|
528
|
+
kind: 'end';
|
|
529
|
+
final?: boolean;
|
|
530
|
+
reason?: string;
|
|
531
|
+
} | {
|
|
532
|
+
kind: 'error';
|
|
533
|
+
errors: Array<{
|
|
534
|
+
message: string;
|
|
535
|
+
code?: string;
|
|
536
|
+
}>;
|
|
537
|
+
};
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region ../../packages/substrate-client/src/cache/store.d.ts
|
|
540
|
+
interface CacheEntry<T = unknown> {
|
|
541
|
+
readonly data: Signal<T | undefined>;
|
|
542
|
+
readonly loading: Signal<boolean>;
|
|
543
|
+
readonly error: Signal<Error | null>;
|
|
544
|
+
/**
|
|
545
|
+
* Non-fatal diagnostics from the envelope that produced `data` — empty when
|
|
546
|
+
* there is nothing to report. Cached with the data so every reader of this
|
|
547
|
+
* key sees them, not only the caller that issued the request.
|
|
548
|
+
*/
|
|
549
|
+
readonly diagnostics: Signal<Diagnostic[]>;
|
|
550
|
+
/** Reactive signal — bumped whenever invalidate() stamps this entry. Resets to 0 on set(). */
|
|
551
|
+
readonly invalidatedSignal: Signal<number>;
|
|
552
|
+
refCount: number;
|
|
553
|
+
invalidatedAt: number | null;
|
|
554
|
+
lastFetched: number;
|
|
555
|
+
gcTimer: ReturnType<typeof setTimeout> | null;
|
|
556
|
+
}
|
|
557
|
+
interface CacheStoreOpts {
|
|
558
|
+
idleGcMs: number;
|
|
559
|
+
}
|
|
560
|
+
declare class CacheStore {
|
|
561
|
+
#private;
|
|
562
|
+
constructor(opts: CacheStoreOpts);
|
|
563
|
+
get<T = unknown>(key: string): CacheEntry<T>;
|
|
564
|
+
peek<T = unknown>(key: string): CacheEntry<T> | undefined;
|
|
565
|
+
subscribe(key: string): () => void;
|
|
566
|
+
set<T>(key: string, data: T, diagnostics?: Diagnostic[]): void;
|
|
567
|
+
setLoading(key: string, loading: boolean): void;
|
|
568
|
+
setError(key: string, err: Error): void;
|
|
569
|
+
invalidate(keyPrefix: string): void;
|
|
570
|
+
/**
|
|
571
|
+
* Apply a subscribe event to the entry at `cacheKey`, patching the row slot
|
|
572
|
+
* under `qualifiedKey` in the entry's `data` envelope.
|
|
573
|
+
*
|
|
574
|
+
* - snapshot → replace the entire envelope via `set()`
|
|
575
|
+
* - add → append the single row to the list at data[qualifiedKey]
|
|
576
|
+
* - update → replace row by id in the list at data[qualifiedKey]
|
|
577
|
+
* - remove → drop row by removedId from the list at data[qualifiedKey]
|
|
578
|
+
* - end / error / chunk → no cache change (the hook surfaces these)
|
|
579
|
+
*
|
|
580
|
+
* `update` / `remove` on an entry without data are no-ops — the server always
|
|
581
|
+
* emits `snapshot` first.
|
|
582
|
+
*/
|
|
583
|
+
applySubscribeEvent(cacheKey: string, qualifiedKey: string, event: SubscribeEvent): void;
|
|
584
|
+
}
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region ../../packages/substrate-client/src/nl.d.ts
|
|
587
|
+
interface NlApi {
|
|
588
|
+
ask(req: NlAskRequest, opts?: {
|
|
589
|
+
signal?: AbortSignal;
|
|
590
|
+
}): AsyncIterable<NlWireEvent>;
|
|
591
|
+
askJson(req: NlAskRequest, opts?: {
|
|
592
|
+
signal?: AbortSignal;
|
|
593
|
+
}): Promise<NlAskResult>;
|
|
594
|
+
pack(namespace: string, opts?: {
|
|
595
|
+
signal?: AbortSignal;
|
|
596
|
+
}): Promise<NlServedPack>;
|
|
597
|
+
}
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region ../../packages/substrate-client/src/client.d.ts
|
|
600
|
+
interface SubstrateClientOptions {
|
|
601
|
+
endpoint: string;
|
|
602
|
+
token?: string;
|
|
603
|
+
/**
|
|
604
|
+
* Supplies the bare JWT (no `Bearer ` prefix — the transports add it).
|
|
605
|
+
*
|
|
606
|
+
* Sync providers are accepted so `@mnmal-ai/substrate-policy`'s synchronous
|
|
607
|
+
* `makeTokenProvider` is usable directly; the transports `await` either way.
|
|
608
|
+
*/
|
|
609
|
+
getToken?: () => string | Promise<string>;
|
|
610
|
+
fetch?: typeof fetch;
|
|
611
|
+
reconnect?: {
|
|
612
|
+
baseDelayMs?: number;
|
|
613
|
+
maxDelayMs?: number;
|
|
614
|
+
jitter?: number;
|
|
615
|
+
};
|
|
616
|
+
/**
|
|
617
|
+
* Wire encoding for the WS surface (subscribe + stream). Default `json`.
|
|
618
|
+
* `pack` advertises the `substrate-pack` subprotocol at handshake; the connection
|
|
619
|
+
* then exclusively speaks msgpack frames with positionally-encoded `data`,
|
|
620
|
+
* which the client decodes back to named-object rows using the cached
|
|
621
|
+
* federated schema. Negotiated once per WS connection — distinct from the
|
|
622
|
+
* per-call HTTP `wire` opt because the WS subprotocol is a handshake-time
|
|
623
|
+
* choice.
|
|
624
|
+
*/
|
|
625
|
+
wsEncoding?: WsEncoding;
|
|
626
|
+
/**
|
|
627
|
+
* Auto-resubscribe policy for `subscription_overloaded` teardowns. Default:
|
|
628
|
+
* enabled with 3 attempts. See the README "Terminal-aware resubscribe" section.
|
|
629
|
+
*/
|
|
630
|
+
overloadResubscribe?: WsOverloadResubscribeOpts;
|
|
631
|
+
/**
|
|
632
|
+
* Explicit WebSocket implementation for the subscribe/stream surface. Must
|
|
633
|
+
* be node-ws-compatible (`new (url, protocols?, { headers })`) so the
|
|
634
|
+
* bearer can ride the upgrade. Defaults to node-ws under Node and the
|
|
635
|
+
* global WebSocket elsewhere — see WsTransportOpts.webSocket.
|
|
636
|
+
*/
|
|
637
|
+
webSocket?: WebSocketImpl;
|
|
638
|
+
/**
|
|
639
|
+
* Sink for non-fatal envelope diagnostics (`_diagnostics`) on query/mutate
|
|
640
|
+
* responses: projection keys the type does not declare, a where-clause that
|
|
641
|
+
* never reached the validator, and any diagnostic a newer substrate reports
|
|
642
|
+
* that this client cannot read.
|
|
643
|
+
*
|
|
644
|
+
* Defaults to a deduped `console.warn`. Pass an explicit no-op only if you
|
|
645
|
+
* surface the slot yourself — silence is the failure this exists to prevent.
|
|
646
|
+
*/
|
|
647
|
+
onDiagnostics?: DiagnosticsSink;
|
|
648
|
+
}
|
|
649
|
+
interface CallOpts {
|
|
650
|
+
wire?: 'json' | 'pack';
|
|
651
|
+
signal?: AbortSignal;
|
|
652
|
+
headers?: Record<string, string>;
|
|
653
|
+
}
|
|
654
|
+
export declare class SubstrateClient {
|
|
655
|
+
#private;
|
|
656
|
+
constructor(opts: SubstrateClientOptions);
|
|
657
|
+
/** Natural-language ask (SSE or JSON) and the served namespace pack. Requires the substrate-nl plugin. */
|
|
658
|
+
get nl(): NlApi;
|
|
659
|
+
/** The admin-gated routes. Needs an identity whose grant confers `admin`. */
|
|
660
|
+
get admin(): AdminApi;
|
|
661
|
+
federatedSchema(): Promise<Record<string, Schema>>;
|
|
662
|
+
query(frame: QualifiedFrame, opts?: CallOpts): Promise<PackEnvelope>;
|
|
663
|
+
mutate(frame: QualifiedFrame, opts?: CallOpts): Promise<PackEnvelope>;
|
|
664
|
+
subscribe(frame: QualifiedFrame, _opts?: CallOpts): AsyncIterable<SubscribeEvent>;
|
|
665
|
+
stream(frame: QualifiedFrame, _opts?: CallOpts): AsyncIterable<SubscribeEvent>;
|
|
666
|
+
/**
|
|
667
|
+
* Live typed-row view over a single-key subscription. Subscribes under the
|
|
668
|
+
* hood, folds snapshot/add/update/remove into the current row-set, and yields
|
|
669
|
+
* the maintained `T[]` after each delta — hiding the raw `SubscribeEvent`
|
|
670
|
+
* protocol. `id` is force-selected (via `augmentFramesWithId`) so
|
|
671
|
+
* update/remove can correlate rows by id.
|
|
672
|
+
*
|
|
673
|
+
* Completes when the subscription ends; throws on an error frame — the same
|
|
674
|
+
* contract as `subscribe`. Breaking the consuming `for await` cancels the
|
|
675
|
+
* underlying WS subscription. Reconnect / overload-resubscribe are handled by
|
|
676
|
+
* `subscribe`; each fresh snapshot atomically replaces the row-set.
|
|
677
|
+
*
|
|
678
|
+
* Single-qualified-key only: multi-key frames throw; use `subscribe` for
|
|
679
|
+
* those or for raw events.
|
|
680
|
+
*/
|
|
681
|
+
watch<T = Record<string, unknown>>(frame: QualifiedFrame): AsyncIterable<T[]>;
|
|
682
|
+
/**
|
|
683
|
+
* @internal — not part of the stable public surface.
|
|
684
|
+
*/
|
|
685
|
+
get cache(): CacheStore;
|
|
686
|
+
invalidate(keyPrefix: string): void;
|
|
687
|
+
/** Runtime metrics: op totals, per-key latency, process health, slowest requests. Needs `read`. */
|
|
688
|
+
metrics(opts?: {
|
|
689
|
+
signal?: AbortSignal;
|
|
690
|
+
}): Promise<RuntimeMetrics>;
|
|
691
|
+
/** The recent error log. Needs `admin`. */
|
|
692
|
+
errors(opts?: {
|
|
693
|
+
signal?: AbortSignal;
|
|
694
|
+
}): Promise<RuntimeErrors>;
|
|
695
|
+
close(): Promise<void>;
|
|
696
|
+
}
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region ../../packages/substrate-client/src/errors.d.ts
|
|
699
|
+
/** What a non-2xx HTTP response said, when it said it as JSON `{ error, code }`. */
|
|
700
|
+
interface NetworkErrorInfo {
|
|
701
|
+
status?: number;
|
|
702
|
+
code?: string;
|
|
703
|
+
serverMessage?: string;
|
|
704
|
+
/** The refusal's parsed JSON object, verbatim: route-specific detail (`edgeCount`, `unmapped`, `invalid`, …) lives here. */
|
|
705
|
+
body?: Readonly<Record<string, unknown>>;
|
|
706
|
+
}
|
|
707
|
+
export declare class NetworkError extends Error {
|
|
708
|
+
readonly cause: unknown;
|
|
709
|
+
readonly name = "NetworkError";
|
|
710
|
+
/** HTTP status of the response, when the failure was one. */
|
|
711
|
+
readonly status?: number;
|
|
712
|
+
/** The server's JSON error `code`, when its body carried one. */
|
|
713
|
+
readonly code?: string;
|
|
714
|
+
/** The server's JSON `error` text, when its body carried one. */
|
|
715
|
+
readonly serverMessage?: string;
|
|
716
|
+
/** The refusal's parsed JSON object, verbatim. */
|
|
717
|
+
readonly body?: Readonly<Record<string, unknown>>;
|
|
718
|
+
constructor(message: string, cause: unknown, info?: NetworkErrorInfo);
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Thrown on Substrate auth failures — 401 (unauthenticated) or 403 (authenticated but
|
|
722
|
+
* not authorised). Proxy-level failures (407, 511) fall through to NetworkError.
|
|
723
|
+
*/
|
|
724
|
+
export declare class AuthError extends Error {
|
|
725
|
+
readonly status: 401 | 403;
|
|
726
|
+
readonly name = "AuthError";
|
|
727
|
+
/** The server's JSON error `code`, when its body carried one: the auth gate says `forbidden`. */
|
|
728
|
+
readonly code?: string;
|
|
729
|
+
/** The server's JSON `error` or `message` text, when its body carried one. */
|
|
730
|
+
readonly serverMessage?: string;
|
|
731
|
+
/** The refusal's parsed JSON object, verbatim. */
|
|
732
|
+
readonly body?: Readonly<Record<string, unknown>>;
|
|
733
|
+
constructor(message: string, status: 401 | 403, info?: {
|
|
734
|
+
code?: string;
|
|
735
|
+
serverMessage?: string;
|
|
736
|
+
body?: Readonly<Record<string, unknown>>;
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
export declare class SubscribeError extends Error {
|
|
740
|
+
readonly code: string;
|
|
741
|
+
readonly name = "SubscribeError";
|
|
742
|
+
constructor(message: string, code: string);
|
|
743
|
+
}
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region ../../packages/substrate-client/src/subscribe-rows.d.ts
|
|
746
|
+
/**
|
|
747
|
+
* Fold one subscribe event into `current`, returning the next row list. Pure:
|
|
748
|
+
* the caller owns terminal-kind delivery and the "select id" contract.
|
|
749
|
+
*
|
|
750
|
+
* Returns the SAME array reference when the event does not change the set (an
|
|
751
|
+
* `update` whose row carries no `id`, or a non-row kind), so callers can cheaply
|
|
752
|
+
* skip redundant writes / yields by identity.
|
|
753
|
+
*/
|
|
754
|
+
export declare function reduceSubscribeRows<T>(current: T[], qualifiedKey: string, event: SubscribeEvent): T[];
|
|
755
|
+
/**
|
|
756
|
+
* Fold a single-key subscription's event stream into a live row-set: yields the
|
|
757
|
+
* current `T[]` after every snapshot / add / update / remove. Completes on `end`
|
|
758
|
+
* (or when the source iterator completes); throws `SubscribeError` on an `error`
|
|
759
|
+
* event — matching the raw `subscribe` contract, where the transport throws on
|
|
760
|
+
* error frames.
|
|
761
|
+
*
|
|
762
|
+
* A delta that does not change the set (e.g. an `update` whose row has no id) is
|
|
763
|
+
* not re-yielded. Cancellation: breaking the consuming `for await` (or calling
|
|
764
|
+
* `.return()`) propagates to the source iterable's `return()` through the inner
|
|
765
|
+
* `for await`, cancelling the underlying WS subscription.
|
|
766
|
+
*/
|
|
767
|
+
export declare function watchRows<T>(events: AsyncIterable<SubscribeEvent>, qualifiedKey: string): AsyncGenerator<T[]>;
|
|
768
|
+
//#endregion
|
|
769
|
+
//#region ../../packages/substrate-client/src/token-target.d.ts
|
|
770
|
+
/**
|
|
771
|
+
* Where a freshly minted credential may be sent: an https origin, or plain
|
|
772
|
+
* http only to a loopback host, where nothing on the network can read it.
|
|
773
|
+
*/
|
|
774
|
+
/**
|
|
775
|
+
* @returns the origin of `baseUrl`, which a token for it names as its `aud`.
|
|
776
|
+
* @throws Error when `baseUrl` is not a URL, or is plain http to a non-loopback host.
|
|
777
|
+
*/
|
|
778
|
+
export declare function tokenAudience(baseUrl: string): string;
|
|
779
|
+
/** `fetchImpl` with redirects refused: a redirect would carry the credential to wherever it points. */
|
|
780
|
+
export declare function noRedirectFetch(fetchImpl?: typeof fetch): typeof fetch;
|
|
781
|
+
//#endregion
|
|
782
|
+
export { ADMIN_CAPABILITIES, type AdminApi, type AdminBackfillChunk, type AdminBackfillInput, type AdminBackfillSummary, type AdminCredential, type AdminDropCascade, type AdminDropNamespaceInput, type AdminDropResult, type AdminDropTypeInput, type AdminEmbedStats, type AdminEnv, type AdminGrantChange, type AdminInviteInput, type AdminInviteResult, type AdminKeyAlgorithm, type AdminKeyRow, type AdminNormaliseInput, type AdminNormaliseResult, type AdminRegisterInput, type AdminRegisterResult, type AdminReindexInput, type AdminReindexPage, type AdminRevokeResult, type AdminUpdateResult, type CallOpts, DEFAULT_CAPABILITIES, type DiagnoseCredential, type DiagnoseFacts, type DiagnoseOpts, type DiagnoseResult, type Diagnostic, type DiagnosticsSink, type DirectoryReconciliation, type DoctorCheck, type DoctorReport, type DoctorStatus, type Grant, type KeyMutationRefusal, type KeyUpdateRefusal, type NlApi, type NlAskRequest, type NlAskResult, type NlOutcome, type NlServedPack, type NlTrailEvent, type NlWireEvent, type OnboardAction, type OnboardStep, type OnboardStepStatus, type PlanOnboardingOpts, type ProcessStat, type QualifiedFrame, type ResolverStat, type RuntimeErrorEntry, type RuntimeErrors, type RuntimeMetrics, SYSTEM_NAMESPACE, SchemaDriftError, type SlowRequest, type SubscribeEvent, type SubstrateClientOptions, type SurgeryApi, type TokenProviderOpts, type WebSocketImpl, type WsOverloadResubscribeOpts, adminClaimCapabilities, allowAll, allowVerbs, and, applyRowFilters, capabilitiesFor, checkRevocable, checkUpdatable, decodeList, denyAll, denyVerbs, describeGrant, encodeGrant, encodeList, expandFlat, flattenGrant, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, intersectGrants, isActiveAdminKeyRow, isEncryptedKey, makeAuthorizationProvider, makeTokenProvider, newlyGranted, newlyGrantedPairs, not, or, parseGrantEntries, requireCapability, requireIdentity, requireNamespace, resolveAdminCredential, resolveDefaultKeyPath, resolveDefaultKidPath, revokedAtIso, row };
|