prisma 8.0.0-rc.9-dev.75 → 8.1.0-dev.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.
Files changed (53) hide show
  1. package/LICENSE +201 -158
  2. package/README.md +58 -101
  3. package/build/child.js +82915 -0
  4. package/build/cli.js +5778 -0
  5. package/build/completion.js +802 -0
  6. package/build/index.js +2 -0
  7. package/build/prisma_schema_build_bg.wasm +0 -0
  8. package/build/query_compiler_fast_bg.cockroachdb.js +2 -0
  9. package/build/query_compiler_fast_bg.cockroachdb.mjs +2 -0
  10. package/build/query_compiler_fast_bg.cockroachdb.wasm +0 -0
  11. package/build/query_compiler_fast_bg.mysql.js +2 -0
  12. package/build/query_compiler_fast_bg.mysql.mjs +2 -0
  13. package/build/query_compiler_fast_bg.mysql.wasm +0 -0
  14. package/build/query_compiler_fast_bg.postgresql.js +2 -0
  15. package/build/query_compiler_fast_bg.postgresql.mjs +2 -0
  16. package/build/query_compiler_fast_bg.postgresql.wasm +0 -0
  17. package/build/query_compiler_fast_bg.sqlite.js +2 -0
  18. package/build/query_compiler_fast_bg.sqlite.mjs +2 -0
  19. package/build/query_compiler_fast_bg.sqlite.wasm +0 -0
  20. package/build/query_compiler_fast_bg.sqlserver.js +2 -0
  21. package/build/query_compiler_fast_bg.sqlserver.mjs +2 -0
  22. package/build/query_compiler_fast_bg.sqlserver.wasm +0 -0
  23. package/build/query_compiler_small_bg.cockroachdb.js +2 -0
  24. package/build/query_compiler_small_bg.cockroachdb.mjs +2 -0
  25. package/build/query_compiler_small_bg.cockroachdb.wasm +0 -0
  26. package/build/query_compiler_small_bg.mysql.js +2 -0
  27. package/build/query_compiler_small_bg.mysql.mjs +2 -0
  28. package/build/query_compiler_small_bg.mysql.wasm +0 -0
  29. package/build/query_compiler_small_bg.postgresql.js +2 -0
  30. package/build/query_compiler_small_bg.postgresql.mjs +2 -0
  31. package/build/query_compiler_small_bg.postgresql.wasm +0 -0
  32. package/build/query_compiler_small_bg.sqlite.js +2 -0
  33. package/build/query_compiler_small_bg.sqlite.mjs +2 -0
  34. package/build/query_compiler_small_bg.sqlite.wasm +0 -0
  35. package/build/query_compiler_small_bg.sqlserver.js +2 -0
  36. package/build/query_compiler_small_bg.sqlserver.mjs +2 -0
  37. package/build/query_compiler_small_bg.sqlserver.wasm +0 -0
  38. package/build/schema_engine_bg.wasm +0 -0
  39. package/build/studio.css +5850 -0
  40. package/build/studio.js +373 -0
  41. package/build/xdg-open +1066 -0
  42. package/config.d.ts +1 -0
  43. package/config.js +30 -0
  44. package/dist/cli/src/config.d.ts +1 -0
  45. package/dist/cli/src/types.d.ts +1 -0
  46. package/package.json +189 -55
  47. package/preinstall/index.js +7 -0
  48. package/scripts/preinstall-entry.js +10 -0
  49. package/dist/config.d.ts +0 -2
  50. package/dist/config.js +0 -2
  51. package/dist/payload-B88Qvzxk-CrtTXSOe.js +0 -34
  52. package/dist/prisma.js +0 -14417
  53. package/dist/sender.js +0 -192
