@mnmal-ai/substrate 1.0.0-alpha.10 → 1.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{boot-store-BVqfFxh1.js → boot-store-C5vNZJ3i.js} +13 -8
- package/dist/{bridge-Cp4PaIYO.d.ts → bridge-COu0Tg_h.d.ts} +1 -1
- package/dist/{cli-hSCBywhE.js → cli-BrwW4tjO.js} +41 -23
- package/dist/client.d.ts +3 -4
- package/dist/client.js +3 -3
- package/dist/{errors-7mycvNGq.d.ts → errors-BOllGhVx.d.ts} +15 -2
- package/dist/{index-DgSfwx7M.d.ts → index-Cp74OcmS.d.ts} +1 -1
- package/dist/pack.d.ts +2 -2
- package/dist/pack.js +1 -1
- package/dist/{pg-edges-store-Lxsl5ZnK.js → pg-edges-store-BLsbcXkk.js} +1 -1
- package/dist/{plugin-CtwOINCM.js → plugin-DIYm2cZE.js} +2 -2
- package/dist/proposals-bootstrap.js +2 -2
- package/dist/proposals.d.ts +2 -3
- package/dist/proposals.js +1 -1
- package/dist/recall-bootstrap.js +2 -2
- package/dist/recall.d.ts +1 -2
- package/dist/recall.js +2 -2
- package/dist/{repl-DqfHelK7.js → repl-B8gy0YM7.js} +22 -22
- package/dist/{row-BKKCXIG6.d.ts → row-DwaDU4b-.d.ts} +57 -10
- package/dist/{run-B5dTbZ3g.js → run-B18qtGKc.js} +23 -8
- package/dist/{dataset-CejF-Fr_.d.ts → schema-CijHRfuk.d.ts} +2225 -1604
- package/dist/sdk.d.ts +21 -11
- package/dist/sdk.js +4 -4
- package/dist/{src-7CUSMK66.js → src-Br6aDUti.js} +7 -3
- package/dist/{src-CqT-QWZ_.js → src-D041j6GS.js} +3 -3
- package/dist/{src-5SJ5GEIM.js → src-DK7VEQT6.js} +2572 -742
- package/dist/{src-hZb8wfvg.js → src-Dbvuel6w.js} +383 -284
- package/dist/{src-Da0t6si5.js → src-DpPdw2oL.js} +1 -1
- package/dist/{src-Bi849yhn.js → src-DptNGNYQ.js} +3 -3
- package/dist/{src-CyvV7dCK.js → src-gz4I1F29.js} +1027 -263
- package/dist/substrate-admin.js +1 -1
- package/dist/substrate.js +1 -1
- package/dist/testing.d.ts +28 -4
- package/dist/testing.js +4 -4
- package/dist/{ws-ByZyHk7m.d.ts → ws-DC8OhMaV.d.ts} +2 -3
- package/package.json +20 -19
- package/dist/schema-DoSc-4ig.d.ts +0 -470
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as BridgeCredential } from "./bridge-
|
|
3
|
-
import { Ct as AutoCrudVerb, Dt as PolicyDecision, Et as Policy, kt as RequestContext } from "./dataset-CejF-Fr_.js";
|
|
1
|
+
import { At as DeriveSpec, Cn as Row, Qt as WhereClause, _t as RequestContext, dt as AutoCrudVerb, ht as PolicyDecision, l as FieldInput, mt as Policy, n as Dropped, p as PlanClause } from "./schema-CijHRfuk.js";
|
|
2
|
+
import { n as BridgeCredential } from "./bridge-COu0Tg_h.js";
|
|
4
3
|
//#region ../../packages/substrate-types/src/nl.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* The engine-dispatchable frame a successful NL translation produces. Keys
|
|
@@ -74,19 +73,39 @@ interface NlJudgeStep {
|
|
|
74
73
|
choice?: NlJudgeChoice;
|
|
75
74
|
/** Why the reply was not applied. */
|
|
76
75
|
rejected?: string;
|
|
76
|
+
/** Keys of an applied reply outside the offered options (a walk, a comparison), ignored. */
|
|
77
|
+
ignored?: string[];
|
|
77
78
|
}
|
|
78
|
-
/** What an ask answered. The
|
|
79
|
+
/** What an ask answered. The five kinds are exhaustive. */
|
|
79
80
|
type NlOutcome = {
|
|
80
81
|
kind: 'rows';
|
|
81
82
|
frame: Query;
|
|
82
83
|
answer: string;
|
|
83
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Absent on the wire when the engine rejected the frame; `errors` then says why.
|
|
86
|
+
* On a `count` answer it is the engine's `{ count }`, or the first page of rows
|
|
87
|
+
* when the server could not count and the rows were paged instead.
|
|
88
|
+
*/
|
|
84
89
|
data: unknown;
|
|
85
|
-
/** On a `count` answer: every row the frame matches
|
|
90
|
+
/** On a `count` answer: every row the frame matches. Absent when counting stopped short, with `errors` saying why. */
|
|
86
91
|
count?: number;
|
|
87
92
|
errors?: unknown[];
|
|
88
93
|
source: 'parser' | 'judge' | 'handoff';
|
|
89
94
|
handoff?: string;
|
|
95
|
+
/** Parts of the question this answer does not reflect. Empty when nothing was lost. */
|
|
96
|
+
dropped: Dropped[];
|
|
97
|
+
/** The plan the frame ran, clause by clause, with the engine's served flags where it gave them. */
|
|
98
|
+
plan: PlanClause[];
|
|
99
|
+
} | {
|
|
100
|
+
/**
|
|
101
|
+
* The question cannot be answered without fabricating: something that
|
|
102
|
+
* changes which rows count was dropped from a count, aggregate, `$ref`
|
|
103
|
+
* or pick reading. Nothing ran; `dropped` says what, `plan` what was understood.
|
|
104
|
+
*/
|
|
105
|
+
kind: 'unknown';
|
|
106
|
+
question: string;
|
|
107
|
+
dropped: Dropped[];
|
|
108
|
+
plan: PlanClause[];
|
|
90
109
|
} | {
|
|
91
110
|
kind: 'recall';
|
|
92
111
|
query: string;
|
|
@@ -116,7 +135,7 @@ interface NlParsedData {
|
|
|
116
135
|
type NlJudgedStatus = 'resolved' | 'recall' | 'clarify' | 'refuse' | 'escalated';
|
|
117
136
|
/**
|
|
118
137
|
* One SSE event, discriminated by the SSE event name. The terminal answer is
|
|
119
|
-
* named by its outcome kind (`rows` | `recall` | `clarify` | `refuse`) and
|
|
138
|
+
* named by its outcome kind (`rows` | `recall` | `clarify` | `refuse` | `unknown`) and
|
|
120
139
|
* carries the whole outcome; `done` always follows. An in-band `error` event
|
|
121
140
|
* is not in this union: the client throws on it.
|
|
122
141
|
*/
|
|
@@ -154,6 +173,11 @@ type NlWireEvent = {
|
|
|
154
173
|
data: Extract<NlOutcome, {
|
|
155
174
|
kind: 'refuse';
|
|
156
175
|
}>;
|
|
176
|
+
} | {
|
|
177
|
+
event: 'unknown';
|
|
178
|
+
data: Extract<NlOutcome, {
|
|
179
|
+
kind: 'unknown';
|
|
180
|
+
}>;
|
|
157
181
|
} | {
|
|
158
182
|
event: 'done';
|
|
159
183
|
data: Record<string, never>;
|
|
@@ -187,8 +211,11 @@ interface NlPackField {
|
|
|
187
211
|
/** `metadata` marks a server-managed virtual (createdAt, createdById, ...). */
|
|
188
212
|
kind: 'scalar' | 'crossRef' | 'list' | 'struct' | 'metadata';
|
|
189
213
|
valueType?: string;
|
|
190
|
-
/** crossRef target
|
|
191
|
-
target?:
|
|
214
|
+
/** crossRef target. */
|
|
215
|
+
target?: {
|
|
216
|
+
namespace: string;
|
|
217
|
+
type: string;
|
|
218
|
+
};
|
|
192
219
|
indexed: boolean;
|
|
193
220
|
operators: string[];
|
|
194
221
|
phrases: string[];
|
|
@@ -226,7 +253,21 @@ interface NlValueAlias {
|
|
|
226
253
|
startsWith?: string;
|
|
227
254
|
contains?: string;
|
|
228
255
|
}
|
|
256
|
+
/** One `fieldPhrases` ruling: what a phrase binds to. Field refs are `'<Type>.<field>'` in the ruling's namespace. */
|
|
257
|
+
interface NlFieldPhrase {
|
|
258
|
+
field?: string;
|
|
259
|
+
/** Needs `field`: an equality binding ("valued PSA 9" -> Cert.grade = 9). */
|
|
260
|
+
value?: unknown;
|
|
261
|
+
/** Needs `field`: the implicit filter on that field's type. Never silent: it shows in `plan`. */
|
|
262
|
+
exclude?: WhereClause;
|
|
263
|
+
/** Operands are `'<Type>.<field>'`, both on one type. */
|
|
264
|
+
derive?: DeriveSpec;
|
|
265
|
+
/** A namespace default pick for this phrase. */
|
|
266
|
+
pick?: 'latest' | 'max' | 'min';
|
|
267
|
+
}
|
|
229
268
|
interface NlNamespaceRulings {
|
|
269
|
+
/** Phrases bound to fields, values, implicit filters, derived orderings and pick defaults. Keys are normalised (trimmed, single-spaced, lower-cased). */
|
|
270
|
+
fieldPhrases?: Record<string, NlFieldPhrase>;
|
|
230
271
|
/** Types never scoped to the asking project (their `project` means "belongs to", not "applies to"). */
|
|
231
272
|
unscopedTypes?: string[];
|
|
232
273
|
/** Extra phrases naming a type, e.g. `backlog` -> Task. Win over the generated phrases. */
|
|
@@ -250,6 +291,12 @@ interface NlNamespaceRulings {
|
|
|
250
291
|
typeNotes?: Record<string, string>;
|
|
251
292
|
/** A phrase that means a predicate, e.g. `accepted` -> Decision.status in [active, accepted]. */
|
|
252
293
|
valueAliases?: Record<string, NlValueAlias[]>;
|
|
294
|
+
/**
|
|
295
|
+
* Rows of a type that never count unless asked for, e.g. `Run` -> `{ status: { in: ['skipped'] } }`.
|
|
296
|
+
* Applied as `NOT <clause>` whenever NL reads the type, as the seed or through a walk,
|
|
297
|
+
* and shown in `plan` as `ruling:<Type> default exclude`.
|
|
298
|
+
*/
|
|
299
|
+
typeExcludes?: Record<string, WhereClause>;
|
|
253
300
|
}
|
|
254
301
|
/** The body of `GET /substrate/v1/nl/pack/:ns`. */
|
|
255
302
|
interface NlServedPack extends NlNamespacePack {
|
|
@@ -718,4 +765,4 @@ declare function row<T>(predicate: (ctx: RequestContext, row: T) => boolean): Po
|
|
|
718
765
|
*/
|
|
719
766
|
declare function applyRowFilters<T>(decision: PolicyDecision, rows: T[], ctx: RequestContext): T[];
|
|
720
767
|
//#endregion
|
|
721
|
-
export {
|
|
768
|
+
export { NlJudgeChoice as $, and as A, SYSTEM_NAMESPACE as B, flattenGrant as C, parseGrantEntries as D, intersectGrants as E, TokenProviderOpts as F, resolveAdminCredential as G, isActiveAdminKeyRow as H, adminClaimCapabilities as I, NlAskRequest as J, resolveDefaultKeyPath as K, isEncryptedKey as L, or as M, ADMIN_CAPABILITIES as N, decodeList as O, DEFAULT_CAPABILITIES as P, NlJudgeAction as Q, makeAuthorizationProvider as R, expandFlat as S, grantIsUniform as T, AdminCredential as U, describeGrant as V, AdminEnv as W, NlEvidence as X, NlAskResult as Y, NlFieldPhrase as Z, newlyGrantedPairs as _, Query as _t, denyAll as a, NlPackField as at, capabilitiesFor as b, requireIdentity as c, NlParseStatus as ct, KeyUpdateRefusal as d, NlTrailEvent as dt, NlJudgeStep as et, checkRevocable as f, NlValueAlias as ft, newlyGranted as g, NLVocabularyHint as gt, grantEntriesConfer as h, NLResult as ht, allowVerbs as i, NlOutcome as it, not as j, encodeList as k, requireNamespace as l, NlParsedData as lt, grantCovers as m, NLBase as mt, row as n, NlNamespacePack as nt, denyVerbs as o, NlPackType as ot, checkUpdatable as p, NlWireEvent as pt, resolveDefaultKidPath as q, allowAll as r, NlNamespaceRulings as rt, requireCapability as s, NlPackValueRef as st, applyRowFilters as t, NlJudgedStatus as tt, KeyMutationRefusal as u, NlServedPack as ut, revokedAtIso as v, grantEntryError as w, encodeGrant as x, Grant as y, makeTokenProvider as z };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
|
|
2
|
-
import { h as AUDIT_EVENT_TYPE, m as buildAuditRow } from "./src-
|
|
3
|
-
import { I as decodeList, L as encodeList, M as grantEntryError, g as checkUpdatable, h as checkRevocable, y as newlyGranted } from "./src-
|
|
4
|
-
import { A as runKeyListViaRoute, B as describeAdminTarget, C as doctorCommand, D as runBootstrap, E as parseBootstrapArgs, F as base64Url, G as USAGE, H as ARGV_SPEC, I as forUpdate, J as pgNoticeOptions, K as argvError, L as generateAdminKeypair, M as ACTOR_HINT, N as BootstrapError, O as REVOKE_EXIT_CODES, P as CLI_ACTOR_KID, R as listActiveAdminKeys, S as grantLines, T as formatBootstrapOutput, U as validateArgv, V as resolveAdminTarget, W as RESTART_NOTE, _ as onboardCommand, b as runRegister, c as refuseContractViolation, g as openPgDataset, h as version, j as runKeyPatchViaRoute, k as UPDATE_EXIT_CODES, l as buildDeferredIndexes, m as loadPluginsFromDir, n as resolvePluginDir, q as AdminCliError, r as BINARY_CONTRACT_VERSION, s as parseEnv, t as bootStore, v as formatRegisterOutput, w as formatDoctorReport, x as runRegisterViaRoute, y as parseRegisterArgs, z as readKeyById } from "./boot-store-
|
|
5
|
-
import { a as PLAIN_SCHEMA_NAME, c as assertStoreSchema, d as isDerivedMigration, g as detectLayout, h as UUID_REGEX, i as MIGRATE_STORE_MARKER_TABLE, o as UUID_CHECK_MIGRATION, r as seqName, u as getMigrationList } from "./src-
|
|
2
|
+
import { h as AUDIT_EVENT_TYPE, m as buildAuditRow } from "./src-DK7VEQT6.js";
|
|
3
|
+
import { I as decodeList, L as encodeList, M as grantEntryError, g as checkUpdatable, h as checkRevocable, y as newlyGranted } from "./src-DpPdw2oL.js";
|
|
4
|
+
import { A as runKeyListViaRoute, B as describeAdminTarget, C as doctorCommand, D as runBootstrap, E as parseBootstrapArgs, F as base64Url, G as USAGE, H as ARGV_SPEC, I as forUpdate, J as pgNoticeOptions, K as argvError, L as generateAdminKeypair, M as ACTOR_HINT, N as BootstrapError, O as REVOKE_EXIT_CODES, P as CLI_ACTOR_KID, R as listActiveAdminKeys, S as grantLines, T as formatBootstrapOutput, U as validateArgv, V as resolveAdminTarget, W as RESTART_NOTE, _ as onboardCommand, b as runRegister, c as refuseContractViolation, g as openPgDataset, h as version, j as runKeyPatchViaRoute, k as UPDATE_EXIT_CODES, l as buildDeferredIndexes, m as loadPluginsFromDir, n as resolvePluginDir, q as AdminCliError, r as BINARY_CONTRACT_VERSION, s as parseEnv, t as bootStore, v as formatRegisterOutput, w as formatDoctorReport, x as runRegisterViaRoute, y as parseRegisterArgs, z as readKeyById } from "./boot-store-C5vNZJ3i.js";
|
|
5
|
+
import { a as PLAIN_SCHEMA_NAME, c as assertStoreSchema, d as isDerivedMigration, g as detectLayout, h as UUID_REGEX, i as MIGRATE_STORE_MARKER_TABLE, o as UUID_CHECK_MIGRATION, r as seqName, u as getMigrationList } from "./src-gz4I1F29.js";
|
|
6
6
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { dirname } from "node:path";
|
|
8
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
8
|
+
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
9
9
|
import { statfs } from "node:fs/promises";
|
|
10
10
|
import postgres from "postgres";
|
|
11
11
|
import { PassThrough, Transform } from "node:stream";
|
|
@@ -1053,11 +1053,15 @@ async function runMigrateStore(args, env, deps) {
|
|
|
1053
1053
|
report.totalMs = Math.round(performance.now() - started);
|
|
1054
1054
|
return report;
|
|
1055
1055
|
};
|
|
1056
|
+
let running;
|
|
1056
1057
|
const phase = async (name, fn) => {
|
|
1057
1058
|
deps.progress(`migrate-store: ${name}`);
|
|
1058
1059
|
const t = performance.now();
|
|
1060
|
+
running = name;
|
|
1059
1061
|
try {
|
|
1060
|
-
|
|
1062
|
+
const out = await fn();
|
|
1063
|
+
running = void 0;
|
|
1064
|
+
return out;
|
|
1061
1065
|
} finally {
|
|
1062
1066
|
report.phases[name] = Math.round(performance.now() - t);
|
|
1063
1067
|
}
|
|
@@ -1067,7 +1071,9 @@ async function runMigrateStore(args, env, deps) {
|
|
|
1067
1071
|
if (report.refusals.length > 0) return finish(2);
|
|
1068
1072
|
const targetEnv = {
|
|
1069
1073
|
...vars,
|
|
1070
|
-
SUBSTRATE_DATABASE_URL: toUrl
|
|
1074
|
+
SUBSTRATE_DATABASE_URL: toUrl,
|
|
1075
|
+
HOST: "127.0.0.1",
|
|
1076
|
+
SUBSTRATE_STREAM_TICKET_SECRET: vars.SUBSTRATE_STREAM_TICKET_SECRET?.trim() || randomBytes(32).toString("hex")
|
|
1071
1077
|
};
|
|
1072
1078
|
const pluginDir = resolvePluginDir(targetEnv);
|
|
1073
1079
|
const boot = () => bootStore({
|
|
@@ -1177,6 +1183,15 @@ async function runMigrateStore(args, env, deps) {
|
|
|
1177
1183
|
if (!verified.ok) return finish(3);
|
|
1178
1184
|
report.switchOver = `stop serve, set SUBSTRATE_DATABASE_URL to the value of ${args.toEnv}${args.toSchema !== null ? ` with search_path ${args.toSchema},public (options=-c search_path=${args.toSchema},public)` : ""}, then start serve. The source is untouched: pointing back at it is the rollback.`;
|
|
1179
1185
|
return finish(0);
|
|
1186
|
+
} catch (e) {
|
|
1187
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
1188
|
+
if (e instanceof AdminCliError && (e.exitCode === 2 || e.exitCode === 3)) {
|
|
1189
|
+
report.refusals.push(message);
|
|
1190
|
+
return finish(e.exitCode);
|
|
1191
|
+
}
|
|
1192
|
+
report.error = message;
|
|
1193
|
+
if (running !== void 0) report.failedPhase = running;
|
|
1194
|
+
return finish(1);
|
|
1180
1195
|
} finally {
|
|
1181
1196
|
await target?.close().catch(() => void 0);
|
|
1182
1197
|
await src.end({ timeout: 5 }).catch(() => void 0);
|
|
@@ -1286,7 +1301,7 @@ async function storeTables(pluginDir) {
|
|
|
1286
1301
|
function formatMigrateStoreOutput(r, json) {
|
|
1287
1302
|
if (json) return `${JSON.stringify(r)}\n`;
|
|
1288
1303
|
const lines = [];
|
|
1289
|
-
const verdict = r.exitCode === 0 ? r.mode === "dry-run" ? "dry run: nothing written" : "copied and verified" : r.exitCode === 3 ? "VERIFICATION FAILED: the target keeps its in-progress marker, so serve will not boot it" : "REFUSED: nothing was written to the target";
|
|
1304
|
+
const verdict = r.exitCode === 0 ? r.mode === "dry-run" ? "dry run: nothing written" : "copied and verified" : r.exitCode === 3 ? "VERIFICATION FAILED: the target keeps its in-progress marker, so serve will not boot it" : r.exitCode === 1 ? `FAILED${r.failedPhase !== void 0 ? ` in ${r.failedPhase}` : ""}: ${r.error ?? "unknown error"}` : "REFUSED: nothing was written to the target";
|
|
1290
1305
|
lines.push(`migrate-store (${r.mode}): ${verdict}`);
|
|
1291
1306
|
for (const x of r.refusals) lines.push(` refused: ${x}`);
|
|
1292
1307
|
for (const x of r.warnings) lines.push(` warning: ${x}`);
|