@effect-uai/core 0.16.0 → 0.18.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.
- package/README.md +1 -1
- package/dist/decision-model/Decision.d.mts +155 -0
- package/dist/decision-model/Decision.d.mts.map +1 -0
- package/dist/decision-model/Decision.mjs +118 -0
- package/dist/decision-model/Decision.mjs.map +1 -0
- package/dist/decision-model/Decision.test.d.mts +1 -0
- package/dist/decision-model/Decision.test.mjs +164 -0
- package/dist/decision-model/Decision.test.mjs.map +1 -0
- package/dist/decision-model/DecisionModel.d.mts +45 -0
- package/dist/decision-model/DecisionModel.d.mts.map +1 -0
- package/dist/decision-model/DecisionModel.mjs +25 -0
- package/dist/decision-model/DecisionModel.mjs.map +1 -0
- package/dist/dist-C8RmtoR8.mjs +172 -0
- package/dist/dist-C8RmtoR8.mjs.map +1 -0
- package/dist/dist-CorQTQL-.mjs +1533 -0
- package/dist/dist-CorQTQL-.mjs.map +1 -0
- package/dist/dist-DNeuh84d.mjs +7 -0
- package/dist/dist-DNeuh84d.mjs.map +1 -0
- package/dist/dist-DzeSyeYF.mjs +10253 -0
- package/dist/dist-DzeSyeYF.mjs.map +1 -0
- package/dist/domain/Transcript.test.mjs +3 -3
- package/dist/domain/Turn.test.mjs +2 -2
- package/dist/embedding-model/EmbeddingModel.test.mjs +2 -2
- package/dist/embedding-model/EmbeddingModel.test.mjs.map +1 -1
- package/dist/index.C4tKZ0yW-LuFnBtmu.mjs +7042 -0
- package/dist/index.C4tKZ0yW-LuFnBtmu.mjs.map +1 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +4 -1
- package/dist/language-model/LanguageModel.test.mjs +2 -2
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.mjs +3 -3
- package/dist/math/Probability.d.mts +21 -0
- package/dist/math/Probability.d.mts.map +1 -0
- package/dist/math/Probability.mjs +31 -0
- package/dist/math/Probability.mjs.map +1 -0
- package/dist/math/Probability.test.d.mts +1 -0
- package/dist/math/Probability.test.mjs +95 -0
- package/dist/math/Probability.test.mjs.map +1 -0
- package/dist/messenger/MessengerAdapter.test.mjs +3 -3
- package/dist/music-generator/MusicGenerator.test.mjs +3 -3
- package/dist/observability/Metrics.test.mjs +3 -3
- package/dist/observability/Telemetry.d.mts +1 -1
- package/dist/observability/Telemetry.mjs +1 -1
- package/dist/observability/Telemetry.mjs.map +1 -1
- package/dist/observability/Telemetry.test.mjs +4 -4
- package/dist/observability/Telemetry.test.mjs.map +1 -1
- package/dist/realtime/RealtimeSession.test.mjs +4 -4
- package/dist/retry/Retry.test.mjs +2 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +3 -3
- package/dist/streaming/JSONL.test.mjs +2 -2
- package/dist/streaming/Multipart.d.mts +1 -1
- package/dist/streaming/Multipart.mjs +1 -1
- package/dist/streaming/Multipart.mjs.map +1 -1
- package/dist/streaming/SSE.d.mts +1 -1
- package/dist/streaming/SSE.mjs +2 -2
- package/dist/streaming/SSE.mjs.map +1 -1
- package/dist/streaming/SSE.test.mjs +2 -2
- package/dist/streaming/Settle.test.mjs +3 -3
- package/dist/streaming/WebSocketSession.d.mts +5 -3
- package/dist/streaming/WebSocketSession.d.mts.map +1 -1
- package/dist/streaming/WebSocketSession.mjs +22 -10
- package/dist/streaming/WebSocketSession.mjs.map +1 -1
- package/dist/streaming/WebSocketSession.test.mjs +41 -5
- package/dist/streaming/WebSocketSession.test.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/structured-format/StructuredFormat.test.mjs +2 -2
- package/dist/testing/FakeWebSocket.d.mts +5 -1
- package/dist/testing/FakeWebSocket.d.mts.map +1 -1
- package/dist/testing/FakeWebSocket.mjs +12 -6
- package/dist/testing/FakeWebSocket.mjs.map +1 -1
- package/dist/tool/Approval.test.mjs +2 -2
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/Tool.test.mjs +3 -3
- package/dist/tool/Toolkit.test.mjs +3 -3
- package/dist/transcriber/Transcriber.test.mjs +3 -3
- package/package.json +15 -3
- package/src/decision-model/Decision.test.ts +146 -0
- package/src/decision-model/Decision.ts +273 -0
- package/src/decision-model/DecisionModel.ts +53 -0
- package/src/embedding-model/EmbeddingModel.test.ts +2 -2
- package/src/index.ts +3 -0
- package/src/loop/Loop.ts +1 -1
- package/src/math/Probability.test.ts +61 -0
- package/src/math/Probability.ts +44 -0
- package/src/observability/Telemetry.test.ts +1 -1
- package/src/observability/Telemetry.ts +2 -2
- package/src/streaming/Multipart.ts +1 -1
- package/src/streaming/SSE.ts +2 -2
- package/src/streaming/WebSocketSession.test.ts +54 -2
- package/src/streaming/WebSocketSession.ts +27 -6
- package/src/structured-format/StructuredFormat.ts +1 -1
- package/src/testing/FakeWebSocket.ts +21 -6
- package/src/tool/Tool.ts +1 -1
- package/dist/dist-BaenoU1A.mjs +0 -145
- package/dist/dist-BaenoU1A.mjs.map +0 -1
- package/dist/dist-nohcnkD6.mjs +0 -182
- package/dist/dist-nohcnkD6.mjs.map +0 -1
- package/dist/magic-string.es-CB2hOw9v.mjs +0 -1014
- package/dist/magic-string.es-CB2hOw9v.mjs.map +0 -1
- package/dist/test.DNmyFkvJ-YPzDR0Co.mjs +0 -10254
- package/dist/test.DNmyFkvJ-YPzDR0Co.mjs.map +0 -1
- package/dist/utils-CiH_DjFW.mjs +0 -3918
- package/dist/utils-CiH_DjFW.mjs.map +0 -1
package/dist/dist-nohcnkD6.mjs
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { m as it$1, n as beforeAll, o as describe, r as beforeEach, t as afterAll } from "./utils-CiH_DjFW.mjs";
|
|
2
|
-
import { t as TestRunner } from "./test.DNmyFkvJ-YPzDR0Co.mjs";
|
|
3
|
-
import * as Cause from "effect/Cause";
|
|
4
|
-
import * as Duration from "effect/Duration";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
|
-
import * as Exit from "effect/Exit";
|
|
7
|
-
import { flow, pipe } from "effect/Function";
|
|
8
|
-
import * as Layer from "effect/Layer";
|
|
9
|
-
import { isObject } from "effect/Predicate";
|
|
10
|
-
import * as Rec from "effect/Record";
|
|
11
|
-
import * as Schedule from "effect/Schedule";
|
|
12
|
-
import * as Schema from "effect/Schema";
|
|
13
|
-
import * as Scope from "effect/Scope";
|
|
14
|
-
import * as fc from "effect/testing/FastCheck";
|
|
15
|
-
import * as TestClock from "effect/testing/TestClock";
|
|
16
|
-
import * as TestConsole from "effect/testing/TestConsole";
|
|
17
|
-
//#region ../../node_modules/.pnpm/@effect+vitest@4.0.0-rc.111_effect@4.0.0-rc.111_vitest@4.1.11_@types+node@26.2.0_vite@7_0a4161190c2476edad4e3173ad651095/node_modules/@effect/vitest/dist/internal/internal.js
|
|
18
|
-
/**
|
|
19
|
-
* @since 4.0.0
|
|
20
|
-
*/
|
|
21
|
-
const getCurrentSuite = TestRunner.getCurrentSuite;
|
|
22
|
-
const runPromise = /*#__PURE__*/ Effect.fnUntraced(function* (effect, _ctx) {
|
|
23
|
-
const exit = yield* Effect.exit(effect);
|
|
24
|
-
if (Exit.isFailure(exit)) {
|
|
25
|
-
const errors = Cause.prettyErrors(exit.cause);
|
|
26
|
-
for (let i = 0; i < errors.length; i++) yield* Effect.logError(errors[i]);
|
|
27
|
-
}
|
|
28
|
-
return yield* exit;
|
|
29
|
-
}, (effect, _, ctx) => Effect.runPromise(effect, { signal: ctx?.signal }));
|
|
30
|
-
/** @internal */
|
|
31
|
-
const runTest = (ctx) => (effect) => runPromise(effect, ctx);
|
|
32
|
-
const TestEnv = /*#__PURE__*/ Layer.mergeAll(TestConsole.layer, /*#__PURE__*/ TestClock.layer());
|
|
33
|
-
/** @internal */
|
|
34
|
-
const testOptions = (timeout) => typeof timeout === "number" ? { timeout } : timeout ?? {};
|
|
35
|
-
const hookTimeout = (timeout) => timeout === void 0 ? void 0 : Duration.toMillis(Duration.fromInputUnsafe(timeout));
|
|
36
|
-
const makeItProxy = (it, overrides) => new Proxy(it, {
|
|
37
|
-
apply(target, thisArg, argArray) {
|
|
38
|
-
return Reflect.apply(target, thisArg, argArray);
|
|
39
|
-
},
|
|
40
|
-
get(target, property, receiver) {
|
|
41
|
-
if (Object.hasOwn(overrides, property)) return Reflect.get(overrides, property);
|
|
42
|
-
return Reflect.get(target, property, receiver);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const collectTasks = (tasks, acc = []) => {
|
|
46
|
-
for (let i = 0; i < tasks.length; i++) {
|
|
47
|
-
const task = tasks[i];
|
|
48
|
-
if (task.type === "test" && task.mode !== "skip" && task.mode !== "todo") acc.push(task);
|
|
49
|
-
else if (task.tasks !== void 0) collectTasks(task.tasks, acc);
|
|
50
|
-
}
|
|
51
|
-
return acc;
|
|
52
|
-
};
|
|
53
|
-
/** @internal */
|
|
54
|
-
const makeTester = (mapEffect, it = it$1) => {
|
|
55
|
-
const run = (ctx, args, self) => pipe(Effect.suspend(() => self(...args)), mapEffect, runTest(ctx));
|
|
56
|
-
const f = (name, self, timeout) => it(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
57
|
-
const skip = (name, self, timeout) => it.skip(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
58
|
-
const skipIf = (condition) => (name, self, timeout) => it.skipIf(condition)(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
59
|
-
const runIf = (condition) => (name, self, timeout) => it.runIf(condition)(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
60
|
-
const only = (name, self, timeout) => it.only(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
61
|
-
const each = (cases) => (name, self, timeout) => it.for(cases)(name, testOptions(timeout), (args, ctx) => run(ctx, [args], self));
|
|
62
|
-
const fails = (name, self, timeout) => it$1.fails(name, testOptions(timeout), (ctx) => run(ctx, [ctx], self));
|
|
63
|
-
const prop = (name, arbitraries, self, timeout) => {
|
|
64
|
-
if (Array.isArray(arbitraries)) {
|
|
65
|
-
const arbs = arbitraries.map((arbitrary) => {
|
|
66
|
-
if (Schema.isSchema(arbitrary)) return Schema.toArbitrary(arbitrary)(fc);
|
|
67
|
-
return arbitrary;
|
|
68
|
-
});
|
|
69
|
-
return it(name, testOptions(timeout), (ctx) => fc.assert(fc.asyncProperty(...arbs, (...as) => run(ctx, [as, ctx], self)), isObject(timeout) ? timeout?.fastCheck : {}));
|
|
70
|
-
}
|
|
71
|
-
const arbs = fc.record(Object.keys(arbitraries).reduce(function(result, key) {
|
|
72
|
-
const arb = arbitraries[key];
|
|
73
|
-
Rec.assignProperty(result, key, Schema.isSchema(arb) ? Schema.toArbitrary(arb)(fc) : arb);
|
|
74
|
-
return result;
|
|
75
|
-
}, {}));
|
|
76
|
-
return it(name, testOptions(timeout), (ctx) => fc.assert(fc.asyncProperty(arbs, (...as) => run(ctx, [as[0], ctx], self)), isObject(timeout) ? timeout?.fastCheck : {}));
|
|
77
|
-
};
|
|
78
|
-
return Object.assign(f, {
|
|
79
|
-
skip,
|
|
80
|
-
skipIf,
|
|
81
|
-
runIf,
|
|
82
|
-
only,
|
|
83
|
-
each,
|
|
84
|
-
fails,
|
|
85
|
-
prop
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
/** @internal */
|
|
89
|
-
const prop = (name, arbitraries, self, timeout) => {
|
|
90
|
-
if (Array.isArray(arbitraries)) {
|
|
91
|
-
const arbs = arbitraries.map((arbitrary) => {
|
|
92
|
-
if (Schema.isSchema(arbitrary)) throw new Error("Schemas are not supported yet");
|
|
93
|
-
return arbitrary;
|
|
94
|
-
});
|
|
95
|
-
return it$1(name, testOptions(timeout), (ctx) => fc.assert(fc.property(...arbs, (...as) => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));
|
|
96
|
-
}
|
|
97
|
-
const arbs = fc.record(Object.keys(arbitraries).reduce(function(result, key) {
|
|
98
|
-
const arb = arbitraries[key];
|
|
99
|
-
if (Schema.isSchema(arb)) throw new Error("Schemas are not supported yet");
|
|
100
|
-
Rec.assignProperty(result, key, arb);
|
|
101
|
-
return result;
|
|
102
|
-
}, {}));
|
|
103
|
-
return it$1(name, testOptions(timeout), (ctx) => fc.assert(fc.property(arbs, (as) => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));
|
|
104
|
-
};
|
|
105
|
-
/** @internal */
|
|
106
|
-
const layer = (layer_, options) => (...args) => {
|
|
107
|
-
const excludeTestServices = options?.excludeTestServices ?? false;
|
|
108
|
-
const withTestEnv = excludeTestServices ? layer_ : Layer.provideMerge(layer_, TestEnv);
|
|
109
|
-
const memoMap = options?.memoMap ?? Effect.runSync(Layer.makeMemoMap);
|
|
110
|
-
const scope = Effect.runSync(Scope.make());
|
|
111
|
-
const contextEffect = Layer.buildWithMemoMap(withTestEnv, memoMap, scope).pipe(Effect.orDie, Effect.cached, Effect.runSync);
|
|
112
|
-
let closed = false;
|
|
113
|
-
const closeScope = (ctx) => {
|
|
114
|
-
if (closed) return Promise.resolve();
|
|
115
|
-
closed = true;
|
|
116
|
-
return runPromise(Scope.close(scope, Exit.void), ctx);
|
|
117
|
-
};
|
|
118
|
-
const makeIt = (it) => makeItProxy(it, {
|
|
119
|
-
effect: makeTester((effect) => Effect.flatMap(contextEffect, (context) => effect.pipe(Effect.scoped, Effect.provide(context))), it),
|
|
120
|
-
prop,
|
|
121
|
-
flakyTest,
|
|
122
|
-
layer(nestedLayer, options) {
|
|
123
|
-
return layer(Layer.provideMerge(nestedLayer, withTestEnv), {
|
|
124
|
-
...options,
|
|
125
|
-
memoMap: Layer.forkMemoMapUnsafe(memoMap),
|
|
126
|
-
excludeTestServices
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
if (args.length === 1) {
|
|
131
|
-
const currentSuite = getCurrentSuite();
|
|
132
|
-
const previousTasks = new Set(currentSuite.tasks);
|
|
133
|
-
args[0](makeIt(it$1));
|
|
134
|
-
const blockTasks = collectTasks(currentSuite.tasks.filter((task) => !previousTasks.has(task)));
|
|
135
|
-
if (blockTasks.length === 0) {
|
|
136
|
-
afterAll(() => closeScope(), hookTimeout(options?.timeout));
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const blockTaskSet = new Set(blockTasks);
|
|
140
|
-
let remaining = blockTasks.length;
|
|
141
|
-
beforeEach((ctx) => {
|
|
142
|
-
if (!blockTaskSet.has(ctx.task)) return;
|
|
143
|
-
ctx.onTestFinished(() => {
|
|
144
|
-
remaining--;
|
|
145
|
-
if (remaining === 0) return closeScope(ctx);
|
|
146
|
-
});
|
|
147
|
-
return runPromise(Effect.asVoid(contextEffect), ctx);
|
|
148
|
-
}, hookTimeout(options?.timeout));
|
|
149
|
-
afterAll(() => closeScope(), hookTimeout(options?.timeout));
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
return describe(args[0], () => {
|
|
153
|
-
beforeAll(() => runPromise(Effect.asVoid(contextEffect)), hookTimeout(options?.timeout));
|
|
154
|
-
afterAll(() => closeScope(), hookTimeout(options?.timeout));
|
|
155
|
-
return args[1](makeIt(it$1));
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
/** @internal */
|
|
159
|
-
const flakyTest = (self, timeout = Duration.seconds(30)) => pipe(self, Effect.scoped, Effect.sandbox, Effect.retry(pipe(Schedule.recurs(10), Schedule.while((_) => Effect.succeed(Duration.isLessThanOrEqualTo(Duration.fromInputUnsafe(_.elapsed), Duration.fromInputUnsafe(timeout)))))), Effect.orDie);
|
|
160
|
-
/** @internal */
|
|
161
|
-
const makeMethods = (it) => makeItProxy(it, {
|
|
162
|
-
effect: makeTester(flow(Effect.scoped, Effect.provide(TestEnv)), it),
|
|
163
|
-
live: makeTester(Effect.scoped, it),
|
|
164
|
-
flakyTest,
|
|
165
|
-
layer,
|
|
166
|
-
prop
|
|
167
|
-
});
|
|
168
|
-
/** @internal */
|
|
169
|
-
const { effect, live } = /*#__PURE__*/ makeMethods(it$1);
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region ../../node_modules/.pnpm/@effect+vitest@4.0.0-rc.111_effect@4.0.0-rc.111_vitest@4.1.11_@types+node@26.2.0_vite@7_0a4161190c2476edad4e3173ad651095/node_modules/@effect/vitest/dist/index.js
|
|
172
|
-
/**
|
|
173
|
-
* @since 4.0.0
|
|
174
|
-
*/
|
|
175
|
-
/**
|
|
176
|
-
* @since 4.0.0
|
|
177
|
-
*/
|
|
178
|
-
const it = /*#__PURE__*/ makeMethods(it$1);
|
|
179
|
-
//#endregion
|
|
180
|
-
export { it as t };
|
|
181
|
-
|
|
182
|
-
//# sourceMappingURL=dist-nohcnkD6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dist-nohcnkD6.mjs","names":["V.it","V.describe","V.it"],"sources":["../../../node_modules/.pnpm/@effect+vitest@4.0.0-rc.111_effect@4.0.0-rc.111_vitest@4.1.11_@types+node@26.2.0_vite@7_0a4161190c2476edad4e3173ad651095/node_modules/@effect/vitest/dist/internal/internal.js","../../../node_modules/.pnpm/@effect+vitest@4.0.0-rc.111_effect@4.0.0-rc.111_vitest@4.1.11_@types+node@26.2.0_vite@7_0a4161190c2476edad4e3173ad651095/node_modules/@effect/vitest/dist/index.js"],"sourcesContent":["/**\n * @since 4.0.0\n */\nimport * as Cause from \"effect/Cause\";\nimport * as Duration from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport { flow, pipe } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport { isObject } from \"effect/Predicate\";\nimport * as Rec from \"effect/Record\";\nimport * as Schedule from \"effect/Schedule\";\nimport * as Schema from \"effect/Schema\";\nimport * as Scope from \"effect/Scope\";\nimport * as fc from \"effect/testing/FastCheck\";\nimport * as TestClock from \"effect/testing/TestClock\";\nimport * as TestConsole from \"effect/testing/TestConsole\";\nimport * as V from \"vitest\";\nconst getCurrentSuite = V.TestRunner.getCurrentSuite;\nconst runPromise = /*#__PURE__*/Effect.fnUntraced(function* (effect, _ctx) {\n const exit = yield* Effect.exit(effect);\n if (Exit.isFailure(exit)) {\n const errors = Cause.prettyErrors(exit.cause);\n for (let i = 0; i < errors.length; i++) {\n yield* Effect.logError(errors[i]);\n }\n }\n return yield* exit;\n}, (effect, _, ctx) => Effect.runPromise(effect, {\n signal: ctx?.signal\n}));\n/** @internal */\nconst runTest = ctx => effect => runPromise(effect, ctx);\nconst TestEnv = /*#__PURE__*/Layer.mergeAll(TestConsole.layer, /*#__PURE__*/TestClock.layer());\n/** @internal */\nexport const addEqualityTesters = () => {\n V.expect.addEqualityTesters([]);\n};\n/** @internal */\nconst testOptions = timeout => typeof timeout === \"number\" ? {\n timeout\n} : timeout ?? {};\nconst hookTimeout = timeout => timeout === undefined ? undefined : Duration.toMillis(Duration.fromInputUnsafe(timeout));\nconst makeItProxy = (it, overrides) => new Proxy(it, {\n apply(target, thisArg, argArray) {\n return Reflect.apply(target, thisArg, argArray);\n },\n get(target, property, receiver) {\n if (Object.hasOwn(overrides, property)) {\n return Reflect.get(overrides, property);\n }\n // do not bind: binding would strip vitest's static helpers (e.g. `describe.each`)\n return Reflect.get(target, property, receiver);\n }\n});\nconst collectTasks = (tasks, acc = []) => {\n for (let i = 0; i < tasks.length; i++) {\n const task = tasks[i];\n if (task.type === \"test\" && task.mode !== \"skip\" && task.mode !== \"todo\") {\n acc.push(task);\n } else if (task.tasks !== undefined) {\n collectTasks(task.tasks, acc);\n }\n }\n return acc;\n};\n/** @internal */\nconst makeTester = (mapEffect, it = V.it) => {\n const run = (ctx, args, self) => pipe(Effect.suspend(() => self(...args)), mapEffect, runTest(ctx));\n const f = (name, self, timeout) => it(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const skip = (name, self, timeout) => it.skip(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const skipIf = condition => (name, self, timeout) => it.skipIf(condition)(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const runIf = condition => (name, self, timeout) => it.runIf(condition)(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const only = (name, self, timeout) => it.only(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const each = cases => (name, self, timeout) => it.for(cases)(name, testOptions(timeout), (args, ctx) => run(ctx, [args], self));\n const fails = (name, self, timeout) => V.it.fails(name, testOptions(timeout), ctx => run(ctx, [ctx], self));\n const prop = (name, arbitraries, self, timeout) => {\n if (Array.isArray(arbitraries)) {\n const arbs = arbitraries.map(arbitrary => {\n if (Schema.isSchema(arbitrary)) {\n return Schema.toArbitrary(arbitrary)(fc);\n }\n return arbitrary;\n });\n return it(name, testOptions(timeout), ctx =>\n // @ts-ignore\n fc.assert(\n // @ts-ignore\n fc.asyncProperty(...arbs, (...as) => run(ctx, [as, ctx], self)),\n // @ts-ignore\n isObject(timeout) ? timeout?.fastCheck : {}));\n }\n const arbs = fc.record(Object.keys(arbitraries).reduce(function (result, key) {\n const arb = arbitraries[key];\n Rec.assignProperty(result, key, Schema.isSchema(arb) ? Schema.toArbitrary(arb)(fc) : arb);\n return result;\n }, {}));\n return it(name, testOptions(timeout), ctx =>\n // @ts-ignore\n fc.assert(fc.asyncProperty(arbs, (...as) =>\n // @ts-ignore\n run(ctx, [as[0], ctx], self)),\n // @ts-ignore\n isObject(timeout) ? timeout?.fastCheck : {}));\n };\n return Object.assign(f, {\n skip,\n skipIf,\n runIf,\n only,\n each,\n fails,\n prop\n });\n};\n/** @internal */\nexport const prop = (name, arbitraries, self, timeout) => {\n if (Array.isArray(arbitraries)) {\n const arbs = arbitraries.map(arbitrary => {\n if (Schema.isSchema(arbitrary)) {\n throw new Error(\"Schemas are not supported yet\");\n }\n return arbitrary;\n });\n return V.it(name, testOptions(timeout),\n // @ts-ignore\n ctx => fc.assert(fc.property(...arbs, (...as) => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));\n }\n const arbs = fc.record(Object.keys(arbitraries).reduce(function (result, key) {\n const arb = arbitraries[key];\n if (Schema.isSchema(arb)) {\n throw new Error(\"Schemas are not supported yet\");\n }\n Rec.assignProperty(result, key, arb);\n return result;\n }, {}));\n return V.it(name, testOptions(timeout),\n // @ts-ignore\n ctx => fc.assert(fc.property(arbs, as => self(as, ctx)), isObject(timeout) ? timeout?.fastCheck : {}));\n};\n/** @internal */\nexport const layer = (layer_, options) => (...args) => {\n const excludeTestServices = options?.excludeTestServices ?? false;\n const withTestEnv = excludeTestServices ? layer_ : Layer.provideMerge(layer_, TestEnv);\n const memoMap = options?.memoMap ?? Effect.runSync(Layer.makeMemoMap);\n const scope = Effect.runSync(Scope.make());\n const contextEffect = Layer.buildWithMemoMap(withTestEnv, memoMap, scope).pipe(Effect.orDie, Effect.cached, Effect.runSync);\n let closed = false;\n const closeScope = ctx => {\n if (closed) {\n return Promise.resolve();\n }\n closed = true;\n return runPromise(Scope.close(scope, Exit.void), ctx);\n };\n const makeIt = it => makeItProxy(it, {\n effect: makeTester(effect => Effect.flatMap(contextEffect, context => effect.pipe(Effect.scoped, Effect.provide(context))), it),\n prop,\n flakyTest,\n layer(nestedLayer, options) {\n return layer(Layer.provideMerge(nestedLayer, withTestEnv), {\n ...options,\n memoMap: Layer.forkMemoMapUnsafe(memoMap),\n excludeTestServices\n });\n }\n });\n if (args.length === 1) {\n const currentSuite = getCurrentSuite();\n const previousTasks = new Set(currentSuite.tasks);\n args[0](makeIt(V.it));\n const blockTasks = collectTasks(currentSuite.tasks.filter(task => !previousTasks.has(task)));\n if (blockTasks.length === 0) {\n V.afterAll(() => closeScope(), hookTimeout(options?.timeout));\n return;\n }\n const blockTaskSet = new Set(blockTasks);\n let remaining = blockTasks.length;\n V.beforeEach(ctx => {\n if (!blockTaskSet.has(ctx.task)) {\n return;\n }\n ctx.onTestFinished(() => {\n remaining--;\n if (remaining === 0) {\n return closeScope(ctx);\n }\n });\n return runPromise(Effect.asVoid(contextEffect), ctx);\n }, hookTimeout(options?.timeout));\n V.afterAll(() => closeScope(), hookTimeout(options?.timeout));\n return;\n }\n return V.describe(args[0], () => {\n V.beforeAll(() => runPromise(Effect.asVoid(contextEffect)), hookTimeout(options?.timeout));\n V.afterAll(() => closeScope(), hookTimeout(options?.timeout));\n return args[1](makeIt(V.it));\n });\n};\n/** @internal */\nexport const flakyTest = (self, timeout = Duration.seconds(30)) => pipe(self, Effect.scoped, Effect.sandbox, Effect.retry(pipe(Schedule.recurs(10), Schedule.while(_ => Effect.succeed(Duration.isLessThanOrEqualTo(Duration.fromInputUnsafe(_.elapsed), Duration.fromInputUnsafe(timeout)))))), Effect.orDie);\n/** @internal */\nexport const makeMethods = it => makeItProxy(it, {\n effect: makeTester(flow(Effect.scoped, Effect.provide(TestEnv)), it),\n live: makeTester(Effect.scoped, it),\n flakyTest,\n layer,\n prop\n});\n/** @internal */\nexport const {\n /** @internal */\n effect,\n /** @internal */\n live\n} = /*#__PURE__*/makeMethods(V.it);\n/** @internal */\nexport const describeWrapped = (name, f) => V.describe(name, it => f(makeMethods(it)));\n//# sourceMappingURL=internal.js.map","import * as V from \"vitest\";\nimport * as internal from \"./internal/internal.js\";\n/**\n * @since 4.0.0\n */\nexport * from \"vitest\";\n/**\n * @since 4.0.0\n */\nexport const addEqualityTesters = internal.addEqualityTesters;\n/**\n * @since 4.0.0\n */\nexport const effect = internal.effect;\n/**\n * @since 4.0.0\n */\nexport const live = internal.live;\n/**\n * Share a `Layer` between multiple tests, optionally wrapping\n * the tests in a `describe` block if a name is provided.\n *\n * @since 4.0.0\n *\n * ```ts\n * import { assert, layer } from \"@effect/vitest\"\n * import { Effect, Layer, Context } from \"effect\"\n *\n * class Foo extends Context.Service<Foo, \"foo\">()(\"Foo\") {\n * static layer = Layer.succeed(Foo, \"foo\")\n * }\n *\n * class Bar extends Context.Service<Bar, \"bar\">()(\"Bar\") {\n * static layer = Layer.effect(\n * Bar,\n * Effect.map(Foo, () => \"bar\" as const)\n * )\n * }\n *\n * layer(Foo.layer)(\"layer\", (it) => {\n * it.effect(\"adds context\", () =>\n * Effect.gen(function*() {\n * const foo = yield* Foo\n * assert.strictEqual(foo, \"foo\")\n * }))\n *\n * it.layer(Bar.layer)(\"nested\", (it) => {\n * it.effect(\"adds context\", () =>\n * Effect.gen(function*() {\n * const foo = yield* Foo\n * const bar = yield* Bar\n * assert.strictEqual(foo, \"foo\")\n * assert.strictEqual(bar, \"bar\")\n * }))\n * })\n * })\n * ```\n */\nexport const layer = internal.layer;\n/**\n * @since 4.0.0\n */\nexport const flakyTest = internal.flakyTest;\n/**\n * @since 4.0.0\n */\nexport const prop = internal.prop;\n/**\n * @since 4.0.0\n */\n/**\n * @since 4.0.0\n */\nexport const it = /*#__PURE__*/internal.makeMethods(V.it);\n/**\n * @since 4.0.0\n */\nexport const makeMethods = internal.makeMethods;\n/**\n * @since 4.0.0\n */\nexport const describeWrapped = internal.describeWrapped;\n//# sourceMappingURL=index.js.map"],"x_google_ignoreList":[0,1],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,kBAAA,WAA+B;AACrC,MAAM,aAA0B,qBAAO,WAAW,WAAW,QAAQ,MAAM;CACzE,MAAM,OAAO,OAAO,OAAO,KAAK,MAAM;CACtC,IAAI,KAAK,UAAU,IAAI,GAAG;EACxB,MAAM,SAAS,MAAM,aAAa,KAAK,KAAK;EAC5C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KACjC,OAAO,OAAO,SAAS,OAAO,EAAE;CAEpC;CACA,OAAO,OAAO;AAChB,IAAI,QAAQ,GAAG,QAAQ,OAAO,WAAW,QAAQ,EAC/C,QAAQ,KAAK,OACf,CAAC,CAAC;;AAEF,MAAM,WAAU,SAAO,WAAU,WAAW,QAAQ,GAAG;AACvD,MAAM,UAAuB,oBAAM,SAAS,YAAY,OAAoB,wBAAU,MAAM,CAAC;;AAM7F,MAAM,eAAc,YAAW,OAAO,YAAY,WAAW,EAC3D,QACF,IAAI,WAAW,CAAC;AAChB,MAAM,eAAc,YAAW,YAAY,KAAA,IAAY,KAAA,IAAY,SAAS,SAAS,SAAS,gBAAgB,OAAO,CAAC;AACtH,MAAM,e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