@nightintelligence/cloudflare-workers-utils 0.35.0-patch1 → 0.35.0-patch3

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/dist/browser.mjs +2 -2
  2. package/dist/browser.mjs.map +1 -1
  3. package/dist/chunk-PAWJFY3S.mjs +6 -0
  4. package/dist/{chunk-6LYDFTTF.mjs.map → chunk-PAWJFY3S.mjs.map} +1 -1
  5. package/dist/compatibility-date.mjs +42 -2
  6. package/dist/compatibility-date.mjs.map +1 -1
  7. package/dist/compliance.mjs +2 -7
  8. package/dist/compliance.mjs.map +1 -1
  9. package/dist/docker-path.mjs +11 -3
  10. package/dist/docker-path.mjs.map +1 -1
  11. package/dist/errors.mjs +61 -2
  12. package/dist/errors.mjs.map +1 -1
  13. package/dist/fs-helpers.mjs +33 -2
  14. package/dist/fs-helpers.mjs.map +1 -1
  15. package/dist/global-wrangler-config-path.mjs +28 -3
  16. package/dist/global-wrangler-config-path.mjs.map +1 -1
  17. package/dist/index.mjs +54 -26280
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/local-env.mjs +5 -80
  20. package/dist/local-env.mjs.map +1 -1
  21. package/dist/metafile-esm.json +1 -1
  22. package/dist/prometheus-metrics.mjs +51 -2
  23. package/dist/prometheus-metrics.mjs.map +1 -1
  24. package/dist/test-helpers/index.mjs +7 -308
  25. package/dist/test-helpers/index.mjs.map +1 -1
  26. package/dist/zod-format.mjs +235 -2
  27. package/dist/zod-format.mjs.map +1 -1
  28. package/package.json +1 -1
  29. package/dist/chunk-3D4BXUZX.mjs +0 -54
  30. package/dist/chunk-3D4BXUZX.mjs.map +0 -1
  31. package/dist/chunk-4RE36JUD.mjs +0 -3160
  32. package/dist/chunk-4RE36JUD.mjs.map +0 -1
  33. package/dist/chunk-6LYDFTTF.mjs +0 -40
  34. package/dist/chunk-CPLEE7LH.mjs +0 -64
  35. package/dist/chunk-CPLEE7LH.mjs.map +0 -1
  36. package/dist/chunk-G5FCNCLK.mjs +0 -47
  37. package/dist/chunk-G5FCNCLK.mjs.map +0 -1
  38. package/dist/chunk-IGC3TZGH.mjs +0 -157
  39. package/dist/chunk-IGC3TZGH.mjs.map +0 -1
  40. package/dist/chunk-NXPJWJ2B.mjs +0 -180
  41. package/dist/chunk-NXPJWJ2B.mjs.map +0 -1
  42. package/dist/chunk-OPAKTV2K.mjs +0 -75
  43. package/dist/chunk-OPAKTV2K.mjs.map +0 -1
  44. package/dist/chunk-VKFVZ67V.mjs +0 -35
  45. package/dist/chunk-VKFVZ67V.mjs.map +0 -1
  46. package/dist/chunk-W7DIL5J2.mjs +0 -267
  47. package/dist/chunk-W7DIL5J2.mjs.map +0 -1
  48. package/dist/chunk-ZLUHKBEC.mjs +0 -44
  49. package/dist/chunk-ZLUHKBEC.mjs.map +0 -1
  50. package/dist/chunk-ZQ2EZEOC.mjs +0 -477
  51. package/dist/chunk-ZQ2EZEOC.mjs.map +0 -1
  52. package/dist/open-OYMIZX6T.mjs +0 -609
  53. package/dist/open-OYMIZX6T.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"prometheus-metrics.mjs"}
