@dxos/effect 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963
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 +76 -86
- 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 +76 -86
- 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 +3 -13
- 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 +8 -15
- package/src/ast.ts +30 -6
- package/src/async-task-tagging.ts +51 -0
- package/src/atom-kvs.ts +1 -1
- package/src/index.ts +2 -0
- package/src/testing.ts +3 -29
- 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;
|
|
@@ -38,12 +37,23 @@ var getBaseType = (prop) => {
|
|
|
38
37
|
};
|
|
39
38
|
var getProperties = (ast) => {
|
|
40
39
|
const properties = SchemaAST.getPropertySignatures(ast);
|
|
41
|
-
return properties.map((prop) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
return properties.map((prop) => {
|
|
41
|
+
const { type, refinements } = getBaseType(prop);
|
|
42
|
+
const mergedType = prop.annotations && Reflect.ownKeys(prop.annotations).length > 0 ? {
|
|
43
|
+
...type,
|
|
44
|
+
annotations: {
|
|
45
|
+
...type.annotations,
|
|
46
|
+
...prop.annotations
|
|
47
|
+
}
|
|
48
|
+
} : type;
|
|
49
|
+
return {
|
|
50
|
+
type: mergedType,
|
|
51
|
+
refinements,
|
|
52
|
+
name: prop.name,
|
|
53
|
+
isOptional: prop.isOptional,
|
|
54
|
+
isReadonly: prop.isReadonly
|
|
55
|
+
};
|
|
56
|
+
});
|
|
47
57
|
};
|
|
48
58
|
var VisitResult = /* @__PURE__ */ (function(VisitResult2) {
|
|
49
59
|
VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
|
|
@@ -140,15 +150,7 @@ var findProperty = (schema, path) => {
|
|
|
140
150
|
const getProp = (node, path2) => {
|
|
141
151
|
const [name, ...rest] = path2;
|
|
142
152
|
const typeNode = findNode(node, SchemaAST.isTypeLiteral);
|
|
143
|
-
invariant(typeNode
|
|
144
|
-
F: __dxlog_file,
|
|
145
|
-
L: 237,
|
|
146
|
-
S: void 0,
|
|
147
|
-
A: [
|
|
148
|
-
"typeNode",
|
|
149
|
-
""
|
|
150
|
-
]
|
|
151
|
-
});
|
|
153
|
+
invariant(typeNode);
|
|
152
154
|
for (const prop of SchemaAST.getPropertySignatures(typeNode)) {
|
|
153
155
|
if (prop.name === name) {
|
|
154
156
|
if (rest.length) {
|
|
@@ -196,6 +198,12 @@ var isOption = (node) => {
|
|
|
196
198
|
var isLiteralUnion = (node) => {
|
|
197
199
|
return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);
|
|
198
200
|
};
|
|
201
|
+
var getLiteralValues = (schema) => {
|
|
202
|
+
if (!isLiteralUnion(schema.ast)) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
return schema.ast.types.map((node) => node.literal);
|
|
206
|
+
};
|
|
199
207
|
var isArrayType = (node) => {
|
|
200
208
|
return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;
|
|
201
209
|
};
|
|
@@ -209,15 +217,7 @@ var isDiscriminatedUnion = (node) => {
|
|
|
209
217
|
return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
|
|
210
218
|
};
|
|
211
219
|
var getDiscriminatingProps = (node) => {
|
|
212
|
-
invariant(SchemaAST.isUnion(node)
|
|
213
|
-
F: __dxlog_file,
|
|
214
|
-
L: 355,
|
|
215
|
-
S: void 0,
|
|
216
|
-
A: [
|
|
217
|
-
"SchemaAST.isUnion(node)",
|
|
218
|
-
""
|
|
219
|
-
]
|
|
220
|
-
});
|
|
220
|
+
invariant(SchemaAST.isUnion(node));
|
|
221
221
|
if (isOption(node)) {
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
@@ -227,39 +227,15 @@ var getDiscriminatingProps = (node) => {
|
|
|
227
227
|
}, []);
|
|
228
228
|
};
|
|
229
229
|
var getDiscriminatedType = (node, value = {}) => {
|
|
230
|
-
invariant(SchemaAST.isUnion(node)
|
|
231
|
-
|
|
232
|
-
L: 379,
|
|
233
|
-
S: void 0,
|
|
234
|
-
A: [
|
|
235
|
-
"SchemaAST.isUnion(node)",
|
|
236
|
-
""
|
|
237
|
-
]
|
|
238
|
-
});
|
|
239
|
-
invariant(value, void 0, {
|
|
240
|
-
F: __dxlog_file,
|
|
241
|
-
L: 380,
|
|
242
|
-
S: void 0,
|
|
243
|
-
A: [
|
|
244
|
-
"value",
|
|
245
|
-
""
|
|
246
|
-
]
|
|
247
|
-
});
|
|
230
|
+
invariant(SchemaAST.isUnion(node));
|
|
231
|
+
invariant(value);
|
|
248
232
|
const props = getDiscriminatingProps(node);
|
|
249
233
|
if (!props?.length) {
|
|
250
234
|
return;
|
|
251
235
|
}
|
|
252
236
|
for (const type of node.types) {
|
|
253
237
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
254
|
-
invariant(SchemaAST.isLiteral(prop.type)
|
|
255
|
-
F: __dxlog_file,
|
|
256
|
-
L: 391,
|
|
257
|
-
S: void 0,
|
|
258
|
-
A: [
|
|
259
|
-
"SchemaAST.isLiteral(prop.type)",
|
|
260
|
-
""
|
|
261
|
-
]
|
|
262
|
-
});
|
|
238
|
+
invariant(SchemaAST.isLiteral(prop.type));
|
|
263
239
|
return prop.type.literal === value[prop.name.toString()];
|
|
264
240
|
});
|
|
265
241
|
if (match) {
|
|
@@ -269,15 +245,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
269
245
|
const fields = Object.fromEntries(props.map((prop) => {
|
|
270
246
|
const literals = node.types.map((type) => {
|
|
271
247
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
272
|
-
invariant(SchemaAST.isLiteral(literal.type)
|
|
273
|
-
F: __dxlog_file,
|
|
274
|
-
L: 409,
|
|
275
|
-
S: void 0,
|
|
276
|
-
A: [
|
|
277
|
-
"SchemaAST.isLiteral(literal.type)",
|
|
278
|
-
""
|
|
279
|
-
]
|
|
280
|
-
});
|
|
248
|
+
invariant(SchemaAST.isLiteral(literal.type));
|
|
281
249
|
return literal.type.literal;
|
|
282
250
|
}).filter(isNonNullable);
|
|
283
251
|
return literals.length ? [
|
|
@@ -329,8 +297,8 @@ var getIndexSignatures = (ast) => {
|
|
|
329
297
|
};
|
|
330
298
|
|
|
331
299
|
// src/atom-kvs.ts
|
|
332
|
-
import * as BrowserKeyValueStore from "@effect/platform-browser/BrowserKeyValueStore";
|
|
333
300
|
import { Atom } from "@effect-atom/atom-react";
|
|
301
|
+
import * as BrowserKeyValueStore from "@effect/platform-browser/BrowserKeyValueStore";
|
|
334
302
|
var defaultRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
|
|
335
303
|
var createKvsStore = (options) => {
|
|
336
304
|
const runtime2 = options.runtime ?? defaultRuntime;
|
|
@@ -345,12 +313,8 @@ var createKvsStore = (options) => {
|
|
|
345
313
|
// src/context.ts
|
|
346
314
|
import * as Effect from "effect/Effect";
|
|
347
315
|
import { Context } from "@dxos/context";
|
|
348
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
349
316
|
var contextFromScope = () => Effect.gen(function* () {
|
|
350
|
-
const ctx = new Context(
|
|
351
|
-
F: __dxlog_file2,
|
|
352
|
-
L: 13
|
|
353
|
-
});
|
|
317
|
+
const ctx = new Context();
|
|
354
318
|
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
355
319
|
return ctx;
|
|
356
320
|
});
|
|
@@ -618,7 +582,6 @@ import * as Schema2 from "effect/Schema";
|
|
|
618
582
|
import { JSONPath } from "jsonpath-plus";
|
|
619
583
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
620
584
|
import { getDeep, setDeep } from "@dxos/util";
|
|
621
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/json-path.ts";
|
|
622
585
|
var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
|
|
623
586
|
var PROP_REGEX = /^\w+$/;
|
|
624
587
|
var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
|
|
@@ -639,28 +602,12 @@ var createJsonPath = (path) => {
|
|
|
639
602
|
return i === 0 ? p : `.${p}`;
|
|
640
603
|
}
|
|
641
604
|
}).join("");
|
|
642
|
-
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}
|
|
643
|
-
F: __dxlog_file3,
|
|
644
|
-
L: 69,
|
|
645
|
-
S: void 0,
|
|
646
|
-
A: [
|
|
647
|
-
"isJsonPath(candidatePath)",
|
|
648
|
-
"`Invalid JsonPath: ${candidatePath}`"
|
|
649
|
-
]
|
|
650
|
-
});
|
|
605
|
+
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);
|
|
651
606
|
return candidatePath;
|
|
652
607
|
};
|
|
653
608
|
var fromEffectValidationPath = (effectPath) => {
|
|
654
609
|
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
655
|
-
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}
|
|
656
|
-
F: __dxlog_file3,
|
|
657
|
-
L: 80,
|
|
658
|
-
S: void 0,
|
|
659
|
-
A: [
|
|
660
|
-
"isJsonPath(jsonPath)",
|
|
661
|
-
"`Invalid JsonPath: ${jsonPath}`"
|
|
662
|
-
]
|
|
663
|
-
});
|
|
610
|
+
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);
|
|
664
611
|
return jsonPath;
|
|
665
612
|
};
|
|
666
613
|
var splitJsonPath = (path) => {
|
|
@@ -791,6 +738,47 @@ var addTrackEntry = (options) => (effect) => Effect6.gen(function* () {
|
|
|
791
738
|
});
|
|
792
739
|
return yield* exit2;
|
|
793
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
|
+
};
|
|
794
782
|
export {
|
|
795
783
|
dynamic_runtime_exports as DynamicRuntime,
|
|
796
784
|
JsonPath,
|
|
@@ -801,6 +789,7 @@ export {
|
|
|
801
789
|
UrlParser,
|
|
802
790
|
VisitResult,
|
|
803
791
|
acquireReleaseResource,
|
|
792
|
+
asyncTaskTaggingLayer,
|
|
804
793
|
causeToError,
|
|
805
794
|
contextFromScope,
|
|
806
795
|
createJsonPath,
|
|
@@ -815,6 +804,7 @@ export {
|
|
|
815
804
|
getDiscriminatedType,
|
|
816
805
|
getDiscriminatingProps,
|
|
817
806
|
getField,
|
|
807
|
+
getLiteralValues,
|
|
818
808
|
getParamKeyAnnotation,
|
|
819
809
|
getProperties,
|
|
820
810
|
getValue,
|