@deslop/deploy 0.1.1310 → 0.1.1313

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -6389,6 +6389,54 @@ const empty$16 = () => ({});
6389
6389
  */
6390
6390
  const isEmptyRecord = (self) => Object.keys(self).length === 0;
6391
6391
  /**
6392
+ * Takes an iterable and a projection function and returns a record.
6393
+ * The projection function maps each value of the iterable to a tuple of a key and a value, which is then added to the resulting record.
6394
+ *
6395
+ * **Example** (Building a record from mapped iterable values)
6396
+ *
6397
+ * ```ts import.meta.vitest
6398
+ * import { Record } from "effect"
6399
+ *
6400
+ * Record.fromIterableWith([1, 2, 3, 4], (a) => [String(a), a * 2]) // => { "1": 2, "2": 4, "3": 6, "4": 8 }
6401
+ * ```
6402
+ *
6403
+ * @stability stable
6404
+ * @category constructors
6405
+ * @since 2.0.0
6406
+ */
6407
+ const fromIterableWith = /*#__PURE__*/ dual(2, (self, f) => {
6408
+ const out = empty$16();
6409
+ for (const a of self) {
6410
+ const [k, b] = f(a);
6411
+ assignProperty(out, k, b);
6412
+ }
6413
+ return out;
6414
+ });
6415
+ /**
6416
+ * Creates a new record from an iterable, utilizing the provided function to determine the key for each element.
6417
+ *
6418
+ * **Example** (Building a record keyed by iterable values)
6419
+ *
6420
+ * ```ts import.meta.vitest
6421
+ * import { Record } from "effect"
6422
+ *
6423
+ * const users = [
6424
+ * { id: "2", name: "name2" },
6425
+ * { id: "1", name: "name1" }
6426
+ * ]
6427
+ *
6428
+ * Record.fromIterableBy(
6429
+ * users,
6430
+ * (user) => user.id
6431
+ * ) // => { "1": { id: "1", name: "name1" }, "2": { id: "2", name: "name2" } }
6432
+ * ```
6433
+ *
6434
+ * @stability stable
6435
+ * @category constructors
6436
+ * @since 2.0.0
6437
+ */
6438
+ const fromIterableBy = /*#__PURE__*/ dual(2, (items, f) => fromIterableWith(items, (a) => [f(a), a]));
6439
+ /**
6392
6440
  * Builds a record from an iterable of key-value pairs.
6393
6441
  *
6394
6442
  * **Details**
@@ -16854,7 +16902,27 @@ const round = /*#__PURE__*/ dual(2, (self, precision) => {
16854
16902
  const factor = Math.pow(10, precision);
16855
16903
  return Math.round(self * factor) / factor;
16856
16904
  });
