@dxos/effect 0.8.3 → 0.8.4-main.16b68245aa

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 (91) hide show
  1. package/dist/lib/browser/chunk-CGS2ULMK.mjs +11 -0
  2. package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +536 -154
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing.mjs +31 -0
  7. package/dist/lib/browser/testing.mjs.map +7 -0
  8. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  9. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +536 -154
  11. package/dist/lib/node-esm/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing.mjs +31 -0
  14. package/dist/lib/node-esm/testing.mjs.map +7 -0
  15. package/dist/types/src/Performance.d.ts +25 -0
  16. package/dist/types/src/Performance.d.ts.map +1 -0
  17. package/dist/types/src/RuntimeProvider.d.ts +21 -0
  18. package/dist/types/src/RuntimeProvider.d.ts.map +1 -0
  19. package/dist/types/src/ast.d.ts +42 -18
  20. package/dist/types/src/ast.d.ts.map +1 -1
  21. package/dist/types/src/async-task-tagging.d.ts +6 -0
  22. package/dist/types/src/async-task-tagging.d.ts.map +1 -0
  23. package/dist/types/src/atom-kvs.d.ts +19 -0
  24. package/dist/types/src/atom-kvs.d.ts.map +1 -0
  25. package/dist/types/src/context.d.ts +5 -0
  26. package/dist/types/src/context.d.ts.map +1 -0
  27. package/dist/types/src/dynamic-runtime.d.ts +56 -0
  28. package/dist/types/src/dynamic-runtime.d.ts.map +1 -0
  29. package/dist/types/src/dynamic-runtime.test.d.ts +2 -0
  30. package/dist/types/src/dynamic-runtime.test.d.ts.map +1 -0
  31. package/dist/types/src/errors.d.ts +57 -0
  32. package/dist/types/src/errors.d.ts.map +1 -0
  33. package/dist/types/src/errors.test.d.ts +2 -0
  34. package/dist/types/src/errors.test.d.ts.map +1 -0
  35. package/dist/types/src/index.d.ts +10 -1
  36. package/dist/types/src/index.d.ts.map +1 -1
  37. package/dist/types/src/interrupt.test.d.ts +2 -0
  38. package/dist/types/src/interrupt.test.d.ts.map +1 -0
  39. package/dist/types/src/{jsonPath.d.ts → json-path.d.ts} +12 -4
  40. package/dist/types/src/json-path.d.ts.map +1 -0
  41. package/dist/types/src/json-path.test.d.ts +2 -0
  42. package/dist/types/src/json-path.test.d.ts.map +1 -0
  43. package/dist/types/src/layers.test.d.ts +2 -0
  44. package/dist/types/src/layers.test.d.ts.map +1 -0
  45. package/dist/types/src/otel.d.ts +17 -0
  46. package/dist/types/src/otel.d.ts.map +1 -0
  47. package/dist/types/src/otel.test.d.ts +2 -0
  48. package/dist/types/src/otel.test.d.ts.map +1 -0
  49. package/dist/types/src/resource.d.ts +8 -0
  50. package/dist/types/src/resource.d.ts.map +1 -0
  51. package/dist/types/src/resource.test.d.ts +2 -0
  52. package/dist/types/src/resource.test.d.ts.map +1 -0
  53. package/dist/types/src/testing.d.ts +58 -0
  54. package/dist/types/src/testing.d.ts.map +1 -0
  55. package/dist/types/src/types.d.ts +8 -0
  56. package/dist/types/src/types.d.ts.map +1 -0
  57. package/dist/types/src/url.d.ts +3 -1
  58. package/dist/types/src/url.d.ts.map +1 -1
  59. package/dist/types/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +33 -11
  61. package/src/Performance.ts +45 -0
  62. package/src/RuntimeProvider.ts +35 -0
  63. package/src/ast.test.ts +55 -10
  64. package/src/ast.ts +151 -84
  65. package/src/async-task-tagging.ts +51 -0
  66. package/src/atom-kvs.ts +35 -0
  67. package/src/context.ts +16 -0
  68. package/src/dynamic-runtime.test.ts +465 -0
  69. package/src/dynamic-runtime.ts +195 -0
  70. package/src/errors.test.ts +22 -0
  71. package/src/errors.ts +252 -0
  72. package/src/index.ts +10 -1
  73. package/src/interrupt.test.ts +35 -0
  74. package/src/{jsonPath.test.ts → json-path.test.ts} +47 -8
  75. package/src/{jsonPath.ts → json-path.ts} +29 -4
  76. package/src/layers.test.ts +112 -0
  77. package/src/otel.test.ts +126 -0
  78. package/src/otel.ts +45 -0
  79. package/src/resource.test.ts +32 -0
  80. package/src/resource.ts +30 -0
  81. package/src/sanity.test.ts +30 -15
  82. package/src/testing.ts +86 -0
  83. package/src/types.ts +11 -0
  84. package/src/url.test.ts +1 -1
  85. package/src/url.ts +5 -2
  86. package/dist/lib/node/index.cjs +0 -487
  87. package/dist/lib/node/index.cjs.map +0 -7
  88. package/dist/lib/node/meta.json +0 -1
  89. package/dist/types/src/jsonPath.d.ts.map +0 -1
  90. package/dist/types/src/jsonPath.test.d.ts +0 -2
  91. package/dist/types/src/jsonPath.test.d.ts.map +0 -1
