@deslop/trips 0.1.1223 → 0.1.1228

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 +37 -9
  2. package/package.json +2 -2
package/dist/server.js CHANGED
@@ -92005,6 +92005,8 @@ const SecureOrigin = Origin.check(makeFilter((value) => {
92005
92005
  const Port = String$6.check(isPattern(/^\d{1,5}$/u), makeFilter((value) => exists(parse$2(value), (port) => port >= 1 && port <= 65535), { expected: "a port between 1 and 65535" }));
92006
92006
  const AppVersion = String$6.check(isPattern(/^0\.1\.\d+$/u));
92007
92007
  const RuntimeConfig = Struct({
92008
+ auth: optionalKey(String$6),
92009
+ name: String$6,
92008
92010
  traces: String$6,
92009
92011
  version: AppVersion
92010
92012
  });
@@ -92936,7 +92938,7 @@ function listEvents(lists) {
92936
92938
  }
92937
92939
  const layerProtocol = mergeAll$2(layerSchemaBinary(), succeed$6(MaxBodySize)(mebibytes(10)));
92938
92940
  const layerTelemetry = unwrap$7(gen(function* () {
92939
- const name = yield* appName;
92941
+ const name = (yield* packageMetadata).name;
92940
92942
  return match$8(yield* option(String$5("OTEL_URL")), {
92941
92943
  onNone: () => empty$12,
92942
92944
  onSome: (url) => layerOtlp(`${name}-server`, url, "server")
@@ -92961,10 +92963,17 @@ const layerRoutes = use((router) => gen(function* () {
92961
92963
  })
92962
92964
  });
92963
92965
  });
92964
- yield* router.add("GET", "/api/runtime", flatMap$3(packageMetadata, (metadata) => schemaJson(RuntimeConfig)({
92965
- traces,
92966
- version: metadata.version
92967
- })));
92966
+ yield* router.add("GET", "/api/runtime", gen(function* () {
92967
+ return yield* schemaJson(RuntimeConfig)({
92968
+ ...match$8(issuer, {
92969
+ onNone: () => ({}),
92970
+ onSome: (origin) => ({ auth: origin })
92971
+ }),
92972
+ name: yield* appName,
92973
+ traces,
92974
+ version: (yield* packageMetadata).version
92975
+ });
92976
+ }));
92968
92977
  yield* router.add("GET", "/auth/sign-in", toIssuer({}));
92969
92978
  yield* router.add("GET", "/auth/sign-out", toIssuer({ "sign-out": "" }));
92970
92979
  yield* router.add("GET", "/auth/user", gen(function* () {
@@ -92976,6 +92985,22 @@ const layerRoutes = use((router) => gen(function* () {
92976
92985
  }, { headers: { "cache-control": "no-store" } });
92977
92986
  }));
92978
92987
  }));
92988
+ const layerAnnounce = effectDiscard(gen(function* () {
92989
+ const origin = new URL(yield* String$5("APP_URL")).origin;
92990
+ const client = filterStatusOk(yield* HttpClient);
92991
+ yield* match$8(yield* option(String$5("AUTH_URL")), {
92992
+ onNone: () => void_$1,
92993
+ onSome: fnUntraced(function* (issuer) {
92994
+ yield* pipe(post(new URL("/api/apps", issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
92995
+ schedule: spaced("1 minute"),
92996
+ times: 60
92997
+ }), ignore$1({
92998
+ log: "Warn",
92999
+ message: "Auth did not list this app"
93000
+ }), forkScoped);
93001
+ })
93002
+ });
93003
+ }));
92979
93004
  function layerIcon(icon) {
92980
93005
  return add("GET", "/icon", succeed$5(text$1(icon, {
92981
93006
  contentType: "image/svg+xml",
@@ -93082,17 +93107,20 @@ function systemctl(...args) {
93082
93107
  const unitDirectory = gen(function* () {
93083
93108
  return (yield* Path$1).join(yield* String$5("HOME"), ".config", "systemd", "user");
93084
93109
  });
93085
- const install = fnUntraced(function* (name, command) {
93110
+ const install = fnUntraced(function* (name, command, options) {
93086
93111
  const fs = yield* FileSystem;
93087
93112
  const path = yield* Path$1;
93088
93113
  const home = yield* String$5("HOME");
93089
93114
  const directory = yield* unitDirectory;
93090
93115
  const unit = `deslop-${name}.service`;
93091
93116
  yield* fs.makeDirectory(directory, { recursive: true });
93092
- yield* fs.writeFileString(path.join(directory, unit), `[Unit]\nDescription=Deslop ${name}\nAfter=network-online.target\n\n[Service]\nType=simple\nEnvironment=NODE_ENV=production\nEnvironment=${systemdArgument(`PATH=${home}/.vite-plus/bin:/usr/local/bin:/usr/bin:/bin`)}\nEnvironmentFile=-${systemdArgument(`${home}/.deslop/${name}.env`)}\nExecStart=${join$3(map$8(command, systemdArgument), " ")}\nRestart=on-failure\nRestartSec=3\nUMask=0077\n\n[Install]\nWantedBy=default.target\n`, { mode: 384 });
93117
+ yield* fs.writeFileString(path.join(directory, unit), `[Unit]\nDescription=Deslop ${name}\nAfter=network-online.target\n\n[Service]\nType=simple\nEnvironment=NODE_ENV=production\nEnvironment=${systemdArgument(`PATH=${home}/.vite-plus/bin:/usr/local/bin:/usr/bin:/bin`)}\nEnvironmentFile=-${replaceAll("%", "%%")(`${home}/.deslop/${name}.env`)}\nExecStart=${join$3(map$8(command, systemdArgument), " ")}\nRestart=on-failure\nRestartSec=3\nUMask=0077\n\n[Install]\nWantedBy=default.target\n`, { mode: 384 });
93093
93118
  yield* systemctl("daemon-reload");
93094
93119
  yield* systemctl("enable", unit);
93095
- yield* systemctl("restart", unit);
93120
+ yield* systemctl(match$1(options?.restart === false, {
93121
+ onFalse: () => "restart",
93122
+ onTrue: () => "start"
93123
+ }), unit);
93096
93124
  return `${unit} installed\n`;
93097
93125
  });
93098
93126
  const installUpdates = fnUntraced(function* (name, command) {
@@ -93215,7 +93243,7 @@ const provider = fnUntraced(function* (given) {
93215
93243
  });
93216
93244
  const layerPlatform = mergeAll$2(layer$4, layer$12, layer$15);
93217
93245
  function server(app) {
93218
- return pipe(serve(pipe(mergeAll$2(app.routes, layerRoutes, layerIcon(app.icon), layerWeb), provide$2(Auth.layer)), {
93246
+ return pipe(serve(pipe(mergeAll$2(app.routes, layerRoutes, layerIcon(app.icon), layerWeb, layerAnnounce), provide$2(Auth.layer)), {
93219
93247
  disableLogger: true,
93220
93248
  middleware: (http) => guard(app.middleware?.(http) ?? http)
93221
93249
  }), provide$2(mergeAll$2(layerProtocol, match$1(app.telemetry === false, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/trips",
3
- "version": "0.1.1223",
3
+ "version": "0.1.1228",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MP281X/deslop",
@@ -31,5 +31,5 @@
31
31
  "engines": {
32
32
  "node": ">=26"
33
33
  },
34
- "fingerprint": "06b9b7b1b3bb4214a92655c41dd71a7deb43ef0f3411b586d3f29435a4351ff3"
34
+ "fingerprint": "294a6b28f68ce53485307760348f546385fbd35f11be8194ff209424a6184e61"
35
35
  }