@mnmal-ai/substrate 0.0.0 → 1.0.0-alpha.1
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 +118 -1
- 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-DOXGRz50.js +1535 -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-BuQQEzL-.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-5hVbeiAu.js +1797 -0
- package/dist/src-C4DzaIQZ.js +837 -0
- package/dist/src-CjEwiKXw.js +2327 -0
- package/dist/src-DuopV8u7.js +2408 -0
- package/dist/src-YXlv_RyL.js +13524 -0
- package/dist/src-zcyUofMJ.js +1015 -0
- package/dist/substrate-admin.js +808 -0
- package/dist/substrate.js +5482 -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 -4
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import { C as Id, D as RowMetadata, E as Row, O as RowMetadataField, S as ClientSuppliedServerFieldError, T as ROW_METADATA_FIELDS, _ as EdgesStore, a as FieldDefScalar, b as ActorIdentity, c as MutationSchema, d as TypeSchema, f as CanDeleteResult, g as EdgeWriteInput, h as EdgeRef, i as FieldDefList, l as PackEnvelope, m as EdgePatch, n as FieldDef, o as FieldDefStruct, p as Edge, r as FieldDefCrossRef, s as FieldInput, t as EnvelopeShape, u as Schema, v as OnDelete, w as IdentityKind, x as CLIENT_SUPPLIED_SERVER_FIELD, y as OnMissing } from "./schema-g4FQLr0V.js";
|
|
2
|
+
import { a as RuntimeErrors, c as BridgeClient, d as BridgeFrame, i as RuntimeErrorEntry, l as BridgeCredential, n as ResolveObservation, o as RuntimeMetrics, r as ResolverStat, s as SlowRequest, t as ProcessStat, u as BridgeCredentialStore } from "./runtime-metrics-DwpDJ8vz.js";
|
|
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, J as AutoCrudVerb, K as WsHandler, L as RequestObservation, M as VirtualMutationDef, N as VirtualTypeDef, O as RegistryEntryKind, P as HttpHandler, Q as PolicyDecision, R as RequestObserver, S as PostWriteHook, St as WriteResult, T as RegistryBase, U as SubstrateServer, V as SubstrateRequest, W as TlsConfig, X as Obligation, Y as Identity, Z as Policy, _ as NamespaceDefinition, _t as ReadResult, a as EngineHandle, at as TypedResolver, b as PluginLifecycleContext, bt as WhereClause, c as FrameEntry, ct as Dataset, d as KernelMigrationContext, dt as DropResult, et as RequestContext, f as KernelNamespaceContribution, ft as FieldKind, g as NamespaceConfig, gt as ReadParams, h as McpToolRegistration, ht as OrderByClause, i as EncodeContext, it as RowFilterObligation, j as ScheduledTaskContext, k as RegistryEntryResolver, l as KernelLifecycleContext, lt as DatasetRegistry, m as KernelRouteClaim, mt as FilterCapabilities, n as DropParticipant, nt as ResolverArgs, o as EngineInput, ot as WriteEvent, p as KernelPlugin, pt as FieldPredicate, q as AfterTxWork, r as EmbedSourceContext, rt as ResolverReturn, s as FilterOperatorDef, st as ConditionalUpdateResult, t as CoordinatorPlugin, tt as Resolver, u as KernelMigration, ut as DeleteResult, v as NamespaceInstallContext, vt as TxScopeHandles, w as Registry, x as PluginRouteContext, xt as WriteOptions, y as NamespaceTypeDef, yt as UpdateFieldRef, z as RuntimeOp } from "./plugin-t2g2wX0b.js";
|
|
4
|
+
import { a as ResolverFrameError, c as isAuthCause, i as ReservedField, l as isResolverFrameError, n as MissingReferentError, o as RestrictViolation, r as NamespaceMismatch, s as UnsupportedFilterError, t as BridgeUnreachableError, u as isRestrictViolation } from "./errors-D4vKuwz8.js";
|
|
5
|
+
import { a as WsResponseFrame, c as ResolveTarget, d as TargetState, f as IdempotencyStore, i as WsRequestFrame, l as SweepDeps, n as WS_REASON_SERVER_RESTART, o as WsResponseKind, r as WS_REASON_SUBSCRIPTION_OVERLOADED, s as BridgeRegistry, t as WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, u as SweepState } from "./ws-C72iVS5T.js";
|
|
6
|
+
import { $ as NlJudgeStep, 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, Q as NlJudgeChoice, R as makeAuthorizationProvider, S as expandFlat, T as grantIsUniform, U as AdminCredential, V as describeGrant, W as AdminEnv, X as NlEvidence, Y as NlAskResult, Z as NlJudgeAction, _ as newlyGrantedPairs, a as denyAll, at as NlPackType, b as capabilitiesFor, c as requireIdentity, ct as NlParsedData, d as KeyUpdateRefusal, dt as NlValueAlias, et as NlJudgedStatus, f as checkRevocable, ft as NlWireEvent, g as newlyGranted, gt as Query, h as grantEntriesConfer, ht as NLVocabularyHint, i as allowVerbs, it as NlPackField, j as not, k as encodeList, l as requireNamespace, lt as NlServedPack, m as grantCovers, mt as NLResult, n as row, nt as NlNamespaceRulings, o as denyVerbs, ot as NlPackValueRef, p as checkUpdatable, pt as NLBase, q as resolveDefaultKidPath, r as allowAll, rt as NlOutcome, s as requireCapability, st as NlParseStatus, t as applyRowFilters, tt as NlNamespacePack, 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";
|
|
7
|
+
//#region ../../packages/substrate-types/src/assert-never.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Exhaustiveness guard for the `default:` arm of a `switch` over a
|
|
10
|
+
* discriminated union. An unhandled variant makes the call fail to
|
|
11
|
+
* type-check; at runtime it throws rather than returning `undefined`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function assertNever(x: never): never;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region ../../packages/substrate-types/src/canonicalize.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Returns a copy of `value` with object keys sorted recursively, so
|
|
18
|
+
* `JSON.stringify(canonicalize(x))` is stable regardless of insertion order.
|
|
19
|
+
* Arrays keep their element order; primitives (incl. `null`) pass through.
|
|
20
|
+
*/
|
|
21
|
+
export declare function canonicalize(value: unknown): unknown;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region ../../packages/substrate-types/src/env-utils.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* Pure env-string parsing helpers shared by plugins and deployment helpers
|
|
26
|
+
* (e.g. `substrate-sentinel-client`) without a substrate-sdk runtime dep.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Strict positive-integer env parsing. Returns `fallback` when `raw` is
|
|
30
|
+
* undefined (env var unset). Throws with `envVar` in the message when `raw`
|
|
31
|
+
* is set but not a positive integer — never falls back on invalid input, so
|
|
32
|
+
* a config typo fails at boot.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parsePositiveInt(raw: string | undefined, envVar: string, fallback: number): number;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../packages/substrate-types/src/hard-delete-gate.d.ts
|
|
37
|
+
/**
|
|
38
|
+
* Runtime kill switch for hard-destructive operations. When
|
|
39
|
+
* `SUBSTRATE_HARD_DELETE=refuse`, every gated apply path refuses with
|
|
40
|
+
* `ResolverFrameError('destructive_ops_disabled')` regardless of caller
|
|
41
|
+
* capability. Unset or 'allow' permits them.
|
|
42
|
+
*
|
|
43
|
+
* Lives in substrate-types so substrate-sdk can call it without a runtime dep on
|
|
44
|
+
* substrate-core. The env is read at call time, not module load.
|
|
45
|
+
*/
|
|
46
|
+
export declare function assertHardDeleteAllowed(): void;
|
|
47
|
+
export declare function validateHardDeleteEnv(): void;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region ../../packages/substrate-types/src/identity-grant.d.ts
|
|
50
|
+
/**
|
|
51
|
+
* The single resolver for "what is this identity granted", read from
|
|
52
|
+
* `Identity.grants`. Do not hand-roll another reader of `grants`; route every
|
|
53
|
+
* gate through these helpers so they cannot disagree.
|
|
54
|
+
*
|
|
55
|
+
* A `null` grant means the identity makes NO CLAIM, which the two gates read
|
|
56
|
+
* in opposite directions:
|
|
57
|
+
*
|
|
58
|
+
* engine per-frame gate no claim -> PASS. Direct-call tests and system
|
|
59
|
+
* actors reach resolvers with a bare `{ id }`, and
|
|
60
|
+
* the route wrapper is authoritative for HTTP.
|
|
61
|
+
* route gate no claim -> REFUSE. A caller that presented a
|
|
62
|
+
* token conferring nothing gets nothing.
|
|
63
|
+
*
|
|
64
|
+
* Do not replace `null` with an empty grant (would REFUSE every no-claim
|
|
65
|
+
* caller) or a wildcard grant (would invent authority).
|
|
66
|
+
*/
|
|
67
|
+
/** A resolved grant: namespace -> capabilities. `'*'` is a legal key. */
|
|
68
|
+
export type IdentityGrant = Record<string, string[]>;
|
|
69
|
+
/** The shape this reads; structural so this module need not import `Identity`. */
|
|
70
|
+
interface GrantBearing {
|
|
71
|
+
grants?: unknown;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The grant this identity carries, or `null` when it claims nothing (no
|
|
75
|
+
* identity, or `grants` absent or not an object — e.g. a bare `{ id }`).
|
|
76
|
+
*
|
|
77
|
+
* An array `grants` passes the `typeof` check and resolves to a table with no
|
|
78
|
+
* real namespace in it, which refuses: fail-closed on malformed data.
|
|
79
|
+
* Non-string capability entries are dropped.
|
|
80
|
+
*/
|
|
81
|
+
export declare function grantOf(identity: GrantBearing | null | undefined): IdentityGrant | null;
|
|
82
|
+
/**
|
|
83
|
+
* Capabilities conferred in `ns` — explicit entry, else the wildcard.
|
|
84
|
+
*
|
|
85
|
+
* Restates `@mnmal-ai/substrate-policy`'s `grant.ts` `capabilitiesFor` at the zero-dep layer;
|
|
86
|
+
* substrate-policy's `test/grant-parity.test.ts` pins the two to identical verdicts.
|
|
87
|
+
*/
|
|
88
|
+
export declare function grantedIn(resolved: IdentityGrant | null, ns: string): string[];
|
|
89
|
+
/** Does the grant name `ns` at all, explicitly or by wildcard? */
|
|
90
|
+
export declare function coversNamespace(resolved: IdentityGrant | null, ns: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Is `capability` conferred in ANY namespace?
|
|
93
|
+
*
|
|
94
|
+
* Only for the route gate, which runs before any frame is parsed and so has
|
|
95
|
+
* no namespace. For "what am I granted in `ns`", use `grantedIn`.
|
|
96
|
+
*/
|
|
97
|
+
export declare function confersAnywhere(resolved: IdentityGrant | null, capability: string): boolean;
|
|
98
|
+
/** Every capability conferred anywhere — the union, for error messages only. */
|
|
99
|
+
export declare function allCapabilities(resolved: IdentityGrant | null): string[];
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../../packages/substrate-types/src/keyed-mutex.d.ts
|
|
102
|
+
/**
|
|
103
|
+
* A process-local mutual-exclusion lock per string key.
|
|
104
|
+
*
|
|
105
|
+
* Holders of the same key run one at a time in arrival order; holders of
|
|
106
|
+
* different keys never wait on each other. A key's entry is dropped once its
|
|
107
|
+
* last holder settles, so the map does not grow with the key space.
|
|
108
|
+
*/
|
|
109
|
+
export type KeyedMutex = <T>(key: string, fn: () => Promise<T>) => Promise<T>;
|
|
110
|
+
/**
|
|
111
|
+
* Create an independent keyed mutex.
|
|
112
|
+
*
|
|
113
|
+
* @returns a function that runs `fn` once every earlier holder of `key` has
|
|
114
|
+
* settled, and resolves or rejects with `fn`'s outcome. Not re-entrant.
|
|
115
|
+
*/
|
|
116
|
+
export declare function createKeyedMutex(): KeyedMutex;
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region ../../packages/substrate-types/src/metadata-filter.d.ts
|
|
119
|
+
/** The canonical metadata filter columns, filterable and orderable on every type. */
|
|
120
|
+
export declare const METADATA_FILTER_FIELDS: Readonly<Record<string, FieldDef>>;
|
|
121
|
+
/**
|
|
122
|
+
* The author names `_metadata` returns, and the columns behind each half of
|
|
123
|
+
* their `{ kind, id }` value. A plain operand on the author name matches the id.
|
|
124
|
+
*/
|
|
125
|
+
export declare const METADATA_AUTHOR_FIELDS: {
|
|
126
|
+
readonly createdBy: {
|
|
127
|
+
readonly id: 'createdById';
|
|
128
|
+
readonly kind: 'createdByKind';
|
|
129
|
+
};
|
|
130
|
+
readonly updatedBy: {
|
|
131
|
+
readonly id: 'updatedById';
|
|
132
|
+
readonly kind: 'updatedByKind';
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Rewrites every metadata spelling in a `where` clause onto the canonical
|
|
137
|
+
* columns, through AND / OR / NOT. A name the type declares as a field of its
|
|
138
|
+
* own is left alone, and so is anything that is not a metadata spelling, for
|
|
139
|
+
* the validator to judge.
|
|
140
|
+
*/
|
|
141
|
+
export declare function normaliseMetadataWhere(where: unknown, fieldDefs: Record<string, FieldDef>): unknown;
|
|
142
|
+
/** Rewrites metadata spellings in an `orderBy` list; an author name sorts by its id. */
|
|
143
|
+
export declare function normaliseMetadataOrderBy(orderBy: unknown, fieldDefs: Record<string, FieldDef>): unknown;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region ../../packages/substrate-types/src/qualified-key.d.ts
|
|
146
|
+
/**
|
|
147
|
+
* Parser for qualified frame keys (`<namespace>/<name>`).
|
|
148
|
+
*
|
|
149
|
+
* Returns `null` for a missing slash, an empty namespace (`/Type`) or an
|
|
150
|
+
* empty name (`ns/`). Never return a stub `{ ns: '' }` instead — that drops
|
|
151
|
+
* the failure signal and routes garbage through downstream lookups.
|
|
152
|
+
*/
|
|
153
|
+
export interface ParsedKey {
|
|
154
|
+
ns: string;
|
|
155
|
+
name: string;
|
|
156
|
+
}
|
|
157
|
+
export declare function parseQualifiedKey(key: string): ParsedKey | null;
|
|
158
|
+
/**
|
|
159
|
+
* Companion formatter for `parseQualifiedKey`: returns the
|
|
160
|
+
* `<namespace>/<name>` frame-key string.
|
|
161
|
+
*/
|
|
162
|
+
export declare function formatQualifiedKey(namespace: string, name: string): string;
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region ../../packages/substrate-types/src/vocab.d.ts
|
|
165
|
+
/**
|
|
166
|
+
* A vocabulary value in its canonical form: an alias becomes its target, and a
|
|
167
|
+
* canonical value differing only in case takes the declared casing. Anything
|
|
168
|
+
* else is returned unchanged, for `assertEnumValues` to judge.
|
|
169
|
+
*/
|
|
170
|
+
export declare function canonicalVocabValue(def: FieldDef, value: unknown): unknown;
|
|
171
|
+
/** The siblings `value` implies on `def`, matched case-insensitively, or undefined. */
|
|
172
|
+
export declare function vocabImplication(def: FieldDef, value: unknown): Readonly<Record<string, unknown>> | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* `params` with every vocabulary field's value in canonical form, and the
|
|
175
|
+
* siblings an alias implies filled in. Implications are read from the RAW
|
|
176
|
+
* value, before canonicalising: `done` and `cancelled` may share a canonical
|
|
177
|
+
* value and differ only in what they imply. Throws `conflicting_implication`
|
|
178
|
+
* when the caller supplied a sibling that disagrees. Returns a copy.
|
|
179
|
+
*/
|
|
180
|
+
export declare function normaliseVocabValues(params: Record<string, unknown>, fieldDefs: Record<string, FieldDef>): Record<string, unknown>;
|
|
181
|
+
/**
|
|
182
|
+
* Every spelling a row may have STORED for `value`: its canonical form plus
|
|
183
|
+
* each alias that targets it. Rows written before a vocabulary (or an alias)
|
|
184
|
+
* existed keep their old spelling until a backfill rewrites them, so a filter
|
|
185
|
+
* on the canonical value must match those too. Unknown values pass through.
|
|
186
|
+
*/
|
|
187
|
+
export declare function storedVocabSpellings(def: FieldDef, value: unknown): unknown[];
|
|
188
|
+
/**
|
|
189
|
+
* A `where` clause that means the same over stored rows whatever spelling
|
|
190
|
+
* they carry, through AND / OR / NOT:
|
|
191
|
+
*
|
|
192
|
+
* - `eq` / `in` match the canonical value and every alias stored for it;
|
|
193
|
+
* `neq` / `nin` exclude them all.
|
|
194
|
+
* - `eq` on an alias that implies siblings (`done` -> closed + completed)
|
|
195
|
+
* matches a row stored as that literal alias, OR a row with any spelling
|
|
196
|
+
* of the canonical value whose implied siblings also hold.
|
|
197
|
+
*
|
|
198
|
+
* Other operators are left alone.
|
|
199
|
+
*/
|
|
200
|
+
export declare function normaliseVocabWhere(where: unknown, fieldDefs: Record<string, FieldDef>): unknown;
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region ../../packages/substrate-bootstrap/src/index.d.ts
|
|
203
|
+
/** One validation failure: where in the config it is, and what is wrong. */
|
|
204
|
+
export interface ConfigValidationIssue {
|
|
205
|
+
readonly path: ReadonlyArray<PropertyKey>;
|
|
206
|
+
readonly message: string;
|
|
207
|
+
}
|
|
208
|
+
/** A failed parse's error. A zod error satisfies this shape. */
|
|
209
|
+
export interface ConfigValidationError {
|
|
210
|
+
readonly issues: ReadonlyArray<ConfigValidationIssue>;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* The config schema seam: anything whose `safeParse` returns the parsed
|
|
214
|
+
* config or a validation error. A zod schema of any version satisfies it.
|
|
215
|
+
*/
|
|
216
|
+
export interface ConfigSchema<TConfig> {
|
|
217
|
+
safeParse(raw: unknown): {
|
|
218
|
+
success: true;
|
|
219
|
+
data: TConfig;
|
|
220
|
+
} | {
|
|
221
|
+
success: false;
|
|
222
|
+
error: ConfigValidationError;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
export interface CoordinatorBootstrapSpec<TConfig> {
|
|
226
|
+
/** Schema for the operator-overridable config surface. */
|
|
227
|
+
schema: ConfigSchema<TConfig>;
|
|
228
|
+
/**
|
|
229
|
+
* Plugin factory — receives parsed, defaults-applied, validated config.
|
|
230
|
+
* Coordinators do not receive code-shaped extras (see the module doc).
|
|
231
|
+
*/
|
|
232
|
+
build: (config: TConfig) => CoordinatorPlugin;
|
|
233
|
+
}
|
|
234
|
+
export type CoordinatorBootstrap = (rawConfig: Record<string, unknown>) => CoordinatorPlugin;
|
|
235
|
+
export interface KernelBootstrapSpec<TConfig, THostDeps> {
|
|
236
|
+
/** Schema for the operator-overridable config surface. */
|
|
237
|
+
schema: ConfigSchema<TConfig>;
|
|
238
|
+
/**
|
|
239
|
+
* Plugin factory — receives parsed, defaults-applied, validated config,
|
|
240
|
+
* plus a typed bag of host-built dependencies the platform constructs and
|
|
241
|
+
* supplies at invocation. Keep `THostDeps` plugin-specific.
|
|
242
|
+
*/
|
|
243
|
+
build: (config: TConfig, hostDeps: THostDeps) => KernelPlugin;
|
|
244
|
+
}
|
|
245
|
+
export type KernelBootstrap<THostDeps> = (rawConfig: Record<string, unknown>, hostDeps: THostDeps) => KernelPlugin;
|
|
246
|
+
export declare const defineBootstrap: {
|
|
247
|
+
readonly coordinator: <TConfig>(spec: CoordinatorBootstrapSpec<TConfig>) => CoordinatorBootstrap;
|
|
248
|
+
readonly kernel: <TConfig, THostDeps>(spec: KernelBootstrapSpec<TConfig, THostDeps>) => KernelBootstrap<THostDeps>;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Boot-time error thrown when a plugin's operator-supplied config fails its
|
|
252
|
+
* declared schema. Caught by the loader, which re-throws with the offending
|
|
253
|
+
* plugin name attached so operators see "<plugin> config invalid: <issues>"
|
|
254
|
+
* rather than a bare validator dump.
|
|
255
|
+
*/
|
|
256
|
+
export declare class BootstrapConfigError extends Error {
|
|
257
|
+
readonly validationError: ConfigValidationError;
|
|
258
|
+
/** The same object as `validationError`. */
|
|
259
|
+
readonly zodError: ConfigValidationError;
|
|
260
|
+
constructor(validationError: ConfigValidationError);
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region ../../packages/substrate-compose/src/routes/helpers.d.ts
|
|
264
|
+
export declare const JSON_HEADERS: Readonly<Record<string, string>>;
|
|
265
|
+
export declare function jsonResponse(status: number, value: unknown, extraHeaders?: Record<string, string>): SubstrateResponse;
|
|
266
|
+
export declare function error400(message: string): SubstrateResponse;
|
|
267
|
+
type ParseBodyResult = {
|
|
268
|
+
ok: true;
|
|
269
|
+
value: unknown;
|
|
270
|
+
} | {
|
|
271
|
+
ok: false;
|
|
272
|
+
response: SubstrateResponse;
|
|
273
|
+
};
|
|
274
|
+
export declare function parseJsonBody(req: SubstrateRequest): ParseBodyResult;
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region ../../packages/substrate-sdk/src/namespace.d.ts
|
|
277
|
+
interface TypeInput {
|
|
278
|
+
fields: Record<string, FieldDef>;
|
|
279
|
+
policy?: Policy;
|
|
280
|
+
/** Opt out of autoCRUD entirely. Default true (autoCRUD is installed). */
|
|
281
|
+
autoCrud?: boolean;
|
|
282
|
+
/** Install the admin-only purge<T> mutation. Default false. */
|
|
283
|
+
purgeable?: boolean;
|
|
284
|
+
/** Rename the admin capability (default 'admin'). */
|
|
285
|
+
adminCapability?: string;
|
|
286
|
+
/**
|
|
287
|
+
* Optional hook called after every successful create or update write.
|
|
288
|
+
* Receives the persisted row and request context. Under the engine it runs
|
|
289
|
+
* once the write's transaction commits, on the committed row, and a failure
|
|
290
|
+
* is reported rather than failing the write; on a direct resolver call,
|
|
291
|
+
* errors propagate to the caller.
|
|
292
|
+
*/
|
|
293
|
+
postWrite?: PostWriteHook;
|
|
294
|
+
/**
|
|
295
|
+
* Optional embeddable-type metadata. When present, substrate plugins
|
|
296
|
+
* (such as substrate-recall) inspect this slot at coordinator-namespace
|
|
297
|
+
* install time and chain an appropriate postWrite hook that runs
|
|
298
|
+
* `source(row, ctx?)` to produce the text fed to the embedder. The SDK
|
|
299
|
+
* does not interpret this slot — it stores the metadata and exposes it
|
|
300
|
+
* via the namespace introspection used by substrate plugins.
|
|
301
|
+
*
|
|
302
|
+
* `ctx` is optional — when the composing substrate has a dataset
|
|
303
|
+
* resolver wired, source functions may call
|
|
304
|
+
* `ctx.read(ns, type, { id })` to inline related-entity context.
|
|
305
|
+
* Async return is supported so source can await crossRef reads.
|
|
306
|
+
*
|
|
307
|
+
* Returning `null` / `undefined` declares the row un-indexable — the
|
|
308
|
+
* substrate skips the embed AND removes any embedding the row already
|
|
309
|
+
* has. `''` is NOT the sentinel; it embeds normally. See
|
|
310
|
+
* `NamespaceTypeDef.embed.source` in @mnmal-ai/substrate-types, which this
|
|
311
|
+
* signature must stay identical to — `embedSourceSignaturesAgree` in
|
|
312
|
+
* test/embed-source-contract.test.ts fails the build if they drift.
|
|
313
|
+
*/
|
|
314
|
+
embed?: {
|
|
315
|
+
source: (row: Row, ctx?: EmbedSourceContext) => string | null | undefined | Promise<string | null | undefined>;
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* Optional lexical (keyword) source. Sibling of `embed`, and it exists
|
|
319
|
+
* BECAUSE the two indexes want different text from the same row: `embed`
|
|
320
|
+
* conventionally takes a handle — `synopsis || body`, often the question a
|
|
321
|
+
* row answers — and that handle drops the proper nouns the body holds.
|
|
322
|
+
*
|
|
323
|
+
* Same `null` / `undefined` un-indexable sentinel as `embed.source`, and `''`
|
|
324
|
+
* is likewise NOT the sentinel.
|
|
325
|
+
*
|
|
326
|
+
* NOTE THE SIGNATURE IS NOT IDENTICAL TO EMBED'S: there is no `ctx`. A
|
|
327
|
+
* lexical source works from `row` alone. `lexicalSourceSignaturesAgree` in
|
|
328
|
+
* test/embed-source-contract.test.ts fails the build if this drifts from
|
|
329
|
+
* `NamespaceTypeDef.lexical.source` in @mnmal-ai/substrate-types.
|
|
330
|
+
*/
|
|
331
|
+
lexical?: {
|
|
332
|
+
source: (row: Row) => string | null | undefined | Promise<string | null | undefined>;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
interface DefineNamespaceOptions {
|
|
336
|
+
/**
|
|
337
|
+
* Plugin-global policy applied to every type's autoCRUD surface. Composes
|
|
338
|
+
* with per-type policies via `and()` — the combined gate must allow.
|
|
339
|
+
*/
|
|
340
|
+
policy?: Policy;
|
|
341
|
+
/**
|
|
342
|
+
* Opaque metadata for consumers of this namespace's schema, keyed by
|
|
343
|
+
* consumer (`nl` for substrate-nl's rulings). Must be JSON-serialisable.
|
|
344
|
+
*/
|
|
345
|
+
annotations?: Record<string, unknown>;
|
|
346
|
+
/** See `NamespaceDefinition.promotedColumns`. */
|
|
347
|
+
promotedColumns?: NamespaceDefinition['promotedColumns'];
|
|
348
|
+
}
|
|
349
|
+
export declare function defineNamespace(namespace: string, types: Record<string, TypeInput>, opts?: DefineNamespaceOptions): NamespaceDefinition;
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region ../../packages/substrate-sdk/src/autocrud/autocrud-create.d.ts
|
|
352
|
+
interface CreateResolverOptions {
|
|
353
|
+
/** Type field definitions. Used to detect readonly fields and drive shortId allocation. */
|
|
354
|
+
fields?: Record<string, FieldDef>;
|
|
355
|
+
}
|
|
356
|
+
export declare function createResolver<T extends Row = Row>(typeName: string, dataset: Dataset, options?: CreateResolverOptions): TypedResolver<T>;
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region ../../packages/substrate-sdk/src/autocrud/autocrud-delete.d.ts
|
|
359
|
+
/**
|
|
360
|
+
* Delete resolver return shape. Carries the row's string index signature so
|
|
361
|
+
* it slots into `Row` (which has `[field: string]: unknown`) without cast
|
|
362
|
+
* gymnastics — the autoCRUD registration path wants the common `Row | Row[]`
|
|
363
|
+
* return type.
|
|
364
|
+
*/
|
|
365
|
+
interface DeleteResolverResult {
|
|
366
|
+
id: Id;
|
|
367
|
+
deleted: boolean;
|
|
368
|
+
[field: string]: unknown;
|
|
369
|
+
}
|
|
370
|
+
export declare function deleteResolver(typeName: string, dataset: Dataset, edges: EdgesStore): TypedResolver<DeleteResolverResult>;
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region ../../packages/substrate-sdk/src/autocrud/autocrud-get.d.ts
|
|
373
|
+
export declare function getResolver<T extends Row = Row>(typeName: string, dataset: Dataset): TypedResolver<T | null>;
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region ../../packages/substrate-sdk/src/autocrud/autocrud-list.d.ts
|
|
376
|
+
interface ListResolverOptions {
|
|
377
|
+
/** Field definitions; vocabulary aliases in `where` are normalised against them. */
|
|
378
|
+
fields?: Record<string, FieldDef>;
|
|
379
|
+
}
|
|
380
|
+
export declare function listResolver<_T extends Row = Row>(typeName: string, dataset: Dataset, options?: ListResolverOptions): TypedResolver<ReadResult>;
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region ../../packages/substrate-sdk/src/autocrud/autocrud-purge.d.ts
|
|
383
|
+
interface PurgeResolverResult {
|
|
384
|
+
id: Id;
|
|
385
|
+
purged: boolean;
|
|
386
|
+
[field: string]: unknown;
|
|
387
|
+
}
|
|
388
|
+
export declare function purgeResolver(typeName: string, dataset: Dataset): TypedResolver<PurgeResolverResult>;
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region ../../packages/substrate-sdk/src/autocrud/autocrud-update.d.ts
|
|
391
|
+
interface UpdateResolverOptions {
|
|
392
|
+
/** Type field definitions. Used to reject client-supplied server fields. */
|
|
393
|
+
fields?: Record<string, FieldDef>;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* The trusted write-tail of an id-based update: applies the whole patch to
|
|
397
|
+
* the live row in one round-trip, stamping updatedAt/updatedBy, and emits
|
|
398
|
+
* the §5.4 onWrite event when a row actually landed. Returns null when the
|
|
399
|
+
* row is missing or tombstoned.
|
|
400
|
+
*
|
|
401
|
+
* `updateResolver` delegates here after its guards; custom system-stamped
|
|
402
|
+
* resolvers (e.g. a status transition such as `approveRequest`) call it
|
|
403
|
+
* directly with an already-resolved row id. It deliberately runs NO
|
|
404
|
+
* client-field guards — that is what lets a system writer stamp serverSet
|
|
405
|
+
* fields like `approvedAt`. Callers own validation and permission
|
|
406
|
+
* checks; this owns the metadata idiom so it stays single-sourced.
|
|
407
|
+
*/
|
|
408
|
+
export declare function applyUpdatePatch(ds: Dataset, typeName: string, rowId: Id, patchFields: Record<string, unknown>, ctx: RequestContext, onWrite?: ResolverArgs['onWrite']): Promise<Row | null>;
|
|
409
|
+
export declare function updateResolver<T extends Row = Row>(typeName: string, dataset: Dataset, edges: EdgesStore, options?: UpdateResolverOptions): TypedResolver<T | null>;
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region ../../packages/substrate-sdk/src/autocrud/index.d.ts
|
|
412
|
+
export type AutoCrudResolver = (ctx: RequestContext, args: ResolverArgs) => Promise<Row | Row[] | ReadResult | null>;
|
|
413
|
+
export interface AutoCrudRegistry {
|
|
414
|
+
register(typeName: string, input: {
|
|
415
|
+
resolver: AutoCrudResolver;
|
|
416
|
+
policy?: Policy;
|
|
417
|
+
fields?: Record<string, FieldDef>;
|
|
418
|
+
kind?: 'type' | 'mutation';
|
|
419
|
+
params?: Record<string, FieldDef>;
|
|
420
|
+
returns?: FieldDef;
|
|
421
|
+
/** Semantic autoCRUD verb threaded to policies via ctx.verb. */
|
|
422
|
+
verb?: AutoCrudVerb;
|
|
423
|
+
}): void;
|
|
424
|
+
}
|
|
425
|
+
export interface InstallAutoCrudOptions {
|
|
426
|
+
/** Field definitions for the type — passed through to the registry entry. */
|
|
427
|
+
fields?: Record<string, FieldDef>;
|
|
428
|
+
/** Policy applied to every generated resolver. Defaults to the registry's default (allowAll). */
|
|
429
|
+
policy?: Policy;
|
|
430
|
+
/**
|
|
431
|
+
* Install the admin-only `purge<T>` hard-delete mutation. Defaults to false —
|
|
432
|
+
* purge is opt-in per §5.1 and §4.5 (hard-delete bypasses tombstone lifecycle).
|
|
433
|
+
*/
|
|
434
|
+
purgeable?: boolean;
|
|
435
|
+
/**
|
|
436
|
+
* Capability name required to invoke `purge<T>` when `purgeable: true`.
|
|
437
|
+
* Defaults to `'admin'`. Composes with `options.policy` via `and(...)` — so
|
|
438
|
+
* deployments that already require authentication + specific roles keep
|
|
439
|
+
* those constraints AND the admin capability on the purge path.
|
|
440
|
+
*/
|
|
441
|
+
adminCapability?: string;
|
|
442
|
+
/**
|
|
443
|
+
* Optional post-write hook. When present, called by the create + update
|
|
444
|
+
* resolvers after a successful write with the persisted row + request
|
|
445
|
+
* context, after the engine transaction commits (see `runPostWrite`).
|
|
446
|
+
* Delete resolver does NOT invoke this hook.
|
|
447
|
+
*/
|
|
448
|
+
postWrite?: PostWriteHook;
|
|
449
|
+
}
|
|
450
|
+
export interface CreateResolverWithEdgesOptions {
|
|
451
|
+
/** Field definitions for the type — crossRef entries drive edge emission. */
|
|
452
|
+
fields?: Record<string, FieldDef>;
|
|
453
|
+
/** Optional post-write hook, called after the row + edges land. */
|
|
454
|
+
postWrite?: PostWriteHook;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Wrap the base create resolver so every crossRef field with a non-null value
|
|
458
|
+
* emits a corresponding edge post-insert — the crossRef set derives from the
|
|
459
|
+
* declared `fields`, so adding a crossRef to a type definition cannot leave a
|
|
460
|
+
* resolver silently writing rows with no edge. The write uses
|
|
461
|
+
* the engine-supplied `args.edges` when present, falling back to the
|
|
462
|
+
* closed-over handle for direct-call tests. Nested-struct crossRefs are
|
|
463
|
+
* deliberately not recursed — spec §5.2 will formalise their emission path.
|
|
464
|
+
*
|
|
465
|
+
* When `postWrite` is provided, it is called after the row is written (and
|
|
466
|
+
* after edges are emitted) with the final row + request context; see
|
|
467
|
+
* `runPostWrite` for when it runs. Errors from a direct call propagate to the
|
|
468
|
+
* caller — the SDK does not swallow.
|
|
469
|
+
*/
|
|
470
|
+
export declare function createResolverWithEdges(typeName: string, dataset: Dataset, edges: EdgesStore, options?: CreateResolverWithEdgesOptions): TypedResolver<Row>;
|
|
471
|
+
/**
|
|
472
|
+
* The options `installAutoCrud` was given, looked up by the type entry's
|
|
473
|
+
* resolver, so a reinstall (a field proposal) keeps the policy, postWrite and
|
|
474
|
+
* purge settings. Undefined for a type autoCRUD did not install.
|
|
475
|
+
*/
|
|
476
|
+
export declare function autoCrudOptionsOf(typeResolver: object): InstallAutoCrudOptions | undefined;
|
|
477
|
+
export declare function installAutoCrud(registry: AutoCrudRegistry, typeName: string, dataset: Dataset, edges: EdgesStore, options?: InstallAutoCrudOptions): void;
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region ../../packages/substrate-sdk/src/autocrud/reserved.d.ts
|
|
480
|
+
export declare const RESERVED_AUTOCRUD_FIELDS: Record<string, FieldDef>;
|
|
481
|
+
/** Reserved field names — useful for validation loops. */
|
|
482
|
+
export declare const RESERVED_AUTOCRUD_FIELD_NAMES: string[];
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region ../../packages/substrate-sdk/src/autocrud/resolve-identity.d.ts
|
|
485
|
+
/**
|
|
486
|
+
* Maps a RequestContext.identity (auth principal from policy.ts) into the
|
|
487
|
+
* row-attribution ActorIdentity used by Tier-1 row metadata.
|
|
488
|
+
*
|
|
489
|
+
* The auth `Identity` in policy.ts carries { id, grants, roles?, scopes?,
|
|
490
|
+
* kid?, [k]: unknown } — no built-in type discriminator.
|
|
491
|
+
* Resolution is by presence of convention fields on the index signature:
|
|
492
|
+
*
|
|
493
|
+
* - `agentKeyId` present → kind='agent', id=agentKeyId (JWT-verified agent key)
|
|
494
|
+
* - `tokenId` present → kind='user', id=tokenId (static token / human session)
|
|
495
|
+
* - `kind='system'` + id → kind='system', id=identity.id (explicit system envelope from internal callers)
|
|
496
|
+
* - anything else → THROWS {@link UnattributedWriteError}
|
|
497
|
+
*
|
|
498
|
+
* Called to fill `createdBy` / `updatedBy` on every autoCRUD row write.
|
|
499
|
+
*
|
|
500
|
+
* Substrate accepts no unattributed write, so there is deliberately no default
|
|
501
|
+
* actor: an internal writer passes `{ kind: 'system', id: '<component>' }`, and
|
|
502
|
+
* an unauthenticated deployment declares its actor at boot (`compose`'s
|
|
503
|
+
* `systemActor`).
|
|
504
|
+
*/
|
|
505
|
+
/**
|
|
506
|
+
* A write that cannot say who made it. Thrown rather than defaulted: a default
|
|
507
|
+
* actor would read as attribution in the audit trail while naming nobody.
|
|
508
|
+
*/
|
|
509
|
+
export declare class UnattributedWriteError extends Error {
|
|
510
|
+
readonly name = "UnattributedWriteError";
|
|
511
|
+
readonly code = "unattributed_write";
|
|
512
|
+
}
|
|
513
|
+
export declare function resolveIdentity(ctx: Pick<RequestContext, 'identity'>): ActorIdentity;
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region ../../packages/substrate-sdk/src/delete.d.ts
|
|
516
|
+
interface DeleteRowArgs {
|
|
517
|
+
dataset: Dataset;
|
|
518
|
+
edges: EdgesStore;
|
|
519
|
+
ref: EdgeRef;
|
|
520
|
+
now: () => Date;
|
|
521
|
+
}
|
|
522
|
+
interface DeleteRowResult {
|
|
523
|
+
ok: true;
|
|
524
|
+
tombstonedAt: Date;
|
|
525
|
+
}
|
|
526
|
+
export declare function deleteRow(args: DeleteRowArgs): Promise<DeleteRowResult>;
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region ../../packages/substrate-sdk/src/engine-helpers.d.ts
|
|
529
|
+
/**
|
|
530
|
+
* Build a minimal `Partial<RequestContext>` for a plugin's engine call.
|
|
531
|
+
*
|
|
532
|
+
* PASS THE CALLER'S IDENTITY WHENEVER THERE IS ONE. Omitting it yields the
|
|
533
|
+
* SYSTEM ACTOR (`identity: null`), which the engine's per-frame namespace gate
|
|
534
|
+
* waves through unconditionally — correct for genuinely system-initiated work
|
|
535
|
+
* (a scheduled sweep, a liveness probe), and a privilege escalation for
|
|
536
|
+
* anything a caller asked for. A plugin route that omits it lets a caller reach
|
|
537
|
+
* namespaces their grant does not cover, because the route gate checks a
|
|
538
|
+
* capability without a namespace and the engine gate then checks a namespace
|
|
539
|
+
* without an identity.
|
|
540
|
+
*
|
|
541
|
+
* The distinction is WHO ASKED, not which plugin.
|
|
542
|
+
*/
|
|
543
|
+
export declare function makeCtx(namespace: string, operation: 'query' | 'mutate', identity?: Identity | null): Partial<RequestContext>;
|
|
544
|
+
/**
|
|
545
|
+
* A frame the engine REFUSED, surfaced as a throw rather than as an empty result.
|
|
546
|
+
*
|
|
547
|
+
* Substrate returns a partial-success envelope: a rejected frame comes back with its
|
|
548
|
+
* key ABSENT from `data` and the reason in `errors`. Without this, `queryOne` /
|
|
549
|
+
* `queryAll` would render a refusal as `null` / `[]`, indistinguishable from a
|
|
550
|
+
* query that matched nothing.
|
|
551
|
+
*/
|
|
552
|
+
export declare class EngineQueryError extends Error {
|
|
553
|
+
readonly name = "EngineQueryError";
|
|
554
|
+
readonly code: string;
|
|
555
|
+
constructor(code: string, message: string);
|
|
556
|
+
}
|
|
557
|
+
/** Expand a list of field names into the `{ field: true }` selection map. */
|
|
558
|
+
export declare function selectAll(fields: readonly string[]): Record<string, true>;
|
|
559
|
+
/**
|
|
560
|
+
* Run an internal engine query and return the row list (empty when the frame
|
|
561
|
+
* resolves to nothing). `fields` may be a name list or a prebuilt selection map.
|
|
562
|
+
*/
|
|
563
|
+
export declare function queryAll<T>(engine: EngineHandle, namespace: string, typeName: string, params: Record<string, unknown>, fields: readonly string[] | Record<string, true>, identity?: Identity | null): Promise<Array<T>>;
|
|
564
|
+
/**
|
|
565
|
+
* Run an internal engine query expecting at most one row; returns the first
|
|
566
|
+
* row or null. `fields` may be a name list or a prebuilt selection map.
|
|
567
|
+
*/
|
|
568
|
+
export declare function queryOne<T>(engine: EngineHandle, namespace: string, typeName: string, params: Record<string, unknown>, fields: readonly string[] | Record<string, true>, identity?: Identity | null): Promise<T | null>;
|
|
569
|
+
//#endregion
|
|
570
|
+
//#region ../../packages/substrate-sdk/src/field.d.ts
|
|
571
|
+
interface ScalarFieldOptions {
|
|
572
|
+
indexed?: boolean;
|
|
573
|
+
nullable?: boolean;
|
|
574
|
+
/**
|
|
575
|
+
* When true, this field is populated by the engine (not the caller) and
|
|
576
|
+
* writes including it must be rejected at the autoCRUD layer. Intended
|
|
577
|
+
* for engine-injected fields like `shortId`; plugin authors typically
|
|
578
|
+
* should not set this on their own declarations.
|
|
579
|
+
*/
|
|
580
|
+
readonly?: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Value autoCRUD `create` fills when the caller omits this field. A
|
|
583
|
+
* non-nullable scalar with no `default` is REQUIRED on create — omitting it
|
|
584
|
+
* is rejected (`missing_required_field`). Use `default` for fields whose
|
|
585
|
+
* omission is legitimate (e.g. `archived: false`); leave it off for fields
|
|
586
|
+
* that must be supplied. Not applied on update (a partial patch).
|
|
587
|
+
*/
|
|
588
|
+
default?: string | number | boolean;
|
|
589
|
+
}
|
|
590
|
+
interface DateFieldOptions extends ScalarFieldOptions {
|
|
591
|
+
/**
|
|
592
|
+
* Marks a server-managed timestamp. autoCRUD rejects a caller-supplied value
|
|
593
|
+
* for the indicated lifecycle moment(s) and never stamps it — server-side
|
|
594
|
+
* code does (e.g. a system writer via `applyUpdatePatch`). A create-gated
|
|
595
|
+
* (`'create'` / `'both'`) field must be `nullable` or carry a `default`;
|
|
596
|
+
* autoCRUD refuses to install one that could never be filled.
|
|
597
|
+
*/
|
|
598
|
+
serverSet?: 'create' | 'update' | 'both';
|
|
599
|
+
}
|
|
600
|
+
interface CrossRefFieldOptions {
|
|
601
|
+
onDelete?: OnDelete;
|
|
602
|
+
onMissing?: OnMissing;
|
|
603
|
+
indexed?: boolean;
|
|
604
|
+
nullable?: boolean;
|
|
605
|
+
/**
|
|
606
|
+
* Activation-spreading opt-in. When `spread: true`,
|
|
607
|
+
* recall hits propagate a damped salience boost across this edge in both
|
|
608
|
+
* directions. Default off; opt in per high-signal edge (e.g.
|
|
609
|
+
* Decision.establishesConcept) to avoid polluting attention with low-signal
|
|
610
|
+
* hops (e.g. Decision.sessionId).
|
|
611
|
+
*
|
|
612
|
+
* Mirrors FieldDefCrossRef.spread — see schema.ts for the spec rationale.
|
|
613
|
+
*/
|
|
614
|
+
spread?: boolean;
|
|
615
|
+
/**
|
|
616
|
+
* Cross-type opt-in for backward expansion walks.
|
|
617
|
+
* Requires `spread: true` (the builder throws otherwise).
|
|
618
|
+
*
|
|
619
|
+
* Mirrors FieldDefCrossRef.expandCrossType — see schema.ts for the spec
|
|
620
|
+
* rationale + named win case.
|
|
621
|
+
*/
|
|
622
|
+
expandCrossType?: boolean;
|
|
623
|
+
}
|
|
624
|
+
interface StructFieldOptions {
|
|
625
|
+
nullable?: boolean;
|
|
626
|
+
}
|
|
627
|
+
interface ListFieldOptions {
|
|
628
|
+
/**
|
|
629
|
+
* Opt the list field into server-side `has` (element-membership) filtering
|
|
630
|
+
* without `_allowTableScan`. The substrate binary auto-derives the backing GIN as
|
|
631
|
+
* a tracked migration at boot — no per-field migration to author.
|
|
632
|
+
* Default false. See `FieldDefList.indexed`.
|
|
633
|
+
*/
|
|
634
|
+
indexed?: boolean;
|
|
635
|
+
nullable?: boolean;
|
|
636
|
+
}
|
|
637
|
+
interface VocabFieldOptions extends ScalarFieldOptions {
|
|
638
|
+
/** alias -> canonical value; each canonical value must be in the vocabulary. */
|
|
639
|
+
aliases?: Record<string, string>;
|
|
640
|
+
/** `false` admits values outside the vocabulary. Default strict. */
|
|
641
|
+
strict?: boolean;
|
|
642
|
+
/** alias or canonical value -> sibling fields it implies; checked against the siblings at install. */
|
|
643
|
+
implies?: Record<string, Record<string, unknown>>;
|
|
644
|
+
}
|
|
645
|
+
interface JsonFieldOptions {
|
|
646
|
+
nullable?: boolean;
|
|
647
|
+
readonly?: boolean;
|
|
648
|
+
/**
|
|
649
|
+
* Derive a GIN over `(body -> field)` so path-filter `eq` / `in` / `has`
|
|
650
|
+
* are index-served. Default false: every write to the type
|
|
651
|
+
* pays GIN maintenance, so only fields that are actually filtered opt in.
|
|
652
|
+
*/
|
|
653
|
+
indexed?: boolean;
|
|
654
|
+
}
|
|
655
|
+
export declare const field: {
|
|
656
|
+
string(opts?: ScalarFieldOptions): FieldDefScalar;
|
|
657
|
+
number(opts?: ScalarFieldOptions): FieldDefScalar;
|
|
658
|
+
boolean(opts?: ScalarFieldOptions): FieldDefScalar;
|
|
659
|
+
date(opts?: DateFieldOptions): FieldDefScalar;
|
|
660
|
+
enum(values: readonly string[], opts?: ScalarFieldOptions): FieldDefScalar;
|
|
661
|
+
/**
|
|
662
|
+
* A governed vocabulary: an enum whose synonyms are normalised to their
|
|
663
|
+
* canonical value on write and in filters. `strict: false` admits unknown
|
|
664
|
+
* values while still normalising aliases. Throws on an alias pointing
|
|
665
|
+
* outside `values`, an alias that shadows a canonical value, or a default
|
|
666
|
+
* outside `values`.
|
|
667
|
+
*/
|
|
668
|
+
vocab(values: readonly string[], opts?: VocabFieldOptions): FieldDefScalar;
|
|
669
|
+
crossRef(ns: string, type: string, opts?: CrossRefFieldOptions): FieldDefCrossRef;
|
|
670
|
+
struct(fields: Record<string, FieldDef>, opts?: StructFieldOptions): FieldDefStruct;
|
|
671
|
+
list(of: FieldDef, opts?: ListFieldOptions): FieldDefList;
|
|
672
|
+
/**
|
|
673
|
+
* JSON body. Value round-trips unchanged. Filter a value INSIDE it with a
|
|
674
|
+
* path predicate — `{ values: { path: ['year'], gt: 1990 } }` — which is
|
|
675
|
+
* type-strict. `eq` / `in` / `has` are index-served only with
|
|
676
|
+
* `{ indexed: true }`; everything else scans the type's rows and needs
|
|
677
|
+
* `_allowTableScan`. No ordering. When inner keys are known at schema time,
|
|
678
|
+
* `field.struct` is still the better fit: declared, indexed, orderable.
|
|
679
|
+
*/
|
|
680
|
+
json(opts?: JsonFieldOptions): FieldDefScalar;
|
|
681
|
+
};
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region ../../packages/substrate-sdk/src/short-id-resolver.d.ts
|
|
684
|
+
export declare function resolveEntityId(dataset: Dataset, type: string, input: Id): Promise<Id | null>;
|
|
685
|
+
/**
|
|
686
|
+
* Like `resolveEntityId`, but returns the fetched row itself. The raw-lookup
|
|
687
|
+
* branch already holds the row, so callers that need its content (e.g. a
|
|
688
|
+
* status-transition resolver reading the current status) avoid an immediate
|
|
689
|
+
* re-read of the same row; the short-form branch pays one extra
|
|
690
|
+
* read to honour the same row-shaped contract.
|
|
691
|
+
*/
|
|
692
|
+
export declare function resolveEntityRow(dataset: Dataset, type: string, input: Id): Promise<Row | null>;
|
|
693
|
+
//#endregion
|
|
694
|
+
export { ADMIN_CAPABILITIES, ActorIdentity, type AdminCredential, type AdminEnv, AfterTxWork, AutoCrudVerb, BridgeClient, BridgeCredential, BridgeCredentialStore, BridgeFrame, BridgeRegistry, BridgeUnreachableError, CLIENT_SUPPLIED_SERVER_FIELD, CanDeleteResult, ClientSuppliedServerFieldError, ConditionalUpdateResult, CoordinatorPlugin, type CrossRefFieldOptions, DEFAULT_CAPABILITIES, Dataset, DatasetRegistry, type DateFieldOptions, type DefineNamespaceOptions, DeleteResult, type DeleteRowArgs, type DeleteRowResult, DropParticipant, DropResult, Edge, EdgePatch, EdgeRef, EdgeWriteInput, EdgesStore, EmbedSourceContext, EncodeContext, EngineHandle, EngineInput, EnvelopeShape, FieldDef, FieldDefCrossRef, FieldDefList, FieldDefScalar, FieldDefStruct, FieldInput, FieldKind, FieldPredicate, FilterCapabilities, FilterOperatorDef, FrameEntry, type Grant, HttpHandler, HttpMethod, Id, IdempotencyStore, Identity, IdentityKind, type JsonFieldOptions, KernelLifecycleContext, KernelMigration, KernelMigrationContext, KernelNamespaceContribution, KernelPlugin, KernelRouteClaim, type KeyMutationRefusal, type KeyUpdateRefusal, type ListFieldOptions, McpToolRegistration, MissingReferentError, MutationSchema, NLBase, NLResult, NLVocabularyHint, NamespaceConfig, NamespaceDefinition, NamespaceInstallContext, NamespaceMismatch, NamespaceTypeDef, NlAskRequest, NlAskResult, NlEvidence, NlJudgeAction, NlJudgeChoice, NlJudgeStep, NlJudgedStatus, NlNamespacePack, NlNamespaceRulings, NlOutcome, NlPackField, NlPackType, NlPackValueRef, NlParseStatus, NlParsedData, NlServedPack, NlTrailEvent, NlValueAlias, NlWireEvent, Obligation, OnDelete, OnMissing, OrderByClause, PackEnvelope, PluginLifecycleContext, PluginRouteContext, PluginRouter, Policy, PolicyDecision, PolicyProbeContext, PostWriteHook, ProcessStat, QualifiedFrame, Query, ROW_METADATA_FIELDS, ReadParams, ReadResult, Registry, RegistryBase, RegistryEntry, RegistryEntryInput, RegistryEntryKind, RegistryEntryResolver, RequestContext, RequestObservation, RequestObserver, ReservedField, ResolveObservation, ResolveTarget, Resolver, ResolverArgs, ResolverFrameError, ResolverReturn, ResolverStat, RestrictViolation, Row, RowFilterObligation, RowMetadata, RowMetadataField, RuntimeErrorEntry, RuntimeErrors, RuntimeMetrics, RuntimeOp, SYSTEM_NAMESPACE, type ScalarFieldOptions, ScheduledTask, ScheduledTaskContext, Schema, SlowRequest, StartOpts, type StructFieldOptions, SubstrateRequest, SubstrateResponse, SubstrateServer, SweepDeps, SweepState, TargetState, TlsConfig, type TokenProviderOpts, TxScopeHandles, type TypeInput, TypeSchema, TypedResolver, UnsupportedFilterError, UpdateFieldRef, type UpdateResolverOptions, VirtualMutationDef, VirtualTypeDef, WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, WS_REASON_SERVER_RESTART, WS_REASON_SUBSCRIPTION_OVERLOADED, WhereClause, WriteEvent, WriteOptions, WriteResult, WsConnection, WsHandler, WsRequestFrame, WsResponseFrame, WsResponseKind, adminClaimCapabilities, allowAll, allowVerbs, and, applyRowFilters, capabilitiesFor, checkRevocable, checkUpdatable, decodeList, denyAll, denyVerbs, describeGrant, encodeGrant, encodeList, expandFlat, flattenGrant, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, intersectGrants, isActiveAdminKeyRow, isAuthCause, isEncryptedKey, isResolverFrameError, isRestrictViolation, makeAuthorizationProvider, makeTokenProvider, newlyGranted, newlyGrantedPairs, not, or, parseGrantEntries, requireCapability, requireIdentity, requireNamespace, resolveAdminCredential, resolveDefaultKeyPath, resolveDefaultKidPath, revokedAtIso, row };
|