@livestore/utils-dev 0.0.0-snapshot-82c4ae545fd15dfcd5d210728623057047d50ac1 → 0.0.0-snapshot-4f805b2565782b5e562923f10caa1424e1774787
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/dist/.tsbuildinfo.json +1 -1
- package/dist/node-vitest/Vitest.d.ts +18 -0
- package/dist/node-vitest/Vitest.d.ts.map +1 -0
- package/dist/node-vitest/Vitest.js +21 -0
- package/dist/node-vitest/Vitest.js.map +1 -0
- package/dist/node-vitest/global.d.ts +2 -0
- package/dist/node-vitest/global.d.ts.map +1 -0
- package/dist/node-vitest/{polyfill.js → global.js} +1 -1
- package/dist/node-vitest/global.js.map +1 -0
- package/dist/node-vitest/mod.d.ts +2 -1
- package/dist/node-vitest/mod.d.ts.map +1 -1
- package/dist/node-vitest/mod.js +2 -1
- package/dist/node-vitest/mod.js.map +1 -1
- package/package.json +8 -6
- package/src/node-vitest/Vitest.ts +62 -0
- package/src/node-vitest/mod.ts +3 -1
- package/dist/node-vitest/polyfill.d.ts +0 -2
- package/dist/node-vitest/polyfill.d.ts.map +0 -1
- package/dist/node-vitest/polyfill.js.map +0 -1
- /package/src/node-vitest/{polyfill.ts → global.ts} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as Vitest from '@effect/vitest';
|
|
2
|
+
import { type Cause, Duration, Effect, Layer, type OtelTracer, type Scope } from '@livestore/utils/effect';
|
|
3
|
+
export * from '@effect/vitest';
|
|
4
|
+
export declare const DEBUGGER_ACTIVE: boolean;
|
|
5
|
+
export declare const makeWithTestCtx: <R1 = never, E1 = never>(ctxParams: WithTestCtxParams<R1, E1>) => (testContext: Vitest.TestContext) => <A, E>(self: Effect.Effect<A, E, Scope.Scope | OtelTracer.OtelTracer | R1>) => Effect.Effect<A, Cause.TimeoutException | E1 | E, Scope.Scope>;
|
|
6
|
+
export type WithTestCtxParams<R1 = never, E1 = never> = {
|
|
7
|
+
suffix?: string;
|
|
8
|
+
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>;
|
|
9
|
+
timeout?: Duration.DurationInput;
|
|
10
|
+
forceOtel?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const withTestCtx: <R1 = never, E1 = never>(testContext: Vitest.TestContext, { suffix, makeLayer, timeout, forceOtel, }?: {
|
|
13
|
+
suffix?: string;
|
|
14
|
+
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>;
|
|
15
|
+
timeout?: Duration.DurationInput;
|
|
16
|
+
forceOtel?: boolean;
|
|
17
|
+
}) => <A, E>(self: Effect.Effect<A, E, Scope.Scope | OtelTracer.OtelTracer | R1>) => Effect.Effect<A, E | Cause.TimeoutException | E1, Scope.Scope>;
|
|
18
|
+
//# sourceMappingURL=Vitest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Vitest.d.ts","sourceRoot":"","sources":["../../src/node-vitest/Vitest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAY,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAIpH,cAAc,gBAAgB,CAAA;AAE9B,eAAO,MAAM,eAAe,SAAwE,CAAA;AAEpG,eAAO,MAAM,eAAe,GACzB,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,WAAW,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,MAC5D,aAAa,MAAM,CAAC,WAAW,MAyB/B,CAAC,EAAE,CAAC,wIAxBgC,CAAA;AAEvC,MAAM,MAAM,iBAAiB,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK,IAAI;IACtD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACjF,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAA;IAChC,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,WAAW,GACrB,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK,EACrB,aAAa,MAAM,CAAC,WAAW,EAC/B,6CAKG;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACjF,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAA;IAChC,SAAS,CAAC,EAAE,OAAO,CAAA;CACf,MAEP,CAAC,EAAE,CAAC,EACH,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,GAAG,EAAE,CAAC,KAClE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,gBAAgB,GAAG,EAAE,EAAE,KAAK,CAAC,KAAK,CAqB/D,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as inspector from 'node:inspector';
|
|
2
|
+
import { IS_CI } from '@livestore/utils';
|
|
3
|
+
import { Duration, Effect, identity, Layer } from '@livestore/utils/effect';
|
|
4
|
+
import { OtelLiveDummy } from '@livestore/utils/node';
|
|
5
|
+
import { OtelLiveHttp } from "../node/mod.js";
|
|
6
|
+
export * from '@effect/vitest';
|
|
7
|
+
export const DEBUGGER_ACTIVE = Boolean(process.env.DEBUGGER_ACTIVE ?? inspector.url() !== undefined);
|
|
8
|
+
export const makeWithTestCtx = (ctxParams) => (testContext) => withTestCtx(testContext, ctxParams);
|
|
9
|
+
export const withTestCtx = (testContext, { suffix, makeLayer, timeout = IS_CI ? 60_000 : 10_000, forceOtel = false, } = {}) => (self) => {
|
|
10
|
+
const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix ? `:${suffix}` : ''}`;
|
|
11
|
+
const layer = makeLayer?.(testContext);
|
|
12
|
+
const otelLayer = DEBUGGER_ACTIVE || forceOtel ? OtelLiveHttp({ serviceName: 'vitest-runner', skipLogUrl: false }) : OtelLiveDummy;
|
|
13
|
+
return self.pipe(DEBUGGER_ACTIVE
|
|
14
|
+
? identity
|
|
15
|
+
: Effect.logWarnIfTakesLongerThan({
|
|
16
|
+
duration: Duration.toMillis(timeout) * 0.8,
|
|
17
|
+
label: `${spanName} approaching timeout (timeout: ${Duration.format(timeout)})`,
|
|
18
|
+
}), DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout), Effect.provide(otelLayer), Effect.provide(layer ?? Layer.empty), Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
|
|
19
|
+
Effect.withSpan(spanName), Effect.annotateLogs({ suffix }));
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=Vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Vitest.js","sourceRoot":"","sources":["../../src/node-vitest/Vitest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAc,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAA+B,MAAM,yBAAyB,CAAA;AACpH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,cAAc,gBAAgB,CAAA;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,C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,CAAC,EACpD,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EACzB,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,EACpC,MAAM,CAAC,MAAM,EAAE,qFAAqF;IACpG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EACzB,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,CACzB,CAAA;AACV,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/node-vitest/global.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/node-vitest/global.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/node-vitest/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/node-vitest/mod.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
|
package/dist/node-vitest/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/node-vitest/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/node-vitest/mod.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livestore/utils-dev",
|
|
3
|
-
"version": "0.0.0-snapshot-
|
|
3
|
+
"version": "0.0.0-snapshot-4f805b2565782b5e562923f10caa1424e1774787",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
|
-
"./
|
|
6
|
+
"./src/node-vitest/polyfill.ts"
|
|
7
7
|
],
|
|
8
8
|
"exports": {
|
|
9
9
|
"./node": "./dist/node/mod.js",
|
|
10
|
-
"./node-vitest": "./dist/node-vitest/mod.js"
|
|
11
|
-
"./node-vitest-polyfill": "./dist/node-vitest/polyfill.js"
|
|
10
|
+
"./node-vitest": "./dist/node-vitest/mod.js"
|
|
12
11
|
},
|
|
13
12
|
"dependencies": {
|
|
14
13
|
"@effect/opentelemetry": "0.56.0",
|
|
@@ -19,7 +18,7 @@
|
|
|
19
18
|
"@opentelemetry/sdk-metrics": "2.0.1",
|
|
20
19
|
"@opentelemetry/sdk-trace-base": "2.0.1",
|
|
21
20
|
"@opentelemetry/sdk-trace-node": "2.0.1",
|
|
22
|
-
"@livestore/utils": "0.0.0-snapshot-
|
|
21
|
+
"@livestore/utils": "0.0.0-snapshot-4f805b2565782b5e562923f10caa1424e1774787"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {},
|
|
25
24
|
"files": [
|
|
@@ -30,7 +29,10 @@
|
|
|
30
29
|
"license": "Apache-2.0",
|
|
31
30
|
"peerDependencies": {},
|
|
32
31
|
"publishConfig": {
|
|
33
|
-
"access": "public"
|
|
32
|
+
"access": "public",
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"./dist/node-vitest/polyfill.js"
|
|
35
|
+
]
|
|
34
36
|
},
|
|
35
37
|
"scripts": {
|
|
36
38
|
"test": "echo 'No tests for utils-dev'"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as inspector from 'node:inspector'
|
|
2
|
+
import type * as Vitest from '@effect/vitest'
|
|
3
|
+
import { IS_CI } from '@livestore/utils'
|
|
4
|
+
import { type Cause, Duration, Effect, identity, Layer, type OtelTracer, type Scope } from '@livestore/utils/effect'
|
|
5
|
+
import { OtelLiveDummy } from '@livestore/utils/node'
|
|
6
|
+
import { OtelLiveHttp } from '../node/mod.ts'
|
|
7
|
+
|
|
8
|
+
export * from '@effect/vitest'
|
|
9
|
+
|
|
10
|
+
export const DEBUGGER_ACTIVE = Boolean(process.env.DEBUGGER_ACTIVE ?? inspector.url() !== undefined)
|
|
11
|
+
|
|
12
|
+
export const makeWithTestCtx =
|
|
13
|
+
<R1 = never, E1 = never>(ctxParams: WithTestCtxParams<R1, E1>) =>
|
|
14
|
+
(testContext: Vitest.TestContext) =>
|
|
15
|
+
withTestCtx(testContext, ctxParams)
|
|
16
|
+
|
|
17
|
+
export type WithTestCtxParams<R1 = never, E1 = never> = {
|
|
18
|
+
suffix?: string
|
|
19
|
+
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>
|
|
20
|
+
timeout?: Duration.DurationInput
|
|
21
|
+
forceOtel?: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const withTestCtx =
|
|
25
|
+
<R1 = never, E1 = never>(
|
|
26
|
+
testContext: Vitest.TestContext,
|
|
27
|
+
{
|
|
28
|
+
suffix,
|
|
29
|
+
makeLayer,
|
|
30
|
+
timeout = IS_CI ? 60_000 : 10_000,
|
|
31
|
+
forceOtel = false,
|
|
32
|
+
}: {
|
|
33
|
+
suffix?: string
|
|
34
|
+
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>
|
|
35
|
+
timeout?: Duration.DurationInput
|
|
36
|
+
forceOtel?: boolean
|
|
37
|
+
} = {},
|
|
38
|
+
) =>
|
|
39
|
+
<A, E>(
|
|
40
|
+
self: Effect.Effect<A, E, Scope.Scope | OtelTracer.OtelTracer | R1>,
|
|
41
|
+
): Effect.Effect<A, E | Cause.TimeoutException | E1, Scope.Scope> => {
|
|
42
|
+
const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix ? `:${suffix}` : ''}`
|
|
43
|
+
const layer = makeLayer?.(testContext)
|
|
44
|
+
|
|
45
|
+
const otelLayer =
|
|
46
|
+
DEBUGGER_ACTIVE || forceOtel ? OtelLiveHttp({ serviceName: 'vitest-runner', skipLogUrl: false }) : OtelLiveDummy
|
|
47
|
+
|
|
48
|
+
return self.pipe(
|
|
49
|
+
DEBUGGER_ACTIVE
|
|
50
|
+
? identity
|
|
51
|
+
: Effect.logWarnIfTakesLongerThan({
|
|
52
|
+
duration: Duration.toMillis(timeout) * 0.8,
|
|
53
|
+
label: `${spanName} approaching timeout (timeout: ${Duration.format(timeout)})`,
|
|
54
|
+
}),
|
|
55
|
+
DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout),
|
|
56
|
+
Effect.provide(otelLayer),
|
|
57
|
+
Effect.provide(layer ?? Layer.empty),
|
|
58
|
+
Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
|
|
59
|
+
Effect.withSpan(spanName),
|
|
60
|
+
Effect.annotateLogs({ suffix }),
|
|
61
|
+
) as any
|
|
62
|
+
}
|
package/src/node-vitest/mod.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../../src/node-vitest/polyfill.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../src/node-vitest/polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAA"}
|
|
File without changes
|