@deslop/opm 0.1.1247 → 0.1.1249

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 +337 -168
  2. package/package.json +2 -2
package/dist/server.js CHANGED
@@ -5064,41 +5064,6 @@ const mergeAll$2 = (...ctxs) => {
5064
5064
  return makeUnsafe$9(map);
5065
5065
  };
5066
5066
  /**
5067
- * Returns a new `Context` with the specified service keys removed.
5068
- *
5069
- * **When to use**
5070
- *
5071
- * Use when you want to remove a denylist of services from a `Context`.
5072
- *
5073
- * **Example** (Omitting services from a context)
5074
- *
5075
- * ```ts import.meta.vitest
5076
- * import { Context, Option, pipe } from "effect"
5077
- *
5078
- * const Port = Context.Service<{ PORT: number }>("Port")
5079
- * const Timeout = Context.Service<{ TIMEOUT: number }>("Timeout")
5080
- *
5081
- * const someContext = pipe(
5082
- * Context.make(Port, { PORT: 8080 }),
5083
- * Context.add(Timeout, { TIMEOUT: 5000 })
5084
- * )
5085
- *
5086
- * const context = pipe(someContext, Context.omit(Timeout))
5087
- *
5088
- * Context.getOption(context, Port) // => Option.some({ PORT: 8080 })
5089
- * Context.getOption(context, Timeout) // => Option.none()
5090
- * ```
5091
- *
5092
- * @see {@link pick} for keeping selected services
5093
- *
5094
- * @stability stable
5095
- * @category filtering
5096
- * @since 2.0.0
5097
- */
5098
- const omit$1 = (...keys) => (self) => withFlat(self, (map) => {
5099
- for (let i = 0; i < keys.length; i++) map.delete(keys[i].key);
5100
- });
5101
- /**
5102
5067
  * Creates a context key with a default value.
5103
5068
  *
5104
5069
  * **When to use**
@@ -10178,7 +10143,7 @@ const forever$2 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, optio
10178
10143
  step: constVoid
10179
10144
  }));
10180
10145
  /** @internal */
