@prisma/get-platform 7.5.0-dev.37 → 7.5.0-dev.39

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.
@@ -0,0 +1 @@
1
+ export declare function serialize(value: any): any;
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var vitest_snapshot_serializer_exports = {};
30
+ __export(vitest_snapshot_serializer_exports, {
31
+ serialize: () => serialize
32
+ });
33
+ module.exports = __toCommonJS(vitest_snapshot_serializer_exports);
34
+ var import_chunk_IPLRRT6O = require("../chunk-IPLRRT6O.js");
35
+ var import_chunk_7MLUNQIZ = require("../chunk-7MLUNQIZ.js");
36
+ var import_chunk_2ESYSVXG = require("../chunk-2ESYSVXG.js");
37
+ var import_node_path = __toESM(require("node:path"));
38
+ var import_node_util = require("node:util");
39
+ (0, import_chunk_IPLRRT6O.init_binaryTargetRegex)();
40
+ var pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x);
41
+ function normalizePrismaPaths(str) {
42
+ return str.replace(/prisma\\([\w-]+)\.prisma/g, "prisma/$1.prisma").replace(/prisma\\seed\.ts/g, "prisma/seed.ts").replace(/custom-folder\\seed\.js/g, "custom-folder/seed.js");
43
+ }
44
+ function normalizeLogs(str) {
45
+ return str.replace(
46
+ /Started query engine http server on http:\/\/127\.0\.0\.1:\d{1,5}/g,
47
+ "Started query engine http server on http://127.0.0.1:00000"
48
+ ).replace(/Starting a postgresql pool with \d+ connections./g, "Starting a postgresql pool with XX connections.");
49
+ }
50
+ function normalizeTmpDir(str) {
51
+ const tempDirRegexes = [
52
+ // Linux
53
+ /\/tmp\/([a-z0-9]+)/g,
54
+ // macOS
55
+ /\/private\/var\/folders\/[^/]+\/[^/]+\/T\/[a-z0-9]+/g
56
+ ];
57
+ if (process.env.TEMP) {
58
+ const escapedPath = process.env.TEMP.replaceAll("\\", "\\\\");
59
+ tempDirRegexes.push(new RegExp(`${escapedPath}\\\\[a-z0-9]+`, "g"));
60
+ }
61
+ for (const regex of tempDirRegexes) {
62
+ str = str.replace(regex, "/tmp/dir");
63
+ }
64
+ return str;
65
+ }
66
+ function trimErrorPaths(str) {
67
+ const parentDir = import_node_path.default.dirname(import_node_path.default.dirname(import_node_path.default.dirname(__dirname)));
68
+ return str.replaceAll(parentDir, "");
69
+ }
70
+ function normalizeToUnixPaths(str) {
71
+ return str.replaceAll(import_node_path.default.sep, "/");
72
+ }
73
+ function normalizeGitHubLinks(str) {
74
+ return str.replace(/https:\/\/github.com\/prisma\/prisma(-client-js)?\/issues\/new\S+/, "TEST_GITHUB_LINK");
75
+ }
76
+ function normalizeTsClientStackTrace(str) {
77
+ return str.replace(/([/\\]client[/\\]src[/\\]__tests__[/\\].*test\.ts)(:\d*:\d*)/, "$1:0:0").replace(/([/\\]client[/\\]tests[/\\]functional[/\\].*\.ts)(:\d*:\d*)/, "$1:0:0");
78
+ }
79
+ function removePlatforms(str) {
80
+ return str.replace(import_chunk_IPLRRT6O.binaryTargetRegex, "TEST_PLATFORM");
81
+ }
82
+ function normalizeBinaryFilePath(str) {
83
+ return str.replace(/\.exe(\s+)?(\W.*)/g, "$1$2").replace(/\.exe$/g, "");
84
+ }
85
+ function normalizeMigrateTimestamps(str) {
86
+ return str.replace(/(?<!\d)\d{14}(?!\d)/g, "20201231000000");
87
+ }
88
+ function normalizeDbUrl(str) {
89
+ return str.replace(/(localhost|postgres|mysql|mssql|mongodb_migrate|cockroachdb):(\d+)/g, "localhost:$2");
90
+ }
91
+ function normalizeRustError(str) {
92
+ return str.replace(/\/rustc\/(.+)\//g, "/rustc/hash/").replace(/(\[.*)(:\d*:\d*)(\])/g, "[/some/rust/path:0:0$3");
93
+ }
94
+ function normalizeRustCodeLocation(str) {
95
+ return str.replace(/(\w+\.rs):(\d+):(\d+)/g, "$1:0:0");
96
+ }
97
+ function normalizeArtificialPanic(str) {
98
+ return str.replace(/(Command failed with exit code 101:) (.+) /g, "$1 prisma-engines-path ");
99
+ }
100
+ function normalizeTime(str) {
101
+ return str.replace(/ \d+ms/g, " XXXms").replace(/ \d+(\.\d+)?s/g, " XXXms");
102
+ }
103
+ function prepareSchemaForSnapshot(str) {
104
+ if (!str.includes("tmp/prisma-tests/integration-test")) return str;
105
+ const urlRegex = /url\s*=\s*.+/;
106
+ const outputRegex = /output\s*=\s*.+/;
107
+ return str.split("\n").map((line) => {
108
+ const urlMatch = urlRegex.exec(line);
109
+ if (urlMatch) {
110
+ return `${line.slice(0, urlMatch.index)}url = "***"`;
111
+ }
112
+ const outputMatch = outputRegex.exec(line);
113
+ if (outputMatch) {
114
+ return `${line.slice(0, outputMatch.index)}output = "***"`;
115
+ }
116
+ return line;
117
+ }).join("\n");
118
+ }
119
+ function wrapWithQuotes(str) {
120
+ return `"${str}"`;
121
+ }
122
+ function serialize(value) {
123
+ const message = typeof value === "string" ? value : value instanceof Error ? value.message : "";
124
+ return pipe(
125
+ import_node_util.stripVTControlCharacters,
126
+ // integration-tests pkg
127
+ prepareSchemaForSnapshot,
128
+ // Generic
129
+ normalizeTmpDir,
130
+ normalizeTime,
131
+ // From Client package
132
+ normalizeGitHubLinks,
133
+ removePlatforms,
134
+ normalizeBinaryFilePath,
135
+ normalizeTsClientStackTrace,
136
+ trimErrorPaths,
137
+ normalizePrismaPaths,
138
+ normalizeLogs,
139
+ // remove windows \\
140
+ normalizeToUnixPaths,
141
+ // From Migrate/CLI package
142
+ normalizeDbUrl,
143
+ normalizeRustError,
144
+ normalizeRustCodeLocation,
145
+ normalizeMigrateTimestamps,
146
+ // artificial panic
147
+ normalizeArtificialPanic,
148
+ wrapWithQuotes
149
+ )(message);
150
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/get-platform",
3
- "version": "7.5.0-dev.37",
3
+ "version": "7.5.0-dev.39",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "typescript": "5.4.5"
28
28
  },
29
29
  "dependencies": {
30
- "@prisma/debug": "7.5.0-dev.37"
30
+ "@prisma/debug": "7.5.0-dev.39"
31
31
  },
32
32
  "files": [
33
33
  "README.md",