@dxos/effect 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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 +58 -79
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing.mjs +0 -8
- package/dist/lib/browser/testing.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +58 -79
- 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 -8
- package/dist/lib/node-esm/testing.mjs.map +3 -3
- package/dist/types/src/Performance.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/src/index.d.ts +2 -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 +0 -10
- 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 +6 -13
- package/src/ast.ts +14 -0
- package/src/async-task-tagging.ts +51 -0
- package/src/index.ts +2 -0
- package/src/testing.ts +0 -26
- 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.abd8ff62ef",
|
|
4
4
|
"description": "Effect utils.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -26,13 +26,6 @@
|
|
|
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"
|
|
@@ -42,10 +35,10 @@
|
|
|
42
35
|
"@effect/opentelemetry": "^0.61.0",
|
|
43
36
|
"@opentelemetry/api": "^1.9.0",
|
|
44
37
|
"jsonpath-plus": "^10.3.0",
|
|
45
|
-
"@dxos/context": "0.8.4-main.
|
|
46
|
-
"@dxos/invariant": "0.8.4-main.
|
|
47
|
-
"@dxos/node-std": "0.8.4-main.
|
|
48
|
-
"@dxos/util": "0.8.4-main.
|
|
38
|
+
"@dxos/context": "0.8.4-main.abd8ff62ef",
|
|
39
|
+
"@dxos/invariant": "0.8.4-main.abd8ff62ef",
|
|
40
|
+
"@dxos/node-std": "0.8.4-main.abd8ff62ef",
|
|
41
|
+
"@dxos/util": "0.8.4-main.abd8ff62ef"
|
|
49
42
|
},
|
|
50
43
|
"devDependencies": {
|
|
51
44
|
"@effect/platform": "0.94.4",
|
|
@@ -57,7 +50,7 @@
|
|
|
57
50
|
"@opentelemetry/sdk-trace-node": "^2.1.0",
|
|
58
51
|
"@opentelemetry/semantic-conventions": "^1.37.0",
|
|
59
52
|
"effect": "3.20.0",
|
|
60
|
-
"@dxos/log": "0.8.4-main.
|
|
53
|
+
"@dxos/log": "0.8.4-main.abd8ff62ef"
|
|
61
54
|
},
|
|
62
55
|
"peerDependencies": {
|
|
63
56
|
"@effect/platform": "0.94.4",
|
package/src/ast.ts
CHANGED
|
@@ -330,6 +330,20 @@ export const isLiteralUnion = (node: SchemaAST.AST): node is SchemaAST.Union<Sch
|
|
|
330
330
|
return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);
|
|
331
331
|
};
|
|
332
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
|
+
|
|
333
347
|
/**
|
|
334
348
|
* Determines if the node is an array type.
|
|
335
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/index.ts
CHANGED
|
@@ -9,6 +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';
|
|
14
15
|
export * as Performance from './Performance';
|
|
16
|
+
export * from './async-task-tagging';
|
package/src/testing.ts
CHANGED
|
@@ -6,12 +6,6 @@ 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.
|
|
@@ -63,26 +57,6 @@ export namespace TestHelpers {
|
|
|
63
57
|
}
|
|
64
58
|
});
|
|
65
59
|
|
|
66
|
-
export const tagEnabled = (tag: TestTag) => process.env.DX_TEST_TAGS?.includes(tag);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Skips this test if the tag is not in the list of tags to run.
|
|
70
|
-
* Tags are specified in the `DX_TEST_TAGS` environment variable.
|
|
71
|
-
*
|
|
72
|
-
* @param tag
|
|
73
|
-
* @returns
|
|
74
|
-
*/
|
|
75
|
-
export const taggedTest =
|
|
76
|
-
(tag: TestTag) =>
|
|
77
|
-
<A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>
|
|
78
|
-
Effect.gen(function* () {
|
|
79
|
-
if (!tagEnabled(tag)) {
|
|
80
|
-
ctx.skip();
|
|
81
|
-
} else {
|
|
82
|
-
return yield* effect;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
60
|
/**
|
|
87
61
|
* Provide TestContext from test parameters.
|
|
88
62
|
*
|
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;
|