@dxos/effect 0.8.4-main.b97322e → 0.8.4-main.c4373fc
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/layers.test.d.ts +2 -0
- package/dist/types/src/layers.test.d.ts.map +1 -0
- 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 +1 -1
- package/dist/types/src/resource.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +33 -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 +16 -7
- package/src/ast.test.ts +4 -3
- package/src/ast.ts +28 -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.test.ts +1 -1
- package/src/jsonPath.ts +2 -1
- package/src/layers.test.ts +110 -0
- package/src/otel.test.ts +125 -0
- package/src/otel.ts +45 -0
- package/src/resource.test.ts +3 -2
- package/src/resource.ts +1 -1
- package/src/sanity.test.ts +6 -5
- package/src/testing.ts +53 -1
- 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":43690,"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":9832,"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":8234,"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":2173,"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":46344},"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","accuireReleaseResource","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":9357},"src/index.ts":{"bytesInOutput":0},"src/jsonPath.ts":{"bytesInOutput":1883},"src/url.ts":{"bytesInOutput":1977},"src/context.ts":{"bytesInOutput":378},"src/errors.ts":{"bytesInOutput":3847},"src/testing.ts":{"bytesInOutput":926},"src/resource.ts":{"bytesInOutput":370}},"bytes":19574}}}
|
|
@@ -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
|
}
|
|
@@ -125,12 +131,13 @@ var findNode = (node, test) => {
|
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
} else if (SchemaAST.isUnion(node)) {
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
if (isLiteralUnion(node)) {
|
|
135
|
+
return void 0;
|
|
136
|
+
}
|
|
137
|
+
for (const type of node.types) {
|
|
138
|
+
const child = findNode(type, test);
|
|
139
|
+
if (child) {
|
|
140
|
+
return child;
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
143
|
} else if (SchemaAST.isRefinement(node)) {
|
|
@@ -143,7 +150,7 @@ var findProperty = (schema, path) => {
|
|
|
143
150
|
const typeNode = findNode(node, SchemaAST.isTypeLiteral);
|
|
144
151
|
invariant(typeNode, void 0, {
|
|
145
152
|
F: __dxlog_file,
|
|
146
|
-
L:
|
|
153
|
+
L: 259,
|
|
147
154
|
S: void 0,
|
|
148
155
|
A: [
|
|
149
156
|
"typeNode",
|
|
@@ -168,16 +175,16 @@ var defaultAnnotations = {
|
|
|
168
175
|
["NumberKeyword"]: SchemaAST.numberKeyword,
|
|
169
176
|
["BooleanKeyword"]: SchemaAST.booleanKeyword
|
|
170
177
|
};
|
|
171
|
-
var
|
|
172
|
-
const id = pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
173
|
-
const value = pipe(SchemaAST.getAnnotation(annotationId)(node), Option.getOrUndefined);
|
|
178
|
+
var getAnnotation2 = (annotationId, noDefault = true) => (node) => {
|
|
179
|
+
const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
180
|
+
const value = Function.pipe(SchemaAST.getAnnotation(annotationId)(node), Option.getOrUndefined);
|
|
174
181
|
if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {
|
|
175
182
|
return void 0;
|
|
176
183
|
}
|
|
177
184
|
return value;
|
|
178
185
|
};
|
|
179
186
|
var findAnnotation = (node, annotationId, noDefault = true) => {
|
|
180
|
-
const getAnnotationById =
|
|
187
|
+
const getAnnotationById = getAnnotation2(annotationId, noDefault);
|
|
181
188
|
const getBaseAnnotation = (node2) => {
|
|
182
189
|
const value = getAnnotationById(node2);
|
|
183
190
|
if (value !== void 0) {
|
|
@@ -203,7 +210,7 @@ var isDiscriminatedUnion = (node) => {
|
|
|
203
210
|
var getDiscriminatingProps = (node) => {
|
|
204
211
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
205
212
|
F: __dxlog_file,
|
|
206
|
-
L:
|
|
213
|
+
L: 356,
|
|
207
214
|
S: void 0,
|
|
208
215
|
A: [
|
|
209
216
|
"SchemaAST.isUnion(node)",
|
|
@@ -221,7 +228,7 @@ var getDiscriminatingProps = (node) => {
|
|
|
221
228
|
var getDiscriminatedType = (node, value = {}) => {
|
|
222
229
|
invariant(SchemaAST.isUnion(node), void 0, {
|
|
223
230
|
F: __dxlog_file,
|
|
224
|
-
L:
|
|
231
|
+
L: 380,
|
|
225
232
|
S: void 0,
|
|
226
233
|
A: [
|
|
227
234
|
"SchemaAST.isUnion(node)",
|
|
@@ -230,7 +237,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
230
237
|
});
|
|
231
238
|
invariant(value, void 0, {
|
|
232
239
|
F: __dxlog_file,
|
|
233
|
-
L:
|
|
240
|
+
L: 381,
|
|
234
241
|
S: void 0,
|
|
235
242
|
A: [
|
|
236
243
|
"value",
|
|
@@ -245,7 +252,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
245
252
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
246
253
|
invariant(SchemaAST.isLiteral(prop.type), void 0, {
|
|
247
254
|
F: __dxlog_file,
|
|
248
|
-
L:
|
|
255
|
+
L: 392,
|
|
249
256
|
S: void 0,
|
|
250
257
|
A: [
|
|
251
258
|
"SchemaAST.isLiteral(prop.type)",
|
|
@@ -263,7 +270,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
263
270
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
264
271
|
invariant(SchemaAST.isLiteral(literal.type), void 0, {
|
|
265
272
|
F: __dxlog_file,
|
|
266
|
-
L:
|
|
273
|
+
L: 410,
|
|
267
274
|
S: void 0,
|
|
268
275
|
A: [
|
|
269
276
|
"SchemaAST.isLiteral(literal.type)",
|
|
@@ -301,12 +308,13 @@ var mapAst = (ast, f) => {
|
|
|
301
308
|
}
|
|
302
309
|
};
|
|
303
310
|
var isArrayType = (node) => {
|
|
304
|
-
return SchemaAST.isTupleType(node) || SchemaAST.isUnion(node) && node.types.some(isArrayType) && node.types.some(isUndefinedKeyword) && node.types.length === 2;
|
|
311
|
+
return SchemaAST.isTupleType(node) || SchemaAST.isUnion(node) && node.types.some(isArrayType) && node.types.some(SchemaAST.isUndefinedKeyword) && node.types.length === 2;
|
|
305
312
|
};
|
|
306
313
|
var SimpleType;
|
|
307
314
|
|
|
308
315
|
// src/jsonPath.ts
|
|
309
|
-
import
|
|
316
|
+
import * as Option2 from "effect/Option";
|
|
317
|
+
import * as Schema2 from "effect/Schema";
|
|
310
318
|
import { JSONPath } from "jsonpath-plus";
|
|
311
319
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
312
320
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/jsonPath.ts";
|
|
@@ -332,7 +340,7 @@ var createJsonPath = (path) => {
|
|
|
332
340
|
}).join("");
|
|
333
341
|
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
|
|
334
342
|
F: __dxlog_file2,
|
|
335
|
-
L:
|
|
343
|
+
L: 64,
|
|
336
344
|
S: void 0,
|
|
337
345
|
A: [
|
|
338
346
|
"isJsonPath(candidatePath)",
|
|
@@ -345,7 +353,7 @@ var fromEffectValidationPath = (effectPath) => {
|
|
|
345
353
|
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
346
354
|
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
|
|
347
355
|
F: __dxlog_file2,
|
|
348
|
-
L:
|
|
356
|
+
L: 75,
|
|
349
357
|
S: void 0,
|
|
350
358
|
A: [
|
|
351
359
|
"isJsonPath(jsonPath)",
|
|
@@ -368,17 +376,29 @@ var getField = (object, path) => {
|
|
|
368
376
|
};
|
|
369
377
|
|
|
370
378
|
// src/url.ts
|
|
371
|
-
import
|
|
379
|
+
import * as Function2 from "effect/Function";
|
|
380
|
+
import * as Option3 from "effect/Option";
|
|
381
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
372
382
|
import { decamelize } from "@dxos/util";
|
|
383
|
+
function _define_property(obj, key, value) {
|
|
384
|
+
if (key in obj) {
|
|
385
|
+
Object.defineProperty(obj, key, {
|
|
386
|
+
value,
|
|
387
|
+
enumerable: true,
|
|
388
|
+
configurable: true,
|
|
389
|
+
writable: true
|
|
390
|
+
});
|
|
391
|
+
} else {
|
|
392
|
+
obj[key] = value;
|
|
393
|
+
}
|
|
394
|
+
return obj;
|
|
395
|
+
}
|
|
373
396
|
var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
374
397
|
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
375
398
|
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
376
399
|
[ParamKeyAnnotationId]: value
|
|
377
400
|
});
|
|
378
401
|
var UrlParser = class {
|
|
379
|
-
constructor(_schema) {
|
|
380
|
-
this._schema = _schema;
|
|
381
|
-
}
|
|
382
402
|
/**
|
|
383
403
|
* Parse URL params.
|
|
384
404
|
*/
|
|
@@ -410,7 +430,7 @@ var UrlParser = class {
|
|
|
410
430
|
if (value !== void 0) {
|
|
411
431
|
const field = this._schema.fields[key];
|
|
412
432
|
if (field) {
|
|
413
|
-
const { key: serializedKey } =
|
|
433
|
+
const { key: serializedKey } = Function2.pipe(getParamKeyAnnotation(field.ast), Option3.getOrElse(() => ({
|
|
414
434
|
key: decamelize(key)
|
|
415
435
|
})));
|
|
416
436
|
url.searchParams.set(serializedKey, String(value));
|
|
@@ -419,23 +439,32 @@ var UrlParser = class {
|
|
|
419
439
|
});
|
|
420
440
|
return url;
|
|
421
441
|
}
|
|
442
|
+
constructor(_schema) {
|
|
443
|
+
_define_property(this, "_schema", void 0);
|
|
444
|
+
this._schema = _schema;
|
|
445
|
+
}
|
|
422
446
|
};
|
|
423
447
|
|
|
424
448
|
// src/context.ts
|
|
425
|
-
import
|
|
449
|
+
import * as Effect from "effect/Effect";
|
|
426
450
|
import { Context } from "@dxos/context";
|
|
427
451
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
428
452
|
var contextFromScope = () => Effect.gen(function* () {
|
|
429
453
|
const ctx = new Context(void 0, {
|
|
430
454
|
F: __dxlog_file3,
|
|
431
|
-
L:
|
|
455
|
+
L: 13
|
|
432
456
|
});
|
|
433
457
|
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
434
458
|
return ctx;
|
|
435
459
|
});
|
|
436
460
|
|
|
437
461
|
// src/errors.ts
|
|
438
|
-
import
|
|
462
|
+
import * as Cause from "effect/Cause";
|
|
463
|
+
import * as Chunk from "effect/Chunk";
|
|
464
|
+
import * as Effect2 from "effect/Effect";
|
|
465
|
+
import * as Exit from "effect/Exit";
|
|
466
|
+
import * as GlobalValue from "effect/GlobalValue";
|
|
467
|
+
import * as Option4 from "effect/Option";
|
|
439
468
|
var spanSymbol = Symbol.for("effect/SpanAnnotation");
|
|
440
469
|
var originalSymbol = Symbol.for("effect/OriginalAnnotation");
|
|
441
470
|
var spanToTrace = GlobalValue.globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
|
|
@@ -505,19 +534,15 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
505
534
|
});
|
|
506
535
|
return error;
|
|
507
536
|
};
|
|
508
|
-
var
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
if (Cause.isEmpty(exit.cause)) {
|
|
514
|
-
throw new Error("Fiber failed without a cause");
|
|
515
|
-
} else if (Cause.isInterrupted(exit.cause)) {
|
|
516
|
-
throw new Error("Fiber was interrupted");
|
|
537
|
+
var causeToError = (cause) => {
|
|
538
|
+
if (Cause.isEmpty(cause)) {
|
|
539
|
+
return new Error("Fiber failed without a cause");
|
|
540
|
+
} else if (Cause.isInterruptedOnly(cause)) {
|
|
541
|
+
return new Error("Fiber was interrupted");
|
|
517
542
|
} else {
|
|
518
543
|
const errors = [
|
|
519
|
-
...Chunk.toArray(Cause.failures(
|
|
520
|
-
...Chunk.toArray(Cause.defects(
|
|
544
|
+
...Chunk.toArray(Cause.failures(cause)),
|
|
545
|
+
...Chunk.toArray(Cause.defects(cause))
|
|
521
546
|
];
|
|
522
547
|
const getStackFrames = () => {
|
|
523
548
|
const o = {};
|
|
@@ -527,15 +552,37 @@ var runAndForwardErrors = async (effect, options) => {
|
|
|
527
552
|
const stackFrames = getStackFrames();
|
|
528
553
|
const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));
|
|
529
554
|
if (newErrors.length === 1) {
|
|
530
|
-
|
|
555
|
+
return newErrors[0];
|
|
531
556
|
} else {
|
|
532
|
-
|
|
557
|
+
return new AggregateError(newErrors);
|
|
533
558
|
}
|
|
534
559
|
}
|
|
535
560
|
};
|
|
561
|
+
var throwCause = (cause) => {
|
|
562
|
+
throw causeToError(cause);
|
|
563
|
+
};
|
|
564
|
+
var unwrapExit = (exit) => {
|
|
565
|
+
if (Exit.isSuccess(exit)) {
|
|
566
|
+
return exit.value;
|
|
567
|
+
}
|
|
568
|
+
return throwCause(exit.cause);
|
|
569
|
+
};
|
|
570
|
+
var runAndForwardErrors = async (effect, options) => {
|
|
571
|
+
const exit = await Effect2.runPromiseExit(effect, options);
|
|
572
|
+
return unwrapExit(exit);
|
|
573
|
+
};
|
|
574
|
+
var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
575
|
+
try {
|
|
576
|
+
const result = await evaluate(signal);
|
|
577
|
+
return Effect2.succeed(result);
|
|
578
|
+
} catch (err) {
|
|
579
|
+
return Effect2.die(err);
|
|
580
|
+
}
|
|
581
|
+
}).pipe(Effect2.flatten);
|
|
536
582
|
|
|
537
583
|
// src/testing.ts
|
|
538
|
-
import
|
|
584
|
+
import * as Context2 from "effect/Context";
|
|
585
|
+
import * as Effect3 from "effect/Effect";
|
|
539
586
|
(function(TestHelpers2) {
|
|
540
587
|
TestHelpers2.runIf = (condition) => (effect, ctx) => Effect3.gen(function* () {
|
|
541
588
|
if (!condition) {
|
|
@@ -551,11 +598,21 @@ import { Effect as Effect3 } from "effect";
|
|
|
551
598
|
return yield* effect;
|
|
552
599
|
}
|
|
553
600
|
});
|
|
601
|
+
TestHelpers2.taggedTest = (tag) => (effect, ctx) => Effect3.gen(function* () {
|
|
602
|
+
if (!process.env.DX_TEST_TAGS?.includes(tag)) {
|
|
603
|
+
ctx.skip();
|
|
604
|
+
} else {
|
|
605
|
+
return yield* effect;
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
TestHelpers2.provideTestContext = (effect, ctx) => Effect3.provideService(effect, TestContextService, ctx);
|
|
554
609
|
})(TestHelpers || (TestHelpers = {}));
|
|
610
|
+
var TestContextService = class extends Context2.Tag("@dxos/effect/TestContextService")() {
|
|
611
|
+
};
|
|
555
612
|
var TestHelpers;
|
|
556
613
|
|
|
557
614
|
// src/resource.ts
|
|
558
|
-
import
|
|
615
|
+
import * as Effect4 from "effect/Effect";
|
|
559
616
|
var accuireReleaseResource = (getResource) => Effect4.acquireRelease(Effect4.gen(function* () {
|
|
560
617
|
const resource = getResource();
|
|
561
618
|
yield* Effect4.promise(async () => {
|
|
@@ -572,17 +629,19 @@ export {
|
|
|
572
629
|
JsonProp,
|
|
573
630
|
ParamKeyAnnotation,
|
|
574
631
|
SimpleType,
|
|
632
|
+
TestContextService,
|
|
575
633
|
TestHelpers,
|
|
576
634
|
UrlParser,
|
|
577
635
|
VisitResult,
|
|
578
636
|
accuireReleaseResource,
|
|
637
|
+
causeToError,
|
|
579
638
|
contextFromScope,
|
|
580
639
|
createJsonPath,
|
|
581
640
|
findAnnotation,
|
|
582
641
|
findNode,
|
|
583
642
|
findProperty,
|
|
584
643
|
fromEffectValidationPath,
|
|
585
|
-
getAnnotation,
|
|
644
|
+
getAnnotation2 as getAnnotation,
|
|
586
645
|
getDiscriminatedType,
|
|
587
646
|
getDiscriminatingProps,
|
|
588
647
|
getField,
|
|
@@ -595,8 +654,11 @@ export {
|
|
|
595
654
|
isOption,
|
|
596
655
|
isSimpleType,
|
|
597
656
|
mapAst,
|
|
657
|
+
promiseWithCauseCapture,
|
|
598
658
|
runAndForwardErrors,
|
|
599
659
|
splitJsonPath,
|
|
660
|
+
throwCause,
|
|
661
|
+
unwrapExit,
|
|
600
662
|
visit
|
|
601
663
|
};
|
|
602
664
|
//# sourceMappingURL=index.mjs.map
|