package/dist/sender.js DELETED
@@ -1,192 +0,0 @@
1
- import { t as isParentToSenderPayload } from "./payload-B88Qvzxk-CrtTXSOe.js";
2
- import { join } from "node:path";
3
- import { readFileSync } from "node:fs";
4
- import { determineAgent } from "@vercel/detect-agent";
5
- //#region ../cli-telemetry/dist/sender.js
6
- /**
7
- * Identify the runtime the sender is running in. Same-runtime as the
8
- * parent is a correctness requirement: the parent forked us via
9
- * `child_process.fork`, which inherits the parent's runtime. Detection
10
- * keys on the runtime-specific version field rather than env vars so a
11
- * spoofed env can't lie about the actual interpreter.
12
- */
13
- function resolveRuntime(versions) {
14
- if (versions.bun !== void 0) return {
15
- name: "bun",
16
- version: versions.bun
17
- };
18
- if (versions.deno !== void 0) return {
19
- name: "deno",
20
- version: versions.deno
21
- };
22
- return {
23
- name: "node",
24
- version: versions.node
25
- };
26
- }
27
- const WHITESPACE = /\s+/;
28
- const SEMVER_RANGE_PREFIX = /^[\^~]/;
29
- /**
30
- * Parse `npm_config_user_agent` into a `<pm>/<version>` token. The
31
- * value, when present, looks like
32
- * `"pnpm/10.27.0 npm/? node/v24.13.0 darwin arm64"` — we take the first
33
- * whitespace-separated token. Any failure → `null`.
34
- */
35
- function parsePackageManager(userAgent) {
36
- if (userAgent === void 0) return null;
37
- const first = userAgent.split(WHITESPACE)[0];
38
- if (first === void 0 || first.length === 0) return null;
39
- if (!first.includes("/")) return null;
40
- return first;
41
- }
42
- /**
43
- * Read the user's project `package.json` and resolve a TypeScript
44
- * version from `devDependencies.typescript` (preferred) or
45
- * `dependencies.typescript`. Strips a leading `^` or `~` semver
46
- * prefix. Returns `null` on any failure mode — file missing,
47
- * unreadable, malformed JSON, key absent, not a string.
48
- */
49
- function readTsVersionFromPackageJson(raw) {
50
- if (raw === null) return null;
51
- let parsed;
52
- try {
53
- parsed = JSON.parse(raw);
54
- } catch {
55
- return null;
56
- }
57
- const candidate = pickStringDep(parsed.devDependencies) ?? pickStringDep(parsed.dependencies);
58
- if (candidate === null) return null;
59
- return candidate.replace(SEMVER_RANGE_PREFIX, "");
60
- }
61
- function pickStringDep(deps) {
62
- if (deps === null || typeof deps !== "object" || Array.isArray(deps)) return null;
63
- const value = deps.typescript;
64
- return typeof value === "string" ? value : null;
65
- }
66
- /**
67
- * Build the full backend event from the parent's payload, the
68
- * project-config slice, and the child's per-process snapshot. Pure
69
- * given a `projectConfig` + `EnrichEnvironment`.
70
- */
71
- function buildTelemetryEvent(payload, projectConfig, env) {
72
- const runtime = resolveRuntime(env.versions);
73
- return {
74
- installationId: payload.installationId,
75
- version: payload.version,
76
- command: payload.command,
77
- flags: payload.flags,
78
- runtimeName: runtime.name,
79
- runtimeVersion: runtime.version,
80
- os: env.platform,
81
- arch: env.arch,
82
- packageManager: parsePackageManager(env.env.npm_config_user_agent),
83
- databaseTarget: projectConfig.databaseTarget,
84
- tsVersion: readTsVersionFromPackageJson(env.readProjectPackageJson()),
85
- agent: env.agent,
86
- extensions: projectConfig.extensions
87
- };
88
- }
89
- /**
90
- * Resolve the agent label for the telemetry event via
91
- * `@vercel/detect-agent`, collapsing its discriminated result to the
92
- * event's `string | null` shape. Any detection failure counts as
93
- * "no agent" — telemetry is best-effort and non-blocking.
94
- */
95
- async function resolveAgentLabel() {
96
- try {
97
- const result = await determineAgent();
98
- return result.isAgent ? result.agent.name : null;
99
- } catch {
100
- return null;
101
- }
102
- }
103
- /**
104
- * Convenience for the sender entry: build the event from the live
105
- * `process` plus a real project-package.json reader, swallowing any
106
- * I/O errors in the file read.
107
- *
108
- * The project-config slice is payload-only: `databaseTarget` is the
109
- * parent's override when present (else `null`), and `extensions` is
110
- * always empty — there is no `prisma-next.config.*` in this product to
111
- * derive them from.
112
- */
113
- async function buildTelemetryEventFromProcess(payload) {
114
- return buildTelemetryEvent(payload, {
115
- databaseTarget: payload.databaseTarget ?? null,
116
- extensions: []
117
- }, {
118
- platform: process.platform,
119
- arch: process.arch,
120
- versions: process.versions,
121
- env: process.env,
122
- agent: await resolveAgentLabel(),
123
- readProjectPackageJson: () => {
124
- try {
125
- return readFileSync(join(payload.projectRoot, "package.json"), "utf-8");
126
- } catch {
127
- return null;
128
- }
129
- }
130
- });
131
- }
132
- /**
133
- * Sender script entry — forked into a detached child by the parent CLI via
134
- * `child_process.fork(senderPath, [], { detached: true, ... })`.
135
- *
136
- * Lifecycle:
137
- * 1. Wait for the parent's IPC `message` event carrying a
138
- * `ParentToSenderPayload`.
139
- * 2. Enrich with the local-process probes (runtime, os, arch, agent,
140
- * package manager, tsVersion).
141
- * 3. POST the event to the endpoint URL with a hard 1.5 s timeout.
142
- * 4. Exit 0 unconditionally — successful POST, network failure, server
143
- * error, parse error of the response, anything else: same outcome.
144
- *
145
- * Every error is swallowed; the only escape valve for visibility is
146
- * `PRISMA_DEBUG=1`, which routes diagnostics to stderr. In normal
147
- * operation no telemetry-originating output ever reaches the user — the
148
- * parent's stdio map ignores our streams anyway, but stderr writes are
149
- * also held behind the debug flag so the same binary is safe to invoke
150
- * directly outside the spawn flow.
151
- */
152
- const REQUEST_TIMEOUT_MS = 1500;
153
- function debugLog(message, error) {
154
- if (process.env.PRISMA_DEBUG !== "1") return;
155
- if (error !== void 0) process.stderr.write(`[cli-telemetry] ${message}: ${String(error)}\n`);
156
- else process.stderr.write(`[cli-telemetry] ${message}\n`);
157
- }
158
- async function postEvent(payload) {
159
- const event = await buildTelemetryEventFromProcess(payload);
160
- const controller = new AbortController();
161
- const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
162
- try {
163
- debugLog(`sent event: status=${(await fetch(payload.endpoint, {
164
- method: "POST",
165
- headers: { "content-type": "application/json" },
166
- body: JSON.stringify(event),
167
- signal: controller.signal
168
- })).status}`);
169
- } catch (err) {
170
- debugLog("send failed", err);
171
- } finally {
172
- clearTimeout(timer);
173
- }
174
- }
175
- function exitClean() {
176
- try {
177
- process.disconnect?.();
178
- } catch {}
179
- process.exit(0);
180
- }
181
- process.once("message", (message) => {
182
- if (!isParentToSenderPayload(message)) {
183
- debugLog("received malformed payload; exiting");
184
- exitClean();
185
- return;
186
- }
187
- postEvent(message).catch((err) => debugLog("post threw", err)).finally(exitClean);
188
- });
189
- const SENDER_IDLE_EXIT_MS = REQUEST_TIMEOUT_MS * 2;
190
- setTimeout(exitClean, SENDER_IDLE_EXIT_MS).unref();
191
- //#endregion
192
- export {};