10181
- const catchCause$2 = /*#__PURE__*/ dual(2, (self, f) => new OnFailureImpl(self, f.length !== 1 ? (cause) => f(cause) : f));
10146
+ const catchCause$3 = /*#__PURE__*/ dual(2, (self, f) => new OnFailureImpl(self, f.length !== 1 ? (cause) => f(cause) : f));
10182
10147
  const OnFailureProto = /*#__PURE__*/ makePrimitiveProto({
10183
10148
  op: "OnFailure",
10184
10149
  [evaluate]: evaluateCont
@@ -10189,7 +10154,7 @@ const OnFailureImpl = function(self, f) {
10189
10154
  };
10190
10155
  OnFailureImpl.prototype = OnFailureProto;
10191
10156
  /** @internal */
10192
- const catchCauseFilter$1 = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$2(self, (cause) => {
10157
+ const catchCauseFilter$1 = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$3(self, (cause) => {
10193
10158
  const eb = filter(cause);
10194
10159
  return isFailure$1(eb) ? failCause$5(eb.failure) : f(eb.success, cause);
10195
10160
  }));
@@ -10198,9 +10163,9 @@ const catch_$2 = /*#__PURE__*/ dual(2, (self, f) => catchCauseFilter$1(self, fin
10198
10163
  /** @internal */
10199
10164
  const catchDefect$1 = /*#__PURE__*/ dual(2, (self, f) => catchCauseFilter$1(self, findDefect, f));
10200
10165
  /** @internal */
10201
- const tapCause$1 = /*#__PURE__*/ dual(2, (self, f) => catchCause$2(self, (cause) => andThen$1(f(cause), failCause$5(cause))));
10166
+ const tapCause$1 = /*#__PURE__*/ dual(2, (self, f) => catchCause$3(self, (cause) => andThen$1(f(cause), failCause$5(cause))));
10202
10167
  /** @internal */
10203
- const tapCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$2(self, (cause) => {
10168
+ const tapCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$3(self, (cause) => {
10204
10169
  const result = filter(cause);
10205
10170
  if (isFailure$1(result)) return failCause$5(cause);
10206
10171
  return andThen$1(f(result.success, cause), failCause$5(cause));
@@ -10208,14 +10173,14 @@ const tapCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$2(s
10208
10173
  /** @internal */
10209
10174
  const tapError$4 = /*#__PURE__*/ dual(2, (self, f) => tapCauseFilter(self, findError, (e) => f(e)));
10210
10175
  /** @internal */
10211
- const catchIf$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, f, orElse) => catchCause$2(self, (cause) => {
10176
+ const catchIf$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, f, orElse) => catchCause$3(self, (cause) => {
10212
10177
  const error = findRecoverableError(cause);
10213
10178
  if (isFailure$1(error)) return failCause$5(error.failure);
10214
10179
  if (!predicate(error.success)) return orElse ? orElse(error.success) : failCause$5(cause);
10215
10180
  return f(error.success);
10216
10181
  }));
10217
10182
  /** @internal */
10218
- const catchFilter$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, filter, f, orElse) => catchCause$2(self, (cause) => {
10183
+ const catchFilter$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, filter, f, orElse) => catchCause$3(self, (cause) => {
10219
10184
  const error = findRecoverableError(cause);
10220
10185
  if (isFailure$1(error)) return failCause$5(error.failure);
10221
10186
  const result = filter(error.success);
@@ -10242,7 +10207,7 @@ const catchReason$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, e
10242
10207
  return orElse ? orElse(reason, e) : fail$10(e);
10243
10208
  }));
10244
10209
  /** @internal */
10245
- const mapError$3 = /*#__PURE__*/ dual(2, (self, f) => catchCause$2(self, (cause) => failCause$5(causeMap(cause, f))));
10210
+ const mapError$3 = /*#__PURE__*/ dual(2, (self, f) => catchCause$3(self, (cause) => failCause$5(causeMap(cause, f))));
10246
10211
  /** @internal */
10247
10212
  const mapBoth = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$1(self, {
10248
10213
  onFailure: (cause) => failCause$5(causeMap(cause, options.onFailure)),
@@ -10382,9 +10347,9 @@ const delay$1 = /*#__PURE__*/ dual(2, (self, duration) => andThen$1(sleep$1(dura
10382
10347
  /** @internal */
10383
10348
  const timeoutOrElse$1 = /*#__PURE__*/ dual(2, (self, options) => flatMap$5(timeoutOption$1(self, options.duration), (option) => isNone(option) ? options.orElse() : succeed$8(option.value)));
10384
10349
  /** @internal */
10385
- const timeoutErrorFromDuration = (duration) => new TimeoutError(`Operation timed out after '${format$1(duration)}'`);
10350
+ const timeoutErrorFromDuration = (duration) => new TimeoutError$1(`Operation timed out after '${format$1(duration)}'`);
10386
10351
  /** @internal */
10387
- const timeout$1 = /*#__PURE__*/ dual(2, (self, duration) => {
10352
+ const timeout$2 = /*#__PURE__*/ dual(2, (self, duration) => {
10388
10353
  const decoded = fromInputUnsafe$1(duration);
10389
10354
  return timeoutOrElse$1(self, {
10390
10355
  duration: decoded,
@@ -10426,7 +10391,7 @@ const runFinalizer = (finalizer, exit_) => {
10426
10391
  return exitDie(defect);
10427
10392
  }
10428
10393
  };
10429
- const combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause$2(finalizer, (cause) => failCause$5(causeElectDefects(causeCombine(exit_.cause, cause))));
10394
+ const combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause$3(finalizer, (cause) => failCause$5(causeElectDefects(causeCombine(exit_.cause, cause))));
10430
10395
  const scopeCloseFinalizers = /*#__PURE__*/ fnUntraced$1(function* (self, finalizers, exit_) {
10431
10396
  let exits = [];
10432
10397
  const fibers = [];
@@ -11174,6 +11139,15 @@ const withSpan$1 = function() {
11174
11139
  return (self, ...args) => useSpan$1(name, fnArg ? fnArg(...args) : options, (span) => withParentSpan$1(self, span, traceOptions));
11175
11140
  };
11176
11141
  /** @internal */
11142
+ const annotateCurrentSpan$1 = (...args) => withFiber$1((fiber) => {
11143
+ const span = fiber.currentSpanLocal;
11144
+ if (span && span.status._tag !== "Ended") {
11145
+ if (args.length === 1) for (const [key, value] of Object.entries(args[0])) span.attribute(key, value);
11146
+ else span.attribute(args[0], args[1]);
11147
+ }
11148
+ return void_$3;
11149
+ });
11150
+ /** @internal */
11177
11151
  const ClockRef = /*#__PURE__*/ Reference("effect/Clock", { defaultValue: () => new ClockImpl() });
11178
11152
  const MAX_TIMER_MILLIS = 2 ** 31 - 1;
11179
11153
  var ClockImpl = class {
@@ -11241,7 +11215,7 @@ const TimeoutErrorTypeId = "~effect/Cause/TimeoutError";
11241
11215
  /** @internal */
11242
11216
  const isTimeoutError$1 = (u) => hasProperty(u, TimeoutErrorTypeId);
11243
11217
  /** @internal */
11244
- var TimeoutError = class extends (/*#__PURE__*/ TaggedError$2("TimeoutError")) {
11218
+ var TimeoutError$1 = class extends (/*#__PURE__*/ TaggedError$2("TimeoutError")) {
11245
11219
  [TimeoutErrorTypeId] = TimeoutErrorTypeId;
11246
11220
  constructor(message) {
11247
11221
  super({ message });
@@ -12021,6 +11995,22 @@ const done$1 = done$2;
12021
11995
  */
12022
11996
  const isTimeoutError = isTimeoutError$1;
12023
11997
  /**
11998
+ * Constructs a `TimeoutError` with an optional message.
11999
+ *
12000
+ * **Example** (Creating a TimeoutError)
12001
+ *
12002
+ * ```ts import.meta.vitest
12003
+ * import { Cause } from "effect"
12004
+ *
12005
+ * new Cause.TimeoutError("Operation timed out").message // => "Operation timed out"
12006
+ * ```
12007
+ *
12008
+ * @stability stable
12009
+ * @category constructors
12010
+ * @since 4.0.0
12011
+ */
12012
+ const TimeoutError = TimeoutError$1;
12013
+ /**
12024
12014
  * Constructs an `IllegalArgumentError` with an optional message.
12025
12015
  *
12026
12016
  * **Example** (Creating an IllegalArgumentError)
@@ -14267,6 +14257,63 @@ const provideMerge = /*#__PURE__*/ dual(2, (self, that) => provideWith(self, tha
14267
14257
  */
14268
14258
  const flatMap$4 = /*#__PURE__*/ dual(2, (self, f) => fromBuild((memoMap, scope) => flatMap$5(self.build(memoMap, scope), (context) => f(context).build(memoMap, scope))));
14269
14259
  /**
14260
+ * Recovers from any failure cause by switching to another layer.
14261
+ *
14262
+ * **When to use**
14263
+ *
14264
+ * Use when you need `Layer` recovery to inspect more than the typed error,
14265
+ * such as defects or interruption information.
14266
+ *
14267
+ * **Details**
14268
+ *
14269
+ * The handler receives the full `Cause` of the failed layer, including typed
14270
+ * errors, unexpected defects, and interruption information, and returns the
14271
+ * fallback layer to build instead. Finalizers for resources acquired by the
14272
+ * failed layer are still run before the fallback layer is acquired.
14273
+ *
14274
+ * **Example** (Recovering from layer failures by cause)
14275
+ *
14276
+ * ```ts import.meta.vitest
14277
+ * import { Context, Data, Effect, Layer } from "effect"
14278
+ *
14279
+ * class DatabaseError extends Data.TaggedError("DatabaseError")<{
14280
+ * message: string
14281
+ * }> {}
14282
+ *
14283
+ * class Database extends Context.Service<Database, {
14284
+ * readonly query: (sql: string) => Effect.Effect<string>
14285
+ * }>()("Database") {}
14286
+ *
14287
+ * const primaryDatabaseLayer = Layer.effect(Database,
14288
+ * Effect.fail(new DatabaseError({ message: "Primary DB unreachable" }))
14289
+ * )
14290
+ *
14291
+ * const databaseWithFallback = primaryDatabaseLayer.pipe(
14292
+ * Layer.catchCause(() => {
14293
+ * return Layer.succeed(Database, {
14294
+ * query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Memory: ${sql}`))
14295
+ * })
14296
+ * })
14297
+ * )
14298
+ *
14299
+ * const program = Effect.gen(function*() {
14300
+ * const database = yield* Database
14301
+ * return yield* database.query("SELECT * FROM users")
14302
+ * }).pipe(
14303
+ * Effect.provide(databaseWithFallback)
14304
+ * )
14305
+ *
14306
+ * await Effect.runPromise(program) // => "Memory: SELECT * FROM users"
14307
+ * ```
14308
+ *
14309
+ * @see {@link catchTag} for recovering from specific tagged errors
14310
+ *
14311
+ * @stability stable
14312
+ * @category error handling
14313
+ * @since 4.0.0
14314
+ */
14315
+ const catchCause$2 = /*#__PURE__*/ dual(2, (self, onError) => fromBuildUnsafe((memoMap, scope) => catchCause$3(self.build(memoMap, scope), (cause) => onError(cause).build(memoMap, scope))));
14316
+ /**
14270
14317
  * Builds this layer and keeps it alive until the returned effect is interrupted.
14271
14318
  *
14272
14319
  * **When to use**
@@ -15485,7 +15532,7 @@ const fromStepWithMetadata = (step) => fromStep(map$8(step, (f) => {
15485
15532
  * @category destructors
15486
15533
  * @since 4.0.0
15487
15534
  */
15488
- const toStep = (schedule) => catchCause$2(schedule.step, (cause) => succeed$8(() => failCause$5(cause)));
15535
+ const toStep = (schedule) => catchCause$3(schedule.step, (cause) => succeed$8(() => failCause$5(cause)));
15489
15536
  /**
15490
15537
  * Extracts a step function from a `Schedule` that sleeps for each computed
15491
15538
  * delay and returns metadata for the completed step.
@@ -17426,7 +17473,7 @@ const catchReason = catchReason$1;
17426
17473
  * @category error handling
17427
17474
  * @since 4.0.0
17428
17475
  */
17429
- const catchCause$1 = catchCause$2;
17476
+ const catchCause$1 = catchCause$3;
17430
17477
  /**
17431
17478
  * Recovers from defects using a provided recovery function.
17432
17479
  *
@@ -17977,7 +18024,7 @@ const firstSuccessOf = firstSuccessOf$1;
17977
18024
  * @category delays & timeouts
17978
18025
  * @since 2.0.0
17979
18026
  */
17980
- const timeout = timeout$1;
18027
+ const timeout$1 = timeout$2;
17981
18028
  /**
17982
18029
  * Runs an effect with a time limit and represents only the timeout case as
17983
18030
  * `Option.none`.
@@ -19385,6 +19432,31 @@ const repeat = repeat$1;
19385
19432
  */
19386
19433
  const withTracerEnabled = withTracerEnabled$1;
19387
19434
  /**
19435
+ * Adds an annotation to the current span if available.
19436
+ *
19437
+ * **Example** (Annotating the current span)
19438
+ *
19439
+ * ```ts import.meta.vitest
19440
+ * import { Effect } from "effect"
19441
+ *
19442
+ * const program = Effect.gen(function*() {
19443
+ * yield* Effect.annotateCurrentSpan("userId", "123")
19444
+ * yield* Effect.annotateCurrentSpan({
19445
+ * operation: "user-lookup"
19446
+ * })
19447
+ * return "success"
19448
+ * })
19449
+ *
19450
+ * const traced = Effect.withSpan(program, "user-operation")
19451
+ * Effect.runSync(traced) // => "success"
19452
+ * ```
19453
+ *
19454
+ * @stability stable
19455
+ * @category tracing
19456
+ * @since 2.0.0
19457
+ */
19458
+ const annotateCurrentSpan = annotateCurrentSpan$1;
19459
+ /**
19388
19460
  * Create a new span for tracing, and automatically close it when the effect
19389
19461
  * completes.
19390
19462
  *
@@ -29185,7 +29257,7 @@ const compose = /*#__PURE__*/ dual(2, (self, other) => {
29185
29257
  if (other._tag === "Passthrough") return self;
29186
29258
  switch (self._tag) {
29187
29259
  case "Transform": switch (other._tag) {
29188
- case "Transform": return transform$2((input) => other.transform(self.transform(input)));
29260
+ case "Transform": return transform$3((input) => other.transform(self.transform(input)));
29189
29261
  case "TransformOptional": return transformOptional((input) => other.transform(map$12(input, self.transform)));
29190
29262
  case "TransformEffect": return transformEffect$1((input, options) => other.transform(self.transform(input), options));
29191
29263
  case "TransformOptionalEffect": return composeOptionalEffect(self, other);
@@ -29247,7 +29319,7 @@ function passthrough$1() {
29247
29319
  * @category transforming
29248
29320
  * @since 4.0.0
29249
29321
  */
29250
- function transform$2(f) {
29322
+ function transform$3(f) {
29251
29323
  return makeGetter({
29252
29324
  _tag: "Transform",
29253
29325
  transform: f
@@ -29374,7 +29446,7 @@ function transformOptionalEffect(f) {
29374
29446
  * @since 4.0.0
29375
29447
  */
29376
29448
  function String$8() {
29377
- return transform$2(globalThis.String);
29449
+ return transform$3(globalThis.String);
29378
29450
  }
29379
29451
  /**
29380
29452
  * Coerces any value to a `number` using the global `Number()` constructor.
@@ -29405,7 +29477,7 @@ function String$8() {
29405
29477
  * @since 4.0.0
29406
29478
  */
29407
29479
  function Number$4() {
29408
- return transform$2(globalThis.Number);
29480
+ return transform$3(globalThis.Number);
29409
29481
  }
29410
29482
  function parseJson(options) {
29411
29483
  return transformEffect$1((input, parseOptions) => try_({
@@ -29495,7 +29567,7 @@ function splitKeyValue$1(options) {
29495
29567
  const keyValueSeparator = options?.keyValueSeparator ?? "=";
29496
29568
  const trim = options?.trim ?? false;
29497
29569
  const keepEmptyValues = options?.keepEmptyValues ?? false;
29498
- return transform$2((input) => input.split(separator).reduce((acc, pair) => {
29570
+ return transform$3((input) => input.split(separator).reduce((acc, pair) => {
29499
29571
  let key;
29500
29572
  let value;
29501
29573
  if (keyValueSeparator === "") {
@@ -29549,7 +29621,7 @@ function splitKeyValue$1(options) {
29549
29621
  function joinKeyValue(options) {
29550
29622
  const separator = options?.separator ?? ",";
29551
29623
  const keyValueSeparator = options?.keyValueSeparator ?? "=";
29552
- return transform$2((input) => Object.entries(input).map(([key, value]) => `${key}${keyValueSeparator}${value}`).join(separator));
29624
+ return transform$3((input) => Object.entries(input).map(([key, value]) => `${key}${keyValueSeparator}${value}`).join(separator));
29553
29625
  }
29554
29626
  /**
29555
29627
  * Splits a string into an array of strings by a separator.
@@ -29582,7 +29654,7 @@ function joinKeyValue(options) {
29582
29654
  */
29583
29655
  function split(options) {
29584
29656
  const separator = options?.separator ?? ",";
29585
- return transform$2((input) => input === "" ? [] : input.split(separator));
29657
+ return transform$3((input) => input === "" ? [] : input.split(separator));
29586
29658
  }
29587
29659
  /**
29588
29660
  * Encodes a `Uint8Array` or string to a Base64 string.
@@ -29610,7 +29682,7 @@ function split(options) {
29610
29682
  * @since 4.0.0
29611
29683
  */
29612
29684
  function encodeBase64() {
29613
- return transform$2(encode);
29685
+ return transform$3(encode);
29614
29686
  }
29615
29687
  /**
29616
29688
  * Decodes a Base64 string to a `Uint8Array`.
@@ -29665,7 +29737,7 @@ function decodeBase64$1() {
29665
29737
  * @since 4.0.0
29666
29738
  */
29667
29739
  function encodeUriComponent() {
29668
- return transform$2(encodeURIComponent);
29740
+ return transform$3(encodeURIComponent);
29669
29741
  }
29670
29742
  /**
29671
29743
  * Decodes a URI component encoded string using `decodeURIComponent`.
@@ -29906,8 +29978,8 @@ function transformEffect(options) {
29906
29978
  * @category transforming
29907
29979
  * @since 3.10.0
29908
29980
  */
29909
- function transform$1(options) {
29910
- return new Transformation(transform$2(options.decode), transform$2(options.encode));
29981
+ function transform$2(options) {
29982
+ return new Transformation(transform$3(options.decode), transform$3(options.encode));
29911
29983
  }
29912
29984
  /**
29913
29985
  * Transforms a string into a record of key-value pairs and
@@ -30031,7 +30103,7 @@ const makeEncodeDefect = (options) => {
30031
30103
  };
30032
30104
  const decodeDefect = (input) => isJsonError(input) ? decodeJsonError(input) : input;
30033
30105
  /** @internal */
30034
- const defectFromJson = (options) => transform$1({
30106
+ const defectFromJson = (options) => transform$2({
30035
30107
  decode: decodeDefect,
30036
30108
  encode: makeEncodeDefect(options)
30037
30109
  });
@@ -30396,7 +30468,7 @@ const Undefined$1 = class extends ASTNodeImpl {
30396
30468
  return "undefined";
30397
30469
  }
30398
30470
  };
30399
- const undefinedToNull = /*#__PURE__*/ new Link(null_, /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$2(() => void 0), /*#__PURE__*/ transform$2(() => null)));
30471
+ const undefinedToNull = /*#__PURE__*/ new Link(null_, /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$3(() => void 0), /*#__PURE__*/ transform$3(() => null)));
30400
30472
  const undefined_ = /*#__PURE__*/ new Undefined$1();
30401
30473
  /**
30402
30474
  * Constructs a {@link Void}.
@@ -30634,7 +30706,7 @@ function templateLiteralTransformation(template) {
30634
30706
  const segments = segmentTemplateLiteralParts(template, s, options);
30635
30707
  if (segments) return succeed$5(segments);
30636
30708
  return fail$6(new InvalidValue$1({ expected: "a string matching template literal parts" }, s, options));
30637
- }), transform$2((parts) => parts.join("")));
30709
+ }), transform$3((parts) => parts.join("")));
30638
30710
  }
30639
30711
  /**
30640
30712
  * Constructs a {@link Literal}.
@@ -30674,7 +30746,7 @@ const Literal$1 = class extends ASTNodeImpl {
30674
30746
  };
30675
30747
  function literalToString(ast) {
30676
30748
  const literalAsString = globalThis.String(ast.literal);
30677
- return replaceEncoding(ast, [new Link(new Literal$1(literalAsString), new Transformation(transform$2(() => ast.literal), transform$2(() => literalAsString)))]);
30749
+ return replaceEncoding(ast, [new Link(new Literal$1(literalAsString), new Transformation(transform$3(() => ast.literal), transform$3(() => literalAsString)))]);
30678
30750
  }
30679
30751
  /**
30680
30752
  * Constructs a {@link String}.
@@ -31741,7 +31813,7 @@ function isFinite$1(annotations) {
31741
31813
  }
31742
31814
  /** @internal */
31743
31815
  const finite = /*#__PURE__*/ appendChecks(number, [/*#__PURE__*/ isFinite$1()]);
31744
- const numberToJson = /*#__PURE__*/ new Link(/*#__PURE__*/ new Union$1([finite, nonFiniteLiterals]), /*#__PURE__*/ new Transformation(/*#__PURE__*/ Number$4(), /*#__PURE__*/ transform$2((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))));
31816
+ const numberToJson = /*#__PURE__*/ new Link(/*#__PURE__*/ new Union$1([finite, nonFiniteLiterals]), /*#__PURE__*/ new Transformation(/*#__PURE__*/ Number$4(), /*#__PURE__*/ transform$3((n) => globalThis.Number.isFinite(n) ? n : globalThis.String(n))));
31745
31817
  /**
31746
31818
  * Creates a {@link Filter} that validates strings by running `RegExp.test`.
31747
31819
  *
@@ -32991,9 +33063,9 @@ function toCodecStringTreeASTStep(ast, recur, onMissingAnnotation) {
32991
33063
  }
32992
33064
  return ast;
32993
33065
  }
32994
- const nullToString = /*#__PURE__*/ new Link(/*#__PURE__*/ new Literal$1("null"), /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$2(() => null), /*#__PURE__*/ transform$2(() => "null")));
32995
- const booleanToString = /*#__PURE__*/ new Link(/*#__PURE__*/ new Union$1([/*#__PURE__*/ new Literal$1("true"), /*#__PURE__*/ new Literal$1("false")]), /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$2((s) => s === "true"), /*#__PURE__*/ String$8()));
32996
- const arrayFromSingleTransformation = /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$2((input) => typeof input === "string" ? [input] : input), /*#__PURE__*/ passthrough$1());
33066
+ const nullToString = /*#__PURE__*/ new Link(/*#__PURE__*/ new Literal$1("null"), /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$3(() => null), /*#__PURE__*/ transform$3(() => "null")));
33067
+ const booleanToString = /*#__PURE__*/ new Link(/*#__PURE__*/ new Union$1([/*#__PURE__*/ new Literal$1("true"), /*#__PURE__*/ new Literal$1("false")]), /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$3((s) => s === "true"), /*#__PURE__*/ String$8()));
33068
+ const arrayFromSingleTransformation = /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$3((input) => typeof input === "string" ? [input] : input), /*#__PURE__*/ passthrough$1());
32997
33069
  const isCodecArrayFromSingleLink = (link) => link.transformation === arrayFromSingleTransformation;
32998
33070
  const toCodecStringTreeAST = /*#__PURE__*/ makeCodecDerivation((ast, recur) => toCodecStringTreeASTStep(ast, recur, (ast) => {
32999
33071
  throw new globalThis.Error("Missing structural codec for StringTree", { cause: ast });
@@ -34267,8 +34339,8 @@ function Literal(literal) {
34267
34339
  literal,
34268
34340
  transform(to) {
34269
34341
  return out.pipe(decodeTo(Literal(to), {
34270
- decode: transform$2(() => to),
34271
- encode: transform$2(() => literal)
34342
+ decode: transform$3(() => to),
34343
+ encode: transform$3(() => literal)
34272
34344
  }));
34273
34345
  }
34274
34346
  });
@@ -34687,7 +34759,7 @@ const FalseLiterals = /*#__PURE__*/ Literals([
34687
34759
  "n"
34688
34760
  ]);
34689
34761
  /** @internal */
34690
- const BooleanLiterals = /*#__PURE__*/ Literals([...TrueLiterals.literals, ...FalseLiterals.literals]).pipe(/*#__PURE__*/ decodeTo(Boolean$5, /*#__PURE__*/ transform$1({
34762
+ const BooleanLiterals = /*#__PURE__*/ Literals([...TrueLiterals.literals, ...FalseLiterals.literals]).pipe(/*#__PURE__*/ decodeTo(Boolean$5, /*#__PURE__*/ transform$2({
34691
34763
  decode: (value) => value === "true" || value === "yes" || value === "on" || value === "1" || value === "y",
34692
34764
  encode: (value) => value ? "true" : "false"
34693
34765
  })));
@@ -35347,7 +35419,7 @@ function CauseReason(error, defect) {
35347
35419
  _tag: Literal("Interrupt"),
35348
35420
  fiberId: UndefinedOr(Finite)
35349
35421
  })
35350
- ]), transform$1({
35422
+ ]), transform$2({
35351
35423
  decode: (e) => {
35352
35424
  switch (e._tag) {
35353
35425
  case "Fail": return makeFailReason(e.error);
@@ -35421,7 +35493,7 @@ function Cause(error, defect) {
35421
35493
  importDeclarations: [`import * as Cause from "effect/Cause"`]
35422
35494
  }),
35423
35495
  expected: "Cause",
35424
- toCodec: ([error, defect]) => link$1()(ArraySchema(CauseReason(error, defect)), transform$1({
35496
+ toCodec: ([error, defect]) => link$1()(ArraySchema(CauseReason(error, defect)), transform$2({
35425
35497
  decode: fromReasons,
35426
35498
  encode: ({ reasons: failures }) => failures
35427
35499
  }))
@@ -35481,7 +35553,7 @@ function Exit(value, error, defect) {
35481
35553
  }), Struct({
35482
35554
  _tag: Literal("Failure"),
35483
35555
  cause: Cause(error, defect)
35484
- })]), transform$1({
35556
+ })]), transform$2({
35485
35557
  decode: (e) => e._tag === "Success" ? succeed$7(e.value) : failCause$4(e.cause),
35486
35558
  encode: (exit) => isSuccess(exit) ? {
35487
35559
  _tag: "Success",
@@ -35581,7 +35653,7 @@ function makeClassTrusted(self, fields) {
35581
35653
  } });
35582
35654
  }
35583
35655
  function getClassTransformation(self) {
35584
- return new Transformation(transform$2((input) => makeClassTrusted(self, input)), passthrough$1());
35656
+ return new Transformation(transform$3((input) => makeClassTrusted(self, input)), passthrough$1());
35585
35657
  }
35586
35658
  function getClassTypeId(identifier) {
35587
35659
  return `~effect/Schema/Class/${identifier}`;
@@ -42296,7 +42368,7 @@ function Array$1(value, pathOrOptions, options) {
42296
42368
  const separator = resolvedOptions?.separator ?? ",";
42297
42369
  return schema$1(Union([String$6.pipe(decodeTo(toCodecStringTree(array), {
42298
42370
  decode: split(resolvedOptions),
42299
- encode: compose(passthrough$1({ strict: false }), transform$2((input) => input.join(separator)))
42371
+ encode: compose(passthrough$1({ strict: false }), transform$3((input) => input.join(separator)))
42300
42372
  })), array]), hasPath ? pathOrOptions : void 0);
42301
42373
  }
42302
42374
  function Record(key, value, pathOrOptions, options) {
@@ -45542,6 +45614,18 @@ const accessor = (method) => (...args) => flatMap$3(HttpClient, (client) => clie
45542
45614
  */
45543
45615
  const get$1 = /*#__PURE__*/ accessor("get");
45544
45616
  /**
45617
+ * Transforms a client by wrapping the response effect for each request.
45618
+ *
45619
+ * **Details**
45620
+ *
45621
+ * The transformation receives both the response effect and the original request, allowing it to change success, error, and environment behavior.
45622
+ *
45623
+ * @stability unstable
45624
+ * @category mapping
45625
+ * @since 4.0.0
45626
+ */
45627
+ const transform$1 = /*#__PURE__*/ dual(2, (self, f) => makeWith(flatMap$3((request) => f(self.postprocess(succeed$5(request)), request)), self.preprocess));
45628
+ /**
45545
45629
  * Transforms a client by applying an effectful transformation to each response effect.
45546
45630
  *
45547
45631
  * @stability unstable
@@ -45695,6 +45779,77 @@ const retryTransient = /*#__PURE__*/ dual(2, (self, options) => {
45695
45779
  times
45696
45780
  })));
45697
45781
  });
45782
+ /**
45783
+ * Fails requests that do not receive a response within the given duration.
45784
+ *
45785
+ * **When to use**
45786
+ *
45787
+ * Use to configure a timeout once on the client, for example when providing
45788
+ * the `HttpClient` service, while keeping the standard `HttpClientError` error
45789
+ * model.
45790
+ *
45791
+ * **Details**
45792
+ *
45793
+ * A timed out request is interrupted and fails with an `HttpClientError` whose
45794
+ * reason is a `TransportError` with a `Cause.TimeoutError` cause.
45795
+ * `retryTransient` treats it as transient. Interrupting a request aborts the
45796
+ * underlying transport, unless the request is attached to a scope with
45797
+ * `withScope`, in which case it stays open until the scope closes.
45798
+ *
45799
+ * The timer starts after request preprocessing and covers everything the
45800
+ * wrapped client does to produce a response. For a plain client this ends when
45801
+ * the response headers arrive, but response middleware applied before
45802
+ * `timeout`, such as `tap` or `retryTransient`, runs inside the budget,
45803
+ * including any body reads it performs. Composition order therefore decides
45804
+ * how it interacts with retries: applying `timeout` before `retryTransient`
45805
+ * gives each attempt its own budget, while applying it after bounds the whole
45806
+ * retry loop.
45807
+ *
45808
+ * **Gotchas**
45809
+ *
45810
+ * Body reads outside the timed client are not covered, including those made
45811
+ * by response middleware applied after `timeout` and by consumers of the
45812
+ * `HttpClient` service. Apply a separate timeout to body reads such as
45813
+ * `response.json` or `response.stream` when needed.
45814
+ *
45815
+ * **Example** (Timing out each attempt)
45816
+ *
45817
+ * ```ts
45818
+ * import { Effect, Layer } from "effect"
45819
+ * import { FetchHttpClient, HttpClient } from "effect/http"
45820
+ *
45821
+ * const TimedHttpClient = Layer.effect(
45822
+ * HttpClient.HttpClient,
45823
+ * Effect.map(
45824
+ * HttpClient.HttpClient,
45825
+ * HttpClient.timeout("5 seconds")
45826
+ * )
45827
+ * ).pipe(Layer.provide(FetchHttpClient.layer))
45828
+ *
45829
+ * const program = Effect.gen(function*() {
45830
+ * const client = (yield* HttpClient.HttpClient).pipe(
45831
+ * HttpClient.retryTransient({ times: 3 })
45832
+ * )
45833
+ * return yield* client.get("https://example.com")
45834
+ * }).pipe(Effect.provide(TimedHttpClient))
45835
+ * ```
45836
+ *
45837
+ * @stability unstable
45838
+ * @category error handling
45839
+ * @since 4.1.0
45840
+ */
45841
+ const timeout = /*#__PURE__*/ dual(2, (self, duration) => {
45842
+ const decoded = fromInputUnsafe$1(duration);
45843
+ const description = `timed out after ${format$1(decoded)}`;
45844
+ return transform$1(self, (effect, request) => timeoutOrElse(effect, {
45845
+ duration: decoded,
45846
+ orElse: () => fail$6(new HttpClientError({ reason: new TransportError({
45847
+ request,
45848
+ cause: new TimeoutError(`Operation ${description}`),
45849
+ description
45850
+ }) }))
45851
+ }));
45852
+ });
45698
45853
  const parseRetryAfter = (nowMillis, value) => {
45699
45854
  if (value === void 0) return;
45700
45855
  const retryAfter = parseRetryAfter$1(value);
@@ -50386,7 +50541,7 @@ function withCycleGuard(target) {
50386
50541
  return decodeTo(declareConstructor()([type], ([type]) => (input, ast, options) => {
50387
50542
  if (isObjectOrArray(input) && decoded.delete(input)) return succeed$5(input);
50388
50543
  return isCyclic(input) ? fail$6(new InvalidType(ast, input, options)) : decodeUnknownEffect$1(type)(input, options);
50389
- }, { identifier: "acyclic value" }), transform$1({
50544
+ }, { identifier: "acyclic value" }), transform$2({
50390
50545
  decode: (value) => {
50391
50546
  if (isObjectOrArray(value)) decoded.add(value);
50392
50547
  return value;
@@ -50714,20 +50869,6 @@ const Service = () => (id, options) => {
50714
50869
  ServiceClass_.requiredForClient = options?.requiredForClient ?? false;
50715
50870
  return ServiceClass;
50716
50871
  };
50717
- /**
50718
- * Provides the client-side implementation for an RPC middleware service,
50719
- * capturing the layer's environment and merging it into each middleware
50720
- * invocation.
50721
- *
50722
- * @stability unstable
50723
- * @category layers
50724
- * @since 4.0.0
50725
- */
50726
- const layerClient = (tag, service) => effectContext(gen(function* () {
50727
- const services = (yield* context()).pipe(omit$1(Scope));
50728
- const middleware = isEffect(service) ? yield* service : service;
50729
- return makeUnsafe$9(/* @__PURE__ */ new Map([[`${tag.key}/Client`, (options) => updateContext(middleware(options), (requestContext) => merge$5(services, requestContext))]]));
50730
- }));
50731
50872
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/FindMyWay/internal/queryString.js
50732
50873
  /**
50733
50874
  * @since 1.0.0
@@ -71210,7 +71351,7 @@ const Port = String$6.check(isPattern(/^\d{1,5}$/u), makeFilter((value) => exist
71210
71351
  const AppVersion = String$6.check(isPattern(/^0\.1\.\d+$/u));
71211
71352
  const RUNTIME_PATH = "/api/runtime";
71212
71353
  const RuntimeConfig = Struct({
71213
- auth: optionalKey(String$6),
71354
+ auth: optionalKey(Origin),
71214
71355
  name: String$6,
71215
71356
  traces: String$6,
71216
71357
  version: AppVersion
@@ -71910,8 +72051,9 @@ const SpanKind = {
71910
72051
  };
71911
72052
  // ../../packages/runtime/src/telemetry.ts
71912
72053
  function layerOtlp(serviceName, url, runtime, version) {
71913
- return unwrap$8(gen(function* () {
72054
+ return pipe(unwrap$8(gen(function* () {
71914
72055
  const start = `${yield* currentTimeNanos}`;
72056
+ const redacted = yield* CurrentRedactedNames;
71915
72057
  const resource = {
71916
72058
  attributes: {
71917
72059
  "scope.run.started_unix_nano": start,
@@ -71922,14 +72064,28 @@ function layerOtlp(serviceName, url, runtime, version) {
71922
72064
  serviceVersion: getOrUndefined$1(liftPredicate(version, (current) => current !== "0.1.0"))
71923
72065
  };
71924
72066
  return pipe(mergeAll$1(layer({
71925
- exportInterval: "250 millis",
71926
72067
  resource,
71927
72068
  url: new URL("/v1/traces", url).href
71928
72069
  }), layer$1({
71929
- exportInterval: "250 millis",
71930
72070
  resource,
71931
72071
  url: new URL("/v1/logs", url).href
71932
- })), provide$2([layerJson, layer$12]));
72072
+ }), succeed$6(CurrentRedactedNames)([
72073
+ ...redacted,
72074
+ "code",
72075
+ "state",
72076
+ "request",
72077
+ "access_token",
72078
+ "refresh_token",
72079
+ "id_token",
72080
+ "client_secret",
72081
+ "client_assertion",
72082
+ "code_verifier",
72083
+ "session",
72084
+ "token"
72085
+ ])), provide$2([layerJson, layer$12]));
72086
+ })), catchCause$2((cause) => {
72087
+ if (hasInterrupts(cause)) return effectDiscard(interrupt$1);
72088
+ return effectDiscard(logWarning("Telemetry is unavailable"));
71933
72089
  }));
71934
72090
  }
71935
72091
  // ../../packages/runtime/src/auth/lib/utils.ts
@@ -71946,15 +72102,15 @@ gen(function* () {
71946
72102
  if (yield* localAuth) return yield* withDefault$2(listed, ["0"]);
71947
72103
  return yield* listed;
71948
72104
  });
72105
+ function failureOptions(error, status) {
72106
+ if (is$3(AuthError)(error) && error.error === "temporarily_unavailable") return {
72107
+ headers: { "retry-after": "5" },
72108
+ status: 503
72109
+ };
72110
+ return { status };
72111
+ }
71949
72112
  var CurrentUser = class extends Service$1()("@deslop/runtime/auth/lib/utils/CurrentUser") {};
71950
- var RpcAuth = class RpcAuth extends Service()("@deslop/runtime/auth/lib/utils/RpcAuth", { error: AuthError }) {
71951
- static layerClient = (token) => layerClient(RpcAuth, (options) => gen(function* () {
71952
- return yield* options.next({
71953
- ...options.request,
71954
- headers: set$1(options.request.headers, "authorization", `Bearer ${yield* token}`)
71955
- });
71956
- }));
71957
- };
72113
+ var RpcAuth = class extends Service()("@deslop/runtime/auth/lib/utils/RpcAuth", { error: AuthError }) {};
71958
72114
  // ../../packages/runtime/src/auth/service.ts
71959
72115
  function rejected(message) {
71960
72116
  return mapError$2((cause) => {
@@ -71978,7 +72134,10 @@ const unavailable = text$2("The authorization service is temporarily unavailable
71978
72134
  status: 503
71979
72135
  });
71980
72136
  var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
71981
- static makeContext = (auth) => pipe(make$68(Auth, auth), add$2(RpcAuth, RpcAuth.of((effect, request) => pipe(auth.user(request.headers), flatMap$3((user) => raceFirst(provideService(effect, CurrentUser, user), pipe(delay(auth.user(request.headers), "5 minutes"), retry({ while: (error) => error.error === "temporarily_unavailable" }), forever)))))));
72137
+ static makeContext = (auth) => pipe(make$68(Auth, auth), add$2(RpcAuth, RpcAuth.of((effect, request) => pipe(auth.user(request.headers), tap$1(() => {
72138
+ if (isStreamSchema(request.rpc.successSchema)) return annotateCurrentSpan("rpc.stream", true);
72139
+ return void_$1;
72140
+ }), flatMap$3((user) => raceFirst(provideService(effect, CurrentUser, user), pipe(delay(auth.user(request.headers), "5 minutes"), retry({ while: (error) => error.error === "temporarily_unavailable" }), forever)))))));
71982
72141
  static layer = effectContext(gen(function* () {
71983
72142
  if (yield* localAuth) return Auth.makeContext(Auth.of({
71984
72143
  access: developer,
@@ -71991,13 +72150,13 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
71991
72150
  return yield* pipe(client.get(new URL(VERIFY_PATH, issuer).href, {
71992
72151
  headers: { authorization: headers["authorization"] ?? "" },
71993
72152
  urlParams: { resource: audience }
71994
- }), flatMap$3(schemaBodyJson(User)), timeout("10 seconds"));
72153
+ }), flatMap$3(schemaBodyJson(User)), timeout$1("10 seconds"));
71995
72154
  }, rejected("Sign in first"));
71996
72155
  return Auth.makeContext(Auth.of({
71997
72156
  access,
71998
72157
  user: fn("Auth.user")(function* (headers) {
71999
72158
  if (isSome(get$6(headers, "authorization"))) return yield* access(headers, canonical);
72000
- return yield* pipe(client.get(new URL(SESSION_PATH, issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$3(schemaBodyJson(User)), timeout("10 seconds"));
72159
+ return yield* pipe(client.get(new URL(SESSION_PATH, issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$3(schemaBodyJson(User)), timeout$1("10 seconds"));
72001
72160
  }, rejected("Sign in first"))
72002
72161
  }));
72003
72162
  }));
@@ -72044,7 +72203,7 @@ const dataDirectory = gen(function* () {
72044
72203
  });
72045
72204
  return directory;
72046
72205
  });
72047
- fnUntraced(function* (name) {
72206
+ const tool = fnUntraced(function* (name) {
72048
72207
  const fs = yield* FileSystem;
72049
72208
  const path = yield* Path$1;
72050
72209
  const version = (yield* packageMetadata).version;
@@ -72061,6 +72220,9 @@ fnUntraced(function* (name) {
72061
72220
  yield* forEach$1(filter$4(yield* fs.readDirectory(tools), (entry) => entry !== version), (entry) => fs.remove(path.join(tools, entry), { recursive: true }), { concurrency: 1 });
72062
72221
  return target;
72063
72222
  });
72223
+ var ToolPath = class extends Service$1()("@deslop/runtime/server/ToolPath") {
72224
+ static layer = succeed$6(this, tool);
72225
+ };
72064
72226
  const guard = make$17((app) => gen(function* () {
72065
72227
  const request = yield* HttpServerRequest;
72066
72228
  const host = request.headers["host"] ?? "";
@@ -72094,7 +72256,7 @@ function layerKeyValueStore(directory) {
72094
72256
  return pipe(gen(function* () {
72095
72257
  if (isString$1(value)) yield* fs.writeFileString(`${target}.tmp`, value, { mode: 384 });
72096
72258
  else yield* fs.writeFile(`${target}.tmp`, value, { mode: 384 });
72097
- }), andThen(fs.rename(`${target}.tmp`, target)), withPermit(writes), uninterruptible, mapError$2((cause) => new KeyValueStoreError({
72259
+ }), andThen(fs.rename(`${target}.tmp`, target)), uninterruptible, withPermit(writes), mapError$2((cause) => new KeyValueStoreError({
72098
72260
  cause,
72099
72261
  key,
72100
72262
  message: "Cannot save the value",
@@ -72104,8 +72266,16 @@ function layerKeyValueStore(directory) {
72104
72266
  });
72105
72267
  })), provide$2(layerFileSystem(directory)));
72106
72268
  }
72107
- unwrap$8(map$6(dataDirectory, layerKeyValueStore));
72108
- const layerProtocol = mergeAll$1(layerSchemaBinary(), succeed$6(MaxBodySize)(mebibytes(10)));
72269
+ const layerDataStore = unwrap$8(map$6(dataDirectory, layerKeyValueStore));
72270
+ const layerProtocol = mergeAll$1(layerSchemaBinary(), succeed$6(MaxBodySize)(mebibytes(10)), effect(TracerDisabledWhen, map$6(TracerDisabledWhen, (previous) => (request) => {
72271
+ const path = headNonEmpty(split$1(request.url, "?"));
72272
+ return previous(request) || path === "/api/rpc" && toLowerCase(request.headers["upgrade"] ?? "") === "websocket" || startsWith("/assets/")(path) || contains$1([
72273
+ "/icon",
72274
+ "/favicon.ico",
72275
+ "/apple-touch-icon.png",
72276
+ "/manifest.webmanifest"
72277
+ ], path);
72278
+ })));
72109
72279
  const layerTelemetry = unwrap$8(gen(function* () {
72110
72280
  const metadata = yield* packageMetadata;
72111
72281
  return match$8(yield* option(String$5("OTEL_URL")), {
@@ -72118,6 +72288,7 @@ const layerRoutes = use((router) => gen(function* () {
72118
72288
  const canonical = new URL(yield* String$5("APP_URL")).origin;
72119
72289
  const issuer = yield* option(String$5("AUTH_URL"));
72120
72290
  const traces = yield* pipe(String$5("OTEL_URL"), withDefault$2(""));
72291
+ const metadata = yield* cached(packageMetadata);
72121
72292
  const toIssuer = fnUntraced(function* (search) {
72122
72293
  const request = yield* HttpServerRequest;
72123
72294
  const next = filter$5(liftThrowable(() => new URL(new URL(request.url, canonical).searchParams.get("next") ?? canonical, canonical))(), (url) => url.origin === canonical);
@@ -72133,21 +72304,22 @@ const layerRoutes = use((router) => gen(function* () {
72133
72304
  });
72134
72305
  });
72135
72306
  yield* router.add("GET", RUNTIME_PATH, gen(function* () {
72307
+ const release = yield* metadata;
72136
72308
  return yield* schemaJson(RuntimeConfig)({
72137
72309
  ...match$8(issuer, {
72138
72310
  onNone: () => ({}),
72139
72311
  onSome: (origin) => ({ auth: origin })
72140
72312
  }),
72141
- name: yield* appName,
72313
+ name: replace("@deslop/", "")(release.name),
72142
72314
  traces,
72143
- version: (yield* packageMetadata).version
72315
+ version: release.version
72144
72316
  });
72145
72317
  }));
72146
72318
  yield* router.add("GET", "/auth/sign-in", toIssuer({}));
72147
72319
  yield* router.add("GET", "/auth/sign-out", toIssuer({ "sign-out": "" }));
72148
72320
  yield* router.add("GET", "/auth/user", gen(function* () {
72149
72321
  const user = yield* result(auth.user((yield* HttpServerRequest).headers));
72150
- if (isFailure$1(user)) return empty$1({ status: 401 });
72322
+ if (isFailure$1(user)) return empty$1(failureOptions(user.failure, 401));
72151
72323
  return yield* schemaJson(Account)({
72152
72324
  ...user.success,
72153
72325
  signOut: isSome(issuer)
@@ -72156,14 +72328,14 @@ const layerRoutes = use((router) => gen(function* () {
72156
72328
  }));
72157
72329
  const layerAnnounce = effectDiscard(gen(function* () {
72158
72330
  const origin = new URL(yield* String$5("APP_URL")).origin;
72159
- const client = filterStatusOk(yield* HttpClient);
72331
+ const client = pipe(yield* HttpClient, filterStatusOk, timeout("10 seconds"), retryTransient({
72332
+ schedule: spaced("1 minute"),
72333
+ times: 60
72334
+ }));
72160
72335
  yield* match$8(yield* option(String$5("AUTH_URL")), {
72161
72336
  onNone: () => void_$1,
72162
72337
  onSome: fnUntraced(function* (issuer) {
72163
- yield* pipe(post(new URL(APPS_PATH, issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
72164
- schedule: spaced("1 minute"),
72165
- times: 60
72166
- }), ignore$1({
72338
+ yield* pipe(post(new URL(APPS_PATH, issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), ignore$1({
72167
72339
  log: "Warn",
72168
72340
  message: "Auth did not list this app"
72169
72341
  }), forkScoped);
@@ -72182,11 +72354,10 @@ const layerWeb = unwrap$8(gen(function* () {
72182
72354
  if (!(yield* (yield* FileSystem).exists((yield* Path$1).join(client, "index.html")))) return empty$10;
72183
72355
  const name = capitalize(yield* appName);
72184
72356
  return mergeAll$1(add$1("GET", MANIFEST_PATH, succeed$5(jsonUnsafe({
72185
- background_color: "#0a0a0a",
72357
+ background_color: "#0d0c0c",
72186
72358
  display: "standalone",
72187
72359
  icons: [{
72188
72360
  purpose: "any",
72189
- sizes: "512x512",
72190
72361
  src: "/apple-touch-icon.png",
72191
72362
  type: "image/png"
72192
72363
  }],
@@ -72195,7 +72366,7 @@ const layerWeb = unwrap$8(gen(function* () {
72195
72366
  scope: "/",
72196
72367
  short_name: name,
72197
72368
  start_url: "/",
72198
- theme_color: "#0a0a0a"
72369
+ theme_color: "#0d0c0c"
72199
72370
  }, {
72200
72371
  contentType: "application/manifest+json",
72201
72372
  headers: { "cache-control": "no-cache" }
@@ -72244,7 +72415,7 @@ const execute = fnUntraced(function* (command, args) {
72244
72415
  }, { concurrency: "unbounded" });
72245
72416
  if (result.code !== 0) return yield* AppError.make({ message: `${command} failed: ${result.stderr}` });
72246
72417
  return result.stdout;
72247
- });
72418
+ }, scoped);
72248
72419
  function systemctl(...args) {
72249
72420
  return execute("systemctl", ["--user", ...args]);
72250
72421
  }
@@ -72294,7 +72465,7 @@ function status(name) {
72294
72465
  return systemctl("show", `deslop-${name}.service`, "--property=LoadState,ActiveState,SubState,MainPID");
72295
72466
  }
72296
72467
  function restart(name) {
72297
- return pipe(systemctl("restart", `deslop-${name}.service`), timeout("30 seconds"));
72468
+ return pipe(systemctl("restart", `deslop-${name}.service`), timeout$1("30 seconds"));
72298
72469
  }
72299
72470
  // ../../packages/runtime/src/cli/update.ts
72300
72471
  const serviceDirectory = fnUntraced(function* (name) {
@@ -72318,7 +72489,7 @@ const update$1 = fnUntraced(function* (name) {
72318
72489
  const path = yield* Path$1;
72319
72490
  const root = yield* serviceDirectory(name);
72320
72491
  const running = (yield* decodeEffect(fromJsonString(Struct({ version: AppVersion })))(yield* fs.readFileString(path.join(root, "current", "package.json")))).version;
72321
- const latest = (yield* pipe(filterStatusOk(yield* HttpClient).get(`https://registry.npmjs.org/@deslop%2f${name}/latest`), flatMap$3(schemaBodyJson(Struct({ version: AppVersion }))), timeout("15 seconds"))).version;
72492
+ const latest = (yield* pipe(filterStatusOk(yield* HttpClient).get(`https://registry.npmjs.org/@deslop%2f${name}/latest`), flatMap$3(schemaBodyJson(Struct({ version: AppVersion }))), timeout$1("15 seconds"))).version;
72322
72493
  if (latest === running) return `${name} ${running} is current\n`;
72323
72494
  const npm = path.resolve(path.dirname(execPath), "../lib/node_modules/npm/bin/npm-cli.js");
72324
72495
  if (!(yield* fs.exists(npm))) return yield* AppError.make({ message: "This Node runtime does not include npm; install Node with Vite+" });
@@ -72335,7 +72506,7 @@ const update$1 = fnUntraced(function* (name) {
72335
72506
  "--prefer-online",
72336
72507
  "--registry=https://registry.npmjs.org",
72337
72508
  `@deslop/${name}@${latest}`
72338
- ]), timeout("5 minutes"));
72509
+ ]), timeout$1("5 minutes"));
72339
72510
  const previous = yield* option$1(fs.readLink(path.join(root, "current")));
72340
72511
  yield* activate(name, path.join(directory, "node_modules", "@deslop", name));
72341
72512
  yield* restart(name);
@@ -72344,6 +72515,7 @@ const update$1 = fnUntraced(function* (name) {
72344
72515
  return `Updated ${name} from ${running} to ${latest}\n`;
72345
72516
  });
72346
72517
  // ../../packages/runtime/src/cli.ts
72518
+ const DEFAULT_HOST = "127.0.0.1";
72347
72519
  const SETTINGS = {
72348
72520
  APP_URL: {
72349
72521
  description: "Canonical origin, such as the HTTPS name a proxy serves",
@@ -72356,7 +72528,7 @@ const SETTINGS = {
72356
72528
  schema: SecureOrigin
72357
72529
  },
72358
72530
  HOST: {
72359
- description: "Listen address; defaults to 127.0.0.1",
72531
+ description: `Listen address; defaults to ${DEFAULT_HOST}`,
72360
72532
  flag: "host",
72361
72533
  schema: NonEmptyString
72362
72534
  },
@@ -72364,23 +72536,18 @@ const SETTINGS = {
72364
72536
  description: "Scope origin to export traces and logs to",
72365
72537
  flag: "traces",
72366
72538
  schema: Origin
72367
- },
72368
- PORT: {
72369
- description: "Listen port; defaults to the package's config.port",
72370
- flag: "port",
72371
- schema: Port
72372
72539
  }
72373
72540
  };
72374
72541
  String$6.check(isPattern(/^\d+(?:,\d+)*$/u));
72375
72542
  function flagsOf(settings) {
72376
- return map$10(settings, (setting, key) => pipe(String$1(setting.flag), withSchema(setting.schema), withFallbackConfig(schema$1(setting.schema, key)), withDescription(setting.description), optional));
72543
+ return map$10(settings, (setting, key) => pipe(String$1(setting.flag), withSchema(setting.schema), withFallbackConfig(schema$1(setting.schema, key)), withDescription(`${setting.description} [${key}]`), optional));
72377
72544
  }
72378
- const provider = fnUntraced(function* (given) {
72379
- const port = given["PORT"] ?? `${(yield* packageMetadata).config.port}`;
72545
+ const provider = fnUntraced(function* (given, defaultPort) {
72546
+ const port = given["PORT"] ?? `${defaultPort}`;
72380
72547
  const url = given["APP_URL"] ?? `http://localhost:${port}`;
72381
72548
  if (given["AUTH_URL"] !== void 0 && new URL(url).protocol !== "https:") return yield* AppError.make({ message: "With --auth, set --url to the app's HTTPS origin" });
72382
72549
  return orElse(fromUnknown({
72383
- HOST: "127.0.0.1",
72550
+ HOST: DEFAULT_HOST,
72384
72551
  ...given,
72385
72552
  APP_URL: url,
72386
72553
  PORT: port
@@ -72388,9 +72555,12 @@ const provider = fnUntraced(function* (given) {
72388
72555
  });
72389
72556
  const layerPlatform = mergeAll$1(layer$4, layer$12, layer$15);
72390
72557
  function server(app) {
72391
- return pipe(serve(pipe(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb, layerAnnounce), provide$2(Auth.layer)), {
72558
+ return pipe(serve(pipe(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb, layerAnnounce), provide$2(match$8(fromUndefinedOr(app.middleware), {
72559
+ onNone: () => empty$10,
72560
+ onSome: (middleware$1) => middleware()(middleware$1).layer
72561
+ })), provide$2(Auth.layer)), {
72392
72562
  disableLogger: true,
72393
- middleware: (http) => guard(app.middleware?.(http) ?? http)
72563
+ middleware: guard
72394
72564
  }), provide$2(mergeAll$1(layerProtocol, match$1(app.telemetry === false, {
72395
72565
  onFalse: () => layerTelemetry,
72396
72566
  onTrue: () => empty$10
@@ -72400,21 +72570,26 @@ function output(text) {
72400
72570
  return flatMap$3(Stdio, (stdio) => run$4(make$42(text), stdio.stdout()));
72401
72571
  }
72402
72572
  function runApp(app) {
72403
- const settings = {
72404
- ...SETTINGS,
72405
- ...app.settings
72406
- };
72407
72573
  const program = gen(function* () {
72408
72574
  const metadata = yield* packageMetadata;
72409
72575
  const name = yield* appName;
72576
+ const settings = {
72577
+ ...SETTINGS,
72578
+ PORT: {
72579
+ description: `Listen port; defaults to ${metadata.config.port}`,
72580
+ flag: "port",
72581
+ schema: Port
72582
+ },
72583
+ ...app.settings
72584
+ };
72410
72585
  const root = pipe(make$5(name), withSharedFlags(flagsOf(settings)));
72411
72586
  const given = map$6(root, (input) => getSomes$1(input));
72412
- return yield* pipe(root, withHandler((input) => flatMap$3(provider(getSomes$1(input)), (values) => provideService(server(app), ConfigProvider, values))), withSubcommands([pipe(make$5("service"), withSubcommands([
72587
+ return yield* pipe(root, withHandler((input) => flatMap$3(provider(getSomes$1(input), metadata.config.port), (values) => provideService(server(app), ConfigProvider, values))), withSubcommands([pipe(make$5("service"), withSubcommands([
72413
72588
  make$5("install", {}, fnUntraced(function* () {
72414
72589
  const fs = yield* FileSystem;
72415
72590
  const path = yield* Path$1;
72416
72591
  const flags = yield* given;
72417
- yield* provider(flags);
72592
+ yield* provider(flags, metadata.config.port);
72418
72593
  const entry = path.join(yield* activate(name, yield* fs.realPath(packageRoot)), "dist", "server.js");
72419
72594
  const args = flatten$4(collect$1(flags, (key, value) => [`--${settings[key]?.flag ?? key}`, value]));
72420
72595
  yield* output(yield* install(name, [
@@ -72437,7 +72612,7 @@ function runApp(app) {
72437
72612
  runMain(pipe(program, scoped, provide(layerPlatform), provideService(LogToStderr, true)));
72438
72613
  }
72439
72614
  // src/routes/icon.svg
72440
- var icon_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" shape-rendering=\"crispEdges\"><path fill=\"#deb49a\" d=\"M21 11h1v1h-1zM22 12h2v1h-2zM24 13h2v1h-2zM15 14h1v28h-1zM26 14h2v1h-2zM16 15h2v28h-2zM28 15h2v1h-2zM18 16h2v28h-2zM30 16h2v1h-2zM20 17h2v8h-2zM32 17h2v1h-2zM22 18h2v5h-2zM34 18h2v1h-2zM24 19h2v5h-2zM36 19h2v1h-2zM26 20h2v9h-2zM38 20h2v1h-2zM28 21h2v9h-2zM40 21h2v1h-2zM30 22h2v9h-2zM42 22h2v1h-2zM32 23h2v5h-2zM44 23h2v1h-2zM22 24h2v2h-2zM34 24h2v5h-2zM46 24h1v28h-1zM20 25h1v1h-1zM24 25h2v2h-2zM36 25h2v5h-2zM38 26h2v28h-2zM40 27h1v28h-1zM32 28h1v3h-1zM20 29h1v16h-1zM27 29h1v11h-1zM33 29h1v2h-1zM21 30h1v15h-1zM28 30h1v7h-1zM34 30h2v2h-2zM37 30h1v4h-1zM22 31h2v15h-2zM30 31h1v7h-1zM36 31h1v2h-1zM24 32h3v8h-3zM31 34h1v8h-1zM32 36h2v7h-2zM34 37h2v15h-2zM37 37h1v16h-1zM28 38h2v3h-2zM36 38h1v15h-1zM30 39h1v3h-1zM24 40h2v7h-2zM26 42h1v6h-1zM27 43h1v5h-1zM33 43h1v8h-1zM28 45h2v4h-2zM31 45h2v5h-2zM30 46h1v4h-1zM32 50h1v1h-1z\"/><path fill=\"#0a0a0a\" d=\"M22 9h2v1h-2zM21 10h1v1h-1zM24 10h2v1h-2zM20 11h1v1h-1zM26 11h2v1h-2zM16 12h4v1h-4zM28 12h2v1h-2zM15 13h1v1h-1zM30 13h2v1h-2zM14 14h1v28h-1zM32 14h2v1h-2zM34 15h2v1h-2zM36 16h2v1h-2zM38 17h2v1h-2zM40 18h2v1h-2zM42 19h2v1h-2zM44 20h2v1h-2zM46 21h2v1h-2zM48 22h1v1h-1zM49 23h1v28h-1zM15 42h1v1h-1zM16 43h2v1h-2zM18 44h2v1h-2zM20 45h2v1h-2zM22 46h2v1h-2zM24 47h2v1h-2zM26 48h2v1h-2zM28 49h2v1h-2zM30 50h2v1h-2zM32 51h2v1h-2zM44 51h2v1h-2zM48 51h1v1h-1zM34 52h2v1h-2zM43 52h1v2h-1zM46 52h2v1h-2zM36 53h2v1h-2zM38 54h2v1h-2zM42 54h1v1h-1zM40 55h2v1h-2z\"/><path fill=\"#c49678\" d=\"M48 23h1v28h-1zM47 24h1v28h-1zM42 26h1v28h-1zM41 27h1v28h-1z\"/><path fill=\"#fffcf0\" d=\"M20 12h2v3h-2zM18 13h2v1h-2zM22 13h2v3h-2zM24 14h2v3h-2zM26 15h2v3h-2zM28 16h2v3h-2zM30 17h2v3h-2zM32 18h2v3h-2zM34 19h2v3h-2zM36 20h2v3h-2zM38 21h2v3h-2zM40 22h2v3h-2zM42 23h2v3h-2zM44 24h2v1h-2zM21 26h1v3h-1zM22 27h2v3h-2zM24 28h2v1h-2zM25 29h1v2h-1zM24 30h1v1h-1zM32 32h2v1h-2zM32 33h1v2h-1zM34 33h2v3h-2zM33 34h1v1h-1zM36 34h1v3h-1z\"/><path fill=\"#2a211c\" d=\"M22 23h2v1h-2zM24 24h2v1h-2zM21 25h1v1h-1zM20 26h1v3h-1zM22 26h2v1h-2zM24 27h2v1h-2zM33 28h1v1h-1zM21 29h1v1h-1zM24 29h1v1h-1zM26 29h1v3h-1zM34 29h2v1h-2zM22 30h2v1h-2zM36 30h1v1h-1zM24 31h2v1h-2zM31 31h3v1h-3zM31 32h1v2h-1zM34 32h2v1h-2zM33 33h1v1h-1zM36 33h1v1h-1zM37 34h1v3h-1zM32 35h2v1h-2zM34 36h2v1h-2zM36 37h1v1h-1zM26 40h2v1h-2zM26 41h1v1h-1zM28 41h2v1h-2zM27 42h1v1h-1zM30 42h2v1h-2zM32 43h1v2h-1zM28 44h2v1h-2zM31 44h1v1h-1zM30 45h1v1h-1z\"/><path fill=\"#ecc9b2\" d=\"M22 10h2v1h-2zM24 11h2v1h-2zM26 12h2v1h-2zM16 13h2v1h-2zM28 13h2v1h-2zM18 14h2v1h-2zM30 14h2v1h-2zM20 15h2v1h-2zM32 15h2v1h-2zM22 16h2v1h-2zM34 16h2v1h-2zM24 17h2v1h-2zM36 17h2v1h-2zM26 18h2v1h-2zM38 18h2v1h-2zM28 19h2v1h-2zM40 19h2v1h-2zM30 20h2v1h-2zM42 20h2v1h-2zM32 21h2v1h-2zM44 21h2v1h-2zM34 22h2v1h-2zM46 22h2v1h-2zM36 23h2v1h-2zM38 24h2v1h-2zM40 25h2v1h-2z\"/><path fill=\"#f1d6c5\" d=\"M22 11h2v1h-2zM24 12h2v1h-2zM26 13h2v1h-2zM16 14h2v1h-2zM28 14h2v1h-2zM18 15h2v1h-2zM30 15h2v1h-2zM20 16h2v1h-2zM32 16h2v1h-2zM22 17h2v1h-2zM34 17h2v1h-2zM24 18h2v1h-2zM36 18h2v1h-2zM26 19h2v1h-2zM38 19h2v1h-2zM28 20h2v1h-2zM40 20h2v1h-2zM30 21h2v1h-2zM42 21h2v1h-2zM32 22h2v1h-2zM44 22h2v1h-2zM34 23h2v1h-2zM46 23h2v1h-2zM36 24h2v1h-2zM38 25h2v1h-2zM40 26h2v1h-2z\"/><path fill=\"#dad8ce\" d=\"M44 25h2v1h-2zM43 26h1v1h-1zM44 27h2v1h-2zM43 28h1v1h-1zM44 29h2v1h-2zM43 30h1v1h-1zM44 31h2v1h-2zM43 32h1v1h-1zM44 33h2v1h-2zM43 34h1v1h-1zM44 35h2v1h-2zM43 36h1v1h-1zM44 37h2v1h-2zM43 38h1v1h-1zM44 39h2v1h-2zM43 40h1v1h-1zM44 41h2v1h-2zM43 42h1v1h-1zM44 43h2v1h-2zM43 44h1v1h-1zM44 45h2v1h-2zM43 46h1v1h-1zM44 47h2v1h-2zM43 48h1v1h-1zM44 49h2v1h-2zM43 50h1v1h-1z\"/><path fill=\"#f2f0e5\" d=\"M44 26h2v1h-2zM43 27h1v1h-1zM44 28h2v1h-2zM43 29h1v1h-1zM44 30h2v1h-2zM43 31h1v1h-1zM44 32h2v1h-2zM43 33h1v1h-1zM44 34h2v1h-2zM43 35h1v1h-1zM44 36h2v1h-2zM43 37h1v1h-1zM44 38h2v1h-2zM43 39h1v1h-1zM44 40h2v1h-2zM43 41h1v1h-1zM44 42h2v1h-2zM43 43h1v1h-1zM44 44h2v1h-2zM43 45h1v1h-1zM44 46h2v1h-2zM43 47h1v1h-1zM44 48h2v1h-2zM43 49h1v1h-1zM44 50h2v1h-2zM43 51h1v1h-1z\"/><path fill=\"#000000\" fill-opacity=\"0.353\" d=\"M17 44h1v1h-1zM18 45h2v1h-2zM20 46h2v1h-2zM22 47h2v1h-2zM24 48h2v1h-2zM26 49h2v1h-2zM28 50h2v1h-2zM30 51h2v1h-2zM32 52h2v1h-2zM34 53h2v1h-2zM36 54h2v1h-2zM38 55h2v1h-2zM40 56h1v1h-1z\"/><path fill=\"#a77457\" d=\"M29 30h1v8h-1zM28 37h1v1h-1zM30 38h1v1h-1z\"/><path fill=\"#c98481\" d=\"M27 41h1v1h-1zM28 42h2v2h-2zM30 43h2v1h-2zM30 44h1v1h-1z\"/></svg>\n";
72615
+ var icon_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" shape-rendering=\"crispEdges\"><path fill=\"#000\" fill-opacity=\".18\" d=\"M12 40h1v1h-1zM10 41h3v1h-3zM8 42h4v1h-4zM10 43h4v1h-4zM12 44h4v1h-4zM14 45h4v1h-4zM16 46h4v1h-4zM18 47h4v1h-4zM20 48h4v1h-4zM51 48h1v1h-1zM22 49h4v1h-4zM51 49h3v1h-3zM24 50h4v1h-4zM52 50h4v1h-4zM26 51h4v1h-4zM50 51h4v1h-4zM28 52h4v1h-4zM44 52h8v1h-8zM30 53h4v1h-4zM43 53h7v1h-7zM32 54h4v1h-4zM44 54h4v1h-4zM34 55h4v1h-4zM42 55h4v1h-4zM36 56h8v1h-8zM38 57h4v1h-4z\"/><path fill=\"#000\" fill-opacity=\".38\" d=\"M12 42h2v1h-2zM14 43h1v1h-1zM16 44h1v1h-1zM18 45h1v1h-1zM20 46h1v1h-1zM22 47h1v1h-1zM24 48h1v1h-1zM26 49h1v1h-1zM28 50h1v1h-1zM50 50h2v1h-2zM30 51h1v1h-1zM45 51h2v1h-2zM49 51h1v1h-1zM32 52h1v1h-1zM43 52h1v1h-1zM34 53h1v1h-1zM36 54h1v1h-1zM42 54h2v1h-2zM38 55h1v1h-1zM41 55h1v1h-1z\"/><path fill=\"#7a5d4c\" d=\"M23 8h2v1h-2zM21 9h2v1h-2zM25 9h2v1h-2zM19 10h2v1h-2zM27 10h2v1h-2zM17 11h2v1h-2zM29 11h2v1h-2zM15 12h2v1h-2zM23 12h1v1h-1zM31 12h2v1h-2zM14 13h1v1h-1zM21 13h2v1h-2zM33 13h2v1h-2zM13 14h1v1h-1zM19 14h2v1h-2zM35 14h2v1h-2zM13 15h1v1h-1zM37 15h2v1h-2zM13 16h1v1h-1zM39 16h2v1h-2zM13 17h1v1h-1zM41 17h2v1h-2zM13 18h1v1h-1zM43 18h2v1h-2zM13 19h1v1h-1zM45 19h2v1h-2zM13 20h1v1h-1zM47 20h2v1h-2zM13 21h1v1h-1zM49 21h1v1h-1zM13 22h1v1h-1zM50 22h1v1h-1zM13 23h1v1h-1zM50 23h1v1h-1zM13 24h1v1h-1zM50 24h1v1h-1zM13 25h1v1h-1zM50 25h1v1h-1zM13 26h1v1h-1zM50 26h1v1h-1zM13 27h1v1h-1zM50 27h1v1h-1zM13 28h1v1h-1zM50 28h1v1h-1zM13 29h1v1h-1zM50 29h1v1h-1zM13 30h1v1h-1zM50 30h1v1h-1zM13 31h1v1h-1zM50 31h1v1h-1zM13 32h1v1h-1zM50 32h1v1h-1zM13 33h1v1h-1zM50 33h1v1h-1zM13 34h1v1h-1zM50 34h1v1h-1zM13 35h1v1h-1zM50 35h1v1h-1zM13 36h1v1h-1zM50 36h1v1h-1zM13 37h1v1h-1zM50 37h1v1h-1zM13 38h1v1h-1zM50 38h1v1h-1zM13 39h1v1h-1zM50 39h1v1h-1zM13 40h1v1h-1zM50 40h1v1h-1zM13 41h1v1h-1zM50 41h1v1h-1zM14 42h1v1h-1zM50 42h1v1h-1zM15 43h2v1h-2zM50 43h1v1h-1zM17 44h2v1h-2zM50 44h1v1h-1zM19 45h2v1h-2zM50 45h1v1h-1zM21 46h2v1h-2zM50 46h1v1h-1zM23 47h2v1h-2zM50 47h1v1h-1zM25 48h2v1h-2zM50 48h1v1h-1zM27 49h2v1h-2zM49 49h2v1h-2zM29 50h2v1h-2zM46 50h1v1h-1zM48 50h2v1h-2zM31 51h2v1h-2zM47 51h2v1h-2zM33 52h2v1h-2zM35 53h2v1h-2zM41 53h2v1h-2zM37 54h2v1h-2zM40 54h2v1h-2zM39 55h2v1h-2z\"/><path fill=\"#f3d1b7\" d=\"M23 9h2v1h-2zM21 10h3v1h-3zM25 10h2v1h-2zM19 11h2v1h-2zM27 11h2v1h-2zM17 12h2v1h-2zM29 12h2v1h-2zM15 13h4v1h-4zM31 13h2v1h-2zM17 14h2v1h-2zM33 14h2v1h-2zM19 15h2v1h-2zM35 15h2v1h-2zM21 16h2v1h-2zM37 16h2v1h-2zM23 17h2v1h-2zM39 17h2v1h-2zM25 18h2v1h-2zM41 18h2v1h-2zM27 19h2v1h-2zM43 19h2v1h-2zM29 20h2v1h-2zM45 20h2v1h-2zM31 21h2v1h-2zM47 21h2v1h-2zM33 22h2v1h-2zM35 23h2v1h-2zM47 23h1v1h-1zM37 24h2v1h-2zM47 24h1v1h-1zM39 25h2v1h-2zM47 25h1v1h-1zM47 26h1v1h-1zM39 27h1v1h-1zM47 27h1v1h-1zM39 28h1v1h-1zM47 28h1v1h-1zM39 29h1v1h-1zM47 29h1v1h-1zM39 30h1v1h-1zM47 30h1v1h-1zM39 31h1v1h-1zM47 31h1v1h-1zM39 32h1v1h-1zM47 32h1v1h-1zM39 33h1v1h-1zM47 33h1v1h-1zM39 34h1v1h-1zM47 34h1v1h-1zM39 35h1v1h-1zM47 35h1v1h-1zM39 36h1v1h-1zM47 36h1v1h-1zM39 37h1v1h-1zM47 37h1v1h-1zM39 38h1v1h-1zM47 38h1v1h-1zM39 39h1v1h-1zM47 39h1v1h-1zM39 40h1v1h-1zM47 40h1v1h-1zM39 41h1v1h-1zM47 41h1v1h-1zM39 42h1v1h-1zM47 42h1v1h-1zM39 43h1v1h-1zM47 43h1v1h-1zM39 44h1v1h-1zM47 44h1v1h-1zM39 45h1v1h-1zM47 45h1v1h-1zM39 46h1v1h-1zM47 46h1v1h-1zM39 47h1v1h-1zM47 47h1v1h-1zM39 48h1v1h-1zM47 48h1v1h-1zM39 49h1v1h-1zM47 49h1v1h-1zM39 50h1v1h-1zM39 51h1v1h-1zM39 52h1v1h-1zM39 53h1v1h-1z\"/><path fill=\"#fee7d5\" d=\"M24 10h1v1h-1zM21 11h2v1h-2zM25 11h2v1h-2zM19 12h2v1h-2zM27 12h2v1h-2zM29 13h2v1h-2zM15 14h2v1h-2zM31 14h2v1h-2zM17 15h2v1h-2zM33 15h2v1h-2zM19 16h2v1h-2zM35 16h2v1h-2zM21 17h2v1h-2zM37 17h2v1h-2zM23 18h2v1h-2zM39 18h2v1h-2zM25 19h2v1h-2zM41 19h2v1h-2zM27 20h2v1h-2zM43 20h2v1h-2zM29 21h2v1h-2zM45 21h2v1h-2zM31 22h2v1h-2zM47 22h2v1h-2zM33 23h2v1h-2zM35 24h2v1h-2zM37 25h2v1h-2zM39 26h2v1h-2z\"/><path fill=\"#b38d74\" d=\"M23 11h1v1h-1zM21 12h2v1h-2zM19 13h2v1h-2zM49 22h1v1h-1zM48 23h2v1h-2zM48 24h2v1h-2zM48 25h2v1h-2zM41 26h1v1h-1zM48 26h2v1h-2zM40 27h2v1h-2zM48 27h2v1h-2zM40 28h2v1h-2zM48 28h2v1h-2zM40 29h2v1h-2zM48 29h2v1h-2zM40 30h2v1h-2zM48 30h2v1h-2zM40 31h2v1h-2zM48 31h2v1h-2zM40 32h2v1h-2zM48 32h2v1h-2zM40 33h2v1h-2zM48 33h2v1h-2zM40 34h2v1h-2zM48 34h2v1h-2zM40 35h2v1h-2zM48 35h2v1h-2zM40 36h2v1h-2zM48 36h2v1h-2zM40 37h2v1h-2zM48 37h2v1h-2zM40 38h2v1h-2zM48 38h2v1h-2zM40 39h2v1h-2zM48 39h2v1h-2zM40 40h2v1h-2zM48 40h2v1h-2zM40 41h2v1h-2zM48 41h2v1h-2zM40 42h2v1h-2zM48 42h2v1h-2zM40 43h2v1h-2zM48 43h2v1h-2zM40 44h2v1h-2zM48 44h2v1h-2zM40 45h2v1h-2zM48 45h2v1h-2zM40 46h2v1h-2zM48 46h2v1h-2zM40 47h2v1h-2zM48 47h2v1h-2zM40 48h2v1h-2zM48 48h2v1h-2zM40 49h2v1h-2zM48 49h1v1h-1zM40 50h2v1h-2zM40 51h2v1h-2zM40 52h2v1h-2zM40 53h1v1h-1z\"/><path fill=\"#E4BC9E\" d=\"M24 11h1v1h-1zM25 12h2v1h-2zM27 13h2v1h-2zM14 14h1v1h-1zM29 14h2v1h-2zM14 15h3v1h-3zM31 15h2v1h-2zM14 16h5v1h-5zM33 16h2v1h-2zM14 17h7v1h-7zM35 17h2v1h-2zM14 18h9v1h-9zM37 18h2v1h-2zM14 19h11v1h-11zM39 19h2v1h-2zM14 20h13v1h-13zM41 20h2v1h-2zM14 21h15v1h-15zM43 21h2v1h-2zM14 22h17v1h-17zM45 22h2v1h-2zM14 23h7v1h-7zM23 23h10v1h-10zM46 23h1v1h-1zM14 24h9v1h-9zM25 24h10v1h-10zM46 24h1v1h-1zM14 25h6v1h-6zM21 25h16v1h-16zM46 25h1v1h-1zM14 26h5v1h-5zM23 26h16v1h-16zM46 26h1v1h-1zM14 27h5v1h-5zM25 27h14v1h-14zM46 27h1v1h-1zM14 28h5v1h-5zM25 28h7v1h-7zM33 28h6v1h-6zM46 28h1v1h-1zM14 29h6v1h-6zM26 29h7v1h-7zM35 29h4v1h-4zM46 29h1v1h-1zM14 30h7v1h-7zM26 30h2v1h-2zM29 30h6v1h-6zM36 30h3v1h-3zM46 30h1v1h-1zM14 31h9v1h-9zM26 31h2v1h-2zM29 31h1v1h-1zM33 31h6v1h-6zM46 31h1v1h-1zM14 32h14v1h-14zM29 32h1v1h-1zM35 32h4v1h-4zM46 32h1v1h-1zM14 33h14v1h-14zM29 33h1v1h-1zM36 33h3v1h-3zM46 33h1v1h-1zM14 34h14v1h-14zM29 34h2v1h-2zM37 34h2v1h-2zM46 34h1v1h-1zM14 35h14v1h-14zM29 35h2v1h-2zM37 35h2v1h-2zM46 35h1v1h-1zM14 36h14v1h-14zM29 36h4v1h-4zM37 36h2v1h-2zM46 36h1v1h-1zM14 37h13v1h-13zM29 37h6v1h-6zM36 37h3v1h-3zM46 37h1v1h-1zM14 38h15v1h-15zM30 38h9v1h-9zM46 38h1v1h-1zM14 39h11v1h-11zM27 39h12v1h-12zM46 39h1v1h-1zM14 40h11v1h-11zM29 40h10v1h-10zM46 40h1v1h-1zM15 41h11v1h-11zM31 41h8v1h-8zM46 41h1v1h-1zM17 42h10v1h-10zM32 42h7v1h-7zM46 42h1v1h-1zM19 43h8v1h-8zM32 43h7v1h-7zM46 43h1v1h-1zM21 44h8v1h-8zM30 44h9v1h-9zM46 44h1v1h-1zM23 45h16v1h-16zM46 45h1v1h-1zM25 46h14v1h-14zM46 46h1v1h-1zM27 47h12v1h-12zM46 47h1v1h-1zM29 48h10v1h-10zM46 48h1v1h-1zM31 49h8v1h-8zM33 50h6v1h-6zM35 51h4v1h-4zM37 52h2v1h-2z\"/><path fill=\"#cca68b\" d=\"M24 12h1v1h-1zM25 13h2v1h-2zM27 14h2v1h-2zM29 15h2v1h-2zM31 16h2v1h-2zM33 17h2v1h-2zM35 18h2v1h-2zM37 19h2v1h-2zM39 20h2v1h-2zM41 21h2v1h-2zM43 22h2v1h-2zM45 23h1v1h-1zM14 41h1v1h-1zM15 42h2v1h-2zM17 43h2v1h-2zM19 44h2v1h-2zM21 45h2v1h-2zM23 46h2v1h-2zM25 47h2v1h-2zM27 48h2v1h-2zM29 49h2v1h-2zM46 49h1v1h-1zM31 50h2v1h-2zM47 50h1v1h-1zM33 51h2v1h-2zM35 52h2v1h-2zM37 53h2v1h-2zM39 54h1v1h-1z\"/><path fill=\"#f9f5e6\" d=\"M23 13h2v1h-2zM21 14h6v1h-6zM21 15h8v1h-8zM23 16h8v1h-8zM25 17h8v1h-8zM27 18h8v1h-8zM29 19h8v1h-8zM31 20h8v1h-8zM33 21h8v1h-8zM35 22h8v1h-8zM37 23h8v1h-8zM39 24h6v1h-6zM41 25h2v1h-2z\"/><path fill=\"#2A211C\" d=\"M21 23h2v1h-2zM23 24h2v1h-2zM20 25h1v1h-1zM19 26h1v1h-1zM21 26h2v1h-2zM19 27h1v1h-1zM23 27h2v1h-2zM19 28h1v1h-1zM32 28h1v1h-1zM20 29h1v1h-1zM23 29h1v1h-1zM25 29h1v1h-1zM33 29h2v1h-2zM21 30h2v1h-2zM25 30h1v1h-1zM35 30h1v1h-1zM23 31h3v1h-3zM30 31h3v1h-3zM30 32h1v1h-1zM33 32h2v1h-2zM30 33h1v1h-1zM32 33h1v1h-1zM35 33h1v1h-1zM36 34h1v1h-1zM31 35h2v1h-2zM36 35h1v1h-1zM33 36h2v1h-2zM36 36h1v1h-1zM35 37h1v1h-1zM25 39h2v1h-2zM25 40h1v1h-1zM27 40h2v1h-2zM26 41h1v1h-1zM29 41h2v1h-2zM31 42h1v1h-1zM27 43h2v1h-2zM30 43h2v1h-2zM29 44h1v1h-1z\"/><path fill=\"#c0bdad\" d=\"M45 24h1v1h-1zM43 25h3v1h-3zM42 26h4v1h-4zM42 27h4v1h-4zM42 28h4v1h-4zM42 29h4v1h-4zM42 30h4v1h-4zM42 31h4v1h-4zM42 32h4v1h-4zM42 33h4v1h-4zM42 34h4v1h-4zM42 35h4v1h-4zM42 36h4v1h-4zM42 37h4v1h-4zM42 38h4v1h-4zM42 39h4v1h-4zM42 40h4v1h-4zM42 41h4v1h-4zM42 42h4v1h-4zM42 43h4v1h-4zM42 44h4v1h-4zM42 45h4v1h-4zM42 46h4v1h-4zM42 47h4v1h-4zM42 48h4v1h-4zM42 49h4v1h-4zM42 50h3v1h-3zM42 51h1v1h-1z\"/><path fill=\"#FFFCF0\" d=\"M20 26h1v1h-1zM20 27h3v1h-3zM20 28h5v1h-5zM21 29h2v1h-2zM24 29h1v1h-1zM23 30h2v1h-2zM31 32h2v1h-2zM31 33h1v1h-1zM33 33h2v1h-2zM31 34h5v1h-5zM33 35h3v1h-3zM35 36h1v1h-1z\"/><path fill=\"#A77457\" d=\"M28 30h1v1h-1zM28 31h1v1h-1zM28 32h1v1h-1zM28 33h1v1h-1zM28 34h1v1h-1zM28 35h1v1h-1zM28 36h1v1h-1zM27 37h2v1h-2zM29 38h1v1h-1z\"/><path fill=\"#C98481\" d=\"M26 40h1v1h-1zM27 41h2v1h-2zM27 42h4v1h-4zM29 43h1v1h-1z\"/><path fill=\"#8b897c\" d=\"M45 50h1v1h-1zM43 51h2v1h-2zM42 52h1v1h-1z\"/></svg>";
72441
72616
  // src/services/chapters/schema.ts
72442
72617
  var ChaptersError = class extends TaggedError()("ChaptersError", {
72443
72618
  cause: optional$2(Defect()),
@@ -119276,12 +119451,12 @@ var require_mime_type = /* @__PURE__ */ __commonJSMin(((exports, module) => {
119276
119451
  require_undici();
119277
119452
  require_mime_type();
119278
119453
  // src/services/chapters/lib/store.ts
119279
- const failed$1 = mapError$2((cause) => ChaptersError.make({
119454
+ const failed = mapError$2((cause) => ChaptersError.make({
119280
119455
  cause,
119281
119456
  message: "The chapter storage failed."
119282
119457
  }));
119283
- const openStore = fnUntraced(function* (directory) {
119284
- const store = get$10(yield* build(layerKeyValueStore(directory)), KeyValueStore);
119458
+ const openStore = fnUntraced(function* () {
119459
+ const store = yield* KeyValueStore;
119285
119460
  const chapters = toSchemaStore(store, ArraySchema(Chapter));
119286
119461
  const devices = toSchemaStore(store, ArraySchema(PushToken));
119287
119462
  const tokens = yield* make$34(copy$3(getOrElse(yield* devices.get("devices"), () => [])));
@@ -119289,16 +119464,16 @@ const openStore = fnUntraced(function* (directory) {
119289
119464
  return pipe(updateEffect$1(tokens, (current) => {
119290
119465
  const next = update(current);
119291
119466
  return as(devices.set("devices", next), next);
119292
- }), uninterruptible, failed$1);
119467
+ }), uninterruptible, failed);
119293
119468
  }
119294
119469
  return {
119295
119470
  addDevice: (token) => updateDevices((current) => dedupe([...current, token])),
119296
119471
  devices: get$3(tokens),
119297
- load: pipe(chapters.get("chapters"), map$6(getOrElse(() => [])), failed$1),
119472
+ load: pipe(chapters.get("chapters"), map$6(getOrElse(() => [])), failed),
119298
119473
  removeDevice: (token) => updateDevices((current) => filter$4(current, (saved) => saved !== token)),
119299
- save: (current) => pipe(chapters.set("chapters", current), failed$1)
119474
+ save: (current) => pipe(chapters.set("chapters", current), failed)
119300
119475
  };
119301
- }, failed$1);
119476
+ }, failed);
119302
119477
  // src/services/chapters/lib/utils.ts
119303
119478
  const TITLE = /^(?<tags>(?:\[[^\]]*\]\s*)*)Chapter\s+(?<number>\d+(?:\.\d+)?)(?:\/\d+)?\s*\[(?:English|Translations)\]/iu;
119304
119479
  const CUBARI = /https:\/\/cubari\.moe\/read\/(?<source>imgchest|imgur|gist)\/(?<slug>[\w-]+)(?:\/(?<chapter>[\d.]+))?/u;
@@ -119403,12 +119578,6 @@ const ARCHIVE_POSTS = map$9([
119403
119578
  series: release.series
119404
119579
  }));
119405
119580
  const newestFirst = flip$1(byNumber);
119406
- function failed(message) {
119407
- return mapError$2((cause) => ChaptersError.make({
119408
- cause,
119409
- message
119410
- }));
119411
- }
119412
119581
  function indexUrl(series) {
119413
119582
  return `https://cubari.moe/read/gist/${INDEXES[series]}/`;
119414
119583
  }
@@ -119431,15 +119600,16 @@ function postsOf(feed) {
119431
119600
  })), getSomes);
119432
119601
  }
119433
119602
  var Chapters = class Chapters extends Service$1()("@deslop/opm/services/chapters/service/Chapters") {
119434
- static layer = (directory) => effect(this, gen(function* () {
119603
+ static layer = effect(this, gen(function* () {
119435
119604
  const client = yield* HttpClient;
119436
- const exit = yield* pipe(option(String$5("OPM_PROXY")), failed("OPM_PROXY is unreadable."));
119437
- const store = yield* openStore(directory);
119605
+ const exit = yield* option(String$5("OPM_PROXY"));
119606
+ const store = yield* openStore();
119438
119607
  const state = yield* make$32(sort(yield* store.load, newestFirst));
119439
119608
  function series(url) {
119440
- return pipe(client.get(url, { headers: { "user-agent": BROWSER } }), flatMap$3(filterStatusOk$1), flatMap$3(schemaBodyJson(CubariSeries)), timeout("20 seconds"), retry({
119609
+ return pipe(client.get(url, { headers: { "user-agent": BROWSER } }), flatMap$3(filterStatusOk$1), flatMap$3(schemaBodyJson(CubariSeries)), timeout$1("20 seconds"), retry({
119441
119610
  schedule: exponential("1 second"),
119442
- times: 2
119611
+ times: 2,
119612
+ while: isTransientError
119443
119613
  }));
119444
119614
  }
119445
119615
  const resolve = fnUntraced(function* (post, link) {
@@ -119496,7 +119666,7 @@ var Chapters = class Chapters extends Service$1()("@deslop/opm/services/chapters
119496
119666
  });
119497
119667
  const feeds = yield* forEach$1(FEEDS, (url) => pipe(gen(function* () {
119498
119668
  const session = `${yield* nextIntBetween(1e7, 99999999)}`;
119499
- return yield* pipe(get$1(url, { headers: { "user-agent": BROWSER } }), flatMap$3(filterStatusOk$1), flatMap$3((response) => response.text), timeout("20 seconds"), provide(match$8(exit, {
119669
+ return yield* pipe(get$1(url, { headers: { "user-agent": BROWSER } }), flatMap$3(filterStatusOk$1), flatMap$3((response) => response.text), timeout$1("20 seconds"), provide(match$8(exit, {
119500
119670
  onNone: () => succeed$6(HttpClient, client),
119501
119671
  onSome: (proxy) => pipe(layerNodeHttpNoAgent, provide$2(layerAgentOptions({ proxyEnv: {
119502
119672
  HTTP_PROXY: replaceAll("{session}", session)(proxy),
@@ -119550,7 +119720,7 @@ var Chapters = class Chapters extends Service$1()("@deslop/opm/services/chapters
119550
119720
  threadId: chapter.series,
119551
119721
  title: `${SERIES_NAMES[chapter.series]} · Chapter ${chapter.number}`,
119552
119722
  to
119553
- }))), flatMap$3((request) => client.execute(request)), flatMap$3(filterStatusOk$1), flatMap$3(schemaBodyJson(PushTickets)), timeout("20 seconds"));
119723
+ }))), flatMap$3((request) => client.execute(request)), flatMap$3(filterStatusOk$1), flatMap$3(schemaBodyJson(PushTickets.check(makeFilter((received) => received.data.length === tokens.length, { message: "Expo must return exactly one ticket per message" })))), timeout$1("20 seconds"));
119554
119724
  const tickets = zip(tokens, answer.data);
119555
119725
  yield* forEach$1(filter$4(tickets, (pair) => pair[1].details?.error === "DeviceNotRegistered"), (pair) => store.removeDevice(pair[0]), {
119556
119726
  concurrency: 1,
@@ -119580,7 +119750,7 @@ var Chapters = class Chapters extends Service$1()("@deslop/opm/services/chapters
119580
119750
  yield* forkScoped(repeat(pipe(sync, ignore$1({
119581
119751
  log: "Warn",
119582
119752
  message: "The chapter sync failed"
119583
- }), andThen(notify)), spaced("6 hours")));
119753
+ }), andThen(notify), withSpan("Chapters.sync")), spaced("6 hours")));
119584
119754
  return Chapters.of({
119585
119755
  changes: pipe(changes(state), mapAccum(() => none(), (previous, current) => [some$2(current), match$8(previous, {
119586
119756
  onNone: () => [{
@@ -119615,7 +119785,6 @@ var Chapters = class Chapters extends Service$1()("@deslop/opm/services/chapters
119615
119785
  });
119616
119786
  }));
119617
119787
  };
119618
- const layerChapters = unwrap$8(pipe(dataDirectory, failed("The chapters folder could not be read."), map$6(Chapters.layer)));
119619
119788
  // src/main.server.ts
119620
119789
  runApp({
119621
119790
  icon: icon_default,
@@ -119629,6 +119798,6 @@ runApp({
119629
119798
  "library.watch": () => chapters.changes
119630
119799
  });
119631
119800
  }))
119632
- }), provide$2(layerJson$1), provide$2(layerChapters))
119801
+ }), provide$2(layerJson$1), provide$2(Chapters.layer), provide$2(layerDataStore))
119633
119802
  });
119634
119803
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/opm",
3
- "version": "0.1.1247",
3
+ "version": "0.1.1249",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/MP281X/deslop.git",
@@ -31,5 +31,5 @@
31
31
  "engines": {
32
32
  "node": ">=26"
33
33
  },
34
- "fingerprint": "6aa51ed4032a5ac9cf23305b328ea59541f438b63683aee8303fde077a034822"
34
+ "fingerprint": "3fecf483e0cf4058cec00c7e864e987b7a6e1c9054a79bf987b32e736a5df54a"
35
35
  }