@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 +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,17 +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";
|
|
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,
|