@@ -0,0 +1,112 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { it } from '@effect/vitest';
6
+ import * as Context from 'effect/Context';
7
+ import * as Duration from 'effect/Duration';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Layer from 'effect/Layer';
10
+ import * as ManagedRuntime from 'effect/ManagedRuntime';
11
+ import { test } from 'vitest';
12
+
13
+ import { runAndForwardErrors } from './errors';
14
+
15
+ class ClientConfig extends Context.Tag('ClientConfig')<ClientConfig, { endpoint: string }>() {}
16
+
17
+ class Client extends Context.Tag('Client')<Client, { call: () => Effect.Effect<void> }>() {
18
+ static layer = Layer.effect(
19
+ Client,
20
+ Effect.gen(function* () {
21
+ const config = yield* ClientConfig;
22
+ return {
23
+ call: () => {
24
+ console.log('called', config.endpoint);
25
+ return Effect.void;
26
+ },
27
+ };
28
+ }),
29
+ );
30
+ }
31
+
32
+ const ServerLive = Layer.scoped(
33
+ ClientConfig,
34
+ Effect.gen(function* () {
35
+ console.log('start server');
36
+
37
+ yield* Effect.sleep(Duration.millis(100));
38
+
39
+ yield* Effect.addFinalizer(
40
+ Effect.fn(function* () {
41
+ yield* Effect.sleep(Duration.millis(100));
42
+ console.log('stop server');
43
+ }),
44
+ );
45
+
46
+ return {
47
+ endpoint: 'http://localhost:8080',
48
+ };
49
+ }),
50
+ );
51
+
52
+ it.effect.skip(
53
+ 'test',
54
+ Effect.fn(
55
+ function* (_) {
56
+ const client = yield* Client;
57
+ yield* client.call();
58
+ },
59
+ Effect.provide(Layer.provide(Client.layer, ServerLive)),
60
+ ),
61
+ );
62
+
63
+ class ServerPlugin {
64
+ #runtime = ManagedRuntime.make(ServerLive);
65
+
66
+ readonly clientConfigLayer = Layer.effectContext(
67
+ this.#runtime.runtimeEffect.pipe(Effect.map((rt) => rt.context.pipe(Context.pick(ClientConfig)))),
68
+ );
69
+
70
+ async dispose() {
71
+ await this.#runtime.dispose();
72
+ }
73
+ }
74
+
75
+ class ClientPlugin {
76
+ constructor(private readonly _serverPlugin: ServerPlugin) {}
77
+
78
+ async run() {
79
+ const layer = Layer.provide(Client.layer, this._serverPlugin.clientConfigLayer);
80
+
81
+ await runAndForwardErrors(
82
+ Effect.gen(function* () {
83
+ const client = yield* Client;
84
+ yield* client.call();
85
+ }).pipe(Effect.provide(layer)),
86
+ );
87
+ }
88
+ }
89
+
90
+ test.skip('plugins', async () => {
91
+ const serverPlugin = new ServerPlugin();
92
+ console.log('ServerPlugin created');
93
+
94
+ await runAndForwardErrors(Effect.sleep(Duration.millis(500)));
95
+ console.log('wake up');
96
+
97
+ {
98
+ const clientPlugin1 = new ClientPlugin(serverPlugin);
99
+ console.log('ClientPlugin1 created');
100
+ await clientPlugin1.run();
101
+ console.log('client1 run');
102
+ }
103
+
104
+ {
105
+ const clientPlugin2 = new ClientPlugin(serverPlugin);
106
+ console.log('ClientPlugin2 created');
107
+ await clientPlugin2.run();
108
+ console.log('client2 run');
109
+ }
110
+
111
+ await serverPlugin.dispose();
112
+ });
@@ -0,0 +1,126 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { afterAll, beforeAll, it } from '@effect/vitest';
6
+ import { SpanStatusCode, trace } from '@opentelemetry/api';
7
+ import { type Logger, SeverityNumber, logs } from '@opentelemetry/api-logs';
8
+ import { resourceFromAttributes } from '@opentelemetry/resources';
9
+ import { ConsoleLogRecordExporter, LoggerProvider, SimpleLogRecordProcessor } from '@opentelemetry/sdk-logs';
10
+ import { NodeSDK } from '@opentelemetry/sdk-node';
11
+ import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node';
12
+ import {
13
+ ATTR_CODE_FILE_PATH,
14
+ ATTR_CODE_LINE_NUMBER,
15
+ ATTR_CODE_STACKTRACE,
16
+ ATTR_SERVICE_NAME,
17
+ } from '@opentelemetry/semantic-conventions';
18
+ import * as Duration from 'effect/Duration';
19
+ import * as Effect from 'effect/Effect';
20
+ import { beforeEach } from 'vitest';
21
+
22
+ import { LogLevel, type LogProcessor, log } from '@dxos/log';
23
+
24
+ import { layerOtel } from './otel';
25
+
26
+ const resource = resourceFromAttributes({
27
+ [ATTR_SERVICE_NAME]: 'test',
28
+ });
29
+
30
+ const sdk = new NodeSDK({
31
+ traceExporter: new ConsoleSpanExporter(),
32
+ resource,
33
+ });
34
+
35
+ // and add a processor to export log record
36
+ const loggerProvider = new LoggerProvider({
37
+ processors: [new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())],
38
+ resource,
39
+ });
40
+ logs.setGlobalLoggerProvider(loggerProvider);
41
+
42
+ // You can also use global singleton
43
+ const logger = logs.getLogger('test');
44
+
45
+ const makeOtelLogProcessor = (logger: Logger): LogProcessor => {
46
+ return (config, entry) => {
47
+ let severity: SeverityNumber = SeverityNumber.UNSPECIFIED;
48
+ switch (entry.level) {
49
+ case LogLevel.DEBUG:
50
+ severity = SeverityNumber.DEBUG;
51
+ break;
52
+ case LogLevel.INFO:
53
+ severity = SeverityNumber.INFO;
54
+ break;
55
+ case LogLevel.WARN:
56
+ severity = SeverityNumber.WARN;
57
+ break;
58
+ case LogLevel.ERROR:
59
+ severity = SeverityNumber.ERROR;
60
+ break;
61
+ }
62
+
63
+ logger.emit({
64
+ body: entry.error ? ('stack' in entry.error ? entry.error.stack : String(entry.error)) : entry.message,
65
+ severityNumber: severity,
66
+ attributes: {
67
+ [ATTR_CODE_FILE_PATH]: entry.meta?.F,
68
+ [ATTR_CODE_LINE_NUMBER]: entry.meta?.L,
69
+ [ATTR_CODE_STACKTRACE]: entry.error?.stack,
70
+ ...(typeof entry.context === 'object'
71
+ ? entry.context
72
+ : {
73
+ ctx: entry.context,
74
+ }),
75
+ },
76
+ });
77
+ };
78
+ };
79
+
80
+ log.addProcessor(makeOtelLogProcessor(logger));
81
+
82
+ beforeAll(() => {
83
+ sdk.start();
84
+ });
85
+
86
+ afterAll(async () => {
87
+ await loggerProvider.shutdown();
88
+ await sdk.shutdown();
89
+ });
90
+
91
+ beforeEach((ctx) => {
92
+ const span = trace.getTracer('testing-framework').startSpan(ctx.task.name);
93
+ ctx.onTestFailed((ctx) => {
94
+ // TODO(dmaretskyi): Record result.
95
+ span.setStatus({ code: SpanStatusCode.ERROR });
96
+ span.end();
97
+ });
98
+ ctx.onTestFinished((ctx) => {
99
+ span.setStatus({ code: SpanStatusCode.OK });
100
+ span.end();
101
+ });
102
+ });
103
+
104
+ const foo = Effect.fn('foo')(function* () {
105
+ yield* Effect.sleep(Duration.millis(100));
106
+
107
+ log('log inside foo', { detail: 123 });
108
+ });
109
+
110
+ const bar = Effect.fn('bar')(function* () {
111
+ yield* foo();
112
+ });
113
+
114
+ const baz = Effect.fn('baz')(function* () {
115
+ yield* bar();
116
+ });
117
+
118
+ it.live(
119
+ 'Test Suite One',
120
+ Effect.fnUntraced(
121
+ function* () {
122
+ yield* baz();
123
+ },
124
+ Effect.provide(layerOtel(Effect.succeed({}))),
125
+ ),
126
+ );
package/src/otel.ts ADDED
@@ -0,0 +1,45 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Resource from '@effect/opentelemetry/Resource';
6
+ import * as Tracer from '@effect/opentelemetry/Tracer';
7
+ import { type Attributes, trace } from '@opentelemetry/api';
8
+ import * as Effect from 'effect/Effect';
9
+ import type * as Function from 'effect/Function';
10
+ import * as Layer from 'effect/Layer';
11
+
12
+ export interface Configuration {
13
+ readonly resource?:
14
+ | {
15
+ readonly serviceName: string;
16
+ readonly serviceVersion?: string;
17
+ readonly attributes?: Attributes;
18
+ }
19
+ | undefined;
20
+ }
21
+
22
+ // Based on https://github.com/Effect-TS/effect/blob/main/packages/opentelemetry/src/NodeSdk.ts
23
+ export const layerOtel: {
24
+ (evaluate: Function.LazyArg<Configuration>): Layer.Layer<Resource.Resource>;
25
+ <R, E>(evaluate: Effect.Effect<Configuration, E, R>): Layer.Layer<Resource.Resource, E, R>;
26
+ } = (
27
+ evaluate: Function.LazyArg<Configuration> | Effect.Effect<Configuration, any, any>,
28
+ ): Layer.Layer<Resource.Resource> =>
29
+ Layer.unwrapEffect(
30
+ Effect.map(
31
+ Effect.isEffect(evaluate) ? (evaluate as Effect.Effect<Configuration>) : Effect.sync(evaluate),
32
+ (config) => {
33
+ const ResourceLive = Resource.layerFromEnv(config.resource && Resource.configToAttributes(config.resource));
34
+
35
+ const provider = trace.getTracerProvider();
36
+ const TracerLive = Layer.provide(Tracer.layer, Layer.succeed(Tracer.OtelTracerProvider, provider));
37
+
38
+ // TODO(wittjosiah): Add metrics and logger layers.
39
+ const MetricsLive = Layer.empty;
40
+ const LoggerLive = Layer.empty;
41
+
42
+ return Layer.mergeAll(TracerLive, MetricsLive, LoggerLive).pipe(Layer.provideMerge(ResourceLive));
43
+ },
44
+ ),
45
+ );
@@ -0,0 +1,32 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { it } from '@effect/vitest';
6
+ import * as Effect from 'effect/Effect';
7
+
8
+ import { acquireReleaseResource } from './resource';
9
+
10
+ it.effect(
11
+ 'acquire-release',
12
+ Effect.fn(function* ({ expect }) {
13
+ const events: string[] = [];
14
+ const makeResource = acquireReleaseResource(() => ({
15
+ open: () => {
16
+ events.push('open');
17
+ },
18
+ close: () => {
19
+ events.push('close');
20
+ },
21
+ }));
22
+
23
+ yield* Effect.gen(function* () {
24
+ events.push('1');
25
+ const _resource = yield* makeResource;
26
+ events.push('2');
27
+ }).pipe(Effect.scoped);
28
+
29
+ events.push('3');
30
+ expect(events).to.deep.equal(['1', 'open', '2', 'close', '3']);
31
+ }),
32
+ );
@@ -0,0 +1,30 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import type * as Scope from 'effect/Scope';
7
+
8
+ import type { Lifecycle } from '@dxos/context';
9
+
10
+ /**
11
+ * Acquires a resource and releases it when the scope is closed.
12
+ */
13
+ export const acquireReleaseResource = <T extends Lifecycle>(
14
+ getResource: () => T,
15
+ ): Effect.Effect<T, never, Scope.Scope> =>
16
+ Effect.acquireRelease(
17
+ Effect.gen(function* () {
18
+ const resource = getResource();
19
+ yield* Effect.promise(async () => {
20
+ await resource.open?.();
21
+ return undefined;
22
+ });
23
+ return resource;
24
+ }),
25
+ (resource) =>
26
+ Effect.promise(async () => {
27
+ await resource.close?.();
28
+ return undefined;
29
+ }),
30
+ );
@@ -2,14 +2,17 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Effect, pipe } from 'effect';
5
+ import * as Effect from 'effect/Effect';
6
+ import * as Function from 'effect/Function';
6
7
  import { describe, test } from 'vitest';
