@neon/sdk 0.1.0 → 0.2.0

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 (76) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_rolldown/runtime.js +2 -1
  3. package/dist/neon/client.test-d.d.ts +1 -0
  4. package/dist/neon/client.test-d.js +76 -0
  5. package/dist/neon/client.test-d.js.map +1 -0
  6. package/dist/neon/resources/postgres.d.ts +1 -1
  7. package/dist/neon/resources/postgres.js.map +1 -1
  8. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.0.9/node_modules/@vitest/pretty-format/dist/index.js +879 -0
  9. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.0.9/node_modules/@vitest/pretty-format/dist/index.js.map +1 -0
  10. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/chunk-tasks.js +30 -0
  11. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/chunk-tasks.js.map +1 -0
  12. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/index.js +578 -0
  13. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/index.js.map +1 -0
  14. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +92 -0
  15. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js.map +1 -0
  16. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js +43 -0
  17. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js.map +1 -0
  18. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js +450 -0
  19. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js.map +1 -0
  20. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js +168 -0
  21. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js.map +1 -0
  22. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.js +10 -0
  23. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.js.map +1 -0
  24. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/index.js +109 -0
  25. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/index.js.map +1 -0
  26. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.js +10 -0
  27. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.js.map +1 -0
  28. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.js +10 -0
  29. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.js.map +1 -0
  30. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.js +10 -0
  31. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.js.map +1 -0
  32. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +11 -0
  33. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js.map +1 -0
  34. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +16 -0
  35. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js.map +1 -0
  36. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +11 -0
  37. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js.map +1 -0
  38. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +15 -0
  39. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js.map +1 -0
  40. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +13 -0
  41. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js.map +1 -0
  42. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +34 -0
  43. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js.map +1 -0
  44. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +12 -0
  45. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js.map +1 -0
  46. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +122 -0
  47. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js.map +1 -0
  48. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +39 -0
  49. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js.map +1 -0
  50. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +99 -0
  51. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js.map +1 -0
  52. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +25 -0
  53. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js.map +1 -0
  54. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +14 -0
  55. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js.map +1 -0
  56. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +21 -0
  57. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js.map +1 -0
  58. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +6 -0
  59. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js.map +1 -0
  60. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +12 -0
  61. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js.map +1 -0
  62. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +18 -0
  63. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js.map +1 -0
  64. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +24 -0
  65. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js.map +1 -0
  66. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +9 -0
  67. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js.map +1 -0
  68. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +30 -0
  69. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js.map +1 -0
  70. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +82 -0
  71. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js.map +1 -0
  72. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js +7 -0
  73. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js.map +1 -0
  74. package/dist/node_modules/.pnpm/vitest@3.0.9_@types_debug@4.1.13_@types_node@20.19.17_jiti@2.7.0_jsdom@26.1.0_lightning_fb7ae83398b95c49208c9194029bba02/node_modules/vitest/dist/index.js +8 -0
  75. package/dist/node_modules/.pnpm/vitest@3.0.9_@types_debug@4.1.13_@types_node@20.19.17_jiti@2.7.0_jsdom@26.1.0_lightning_fb7ae83398b95c49208c9194029bba02/node_modules/vitest/dist/index.js.map +1 -0
  76. package/package.json +3 -2
