@dxos/effect 0.8.4-main.fd6878d → 0.8.4-main.fffef41
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 +113 -51
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +113 -51
- 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 +31 -1
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/interrupt.test.d.ts +2 -0
- package/dist/types/src/interrupt.test.d.ts.map +1 -0
- 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 +25 -2
- 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 +51 -16
- package/src/context.ts +2 -1
- package/src/errors.test.ts +1 -1
- package/src/errors.ts +73 -20
- package/src/interrupt.test.ts +33 -0
- 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 +33 -2
- package/src/url.test.ts +1 -1
- package/src/url.ts +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/ast.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/ast.ts":{"bytes":45961,"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/jsonPath.ts":{"bytes":9966,"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}],"format":"esm"},"src/url.ts":{"bytes":7881,"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/context.ts":{"bytes":1719,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true}],"format":"esm"},"src/errors.ts":{"bytes":19285,"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}],"format":"esm"},"src/testing.ts":{"bytes":6498,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"},"src/resource.ts":{"bytes":2356,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":947,"imports":[{"path":"src/ast.ts","kind":"import-statement","original":"./ast"},{"path":"src/jsonPath.ts","kind":"import-statement","original":"./jsonPath"},{"path":"src/url.ts","kind":"import-statement","original":"./url"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/testing.ts","kind":"import-statement","original":"./testing"},{"path":"src/resource.ts","kind":"import-statement","original":"./resource"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":47701},"dist/lib/browser/index.mjs":{"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},{"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":"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":"@dxos/context","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/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"exports":["JsonPath","JsonProp","ParamKeyAnnotation","SimpleType","TestContextService","TestHelpers","UrlParser","VisitResult","acquireReleaseResource","causeToError","contextFromScope","createJsonPath","findAnnotation","findNode","findProperty","fromEffectValidationPath","getAnnotation","getDiscriminatedType","getDiscriminatingProps","getField","getParamKeyAnnotation","getSimpleType","isArrayType","isDiscriminatedUnion","isJsonPath","isLiteralUnion","isOption","isSimpleType","mapAst","promiseWithCauseCapture","runAndForwardErrors","splitJsonPath","throwCause","unwrapExit","visit"],"entryPoint":"src/index.ts","inputs":{"src/ast.ts":{"bytesInOutput":9947},"src/index.ts":{"bytesInOutput":0},"src/jsonPath.ts":{"bytesInOutput":1883},"src/url.ts":{"bytesInOutput":1693},"src/context.ts":{"bytesInOutput":378},"src/errors.ts":{"bytesInOutput":3847},"src/testing.ts":{"bytesInOutput":926},"src/resource.ts":{"bytesInOutput":370}},"bytes":19880}}}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
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";
|
|
11
|
+
var isTupleType2 = (node) => {
|
|
12
|
+
return SchemaAST.isTupleType(node) && node.elements.length > 0;
|
|
13
|
+
};
|
|
9
14
|
var getSimpleType = (node) => {
|
|
10
|
-
if (SchemaAST.isDeclaration(node) || SchemaAST.isObjectKeyword(node) || SchemaAST.isTypeLiteral(node) ||
|
|
15
|
+
if (SchemaAST.isDeclaration(node) || SchemaAST.isObjectKeyword(node) || SchemaAST.isTypeLiteral(node) || // TODO(wittjosiah): Tuples are actually arrays.
|
|
16
|
+
isTupleType2(node) || isDiscriminatedUnion(node)) {
|
|
11
17
|
return "object";
|
|
12
18
|
}
|
|
13
19
|
if (SchemaAST.isStringKeyword(node)) {
|
|
@@ -48,12 +54,12 @@ var isSimpleType = (node) => !!getSimpleType(node);
|
|
|
48
54
|
}
|
|
49
55
|
};
|
|
50
56
|
})(SimpleType || (SimpleType = {}));
|
|
51
|
-
var VisitResult = /* @__PURE__ */ function(VisitResult2) {
|
|
57
|
+
var VisitResult = /* @__PURE__ */ (function(VisitResult2) {
|
|
52
58
|
VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
|
|
53
59
|
VisitResult2[VisitResult2["SKIP"] = 1] = "SKIP";
|
|
54
60
|
VisitResult2[VisitResult2["EXIT"] = 2] = "EXIT";
|
|
55
61
|
return VisitResult2;
|
|
56
|
-
}({});
|
|
62
|
+
})({});
|
|
57
63
|
var defaultTest = isSimpleType;
|
|
58
64
|
var visit = (node, testOrVisitor, visitor) => {
|
|
59
65
|
if (!visitor) {
|
|
@@ -63,8 +69,8 @@ var visit = (node, testOrVisitor, visitor) => {
|
|
|
63
69
|
}
|
|
64
70
|
};
|
|
65
71
|
var visitNode = (node, test, visitor, path = [], depth = 0) => {
|
|
66
|
-
const
|
|
67
|
-
const result =
|
|
72
|
+
const $result = test?.(node, path, depth);
|
|
73
|
+
const result = $result === void 0 ? 0 : typeof $result === "boolean" ? $result ? 0 : 1 : $result;
|
|
68
74
|
if (result === 2) {
|
|
69
75
|
return result;
|
|
70
76
|
}
|
|
@@ -117,6 +123,12 @@ var findNode = (node, test) => {
|
|
|
117
123
|
return child;
|
|
118
124
|
}
|
|
119
125
|
}
|
|
126
|
+
for (const prop of getIndexSignatures(node)) {
|
|
127
|
+
const child = findNode(prop.type, test);
|
|
128
|
+
if (child) {
|
|
129
|
+
return child;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
120
132
|
} else if (SchemaAST.isTupleType(node)) {
|
|
121
133
|
for (const [_, element] of node.elements.entries()) {
|
|
122
134
|
const child = findNode(element.type, test);
|
|
@@ -125,12 +137,13 @@ var findNode = (node, test) => {
|
|
|
125
137
|
}
|
|
126
138
|
}
|
|
127
139
|
} else if (SchemaAST.isUnion(node)) {
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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;
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
} else if (SchemaAST.isRefinement(node)) {
|
|
@@ -143,7 +156,7 @@ var findProperty = (schema, path) => {
|
|
|
143
156
|
const typeNode = findNode(node, SchemaAST.isTypeLiteral);
|
|
144
157
|
invariant(typeNode, void 0, {
|
|
145
158
|
F: __dxlog_file,
|
|
146
|
-
L:
|
|
159
|
+
L: 265,
|
|
147
160
|
S: void 0,
|
|
148
161
|
A: [
|
|
149
162
|
"typeNode",
|
|
@@ -168,16 +181,16 @@ var defaultAnnotations = {
|
|
|
168
181
|
["NumberKeyword"]: SchemaAST.numberKeyword,
|
|
169
182
|
["BooleanKeyword"]: SchemaAST.booleanKeyword
|
|
170
183
|
};
|
|
171
|
-
var
|
|
172
|
-
const id = pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
173
|
-
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);
|
|
174
187
|
if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {
|
|
175
188
|
return void 0;
|
|
176
189
|
}
|
|
177
190
|
return value;
|
|
178
191
|
};
|
|
179
192
|
var findAnnotation = (node, annotationId, noDefault = true) => {
|
|
180
|
-
const getAnnotationById =
|
|
193
|
+
const getAnnotationById = getAnnotation2(annotationId, noDefault);
|
|
181
194
|
const getBaseAnnotation = (node2) => {
|
|
182
195
|
const value = getAnnotationById(node2);
|
|
183
196
|
if (value !== void 0) {
|
|
@@ -203,7 +216,7 @@ var isDiscriminatedUnion = (node) => {
|
|
|
203
216
|
var getDiscriminatingProps = (node) => {
|
|
204
217
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
205
218
|
F: __dxlog_file,
|
|
206
|
-
L:
|
|
219
|
+
L: 362,
|
|
207
220
|
S: void 0,
|
|
208
221
|
A: [
|
|
209
222
|
"SchemaAST.isUnion(node)",
|
|
@@ -221,7 +234,7 @@ var getDiscriminatingProps = (node) => {
|
|
|
221
234
|
var getDiscriminatedType = (node, value = {}) => {
|
|
222
235
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
223
236
|
F: __dxlog_file,
|
|
224
|
-
L:
|
|
237
|
+
L: 386,
|
|
225
238
|
S: void 0,
|
|
226
239
|
A: [
|
|
227
240
|
"SchemaAST.isUnion(node)",
|
|
@@ -230,7 +243,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
230
243
|
});
|
|
231
244
|
invariant(value, void 0, {
|
|
232
245
|
F: __dxlog_file,
|
|
233
|
-
L:
|
|
246
|
+
L: 387,
|
|
234
247
|
S: void 0,
|
|
235
248
|
A: [
|
|
236
249
|
"value",
|
|
@@ -245,7 +258,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
245
258
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
246
259
|
invariant(SchemaAST.isLiteral(prop.type), void 0, {
|
|
247
260
|
F: __dxlog_file,
|
|
248
|
-
L:
|
|
261
|
+
L: 398,
|
|
249
262
|
S: void 0,
|
|
250
263
|
A: [
|
|
251
264
|
"SchemaAST.isLiteral(prop.type)",
|
|
@@ -263,7 +276,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
263
276
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
264
277
|
invariant(SchemaAST.isLiteral(literal.type), void 0, {
|
|
265
278
|
F: __dxlog_file,
|
|
266
|
-
L:
|
|
279
|
+
L: 416,
|
|
267
280
|
S: void 0,
|
|
268
281
|
A: [
|
|
269
282
|
"SchemaAST.isLiteral(literal.type)",
|
|
@@ -283,7 +296,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
283
296
|
var mapAst = (ast, f) => {
|
|
284
297
|
switch (ast._tag) {
|
|
285
298
|
case "TypeLiteral": {
|
|
286
|
-
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);
|
|
287
300
|
}
|
|
288
301
|
case "Union": {
|
|
289
302
|
return SchemaAST.Union.make(ast.types.map(f), ast.annotations);
|
|
@@ -301,12 +314,28 @@ var mapAst = (ast, f) => {
|
|
|
301
314
|
}
|
|
302
315
|
};
|
|
303
316
|
var isArrayType = (node) => {
|
|
304
|
-
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 [];
|
|
305
333
|
};
|
|
306
334
|
var SimpleType;
|
|
307
335
|
|
|
308
336
|
// src/jsonPath.ts
|
|
309
|
-
import
|
|
337
|
+
import * as Option2 from "effect/Option";
|
|
338
|
+
import * as Schema2 from "effect/Schema";
|
|
310
339
|
import { JSONPath } from "jsonpath-plus";
|
|
311
340
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
312
341
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/jsonPath.ts";
|
|
@@ -332,7 +361,7 @@ var createJsonPath = (path) => {
|
|
|
332
361
|
}).join("");
|
|
333
362
|
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
|
|
334
363
|
F: __dxlog_file2,
|
|
335
|
-
L:
|
|
364
|
+
L: 65,
|
|
336
365
|
S: void 0,
|
|
337
366
|
A: [
|
|
338
367
|
"isJsonPath(candidatePath)",
|
|
@@ -345,7 +374,7 @@ var fromEffectValidationPath = (effectPath) => {
|
|
|
345
374
|
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
346
375
|
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
|
|
347
376
|
F: __dxlog_file2,
|
|
348
|
-
L:
|
|
377
|
+
L: 76,
|
|
349
378
|
S: void 0,
|
|
350
379
|
A: [
|
|
351
380
|
"isJsonPath(jsonPath)",
|
|
@@ -368,7 +397,9 @@ var getField = (object, path) => {
|
|
|
368
397
|
};
|
|
369
398
|
|
|
370
399
|
// src/url.ts
|
|
371
|
-
import
|
|
400
|
+
import * as Function2 from "effect/Function";
|
|
401
|
+
import * as Option3 from "effect/Option";
|
|
402
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
372
403
|
import { decamelize } from "@dxos/util";
|
|
373
404
|
var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
374
405
|
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
@@ -411,7 +442,7 @@ var UrlParser = class {
|
|
|
411
442
|
if (value !== void 0) {
|
|
412
443
|
const field = this._schema.fields[key];
|
|
413
444
|
if (field) {
|
|
414
|
-
const { key: serializedKey } =
|
|
445
|
+
const { key: serializedKey } = Function2.pipe(getParamKeyAnnotation(field.ast), Option3.getOrElse(() => ({
|
|
415
446
|
key: decamelize(key)
|
|
416
447
|
})));
|
|
417
448
|
url.searchParams.set(serializedKey, String(value));
|
|
@@ -423,20 +454,25 @@ var UrlParser = class {
|
|
|
423
454
|
};
|
|
424
455
|
|
|
425
456
|
// src/context.ts
|
|
426
|
-
import
|
|
457
|
+
import * as Effect from "effect/Effect";
|
|
427
458
|
import { Context } from "@dxos/context";
|
|
428
459
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
429
460
|
var contextFromScope = () => Effect.gen(function* () {
|
|
430
461
|
const ctx = new Context(void 0, {
|
|
431
462
|
F: __dxlog_file3,
|
|
432
|
-
L:
|
|
463
|
+
L: 13
|
|
433
464
|
});
|
|
434
465
|
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
435
466
|
return ctx;
|
|
436
467
|
});
|
|
437
468
|
|
|
438
469
|
// src/errors.ts
|
|
439
|
-
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";
|
|
440
476
|
var spanSymbol = Symbol.for("effect/SpanAnnotation");
|
|
441
477
|
var originalSymbol = Symbol.for("effect/OriginalAnnotation");
|
|
442
478
|
var spanToTrace = GlobalValue.globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
|
|
@@ -506,19 +542,15 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
506
542
|
});
|
|
507
543
|
return error;
|
|
508
544
|
};
|
|
509
|
-
var
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (Cause.isEmpty(exit.cause)) {
|
|
515
|
-
throw new Error("Fiber failed without a cause");
|
|
516
|
-
} else if (Cause.isInterrupted(exit.cause)) {
|
|
517
|
-
throw new Error("Fiber was interrupted");
|
|
545
|
+
var causeToError = (cause) => {
|
|
546
|
+
if (Cause.isEmpty(cause)) {
|
|
547
|
+
return new Error("Fiber failed without a cause");
|
|
548
|
+
} else if (Cause.isInterruptedOnly(cause)) {
|
|
549
|
+
return new Error("Fiber was interrupted");
|
|
518
550
|
} else {
|
|
519
551
|
const errors = [
|
|
520
|
-
...Chunk.toArray(Cause.failures(
|
|
521
|
-
...Chunk.toArray(Cause.defects(
|
|
552
|
+
...Chunk.toArray(Cause.failures(cause)),
|
|
553
|
+
...Chunk.toArray(Cause.defects(cause))
|
|
522
554
|
];
|
|
523
555
|
const getStackFrames = () => {
|
|
524
556
|
const o = {};
|
|
@@ -528,15 +560,37 @@ var runAndForwardErrors = async (effect, options) => {
|
|
|
528
560
|
const stackFrames = getStackFrames();
|
|
529
561
|
const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));
|
|
530
562
|
if (newErrors.length === 1) {
|
|
531
|
-
|
|
563
|
+
return newErrors[0];
|
|
532
564
|
} else {
|
|
533
|
-
|
|
565
|
+
return new AggregateError(newErrors);
|
|
534
566
|
}
|
|
535
567
|
}
|
|
536
568
|
};
|
|
569
|
+
var throwCause = (cause) => {
|
|
570
|
+
throw causeToError(cause);
|
|
571
|
+
};
|
|
572
|
+
var unwrapExit = (exit) => {
|
|
573
|
+
if (Exit.isSuccess(exit)) {
|
|
574
|
+
return exit.value;
|
|
575
|
+
}
|
|
576
|
+
return throwCause(exit.cause);
|
|
577
|
+
};
|
|
578
|
+
var runAndForwardErrors = async (effect, options) => {
|
|
579
|
+
const exit = await Effect2.runPromiseExit(effect, options);
|
|
580
|
+
return unwrapExit(exit);
|
|
581
|
+
};
|
|
582
|
+
var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
583
|
+
try {
|
|
584
|
+
const result = await evaluate(signal);
|
|
585
|
+
return Effect2.succeed(result);
|
|
586
|
+
} catch (err) {
|
|
587
|
+
return Effect2.die(err);
|
|
588
|
+
}
|
|
589
|
+
}).pipe(Effect2.flatten);
|
|
537
590
|
|
|
538
591
|
// src/testing.ts
|
|
539
|
-
import
|
|
592
|
+
import * as Context2 from "effect/Context";
|
|
593
|
+
import * as Effect3 from "effect/Effect";
|
|
540
594
|
(function(TestHelpers2) {
|
|
541
595
|
TestHelpers2.runIf = (condition) => (effect, ctx) => Effect3.gen(function* () {
|
|
542
596
|
if (!condition) {
|
|
@@ -559,12 +613,15 @@ import { Effect as Effect3 } from "effect";
|
|
|
559
613
|
return yield* effect;
|
|
560
614
|
}
|
|
561
615
|
});
|
|
616
|
+
TestHelpers2.provideTestContext = (effect, ctx) => Effect3.provideService(effect, TestContextService, ctx);
|
|
562
617
|
})(TestHelpers || (TestHelpers = {}));
|
|
618
|
+
var TestContextService = class extends Context2.Tag("@dxos/effect/TestContextService")() {
|
|
619
|
+
};
|
|
563
620
|
var TestHelpers;
|
|
564
621
|
|
|
565
622
|
// src/resource.ts
|
|
566
|
-
import
|
|
567
|
-
var
|
|
623
|
+
import * as Effect4 from "effect/Effect";
|
|
624
|
+
var acquireReleaseResource = (getResource) => Effect4.acquireRelease(Effect4.gen(function* () {
|
|
568
625
|
const resource = getResource();
|
|
569
626
|
yield* Effect4.promise(async () => {
|
|
570
627
|
resource.open?.();
|
|
@@ -580,17 +637,19 @@ export {
|
|
|
580
637
|
JsonProp,
|
|
581
638
|
ParamKeyAnnotation,
|
|
582
639
|
SimpleType,
|
|
640
|
+
TestContextService,
|
|
583
641
|
TestHelpers,
|
|
584
642
|
UrlParser,
|
|
585
643
|
VisitResult,
|
|
586
|
-
|
|
644
|
+
acquireReleaseResource,
|
|
645
|
+
causeToError,
|
|
587
646
|
contextFromScope,
|
|
588
647
|
createJsonPath,
|
|
589
648
|
findAnnotation,
|
|
590
649
|
findNode,
|
|
591
650
|
findProperty,
|
|
592
651
|
fromEffectValidationPath,
|
|
593
|
-
getAnnotation,
|
|
652
|
+
getAnnotation2 as getAnnotation,
|
|
594
653
|
getDiscriminatedType,
|
|
595
654
|
getDiscriminatingProps,
|
|
596
655
|
getField,
|
|
@@ -603,8 +662,11 @@ export {
|
|
|
603
662
|
isOption,
|
|
604
663
|
isSimpleType,
|
|
605
664
|
mapAst,
|
|
665
|
+
promiseWithCauseCapture,
|
|
606
666
|
runAndForwardErrors,
|
|
607
667
|
splitJsonPath,
|
|
668
|
+
throwCause,
|
|
669
|
+
unwrapExit,
|
|
608
670
|
visit
|
|
609
671
|
};
|
|
610
672
|
//# sourceMappingURL=index.mjs.map
|