7
8
 
8
9
  import { log } from '@dxos/log';
9
10
 
11
+ import { runAndForwardErrors } from './errors';
12
+
10
13
  describe('sanity tests', () => {
11
14
  test('function pipeline', async ({ expect }) => {
12
- const result = pipe(
15
+ const result = Function.pipe(
13
16
  10,
14
17
  (value) => value + 3,
15
18
  (value) => value * 2,
@@ -18,36 +21,48 @@ describe('sanity tests', () => {
18
21
  });
19
22
 
20
23
  test('effect pipeline (mixing types)', async ({ expect }) => {
21
- const result = await Effect.runPromise(
22
- pipe(
24
+ const result = await runAndForwardErrors(
25
+ Function.pipe(
23
26
  Effect.promise(() => Promise.resolve(100)),
24
- Effect.tap((value) => log('tap', { value })),
27
+ Effect.tap((value) => {
28
+ log('tap', { value });
29
+ }),
25
30
  Effect.map((value: number) => String(value)),
26
- Effect.tap((value) => log('tap', { value })),
31
+ Effect.tap((value) => {
32
+ log('tap', { value });
33
+ }),
27
34
  Effect.map((value: string) => value.length),
28
- Effect.tap((value) => log('tap', { value })),
35
+ Effect.tap((value) => {
36
+ log('tap', { value });
37
+ }),
29
38
  ),
30
39
  );
31
40
  expect(result).to.eq(3);
32
41
  });
33
42
 
34
43
  test('effect pipeline (mixing sync/async)', async ({ expect }) => {
35
- const result = await Effect.runPromise(
36
- pipe(
44
+ const result = await runAndForwardErrors(
45
+ Function.pipe(
37
46
  Effect.succeed(100),
38
- Effect.tap((value) => log('tap', { value })),
47
+ Effect.tap((value) => {
48
+ log('tap', { value });
49
+ }),
39
50
  Effect.flatMap((value) => Effect.promise(() => Promise.resolve(String(value)))),
40
- Effect.tap((value) => log('tap', { value })),
51
+ Effect.tap((value) => {
52
+ log('tap', { value });
53
+ }),
41
54
  Effect.map((value) => value.length),
42
- Effect.tap((value) => log('tap', { value })),
55
+ Effect.tap((value) => {
56
+ log('tap', { value });
57
+ }),
43
58
  ),
44
59
  );
45
60
  expect(result).to.eq(3);
46
61
  });
47
62
 
48
63
  test('error handling', async ({ expect }) => {
49
- Effect.runPromise(
50
- pipe(
64
+ runAndForwardErrors(
65
+ Function.pipe(
51
66
  Effect.succeed(10),
52
67
  Effect.map((value) => value * 2),
53
68
  Effect.flatMap((value) =>
@@ -62,7 +77,7 @@ describe('sanity tests', () => {
62
77
  ),
63
78
  )
64
79
  .then(() => expect.fail())
65
- .catch((error) => {
80
+ .catch((error: any) => {
66
81
  expect(error).to.be.instanceOf(Error);
67
82
  });
68
83
  });
package/src/testing.ts ADDED
@@ -0,0 +1,86 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Context from 'effect/Context';
6
+ import * as Effect from 'effect/Effect';
7
+ import type { TestContext } from 'vitest';
8
+
9
+ export namespace TestHelpers {
10
+ /**
11
+ * Skip the test if the condition is false.
12
+ *
13
+ * Example:
14
+ * ```ts
15
+ * it.effect(
16
+ * 'should process an agentic loop using Claude',
17
+ * Effect.fn(function* ({ expect }) {
18
+ * // ...
19
+ * }),
20
+ * TestHelpers.runIf(process.env.ANTHROPIC_API_KEY),
21
+ * );
22
+ * ```
23
+ */
24
+ export const runIf =
25
+ (condition: unknown) =>
26
+ <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>
27
+ Effect.gen(function* () {
28
+ if (!condition) {
29
+ ctx.skip();
30
+ } else {
31
+ return yield* effect;
32
+ }
33
+ });
34
+
35
+ /**
36
+ * Skip the test if the condition is true.
37
+ *
38
+ * Example:
39
+ * ```ts
40
+ * it.effect(
41
+ * 'should process an agentic loop using Claude',
42
+ * Effect.fn(function* ({ expect }) {
43
+ * // ...
44
+ * }),
45
+ * TestHelpers.skipIf(!process.env.ANTHROPIC_API_KEY),
46
+ * );
47
+ * ```
48
+ */
49
+ export const skipIf =
50
+ (condition: unknown) =>
51
+ <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>
52
+ Effect.gen(function* () {
53
+ if (condition) {
54
+ ctx.skip();
55
+ } else {
56
+ return yield* effect;
57
+ }
58
+ });
59
+
60
+ /**
61
+ * Provide TestContext from test parameters.
62
+ *
63
+ * Example:
64
+ * ```ts
65
+ * it.effect(
66
+ * 'with context',
67
+ * Effect.fn(function* ({ expect }) {
68
+ * const ctx = yield* TestContextService;
69
+ * }),
70
+ * TestHelpers.provideTestContext,
71
+ * );
72
+ * ```
73
+ */
74
+ export const provideTestContext = <A, E, R>(
75
+ effect: Effect.Effect<A, E, R>,
76
+ ctx: TestContext,
77
+ ): Effect.Effect<A, E, Exclude<R, TestContextService>> => Effect.provideService(effect, TestContextService, ctx);
78
+ }
79
+
80
+ /**
81
+ * Exposes vitest test context as an effect service.
82
+ */
83
+ export class TestContextService extends Context.Tag('@dxos/effect/TestContextService')<
84
+ TestContextService,
85
+ TestContext
86
+ >() {}
package/src/types.ts ADDED
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ /**
6
+ * Flat intersection of up to five types. Behaves like `A & B & C & ...` but
7
+ * formats as a comma-separated tuple, which fits multi-line layouts more
8
+ * cleanly than chained `&` operators. Unused slots default to `unknown`,
9
+ * which is inert under intersection (`T & unknown = T`).
10
+ */
11
+ export type Merge<A, B = unknown, C = unknown, D = unknown, E = unknown> = A & B & C & D & E;
package/src/url.test.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import { describe, expect, test } from 'vitest';
7
7
 
8
8
  import { ParamKeyAnnotation, UrlParser } from './url';
package/src/url.ts CHANGED
@@ -2,7 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { SchemaAST, type Schema, Option, pipe } from 'effect';
5
+ import * as Function from 'effect/Function';
6
+ import * as Option from 'effect/Option';
7
+ import type * as Schema from 'effect/Schema';
8
+ import * as SchemaAST from 'effect/SchemaAST';
6
9
 
7
10
  import { decamelize } from '@dxos/util';
8
11
 
@@ -59,7 +62,7 @@ export class UrlParser<T extends Record<string, any>> {
59
62
  if (value !== undefined) {
60
63
  const field = this._schema.fields[key];
61
64
  if (field) {
62
- const { key: serializedKey } = pipe(
65
+ const { key: serializedKey } = Function.pipe(
63
66
  getParamKeyAnnotation(field.ast),
64
67
  Option.getOrElse(() => ({
65
68
  key: decamelize(key),