@dxos/effect 0.8.4-main.fbb7a13 → 0.8.4-main.fcc0d83b33
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/lib/browser/index.mjs +149 -111
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing.mjs +0 -7
- package/dist/lib/browser/testing.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +149 -111
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing.mjs +0 -7
- package/dist/lib/node-esm/testing.mjs.map +3 -3
- package/dist/types/src/Performance.d.ts +25 -0
- package/dist/types/src/Performance.d.ts.map +1 -0
- package/dist/types/src/RuntimeProvider.d.ts.map +1 -1
- package/dist/types/src/ast.d.ts +7 -1
- package/dist/types/src/ast.d.ts.map +1 -1
- package/dist/types/src/async-task-tagging.d.ts +6 -0
- package/dist/types/src/async-task-tagging.d.ts.map +1 -0
- package/dist/types/src/atom-kvs.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +11 -3
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/json-path.d.ts.map +1 -1
- package/dist/types/src/resource.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +3 -12
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +8 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/src/url.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -19
- package/src/Performance.ts +45 -0
- package/src/ast.test.ts +25 -0
- package/src/ast.ts +38 -12
- package/src/async-task-tagging.ts +51 -0
- package/src/atom-kvs.ts +1 -1
- package/src/errors.ts +59 -13
- package/src/index.ts +3 -0
- package/src/testing.ts +3 -27
- package/src/types.ts +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/effect",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fcc0d83b33",
|
|
4
4
|
"description": "Effect utils.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -26,40 +26,36 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"types": "dist/types/src/index.d.ts",
|
|
29
|
-
"typesVersions": {
|
|
30
|
-
"*": {
|
|
31
|
-
"testing": [
|
|
32
|
-
"./dist/types/src/testing.d.ts"
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
29
|
"files": [
|
|
37
30
|
"dist",
|
|
38
31
|
"src"
|
|
39
32
|
],
|
|
40
33
|
"dependencies": {
|
|
41
|
-
"@effect-atom/atom-react": "^0.
|
|
42
|
-
"@effect/opentelemetry": "^0.
|
|
43
|
-
"@effect/platform-browser": "0.73.0",
|
|
34
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
35
|
+
"@effect/opentelemetry": "^0.61.0",
|
|
44
36
|
"@opentelemetry/api": "^1.9.0",
|
|
45
|
-
"jsonpath-plus": "10.
|
|
46
|
-
"@dxos/invariant": "0.8.4-main.
|
|
47
|
-
"@dxos/node-std": "0.8.4-main.
|
|
48
|
-
"@dxos/util": "0.8.4-main.
|
|
49
|
-
"@dxos/context": "0.8.4-main.
|
|
37
|
+
"jsonpath-plus": "^10.3.0",
|
|
38
|
+
"@dxos/invariant": "0.8.4-main.fcc0d83b33",
|
|
39
|
+
"@dxos/node-std": "0.8.4-main.fcc0d83b33",
|
|
40
|
+
"@dxos/util": "0.8.4-main.fcc0d83b33",
|
|
41
|
+
"@dxos/context": "0.8.4-main.fcc0d83b33"
|
|
50
42
|
},
|
|
51
43
|
"devDependencies": {
|
|
44
|
+
"@effect/platform": "0.94.4",
|
|
45
|
+
"@effect/platform-browser": "0.74.0",
|
|
52
46
|
"@opentelemetry/api-logs": "^0.203.0",
|
|
53
47
|
"@opentelemetry/resources": "^2.1.0",
|
|
54
48
|
"@opentelemetry/sdk-logs": "^0.203.0",
|
|
55
49
|
"@opentelemetry/sdk-node": "^0.203.0",
|
|
56
50
|
"@opentelemetry/sdk-trace-node": "^2.1.0",
|
|
57
51
|
"@opentelemetry/semantic-conventions": "^1.37.0",
|
|
58
|
-
"effect": "3.
|
|
59
|
-
"@dxos/log": "0.8.4-main.
|
|
52
|
+
"effect": "3.20.0",
|
|
53
|
+
"@dxos/log": "0.8.4-main.fcc0d83b33"
|
|
60
54
|
},
|
|
61
55
|
"peerDependencies": {
|
|
62
|
-
"effect": "
|
|
56
|
+
"@effect/platform": "0.94.4",
|
|
57
|
+
"@effect/platform-browser": "0.74.0",
|
|
58
|
+
"effect": "3.20.0"
|
|
63
59
|
},
|
|
64
60
|
"publishConfig": {
|
|
65
61
|
"access": "public"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import type * as Exit from 'effect/Exit';
|
|
7
|
+
|
|
8
|
+
export interface AddTrackEntryOptions {
|
|
9
|
+
name: string;
|
|
10
|
+
devtools?: {
|
|
11
|
+
/**
|
|
12
|
+
* @example 'track-entry'
|
|
13
|
+
*/
|
|
14
|
+
dataType: string;
|
|
15
|
+
track: string;
|
|
16
|
+
trackGroup: string;
|
|
17
|
+
/**
|
|
18
|
+
* @example 'tertiary-dark'
|
|
19
|
+
*/
|
|
20
|
+
color: string;
|
|
21
|
+
properties?: [string, any][];
|
|
22
|
+
tooltipText?: string;
|
|
23
|
+
};
|
|
24
|
+
detail?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Puts the effect span on the performance timeline in DevTools.
|
|
29
|
+
*/
|
|
30
|
+
export const addTrackEntry =
|
|
31
|
+
<A, E>(options: AddTrackEntryOptions | ((exit: Exit.Exit<A, E>) => AddTrackEntryOptions)) =>
|
|
32
|
+
<R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
|
|
33
|
+
Effect.gen(function* () {
|
|
34
|
+
const start = performance.now();
|
|
35
|
+
const exit = yield* Effect.exit(effect);
|
|
36
|
+
const resolvedOptions = typeof options === 'function' ? options(exit) : options;
|
|
37
|
+
performance.measure(resolvedOptions.name, {
|
|
38
|
+
start: start,
|
|
39
|
+
detail: {
|
|
40
|
+
...resolvedOptions.detail,
|
|
41
|
+
devtools: resolvedOptions.devtools,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
return yield* exit;
|
|
45
|
+
});
|
package/src/ast.test.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
getAnnotation,
|
|
16
16
|
getDiscriminatedType,
|
|
17
17
|
getDiscriminatingProps,
|
|
18
|
+
getProperties,
|
|
18
19
|
isArrayType,
|
|
19
20
|
isDiscriminatedUnion,
|
|
20
21
|
isOption,
|
|
@@ -90,6 +91,30 @@ describe('AST', () => {
|
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
93
|
|
|
94
|
+
test('getProperties preserves annotation on property type after refinements', ({ expect }) => {
|
|
95
|
+
// When a property is e.g. Format.Text.pipe(nonEmptyString(), maxLength(), Schema.annotations({ title, description })),
|
|
96
|
+
// the form uses getProperties(schema.ast) and then Format.FormatAnnotation.getFromAst(property.type).
|
|
97
|
+
// Custom title and description from the outer Schema.annotations() must not be lost.
|
|
98
|
+
const WithRefinements = Schema.Struct({
|
|
99
|
+
message: Schema.String.annotations({ title: 'Feedback' }).pipe(
|
|
100
|
+
Schema.minLength(1),
|
|
101
|
+
Schema.maxLength(4096),
|
|
102
|
+
Schema.annotations({
|
|
103
|
+
title: 'Feedback label',
|
|
104
|
+
description: 'Feedback placeholder',
|
|
105
|
+
}),
|
|
106
|
+
),
|
|
107
|
+
});
|
|
108
|
+
const properties = getProperties(WithRefinements.ast);
|
|
109
|
+
const messageProp = properties.find((p) => p.name === 'message');
|
|
110
|
+
invariant(messageProp);
|
|
111
|
+
const title = findAnnotation(messageProp.type, SchemaAST.TitleAnnotationId);
|
|
112
|
+
const description = findAnnotation(messageProp.type, SchemaAST.DescriptionAnnotationId);
|
|
113
|
+
// Outer Schema.annotations() wins so form labels/placeholders are preserved.
|
|
114
|
+
expect(title).to.eq('Feedback label');
|
|
115
|
+
expect(description).to.eq('Feedback placeholder');
|
|
116
|
+
});
|
|
117
|
+
|
|
93
118
|
test('findAnnotation', ({ expect }) => {
|
|
94
119
|
const TestSchema = Schema.NonEmptyString.pipe(Schema.pattern(/^\d{5}$/)).annotations({
|
|
95
120
|
title: 'original title',
|
package/src/ast.ts
CHANGED
|
@@ -27,9 +27,11 @@ const reduceRefinements = (
|
|
|
27
27
|
refinements: SchemaAST.Refinement['filter'][] = [],
|
|
28
28
|
): { type: SchemaAST.AST; refinements: SchemaAST.Refinement['filter'][] } => {
|
|
29
29
|
if (SchemaAST.isRefinement(type)) {
|
|
30
|
-
const annotations = type.annotations;
|
|
31
30
|
const filter = type.filter;
|
|
32
|
-
const nextType = {
|
|
31
|
+
const nextType = {
|
|
32
|
+
...type.from,
|
|
33
|
+
annotations: { ...type.from.annotations, ...type.annotations },
|
|
34
|
+
} as SchemaAST.AST;
|
|
33
35
|
return reduceRefinements(nextType, [...refinements, filter]);
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -60,12 +62,22 @@ export type SchemaProperty = Pick<SchemaAST.PropertySignature, 'name' | 'type' |
|
|
|
60
62
|
*/
|
|
61
63
|
export const getProperties = (ast: SchemaAST.AST): SchemaProperty[] => {
|
|
62
64
|
const properties = SchemaAST.getPropertySignatures(ast);
|
|
63
|
-
return properties.map((prop) =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
return properties.map((prop) => {
|
|
66
|
+
const { type, refinements } = getBaseType(prop);
|
|
67
|
+
// Merge PropertySignature-level annotations (e.g., title, description set via .annotations())
|
|
68
|
+
// onto the unwrapped base type so downstream consumers see them.
|
|
69
|
+
const mergedType =
|
|
70
|
+
prop.annotations && Reflect.ownKeys(prop.annotations).length > 0
|
|
71
|
+
? ({ ...type, annotations: { ...type.annotations, ...prop.annotations } } as SchemaAST.AST)
|
|
72
|
+
: type;
|
|
73
|
+
return {
|
|
74
|
+
type: mergedType,
|
|
75
|
+
refinements,
|
|
76
|
+
name: prop.name,
|
|
77
|
+
isOptional: prop.isOptional,
|
|
78
|
+
isReadonly: prop.isReadonly,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
69
81
|
};
|
|
70
82
|
|
|
71
83
|
//
|
|
@@ -252,10 +264,10 @@ export const findProperty = (
|
|
|
252
264
|
//
|
|
253
265
|
|
|
254
266
|
const defaultAnnotations: Record<string, SchemaAST.Annotated> = {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
267
|
+
ObjectKeyword: SchemaAST.objectKeyword,
|
|
268
|
+
StringKeyword: SchemaAST.stringKeyword,
|
|
269
|
+
NumberKeyword: SchemaAST.numberKeyword,
|
|
270
|
+
BooleanKeyword: SchemaAST.booleanKeyword,
|
|
259
271
|
};
|
|
260
272
|
|
|
261
273
|
/**
|
|
@@ -318,6 +330,20 @@ export const isLiteralUnion = (node: SchemaAST.AST): node is SchemaAST.Union<Sch
|
|
|
318
330
|
return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);
|
|
319
331
|
};
|
|
320
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Extracts the literal values from a schema that is a union of literals
|
|
335
|
+
* (e.g. `Schema.Literal('a', 'b')` or `Schema.Union(Schema.Literal('a'), Schema.Literal('b'))`).
|
|
336
|
+
* Returns an empty array if the schema is not a literal union.
|
|
337
|
+
*/
|
|
338
|
+
export const getLiteralValues = <S extends Schema.Schema<any, any, any>>(
|
|
339
|
+
schema: S,
|
|
340
|
+
): ReadonlyArray<Schema.Schema.Type<S>> => {
|
|
341
|
+
if (!isLiteralUnion(schema.ast)) {
|
|
342
|
+
return [];
|
|
343
|
+
}
|
|
344
|
+
return schema.ast.types.map((node) => node.literal as Schema.Schema.Type<S>);
|
|
345
|
+
};
|
|
346
|
+
|
|
321
347
|
/**
|
|
322
348
|
* Determines if the node is an array type.
|
|
323
349
|
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Context from 'effect/Context';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import { pipe } from 'effect/Function';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
9
|
+
import * as Predicate from 'effect/Predicate';
|
|
10
|
+
import * as Tracer from 'effect/Tracer';
|
|
11
|
+
|
|
12
|
+
const runInTask = Symbol('runInTask');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Traces effect frames using console.createTask so that the proper stack-trace is visible in Chrome Devtools debugger.
|
|
16
|
+
*/
|
|
17
|
+
export const asyncTaskTaggingLayer = () => {
|
|
18
|
+
if (Predicate.hasProperty(console, 'createTask') === false) {
|
|
19
|
+
return Layer.empty;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const makeTracer = Effect.gen(function* () {
|
|
23
|
+
const oldTracer = yield* Effect.tracer;
|
|
24
|
+
return Tracer.make({
|
|
25
|
+
span: (name, ...args) => {
|
|
26
|
+
const span = oldTracer.span(name, ...args);
|
|
27
|
+
const trace = (console as any).createTask(name);
|
|
28
|
+
(span as any)[runInTask] = (f: any) => trace.run(f);
|
|
29
|
+
return span;
|
|
30
|
+
},
|
|
31
|
+
context: (f, fiber) => {
|
|
32
|
+
const maybeParentSpan = Context.getOption(Tracer.ParentSpan)(fiber.currentContext);
|
|
33
|
+
|
|
34
|
+
if (maybeParentSpan._tag === 'None') {
|
|
35
|
+
return oldTracer.context(f, fiber);
|
|
36
|
+
}
|
|
37
|
+
const parentSpan = maybeParentSpan.value;
|
|
38
|
+
if (parentSpan._tag === 'ExternalSpan') {
|
|
39
|
+
return oldTracer.context(f, fiber);
|
|
40
|
+
}
|
|
41
|
+
const span = parentSpan;
|
|
42
|
+
if (runInTask in span && typeof span[runInTask] === 'function') {
|
|
43
|
+
return span[runInTask](() => oldTracer.context(f, fiber));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return oldTracer.context(f, fiber);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
return pipe(makeTracer, Effect.map(Layer.setTracer), Layer.unwrapEffect);
|
|
51
|
+
};
|
package/src/atom-kvs.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as BrowserKeyValueStore from '@effect/platform-browser/BrowserKeyValueStore';
|
|
6
5
|
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as BrowserKeyValueStore from '@effect/platform-browser/BrowserKeyValueStore';
|
|
7
7
|
import type * as Schema from 'effect/Schema';
|
|
8
8
|
|
|
9
9
|
// TODO(wittjosiah): This is currently provided for convenience but maybe should be removed.
|
package/src/errors.ts
CHANGED
|
@@ -12,7 +12,6 @@ import * as Runtime from 'effect/Runtime';
|
|
|
12
12
|
import type * as Tracer from 'effect/Tracer';
|
|
13
13
|
|
|
14
14
|
const spanSymbol = Symbol.for('effect/SpanAnnotation');
|
|
15
|
-
const originalSymbol = Symbol.for('effect/OriginalAnnotation');
|
|
16
15
|
const spanToTrace = GlobalValue.globalValue('effect/Tracer/spanToTrace', () => new WeakMap());
|
|
17
16
|
const locationRegex = /\((.*)\)/g;
|
|
18
17
|
|
|
@@ -31,7 +30,10 @@ const prettyErrorStack = (error: any, appendStacks: string[] = []): any => {
|
|
|
31
30
|
const lines = typeof error.stack === 'string' ? error.stack.split('\n') : [];
|
|
32
31
|
const out = [];
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
// Very hacky way to remove effect runtime internal stack frames.
|
|
34
|
+
let atStack = false,
|
|
35
|
+
inCore = false,
|
|
36
|
+
passedScheduler = false;
|
|
35
37
|
for (let i = 0; i < lines.length; i++) {
|
|
36
38
|
if (!atStack && !lines[i].startsWith(' at ')) {
|
|
37
39
|
out.push(lines[i]);
|
|
@@ -49,6 +51,26 @@ const prettyErrorStack = (error: any, appendStacks: string[] = []): any => {
|
|
|
49
51
|
if (lines[i].includes('effect_internal_function')) {
|
|
50
52
|
break;
|
|
51
53
|
}
|
|
54
|
+
|
|
55
|
+
const filename = lines[i].match(/\/([a-zA-Z0-9_\-.]+):\d+:\d+\)$/)?.[1];
|
|
56
|
+
|
|
57
|
+
if (!inCore && ['core-effect.ts'].includes(filename)) {
|
|
58
|
+
inCore = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (inCore && !passedScheduler && ['Scheduler.ts'].includes(filename)) {
|
|
62
|
+
passedScheduler = true;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (passedScheduler && !['Scheduler.ts'].includes(filename)) {
|
|
67
|
+
inCore = false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (inCore) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
52
74
|
out.push(
|
|
53
75
|
lines[i]
|
|
54
76
|
.replace(/at .*effect_instruction_i.*\((.*)\)/, 'at $1')
|
|
@@ -87,9 +109,7 @@ const prettyErrorStack = (error: any, appendStacks: string[] = []): any => {
|
|
|
87
109
|
|
|
88
110
|
out.push(...appendStacks);
|
|
89
111
|
|
|
90
|
-
|
|
91
|
-
error = error[originalSymbol];
|
|
92
|
-
}
|
|
112
|
+
error = Cause.originalError(error);
|
|
93
113
|
if (error.cause) {
|
|
94
114
|
error.cause = prettyErrorStack(error.cause);
|
|
95
115
|
}
|
|
@@ -125,7 +145,7 @@ export const causeToError = (cause: Cause.Cause<any>): Error => {
|
|
|
125
145
|
const getStackFrames = (): string[] => {
|
|
126
146
|
// Bun requies the target object for `captureStackTrace` to be an Error.
|
|
127
147
|
const o = new Error();
|
|
128
|
-
Error.captureStackTrace(o,
|
|
148
|
+
Error.captureStackTrace(o, causeToError);
|
|
129
149
|
return o.stack!.split('\n').slice(1);
|
|
130
150
|
};
|
|
131
151
|
|
|
@@ -180,13 +200,39 @@ export const runAndForwardErrors = async <A, E>(
|
|
|
180
200
|
return unwrapExit(exit);
|
|
181
201
|
};
|
|
182
202
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Runs the embedded effect asynchronously and throws any failures and defects as errors.
|
|
205
|
+
*/
|
|
206
|
+
export const runInRuntime: {
|
|
207
|
+
<R>(
|
|
208
|
+
runtime: Runtime.Runtime<R>,
|
|
209
|
+
): <A, E>(effect: Effect.Effect<A, E, R>, options?: { signal?: AbortSignal } | undefined) => Promise<A>;
|
|
210
|
+
<R, A, E>(
|
|
211
|
+
runtime: Runtime.Runtime<R>,
|
|
212
|
+
effect: Effect.Effect<A, E, R>,
|
|
213
|
+
options?: { signal?: AbortSignal } | undefined,
|
|
214
|
+
): Promise<A>;
|
|
215
|
+
} = (...args: any[]): any => {
|
|
216
|
+
if (args.length === 1) {
|
|
217
|
+
const [runtime] = args as [Runtime.Runtime<any>];
|
|
218
|
+
return async (
|
|
219
|
+
effect: Effect.Effect<any, any, any>,
|
|
220
|
+
options?: { signal?: AbortSignal } | undefined,
|
|
221
|
+
): Promise<any> => {
|
|
222
|
+
const exit = await Runtime.runPromiseExit(runtime, effect, options);
|
|
223
|
+
return unwrapExit(exit);
|
|
224
|
+
};
|
|
225
|
+
} else {
|
|
226
|
+
const [runtime, effect, options] = args as [
|
|
227
|
+
Runtime.Runtime<any>,
|
|
228
|
+
Effect.Effect<any, any, any>,
|
|
229
|
+
{ signal?: AbortSignal } | undefined,
|
|
230
|
+
];
|
|
231
|
+
return (async () => {
|
|
232
|
+
const exit = await Runtime.runPromiseExit(runtime, effect, options);
|
|
233
|
+
return unwrapExit(exit);
|
|
234
|
+
})();
|
|
235
|
+
}
|
|
190
236
|
};
|
|
191
237
|
|
|
192
238
|
/**
|
package/src/index.ts
CHANGED
|
@@ -9,5 +9,8 @@ export * as DynamicRuntime from './dynamic-runtime';
|
|
|
9
9
|
export * from './errors';
|
|
10
10
|
export * from './json-path';
|
|
11
11
|
export * from './resource';
|
|
12
|
+
export * from './types';
|
|
12
13
|
export * from './url';
|
|
13
14
|
export * as RuntimeProvider from './RuntimeProvider';
|
|
15
|
+
export * as Performance from './Performance';
|
|
16
|
+
export * from './async-task-tagging';
|
package/src/testing.ts
CHANGED
|
@@ -6,17 +6,11 @@ import * as Context from 'effect/Context';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import type { TestContext } from 'vitest';
|
|
8
8
|
|
|
9
|
-
// TODO(dmaretskyi): Add all different test tags here.
|
|
10
|
-
export type TestTag =
|
|
11
|
-
| 'flaky' // Flaky tests.
|
|
12
|
-
| 'llm' // Tests with AI.
|
|
13
|
-
| 'sync'; // Sync with external services.
|
|
14
|
-
|
|
15
9
|
export namespace TestHelpers {
|
|
16
10
|
/**
|
|
17
11
|
* Skip the test if the condition is false.
|
|
18
12
|
*
|
|
19
|
-
*
|
|
13
|
+
* Example:
|
|
20
14
|
* ```ts
|
|
21
15
|
* it.effect(
|
|
22
16
|
* 'should process an agentic loop using Claude',
|
|
@@ -41,7 +35,7 @@ export namespace TestHelpers {
|
|
|
41
35
|
/**
|
|
42
36
|
* Skip the test if the condition is true.
|
|
43
37
|
*
|
|
44
|
-
*
|
|
38
|
+
* Example:
|
|
45
39
|
* ```ts
|
|
46
40
|
* it.effect(
|
|
47
41
|
* 'should process an agentic loop using Claude',
|
|
@@ -63,28 +57,10 @@ export namespace TestHelpers {
|
|
|
63
57
|
}
|
|
64
58
|
});
|
|
65
59
|
|
|
66
|
-
/**
|
|
67
|
-
* Skips this test if the tag is not in the list of tags to run.
|
|
68
|
-
* Tags are specified in the `DX_TEST_TAGS` environment variable.
|
|
69
|
-
*
|
|
70
|
-
* @param tag
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
export const taggedTest =
|
|
74
|
-
(tag: TestTag) =>
|
|
75
|
-
<A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>
|
|
76
|
-
Effect.gen(function* () {
|
|
77
|
-
if (!process.env.DX_TEST_TAGS?.includes(tag)) {
|
|
78
|
-
ctx.skip();
|
|
79
|
-
} else {
|
|
80
|
-
return yield* effect;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
60
|
/**
|
|
85
61
|
* Provide TestContext from test parameters.
|
|
86
62
|
*
|
|
87
|
-
*
|
|
63
|
+
* Example:
|
|
88
64
|
* ```ts
|
|
89
65
|
* it.effect(
|
|
90
66
|
* 'with context',
|
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;
|