@deslop/scope 0.1.1227 → 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 +47 -5
  2. package/package.json +2 -2
package/dist/server.js CHANGED
@@ -51040,6 +51040,23 @@ const compressBody = /*#__PURE__*/ dual((args) => isHttpClientRequest(args[0]),
51040
51040
  return map$5(compressBody$1(self.body, algorithm, options), (body) => body === self.body ? self : makeWith$1(self.method, self.url, self.urlParams, self.hash, set$1(updateContentLength(self.headers, body), "content-encoding", algorithm), body));
51041
51041
  });
51042
51042
  /**
51043
+ * Sets a JSON request body using unsafe JSON encoding.
51044
+ *
51045
+ * **When to use**
51046
+ *
51047
+ * Use when the request body is known to be JSON-serializable and a synchronous
51048
+ * `HttpClientRequest` result is needed.
51049
+ *
51050
+ * **Gotchas**
51051
+ *
51052
+ * JSON encoding may throw instead of failing in the Effect error channel.
51053
+ *
51054
+ * @stability unstable
51055
+ * @category combinators
51056
+ * @since 4.0.0
51057
+ */
51058
+ const bodyJsonUnsafe = /*#__PURE__*/ dual(2, (self, body) => setBody$1(self, jsonUnsafe$1(body)));
51059
+ /**
51043
51060
  * Builds a `URL` from the request URL, query parameters, and hash, returning `Option.none()` if the URL is invalid.
51044
51061
  *
51045
51062
  * @stability unstable
@@ -85386,6 +85403,8 @@ const SecureOrigin = Origin.check(makeFilter((value) => {
85386
85403
  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" }));
85387
85404
  const AppVersion = String$6.check(isPattern(/^0\.1\.\d+$/u));
85388
85405
  const RuntimeConfig = Struct({
85406
+ auth: optionalKey(String$6),
85407
+ name: String$6,
85389
85408
  traces: String$6,
85390
85409
  version: AppVersion
85391
85410
  });
@@ -86318,10 +86337,17 @@ const layerRoutes = use((router) => gen(function* () {
86318
86337
  })
86319
86338
  });
86320
86339
  });
86321
- yield* router.add("GET", "/api/runtime", flatMap$2(packageMetadata, (metadata) => schemaJson(RuntimeConfig)({
86322
- traces,
86323
- version: metadata.version
86324
- })));
86340
+ yield* router.add("GET", "/api/runtime", gen(function* () {
86341
+ return yield* schemaJson(RuntimeConfig)({
86342
+ ...match$8(issuer, {
86343
+ onNone: () => ({}),
86344
+ onSome: (origin) => ({ auth: origin })
86345
+ }),
86346
+ name: yield* appName,
86347
+ traces,
86348
+ version: (yield* packageMetadata).version
86349
+ });
86350
+ }));
86325
86351
  yield* router.add("GET", "/auth/sign-in", toIssuer({}));
86326
86352
  yield* router.add("GET", "/auth/sign-out", toIssuer({ "sign-out": "" }));
86327
86353
  yield* router.add("GET", "/auth/user", gen(function* () {
@@ -86333,6 +86359,22 @@ const layerRoutes = use((router) => gen(function* () {
86333
86359
  }, { headers: { "cache-control": "no-store" } });
86334
86360
  }));
86335
86361
  }));
86362
+ const layerAnnounce = effectDiscard(gen(function* () {
86363
+ const origin = new URL(yield* String$5("APP_URL")).origin;
86364
+ const client = filterStatusOk(yield* HttpClient);
86365
+ yield* match$8(yield* option(String$5("AUTH_URL")), {
86366
+ onNone: () => void_$1,
86367
+ onSome: fnUntraced(function* (issuer) {
86368
+ yield* pipe(post(new URL("/api/apps", issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
86369
+ schedule: spaced("1 minute"),
86370
+ times: 60
86371
+ }), ignore$1({
86372
+ log: "Warn",
86373
+ message: "Auth did not list this app"
86374
+ }), forkScoped);
86375
+ })
86376
+ });
86377
+ }));
86336
86378
  function layerIcon(icon) {
86337
86379
  return add("GET", "/icon", succeed$5(text(icon, {
86338
86380
  contentType: "image/svg+xml",
@@ -86575,7 +86617,7 @@ const provider = fnUntraced(function* (given) {
86575
86617
  });
86576
86618
  const layerPlatform = mergeAll$1(layer$3, layer$16, layer$13);
86577
86619
  function server(app) {
86578
- return pipe(serve(pipe(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb), provide$2(Auth.layer)), {
86620
+ return pipe(serve(pipe(mergeAll$1(app.routes, layerRoutes, layerIcon(app.icon), layerWeb, layerAnnounce), provide$2(Auth.layer)), {
86579
86621
  disableLogger: true,
86580
86622
  middleware: (http) => guard(app.middleware?.(http) ?? http)
86581
86623
  }), provide$2(mergeAll$1(layerProtocol, match$1(app.telemetry === false, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/scope",
3
- "version": "0.1.1227",
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": "f9689b8b84b7a0a2be75924eef22d9c79970ed10060bf792c678eaac3d9940af"
34
+ "fingerprint": "763e00c7c5f4f244233a2062bc61311fe78b2133b21400e5ceb1d4f7eaf8e33d"
35
35
  }