@deslop/scope 0.1.1142 → 0.1.1155
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 +1 -1
- package/dist/server.js +960 -728
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -3169,9 +3169,9 @@ function Array_$1(item) {
|
|
|
3169
3169
|
/**
|
|
3170
3170
|
* @since 2.0.0
|
|
3171
3171
|
*/
|
|
3172
|
-
const TypeId$
|
|
3172
|
+
const TypeId$57 = "~effect/Option";
|
|
3173
3173
|
const CommonProto$1 = {
|
|
3174
|
-
[TypeId$
|
|
3174
|
+
[TypeId$57]: { _A: (_) => _ },
|
|
3175
3175
|
...PipeInspectableProto,
|
|
3176
3176
|
[Symbol.iterator]() {
|
|
3177
3177
|
return new SingleShotGen(this);
|
|
@@ -3221,7 +3221,7 @@ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
|
|
|
3221
3221
|
}
|
|
3222
3222
|
});
|
|
3223
3223
|
/** @internal */
|
|
3224
|
-
const isOption$1 = (input) => hasProperty(input, TypeId$
|
|
3224
|
+
const isOption$1 = (input) => hasProperty(input, TypeId$57);
|
|
3225
3225
|
/** @internal */
|
|
3226
3226
|
const isNone$1 = (fa) => fa._tag === "None";
|
|
3227
3227
|
/** @internal */
|
|
@@ -3234,11 +3234,11 @@ const SomeImpl = function(value) {
|
|
|
3234
3234
|
};
|
|
3235
3235
|
SomeImpl.prototype = SomeProto;
|
|
3236
3236
|
/** @internal */
|
|
3237
|
-
const some$
|
|
3237
|
+
const some$1 = (value) => new SomeImpl(value);
|
|
3238
3238
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/internal/result.js
|
|
3239
|
-
const TypeId$
|
|
3239
|
+
const TypeId$56 = "~effect/Result";
|
|
3240
3240
|
const CommonProto = {
|
|
3241
|
-
[TypeId$
|
|
3241
|
+
[TypeId$56]: {
|
|
3242
3242
|
/* v8 ignore next 2 */
|
|
3243
3243
|
_A: (_) => _,
|
|
3244
3244
|
_E: (_) => _
|
|
@@ -3289,7 +3289,7 @@ const FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Com
|
|
|
3289
3289
|
}
|
|
3290
3290
|
});
|
|
3291
3291
|
/** @internal */
|
|
3292
|
-
const isResult$1 = (input) => hasProperty(input, TypeId$
|
|
3292
|
+
const isResult$1 = (input) => hasProperty(input, TypeId$56);
|
|
3293
3293
|
/** @internal */
|
|
3294
3294
|
const isFailure$2 = (result) => result._tag === "Failure";
|
|
3295
3295
|
/** @internal */
|
|
@@ -3713,6 +3713,38 @@ const isLessThanOrEqualTo$1 = (O) => dual(2, (self, that) => O(self, that) !== 1
|
|
|
3713
3713
|
*/
|
|
3714
3714
|
const isGreaterThanOrEqualTo$2 = (O) => dual(2, (self, that) => O(self, that) !== -1);
|
|
3715
3715
|
/**
|
|
3716
|
+
* Returns the minimum of two values according to the given order. If they are equal, returns the first argument.
|
|
3717
|
+
*
|
|
3718
|
+
* **When to use**
|
|
3719
|
+
*
|
|
3720
|
+
* Use when you need to select the smaller of two values according to an
|
|
3721
|
+
* `Order`.
|
|
3722
|
+
*
|
|
3723
|
+
* **Details**
|
|
3724
|
+
*
|
|
3725
|
+
* Returns the value that compares as less than or equal to the other value. If
|
|
3726
|
+
* values are equal, the first argument is returned.
|
|
3727
|
+
*
|
|
3728
|
+
* **Example** (Selecting the minimum value)
|
|
3729
|
+
*
|
|
3730
|
+
* ```ts import.meta.vitest
|
|
3731
|
+
* import { Order } from "effect"
|
|
3732
|
+
*
|
|
3733
|
+
* const minNumber = Order.min(Order.Number)
|
|
3734
|
+
*
|
|
3735
|
+
* minNumber(1, 2) // => 1
|
|
3736
|
+
* minNumber(2, 1) // => 1
|
|
3737
|
+
* minNumber(1, 1) // => 1
|
|
3738
|
+
* ```
|
|
3739
|
+
*
|
|
3740
|
+
* @see {@link max} for the maximum of two values
|
|
3741
|
+
* @see {@link clamp} to clamp a value between min and max
|
|
3742
|
+
* @stability stable
|
|
3743
|
+
* @category comparisons
|
|
3744
|
+
* @since 2.0.0
|
|
3745
|
+
*/
|
|
3746
|
+
const min$1 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1 ? self : that);
|
|
3747
|
+
/**
|
|
3716
3748
|
* Returns the maximum of two values according to the given order. If they are equal, returns the first argument.
|
|
3717
3749
|
*
|
|
3718
3750
|
* **When to use**
|
|
@@ -3804,7 +3836,7 @@ const none = () => none$1;
|
|
|
3804
3836
|
* @category constructors
|
|
3805
3837
|
* @since 2.0.0
|
|
3806
3838
|
*/
|
|
3807
|
-
const some
|
|
3839
|
+
const some = some$1;
|
|
3808
3840
|
/**
|
|
3809
3841
|
* Determines whether the given value is an `Option`.
|
|
3810
3842
|
*
|
|
@@ -3921,7 +3953,7 @@ const isSome = isSome$1;
|
|
|
3921
3953
|
* @category pattern matching
|
|
3922
3954
|
* @since 2.0.0
|
|
3923
3955
|
*/
|
|
3924
|
-
const match$
|
|
3956
|
+
const match$6 = /*#__PURE__*/ dual(2, (self, { onNone, onSome }) => isNone(self) ? onNone() : onSome(self.value));
|
|
3925
3957
|
/**
|
|
3926
3958
|
* Extracts the value from a `Some`, or evaluates a fallback thunk on `None`.
|
|
3927
3959
|
*
|
|
@@ -4016,7 +4048,7 @@ const orElse$2 = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : s
|
|
|
4016
4048
|
* @category converting
|
|
4017
4049
|
* @since 4.0.0
|
|
4018
4050
|
*/
|
|
4019
|
-
const fromNullishOr = (a) => a == null ? none() : some
|
|
4051
|
+
const fromNullishOr = (a) => a == null ? none() : some(a);
|
|
4020
4052
|
/**
|
|
4021
4053
|
* Converts a possibly `undefined` value into an `Option`, leaving `null`
|
|
4022
4054
|
* as a valid `Some`.
|
|
@@ -4048,7 +4080,7 @@ const fromNullishOr = (a) => a == null ? none() : some$1(a);
|
|
|
4048
4080
|
* @category converting
|
|
4049
4081
|
* @since 4.0.0
|
|
4050
4082
|
*/
|
|
4051
|
-
const fromUndefinedOr = (a) => a === void 0 ? none() : some
|
|
4083
|
+
const fromUndefinedOr = (a) => a === void 0 ? none() : some(a);
|
|
4052
4084
|
/**
|
|
4053
4085
|
* Extracts the value from a `Some`, or returns `undefined` for `None`.
|
|
4054
4086
|
*
|
|
@@ -4110,7 +4142,7 @@ const getOrUndefined$1 = /*#__PURE__*/ getOrElse(constUndefined);
|
|
|
4110
4142
|
*/
|
|
4111
4143
|
const liftThrowable = (f) => (...a) => {
|
|
4112
4144
|
try {
|
|
4113
|
-
return some
|
|
4145
|
+
return some(f(...a));
|
|
4114
4146
|
} catch {
|
|
4115
4147
|
return none();
|
|
4116
4148
|
}
|
|
@@ -4183,7 +4215,7 @@ const getOrThrow$1 = /*#__PURE__*/ (/* @__PURE__ */ dual(2, (self, onNone) => {
|
|
|
4183
4215
|
* @category mapping
|
|
4184
4216
|
* @since 2.0.0
|
|
4185
4217
|
*/
|
|
4186
|
-
const map$8 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some
|
|
4218
|
+
const map$8 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
|
|
4187
4219
|
/**
|
|
4188
4220
|
* Applies a function that returns an `Option` to the value of a `Some`,
|
|
4189
4221
|
* flattening the result. Returns `None` if the input is `None`.
|
|
@@ -4264,7 +4296,7 @@ const flatMap$6 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : f(s
|
|
|
4264
4296
|
* @category filtering
|
|
4265
4297
|
* @since 2.0.0
|
|
4266
4298
|
*/
|
|
4267
|
-
const filter$3 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some
|
|
4299
|
+
const filter$3 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none() : predicate(self.value) ? some(self.value) : none());
|
|
4268
4300
|
/**
|
|
4269
4301
|
* Lifts a `Predicate` or `Refinement` into the `Option` context: returns
|
|
4270
4302
|
* `Some(value)` when the predicate holds, `None` otherwise.
|
|
@@ -4298,7 +4330,7 @@ const filter$3 = /*#__PURE__*/ dual(2, (self, predicate) => isNone(self) ? none(
|
|
|
4298
4330
|
* @category lifting
|
|
4299
4331
|
* @since 2.0.0
|
|
4300
4332
|
*/
|
|
4301
|
-
const liftPredicate = /*#__PURE__*/ dual(2, (b, predicate) => predicate(b) ? some
|
|
4333
|
+
const liftPredicate = /*#__PURE__*/ dual(2, (b, predicate) => predicate(b) ? some(b) : none());
|
|
4302
4334
|
/**
|
|
4303
4335
|
* Checks whether the value in a `Some` satisfies a predicate or refinement.
|
|
4304
4336
|
*
|
|
@@ -4439,7 +4471,7 @@ const ServiceProto = {
|
|
|
4439
4471
|
};
|
|
4440
4472
|
const cacheKeys = /*#__PURE__*/ new Set();
|
|
4441
4473
|
const ReferenceTypeId = "~effect/Context/Reference";
|
|
4442
|
-
const TypeId$
|
|
4474
|
+
const TypeId$55 = "~effect/Context";
|
|
4443
4475
|
const MaxDepth = 8;
|
|
4444
4476
|
const FlattenAfterBaseHits = 8;
|
|
4445
4477
|
const makeImpl$1 = (cacheRoot, base, overlay, depth) => {
|
|
@@ -4520,7 +4552,7 @@ const Proto$17 = {
|
|
|
4520
4552
|
return flatten$3(this);
|
|
4521
4553
|
},
|
|
4522
4554
|
...PipeInspectableProto,
|
|
4523
|
-
[TypeId$
|
|
4555
|
+
[TypeId$55]: { _Services: (_) => _ },
|
|
4524
4556
|
toJSON() {
|
|
4525
4557
|
return {
|
|
4526
4558
|
_id: "Context",
|
|
@@ -4576,7 +4608,7 @@ const hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot;
|
|
|
4576
4608
|
* @category guards
|
|
4577
4609
|
* @since 2.0.0
|
|
4578
4610
|
*/
|
|
4579
|
-
const isContext = (u) => hasProperty(u, TypeId$
|
|
4611
|
+
const isContext = (u) => hasProperty(u, TypeId$55);
|
|
4580
4612
|
/**
|
|
4581
4613
|
* Checks whether the provided argument is a `Reference`.
|
|
4582
4614
|
*
|
|
@@ -4846,8 +4878,8 @@ const serviceNotFoundError = (service) => {
|
|
|
4846
4878
|
*/
|
|
4847
4879
|
const getOption = /*#__PURE__*/ dual(2, (self, service) => {
|
|
4848
4880
|
const value = lookup(self, service.key);
|
|
4849
|
-
if (value !== notFound$1) return some
|
|
4850
|
-
return isReference(service) ? some
|
|
4881
|
+
if (value !== notFound$1) return some(value);
|
|
4882
|
+
return isReference(service) ? some(getDefaultValue(service)) : none();
|
|
4851
4883
|
});
|
|
4852
4884
|
/**
|
|
4853
4885
|
* Merges two `Context`s into one.
|
|
@@ -5020,7 +5052,7 @@ const omit$2 = (...keys) => (self) => withFlat(self, (map) => {
|
|
|
5020
5052
|
*/
|
|
5021
5053
|
const Reference = Service$2;
|
|
5022
5054
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/Duration.js
|
|
5023
|
-
const TypeId$
|
|
5055
|
+
const TypeId$54 = "~effect/Duration";
|
|
5024
5056
|
const bigint0$3 = /*#__PURE__*/ BigInt(0);
|
|
5025
5057
|
const bigint1$2 = /*#__PURE__*/ BigInt(1);
|
|
5026
5058
|
const bigint2 = /*#__PURE__*/ BigInt(2);
|
|
@@ -5121,7 +5153,7 @@ const fromInputUnsafe$1 = (input) => {
|
|
|
5121
5153
|
}
|
|
5122
5154
|
case "object": {
|
|
5123
5155
|
if (input === null) break;
|
|
5124
|
-
if (TypeId$
|
|
5156
|
+
if (TypeId$54 in input) return input;
|
|
5125
5157
|
if (Array.isArray(input)) {
|
|
5126
5158
|
if (input.length !== 2 || !input.every(isNumber)) return invalid$2(input);
|
|
5127
5159
|
if (Number.isNaN(input[0]) || Number.isNaN(input[1])) return zero$2;
|
|
@@ -5192,7 +5224,7 @@ const zeroDurationValue = {
|
|
|
5192
5224
|
const infinityDurationValue = { _tag: "Infinity" };
|
|
5193
5225
|
const negativeInfinityDurationValue = { _tag: "NegativeInfinity" };
|
|
5194
5226
|
const DurationProto = {
|
|
5195
|
-
[TypeId$
|
|
5227
|
+
[TypeId$54]: TypeId$54,
|
|
5196
5228
|
[symbol$3]() {
|
|
5197
5229
|
switch (this.value._tag) {
|
|
5198
5230
|
case "Millis": return hash(roundMillisToNanos(this.value.millis));
|
|
@@ -5276,7 +5308,7 @@ const make$70 = (input) => {
|
|
|
5276
5308
|
* @category guards
|
|
5277
5309
|
* @since 2.0.0
|
|
5278
5310
|
*/
|
|
5279
|
-
const isDuration = (u) => hasProperty(u, TypeId$
|
|
5311
|
+
const isDuration = (u) => hasProperty(u, TypeId$54);
|
|
5280
5312
|
/**
|
|
5281
5313
|
* Checks whether a Duration is finite (not infinite).
|
|
5282
5314
|
*
|
|
@@ -5480,6 +5512,22 @@ const seconds = (seconds) => make$70(seconds * 1e3);
|
|
|
5480
5512
|
*/
|
|
5481
5513
|
const minutes = (minutes) => make$70(minutes * 6e4);
|
|
5482
5514
|
/**
|
|
5515
|
+
* Creates a Duration from days.
|
|
5516
|
+
*
|
|
5517
|
+
* **Example** (Creating durations from days)
|
|
5518
|
+
*
|
|
5519
|
+
* ```ts import.meta.vitest
|
|
5520
|
+
* import { Duration } from "effect"
|
|
5521
|
+
*
|
|
5522
|
+
* Duration.toMillis(Duration.days(1)) // => 86_400_000
|
|
5523
|
+
* ```
|
|
5524
|
+
*
|
|
5525
|
+
* @stability stable
|
|
5526
|
+
* @category constructors
|
|
5527
|
+
* @since 2.0.0
|
|
5528
|
+
*/
|
|
5529
|
+
const days = (days) => make$70(days * 864e5);
|
|
5530
|
+
/**
|
|
5483
5531
|
* Converts a Duration to milliseconds.
|
|
5484
5532
|
*
|
|
5485
5533
|
* **Example** (Converting durations to milliseconds)
|
|
@@ -5495,7 +5543,7 @@ const minutes = (minutes) => make$70(minutes * 6e4);
|
|
|
5495
5543
|
* @category getters
|
|
5496
5544
|
* @since 2.0.0
|
|
5497
5545
|
*/
|
|
5498
|
-
const toMillis = (self) => match$
|
|
5546
|
+
const toMillis = (self) => match$5(fromInputUnsafe$1(self), {
|
|
5499
5547
|
onMillis: identity,
|
|
5500
5548
|
onNanos: (nanos) => nanosToUnit(nanos, 1e6),
|
|
5501
5549
|
onInfinity: () => Infinity,
|
|
@@ -5517,7 +5565,7 @@ const toMillis = (self) => match$4(fromInputUnsafe$1(self), {
|
|
|
5517
5565
|
* @category getters
|
|
5518
5566
|
* @since 2.0.0
|
|
5519
5567
|
*/
|
|
5520
|
-
const toSeconds = (self) => match$
|
|
5568
|
+
const toSeconds = (self) => match$5(fromInputUnsafe$1(self), {
|
|
5521
5569
|
onMillis: (millis) => millis / 1e3,
|
|
5522
5570
|
onNanos: (nanos) => nanosToUnit(nanos, 1e9),
|
|
5523
5571
|
onInfinity: () => Infinity,
|
|
@@ -5589,7 +5637,7 @@ const toNanosUnsafe = (input) => {
|
|
|
5589
5637
|
* @category pattern matching
|
|
5590
5638
|
* @since 2.0.0
|
|
5591
5639
|
*/
|
|
5592
|
-
const match$
|
|
5640
|
+
const match$5 = /*#__PURE__*/ dual(2, (self, options) => {
|
|
5593
5641
|
switch (self.value._tag) {
|
|
5594
5642
|
case "Millis": return options.onMillis(self.value.millis);
|
|
5595
5643
|
case "Nanos": return options.onNanos(self.value.nanos);
|
|
@@ -6027,7 +6075,7 @@ const map$7 = /*#__PURE__*/ dual(2, (self, f) => isSuccess$1(self) ? succeed$9(f
|
|
|
6027
6075
|
* @category pattern matching
|
|
6028
6076
|
* @since 2.0.0
|
|
6029
6077
|
*/
|
|
6030
|
-
const match$
|
|
6078
|
+
const match$4 = /*#__PURE__*/ dual(2, (self, { onFailure, onSuccess }) => isFailure$1(self) ? onFailure(self.failure) : onSuccess(self.success));
|
|
6031
6079
|
/**
|
|
6032
6080
|
* Extracts the success value or throws the raw failure value `E`.
|
|
6033
6081
|
*
|
|
@@ -6273,7 +6321,7 @@ const findFirst$1 = /*#__PURE__*/ dual(2, (self, f) => {
|
|
|
6273
6321
|
for (const a of self) {
|
|
6274
6322
|
const o = f(a, i);
|
|
6275
6323
|
if (isBoolean(o)) {
|
|
6276
|
-
if (o) return some
|
|
6324
|
+
if (o) return some(a);
|
|
6277
6325
|
} else if (isSome(o)) return o;
|
|
6278
6326
|
i++;
|
|
6279
6327
|
}
|
|
@@ -6395,7 +6443,7 @@ const has$3 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key));
|
|
|
6395
6443
|
* @category getters
|
|
6396
6444
|
* @since 2.0.0
|
|
6397
6445
|
*/
|
|
6398
|
-
const get$9 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key) ? some
|
|
6446
|
+
const get$9 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key) ? some(self[key]) : none());
|
|
6399
6447
|
/**
|
|
6400
6448
|
* Maps a record into another record by applying a transformation function to each of its values.
|
|
6401
6449
|
*
|
|
@@ -6647,6 +6695,42 @@ const fromIterable$6 = (collection) => Array$1.isArray(collection) ? collection
|
|
|
6647
6695
|
*/
|
|
6648
6696
|
const ensure = (self) => Array$1.isArray(self) ? self : [self];
|
|
6649
6697
|
/**
|
|
6698
|
+
* Pattern-matches on an array, handling empty and non-empty cases separately.
|
|
6699
|
+
*
|
|
6700
|
+
* **When to use**
|
|
6701
|
+
*
|
|
6702
|
+
* Use when you need to branch on whether an array is empty.
|
|
6703
|
+
*
|
|
6704
|
+
* **Details**
|
|
6705
|
+
*
|
|
6706
|
+
* `onNonEmpty` receives a `NonEmptyArray` for mutable arrays and a
|
|
6707
|
+
* `NonEmptyReadonlyArray` otherwise. Data-last calls default to the readonly
|
|
6708
|
+
* callback, so the returned function still accepts `ReadonlyArray`. Supports
|
|
6709
|
+
* both data-first and data-last usage.
|
|
6710
|
+
*
|
|
6711
|
+
* **Example** (Branching on emptiness)
|
|
6712
|
+
*
|
|
6713
|
+
* ```ts import.meta.vitest
|
|
6714
|
+
* import { Array } from "effect"
|
|
6715
|
+
*
|
|
6716
|
+
* const describe = Array.match({
|
|
6717
|
+
* onEmpty: () => "empty",
|
|
6718
|
+
* onNonEmpty: ([head, ...tail]) => `head: ${head}, tail: ${tail.length}`
|
|
6719
|
+
* })
|
|
6720
|
+
*
|
|
6721
|
+
* describe([]) // => "empty"
|
|
6722
|
+
* describe([1, 2, 3]) // => "head: 1, tail: 2"
|
|
6723
|
+
* ```
|
|
6724
|
+
*
|
|
6725
|
+
* @see {@link matchLeft} — destructures into head + tail
|
|
6726
|
+
* @see {@link matchRight} — destructures into init + last
|
|
6727
|
+
*
|
|
6728
|
+
* @stability stable
|
|
6729
|
+
* @category pattern matching
|
|
6730
|
+
* @since 2.0.0
|
|
6731
|
+
*/
|
|
6732
|
+
const match$3 = /*#__PURE__*/ dual(2, (self, { onEmpty, onNonEmpty }) => isReadonlyArrayNonEmpty(self) ? onNonEmpty(self) : onEmpty());
|
|
6733
|
+
/**
|
|
6650
6734
|
* Adds a single element to the end of an iterable, returning a `NonEmptyArray`.
|
|
6651
6735
|
*
|
|
6652
6736
|
* **When to use**
|
|
@@ -6670,7 +6754,35 @@ const ensure = (self) => Array$1.isArray(self) ? self : [self];
|
|
|
6670
6754
|
* @since 2.0.0
|
|
6671
6755
|
*/
|
|
6672
6756
|
const append$1 = /*#__PURE__*/ dual(2, (self, last) => [...self, last]);
|
|
6673
|
-
|
|
6757
|
+
/**
|
|
6758
|
+
* Checks whether a value is an `Array`.
|
|
6759
|
+
*
|
|
6760
|
+
* **When to use**
|
|
6761
|
+
*
|
|
6762
|
+
* Use to verify a value is a mutable array, narrowing its type to `Array<unknown>`.
|
|
6763
|
+
*
|
|
6764
|
+
* **Details**
|
|
6765
|
+
*
|
|
6766
|
+
* Acts as a type guard narrowing the input to `Array<unknown>` and delegates to
|
|
6767
|
+
* `globalThis.Array.isArray`.
|
|
6768
|
+
*
|
|
6769
|
+
* **Example** (Type-guarding an unknown value)
|
|
6770
|
+
*
|
|
6771
|
+
* ```ts import.meta.vitest
|
|
6772
|
+
* import { Array } from "effect"
|
|
6773
|
+
*
|
|
6774
|
+
* Array.isArray(null) // => false
|
|
6775
|
+
* Array.isArray([1, 2, 3]) // => true
|
|
6776
|
+
* ```
|
|
6777
|
+
*
|
|
6778
|
+
* @see {@link isArrayEmpty} — check for an empty array
|
|
6779
|
+
* @see {@link isArrayNonEmpty} — check for a non-empty array
|
|
6780
|
+
*
|
|
6781
|
+
* @stability stable
|
|
6782
|
+
* @category guards
|
|
6783
|
+
* @since 2.0.0
|
|
6784
|
+
*/
|
|
6785
|
+
const isArray = Array$1.isArray;
|
|
6674
6786
|
/**
|
|
6675
6787
|
* Checks whether a mutable `Array` is empty, narrowing the type to `[]`.
|
|
6676
6788
|
*
|
|
@@ -6810,7 +6922,7 @@ function isOutOfBounds(i, as) {
|
|
|
6810
6922
|
*/
|
|
6811
6923
|
const get$8 = /*#__PURE__*/ dual(2, (self, index) => {
|
|
6812
6924
|
const i = Math.floor(index);
|
|
6813
|
-
return isOutOfBounds(i, self) ? none() : some
|
|
6925
|
+
return isOutOfBounds(i, self) ? none() : some(self[i]);
|
|
6814
6926
|
});
|
|
6815
6927
|
/**
|
|
6816
6928
|
* Reads an element at the given index, throwing if the index is out of bounds.
|
|
@@ -7382,26 +7494,25 @@ const filter$1 = /*#__PURE__*/ dual(2, (self, predicate) => {
|
|
|
7382
7494
|
*/
|
|
7383
7495
|
const reduce = /*#__PURE__*/ dual(3, (self, b, f) => fromIterable$6(self).reduce((b, a, i) => f(b, a, i), b));
|
|
7384
7496
|
/**
|
|
7385
|
-
*
|
|
7386
|
-
*
|
|
7497
|
+
* Returns the minimum element of a non-empty array according to the given
|
|
7498
|
+
* `Order`.
|
|
7387
7499
|
*
|
|
7388
|
-
* **Example** (
|
|
7500
|
+
* **Example** (Finding the minimum)
|
|
7389
7501
|
*
|
|
7390
7502
|
* ```ts import.meta.vitest
|
|
7391
|
-
* import { Array } from "effect"
|
|
7503
|
+
* import { Array, Order } from "effect"
|
|
7392
7504
|
*
|
|
7393
|
-
* Array.
|
|
7394
|
-
* Array.some([1, 3, 5], (x) => x % 2 === 0) // => false
|
|
7505
|
+
* Array.min([3, 1, 2], Order.Number) // => 1
|
|
7395
7506
|
* ```
|
|
7396
7507
|
*
|
|
7397
|
-
* @see {@link
|
|
7398
|
-
* @see {@link
|
|
7508
|
+
* @see {@link max} — find the maximum
|
|
7509
|
+
* @see {@link sort} — sort the entire array
|
|
7399
7510
|
*
|
|
7400
7511
|
* @stability stable
|
|
7401
|
-
* @category
|
|
7512
|
+
* @category getters
|
|
7402
7513
|
* @since 2.0.0
|
|
7403
7514
|
*/
|
|
7404
|
-
const
|
|
7515
|
+
const min = /*#__PURE__*/ dual(2, (self, O) => self.reduce(min$1(O)));
|
|
7405
7516
|
/**
|
|
7406
7517
|
* Builds an array by repeatedly applying a function to a seed value. The
|
|
7407
7518
|
* function returns `Option.some([element, nextSeed])` to continue, or
|
|
@@ -7521,6 +7632,24 @@ const dedupe = (self) => {
|
|
|
7521
7632
|
return out;
|
|
7522
7633
|
};
|
|
7523
7634
|
/**
|
|
7635
|
+
* Joins string elements with a separator.
|
|
7636
|
+
*
|
|
7637
|
+
* **Example** (Joining strings)
|
|
7638
|
+
*
|
|
7639
|
+
* ```ts import.meta.vitest
|
|
7640
|
+
* import { Array } from "effect"
|
|
7641
|
+
*
|
|
7642
|
+
* Array.join(["a", "b", "c"], "-") // => "a-b-c"
|
|
7643
|
+
* ```
|
|
7644
|
+
*
|
|
7645
|
+
* @see {@link intersperse} — insert separator elements without joining
|
|
7646
|
+
*
|
|
7647
|
+
* @stability stable
|
|
7648
|
+
* @category folding
|
|
7649
|
+
* @since 2.0.0
|
|
7650
|
+
*/
|
|
7651
|
+
const join$1 = /*#__PURE__*/ dual(2, (self, sep) => fromIterable$6(self).join(sep));
|
|
7652
|
+
/**
|
|
7524
7653
|
* Computes the number of elements in an iterable that satisfy a predicate.
|
|
7525
7654
|
*
|
|
7526
7655
|
* **When to use**
|
|
@@ -9071,7 +9200,7 @@ const suspend$3 = /*#__PURE__*/ makePrimitive({
|
|
|
9071
9200
|
/** @internal */
|
|
9072
9201
|
const fromOption$1 = /*#__PURE__*/ dual((args) => args.length >= 2 || isOption(args[0]), (option, onNone) => isNone(option) ? onNone ? failSync$1(onNone) : fail$6(new NoSuchElementError("Effect.fromOption: Option.none")) : succeed$8(option.value));
|
|
9073
9202
|
/** @internal */
|
|
9074
|
-
const fromResult$1 = /*#__PURE__*/ match$
|
|
9203
|
+
const fromResult$1 = /*#__PURE__*/ match$4({
|
|
9075
9204
|
onFailure: fail$6,
|
|
9076
9205
|
onSuccess: succeed$8
|
|
9077
9206
|
});
|
|
@@ -9090,7 +9219,7 @@ const yieldNow$1 = /*#__PURE__*/ (/* @__PURE__ */ makePrimitive({
|
|
|
9090
9219
|
}
|
|
9091
9220
|
}))(0);
|
|
9092
9221
|
/** @internal */
|
|
9093
|
-
const succeedSome$1 = (a) => succeed$8(some
|
|
9222
|
+
const succeedSome$1 = (a) => succeed$8(some(a));
|
|
9094
9223
|
/** @internal */
|
|
9095
9224
|
const succeedNone$1 = /*#__PURE__*/ succeed$8(/*#__PURE__*/ none());
|
|
9096
9225
|
/** @internal */
|
|
@@ -9369,7 +9498,7 @@ const tapEffectCont = function(value) {
|
|
|
9369
9498
|
return new ContImpl(this.payload, succeedPayload, value);
|
|
9370
9499
|
};
|
|
9371
9500
|
/** @internal */
|
|
9372
|
-
const asSome$1 = (self) => map$4(self, some
|
|
9501
|
+
const asSome$1 = (self) => map$4(self, some);
|
|
9373
9502
|
/** @internal */
|
|
9374
9503
|
const andThen$1 = /*#__PURE__*/ dual(2, (self, f) => new ContImpl(self, isEffect$1(f) ? returnPayload : andThenCont, f));
|
|
9375
9504
|
/** @internal */
|
|
@@ -9546,9 +9675,11 @@ const provideService$1 = function() {
|
|
|
9546
9675
|
};
|
|
9547
9676
|
const provideServiceImpl = (self, service, implementation) => updateContext$1(self, add$3(service, implementation));
|
|
9548
9677
|
/** @internal */
|
|
9678
|
+
const filterOrFail$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, orFailWith) => filterOrElse(self, predicate, orFailWith ? (a) => fail$6(orFailWith(a)) : () => fail$6(new NoSuchElementError())));
|
|
9679
|
+
/** @internal */
|
|
9549
9680
|
const when$3 = /*#__PURE__*/ dual(2, (self, condition) => flatMap$3(condition, (pass) => pass ? asSome$1(self) : succeedNone$1));
|
|
9550
9681
|
/** @internal */
|
|
9551
|
-
const forever$
|
|
9682
|
+
const forever$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
|
|
9552
9683
|
while: constTrue,
|
|
9553
9684
|
body: constant(options?.disableYield ? self : flatMap$3(self, (_) => yieldNow$1)),
|
|
9554
9685
|
step: constVoid
|
|
@@ -10228,6 +10359,8 @@ const forEachConcurrent = /*#__PURE__*/ iterateConcurrentImpl({
|
|
|
10228
10359
|
}
|
|
10229
10360
|
});
|
|
10230
10361
|
/** @internal */
|
|
10362
|
+
const filterOrElse = /*#__PURE__*/ dual(3, (self, predicate, orElse) => flatMap$3(self, (a) => predicate(a) ? succeed$8(a) : orElse(a)));
|
|
10363
|
+
/** @internal */
|
|
10231
10364
|
const forkChild$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => withFiber$1((fiber) => {
|
|
10232
10365
|
interruptChildrenPatch();
|
|
10233
10366
|
return succeed$8(forkUnsafe$1(fiber, self, options?.startImmediately, false, options?.uninterruptible ?? false));
|
|
@@ -10429,12 +10562,12 @@ const NoopSpanProto = {
|
|
|
10429
10562
|
const noopSpan = (options) => Object.assign(Object.create(NoopSpanProto), options);
|
|
10430
10563
|
const filterDisablePropagation = (span) => {
|
|
10431
10564
|
if (!span) return none();
|
|
10432
|
-
return get$10(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$1(span.parent)) : none() : some
|
|
10565
|
+
return get$10(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$1(span.parent)) : none() : some(span);
|
|
10433
10566
|
};
|
|
10434
10567
|
/** @internal */
|
|
10435
10568
|
const makeSpanUnsafe = (fiber, name, options) => {
|
|
10436
10569
|
const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get$10(options.annotations, DisablePropagation);
|
|
10437
|
-
const parent = options?.parent !== void 0 ? some
|
|
10570
|
+
const parent = options?.parent !== void 0 ? some(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.cache.span);
|
|
10438
10571
|
let span;
|
|
10439
10572
|
if (disablePropagation) span = noopSpan({
|
|
10440
10573
|
name,
|
|
@@ -11084,7 +11217,7 @@ const hasInterrupts$1 = exitHasInterrupts;
|
|
|
11084
11217
|
*/
|
|
11085
11218
|
const asVoidAll = exitAsVoidAll;
|
|
11086
11219
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/Deferred.js
|
|
11087
|
-
const TypeId$
|
|
11220
|
+
const TypeId$53 = "~effect/Deferred";
|
|
11088
11221
|
/**
|
|
11089
11222
|
* Checks whether a value is a `Deferred`.
|
|
11090
11223
|
*
|
|
@@ -11097,9 +11230,9 @@ const TypeId$52 = "~effect/Deferred";
|
|
|
11097
11230
|
* @category guards
|
|
11098
11231
|
* @since 4.0.0
|
|
11099
11232
|
*/
|
|
11100
|
-
const isDeferred = (u) => hasProperty(u, TypeId$
|
|
11233
|
+
const isDeferred = (u) => hasProperty(u, TypeId$53);
|
|
11101
11234
|
const DeferredProto = {
|
|
11102
|
-
[TypeId$
|
|
11235
|
+
[TypeId$53]: {
|
|
11103
11236
|
_A: identity,
|
|
11104
11237
|
_E: identity
|
|
11105
11238
|
},
|
|
@@ -11968,7 +12101,7 @@ const closeUnsafe = scopeCloseUnsafe;
|
|
|
11968
12101
|
*/
|
|
11969
12102
|
const use$1 = scopeUse;
|
|
11970
12103
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/Layer.js
|
|
11971
|
-
const TypeId$
|
|
12104
|
+
const TypeId$52 = "~effect/Layer";
|
|
11972
12105
|
const MemoMapTypeId = "~effect/Layer/MemoMap";
|
|
11973
12106
|
const makeMemoMapEntry = (memoMap, layer) => {
|
|
11974
12107
|
const entry = {
|
|
@@ -11990,7 +12123,7 @@ const memoMapObserve = (entry, scope) => {
|
|
|
11990
12123
|
return true;
|
|
11991
12124
|
};
|
|
11992
12125
|
const LayerProto = {
|
|
11993
|
-
[TypeId$
|
|
12126
|
+
[TypeId$52]: {
|
|
11994
12127
|
_ROut: identity,
|
|
11995
12128
|
_E: identity,
|
|
11996
12129
|
_RIn: identity
|
|
@@ -13840,11 +13973,11 @@ const Clock = ClockRef;
|
|
|
13840
13973
|
const currentTimeMillis = currentTimeMillis$1;
|
|
13841
13974
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/internal/dateTime.js
|
|
13842
13975
|
/** @internal */
|
|
13843
|
-
const TypeId$
|
|
13976
|
+
const TypeId$51 = "~effect/DateTime";
|
|
13844
13977
|
/** @internal */
|
|
13845
13978
|
const TimeZoneTypeId = "~effect/DateTime/TimeZone";
|
|
13846
13979
|
const Proto$16 = {
|
|
13847
|
-
[TypeId$
|
|
13980
|
+
[TypeId$51]: TypeId$51,
|
|
13848
13981
|
pipe() {
|
|
13849
13982
|
return pipeArguments(this, arguments);
|
|
13850
13983
|
},
|
|
@@ -13878,7 +14011,7 @@ const ProtoTimeZone = {
|
|
|
13878
14011
|
({ ...ProtoTimeZone });
|
|
13879
14012
|
({ ...ProtoTimeZone });
|
|
13880
14013
|
/** @internal */
|
|
13881
|
-
const isDateTime$1 = (u) => hasProperty(u, TypeId$
|
|
14014
|
+
const isDateTime$1 = (u) => hasProperty(u, TypeId$51);
|
|
13882
14015
|
/** @internal */
|
|
13883
14016
|
const isUtc$1 = (self) => self._tag === "Utc";
|
|
13884
14017
|
const makeUtc = (epochMillis) => {
|
|
@@ -14021,12 +14154,12 @@ const max = /*#__PURE__*/ max$1(Number$5);
|
|
|
14021
14154
|
* @since 2.0.0
|
|
14022
14155
|
*/
|
|
14023
14156
|
const parse$2 = (s) => {
|
|
14024
|
-
if (s === "NaN") return some
|
|
14025
|
-
if (s === "Infinity") return some
|
|
14026
|
-
if (s === "-Infinity") return some
|
|
14157
|
+
if (s === "NaN") return some(NaN);
|
|
14158
|
+
if (s === "Infinity") return some(Infinity);
|
|
14159
|
+
if (s === "-Infinity") return some(-Infinity);
|
|
14027
14160
|
if (s.trim() === "") return none();
|
|
14028
14161
|
const n = Number$4(s);
|
|
14029
|
-
return Number$4.isNaN(n) ? none() : some
|
|
14162
|
+
return Number$4.isNaN(n) ? none() : some(n);
|
|
14030
14163
|
};
|
|
14031
14164
|
globalThis.String;
|
|
14032
14165
|
/**
|
|
@@ -14342,10 +14475,375 @@ const matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$
|
|
|
14342
14475
|
return !isFailure$1(halt) ? options.onDone(halt.success.value) : options.onFailure(halt.failure);
|
|
14343
14476
|
}
|
|
14344
14477
|
}));
|
|
14478
|
+
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/Schedule.js
|
|
14479
|
+
const TypeId$50 = "~effect/Schedule";
|
|
14480
|
+
/**
|
|
14481
|
+
* Context reference containing metadata for the currently running schedule step.
|
|
14482
|
+
*
|
|
14483
|
+
* **Details**
|
|
14484
|
+
*
|
|
14485
|
+
* Repeat, retry, stream, and channel scheduling operations provide this service
|
|
14486
|
+
* to effects run between schedule steps. The default value contains undefined
|
|
14487
|
+
* input and output values, zero duration, and zeroed timing fields before any
|
|
14488
|
+
* schedule step has produced metadata.
|
|
14489
|
+
*
|
|
14490
|
+
* @stability stable
|
|
14491
|
+
* @category services
|
|
14492
|
+
* @since 4.0.0
|
|
14493
|
+
*/
|
|
14494
|
+
const CurrentMetadata = /*#__PURE__*/ Reference("effect/Schedule/CurrentMetadata", { defaultValue: /*#__PURE__*/ constant({
|
|
14495
|
+
input: void 0,
|
|
14496
|
+
output: void 0,
|
|
14497
|
+
duration: zero$2,
|
|
14498
|
+
attempt: 0,
|
|
14499
|
+
start: 0,
|
|
14500
|
+
now: 0,
|
|
14501
|
+
elapsed: 0,
|
|
14502
|
+
elapsedSincePrevious: 0
|
|
14503
|
+
}) });
|
|
14504
|
+
const ScheduleProto = {
|
|
14505
|
+
[TypeId$50]: {
|
|
14506
|
+
_Out: identity,
|
|
14507
|
+
_In: identity,
|
|
14508
|
+
_Env: identity
|
|
14509
|
+
},
|
|
14510
|
+
pipe() {
|
|
14511
|
+
return pipeArguments(this, arguments);
|
|
14512
|
+
}
|
|
14513
|
+
};
|
|
14514
|
+
/**
|
|
14515
|
+
* Type guard that checks if a value is a Schedule.
|
|
14516
|
+
*
|
|
14517
|
+
* **Example** (Checking for schedules)
|
|
14518
|
+
*
|
|
14519
|
+
* ```ts import.meta.vitest
|
|
14520
|
+
* import { Schedule } from "effect"
|
|
14521
|
+
*
|
|
14522
|
+
* const schedule = Schedule.exponential("100 millis")
|
|
14523
|
+
* const notSchedule = { foo: "bar" }
|
|
14524
|
+
*
|
|
14525
|
+
* Schedule.isSchedule(schedule) // => true
|
|
14526
|
+
* Schedule.isSchedule(notSchedule) // => false
|
|
14527
|
+
* Schedule.isSchedule(null) // => false
|
|
14528
|
+
* Schedule.isSchedule(undefined) // => false
|
|
14529
|
+
* ```
|
|
14530
|
+
*
|
|
14531
|
+
* @stability stable
|
|
14532
|
+
* @category guards
|
|
14533
|
+
* @since 2.0.0
|
|
14534
|
+
*/
|
|
14535
|
+
const isSchedule = (u) => hasProperty(u, TypeId$50);
|
|
14536
|
+
/**
|
|
14537
|
+
* Creates a Schedule from a step function that returns a Pull.
|
|
14538
|
+
*
|
|
14539
|
+
* **Example** (Creating a custom schedule from a step function)
|
|
14540
|
+
*
|
|
14541
|
+
* ```ts import.meta.vitest
|
|
14542
|
+
* import { Cause, Duration, Effect, Schedule } from "effect"
|
|
14543
|
+
*
|
|
14544
|
+
* const schedule = Schedule.fromStep(Effect.sync(() => {
|
|
14545
|
+
* let count = 0
|
|
14546
|
+
*
|
|
14547
|
+
* return (_now: number, _input: string) => {
|
|
14548
|
+
* if (count >= 3) {
|
|
14549
|
+
* return Cause.done(count)
|
|
14550
|
+
* }
|
|
14551
|
+
* return Effect.succeed([count++, Duration.millis(100)] as [number, Duration.Duration])
|
|
14552
|
+
* }
|
|
14553
|
+
* }))
|
|
14554
|
+
*
|
|
14555
|
+
* const program = Effect.gen(function*() {
|
|
14556
|
+
* const step = yield* Schedule.toStep(schedule)
|
|
14557
|
+
* const [output] = yield* step(0, "input")
|
|
14558
|
+
* return output
|
|
14559
|
+
* })
|
|
14560
|
+
*
|
|
14561
|
+
* await Effect.runPromise(program) // => 0
|
|
14562
|
+
* ```
|
|
14563
|
+
*
|
|
14564
|
+
* @stability stable
|
|
14565
|
+
* @category constructors
|
|
14566
|
+
* @since 4.0.0
|
|
14567
|
+
*/
|
|
14568
|
+
const fromStep = (step) => {
|
|
14569
|
+
const self = Object.create(ScheduleProto);
|
|
14570
|
+
self.step = step;
|
|
14571
|
+
return self;
|
|
14572
|
+
};
|
|
14573
|
+
const metadataFn = () => {
|
|
14574
|
+
let n = 0;
|
|
14575
|
+
let previous;
|
|
14576
|
+
let start;
|
|
14577
|
+
return (now, input) => {
|
|
14578
|
+
if (start === void 0) start = now;
|
|
14579
|
+
const elapsed = now - start;
|
|
14580
|
+
const elapsedSincePrevious = previous === void 0 ? 0 : now - previous;
|
|
14581
|
+
previous = now;
|
|
14582
|
+
return {
|
|
14583
|
+
input,
|
|
14584
|
+
attempt: ++n,
|
|
14585
|
+
start,
|
|
14586
|
+
now,
|
|
14587
|
+
elapsed,
|
|
14588
|
+
elapsedSincePrevious
|
|
14589
|
+
};
|
|
14590
|
+
};
|
|
14591
|
+
};
|
|
14592
|
+
/**
|
|
14593
|
+
* Creates a Schedule from a step function that receives metadata about the schedule's execution.
|
|
14594
|
+
*
|
|
14595
|
+
* **Example** (Creating a metadata-aware schedule)
|
|
14596
|
+
*
|
|
14597
|
+
* ```ts import.meta.vitest
|
|
14598
|
+
* import { Cause, Duration, Effect, Schedule } from "effect"
|
|
14599
|
+
*
|
|
14600
|
+
* const firstThreeInputs = Schedule.fromStepWithMetadata(Effect.succeed((metadata: Schedule.InputMetadata<string>) => {
|
|
14601
|
+
* if (metadata.attempt > 3) {
|
|
14602
|
+
* return Cause.done("finished")
|
|
14603
|
+
* }
|
|
14604
|
+
*
|
|
14605
|
+
* return Effect.succeed([
|
|
14606
|
+
* `attempt ${metadata.attempt}: ${metadata.input}`,
|
|
14607
|
+
* Duration.millis(250)
|
|
14608
|
+
* ] as [string, Duration.Duration])
|
|
14609
|
+
* }))
|
|
14610
|
+
*
|
|
14611
|
+
* const program = Effect.gen(function*() {
|
|
14612
|
+
* const step = yield* Schedule.toStep(firstThreeInputs)
|
|
14613
|
+
* const [output] = yield* step(0, "input")
|
|
14614
|
+
* return output
|
|
14615
|
+
* })
|
|
14616
|
+
*
|
|
14617
|
+
* await Effect.runPromise(program) // => "attempt 1: input"
|
|
14618
|
+
* ```
|
|
14619
|
+
*
|
|
14620
|
+
* @stability stable
|
|
14621
|
+
* @category constructors
|
|
14622
|
+
* @since 4.0.0
|
|
14623
|
+
*/
|
|
14624
|
+
const fromStepWithMetadata = (step) => fromStep(map$4(step, (f) => {
|
|
14625
|
+
const meta = metadataFn();
|
|
14626
|
+
return (now, input) => f(meta(now, input));
|
|
14627
|
+
}));
|
|
14628
|
+
/**
|
|
14629
|
+
* Extracts the step function from a Schedule.
|
|
14630
|
+
*
|
|
14631
|
+
* **Example** (Extracting a schedule step function)
|
|
14632
|
+
*
|
|
14633
|
+
* ```ts import.meta.vitest
|
|
14634
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
14635
|
+
*
|
|
14636
|
+
* // Extract step function from an existing schedule
|
|
14637
|
+
* const schedule = Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
|
|
14638
|
+
*
|
|
14639
|
+
* const program = Effect.gen(function*() {
|
|
14640
|
+
* const stepFn = yield* Schedule.toStep(schedule)
|
|
14641
|
+
*
|
|
14642
|
+
* // Use the step function directly for custom logic. The timestamp is
|
|
14643
|
+
* // supplied by the caller, so tests can pass a deterministic value.
|
|
14644
|
+
* const now = 0
|
|
14645
|
+
* return yield* stepFn(now, "input")
|
|
14646
|
+
* })
|
|
14647
|
+
*
|
|
14648
|
+
* await Effect.runPromise(program) // => [Duration.millis(100), Duration.millis(100)]
|
|
14649
|
+
* ```
|
|
14650
|
+
*
|
|
14651
|
+
* @stability stable
|
|
14652
|
+
* @category destructors
|
|
14653
|
+
* @since 4.0.0
|
|
14654
|
+
*/
|
|
14655
|
+
const toStep = (schedule) => catchCause$3(schedule.step, (cause) => succeed$8(() => failCause$6(cause)));
|
|
14656
|
+
/**
|
|
14657
|
+
* Extracts a step function from a `Schedule` that sleeps for each computed
|
|
14658
|
+
* delay and returns metadata for the completed step.
|
|
14659
|
+
*
|
|
14660
|
+
* **When to use**
|
|
14661
|
+
*
|
|
14662
|
+
* Use to drive a schedule manually while preserving the computed output,
|
|
14663
|
+
* delay, input, attempt, and elapsed timing metadata for each step.
|
|
14664
|
+
*
|
|
14665
|
+
* **Details**
|
|
14666
|
+
*
|
|
14667
|
+
* The returned step reads the current time from `Clock` when invoked, calls the
|
|
14668
|
+
* schedule step with that timestamp and input, sleeps for the returned
|
|
14669
|
+
* duration, and then yields `Metadata`.
|
|
14670
|
+
*
|
|
14671
|
+
* @see {@link toStep} for manually supplying the timestamp and handling the returned delay yourself
|
|
14672
|
+
* @see {@link toStepWithSleep} for the same automatic sleeping behavior when only the schedule output is needed
|
|
14673
|
+
*
|
|
14674
|
+
* @stability stable
|
|
14675
|
+
* @category destructors
|
|
14676
|
+
* @since 4.0.0
|
|
14677
|
+
*/
|
|
14678
|
+
const toStepWithMetadata = (schedule) => clockWith$1((clock) => map$4(toStep(schedule), (step) => {
|
|
14679
|
+
const metaFn = metadataFn();
|
|
14680
|
+
return (input) => suspend$3(() => {
|
|
14681
|
+
const now = clock.currentTimeMillisUnsafe();
|
|
14682
|
+
return flatMap$3(step(now, input), ([output, duration]) => {
|
|
14683
|
+
const meta = metaFn(now, input);
|
|
14684
|
+
meta.output = output;
|
|
14685
|
+
meta.duration = duration;
|
|
14686
|
+
return as$1(sleep$1(duration), meta);
|
|
14687
|
+
});
|
|
14688
|
+
});
|
|
14689
|
+
}));
|
|
14690
|
+
/**
|
|
14691
|
+
* Returns a new `Schedule` that outputs the inputs of the specified schedule.
|
|
14692
|
+
*
|
|
14693
|
+
* **Example** (Passing inputs through as outputs)
|
|
14694
|
+
*
|
|
14695
|
+
* ```ts import.meta.vitest
|
|
14696
|
+
* import { Effect, Schedule } from "effect"
|
|
14697
|
+
*
|
|
14698
|
+
* const inputSchedule = Schedule.passthrough(
|
|
14699
|
+
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
|
|
14700
|
+
* )
|
|
14701
|
+
* const program = Effect.gen(function*() {
|
|
14702
|
+
* const step = yield* Schedule.toStep(inputSchedule)
|
|
14703
|
+
* const [output] = yield* step(0, "input")
|
|
14704
|
+
* return output
|
|
14705
|
+
* })
|
|
14706
|
+
*
|
|
14707
|
+
* await Effect.runPromise(program) // => "input"
|
|
14708
|
+
* ```
|
|
14709
|
+
*
|
|
14710
|
+
* @stability stable
|
|
14711
|
+
* @category mapping
|
|
14712
|
+
* @since 2.0.0
|
|
14713
|
+
*/
|
|
14714
|
+
const passthrough$2 = (self) => fromStep(map$4(toStep(self), (step) => (now, input) => matchEffect$1(step(now, input), {
|
|
14715
|
+
onSuccess: (result) => succeed$8([input, result[1]]),
|
|
14716
|
+
onFailure: failCause$6,
|
|
14717
|
+
onDone: () => done(input)
|
|
14718
|
+
})));
|
|
14719
|
+
/**
|
|
14720
|
+
* Returns a schedule that recurs continuously, each repetition spaced the
|
|
14721
|
+
* specified duration from the last run.
|
|
14722
|
+
*
|
|
14723
|
+
* **When to use**
|
|
14724
|
+
*
|
|
14725
|
+
* Use when each delay should start after the previous action completes.
|
|
14726
|
+
*
|
|
14727
|
+
* **Example** (Repeating with fixed spacing)
|
|
14728
|
+
*
|
|
14729
|
+
* ```ts import.meta.vitest
|
|
14730
|
+
* import { Duration, Effect, Schedule } from "effect"
|
|
14731
|
+
*
|
|
14732
|
+
* const program = Effect.gen(function*() {
|
|
14733
|
+
* const step = yield* Schedule.toStep(Schedule.spaced("2 seconds"))
|
|
14734
|
+
* return yield* step(0, undefined)
|
|
14735
|
+
* })
|
|
14736
|
+
*
|
|
14737
|
+
* await Effect.runPromise(program) // => [0, Duration.seconds(2)]
|
|
14738
|
+
* ```
|
|
14739
|
+
*
|
|
14740
|
+
* @see {@link fixed} for recurrence aligned to a regular cadence
|
|
14741
|
+
*
|
|
14742
|
+
* @stability stable
|
|
14743
|
+
* @category constructors
|
|
14744
|
+
* @since 2.0.0
|
|
14745
|
+
*/
|
|
14746
|
+
const spaced = (duration) => {
|
|
14747
|
+
const decoded = fromInputUnsafe$1(duration);
|
|
14748
|
+
return fromStepWithMetadata(succeed$8((meta) => succeed$8([meta.attempt - 1, decoded])));
|
|
14749
|
+
};
|
|
14750
|
+
const while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map$4(toStep(self), (step) => {
|
|
14751
|
+
const meta = metadataFn();
|
|
14752
|
+
return (now, input) => flatMap$3(step(now, input), (result) => {
|
|
14753
|
+
const [output, duration] = result;
|
|
14754
|
+
const eff = predicate({
|
|
14755
|
+
...meta(now, input),
|
|
14756
|
+
output,
|
|
14757
|
+
duration
|
|
14758
|
+
});
|
|
14759
|
+
return flatMap$3(isEffect$1(eff) ? eff : succeed$8(eff), (check) => check ? succeed$8(result) : done(output));
|
|
14760
|
+
});
|
|
14761
|
+
})));
|
|
14762
|
+
/**
|
|
14763
|
+
* Returns a new `Schedule` that will recur forever.
|
|
14764
|
+
*
|
|
14765
|
+
* **Details**
|
|
14766
|
+
*
|
|
14767
|
+
* The output of the schedule is the current count of its repetitions thus far
|
|
14768
|
+
* (i.e. `0, 1, 2, ...`).
|
|
14769
|
+
*
|
|
14770
|
+
* **Example** (Repeating forever)
|
|
14771
|
+
*
|
|
14772
|
+
* ```ts import.meta.vitest
|
|
14773
|
+
* import { Effect, Schedule } from "effect"
|
|
14774
|
+
* import { TestClock } from "effect/testing"
|
|
14775
|
+
*
|
|
14776
|
+
* const executions: Array<number> = []
|
|
14777
|
+
* const schedule = Schedule.forever.pipe(Schedule.upTo({ times: 2 }))
|
|
14778
|
+
* const program = Effect.sync(() => executions.push(executions.length + 1)).pipe(
|
|
14779
|
+
* Effect.repeat(schedule),
|
|
14780
|
+
* Effect.as(executions)
|
|
14781
|
+
* )
|
|
14782
|
+
*
|
|
14783
|
+
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [1, 2, 3]
|
|
14784
|
+
* ```
|
|
14785
|
+
*
|
|
14786
|
+
* @stability stable
|
|
14787
|
+
* @category constructors
|
|
14788
|
+
* @since 2.0.0
|
|
14789
|
+
*/
|
|
14790
|
+
const forever$1 = /*#__PURE__*/ spaced(zero$2);
|
|
14345
14791
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/internal/layer.js
|
|
14346
14792
|
const provideLayer = (self, layer, options) => scopedWith$1((scope) => flatMap$3(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext$3(self, context)));
|
|
14347
14793
|
/** @internal */
|
|
14348
14794
|
const provide$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, source, options) => isContext(source) ? provideContext$3(self, source) : provideLayer(self, Array.isArray(source) ? mergeAll$1(...source) : source, options));
|
|
14795
|
+
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/internal/schedule.js
|
|
14796
|
+
/** @internal */
|
|
14797
|
+
const repeatOrElse = /*#__PURE__*/ dual(3, (self, schedule, orElse) => flatMap$3(toStepWithMetadata(schedule), (step) => {
|
|
14798
|
+
let meta = CurrentMetadata.defaultValue();
|
|
14799
|
+
const loop = (input) => matchEffect$1(step(input), {
|
|
14800
|
+
onSuccess(meta_) {
|
|
14801
|
+
meta = meta_;
|
|
14802
|
+
return flatMap$3(provideService$1(self, CurrentMetadata, meta), loop);
|
|
14803
|
+
},
|
|
14804
|
+
onFailure: failCause$6,
|
|
14805
|
+
onDone: succeed$8
|
|
14806
|
+
});
|
|
14807
|
+
return catchCauseFilter$1(flatMap$3(provideService$1(self, CurrentMetadata, meta), loop), findRecoverableError, (error) => orElse(error, meta.attempt === 0 ? none() : some(meta)));
|
|
14808
|
+
}));
|
|
14809
|
+
/** @internal */
|
|
14810
|
+
const retryOrElse = /*#__PURE__*/ dual(3, (self, policy, orElse) => flatMap$3(toStepWithMetadata(policy), (step) => {
|
|
14811
|
+
let meta = CurrentMetadata.defaultValue();
|
|
14812
|
+
let lastError;
|
|
14813
|
+
const loop = catchCauseFilter$1(suspend$3(() => provideService$1(self, CurrentMetadata, meta)), findRecoverableError, (error) => {
|
|
14814
|
+
lastError = error;
|
|
14815
|
+
return flatMap$3(step(error), (meta_) => {
|
|
14816
|
+
meta = meta_;
|
|
14817
|
+
return loop;
|
|
14818
|
+
});
|
|
14819
|
+
});
|
|
14820
|
+
return catchDone(loop, (out) => internalCall(() => orElse(lastError, out)));
|
|
14821
|
+
}));
|
|
14822
|
+
/** @internal */
|
|
14823
|
+
const repeat$1 = /*#__PURE__*/ dual(2, (self, options) => {
|
|
14824
|
+
const schedule = typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options);
|
|
14825
|
+
return repeatOrElse(self, schedule, fail$6);
|
|
14826
|
+
});
|
|
14827
|
+
/** @internal */
|
|
14828
|
+
const retry$1 = /*#__PURE__*/ dual(2, (self, options) => {
|
|
14829
|
+
const schedule = typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options);
|
|
14830
|
+
return retryOrElse(self, schedule, fail$6);
|
|
14831
|
+
});
|
|
14832
|
+
const passthroughForever = /*#__PURE__*/ passthrough$2(forever$1);
|
|
14833
|
+
/** @internal */
|
|
14834
|
+
const buildFromOptions = (options) => {
|
|
14835
|
+
let schedule = options.schedule ? passthrough$2(options.schedule) : passthroughForever;
|
|
14836
|
+
if (options.while) schedule = while_(schedule, ({ input }) => {
|
|
14837
|
+
const applied = options.while(input);
|
|
14838
|
+
return isEffect$1(applied) ? applied : succeed$8(applied);
|
|
14839
|
+
});
|
|
14840
|
+
if (options.until) schedule = while_(schedule, ({ input }) => {
|
|
14841
|
+
const applied = options.until(input);
|
|
14842
|
+
return isEffect$1(applied) ? map$4(applied, (b) => !b) : succeed$8(!applied);
|
|
14843
|
+
});
|
|
14844
|
+
if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$8(attempt <= options.times));
|
|
14845
|
+
return schedule;
|
|
14846
|
+
};
|
|
14349
14847
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/MutableHashMap.js
|
|
14350
14848
|
const TypeId$49 = "~effect/MutableHashMap";
|
|
14351
14849
|
const MutableHashMapProto = {
|
|
@@ -14441,7 +14939,7 @@ const empty$9 = () => {
|
|
|
14441
14939
|
* @since 2.0.0
|
|
14442
14940
|
*/
|
|
14443
14941
|
const get$7 = /*#__PURE__*/ dual(2, (self, key) => {
|
|
14444
|
-
if (self.backing.has(key)) return some
|
|
14942
|
+
if (self.backing.has(key)) return some(self.backing.get(key));
|
|
14445
14943
|
else if (isSimpleKey(key)) return none();
|
|
14446
14944
|
const hash$3 = hash(key);
|
|
14447
14945
|
const bucket = self.buckets.get(hash$3);
|
|
@@ -14452,7 +14950,7 @@ const isSimpleKey = (u) => typeof u !== "object" && typeof u !== "function";
|
|
|
14452
14950
|
const getFromBucket = (self, bucket, key) => {
|
|
14453
14951
|
for (let i = 0, len = bucket.length; i < len; i++) if (equals$1(key, bucket[i])) {
|
|
14454
14952
|
const refKey = bucket[i];
|
|
14455
|
-
return some
|
|
14953
|
+
return some(self.backing.get(refKey));
|
|
14456
14954
|
}
|
|
14457
14955
|
return none();
|
|
14458
14956
|
};
|
|
@@ -14561,7 +15059,7 @@ const getRefKey = (bucket, key) => {
|
|
|
14561
15059
|
* @category mutations
|
|
14562
15060
|
* @since 2.0.0
|
|
14563
15061
|
*/
|
|
14564
|
-
const remove$
|
|
15062
|
+
const remove$5 = /*#__PURE__*/ dual(2, (self, key_) => {
|
|
14565
15063
|
if (isSimpleKey(key_)) {
|
|
14566
15064
|
self.backing.delete(key_);
|
|
14567
15065
|
return self;
|
|
@@ -16483,6 +16981,61 @@ const orDie$2 = orDie$3;
|
|
|
16483
16981
|
*/
|
|
16484
16982
|
const tapCause = tapCause$1;
|
|
16485
16983
|
/**
|
|
16984
|
+
* Retries typed failures from an effect according to a retry policy.
|
|
16985
|
+
*
|
|
16986
|
+
* **When to use**
|
|
16987
|
+
*
|
|
16988
|
+
* Use when you need to rerun an effect after transient typed failures, such as
|
|
16989
|
+
* network issues or temporary resource unavailability.
|
|
16990
|
+
*
|
|
16991
|
+
* **Details**
|
|
16992
|
+
*
|
|
16993
|
+
* The policy can be a `Schedule`, a schedule builder, or a `Retry.Options`
|
|
16994
|
+
* object using `schedule`, `times`, `while`, or `until`. If a retry eventually
|
|
16995
|
+
* succeeds, the returned effect succeeds with that value. If the policy stops
|
|
16996
|
+
* while the effect is still failing, the last failure is propagated.
|
|
16997
|
+
*
|
|
16998
|
+
* **Gotchas**
|
|
16999
|
+
*
|
|
17000
|
+
* The source effect is always evaluated once before any retry policy is
|
|
17001
|
+
* applied. For example, `Schedule.recurs(3)` allows up to three retries after
|
|
17002
|
+
* the initial attempt.
|
|
17003
|
+
*
|
|
17004
|
+
* Defects take precedence over typed errors. A failure whose cause contains a
|
|
17005
|
+
* defect is not retried and is propagated with every typed error converted to a
|
|
17006
|
+
* defect. A typed error alongside an interruption is retried.
|
|
17007
|
+
*
|
|
17008
|
+
* **Example** (Retrying with a schedule)
|
|
17009
|
+
*
|
|
17010
|
+
* ```ts import.meta.vitest
|
|
17011
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
17012
|
+
*
|
|
17013
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
17014
|
+
*
|
|
17015
|
+
* let attempt = 0
|
|
17016
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
17017
|
+
* attempt++
|
|
17018
|
+
* if (attempt <= 2) {
|
|
17019
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
17020
|
+
* } else {
|
|
17021
|
+
* resume(Effect.succeed("Success!"))
|
|
17022
|
+
* }
|
|
17023
|
+
* })
|
|
17024
|
+
*
|
|
17025
|
+
* const policy = Schedule.recurs(5)
|
|
17026
|
+
* const program = Effect.retry(task, policy)
|
|
17027
|
+
*
|
|
17028
|
+
* await Effect.runPromise(program) // => "Success!"
|
|
17029
|
+
* ```
|
|
17030
|
+
*
|
|
17031
|
+
* @see {@link retryOrElse} for a version that allows you to run a fallback.
|
|
17032
|
+
* @see {@link repeat} if your retry condition is based on successful outcomes rather than errors.
|
|
17033
|
+
* @stability stable
|
|
17034
|
+
* @category error handling
|
|
17035
|
+
* @since 2.0.0
|
|
17036
|
+
*/
|
|
17037
|
+
const retry = retry$1;
|
|
17038
|
+
/**
|
|
16486
17039
|
* Discards both the success and failure values of an effect.
|
|
16487
17040
|
*
|
|
16488
17041
|
* **When to use**
|
|
@@ -16747,6 +17300,38 @@ const race = race$1;
|
|
|
16747
17300
|
*/
|
|
16748
17301
|
const raceFirst = raceFirst$1;
|
|
16749
17302
|
/**
|
|
17303
|
+
* Filters an effect, failing with a custom error if the predicate fails.
|
|
17304
|
+
*
|
|
17305
|
+
* **Details**
|
|
17306
|
+
*
|
|
17307
|
+
* This function applies a predicate to the result of an effect. If the
|
|
17308
|
+
* predicate evaluates to `false`, the effect fails with either a custom
|
|
17309
|
+
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
17310
|
+
*
|
|
17311
|
+
* **Example** (Filtering with a custom failure)
|
|
17312
|
+
*
|
|
17313
|
+
* ```ts import.meta.vitest
|
|
17314
|
+
* import { Effect } from "effect"
|
|
17315
|
+
*
|
|
17316
|
+
* // An effect that produces a number
|
|
17317
|
+
* const program = Effect.succeed(5)
|
|
17318
|
+
*
|
|
17319
|
+
* // Filter for even numbers, fail for odd numbers
|
|
17320
|
+
* const filtered = Effect.filterOrFail(
|
|
17321
|
+
* program,
|
|
17322
|
+
* (n) => n % 2 === 0,
|
|
17323
|
+
* (n) => `Expected even number, got ${n}`
|
|
17324
|
+
* )
|
|
17325
|
+
*
|
|
17326
|
+
* Effect.runSync(Effect.flip(filtered)) // => "Expected even number, got 5"
|
|
17327
|
+
* ```
|
|
17328
|
+
*
|
|
17329
|
+
* @stability stable
|
|
17330
|
+
* @category filtering
|
|
17331
|
+
* @since 2.0.0
|
|
17332
|
+
*/
|
|
17333
|
+
const filterOrFail = filterOrFail$1;
|
|
17334
|
+
/**
|
|
16750
17335
|
* Runs an effect conditionally based on the result of an effectful boolean
|
|
16751
17336
|
* condition.
|
|
16752
17337
|
*
|
|
@@ -17804,7 +18389,93 @@ const uninterruptibleMask = uninterruptibleMask$1;
|
|
|
17804
18389
|
* @category repetition
|
|
17805
18390
|
* @since 2.0.0
|
|
17806
18391
|
*/
|
|
17807
|
-
const forever = forever$
|
|
18392
|
+
const forever = forever$2;
|
|
18393
|
+
/**
|
|
18394
|
+
* Repeats an effect based on a specified schedule or until the first failure.
|
|
18395
|
+
*
|
|
18396
|
+
* **When to use**
|
|
18397
|
+
*
|
|
18398
|
+
* Use to rerun an effect after successful executions.
|
|
18399
|
+
*
|
|
18400
|
+
* **Details**
|
|
18401
|
+
*
|
|
18402
|
+
* This function executes an effect repeatedly according to the given schedule.
|
|
18403
|
+
* Each repetition occurs after the initial execution of the effect, meaning
|
|
18404
|
+
* that the schedule determines the number of additional repetitions. For
|
|
18405
|
+
* example, using `Schedule.once` will result in the effect being executed twice
|
|
18406
|
+
* (once initially and once as part of the repetition).
|
|
18407
|
+
*
|
|
18408
|
+
* If the effect succeeds, it is repeated according to the schedule. If it
|
|
18409
|
+
* fails, the repetition stops immediately, and the failure is returned.
|
|
18410
|
+
*
|
|
18411
|
+
* The schedule can also specify delays between repetitions, making it useful
|
|
18412
|
+
* for tasks like retrying operations with backoff, periodic execution, or
|
|
18413
|
+
* performing a series of dependent actions.
|
|
18414
|
+
*
|
|
18415
|
+
* You can combine schedules for more advanced repetition logic, such as adding
|
|
18416
|
+
* delays, limiting recursions, or dynamically adjusting based on the outcome of
|
|
18417
|
+
* each execution.
|
|
18418
|
+
*
|
|
18419
|
+
* **Gotchas**
|
|
18420
|
+
*
|
|
18421
|
+
* The source effect is always evaluated once before the schedule is stepped.
|
|
18422
|
+
* The schedule controls additional repetitions, not the initial execution.
|
|
18423
|
+
*
|
|
18424
|
+
* If the effect or policy fails with a cause that contains a defect, the
|
|
18425
|
+
* failure is propagated with every typed error converted to a defect.
|
|
18426
|
+
* An interruption alongside a typed error does not block the typed error path.
|
|
18427
|
+
*
|
|
18428
|
+
* **Example** (Repeating successful effects with a schedule)
|
|
18429
|
+
*
|
|
18430
|
+
* ```ts import.meta.vitest
|
|
18431
|
+
* // Success Example
|
|
18432
|
+
* import { Effect, Schedule } from "effect"
|
|
18433
|
+
* const output: Array<unknown> = []
|
|
18434
|
+
*
|
|
18435
|
+
* const action = Effect.sync(() => { output.push("success") })
|
|
18436
|
+
* const policy = Schedule.recurs(2)
|
|
18437
|
+
* const program = Effect.repeat(action, policy)
|
|
18438
|
+
*
|
|
18439
|
+
* void output.push(Effect.runSync(program))
|
|
18440
|
+
* output // => ["success", "success", "success", 2]
|
|
18441
|
+
* ```
|
|
18442
|
+
*
|
|
18443
|
+
* **Example** (Stopping repetition on failure)
|
|
18444
|
+
*
|
|
18445
|
+
* ```ts import.meta.vitest
|
|
18446
|
+
* // Failure Example
|
|
18447
|
+
* import { Effect, Schedule } from "effect"
|
|
18448
|
+
* const output: Array<unknown> = []
|
|
18449
|
+
*
|
|
18450
|
+
* let count = 0
|
|
18451
|
+
*
|
|
18452
|
+
* // Define a callback effect that simulates an action with possible failures
|
|
18453
|
+
* const action = Effect.callback<string, string>((resume) => {
|
|
18454
|
+
* if (count > 1) {
|
|
18455
|
+
* void output.push("failure")
|
|
18456
|
+
* resume(Effect.fail("Uh oh!"))
|
|
18457
|
+
* } else {
|
|
18458
|
+
* count++
|
|
18459
|
+
* void output.push("success")
|
|
18460
|
+
* resume(Effect.succeed("yay!"))
|
|
18461
|
+
* }
|
|
18462
|
+
* })
|
|
18463
|
+
*
|
|
18464
|
+
* const policy = Schedule.recurs(2)
|
|
18465
|
+
* const program = Effect.repeat(action, policy)
|
|
18466
|
+
*
|
|
18467
|
+
* void output.push((await Effect.runPromiseExit(program))._tag)
|
|
18468
|
+
* output // => ["success", "success", "failure", "Failure"]
|
|
18469
|
+
* ```
|
|
18470
|
+
*
|
|
18471
|
+
* @see {@link retry} for failure-based repetition
|
|
18472
|
+
* @see {@link repeatOrElse} for fallback handling when repetition fails
|
|
18473
|
+
*
|
|
18474
|
+
* @stability stable
|
|
18475
|
+
* @category repetition
|
|
18476
|
+
* @since 2.0.0
|
|
18477
|
+
*/
|
|
18478
|
+
const repeat = repeat$1;
|
|
17808
18479
|
/**
|
|
17809
18480
|
* Adds an annotation to the current span if available.
|
|
17810
18481
|
*
|
|
@@ -19646,7 +20317,7 @@ const BigInt$4 = globalThis.BigInt;
|
|
|
19646
20317
|
*/
|
|
19647
20318
|
const toNumber = (b) => {
|
|
19648
20319
|
if (b > BigInt$4(Number.MAX_SAFE_INTEGER) || b < BigInt$4(Number.MIN_SAFE_INTEGER)) return none();
|
|
19649
|
-
return some
|
|
20320
|
+
return some(Number(b));
|
|
19650
20321
|
};
|
|
19651
20322
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/ByteSize.js
|
|
19652
20323
|
const bigint0$1 = /*#__PURE__*/ BigInt(0);
|
|
@@ -20816,7 +21487,7 @@ const filter = (self, f) => {
|
|
|
20816
21487
|
* @category mutations
|
|
20817
21488
|
* @since 4.0.0
|
|
20818
21489
|
*/
|
|
20819
|
-
const remove$
|
|
21490
|
+
const remove$4 = (self, value) => filter(self, (v) => v !== value);
|
|
20820
21491
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/PubSub.js
|
|
20821
21492
|
const TypeId$44 = "~effect/PubSub";
|
|
20822
21493
|
const SubscriptionTypeId = "~effect/PubSub/Subscription";
|
|
@@ -21096,7 +21767,7 @@ const pollForItem = (self) => callback$1((resume) => {
|
|
|
21096
21767
|
self.strategy.completePollersUnsafe(self.pubsub, self.subscribers, self.subscription, self.pollers);
|
|
21097
21768
|
if (deferred.effect) return resume(deferred.effect);
|
|
21098
21769
|
deferred.resumes = [resume];
|
|
21099
|
-
return sync(() => remove$
|
|
21770
|
+
return sync(() => remove$4(self.pollers, deferred));
|
|
21100
21771
|
});
|
|
21101
21772
|
const AbsentValue = /*#__PURE__*/ Symbol.for("effect/PubSub/AbsentValue");
|
|
21102
21773
|
const addSubscribers = (subscribers, subscription, pollers) => {
|
|
@@ -22299,7 +22970,7 @@ const take = (self) => suspendTake(() => takeUnsafe(self) ?? andThen$1(awaitTake
|
|
|
22299
22970
|
const poll = (self) => suspendTake(() => {
|
|
22300
22971
|
const result = takeUnsafe(self);
|
|
22301
22972
|
if (result === void 0) return succeed$8(none());
|
|
22302
|
-
if (result._tag === "Success") return succeed$8(some
|
|
22973
|
+
if (result._tag === "Success") return succeed$8(some(result.value));
|
|
22303
22974
|
return succeed$8(none());
|
|
22304
22975
|
});
|
|
22305
22976
|
/**
|
|
@@ -23520,19 +24191,6 @@ const catchCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$1
|
|
|
23520
24191
|
}));
|
|
23521
24192
|
const catch_$1 = /*#__PURE__*/ dual(2, (self, f) => catchCauseFilter(self, findRecoverableError, (e) => f(e)));
|
|
23522
24193
|
/**
|
|
23523
|
-
* Transforms the typed errors of a channel using the specified function.
|
|
23524
|
-
*
|
|
23525
|
-
* **Details**
|
|
23526
|
-
*
|
|
23527
|
-
* Maps every typed error in the cause, preserving defects, interrupts and
|
|
23528
|
-
* reason order. Unlike typed recovery, mapping does not convert errors to defects.
|
|
23529
|
-
*
|
|
23530
|
-
* @stability stable
|
|
23531
|
-
* @category error handling
|
|
23532
|
-
* @since 2.0.0
|
|
23533
|
-
*/
|
|
23534
|
-
const mapError$1 = /*#__PURE__*/ dual(2, (self, f) => transformPull$1(self, (pull) => succeed$4(mapError$2(pull, (err) => isDone(err) ? err : f(err)))));
|
|
23535
|
-
/**
|
|
23536
24194
|
* Converts all errors in the channel to defects (unrecoverable failures).
|
|
23537
24195
|
* This is useful when you want to treat errors as programming errors.
|
|
23538
24196
|
*
|
|
@@ -23772,7 +24430,7 @@ const splitLines$1 = () => fromTransform$1((upstream, _scope) => sync(() => {
|
|
|
23772
24430
|
onSuccess: loop,
|
|
23773
24431
|
onFailure: failCause$3,
|
|
23774
24432
|
onDone: (leftover) => {
|
|
23775
|
-
done$13 = some
|
|
24433
|
+
done$13 = some(leftover);
|
|
23776
24434
|
if (stringBuilder.length > 0) {
|
|
23777
24435
|
const last = stringBuilder;
|
|
23778
24436
|
stringBuilder = "";
|
|
@@ -24036,51 +24694,6 @@ const provideContext$1 = /*#__PURE__*/ dual(2, (self, context) => fromTransform$
|
|
|
24036
24694
|
*/
|
|
24037
24695
|
const runForEach$1 = /*#__PURE__*/ dual(2, (self, f) => runWith(self, (pull) => forever(flatMap$1(pull, f), { disableYield: true })));
|
|
24038
24696
|
/**
|
|
24039
|
-
* Concatenates a channel's `Uint8Array` chunks into a single `Uint8Array`.
|
|
24040
|
-
*
|
|
24041
|
-
* **Gotchas**
|
|
24042
|
-
*
|
|
24043
|
-
* This materializes the full content in memory. The source channel must not
|
|
24044
|
-
* reuse or mutate emitted buffers, which are retained until collection completes.
|
|
24045
|
-
*
|
|
24046
|
-
* **Example** (Joining channel byte chunks)
|
|
24047
|
-
*
|
|
24048
|
-
* ```ts import.meta.vitest
|
|
24049
|
-
* import { Channel, Effect } from "effect"
|
|
24050
|
-
*
|
|
24051
|
-
* const channel = Channel.fromArray([
|
|
24052
|
-
* [new Uint8Array([1, 2])],
|
|
24053
|
-
* [new Uint8Array([3, 4])]
|
|
24054
|
-
* ] as const)
|
|
24055
|
-
*
|
|
24056
|
-
* const bytes = Effect.runSync(Channel.mkUint8Array(channel))
|
|
24057
|
-
* Array.from(bytes) // => [1, 2, 3, 4]
|
|
24058
|
-
* ```
|
|
24059
|
-
*
|
|
24060
|
-
* @stability stable
|
|
24061
|
-
* @category running
|
|
24062
|
-
* @since 4.0.0
|
|
24063
|
-
*/
|
|
24064
|
-
const mkUint8Array$1 = (self) => map$2(runFold(self, () => ({
|
|
24065
|
-
bytes: 0,
|
|
24066
|
-
arrays: []
|
|
24067
|
-
}), (acc, chunk) => {
|
|
24068
|
-
for (let i = 0; i < chunk.length; i++) {
|
|
24069
|
-
acc.bytes += chunk[i].length;
|
|
24070
|
-
acc.arrays.push(chunk[i]);
|
|
24071
|
-
}
|
|
24072
|
-
return acc;
|
|
24073
|
-
}), ({ arrays, bytes }) => {
|
|
24074
|
-
const result = new Uint8Array(bytes);
|
|
24075
|
-
let offset = 0;
|
|
24076
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
24077
|
-
const array = arrays[i];
|
|
24078
|
-
result.set(array, offset);
|
|
24079
|
-
offset += array.length;
|
|
24080
|
-
}
|
|
24081
|
-
return result;
|
|
24082
|
-
});
|
|
24083
|
-
/**
|
|
24084
24697
|
* Runs a channel to completion and returns the last output element in an
|
|
24085
24698
|
* `Option`.
|
|
24086
24699
|
*
|
|
@@ -24564,7 +25177,7 @@ const removeInterrupted = (self, key, entry, context) => {
|
|
|
24564
25177
|
if (self.state._tag === "Closed") return;
|
|
24565
25178
|
const o = get$7(self.state.map, key);
|
|
24566
25179
|
if (o._tag === "None" || o.value !== entry) return;
|
|
24567
|
-
remove$
|
|
25180
|
+
remove$5(self.state.map, key);
|
|
24568
25181
|
if (entry.refCount > 0) return;
|
|
24569
25182
|
closeEntry(entry).pipe(runForkWith(context), runIn(self.scope));
|
|
24570
25183
|
};
|
|
@@ -24576,7 +25189,7 @@ const release$1 = (self, key, entry) => withFiber((fiber) => {
|
|
|
24576
25189
|
const o = get$7(self.state.map, key);
|
|
24577
25190
|
if (o._tag === "None" || o.value !== entry) return closeEntry(entry);
|
|
24578
25191
|
else if (isZero$1(entry.idleTimeToLive)) {
|
|
24579
|
-
remove$
|
|
25192
|
+
remove$5(self.state.map, key);
|
|
24580
25193
|
return closeEntry(entry);
|
|
24581
25194
|
} else if (!isFinite$1(entry.idleTimeToLive)) return void_$1;
|
|
24582
25195
|
const clock = fiber.getRef(Clock);
|
|
@@ -24589,7 +25202,7 @@ const release$1 = (self, key, entry) => withFiber((fiber) => {
|
|
|
24589
25202
|
if (self.state._tag === "Closed" || entry.refCount > 0) return void_$1;
|
|
24590
25203
|
const o = get$7(self.state.map, key);
|
|
24591
25204
|
if (o._tag === "None" || o.value !== entry) return void_$1;
|
|
24592
|
-
remove$
|
|
25205
|
+
remove$5(self.state.map, key);
|
|
24593
25206
|
return close(entry.scope, void_$2);
|
|
24594
25207
|
}
|
|
24595
25208
|
return flatMap$1(restore(clock.sleep(millis(remaining))), () => loop(restore));
|
|
@@ -25451,36 +26064,6 @@ const merge$1 = /*#__PURE__*/ dual((args) => isStream(args[0]) && isStream(args[
|
|
|
25451
26064
|
const catchCause = /*#__PURE__*/ dual(2, (self, f) => self.channel.pipe(catchCause$1((cause) => f(cause).channel), fromChannel));
|
|
25452
26065
|
const catch_ = /*#__PURE__*/ dual(2, (self, f) => fromChannel(catch_$1(self.channel, (error) => f(error).channel)));
|
|
25453
26066
|
/**
|
|
25454
|
-
* Transforms the errors emitted by this stream using `f`.
|
|
25455
|
-
*
|
|
25456
|
-
* **Details**
|
|
25457
|
-
*
|
|
25458
|
-
* Maps every typed error in the cause, preserving defects, interrupts and
|
|
25459
|
-
* reason order. Unlike typed recovery, mapping does not convert errors to defects.
|
|
25460
|
-
*
|
|
25461
|
-
* **Example** (Mapping stream errors)
|
|
25462
|
-
*
|
|
25463
|
-
* ```ts import.meta.vitest
|
|
25464
|
-
* import { Effect, Stream } from "effect"
|
|
25465
|
-
*
|
|
25466
|
-
* const program = Effect.gen(function*() {
|
|
25467
|
-
* const result = yield* Stream.fail("bad").pipe(
|
|
25468
|
-
* Stream.mapError((error) => `mapped: ${error}`),
|
|
25469
|
-
* Stream.catch((error) => Stream.make(`recovered from ${error}`)),
|
|
25470
|
-
* Stream.runCollect
|
|
25471
|
-
* )
|
|
25472
|
-
* result // => [ 'recovered from mapped: bad' ]
|
|
25473
|
-
* })
|
|
25474
|
-
*
|
|
25475
|
-
* await Effect.runPromise(program)
|
|
25476
|
-
* ```
|
|
25477
|
-
*
|
|
25478
|
-
* @stability stable
|
|
25479
|
-
* @category error handling
|
|
25480
|
-
* @since 2.0.0
|
|
25481
|
-
*/
|
|
25482
|
-
const mapError = /*#__PURE__*/ dual(2, (self, f) => fromChannel(mapError$1(self.channel, f)));
|
|
25483
|
-
/**
|
|
25484
26067
|
* Turns typed failures into defects, making the stream infallible.
|
|
25485
26068
|
*
|
|
25486
26069
|
* **Example** (Turning failures into defects)
|
|
@@ -25591,42 +26174,6 @@ const transduce = /*#__PURE__*/ dual(2, (self, sink) => transformPull(self, (ups
|
|
|
25591
26174
|
return suspend$2(() => done$10 ? done$10 : pull);
|
|
25592
26175
|
})));
|
|
25593
26176
|
/**
|
|
25594
|
-
* Pipes this stream through a channel that consumes and emits chunked elements.
|
|
25595
|
-
*
|
|
25596
|
-
* **Details**
|
|
25597
|
-
*
|
|
25598
|
-
* The channel receives `NonEmptyReadonlyArray` chunks and can transform both the
|
|
25599
|
-
* output elements and error type.
|
|
25600
|
-
*
|
|
25601
|
-
* **Example** (Piping through a channel)
|
|
25602
|
-
*
|
|
25603
|
-
* ```ts import.meta.vitest
|
|
25604
|
-
* import { Array, Channel, Effect, Stream } from "effect"
|
|
25605
|
-
*
|
|
25606
|
-
* type NumberChunk = readonly [number, ...Array<number>]
|
|
25607
|
-
*
|
|
25608
|
-
* const doubleChunks = Channel.identity<NumberChunk, never, unknown>().pipe(
|
|
25609
|
-
* Channel.map((chunk) => Array.map(chunk, (n) => n * 2))
|
|
25610
|
-
* )
|
|
25611
|
-
*
|
|
25612
|
-
* const program = Effect.gen(function*() {
|
|
25613
|
-
* const result = yield* Stream.fromArray([1, 2, 3]).pipe(
|
|
25614
|
-
* Stream.rechunk(2),
|
|
25615
|
-
* Stream.pipeThroughChannel(doubleChunks),
|
|
25616
|
-
* Stream.runCollect
|
|
25617
|
-
* )
|
|
25618
|
-
* result // => [ 2, 4, 6 ]
|
|
25619
|
-
* })
|
|
25620
|
-
*
|
|
25621
|
-
* await Effect.runPromise(program)
|
|
25622
|
-
* ```
|
|
25623
|
-
*
|
|
25624
|
-
* @stability stable
|
|
25625
|
-
* @category sequencing
|
|
25626
|
-
* @since 2.0.0
|
|
25627
|
-
*/
|
|
25628
|
-
const pipeThroughChannel = /*#__PURE__*/ dual(2, (self, channel) => fromChannel(pipeTo$1(self.channel, channel)));
|
|
25629
|
-
/**
|
|
25630
26177
|
* Pipes values through the provided channel while preserving this stream's
|
|
25631
26178
|
* failures alongside any channel failures.
|
|
25632
26179
|
*
|
|
@@ -25965,33 +26512,6 @@ const runForEachArray = /*#__PURE__*/ dual(2, (self, f) => runForEach$1(self.cha
|
|
|
25965
26512
|
*/
|
|
25966
26513
|
const mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join(""));
|
|
25967
26514
|
/**
|
|
25968
|
-
* Concatenates the stream's `Uint8Array` chunks into a single `Uint8Array`.
|
|
25969
|
-
*
|
|
25970
|
-
* **Gotchas**
|
|
25971
|
-
*
|
|
25972
|
-
* This materializes the full content in memory. The source stream must not
|
|
25973
|
-
* reuse or mutate emitted buffers, which are retained until collection completes.
|
|
25974
|
-
*
|
|
25975
|
-
* **Example** (Joining Uint8Array chunks)
|
|
25976
|
-
*
|
|
25977
|
-
* ```ts import.meta.vitest
|
|
25978
|
-
* import { Effect, Stream } from "effect"
|
|
25979
|
-
*
|
|
25980
|
-
* const stream = Stream.make(new Uint8Array([1, 2]), new Uint8Array([3, 4]))
|
|
25981
|
-
* const program = Effect.gen(function*() {
|
|
25982
|
-
* const bytes = yield* Stream.mkUint8Array(stream)
|
|
25983
|
-
* const values = Array.from(bytes) // => [1, 2, 3, 4]
|
|
25984
|
-
* })
|
|
25985
|
-
*
|
|
25986
|
-
* await Effect.runPromise(program)
|
|
25987
|
-
* ```
|
|
25988
|
-
*
|
|
25989
|
-
* @stability stable
|
|
25990
|
-
* @category destructors
|
|
25991
|
-
* @since 4.0.0
|
|
25992
|
-
*/
|
|
25993
|
-
const mkUint8Array = (self) => mkUint8Array$1(self.channel);
|
|
25994
|
-
/**
|
|
25995
26515
|
* Converts the stream to a `ReadableStream` using the provided services.
|
|
25996
26516
|
*
|
|
25997
26517
|
* **When to use**
|
|
@@ -26196,7 +26716,7 @@ const make$55 = (impl) => FileSystem.of({
|
|
|
26196
26716
|
return fromPull(succeed$4(flatMap$1(suspend$2(() => {
|
|
26197
26717
|
if (bytesToRead !== void 0 && bytesToRead <= totalBytesRead) return done();
|
|
26198
26718
|
return bytesToRead !== void 0 && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk;
|
|
26199
|
-
}), match$
|
|
26719
|
+
}), match$6({
|
|
26200
26720
|
onNone: () => done(),
|
|
26201
26721
|
onSome: (buf) => {
|
|
26202
26722
|
totalBytesRead += BigInt(buf.length);
|
|
@@ -26401,7 +26921,7 @@ const make$54 = (impl) => Path$1.of({
|
|
|
26401
26921
|
const base = impl.resolve(root);
|
|
26402
26922
|
const candidate = impl.resolve(base, input);
|
|
26403
26923
|
const relative = impl.relative(base, candidate);
|
|
26404
|
-
return relative === ".." || relative.startsWith(`..${impl.sep}`) || impl.isAbsolute(relative) ? none() : some
|
|
26924
|
+
return relative === ".." || relative.startsWith(`..${impl.sep}`) || impl.isAbsolute(relative) ? none() : some(candidate);
|
|
26405
26925
|
}
|
|
26406
26926
|
});
|
|
26407
26927
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/internal/schema/annotations.js
|
|
@@ -26472,7 +26992,7 @@ const missingExit = /*#__PURE__*/ succeed$1(missing);
|
|
|
26472
26992
|
/** @internal */
|
|
26473
26993
|
const sameExit = /*#__PURE__*/ succeed$1(missing);
|
|
26474
26994
|
/** @internal */
|
|
26475
|
-
const toOption = (value) => value === missing ? none() : some
|
|
26995
|
+
const toOption = (value) => value === missing ? none() : some(value);
|
|
26476
26996
|
/** @internal */
|
|
26477
26997
|
const fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed$1(option.value);
|
|
26478
26998
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/SchemaIssue.js
|
|
@@ -27638,7 +28158,7 @@ function omit$1() {
|
|
|
27638
28158
|
function withDefault$2(defaultValue) {
|
|
27639
28159
|
return transformOptionalEffect((o) => {
|
|
27640
28160
|
const filtered = filter$3(o, isNotUndefined);
|
|
27641
|
-
return isSome(filtered) ? succeed$4(filtered) : mapEager(defaultValue, some
|
|
28161
|
+
return isSome(filtered) ? succeed$4(filtered) : mapEager(defaultValue, some);
|
|
27642
28162
|
});
|
|
27643
28163
|
}
|
|
27644
28164
|
/**
|
|
@@ -30828,7 +31348,7 @@ const unknownToStringTree = /*#__PURE__*/ new Link(/* @__PURE__ */ new Declarati
|
|
|
30828
31348
|
*/
|
|
30829
31349
|
function nominal() {
|
|
30830
31350
|
return Object.assign((input) => input, {
|
|
30831
|
-
option: (input) => some
|
|
31351
|
+
option: (input) => some(input),
|
|
30832
31352
|
result: (input) => succeed$9(input),
|
|
30833
31353
|
is: (_) => true
|
|
30834
31354
|
});
|
|
@@ -32787,28 +33307,12 @@ const merge = /*#__PURE__*/ dual(2, (self, headers) => {
|
|
|
32787
33307
|
* @category combinators
|
|
32788
33308
|
* @since 4.0.0
|
|
32789
33309
|
*/
|
|
32790
|
-
const remove$
|
|
33310
|
+
const remove$3 = /*#__PURE__*/ dual(2, (self, key) => {
|
|
32791
33311
|
const out = make$46(self);
|
|
32792
33312
|
delete out[key.toLowerCase()];
|
|
32793
33313
|
return out;
|
|
32794
33314
|
});
|
|
32795
33315
|
/**
|
|
32796
|
-
* Returns a new `Headers` collection with each named header removed.
|
|
32797
|
-
*
|
|
32798
|
-
* **Details**
|
|
32799
|
-
*
|
|
32800
|
-
* Each provided header name is normalized to lowercase before removal.
|
|
32801
|
-
*
|
|
32802
|
-
* @stability unstable
|
|
32803
|
-
* @category combinators
|
|
32804
|
-
* @since 4.0.0
|
|
32805
|
-
*/
|
|
32806
|
-
const removeMany = /*#__PURE__*/ dual(2, (self, keys) => {
|
|
32807
|
-
const out = make$46(self);
|
|
32808
|
-
for (const key of keys) delete out[key.toLowerCase()];
|
|
32809
|
-
return out;
|
|
32810
|
-
});
|
|
32811
|
-
/**
|
|
32812
33316
|
* Returns a plain record with selected header values wrapped in `Redacted`.
|
|
32813
33317
|
*
|
|
32814
33318
|
* **Details**
|
|
@@ -33099,7 +33603,7 @@ var LeafNode = class LeafNode extends Node {
|
|
|
33099
33603
|
return 1;
|
|
33100
33604
|
}
|
|
33101
33605
|
get(_shift, hash, key) {
|
|
33102
|
-
if (this.hash === hash && equals$1(this.key, key)) return some
|
|
33606
|
+
if (this.hash === hash && equals$1(this.key, key)) return some(this.value);
|
|
33103
33607
|
return none();
|
|
33104
33608
|
}
|
|
33105
33609
|
has(_shift, hash, key) {
|
|
@@ -33150,7 +33654,7 @@ var CollisionNode = class CollisionNode extends Node {
|
|
|
33150
33654
|
}
|
|
33151
33655
|
get(_shift, hash, key) {
|
|
33152
33656
|
if (this.hash !== hash) return none();
|
|
33153
|
-
for (const [k, v] of this.entries) if (equals$1(k, key)) return some
|
|
33657
|
+
for (const [k, v] of this.entries) if (equals$1(k, key)) return some(v);
|
|
33154
33658
|
return none();
|
|
33155
33659
|
}
|
|
33156
33660
|
has(_shift, hash, key) {
|
|
@@ -33557,6 +34061,24 @@ const keys = (self) => new HashMapIterator(self._root, identity);
|
|
|
33557
34061
|
const values$1 = (self) => new HashMapIterator(self._root, toValue);
|
|
33558
34062
|
/** @internal */
|
|
33559
34063
|
const size$1 = (self) => self.size;
|
|
34064
|
+
const removeHash = (self, key, hash) => {
|
|
34065
|
+
const impl = self;
|
|
34066
|
+
const removed = { value: false };
|
|
34067
|
+
const edit = impl._editable ? impl._edit : NaN;
|
|
34068
|
+
const newRoot = impl._root.remove(edit, 0, hash, key, removed);
|
|
34069
|
+
if (!removed.value) return self;
|
|
34070
|
+
if (impl._editable) {
|
|
34071
|
+
impl._root = newRoot ?? emptyNode;
|
|
34072
|
+
impl._size--;
|
|
34073
|
+
return self;
|
|
34074
|
+
}
|
|
34075
|
+
if (newRoot === void 0) return empty$4();
|
|
34076
|
+
return new HashMapImpl(false, impl._edit, newRoot, impl._size - 1);
|
|
34077
|
+
};
|
|
34078
|
+
/** @internal */
|
|
34079
|
+
const remove$2 = /*#__PURE__*/ dual(2, (self, key) => {
|
|
34080
|
+
return removeHash(self, key, hash(key));
|
|
34081
|
+
});
|
|
33560
34082
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/HashMap.js
|
|
33561
34083
|
/**
|
|
33562
34084
|
* Stores key/value entries in an immutable hash map.
|
|
@@ -33625,6 +34147,26 @@ const set = set$1;
|
|
|
33625
34147
|
* @since 2.0.0
|
|
33626
34148
|
*/
|
|
33627
34149
|
const values = values$1;
|
|
34150
|
+
/**
|
|
34151
|
+
* Removes the entry for the specified key in the `HashMap` using the internal
|
|
34152
|
+
* hashing function.
|
|
34153
|
+
*
|
|
34154
|
+
* **Example** (Removing a key)
|
|
34155
|
+
*
|
|
34156
|
+
* ```ts import.meta.vitest
|
|
34157
|
+
* import { HashMap } from "effect"
|
|
34158
|
+
*
|
|
34159
|
+
* const map1 = HashMap.make(["a", 1], ["b", 2], ["c", 3])
|
|
34160
|
+
* const map2 = HashMap.remove(map1, "b")
|
|
34161
|
+
*
|
|
34162
|
+
* map2 // => HashMap.make(["a", 1], ["c", 3])
|
|
34163
|
+
* ```
|
|
34164
|
+
*
|
|
34165
|
+
* @stability stable
|
|
34166
|
+
* @category transforming
|
|
34167
|
+
* @since 2.0.0
|
|
34168
|
+
*/
|
|
34169
|
+
const remove$1 = remove$2;
|
|
33628
34170
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/internal/hashSet.js
|
|
33629
34171
|
/**
|
|
33630
34172
|
* @since 2.0.0
|
|
@@ -34301,7 +34843,7 @@ function makeOption(schema) {
|
|
|
34301
34843
|
const parser = makeEffect(schema);
|
|
34302
34844
|
return (input, options) => {
|
|
34303
34845
|
const exit = runSyncExit(parser(input, options));
|
|
34304
|
-
if (isSuccess(exit)) return some
|
|
34846
|
+
if (isSuccess(exit)) return some(exit.value);
|
|
34305
34847
|
getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues");
|
|
34306
34848
|
return none();
|
|
34307
34849
|
};
|
|
@@ -35830,6 +36372,35 @@ function toRepresentations(asts, options) {
|
|
|
35830
36372
|
}
|
|
35831
36373
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/Struct.js
|
|
35832
36374
|
/**
|
|
36375
|
+
* Creates a new struct containing only the specified keys.
|
|
36376
|
+
*
|
|
36377
|
+
* **When to use**
|
|
36378
|
+
*
|
|
36379
|
+
* Use to narrow a struct down to a subset of its properties.
|
|
36380
|
+
*
|
|
36381
|
+
* **Gotchas**
|
|
36382
|
+
*
|
|
36383
|
+
* Keys not present in the struct are silently ignored.
|
|
36384
|
+
*
|
|
36385
|
+
* **Example** (Selecting specific properties)
|
|
36386
|
+
*
|
|
36387
|
+
* ```ts import.meta.vitest
|
|
36388
|
+
* import { pipe, Struct } from "effect"
|
|
36389
|
+
*
|
|
36390
|
+
* const user = { name: "Alice", age: 30, admin: true }
|
|
36391
|
+
* pipe(user, Struct.pick(["name", "age"])) // => { name: "Alice", age: 30 }
|
|
36392
|
+
* ```
|
|
36393
|
+
*
|
|
36394
|
+
* @see {@link omit} – the inverse (exclude keys instead)
|
|
36395
|
+
* @see {@link get} – extract a single value
|
|
36396
|
+
* @stability stable
|
|
36397
|
+
* @category filtering
|
|
36398
|
+
* @since 2.0.0
|
|
36399
|
+
*/
|
|
36400
|
+
const pick = /*#__PURE__*/ dual(2, (self, keys) => {
|
|
36401
|
+
return buildStruct(self, (k, v) => hasPropertyKey(keys, k) ? [k, v] : void 0);
|
|
36402
|
+
});
|
|
36403
|
+
/**
|
|
35833
36404
|
* Creates a new struct with the specified keys removed.
|
|
35834
36405
|
*
|
|
35835
36406
|
* **When to use**
|
|
@@ -38136,7 +38707,7 @@ function Cause(error, defect) {
|
|
|
38136
38707
|
}
|
|
38137
38708
|
const dateTimeUtcFromString = /*#__PURE__*/ transformEffect({
|
|
38138
38709
|
decode: (s, options) => {
|
|
38139
|
-
return match$
|
|
38710
|
+
return match$6(make$53(s), {
|
|
38140
38711
|
onNone: () => fail$3(new InvalidValue({ expected: "a valid UTC DateTime string" }, s, options)),
|
|
38141
38712
|
onSome: (result) => succeed$4(toUtc(result))
|
|
38142
38713
|
});
|
|
@@ -38197,7 +38768,7 @@ const DateTimeUtc = /*#__PURE__*/ declare((u) => isDateTime(u) && isUtc(u), {
|
|
|
38197
38768
|
toFormatter: () => (utc) => utc.toString()
|
|
38198
38769
|
});
|
|
38199
38770
|
const durationFromString = /*#__PURE__*/ transformEffect({
|
|
38200
|
-
decode: (s, options) => match$
|
|
38771
|
+
decode: (s, options) => match$6(fromInput$3(s), {
|
|
38201
38772
|
onNone: () => fail$3(new InvalidValue({ expected: "a valid Duration string" }, s, options)),
|
|
38202
38773
|
onSome: succeed$4
|
|
38203
38774
|
}),
|
|
@@ -39259,25 +39830,6 @@ var EmptyBodyError = class extends (/*#__PURE__*/ TaggedError$1("EmptyBodyError"
|
|
|
39259
39830
|
};
|
|
39260
39831
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/HttpMethod.js
|
|
39261
39832
|
/**
|
|
39262
|
-
* Defines supported HTTP method names for the unstable HTTP modules.
|
|
39263
|
-
*
|
|
39264
|
-
* Values are uppercase string literals such as `"GET"` and `"POST"`, matching
|
|
39265
|
-
* the method tokens used by HTTP requests and routes. This module also includes
|
|
39266
|
-
* helpers for checking whether a method can carry a request body and whether an
|
|
39267
|
-
* unknown value is one of the supported methods.
|
|
39268
|
-
*
|
|
39269
|
-
* @stability unstable
|
|
39270
|
-
* @since 4.0.0
|
|
39271
|
-
*/
|
|
39272
|
-
/**
|
|
39273
|
-
* Returns `true` when a method can carry a request body and narrows it to `HttpMethod.WithBody`.
|
|
39274
|
-
*
|
|
39275
|
-
* @stability unstable
|
|
39276
|
-
* @category guards
|
|
39277
|
-
* @since 4.0.0
|
|
39278
|
-
*/
|
|
39279
|
-
const hasBody = (method) => method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE";
|
|
39280
|
-
/**
|
|
39281
39833
|
* Provides tuples mapping each supported HTTP method to its short
|
|
39282
39834
|
* request-constructor name.
|
|
39283
39835
|
*
|
|
@@ -39306,9 +39858,9 @@ const allShort = [
|
|
|
39306
39858
|
* @internal
|
|
39307
39859
|
*/
|
|
39308
39860
|
const updateHeaders = (headers, body) => {
|
|
39309
|
-
if (body._tag === "Empty" || body._tag === "FormData") return remove$
|
|
39310
|
-
headers = body.contentType === void 0 ? remove$
|
|
39311
|
-
return body.contentLength === void 0 ? remove$
|
|
39861
|
+
if (body._tag === "Empty" || body._tag === "FormData") return remove$3(remove$3(headers, "content-type"), "content-length");
|
|
39862
|
+
headers = body.contentType === void 0 ? remove$3(headers, "content-type") : set$2(headers, "content-type", body.contentType);
|
|
39863
|
+
return body.contentLength === void 0 ? remove$3(headers, "content-length") : set$2(headers, "content-length", body.contentLength.toString());
|
|
39312
39864
|
};
|
|
39313
39865
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/Url.js
|
|
39314
39866
|
/**
|
|
@@ -39499,7 +40051,7 @@ const setUrlParams = /*#__PURE__*/ dual(2, (self, input) => makeWith$1(self.meth
|
|
|
39499
40051
|
* @category combinators
|
|
39500
40052
|
* @since 4.0.0
|
|
39501
40053
|
*/
|
|
39502
|
-
const setHash = /*#__PURE__*/ dual(2, (self, hash) => makeWith$1(self.method, self.url, self.urlParams, some
|
|
40054
|
+
const setHash = /*#__PURE__*/ dual(2, (self, hash) => makeWith$1(self.method, self.url, self.urlParams, some(hash), self.headers, self.body));
|
|
39503
40055
|
/**
|
|
39504
40056
|
* Sets the request body and updates `Content-Type` and `Content-Length` headers from the body metadata when available.
|
|
39505
40057
|
*
|
|
@@ -39519,7 +40071,7 @@ const setBody$1 = /*#__PURE__*/ dual(2, (self, body) => {
|
|
|
39519
40071
|
*/
|
|
39520
40072
|
function toUrl(self) {
|
|
39521
40073
|
const r = make$39(self.url, self.urlParams, getOrUndefined$1(self.hash));
|
|
39522
|
-
if (isSuccess$1(r)) return some
|
|
40074
|
+
if (isSuccess$1(r)) return some(r.success);
|
|
39523
40075
|
return none();
|
|
39524
40076
|
}
|
|
39525
40077
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/HttpIncomingMessage.js
|
|
@@ -39760,7 +40312,7 @@ var WebHttpClientResponse = class extends Class$2 {
|
|
|
39760
40312
|
* @since 4.0.0
|
|
39761
40313
|
*/
|
|
39762
40314
|
const toHeaders = (span) => fromRecordUnsafe({
|
|
39763
|
-
b3: `${span.traceId}-${span.spanId}-${span.sampled ? "1" : "0"}${match$
|
|
40315
|
+
b3: `${span.traceId}-${span.spanId}-${span.sampled ? "1" : "0"}${match$6(span.parent, {
|
|
39764
40316
|
onNone: () => "",
|
|
39765
40317
|
onSome: (parent) => `-${parent.spanId}`
|
|
39766
40318
|
})}`,
|
|
@@ -39801,7 +40353,7 @@ const b3 = (headers) => {
|
|
|
39801
40353
|
if (!("b3" in headers)) return none();
|
|
39802
40354
|
const parts = headers["b3"].split("-");
|
|
39803
40355
|
if (parts.length < 2 || isB3Ids(parts[0], parts[1]) === false) return none();
|
|
39804
|
-
return some
|
|
40356
|
+
return some(externalSpan({
|
|
39805
40357
|
traceId: parts[0],
|
|
39806
40358
|
spanId: parts[1],
|
|
39807
40359
|
sampled: parts[2] ? parts[2] === "1" || parts[2] === "d" : true
|
|
@@ -39821,7 +40373,7 @@ const b3 = (headers) => {
|
|
|
39821
40373
|
*/
|
|
39822
40374
|
const xb3 = (headers) => {
|
|
39823
40375
|
if (!headers["x-b3-traceid"] || !headers["x-b3-spanid"] || isB3Ids(headers["x-b3-traceid"], headers["x-b3-spanid"]) === false) return none();
|
|
39824
|
-
return some
|
|
40376
|
+
return some(externalSpan({
|
|
39825
40377
|
traceId: headers["x-b3-traceid"],
|
|
39826
40378
|
spanId: headers["x-b3-spanid"],
|
|
39827
40379
|
sampled: headers["x-b3-flags"] === "1" || (headers["x-b3-sampled"] ? headers["x-b3-sampled"] === "1" || headers["x-b3-sampled"] === "true" : true)
|
|
@@ -39850,7 +40402,7 @@ const w3c = (headers) => {
|
|
|
39850
40402
|
switch (version) {
|
|
39851
40403
|
case "00":
|
|
39852
40404
|
if (w3cTraceId.test(traceId) === false || w3cSpanId.test(spanId) === false || traceId === "00000000000000000000000000000000" || spanId === "0000000000000000") return none();
|
|
39853
|
-
return some
|
|
40405
|
+
return some(externalSpan({
|
|
39854
40406
|
traceId,
|
|
39855
40407
|
spanId,
|
|
39856
40408
|
sampled: (parseInt(flags, 16) & 1) === 1
|
|
@@ -40943,7 +41495,7 @@ const toString = (self) => {
|
|
|
40943
41495
|
*/
|
|
40944
41496
|
var Generator = class extends (/*#__PURE__*/ Service$2()("effect/http/Etag/Generator")) {};
|
|
40945
41497
|
const fromFileInfo = (info) => {
|
|
40946
|
-
const mtime = match$
|
|
41498
|
+
const mtime = match$6(info.mtime, {
|
|
40947
41499
|
onNone: () => "0",
|
|
40948
41500
|
onSome: (mtime) => mtime.getTime().toString(16)
|
|
40949
41501
|
});
|
|
@@ -41292,7 +41844,7 @@ const setHeader = /*#__PURE__*/ dual(3, (self, key, value) => makeResponse(self,
|
|
|
41292
41844
|
*/
|
|
41293
41845
|
const removeHeader = /*#__PURE__*/ dual(2, (self, key) => makeResponse({
|
|
41294
41846
|
...self,
|
|
41295
|
-
headers: remove$
|
|
41847
|
+
headers: remove$3(self.headers, key)
|
|
41296
41848
|
}));
|
|
41297
41849
|
/**
|
|
41298
41850
|
* Returns a response with all supplied headers set on the existing header map.
|
|
@@ -42374,7 +42926,7 @@ const causeResponseStripped = (cause) => {
|
|
|
42374
42926
|
}
|
|
42375
42927
|
return true;
|
|
42376
42928
|
});
|
|
42377
|
-
return [response ?? internalServerError$1, failures.length > 0 ? some
|
|
42929
|
+
return [response ?? internalServerError$1, failures.length > 0 ? some(fromReasons(failures)) : none()];
|
|
42378
42930
|
};
|
|
42379
42931
|
const internalServerError$1 = /*#__PURE__*/ empty({ status: 500 });
|
|
42380
42932
|
const succeedInternalServerError = /*#__PURE__*/ succeed$4(internalServerError$1);
|
|
@@ -42810,21 +43362,6 @@ const fromWebSocket = (acquire, options) => withFiber((fiber) => {
|
|
|
42810
43362
|
}));
|
|
42811
43363
|
});
|
|
42812
43364
|
const defaultHighWaterMark = 65536;
|
|
42813
|
-
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/internal/lazyStream.js
|
|
42814
|
-
/**
|
|
42815
|
-
* Opens `stream` on its first pull rather than when it is run, so a consumer
|
|
42816
|
-
* that runs it without pulling, such as a Web `ReadableStream`, leaves the
|
|
42817
|
-
* body unread.
|
|
42818
|
-
*
|
|
42819
|
-
* @internal
|
|
42820
|
-
*/
|
|
42821
|
-
const openOnFirstPull = (stream) => fromChannel(fromTransform$1((_, scope) => sync(() => {
|
|
42822
|
-
let pull;
|
|
42823
|
-
return suspend$2(() => pull ?? flatMap$1(toPullScoped(stream.channel, scope), (upstream) => {
|
|
42824
|
-
pull = upstream;
|
|
42825
|
-
return upstream;
|
|
42826
|
-
}));
|
|
42827
|
-
})));
|
|
42828
43365
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/MultipartParser/internal/contentType.js
|
|
42829
43366
|
/**
|
|
42830
43367
|
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
|
|
@@ -43548,87 +44085,6 @@ const makeConfig = (headers) => withFiber((fiber) => {
|
|
|
43548
44085
|
isFile: mimeTypes.length === 0 ? void 0 : (info) => !mimeTypes.some((_) => info.contentType.includes(_)) && defaultIsFile(info)
|
|
43549
44086
|
});
|
|
43550
44087
|
});
|
|
43551
|
-
/**
|
|
43552
|
-
* Creates a channel that parses multipart byte chunks into multipart parts.
|
|
43553
|
-
*
|
|
43554
|
-
* **Details**
|
|
43555
|
-
*
|
|
43556
|
-
* The channel consumes non-empty batches of `Uint8Array` chunks and emits
|
|
43557
|
-
* non-empty batches of parsed `Part` values, failing with `MultipartError` for
|
|
43558
|
-
* parser and limit failures.
|
|
43559
|
-
*
|
|
43560
|
-
* @stability unstable
|
|
43561
|
-
* @category parsing
|
|
43562
|
-
* @since 4.0.0
|
|
43563
|
-
*/
|
|
43564
|
-
const makeChannel = (headers) => fromTransform$1((upstream) => map$2(makeConfig(headers), (config) => {
|
|
43565
|
-
let partsBuffer = [];
|
|
43566
|
-
let exit = none();
|
|
43567
|
-
let ended = false;
|
|
43568
|
-
const parser = make$29({
|
|
43569
|
-
...config,
|
|
43570
|
-
onField(info, value) {
|
|
43571
|
-
partsBuffer.push(new FieldImpl$1(info.name, info.contentType, decodeField(info, value)));
|
|
43572
|
-
},
|
|
43573
|
-
onFile(info) {
|
|
43574
|
-
let chunks = [];
|
|
43575
|
-
let finished = false;
|
|
43576
|
-
const pullChunks = fromPull$1(succeed$4(suspend$2(function loop() {
|
|
43577
|
-
if (!isReadonlyArrayNonEmpty(chunks)) {
|
|
43578
|
-
if (finished) return done();
|
|
43579
|
-
if (isSome(exit)) return exit.value;
|
|
43580
|
-
return flatMap$1(pump, loop);
|
|
43581
|
-
}
|
|
43582
|
-
const chunk = chunks;
|
|
43583
|
-
chunks = [];
|
|
43584
|
-
return succeed$4(chunk);
|
|
43585
|
-
})));
|
|
43586
|
-
partsBuffer.push(new FileImpl$1(info, mapError$1(pullChunks, toMultipartError)));
|
|
43587
|
-
return function(chunk) {
|
|
43588
|
-
if (chunk === null) finished = true;
|
|
43589
|
-
else chunks.push(chunk);
|
|
43590
|
-
};
|
|
43591
|
-
},
|
|
43592
|
-
onError(error_) {
|
|
43593
|
-
exit = some$1(fail$5(convertError$1(error_)));
|
|
43594
|
-
},
|
|
43595
|
-
onDone() {
|
|
43596
|
-
if (isNone(exit)) exit = some$1(fail$5(Done()));
|
|
43597
|
-
}
|
|
43598
|
-
});
|
|
43599
|
-
const pump = upstream.pipe(flatMap$1((chunk) => {
|
|
43600
|
-
for (let i = 0; i < chunk.length; i++) parser.write(chunk[i]);
|
|
43601
|
-
return void_$1;
|
|
43602
|
-
}), catchCause$2((cause) => {
|
|
43603
|
-
if (isDoneCause(cause)) {
|
|
43604
|
-
if (!ended) {
|
|
43605
|
-
ended = true;
|
|
43606
|
-
parser.end();
|
|
43607
|
-
}
|
|
43608
|
-
} else exit = some$1(failCause$5(cause));
|
|
43609
|
-
return void_$1;
|
|
43610
|
-
}));
|
|
43611
|
-
return suspend$2(function loop() {
|
|
43612
|
-
if (!isReadonlyArrayNonEmpty(partsBuffer)) {
|
|
43613
|
-
if (isSome(exit)) return exit.value;
|
|
43614
|
-
return flatMap$1(pump, loop);
|
|
43615
|
-
}
|
|
43616
|
-
const parts = partsBuffer;
|
|
43617
|
-
partsBuffer = [];
|
|
43618
|
-
return succeed$4(parts);
|
|
43619
|
-
});
|
|
43620
|
-
}));
|
|
43621
|
-
function convertError$1(cause) {
|
|
43622
|
-
switch (cause._tag) {
|
|
43623
|
-
case "ReachedLimit": switch (cause.limit) {
|
|
43624
|
-
case "MaxParts": return MultipartError.fromReason("TooManyParts", cause);
|
|
43625
|
-
case "MaxFieldSize": return MultipartError.fromReason("FieldTooLarge", cause);
|
|
43626
|
-
case "MaxPartSize": return MultipartError.fromReason("FileTooLarge", cause);
|
|
43627
|
-
case "MaxTotalSize": return MultipartError.fromReason("BodyTooLarge", cause);
|
|
43628
|
-
}
|
|
43629
|
-
default: return MultipartError.fromReason("Parse", cause);
|
|
43630
|
-
}
|
|
43631
|
-
}
|
|
43632
44088
|
var PartBase$1 = class extends Class$2 {
|
|
43633
44089
|
[TypeId$14];
|
|
43634
44090
|
constructor() {
|
|
@@ -43636,52 +44092,6 @@ var PartBase$1 = class extends Class$2 {
|
|
|
43636
44092
|
this[TypeId$14] = TypeId$14;
|
|
43637
44093
|
}
|
|
43638
44094
|
};
|
|
43639
|
-
var FieldImpl$1 = class extends PartBase$1 {
|
|
43640
|
-
_tag = "Field";
|
|
43641
|
-
key;
|
|
43642
|
-
contentType;
|
|
43643
|
-
value;
|
|
43644
|
-
constructor(key, contentType, value) {
|
|
43645
|
-
super();
|
|
43646
|
-
this.key = key;
|
|
43647
|
-
this.contentType = contentType;
|
|
43648
|
-
this.value = value;
|
|
43649
|
-
}
|
|
43650
|
-
toJSON() {
|
|
43651
|
-
return {
|
|
43652
|
-
_id: "@effect/platform/Multipart/Part",
|
|
43653
|
-
_tag: "Field",
|
|
43654
|
-
key: this.key,
|
|
43655
|
-
contentType: this.contentType,
|
|
43656
|
-
value: this.value
|
|
43657
|
-
};
|
|
43658
|
-
}
|
|
43659
|
-
};
|
|
43660
|
-
var FileImpl$1 = class extends PartBase$1 {
|
|
43661
|
-
_tag = "File";
|
|
43662
|
-
key;
|
|
43663
|
-
name;
|
|
43664
|
-
contentType;
|
|
43665
|
-
content;
|
|
43666
|
-
contentEffect;
|
|
43667
|
-
constructor(info, channel) {
|
|
43668
|
-
super();
|
|
43669
|
-
this.key = info.name;
|
|
43670
|
-
this.name = info.filename ?? info.name;
|
|
43671
|
-
this.contentType = info.contentType;
|
|
43672
|
-
this.content = fromChannel(channel);
|
|
43673
|
-
this.contentEffect = mkUint8Array$1(channel);
|
|
43674
|
-
}
|
|
43675
|
-
toJSON() {
|
|
43676
|
-
return {
|
|
43677
|
-
_id: "@effect/platform/Multipart/Part",
|
|
43678
|
-
_tag: "File",
|
|
43679
|
-
key: this.key,
|
|
43680
|
-
name: this.name,
|
|
43681
|
-
contentType: this.contentType
|
|
43682
|
-
};
|
|
43683
|
-
}
|
|
43684
|
-
};
|
|
43685
44095
|
const defaultWriteFile = (path, file) => flatMap$1(FileSystem, (fs) => mapError$2(run$1(file.content, fs.sink(path)), toMultipartError));
|
|
43686
44096
|
const maxPersistedFileNameBytes = 128;
|
|
43687
44097
|
const fileNameEncoder = /*#__PURE__*/ new TextEncoder();
|
|
@@ -43888,149 +44298,11 @@ const toURL = (self) => {
|
|
|
43888
44298
|
const host = self.headers.host ?? "localhost";
|
|
43889
44299
|
const protocol = self.protocol ?? (/^https:/i.test(self.originalUrl) ? "https" : "http");
|
|
43890
44300
|
try {
|
|
43891
|
-
return some
|
|
44301
|
+
return some(new URL(self.url.startsWith("/") ? `.${self.url}` : self.url, `${protocol}://${host}`));
|
|
43892
44302
|
} catch {
|
|
43893
44303
|
return none();
|
|
43894
44304
|
}
|
|
43895
44305
|
};
|
|
43896
|
-
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/internal/decompression.js
|
|
43897
|
-
const defaultMaxDecompressedSize = /*#__PURE__*/ mebibytes(10);
|
|
43898
|
-
/**
|
|
43899
|
-
* Parses a `Content-Encoding` header into the codings to undo, in the order
|
|
43900
|
-
* they were applied. `identity` members are dropped. Returns `undefined` if
|
|
43901
|
-
* any member is unsupported.
|
|
43902
|
-
*
|
|
43903
|
-
* @internal
|
|
43904
|
-
*/
|
|
43905
|
-
const parseContentEncoding = (header) => {
|
|
43906
|
-
const codings = [];
|
|
43907
|
-
for (const member of header.split(",")) {
|
|
43908
|
-
const coding = member.trim().toLowerCase();
|
|
43909
|
-
if (coding === "" || coding === "identity") continue;
|
|
43910
|
-
if (coding !== "gzip" && coding !== "deflate") return void 0;
|
|
43911
|
-
codings.push(coding);
|
|
43912
|
-
}
|
|
43913
|
-
return codings;
|
|
43914
|
-
};
|
|
43915
|
-
/**
|
|
43916
|
-
* Wraps a request so that its body accessors yield the decompressed body.
|
|
43917
|
-
* Decompression happens lazily, when a body accessor is read.
|
|
43918
|
-
*
|
|
43919
|
-
* @internal
|
|
43920
|
-
*/
|
|
43921
|
-
var DecompressedRequest = class DecompressedRequest extends Class$2 {
|
|
43922
|
-
[TypeId$13];
|
|
43923
|
-
[TypeId$20];
|
|
43924
|
-
inner;
|
|
43925
|
-
codings;
|
|
43926
|
-
maxDecompressedSize;
|
|
43927
|
-
headers;
|
|
43928
|
-
constructor(inner, codings, maxDecompressedSize) {
|
|
43929
|
-
super();
|
|
43930
|
-
this[TypeId$13] = TypeId$13;
|
|
43931
|
-
this[TypeId$20] = TypeId$20;
|
|
43932
|
-
this.inner = inner;
|
|
43933
|
-
this.codings = codings;
|
|
43934
|
-
this.maxDecompressedSize = maxDecompressedSize;
|
|
43935
|
-
this.headers = removeMany(inner.headers, ["content-encoding", "content-length"]);
|
|
43936
|
-
}
|
|
43937
|
-
toJSON() {
|
|
43938
|
-
return inspect(this, {
|
|
43939
|
-
_id: "HttpServerRequest",
|
|
43940
|
-
method: this.method,
|
|
43941
|
-
url: this.originalUrl
|
|
43942
|
-
});
|
|
43943
|
-
}
|
|
43944
|
-
modify(options) {
|
|
43945
|
-
return new DecompressedRequest(this.inner.modify(options), this.codings, this.maxDecompressedSize);
|
|
43946
|
-
}
|
|
43947
|
-
get source() {
|
|
43948
|
-
return this.inner.source;
|
|
43949
|
-
}
|
|
43950
|
-
get url() {
|
|
43951
|
-
return this.inner.url;
|
|
43952
|
-
}
|
|
43953
|
-
get originalUrl() {
|
|
43954
|
-
return this.inner.originalUrl;
|
|
43955
|
-
}
|
|
43956
|
-
get method() {
|
|
43957
|
-
return this.inner.method;
|
|
43958
|
-
}
|
|
43959
|
-
get cookies() {
|
|
43960
|
-
return this.inner.cookies;
|
|
43961
|
-
}
|
|
43962
|
-
get remoteAddress() {
|
|
43963
|
-
return this.inner.remoteAddress;
|
|
43964
|
-
}
|
|
43965
|
-
get peerAddress() {
|
|
43966
|
-
return this.inner.peerAddress;
|
|
43967
|
-
}
|
|
43968
|
-
get protocol() {
|
|
43969
|
-
return this.inner.protocol;
|
|
43970
|
-
}
|
|
43971
|
-
get upgrade() {
|
|
43972
|
-
return this.inner.upgrade;
|
|
43973
|
-
}
|
|
43974
|
-
get response() {
|
|
43975
|
-
return this.inner.response;
|
|
43976
|
-
}
|
|
43977
|
-
get stream() {
|
|
43978
|
-
return openOnFirstPull(unwrap$2(withFiber((fiber) => {
|
|
43979
|
-
const limit = this.maxDecompressedSize ?? fiber.getRef(MaxBodySize) ?? defaultMaxDecompressedSize;
|
|
43980
|
-
return succeed$4(fromReadableStream({
|
|
43981
|
-
evaluate: () => {
|
|
43982
|
-
let body = toReadableStreamWith(this.inner.stream, fiber.context);
|
|
43983
|
-
for (let i = this.codings.length - 1; i >= 0; i--) body = body.pipeThrough(new DecompressionStream(this.codings[i]));
|
|
43984
|
-
let size = 0;
|
|
43985
|
-
return body.pipeThrough(new TransformStream({ transform: (chunk, controller) => {
|
|
43986
|
-
size += chunk.byteLength;
|
|
43987
|
-
if (size > limit) controller.error(this.parseError(void 0, `Decompressed request body exceeds ${limit} bytes`, "BodyTooLarge"));
|
|
43988
|
-
else controller.enqueue(chunk);
|
|
43989
|
-
} }));
|
|
43990
|
-
},
|
|
43991
|
-
onError: (cause) => cause instanceof HttpServerError ? cause : this.parseError(cause)
|
|
43992
|
-
}));
|
|
43993
|
-
})));
|
|
43994
|
-
}
|
|
43995
|
-
bytesEffect;
|
|
43996
|
-
get bytes() {
|
|
43997
|
-
return this.bytesEffect ??= runSync$1(cached(mkUint8Array(this.stream)));
|
|
43998
|
-
}
|
|
43999
|
-
get text() {
|
|
44000
|
-
return map$2(this.bytes, (bytes) => textDecoder$1.decode(bytes));
|
|
44001
|
-
}
|
|
44002
|
-
get json() {
|
|
44003
|
-
return flatMap$1(this.text, (text) => try_({
|
|
44004
|
-
try: () => text === "" ? null : JSON.parse(text),
|
|
44005
|
-
catch: (cause) => this.parseError(cause)
|
|
44006
|
-
}));
|
|
44007
|
-
}
|
|
44008
|
-
get urlParamsBody() {
|
|
44009
|
-
return flatMap$1(this.text, (text) => try_({
|
|
44010
|
-
try: () => fromInput(new URLSearchParams(text)),
|
|
44011
|
-
catch: (cause) => this.parseError(cause)
|
|
44012
|
-
}));
|
|
44013
|
-
}
|
|
44014
|
-
get arrayBuffer() {
|
|
44015
|
-
return map$2(this.bytes, (bytes) => bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength));
|
|
44016
|
-
}
|
|
44017
|
-
get multipartStream() {
|
|
44018
|
-
return pipeThroughChannel(mapError(this.stream, (cause) => MultipartError.fromReason(cause.reason instanceof RequestParseError && cause.reason.request === this ? cause.reason.reason ?? "Parse" : "InternalError", cause)), makeChannel(this.headers));
|
|
44019
|
-
}
|
|
44020
|
-
multipartEffect;
|
|
44021
|
-
get multipart() {
|
|
44022
|
-
return this.multipartEffect ??= runSync$1(cached(toPersisted(this.multipartStream)));
|
|
44023
|
-
}
|
|
44024
|
-
parseError(cause, description, reason = "Parse") {
|
|
44025
|
-
return new HttpServerError({ reason: new RequestParseError({
|
|
44026
|
-
request: this,
|
|
44027
|
-
reason,
|
|
44028
|
-
...description === void 0 ? void 0 : { description },
|
|
44029
|
-
...cause === void 0 ? void 0 : { cause }
|
|
44030
|
-
}) });
|
|
44031
|
-
}
|
|
44032
|
-
};
|
|
44033
|
-
const textDecoder$1 = /*#__PURE__*/ new TextDecoder();
|
|
44034
44306
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/internal/requestState.js
|
|
44035
44307
|
/**
|
|
44036
44308
|
* Mutable state owned by the root that handles a single server request.
|
|
@@ -44059,19 +44331,6 @@ const appendPreResponseHandlerUnsafe$1 = (context, handler) => {
|
|
|
44059
44331
|
};
|
|
44060
44332
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/HttpMiddleware.js
|
|
44061
44333
|
/**
|
|
44062
|
-
* Wraps HTTP server apps with request and response behavior.
|
|
44063
|
-
*
|
|
44064
|
-
* A middleware is a function from one HTTP server app effect to another. The app
|
|
44065
|
-
* runs with the current `HttpServerRequest` in its context, so middleware can
|
|
44066
|
-
* inspect or rewrite the request, provide request-scoped services, attach hooks
|
|
44067
|
-
* before the response is sent, or observe the app exit. This module includes
|
|
44068
|
-
* middleware for response logging, server tracing, forwarded proxy headers,
|
|
44069
|
-
* parsed search parameters, and CORS response headers.
|
|
44070
|
-
*
|
|
44071
|
-
* @stability unstable
|
|
44072
|
-
* @since 4.0.0
|
|
44073
|
-
*/
|
|
44074
|
-
/**
|
|
44075
44334
|
* Defines an `HttpMiddleware` while preserving its precise type.
|
|
44076
44335
|
*
|
|
44077
44336
|
* **Gotchas**
|
|
@@ -44362,60 +44621,6 @@ const cors$1 = (options) => {
|
|
|
44362
44621
|
return httpApp;
|
|
44363
44622
|
});
|
|
44364
44623
|
};
|
|
44365
|
-
/**
|
|
44366
|
-
* Middleware that decompresses request bodies sent with a `Content-Encoding`
|
|
44367
|
-
* of `gzip` or `deflate`.
|
|
44368
|
-
*
|
|
44369
|
-
* **Details**
|
|
44370
|
-
*
|
|
44371
|
-
* The request service is replaced with a view whose body accessors (`stream`,
|
|
44372
|
-
* `text`, `json`, `arrayBuffer`, `urlParamsBody`, `multipart`) yield the
|
|
44373
|
-
* decompressed body, and whose headers no longer include `Content-Encoding`
|
|
44374
|
-
* or `Content-Length`. Decompression is lazy and only happens when the body
|
|
44375
|
-
* is read. Stacked codings such as `deflate, gzip` are undone in reverse
|
|
44376
|
-
* order, and `identity` members are ignored.
|
|
44377
|
-
*
|
|
44378
|
-
* Requests whose `Content-Encoding` includes any other coding are rejected
|
|
44379
|
-
* with `415 Unsupported Media Type` and `Accept-Encoding: gzip, deflate`,
|
|
44380
|
-
* without running the app. Malformed compressed data fails the body read
|
|
44381
|
-
* with a `RequestParseError`, or a `MultipartError` with reason `Parse` when
|
|
44382
|
-
* reading multipart data.
|
|
44383
|
-
*
|
|
44384
|
-
* The decompressed size is limited to `maxDecompressedSize`, falling back to
|
|
44385
|
-
* the `MaxBodySize` reference and then to 10 MiB. Exceeding it fails the body
|
|
44386
|
-
* read with a `RequestParseError`, or a `MultipartError` with reason
|
|
44387
|
-
* `BodyTooLarge` when reading multipart data. The limit applies to every body
|
|
44388
|
-
* accessor, including `stream`.
|
|
44389
|
-
*
|
|
44390
|
-
* Decompression uses the global `DecompressionStream`. `deflate` means the
|
|
44391
|
-
* zlib format (RFC 1950); raw deflate data is rejected.
|
|
44392
|
-
*
|
|
44393
|
-
* **Gotchas**
|
|
44394
|
-
*
|
|
44395
|
-
* `request.source` is still the original, compressed request.
|
|
44396
|
-
* `HttpServerRequest.toWeb` returns that compressed request only when the
|
|
44397
|
-
* source is a Web `Request`. On other platforms, such as Node, it builds a new
|
|
44398
|
-
* `Request` from the decompressed body and the stripped headers.
|
|
44399
|
-
*
|
|
44400
|
-
* @stability unstable
|
|
44401
|
-
* @category compression
|
|
44402
|
-
* @since 4.0.0
|
|
44403
|
-
*/
|
|
44404
|
-
const decompression = (options) => {
|
|
44405
|
-
const maxDecompressedSize = options?.maxDecompressedSize === void 0 ? void 0 : fromInputUnsafe(options.maxDecompressedSize);
|
|
44406
|
-
return (httpApp) => withFiber((fiber) => {
|
|
44407
|
-
const request = getUnsafe$2(fiber.context, HttpServerRequest);
|
|
44408
|
-
const contentEncoding = request.headers["content-encoding"];
|
|
44409
|
-
if (contentEncoding === void 0 || !hasBody(request.method)) return httpApp;
|
|
44410
|
-
const codings = parseContentEncoding(contentEncoding);
|
|
44411
|
-
if (codings === void 0) return succeed$4(empty({
|
|
44412
|
-
status: 415,
|
|
44413
|
-
headers: { "accept-encoding": "gzip, deflate" }
|
|
44414
|
-
}));
|
|
44415
|
-
if (codings.length === 0) return httpApp;
|
|
44416
|
-
return provideService(httpApp, HttpServerRequest, new DecompressedRequest(request, codings, maxDecompressedSize));
|
|
44417
|
-
});
|
|
44418
|
-
};
|
|
44419
44624
|
// ../../node_modules/.pnpm/effect@4.0.6/node_modules/effect/dist/http/HttpEffect.js
|
|
44420
44625
|
/**
|
|
44421
44626
|
* Runs an HTTP server effect, sends the produced response with the supplied handler, and converts failures into HTTP responses.
|
|
@@ -44886,7 +45091,7 @@ const RouteTypeId = "~effect/http/HttpRouter/Route";
|
|
|
44886
45091
|
const makeRoute = (options) => ({
|
|
44887
45092
|
...options,
|
|
44888
45093
|
uninterruptible: options.uninterruptible ?? false,
|
|
44889
|
-
prefix: typeof options.prefix === "string" ? some
|
|
45094
|
+
prefix: typeof options.prefix === "string" ? some(options.prefix) : options.prefix ?? none(),
|
|
44890
45095
|
[RouteTypeId]: RouteTypeId
|
|
44891
45096
|
});
|
|
44892
45097
|
/**
|
|
@@ -44944,7 +45149,7 @@ const prefixPath = /*#__PURE__*/ dual(2, (self, prefix) => {
|
|
|
44944
45149
|
const prefixRoute = /*#__PURE__*/ dual(2, (self, prefix) => makeRoute({
|
|
44945
45150
|
...self,
|
|
44946
45151
|
path: prefixPath(self.path, prefix),
|
|
44947
|
-
prefix: match$
|
|
45152
|
+
prefix: match$6(self.prefix, {
|
|
44948
45153
|
onNone: () => removeTrailingSlash(prefix),
|
|
44949
45154
|
onSome: (existingPrefix) => prefixPath(existingPrefix, prefix)
|
|
44950
45155
|
})
|
|
@@ -45205,7 +45410,7 @@ function isStreamSchema(schema) {
|
|
|
45205
45410
|
* @internal
|
|
45206
45411
|
*/
|
|
45207
45412
|
function getStreamSchemas(schema) {
|
|
45208
|
-
return isStreamSchema(schema) ? some
|
|
45413
|
+
return isStreamSchema(schema) ? some({
|
|
45209
45414
|
success: schema.success,
|
|
45210
45415
|
error: schema.error
|
|
45211
45416
|
}) : none();
|
|
@@ -52144,10 +52349,10 @@ const makeFile = /*#__PURE__*/ (() => {
|
|
|
52144
52349
|
}), (bytesRead) => {
|
|
52145
52350
|
if (bytesRead === 0) return none();
|
|
52146
52351
|
if (explicit === void 0) this.position = position + BigInt(bytesRead);
|
|
52147
|
-
if (bytesRead === size) return some
|
|
52352
|
+
if (bytesRead === size) return some(buffer);
|
|
52148
52353
|
const dst = Buffer.allocUnsafeSlow(bytesRead);
|
|
52149
52354
|
buffer.copy(dst, 0, 0, bytesRead);
|
|
52150
|
-
return some
|
|
52355
|
+
return some(dst);
|
|
52151
52356
|
});
|
|
52152
52357
|
} catch (cause) {
|
|
52153
52358
|
return fail$3(handleBadArgument("readAlloc")(cause));
|
|
@@ -52249,7 +52454,7 @@ const makeFileInfo = (stat, method = "stat") => try_({
|
|
|
52249
52454
|
uid: bigintToNumberOption(stat.uid),
|
|
52250
52455
|
gid: bigintToNumberOption(stat.gid),
|
|
52251
52456
|
size: bytes(stat.size),
|
|
52252
|
-
blksize: stat.blksize !== void 0 ? some
|
|
52457
|
+
blksize: stat.blksize !== void 0 ? some(bytes(stat.blksize)) : none(),
|
|
52253
52458
|
blocks: fromNullishOr(stat.blocks)
|
|
52254
52459
|
}),
|
|
52255
52460
|
catch: handleBadArgument(method)
|
|
@@ -52566,7 +52771,7 @@ const layer$11 = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$4(/* @__
|
|
|
52566
52771
|
const fetch = fiber.getRef(Fetch);
|
|
52567
52772
|
const options = getOrUndefined(fiber.context, RequestInit) ?? {};
|
|
52568
52773
|
let headers = options.headers ? merge(fromInput$1(options.headers), request.headers) : request.headers;
|
|
52569
|
-
if (headers["content-length"]) headers = remove$
|
|
52774
|
+
if (headers["content-length"]) headers = remove$3(headers, "content-length");
|
|
52570
52775
|
let uploadController;
|
|
52571
52776
|
const stopUpload = sync(() => uploadController?.abort());
|
|
52572
52777
|
const send = (body) => map$2(tryPromise({
|
|
@@ -53340,7 +53545,7 @@ const layer$5 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
|
|
|
53340
53545
|
}
|
|
53341
53546
|
return queue;
|
|
53342
53547
|
});
|
|
53343
|
-
const readLine = suspend$2(() => poll(lines).pipe(flatMap$1(match$
|
|
53548
|
+
const readLine = suspend$2(() => poll(lines).pipe(flatMap$1(match$6({
|
|
53344
53549
|
onNone: () => scoped(andThen(get$4(rlRef), take(lines))),
|
|
53345
53550
|
onSome: succeed$4
|
|
53346
53551
|
})), mapError$2(() => new QuitError({}))));
|
|
@@ -55133,7 +55338,7 @@ const toSchemaStore = (self, schema) => {
|
|
|
55133
55338
|
const modify = (key, f) => flatMap$1(get(key), (o) => {
|
|
55134
55339
|
if (isNone(o)) return succeedNone;
|
|
55135
55340
|
const newValue = f(o.value);
|
|
55136
|
-
return as(set(key, newValue), some
|
|
55341
|
+
return as(set(key, newValue), some(newValue));
|
|
55137
55342
|
});
|
|
55138
55343
|
return {
|
|
55139
55344
|
[SchemaStoreTypeId]: SchemaStoreTypeId,
|
|
@@ -63931,7 +64136,7 @@ const runWithRuntime = /*#__PURE__*/ fnUntraced(function* (options, runtime, tra
|
|
|
63931
64136
|
const request = request_;
|
|
63932
64137
|
const httpRequest = isHttp ? getOrUndefined(fiber.context, HttpServerRequest) : void 0;
|
|
63933
64138
|
if (httpRequest !== void 0 && request._tag !== "Eof") appendPreResponseHandlerUnsafe(fiber.context, (_, response) => succeed$4(response.status === 200 && response.body._tag === "Uint8Array" && response.body.contentLength === 0 ? empty({
|
|
63934
|
-
headers: remove$
|
|
64139
|
+
headers: remove$3(response.headers, "content-type"),
|
|
63935
64140
|
status: 202
|
|
63936
64141
|
}) : response));
|
|
63937
64142
|
switch (request._tag) {
|
|
@@ -64307,7 +64512,7 @@ const toServerSentEvents = (response, keepAlive) => {
|
|
|
64307
64512
|
const options = {
|
|
64308
64513
|
status: response.status,
|
|
64309
64514
|
statusText: response.statusText,
|
|
64310
|
-
headers: remove$
|
|
64515
|
+
headers: remove$3(response.headers, "content-type"),
|
|
64311
64516
|
cookies: response.cookies,
|
|
64312
64517
|
contentType: "text/event-stream"
|
|
64313
64518
|
};
|
|
@@ -64853,7 +65058,7 @@ const unavailable = text("The authorization service is temporarily unavailable;
|
|
|
64853
65058
|
status: 503
|
|
64854
65059
|
});
|
|
64855
65060
|
var Auth = class Auth extends Service$2()("@deslop/runtime/auth/service/Auth") {
|
|
64856
|
-
static makeContext = (auth) => pipe(make$71(Auth, auth), add$3(RpcAuth, RpcAuth.of((effect, request) => pipe(auth.user(request.headers), flatMap$1((user) => provideService(effect, CurrentUser, user))))));
|
|
65061
|
+
static makeContext = (auth) => pipe(make$71(Auth, auth), add$3(RpcAuth, RpcAuth.of((effect, request) => pipe(auth.user(request.headers), flatMap$1((user) => raceFirst(provideService(effect, CurrentUser, user), pipe(delay(auth.user(request.headers), "5 minutes"), retry({ while: (error) => error.error === "temporarily_unavailable" }), forever)))))));
|
|
64857
65062
|
static layer = (resource) => effectContext(gen(function* () {
|
|
64858
65063
|
const url = yield* pipe(String$1("AUTH_URL"), withDefault(AUTH_URL));
|
|
64859
65064
|
const client = filterStatusOk(yield* HttpClient);
|
|
@@ -64973,7 +65178,7 @@ const layerNodeHttpServer = layerConfig(createServer, {
|
|
|
64973
65178
|
port: pipe(Port("PORT"), withDefault(5e3))
|
|
64974
65179
|
});
|
|
64975
65180
|
// package.json
|
|
64976
|
-
var version = "0.1.
|
|
65181
|
+
var version = "0.1.1155";
|
|
64977
65182
|
// src/services/telemetry/schema.ts
|
|
64978
65183
|
var TelemetryError = class extends TaggedError()("TelemetryError", {
|
|
64979
65184
|
cause: optional$6(Defect()),
|
|
@@ -65053,6 +65258,12 @@ const Entry = Struct({
|
|
|
65053
65258
|
time: Nano,
|
|
65054
65259
|
traceId: String$2
|
|
65055
65260
|
});
|
|
65261
|
+
const EntryItem = Entry.mapFields(omit([
|
|
65262
|
+
"resource",
|
|
65263
|
+
"resourceSchemaUrl",
|
|
65264
|
+
"scope",
|
|
65265
|
+
"scopeSchemaUrl"
|
|
65266
|
+
]));
|
|
65056
65267
|
const Query = Struct({
|
|
65057
65268
|
errors: Boolean$2,
|
|
65058
65269
|
from: Finite,
|
|
@@ -65070,7 +65281,7 @@ const Query = Struct({
|
|
|
65070
65281
|
traceId: String$2
|
|
65071
65282
|
});
|
|
65072
65283
|
const Page = Struct({
|
|
65073
|
-
entries: ArraySchema(
|
|
65284
|
+
entries: ArraySchema(EntryItem),
|
|
65074
65285
|
total: Int
|
|
65075
65286
|
});
|
|
65076
65287
|
const Runtime = Literals([
|
|
@@ -65128,9 +65339,9 @@ const Stats = Struct({
|
|
|
65128
65339
|
to: Finite
|
|
65129
65340
|
});
|
|
65130
65341
|
const TraceSpan = Struct({
|
|
65131
|
-
...
|
|
65342
|
+
...EntryItem.fields,
|
|
65132
65343
|
depth: Natural,
|
|
65133
|
-
logs: ArraySchema(
|
|
65344
|
+
logs: ArraySchema(EntryItem),
|
|
65134
65345
|
offsetMs: Finite,
|
|
65135
65346
|
parentSpanId: String$2,
|
|
65136
65347
|
runtime: Runtime
|
|
@@ -65138,7 +65349,7 @@ const TraceSpan = Struct({
|
|
|
65138
65349
|
const Trace = Struct({
|
|
65139
65350
|
durationMs: Finite,
|
|
65140
65351
|
id: TraceId,
|
|
65141
|
-
logs: ArraySchema(
|
|
65352
|
+
logs: ArraySchema(EntryItem),
|
|
65142
65353
|
services: ArraySchema(Service),
|
|
65143
65354
|
spans: ArraySchema(TraceSpan)
|
|
65144
65355
|
});
|
|
@@ -65153,7 +65364,7 @@ const Filters = Struct({
|
|
|
65153
65364
|
});
|
|
65154
65365
|
const PageFilters = Struct({
|
|
65155
65366
|
...Filters.fields,
|
|
65156
|
-
limit: pipe(Query.fields.limit, withDecodingDefaultTypeKey(succeed$4(
|
|
65367
|
+
limit: pipe(Query.fields.limit, withDecodingDefaultTypeKey(succeed$4(20)), annotateEncoded({ description: "Page size, 1 to 1000." })),
|
|
65157
65368
|
offset: pipe(Query.fields.offset, withDecodingDefaultTypeKey(succeed$4(0)), annotateEncoded({ description: "Entries to skip, for the next page." }))
|
|
65158
65369
|
});
|
|
65159
65370
|
const SortFilters = Struct({
|
|
@@ -65177,28 +65388,35 @@ function started(resource) {
|
|
|
65177
65388
|
if (is$2(Nano)(value)) return BigInt(value);
|
|
65178
65389
|
return 0n;
|
|
65179
65390
|
}
|
|
65180
|
-
function
|
|
65391
|
+
function runsOf(entries) {
|
|
65392
|
+
const runs = fromEntries(map$5(entries, (entry) => [entry.id, started(entry.resource)]));
|
|
65393
|
+
return (entry) => runs[entry.id] ?? 0n;
|
|
65394
|
+
}
|
|
65395
|
+
function latestEntry(entries, run) {
|
|
65181
65396
|
return reduce(entries, headNonEmpty(entries), (current, entry) => {
|
|
65182
|
-
if (
|
|
65397
|
+
if (run(entry) > run(current)) return entry;
|
|
65183
65398
|
return current;
|
|
65184
65399
|
});
|
|
65185
65400
|
}
|
|
65186
65401
|
function currentEntries(entries) {
|
|
65187
|
-
const
|
|
65188
|
-
const
|
|
65189
|
-
|
|
65402
|
+
const run = runsOf(entries);
|
|
65403
|
+
const latest = map$6(groupBy(entries, (entry) => entry.service), (group) => run(latestEntry(group, run)));
|
|
65404
|
+
const stale = fromIterable(map$5(filter$1(entries, (entry) => entry.traceId !== "" && run(entry) < (latest[entry.service] ?? 0n)), (entry) => entry.traceId));
|
|
65405
|
+
return filter$1(entries, (entry) => run(entry) === (latest[entry.service] ?? 0n) && !has(stale, entry.traceId));
|
|
65190
65406
|
}
|
|
65191
65407
|
function serviceName(resource) {
|
|
65192
65408
|
const value = resourceString(resource, "service.name");
|
|
65193
65409
|
if (isNonEmpty$1(value)) return value;
|
|
65194
65410
|
return "unknown";
|
|
65195
65411
|
}
|
|
65196
|
-
function
|
|
65197
|
-
|
|
65412
|
+
function leaves(value) {
|
|
65413
|
+
if (isArray(value)) return flatMap$4(value, leaves);
|
|
65414
|
+
if (isString$1(value) || isNumber(value) || isBoolean(value)) return [`${value}`];
|
|
65415
|
+
if (value === null) return [];
|
|
65416
|
+
return flatMap$4(values$2(value), leaves);
|
|
65198
65417
|
}
|
|
65199
65418
|
function logMessage(body) {
|
|
65200
|
-
|
|
65201
|
-
return displayValue(body);
|
|
65419
|
+
return join$1(leaves(body), " ");
|
|
65202
65420
|
}
|
|
65203
65421
|
function durationMs(start, end) {
|
|
65204
65422
|
if (BigInt(end) < BigInt(start)) return 0;
|
|
@@ -65220,9 +65438,16 @@ function summary(entries, query) {
|
|
|
65220
65438
|
};
|
|
65221
65439
|
}
|
|
65222
65440
|
function filterEntries(entries, query, signal) {
|
|
65441
|
+
const text = toLowerCase(query.text);
|
|
65442
|
+
const traceId = toLowerCase(query.traceId);
|
|
65223
65443
|
return filter$1(entries, (entry) => {
|
|
65224
65444
|
const milliseconds = pipe(parse$2(`${BigInt(entry.time) / 1000000n}`), getOrThrow$1);
|
|
65225
|
-
return (signal === "all" || entry.signal === signal) && milliseconds >= query.from && milliseconds <= query.to && (query.service === "" || entry.service === query.service) && (query.operation === "" || entry.name === query.operation) && (
|
|
65445
|
+
return (signal === "all" || entry.signal === signal) && milliseconds >= query.from && milliseconds <= query.to && (query.service === "" || entry.service === query.service) && (query.operation === "" || entry.name === query.operation) && (traceId === "" || entry.traceId === traceId) && (!query.errors || entry.status === 2) && (text === "" || includes(text)(toLowerCase(join$1([entry.name, ...leaves(pick(entry.payload, [
|
|
65446
|
+
"attributes",
|
|
65447
|
+
"body",
|
|
65448
|
+
"events",
|
|
65449
|
+
"status"
|
|
65450
|
+
]))], " "))));
|
|
65226
65451
|
});
|
|
65227
65452
|
}
|
|
65228
65453
|
function orderEntries(entries, sort$1) {
|
|
@@ -65232,10 +65457,11 @@ function orderEntries(entries, sort$1) {
|
|
|
65232
65457
|
}));
|
|
65233
65458
|
}
|
|
65234
65459
|
function serviceStatuses(entries) {
|
|
65460
|
+
const runOf = runsOf(entries);
|
|
65235
65461
|
return collect$1(groupBy(entries, (entry) => entry.service), (name, group) => {
|
|
65236
|
-
const latest = latestEntry(group);
|
|
65237
|
-
const run =
|
|
65238
|
-
const current = filter$1(group, (entry) =>
|
|
65462
|
+
const latest = latestEntry(group, runOf);
|
|
65463
|
+
const run = runOf(latest);
|
|
65464
|
+
const current = filter$1(group, (entry) => runOf(entry) === run);
|
|
65239
65465
|
return {
|
|
65240
65466
|
entries: current.length,
|
|
65241
65467
|
lastEventAt: reduce(current, "0", (time, entry) => {
|
|
@@ -65248,6 +65474,20 @@ function serviceStatuses(entries) {
|
|
|
65248
65474
|
};
|
|
65249
65475
|
});
|
|
65250
65476
|
}
|
|
65477
|
+
function traceTiming(records) {
|
|
65478
|
+
const spans = filter$1(records, (entry) => entry.signal === "trace");
|
|
65479
|
+
const start = match$3(match$3(spans, {
|
|
65480
|
+
onEmpty: () => records,
|
|
65481
|
+
onNonEmpty: identity
|
|
65482
|
+
}), {
|
|
65483
|
+
onEmpty: () => "0",
|
|
65484
|
+
onNonEmpty: (timed) => min(map$5(timed, (entry) => entry.time), mapInput(BigInt$5, (time) => BigInt(time)))
|
|
65485
|
+
});
|
|
65486
|
+
return {
|
|
65487
|
+
durationMs: reduce(spans, 0, (end, span) => max(end, durationMs(start, span.time) + span.durationMs)),
|
|
65488
|
+
time: start
|
|
65489
|
+
};
|
|
65490
|
+
}
|
|
65251
65491
|
function parentId(entry) {
|
|
65252
65492
|
if (isString$1(entry.payload["parentSpanId"])) return toLowerCase(entry.payload["parentSpanId"]);
|
|
65253
65493
|
return "";
|
|
@@ -65259,13 +65499,10 @@ function traceView(entries, id) {
|
|
|
65259
65499
|
index
|
|
65260
65500
|
}));
|
|
65261
65501
|
const byId = fromEntries(map$5(spans, (span) => [span.entry.spanId, span]));
|
|
65262
|
-
const
|
|
65263
|
-
onNone: () => "0",
|
|
65264
|
-
onSome: (entry) => entry.time
|
|
65265
|
-
}));
|
|
65502
|
+
const timing = traceTiming(entries);
|
|
65266
65503
|
const logs = filter$1(ordered, (entry) => entry.signal === "log");
|
|
65267
65504
|
const bySpan = groupBy(logs, (log) => log.spanId);
|
|
65268
|
-
const
|
|
65505
|
+
const tree = pipe(map$5(spans, (span) => {
|
|
65269
65506
|
const ancestors = reverse(unfold({
|
|
65270
65507
|
entry: span.entry,
|
|
65271
65508
|
seen: make$44(span.entry.spanId)
|
|
@@ -65279,15 +65516,14 @@ function traceView(entries, id) {
|
|
|
65279
65516
|
...span.entry,
|
|
65280
65517
|
depth: ancestors.length,
|
|
65281
65518
|
logs: getOrElse(get$9(bySpan, span.entry.spanId), () => []),
|
|
65282
|
-
offsetMs: durationMs(
|
|
65519
|
+
offsetMs: durationMs(timing.time, span.entry.time),
|
|
65283
65520
|
parentSpanId: parentId(span.entry),
|
|
65284
65521
|
runtime: runtime(span.entry.resource)
|
|
65285
65522
|
}
|
|
65286
65523
|
};
|
|
65287
|
-
});
|
|
65288
|
-
const tree = pipe(nodes, sort(Struct$1({ path: Array_(Number$5) })), map$5((node) => node.value));
|
|
65524
|
+
}), sort(Struct$1({ path: Array_(Number$5) })), map$5((node) => node.value));
|
|
65289
65525
|
return {
|
|
65290
|
-
durationMs:
|
|
65526
|
+
durationMs: timing.durationMs,
|
|
65291
65527
|
id,
|
|
65292
65528
|
logs: filter$1(logs, (log) => !has$3(byId, log.spanId)),
|
|
65293
65529
|
services: dedupeWith(map$5([...tree, ...logs], (entry) => ({
|
|
@@ -65298,18 +65534,35 @@ function traceView(entries, id) {
|
|
|
65298
65534
|
};
|
|
65299
65535
|
}
|
|
65300
65536
|
// src/services/telemetry/service.ts
|
|
65537
|
+
const RETENTION = days(3);
|
|
65301
65538
|
const failed = mapError$2((cause) => TelemetryError.make({
|
|
65302
65539
|
cause,
|
|
65303
65540
|
message: "The telemetry storage could not be read or written."
|
|
65304
65541
|
}));
|
|
65305
65542
|
var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/service/Telemetry", { make: fnUntraced(function* (directory) {
|
|
65306
65543
|
const fs = yield* FileSystem;
|
|
65544
|
+
const path = yield* Path$1;
|
|
65307
65545
|
const store = toSchemaStore(yield* KeyValueStore, Entry);
|
|
65308
65546
|
const crypto = yield* Crypto;
|
|
65309
65547
|
const since = yield* currentTimeMillis;
|
|
65310
65548
|
const rejections = yield* make$48(empty$11());
|
|
65311
|
-
const saved = yield* forEach$1(
|
|
65549
|
+
const saved = yield* forEach$1(yield* fs.readDirectory(directory), (file) => pipe(try_(() => decodeURIComponent(file)), filterOrFail((key) => !endsWith(".tmp")(key)), flatMap$1((key) => store.get(key)), catch_$2(() => as(fs.remove(path.join(directory, file), { force: true }), none()))), { concurrency: 8 });
|
|
65312
65550
|
const state = yield* make$9(fromIterable$2(map$5(getSomes(saved), (entry) => [entry.id, entry])));
|
|
65551
|
+
const prune = gen(function* () {
|
|
65552
|
+
const cutoff = BigInt((yield* currentTimeMillis) - toMillis(RETENTION)) * 1000000n;
|
|
65553
|
+
yield* updateEffect(state, (current) => {
|
|
65554
|
+
const expired = filter$1(fromIterable$6(values(current)), (entry) => BigInt(entry.time) < cutoff);
|
|
65555
|
+
return as(forEach$1(expired, (entry) => store.remove(entry.id), {
|
|
65556
|
+
concurrency: 1,
|
|
65557
|
+
discard: true
|
|
65558
|
+
}), reduce(expired, current, (all, entry) => remove$1(all, entry.id)));
|
|
65559
|
+
});
|
|
65560
|
+
});
|
|
65561
|
+
yield* prune;
|
|
65562
|
+
yield* pipe(prune, ignore$1({
|
|
65563
|
+
log: "Warn",
|
|
65564
|
+
message: "Expired telemetry could not be deleted"
|
|
65565
|
+
}), repeat(spaced("1 hour")), forkScoped);
|
|
65313
65566
|
const read = map$2(get(state), (entries) => fromIterable$6(values(entries)));
|
|
65314
65567
|
const selected = fnUntraced(function* (runs) {
|
|
65315
65568
|
const entries = yield* read;
|
|
@@ -65400,36 +65653,37 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
|
|
|
65400
65653
|
return summary(filterEntries(yield* selected(query.runs), query, "trace"), query);
|
|
65401
65654
|
}),
|
|
65402
65655
|
trace: fn("Telemetry.trace")(function* (id) {
|
|
65403
|
-
const
|
|
65404
|
-
|
|
65405
|
-
|
|
65656
|
+
const traceId = toLowerCase(id);
|
|
65657
|
+
const records = filter$1(yield* read, (entry) => entry.traceId === traceId);
|
|
65658
|
+
if (isReadonlyArrayEmpty(records)) return yield* TelemetryError.make({ message: "No telemetry received for this trace." });
|
|
65659
|
+
return traceView(records, traceId);
|
|
65406
65660
|
}),
|
|
65407
65661
|
traces: fn("Telemetry.traces")(function* (query) {
|
|
65408
65662
|
const active = yield* selected(query.runs);
|
|
65409
65663
|
const byTrace = groupBy(active, (entry) => entry.traceId);
|
|
65410
|
-
const
|
|
65411
|
-
|
|
65412
|
-
|
|
65413
|
-
|
|
65414
|
-
|
|
65415
|
-
durationMs: view.durationMs,
|
|
65416
|
-
errors: countBy(records, (entry) => entry.status === 2),
|
|
65417
|
-
id,
|
|
65418
|
-
logs: countBy(records, (entry) => entry.signal === "log"),
|
|
65419
|
-
operation: root.name,
|
|
65420
|
-
service: root.service,
|
|
65421
|
-
services: view.services,
|
|
65422
|
-
spans: view.spans.length,
|
|
65423
|
-
time: root.time
|
|
65424
|
-
};
|
|
65425
|
-
});
|
|
65426
|
-
const sorted = sort(entries, match$1(query.sort === "slowest", {
|
|
65427
|
-
onFalse: () => flip$2(mapInput(BigInt$5, (entry) => BigInt(entry.time))),
|
|
65428
|
-
onTrue: () => flip$2(mapInput(Number$5, (entry) => entry.durationMs))
|
|
65429
|
-
}));
|
|
65664
|
+
const ids = dedupe(map$5(filter$1(filterEntries(active, query, "all"), (entry) => entry.traceId !== ""), (entry) => entry.traceId));
|
|
65665
|
+
const ordered = orderEntries(map$5(ids, (id) => ({
|
|
65666
|
+
id,
|
|
65667
|
+
...traceTiming(byTrace[id] ?? [])
|
|
65668
|
+
})), query.sort);
|
|
65430
65669
|
return {
|
|
65431
|
-
entries: take$3(drop$1(
|
|
65432
|
-
|
|
65670
|
+
entries: map$5(take$3(drop$1(ordered, query.offset), query.limit), (found) => {
|
|
65671
|
+
const records = byTrace[found.id] ?? [];
|
|
65672
|
+
const view = traceView(records, found.id);
|
|
65673
|
+
const root = getOrElse(head(view.spans), () => getOrThrow$1(head(records)));
|
|
65674
|
+
return {
|
|
65675
|
+
durationMs: found.durationMs,
|
|
65676
|
+
errors: countBy(records, (entry) => entry.status === 2),
|
|
65677
|
+
id: found.id,
|
|
65678
|
+
logs: countBy(records, (entry) => entry.signal === "log"),
|
|
65679
|
+
operation: root.name,
|
|
65680
|
+
service: root.service,
|
|
65681
|
+
services: view.services,
|
|
65682
|
+
spans: view.spans.length,
|
|
65683
|
+
time: found.time
|
|
65684
|
+
};
|
|
65685
|
+
}),
|
|
65686
|
+
total: ids.length
|
|
65433
65687
|
};
|
|
65434
65688
|
})
|
|
65435
65689
|
};
|
|
@@ -65438,7 +65692,7 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
|
|
|
65438
65692
|
};
|
|
65439
65693
|
// src/tools/contracts.ts
|
|
65440
65694
|
const Tools = make$6(make$7("list_services", {
|
|
65441
|
-
description: "Check ingestion first: every stored service, its runtime, latest run, last event time and entry count. Event/run times use the exporter clock (Unix nanoseconds), not receiver arrival time. Rejected OTLP requests are grouped by route, HTTP status and credential-header presence, never attributed to an app. Rejection counters and since (Unix milliseconds) reset when Scope restarts. Missing services
|
|
65695
|
+
description: "Check ingestion first: every stored service, its runtime, latest run, last event time and entry count. Event/run times use the exporter clock (Unix nanoseconds), not receiver arrival time. Rejected OTLP requests are grouped by route, HTTP status and credential-header presence, never attributed to an app. Rejection counters and since (Unix milliseconds) reset when Scope restarts. Missing services sent no telemetry in the last three days.",
|
|
65442
65696
|
failure: TelemetryError,
|
|
65443
65697
|
success: IngestionStatus
|
|
65444
65698
|
}).annotate(Readonly, true), make$7("find_traces", {
|
|
@@ -65491,12 +65745,10 @@ const ToolHandlers = Tools.toLayer(gen(function* () {
|
|
|
65491
65745
|
});
|
|
65492
65746
|
}));
|
|
65493
65747
|
// src/main.server.ts
|
|
65494
|
-
|
|
65495
|
-
|
|
65496
|
-
const ack = text("{}", { contentType: "application/json" });
|
|
65497
|
-
yield* router.add("POST", "/v1/traces", (request) => {
|
|
65748
|
+
function ingest(schema, save) {
|
|
65749
|
+
return (request) => {
|
|
65498
65750
|
if (!startsWith("application/json")(request.headers["content-type"] ?? "")) return succeed$4(empty({ status: 415 }));
|
|
65499
|
-
return pipe(schemaBodyJson(
|
|
65751
|
+
return pipe(schemaBodyJson(schema), flatMap$1(save), as(text("{}", { contentType: "application/json" })), catchTags({
|
|
65500
65752
|
HttpServerError: () => succeed$4(jsonUnsafe({
|
|
65501
65753
|
code: 3,
|
|
65502
65754
|
message: "Invalid OTLP JSON body"
|
|
@@ -65510,27 +65762,15 @@ const receiver = use((router) => gen(function* () {
|
|
|
65510
65762
|
message: "Telemetry storage unavailable"
|
|
65511
65763
|
}, { status: 503 }))
|
|
65512
65764
|
}));
|
|
65513
|
-
}
|
|
65514
|
-
|
|
65515
|
-
|
|
65516
|
-
|
|
65517
|
-
|
|
65518
|
-
|
|
65519
|
-
message: "Invalid OTLP JSON body"
|
|
65520
|
-
}, { status: 400 })),
|
|
65521
|
-
SchemaError: (error) => succeed$4(jsonUnsafe({
|
|
65522
|
-
code: 3,
|
|
65523
|
-
message: error.message
|
|
65524
|
-
}, { status: 400 })),
|
|
65525
|
-
TelemetryError: () => succeed$4(jsonUnsafe({
|
|
65526
|
-
code: 14,
|
|
65527
|
-
message: "Telemetry storage unavailable"
|
|
65528
|
-
}, { status: 503 }))
|
|
65529
|
-
}));
|
|
65530
|
-
});
|
|
65765
|
+
};
|
|
65766
|
+
}
|
|
65767
|
+
const receiver = use((router) => gen(function* () {
|
|
65768
|
+
const telemetry = yield* Telemetry;
|
|
65769
|
+
yield* router.add("POST", "/v1/traces", ingest(TracesRequest, telemetry.ingestTraces));
|
|
65770
|
+
yield* router.add("POST", "/v1/logs", ingest(LogsRequest, telemetry.ingestLogs));
|
|
65531
65771
|
yield* router.add("GET", "/health", text("ready"));
|
|
65532
65772
|
}));
|
|
65533
|
-
const observe = make$28((app) => pipe(app,
|
|
65773
|
+
const observe = make$28((app) => pipe(app, onExit$1((exit) => gen(function* () {
|
|
65534
65774
|
const request = yield* HttpServerRequest;
|
|
65535
65775
|
const route = headNonEmpty(split(request.url, "?"));
|
|
65536
65776
|
const status = exitResponse(exit).status;
|
|
@@ -65556,14 +65796,6 @@ const telemetry = unwrap$5(gen(function* () {
|
|
|
65556
65796
|
const path = yield* Path$1;
|
|
65557
65797
|
const directory = path.join(yield* String$1("HOME"), ".deslop", "scope");
|
|
65558
65798
|
yield* fs.makeDirectory(directory, { recursive: true });
|
|
65559
|
-
yield* forEach$1([
|
|
65560
|
-
"telemetry.sqlite",
|
|
65561
|
-
"telemetry.sqlite-wal",
|
|
65562
|
-
"telemetry.sqlite-shm"
|
|
65563
|
-
], (name) => fs.remove(path.join(directory, name), { force: true }), {
|
|
65564
|
-
concurrency: 1,
|
|
65565
|
-
discard: true
|
|
65566
|
-
});
|
|
65567
65799
|
return Telemetry.layer(path.join(directory, "entries"));
|
|
65568
65800
|
}));
|
|
65569
65801
|
runMain(pipe(merge$3(pipe(serve(mergeAll$1(pipe(fresh(receiver), provide$2(HttpAuth.layer)), mcp, cors({
|