brass-runtime 1.17.0 → 1.18.1
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/README.md +36 -3
- package/dist/agent/cli/main.cjs +31 -32
- package/dist/agent/cli/main.js +3 -4
- package/dist/agent/cli/main.mjs +3 -4
- package/dist/agent/index.cjs +4 -5
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +3 -4
- package/dist/agent/index.mjs +3 -4
- package/dist/{chunk-7X3K5RMS.js → chunk-22HZQG5F.js} +9 -11
- package/dist/{chunk-GLE2WY7Z.cjs → chunk-2JHJ4YHS.cjs} +417 -124
- package/dist/{chunk-Q2I37RP3.cjs → chunk-2OW6IFY2.cjs} +44 -323
- package/dist/{chunk-7ZPEZ57L.cjs → chunk-5LC7V2OZ.cjs} +18 -20
- package/dist/{chunk-AGR5B2BC.cjs → chunk-5RZ7YITF.cjs} +564 -12
- package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
- package/dist/{chunk-EJ6BPYVR.mjs → chunk-6V2AWT4R.mjs} +1 -1
- package/dist/{chunk-3AYM6WPJ.js → chunk-7DU7IQHK.js} +20 -299
- package/dist/{chunk-SK7UZRNI.mjs → chunk-7GBJYOX7.mjs} +528 -23
- package/dist/chunk-7TKI527D.cjs +123 -0
- package/dist/{chunk-52OB2ROS.js → chunk-7VQLEN37.js} +2 -4
- package/dist/{chunk-KH4SYAOS.mjs → chunk-B5FKOLTB.mjs} +20 -299
- package/dist/{chunk-FHQGHPMO.mjs → chunk-BC6Q6BCO.mjs} +2 -4
- package/dist/{chunk-4P2HHGAX.mjs → chunk-COOW7BJX.mjs} +32 -11
- package/dist/{chunk-2HQTDLHF.mjs → chunk-EEN5OTCR.mjs} +555 -3
- package/dist/{chunk-KZJQ723N.cjs → chunk-EICAJDNX.cjs} +13 -15
- package/dist/chunk-ELIECDYN.cjs +33 -0
- package/dist/{chunk-GYM3LLGS.mjs → chunk-H626ZTDZ.mjs} +399 -106
- package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
- package/dist/{chunk-7JIJOVCT.js → chunk-IPSMXUWA.js} +2 -4
- package/dist/{chunk-4ROBZFL6.cjs → chunk-J6DUHITE.cjs} +6 -8
- package/dist/{chunk-6RY2FFN4.mjs → chunk-JWIEMBE6.mjs} +9 -11
- package/dist/{chunk-PD4EJTQC.cjs → chunk-KNTJ7FQB.cjs} +5 -5
- package/dist/chunk-KTGDLBLD.mjs +123 -0
- package/dist/chunk-LSYQ3C2M.js +33 -0
- package/dist/{chunk-RKGKFN2A.js → chunk-OW5VHAOE.js} +1 -1
- package/dist/{chunk-EOC4UHBS.mjs → chunk-RBHNOKH4.mjs} +2 -2
- package/dist/{chunk-6IXXWIUM.js → chunk-S4HXADU4.js} +555 -3
- package/dist/{chunk-FH2X7BVP.js → chunk-TTSPIU3U.js} +399 -106
- package/dist/{chunk-5QC7LRZ3.js → chunk-UAKAF32U.js} +2 -2
- package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
- package/dist/{chunk-MBEJI5HF.mjs → chunk-WCBNXPN6.mjs} +2 -4
- package/dist/{chunk-52PPNNI4.cjs → chunk-WGE2FEZE.cjs} +2 -2
- package/dist/{chunk-WBGRHGBP.cjs → chunk-WI7GZF3B.cjs} +114 -93
- package/dist/chunk-WUDHOZIH.js +6234 -0
- package/dist/{chunk-F6XWZQY4.cjs → chunk-WVSZOPGQ.cjs} +583 -78
- package/dist/chunk-XPIMJQYS.cjs +6234 -0
- package/dist/{chunk-VWIPB6I5.js → chunk-YGR2IN4R.js} +528 -23
- package/dist/chunk-YM3EDNYD.js +123 -0
- package/dist/chunk-YWLLH27R.mjs +33 -0
- package/dist/{chunk-BKK77SBA.js → chunk-YZ5LQ32F.js} +32 -11
- package/dist/chunk-Z3ZZMQUZ.mjs +6234 -0
- package/dist/core/index.cjs +37 -9
- package/dist/core/index.d.ts +19 -152
- package/dist/core/index.js +86 -58
- package/dist/core/index.mjs +86 -58
- package/dist/defaultClient-Cid0JoUR.d.ts +1648 -0
- package/dist/{effect-DIUHZ9IN.d.ts → effect-DnGUuhw6.d.ts} +22 -1
- package/dist/http/index.cjs +206 -59
- package/dist/http/index.d.ts +55 -819
- package/dist/http/index.js +220 -73
- package/dist/http/index.mjs +220 -73
- package/dist/http/testing.cjs +31 -10
- package/dist/http/testing.d.ts +16 -5
- package/dist/http/testing.js +29 -8
- package/dist/http/testing.mjs +29 -8
- package/dist/index.cjs +116 -88
- package/dist/index.d.ts +9 -8
- package/dist/index.js +87 -59
- package/dist/index.mjs +87 -59
- package/dist/{schedule-CK3Ml_7p.d.ts → layer-D2LFcBVx.d.ts} +176 -2
- package/dist/observability/index.cjs +20 -7
- package/dist/observability/index.d.ts +32 -8
- package/dist/observability/index.js +19 -6
- package/dist/observability/index.mjs +19 -6
- package/dist/perf/cli.cjs +26 -28
- package/dist/perf/cli.js +11 -13
- package/dist/perf/cli.mjs +11 -13
- package/dist/perf/index.cjs +13 -15
- package/dist/perf/index.js +11 -13
- package/dist/perf/index.mjs +11 -13
- package/dist/schema/index.cjs +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/index.mjs +1 -1
- package/dist/{server-D6JZ15_e.d.ts → server-Bf1zNYZk.d.ts} +5 -5
- package/dist/{stream-B4oK9JFP.d.ts → stream-I7bkvF7a.d.ts} +1 -1
- package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DF83nLn6.d.ts} +2 -2
- package/dist/{tracing-DqbTKGcf.d.ts → tracing-CWV4gT0u.d.ts} +1 -1
- package/docs/README.md +2 -0
- package/docs/ai/PUBLIC_API.md +28 -7
- package/docs/articles/brass-runtime-http-observability.md +467 -0
- package/docs/frameworks/angular.md +51 -0
- package/docs/frameworks/express.md +58 -0
- package/docs/frameworks/fastify.md +49 -0
- package/docs/frameworks/nestjs.md +53 -0
- package/docs/frameworks/nextjs.md +55 -0
- package/docs/frameworks/react.md +44 -0
- package/docs/frameworks/vanilla.md +56 -0
- package/docs/guides/layers.md +130 -0
- package/docs/http-recipes.md +31 -1
- package/docs/http.md +50 -1
- package/docs/observability.md +132 -0
- package/docs/performance-profiler.md +6 -2
- package/docs/recipes/layers.md +46 -2
- package/docs/recipes/testing.md +25 -0
- package/package.json +6 -2
- package/dist/chunk-3LOYJFRR.cjs +0 -300
- package/dist/chunk-3Y2RIUMM.js +0 -300
- package/dist/chunk-5EC274J5.cjs +0 -2874
- package/dist/chunk-5VRJNBLZ.mjs +0 -2874
- package/dist/chunk-62AZW6UT.cjs +0 -313
- package/dist/chunk-74ZTY6CP.js +0 -2871
- package/dist/chunk-7CMJS3QE.mjs +0 -2871
- package/dist/chunk-A2OM6NEH.mjs +0 -194
- package/dist/chunk-B33ICAKP.js +0 -313
- package/dist/chunk-JF5WGYJJ.cjs +0 -194
- package/dist/chunk-KN32XNTH.mjs +0 -313
- package/dist/chunk-KQLYONSE.cjs +0 -2871
- package/dist/chunk-L2SYFEBS.js +0 -194
- package/dist/chunk-MIIYDLGM.js +0 -2874
- package/dist/chunk-PWC3RBQE.mjs +0 -300
- package/dist/client-CZHU674n.d.ts +0 -820
|
@@ -29,6 +29,7 @@ function formatConfigError(error) {
|
|
|
29
29
|
}
|
|
30
30
|
var ok = (data) => ({ success: true, data });
|
|
31
31
|
var fail = (issues) => ({ success: false, issues });
|
|
32
|
+
var EMPTY_PATH = Object.freeze([]);
|
|
32
33
|
var receivedKind = (value) => {
|
|
33
34
|
if (value === null) return "null";
|
|
34
35
|
if (value === void 0) return "undefined";
|
|
@@ -37,12 +38,16 @@ var receivedKind = (value) => {
|
|
|
37
38
|
return typeof value;
|
|
38
39
|
};
|
|
39
40
|
var pathLabel = (path) => path.length === 0 ? "$" : path.reduce((acc, part) => typeof part === "number" ? `${acc}[${part}]` : `${acc}.${part}`, "$");
|
|
40
|
-
var makeSchemaIssue = (path, expected, received, message) =>
|
|
41
|
-
path
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
var makeSchemaIssue = (path, expected, received, message) => {
|
|
42
|
+
const issuePath = path.length === 0 ? EMPTY_PATH : [...path];
|
|
43
|
+
const receivedLabel = receivedKind(received);
|
|
44
|
+
return {
|
|
45
|
+
path: issuePath,
|
|
46
|
+
expected,
|
|
47
|
+
received: receivedLabel,
|
|
48
|
+
message: message ?? `Expected ${expected} at ${pathLabel(issuePath)}, received ${receivedLabel}`
|
|
49
|
+
};
|
|
50
|
+
};
|
|
46
51
|
function formatIssues(issues) {
|
|
47
52
|
if (issues.length === 0) return "Validation failed";
|
|
48
53
|
const preview = issues.slice(0, 3).map((issue) => `${pathLabel(issue.path)}: ${issue.message}`).join("; ");
|
|
@@ -55,9 +60,9 @@ function makeSchema(kind, isOptional, parser, name) {
|
|
|
55
60
|
name,
|
|
56
61
|
isOptional,
|
|
57
62
|
_parse: parser,
|
|
58
|
-
safeParse: (input) => parser(input,
|
|
63
|
+
safeParse: (input) => parser(input, EMPTY_PATH),
|
|
59
64
|
parse: (input) => {
|
|
60
|
-
const result = parser(input,
|
|
65
|
+
const result = parser(input, EMPTY_PATH);
|
|
61
66
|
if (result.success) return result.data;
|
|
62
67
|
throw new SchemaValidationException(result.issues);
|
|
63
68
|
},
|
|
@@ -212,50 +217,65 @@ function arraySchema(item) {
|
|
|
212
217
|
return makeSchema("array", false, (input, path) => {
|
|
213
218
|
if (!Array.isArray(input)) return fail([makeSchemaIssue(path, "array", input)]);
|
|
214
219
|
const out = [];
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
const childPath = path.length === 0 ? [] : [...path];
|
|
221
|
+
let issues;
|
|
222
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
223
|
+
if (!(index in input)) continue;
|
|
224
|
+
childPath.push(index);
|
|
225
|
+
const result = item._parse(input[index], childPath);
|
|
226
|
+
childPath.pop();
|
|
218
227
|
if (result.success) {
|
|
219
228
|
out.push(result.data);
|
|
220
229
|
} else {
|
|
230
|
+
issues ??= [];
|
|
221
231
|
issues.push(...result.issues);
|
|
222
232
|
}
|
|
223
|
-
}
|
|
224
|
-
return issues
|
|
233
|
+
}
|
|
234
|
+
return issues ? fail(issues) : ok(out);
|
|
225
235
|
});
|
|
226
236
|
}
|
|
227
237
|
function objectSchema(shape, options = {}) {
|
|
228
238
|
const unknownKeys = options.unknownKeys ?? "strip";
|
|
239
|
+
const shapeEntries = Object.entries(shape);
|
|
240
|
+
const knownKeys = unknownKeys === "strict" ? new Set(shapeEntries.map(([key]) => key)) : void 0;
|
|
229
241
|
return makeSchema("object", false, (input, path) => {
|
|
230
242
|
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
231
243
|
return fail([makeSchemaIssue(path, options.name ?? "object", input)]);
|
|
232
244
|
}
|
|
233
245
|
const source = input;
|
|
234
246
|
const out = unknownKeys === "passthrough" ? { ...source } : {};
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
for (const [key, fieldSchema] of
|
|
247
|
+
const childPath = path.length === 0 ? [] : [...path];
|
|
248
|
+
let issues;
|
|
249
|
+
for (const [key, fieldSchema] of shapeEntries) {
|
|
250
|
+
childPath.push(key);
|
|
238
251
|
if (!(key in source)) {
|
|
239
252
|
if (!fieldSchema.isOptional) {
|
|
240
|
-
issues
|
|
253
|
+
issues ??= [];
|
|
254
|
+
issues.push(makeSchemaIssue(childPath, fieldSchema.name ?? fieldSchema.kind, void 0, "Required field is missing"));
|
|
241
255
|
}
|
|
256
|
+
childPath.pop();
|
|
242
257
|
continue;
|
|
243
258
|
}
|
|
244
|
-
const result = fieldSchema._parse(source[key],
|
|
259
|
+
const result = fieldSchema._parse(source[key], childPath);
|
|
260
|
+
childPath.pop();
|
|
245
261
|
if (result.success) {
|
|
246
262
|
out[key] = result.data;
|
|
247
263
|
} else {
|
|
264
|
+
issues ??= [];
|
|
248
265
|
issues.push(...result.issues);
|
|
249
266
|
}
|
|
250
267
|
}
|
|
251
|
-
if (
|
|
268
|
+
if (knownKeys) {
|
|
252
269
|
for (const key of Object.keys(source)) {
|
|
253
270
|
if (!knownKeys.has(key)) {
|
|
254
|
-
|
|
271
|
+
childPath.push(key);
|
|
272
|
+
issues ??= [];
|
|
273
|
+
issues.push(makeSchemaIssue(childPath, "known key", source[key], "Unknown key is not allowed"));
|
|
274
|
+
childPath.pop();
|
|
255
275
|
}
|
|
256
276
|
}
|
|
257
277
|
}
|
|
258
|
-
return issues
|
|
278
|
+
return issues ? fail(issues) : ok(out);
|
|
259
279
|
}, options.name);
|
|
260
280
|
}
|
|
261
281
|
function recordSchema(valueSchema) {
|
|
@@ -264,16 +284,20 @@ function recordSchema(valueSchema) {
|
|
|
264
284
|
return fail([makeSchemaIssue(path, "record", input)]);
|
|
265
285
|
}
|
|
266
286
|
const out = {};
|
|
267
|
-
const
|
|
287
|
+
const childPath = path.length === 0 ? [] : [...path];
|
|
288
|
+
let issues;
|
|
268
289
|
for (const [key, value] of Object.entries(input)) {
|
|
269
|
-
|
|
290
|
+
childPath.push(key);
|
|
291
|
+
const result = valueSchema._parse(value, childPath);
|
|
292
|
+
childPath.pop();
|
|
270
293
|
if (result.success) {
|
|
271
294
|
out[key] = result.data;
|
|
272
295
|
} else {
|
|
296
|
+
issues ??= [];
|
|
273
297
|
issues.push(...result.issues);
|
|
274
298
|
}
|
|
275
299
|
}
|
|
276
|
-
return issues
|
|
300
|
+
return issues ? fail(issues) : ok(out);
|
|
277
301
|
});
|
|
278
302
|
}
|
|
279
303
|
function unionSchema(members) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
makeRuntimeEventRecord
|
|
3
|
+
} from "./chunk-OW5VHAOE.js";
|
|
4
4
|
import {
|
|
5
|
+
layerEffect,
|
|
5
6
|
makeScheduleDriver
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
makeRuntimeEventRecord
|
|
9
|
-
} from "./chunk-RKGKFN2A.js";
|
|
7
|
+
} from "./chunk-S4HXADU4.js";
|
|
10
8
|
import {
|
|
11
9
|
Runtime,
|
|
12
10
|
getCurrentFiber,
|
|
@@ -14,7 +12,7 @@ import {
|
|
|
14
12
|
runtimeClockFromEnv,
|
|
15
13
|
toPromise,
|
|
16
14
|
unsafeRunAsync
|
|
17
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TTSPIU3U.js";
|
|
18
16
|
import {
|
|
19
17
|
Cause,
|
|
20
18
|
Exit,
|
|
@@ -24,9 +22,11 @@ import {
|
|
|
24
22
|
asyncFold,
|
|
25
23
|
asyncMap,
|
|
26
24
|
asyncSucceed,
|
|
27
|
-
asyncSync
|
|
28
|
-
unit
|
|
25
|
+
asyncSync
|
|
29
26
|
} from "./chunk-UB4B6OFY.js";
|
|
27
|
+
import {
|
|
28
|
+
parseConfig
|
|
29
|
+
} from "./chunk-HCJ4S3YB.js";
|
|
30
30
|
|
|
31
31
|
// src/core/types/cancel.ts
|
|
32
32
|
function makeCancelToken() {
|
|
@@ -636,275 +636,19 @@ function neverEffect() {
|
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
-
// src/core/runtime/
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
this.name = "MissingLayerServiceError";
|
|
646
|
-
this.serviceName = serviceName;
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
function formatLayerError(error) {
|
|
650
|
-
if (error instanceof MissingLayerServiceError) return error.message;
|
|
651
|
-
if (isObjectRecord(error) && error._tag === "MissingLayerService" && typeof error.serviceName === "string") {
|
|
652
|
-
return `Missing layer service '${error.serviceName}'. Add the provider layer before using the service.`;
|
|
653
|
-
}
|
|
654
|
-
return error instanceof Error ? error.message : String(error);
|
|
655
|
-
}
|
|
656
|
-
function makeServiceTag(name) {
|
|
657
|
-
return {
|
|
658
|
-
_tag: "ServiceTag",
|
|
659
|
-
key: Symbol(name),
|
|
660
|
-
name
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
var serviceTag = makeServiceTag;
|
|
664
|
-
var defineService = makeServiceTag;
|
|
665
|
-
var LayerContext = class _LayerContext {
|
|
666
|
-
services;
|
|
667
|
-
constructor(entries) {
|
|
668
|
-
if (entries instanceof Map) {
|
|
669
|
-
this.services = new Map(entries);
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
this.services = /* @__PURE__ */ new Map();
|
|
673
|
-
if (!entries) return;
|
|
674
|
-
for (const [tag, service] of entries) this.services.set(tag.key, service);
|
|
675
|
-
}
|
|
676
|
-
static empty() {
|
|
677
|
-
return new _LayerContext();
|
|
678
|
-
}
|
|
679
|
-
get(tag) {
|
|
680
|
-
return this.services.get(tag.key);
|
|
681
|
-
}
|
|
682
|
-
unsafeGet(tag) {
|
|
683
|
-
if (!this.services.has(tag.key)) {
|
|
684
|
-
throw new MissingLayerServiceError(tag.name);
|
|
685
|
-
}
|
|
686
|
-
return this.services.get(tag.key);
|
|
687
|
-
}
|
|
688
|
-
has(tag) {
|
|
689
|
-
return this.services.has(tag.key);
|
|
690
|
-
}
|
|
691
|
-
add(tag, service) {
|
|
692
|
-
const next = new Map(this.services);
|
|
693
|
-
next.set(tag.key, service);
|
|
694
|
-
return new _LayerContext(next);
|
|
695
|
-
}
|
|
696
|
-
merge(other) {
|
|
697
|
-
const next = new Map(this.services);
|
|
698
|
-
for (const [key, service] of other.services) next.set(key, service);
|
|
699
|
-
return new _LayerContext(next);
|
|
700
|
-
}
|
|
701
|
-
size() {
|
|
702
|
-
return this.services.size;
|
|
703
|
-
}
|
|
704
|
-
};
|
|
705
|
-
function makeLayerScope() {
|
|
706
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
707
|
-
const finalizers = [];
|
|
708
|
-
let closed = false;
|
|
709
|
-
const scope = {
|
|
710
|
-
get: (l, deps) => {
|
|
711
|
-
if (closed) return asyncFail(new Error("LayerScope is closed"));
|
|
712
|
-
if (cache.has(l)) return asyncSucceed(cache.get(l));
|
|
713
|
-
const built = l.buildScoped ? l.buildScoped(deps, scope) : asyncFlatMap(
|
|
714
|
-
l.build(deps),
|
|
715
|
-
({ service, release }) => asyncFlatMap(scope.addFinalizer(release), () => asyncSucceed(service))
|
|
716
|
-
);
|
|
717
|
-
return asyncFlatMap(
|
|
718
|
-
built,
|
|
719
|
-
(service) => asyncSync(() => {
|
|
720
|
-
cache.set(l, service);
|
|
721
|
-
return service;
|
|
722
|
-
})
|
|
723
|
-
);
|
|
724
|
-
},
|
|
725
|
-
close: () => {
|
|
726
|
-
if (closed) return unit();
|
|
727
|
-
closed = true;
|
|
728
|
-
return releaseAll(finalizers);
|
|
729
|
-
},
|
|
730
|
-
size: () => finalizers.length,
|
|
731
|
-
addFinalizer: (release) => asyncSync(() => {
|
|
732
|
-
if (!closed) finalizers.push(release);
|
|
733
|
-
})
|
|
734
|
-
};
|
|
735
|
-
return scope;
|
|
736
|
-
}
|
|
737
|
-
function releaseAll(finalizers) {
|
|
738
|
-
const next = finalizers.pop();
|
|
739
|
-
if (!next) return unit();
|
|
740
|
-
return asyncFold(
|
|
741
|
-
next(),
|
|
742
|
-
() => releaseAll(finalizers),
|
|
743
|
-
() => releaseAll(finalizers)
|
|
744
|
-
);
|
|
745
|
-
}
|
|
746
|
-
function mergeServices(a, b) {
|
|
747
|
-
if (a instanceof LayerContext && b instanceof LayerContext) {
|
|
748
|
-
return a.merge(b);
|
|
749
|
-
}
|
|
750
|
-
if (isObjectRecord(a) && isObjectRecord(b)) {
|
|
751
|
-
return { ...a, ...b };
|
|
752
|
-
}
|
|
753
|
-
return Object.assign({}, a, b);
|
|
754
|
-
}
|
|
755
|
-
function isObjectRecord(value) {
|
|
756
|
-
return typeof value === "object" && value !== null;
|
|
757
|
-
}
|
|
758
|
-
function layer(acquire, release) {
|
|
759
|
-
return {
|
|
760
|
-
_tag: "Layer",
|
|
761
|
-
build: (_deps) => asyncFlatMap(acquire(), (service) => asyncSucceed({
|
|
762
|
-
service,
|
|
763
|
-
release: release ? () => release(service) : () => unit()
|
|
764
|
-
}))
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
function layerValue(tag, value) {
|
|
768
|
-
return layerEffect(tag, () => asyncSucceed(value));
|
|
769
|
-
}
|
|
770
|
-
function layerEffect(tag, acquire, release) {
|
|
771
|
-
return {
|
|
772
|
-
_tag: "Layer",
|
|
773
|
-
build: (deps = LayerContext.empty()) => asyncFlatMap(acquire(deps), (service) => asyncSucceed({
|
|
774
|
-
service: deps.add(tag, service),
|
|
775
|
-
release: release ? () => release(service) : () => unit()
|
|
776
|
-
}))
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
var layerFromContext = layerEffect;
|
|
780
|
-
var defineLayer = layerEffect;
|
|
781
|
-
function getService(tag) {
|
|
782
|
-
return asyncSync((context) => context.unsafeGet(tag));
|
|
783
|
-
}
|
|
784
|
-
function layerFrom() {
|
|
785
|
-
return (acquire, release) => ({
|
|
786
|
-
_tag: "Layer",
|
|
787
|
-
build: (deps) => asyncFlatMap(acquire(deps), (service) => asyncSucceed({
|
|
788
|
-
service,
|
|
789
|
-
release: release ? () => release(service) : () => unit()
|
|
790
|
-
}))
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
function layerSucceed(value) {
|
|
794
|
-
return {
|
|
795
|
-
_tag: "Layer",
|
|
796
|
-
build: () => asyncSucceed({ service: value, release: () => unit() })
|
|
797
|
-
};
|
|
798
|
-
}
|
|
799
|
-
function layerFail(error) {
|
|
800
|
-
return {
|
|
801
|
-
_tag: "Layer",
|
|
802
|
-
build: () => asyncFail(error)
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
function compose(from, to) {
|
|
806
|
-
return {
|
|
807
|
-
_tag: "Layer",
|
|
808
|
-
buildScoped: (deps, scope) => asyncFlatMap(
|
|
809
|
-
scope.get(from, deps),
|
|
810
|
-
(mid) => scope.get(to, mid)
|
|
811
|
-
),
|
|
812
|
-
build: (deps) => asyncFlatMap(
|
|
813
|
-
from.build(deps),
|
|
814
|
-
({ service: mid, release: releaseMid }) => asyncFold(
|
|
815
|
-
to.build(mid),
|
|
816
|
-
(error) => asyncFlatMap(releaseMid(), () => asyncFail(error)),
|
|
817
|
-
({ service: out, release: releaseOut }) => asyncSucceed({
|
|
818
|
-
service: out,
|
|
819
|
-
release: () => asyncFlatMap(releaseOut(), () => releaseMid())
|
|
820
|
-
})
|
|
821
|
-
)
|
|
822
|
-
)
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
function merge(left, right) {
|
|
826
|
-
return {
|
|
827
|
-
_tag: "Layer",
|
|
828
|
-
buildScoped: (deps, scope) => asyncFlatMap(
|
|
829
|
-
scope.get(left, deps),
|
|
830
|
-
(a) => asyncFlatMap(
|
|
831
|
-
scope.get(right, deps),
|
|
832
|
-
(b) => asyncSucceed(mergeServices(a, b))
|
|
833
|
-
)
|
|
834
|
-
),
|
|
835
|
-
build: (deps) => asyncFlatMap(
|
|
836
|
-
left.build(deps),
|
|
837
|
-
({ service: a, release: releaseA }) => asyncFold(
|
|
838
|
-
right.build(deps),
|
|
839
|
-
(error) => asyncFlatMap(releaseA(), () => asyncFail(error)),
|
|
840
|
-
({ service: b, release: releaseB }) => asyncSucceed({
|
|
841
|
-
service: mergeServices(a, b),
|
|
842
|
-
release: () => asyncFlatMap(releaseB(), () => releaseA())
|
|
843
|
-
})
|
|
844
|
-
)
|
|
845
|
-
)
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
function mapLayer(l, f) {
|
|
849
|
-
return {
|
|
850
|
-
_tag: "Layer",
|
|
851
|
-
buildScoped: (deps, scope) => asyncFlatMap(
|
|
852
|
-
scope.get(l, deps),
|
|
853
|
-
(service) => asyncSucceed(f(service))
|
|
854
|
-
),
|
|
855
|
-
build: (deps) => asyncFlatMap(
|
|
856
|
-
l.build(deps),
|
|
857
|
-
({ service, release }) => asyncSucceed({ service: f(service), release })
|
|
639
|
+
// src/core/runtime/configLayer.ts
|
|
640
|
+
function makeConfigLayer(tag, schema, source, options = {}) {
|
|
641
|
+
return layerEffect(
|
|
642
|
+
tag,
|
|
643
|
+
(context) => asyncSync(
|
|
644
|
+
() => parseConfig(options.name ?? tag.name, schema, readConfigSource(source, context))
|
|
858
645
|
)
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
function buildLayer(l, deps) {
|
|
862
|
-
const scope = makeLayerScope();
|
|
863
|
-
return asyncFold(
|
|
864
|
-
scope.get(l, deps),
|
|
865
|
-
(error) => asyncFlatMap(scope.close(), () => asyncFail(error)),
|
|
866
|
-
(service) => asyncSucceed({
|
|
867
|
-
service,
|
|
868
|
-
scope,
|
|
869
|
-
close: scope.close,
|
|
870
|
-
use: (body) => body(service)
|
|
871
|
-
})
|
|
872
646
|
);
|
|
873
647
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
({ service, close }) => ensuring(
|
|
878
|
-
use(service),
|
|
879
|
-
() => close()
|
|
880
|
-
)
|
|
881
|
-
);
|
|
648
|
+
var defineConfigLayer = makeConfigLayer;
|
|
649
|
+
function readConfigSource(source, context) {
|
|
650
|
+
return typeof source === "function" ? source(context) : source;
|
|
882
651
|
}
|
|
883
|
-
function provideLayerContext(l, use, deps = LayerContext.empty()) {
|
|
884
|
-
return provideLayer(l, use, deps);
|
|
885
|
-
}
|
|
886
|
-
var provide = provideLayer;
|
|
887
|
-
var provideContext = provideLayerContext;
|
|
888
|
-
var Layer = Object.freeze({
|
|
889
|
-
make: layer,
|
|
890
|
-
from: layerFrom,
|
|
891
|
-
succeed: layerSucceed,
|
|
892
|
-
fail: layerFail,
|
|
893
|
-
value: layerValue,
|
|
894
|
-
effect: layerEffect,
|
|
895
|
-
define: defineLayer,
|
|
896
|
-
fromContext: layerFromContext,
|
|
897
|
-
compose,
|
|
898
|
-
merge,
|
|
899
|
-
map: mapLayer,
|
|
900
|
-
provide: provideLayer,
|
|
901
|
-
provideContext: provideLayerContext,
|
|
902
|
-
build: buildLayer,
|
|
903
|
-
scope: makeLayerScope,
|
|
904
|
-
context: LayerContext.empty,
|
|
905
|
-
tag: makeServiceTag,
|
|
906
|
-
service: getService
|
|
907
|
-
});
|
|
908
652
|
|
|
909
653
|
// src/core/runtime/workerPool.ts
|
|
910
654
|
function makeWorkerPool(config = {}) {
|
|
@@ -1586,31 +1330,8 @@ export {
|
|
|
1586
1330
|
flakyEffect,
|
|
1587
1331
|
delayedEffect,
|
|
1588
1332
|
neverEffect,
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
makeServiceTag,
|
|
1592
|
-
serviceTag,
|
|
1593
|
-
defineService,
|
|
1594
|
-
LayerContext,
|
|
1595
|
-
makeLayerScope,
|
|
1596
|
-
layer,
|
|
1597
|
-
layerValue,
|
|
1598
|
-
layerEffect,
|
|
1599
|
-
layerFromContext,
|
|
1600
|
-
defineLayer,
|
|
1601
|
-
getService,
|
|
1602
|
-
layerFrom,
|
|
1603
|
-
layerSucceed,
|
|
1604
|
-
layerFail,
|
|
1605
|
-
compose,
|
|
1606
|
-
merge,
|
|
1607
|
-
mapLayer,
|
|
1608
|
-
buildLayer,
|
|
1609
|
-
provideLayer,
|
|
1610
|
-
provideLayerContext,
|
|
1611
|
-
provide,
|
|
1612
|
-
provideContext,
|
|
1613
|
-
Layer,
|
|
1333
|
+
makeConfigLayer,
|
|
1334
|
+
defineConfigLayer,
|
|
1614
1335
|
makeWorkerPool,
|
|
1615
1336
|
makeTracer,
|
|
1616
1337
|
consoleJsonLogger,
|