16857
- globalThis.String;
16905
+ // ../../node_modules/.pnpm/effect@4.1.4/node_modules/effect/dist/String.js
16906
+ /**
16907
+ * Exposes the global string constructor.
16908
+ *
16909
+ * **When to use**
16910
+ *
16911
+ * Use to access native JavaScript string coercion or constructor behavior from
16912
+ * the Effect module namespace.
16913
+ *
16914
+ * **Gotchas**
16915
+ *
16916
+ * Calling `String(value)` returns a primitive string. Calling
16917
+ * `new String(value)` creates a boxed `String` object.
16918
+ *
16919
+ * @see {@link isString} for checking whether a value is a primitive string
16920
+ *
16921
+ * @stability stable
16922
+ * @category constructors
16923
+ * @since 4.0.0
16924
+ */
16925
+ const String$9 = globalThis.String;
16858
16926
  /**
16859
16927
  * Checks whether a value is a `string`.
16860
16928
  *
@@ -109169,7 +109237,7 @@ var Sessions = class Sessions extends Service$1()("@deslop/runtime/server/sessio
109169
109237
  });
109170
109238
  const granted = fnUntraced(function* (params) {
109171
109239
  const response = yield* post$1(TOKEN_PATH, params);
109172
- if (response.status === 400 || response.status === 401) return yield* RefusedError.make({ message: pipe(yield* option$1(schemaBodyJson$1(Refusal$1)(response)), flatMap$8((body) => body.error_description), getOrElse$1(() => "Auth refused the sign-in")) });
109240
+ if (response.status === 400 || response.status === 401) return yield* RefusedError.make({ message: pipe(yield* option$1(schemaBodyJson$1(Refusal$1)(response)), flatMap$8((body) => body.error_description), getOrElse$1(constant("Auth refused the sign-in"))) });
109173
109241
  return yield* schemaBodyJson$1(TokenResponse)(yield* filterStatusOk$1(response));
109174
109242
  });
109175
109243
  const sessionOf = fnUntraced(function* (tokens, clientId, idHash) {
@@ -109253,7 +109321,7 @@ var Sessions = class Sessions extends Service$1()("@deslop/runtime/server/sessio
109253
109321
  for (const session of yield* findSessionsOf(userId)) {
109254
109322
  if (yield* fresh(session)) return value$2(session.access);
109255
109323
  const renewed = yield* result$1(asAuthError("AI access is temporarily unavailable")(refreshed(session.idHash)));
109256
- if (renewed._tag === "Success") return value$2(renewed.success.access);
109324
+ if (isSuccess$1(renewed)) return value$2(renewed.success.access);
109257
109325
  if (is$2(AuthError)(renewed.failure) && renewed.failure.error === "temporarily_unavailable") return yield* renewed.failure;
109258
109326
  }
109259
109327
  const now$3 = yield* now;
@@ -109327,7 +109395,7 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/server/auth") {
109327
109395
  issuer: new URL(ISSUER_PATH, issuer).href,
109328
109396
  typ: "at+jwt"
109329
109397
  }), provideService$2(Jwks, jwks), provideService$2(Signature, signature), mapError$2((cause) => {
109330
- if (isJoseError(cause) && cause.reason._tag === "KeySetUnavailable") return AuthError.make({
109398
+ if (isJoseError(cause) && cause.reason instanceof KeySetUnavailable) return AuthError.make({
109331
109399
  cause,
109332
109400
  error: "temporarily_unavailable",
109333
109401
  message: "The authorization service is temporarily unavailable"
@@ -110762,8 +110830,8 @@ const installService = fnUntraced(function* (name, command, options) {
110762
110830
  yield* systemctl("daemon-reload");
110763
110831
  yield* systemctl("enable", unit);
110764
110832
  yield* systemctl(match(options?.restart === false, {
110765
- onFalse: () => "restart",
110766
- onTrue: () => "start"
110833
+ onFalse: constant("restart"),
110834
+ onTrue: constant("start")
110767
110835
  }), unit);
110768
110836
  return `${unit} installed\n`;
110769
110837
  });
@@ -110872,7 +110940,7 @@ function layerSignIn(issuer) {
110872
110940
  const started = yield* result$1(gen(function* () {
110873
110941
  const params = yield* schemaSearchParams(CallbackParams);
110874
110942
  if (!contains$1(params.state, saved.state)) return yield* AuthError.make({ message: "The sign-in began in another browser" });
110875
- if (isSome(params.error) || isNone(params.code)) return yield* AuthError.make({ message: `Auth answered ${getOrElse$1(params.error, () => "without a code")}` });
110943
+ if (isSome(params.error) || isNone(params.code)) return yield* AuthError.make({ message: `Auth answered ${getOrElse$1(params.error, constant("without a code"))}` });
110876
110944
  if (!contains$1(params.iss, new URL("/api/auth", issuer).href)) return yield* AuthError.make({ message: "The answer came from another issuer" });
110877
110945
  return yield* sessions.start({
110878
110946
  client_id: yield* clientId,
@@ -111083,7 +111151,7 @@ const CpuTime$1 = Struct$2({
111083
111151
  });
111084
111152
  const TextFromEmpty = pipe(String$6, decodeTo(Option(String$6), {
111085
111153
  decode: transform$4((value) => liftPredicate(value, isNonEmpty$1)),
111086
- encode: transform$4((value) => getOrElse$1(value, () => ""))
111154
+ encode: transform$4((value) => getOrElse$1(value, constant("")))
111087
111155
  }));
111088
111156
  const OptionalTextFromEmpty = pipe(OptionFromOptionalKey(String$6), decodeTo(Option(String$6), {
111089
111157
  decode: transform$4((value) => filter$7(value, isNonEmpty$1)),
@@ -111659,23 +111727,23 @@ function failureReason(result, status, ran) {
111659
111727
  return pipe(value(result), when("exit-code", () => match$7(fromUndefinedOr(SIGNALS[status - 128]), {
111660
111728
  onNone: () => `Exited with code ${status}`,
111661
111729
  onSome: (name) => `Exited with code ${status} (${name})`
111662
- })), when("signal", () => `Killed by ${signal}`), when("core-dump", () => `Crashed with ${signal}`), when("oom-kill", () => "Killed for running out of memory"), when("timeout", () => "Timed out"), when("watchdog", () => "Stopped answering its watchdog"), when("start-limit-hit", () => "Restarted too often"), orElse(() => `Failed: ${result}`));
111730
+ })), when("signal", () => `Killed by ${signal}`), when("core-dump", () => `Crashed with ${signal}`), when("oom-kill", constant("Killed for running out of memory")), when("timeout", constant("Timed out")), when("watchdog", constant("Stopped answering its watchdog")), when("start-limit-hit", constant("Restarted too often")), orElse(() => `Failed: ${result}`));
111663
111731
  }
111664
111732
  function exitFailure(status) {
111665
111733
  if (status < 0) return failureReason("signal", -status, true);
111666
111734
  return failureReason("exit-code", status, true);
111667
111735
  }
111668
111736
  function unitFailures(text) {
111669
- return fromEntries(pipe(trim(text), split$2(/\n\s*\n/u), filter$5(isNonEmpty$1), map$10((block) => {
111670
- const fields = fromEntries(pipe(block, split$2("\n"), filter$5(includes("=")), map$10((line) => {
111737
+ return pipe(trim(text), split$2(/\n\s*\n/u), filter$5(isNonEmpty$1), fromIterableWith((block) => {
111738
+ const fields = pipe(block, split$2("\n"), filter$5(includes("=")), fromIterableWith((line) => {
111671
111739
  const [key, ...value] = split$2(line, "=");
111672
111740
  return [key, join$4(value, "=")];
111673
- })));
111741
+ }));
111674
111742
  return [UnitId.make(fields["Id"] ?? ""), {
111675
111743
  at: map$13(parse$3(replace(/^@/u, "")(fields["StateChangeTimestamp"] ?? "")), (seconds) => mapEpochMillis(makeUnsafe$5(0), () => seconds * 1e3)),
111676
- reason: failureReason(fields["Result"] ?? "", getOrElse$1(parse$3(fields["ExecMainStatus"] ?? ""), () => 0), fields["ExecMainCode"] !== "0")
111744
+ reason: failureReason(fields["Result"] ?? "", getOrElse$1(parse$3(fields["ExecMainStatus"] ?? ""), constant(0)), fields["ExecMainCode"] !== "0")
111677
111745
  }];
111678
- })));
111746
+ }));
111679
111747
  }
111680
111748
  // src/services/inventory/lib/launchd.ts
111681
111749
  const launchAgents = fnUntraced(function* (text) {
@@ -111766,12 +111834,12 @@ function flagParts(token) {
111766
111834
  });
111767
111835
  }
111768
111836
  function alias(value$4) {
111769
- return pipe(value(value$4), when("vite-plus", () => "vp"), orElse(() => value$4));
111837
+ return pipe(value(value$4), when("vite-plus", constant("vp")), orElse(() => value$4));
111770
111838
  }
111771
111839
  function shellRest(tokens) {
111772
- const script = pipe(tokens, get$11(2), getOrElse$1(() => ""));
111840
+ const script = pipe(tokens, get$11(2), getOrElse$1(constant("")));
111773
111841
  const shifts = match$7(match$2(/\bshift\b/gu)(script), {
111774
- onNone: () => 0,
111842
+ onNone: constant(0),
111775
111843
  onSome: (matches) => matches.length
111776
111844
  });
111777
111845
  if (includes("exec \"$@\"")(script)) return drop$1(tokens, 4 + shifts);
@@ -111779,7 +111847,7 @@ function shellRest(tokens) {
111779
111847
  return pipe(findFirst(segments, (words) => words[0] === "exec"), map$13((words) => drop$1(words, 1)), orElse$3(() => findFirst(segments, (words) => !contains(SETUP, words[0] ?? ""))), getOrElse$1(() => take$3(tokens, 1)));
111780
111848
  }
111781
111849
  function unwrapTokens(tokens, cwd) {
111782
- const name = basename(getOrElse$1(head(tokens), () => ""));
111850
+ const name = basename(getOrElse$1(head(tokens), constant("")));
111783
111851
  if (contains(WRAPPERS, name)) return unwrapTokens(pipe(findFirstIndex(tokens, (token) => token === "--"), filter$7((index) => index > 0), match$7({
111784
111852
  onNone: () => {
111785
111853
  const tail = drop$1(tokens, 1);
@@ -111790,11 +111858,11 @@ function unwrapTokens(tokens, cwd) {
111790
111858
  },
111791
111859
  onSome: (index) => drop$1(tokens, index + 1)
111792
111860
  })), cwd);
111793
- if (contains(SHELLS, name) && pipe(tokens, get$11(1), getOrElse$1(() => "")) === "-c") return unwrapTokens(shellRest(tokens), cwd);
111861
+ if (contains(SHELLS, name) && pipe(tokens, get$11(1), getOrElse$1(constant(""))) === "-c") return unwrapTokens(shellRest(tokens), cwd);
111794
111862
  if (contains(RUNTIMES, name)) return pipe(tokens, findFirstIndex((token, index) => index > 0 && !isFlag(token)), match$7({
111795
111863
  onNone: () => tokens,
111796
111864
  onSome: (index) => {
111797
- const script = pipe(tokens, get$11(index), getOrElse$1(() => ""));
111865
+ const script = pipe(tokens, get$11(index), getOrElse$1(constant("")));
111798
111866
  const pkg = capture(/.*node_modules\/((?:@[^/]+\/)?[^/.][^/]*)\//u, script);
111799
111867
  const app = orElse$3(capture(/\.deslop\/([^/]+)\//u, script), () => flatMap$8(cwd, (value) => capture(/\/apps\/([^/]+)$/u, value)));
111800
111868
  return [pipe(pkg, orElse$3(() => app), getOrElse$1(() => basename(script))), ...drop$1(tokens, index + 1)];
@@ -111805,9 +111873,9 @@ function unwrapTokens(tokens, cwd) {
111805
111873
  function unwrap(argv, cwd) {
111806
111874
  const tokens = match(length$2(argv) === 1, {
111807
111875
  onFalse: () => argv,
111808
- onTrue: () => pipe(head(argv), getOrElse$1(() => ""), split$2(/\s+/u), filter$5(isNonEmpty$1))
111876
+ onTrue: () => pipe(head(argv), getOrElse$1(constant("")), split$2(/\s+/u), filter$5(isNonEmpty$1))
111809
111877
  });
111810
- return unwrapTokens([replace(/:$/u, "")(getOrElse$1(head(tokens), () => "")), ...drop$1(tokens, 1)], cwd);
111878
+ return unwrapTokens([replace(/:$/u, "")(getOrElse$1(head(tokens), constant(""))), ...drop$1(tokens, 1)], cwd);
111811
111879
  }
111812
111880
  function scan(name, subject, args, words, values) {
111813
111881
  return match$7(head(args), {
@@ -111858,7 +111926,7 @@ function commandLabel(argv, cwd) {
111858
111926
  const subject = pipe(SUBJECT, get$12(name), getOrElse$1(() => empty$15()));
111859
111927
  const scanned = scan(name, subject, args, [], {});
111860
111928
  if (contains(SHELLS, name) && isReadonlyArrayEmpty(scanned.words)) return {
111861
- detail: pipe(cwd, map$13(basename), getOrElse$1(() => "")),
111929
+ detail: pipe(cwd, map$13(basename), getOrElse$1(constant(""))),
111862
111930
  name
111863
111931
  };
111864
111932
  return match$7(scanned.ssh, {
@@ -111870,7 +111938,7 @@ function commandLabel(argv, cwd) {
111870
111938
  const remote = commandLabel(ssh.remote, none());
111871
111939
  return {
111872
111940
  detail: pipe([ssh.host, match(isNonEmpty$1(remote.name), {
111873
- onFalse: () => "",
111941
+ onFalse: constant(""),
111874
111942
  onTrue: () => `→ ${remote.name}`
111875
111943
  })], filter$5(isNonEmpty$1), join$4(" ")),
111876
111944
  name
@@ -111889,8 +111957,8 @@ function processOwner(cgroup) {
111889
111957
  const service = findLastIndex(segments, endsWith(".service"));
111890
111958
  const userService = findFirstIndex(segments, (segment) => isSome(match$2(/^user@[0-9]+\.service$/u)(segment)));
111891
111959
  return pipe(userService, filter$7((index) => !exists(service, (last) => last > index)), flatMap$8((index) => pipe(segments, drop$1(index + 1), findFirst((segment) => match$2(/^app-(.+)\.slice$/u)(segment)))), map$13((match) => AppId.make(`service:user:${match[1]}.service`)), orElse$3(() => map$13(service, (index) => AppId.make(`service:${pipe(userService, exists((first) => index > first), match({
111892
- onFalse: () => "system",
111893
- onTrue: () => "user"
111960
+ onFalse: constant("system"),
111961
+ onTrue: constant("user")
111894
111962
  }))}:${segments[index]}`))));
111895
111963
  }
111896
111964
  function loopbackPort(item) {
@@ -111912,8 +111980,8 @@ function ports(items) {
111912
111980
  return pipe(items, filter$5((item) => appPort(item) && contains$1(item.http, true)), sort(mapInput(String$10, (item) => `${item.worker}:${getOrUndefined$1(item.port)}:${getOrUndefined$1(item.address)}`)), dedupeWith((a, b) => a.worker === b.worker && makeEquivalence$5((x, y) => x === y)(a.port, b.port)));
111913
111981
  }
111914
111982
  function itemOwner(item) {
111915
- if (item.kind === "container") return AppId.make(`container:${slice$1(0, 12)(getOrElse$1(last$1(split$2(item.id, ":docker:")), () => ""))}`);
111916
- return AppId.make(`service:${getOrElse$1(item.scope, () => "system")}:${item.name}`);
111983
+ if (item.kind === "container") return AppId.make(`container:${slice$1(0, 12)(getOrElse$1(last$1(split$2(item.id, ":docker:")), constant("")))}`);
111984
+ return AppId.make(`service:${getOrElse$1(item.scope, constant("system"))}:${item.name}`);
111917
111985
  }
111918
111986
  function fullName(item) {
111919
111987
  if (item.kind === "port") return getOrElse$1(item.process, () => item.name);
@@ -111943,7 +112011,7 @@ function socket(worker, binding) {
111943
112011
  function workloads(items) {
111944
112012
  const listeners = filter$5(items, (item) => item.kind === "port");
111945
112013
  const byUnit = pipe(listeners, groupBy((listener) => listener.worker), map$11((worker) => groupBy(worker, (listener) => match$7(listener.unit, {
111946
- onNone: () => "none",
112014
+ onNone: constant("none"),
111947
112015
  onSome: (unit) => `unit:${unit}`
111948
112016
  }))));
111949
112017
  const bySocket = fromIterable$5(map$10(reverse(filter$5(listeners, (listener) => !contains$1(listener.address, "container"))), (listener) => [socket(listener.worker, listener), listener]));
@@ -111986,7 +112054,7 @@ function workloads(items) {
111986
112054
  const exposuresBySocket = pipe(exposures, map$10((item, index) => ({
111987
112055
  index,
111988
112056
  item
111989
- })), groupBy((entry) => `${entry.item.worker}:${getOrElse$1(entry.item.port, () => 0)}`));
112057
+ })), groupBy((entry) => `${entry.item.worker}:${getOrElse$1(entry.item.port, constant(0))}`));
111990
112058
  const linked = map$10(rows, (row) => {
111991
112059
  const reachable = dedupe(pipe(row.listeners, filter$5((listener) => exists(listener.port, (port) => sameSocket(listener, {
111992
112060
  address: `127.0.0.1:${port}`,
@@ -112025,10 +112093,6 @@ function workloads(items) {
112025
112093
  };
112026
112094
  }));
112027
112095
  }
112028
- new Intl.RelativeTimeFormat("en", {
112029
- numeric: "auto",
112030
- style: "narrow"
112031
- });
112032
112096
  function status(item) {
112033
112097
  if (item.kind === "port") return "listening";
112034
112098
  if (item.kind === "exposure" && contains$1(item.owned, true)) return "configured";
@@ -112067,11 +112131,11 @@ function fold(node) {
112067
112131
  }
112068
112132
  function processTree(rows) {
112069
112133
  const pids = fromIterable(map$10(rows, (row) => row.pid));
112070
- const children = reduce(rows, empty$11(), (all, row) => set$3(all, row.parent, [...pipe(all, get$8(row.parent), getOrElse$1(empty$15)), row]));
112134
+ const children = groupBy(rows, (row) => String$9(row.parent));
112071
112135
  const visited = empty$5();
112072
112136
  function build(row) {
112073
112137
  add$1(visited, row.pid);
112074
- const below = pipe(children, get$8(row.pid), getOrElse$1(empty$15), filter$5((child) => !has(visited, child.pid)), map$10(build));
112138
+ const below = pipe(get$12(children, `${row.pid}`), getOrElse$1(empty$15), filter$5((child) => !has(visited, child.pid)), map$10(build));
112075
112139
  const self = {
112076
112140
  children: [],
112077
112141
  command: row.command,
@@ -112151,8 +112215,8 @@ function appOf(row, withProcesses) {
112151
112215
  function exposureOf(item) {
112152
112216
  return {
112153
112217
  access: pipe(item.publicAccess, contains$1(true), match({
112154
- onFalse: () => "tailnet",
112155
- onTrue: () => "public"
112218
+ onFalse: constant("tailnet"),
112219
+ onTrue: constant("public")
112156
112220
  })),
112157
112221
  id: item.id,
112158
112222
  name: ExposureName.make(item.name),
@@ -112204,12 +112268,12 @@ function listApps(snapshot, input) {
112204
112268
  }
112205
112269
  function ownerNames(snapshot) {
112206
112270
  const byWorker = groupBy(snapshot.items, (item) => item.worker);
112207
- return fromEntries(map$10(workerNames(snapshot), (worker) => [worker, fromEntries(pipe(byWorker[worker] ?? empty$15(), filter$5((item) => item.kind === "service" || item.kind === "container"), flatMap$6((item) => [[itemOwner(item), workloadName(item)]])))]));
112271
+ return fromIterableWith(workerNames(snapshot), (worker) => [worker, pipe(byWorker[worker] ?? empty$15(), filter$5((item) => item.kind === "service" || item.kind === "container"), fromIterableWith((item) => [itemOwner(item), workloadName(item)]))]);
112208
112272
  }
112209
112273
  function requestOf(item) {
112210
112274
  return {
112211
112275
  name: UnitId.make(item.name),
112212
- scope: getOrElse$1(item.scope, () => "system"),
112276
+ scope: getOrElse$1(item.scope, constant("system")),
112213
112277
  worker: item.worker
112214
112278
  };
112215
112279
  }
@@ -112223,10 +112287,10 @@ const jobRequest = fnUntraced(function* (snapshot, input) {
112223
112287
  const SECRET = /(?:token|secret|passw(?:or)?d|key|auth|credential|cookie|session)/iu;
112224
112288
  const PROCESS_INTERVAL = seconds(2);
112225
112289
  function processStatus(status) {
112226
- const values = fromEntries(pipe(trim(status), split$2("\n"), map$10((line) => {
112290
+ const values = pipe(trim(status), split$2("\n"), fromIterableWith((line) => {
112227
112291
  const at = getOrThrow$1(indexOf(":")(line));
112228
112292
  return [slice$1(0, at)(line), trim(slice$1(at + 1)(line))];
112229
- })));
112293
+ }));
112230
112294
  return {
112231
112295
  memory: decodeSync(ResidentMemoryFromKiB)(split$2(values["VmRSS"] ?? "", /\s+/u)[0] || "0"),
112232
112296
  name: values["Name"] ?? "",
@@ -112336,7 +112400,7 @@ function launchdProcesses(text, agents) {
112336
112400
  1: match[1],
112337
112401
  2: match[2] ?? "",
112338
112402
  3: match[3] ?? ""
112339
- })), map$13((fields) => pipe(hours(getOrElse$1(fields[1], () => 0)), sum(minutes(fields[2])), sum(seconds(fields[3])))), filter$7(isFinite$1))
112403
+ })), map$13((fields) => pipe(hours(getOrElse$1(fields[1], constant(0))), sum(minutes(fields[2])), sum(seconds(fields[3])))), filter$7(isFinite$1))
112340
112404
  }), (times) => {
112341
112405
  const command = commandArgs(pipe(trim(row.args), split$2(/\s+/u), join$4("\0")));
112342
112406
  return {
@@ -112346,7 +112410,7 @@ function launchdProcesses(text, agents) {
112346
112410
  cpu: none(),
112347
112411
  label: commandLabel(command, none()),
112348
112412
  memory: row.memory,
112349
- name: pipe(head(command), flatMap$8((head) => last$1(split$2(head, "/"))), getOrElse$1(() => "")),
112413
+ name: pipe(head(command), flatMap$8((head) => last$1(split$2(head, "/"))), getOrElse$1(constant(""))),
112350
112414
  parent: row.parent,
112351
112415
  pid: row.pid
112352
112416
  }),
@@ -112390,8 +112454,8 @@ function socketLine(line) {
112390
112454
  function lsofSocket(file) {
112391
112455
  if (includes("->")(file.address) || !contains(["TCP", "UDP"], file.protocol)) return none();
112392
112456
  const address = replace(/^\*:/u, match(file.type === "IPv4", {
112393
- onFalse: () => "*:",
112394
- onTrue: () => "0.0.0.0:"
112457
+ onFalse: constant("*:"),
112458
+ onTrue: constant("0.0.0.0:")
112395
112459
  }))(file.address);
112396
112460
  return flatMap$8(file.pid, (pid) => map$13(portOf(address), (port) => ({
112397
112461
  address,
@@ -112402,7 +112466,7 @@ function lsofSocket(file) {
112402
112466
  }),
112403
112467
  protocol: toLowerCase(file.protocol),
112404
112468
  state: match(file.protocol === "TCP", {
112405
- onFalse: () => "UNCONN",
112469
+ onFalse: constant("UNCONN"),
112406
112470
  onTrue: () => replace(/^ST=/u, "")(file.state) || "LISTEN"
112407
112471
  })
112408
112472
  })));
@@ -112505,7 +112569,7 @@ function portItems(sockets, worker, http, origin) {
112505
112569
  }), liftPredicate(isNonEmpty$1));
112506
112570
  })
112507
112571
  });
112508
- const response = yield* match(probeSocket(socket, getOrElse$1(process, () => "")), {
112572
+ const response = yield* match(probeSocket(socket, getOrElse$1(process, constant(""))), {
112509
112573
  onFalse: () => succeed$5(none()),
112510
112574
  onTrue: fnUntraced(function* () {
112511
112575
  return yield* pipe(http.head(`http://127.0.0.1:${socket.port}/`, { headers: toHeaders(new NativeSpan({
@@ -112524,7 +112588,7 @@ function portItems(sockets, worker, http, origin) {
112524
112588
  });
112525
112589
  return InventoryItem.make({
112526
112590
  address: some$1(socket.address),
112527
- detail: `${socket.address} · ${getOrElse$1(process, () => "process unavailable")}`,
112591
+ detail: `${socket.address} · ${getOrElse$1(process, constant("process unavailable"))}`,
112528
112592
  http: some$1(exists(response, (value) => value.http)),
112529
112593
  id: ItemId.make(`${worker}:port:${socket.protocol}:${socket.address}`),
112530
112594
  kind: "port",
@@ -112532,8 +112596,8 @@ function portItems(sockets, worker, http, origin) {
112532
112596
  port: some$1(socket.port),
112533
112597
  process,
112534
112598
  protocol: some$1(match(socket.protocol === "udp", {
112535
- onFalse: () => "tcp",
112536
- onTrue: () => "udp"
112599
+ onFalse: constant("tcp"),
112600
+ onTrue: constant("udp")
112537
112601
  })),
112538
112602
  state: socket.state,
112539
112603
  ui: some$1(exists(response, (value) => value.ui)),
@@ -112577,8 +112641,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112577
112641
  const processState = yield* make$54(none());
112578
112642
  const units = fnUntraced(function* (system) {
112579
112643
  const scope = match(system, {
112580
- onFalse: () => "user",
112581
- onTrue: () => "system"
112644
+ onFalse: constant("user"),
112645
+ onTrue: constant("system")
112582
112646
  });
112583
112647
  const scopeFlags = match(system, {
112584
112648
  onFalse: () => ["--user"],
@@ -112613,8 +112677,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112613
112677
  detail: `${scope} · ${row.description}`,
112614
112678
  failure: get$12(failures, row.unit),
112615
112679
  health: match(row.active === "failed", {
112616
- onFalse: () => "quiet",
112617
- onTrue: () => "error"
112680
+ onFalse: constant("quiet"),
112681
+ onTrue: constant("error")
112618
112682
  }),
112619
112683
  id: ItemId.make(`${worker}:${scope}:${row.unit}`),
112620
112684
  kind: "service",
@@ -112642,33 +112706,33 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112642
112706
  "restarting",
112643
112707
  "paused"
112644
112708
  ], row.State),
112645
- bindings: some$1([...map$10(fromIterable$8(matchAll(/traefik\.http\.services\.[^=,]+\.loadbalancer\.server\.port=([0-9]+)/gu)(getOrElse$1(row.Labels, () => ""))), (match) => ({
112709
+ bindings: some$1([...map$10(fromIterable$8(matchAll(/traefik\.http\.services\.[^=,]+\.loadbalancer\.server\.port=([0-9]+)/gu)(getOrElse$1(row.Labels, constant("")))), (match) => ({
112646
112710
  address: "container",
112647
- port: getOrElse$1(parse$3(match[1] ?? ""), () => 0),
112711
+ port: getOrElse$1(parse$3(match[1] ?? ""), constant(0)),
112648
112712
  protocol: "tcp"
112649
112713
  })), ...map$10(fromIterable$8(matchAll(/((?:[0-9.]+|\[::\])):([0-9]+)->[0-9]+\/(tcp|udp)/gu)(row.Ports)), (match$8) => ({
112650
112714
  address: `${match$8[1]}:${match$8[2]}`,
112651
- port: getOrElse$1(parse$3(match$8[2] ?? ""), () => 0),
112715
+ port: getOrElse$1(parse$3(match$8[2] ?? ""), constant(0)),
112652
112716
  protocol: match(match$8[3] === "udp", {
112653
- onFalse: () => "tcp",
112654
- onTrue: () => "udp"
112717
+ onFalse: constant("tcp"),
112718
+ onTrue: constant("udp")
112655
112719
  })
112656
112720
  }))]),
112657
112721
  detail: row.Status,
112658
112722
  health: match(includes("unhealthy")(row.Status) || isSome(match$2(/Exited \([1-9]/u)(row.Status)), {
112659
112723
  onFalse: () => match(row.State === "restarting", {
112660
- onFalse: () => "quiet",
112661
- onTrue: () => "warning"
112724
+ onFalse: constant("quiet"),
112725
+ onTrue: constant("warning")
112662
112726
  }),
112663
- onTrue: () => "error"
112727
+ onTrue: constant("error")
112664
112728
  }),
112665
112729
  id: ItemId.make(`${worker}:docker:${row.ID}`),
112666
112730
  kind: "container",
112667
- links: some$1(dedupe(map$10(fromIterable$8(matchAll(/Host\(`([^`]+)`\)/gu)(getOrElse$1(row.Labels, () => ""))), (match) => `https://${match[1]}`))),
112731
+ links: some$1(dedupe(map$10(fromIterable$8(matchAll(/Host\(`([^`]+)`\)/gu)(getOrElse$1(row.Labels, constant("")))), (match) => `https://${match[1]}`))),
112668
112732
  name: row.Names,
112669
112733
  state: match(includes("unhealthy")(row.Status), {
112670
112734
  onFalse: () => row.State,
112671
- onTrue: () => "unhealthy"
112735
+ onTrue: constant("unhealthy")
112672
112736
  }),
112673
112737
  url: none(),
112674
112738
  worker
@@ -112684,7 +112748,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112684
112748
  collect("Docker", docker),
112685
112749
  collect("Listening ports", flatMap$3(command("ss", ["-H", "-lntup"]), (text) => portItems(getSomes(pipe(trim(text), split$2("\n"), map$10(socketLine))), worker, http, {
112686
112750
  cwd: (processId) => option$1(fs.readLink(`/proc/${processId}/cwd`)),
112687
- unit: (processId) => map$7(option$1(fs.readFileString(`/proc/${processId}/cgroup`)), (cgroup) => socketUnit(getOrElse$1(cgroup, () => "")))
112751
+ unit: (processId) => map$7(option$1(fs.readFileString(`/proc/${processId}/cgroup`)), (cgroup) => socketUnit(getOrElse$1(cgroup, constant(""))))
112688
112752
  })))
112689
112753
  ]
112690
112754
  });
@@ -112720,8 +112784,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112720
112784
  reason: exitFailure(status)
112721
112785
  }))),
112722
112786
  health: match(isNone(agent.pid) && agent.status !== 0, {
112723
- onFalse: () => "quiet",
112724
- onTrue: () => "error"
112787
+ onFalse: constant("quiet"),
112788
+ onTrue: constant("error")
112725
112789
  }),
112726
112790
  id: ItemId.make(`${worker}:user:${agent.label}`),
112727
112791
  kind: "service",
@@ -112730,10 +112794,10 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112730
112794
  scope: some$1("user"),
112731
112795
  state: match$7(agent.pid, {
112732
112796
  onNone: () => match(agent.status === 0, {
112733
- onFalse: () => "failed · failed",
112734
- onTrue: () => "inactive · dead"
112797
+ onFalse: constant("failed · failed"),
112798
+ onTrue: constant("inactive · dead")
112735
112799
  }),
112736
- onSome: () => "running"
112800
+ onSome: constant("running")
112737
112801
  }),
112738
112802
  url: none(),
112739
112803
  worker
@@ -112755,7 +112819,7 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112755
112819
  "-d",
112756
112820
  "cwd",
112757
112821
  "-Fn"
112758
- ])), getOrElse$1(() => ""), split$2("\n"), findFirst(startsWith("n")), map$13(slice$1(1)));
112822
+ ])), getOrElse$1(constant("")), split$2("\n"), findFirst(startsWith("n")), map$13(slice$1(1)));
112759
112823
  }),
112760
112824
  unit: (processId) => succeed$5(pipe(owned, findFirst((record) => record.process.pid === processId), map$13((record) => record.unit)))
112761
112825
  })))]
@@ -112815,8 +112879,8 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112815
112879
  name: peer.HostName,
112816
112880
  self: some$1(true),
112817
112881
  state: match(peer.Online, {
112818
- onFalse: () => "offline",
112819
- onTrue: () => "online"
112882
+ onFalse: constant("offline"),
112883
+ onTrue: constant("online")
112820
112884
  }),
112821
112885
  url: none(),
112822
112886
  worker
@@ -112827,12 +112891,12 @@ var Inventory = class extends Service$1()("@deslop/deploy/services/inventory/ser
112827
112891
  "--json"
112828
112892
  ]), flatMap$3(decodeEffect(fromJsonString(Serve))), map$7((status) => flatMap$6(toEntries(getOrElse$1(status.Web, () => ({}))), (site) => map$10(toEntries(site[1].Handlers), (handler) => InventoryItem.make({
112829
112893
  detail: `${pipe(status.AllowFunnel, exists((permissions) => permissions[site[0]] === true), match({
112830
- onFalse: () => "tailnet",
112831
- onTrue: () => "Funnel permitted (public)"
112832
- }))} → ${getOrElse$1(handler[1].Proxy, () => "non-proxy handler")}`,
112894
+ onFalse: constant("tailnet"),
112895
+ onTrue: constant("Funnel permitted (public)")
112896
+ }))} → ${getOrElse$1(handler[1].Proxy, constant("non-proxy handler"))}`,
112833
112897
  health: pipe(status.AllowFunnel, exists((permissions) => permissions[site[0]] === true), match({
112834
- onFalse: () => "quiet",
112835
- onTrue: () => "warning"
112898
+ onFalse: constant("quiet"),
112899
+ onTrue: constant("warning")
112836
112900
  })),
112837
112901
  id: ItemId.make(`${worker}:tailscale:${site[0]}:${handler[0]}`),
112838
112902
  kind: "exposure",
@@ -112890,7 +112954,7 @@ const SERIES = {
112890
112954
  10080: hours(1)
112891
112955
  };
112892
112956
  function counters(stat, uptime, time) {
112893
- const values = decodeSync(CpuCounters)(pipe(stat, split$2("\n"), head, getOrElse$1(() => ""), trim, split$2(/\s+/u), drop$1(1), take$3(8)));
112957
+ const values = decodeSync(CpuCounters)(pipe(stat, split$2("\n"), head, getOrElse$1(constant("")), trim, split$2(/\s+/u), drop$1(1), take$3(8)));
112894
112958
  return {
112895
112959
  cpuIdle: millis$1(((values[3] ?? 0) + (values[4] ?? 0)) * 10),
112896
112960
  cpuTotal: millis$1(sumAll(values) * 10),
@@ -112919,7 +112983,7 @@ function cpuCounters(cpus, uptime, time) {
112919
112983
  }
112920
112984
  function vmStatMemory(text, total) {
112921
112985
  const pages = fromEntries(getSomes(pipe(text, split$2("\n"), map$10((line) => map$13(match$2(/^"?([^":]+)"?:\s+([0-9]+)\.$/u)(trim(line)), (match) => [match[1] ?? "", match[2] ?? ""])))));
112922
- const page = decodeSync(FiniteFromString)(pipe(match$2(/page size of ([0-9]+) bytes/u)(text), map$13((match) => match[1] ?? ""), getOrElse$1(() => "")));
112986
+ const page = decodeSync(FiniteFromString)(pipe(match$2(/page size of ([0-9]+) bytes/u)(text), map$13((match) => match[1] ?? ""), getOrElse$1(constant(""))));
112923
112987
  function count(name) {
112924
112988
  return decodeSync(FiniteFromString)(pages[name] ?? "");
112925
112989
  }
@@ -112972,10 +113036,10 @@ function reading(current, memory, disks, load, previous) {
112972
113036
  };
112973
113037
  }
112974
113038
  function sample(current, memory, disk, previous, load) {
112975
- const values = fromEntries(pipe(trim(memory), split$2("\n"), map$10((line) => {
113039
+ const values = pipe(trim(memory), split$2("\n"), fromIterableWith((line) => {
112976
113040
  const fields = split$2(line, /\s+/u);
112977
113041
  return [fields[0], decodeSync(FiniteFromString)(fields[1] ?? "") * 1024];
112978
- })));
113042
+ }));
112979
113043
  return reading(current, {
112980
113044
  total: values["MemTotal:"] ?? 0,
112981
113045
  used: (values["MemTotal:"] ?? 0) - (values["MemAvailable:"] ?? 0)
@@ -112986,7 +113050,7 @@ function sample(current, memory, disk, previous, load) {
112986
113050
  mount: fields[0],
112987
113051
  total: decodeSync(FiniteFromString)(fields[1] ?? ""),
112988
113052
  used: decodeSync(FiniteFromString)(fields[2] ?? "")
112989
- }))), decodeSync(LoadAverages)(pipe(getOrElse$1(load, () => ""), trim, split$2(/\s+/u), filter$5(isNonEmpty$1), take$3(3))), previous);
113053
+ }))), decodeSync(LoadAverages)(pipe(getOrElse$1(load, constant("")), trim, split$2(/\s+/u), filter$5(isNonEmpty$1), take$3(3))), previous);
112990
113054
  }
112991
113055
  function resolution(range) {
112992
113056
  return divideUnsafe(range, 60);
@@ -113010,7 +113074,7 @@ function mean(bucket, read) {
113010
113074
  function merge(bucket) {
113011
113075
  if (bucket.length === 1) return bucket[0];
113012
113076
  const reported = filter$5(bucket, (point) => isSome(point.apps));
113013
- const appsById = map$10(reported, (point) => fromEntries(pipe(point.apps, getOrElse$1(empty$15), map$10((app) => [app.id, app]))));
113077
+ const appsById = map$10(reported, (point) => pipe(point.apps, getOrElse$1(empty$15), fromIterableBy((app) => app.id)));
113014
113078
  function appMean(id, read) {
113015
113079
  return mean(reported, (_point, index) => match$7(fromUndefinedOr(appsById[index]?.[id]), {
113016
113080
  onNone: () => some$1(0),
@@ -113029,7 +113093,7 @@ function merge(bucket) {
113029
113093
  onNonEmpty: () => some$1(map$10(dedupe(flatMap$6(reported, (point) => pipe(point.apps, getOrElse$1(empty$15), map$10((app) => app.id)))), (id) => ({
113030
113094
  cpu: appMean(id, (app) => app.cpu),
113031
113095
  id,
113032
- memory: pipe(appMean(id, (app) => some$1(app.memory)), getOrElse$1(() => 0), round(0))
113096
+ memory: pipe(appMean(id, (app) => some$1(app.memory)), getOrElse$1(constant(0)), round(0))
113033
113097
  })))
113034
113098
  }),
113035
113099
  cpu: mean(bucket, (point) => point.cpu),
@@ -113071,7 +113135,7 @@ function bandName(id, labels) {
113071
113135
  return pipe(labels, get$12(id), getOrElse$1(() => replaceAll(/^service:[a-z]+:(?:deslop-)?|\.service$/gu, "")(replace(/^container:/u, "container ")(id))));
113072
113136
  }
113073
113137
  function appCgroup(path, siblings) {
113074
- const name = getOrElse$1(last$1(split$2(path, "/")), () => "");
113138
+ const name = getOrElse$1(last$1(split$2(path, "/")), constant(""));
113075
113139
  if (isSome(match$2(/^docker-[a-f0-9]{12,64}\.scope$/u)(name))) return true;
113076
113140
  if (endsWith(".service")(name)) return isNone(match$2(/^user@[0-9]+\.service$/u)(name));
113077
113141
  return exists(match$2(/\/user@[0-9]+\.service\/app\.slice\/app-([^/]+)\.slice$/u)(path), (match) => contains(siblings, `${match[1]}.service`));
@@ -113122,10 +113186,10 @@ function diskTotal(machine) {
113122
113186
  function series(machine, minutes, read) {
113123
113187
  const start = chartWindow(minutes, machine.time).start;
113124
113188
  const slot = resolution(minutes);
113125
- const bySlot = fromEntries(map$10(machine.samples, (point) => [`${clamp(Math.ceil(toMillis(distance(start, point.time)) / toMillis(slot)) - 1, {
113189
+ const bySlot = fromIterableWith(machine.samples, (point) => [`${clamp(Math.ceil(toMillis(distance(start, point.time)) / toMillis(slot)) - 1, {
113126
113190
  maximum: 59,
113127
113191
  minimum: 0
113128
- })}`, point]));
113192
+ })}`, point]);
113129
113193
  return makeBy(60, (index) => pipe(fromUndefinedOr(bySlot[`${index}`]), flatMap$8(read), map$13((value) => round(value, 1))));
113130
113194
  }
113131
113195
  function appsOf(labels, latest) {
@@ -113251,7 +113315,7 @@ var Metrics = class extends Service$1()("@deslop/deploy/services/metrics/service
113251
113315
  cpu: fs.readFileString(`${CGROUP}${path}/cpu.stat`),
113252
113316
  memory: fs.readFileString(`${CGROUP}${path}/memory.stat`)
113253
113317
  }, { concurrency: "unbounded" }), catchTag("PlatformError", (cause) => {
113254
- if (cause.reason._tag === "NotFound") return undefined_$1;
113318
+ if (isTagged(cause.reason, "NotFound")) return undefined_$1;
113255
113319
  return fail$7(cause);
113256
113320
  }), flatMap$3((stats) => {
113257
113321
  if (stats === void 0) return succeedNone;
@@ -113470,8 +113534,8 @@ var Fleet = class Fleet extends Service$1()("@deslop/deploy/services/fleet/servi
113470
113534
  const clients = yield* forEach$1(workers, (worker) => gen(function* () {
113471
113535
  const url = new URL(RPC_PATH, worker.url);
113472
113536
  url.protocol = match(new URL(worker.url).protocol === "http:", {
113473
- onFalse: () => "wss:",
113474
- onTrue: () => "ws:"
113537
+ onFalse: constant("wss:"),
113538
+ onTrue: constant("ws:")
113475
113539
  });
113476
113540
  const protocol = yield* build(pipe(layerProtocolSocket({ pingTimeout: seconds(15) }), provide$2(layerWebSocket(url.href)), provide$2(layerSchemaBinary()), provideMerge(layerRpcStreamClient)));
113477
113541
  return [worker.name, yield* provideContext$2(makeRemoteClient, protocol)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/deploy",
3
- "version": "0.1.1310",
3
+ "version": "0.1.1313",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/MP281X/deslop.git",
@@ -40,5 +40,5 @@
40
40
  "engines": {
41
41
  "node": ">=26"
42
42
  },
43
- "fingerprint": "91b909b317bde5f71dc7e0b0908e9359f04c69716b76e5eddfda4b542c70c97d"
43
+ "fingerprint": "87d978db7e86f8ca327e89848b316b5d61a2c94f639353ae9f26218021222316"
44
44
  }