@prisma/cli-engine 0.5.0 → 0.6.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.
|
@@ -3829,10 +3829,8 @@ function makePromptSurface(invocation) {
|
|
|
3829
3829
|
},
|
|
3830
3830
|
consent: async (question, opts) => {
|
|
3831
3831
|
const token = opts?.token;
|
|
3832
|
-
if (
|
|
3833
|
-
|
|
3834
|
-
throw consentUnavailable(question, state, token);
|
|
3835
|
-
}
|
|
3832
|
+
if (token !== void 0 && consumeConfirmValue(state, token)) return true;
|
|
3833
|
+
if (state.yes || !state.interactive) throw consentUnavailable(question, state, token);
|
|
3836
3834
|
if (token !== void 0) return confirmByTyping(question, token);
|
|
3837
3835
|
if (useClack()) return renderWithClack(question, (r) => r.consent(question));
|
|
3838
3836
|
return isExplicitYes(await ask(question, `? ${question} (y/n) `));
|
|
@@ -5228,6 +5226,16 @@ function unknownCommandActions(spec, state) {
|
|
|
5228
5226
|
function buildEngine(spec, options) {
|
|
5229
5227
|
return new EngineImpl(spec, options?.now, options?.delay);
|
|
5230
5228
|
}
|
|
5229
|
+
/** Returning the iterator is how the engine tells the host it has
|
|
5230
|
+
* stopped reading. On a real terminal the host's iterator may be
|
|
5231
|
+
* awaiting a keystroke that never comes, and its return cannot settle
|
|
5232
|
+
* before the host stops reading, so the run does not wait for it. */
|
|
5233
|
+
function releaseStdin(state) {
|
|
5234
|
+
const iterator = state.stdinIterator;
|
|
5235
|
+
if (iterator === void 0) return;
|
|
5236
|
+
state.stdinIterator = void 0;
|
|
5237
|
+
iterator.return?.()?.catch(() => {});
|
|
5238
|
+
}
|
|
5231
5239
|
/** Resolves on the timer OR on the signal, whichever comes first — the
|
|
5232
5240
|
* caller decides what an abort means, and no timer outlives the run. */
|
|
5233
5241
|
function waitFor(ms, signal) {
|
|
@@ -5375,7 +5383,7 @@ var EngineImpl = class {
|
|
|
5375
5383
|
});
|
|
5376
5384
|
} finally {
|
|
5377
5385
|
unsubscribe();
|
|
5378
|
-
|
|
5386
|
+
releaseStdin(state);
|
|
5379
5387
|
}
|
|
5380
5388
|
const exitCode = state.settledExitCode !== void 0 ? state.settledExitCode : this.settleRouting(invocation, stricliProcess.exitCode);
|
|
5381
5389
|
this.fireOnSettled(invocation, exitCode, startedAtMs);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ResolvedSection, A as Format, At as CommandArgs, B as Ui, Bt as CredentialOrigin, C as defineSessionCommand, Ct as PackageManagerRunRequest, D as OpenUrlRequest, Dt as Args, E as OpenUrlOutcome, Et as PackageOperations, F as Span, Ft as ActiveAccessTokenOptions, G as ConfigSection, Gt as CredentialRefresher, H as Severity, Ht as Session, I as Status, It as ActiveCredential, J as ConfigSchema, Jt as TokenStorage, K as SectionValidation, Kt as ManagementApiClient, L as Text, Lt as Credential, M as PRESENTED, Mt as PositionalSpec, N as Presentations, Nt as flag, O as PromptSurface, Ot as ArgsSpec, P as PresentedResult, Pt as positional, Q as validateSectionWithSchema, R as Tone, Rt as CredentialIdentity, S as defineServerCommand, St as PackageManagerId, T as CommandContext, Tt as PackageManagerRunner, U as StreamEvent, Ut as StoredSessions, V as EngineEvent, Vt as SERVICE_TOKEN_ENV_VAR, W as StreamMeta, Wt as CredentialRefreshResult, X as configSchema, Y as ConfigSchemaValue, Z as reference, _ as ServerCommandDefinition, _t as SpawnChild, a as RedirectSpec, at as InputStream, b as WorkflowStep, bt as SpawnedChild, c as CommandDefinition, ct as OutputStream, d as CommandNeeds, dt as TelemetryPayload, et as SectionProvenance, f as CompletedEnvelope, ft as EngineCommandSnapshot, g as NeedsSpec, gt as ExitWithChildStatusOptions, h as HelpSpec, ht as ChildStatusSettlement, i as MountedTree, it as HostProcess, j as Outcome, jt as FlagSpec, k as Block, kt as Char, l as CommandHandler, lt as PRISMA_CONFIG_VERSION, m as Handler, mt as ChildResult, n as CommandFamily, nt as resolveSectionPath, o as defineCommandFamily, ot as LoadedConfig, p as ErroredEnvelope, pt as RunSummary, q as defineConfigSection, qt as ManagementApiClientConfig, r as CommandRedirect, rt as Host, s as AnyCommand, st as LoadedConfigFile, t as TelemetryDeclaration, tt as resolveSectionOverChain, u as CommandHelp, ut as Runtime, v as SessionCommandDefinition, vt as SpawnOptions, w as BrowserWaitRequest, wt as PackageManagerRunResult, x as defineCommand, xt as exitWithChildStatus, y as SpawnDeclarations, yt as SpawnRequest, z as TreeNode, zt as CredentialManager } from "./report-B_8n69OY.js";
|
|
2
2
|
import { n as CliStructuredError } from "./protocol-YjqPCCOG.js";
|
|
3
3
|
|
|
4
4
|
//#region src/active-access-token.d.ts
|
|
@@ -225,4 +225,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
|
|
|
225
225
|
*/
|
|
226
226
|
declare function claimedIdentity(token: string): CredentialIdentity | undefined;
|
|
227
227
|
//#endregion
|
|
228
|
-
export { type ActiveAccessTokenOptions, 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 CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type LoadedConfigFile, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type ResolvedSection, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionProvenance, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, type WorkflowStep, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup };
|
|
228
|
+
export { type ActiveAccessTokenOptions, 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 ConfigSchema, type ConfigSchemaValue, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type LoadedConfigFile, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type ResolvedSection, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionProvenance, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, type WorkflowStep, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { i as ok, r as notOk, t as CliStructuredError } from "./protocol-TtNVkeVS.js";
|
|
2
|
-
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, O as emptyServiceTokenError, S as claimedIdentity, T as credentialRejectedError, _ as detectCI, a as definePrismaConfig, b as readActiveAccessToken, c as PRISMA_CONFIG_VERSION, d as PRESENTED, f as readUserConfig, g as exitWithChildStatus, h as resolveGating, k as noSessionForWorkspaceError, l as SERVICE_TOKEN_ENV_VAR, m as writeUserConfig, n as resolveSectionOverChain, o as loadConfig, p as userConfigPath, r as resolveSectionPath, s as realpathOr, t as buildEngine, u as WORKSPACE_ID_ENV_VAR, v as flag, w as authServiceError, x as claimedExpiresAt, y as positional } from "./engine-
|
|
2
|
+
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, O as emptyServiceTokenError, S as claimedIdentity, T as credentialRejectedError, _ as detectCI, a as definePrismaConfig, b as readActiveAccessToken, c as PRISMA_CONFIG_VERSION, d as PRESENTED, f as readUserConfig, g as exitWithChildStatus, h as resolveGating, k as noSessionForWorkspaceError, l as SERVICE_TOKEN_ENV_VAR, m as writeUserConfig, n as resolveSectionOverChain, o as loadConfig, p as userConfigPath, r as resolveSectionPath, s as realpathOr, t as buildEngine, u as WORKSPACE_ID_ENV_VAR, v as flag, w as authServiceError, x as claimedExpiresAt, y as positional } from "./engine-ChihWB8y.js";
|
|
3
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
4
|
+
import { scope, type } from "arktype";
|
|
3
5
|
//#region src/cli.ts
|
|
4
6
|
/**
|
|
5
7
|
* Shell-side construction. Group help is declared with the mount.
|
|
@@ -91,11 +93,222 @@ function defineServerCommand(def) {
|
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
95
|
//#endregion
|
|
96
|
+
//#region src/config-schema.ts
|
|
97
|
+
/**
|
|
98
|
+
* The section being validated, published for the duration of one
|
|
99
|
+
* synchronous schema run: its provenance, so the `path` keyword can resolve
|
|
100
|
+
* each value against the file that declared its top-level key, and the
|
|
101
|
+
* values the schema declared references, so the clone keeps them.
|
|
102
|
+
*/
|
|
103
|
+
let current;
|
|
104
|
+
/** The file that declared the top-level key a value sits under, else the nearest file. */
|
|
105
|
+
function declaringFile(provenance, path) {
|
|
106
|
+
const top = path[0];
|
|
107
|
+
return (typeof top === "string" ? provenance.keys[top] : void 0) ?? provenance.files[0];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A `path` value reaches this morph in two situations. During a section
|
|
111
|
+
* validation `current` names the provenance and the value resolves
|
|
112
|
+
* against the file that declared its top-level key. Outside one, arktype
|
|
113
|
+
* is evaluating a literal default while the schema is defined; a relative
|
|
114
|
+
* literal would be stored already resolved against nothing, so it is
|
|
115
|
+
* refused with the thunk form, which arktype evaluates and morphs at
|
|
116
|
+
* application time instead.
|
|
117
|
+
*/
|
|
118
|
+
function resolvePathValue(value, path) {
|
|
119
|
+
if (isAbsolute(value)) return value;
|
|
120
|
+
if (current === void 0) throw new Error(`@prisma/cli-engine: the relative 'path' default '${value}' must be declared as a thunk, ["path", "=", () => "..."], so it resolves against the config file when the default is applied`);
|
|
121
|
+
const file = declaringFile(current.provenance, path);
|
|
122
|
+
return file === void 0 ? value : resolve(dirname(file), value);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Declares the shape of a config section once. Definitions are arktype
|
|
126
|
+
* definitions with one extra keyword, `path`, for a field holding a path
|
|
127
|
+
* relative to the config file. The declaration drives validation, the
|
|
128
|
+
* diagnostics that name the field and the file to fix, and path
|
|
129
|
+
* resolution; nothing else has to know which fields are paths.
|
|
130
|
+
*
|
|
131
|
+
* ```ts
|
|
132
|
+
* const toySchema = configSchema({
|
|
133
|
+
* "out?": "path",
|
|
134
|
+
* "inputs?": "path[]",
|
|
135
|
+
* dir: ["path", "=", () => "./migrations"],
|
|
136
|
+
* greeting: "string = 'hello'",
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*
|
|
140
|
+
* A relative `path` default is declared as a thunk, as above: arktype
|
|
141
|
+
* evaluates a thunk when the default is applied, so it resolves against
|
|
142
|
+
* the config file like an authored value. A relative literal default is
|
|
143
|
+
* refused when the schema is defined.
|
|
144
|
+
*/
|
|
145
|
+
const configSchema = scope({
|
|
146
|
+
/**
|
|
147
|
+
* A string relative to the config file that wrote it. Validation turns it
|
|
148
|
+
* into an absolute path against that file's directory; an absolute value
|
|
149
|
+
* passes through unchanged.
|
|
150
|
+
*/
|
|
151
|
+
path: type("string").pipe((value, ctx) => resolvePathValue(value, ctx.path)) }, { clone: (original) => copyExceptReferences(original, current?.references, /* @__PURE__ */ new Map()) }).type;
|
|
152
|
+
function isPlainObject(value) {
|
|
153
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
154
|
+
const prototype = Object.getPrototypeOf(value);
|
|
155
|
+
return prototype === Object.prototype || prototype === null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Before arktype applies a morph it clones the value, so resolving a path or
|
|
159
|
+
* applying a default never writes into what the caller passed in. The scope
|
|
160
|
+
* above supplies the clone through arktype's `clone` option: it copies every
|
|
161
|
+
* value except the ones the schema declared with {@link reference}, which
|
|
162
|
+
* reach the command as the config file built them. `seen` carries the copies
|
|
163
|
+
* made so far, so a value that refers back to itself is copied once.
|
|
164
|
+
*/
|
|
165
|
+
function copyExceptReferences(value, references, seen) {
|
|
166
|
+
if (typeof value !== "object" || value === null || references?.has(value)) return value;
|
|
167
|
+
const copied = seen.get(value);
|
|
168
|
+
if (copied !== void 0) return copied;
|
|
169
|
+
if (Array.isArray(value)) {
|
|
170
|
+
const elements = [];
|
|
171
|
+
seen.set(value, elements);
|
|
172
|
+
for (const element of value) elements.push(copyExceptReferences(element, references, seen));
|
|
173
|
+
return elements;
|
|
174
|
+
}
|
|
175
|
+
const copy = Object.create(Object.getPrototypeOf(value));
|
|
176
|
+
seen.set(value, copy);
|
|
177
|
+
for (const key of Reflect.ownKeys(value)) copy[key] = copyExceptReferences(value[key], references, seen);
|
|
178
|
+
return copy;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Declares a value the config file constructs, such as a descriptor, a
|
|
182
|
+
* client or any class instance: validation checks it against `schema`, and
|
|
183
|
+
* the command receives the file's own object, never a copy. Every value not
|
|
184
|
+
* declared this way is copied before arktype writes into the section.
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* const toySchema = configSchema({
|
|
188
|
+
* target: reference(configSchema({ kind: "'target'", id: "string" })),
|
|
189
|
+
* "out?": "path",
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* `schema` cannot contain a `path` or a default: resolving one would write
|
|
194
|
+
* into the config file's own object, so such a schema is refused here.
|
|
195
|
+
*/
|
|
196
|
+
function reference(schema) {
|
|
197
|
+
if (schema.in.expression !== schema.expression) throw new Error(`@prisma/cli-engine: a reference cannot contain a path or a default, because resolving it would write into the config file's own object: ${schema.expression}`);
|
|
198
|
+
return schema.narrow((value) => {
|
|
199
|
+
if (typeof value === "object" && value !== null || typeof value === "function") current?.references.add(value);
|
|
200
|
+
return true;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function fieldDiagnostic(name, error, provenance) {
|
|
204
|
+
const field = error.path.map(String).join(".");
|
|
205
|
+
const file = declaringFile(provenance, error.path);
|
|
206
|
+
return {
|
|
207
|
+
code: "CLI.CONFIG_FIELD_INVALID",
|
|
208
|
+
severity: "error",
|
|
209
|
+
summary: `In the '${name}' section, ${error.message}`,
|
|
210
|
+
nextActions: [{
|
|
211
|
+
kind: "edit-file",
|
|
212
|
+
label: file === void 0 ? `Correct ${field === "" ? name : `${name}.${field}`} in prisma.config.ts` : `Correct ${field === "" ? name : `${name}.${field}`} in ${file}`
|
|
213
|
+
}],
|
|
214
|
+
...file === void 0 ? {} : { where: { path: file } },
|
|
215
|
+
meta: {
|
|
216
|
+
section: name,
|
|
217
|
+
field
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Validates one section's resolved value against its schema. An absent
|
|
223
|
+
* section is validated as an empty object, so a schema whose fields are
|
|
224
|
+
* all optional accepts it and a required field is reported by name. A
|
|
225
|
+
* plain-object value comes back frozen and carrying `baseDir`, the
|
|
226
|
+
* directory of the nearest file declaring the section, unless the whole
|
|
227
|
+
* section is a reference, which comes back as the file's own object. Never
|
|
228
|
+
* throws for
|
|
229
|
+
* any input: arktype reports problems as errors, and a `path` value is
|
|
230
|
+
* only ever resolved here.
|
|
231
|
+
*/
|
|
232
|
+
function validateSectionWithSchema(name, schema, raw, provenance) {
|
|
233
|
+
if (isPlainObject(raw) && Object.hasOwn(raw, "baseDir")) return {
|
|
234
|
+
ok: false,
|
|
235
|
+
diagnostics: [reservedKeyDiagnostic(name, "baseDir", provenance)]
|
|
236
|
+
};
|
|
237
|
+
const previous = current;
|
|
238
|
+
const references = /* @__PURE__ */ new WeakSet();
|
|
239
|
+
current = {
|
|
240
|
+
name,
|
|
241
|
+
provenance,
|
|
242
|
+
references
|
|
243
|
+
};
|
|
244
|
+
try {
|
|
245
|
+
const out = schema(raw === void 0 ? {} : raw);
|
|
246
|
+
if (out instanceof type.errors) return {
|
|
247
|
+
ok: false,
|
|
248
|
+
diagnostics: [...out].map((error) => fieldDiagnostic(name, error, provenance))
|
|
249
|
+
};
|
|
250
|
+
const nearest = provenance.files[0];
|
|
251
|
+
return {
|
|
252
|
+
ok: true,
|
|
253
|
+
value: isPlainObject(out) && nearest !== void 0 && !references.has(out) ? Object.freeze({
|
|
254
|
+
...out,
|
|
255
|
+
baseDir: dirname(nearest)
|
|
256
|
+
}) : out,
|
|
257
|
+
diagnostics: []
|
|
258
|
+
};
|
|
259
|
+
} catch (cause) {
|
|
260
|
+
return {
|
|
261
|
+
ok: false,
|
|
262
|
+
diagnostics: [unreadableDiagnostic(name, cause, provenance)]
|
|
263
|
+
};
|
|
264
|
+
} finally {
|
|
265
|
+
current = previous;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function reservedKeyDiagnostic(name, key, provenance) {
|
|
269
|
+
const file = provenance.keys[key] ?? provenance.files[0];
|
|
270
|
+
return {
|
|
271
|
+
code: "CLI.CONFIG_FIELD_INVALID",
|
|
272
|
+
severity: "error",
|
|
273
|
+
summary: `In the '${name}' section, ${key} is reserved: the CLI records it when the section is loaded`,
|
|
274
|
+
nextActions: [{
|
|
275
|
+
kind: "edit-file",
|
|
276
|
+
label: `Remove ${name}.${key} from ${file ?? "prisma.config.ts"}`
|
|
277
|
+
}],
|
|
278
|
+
...file === void 0 ? {} : { where: { path: file } },
|
|
279
|
+
meta: {
|
|
280
|
+
section: name,
|
|
281
|
+
field: key
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function unreadableDiagnostic(name, cause, provenance) {
|
|
286
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
287
|
+
const file = provenance.files[0];
|
|
288
|
+
return {
|
|
289
|
+
code: "CLI.CONFIG_FIELD_INVALID",
|
|
290
|
+
severity: "error",
|
|
291
|
+
summary: `The '${name}' section could not be validated: ${message.split("\n", 1)[0].trim()}`,
|
|
292
|
+
nextActions: [{
|
|
293
|
+
kind: "edit-file",
|
|
294
|
+
label: `Export a plain configuration object for '${name}' in ${file ?? "prisma.config.ts"}`
|
|
295
|
+
}],
|
|
296
|
+
...file === void 0 ? {} : { where: { path: file } },
|
|
297
|
+
meta: {
|
|
298
|
+
section: name,
|
|
299
|
+
field: ""
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
94
304
|
//#region src/config-section.ts
|
|
95
305
|
function defineConfigSection(spec) {
|
|
306
|
+
const schema = spec.schema;
|
|
307
|
+
const validate = schema === void 0 ? spec.validate : (raw, provenance) => validateSectionWithSchema(spec.name, schema, raw, provenance);
|
|
308
|
+
if (validate === void 0) throw new Error(`@prisma/cli-engine: config section '${spec.name}' declares neither a schema nor a validate function`);
|
|
96
309
|
return Object.freeze({
|
|
97
310
|
name: spec.name,
|
|
98
|
-
validate
|
|
311
|
+
validate,
|
|
99
312
|
merge: spec.merge
|
|
100
313
|
});
|
|
101
314
|
}
|
|
@@ -379,4 +592,4 @@ Telemetry is on by default (opt-out); see ${options.docsUrl}\nfor what is collec
|
|
|
379
592
|
};
|
|
380
593
|
}
|
|
381
594
|
//#endregion
|
|
382
|
-
export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup };
|
|
595
|
+
export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { i as NextAction, n as CliStructuredError, r as Diagnostic, s as Result } from "./protocol-YjqPCCOG.js";
|
|
2
|
+
import * as _$arktype from "arktype";
|
|
3
|
+
import { Type } from "arktype";
|
|
2
4
|
import { ManagementApiClient, TokenStorage } from "@prisma/management-api-sdk";
|
|
3
5
|
|
|
4
6
|
//#region src/management-api.d.ts
|
|
@@ -700,6 +702,12 @@ interface HostProcess {
|
|
|
700
702
|
readonly stdin: {
|
|
701
703
|
isTTY?: boolean;
|
|
702
704
|
setRawMode?(enabled: boolean): unknown;
|
|
705
|
+
/** Whether a stdin still being read keeps the process alive. The
|
|
706
|
+
* engine reads through the bin's adapter, which unrefs stdin once
|
|
707
|
+
* a run has finished prompting so an idle process can exit, and
|
|
708
|
+
* refs it again when the next run starts reading. */
|
|
709
|
+
ref?(): unknown;
|
|
710
|
+
unref?(): unknown;
|
|
703
711
|
[Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
|
|
704
712
|
};
|
|
705
713
|
on(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
|
|
@@ -794,6 +802,73 @@ declare function resolveSectionOverChain(section: ConfigSection<unknown>, files:
|
|
|
794
802
|
*/
|
|
795
803
|
declare function resolveSectionPath(provenance: SectionProvenance, key: string, path: string): string;
|
|
796
804
|
//#endregion
|
|
805
|
+
//#region src/config-schema.d.ts
|
|
806
|
+
declare const configScope: _$arktype.Scope<{
|
|
807
|
+
path: (In: string) => _$arktype.Out<string>;
|
|
808
|
+
}>;
|
|
809
|
+
/**
|
|
810
|
+
* Declares the shape of a config section once. Definitions are arktype
|
|
811
|
+
* definitions with one extra keyword, `path`, for a field holding a path
|
|
812
|
+
* relative to the config file. The declaration drives validation, the
|
|
813
|
+
* diagnostics that name the field and the file to fix, and path
|
|
814
|
+
* resolution; nothing else has to know which fields are paths.
|
|
815
|
+
*
|
|
816
|
+
* ```ts
|
|
817
|
+
* const toySchema = configSchema({
|
|
818
|
+
* "out?": "path",
|
|
819
|
+
* "inputs?": "path[]",
|
|
820
|
+
* dir: ["path", "=", () => "./migrations"],
|
|
821
|
+
* greeting: "string = 'hello'",
|
|
822
|
+
* });
|
|
823
|
+
* ```
|
|
824
|
+
*
|
|
825
|
+
* A relative `path` default is declared as a thunk, as above: arktype
|
|
826
|
+
* evaluates a thunk when the default is applied, so it resolves against
|
|
827
|
+
* the config file like an authored value. A relative literal default is
|
|
828
|
+
* refused when the schema is defined.
|
|
829
|
+
*/
|
|
830
|
+
declare const configSchema: typeof configScope.type;
|
|
831
|
+
type ConfigSchema<T = unknown> = Type<T, typeof configScope.t>;
|
|
832
|
+
/**
|
|
833
|
+
* The validated value a schema produces: its output type plus `baseDir`,
|
|
834
|
+
* the directory of the nearest file declaring the section, which the engine
|
|
835
|
+
* adds to a plain-object value that is not a {@link reference}. `baseDir`
|
|
836
|
+
* is reserved: a schema may not declare it and a config file may not write
|
|
837
|
+
* it.
|
|
838
|
+
*/
|
|
839
|
+
type ConfigSchemaValue<S extends ConfigSchema> = S["infer"] & {
|
|
840
|
+
readonly baseDir?: string;
|
|
841
|
+
};
|
|
842
|
+
/**
|
|
843
|
+
* Declares a value the config file constructs, such as a descriptor, a
|
|
844
|
+
* client or any class instance: validation checks it against `schema`, and
|
|
845
|
+
* the command receives the file's own object, never a copy. Every value not
|
|
846
|
+
* declared this way is copied before arktype writes into the section.
|
|
847
|
+
*
|
|
848
|
+
* ```ts
|
|
849
|
+
* const toySchema = configSchema({
|
|
850
|
+
* target: reference(configSchema({ kind: "'target'", id: "string" })),
|
|
851
|
+
* "out?": "path",
|
|
852
|
+
* });
|
|
853
|
+
* ```
|
|
854
|
+
*
|
|
855
|
+
* `schema` cannot contain a `path` or a default: resolving one would write
|
|
856
|
+
* into the config file's own object, so such a schema is refused here.
|
|
857
|
+
*/
|
|
858
|
+
declare function reference<S extends ConfigSchema>(schema: S): S;
|
|
859
|
+
/**
|
|
860
|
+
* Validates one section's resolved value against its schema. An absent
|
|
861
|
+
* section is validated as an empty object, so a schema whose fields are
|
|
862
|
+
* all optional accepts it and a required field is reported by name. A
|
|
863
|
+
* plain-object value comes back frozen and carrying `baseDir`, the
|
|
864
|
+
* directory of the nearest file declaring the section, unless the whole
|
|
865
|
+
* section is a reference, which comes back as the file's own object. Never
|
|
866
|
+
* throws for
|
|
867
|
+
* any input: arktype reports problems as errors, and a `path` value is
|
|
868
|
+
* only ever resolved here.
|
|
869
|
+
*/
|
|
870
|
+
declare function validateSectionWithSchema<S extends ConfigSchema>(name: string, schema: S, raw: unknown, provenance: SectionProvenance): SectionValidation<ConfigSchemaValue<S>>;
|
|
871
|
+
//#endregion
|
|
797
872
|
//#region src/config-section.d.ts
|
|
798
873
|
/**
|
|
799
874
|
* A command family's named slice of prisma.config.ts. The token couples
|
|
@@ -832,10 +907,24 @@ type SectionValidation<T> = {
|
|
|
832
907
|
readonly ok: false;
|
|
833
908
|
readonly diagnostics: readonly Diagnostic[];
|
|
834
909
|
};
|
|
910
|
+
type SectionValidator<T> = (raw: unknown | undefined, provenance: SectionProvenance) => SectionValidation<T>;
|
|
911
|
+
type SectionMerge = (parent: unknown, child: unknown) => unknown;
|
|
912
|
+
/**
|
|
913
|
+
* A section declared by its schema: validation, the diagnostics naming
|
|
914
|
+
* each bad field and the file to fix, and the resolution of every field
|
|
915
|
+
* declared `path` all derive from the one declaration (see configSchema).
|
|
916
|
+
* A section that needs logic a schema cannot express supplies `validate`
|
|
917
|
+
* instead; it then resolves its own path fields through resolveSectionPath.
|
|
918
|
+
*/
|
|
919
|
+
declare function defineConfigSection<S extends ConfigSchema>(spec: {
|
|
920
|
+
readonly name: string;
|
|
921
|
+
readonly schema: S;
|
|
922
|
+
readonly merge?: SectionMerge;
|
|
923
|
+
}): ConfigSection<ConfigSchemaValue<S>>;
|
|
835
924
|
declare function defineConfigSection<T>(spec: {
|
|
836
925
|
readonly name: string;
|
|
837
|
-
readonly validate:
|
|
838
|
-
readonly merge?:
|
|
926
|
+
readonly validate: SectionValidator<T>;
|
|
927
|
+
readonly merge?: SectionMerge;
|
|
839
928
|
}): ConfigSection<T>;
|
|
840
929
|
//#endregion
|
|
841
930
|
//#region src/events.d.ts
|
|
@@ -1270,10 +1359,10 @@ interface PromptSurface {
|
|
|
1270
1359
|
* `token` is the natural noun of what is being consented to — an app
|
|
1271
1360
|
* name, a hostname. Supplying one changes both halves of the prompt:
|
|
1272
1361
|
* interactively the user must type the token exactly instead of
|
|
1273
|
-
* answering yes/no, and
|
|
1274
|
-
*
|
|
1275
|
-
* consent). Without a token there is no
|
|
1276
|
-
* consent at all.
|
|
1362
|
+
* answering yes/no, and `--confirm <token>` on the command line grants
|
|
1363
|
+
* the consent up front in any session, so no prompt is shown (one
|
|
1364
|
+
* `--confirm` value per consent). Without a token there is no
|
|
1365
|
+
* non-interactive way to consent at all.
|
|
1277
1366
|
*/
|
|
1278
1367
|
readonly consent: (question: string, opts?: {
|
|
1279
1368
|
readonly token?: string;
|
|
@@ -1640,4 +1729,4 @@ interface TelemetryDeclaration {
|
|
|
1640
1729
|
readonly docsUrl: string;
|
|
1641
1730
|
}
|
|
1642
1731
|
//#endregion
|
|
1643
|
-
export {
|
|
1732
|
+
export { ResolvedSection as $, Format as A, CommandArgs as At, Ui as B, CredentialOrigin as Bt, defineSessionCommand as C, PackageManagerRunRequest as Ct, OpenUrlRequest as D, Args as Dt, OpenUrlOutcome as E, PackageOperations as Et, Span as F, ActiveAccessTokenOptions as Ft, ConfigSection as G, CredentialRefresher as Gt, Severity as H, Session as Ht, Status as I, ActiveCredential as It, ConfigSchema as J, TokenStorage$1 as Jt, SectionValidation as K, ManagementApiClient$1 as Kt, Text as L, Credential as Lt, PRESENTED as M, PositionalSpec as Mt, Presentations as N, flag as Nt, PromptSurface as O, ArgsSpec as Ot, PresentedResult as P, positional as Pt, validateSectionWithSchema as Q, Tone as R, CredentialIdentity as Rt, defineServerCommand as S, PackageManagerId as St, CommandContext as T, PackageManagerRunner as Tt, StreamEvent as U, StoredSessions as Ut, EngineEvent as V, SERVICE_TOKEN_ENV_VAR as Vt, StreamMeta as W, CredentialRefreshResult as Wt, configSchema as X, ConfigSchemaValue as Y, reference as Z, ServerCommandDefinition as _, SpawnChild as _t, RedirectSpec as a, InputStream as at, WorkflowStep as b, SpawnedChild as bt, CommandDefinition as c, OutputStream as ct, CommandNeeds as d, TelemetryPayload as dt, SectionProvenance as et, CompletedEnvelope as f, EngineCommandSnapshot as ft, NeedsSpec as g, ExitWithChildStatusOptions as gt, HelpSpec as h, ChildStatusSettlement as ht, MountedTree as i, HostProcess as it, Outcome as j, FlagSpec as jt, Block as k, Char as kt, CommandHandler as l, PRISMA_CONFIG_VERSION as lt, Handler as m, ChildResult as mt, CommandFamily as n, resolveSectionPath as nt, defineCommandFamily as o, LoadedConfig as ot, ErroredEnvelope as p, RunSummary as pt, defineConfigSection as q, ManagementApiClientConfig as qt, CommandRedirect as r, Host as rt, AnyCommand as s, LoadedConfigFile as st, TelemetryDeclaration as t, resolveSectionOverChain as tt, CommandHelp as u, Runtime as ut, SessionCommandDefinition as v, SpawnOptions as vt, BrowserWaitRequest as w, PackageManagerRunResult as wt, defineCommand as x, exitWithChildStatus as xt, SpawnDeclarations as y, SpawnRequest as yt, TreeNode as z, CredentialManager as zt };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ft as ActiveAccessTokenOptions, Gt as CredentialRefresher, Ht as Session, It as ActiveCredential, Jt as TokenStorage, Kt as ManagementApiClient, Lt as Credential, P as PresentedResult, St as PackageManagerId, Tt as PackageManagerRunner, U as StreamEvent, Ut as StoredSessions, V as EngineEvent, _t as SpawnChild, b as WorkflowStep, dt as TelemetryPayload, i as MountedTree, mt as ChildResult, n as CommandFamily, pt as RunSummary, qt as ManagementApiClientConfig, rt as Host, t as TelemetryDeclaration, ut as Runtime, yt as SpawnRequest, zt as CredentialManager } from "./report-B_8n69OY.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
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, S as claimedIdentity, b as readActiveAccessToken, k as noSessionForWorkspaceError, t as buildEngine, x as claimedExpiresAt } from "./engine-
|
|
1
|
+
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, S as claimedIdentity, b as readActiveAccessToken, k as noSessionForWorkspaceError, t as buildEngine, x as claimedExpiresAt } from "./engine-ChihWB8y.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
//#region src/in-memory-credential-manager.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/cli-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "The execution engine of the unified Prisma CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@clack/prompts": "1.5.0",
|
|
44
44
|
"@stricli/core": "1.3.0",
|
|
45
|
+
"arktype": "2.2.3",
|
|
45
46
|
"c12": "3.3.4",
|
|
46
47
|
"colorette": "^2.0.20",
|
|
47
48
|
"package-manager-detector": "1.8.0",
|
|
@@ -52,8 +53,8 @@
|
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@prisma/management-api-sdk": "1.69.0",
|
|
55
|
-
"@repo/cli-conformance": "8.0.0-rc.
|
|
56
|
-
"@repo/tsconfig": "8.0.0-rc.
|
|
56
|
+
"@repo/cli-conformance": "8.0.0-rc.16-dev.119",
|
|
57
|
+
"@repo/tsconfig": "8.0.0-rc.16-dev.119",
|
|
57
58
|
"@types/node": "^22.19.19",
|
|
58
59
|
"ci-info": "^4.3.1",
|
|
59
60
|
"tsdown": "^0.21.10",
|