1
+ {"version":3,"sources":["../src/prometheus-metrics.ts"],"names":[],"mappings":";;AAuCO,MAAM,eAAA,CAAgB;AAAA,EAvC7B;AAuC6B,IAAA,MAAA,CAAA,IAAA,EAAA,iBAAA,CAAA;AAAA;AAAA,EACpB,WAA2B,EAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpC,aAAA,CAAc,MAAc,IAAA,EAAuB;AAClD,IAAA,MAAM,KAAA,GAAsB,EAAE,IAAA,EAAM,IAAA,EAAM,OAAO,CAAA,EAAE;AACnD,IAAA,IAAA,CAAK,QAAA,CAAS,KAAK,KAAK,CAAA;AACxB,IAAA,OAAO;AAAA,MACN,qBAAK,MAAA,CAAA,MAAM;AACV,QAAA,KAAA,CAAM,KAAA,EAAA;AAAA,MACP,CAAA,EAFK,KAAA,CAAA;AAAA,MAGL,GAAA,0BAAM,MAAA,KAAmB;AACxB,QAAA,IAAI,SAAS,CAAA,EAAG;AACf,UAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,QAChD;AACA,QAAA,KAAA,CAAM,KAAA,IAAS,MAAA;AAAA,MAChB,CAAA,EALK,KAAA;AAAA,KAMN;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAA,GAAkB;AACjB,IAAA,OAAO,IAAA,CAAK,QAAA,CACV,GAAA,CAAI,CAAC,CAAA,KAAM;AACX,MAAA,IAAI,MAAA,GAAS,EAAA;AACb,MAAA,IAAI,CAAA,CAAE,IAAA,CAAK,MAAA,GAAS,CAAA,EAAG;AACtB,QAAA,MAAA,IAAU,CAAA,OAAA,EAAU,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,EAAE,IAAI;AAAA,CAAA;AAAA,MACrC;AACA,MAAA,MAAA,IAAU,CAAA,OAAA,EAAU,EAAE,IAAI,CAAA;AAAA,CAAA;AAC1B,MAAA,MAAA,IAAU,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,EAAE,KAAK;AAAA,CAAA;AAC9B,MAAA,OAAO,MAAA;AAAA,IACR,CAAC,CAAA,CACA,IAAA,CAAK,EAAE,CAAA;AAAA,EACV;AACD","file":"prometheus-metrics.mjs","sourcesContent":["/**\n * Lightweight Prometheus metrics registry for push-based counter metrics.\n *\n * Designed for ephemeral per-request usage in Cloudflare Workers that push\n * metrics to a Prometheus push gateway. Replaces the deprecated `promjs` library.\n *\n * @example\n * ```ts\n * const metrics = new MetricsRegistry();\n * const reqCounter = metrics.createCounter(\n * \"service_request_total\",\n * \"Total requests\"\n * );\n * reqCounter.inc();\n *\n * // Push to Prometheus gateway\n * ctx.waitUntil(\n * fetch(prometheusUrl, {\n * method: \"POST\",\n * headers: { Authorization: `Bearer ${token}` },\n * body: metrics.metrics(),\n * })\n * );\n * ```\n */\n\nexport interface Counter {\n\t/** Increment the counter by 1. */\n\tinc(): void;\n\t/** Increment the counter by the given non-negative amount. */\n\tadd(amount: number): void;\n}\n\ninterface CounterEntry {\n\tname: string;\n\thelp: string;\n\tvalue: number;\n}\n\nexport class MetricsRegistry {\n\tprivate counters: CounterEntry[] = [];\n\n\t/**\n\t * Create and register a new counter metric.\n\t *\n\t * @param name - The metric name (e.g. \"service_request_total\")\n\t * @param help - A human-readable description of the metric\n\t * @returns A Counter that can be incremented\n\t */\n\tcreateCounter(name: string, help: string): Counter {\n\t\tconst entry: CounterEntry = { name, help, value: 0 };\n\t\tthis.counters.push(entry);\n\t\treturn {\n\t\t\tinc: () => {\n\t\t\t\tentry.value++;\n\t\t\t},\n\t\t\tadd: (amount: number) => {\n\t\t\t\tif (amount < 0) {\n\t\t\t\t\tthrow new Error(\"Counter value cannot decrease\");\n\t\t\t\t}\n\t\t\t\tentry.value += amount;\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Serialize all registered metrics in Prometheus text exposition format.\n\t *\n\t * @see https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format\n\t */\n\tmetrics(): string {\n\t\treturn this.counters\n\t\t\t.map((c) => {\n\t\t\t\tlet result = \"\";\n\t\t\t\tif (c.help.length > 0) {\n\t\t\t\t\tresult += `# HELP ${c.name} ${c.help}\\n`;\n\t\t\t\t}\n\t\t\t\tresult += `# TYPE ${c.name} counter\\n`;\n\t\t\t\tresult += `${c.name} ${c.value}\\n`;\n\t\t\t\treturn result;\n\t\t\t})\n\t\t\t.join(\"\");\n\t}\n}\n"]}
@@ -1,310 +1,9 @@
1
- import { formatConfigSnippet, PATH_TO_DEPLOY_CONFIG, parseTOML, parseJSONC } from '../chunk-4RE36JUD.mjs';
2
- import '../chunk-G5FCNCLK.mjs';
3
- import '../chunk-CPLEE7LH.mjs';
4
- import { removeDir } from '../chunk-VKFVZ67V.mjs';
5
- import { __name } from '../chunk-6LYDFTTF.mjs';
6
- import * as util from 'node:util';
7
- import { beforeEach, vi, afterEach } from 'vitest';
8
- import * as fs2 from 'node:fs';
9
- import os from 'node:os';
10
- import * as path from 'node:path';
11
- import path__default, { dirname, relative } from 'node:path';
12
- import { mkdir, writeFile } from 'node:fs/promises';
13
-
14
- // src/test-helpers/normalize.ts
15
- var mockCreateDate = new Date(2025, 4, 1);
16
- var mockModifiedDate = new Date(2025, 4, 2);
17
- var mockStartDate = new Date(2021, 1, 1);
18
- var mockQueuedDate = new Date(2025, 1, 2);
19
- var mockEndDate = new Date(2025, 1, 3);
20
- function normalizeString(input) {
21
- return normalizeTables(
22
- normalizeDates(
23
- normalizeErrorMarkers(
24
- replaceByte(
25
- stripTrailingWhitespace(
26
- stripStartupProfileHash(
27
- normalizeSlashes(
28
- normalizeCwd(
29
- normalizeTempDirs(
30
- normalizeOAuthUrlParams(
31
- stripTimings(replaceThinSpaces(input))
32
- )
33
- )
34
- )
35
- )
36
- )
37
- )
38
- )
39
- )
40
- )
41
- );
42
- }
43
- __name(normalizeString, "normalizeString");
44
- function normalizeOAuthUrlParams(str) {
45
- return str.replace(/([?&]state=)[^&\s]+/g, "$1<OAUTH_STATE>").replace(/([?&]code_challenge=)[^&\s]+/g, "$1<OAUTH_CODE_CHALLENGE>");
46
- }
47
- __name(normalizeOAuthUrlParams, "normalizeOAuthUrlParams");
48
- function stripStartupProfileHash(str) {
49
- return str.replace(/startup-profile-[^/]+/g, "startup-profile-<HASH>");
50
- }
51
- __name(stripStartupProfileHash, "stripStartupProfileHash");
52
- function normalizeTables(str) {
53
- return str.replaceAll(/┌─+/g, "\u250C\u2500").replaceAll(/┬─+/g, "\u252C\u2500").replaceAll(/ +│/g, " \u2502").replaceAll(/├─+/g, "\u251C\u2500").replaceAll(/┼─+/g, "\u253C\u2500").replaceAll(/└─+/g, "\u2514\u2500").replaceAll(/┴─+/g, "\u2534\u2500");
54
- }
55
- __name(normalizeTables, "normalizeTables");
56
- function normalizeDates(str) {
57
- return str.replaceAll(/\d+ (years?|days?|months?) ago/g, "[mock-time-ago]").replaceAll(mockCreateDate.toLocaleString(), "[mock-create-date]").replaceAll(mockModifiedDate.toLocaleString(), "[mock-modified-date]").replaceAll(mockStartDate.toLocaleString(), "[mock-start-date]").replaceAll(mockQueuedDate.toLocaleString(), "[mock-queued-date]").replaceAll(mockEndDate.toLocaleString(), "[mock-end-date]");
58
- }
59
- __name(normalizeDates, "normalizeDates");
60
- function normalizeErrorMarkers(str) {
61
- return str.replaceAll("\u2718", "X");
62
- }
63
- __name(normalizeErrorMarkers, "normalizeErrorMarkers");
64
- function normalizeSlashes(str) {
65
- return str.replace(/\\/g, "/");
66
- }
67
- __name(normalizeSlashes, "normalizeSlashes");
68
- function normalizeCwd(str) {
69
- return str.replaceAll(process.cwd(), "<cwd>");
70
- }
71
- __name(normalizeCwd, "normalizeCwd");
72
- function stripTimings(stdout) {
73
- return stdout.replace(/\(\d+\.\d+ sec\)/g, "(TIMINGS)");
74
- }
75
- __name(stripTimings, "stripTimings");
76
- function stripTrailingWhitespace(str) {
77
- return str.replace(/[^\S\n]+\n/g, "\n");
78
- }
79
- __name(stripTrailingWhitespace, "stripTrailingWhitespace");
80
- function replaceByte(stdout) {
81
- return stdout.replaceAll(/\d+\.\d+ KiB/g, "xx KiB");
82
- }
83
- __name(replaceByte, "replaceByte");
84
- function normalizeTempDirs(stdout) {
85
- return stdout.replaceAll(/\/\/.+\/tmp.+/g, "//tmpdir");
86
- }
87
- __name(normalizeTempDirs, "normalizeTempDirs");
88
- function replaceThinSpaces(str) {
89
- return str.replaceAll(/\u200a/g, " ");
90
- }
91
- __name(replaceThinSpaces, "replaceThinSpaces");
92
-
93
- // src/test-helpers/mock.ts
94
- var debugSpy;
95
- var logSpy;
96
- var infoSpy;
97
- var errorSpy;
98
- var warnSpy;
99
- var std = Object.defineProperties(
100
- { debug: "", out: "", info: "", err: "", warn: "", getAndClearOut: /* @__PURE__ */ __name(() => "", "getAndClearOut") },
101
- {
102
- debug: {
103
- get: /* @__PURE__ */ __name(() => normalizeOutput(debugSpy), "get"),
104
- enumerable: true
105
- },
106
- out: {
107
- get: /* @__PURE__ */ __name(() => normalizeOutput(logSpy), "get"),
108
- enumerable: true
109
- },
110
- info: {
111
- get: /* @__PURE__ */ __name(() => normalizeOutput(infoSpy), "get"),
112
- enumerable: true
113
- },
114
- err: {
115
- get: /* @__PURE__ */ __name(() => normalizeOutput(errorSpy), "get"),
116
- enumerable: true
117
- },
118
- warn: {
119
- get: /* @__PURE__ */ __name(() => normalizeOutput(warnSpy), "get"),
120
- enumerable: true
121
- },
122
- /**
123
- * Return the content of the mocked stdout and clear the mock's history.
124
- *
125
- * Helpful for tests that need to assert on multiple sequential console outputs.
126
- */
127
- getAndClearOut: {
128
- value: /* @__PURE__ */ __name(() => {
129
- const output = normalizeOutput(logSpy);
130
- logSpy.mockClear();
131
- return output;
132
- }, "value"),
133
- enumerable: false
134
- }
135
- }
136
- );
137
- function normalizeOutput(spy, join2 = "\n") {
138
- return normalizeString(captureCalls(spy, join2));
139
- }
140
- __name(normalizeOutput, "normalizeOutput");
141
- function captureCalls(spy, join2 = "\n") {
142
- return spy.mock.calls.map((args) => util.format("%s", ...args)).join(join2);
143
- }
144
- __name(captureCalls, "captureCalls");
145
- function mockConsoleMethods() {
146
- beforeEach(() => {
147
- debugSpy = vi.spyOn(console, "debug").mockImplementation(() => {
148
- });
149
- logSpy = vi.spyOn(console, "log").mockImplementation(() => {
150
- });
151
- infoSpy = vi.spyOn(console, "info").mockImplementation(() => {
152
- });
153
- errorSpy = vi.spyOn(console, "error").mockImplementation(() => {
154
- });
155
- warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {
156
- });
157
- });
158
- afterEach(() => {
159
- debugSpy.mockRestore();
160
- logSpy.mockRestore();
161
- infoSpy.mockRestore();
162
- errorSpy.mockRestore();
163
- warnSpy.mockRestore();
164
- });
165
- return std;
166
- }
167
- __name(mockConsoleMethods, "mockConsoleMethods");
168
- function createDeferred() {
169
- let resolve2;
170
- let reject;
171
- const promise = new Promise((_resolve, _reject) => {
172
- resolve2 = _resolve;
173
- reject = _reject;
174
- });
175
- if (!resolve2 || !reject) {
176
- throw new Error("Failed to create deferred promise");
177
- }
178
- return {
179
- promise,
180
- resolve: resolve2,
181
- reject
182
- };
183
- }
184
- __name(createDeferred, "createDeferred");
185
-
186
- // src/test-helpers/email-header-validation.ts
187
- var EMAIL_HEADER_NAME_CASES = [
188
- ["accepts RFC token characters", "X-Custom_Header.1", true],
189
- ["rejects spaces", "X Header", false],
190
- ["rejects colons", "X:Header", false],
191
- ["rejects an empty name", "", false]
192
- ];
193
- var EMAIL_HEADER_VALUE_CASES = [
194
- ["accepts plain text", "custom value", true],
195
- ["accepts LF-delimited lines", "first\nsecond", true],
196
- ["accepts CRLF-delimited lines", "first\r\nsecond", true],
197
- [
198
- "accepts an injection-shaped line for safe folding",
199
- "safe\nBcc: victim@example.com",
200
- true
201
- ],
202
- ["rejects a bare carriage return", "first\rsecond", false],
203
- ["rejects a tab", "first second", false],
204
- ["rejects DEL", "first\x7Fsecond", false]
205
- ];
206
- var MANAGED_EMAIL_HEADER_CASES = [
207
- ["Bcc", true],
208
- ["Cc", true],
209
- ["Content-Transfer-Encoding", true],
210
- ["CONTENT-TYPE", true],
211
- ["Date", true],
212
- ["From", true],
213
- ["MIME-Version", true],
214
- ["Reply-To", true],
215
- ["Subject", true],
216
- ["mEsSaGe-Id", true],
217
- ["To", true],
218
- ["X-Custom-Header", false]
219
- ];
220
- var originalCwd = process.cwd();
221
- function runInTempDir({ homedir } = { homedir: "./home" }) {
222
- let tmpDir;
223
- beforeEach(() => {
224
- tmpDir = fs2.realpathSync(
225
- fs2.mkdtempSync(path.join(os.tmpdir(), "wrangler-tests"))
226
- );
227
- process.chdir(tmpDir);
228
- vi.stubEnv("PWD", tmpDir);
229
- const absHomedir = path.resolve(tmpDir, homedir);
230
- fs2.mkdirSync(absHomedir, { recursive: true });
231
- vi.stubEnv("HOME", absHomedir);
232
- vi.stubEnv("XDG_CONFIG_HOME", path.resolve(absHomedir, ".config"));
233
- });
234
- afterEach(() => {
235
- process.chdir(originalCwd);
236
- removeDir(tmpDir, { fireAndForget: true });
237
- });
238
- }
239
- __name(runInTempDir, "runInTempDir");
240
- async function seed(files) {
241
- for (const [name, contents] of Object.entries(files)) {
242
- const filePath = path__default.resolve(name);
243
- await mkdir(path__default.dirname(filePath), { recursive: true });
244
- await writeFile(filePath, contents);
245
- }
246
- }
247
- __name(seed, "seed");
248
- function writeWranglerConfig(config = {}, path3 = "./wrangler.toml") {
249
- const json = /\.jsonc?$/.test(path3);
250
- fs2.mkdirSync(dirname(path3), { recursive: true });
251
- fs2.writeFileSync(
252
- path3,
253
- formatConfigSnippet(
254
- {
255
- compatibility_date: "2022-01-12",
256
- name: "test-name",
257
- ...config
258
- },
259
- path3,
260
- !!json
261
- ),
262
- "utf-8"
263
- );
264
- }
265
- __name(writeWranglerConfig, "writeWranglerConfig");
266
- function writeRedirectedWranglerConfig(config, path3 = "./dist/wrangler.json") {
267
- const json = /\.jsonc?$/.test(path3);
268
- fs2.mkdirSync(dirname(path3), { recursive: true });
269
- fs2.writeFileSync(
270
- path3,
271
- formatConfigSnippet(
272
- {
273
- compatibility_date: "2022-01-12",
274
- name: "test-name",
275
- ...config
276
- },
277
- path3,
278
- !!json
279
- ),
280
- "utf-8"
281
- );
282
- writeDeployRedirectConfig(path3);
283
- }
284
- __name(writeRedirectedWranglerConfig, "writeRedirectedWranglerConfig");
285
- function writeDeployRedirectConfig(configPath) {
286
- const config = {
287
- configPath: relative(dirname(PATH_TO_DEPLOY_CONFIG), configPath)
288
- };
289
- fs2.mkdirSync(dirname(PATH_TO_DEPLOY_CONFIG), { recursive: true });
290
- fs2.writeFileSync(
291
- PATH_TO_DEPLOY_CONFIG,
292
- formatConfigSnippet(config, ".json", true),
293
- "utf-8"
294
- );
295
- }
296
- __name(writeDeployRedirectConfig, "writeDeployRedirectConfig");
297
- function readWranglerConfig(path3 = "./wrangler.toml") {
298
- if (path3.endsWith(".toml")) {
299
- return parseTOML(fs2.readFileSync(path3, "utf8"), path3);
300
- }
301
- if (path3.endsWith(".json") || path3.endsWith(".jsonc")) {
302
- return parseJSONC(fs2.readFileSync(path3, "utf8"), path3);
303
- }
304
- return {};
305
- }
306
- __name(readWranglerConfig, "readWranglerConfig");
307
-
308
- export { EMAIL_HEADER_NAME_CASES, EMAIL_HEADER_VALUE_CASES, MANAGED_EMAIL_HEADER_CASES, createDeferred, mockConsoleMethods, mockCreateDate, mockEndDate, mockModifiedDate, mockQueuedDate, mockStartDate, normalizeString, readWranglerConfig, runInTempDir, seed, writeDeployRedirectConfig, writeRedirectedWranglerConfig, writeWranglerConfig };
1
+ import '../chunk-PAWJFY3S.mjs';
2
+ export { createDeferred, mockConsoleMethods } from './mock';
3
+ export { EMAIL_HEADER_NAME_CASES, EMAIL_HEADER_VALUE_CASES, MANAGED_EMAIL_HEADER_CASES } from './email-header-validation';
4
+ export { mockCreateDate, mockEndDate, mockModifiedDate, mockQueuedDate, mockStartDate, normalizeString } from './normalize';
5
+ export { runInTempDir } from './run-in-tmp';
6
+ export { seed } from './seed';
7
+ export { readWranglerConfig, writeDeployRedirectConfig, writeRedirectedWranglerConfig, writeWranglerConfig } from './wrangler-config';
309
8
  //# sourceMappingURL=index.mjs.map