@@ -0,0 +1,578 @@
1
+ import { format, objDisplay } from "../../../../../@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js";
2
+ import { createDefer, isNegativeNaN, isObject, objectAttr, toArray } from "../../../../../@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js";
3
+ import { getSafeTimers } from "../../../../../@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js";
4
+ import { parseSingleStack } from "../../../../../@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js";
5
+ import { createChainable } from "./chunk-tasks.js";
6
+ //#region ../../node_modules/.pnpm/@vitest+runner@3.0.9/node_modules/@vitest/runner/dist/index.js
7
+ var PendingError = class extends Error {
8
+ constructor(message, task, note) {
9
+ super(message);
10
+ this.message = message;
11
+ this.note = note;
12
+ this.taskId = task.id;
13
+ }
14
+ code = "VITEST_PENDING";
15
+ taskId;
16
+ };
17
+ const now$2 = Date.now;
18
+ const collectorContext = {
19
+ tasks: [],
20
+ currentSuite: null
21
+ };
22
+ function collectTask(task) {
23
+ var _a;
24
+ (_a = collectorContext.currentSuite) == null || _a.tasks.push(task);
25
+ }
26
+ async function runWithSuite(suite, fn) {
27
+ const prev = collectorContext.currentSuite;
28
+ collectorContext.currentSuite = suite;
29
+ await fn();
30
+ collectorContext.currentSuite = prev;
31
+ }
32
+ function withTimeout(fn, timeout, isHook = false, stackTraceError) {
33
+ if (timeout <= 0 || timeout === Number.POSITIVE_INFINITY) return fn;
34
+ const { setTimeout, clearTimeout } = getSafeTimers();
35
+ return function runWithTimeout(...args) {
36
+ const startTime = now$2();
37
+ return new Promise((resolve_, reject_) => {
38
+ var _a;
39
+ const timer = setTimeout(() => {
40
+ clearTimeout(timer);
41
+ rejectTimeoutError();
42
+ }, timeout);
43
+ (_a = timer.unref) == null || _a.call(timer);
44
+ function rejectTimeoutError() {
45
+ reject_(makeTimeoutError(isHook, timeout, stackTraceError));
46
+ }
47
+ function resolve(result) {
48
+ clearTimeout(timer);
49
+ if (now$2() - startTime >= timeout) {
50
+ rejectTimeoutError();
51
+ return;
52
+ }
53
+ resolve_(result);
54
+ }
55
+ function reject(error) {
56
+ clearTimeout(timer);
57
+ reject_(error);
58
+ }
59
+ try {
60
+ const result = fn(...args);
61
+ if (typeof result === "object" && result != null && typeof result.then === "function") result.then(resolve, reject);
62
+ else resolve(result);
63
+ } catch (error) {
64
+ reject(error);
65
+ }
66
+ });
67
+ };
68
+ }
69
+ function createTestContext(test, runner) {
70
+ var _a;
71
+ const context = function() {
72
+ throw new Error("done() callback is deprecated, use promise instead");
73
+ };
74
+ context.task = test;
75
+ context.skip = (note) => {
76
+ test.result ?? (test.result = { state: "skip" });
77
+ test.result.pending = true;
78
+ throw new PendingError("test is skipped; abort execution", test, note);
79
+ };
80
+ context.onTestFailed = (handler, timeout) => {
81
+ test.onFailed || (test.onFailed = []);
82
+ test.onFailed.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, /* @__PURE__ */ new Error("STACK_TRACE_ERROR")));
83
+ };
84
+ context.onTestFinished = (handler, timeout) => {
85
+ test.onFinished || (test.onFinished = []);
86
+ test.onFinished.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, /* @__PURE__ */ new Error("STACK_TRACE_ERROR")));
87
+ };
88
+ return ((_a = runner.extendTaskContext) == null ? void 0 : _a.call(runner, context)) || context;
89
+ }
90
+ function makeTimeoutError(isHook, timeout, stackTraceError) {
91
+ const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
92
+ If this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
93
+ const error = new Error(message);
94
+ if (stackTraceError == null ? void 0 : stackTraceError.stack) error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
95
+ return error;
96
+ }
97
+ const fnMap = /* @__PURE__ */ new WeakMap();
98
+ const fixtureMap = /* @__PURE__ */ new WeakMap();
99
+ const hooksMap = /* @__PURE__ */ new WeakMap();
100
+ function setFn(key, fn) {
101
+ fnMap.set(key, fn);
102
+ }
103
+ function setFixture(key, fixture) {
104
+ fixtureMap.set(key, fixture);
105
+ }
106
+ function getFixture(key) {
107
+ return fixtureMap.get(key);
108
+ }
109
+ function setHooks(key, hooks) {
110
+ hooksMap.set(key, hooks);
111
+ }
112
+ function getHooks(key) {
113
+ return hooksMap.get(key);
114
+ }
115
+ function mergeContextFixtures(fixtures, context, inject) {
116
+ const fixtureOptionKeys = ["auto", "injected"];
117
+ const fixtureArray = Object.entries(fixtures).map(([prop, value]) => {
118
+ const fixtureItem = { value };
119
+ if (Array.isArray(value) && value.length >= 2 && isObject(value[1]) && Object.keys(value[1]).some((key) => fixtureOptionKeys.includes(key))) {
120
+ Object.assign(fixtureItem, value[1]);
121
+ const userValue = value[0];
122
+ fixtureItem.value = fixtureItem.injected ? inject(prop) ?? userValue : userValue;
123
+ }
124
+ fixtureItem.prop = prop;
125
+ fixtureItem.isFn = typeof fixtureItem.value === "function";
126
+ return fixtureItem;
127
+ });
128
+ if (Array.isArray(context.fixtures)) context.fixtures = context.fixtures.concat(fixtureArray);
129
+ else context.fixtures = fixtureArray;
130
+ fixtureArray.forEach((fixture) => {
131
+ if (fixture.isFn) {
132
+ const usedProps = getUsedProps(fixture.value);
133
+ if (usedProps.length) fixture.deps = context.fixtures.filter(({ prop }) => prop !== fixture.prop && usedProps.includes(prop));
134
+ }
135
+ });
136
+ return context;
137
+ }
138
+ const fixtureValueMaps = /* @__PURE__ */ new Map();
139
+ const cleanupFnArrayMap = /* @__PURE__ */ new Map();
140
+ function withFixtures(fn, testContext) {
141
+ return (hookContext) => {
142
+ const context = hookContext || testContext;
143
+ if (!context) return fn({});
144
+ const fixtures = getFixture(context);
145
+ if (!(fixtures == null ? void 0 : fixtures.length)) return fn(context);
146
+ const usedProps = getUsedProps(fn);
147
+ const hasAutoFixture = fixtures.some(({ auto }) => auto);
148
+ if (!usedProps.length && !hasAutoFixture) return fn(context);
149
+ if (!fixtureValueMaps.get(context)) fixtureValueMaps.set(context, /* @__PURE__ */ new Map());
150
+ const fixtureValueMap = fixtureValueMaps.get(context);
151
+ if (!cleanupFnArrayMap.has(context)) cleanupFnArrayMap.set(context, []);
152
+ const cleanupFnArray = cleanupFnArrayMap.get(context);
153
+ const pendingFixtures = resolveDeps(fixtures.filter(({ prop, auto }) => auto || usedProps.includes(prop)));
154
+ if (!pendingFixtures.length) return fn(context);
155
+ async function resolveFixtures() {
156
+ for (const fixture of pendingFixtures) {
157
+ if (fixtureValueMap.has(fixture)) continue;
158
+ const resolvedValue = fixture.isFn ? await resolveFixtureFunction(fixture.value, context, cleanupFnArray) : fixture.value;
159
+ context[fixture.prop] = resolvedValue;
160
+ fixtureValueMap.set(fixture, resolvedValue);
161
+ cleanupFnArray.unshift(() => {
162
+ fixtureValueMap.delete(fixture);
163
+ });
164
+ }
165
+ }
166
+ return resolveFixtures().then(() => fn(context));
167
+ };
168
+ }
169
+ async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
170
+ const useFnArgPromise = createDefer();
171
+ let isUseFnArgResolved = false;
172
+ const fixtureReturn = fixtureFn(context, async (useFnArg) => {
173
+ isUseFnArgResolved = true;
174
+ useFnArgPromise.resolve(useFnArg);
175
+ const useReturnPromise = createDefer();
176
+ cleanupFnArray.push(async () => {
177
+ useReturnPromise.resolve();
178
+ await fixtureReturn;
179
+ });
180
+ await useReturnPromise;
181
+ }).catch((e) => {
182
+ if (!isUseFnArgResolved) {
183
+ useFnArgPromise.reject(e);
184
+ return;
185
+ }
186
+ throw e;
187
+ });
188
+ return useFnArgPromise;
189
+ }
190
+ function resolveDeps(fixtures, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
191
+ fixtures.forEach((fixture) => {
192
+ if (pendingFixtures.includes(fixture)) return;
193
+ if (!fixture.isFn || !fixture.deps) {
194
+ pendingFixtures.push(fixture);
195
+ return;
196
+ }
197
+ if (depSet.has(fixture)) throw new Error(`Circular fixture dependency detected: ${fixture.prop} <- ${[...depSet].reverse().map((d) => d.prop).join(" <- ")}`);
198
+ depSet.add(fixture);
199
+ resolveDeps(fixture.deps, depSet, pendingFixtures);
200
+ pendingFixtures.push(fixture);
201
+ depSet.clear();
202
+ });
203
+ return pendingFixtures;
204
+ }
205
+ function getUsedProps(fn) {
206
+ let fnString = fn.toString();
207
+ if (/__async\(this, (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) fnString = fnString.split("__async(this,")[1];
208
+ const match = fnString.match(/[^(]*\(([^)]*)/);
209
+ if (!match) return [];
210
+ const args = splitByComma(match[1]);
211
+ if (!args.length) return [];
212
+ let first = args[0];
213
+ if ("__VITEST_FIXTURE_INDEX__" in fn) {
214
+ first = args[fn.__VITEST_FIXTURE_INDEX__];
215
+ if (!first) return [];
216
+ }
217
+ if (!(first.startsWith("{") && first.endsWith("}"))) throw new Error(`The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "${first}".`);
218
+ const props = splitByComma(first.slice(1, -1).replace(/\s/g, "")).map((prop) => {
219
+ return prop.replace(/:.*|=.*/g, "");
220
+ });
221
+ const last = props.at(-1);
222
+ if (last && last.startsWith("...")) throw new Error(`Rest parameters are not supported in fixtures, received "${last}".`);
223
+ return props;
224
+ }
225
+ function splitByComma(s) {
226
+ const result = [];
227
+ const stack = [];
228
+ let start = 0;
229
+ for (let i = 0; i < s.length; i++) if (s[i] === "{" || s[i] === "[") stack.push(s[i] === "{" ? "}" : "]");
230
+ else if (s[i] === stack[stack.length - 1]) stack.pop();
231
+ else if (!stack.length && s[i] === ",") {
232
+ const token = s.substring(start, i).trim();
233
+ if (token) result.push(token);
234
+ start = i + 1;
235
+ }
236
+ const lastToken = s.substring(start).trim();
237
+ if (lastToken) result.push(lastToken);
238
+ return result;
239
+ }
240
+ const suite = createSuite();
241
+ const test = createTest(function(name, optionsOrFn, optionsOrTest) {
242
+ getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
243
+ });
244
+ const it = test;
245
+ let runner;
246
+ let defaultSuite;
247
+ function assert(condition, message) {
248
+ if (!condition) throw new Error(`Vitest failed to find ${message}. This is a bug in Vitest. Please, open an issue with reproduction.`);
249
+ }
250
+ function getRunner() {
251
+ assert(runner, "the runner");
252
+ }
253
+ function getCurrentSuite() {
254
+ const currentSuite = collectorContext.currentSuite || defaultSuite;
255
+ assert(currentSuite, "the current suite");
256
+ return currentSuite;
257
+ }
258
+ function createSuiteHooks() {
259
+ return {
260
+ beforeAll: [],
261
+ afterAll: [],
262
+ beforeEach: [],
263
+ afterEach: []
264
+ };
265
+ }
266
+ function parseArguments(optionsOrFn, optionsOrTest) {
267
+ let options = {};
268
+ let fn = () => {};
269
+ if (typeof optionsOrTest === "object") {
270
+ if (typeof optionsOrFn === "object") throw new TypeError("Cannot use two objects as arguments. Please provide options and a function callback in that order.");
271
+ console.warn("Using an object as a third argument is deprecated. Vitest 4 will throw an error if the third argument is not a timeout number. Please use the second argument for options. See more at https://vitest.dev/guide/migration");
272
+ options = optionsOrTest;
273
+ } else if (typeof optionsOrTest === "number") options = { timeout: optionsOrTest };
274
+ else if (typeof optionsOrFn === "object") options = optionsOrFn;
275
+ if (typeof optionsOrFn === "function") {
276
+ if (typeof optionsOrTest === "function") throw new TypeError("Cannot use two functions as arguments. Please use the second argument for options.");
277
+ fn = optionsOrFn;
278
+ } else if (typeof optionsOrTest === "function") fn = optionsOrTest;
279
+ return {
280
+ options,
281
+ handler: fn
282
+ };
283
+ }
284
+ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions) {
285
+ const tasks = [];
286
+ let suite2;
287
+ initSuite(true);
288
+ const task = function(name2 = "", options = {}) {
289
+ var _a;
290
+ const timeout = (options == null ? void 0 : options.timeout) ?? runner.config.testTimeout;
291
+ const task2 = {
292
+ id: "",
293
+ name: name2,
294
+ suite: (_a = collectorContext.currentSuite) == null ? void 0 : _a.suite,
295
+ each: options.each,
296
+ fails: options.fails,
297
+ context: void 0,
298
+ type: "test",
299
+ file: void 0,
300
+ timeout,
301
+ retry: options.retry ?? runner.config.retry,
302
+ repeats: options.repeats,
303
+ mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
304
+ meta: options.meta ?? /* @__PURE__ */ Object.create(null)
305
+ };
306
+ const handler = options.handler;
307
+ if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) task2.concurrent = true;
308
+ task2.shuffle = suiteOptions == null ? void 0 : suiteOptions.shuffle;
309
+ const context = createTestContext(task2, runner);
310
+ Object.defineProperty(task2, "context", {
311
+ value: context,
312
+ enumerable: false
313
+ });
314
+ setFixture(context, options.fixtures);
315
+ if (handler) setFn(task2, withTimeout(withAwaitAsyncAssertions(withFixtures(handler, context), task2), timeout));
316
+ if (runner.config.includeTaskLocation) {
317
+ const limit = Error.stackTraceLimit;
318
+ Error.stackTraceLimit = 15;
319
+ const error = (/* @__PURE__ */ new Error("stacktrace")).stack;
320
+ Error.stackTraceLimit = limit;
321
+ const stack = findTestFileStackTrace(error, task2.each ?? false);
322
+ if (stack) task2.location = stack;
323
+ }
324
+ tasks.push(task2);
325
+ return task2;
326
+ };
327
+ const test2 = createTest(function(name2, optionsOrFn, optionsOrTest) {
328
+ let { options, handler } = parseArguments(optionsOrFn, optionsOrTest);
329
+ if (typeof suiteOptions === "object") options = Object.assign({}, suiteOptions, options);
330
+ options.concurrent = this.concurrent || !this.sequential && (options == null ? void 0 : options.concurrent);
331
+ options.sequential = this.sequential || !this.concurrent && (options == null ? void 0 : options.sequential);
332
+ const test3 = task(formatName(name2), {
333
+ ...this,
334
+ ...options,
335
+ handler
336
+ });
337
+ test3.type = "test";
338
+ });
339
+ const collector = {
340
+ type: "collector",
341
+ name,
342
+ mode,
343
+ suite: suite2,
344
+ options: suiteOptions,
345
+ test: test2,
346
+ tasks,
347
+ collect,
348
+ task,
349
+ clear,
350
+ on: addHook
351
+ };
352
+ function addHook(name2, ...fn) {
353
+ getHooks(suite2)[name2].push(...fn);
354
+ }
355
+ function initSuite(includeLocation) {
356
+ var _a;
357
+ if (typeof suiteOptions === "number") suiteOptions = { timeout: suiteOptions };
358
+ suite2 = {
359
+ id: "",
360
+ type: "suite",
361
+ name,
362
+ suite: (_a = collectorContext.currentSuite) == null ? void 0 : _a.suite,
363
+ mode,
364
+ each,
365
+ file: void 0,
366
+ shuffle: suiteOptions == null ? void 0 : suiteOptions.shuffle,
367
+ tasks: [],
368
+ meta: /* @__PURE__ */ Object.create(null),
369
+ concurrent: suiteOptions == null ? void 0 : suiteOptions.concurrent
370
+ };
371
+ setHooks(suite2, createSuiteHooks());
372
+ }
373
+ function clear() {
374
+ tasks.length = 0;
375
+ initSuite(false);
376
+ }
377
+ async function collect(file) {
378
+ if (!file) throw new TypeError("File is required to collect tasks.");
379
+ if (factory) await runWithSuite(collector, () => factory(test2));
380
+ const allChildren = [];
381
+ for (const i of tasks) allChildren.push(i.type === "collector" ? await i.collect(file) : i);
382
+ suite2.file = file;
383
+ suite2.tasks = allChildren;
384
+ allChildren.forEach((task2) => {
385
+ task2.file = file;
386
+ });
387
+ return suite2;
388
+ }
389
+ collectTask(collector);
390
+ return collector;
391
+ }
392
+ function withAwaitAsyncAssertions(fn, task) {
393
+ return async (...args) => {
394
+ const fnResult = await fn(...args);
395
+ if (task.promises) {
396
+ const errors = (await Promise.allSettled(task.promises)).map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
397
+ if (errors.length) throw errors;
398
+ }
399
+ return fnResult;
400
+ };
401
+ }
402
+ function createSuite() {
403
+ function suiteFn(name, factoryOrOptions, optionsOrFactory) {
404
+ var _a;
405
+ const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
406
+ const currentSuite = collectorContext.currentSuite || defaultSuite;
407
+ let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
408
+ const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
409
+ const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
410
+ options = {
411
+ ...currentSuite == null ? void 0 : currentSuite.options,
412
+ ...options,
413
+ shuffle: this.shuffle ?? options.shuffle ?? ((_a = currentSuite == null ? void 0 : currentSuite.options) == null ? void 0 : _a.shuffle) ?? void 0
414
+ };
415
+ const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
416
+ const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
417
+ options.concurrent = isConcurrent && !isSequential;
418
+ options.sequential = isSequential && !isConcurrent;
419
+ return createSuiteCollector(formatName(name), factory, mode, this.each, options);
420
+ }
421
+ suiteFn.each = function(cases, ...args) {
422
+ const suite2 = this.withContext();
423
+ this.setContext("each", true);
424
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
425
+ return (name, optionsOrFn, fnOrOptions) => {
426
+ const _name = formatName(name);
427
+ const arrayOnlyCases = cases.every(Array.isArray);
428
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
429
+ const fnFirst = typeof optionsOrFn === "function" && typeof fnOrOptions === "object";
430
+ cases.forEach((i, idx) => {
431
+ const items = Array.isArray(i) ? i : [i];
432
+ if (fnFirst) if (arrayOnlyCases) suite2(formatTitle(_name, items, idx), () => handler(...items), options);
433
+ else suite2(formatTitle(_name, items, idx), () => handler(i), options);
434
+ else if (arrayOnlyCases) suite2(formatTitle(_name, items, idx), options, () => handler(...items));
435
+ else suite2(formatTitle(_name, items, idx), options, () => handler(i));
436
+ });
437
+ this.setContext("each", void 0);
438
+ };
439
+ };
440
+ suiteFn.for = function(cases, ...args) {
441
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
442
+ return (name, optionsOrFn, fnOrOptions) => {
443
+ const name_ = formatName(name);
444
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
445
+ cases.forEach((item, idx) => {
446
+ suite(formatTitle(name_, toArray(item), idx), options, () => handler(item));
447
+ });
448
+ };
449
+ };
450
+ suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
451
+ suiteFn.runIf = (condition) => condition ? suite : suite.skip;
452
+ return createChainable([
453
+ "concurrent",
454
+ "sequential",
455
+ "shuffle",
456
+ "skip",
457
+ "only",
458
+ "todo"
459
+ ], suiteFn);
460
+ }
461
+ function createTaskCollector(fn, context) {
462
+ const taskFn = fn;
463
+ taskFn.each = function(cases, ...args) {
464
+ const test2 = this.withContext();
465
+ this.setContext("each", true);
466
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
467
+ return (name, optionsOrFn, fnOrOptions) => {
468
+ const _name = formatName(name);
469
+ const arrayOnlyCases = cases.every(Array.isArray);
470
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
471
+ const fnFirst = typeof optionsOrFn === "function" && typeof fnOrOptions === "object";
472
+ cases.forEach((i, idx) => {
473
+ const items = Array.isArray(i) ? i : [i];
474
+ if (fnFirst) if (arrayOnlyCases) test2(formatTitle(_name, items, idx), () => handler(...items), options);
475
+ else test2(formatTitle(_name, items, idx), () => handler(i), options);
476
+ else if (arrayOnlyCases) test2(formatTitle(_name, items, idx), options, () => handler(...items));
477
+ else test2(formatTitle(_name, items, idx), options, () => handler(i));
478
+ });
479
+ this.setContext("each", void 0);
480
+ };
481
+ };
482
+ taskFn.for = function(cases, ...args) {
483
+ const test2 = this.withContext();
484
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
485
+ return (name, optionsOrFn, fnOrOptions) => {
486
+ const _name = formatName(name);
487
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
488
+ cases.forEach((item, idx) => {
489
+ const handlerWrapper = (ctx) => handler(item, ctx);
490
+ handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
491
+ handlerWrapper.toString = () => handler.toString();
492
+ test2(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
493
+ });
494
+ };
495
+ };
496
+ taskFn.skipIf = function(condition) {
497
+ return condition ? this.skip : this;
498
+ };
499
+ taskFn.runIf = function(condition) {
500
+ return condition ? this : this.skip;
501
+ };
502
+ taskFn.extend = function(fixtures) {
503
+ return createTest(function fn2(name, optionsOrFn, optionsOrTest) {
504
+ getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
505
+ }, mergeContextFixtures(fixtures, context || {}, (key) => {
506
+ var _a, _b;
507
+ return (_b = (_a = getRunner()).injectValue) == null ? void 0 : _b.call(_a, key);
508
+ }));
509
+ };
510
+ const _test = createChainable([
511
+ "concurrent",
512
+ "sequential",
513
+ "skip",
514
+ "only",
515
+ "todo",
516
+ "fails"
517
+ ], taskFn);
518
+ if (context) _test.mergeContext(context);
519
+ return _test;
520
+ }
521
+ function createTest(fn, context) {
522
+ return createTaskCollector(fn, context);
523
+ }
524
+ function formatName(name) {
525
+ return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
526
+ }
527
+ function formatTitle(template, items, idx) {
528
+ if (template.includes("%#")) template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/__vitest_escaped_%__/g, "%%");
529
+ const count = template.split("%").length - 1;
530
+ if (template.includes("%f")) (template.match(/%f/g) || []).forEach((_, i) => {
531
+ if (isNegativeNaN(items[i]) || Object.is(items[i], -0)) {
532
+ let occurrence = 0;
533
+ template = template.replace(/%f/g, (match) => {
534
+ occurrence++;
535
+ return occurrence === i + 1 ? "-%f" : match;
536
+ });
537
+ }
538
+ });
539
+ let formatted = format(template, ...items.slice(0, count));
540
+ if (isObject(items[0])) formatted = formatted.replace(/\$([$\w.]+)/g, (_, key) => {
541
+ var _a, _b;
542
+ return objDisplay(objectAttr(items[0], key), { truncate: (_b = (_a = void 0) == null ? void 0 : _a.chaiConfig) == null ? void 0 : _b.truncateThreshold });
543
+ });
544
+ return formatted;
545
+ }
546
+ function formatTemplateString(cases, args) {
547
+ const header = cases.join("").trim().replace(/ /g, "").split("\n").map((i) => i.split("|"))[0];
548
+ const res = [];
549
+ for (let i = 0; i < Math.floor(args.length / header.length); i++) {
550
+ const oneCase = {};
551
+ for (let j = 0; j < header.length; j++) oneCase[header[j]] = args[i * header.length + j];
552
+ res.push(oneCase);
553
+ }
554
+ return res;
555
+ }
556
+ function findTestFileStackTrace(error, each) {
557
+ const lines = error.split("\n").slice(1);
558
+ for (const line of lines) {
559
+ const stack = parseSingleStack(line);
560
+ if (stack && stack.file === void 0) return {
561
+ line: stack.line,
562
+ /**
563
+ * test.each([1, 2])('name')
564
+ * ^ leads here, but should
565
+ * ^ lead here
566
+ * in source maps it's the same boundary, so it just points to the start of it
567
+ */
568
+ column: each ? stack.column + 1 : stack.column
569
+ };
570
+ }
571
+ }
572
+ globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
573
+ globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
574
+ Date.now;
575
+ //#endregion
576
+ export { it, suite, test };
577
+
578
+ //# sourceMappingURL=index.js.map