@prisma/cli-engine 0.0.3 → 0.0.6
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/index.d.ts +19 -13
- package/dist/index.js +12 -123
- package/dist/{run-summary-DMFNIvjx.d.ts → run-summary-CNL0TNZu.d.ts} +78 -14
- package/dist/testing.d.ts +9 -1
- package/dist/testing.js +7 -6
- package/dist/{token-claims-DXO0q52l.js → token-claims-B6V7E0NS.js} +637 -93
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as StreamEvent, A as BrowserWaitRequest, B as SpawnRequest, C as defineSessionCommand, D as OutputStream, E as LoadedConfig, F as ChildResult, G as Outcome, H as exitWithChildStatus, I as ChildStatusSettlement, J as PresentedResult, K as PRESENTED, L as ExitWithChildStatusOptions, M as OpenUrlOutcome, N as OpenUrlRequest, O as PRISMA_CONFIG_VERSION, P as PromptSurface, Q as Severity, R as SpawnChild, S as defineServerCommand, St as positional, T as InputStream, U as Block, V as SpawnedChild, W as Format, X as Ui, Y as TreeNode, Z as EngineEvent, _ as NeedsSpec, _t as Char, a as MountedTree, at as CredentialOrigin, b as SpawnDeclarations, bt as PositionalSpec, c as AnyCommand, ct as StoredSessions, d as CommandHelp, dt as TokenStorage, et as StreamMeta, f as CommandNeeds, ft as ConfigSection, g as HelpSpec, gt as ArgsSpec, h as Handler, ht as Args, i as CommandRedirect, it as CredentialManager, j as CommandContext, k as Runtime, l as CommandDefinition, lt as ManagementApiClient, m as ErroredEnvelope, mt as defineConfigSection, n as RunSummary, nt as Credential, o as RedirectSpec, ot as SERVICE_TOKEN_ENV_VAR, p as CompletedEnvelope, pt as SectionValidation, q as Presentations, r as CommandFamily, rt as CredentialIdentity, s as defineCommandFamily, st as Session, t as EngineCommandSnapshot, tt as ActiveCredential, u as CommandHandler, ut as ManagementApiClientConfig, v as ServerCommandDefinition, vt as CommandArgs, w as HostProcess, x as defineCommand, xt as flag, y as SessionCommandDefinition, yt as FlagSpec, z as SpawnOptions } from "./run-summary-CNL0TNZu.js";
|
|
2
2
|
import { n as CliStructuredError } from "./protocol-CpZLdxML.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli.d.ts
|
|
@@ -41,19 +41,20 @@ declare function createCli(spec: {
|
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/config-loader.d.ts
|
|
43
43
|
/**
|
|
44
|
-
* Attaches the version marker to a prisma.config.ts export.
|
|
45
|
-
*
|
|
46
|
-
* the
|
|
44
|
+
* Attaches the version marker to a prisma.config.ts export. Each
|
|
45
|
+
* top-level key names a config section, and the recognised section
|
|
46
|
+
* names are exactly the ones the CLI's command families declare. Never
|
|
47
|
+
* throws — bad section values are the section validator's problem, not
|
|
48
|
+
* defineConfig's.
|
|
47
49
|
*/
|
|
48
50
|
declare function defineConfig<T extends Record<string, unknown>>(config: T): T & {
|
|
49
51
|
readonly $prismaConfig: number;
|
|
50
52
|
};
|
|
51
53
|
/**
|
|
52
|
-
* The real-disk loader behind Runtime.
|
|
53
|
-
*
|
|
54
|
-
* bin builds Runtime.config with this; tests hand in fixtures.
|
|
54
|
+
* The real-disk loader behind Runtime.loadConfig. The bin binds it to
|
|
55
|
+
* the process cwd; tests hand in fixtures.
|
|
55
56
|
*/
|
|
56
|
-
declare function loadConfig(cwd: string): Promise<LoadedConfig>;
|
|
57
|
+
declare function loadConfig(cwd: string, configPath?: string): Promise<LoadedConfig>;
|
|
57
58
|
//#endregion
|
|
58
59
|
//#region src/credential-errors.d.ts
|
|
59
60
|
type CredentialsRequiredReason = "unauthenticated" | "expired" | "expiring-soon" | "session-ended" | "sessions-held-none-selected";
|
|
@@ -116,10 +117,15 @@ declare class EnvironmentCredentialManager implements CredentialManager {
|
|
|
116
117
|
}
|
|
117
118
|
//#endregion
|
|
118
119
|
//#region src/token-claims.d.ts
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*
|
|
120
|
+
/**
|
|
121
|
+
* The workspace a credential names. One derivation, because a token
|
|
122
|
+
* says it one of two ways and every caller wants the same answer: an
|
|
123
|
+
* OAuth token carries `workspace_id`, while a service token names its
|
|
124
|
+
* workspace through `sub` and carries no `workspace_id` at all. Reading
|
|
125
|
+
* only the claim was a second path that happened to work because
|
|
126
|
+
* service tokens reached it by a different route — a split nothing
|
|
127
|
+
* enforced.
|
|
128
|
+
*/
|
|
123
129
|
declare function credentialWorkspaceId(token: string): string | undefined;
|
|
124
130
|
declare function claimedExpiresAt(token: string): Date | undefined;
|
|
125
131
|
/**
|
|
@@ -129,4 +135,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
|
|
|
129
135
|
*/
|
|
130
136
|
declare function claimedIdentity(token: string): CredentialIdentity | undefined;
|
|
131
137
|
//#endregion
|
|
132
|
-
export { type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CompletedEnvelope, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type HostProcess, type InputStream, type LoadedConfig, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RunSummary, type Runtime, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type StoredSessions, type StreamEvent, type StreamMeta, type TokenStorage, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity,
|
|
138
|
+
export { type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type HostProcess, type InputStream, type LoadedConfig, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type StoredSessions, type StreamEvent, type StreamMeta, type TokenStorage, type TreeNode, type Ui, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, defineServerCommand, defineSessionCommand, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as PRESENTED, b as positional, c as PRISMA_CONFIG_VERSION, d as authServiceError, f as credentialRejectedError, g as noSessionForWorkspaceError, h as emptyServiceTokenError, i as buildEngine, l as SERVICE_TOKEN_ENV_VAR, m as credentialsRequiredError, n as claimedIdentity, o as defineConfig, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, s as loadConfig, t as claimedExpiresAt, u as WORKSPACE_ID_ENV_VAR, v as exitWithChildStatus, y as flag } from "./token-claims-B6V7E0NS.js";
|
|
2
2
|
import { t as CliStructuredError } from "./protocol-C1JQcGl9.js";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
|
-
import { pathToFileURL } from "node:url";
|
|
6
3
|
//#region src/cli.ts
|
|
7
4
|
/**
|
|
8
5
|
* Shell-side construction. Group help is declared with the mount.
|
|
@@ -16,11 +13,20 @@ function createCli(spec) {
|
|
|
16
13
|
}
|
|
17
14
|
//#endregion
|
|
18
15
|
//#region src/command-family.ts
|
|
16
|
+
function normalizeRedirect(spec) {
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
from: spec.from,
|
|
19
|
+
flag: spec.flag,
|
|
20
|
+
replacement: spec.replacement,
|
|
21
|
+
reason: spec.reason
|
|
22
|
+
});
|
|
23
|
+
}
|
|
19
24
|
function defineCommandFamily(spec) {
|
|
20
25
|
return Object.freeze({
|
|
21
26
|
configSection: spec.configSection,
|
|
22
27
|
commands: spec.commands,
|
|
23
|
-
docsBaseUrl: spec.docsBaseUrl
|
|
28
|
+
docsBaseUrl: spec.docsBaseUrl,
|
|
29
|
+
redirects: (spec.redirects ?? []).map(normalizeRedirect)
|
|
24
30
|
});
|
|
25
31
|
}
|
|
26
32
|
//#endregion
|
|
@@ -79,121 +85,6 @@ function defineServerCommand(def) {
|
|
|
79
85
|
});
|
|
80
86
|
}
|
|
81
87
|
//#endregion
|
|
82
|
-
//#region src/runtime.ts
|
|
83
|
-
/**
|
|
84
|
-
* The config contract version defineConfig writes as the structural
|
|
85
|
-
* `$prismaConfig` marker; the loader checks it before interpreting
|
|
86
|
-
* anything.
|
|
87
|
-
*/
|
|
88
|
-
const PRISMA_CONFIG_VERSION = 1;
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/config-loader.ts
|
|
91
|
-
/**
|
|
92
|
-
* The minimal prisma.config.ts loader behind Runtime.config:
|
|
93
|
-
* discover the file in cwd (cwd only — no walking up), evaluate it,
|
|
94
|
-
* check the defineConfig version marker, and produce LoadedConfig.
|
|
95
|
-
*
|
|
96
|
-
* Absence is not an error: section validators own absence, so a missing
|
|
97
|
-
* file is an empty LoadedConfig. An evaluated file WITHOUT the marker (a
|
|
98
|
-
* classic Prisma 7 config, which uses the same filename) fails early
|
|
99
|
-
* with one typed diagnostic — the loader never partially interprets an
|
|
100
|
-
* unmarked file, and never guesses.
|
|
101
|
-
*/
|
|
102
|
-
const CONFIG_FILE_NAME = "prisma.config.ts";
|
|
103
|
-
const MARKER_KEY = "$prismaConfig";
|
|
104
|
-
/**
|
|
105
|
-
* Attaches the version marker to a prisma.config.ts export. Top-level
|
|
106
|
-
* keys are the config sections. Never throws — bad section values are
|
|
107
|
-
* the section validator's problem, not defineConfig's.
|
|
108
|
-
*/
|
|
109
|
-
function defineConfig(config) {
|
|
110
|
-
return Object.freeze({
|
|
111
|
-
...config,
|
|
112
|
-
$prismaConfig: 1
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function hasVersionMarker(value) {
|
|
116
|
-
return typeof value === "object" && value !== null && typeof value[MARKER_KEY] === "number";
|
|
117
|
-
}
|
|
118
|
-
function fileLevelConfig(diagnostic) {
|
|
119
|
-
return {
|
|
120
|
-
sections: {},
|
|
121
|
-
diagnostics: [{
|
|
122
|
-
section: null,
|
|
123
|
-
diagnostic
|
|
124
|
-
}]
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function missingMarkerDiagnostic(path) {
|
|
128
|
-
return {
|
|
129
|
-
code: "CLI.CONFIG_MISSING_MARKER",
|
|
130
|
-
severity: "error",
|
|
131
|
-
summary: "This prisma.config.ts was not written for this version of the Prisma CLI, so it cannot be used.",
|
|
132
|
-
why: "Configs for this CLI are created with defineConfig, which records a version marker on the exported object. This file's default export has no marker — it is most likely a Prisma 7 config, which uses the same filename — and the CLI stops rather than misread it.",
|
|
133
|
-
nextActions: [{
|
|
134
|
-
kind: "user-choice",
|
|
135
|
-
label: "Migrate the file: wrap the exported object in defineConfig from @prisma/cli-engine and export the result as the default export."
|
|
136
|
-
}],
|
|
137
|
-
where: { path }
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function firstLine(text) {
|
|
141
|
-
const newline = text.indexOf("\n");
|
|
142
|
-
return (newline === -1 ? text : text.slice(0, newline)).trim();
|
|
143
|
-
}
|
|
144
|
-
function unsupportedVersionDiagnostic(path, found) {
|
|
145
|
-
return {
|
|
146
|
-
code: "CLI.CONFIG_INVALID",
|
|
147
|
-
severity: "error",
|
|
148
|
-
summary: `prisma.config.ts declares config version ${found}, but this CLI supports only version 1.`,
|
|
149
|
-
nextActions: [{
|
|
150
|
-
kind: "user-choice",
|
|
151
|
-
label: "Regenerate the config with a defineConfig matching this CLI, or update the CLI to a version that supports the declared config version."
|
|
152
|
-
}],
|
|
153
|
-
where: { path }
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
function unreadableDiagnostic(path, cause) {
|
|
157
|
-
return {
|
|
158
|
-
code: "CLI.CONFIG_UNREADABLE",
|
|
159
|
-
severity: "error",
|
|
160
|
-
summary: `prisma.config.ts could not be evaluated: ${firstLine(cause instanceof Error ? cause.message : String(cause))}`,
|
|
161
|
-
nextActions: [{
|
|
162
|
-
kind: "user-choice",
|
|
163
|
-
label: "Fix the error in the file, then run the command again."
|
|
164
|
-
}],
|
|
165
|
-
where: { path }
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* The real-disk loader behind Runtime.config: reads prisma.config.ts
|
|
170
|
-
* from cwd (cwd only — no walking up) and produces LoadedConfig. The
|
|
171
|
-
* bin builds Runtime.config with this; tests hand in fixtures.
|
|
172
|
-
*/
|
|
173
|
-
async function loadConfig(cwd) {
|
|
174
|
-
const path = join(cwd, CONFIG_FILE_NAME);
|
|
175
|
-
if (!existsSync(path)) return {
|
|
176
|
-
sections: {},
|
|
177
|
-
diagnostics: []
|
|
178
|
-
};
|
|
179
|
-
let loaded;
|
|
180
|
-
try {
|
|
181
|
-
loaded = await import(pathToFileURL(path).href);
|
|
182
|
-
} catch (cause) {
|
|
183
|
-
return fileLevelConfig(unreadableDiagnostic(path, cause));
|
|
184
|
-
}
|
|
185
|
-
const exported = loaded.default;
|
|
186
|
-
if (!hasVersionMarker(exported)) return fileLevelConfig(missingMarkerDiagnostic(path));
|
|
187
|
-
const version = exported[MARKER_KEY];
|
|
188
|
-
if (version !== 1) return fileLevelConfig(unsupportedVersionDiagnostic(path, version));
|
|
189
|
-
const sections = {};
|
|
190
|
-
for (const [key, value] of Object.entries(exported)) if (key !== MARKER_KEY) sections[key] = value;
|
|
191
|
-
return {
|
|
192
|
-
sections,
|
|
193
|
-
diagnostics: []
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
//#endregion
|
|
197
88
|
//#region src/config-section.ts
|
|
198
89
|
function defineConfigSection(spec) {
|
|
199
90
|
return Object.freeze({
|
|
@@ -211,8 +102,6 @@ function defineConfigSection(spec) {
|
|
|
211
102
|
* refuses with a structured error. Env is a construction input; nothing
|
|
212
103
|
* here reads process.env.
|
|
213
104
|
*/
|
|
214
|
-
const SERVICE_TOKEN_ENV_VAR = "PRISMA_SERVICE_TOKEN";
|
|
215
|
-
const WORKSPACE_ID_ENV_VAR = "PRISMA_WORKSPACE_ID";
|
|
216
105
|
/** The SDK's Tokens requires a workspace id; an environment credential
|
|
217
106
|
* that names none is given this instead. It never leaves the manager
|
|
218
107
|
* and is never the empty string. */
|
|
@@ -315,4 +204,4 @@ var EnvironmentCredentialManager = class {
|
|
|
315
204
|
}
|
|
316
205
|
};
|
|
317
206
|
//#endregion
|
|
318
|
-
export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, authServiceError, claimedExpiresAt, claimedIdentity,
|
|
207
|
+
export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfig, defineConfigSection, defineServerCommand, defineSessionCommand, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional };
|
|
@@ -154,6 +154,11 @@ interface ManagementApiClientConfig {
|
|
|
154
154
|
}
|
|
155
155
|
//#endregion
|
|
156
156
|
//#region src/credential-manager.d.ts
|
|
157
|
+
/** The environment variables that supply a credential to a process: a
|
|
158
|
+
* service token, plus the workspace it acts in when the token's own
|
|
159
|
+
* claims name none. EnvironmentCredentialManager reads the pair; the
|
|
160
|
+
* spawn path writes it into a child's environment. */
|
|
161
|
+
declare const SERVICE_TOKEN_ENV_VAR = "PRISMA_SERVICE_TOKEN";
|
|
157
162
|
/**
|
|
158
163
|
* The proof material. Seen by the login flow (which mints it),
|
|
159
164
|
* createSession (which stores it), and the engine (which authenticates
|
|
@@ -519,8 +524,9 @@ declare const CHILD_STATUS: unique symbol;
|
|
|
519
524
|
* The sanctioned settlement outcome for "exit with the child's status
|
|
520
525
|
* verbatim": no envelope, the same settlement bypass server commands
|
|
521
526
|
* use. Built exclusively by exitWithChildStatus, and only settled by a
|
|
522
|
-
* command that declares maySpawn
|
|
523
|
-
*
|
|
527
|
+
* command that declares maySpawn, from a child result the engine
|
|
528
|
+
* itself produced. `nextActions` render to stderr before the process
|
|
529
|
+
* exits with the child's code.
|
|
524
530
|
*/
|
|
525
531
|
interface ChildStatusSettlement {
|
|
526
532
|
readonly [CHILD_STATUS]: true;
|
|
@@ -532,10 +538,10 @@ interface ExitWithChildStatusOptions {
|
|
|
532
538
|
* failed converge's reproduce hint. The envelope stays absent. */
|
|
533
539
|
readonly nextActions?: readonly NextAction[];
|
|
534
540
|
}
|
|
535
|
-
/**
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
541
|
+
/** Settles the run with the status of the child `ctx.spawn` returned.
|
|
542
|
+
* A result the engine did not produce is a construction error at
|
|
543
|
+
* settlement: this is how a real child's status reaches the exit code,
|
|
544
|
+
* not how a handler picks one. */
|
|
539
545
|
declare function exitWithChildStatus(child: ChildResult, options?: ExitWithChildStatusOptions): ChildStatusSettlement;
|
|
540
546
|
//#endregion
|
|
541
547
|
//#region src/context.d.ts
|
|
@@ -609,6 +615,10 @@ interface CommandContext<TConfig = undefined, TCode extends number = never> {
|
|
|
609
615
|
* Fires on Ctrl-C/SIGTERM (engine-owned; a second signal force-exits
|
|
610
616
|
* through the runtime's exit proxy). Session commands run until it
|
|
611
617
|
* fires.
|
|
618
|
+
*
|
|
619
|
+
* Once it has fired the engine settles the run at 130/143 from its
|
|
620
|
+
* own record of the signal, whatever the handler goes on to return —
|
|
621
|
+
* so cleanup code never states an exit code of its own.
|
|
612
622
|
*/
|
|
613
623
|
readonly signal: AbortSignal;
|
|
614
624
|
/** Where the user invoked the CLI. Handlers never read process.cwd(). */
|
|
@@ -752,10 +762,15 @@ interface Runtime {
|
|
|
752
762
|
*/
|
|
753
763
|
readonly onSignal: (cb: (signal: "SIGINT" | "SIGTERM") => void) => () => void;
|
|
754
764
|
/**
|
|
755
|
-
*
|
|
756
|
-
* the
|
|
765
|
+
* Reads prisma.config.ts, on demand. The engine calls it only when
|
|
766
|
+
* the command it is about to run declares a config section, so a run
|
|
767
|
+
* that needs no config never touches the file. `configPath` is the
|
|
768
|
+
* file `--config` named: the loader resolves it against the runtime's
|
|
769
|
+
* cwd and reports its absence. Absent means look for prisma.config.ts
|
|
770
|
+
* in cwd, where absence is not an error. The bin wires the real disk
|
|
771
|
+
* loader; tests hand in fixtures.
|
|
757
772
|
*/
|
|
758
|
-
readonly
|
|
773
|
+
readonly loadConfig: (configPath?: string) => Promise<LoadedConfig>;
|
|
759
774
|
/**
|
|
760
775
|
* The credential manager the bin wires. It is the only source of
|
|
761
776
|
* the needs check, ctx.activeCredential, and ctx.api; absent means
|
|
@@ -822,9 +837,19 @@ interface HostProcess {
|
|
|
822
837
|
exit(code: number): never;
|
|
823
838
|
}
|
|
824
839
|
interface LoadedConfig {
|
|
840
|
+
/**
|
|
841
|
+
* The file this config came from, absolute: the one `--config` named,
|
|
842
|
+
* or prisma.config.ts in cwd. A loader that found no file still names
|
|
843
|
+
* the file it looked for — with no file there are no sections, and
|
|
844
|
+
* the engine reads the path only to name the file when it reports a
|
|
845
|
+
* top-level key that is not one of the CLI's sections.
|
|
846
|
+
*/
|
|
847
|
+
readonly path: string;
|
|
825
848
|
/**
|
|
826
849
|
* Raw section values by name; validation happens per command via its
|
|
827
|
-
* command family's section token.
|
|
850
|
+
* command family's section token. The engine, not the loader, checks
|
|
851
|
+
* these names against the sections the CLI declares, so the closed
|
|
852
|
+
* set holds whatever loader a host wires.
|
|
828
853
|
*/
|
|
829
854
|
readonly sections: Readonly<Record<string, unknown>>;
|
|
830
855
|
/**
|
|
@@ -992,9 +1017,10 @@ declare function defineCommand<TFlags extends Record<string, FlagSpec<unknown>>
|
|
|
992
1017
|
* UNLESS it declares `maySpawn`, in which case it rejects --json as soon
|
|
993
1018
|
* as the command is known, before anything runs (S3): output delegated
|
|
994
1019
|
* to a child process cannot be framed. A session that returns
|
|
995
|
-
* ok(undefined) exits 0
|
|
996
|
-
*
|
|
997
|
-
*
|
|
1020
|
+
* ok(undefined) exits 0 — or 130/143 when a signal ended the run, which
|
|
1021
|
+
* the engine settles from its own record of that signal, not from
|
|
1022
|
+
* anything the handler returns; one that returns
|
|
1023
|
+
* ok(exitWithChildStatus(child)) exits with the child's status.
|
|
998
1024
|
*/
|
|
999
1025
|
interface SessionCommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = Record<never, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>> = Record<never, PositionalSpec<unknown>>, TConfig = undefined> {
|
|
1000
1026
|
readonly kind: "session-command";
|
|
@@ -1092,6 +1118,41 @@ interface ErroredEnvelope {
|
|
|
1092
1118
|
}
|
|
1093
1119
|
//#endregion
|
|
1094
1120
|
//#region src/command-family.d.ts
|
|
1121
|
+
/**
|
|
1122
|
+
* A retired invocation and the invocation that replaced it. Redirects
|
|
1123
|
+
* are metadata, never commands: they stay out of help and out of the
|
|
1124
|
+
* command tree, and are consulted only when an invocation fails to
|
|
1125
|
+
* resolve.
|
|
1126
|
+
*/
|
|
1127
|
+
interface RedirectSpec {
|
|
1128
|
+
/**
|
|
1129
|
+
* The retired invocation as the user types it: a space-separated
|
|
1130
|
+
* absolute path in the mounted tree, the same convention as
|
|
1131
|
+
* MountedTree keys.
|
|
1132
|
+
*/
|
|
1133
|
+
readonly from: string;
|
|
1134
|
+
/**
|
|
1135
|
+
* When present, a retired FLAG on a live command: `from` names the
|
|
1136
|
+
* live command's path and this the retired flag's camelCase name
|
|
1137
|
+
* (rendered --kebab-case, as flag declarations are).
|
|
1138
|
+
*/
|
|
1139
|
+
readonly flag?: string;
|
|
1140
|
+
/**
|
|
1141
|
+
* The replacement invocation, written the way help examples are
|
|
1142
|
+
* written: no binary name, `{bin}` available when the name has to sit
|
|
1143
|
+
* mid-string. Placeholder arguments use angle brackets (`<ref>`).
|
|
1144
|
+
*/
|
|
1145
|
+
readonly replacement: string;
|
|
1146
|
+
/** One sentence of context, surfaced as the error's `why`. */
|
|
1147
|
+
readonly reason?: string;
|
|
1148
|
+
}
|
|
1149
|
+
/** The normalized redirect a command family carries. */
|
|
1150
|
+
interface CommandRedirect {
|
|
1151
|
+
readonly from: string;
|
|
1152
|
+
readonly flag: string | undefined;
|
|
1153
|
+
readonly replacement: string;
|
|
1154
|
+
readonly reason: string | undefined;
|
|
1155
|
+
}
|
|
1095
1156
|
/**
|
|
1096
1157
|
* The unit of contribution and ownership a package exports for CLI
|
|
1097
1158
|
* purposes: its config section (declared once — a family-level fact)
|
|
@@ -1107,11 +1168,14 @@ interface CommandFamily {
|
|
|
1107
1168
|
* diagnostic's docs link from base + code.
|
|
1108
1169
|
*/
|
|
1109
1170
|
readonly docsBaseUrl: string | undefined;
|
|
1171
|
+
/** The invocations this family retired. */
|
|
1172
|
+
readonly redirects: readonly CommandRedirect[];
|
|
1110
1173
|
}
|
|
1111
1174
|
declare function defineCommandFamily(spec: {
|
|
1112
1175
|
readonly configSection?: ConfigSection<unknown>;
|
|
1113
1176
|
readonly commands: Readonly<Record<string, AnyCommand>>;
|
|
1114
1177
|
readonly docsBaseUrl?: string;
|
|
1178
|
+
readonly redirects?: readonly RedirectSpec[];
|
|
1115
1179
|
}): CommandFamily;
|
|
1116
1180
|
/** What the shell builds: commands by PATH (space-separated, 'db migrate'). */
|
|
1117
1181
|
type MountedTree = Readonly<Record<string, AnyCommand>>;
|
|
@@ -1164,4 +1228,4 @@ interface RunSummary {
|
|
|
1164
1228
|
readonly snapshot: EngineCommandSnapshot;
|
|
1165
1229
|
}
|
|
1166
1230
|
//#endregion
|
|
1167
|
-
export {
|
|
1231
|
+
export { StreamEvent as $, BrowserWaitRequest as A, SpawnRequest as B, defineSessionCommand as C, OutputStream as D, LoadedConfig as E, ChildResult as F, Outcome as G, exitWithChildStatus as H, ChildStatusSettlement as I, PresentedResult as J, PRESENTED as K, ExitWithChildStatusOptions as L, OpenUrlOutcome as M, OpenUrlRequest as N, PRISMA_CONFIG_VERSION as O, PromptSurface as P, Severity as Q, SpawnChild as R, defineServerCommand as S, positional as St, InputStream as T, Block as U, SpawnedChild as V, Format as W, Ui as X, TreeNode as Y, EngineEvent as Z, NeedsSpec as _, Char as _t, MountedTree as a, CredentialOrigin as at, SpawnDeclarations as b, PositionalSpec as bt, AnyCommand as c, StoredSessions as ct, CommandHelp as d, TokenStorage$1 as dt, StreamMeta as et, CommandNeeds as f, ConfigSection as ft, HelpSpec as g, ArgsSpec as gt, Handler as h, Args as ht, CommandRedirect as i, CredentialManager as it, CommandContext as j, Runtime as k, CommandDefinition as l, ManagementApiClient$1 as lt, ErroredEnvelope as m, defineConfigSection as mt, RunSummary as n, Credential as nt, RedirectSpec as o, SERVICE_TOKEN_ENV_VAR as ot, CompletedEnvelope as p, SectionValidation as pt, Presentations as q, CommandFamily as r, CredentialIdentity as rt, defineCommandFamily as s, Session as st, EngineCommandSnapshot as t, ActiveCredential as tt, CommandHandler as u, ManagementApiClientConfig as ut, ServerCommandDefinition as v, CommandArgs as vt, HostProcess as w, defineCommand as x, flag as xt, SessionCommandDefinition as y, FlagSpec as yt, SpawnOptions as z };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as StreamEvent, B as SpawnRequest, F as ChildResult, J as PresentedResult, R as SpawnChild, Z as EngineEvent, a as MountedTree, ct as StoredSessions, dt as TokenStorage, it as CredentialManager, k as Runtime, lt as ManagementApiClient, n as RunSummary, nt as Credential, r as CommandFamily, st as Session, tt as ActiveCredential, ut as ManagementApiClientConfig } from "./run-summary-CNL0TNZu.js";
|
|
2
2
|
|
|
3
3
|
//#region src/in-memory-credential-manager.d.ts
|
|
4
4
|
/** A stored session with its credential material — what the manager
|
|
@@ -158,7 +158,15 @@ declare function createTestCli(spec: {
|
|
|
158
158
|
readonly groups?: Readonly<Record<string, {
|
|
159
159
|
readonly brief: string;
|
|
160
160
|
}>>;
|
|
161
|
+
/** Seeds the sections the config file would have held. The engine
|
|
162
|
+
* asks for them only when the command declares a config section, and
|
|
163
|
+
* checks them as it would a real file's: a section name no mounted
|
|
164
|
+
* command declares fails the run. */
|
|
161
165
|
readonly config?: Readonly<Record<string, unknown>>;
|
|
166
|
+
/** Replaces the loader outright — to assert what --config asked for,
|
|
167
|
+
* to return file-level diagnostics, or to prove a run never reads
|
|
168
|
+
* the config at all. Wins over `config` when both are given. */
|
|
169
|
+
readonly loadConfig?: Runtime["loadConfig"];
|
|
162
170
|
/** Convenience manager seed: createSession runs its real claims
|
|
163
171
|
* derivation on this credential (mint the token with mintTestJwt). */
|
|
164
172
|
readonly credential?: Credential; /** Stored sessions, mirroring the state file's records. */
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as noSessionForWorkspaceError, i as buildEngine, m as credentialsRequiredError, n as claimedIdentity, p as credentialWorkspaceMismatchError, r as credentialWorkspaceId, t as claimedExpiresAt } from "./token-claims-B6V7E0NS.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
//#region src/in-memory-credential-manager.ts
|
|
4
4
|
/**
|
|
@@ -102,7 +102,7 @@ var InMemoryCredentialManager = class {
|
|
|
102
102
|
this.selection = seed.selectedWorkspaceId;
|
|
103
103
|
this.environmentCredential = seed.environmentCredential;
|
|
104
104
|
if (seed.credential !== void 0) {
|
|
105
|
-
const workspaceId =
|
|
105
|
+
const workspaceId = credentialWorkspaceId(seed.credential.token);
|
|
106
106
|
if (workspaceId === void 0) throw new Error("@prisma/cli-engine/testing: the `credential` seed runs createSession's claims derivation — the token must be a JWT with `workspace_id` (use mintTestJwt)");
|
|
107
107
|
this.applyCreateSession(seed.credential, workspaceId);
|
|
108
108
|
}
|
|
@@ -194,7 +194,7 @@ var InMemoryCredentialManager = class {
|
|
|
194
194
|
},
|
|
195
195
|
setTokens: async (tokens) => {
|
|
196
196
|
if (pinnedRecord() === void 0) throw credentialsRequiredError("session-ended");
|
|
197
|
-
const claimed =
|
|
197
|
+
const claimed = credentialWorkspaceId(tokens.accessToken);
|
|
198
198
|
if (claimed !== void 0 && claimed !== workspaceId) throw credentialWorkspaceMismatchError(workspaceId);
|
|
199
199
|
this.storedSessions = this.storedSessions.map((stored) => stored.workspaceId === workspaceId ? {
|
|
200
200
|
...stored,
|
|
@@ -254,7 +254,7 @@ var InMemoryCredentialManager = class {
|
|
|
254
254
|
return credential;
|
|
255
255
|
}
|
|
256
256
|
applyCreateSession(credential, workspaceId) {
|
|
257
|
-
const claimed =
|
|
257
|
+
const claimed = credentialWorkspaceId(credential.token);
|
|
258
258
|
if (claimed !== void 0 && claimed !== workspaceId) throw credentialWorkspaceMismatchError(workspaceId);
|
|
259
259
|
const record = {
|
|
260
260
|
workspaceId,
|
|
@@ -401,10 +401,11 @@ function createTestCli(spec) {
|
|
|
401
401
|
signalListeners.delete(cb);
|
|
402
402
|
};
|
|
403
403
|
},
|
|
404
|
-
|
|
404
|
+
loadConfig: spec.loadConfig ?? (async (configPath) => ({
|
|
405
|
+
path: configPath ?? "prisma.config.ts",
|
|
405
406
|
sections: spec.config ?? {},
|
|
406
407
|
diagnostics: []
|
|
407
|
-
},
|
|
408
|
+
})),
|
|
408
409
|
credentialManager,
|
|
409
410
|
managementApiClientConfig,
|
|
410
411
|
spawn: recordingSpawn(spec.spawn ?? scriptedSpawn(spec.spawnScript ?? (() => ({
|