@dxos/effect 0.8.4-main.5ea62a8 → 0.8.4-main.72ec0f3
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 +82 -58
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +82 -58
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/ast.d.ts +2 -1
- package/dist/types/src/ast.d.ts.map +1 -1
- package/dist/types/src/context.d.ts +2 -1
- package/dist/types/src/context.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +3 -1
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/jsonPath.d.ts +1 -1
- package/dist/types/src/jsonPath.d.ts.map +1 -1
- package/dist/types/src/otel.d.ts +17 -0
- package/dist/types/src/otel.d.ts.map +1 -0
- package/dist/types/src/otel.test.d.ts +2 -0
- package/dist/types/src/otel.test.d.ts.map +1 -0
- package/dist/types/src/resource.d.ts +6 -2
- package/dist/types/src/resource.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +24 -1
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/src/url.d.ts +3 -1
- package/dist/types/src/url.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -7
- package/src/ast.test.ts +2 -1
- package/src/ast.ts +38 -11
- package/src/context.ts +2 -1
- package/src/errors.test.ts +1 -1
- package/src/errors.ts +12 -7
- package/src/interrupt.test.ts +4 -5
- package/src/jsonPath.ts +3 -1
- package/src/layers.test.ts +6 -2
- package/src/otel.test.ts +126 -0
- package/src/otel.ts +45 -0
- package/src/resource.test.ts +3 -3
- package/src/resource.ts +8 -3
- package/src/sanity.test.ts +24 -11
- package/src/testing.ts +29 -1
- package/src/url.test.ts +1 -1
- package/src/url.ts +5 -2
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// src/ast.ts
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import * as Function from "effect/Function";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
6
8
|
import { invariant } from "@dxos/invariant";
|
|
7
9
|
import { isNonNullable } from "@dxos/util";
|
|
8
10
|
var __dxlog_file = "/__w/dxos/dxos/packages/common/effect/src/ast.ts";
|
|
9
|
-
var
|
|
11
|
+
var isTupleType2 = (node) => {
|
|
10
12
|
return SchemaAST.isTupleType(node) && node.elements.length > 0;
|
|
11
13
|
};
|
|
12
14
|
var getSimpleType = (node) => {
|
|
13
15
|
if (SchemaAST.isDeclaration(node) || SchemaAST.isObjectKeyword(node) || SchemaAST.isTypeLiteral(node) || // TODO(wittjosiah): Tuples are actually arrays.
|
|
14
|
-
|
|
16
|
+
isTupleType2(node) || isDiscriminatedUnion(node)) {
|
|
15
17
|
return "object";
|
|
16
18
|
}
|
|
17
19
|
if (SchemaAST.isStringKeyword(node)) {
|
|
@@ -52,12 +54,12 @@ var isSimpleType = (node) => !!getSimpleType(node);
|
|
|
52
54
|
}
|
|
53
55
|
};
|
|
54
56
|
})(SimpleType || (SimpleType = {}));
|
|
55
|
-
var VisitResult = /* @__PURE__ */ function(VisitResult2) {
|
|
57
|
+
var VisitResult = /* @__PURE__ */ (function(VisitResult2) {
|
|
56
58
|
VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
|
|
57
59
|
VisitResult2[VisitResult2["SKIP"] = 1] = "SKIP";
|
|
58
60
|
VisitResult2[VisitResult2["EXIT"] = 2] = "EXIT";
|
|
59
61
|
return VisitResult2;
|
|
60
|
-
}({});
|
|
62
|
+
})({});
|
|
61
63
|
var defaultTest = isSimpleType;
|
|
62
64
|
var visit = (node, testOrVisitor, visitor) => {
|
|
63
65
|
if (!visitor) {
|
|
@@ -121,6 +123,12 @@ var findNode = (node, test) => {
|
|
|
121
123
|
return child;
|
|
122
124
|
}
|
|
123
125
|
}
|
|
126
|
+
for (const prop of getIndexSignatures(node)) {
|
|
127
|
+
const child = findNode(prop.type, test);
|
|
128
|
+
if (child) {
|
|
129
|
+
return child;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
124
132
|
} else if (SchemaAST.isTupleType(node)) {
|
|
125
133
|
for (const [_, element] of node.elements.entries()) {
|
|
126
134
|
const child = findNode(element.type, test);
|
|
@@ -129,12 +137,13 @@ var findNode = (node, test) => {
|
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
139
|
} else if (SchemaAST.isUnion(node)) {
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
if (isLiteralUnion(node)) {
|
|
141
|
+
return void 0;
|
|
142
|
+
}
|
|
143
|
+
for (const type of node.types) {
|
|
144
|
+
const child = findNode(type, test);
|
|
145
|
+
if (child) {
|
|
146
|
+
return child;
|
|
138
147
|
}
|
|
139
148
|
}
|
|
140
149
|
} else if (SchemaAST.isRefinement(node)) {
|
|
@@ -147,7 +156,7 @@ var findProperty = (schema, path) => {
|
|
|
147
156
|
const typeNode = findNode(node, SchemaAST.isTypeLiteral);
|
|
148
157
|
invariant(typeNode, void 0, {
|
|
149
158
|
F: __dxlog_file,
|
|
150
|
-
L:
|
|
159
|
+
L: 265,
|
|
151
160
|
S: void 0,
|
|
152
161
|
A: [
|
|
153
162
|
"typeNode",
|
|
@@ -172,16 +181,16 @@ var defaultAnnotations = {
|
|
|
172
181
|
["NumberKeyword"]: SchemaAST.numberKeyword,
|
|
173
182
|
["BooleanKeyword"]: SchemaAST.booleanKeyword
|
|
174
183
|
};
|
|
175
|
-
var
|
|
176
|
-
const id = pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
177
|
-
const value = pipe(SchemaAST.getAnnotation(annotationId)(node), Option.getOrUndefined);
|
|
184
|
+
var getAnnotation2 = (annotationId, noDefault = true) => (node) => {
|
|
185
|
+
const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
186
|
+
const value = Function.pipe(SchemaAST.getAnnotation(annotationId)(node), Option.getOrUndefined);
|
|
178
187
|
if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {
|
|
179
188
|
return void 0;
|
|
180
189
|
}
|
|
181
190
|
return value;
|
|
182
191
|
};
|
|
183
192
|
var findAnnotation = (node, annotationId, noDefault = true) => {
|
|
184
|
-
const getAnnotationById =
|
|
193
|
+
const getAnnotationById = getAnnotation2(annotationId, noDefault);
|
|
185
194
|
const getBaseAnnotation = (node2) => {
|
|
186
195
|
const value = getAnnotationById(node2);
|
|
187
196
|
if (value !== void 0) {
|
|
@@ -207,7 +216,7 @@ var isDiscriminatedUnion = (node) => {
|
|
|
207
216
|
var getDiscriminatingProps = (node) => {
|
|
208
217
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
209
218
|
F: __dxlog_file,
|
|
210
|
-
L:
|
|
219
|
+
L: 362,
|
|
211
220
|
S: void 0,
|
|
212
221
|
A: [
|
|
213
222
|
"SchemaAST.isUnion(node)",
|
|
@@ -225,7 +234,7 @@ var getDiscriminatingProps = (node) => {
|
|
|
225
234
|
var getDiscriminatedType = (node, value = {}) => {
|
|
226
235
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
227
236
|
F: __dxlog_file,
|
|
228
|
-
L:
|
|
237
|
+
L: 386,
|
|
229
238
|
S: void 0,
|
|
230
239
|
A: [
|
|
231
240
|
"SchemaAST.isUnion(node)",
|
|
@@ -234,7 +243,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
234
243
|
});
|
|
235
244
|
invariant(value, void 0, {
|
|
236
245
|
F: __dxlog_file,
|
|
237
|
-
L:
|
|
246
|
+
L: 387,
|
|
238
247
|
S: void 0,
|
|
239
248
|
A: [
|
|
240
249
|
"value",
|
|
@@ -249,7 +258,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
249
258
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
250
259
|
invariant(SchemaAST.isLiteral(prop.type), void 0, {
|
|
251
260
|
F: __dxlog_file,
|
|
252
|
-
L:
|
|
261
|
+
L: 398,
|
|
253
262
|
S: void 0,
|
|
254
263
|
A: [
|
|
255
264
|
"SchemaAST.isLiteral(prop.type)",
|
|
@@ -267,7 +276,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
267
276
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
268
277
|
invariant(SchemaAST.isLiteral(literal.type), void 0, {
|
|
269
278
|
F: __dxlog_file,
|
|
270
|
-
L:
|
|
279
|
+
L: 416,
|
|
271
280
|
S: void 0,
|
|
272
281
|
A: [
|
|
273
282
|
"SchemaAST.isLiteral(literal.type)",
|
|
@@ -287,7 +296,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
287
296
|
var mapAst = (ast, f) => {
|
|
288
297
|
switch (ast._tag) {
|
|
289
298
|
case "TypeLiteral": {
|
|
290
|
-
return new SchemaAST.TypeLiteral(ast.propertySignatures.map((prop) => new SchemaAST.PropertySignature(prop.name, f(prop.type, prop.name), prop.isOptional, prop.isReadonly, prop.annotations)), ast.indexSignatures);
|
|
299
|
+
return new SchemaAST.TypeLiteral(ast.propertySignatures.map((prop) => new SchemaAST.PropertySignature(prop.name, f(prop.type, prop.name), prop.isOptional, prop.isReadonly, prop.annotations)), ast.indexSignatures, ast.annotations);
|
|
291
300
|
}
|
|
292
301
|
case "Union": {
|
|
293
302
|
return SchemaAST.Union.make(ast.types.map(f), ast.annotations);
|
|
@@ -305,12 +314,28 @@ var mapAst = (ast, f) => {
|
|
|
305
314
|
}
|
|
306
315
|
};
|
|
307
316
|
var isArrayType = (node) => {
|
|
308
|
-
return SchemaAST.isTupleType(node) || SchemaAST.isUnion(node) && node.types.some(isArrayType) && node.types.some(isUndefinedKeyword) && node.types.length === 2;
|
|
317
|
+
return SchemaAST.isTupleType(node) || SchemaAST.isUnion(node) && node.types.some(isArrayType) && node.types.some(SchemaAST.isUndefinedKeyword) && node.types.length === 2;
|
|
318
|
+
};
|
|
319
|
+
var getIndexSignatures = (ast) => {
|
|
320
|
+
const annotation = SchemaAST.getSurrogateAnnotation(ast);
|
|
321
|
+
if (Option.isSome(annotation)) {
|
|
322
|
+
return getIndexSignatures(annotation.value);
|
|
323
|
+
}
|
|
324
|
+
switch (ast._tag) {
|
|
325
|
+
case "TypeLiteral":
|
|
326
|
+
return ast.indexSignatures.slice();
|
|
327
|
+
case "Suspend":
|
|
328
|
+
return getIndexSignatures(ast.f());
|
|
329
|
+
case "Refinement":
|
|
330
|
+
return getIndexSignatures(ast.from);
|
|
331
|
+
}
|
|
332
|
+
return [];
|
|
309
333
|
};
|
|
310
334
|
var SimpleType;
|
|
311
335
|
|
|
312
336
|
// src/jsonPath.ts
|
|
313
|
-
import
|
|
337
|
+
import * as Option2 from "effect/Option";
|
|
338
|
+
import * as Schema2 from "effect/Schema";
|
|
314
339
|
import { JSONPath } from "jsonpath-plus";
|
|
315
340
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
316
341
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/jsonPath.ts";
|
|
@@ -336,7 +361,7 @@ var createJsonPath = (path) => {
|
|
|
336
361
|
}).join("");
|
|
337
362
|
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
|
|
338
363
|
F: __dxlog_file2,
|
|
339
|
-
L:
|
|
364
|
+
L: 65,
|
|
340
365
|
S: void 0,
|
|
341
366
|
A: [
|
|
342
367
|
"isJsonPath(candidatePath)",
|
|
@@ -349,7 +374,7 @@ var fromEffectValidationPath = (effectPath) => {
|
|
|
349
374
|
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
350
375
|
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
|
|
351
376
|
F: __dxlog_file2,
|
|
352
|
-
L:
|
|
377
|
+
L: 76,
|
|
353
378
|
S: void 0,
|
|
354
379
|
A: [
|
|
355
380
|
"isJsonPath(jsonPath)",
|
|
@@ -372,27 +397,20 @@ var getField = (object, path) => {
|
|
|
372
397
|
};
|
|
373
398
|
|
|
374
399
|
// src/url.ts
|
|
375
|
-
import
|
|
400
|
+
import * as Function2 from "effect/Function";
|
|
401
|
+
import * as Option3 from "effect/Option";
|
|
402
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
376
403
|
import { decamelize } from "@dxos/util";
|
|
377
|
-
function _define_property(obj, key, value) {
|
|
378
|
-
if (key in obj) {
|
|
379
|
-
Object.defineProperty(obj, key, {
|
|
380
|
-
value,
|
|
381
|
-
enumerable: true,
|
|
382
|
-
configurable: true,
|
|
383
|
-
writable: true
|
|
384
|
-
});
|
|
385
|
-
} else {
|
|
386
|
-
obj[key] = value;
|
|
387
|
-
}
|
|
388
|
-
return obj;
|
|
389
|
-
}
|
|
390
404
|
var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
391
405
|
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
392
406
|
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
393
407
|
[ParamKeyAnnotationId]: value
|
|
394
408
|
});
|
|
395
409
|
var UrlParser = class {
|
|
410
|
+
_schema;
|
|
411
|
+
constructor(_schema) {
|
|
412
|
+
this._schema = _schema;
|
|
413
|
+
}
|
|
396
414
|
/**
|
|
397
415
|
* Parse URL params.
|
|
398
416
|
*/
|
|
@@ -424,7 +442,7 @@ var UrlParser = class {
|
|
|
424
442
|
if (value !== void 0) {
|
|
425
443
|
const field = this._schema.fields[key];
|
|
426
444
|
if (field) {
|
|
427
|
-
const { key: serializedKey } =
|
|
445
|
+
const { key: serializedKey } = Function2.pipe(getParamKeyAnnotation(field.ast), Option3.getOrElse(() => ({
|
|
428
446
|
key: decamelize(key)
|
|
429
447
|
})));
|
|
430
448
|
url.searchParams.set(serializedKey, String(value));
|
|
@@ -433,27 +451,28 @@ var UrlParser = class {
|
|
|
433
451
|
});
|
|
434
452
|
return url;
|
|
435
453
|
}
|
|
436
|
-
constructor(_schema) {
|
|
437
|
-
_define_property(this, "_schema", void 0);
|
|
438
|
-
this._schema = _schema;
|
|
439
|
-
}
|
|
440
454
|
};
|
|
441
455
|
|
|
442
456
|
// src/context.ts
|
|
443
|
-
import
|
|
457
|
+
import * as Effect from "effect/Effect";
|
|
444
458
|
import { Context } from "@dxos/context";
|
|
445
459
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
446
460
|
var contextFromScope = () => Effect.gen(function* () {
|
|
447
461
|
const ctx = new Context(void 0, {
|
|
448
462
|
F: __dxlog_file3,
|
|
449
|
-
L:
|
|
463
|
+
L: 13
|
|
450
464
|
});
|
|
451
465
|
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
452
466
|
return ctx;
|
|
453
467
|
});
|
|
454
468
|
|
|
455
469
|
// src/errors.ts
|
|
456
|
-
import
|
|
470
|
+
import * as Cause from "effect/Cause";
|
|
471
|
+
import * as Chunk from "effect/Chunk";
|
|
472
|
+
import * as Effect2 from "effect/Effect";
|
|
473
|
+
import * as Exit from "effect/Exit";
|
|
474
|
+
import * as GlobalValue from "effect/GlobalValue";
|
|
475
|
+
import * as Option4 from "effect/Option";
|
|
457
476
|
var spanSymbol = Symbol.for("effect/SpanAnnotation");
|
|
458
477
|
var originalSymbol = Symbol.for("effect/OriginalAnnotation");
|
|
459
478
|
var spanToTrace = GlobalValue.globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
|
|
@@ -525,9 +544,9 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
525
544
|
};
|
|
526
545
|
var causeToError = (cause) => {
|
|
527
546
|
if (Cause.isEmpty(cause)) {
|
|
528
|
-
|
|
547
|
+
return new Error("Fiber failed without a cause");
|
|
529
548
|
} else if (Cause.isInterruptedOnly(cause)) {
|
|
530
|
-
|
|
549
|
+
return new Error("Fiber was interrupted");
|
|
531
550
|
} else {
|
|
532
551
|
const errors = [
|
|
533
552
|
...Chunk.toArray(Cause.failures(cause)),
|
|
@@ -541,9 +560,9 @@ var causeToError = (cause) => {
|
|
|
541
560
|
const stackFrames = getStackFrames();
|
|
542
561
|
const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));
|
|
543
562
|
if (newErrors.length === 1) {
|
|
544
|
-
|
|
563
|
+
return newErrors[0];
|
|
545
564
|
} else {
|
|
546
|
-
|
|
565
|
+
return new AggregateError(newErrors);
|
|
547
566
|
}
|
|
548
567
|
}
|
|
549
568
|
};
|
|
@@ -570,7 +589,8 @@ var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
|
570
589
|
}).pipe(Effect2.flatten);
|
|
571
590
|
|
|
572
591
|
// src/testing.ts
|
|
573
|
-
import
|
|
592
|
+
import * as Context2 from "effect/Context";
|
|
593
|
+
import * as Effect3 from "effect/Effect";
|
|
574
594
|
(function(TestHelpers2) {
|
|
575
595
|
TestHelpers2.runIf = (condition) => (effect, ctx) => Effect3.gen(function* () {
|
|
576
596
|
if (!condition) {
|
|
@@ -593,12 +613,15 @@ import { Effect as Effect3 } from "effect";
|
|
|
593
613
|
return yield* effect;
|
|
594
614
|
}
|
|
595
615
|
});
|
|
616
|
+
TestHelpers2.provideTestContext = (effect, ctx) => Effect3.provideService(effect, TestContextService, ctx);
|
|
596
617
|
})(TestHelpers || (TestHelpers = {}));
|
|
618
|
+
var TestContextService = class extends Context2.Tag("@dxos/effect/TestContextService")() {
|
|
619
|
+
};
|
|
597
620
|
var TestHelpers;
|
|
598
621
|
|
|
599
622
|
// src/resource.ts
|
|
600
|
-
import
|
|
601
|
-
var
|
|
623
|
+
import * as Effect4 from "effect/Effect";
|
|
624
|
+
var acquireReleaseResource = (getResource) => Effect4.acquireRelease(Effect4.gen(function* () {
|
|
602
625
|
const resource = getResource();
|
|
603
626
|
yield* Effect4.promise(async () => {
|
|
604
627
|
resource.open?.();
|
|
@@ -614,10 +637,11 @@ export {
|
|
|
614
637
|
JsonProp,
|
|
615
638
|
ParamKeyAnnotation,
|
|
616
639
|
SimpleType,
|
|
640
|
+
TestContextService,
|
|
617
641
|
TestHelpers,
|
|
618
642
|
UrlParser,
|
|
619
643
|
VisitResult,
|
|
620
|
-
|
|
644
|
+
acquireReleaseResource,
|
|
621
645
|
causeToError,
|
|
622
646
|
contextFromScope,
|
|
623
647
|
createJsonPath,
|
|
@@ -625,7 +649,7 @@ export {
|
|
|
625
649
|
findNode,
|
|
626
650
|
findProperty,
|
|
627
651
|
fromEffectValidationPath,
|
|
628
|
-
getAnnotation,
|
|
652
|
+
getAnnotation2 as getAnnotation,
|
|
629
653
|
getDiscriminatedType,
|
|
630
654
|
getDiscriminatingProps,
|
|
631
655
|
getField,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ast.ts", "../../../src/jsonPath.ts", "../../../src/url.ts", "../../../src/context.ts", "../../../src/errors.ts", "../../../src/testing.ts", "../../../src/resource.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Option, Schema, SchemaAST, pipe } from 'effect';\nimport { isUndefinedKeyword } from 'effect/SchemaAST';\n\nimport { invariant } from '@dxos/invariant';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type JsonPath, type JsonProp } from './jsonPath';\n\n//\n// Refs\n// https://effect.website/docs/schema/introduction\n// https://www.npmjs.com/package/@effect/schema\n// https://effect-ts.github.io/effect/schema/SchemaAST.ts.html\n//\n\n// TODO(wittjosiah): What is a \"simple type\"?\nexport type SimpleType = 'object' | 'string' | 'number' | 'boolean' | 'enum' | 'literal';\n\nconst isTupleType = (node: SchemaAST.AST): boolean => {\n // NOTE: Arrays are represented as tuples with no elements and a rest part.\n return SchemaAST.isTupleType(node) && node.elements.length > 0;\n};\n\n/**\n * Get the base type; e.g., traverse through refinements.\n */\nexport const getSimpleType = (node: SchemaAST.AST): SimpleType | undefined => {\n if (\n SchemaAST.isDeclaration(node) ||\n SchemaAST.isObjectKeyword(node) ||\n SchemaAST.isTypeLiteral(node) ||\n // TODO(wittjosiah): Tuples are actually arrays.\n isTupleType(node) ||\n isDiscriminatedUnion(node)\n ) {\n return 'object';\n }\n\n if (SchemaAST.isStringKeyword(node)) {\n return 'string';\n }\n if (SchemaAST.isNumberKeyword(node)) {\n return 'number';\n }\n if (SchemaAST.isBooleanKeyword(node)) {\n return 'boolean';\n }\n\n if (SchemaAST.isEnums(node)) {\n return 'enum';\n }\n\n if (SchemaAST.isLiteral(node)) {\n return 'literal';\n }\n};\n\nexport const isSimpleType = (node: SchemaAST.AST): boolean => !!getSimpleType(node);\n\nexport namespace SimpleType {\n /**\n * Returns the default empty value for a given SimpleType.\n * Used for initializing new array values etc.\n */\n export const getDefaultValue = (type: SimpleType): any => {\n switch (type) {\n case 'string': {\n return '';\n }\n case 'number': {\n return 0;\n }\n case 'boolean': {\n return false;\n }\n case 'object': {\n return {};\n }\n default: {\n throw new Error(`Unsupported type for default value: ${type}`);\n }\n }\n };\n}\n\n//\n// Branded types\n//\n\nexport enum VisitResult {\n CONTINUE = 0,\n /**\n * Skip visiting children.\n */\n SKIP = 1,\n /**\n * Stop traversing immediately.\n */\n EXIT = 2,\n}\n\nexport type Path = (string | number)[];\n\nexport type TestFn = (node: SchemaAST.AST, path: Path, depth: number) => VisitResult | boolean | undefined;\n\nexport type VisitorFn = (node: SchemaAST.AST, path: Path, depth: number) => void;\n\nconst defaultTest: TestFn = isSimpleType;\n\n/**\n * Visit leaf nodes.\n * Refs:\n * - https://github.com/syntax-tree/unist-util-visit?tab=readme-ov-file#visitor\n * - https://github.com/syntax-tree/unist-util-is?tab=readme-ov-file#test\n */\nexport const visit: {\n (node: SchemaAST.AST, visitor: VisitorFn): void;\n (node: SchemaAST.AST, test: TestFn, visitor: VisitorFn): void;\n} = (node: SchemaAST.AST, testOrVisitor: TestFn | VisitorFn, visitor?: VisitorFn): void => {\n if (!visitor) {\n visitNode(node, defaultTest, testOrVisitor);\n } else {\n visitNode(node, testOrVisitor as TestFn, visitor);\n }\n};\n\nconst visitNode = (\n node: SchemaAST.AST,\n test: TestFn | undefined,\n visitor: VisitorFn,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n const $result = test?.(node, path, depth);\n const result: VisitResult =\n $result === undefined\n ? VisitResult.CONTINUE\n : typeof $result === 'boolean'\n ? $result\n ? VisitResult.CONTINUE\n : VisitResult.SKIP\n : $result;\n\n if (result === VisitResult.EXIT) {\n return result;\n }\n if (result !== VisitResult.SKIP) {\n visitor(node, path, depth);\n }\n\n // Object.\n if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const currentPath = [...path, prop.name.toString()];\n const result = visitNode(prop.type, test, visitor, currentPath, depth + 1);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Array.\n else if (SchemaAST.isTupleType(node)) {\n for (const [i, element] of node.elements.entries()) {\n const currentPath = [...path, i];\n const result = visitNode(element.type, test, visitor, currentPath, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n for (const type of node.types) {\n const result = visitNode(type, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n const result = visitNode(node.from, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n\n // TODO(burdon): Transforms?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Rewrite using visitNode?\nexport const findNode = (node: SchemaAST.AST, test: (node: SchemaAST.AST) => boolean): SchemaAST.AST | undefined => {\n if (test(node)) {\n return node;\n }\n\n // Object.\n else if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Tuple.\n else if (SchemaAST.isTupleType(node)) {\n for (const [_, element] of node.elements.entries()) {\n const child = findNode(element.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n for (const type of node.types) {\n const child = findNode(type, test);\n if (child) {\n return child;\n }\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n};\n\n/**\n * Get the AST node for the given property (dot-path).\n */\nexport const findProperty = (\n schema: Schema.Schema.AnyNoContext,\n path: JsonPath | JsonProp,\n): SchemaAST.AST | undefined => {\n const getProp = (node: SchemaAST.AST, path: JsonProp[]): SchemaAST.AST | undefined => {\n const [name, ...rest] = path;\n const typeNode = findNode(node, SchemaAST.isTypeLiteral);\n invariant(typeNode);\n for (const prop of SchemaAST.getPropertySignatures(typeNode)) {\n if (prop.name === name) {\n if (rest.length) {\n return getProp(prop.type, rest);\n } else {\n return prop.type;\n }\n }\n }\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n//\n// Annotations\n//\n\nconst defaultAnnotations: Record<string, SchemaAST.Annotated> = {\n ['ObjectKeyword' as const]: SchemaAST.objectKeyword,\n ['StringKeyword' as const]: SchemaAST.stringKeyword,\n ['NumberKeyword' as const]: SchemaAST.numberKeyword,\n ['BooleanKeyword' as const]: SchemaAST.booleanKeyword,\n};\n\n/**\n * Get annotation or return undefined.\n * @param annotationId\n * @param noDefault If true, then return undefined for effect library defined values.\n */\nexport const getAnnotation =\n <T>(annotationId: symbol, noDefault = true) =>\n (node: SchemaAST.AST): T | undefined => {\n // Title fallback seems to be the identifier.\n const id = pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);\n const value = pipe(SchemaAST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\n if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {\n return undefined;\n }\n\n return value;\n };\n\n/**\n * Recursively descend into AST to find first matching annotations.\n * Optionally skips default annotations for basic types (e.g., 'a string').\n */\n// TODO(burdon): Convert to effect pattern (i.e., return operator like getAnnotation).\nexport const findAnnotation = <T>(node: SchemaAST.AST, annotationId: symbol, noDefault = true): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId, noDefault);\n\n const getBaseAnnotation = (node: SchemaAST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n return getAnnotationById(node.types[0]) as T;\n }\n }\n };\n\n return getBaseAnnotation(node);\n};\n\n//\n// Unions\n//\n\n/**\n * Effect Schema.optional creates a union type with undefined as the second type.\n */\nexport const isOption = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.length === 2 && SchemaAST.isUndefinedKeyword(node.types[1]);\n};\n\n/**\n * Determines if the node is a union of literal types.\n */\nexport const isLiteralUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);\n};\n\n/**\n * Determines if the node is a discriminated union.\n */\nexport const isDiscriminatedUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;\n};\n\n/**\n * Get the discriminating properties for the given union type.\n */\nexport const getDiscriminatingProps = (node: SchemaAST.AST): string[] | undefined => {\n invariant(SchemaAST.isUnion(node));\n if (isOption(node)) {\n return;\n }\n\n // Get common literals across all types.\n return node.types.reduce<string[]>((shared, type) => {\n const props = SchemaAST.getPropertySignatures(type)\n // TODO(burdon): Should check each literal is unique.\n .filter((p) => SchemaAST.isLiteral(p.type))\n .map((p) => p.name.toString());\n\n // Return common literals.\n return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));\n }, []);\n};\n\n/**\n * Get the discriminated type for the given value.\n */\nexport const getDiscriminatedType = (\n node: SchemaAST.AST,\n value: Record<string, any> = {},\n): SchemaAST.AST | undefined => {\n invariant(SchemaAST.isUnion(node));\n invariant(value);\n const props = getDiscriminatingProps(node);\n if (!props?.length) {\n return;\n }\n\n // Match provided values.\n for (const type of node.types) {\n const match = SchemaAST.getPropertySignatures(type)\n .filter((prop) => props?.includes(prop.name.toString()))\n .every((prop) => {\n invariant(SchemaAST.isLiteral(prop.type));\n return prop.type.literal === value[prop.name.toString()];\n });\n\n if (match) {\n return type;\n }\n }\n\n // Create union of discriminating properties.\n // NOTE: This may not work with non-overlapping variants.\n // TODO(burdon): Iterate through props and knock-out variants that don't match.\n const fields = Object.fromEntries(\n props\n .map((prop) => {\n const literals = node.types\n .map((type) => {\n const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop)!;\n invariant(SchemaAST.isLiteral(literal.type));\n return literal.type.literal;\n })\n .filter(isNonNullable);\n\n return literals.length ? [prop, Schema.Literal(...literals)] : undefined;\n })\n .filter(isNonNullable),\n );\n\n const schema = Schema.Struct(fields);\n return schema.ast;\n};\n\n/**\n * Maps AST nodes.\n * The user is responsible for recursively calling {@link mapAst} on the SchemaAST.\n * NOTE: Will evaluate suspended ASTs.\n */\nexport const mapAst = (\n ast: SchemaAST.AST,\n f: (ast: SchemaAST.AST, key: keyof any | undefined) => SchemaAST.AST,\n): SchemaAST.AST => {\n switch (ast._tag) {\n case 'TypeLiteral': {\n return new SchemaAST.TypeLiteral(\n ast.propertySignatures.map(\n (prop) =>\n new SchemaAST.PropertySignature(\n prop.name,\n f(prop.type, prop.name),\n prop.isOptional,\n prop.isReadonly,\n prop.annotations,\n ),\n ),\n ast.indexSignatures,\n );\n }\n case 'Union': {\n return SchemaAST.Union.make(ast.types.map(f), ast.annotations);\n }\n case 'TupleType': {\n return new SchemaAST.TupleType(\n ast.elements.map((t, index) => new SchemaAST.OptionalType(f(t.type, index), t.isOptional, t.annotations)),\n ast.rest.map((t) => new SchemaAST.Type(f(t.type, undefined), t.annotations)),\n ast.isReadonly,\n ast.annotations,\n );\n }\n case 'Suspend': {\n const newAst = f(ast.f(), undefined);\n return new SchemaAST.Suspend(() => newAst, ast.annotations);\n }\n default: {\n // TODO(dmaretskyi): Support more nodes.\n return ast;\n }\n }\n};\n\n/**\n * @returns true if AST is for Array(T) or optional(Array(T)).\n */\nexport const isArrayType = (node: SchemaAST.AST): boolean => {\n return (\n SchemaAST.isTupleType(node) ||\n (SchemaAST.isUnion(node) &&\n node.types.some(isArrayType) &&\n node.types.some(isUndefinedKeyword) &&\n node.types.length === 2)\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Option, Schema } from 'effect';\nimport { JSONPath } from 'jsonpath-plus';\n\nimport { invariant } from '@dxos/invariant';\n\nexport type JsonProp = string & { __JsonPath: true; __JsonProp: true };\nexport type JsonPath = string & { __JsonPath: true };\n\nconst PATH_REGEX = /^($|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*|\\[\\d+\\](?:\\.)?)*$)/;\nconst PROP_REGEX = /^\\w+$/;\n\n/**\n * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html\n */\nexport const JsonPath = Schema.String.pipe(Schema.pattern(PATH_REGEX)).annotations({\n title: 'JSON path',\n description: 'JSON path to a property',\n}) as any as Schema.Schema<JsonPath>;\nexport const JsonProp = Schema.NonEmptyString.pipe(\n Schema.pattern(PROP_REGEX, {\n message: () => 'Property name must contain only letters, numbers, and underscores',\n }),\n) as any as Schema.Schema<JsonProp>;\n\nexport const isJsonPath = (value: unknown): value is JsonPath => {\n return Option.isSome(Schema.validateOption(JsonPath)(value));\n};\n\n/**\n * Creates a JsonPath from an array of path segments.\n *\n * Currently supports:\n * - Simple property access (e.g., 'foo.bar')\n * - Array indexing with non-negative integers (e.g., 'foo[0]')\n * - Identifiers starting with letters, underscore, or $ (e.g., '$foo', '_bar')\n * - Dot notation for nested properties (e.g., 'foo.bar.baz')\n *\n * Does not support (yet?).\n * - Recursive descent (..)\n * - Wildcards (*)\n * - Array slicing\n * - Filters\n * - Negative indices\n *\n * @param path Array of string or number segments\n * @returns Valid JsonPath or undefined if invalid\n */\nexport const createJsonPath = (path: (string | number)[]): JsonPath => {\n const candidatePath = path\n .map((p, i) => {\n if (typeof p === 'number') {\n return `[${p}]`;\n } else {\n return i === 0 ? p : `.${p}`;\n }\n })\n .join('');\n\n invariant(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);\n return candidatePath;\n};\n\n/**\n * Converts Effect validation path format (e.g. \"addresses.[0].zip\")\n * to JsonPath format (e.g., \"addresses[0].zip\")\n */\nexport const fromEffectValidationPath = (effectPath: string): JsonPath => {\n // Handle array notation: convert \"prop.[0]\" to \"prop[0]\"\n const jsonPath = effectPath.replace(/\\.\\[(\\d+)\\]/g, '[$1]');\n invariant(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);\n return jsonPath;\n};\n\n/**\n * Splits a JsonPath into its constituent parts.\n * Handles property access and array indexing.\n */\nexport const splitJsonPath = (path: JsonPath): string[] => {\n if (!isJsonPath(path)) {\n return [];\n }\n\n return (\n path\n .match(/[a-zA-Z_$][\\w$]*|\\[\\d+\\]/g)\n ?.map((part) => (part.startsWith('[') ? part.replace(/[[\\]]/g, '') : part)) ?? []\n );\n};\n\n/**\n * Applies a JsonPath to an object.\n */\nexport const getField = (object: any, path: JsonPath): any => {\n // By default, JSONPath returns an array of results.\n return JSONPath({ path, json: object })[0];\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Option, type Schema, SchemaAST, pipe } from 'effect';\n\nimport { decamelize } from '@dxos/util';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: SchemaAST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n SchemaAST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends Schema.Annotable.All>(self: S): Schema.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: Schema.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (SchemaAST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (SchemaAST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect, type Scope } from 'effect';\n\nimport { Context } from '@dxos/context';\n\n// TODO(dmaretskyi): Error handling.\nexport const contextFromScope = (): Effect.Effect<Context, never, Scope.Scope> =>\n Effect.gen(function* () {\n const ctx = new Context();\n yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));\n return ctx;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Cause, Chunk, Effect, Exit, GlobalValue, Option } from 'effect';\nimport type { AnySpan, Span } from 'effect/Tracer';\n\nconst spanSymbol = Symbol.for('effect/SpanAnnotation');\nconst originalSymbol = Symbol.for('effect/OriginalAnnotation');\nconst spanToTrace = GlobalValue.globalValue('effect/Tracer/spanToTrace', () => new WeakMap());\nconst locationRegex = /\\((.*)\\)/g;\n\n/**\n * Adds effect spans.\n * Removes effect internal functions.\n * Unwraps error proxy.\n */\nconst prettyErrorStack = (error: any, appendStacks: string[] = []): any => {\n const span = error[spanSymbol];\n\n const lines = typeof error.stack === 'string' ? error.stack.split('\\n') : [];\n const out = [];\n\n let atStack = false;\n for (let i = 0; i < lines.length; i++) {\n if (!atStack && !lines[i].startsWith(' at ')) {\n out.push(lines[i]);\n continue;\n }\n atStack = true;\n\n if (lines[i].includes(' at new BaseEffectError') || lines[i].includes(' at new YieldableError')) {\n i++;\n continue;\n }\n if (lines[i].includes('Generator.next')) {\n break;\n }\n if (lines[i].includes('effect_internal_function')) {\n break;\n }\n out.push(\n lines[i]\n .replace(/at .*effect_instruction_i.*\\((.*)\\)/, 'at $1')\n .replace(/EffectPrimitive\\.\\w+/, '<anonymous>')\n .replace(/at Arguments\\./, 'at '),\n );\n }\n\n if (span) {\n let current: Span | AnySpan | undefined = span;\n let i = 0;\n while (current && current._tag === 'Span' && i < 10) {\n const stackFn = spanToTrace.get(current);\n if (typeof stackFn === 'function') {\n const stack = stackFn();\n if (typeof stack === 'string') {\n const locationMatchAll = stack.matchAll(locationRegex);\n let match = false;\n for (const [, location] of locationMatchAll) {\n match = true;\n out.push(` at ${current.name} (${location})`);\n }\n if (!match) {\n out.push(` at ${current.name} (${stack.replace(/^at /, '')})`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n current = Option.getOrUndefined(current.parent);\n i++;\n }\n }\n\n out.push(...appendStacks);\n\n if (error[originalSymbol]) {\n error = error[originalSymbol];\n }\n if (error.cause) {\n error.cause = prettyErrorStack(error.cause);\n }\n\n Object.defineProperty(error, 'stack', {\n value: out.join('\\n'),\n writable: true,\n enumerable: false,\n configurable: true,\n });\n\n return error;\n};\n\n/**\n * Converts a cause to an error.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const causeToError = (cause: Cause.Cause<any>): Error => {\n if (Cause.isEmpty(cause)) {\n throw new Error('Fiber failed without a cause');\n } else if (Cause.isInterruptedOnly(cause)) {\n throw new Error('Fiber was interrupted');\n } else {\n const errors = [...Chunk.toArray(Cause.failures(cause)), ...Chunk.toArray(Cause.defects(cause))];\n\n const getStackFrames = (): string[] => {\n const o: { stack: string } = {} as any;\n Error.captureStackTrace(o, getStackFrames);\n return o.stack.split('\\n').slice(1);\n };\n\n const stackFrames = getStackFrames();\n const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));\n\n if (newErrors.length === 1) {\n throw newErrors[0];\n } else {\n throw new AggregateError(newErrors);\n }\n }\n};\n\n/**\n * Throws an error based on the cause.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const throwCause = (cause: Cause.Cause<any>): never => {\n throw causeToError(cause);\n};\n\nexport const unwrapExit = <A>(exit: Exit.Exit<A, any>): A => {\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n return throwCause(exit.cause);\n};\n\n/**\n * Runs the embedded effect asynchronously and throws any failures and defects as errors.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const runAndForwardErrors = async <A, E>(\n effect: Effect.Effect<A, E, never>,\n options?: { signal?: AbortSignal },\n): Promise<A> => {\n const exit = await Effect.runPromiseExit(effect, options);\n return unwrapExit(exit);\n};\n\n/**\n * Like `Effect.promise` but also caputes spans for defects.\n * Workaround for: https://github.com/Effect-TS/effect/issues/5436\n */\nexport const promiseWithCauseCapture: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Effect.Effect<A> = (\n evaluate,\n) =>\n Effect.promise(async (signal) => {\n try {\n const result = await evaluate(signal);\n return Effect.succeed(result);\n } catch (err) {\n return Effect.die(err);\n }\n }).pipe(Effect.flatten);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect } from 'effect';\nimport type { TestContext } from 'vitest';\n\n// TODO(dmaretskyi): Add all different test tags here.\nexport type TestTag =\n | 'flaky' // Flaky tests.\n | 'llm' // Tests with AI.\n | 'sync'; // Sync with external services.\n\nexport namespace TestHelpers {\n /**\n * Skip the test if the condition is false.\n *\n * Exmaple:\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 * Exmaple:\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 * Skips this test if the tag is not in the list of tags to run.\n * Tags are specified in the `DX_TEST_TAGS` environment variable.\n *\n * @param tag\n * @returns\n */\n export const taggedTest =\n (tag: TestTag) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (!process.env.DX_TEST_TAGS?.includes(tag)) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect } from 'effect';\n\nimport type { Lifecycle } from '@dxos/context';\n\n// TODO(dmaretskyi): Extract to effect-utils.\nexport const accuireReleaseResource = <T extends Lifecycle>(getResource: () => T) =>\n Effect.acquireRelease(\n Effect.gen(function* () {\n const resource = getResource();\n yield* Effect.promise(async () => {\n resource.open?.();\n return undefined;\n });\n return resource;\n }),\n (resource) =>\n Effect.promise(async () => {\n resource.close?.();\n return undefined;\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,QAAQC,QAAQC,WAAWC,YAAY;AAChD,SAASC,0BAA0B;AAEnC,SAASC,iBAAiB;AAC1B,SAASC,qBAAqB;;AAc9B,IAAMC,cAAc,CAACC,SAAAA;AAEnB,SAAON,UAAUK,YAAYC,IAAAA,KAASA,KAAKC,SAASC,SAAS;AAC/D;AAKO,IAAMC,gBAAgB,CAACH,SAAAA;AAC5B,MACEN,UAAUU,cAAcJ,IAAAA,KACxBN,UAAUW,gBAAgBL,IAAAA,KAC1BN,UAAUY,cAAcN,IAAAA;EAExBD,YAAYC,IAAAA,KACZO,qBAAqBP,IAAAA,GACrB;AACA,WAAO;EACT;AAEA,MAAIN,UAAUc,gBAAgBR,IAAAA,GAAO;AACnC,WAAO;EACT;AACA,MAAIN,UAAUe,gBAAgBT,IAAAA,GAAO;AACnC,WAAO;EACT;AACA,MAAIN,UAAUgB,iBAAiBV,IAAAA,GAAO;AACpC,WAAO;EACT;AAEA,MAAIN,UAAUiB,QAAQX,IAAAA,GAAO;AAC3B,WAAO;EACT;AAEA,MAAIN,UAAUkB,UAAUZ,IAAAA,GAAO;AAC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B,CAAsBC,gBAC1DC,QAAOC,eACLD,QAAOE,IAAI,aAAA;AACT,QAAMC,WAAWJ,YAAAA;AACjB,SAAOC,QAAOI,QAAQ,YAAA;AACpBD,aAASE,OAAI;AACb,WAAOC;EACT,CAAA;AACA,SAAOH;AACT,CAAA,GACA,CAACA,aACCH,QAAOI,QAAQ,YAAA;AACbD,WAASI,QAAK;AACd,SAAOD;AACT,CAAA,CAAA;",
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { invariant } from '@dxos/invariant';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type JsonPath, type JsonProp } from './jsonPath';\n\n//\n// Refs\n// https://effect.website/docs/schema/introduction\n// https://www.npmjs.com/package/@effect/schema\n// https://effect-ts.github.io/effect/schema/SchemaAST.ts.html\n//\n\n// TODO(wittjosiah): What is a \"simple type\"?\nexport type SimpleType = 'object' | 'string' | 'number' | 'boolean' | 'enum' | 'literal';\n\nconst isTupleType = (node: SchemaAST.AST): boolean => {\n // NOTE: Arrays are represented as tuples with no elements and a rest part.\n return SchemaAST.isTupleType(node) && node.elements.length > 0;\n};\n\n/**\n * Get the base type; e.g., traverse through refinements.\n */\nexport const getSimpleType = (node: SchemaAST.AST): SimpleType | undefined => {\n if (\n SchemaAST.isDeclaration(node) ||\n SchemaAST.isObjectKeyword(node) ||\n SchemaAST.isTypeLiteral(node) ||\n // TODO(wittjosiah): Tuples are actually arrays.\n isTupleType(node) ||\n isDiscriminatedUnion(node)\n ) {\n return 'object';\n }\n\n if (SchemaAST.isStringKeyword(node)) {\n return 'string';\n }\n if (SchemaAST.isNumberKeyword(node)) {\n return 'number';\n }\n if (SchemaAST.isBooleanKeyword(node)) {\n return 'boolean';\n }\n\n if (SchemaAST.isEnums(node)) {\n return 'enum';\n }\n\n if (SchemaAST.isLiteral(node)) {\n return 'literal';\n }\n};\n\nexport const isSimpleType = (node: SchemaAST.AST): boolean => !!getSimpleType(node);\n\nexport namespace SimpleType {\n /**\n * Returns the default empty value for a given SimpleType.\n * Used for initializing new array values etc.\n */\n export const getDefaultValue = (type: SimpleType): any => {\n switch (type) {\n case 'string': {\n return '';\n }\n case 'number': {\n return 0;\n }\n case 'boolean': {\n return false;\n }\n case 'object': {\n return {};\n }\n default: {\n throw new Error(`Unsupported type for default value: ${type}`);\n }\n }\n };\n}\n\n//\n// Branded types\n//\n\nexport enum VisitResult {\n CONTINUE = 0,\n /**\n * Skip visiting children.\n */\n SKIP = 1,\n /**\n * Stop traversing immediately.\n */\n EXIT = 2,\n}\n\nexport type Path = (string | number)[];\n\nexport type TestFn = (node: SchemaAST.AST, path: Path, depth: number) => VisitResult | boolean | undefined;\n\nexport type VisitorFn = (node: SchemaAST.AST, path: Path, depth: number) => void;\n\nconst defaultTest: TestFn = isSimpleType;\n\n/**\n * Visit leaf nodes.\n * Refs:\n * - https://github.com/syntax-tree/unist-util-visit?tab=readme-ov-file#visitor\n * - https://github.com/syntax-tree/unist-util-is?tab=readme-ov-file#test\n */\nexport const visit: {\n (node: SchemaAST.AST, visitor: VisitorFn): void;\n (node: SchemaAST.AST, test: TestFn, visitor: VisitorFn): void;\n} = (node: SchemaAST.AST, testOrVisitor: TestFn | VisitorFn, visitor?: VisitorFn): void => {\n if (!visitor) {\n visitNode(node, defaultTest, testOrVisitor);\n } else {\n visitNode(node, testOrVisitor as TestFn, visitor);\n }\n};\n\nconst visitNode = (\n node: SchemaAST.AST,\n test: TestFn | undefined,\n visitor: VisitorFn,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n const $result = test?.(node, path, depth);\n const result: VisitResult =\n $result === undefined\n ? VisitResult.CONTINUE\n : typeof $result === 'boolean'\n ? $result\n ? VisitResult.CONTINUE\n : VisitResult.SKIP\n : $result;\n\n if (result === VisitResult.EXIT) {\n return result;\n }\n if (result !== VisitResult.SKIP) {\n visitor(node, path, depth);\n }\n\n // Object.\n if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const currentPath = [...path, prop.name.toString()];\n const result = visitNode(prop.type, test, visitor, currentPath, depth + 1);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Array.\n else if (SchemaAST.isTupleType(node)) {\n for (const [i, element] of node.elements.entries()) {\n const currentPath = [...path, i];\n const result = visitNode(element.type, test, visitor, currentPath, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n for (const type of node.types) {\n const result = visitNode(type, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n const result = visitNode(node.from, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n\n // TODO(burdon): Transforms?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Rewrite using visitNode?\nexport const findNode = (node: SchemaAST.AST, test: (node: SchemaAST.AST) => boolean): SchemaAST.AST | undefined => {\n if (test(node)) {\n return node;\n }\n\n // Object.\n else if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n for (const prop of getIndexSignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Tuple.\n else if (SchemaAST.isTupleType(node)) {\n for (const [_, element] of node.elements.entries()) {\n const child = findNode(element.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n if (isLiteralUnion(node)) {\n return undefined;\n }\n\n for (const type of node.types) {\n const child = findNode(type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n};\n\n/**\n * Get the AST node for the given property (dot-path).\n */\nexport const findProperty = (\n schema: Schema.Schema.AnyNoContext,\n path: JsonPath | JsonProp,\n): SchemaAST.AST | undefined => {\n const getProp = (node: SchemaAST.AST, path: JsonProp[]): SchemaAST.AST | undefined => {\n const [name, ...rest] = path;\n const typeNode = findNode(node, SchemaAST.isTypeLiteral);\n invariant(typeNode);\n for (const prop of SchemaAST.getPropertySignatures(typeNode)) {\n if (prop.name === name) {\n if (rest.length) {\n return getProp(prop.type, rest);\n } else {\n return prop.type;\n }\n }\n }\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n//\n// Annotations\n//\n\nconst defaultAnnotations: Record<string, SchemaAST.Annotated> = {\n ['ObjectKeyword' as const]: SchemaAST.objectKeyword,\n ['StringKeyword' as const]: SchemaAST.stringKeyword,\n ['NumberKeyword' as const]: SchemaAST.numberKeyword,\n ['BooleanKeyword' as const]: SchemaAST.booleanKeyword,\n};\n\n/**\n * Get annotation or return undefined.\n * @param annotationId\n * @param noDefault If true, then return undefined for effect library defined values.\n */\nexport const getAnnotation =\n <T>(annotationId: symbol, noDefault = true) =>\n (node: SchemaAST.AST): T | undefined => {\n // Title fallback seems to be the identifier.\n const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);\n const value = Function.pipe(SchemaAST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\n if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {\n return undefined;\n }\n\n return value;\n };\n\n/**\n * Recursively descend into AST to find first matching annotations.\n * Optionally skips default annotations for basic types (e.g., 'a string').\n */\n// TODO(burdon): Convert to effect pattern (i.e., return operator like getAnnotation).\nexport const findAnnotation = <T>(node: SchemaAST.AST, annotationId: symbol, noDefault = true): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId, noDefault);\n\n const getBaseAnnotation = (node: SchemaAST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n return getAnnotationById(node.types[0]) as T;\n }\n }\n };\n\n return getBaseAnnotation(node);\n};\n\n//\n// Unions\n//\n\n/**\n * Effect Schema.optional creates a union type with undefined as the second type.\n */\nexport const isOption = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.length === 2 && SchemaAST.isUndefinedKeyword(node.types[1]);\n};\n\n/**\n * Determines if the node is a union of literal types.\n */\nexport const isLiteralUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);\n};\n\n/**\n * Determines if the node is a discriminated union.\n */\nexport const isDiscriminatedUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;\n};\n\n/**\n * Get the discriminating properties for the given union type.\n */\nexport const getDiscriminatingProps = (node: SchemaAST.AST): string[] | undefined => {\n invariant(SchemaAST.isUnion(node));\n if (isOption(node)) {\n return;\n }\n\n // Get common literals across all types.\n return node.types.reduce<string[]>((shared, type) => {\n const props = SchemaAST.getPropertySignatures(type)\n // TODO(burdon): Should check each literal is unique.\n .filter((p) => SchemaAST.isLiteral(p.type))\n .map((p) => p.name.toString());\n\n // Return common literals.\n return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));\n }, []);\n};\n\n/**\n * Get the discriminated type for the given value.\n */\nexport const getDiscriminatedType = (\n node: SchemaAST.AST,\n value: Record<string, any> = {},\n): SchemaAST.AST | undefined => {\n invariant(SchemaAST.isUnion(node));\n invariant(value);\n const props = getDiscriminatingProps(node);\n if (!props?.length) {\n return;\n }\n\n // Match provided values.\n for (const type of node.types) {\n const match = SchemaAST.getPropertySignatures(type)\n .filter((prop) => props?.includes(prop.name.toString()))\n .every((prop) => {\n invariant(SchemaAST.isLiteral(prop.type));\n return prop.type.literal === value[prop.name.toString()];\n });\n\n if (match) {\n return type;\n }\n }\n\n // Create union of discriminating properties.\n // NOTE: This may not work with non-overlapping variants.\n // TODO(burdon): Iterate through props and knock-out variants that don't match.\n const fields = Object.fromEntries(\n props\n .map((prop) => {\n const literals = node.types\n .map((type) => {\n const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop)!;\n invariant(SchemaAST.isLiteral(literal.type));\n return literal.type.literal;\n })\n .filter(isNonNullable);\n\n return literals.length ? [prop, Schema.Literal(...literals)] : undefined;\n })\n .filter(isNonNullable),\n );\n\n const schema = Schema.Struct(fields);\n return schema.ast;\n};\n\n/**\n * Maps AST nodes.\n * The user is responsible for recursively calling {@link mapAst} on the SchemaAST.\n * NOTE: Will evaluate suspended ASTs.\n */\nexport const mapAst = (\n ast: SchemaAST.AST,\n f: (ast: SchemaAST.AST, key: keyof any | undefined) => SchemaAST.AST,\n): SchemaAST.AST => {\n switch (ast._tag) {\n case 'TypeLiteral': {\n return new SchemaAST.TypeLiteral(\n ast.propertySignatures.map(\n (prop) =>\n new SchemaAST.PropertySignature(\n prop.name,\n f(prop.type, prop.name),\n prop.isOptional,\n prop.isReadonly,\n prop.annotations,\n ),\n ),\n ast.indexSignatures,\n ast.annotations,\n );\n }\n case 'Union': {\n return SchemaAST.Union.make(ast.types.map(f), ast.annotations);\n }\n case 'TupleType': {\n return new SchemaAST.TupleType(\n ast.elements.map((t, index) => new SchemaAST.OptionalType(f(t.type, index), t.isOptional, t.annotations)),\n ast.rest.map((t) => new SchemaAST.Type(f(t.type, undefined), t.annotations)),\n ast.isReadonly,\n ast.annotations,\n );\n }\n case 'Suspend': {\n const newAst = f(ast.f(), undefined);\n return new SchemaAST.Suspend(() => newAst, ast.annotations);\n }\n default: {\n // TODO(dmaretskyi): Support more nodes.\n return ast;\n }\n }\n};\n\n/**\n * @returns true if AST is for Array(T) or optional(Array(T)).\n */\nexport const isArrayType = (node: SchemaAST.AST): boolean => {\n return (\n SchemaAST.isTupleType(node) ||\n (SchemaAST.isUnion(node) &&\n node.types.some(isArrayType) &&\n node.types.some(SchemaAST.isUndefinedKeyword) &&\n node.types.length === 2)\n );\n};\n\nconst getIndexSignatures = (ast: SchemaAST.AST): Array<SchemaAST.IndexSignature> => {\n const annotation = SchemaAST.getSurrogateAnnotation(ast);\n if (Option.isSome(annotation)) {\n return getIndexSignatures(annotation.value);\n }\n switch (ast._tag) {\n case 'TypeLiteral':\n return ast.indexSignatures.slice();\n case 'Suspend':\n return getIndexSignatures(ast.f());\n case 'Refinement':\n return getIndexSignatures(ast.from);\n }\n return [];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport { JSONPath } from 'jsonpath-plus';\n\nimport { invariant } from '@dxos/invariant';\n\nexport type JsonProp = string & { __JsonPath: true; __JsonProp: true };\nexport type JsonPath = string & { __JsonPath: true };\n\nconst PATH_REGEX = /^($|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*|\\[\\d+\\](?:\\.)?)*$)/;\nconst PROP_REGEX = /^\\w+$/;\n\n/**\n * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html\n */\n// TODO(burdon): Keys could be arbitrary strings.\nexport const JsonPath = Schema.String.pipe(Schema.pattern(PATH_REGEX)).annotations({\n title: 'JSON path',\n description: 'JSON path to a property',\n}) as any as Schema.Schema<JsonPath>;\nexport const JsonProp = Schema.NonEmptyString.pipe(\n Schema.pattern(PROP_REGEX, {\n message: () => 'Property name must contain only letters, numbers, and underscores',\n }),\n) as any as Schema.Schema<JsonProp>;\n\nexport const isJsonPath = (value: unknown): value is JsonPath => {\n return Option.isSome(Schema.validateOption(JsonPath)(value));\n};\n\n/**\n * Creates a JsonPath from an array of path segments.\n *\n * Currently supports:\n * - Simple property access (e.g., 'foo.bar')\n * - Array indexing with non-negative integers (e.g., 'foo[0]')\n * - Identifiers starting with letters, underscore, or $ (e.g., '$foo', '_bar')\n * - Dot notation for nested properties (e.g., 'foo.bar.baz')\n *\n * Does not support (yet?).\n * - Recursive descent (..)\n * - Wildcards (*)\n * - Array slicing\n * - Filters\n * - Negative indices\n *\n * @param path Array of string or number segments\n * @returns Valid JsonPath or undefined if invalid\n */\nexport const createJsonPath = (path: (string | number)[]): JsonPath => {\n const candidatePath = path\n .map((p, i) => {\n if (typeof p === 'number') {\n return `[${p}]`;\n } else {\n return i === 0 ? p : `.${p}`;\n }\n })\n .join('');\n\n invariant(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);\n return candidatePath;\n};\n\n/**\n * Converts Effect validation path format (e.g. \"addresses.[0].zip\")\n * to JsonPath format (e.g., \"addresses[0].zip\")\n */\nexport const fromEffectValidationPath = (effectPath: string): JsonPath => {\n // Handle array notation: convert \"prop.[0]\" to \"prop[0]\"\n const jsonPath = effectPath.replace(/\\.\\[(\\d+)\\]/g, '[$1]');\n invariant(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);\n return jsonPath;\n};\n\n/**\n * Splits a JsonPath into its constituent parts.\n * Handles property access and array indexing.\n */\nexport const splitJsonPath = (path: JsonPath): string[] => {\n if (!isJsonPath(path)) {\n return [];\n }\n\n return (\n path\n .match(/[a-zA-Z_$][\\w$]*|\\[\\d+\\]/g)\n ?.map((part) => (part.startsWith('[') ? part.replace(/[[\\]]/g, '') : part)) ?? []\n );\n};\n\n/**\n * Applies a JsonPath to an object.\n */\nexport const getField = (object: any, path: JsonPath): any => {\n // By default, JSONPath returns an array of results.\n return JSONPath({ path, json: object })[0];\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport type * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { decamelize } from '@dxos/util';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: SchemaAST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n SchemaAST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends Schema.Annotable.All>(self: S): Schema.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: Schema.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (SchemaAST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (SchemaAST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = Function.pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Scope from 'effect/Scope';\n\nimport { Context } from '@dxos/context';\n\n// TODO(dmaretskyi): Error handling.\nexport const contextFromScope = (): Effect.Effect<Context, never, Scope.Scope> =>\n Effect.gen(function* () {\n const ctx = new Context();\n yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));\n return ctx;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Chunk from 'effect/Chunk';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as GlobalValue from 'effect/GlobalValue';\nimport * as Option from 'effect/Option';\nimport type * as Tracer from 'effect/Tracer';\n\nconst spanSymbol = Symbol.for('effect/SpanAnnotation');\nconst originalSymbol = Symbol.for('effect/OriginalAnnotation');\nconst spanToTrace = GlobalValue.globalValue('effect/Tracer/spanToTrace', () => new WeakMap());\nconst locationRegex = /\\((.*)\\)/g;\n\n/**\n * Adds effect spans.\n * Removes effect internal functions.\n * Unwraps error proxy.\n */\nconst prettyErrorStack = (error: any, appendStacks: string[] = []): any => {\n const span = error[spanSymbol];\n\n const lines = typeof error.stack === 'string' ? error.stack.split('\\n') : [];\n const out = [];\n\n let atStack = false;\n for (let i = 0; i < lines.length; i++) {\n if (!atStack && !lines[i].startsWith(' at ')) {\n out.push(lines[i]);\n continue;\n }\n atStack = true;\n\n if (lines[i].includes(' at new BaseEffectError') || lines[i].includes(' at new YieldableError')) {\n i++;\n continue;\n }\n if (lines[i].includes('Generator.next')) {\n break;\n }\n if (lines[i].includes('effect_internal_function')) {\n break;\n }\n out.push(\n lines[i]\n .replace(/at .*effect_instruction_i.*\\((.*)\\)/, 'at $1')\n .replace(/EffectPrimitive\\.\\w+/, '<anonymous>')\n .replace(/at Arguments\\./, 'at '),\n );\n }\n\n if (span) {\n let current: Tracer.Span | Tracer.AnySpan | undefined = span;\n let i = 0;\n while (current && current._tag === 'Span' && i < 10) {\n const stackFn = spanToTrace.get(current);\n if (typeof stackFn === 'function') {\n const stack = stackFn();\n if (typeof stack === 'string') {\n const locationMatchAll = stack.matchAll(locationRegex);\n let match = false;\n for (const [, location] of locationMatchAll) {\n match = true;\n out.push(` at ${current.name} (${location})`);\n }\n if (!match) {\n out.push(` at ${current.name} (${stack.replace(/^at /, '')})`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n current = Option.getOrUndefined(current.parent);\n i++;\n }\n }\n\n out.push(...appendStacks);\n\n if (error[originalSymbol]) {\n error = error[originalSymbol];\n }\n if (error.cause) {\n error.cause = prettyErrorStack(error.cause);\n }\n\n Object.defineProperty(error, 'stack', {\n value: out.join('\\n'),\n writable: true,\n enumerable: false,\n configurable: true,\n });\n\n return error;\n};\n\n/**\n * Converts a cause to an error.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const causeToError = (cause: Cause.Cause<any>): Error => {\n if (Cause.isEmpty(cause)) {\n return new Error('Fiber failed without a cause');\n } else if (Cause.isInterruptedOnly(cause)) {\n return new Error('Fiber was interrupted');\n } else {\n const errors = [...Chunk.toArray(Cause.failures(cause)), ...Chunk.toArray(Cause.defects(cause))];\n\n const getStackFrames = (): string[] => {\n const o: { stack: string } = {} as any;\n Error.captureStackTrace(o, getStackFrames);\n return o.stack.split('\\n').slice(1);\n };\n\n const stackFrames = getStackFrames();\n const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));\n\n if (newErrors.length === 1) {\n return newErrors[0];\n } else {\n return new AggregateError(newErrors);\n }\n }\n};\n\n/**\n * Throws an error based on the cause.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const throwCause = (cause: Cause.Cause<any>): never => {\n throw causeToError(cause);\n};\n\nexport const unwrapExit = <A>(exit: Exit.Exit<A, any>): A => {\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n return throwCause(exit.cause);\n};\n\n/**\n * Runs the embedded effect asynchronously and throws any failures and defects as errors.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const runAndForwardErrors = async <A, E>(\n effect: Effect.Effect<A, E, never>,\n options?: { signal?: AbortSignal },\n): Promise<A> => {\n const exit = await Effect.runPromiseExit(effect, options);\n return unwrapExit(exit);\n};\n\n/**\n * Like `Effect.promise` but also caputes spans for defects.\n * Workaround for: https://github.com/Effect-TS/effect/issues/5436\n */\nexport const promiseWithCauseCapture: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Effect.Effect<A> = (\n evaluate,\n) =>\n Effect.promise(async (signal) => {\n try {\n const result = await evaluate(signal);\n return Effect.succeed(result);\n } catch (err) {\n return Effect.die(err);\n }\n }).pipe(Effect.flatten);\n", "//\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\n// TODO(dmaretskyi): Add all different test tags here.\nexport type TestTag =\n | 'flaky' // Flaky tests.\n | 'llm' // Tests with AI.\n | 'sync'; // Sync with external services.\n\nexport namespace TestHelpers {\n /**\n * Skip the test if the condition is false.\n *\n * Exmaple:\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 * Exmaple:\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 * Skips this test if the tag is not in the list of tags to run.\n * Tags are specified in the `DX_TEST_TAGS` environment variable.\n *\n * @param tag\n * @returns\n */\n export const taggedTest =\n (tag: TestTag) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (!process.env.DX_TEST_TAGS?.includes(tag)) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n\n /**\n * Provide TestContext from test parameters.\n *\n * Exmaple:\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", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Scope from 'effect/Scope';\n\nimport type { Lifecycle } from '@dxos/context';\n\n/**\n * Acquires a resource and releases it when the scope is closed.\n */\nexport const acquireReleaseResource = <T extends Lifecycle>(\n getResource: () => T,\n): Effect.Effect<T, never, Scope.Scope> =>\n Effect.acquireRelease(\n Effect.gen(function* () {\n const resource = getResource();\n yield* Effect.promise(async () => {\n resource.open?.();\n return undefined;\n });\n return resource;\n }),\n (resource) =>\n Effect.promise(async () => {\n resource.close?.();\n return undefined;\n }),\n );\n"],
|
|
5
|
+
"mappings": ";;;AAIA,YAAYA,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,eAAe;AAE3B,SAASC,iBAAiB;AAC1B,SAASC,qBAAqB;;AAc9B,IAAMC,eAAc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eAeFC,QACX,CAACC,cACD,CAAUC,QAAgCC,QACjCC,YAAI,aAAA;AACT,QAAI,CAACH,WAAW;AACdE,UAAIE,KAAI;IACV,OAAO;AACL,aAAO,OAAOH;IAChB;EACF,CAAA;eAgBSI,SACX,CAACL,cACD,CAAUC,QAAgCC,QACjCC,YAAI,aAAA;AACT,QAAIH,WAAW;AACbE,UAAIE,KAAI;IACV,OAAO;AACL,aAAO,OAAOH;IAChB;EACF,CAAA;eASSK,aACX,CAACC,QACD,CAAUN,QAAgCC,QACjCC,YAAI,aAAA;AACT,QAAI,CAACK,QAAQC,IAAIC,cAAcC,SAASJ,GAAAA,GAAM;AAC5CL,UAAIE,KAAI;IACV,OAAO;AACL,aAAO,OAAOH;IAChB;EACF,CAAA;eAgBSW,qBAAqB,CAChCX,QACAC,QAC+DW,uBAAeZ,QAAQa,oBAAoBZ,GAAAA;AAC9G,GAvFiBJ,gBAAAA,cAAAA,CAAAA,EAAAA;AA4FV,IAAMgB,qBAAN,cAAyCC,aAAI,iCAAA,EAAA,EAAA;AAG/C;;;;ACzGL,YAAYC,aAAY;AAQjB,IAAMC,yBAAyB,CACpCC,gBAEOC,uBACEC,YAAI,aAAA;AACT,QAAMC,WAAWH,YAAAA;AACjB,SAAcI,gBAAQ,YAAA;AACpBD,aAASE,OAAI;AACb,WAAOC;EACT,CAAA;AACA,SAAOH;AACT,CAAA,GACA,CAACA,aACQC,gBAAQ,YAAA;AACbD,WAASI,QAAK;AACd,SAAOD;AACT,CAAA,CAAA;",
|
|
6
|
+
"names": ["Function", "Option", "Schema", "SchemaAST", "invariant", "isNonNullable", "isTupleType", "node", "elements", "length", "getSimpleType", "isDeclaration", "isObjectKeyword", "isTypeLiteral", "isDiscriminatedUnion", "isStringKeyword", "isNumberKeyword", "isBooleanKeyword", "isEnums", "isLiteral", "isSimpleType", "SimpleType", "getDefaultValue", "type", "Error", "VisitResult", "defaultTest", "visit", "testOrVisitor", "visitor", "visitNode", "test", "path", "depth", "$result", "result", "undefined", "prop", "getPropertySignatures", "currentPath", "name", "toString", "i", "element", "entries", "isUnion", "types", "isRefinement", "from", "findNode", "child", "getIndexSignatures", "_", "isLiteralUnion", "findProperty", "schema", "getProp", "rest", "typeNode", "ast", "split", "defaultAnnotations", "objectKeyword", "stringKeyword", "numberKeyword", "booleanKeyword", "getAnnotation", "annotationId", "noDefault", "id", "pipe", "getIdentifierAnnotation", "getOrUndefined", "value", "_tag", "annotations", "findAnnotation", "getAnnotationById", "getBaseAnnotation", "isOption", "isUndefinedKeyword", "every", "getDiscriminatingProps", "reduce", "shared", "props", "filter", "p", "map", "includes", "getDiscriminatedType", "match", "literal", "fields", "Object", "fromEntries", "literals", "find", "Literal", "Struct", "mapAst", "f", "TypeLiteral", "propertySignatures", "PropertySignature", "isOptional", "isReadonly", "indexSignatures", "Union", "make", "TupleType", "t", "index", "OptionalType", "Type", "newAst", "Suspend", "isArrayType", "some", "annotation", "getSurrogateAnnotation", "isSome", "slice", "Option", "Schema", "JSONPath", "invariant", "PATH_REGEX", "PROP_REGEX", "JsonPath", "String", "pipe", "pattern", "annotations", "title", "description", "JsonProp", "NonEmptyString", "message", "isJsonPath", "value", "isSome", "validateOption", "createJsonPath", "path", "candidatePath", "map", "p", "i", "join", "fromEffectValidationPath", "effectPath", "jsonPath", "replace", "splitJsonPath", "match", "part", "startsWith", "getField", "object", "json", "Function", "Option", "SchemaAST", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "getOrElse", "set", "String", "Effect", "Context", "contextFromScope", "gen", "ctx", "addFinalizer", "promise", "dispose", "Cause", "Chunk", "Effect", "Exit", "GlobalValue", "Option", "spanSymbol", "Symbol", "for", "originalSymbol", "spanToTrace", "globalValue", "WeakMap", "locationRegex", "prettyErrorStack", "error", "appendStacks", "span", "lines", "stack", "split", "out", "atStack", "i", "length", "startsWith", "push", "includes", "replace", "current", "_tag", "stackFn", "get", "locationMatchAll", "matchAll", "match", "location", "name", "getOrUndefined", "parent", "cause", "Object", "defineProperty", "value", "join", "writable", "enumerable", "configurable", "causeToError", "isEmpty", "Error", "isInterruptedOnly", "errors", "toArray", "failures", "defects", "getStackFrames", "o", "captureStackTrace", "slice", "stackFrames", "newErrors", "map", "AggregateError", "throwCause", "unwrapExit", "exit", "isSuccess", "runAndForwardErrors", "effect", "options", "runPromiseExit", "promiseWithCauseCapture", "evaluate", "promise", "signal", "result", "succeed", "err", "die", "pipe", "flatten", "Context", "Effect", "TestHelpers", "runIf", "condition", "effect", "ctx", "gen", "skip", "skipIf", "taggedTest", "tag", "process", "env", "DX_TEST_TAGS", "includes", "provideTestContext", "provideService", "TestContextService", "Tag", "Effect", "acquireReleaseResource", "getResource", "acquireRelease", "gen", "resource", "promise", "open", "undefined", "close"]
|
|
7
7
|
}
|