310
9
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test-helpers/normalize.ts","../../src/test-helpers/mock.ts","../../src/test-helpers/email-header-validation.ts","../../src/test-helpers/run-in-tmp.ts","../../src/test-helpers/seed.ts","../../src/test-helpers/wrangler-config.ts"],"names":["join","resolve","beforeEach","fs","vi","afterEach","path"],"mappings":";;;;;;;;;;;;;;AAAO,IAAM,cAAA,GAAiB,IAAI,IAAA,CAAK,IAAA,EAAM,GAAG,CAAC;AAC1C,IAAM,gBAAA,GAAmB,IAAI,IAAA,CAAK,IAAA,EAAM,GAAG,CAAC;AAC5C,IAAM,aAAA,GAAgB,IAAI,I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7D,EAAA,MAAM,MAAA,GAA8B;AAAA,IACnC,UAAA,EAAY,QAAA,CAAS,OAAA,CAAQ,qBAAqB,GAAG,UAAU;AAAA,GAChE;AACA,EAAG,cAAU,OAAA,CAAQ,qBAAqB,GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AAChE,EAAG,GAAA,CAAA,aAAA;AAAA,IACF,qBAAA;AAAA,IACA,mBAAA,CAAoB,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,IACzC;AAAA,GACD;AACD;AAVgB,MAAA,CAAA,yBAAA,EAAA,2BAAA,CAAA;AAYT,SAAS,kBAAA,CAAmBA,QAAO,iBAAA,EAA8B;AACvE,EAAA,IAAIA,KAAAA,CAAK,QAAA,CAAS,OAAO,CAAA,EAAG;AAC3B,IAAA,OAAO,SAAA,CAAa,GAAA,CAAA,YAAA,CAAaA,KAAAA,EAAM,MAAM,GAAGA,KAAI,CAAA;AAAA,EACrD;AAEA,EAAA,IAAIA,MAAK,QAAA,CAAS,OAAO,KAAKA,KAAAA,CAAK,QAAA,CAAS,QAAQ,CAAA,EAAG;AACtD,IAAA,OAAO,UAAA,CAAc,GAAA,CAAA,YAAA,CAAaA,KAAAA,EAAM,MAAM,GAAGA,KAAI,CAAA;AAAA,EACtD;AAEA,EAAA,OAAO,EAAC;AACT;AAVgB,MAAA,CAAA,kBAAA,EAAA,oBAAA,CAAA","file":"index.mjs","sourcesContent":["export const mockCreateDate = new Date(2025, 4, 1);\nexport const mockModifiedDate = new Date(2025, 4, 2);\nexport const mockStartDate = new Date(2021, 1, 1);\nexport const mockQueuedDate = new Date(2025, 1, 2);\nexport const mockEndDate = new Date(2025, 1, 3);\n\n/**\n * Normalize the input string, to make it reliable to use in tests.\n */\nexport function normalizeString(input: string): string {\n\treturn normalizeTables(\n\t\tnormalizeDates(\n\t\t\tnormalizeErrorMarkers(\n\t\t\t\treplaceByte(\n\t\t\t\t\tstripTrailingWhitespace(\n\t\t\t\t\t\tstripStartupProfileHash(\n\t\t\t\t\t\t\tnormalizeSlashes(\n\t\t\t\t\t\t\t\tnormalizeCwd(\n\t\t\t\t\t\t\t\t\tnormalizeTempDirs(\n\t\t\t\t\t\t\t\t\t\tnormalizeOAuthUrlParams(\n\t\t\t\t\t\t\t\t\t\t\tstripTimings(replaceThinSpaces(input))\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t);\n}\n\n/**\n * The OAuth authorize URL contains a random `state` and PKCE `code_challenge`\n * on every run. Replace those two values (but not `code_challenge_method`) with\n * stable placeholders so snapshots of the login URL stay deterministic.\n */\nfunction normalizeOAuthUrlParams(str: string): string {\n\treturn str\n\t\t.replace(/([?&]state=)[^&\\s]+/g, \"$1<OAUTH_STATE>\")\n\t\t.replace(/([?&]code_challenge=)[^&\\s]+/g, \"$1<OAUTH_CODE_CHALLENGE>\");\n}\n\nfunction stripStartupProfileHash(str: string): string {\n\treturn str.replace(/startup-profile-[^/]+/g, \"startup-profile-<HASH>\");\n}\n\nfunction normalizeTables(str: string): string {\n\treturn str\n\t\t.replaceAll(/┌─+/g, \"┌─\")\n\t\t.replaceAll(/┬─+/g, \"┬─\")\n\t\t.replaceAll(/ +│/g, \" │\")\n\t\t.replaceAll(/├─+/g, \"├─\")\n\t\t.replaceAll(/┼─+/g, \"┼─\")\n\t\t.replaceAll(/└─+/g, \"└─\")\n\t\t.replaceAll(/┴─+/g, \"┴─\");\n}\n\nfunction normalizeDates(str: string): string {\n\treturn str\n\t\t.replaceAll(/\\d+ (years?|days?|months?) ago/g, \"[mock-time-ago]\")\n\t\t.replaceAll(mockCreateDate.toLocaleString(), \"[mock-create-date]\")\n\t\t.replaceAll(mockModifiedDate.toLocaleString(), \"[mock-modified-date]\")\n\t\t.replaceAll(mockStartDate.toLocaleString(), \"[mock-start-date]\")\n\t\t.replaceAll(mockQueuedDate.toLocaleString(), \"[mock-queued-date]\")\n\t\t.replaceAll(mockEndDate.toLocaleString(), \"[mock-end-date]\");\n}\n\n/**\n * Normalize error `X` markers.\n *\n * Windows gets a different character.\n */\nfunction normalizeErrorMarkers(str: string): string {\n\treturn str.replaceAll(\"✘\", \"X\");\n}\n\n/**\n * Ensure slashes in the `str` are OS file-system agnostic.\n *\n * Use this in snapshot tests to be resilient to file-system differences.\n */\nfunction normalizeSlashes(str: string): string {\n\treturn str.replace(/\\\\/g, \"/\");\n}\n\n/**\n * Replace any use of the current working directory with `<cwd>` to avoid cross OS issues.\n */\nfunction normalizeCwd(str: string): string {\n\treturn str.replaceAll(process.cwd(), \"<cwd>\");\n}\n\n/**\n * Strip \"timing data\" out of the `stdout` string, since this is not always deterministic.\n *\n * Use this in snapshot tests to be resilient to slight changes in timing of processing.\n */\nfunction stripTimings(stdout: string): string {\n\treturn stdout.replace(/\\(\\d+\\.\\d+ sec\\)/g, \"(TIMINGS)\");\n}\n\nfunction stripTrailingWhitespace(str: string): string {\n\treturn str.replace(/[^\\S\\n]+\\n/g, \"\\n\");\n}\n\n/**\n * Removing leading kilobit (tenth of a byte) from test output due to\n * variation causing every few tests the value to change by ± .01\n */\nfunction replaceByte(stdout: string): string {\n\treturn stdout.replaceAll(/\\d+\\.\\d+ KiB/g, \"xx KiB\");\n}\n\n/**\n * Temp directories are created with random names, so we replace all comments temp dirs in them\n */\nfunction normalizeTempDirs(stdout: string): string {\n\treturn stdout.replaceAll(/\\/\\/.+\\/tmp.+/g, \"//tmpdir\");\n}\n\n/**\n * Replace thin space characters (U+200A) with regular spaces to normalize output\n */\nfunction replaceThinSpaces(str: string): string {\n\treturn str.replaceAll(/\\u200a/g, \" \");\n}\n","import * as util from \"node:util\";\nimport { afterEach, beforeEach, vi } from \"vitest\";\nimport { normalizeString } from \"./normalize\";\nimport type { MockInstance } from \"vitest\";\n\n/**\n * We use this module to mock console methods, and optionally\n * assert on the values they're called with in our tests.\n */\n\nlet debugSpy: MockInstance,\n\tlogSpy: MockInstance,\n\tinfoSpy: MockInstance,\n\terrorSpy: MockInstance,\n\twarnSpy: MockInstance;\n\n/**\n * An object containing the normalized output of each console method.\n *\n * We use `defineProperties` to add non enumerable methods to the object,\n * so they don't show up in test assertions that iterate over the object's keys.\n * i.e. `expect(std).toMatchInlineSnapshot('...')`;\n */\nconst std = Object.defineProperties(\n\t{ debug: \"\", out: \"\", info: \"\", err: \"\", warn: \"\", getAndClearOut: () => \"\" },\n\t{\n\t\tdebug: {\n\t\t\tget: () => normalizeOutput(debugSpy),\n\t\t\tenumerable: true,\n\t\t},\n\t\tout: {\n\t\t\tget: () => normalizeOutput(logSpy),\n\t\t\tenumerable: true,\n\t\t},\n\t\tinfo: {\n\t\t\tget: () => normalizeOutput(infoSpy),\n\t\t\tenumerable: true,\n\t\t},\n\t\terr: {\n\t\t\tget: () => normalizeOutput(errorSpy),\n\t\t\tenumerable: true,\n\t\t},\n\t\twarn: {\n\t\t\tget: () => normalizeOutput(warnSpy),\n\t\t\tenumerable: true,\n\t\t},\n\t\t/**\n\t\t * Return the content of the mocked stdout and clear the mock's history.\n\t\t *\n\t\t * Helpful for tests that need to assert on multiple sequential console outputs.\n\t\t */\n\t\tgetAndClearOut: {\n\t\t\tvalue: () => {\n\t\t\t\tconst output = normalizeOutput(logSpy);\n\t\t\t\tlogSpy.mockClear();\n\t\t\t\treturn output;\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t},\n\t}\n);\n\nfunction normalizeOutput(spy: MockInstance, join = \"\\n\"): string {\n\treturn normalizeString(captureCalls(spy, join));\n}\n\nfunction captureCalls(spy: MockInstance, join = \"\\n\"): string {\n\treturn spy.mock.calls\n\t\t.map((args: unknown[]) => util.format(\"%s\", ...args))\n\t\t.join(join);\n}\n\nexport function mockConsoleMethods() {\n\tbeforeEach(() => {\n\t\tdebugSpy = vi.spyOn(console, \"debug\").mockImplementation(() => {});\n\t\tlogSpy = vi.spyOn(console, \"log\").mockImplementation(() => {});\n\t\tinfoSpy = vi.spyOn(console, \"info\").mockImplementation(() => {});\n\t\terrorSpy = vi.spyOn(console, \"error\").mockImplementation(() => {});\n\t\twarnSpy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n\t});\n\tafterEach(() => {\n\t\tdebugSpy.mockRestore();\n\t\tlogSpy.mockRestore();\n\t\tinfoSpy.mockRestore();\n\t\terrorSpy.mockRestore();\n\t\twarnSpy.mockRestore();\n\t});\n\treturn std;\n}\n\nexport function createDeferred<T>() {\n\tlet resolve: ((value: T) => void) | undefined;\n\tlet reject: ((reason?: unknown) => void) | undefined;\n\tconst promise = new Promise<T>((_resolve, _reject) => {\n\t\tresolve = _resolve;\n\t\treject = _reject;\n\t});\n\n\tif (!resolve || !reject) {\n\t\tthrow new Error(\"Failed to create deferred promise\");\n\t}\n\n\treturn {\n\t\tpromise,\n\t\tresolve,\n\t\treject,\n\t};\n}\n","export const EMAIL_HEADER_NAME_CASES = [\n\t[\"accepts RFC token characters\", \"X-Custom_Header.1\", true],\n\t[\"rejects spaces\", \"X Header\", false],\n\t[\"rejects colons\", \"X:Header\", false],\n\t[\"rejects an empty name\", \"\", false],\n] as const;\n\nexport const EMAIL_HEADER_VALUE_CASES = [\n\t[\"accepts plain text\", \"custom value\", true],\n\t[\"accepts LF-delimited lines\", \"first\\nsecond\", true],\n\t[\"accepts CRLF-delimited lines\", \"first\\r\\nsecond\", true],\n\t[\n\t\t\"accepts an injection-shaped line for safe folding\",\n\t\t\"safe\\nBcc: victim@example.com\",\n\t\ttrue,\n\t],\n\t[\"rejects a bare carriage return\", \"first\\rsecond\", false],\n\t[\"rejects a tab\", \"first\\tsecond\", false],\n\t[\"rejects DEL\", \"first\\u007fsecond\", false],\n] as const;\n\nexport const MANAGED_EMAIL_HEADER_CASES = [\n\t[\"Bcc\", true],\n\t[\"Cc\", true],\n\t[\"Content-Transfer-Encoding\", true],\n\t[\"CONTENT-TYPE\", true],\n\t[\"Date\", true],\n\t[\"From\", true],\n\t[\"MIME-Version\", true],\n\t[\"Reply-To\", true],\n\t[\"Subject\", true],\n\t[\"mEsSaGe-Id\", true],\n\t[\"To\", true],\n\t[\"X-Custom-Header\", false],\n] as const;\n","import * as fs from \"node:fs\";\nimport os from \"node:os\";\nimport * as path from \"node:path\";\nimport { afterEach, beforeEach, vi } from \"vitest\";\nimport { removeDir } from \"../fs-helpers\";\n\nconst originalCwd = process.cwd();\n\nexport function runInTempDir({ homedir } = { homedir: \"./home\" }) {\n\tlet tmpDir: string;\n\n\tbeforeEach(() => {\n\t\t// Use realpath because the temporary path can point to a symlink rather than the actual path.\n\t\ttmpDir = fs.realpathSync(\n\t\t\tfs.mkdtempSync(path.join(os.tmpdir(), \"wrangler-tests\"))\n\t\t);\n\n\t\tprocess.chdir(tmpDir);\n\t\tvi.stubEnv(\"PWD\", tmpDir);\n\n\t\t// Override where the home directory is so that we can write our own user config,\n\t\t// without destroying the real thing.\n\t\t// The path that is returned from `homedir()` should be absolute.\n\t\tconst absHomedir = path.resolve(tmpDir, homedir);\n\t\tfs.mkdirSync(absHomedir, { recursive: true });\n\t\tvi.stubEnv(\"HOME\", absHomedir);\n\t\tvi.stubEnv(\"XDG_CONFIG_HOME\", path.resolve(absHomedir, \".config\"));\n\t});\n\n\tafterEach(() => {\n\t\tprocess.chdir(originalCwd);\n\t\tremoveDir(tmpDir, { fireAndForget: true });\n\t});\n}\n","// Seeds the `root` directory on the file system with some data. Use in\n\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\n// combination with `dedent` for petty formatting of seeded contents.\nexport async function seed(files: Record<string, string | Uint8Array>) {\n\tfor (const [name, contents] of Object.entries(files)) {\n\t\tconst filePath = path.resolve(name);\n\t\tawait mkdir(path.dirname(filePath), { recursive: true });\n\t\tawait writeFile(filePath, contents);\n\t}\n}\n","import * as fs from \"node:fs\";\nimport { dirname, relative } from \"node:path\";\nimport { formatConfigSnippet } from \"../config\";\nimport { PATH_TO_DEPLOY_CONFIG } from \"../constants\";\nimport { parseJSONC, parseTOML } from \"../parse\";\nimport type { RawConfig } from \"../config\";\nimport type { RedirectedRawConfig } from \"../config/config\";\n\n/** Write a mock wrangler config file to disk. */\nexport function writeWranglerConfig(\n\tconfig: RawConfig = {},\n\tpath = \"./wrangler.toml\"\n) {\n\tconst json = /\\.jsonc?$/.test(path);\n\tfs.mkdirSync(dirname(path), { recursive: true });\n\tfs.writeFileSync(\n\t\tpath,\n\t\tformatConfigSnippet(\n\t\t\t{\n\t\t\t\tcompatibility_date: \"2022-01-12\",\n\t\t\t\tname: \"test-name\",\n\t\t\t\t...config,\n\t\t\t},\n\t\t\tpath,\n\t\t\t!!json\n\t\t),\n\t\t\"utf-8\"\n\t);\n}\n\nexport function writeRedirectedWranglerConfig(\n\tconfig: RedirectedRawConfig,\n\tpath = \"./dist/wrangler.json\"\n) {\n\tconst json = /\\.jsonc?$/.test(path);\n\tfs.mkdirSync(dirname(path), { recursive: true });\n\tfs.writeFileSync(\n\t\tpath,\n\t\tformatConfigSnippet(\n\t\t\t{\n\t\t\t\tcompatibility_date: \"2022-01-12\",\n\t\t\t\tname: \"test-name\",\n\t\t\t\t...config,\n\t\t\t},\n\t\t\tpath,\n\t\t\t!!json\n\t\t),\n\t\t\"utf-8\"\n\t);\n\twriteDeployRedirectConfig(path);\n}\n\nexport function writeDeployRedirectConfig(configPath: string) {\n\tconst config: RedirectedRawConfig = {\n\t\tconfigPath: relative(dirname(PATH_TO_DEPLOY_CONFIG), configPath),\n\t};\n\tfs.mkdirSync(dirname(PATH_TO_DEPLOY_CONFIG), { recursive: true });\n\tfs.writeFileSync(\n\t\tPATH_TO_DEPLOY_CONFIG,\n\t\tformatConfigSnippet(config, \".json\", true),\n\t\t\"utf-8\"\n\t);\n}\n\nexport function readWranglerConfig(path = \"./wrangler.toml\"): RawConfig {\n\tif (path.endsWith(\".toml\")) {\n\t\treturn parseTOML(fs.readFileSync(path, \"utf8\"), path) as RawConfig;\n\t}\n\n\tif (path.endsWith(\".json\") || path.endsWith(\".jsonc\")) {\n\t\treturn parseJSONC(fs.readFileSync(path, \"utf8\"), path) as RawConfig;\n\t}\n\n\treturn {};\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs","sourcesContent":[]}
@@ -1,4 +1,237 @@
1
- export { _forceColour, formatZodError } from './chunk-W7DIL5J2.mjs';
2
- import './chunk-6LYDFTTF.mjs';
1
+ import { __name } from './chunk-PAWJFY3S.mjs';
2
+ import assert from 'node:assert';
3
+ import util from 'node:util';
4
+ import { $, yellow, cyan, blue, magenta, green, dim, red } from 'kleur/colors';
5
+
6
+ const originalEnabled = $.enabled;
7
+ function _forceColour(enabled = originalEnabled) {
8
+ $.enabled = enabled;
9
+ }
10
+ __name(_forceColour, "_forceColour");
11
+ const kMessages = Symbol("kMessages");
12
+ const kActual = Symbol("kActual");
13
+ const kGroupId = Symbol("kGroupId");
14
+ const groupColours = [
15
+ yellow,
16
+ /* (green) */
17
+ cyan,
18
+ blue,
19
+ magenta,
20
+ green
21
+ ];
22
+ const GroupCountsMap = Map;
23
+ function isAnnotation(value) {
24
+ return typeof value === "object" && value !== null && kMessages in value && kActual in value;
25
+ }
26
+ __name(isAnnotation, "isAnnotation");
27
+ function isRecord(value) {
28
+ return typeof value === "object" && value !== null;
29
+ }
30
+ __name(isRecord, "isRecord");
31
+ function arrayShallowEqual(a, b) {
32
+ if (a.length !== b.length) {
33
+ return false;
34
+ }
35
+ for (let i = 0; i < a.length; i++) {
36
+ if (a[i] !== b[i]) {
37
+ return false;
38
+ }
39
+ }
40
+ return true;
41
+ }
42
+ __name(arrayShallowEqual, "arrayShallowEqual");
43
+ function issueEqual(a, b) {
44
+ return a.message === b.message && arrayShallowEqual(a.path, b.path);
45
+ }
46
+ __name(issueEqual, "issueEqual");
47
+ function hasMultipleDistinctMessages(issues, atDepth) {
48
+ let firstIssue;
49
+ for (const issue of issues) {
50
+ if (issue.path.length < atDepth) {
51
+ continue;
52
+ }
53
+ if (firstIssue === void 0) {
54
+ firstIssue = issue;
55
+ } else if (!issueEqual(firstIssue, issue)) {
56
+ return true;
57
+ }
58
+ }
59
+ return false;
60
+ }
61
+ __name(hasMultipleDistinctMessages, "hasMultipleDistinctMessages");
62
+ function annotate(groupCounts, annotated, input, issue, path, groupId) {
63
+ if (path.length === 0) {
64
+ if (issue.code === "invalid_union") {
65
+ const allBranchIssues = issue.errors;
66
+ const unionIssues = allBranchIssues.flat();
67
+ if (unionIssues.length > 0) {
68
+ const multipleDistinct = hasMultipleDistinctMessages(unionIssues, 1);
69
+ let newGroupId;
70
+ if (isRecord(input) && multipleDistinct) {
71
+ newGroupId = groupCounts.size;
72
+ groupCounts.set(newGroupId, 0);
73
+ }
74
+ for (const branchIssues of allBranchIssues) {
75
+ for (const unionIssue of branchIssues) {
76
+ const unionPath = unionIssue.path;
77
+ if (multipleDistinct && unionPath.length === 0) {
78
+ continue;
79
+ }
80
+ annotated = annotate(
81
+ groupCounts,
82
+ annotated,
83
+ input,
84
+ unionIssue,
85
+ unionPath,
86
+ newGroupId
87
+ );
88
+ }
89
+ }
90
+ return annotated;
91
+ }
92
+ }
93
+ const message = issue.message;
94
+ if (annotated !== void 0) {
95
+ if (isAnnotation(annotated) && !annotated[kMessages].includes(message)) {
96
+ annotated[kMessages].push(message);
97
+ }
98
+ return annotated;
99
+ }
100
+ if (groupId !== void 0) {
101
+ const current = groupCounts.get(groupId);
102
+ assert(current !== void 0);
103
+ groupCounts.set(groupId, current + 1);
104
+ }
105
+ return {
106
+ [kMessages]: [message],
107
+ [kActual]: input,
108
+ [kGroupId]: groupId
109
+ };
110
+ }
111
+ const [head, ...tail] = path;
112
+ assert(isRecord(input), "Expected object/array input for nested issue");
113
+ if (annotated === void 0) {
114
+ if (Array.isArray(input)) {
115
+ annotated = new Array(input.length);
116
+ } else {
117
+ const entries = Object.keys(input).map((key) => [key, void 0]);
118
+ annotated = Object.fromEntries(entries);
119
+ }
120
+ }
121
+ assert(isRecord(annotated), "Expected object/array for nested issue");
122
+ annotated[head] = annotate(
123
+ groupCounts,
124
+ annotated[head],
125
+ input[head],
126
+ issue,
127
+ tail,
128
+ groupId
129
+ );
130
+ return annotated;
131
+ }
132
+ __name(annotate, "annotate");
133
+ function print(inspectOptions, groupCounts, annotated, indent = "", extras) {
134
+ const prefix = extras?.prefix ?? "";
135
+ const suffix = extras?.suffix ?? "";
136
+ if (isAnnotation(annotated)) {
137
+ const prefixIndent = indent + " ".repeat(prefix.length);
138
+ const actual = util.inspect(annotated[kActual], inspectOptions);
139
+ const actualIndented = actual.split("\n").map((line, i) => i > 0 ? prefixIndent + line : line).join("\n");
140
+ let messageColour = red;
141
+ let messagePrefix = prefixIndent + "^";
142
+ let groupOr = "";
143
+ if (annotated[kGroupId] !== void 0) {
144
+ messageColour = groupColours[annotated[kGroupId] % groupColours.length];
145
+ messagePrefix += annotated[kGroupId] + 1;
146
+ const remaining = groupCounts.get(annotated[kGroupId]);
147
+ assert(remaining !== void 0);
148
+ if (remaining > 1) {
149
+ groupOr = " *or*";
150
+ }
151
+ groupCounts.set(annotated[kGroupId], remaining - 1);
152
+ }
153
+ messagePrefix += " ";
154
+ const messageIndent = " ".repeat(messagePrefix.length);
155
+ const messageIndented = annotated[kMessages].flatMap((m) => m.split("\n")).map((line, i) => i > 0 ? messageIndent + line : line).join("\n");
156
+ const error = messageColour(`${messagePrefix}${messageIndented}${groupOr}`);
157
+ return `${indent}${dim(prefix)}${actualIndented}${dim(suffix)}
158
+ ${error}`;
159
+ } else if (Array.isArray(annotated)) {
160
+ let result = `${indent}${dim(`${prefix}[`)}
161
+ `;
162
+ const arrayIndent = indent + " ";
163
+ for (let i = 0; i < annotated.length; i++) {
164
+ const value = annotated[i];
165
+ if (value === void 0 && (i === 0 || annotated[i - 1] !== void 0)) {
166
+ result += `${arrayIndent}${dim("...,")}
167
+ `;
168
+ }
169
+ if (value !== void 0) {
170
+ result += print(inspectOptions, groupCounts, value, arrayIndent, {
171
+ prefix: `/* [${i}] */ `,
172
+ suffix: ","
173
+ });
174
+ result += "\n";
175
+ }
176
+ }
177
+ result += `${indent}${dim(`]${suffix}`)}`;
178
+ return result;
179
+ } else if (isRecord(annotated)) {
180
+ let result = `${indent}${dim(`${prefix}{`)}
181
+ `;
182
+ const objectIndent = indent + " ";
183
+ const entries = Object.entries(annotated);
184
+ for (let i = 0; i < entries.length; i++) {
185
+ const [key, value] = entries[i];
186
+ if (value === void 0 && (i === 0 || entries[i - 1][1] !== void 0)) {
187
+ result += `${objectIndent}${dim("...,")}
188
+ `;
189
+ }
190
+ if (value !== void 0) {
191
+ result += print(inspectOptions, groupCounts, value, objectIndent, {
192
+ prefix: `${key}: `,
193
+ suffix: ","
194
+ });
195
+ result += "\n";
196
+ }
197
+ }
198
+ result += `${indent}${dim(`}${suffix}`)}`;
199
+ return result;
200
+ }
201
+ return "";
202
+ }
203
+ __name(print, "print");
204
+ function formatZodError(error, input) {
205
+ const sortedIssues = Array.from(error.issues).sort((a, b) => {
206
+ if (a.code !== b.code) {
207
+ if (a.code === "invalid_union") {
208
+ return -1;
209
+ }
210
+ if (b.code === "invalid_union") {
211
+ return 1;
212
+ }
213
+ }
214
+ return 0;
215
+ });
216
+ let annotated;
217
+ const groupCounts = new GroupCountsMap();
218
+ for (const issue of sortedIssues) {
219
+ annotated = annotate(
220
+ groupCounts,
221
+ annotated,
222
+ input,
223
+ issue,
224
+ issue.path
225
+ );
226
+ }
227
+ const inspectOptions = {
228
+ depth: 0,
229
+ colors: $.enabled
230
+ };
231
+ return print(inspectOptions, groupCounts, annotated);
232
+ }
233
+ __name(formatZodError, "formatZodError");
234
+
235
+ export { _forceColour, formatZodError };
3
236
  //# sourceMappingURL=zod-format.mjs.map
4
237
  //# sourceMappingURL=zod-format.mjs.map