@prisma/orm-toolchain 8.0.0-rc.9-dev.8 → 8.0.0-rc.9-dev.10
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/cli-telemetry.d.mts +6 -5
- package/dist/cli-telemetry.d.mts.map +1 -1
- package/dist/cli-telemetry.mjs +12 -11
- package/dist/cli-telemetry.mjs.map +1 -1
- package/dist/cli.mjs +12 -12
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__init-output.mjs +1 -1
- package/dist/{exports-abZ-M396.mjs → exports-CYa2di3d.mjs} +12 -7
- package/dist/exports-CYa2di3d.mjs.map +1 -0
- package/dist/{output-D87bBeOF-DWlKHmk9.mjs → output-D83nTTpC-XlvN30yS.mjs} +3 -3
- package/dist/{output-D87bBeOF-DWlKHmk9.mjs.map → output-D83nTTpC-XlvN30yS.mjs.map} +1 -1
- package/dist/readme-mongo.md +1 -1
- package/dist/readme-postgres.md +1 -1
- package/dist/vite-plugin-contract-emit.mjs +2 -2
- package/dist/vite-plugin-contract-emit.mjs.map +1 -1
- package/package.json +12 -12
- package/dist/exports-abZ-M396.mjs.map +0 -1
package/dist/cli-telemetry.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ declare const TELEMETRY_BACKEND_URL = "https://cmpbfbsdp09hr3jf7pojjs5qs.ewr.pri
|
|
|
11
11
|
declare const TELEMETRY_ENDPOINT_PATH = "/events";
|
|
12
12
|
/**
|
|
13
13
|
* Resolve the full POST URL the sender targets. The
|
|
14
|
-
* `
|
|
14
|
+
* `PRISMA_TELEMETRY_ENDPOINT` env var is an integration-testing
|
|
15
15
|
* affordance only — it lets the test suite spin up a mock HTTP server
|
|
16
16
|
* on an ephemeral port and point the spawned sender at it. The override
|
|
17
17
|
* is intentionally undocumented in user-facing material.
|
|
@@ -206,7 +206,7 @@ interface GatingInputs {
|
|
|
206
206
|
/**
|
|
207
207
|
* Environment-variable lookups the resolver consults. Tests pass a
|
|
208
208
|
* literal record; production passes `process.env`. The two opt-out
|
|
209
|
-
* signals are `
|
|
209
|
+
* signals are `PRISMA_DISABLE_TELEMETRY` (Prisma-specific) and
|
|
210
210
|
* `DO_NOT_TRACK` (community convention).
|
|
211
211
|
*/
|
|
212
212
|
readonly env: Readonly<Record<string, string | undefined>>;
|
|
@@ -219,7 +219,8 @@ interface GatingInputs {
|
|
|
219
219
|
* user config.
|
|
220
220
|
*
|
|
221
221
|
* Decision order:
|
|
222
|
-
* 1. Env-var override (`
|
|
222
|
+
* 1. Env-var override (`PRISMA_DISABLE_TELEMETRY` truthy, its
|
|
223
|
+
* `PRISMA_NEXT_DISABLE_TELEMETRY` spelling from earlier releases, or
|
|
223
224
|
* `DO_NOT_TRACK=1`) → disabled. The env check runs first, so an
|
|
224
225
|
* opt-out env var wins over any stored or unset preference.
|
|
225
226
|
* 2. Stored `enableTelemetry === false` → disabled (`stored-opt-out`).
|
|
@@ -253,7 +254,7 @@ interface CommanderResultShape {
|
|
|
253
254
|
/**
|
|
254
255
|
* The full command path from the root program to the leaf, including
|
|
255
256
|
* the root program name as the first element (the sanitiser drops it).
|
|
256
|
-
* Example: `['prisma
|
|
257
|
+
* Example: `['prisma', 'migration', 'new']`.
|
|
257
258
|
*/
|
|
258
259
|
readonly commandPath: readonly string[];
|
|
259
260
|
/**
|
|
@@ -355,7 +356,7 @@ interface RunTelemetryInputs {
|
|
|
355
356
|
* the fork runs in the background and never blocks the parent. Every
|
|
356
357
|
* failure mode is swallowed; the parent's stdout/stderr is untouched in
|
|
357
358
|
* normal operation, the only escape valve being
|
|
358
|
-
* `
|
|
359
|
+
* `PRISMA_DEBUG=1` which routes diagnostics to stderr.
|
|
359
360
|
*
|
|
360
361
|
* Returns the spawn outcome so debug-mode logging and the test-harness
|
|
361
362
|
* probe (which verifies test runs short-circuit the fork) can inspect
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-telemetry.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.d.mts"],"mappings":";;;;;;cAKc;;;;cAIA;;;;;;;;;;;;iBAYG,yBAAyB,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAgC/C;WACC;WACA;WACA;WACA;;;;;;;WAOA;;WAEA;;;;;;;;;;;WAWA;;;;;;;;WAQA;;;;;;UAMD;WACC;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;;UAUD;WACC;WACA;;;;;;;;;;;;;;;;iBAgBM,kBAAkB,sBAAsB,QAAQ;;;;;;;;;;;;;;UAcvD;WACC;WACA;YACC;;;;;;iBAMK;;;;;;iBAMA,kBAAkB;;;;;;;;;;;;;;;;iBAgBlB,gBAAgB,SAAS,QAAQ;;;;;;;;;;;iBAWjC;;;;;;;KAOZ;KACA;WACM;;WAEA;WACA,QAAQ;;UAET;;;;;;;WAOC,KAAK,SAAS;;WAEd,QAAQ
|
|
1
|
+
{"version":3,"file":"cli-telemetry.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.d.mts"],"mappings":";;;;;;cAKc;;;;cAIA;;;;;;;;;;;;iBAYG,yBAAyB,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAgC/C;WACC;WACA;WACA;WACA;;;;;;;WAOA;;WAEA;;;;;;;;;;;WAWA;;;;;;;;WAQA;;;;;;UAMD;WACC;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;;UAUD;WACC;WACA;;;;;;;;;;;;;;;;iBAgBM,kBAAkB,sBAAsB,QAAQ;;;;;;;;;;;;;;UAcvD;WACC;WACA;YACC;;;;;;iBAMK;;;;;;iBAMA,kBAAkB;;;;;;;;;;;;;;;;iBAgBlB,gBAAgB,SAAS,QAAQ;;;;;;;;;;;iBAWjC;;;;;;;KAOZ;KACA;WACM;;WAEA;WACA,QAAQ;;UAET;;;;;;;WAOC,KAAK,SAAS;;WAEd,QAAQ;;;;;;;;;;;;;;;;;;;;;;iBAsBF,cAAc,QAAQ,eAAe;;;UAG5C;;WAEC;;WAEA;;WAEA;;;;;;;;UAQD;;;;;;WAMC;;;;;;;WAOA;;;;;;;WAOA,kBAAkB;;;;;;;UAOnB;WACC;WACA;;;;;;;;;;;;;;;;;iBAiBM,wBAAwB,OAAO,uBAAuB;;;;;;;;;;;;;;;;;;;UAmB7D;;WAEC,SAAS;;WAET;;WAEA;;;;;;WAMA;;;;;WAKA;;;;;;;WAOA;;;;;;WAMA;;WAEA,MAAM,SAAS;;WAEf,aAAa;;;;;;;;;;;;;KAanB;WACM;;WAEA;WACA;;iBAEM,aAAa,QAAQ,qBAAqB;;;;;;;;iBAQ1C,gBAAgB"}
|
package/dist/cli-telemetry.mjs
CHANGED
|
@@ -65,7 +65,7 @@ const TELEMETRY_BACKEND_URL = "https://cmpbfbsdp09hr3jf7pojjs5qs.ewr.prisma.buil
|
|
|
65
65
|
const TELEMETRY_ENDPOINT_PATH = "/events";
|
|
66
66
|
/**
|
|
67
67
|
* Resolve the full POST URL the sender targets. The
|
|
68
|
-
* `
|
|
68
|
+
* `PRISMA_TELEMETRY_ENDPOINT` env var is an integration-testing
|
|
69
69
|
* affordance only — it lets the test suite spin up a mock HTTP server
|
|
70
70
|
* on an ephemeral port and point the spawned sender at it. The override
|
|
71
71
|
* is intentionally undocumented in user-facing material.
|
|
@@ -75,7 +75,7 @@ const TELEMETRY_ENDPOINT_PATH = "/events";
|
|
|
75
75
|
* matching the telemetry layer's broader silent-on-failure contract.
|
|
76
76
|
*/
|
|
77
77
|
function resolveTelemetryEndpoint(env = process.env) {
|
|
78
|
-
const override = env["
|
|
78
|
+
const override = env["PRISMA_TELEMETRY_ENDPOINT"];
|
|
79
79
|
const base = override !== void 0 && override.length > 0 ? override : TELEMETRY_BACKEND_URL;
|
|
80
80
|
try {
|
|
81
81
|
return new URL(TELEMETRY_ENDPOINT_PATH, base).toString();
|
|
@@ -84,7 +84,7 @@ function resolveTelemetryEndpoint(env = process.env) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
* A `
|
|
87
|
+
* A `PRISMA_DISABLE_TELEMETRY` value counts as an opt-out only if
|
|
88
88
|
* it parses as a truthy string. The set-but-falsy spellings (`''`,
|
|
89
89
|
* `'0'`, `'false'`) are intentionally treated as not-set so a parent
|
|
90
90
|
* shell that exports the variable to a benign value doesn't accidentally
|
|
@@ -104,7 +104,8 @@ function isTruthyOptOut(raw) {
|
|
|
104
104
|
* user config.
|
|
105
105
|
*
|
|
106
106
|
* Decision order:
|
|
107
|
-
* 1. Env-var override (`
|
|
107
|
+
* 1. Env-var override (`PRISMA_DISABLE_TELEMETRY` truthy, its
|
|
108
|
+
* `PRISMA_NEXT_DISABLE_TELEMETRY` spelling from earlier releases, or
|
|
108
109
|
* `DO_NOT_TRACK=1`) → disabled. The env check runs first, so an
|
|
109
110
|
* opt-out env var wins over any stored or unset preference.
|
|
110
111
|
* 2. Stored `enableTelemetry === false` → disabled (`stored-opt-out`).
|
|
@@ -118,7 +119,7 @@ function isTruthyOptOut(raw) {
|
|
|
118
119
|
* `enableTelemetry` is explicitly `false`.
|
|
119
120
|
*/
|
|
120
121
|
function resolveGating(inputs) {
|
|
121
|
-
if (isTruthyOptOut(inputs.env["PRISMA_NEXT_DISABLE_TELEMETRY"]) || inputs.env["DO_NOT_TRACK"] === "1") return {
|
|
122
|
+
if (isTruthyOptOut(inputs.env["PRISMA_DISABLE_TELEMETRY"]) || isTruthyOptOut(inputs.env["PRISMA_NEXT_DISABLE_TELEMETRY"]) || inputs.env["DO_NOT_TRACK"] === "1") return {
|
|
122
123
|
enabled: false,
|
|
123
124
|
reason: "env-override"
|
|
124
125
|
};
|
|
@@ -158,13 +159,13 @@ function sanitizeCommanderResult(input) {
|
|
|
158
159
|
})
|
|
159
160
|
};
|
|
160
161
|
}
|
|
161
|
-
const APP_DIR = "prisma-
|
|
162
|
+
const APP_DIR = "prisma-8";
|
|
162
163
|
const FILE_NAME = "config.json";
|
|
163
164
|
/**
|
|
164
165
|
* Resolves the user-level config directory:
|
|
165
|
-
* - Windows: `%APPDATA%\prisma-
|
|
166
|
-
* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-
|
|
167
|
-
* `$HOME/.config/prisma-
|
|
166
|
+
* - Windows: `%APPDATA%\prisma-8\` (fallback: `%USERPROFILE%\AppData\Roaming\prisma-8\`).
|
|
167
|
+
* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-8/` if set, else
|
|
168
|
+
* `$HOME/.config/prisma-8/` per the XDG Base Directory Specification.
|
|
168
169
|
*
|
|
169
170
|
* The spec deliberately picks XDG over the macOS-native
|
|
170
171
|
* `~/Library/Preferences/` convention so the path resolution is
|
|
@@ -296,13 +297,13 @@ function runTelemetry(inputs) {
|
|
|
296
297
|
]
|
|
297
298
|
});
|
|
298
299
|
child.send(payload, (err) => {
|
|
299
|
-
if (err !== null && process.env["
|
|
300
|
+
if (err !== null && process.env["PRISMA_DEBUG"] === "1") process.stderr.write(`[cli-telemetry] parent send error: ${String(err)}\n`);
|
|
300
301
|
});
|
|
301
302
|
child.disconnect();
|
|
302
303
|
child.unref();
|
|
303
304
|
return { spawned: true };
|
|
304
305
|
} catch (err) {
|
|
305
|
-
if (process.env["
|
|
306
|
+
if (process.env["PRISMA_DEBUG"] === "1") process.stderr.write(`[cli-telemetry] parent fork failed: ${String(err)}\n`);
|
|
306
307
|
return {
|
|
307
308
|
spawned: false,
|
|
308
309
|
reason: "fork-failed"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-telemetry.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/enrich-rd5g3THY.mjs","../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.mjs"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { determineAgent } from \"@vercel/detect-agent\";\nimport { join } from \"pathe\";\n//#region src/enrich.ts\nconst EMPTY_PROJECT_CONFIG = {\n\tdatabaseTarget: null,\n\textensions: []\n};\n/**\n* Best-effort load of `prisma.config.*` from `projectRoot`,\n* validated against the canonical `@internal/config` schema.\n* Returns `{ databaseTarget: null, extensions: [] }` on any failure\n* mode — missing config file (e.g. before `prisma orm init`), c12\n* throws while evaluating user TS, validator rejects a malformed\n* shape, etc. Telemetry is non-blocking and best-effort; an empty\n* result is the only downside of an unloadable or invalid config.\n*\n* Both `c12` and `@internal/config/config-validation` are imported\n* lazily so the detached sender's cold-start cost is paid only when\n* telemetry actually fires, not on every fork even when gates\n* short-circuit before reaching this code path.\n*/\nasync function loadProjectConfig(projectRoot) {\n\ttry {\n\t\tconst { loadConfig } = await import(\"c12\");\n\t\tconst load = (name) => loadConfig({\n\t\t\tname,\n\t\t\tcwd: projectRoot,\n\t\t\tdotenv: false,\n\t\t\trcFile: false,\n\t\t\tglobalRc: false\n\t\t});\n\t\tlet config = (await load(\"prisma\")).config ?? null;\n\t\tif (config === null || Object.keys(config).length === 0) return EMPTY_PROJECT_CONFIG;\n\t\tif (config[\"$prismaConfig\"] === void 0) return EMPTY_PROJECT_CONFIG;\n\t\tconst orm = config[\"orm\"];\n\t\tif (orm === null || typeof orm !== \"object\" || Array.isArray(orm)) return EMPTY_PROJECT_CONFIG;\n\t\tconfig = blindCast(orm);\n\t\tif ((await import(\"@internal/config/config-validation\")).collectConfigIssues(config).length > 0) return EMPTY_PROJECT_CONFIG;\n\t\tconst validConfig = blindCast(config);\n\t\treturn {\n\t\t\tdatabaseTarget: validConfig.target.targetId,\n\t\t\textensions: (validConfig.extensions ?? []).map((pack) => pack.id)\n\t\t};\n\t} catch {\n\t\treturn EMPTY_PROJECT_CONFIG;\n\t}\n}\n/**\n* Identify the runtime the sender is running in. Same-runtime as the\n* parent is a correctness requirement: the parent forked us via\n* `child_process.fork`, which inherits the parent's runtime. Detection\n* keys on the runtime-specific version field rather than env vars so a\n* spoofed env can't lie about the actual interpreter.\n*/\nfunction resolveRuntime(versions) {\n\tif (versions.bun !== void 0) return {\n\t\tname: \"bun\",\n\t\tversion: versions.bun\n\t};\n\tif (versions.deno !== void 0) return {\n\t\tname: \"deno\",\n\t\tversion: versions.deno\n\t};\n\treturn {\n\t\tname: \"node\",\n\t\tversion: versions.node\n\t};\n}\n/**\n* Parse `npm_config_user_agent` into a `<pm>/<version>` token. The\n* value, when present, looks like\n* `\"pnpm/10.27.0 npm/? node/v24.13.0 darwin arm64\"` — we take the first\n* whitespace-separated token. Any failure → `null`.\n*/\nfunction parsePackageManager(userAgent) {\n\tif (userAgent === void 0) return null;\n\tconst first = userAgent.split(/\\s+/)[0];\n\tif (first === void 0 || first.length === 0) return null;\n\tif (!first.includes(\"/\")) return null;\n\treturn first;\n}\n/**\n* Read the user's project `package.json` and resolve a TypeScript\n* version from `devDependencies.typescript` (preferred) or\n* `dependencies.typescript`. Strips a leading `^` or `~` semver\n* prefix. Returns `null` on any failure mode — file missing,\n* unreadable, malformed JSON, key absent, not a string.\n*/\nfunction readTsVersionFromPackageJson(raw) {\n\tif (raw === null) return null;\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n\tconst candidate = pickStringDep(parsed[\"devDependencies\"]) ?? pickStringDep(parsed[\"dependencies\"]);\n\tif (candidate === null) return null;\n\treturn candidate.replace(/^[\\^~]/, \"\");\n}\nfunction pickStringDep(deps) {\n\tif (deps === null || typeof deps !== \"object\" || Array.isArray(deps)) return null;\n\tconst value = deps[\"typescript\"];\n\treturn typeof value === \"string\" ? value : null;\n}\n/**\n* Build the full backend event from the parent's payload, the\n* c12-loaded project-config slice, and the child's per-process\n* snapshot. Pure given a `projectConfig` + `EnrichEnvironment`.\n*/\nfunction buildTelemetryEvent(payload, projectConfig, env) {\n\tconst runtime = resolveRuntime(env.versions);\n\treturn {\n\t\tinstallationId: payload.installationId,\n\t\tversion: payload.version,\n\t\tcommand: payload.command,\n\t\tflags: payload.flags,\n\t\truntimeName: runtime.name,\n\t\truntimeVersion: runtime.version,\n\t\tos: env.platform,\n\t\tarch: env.arch,\n\t\tpackageManager: parsePackageManager(env.env[\"npm_config_user_agent\"]),\n\t\tdatabaseTarget: projectConfig.databaseTarget,\n\t\ttsVersion: readTsVersionFromPackageJson(env.readProjectPackageJson()),\n\t\tagent: env.agent,\n\t\textensions: projectConfig.extensions,\n\t\texitCode: payload.exitCode ?? null\n\t};\n}\n/**\n* Resolve the agent label for the telemetry event via\n* `@vercel/detect-agent`, collapsing its discriminated result to the\n* event's `string | null` shape. Any detection failure counts as\n* \"no agent\" — telemetry is best-effort and non-blocking.\n*/\nasync function resolveAgentLabel() {\n\ttry {\n\t\tconst result = await determineAgent();\n\t\treturn result.isAgent ? result.agent.name : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Convenience for the sender entry: build the event from the live\n* `process` plus a c12 load of `prisma.config.*` from\n* `payload.projectRoot` plus a real project-package.json reader,\n* swallowing any I/O errors in the file read.\n*\n* The parent's `payload.databaseTarget` (when present) wins over the\n* c12-derived value. The parent sets this for the first-`init` run,\n* where the config file does not exist on disk yet but the user has\n* just declared a target via the consent prompt; every other\n* invocation leaves it unset and the c12 load supplies the value.\n*/\nasync function buildTelemetryEventFromProcess(payload) {\n\tconst loadedConfig = await loadProjectConfig(payload.projectRoot);\n\treturn buildTelemetryEvent(payload, {\n\t\tdatabaseTarget: payload.databaseTarget ?? loadedConfig.databaseTarget,\n\t\textensions: loadedConfig.extensions\n\t}, {\n\t\tplatform: process.platform,\n\t\tarch: process.arch,\n\t\tversions: process.versions,\n\t\tenv: process.env,\n\t\tagent: await resolveAgentLabel(),\n\t\treadProjectPackageJson: () => {\n\t\t\ttry {\n\t\t\t\treturn readFileSync(join(payload.projectRoot, \"package.json\"), \"utf-8\");\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t});\n}\n//#endregion\nexport { loadProjectConfig as n, buildTelemetryEventFromProcess as t };\n\n//# sourceMappingURL=enrich-rd5g3THY.mjs.map","import { n as loadProjectConfig } from \"../enrich-rd5g3THY.mjs\";\nimport { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"pathe\";\nimport { fork } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { randomUUID } from \"node:crypto\";\nimport { homedir } from \"node:os\";\n//#region src/endpoint.ts\n/**\n* Production endpoint pinned to the deployed Prisma Compute backend.\n* Compiled as a build-time constant; not user-configurable.\n*/\nconst TELEMETRY_BACKEND_URL = \"https://cmpbfbsdp09hr3jf7pojjs5qs.ewr.prisma.build\";\n/**\n* Path within the backend that accepts telemetry POSTs.\n*/\nconst TELEMETRY_ENDPOINT_PATH = \"/events\";\n/**\n* Resolve the full POST URL the sender targets. The\n* `PRISMA_NEXT_TELEMETRY_ENDPOINT` env var is an integration-testing\n* affordance only — it lets the test suite spin up a mock HTTP server\n* on an ephemeral port and point the spawned sender at it. The override\n* is intentionally undocumented in user-facing material.\n*\n* Fail-open: a malformed override (typo in a dev shell, bad CI config)\n* silently falls back to the production backend rather than throwing,\n* matching the telemetry layer's broader silent-on-failure contract.\n*/\nfunction resolveTelemetryEndpoint(env = process.env) {\n\tconst override = env[\"PRISMA_NEXT_TELEMETRY_ENDPOINT\"];\n\tconst base = override !== void 0 && override.length > 0 ? override : TELEMETRY_BACKEND_URL;\n\ttry {\n\t\treturn new URL(TELEMETRY_ENDPOINT_PATH, base).toString();\n\t} catch {\n\t\treturn new URL(TELEMETRY_ENDPOINT_PATH, TELEMETRY_BACKEND_URL).toString();\n\t}\n}\n//#endregion\n//#region src/gating.ts\n/**\n* A `PRISMA_NEXT_DISABLE_TELEMETRY` value counts as an opt-out only if\n* it parses as a truthy string. The set-but-falsy spellings (`''`,\n* `'0'`, `'false'`) are intentionally treated as not-set so a parent\n* shell that exports the variable to a benign value doesn't accidentally\n* disable telemetry for child processes.\n*/\nfunction isTruthyOptOut(raw) {\n\tif (raw === void 0) return false;\n\tconst normalised = raw.trim().toLowerCase();\n\tif (normalised === \"\") return false;\n\tif (normalised === \"0\") return false;\n\tif (normalised === \"false\") return false;\n\treturn true;\n}\n/**\n* Pure-function resolution of the gating decision. Same input → same\n* output; no I/O. The caller is responsible for reading the env and the\n* user config.\n*\n* Decision order:\n* 1. Env-var override (`PRISMA_NEXT_DISABLE_TELEMETRY` truthy, or\n* `DO_NOT_TRACK=1`) → disabled. The env check runs first, so an\n* opt-out env var wins over any stored or unset preference.\n* 2. Stored `enableTelemetry === false` → disabled (`stored-opt-out`).\n* 3. Stored `enableTelemetry === true` → enabled.\n* 4. Stored `enableTelemetry === undefined` (file missing, or field\n* not set) → ENABLED. This is the opt-out default: absence of an\n* explicit choice means telemetry is on. This is the load-bearing,\n* counter-intuitive branch — do not \"fix\" it to default-off.\n*\n* Telemetry is disabled only when an env override is active or\n* `enableTelemetry` is explicitly `false`.\n*/\nfunction resolveGating(inputs) {\n\tif (isTruthyOptOut(inputs.env[\"PRISMA_NEXT_DISABLE_TELEMETRY\"]) || inputs.env[\"DO_NOT_TRACK\"] === \"1\") return {\n\t\tenabled: false,\n\t\treason: \"env-override\"\n\t};\n\tif (inputs.config.enableTelemetry === false) return {\n\t\tenabled: false,\n\t\treason: \"stored-opt-out\"\n\t};\n\treturn { enabled: true };\n}\n//#endregion\n//#region src/sanitize.ts\nfunction flagNameFromLongName(longName) {\n\tif (longName === null || !longName.startsWith(\"--\")) return null;\n\tconst withoutPrefix = longName.slice(2);\n\treturn withoutPrefix.length > 0 ? withoutPrefix : null;\n}\n/**\n* Project commander's parsed result into the wire-shape command and\n* flag-name list. Pure; the only allowed inputs are the fields of\n* `CommanderResultShape`.\n*\n* Sanitiser contract — no flag values, no positionals, no raw argv:\n* - Drop the root program name (`commandPath[0]`); the wire ships\n* `migration new`, not `prisma migration new`.\n* - Emit only options whose Commander source is `cli`.\n* - Emit the long user-facing flag spelling without the `--` prefix;\n* never emit Commander's camelCase attribute names.\n* - `positionalArgs` is accepted but never consumed; the field exists\n* in the input type to make it obvious at the call site that\n* positionals were deliberately excluded.\n*/\nfunction sanitizeCommanderResult(input) {\n\treturn {\n\t\tcommand: input.commandPath.slice(1).join(\" \"),\n\t\tflags: input.options.flatMap((option) => {\n\t\t\tif (option.source !== \"cli\") return [];\n\t\t\tconst flagName = flagNameFromLongName(option.longName);\n\t\t\treturn flagName === null ? [] : [flagName];\n\t\t})\n\t};\n}\n//#endregion\n//#region src/user-config.ts\nconst APP_DIR = \"prisma-next\";\nconst FILE_NAME = \"config.json\";\n/**\n* Resolves the user-level config directory:\n* - Windows: `%APPDATA%\\prisma-next\\` (fallback: `%USERPROFILE%\\AppData\\Roaming\\prisma-next\\`).\n* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-next/` if set, else\n* `$HOME/.config/prisma-next/` per the XDG Base Directory Specification.\n*\n* The spec deliberately picks XDG over the macOS-native\n* `~/Library/Preferences/` convention so the path resolution is\n* test-overridable via `XDG_CONFIG_HOME` and matches the documented\n* behaviour on all *nix platforms. We intentionally do not use\n* `env-paths`: its macOS choice of `~/Library/Preferences` is for\n* OS-managed plist preferences, not arbitrary JSON files. Apple documents\n* that apps access that directory through system APIs such as\n* `NSUserDefaults`, while cross-platform CLI and developer tools conventionally\n* use `~/.config` on macOS too:\n* https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html\n*/\nfunction configDir() {\n\tif (process.platform === \"win32\") {\n\t\tconst appData = process.env[\"APPDATA\"];\n\t\tif (appData !== void 0 && appData.length > 0) return join(appData, APP_DIR);\n\t\treturn join(homedir(), \"AppData\", \"Roaming\", APP_DIR);\n\t}\n\tconst xdg = process.env[\"XDG_CONFIG_HOME\"];\n\tif (xdg !== void 0 && xdg.length > 0) return join(xdg, APP_DIR);\n\treturn join(homedir(), \".config\", APP_DIR);\n}\n/**\n* Path to the user-level config file. Resolved per call so test\n* harnesses can mutate `$XDG_CONFIG_HOME` between cases.\n*/\nfunction userConfigPath() {\n\treturn join(configDir(), FILE_NAME);\n}\n/**\n* Reads the user-level config. File-missing, unreadable, or malformed →\n* `{}` (the absence of consent is the same answer in every error mode).\n* Unknown fields from a future client are passed through verbatim.\n*/\nfunction readUserConfig() {\n\tconst path = userConfigPath();\n\tif (!existsSync(path)) return {};\n\ttry {\n\t\tconst raw = readFileSync(path, \"utf-8\");\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)) return parsed;\n\t\treturn {};\n\t} catch {\n\t\treturn {};\n\t}\n}\n/**\n* Merges `partial` into the current config and writes the result\n* atomically (temp file + rename) so a crash mid-write never leaves a\n* half-baked file readable on disk. Unknown fields already on disk are\n* preserved.\n*\n* When `partial.enableTelemetry === true` and no `installationId` is\n* stored yet, generates a v4 random UUID and persists both fields in\n* the same write. An existing `installationId` is never rotated. This is\n* the *explicit-consent* mint path: a `false` answer\n* (`writeUserConfig({ enableTelemetry: false })`) writes no id, and a bare\n* `writeUserConfig({ installationId })` mints nothing extra. The default-on\n* first-send path mints its id separately via {@link ensureInstallationId},\n* which records no consent answer.\n*/\nfunction writeUserConfig(partial) {\n\tconst merged = {\n\t\t...readUserConfig(),\n\t\t...partial\n\t};\n\tif (partial.enableTelemetry === true && merged[\"installationId\"] === void 0) merged[\"installationId\"] = randomUUID();\n\tconst path = userConfigPath();\n\tconst dir = dirname(path);\n\tif (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n\tconst tmpPath = `${path}.${process.pid}.tmp`;\n\twriteFileSync(tmpPath, `${JSON.stringify(merged, null, 2)}\\n`, \"utf-8\");\n\trenameSync(tmpPath, path);\n}\n/**\n* Returns the stored `installationId`, minting and persisting a fresh v4\n* UUID when none exists yet. Crucially, this persists *only* the id —\n* `enableTelemetry` is left untouched (stays `undefined` on a default-on\n* first run), so the interactive `init` consent prompt is not wrongly\n* suppressed and no explicit consent the user never gave is recorded.\n*\n* Used by the default-on first-run fire path: the gate has already\n* resolved enabled, so this only ever runs when telemetry is on.\n*/\nfunction ensureInstallationId() {\n\tconst existing = readUserConfig().installationId;\n\tif (typeof existing === \"string\" && existing.length > 0) return existing;\n\tconst installationId = randomUUID();\n\twriteUserConfig({ installationId });\n\treturn installationId;\n}\n//#endregion\n//#region src/spawn.ts\nfunction runTelemetry(inputs) {\n\tconst env = inputs.env ?? process.env;\n\tif (inputs.isCI) return {\n\t\tspawned: false,\n\t\treason: \"ci\"\n\t};\n\tconst config = inputs.userConfig ?? readUserConfig();\n\tif (!resolveGating({\n\t\tenv,\n\t\tconfig\n\t}).enabled) return {\n\t\tspawned: false,\n\t\treason: \"gated-off\"\n\t};\n\tconst sanitised = sanitizeCommanderResult(inputs.command);\n\tif (typeof config.installationId !== \"string\" || config.installationId.length === 0) return {\n\t\tspawned: false,\n\t\treason: \"gated-off\"\n\t};\n\tconst payload = {\n\t\tinstallationId: config.installationId,\n\t\tversion: inputs.version,\n\t\tcommand: sanitised.command,\n\t\tflags: sanitised.flags,\n\t\tprojectRoot: inputs.projectRoot,\n\t\tendpoint: resolveTelemetryEndpoint(env),\n\t\t...ifDefined(\"databaseTarget\", inputs.databaseTarget),\n\t\t...ifDefined(\"exitCode\", inputs.exitCode)\n\t};\n\ttry {\n\t\tconst child = fork(inputs.senderPath, [], {\n\t\t\tdetached: true,\n\t\t\tstdio: [\n\t\t\t\t\"pipe\",\n\t\t\t\t\"ignore\",\n\t\t\t\t\"ignore\",\n\t\t\t\t\"ipc\"\n\t\t\t]\n\t\t});\n\t\tchild.send(payload, (err) => {\n\t\t\tif (err !== null && process.env[\"PRISMA_NEXT_DEBUG\"] === \"1\") process.stderr.write(`[cli-telemetry] parent send error: ${String(err)}\\n`);\n\t\t});\n\t\tchild.disconnect();\n\t\tchild.unref();\n\t\treturn { spawned: true };\n\t} catch (err) {\n\t\tif (process.env[\"PRISMA_NEXT_DEBUG\"] === \"1\") process.stderr.write(`[cli-telemetry] parent fork failed: ${String(err)}\\n`);\n\t\treturn {\n\t\t\tspawned: false,\n\t\t\treason: \"fork-failed\"\n\t\t};\n\t}\n}\n/**\n* Resolve the path to the compiled sender entry relative to a consumer\n* that has captured its own `import.meta.url`. The CLI's\n* `tsdown`-emitted entry sits at `<package>/dist/sender.mjs`; the\n* consumer asks `senderModuleUrl()` and forwards the result to\n* `runTelemetry({ senderPath })`.\n*/\nfunction senderModuleUrl(importMetaUrl) {\n\treturn fileURLToPath(new URL(\"./sender.mjs\", importMetaUrl));\n}\n//#endregion\nexport { TELEMETRY_BACKEND_URL, TELEMETRY_ENDPOINT_PATH, ensureInstallationId, loadProjectConfig, readUserConfig, resolveGating, resolveTelemetryEndpoint, runTelemetry, sanitizeCommanderResult, senderModuleUrl, userConfigPath, writeUserConfig };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;AAKA,MAAM,uBAAuB;CAC5B,gBAAgB;CAChB,YAAY,CAAC;AACd;;;;;;;;;;;;;;;AAeA,eAAe,kBAAkB,aAAa;CAC7C,IAAI;EACH,MAAM,EAAE,eAAe,MAAM,OAAO;EACpC,MAAM,QAAQ,SAAS,WAAW;GACjC;GACA,KAAK;GACL,QAAQ;GACR,QAAQ;GACR,UAAU;EACX,CAAC;EACD,IAAI,UAAU,MAAM,KAAK,QAAQ,EAAA,CAAG,UAAU;EAC9C,IAAI,WAAW,QAAQ,OAAO,KAAK,MAAM,CAAC,CAAC,WAAW,GAAG,OAAO;EAChE,IAAI,OAAO,qBAAqB,KAAK,GAAG,OAAO;EAC/C,MAAM,MAAM,OAAO;EACnB,IAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GAAG,OAAO;EAC1E,SAAS,UAAU,GAAG;EACtB,KAAK,MAAM,OAAO,kDAAA,CAAuC,oBAAoB,MAAM,CAAC,CAAC,SAAS,GAAG,OAAO;EACxG,MAAM,cAAc,U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QAAQ;GAC5B,IAAI,QAAQ,QAAQ,QAAQ,IAAI,yBAAyB,KAAK,QAAQ,OAAO,MAAM,sCAAsC,OAAO,GAAG,EAAE,GAAG;EACzI,CAAC;EACD,MAAM,WAAW;EACjB,MAAM,MAAM;EACZ,OAAO,EAAE,SAAS,KAAK;CACxB,SAAS,KAAK;EACb,IAAI,QAAQ,IAAI,yBAAyB,KAAK,QAAQ,OAAO,MAAM,uCAAuC,OAAO,GAAG,EAAE,GAAG;EACzH,OAAO;GACN,SAAS;GACT,QAAQ;EACT;CACD;AACD;;;;;;;;AAQA,SAAS,gBAAgB,eAAe;CACvC,OAAO,cAAc,IAAI,IAAI,gBAAgB,aAAa,CAAC;AAC5D"}
|
|
1
|
+
{"version":3,"file":"cli-telemetry.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/enrich-rd5g3THY.mjs","../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.mjs"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { determineAgent } from \"@vercel/detect-agent\";\nimport { join } from \"pathe\";\n//#region src/enrich.ts\nconst EMPTY_PROJECT_CONFIG = {\n\tdatabaseTarget: null,\n\textensions: []\n};\n/**\n* Best-effort load of `prisma.config.*` from `projectRoot`,\n* validated against the canonical `@internal/config` schema.\n* Returns `{ databaseTarget: null, extensions: [] }` on any failure\n* mode — missing config file (e.g. before `prisma orm init`), c12\n* throws while evaluating user TS, validator rejects a malformed\n* shape, etc. Telemetry is non-blocking and best-effort; an empty\n* result is the only downside of an unloadable or invalid config.\n*\n* Both `c12` and `@internal/config/config-validation` are imported\n* lazily so the detached sender's cold-start cost is paid only when\n* telemetry actually fires, not on every fork even when gates\n* short-circuit before reaching this code path.\n*/\nasync function loadProjectConfig(projectRoot) {\n\ttry {\n\t\tconst { loadConfig } = await import(\"c12\");\n\t\tconst load = (name) => loadConfig({\n\t\t\tname,\n\t\t\tcwd: projectRoot,\n\t\t\tdotenv: false,\n\t\t\trcFile: false,\n\t\t\tglobalRc: false\n\t\t});\n\t\tlet config = (await load(\"prisma\")).config ?? null;\n\t\tif (config === null || Object.keys(config).length === 0) return EMPTY_PROJECT_CONFIG;\n\t\tif (config[\"$prismaConfig\"] === void 0) return EMPTY_PROJECT_CONFIG;\n\t\tconst orm = config[\"orm\"];\n\t\tif (orm === null || typeof orm !== \"object\" || Array.isArray(orm)) return EMPTY_PROJECT_CONFIG;\n\t\tconfig = blindCast(orm);\n\t\tif ((await import(\"@internal/config/config-validation\")).collectConfigIssues(config).length > 0) return EMPTY_PROJECT_CONFIG;\n\t\tconst validConfig = blindCast(config);\n\t\treturn {\n\t\t\tdatabaseTarget: validConfig.target.targetId,\n\t\t\textensions: (validConfig.extensions ?? []).map((pack) => pack.id)\n\t\t};\n\t} catch {\n\t\treturn EMPTY_PROJECT_CONFIG;\n\t}\n}\n/**\n* Identify the runtime the sender is running in. Same-runtime as the\n* parent is a correctness requirement: the parent forked us via\n* `child_process.fork`, which inherits the parent's runtime. Detection\n* keys on the runtime-specific version field rather than env vars so a\n* spoofed env can't lie about the actual interpreter.\n*/\nfunction resolveRuntime(versions) {\n\tif (versions.bun !== void 0) return {\n\t\tname: \"bun\",\n\t\tversion: versions.bun\n\t};\n\tif (versions.deno !== void 0) return {\n\t\tname: \"deno\",\n\t\tversion: versions.deno\n\t};\n\treturn {\n\t\tname: \"node\",\n\t\tversion: versions.node\n\t};\n}\n/**\n* Parse `npm_config_user_agent` into a `<pm>/<version>` token. The\n* value, when present, looks like\n* `\"pnpm/10.27.0 npm/? node/v24.13.0 darwin arm64\"` — we take the first\n* whitespace-separated token. Any failure → `null`.\n*/\nfunction parsePackageManager(userAgent) {\n\tif (userAgent === void 0) return null;\n\tconst first = userAgent.split(/\\s+/)[0];\n\tif (first === void 0 || first.length === 0) return null;\n\tif (!first.includes(\"/\")) return null;\n\treturn first;\n}\n/**\n* Read the user's project `package.json` and resolve a TypeScript\n* version from `devDependencies.typescript` (preferred) or\n* `dependencies.typescript`. Strips a leading `^` or `~` semver\n* prefix. Returns `null` on any failure mode — file missing,\n* unreadable, malformed JSON, key absent, not a string.\n*/\nfunction readTsVersionFromPackageJson(raw) {\n\tif (raw === null) return null;\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n\tconst candidate = pickStringDep(parsed[\"devDependencies\"]) ?? pickStringDep(parsed[\"dependencies\"]);\n\tif (candidate === null) return null;\n\treturn candidate.replace(/^[\\^~]/, \"\");\n}\nfunction pickStringDep(deps) {\n\tif (deps === null || typeof deps !== \"object\" || Array.isArray(deps)) return null;\n\tconst value = deps[\"typescript\"];\n\treturn typeof value === \"string\" ? value : null;\n}\n/**\n* Build the full backend event from the parent's payload, the\n* c12-loaded project-config slice, and the child's per-process\n* snapshot. Pure given a `projectConfig` + `EnrichEnvironment`.\n*/\nfunction buildTelemetryEvent(payload, projectConfig, env) {\n\tconst runtime = resolveRuntime(env.versions);\n\treturn {\n\t\tinstallationId: payload.installationId,\n\t\tversion: payload.version,\n\t\tcommand: payload.command,\n\t\tflags: payload.flags,\n\t\truntimeName: runtime.name,\n\t\truntimeVersion: runtime.version,\n\t\tos: env.platform,\n\t\tarch: env.arch,\n\t\tpackageManager: parsePackageManager(env.env[\"npm_config_user_agent\"]),\n\t\tdatabaseTarget: projectConfig.databaseTarget,\n\t\ttsVersion: readTsVersionFromPackageJson(env.readProjectPackageJson()),\n\t\tagent: env.agent,\n\t\textensions: projectConfig.extensions,\n\t\texitCode: payload.exitCode ?? null\n\t};\n}\n/**\n* Resolve the agent label for the telemetry event via\n* `@vercel/detect-agent`, collapsing its discriminated result to the\n* event's `string | null` shape. Any detection failure counts as\n* \"no agent\" — telemetry is best-effort and non-blocking.\n*/\nasync function resolveAgentLabel() {\n\ttry {\n\t\tconst result = await determineAgent();\n\t\treturn result.isAgent ? result.agent.name : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Convenience for the sender entry: build the event from the live\n* `process` plus a c12 load of `prisma.config.*` from\n* `payload.projectRoot` plus a real project-package.json reader,\n* swallowing any I/O errors in the file read.\n*\n* The parent's `payload.databaseTarget` (when present) wins over the\n* c12-derived value. The parent sets this for the first-`init` run,\n* where the config file does not exist on disk yet but the user has\n* just declared a target via the consent prompt; every other\n* invocation leaves it unset and the c12 load supplies the value.\n*/\nasync function buildTelemetryEventFromProcess(payload) {\n\tconst loadedConfig = await loadProjectConfig(payload.projectRoot);\n\treturn buildTelemetryEvent(payload, {\n\t\tdatabaseTarget: payload.databaseTarget ?? loadedConfig.databaseTarget,\n\t\textensions: loadedConfig.extensions\n\t}, {\n\t\tplatform: process.platform,\n\t\tarch: process.arch,\n\t\tversions: process.versions,\n\t\tenv: process.env,\n\t\tagent: await resolveAgentLabel(),\n\t\treadProjectPackageJson: () => {\n\t\t\ttry {\n\t\t\t\treturn readFileSync(join(payload.projectRoot, \"package.json\"), \"utf-8\");\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t});\n}\n//#endregion\nexport { loadProjectConfig as n, buildTelemetryEventFromProcess as t };\n\n//# sourceMappingURL=enrich-rd5g3THY.mjs.map","import { n as loadProjectConfig } from \"../enrich-rd5g3THY.mjs\";\nimport { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"pathe\";\nimport { fork } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { randomUUID } from \"node:crypto\";\nimport { homedir } from \"node:os\";\n//#region src/endpoint.ts\n/**\n* Production endpoint pinned to the deployed Prisma Compute backend.\n* Compiled as a build-time constant; not user-configurable.\n*/\nconst TELEMETRY_BACKEND_URL = \"https://cmpbfbsdp09hr3jf7pojjs5qs.ewr.prisma.build\";\n/**\n* Path within the backend that accepts telemetry POSTs.\n*/\nconst TELEMETRY_ENDPOINT_PATH = \"/events\";\n/**\n* Resolve the full POST URL the sender targets. The\n* `PRISMA_TELEMETRY_ENDPOINT` env var is an integration-testing\n* affordance only — it lets the test suite spin up a mock HTTP server\n* on an ephemeral port and point the spawned sender at it. The override\n* is intentionally undocumented in user-facing material.\n*\n* Fail-open: a malformed override (typo in a dev shell, bad CI config)\n* silently falls back to the production backend rather than throwing,\n* matching the telemetry layer's broader silent-on-failure contract.\n*/\nfunction resolveTelemetryEndpoint(env = process.env) {\n\tconst override = env[\"PRISMA_TELEMETRY_ENDPOINT\"];\n\tconst base = override !== void 0 && override.length > 0 ? override : TELEMETRY_BACKEND_URL;\n\ttry {\n\t\treturn new URL(TELEMETRY_ENDPOINT_PATH, base).toString();\n\t} catch {\n\t\treturn new URL(TELEMETRY_ENDPOINT_PATH, TELEMETRY_BACKEND_URL).toString();\n\t}\n}\n//#endregion\n//#region src/gating.ts\n/**\n* A `PRISMA_DISABLE_TELEMETRY` value counts as an opt-out only if\n* it parses as a truthy string. The set-but-falsy spellings (`''`,\n* `'0'`, `'false'`) are intentionally treated as not-set so a parent\n* shell that exports the variable to a benign value doesn't accidentally\n* disable telemetry for child processes.\n*/\nfunction isTruthyOptOut(raw) {\n\tif (raw === void 0) return false;\n\tconst normalised = raw.trim().toLowerCase();\n\tif (normalised === \"\") return false;\n\tif (normalised === \"0\") return false;\n\tif (normalised === \"false\") return false;\n\treturn true;\n}\n/**\n* Pure-function resolution of the gating decision. Same input → same\n* output; no I/O. The caller is responsible for reading the env and the\n* user config.\n*\n* Decision order:\n* 1. Env-var override (`PRISMA_DISABLE_TELEMETRY` truthy, its\n* `PRISMA_NEXT_DISABLE_TELEMETRY` spelling from earlier releases, or\n* `DO_NOT_TRACK=1`) → disabled. The env check runs first, so an\n* opt-out env var wins over any stored or unset preference.\n* 2. Stored `enableTelemetry === false` → disabled (`stored-opt-out`).\n* 3. Stored `enableTelemetry === true` → enabled.\n* 4. Stored `enableTelemetry === undefined` (file missing, or field\n* not set) → ENABLED. This is the opt-out default: absence of an\n* explicit choice means telemetry is on. This is the load-bearing,\n* counter-intuitive branch — do not \"fix\" it to default-off.\n*\n* Telemetry is disabled only when an env override is active or\n* `enableTelemetry` is explicitly `false`.\n*/\nfunction resolveGating(inputs) {\n\tif (isTruthyOptOut(inputs.env[\"PRISMA_DISABLE_TELEMETRY\"]) || isTruthyOptOut(inputs.env[\"PRISMA_NEXT_DISABLE_TELEMETRY\"]) || inputs.env[\"DO_NOT_TRACK\"] === \"1\") return {\n\t\tenabled: false,\n\t\treason: \"env-override\"\n\t};\n\tif (inputs.config.enableTelemetry === false) return {\n\t\tenabled: false,\n\t\treason: \"stored-opt-out\"\n\t};\n\treturn { enabled: true };\n}\n//#endregion\n//#region src/sanitize.ts\nfunction flagNameFromLongName(longName) {\n\tif (longName === null || !longName.startsWith(\"--\")) return null;\n\tconst withoutPrefix = longName.slice(2);\n\treturn withoutPrefix.length > 0 ? withoutPrefix : null;\n}\n/**\n* Project commander's parsed result into the wire-shape command and\n* flag-name list. Pure; the only allowed inputs are the fields of\n* `CommanderResultShape`.\n*\n* Sanitiser contract — no flag values, no positionals, no raw argv:\n* - Drop the root program name (`commandPath[0]`); the wire ships\n* `migration new`, not `prisma migration new`.\n* - Emit only options whose Commander source is `cli`.\n* - Emit the long user-facing flag spelling without the `--` prefix;\n* never emit Commander's camelCase attribute names.\n* - `positionalArgs` is accepted but never consumed; the field exists\n* in the input type to make it obvious at the call site that\n* positionals were deliberately excluded.\n*/\nfunction sanitizeCommanderResult(input) {\n\treturn {\n\t\tcommand: input.commandPath.slice(1).join(\" \"),\n\t\tflags: input.options.flatMap((option) => {\n\t\t\tif (option.source !== \"cli\") return [];\n\t\t\tconst flagName = flagNameFromLongName(option.longName);\n\t\t\treturn flagName === null ? [] : [flagName];\n\t\t})\n\t};\n}\n//#endregion\n//#region src/user-config.ts\nconst APP_DIR = \"prisma-8\";\nconst FILE_NAME = \"config.json\";\n/**\n* Resolves the user-level config directory:\n* - Windows: `%APPDATA%\\prisma-8\\` (fallback: `%USERPROFILE%\\AppData\\Roaming\\prisma-8\\`).\n* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-8/` if set, else\n* `$HOME/.config/prisma-8/` per the XDG Base Directory Specification.\n*\n* The spec deliberately picks XDG over the macOS-native\n* `~/Library/Preferences/` convention so the path resolution is\n* test-overridable via `XDG_CONFIG_HOME` and matches the documented\n* behaviour on all *nix platforms. We intentionally do not use\n* `env-paths`: its macOS choice of `~/Library/Preferences` is for\n* OS-managed plist preferences, not arbitrary JSON files. Apple documents\n* that apps access that directory through system APIs such as\n* `NSUserDefaults`, while cross-platform CLI and developer tools conventionally\n* use `~/.config` on macOS too:\n* https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html\n*/\nfunction configDir() {\n\tif (process.platform === \"win32\") {\n\t\tconst appData = process.env[\"APPDATA\"];\n\t\tif (appData !== void 0 && appData.length > 0) return join(appData, APP_DIR);\n\t\treturn join(homedir(), \"AppData\", \"Roaming\", APP_DIR);\n\t}\n\tconst xdg = process.env[\"XDG_CONFIG_HOME\"];\n\tif (xdg !== void 0 && xdg.length > 0) return join(xdg, APP_DIR);\n\treturn join(homedir(), \".config\", APP_DIR);\n}\n/**\n* Path to the user-level config file. Resolved per call so test\n* harnesses can mutate `$XDG_CONFIG_HOME` between cases.\n*/\nfunction userConfigPath() {\n\treturn join(configDir(), FILE_NAME);\n}\n/**\n* Reads the user-level config. File-missing, unreadable, or malformed →\n* `{}` (the absence of consent is the same answer in every error mode).\n* Unknown fields from a future client are passed through verbatim.\n*/\nfunction readUserConfig() {\n\tconst path = userConfigPath();\n\tif (!existsSync(path)) return {};\n\ttry {\n\t\tconst raw = readFileSync(path, \"utf-8\");\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)) return parsed;\n\t\treturn {};\n\t} catch {\n\t\treturn {};\n\t}\n}\n/**\n* Merges `partial` into the current config and writes the result\n* atomically (temp file + rename) so a crash mid-write never leaves a\n* half-baked file readable on disk. Unknown fields already on disk are\n* preserved.\n*\n* When `partial.enableTelemetry === true` and no `installationId` is\n* stored yet, generates a v4 random UUID and persists both fields in\n* the same write. An existing `installationId` is never rotated. This is\n* the *explicit-consent* mint path: a `false` answer\n* (`writeUserConfig({ enableTelemetry: false })`) writes no id, and a bare\n* `writeUserConfig({ installationId })` mints nothing extra. The default-on\n* first-send path mints its id separately via {@link ensureInstallationId},\n* which records no consent answer.\n*/\nfunction writeUserConfig(partial) {\n\tconst merged = {\n\t\t...readUserConfig(),\n\t\t...partial\n\t};\n\tif (partial.enableTelemetry === true && merged[\"installationId\"] === void 0) merged[\"installationId\"] = randomUUID();\n\tconst path = userConfigPath();\n\tconst dir = dirname(path);\n\tif (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n\tconst tmpPath = `${path}.${process.pid}.tmp`;\n\twriteFileSync(tmpPath, `${JSON.stringify(merged, null, 2)}\\n`, \"utf-8\");\n\trenameSync(tmpPath, path);\n}\n/**\n* Returns the stored `installationId`, minting and persisting a fresh v4\n* UUID when none exists yet. Crucially, this persists *only* the id —\n* `enableTelemetry` is left untouched (stays `undefined` on a default-on\n* first run), so the interactive `init` consent prompt is not wrongly\n* suppressed and no explicit consent the user never gave is recorded.\n*\n* Used by the default-on first-run fire path: the gate has already\n* resolved enabled, so this only ever runs when telemetry is on.\n*/\nfunction ensureInstallationId() {\n\tconst existing = readUserConfig().installationId;\n\tif (typeof existing === \"string\" && existing.length > 0) return existing;\n\tconst installationId = randomUUID();\n\twriteUserConfig({ installationId });\n\treturn installationId;\n}\n//#endregion\n//#region src/spawn.ts\nfunction runTelemetry(inputs) {\n\tconst env = inputs.env ?? process.env;\n\tif (inputs.isCI) return {\n\t\tspawned: false,\n\t\treason: \"ci\"\n\t};\n\tconst config = inputs.userConfig ?? readUserConfig();\n\tif (!resolveGating({\n\t\tenv,\n\t\tconfig\n\t}).enabled) return {\n\t\tspawned: false,\n\t\treason: \"gated-off\"\n\t};\n\tconst sanitised = sanitizeCommanderResult(inputs.command);\n\tif (typeof config.installationId !== \"string\" || config.installationId.length === 0) return {\n\t\tspawned: false,\n\t\treason: \"gated-off\"\n\t};\n\tconst payload = {\n\t\tinstallationId: config.installationId,\n\t\tversion: inputs.version,\n\t\tcommand: sanitised.command,\n\t\tflags: sanitised.flags,\n\t\tprojectRoot: inputs.projectRoot,\n\t\tendpoint: resolveTelemetryEndpoint(env),\n\t\t...ifDefined(\"databaseTarget\", inputs.databaseTarget),\n\t\t...ifDefined(\"exitCode\", inputs.exitCode)\n\t};\n\ttry {\n\t\tconst child = fork(inputs.senderPath, [], {\n\t\t\tdetached: true,\n\t\t\tstdio: [\n\t\t\t\t\"pipe\",\n\t\t\t\t\"ignore\",\n\t\t\t\t\"ignore\",\n\t\t\t\t\"ipc\"\n\t\t\t]\n\t\t});\n\t\tchild.send(payload, (err) => {\n\t\t\tif (err !== null && process.env[\"PRISMA_DEBUG\"] === \"1\") process.stderr.write(`[cli-telemetry] parent send error: ${String(err)}\\n`);\n\t\t});\n\t\tchild.disconnect();\n\t\tchild.unref();\n\t\treturn { spawned: true };\n\t} catch (err) {\n\t\tif (process.env[\"PRISMA_DEBUG\"] === \"1\") process.stderr.write(`[cli-telemetry] parent fork failed: ${String(err)}\\n`);\n\t\treturn {\n\t\t\tspawned: false,\n\t\t\treason: \"fork-failed\"\n\t\t};\n\t}\n}\n/**\n* Resolve the path to the compiled sender entry relative to a consumer\n* that has captured its own `import.meta.url`. The CLI's\n* `tsdown`-emitted entry sits at `<package>/dist/sender.mjs`; the\n* consumer asks `senderModuleUrl()` and forwards the result to\n* `runTelemetry({ senderPath })`.\n*/\nfunction senderModuleUrl(importMetaUrl) {\n\treturn fileURLToPath(new URL(\"./sender.mjs\", importMetaUrl));\n}\n//#endregion\nexport { TELEMETRY_BACKEND_URL, TELEMETRY_ENDPOINT_PATH, ensureInstallationId, loadProjectConfig, readUserConfig, resolveGating, resolveTelemetryEndpoint, runTelemetry,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HANGED
|
@@ -3,7 +3,7 @@ import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
|
3
3
|
import { c as spaceMigrationDirectory } from "./verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs";
|
|
4
4
|
import { i as createScaffoldSpecifierResolver } from "./import-roots-BHOrDJbI.mjs";
|
|
5
5
|
import { $ as loadContractRawSafely, A as errorMigrationPlanningFailed, At as statusForMigrationHash, C as errorDestructiveChanges, Ct as resolveRefAdvancementFields, D as errorLegendHumanOnly, Dt as runMigrationCheck, E as errorHashMismatch, F as errorTargetMigrationNotSupported, H as executeMigrateShowPlan, I as errorTargetMismatch, J as executeRefSetCommand, K as executeRefDeleteCommand, L as errorUnexpected, M as errorPathUnreachable, Mt as toDeclaredExtensionsFromRaw, N as errorRunnerFailed, O as errorMarkerMissing, Ot as runMigrationList, P as errorRuntime, Q as loadAggregateIntegrityViolations, R as executeContractEmit, S as errorDatabaseConnectionRequired, St as resolveMigrationRef, T as errorFileNotFound, Tt as runCommandAction, U as executeMigrationNewCommand, W as executeMigrationPlanCommand, X as hasMigrationPath, Y as findPackageByDirPath, Z as listRefsByContractHash, _ as enumerateCheckSpaces, _t as requireLiveDatabase, at as maskConnectionUrl, b as errorContractArgConflict, bt as resolveContractRefToSnapshot, ct as readContractEnvelope, d as closeQuietly, dt as refuseContractSpaceIntegrity, et as loadContractSpaceAggregateForCli, gt as refuseUnknownInvariants, ht as refusePackageCorruptionOnAggregate, i as appliedHashesFromLedger, j as errorNoMigrations, jt as targetSupportsMigrations, k as errorMigrationPackageNotFound, kt as sanitizeErrorMessage, l as checkSingleTarget, lt as readContractIR, m as deriveStatusEdgeAnnotations, mt as refuseMissingInvariantPath, n as advanceRefSafely, nt as mapCaughtMigrationError, o as buildMigrationSpaceGraphEntries, ot as migrationSpaceListEntriesFromAggregate, p as createControlClient, pt as refuseMarkerOutsideGraph, q as executeRefListCommand, rt as mapContractAtError, s as buildReadAggregate, st as originHashForStatus, t as CliStructuredError$1$1, tt as looksLikePath, u as chooseAction, ut as readMigrationRefs, v as errorConfigValidation$1, vt as resolveAppTargetPath, w as errorDriverRequired, x as errorContractValidationFailed, y as errorConsentPlanMismatch, yt as resolveContractRef$1 } from "./ref-BPBIUGrB-BQt8iSyJ.mjs";
|
|
6
|
-
import { n as buildNextSteps, t as InitOutputSchema } from "./output-
|
|
6
|
+
import { n as buildNextSteps, t as InitOutputSchema } from "./output-D83nTTpC-XlvN30yS.mjs";
|
|
7
7
|
import { r as loadConfig, t as finalizeConfig } from "./exports-BXXeNWlj.mjs";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { existsSync, mkdirSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -33,7 +33,7 @@ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
|
|
|
33
33
|
import stringWidth from "string-width";
|
|
34
34
|
import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
|
|
35
35
|
import { build } from "esbuild";
|
|
36
|
-
//#region ../../../1-framework/3-tooling/cli/dist/load-config-
|
|
36
|
+
//#region ../../../1-framework/3-tooling/cli/dist/load-config-CWwenkv5.mjs
|
|
37
37
|
const MISSING_CONFIG_ACTION = {
|
|
38
38
|
kind: "run-command",
|
|
39
39
|
label: "Create a config file",
|
|
@@ -3019,7 +3019,7 @@ function starterSchema(target, authoring, resolveImportSpecifier = keepInternalS
|
|
|
3019
3019
|
}
|
|
3020
3020
|
/**
|
|
3021
3021
|
* Renders a short authoring-appropriate schema sample for embedding in
|
|
3022
|
-
* `prisma-
|
|
3022
|
+
* `prisma-8.md`. Returns a complete fenced markdown code block.
|
|
3023
3023
|
*
|
|
3024
3024
|
* The sample intentionally shows just one model: it's illustrative, not
|
|
3025
3025
|
* a substitute for the full scaffolded contract file. The TS samples use
|
|
@@ -3098,7 +3098,7 @@ export const contract = defineContract(
|
|
|
3098
3098
|
\`\`\``;
|
|
3099
3099
|
}
|
|
3100
3100
|
function starterSchemaPslPostgres() {
|
|
3101
|
-
return `// use prisma-
|
|
3101
|
+
return `// use prisma-8
|
|
3102
3102
|
|
|
3103
3103
|
model User {
|
|
3104
3104
|
id Int @id @default(autoincrement())
|
|
@@ -3122,7 +3122,7 @@ model Post {
|
|
|
3122
3122
|
`;
|
|
3123
3123
|
}
|
|
3124
3124
|
function starterSchemaPslMongo() {
|
|
3125
|
-
return `// use prisma-
|
|
3125
|
+
return `// use prisma-8
|
|
3126
3126
|
|
|
3127
3127
|
model User {
|
|
3128
3128
|
id ObjectId @id @map("_id")
|
|
@@ -3267,7 +3267,7 @@ export const db = mongo<Contract>({
|
|
|
3267
3267
|
* Bumping a value here in isolation is **not** safe: edit the
|
|
3268
3268
|
* corresponding target package's `package.json` first, then mirror
|
|
3269
3269
|
* here. The scaffold's `.env.example` and the "Requirements" section
|
|
3270
|
-
* of `prisma-
|
|
3270
|
+
* of `prisma-8.md` both read from this constant, so a stale value
|
|
3271
3271
|
* lies to every freshly initialised user.
|
|
3272
3272
|
*/
|
|
3273
3273
|
const MIN_SERVER_VERSION = {
|
|
@@ -3418,11 +3418,11 @@ function buildInitNextActions(inputs) {
|
|
|
3418
3418
|
kind: "edit-file",
|
|
3419
3419
|
label: `Edit your schema at ${inputs.schemaPath}, then emit again`
|
|
3420
3420
|
});
|
|
3421
|
-
actions.push(chooseAction("Open prisma-
|
|
3421
|
+
actions.push(chooseAction("Open prisma-8.md for a quick reference on writing your first typed query"));
|
|
3422
3422
|
actions.push(runCommandAction("Set up the Prisma agent skills for your coding agent", "prisma init"));
|
|
3423
3423
|
return actions;
|
|
3424
3424
|
}
|
|
3425
|
-
const DONE_TEXT = "Done. Open prisma-
|
|
3425
|
+
const DONE_TEXT = "Done. Open prisma-8.md to get started.";
|
|
3426
3426
|
const INCOMPLETE_TEXT = "Scaffold written. Finish the steps above to complete setup.";
|
|
3427
3427
|
/**
|
|
3428
3428
|
* `init` writes files rather than data another program reads, so it supplies
|
|
@@ -4002,7 +4002,7 @@ function quickReferenceMd(target, authoring, schemaPath, pkgRun, resolveImportSp
|
|
|
4002
4002
|
return renderTemplate(`quick-reference-${target}.md`, variables, vars);
|
|
4003
4003
|
}
|
|
4004
4004
|
/**
|
|
4005
|
-
* Renders the FR8.2 "Requirements" block injected into `prisma-
|
|
4005
|
+
* Renders the FR8.2 "Requirements" block injected into `prisma-8.md`
|
|
4006
4006
|
* (the user-facing quick reference). Sources the minimum server
|
|
4007
4007
|
* version from `MIN_SERVER_VERSION` — itself mirrored from each
|
|
4008
4008
|
* target package's `package.json#prismaNext.minServerVersion`
|
|
@@ -4211,7 +4211,7 @@ function mergeTypesArray(existing) {
|
|
|
4211
4211
|
return result;
|
|
4212
4212
|
}
|
|
4213
4213
|
const CONFIG_FILE = "prisma.config.ts";
|
|
4214
|
-
const QUICK_REFERENCE_FILE = "prisma-
|
|
4214
|
+
const QUICK_REFERENCE_FILE = "prisma-8.md";
|
|
4215
4215
|
const ENV_EXAMPLE_FILE = ".env.example";
|
|
4216
4216
|
/**
|
|
4217
4217
|
* The generated files a run replaces outright, in the order it writes them.
|
|
@@ -4979,7 +4979,7 @@ const lspCommand = defineServerCommand({
|
|
|
4979
4979
|
} },
|
|
4980
4980
|
handler: async (args, io) => {
|
|
4981
4981
|
const exitCode = await withoutClientProcessIdInArgv(async () => {
|
|
4982
|
-
const { startServer } = await import("./exports-
|
|
4982
|
+
const { startServer } = await import("./exports-CYa2di3d.mjs");
|
|
4983
4983
|
return startServer({
|
|
4984
4984
|
stdin: io.stdin,
|
|
4985
4985
|
stdout: io.stdout,
|
|
@@ -9550,7 +9550,7 @@ function createImportAllowlistPlugin(allowlist, entryPath, collected) {
|
|
|
9550
9550
|
async function loadContractFromTs(entryPath, options) {
|
|
9551
9551
|
const allowlist = options?.allowlist ?? DEFAULT_ALLOWLIST;
|
|
9552
9552
|
if (!existsSync(entryPath)) throw new CliStructuredError("CLI.FILE_NOT_FOUND", `Contract file not found: ${entryPath}`, { where: { path: entryPath } });
|
|
9553
|
-
const tempFile = join(tmpdir(), `prisma-
|
|
9553
|
+
const tempFile = join(tmpdir(), `prisma-8-contract-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`);
|
|
9554
9554
|
const disallowedFromEntry = /* @__PURE__ */ new Set();
|
|
9555
9555
|
try {
|
|
9556
9556
|
const result = await build({
|