@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/ast.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/ast.ts":{"bytes":48628,"imports":[{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/atom-kvs.ts":{"bytes":3815,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@effect/platform-browser/BrowserKeyValueStore","kind":"import-statement","external":true}],"format":"esm"},"src/context.ts":{"bytes":1574,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true}],"format":"esm"},"src/errors.ts":{"bytes":24140,"imports":[{"path":"effect/Cause","kind":"import-statement","external":true},{"path":"effect/Chunk","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/GlobalValue","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true}],"format":"esm"},"src/dynamic-runtime.ts":{"bytes":17162,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"src/json-path.ts":{"bytes":11405,"imports":[{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"jsonpath-plus","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/resource.ts":{"bytes":2324,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"},"src/types.ts":{"bytes":1147,"imports":[],"format":"esm"},"src/url.ts":{"bytes":7806,"imports":[{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/RuntimeProvider.ts":{"bytes":3443,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"src/Performance.ts":{"bytes":3212,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"},"src/async-task-tagging.ts":{"bytes":6303,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Predicate","kind":"import-statement","external":true},{"path":"effect/Tracer","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1632,"imports":[{"path":"src/ast.ts","kind":"import-statement","original":"./ast"},{"path":"src/atom-kvs.ts","kind":"import-statement","original":"./atom-kvs"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/dynamic-runtime.ts","kind":"import-statement","original":"./dynamic-runtime"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/json-path.ts","kind":"import-statement","original":"./json-path"},{"path":"src/resource.ts","kind":"import-statement","original":"./resource"},{"path":"src/types.ts","kind":"import-statement","original":"./types"},{"path":"src/url.ts","kind":"import-statement","original":"./url"},{"path":"src/RuntimeProvider.ts","kind":"import-statement","original":"./RuntimeProvider"},{"path":"src/Performance.ts","kind":"import-statement","original":"./Performance"},{"path":"src/async-task-tagging.ts","kind":"import-statement","original":"./async-task-tagging"}],"format":"esm"},"src/testing.ts":{"bytes":4890,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":67287},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-CGS2ULMK.mjs","kind":"import-statement"},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@effect/platform-browser/BrowserKeyValueStore","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"effect/Cause","kind":"import-statement","external":true},{"path":"effect/Chunk","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/GlobalValue","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"jsonpath-plus","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Predicate","kind":"import-statement","external":true},{"path":"effect/Tracer","kind":"import-statement","external":true}],"exports":["DynamicRuntime","JsonPath","JsonProp","ParamKeyAnnotation","Performance","RuntimeProvider","UrlParser","VisitResult","acquireReleaseResource","asyncTaskTaggingLayer","causeToError","contextFromScope","createJsonPath","createKvsStore","findAnnotation","findNode","findProperty","fromEffectValidationPath","getAnnotation","getArrayElementType","getBaseType","getDiscriminatedType","getDiscriminatingProps","getField","getLiteralValues","getParamKeyAnnotation","getProperties","getValue","isArrayType","isDiscriminatedUnion","isJsonPath","isLiteralUnion","isNestedType","isOption","isTupleType","mapAst","promiseWithCauseCapture","runAndForwardErrors","runInRuntime","setValue","splitJsonPath","throwCause","unwrapExit","visit"],"entryPoint":"src/index.ts","inputs":{"src/ast.ts":{"bytesInOutput":9457},"src/index.ts":{"bytesInOutput":0},"src/atom-kvs.ts":{"bytesInOutput":462},"src/context.ts":{"bytesInOutput":257},"src/dynamic-runtime.ts":{"bytesInOutput":3194},"src/errors.ts":{"bytesInOutput":4860},"src/json-path.ts":{"bytesInOutput":1821},"src/resource.ts":{"bytesInOutput":382},"src/url.ts":{"bytesInOutput":1709},"src/RuntimeProvider.ts":{"bytesInOutput":657},"src/Performance.ts":{"bytesInOutput":565},"src/async-task-tagging.ts":{"bytesInOutput":1487}},"bytes":26124},"dist/lib/browser/testing.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2916},"dist/lib/browser/testing.mjs":{"imports":[{"path":"dist/lib/browser/chunk-CGS2ULMK.mjs","kind":"import-statement"},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"exports":["TestContextService","TestHelpers"],"entryPoint":"src/testing.ts","inputs":{"src/testing.ts":{"bytesInOutput":716}},"bytes":884},"dist/lib/browser/chunk-CGS2ULMK.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/browser/chunk-CGS2ULMK.mjs":{"imports":[],"exports":["__export"],"inputs":{},"bytes":268}}}
|
|
@@ -19,14 +19,6 @@ import * as Effect from "effect/Effect";
|
|
|
19
19
|
return yield* effect;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
TestHelpers2.tagEnabled = (tag) => process.env.DX_TEST_TAGS?.includes(tag);
|
|
23
|
-
TestHelpers2.taggedTest = (tag) => (effect, ctx) => Effect.gen(function* () {
|
|
24
|
-
if (!TestHelpers2.tagEnabled(tag)) {
|
|
25
|
-
ctx.skip();
|
|
26
|
-
} else {
|
|
27
|
-
return yield* effect;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
22
|
TestHelpers2.provideTestContext = (effect, ctx) => Effect.provideService(effect, TestContextService, ctx);
|
|
31
23
|
})(TestHelpers || (TestHelpers = {}));
|
|
32
24
|
var TestContextService = class extends Context.Tag("@dxos/effect/TestContextService")() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/testing.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport type { TestContext } from 'vitest';\n\
|
|
5
|
-
"mappings": ";;;;AAIA,YAAYA,aAAa;AACzB,YAAYC,YAAY;
|
|
6
|
-
"names": ["Context", "Effect", "TestHelpers", "runIf", "condition", "effect", "ctx", "gen", "skip", "skipIf", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport type { TestContext } from 'vitest';\n\nexport namespace TestHelpers {\n /**\n * Skip the test if the condition is false.\n *\n * Example:\n * ```ts\n * it.effect(\n * 'should process an agentic loop using Claude',\n * Effect.fn(function* ({ expect }) {\n * // ...\n * }),\n * TestHelpers.runIf(process.env.ANTHROPIC_API_KEY),\n * );\n * ```\n */\n export const runIf =\n (condition: unknown) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (!condition) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n\n /**\n * Skip the test if the condition is true.\n *\n * Example:\n * ```ts\n * it.effect(\n * 'should process an agentic loop using Claude',\n * Effect.fn(function* ({ expect }) {\n * // ...\n * }),\n * TestHelpers.skipIf(!process.env.ANTHROPIC_API_KEY),\n * );\n * ```\n */\n export const skipIf =\n (condition: unknown) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (condition) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n\n /**\n * Provide TestContext from test parameters.\n *\n * Example:\n * ```ts\n * it.effect(\n * 'with context',\n * Effect.fn(function* ({ expect }) {\n * const ctx = yield* TestContextService;\n * }),\n * TestHelpers.provideTestContext,\n * );\n * ```\n */\n export const provideTestContext = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n ctx: TestContext,\n ): Effect.Effect<A, E, Exclude<R, TestContextService>> => Effect.provideService(effect, TestContextService, ctx);\n}\n\n/**\n * Exposes vitest test context as an effect service.\n */\nexport class TestContextService extends Context.Tag('@dxos/effect/TestContextService')<\n TestContextService,\n TestContext\n>() {}\n"],
|
|
5
|
+
"mappings": ";;;;AAIA,YAAYA,aAAa;AACzB,YAAYC,YAAY;UAGPC,cAAAA;eAeFC,QACX,CAACC,cACD,CAAUC,QAAgCC,QACjCC,WAAI,aAAA;AACT,QAAI,CAACH,WAAW;AACdE,UAAIE,KAAI;IACV,OAAO;AACL,aAAO,OAAOH;IAChB;EACF,CAAA;eAgBSI,SACX,CAACL,cACD,CAAUC,QAAgCC,QACjCC,WAAI,aAAA;AACT,QAAIH,WAAW;AACbE,UAAIE,KAAI;IACV,OAAO;AACL,aAAO,OAAOH;IAChB;EACF,CAAA;eAgBSK,qBAAqB,CAChCL,QACAC,QAC+DK,sBAAeN,QAAQO,oBAAoBN,GAAAA;AAC9G,GArEiBJ,gBAAAA,cAAAA,CAAAA,EAAAA;AA0EV,IAAMU,qBAAN,cAAyCC,YAAI,iCAAA,EAAA,EAAA;AAG/C;;",
|
|
6
|
+
"names": ["Context", "Effect", "TestHelpers", "runIf", "condition", "effect", "ctx", "gen", "skip", "skipIf", "provideTestContext", "provideService", "TestContextService", "Tag"]
|
|
7
7
|
}
|
|
@@ -10,7 +10,6 @@ import * as Schema from "effect/Schema";
|
|
|
10
10
|
import * as SchemaAST from "effect/SchemaAST";
|
|
11
11
|
import { invariant } from "@dxos/invariant";
|
|
12
12
|
import { isNonNullable } from "@dxos/util";
|
|
13
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/common/effect/src/ast.ts";
|
|
14
13
|
var reduceRefinements = (type, refinements = []) => {
|
|
15
14
|
if (SchemaAST.isRefinement(type)) {
|
|
16
15
|
const filter = type.filter;
|
|
@@ -151,15 +150,7 @@ var findProperty = (schema, path) => {
|
|
|
151
150
|
const getProp = (node, path2) => {
|
|
152
151
|
const [name, ...rest] = path2;
|
|
153
152
|
const typeNode = findNode(node, SchemaAST.isTypeLiteral);
|
|
154
|
-
invariant(typeNode
|
|
155
|
-
F: __dxlog_file,
|
|
156
|
-
L: 247,
|
|
157
|
-
S: void 0,
|
|
158
|
-
A: [
|
|
159
|
-
"typeNode",
|
|
160
|
-
""
|
|
161
|
-
]
|
|
162
|
-
});
|
|
153
|
+
invariant(typeNode);
|
|
163
154
|
for (const prop of SchemaAST.getPropertySignatures(typeNode)) {
|
|
164
155
|
if (prop.name === name) {
|
|
165
156
|
if (rest.length) {
|
|
@@ -207,6 +198,12 @@ var isOption = (node) => {
|
|
|
207
198
|
var isLiteralUnion = (node) => {
|
|
208
199
|
return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);
|
|
209
200
|
};
|
|
201
|
+
var getLiteralValues = (schema) => {
|
|
202
|
+
if (!isLiteralUnion(schema.ast)) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
return schema.ast.types.map((node) => node.literal);
|
|
206
|
+
};
|
|
210
207
|
var isArrayType = (node) => {
|
|
211
208
|
return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;
|
|
212
209
|
};
|
|
@@ -220,15 +217,7 @@ var isDiscriminatedUnion = (node) => {
|
|
|
220
217
|
return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
|
|
221
218
|
};
|
|
222
219
|
var getDiscriminatingProps = (node) => {
|
|
223
|
-
invariant(SchemaAST.isUnion(node)
|
|
224
|
-
F: __dxlog_file,
|
|
225
|
-
L: 365,
|
|
226
|
-
S: void 0,
|
|
227
|
-
A: [
|
|
228
|
-
"SchemaAST.isUnion(node)",
|
|
229
|
-
""
|
|
230
|
-
]
|
|
231
|
-
});
|
|
220
|
+
invariant(SchemaAST.isUnion(node));
|
|
232
221
|
if (isOption(node)) {
|
|
233
222
|
return;
|
|
234
223
|
}
|
|
@@ -238,39 +227,15 @@ var getDiscriminatingProps = (node) => {
|
|
|
238
227
|
}, []);
|
|
239
228
|
};
|
|
240
229
|
var getDiscriminatedType = (node, value = {}) => {
|
|
241
|
-
invariant(SchemaAST.isUnion(node)
|
|
242
|
-
|
|
243
|
-
L: 389,
|
|
244
|
-
S: void 0,
|
|
245
|
-
A: [
|
|
246
|
-
"SchemaAST.isUnion(node)",
|
|
247
|
-
""
|
|
248
|
-
]
|
|
249
|
-
});
|
|
250
|
-
invariant(value, void 0, {
|
|
251
|
-
F: __dxlog_file,
|
|
252
|
-
L: 390,
|
|
253
|
-
S: void 0,
|
|
254
|
-
A: [
|
|
255
|
-
"value",
|
|
256
|
-
""
|
|
257
|
-
]
|
|
258
|
-
});
|
|
230
|
+
invariant(SchemaAST.isUnion(node));
|
|
231
|
+
invariant(value);
|
|
259
232
|
const props = getDiscriminatingProps(node);
|
|
260
233
|
if (!props?.length) {
|
|
261
234
|
return;
|
|
262
235
|
}
|
|
263
236
|
for (const type of node.types) {
|
|
264
237
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
265
|
-
invariant(SchemaAST.isLiteral(prop.type)
|
|
266
|
-
F: __dxlog_file,
|
|
267
|
-
L: 401,
|
|
268
|
-
S: void 0,
|
|
269
|
-
A: [
|
|
270
|
-
"SchemaAST.isLiteral(prop.type)",
|
|
271
|
-
""
|
|
272
|
-
]
|
|
273
|
-
});
|
|
238
|
+
invariant(SchemaAST.isLiteral(prop.type));
|
|
274
239
|
return prop.type.literal === value[prop.name.toString()];
|
|
275
240
|
});
|
|
276
241
|
if (match) {
|
|
@@ -280,15 +245,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
280
245
|
const fields = Object.fromEntries(props.map((prop) => {
|
|
281
246
|
const literals = node.types.map((type) => {
|
|
282
247
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
283
|
-
invariant(SchemaAST.isLiteral(literal.type)
|
|
284
|
-
F: __dxlog_file,
|
|
285
|
-
L: 419,
|
|
286
|
-
S: void 0,
|
|
287
|
-
A: [
|
|
288
|
-
"SchemaAST.isLiteral(literal.type)",
|
|
289
|
-
""
|
|
290
|
-
]
|
|
291
|
-
});
|
|
248
|
+
invariant(SchemaAST.isLiteral(literal.type));
|
|
292
249
|
return literal.type.literal;
|
|
293
250
|
}).filter(isNonNullable);
|
|
294
251
|
return literals.length ? [
|
|
@@ -356,12 +313,8 @@ var createKvsStore = (options) => {
|
|
|
356
313
|
// src/context.ts
|
|
357
314
|
import * as Effect from "effect/Effect";
|
|
358
315
|
import { Context } from "@dxos/context";
|
|
359
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
360
316
|
var contextFromScope = () => Effect.gen(function* () {
|
|
361
|
-
const ctx = new Context(
|
|
362
|
-
F: __dxlog_file2,
|
|
363
|
-
L: 13
|
|
364
|
-
});
|
|
317
|
+
const ctx = new Context();
|
|
365
318
|
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
366
319
|
return ctx;
|
|
367
320
|
});
|
|
@@ -629,7 +582,6 @@ import * as Schema2 from "effect/Schema";
|
|
|
629
582
|
import { JSONPath } from "jsonpath-plus";
|
|
630
583
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
631
584
|
import { getDeep, setDeep } from "@dxos/util";
|
|
632
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/json-path.ts";
|
|
633
585
|
var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
|
|
634
586
|
var PROP_REGEX = /^\w+$/;
|
|
635
587
|
var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
|
|
@@ -650,28 +602,12 @@ var createJsonPath = (path) => {
|
|
|
650
602
|
return i === 0 ? p : `.${p}`;
|
|
651
603
|
}
|
|
652
604
|
}).join("");
|
|
653
|
-
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}
|
|
654
|
-
F: __dxlog_file3,
|
|
655
|
-
L: 69,
|
|
656
|
-
S: void 0,
|
|
657
|
-
A: [
|
|
658
|
-
"isJsonPath(candidatePath)",
|
|
659
|
-
"`Invalid JsonPath: ${candidatePath}`"
|
|
660
|
-
]
|
|
661
|
-
});
|
|
605
|
+
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);
|
|
662
606
|
return candidatePath;
|
|
663
607
|
};
|
|
664
608
|
var fromEffectValidationPath = (effectPath) => {
|
|
665
609
|
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
666
|
-
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}
|
|
667
|
-
F: __dxlog_file3,
|
|
668
|
-
L: 80,
|
|
669
|
-
S: void 0,
|
|
670
|
-
A: [
|
|
671
|
-
"isJsonPath(jsonPath)",
|
|
672
|
-
"`Invalid JsonPath: ${jsonPath}`"
|
|
673
|
-
]
|
|
674
|
-
});
|
|
610
|
+
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);
|
|
675
611
|
return jsonPath;
|
|
676
612
|
};
|
|
677
613
|
var splitJsonPath = (path) => {
|
|
@@ -802,6 +738,47 @@ var addTrackEntry = (options) => (effect) => Effect6.gen(function* () {
|
|
|
802
738
|
});
|
|
803
739
|
return yield* exit2;
|
|
804
740
|
});
|
|
741
|
+
|
|
742
|
+
// src/async-task-tagging.ts
|
|
743
|
+
import * as Context3 from "effect/Context";
|
|
744
|
+
import * as Effect7 from "effect/Effect";
|
|
745
|
+
import { pipe as pipe3 } from "effect/Function";
|
|
746
|
+
import * as Layer from "effect/Layer";
|
|
747
|
+
import * as Predicate from "effect/Predicate";
|
|
748
|
+
import * as Tracer from "effect/Tracer";
|
|
749
|
+
var runInTask = /* @__PURE__ */ Symbol("runInTask");
|
|
750
|
+
var asyncTaskTaggingLayer = () => {
|
|
751
|
+
if (Predicate.hasProperty(console, "createTask") === false) {
|
|
752
|
+
return Layer.empty;
|
|
753
|
+
}
|
|
754
|
+
const makeTracer = Effect7.gen(function* () {
|
|
755
|
+
const oldTracer = yield* Effect7.tracer;
|
|
756
|
+
return Tracer.make({
|
|
757
|
+
span: (name, ...args) => {
|
|
758
|
+
const span = oldTracer.span(name, ...args);
|
|
759
|
+
const trace = console.createTask(name);
|
|
760
|
+
span[runInTask] = (f) => trace.run(f);
|
|
761
|
+
return span;
|
|
762
|
+
},
|
|
763
|
+
context: (f, fiber) => {
|
|
764
|
+
const maybeParentSpan = Context3.getOption(Tracer.ParentSpan)(fiber.currentContext);
|
|
765
|
+
if (maybeParentSpan._tag === "None") {
|
|
766
|
+
return oldTracer.context(f, fiber);
|
|
767
|
+
}
|
|
768
|
+
const parentSpan = maybeParentSpan.value;
|
|
769
|
+
if (parentSpan._tag === "ExternalSpan") {
|
|
770
|
+
return oldTracer.context(f, fiber);
|
|
771
|
+
}
|
|
772
|
+
const span = parentSpan;
|
|
773
|
+
if (runInTask in span && typeof span[runInTask] === "function") {
|
|
774
|
+
return span[runInTask](() => oldTracer.context(f, fiber));
|
|
775
|
+
}
|
|
776
|
+
return oldTracer.context(f, fiber);
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
return pipe3(makeTracer, Effect7.map(Layer.setTracer), Layer.unwrapEffect);
|
|
781
|
+
};
|
|
805
782
|
export {
|
|
806
783
|
dynamic_runtime_exports as DynamicRuntime,
|
|
807
784
|
JsonPath,
|
|
@@ -812,6 +789,7 @@ export {
|
|
|
812
789
|
UrlParser,
|
|
813
790
|
VisitResult,
|
|
814
791
|
acquireReleaseResource,
|
|
792
|
+
asyncTaskTaggingLayer,
|
|
815
793
|
causeToError,
|
|
816
794
|
contextFromScope,
|
|
817
795
|
createJsonPath,
|
|
@@ -826,6 +804,7 @@ export {
|
|
|
826
804
|
getDiscriminatedType,
|
|
827
805
|
getDiscriminatingProps,
|
|
828
806
|
getField,
|
|
807
|
+
getLiteralValues,
|
|
829
808
|
getParamKeyAnnotation,
|
|
830
809
|
getProperties,
|
|
831
810
|
getValue,
|