@deslop/scope 0.1.1109 → 0.1.1112

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.
Files changed (2) hide show
  1. package/dist/server.js +127 -2503
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -389,7 +389,7 @@ const constVoid = constUndefined;
389
389
  * @category combinators
390
390
  * @since 2.0.0
391
391
  */
392
- const compose$1 = /*#__PURE__*/ dual(2, (ab, bc) => (a) => bc(ab(a)));
392
+ const compose = /*#__PURE__*/ dual(2, (ab, bc) => (a) => bc(ab(a)));
393
393
  function pipe(a, ...args) {
394
394
  return pipeArguments(a, args);
395
395
  }
@@ -3728,38 +3728,6 @@ const isLessThanOrEqualTo$1 = (O) => dual(2, (self, that) => O(self, that) !== 1
3728
3728
  */
3729
3729
  const isGreaterThanOrEqualTo$2 = (O) => dual(2, (self, that) => O(self, that) !== -1);
3730
3730
  /**
3731
- * Returns the minimum of two values according to the given order. If they are equal, returns the first argument.
3732
- *
3733
- * **When to use**
3734
- *
3735
- * Use when you need to select the smaller of two values according to an
3736
- * `Order`.
3737
- *
3738
- * **Details**
3739
- *
3740
- * Returns the value that compares as less than or equal to the other value. If
3741
- * values are equal, the first argument is returned.
3742
- *
3743
- * **Example** (Selecting the minimum value)
3744
- *
3745
- * ```ts import.meta.vitest
3746
- * import { Order } from "effect"
3747
- *
3748
- * const minNumber = Order.min(Order.Number)
3749
- *
3750
- * minNumber(1, 2) // => 1
3751
- * minNumber(2, 1) // => 1
3752
- * minNumber(1, 1) // => 1
3753
- * ```
3754
- *
3755
- * @see {@link max} for the maximum of two values
3756
- * @see {@link clamp} to clamp a value between min and max
3757
- * @stability stable
3758
- * @category comparisons
3759
- * @since 2.0.0
3760
- */
3761
- const min$1 = (O) => dual(2, (self, that) => self === that || O(self, that) < 1 ? self : that);
3762
- /**
3763
3731
  * Returns the maximum of two values according to the given order. If they are equal, returns the first argument.
3764
3732
  *
3765
3733
  * **When to use**
@@ -4464,7 +4432,7 @@ const ServiceProto = {
4464
4432
  .../*#__PURE__*/ Prototype({
4465
4433
  label: "Service",
4466
4434
  evaluate(fiber) {
4467
- return exitSucceed(get$10(fiber.context, this));
4435
+ return exitSucceed(get$9(fiber.context, this));
4468
4436
  }
4469
4437
  }),
4470
4438
  toJSON() {
@@ -4480,10 +4448,10 @@ const ServiceProto = {
4480
4448
  return make$73(this, self);
4481
4449
  },
4482
4450
  use(f) {
4483
- return withFiber$1((fiber) => f(get$10(fiber.context, this)));
4451
+ return withFiber$1((fiber) => f(get$9(fiber.context, this)));
4484
4452
  },
4485
4453
  useSync(f) {
4486
- return withFiber$1((fiber) => exitSucceed(f(get$10(fiber.context, this))));
4454
+ return withFiber$1((fiber) => exitSucceed(f(get$9(fiber.context, this))));
4487
4455
  }
4488
4456
  };
4489
4457
  const cacheKeys = /*#__PURE__*/ new Set();
@@ -4844,7 +4812,7 @@ const getUnsafe = /*#__PURE__*/ dual(2, (self, service) => {
4844
4812
  * @category getters
4845
4813
  * @since 2.0.0
4846
4814
  */
4847
- const get$10 = getUnsafe;
4815
+ const get$9 = getUnsafe;
4848
4816
  const defaultValueCacheKey = "~effect/Context/defaultValue";
4849
4817
  const getDefaultValue = (ref) => {
4850
4818
  if (defaultValueCacheKey in ref) return ref[defaultValueCacheKey];
@@ -6441,7 +6409,7 @@ const has$3 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key));
6441
6409
  * @category getters
6442
6410
  * @since 2.0.0
6443
6411
  */
6444
- const get$9 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key) ? some$1(self[key]) : none());
6412
+ const get$8 = /*#__PURE__*/ dual(2, (self, key) => Object.hasOwn(self, key) ? some$1(self[key]) : none());
6445
6413
  /**
6446
6414
  * Maps a record into another record by applying a transformation function to each of its values.
6447
6415
  *
@@ -6506,28 +6474,6 @@ const filter$2 = /*#__PURE__*/ dual(2, (self, predicate) => {
6506
6474
  */
6507
6475
  const keys$1 = (self) => Object.keys(self);
6508
6476
  /**
6509
- * Adds a new key-value pair or update an existing key's value in a record.
6510
- *
6511
- * **Example** (Setting a record value)
6512
- *
6513
- * ```ts import.meta.vitest
6514
- * import { Record } from "effect"
6515
- *
6516
- * Record.set("a", 5)({ a: 1, b: 2 }) // => { a: 5, b: 2 }
6517
- * Record.set("c", 5)({ a: 1, b: 2 }) // => { a: 1, b: 2, c: 5 }
6518
- * ```
6519
- *
6520
- * @stability stable
6521
- * @category mutations
6522
- * @since 2.0.0
6523
- */
6524
- const set$4 = /*#__PURE__*/ dual(3, (self, key, value) => {
6525
- return {
6526
- ...self,
6527
- [key]: value
6528
- };
6529
- });
6530
- /**
6531
6477
  * Checks whether all the keys and values in one record are also found in another record.
6532
6478
  * Uses the provided equivalence function to compare values.
6533
6479
  *
@@ -6616,7 +6562,7 @@ const makeEquivalence$2 = (equivalence) => {
6616
6562
  * @category constructors
6617
6563
  * @since 4.0.0
6618
6564
  */
6619
- const Array$2 = globalThis.Array;
6565
+ const Array$1 = globalThis.Array;
6620
6566
  /**
6621
6567
  * Converts an `Iterable` to an `Array`.
6622
6568
  *
@@ -6645,7 +6591,7 @@ const Array$2 = globalThis.Array;
6645
6591
  * @category constructors
6646
6592
  * @since 2.0.0
6647
6593
  */
6648
- const fromIterable$5 = (collection) => Array$2.isArray(collection) ? collection : Array$2.from(collection);
6594
+ const fromIterable$5 = (collection) => Array$1.isArray(collection) ? collection : Array$1.from(collection);
6649
6595
  /**
6650
6596
  * Adds a single element to the end of an iterable, returning a `NonEmptyArray`.
6651
6597
  *
@@ -6670,7 +6616,7 @@ const fromIterable$5 = (collection) => Array$2.isArray(collection) ? collection
6670
6616
  * @since 2.0.0
6671
6617
  */
6672
6618
  const append$1 = /*#__PURE__*/ dual(2, (self, last) => [...self, last]);
6673
- Array$2.isArray;
6619
+ Array$1.isArray;
6674
6620
  /**
6675
6621
  * Checks whether a mutable `Array` is empty, narrowing the type to `[]`.
6676
6622
  *
@@ -6808,7 +6754,7 @@ function isOutOfBounds(i, as) {
6808
6754
  * @category getters
6809
6755
  * @since 2.0.0
6810
6756
  */
6811
- const get$8 = /*#__PURE__*/ dual(2, (self, index) => {
6757
+ const get$7 = /*#__PURE__*/ dual(2, (self, index) => {
6812
6758
  const i = Math.floor(index);
6813
6759
  return isOutOfBounds(i, self) ? none() : some$1(self[i]);
6814
6760
  });
@@ -6836,7 +6782,7 @@ const get$8 = /*#__PURE__*/ dual(2, (self, index) => {
6836
6782
  * @category getters
6837
6783
  * @since 2.0.0
6838
6784
  */
6839
- const head = /*#__PURE__*/ get$8(0);
6785
+ const head = /*#__PURE__*/ get$7(0);
6840
6786
  /**
6841
6787
  * Returns the last element of a `NonEmptyReadonlyArray` directly (no `Option`
6842
6788
  * wrapper).
@@ -6983,7 +6929,7 @@ const findFirst = findFirst$1;
6983
6929
  * @category transforming
6984
6930
  * @since 2.0.0
6985
6931
  */
6986
- const reverse = (self) => Array$2.from(self).reverse();
6932
+ const reverse = (self) => Array$1.from(self).reverse();
6987
6933
  /**
6988
6934
  * Sorts an array by the given `Order`, returning a new array.
6989
6935
  *
@@ -7012,7 +6958,7 @@ const reverse = (self) => Array$2.from(self).reverse();
7012
6958
  * @since 2.0.0
7013
6959
  */
7014
6960
  const sort = /*#__PURE__*/ dual(2, (self, O) => {
7015
- const out = Array$2.from(self);
6961
+ const out = Array$1.from(self);
7016
6962
  out.sort(O);
7017
6963
  return out;
7018
6964
  });
@@ -7297,31 +7243,6 @@ const filter$1 = /*#__PURE__*/ dual(2, (self, predicate) => {
7297
7243
  */
7298
7244
  const reduce = /*#__PURE__*/ dual(3, (self, b, f) => fromIterable$5(self).reduce((b, a, i) => f(b, a, i), b));
7299
7245
  /**
7300
- * Checks whether all elements satisfy the predicate. Supports refinements for
7301
- * type narrowing.
7302
- *
7303
- * **When to use**
7304
- *
7305
- * Use to check whether every array element satisfies a predicate, including
7306
- * refinement-based type narrowing.
7307
- *
7308
- * **Example** (Testing all elements)
7309
- *
7310
- * ```ts import.meta.vitest
7311
- * import { Array } from "effect"
7312
- *
7313
- * Array.every([2, 4, 6], (x) => x % 2 === 0) // => true
7314
- * Array.every([2, 3, 6], (x) => x % 2 === 0) // => false
7315
- * ```
7316
- *
7317
- * @see {@link some} — test if any element matches
7318
- *
7319
- * @stability stable
7320
- * @category guards
7321
- * @since 2.0.0
7322
- */
7323
- const every$1 = /*#__PURE__*/ dual(2, (self, refinement) => self.every(refinement));
7324
- /**
7325
7246
  * Checks whether at least one element satisfies the predicate. Narrows the type
7326
7247
  * to `NonEmptyReadonlyArray` on success.
7327
7248
  *
@@ -7362,7 +7283,7 @@ const some = /*#__PURE__*/ dual(2, (self, predicate) => self.some(predicate));
7362
7283
  * @category constructors
7363
7284
  * @since 2.0.0
7364
7285
  */
7365
- const unfold$1 = (b, f) => {
7286
+ const unfold = (b, f) => {
7366
7287
  const out = [];
7367
7288
  let next = b;
7368
7289
  while (true) {
@@ -7460,24 +7381,6 @@ const dedupe = (self) => {
7460
7381
  for (const value of input) if (hashBucketsAdd(buckets, value)) out.push(value);
7461
7382
  return out;
7462
7383
  };
7463
- /**
7464
- * Joins string elements with a separator.
7465
- *
7466
- * **Example** (Joining strings)
7467
- *
7468
- * ```ts import.meta.vitest
7469
- * import { Array } from "effect"
7470
- *
7471
- * Array.join(["a", "b", "c"], "-") // => "a-b-c"
7472
- * ```
7473
- *
7474
- * @see {@link intersperse} — insert separator elements without joining
7475
- *
7476
- * @stability stable
7477
- * @category folding
7478
- * @since 2.0.0
7479
- */
7480
- const join$2 = /*#__PURE__*/ dual(2, (self, sep) => fromIterable$5(self).join(sep));
7481
7384
  //#endregion
7482
7385
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Scheduler.js
7483
7386
  /**
@@ -8701,7 +8604,7 @@ var FiberImpl = class {
8701
8604
  return this._dispatcher ??= this.cache.scheduler.makeDispatcher();
8702
8605
  }
8703
8606
  getRef(ref) {
8704
- return get$10(this.context, ref);
8607
+ return get$9(this.context, ref);
8705
8608
  }
8706
8609
  addObserver(cb) {
8707
8610
  if (this._exit) {
@@ -8859,17 +8762,17 @@ var FiberImpl = class {
8859
8762
  const makeFiberContextCache = (context) => {
8860
8763
  const currentTracer = getOrUndefinedUnsafe(context, TracerKey);
8861
8764
  return {
8862
- scheduler: get$10(context, Scheduler),
8765
+ scheduler: get$9(context, Scheduler),
8863
8766
  tracer: currentTracer,
8864
8767
  tracerContext: currentTracer ? currentTracer["context"] : void 0,
8865
- tracerEnabled: get$10(context, TracerEnabled),
8768
+ tracerEnabled: get$9(context, TracerEnabled),
8866
8769
  span: getOrUndefinedUnsafe(context, ParentSpanKey),
8867
- logLevel: get$10(context, CurrentLogLevel$1),
8868
- minimumLogLevel: get$10(context, MinimumLogLevel),
8869
- stackFrame: get$10(context, CurrentStackFrame),
8770
+ logLevel: get$9(context, CurrentLogLevel$1),
8771
+ minimumLogLevel: get$9(context, MinimumLogLevel),
8772
+ stackFrame: get$9(context, CurrentStackFrame),
8870
8773
  runtimeMetrics: getOrUndefinedUnsafe(context, FiberRuntimeMetricsKey),
8871
- maxOpsBeforeYield: get$10(context, MaxOpsBeforeYield),
8872
- preventYield: get$10(context, PreventSchedulerYield)
8774
+ maxOpsBeforeYield: get$9(context, MaxOpsBeforeYield),
8775
+ preventYield: get$9(context, PreventSchedulerYield)
8873
8776
  };
8874
8777
  };
8875
8778
  const deferredInterruptCont = {
@@ -10350,11 +10253,11 @@ const NoopSpanProto = {
10350
10253
  const noopSpan = (options) => Object.assign(Object.create(NoopSpanProto), options);
10351
10254
  const filterDisablePropagation = (span) => {
10352
10255
  if (!span) return none();
10353
- return get$10(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$1(span.parent)) : none() : some$1(span);
10256
+ return get$9(span.annotations, DisablePropagation) ? span._tag === "Span" ? filterDisablePropagation(getOrUndefined$1(span.parent)) : none() : some$1(span);
10354
10257
  };
10355
10258
  /** @internal */
10356
10259
  const makeSpanUnsafe = (fiber, name, options) => {
10357
- const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get$10(options.annotations, DisablePropagation);
10260
+ const disablePropagation = !fiber.cache.tracerEnabled || options?.annotations && get$9(options.annotations, DisablePropagation);
10358
10261
  const parent = options?.parent !== void 0 ? some$1(options.parent) : options?.root ? none() : filterDisablePropagation(fiber.cache.span);
10359
10262
  let span;
10360
10263
  if (disablePropagation) span = noopSpan({
@@ -11659,7 +11562,7 @@ const makeUnsafe$6 = scopeMakeUnsafe;
11659
11562
  * @category combinators
11660
11563
  * @since 4.0.0
11661
11564
  */
11662
- const provide$4 = provideScope;
11565
+ const provide$3 = provideScope;
11663
11566
  /**
11664
11567
  * Registers an exit-aware finalizer on a scope.
11665
11568
  *
@@ -12425,7 +12328,7 @@ const effectImpl = (service, effect) => effectContext(map$4(effect, (value) => m
12425
12328
  * @category constructors
12426
12329
  * @since 2.0.0
12427
12330
  */
12428
- const effectContext = (effect) => fromBuildMemo((_, scope) => provide$4(effect, scope));
12331
+ const effectContext = (effect) => fromBuildMemo((_, scope) => provide$3(effect, scope));
12429
12332
  /**
12430
12333
  * Constructs a layer from an effect, discarding its value and providing no
12431
12334
  * services.
@@ -12493,7 +12396,7 @@ const unwrapKey = /*#__PURE__*/ Service$2("effect/Layer/unwrap");
12493
12396
  * @category converting
12494
12397
  * @since 4.0.0
12495
12398
  */
12496
- const unwrap$5 = (self) => flatMap$2(effect(unwrapKey)(self), get$10(unwrapKey));
12399
+ const unwrap$5 = (self) => flatMap$2(effect(unwrapKey)(self), get$9(unwrapKey));
12497
12400
  const mergeAllEffect = (layers, memoMap, scope) => {
12498
12401
  const parentScope = forkUnsafe(scope, "parallel");
12499
12402
  return forEach$2(layers, (layer) => layer.build(memoMap, forkUnsafe(parentScope, "sequential")), { concurrency: layers.length }).pipe(map$4((context) => mergeAll$2(...context)));
@@ -12677,7 +12580,7 @@ const provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap$3(A
12677
12580
  * @category providing services
12678
12581
  * @since 2.0.0
12679
12582
  */
12680
- const provide$3 = /*#__PURE__*/ dual(2, (self, that) => provideWith(self, that, identity));
12583
+ const provide$2 = /*#__PURE__*/ dual(2, (self, that) => provideWith(self, that, identity));
12681
12584
  /**
12682
12585
  * Feeds the output services of the dependency layer into the requirements of
12683
12586
  * this layer, returning a layer that provides both sets of services.
@@ -13940,51 +13843,6 @@ const formatIso$1 = (self) => toDateUtc$1(self).toISOString();
13940
13843
  */
13941
13844
  const Number$4 = globalThis.Number;
13942
13845
  /**
13943
- * Order instance for `number` values.
13944
- *
13945
- * **When to use**
13946
- *
13947
- * Use when you need to sort or compare numbers through APIs that accept an
13948
- * ordering instance.
13949
- *
13950
- * **Example** (Comparing numbers)
13951
- *
13952
- * ```ts import.meta.vitest
13953
- * import { Number } from "effect"
13954
- *
13955
- * Number.Order(1, 2) // => -1
13956
- * Number.Order(2, 1) // => 1
13957
- * Number.Order(1, 1) // => 0
13958
- * ```
13959
- *
13960
- * @stability stable
13961
- * @category instances
13962
- * @since 2.0.0
13963
- */
13964
- const Order$2 = Number$5;
13965
- /**
13966
- * Returns the minimum between two `number`s.
13967
- *
13968
- * **When to use**
13969
- *
13970
- * Use to select the smaller of two numbers.
13971
- *
13972
- * **Example** (Finding the minimum)
13973
- *
13974
- * ```ts import.meta.vitest
13975
- * import { Number } from "effect"
13976
- *
13977
- * Number.min(2, 3) // => 2
13978
- * ```
13979
- *
13980
- * @see {@link max} for selecting the larger value
13981
- *
13982
- * @stability stable
13983
- * @category math
13984
- * @since 2.0.0
13985
- */
13986
- const min = /*#__PURE__*/ min$1(Order$2);
13987
- /**
13988
13846
  * Returns the maximum between two `number`s.
13989
13847
  *
13990
13848
  * **When to use**
@@ -14005,31 +13863,7 @@ const min = /*#__PURE__*/ min$1(Order$2);
14005
13863
  * @category math
14006
13864
  * @since 2.0.0
14007
13865
  */
14008
- const max = /*#__PURE__*/ max$1(Order$2);
14009
- /**
14010
- * Returns the next power of 2 from the given number.
14011
- *
14012
- * **When to use**
14013
- *
14014
- * Use to round a number up to the next power of two.
14015
- *
14016
- * **Example** (Finding the next power of two)
14017
- *
14018
- * ```ts import.meta.vitest
14019
- * import { Number } from "effect"
14020
- *
14021
- * Number.nextPow2(5) // => 8
14022
- * Number.nextPow2(17) // => 32
14023
- * ```
14024
- *
14025
- * @stability stable
14026
- * @category math
14027
- * @since 2.0.0
14028
- */
14029
- const nextPow2 = (n) => {
14030
- const nextPow = Math.ceil(Math.log(n) / Math.log(2));
14031
- return Math.max(Math.pow(2, nextPow), 2);
14032
- };
13866
+ const max = /*#__PURE__*/ max$1(Number$5);
14033
13867
  /**
14034
13868
  * Parses a `number` from a `string` safely using the `Number()` function.
14035
13869
  * The following special string values are supported: "NaN", "Infinity", "-Infinity".
@@ -14101,62 +13935,6 @@ const isString$1 = isString$2;
14101
13935
  */
14102
13936
  const toLowerCase = (self) => self.toLowerCase();
14103
13937
  /**
14104
- * Replaces matches in a string using `String.prototype.replace`.
14105
- *
14106
- * **Details**
14107
- *
14108
- * String search values and non-global regular expressions replace the first
14109
- * match; global regular expressions replace every match.
14110
- *
14111
- * **Example** (Replacing a substring)
14112
- *
14113
- * ```ts import.meta.vitest
14114
- * import { pipe, String } from "effect"
14115
- *
14116
- * pipe("abc", String.replace("b", "d")) // => "adc"
14117
- * pipe("hello world", String.replace("world", "Effect")) // => "hello Effect"
14118
- * ```
14119
- *
14120
- * @stability stable
14121
- * @category transforming
14122
- * @since 2.0.0
14123
- */
14124
- const replace = (searchValue, replaceValue) => (self) => self.replace(searchValue, replaceValue);
14125
- /**
14126
- * Extracts a section of a string and returns it as a new string.
14127
- *
14128
- * **Example** (Slicing strings)
14129
- *
14130
- * ```ts import.meta.vitest
14131
- * import { pipe, String } from "effect"
14132
- *
14133
- * pipe("abcd", String.slice(1, 3)) // => "bc"
14134
- * pipe("hello world", String.slice(0, 5)) // => "hello"
14135
- * ```
14136
- *
14137
- * @stability stable
14138
- * @category transforming
14139
- * @since 2.0.0
14140
- */
14141
- const slice = (start, end) => (self) => self.slice(start, end);
14142
- /**
14143
- * Checks whether a `string` is empty.
14144
- *
14145
- * **Example** (Checking for empty strings)
14146
- *
14147
- * ```ts import.meta.vitest
14148
- * import { String } from "effect"
14149
- *
14150
- * String.isEmpty("") // => true
14151
- * String.isEmpty("a") // => false
14152
- * ```
14153
- *
14154
- * @stability stable
14155
- * @category guards
14156
- * @since 2.0.0
14157
- */
14158
- const isEmpty$1 = (self) => self.length === 0;
14159
- /**
14160
13938
  * Checks whether a `string` is non-empty.
14161
13939
  *
14162
13940
  * **Example** (Checking for non-empty strings)
@@ -14174,27 +13952,6 @@ const isEmpty$1 = (self) => self.length === 0;
14174
13952
  */
14175
13953
  const isNonEmpty$1 = (self) => self.length > 0;
14176
13954
  /**
14177
- * Splits a string into an array of substrings using a separator.
14178
- *
14179
- * **Example** (Splitting strings)
14180
- *
14181
- * ```ts import.meta.vitest
14182
- * import { pipe, String } from "effect"
14183
- *
14184
- * pipe("abc", String.split("")) // => ["a", "b", "c"]
14185
- * pipe("", String.split("")) // => [""]
14186
- * String.split("hello,world", ",") // => ["hello", "world"]
14187
- * ```
14188
- *
14189
- * @stability stable
14190
- * @category transforming
14191
- * @since 2.0.0
14192
- */
14193
- const split$1 = /*#__PURE__*/ dual(2, (self, separator) => {
14194
- const out = self.split(separator);
14195
- return isArrayNonEmpty$1(out) ? out : [self];
14196
- });
14197
- /**
14198
13955
  * Returns `true` if `searchString` appears as a substring of `self`, at one or more positions that are
14199
13956
  * greater than or equal to `position`; otherwise, returns `false`.
14200
13957
  *
@@ -14738,7 +14495,7 @@ const forever$1 = /*#__PURE__*/ spaced(zero$2);
14738
14495
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/layer.js
14739
14496
  const provideLayer = (self, layer, options) => scopedWith$1((scope) => flatMap$3(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext$3(self, context)));
14740
14497
  /** @internal */
14741
- const provide$2 = /*#__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));
14498
+ 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));
14742
14499
  //#endregion
14743
14500
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/schedule.js
14744
14501
  const findErrorOnly = (cause) => cause.reasons.every(isFailReason$1) ? findError$1(cause) : fail$7(cause);
@@ -14940,7 +14697,7 @@ const fromIterable$4 = (entries) => {
14940
14697
  * @category getters
14941
14698
  * @since 2.0.0
14942
14699
  */
14943
- const get$7 = /*#__PURE__*/ dual(2, (self, key) => {
14700
+ const get$6 = /*#__PURE__*/ dual(2, (self, key) => {
14944
14701
  if (self.backing.has(key)) return some$1(self.backing.get(key));
14945
14702
  else if (isSimpleKey(key)) return none();
14946
14703
  const hash$3 = hash(key);
@@ -17506,7 +17263,7 @@ const contextWith = contextWith$1;
17506
17263
  * @category providing services
17507
17264
  * @since 2.0.0
17508
17265
  */
17509
- const provide$1 = provide$2;
17266
+ const provide = provide$1;
17510
17267
  /**
17511
17268
  * Provides a context to an effect, fulfilling its service requirements.
17512
17269
  *
@@ -19055,31 +18812,6 @@ const log = /*#__PURE__*/ logWithLevel();
19055
18812
  */
19056
18813
  const logFatal = /*#__PURE__*/ logWithLevel("Fatal");
19057
18814
  /**
19058
- * Logs one or more messages at the WARNING level.
19059
- *
19060
- * **Example** (Logging warnings)
19061
- *
19062
- * ```ts import.meta.vitest
19063
- * import { Effect, Logger } from "effect"
19064
- * const output: Array<unknown> = []
19065
- *
19066
- * const program = Effect.gen(function*() {
19067
- * yield* Effect.logWarning("API rate limit approaching")
19068
- * })
19069
- *
19070
- * const logger = Logger.make<unknown, void>(({ logLevel, message }) => {
19071
- * void output.push(`${logLevel}: ${Array.isArray(message) ? message.map(String).join(" ") : String(message)}`)
19072
- * })
19073
- * Effect.runSync(Effect.provide(program, Logger.layer([logger])))
19074
- * output // => ["Warn: API rate limit approaching"]
19075
- * ```
19076
- *
19077
- * @stability stable
19078
- * @category logging
19079
- * @since 2.0.0
19080
- */
19081
- const logWarning = /*#__PURE__*/ logWithLevel("Warn");
19082
- /**
19083
18815
  * Logs one or more messages at the ERROR level.
19084
18816
  *
19085
18817
  * **Example** (Logging errors)
@@ -21300,19 +21032,6 @@ const filter = (self, f) => {
21300
21032
  const remove$2 = (self, value) => filter(self, (v) => v !== value);
21301
21033
  //#endregion
21302
21034
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/PubSub.js
21303
- /**
21304
- * Broadcasts values from publishers to many subscribers.
21305
- *
21306
- * Publishers add messages with `publish` or `publishAll`, and each active
21307
- * `Subscription` receives its own copy of every accepted message. Unlike a
21308
- * queue, subscribers do not compete for messages. This module includes bounded,
21309
- * dropping, sliding, and unbounded hubs, optional replay buffers for late
21310
- * subscribers, message-taking helpers, capacity and shutdown operations, a
21311
- * type guard, and low-level types for custom hub strategies.
21312
- *
21313
- * @stability stable
21314
- * @since 2.0.0
21315
- */
21316
21035
  const TypeId$47 = "~effect/PubSub";
21317
21036
  const SubscriptionTypeId = "~effect/PubSub/Subscription";
21318
21037
  /**
@@ -21346,48 +21065,6 @@ const SubscriptionTypeId = "~effect/PubSub/Subscription";
21346
21065
  */
21347
21066
  const make$62 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), /* @__PURE__ */ new Map(), makeUnsafe$6(), makeUnsafe$4(false), make$64(false), options.strategy(), make$64(none())));
21348
21067
  /**
21349
- * Creates a bounded `PubSub` with the sliding strategy. The `PubSub` will add new
21350
- * messages and drop old messages if the `PubSub` is at capacity.
21351
- *
21352
- * **Details**
21353
- *
21354
- * The capacity must be a positive integer or `Infinity` for unbounded storage.
21355
- * Invalid capacities cause the effect to die.
21356
- * For best performance use capacities that are powers of two.
21357
- *
21358
- * **Example** (Sliding old messages when full)
21359
- *
21360
- * ```ts import.meta.vitest
21361
- * import { Effect, PubSub } from "effect"
21362
- *
21363
- * const program = Effect.scoped(Effect.gen(function*() {
21364
- * // Create sliding PubSub that evicts old messages when full
21365
- * const pubsub = yield* PubSub.sliding<string>(3)
21366
- *
21367
- * const subscription = yield* PubSub.subscribe(pubsub)
21368
- *
21369
- * // Fill and overflow the PubSub
21370
- * yield* PubSub.publish(pubsub, "msg1")
21371
- * yield* PubSub.publish(pubsub, "msg2")
21372
- * yield* PubSub.publish(pubsub, "msg3")
21373
- * yield* PubSub.publish(pubsub, "msg4") // "msg1" is evicted
21374
- *
21375
- * return yield* PubSub.takeAll(subscription)
21376
- * }))
21377
- *
21378
- * const actual = await Effect.runPromise(program)
21379
- * actual // => ["msg2", "msg3", "msg4"]
21380
- * ```
21381
- *
21382
- * @stability stable
21383
- * @category constructors
21384
- * @since 2.0.0
21385
- */
21386
- const sliding = (capacity) => make$62({
21387
- atomicPubSub: () => makeAtomicBounded(capacity),
21388
- strategy: () => new SlidingStrategy()
21389
- });
21390
- /**
21391
21068
  * Creates an unbounded `PubSub`.
21392
21069
  *
21393
21070
  * **Example** (Creating an unbounded PubSub)
@@ -21422,45 +21099,6 @@ const unbounded = (options) => make$62({
21422
21099
  strategy: () => new DroppingStrategy()
21423
21100
  });
21424
21101
  /**
21425
- * Creates a bounded atomic PubSub implementation with optional replay buffer.
21426
- *
21427
- * **When to use**
21428
- *
21429
- * Use to provide bounded message storage when building a custom `PubSub` with
21430
- * `make` and an explicit delivery strategy.
21431
- *
21432
- * **Details**
21433
- *
21434
- * Pass either a capacity number or an options object with `capacity` and
21435
- * optional `replay`. A positive `replay` value enables a replay buffer for late
21436
- * subscribers, and fractional replay sizes are rounded up.
21437
- *
21438
- * **Gotchas**
21439
- *
21440
- * The capacity must be a positive integer or `Infinity` for unbounded storage;
21441
- * invalid capacities throw synchronously before an atomic implementation is
21442
- * created.
21443
- *
21444
- * @see {@link make} for constructing a `PubSub` from an atomic implementation and delivery strategy
21445
- * @see {@link makeAtomicUnbounded} for an atomic implementation without a bounded capacity
21446
- * @see {@link bounded} for the higher-level backpressure constructor
21447
- * @see {@link dropping} for the higher-level dropping constructor
21448
- * @see {@link sliding} for the higher-level sliding constructor
21449
- *
21450
- * @stability stable
21451
- * @category constructors
21452
- * @since 4.0.0
21453
- */
21454
- const makeAtomicBounded = (capacity) => {
21455
- const options = typeof capacity === "number" ? { capacity } : capacity;
21456
- ensureCapacity(options.capacity);
21457
- if (options.capacity === Infinity) return makeAtomicUnbounded(options);
21458
- const replayBuffer = options.replay && options.replay > 0 ? new ReplayBuffer(Math.ceil(options.replay)) : void 0;
21459
- if (options.capacity === 1) return new BoundedPubSubSingle(replayBuffer);
21460
- else if (nextPow2(options.capacity) === options.capacity) return new BoundedPubSubPow2(options.capacity, replayBuffer);
21461
- else return new BoundedPubSubArb(options.capacity, replayBuffer);
21462
- };
21463
- /**
21464
21102
  * Creates an unbounded atomic PubSub implementation with optional replay buffer.
21465
21103
  *
21466
21104
  * **When to use**
@@ -21589,7 +21227,7 @@ const publish = /*#__PURE__*/ dual(2, (self, value) => suspend$2(() => {
21589
21227
  * @since 2.0.0
21590
21228
  */
21591
21229
  const subscribe = (self) => uninterruptible(contextWith((services) => {
21592
- const localScope = get$10(services, Scope);
21230
+ const localScope = get$9(services, Scope);
21593
21231
  const scope = forkUnsafe(self.scope);
21594
21232
  const subscription = makeSubscriptionUnsafe(self.pubsub, self.subscribers, self.strategy, self.ended);
21595
21233
  return addFinalizer$1(scope, unsubscribe(subscription)).pipe(andThen(addFinalizerExit(localScope, (exit) => close(scope, exit))), as(subscription));
@@ -21686,406 +21324,6 @@ const removeSubscribers = (subscribers, subscription, pollers) => {
21686
21324
  if (set.size === 0) subscribers.delete(subscription);
21687
21325
  };
21688
21326
  const makeSubscriptionUnsafe = (pubsub, subscribers, strategy, ended) => new SubscriptionImpl(pubsub, subscribers, pubsub.subscribe(), make$63(), makeUnsafe$4(false), make$64(false), strategy, pubsub.replayWindow(), ended);
21689
- var BoundedPubSubArb = class {
21690
- array;
21691
- replayIndices;
21692
- publisherIndex = 0;
21693
- subscribers;
21694
- subscriberCount = 0;
21695
- subscribersIndex = 0;
21696
- capacity;
21697
- replayBuffer;
21698
- constructor(capacity, replayBuffer) {
21699
- this.capacity = capacity;
21700
- this.replayBuffer = replayBuffer;
21701
- this.array = Array.from({ length: capacity });
21702
- this.replayIndices = replayBuffer ? Array.from({ length: capacity }) : [];
21703
- this.subscribers = Array.from({ length: capacity });
21704
- }
21705
- replayWindow() {
21706
- return this.replayBuffer ? new ReplayWindowImpl(this.replayBuffer) : emptyReplayWindow;
21707
- }
21708
- isEmpty() {
21709
- return this.publisherIndex === this.subscribersIndex;
21710
- }
21711
- isFull() {
21712
- return this.publisherIndex === this.subscribersIndex + this.capacity;
21713
- }
21714
- size() {
21715
- return this.publisherIndex - this.subscribersIndex;
21716
- }
21717
- publish(value) {
21718
- if (this.isFull()) return false;
21719
- const replayIndex = this.replayBuffer?.offer(value);
21720
- if (this.subscriberCount !== 0) {
21721
- const index = this.publisherIndex % this.capacity;
21722
- this.array[index] = value;
21723
- if (replayIndex !== void 0) this.replayIndices[index] = replayIndex;
21724
- this.subscribers[index] = this.subscriberCount;
21725
- this.publisherIndex += 1;
21726
- }
21727
- return true;
21728
- }
21729
- publishAll(elements) {
21730
- if (this.subscriberCount === 0) {
21731
- if (this.replayBuffer) this.replayBuffer.offerAll(elements);
21732
- return [];
21733
- }
21734
- const chunk = fromIterable$5(elements);
21735
- const n = chunk.length;
21736
- const size = this.publisherIndex - this.subscribersIndex;
21737
- const available = this.capacity - size;
21738
- const forPubSub = Math.min(n, available);
21739
- if (forPubSub === 0) return chunk;
21740
- let iteratorIndex = 0;
21741
- const publishAllIndex = this.publisherIndex + forPubSub;
21742
- while (this.publisherIndex !== publishAllIndex) {
21743
- const a = chunk[iteratorIndex++];
21744
- const index = this.publisherIndex % this.capacity;
21745
- this.array[index] = a;
21746
- const replayIndex = this.replayBuffer?.offer(a);
21747
- if (replayIndex !== void 0) this.replayIndices[index] = replayIndex;
21748
- this.subscribers[index] = this.subscriberCount;
21749
- this.publisherIndex += 1;
21750
- }
21751
- return chunk.slice(iteratorIndex);
21752
- }
21753
- slide() {
21754
- if (this.subscribersIndex !== this.publisherIndex) {
21755
- const index = this.subscribersIndex % this.capacity;
21756
- const value = this.array[index];
21757
- this.array[index] = AbsentValue;
21758
- this.subscribers[index] = 0;
21759
- this.subscribersIndex += 1;
21760
- this.replayBuffer?.slide(value, this.replayIndices[index]);
21761
- }
21762
- }
21763
- subscribe() {
21764
- this.subscriberCount += 1;
21765
- return new BoundedPubSubArbSubscription(this, this.publisherIndex, false);
21766
- }
21767
- };
21768
- var BoundedPubSubArbSubscription = class {
21769
- self;
21770
- subscriberIndex;
21771
- unsubscribed;
21772
- constructor(self, subscriberIndex, unsubscribed) {
21773
- this.self = self;
21774
- this.subscriberIndex = subscriberIndex;
21775
- this.unsubscribed = unsubscribed;
21776
- }
21777
- isEmpty() {
21778
- return this.unsubscribed || this.self.publisherIndex === this.subscriberIndex || this.self.publisherIndex === this.self.subscribersIndex;
21779
- }
21780
- size() {
21781
- if (this.unsubscribed) return 0;
21782
- return this.self.publisherIndex - Math.max(this.subscriberIndex, this.self.subscribersIndex);
21783
- }
21784
- poll() {
21785
- if (this.unsubscribed) return Empty$2;
21786
- this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
21787
- if (this.subscriberIndex !== this.self.publisherIndex) {
21788
- const index = this.subscriberIndex % this.self.capacity;
21789
- const elem = this.self.array[index];
21790
- this.self.subscribers[index] -= 1;
21791
- if (this.self.subscribers[index] === 0) {
21792
- this.self.array[index] = AbsentValue;
21793
- this.self.subscribersIndex += 1;
21794
- }
21795
- this.subscriberIndex += 1;
21796
- return elem;
21797
- }
21798
- return Empty$2;
21799
- }
21800
- pollUpTo(n) {
21801
- n = normalize$1(n);
21802
- if (this.unsubscribed) return [];
21803
- this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
21804
- const size = this.self.publisherIndex - this.subscriberIndex;
21805
- const toPoll = Math.min(n, size);
21806
- if (toPoll <= 0) return [];
21807
- const builder = [];
21808
- const pollUpToIndex = this.subscriberIndex + toPoll;
21809
- while (this.subscriberIndex !== pollUpToIndex) {
21810
- const index = this.subscriberIndex % this.self.capacity;
21811
- const a = this.self.array[index];
21812
- this.self.subscribers[index] -= 1;
21813
- if (this.self.subscribers[index] === 0) {
21814
- this.self.array[index] = AbsentValue;
21815
- this.self.subscribersIndex += 1;
21816
- }
21817
- builder.push(a);
21818
- this.subscriberIndex += 1;
21819
- }
21820
- return builder;
21821
- }
21822
- unsubscribe() {
21823
- if (!this.unsubscribed) {
21824
- this.unsubscribed = true;
21825
- this.self.subscriberCount -= 1;
21826
- this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
21827
- while (this.subscriberIndex !== this.self.publisherIndex) {
21828
- const index = this.subscriberIndex % this.self.capacity;
21829
- this.self.subscribers[index] -= 1;
21830
- if (this.self.subscribers[index] === 0) {
21831
- this.self.array[index] = AbsentValue;
21832
- this.self.subscribersIndex += 1;
21833
- }
21834
- this.subscriberIndex += 1;
21835
- }
21836
- }
21837
- }
21838
- };
21839
- var BoundedPubSubPow2 = class {
21840
- array;
21841
- replayIndices;
21842
- mask;
21843
- publisherIndex = 0;
21844
- subscribers;
21845
- subscriberCount = 0;
21846
- subscribersIndex = 0;
21847
- capacity;
21848
- replayBuffer;
21849
- constructor(capacity, replayBuffer) {
21850
- this.capacity = capacity;
21851
- this.replayBuffer = replayBuffer;
21852
- this.array = Array.from({ length: capacity });
21853
- this.replayIndices = replayBuffer ? Array.from({ length: capacity }) : [];
21854
- this.mask = capacity - 1;
21855
- this.subscribers = Array.from({ length: capacity });
21856
- }
21857
- replayWindow() {
21858
- return this.replayBuffer ? new ReplayWindowImpl(this.replayBuffer) : emptyReplayWindow;
21859
- }
21860
- isEmpty() {
21861
- return this.publisherIndex === this.subscribersIndex;
21862
- }
21863
- isFull() {
21864
- return this.publisherIndex === this.subscribersIndex + this.capacity;
21865
- }
21866
- size() {
21867
- return this.publisherIndex - this.subscribersIndex;
21868
- }
21869
- publish(value) {
21870
- if (this.isFull()) return false;
21871
- const replayIndex = this.replayBuffer?.offer(value);
21872
- if (this.subscriberCount !== 0) {
21873
- const index = this.publisherIndex & this.mask;
21874
- this.array[index] = value;
21875
- if (replayIndex !== void 0) this.replayIndices[index] = replayIndex;
21876
- this.subscribers[index] = this.subscriberCount;
21877
- this.publisherIndex += 1;
21878
- }
21879
- return true;
21880
- }
21881
- publishAll(elements) {
21882
- if (this.subscriberCount === 0) {
21883
- if (this.replayBuffer) this.replayBuffer.offerAll(elements);
21884
- return [];
21885
- }
21886
- const chunk = fromIterable$5(elements);
21887
- const n = chunk.length;
21888
- const size = this.publisherIndex - this.subscribersIndex;
21889
- const available = this.capacity - size;
21890
- const forPubSub = Math.min(n, available);
21891
- if (forPubSub === 0) return chunk;
21892
- let iteratorIndex = 0;
21893
- const publishAllIndex = this.publisherIndex + forPubSub;
21894
- while (this.publisherIndex !== publishAllIndex) {
21895
- const elem = chunk[iteratorIndex++];
21896
- const index = this.publisherIndex & this.mask;
21897
- this.array[index] = elem;
21898
- const replayIndex = this.replayBuffer?.offer(elem);
21899
- if (replayIndex !== void 0) this.replayIndices[index] = replayIndex;
21900
- this.subscribers[index] = this.subscriberCount;
21901
- this.publisherIndex += 1;
21902
- }
21903
- return chunk.slice(iteratorIndex);
21904
- }
21905
- slide() {
21906
- if (this.subscribersIndex !== this.publisherIndex) {
21907
- const index = this.subscribersIndex & this.mask;
21908
- const value = this.array[index];
21909
- this.array[index] = AbsentValue;
21910
- this.subscribers[index] = 0;
21911
- this.subscribersIndex += 1;
21912
- this.replayBuffer?.slide(value, this.replayIndices[index]);
21913
- }
21914
- }
21915
- subscribe() {
21916
- this.subscriberCount += 1;
21917
- return new BoundedPubSubPow2Subscription(this, this.publisherIndex, false);
21918
- }
21919
- };
21920
- var BoundedPubSubPow2Subscription = class {
21921
- self;
21922
- subscriberIndex;
21923
- unsubscribed;
21924
- constructor(self, subscriberIndex, unsubscribed) {
21925
- this.self = self;
21926
- this.subscriberIndex = subscriberIndex;
21927
- this.unsubscribed = unsubscribed;
21928
- }
21929
- isEmpty() {
21930
- return this.unsubscribed || this.self.publisherIndex === this.subscriberIndex || this.self.publisherIndex === this.self.subscribersIndex;
21931
- }
21932
- size() {
21933
- if (this.unsubscribed) return 0;
21934
- return this.self.publisherIndex - Math.max(this.subscriberIndex, this.self.subscribersIndex);
21935
- }
21936
- poll() {
21937
- if (this.unsubscribed) return Empty$2;
21938
- this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
21939
- if (this.subscriberIndex !== this.self.publisherIndex) {
21940
- const index = this.subscriberIndex & this.self.mask;
21941
- const elem = this.self.array[index];
21942
- this.self.subscribers[index] -= 1;
21943
- if (this.self.subscribers[index] === 0) {
21944
- this.self.array[index] = AbsentValue;
21945
- this.self.subscribersIndex += 1;
21946
- }
21947
- this.subscriberIndex += 1;
21948
- return elem;
21949
- }
21950
- return Empty$2;
21951
- }
21952
- pollUpTo(n) {
21953
- n = normalize$1(n);
21954
- if (this.unsubscribed) return [];
21955
- this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
21956
- const size = this.self.publisherIndex - this.subscriberIndex;
21957
- const toPoll = Math.min(n, size);
21958
- if (toPoll <= 0) return [];
21959
- const builder = [];
21960
- const pollUpToIndex = this.subscriberIndex + toPoll;
21961
- while (this.subscriberIndex !== pollUpToIndex) {
21962
- const index = this.subscriberIndex & this.self.mask;
21963
- const elem = this.self.array[index];
21964
- this.self.subscribers[index] -= 1;
21965
- if (this.self.subscribers[index] === 0) {
21966
- this.self.array[index] = AbsentValue;
21967
- this.self.subscribersIndex += 1;
21968
- }
21969
- builder.push(elem);
21970
- this.subscriberIndex += 1;
21971
- }
21972
- return builder;
21973
- }
21974
- unsubscribe() {
21975
- if (!this.unsubscribed) {
21976
- this.unsubscribed = true;
21977
- this.self.subscriberCount -= 1;
21978
- this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex);
21979
- while (this.subscriberIndex !== this.self.publisherIndex) {
21980
- const index = this.subscriberIndex & this.self.mask;
21981
- this.self.subscribers[index] -= 1;
21982
- if (this.self.subscribers[index] === 0) {
21983
- this.self.array[index] = AbsentValue;
21984
- this.self.subscribersIndex += 1;
21985
- }
21986
- this.subscriberIndex += 1;
21987
- }
21988
- }
21989
- }
21990
- };
21991
- var BoundedPubSubSingle = class {
21992
- publisherIndex = 0;
21993
- subscriberCount = 0;
21994
- subscribers = 0;
21995
- value = AbsentValue;
21996
- replayIndex = 0;
21997
- capacity = 1;
21998
- replayBuffer;
21999
- constructor(replayBuffer) {
22000
- this.replayBuffer = replayBuffer;
22001
- }
22002
- replayWindow() {
22003
- return this.replayBuffer ? new ReplayWindowImpl(this.replayBuffer) : emptyReplayWindow;
22004
- }
22005
- pipe() {
22006
- return pipeArguments(this, arguments);
22007
- }
22008
- isEmpty() {
22009
- return this.subscribers === 0;
22010
- }
22011
- isFull() {
22012
- return !this.isEmpty();
22013
- }
22014
- size() {
22015
- return this.isEmpty() ? 0 : 1;
22016
- }
22017
- publish(value) {
22018
- if (this.isFull()) return false;
22019
- const replayIndex = this.replayBuffer?.offer(value);
22020
- if (this.subscriberCount !== 0) {
22021
- this.value = value;
22022
- if (replayIndex !== void 0) this.replayIndex = replayIndex;
22023
- this.subscribers = this.subscriberCount;
22024
- this.publisherIndex += 1;
22025
- }
22026
- return true;
22027
- }
22028
- publishAll(elements) {
22029
- if (this.subscriberCount === 0) {
22030
- if (this.replayBuffer) this.replayBuffer.offerAll(elements);
22031
- return [];
22032
- }
22033
- const chunk = fromIterable$5(elements);
22034
- if (chunk.length === 0) return chunk;
22035
- if (this.publish(chunk[0])) return chunk.slice(1);
22036
- else return chunk;
22037
- }
22038
- slide() {
22039
- if (this.isFull()) {
22040
- const value = this.value;
22041
- this.subscribers = 0;
22042
- this.value = AbsentValue;
22043
- this.replayBuffer?.slide(value, this.replayIndex);
22044
- }
22045
- }
22046
- subscribe() {
22047
- this.subscriberCount += 1;
22048
- return new BoundedPubSubSingleSubscription(this, this.publisherIndex, false);
22049
- }
22050
- };
22051
- var BoundedPubSubSingleSubscription = class {
22052
- self;
22053
- subscriberIndex;
22054
- unsubscribed;
22055
- constructor(self, subscriberIndex, unsubscribed) {
22056
- this.self = self;
22057
- this.subscriberIndex = subscriberIndex;
22058
- this.unsubscribed = unsubscribed;
22059
- }
22060
- isEmpty() {
22061
- return this.unsubscribed || this.self.subscribers === 0 || this.subscriberIndex === this.self.publisherIndex;
22062
- }
22063
- size() {
22064
- return this.isEmpty() ? 0 : 1;
22065
- }
22066
- poll() {
22067
- if (this.isEmpty()) return Empty$2;
22068
- const elem = this.self.value;
22069
- this.self.subscribers -= 1;
22070
- if (this.self.subscribers === 0) this.self.value = AbsentValue;
22071
- this.subscriberIndex = this.self.publisherIndex;
22072
- return elem;
22073
- }
22074
- pollUpTo(n) {
22075
- if (normalize$1(n) < 1 || this.isEmpty()) return [];
22076
- return [this.poll()];
22077
- }
22078
- unsubscribe() {
22079
- if (!this.unsubscribed) {
22080
- this.unsubscribed = true;
22081
- this.self.subscriberCount -= 1;
22082
- if (this.self.subscribers !== 0 && this.subscriberIndex !== this.self.publisherIndex) {
22083
- this.self.subscribers -= 1;
22084
- if (this.self.subscribers === 0) this.self.value = AbsentValue;
22085
- }
22086
- }
22087
- }
22088
- };
22089
21327
  var UnboundedPubSub = class {
22090
21328
  publisherHead = {
22091
21329
  value: AbsentValue,
@@ -22281,9 +21519,6 @@ var PubSubImpl = class {
22281
21519
  }
22282
21520
  };
22283
21521
  const makePubSubUnsafe = (pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended) => new PubSubImpl(pubsub, subscribers, scope, shutdownHook, shutdownFlag, strategy, ended);
22284
- const ensureCapacity = (capacity) => {
22285
- if (capacity <= 0 || capacity !== Infinity && !Number.isInteger(capacity)) throw new Error(`Cannot construct PubSub with capacity of ${capacity}`);
22286
- };
22287
21522
  /**
22288
21523
  * Represents the dropping strategy for bounded `PubSub` values.
22289
21524
  *
@@ -22348,89 +21583,6 @@ var DroppingStrategy = class {
22348
21583
  return strategyCompleteSubscribersUnsafe(this, pubsub, subscribers);
22349
21584
  }
22350
21585
  };
22351
- /**
22352
- * Represents the sliding strategy for bounded `PubSub` values.
22353
- *
22354
- * **When to use**
22355
- *
22356
- * Use to keep the most recent messages when the `PubSub` is at capacity.
22357
- *
22358
- * **Details**
22359
- *
22360
- * New messages are accepted by evicting older messages from the bounded
22361
- * `PubSub`.
22362
- *
22363
- * **Gotchas**
22364
- *
22365
- * Slow subscribers may miss older messages that are evicted before they are
22366
- * consumed.
22367
- *
22368
- * **Example** (Applying a sliding strategy)
22369
- *
22370
- * ```ts import.meta.vitest
22371
- * import { Effect, PubSub } from "effect"
22372
- *
22373
- * const program = Effect.scoped(Effect.gen(function*() {
22374
- * // Explicitly create a PubSub with a sliding strategy
22375
- * const pubsub = yield* PubSub.make<string>({
22376
- * atomicPubSub: () => PubSub.makeAtomicBounded(2),
22377
- * strategy: () => new PubSub.SlidingStrategy()
22378
- * })
22379
- *
22380
- * const subscription = yield* PubSub.subscribe(pubsub)
22381
- *
22382
- * // Publish messages that exceed capacity
22383
- * yield* PubSub.publish(pubsub, "msg1") // stored
22384
- * yield* PubSub.publish(pubsub, "msg2") // stored
22385
- * yield* PubSub.publish(pubsub, "msg3") // "msg1" evicted, "msg3" stored
22386
- * yield* PubSub.publish(pubsub, "msg4") // "msg2" evicted, "msg4" stored
22387
- *
22388
- * // Subscribers will see the most recent messages
22389
- * return yield* PubSub.takeAll(subscription)
22390
- * }))
22391
- *
22392
- * const actual = await Effect.runPromise(program)
22393
- * actual // => ["msg3", "msg4"]
22394
- * ```
22395
- *
22396
- * @stability stable
22397
- * @category models
22398
- * @since 4.0.0
22399
- */
22400
- var SlidingStrategy = class {
22401
- get shutdown() {
22402
- return void_$1;
22403
- }
22404
- handleSurplus(pubsub, subscribers, elements, _isShutdown, ended) {
22405
- return sync(() => {
22406
- if (isSome(ended.current)) return false;
22407
- this.slidingPublishUnsafe(pubsub, elements);
22408
- this.completeSubscribersUnsafe(pubsub, subscribers);
22409
- return true;
22410
- });
22411
- }
22412
- onPubSubEmptySpaceUnsafe(_pubsub, _subscribers) {}
22413
- completePollersUnsafe(pubsub, subscribers, subscription, pollers) {
22414
- return strategyCompletePollersUnsafe(this, pubsub, subscribers, subscription, pollers);
22415
- }
22416
- completeSubscribersUnsafe(pubsub, subscribers) {
22417
- return strategyCompleteSubscribersUnsafe(this, pubsub, subscribers);
22418
- }
22419
- slidingPublishUnsafe(pubsub, elements) {
22420
- const it = elements[Symbol.iterator]();
22421
- let next = it.next();
22422
- if (!next.done && pubsub.capacity > 0) {
22423
- let a = next.value;
22424
- let loop = true;
22425
- while (loop) {
22426
- pubsub.slide();
22427
- const pub = pubsub.publish(a);
22428
- if (pub && (next = it.next()) && !next.done) a = next.value;
22429
- else if (pub) loop = false;
22430
- }
22431
- }
22432
- }
22433
- };
22434
21586
  const strategyCompletePollersUnsafe = (strategy, pubsub, subscribers, subscription, pollers) => {
22435
21587
  let keepPolling = true;
22436
21588
  while (keepPolling && !subscription.isEmpty()) {
@@ -23921,7 +23073,7 @@ const toTransform = (channel) => channel.transform;
23921
23073
  const asyncQueue = (scope, f, options) => make$61({
23922
23074
  capacity: options?.bufferSize,
23923
23075
  strategy: options?.strategy
23924
- }).pipe(tap((queue) => addFinalizer$1(scope, shutdown(queue))), tap((queue) => provide$4(f(queue), scope).pipe(catchCause$1((cause) => failCause$2(queue, cause)), forkIn(scope))));
23076
+ }).pipe(tap((queue) => addFinalizer$1(scope, shutdown(queue))), tap((queue) => provide$3(f(queue), scope).pipe(catchCause$1((cause) => failCause$2(queue, cause)), forkIn(scope))));
23925
23077
  /**
23926
23078
  * Creates a `Channel` that interacts with a callback function using a queue, emitting arrays.
23927
23079
  *
@@ -24910,7 +24062,7 @@ const unwrap$4 = (channel) => fromTransform$1((upstream, scope) => {
24910
24062
  let pull;
24911
24063
  return succeed$4(suspend$2(() => {
24912
24064
  if (pull) return pull;
24913
- return channel.pipe(provide$4(scope), flatMap$1((channel) => toTransform(channel)(upstream, scope)), flatMap$1((pull_) => pull = pull_));
24065
+ return channel.pipe(provide$3(scope), flatMap$1((channel) => toTransform(channel)(upstream, scope)), flatMap$1((pull_) => pull = pull_));
24914
24066
  }));
24915
24067
  });
24916
24068
  /**
@@ -25467,7 +24619,7 @@ const makeUnsafe$2 = (options) => ({
25467
24619
  */
25468
24620
  const make$59 = (options) => withFiber((fiber) => {
25469
24621
  const context = fiber.context;
25470
- const scope = get$10(context, Scope);
24622
+ const scope = get$9(context, Scope);
25471
24623
  const self = makeUnsafe$2({
25472
24624
  lookup: options.lookup,
25473
24625
  context,
@@ -25530,11 +24682,11 @@ const make$59 = (options) => withFiber((fiber) => {
25530
24682
  * @category combinators
25531
24683
  * @since 3.5.0
25532
24684
  */
25533
- const get$6 = /*#__PURE__*/ dual(2, (self, key) => uninterruptibleMask((restore) => {
24685
+ const get$5 = /*#__PURE__*/ dual(2, (self, key) => uninterruptibleMask((restore) => {
25534
24686
  if (self.state._tag === "Closed") return interrupt$1;
25535
24687
  const state = self.state;
25536
24688
  const parent = getCurrent();
25537
- const o = get$7(state.map, key);
24689
+ const o = get$6(state.map, key);
25538
24690
  let entry;
25539
24691
  if (o._tag === "Some") {
25540
24692
  entry = o.value;
@@ -25568,7 +24720,7 @@ const get$6 = /*#__PURE__*/ dual(2, (self, key) => uninterruptibleMask((restore)
25568
24720
  }));
25569
24721
  const removeInterrupted = (self, key, entry, context) => {
25570
24722
  if (self.state._tag === "Closed") return;
25571
- const o = get$7(self.state.map, key);
24723
+ const o = get$6(self.state.map, key);
25572
24724
  if (o._tag === "None" || o.value !== entry) return;
25573
24725
  remove$3(self.state.map, key);
25574
24726
  if (entry.refCount > 0) return;
@@ -25579,7 +24731,7 @@ const release$1 = (self, key, entry) => withFiber((fiber) => {
25579
24731
  entry.refCount--;
25580
24732
  if (entry.refCount > 0) return void_$1;
25581
24733
  else if (self.state._tag === "Closed") return closeEntry(entry);
25582
- const o = get$7(self.state.map, key);
24734
+ const o = get$6(self.state.map, key);
25583
24735
  if (o._tag === "None" || o.value !== entry) return closeEntry(entry);
25584
24736
  else if (isZero$1(entry.idleTimeToLive)) {
25585
24737
  remove$3(self.state.map, key);
@@ -25593,7 +24745,7 @@ const release$1 = (self, key, entry) => withFiber((fiber) => {
25593
24745
  const remaining = entry.expiresAt - now;
25594
24746
  if (remaining <= 0) {
25595
24747
  if (self.state._tag === "Closed" || entry.refCount > 0) return void_$1;
25596
- const o = get$7(self.state.map, key);
24748
+ const o = get$6(self.state.map, key);
25597
24749
  if (o._tag === "None" || o.value !== entry) return void_$1;
25598
24750
  remove$3(self.state.map, key);
25599
24751
  return close(entry.scope, void_$2);
@@ -25633,7 +24785,7 @@ var RcRefImpl = class {
25633
24785
  /** @internal */
25634
24786
  const make$58 = (options) => withFiber((fiber) => {
25635
24787
  const context = fiber.context;
25636
- const scope = get$10(context, Scope);
24788
+ const scope = get$9(context, Scope);
25637
24789
  const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== void 0 ? fromInputUnsafe$1(options.idleTimeToLive) : void 0);
25638
24790
  return as(addFinalizerExit(scope, () => {
25639
24791
  const state = ref.state;
@@ -25696,7 +24848,7 @@ const awaitAcquiring = (self, acquiring, restore) => onExit$1(restore(join$1(acq
25696
24848
  return interrupt(acquiring.fiber);
25697
24849
  });
25698
24850
  /** @internal */
25699
- const get$5 = (self_) => {
24851
+ const get$4 = (self_) => {
25700
24852
  const self = self_;
25701
24853
  return uninterruptibleMask((restore) => flatMap$1(scope, (scope) => flatMap$1(getState(self, restore), (state) => as(addFinalizerExit(scope, () => release(self, state)), state.value))));
25702
24854
  };
@@ -25814,7 +24966,7 @@ const make$57 = make$58;
25814
24966
  * @category combinators
25815
24967
  * @since 3.5.0
25816
24968
  */
25817
- const get$4 = get$5;
24969
+ const get$3 = get$4;
25818
24970
  //#endregion
25819
24971
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Stream.js
25820
24972
  /**
@@ -26235,41 +25387,6 @@ const fromQueue = (queue) => fromChannel(fromQueueArray(queue));
26235
25387
  */
26236
25388
  const fromReadableStream = (options) => fromChannel(fromReadableStream$1(options));
26237
25389
  /**
26238
- * Creates a stream by repeatedly applying an effectful step function to a
26239
- * state.
26240
- *
26241
- * **Details**
26242
- *
26243
- * Each `readonly [value, nextState]` result emits `value` and continues with
26244
- * `nextState`; returning `undefined` ends the stream.
26245
- *
26246
- * **Example** (Unfolding stream state)
26247
- *
26248
- * ```ts import.meta.vitest
26249
- * import { Effect, Stream } from "effect"
26250
- *
26251
- * const program = Effect.gen(function*() {
26252
- * const stream = Stream.unfold(1, (n) => Effect.succeed([n, n + 1] as const))
26253
- * const values = yield* Stream.runCollect(stream.pipe(Stream.take(5)))
26254
- * values // => [ 1, 2, 3, 4, 5 ]
26255
- * })
26256
- *
26257
- * await Effect.runPromise(program)
26258
- * ```
26259
- *
26260
- * @stability stable
26261
- * @category constructors
26262
- * @since 2.0.0
26263
- */
26264
- const unfold = (s, f) => fromPull(sync(() => {
26265
- let state = s;
26266
- return flatMap$1(suspend$2(() => f(state)), (next) => {
26267
- if (next === void 0) return done();
26268
- state = next[1];
26269
- return succeed$4(of(next[0]));
26270
- });
26271
- }));
26272
- /**
26273
25390
  * Creates a stream produced from an `Effect`.
26274
25391
  *
26275
25392
  * **Example** (Unwrapping a stream effect)
@@ -26469,53 +25586,6 @@ const mapError = /*#__PURE__*/ dual(2, (self, f) => fromChannel(mapError$1(self.
26469
25586
  */
26470
25587
  const orDie = (self) => fromChannel(orDie$1(self.channel));
26471
25588
  /**
26472
- * Takes elements until the predicate matches.
26473
- *
26474
- * **Details**
26475
- *
26476
- * When `excludeLast` is `true`, the matching element is dropped.
26477
- *
26478
- * **Example** (Taking until a predicate matches)
26479
- *
26480
- * ```ts import.meta.vitest
26481
- * import { Effect, Stream } from "effect"
26482
- *
26483
- * const stream = Stream.range(1, 5)
26484
- *
26485
- * const program = Effect.gen(function*() {
26486
- * const inclusive = yield* stream.pipe(
26487
- * Stream.takeUntil((n) => n % 3 === 0),
26488
- * Stream.runCollect
26489
- * )
26490
- * inclusive // => [ 1, 2, 3 ]
26491
- *
26492
- * const exclusive = yield* stream.pipe(
26493
- * Stream.takeUntil((n) => n % 3 === 0, { excludeLast: true }),
26494
- * Stream.runCollect
26495
- * )
26496
- * exclusive // => [ 1, 2 ]
26497
- * })
26498
- * await Effect.runPromise(program)
26499
- * ```
26500
- *
26501
- * @stability stable
26502
- * @category filtering
26503
- * @since 2.0.0
26504
- */
26505
- const takeUntil = /*#__PURE__*/ dual((args) => isStream(args[0]), (self, predicate, options) => transformPull(self, (pull, _scope) => sync(() => {
26506
- let i = 0;
26507
- let done$8 = false;
26508
- return flatMap$1(suspend$2(() => done$8 ? done() : pull), (chunk) => {
26509
- const index = chunk.findIndex((a) => predicate(a, i++));
26510
- if (index >= 0) {
26511
- done$8 = true;
26512
- const arr = chunk.slice(0, options?.excludeLast ? index : index + 1);
26513
- return isReadonlyArrayNonEmpty(arr) ? succeed$4(arr) : done();
26514
- }
26515
- return succeed$4(chunk);
26516
- });
26517
- })));
26518
- /**
26519
25589
  * Drops the first `n` elements from this stream.
26520
25590
  *
26521
25591
  * **Details**
@@ -28255,7 +27325,7 @@ const formatIso = formatIso$1;
28255
27325
  * @category encoding
28256
27326
  * @since 4.0.0
28257
27327
  */
28258
- const encode$1 = (input) => encodeBytes(typeof input === "string" ? encoder$2.encode(input) : input);
27328
+ const encode = (input) => encodeBytes(typeof input === "string" ? encoder$2.encode(input) : input);
28259
27329
  /**
28260
27330
  * Decodes a Base64 (RFC 4648) string into bytes safely.
28261
27331
  *
@@ -28351,108 +27421,8 @@ const getCode = (charCode) => {
28351
27421
  return codes[charCode];
28352
27422
  };
28353
27423
  //#endregion
28354
- //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/encoding/Base64Url.js
28355
- /**
28356
- * Encodes the given value into an unpadded URL-safe Base64 string.
28357
- *
28358
- * **When to use**
28359
- *
28360
- * Use to encode text or bytes in contexts that require the URL-safe alphabet.
28361
- *
28362
- * **Details**
28363
- *
28364
- * String inputs are encoded as UTF-8 bytes before Base64Url encoding.
28365
- * `Uint8Array` inputs are encoded directly. The output removes `=` padding
28366
- * and replaces `+` with `-` and `/` with `_`.
28367
- *
28368
- * **Example** (Encoding URL-safe Base64)
28369
- *
28370
- * ```ts import.meta.vitest
28371
- * import { Base64Url } from "effect/encoding"
28372
- *
28373
- * Base64Url.encode("hello?") // => "aGVsbG8_"
28374
- *
28375
- * const bytes = new Uint8Array([72, 101, 108, 108, 111, 63])
28376
- * Base64Url.encode(bytes) // => "SGVsbG8_"
28377
- * ```
28378
- *
28379
- * @see {@link decode} for decoding URL-safe Base64 to bytes
28380
- * @see {@link decodeString} for decoding URL-safe Base64 to UTF-8 text
28381
- *
28382
- * @stability stable
28383
- * @category encoding
28384
- * @since 4.0.0
28385
- */
28386
- const encode = (input) => encode$1(input).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
28387
- //#endregion
28388
27424
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/SchemaGetter.js
28389
- const runGetter = (self, input, options) => {
28390
- switch (self._tag) {
28391
- case "Passthrough": return succeed$4(input);
28392
- case "Transform": return succeed$4(map$8(input, self.transform));
28393
- case "TransformOptional": return succeed$4(self.transform(input));
28394
- case "TransformEffect": return isNone(input) ? succeedNone : mapEager(self.transform(input.value, options), some$1);
28395
- case "TransformOptionalEffect": return self.transform(input, options);
28396
- }
28397
- };
28398
27425
  const makeGetter = (fields) => Object.assign(Object.create(Prototype$1), fields);
28399
- const composeOptionalEffect = (first, second) => transformOptionalEffect((input, options) => flatMapEager(runGetter(first, input, options), (output) => runGetter(second, output, options)));
28400
- /**
28401
- * Composes two getters by passing the output of the first to the second.
28402
- *
28403
- * **When to use**
28404
- *
28405
- * Use when a schema conversion requires multiple transformation steps.
28406
- *
28407
- * **Details**
28408
- *
28409
- * Composition forwards `Option.none()` to getters that handle optional values
28410
- * and skips getters that operate only on present values. Composing with
28411
- * {@link passthrough} returns the other getter unchanged. The function supports
28412
- * both `compose(first, second)` and `first.pipe(compose(second))`.
28413
- *
28414
- * **Example** (Parsing and normalizing a number)
28415
- *
28416
- * ```ts import.meta.vitest
28417
- * import { Effect, Option, SchemaGetter } from "effect"
28418
- *
28419
- * const getter = SchemaGetter.compose(
28420
- * SchemaGetter.transform<number, string>(Number),
28421
- * SchemaGetter.transform((n) => Math.max(0, n))
28422
- * )
28423
- *
28424
- * Effect.runSync(SchemaGetter.run(getter, Option.some("-1"), {})) // => Option.some(0)
28425
- * ```
28426
- *
28427
- * @stability stable
28428
- * @category combining
28429
- * @since 4.0.0
28430
- */
28431
- const compose = /*#__PURE__*/ dual(2, (self, other) => {
28432
- if (self._tag === "Passthrough") return other;
28433
- if (other._tag === "Passthrough") return self;
28434
- switch (self._tag) {
28435
- case "Transform": switch (other._tag) {
28436
- case "Transform": return transform$1((input) => other.transform(self.transform(input)));
28437
- case "TransformOptional": return transformOptional((input) => other.transform(map$8(input, self.transform)));
28438
- case "TransformEffect": return transformEffect$1((input, options) => other.transform(self.transform(input), options));
28439
- case "TransformOptionalEffect": return composeOptionalEffect(self, other);
28440
- }
28441
- case "TransformOptional": switch (other._tag) {
28442
- case "Transform": return transformOptional((input) => map$8(self.transform(input), other.transform));
28443
- case "TransformOptional": return transformOptional((input) => other.transform(self.transform(input)));
28444
- case "TransformEffect":
28445
- case "TransformOptionalEffect": return composeOptionalEffect(self, other);
28446
- }
28447
- case "TransformEffect": switch (other._tag) {
28448
- case "Transform": return transformEffect$1((input, options) => mapEager(self.transform(input, options), other.transform));
28449
- case "TransformOptional":
28450
- case "TransformOptionalEffect": return composeOptionalEffect(self, other);
28451
- case "TransformEffect": return transformEffect$1((input, options) => flatMapEager(self.transform(input, options), (output) => other.transform(output, options)));
28452
- }
28453
- case "TransformOptionalEffect": return composeOptionalEffect(self, other);
28454
- }
28455
- });
28456
27426
  /**
28457
27427
  * Creates a getter that always fails with the given issue.
28458
27428
  *
@@ -28909,39 +27879,6 @@ function stringifyJson(options) {
28909
27879
  }));
28910
27880
  }
28911
27881
  /**
28912
- * Splits a string into an array of strings by a separator.
28913
- *
28914
- * **When to use**
28915
- *
28916
- * Use when you need a schema getter to split a present encoded string
28917
- * containing a delimited list, such as CSV values.
28918
- *
28919
- * **Details**
28920
- *
28921
- * The getter is pure and never fails. It splits by `separator` (default `,`).
28922
- * An empty string produces an empty array, not `[""]`.
28923
- *
28924
- * **Example** (Splitting a comma-separated string)
28925
- *
28926
- * ```ts import.meta.vitest
28927
- * import { Effect, Option, SchemaGetter } from "effect"
28928
- *
28929
- * const splitComma = SchemaGetter.split<string>()
28930
- * const result = Effect.runSync(SchemaGetter.run(splitComma, Option.some("a,b,c"), {}))
28931
- * result // => Option.some(["a", "b", "c"])
28932
- * ```
28933
- *
28934
- * @see {@link splitKeyValue} when values are key-value pairs
28935
- *
28936
- * @stability stable
28937
- * @category splitting
28938
- * @since 4.0.0
28939
- */
28940
- function split(options) {
28941
- const separator = options?.separator ?? ",";
28942
- return transform$1((input) => input === "" ? [] : input.split(separator));
28943
- }
28944
- /**
28945
27882
  * Encodes a `Uint8Array` or string to a Base64 string.
28946
27883
  *
28947
27884
  * **Details**
@@ -28967,7 +27904,7 @@ function split(options) {
28967
27904
  * @since 4.0.0
28968
27905
  */
28969
27906
  function encodeBase64() {
28970
- return transform$1(encode$1);
27907
+ return transform$1(encode);
28971
27908
  }
28972
27909
  /**
28973
27910
  * Decodes a Base64 string to a `Uint8Array`.
@@ -29769,14 +28706,6 @@ const isArrays = /*#__PURE__*/ makeGuard("Arrays");
29769
28706
  */
29770
28707
  const isObjects = /*#__PURE__*/ makeGuard("Objects");
29771
28708
  /**
29772
- * Narrows an {@link AST} to {@link Union}.
29773
- *
29774
- * @stability stable
29775
- * @category guards
29776
- * @since 3.10.0
29777
- */
29778
- const isUnion = /*#__PURE__*/ makeGuard("Union");
29779
- /**
29780
28709
  * Narrows an {@link AST} to {@link Suspend}.
29781
28710
  *
29782
28711
  * @stability stable
@@ -33061,14 +31990,6 @@ const flattenCommand = (command) => {
33061
31990
  * @since 4.0.0
33062
31991
  */
33063
31992
  const TypeId$32 = "~effect/http/Cookies";
33064
- /**
33065
- * Returns `true` when a value is a `Cookies` collection.
33066
- *
33067
- * @stability unstable
33068
- * @category guards
33069
- * @since 4.0.0
33070
- */
33071
- const isCookies = (u) => hasProperty(u, TypeId$32);
33072
31993
  const CookieTypeId = "~effect/http/Cookies/Cookie";
33073
31994
  const CookieErrorTypeId = "~effect/http/Cookies/CookieError";
33074
31995
  /**
@@ -33290,28 +32211,6 @@ const CookieProto = {
33290
32211
  };
33291
32212
  }
33292
32213
  };
33293
- /**
33294
- * Creates a cookie, validating the name, encoded value, domain, path, and finite `maxAge`.
33295
- *
33296
- * **Details**
33297
- *
33298
- * Returns a `CookiesError` in the `Result` failure channel when validation fails.
33299
- *
33300
- * @stability unstable
33301
- * @category constructors
33302
- * @since 4.0.0
33303
- */
33304
- function makeCookie(name, value, options) {
33305
- const encodedValue = encodeURIComponent(value);
33306
- const error = validateCookie(name, encodedValue, options);
33307
- if (error !== void 0) return fail$7(error);
33308
- return succeed$9(Object.assign(Object.create(CookieProto), {
33309
- name,
33310
- value,
33311
- valueEncoded: encodedValue,
33312
- options
33313
- }));
33314
- }
33315
32214
  function validateCookie(name, encodedValue, options) {
33316
32215
  if (!cookieNameRegExp.test(name)) return CookiesError.fromReason("InvalidCookieName");
33317
32216
  if (encodedValue && !fieldContentRegExp.test(encodedValue)) return CookiesError.fromReason("InvalidCookieValue");
@@ -33320,34 +32219,6 @@ function validateCookie(name, encodedValue, options) {
33320
32219
  if (options?.maxAge !== void 0 && !isFinite$1(fromInputUnsafe$1(options.maxAge))) return CookiesError.fromReason("CookieInfinityMaxAge");
33321
32220
  }
33322
32221
  /**
33323
- * Create a new cookie, throwing an error if invalid
33324
- *
33325
- * @stability unstable
33326
- * @category constructors
33327
- * @since 4.0.0
33328
- */
33329
- const makeCookieUnsafe = (name, value, options) => getOrThrow(makeCookie(name, value, options));
33330
- /**
33331
- * Creates and adds a cookie by name and value, throwing if the cookie fields are invalid.
33332
- *
33333
- * @stability unstable
33334
- * @category combinators
33335
- * @since 4.0.0
33336
- */
33337
- const setUnsafe = /*#__PURE__*/ dual((args) => isCookies(args[0]), (self, name, value, options) => fromReadonlyRecord(set$4(self.cookies, name, makeCookieUnsafe(name, value, options))));
33338
- /**
33339
- * Adds an expired cookie to a Cookies object, throwing an error if invalid
33340
- *
33341
- * @stability unstable
33342
- * @category combinators
33343
- * @since 4.0.0
33344
- */
33345
- const expireCookieUnsafe$1 = /*#__PURE__*/ dual((args) => isCookies(args[0]), (self, name, options) => setUnsafe(self, name, "", {
33346
- ...options,
33347
- maxAge: 0,
33348
- expires: /* @__PURE__ */ new Date(0)
33349
- }));
33350
- /**
33351
32222
  * Serializes a cookie into a string.
33352
32223
  *
33353
32224
  * **Details**
@@ -33453,8 +32324,6 @@ const value$3 = (self) => {
33453
32324
  if (redactedRegistry.has(self)) return redactedRegistry.get(self);
33454
32325
  else throw new Error("Unable to get redacted value" + (self.label ? ` with label: "${self.label}"` : ""));
33455
32326
  };
33456
- /** @internal */
33457
- const stringOrRedacted = (val) => typeof val === "string" ? val : value$3(val);
33458
32327
  //#endregion
33459
32328
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Redacted.js
33460
32329
  /**
@@ -33627,7 +32496,7 @@ const TypeId$30 = /*#__PURE__*/ Symbol.for("~effect/http/Headers");
33627
32496
  const Proto$12 = /*#__PURE__*/ Object.defineProperties(/*#__PURE__*/ Object.create(null), {
33628
32497
  [TypeId$30]: { value: TypeId$30 },
33629
32498
  [symbolRedactable]: { value(context) {
33630
- return redact$1(this, get$10(context, CurrentRedactedNames$1));
32499
+ return redact$1(this, get$9(context, CurrentRedactedNames$1));
33631
32500
  } },
33632
32501
  toJSON: { value() {
33633
32502
  return redact$2(this);
@@ -33705,7 +32574,7 @@ const fromRecordUnsafe = (input) => Object.setPrototypeOf(input, Proto$12);
33705
32574
  * @category combinators
33706
32575
  * @since 4.0.0
33707
32576
  */
33708
- const get$3 = /*#__PURE__*/ dual(2, (self, key) => fromUndefinedOr(self[key.toLowerCase()]));
32577
+ const get$2 = /*#__PURE__*/ dual(2, (self, key) => fromUndefinedOr(self[key.toLowerCase()]));
33709
32578
  /**
33710
32579
  * Returns a new `Headers` collection with the given header set.
33711
32580
  *
@@ -34339,7 +33208,7 @@ var HashMapImpl = class {
34339
33208
  const thatImpl = that;
34340
33209
  if (this.size !== thatImpl.size) return false;
34341
33210
  for (const [key, value] of this) {
34342
- const otherValue = pipe(that, get$2(key));
33211
+ const otherValue = pipe(that, get$1(key));
34343
33212
  if (isNone(otherValue) || !equals$1(value, otherValue.value)) return false;
34344
33213
  }
34345
33214
  return true;
@@ -34372,7 +33241,7 @@ const isHashMap = (u) => hasProperty(u, HashMapTypeId);
34372
33241
  /** @internal */
34373
33242
  const empty$4 = () => new HashMapImpl(false, 0, emptyNode, 0);
34374
33243
  /** @internal */
34375
- const get$2 = /*#__PURE__*/ dual(2, (self, key) => {
33244
+ const get$1 = /*#__PURE__*/ dual(2, (self, key) => {
34376
33245
  return self._root.get(0, hash(key), key);
34377
33246
  });
34378
33247
  /** @internal */
@@ -34615,7 +33484,7 @@ const Proto$11 = {
34615
33484
  [symbolRedactable](context) {
34616
33485
  return {
34617
33486
  _id: "UrlParams",
34618
- params: Object.fromEntries(redact(this, get$10(context, CurrentRedactedNames)))
33487
+ params: Object.fromEntries(redact(this, get$9(context, CurrentRedactedNames)))
34619
33488
  };
34620
33489
  },
34621
33490
  toJSON() {
@@ -34724,67 +33593,6 @@ const setAll = /*#__PURE__*/ dual(2, (self, input) => {
34724
33593
  return make$45(params);
34725
33594
  });
34726
33595
  /**
34727
- * Serializes `UrlParams` to a URL query string without a leading question mark.
34728
- *
34729
- * **Gotchas**
34730
- *
34731
- * The output contains the unwrapped values of `Redacted` parameters.
34732
- *
34733
- * @stability unstable
34734
- * @category converting
34735
- * @since 4.0.0
34736
- */
34737
- const toString$1 = (input) => new URLSearchParams(fromInput(input).params.map(([key, value]) => [key, unwrap$1(value)])).toString();
34738
- /**
34739
- * Builds a `Record` containing all the key-value pairs in the given `UrlParams`
34740
- * as `string` (if only one value for a key) or a `NonEmptyArray<string>`
34741
- * (when more than one value for a key)
34742
- *
34743
- * **Example** (Converting parameters to a record)
34744
- *
34745
- * ```ts import.meta.vitest
34746
- * import { UrlParams } from "effect/http"
34747
- *
34748
- * const urlParams = UrlParams.fromInput({
34749
- * a: 1,
34750
- * b: true,
34751
- * c: "string",
34752
- * e: [1, 2, 3]
34753
- * })
34754
- * UrlParams.toRecord(urlParams) // => { a: "1", b: "true", c: "string", e: ["1", "2", "3"] }
34755
- * ```
34756
- *
34757
- * @stability unstable
34758
- * @category converting
34759
- * @since 4.0.0
34760
- */
34761
- const toRecord = (self) => {
34762
- const out = {};
34763
- for (const [k, v] of self.params) {
34764
- const value = unwrap$1(v);
34765
- if (!Object.hasOwn(out, k)) assignProperty(out, k, value);
34766
- else {
34767
- const current = out[k];
34768
- if (typeof current === "string") assignProperty(out, k, [current, value]);
34769
- else current.push(value);
34770
- }
34771
- }
34772
- return out;
34773
- };
34774
- /**
34775
- * Builds a readonly record from `UrlParams`.
34776
- *
34777
- * **Details**
34778
- *
34779
- * Keys with one value map to a string, and keys with multiple values map to a
34780
- * non-empty readonly array of strings.
34781
- *
34782
- * @stability unstable
34783
- * @category converting
34784
- * @since 4.0.0
34785
- */
34786
- const toReadonlyRecord = toRecord;
34787
- /**
34788
33596
  * Returns the parameter pairs with selected values wrapped in `Redacted`.
34789
33597
  *
34790
33598
  * **Details**
@@ -34877,7 +33685,7 @@ const decodeQueryKey = (key) => {
34877
33685
  return key;
34878
33686
  }
34879
33687
  };
34880
- const currentRedactedNames = () => get$10(globalThis["~effect/Fiber/currentFiber"]?.context ?? empty$12(), CurrentRedactedNames);
33688
+ const currentRedactedNames = () => get$9(globalThis["~effect/Fiber/currentFiber"]?.context ?? empty$12(), CurrentRedactedNames);
34881
33689
  /**
34882
33690
  * Query parameter names or patterns to redact in inspection, spans and errors.
34883
33691
  *
@@ -36649,35 +35457,6 @@ function toRepresentations(asts, options) {
36649
35457
  //#endregion
36650
35458
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Struct.js
36651
35459
  /**
36652
- * Creates a new struct containing only the specified keys.
36653
- *
36654
- * **When to use**
36655
- *
36656
- * Use to narrow a struct down to a subset of its properties.
36657
- *
36658
- * **Gotchas**
36659
- *
36660
- * Keys not present in the struct are silently ignored.
36661
- *
36662
- * **Example** (Selecting specific properties)
36663
- *
36664
- * ```ts import.meta.vitest
36665
- * import { pipe, Struct } from "effect"
36666
- *
36667
- * const user = { name: "Alice", age: 30, admin: true }
36668
- * pipe(user, Struct.pick(["name", "age"])) // => { name: "Alice", age: 30 }
36669
- * ```
36670
- *
36671
- * @see {@link omit} – the inverse (exclude keys instead)
36672
- * @see {@link get} – extract a single value
36673
- * @stability stable
36674
- * @category filtering
36675
- * @since 2.0.0
36676
- */
36677
- const pick = /*#__PURE__*/ dual(2, (self, keys) => {
36678
- return buildStruct(self, (k, v) => hasPropertyKey(keys, k) ? [k, v] : void 0);
36679
- });
36680
- /**
36681
35460
  * Creates a new struct with the specified keys removed.
36682
35461
  *
36683
35462
  * **When to use**
@@ -37827,45 +36606,6 @@ const ArraySchema = /*#__PURE__*/ lambda((schema) => make$42(new Arrays(false, [
37827
36606
  * @since 3.10.0
37828
36607
  */
37829
36608
  const NonEmptyArray = /*#__PURE__*/ lambda((schema) => make$42(new Arrays(false, [schema.ast], [schema.ast]), { value: schema }));
37830
- /**
37831
- * Creates a schema that accepts either a value decoded by `schema` or an array
37832
- * decoded by `Schema.Array(schema)`, then returns an array.
37833
- *
37834
- * **When to use**
37835
- *
37836
- * Use to accept input that may be provided either as one item or as an array,
37837
- * while normalizing decoded values to a readonly array.
37838
- *
37839
- * **Details**
37840
- *
37841
- * During encoding, one-element arrays are encoded as the single element. Empty
37842
- * arrays and arrays with two or more elements are encoded as arrays.
37843
- *
37844
- * **Gotchas**
37845
- *
37846
- * The single-value branch is tried before the array branch. If `schema` itself
37847
- * accepts arrays, an array input can be treated as one value and wrapped in a
37848
- * one-element array.
37849
- *
37850
- * @see {@link Array} for accepting only array input
37851
- * @see {@link NonEmptyArray} for requiring at least one decoded element
37852
- *
37853
- * @stability stable
37854
- * @category constructors
37855
- * @since 3.10.0
37856
- */
37857
- function ArrayEnsure(schema) {
37858
- const many = ArraySchema(schema);
37859
- const to = ArraySchema(toType(schema));
37860
- const one = decodeTo(Tuple([Unknown]), transform({
37861
- decode: (value) => [value],
37862
- encode: ([value]) => value
37863
- }))(schema);
37864
- return make$42(Union([one, many]).pipe(decodeTo(to)).ast, {
37865
- from: Union([schema, many]),
37866
- to
37867
- });
37868
- }
37869
36609
  function makeUnion(ast, members) {
37870
36610
  return make$42(ast, {
37871
36611
  members,
@@ -38281,152 +37021,6 @@ function TaggedStruct(value, fields) {
38281
37021
  });
38282
37022
  }
38283
37023
  /**
38284
- * Augments an existing {@link Union} of tagged structs with utility methods and an ordered tuple of discriminant
38285
- * values.
38286
- *
38287
- * **Gotchas**
38288
- *
38289
- * Rejects overlapping discriminant types in known member tuples at compile
38290
- * time, including nested unions. Numeric and string values such as `1` and
38291
- * `"1"` count as duplicates. Also throws at runtime if multiple members use the
38292
- * same discriminant property key.
38293
- *
38294
- * **Example** (Adding tagged-union utilities to an existing union)
38295
- *
38296
- * ```ts import.meta.vitest
38297
- * import { Schema } from "effect"
38298
- *
38299
- * const A = Schema.TaggedStruct("A", { value: Schema.Number })
38300
- * const B = Schema.TaggedStruct("B", { name: Schema.String })
38301
- *
38302
- * const MyUnion = Schema.Union([A, B]).pipe(Schema.toTaggedUnion("_tag"))
38303
- *
38304
- * // Pattern-match on the union
38305
- * const result = MyUnion.match({ _tag: "A", value: 1 }, {
38306
- * A: (a) => `number: ${a.value}`,
38307
- * B: (b) => `name: ${b.name}`
38308
- * })
38309
- * result // => "number: 1"
38310
- * ```
38311
- *
38312
- * @see {@link TaggedUnion} for a shorthand that builds the union from scratch
38313
- * @stability stable
38314
- * @category combinators
38315
- * @since 4.0.0
38316
- */
38317
- function toTaggedUnion(tag) {
38318
- return (self) => {
38319
- const cases = {};
38320
- const discriminants = [];
38321
- const discriminantKeys = /* @__PURE__ */ new Set();
38322
- const guards = {};
38323
- const isAnyOf = (keys) => (value) => keys.includes(value[tag]);
38324
- walk(self);
38325
- return Object.assign(self, {
38326
- tag,
38327
- cases,
38328
- discriminants,
38329
- isAnyOf,
38330
- guards,
38331
- match,
38332
- matchOrElse
38333
- });
38334
- function walk(schema) {
38335
- const ast = schema.ast;
38336
- if (isUnion(ast) && "members" in schema && globalThis.Array.isArray(schema.members) && schema.members.every(isSchema)) return schema.members.forEach(walk);
38337
- const sentinels = collectSentinels(ast);
38338
- if (sentinels.length > 0) {
38339
- const literal = sentinels.find((s) => s.key === tag)?.literal;
38340
- if (isPropertyKey(literal)) {
38341
- const key = typeof literal === "number" ? globalThis.String(literal) : literal;
38342
- if (discriminantKeys.has(key)) throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(literal)}`);
38343
- discriminantKeys.add(key);
38344
- discriminants.push(literal);
38345
- assignProperty(cases, literal, schema);
38346
- assignProperty(guards, literal, is$3(toType(schema)));
38347
- return;
38348
- }
38349
- }
38350
- throw new globalThis.Error("No literal or unique symbol found");
38351
- }
38352
- function match() {
38353
- if (arguments.length === 1) {
38354
- const cases = arguments[0];
38355
- return function(value) {
38356
- const key = value[tag];
38357
- return (Object.hasOwn(cases, key) ? cases[key] : void 0)(value);
38358
- };
38359
- }
38360
- const value = arguments[0];
38361
- const cases = arguments[1];
38362
- const key = value[tag];
38363
- return (Object.hasOwn(cases, key) ? cases[key] : void 0)(value);
38364
- }
38365
- function matchOrElse() {
38366
- if (arguments.length === 2) {
38367
- const cases = arguments[0];
38368
- const orElse = arguments[1];
38369
- return function(value) {
38370
- const key = value[tag];
38371
- return (Object.hasOwn(cases, key) ? cases[key] ?? orElse : orElse)(value);
38372
- };
38373
- }
38374
- const value = arguments[0];
38375
- const cases = arguments[1];
38376
- const orElse = arguments[2];
38377
- const key = value[tag];
38378
- return (Object.hasOwn(cases, key) ? cases[key] ?? orElse : orElse)(value);
38379
- }
38380
- };
38381
- }
38382
- /**
38383
- * Builds a discriminated union from a record of field sets, one per variant.
38384
- * Each key becomes the `_tag` literal and the value is passed to {@link TaggedStruct}.
38385
- * The result includes `tag`, `cases`, `guards`, `isAnyOf`, `match`, and `matchOrElse` utilities.
38386
- *
38387
- * **Example** (Pattern matching a discriminated union)
38388
- *
38389
- * ```ts import.meta.vitest
38390
- * import { Schema } from "effect"
38391
- *
38392
- * const Shape = Schema.TaggedUnion({
38393
- * Circle: { radius: Schema.Number },
38394
- * Rectangle: { width: Schema.Number, height: Schema.Number }
38395
- * })
38396
- *
38397
- * // Pattern-match on a decoded value
38398
- * const area = Shape.match({ _tag: "Circle", radius: 5 }, {
38399
- * Circle: (c) => Math.PI * c.radius ** 2,
38400
- * Rectangle: (r) => r.width * r.height
38401
- * })
38402
- * Math.round(area * 100) / 100 // => 78.54
38403
- * ```
38404
- *
38405
- * @see {@link toTaggedUnion} to augment an existing union instead
38406
- * @stability stable
38407
- * @category constructors
38408
- * @since 4.0.0
38409
- */
38410
- function TaggedUnion(casesByTag) {
38411
- const cases = {};
38412
- const members = [];
38413
- for (const key of Object.keys(casesByTag)) {
38414
- const member = TaggedStruct(key, casesByTag[key]);
38415
- assignProperty(cases, key, member);
38416
- members.push(member);
38417
- }
38418
- const union = Union(members);
38419
- const { tag, guards, isAnyOf, match, matchOrElse } = toTaggedUnion("_tag")(union);
38420
- return make$42(union.ast, {
38421
- tag,
38422
- cases,
38423
- isAnyOf,
38424
- guards,
38425
- match,
38426
- matchOrElse
38427
- });
38428
- }
38429
- /**
38430
37024
  * Wraps a struct schema so that its decoded `Type` becomes a nominally distinct type `Self`.
38431
37025
  * Useful for creating opaque types that are structurally identical to a base struct
38432
37026
  * but type-incompatible with it.
@@ -38779,45 +37373,6 @@ const Int = /*#__PURE__*/ Number$1.check(/*#__PURE__*/ isInt());
38779
37373
  * @since 4.0.0
38780
37374
  */
38781
37375
  const Natural = /*#__PURE__*/ Int.check(/*#__PURE__*/ isGreaterThanOrEqualTo$1(0));
38782
- /**
38783
- * Validates that a value has at least the specified length. Works with strings
38784
- * and arrays.
38785
- *
38786
- * **Details**
38787
- *
38788
- * JSON Schema:
38789
- *
38790
- * The bound must be finite; it is rounded down and clamped to zero. For arrays,
38791
- * this check corresponds to `minItems`. JavaScript counts UTF-16 code units
38792
- * while JSON Schema counts Unicode code points, so strings use
38793
- * `minLength: Math.ceil(minLength / 2)`, the tightest lower bound that cannot
38794
- * reject a string accepted by this check.
38795
- *
38796
- * Arbitrary:
38797
- *
38798
- * During arbitrary generation, this applies a `minLength`
38799
- * constraint to ensure generated strings or arrays have at least the required
38800
- * length.
38801
- *
38802
- * **Example** (Checking minimum length)
38803
- *
38804
- * ```ts import.meta.vitest
38805
- * import { Schema } from "effect"
38806
- *
38807
- * const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1))
38808
- * const NonEmptyArraySchema = Schema.Array(Schema.Number).check(Schema.isMinLength(1))
38809
- * Schema.is(NonEmptyStringSchema)("a") // => true
38810
- * Schema.is(NonEmptyArraySchema)([1]) // => true
38811
- * ```
38812
- *
38813
- * @stability stable
38814
- * @category validation
38815
- * @since 4.0.0
38816
- */
38817
- function isMinLength(minLength, annotations) {
38818
- minLength = normalizeCardinality(minLength);
38819
- return makeIsMinLength(minLength, Math.ceil(minLength / 2), annotations);
38820
- }
38821
37376
  function makeIsMinLength(minLength, minCodePoints, annotations) {
38822
37377
  return makeFilter((input) => input.length >= minLength, {
38823
37378
  expected: `a value with a length of at least ${minLength}`,
@@ -39431,58 +37986,6 @@ function Exit(value, error, defect) {
39431
37986
  });
39432
37987
  }
39433
37988
  /**
39434
- * Schema that decodes URL parameters into a record of string values.
39435
- *
39436
- * **Details**
39437
- *
39438
- * Keys with one value decode to a string, and keys with multiple values decode to
39439
- * a non-empty readonly array of strings.
39440
- *
39441
- * **Example** (Decoding URL parameters to a record)
39442
- *
39443
- * ```ts import.meta.vitest
39444
- * import { Schema } from "effect"
39445
- * import { UrlParams } from "effect/http"
39446
- *
39447
- * const toStruct = Schema.RecordFromUrlParams.pipe(
39448
- * Schema.decodeTo(Schema.Struct({
39449
- * some: Schema.String,
39450
- * number: Schema.FiniteFromString
39451
- * }))
39452
- * )
39453
- *
39454
- * const decoded = Schema.decodeSync(toStruct)(UrlParams.fromInput({
39455
- * some: "value",
39456
- * number: 42
39457
- * }))
39458
- * const result = [decoded.some, decoded.number] // => ["value", 42]
39459
- * ```
39460
- *
39461
- * @stability unstable
39462
- * @category schemas
39463
- * @since 4.0.0
39464
- */
39465
- const RecordFromUrlParams = /*#__PURE__*/ (/* @__PURE__ */ declare(isUrlParams, {
39466
- representation: {
39467
- id: "effect/http/UrlParams",
39468
- payload: null
39469
- },
39470
- toCode: () => ({
39471
- runtime: "Schema.UrlParams",
39472
- Type: "UrlParams.UrlParams",
39473
- importDeclarations: [`import * as UrlParams from "effect/http/UrlParams"`]
39474
- }),
39475
- expected: "UrlParams",
39476
- toEquivalence: () => Equivalence,
39477
- toCodec: () => link$1()(ArraySchema(Tuple([String$2, String$2])), transform({
39478
- decode: make$45,
39479
- encode: (self) => self.params.map(([key, value]) => [key, unwrap$1(value)])
39480
- }))
39481
- })).pipe(/*#__PURE__*/ decodeTo(/*#__PURE__*/ Record(String$2, /*#__PURE__*/ Union([String$2, /*#__PURE__*/ NonEmptyArray(String$2)])), /*#__PURE__*/ transform({
39482
- decode: toReadonlyRecord,
39483
- encode: fromInput
39484
- })));
39485
- /**
39486
37989
  * Schema for `Redacted` values, which hide their contents from inspection.
39487
37990
  *
39488
37991
  * **Details**
@@ -39503,7 +38006,7 @@ const RecordFromUrlParams = /*#__PURE__*/ (/* @__PURE__ */ declare(isUrlParams,
39503
38006
  * @category schemas
39504
38007
  * @since 3.10.0
39505
38008
  */
39506
- function Redacted$1(value, options) {
38009
+ function Redacted(value, options) {
39507
38010
  const label = typeof options?.label === "string" ? options.label : void 0;
39508
38011
  const disallowJsonEncode = options?.disallowJsonEncode === true;
39509
38012
  const normalizedOptions = label !== void 0 ? disallowJsonEncode ? {
@@ -39970,23 +38473,6 @@ const MutableJson = /*#__PURE__*/ make$42(/*#__PURE__*/ annotate(MutableJson$1,
39970
38473
  //#endregion
39971
38474
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpBody.js
39972
38475
  const TypeId$26 = "~effect/http/HttpBody";
39973
- const HttpBodyErrorTypeId = "~effect/http/HttpBody/HttpBodyError";
39974
- /**
39975
- * Error produced while constructing an HTTP body from JSON or schema-encoded input.
39976
- *
39977
- * @stability unstable
39978
- * @category errors
39979
- * @since 4.0.0
39980
- */
39981
- var HttpBodyError = class extends (/*#__PURE__*/ TaggedError$1("HttpBodyError")) {
39982
- /**
39983
- * Marks this value as an HTTP body error for runtime guards.
39984
- *
39985
- * @stability unstable
39986
- * @since 4.0.0
39987
- */
39988
- [HttpBodyErrorTypeId] = HttpBodyErrorTypeId;
39989
- };
39990
38476
  var Proto$10 = class {
39991
38477
  [TypeId$26];
39992
38478
  constructor() {
@@ -40146,53 +38632,6 @@ const text$1 = (body, contentType) => {
40146
38632
  */
40147
38633
  const jsonUnsafe$1 = (body, contentType) => text$1(JSON.stringify(body), contentType ?? "application/json");
40148
38634
  /**
40149
- * Creates a JSON HTTP body in an `Effect`.
40150
- *
40151
- * **Details**
40152
- *
40153
- * `JSON.stringify` failures are captured as `HttpBodyError` values, and the content type defaults to `application/json`.
40154
- *
40155
- * @stability unstable
40156
- * @category constructors
40157
- * @since 4.0.0
40158
- */
40159
- const json$1 = (body, contentType) => try_({
40160
- try: () => text$1(JSON.stringify(body), contentType ?? "application/json"),
40161
- catch: (cause) => new HttpBodyError({
40162
- reason: { _tag: "JsonError" },
40163
- cause
40164
- })
40165
- });
40166
- /**
40167
- * Creates a JSON body constructor that first encodes values with the schema's JSON codec.
40168
- *
40169
- * **Details**
40170
- *
40171
- * Schema encoding issues and JSON serialization failures are returned as `HttpBodyError` values.
40172
- *
40173
- * @stability unstable
40174
- * @category constructors
40175
- * @since 4.0.0
40176
- */
40177
- const jsonSchema = (schema, options) => {
40178
- const encode = encodeUnknownEffect$1(toCodecJson(schema));
40179
- return (body, contentType) => encode(body, options).pipe(mapError$2((issue) => new HttpBodyError({
40180
- reason: {
40181
- _tag: "SchemaError",
40182
- issue
40183
- },
40184
- cause: issue
40185
- })), flatMap$1((body) => json$1(body, contentType)));
40186
- };
40187
- /**
40188
- * Creates an `application/x-www-form-urlencoded` HTTP body from `UrlParams`.
40189
- *
40190
- * @stability unstable
40191
- * @category constructors
40192
- * @since 4.0.0
40193
- */
40194
- const urlParams = (urlParams, contentType) => text$1(toString$1(fromInput(urlParams)), contentType ?? "application/x-www-form-urlencoded");
40195
- /**
40196
38635
  * HTTP body variant backed by a stream of `Uint8Array` chunks.
40197
38636
  *
40198
38637
  * @stability unstable
@@ -40489,17 +38928,6 @@ const updateHeaders = (headers, body) => {
40489
38928
  //#endregion
40490
38929
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/Url.js
40491
38930
  /**
40492
- * Parses and edits platform `URL` values.
40493
- *
40494
- * The HTTP modules use the standard `URL` object as their URL representation.
40495
- * This module adds safe parsing and helpers that return updated copies when
40496
- * changing credentials, host, path, protocol, query, or hash parts. Query
40497
- * strings can also be read or updated through `UrlParams`.
40498
- *
40499
- * @stability unstable
40500
- * @since 4.0.0
40501
- */
40502
- /**
40503
38931
  * Error returned when constructing a `URL` fails.
40504
38932
  *
40505
38933
  * @stability unstable
@@ -40533,51 +38961,6 @@ const make$41 = (url, params, hash) => try_$2({
40533
38961
  const baseUrl = () => {
40534
38962
  if ("location" in globalThis && globalThis.location !== void 0 && globalThis.location.origin !== void 0 && globalThis.location.pathname !== void 0) return location.origin + location.pathname;
40535
38963
  };
40536
- /**
40537
- * Parses a URL string safely into a `URL` object, returning a `Result` type for
40538
- * error handling.
40539
- *
40540
- * **Details**
40541
- *
40542
- * This function converts a string into a `URL` object, enabling safe URL
40543
- * parsing with built-in error handling. If the string is invalid or fails to
40544
- * parse, this function does not throw an error; instead, it wraps the error in
40545
- * a `IllegalArgumentError` and returns it as the `Failure` value of an
40546
- * `Result`. The `Success` value contains the successfully parsed `URL`.
40547
- *
40548
- * An optional `base` parameter can be provided to resolve relative URLs. If
40549
- * specified, the function interprets the input `url` as relative to this
40550
- * `base`. This is especially useful when dealing with URLs that might not be
40551
- * fully qualified.
40552
- *
40553
- * **Example** (Parsing absolute and relative URLs)
40554
- *
40555
- * ```ts import.meta.vitest
40556
- * import { Result } from "effect"
40557
- * import { Url } from "effect/http"
40558
- *
40559
- * // Parse an absolute URL
40560
- * //
40561
- * // ┌─── Result<URL, IllegalArgumentError>
40562
- * // ▼
40563
- * const parsed = Url.fromString("https://example.com/path")
40564
- *
40565
- * Result.map(parsed, (url) => url.toString()) // => Result.succeed("https://example.com/path")
40566
- *
40567
- * // Parse a relative URL with a base
40568
- * const relativeParsed = Url.fromString("/relative-path", "https://example.com")
40569
- *
40570
- * Result.map(relativeParsed, (url) => url.toString()) // => Result.succeed("https://example.com/relative-path")
40571
- * ```
40572
- *
40573
- * @stability unstable
40574
- * @category constructors
40575
- * @since 4.0.0
40576
- */
40577
- const fromString = (url, base) => try_$2({
40578
- try: () => new URL(url, base),
40579
- catch: () => new IllegalArgumentError(`Invalid URL: "${url}"${base !== void 0 ? ` with base "${base}"` : ""}`)
40580
- });
40581
38964
  //#endregion
40582
38965
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/http/HttpClientRequest.js
40583
38966
  const TypeId$24 = "~effect/http/HttpClientRequest";
@@ -40637,22 +39020,6 @@ const make$40 = (method) => (url, options) => modify(empty$1, {
40637
39020
  ...options ?? void 0
40638
39021
  });
40639
39022
  /**
40640
- * Creates a `GET` request for the specified URL.
40641
- *
40642
- * @stability unstable
40643
- * @category constructors
40644
- * @since 4.0.0
40645
- */
40646
- const get$1 = /*#__PURE__*/ make$40("GET");
40647
- /**
40648
- * Creates a `POST` request for the specified URL.
40649
- *
40650
- * @stability unstable
40651
- * @category constructors
40652
- * @since 4.0.0
40653
- */
40654
- const post = /*#__PURE__*/ make$40("POST");
40655
- /**
40656
39023
  * Applies request options to an `HttpClientRequest`, returning a new request.
40657
39024
  *
40658
39025
  * @stability unstable
@@ -40696,14 +39063,6 @@ const setHeader$1 = /*#__PURE__*/ dual(3, (self, key, value) => makeWith$2(self.
40696
39063
  */
40697
39064
  const setHeaders$1 = /*#__PURE__*/ dual(2, (self, input) => makeWith$2(self.method, self.url, self.urlParams, self.hash, setAll$1(self.headers, input), self.body));
40698
39065
  /**
40699
- * Sets the `Authorization` header using a bearer token.
40700
- *
40701
- * @stability unstable
40702
- * @category combinators
40703
- * @since 4.0.0
40704
- */
40705
- const bearerToken = /*#__PURE__*/ dual(2, (self, token) => setHeader$1(self, "Authorization", `Bearer ${stringOrRedacted(token)}`));
40706
- /**
40707
39066
  * Sets the `Accept` header to the specified media type.
40708
39067
  *
40709
39068
  * @stability unstable
@@ -40762,14 +39121,6 @@ const setBody$1 = /*#__PURE__*/ dual(2, (self, body) => {
40762
39121
  return makeWith$2(self.method, self.url, self.urlParams, self.hash, updateHeaders(self.headers, body), body);
40763
39122
  });
40764
39123
  /**
40765
- * Sets an `application/x-www-form-urlencoded` request body from URL parameter input.
40766
- *
40767
- * @stability unstable
40768
- * @category combinators
40769
- * @since 4.0.0
40770
- */
40771
- const bodyUrlParams = /*#__PURE__*/ dual(2, (self, input) => setBody$1(self, urlParams(fromInput(input))));
40772
- /**
40773
39124
  * Builds a `URL` from the request URL, query parameters, and hash, returning `Option.none()` if the URL is invalid.
40774
39125
  *
40775
39126
  * @stability unstable
@@ -40804,17 +39155,6 @@ const schemaBodyJson$1 = (schema, options) => {
40804
39155
  return (self) => decodeJson === void 0 ? flatMap$1(self.json, (u) => decode(u, options)) : flatMap$1(self.text, (body) => body === "" ? flatMap$1(self.json, (u) => decode(u, options)) : decodeJson(body, options));
40805
39156
  };
40806
39157
  /**
40807
- * Creates a decoder that reads an incoming message's URL-encoded body parameters and decodes them with the supplied schema.
40808
- *
40809
- * @stability unstable
40810
- * @category schemas
40811
- * @since 4.0.0
40812
- */
40813
- const schemaBodyUrlParams$1 = (schema, options) => {
40814
- const decode = RecordFromUrlParams.pipe(decodeTo(schema), decodeEffect);
40815
- return (self) => flatMap$1(self.urlParamsBody, (u) => decode(u, options));
40816
- };
40817
- /**
40818
39158
  * Context reference for the optional maximum size allowed when reading an incoming message body.
40819
39159
  *
40820
39160
  * @stability unstable
@@ -42394,27 +40734,6 @@ const empty = (options) => makeResponse({
42394
40734
  cookies: options?.cookies
42395
40735
  });
42396
40736
  /**
42397
- * Creates a redirect response with a `Location` header.
42398
- *
42399
- * **Details**
42400
- *
42401
- * The default status is `302`; custom headers are merged with the generated
42402
- * `Location` header.
42403
- *
42404
- * @stability unstable
42405
- * @category constructors
42406
- * @since 4.0.0
42407
- */
42408
- const redirect = (location, options) => {
42409
- const headers = fromRecordUnsafe({ location: location.toString() });
42410
- return makeResponse({
42411
- status: options?.status ?? 302,
42412
- statusText: options?.statusText,
42413
- headers: options?.headers ? merge(headers, fromInput$1(options.headers)) : headers,
42414
- cookies: options?.cookies ?? empty$6
42415
- });
42416
- };
42417
- /**
42418
40737
  * Creates an HTTP response whose body is a `Uint8Array`.
42419
40738
  *
42420
40739
  * @stability unstable
@@ -42453,32 +40772,6 @@ const text = (body, options) => {
42453
40772
  });
42454
40773
  };
42455
40774
  /**
42456
- * Creates a JSON response constructor backed by a schema encoder.
42457
- *
42458
- * **Details**
42459
- *
42460
- * The returned function encodes the value with the supplied schema before
42461
- * serializing it as JSON, and can fail with `HttpBodyError` if schema encoding or
42462
- * JSON serialization fails.
42463
- *
42464
- * @stability unstable
42465
- * @category constructors
42466
- * @since 4.0.0
42467
- */
42468
- const schemaJson = (schema, options) => {
42469
- const encode = jsonSchema(schema, options);
42470
- return (body, options) => {
42471
- const headers = options?.headers ? fromInput$1(options.headers) : empty$5;
42472
- return map$2(encode(body, getContentType(options, headers)), (body) => makeResponse({
42473
- status: options?.status ?? 200,
42474
- statusText: options?.statusText,
42475
- headers,
42476
- cookies: options?.cookies,
42477
- body
42478
- }));
42479
- };
42480
- };
42481
- /**
42482
40775
  * Creates a JSON HTTP response synchronously.
42483
40776
  *
42484
40777
  * **When to use**
@@ -42578,40 +40871,6 @@ const removeHeader = /*#__PURE__*/ dual(2, (self, key) => makeResponse({
42578
40871
  */
42579
40872
  const setHeaders = /*#__PURE__*/ dual(2, (self, input) => makeResponse(self, setAll$1(self.headers, input)));
42580
40873
  /**
42581
- * Sets a cookie on an `HttpServerResponse`, throwing if the cookie cannot be
42582
- * encoded.
42583
- *
42584
- * **When to use**
42585
- *
42586
- * Use when you need to set one trusted cookie and want encoding failures to
42587
- * throw instead of being represented as `CookiesError` failures.
42588
- *
42589
- * @stability unstable
42590
- * @category combinators
42591
- * @since 4.0.0
42592
- */
42593
- const setCookieUnsafe = /*#__PURE__*/ dual((args) => isHttpServerResponse(args[0]), (self, name, value, options) => makeResponse({
42594
- ...self,
42595
- cookies: setUnsafe(self.cookies, name, value, options)
42596
- }));
42597
- /**
42598
- * Sets an expired cookie on an `HttpServerResponse`, throwing if the expiration cookie
42599
- * cannot be encoded.
42600
- *
42601
- * **When to use**
42602
- *
42603
- * Use when you need to expire one trusted cookie and want encoding failures to
42604
- * throw instead of being represented as `CookiesError` failures.
42605
- *
42606
- * @stability unstable
42607
- * @category combinators
42608
- * @since 4.0.0
42609
- */
42610
- const expireCookieUnsafe = /*#__PURE__*/ dual((args) => isHttpServerResponse(args[0]), (self, name, options) => makeResponse({
42611
- ...self,
42612
- cookies: expireCookieUnsafe$1(self.cookies, name, options)
42613
- }));
42614
- /**
42615
40874
  * Replaces the body of an `HttpServerResponse`.
42616
40875
  *
42617
40876
  * **Details**
@@ -43940,7 +42199,7 @@ const fromWebSocket = (acquire, options) => withFiber((fiber) => {
43940
42199
  const acquireContext = fiber.context;
43941
42200
  const reader = gen(function* () {
43942
42201
  const scope$7 = yield* scope;
43943
- const ws = yield* provide$4(acquire, scope$7);
42202
+ const ws = yield* provide$3(acquire, scope$7);
43944
42203
  if ("binaryType" in ws) ws.binaryType = "arraybuffer";
43945
42204
  const pausable = isPausable(ws);
43946
42205
  const highWaterMark = options?.highWaterMark ?? (pausable ? defaultHighWaterMark : void 0);
@@ -44785,7 +43044,7 @@ const isMultipartError = (u) => hasProperty(u, MultipartErrorTypeId);
44785
43044
  * @since 4.0.0
44786
43045
  */
44787
43046
  const makeConfig = (headers) => withFiber((fiber) => {
44788
- const mimeTypes = get$10(fiber.context, FieldMimeTypes);
43047
+ const mimeTypes = get$9(fiber.context, FieldMimeTypes);
44789
43048
  return succeed$4({
44790
43049
  headers,
44791
43050
  maxParts: fiber.getRef(MaxParts),
@@ -45100,17 +43359,6 @@ const HttpServerRequest = /*#__PURE__*/ Service$2("effect/http/HttpServerRequest
45100
43359
  */
45101
43360
  var ParsedSearchParams = class extends (/*#__PURE__*/ Service$2()("effect/http/ParsedSearchParams")) {};
45102
43361
  /**
45103
- * Decodes a schema from the parsed search parameters of the current request.
45104
- *
45105
- * @stability unstable
45106
- * @category schemas
45107
- * @since 4.0.0
45108
- */
45109
- const schemaSearchParams = (schema, options) => {
45110
- const parse = decodeUnknownEffect(schema);
45111
- return flatMap$1(ParsedSearchParams, (params) => parse(params, options));
45112
- };
45113
- /**
45114
43362
  * Reads the current request body as JSON and decodes it with the supplied schema.
45115
43363
  *
45116
43364
  * **Details**
@@ -45127,18 +43375,6 @@ const schemaBodyJson = (schema, options) => {
45127
43375
  return flatMap$1(HttpServerRequest, parse);
45128
43376
  };
45129
43377
  /**
45130
- * Reads the current request body as URL-encoded parameters and decodes them with
45131
- * the supplied schema.
45132
- *
45133
- * @stability unstable
45134
- * @category schemas
45135
- * @since 4.0.0
45136
- */
45137
- const schemaBodyUrlParams = (schema, options) => {
45138
- const parse = schemaBodyUrlParams$1(schema, options);
45139
- return flatMap$1(HttpServerRequest, parse);
45140
- };
45141
- /**
45142
43378
  * Attempts to construct an absolute `URL` for a server request safely.
45143
43379
  *
45144
43380
  * **Details**
@@ -46217,12 +44453,12 @@ var MiddlewareImpl = class MiddlewareImpl {
46217
44453
  const stack = [getOrUndefinedUnsafe(context$3, fnContextKey)];
46218
44454
  if (this.dependencies) {
46219
44455
  const memoMap = yield* CurrentMemoMap;
46220
- const scope = get$10(context$3, Scope);
44456
+ const scope = get$9(context$3, Scope);
46221
44457
  const depsContext = yield* buildWithMemoMap(this.dependencies, memoMap, scope);
46222
44458
  stack.push(...getMiddleware(depsContext));
46223
44459
  }
46224
44460
  return makeUnsafe$8(/* @__PURE__ */ new Map([[contextKey, stack]]));
46225
- })).pipe(provide$3(this.layerFn));
44461
+ })).pipe(provide$2(this.layerFn));
46226
44462
  }
46227
44463
  layer;
46228
44464
  combine(other) {
@@ -46276,13 +44512,13 @@ const cors = (options) => middleware(cors$1(options), { global: true });
46276
44512
  */
46277
44513
  const serve = (appLayer, options) => {
46278
44514
  let middleware = options?.middleware;
46279
- if (options?.disableLogger !== true) middleware = middleware ? compose$1(middleware, logger) : logger;
46280
- const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide$3(layer$17, succeed$5(RouterConfig)(options.routerConfig)) : layer$17);
44515
+ if (options?.disableLogger !== true) middleware = middleware ? compose(middleware, logger) : logger;
44516
+ const layerWithRouter = provideMerge(appLayer, options?.routerConfig ? provide$2(layer$17, succeed$5(RouterConfig)(options.routerConfig)) : layer$17);
46281
44517
  return contextWith((context) => {
46282
44518
  const memoMap = CurrentMemoMap.forkOrCreate(context);
46283
- return buildWithMemoMap(layerWithRouter, memoMap, get$10(context, Scope));
44519
+ return buildWithMemoMap(layerWithRouter, memoMap, get$9(context, Scope));
46284
44520
  }).pipe(map$2((context) => {
46285
- const handler = get$10(context, HttpRouter).asHttpEffect();
44521
+ const handler = get$9(context, HttpRouter).asHttpEffect();
46286
44522
  return merge$3(middleware ? serve$1(handler, middleware) : serve$1(handler), succeedContext(context));
46287
44523
  }), unwrap$5, options?.disableListenLog ? identity : withLogAddress);
46288
44524
  };
@@ -47018,7 +45254,7 @@ const makeNoSerialization$1 = /*#__PURE__*/ fnUntraced(function* (group, options
47018
45254
  const disableTracing = options?.disableTracing ?? false;
47019
45255
  const generateRequestId = options?.generateRequestId ?? (() => requestIdCounter++);
47020
45256
  const services = yield* context();
47021
- const scope = get$10(services, Scope);
45257
+ const scope = get$9(services, Scope);
47022
45258
  const entries = /* @__PURE__ */ new Map();
47023
45259
  let isShutdown = false;
47024
45260
  yield* addFinalizer$1(scope, withFiber((parent) => {
@@ -47482,7 +45718,7 @@ const makeNoSerialization = /*#__PURE__*/ fnUntraced(function* (group, options)
47482
45718
  const concurrency = options.concurrency ?? "unbounded";
47483
45719
  const disableFatalDefects = options.disableFatalDefects ?? false;
47484
45720
  const services = yield* context();
47485
- const scope = get$10(services, Scope);
45721
+ const scope = get$9(services, Scope);
47486
45722
  const trackFiber = runIn(forkUnsafe(scope, "parallel"));
47487
45723
  const concurrencySemaphore = concurrency === "unbounded" ? void 0 : yield* make$60(concurrency);
47488
45724
  const clients = /* @__PURE__ */ new Map();
@@ -47794,7 +46030,7 @@ const make$24 = /*#__PURE__*/ fnUntraced(function* (group, options) {
47794
46030
  return end(response.clientId);
47795
46031
  }
47796
46032
  }
47797
- }).pipe(provide$4(scope));
46033
+ }).pipe(provide$3(scope));
47798
46034
  yield* forkChild(whileLoop({
47799
46035
  while: constTrue,
47800
46036
  body: constant(flatMap$1(take(disconnects), (clientId) => {
@@ -48135,7 +46371,7 @@ const RpcGroupProto = {
48135
46371
  options.rpc = rpc;
48136
46372
  const result = handler(payload, options);
48137
46373
  const effectOrStream = isWrapper(result) ? result.value : result;
48138
- return isEffect(effectOrStream) ? provide$1(effectOrStream, context) : provideContext(effectOrStream, context);
46374
+ return isEffect(effectOrStream) ? provide(effectOrStream, context) : provideContext(effectOrStream, context);
48139
46375
  });
48140
46376
  });
48141
46377
  },
@@ -48924,7 +47160,6 @@ const PortSchema = /*#__PURE__*/ Int.check(/*#__PURE__*/ isBetween({
48924
47160
  minimum: 1,
48925
47161
  maximum: 65535
48926
47162
  }));
48927
- const isPath = (u) => isString$2(u) || globalThis.Array.isArray(u);
48928
47163
  /**
48929
47164
  * Creates a config that always succeeds with the given value, ignoring the
48930
47165
  * provider entirely.
@@ -48985,16 +47220,6 @@ function succeed(value) {
48985
47220
  function String$1(name) {
48986
47221
  return schema(String$2, name);
48987
47222
  }
48988
- function Array$1(value, pathOrOptions, options) {
48989
- const hasPath = isPath(pathOrOptions);
48990
- const resolvedOptions = hasPath ? options : pathOrOptions;
48991
- const array = ArraySchema(value);
48992
- const separator = resolvedOptions?.separator ?? ",";
48993
- return schema(Union([String$2.pipe(decodeTo(toCodecStringTree(array), {
48994
- decode: split(resolvedOptions),
48995
- encode: compose(passthrough$1({ strict: false }), transform$1((input) => input.join(separator)))
48996
- })), array]), hasPath ? pathOrOptions : void 0);
48997
- }
48998
47223
  /**
48999
47224
  * Creates a config for a port number (integer in 1–65535).
49000
47225
  *
@@ -49033,46 +47258,6 @@ function Array$1(value, pathOrOptions, options) {
49033
47258
  function Port(name) {
49034
47259
  return schema(PortSchema, name);
49035
47260
  }
49036
- /**
49037
- * Creates a config for a redacted string value. The parsed result is wrapped
49038
- * in a `Redacted` container that hides the value from logs and `toString`.
49039
- *
49040
- * **When to use**
49041
- *
49042
- * Use to read secret string settings that should not be exposed in logs or
49043
- * string output.
49044
- *
49045
- * **Details**
49046
- *
49047
- * Shortcut for `Config.schema(Schema.Redacted(Schema.String), name)`.
49048
- *
49049
- * **Example** (Reading a secret)
49050
- *
49051
- * ```ts import.meta.vitest
49052
- * import { Config, ConfigProvider, Effect } from "effect"
49053
- *
49054
- * const program = Config.Redacted("API_KEY").pipe(Effect.map(String))
49055
- *
49056
- * const provider = ConfigProvider.fromEnv({
49057
- * env: {
49058
- * API_KEY: "sk-1234567890abcdef"
49059
- * }
49060
- * })
49061
- *
49062
- * Effect.runSync(
49063
- * program.pipe(Effect.provideService(ConfigProvider.ConfigProvider, provider))
49064
- * ) // => "<redacted>"
49065
- * ```
49066
- *
49067
- * @see {@link String} for non-secret string settings
49068
- *
49069
- * @stability stable
49070
- * @category constructors
49071
- * @since 2.0.0
49072
- */
49073
- function Redacted(name) {
49074
- return schema(Redacted$1(String$2), name);
49075
- }
49076
47261
  //#endregion
49077
47262
  //#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/ulid.js
49078
47263
  const maxTimestamp = 2 ** 48 - 1;
@@ -49342,7 +47527,7 @@ const make$19 = /*#__PURE__*/ sync(() => {
49342
47527
  };
49343
47528
  const query = (keys, effect) => gen(function* () {
49344
47529
  const services = yield* context();
49345
- const scope = get$10(services, Scope);
47530
+ const scope = get$9(services, Scope);
49346
47531
  const results = yield* make$61();
49347
47532
  const runFork = flow(runForkWith(services), runIn(scope));
49348
47533
  let running = false;
@@ -50619,7 +48804,7 @@ const make$17 = /*#__PURE__*/ fnUntraced(function* (options) {
50619
48804
  const withTransaction = makeWithTransaction({
50620
48805
  transactionService,
50621
48806
  spanAttributes: options.spanAttributes,
50622
- acquireConnection: flatMap$1(make$69(), (scope) => provide$4(transactionAcquirer, scope).pipe(onError((cause) => close(scope, failCause$5(cause))), map$2((conn) => [scope, conn]))),
48807
+ acquireConnection: flatMap$1(make$69(), (scope) => provide$3(transactionAcquirer, scope).pipe(onError((cause) => close(scope, failCause$5(cause))), map$2((conn) => [scope, conn]))),
50623
48808
  begin: (conn) => control(conn, beginTransaction),
50624
48809
  savepoint: (conn, id) => control(conn, savepoint(`effect_sql_${id}`)),
50625
48810
  releaseSavepoint: releaseSavepoint ? (conn, id) => control(conn, releaseSavepoint(`effect_sql_${id}`)) : void 0,
@@ -55281,7 +53466,7 @@ const make$14 = /*#__PURE__*/ make$36({
55281
53466
  * @category layers
55282
53467
  * @since 4.0.0
55283
53468
  */
55284
- const layer$10 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$14), /*#__PURE__*/ provide$3(layer$12), /*#__PURE__*/ provide$3(layer$18));
53469
+ const layer$10 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$14), /*#__PURE__*/ provide$2(layer$12), /*#__PURE__*/ provide$2(layer$18));
55285
53470
  //#endregion
55286
53471
  //#region ../../node_modules/.pnpm/@effect+platform-node@4.0.5_effect@4.0.5_redis@6.3.0_@opentelemetry+api@1.9.1_/node_modules/@effect/platform-node/dist/NodeMultipartParser.js
55287
53472
  /**
@@ -55764,13 +53949,13 @@ const layer$5 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
55764
53949
  stdin.on("keypress", handleKeypress);
55765
53950
  if (inputEnded) handleEnd();
55766
53951
  else {
55767
- yield* get$4(rlRef);
53952
+ yield* get$3(rlRef);
55768
53953
  stdin.once("end", handleEnd);
55769
53954
  }
55770
53955
  return queue;
55771
53956
  });
55772
53957
  const readLine = suspend$2(() => poll(lines).pipe(flatMap$1(match$4({
55773
- onNone: () => scoped(andThen(get$4(rlRef), take(lines))),
53958
+ onNone: () => scoped(andThen(get$3(rlRef), take(lines))),
55774
53959
  onSome: succeed$4
55775
53960
  })), mapError$2(() => new QuitError({}))));
55776
53961
  const display = (prompt) => uninterruptible(callback$1((resume) => {
@@ -55862,7 +54047,7 @@ const make$10 = /*#__PURE__*/ fnUntraced(function* (evaluate, options) {
55862
54047
  noServer: true
55863
54048
  })), (wss) => callback$1((resume) => {
55864
54049
  wss.close(() => resume(void_$1));
55865
- })).pipe(provide$4(scope$3), cached);
54050
+ })).pipe(provide$3(scope$3), cached);
55866
54051
  return make$29({
55867
54052
  address: boundAddress,
55868
54053
  serve: fnUntraced(function* (httpApp, middleware) {
@@ -56324,7 +54509,7 @@ const defaultTimeToLive = (_, _key) => infinity;
56324
54509
  * @since 4.0.0
56325
54510
  */
56326
54511
  const get = /*#__PURE__*/ dual(2, (self, key) => withFiber$1((fiber) => {
56327
- const oentry = get$7(self.map, key);
54512
+ const oentry = get$6(self.map, key);
56328
54513
  if (isSome(oentry)) {
56329
54514
  remove$3(self.map, key);
56330
54515
  if (!hasExpired(oentry.value, fiber)) {
@@ -56377,7 +54562,7 @@ var EntryImpl = class {
56377
54562
  }
56378
54563
  };
56379
54564
  const removeEntry = (self, key, entry) => {
56380
- const current = get$7(self.map, key);
54565
+ const current = get$6(self.map, key);
56381
54566
  if (isSome(current) && current.value === entry) remove$3(self.map, key);
56382
54567
  };
56383
54568
  const hasExpired = (entry, fiber) => {
@@ -56824,7 +55009,7 @@ const make$9 = (options) => gen(function* () {
56824
55009
  timeToLive: (exit) => isSuccess(exit) ? prepareCacheTTL : zero$2
56825
55010
  });
56826
55011
  const runStatement = (statement, params, raw) => withFiber((fiber) => {
56827
- const useSafeIntegers = get$10(fiber.context, SafeIntegers);
55012
+ const useSafeIntegers = get$9(fiber.context, SafeIntegers);
56828
55013
  return try_({
56829
55014
  try: () => {
56830
55015
  statement.setReadBigInts(useSafeIntegers);
@@ -56839,7 +55024,7 @@ const make$9 = (options) => gen(function* () {
56839
55024
  });
56840
55025
  });
56841
55026
  const runStatementValues = (statement, params) => withFiber((fiber) => {
56842
- const useSafeIntegers = get$10(fiber.context, SafeIntegers);
55027
+ const useSafeIntegers = get$9(fiber.context, SafeIntegers);
56843
55028
  return try_({
56844
55029
  try: () => {
56845
55030
  statement.setReadBigInts(useSafeIntegers);
@@ -56849,7 +55034,7 @@ const make$9 = (options) => gen(function* () {
56849
55034
  });
56850
55035
  });
56851
55036
  const runStatementValuesUnprepared = (statement, params) => withFiber((fiber) => {
56852
- const useSafeIntegers = get$10(fiber.context, SafeIntegers);
55037
+ const useSafeIntegers = get$9(fiber.context, SafeIntegers);
56853
55038
  return try_({
56854
55039
  try: () => {
56855
55040
  statement.setReadBigInts(useSafeIntegers);
@@ -56937,7 +55122,7 @@ const make$9 = (options) => gen(function* () {
56937
55122
  * @category layers
56938
55123
  * @since 4.0.0
56939
55124
  */
56940
- const layer$2 = (config) => effectContext(map$2(make$9(config), (client) => make$73(SqliteClient, client).pipe(add$3(SqlClient, client)))).pipe(provide$3(layer$16));
55125
+ const layer$2 = (config) => effectContext(map$2(make$9(config), (client) => make$73(SqliteClient, client).pipe(add$3(SqlClient, client)))).pipe(provide$2(layer$16));
56941
55126
  const classifyError = (cause, message, operation) => classifySqliteError(sqliteCauseWithErrno(cause), {
56942
55127
  message,
56943
55128
  operation
@@ -57647,9 +55832,9 @@ const HttpRequestDetails = /*#__PURE__*/ Struct({
57647
55832
  "QUERY"
57648
55833
  ]),
57649
55834
  url: String$2,
57650
- urlParams: ArraySchema(Tuple([String$2, Union([String$2, Redacted$1(String$2)])])),
55835
+ urlParams: ArraySchema(Tuple([String$2, Union([String$2, Redacted(String$2)])])),
57651
55836
  hash: optional$6(String$2),
57652
- headers: Record(String$2, Union([String$2, Redacted$1(String$2)]))
55837
+ headers: Record(String$2, Union([String$2, Redacted(String$2)]))
57653
55838
  }).annotate({ identifier: "HttpRequestDetails" });
57654
55839
  /**
57655
55840
  * Schema for HTTP responses from an AI provider.
@@ -57675,7 +55860,7 @@ const HttpRequestDetails = /*#__PURE__*/ Struct({
57675
55860
  */
57676
55861
  const HttpResponseDetails = /*#__PURE__*/ Struct({
57677
55862
  status: Int,
57678
- headers: Record(String$2, Union([String$2, Redacted$1(String$2)]))
55863
+ headers: Record(String$2, Union([String$2, Redacted(String$2)]))
57679
55864
  }).annotate({ identifier: "HttpResponseDetails" });
57680
55865
  const ReasonTypeId = "~effect/ai/AiError/Reason";
57681
55866
  const providerMetadataWithDefaults = () => ProviderMetadata.pipe(withConstructorDefault(succeed$4({})), withDecodingDefault(succeed$4({})));
@@ -59335,7 +57520,7 @@ const Strict = /*#__PURE__*/ Reference("effect/ai/Tool/Strict", { defaultValue:
59335
57520
  * @category getters
59336
57521
  * @since 4.0.0
59337
57522
  */
59338
- const getStrictMode = (tool) => get$10(tool.annotations, Strict);
57523
+ const getStrictMode = (tool) => get$9(tool.annotations, Strict);
59339
57524
  /**
59340
57525
  * Schema for denied or interrupted tool calls.
59341
57526
  *
@@ -63542,7 +61727,7 @@ const projectContent$2 = /*#__PURE__*/ fnUntraced(function* (content) {
63542
61727
  return value(content).pipe(when({ type: is("text", "resource_link") }, (content) => content), when({ type: is("image", "audio") }, (content) => ({
63543
61728
  type: content.type,
63544
61729
  mimeType: content.mimeType,
63545
- data: encode$1(content.data),
61730
+ data: encode(content.data),
63546
61731
  annotations: content.annotations,
63547
61732
  _meta: content._meta
63548
61733
  })), when({ type: "resource" }, (content) => {
@@ -63564,7 +61749,7 @@ const projectContent$2 = /*#__PURE__*/ fnUntraced(function* (content) {
63564
61749
  uri: resource.uri,
63565
61750
  mimeType: resource.mimeType,
63566
61751
  _meta: resource._meta,
63567
- blob: encode$1(resource.blob)
61752
+ blob: encode(resource.blob)
63568
61753
  },
63569
61754
  annotations: content.annotations,
63570
61755
  _meta: content._meta
@@ -63580,7 +61765,7 @@ const projectResourceContents$1 = (content) => "text" in content ? {
63580
61765
  uri: content.uri,
63581
61766
  mimeType: content.mimeType,
63582
61767
  _meta: content._meta,
63583
- blob: encode$1(content.blob)
61768
+ blob: encode(content.blob)
63584
61769
  };
63585
61770
  const projectStructuredContent$1 = (content) => content === void 0 || isJsonObject$1(content) ? content : void 0;
63586
61771
  const isJsonObject$1 = (value) => isReadonlyObject(value);
@@ -64272,7 +62457,7 @@ const projectContent$1 = /*#__PURE__*/ fnUntraced(function* (content) {
64272
62457
  return value(content).pipe(when({ type: is("text", "resource_link") }, (content) => content), when({ type: is("image", "audio") }, (content) => ({
64273
62458
  type: content.type,
64274
62459
  mimeType: content.mimeType,
64275
- data: encode$1(content.data),
62460
+ data: encode(content.data),
64276
62461
  annotations: content.annotations,
64277
62462
  _meta: content._meta
64278
62463
  })), when({ type: "resource" }, (content) => {
@@ -64294,7 +62479,7 @@ const projectContent$1 = /*#__PURE__*/ fnUntraced(function* (content) {
64294
62479
  uri: resource.uri,
64295
62480
  mimeType: resource.mimeType,
64296
62481
  _meta: resource._meta,
64297
- blob: encode$1(resource.blob)
62482
+ blob: encode(resource.blob)
64298
62483
  },
64299
62484
  annotations: content.annotations,
64300
62485
  _meta: content._meta
@@ -64363,7 +62548,7 @@ const protocol$1 = /*#__PURE__*/ make$4({
64363
62548
  uri: content.uri,
64364
62549
  mimeType: content.mimeType,
64365
62550
  _meta: content._meta,
64366
- blob: encode$1(content.blob)
62551
+ blob: encode(content.blob)
64367
62552
  }),
64368
62553
  _meta: result._meta
64369
62554
  });
@@ -64567,7 +62752,7 @@ const RequestMetaObject = /*#__PURE__*/ StructWithRest(/*#__PURE__*/ Struct({
64567
62752
  /**
64568
62753
  * @internal
64569
62754
  */
64570
- const RequestParams$1 = /*#__PURE__*/ Struct({ _meta: RequestMetaObject });
62755
+ const RequestParams = /*#__PURE__*/ Struct({ _meta: RequestMetaObject });
64571
62756
  /**
64572
62757
  * @internal
64573
62758
  */
@@ -64854,7 +63039,7 @@ const InputRequiredResult = /*#__PURE__*/ Union([/*#__PURE__*/ StructWithRest(/*
64854
63039
  * @internal
64855
63040
  */
64856
63041
  const InputResponseRequestParams = {
64857
- ...RequestParams$1.fields,
63042
+ ...RequestParams.fields,
64858
63043
  inputResponses: /*#__PURE__*/ optional(InputResponses$1),
64859
63044
  requestState: /*#__PURE__*/ optional(String$2)
64860
63045
  };
@@ -64870,7 +63055,7 @@ const CacheableResult = {
64870
63055
  * @internal
64871
63056
  */
64872
63057
  const PaginatedRequestParams = {
64873
- ...RequestParams$1.fields,
63058
+ ...RequestParams.fields,
64874
63059
  cursor: /*#__PURE__*/ optional(String$2)
64875
63060
  };
64876
63061
  /**
@@ -64895,7 +63080,7 @@ const DiscoverResult = /*#__PURE__*/ StructWithRest(/*#__PURE__*/ Struct({
64895
63080
  var Discover = class extends (/*#__PURE__*/ make$27("server/discover", {
64896
63081
  success: DiscoverResult,
64897
63082
  error: McpError,
64898
- payload: RequestParams$1
63083
+ payload: RequestParams
64899
63084
  })) {};
64900
63085
  /**
64901
63086
  * @internal
@@ -65046,7 +63231,7 @@ var Complete = class extends (/*#__PURE__*/ make$27("completion/complete", {
65046
63231
  success: CompleteResult,
65047
63232
  error: McpError,
65048
63233
  payload: {
65049
- ...RequestParams$1.fields,
63234
+ ...RequestParams.fields,
65050
63235
  ref: /*#__PURE__*/ Union([PromptReference, ResourceTemplateReference]),
65051
63236
  argument: /*#__PURE__*/ Struct({
65052
63237
  name: String$2,
@@ -65081,7 +63266,7 @@ var SubscriptionsListen = class extends (/*#__PURE__*/ make$27("subscriptions/li
65081
63266
  success: SubscriptionsListenResult,
65082
63267
  error: McpError,
65083
63268
  payload: {
65084
- ...RequestParams$1.fields,
63269
+ ...RequestParams.fields,
65085
63270
  notifications: SubscriptionFilter
65086
63271
  }
65087
63272
  })) {};
@@ -65241,12 +63426,12 @@ const projectResourceContents = (resource) => omitUndefined({
65241
63426
  uri: resource.uri,
65242
63427
  mimeType: resource.mimeType,
65243
63428
  _meta: resource._meta,
65244
- ..."text" in resource ? { text: resource.text } : { blob: encode$1(resource.blob) }
63429
+ ..."text" in resource ? { text: resource.text } : { blob: encode(resource.blob) }
65245
63430
  });
65246
63431
  const projectContent = /*#__PURE__*/ type().pipe(/*#__PURE__*/ when({ type: /*#__PURE__*/ is("text", "resource_link") }, (content) => content), /*#__PURE__*/ when({ type: /*#__PURE__*/ is("image", "audio") }, (content) => omitUndefined({
65247
63432
  type: content.type,
65248
63433
  mimeType: content.mimeType,
65249
- data: encode$1(content.data),
63434
+ data: encode(content.data),
65250
63435
  annotations: content.annotations,
65251
63436
  _meta: content._meta
65252
63437
  })), /*#__PURE__*/ when({ type: "resource" }, (content) => omitUndefined({
@@ -65369,7 +63554,7 @@ const makeHandlers = (core, _lifecycle, context) => {
65369
63554
  const presence = yield* context.registrationPresence;
65370
63555
  const eventsScope = yield* fork(yield* scope);
65371
63556
  const listChangeRevision = context.getListChangeRevision?.() ?? 0;
65372
- const events = yield* provide$4(context.subscribeServerNotifications, eventsScope);
63557
+ const events = yield* provide$3(context.subscribeServerNotifications, eventsScope);
65373
63558
  const honored = {
65374
63559
  ...presence.tools && request.notifications.toolsListChanged === true ? { toolsListChanged: true } : {},
65375
63560
  ...presence.prompts && request.notifications.promptsListChanged === true ? { promptsListChanged: true } : {},
@@ -65759,7 +63944,7 @@ var McpServer = class McpServer extends (/*#__PURE__*/ Service$2()("effect/ai/Mc
65759
63944
  _tag: "Exit",
65760
63945
  exit: void_$2
65761
63946
  }));
65762
- const requestQueue = get$10(fiber.context, RequestNotificationQueue);
63947
+ const requestQueue = get$9(fiber.context, RequestNotificationQueue);
65763
63948
  if (requestQueue !== void 0 && queued.requestContext !== void 0 && isRequestNotification(notification)) {
65764
63949
  offerUnsafe(requestQueue, queued);
65765
63950
  return andThen(_await(delivered), acknowledge);
@@ -66134,7 +64319,7 @@ const runWithRuntime = /*#__PURE__*/ fnUntraced(function* (options, runtime, tra
66134
64319
  clientInfo: profile.clientInfo,
66135
64320
  initializePayload,
66136
64321
  requestMetadata: isReadonlyObject(payload) && isReadonlyObject(payload._meta) ? payload._meta : void 0,
66137
- getClient: get$6(clients, new McpClientKey({
64322
+ getClient: get$5(clients, new McpClientKey({
66138
64323
  clientId: client.id,
66139
64324
  profile
66140
64325
  })).pipe(map$2(({ client }) => client))
@@ -66285,7 +64470,7 @@ const runWithRuntime = /*#__PURE__*/ fnUntraced(function* (options, runtime, tra
66285
64470
  version: "unknown"
66286
64471
  }
66287
64472
  };
66288
- return get$6(clients, new McpClientKey({
64473
+ return get$5(clients, new McpClientKey({
66289
64474
  clientId: targetClientId,
66290
64475
  profile
66291
64476
  })).pipe(flatMap$1(({ write }) => write(request)), scoped);
@@ -66374,7 +64559,7 @@ const runWithRuntime = /*#__PURE__*/ fnUntraced(function* (options, runtime, tra
66374
64559
  return yield* make$24(runtime.clientRpcs, {
66375
64560
  spanPrefix: "McpServer",
66376
64561
  disableFatalDefects: true
66377
- }).pipe(provideService$2(Protocol, patchedProtocol), provideService$2(McpServerClientMiddleware, clientMiddleware), provide$1(handlers));
64562
+ }).pipe(provideService$2(Protocol, patchedProtocol), provideService$2(McpServerClientMiddleware, clientMiddleware), provide(handlers));
66378
64563
  }, scoped);
66379
64564
  const layerWithRuntime = (options, transport) => effectDiscard(gen(function* () {
66380
64565
  const runtime = yield* ServerRuntime;
@@ -66436,7 +64621,7 @@ const layerWithRuntime = (options, transport) => effectDiscard(gen(function* ()
66436
64621
  */
66437
64622
  const layerHttp = (options) => {
66438
64623
  const runtime = layer$1(options.protocols);
66439
- return layerWithRuntime(options, "http").pipe(provide$3(layerMcpProtocolHttp(options)), provide$3(runtime), provide$3(layerJsonRpc()));
64624
+ return layerWithRuntime(options, "http").pipe(provide$2(layerMcpProtocolHttp(options)), provide$2(runtime), provide$2(layerJsonRpc()));
66440
64625
  };
66441
64626
  const layerMcpProtocolHttp = (options) => effect(Protocol)(gen(function* () {
66442
64627
  const { httpEffect, protocol } = yield* makeProtocolWithHttpEffect().pipe(provideService$2(RpcSerialization, mcpHttpSerialization));
@@ -66636,7 +64821,7 @@ const registerToolkit = /*#__PURE__*/ fnUntraced(function* (toolkit) {
66636
64821
  const failure = findFail(cause);
66637
64822
  if (isSuccess$1(failure)) {
66638
64823
  const error = failure.success.error;
66639
- const origin = get$10(reasonAnnotations(failure.success), FailureOrigin);
64824
+ const origin = get$9(reasonAnnotations(failure.success), FailureOrigin);
66640
64825
  if (origin === "parameters" && isParameterValidationError(error)) return fail$3(new InvalidParams({ message: error.reason.message }));
66641
64826
  if (origin === "handler" && isDeclaredFailure(error)) return catchCause$1(declaredFailureResult(error), internalToolError);
66642
64827
  }
@@ -66651,10 +64836,10 @@ const registerToolkit = /*#__PURE__*/ fnUntraced(function* (toolkit) {
66651
64836
  outputSchema,
66652
64837
  annotations: {
66653
64838
  ...getOption(tool.annotations, Title).pipe(map$8((title) => ({ title })), getOrUndefined$1),
66654
- readOnlyHint: get$10(tool.annotations, Readonly),
66655
- destructiveHint: get$10(tool.annotations, Destructive),
66656
- idempotentHint: get$10(tool.annotations, Idempotent),
66657
- openWorldHint: get$10(tool.annotations, OpenWorld)
64839
+ readOnlyHint: get$9(tool.annotations, Readonly),
64840
+ destructiveHint: get$9(tool.annotations, Destructive),
64841
+ idempotentHint: get$9(tool.annotations, Idempotent),
64842
+ openWorldHint: get$9(tool.annotations, OpenWorld)
66658
64843
  },
66659
64844
  _meta: toolMeta
66660
64845
  });
@@ -66687,7 +64872,7 @@ const toolJsonSchema = (schema, strict) => {
66687
64872
  * @category layers
66688
64873
  * @since 4.0.0
66689
64874
  */
66690
- const toolkit = (toolkit) => effectDiscard(registerToolkit(toolkit)).pipe(provide$3(McpServer.layer));
64875
+ const toolkit = (toolkit) => effectDiscard(registerToolkit(toolkit)).pipe(provide$2(McpServer.layer));
66691
64876
  const makeUriMatcher = () => {
66692
64877
  const router = make$37({
66693
64878
  ignoreTrailingSlash: true,
@@ -67015,7 +65200,7 @@ const evaluateConditionalRequest = (request, response) => {
67015
65200
  if (ifModifiedSince !== void 0 && isNotModifiedSince(ifModifiedSince, response.headers["last-modified"])) return notModifiedResponse(response);
67016
65201
  };
67017
65202
  //#endregion
67018
- //#region ../../packages/auth/src/schema.ts
65203
+ //#region ../../packages/runtime/src/auth/schema.ts
67019
65204
  var AuthError = class extends TaggedError()("AuthError", {
67020
65205
  cause: optional$6(Defect()),
67021
65206
  error: optionalKey(Literals([
@@ -67038,124 +65223,6 @@ const Resource$1 = Literals([
67038
65223
  "https://scope.mp281x.xyz/mcp",
67039
65224
  "https://otel.mp281x.xyz"
67040
65225
  ]);
67041
- const authorizationFields = {
67042
- challenge: NonEmptyString,
67043
- clientId: NonEmptyString,
67044
- redirectUri: NonEmptyString,
67045
- resources: ArraySchema(Resource$1),
67046
- state: NonEmptyString
67047
- };
67048
- const Registration = Struct({
67049
- client_name: optionalKey(String$2.check(isMaxLength(100))),
67050
- redirect_uris: NonEmptyArray(NonEmptyString),
67051
- token_endpoint_auth_method: optionalKey(Literal("none"))
67052
- });
67053
- const PendingAuthorization = Struct({
67054
- clientName: String$2,
67055
- createdAt: Finite,
67056
- expiresAt: Finite,
67057
- id: NonEmptyString,
67058
- redirectUri: NonEmptyString,
67059
- resources: ArraySchema(Resource$1)
67060
- });
67061
- const AuthorizationStatus = TaggedUnion({
67062
- Completed: { url: NonEmptyString },
67063
- Expired: {},
67064
- Waiting: { request: PendingAuthorization }
67065
- });
67066
- const AuthorizeParams = Struct({
67067
- client_id: NonEmptyString,
67068
- code_challenge: NonEmptyString,
67069
- code_challenge_method: Literal("S256"),
67070
- redirect_uri: NonEmptyString,
67071
- resource: ArrayEnsure(Resource$1).check(isMinLength(1)),
67072
- response_type: Literal("code"),
67073
- scope: optionalKey(NonEmptyString),
67074
- state: NonEmptyString
67075
- });
67076
- const TokenParams = Union([Struct({
67077
- client_id: NonEmptyString,
67078
- code: NonEmptyString,
67079
- code_verifier: NonEmptyString,
67080
- grant_type: Literal("authorization_code"),
67081
- redirect_uri: NonEmptyString,
67082
- resource: optionalKey(ArrayEnsure(Resource$1).check(isMinLength(1)))
67083
- }), Struct({
67084
- client_id: NonEmptyString,
67085
- grant_type: Literal("refresh_token"),
67086
- refresh_token: NonEmptyString,
67087
- resource: optionalKey(ArrayEnsure(Resource$1).check(isMinLength(1)))
67088
- })]);
67089
- const Stored = TaggedUnion({
67090
- Access: {
67091
- family: NonEmptyString,
67092
- resources: ArraySchema(Resource$1),
67093
- user: User
67094
- },
67095
- Client: {
67096
- name: optionalKey(String$2),
67097
- redirects: NonEmptyArray(NonEmptyString)
67098
- },
67099
- Code: {
67100
- ...authorizationFields,
67101
- user: User
67102
- },
67103
- Delivered: {
67104
- id: NonEmptyString,
67105
- url: NonEmptyString
67106
- },
67107
- Login: {
67108
- request: optionalKey(NonEmptyString),
67109
- verifier: NonEmptyString
67110
- },
67111
- Refresh: {
67112
- clientId: NonEmptyString,
67113
- family: NonEmptyString,
67114
- resources: ArraySchema(Resource$1),
67115
- user: User
67116
- },
67117
- Request: {
67118
- ...authorizationFields,
67119
- clientName: String$2,
67120
- createdAt: Finite,
67121
- decision: TaggedUnion({
67122
- Approved: { user: User },
67123
- Denied: {},
67124
- Pending: {}
67125
- }),
67126
- id: NonEmptyString
67127
- },
67128
- Session: { user: User },
67129
- UsedRefresh: {
67130
- clientId: NonEmptyString,
67131
- family: NonEmptyString
67132
- }
67133
- });
67134
- const StoredRow = Struct({ payload: String$2 });
67135
- const AuthorizationRow = Struct({
67136
- expiresAt: Finite,
67137
- hash: String$2,
67138
- payload: String$2
67139
- });
67140
- const RequestParams = Struct({ request: NonEmptyString });
67141
- const SignInParams = Struct({ request: optionalKey(NonEmptyString) });
67142
- const ConsentParams = Struct({
67143
- ...RequestParams.fields,
67144
- accept: Boolean$2
67145
- });
67146
- const RevokeParams = Struct({
67147
- client_id: NonEmptyString,
67148
- token: NonEmptyString
67149
- });
67150
- const CallbackParams = Struct({
67151
- code: NonEmptyString,
67152
- state: NonEmptyString
67153
- });
67154
- const GitHubToken = Struct({ access_token: NonEmptyString });
67155
- const GitHubUser = Struct({
67156
- id: Int,
67157
- login: NonEmptyString
67158
- });
67159
65226
  Struct({
67160
65227
  accessToken: NonEmptyString,
67161
65228
  clientId: NonEmptyString,
@@ -67168,12 +65235,11 @@ Struct({
67168
65235
  expires_in: Finite,
67169
65236
  refresh_token: NonEmptyString
67170
65237
  });
67171
- const VerificationParams = Struct({ resource: Resource$1 });
67172
65238
  //#endregion
67173
- //#region ../../packages/auth/src/lib/utils.ts
65239
+ //#region ../../packages/runtime/src/auth/lib/utils.ts
67174
65240
  const AUTH_URL = "https://auth.mp281x.xyz";
67175
- var CurrentUser = class extends Service$2()("@deslop/auth/lib/utils/CurrentUser") {};
67176
- var RpcAuth = class RpcAuth extends Service$1()("@deslop/auth/lib/utils/RpcAuth", { error: AuthError }) {
65241
+ var CurrentUser = class extends Service$2()("@deslop/runtime/auth/lib/utils/CurrentUser") {};
65242
+ var RpcAuth = class RpcAuth extends Service$1()("@deslop/runtime/auth/lib/utils/RpcAuth", { error: AuthError }) {
67177
65243
  static layerClient = (token) => layerClient(RpcAuth, (options) => gen(function* () {
67178
65244
  return yield* options.next({
67179
65245
  ...options.request,
@@ -67182,16 +65248,7 @@ var RpcAuth = class RpcAuth extends Service$1()("@deslop/auth/lib/utils/RpcAuth"
67182
65248
  }));
67183
65249
  };
67184
65250
  //#endregion
67185
- //#region ../../packages/auth/src/service.ts
67186
- const SESSION_COOKIE = "__Secure-session";
67187
- const LOGIN_COOKIE = "__Host-login";
67188
- const REQUEST_COOKIE = "__Host-request-";
67189
- const COOKIE = {
67190
- httpOnly: true,
67191
- path: "/",
67192
- sameSite: "lax",
67193
- secure: true
67194
- };
65251
+ //#region ../../packages/runtime/src/auth/service.ts
67195
65252
  function rejected(message) {
67196
65253
  return mapError$2((cause) => {
67197
65254
  if (is$2(AuthError)(cause)) return cause;
@@ -67201,36 +65258,8 @@ function rejected(message) {
67201
65258
  });
67202
65259
  });
67203
65260
  }
67204
- function provide(auth) {
67205
- return pipe(make$73(Auth, auth), add$3(RpcAuth, RpcAuth.of((effect, request) => pipe(auth.user(request.headers), flatMap$1((user) => provideService$2(effect, CurrentUser, user))))));
67206
- }
67207
- function oauth(handler) {
67208
- return pipe(handler, catchIf(is$2(AuthError), (failure) => succeed$4(jsonUnsafe({
67209
- error: failure.error ?? "invalid_request",
67210
- error_description: failure.message
67211
- }, { status: 400 }))), map$2(setHeader("cache-control", "no-store")));
67212
- }
67213
- function publicRequest(request, expiresAt) {
67214
- return {
67215
- ...pipe(request, pick([
67216
- "clientName",
67217
- "createdAt",
67218
- "id",
67219
- "redirectUri",
67220
- "resources"
67221
- ])),
67222
- expiresAt
67223
- };
67224
- }
67225
- function allowedRedirect(redirect) {
67226
- if (redirect === "stash://auth/callback" || redirect === "stash-dev://auth/callback") return true;
67227
- return match$2(fromString(redirect), {
67228
- onFailure: () => false,
67229
- onSuccess: (target) => target.protocol === "http:" && (target.hostname === "127.0.0.1" || target.hostname === "localhost") && isEmpty$1(target.username) && isEmpty$1(target.password) && isEmpty$1(target.search) && isEmpty$1(target.hash)
67230
- });
67231
- }
67232
- var Authorizations = class extends Service$2()("@deslop/auth/service/Authorizations") {};
67233
- var Auth = class Auth extends Service$2()("@deslop/auth/service/Auth") {
65261
+ var Auth = class Auth extends Service$2()("@deslop/runtime/auth/service/Auth") {
65262
+ static makeContext = (auth) => pipe(make$73(Auth, auth), add$3(RpcAuth, RpcAuth.of((effect, request) => pipe(auth.user(request.headers), flatMap$1((user) => provideService$2(effect, CurrentUser, user))))));
67234
65263
  static layer = (resource) => effectContext(gen(function* () {
67235
65264
  const url = yield* pipe(String$1("AUTH_URL"), withDefault(AUTH_URL));
67236
65265
  const client = filterStatusOk(yield* HttpClient);
@@ -67245,420 +65274,15 @@ var Auth = class Auth extends Service$2()("@deslop/auth/service/Auth") {
67245
65274
  urlParams: { resource: audience }
67246
65275
  }), flatMap$1(schemaBodyJson$1(User)), timeout("10 seconds"));
67247
65276
  }, rejected("Sign in first"));
67248
- return provide(Auth.of({
65277
+ return Auth.makeContext(Auth.of({
67249
65278
  access,
67250
65279
  user: fn("Auth.user")(function* (headers) {
67251
- if (isSome(get$3(headers, "authorization"))) return yield* access(headers, resource);
67252
- if (exists(get$3(headers, "origin"), (origin) => !contains(origins, origin))) return yield* AuthError.make({ message: "The request comes from another origin" });
65280
+ if (isSome(get$2(headers, "authorization"))) return yield* access(headers, resource);
65281
+ if (exists(get$2(headers, "origin"), (origin) => !contains(origins, origin))) return yield* AuthError.make({ message: "The request comes from another origin" });
67253
65282
  return yield* pipe(client.get(`${url}/auth/session`, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$1(schemaBodyJson$1(User)), timeout("10 seconds"));
67254
65283
  }, rejected("Sign in first"))
67255
65284
  }));
67256
65285
  }));
67257
- static layerIssuer = pipe(effectContext(gen(function* () {
67258
- const sql = yield* SqliteClient;
67259
- const random = yield* Crypto;
67260
- const changes = yield* sliding(1);
67261
- const router = yield* HttpRouter;
67262
- const client = filterStatusOk(yield* HttpClient);
67263
- const url = yield* pipe(String$1("AUTH_URL"), withDefault(AUTH_URL));
67264
- const issuer = `${url}/api/auth`;
67265
- const provider = yield* all({
67266
- clientId: String$1("GITHUB_CLIENT_ID"),
67267
- secret: Redacted("GITHUB_CLIENT_SECRET"),
67268
- users: Array$1(String$2, "GITHUB_USERS")
67269
- });
67270
- yield* sql`CREATE TABLE IF NOT EXISTS auth_state (hash TEXT PRIMARY KEY, payload TEXT NOT NULL, expires_at INTEGER NOT NULL)`;
67271
- const hash = fnUntraced(function* (value) {
67272
- return encode(yield* random.digest("SHA-256", new TextEncoder().encode(value)));
67273
- });
67274
- const save = fnUntraced(function* (state, seconds) {
67275
- const token = encode(yield* random.randomBytes(32));
67276
- const now = yield* currentTimeMillis;
67277
- yield* sql`DELETE FROM auth_state WHERE expires_at <= ${now}`;
67278
- yield* sql`INSERT INTO auth_state (hash, payload, expires_at) VALUES (${yield* hash(token)}, ${yield* encodeEffect(fromJsonString(Stored))(state)}, ${now + seconds * 1e3})`;
67279
- return token;
67280
- });
67281
- const load = fnUntraced(function* (token) {
67282
- const row = yield* pipe(head(yield* sql`SELECT payload FROM auth_state WHERE hash = ${yield* hash(token)} AND expires_at > ${yield* currentTimeMillis}`), fromOption, flatMap$1(decodeUnknownEffect(StoredRow)), mapError$2((cause) => AuthError.make({
67283
- cause,
67284
- error: "invalid_grant",
67285
- message: "The authorization expired. Sign in again."
67286
- })));
67287
- return yield* decodeEffect(fromJsonString(Stored))(row.payload);
67288
- });
67289
- const remove = fnUntraced(function* (token) {
67290
- yield* sql`DELETE FROM auth_state WHERE hash = ${yield* hash(token)}`;
67291
- });
67292
- const allowed = fnUntraced(function* (user) {
67293
- if (!contains(provider.users, replace("github:", "")(user.id))) return yield* AuthError.make({
67294
- error: "access_denied",
67295
- message: "This GitHub account is not allowed"
67296
- });
67297
- return user;
67298
- });
67299
- const session = fnUntraced(function* (headers) {
67300
- const stored = yield* load(parseHeader(headers["cookie"] ?? "")[SESSION_COOKIE] ?? "");
67301
- if (stored._tag !== "Session") return yield* AuthError.make({ message: "Sign in first" });
67302
- return yield* allowed(stored.user);
67303
- }, rejected("Sign in first"));
67304
- const access = fn("Auth.access")(function* (headers, resource) {
67305
- const authorization = headers["authorization"] ?? "";
67306
- if (!startsWith("Bearer ")(authorization)) return yield* AuthError.make({ message: "Sign in first" });
67307
- const stored = yield* load(slice(7)(authorization));
67308
- if (stored._tag !== "Access" || !some(stored.resources, (value) => value === resource)) return yield* AuthError.make({ message: "The token is not valid for this app" });
67309
- return yield* allowed(stored.user);
67310
- }, rejected("Sign in first"));
67311
- const checkOrigin = fnUntraced(function* (headers) {
67312
- if (headers["origin"] !== new URL(url).origin) return yield* AuthError.make({
67313
- error: "access_denied",
67314
- message: "The request comes from another origin"
67315
- });
67316
- });
67317
- const sameOrigin = flatMap$1(HttpServerRequest, (request) => checkOrigin(request.headers));
67318
- const requestRow = fnUntraced(function* (id) {
67319
- return yield* pipe(sql`SELECT hash, payload, expires_at AS "expiresAt" FROM auth_state WHERE json_extract(payload, '$.id') = ${id} AND expires_at > ${yield* currentTimeMillis}`, flatMap$1(decodeUnknownEffect(ArraySchema(AuthorizationRow))), map$2(head));
67320
- });
67321
- const requestState = fnUntraced(function* (id) {
67322
- const row = yield* fromOption(yield* requestRow(id));
67323
- const stored = yield* decodeEffect(fromJsonString(Stored))(row.payload);
67324
- if (stored._tag !== "Request") return yield* AuthError.make({ message: "The authorization request expired" });
67325
- return stored;
67326
- }, rejected("The authorization request expired"));
67327
- const receiver = fnUntraced(function* (id, headers) {
67328
- const token = parseHeader(headers["cookie"] ?? "")[`${REQUEST_COOKIE}${id}`];
67329
- if (token === void 0) return yield* AuthError.make({ message: "Open the authorization link again" });
67330
- return yield* match$4(yield* requestRow(id), {
67331
- onNone: () => succeedNone,
67332
- onSome: fnUntraced(function* (row) {
67333
- if (row.hash !== (yield* hash(token))) return yield* AuthError.make({ message: "The authorization belongs to another browser" });
67334
- return some$1(row);
67335
- })
67336
- });
67337
- });
67338
- function watch(read, expires) {
67339
- return unwrap$2(gen(function* () {
67340
- const subscription = yield* subscribe(changes);
67341
- return unfold(none(), (previous) => gen(function* () {
67342
- yield* match$4(previous, {
67343
- onNone: () => void_$1,
67344
- onSome: (expiresAt) => raceFirst(take$1(subscription), match(expiresAt === Infinity, {
67345
- onFalse: () => flatMap$1(currentTimeMillis, (now) => sleep(max(0, expiresAt - now))),
67346
- onTrue: () => never$1
67347
- }))
67348
- });
67349
- const value = yield* read;
67350
- return [value, some$1(expires(value))];
67351
- }));
67352
- }));
67353
- }
67354
- const pending = fnUntraced(function* (headers) {
67355
- yield* session(headers);
67356
- const rows = yield* pipe(sql`SELECT payload, hash, expires_at AS "expiresAt" FROM auth_state WHERE json_extract(payload, '$._tag') = 'Request' AND json_extract(payload, '$.decision._tag') = 'Pending' AND expires_at > ${yield* currentTimeMillis} ORDER BY json_extract(payload, '$.createdAt') DESC, hash`, flatMap$1(decodeUnknownEffect(ArraySchema(AuthorizationRow))));
67357
- return yield* forEach$1(rows, fnUntraced(function* (row) {
67358
- return publicRequest(yield* decodeEffect(fromJsonString(Stored.cases.Request))(row.payload), row.expiresAt);
67359
- }), { concurrency: 1 });
67360
- }, rejected("Cannot read pending authorizations"));
67361
- const respond = fn("Authorizations.respond")(function* (params, headers) {
67362
- yield* checkOrigin(headers);
67363
- const user = yield* session(headers);
67364
- yield* sql.withTransaction(gen(function* () {
67365
- const request = yield* requestState(params.request);
67366
- if (request.decision._tag !== "Pending") return yield* AuthError.make({ message: "This authorization has already been answered" });
67367
- yield* sql`UPDATE auth_state SET payload = ${yield* encodeEffect(fromJsonString(Stored))({
67368
- ...request,
67369
- decision: match(params.accept, {
67370
- onFalse: () => ({ _tag: "Denied" }),
67371
- onTrue: () => ({
67372
- _tag: "Approved",
67373
- user
67374
- })
67375
- })
67376
- })} WHERE json_extract(payload, '$.id') = ${params.request}`;
67377
- }));
67378
- yield* publish(changes, true);
67379
- }, rejected("Cannot answer the authorization request"));
67380
- const receive = fnUntraced(function* (id, headers) {
67381
- return yield* sql.withTransaction(flatMap$1(receiver(id, headers), (result) => match$4(result, {
67382
- onNone: () => succeed$4(AuthorizationStatus.make({ _tag: "Expired" })),
67383
- onSome: fnUntraced(function* (row) {
67384
- const request = yield* decodeEffect(fromJsonString(Stored))(row.payload);
67385
- if (request._tag === "Delivered") return AuthorizationStatus.make({
67386
- _tag: "Completed",
67387
- url: request.url
67388
- });
67389
- if (request._tag !== "Request") return yield* AuthError.make({ message: "Invalid authorization request" });
67390
- if (request.decision._tag === "Pending") return AuthorizationStatus.make({
67391
- _tag: "Waiting",
67392
- request: publicRequest(request, row.expiresAt)
67393
- });
67394
- const target = new URL(request.redirectUri);
67395
- target.searchParams.set("state", request.state);
67396
- target.searchParams.set("iss", issuer);
67397
- if (request.decision._tag === "Approved") target.searchParams.set("code", yield* save({
67398
- ...pipe(request, pick([
67399
- "challenge",
67400
- "clientId",
67401
- "redirectUri",
67402
- "resources",
67403
- "state"
67404
- ])),
67405
- _tag: "Code",
67406
- user: request.decision.user
67407
- }, 60));
67408
- else target.searchParams.set("error", "access_denied");
67409
- yield* sql`UPDATE auth_state SET payload = ${yield* encodeEffect(fromJsonString(Stored))({
67410
- _tag: "Delivered",
67411
- id,
67412
- url: target.href
67413
- })}, expires_at = ${yield* currentTimeMillis} + 60000 WHERE hash = ${row.hash}`;
67414
- return AuthorizationStatus.make({
67415
- _tag: "Completed",
67416
- url: target.href
67417
- });
67418
- })
67419
- })));
67420
- }, rejected("Cannot complete the authorization request"));
67421
- const grantTokens = fnUntraced(function* (grant, resources) {
67422
- yield* allowed(grant.user);
67423
- const seconds = match(contains(resources, "https://stash.mp281x.xyz"), {
67424
- onFalse: () => 900,
67425
- onTrue: () => 9e4
67426
- });
67427
- return jsonUnsafe({
67428
- access_token: yield* save({
67429
- _tag: "Access",
67430
- family: grant.family,
67431
- resources,
67432
- user: grant.user
67433
- }, seconds),
67434
- expires_in: seconds,
67435
- refresh_token: yield* save({
67436
- ...grant,
67437
- _tag: "Refresh"
67438
- }, 2592e3),
67439
- scope: "deslop",
67440
- token_type: "Bearer"
67441
- }, { headers: { "cache-control": "no-store" } });
67442
- });
67443
- const tokenResources = fnUntraced(function* (params, granted) {
67444
- if (params.resource === void 0) return granted;
67445
- if (!every$1(params.resource, (value) => contains(granted, value))) return yield* AuthError.make({
67446
- error: "invalid_target",
67447
- message: "The resource was not authorized"
67448
- });
67449
- return params.resource;
67450
- });
67451
- yield* router.add("GET", "/.well-known/oauth-authorization-server/api/auth", jsonUnsafe({
67452
- authorization_endpoint: `${issuer}/oauth2/authorize`,
67453
- authorization_response_iss_parameter_supported: true,
67454
- code_challenge_methods_supported: ["S256"],
67455
- grant_types_supported: ["authorization_code", "refresh_token"],
67456
- issuer,
67457
- registration_endpoint: `${issuer}/oauth2/register`,
67458
- response_types_supported: ["code"],
67459
- revocation_endpoint: `${issuer}/oauth2/revoke`,
67460
- scopes_supported: ["deslop", "offline_access"],
67461
- token_endpoint: `${issuer}/oauth2/token`,
67462
- token_endpoint_auth_methods_supported: ["none"]
67463
- }));
67464
- yield* router.add("POST", "/api/auth/oauth2/register", oauth(gen(function* () {
67465
- const params = yield* pipe(schemaBodyJson(Registration), rejected("Invalid client registration"));
67466
- if (!every$1(params.redirect_uris, allowedRedirect)) return yield* AuthError.make({ message: "Use a Codex, Claude Code or Stash callback" });
67467
- return jsonUnsafe({
67468
- client_id: yield* save({
67469
- _tag: "Client",
67470
- name: params.client_name ?? "Unknown client",
67471
- redirects: params.redirect_uris
67472
- }, 31536e3),
67473
- grant_types: ["authorization_code", "refresh_token"],
67474
- redirect_uris: params.redirect_uris,
67475
- response_types: ["code"],
67476
- token_endpoint_auth_method: "none"
67477
- }, { status: 201 });
67478
- })));
67479
- yield* router.add("GET", "/api/auth/oauth2/authorize", oauth(pipe(sql.withTransaction(gen(function* () {
67480
- const params = yield* pipe(schemaSearchParams(AuthorizeParams), rejected("Invalid authorization request"));
67481
- const registration = yield* load(params.client_id);
67482
- if (registration._tag !== "Client" || !contains(registration.redirects, params.redirect_uri)) return yield* AuthError.make({
67483
- error: "invalid_client",
67484
- message: "The callback does not match the registered client"
67485
- });
67486
- if (!every$1(split$1(params.scope ?? "deslop", " "), (scope) => scope === "deslop" || scope === "offline_access")) return yield* AuthError.make({
67487
- error: "invalid_scope",
67488
- message: "Only Deslop access is supported"
67489
- });
67490
- const now = yield* currentTimeMillis;
67491
- const id = encode(yield* random.randomBytes(16));
67492
- const token = yield* save({
67493
- _tag: "Request",
67494
- challenge: params.code_challenge,
67495
- clientId: params.client_id,
67496
- clientName: registration.name ?? "Unknown client",
67497
- createdAt: now,
67498
- decision: { _tag: "Pending" },
67499
- id,
67500
- redirectUri: params.redirect_uri,
67501
- resources: params.resource,
67502
- state: params.state
67503
- }, 240);
67504
- return setCookieUnsafe(redirect(`/?request=${id}`), `${REQUEST_COOKIE}${id}`, token, {
67505
- ...COOKIE,
67506
- maxAge: "5 minutes"
67507
- });
67508
- })), tap(() => publish(changes, true)))));
67509
- yield* router.add("POST", "/api/auth/oauth2/consent", oauth(gen(function* () {
67510
- const params = yield* pipe(schemaBodyJson(ConsentParams), rejected("Invalid authorization response"));
67511
- yield* respond(params, (yield* HttpServerRequest).headers);
67512
- return empty();
67513
- })));
67514
- yield* router.add("POST", "/api/auth/oauth2/token", oauth(gen(function* () {
67515
- const params = yield* pipe(schemaBodyUrlParams(TokenParams), rejected("Invalid token request"));
67516
- return yield* sql.withTransaction(gen(function* () {
67517
- if (params.grant_type === "authorization_code") {
67518
- const code = yield* load(params.code);
67519
- if (code._tag !== "Code" || code.clientId !== params.client_id || code.redirectUri !== params.redirect_uri || code.challenge !== (yield* hash(params.code_verifier))) return yield* AuthError.make({
67520
- error: "invalid_grant",
67521
- message: "The authorization code or verifier is invalid"
67522
- });
67523
- const resources = yield* tokenResources(params, code.resources);
67524
- yield* remove(params.code);
67525
- return yield* grantTokens({
67526
- _tag: "Refresh",
67527
- clientId: code.clientId,
67528
- family: encode(yield* random.randomBytes(32)),
67529
- resources: code.resources,
67530
- user: code.user
67531
- }, resources);
67532
- }
67533
- const refresh = yield* load(params.refresh_token);
67534
- if (refresh._tag === "UsedRefresh") {
67535
- yield* sql`DELETE FROM auth_state WHERE json_extract(payload, '$.family') = ${refresh.family}`;
67536
- return jsonUnsafe({
67537
- error: "invalid_grant",
67538
- error_description: "Sign in again"
67539
- }, { status: 400 });
67540
- }
67541
- if (refresh._tag !== "Refresh" || refresh.clientId !== params.client_id) return yield* AuthError.make({
67542
- error: "invalid_grant",
67543
- message: "The refresh token is invalid"
67544
- });
67545
- const resources = yield* tokenResources(params, refresh.resources);
67546
- yield* sql`UPDATE auth_state SET payload = ${yield* encodeEffect(fromJsonString(Stored))({
67547
- _tag: "UsedRefresh",
67548
- clientId: refresh.clientId,
67549
- family: refresh.family
67550
- })} WHERE hash = ${yield* hash(params.refresh_token)}`;
67551
- return yield* grantTokens(refresh, resources);
67552
- }));
67553
- })));
67554
- yield* router.add("POST", "/api/auth/oauth2/revoke", oauth(gen(function* () {
67555
- const params = yield* pipe(schemaBodyUrlParams(RevokeParams), rejected("Invalid revocation request"));
67556
- const token = yield* result$1(load(params.token));
67557
- if (isSuccess$1(token) && (token.success._tag === "Refresh" || token.success._tag === "UsedRefresh") && token.success.clientId === params.client_id) yield* sql`DELETE FROM auth_state WHERE json_extract(payload, '$.family') = ${token.success.family}`;
67558
- return empty();
67559
- })));
67560
- yield* router.add("GET", "/auth/session", gen(function* () {
67561
- const user = yield* result$1(session((yield* HttpServerRequest).headers));
67562
- if (isFailure$1(user)) return empty({ status: 401 });
67563
- return yield* schemaJson(User)(user.success, { headers: { "cache-control": "no-store" } });
67564
- }));
67565
- yield* router.add("GET", "/auth/verify", gen(function* () {
67566
- const params = yield* pipe(schemaSearchParams(VerificationParams), rejected("Invalid resource"));
67567
- const user = yield* result$1(access((yield* HttpServerRequest).headers, params.resource));
67568
- if (isFailure$1(user)) return empty({ status: 401 });
67569
- return yield* schemaJson(User)(user.success, { headers: { "cache-control": "no-store" } });
67570
- }));
67571
- yield* router.add("GET", "/auth/github", oauth(gen(function* () {
67572
- const params = yield* pipe(schemaSearchParams(SignInParams), rejected("Invalid sign-in request"));
67573
- if (params.request !== void 0) yield* receiver(params.request, (yield* HttpServerRequest).headers);
67574
- const verifier = encode(yield* random.randomBytes(32));
67575
- const state = yield* save({
67576
- _tag: "Login",
67577
- ...params,
67578
- verifier
67579
- }, 600);
67580
- const authorize = new URL("https://github.com/login/oauth/authorize");
67581
- authorize.search = toString$1(fromInput({
67582
- client_id: provider.clientId,
67583
- code_challenge: yield* hash(verifier),
67584
- code_challenge_method: "S256",
67585
- redirect_uri: `${url}/auth/github/callback`,
67586
- state
67587
- }));
67588
- return setCookieUnsafe(redirect(authorize.href), LOGIN_COOKIE, state, {
67589
- ...COOKIE,
67590
- maxAge: "10 minutes"
67591
- });
67592
- })));
67593
- yield* router.add("GET", "/auth/github/callback", pipe(gen(function* () {
67594
- const params = yield* pipe(schemaSearchParams(CallbackParams), rejected("GitHub sent no code"));
67595
- if ((yield* HttpServerRequest).cookies[LOGIN_COOKIE] !== params.state) return yield* AuthError.make({ message: "The sign-in state does not match" });
67596
- const flow = yield* sql.withTransaction(gen(function* () {
67597
- const stored = yield* load(params.state);
67598
- if (stored._tag !== "Login") return yield* AuthError.make({ message: "The sign-in expired" });
67599
- yield* remove(params.state);
67600
- return stored;
67601
- }));
67602
- const token = yield* pipe(post("https://github.com/login/oauth/access_token"), acceptJson, bodyUrlParams({
67603
- client_id: provider.clientId,
67604
- client_secret: value$2(provider.secret),
67605
- code: params.code,
67606
- code_verifier: flow.verifier,
67607
- redirect_uri: `${url}/auth/github/callback`
67608
- }), (request) => client.execute(request), flatMap$1(schemaBodyJson$1(GitHubToken)));
67609
- const github = yield* pipe(get$1("https://api.github.com/user"), bearerToken(token.access_token), setHeaders$1({
67610
- accept: "application/vnd.github+json",
67611
- "user-agent": "@deslop/auth"
67612
- }), (request) => client.execute(request), flatMap$1(schemaBodyJson$1(GitHubUser)));
67613
- const user = yield* allowed({
67614
- id: `github:${github.id}`,
67615
- name: github.login
67616
- });
67617
- return setCookieUnsafe(expireCookieUnsafe(redirect(match(flow.request === void 0, {
67618
- onFalse: () => `/?request=${flow.request}`,
67619
- onTrue: () => "/"
67620
- })), LOGIN_COOKIE, COOKIE), SESSION_COOKIE, yield* save({
67621
- _tag: "Session",
67622
- user
67623
- }, 31536e3), {
67624
- ...COOKIE,
67625
- domain: pipe(new URL(url).hostname, split$1("."), drop$1(1), join$2(".")),
67626
- maxAge: "365 days"
67627
- });
67628
- }), catch_$2(fnUntraced(function* (cause) {
67629
- yield* logWarning("GitHub sign-in failed", cause);
67630
- return expireCookieUnsafe(redirect(`/?${toString$1(fromInput({
67631
- error: "github",
67632
- request: void 0
67633
- }))}`), LOGIN_COOKIE, COOKIE);
67634
- }))));
67635
- yield* router.add("POST", "/auth/sign-out", oauth(gen(function* () {
67636
- yield* sameOrigin;
67637
- yield* remove((yield* HttpServerRequest).cookies[SESSION_COOKIE] ?? "");
67638
- return expireCookieUnsafe(empty(), SESSION_COOKIE, {
67639
- ...COOKIE,
67640
- domain: pipe(new URL(url).hostname, split$1("."), drop$1(1), join$2("."))
67641
- });
67642
- })));
67643
- return pipe(provide(Auth.of({
67644
- access,
67645
- user: fn("Auth.user")(function* (headers) {
67646
- return yield* session(headers);
67647
- })
67648
- })), add$3(Authorizations, Authorizations.of({
67649
- pending: (headers) => watch(pending(headers), (requests) => reduce(requests, Infinity, (expiresAt, request) => min(expiresAt, request.expiresAt))),
67650
- wait: (id, headers) => pipe(watch(receive(id, headers), (status) => pipe(value(status), tag("Waiting", (value) => value.request.expiresAt), orElse(() => Infinity))), takeUntil((status) => status._tag !== "Waiting"))
67651
- })));
67652
- })), provide$3(unwrap$5(gen(function* () {
67653
- const fs = yield* FileSystem;
67654
- const path = yield* Path$1;
67655
- const directory = path.join(yield* String$1("HOME"), ".deslop", "auth-server");
67656
- yield* fs.makeDirectory(directory, {
67657
- mode: 448,
67658
- recursive: true
67659
- });
67660
- return layer$2({ filename: path.join(directory, "auth.sqlite") });
67661
- }))));
67662
65286
  };
67663
65287
  const HttpAuth = middleware()(gen(function* () {
67664
65288
  const auth = yield* Auth;
@@ -67694,7 +65318,7 @@ function layerMcp(options) {
67694
65318
  v2025_11_25,
67695
65319
  v2025_06_18
67696
65320
  ]
67697
- }), provide$3(layerMcpAuth(resource))), add("GET", "/.well-known/oauth-protected-resource/mcp", map$2(pipe(String$1("AUTH_URL"), withDefault(AUTH_URL)), (url) => jsonUnsafe({
65321
+ }), provide$2(layerMcpAuth(resource))), add("GET", "/.well-known/oauth-protected-resource/mcp", map$2(pipe(String$1("AUTH_URL"), withDefault(AUTH_URL)), (url) => jsonUnsafe({
67698
65322
  authorization_servers: [`${url}/api/auth`],
67699
65323
  bearer_methods_supported: ["header"],
67700
65324
  resource,
@@ -67713,7 +65337,7 @@ const layerNodeHttpServer = layerConfig(createServer, {
67713
65337
  });
67714
65338
  //#endregion
67715
65339
  //#region package.json
67716
- var version = "0.1.1109";
65340
+ var version = "0.1.1112";
67717
65341
  //#endregion
67718
65342
  //#region src/services/telemetry/schema.ts
67719
65343
  var TelemetryError = class extends TaggedError()("TelemetryError", {
@@ -67925,7 +65549,7 @@ function durationMs(start, end) {
67925
65549
  function summary(entries, query) {
67926
65550
  const times = sort(map$5(entries, (entry) => entry.durationMs), Number$5);
67927
65551
  function percentile(ratio) {
67928
- return pipe(get$8(times, max(0, Math.ceil(times.length * ratio) - 1)), getOrElse(() => 0));
65552
+ return pipe(get$7(times, max(0, Math.ceil(times.length * ratio) - 1)), getOrElse(() => 0));
67929
65553
  }
67930
65554
  return {
67931
65555
  count: entries.length,
@@ -67972,10 +65596,10 @@ function traceView(entries, id) {
67972
65596
  }));
67973
65597
  const logs = filter$1(ordered, (entry) => entry.signal === "log");
67974
65598
  const nodes = map$5(spans, (span) => {
67975
- const ancestors = reverse(unfold$1({
65599
+ const ancestors = reverse(unfold({
67976
65600
  entry: span.entry,
67977
65601
  seen: make$46(span.entry.spanId)
67978
- }, (current) => pipe(get$9(byId, parentId(current.entry)), filter$3((parent) => !has(current.seen, parent.entry.spanId)), map$8((parent) => [parent, {
65602
+ }, (current) => pipe(get$8(byId, parentId(current.entry)), filter$3((parent) => !has(current.seen, parent.entry.spanId)), map$8((parent) => [parent, {
67979
65603
  entry: parent.entry,
67980
65604
  seen: add$1(current.seen, parent.entry.spanId)
67981
65605
  }]))));
@@ -68222,7 +65846,7 @@ const receiver = use((router) => gen(function* () {
68222
65846
  });
68223
65847
  yield* router.add("GET", "/health", text("ready"));
68224
65848
  }));
68225
- const mcp = pipe(toolkit(Tools), provide$3(ToolHandlers), provide$3(layerMcp({
65849
+ const mcp = pipe(toolkit(Tools), provide$2(ToolHandlers), provide$2(layerMcp({
68226
65850
  instructions: "Scope is the debugger for the user's Effect apps: each app's web, mobile and server code exports its traces and logs here, and Scope keeps only the current run of each app. Use it to see what the code actually did instead of guessing: reproduce the action, then list_services, find_traces and read_trace; find_logs for what the app said; measure_latency before and after a change to prove it got faster.",
68227
65851
  name: "scope",
68228
65852
  version
@@ -68234,7 +65858,7 @@ const database = unwrap$5(gen(function* () {
68234
65858
  yield* fs.makeDirectory(directory, { recursive: true });
68235
65859
  return layer$2({ filename: path.join(directory, "telemetry.sqlite") });
68236
65860
  }));
68237
- runMain(pipe(merge$3(pipe(serve(mergeAll$1(pipe(fresh(receiver), provide$3(HttpAuth.layer)), mcp, cors({
65861
+ runMain(pipe(merge$3(pipe(serve(mergeAll$1(pipe(fresh(receiver), provide$2(HttpAuth.layer)), mcp, cors({
68238
65862
  allowedHeaders: ["authorization", "content-type"],
68239
65863
  allowedMethods: ["POST", "OPTIONS"],
68240
65864
  allowedOrigins: [
@@ -68246,12 +65870,12 @@ runMain(pipe(merge$3(pipe(serve(mergeAll$1(pipe(fresh(receiver), provide$3(HttpA
68246
65870
  })), {
68247
65871
  disableLogger: true,
68248
65872
  middleware: decompression()
68249
- }), provide$3(layerNodeHttpServer)), pipe(serve(merge$3(fresh(receiver), cors({ allowedHeaders: ["content-type"] })), {
65873
+ }), provide$2(layerNodeHttpServer)), pipe(serve(merge$3(fresh(receiver), cors({ allowedHeaders: ["content-type"] })), {
68250
65874
  disableLogger: true,
68251
65875
  middleware: decompression()
68252
- }), provide$3(layerConfig(createServer, {
65876
+ }), provide$2(layerConfig(createServer, {
68253
65877
  host: pipe(String$1("HOST"), withDefault("127.0.0.1")),
68254
65878
  port: succeed(4318)
68255
- })))), provide$3(Auth.layer("https://otel.mp281x.xyz")), provide$3(layer$11), provide$3(Telemetry.layer), provide$3(database), provide$3(layer$3), provide$3(succeed$5(MaxBodySize)(mebibytes(10))), launch));
65879
+ })))), provide$2(Auth.layer("https://otel.mp281x.xyz")), provide$2(layer$11), provide$2(Telemetry.layer), provide$2(database), provide$2(layer$3), provide$2(succeed$5(MaxBodySize)(mebibytes(10))), launch));
68256
65880
  //#endregion
68257
65881
  export {};